aboutsummaryrefslogtreecommitdiffstats
path: root/demos/STM32/RT-STM32F103-MAPLEMINI/main.c
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2015-12-25 12:45:23 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2015-12-25 12:45:23 +0000
commit2fdca55f58f29aa01be6a0b90728c902c20098ef (patch)
tree616b0a91bbf31c7882f292a44fccd99fef1d1151 /demos/STM32/RT-STM32F103-MAPLEMINI/main.c
parent6857f4ff339826e7c5b2f26cf19d6275208631e6 (diff)
downloadChibiOS-2fdca55f58f29aa01be6a0b90728c902c20098ef.tar.gz
ChibiOS-2fdca55f58f29aa01be6a0b90728c902c20098ef.tar.bz2
ChibiOS-2fdca55f58f29aa01be6a0b90728c902c20098ef.zip
Updated all USB demos.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8644 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'demos/STM32/RT-STM32F103-MAPLEMINI/main.c')
-rw-r--r--demos/STM32/RT-STM32F103-MAPLEMINI/main.c14
1 files changed, 10 insertions, 4 deletions
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");
}