From 797f3277706ac383f4c93cdb641a23f165d7e189 Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Wed, 9 Mar 2022 01:19:49 +0200 Subject: [PATCH] boards/OPENMVPT: Fix RTC errata. --- src/hal/cmsis/src/st/system_stm32fxxx.c | 4 ++++ src/hal/stm32/h7/include/stm32h7xx_hal_conf.h | 2 +- src/omv/boards/OPENMVPT/omv_boardconfig.h | 6 ++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/hal/cmsis/src/st/system_stm32fxxx.c b/src/hal/cmsis/src/st/system_stm32fxxx.c index 6fa9c99a7..7784ab387 100644 --- a/src/hal/cmsis/src/st/system_stm32fxxx.c +++ b/src/hal/cmsis/src/st/system_stm32fxxx.c @@ -319,12 +319,16 @@ void SystemClock_Config(void) #endif #if defined(MCU_SERIES_H7) + + #if !defined(OMV_OMVPT_ERRATA_RTC) PeriphClkInitStruct.PeriphClockSelection |= RCC_PERIPHCLK_RTC; #if defined(OMV_OSC_RTC_CLKSOURCE) PeriphClkInitStruct.RTCClockSelection = OMV_OSC_RTC_CLKSOURCE; #else PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSI; #endif + #endif + PeriphClkInitStruct.PeriphClockSelection |= RCC_PERIPHCLK_RNG; PeriphClkInitStruct.RngClockSelection = OMV_OSC_RNG_CLKSOURCE; diff --git a/src/hal/stm32/h7/include/stm32h7xx_hal_conf.h b/src/hal/stm32/h7/include/stm32h7xx_hal_conf.h index 4a34f0105..319b9129c 100644 --- a/src/hal/stm32/h7/include/stm32h7xx_hal_conf.h +++ b/src/hal/stm32/h7/include/stm32h7xx_hal_conf.h @@ -138,7 +138,7 @@ #if !defined (LSE_STARTUP_TIMEOUT) - #define LSE_STARTUP_TIMEOUT (5000UL) /*!< Time out for LSE start up, in ms */ + #define LSE_STARTUP_TIMEOUT (500UL) /*!< Time out for LSE start up, in ms */ #endif /* LSE_STARTUP_TIMEOUT */ #if !defined (LSI_VALUE) diff --git a/src/omv/boards/OPENMVPT/omv_boardconfig.h b/src/omv/boards/OPENMVPT/omv_boardconfig.h index c03c30c64..24364296c 100644 --- a/src/omv/boards/OPENMVPT/omv_boardconfig.h +++ b/src/omv/boards/OPENMVPT/omv_boardconfig.h @@ -133,15 +133,17 @@ #define OMV_OSC_USB_CLKSOURCE RCC_USBCLKSOURCE_PLL #define OMV_OSC_RNG_CLKSOURCE RCC_RNGCLKSOURCE_HSI48 #define OMV_OSC_ADC_CLKSOURCE RCC_ADCCLKSOURCE_PLL2 -#define OMV_OSC_RTC_CLKSOURCE RCC_RTCCLKSOURCE_LSE +//#define OMV_OSC_RTC_CLKSOURCE RCC_RTCCLKSOURCE_LSE #define OMV_OSC_SPI123_CLKSOURCE RCC_SPI123CLKSOURCE_PLL2 // HSE/HSI/CSI State -// The LSE is not configured due to an issue with the LSE crystal oscillator. +// The LSE/LSI and RTC are managed by micropython's rtc.c. // #define OMV_OSC_LSE_STATE (RCC_LSE_ON) // #define OMV_OSC_LSE_DRIVE (RCC_LSEDRIVE_HIGH) #define OMV_OSC_HSE_STATE (RCC_HSE_ON) #define OMV_OSC_HSI48_STATE (RCC_HSI48_ON) +// Errata +#define OMV_OMVPT_ERRATA_RTC (1) // Flash Latency #define OMV_FLASH_LATENCY (FLASH_LATENCY_2)