PushButton

Trait PushButton 

Source
pub trait PushButton {
    type Pin: Exti;

    // Required method
    fn is_pushed(&self) -> bool;
}
Expand description

Simple trait for a push-button

Required Associated Types§

Source

type Pin: Exti

Input pin for the push-button

This can be used to access the EXTI trait for the pin.

§Example

Setup EXTI to fire an interrupt when D0 is pushed.

use lora_e5_bsp::{
    hal::{
        cortex_m,
        gpio::{Exti, ExtiTrg, 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));

<D0 as PushButton>::Pin::setup_exti_c1(&mut dp.EXTI, &mut dp.SYSCFG, ExtiTrg::Falling);

Required Methods§

Source

fn is_pushed(&self) -> bool

Returns True if the button is currently being pushed.

Implementors§