pico-sdk icon indicating copy to clipboard operation
pico-sdk copied to clipboard

pio helper functions

Open peterharperuk opened this issue 1 year ago • 4 comments

It would be nice to add a pio_init function that picks a free pio, state machine and loads a program, as I keep writing this and it's easy to get wrong.

bool pio_init(const pio_program_t *program, PIO *pio_hw, uint *sm, uint *offset); static void pio_deinit(const pio_program_t *program, PIO pio_hw, uint sm, uint offset);

and while we're at it, pio_get_instance like static inline i2c_inst_t *i2c_get_instance(uint instance)

peterharperuk avatar Jan 26 '24 18:01 peterharperuk

don't like the name pio_init since it doesnt initialize a PIO

kilograham avatar Jan 26 '24 19:01 kilograham

pio_load?

peterharperuk avatar Jan 26 '24 19:01 peterharperuk

pio_load_where_space_available or pio_load_if_possible ? :wink:

and while we're at it, pio_get_instance like static inline i2c_inst_t *i2c_get_instance(uint instance)

Unfortunately that function doesn't have any doxygen-comments, and thus doesn't appear in the API documentation.

EDIT: And there's also a (similarly un-documented) uart_get_instance function, but SPI is also lacking a _get_instance function. (And on a sidenote, it's also slightly inconsistent that I2C uses i2c_hw_index, whereas the other hardware-wrappers have pio_get_index, spi_get_index and uart_get_index functions.)

lurch avatar Jan 27 '24 00:01 lurch

some more ideas...

pio_claim_free_sm_add_program pio_unclaim_sm_remove_program

peterharperuk avatar Jan 29 '24 11:01 peterharperuk