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:
parent
7598b8a40f
commit
48afef28a0
3 changed files with 3 additions and 3 deletions
|
@ -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 {
|
||||
|
|
|
@ -25,7 +25,7 @@ async fn main(_spawner: Spawner, p: Peripherals) {
|
|||
config.refresh = 624;
|
||||
// thus our sequence takes 5 * 5000ms or 25 seconds
|
||||
|
||||
let pwm = unwrap!(SequencePwm::new(
|
||||
let mut pwm = unwrap!(SequencePwm::new(
|
||||
p.PWM0, p.P0_13, NoPin, NoPin, NoPin, config,
|
||||
));
|
||||
let _ = pwm.start(&seq_values_1, SequenceMode::Infinite);
|
||||
|
|
|
@ -26,7 +26,7 @@ async fn main(_spawner: Spawner, p: Peripherals) {
|
|||
// thus our sequence takes 5 * 250ms or 1.25 seconds
|
||||
config.refresh = 30;
|
||||
|
||||
let pwm = unwrap!(SequencePwm::new(
|
||||
let mut pwm = unwrap!(SequencePwm::new(
|
||||
p.PWM0, p.P0_13, NoPin, NoPin, NoPin, config,
|
||||
));
|
||||
|
||||
|
|
Loading…
Reference in a new issue