From f5a8502a288742f80cbaeb094911d75efff82b28 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Thu, 5 Feb 2015 12:45:05 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7656 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- testhal/STM32/STM32F30x/USB_CDC_IAD/Makefile | 2 +- ...30x-USB_CDC_IAD (OpenOCD, Flash and Run).launch | 2 +- testhal/STM32/STM32F30x/USB_CDC_IAD/main.c | 6 ++-- testhal/STM32/STM32F30x/USB_CDC_IAD/usbcfg.c | 40 +++++++++++++++------- 4 files changed, 31 insertions(+), 19 deletions(-) (limited to 'testhal/STM32/STM32F30x/USB_CDC_IAD') diff --git a/testhal/STM32/STM32F30x/USB_CDC_IAD/Makefile b/testhal/STM32/STM32F30x/USB_CDC_IAD/Makefile index 4b3d40da0..2c5d529b2 100644 --- a/testhal/STM32/STM32F30x/USB_CDC_IAD/Makefile +++ b/testhal/STM32/STM32F30x/USB_CDC_IAD/Makefile @@ -5,7 +5,7 @@ # Compiler options here. ifeq ($(USE_OPT),) - USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16 + USE_OPT = -O0 -ggdb -fomit-frame-pointer -falign-functions=16 endif # C specific options here (added to USE_OPT). diff --git a/testhal/STM32/STM32F30x/USB_CDC_IAD/debug/STM32F30x-USB_CDC_IAD (OpenOCD, Flash and Run).launch b/testhal/STM32/STM32F30x/USB_CDC_IAD/debug/STM32F30x-USB_CDC_IAD (OpenOCD, Flash and Run).launch index 17c974b1e..4ba94fc0d 100644 --- a/testhal/STM32/STM32F30x/USB_CDC_IAD/debug/STM32F30x-USB_CDC_IAD (OpenOCD, Flash and Run).launch +++ b/testhal/STM32/STM32F30x/USB_CDC_IAD/debug/STM32F30x-USB_CDC_IAD (OpenOCD, Flash and Run).launch @@ -33,7 +33,7 @@ - + diff --git a/testhal/STM32/STM32F30x/USB_CDC_IAD/main.c b/testhal/STM32/STM32F30x/USB_CDC_IAD/main.c index af251fd18..b3d664317 100644 --- a/testhal/STM32/STM32F30x/USB_CDC_IAD/main.c +++ b/testhal/STM32/STM32F30x/USB_CDC_IAD/main.c @@ -189,8 +189,8 @@ int main(void) { */ sduObjectInit(&SDU1); sduStart(&SDU1, &serusbcfg1); -// sduObjectInit(&SDU2); -// sduStart(&SDU2, &serusbcfg2); + sduObjectInit(&SDU2); + sduStart(&SDU2, &serusbcfg2); /* * Activates the USB driver and then the USB bus pull-up on D+. @@ -223,14 +223,12 @@ int main(void) { chThdRelease(shelltp1); /* Recovers memory of the previous shell. */ shelltp1 = NULL; /* Triggers spawning of a new shell. */ } -#if 0 if (!shelltp2 && (SDU2.config->usbp->state == USB_ACTIVE)) shelltp2 = shellCreate(&shell_cfg2, SHELL_WA_SIZE, NORMALPRIO); else if (chThdTerminatedX(shelltp2)) { chThdRelease(shelltp2); /* Recovers memory of the previous shell. */ shelltp2 = NULL; /* Triggers spawning of a new shell. */ } -#endif chThdSleepMilliseconds(1000); } } diff --git a/testhal/STM32/STM32F30x/USB_CDC_IAD/usbcfg.c b/testhal/STM32/STM32F30x/USB_CDC_IAD/usbcfg.c index 3a06a9d2a..eb8fa26f1 100644 --- a/testhal/STM32/STM32F30x/USB_CDC_IAD/usbcfg.c +++ b/testhal/STM32/STM32F30x/USB_CDC_IAD/usbcfg.c @@ -29,7 +29,7 @@ /* * Interfaces */ -#define USB_NUM_INTERFACES 2 +#define USB_NUM_INTERFACES 4 #define USB_CDC_CIF_NUM0 0 #define USB_CDC_DIF_NUM0 1 #define USB_CDC_CIF_NUM1 2 @@ -64,7 +64,7 @@ static const USBDescriptor vcom_device_descriptor = { #define CDC_IF_DESC_SET_SIZE \ (USB_DESC_INTERFACE_SIZE + 5 + 5 + 4 + 5 + USB_DESC_ENDPOINT_SIZE + \ - USB_DESC_INTERFACE_SIZE + (USB_DESC_ENDPOINT_SIZE *2)) + USB_DESC_INTERFACE_SIZE + (USB_DESC_ENDPOINT_SIZE * 2)) #define CDC_IF_DESC_SET(comIfNum, datIfNum, comInEp, datOutEp, datInEp) \ /* Interface Descriptor.*/ \ @@ -122,17 +122,17 @@ static const USBDescriptor vcom_device_descriptor = { USB_DESC_ENDPOINT( \ datOutEp, /* bEndpointAddress. */ \ USB_EP_MODE_TYPE_BULK, /* bmAttributes. */ \ - 0x0040, /*ZZZZZ*/ /* wMaxPacketSize. */ \ + 0x0040, /* wMaxPacketSize. */ \ 0x00), /* bInterval. */ \ /* Endpoint, Bulk IN.*/ \ USB_DESC_ENDPOINT( \ datInEp, /* bEndpointAddress. */ \ USB_EP_MODE_TYPE_BULK, /* bmAttributes. */ \ - 0x0040, /*ZZZZZ*/ /* wMaxPacketSize. */ \ + 0x0040, /* wMaxPacketSize. */ \ 0x00) /* bInterval. */ -#define IAD_CDC_IF_DESC_SET_SIZE (USB_DESC_INTERFACE_ASSOCIATION_SIZE + \ - CDC_IF_DESC_SET_SIZE) +#define IAD_CDC_IF_DESC_SET_SIZE \ + (USB_DESC_INTERFACE_ASSOCIATION_SIZE + CDC_IF_DESC_SET_SIZE) #define IAD_CDC_IF_DESC_SET(comIfNum, datIfNum, comInEp, datOutEp, datInEp) \ /* Interface Association Descriptor.*/ \ @@ -152,7 +152,7 @@ static const uint8_t vcom_configuration_descriptor_data[] = { /* Configuration Descriptor.*/ USB_DESC_CONFIGURATION( USB_DESC_CONFIGURATION_SIZE + - (IAD_CDC_IF_DESC_SET_SIZE * 1), /* wTotalLength. */ + (IAD_CDC_IF_DESC_SET_SIZE * 2), /* wTotalLength. */ USB_NUM_INTERFACES, /* bNumInterfaces. */ 0x01, /* bConfigurationValue. */ 0, /* iConfiguration. */ @@ -166,13 +166,13 @@ static const uint8_t vcom_configuration_descriptor_data[] = { USB_ENDPOINT_OUT(USB_DATA_AVAILABLE_EP_A), USB_ENDPOINT_IN(USB_DATA_REQUEST_EP_A) ), -/* IAD_CDC_IF_DESC_SET( + IAD_CDC_IF_DESC_SET( USB_CDC_CIF_NUM1, USB_CDC_DIF_NUM1, USB_ENDPOINT_IN(USB_INTERRUPT_REQUEST_EP_B), USB_ENDPOINT_OUT(USB_DATA_AVAILABLE_EP_B), USB_ENDPOINT_IN(USB_DATA_REQUEST_EP_B) - ),*/ + ), }; /* @@ -374,12 +374,12 @@ static void usb_event(USBDriver *usbp, usbevent_t event) { must be used.*/ usbInitEndpointI(usbp, USB_INTERRUPT_REQUEST_EP_A, &ep1config); usbInitEndpointI(usbp, USB_DATA_REQUEST_EP_A, &ep2config); -// usbInitEndpointI(usbp, USB_INTERRUPT_REQUEST_EP_B, &ep3config); -// usbInitEndpointI(usbp, USB_DATA_REQUEST_EP_B, &ep4config); + usbInitEndpointI(usbp, USB_INTERRUPT_REQUEST_EP_B, &ep3config); + usbInitEndpointI(usbp, USB_DATA_REQUEST_EP_B, &ep4config); /* Resetting the state of the CDC subsystem.*/ sduConfigureHookI(&SDU1); -// sduConfigureHookI(&SDU2); + sduConfigureHookI(&SDU2); } else if (usbp->state == USB_SELECTED) { // usbDisableEndpointsI(usbp); @@ -397,13 +397,27 @@ static void usb_event(USBDriver *usbp, usbevent_t event) { return; } +/* + * Handling messages not implemented in the default handler nor in the + * SerialUSB handler. + */ +static bool requests_hook(USBDriver *usbp) { + + if (((usbp->setup[0] & USB_RTYPE_RECIPIENT_MASK) == USB_RTYPE_RECIPIENT_INTERFACE) && + (usbp->setup[1] == USB_REQ_SET_INTERFACE)) { + usbSetupTransfer(usbp, NULL, 0, NULL); + return true; + } + return sduRequestsHook(usbp); +} + /* * USB driver configuration. */ const USBConfig usbcfg = { usb_event, get_descriptor, - sduRequestsHook, + requests_hook, NULL }; -- cgit v1.2.3