stm32: Allow a board to configure the HSE in bypass mode.

To use HSE bypass mode the board should define:

    #define MICROPY_HW_CLK_USE_BYPASS (1)

If this is not defined, or is defined to 0, then HSE oscillator mode is
used.
pull/3713/head
Damien George 2018-04-11 16:46:47 +10:00
rodzic 68b70fac5c
commit cf9fc7346d
4 zmienionych plików z 11 dodań i 4 usunięć

Wyświetl plik

@ -377,7 +377,7 @@ STATIC mp_obj_t machine_freq(size_t n_args, const mp_obj_t *args) {
// 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 = RCC_HSE_ON;
RCC_OscInitStruct.HSEState = MICROPY_HW_CLK_HSE_STATE;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLM = m;
@ -500,7 +500,7 @@ STATIC mp_obj_t machine_sleep(void) {
// reconfigure the system clock after waking up
// enable HSE
__HAL_RCC_HSE_CONFIG(RCC_HSE_ON);
__HAL_RCC_HSE_CONFIG(MICROPY_HW_CLK_HSE_STATE);
while (!__HAL_RCC_GET_FLAG(RCC_FLAG_HSERDY)) {
}

Wyświetl plik

@ -136,6 +136,13 @@
#error Unsupported MCU series
#endif
// Configure HSE for bypass or oscillator
#if MICROPY_HW_CLK_USE_BYPASS
#define MICROPY_HW_CLK_HSE_STATE (RCC_HSE_BYPASS)
#else
#define MICROPY_HW_CLK_HSE_STATE (RCC_HSE_ON)
#endif
#if MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE
// Provide block device macros if internal flash storage is enabled
#define MICROPY_HW_BDEV_IOCTL flash_bdev_ioctl

Wyświetl plik

@ -369,7 +369,7 @@ STATIC void OTG_CMD_WKUP_Handler(PCD_HandleTypeDef *pcd_handle) {
/* Configures system clock after wake-up from STOP: enable HSE, PLL and select
PLL as system clock source (HSE and PLL are disabled in STOP mode) */
__HAL_RCC_HSE_CONFIG(RCC_HSE_ON);
__HAL_RCC_HSE_CONFIG(MICROPY_HW_CLK_HSE_STATE);
/* Wait till HSE is ready */
while(__HAL_RCC_GET_FLAG(RCC_FLAG_HSERDY) == RESET)

Wyświetl plik

@ -404,7 +404,7 @@ void SystemClock_Config(void)
/* Enable HSE Oscillator and activate PLL with HSE as source */
#if defined(STM32F4) || defined(STM32F7) || defined(STM32H7)
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.HSEState = MICROPY_HW_CLK_HSE_STATE;
RCC_OscInitStruct.HSIState = RCC_HSI_OFF;
#if defined(STM32H7)
RCC_OscInitStruct.CSIState = RCC_CSI_OFF;