]>
Commit | Line | Data |
---|---|---|
1 | #include <stdio.h> | |
2 | #include <stdlib.h> | |
3 | #include "config.h" | |
4 | ||
5 | static struct parport_config pp_config[4]; | |
6 | ||
7 | static void read_config() { | |
8 | int i; | |
9 | static int config_read = 0; | |
10 | ||
11 | if (config_read) | |
12 | return; | |
13 | ||
14 | config_read = 1; | |
15 | ||
16 | for (i=0; i<sizeof(pp_config)/sizeof(struct parport_config); i++) { | |
17 | pp_config[i].num = i; | |
18 | pp_config[i].ppbase = i*0x10; | |
19 | pp_config[i].real = 1; | |
20 | } | |
21 | ||
22 | #ifdef JTAGKEY | |
23 | pp_config[3].real = 0; | |
24 | pp_config[3].usb_vid = 0x0403; | |
25 | pp_config[3].usb_pid = 0xcff8; | |
26 | #endif | |
27 | } | |
28 | ||
29 | unsigned char config_is_real_pport(int num) { | |
30 | int ret = 1; | |
31 | int i; | |
32 | ||
33 | read_config(); | |
34 | ||
35 | for (i=0; i<sizeof(pp_config)/sizeof(struct parport_config); i++) { | |
36 | if (pp_config[i].num == num) { | |
37 | ret = pp_config[i].real; | |
38 | break; | |
39 | } | |
40 | } | |
41 | ||
42 | return ret; | |
43 | } | |
44 | ||
45 | unsigned short config_usb_vid(int num) { | |
46 | unsigned short ret = 0x00; | |
47 | int i; | |
48 | ||
49 | read_config(); | |
50 | ||
51 | for (i=0; i<sizeof(pp_config)/sizeof(struct parport_config); i++) { | |
52 | if (pp_config[i].num == num) { | |
53 | ret = pp_config[i].usb_vid; | |
54 | break; | |
55 | } | |
56 | } | |
57 | ||
58 | return ret; | |
59 | } | |
60 | ||
61 | unsigned short config_usb_pid(int num) { | |
62 | unsigned short ret = 0x00; | |
63 | int i; | |
64 | ||
65 | read_config(); | |
66 | ||
67 | for (i=0; i<sizeof(pp_config)/sizeof(struct parport_config); i++) { | |
68 | if (pp_config[i].num == num) { | |
69 | ret = pp_config[i].usb_pid; | |
70 | break; | |
71 | } | |
72 | } | |
73 | ||
74 | return ret; | |
75 | } |