From 0261cacb06a3a0eabe40b850dcea9dbe4a47f03f Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 27 Aug 2021 10:07:14 -0400 Subject: [PATCH] Stop StateMachine explicitly on deinit --- ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c | 2 -- ports/raspberrypi/common-hal/rp2pio/StateMachine.c | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c b/ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c index d5251f6598..06504a66f9 100644 --- a/ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c +++ b/ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c @@ -91,8 +91,6 @@ void common_hal_rotaryio_incrementalencoder_construct(rotaryio_incrementalencode false, // Wait for txstall false, 32, false); // in settings - common_hal_rp2pio_statemachine_run(&self->state_machine, encoder_init, MP_ARRAY_SIZE(encoder_init)); - // We're guaranteed by the init code that some output will be available promptly uint8_t quiescent_state; common_hal_rp2pio_statemachine_readinto(&self->state_machine, &quiescent_state, 1, 1); diff --git a/ports/raspberrypi/common-hal/rp2pio/StateMachine.c b/ports/raspberrypi/common-hal/rp2pio/StateMachine.c index 6594dd9c6f..fcbb7e2bb7 100644 --- a/ports/raspberrypi/common-hal/rp2pio/StateMachine.c +++ b/ports/raspberrypi/common-hal/rp2pio/StateMachine.c @@ -553,6 +553,8 @@ void common_hal_rp2pio_statemachine_set_frequency(rp2pio_statemachine_obj_t *sel } void rp2pio_statemachine_deinit(rp2pio_statemachine_obj_t *self, bool leave_pins) { + common_hal_rp2pio_statemachine_stop(self); + uint8_t sm = self->state_machine; uint8_t pio_index = pio_get_index(self->pio); common_hal_mcu_disable_interrupts();