Skip to content

Commit 41987c6

Browse files
committed
rp2/rp2_pio: Configure jmp_pin for PIO use if it's isolation is set.
Signed-off-by: Damien George <[email protected]>
1 parent dea949e commit 41987c6

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

ports/rp2/rp2_pio.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,8 +683,10 @@ static mp_obj_t rp2_state_machine_init_helper(const rp2_state_machine_obj_t *sel
683683
}
684684

685685
// Configure jmp pin, if needed.
686+
int jmp_pin = -1;
686687
if (args[ARG_jmp_pin].u_obj != mp_const_none) {
687-
sm_config_set_jmp_pin(&config, mp_hal_get_pin_obj(args[ARG_jmp_pin].u_obj));
688+
jmp_pin = mp_hal_get_pin_obj(args[ARG_jmp_pin].u_obj);
689+
sm_config_set_jmp_pin(&config, jmp_pin);
688690
}
689691

690692
// Configure sideset pin, if needed.
@@ -716,6 +718,18 @@ static mp_obj_t rp2_state_machine_init_helper(const rp2_state_machine_obj_t *sel
716718
if (set_config.base >= 0) {
717719
asm_pio_init_gpio(self->pio, self->sm, &set_config);
718720
}
721+
#if !PICO_RP2040
722+
if (jmp_pin >= 0) {
723+
// On RP2350 pins by default have their isolation enabled. This means they will
724+
// not work as input to a PIO without further configuration. That's different to
725+
// RP2040 where pins can work as PIO input from a reset. To make RP2350 have
726+
// similar behaviour as RP2040, configure the jmp pin for PIO use if it's isolation
727+
// is enabled (which means it's probably unconfigured from reset).
728+
if (pads_bank0_hw->io[jmp_pin] & PADS_BANK0_GPIO0_ISO_BITS) {
729+
pio_gpio_init(self->pio, jmp_pin);
730+
}
731+
}
732+
#endif
719733
if (sideset_config.base >= 0) {
720734
asm_pio_init_gpio(self->pio, self->sm, &sideset_config);
721735
}

0 commit comments

Comments
 (0)