Skip to content

Commit 94d9074

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

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

ports/atmel-samd/common-hal/pulseio/PulseIn.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ void pulsein_interrupt_handler(uint8_t channel) {
125125
}
126126

127127
void pulsein_reset() {
128+
#ifdef SAMD21
129+
rtc_end_pulsein();
130+
#endif
128131
refcount = 0;
129132
pulsein_tc_index = 0xff;
130133
overflow_count = 0;
@@ -221,6 +224,10 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t* self,
221224

222225
// Set config will enable the EIC.
223226
pulsein_set_config(self, true);
227+
#ifdef SAMD21
228+
rtc_start_pulsein();
229+
#endif
230+
224231
}
225232

226233
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) {
231238
if (common_hal_pulseio_pulsein_deinited(self)) {
232239
return;
233240
}
241+
#ifdef SAMD21
242+
rtc_end_pulsein();
243+
#endif
234244
set_eic_handler(self->channel, EIC_HANDLER_NO_INTERRUPT);
235245
turn_off_eic_channel(self->channel);
236246
reset_pin_number(self->pin);

ports/atmel-samd/common-hal/pulseio/PulseIn.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,11 @@ void pulsein_reset(void);
5050

5151
void pulsein_interrupt_handler(uint8_t channel);
5252
void pulsein_timer_interrupt_handler(uint8_t index);
53+
#ifdef SAMD21
54+
void rtc_set_continuous(void);
55+
void rtc_start_pulsein(void);
56+
void rtc_end_pulsein(void);
57+
#endif
58+
5359

5460
#endif // MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_PULSEIO_PULSEIN_H

0 commit comments

Comments
 (0)