@@ -79,7 +79,7 @@ void fRtcInit(void)
79
79
NVIC_ClearPendingIRQ (Rtc_IRQn );
80
80
NVIC_EnableIRQ (Rtc_IRQn );
81
81
82
- while (RTCREG -> STATUS .BITS .BSY_ANY_WRT == True ); /* Wait for RTC to finish writing register - RTC operates on 32K clock as compared to 32M core*/
82
+ while (RTCREG -> STATUS .BITS .BSY_CTRL_REG_WRT == True ); /* Wait for RTC to finish writing register - RTC operates on 32K clock as compared to 32M core*/
83
83
84
84
return ;
85
85
}
@@ -93,14 +93,14 @@ void fRtcFree(void)
93
93
/* disable interruption associated with the rtc */
94
94
NVIC_DisableIRQ (Rtc_IRQn );
95
95
96
- while (RTCREG -> STATUS .BITS .BSY_ANY_WRT == True ); /* Wait for RTC to finish writing register - RTC operates on 32K clock as compared to 32M core*/
96
+ while (RTCREG -> STATUS .BITS .BSY_CTRL_REG_WRT == True ); /* Wait for RTC to finish writing register - RTC operates on 32K clock as compared to 32M core*/
97
97
}
98
98
99
99
/* See rtc.h for details */
100
100
void fRtcSetInterrupt (uint32_t timestamp )
101
101
{
102
- SubSecond = False ;
103
- uint32_t Second = False ;
102
+ SubSecond = False ;
103
+ uint32_t Second = False ;
104
104
uint8_t DividerAdjust = 1 ;
105
105
106
106
if (timestamp ) {
@@ -137,6 +137,7 @@ void fRtcSetInterrupt(uint32_t timestamp)
137
137
RTCREG -> SUB_SECOND_ALARM = SubSecond ; /* Write to sub second alarm */
138
138
139
139
/* Enable sub second interrupt */
140
+ while (RTCREG -> STATUS .BITS .BSY_CTRL_REG_WRT == True );
140
141
RTCREG -> CONTROL .WORD |= (True << RTC_CONTROL_SUBSEC_CNT_INT_BIT_POS );
141
142
}
142
143
}
@@ -151,15 +152,15 @@ void fRtcDisableInterrupt(void)
151
152
{
152
153
/* Disable subsec/sec interrupt */
153
154
RTCREG -> CONTROL .WORD &= ~((RTC_ALL_INTERRUPT_BIT_VAL ) << RTC_CONTROL_SUBSEC_CNT_INT_BIT_POS );
154
- while (RTCREG -> STATUS .BITS .BSY_ANY_WRT == True ); /* Wait for RTC to finish writing register - RTC operates on 32K clock as compared to 32M core*/
155
+ while (RTCREG -> STATUS .BITS .BSY_CTRL_REG_WRT == True ); /* Wait for RTC to finish writing register - RTC operates on 32K clock as compared to 32M core*/
155
156
}
156
157
157
158
/* See rtc.h for details */
158
159
void fRtcEnableInterrupt (void )
159
160
{
160
161
/* Disable subsec/sec interrupt */
161
162
RTCREG -> CONTROL .WORD |= ((RTC_ALL_INTERRUPT_BIT_VAL ) << RTC_CONTROL_SUBSEC_CNT_INT_BIT_POS );
162
- while (RTCREG -> STATUS .BITS .BSY_ANY_WRT == True ); /* Wait for RTC to finish writing register - RTC operates on 32K clock as compared to 32M core*/
163
+ while (RTCREG -> STATUS .BITS .BSY_CTRL_REG_WRT == True ); /* Wait for RTC to finish writing register - RTC operates on 32K clock as compared to 32M core*/
163
164
}
164
165
165
166
/* See rtc.h for details */
@@ -237,40 +238,40 @@ void fRtcWrite(uint64_t RtcTimeus)
237
238
/* See rtc.h for details */
238
239
void fRtcHandler (void )
239
240
{
240
- while (RTCREG -> STATUS .BITS .BSY_ANY_WRT == True ); /* Wait for RTC to finish writing register - RTC operates on 32K clock as compared to 32M core*/
241
241
/* SUB_SECOND/SECOND interrupt occured */
242
242
volatile uint32_t TempStatus = RTCREG -> STATUS .WORD ;
243
243
244
- /* disable all interrupts */
245
- RTCREG -> CONTROL . WORD &= ~(( RTC_ALL_INTERRUPT_BIT_VAL ) << RTC_CONTROL_SUBSEC_CNT_INT_BIT_POS );
244
+ /* Disable RTC interrupt */
245
+ NVIC_DisableIRQ ( Rtc_IRQn );
246
246
247
247
/* Clear sec & sub_sec interrupts */
248
248
RTCREG -> INT_CLEAR .WORD = ((True << RTC_INT_CLR_SUB_SEC_BIT_POS ) |
249
249
(True << RTC_INT_CLR_SEC_BIT_POS ));
250
250
251
- /* TODO ANDing SUB_SEC & SEC interrupt - work around for RTC issue - will be solved in REV G */
251
+ /* TODO ANDing SUB_SEC & SEC interrupt - work around for RTC issue - will be resolved in REV G */
252
252
if (TempStatus & RTC_SEC_INT_STATUS_MASK ) {
253
253
/* Second interrupt occured */
254
254
if (SubSecond > False ) {
255
255
/* Set SUB SEC_ALARM */
256
256
RTCREG -> SUB_SECOND_ALARM = SubSecond + RTCREG -> SUB_SECOND_COUNTER ;
257
257
/* Enable sub second interrupt */
258
- while (RTCREG -> STATUS .BITS .BSY_CTRL_REG_WRT == True );
259
258
RTCREG -> CONTROL .WORD |= (True << RTC_CONTROL_SUBSEC_CNT_INT_BIT_POS );
260
259
} else {
261
260
/* We reach here after second interrupt is occured */
262
- while (RTCREG -> STATUS .BITS .BSY_CTRL_REG_WRT == True );
263
261
RTCREG -> CONTROL .WORD &= ~(True << RTC_CONTROL_SUBSEC_CNT_INT_BIT_POS ) |
264
262
(True << RTC_CONTROL_SEC_CNT_INT_BIT_POS );
265
263
}
266
264
} else {
267
265
/* We reach here after sub_second or (Sub second + second) interrupt occured */
268
- while (RTCREG -> STATUS .BITS .BSY_CTRL_REG_WRT == True );
269
266
/* Disable Second and sub_second interrupt */
270
267
RTCREG -> CONTROL .WORD &= ~(True << RTC_CONTROL_SUBSEC_CNT_INT_BIT_POS ) |
271
268
(True << RTC_CONTROL_SEC_CNT_INT_BIT_POS );
272
269
}
273
270
271
+ NVIC_EnableIRQ (Rtc_IRQn );
272
+
273
+ while (RTCREG -> STATUS .BITS .BSY_ANY_WRT == True ); /* Wait for RTC to finish writing register - RTC operates on 32K clock as compared to 32M core*/
274
+
274
275
lp_ticker_irq_handler ();
275
276
}
276
277
0 commit comments