more parts of the config infrastructure
[usb-driver] / config.c
index c41590f1818fb30dca2155c5bdc245d2cb5accec..ba6b9a65ddc7ce8b9d665b5e5e37fdba6c58baba 100644 (file)
--- a/config.c
+++ b/config.c
@@ -1,5 +1,11 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <inttypes.h>
+#include "usb-driver.h"
+#include "parport.h"
+#ifdef JTAGKEY
+#include "jtagkey.h"
+#endif
 #include "config.h"
 
 static struct parport_config pp_config[4];
@@ -17,15 +23,37 @@ static void read_config() {
                pp_config[i].num = i;
                pp_config[i].ppbase = i*0x10;
                pp_config[i].real = 1;
+               pp_config[i].open = parport_open;
+               pp_config[i].close = parport_close;
+               pp_config[i].transfer = parport_transfer;
        }
 
 #ifdef JTAGKEY
        pp_config[3].real = 0;
        pp_config[3].usb_vid = 0x0403;
        pp_config[3].usb_pid = 0xcff8;
+       pp_config[3].open = jtagkey_open;
+       pp_config[3].close = jtagkey_close;
+       pp_config[3].transfer = jtagkey_transfer;
 #endif
 }
 
+struct parport_config *config_get(int num) {
+       struct parport_config *ret = NULL;
+       int i;
+
+       read_config();
+       
+       for (i=0; i<sizeof(pp_config)/sizeof(struct parport_config); i++) {
+               if (pp_config[i].num == num) {
+                       ret = &(pp_config[i]);
+                       break;
+               }
+       }
+
+       return ret;
+}
+
 unsigned char config_is_real_pport(int num) {
        int ret = 1;
        int i;
Impressum, Datenschutz