Skip to content

Comments

Change a couple of hardcoded numbers to PIO_INSTRUCTION_COUNT for clarity#2832

Open
lurch wants to merge 2 commits intodevelopfrom
lurch-patch-2
Open

Change a couple of hardcoded numbers to PIO_INSTRUCTION_COUNT for clarity#2832
lurch wants to merge 2 commits intodevelopfrom
lurch-patch-2

Conversation

@lurch
Copy link
Contributor

@lurch lurch commented Feb 14, 2026

32 is:

  • number of words in a PIO's instruction memory
  • number of GPIO pins that can be addressed by a PIO block
  • number of bits that get shifted in or out by a PULL or PUSH instruction

so this PR clarifies "which 32" is being used here 😉 (Which IMHO also tallies nicely with the assert(program->length <= PIO_INSTRUCTION_COUNT); on line 67)

I was also tempted to change

if (program->origin > PIO_INSTRUCTION_COUNT - program->length) return PICO_ERROR_GENERIC;

to

if (program->origin > PIO_INSTRUCTION_COUNT - program->length) return PICO_ERROR_BAD_ALIGNMENT;

to match up with the error being returned here from add_program_at_offset_check, but I refrained from doing so in case that would be considered a backwards-incompatible change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants