Skip to content

Commit abf4a11

Browse files
authored
Change a couple of hardcoded numbers to PIO_INSTRUCTION_COUNT
for clarity
1 parent a1e9cf0 commit abf4a11

File tree

1 file changed

+2
-2
lines changed
  • src/rp2_common/hardware_pio

1 file changed

+2
-2
lines changed

src/rp2_common/hardware_pio/pio.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ static int find_offset_for_program(PIO pio, const pio_program_t *program) {
6868
uint32_t used_mask = _used_instruction_space[pio_get_index(pio)];
6969
uint32_t program_mask = (1u << program->length) - 1;
7070
if (program->origin >= 0) {
71-
if (program->origin > 32 - program->length) return PICO_ERROR_GENERIC;
71+
if (program->origin > PIO_INSTRUCTION_COUNT - program->length) return PICO_ERROR_GENERIC;
7272
return used_mask & (program_mask << program->origin) ? -1 : program->origin;
7373
} else {
7474
// work down from the top always
75-
for (int i = 32 - program->length; i >= 0; i--) {
75+
for (int i = PIO_INSTRUCTION_COUNT - program->length; i >= 0; i--) {
7676
if (!(used_mask & (program_mask << (uint) i))) {
7777
return i;
7878
}

0 commit comments

Comments
 (0)