pub struct D0 { /* private fields */ }Expand description
Push-button D0.
Implementations§
Source§impl D0
impl D0
Sourcepub fn new(a0: A0, cs: &CriticalSection) -> Self
pub fn new(a0: A0, cs: &CriticalSection) -> Self
Create a new push-button D0.
§Example
use lora_e5_bsp::{
hal::{cortex_m, gpio::PortA, pac},
pb::{PushButton, D0},
};
let mut dp: pac::Peripherals = pac::Peripherals::take().unwrap();
let gpioa: PortA = PortA::split(dp.GPIOA, &mut dp.RCC);
let d0 = cortex_m::interrupt::free(|cs| D0::new(gpioa.a0, cs));Sourcepub fn free(self) -> A0
pub fn free(self) -> A0
Free the GPIO pin from the push-button struct.
§Example
use lora_e5_bsp::{
hal::{cortex_m, gpio::PortA, pac},
pb::{PushButton, D0},
};
let mut dp: pac::Peripherals = pac::Peripherals::take().unwrap();
let gpioa: PortA = PortA::split(dp.GPIOA, &mut dp.RCC);
let d0 = cortex_m::interrupt::free(|cs| D0::new(gpioa.a0, cs));
// ... use push button
let c0 = d0.free();Sourcepub unsafe fn steal() -> Self
pub unsafe fn steal() -> Self
Steal the push-button from whatever is currently using it.
§Safety
- Ensure that the code stealing the push-button has exclusive access to the underlying GPIO. Singleton checks are bypassed with this method.
- You are responsible for setting up the underlying GPIO correctly. No setup will occur when using this method.
§Example
use lora_e5_bsp::pb::D0;
// ... setup happens here
let d0: D0 = unsafe { D0::steal() };Trait Implementations§
Auto Trait Implementations§
impl Freeze for D0
impl RefUnwindSafe for D0
impl Send for D0
impl Sync for D0
impl Unpin for D0
impl UnwindSafe for D0
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