aboutsummaryrefslogtreecommitdiff
path: root/examples/stm32h7
diff options
context:
space:
mode:
authorBob McWhirter <[email protected]>2021-09-01 09:39:33 -0400
committerBob McWhirter <[email protected]>2021-09-01 09:39:33 -0400
commit37ceae908b39fcf1ef3b38680cef240ed6b1e867 (patch)
treeec7fe229b9ebc2892dc7c57732ab01f8f611ae4b /examples/stm32h7
parentfd7a76c59e8a190781aea476d199bda826dd5031 (diff)
Rename Random impl to Rng.
Create Random struct providing next_x(range) for all T:Rng.
Diffstat (limited to 'examples/stm32h7')
-rw-r--r--examples/stm32h7/src/bin/eth.rs6
-rw-r--r--examples/stm32h7/src/bin/rng.rs10
2 files changed, 8 insertions, 8 deletions
diff --git a/examples/stm32h7/src/bin/eth.rs b/examples/stm32h7/src/bin/eth.rs
index 4a9f261c2..df4931455 100644
--- a/examples/stm32h7/src/bin/eth.rs
+++ b/examples/stm32h7/src/bin/eth.rs
@@ -21,7 +21,7 @@ use embassy_net::{
21}; 21};
22use embassy_stm32::eth::lan8742a::LAN8742A; 22use embassy_stm32::eth::lan8742a::LAN8742A;
23use embassy_stm32::eth::{Ethernet, State}; 23use embassy_stm32::eth::{Ethernet, State};
24use embassy_stm32::rng::Random; 24use embassy_stm32::rng::Rng;
25use embassy_stm32::{interrupt, peripherals}; 25use embassy_stm32::{interrupt, peripherals};
26use heapless::Vec; 26use heapless::Vec;
27use panic_probe as _; 27use panic_probe as _;
@@ -81,7 +81,7 @@ fn _embassy_rand(buf: &mut [u8]) {
81 }); 81 });
82} 82}
83 83
84static mut RNG_INST: Option<Random<RNG>> = None; 84static mut RNG_INST: Option<Rng<RNG>> = None;
85 85
86static EXECUTOR: Forever<Executor> = Forever::new(); 86static EXECUTOR: Forever<Executor> = Forever::new();
87static STATE: Forever<State<'static, 4, 4>> = Forever::new(); 87static STATE: Forever<State<'static, 4, 4>> = Forever::new();
@@ -97,7 +97,7 @@ fn main() -> ! {
97 97
98 let p = embassy_stm32::init(config()); 98 let p = embassy_stm32::init(config());
99 99
100 let rng = Random::new(p.RNG); 100 let rng = Rng::new(p.RNG);
101 unsafe { 101 unsafe {
102 RNG_INST.replace(rng); 102 RNG_INST.replace(rng);
103 } 103 }
diff --git a/examples/stm32h7/src/bin/rng.rs b/examples/stm32h7/src/bin/rng.rs
index fea88c410..cf1b14ea5 100644
--- a/examples/stm32h7/src/bin/rng.rs
+++ b/examples/stm32h7/src/bin/rng.rs
@@ -8,9 +8,9 @@
8mod example_common; 8mod example_common;
9use embassy::executor::Spawner; 9use embassy::executor::Spawner;
10use embassy::time::{Duration, Timer}; 10use embassy::time::{Duration, Timer};
11use embassy::traits::rng::Random as _;
12use embassy_stm32::gpio::{Level, Output, Speed}; 11use embassy_stm32::gpio::{Level, Output, Speed};
13use embassy_stm32::rng::Random; 12use embassy_stm32::rng::Rng;
13use embassy::traits::rng::Random;
14use embassy_stm32::Peripherals; 14use embassy_stm32::Peripherals;
15use embedded_hal::digital::v2::OutputPin; 15use embedded_hal::digital::v2::OutputPin;
16use example_common::*; 16use example_common::*;
@@ -21,14 +21,14 @@ async fn main(_spawner: Spawner, p: Peripherals) {
21 21
22 let mut led = Output::new(p.PB14, Level::High, Speed::Low); 22 let mut led = Output::new(p.PB14, Level::High, Speed::Low);
23 23
24 let mut rng = Random::new(p.RNG); 24 let mut rng = Random::new(Rng::new(p.RNG));
25 25
26 loop { 26 loop {
27 info!("high {}", unwrap!(rng.next(16).await)); 27 info!("high {}", unwrap!(rng.next_u8(16).await));
28 unwrap!(led.set_high()); 28 unwrap!(led.set_high());
29 Timer::after(Duration::from_millis(500)).await; 29 Timer::after(Duration::from_millis(500)).await;
30 30
31 info!("low {}", unwrap!(rng.next(16).await)); 31 info!("low {}", unwrap!(rng.next_u8(16).await));
32 unwrap!(led.set_low()); 32 unwrap!(led.set_low());
33 Timer::after(Duration::from_millis(500)).await; 33 Timer::after(Duration::from_millis(500)).await;
34 } 34 }