aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/include
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2015-02-04 14:13:52 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2015-02-04 14:13:52 +0000
commit2eb9d1cb124a33c6e48b4bc8c572d1beb9c42ca4 (patch)
treed79a585d0cccec3dc3f7357d6d0c741860a62d81 /os/hal/include
parent2f5f47e43b45c6af839b0177f441d3a8081ebbc6 (diff)
downloadChibiOS-2eb9d1cb124a33c6e48b4bc8c572d1beb9c42ca4.tar.gz
ChibiOS-2eb9d1cb124a33c6e48b4bc8c572d1beb9c42ca4.tar.bz2
ChibiOS-2eb9d1cb124a33c6e48b4bc8c572d1beb9c42ca4.zip
Dual CDC demo for the STM32F4, to be tested.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7653 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/include')
-rw-r--r--os/hal/include/serial_usb.h36
-rw-r--r--os/hal/include/usb.h38
2 files changed, 60 insertions, 14 deletions
diff --git a/os/hal/include/serial_usb.h b/os/hal/include/serial_usb.h
index 8461f1211..a34710e6c 100644
--- a/os/hal/include/serial_usb.h
+++ b/os/hal/include/serial_usb.h
@@ -60,13 +60,31 @@
/** @} */
/**
- * @name CDC related constants
+ * @name CDC classes
* @{
*/
#define CDC_COMMUNICATION_INTERFACE_CLASS 0x02
#define CDC_DATA_INTERFACE_CLASS 0x0A
+/** @} */
+
+/**
+ * @name CDC subclasses
+ * @{
+ */
#define CDC_ABSTRACT_CONTROL_MODEL 0x02
+/** @} */
+
+/**
+ * @name CDC descriptors
+ * @{
+ */
#define CDC_CS_INTERFACE 0x24
+/** @} */
+
+/**
+ * @name CDC subdescriptors
+ * @{
+ */
#define CDC_HEADER 0x00
#define CDC_CALL_MANAGEMENT 0x01
#define CDC_ABSTRACT_CONTROL_MANAGEMENT 0x02
@@ -77,15 +95,15 @@
* @name Line Control bit definitions.
* @{
*/
-#define LC_STOP_1 0
-#define LC_STOP_1P5 1
-#define LC_STOP_2 2
+#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
+#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
/** @} */
/*===========================================================================*/
diff --git a/os/hal/include/usb.h b/os/hal/include/usb.h
index 380f8a1ed..a52480135 100644
--- a/os/hal/include/usb.h
+++ b/os/hal/include/usb.h
@@ -34,6 +34,9 @@
/* Driver constants. */
/*===========================================================================*/
+#define USB_ENDPOINT_OUT(ep) (ep)
+#define USB_ENDPOINT_IN(ep) ((ep) | 0x80)
+
#define USB_RTYPE_DIR_MASK 0x80
#define USB_RTYPE_DIR_HOST2DEV 0x00
#define USB_RTYPE_DIR_DEV2HOST 0x80
@@ -111,6 +114,11 @@
(uint8_t)((bcd) & 255), \
(uint8_t)(((bcd) >> 8) & 255)
+/*
+ * @define Device Descriptor size.
+ */
+#define USB_DESC_DEVICE_SIZE 18
+
/**
* @brief Device Descriptor helper macro.
*/
@@ -118,7 +126,7 @@
bDeviceProtocol, bMaxPacketSize, idVendor, \
idProduct, bcdDevice, iManufacturer, \
iProduct, iSerialNumber, bNumConfigurations) \
- USB_DESC_BYTE(18), \
+ USB_DESC_BYTE(USB_DESC_DEVICE_SIZE), \
USB_DESC_BYTE(USB_DESCRIPTOR_DEVICE), \
USB_DESC_BCD(bcdUSB), \
USB_DESC_BYTE(bDeviceClass), \
@@ -134,12 +142,17 @@
USB_DESC_BYTE(bNumConfigurations)
/**
+ * @brief Configuration Descriptor size.
+ */
+#define USB_DESC_CONFIGURATION_SIZE 9
+
+/**
* @brief Configuration Descriptor helper macro.
*/
#define USB_DESC_CONFIGURATION(wTotalLength, bNumInterfaces, \
bConfigurationValue, iConfiguration, \
bmAttributes, bMaxPower) \
- USB_DESC_BYTE(9), \
+ USB_DESC_BYTE(USB_DESC_CONFIGURATION_SIZE), \
USB_DESC_BYTE(USB_DESCRIPTOR_CONFIGURATION), \
USB_DESC_WORD(wTotalLength), \
USB_DESC_BYTE(bNumInterfaces), \
@@ -149,13 +162,18 @@
USB_DESC_BYTE(bMaxPower)
/**
+ * @brief Interface Descriptor size.
+ */
+#define USB_DESC_INTERFACE_SIZE 9
+
+/**
* @brief Interface Descriptor helper macro.
*/
#define USB_DESC_INTERFACE(bInterfaceNumber, bAlternateSetting, \
bNumEndpoints, bInterfaceClass, \
bInterfaceSubClass, bInterfaceProtocol, \
iInterface) \
- USB_DESC_BYTE(9), \
+ USB_DESC_BYTE(USB_DESC_INTERFACE_SIZE), \
USB_DESC_BYTE(USB_DESCRIPTOR_INTERFACE), \
USB_DESC_BYTE(bInterfaceNumber), \
USB_DESC_BYTE(bAlternateSetting), \
@@ -166,13 +184,18 @@
USB_DESC_INDEX(iInterface)
/**
+ * @brief Interface Association Descriptor size.
+ */
+#define USB_DESC_INTERFACE_ASSOCIATION_SIZE 8
+
+/**
* @brief Interface Association Descriptor helper macro.
*/
#define USB_DESC_INTERFACE_ASSOCIATION(bFirstInterface, \
bInterfaceCount, bFunctionClass, \
bFunctionSubClass, bFunctionProcotol, \
iInterface) \
- USB_DESC_BYTE(8), \
+ USB_DESC_BYTE(USB_DESC_INTERFACE_ASSOCIATION_SIZE), \
USB_DESC_BYTE(USB_DESCRIPTOR_INTERFACE_ASSOCIATION), \
USB_DESC_BYTE(bFirstInterface), \
USB_DESC_BYTE(bInterfaceCount), \
@@ -182,11 +205,16 @@
USB_DESC_INDEX(iInterface)
/**
+ * @brief Endpoint Descriptor size.
+ */
+#define USB_DESC_ENDPOINT_SIZE 7
+
+/**
* @brief Endpoint Descriptor helper macro.
*/
#define USB_DESC_ENDPOINT(bEndpointAddress, bmAttributes, wMaxPacketSize, \
bInterval) \
- USB_DESC_BYTE(7), \
+ USB_DESC_BYTE(USB_DESC_ENDPOINT_SIZE), \
USB_DESC_BYTE(USB_DESCRIPTOR_ENDPOINT), \
USB_DESC_BYTE(bEndpointAddress), \
USB_DESC_BYTE(bmAttributes), \