From a3528b0e3edfb0667c39d61b21396fc852bd9fcd Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Tue, 22 Dec 2015 16:12:32 +0000 Subject: Updated Serial-USB driver using the new buffering mechanism. Only the STM32F4 CDC demo updated for it. Apparently it works. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8631 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- .../STM32F4xx-USB_CDC (OpenOCD, Flash and Run).launch | 2 +- testhal/STM32/STM32F4xx/USB_CDC/main.c | 3 --- testhal/STM32/STM32F4xx/USB_CDC/usbcfg.c | 18 ++++++++++++++++-- testhal/STM32/STM32F4xx/USB_CDC/usbcfg.h | 1 + 4 files changed, 18 insertions(+), 6 deletions(-) (limited to 'testhal/STM32') diff --git a/testhal/STM32/STM32F4xx/USB_CDC/debug/STM32F4xx-USB_CDC (OpenOCD, Flash and Run).launch b/testhal/STM32/STM32F4xx/USB_CDC/debug/STM32F4xx-USB_CDC (OpenOCD, Flash and Run).launch index 4a04bbd16..9f4df03ef 100644 --- a/testhal/STM32/STM32F4xx/USB_CDC/debug/STM32F4xx-USB_CDC (OpenOCD, Flash and Run).launch +++ b/testhal/STM32/STM32F4xx/USB_CDC/debug/STM32F4xx-USB_CDC (OpenOCD, Flash and Run).launch @@ -33,7 +33,7 @@ - + diff --git a/testhal/STM32/STM32F4xx/USB_CDC/main.c b/testhal/STM32/STM32F4xx/USB_CDC/main.c index 67cfec3da..37c0cfdc1 100644 --- a/testhal/STM32/STM32F4xx/USB_CDC/main.c +++ b/testhal/STM32/STM32F4xx/USB_CDC/main.c @@ -26,9 +26,6 @@ #include "usbcfg.h" -/* Virtual serial port over USB.*/ -SerialUSBDriver SDU1; - /*===========================================================================*/ /* Command line related. */ /*===========================================================================*/ diff --git a/testhal/STM32/STM32F4xx/USB_CDC/usbcfg.c b/testhal/STM32/STM32F4xx/USB_CDC/usbcfg.c index cfe1a7f5c..07a492758 100644 --- a/testhal/STM32/STM32F4xx/USB_CDC/usbcfg.c +++ b/testhal/STM32/STM32F4xx/USB_CDC/usbcfg.c @@ -14,9 +14,11 @@ limitations under the License. */ -#include "ch.h" #include "hal.h" +/* Virtual serial port over USB.*/ +SerialUSBDriver SDU1; + /* * Endpoints to be used for USBD1. */ @@ -299,6 +301,18 @@ static void usb_event(USBDriver *usbp, usbevent_t event) { return; } +/* + * Handles the USB driver global events. + */ +static void sof_handler(USBDriver *usbp) { + + (void)usbp; + + osalSysLockFromISR(); + sduSOFHookI(&SDU1); + osalSysUnlockFromISR(); +} + /* * USB driver configuration. */ @@ -306,7 +320,7 @@ const USBConfig usbcfg = { usb_event, get_descriptor, sduRequestsHook, - NULL + sof_handler }; /* diff --git a/testhal/STM32/STM32F4xx/USB_CDC/usbcfg.h b/testhal/STM32/STM32F4xx/USB_CDC/usbcfg.h index 2ffaa17f9..2da1c40a4 100644 --- a/testhal/STM32/STM32F4xx/USB_CDC/usbcfg.h +++ b/testhal/STM32/STM32F4xx/USB_CDC/usbcfg.h @@ -19,6 +19,7 @@ extern const USBConfig usbcfg; extern SerialUSBConfig serusbcfg; +extern SerialUSBDriver SDU1; #endif /* _USBCFG_H_ */ -- cgit v1.2.3