aboutsummaryrefslogtreecommitdiff
path: root/examples/stm32h7/src
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2022-01-27 00:08:02 +0100
committerDario Nieuwenhuis <[email protected]>2022-01-27 00:08:02 +0100
commit0719b05d63a1d80d3b8ea39a411545a6e8e22ec2 (patch)
tree9abf789ef5213c191433466b0b201edde967eaed /examples/stm32h7/src
parentd76cd5ceaf5140c48ef97180beae156c0c0e07c8 (diff)
traits: migrate Delay to embedded-hal 1.0+async, remove Rng and Flash.
Diffstat (limited to 'examples/stm32h7/src')
-rw-r--r--examples/stm32h7/src/bin/rng.rs19
1 files changed, 4 insertions, 15 deletions
diff --git a/examples/stm32h7/src/bin/rng.rs b/examples/stm32h7/src/bin/rng.rs
index 8e03861d5..932cfcb8b 100644
--- a/examples/stm32h7/src/bin/rng.rs
+++ b/examples/stm32h7/src/bin/rng.rs
@@ -5,9 +5,6 @@
5#[path = "../example_common.rs"] 5#[path = "../example_common.rs"]
6mod example_common; 6mod example_common;
7use embassy::executor::Spawner; 7use embassy::executor::Spawner;
8use embassy::time::{Duration, Timer};
9use embassy::traits::rng::Random;
10use embassy_stm32::gpio::{Level, Output, Speed};
11use embassy_stm32::rng::Rng; 8use embassy_stm32::rng::Rng;
12use embassy_stm32::Peripherals; 9use embassy_stm32::Peripherals;
13use example_common::*; 10use example_common::*;
@@ -16,17 +13,9 @@ use example_common::*;
16async fn main(_spawner: Spawner, p: Peripherals) { 13async fn main(_spawner: Spawner, p: Peripherals) {
17 info!("Hello World!"); 14 info!("Hello World!");
18 15
19 let mut led = Output::new(p.PB14, Level::High, Speed::Low); 16 let mut rng = Rng::new(p.RNG);
20 17
21 let mut rng = Random::new(Rng::new(p.RNG)); 18 let mut buf = [0u8; 16];
22 19 unwrap!(rng.async_fill_bytes(&mut buf).await);
23 loop { 20 info!("random bytes: {:02x}", buf);
24 info!("high {}", unwrap!(rng.next_u8(16).await));
25 led.set_high();
26 Timer::after(Duration::from_millis(500)).await;
27
28 info!("low {}", unwrap!(rng.next_u8(16).await));
29 led.set_low();
30 Timer::after(Duration::from_millis(500)).await;
31 }
32} 21}