From 2eb9d1cb124a33c6e48b4bc8c572d1beb9c42ca4 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Wed, 4 Feb 2015 14:13:52 +0000 Subject: 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 --- .../ports/ARMCMx/devices/STM32L1xx/cmparams.h | 4 +-- os/hal/include/serial_usb.h | 36 +++++++++++++++----- os/hal/include/usb.h | 38 +++++++++++++++++++--- 3 files changed, 62 insertions(+), 16 deletions(-) (limited to 'os') diff --git a/os/common/ports/ARMCMx/devices/STM32L1xx/cmparams.h b/os/common/ports/ARMCMx/devices/STM32L1xx/cmparams.h index 08451c86e..2e3062f4a 100644 --- a/os/common/ports/ARMCMx/devices/STM32L1xx/cmparams.h +++ b/os/common/ports/ARMCMx/devices/STM32L1xx/cmparams.h @@ -19,11 +19,11 @@ /** * @file STM32L1xx/cmparams.h - * @brief ARM Cortex-M4 parameters for the STM32L1xx. + * @brief ARM Cortex-M3 parameters for the STM32L1xx. * * @defgroup ARMCMx_STM32L1xx STM32L1xx Specific Parameters * @ingroup ARMCMx_SPECIFIC - * @details This file contains the Cortex-M4 specific parameters for the + * @details This file contains the Cortex-M3 specific parameters for the * STM32L1xx platform. * @{ */ 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), \ @@ -133,13 +141,18 @@ USB_DESC_INDEX(iSerialNumber), \ 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), \ @@ -148,6 +161,11 @@ USB_DESC_BYTE(bmAttributes), \ USB_DESC_BYTE(bMaxPower) +/** + * @brief Interface Descriptor size. + */ +#define USB_DESC_INTERFACE_SIZE 9 + /** * @brief Interface Descriptor helper macro. */ @@ -155,7 +173,7 @@ 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), \ @@ -165,6 +183,11 @@ USB_DESC_BYTE(bInterfaceProtocol), \ USB_DESC_INDEX(iInterface) +/** + * @brief Interface Association Descriptor size. + */ +#define USB_DESC_INTERFACE_ASSOCIATION_SIZE 8 + /** * @brief Interface Association Descriptor helper macro. */ @@ -172,7 +195,7 @@ 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), \ @@ -181,12 +204,17 @@ USB_DESC_BYTE(bFunctionProcotol), \ 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), \ -- cgit v1.2.3