D0

Struct D0 

Source
pub struct D0 { /* private fields */ }
Expand description

Push-button D0.

Implementations§

Source§

impl D0

Source

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));
Source

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();
Source

pub unsafe fn steal() -> Self

Steal the push-button from whatever is currently using it.

§Safety
  1. Ensure that the code stealing the push-button has exclusive access to the underlying GPIO. Singleton checks are bypassed with this method.
  2. 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§

Source§

impl Debug for D0

Source§

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

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

impl PushButton for D0

Source§

type Pin = A0

Input pin for the push-button Read more
Source§

fn is_pushed(&self) -> bool

Returns True if the button is currently being pushed.

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