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