trezorhal/usb: add some support for hs-in-fs

This commit is contained in:
Jan Pochyla 2017-06-12 13:58:32 +02:00
parent e22164e34d
commit fbf7be27cd
2 changed files with 30 additions and 3 deletions

View File

@ -16,6 +16,14 @@
#define USB_MAX_STR_SIZE 62
#define USB_MAX_STR_DESC_SIZE (USB_MAX_STR_SIZE * 2 + 2)
#if defined(USE_USB_FS)
#define USB_PHY_ID USB_PHY_FS_ID
#elif defined(USE_USB_HS) && defined(USE_USB_HS_IN_FS)
#define USB_PHY_ID USB_PHY_HS_ID
#else
#error Unable to determine proper USB_PHY_ID to use
#endif
static usb_device_descriptor_t usb_dev_desc;
// Config descriptor
@ -86,7 +94,7 @@ int usb_init(const usb_dev_info_t *dev_info) {
// Pointer to interface descriptor data
usb_next_iface_desc = (usb_interface_descriptor_t *)(usb_config_buf + usb_config_desc->wTotalLength);
if (0 != USBD_Init(&usb_dev_handle, (USBD_DescriptorsTypeDef*)&usb_descriptors, USB_PHY_FS_ID)) {
if (0 != USBD_Init(&usb_dev_handle, (USBD_DescriptorsTypeDef*)&usb_descriptors, USB_PHY_ID)) {
return 1;
}
if (0 != USBD_RegisterClass(&usb_dev_handle, (USBD_ClassTypeDef*)&usb_class)) {

View File

@ -698,19 +698,27 @@ void USBD_LL_Delay(uint32_t Delay)
*******************************************************************************/
/**
* @brief This function handles USB-On-The-Go FS global interrupt request.
* @brief This function handles USB-On-The-Go FS/HS global interrupt request.
* @param None
* @retval None
*/
#if defined(USE_USB_FS)
void OTG_FS_IRQHandler(void) {
HAL_PCD_IRQHandler(&pcd_fs_handle);
}
#endif
#if defined(USE_USB_HS)
void OTG_HS_IRQHandler(void) {
HAL_PCD_IRQHandler(&pcd_hs_handle);
}
#endif
/**
* @brief This function handles USB OTG Common FS/HS Wakeup functions.
* @param *pcd_handle for FS or HS
* @retval None
*/
#if defined(USE_USB_FS) || defined(USE_USB_HS)
static void OTG_CMD_WKUP_Handler(PCD_HandleTypeDef *pcd_handle) {
if (!(pcd_handle->Init.low_power_enable)) {
return;
@ -741,17 +749,28 @@ static void OTG_CMD_WKUP_Handler(PCD_HandleTypeDef *pcd_handle) {
/* ungate PHY clock */
__HAL_PCD_UNGATE_PHYCLOCK(pcd_handle);
}
#endif
/**
* @brief This function handles USB OTG FS Wakeup IRQ Handler.
* @brief This function handles USB OTG FS/HS Wakeup IRQ Handler.
* @param None
* @retval None
*/
#if defined(USE_USB_FS)
void OTG_FS_WKUP_IRQHandler(void) {
OTG_CMD_WKUP_Handler(&pcd_fs_handle);
/* Clear EXTI pending Bit*/
__HAL_USB_OTG_FS_WAKEUP_EXTI_CLEAR_FLAG();
}
#endif
#if defined(USE_USB_HS)
void OTG_HS_WKUP_IRQHandler(void) {
OTG_CMD_WKUP_Handler(&pcd_hs_handle);
/* Clear EXTI pending Bit*/
__HAL_USB_HS_EXTI_CLEAR_FLAG();
}
#endif
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/