diff options
| author | Jacob Rosenthal <[email protected]> | 2021-11-01 01:20:01 -0700 |
|---|---|---|
| committer | Jacob Rosenthal <[email protected]> | 2021-11-01 01:20:01 -0700 |
| commit | 14dc524b84b28cfa6f8a9649c38173d6a1977a9e (patch) | |
| tree | 2125d0c9978a1d2df8943f25451b0f7a45ef3a44 | |
| parent | 7b092f463e630e7d8725f6af2d0138b608050b1f (diff) | |
documentation
| -rw-r--r-- | embassy-nrf/src/pwm.rs | 19 | ||||
| -rw-r--r-- | examples/nrf/src/bin/pwm_sequence.rs | 2 | ||||
| -rw-r--r-- | 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 { | |||
| 27 | /// How a sequence is read from RAM and is spread to the compare register | 27 | /// How a sequence is read from RAM and is spread to the compare register |
| 28 | #[derive(Debug, Eq, PartialEq, Clone, Copy)] | 28 | #[derive(Debug, Eq, PartialEq, Clone, Copy)] |
| 29 | pub enum SequenceLoad { | 29 | pub enum SequenceLoad { |
| 30 | /// sequence in buffer will be used across all channels | 30 | /// Provided sequence will be used across all channels |
| 31 | Common, | 31 | Common, |
| 32 | /// Provided sequence contains grouped values for each channel ex: | ||
| 33 | /// [ch0_0_and_ch1_0, ch2_0_and_ch3_0, ... ch0_n_and_ch1_n, ch2_n_and_ch3_n] | ||
| 32 | Grouped, | 34 | Grouped, |
| 33 | /// buffer holds [ch0_0, ch1_0, ch2_0, ch3_0... ch0_n, ch1_n, ch2_n, ch3_n] | 35 | /// Provided sequence contains individual values for each channel ex: |
| 36 | /// [ch0_0, ch1_0, ch2_0, ch3_0... ch0_n, ch1_n, ch2_n, ch3_n] | ||
| 34 | Individual, | 37 | Individual, |
| 38 | /// Similar to Individual mode, but only three channels are used. The fourth | ||
| 39 | /// value is loaded into the pulse generator counter as its top value. | ||
| 35 | Waveform, | 40 | Waveform, |
| 36 | } | 41 | } |
| 37 | 42 | ||
| @@ -66,10 +71,10 @@ pub struct LoopingConfig<'a> { | |||
| 66 | pub sequence: &'a [u16], | 71 | pub sequence: &'a [u16], |
| 67 | /// How a sequence is read from RAM and is spread to the compare register | 72 | /// How a sequence is read from RAM and is spread to the compare register |
| 68 | pub sequence_load: SequenceLoad, | 73 | pub sequence_load: SequenceLoad, |
| 69 | /// Number of additional PWM periods between samples loaded into compare register | 74 | /// Number of additional PWM periods to delay between each sequence sample |
| 70 | pub refresh: u32, | 75 | pub refresh: u32, |
| 71 | /// Number of additional PWM periods after the sequence ends | 76 | /// Number of additional PWM periods after the sequence ends before starting the next sequence |
| 72 | pub enddelay: u32, | 77 | pub end_delay: u32, |
| 73 | /// How many times to repeat the sequence | 78 | /// How many times to repeat the sequence |
| 74 | pub additional_loops: LoopMode, | 79 | pub additional_loops: LoopMode, |
| 75 | } | 80 | } |
| @@ -222,7 +227,7 @@ impl<'d, T: Instance> Pwm<'d, T> { | |||
| 222 | r.seq0.refresh.write(|w| unsafe { w.bits(config.refresh) }); | 227 | r.seq0.refresh.write(|w| unsafe { w.bits(config.refresh) }); |
| 223 | r.seq0 | 228 | r.seq0 |
| 224 | .enddelay | 229 | .enddelay |
| 225 | .write(|w| unsafe { w.bits(config.enddelay) }); | 230 | .write(|w| unsafe { w.bits(config.end_delay) }); |
| 226 | 231 | ||
| 227 | r.seq1 | 232 | r.seq1 |
| 228 | .ptr | 233 | .ptr |
| @@ -233,7 +238,7 @@ impl<'d, T: Instance> Pwm<'d, T> { | |||
| 233 | r.seq1.refresh.write(|w| unsafe { w.bits(config.refresh) }); | 238 | r.seq1.refresh.write(|w| unsafe { w.bits(config.refresh) }); |
| 234 | r.seq1 | 239 | r.seq1 |
| 235 | .enddelay | 240 | .enddelay |
| 236 | .write(|w| unsafe { w.bits(config.enddelay) }); | 241 | .write(|w| unsafe { w.bits(config.end_delay) }); |
| 237 | 242 | ||
| 238 | match config.additional_loops { | 243 | match config.additional_loops { |
| 239 | // just the one time, no loop count | 244 | // 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) { | |||
| 23 | sequence: &seq_values, | 23 | sequence: &seq_values, |
| 24 | sequence_load: SequenceLoad::Individual, | 24 | sequence_load: SequenceLoad::Individual, |
| 25 | refresh: 0, | 25 | refresh: 0, |
| 26 | enddelay: 0, | 26 | end_delay: 0, |
| 27 | additional_loops: LoopMode::Additional(5), | 27 | additional_loops: LoopMode::Additional(5), |
| 28 | }; | 28 | }; |
| 29 | 29 | ||
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) { | |||
| 27 | sequence: &seq_values, | 27 | sequence: &seq_values, |
| 28 | sequence_load: SequenceLoad::Common, | 28 | sequence_load: SequenceLoad::Common, |
| 29 | refresh: 0, | 29 | refresh: 0, |
| 30 | enddelay: 0, | 30 | end_delay: 1, |
| 31 | additional_loops: LoopMode::Infinite, | 31 | additional_loops: LoopMode::Infinite, |
| 32 | }; | 32 | }; |
| 33 | 33 | ||
