From 14dc524b84b28cfa6f8a9649c38173d6a1977a9e Mon Sep 17 00:00:00 2001 From: Jacob Rosenthal Date: Mon, 1 Nov 2021 01:20:01 -0700 Subject: [PATCH] documentation --- embassy-nrf/src/pwm.rs | 19 ++++++++++++------- examples/nrf/src/bin/pwm_sequence.rs | 2 +- examples/nrf/src/bin/pwm_simple_sin.rs | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/embassy-nrf/src/pwm.rs b/embassy-nrf/src/pwm.rs index 5ed9cf146..5f3a4df83 100644 --- a/embassy-nrf/src/pwm.rs +++ b/embassy-nrf/src/pwm.rs @@ -27,11 +27,16 @@ pub enum Prescaler { /// How a sequence is read from RAM and is spread to the compare register #[derive(Debug, Eq, PartialEq, Clone, Copy)] pub enum SequenceLoad { - /// sequence in buffer will be used across all channels + /// Provided sequence will be used across all channels Common, + /// Provided sequence contains grouped values for each channel ex: + /// [ch0_0_and_ch1_0, ch2_0_and_ch3_0, ... ch0_n_and_ch1_n, ch2_n_and_ch3_n] Grouped, - /// buffer holds [ch0_0, ch1_0, ch2_0, ch3_0... ch0_n, ch1_n, ch2_n, ch3_n] + /// Provided sequence contains individual values for each channel ex: + /// [ch0_0, ch1_0, ch2_0, ch3_0... ch0_n, ch1_n, ch2_n, ch3_n] Individual, + /// Similar to Individual mode, but only three channels are used. The fourth + /// value is loaded into the pulse generator counter as its top value. Waveform, } @@ -66,10 +71,10 @@ pub struct LoopingConfig<'a> { pub sequence: &'a [u16], /// How a sequence is read from RAM and is spread to the compare register pub sequence_load: SequenceLoad, - /// Number of additional PWM periods between samples loaded into compare register + /// Number of additional PWM periods to delay between each sequence sample pub refresh: u32, - /// Number of additional PWM periods after the sequence ends - pub enddelay: u32, + /// Number of additional PWM periods after the sequence ends before starting the next sequence + pub end_delay: u32, /// How many times to repeat the sequence pub additional_loops: LoopMode, } @@ -222,7 +227,7 @@ impl<'d, T: Instance> Pwm<'d, T> { r.seq0.refresh.write(|w| unsafe { w.bits(config.refresh) }); r.seq0 .enddelay - .write(|w| unsafe { w.bits(config.enddelay) }); + .write(|w| unsafe { w.bits(config.end_delay) }); r.seq1 .ptr @@ -233,7 +238,7 @@ impl<'d, T: Instance> Pwm<'d, T> { r.seq1.refresh.write(|w| unsafe { w.bits(config.refresh) }); r.seq1 .enddelay - .write(|w| unsafe { w.bits(config.enddelay) }); + .write(|w| unsafe { w.bits(config.end_delay) }); match config.additional_loops { // just the one time, no loop count diff --git a/examples/nrf/src/bin/pwm_sequence.rs b/examples/nrf/src/bin/pwm_sequence.rs index 8b7aeddcd..1c5ab2682 100644 --- a/examples/nrf/src/bin/pwm_sequence.rs +++ b/examples/nrf/src/bin/pwm_sequence.rs @@ -23,7 +23,7 @@ async fn main(_spawner: Spawner, p: Peripherals) { sequence: &seq_values, sequence_load: SequenceLoad::Individual, refresh: 0, - enddelay: 0, + end_delay: 0, additional_loops: LoopMode::Additional(5), }; diff --git a/examples/nrf/src/bin/pwm_simple_sin.rs b/examples/nrf/src/bin/pwm_simple_sin.rs index c7d85381b..909b8bf3a 100644 --- a/examples/nrf/src/bin/pwm_simple_sin.rs +++ b/examples/nrf/src/bin/pwm_simple_sin.rs @@ -27,7 +27,7 @@ async fn main(_spawner: Spawner, p: Peripherals) { sequence: &seq_values, sequence_load: SequenceLoad::Common, refresh: 0, - enddelay: 0, + end_delay: 1, additional_loops: LoopMode::Infinite, };