aboutsummaryrefslogtreecommitdiff
path: root/examples/stm32wl/src
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2023-07-31 01:41:12 +0200
committerDario Nieuwenhuis <[email protected]>2023-07-31 01:41:12 +0200
commit4999b045df4e5956733b0341795714a9214c12d3 (patch)
tree84c40ec27c89bb4dedea30cdafbaad484bfda3cb /examples/stm32wl/src
parentd6c5c1772cf2c6099ab08675afc0fead2e50fffb (diff)
stm32/rng: use bind_interrupts!.
Diffstat (limited to 'examples/stm32wl/src')
-rw-r--r--examples/stm32wl/src/bin/lora_lorawan.rs7
-rw-r--r--examples/stm32wl/src/bin/random.rs10
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;
10use embassy_lora::iv::{InterruptHandler, Stm32wlInterfaceVariant}; 10use embassy_lora::iv::{InterruptHandler, Stm32wlInterfaceVariant};
11use embassy_lora::LoraTimer; 11use embassy_lora::LoraTimer;
12use embassy_stm32::gpio::{Level, Output, Pin, Speed}; 12use embassy_stm32::gpio::{Level, Output, Pin, Speed};
13use embassy_stm32::rng::Rng; 13use embassy_stm32::rng::{self, Rng};
14use embassy_stm32::spi::Spi; 14use embassy_stm32::spi::Spi;
15use embassy_stm32::{bind_interrupts, pac}; 15use embassy_stm32::{bind_interrupts, pac, peripherals};
16use embassy_time::Delay; 16use embassy_time::Delay;
17use lora_phy::mod_params::*; 17use lora_phy::mod_params::*;
18use lora_phy::sx1261_2::SX1261_2; 18use lora_phy::sx1261_2::SX1261_2;
@@ -26,6 +26,7 @@ const LORAWAN_REGION: region::Region = region::Region::EU868; // warning: set th
26 26
27bind_interrupts!(struct Irqs{ 27bind_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
5use defmt::*; 5use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::pac; 7use embassy_stm32::rng::{self, Rng};
8use embassy_stm32::rng::Rng; 8use embassy_stm32::{bind_interrupts, pac, peripherals};
9use {defmt_rtt as _, panic_probe as _}; 9use {defmt_rtt as _, panic_probe as _};
10 10
11bind_interrupts!(struct Irqs{
12 RNG => rng::InterruptHandler<peripherals::RNG>;
13});
14
11#[embassy_executor::main] 15#[embassy_executor::main]
12async fn main(_spawner: Spawner) { 16async 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);