mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-17 05:32:55 +08:00
bsp.stm32f407g_disc1: Initialize USB clock and pins.
This commit is contained in:
parent
75fda7d638
commit
e73e016a8c
@ -58,11 +58,24 @@ void board_init(void)
|
||||
|
||||
// Init the LED on PD14
|
||||
RCC->AHB1ENR |= RCC_AHB1ENR_GPIODEN;
|
||||
GPIOD->MODER = GPIO_MODER_MODE14_0;
|
||||
GPIOD->MODER |= GPIO_MODER_MODE14_0;
|
||||
|
||||
// USB Clock init
|
||||
// PLL input- 16 MHz (HSI clock)
|
||||
// VCO input- 1 to 2 MHz (2 MHz, M = 8)
|
||||
// VCO output- 100 to 432 MHz (144 MHz, N = 72)
|
||||
// Main PLL out- <= 180 MHz (18 MHz, P = 8, not used; HSI used as system clk.)
|
||||
// USB PLL out- 48 MHz (Q = 3)
|
||||
RCC->PLLCFGR = (3 << RCC_PLLCFGR_PLLQ_Pos) | (8 << RCC_PLLCFGR_PLLP_Pos) \
|
||||
| (72 << RCC_PLLCFGR_PLLN_Pos) | (8 << RCC_PLLCFGR_PLLM_Pos);
|
||||
RCC->CR |= RCC_CR_PLLON;
|
||||
RCC->AHB2ENR |= RCC_AHB2ENR_OTGFSEN;
|
||||
|
||||
// USB Pin Init
|
||||
// PA10- ID, PA11- DM, PA12- DP
|
||||
// PC0- Power on
|
||||
GPIOD->MODER |= GPIO_MODER_MODE10_1 | GPIO_MODER_MODE11_1 | GPIO_MODER_MODE12_1;
|
||||
GPIOA->AFR[1] |= (10 << GPIO_AFRH_AFSEL10_Pos) | (10 << GPIO_AFRH_AFSEL11_Pos) | (10 << GPIO_AFRH_AFSEL12_Pos);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user