mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-26 01:18:28 +00:00
trezorhal/usb: add some support for hs-in-fs
This commit is contained in:
parent
e22164e34d
commit
fbf7be27cd
@ -16,6 +16,14 @@
|
|||||||
#define USB_MAX_STR_SIZE 62
|
#define USB_MAX_STR_SIZE 62
|
||||||
#define USB_MAX_STR_DESC_SIZE (USB_MAX_STR_SIZE * 2 + 2)
|
#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;
|
static usb_device_descriptor_t usb_dev_desc;
|
||||||
|
|
||||||
// Config descriptor
|
// Config descriptor
|
||||||
@ -86,7 +94,7 @@ int usb_init(const usb_dev_info_t *dev_info) {
|
|||||||
// Pointer to interface descriptor data
|
// Pointer to interface descriptor data
|
||||||
usb_next_iface_desc = (usb_interface_descriptor_t *)(usb_config_buf + usb_config_desc->wTotalLength);
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
if (0 != USBD_RegisterClass(&usb_dev_handle, (USBD_ClassTypeDef*)&usb_class)) {
|
if (0 != USBD_RegisterClass(&usb_dev_handle, (USBD_ClassTypeDef*)&usb_class)) {
|
||||||
|
@ -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
|
* @param None
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
|
#if defined(USE_USB_FS)
|
||||||
void OTG_FS_IRQHandler(void) {
|
void OTG_FS_IRQHandler(void) {
|
||||||
HAL_PCD_IRQHandler(&pcd_fs_handle);
|
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.
|
* @brief This function handles USB OTG Common FS/HS Wakeup functions.
|
||||||
* @param *pcd_handle for FS or HS
|
* @param *pcd_handle for FS or HS
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
|
#if defined(USE_USB_FS) || defined(USE_USB_HS)
|
||||||
static void OTG_CMD_WKUP_Handler(PCD_HandleTypeDef *pcd_handle) {
|
static void OTG_CMD_WKUP_Handler(PCD_HandleTypeDef *pcd_handle) {
|
||||||
if (!(pcd_handle->Init.low_power_enable)) {
|
if (!(pcd_handle->Init.low_power_enable)) {
|
||||||
return;
|
return;
|
||||||
@ -741,17 +749,28 @@ static void OTG_CMD_WKUP_Handler(PCD_HandleTypeDef *pcd_handle) {
|
|||||||
/* ungate PHY clock */
|
/* ungate PHY clock */
|
||||||
__HAL_PCD_UNGATE_PHYCLOCK(pcd_handle);
|
__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
|
* @param None
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
|
#if defined(USE_USB_FS)
|
||||||
void OTG_FS_WKUP_IRQHandler(void) {
|
void OTG_FS_WKUP_IRQHandler(void) {
|
||||||
OTG_CMD_WKUP_Handler(&pcd_fs_handle);
|
OTG_CMD_WKUP_Handler(&pcd_fs_handle);
|
||||||
|
|
||||||
/* Clear EXTI pending Bit*/
|
/* Clear EXTI pending Bit*/
|
||||||
__HAL_USB_OTG_FS_WAKEUP_EXTI_CLEAR_FLAG();
|
__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****/
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||||
|
Loading…
Reference in New Issue
Block a user