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