diff options
| author | Dario Nieuwenhuis <[email protected]> | 2023-07-31 01:41:12 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2023-07-31 01:41:12 +0200 |
| commit | 4999b045df4e5956733b0341795714a9214c12d3 (patch) | |
| tree | 84c40ec27c89bb4dedea30cdafbaad484bfda3cb /examples/stm32wl/src/bin | |
| parent | d6c5c1772cf2c6099ab08675afc0fead2e50fffb (diff) | |
stm32/rng: use bind_interrupts!.
Diffstat (limited to 'examples/stm32wl/src/bin')
| -rw-r--r-- | examples/stm32wl/src/bin/lora_lorawan.rs | 7 | ||||
| -rw-r--r-- | examples/stm32wl/src/bin/random.rs | 10 |
2 files changed, 11 insertions, 6 deletions
diff --git a/examples/stm32wl/src/bin/lora_lorawan.rs b/examples/stm32wl/src/bin/lora_lorawan.rs index 805d21418..2c9c98861 100644 --- a/examples/stm32wl/src/bin/lora_lorawan.rs +++ b/examples/stm32wl/src/bin/lora_lorawan.rs | |||
| @@ -10,9 +10,9 @@ use embassy_executor::Spawner; | |||
| 10 | use embassy_lora::iv::{InterruptHandler, Stm32wlInterfaceVariant}; | 10 | use embassy_lora::iv::{InterruptHandler, Stm32wlInterfaceVariant}; |
| 11 | use embassy_lora::LoraTimer; | 11 | use embassy_lora::LoraTimer; |
| 12 | use embassy_stm32::gpio::{Level, Output, Pin, Speed}; | 12 | use embassy_stm32::gpio::{Level, Output, Pin, Speed}; |
| 13 | use embassy_stm32::rng::Rng; | 13 | use embassy_stm32::rng::{self, Rng}; |
| 14 | use embassy_stm32::spi::Spi; | 14 | use embassy_stm32::spi::Spi; |
| 15 | use embassy_stm32::{bind_interrupts, pac}; | 15 | use embassy_stm32::{bind_interrupts, pac, peripherals}; |
| 16 | use embassy_time::Delay; | 16 | use embassy_time::Delay; |
| 17 | use lora_phy::mod_params::*; | 17 | use lora_phy::mod_params::*; |
| 18 | use lora_phy::sx1261_2::SX1261_2; | 18 | use lora_phy::sx1261_2::SX1261_2; |
| @@ -26,6 +26,7 @@ const LORAWAN_REGION: region::Region = region::Region::EU868; // warning: set th | |||
| 26 | 26 | ||
| 27 | bind_interrupts!(struct Irqs{ | 27 | bind_interrupts!(struct Irqs{ |
| 28 | SUBGHZ_RADIO => InterruptHandler; | 28 | SUBGHZ_RADIO => InterruptHandler; |
| 29 | RNG => rng::InterruptHandler<peripherals::RNG>; | ||
| 29 | }); | 30 | }); |
| 30 | 31 | ||
| 31 | #[embassy_executor::main] | 32 | #[embassy_executor::main] |
| @@ -58,7 +59,7 @@ async fn main(_spawner: Spawner) { | |||
| 58 | }; | 59 | }; |
| 59 | let radio = LoRaRadio::new(lora); | 60 | let radio = LoRaRadio::new(lora); |
| 60 | let region: region::Configuration = region::Configuration::new(LORAWAN_REGION); | 61 | let region: region::Configuration = region::Configuration::new(LORAWAN_REGION); |
| 61 | let mut device: Device<_, Crypto, _, _> = Device::new(region, radio, LoraTimer::new(), Rng::new(p.RNG)); | 62 | let mut device: Device<_, Crypto, _, _> = Device::new(region, radio, LoraTimer::new(), Rng::new(p.RNG, Irqs)); |
| 62 | 63 | ||
| 63 | defmt::info!("Joining LoRaWAN network"); | 64 | defmt::info!("Joining LoRaWAN network"); |
| 64 | 65 | ||
diff --git a/examples/stm32wl/src/bin/random.rs b/examples/stm32wl/src/bin/random.rs index d8562fca5..592e65f40 100644 --- a/examples/stm32wl/src/bin/random.rs +++ b/examples/stm32wl/src/bin/random.rs | |||
| @@ -4,10 +4,14 @@ | |||
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::pac; | 7 | use embassy_stm32::rng::{self, Rng}; |
| 8 | use embassy_stm32::rng::Rng; | 8 | use embassy_stm32::{bind_interrupts, pac, peripherals}; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | bind_interrupts!(struct Irqs{ | ||
| 12 | RNG => rng::InterruptHandler<peripherals::RNG>; | ||
| 13 | }); | ||
| 14 | |||
| 11 | #[embassy_executor::main] | 15 | #[embassy_executor::main] |
| 12 | async fn main(_spawner: Spawner) { | 16 | async fn main(_spawner: Spawner) { |
| 13 | let mut config = embassy_stm32::Config::default(); | 17 | let mut config = embassy_stm32::Config::default(); |
| @@ -21,7 +25,7 @@ async fn main(_spawner: Spawner) { | |||
| 21 | 25 | ||
| 22 | info!("Hello World!"); | 26 | info!("Hello World!"); |
| 23 | 27 | ||
| 24 | let mut rng = Rng::new(p.RNG); | 28 | let mut rng = Rng::new(p.RNG, Irqs); |
| 25 | 29 | ||
| 26 | let mut buf = [0u8; 16]; | 30 | let mut buf = [0u8; 16]; |
| 27 | unwrap!(rng.async_fill_bytes(&mut buf).await); | 31 | unwrap!(rng.async_fill_bytes(&mut buf).await); |
