Struct BasicTimer

Source
pub struct BasicTimer<R> {
    pub regs: R,
    /* private fields */
}
Expand description

Represents a Basic timer, used primarily to trigger the onboard DAC. Eg Tim6 or Tim7.

Fields§

§regs: R

Implementations§

Source§

impl<R> BasicTimer<R>
where R: Deref<Target = RegisterBlock> + RccPeriph,

Source

pub fn new(regs: R, freq: f32, clock_cfg: &Clocks) -> Self

Initialize a Basic timer, including enabling and resetting its RCC peripheral clock.

Source

pub fn enable(&mut self)

Enable the timer.

Source

pub fn disable(&mut self)

Disable the timer.

Source

pub fn is_enabled(&self) -> bool

Check if the timer is enabled.

Source

pub fn set_period(&mut self, time: f32) -> Result<(), ValueError>

Set the timer period, in seconds. Overrides the period or frequency set in the constructor. If changing pe riod frequently, don’t use this method, as it has computational overhead: use set_auto_reload and set_prescaler methods instead.

Source

pub fn set_freq(&mut self, freq: f32) -> Result<(), ValueError>

Set the timer frequency, in Hz. Overrides the period or frequency set in the constructor. If changing frequency frequently, don’t use this method, as it has computational overhead: use set_auto_reload and set_prescaler methods instead.

Source

pub fn get_max_duty(&self) -> u16

Return the integer associated with the maximum duty period.

Source

pub fn set_auto_reload(&mut self, arr: u16)

Set the auto-reload register value. Used for adjusting frequency.

Source

pub fn set_prescaler(&mut self, psc: u16)

Set the prescaler value. Used for adjusting frequency.

Source

pub fn reset_count(&mut self)

Reset the count; set the counter to 0.

Source

pub fn read_count(&self) -> u16

Read the current counter value.

Source

pub fn set_mastermode(&self, mode: MasterModeSelection)

Allow selected information to be sent in master mode to slave timers for synchronization (TRGO).

Auto Trait Implementations§

§

impl<R> Freeze for BasicTimer<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for BasicTimer<R>
where R: RefUnwindSafe,

§

impl<R> Send for BasicTimer<R>
where R: Send,

§

impl<R> Sync for BasicTimer<R>
where R: Sync,

§

impl<R> Unpin for BasicTimer<R>
where R: Unpin,

§

impl<R> UnwindSafe for BasicTimer<R>
where R: 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<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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

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.