stm32: Add compile-time option to use HSI as clock source.
To use HSI instead of HSE define MICROPY_HW_CLK_USE_HSI as 1 in the board configuration file. The default is to use HSE. HSI has been made the default for the NUCLEO_F401RE board to serve as an example, and because early revisions of this board need a hardware modification to get HSE working.
This commit is contained in:
committed by
Damien George
parent
e61862d063
commit
f938e70c69
@@ -215,10 +215,10 @@ set_clk:
|
||||
// Re-configure PLL
|
||||
// Even if we don't use the PLL for the system clock, we still need it for USB, RNG and SDIO
|
||||
RCC_OscInitTypeDef RCC_OscInitStruct;
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
|
||||
RCC_OscInitStruct.HSEState = MICROPY_HW_CLK_HSE_STATE;
|
||||
RCC_OscInitStruct.OscillatorType = MICROPY_HW_RCC_OSCILLATOR_TYPE;
|
||||
RCC_OscInitStruct.HSEState = MICROPY_HW_RCC_HSE_STATE;
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
|
||||
RCC_OscInitStruct.PLL.PLLSource = MICROPY_HW_RCC_PLL_SRC;
|
||||
RCC_OscInitStruct.PLL.PLLM = m;
|
||||
RCC_OscInitStruct.PLL.PLLN = n;
|
||||
RCC_OscInitStruct.PLL.PLLP = p;
|
||||
@@ -297,9 +297,12 @@ void powerctrl_enter_stop_mode(void) {
|
||||
#else
|
||||
|
||||
#if !defined(STM32L4)
|
||||
// enable HSE
|
||||
__HAL_RCC_HSE_CONFIG(MICROPY_HW_CLK_HSE_STATE);
|
||||
while (!__HAL_RCC_GET_FLAG(RCC_FLAG_HSERDY)) {
|
||||
// enable clock
|
||||
__HAL_RCC_HSE_CONFIG(MICROPY_HW_RCC_HSE_STATE);
|
||||
#if MICROPY_HW_CLK_USE_HSI
|
||||
__HAL_RCC_HSI_ENABLE();
|
||||
#endif
|
||||
while (!__HAL_RCC_GET_FLAG(MICROPY_HW_RCC_FLAG_HSxRDY)) {
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user