TUKS MCU Introductory course / TUKS-COURSE-TIMER
Committer:
elmot
Date:
Fri Feb 24 21:13:56 2017 +0000
Revision:
1:d0dfbce63a89
Ready-to-copy

Who changed what in which revision?

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