Skip to content

Commit 5c9823d

Browse files
committed
Change order of operations in restart
1 parent 490f263 commit 5c9823d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ports/raspberrypi/common-hal/rp2pio/StateMachine.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,12 +497,12 @@ void common_hal_rp2pio_statemachine_construct(rp2pio_statemachine_obj_t *self,
497497
}
498498

499499
void common_hal_rp2pio_statemachine_restart(rp2pio_statemachine_obj_t *self) {
500-
pio_sm_restart(self->pio, self->state_machine);
500+
common_hal_rp2pio_statemachine_stop(self);
501501
// Reset program counter to the original offset. A JMP is 0x0000 plus
502502
// the desired offset, so we can just use self->offset.
503503
pio_sm_exec(self->pio, self->state_machine,self->offset);
504+
pio_sm_restart(self->pio, self->state_machine);
504505
uint8_t pio_index = pio_get_index(self->pio);
505-
common_hal_rp2pio_statemachine_stop(self);
506506
uint32_t pins_we_use = _current_sm_pins[pio_index][self->state_machine];
507507
pio_sm_set_pins_with_mask(self->pio, self->state_machine, self->initial_pin_state, pins_we_use);
508508
pio_sm_set_pindirs_with_mask(self->pio, self->state_machine, self->initial_pin_direction, pins_we_use);

0 commit comments

Comments
 (0)