diff options
| author | Bob McWhirter <[email protected]> | 2021-09-01 09:39:33 -0400 |
|---|---|---|
| committer | Bob McWhirter <[email protected]> | 2021-09-01 09:39:33 -0400 |
| commit | 37ceae908b39fcf1ef3b38680cef240ed6b1e867 (patch) | |
| tree | ec7fe229b9ebc2892dc7c57732ab01f8f611ae4b /examples/stm32h7/src/bin/rng.rs | |
| parent | fd7a76c59e8a190781aea476d199bda826dd5031 (diff) | |
Rename Random impl to Rng.
Create Random struct providing next_x(range) for all T:Rng.
Diffstat (limited to 'examples/stm32h7/src/bin/rng.rs')
| -rw-r--r-- | examples/stm32h7/src/bin/rng.rs | 10 |
1 files changed, 5 insertions, 5 deletions
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 @@ | |||
| 8 | mod example_common; | 8 | mod example_common; |
| 9 | use embassy::executor::Spawner; | 9 | use embassy::executor::Spawner; |
| 10 | use embassy::time::{Duration, Timer}; | 10 | use embassy::time::{Duration, Timer}; |
| 11 | use embassy::traits::rng::Random as _; | ||
| 12 | use embassy_stm32::gpio::{Level, Output, Speed}; | 11 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 13 | use embassy_stm32::rng::Random; | 12 | use embassy_stm32::rng::Rng; |
| 13 | use embassy::traits::rng::Random; | ||
| 14 | use embassy_stm32::Peripherals; | 14 | use embassy_stm32::Peripherals; |
| 15 | use embedded_hal::digital::v2::OutputPin; | 15 | use embedded_hal::digital::v2::OutputPin; |
| 16 | use example_common::*; | 16 | use 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 | } |
