From ebe2926cd610661e210b70be1a22bac13923f4fb Mon Sep 17 00:00:00 2001 From: WwWangGuan Date: Wed, 13 Nov 2024 22:58:27 +0800 Subject: [PATCH] [bsp][gd32][fix rtc clock selection] --- bsp/gd32/arm/libraries/gd32_drivers/drv_rtc.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bsp/gd32/arm/libraries/gd32_drivers/drv_rtc.c b/bsp/gd32/arm/libraries/gd32_drivers/drv_rtc.c index 4ed2a31f38..0b32389d31 100644 --- a/bsp/gd32/arm/libraries/gd32_drivers/drv_rtc.c +++ b/bsp/gd32/arm/libraries/gd32_drivers/drv_rtc.c @@ -102,12 +102,21 @@ static int rt_hw_rtc_init(void) rcu_bkp_reset_enable(); rcu_bkp_reset_disable(); rcu_periph_clock_enable(RCU_RTC); +#ifdef BSP_RTC_USING_LSE rcu_osci_on(RCU_LXTAL); if (SUCCESS == rcu_osci_stab_wait(RCU_LXTAL)) { /* set lxtal as rtc clock source */ rcu_rtc_clock_config(RCU_RTCSRC_LXTAL); } +#elifdef BSP_RTC_USING_LSI + rcu_osci_on(RCU_IRC40K); + if (SUCCESS == rcu_osci_stab_wait(RCU_IRC40K)) + { + /* set IRC40K as rtc clock source */ + rcu_rtc_clock_config(RCU_RTCSRC_IRC40K); + } +#endif set_rtc_timestamp(rtc_counter); #ifdef RT_USING_DEVICE_OPS