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