diff options
| -rw-r--r-- | embassy-nrf/src/pwm.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/embassy-nrf/src/pwm.rs b/embassy-nrf/src/pwm.rs index e038f44b8..1fa8f183b 100644 --- a/embassy-nrf/src/pwm.rs +++ b/embassy-nrf/src/pwm.rs | |||
| @@ -289,6 +289,8 @@ impl<'a> Drop for SequencePwm<'a> { | |||
| 289 | } | 289 | } |
| 290 | 290 | ||
| 291 | /// Configuration for the PWM as a whole. | 291 | /// Configuration for the PWM as a whole. |
| 292 | #[derive(Debug, Clone)] | ||
| 293 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
| 292 | #[non_exhaustive] | 294 | #[non_exhaustive] |
| 293 | pub struct Config { | 295 | pub struct Config { |
| 294 | /// Selects up mode or up-and-down mode for the counter | 296 | /// Selects up mode or up-and-down mode for the counter |
| @@ -326,7 +328,8 @@ impl Default for Config { | |||
| 326 | 328 | ||
| 327 | /// Configuration per sequence | 329 | /// Configuration per sequence |
| 328 | #[non_exhaustive] | 330 | #[non_exhaustive] |
| 329 | #[derive(Clone)] | 331 | #[derive(Debug, Clone)] |
| 332 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
| 330 | pub struct SequenceConfig { | 333 | pub struct SequenceConfig { |
| 331 | /// Number of PWM periods to delay between each sequence sample | 334 | /// Number of PWM periods to delay between each sequence sample |
| 332 | pub refresh: u32, | 335 | pub refresh: u32, |
| @@ -345,6 +348,8 @@ impl Default for SequenceConfig { | |||
| 345 | 348 | ||
| 346 | /// A composition of a sequence buffer and its configuration. | 349 | /// A composition of a sequence buffer and its configuration. |
| 347 | #[non_exhaustive] | 350 | #[non_exhaustive] |
| 351 | #[derive(Debug, Clone)] | ||
| 352 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
| 348 | pub struct Sequence<'s> { | 353 | pub struct Sequence<'s> { |
| 349 | /// The words comprising the sequence. Must not exceed 32767 words. | 354 | /// The words comprising the sequence. Must not exceed 32767 words. |
| 350 | pub words: &'s [u16], | 355 | pub words: &'s [u16], |
| @@ -496,6 +501,7 @@ impl<'d, 's> Drop for Sequencer<'d, 's> { | |||
| 496 | 501 | ||
| 497 | /// How many times to run a single sequence | 502 | /// How many times to run a single sequence |
| 498 | #[derive(Debug, Eq, PartialEq, Clone, Copy)] | 503 | #[derive(Debug, Eq, PartialEq, Clone, Copy)] |
| 504 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
| 499 | pub enum SingleSequenceMode { | 505 | pub enum SingleSequenceMode { |
| 500 | /// Run a single sequence n Times total. | 506 | /// Run a single sequence n Times total. |
| 501 | Times(u16), | 507 | Times(u16), |
| @@ -505,6 +511,7 @@ pub enum SingleSequenceMode { | |||
| 505 | 511 | ||
| 506 | /// Which sequence to start a loop with | 512 | /// Which sequence to start a loop with |
| 507 | #[derive(Debug, Eq, PartialEq, Clone, Copy)] | 513 | #[derive(Debug, Eq, PartialEq, Clone, Copy)] |
| 514 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
| 508 | pub enum StartSequence { | 515 | pub enum StartSequence { |
| 509 | /// Start with Sequence 0 | 516 | /// Start with Sequence 0 |
| 510 | Zero, | 517 | Zero, |
| @@ -514,6 +521,7 @@ pub enum StartSequence { | |||
| 514 | 521 | ||
| 515 | /// How many loops to run two sequences | 522 | /// How many loops to run two sequences |
| 516 | #[derive(Debug, Eq, PartialEq, Clone, Copy)] | 523 | #[derive(Debug, Eq, PartialEq, Clone, Copy)] |
| 524 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
| 517 | pub enum SequenceMode { | 525 | pub enum SequenceMode { |
| 518 | /// Run two sequences n loops i.e. (n * (seq0 + seq1.unwrap_or(seq0))) | 526 | /// Run two sequences n loops i.e. (n * (seq0 + seq1.unwrap_or(seq0))) |
| 519 | Loop(u16), | 527 | Loop(u16), |
| @@ -523,6 +531,7 @@ pub enum SequenceMode { | |||
| 523 | 531 | ||
| 524 | /// PWM Base clock is system clock (16MHz) divided by prescaler | 532 | /// PWM Base clock is system clock (16MHz) divided by prescaler |
| 525 | #[derive(Debug, Eq, PartialEq, Clone, Copy)] | 533 | #[derive(Debug, Eq, PartialEq, Clone, Copy)] |
| 534 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
| 526 | pub enum Prescaler { | 535 | pub enum Prescaler { |
| 527 | /// Divide by 1 | 536 | /// Divide by 1 |
| 528 | Div1, | 537 | Div1, |
| @@ -544,6 +553,7 @@ pub enum Prescaler { | |||
| 544 | 553 | ||
| 545 | /// How the sequence values are distributed across the channels | 554 | /// How the sequence values are distributed across the channels |
| 546 | #[derive(Debug, Eq, PartialEq, Clone, Copy)] | 555 | #[derive(Debug, Eq, PartialEq, Clone, Copy)] |
| 556 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
| 547 | pub enum SequenceLoad { | 557 | pub enum SequenceLoad { |
| 548 | /// Provided sequence will be used across all channels | 558 | /// Provided sequence will be used across all channels |
| 549 | Common, | 559 | Common, |
| @@ -560,6 +570,7 @@ pub enum SequenceLoad { | |||
| 560 | 570 | ||
| 561 | /// Selects up mode or up-and-down mode for the counter | 571 | /// Selects up mode or up-and-down mode for the counter |
| 562 | #[derive(Debug, Eq, PartialEq, Clone, Copy)] | 572 | #[derive(Debug, Eq, PartialEq, Clone, Copy)] |
| 573 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
| 563 | pub enum CounterMode { | 574 | pub enum CounterMode { |
| 564 | /// Up counter (edge-aligned PWM duty cycle) | 575 | /// Up counter (edge-aligned PWM duty cycle) |
| 565 | Up, | 576 | Up, |
