[−][src]Trait atsame54_xpro::prelude::_embedded_hal_Pwm
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
type Channel
[src]
Enumeration of channels that can be used with this Pwm
interface
If your Pwm
interface has no channels you can use the type ()
here
type Time
[src]
A time unit that can be converted into a human time unit (e.g. seconds)
type Duty
[src]
Type for the duty
methods
The implementer is free to choose a float / percentage representation
(e.g. 0.0 .. 1.0
) or an integer representation (e.g. 0 .. 65535
)
Required methods
pub fn disable(&mut self, channel: Self::Channel)
[src]
Disables a PWM channel
pub fn enable(&mut self, channel: Self::Channel)
[src]
Enables a PWM channel
pub fn get_period(&self) -> Self::Time
[src]
Returns the current PWM period
pub fn get_duty(&self, channel: Self::Channel) -> Self::Duty
[src]
Returns the current duty cycle
pub fn get_max_duty(&self) -> Self::Duty
[src]
Returns the maximum duty cycle value
pub fn set_duty(&mut self, channel: Self::Channel, duty: Self::Duty)
[src]
Sets a new duty cycle
pub fn set_period<P>(&mut self, period: P) where
P: Into<Self::Time>,
[src]
P: Into<Self::Time>,
Sets a new PWM period
Implementors
impl Pwm for Tcc0Pwm
[src]
type Channel = Channel
type Time = Hertz
type Duty = u32
pub fn disable(&mut self, _channel: <Tcc0Pwm as Pwm>::Channel)
[src]
pub fn enable(&mut self, _channel: <Tcc0Pwm as Pwm>::Channel)
[src]
pub fn get_period(&self) -> <Tcc0Pwm as Pwm>::Time
[src]
pub fn get_duty(
&self,
channel: <Tcc0Pwm as Pwm>::Channel
) -> <Tcc0Pwm as Pwm>::Duty
[src]
&self,
channel: <Tcc0Pwm as Pwm>::Channel
) -> <Tcc0Pwm as Pwm>::Duty
pub fn get_max_duty(&self) -> <Tcc0Pwm as Pwm>::Duty
[src]
pub fn set_duty(
&mut self,
channel: <Tcc0Pwm as Pwm>::Channel,
duty: <Tcc0Pwm as Pwm>::Duty
)
[src]
&mut self,
channel: <Tcc0Pwm as Pwm>::Channel,
duty: <Tcc0Pwm as Pwm>::Duty
)
pub fn set_period<P>(&mut self, period: P) where
P: Into<<Tcc0Pwm as Pwm>::Time>,
[src]
P: Into<<Tcc0Pwm as Pwm>::Time>,
impl Pwm for Tcc1Pwm
[src]
type Channel = Channel
type Time = Hertz
type Duty = u32
pub fn disable(&mut self, _channel: <Tcc1Pwm as Pwm>::Channel)
[src]
pub fn enable(&mut self, _channel: <Tcc1Pwm as Pwm>::Channel)
[src]
pub fn get_period(&self) -> <Tcc1Pwm as Pwm>::Time
[src]
pub fn get_duty(
&self,
channel: <Tcc1Pwm as Pwm>::Channel
) -> <Tcc1Pwm as Pwm>::Duty
[src]
&self,
channel: <Tcc1Pwm as Pwm>::Channel
) -> <Tcc1Pwm as Pwm>::Duty
pub fn get_max_duty(&self) -> <Tcc1Pwm as Pwm>::Duty
[src]
pub fn set_duty(
&mut self,
channel: <Tcc1Pwm as Pwm>::Channel,
duty: <Tcc1Pwm as Pwm>::Duty
)
[src]
&mut self,
channel: <Tcc1Pwm as Pwm>::Channel,
duty: <Tcc1Pwm as Pwm>::Duty
)
pub fn set_period<P>(&mut self, period: P) where
P: Into<<Tcc1Pwm as Pwm>::Time>,
[src]
P: Into<<Tcc1Pwm as Pwm>::Time>,
impl Pwm for Tcc2Pwm
[src]
type Channel = Channel
type Time = Hertz
type Duty = u32
pub fn disable(&mut self, _channel: <Tcc2Pwm as Pwm>::Channel)
[src]
pub fn enable(&mut self, _channel: <Tcc2Pwm as Pwm>::Channel)
[src]
pub fn get_period(&self) -> <Tcc2Pwm as Pwm>::Time
[src]
pub fn get_duty(
&self,
channel: <Tcc2Pwm as Pwm>::Channel
) -> <Tcc2Pwm as Pwm>::Duty
[src]
&self,
channel: <Tcc2Pwm as Pwm>::Channel
) -> <Tcc2Pwm as Pwm>::Duty
pub fn get_max_duty(&self) -> <Tcc2Pwm as Pwm>::Duty
[src]
pub fn set_duty(
&mut self,
channel: <Tcc2Pwm as Pwm>::Channel,
duty: <Tcc2Pwm as Pwm>::Duty
)
[src]
&mut self,
channel: <Tcc2Pwm as Pwm>::Channel,
duty: <Tcc2Pwm as Pwm>::Duty
)
pub fn set_period<P>(&mut self, period: P) where
P: Into<<Tcc2Pwm as Pwm>::Time>,
[src]
P: Into<<Tcc2Pwm as Pwm>::Time>,
impl Pwm for Tcc3Pwm
[src]
type Channel = Channel
type Time = Hertz
type Duty = u32
pub fn disable(&mut self, _channel: <Tcc3Pwm as Pwm>::Channel)
[src]
pub fn enable(&mut self, _channel: <Tcc3Pwm as Pwm>::Channel)
[src]
pub fn get_period(&self) -> <Tcc3Pwm as Pwm>::Time
[src]
pub fn get_duty(
&self,
channel: <Tcc3Pwm as Pwm>::Channel
) -> <Tcc3Pwm as Pwm>::Duty
[src]
&self,
channel: <Tcc3Pwm as Pwm>::Channel
) -> <Tcc3Pwm as Pwm>::Duty
pub fn get_max_duty(&self) -> <Tcc3Pwm as Pwm>::Duty
[src]
pub fn set_duty(
&mut self,
channel: <Tcc3Pwm as Pwm>::Channel,
duty: <Tcc3Pwm as Pwm>::Duty
)
[src]
&mut self,
channel: <Tcc3Pwm as Pwm>::Channel,
duty: <Tcc3Pwm as Pwm>::Duty
)
pub fn set_period<P>(&mut self, period: P) where
P: Into<<Tcc3Pwm as Pwm>::Time>,
[src]
P: Into<<Tcc3Pwm as Pwm>::Time>,
impl Pwm for Tcc4Pwm
[src]
type Channel = Channel
type Time = Hertz
type Duty = u32
pub fn disable(&mut self, _channel: <Tcc4Pwm as Pwm>::Channel)
[src]
pub fn enable(&mut self, _channel: <Tcc4Pwm as Pwm>::Channel)
[src]
pub fn get_period(&self) -> <Tcc4Pwm as Pwm>::Time
[src]
pub fn get_duty(
&self,
channel: <Tcc4Pwm as Pwm>::Channel
) -> <Tcc4Pwm as Pwm>::Duty
[src]
&self,
channel: <Tcc4Pwm as Pwm>::Channel
) -> <Tcc4Pwm as Pwm>::Duty
pub fn get_max_duty(&self) -> <Tcc4Pwm as Pwm>::Duty
[src]
pub fn set_duty(
&mut self,
channel: <Tcc4Pwm as Pwm>::Channel,
duty: <Tcc4Pwm as Pwm>::Duty
)
[src]
&mut self,
channel: <Tcc4Pwm as Pwm>::Channel,
duty: <Tcc4Pwm as Pwm>::Duty
)
pub fn set_period<P>(&mut self, period: P) where
P: Into<<Tcc4Pwm as Pwm>::Time>,
[src]
P: Into<<Tcc4Pwm as Pwm>::Time>,