Skip to main content

Channel

Struct Channel 

Source
pub struct Channel<'a, S: TimerSpeed> { /* private fields */ }
Expand description

Channel struct

Implementations§

Source§

impl<'a, S: TimerSpeed> Channel<'a, S>

Source

pub fn new(number: Number, output_pin: impl PeripheralOutput<'a>) -> Self

Returns a new channel.

Trait Implementations§

Source§

impl<S> ChannelHW for Channel<'_, S>
where S: TimerSpeed,

Available on crate feature unstable only.
Source§

fn configure_hw(&mut self) -> Result<(), Error>

Configures Channel HW.

Source§

fn set_duty_hw(&self, duty: u32)

Sets duty in channel HW.

Source§

fn start_duty_fade_hw( &self, start_duty: u32, duty_inc: bool, duty_steps: u16, cycles_per_step: u16, duty_per_cycle: u16, )

Starts a duty-cycle fade HW.

Source§

fn configure_hw_with_drive_mode(&mut self, cfg: DriveMode) -> Result<(), Error>

Configures the hardware for the channel with a specific pin configuration.
Source§

fn is_duty_fade_running_hw(&self) -> bool

Returns whether a duty-cycle fade is running HW.
Source§

impl<'a, S: TimerSpeed> ChannelIFace<'a, S> for Channel<'a, S>
where Channel<'a, S>: ChannelHW,

Available on crate feature unstable only.
Source§

fn configure(&mut self, config: Config<'a, S>) -> Result<(), Error>

Configures channel.

Source§

fn set_duty(&self, duty_pct: u8) -> Result<(), Error>

Sets duty % of channel.

Source§

fn start_duty_fade( &self, start_duty_pct: u8, end_duty_pct: u8, duration_ms: u16, ) -> Result<(), Error>

Starts a duty fade from one % to another.

There is a constraint on the combination of timer frequency, timer PWM duty resolution (the bit count), the fade “range” (abs(start-end)), and the duration:

frequency * duration / ((1<<bit_count) * abs(start-end)) < 1024

Small percentage changes, long durations, coarse PWM resolutions (that is, low bit counts), and high timer frequencies will all be more likely to fail this requirement. If it does fail, returns an error.

Source§

fn is_duty_fade_running(&self) -> bool

Returns whether a duty-cycle fade is running.
Source§

impl<S: TimerSpeed> ErrorType for Channel<'_, S>

Available on crate feature unstable only.
Source§

type Error = Error

Error type
Source§

impl<'a, S: TimerSpeed> SetDutyCycle for Channel<'a, S>
where Channel<'a, S>: ChannelHW,

Available on crate feature unstable only.
Source§

fn max_duty_cycle(&self) -> u16

Get the maximum duty cycle value. Read more
Source§

fn set_duty_cycle(&mut self, duty: u16) -> Result<(), Self::Error>

Set the duty cycle to duty / max_duty. Read more
Source§

fn set_duty_cycle_fully_off(&mut self) -> Result<(), Self::Error>

Set the duty cycle to 0%, or always inactive.
Source§

fn set_duty_cycle_fully_on(&mut self) -> Result<(), Self::Error>

Set the duty cycle to 100%, or always active.
Source§

fn set_duty_cycle_fraction( &mut self, num: u16, denom: u16, ) -> Result<(), Self::Error>

Set the duty cycle to num / denom. Read more
Source§

fn set_duty_cycle_percent(&mut self, percent: u8) -> Result<(), Self::Error>

Set the duty cycle to percent / 100 Read more

Auto Trait Implementations§

§

impl<'a, S> !RefUnwindSafe for Channel<'a, S>

§

impl<'a, S> !Send for Channel<'a, S>

§

impl<'a, S> !Sync for Channel<'a, S>

§

impl<'a, S> !UnwindSafe for Channel<'a, S>

§

impl<'a, S> Freeze for Channel<'a, S>
where Option<&'a dyn TimerIFace<S>>: Freeze,

§

impl<'a, S> Unpin for Channel<'a, S>
where Option<&'a dyn TimerIFace<S>>: Unpin,

§

impl<'a, S> UnsafeUnpin for Channel<'a, S>
where Option<&'a dyn TimerIFace<S>>: UnsafeUnpin,

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<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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.