Strengthen the borrow

The start method is now safe. Because it has the potential of borrowing the sequence and mutating itself, the sequence must outlive the Pwm struct.
This commit is contained in:
huntc
2022-01-24 17:08:24 +11:00
parent 7598b8a40f
commit 48afef28a0
3 changed files with 3 additions and 3 deletions

View File

@ -138,7 +138,7 @@ impl<'d, T: Instance> SequencePwm<'d, T> {
/// Start or restart playback
#[inline(always)]
pub fn start(&self, sequence: &'d [u16], times: SequenceMode) -> Result<(), Error> {
pub fn start(&mut self, sequence: &'d [u16], times: SequenceMode) -> Result<(), Error> {
slice_in_ram_or(sequence, Error::DMABufferNotInDataMemory)?;
if sequence.len() > 32767 {