diff options
author | Giovanni Di Sirio <gdisirio@gmail.com> | 2015-12-28 11:16:40 +0000 |
---|---|---|
committer | Giovanni Di Sirio <gdisirio@gmail.com> | 2015-12-28 11:16:40 +0000 |
commit | de202dd376ea3109e21f535554647689dda23c7b (patch) | |
tree | e7247994911999dc69ab1755346057df768309bb /testhal/STM32/STM32F7xx | |
parent | d93fdcd424c049078009119940d0042bb229ed38 (diff) | |
download | ChibiOS-de202dd376ea3109e21f535554647689dda23c7b.tar.gz ChibiOS-de202dd376ea3109e21f535554647689dda23c7b.tar.bz2 ChibiOS-de202dd376ea3109e21f535554647689dda23c7b.zip |
New USB API finalized, updated OTGv1, USBv1 not yet updated.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8653 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'testhal/STM32/STM32F7xx')
-rw-r--r-- | testhal/STM32/STM32F7xx/USB_RAW/Makefile | 2 | ||||
-rw-r--r-- | testhal/STM32/STM32F7xx/USB_RAW/main.c | 39 |
2 files changed, 30 insertions, 11 deletions
diff --git a/testhal/STM32/STM32F7xx/USB_RAW/Makefile b/testhal/STM32/STM32F7xx/USB_RAW/Makefile index 8d169d51f..3988aeb34 100644 --- a/testhal/STM32/STM32F7xx/USB_RAW/Makefile +++ b/testhal/STM32/STM32F7xx/USB_RAW/Makefile @@ -5,7 +5,7 @@ # Compiler options here.
ifeq ($(USE_OPT),)
- USE_OPT = -O0 -ggdb -fomit-frame-pointer -falign-functions=16
+ USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16
endif
# C specific options here (added to USE_OPT).
diff --git a/testhal/STM32/STM32F7xx/USB_RAW/main.c b/testhal/STM32/STM32F7xx/USB_RAW/main.c index c2c4845e2..9d4011f00 100644 --- a/testhal/STM32/STM32F7xx/USB_RAW/main.c +++ b/testhal/STM32/STM32F7xx/USB_RAW/main.c @@ -23,8 +23,7 @@ #include "usbcfg.h"
-/* Can be measured using dd if=/dev/xxxx of=/dev/null bs=512 count=10000.*/
-static uint8_t buf[] =
+static const uint8_t txbuf[] =
"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
@@ -42,8 +41,12 @@ static uint8_t buf[] = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef";
+static uint8_t rxbuf[1024];
+
/*
- * Red LED blinker thread, times are in milliseconds.
+ * USB writer. This thread writes data to the USB at maximum rate.
+ * Can be measured using:
+ * dd if=/dev/xxxx of=/dev/null bs=512 count=10000
*/
static THD_WORKING_AREA(waWriter, 128);
static THD_FUNCTION(Writer, arg) {
@@ -51,13 +54,28 @@ static THD_FUNCTION(Writer, arg) { (void)arg;
chRegSetThreadName("writer");
while (true) {
- if (USBD2.state == USB_ACTIVE) {
- msg_t msg = usbTransmit(&USBD2, USBD2_DATA_REQUEST_EP,
- buf, sizeof (buf) - 1);
- if (msg == MSG_OK)
- continue;
- }
- chThdSleepMilliseconds(500);
+ msg_t msg = usbTransmit(&USBD2, USBD2_DATA_REQUEST_EP,
+ txbuf, sizeof (txbuf) - 1);
+ if (msg == MSG_RESET)
+ chThdSleepMilliseconds(500);
+ }
+}
+
+/*
+ * USB reader. This thread reads data from the USB at maximum rate.
+ * Can be measured using:
+ * dd if=bigfile of=/dev/xxx bs=512 count=10000
+ */
+static THD_WORKING_AREA(waReader, 128);
+static THD_FUNCTION(Reader, arg) {
+
+ (void)arg;
+ chRegSetThreadName("reader");
+ while (true) {
+ msg_t msg = usbReceive(&USBD2, USBD2_DATA_AVAILABLE_EP,
+ rxbuf, sizeof (rxbuf) - 1);
+ if (msg == MSG_RESET)
+ chThdSleepMilliseconds(500);
}
}
@@ -116,6 +134,7 @@ int main(void) { */
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
chThdCreateStatic(waWriter, sizeof(waWriter), NORMALPRIO, Writer, NULL);
+ chThdCreateStatic(waReader, sizeof(waReader), NORMALPRIO, Reader, NULL);
/*
* Normal main() thread activity, in this demo it does nothing except
|