Struct nrf52832_hal::pwm::Pwm
source · pub struct Pwm<T>where
T: Instance,{ /* private fields */ }
Expand description
A safe wrapper around the raw peripheral.
Implementations§
source§impl<T> Pwm<T>where
T: Instance,
impl<T> Pwm<T>where
T: Instance,
sourcepub fn set_prescaler(&self, div: Prescaler) -> &Pwm<T>
pub fn set_prescaler(&self, div: Prescaler) -> &Pwm<T>
Sets the PWM clock prescaler.
sourcepub fn set_max_duty(&self, duty: u16) -> &Pwm<T>
pub fn set_max_duty(&self, duty: u16) -> &Pwm<T>
Sets the maximum duty cycle value.
sourcepub fn set_period(&self, freq: Hertz) -> &Pwm<T>
pub fn set_period(&self, freq: Hertz) -> &Pwm<T>
Sets the PWM output frequency.
sourcepub fn set_output_pin(
&self,
channel: Channel,
pin: Pin<Output<PushPull>>
) -> &Pwm<T>
pub fn set_output_pin( &self, channel: Channel, pin: Pin<Output<PushPull>> ) -> &Pwm<T>
Sets the associated output pin for the PWM channel.
Modifying the pin configuration while the PWM instance is enabled is not recommended.
sourcepub fn swap_output_pin(
&mut self,
channel: Channel,
pin: Pin<Output<PushPull>>
) -> Option<Pin<Output<PushPull>>>
pub fn swap_output_pin( &mut self, channel: Channel, pin: Pin<Output<PushPull>> ) -> Option<Pin<Output<PushPull>>>
Sets the output pin of channel
, and returns the old pin (if any).
Modifying the pin configuration while the PWM instance is enabled is not recommended.
sourcepub fn clear_output_pin(
&mut self,
channel: Channel
) -> Option<Pin<Output<PushPull>>>
pub fn clear_output_pin( &mut self, channel: Channel ) -> Option<Pin<Output<PushPull>>>
Disables the output pin of channel
.
The output pin is returned, if one was previously configured.
Modifying the pin configuration while the PWM instance is enabled is not recommended.
sourcepub fn enable_channel(&self, channel: Channel) -> &Pwm<T>
pub fn enable_channel(&self, channel: Channel) -> &Pwm<T>
Enables a PWM channel.
sourcepub fn disable_channel(&self, channel: Channel) -> &Pwm<T>
pub fn disable_channel(&self, channel: Channel) -> &Pwm<T>
Disables a PWM channel.
sourcepub fn enable_group(&self, group: Group) -> &Pwm<T>
pub fn enable_group(&self, group: Group) -> &Pwm<T>
Enables a PWM group.
sourcepub fn disable_group(&self, group: Group) -> &Pwm<T>
pub fn disable_group(&self, group: Group) -> &Pwm<T>
Disables a PWM group.
sourcepub fn set_load_mode(&self, mode: LoadMode) -> &Pwm<T>
pub fn set_load_mode(&self, mode: LoadMode) -> &Pwm<T>
Cofigures how a sequence is read from RAM and is spread to the compare register.
sourcepub fn load_mode(&self) -> LoadMode
pub fn load_mode(&self) -> LoadMode
Returns how a sequence is read from RAM and is spread to the compare register.
sourcepub fn set_counter_mode(&self, mode: CounterMode) -> &Pwm<T>
pub fn set_counter_mode(&self, mode: CounterMode) -> &Pwm<T>
Selects operating mode of the wave counter.
sourcepub fn counter_mode(&self) -> CounterMode
pub fn counter_mode(&self) -> CounterMode
Returns selected operating mode of the wave counter.
sourcepub fn set_step_mode(&self, mode: StepMode) -> &Pwm<T>
pub fn set_step_mode(&self, mode: StepMode) -> &Pwm<T>
Selects source for advancing the active sequence.
sourcepub fn set_duty_on_common(&self, duty: u16)
pub fn set_duty_on_common(&self, duty: u16)
Sets duty cycle (15 bit) for all PWM channels. Will replace any ongoing sequence playback.
sourcepub fn set_duty_off_common(&self, duty: u16)
pub fn set_duty_off_common(&self, duty: u16)
Sets inverted duty cycle (15 bit) for all PWM channels. Will replace any ongoing sequence playback.
sourcepub fn duty_on_common(&self) -> u16
pub fn duty_on_common(&self) -> u16
Returns the common duty cycle value for all PWM channels in Common
load mode.
sourcepub fn duty_off_common(&self) -> u16
pub fn duty_off_common(&self) -> u16
Returns the inverted common duty cycle value for all PWM channels in Common
load mode.
sourcepub fn set_duty_on_group(&self, group: Group, duty: u16)
pub fn set_duty_on_group(&self, group: Group, duty: u16)
Sets duty cycle (15 bit) for a PWM group. Will replace any ongoing sequence playback.
sourcepub fn set_duty_off_group(&self, group: Group, duty: u16)
pub fn set_duty_off_group(&self, group: Group, duty: u16)
Sets inverted duty cycle (15 bit) for a PWM group. Will replace any ongoing sequence playback.
sourcepub fn duty_on_group(&self, group: Group) -> u16
pub fn duty_on_group(&self, group: Group) -> u16
Returns duty cycle value for a PWM group.
sourcepub fn duty_off_group(&self, group: Group) -> u16
pub fn duty_off_group(&self, group: Group) -> u16
Returns inverted duty cycle value for a PWM group.
sourcepub fn set_duty_on(&self, channel: Channel, duty: u16)
pub fn set_duty_on(&self, channel: Channel, duty: u16)
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.
sourcepub fn set_duty_off(&self, channel: Channel, duty: u16)
pub fn set_duty_off(&self, channel: Channel, duty: u16)
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.
sourcepub fn duty_off(&self, channel: Channel) -> u16
pub fn duty_off(&self, channel: Channel) -> u16
Returns the inverted duty cycle value for a PWM group.
sourcepub fn set_seq_refresh(&self, seq: Seq, periods: u32) -> &Pwm<T>
pub fn set_seq_refresh(&self, seq: Seq, periods: u32) -> &Pwm<T>
Sets number of additional PWM periods between samples loaded into compare register.
sourcepub fn set_seq_end_delay(&self, seq: Seq, periods: u32) -> &Pwm<T>
pub fn set_seq_end_delay(&self, seq: Seq, periods: u32) -> &Pwm<T>
Sets number of additional PWM periods after the sequence ends.
sourcepub fn start_seq(&self, seq: Seq)
pub fn start_seq(&self, seq: Seq)
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.
sourcepub fn next_step(&self)
pub fn next_step(&self)
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.
sourcepub fn stop(&self)
pub fn stop(&self)
Stops PWM pulse generation on all channels at the end of current PWM period, and stops sequence playback.
sourcepub 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>)>
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>)>
Loads the given sequence buffers and optionally (re-)starts sequence playback.
Returns a PemSeq
, containing Pwm<T>
and the buffers.
sourcepub fn enable_interrupt(&self, event: PwmEvent) -> &Pwm<T>
pub fn enable_interrupt(&self, event: PwmEvent) -> &Pwm<T>
Enables interrupt triggering on the specified event.
sourcepub fn disable_interrupt(&self, event: PwmEvent) -> &Pwm<T>
pub fn disable_interrupt(&self, event: PwmEvent) -> &Pwm<T>
Disables interrupt triggering on the specified event.
sourcepub fn is_event_triggered(&self, event: PwmEvent) -> bool
pub fn is_event_triggered(&self, event: PwmEvent) -> bool
Checks if an event has been triggered.
sourcepub fn reset_event(&self, event: PwmEvent)
pub fn reset_event(&self, event: PwmEvent)
Marks event as handled.
sourcepub fn event_stopped(&self) -> &Reg<EVENTS_STOPPED_SPEC>
pub fn event_stopped(&self) -> &Reg<EVENTS_STOPPED_SPEC>
Returns reference to Stopped
event endpoint for PPI.
sourcepub fn event_loops_done(&self) -> &Reg<EVENTS_LOOPSDONE_SPEC>
pub fn event_loops_done(&self) -> &Reg<EVENTS_LOOPSDONE_SPEC>
Returns reference to LoopsDone
event endpoint for PPI.
sourcepub fn event_pwm_period_end(&self) -> &Reg<EVENTS_PWMPERIODEND_SPEC>
pub fn event_pwm_period_end(&self) -> &Reg<EVENTS_PWMPERIODEND_SPEC>
Returns reference to PwmPeriodEnd
event endpoint for PPI.
sourcepub fn event_seq0_end(&self) -> &Reg<EVENTS_SEQEND_SPEC>
pub fn event_seq0_end(&self) -> &Reg<EVENTS_SEQEND_SPEC>
Returns reference to Seq0 End
event endpoint for PPI.
sourcepub fn event_seq1_end(&self) -> &Reg<EVENTS_SEQEND_SPEC>
pub fn event_seq1_end(&self) -> &Reg<EVENTS_SEQEND_SPEC>
Returns reference to Seq1 End
event endpoint for PPI.
sourcepub fn event_seq0_started(&self) -> &Reg<EVENTS_SEQSTARTED_SPEC>
pub fn event_seq0_started(&self) -> &Reg<EVENTS_SEQSTARTED_SPEC>
Returns reference to Seq0 Started
event endpoint for PPI.
sourcepub fn event_seq1_started(&self) -> &Reg<EVENTS_SEQSTARTED_SPEC>
pub fn event_seq1_started(&self) -> &Reg<EVENTS_SEQSTARTED_SPEC>
Returns reference to Seq1 Started
event endpoint for PPI.
sourcepub fn task_start_seq0(&self) -> &Reg<TASKS_SEQSTART_SPEC>
pub fn task_start_seq0(&self) -> &Reg<TASKS_SEQSTART_SPEC>
Returns reference to Seq0 Start
task endpoint for PPI.
sourcepub fn task_start_seq1(&self) -> &Reg<TASKS_SEQSTART_SPEC>
pub fn task_start_seq1(&self) -> &Reg<TASKS_SEQSTART_SPEC>
Returns reference to Seq1 Started
task endpoint for PPI.
sourcepub fn task_next_step(&self) -> &Reg<TASKS_NEXTSTEP_SPEC>
pub fn task_next_step(&self) -> &Reg<TASKS_NEXTSTEP_SPEC>
Returns reference to NextStep
task endpoint for PPI.
sourcepub fn task_stop(&self) -> &Reg<TASKS_STOP_SPEC>
pub fn task_stop(&self) -> &Reg<TASKS_STOP_SPEC>
Returns reference to Stop
task endpoint for PPI.
sourcepub fn split_channels(
&self
) -> (PwmChannel<'_, T>, PwmChannel<'_, T>, PwmChannel<'_, T>, PwmChannel<'_, T>)
pub fn split_channels( &self ) -> (PwmChannel<'_, T>, PwmChannel<'_, T>, PwmChannel<'_, T>, PwmChannel<'_, T>)
Returns individual handles to the four PWM channels.
sourcepub fn split_groups(&self) -> (PwmGroup<'_, T>, PwmGroup<'_, T>)
pub fn split_groups(&self) -> (PwmGroup<'_, T>, PwmGroup<'_, T>)
Returns individual handles to the two PWM groups.