raspberrypi / pico-sdk

BSD 3-Clause "New" or "Revised" License
3.64k stars 903 forks source link

Get/clear functions for PIO FIFO debug register #450

Open jonathangjertsen opened 3 years ago

jonathangjertsen commented 3 years ago

AFAICT the only way to get at the contents of the PIO FIFO debug register is to access the fdebug field on the PIO struct and do the appropriate bit manipulations. It would be nice with a more convenient helper function.

One possible API is

static inline pio_fifo_debug_flags_t pio_sm_get_debug_flags(PIO pio, uint sm, bool clear) { ... }

where pio_fifo_debug_flags_t is a struct with one bool for each flag, and the clear parameter selects whether or not to clear the flags afterwards.

lurch commented 3 years ago

You might only want to clear one flag (and leave the others set) rather than clearing all flags? Might make sense to have e.g.

static inline pio_fifo_debug_flags_t pio_sm_get_fifo_debug_flags(PIO pio, uint sm) { ... }
static inline void pio_sm_clear_fifo_debug_flags(PIO pio, uint sm, pio_fifo_debug_flags_t clear) { ... }

:man_shrugging: (disclaimer: I've never actually done any PIO debugging!)