diff options
| author | DavePutz <dwputz@gmail.com> | 2020-07-04 21:17:19 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-04 21:17:19 -0500 |
| commit | ac33c3fe2c8f8bd866b205ecb844b2f1b9fffcdd (patch) | |
| tree | c9325a9d96e37745133d4b5b346299492e96812a | |
| parent | 94d90742dd02a7d4350a5f712baa81a3ee105fa9 (diff) | |
Implementation of continuous synchronization of RTC during pulsein
Flags and code to implement continuous synchronization of RTC during pulsein
| -rw-r--r-- | ports/atmel-samd/supervisor/port.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/ports/atmel-samd/supervisor/port.c b/ports/atmel-samd/supervisor/port.c index 48bd3211b..05ce0eb09 100644 --- a/ports/atmel-samd/supervisor/port.c +++ b/ports/atmel-samd/supervisor/port.c @@ -91,6 +91,23 @@ #if CIRCUITPY_PEW #include "common-hal/_pew/PewPew.h" #endif +#ifdef SAMD21 +volatile bool hold_interrupt = false; + +void rtc_start_pulsein(void) { + rtc_set_continuous(); + hold_interrupt = true; +} +void rtc_end_pulsein(void) { + hold_interrupt = false; +} + +void rtc_set_continuous(void) { + while (RTC->MODE0.STATUS.bit.SYNCBUSY); + RTC->MODE0.READREQ.reg = RTC_READREQ_RREQ | RTC_READREQ_RCONT | 0x0010; + while (RTC->MODE0.STATUS.bit.SYNCBUSY); +} +#endif extern volatile bool mp_msc_enabled; @@ -489,6 +506,11 @@ void port_interrupt_after_ticks(uint32_t ticks) { // We'll interrupt sooner with an overflow. return; } +#ifdef SAMD21 + if (hold_interrupt == true) { + return; + } +#endif RTC->MODE0.COMP[0].reg = current_ticks + (ticks << 4); RTC->MODE0.INTFLAG.reg = RTC_MODE0_INTFLAG_CMP0; RTC->MODE0.INTENSET.reg = RTC_MODE0_INTENSET_CMP0; |
