8000 rp2pio: fix occasional bug when not using OUT pins · pepijndevos/circuitpython@a3e1718 · GitHub
[go: up one dir, main page]

Skip to content

Commit a3e1718

Browse files
committed
rp2pio: fix occasional bug when not using OUT pins
a NULL first pin object is used to indicate that there are zero of some kind of pin associated with the StateMachine. However, mask_and_rotate wasn't checking for zero. It actually read data from near address 0x0 and (in my case) got a nonzero mask, which then caused a program with GPIO11 and GPIO12 as input with pull-up and no out pins to erroneously encounter the error "pull masks conflict with direction masks"
1 parent aa5f892 commit a3e1718

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,9 @@ bool rp2pio_statemachine_construct(rp2pio_statemachine_obj_t *self,
369369
}
370370

371371
static uint32_t mask_and_rotate(const mcu_pin_obj_t *first_pin, uint32_t bit_count, uint32_t value) {
372+
if (!first_pin) {
373+
return 0;
374+
}
372375
value = value & ((1 << bit_count) - 1);
373376
uint32_t shift = first_pin->number;
374377
return value << shift | value >> (32 - shift);

0 commit comments

Comments
 (0)
0