From 2296afaa34c8f4c19750a410e336b6f565918bcc Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Thu, 24 Dec 2015 07:53:33 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8637 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- testhal/STM32/STM32F7xx/USB_CDC/main.c | 14 ++++++++++---- testhal/STM32/STM32F7xx/USB_CDC/usbcfg.c | 18 ++++++++++++++++-- testhal/STM32/STM32F7xx/USB_CDC/usbcfg.h | 1 + 3 files changed, 27 insertions(+), 6 deletions(-) (limited to 'testhal/STM32/STM32F7xx/USB_CDC') diff --git a/testhal/STM32/STM32F7xx/USB_CDC/main.c b/testhal/STM32/STM32F7xx/USB_CDC/main.c index a2b393720..f2e56dedc 100644 --- a/testhal/STM32/STM32F7xx/USB_CDC/main.c +++ b/testhal/STM32/STM32F7xx/USB_CDC/main.c @@ -26,9 +26,6 @@ #include "usbcfg.h" -/* Virtual serial port over USB.*/ -SerialUSBDriver SDU2; - /*===========================================================================*/ /* Command line related. */ /*===========================================================================*/ @@ -87,6 +84,7 @@ static void cmd_test(BaseSequentialStream *chp, int argc, char *argv[]) { chThdWait(tp); } +/* Can be measured using dd if=/dev/xxxx of=/dev/null bs=512 count=10000.*/ static void cmd_write(BaseSequentialStream *chp, int argc, char *argv[]) { static uint8_t buf[] = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" @@ -113,7 +111,15 @@ static void cmd_write(BaseSequentialStream *chp, int argc, char *argv[]) { } while (chnGetTimeout((BaseChannel *)chp, TIME_IMMEDIATE) == Q_TIMEOUT) { - chSequentialStreamWrite(&SDU2, buf, sizeof buf - 1); +#if 1 + /* Writing in stream mode.*/ + streamWrite(&SDU2, buf, sizeof buf - 1); +#else + /* Writing in buffer mode.*/ + (void) obqGetEmptyBufferTimeout(&SDU2.obqueue, TIME_INFINITE); + memcpy(SDU2.obqueue.ptr, buf, SERIAL_USB_BUFFERS_SIZE); + obqPostFullBuffer(&SDU2.obqueue, SERIAL_USB_BUFFERS_SIZE); +#endif } chprintf(chp, "\r\n\nstopped\r\n"); } diff --git a/testhal/STM32/STM32F7xx/USB_CDC/usbcfg.c b/testhal/STM32/STM32F7xx/USB_CDC/usbcfg.c index 968fd6724..6d1e45865 100644 --- a/testhal/STM32/STM32F7xx/USB_CDC/usbcfg.c +++ b/testhal/STM32/STM32F7xx/USB_CDC/usbcfg.c @@ -14,9 +14,11 @@ limitations under the License. */ -#include "ch.h" #include "hal.h" +/* Virtual serial port over USB.*/ +SerialUSBDriver SDU2; + /* * Endpoints to be used for USBD2. */ @@ -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(&SDU2); + osalSysUnlockFromISR(); +} + /* * USB driver configuration. */ @@ -306,7 +320,7 @@ const USBConfig usbcfg = { usb_event, get_descriptor, sduRequestsHook, - NULL + sof_handler }; /* diff --git a/testhal/STM32/STM32F7xx/USB_CDC/usbcfg.h b/testhal/STM32/STM32F7xx/USB_CDC/usbcfg.h index 2ffaa17f9..333a5f9d3 100644 --- a/testhal/STM32/STM32F7xx/USB_CDC/usbcfg.h +++ b/testhal/STM32/STM32F7xx/USB_CDC/usbcfg.h @@ -19,6 +19,7 @@ extern const USBConfig usbcfg; extern SerialUSBConfig serusbcfg; +extern SerialUSBDriver SDU2; #endif /* _USBCFG_H_ */ -- cgit v1.2.3