@@ -57,6 +57,19 @@ static void *_interrupt_arg[NUM_PIOS][NUM_PIO_STATE_MACHINES];
57
57
58
58
static void rp2pio_statemachine_interrupt_handler (void );
59
59
60
+ // Workaround for sdk bug: https://github.com/raspberrypi/pico-sdk/issues/1878
61
+ // This workaround can be removed when we upgrade to sdk 2.0.1
62
+ static inline void sm_config_set_in_pin_count_issue1878 (pio_sm_config * c , uint in_count ) {
63
+ #if PICO_PIO_VERSION == 0
64
+ // can't be changed from 32 on PIO v0
65
+ ((void )c );
66
+ valid_params_if (HARDWARE_PIO , in_count == 32 );
67
+ #else
68
+ valid_params_if (HARDWARE_PIO , in_count && in_count <= 32 );
69
+ c -> shiftctrl = (c -> shiftctrl & ~PIO_SM0_SHIFTCTRL_IN_COUNT_BITS ) |
70
+ ((in_count & 0x1fu ) << PIO_SM0_SHIFTCTRL_IN_COUNT_LSB );
71
+ #endif
72
+ }
60
73
static void rp2pio_statemachine_set_pull (uint32_t pull_pin_up , uint32_t pull_pin_down , uint32_t pins_we_use ) {
61
74
for (size_t i = 0 ; i < NUM_BANK0_GPIOS ; i ++ ) {
62
75
bool used = pins_we_use & (1 << i );
@@ -374,7 +387,7 @@ bool rp2pio_statemachine_construct(rp2pio_statemachine_obj_t *self,
374
387
sm_config_set_wrap (& c , wrap_target , wrap );
375
388
sm_config_set_in_shift (& c , in_shift_right , auto_push , push_threshold );
376
389
#if PICO_PIO_VERSION > 0
377
- sm_config_set_in_pin_count (& c , in_pin_count );
390
+ sm_config_set_in_pin_count_issue1878 (& c , in_pin_count );
378
391
#endif
379
392
380
393
sm_config_set_out_shift (& c , out_shift_right , auto_pull , pull_threshold );
0 commit comments