2 ******************************************************************************
3 * @file stm32f1xx_hal_hcd.h
4 * @author MCD Application Team
7 * @brief Header file of HCD HAL module.
8 ******************************************************************************
11 * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
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.
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.
35 ******************************************************************************
38 /* Define to prevent recursive inclusion -------------------------------------*/
39 #ifndef __STM32F1xx_HAL_HCD_H
40 #define __STM32F1xx_HAL_HCD_H
46 #if defined(STM32F105xC) || defined(STM32F107xC)
49 /* Includes ------------------------------------------------------------------*/
50 #include "stm32f1xx_ll_usb.h"
52 /** @addtogroup STM32F1xx_HAL_Driver
60 /* Exported types ------------------------------------------------------------*/
61 /** @defgroup HCD_Exported_Types HCD Exported Types
66 * @brief HCD Status structure definition
70 HAL_HCD_STATE_RESET
= 0x00U
,
71 HAL_HCD_STATE_READY
= 0x01U
,
72 HAL_HCD_STATE_ERROR
= 0x02U
,
73 HAL_HCD_STATE_BUSY
= 0x03U
,
74 HAL_HCD_STATE_TIMEOUT
= 0x04U
77 typedef USB_OTG_GlobalTypeDef HCD_TypeDef
;
78 typedef USB_OTG_CfgTypeDef HCD_InitTypeDef
;
79 typedef USB_OTG_HCTypeDef HCD_HCTypeDef
;
80 typedef USB_OTG_URBStateTypeDef HCD_URBStateTypeDef
;
81 typedef USB_OTG_HCStateTypeDef HCD_HCStateTypeDef
;
84 * @brief HCD Handle Structure definition
88 HCD_TypeDef
*Instance
; /*!< Register base address */
89 HCD_InitTypeDef Init
; /*!< HCD required parameters */
90 HCD_HCTypeDef hc
[15U]; /*!< Host channels parameters */
91 HAL_LockTypeDef Lock
; /*!< HCD peripheral status */
92 __IO HCD_StateTypeDef State
; /*!< HCD communication state */
93 void *pData
; /*!< Pointer Stack Handler */
100 /* Exported constants --------------------------------------------------------*/
101 /** @defgroup HCD_Exported_Constants HCD Exported Constants
104 /** @defgroup HCD_Speed HCD Speed
107 #define HCD_SPEED_LOW 2U
108 #define HCD_SPEED_FULL 3U
118 /* Exported macro ------------------------------------------------------------*/
119 /** @defgroup HCD_Exported_Macros HCD Exported Macros
120 * @brief macros to handle interrupts and specific clock configurations
123 #define __HAL_HCD_ENABLE(__HANDLE__) USB_EnableGlobalInt ((__HANDLE__)->Instance)
124 #define __HAL_HCD_DISABLE(__HANDLE__) USB_DisableGlobalInt ((__HANDLE__)->Instance)
127 #define __HAL_HCD_GET_FLAG(__HANDLE__, __INTERRUPT__) ((USB_ReadInterrupts((__HANDLE__)->Instance) & (__INTERRUPT__)) == (__INTERRUPT__))
128 #define __HAL_HCD_CLEAR_FLAG(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->GINTSTS) = (__INTERRUPT__))
129 #define __HAL_HCD_IS_INVALID_INTERRUPT(__HANDLE__) (USB_ReadInterrupts((__HANDLE__)->Instance) == 0U)
132 #define __HAL_HCD_CLEAR_HC_INT(chnum, __INTERRUPT__) (USBx_HC(chnum)->HCINT = (__INTERRUPT__))
133 #define __HAL_HCD_MASK_HALT_HC_INT(chnum) (USBx_HC(chnum)->HCINTMSK &= ~USB_OTG_HCINTMSK_CHHM)
134 #define __HAL_HCD_UNMASK_HALT_HC_INT(chnum) (USBx_HC(chnum)->HCINTMSK |= USB_OTG_HCINTMSK_CHHM)
135 #define __HAL_HCD_MASK_ACK_HC_INT(chnum) (USBx_HC(chnum)->HCINTMSK &= ~USB_OTG_HCINTMSK_ACKM)
136 #define __HAL_HCD_UNMASK_ACK_HC_INT(chnum) (USBx_HC(chnum)->HCINTMSK |= USB_OTG_HCINTMSK_ACKM)
142 /* Exported functions --------------------------------------------------------*/
143 /** @addtogroup HCD_Exported_Functions HCD Exported Functions
147 /* Initialization/de-initialization functions ********************************/
148 /** @addtogroup HCD_Exported_Functions_Group1 Initialization and de-initialization functions
151 HAL_StatusTypeDef
HAL_HCD_Init(HCD_HandleTypeDef
*hhcd
);
152 HAL_StatusTypeDef
HAL_HCD_DeInit (HCD_HandleTypeDef
*hhcd
);
153 HAL_StatusTypeDef
HAL_HCD_HC_Init(HCD_HandleTypeDef
*hhcd
,
161 HAL_StatusTypeDef
HAL_HCD_HC_Halt(HCD_HandleTypeDef
*hhcd
,
164 void HAL_HCD_MspInit(HCD_HandleTypeDef
*hhcd
);
165 void HAL_HCD_MspDeInit(HCD_HandleTypeDef
*hhcd
);
170 /* I/O operation functions ***************************************************/
171 /** @addtogroup HCD_Exported_Functions_Group2 IO operation functions
174 HAL_StatusTypeDef
HAL_HCD_HC_SubmitRequest(HCD_HandleTypeDef
*hhcd
,
183 /* Non-Blocking mode: Interrupt */
184 void HAL_HCD_IRQHandler(HCD_HandleTypeDef
*hhcd
);
185 void HAL_HCD_SOF_Callback(HCD_HandleTypeDef
*hhcd
);
186 void HAL_HCD_Connect_Callback(HCD_HandleTypeDef
*hhcd
);
187 void HAL_HCD_Disconnect_Callback(HCD_HandleTypeDef
*hhcd
);
188 void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef
*hhcd
,
190 HCD_URBStateTypeDef urb_state
);
194 /* Peripheral Control functions **********************************************/
195 /** @addtogroup HCD_Exported_Functions_Group3 Peripheral Control functions
198 HAL_StatusTypeDef
HAL_HCD_ResetPort(HCD_HandleTypeDef
*hhcd
);
199 HAL_StatusTypeDef
HAL_HCD_Start(HCD_HandleTypeDef
*hhcd
);
200 HAL_StatusTypeDef
HAL_HCD_Stop(HCD_HandleTypeDef
*hhcd
);
204 /* Peripheral State functions ************************************************/
205 /** @addtogroup HCD_Exported_Functions_Group4 Peripheral State functions
208 HCD_StateTypeDef
HAL_HCD_GetState(HCD_HandleTypeDef
*hhcd
);
209 HCD_URBStateTypeDef
HAL_HCD_HC_GetURBState(HCD_HandleTypeDef
*hhcd
, uint8_t chnum
);
210 uint32_t HAL_HCD_HC_GetXferCount(HCD_HandleTypeDef
*hhcd
, uint8_t chnum
);
211 HCD_HCStateTypeDef
HAL_HCD_HC_GetState(HCD_HandleTypeDef
*hhcd
, uint8_t chnum
);
212 uint32_t HAL_HCD_GetCurrentFrame(HCD_HandleTypeDef
*hhcd
);
213 uint32_t HAL_HCD_GetCurrentSpeed(HCD_HandleTypeDef
*hhcd
);
222 /* Private macros ------------------------------------------------------------*/
223 /** @defgroup HCD_Private_Macros HCD Private Macros
226 /** @defgroup HCD_Instance_definition HCD Instance definition
229 #define IS_HCD_ALL_INSTANCE(INSTANCE) (((INSTANCE) == USB_OTG_FS))
245 #endif /* STM32F105xC || STM32F107xC */
252 #endif /* __STM32F1xx_HAL_HCD_H */
254 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/