summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavePutz <dwputz@gmail.com>2020-07-04 21:15:38 -0500
committerGitHub <noreply@github.com>2020-07-04 21:15:38 -0500
commit94d90742dd02a7d4350a5f712baa81a3ee105fa9 (patch)
treec46f28ca53458dff06aca5cd13976a46ff4a284e
parent22d67b45f0dffe7c10718a05d3065cc211f811ee (diff)
Implementation of RTC continuous synchronization during pulsein
Flags and code to implement RTC continuous synchronization during pulsein
-rw-r--r--ports/atmel-samd/common-hal/pulseio/PulseIn.c10
-rw-r--r--ports/atmel-samd/common-hal/pulseio/PulseIn.h6
2 files changed, 16 insertions, 0 deletions
diff --git a/ports/atmel-samd/common-hal/pulseio/PulseIn.c b/ports/atmel-samd/common-hal/pulseio/PulseIn.c
index 7ea20321b..b825579db 100644
--- a/ports/atmel-samd/common-hal/pulseio/PulseIn.c
+++ b/ports/atmel-samd/common-hal/pulseio/PulseIn.c
@@ -125,6 +125,9 @@ void pulsein_interrupt_handler(uint8_t channel) {
}
void pulsein_reset() {
+#ifdef SAMD21
+ rtc_end_pulsein();
+#endif
refcount = 0;
pulsein_tc_index = 0xff;
overflow_count = 0;
@@ -221,6 +224,10 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t* self,
// Set config will enable the EIC.
pulsein_set_config(self, true);
+#ifdef SAMD21
+ rtc_start_pulsein();
+#endif
+
}
bool common_hal_pulseio_pulsein_deinited(pulseio_pulsein_obj_t* self) {
@@ -231,6 +238,9 @@ void common_hal_pulseio_pulsein_deinit(pulseio_pulsein_obj_t* self) {
if (common_hal_pulseio_pulsein_deinited(self)) {
return;
}
+#ifdef SAMD21
+ rtc_end_pulsein();
+#endif
set_eic_handler(self->channel, EIC_HANDLER_NO_INTERRUPT);
turn_off_eic_channel(self->channel);
reset_pin_number(self->pin);
diff --git a/ports/atmel-samd/common-hal/pulseio/PulseIn.h b/ports/atmel-samd/common-hal/pulseio/PulseIn.h
index 89b61a83a..99358178f 100644
--- a/ports/atmel-samd/common-hal/pulseio/PulseIn.h
+++ b/ports/atmel-samd/common-hal/pulseio/PulseIn.h
@@ -50,5 +50,11 @@ void pulsein_reset(void);
void pulsein_interrupt_handler(uint8_t channel);
void pulsein_timer_interrupt_handler(uint8_t index);
+#ifdef SAMD21
+void rtc_set_continuous(void);
+void rtc_start_pulsein(void);
+void rtc_end_pulsein(void);
+#endif
+
#endif // MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_PULSEIO_PULSEIN_H