Skip to content

Commit c382b55

Browse files
authored
Merge pull request #10627 from dhalbert/pio-wait-pin-check
ports/raspberrypi/rp2pio/StateMachine.c: fix wait pin validation
2 parents 1a6c2b9 + 146c199 commit c382b55

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -523,9 +523,10 @@ static void consider_instruction(introspect_t *state, uint16_t full_instruction,
523523
}
524524
}
525525
if (instruction == pio_instr_bits_wait) {
526-
uint16_t wait_source = (full_instruction & 0x0060) >> 5;
527-
uint16_t wait_index = (full_instruction & 0x001f) + state->inputs.pio_gpio_offset;
528-
if (wait_source == 0 && !PIO_PINMASK_IS_SET(state->inputs.pins_we_use, wait_index)) { // GPIO
526+
const uint16_t wait_source = (full_instruction & 0x0060) >> 5;
527+
const uint16_t wait_index = full_instruction & 0x001f;
528+
const uint16_t wait_pin = wait_index + state->inputs.pio_gpio_offset;
529+
if (wait_source == 0 && !PIO_PINMASK_IS_SET(state->inputs.pins_we_use, wait_pin)) { // GPIO
529530
mp_raise_ValueError_varg(MP_ERROR_TEXT("%q[%u] uses extra pin"), what_program, i);
530531
} else if (wait_source == 1) { // Input pin
531532
if (!state->inputs.has_in_pin) {

0 commit comments

Comments
 (0)