3030 *
3131 * NOTE: This dependents on real hardware.
3232 */
33- #define NU_RTCCLK_PER_SEC ((CLK->CLKSEL3 & CLK_CLKSEL3_SC0SEL_Msk) ? __LIRC : __LXT)
33+ #define NU_RTCCLK_PER_SEC __LXT
3434
3535/* Strategy for implementation of RTC HAL
3636 *
@@ -84,7 +84,7 @@ static time_t t_write = 0;
8484/* Convert date time from H/W RTC to struct TM */
8585static void rtc_convert_datetime_hwrtc_to_tm (struct tm * datetime_tm , const S_RTC_TIME_DATA_T * datetime_hwrtc );
8686
87- static const struct nu_modinit_s rtc_modinit = {RTC_0 , RTC_MODULE , 0 , 0 , 0 , RTC_IRQn , NULL };
87+ static const struct nu_modinit_s rtc_modinit = {RTC_0 , RTC_MODULE , CLK_CLKSEL3_RTCSEL_LXT , 0 , 0 , RTC_IRQn , NULL };
8888
8989void rtc_init (void )
9090{
@@ -105,11 +105,10 @@ void rtc_free(void)
105105
106106int rtc_isenabled (void )
107107{
108- // NOTE: To access (RTC) registers, clock must be enabled first.
109- if (! (CLK -> APBCLK0 & CLK_APBCLK0_RTCCKEN_Msk )) {
110- // Enable IP clock
111- CLK_EnableModuleClock (rtc_modinit .clkidx );
112- }
108+ // To access (RTC) registers, clock must be enabled first.
109+ // For TZ, with RTC being secure, we needn't call the secure gateway versions.
110+ CLK_EnableModuleClock (rtc_modinit .clkidx );
111+ CLK_SetModuleClock (rtc_modinit .clkidx , rtc_modinit .clksrc , rtc_modinit .clkdiv );
113112
114113 // NOTE: Check RTC Init Active flag to support crossing reset cycle.
115114 return !! (RTC -> INIT & RTC_INIT_ACTIVE_Msk );
0 commit comments