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:
@ -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,
|
||||
));
|
||||
|
||||
|
Reference in New Issue
Block a user