aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2015-12-24 07:53:33 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2015-12-24 07:53:33 +0000
commit2296afaa34c8f4c19750a410e336b6f565918bcc (patch)
tree5867173aa747d12989d551a2eadf7c746c87160d
parentd9973ea126e8eb0a740312e70b8b41efe12f1112 (diff)
downloadChibiOS-2296afaa34c8f4c19750a410e336b6f565918bcc.tar.gz
ChibiOS-2296afaa34c8f4c19750a410e336b6f565918bcc.tar.bz2
ChibiOS-2296afaa34c8f4c19750a410e336b6f565918bcc.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8637 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r--os/hal/src/hal_buffers.c4
-rw-r--r--testhal/STM32/STM32F7xx/USB_CDC/main.c14
-rw-r--r--testhal/STM32/STM32F7xx/USB_CDC/usbcfg.c18
-rw-r--r--testhal/STM32/STM32F7xx/USB_CDC/usbcfg.h1
4 files changed, 29 insertions, 8 deletions
diff --git a/os/hal/src/hal_buffers.c b/os/hal/src/hal_buffers.c
index a7cc5c79a..4e6bf9f10 100644
--- a/os/hal/src/hal_buffers.c
+++ b/os/hal/src/hal_buffers.c
@@ -340,7 +340,7 @@ size_t ibqReadTimeout(input_buffers_queue_t *ibqp, uint8_t *bp,
}
if (msg != MSG_OK) {
ibqp->accessed = false;
- return 0;
+ return r;
}
}
@@ -667,7 +667,7 @@ size_t obqWriteTimeout(output_buffers_queue_t *obqp, const uint8_t *bp,
}
if (msg != MSG_OK) {
obqp->accessed = false;
- return 0;
+ return r;
}
}
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_ */