From 64acf753c775e724040fea8d286903a1a497a04b Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Tue, 5 Jan 2016 11:15:40 +0000 Subject: [PATCH] git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8692 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/dox/main.dox | 7 ++ os/hal/dox/mii.dox | 23 ++++ os/hal/dox/usb_cdc.dox | 23 ++++ os/hal/include/mii.h | 53 +++++---- os/hal/include/serial_usb.h | 84 +------------- os/hal/include/usb_cdc.h | 136 +++++++++++++++++++++++ testhal/STM32/STM32F7xx/USB_RAW/usbcfg.c | 16 +-- 7 files changed, 226 insertions(+), 116 deletions(-) create mode 100644 os/hal/dox/mii.dox create mode 100644 os/hal/dox/usb_cdc.dox create mode 100644 os/hal/include/usb_cdc.h diff --git a/os/hal/dox/main.dox b/os/hal/dox/main.dox index 331a1407b..0ec83d92c 100644 --- a/os/hal/dox/main.dox +++ b/os/hal/dox/main.dox @@ -127,6 +127,13 @@ * @ingroup IO */ +/** + * @defgroup HAL_SUPPORT Support Code + * @brief HAL Support Code. + * + * @ingroup IO + */ + /** * @defgroup OSAL OSAL * @brief Operating System Abstraction Layer. diff --git a/os/hal/dox/mii.dox b/os/hal/dox/mii.dox new file mode 100644 index 000000000..1973dc5a7 --- /dev/null +++ b/os/hal/dox/mii.dox @@ -0,0 +1,23 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** + * @defgroup MII MII/RMII Header + * @brief MII/RMII Support Header + * @details This header contains definitions and types related to MII/RMII. + * + * @ingroup HAL_SUPPORT + */ diff --git a/os/hal/dox/usb_cdc.dox b/os/hal/dox/usb_cdc.dox new file mode 100644 index 000000000..d4aca2682 --- /dev/null +++ b/os/hal/dox/usb_cdc.dox @@ -0,0 +1,23 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** + * @defgroup USB_CDC USB CDC Header + * @brief USB CDC Support Header + * @details This header contains definitions and types related to USB CDC. + * + * @ingroup HAL_SUPPORT + */ diff --git a/os/hal/include/mii.h b/os/hal/include/mii.h index e7e59a343..27a616cc5 100644 --- a/os/hal/include/mii.h +++ b/os/hal/include/mii.h @@ -14,9 +14,9 @@ limitations under the License. */ -/*-* +/** * @file mii.h - * @brief MII Driver macros and structures. + * @brief MII macros and structures. * * @addtogroup MII * @{ @@ -25,9 +25,9 @@ #ifndef _MII_H_ #define _MII_H_ -/* - * Generic MII registers. Note, not all registers are present on all PHY - * devices and some extra registers may be present. +/** + * @name Generic MII registers + * @{ */ #define MII_BMCR 0x00 /**< Basic mode control register. */ #define MII_BMSR 0x01 /**< Basic mode status register. */ @@ -53,9 +53,11 @@ #define MII_RESV2 0x1a /**< Reserved. */ #define MII_TPISTATUS 0x1b /**< TPI status for 10Mbps. */ #define MII_NCONFIG 0x1c /**< Network interface config. */ +/** @} */ -/* - * Basic mode control register. +/** + * @name Basic mode control register + * @{ */ #define BMCR_RESV 0x007f /**< Unused. */ #define BMCR_CTST 0x0080 /**< Collision test. */ @@ -67,9 +69,11 @@ #define BMCR_SPEED100 0x2000 /**< Select 100Mbps. */ #define BMCR_LOOPBACK 0x4000 /**< TXD loopback bit. */ #define BMCR_RESET 0x8000 /**< Reset. */ +/** @} */ -/* - * Basic mode status register. +/** + * @name Basic mode status register + * @{ */ #define BMSR_ERCAP 0x0001 /**< Ext-reg capability. */ #define BMSR_JCD 0x0002 /**< Jabber detected. */ @@ -84,9 +88,11 @@ #define BMSR_100HALF 0x2000 /**< Can do 100mbps, half-duplex. */ #define BMSR_100FULL 0x4000 /**< Can do 100mbps, full-duplex. */ #define BMSR_100BASE4 0x8000 /**< Can do 100mbps, 4k packets. */ +/** @} */ -/* - * Advertisement control register. +/** + * @name Advertisement control register + * @{ */ #define ADVERTISE_SLCT 0x001f /**< Selector bits. */ #define ADVERTISE_CSMA 0x0001 /**< Only selector supported. */ @@ -106,9 +112,11 @@ ADVERTISE_CSMA) #define ADVERTISE_ALL (ADVERTISE_10HALF | ADVERTISE_10FULL | \ ADVERTISE_100HALF | ADVERTISE_100FULL) +/** @} */ -/* - * Link partner ability register. +/** + * @name Link partner ability register + * @{ */ #define LPA_SLCT 0x001f /**< Same as advertise selector. */ #define LPA_10HALF 0x0020 /**< Can do 10mbps half-duplex. */ @@ -125,9 +133,11 @@ #define LPA_DUPLEX (LPA_10FULL | LPA_100FULL) #define LPA_100 (LPA_100FULL | LPA_100HALF | LPA_100BASE4) +/** @} */ -/* - * Expansion register for auto-negotiation. +/** + * @name Expansion register for auto-negotiation + * @{ */ #define EXPANSION_NWAY 0x0001 /**< Can do N-way auto-nego. */ #define EXPANSION_LCWP 0x0002 /**< Got new RX page code word. */ @@ -135,16 +145,20 @@ #define EXPANSION_NPCAPABLE 0x0008 /**< Link partner supports npage. */ #define EXPANSION_MFAULTS 0x0010 /**< Multiple faults detected. */ #define EXPANSION_RESV 0xffe0 /**< Unused. */ +/** @} */ -/* - * N-way test register. +/** + * @name N-way test register + * @{ */ #define NWAYTEST_RESV1 0x00ff /**< Unused. */ #define NWAYTEST_LOOPBACK 0x0100 /**< Enable loopback for N-way. */ #define NWAYTEST_RESV2 0xfe00 /**< Unused. */ +/** @} */ -/* - * PHY identifiers. +/** + * @name PHY identifiers + * @{ */ #define MII_DM9161_ID 0x0181b8a0 #define MII_AM79C875_ID 0x00225540 @@ -154,6 +168,7 @@ #define MII_LAN8710A_ID 0x0007C0F1 #define MII_LAN8720_ID 0x0007C0F0 #define MII_LAN8742A_ID 0x0007C130 +/** @} */ #endif /* _MII_H_ */ diff --git a/os/hal/include/serial_usb.h b/os/hal/include/serial_usb.h index 0ca4ba06d..51ab1fe06 100644 --- a/os/hal/include/serial_usb.h +++ b/os/hal/include/serial_usb.h @@ -27,82 +27,12 @@ #if (HAL_USE_SERIAL_USB == TRUE) || defined(__DOXYGEN__) +#include "usb_cdc.h" + /*===========================================================================*/ /* Driver constants. */ /*===========================================================================*/ -/** - * @name CDC specific messages. - * @{ - */ -#define CDC_SEND_ENCAPSULATED_COMMAND 0x00 -#define CDC_GET_ENCAPSULATED_RESPONSE 0x01 -#define CDC_SET_COMM_FEATURE 0x02 -#define CDC_GET_COMM_FEATURE 0x03 -#define CDC_CLEAR_COMM_FEATURE 0x04 -#define CDC_SET_AUX_LINE_STATE 0x10 -#define CDC_SET_HOOK_STATE 0x11 -#define CDC_PULSE_SETUP 0x12 -#define CDC_SEND_PULSE 0x13 -#define CDC_SET_PULSE_TIME 0x14 -#define CDC_RING_AUX_JACK 0x15 -#define CDC_SET_LINE_CODING 0x20 -#define CDC_GET_LINE_CODING 0x21 -#define CDC_SET_CONTROL_LINE_STATE 0x22 -#define CDC_SEND_BREAK 0x23 -#define CDC_SET_RINGER_PARMS 0x30 -#define CDC_GET_RINGER_PARMS 0x31 -#define CDC_SET_OPERATION_PARMS 0x32 -#define CDC_GET_OPERATION_PARMS 0x33 -/** @} */ - -/** - * @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 -#define CDC_UNION 0x06 -/** @} */ - -/** - * @name Line Control bit definitions. - * @{ - */ -#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. */ /*===========================================================================*/ @@ -143,16 +73,6 @@ /* Driver data structures and types. */ /*===========================================================================*/ -/** - * @brief Type of Line Coding structure. - */ -typedef struct { - uint8_t dwDTERate[4]; - uint8_t bCharFormat; - uint8_t bParityType; - uint8_t bDataBits; -} cdc_linecoding_t; - /** * @brief Driver state machine possible states. */ diff --git a/os/hal/include/usb_cdc.h b/os/hal/include/usb_cdc.h new file mode 100644 index 000000000..81d9f0a5a --- /dev/null +++ b/os/hal/include/usb_cdc.h @@ -0,0 +1,136 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** + * @file usb_cdc.h + * @brief USB CDC macros and structures. + * + * @addtogroup USB_CDC + * @{ + */ + +#ifndef _USB_CDC_H_ +#define _USB_CDC_H_ + +/*===========================================================================*/ +/* Driver constants. */ +/*===========================================================================*/ + +/** + * @name CDC specific messages. + * @{ + */ +#define CDC_SEND_ENCAPSULATED_COMMAND 0x00U +#define CDC_GET_ENCAPSULATED_RESPONSE 0x01U +#define CDC_SET_COMM_FEATURE 0x02U +#define CDC_GET_COMM_FEATURE 0x03U +#define CDC_CLEAR_COMM_FEATURE 0x04U +#define CDC_SET_AUX_LINE_STATE 0x10U +#define CDC_SET_HOOK_STATE 0x11U +#define CDC_PULSE_SETUP 0x12U +#define CDC_SEND_PULSE 0x13U +#define CDC_SET_PULSE_TIME 0x14U +#define CDC_RING_AUX_JACK 0x15U +#define CDC_SET_LINE_CODING 0x20U +#define CDC_GET_LINE_CODING 0x21U +#define CDC_SET_CONTROL_LINE_STATE 0x22U +#define CDC_SEND_BREAK 0x23U +#define CDC_SET_RINGER_PARMS 0x30U +#define CDC_GET_RINGER_PARMS 0x31U +#define CDC_SET_OPERATION_PARMS 0x32U +#define CDC_GET_OPERATION_PARMS 0x33U +/** @} */ + +/** + * @name CDC classes + * @{ + */ +#define CDC_COMMUNICATION_INTERFACE_CLASS 0x02U +#define CDC_DATA_INTERFACE_CLASS 0x0AU +/** @} */ + +/** + * @name CDC subclasses + * @{ + */ +#define CDC_ABSTRACT_CONTROL_MODEL 0x02U +/** @} */ + +/** + * @name CDC descriptors + * @{ + */ +#define CDC_CS_INTERFACE 0x24U +/** @} */ + +/** + * @name CDC subdescriptors + * @{ + */ +#define CDC_HEADER 0x00U +#define CDC_CALL_MANAGEMENT 0x01U +#define CDC_ABSTRACT_CONTROL_MANAGEMENT 0x02U +#define CDC_UNION 0x06U +/** @} */ + +/** + * @name Line Control bit definitions. + * @{ + */ +#define LC_STOP_1 0U +#define LC_STOP_1P5 1U +#define LC_STOP_2 2U + +#define LC_PARITY_NONE 0U +#define LC_PARITY_ODD 1U +#define LC_PARITY_EVEN 2U +#define LC_PARITY_MARK 3U +#define LC_PARITY_SPACE 4U +/** @} */ + +/*===========================================================================*/ +/* Driver pre-compile time settings. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Derived constants and error checks. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver data structures and types. */ +/*===========================================================================*/ + +/** + * @brief Type of Line Coding structure. + */ +typedef struct { + uint8_t dwDTERate[4]; + uint8_t bCharFormat; + uint8_t bParityType; + uint8_t bDataBits; +} cdc_linecoding_t; + +/*===========================================================================*/ +/* Driver macros. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +#endif /* _USB_CDC_H_ */ + +/** @} */ diff --git a/testhal/STM32/STM32F7xx/USB_RAW/usbcfg.c b/testhal/STM32/STM32F7xx/USB_RAW/usbcfg.c index 2c366c64d..803d1a059 100644 --- a/testhal/STM32/STM32F7xx/USB_RAW/usbcfg.c +++ b/testhal/STM32/STM32F7xx/USB_RAW/usbcfg.c @@ -15,7 +15,7 @@ */ #include "hal.h" - +#include "usb_cdc.h" #include "usbcfg.h" /* @@ -283,20 +283,6 @@ static void usb_event(USBDriver *usbp, usbevent_t event) { return; } -#define CDC_SET_LINE_CODING 0x20 -#define CDC_GET_LINE_CODING 0x21 -#define CDC_SET_CONTROL_LINE_STATE 0x22 - -#define LC_STOP_1 0 -#define LC_PARITY_NONE 0 - -typedef struct { - uint8_t dwDTERate[4]; - uint8_t bCharFormat; - uint8_t bParityType; - uint8_t bDataBits; -} cdc_linecoding_t; - static cdc_linecoding_t linecoding = { {0x00, 0x96, 0x00, 0x00}, /* 38400. */ LC_STOP_1, LC_PARITY_NONE, 8