Trait stm32wlxx_hal::gpio::Exti

source ·
pub trait Exti {
    const INTERRUPT: Interrupt;

    // Required methods
    fn set_port(syscfg: &mut SYSCFG);
    fn set_rising_trigger(exti: &mut EXTI, en: bool);
    fn set_falling_trigger(exti: &mut EXTI, en: bool);
    fn set_c1_mask(exti: &mut EXTI, unmask: bool);
    fn clear_exti();
    fn is_pending() -> bool;

    // Provided methods
    fn setup_exti_c1(exti: &mut EXTI, syscfg: &mut SYSCFG, trg: ExtiTrg) { ... }
    unsafe fn unmask() { ... }
    fn mask() { ... }
}
Expand description

Input pin extended interrupts.

Required Associated Constants§

source

const INTERRUPT: Interrupt

Interrupt number for the EXTI.

  • On core 1 this is shared for EXTI 5-9, and 10-15.
  • On core 2 this is shared for EXTI 0-1, 2-3, and 4-15.

Required Methods§

source

fn set_port(syscfg: &mut SYSCFG)

Set the current port as the interrupt source.

Only one port (A, B, C) can be active at a time for each pin number. For example, enabling PA2 will disable PB2 and PC2 if previously enabled.

Example

Set port C as the pin-6 EXTI port.

use stm32wlxx_hal::{
    gpio::{pins::C6, Exti},
    pac,
};

let mut dp: pac::Peripherals = pac::Peripherals::take().unwrap();
C6::set_port(&mut dp.SYSCFG);
source

fn set_rising_trigger(exti: &mut EXTI, en: bool)

Set the rising trigger enable.

Example

Set C6 to trigger on a rising edge.

use stm32wlxx_hal::{
    gpio::{pins::C6, Exti},
    pac,
};

let mut dp: pac::Peripherals = pac::Peripherals::take().unwrap();
C6::set_port(&mut dp.SYSCFG);
C6::set_rising_trigger(&mut dp.EXTI, true);
source

fn set_falling_trigger(exti: &mut EXTI, en: bool)

Set the falling trigger enable.

Example

Set C6 to trigger on a falling edge.

use stm32wlxx_hal::{
    gpio::{pins::C6, Exti},
    pac,
};

let mut dp: pac::Peripherals = pac::Peripherals::take().unwrap();
C6::set_port(&mut dp.SYSCFG);
C6::set_falling_trigger(&mut dp.EXTI, true);
source

fn set_c1_mask(exti: &mut EXTI, unmask: bool)

Set the core 1 interrupt mask in the EXTI.

This will not mask/unmask the IRQ in the NVIC, use mask and unmask for that.

Example

Unmask C6.

use stm32wlxx_hal::{
    gpio::{pins::C6, Exti},
    pac,
};

let mut dp: pac::Peripherals = pac::Peripherals::take().unwrap();
C6::set_port(&mut dp.SYSCFG);
C6::set_c1_mask(&mut dp.EXTI, true);
source

fn clear_exti()

Clear the pending EXTI interrupt.

Example

See gpio-button-irq.rs.

source

fn is_pending() -> bool

Returns true if a trigger request occurred.

Example

See gpio-button-irq.rs.

Provided Methods§

source

fn setup_exti_c1(exti: &mut EXTI, syscfg: &mut SYSCFG, trg: ExtiTrg)

Setup an input pin as an EXTI interrupt source on core 1.

This is a helper function that wraps:

  1. set_port
  2. set_rising_trigger
  3. set_falling_trigger
  4. Unmask with set_c1_mask
Example

Setup C6 to trigger on both edges.

use stm32wlxx_hal::{
    gpio::{pins::C6, Exti, ExtiTrg},
    pac,
};

let mut dp: pac::Peripherals = pac::Peripherals::take().unwrap();
C6::setup_exti_c1(&mut dp.EXTI, &mut dp.SYSCFG, ExtiTrg::Both);
source

unsafe fn unmask()

Unmask the interrupt in the NVIC.

This will not unmask the IRQ in the EXTI, use set_c1_mask for that.

Safety

This can break mask-based critical sections.

Example

Setup and unmask C6 (which will unmask all pins 5-9).

use stm32wlxx_hal::{
    gpio::{pins::C6, Exti, ExtiTrg},
    pac,
};

let mut dp: pac::Peripherals = pac::Peripherals::take().unwrap();
C6::setup_exti_c1(&mut dp.EXTI, &mut dp.SYSCFG, ExtiTrg::Both);
unsafe { C6::unmask() };
source

fn mask()

Mask the interrupt in the NVIC.

This will not mask the IRQ in the EXTI, use set_c1_mask for that.

Example

Mask C6 (which will mask all pins 5-9).

use stm32wlxx_hal::gpio::{pins::C6, Exti};

C6::mask();

Object Safety§

This trait is not object safe.

Implementors§

source§

impl Exti for A0

source§

const INTERRUPT: Interrupt = pac::Interrupt::EXTI0

source§

impl Exti for A1

source§

const INTERRUPT: Interrupt = pac::Interrupt::EXTI1

source§

impl Exti for A2

source§

const INTERRUPT: Interrupt = pac::Interrupt::EXTI2

source§

impl Exti for A3

source§

const INTERRUPT: Interrupt = pac::Interrupt::EXTI3

source§

impl Exti for A4

source§

const INTERRUPT: Interrupt = pac::Interrupt::EXTI4

source§

impl Exti for A5

source§

const INTERRUPT: Interrupt = pac::Interrupt::EXTI9_5

source§

impl Exti for A6

source§

const INTERRUPT: Interrupt = pac::Interrupt::EXTI9_5

source§

impl Exti for A7

source§

const INTERRUPT: Interrupt = pac::Interrupt::EXTI9_5

source§

impl Exti for A8

source§

const INTERRUPT: Interrupt = pac::Interrupt::EXTI9_5

source§

impl Exti for A9

source§

const INTERRUPT: Interrupt = pac::Interrupt::EXTI9_5

source§

impl Exti for A10

source§

const INTERRUPT: Interrupt = pac::Interrupt::EXTI15_10

source§

impl Exti for A11

source§

const INTERRUPT: Interrupt = pac::Interrupt::EXTI15_10

source§

impl Exti for A12

source§

const INTERRUPT: Interrupt = pac::Interrupt::EXTI15_10

source§

impl Exti for A13

source§

const INTERRUPT: Interrupt = pac::Interrupt::EXTI15_10

source§

impl Exti for A14

source§

const INTERRUPT: Interrupt = pac::Interrupt::EXTI15_10

source§

impl Exti for A15

source§

const INTERRUPT: Interrupt = pac::Interrupt::EXTI15_10

source§

impl Exti for B0

source§

const INTERRUPT: Interrupt = pac::Interrupt::EXTI0

source§

impl Exti for B1

source§

const INTERRUPT: Interrupt = pac::Interrupt::EXTI1

source§

impl Exti for B2

source§

const INTERRUPT: Interrupt = pac::Interrupt::EXTI2

source§

impl Exti for B3

source§

const INTERRUPT: Interrupt = pac::Interrupt::EXTI3

source§

impl Exti for B4

source§

const INTERRUPT: Interrupt = pac::Interrupt::EXTI4

source§

impl Exti for B5

source§

const INTERRUPT: Interrupt = pac::Interrupt::EXTI9_5

source§

impl Exti for B6

source§

const INTERRUPT: Interrupt = pac::Interrupt::EXTI9_5

source§

impl Exti for B7

source§

const INTERRUPT: Interrupt = pac::Interrupt::EXTI9_5

source§

impl Exti for B8

source§

const INTERRUPT: Interrupt = pac::Interrupt::EXTI9_5

source§

impl Exti for B9

source§

const INTERRUPT: Interrupt = pac::Interrupt::EXTI9_5

source§

impl Exti for B10

source§

const INTERRUPT: Interrupt = pac::Interrupt::EXTI15_10

source§

impl Exti for B11

source§

const INTERRUPT: Interrupt = pac::Interrupt::EXTI15_10

source§

impl Exti for B12

source§

const INTERRUPT: Interrupt = pac::Interrupt::EXTI15_10

source§

impl Exti for B13

source§

const INTERRUPT: Interrupt = pac::Interrupt::EXTI15_10

source§

impl Exti for B14

source§

const INTERRUPT: Interrupt = pac::Interrupt::EXTI15_10

source§

impl Exti for B15

source§

const INTERRUPT: Interrupt = pac::Interrupt::EXTI15_10

source§

impl Exti for C0

source§

const INTERRUPT: Interrupt = pac::Interrupt::EXTI0

source§

impl Exti for C1

source§

const INTERRUPT: Interrupt = pac::Interrupt::EXTI1

source§

impl Exti for C2

source§

const INTERRUPT: Interrupt = pac::Interrupt::EXTI2

source§

impl Exti for C3

source§

const INTERRUPT: Interrupt = pac::Interrupt::EXTI3

source§

impl Exti for C4

source§

const INTERRUPT: Interrupt = pac::Interrupt::EXTI4

source§

impl Exti for C5

source§

const INTERRUPT: Interrupt = pac::Interrupt::EXTI9_5

source§

impl Exti for C6

source§

const INTERRUPT: Interrupt = pac::Interrupt::EXTI9_5

source§

impl Exti for C13

source§

const INTERRUPT: Interrupt = pac::Interrupt::EXTI15_10

source§

impl Exti for C14

source§

const INTERRUPT: Interrupt = pac::Interrupt::EXTI15_10

source§

impl Exti for C15

source§

const INTERRUPT: Interrupt = pac::Interrupt::EXTI15_10