From 168082918761b7015e45576474db873e35b00936 Mon Sep 17 00:00:00 2001 From: Justace Clutter Date: Sun, 26 Jan 2020 09:19:05 -0500 Subject: [PATCH 1/5] Add methods to enable/disable the entire timer --- src/lib.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 13c0d8bd7..2a8225fb8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -862,11 +862,17 @@ pub trait Pwm { /// (e.g. `0.0 .. 1.0`) or an integer representation (e.g. `0 .. 65535`) type Duty; + /// Disables a PWM timer (all channels) + fn disable(&mut self); + + /// Enables a PWM timer (all channels) + fn enable(&mut self); + /// Disables a PWM `channel` - fn disable(&mut self, channel: Self::Channel); + fn channel_disable(&mut self, channel: Self::Channel); /// Enables a PWM `channel` - fn enable(&mut self, channel: Self::Channel); + fn channel_enable(&mut self, channel: Self::Channel); /// Returns the current PWM period fn get_period(&self) -> Self::Time; From 27a05e336f6e8fc279169e2256171985d01c8417 Mon Sep 17 00:00:00 2001 From: Justace Clutter Date: Sun, 26 Jan 2020 09:56:10 -0500 Subject: [PATCH 2/5] Update the test for the PWM trait --- src/lib.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 2a8225fb8..5f50e90b4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -834,8 +834,10 @@ pub trait Capture { /// # type Channel = Channel; /// # type Time = KiloHertz; /// # type Duty = u16; -/// # fn disable(&mut self, _: Channel) { unimplemented!() } -/// # fn enable(&mut self, _: Channel) { unimplemented!() } +/// #. fn disable(&mut self) { unimplemented!() } +/// #. fn enable(&mut self) { unimplemented!() } +/// # fn channel_disable(&mut self, _: Channel) { unimplemented!() } +/// # fn channel_enable(&mut self, _: Channel) { unimplemented!() } /// # fn get_duty(&self, _: Channel) -> u16 { unimplemented!() } /// # fn get_max_duty(&self) -> u16 { 0 } /// # fn set_duty(&mut self, _: Channel, _: u16) {} From cfc70179dcb36cedc36bf96e993476ed32269e65 Mon Sep 17 00:00:00 2001 From: Justace Clutter Date: Sun, 26 Jan 2020 10:04:22 -0500 Subject: [PATCH 3/5] Remove extraneous periods in test code --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 5f50e90b4..415472c05 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -834,8 +834,8 @@ pub trait Capture { /// # type Channel = Channel; /// # type Time = KiloHertz; /// # type Duty = u16; -/// #. fn disable(&mut self) { unimplemented!() } -/// #. fn enable(&mut self) { unimplemented!() } +/// # fn disable(&mut self) { unimplemented!() } +/// # fn enable(&mut self) { unimplemented!() } /// # fn channel_disable(&mut self, _: Channel) { unimplemented!() } /// # fn channel_enable(&mut self, _: Channel) { unimplemented!() } /// # fn get_duty(&self, _: Channel) -> u16 { unimplemented!() } From b6a04ca523c25bcd3c42edc26723510bfbece0b0 Mon Sep 17 00:00:00 2001 From: Justace Clutter Date: Sun, 21 Jun 2020 14:44:01 -0400 Subject: [PATCH 4/5] Add functions to enable/disable all channels for a timer --- src/pwm.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/pwm.rs b/src/pwm.rs index eaa6a92d6..3bb67d76b 100644 --- a/src/pwm.rs +++ b/src/pwm.rs @@ -39,8 +39,10 @@ /// # type Channel = Channel; /// # type Time = KiloHertz; /// # type Duty = u16; -/// # fn try_disable(&mut self, _: Channel) -> Result<(), Self::Error> { unimplemented!() } -/// # fn try_enable(&mut self, _: Channel) -> Result<(), Self::Error> { unimplemented!() } +/// # fn try_disable(&mut self) -> Result<(), Self::Error> { unimplemented!() } +/// # fn try_enable(&mut self) -> Result<(), Self::Error> { unimplemented!() } +/// # fn try_disable_channel(&mut self, _: Channel) -> Result<(), Self::Error> { unimplemented!() } +/// # fn try_enable_channel(&mut self, _: Channel) -> Result<(), Self::Error> { unimplemented!() } /// # fn try_get_duty(&self, _: Channel) -> Result { unimplemented!() } /// # fn try_get_max_duty(&self) -> Result { Ok(0) } /// # fn try_set_duty(&mut self, _: Channel, _: u16) -> Result<(), Self::Error> { Ok(()) } @@ -69,11 +71,17 @@ pub trait Pwm { /// (e.g. `0.0 .. 1.0`) or an integer representation (e.g. `0 .. 65535`) type Duty; + /// Disables all channels on the timer + fn try_disable(&mut self) -> Result<(), Self::Error>; + + /// Enables all channels on the timer + fn try_enable(&mut self) -> Result<(), Self::Error>; + /// Disables a PWM `channel` - fn try_disable(&mut self, channel: Self::Channel) -> Result<(), Self::Error>; + fn try_disable_channel(&mut self, channel: Self::Channel) -> Result<(), Self::Error>; /// Enables a PWM `channel` - fn try_enable(&mut self, channel: Self::Channel) -> Result<(), Self::Error>; + fn try_enable_channel(&mut self, channel: Self::Channel) -> Result<(), Self::Error>; /// Returns the current PWM period fn try_get_period(&self) -> Result; From 6f9d9c1a77bf57e27b3e2a7c923aea73f80e6495 Mon Sep 17 00:00:00 2001 From: Justace Clutter Date: Mon, 22 Jun 2020 06:39:24 -0400 Subject: [PATCH 5/5] Updated changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d5b14d86b..ab8ce5e52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added - A nonblocking trait for interfacing with random number generation hardware. +- Methods to enable or disable all channels for a PWM object ### Changed - All traits have been marked as proven (`unproven` feature has been removed). @@ -26,6 +27,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - A new [process](https://github.com/rust-embedded/embedded-hal#how-to-add-a-new-trait) has been adopted for the addition of traits to the embedded-hal. - The minimum supported Rust version is 1.35 due to [this issue](https://github.com/rust-lang/rust/issues/54973). +- Renamed the existing PWM try_enable/try_disable methods to try_enable_channel/try_disable_channel to make room for new try_enable/try_disable methods ## [v0.2.3] - 2019-05-09