nrf: sequencepwm rename top to max_duty for consistancy

This commit is contained in:
Jacob Rosenthal 2021-11-11 22:47:57 -07:00
parent ea1c62ff61
commit 937f49dead
2 changed files with 4 additions and 4 deletions

View File

@ -139,7 +139,7 @@ impl<'d, T: Instance> SequencePwm<'d, T> {
r.prescaler
.write(|w| w.prescaler().bits(config.prescaler as u8));
r.countertop
.write(|w| unsafe { w.countertop().bits(config.top) });
.write(|w| unsafe { w.countertop().bits(config.max_duty) });
Ok(Self {
phantom: PhantomData,
@ -260,7 +260,7 @@ pub struct SequenceConfig {
/// Selects up mode or up-and-down mode for the counter
pub counter_mode: CounterMode,
/// Top value to be compared against buffer values
pub top: u16,
pub max_duty: u16,
/// Configuration for PWM_CLK
pub prescaler: Prescaler,
/// How a sequence is read from RAM and is spread to the compare register
@ -275,7 +275,7 @@ impl Default for SequenceConfig {
fn default() -> SequenceConfig {
SequenceConfig {
counter_mode: CounterMode::Up,
top: 1000,
max_duty: 1000,
prescaler: Prescaler::Div16,
sequence_load: SequenceLoad::Common,
refresh: 0,

View File

@ -91,7 +91,7 @@ async fn main(_spawner: Spawner, p: Peripherals) {
let mut config = SequenceConfig::default();
config.prescaler = Prescaler::Div1;
// 1 period is 32767 * 1/16mhz = 0.002047938 = 2.047938ms
config.top = 32767;
config.max_duty = 32767;
// pwm example is delaying >~3ms before updating duty cycle, our refreshes
// happen exactly at 2.047938ms so we need a delay after each value of >~1ms
// which for us is ~1-2 periods