Fix RP2 countio reset

Fixes #5251
This commit is contained in:
Scott Shawcroft 2021-08-27 17:39:19 -07:00
parent dd89ff244d
commit 6e7e703f89
No known key found for this signature in database
GPG Key ID: 0DFD512649C052DA
3 changed files with 17 additions and 1 deletions

View File

@ -1,4 +1,4 @@
#include "common-hal/countio/Counter.h"
#include "shared-bindings/countio/Counter.h"
#include "py/runtime.h"
#include "py/mpstate.h"
@ -48,6 +48,15 @@ void common_hal_countio_counter_construct(countio_counter_obj_t *self,
pwm_set_enabled(self->slice_num, true);
}
void reset_countio(void) {
for (size_t i = 0; i < NUM_PWM_SLICES; i++) {
if (MP_STATE_PORT(counting)[i] != NULL) {
common_hal_countio_counter_deinit(MP_STATE_PORT(counting)[i]);
}
}
}
bool common_hal_countio_counter_deinited(countio_counter_obj_t *self) {
return self->pin_a == 0;
}

View File

@ -16,4 +16,6 @@ typedef struct {
void counter_interrupt_handler();
void reset_countio(void);
#endif // MICROPY_INCLUDED_RASPBERRRYPI_COMMON_HAL_COUNTIO_COUNTER_H

View File

@ -36,6 +36,7 @@
#include "shared-bindings/audiopwmio/PWMAudioOut.h"
#include "shared-bindings/busio/I2C.h"
#include "shared-bindings/busio/SPI.h"
#include "shared-bindings/countio/Counter.h"
#include "shared-bindings/microcontroller/__init__.h"
#include "shared-bindings/rtc/__init__.h"
#include "shared-bindings/pwmio/PWMOut.h"
@ -135,6 +136,10 @@ void reset_port(void) {
reset_uart();
#endif
#if CIRCUITPY_COUNTIO
reset_countio();
#endif
#if CIRCUITPY_PWMIO
pwmout_reset();
#endif