Struct rp2040_hal::pwm::Slice

source ·
pub struct Slice<I, M>
where I: SliceId, M: ValidSliceMode<I>,
{ pub channel_a: Channel<Self, A>, pub channel_b: Channel<Self, B>, /* private fields */ }
Expand description

Pwm slice

Fields§

§channel_a: Channel<Self, A>

Channel A (always output)

§channel_b: Channel<Self, B>

Channel B (input or output)

Implementations§

source§

impl<I, M> Slice<I, M>
where I: SliceId, M: ValidSliceMode<I>,

source

pub fn into_mode<N: ValidSliceMode<I>>(self) -> Slice<I, N>

Convert the slice to the requested SliceMode

source

pub fn default_config(&mut self)

Set a default config for the slice

source

pub fn advance_phase(&mut self)

Advance the phase with one count

Counter must be running at less than full speed (div_int + div_frac / 16 > 1)

source

pub fn retard_phase(&mut self)

Retard the phase with one count

Counter must be running at less than full speed (div_int + div_frac / 16 > 1)

source

pub fn set_ph_correct(&mut self)

Enable phase correct mode

source

pub fn clr_ph_correct(&mut self)

Disables phase correct mode

source

pub fn enable(&mut self)

Enable slice

source

pub fn disable(&mut self)

Disable slice

source

pub fn set_div_int(&mut self, value: u8)

Sets the integer part of the clock divider

source

pub fn set_div_frac(&mut self, value: u8)

Sets the fractional part of the clock divider

source

pub fn get_counter(&self) -> u16

Get the counter register value

source

pub fn set_counter(&mut self, value: u16)

Set the counter register value

source

pub fn get_top(&self) -> u16

Get the top register value

source

pub fn set_top(&mut self, value: u16)

Sets the top register value

Don’t set this to 0xffff if you need true 100% duty cycle:

The CC register, which is used to configure the duty cycle, must be set to TOP + 1 for 100% duty cycle, but also is a 16 bit register.

In case you do set TOP to 0xffff, SetDutyCycle::set_duty_cycle will slightly violate the trait’s documentation, as SetDutyCycle::set_duty_cycle_fully_on and other calls that should lead to 100% duty cycle will only reach a duty cycle of about 99.998%.

source

pub fn enable_interrupt(&mut self)

Enable the PWM_IRQ_WRAP interrupt when this slice overflows.

source

pub fn disable_interrupt(&mut self)

Disable the PWM_IRQ_WRAP interrupt for this slice.

source

pub fn has_overflown(&self) -> bool

Did this slice trigger an overflow interrupt?

This reports the raw interrupt flag, without considering masking or forcing bits. It may return true even if the interrupt is disabled or false even if the interrupt is forced.

source

pub fn clear_interrupt(&mut self)

Mark the interrupt handled for this slice.

source

pub fn force_interrupt(&mut self)

Force the interrupt. This bit is not cleared by hardware and must be manually cleared to stop the interrupt from continuing to be asserted.

source

pub fn clear_force_interrupt(&mut self)

Clear force interrupt. This bit is not cleared by hardware and must be manually cleared to stop the interrupt from continuing to be asserted.

source§

impl<S: SliceId, M: ValidSliceMode<S>> Slice<S, M>

source

pub fn output_to<P: AnyPin, C: ChannelId>( &mut self, pin: P ) -> Pin<P::Id, FunctionPwm, P::Pull>
where P::Id: ValidPwmOutputPin<S, C>,

Capture a gpio pin and use it as pwm output

source§

impl<S: SliceId, M: ValidSliceInputMode<S>> Slice<S, M>

source

pub fn input_from<P: AnyPin>( &mut self, pin: P ) -> Pin<P::Id, FunctionPwm, P::Pull>
where P::Id: ValidPwmInputPin<S>,

Capture a gpio pin and use it as pwm input for channel B

Trait Implementations§

source§

impl<S, M> AnySlice for Slice<S, M>
where S: SliceId, M: ValidSliceMode<S>,

§

type Id = S

SliceId of the corresponding Slice
§

type Mode = M

SliceMode of the corresponding Slice
source§

impl<S: SliceId, M: ValidSliceMode<S>> From<Slice<S, M>> for SliceDmaWrite<S, M>

source§

fn from(value: Slice<S, M>) -> Self

Converts to this type from the input type.
source§

impl<S: SliceId, M: ValidSliceMode<S>> From<SliceDmaWrite<S, M>> for Slice<S, M>

source§

fn from(value: SliceDmaWrite<S, M>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<I, M> Freeze for Slice<I, M>

§

impl<I, M> RefUnwindSafe for Slice<I, M>

§

impl<I, M> Send for Slice<I, M>
where M: Send, I: Send,

§

impl<I, M> Sync for Slice<I, M>
where M: Sync, I: Sync,

§

impl<I, M> Unpin for Slice<I, M>
where M: Unpin, I: Unpin,

§

impl<I, M> UnwindSafe for Slice<I, M>
where M: UnwindSafe, I: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Choices> CoproductSubsetter<CNil, HNil> for Choices

§

type Remainder = Choices

source§

fn subset( self ) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>

Extract a subset of the possible types in a coproduct (or get the remaining possibilities) Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> Is for T
where T: Sealed + Borrow<T> + BorrowMut<T>,

§

type Type = T

source§

impl<T, U, I> LiftInto<U, I> for T
where U: LiftFrom<T, I>,

source§

fn lift_into(self) -> U

Performs the indexed conversion.
source§

impl<Source> Sculptor<HNil, HNil> for Source

§

type Remainder = Source

source§

fn sculpt(self) -> (HNil, <Source as Sculptor<HNil, HNil>>::Remainder)

Consumes the current HList and returns an HList with the requested shape. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

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

Performs the conversion.