@@ -342,18 +342,24 @@ STATIC void PYB_RTC_MspInit_Kick(RTC_HandleTypeDef *hrtc, bool rtc_use_lse, bool
342342 rtc_need_init_finalise = true;
343343}
344344
345- #define PYB_LSE_TIMEOUT_VALUE 1000 // ST docs spec 2000 ms LSE startup, seems to be too pessimistic
346- #define PYB_LSI_TIMEOUT_VALUE 500 // this is way too pessimistic, typ. < 1ms
347- #define PYB_BYP_TIMEOUT_VALUE 150
345+ #ifndef MICROPY_HW_RTC_LSE_TIMEOUT_MS
346+ #define MICROPY_HW_RTC_LSE_TIMEOUT_MS 1000 // ST docs spec 2000 ms LSE startup, seems to be too pessimistic
347+ #endif
348+ #ifndef MICROPY_HW_RTC_LSI_TIMEOUT_MS
349+ #define MICROPY_HW_RTC_LSI_TIMEOUT_MS 500 // this is way too pessimistic, typ. < 1ms
350+ #endif
351+ #ifndef MICROPY_HW_RTC_BYP_TIMEOUT_MS
352+ #define MICROPY_HW_RTC_BYP_TIMEOUT_MS 150
353+ #endif
348354
349355STATIC HAL_StatusTypeDef PYB_RTC_MspInit_Finalise (RTC_HandleTypeDef * hrtc ) {
350356 // we already had a kick so now wait for the corresponding ready state...
351357 if (rtc_use_lse ) {
352358 // we now have to wait for LSE ready or timeout
353- uint32_t timeout = PYB_LSE_TIMEOUT_VALUE ;
359+ uint32_t timeout = MICROPY_HW_RTC_LSE_TIMEOUT_MS ;
354360 #if MICROPY_HW_RTC_USE_BYPASS
355361 if (RCC -> BDCR & RCC_BDCR_LSEBYP ) {
356- timeout = PYB_BYP_TIMEOUT_VALUE ;
362+ timeout = MICROPY_HW_RTC_BYP_TIMEOUT_MS ;
357363 }
358364 #endif
359365 uint32_t tickstart = rtc_startup_tick ;
@@ -366,7 +372,7 @@ STATIC HAL_StatusTypeDef PYB_RTC_MspInit_Finalise(RTC_HandleTypeDef *hrtc) {
366372 // we now have to wait for LSI ready or timeout
367373 uint32_t tickstart = rtc_startup_tick ;
368374 while (__HAL_RCC_GET_FLAG (RCC_FLAG_LSIRDY ) == RESET ) {
369- if ((HAL_GetTick () - tickstart ) > PYB_LSI_TIMEOUT_VALUE ) {
375+ if ((HAL_GetTick () - tickstart ) > MICROPY_HW_RTC_LSI_TIMEOUT_MS ) {
370376 return HAL_TIMEOUT ;
371377 }
372378 }
0 commit comments