Struct stm32wlxx_hal::lptim::LpTim3

source ·
pub struct LpTim3 { /* private fields */ }
Expand description

Low-power timer 3 driver.

Implementations§

source§

impl LpTim3

source

pub fn new_trigger_pin( &mut self, pin: A11, filter: Filter, pol: TrgPol, cs: &CriticalSection ) -> LpTim3Trg

Setup a new pin trigger.

Panics
  • (debug) timer is enabled.
Example

Setup a one-shot timer that starts after a transition on pin A11.

use stm32wlxx_hal::{
    cortex_m,
    embedded_hal::timer::CountDown,
    gpio::PortA,
    lptim::{self, Filter, LpTim, LpTim3, LpTim3Trg, Prescaler::Div1, TrgPol},
    pac,
};

let mut dp: pac::Peripherals = pac::Peripherals::take().unwrap();

// enable the HSI16 source clock
dp.RCC.cr.modify(|_, w| w.hsion().set_bit());
while dp.RCC.cr.read().hsirdy().is_not_ready() {}

let pa: PortA = PortA::split(dp.GPIOA, &mut dp.RCC);
let mut lptim3: LpTim3 = LpTim3::new(dp.LPTIM3, lptim::Clk::Hsi16, Div1, &mut dp.RCC);
let lptim3trg: LpTim3Trg = cortex_m::interrupt::free(|cs| {
    lptim3.new_trigger_pin(pa.a11, Filter::Any, TrgPol::Both, cs)
});
lptim3.start(12_345_u16);
// timer will only start after any transition on pin A11
nb::block!(lptim3.wait());
source

pub fn free_trigger_pin(&mut self, pin: LpTim3Trg) -> A11

Free the trigger pin previously created with new_trigger_pin.

This is will the trigger source to a software trigger.

Panics
  • (debug) timer is enabled.
Example

Setup a one-shot timer that starts after a transition on pin A11.

use stm32wlxx_hal::{
    embedded_hal::timer::CountDown,
    gpio::PortA,
    lptim::{self, Filter, LpTim, LpTim3, LpTim3Trg, Prescaler::Div1, TrgPol},
    pac,
};

let mut dp: pac::Peripherals = pac::Peripherals::take().unwrap();

// enable the HSI16 source clock
dp.RCC.cr.modify(|_, w| w.hsion().set_bit());
while dp.RCC.cr.read().hsirdy().is_not_ready() {}

let pa: PortA = PortA::split(dp.GPIOA, &mut dp.RCC);
let mut lptim3: LpTim3 = LpTim3::new(dp.LPTIM3, lptim::Clk::Hsi16, Div1, &mut dp.RCC);
let lptim3trg: LpTim3Trg = cortex_m::interrupt::free(|cs| {
    lptim3.new_trigger_pin(pa.a11, Filter::Any, TrgPol::Both, cs)
});
lptim3.start(12_345_u16);
// timer will only start after any transition on pin A11
nb::block!(lptim3.wait());

// free the pin
let a11 = lptim3.free_trigger_pin(lptim3trg);
source§

impl LpTim3

source

pub fn new_output_pin(&mut self, pin: A1, cs: &CriticalSection) -> LpTim3OutPin

Setup a new output pin.

source

pub fn free_output_pin(&mut self, pin: LpTim3OutPin) -> A1

Free the output pin previously created with new_output_pin.

Trait Implementations§

source§

impl Debug for LpTim3

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl LpTim for LpTim3

§

type TrgSel = TrgSel3

Trigger selection options.
source§

fn new(tim: Self::Pac, clk: Clk, pre: Prescaler, rcc: &mut RCC) -> Self

Create a new LPTIM driver. Read more
source§

fn free(self) -> Self::Pac

Free the LPTIM registers from the driver. Read more
source§

unsafe fn pulse_reset(rcc: &mut RCC)

Reset the LPTIM peripheral. Read more
source§

fn enable_clock(rcc: &mut RCC)

Enable clocks for the LPTIM peripheral. Read more
source§

unsafe fn disable_clock(rcc: &mut RCC)

Disable the LPTIM peripheral clock. Read more
source§

fn clk(rcc: &RCC) -> Clk

Get the clock source. Read more
source§

fn hz(&self) -> &Ratio<u32>

Get the clock speed in hertz. Read more
source§

fn cnt() -> u16

Get the timer count.
source§

fn isr() -> u32

Get the interrupt status.
source§

fn set_ier(&mut self, ier: u32)

Enable and disable interrupts. Read more
source§

unsafe fn set_icr(&mut self, icr: u32)

Clear interrupts. Read more
source§

fn is_enabled(&self) -> bool

Returns true if the timer is enabled.
source§

fn setup_trigger(&mut self, filter: Filter, pol: TrgPol, sel: Self::TrgSel)

Setup a non-pin trigger. Read more
source§

fn set_max_duty(&mut self, duty: u16)

Set the maximum duty cycle (autoreload value). Read more
source§

impl PwmPin for LpTim3

§

type Duty = u16

Type for the duty methods Read more
source§

fn disable(&mut self)

Disables a PWM channel
source§

fn enable(&mut self)

Enables a PWM channel
source§

fn get_duty(&self) -> Self::Duty

Returns the current duty cycle
source§

fn get_max_duty(&self) -> Self::Duty

Returns the maximum duty cycle value
source§

fn set_duty(&mut self, duty: Self::Duty)

Sets a new duty cycle
source§

impl CountDown for LpTim3

§

type Time = u16

The unit of time used by this timer
source§

fn start<T>(&mut self, count: T)where T: Into<Self::Time>,

Starts a new count down
source§

fn wait(&mut self) -> Result<(), Void>

Non-blockingly “waits” until the count down finishes Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for LpTim3

§

impl Send for LpTim3

§

impl !Sync for LpTim3

§

impl Unpin for LpTim3

§

impl UnwindSafe for LpTim3

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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 Twhere 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.