diff options
| author | huntc <[email protected]> | 2022-01-24 17:08:24 +1100 |
|---|---|---|
| committer | huntc <[email protected]> | 2022-01-24 17:22:35 +1100 |
| commit | 48afef28a0c85d8296b0b984217350dad75daf46 (patch) | |
| tree | 76a0523ef781ba54c133c44e382550ad68a591d6 /examples | |
| parent | 7598b8a40fba7e7035d67da5867f27d16818ea62 (diff) | |
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.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/nrf/src/bin/pwm_sequence.rs | 2 | ||||
| -rw-r--r-- | examples/nrf/src/bin/pwm_sequence_ppi.rs | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/examples/nrf/src/bin/pwm_sequence.rs b/examples/nrf/src/bin/pwm_sequence.rs index 9877b54a6..561bc1dd1 100644 --- a/examples/nrf/src/bin/pwm_sequence.rs +++ b/examples/nrf/src/bin/pwm_sequence.rs | |||
| @@ -25,7 +25,7 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 25 | config.refresh = 624; | 25 | config.refresh = 624; |
| 26 | // thus our sequence takes 5 * 5000ms or 25 seconds | 26 | // thus our sequence takes 5 * 5000ms or 25 seconds |
| 27 | 27 | ||
| 28 | let pwm = unwrap!(SequencePwm::new( | 28 | let mut pwm = unwrap!(SequencePwm::new( |
| 29 | p.PWM0, p.P0_13, NoPin, NoPin, NoPin, config, | 29 | p.PWM0, p.P0_13, NoPin, NoPin, NoPin, config, |
| 30 | )); | 30 | )); |
| 31 | let _ = pwm.start(&seq_values_1, SequenceMode::Infinite); | 31 | let _ = pwm.start(&seq_values_1, SequenceMode::Infinite); |
diff --git a/examples/nrf/src/bin/pwm_sequence_ppi.rs b/examples/nrf/src/bin/pwm_sequence_ppi.rs index f72ccc112..213ef5ed7 100644 --- a/examples/nrf/src/bin/pwm_sequence_ppi.rs +++ b/examples/nrf/src/bin/pwm_sequence_ppi.rs | |||
| @@ -26,7 +26,7 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 26 | // thus our sequence takes 5 * 250ms or 1.25 seconds | 26 | // thus our sequence takes 5 * 250ms or 1.25 seconds |
| 27 | config.refresh = 30; | 27 | config.refresh = 30; |
| 28 | 28 | ||
| 29 | let pwm = unwrap!(SequencePwm::new( | 29 | let mut pwm = unwrap!(SequencePwm::new( |
| 30 | p.PWM0, p.P0_13, NoPin, NoPin, NoPin, config, | 30 | p.PWM0, p.P0_13, NoPin, NoPin, NoPin, config, |
| 31 | )); | 31 | )); |
| 32 | 32 | ||
