Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add methods to enable/disable the entire timer #183

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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

Expand Down
16 changes: 12 additions & 4 deletions src/pwm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u16, Self::Error> { unimplemented!() }
/// # fn try_get_max_duty(&self) -> Result<u16, Self::Error> { Ok(0) }
/// # fn try_set_duty(&mut self, _: Channel, _: u16) -> Result<(), Self::Error> { Ok(()) }
Expand Down Expand Up @@ -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<Self::Time, Self::Error>;
Expand Down