aboutsummaryrefslogtreecommitdiffstats
path: root/testhal/STM32/STM32F4xx/USB_CDC_IAD
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2015-12-25 08:59:10 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2015-12-25 08:59:10 +0000
commit4b601a5d0fd06f8e238c17fb96633100ecc59503 (patch)
tree0ed28cfc2e87f0a346850c49a9343df30604f218 /testhal/STM32/STM32F4xx/USB_CDC_IAD
parent6a20a7107a016a4cb43c3f98362b447f883db8c8 (diff)
downloadChibiOS-4b601a5d0fd06f8e238c17fb96633100ecc59503.tar.gz
ChibiOS-4b601a5d0fd06f8e238c17fb96633100ecc59503.tar.bz2
ChibiOS-4b601a5d0fd06f8e238c17fb96633100ecc59503.zip
USB upgrade.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8641 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'testhal/STM32/STM32F4xx/USB_CDC_IAD')
-rw-r--r--testhal/STM32/STM32F4xx/USB_CDC_IAD/main.c17
-rw-r--r--testhal/STM32/STM32F4xx/USB_CDC_IAD/usbcfg.c21
-rw-r--r--testhal/STM32/STM32F4xx/USB_CDC_IAD/usbcfg.h2
3 files changed, 32 insertions, 8 deletions
diff --git a/testhal/STM32/STM32F4xx/USB_CDC_IAD/main.c b/testhal/STM32/STM32F4xx/USB_CDC_IAD/main.c
index 7827acf47..486942104 100644
--- a/testhal/STM32/STM32F4xx/USB_CDC_IAD/main.c
+++ b/testhal/STM32/STM32F4xx/USB_CDC_IAD/main.c
@@ -26,12 +26,6 @@
#include "usbcfg.h"
-/*
- * Virtual serial ports over USB.
- */
-SerialUSBDriver SDU1;
-SerialUSBDriver SDU2;
-
/*===========================================================================*/
/* Command line related. */
/*===========================================================================*/
@@ -90,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"
@@ -116,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");
}
diff --git a/testhal/STM32/STM32F4xx/USB_CDC_IAD/usbcfg.c b/testhal/STM32/STM32F4xx/USB_CDC_IAD/usbcfg.c
index 873bea31e..14bd5ed32 100644
--- a/testhal/STM32/STM32F4xx/USB_CDC_IAD/usbcfg.c
+++ b/testhal/STM32/STM32F4xx/USB_CDC_IAD/usbcfg.c
@@ -16,6 +16,12 @@
#include "hal.h"
+/*
+ * Virtual serial ports over USB.
+ */
+SerialUSBDriver SDU1;
+SerialUSBDriver SDU2;
+
#define USB_DEVICE_VID 0xF055 /* You MUST change this.*/
#define USB_DEVICE_PID 0xE063 /* You MUST change this.*/
@@ -425,13 +431,26 @@ static bool requests_hook(USBDriver *usbp) {
}
/*
+ * Handles the USB driver global events.
+ */
+static void sof_handler(USBDriver *usbp) {
+
+ (void)usbp;
+
+ osalSysLockFromISR();
+ sduSOFHookI(&SDU1);
+ sduSOFHookI(&SDU2);
+ osalSysUnlockFromISR();
+}
+
+/*
* USB driver configuration.
*/
const USBConfig usbcfg = {
usb_event,
get_descriptor,
requests_hook,
- NULL
+ sof_handler
};
/*
diff --git a/testhal/STM32/STM32F4xx/USB_CDC_IAD/usbcfg.h b/testhal/STM32/STM32F4xx/USB_CDC_IAD/usbcfg.h
index a97780b09..7c6aaebf3 100644
--- a/testhal/STM32/STM32F4xx/USB_CDC_IAD/usbcfg.h
+++ b/testhal/STM32/STM32F4xx/USB_CDC_IAD/usbcfg.h
@@ -20,6 +20,8 @@
extern const USBConfig usbcfg;
extern SerialUSBConfig serusbcfg1;
extern SerialUSBConfig serusbcfg2;
+extern SerialUSBDriver SDU1;
+extern SerialUSBDriver SDU2;
#endif /* _USBCFG_H_ */