RTEMS 6.1-rc4
Loading...
Searching...
No Matches
stm32h7xx_hal_hcd.h
Go to the documentation of this file.
1
19/* Define to prevent recursive inclusion -------------------------------------*/
20#ifndef STM32H7xx_HAL_HCD_H
21#define STM32H7xx_HAL_HCD_H
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27/* Includes ------------------------------------------------------------------*/
28#include "stm32h7xx_ll_usb.h"
29
30#if defined (USB_OTG_FS) || defined (USB_OTG_HS)
39/* Exported types ------------------------------------------------------------*/
49typedef enum
50{
51 HAL_HCD_STATE_RESET = 0x00,
52 HAL_HCD_STATE_READY = 0x01,
53 HAL_HCD_STATE_ERROR = 0x02,
54 HAL_HCD_STATE_BUSY = 0x03,
55 HAL_HCD_STATE_TIMEOUT = 0x04
56} HCD_StateTypeDef;
57
58typedef USB_OTG_GlobalTypeDef HCD_TypeDef;
59typedef USB_OTG_CfgTypeDef HCD_InitTypeDef;
60typedef USB_OTG_HCTypeDef HCD_HCTypeDef;
61typedef USB_OTG_URBStateTypeDef HCD_URBStateTypeDef;
62typedef USB_OTG_HCStateTypeDef HCD_HCStateTypeDef;
71#if (USE_HAL_HCD_REGISTER_CALLBACKS == 1U)
72typedef struct __HCD_HandleTypeDef
73#else
74typedef struct
75#endif /* USE_HAL_HCD_REGISTER_CALLBACKS */
76{
77 HCD_TypeDef *Instance;
78 HCD_InitTypeDef Init;
79 HCD_HCTypeDef hc[16];
80 HAL_LockTypeDef Lock;
81 __IO HCD_StateTypeDef State;
82 __IO uint32_t ErrorCode;
83 void *pData;
84#if (USE_HAL_HCD_REGISTER_CALLBACKS == 1U)
85 void (* SOFCallback)(struct __HCD_HandleTypeDef *hhcd);
86 void (* ConnectCallback)(struct __HCD_HandleTypeDef *hhcd);
87 void (* DisconnectCallback)(struct __HCD_HandleTypeDef *hhcd);
88 void (* PortEnabledCallback)(struct __HCD_HandleTypeDef *hhcd);
89 void (* PortDisabledCallback)(struct __HCD_HandleTypeDef *hhcd);
90 void (* HC_NotifyURBChangeCallback)(struct __HCD_HandleTypeDef *hhcd, uint8_t chnum,
91 HCD_URBStateTypeDef urb_state);
93 void (* MspInitCallback)(struct __HCD_HandleTypeDef *hhcd);
94 void (* MspDeInitCallback)(struct __HCD_HandleTypeDef *hhcd);
95#endif /* USE_HAL_HCD_REGISTER_CALLBACKS */
96} HCD_HandleTypeDef;
105/* Exported constants --------------------------------------------------------*/
115#define HCD_SPEED_HIGH USBH_HS_SPEED
116#define HCD_SPEED_FULL USBH_FSLS_SPEED
117#define HCD_SPEED_LOW USBH_FSLS_SPEED
126#define HCD_DEVICE_SPEED_HIGH 0U
127#define HCD_DEVICE_SPEED_FULL 1U
128#define HCD_DEVICE_SPEED_LOW 2U
137#define HCD_PHY_ULPI 1U
138#define HCD_PHY_EMBEDDED 2U
148#if (USE_HAL_HCD_REGISTER_CALLBACKS == 1U)
149#define HAL_HCD_ERROR_INVALID_CALLBACK (0x00000010U)
150#endif /* USE_HAL_HCD_REGISTER_CALLBACKS */
151
160/* Exported macro ------------------------------------------------------------*/
166#define __HAL_HCD_ENABLE(__HANDLE__) (void)USB_EnableGlobalInt ((__HANDLE__)->Instance)
167#define __HAL_HCD_DISABLE(__HANDLE__) (void)USB_DisableGlobalInt ((__HANDLE__)->Instance)
168
169#define __HAL_HCD_GET_FLAG(__HANDLE__, __INTERRUPT__) ((USB_ReadInterrupts((__HANDLE__)->Instance)\
170 & (__INTERRUPT__)) == (__INTERRUPT__))
171
172#define __HAL_HCD_GET_CH_FLAG(__HANDLE__, __chnum__, __INTERRUPT__) \
173 ((USB_ReadChInterrupts((__HANDLE__)->Instance, (__chnum__)) & (__INTERRUPT__)) == (__INTERRUPT__))
174
175#define __HAL_HCD_CLEAR_FLAG(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->GINTSTS) = (__INTERRUPT__))
176#define __HAL_HCD_IS_INVALID_INTERRUPT(__HANDLE__) (USB_ReadInterrupts((__HANDLE__)->Instance) == 0U)
177
178#define __HAL_HCD_CLEAR_HC_INT(chnum, __INTERRUPT__) (USBx_HC(chnum)->HCINT = (__INTERRUPT__))
179#define __HAL_HCD_MASK_HALT_HC_INT(chnum) (USBx_HC(chnum)->HCINTMSK &= ~USB_OTG_HCINTMSK_CHHM)
180#define __HAL_HCD_UNMASK_HALT_HC_INT(chnum) (USBx_HC(chnum)->HCINTMSK |= USB_OTG_HCINTMSK_CHHM)
181#define __HAL_HCD_MASK_ACK_HC_INT(chnum) (USBx_HC(chnum)->HCINTMSK &= ~USB_OTG_HCINTMSK_ACKM)
182#define __HAL_HCD_UNMASK_ACK_HC_INT(chnum) (USBx_HC(chnum)->HCINTMSK |= USB_OTG_HCINTMSK_ACKM)
183#define __HAL_HCD_SET_HC_CSPLT(chnum) (USBx_HC(chnum)->HCSPLT |= USB_OTG_HCSPLT_COMPLSPLT)
184#define __HAL_HCD_CLEAR_HC_CSPLT(chnum) (USBx_HC(chnum)->HCSPLT &= ~USB_OTG_HCSPLT_COMPLSPLT)
185#define __HAL_HCD_CLEAR_HC_SSPLT(chnum) (USBx_HC(chnum)->HCSPLT &= ~USB_OTG_HCSPLT_SPLITEN)
190/* Exported functions --------------------------------------------------------*/
199HAL_StatusTypeDef HAL_HCD_Init(HCD_HandleTypeDef *hhcd);
200HAL_StatusTypeDef HAL_HCD_DeInit(HCD_HandleTypeDef *hhcd);
201HAL_StatusTypeDef HAL_HCD_HC_Init(HCD_HandleTypeDef *hhcd, uint8_t ch_num,
202 uint8_t epnum, uint8_t dev_address,
203 uint8_t speed, uint8_t ep_type, uint16_t mps);
204
205HAL_StatusTypeDef HAL_HCD_HC_Halt(HCD_HandleTypeDef *hhcd, uint8_t ch_num);
206void HAL_HCD_MspInit(HCD_HandleTypeDef *hhcd);
207void HAL_HCD_MspDeInit(HCD_HandleTypeDef *hhcd);
208
209#if (USE_HAL_HCD_REGISTER_CALLBACKS == 1U)
215typedef enum
216{
217 HAL_HCD_SOF_CB_ID = 0x01,
218 HAL_HCD_CONNECT_CB_ID = 0x02,
219 HAL_HCD_DISCONNECT_CB_ID = 0x03,
220 HAL_HCD_PORT_ENABLED_CB_ID = 0x04,
221 HAL_HCD_PORT_DISABLED_CB_ID = 0x05,
223 HAL_HCD_MSPINIT_CB_ID = 0x06,
224 HAL_HCD_MSPDEINIT_CB_ID = 0x07
226} HAL_HCD_CallbackIDTypeDef;
237typedef void (*pHCD_CallbackTypeDef)(HCD_HandleTypeDef *hhcd);
238typedef void (*pHCD_HC_NotifyURBChangeCallbackTypeDef)(HCD_HandleTypeDef *hhcd,
239 uint8_t epnum,
240 HCD_URBStateTypeDef urb_state);
245HAL_StatusTypeDef HAL_HCD_RegisterCallback(HCD_HandleTypeDef *hhcd,
246 HAL_HCD_CallbackIDTypeDef CallbackID,
247 pHCD_CallbackTypeDef pCallback);
248
249HAL_StatusTypeDef HAL_HCD_UnRegisterCallback(HCD_HandleTypeDef *hhcd,
250 HAL_HCD_CallbackIDTypeDef CallbackID);
251
252HAL_StatusTypeDef HAL_HCD_RegisterHC_NotifyURBChangeCallback(HCD_HandleTypeDef *hhcd,
253 pHCD_HC_NotifyURBChangeCallbackTypeDef pCallback);
254
255HAL_StatusTypeDef HAL_HCD_UnRegisterHC_NotifyURBChangeCallback(HCD_HandleTypeDef *hhcd);
256#endif /* USE_HAL_HCD_REGISTER_CALLBACKS */
261/* I/O operation functions ***************************************************/
265HAL_StatusTypeDef HAL_HCD_HC_SubmitRequest(HCD_HandleTypeDef *hhcd, uint8_t ch_num,
266 uint8_t direction, uint8_t ep_type,
267 uint8_t token, uint8_t *pbuff,
268 uint16_t length, uint8_t do_ping);
269
270HAL_StatusTypeDef HAL_HCD_HC_SetHubInfo(HCD_HandleTypeDef *hhcd, uint8_t ch_num,
271 uint8_t addr, uint8_t PortNbr);
272
273HAL_StatusTypeDef HAL_HCD_HC_ClearHubInfo(HCD_HandleTypeDef *hhcd, uint8_t ch_num);
274
275/* Non-Blocking mode: Interrupt */
276void HAL_HCD_IRQHandler(HCD_HandleTypeDef *hhcd);
277void HAL_HCD_SOF_Callback(HCD_HandleTypeDef *hhcd);
278void HAL_HCD_Connect_Callback(HCD_HandleTypeDef *hhcd);
279void HAL_HCD_Disconnect_Callback(HCD_HandleTypeDef *hhcd);
280void HAL_HCD_PortEnabled_Callback(HCD_HandleTypeDef *hhcd);
281void HAL_HCD_PortDisabled_Callback(HCD_HandleTypeDef *hhcd);
282void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum,
283 HCD_URBStateTypeDef urb_state);
288/* Peripheral Control functions **********************************************/
292HAL_StatusTypeDef HAL_HCD_ResetPort(HCD_HandleTypeDef *hhcd);
293HAL_StatusTypeDef HAL_HCD_Start(HCD_HandleTypeDef *hhcd);
294HAL_StatusTypeDef HAL_HCD_Stop(HCD_HandleTypeDef *hhcd);
299/* Peripheral State functions ************************************************/
303HCD_StateTypeDef HAL_HCD_GetState(HCD_HandleTypeDef const *hhcd);
304HCD_URBStateTypeDef HAL_HCD_HC_GetURBState(HCD_HandleTypeDef const *hhcd, uint8_t chnum);
305HCD_HCStateTypeDef HAL_HCD_HC_GetState(HCD_HandleTypeDef const *hhcd, uint8_t chnum);
306uint32_t HAL_HCD_HC_GetXferCount(HCD_HandleTypeDef const *hhcd, uint8_t chnum);
307uint32_t HAL_HCD_GetCurrentFrame(HCD_HandleTypeDef *hhcd);
308uint32_t HAL_HCD_GetCurrentSpeed(HCD_HandleTypeDef *hhcd);
309
310
315/* Private macros ------------------------------------------------------------*/
323/* Private functions prototypes ----------------------------------------------*/
324
334#endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */
335
336#ifdef __cplusplus
337}
338#endif
339
340#endif /* STM32H7xx_HAL_HCD_H */
#define __IO
Definition: core_cm4.h:239
HAL_StatusTypeDef
HAL Status structures definition.
Definition: stm32h7xx_hal_def.h:47
HAL_LockTypeDef
HAL Lock structures definition.
Definition: stm32h7xx_hal_def.h:58
Header file of USB Low Layer HAL module.
USB_OTG_Core_Registers.
Definition: stm32h723xx.h:1761