diff options
| author | Jacob Rosenthal <[email protected]> | 2021-11-01 19:11:37 -0700 |
|---|---|---|
| committer | Jacob Rosenthal <[email protected]> | 2021-11-01 20:50:14 -0700 |
| commit | 49253152cff2a45bd08cd1801bb6d5f0f3ce9b30 (patch) | |
| tree | b9b905764990b0273dc176fc4843e9f8a20d5089 /examples | |
| parent | b297e5f7bd152d1e5147631c81987c26f9fa0664 (diff) | |
seperate sequence from duty cycle pwm struct
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/nrf/src/bin/pwm_sequence.rs | 9 | ||||
| -rw-r--r-- | examples/nrf/src/bin/pwm_simple_sin.rs | 9 |
2 files changed, 11 insertions, 7 deletions
diff --git a/examples/nrf/src/bin/pwm_sequence.rs b/examples/nrf/src/bin/pwm_sequence.rs index 066ab3c03..0a7bea1c4 100644 --- a/examples/nrf/src/bin/pwm_sequence.rs +++ b/examples/nrf/src/bin/pwm_sequence.rs | |||
| @@ -7,7 +7,9 @@ mod example_common; | |||
| 7 | use defmt::*; | 7 | use defmt::*; |
| 8 | use embassy::executor::Spawner; | 8 | use embassy::executor::Spawner; |
| 9 | use embassy::time::{Duration, Timer}; | 9 | use embassy::time::{Duration, Timer}; |
| 10 | use embassy_nrf::pwm::{CounterMode, Prescaler, Pwm, SequenceConfig, SequenceLoad, SequenceMode}; | 10 | use embassy_nrf::pwm::{ |
| 11 | CounterMode, Prescaler, PwmSeq, SequenceConfig, SequenceLoad, SequenceMode, | ||
| 12 | }; | ||
| 11 | use embassy_nrf::Peripherals; | 13 | use embassy_nrf::Peripherals; |
| 12 | 14 | ||
| 13 | #[embassy::main] | 15 | #[embassy::main] |
| @@ -27,8 +29,9 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 27 | times: SequenceMode::Times(5), | 29 | times: SequenceMode::Times(5), |
| 28 | }; | 30 | }; |
| 29 | 31 | ||
| 30 | let pwm = Pwm::new(p.PWM0, p.P0_13, p.P0_15, p.P0_16, p.P0_14); | 32 | let _pwm = unwrap!(PwmSeq::new( |
| 31 | unwrap!(pwm.play_sequence(config)); | 33 | p.PWM0, p.P0_13, p.P0_15, p.P0_16, p.P0_14, config |
| 34 | )); | ||
| 32 | info!("pwm started!"); | 35 | info!("pwm started!"); |
| 33 | 36 | ||
| 34 | loop { | 37 | loop { |
diff --git a/examples/nrf/src/bin/pwm_simple_sin.rs b/examples/nrf/src/bin/pwm_simple_sin.rs index 3c1bddbc7..6fd59c6a4 100644 --- a/examples/nrf/src/bin/pwm_simple_sin.rs +++ b/examples/nrf/src/bin/pwm_simple_sin.rs | |||
| @@ -9,7 +9,9 @@ use defmt::*; | |||
| 9 | use embassy::executor::Spawner; | 9 | use embassy::executor::Spawner; |
| 10 | use embassy::time::{Duration, Timer}; | 10 | use embassy::time::{Duration, Timer}; |
| 11 | use embassy_nrf::gpio::NoPin; | 11 | use embassy_nrf::gpio::NoPin; |
| 12 | use embassy_nrf::pwm::{CounterMode, Prescaler, Pwm, SequenceConfig, SequenceLoad, SequenceMode}; | 12 | use embassy_nrf::pwm::{ |
| 13 | CounterMode, Prescaler, PwmSeq, SequenceConfig, SequenceLoad, SequenceMode, | ||
| 14 | }; | ||
| 13 | use embassy_nrf::Peripherals; | 15 | use embassy_nrf::Peripherals; |
| 14 | use micromath::F32Ext; | 16 | use micromath::F32Ext; |
| 15 | 17 | ||
| @@ -31,13 +33,12 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 31 | times: SequenceMode::Infinite, | 33 | times: SequenceMode::Infinite, |
| 32 | }; | 34 | }; |
| 33 | 35 | ||
| 34 | let pwm = Pwm::new(p.PWM0, p.P0_13, NoPin, NoPin, NoPin); | 36 | let pwm = unwrap!(PwmSeq::new(p.PWM0, p.P0_13, NoPin, NoPin, NoPin, config)); |
| 35 | unwrap!(pwm.play_sequence(config)); | ||
| 36 | info!("pwm started!"); | 37 | info!("pwm started!"); |
| 37 | 38 | ||
| 38 | Timer::after(Duration::from_millis(20000)).await; | 39 | Timer::after(Duration::from_millis(20000)).await; |
| 39 | 40 | ||
| 40 | pwm.sequence_stop(); | 41 | pwm.stop(); |
| 41 | info!("pwm stopped!"); | 42 | info!("pwm stopped!"); |
| 42 | 43 | ||
| 43 | loop { | 44 | loop { |
