aboutsummaryrefslogtreecommitdiff
path: root/embassy-lora
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2023-06-08 16:08:40 +0200
committerDario Nieuwenhuis <[email protected]>2023-06-08 18:00:48 +0200
commit921780e6bfb9bcb2cd087b8aa8b094d792c99fa2 (patch)
treebd21fba9800471b860ca44e05567588dcc1afef7 /embassy-lora
parent87ad66f2b4a5bfd36dfc8d8aad5492e9e3f915e6 (diff)
Make interrupt module more standard.
- Move typelevel interrupts to a special-purpose mod: `embassy_xx::interrupt::typelevel`. - Reexport the PAC interrupt enum in `embassy_xx::interrupt`. This has a few advantages: - The `embassy_xx::interrupt` module is now more "standard". - It works with `cortex-m` functions for manipulating interrupts, for example. - It works with RTIC. - the interrupt enum allows holding value that can be "any interrupt at runtime", this can't be done with typelevel irqs. - When "const-generics on enums" is stable, we can remove the typelevel interrupts without disruptive changes to `embassy_xx::interrupt`.
Diffstat (limited to 'embassy-lora')
-rw-r--r--embassy-lora/src/iv.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/embassy-lora/src/iv.rs b/embassy-lora/src/iv.rs
index 8d521040f..2e0b68d1a 100644
--- a/embassy-lora/src/iv.rs
+++ b/embassy-lora/src/iv.rs
@@ -1,7 +1,7 @@
1#[cfg(feature = "stm32wl")] 1#[cfg(feature = "stm32wl")]
2use embassy_stm32::interrupt; 2use embassy_stm32::interrupt;
3#[cfg(feature = "stm32wl")] 3#[cfg(feature = "stm32wl")]
4use embassy_stm32::interrupt::*; 4use embassy_stm32::interrupt::InterruptExt;
5#[cfg(feature = "stm32wl")] 5#[cfg(feature = "stm32wl")]
6use embassy_stm32::pac; 6use embassy_stm32::pac;
7#[cfg(feature = "stm32wl")] 7#[cfg(feature = "stm32wl")]
@@ -20,9 +20,9 @@ use lora_phy::mod_traits::InterfaceVariant;
20pub struct InterruptHandler {} 20pub struct InterruptHandler {}
21 21
22#[cfg(feature = "stm32wl")] 22#[cfg(feature = "stm32wl")]
23impl interrupt::Handler<interrupt::SUBGHZ_RADIO> for InterruptHandler { 23impl interrupt::typelevel::Handler<interrupt::typelevel::SUBGHZ_RADIO> for InterruptHandler {
24 unsafe fn on_interrupt() { 24 unsafe fn on_interrupt() {
25 interrupt::SUBGHZ_RADIO::disable(); 25 interrupt::SUBGHZ_RADIO.disable();
26 IRQ_SIGNAL.signal(()); 26 IRQ_SIGNAL.signal(());
27 } 27 }
28} 28}
@@ -45,11 +45,11 @@ where
45{ 45{
46 /// Create an InterfaceVariant instance for an stm32wl/sx1262 combination 46 /// Create an InterfaceVariant instance for an stm32wl/sx1262 combination
47 pub fn new( 47 pub fn new(
48 _irq: impl interrupt::Binding<interrupt::SUBGHZ_RADIO, InterruptHandler>, 48 _irq: impl interrupt::typelevel::Binding<interrupt::typelevel::SUBGHZ_RADIO, InterruptHandler>,
49 rf_switch_rx: Option<CTRL>, 49 rf_switch_rx: Option<CTRL>,
50 rf_switch_tx: Option<CTRL>, 50 rf_switch_tx: Option<CTRL>,
51 ) -> Result<Self, RadioError> { 51 ) -> Result<Self, RadioError> {
52 interrupt::SUBGHZ_RADIO::disable(); 52 interrupt::SUBGHZ_RADIO.disable();
53 Ok(Self { 53 Ok(Self {
54 board_type: BoardType::Stm32wlSx1262, // updated when associated with a specific LoRa board 54 board_type: BoardType::Stm32wlSx1262, // updated when associated with a specific LoRa board
55 rf_switch_rx, 55 rf_switch_rx,
@@ -95,7 +95,7 @@ where
95 } 95 }
96 96
97 async fn await_irq(&mut self) -> Result<(), RadioError> { 97 async fn await_irq(&mut self) -> Result<(), RadioError> {
98 unsafe { interrupt::SUBGHZ_RADIO::enable() }; 98 unsafe { interrupt::SUBGHZ_RADIO.enable() };
99 IRQ_SIGNAL.wait().await; 99 IRQ_SIGNAL.wait().await;
100 Ok(()) 100 Ok(())
101 } 101 }