aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--os/hal/include/serial_usb.h12
-rw-r--r--os/hal/src/serial_usb.c4
-rw-r--r--os/various/usb_cdc.h61
-rw-r--r--readme.txt1
-rw-r--r--testhal/STM32/USB_CDC/main.c11
5 files changed, 59 insertions, 30 deletions
diff --git a/os/hal/include/serial_usb.h b/os/hal/include/serial_usb.h
index b1d90cfb5..a220f7191 100644
--- a/os/hal/include/serial_usb.h
+++ b/os/hal/include/serial_usb.h
@@ -90,18 +90,6 @@ typedef struct {
* @brief USB driver configuration structure.
*/
USBConfig usb_config;
- /*
- * @brief Endpoint used for data transmission.
- */
- usbep_t data_request_ep;
- /*
- * @brief Endpoint used for data reception.
- */
- usbep_t data_available_ep;
- /*
- * @brief Endpoint used for interrupt request.
- */
- usbep_t interrupt_request_ep;
} SerialUSBConfig;
/**
diff --git a/os/hal/src/serial_usb.c b/os/hal/src/serial_usb.c
index 0393ad141..6ed5d324c 100644
--- a/os/hal/src/serial_usb.c
+++ b/os/hal/src/serial_usb.c
@@ -119,7 +119,7 @@ static void inotify(GenericQueue *qp) {
emptied, then a whole packet is loaded in the queue.*/
if (chIQIsEmptyI(&sdup->iqueue)) {
- n = usbReadPacketI(sdup->config->usbp, sdup->config->data_available_ep,
+ n = usbReadPacketI(sdup->config->usbp, DATA_AVAILABLE_EP,
sdup->iqueue.q_buffer, SERIAL_USB_BUFFERS_SIZE);
if (n != USB_ENDPOINT_BUSY) {
sdup->iqueue.q_rdptr = sdup->iqueue.q_buffer;
@@ -138,7 +138,7 @@ static void onotify(GenericQueue *qp) {
/* If there is any data in the output queue then it is sent within a
single packet and the queue is emptied.*/
- n = usbWritePacketI(sdup->config->usbp, sdup->config->data_request_ep,
+ n = usbWritePacketI(sdup->config->usbp, DATA_REQUEST_EP,
sdup->oqueue.q_buffer, chOQGetFullI(&sdup->oqueue));
if (n != USB_ENDPOINT_BUSY) {
sdup->oqueue.q_wrptr = sdup->oqueue.q_buffer;
diff --git a/os/various/usb_cdc.h b/os/various/usb_cdc.h
index c1d3da3e7..ac15b847b 100644
--- a/os/various/usb_cdc.h
+++ b/os/various/usb_cdc.h
@@ -28,6 +28,10 @@
#ifndef _USB_CDC_H_
#define _USB_CDC_H_
+/*===========================================================================*/
+/* Driver constants. */
+/*===========================================================================*/
+
#define CDC_SEND_ENCAPSULATED_COMMAND 0x00
#define CDC_GET_ENCAPSULATED_RESPONSE 0x01
#define CDC_SET_COMM_FEATURE 0x02
@@ -48,6 +52,49 @@
#define CDC_SET_OPERATION_PARMS 0x32
#define CDC_GET_OPERATION_PARMS 0x33
+#define LC_STOP_1 0
+#define LC_STOP_1P5 1
+#define LC_STOP_2 2
+
+#define LC_PARITY_NONE 0
+#define LC_PARITY_ODD 1
+#define LC_PARITY_EVEN 2
+#define LC_PARITY_MARK 3
+#define LC_PARITY_SPACE 4
+
+/*===========================================================================*/
+/* Driver pre-compile time settings. */
+/*===========================================================================*/
+
+/**
+ * @brief Endpoint number for bulk IN.
+ */
+#if !defined(DATA_REQUEST_EP) || defined(__DOXYGEN__)
+#define DATA_REQUEST_EP 1
+#endif
+
+/**
+ * @brief Endpoint number for interrupt IN.
+ */
+#if !defined(INTERRUPT_REQUEST_EP) || defined(__DOXYGEN__)
+#define INTERRUPT_REQUEST_EP 2
+#endif
+
+/**
+ * @brief Endpoint number for bulk OUT.
+ */
+#if !defined(DATA_AVAILABLE_EP) || defined(__DOXYGEN__)
+#define DATA_AVAILABLE_EP 3
+#endif
+
+/*===========================================================================*/
+/* Derived constants and error checks. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver data structures and types. */
+/*===========================================================================*/
+
/**
* @brief Type of Line Coding structure.
*/
@@ -58,15 +105,13 @@ typedef struct {
uint8_t bDataBits;
} cdc_linecoding_t;
-#define LC_STOP_1 0
-#define LC_STOP_1P5 1
-#define LC_STOP_2 2
+/*===========================================================================*/
+/* Driver macros. */
+/*===========================================================================*/
-#define LC_PARITY_NONE 0
-#define LC_PARITY_ODD 1
-#define LC_PARITY_EVEN 2
-#define LC_PARITY_MARK 3
-#define LC_PARITY_SPACE 4
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
#endif /* _USB_CDC_H_ */
diff --git a/readme.txt b/readme.txt
index a1a0a3ce4..d07108ad3 100644
--- a/readme.txt
+++ b/readme.txt
@@ -71,6 +71,7 @@
*****************************************************************************
*** 2.3.1 ***
+- OPT: Simplified Serial over USB driver configuration.
- CHANGE: Removed all the prefixes from the structure/union field names
in the HAL subsystem.
diff --git a/testhal/STM32/USB_CDC/main.c b/testhal/STM32/USB_CDC/main.c
index 49d744d5d..e18275808 100644
--- a/testhal/STM32/USB_CDC/main.c
+++ b/testhal/STM32/USB_CDC/main.c
@@ -21,14 +21,12 @@
#include "hal.h"
#include "test.h"
+#include "usb_cdc.h"
+
/*===========================================================================*/
/* USB related stuff. */
/*===========================================================================*/
-#define DATA_REQUEST_EP 1
-#define INTERRUPT_REQUEST_EP 2
-#define DATA_AVAILABLE_EP 3
-
/*
* USB Driver structure.
*/
@@ -300,10 +298,7 @@ static const SerialUSBConfig serusbcfg = {
get_descriptor,
sduRequestsHook,
NULL
- },
- DATA_REQUEST_EP,
- DATA_AVAILABLE_EP,
- INTERRUPT_REQUEST_EP
+ }
};
/*===========================================================================*/