Struct stm32wlxx_hal::lptim::LpTim3
source · pub struct LpTim3 { /* private fields */ }
Expand description
Low-power timer 3 driver.
Implementations§
source§impl LpTim3
impl LpTim3
sourcepub fn new_trigger_pin(
&mut self,
pin: A11,
filter: Filter,
pol: TrgPol,
cs: &CriticalSection
) -> LpTim3Trg
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());
sourcepub fn free_trigger_pin(&mut self, pin: LpTim3Trg) -> A11
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
impl LpTim3
sourcepub fn new_output_pin(&mut self, pin: A1, cs: &CriticalSection) -> LpTim3OutPin
pub fn new_output_pin(&mut self, pin: A1, cs: &CriticalSection) -> LpTim3OutPin
Setup a new output pin.
sourcepub fn free_output_pin(&mut self, pin: LpTim3OutPin) -> A1
pub fn free_output_pin(&mut self, pin: LpTim3OutPin) -> A1
Free the output pin previously created with
new_output_pin
.
Trait Implementations§
source§impl LpTim for LpTim3
impl LpTim for LpTim3
source§fn new(tim: Self::Pac, clk: Clk, pre: Prescaler, rcc: &mut RCC) -> Self
fn new(tim: Self::Pac, clk: Clk, pre: Prescaler, rcc: &mut RCC) -> Self
Create a new LPTIM driver. Read more
source§unsafe fn pulse_reset(rcc: &mut RCC)
unsafe fn pulse_reset(rcc: &mut RCC)
Reset the LPTIM peripheral. Read more
source§fn enable_clock(rcc: &mut RCC)
fn enable_clock(rcc: &mut RCC)
Enable clocks for the LPTIM peripheral. Read more
source§unsafe fn disable_clock(rcc: &mut RCC)
unsafe fn disable_clock(rcc: &mut RCC)
Disable the LPTIM peripheral clock. Read more
source§fn is_enabled(&self) -> bool
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)
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)
fn set_max_duty(&mut self, duty: u16)
Set the maximum duty cycle (autoreload value). 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> 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
Mutably borrows from an owned value. Read more