Struct microbit::hal::pwm::Pwm [−][src]
pub struct Pwm<T> where
T: Instance, { /* fields omitted */ }
Expand description
A safe wrapper around the raw peripheral.
Implementations
impl<T> Pwm<T> where
T: Instance,
[src]
impl<T> Pwm<T> where
T: Instance,
[src]pub fn set_prescaler(&self, div: Prescaler) -> &Pwm<T>
[src]
pub fn set_prescaler(&self, div: Prescaler) -> &Pwm<T>
[src]Sets the PWM clock prescaler.
pub fn set_max_duty(&self, duty: u16) -> &Pwm<T>
[src]
pub fn set_max_duty(&self, duty: u16) -> &Pwm<T>
[src]Sets the maximum duty cycle value.
pub fn set_period(&self, freq: Hertz) -> &Pwm<T>
[src]
pub fn set_period(&self, freq: Hertz) -> &Pwm<T>
[src]Sets the PWM output frequency.
pub fn set_output_pin(
&self,
channel: Channel,
pin: &Pin<Output<PushPull>>
) -> &Pwm<T>
[src]
pub fn set_output_pin(
&self,
channel: Channel,
pin: &Pin<Output<PushPull>>
) -> &Pwm<T>
[src]Sets the associated output pin for the PWM channel and enables it.
pub fn enable_channel(&self, channel: Channel) -> &Pwm<T>
[src]
pub fn enable_channel(&self, channel: Channel) -> &Pwm<T>
[src]Enables a PWM channel.
pub fn disable_channel(&self, channel: Channel) -> &Pwm<T>
[src]
pub fn disable_channel(&self, channel: Channel) -> &Pwm<T>
[src]Disables a PWM channel.
pub fn enable_group(&self, group: Group) -> &Pwm<T>
[src]
pub fn enable_group(&self, group: Group) -> &Pwm<T>
[src]Enables a PWM group.
pub fn disable_group(&self, group: Group) -> &Pwm<T>
[src]
pub fn disable_group(&self, group: Group) -> &Pwm<T>
[src]Disables a PWM group.
pub fn set_load_mode(&self, mode: LoadMode) -> &Pwm<T>
[src]
pub fn set_load_mode(&self, mode: LoadMode) -> &Pwm<T>
[src]Cofigures how a sequence is read from RAM and is spread to the compare register.
pub fn load_mode(&self) -> LoadMode
[src]
pub fn load_mode(&self) -> LoadMode
[src]Returns how a sequence is read from RAM and is spread to the compare register.
pub fn set_counter_mode(&self, mode: CounterMode) -> &Pwm<T>
[src]
pub fn set_counter_mode(&self, mode: CounterMode) -> &Pwm<T>
[src]Selects operating mode of the wave counter.
pub fn counter_mode(&self) -> CounterMode
[src]
pub fn counter_mode(&self) -> CounterMode
[src]Returns selected operating mode of the wave counter.
pub fn set_step_mode(&self, mode: StepMode) -> &Pwm<T>
[src]
pub fn set_step_mode(&self, mode: StepMode) -> &Pwm<T>
[src]Selects source for advancing the active sequence.
pub fn set_duty_on_common(&self, duty: u16)
[src]
pub fn set_duty_on_common(&self, duty: u16)
[src]Sets duty cycle (15 bit) for all PWM channels. Will replace any ongoing sequence playback.
pub fn set_duty_off_common(&self, duty: u16)
[src]
pub fn set_duty_off_common(&self, duty: u16)
[src]Sets inverted duty cycle (15 bit) for all PWM channels. Will replace any ongoing sequence playback.
pub fn duty_on_common(&self) -> u16
[src]
pub fn duty_on_common(&self) -> u16
[src]Returns the common duty cycle value for all PWM channels in Common
load mode.
pub fn duty_off_common(&self) -> u16
[src]
pub fn duty_off_common(&self) -> u16
[src]Returns the inverted common duty cycle value for all PWM channels in Common
load mode.
pub fn set_duty_on_group(&self, group: Group, duty: u16)
[src]
pub fn set_duty_on_group(&self, group: Group, duty: u16)
[src]Sets duty cycle (15 bit) for a PWM group. Will replace any ongoing sequence playback.
pub fn set_duty_off_group(&self, group: Group, duty: u16)
[src]
pub fn set_duty_off_group(&self, group: Group, duty: u16)
[src]Sets inverted duty cycle (15 bit) for a PWM group. Will replace any ongoing sequence playback.
pub fn duty_on_group(&self, group: Group) -> u16
[src]
pub fn duty_on_group(&self, group: Group) -> u16
[src]Returns duty cycle value for a PWM group.
pub fn duty_off_group(&self, group: Group) -> u16
[src]
pub fn duty_off_group(&self, group: Group) -> u16
[src]Returns inverted duty cycle value for a PWM group.
pub fn set_duty_on(&self, channel: Channel, duty: u16)
[src]
pub fn set_duty_on(&self, channel: Channel, duty: u16)
[src]Sets duty cycle (15 bit) for a PWM channel. Will replace any ongoing sequence playback and the other channels will return to their previously set value.
pub fn set_duty_off(&self, channel: Channel, duty: u16)
[src]
pub fn set_duty_off(&self, channel: Channel, duty: u16)
[src]Sets inverted duty cycle (15 bit) for a PWM channel. Will replace any ongoing sequence playback and the other channels will return to their previously set value.
pub fn duty_off(&self, channel: Channel) -> u16
[src]
pub fn duty_off(&self, channel: Channel) -> u16
[src]Returns the inverted duty cycle value for a PWM group.
pub fn set_seq_refresh(&self, seq: Seq, periods: u32) -> &Pwm<T>
[src]
pub fn set_seq_refresh(&self, seq: Seq, periods: u32) -> &Pwm<T>
[src]Sets number of additional PWM periods between samples loaded into compare register.
pub fn set_seq_end_delay(&self, seq: Seq, periods: u32) -> &Pwm<T>
[src]
pub fn set_seq_end_delay(&self, seq: Seq, periods: u32) -> &Pwm<T>
[src]Sets number of additional PWM periods after the sequence ends.
pub fn start_seq(&self, seq: Seq)
[src]
pub fn start_seq(&self, seq: Seq)
[src]Loads the first PWM value on all enabled channels from a sequence and starts playing that sequence. Causes PWM generation to start if not running.
pub fn next_step(&self)
[src]
pub fn next_step(&self)
[src]Steps by one value in the current sequence on all enabled channels, if the NextStep
step mode is selected.
Does not cause PWM generation to start if not running.
pub fn stop(&self)
[src]
pub fn stop(&self)
[src]Stops PWM pulse generation on all channels at the end of current PWM period, and stops sequence playback.
pub fn load<B0, B1>(
self,
seq0_buffer: Option<B0>,
seq1_buffer: Option<B1>,
start: bool
) -> Result<PwmSeq<T, B0, B1>, (Error, Pwm<T>, Option<B0>, Option<B1>)> where
B0: ReadBuffer<Word = u16> + 'static,
B1: ReadBuffer<Word = u16> + 'static,
[src]
pub fn load<B0, B1>(
self,
seq0_buffer: Option<B0>,
seq1_buffer: Option<B1>,
start: bool
) -> Result<PwmSeq<T, B0, B1>, (Error, Pwm<T>, Option<B0>, Option<B1>)> where
B0: ReadBuffer<Word = u16> + 'static,
B1: ReadBuffer<Word = u16> + 'static,
[src]Loads the given sequence buffers and optionally (re-)starts sequence playback.
Returns a PemSeq
, containing Pwm<T>
and the buffers.
pub fn enable_interrupt(&self, event: PwmEvent) -> &Pwm<T>
[src]
pub fn enable_interrupt(&self, event: PwmEvent) -> &Pwm<T>
[src]Enables interrupt triggering on the specified event.
pub fn disable_interrupt(&self, event: PwmEvent) -> &Pwm<T>
[src]
pub fn disable_interrupt(&self, event: PwmEvent) -> &Pwm<T>
[src]Disables interrupt triggering on the specified event.
pub fn is_event_triggered(&self, event: PwmEvent) -> bool
[src]
pub fn is_event_triggered(&self, event: PwmEvent) -> bool
[src]Checks if an event has been triggered.
pub fn reset_event(&self, event: PwmEvent)
[src]
pub fn reset_event(&self, event: PwmEvent)
[src]Marks event as handled.
pub fn event_stopped(&self) -> &Reg<u32, _EVENTS_STOPPED>
[src]
pub fn event_stopped(&self) -> &Reg<u32, _EVENTS_STOPPED>
[src]Returns reference to Stopped
event endpoint for PPI.
pub fn event_loops_done(&self) -> &Reg<u32, _EVENTS_LOOPSDONE>
[src]
pub fn event_loops_done(&self) -> &Reg<u32, _EVENTS_LOOPSDONE>
[src]Returns reference to LoopsDone
event endpoint for PPI.
pub fn event_pwm_period_end(&self) -> &Reg<u32, _EVENTS_PWMPERIODEND>
[src]
pub fn event_pwm_period_end(&self) -> &Reg<u32, _EVENTS_PWMPERIODEND>
[src]Returns reference to PwmPeriodEnd
event endpoint for PPI.
pub fn event_seq0_end(&self) -> &Reg<u32, _EVENTS_SEQEND>
[src]
pub fn event_seq0_end(&self) -> &Reg<u32, _EVENTS_SEQEND>
[src]Returns reference to Seq0 End
event endpoint for PPI.
pub fn event_seq1_end(&self) -> &Reg<u32, _EVENTS_SEQEND>
[src]
pub fn event_seq1_end(&self) -> &Reg<u32, _EVENTS_SEQEND>
[src]Returns reference to Seq1 End
event endpoint for PPI.
pub fn event_seq0_started(&self) -> &Reg<u32, _EVENTS_SEQSTARTED>
[src]
pub fn event_seq0_started(&self) -> &Reg<u32, _EVENTS_SEQSTARTED>
[src]Returns reference to Seq0 Started
event endpoint for PPI.
pub fn event_seq1_started(&self) -> &Reg<u32, _EVENTS_SEQSTARTED>
[src]
pub fn event_seq1_started(&self) -> &Reg<u32, _EVENTS_SEQSTARTED>
[src]Returns reference to Seq1 Started
event endpoint for PPI.
pub fn task_start_seq0(&self) -> &Reg<u32, _TASKS_SEQSTART>
[src]
pub fn task_start_seq0(&self) -> &Reg<u32, _TASKS_SEQSTART>
[src]Returns reference to Seq0 Start
task endpoint for PPI.
pub fn task_start_seq1(&self) -> &Reg<u32, _TASKS_SEQSTART>
[src]
pub fn task_start_seq1(&self) -> &Reg<u32, _TASKS_SEQSTART>
[src]Returns reference to Seq1 Started
task endpoint for PPI.
pub fn task_next_step(&self) -> &Reg<u32, _TASKS_NEXTSTEP>
[src]
pub fn task_next_step(&self) -> &Reg<u32, _TASKS_NEXTSTEP>
[src]Returns reference to NextStep
task endpoint for PPI.
pub fn task_stop(&self) -> &Reg<u32, _TASKS_STOP>
[src]
pub fn task_stop(&self) -> &Reg<u32, _TASKS_STOP>
[src]Returns reference to Stop
task endpoint for PPI.
pub fn split_channels(
&self
) -> (PwmChannel<'_, T>, PwmChannel<'_, T>, PwmChannel<'_, T>, PwmChannel<'_, T>)
[src]
pub fn split_channels(
&self
) -> (PwmChannel<'_, T>, PwmChannel<'_, T>, PwmChannel<'_, T>, PwmChannel<'_, T>)
[src]Returns individual handles to the four PWM channels.
pub fn split_groups(&self) -> (PwmGroup<'_, T>, PwmGroup<'_, T>)
[src]
pub fn split_groups(&self) -> (PwmGroup<'_, T>, PwmGroup<'_, T>)
[src]Returns individual handles to the two PWM groups.
Trait Implementations
impl<T> Pwm for Pwm<T> where
T: Instance,
[src]
impl<T> Pwm for Pwm<T> where
T: Instance,
[src]pub fn get_duty(
&self,
channel: <Pwm<T> as Pwm>::Channel
) -> <Pwm<T> as Pwm>::Duty
[src]
pub fn get_duty(
&self,
channel: <Pwm<T> as Pwm>::Channel
) -> <Pwm<T> as Pwm>::Duty
[src]Returns the current duty cycle
pub fn set_duty(
&mut self,
channel: <Pwm<T> as Pwm>::Channel,
duty: <Pwm<T> as Pwm>::Duty
)
[src]
pub fn set_duty(
&mut self,
channel: <Pwm<T> as Pwm>::Channel,
duty: <Pwm<T> as Pwm>::Duty
)
[src]Sets a new duty cycle
pub fn get_max_duty(&self) -> <Pwm<T> as Pwm>::Duty
[src]
pub fn get_max_duty(&self) -> <Pwm<T> as Pwm>::Duty
[src]Returns the maximum duty cycle value
pub fn get_period(&self) -> <Pwm<T> as Pwm>::Time
[src]
pub fn get_period(&self) -> <Pwm<T> as Pwm>::Time
[src]Returns the current PWM period
Auto Trait Implementations
impl<T> Send for Pwm<T> where
T: Send,
T: Send,
impl<T> Sync for Pwm<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Pwm<T> where
T: Unpin,
T: Unpin,
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> CheckedAs for T
[src]
impl<T> CheckedAs for T
[src]pub fn checked_as<Dst>(self) -> Option<Dst> where
T: CheckedCast<Dst>,
[src]
pub fn checked_as<Dst>(self) -> Option<Dst> where
T: CheckedCast<Dst>,
[src]Casts the value.
impl<Src, Dst> LosslessTryInto<Dst> for Src where
Dst: LosslessTryFrom<Src>,
[src]
impl<Src, Dst> LosslessTryInto<Dst> for Src where
Dst: LosslessTryFrom<Src>,
[src]pub fn lossless_try_into(self) -> Option<Dst>
[src]
pub fn lossless_try_into(self) -> Option<Dst>
[src]Performs the conversion.
impl<Src, Dst> LossyInto<Dst> for Src where
Dst: LossyFrom<Src>,
[src]
impl<Src, Dst> LossyInto<Dst> for Src where
Dst: LossyFrom<Src>,
[src]pub fn lossy_into(self) -> Dst
[src]
pub fn lossy_into(self) -> Dst
[src]Performs the conversion.
impl<T> OverflowingAs for T
[src]
impl<T> OverflowingAs for T
[src]pub fn overflowing_as<Dst>(self) -> (Dst, bool) where
T: OverflowingCast<Dst>,
[src]
pub fn overflowing_as<Dst>(self) -> (Dst, bool) where
T: OverflowingCast<Dst>,
[src]Casts the value.
impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
type Output = T
Should always be Self
impl<T> SaturatingAs for T
[src]
impl<T> SaturatingAs for T
[src]pub fn saturating_as<Dst>(self) -> Dst where
T: SaturatingCast<Dst>,
[src]
pub fn saturating_as<Dst>(self) -> Dst where
T: SaturatingCast<Dst>,
[src]Casts the value.
impl<T> UnwrappedAs for T
[src]
impl<T> UnwrappedAs for T
[src]pub fn unwrapped_as<Dst>(self) -> Dst where
T: UnwrappedCast<Dst>,
[src]
pub fn unwrapped_as<Dst>(self) -> Dst where
T: UnwrappedCast<Dst>,
[src]Casts the value.
impl<T> WrappingAs for T
[src]
impl<T> WrappingAs for T
[src]pub fn wrapping_as<Dst>(self) -> Dst where
T: WrappingCast<Dst>,
[src]
pub fn wrapping_as<Dst>(self) -> Dst where
T: WrappingCast<Dst>,
[src]Casts the value.