Skip to content

Commit

Permalink
Rename UnconfiguredPwmPin and configure
Browse files Browse the repository at this point in the history
As suggested by @hannobraun, makes it clearer what's going on
  • Loading branch information
david-sawatzke committed Jan 13, 2020
1 parent 0b72af9 commit 4b93b62
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions examples/ctimer_fade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ fn main() -> ! {
let (green, _) = swm.movable_functions.t0_mat1.assign(green, &mut handle);
let (blue, _) = swm.movable_functions.t0_mat2.assign(blue, &mut handle);

let mut red = red_pwm.configure(red);
let mut green = green_pwm.configure(green);
let mut blue = blue_pwm.configure(blue);
let mut red = red_pwm.attach(red);
let mut green = green_pwm.attach(green);
let mut blue = blue_pwm.attach(blue);
// Fade each color after anothe
loop {
for i in 0..red.get_max_duty() {
Expand Down
26 changes: 13 additions & 13 deletions src/ctimer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
//!
//! let (pwm_output, _) = swm.movable_functions.t0_mat0.assign(pwm_output, &mut handle);
//!
//! let mut pwm_pin = pwm_channel.configure(pwm_output);
//! let mut pwm_pin = pwm_channel.attach(pwm_output);
//! loop {
//! for i in 0..red.get_max_duty() {
//! delay.delay_ms(4_u8);
Expand Down Expand Up @@ -57,12 +57,12 @@ pub struct CTimer {
ct: CTIMER0,
}

/// An unconfigured [`CTimerPwmPin`]
/// A detached [`CTimerPwmPin`]
///
/// Use `configure` to assing an output to it
/// Use `attach` to assign an output to it
///
/// [`CTimerPwmPin`]: struct.CTimerPwmPin.html
pub struct UnconfiguredPwmPin<CTOutput> {
pub struct DetachedPwmPin<CTOutput> {
number: u8,
mr: RegProxy<MR>,
msr: RegProxy<MSR>,
Expand Down Expand Up @@ -91,9 +91,9 @@ impl CTimer {
prescaler: u32,
syscon: &mut syscon::Handle,
) -> (
UnconfiguredPwmPin<T0_MAT0>,
UnconfiguredPwmPin<T0_MAT1>,
UnconfiguredPwmPin<T0_MAT2>,
DetachedPwmPin<T0_MAT0>,
DetachedPwmPin<T0_MAT1>,
DetachedPwmPin<T0_MAT2>,
) {
syscon.enable_clock(&self.ct);
unsafe { self.ct.pr.write(|w| w.prval().bits(prescaler)) };
Expand All @@ -116,19 +116,19 @@ impl CTimer {
// Start the timer
self.ct.tcr.write(|w| w.cen().set_bit());
(
UnconfiguredPwmPin {
DetachedPwmPin {
number: 0,
mr: RegProxy::new(),
msr: RegProxy::new(),
output: PhantomData {},
},
UnconfiguredPwmPin {
DetachedPwmPin {
number: 1,
mr: RegProxy::new(),
msr: RegProxy::new(),
output: PhantomData {},
},
UnconfiguredPwmPin {
DetachedPwmPin {
number: 2,
mr: RegProxy::new(),
msr: RegProxy::new(),
Expand All @@ -154,10 +154,10 @@ impl CTimer {
}
}

impl<CTOutput> UnconfiguredPwmPin<CTOutput> {
/// Assings a pin to an `UnconfiguredPwmOutput`,
impl<CTOutput> DetachedPwmPin<CTOutput> {
/// Assigns a pin to a `DetachedPwmPin`,
/// allowing it to be used as a pwm output
pub fn configure<PWM>(
pub fn attach<PWM>(
self,
_: swm::Function<CTOutput, swm::state::Assigned<PWM>>,
) -> CTimerPwmPin
Expand Down

0 comments on commit 4b93b62

Please sign in to comment.