@@ -51,13 +51,6 @@ static int8_t _sm_dma_plus_one_read[NUM_PIOS][NUM_PIO_STATE_MACHINES];
51
51
#define SM_DMA_CLEAR_CHANNEL_READ (pio_index , sm ) (_sm_dma_plus_one_read[(pio_index)][(sm)] = 0)
52
52
#define SM_DMA_SET_CHANNEL_READ (pio_index , sm , channel ) (_sm_dma_plus_one_read[(pio_index)][(sm)] = (channel) + 1)
53
53
54
- static PIO pio_instances [NUM_PIOS ] = {
55
- pio0 ,
56
- pio1
57
- #if NUM_PIOS == 3
58
- , pio2
59
- #endif
60
- };
61
54
typedef void (* interrupt_handler_type )(void * );
62
55
static interrupt_handler_type _interrupt_handler [NUM_PIOS ][NUM_PIO_STATE_MACHINES ];
63
56
static void * _interrupt_arg [NUM_PIOS ][NUM_PIO_STATE_MACHINES ];
@@ -162,7 +155,7 @@ static void _reset_statemachine(PIO pio, uint8_t sm, bool leave_pins) {
162
155
163
156
void reset_rp2pio_statemachine (void ) {
164
157
for (size_t i = 0 ; i < NUM_PIOS ; i ++ ) {
165
- PIO pio = pio_instances [ i ] ;
158
+ PIO pio = pio_get_instance ( i ) ;
166
159
for (size_t j = 0 ; j < NUM_PIO_STATE_MACHINES ; j ++ ) {
167
160
if (_never_reset [i ][j ]) {
168
161
continue ;
@@ -252,7 +245,7 @@ static bool use_existing_program(PIO *pio_out, uint *sm_out, int *offset_inout,
252
245
}
253
246
254
247
for (size_t i = 0 ; i < NUM_PIOS ; i ++ ) {
255
- PIO pio = pio_instances [ i ] ;
248
+ PIO pio = pio_get_instance ( i ) ;
256
249
if (!is_gpio_compatible (pio , required_gpio_ranges )) {
257
250
continue ;
258
251
}
@@ -1097,7 +1090,7 @@ void common_hal_rp2pio_statemachine_set_interrupt_handler(rp2pio_statemachine_ob
1097
1090
1098
1091
static void rp2pio_statemachine_interrupt_handler (void ) {
1099
1092
for (size_t pio_index = 0 ; pio_index < NUM_PIOS ; pio_index ++ ) {
1100
- PIO pio = pio_instances [ pio_index ] ;
1093
+ PIO pio = pio_get_instance ( pio_index ) ;
1101
1094
for (size_t sm = 0 ; sm < NUM_PIO_STATE_MACHINES ; sm ++ ) {
1102
1095
if (!_interrupt_handler [pio_index ][sm ]) {
1103
1096
continue ;
@@ -1452,7 +1445,7 @@ int common_hal_rp2pio_statemachine_get_offset(rp2pio_statemachine_obj_t *self) {
1452
1445
1453
1446
int common_hal_rp2pio_statemachine_get_pc (rp2pio_statemachine_obj_t * self ) {
1454
1447
uint8_t pio_index = pio_get_index (self -> pio );
1455
- PIO pio = pio_instances [ pio_index ] ;
1448
+ PIO pio = pio_get_instance ( pio_index ) ;
1456
1449
uint8_t sm = self -> state_machine ;
1457
1450
return pio_sm_get_pc (pio , sm );
1458
1451
}
0 commit comments