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>,
impl<I, M> Slice<I, M>where
I: SliceId,
M: ValidSliceMode<I>,
sourcepub fn into_mode<N: ValidSliceMode<I>>(self) -> Slice<I, N>
pub fn into_mode<N: ValidSliceMode<I>>(self) -> Slice<I, N>
Convert the slice to the requested SliceMode
sourcepub fn default_config(&mut self)
pub fn default_config(&mut self)
Set a default config for the slice
sourcepub fn advance_phase(&mut self)
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)
sourcepub fn retard_phase(&mut self)
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)
sourcepub fn set_ph_correct(&mut self)
pub fn set_ph_correct(&mut self)
Enable phase correct mode
sourcepub fn clr_ph_correct(&mut self)
pub fn clr_ph_correct(&mut self)
Disables phase correct mode
sourcepub fn set_div_int(&mut self, value: u8)
pub fn set_div_int(&mut self, value: u8)
Sets the integer part of the clock divider
sourcepub fn set_div_frac(&mut self, value: u8)
pub fn set_div_frac(&mut self, value: u8)
Sets the fractional part of the clock divider
sourcepub fn get_counter(&self) -> u16
pub fn get_counter(&self) -> u16
Get the counter register value
sourcepub fn set_counter(&mut self, value: u16)
pub fn set_counter(&mut self, value: u16)
Set the counter register value
sourcepub fn set_top(&mut self, value: u16)
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%.
sourcepub fn enable_interrupt(&mut self)
pub fn enable_interrupt(&mut self)
Enable the PWM_IRQ_WRAP interrupt when this slice overflows.
sourcepub fn disable_interrupt(&mut self)
pub fn disable_interrupt(&mut self)
Disable the PWM_IRQ_WRAP interrupt for this slice.
sourcepub fn has_overflown(&self) -> bool
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.
sourcepub fn clear_interrupt(&mut self)
pub fn clear_interrupt(&mut self)
Mark the interrupt handled for this slice.
sourcepub fn force_interrupt(&mut self)
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.
sourcepub fn clear_force_interrupt(&mut self)
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>
impl<S: SliceId, M: ValidSliceMode<S>> Slice<S, M>
sourcepub fn output_to<P: AnyPin, C: ChannelId>(
&mut self,
pin: P
) -> Pin<P::Id, FunctionPwm, P::Pull>where
P::Id: ValidPwmOutputPin<S, C>,
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>
impl<S: SliceId, M: ValidSliceInputMode<S>> Slice<S, M>
sourcepub fn input_from<P: AnyPin>(
&mut self,
pin: P
) -> Pin<P::Id, FunctionPwm, P::Pull>where
P::Id: ValidPwmInputPin<S>,
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: SliceId, M: ValidSliceMode<S>> From<Slice<S, M>> for SliceDmaWrite<S, M>
impl<S: SliceId, M: ValidSliceMode<S>> From<Slice<S, M>> for SliceDmaWrite<S, M>
source§impl<S: SliceId, M: ValidSliceMode<S>> From<SliceDmaWrite<S, M>> for Slice<S, M>
impl<S: SliceId, M: ValidSliceMode<S>> From<SliceDmaWrite<S, M>> for Slice<S, M>
source§fn from(value: SliceDmaWrite<S, M>) -> Self
fn from(value: SliceDmaWrite<S, M>) -> Self
Auto Trait Implementations§
impl<I, M> Freeze for Slice<I, M>
impl<I, M> RefUnwindSafe for Slice<I, M>where
M: RefUnwindSafe,
I: RefUnwindSafe,
impl<I, M> Send for Slice<I, M>
impl<I, M> Sync for Slice<I, M>
impl<I, M> Unpin for Slice<I, M>
impl<I, M> UnwindSafe for Slice<I, M>where
M: UnwindSafe,
I: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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