8000 nrf5/modules/rtc: Adding support for stopping and restarting rtc (if … · boneskull/circuitpython@5acba01 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5acba01

Browse files
committed
nrf5/modules/rtc: Adding support for stopping and restarting rtc (if periodic) for all the instances of RTC.
1 parent 7c50cd2 commit 5acba01

File tree

1 file changed

+11
-8
lines changed
  • nrf5/modules/machine

1 file changed

+11
-8
lines changed

nrf5/modules/machine/rtc.c

Lines changed: 11 additions & 8 deletions
< 8000 td data-grid-cell-id="diff-ad0b1e5c2d341b3f9a575f092c442b364d48a7b62ce16e1bd990b939b5a46d80-69-64-0" data-selected="false" role="gridcell" style="background-color:var(--diffBlob-deletionNum-bgColor, var(--diffBlob-deletion-bgColor-num));text-align:center" tabindex="-1" valign="top" class="focusable-grid-cell diff-line-number position-relative left-side">69
Original file line numberDiff line numberDiff line change
@@ -52,24 +52,27 @@ STATIC machine_rtc_obj_t machine_rtc_obj[] = {
5252
};
5353

5454
STATIC void hal_interrupt_handle(NRF_RTC_Type * p_instance) {
55+
const machine_rtc_obj_t * self = NULL;
5556
if (p_instance == RTC0) {
56-
const machine_rtc_obj_t *self = &machine_rtc_obj[0];
57+
self = &machine_rtc_obj[0];
5758
mp_call_function_0(self->callback);
58-
59-
hal_rtc_stop(&self->rtc->config);
60-
if (self->mode == 1) {
61-
hal_rtc_start(&self->rtc->config, self->period);
62-
}
6359
} else if (p_instance == RTC1) {
64-
const machine_rtc_obj_t *self = &machine_rtc_obj[1];
60+
self = &machine_rtc_obj[1];
6561
mp_call_function_0(self->callback);
6662
}
6763
#if NRF52
6864
else if (p_instance == RTC2) {
-
const machine_rtc_obj_t *self = &machine_rtc_obj[2];
65+
self = &machine_rtc_obj[2];
7066
mp_call_function_0(self->callback);
7167
}
7268
#endif
69+
70+
if (self != NULL) {
71+
hal_rtc_stop(&self->rtc->config);
72+
if (self->mode == 1) {
73+
hal_rtc_start(&self->rtc->config, self->period);
74+
}
75+
}
7376
}
7477

7578
void rtc_init0(void) {

0 commit comments

Comments
 (0)
0