From 2fdca55f58f29aa01be6a0b90728c902c20098ef Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Fri, 25 Dec 2015 12:45:23 +0000 Subject: Updated all USB demos. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8644 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/STM32/RT-STM32F103-MAPLEMINI/main.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'demos/STM32/RT-STM32F103-MAPLEMINI/main.c') diff --git a/demos/STM32/RT-STM32F103-MAPLEMINI/main.c b/demos/STM32/RT-STM32F103-MAPLEMINI/main.c index 44eddabd1..5ce15913b 100644 --- a/demos/STM32/RT-STM32F103-MAPLEMINI/main.c +++ b/demos/STM32/RT-STM32F103-MAPLEMINI/main.c @@ -26,9 +26,6 @@ #include "usbcfg.h" -/* Virtual serial port over USB.*/ -SerialUSBDriver SDU1; - /*===========================================================================*/ /* 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(&SDU1, buf, sizeof buf - 1); +#if 1 + /* Writing in channel mode.*/ + chnWrite(&SDU1, buf, sizeof buf - 1); +#else + /* Writing in buffer mode.*/ + (void) obqGetEmptyBufferTimeout(&SDU1.obqueue, TIME_INFINITE); + memcpy(SDU1.obqueue.ptr, buf, SERIAL_USB_BUFFERS_SIZE); + obqPostFullBuffer(&SDU1.obqueue, SERIAL_USB_BUFFERS_SIZE); +#endif } chprintf(chp, "\r\n\nstopped\r\n"); } -- cgit v1.2.3