testing hcd with f723 due to h743eval issue with mfx vbus drive.
This commit is contained in:
		| @@ -1,6 +1,6 @@ | |||||||
| set(MCU_VARIANT stm32f723xx) | set(MCU_VARIANT stm32f723xx) | ||||||
| set(JLINK_DEVICE stm32f723ie) | set(JLINK_DEVICE stm32f723ie) | ||||||
|  | #set(JLINK_OPTION "-USB 000776606156") | ||||||
| set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/STM32F723xE_FLASH.ld) | set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/STM32F723xE_FLASH.ld) | ||||||
|  |  | ||||||
| function(update_board TARGET) | function(update_board TARGET) | ||||||
|   | |||||||
| @@ -56,8 +56,7 @@ | |||||||
| //--------------------------------------------------------------------+ | //--------------------------------------------------------------------+ | ||||||
| // RCC Clock | // RCC Clock | ||||||
| //--------------------------------------------------------------------+ | //--------------------------------------------------------------------+ | ||||||
| static inline void board_clock_init(void) | static inline void board_clock_init(void) { | ||||||
| { |  | ||||||
|   RCC_ClkInitTypeDef RCC_ClkInitStruct; |   RCC_ClkInitTypeDef RCC_ClkInitStruct; | ||||||
|   RCC_OscInitTypeDef RCC_OscInitStruct; |   RCC_OscInitTypeDef RCC_OscInitStruct; | ||||||
|  |  | ||||||
| @@ -74,7 +73,7 @@ static inline void board_clock_init(void) | |||||||
|   RCC_OscInitStruct.HSEState = RCC_HSE_ON; |   RCC_OscInitStruct.HSEState = RCC_HSE_ON; | ||||||
|   RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; |   RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; | ||||||
|   RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; |   RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; | ||||||
|   RCC_OscInitStruct.PLL.PLLM = HSE_VALUE/1000000; |   RCC_OscInitStruct.PLL.PLLM = HSE_VALUE / 1000000; | ||||||
|   RCC_OscInitStruct.PLL.PLLN = 432; |   RCC_OscInitStruct.PLL.PLLN = 432; | ||||||
|   RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; |   RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; | ||||||
|   RCC_OscInitStruct.PLL.PLLQ = 9; |   RCC_OscInitStruct.PLL.PLLQ = 9; | ||||||
| @@ -98,6 +97,42 @@ static inline void board_clock_init(void) | |||||||
| // | // | ||||||
| //} | //} | ||||||
|  |  | ||||||
|  | typedef struct { | ||||||
|  |   GPIO_TypeDef* port; | ||||||
|  |   GPIO_InitTypeDef pin_init; | ||||||
|  |   bool active_state; | ||||||
|  | } board_pindef_t; | ||||||
|  |  | ||||||
|  | static board_pindef_t vbus_pindef[] = { | ||||||
|  | { | ||||||
|  |     .port = GPIOG, | ||||||
|  |     .pin_init = { | ||||||
|  |       .Pin = GPIO_PIN_8, .Mode = GPIO_MODE_OUTPUT_OD, .Pull = GPIO_NOPULL, | ||||||
|  |       .Speed = GPIO_SPEED_HIGH, .Alternate = 0 | ||||||
|  |     }, | ||||||
|  |     .active_state = false | ||||||
|  |   }, | ||||||
|  | { | ||||||
|  |     .port = GPIOH, | ||||||
|  |     .pin_init = { | ||||||
|  |       .Pin = GPIO_PIN_12, .Mode = GPIO_MODE_OUTPUT_PP, .Pull = GPIO_NOPULL, | ||||||
|  |       .Speed = GPIO_SPEED_HIGH, .Alternate = 0 | ||||||
|  |     }, | ||||||
|  |     .active_state = true | ||||||
|  |   }, | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | static inline void board_vbus_set(uint8_t rhport, bool state) { | ||||||
|  |   static bool pin_inited[2] = { false, false }; | ||||||
|  |   board_pindef_t* pindef = &vbus_pindef[rhport]; | ||||||
|  |   if (!pin_inited[rhport]) { | ||||||
|  |     HAL_GPIO_Init(pindef->port, &pindef->pin_init); | ||||||
|  |     pin_inited[rhport] = true; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   HAL_GPIO_WritePin(pindef->port, pindef->pin_init.Pin, state == pindef->active_state ? GPIO_PIN_SET : GPIO_PIN_RESET); | ||||||
|  | } | ||||||
|  |  | ||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
|  } |  } | ||||||
| #endif | #endif | ||||||
|   | |||||||
| @@ -34,13 +34,13 @@ | |||||||
| // Forward USB interrupt events to TinyUSB IRQ Handler | // Forward USB interrupt events to TinyUSB IRQ Handler | ||||||
| //--------------------------------------------------------------------+ | //--------------------------------------------------------------------+ | ||||||
| void OTG_FS_IRQHandler(void) { | void OTG_FS_IRQHandler(void) { | ||||||
|   tud_int_handler(0); |   tusb_int_handler(0, true); | ||||||
| } | } | ||||||
|  |  | ||||||
| // Despite being call USB2_OTG | // Despite being call USB2_OTG | ||||||
| // OTG_HS is marked as RHPort1 by TinyUSB to be consistent across stm32 port | // OTG_HS is marked as RHPort1 by TinyUSB to be consistent across stm32 port | ||||||
| void OTG_HS_IRQHandler(void) { | void OTG_HS_IRQHandler(void) { | ||||||
|   tud_int_handler(1); |   tusb_int_handler(1, true); | ||||||
| } | } | ||||||
|  |  | ||||||
| //--------------------------------------------------------------------+ | //--------------------------------------------------------------------+ | ||||||
| @@ -65,7 +65,7 @@ void board_init(void) { | |||||||
|   __HAL_RCC_GPIOJ_CLK_ENABLE(); |   __HAL_RCC_GPIOJ_CLK_ENABLE(); | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|       UART_CLK_EN(); |   UART_CLK_EN(); | ||||||
|  |  | ||||||
| #if CFG_TUSB_OS == OPT_OS_NONE | #if CFG_TUSB_OS == OPT_OS_NONE | ||||||
|   // 1ms tick timer |   // 1ms tick timer | ||||||
| @@ -122,9 +122,7 @@ void board_init(void) { | |||||||
|   UartHandle.Init.OverSampling = UART_OVERSAMPLING_16; |   UartHandle.Init.OverSampling = UART_OVERSAMPLING_16; | ||||||
|   HAL_UART_Init(&UartHandle); |   HAL_UART_Init(&UartHandle); | ||||||
|  |  | ||||||
| #if BOARD_TUD_RHPORT == 0 |   //------------- rhport0: OTG_FS -------------// | ||||||
|   // OTG_FS |  | ||||||
|  |  | ||||||
|   /* Configure DM DP Pins */ |   /* Configure DM DP Pins */ | ||||||
|   GPIO_InitStruct.Pin = (GPIO_PIN_11 | GPIO_PIN_12); |   GPIO_InitStruct.Pin = (GPIO_PIN_11 | GPIO_PIN_12); | ||||||
|   GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |   GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | ||||||
| @@ -171,9 +169,7 @@ void board_init(void) { | |||||||
|   USB_OTG_FS->GOTGCTL |= USB_OTG_GOTGCTL_BVALOVAL; |   USB_OTG_FS->GOTGCTL |= USB_OTG_GOTGCTL_BVALOVAL; | ||||||
| #endif // vbus sense | #endif // vbus sense | ||||||
|  |  | ||||||
| #else |   //------------- rhport1: OTG_HS -------------// | ||||||
|   // OTG_HS |  | ||||||
|  |  | ||||||
|   #ifdef USB_HS_PHYC |   #ifdef USB_HS_PHYC | ||||||
|   // MCU with built-in HS PHY such as F723, F733, F730 |   // MCU with built-in HS PHY such as F723, F733, F730 | ||||||
|  |  | ||||||
| @@ -261,12 +257,10 @@ void board_init(void) { | |||||||
|   USB_OTG_HS->GOTGCTL |= USB_OTG_GOTGCTL_BVALOVAL; |   USB_OTG_HS->GOTGCTL |= USB_OTG_GOTGCTL_BVALOVAL; | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|   // Force device mode |   // Turn on host vbus | ||||||
|   USB_OTG_HS->GUSBCFG &= ~USB_OTG_GUSBCFG_FHMOD; | #if CFG_TUH_ENABLED | ||||||
|   USB_OTG_HS->GUSBCFG |= USB_OTG_GUSBCFG_FDMOD; |   board_vbus_set(BOARD_TUH_RHPORT, true); | ||||||
|  | #endif | ||||||
| #endif // BOARD_TUD_RHPORT |  | ||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
| //--------------------------------------------------------------------+ | //--------------------------------------------------------------------+ | ||||||
|   | |||||||
| @@ -41,8 +41,8 @@ | |||||||
|  |  | ||||||
| typedef enum { | typedef enum { | ||||||
|   TUSB_ROLE_INVALID = 0, |   TUSB_ROLE_INVALID = 0, | ||||||
|   TUSB_ROLE_DEVICE, |   TUSB_ROLE_DEVICE  = 0x1, | ||||||
|   TUSB_ROLE_HOST, |   TUSB_ROLE_HOST    = 0x2, | ||||||
| } tusb_role_t; | } tusb_role_t; | ||||||
|  |  | ||||||
| /// defined base on EHCI specs value for Endpoint Speed | /// defined base on EHCI specs value for Endpoint Speed | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 hathach
					hathach