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]

pub fn new(pwm: T) -> Pwm<T>[src]

Takes ownership of the peripheral and applies sane defaults.

pub fn set_prescaler(&self, div: Prescaler) -> &Pwm<T>[src]

Sets the PWM clock prescaler.

pub fn prescaler(&self) -> Prescaler[src]

Sets the PWM clock prescaler.

pub fn set_max_duty(&self, duty: u16) -> &Pwm<T>[src]

Sets the maximum duty cycle value.

pub fn max_duty(&self) -> u16[src]

Returns the maximum duty cycle value.

pub fn set_period(&self, freq: Hertz) -> &Pwm<T>[src]

Sets the PWM output frequency.

pub fn period(&self) -> Hertz[src]

Returns the PWM output frequency.

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(&self)[src]

Enables the PWM generator.

pub fn disable(&self)[src]

Disables the PWM generator.

pub fn enable_channel(&self, channel: Channel) -> &Pwm<T>[src]

Enables a PWM channel.

pub fn disable_channel(&self, channel: Channel) -> &Pwm<T>[src]

Disables a PWM channel.

pub fn enable_group(&self, group: Group) -> &Pwm<T>[src]

Enables a PWM group.

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]

Cofigures how a sequence is read from RAM and is spread to the compare register.

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]

Selects operating mode of the wave counter.

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]

Selects source for advancing the active sequence.

pub fn step_mode(&self) -> StepMode[src]

Returns selected source for advancing the active sequence.

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]

Sets inverted duty cycle (15 bit) for all PWM channels. Will replace any ongoing sequence playback.

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]

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]

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]

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]

Returns duty cycle value for a PWM group.

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]

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]

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_on(&self, channel: Channel) -> u16[src]

Returns the duty cycle value for a PWM channel.

pub fn duty_off(&self, channel: Channel) -> u16[src]

Returns the inverted duty cycle value for a PWM group.

pub fn set_loop(&self, mode: Loop)[src]

Sets number of playbacks of sequences.

pub fn one_shot(&self) -> &Pwm<T>[src]

Looping disabled (stop at the end of the sequence).

pub fn loop_inf(&self) -> &Pwm<T>[src]

Loops playback of sequences indefinately.

pub fn repeat(&self, times: u16) -> &Pwm<T>[src]

Sets number of playbacks of sequences.

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]

Sets number of additional PWM periods after the sequence ends.

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]

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]

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]

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]

Enables interrupt triggering on the specified event.

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]

Checks if an event has been triggered.

pub fn reset_event(&self, event: PwmEvent)[src]

Marks event as handled.

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]

Returns reference to LoopsDone event endpoint for PPI.

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]

Returns reference to Seq0 End event endpoint for PPI.

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]

Returns reference to Seq0 Started event endpoint for PPI.

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]

Returns reference to Seq0 Start task endpoint for PPI.

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]

Returns reference to NextStep task endpoint for PPI.

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]

Returns individual handles to the four PWM channels.

pub fn split_groups(&self) -> (PwmGroup<'_, T>, PwmGroup<'_, T>)[src]

Returns individual handles to the two PWM groups.

pub fn free(self) -> T[src]

Consumes self and returns back the raw peripheral.

Trait Implementations

impl<T> Debug for Pwm<T> where
    T: Debug + Instance
[src]

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

Formats the value using the given formatter. Read more

impl<T> Pwm for Pwm<T> where
    T: Instance
[src]

type Channel = Channel

Enumeration of channels that can be used with this Pwm interface Read more

type Duty = u16

Type for the duty methods Read more

type Time = Hertz

A time unit that can be converted into a human time unit (e.g. seconds)

pub fn enable(&mut self, channel: <Pwm<T> as Pwm>::Channel)[src]

Enables a PWM channel

pub fn disable(&mut self, channel: <Pwm<T> as Pwm>::Channel)[src]

Disables a PWM channel

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]

Sets a new duty cycle

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]

Returns the current PWM period

pub fn set_period<P>(&mut self, period: P) where
    P: Into<<Pwm<T> as Pwm>::Time>, 
[src]

Sets a new PWM period

Auto Trait Implementations

impl<T> Send for Pwm<T> where
    T: Send

impl<T> Sync for Pwm<T> where
    T: Sync

impl<T> Unpin for Pwm<T> where
    T: Unpin

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Az for T[src]

pub fn az<Dst>(self) -> Dst where
    T: Cast<Dst>, 
[src]

Casts the value.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> CheckedAs for T[src]

pub fn checked_as<Dst>(self) -> Option<Dst> where
    T: CheckedCast<Dst>, 
[src]

Casts the value.

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<Src, Dst> LosslessTryInto<Dst> for Src where
    Dst: LosslessTryFrom<Src>, 
[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]

pub fn lossy_into(self) -> Dst[src]

Performs the conversion.

impl<T> OverflowingAs for T[src]

pub fn overflowing_as<Dst>(self) -> (Dst, bool) where
    T: OverflowingCast<Dst>, 
[src]

Casts the value.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> SaturatingAs for T[src]

pub fn saturating_as<Dst>(self) -> Dst where
    T: SaturatingCast<Dst>, 
[src]

Casts the value.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<T> UnwrappedAs for T[src]

pub fn unwrapped_as<Dst>(self) -> Dst where
    T: UnwrappedCast<Dst>, 
[src]

Casts the value.

impl<T> WrappingAs for T[src]

pub fn wrapping_as<Dst>(self) -> Dst where
    T: WrappingCast<Dst>, 
[src]

Casts the value.