RTEMS 6.1-rc2
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)
187/* Exported functions --------------------------------------------------------*/
196HAL_StatusTypeDef HAL_HCD_Init(HCD_HandleTypeDef *hhcd);
197HAL_StatusTypeDef HAL_HCD_DeInit(HCD_HandleTypeDef *hhcd);
198HAL_StatusTypeDef HAL_HCD_HC_Init(HCD_HandleTypeDef *hhcd, uint8_t ch_num,
199 uint8_t epnum, uint8_t dev_address,
200 uint8_t speed, uint8_t ep_type, uint16_t mps);
201
202HAL_StatusTypeDef HAL_HCD_HC_Halt(HCD_HandleTypeDef *hhcd, uint8_t ch_num);
203void HAL_HCD_MspInit(HCD_HandleTypeDef *hhcd);
204void HAL_HCD_MspDeInit(HCD_HandleTypeDef *hhcd);
205
206#if (USE_HAL_HCD_REGISTER_CALLBACKS == 1U)
212typedef enum
213{
214 HAL_HCD_SOF_CB_ID = 0x01,
215 HAL_HCD_CONNECT_CB_ID = 0x02,
216 HAL_HCD_DISCONNECT_CB_ID = 0x03,
217 HAL_HCD_PORT_ENABLED_CB_ID = 0x04,
218 HAL_HCD_PORT_DISABLED_CB_ID = 0x05,
220 HAL_HCD_MSPINIT_CB_ID = 0x06,
221 HAL_HCD_MSPDEINIT_CB_ID = 0x07
223} HAL_HCD_CallbackIDTypeDef;
234typedef void (*pHCD_CallbackTypeDef)(HCD_HandleTypeDef *hhcd);
235typedef void (*pHCD_HC_NotifyURBChangeCallbackTypeDef)(HCD_HandleTypeDef *hhcd,
236 uint8_t epnum,
237 HCD_URBStateTypeDef urb_state);
242HAL_StatusTypeDef HAL_HCD_RegisterCallback(HCD_HandleTypeDef *hhcd,
243 HAL_HCD_CallbackIDTypeDef CallbackID,
244 pHCD_CallbackTypeDef pCallback);
245
246HAL_StatusTypeDef HAL_HCD_UnRegisterCallback(HCD_HandleTypeDef *hhcd,
247 HAL_HCD_CallbackIDTypeDef CallbackID);
248
249HAL_StatusTypeDef HAL_HCD_RegisterHC_NotifyURBChangeCallback(HCD_HandleTypeDef *hhcd,
250 pHCD_HC_NotifyURBChangeCallbackTypeDef pCallback);
251
252HAL_StatusTypeDef HAL_HCD_UnRegisterHC_NotifyURBChangeCallback(HCD_HandleTypeDef *hhcd);
253#endif /* USE_HAL_HCD_REGISTER_CALLBACKS */
258/* I/O operation functions ***************************************************/
262HAL_StatusTypeDef HAL_HCD_HC_SubmitRequest(HCD_HandleTypeDef *hhcd, uint8_t ch_num,
263 uint8_t direction, uint8_t ep_type,
264 uint8_t token, uint8_t *pbuff,
265 uint16_t length, uint8_t do_ping);
266
267/* Non-Blocking mode: Interrupt */
268void HAL_HCD_IRQHandler(HCD_HandleTypeDef *hhcd);
269void HAL_HCD_SOF_Callback(HCD_HandleTypeDef *hhcd);
270void HAL_HCD_Connect_Callback(HCD_HandleTypeDef *hhcd);
271void HAL_HCD_Disconnect_Callback(HCD_HandleTypeDef *hhcd);
272void HAL_HCD_PortEnabled_Callback(HCD_HandleTypeDef *hhcd);
273void HAL_HCD_PortDisabled_Callback(HCD_HandleTypeDef *hhcd);
274void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum,
275 HCD_URBStateTypeDef urb_state);
280/* Peripheral Control functions **********************************************/
284HAL_StatusTypeDef HAL_HCD_ResetPort(HCD_HandleTypeDef *hhcd);
285HAL_StatusTypeDef HAL_HCD_Start(HCD_HandleTypeDef *hhcd);
286HAL_StatusTypeDef HAL_HCD_Stop(HCD_HandleTypeDef *hhcd);
291/* Peripheral State functions ************************************************/
295HCD_StateTypeDef HAL_HCD_GetState(HCD_HandleTypeDef *hhcd);
296HCD_URBStateTypeDef HAL_HCD_HC_GetURBState(HCD_HandleTypeDef *hhcd, uint8_t chnum);
297HCD_HCStateTypeDef HAL_HCD_HC_GetState(HCD_HandleTypeDef *hhcd, uint8_t chnum);
298uint32_t HAL_HCD_HC_GetXferCount(HCD_HandleTypeDef *hhcd, uint8_t chnum);
299uint32_t HAL_HCD_GetCurrentFrame(HCD_HandleTypeDef *hhcd);
300uint32_t HAL_HCD_GetCurrentSpeed(HCD_HandleTypeDef *hhcd);
301
302
307/* Private macros ------------------------------------------------------------*/
315/* Private functions prototypes ----------------------------------------------*/
316
326#endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */
327
328#ifdef __cplusplus
329}
330#endif
331
332#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