Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 2 | Rev 9 | ||
|---|---|---|---|
| Line 1... | Line 1... | ||
| 1 | /** |
1 | /** |
| 2 | ****************************************************************************** |
2 | ****************************************************************************** |
| 3 | * @file usbd_def.h |
3 | * @file usbd_def.h |
| 4 | * @author MCD Application Team |
4 | * @author MCD Application Team |
| 5 | * @version V2.4.2 |
- | |
| 6 | * @date 11-December-2015 |
- | |
| 7 | * @brief General defines for the usb device library |
5 | * @brief General defines for the usb device library |
| 8 | ****************************************************************************** |
6 | ****************************************************************************** |
| 9 | * @attention |
7 | * @attention |
| 10 | * |
8 | * |
| 11 | * <h2><center>© COPYRIGHT 2015 STMicroelectronics</center></h2> |
9 | * <h2><center>© Copyright (c) 2015 STMicroelectronics. |
| - | 10 | * All rights reserved.</center></h2> |
|
| 12 | * |
11 | * |
| 13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); |
12 | * This software component is licensed by ST under Ultimate Liberty license |
| 14 | * You may not use this file except in compliance with the License. |
13 | * SLA0044, the "License"; You may not use this file except in compliance with |
| 15 | * You may obtain a copy of the License at: |
14 | * the License. You may obtain a copy of the License at: |
| 16 | * |
- | |
| 17 | * http://www.st.com/software_license_agreement_liberty_v2 |
- | |
| 18 | * |
- | |
| 19 | * Unless required by applicable law or agreed to in writing, software |
- | |
| 20 | * distributed under the License is distributed on an "AS IS" BASIS, |
- | |
| 21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | |
| 22 | * See the License for the specific language governing permissions and |
- | |
| 23 | * limitations under the License. |
15 | * www.st.com/SLA0044 |
| 24 | * |
16 | * |
| 25 | ****************************************************************************** |
17 | ****************************************************************************** |
| 26 | */ |
18 | */ |
| 27 | 19 | ||
| 28 | /* Define to prevent recursive inclusion -------------------------------------*/ |
20 | /* Define to prevent recursive inclusion -------------------------------------*/ |
| 29 | #ifndef __USBD_DEF_H |
21 | #ifndef __USBD_DEF_H |
| 30 | #define __USBD_DEF_H |
22 | #define __USBD_DEF_H |
| 31 | 23 | ||
| 32 | #ifdef __cplusplus |
24 | #ifdef __cplusplus |
| 33 | extern "C" { |
25 | extern "C" { |
| 34 | #endif |
26 | #endif |
| 35 | 27 | ||
| 36 | /* Includes ------------------------------------------------------------------*/ |
28 | /* Includes ------------------------------------------------------------------*/ |
| 37 | #include "usbd_conf.h" |
29 | #include "usbd_conf.h" |
| 38 | 30 | ||
| 39 | /** @addtogroup STM32_USBD_DEVICE_LIBRARY |
31 | /** @addtogroup STM32_USBD_DEVICE_LIBRARY |
| 40 | * @{ |
32 | * @{ |
| 41 | */ |
33 | */ |
| 42 | 34 | ||
| 43 | /** @defgroup USB_DEF |
35 | /** @defgroup USB_DEF |
| 44 | * @brief general defines for the usb device library file |
36 | * @brief general defines for the usb device library file |
| 45 | * @{ |
37 | * @{ |
| 46 | */ |
38 | */ |
| 47 | 39 | ||
| 48 | /** @defgroup USB_DEF_Exported_Defines |
40 | /** @defgroup USB_DEF_Exported_Defines |
| 49 | * @{ |
41 | * @{ |
| 50 | */ |
42 | */ |
| 51 | 43 | ||
| 52 | #ifndef NULL |
44 | #ifndef NULL |
| 53 | #define NULL 0 |
45 | #define NULL 0U |
| 54 | #endif |
46 | #endif /* NULL */ |
| 55 | 47 | ||
| - | 48 | #ifndef USBD_MAX_NUM_INTERFACES |
|
| - | 49 | #define USBD_MAX_NUM_INTERFACES 1U |
|
| - | 50 | #endif /* USBD_MAX_NUM_CONFIGURATION */ |
|
| 56 | 51 | ||
| - | 52 | #ifndef USBD_MAX_NUM_CONFIGURATION |
|
| - | 53 | #define USBD_MAX_NUM_CONFIGURATION 1U |
|
| - | 54 | #endif /* USBD_MAX_NUM_CONFIGURATION */ |
|
| - | 55 | ||
| - | 56 | #ifndef USBD_LPM_ENABLED |
|
| - | 57 | #define USBD_LPM_ENABLED 0U |
|
| - | 58 | #endif /* USBD_LPM_ENABLED */ |
|
| - | 59 | ||
| - | 60 | #ifndef USBD_SELF_POWERED |
|
| - | 61 | #define USBD_SELF_POWERED 1U |
|
| - | 62 | #endif /*USBD_SELF_POWERED */ |
|
| - | 63 | ||
| - | 64 | #ifndef USBD_SUPPORT_USER_STRING_DESC |
|
| - | 65 | #define USBD_SUPPORT_USER_STRING_DESC 0U |
|
| - | 66 | #endif /* USBD_SUPPORT_USER_STRING_DESC */ |
|
| - | 67 | ||
| 57 | #define USB_LEN_DEV_QUALIFIER_DESC 0x0A |
68 | #define USB_LEN_DEV_QUALIFIER_DESC 0x0AU |
| 58 | #define USB_LEN_DEV_DESC 0x12 |
69 | #define USB_LEN_DEV_DESC 0x12U |
| 59 | #define USB_LEN_CFG_DESC 0x09 |
70 | #define USB_LEN_CFG_DESC 0x09U |
| 60 | #define USB_LEN_IF_DESC 0x09 |
71 | #define USB_LEN_IF_DESC 0x09U |
| 61 | #define USB_LEN_EP_DESC 0x07 |
72 | #define USB_LEN_EP_DESC 0x07U |
| 62 | #define USB_LEN_OTG_DESC 0x03 |
73 | #define USB_LEN_OTG_DESC 0x03U |
| 63 | #define USB_LEN_LANGID_STR_DESC 0x04 |
74 | #define USB_LEN_LANGID_STR_DESC 0x04U |
| 64 | #define USB_LEN_OTHER_SPEED_DESC_SIZ 0x09 |
75 | #define USB_LEN_OTHER_SPEED_DESC_SIZ 0x09U |
| 65 | 76 | ||
| 66 | #define USBD_IDX_LANGID_STR 0x00 |
77 | #define USBD_IDX_LANGID_STR 0x00U |
| 67 | #define USBD_IDX_MFC_STR 0x01 |
78 | #define USBD_IDX_MFC_STR 0x01U |
| 68 | #define USBD_IDX_PRODUCT_STR 0x02 |
79 | #define USBD_IDX_PRODUCT_STR 0x02U |
| 69 | #define USBD_IDX_SERIAL_STR 0x03 |
80 | #define USBD_IDX_SERIAL_STR 0x03U |
| 70 | #define USBD_IDX_CONFIG_STR 0x04 |
81 | #define USBD_IDX_CONFIG_STR 0x04U |
| 71 | #define USBD_IDX_INTERFACE_STR 0x05 |
82 | #define USBD_IDX_INTERFACE_STR 0x05U |
| 72 | 83 | ||
| 73 | #define USB_REQ_TYPE_STANDARD 0x00 |
84 | #define USB_REQ_TYPE_STANDARD 0x00U |
| 74 | #define USB_REQ_TYPE_CLASS 0x20 |
85 | #define USB_REQ_TYPE_CLASS 0x20U |
| 75 | #define USB_REQ_TYPE_VENDOR 0x40 |
86 | #define USB_REQ_TYPE_VENDOR 0x40U |
| 76 | #define USB_REQ_TYPE_MASK 0x60 |
87 | #define USB_REQ_TYPE_MASK 0x60U |
| 77 | 88 | ||
| 78 | #define USB_REQ_RECIPIENT_DEVICE 0x00 |
89 | #define USB_REQ_RECIPIENT_DEVICE 0x00U |
| 79 | #define USB_REQ_RECIPIENT_INTERFACE 0x01 |
90 | #define USB_REQ_RECIPIENT_INTERFACE 0x01U |
| 80 | #define USB_REQ_RECIPIENT_ENDPOINT 0x02 |
91 | #define USB_REQ_RECIPIENT_ENDPOINT 0x02U |
| 81 | #define USB_REQ_RECIPIENT_MASK 0x03 |
92 | #define USB_REQ_RECIPIENT_MASK 0x03U |
| 82 | 93 | ||
| 83 | #define USB_REQ_GET_STATUS 0x00 |
94 | #define USB_REQ_GET_STATUS 0x00U |
| 84 | #define USB_REQ_CLEAR_FEATURE 0x01 |
95 | #define USB_REQ_CLEAR_FEATURE 0x01U |
| 85 | #define USB_REQ_SET_FEATURE 0x03 |
96 | #define USB_REQ_SET_FEATURE 0x03U |
| 86 | #define USB_REQ_SET_ADDRESS 0x05 |
97 | #define USB_REQ_SET_ADDRESS 0x05U |
| 87 | #define USB_REQ_GET_DESCRIPTOR 0x06 |
98 | #define USB_REQ_GET_DESCRIPTOR 0x06U |
| 88 | #define USB_REQ_SET_DESCRIPTOR 0x07 |
99 | #define USB_REQ_SET_DESCRIPTOR 0x07U |
| 89 | #define USB_REQ_GET_CONFIGURATION 0x08 |
100 | #define USB_REQ_GET_CONFIGURATION 0x08U |
| 90 | #define USB_REQ_SET_CONFIGURATION 0x09 |
101 | #define USB_REQ_SET_CONFIGURATION 0x09U |
| 91 | #define USB_REQ_GET_INTERFACE 0x0A |
102 | #define USB_REQ_GET_INTERFACE 0x0AU |
| 92 | #define USB_REQ_SET_INTERFACE 0x0B |
103 | #define USB_REQ_SET_INTERFACE 0x0BU |
| 93 | #define USB_REQ_SYNCH_FRAME 0x0C |
104 | #define USB_REQ_SYNCH_FRAME 0x0CU |
| 94 | 105 | ||
| 95 | #define USB_DESC_TYPE_DEVICE 1 |
106 | #define USB_DESC_TYPE_DEVICE 0x01U |
| 96 | #define USB_DESC_TYPE_CONFIGURATION 2 |
107 | #define USB_DESC_TYPE_CONFIGURATION 0x02U |
| 97 | #define USB_DESC_TYPE_STRING 3 |
108 | #define USB_DESC_TYPE_STRING 0x03U |
| 98 | #define USB_DESC_TYPE_INTERFACE 4 |
109 | #define USB_DESC_TYPE_INTERFACE 0x04U |
| 99 | #define USB_DESC_TYPE_ENDPOINT 5 |
110 | #define USB_DESC_TYPE_ENDPOINT 0x05U |
| 100 | #define USB_DESC_TYPE_DEVICE_QUALIFIER 6 |
111 | #define USB_DESC_TYPE_DEVICE_QUALIFIER 0x06U |
| 101 | #define USB_DESC_TYPE_OTHER_SPEED_CONFIGURATION 7 |
112 | #define USB_DESC_TYPE_OTHER_SPEED_CONFIGURATION 0x07U |
| 102 | #define USB_DESC_TYPE_BOS 0x0F |
113 | #define USB_DESC_TYPE_BOS 0x0FU |
| 103 | 114 | ||
| 104 | #define USB_CONFIG_REMOTE_WAKEUP 2 |
115 | #define USB_CONFIG_REMOTE_WAKEUP 0x02U |
| 105 | #define USB_CONFIG_SELF_POWERED 1 |
116 | #define USB_CONFIG_SELF_POWERED 0x01U |
| 106 | 117 | ||
| 107 | #define USB_FEATURE_EP_HALT 0 |
118 | #define USB_FEATURE_EP_HALT 0x00U |
| 108 | #define USB_FEATURE_REMOTE_WAKEUP 1 |
119 | #define USB_FEATURE_REMOTE_WAKEUP 0x01U |
| 109 | #define USB_FEATURE_TEST_MODE 2 |
120 | #define USB_FEATURE_TEST_MODE 0x02U |
| 110 | 121 | ||
| 111 | #define USB_DEVICE_CAPABITY_TYPE 0x10 |
122 | #define USB_DEVICE_CAPABITY_TYPE 0x10U |
| 112 | 123 | ||
| 113 | #define USB_HS_MAX_PACKET_SIZE 512 |
124 | #define USB_HS_MAX_PACKET_SIZE 512U |
| 114 | #define USB_FS_MAX_PACKET_SIZE 64 |
125 | #define USB_FS_MAX_PACKET_SIZE 64U |
| 115 | #define USB_MAX_EP0_SIZE 64 |
126 | #define USB_MAX_EP0_SIZE 64U |
| 116 | 127 | ||
| 117 | /* Device Status */ |
128 | /* Device Status */ |
| 118 | #define USBD_STATE_DEFAULT 1 |
129 | #define USBD_STATE_DEFAULT 0x01U |
| 119 | #define USBD_STATE_ADDRESSED 2 |
130 | #define USBD_STATE_ADDRESSED 0x02U |
| 120 | #define USBD_STATE_CONFIGURED 3 |
131 | #define USBD_STATE_CONFIGURED 0x03U |
| 121 | #define USBD_STATE_SUSPENDED 4 |
132 | #define USBD_STATE_SUSPENDED 0x04U |
| 122 | 133 | ||
| 123 | 134 | ||
| 124 | /* EP0 State */ |
135 | /* EP0 State */ |
| 125 | #define USBD_EP0_IDLE 0 |
136 | #define USBD_EP0_IDLE 0x00U |
| 126 | #define USBD_EP0_SETUP 1 |
137 | #define USBD_EP0_SETUP 0x01U |
| 127 | #define USBD_EP0_DATA_IN 2 |
138 | #define USBD_EP0_DATA_IN 0x02U |
| 128 | #define USBD_EP0_DATA_OUT 3 |
139 | #define USBD_EP0_DATA_OUT 0x03U |
| 129 | #define USBD_EP0_STATUS_IN 4 |
140 | #define USBD_EP0_STATUS_IN 0x04U |
| 130 | #define USBD_EP0_STATUS_OUT 5 |
141 | #define USBD_EP0_STATUS_OUT 0x05U |
| 131 | #define USBD_EP0_STALL 6 |
142 | #define USBD_EP0_STALL 0x06U |
| 132 | 143 | ||
| 133 | #define USBD_EP_TYPE_CTRL 0 |
144 | #define USBD_EP_TYPE_CTRL 0x00U |
| 134 | #define USBD_EP_TYPE_ISOC 1 |
145 | #define USBD_EP_TYPE_ISOC 0x01U |
| 135 | #define USBD_EP_TYPE_BULK 2 |
146 | #define USBD_EP_TYPE_BULK 0x02U |
| 136 | #define USBD_EP_TYPE_INTR 3 |
147 | #define USBD_EP_TYPE_INTR 0x03U |
| 137 | 148 | ||
| 138 | 149 | ||
| 139 | /** |
150 | /** |
| 140 | * @} |
151 | * @} |
| 141 | */ |
152 | */ |
| 142 | 153 | ||
| 143 | 154 | ||
| 144 | /** @defgroup USBD_DEF_Exported_TypesDefinitions |
155 | /** @defgroup USBD_DEF_Exported_TypesDefinitions |
| 145 | * @{ |
156 | * @{ |
| 146 | */ |
157 | */ |
| 147 | 158 | ||
| 148 | typedef struct usb_setup_req |
159 | typedef struct usb_setup_req |
| 149 | { |
160 | { |
| 150 | - | ||
| 151 | uint8_t bmRequest; |
161 | uint8_t bmRequest; |
| 152 | uint8_t bRequest; |
162 | uint8_t bRequest; |
| 153 | uint16_t wValue; |
163 | uint16_t wValue; |
| 154 | uint16_t wIndex; |
164 | uint16_t wIndex; |
| 155 | uint16_t wLength; |
165 | uint16_t wLength; |
| 156 | }USBD_SetupReqTypedef; |
166 | } USBD_SetupReqTypedef; |
| 157 | 167 | ||
| 158 | struct _USBD_HandleTypeDef; |
168 | struct _USBD_HandleTypeDef; |
| 159 | 169 | ||
| 160 | typedef struct _Device_cb |
170 | typedef struct _Device_cb |
| 161 | { |
171 | { |
| 162 | uint8_t (*Init) (struct _USBD_HandleTypeDef *pdev , uint8_t cfgidx); |
172 | uint8_t (*Init)(struct _USBD_HandleTypeDef *pdev, uint8_t cfgidx); |
| 163 | uint8_t (*DeInit) (struct _USBD_HandleTypeDef *pdev , uint8_t cfgidx); |
173 | uint8_t (*DeInit)(struct _USBD_HandleTypeDef *pdev, uint8_t cfgidx); |
| 164 | /* Control Endpoints*/ |
174 | /* Control Endpoints*/ |
| 165 | uint8_t (*Setup) (struct _USBD_HandleTypeDef *pdev , USBD_SetupReqTypedef *req); |
175 | uint8_t (*Setup)(struct _USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); |
| 166 | uint8_t (*EP0_TxSent) (struct _USBD_HandleTypeDef *pdev ); |
176 | uint8_t (*EP0_TxSent)(struct _USBD_HandleTypeDef *pdev); |
| 167 | uint8_t (*EP0_RxReady) (struct _USBD_HandleTypeDef *pdev ); |
177 | uint8_t (*EP0_RxReady)(struct _USBD_HandleTypeDef *pdev); |
| 168 | /* Class Specific Endpoints*/ |
178 | /* Class Specific Endpoints*/ |
| 169 | uint8_t (*DataIn) (struct _USBD_HandleTypeDef *pdev , uint8_t epnum); |
179 | uint8_t (*DataIn)(struct _USBD_HandleTypeDef *pdev, uint8_t epnum); |
| 170 | uint8_t (*DataOut) (struct _USBD_HandleTypeDef *pdev , uint8_t epnum); |
180 | uint8_t (*DataOut)(struct _USBD_HandleTypeDef *pdev, uint8_t epnum); |
| 171 | uint8_t (*SOF) (struct _USBD_HandleTypeDef *pdev); |
181 | uint8_t (*SOF)(struct _USBD_HandleTypeDef *pdev); |
| 172 | uint8_t (*IsoINIncomplete) (struct _USBD_HandleTypeDef *pdev , uint8_t epnum); |
182 | uint8_t (*IsoINIncomplete)(struct _USBD_HandleTypeDef *pdev, uint8_t epnum); |
| 173 | uint8_t (*IsoOUTIncomplete) (struct _USBD_HandleTypeDef *pdev , uint8_t epnum); |
183 | uint8_t (*IsoOUTIncomplete)(struct _USBD_HandleTypeDef *pdev, uint8_t epnum); |
| 174 | 184 | ||
| 175 | uint8_t *(*GetHSConfigDescriptor)(uint16_t *length); |
185 | uint8_t *(*GetHSConfigDescriptor)(uint16_t *length); |
| 176 | uint8_t *(*GetFSConfigDescriptor)(uint16_t *length); |
186 | uint8_t *(*GetFSConfigDescriptor)(uint16_t *length); |
| 177 | uint8_t *(*GetOtherSpeedConfigDescriptor)(uint16_t *length); |
187 | uint8_t *(*GetOtherSpeedConfigDescriptor)(uint16_t *length); |
| 178 | uint8_t *(*GetDeviceQualifierDescriptor)(uint16_t *length); |
188 | uint8_t *(*GetDeviceQualifierDescriptor)(uint16_t *length); |
| 179 | #if (USBD_SUPPORT_USER_STRING == 1) |
189 | #if (USBD_SUPPORT_USER_STRING_DESC == 1U) |
| 180 | uint8_t *(*GetUsrStrDescriptor)(struct _USBD_HandleTypeDef *pdev ,uint8_t index, uint16_t *length); |
190 | uint8_t *(*GetUsrStrDescriptor)(struct _USBD_HandleTypeDef *pdev, uint8_t index, uint16_t *length); |
| 181 | #endif |
191 | #endif |
| 182 | 192 | ||
| 183 | } USBD_ClassTypeDef; |
193 | } USBD_ClassTypeDef; |
| 184 | 194 | ||
| 185 | /* Following USB Device Speed */ |
195 | /* Following USB Device Speed */ |
| 186 | typedef enum |
196 | typedef enum |
| 187 | { |
197 | { |
| 188 | USBD_SPEED_HIGH = 0, |
198 | USBD_SPEED_HIGH = 0U, |
| 189 | USBD_SPEED_FULL = 1, |
199 | USBD_SPEED_FULL = 1U, |
| 190 | USBD_SPEED_LOW = 2, |
200 | USBD_SPEED_LOW = 2U, |
| 191 | }USBD_SpeedTypeDef; |
201 | } USBD_SpeedTypeDef; |
| 192 | 202 | ||
| 193 | /* Following USB Device status */ |
203 | /* Following USB Device status */ |
| 194 | typedef enum { |
204 | typedef enum |
| - | 205 | { |
|
| 195 | USBD_OK = 0, |
206 | USBD_OK = 0U, |
| 196 | USBD_BUSY, |
207 | USBD_BUSY, |
| 197 | USBD_FAIL, |
208 | USBD_FAIL, |
| 198 | }USBD_StatusTypeDef; |
209 | } USBD_StatusTypeDef; |
| 199 | 210 | ||
| 200 | /* USB Device descriptors structure */ |
211 | /* USB Device descriptors structure */ |
| 201 | typedef struct |
212 | typedef struct |
| 202 | { |
213 | { |
| 203 | uint8_t *(*GetDeviceDescriptor)( USBD_SpeedTypeDef speed , uint16_t *length); |
214 | uint8_t *(*GetDeviceDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length); |
| 204 | uint8_t *(*GetLangIDStrDescriptor)( USBD_SpeedTypeDef speed , uint16_t *length); |
215 | uint8_t *(*GetLangIDStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length); |
| 205 | uint8_t *(*GetManufacturerStrDescriptor)( USBD_SpeedTypeDef speed , uint16_t *length); |
216 | uint8_t *(*GetManufacturerStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length); |
| 206 | uint8_t *(*GetProductStrDescriptor)( USBD_SpeedTypeDef speed , uint16_t *length); |
217 | uint8_t *(*GetProductStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length); |
| 207 | uint8_t *(*GetSerialStrDescriptor)( USBD_SpeedTypeDef speed , uint16_t *length); |
218 | uint8_t *(*GetSerialStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length); |
| 208 | uint8_t *(*GetConfigurationStrDescriptor)( USBD_SpeedTypeDef speed , uint16_t *length); |
219 | uint8_t *(*GetConfigurationStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length); |
| 209 | uint8_t *(*GetInterfaceStrDescriptor)( USBD_SpeedTypeDef speed , uint16_t *length); |
220 | uint8_t *(*GetInterfaceStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length); |
| 210 | #if (USBD_LPM_ENABLED == 1) |
221 | #if (USBD_LPM_ENABLED == 1U) |
| 211 | uint8_t *(*GetBOSDescriptor)( USBD_SpeedTypeDef speed , uint16_t *length); |
222 | uint8_t *(*GetBOSDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length); |
| 212 | #endif |
223 | #endif |
| 213 | } USBD_DescriptorsTypeDef; |
224 | } USBD_DescriptorsTypeDef; |
| 214 | 225 | ||
| 215 | /* USB Device handle structure */ |
226 | /* USB Device handle structure */ |
| 216 | typedef struct |
227 | typedef struct |
| 217 | { |
228 | { |
| 218 | uint32_t status; |
229 | uint32_t status; |
| - | 230 | uint32_t is_used; |
|
| 219 | uint32_t total_length; |
231 | uint32_t total_length; |
| 220 | uint32_t rem_length; |
232 | uint32_t rem_length; |
| 221 | uint32_t maxpacket; |
233 | uint32_t maxpacket; |
| 222 | } USBD_EndpointTypeDef; |
234 | } USBD_EndpointTypeDef; |
| 223 | 235 | ||
| 224 | /* USB Device handle structure */ |
236 | /* USB Device handle structure */ |
| 225 | typedef struct _USBD_HandleTypeDef |
237 | typedef struct _USBD_HandleTypeDef |
| 226 | { |
238 | { |
| 227 | uint8_t id; |
239 | uint8_t id; |
| 228 | uint32_t dev_config; |
240 | uint32_t dev_config; |
| 229 | uint32_t dev_default_config; |
241 | uint32_t dev_default_config; |
| 230 | uint32_t dev_config_status; |
242 | uint32_t dev_config_status; |
| 231 | USBD_SpeedTypeDef dev_speed; |
243 | USBD_SpeedTypeDef dev_speed; |
| 232 | USBD_EndpointTypeDef ep_in[15]; |
244 | USBD_EndpointTypeDef ep_in[16]; |
| 233 | USBD_EndpointTypeDef ep_out[15]; |
245 | USBD_EndpointTypeDef ep_out[16]; |
| 234 | uint32_t ep0_state; |
246 | uint32_t ep0_state; |
| 235 | uint32_t ep0_data_len; |
247 | uint32_t ep0_data_len; |
| 236 | uint8_t dev_state; |
248 | uint8_t dev_state; |
| 237 | uint8_t dev_old_state; |
249 | uint8_t dev_old_state; |
| 238 | uint8_t dev_address; |
250 | uint8_t dev_address; |
| 239 | uint8_t dev_connection_status; |
251 | uint8_t dev_connection_status; |
| 240 | uint8_t dev_test_mode; |
252 | uint8_t dev_test_mode; |
| 241 | uint32_t dev_remote_wakeup; |
253 | uint32_t dev_remote_wakeup; |
| 242 | 254 | ||
| 243 | USBD_SetupReqTypedef request; |
255 | USBD_SetupReqTypedef request; |
| 244 | USBD_DescriptorsTypeDef *pDesc; |
256 | USBD_DescriptorsTypeDef *pDesc; |
| 245 | USBD_ClassTypeDef *pClass; |
257 | USBD_ClassTypeDef *pClass; |
| 246 | void *pClassData; |
258 | void *pClassData; |
| 247 | void *pUserData; |
259 | void *pUserData; |
| 248 | void *pData; |
260 | void *pData; |
| 249 | } USBD_HandleTypeDef; |
261 | } USBD_HandleTypeDef; |
| 250 | 262 | ||
| 251 | /** |
263 | /** |
| 252 | * @} |
264 | * @} |
| 253 | */ |
265 | */ |
| 254 | 266 | ||
| 255 | 267 | ||
| 256 | 268 | ||
| 257 | /** @defgroup USBD_DEF_Exported_Macros |
269 | /** @defgroup USBD_DEF_Exported_Macros |
| 258 | * @{ |
270 | * @{ |
| 259 | */ |
271 | */ |
| 260 | #define SWAPBYTE(addr) (((uint16_t)(*((uint8_t *)(addr)))) + \ |
272 | #define SWAPBYTE(addr) (((uint16_t)(*((uint8_t *)(addr)))) + \ |
| 261 | (((uint16_t)(*(((uint8_t *)(addr)) + 1))) << 8)) |
273 | (((uint16_t)(*(((uint8_t *)(addr)) + 1U))) << 8U)) |
| 262 | 274 | ||
| 263 | #define LOBYTE(x) ((uint8_t)(x & 0x00FF)) |
275 | #define LOBYTE(x) ((uint8_t)((x) & 0x00FFU)) |
| 264 | #define HIBYTE(x) ((uint8_t)((x & 0xFF00) >>8)) |
276 | #define HIBYTE(x) ((uint8_t)(((x) & 0xFF00U) >> 8U)) |
| 265 | #define MIN(a, b) (((a) < (b)) ? (a) : (b)) |
277 | #define MIN(a, b) (((a) < (b)) ? (a) : (b)) |
| 266 | #define MAX(a, b) (((a) > (b)) ? (a) : (b)) |
278 | #define MAX(a, b) (((a) > (b)) ? (a) : (b)) |
| 267 | 279 | ||
| 268 | 280 | ||
| 269 | #if defined ( __GNUC__ ) |
281 | #if defined ( __GNUC__ ) |
| 270 | #ifndef __weak |
282 | #ifndef __weak |
| 271 | #define __weak __attribute__((weak)) |
283 | #define __weak __attribute__((weak)) |
| 272 | #endif /* __weak */ |
284 | #endif /* __weak */ |
| 273 | #ifndef __packed |
285 | #ifndef __packed |
| 274 | #define __packed __attribute__((__packed__)) |
286 | #define __packed __attribute__((__packed__)) |
| 275 | #endif /* __packed */ |
287 | #endif /* __packed */ |
| 276 | #endif /* __GNUC__ */ |
288 | #endif /* __GNUC__ */ |
| 277 | 289 | ||
| 278 | 290 | ||
| 279 | /* In HS mode and when the DMA is used, all variables and data structures dealing |
291 | /* In HS mode and when the DMA is used, all variables and data structures dealing |
| 280 | with the DMA during the transaction process should be 4-bytes aligned */ |
292 | with the DMA during the transaction process should be 4-bytes aligned */ |
| - | 293 | ||
| - | 294 | #if defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */ |
|
| - | 295 | #ifndef __ALIGN_END |
|
| - | 296 | #define __ALIGN_END __attribute__ ((aligned (4U))) |
|
| - | 297 | #endif /* __ALIGN_END */ |
|
| - | 298 | #ifndef __ALIGN_BEGIN |
|
| - | 299 | #define __ALIGN_BEGIN |
|
| - | 300 | #endif /* __ALIGN_BEGIN */ |
|
| - | 301 | #else |
|
| - | 302 | #ifndef __ALIGN_END |
|
| - | 303 | #define __ALIGN_END |
|
| - | 304 | #endif /* __ALIGN_END */ |
|
| - | 305 | #ifndef __ALIGN_BEGIN |
|
| - | 306 | #if defined (__CC_ARM) /* ARM Compiler */ |
|
| - | 307 | #define __ALIGN_BEGIN __align(4U) |
|
| - | 308 | #elif defined (__ICCARM__) /* IAR Compiler */ |
|
| - | 309 | #define __ALIGN_BEGIN |
|
| - | 310 | #endif /* __CC_ARM */ |
|
| - | 311 | #endif /* __ALIGN_BEGIN */ |
|
| - | 312 | #endif /* __GNUC__ */ |
|
| 281 | 313 | ||
| 282 | #if defined (__GNUC__) /* GNU Compiler */ |
- | |
| 283 | #define __ALIGN_END __attribute__ ((aligned (4))) |
- | |
| 284 | #define __ALIGN_BEGIN |
- | |
| 285 | #else |
- | |
| 286 | #define __ALIGN_END |
- | |
| 287 | #if defined (__CC_ARM) /* ARM Compiler */ |
- | |
| 288 | #define __ALIGN_BEGIN __align(4) |
- | |
| 289 | #elif defined (__ICCARM__) /* IAR Compiler */ |
- | |
| 290 | #define __ALIGN_BEGIN |
- | |
| 291 | #elif defined (__TASKING__) /* TASKING Compiler */ |
- | |
| 292 | #define __ALIGN_BEGIN __align(4) |
- | |
| 293 | #endif /* __CC_ARM */ |
- | |
| 294 | #endif /* __GNUC__ */ |
- | |
| 295 | - | ||
| 296 | 314 | ||
| 297 | /** |
315 | /** |
| 298 | * @} |
316 | * @} |
| 299 | */ |
317 | */ |
| 300 | 318 | ||
| 301 | /** @defgroup USBD_DEF_Exported_Variables |
319 | /** @defgroup USBD_DEF_Exported_Variables |
| 302 | * @{ |
320 | * @{ |
| 303 | */ |
321 | */ |
| 304 | 322 | ||
| 305 | /** |
323 | /** |
| 306 | * @} |
324 | * @} |
| 307 | */ |
325 | */ |
| 308 | 326 | ||
| 309 | /** @defgroup USBD_DEF_Exported_FunctionsPrototype |
327 | /** @defgroup USBD_DEF_Exported_FunctionsPrototype |
| 310 | * @{ |
328 | * @{ |
| 311 | */ |
329 | */ |
| 312 | 330 | ||
| 313 | /** |
331 | /** |
| 314 | * @} |
332 | * @} |
| 315 | */ |
333 | */ |
| 316 | 334 | ||
| 317 | #ifdef __cplusplus |
335 | #ifdef __cplusplus |
| 318 | } |
336 | } |
| 319 | #endif |
337 | #endif |
| 320 | 338 | ||
| 321 | #endif /* __USBD_DEF_H */ |
339 | #endif /* __USBD_DEF_H */ |
| 322 | 340 | ||
| 323 | /** |
341 | /** |
| 324 | * @} |
342 | * @} |
| 325 | */ |
343 | */ |
| 326 | 344 | ||
| 327 | /** |
345 | /** |
| 328 | * @} |
346 | * @} |
| 329 | */ |
347 | */ |
| 330 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
348 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |