| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,514 @@ |
| 1 |
+/** |
|
| 2 |
+ ****************************************************************************** |
|
| 3 |
+ * @file usbd_def.h |
|
| 4 |
+ * @author MCD Application Team |
|
| 5 |
+ * @brief General defines for the usb device library |
|
| 6 |
+ ****************************************************************************** |
|
| 7 |
+ * @attention |
|
| 8 |
+ * |
|
| 9 |
+ * Copyright (c) 2015 STMicroelectronics. |
|
| 10 |
+ * All rights reserved. |
|
| 11 |
+ * |
|
| 12 |
+ * This software is licensed under terms that can be found in the LICENSE file |
|
| 13 |
+ * in the root directory of this software component. |
|
| 14 |
+ * If no LICENSE file comes with this software, it is provided AS-IS. |
|
| 15 |
+ * |
|
| 16 |
+ ****************************************************************************** |
|
| 17 |
+ */ |
|
| 18 |
+ |
|
| 19 |
+/* Define to prevent recursive inclusion -------------------------------------*/ |
|
| 20 |
+#ifndef __USBD_DEF_H |
|
| 21 |
+#define __USBD_DEF_H |
|
| 22 |
+ |
|
| 23 |
+#ifdef __cplusplus |
|
| 24 |
+extern "C" {
|
|
| 25 |
+#endif |
|
| 26 |
+ |
|
| 27 |
+/* Includes ------------------------------------------------------------------*/ |
|
| 28 |
+#include "usbd_conf.h" |
|
| 29 |
+ |
|
| 30 |
+/** @addtogroup STM32_USBD_DEVICE_LIBRARY |
|
| 31 |
+ * @{
|
|
| 32 |
+ */ |
|
| 33 |
+ |
|
| 34 |
+/** @defgroup USB_DEF |
|
| 35 |
+ * @brief general defines for the usb device library file |
|
| 36 |
+ * @{
|
|
| 37 |
+ */ |
|
| 38 |
+ |
|
| 39 |
+/** @defgroup USB_DEF_Exported_Defines |
|
| 40 |
+ * @{
|
|
| 41 |
+ */ |
|
| 42 |
+ |
|
| 43 |
+#ifndef NULL |
|
| 44 |
+#define NULL 0U |
|
| 45 |
+#endif /* NULL */ |
|
| 46 |
+ |
|
| 47 |
+#ifndef USBD_MAX_NUM_INTERFACES |
|
| 48 |
+#define USBD_MAX_NUM_INTERFACES 1U |
|
| 49 |
+#endif /* USBD_MAX_NUM_CONFIGURATION */ |
|
| 50 |
+ |
|
| 51 |
+#ifndef USBD_MAX_NUM_CONFIGURATION |
|
| 52 |
+#define USBD_MAX_NUM_CONFIGURATION 1U |
|
| 53 |
+#endif /* USBD_MAX_NUM_CONFIGURATION */ |
|
| 54 |
+ |
|
| 55 |
+#ifdef USE_USBD_COMPOSITE |
|
| 56 |
+#ifndef USBD_MAX_SUPPORTED_CLASS |
|
| 57 |
+#define USBD_MAX_SUPPORTED_CLASS 4U |
|
| 58 |
+#endif /* USBD_MAX_SUPPORTED_CLASS */ |
|
| 59 |
+#else |
|
| 60 |
+#ifndef USBD_MAX_SUPPORTED_CLASS |
|
| 61 |
+#define USBD_MAX_SUPPORTED_CLASS 1U |
|
| 62 |
+#endif /* USBD_MAX_SUPPORTED_CLASS */ |
|
| 63 |
+#endif /* USE_USBD_COMPOSITE */ |
|
| 64 |
+ |
|
| 65 |
+#ifndef USBD_MAX_CLASS_ENDPOINTS |
|
| 66 |
+#define USBD_MAX_CLASS_ENDPOINTS 5U |
|
| 67 |
+#endif /* USBD_MAX_CLASS_ENDPOINTS */ |
|
| 68 |
+ |
|
| 69 |
+#ifndef USBD_MAX_CLASS_INTERFACES |
|
| 70 |
+#define USBD_MAX_CLASS_INTERFACES 5U |
|
| 71 |
+#endif /* USBD_MAX_CLASS_INTERFACES */ |
|
| 72 |
+ |
|
| 73 |
+#ifndef USBD_LPM_ENABLED |
|
| 74 |
+#define USBD_LPM_ENABLED 0U |
|
| 75 |
+#endif /* USBD_LPM_ENABLED */ |
|
| 76 |
+ |
|
| 77 |
+#ifndef USBD_SELF_POWERED |
|
| 78 |
+#define USBD_SELF_POWERED 1U |
|
| 79 |
+#endif /*USBD_SELF_POWERED */ |
|
| 80 |
+ |
|
| 81 |
+#ifndef USBD_MAX_POWER |
|
| 82 |
+#define USBD_MAX_POWER 0x32U /* 100 mA */ |
|
| 83 |
+#endif /* USBD_MAX_POWER */ |
|
| 84 |
+ |
|
| 85 |
+#ifndef USBD_SUPPORT_USER_STRING_DESC |
|
| 86 |
+#define USBD_SUPPORT_USER_STRING_DESC 0U |
|
| 87 |
+#endif /* USBD_SUPPORT_USER_STRING_DESC */ |
|
| 88 |
+ |
|
| 89 |
+#ifndef USBD_CLASS_USER_STRING_DESC |
|
| 90 |
+#define USBD_CLASS_USER_STRING_DESC 0U |
|
| 91 |
+#endif /* USBD_CLASS_USER_STRING_DESC */ |
|
| 92 |
+ |
|
| 93 |
+#define USB_LEN_DEV_QUALIFIER_DESC 0x0AU |
|
| 94 |
+#define USB_LEN_DEV_DESC 0x12U |
|
| 95 |
+#define USB_LEN_CFG_DESC 0x09U |
|
| 96 |
+#define USB_LEN_IF_DESC 0x09U |
|
| 97 |
+#define USB_LEN_EP_DESC 0x07U |
|
| 98 |
+#define USB_LEN_OTG_DESC 0x03U |
|
| 99 |
+#define USB_LEN_LANGID_STR_DESC 0x04U |
|
| 100 |
+#define USB_LEN_OTHER_SPEED_DESC_SIZ 0x09U |
|
| 101 |
+ |
|
| 102 |
+#define USBD_IDX_LANGID_STR 0x00U |
|
| 103 |
+#define USBD_IDX_MFC_STR 0x01U |
|
| 104 |
+#define USBD_IDX_PRODUCT_STR 0x02U |
|
| 105 |
+#define USBD_IDX_SERIAL_STR 0x03U |
|
| 106 |
+#define USBD_IDX_CONFIG_STR 0x04U |
|
| 107 |
+#define USBD_IDX_INTERFACE_STR 0x05U |
|
| 108 |
+ |
|
| 109 |
+#define USB_REQ_TYPE_STANDARD 0x00U |
|
| 110 |
+#define USB_REQ_TYPE_CLASS 0x20U |
|
| 111 |
+#define USB_REQ_TYPE_VENDOR 0x40U |
|
| 112 |
+#define USB_REQ_TYPE_MASK 0x60U |
|
| 113 |
+ |
|
| 114 |
+#define USB_REQ_RECIPIENT_DEVICE 0x00U |
|
| 115 |
+#define USB_REQ_RECIPIENT_INTERFACE 0x01U |
|
| 116 |
+#define USB_REQ_RECIPIENT_ENDPOINT 0x02U |
|
| 117 |
+#define USB_REQ_RECIPIENT_MASK 0x03U |
|
| 118 |
+ |
|
| 119 |
+#define USB_REQ_GET_STATUS 0x00U |
|
| 120 |
+#define USB_REQ_CLEAR_FEATURE 0x01U |
|
| 121 |
+#define USB_REQ_SET_FEATURE 0x03U |
|
| 122 |
+#define USB_REQ_SET_ADDRESS 0x05U |
|
| 123 |
+#define USB_REQ_GET_DESCRIPTOR 0x06U |
|
| 124 |
+#define USB_REQ_SET_DESCRIPTOR 0x07U |
|
| 125 |
+#define USB_REQ_GET_CONFIGURATION 0x08U |
|
| 126 |
+#define USB_REQ_SET_CONFIGURATION 0x09U |
|
| 127 |
+#define USB_REQ_GET_INTERFACE 0x0AU |
|
| 128 |
+#define USB_REQ_SET_INTERFACE 0x0BU |
|
| 129 |
+#define USB_REQ_SYNCH_FRAME 0x0CU |
|
| 130 |
+ |
|
| 131 |
+#define USB_DESC_TYPE_DEVICE 0x01U |
|
| 132 |
+#define USB_DESC_TYPE_CONFIGURATION 0x02U |
|
| 133 |
+#define USB_DESC_TYPE_STRING 0x03U |
|
| 134 |
+#define USB_DESC_TYPE_INTERFACE 0x04U |
|
| 135 |
+#define USB_DESC_TYPE_ENDPOINT 0x05U |
|
| 136 |
+#define USB_DESC_TYPE_DEVICE_QUALIFIER 0x06U |
|
| 137 |
+#define USB_DESC_TYPE_OTHER_SPEED_CONFIGURATION 0x07U |
|
| 138 |
+#define USB_DESC_TYPE_IAD 0x0BU |
|
| 139 |
+#define USB_DESC_TYPE_BOS 0x0FU |
|
| 140 |
+ |
|
| 141 |
+#define USB_CONFIG_REMOTE_WAKEUP 0x02U |
|
| 142 |
+#define USB_CONFIG_SELF_POWERED 0x01U |
|
| 143 |
+ |
|
| 144 |
+#define USB_FEATURE_EP_HALT 0x00U |
|
| 145 |
+#define USB_FEATURE_REMOTE_WAKEUP 0x01U |
|
| 146 |
+#define USB_FEATURE_TEST_MODE 0x02U |
|
| 147 |
+ |
|
| 148 |
+#define USB_DEVICE_CAPABITY_TYPE 0x10U |
|
| 149 |
+ |
|
| 150 |
+#define USB_CONF_DESC_SIZE 0x09U |
|
| 151 |
+#define USB_IF_DESC_SIZE 0x09U |
|
| 152 |
+#define USB_EP_DESC_SIZE 0x07U |
|
| 153 |
+#define USB_IAD_DESC_SIZE 0x08U |
|
| 154 |
+ |
|
| 155 |
+#define USB_HS_MAX_PACKET_SIZE 512U |
|
| 156 |
+#define USB_FS_MAX_PACKET_SIZE 64U |
|
| 157 |
+#define USB_MAX_EP0_SIZE 64U |
|
| 158 |
+ |
|
| 159 |
+/* Device Status */ |
|
| 160 |
+#define USBD_STATE_DEFAULT 0x01U |
|
| 161 |
+#define USBD_STATE_ADDRESSED 0x02U |
|
| 162 |
+#define USBD_STATE_CONFIGURED 0x03U |
|
| 163 |
+#define USBD_STATE_SUSPENDED 0x04U |
|
| 164 |
+ |
|
| 165 |
+ |
|
| 166 |
+/* EP0 State */ |
|
| 167 |
+#define USBD_EP0_IDLE 0x00U |
|
| 168 |
+#define USBD_EP0_SETUP 0x01U |
|
| 169 |
+#define USBD_EP0_DATA_IN 0x02U |
|
| 170 |
+#define USBD_EP0_DATA_OUT 0x03U |
|
| 171 |
+#define USBD_EP0_STATUS_IN 0x04U |
|
| 172 |
+#define USBD_EP0_STATUS_OUT 0x05U |
|
| 173 |
+#define USBD_EP0_STALL 0x06U |
|
| 174 |
+ |
|
| 175 |
+#define USBD_EP_TYPE_CTRL 0x00U |
|
| 176 |
+#define USBD_EP_TYPE_ISOC 0x01U |
|
| 177 |
+#define USBD_EP_TYPE_BULK 0x02U |
|
| 178 |
+#define USBD_EP_TYPE_INTR 0x03U |
|
| 179 |
+ |
|
| 180 |
+#ifdef USE_USBD_COMPOSITE |
|
| 181 |
+#define USBD_EP_IN 0x80U |
|
| 182 |
+#define USBD_EP_OUT 0x00U |
|
| 183 |
+#define USBD_FUNC_DESCRIPTOR_TYPE 0x24U |
|
| 184 |
+#define USBD_DESC_SUBTYPE_ACM 0x0FU |
|
| 185 |
+#define USBD_DESC_ECM_BCD_LOW 0x00U |
|
| 186 |
+#define USBD_DESC_ECM_BCD_HIGH 0x10U |
|
| 187 |
+#endif /* USE_USBD_COMPOSITE */ |
|
| 188 |
+/** |
|
| 189 |
+ * @} |
|
| 190 |
+ */ |
|
| 191 |
+ |
|
| 192 |
+ |
|
| 193 |
+/** @defgroup USBD_DEF_Exported_TypesDefinitions |
|
| 194 |
+ * @{
|
|
| 195 |
+ */ |
|
| 196 |
+ |
|
| 197 |
+typedef struct usb_setup_req |
|
| 198 |
+{
|
|
| 199 |
+ uint8_t bmRequest; |
|
| 200 |
+ uint8_t bRequest; |
|
| 201 |
+ uint16_t wValue; |
|
| 202 |
+ uint16_t wIndex; |
|
| 203 |
+ uint16_t wLength; |
|
| 204 |
+} USBD_SetupReqTypedef; |
|
| 205 |
+ |
|
| 206 |
+typedef struct |
|
| 207 |
+{
|
|
| 208 |
+ uint8_t bLength; |
|
| 209 |
+ uint8_t bDescriptorType; |
|
| 210 |
+ uint16_t wTotalLength; |
|
| 211 |
+ uint8_t bNumInterfaces; |
|
| 212 |
+ uint8_t bConfigurationValue; |
|
| 213 |
+ uint8_t iConfiguration; |
|
| 214 |
+ uint8_t bmAttributes; |
|
| 215 |
+ uint8_t bMaxPower; |
|
| 216 |
+} __PACKED USBD_ConfigDescTypeDef; |
|
| 217 |
+ |
|
| 218 |
+typedef struct |
|
| 219 |
+{
|
|
| 220 |
+ uint8_t bLength; |
|
| 221 |
+ uint8_t bDescriptorType; |
|
| 222 |
+ uint16_t wTotalLength; |
|
| 223 |
+ uint8_t bNumDeviceCaps; |
|
| 224 |
+} USBD_BosDescTypeDef; |
|
| 225 |
+ |
|
| 226 |
+typedef struct |
|
| 227 |
+{
|
|
| 228 |
+ uint8_t bLength; |
|
| 229 |
+ uint8_t bDescriptorType; |
|
| 230 |
+ uint8_t bEndpointAddress; |
|
| 231 |
+ uint8_t bmAttributes; |
|
| 232 |
+ uint16_t wMaxPacketSize; |
|
| 233 |
+ uint8_t bInterval; |
|
| 234 |
+} __PACKED USBD_EpDescTypeDef; |
|
| 235 |
+ |
|
| 236 |
+typedef struct |
|
| 237 |
+{
|
|
| 238 |
+ uint8_t bLength; |
|
| 239 |
+ uint8_t bDescriptorType; |
|
| 240 |
+ uint8_t bDescriptorSubType; |
|
| 241 |
+} USBD_DescHeaderTypeDef; |
|
| 242 |
+ |
|
| 243 |
+struct _USBD_HandleTypeDef; |
|
| 244 |
+ |
|
| 245 |
+typedef struct _Device_cb |
|
| 246 |
+{
|
|
| 247 |
+ uint8_t (*Init)(struct _USBD_HandleTypeDef *pdev, uint8_t cfgidx); |
|
| 248 |
+ uint8_t (*DeInit)(struct _USBD_HandleTypeDef *pdev, uint8_t cfgidx); |
|
| 249 |
+ /* Control Endpoints*/ |
|
| 250 |
+ uint8_t (*Setup)(struct _USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); |
|
| 251 |
+ uint8_t (*EP0_TxSent)(struct _USBD_HandleTypeDef *pdev); |
|
| 252 |
+ uint8_t (*EP0_RxReady)(struct _USBD_HandleTypeDef *pdev); |
|
| 253 |
+ /* Class Specific Endpoints*/ |
|
| 254 |
+ uint8_t (*DataIn)(struct _USBD_HandleTypeDef *pdev, uint8_t epnum); |
|
| 255 |
+ uint8_t (*DataOut)(struct _USBD_HandleTypeDef *pdev, uint8_t epnum); |
|
| 256 |
+ uint8_t (*SOF)(struct _USBD_HandleTypeDef *pdev); |
|
| 257 |
+ uint8_t (*IsoINIncomplete)(struct _USBD_HandleTypeDef *pdev, uint8_t epnum); |
|
| 258 |
+ uint8_t (*IsoOUTIncomplete)(struct _USBD_HandleTypeDef *pdev, uint8_t epnum); |
|
| 259 |
+ |
|
| 260 |
+ uint8_t *(*GetHSConfigDescriptor)(uint16_t *length); |
|
| 261 |
+ uint8_t *(*GetFSConfigDescriptor)(uint16_t *length); |
|
| 262 |
+ uint8_t *(*GetOtherSpeedConfigDescriptor)(uint16_t *length); |
|
| 263 |
+ uint8_t *(*GetDeviceQualifierDescriptor)(uint16_t *length); |
|
| 264 |
+#if (USBD_SUPPORT_USER_STRING_DESC == 1U) |
|
| 265 |
+ uint8_t *(*GetUsrStrDescriptor)(struct _USBD_HandleTypeDef *pdev, uint8_t index, uint16_t *length); |
|
| 266 |
+#endif /* USBD_SUPPORT_USER_STRING_DESC */ |
|
| 267 |
+ |
|
| 268 |
+} USBD_ClassTypeDef; |
|
| 269 |
+ |
|
| 270 |
+/* Following USB Device Speed */ |
|
| 271 |
+typedef enum |
|
| 272 |
+{
|
|
| 273 |
+ USBD_SPEED_HIGH = 0U, |
|
| 274 |
+ USBD_SPEED_FULL = 1U, |
|
| 275 |
+ USBD_SPEED_LOW = 2U, |
|
| 276 |
+} USBD_SpeedTypeDef; |
|
| 277 |
+ |
|
| 278 |
+/* Following USB Device status */ |
|
| 279 |
+typedef enum |
|
| 280 |
+{
|
|
| 281 |
+ USBD_OK = 0U, |
|
| 282 |
+ USBD_BUSY, |
|
| 283 |
+ USBD_EMEM, |
|
| 284 |
+ USBD_FAIL, |
|
| 285 |
+} USBD_StatusTypeDef; |
|
| 286 |
+ |
|
| 287 |
+/* USB Device descriptors structure */ |
|
| 288 |
+typedef struct |
|
| 289 |
+{
|
|
| 290 |
+ uint8_t *(*GetDeviceDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length); |
|
| 291 |
+ uint8_t *(*GetLangIDStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length); |
|
| 292 |
+ uint8_t *(*GetManufacturerStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length); |
|
| 293 |
+ uint8_t *(*GetProductStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length); |
|
| 294 |
+ uint8_t *(*GetSerialStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length); |
|
| 295 |
+ uint8_t *(*GetConfigurationStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length); |
|
| 296 |
+ uint8_t *(*GetInterfaceStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length); |
|
| 297 |
+#if (USBD_CLASS_USER_STRING_DESC == 1) |
|
| 298 |
+ uint8_t *(*GetUserStrDescriptor)(USBD_SpeedTypeDef speed, uint8_t idx, uint16_t *length); |
|
| 299 |
+#endif /* USBD_CLASS_USER_STRING_DESC */ |
|
| 300 |
+#if ((USBD_LPM_ENABLED == 1U) || (USBD_CLASS_BOS_ENABLED == 1)) |
|
| 301 |
+ uint8_t *(*GetBOSDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length); |
|
| 302 |
+#endif /* (USBD_LPM_ENABLED == 1U) || (USBD_CLASS_BOS_ENABLED == 1) */ |
|
| 303 |
+} USBD_DescriptorsTypeDef; |
|
| 304 |
+ |
|
| 305 |
+/* USB Device handle structure */ |
|
| 306 |
+typedef struct |
|
| 307 |
+{
|
|
| 308 |
+ uint32_t status; |
|
| 309 |
+ uint32_t total_length; |
|
| 310 |
+ uint32_t rem_length; |
|
| 311 |
+ uint32_t maxpacket; |
|
| 312 |
+ uint16_t is_used; |
|
| 313 |
+ uint16_t bInterval; |
|
| 314 |
+} USBD_EndpointTypeDef; |
|
| 315 |
+ |
|
| 316 |
+#ifdef USE_USBD_COMPOSITE |
|
| 317 |
+typedef enum |
|
| 318 |
+{
|
|
| 319 |
+ CLASS_TYPE_NONE = 0, |
|
| 320 |
+ CLASS_TYPE_HID = 1, |
|
| 321 |
+ CLASS_TYPE_CDC = 2, |
|
| 322 |
+ CLASS_TYPE_MSC = 3, |
|
| 323 |
+ CLASS_TYPE_DFU = 4, |
|
| 324 |
+ CLASS_TYPE_CHID = 5, |
|
| 325 |
+ CLASS_TYPE_AUDIO = 6, |
|
| 326 |
+ CLASS_TYPE_ECM = 7, |
|
| 327 |
+ CLASS_TYPE_RNDIS = 8, |
|
| 328 |
+ CLASS_TYPE_MTP = 9, |
|
| 329 |
+ CLASS_TYPE_VIDEO = 10, |
|
| 330 |
+ CLASS_TYPE_PRINTER = 11, |
|
| 331 |
+ CLASS_TYPE_CCID = 12, |
|
| 332 |
+} USBD_CompositeClassTypeDef; |
|
| 333 |
+ |
|
| 334 |
+ |
|
| 335 |
+/* USB Device handle structure */ |
|
| 336 |
+typedef struct |
|
| 337 |
+{
|
|
| 338 |
+ uint8_t add; |
|
| 339 |
+ uint8_t type; |
|
| 340 |
+ uint8_t size; |
|
| 341 |
+ uint8_t is_used; |
|
| 342 |
+} USBD_EPTypeDef; |
|
| 343 |
+ |
|
| 344 |
+/* USB Device handle structure */ |
|
| 345 |
+typedef struct |
|
| 346 |
+{
|
|
| 347 |
+ USBD_CompositeClassTypeDef ClassType; |
|
| 348 |
+ uint32_t ClassId; |
|
| 349 |
+ uint32_t Active; |
|
| 350 |
+ uint32_t NumEps; |
|
| 351 |
+ USBD_EPTypeDef Eps[USBD_MAX_CLASS_ENDPOINTS]; |
|
| 352 |
+ uint8_t *EpAdd; |
|
| 353 |
+ uint32_t NumIf; |
|
| 354 |
+ uint8_t Ifs[USBD_MAX_CLASS_INTERFACES]; |
|
| 355 |
+ uint32_t CurrPcktSze; |
|
| 356 |
+} USBD_CompositeElementTypeDef; |
|
| 357 |
+#endif /* USE_USBD_COMPOSITE */ |
|
| 358 |
+ |
|
| 359 |
+/* USB Device handle structure */ |
|
| 360 |
+typedef struct _USBD_HandleTypeDef |
|
| 361 |
+{
|
|
| 362 |
+ uint8_t id; |
|
| 363 |
+ uint32_t dev_config; |
|
| 364 |
+ uint32_t dev_default_config; |
|
| 365 |
+ uint32_t dev_config_status; |
|
| 366 |
+ USBD_SpeedTypeDef dev_speed; |
|
| 367 |
+ USBD_EndpointTypeDef ep_in[16]; |
|
| 368 |
+ USBD_EndpointTypeDef ep_out[16]; |
|
| 369 |
+ __IO uint32_t ep0_state; |
|
| 370 |
+ uint32_t ep0_data_len; |
|
| 371 |
+ __IO uint8_t dev_state; |
|
| 372 |
+ __IO uint8_t dev_old_state; |
|
| 373 |
+ uint8_t dev_address; |
|
| 374 |
+ uint8_t dev_connection_status; |
|
| 375 |
+ uint8_t dev_test_mode; |
|
| 376 |
+ uint32_t dev_remote_wakeup; |
|
| 377 |
+ uint8_t ConfIdx; |
|
| 378 |
+ |
|
| 379 |
+ USBD_SetupReqTypedef request; |
|
| 380 |
+ USBD_DescriptorsTypeDef *pDesc; |
|
| 381 |
+ USBD_ClassTypeDef *pClass[USBD_MAX_SUPPORTED_CLASS]; |
|
| 382 |
+ void *pClassData; |
|
| 383 |
+ void *pClassDataCmsit[USBD_MAX_SUPPORTED_CLASS]; |
|
| 384 |
+ void *pUserData[USBD_MAX_SUPPORTED_CLASS]; |
|
| 385 |
+ void *pData; |
|
| 386 |
+ void *pBosDesc; |
|
| 387 |
+ void *pConfDesc; |
|
| 388 |
+ uint32_t classId; |
|
| 389 |
+ uint32_t NumClasses; |
|
| 390 |
+#ifdef USE_USBD_COMPOSITE |
|
| 391 |
+ USBD_CompositeElementTypeDef tclasslist[USBD_MAX_SUPPORTED_CLASS]; |
|
| 392 |
+#endif /* USE_USBD_COMPOSITE */ |
|
| 393 |
+} USBD_HandleTypeDef; |
|
| 394 |
+ |
|
| 395 |
+/* USB Device endpoint direction */ |
|
| 396 |
+typedef enum |
|
| 397 |
+{
|
|
| 398 |
+ OUT = 0x00, |
|
| 399 |
+ IN = 0x80, |
|
| 400 |
+} USBD_EPDirectionTypeDef; |
|
| 401 |
+ |
|
| 402 |
+typedef enum |
|
| 403 |
+{
|
|
| 404 |
+ NETWORK_CONNECTION = 0x00, |
|
| 405 |
+ RESPONSE_AVAILABLE = 0x01, |
|
| 406 |
+ CONNECTION_SPEED_CHANGE = 0x2A |
|
| 407 |
+} USBD_CDC_NotifCodeTypeDef; |
|
| 408 |
+/** |
|
| 409 |
+ * @} |
|
| 410 |
+ */ |
|
| 411 |
+ |
|
| 412 |
+ |
|
| 413 |
+ |
|
| 414 |
+/** @defgroup USBD_DEF_Exported_Macros |
|
| 415 |
+ * @{
|
|
| 416 |
+ */ |
|
| 417 |
+__STATIC_INLINE uint16_t SWAPBYTE(uint8_t *addr) |
|
| 418 |
+{
|
|
| 419 |
+ uint16_t _SwapVal, _Byte1, _Byte2; |
|
| 420 |
+ uint8_t *_pbuff = addr; |
|
| 421 |
+ |
|
| 422 |
+ _Byte1 = *(uint8_t *)_pbuff; |
|
| 423 |
+ _pbuff++; |
|
| 424 |
+ _Byte2 = *(uint8_t *)_pbuff; |
|
| 425 |
+ |
|
| 426 |
+ _SwapVal = (_Byte2 << 8) | _Byte1; |
|
| 427 |
+ |
|
| 428 |
+ return _SwapVal; |
|
| 429 |
+} |
|
| 430 |
+ |
|
| 431 |
+#ifndef LOBYTE |
|
| 432 |
+#define LOBYTE(x) ((uint8_t)((x) & 0x00FFU)) |
|
| 433 |
+#endif /* LOBYTE */ |
|
| 434 |
+ |
|
| 435 |
+#ifndef HIBYTE |
|
| 436 |
+#define HIBYTE(x) ((uint8_t)(((x) & 0xFF00U) >> 8U)) |
|
| 437 |
+#endif /* HIBYTE */ |
|
| 438 |
+ |
|
| 439 |
+#ifndef MIN |
|
| 440 |
+#define MIN(a, b) (((a) < (b)) ? (a) : (b)) |
|
| 441 |
+#endif /* MIN */ |
|
| 442 |
+ |
|
| 443 |
+#ifndef MAX |
|
| 444 |
+#define MAX(a, b) (((a) > (b)) ? (a) : (b)) |
|
| 445 |
+#endif /* MAX */ |
|
| 446 |
+ |
|
| 447 |
+#if defined ( __GNUC__ ) |
|
| 448 |
+#ifndef __weak |
|
| 449 |
+#define __weak __attribute__((weak)) |
|
| 450 |
+#endif /* __weak */ |
|
| 451 |
+#ifndef __packed |
|
| 452 |
+#define __packed __attribute__((__packed__)) |
|
| 453 |
+#endif /* __packed */ |
|
| 454 |
+#endif /* __GNUC__ */ |
|
| 455 |
+ |
|
| 456 |
+ |
|
| 457 |
+/* In HS mode and when the DMA is used, all variables and data structures dealing |
|
| 458 |
+ with the DMA during the transaction process should be 4-bytes aligned */ |
|
| 459 |
+ |
|
| 460 |
+#if defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */ |
|
| 461 |
+#ifndef __ALIGN_END |
|
| 462 |
+#define __ALIGN_END __attribute__ ((aligned (4U))) |
|
| 463 |
+#endif /* __ALIGN_END */ |
|
| 464 |
+#ifndef __ALIGN_BEGIN |
|
| 465 |
+#define __ALIGN_BEGIN |
|
| 466 |
+#endif /* __ALIGN_BEGIN */ |
|
| 467 |
+#else |
|
| 468 |
+#ifndef __ALIGN_END |
|
| 469 |
+#define __ALIGN_END |
|
| 470 |
+#endif /* __ALIGN_END */ |
|
| 471 |
+#ifndef __ALIGN_BEGIN |
|
| 472 |
+#if defined (__CC_ARM) /* ARM Compiler */ |
|
| 473 |
+#define __ALIGN_BEGIN __align(4U) |
|
| 474 |
+#elif defined (__ICCARM__) /* IAR Compiler */ |
|
| 475 |
+#define __ALIGN_BEGIN |
|
| 476 |
+#endif /* __CC_ARM */ |
|
| 477 |
+#endif /* __ALIGN_BEGIN */ |
|
| 478 |
+#endif /* __GNUC__ */ |
|
| 479 |
+ |
|
| 480 |
+ |
|
| 481 |
+/** |
|
| 482 |
+ * @} |
|
| 483 |
+ */ |
|
| 484 |
+ |
|
| 485 |
+/** @defgroup USBD_DEF_Exported_Variables |
|
| 486 |
+ * @{
|
|
| 487 |
+ */ |
|
| 488 |
+ |
|
| 489 |
+/** |
|
| 490 |
+ * @} |
|
| 491 |
+ */ |
|
| 492 |
+ |
|
| 493 |
+/** @defgroup USBD_DEF_Exported_FunctionsPrototype |
|
| 494 |
+ * @{
|
|
| 495 |
+ */ |
|
| 496 |
+ |
|
| 497 |
+/** |
|
| 498 |
+ * @} |
|
| 499 |
+ */ |
|
| 500 |
+ |
|
| 501 |
+#ifdef __cplusplus |
|
| 502 |
+} |
|
| 503 |
+#endif |
|
| 504 |
+ |
|
| 505 |
+#endif /* __USBD_DEF_H */ |
|
| 506 |
+ |
|
| 507 |
+/** |
|
| 508 |
+ * @} |
|
| 509 |
+ */ |
|
| 510 |
+ |
|
| 511 |
+/** |
|
| 512 |
+ * @} |
|
| 513 |
+ */ |
|
| 514 |
+ |