aboutsummaryrefslogtreecommitdiff
path: root/examples/nrf/src
diff options
context:
space:
mode:
Diffstat (limited to 'examples/nrf/src')
-rw-r--r--examples/nrf/src/bin/pwm_sequence.rs18
-rw-r--r--examples/nrf/src/bin/pwm_sequence_ppi.rs10
2 files changed, 11 insertions, 17 deletions
diff --git a/examples/nrf/src/bin/pwm_sequence.rs b/examples/nrf/src/bin/pwm_sequence.rs
index 8f57b5245..9877b54a6 100644
--- a/examples/nrf/src/bin/pwm_sequence.rs
+++ b/examples/nrf/src/bin/pwm_sequence.rs
@@ -13,7 +13,8 @@ use embassy_nrf::Peripherals;
13 13
14#[embassy::main] 14#[embassy::main]
15async fn main(_spawner: Spawner, p: Peripherals) { 15async fn main(_spawner: Spawner, p: Peripherals) {
16 let seq_values: [u16; 5] = [1000, 250, 100, 50, 0]; 16 let seq_values_1: [u16; 5] = [1000, 250, 100, 50, 0];
17 let seq_values_2: [u16; 5] = [0, 50, 100, 250, 1000];
17 18
18 let mut config = SequenceConfig::default(); 19 let mut config = SequenceConfig::default();
19 config.prescaler = Prescaler::Div128; 20 config.prescaler = Prescaler::Div128;
@@ -25,18 +26,17 @@ async fn main(_spawner: Spawner, p: Peripherals) {
25 // thus our sequence takes 5 * 5000ms or 25 seconds 26 // thus our sequence takes 5 * 5000ms or 25 seconds
26 27
27 let pwm = unwrap!(SequencePwm::new( 28 let pwm = unwrap!(SequencePwm::new(
28 p.PWM0, 29 p.PWM0, p.P0_13, NoPin, NoPin, NoPin, config,
29 p.P0_13,
30 NoPin,
31 NoPin,
32 NoPin,
33 config,
34 &seq_values
35 )); 30 ));
36 let _ = pwm.start(SequenceMode::Infinite); 31 let _ = pwm.start(&seq_values_1, SequenceMode::Infinite);
37 32
38 info!("pwm started!"); 33 info!("pwm started!");
39 34
35 Timer::after(Duration::from_millis(20000)).await;
36 info!("pwm starting with another sequence!");
37
38 let _ = pwm.start(&seq_values_2, SequenceMode::Infinite);
39
40 // we can abort a sequence if we need to before its complete with pwm.stop() 40 // we can abort a sequence if we need to before its complete with pwm.stop()
41 // or stop is also implicitly called when the pwm peripheral is dropped 41 // or stop is also implicitly called when the pwm peripheral is dropped
42 // when it goes out of scope 42 // when it goes out of scope
diff --git a/examples/nrf/src/bin/pwm_sequence_ppi.rs b/examples/nrf/src/bin/pwm_sequence_ppi.rs
index aaea9ff00..f72ccc112 100644
--- a/examples/nrf/src/bin/pwm_sequence_ppi.rs
+++ b/examples/nrf/src/bin/pwm_sequence_ppi.rs
@@ -27,16 +27,10 @@ async fn main(_spawner: Spawner, p: Peripherals) {
27 config.refresh = 30; 27 config.refresh = 30;
28 28
29 let pwm = unwrap!(SequencePwm::new( 29 let pwm = unwrap!(SequencePwm::new(
30 p.PWM0, 30 p.PWM0, p.P0_13, NoPin, NoPin, NoPin, config,
31 p.P0_13,
32 NoPin,
33 NoPin,
34 NoPin,
35 config,
36 &seq_values
37 )); 31 ));
38 32
39 let _ = pwm.start(SequenceMode::Times(1)); 33 let _ = pwm.start(&seq_values, SequenceMode::Times(1));
40 // pwm.stop() deconfigures pins, and then the task_start_seq0 task cant work 34 // pwm.stop() deconfigures pins, and then the task_start_seq0 task cant work
41 // so its going to have to start running in order load the configuration 35 // so its going to have to start running in order load the configuration
42 36