meh

Fork of mbed by mbed official

Committer:
Kojto
Date:
Wed May 13 08:08:21 2015 +0200
Revision:
99:dbbf35b96557
Parent:
90:cb3d968589d8
Child:
106:ba1f97679dad
Release 99 of the mbed library

Changes:
- new targets - MAXWSNENV, DISCO_L053C8
- STM32F4xx - ST Cube driver
- KSDK mcu - SPI timing fix
- Nordic - update to softdevice s130

Who changed what in which revision?

UserRevisionLine numberNew contents of line
emilmont 77:869cf507173a 1 /**
emilmont 77:869cf507173a 2 ******************************************************************************
emilmont 77:869cf507173a 3 * @file stm32f4xx_hal_hcd.h
emilmont 77:869cf507173a 4 * @author MCD Application Team
Kojto 99:dbbf35b96557 5 * @version V1.3.0
Kojto 99:dbbf35b96557 6 * @date 09-March-2015
emilmont 77:869cf507173a 7 * @brief Header file of HCD HAL module.
emilmont 77:869cf507173a 8 ******************************************************************************
emilmont 77:869cf507173a 9 * @attention
emilmont 77:869cf507173a 10 *
Kojto 99:dbbf35b96557 11 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
emilmont 77:869cf507173a 12 *
emilmont 77:869cf507173a 13 * Redistribution and use in source and binary forms, with or without modification,
emilmont 77:869cf507173a 14 * are permitted provided that the following conditions are met:
emilmont 77:869cf507173a 15 * 1. Redistributions of source code must retain the above copyright notice,
emilmont 77:869cf507173a 16 * this list of conditions and the following disclaimer.
emilmont 77:869cf507173a 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
emilmont 77:869cf507173a 18 * this list of conditions and the following disclaimer in the documentation
emilmont 77:869cf507173a 19 * and/or other materials provided with the distribution.
emilmont 77:869cf507173a 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
emilmont 77:869cf507173a 21 * may be used to endorse or promote products derived from this software
emilmont 77:869cf507173a 22 * without specific prior written permission.
emilmont 77:869cf507173a 23 *
emilmont 77:869cf507173a 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
emilmont 77:869cf507173a 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
emilmont 77:869cf507173a 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
emilmont 77:869cf507173a 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
emilmont 77:869cf507173a 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
emilmont 77:869cf507173a 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
emilmont 77:869cf507173a 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
emilmont 77:869cf507173a 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
emilmont 77:869cf507173a 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
emilmont 77:869cf507173a 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
emilmont 77:869cf507173a 34 *
emilmont 77:869cf507173a 35 ******************************************************************************
emilmont 77:869cf507173a 36 */
emilmont 77:869cf507173a 37
emilmont 77:869cf507173a 38 /* Define to prevent recursive inclusion -------------------------------------*/
emilmont 77:869cf507173a 39 #ifndef __STM32F4xx_HAL_HCD_H
emilmont 77:869cf507173a 40 #define __STM32F4xx_HAL_HCD_H
emilmont 77:869cf507173a 41
emilmont 77:869cf507173a 42 #ifdef __cplusplus
emilmont 77:869cf507173a 43 extern "C" {
emilmont 77:869cf507173a 44 #endif
emilmont 77:869cf507173a 45
emilmont 77:869cf507173a 46 /* Includes ------------------------------------------------------------------*/
emilmont 77:869cf507173a 47 #include "stm32f4xx_ll_usb.h"
emilmont 77:869cf507173a 48
emilmont 77:869cf507173a 49 /** @addtogroup STM32F4xx_HAL_Driver
emilmont 77:869cf507173a 50 * @{
emilmont 77:869cf507173a 51 */
emilmont 77:869cf507173a 52
Kojto 99:dbbf35b96557 53 /** @defgroup HCD HCD
Kojto 99:dbbf35b96557 54 * @brief HCD HAL module driver
emilmont 77:869cf507173a 55 * @{
Kojto 99:dbbf35b96557 56 */
emilmont 77:869cf507173a 57
emilmont 77:869cf507173a 58 /* Exported types ------------------------------------------------------------*/
Kojto 99:dbbf35b96557 59 /** @defgroup HCD_Exported_Types HCD Exported Types
Kojto 99:dbbf35b96557 60 * @{
Kojto 99:dbbf35b96557 61 */
emilmont 77:869cf507173a 62
Kojto 99:dbbf35b96557 63 /** @defgroup HCD_Exported_Types_Group1 HCD State Structure definition
Kojto 99:dbbf35b96557 64 * @{
Kojto 99:dbbf35b96557 65 */
emilmont 77:869cf507173a 66 typedef enum
emilmont 77:869cf507173a 67 {
Kojto 90:cb3d968589d8 68 HAL_HCD_STATE_RESET = 0x00,
Kojto 90:cb3d968589d8 69 HAL_HCD_STATE_READY = 0x01,
Kojto 90:cb3d968589d8 70 HAL_HCD_STATE_ERROR = 0x02,
Kojto 90:cb3d968589d8 71 HAL_HCD_STATE_BUSY = 0x03,
Kojto 90:cb3d968589d8 72 HAL_HCD_STATE_TIMEOUT = 0x04
emilmont 77:869cf507173a 73 } HCD_StateTypeDef;
emilmont 77:869cf507173a 74
emilmont 77:869cf507173a 75 typedef USB_OTG_GlobalTypeDef HCD_TypeDef;
emilmont 77:869cf507173a 76 typedef USB_OTG_CfgTypeDef HCD_InitTypeDef;
emilmont 77:869cf507173a 77 typedef USB_OTG_HCTypeDef HCD_HCTypeDef ;
emilmont 77:869cf507173a 78 typedef USB_OTG_URBStateTypeDef HCD_URBStateTypeDef ;
emilmont 77:869cf507173a 79 typedef USB_OTG_HCStateTypeDef HCD_HCStateTypeDef ;
Kojto 99:dbbf35b96557 80 /**
Kojto 99:dbbf35b96557 81 * @}
Kojto 99:dbbf35b96557 82 */
emilmont 77:869cf507173a 83
Kojto 99:dbbf35b96557 84 /** @defgroup HCD_Exported_Types_Group2 HCD Handle Structure definition
Kojto 99:dbbf35b96557 85 * @{
emilmont 77:869cf507173a 86 */
emilmont 77:869cf507173a 87 typedef struct
emilmont 77:869cf507173a 88 {
emilmont 77:869cf507173a 89 HCD_TypeDef *Instance; /*!< Register base address */
emilmont 77:869cf507173a 90 HCD_InitTypeDef Init; /*!< HCD required parameters */
emilmont 77:869cf507173a 91 HCD_HCTypeDef hc[15]; /*!< Host channels parameters */
emilmont 77:869cf507173a 92 HAL_LockTypeDef Lock; /*!< HCD peripheral status */
emilmont 77:869cf507173a 93 __IO HCD_StateTypeDef State; /*!< HCD communication state */
Kojto 99:dbbf35b96557 94 void *pData; /*!< Pointer Stack Handler */
emilmont 77:869cf507173a 95 } HCD_HandleTypeDef;
emilmont 77:869cf507173a 96 /**
emilmont 77:869cf507173a 97 * @}
emilmont 77:869cf507173a 98 */
emilmont 77:869cf507173a 99
Kojto 99:dbbf35b96557 100 /**
Kojto 99:dbbf35b96557 101 * @}
Kojto 99:dbbf35b96557 102 */
Kojto 99:dbbf35b96557 103
Kojto 99:dbbf35b96557 104 /* Exported constants --------------------------------------------------------*/
Kojto 99:dbbf35b96557 105 /** @defgroup HCD_Exported_Constants HCD Exported Constants
Kojto 99:dbbf35b96557 106 * @{
Kojto 99:dbbf35b96557 107 */
Kojto 99:dbbf35b96557 108 /** @defgroup HCD_Speed HCD Speed
emilmont 77:869cf507173a 109 * @{
emilmont 77:869cf507173a 110 */
emilmont 77:869cf507173a 111 #define HCD_SPEED_HIGH 0
emilmont 77:869cf507173a 112 #define HCD_SPEED_LOW 2
bogdanm 81:7d30d6019079 113 #define HCD_SPEED_FULL 3
emilmont 77:869cf507173a 114 /**
emilmont 77:869cf507173a 115 * @}
emilmont 77:869cf507173a 116 */
Kojto 99:dbbf35b96557 117
Kojto 99:dbbf35b96557 118 /** @defgroup HCD_PHY_Module HCD PHY Module
emilmont 77:869cf507173a 119 * @{
emilmont 77:869cf507173a 120 */
emilmont 77:869cf507173a 121 #define HCD_PHY_ULPI 1
emilmont 77:869cf507173a 122 #define HCD_PHY_EMBEDDED 2
emilmont 77:869cf507173a 123 /**
emilmont 77:869cf507173a 124 * @}
emilmont 77:869cf507173a 125 */
Kojto 99:dbbf35b96557 126
emilmont 77:869cf507173a 127 /**
emilmont 77:869cf507173a 128 * @}
emilmont 77:869cf507173a 129 */
Kojto 99:dbbf35b96557 130
emilmont 77:869cf507173a 131 /* Exported macro ------------------------------------------------------------*/
Kojto 99:dbbf35b96557 132 /** @defgroup HCD_Exported_Macros HCD Exported Macros
emilmont 77:869cf507173a 133 * @brief macros to handle interrupts and specific clock configurations
emilmont 77:869cf507173a 134 * @{
emilmont 77:869cf507173a 135 */
Kojto 99:dbbf35b96557 136 #define __HAL_HCD_ENABLE(__HANDLE__) USB_EnableGlobalInt ((__HANDLE__)->Instance)
Kojto 99:dbbf35b96557 137 #define __HAL_HCD_DISABLE(__HANDLE__) USB_DisableGlobalInt ((__HANDLE__)->Instance)
Kojto 90:cb3d968589d8 138
Kojto 90:cb3d968589d8 139 #define __HAL_HCD_GET_FLAG(__HANDLE__, __INTERRUPT__) ((USB_ReadInterrupts((__HANDLE__)->Instance) & (__INTERRUPT__)) == (__INTERRUPT__))
Kojto 90:cb3d968589d8 140 #define __HAL_HCD_CLEAR_FLAG(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->GINTSTS) = (__INTERRUPT__))
Kojto 90:cb3d968589d8 141 #define __HAL_HCD_IS_INVALID_INTERRUPT(__HANDLE__) (USB_ReadInterrupts((__HANDLE__)->Instance) == 0)
Kojto 99:dbbf35b96557 142
emilmont 77:869cf507173a 143 #define __HAL_HCD_CLEAR_HC_INT(chnum, __INTERRUPT__) (USBx_HC(chnum)->HCINT = (__INTERRUPT__))
emilmont 77:869cf507173a 144 #define __HAL_HCD_MASK_HALT_HC_INT(chnum) (USBx_HC(chnum)->HCINTMSK &= ~USB_OTG_HCINTMSK_CHHM)
emilmont 77:869cf507173a 145 #define __HAL_HCD_UNMASK_HALT_HC_INT(chnum) (USBx_HC(chnum)->HCINTMSK |= USB_OTG_HCINTMSK_CHHM)
emilmont 77:869cf507173a 146 #define __HAL_HCD_MASK_ACK_HC_INT(chnum) (USBx_HC(chnum)->HCINTMSK &= ~USB_OTG_HCINTMSK_ACKM)
emilmont 77:869cf507173a 147 #define __HAL_HCD_UNMASK_ACK_HC_INT(chnum) (USBx_HC(chnum)->HCINTMSK |= USB_OTG_HCINTMSK_ACKM)
emilmont 77:869cf507173a 148 /**
emilmont 77:869cf507173a 149 * @}
emilmont 77:869cf507173a 150 */
emilmont 77:869cf507173a 151
emilmont 77:869cf507173a 152 /* Exported functions --------------------------------------------------------*/
Kojto 99:dbbf35b96557 153 /** @defgroup HCD_Exported_Functions HCD Exported Functions
Kojto 99:dbbf35b96557 154 * @{
Kojto 99:dbbf35b96557 155 */
emilmont 77:869cf507173a 156
Kojto 99:dbbf35b96557 157 /** @defgroup HCD_Exported_Functions_Group1 Initialization and de-initialization functions
Kojto 99:dbbf35b96557 158 * @{
Kojto 99:dbbf35b96557 159 */
Kojto 99:dbbf35b96557 160 HAL_StatusTypeDef HAL_HCD_Init(HCD_HandleTypeDef *hhcd);
Kojto 99:dbbf35b96557 161 HAL_StatusTypeDef HAL_HCD_DeInit(HCD_HandleTypeDef *hhcd);
Kojto 99:dbbf35b96557 162 HAL_StatusTypeDef HAL_HCD_HC_Init(HCD_HandleTypeDef *hhcd,
Kojto 99:dbbf35b96557 163 uint8_t ch_num,
Kojto 99:dbbf35b96557 164 uint8_t epnum,
Kojto 99:dbbf35b96557 165 uint8_t dev_address,
Kojto 99:dbbf35b96557 166 uint8_t speed,
Kojto 99:dbbf35b96557 167 uint8_t ep_type,
Kojto 99:dbbf35b96557 168 uint16_t mps);
Kojto 99:dbbf35b96557 169
Kojto 99:dbbf35b96557 170 HAL_StatusTypeDef HAL_HCD_HC_Halt(HCD_HandleTypeDef *hhcd, uint8_t ch_num);
Kojto 99:dbbf35b96557 171 void HAL_HCD_MspInit(HCD_HandleTypeDef *hhcd);
Kojto 99:dbbf35b96557 172 void HAL_HCD_MspDeInit(HCD_HandleTypeDef *hhcd);
Kojto 99:dbbf35b96557 173 /**
Kojto 99:dbbf35b96557 174 * @}
Kojto 99:dbbf35b96557 175 */
emilmont 77:869cf507173a 176
Kojto 99:dbbf35b96557 177 /** @defgroup HCD_Exported_Functions_Group2 IO operation functions
Kojto 99:dbbf35b96557 178 * @{
Kojto 99:dbbf35b96557 179 */
Kojto 99:dbbf35b96557 180 HAL_StatusTypeDef HAL_HCD_HC_SubmitRequest(HCD_HandleTypeDef *hhcd,
Kojto 99:dbbf35b96557 181 uint8_t pipe,
Kojto 99:dbbf35b96557 182 uint8_t direction,
Kojto 99:dbbf35b96557 183 uint8_t ep_type,
Kojto 99:dbbf35b96557 184 uint8_t token,
Kojto 99:dbbf35b96557 185 uint8_t* pbuff,
Kojto 99:dbbf35b96557 186 uint16_t length,
Kojto 99:dbbf35b96557 187 uint8_t do_ping);
emilmont 77:869cf507173a 188
Kojto 99:dbbf35b96557 189 /* Non-Blocking mode: Interrupt */
Kojto 99:dbbf35b96557 190 void HAL_HCD_IRQHandler(HCD_HandleTypeDef *hhcd);
Kojto 99:dbbf35b96557 191 void HAL_HCD_SOF_Callback(HCD_HandleTypeDef *hhcd);
Kojto 99:dbbf35b96557 192 void HAL_HCD_Connect_Callback(HCD_HandleTypeDef *hhcd);
Kojto 99:dbbf35b96557 193 void HAL_HCD_Disconnect_Callback(HCD_HandleTypeDef *hhcd);
Kojto 99:dbbf35b96557 194 void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd,
Kojto 99:dbbf35b96557 195 uint8_t chnum,
Kojto 99:dbbf35b96557 196 HCD_URBStateTypeDef urb_state);
Kojto 99:dbbf35b96557 197 /**
Kojto 99:dbbf35b96557 198 * @}
Kojto 99:dbbf35b96557 199 */
Kojto 99:dbbf35b96557 200
Kojto 99:dbbf35b96557 201 /** @defgroup HCD_Exported_Functions_Group3 Peripheral Control functions
Kojto 99:dbbf35b96557 202 * @{
Kojto 99:dbbf35b96557 203 */
Kojto 99:dbbf35b96557 204 HAL_StatusTypeDef HAL_HCD_ResetPort(HCD_HandleTypeDef *hhcd);
Kojto 99:dbbf35b96557 205 HAL_StatusTypeDef HAL_HCD_Start(HCD_HandleTypeDef *hhcd);
Kojto 99:dbbf35b96557 206 HAL_StatusTypeDef HAL_HCD_Stop(HCD_HandleTypeDef *hhcd);
Kojto 99:dbbf35b96557 207 /**
Kojto 99:dbbf35b96557 208 * @}
Kojto 99:dbbf35b96557 209 */
emilmont 77:869cf507173a 210
Kojto 99:dbbf35b96557 211 /** @defgroup HCD_Exported_Functions_Group4 Peripheral State functions
Kojto 99:dbbf35b96557 212 * @{
Kojto 99:dbbf35b96557 213 */
Kojto 99:dbbf35b96557 214 HCD_StateTypeDef HAL_HCD_GetState(HCD_HandleTypeDef *hhcd);
Kojto 99:dbbf35b96557 215 HCD_URBStateTypeDef HAL_HCD_HC_GetURBState(HCD_HandleTypeDef *hhcd, uint8_t chnum);
Kojto 99:dbbf35b96557 216 uint32_t HAL_HCD_HC_GetXferCount(HCD_HandleTypeDef *hhcd, uint8_t chnum);
Kojto 99:dbbf35b96557 217 HCD_HCStateTypeDef HAL_HCD_HC_GetState(HCD_HandleTypeDef *hhcd, uint8_t chnum);
Kojto 99:dbbf35b96557 218 uint32_t HAL_HCD_GetCurrentFrame(HCD_HandleTypeDef *hhcd);
Kojto 99:dbbf35b96557 219 uint32_t HAL_HCD_GetCurrentSpeed(HCD_HandleTypeDef *hhcd);
Kojto 99:dbbf35b96557 220 /**
Kojto 99:dbbf35b96557 221 * @}
Kojto 99:dbbf35b96557 222 */
Kojto 99:dbbf35b96557 223
Kojto 99:dbbf35b96557 224 /**
Kojto 99:dbbf35b96557 225 * @}
Kojto 99:dbbf35b96557 226 */
emilmont 77:869cf507173a 227
Kojto 99:dbbf35b96557 228 /* Private macros ------------------------------------------------------------*/
Kojto 99:dbbf35b96557 229 /** @defgroup HCD_Private_Macros HCD Private Macros
Kojto 99:dbbf35b96557 230 * @{
Kojto 99:dbbf35b96557 231 */
Kojto 99:dbbf35b96557 232 /** @defgroup HCD_Instance_definition HCD Instance definition
Kojto 99:dbbf35b96557 233 * @{
Kojto 99:dbbf35b96557 234 */
Kojto 99:dbbf35b96557 235 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F427xx) ||\
Kojto 99:dbbf35b96557 236 defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F446xx)
Kojto 99:dbbf35b96557 237 #define IS_HCD_ALL_INSTANCE(INSTANCE) (((INSTANCE) == USB_OTG_FS) || \
Kojto 99:dbbf35b96557 238 ((INSTANCE) == USB_OTG_HS))
Kojto 99:dbbf35b96557 239 #elif defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE)
Kojto 99:dbbf35b96557 240 #define IS_HCD_ALL_INSTANCE(INSTANCE) (((INSTANCE) == USB_OTG_FS))
Kojto 99:dbbf35b96557 241 #endif
Kojto 99:dbbf35b96557 242 /**
Kojto 99:dbbf35b96557 243 * @}
Kojto 99:dbbf35b96557 244 */
Kojto 99:dbbf35b96557 245
Kojto 99:dbbf35b96557 246 /**
Kojto 99:dbbf35b96557 247 * @}
Kojto 99:dbbf35b96557 248 */
emilmont 77:869cf507173a 249
Kojto 99:dbbf35b96557 250 /* Private functions prototypes ----------------------------------------------*/
Kojto 99:dbbf35b96557 251 /** @defgroup HCD_Private_Functions_Prototypes HCD Private Functions Prototypes
Kojto 99:dbbf35b96557 252 * @{
Kojto 99:dbbf35b96557 253 */
Kojto 99:dbbf35b96557 254
Kojto 99:dbbf35b96557 255 /**
Kojto 99:dbbf35b96557 256 * @}
Kojto 99:dbbf35b96557 257 */
emilmont 77:869cf507173a 258
Kojto 99:dbbf35b96557 259 /* Private functions ---------------------------------------------------------*/
Kojto 99:dbbf35b96557 260 /** @defgroup HCD_Private_Functions HCD Private Functions
Kojto 99:dbbf35b96557 261 * @{
Kojto 99:dbbf35b96557 262 */
Kojto 99:dbbf35b96557 263
Kojto 99:dbbf35b96557 264 /**
Kojto 99:dbbf35b96557 265 * @}
Kojto 99:dbbf35b96557 266 */
Kojto 99:dbbf35b96557 267
Kojto 99:dbbf35b96557 268 /**
Kojto 99:dbbf35b96557 269 * @}
Kojto 99:dbbf35b96557 270 */
emilmont 77:869cf507173a 271
emilmont 77:869cf507173a 272 /**
emilmont 77:869cf507173a 273 * @}
emilmont 77:869cf507173a 274 */
emilmont 77:869cf507173a 275
emilmont 77:869cf507173a 276 #ifdef __cplusplus
emilmont 77:869cf507173a 277 }
emilmont 77:869cf507173a 278 #endif
emilmont 77:869cf507173a 279
emilmont 77:869cf507173a 280 #endif /* __STM32F4xx_HAL_HCD_H */
emilmont 77:869cf507173a 281
emilmont 77:869cf507173a 282 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/