Fork of the official mbed C/C SDK provides the software platform and libraries to build your applications for RenBED.

Dependents:   1-RenBuggyTimed RenBED_RGB RenBED_RGB_PWM RenBED_RGB

Fork of mbed by mbed official

Committer:
elijahorr
Date:
Thu Apr 14 07:28:54 2016 +0000
Revision:
121:672067c3ada4
Parent:
110:165afa46840b
.

Who changed what in which revision?

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