mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-17 05:32:55 +08:00
couldn't get g4 usb clock and pin setup just yet. Leave it as it is for now
This commit is contained in:
parent
f90f5ea369
commit
310f287f44
@ -31,6 +31,10 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// G474RE Nucleo does not has usb connection. We need to manually connect
|
||||
// - PA11 for D+, CN10.14
|
||||
// - PA12 for D-, CN10.12
|
||||
|
||||
// LED
|
||||
#define LED_PORT GPIOA
|
||||
#define LED_PIN GPIO_PIN_5
|
||||
@ -49,6 +53,7 @@
|
||||
#define UART_TX_PIN GPIO_PIN_2
|
||||
#define UART_RX_PIN GPIO_PIN_3
|
||||
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// RCC Clock
|
||||
//--------------------------------------------------------------------+
|
||||
@ -81,6 +86,36 @@ static inline void board_clock_init(void)
|
||||
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
|
||||
|
||||
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_8);
|
||||
|
||||
#if 0 // TODO need to check if USB clock is enabled
|
||||
/* Enable HSI48 */
|
||||
memset(&RCC_OscInitStruct, 0, sizeof(RCC_OscInitStruct));
|
||||
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48;
|
||||
RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
|
||||
HAL_RCC_OscConfig(&RCC_OscInitStruct);
|
||||
|
||||
/*Enable CRS Clock*/
|
||||
RCC_CRSInitTypeDef RCC_CRSInitStruct= {0};
|
||||
__HAL_RCC_CRS_CLK_ENABLE();
|
||||
|
||||
/* Default Synchro Signal division factor (not divided) */
|
||||
RCC_CRSInitStruct.Prescaler = RCC_CRS_SYNC_DIV1;
|
||||
|
||||
/* Set the SYNCSRC[1:0] bits according to CRS_Source value */
|
||||
RCC_CRSInitStruct.Source = RCC_CRS_SYNC_SOURCE_USB;
|
||||
|
||||
/* HSI48 is synchronized with USB SOF at 1KHz rate */
|
||||
RCC_CRSInitStruct.ReloadValue = __HAL_RCC_CRS_RELOADVALUE_CALCULATE(48000000, 1000);
|
||||
RCC_CRSInitStruct.ErrorLimitValue = RCC_CRS_ERRORLIMIT_DEFAULT;
|
||||
|
||||
/* Set the TRIM[5:0] to the default value */
|
||||
RCC_CRSInitStruct.HSI48CalibrationValue = RCC_CRS_HSI48CALIBRATION_DEFAULT;
|
||||
|
||||
/* Start automatic synchronization */
|
||||
HAL_RCCEx_CRSConfig(&RCC_CRSInitStruct);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void board_vbus_sense_init(void)
|
||||
|
@ -31,14 +31,19 @@
|
||||
//--------------------------------------------------------------------+
|
||||
// Forward USB interrupt events to TinyUSB IRQ Handler
|
||||
//--------------------------------------------------------------------+
|
||||
void OTG_FS_IRQHandler(void)
|
||||
void USB_HP_IRQHandler(void)
|
||||
{
|
||||
tud_int_handler(0);
|
||||
}
|
||||
|
||||
void OTG_HS_IRQHandler(void)
|
||||
void USB_LP_IRQHandler(void)
|
||||
{
|
||||
tud_int_handler(1);
|
||||
tud_int_handler(0);
|
||||
}
|
||||
|
||||
void USBWakeUp_IRQHandler(void)
|
||||
{
|
||||
tud_int_handler(0);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
@ -111,7 +116,15 @@ void board_init(void)
|
||||
HAL_UART_Init(&UartHandle);
|
||||
#endif
|
||||
|
||||
// TODO Configure USB GPIOs
|
||||
// USB Pins TODO double check USB clock and pin setup
|
||||
// Configure USB DM and DP pins. This is optional, and maintained only for user guidance.
|
||||
// GPIO_InitStruct.Pin = (GPIO_PIN_11 | GPIO_PIN_12);
|
||||
// GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
// GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
// GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
// HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
//
|
||||
// __HAL_RCC_USB_CLK_ENABLE();
|
||||
|
||||
board_vbus_sense_init();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user