rp2/rp2_pio: Fix StateMachine.restart when PIO program is shared.

The state machines were not properly restarted in the case that the same
PIO program was shared among multiple StateMachine instances.  This is
because only the first StateMachine to use the program would set the
rp2_state_machine_initial_pc variable.

See https://forum.micropython.org/viewtopic.php?f=21&t=12776&p=69464#p69464
This commit is contained in:
robert-hh 2022-07-24 09:15:38 +02:00 committed by Damien George
parent f64862a766
commit 0c45a28d24

View File

@ -469,8 +469,8 @@ STATIC mp_obj_t rp2_state_machine_init_helper(const rp2_state_machine_obj_t *sel
if (offset < 0) {
rp2_pio_add_program(&rp2_pio_obj[PIO_NUM(self->pio)], args[ARG_prog].u_obj);
offset = mp_obj_get_int(prog[PROG_OFFSET_PIO0 + PIO_NUM(self->pio)]);
rp2_state_machine_initial_pc[self->id] = offset;
}
rp2_state_machine_initial_pc[self->id] = offset;
// Compute the clock divider.
uint16_t clkdiv_int;