diff options
Diffstat (limited to 'testhal/STM32')
-rw-r--r-- | testhal/STM32/STM32F7xx/USB_CDC/main.c | 14 | ||||
-rw-r--r-- | testhal/STM32/STM32F7xx/USB_CDC/usbcfg.c | 18 | ||||
-rw-r--r-- | testhal/STM32/STM32F7xx/USB_CDC/usbcfg.h | 1 |
3 files changed, 27 insertions, 6 deletions
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.
*/
@@ -300,13 +302,25 @@ static void usb_event(USBDriver *usbp, usbevent_t event) { }
/*
+ * Handles the USB driver global events.
+ */
+static void sof_handler(USBDriver *usbp) {
+
+ (void)usbp;
+
+ osalSysLockFromISR();
+ sduSOFHookI(&SDU2);
+ osalSysUnlockFromISR();
+}
+
+/*
* USB driver configuration.
*/
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_ */
|