Trait nrf52832_hal::prelude::_embedded_hal_Pwm [−][src]
pub trait _embedded_hal_Pwm { type Channel; type Time; type Duty; fn disable(&mut self, channel: Self::Channel); fn enable(&mut self, channel: Self::Channel); fn get_period(&self) -> Self::Time; fn get_duty(&self, channel: Self::Channel) -> Self::Duty; fn get_max_duty(&self) -> Self::Duty; fn set_duty(&mut self, channel: Self::Channel, duty: Self::Duty); fn set_period<P>(&mut self, period: P)
where
P: Into<Self::Time>; }
Expand description
Pulse Width Modulation
This trait is available if embedded-hal is built with the "unproven"
feature.
Examples
Use this interface to control the power output of some actuator
extern crate embedded_hal as hal; use hal::prelude::*; fn main() { let mut pwm: Pwm1 = { // .. }; pwm.set_period(1.khz()); let max_duty = pwm.get_max_duty(); // brightest LED pwm.set_duty(Channel::_1, max_duty); // dimmer LED pwm.set_duty(Channel::_2, max_duty / 4); }
Associated Types
Required methods
fn get_period(&self) -> Self::Time
[src]
fn get_period(&self) -> Self::Time
[src]Returns the current PWM period
fn get_max_duty(&self) -> Self::Duty
[src]
fn get_max_duty(&self) -> Self::Duty
[src]Returns the maximum duty cycle value
fn set_period<P>(&mut self, period: P) where
P: Into<Self::Time>,
[src]
fn set_period<P>(&mut self, period: P) where
P: Into<Self::Time>,
[src]Sets a new PWM period
Implementors
impl<T> Pwm for Pwm<T> where
T: Instance,
[src]
impl<T> Pwm for Pwm<T> where
T: Instance,
[src]type Channel = Channel
type Duty = u16
type Time = Hertz
pub fn enable(&mut self, channel: <Pwm<T> as Pwm>::Channel)
[src]
pub fn disable(&mut self, channel: <Pwm<T> as Pwm>::Channel)
[src]
pub fn get_duty(
&self,
channel: <Pwm<T> as Pwm>::Channel
) -> <Pwm<T> as Pwm>::Duty
[src]
&self,
channel: <Pwm<T> as Pwm>::Channel
) -> <Pwm<T> as Pwm>::Duty
pub fn set_duty(
&mut self,
channel: <Pwm<T> as Pwm>::Channel,
duty: <Pwm<T> as Pwm>::Duty
)
[src]
&mut self,
channel: <Pwm<T> as Pwm>::Channel,
duty: <Pwm<T> as Pwm>::Duty
)
pub fn get_max_duty(&self) -> <Pwm<T> as Pwm>::Duty
[src]
pub fn get_period(&self) -> <Pwm<T> as Pwm>::Time
[src]
pub fn set_period<P>(&mut self, period: P) where
P: Into<<Pwm<T> as Pwm>::Time>,
[src]
P: Into<<Pwm<T> as Pwm>::Time>,