@@ -51,13 +51,6 @@ static int8_t _sm_dma_plus_one_read[NUM_PIOS][NUM_PIO_STATE_MACHINES];
5151#define SM_DMA_CLEAR_CHANNEL_READ (pio_index , sm ) (_sm_dma_plus_one_read[(pio_index)][(sm)] = 0)
5252#define SM_DMA_SET_CHANNEL_READ (pio_index , sm , channel ) (_sm_dma_plus_one_read[(pio_index)][(sm)] = (channel) + 1)
5353
54- static PIO pio_instances [NUM_PIOS ] = {
55- pio0 ,
56- pio1
57- #if NUM_PIOS == 3
58- , pio2
59- #endif
60- };
6154typedef void (* interrupt_handler_type )(void * );
6255static interrupt_handler_type _interrupt_handler [NUM_PIOS ][NUM_PIO_STATE_MACHINES ];
6356static 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) {
162155
163156void reset_rp2pio_statemachine (void ) {
164157 for (size_t i = 0 ; i < NUM_PIOS ; i ++ ) {
165- PIO pio = pio_instances [ i ] ;
158+ PIO pio = pio_get_instance ( i ) ;
166159 for (size_t j = 0 ; j < NUM_PIO_STATE_MACHINES ; j ++ ) {
167160 if (_never_reset [i ][j ]) {
168161 continue ;
@@ -252,7 +245,7 @@ static bool use_existing_program(PIO *pio_out, uint *sm_out, int *offset_inout,
252245 }
253246
254247 for (size_t i = 0 ; i < NUM_PIOS ; i ++ ) {
255- PIO pio = pio_instances [ i ] ;
248+ PIO pio = pio_get_instance ( i ) ;
256249 if (!is_gpio_compatible (pio , required_gpio_ranges )) {
257250 continue ;
258251 }
@@ -1097,7 +1090,7 @@ void common_hal_rp2pio_statemachine_set_interrupt_handler(rp2pio_statemachine_ob
10971090
10981091static void rp2pio_statemachine_interrupt_handler (void ) {
10991092 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 ) ;
11011094 for (size_t sm = 0 ; sm < NUM_PIO_STATE_MACHINES ; sm ++ ) {
11021095 if (!_interrupt_handler [pio_index ][sm ]) {
11031096 continue ;
@@ -1452,7 +1445,7 @@ int common_hal_rp2pio_statemachine_get_offset(rp2pio_statemachine_obj_t *self) {
14521445
14531446int common_hal_rp2pio_statemachine_get_pc (rp2pio_statemachine_obj_t * self ) {
14541447 uint8_t pio_index = pio_get_index (self -> pio );
1455- PIO pio = pio_instances [ pio_index ] ;
1448+ PIO pio = pio_get_instance ( pio_index ) ;
14561449 uint8_t sm = self -> state_machine ;
14571450 return pio_sm_get_pc (pio , sm );
14581451}
0 commit comments