mbed library sources
Dependents: Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more
Superseded
This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.
Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.
If you are looking for a stable and tested release, please import one of the official mbed library releases:
Import librarymbed
The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.
Diff: targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hcd.c
- Revision:
- 106:ced8cbb51063
- Parent:
- 87:085cde657901
- Child:
- 226:b062af740e40
--- a/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hcd.c Mon Feb 24 10:30:08 2014 +0000 +++ b/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_hcd.c Wed Feb 26 09:45:12 2014 +0000 @@ -2,8 +2,8 @@ ****************************************************************************** * @file stm32f4xx_hal_hcd.c * @author MCD Application Team - * @version V1.0.0RC2 - * @date 04-February-2014 + * @version V1.0.0 + * @date 18-February-2014 * @brief HCD HAL module driver. * This file provides firmware functions to manage the following * functionalities of the USB Peripheral Controller: @@ -88,10 +88,10 @@ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ -static void HAL_HCD_HC_IN_IRQHandler (HCD_HandleTypeDef *hhcd, uint8_t chnum); -static void HAL_HCD_HC_OUT_IRQHandler (HCD_HandleTypeDef *hhcd, uint8_t chnum); -static void HAL_HCD_RXQLVL_IRQHandler (HCD_HandleTypeDef *hhcd); -static void HAL_HCD_Port_IRQHandler (HCD_HandleTypeDef *hhcd); +static void HCD_HC_IN_IRQHandler(HCD_HandleTypeDef *hhcd, uint8_t chnum); +static void HCD_HC_OUT_IRQHandler(HCD_HandleTypeDef *hhcd, uint8_t chnum); +static void HCD_RXQLVL_IRQHandler(HCD_HandleTypeDef *hhcd); +static void HCD_Port_IRQHandler(HCD_HandleTypeDef *hhcd); /* Private functions ---------------------------------------------------------*/ /** @defgroup HCD_Private_Functions @@ -489,16 +489,17 @@ /* Cleanup HPRT */ USBx_HPRT0 &= ~(USB_OTG_HPRT_PENA | USB_OTG_HPRT_PCDET |\ USB_OTG_HPRT_PENCHNG | USB_OTG_HPRT_POCCHNG ); - + /* Handle Host Port Interrupts */ HAL_HCD_Disconnect_Callback(hhcd); + USB_InitFSLSPClkSel(hhcd->Instance ,HCFG_48_MHZ ); __HAL_HCD_CLEAR_FLAG(hhcd, USB_OTG_GINTSTS_DISCINT); } /* Handle Host Port Interrupts */ if(__HAL_HCD_GET_FLAG(hhcd, USB_OTG_GINTSTS_HPRTINT)) { - HAL_HCD_Port_IRQHandler (hhcd); + HCD_Port_IRQHandler (hhcd); } /* Handle Host SOF Interrupts */ @@ -519,11 +520,11 @@ { if ((USBx_HC(i)->HCCHAR) & USB_OTG_HCCHAR_EPDIR) { - HAL_HCD_HC_IN_IRQHandler (hhcd, i); + HCD_HC_IN_IRQHandler (hhcd, i); } else { - HAL_HCD_HC_OUT_IRQHandler (hhcd, i); + HCD_HC_OUT_IRQHandler (hhcd, i); } } } @@ -535,7 +536,7 @@ { USB_MASK_INTERRUPT(hhcd->Instance, USB_OTG_GINTSTS_RXFLVL); - HAL_HCD_RXQLVL_IRQHandler (hhcd); + HCD_RXQLVL_IRQHandler (hhcd); USB_UNMASK_INTERRUPT(hhcd->Instance, USB_OTG_GINTSTS_RXFLVL); } @@ -644,7 +645,6 @@ { __HAL_LOCK(hhcd); USB_StopHost(hhcd->Instance); - USB_DriveVbus(hhcd->Instance, 0); __HAL_UNLOCK(hhcd); return HAL_OK; } @@ -773,7 +773,7 @@ * This parameter can be a value from 1 to 15 * @retval none */ -static void HAL_HCD_HC_IN_IRQHandler (HCD_HandleTypeDef *hhcd, uint8_t chnum) +static void HCD_HC_IN_IRQHandler (HCD_HandleTypeDef *hhcd, uint8_t chnum) { USB_OTG_GlobalTypeDef *USBx = hhcd->Instance; @@ -912,7 +912,7 @@ * This parameter can be a value from 1 to 15 * @retval none */ -static void HAL_HCD_HC_OUT_IRQHandler (HCD_HandleTypeDef *hhcd, uint8_t chnum) +static void HCD_HC_OUT_IRQHandler (HCD_HandleTypeDef *hhcd, uint8_t chnum) { USB_OTG_GlobalTypeDef *USBx = hhcd->Instance; @@ -1052,7 +1052,7 @@ * @param hhcd: HCD handle * @retval none */ -static void HAL_HCD_RXQLVL_IRQHandler (HCD_HandleTypeDef *hhcd) +static void HCD_RXQLVL_IRQHandler (HCD_HandleTypeDef *hhcd) { USB_OTG_GlobalTypeDef *USBx = hhcd->Instance; uint8_t channelnum =0; @@ -1102,7 +1102,7 @@ * @param hhcd: HCD handle * @retval none */ -static void HAL_HCD_Port_IRQHandler (HCD_HandleTypeDef *hhcd) +static void HCD_Port_IRQHandler (HCD_HandleTypeDef *hhcd) { USB_OTG_GlobalTypeDef *USBx = hhcd->Instance; __IO uint32_t hprt0, hprt0_dup; @@ -1116,9 +1116,10 @@ /* Check wether Port Connect Detected */ if((hprt0 & USB_OTG_HPRT_PCDET) == USB_OTG_HPRT_PCDET) - { + { if((hprt0 & USB_OTG_HPRT_PCSTS) == USB_OTG_HPRT_PCSTS) { + USB_MASK_INTERRUPT(hhcd->Instance, USB_OTG_GINTSTS_DISCINT); HAL_HCD_Connect_Callback(hhcd); } hprt0_dup |= USB_OTG_HPRT_PCDET; @@ -1138,17 +1139,33 @@ { USB_InitFSLSPClkSel(hhcd->Instance ,HCFG_6_MHZ ); } - else if ((hprt0 & USB_OTG_HPRT_PSPD) == (HPRT0_PRTSPD_FULL_SPEED << 17)) + else { USB_InitFSLSPClkSel(hhcd->Instance ,HCFG_48_MHZ ); } } else { - USB_InitFSLSPClkSel(USBx , HCFG_30_60_MHZ); + if(hhcd->Init.speed == HCD_SPEED_FULL) + { + USBx_HOST->HFIR = (uint32_t)60000; + } } HAL_HCD_Connect_Callback(hhcd); + + if(hhcd->Init.speed == HCD_SPEED_HIGH) + { + USB_UNMASK_INTERRUPT(hhcd->Instance, USB_OTG_GINTSTS_DISCINT); + } } + else + { + /* Cleanup HPRT */ + USBx_HPRT0 &= ~(USB_OTG_HPRT_PENA | USB_OTG_HPRT_PCDET |\ + USB_OTG_HPRT_PENCHNG | USB_OTG_HPRT_POCCHNG ); + + USB_UNMASK_INTERRUPT(hhcd->Instance, USB_OTG_GINTSTS_DISCINT); + } } /* Check For an overcurrent */