Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions embassy-rp/src/pio/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1105,10 +1105,17 @@ impl<'d, PIO: Instance> Common<'d, PIO> {
// PIO does support that. with only 32 instruction slots it
// doesn't make much sense to do anything more fancy.
let mut origin = 0;
while origin < 32 {
loop {
match self.try_load_program_at(prog, origin as _) {
Ok(r) => return Ok(r),
Err(a) => origin = a + 1,
Err(addr_in_use) => {
if addr_in_use < origin {
// wrapped around, theres no more space
break;
}

origin = addr_in_use + 1;
}
}
}
Err(LoadError::InsufficientSpace)
Expand Down
9 changes: 9 additions & 0 deletions tests/rp/src/bin/pio_multi_load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@ async fn main(_spawner: Spawner) {
};
}

// program won't fit
{
let prg = pio_asm!("nop", "nop", "nop", "nop", "nop", "nop", "nop", "nop", "nop");
match common.try_load_program(&prg.program) {
Err(LoadError::InsufficientSpace) => (),
_ => panic!("program loaded when it shouldn't"),
};
}

info!("Test OK");
cortex_m::asm::bkpt();
}