From a0a1b8177bbd8b88aefe21dc73e3270daa9f0e11 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Fri, 11 May 2012 09:28:04 +0900 Subject: [PATCH] Fixes for New USB stack --- ChangeLog | 10 ++++++++++ GNUK_USB_DEVICE_ID | 2 ++ src/main.c | 1 + src/usb-cdc.h | 3 +++ src/usb_desc.c | 1 + src/usb_endp.c | 1 + src/usb_prop.c | 47 +++++++++++++++++++++++----------------------- 7 files changed, 42 insertions(+), 23 deletions(-) create mode 100644 GNUK_USB_DEVICE_ID diff --git a/ChangeLog b/ChangeLog index a84ad3a..f88fe2d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 2012-05-11 Niibe Yutaka + * src/usb_prop.c (vcom_port_setup_with_nodata) Rename. + (vcom_port_data_setup): Rename and fix return value. + + * src/usb-cdc.h (VIRTUAL_COM_PORT_DATA_SIZE) + (VIRTUAL_COM_PORT_INT_SIZE): New. + + * src/main.c (#include): Add usb-cdc.h. + * src/usb_desc.c (#include): Add usb-cdc.h. + * src/usb_endp.c (#include): Add usb_lld.h. + * src/configure ($help): Add FST_01. 2012-05-10 Niibe Yutaka diff --git a/GNUK_USB_DEVICE_ID b/GNUK_USB_DEVICE_ID new file mode 100644 index 0000000..33f5407 --- /dev/null +++ b/GNUK_USB_DEVICE_ID @@ -0,0 +1,2 @@ +# VID:PID bcdDev Product_STRING Vender_STRING +234b:0000 0200 FSIJ USB Token Free Software Initiative of Japan diff --git a/src/main.c b/src/main.c index b838409..adf3c69 100644 --- a/src/main.c +++ b/src/main.c @@ -25,6 +25,7 @@ #include "ch.h" #include "gnuk.h" #include "usb_lld.h" +#include "usb-cdc.h" #ifdef DEBUG struct stdout { diff --git a/src/usb-cdc.h b/src/usb-cdc.h index 93fcd4e..d004c79 100644 --- a/src/usb-cdc.h +++ b/src/usb-cdc.h @@ -5,3 +5,6 @@ #define USB_CDC_REQ_GET_LINE_CODING 0x21 #define USB_CDC_REQ_SET_CONTROL_LINE_STATE 0x22 #define USB_CDC_REQ_SEND_BREAK 0x23 + +#define VIRTUAL_COM_PORT_DATA_SIZE 16 +#define VIRTUAL_COM_PORT_INT_SIZE 8 diff --git a/src/usb_desc.c b/src/usb_desc.c index caa7506..e814695 100644 --- a/src/usb_desc.c +++ b/src/usb_desc.c @@ -6,6 +6,7 @@ #include "ch.h" #include "usb_lld.h" #include "usb_conf.h" +#include "usb-cdc.h" #define USB_ICC_INTERFACE_CLASS 0x0B #define USB_ICC_INTERFACE_SUBCLASS 0x00 diff --git a/src/usb_endp.c b/src/usb_endp.c index 0870caa..ac60fe7 100644 --- a/src/usb_endp.c +++ b/src/usb_endp.c @@ -5,6 +5,7 @@ #include "config.h" #include "ch.h" #include "gnuk.h" +#include "usb_lld.h" void EP3_IN_Callback (void) diff --git a/src/usb_prop.c b/src/usb_prop.c index b5b03df..62a61a2 100644 --- a/src/usb_prop.c +++ b/src/usb_prop.c @@ -48,19 +48,18 @@ static const struct line_coding line_coding = { }; static void -Virtual_Com_Port_Data_Setup (uint8_t RequestNo) +vcom_port_data_setup (uint8_t RequestNo) { if (RequestNo != USB_CDC_REQ_GET_LINE_CODING) - return USB_UNSUPPORT; + return; /* RequestNo == USB_CDC_REQ_SET_LINE_CODING is not supported */ usb_lld_set_data_to_send (&line_coding, sizeof(line_coding)); - return USB_SUCCESS; } static int -Virtual_Com_Port_NoData_Setup (uint8_t RequestNo) +vcom_port_setup_with_nodata (uint8_t RequestNo) { if (RequestNo == USB_CDC_REQ_SET_CONTROL_LINE_STATE) /* Do nothing and success */ @@ -184,29 +183,31 @@ static void gnuk_setup_with_data (uint8_t recipient, uint8_t RequestNo, uint16_t index) { if (recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT)) /* Interface */ - if (index == 0) - { - if (RequestNo == USB_CCID_REQ_GET_CLOCK_FREQUENCIES) - usb_lld_set_data_to_send (freq_table, sizeof (freq_table)); - else if (RequestNo == USB_CCID_REQ_GET_DATA_RATES) - usb_lld_set_data_to_send (data_rate_table, sizeof (data_rate_table)); - } + { + if (index == 0) + { + if (RequestNo == USB_CCID_REQ_GET_CLOCK_FREQUENCIES) + usb_lld_set_data_to_send (freq_table, sizeof (freq_table)); + else if (RequestNo == USB_CCID_REQ_GET_DATA_RATES) + usb_lld_set_data_to_send (data_rate_table, sizeof (data_rate_table)); + } #if defined(PINPAD_DND_SUPPORT) # if defined(ENABLE_VIRTUAL_COM_PORT) - else if (index == 1) - Virtual_Com_Port_Data_Setup (RequestNo); - else if (index == 3) + else if (index == 1) + vcom_port_data_setup (RequestNo); + else if (index == 3) # else - else if (index == 1) + else if (index == 1) # endif - { - if (RequestNo == MSC_GET_MAX_LUN_COMMAND) - usb_lld_set_data_to_send (lun_table, sizeof (lun_table)); - } + { + if (RequestNo == MSC_GET_MAX_LUN_COMMAND) + usb_lld_set_data_to_send (lun_table, sizeof (lun_table)); + } #elif defined(ENABLE_VIRTUAL_COM_PORT) - else if (index == 1) - Virtual_Com_Port_Data_Setup (RequestNo); + else if (index == 1) + vcom_port_data_setup (RequestNo); #endif + } } @@ -226,7 +227,7 @@ gnuk_setup_with_nodata (uint8_t recipient, uint8_t RequestNo, uint16_t index) #if defined(PINPAD_DND_SUPPORT) # if defined(ENABLE_VIRTUAL_COM_PORT) else if (index == 1) - return Virtual_Com_Port_NoData_Setup (RequestNo); + return vcom_port_setup_with_nodata (RequestNo); else if (index == 3) # else else if (index == 1) @@ -242,7 +243,7 @@ gnuk_setup_with_nodata (uint8_t recipient, uint8_t RequestNo, uint16_t index) } #elif defined(ENABLE_VIRTUAL_COM_PORT) else if (index == 1) - return Virtual_Com_Port_NoData_Setup (RequestNo); + return vcom_port_setup_with_nodata (RequestNo); #endif else return USB_UNSUPPORT;