The official mbed C/C SDK provides the software platform and libraries to build your applications.

Fork of mbed by mbed official

Committer:
Kojto
Date:
Tue Feb 03 15:31:20 2015 +0000
Revision:
93:e188a91d3eaa
Release 93 of the mbed library

Main changes:

- Renesas RZ_A1H bugfixes - i2c, ticker
- new targets - Nucleo F303RE, Nucleo F070RB, BLE SMURFS,
Dragonfly 411RE,
- BusXXX - is connected method, plus operators addition
- LPC8xx - I2c fixes
- timestamp_t reverted to uint32_t
- RTX - fixes regarding stack (alignment, magic word)

Who changed what in which revision?

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