]> cvs.zerfleddert.de Git - usb-driver/blob - config.c
remove outdated comment
[usb-driver] / config.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <inttypes.h>
4 #include "usb-driver.h"
5 #include "parport.h"
6 #ifdef JTAGKEY
7 #include "jtagkey.h"
8 #endif
9 #include "config.h"
10
11 static struct parport_config pp_config[4];
12
13 static void read_config() {
14 int i;
15 static int config_read = 0;
16
17 if (config_read)
18 return;
19
20 config_read = 1;
21
22 for (i=0; i<sizeof(pp_config)/sizeof(struct parport_config); i++) {
23 pp_config[i].num = i;
24 pp_config[i].ppbase = i*0x10;
25 pp_config[i].real = 1;
26 pp_config[i].open = parport_open;
27 pp_config[i].close = parport_close;
28 pp_config[i].transfer = parport_transfer;
29 }
30
31 #ifdef JTAGKEY
32 pp_config[3].real = 0;
33 pp_config[3].usb_vid = 0x0403;
34 pp_config[3].usb_pid = 0xcff8;
35 pp_config[3].open = jtagkey_open;
36 pp_config[3].close = jtagkey_close;
37 pp_config[3].transfer = jtagkey_transfer;
38 #endif
39 }
40
41 struct parport_config *config_get(int num) {
42 struct parport_config *ret = NULL;
43 int i;
44
45 read_config();
46
47 for (i=0; i<sizeof(pp_config)/sizeof(struct parport_config); i++) {
48 if (pp_config[i].num == num) {
49 ret = &(pp_config[i]);
50 break;
51 }
52 }
53
54 return ret;
55 }
56
57 unsigned char config_is_real_pport(int num) {
58 int ret = 1;
59 int i;
60
61 read_config();
62
63 for (i=0; i<sizeof(pp_config)/sizeof(struct parport_config); i++) {
64 if (pp_config[i].num == num) {
65 ret = pp_config[i].real;
66 break;
67 }
68 }
69
70 return ret;
71 }
72
73 unsigned short config_usb_vid(int num) {
74 unsigned short ret = 0x00;
75 int i;
76
77 read_config();
78
79 for (i=0; i<sizeof(pp_config)/sizeof(struct parport_config); i++) {
80 if (pp_config[i].num == num) {
81 ret = pp_config[i].usb_vid;
82 break;
83 }
84 }
85
86 return ret;
87 }
88
89 unsigned short config_usb_pid(int num) {
90 unsigned short ret = 0x00;
91 int i;
92
93 read_config();
94
95 for (i=0; i<sizeof(pp_config)/sizeof(struct parport_config); i++) {
96 if (pp_config[i].num == num) {
97 ret = pp_config[i].usb_pid;
98 break;
99 }
100 }
101
102 return ret;
103 }
Impressum, Datenschutz