@@ -628,6 +628,9 @@ void common_hal_rp2pio_statemachine_construct(rp2pio_statemachine_obj_t *self,
628
628
int mov_status_type ,
629
629
int mov_status_n ) {
630
630
631
+ // Ensure object starts in its deinit state.
632
+ common_hal_rp2pio_statemachine_mark_deinit (self );
633
+
631
634
// First, check that all pins are free OR already in use by any PIO if exclusive_pin_use is false.
632
635
pio_pinmask_t pins_we_use = wait_gpio_mask ;
633
636
PIO_PINMASK_MERGE (pins_we_use , _check_pins_free (first_out_pin , out_pin_count , exclusive_pin_use ));
@@ -744,7 +747,7 @@ void common_hal_rp2pio_statemachine_construct(rp2pio_statemachine_obj_t *self,
744
747
mov_status_type , mov_status_n );
745
748
if (!ok ) {
746
749
// indicate state machine never inited
747
- self -> state_machine = NUM_PIO_STATE_MACHINES ;
750
+ common_hal_rp2pio_statemachine_mark_deinit ( self ) ;
748
751
mp_raise_RuntimeError (MP_ERROR_TEXT ("All state machines in use" ));
749
752
}
750
753
}
@@ -827,6 +830,10 @@ void common_hal_rp2pio_statemachine_deinit(rp2pio_statemachine_obj_t *self) {
827
830
rp2pio_statemachine_deinit (self , false);
828
831
}
829
832
833
+ void common_hal_rp2pio_statemachine_mark_deinit (rp2pio_statemachine_obj_t * self ) {
834
+ self -> state_machine = NUM_PIO_STATE_MACHINES ;
835
+ }
836
+
830
837
void common_hal_rp2pio_statemachine_never_reset (rp2pio_statemachine_obj_t * self ) {
831
838
rp2pio_statemachine_never_reset (self -> pio , self -> state_machine );
832
839
// TODO: never reset all the pins
0 commit comments