stm32/rtc: Allow overriding startup timeouts from mpconfigboard.
This commit is contained in:
parent
3f54462add
commit
29865e3e58
@ -342,18 +342,24 @@ STATIC void PYB_RTC_MspInit_Kick(RTC_HandleTypeDef *hrtc, bool rtc_use_lse, bool
|
||||
rtc_need_init_finalise = true;
|
||||
}
|
||||
|
||||
#define PYB_LSE_TIMEOUT_VALUE 1000 // ST docs spec 2000 ms LSE startup, seems to be too pessimistic
|
||||
#define PYB_LSI_TIMEOUT_VALUE 500 // this is way too pessimistic, typ. < 1ms
|
||||
#define PYB_BYP_TIMEOUT_VALUE 150
|
||||
#ifndef MICROPY_HW_RTC_LSE_TIMEOUT_MS
|
||||
#define MICROPY_HW_RTC_LSE_TIMEOUT_MS 1000 // ST docs spec 2000 ms LSE startup, seems to be too pessimistic
|
||||
#endif
|
||||
#ifndef MICROPY_HW_RTC_LSI_TIMEOUT_MS
|
||||
#define MICROPY_HW_RTC_LSI_TIMEOUT_MS 500 // this is way too pessimistic, typ. < 1ms
|
||||
#endif
|
||||
#ifndef MICROPY_HW_RTC_BYP_TIMEOUT_MS
|
||||
#define MICROPY_HW_RTC_BYP_TIMEOUT_MS 150
|
||||
#endif
|
||||
|
||||
STATIC HAL_StatusTypeDef PYB_RTC_MspInit_Finalise(RTC_HandleTypeDef *hrtc) {
|
||||
// we already had a kick so now wait for the corresponding ready state...
|
||||
if (rtc_use_lse) {
|
||||
// we now have to wait for LSE ready or timeout
|
||||
uint32_t timeout = PYB_LSE_TIMEOUT_VALUE;
|
||||
uint32_t timeout = MICROPY_HW_RTC_LSE_TIMEOUT_MS;
|
||||
#if MICROPY_HW_RTC_USE_BYPASS
|
||||
if (RCC->BDCR & RCC_BDCR_LSEBYP) {
|
||||
timeout = PYB_BYP_TIMEOUT_VALUE;
|
||||
timeout = MICROPY_HW_RTC_BYP_TIMEOUT_MS;
|
||||
}
|
||||
#endif
|
||||
uint32_t tickstart = rtc_startup_tick;
|
||||
@ -366,7 +372,7 @@ STATIC HAL_StatusTypeDef PYB_RTC_MspInit_Finalise(RTC_HandleTypeDef *hrtc) {
|
||||
// we now have to wait for LSI ready or timeout
|
||||
uint32_t tickstart = rtc_startup_tick;
|
||||
while (__HAL_RCC_GET_FLAG(RCC_FLAG_LSIRDY) == RESET) {
|
||||
if ((HAL_GetTick() - tickstart ) > PYB_LSI_TIMEOUT_VALUE) {
|
||||
if ((HAL_GetTick() - tickstart ) > MICROPY_HW_RTC_LSI_TIMEOUT_MS) {
|
||||
return HAL_TIMEOUT;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user