aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--demos/STM32/RT-STM32F407-OLIMEX_E407-LWIP-FATFS-USB/main.c6
-rw-r--r--os/hal/ports/STM32/LLD/OTGv1/usb_lld.c4
-rw-r--r--os/hal/ports/STM32/LLD/USBv1/usb_lld.c10
-rw-r--r--testhal/STM32/STM32F0xx/USB_CDC/main.c6
-rw-r--r--testhal/STM32/STM32F1xx/USB_CDC/main.c6
-rw-r--r--testhal/STM32/STM32F30x/USB_CDC/main.c6
-rw-r--r--testhal/STM32/STM32F30x/USB_CDC_IAD/usbcfg.c7
-rw-r--r--testhal/STM32/STM32F37x/USB_CDC/main.c6
-rw-r--r--testhal/STM32/STM32F4xx/USB_CDC/Makefile2
-rw-r--r--testhal/STM32/STM32F4xx/USB_CDC/usbcfg.c6
-rw-r--r--testhal/STM32/STM32F4xx/USB_CDC_IAD/Makefile2
-rw-r--r--testhal/STM32/STM32F4xx/USB_CDC_IAD/usbcfg.c7
12 files changed, 60 insertions, 8 deletions
diff --git a/demos/STM32/RT-STM32F407-OLIMEX_E407-LWIP-FATFS-USB/main.c b/demos/STM32/RT-STM32F407-OLIMEX_E407-LWIP-FATFS-USB/main.c
index 4e114a51a..5f2888452 100644
--- a/demos/STM32/RT-STM32F407-OLIMEX_E407-LWIP-FATFS-USB/main.c
+++ b/demos/STM32/RT-STM32F407-OLIMEX_E407-LWIP-FATFS-USB/main.c
@@ -425,6 +425,12 @@ static void usb_event(USBDriver *usbp, usbevent_t event) {
chSysUnlockFromISR();
return;
case USB_EVENT_SUSPEND:
+ chSysLockFromISR();
+
+ /* Disconnection event on suspend.*/
+ sduDisconnectI(&SDU2);
+
+ chSysUnlockFromISR();
return;
case USB_EVENT_WAKEUP:
return;
diff --git a/os/hal/ports/STM32/LLD/OTGv1/usb_lld.c b/os/hal/ports/STM32/LLD/OTGv1/usb_lld.c
index b6d2f1cdd..6d8e01538 100644
--- a/os/hal/ports/STM32/LLD/OTGv1/usb_lld.c
+++ b/os/hal/ports/STM32/LLD/OTGv1/usb_lld.c
@@ -320,7 +320,7 @@ static void otg_fifo_read_to_buffer(volatile uint32_t *fifop,
uint8_t *buf,
size_t n,
size_t max) {
- uint32_t w;
+ uint32_t w = 0;
size_t i;
i = 0;
@@ -348,7 +348,7 @@ static void otg_fifo_read_to_buffer(volatile uint32_t *fifop,
static void otg_fifo_read_to_queue(volatile uint32_t *fifop,
input_queue_t *iqp,
size_t n) {
- uint32_t w;
+ uint32_t w = 0;
size_t i;
i = 0;
diff --git a/os/hal/ports/STM32/LLD/USBv1/usb_lld.c b/os/hal/ports/STM32/LLD/USBv1/usb_lld.c
index 19369892e..c6ccc16da 100644
--- a/os/hal/ports/STM32/LLD/USBv1/usb_lld.c
+++ b/os/hal/ports/STM32/LLD/USBv1/usb_lld.c
@@ -316,19 +316,20 @@ OSAL_IRQ_HANDLER(STM32_USB1_LP_HANDLER) {
/* USB bus reset condition handling.*/
if (istr & ISTR_RESET) {
- _usb_reset(usbp);
- _usb_isr_invoke_event_cb(usbp, USB_EVENT_RESET);
STM32_USB->ISTR = ~ISTR_RESET;
+
+ _usb_reset(usbp);
}
/* USB bus SUSPEND condition handling.*/
if (istr & ISTR_SUSP) {
STM32_USB->CNTR |= CNTR_FSUSP;
- _usb_isr_invoke_event_cb(usbp, USB_EVENT_SUSPEND);
#if STM32_USB_LOW_POWER_ON_SUSPEND
STM32_USB->CNTR |= CNTR_LP_MODE;
#endif
STM32_USB->ISTR = ~ISTR_SUSP;
+
+ _usb_suspend(usbp);
}
/* USB bus WAKEUP condition handling.*/
@@ -336,7 +337,8 @@ OSAL_IRQ_HANDLER(STM32_USB1_LP_HANDLER) {
uint32_t fnr = STM32_USB->FNR;
if (!(fnr & FNR_RXDP)) {
STM32_USB->CNTR &= ~CNTR_FSUSP;
- _usb_isr_invoke_event_cb(usbp, USB_EVENT_WAKEUP);
+
+ _usb_wakeup(usbp);
}
#if STM32_USB_LOW_POWER_ON_SUSPEND
else {
diff --git a/testhal/STM32/STM32F0xx/USB_CDC/main.c b/testhal/STM32/STM32F0xx/USB_CDC/main.c
index 2866b85ce..c37010da5 100644
--- a/testhal/STM32/STM32F0xx/USB_CDC/main.c
+++ b/testhal/STM32/STM32F0xx/USB_CDC/main.c
@@ -299,6 +299,12 @@ static void usb_event(USBDriver *usbp, usbevent_t event) {
chSysUnlockFromISR();
return;
case USB_EVENT_SUSPEND:
+ chSysLockFromISR();
+
+ /* Disconnection event on suspend.*/
+ sduDisconnectI(&SDU1);
+
+ chSysUnlockFromISR();
return;
case USB_EVENT_WAKEUP:
return;
diff --git a/testhal/STM32/STM32F1xx/USB_CDC/main.c b/testhal/STM32/STM32F1xx/USB_CDC/main.c
index eae64e0b5..5148d3eba 100644
--- a/testhal/STM32/STM32F1xx/USB_CDC/main.c
+++ b/testhal/STM32/STM32F1xx/USB_CDC/main.c
@@ -299,6 +299,12 @@ static void usb_event(USBDriver *usbp, usbevent_t event) {
chSysUnlockFromISR();
return;
case USB_EVENT_SUSPEND:
+ chSysLockFromISR();
+
+ /* Disconnection event on suspend.*/
+ sduDisconnectI(&SDU1);
+
+ chSysUnlockFromISR();
return;
case USB_EVENT_WAKEUP:
return;
diff --git a/testhal/STM32/STM32F30x/USB_CDC/main.c b/testhal/STM32/STM32F30x/USB_CDC/main.c
index c40a82cb1..c99d56466 100644
--- a/testhal/STM32/STM32F30x/USB_CDC/main.c
+++ b/testhal/STM32/STM32F30x/USB_CDC/main.c
@@ -306,6 +306,12 @@ static void usb_event(USBDriver *usbp, usbevent_t event) {
chSysUnlockFromISR();
return;
case USB_EVENT_SUSPEND:
+ chSysLockFromISR();
+
+ /* Disconnection event on suspend.*/
+ sduDisconnectI(&SDU1);
+
+ chSysUnlockFromISR();
return;
case USB_EVENT_WAKEUP:
return;
diff --git a/testhal/STM32/STM32F30x/USB_CDC_IAD/usbcfg.c b/testhal/STM32/STM32F30x/USB_CDC_IAD/usbcfg.c
index ef55d2bd8..70e55dbba 100644
--- a/testhal/STM32/STM32F30x/USB_CDC_IAD/usbcfg.c
+++ b/testhal/STM32/STM32F30x/USB_CDC_IAD/usbcfg.c
@@ -394,6 +394,13 @@ static void usb_event(USBDriver *usbp, usbevent_t event) {
chSysUnlockFromISR();
return;
case USB_EVENT_SUSPEND:
+ chSysLockFromISR();
+
+ /* Disconnection event on suspend.*/
+ sduDisconnectI(&SDU1);
+ sduDisconnectI(&SDU2);
+
+ chSysUnlockFromISR();
return;
case USB_EVENT_WAKEUP:
return;
diff --git a/testhal/STM32/STM32F37x/USB_CDC/main.c b/testhal/STM32/STM32F37x/USB_CDC/main.c
index 9eea7d19c..55252de37 100644
--- a/testhal/STM32/STM32F37x/USB_CDC/main.c
+++ b/testhal/STM32/STM32F37x/USB_CDC/main.c
@@ -305,6 +305,12 @@ static void usb_event(USBDriver *usbp, usbevent_t event) {
chSysUnlockFromISR();
return;
case USB_EVENT_SUSPEND:
+ chSysLockFromISR();
+
+ /* Disconnection event on suspend.*/
+ sduDisconnectI(&SDU1);
+
+ chSysUnlockFromISR();
return;
case USB_EVENT_WAKEUP:
return;
diff --git a/testhal/STM32/STM32F4xx/USB_CDC/Makefile b/testhal/STM32/STM32F4xx/USB_CDC/Makefile
index a8a9dd05c..48f6caeb3 100644
--- a/testhal/STM32/STM32F4xx/USB_CDC/Makefile
+++ b/testhal/STM32/STM32F4xx/USB_CDC/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/STM32F4xx/USB_CDC/usbcfg.c b/testhal/STM32/STM32F4xx/USB_CDC/usbcfg.c
index f825ec239..cfe1a7f5c 100644
--- a/testhal/STM32/STM32F4xx/USB_CDC/usbcfg.c
+++ b/testhal/STM32/STM32F4xx/USB_CDC/usbcfg.c
@@ -284,6 +284,12 @@ static void usb_event(USBDriver *usbp, usbevent_t event) {
chSysUnlockFromISR();
return;
case USB_EVENT_SUSPEND:
+ chSysLockFromISR();
+
+ /* Disconnection event on suspend.*/
+ sduDisconnectI(&SDU1);
+
+ chSysUnlockFromISR();
return;
case USB_EVENT_WAKEUP:
return;
diff --git a/testhal/STM32/STM32F4xx/USB_CDC_IAD/Makefile b/testhal/STM32/STM32F4xx/USB_CDC_IAD/Makefile
index 56351076a..d5e19d9a2 100644
--- a/testhal/STM32/STM32F4xx/USB_CDC_IAD/Makefile
+++ b/testhal/STM32/STM32F4xx/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/STM32F4xx/USB_CDC_IAD/usbcfg.c b/testhal/STM32/STM32F4xx/USB_CDC_IAD/usbcfg.c
index 5abf0f520..873bea31e 100644
--- a/testhal/STM32/STM32F4xx/USB_CDC_IAD/usbcfg.c
+++ b/testhal/STM32/STM32F4xx/USB_CDC_IAD/usbcfg.c
@@ -394,6 +394,13 @@ static void usb_event(USBDriver *usbp, usbevent_t event) {
chSysUnlockFromISR();
return;
case USB_EVENT_SUSPEND:
+ chSysLockFromISR();
+
+ /* Disconnection event on suspend.*/
+ sduDisconnectI(&SDU1);
+ sduDisconnectI(&SDU2);
+
+ chSysUnlockFromISR();
return;
case USB_EVENT_WAKEUP:
return;