Skip to content

Commit ac33c3f

Browse files
authored
Implementation of continuous synchronization of RTC during pulsein
Flags and code to implement continuous synchronization of RTC during pulsein
1 parent 94d9074 commit ac33c3f

File tree

1 file changed

+22
-0
lines changed
  • ports/atmel-samd/supervisor

1 file changed

+22
-0
lines changed

ports/atmel-samd/supervisor/port.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,23 @@
9191
#if CIRCUITPY_PEW
9292
#include "common-hal/_pew/PewPew.h"
9393
#endif
94+
#ifdef SAMD21
95+
volatile bool hold_interrupt = false;
96+
97+
void rtc_start_pulsein(void) {
98+
rtc_set_continuous();
99+
hold_interrupt = true;
100+
}
101+
void rtc_end_pulsein(void) {
102+
hold_interrupt = false;
103+
}
104+
105+
void rtc_set_continuous(void) {
106+
while (RTC->MODE0.STATUS.bit.SYNCBUSY);
107+
RTC->MODE0.READREQ.reg = RTC_READREQ_RREQ | RTC_READREQ_RCONT | 0x0010;
108+
while (RTC->MODE0.STATUS.bit.SYNCBUSY);
109+
}
110+
#endif
94111

95112
extern volatile bool mp_msc_enabled;
96113

@@ -489,6 +506,11 @@ void port_interrupt_after_ticks(uint32_t ticks) {
489506
// We'll interrupt sooner with an overflow.
490507
return;
491508
}
509+
#ifdef SAMD21
510+
if (hold_interrupt == true) {
511+
return;
512+
}
513+
#endif
492514
RTC->MODE0.COMP[0].reg = current_ticks + (ticks << 4);
493515
RTC->MODE0.INTFLAG.reg = RTC_MODE0_INTFLAG_CMP0;
494516
RTC->MODE0.INTENSET.reg = RTC_MODE0_INTENSET_CMP0;

0 commit comments

Comments
 (0)