Fix PWMOut on SAMD21

This commit is contained in:
root 2021-04-20 15:21:05 -05:00
parent d5768c5338
commit 0e2431048d
5 changed files with 21 additions and 7 deletions

View File

@ -137,7 +137,7 @@ void pulsein_interrupt_handler(uint8_t channel) {
void pulsein_reset() {
#ifdef SAMD21
rtc_end_pulsein();
rtc_end_pulse();
#endif
refcount = 0;
pulsein_tc_index = 0xff;
@ -236,7 +236,7 @@ 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();
rtc_start_pulse();
#endif
}
@ -250,7 +250,7 @@ void common_hal_pulseio_pulsein_deinit(pulseio_pulsein_obj_t* self) {
return;
}
#ifdef SAMD21
rtc_end_pulsein();
rtc_end_pulse();
#endif
set_eic_handler(self->channel, EIC_HANDLER_NO_INTERRUPT);
turn_off_eic_channel(self->channel);

View File

@ -51,8 +51,8 @@ void pulsein_reset(void);
void pulsein_interrupt_handler(uint8_t channel);
void pulsein_timer_interrupt_handler(uint8_t index);
#ifdef SAMD21
void rtc_start_pulsein(void);
void rtc_end_pulsein(void);
void rtc_start_pulse(void);
void rtc_end_pulse(void);
#endif

View File

@ -93,6 +93,9 @@ void pulseout_reset() {
refcount = 0;
pulseout_tc_index = 0xff;
active_pincfg = NULL;
#ifdef SAMD21
rtc_end_pulse();
#endif
}
void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self,
@ -159,6 +162,10 @@ void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self,
// Turn off the pinmux which should connect the port output.
turn_off(self->pincfg);
#ifdef SAMD21
rtc_start_pulse();
#endif
}
bool common_hal_pulseio_pulseout_deinited(pulseio_pulseout_obj_t* self) {
@ -180,6 +187,9 @@ void common_hal_pulseio_pulseout_deinit(pulseio_pulseout_obj_t* self) {
pulseout_tc_index = 0xff;
}
self->pin = NO_PIN;
#ifdef SAMD21
rtc_end_pulse();
#endif
}
void common_hal_pulseio_pulseout_send(pulseio_pulseout_obj_t* self, uint16_t* pulses, uint16_t length) {

View File

@ -39,5 +39,9 @@ typedef struct {
void pulseout_reset(void);
void pulseout_interrupt_handler(uint8_t index);
#ifdef SAMD21
void rtc_start_pulse(void);
void rtc_end_pulse(void);
#endif
#endif // MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_PULSEIO_PULSEOUT_H

View File

@ -102,12 +102,12 @@ static void rtc_set_continuous(bool continuous) {
while (RTC->MODE0.STATUS.bit.SYNCBUSY);
}
void rtc_start_pulsein(void) {
void rtc_start_pulse(void) {
rtc_set_continuous(true);
hold_interrupt = true;
}
void rtc_end_pulsein(void) {
void rtc_end_pulse(void) {
hold_interrupt = false;
rtc_set_continuous(false);
}