diff options
Diffstat (limited to 'testhal/STM32/STM32F3xx/USB_CDC_IAD/main.c')
-rw-r--r-- | testhal/STM32/STM32F3xx/USB_CDC_IAD/main.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/testhal/STM32/STM32F3xx/USB_CDC_IAD/main.c b/testhal/STM32/STM32F3xx/USB_CDC_IAD/main.c index bada16558..6023f418d 100644 --- a/testhal/STM32/STM32F3xx/USB_CDC_IAD/main.c +++ b/testhal/STM32/STM32F3xx/USB_CDC_IAD/main.c @@ -33,12 +33,6 @@ #define usb_lld_connect_bus(usbp)
#define usb_lld_disconnect_bus(usbp)
-/*
- * Virtual serial ports over USB.
- */
-SerialUSBDriver SDU1;
-SerialUSBDriver SDU2;
-
/*===========================================================================*/
/* Command line related. */
/*===========================================================================*/
@@ -97,6 +91,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"
@@ -123,7 +118,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");
}
|