30
30
*
31
31
* NOTE: This dependents on real hardware.
32
32
*/
33
- #define NU_RTCCLK_PER_SEC ((CLK->CLKSEL3 & CLK_CLKSEL3_SC0SEL_Msk) ? __LIRC : __LXT)
33
+ #define NU_RTCCLK_PER_SEC __LXT
34
34
35
35
/* Strategy for implementation of RTC HAL
36
36
*
@@ -84,7 +84,7 @@ static time_t t_write = 0;
84
84
/* Convert date time from H/W RTC to struct TM */
85
85
static void rtc_convert_datetime_hwrtc_to_tm (struct tm * datetime_tm , const S_RTC_TIME_DATA_T * datetime_hwrtc );
86
86
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 };
88
88
89
89
void rtc_init (void )
90
90
{
@@ -105,11 +105,10 @@ void rtc_free(void)
105
105
106
106
int rtc_isenabled (void )
107
107
{
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 );
113
112
114
113
// NOTE: Check RTC Init Active flag to support crossing reset cycle.
115
114
return !! (RTC -> INIT & RTC_INIT_ACTIVE_Msk );
0 commit comments