Skip to content

Commit

Permalink
piolib: Add abstractions for PIO hardware sizes
Browse files Browse the repository at this point in the history
Add methods to return the PIO hardware dimensions, and declare the RP1
PIO FIFO size. Also accept the pio_version field in programs.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
  • Loading branch information
pelwell committed Nov 21, 2024
1 parent 7082298 commit 775224a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions piolib/include/piolib.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ typedef struct pio_program {
const uint16_t *instructions;
uint8_t length;
int8_t origin; // required instruction memory origin or -1
uint8_t pio_version;
} pio_program_t;

typedef struct {
Expand All @@ -106,6 +107,7 @@ struct pio_chip {
const char *compatible;
uint16_t instr_count;
uint16_t sm_count;
uint16_t fifo_depth;
void *hw_state;

PIO (*create_instance)(PIO_CHIP_T *chip, uint index);
Expand Down Expand Up @@ -247,6 +249,21 @@ static inline void pio_enable_fatal_errors(PIO pio, bool enable)
pio->errors_are_fatal = enable;
}

static inline uint pio_get_sm_count(PIO pio)
{
return pio->chip->sm_count;
}

static inline uint pio_get_instruction_count(PIO pio)
{
return pio->chip->instr_count;
}

static inline uint pio_get_fifo_depth(PIO pio)
{
return pio->chip->fifo_depth;
}

static inline void check_pio_param(__unused PIO pio)
{
valid_params_if(PIO, pio_get_index(pio) >= 0);
Expand Down
1 change: 1 addition & 0 deletions piolib/pio_rp1.c
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,7 @@ static const PIO_CHIP_T rp1_pio_chip = {
.compatible = "raspberrypi,rp1-pio",
.instr_count = RP1_PIO_INSTRUCTION_COUNT,
.sm_count = RP1_PIO_SM_COUNT,
.fifo_depth = 8,

.create_instance = rp1_create_instance,
.open_instance = rp1_open_instance,
Expand Down

0 comments on commit 775224a

Please sign in to comment.