rp/pio: make free_instr unsafe

we can't prove that some instruction memory is not used as long as state
machines are alive, and we can pass instance memory handles between
instances as well. mark free_instr unsafe, with documentation for this caveat.
This commit is contained in:
pennae 2023-05-02 20:39:19 +02:00
parent 2afa08c923
commit 1e8da91def

View File

@ -827,8 +827,10 @@ impl<'d, PIO: PioInstance> PioCommon<'d, PIO> {
} }
} }
// TODO make instruction memory that is currently in use unfreeable /// Free instruction memory previously allocated with [`PioCommon::write_instr`].
pub fn free_instr(&mut self, instrs: PioInstanceMemory<PIO>) { /// This is always possible but unsafe if any state machine is still using this
/// bit of memory.
pub unsafe fn free_instr(&mut self, instrs: PioInstanceMemory<PIO>) {
self.instructions_used &= !instrs.used_mask; self.instructions_used &= !instrs.used_mask;
} }