diff options
| author | Jacob Rosenthal <[email protected]> | 2021-11-11 23:47:35 -0700 |
|---|---|---|
| committer | Jacob Rosenthal <[email protected]> | 2021-11-11 23:47:35 -0700 |
| commit | aca7b86c7e60852ab7ea22a3b793eca7860f4887 (patch) | |
| tree | 96cf1f21170a8d70e3c2c8ab49aa9efbf5b8671c /examples/nrf/src/bin | |
| parent | 667a93b5c89c1d71077ef6a8d58a35621d9f498a (diff) | |
pwm_sequence show implicit and explicit stop functionality
Diffstat (limited to 'examples/nrf/src/bin')
| -rw-r--r-- | examples/nrf/src/bin/pwm_sequence.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/examples/nrf/src/bin/pwm_sequence.rs b/examples/nrf/src/bin/pwm_sequence.rs index 1e15bf6c4..8f57b5245 100644 --- a/examples/nrf/src/bin/pwm_sequence.rs +++ b/examples/nrf/src/bin/pwm_sequence.rs | |||
| @@ -22,6 +22,7 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 22 | // so we want to repeat our value as many times as necessary until 5000ms passes | 22 | // so we want to repeat our value as many times as necessary until 5000ms passes |
| 23 | // want 5000/8 = 625 periods total to occur, so 624 (we get the one period for free remember) | 23 | // want 5000/8 = 625 periods total to occur, so 624 (we get the one period for free remember) |
| 24 | config.refresh = 624; | 24 | config.refresh = 624; |
| 25 | // thus our sequence takes 5 * 5000ms or 25 seconds | ||
| 25 | 26 | ||
| 26 | let pwm = unwrap!(SequencePwm::new( | 27 | let pwm = unwrap!(SequencePwm::new( |
| 27 | p.PWM0, | 28 | p.PWM0, |
| @@ -36,7 +37,9 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 36 | 37 | ||
| 37 | info!("pwm started!"); | 38 | info!("pwm started!"); |
| 38 | 39 | ||
| 39 | loop { | 40 | // we can abort a sequence if we need to before its complete with pwm.stop() |
| 40 | Timer::after(Duration::from_millis(5000)).await; | 41 | // or stop is also implicitly called when the pwm peripheral is dropped |
| 41 | } | 42 | // when it goes out of scope |
| 43 | Timer::after(Duration::from_millis(20000)).await; | ||
| 44 | info!("pwm stopped early!"); | ||
| 42 | } | 45 | } |
