aboutsummaryrefslogtreecommitdiffstats
path: root/testhal/STM32F4xx/USB_CDC
diff options
context:
space:
mode:
Diffstat (limited to 'testhal/STM32F4xx/USB_CDC')
-rw-r--r--testhal/STM32F4xx/USB_CDC/Makefile2
-rw-r--r--testhal/STM32F4xx/USB_CDC/main.c11
2 files changed, 9 insertions, 4 deletions
diff --git a/testhal/STM32F4xx/USB_CDC/Makefile b/testhal/STM32F4xx/USB_CDC/Makefile
index 233e47d0e..1a6ac2d74 100644
--- a/testhal/STM32F4xx/USB_CDC/Makefile
+++ b/testhal/STM32F4xx/USB_CDC/Makefile
@@ -5,7 +5,7 @@
# Compiler options here.
ifeq ($(USE_OPT),)
- USE_OPT = -O0 -ggdb -fomit-frame-pointer -falign-functions=16
+ USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16
endif
# C specific options here (added to USE_OPT).
diff --git a/testhal/STM32F4xx/USB_CDC/main.c b/testhal/STM32F4xx/USB_CDC/main.c
index 0ae9c81e0..99acdc894 100644
--- a/testhal/STM32F4xx/USB_CDC/main.c
+++ b/testhal/STM32F4xx/USB_CDC/main.c
@@ -296,13 +296,18 @@ static void usb_event(USBDriver *usbp, usbevent_t event) {
case USB_EVENT_ADDRESS:
return;
case USB_EVENT_CONFIGURED:
+ chSysLockFromIsr();
+
/* Enables the endpoints specified into the configuration.
Note, this callback is invoked from an ISR so I-Class functions
must be used.*/
- chSysLockFromIsr();
usbInitEndpointI(usbp, USB_CDC_DATA_REQUEST_EP, &ep1config);
usbInitEndpointI(usbp, USB_CDC_INTERRUPT_REQUEST_EP, &ep2config);
usbInitEndpointI(usbp, USB_CDC_DATA_AVAILABLE_EP, &ep3config);
+
+ /* Resetting the state of the CDC subsystem.*/
+ sduConfigureHookI(usbp);
+
chSysUnlockFromIsr();
return;
case USB_EVENT_SUSPEND:
@@ -437,10 +442,10 @@ int main(void) {
/*
* Activates the USB driver and then the USB bus pull-up on D+.
*/
+ usbDisconnectBus(serusbcfg.usbp);
+ chThdSleepMilliseconds(1000);
sduObjectInit(&SDU1);
sduStart(&SDU1, &serusbcfg);
- usbDisconnectBus(serusbcfg.usbp);
- chThdSleepMilliseconds(100);
usbConnectBus(serusbcfg.usbp);
/*