embassy/examples/stm32l4/src/bin/rng.rs
Dario Nieuwenhuis cdc66e110f stm32/rcc: remove builders on Config.
This makes API consistent with other Config structs in Embassy, where
the convention is to not use builders.
2022-01-04 13:31:30 +01:00

38 lines
935 B
Rust

#![no_std]
#![no_main]
#![feature(type_alias_impl_trait)]
#[path = "../example_common.rs"]
mod example_common;
use embassy::executor::Spawner;
use embassy::time::{Duration, Timer};
use embassy::traits::rng::Random;
use embassy_stm32::rcc::{ClockSrc, PLLClkDiv, PLLMul, PLLSource, PLLSrcDiv};
use embassy_stm32::rng::Rng;
use embassy_stm32::{Config, Peripherals};
use example_common::*;
fn config() -> Config {
let mut config = Config::default();
config.rcc.mux = ClockSrc::PLL(
PLLSource::HSI16,
PLLClkDiv::Div2,
PLLSrcDiv::Div1,
PLLMul::Mul8,
Some(PLLClkDiv::Div2),
);
config
}
#[embassy::main(config = "config()")]
async fn main(_spawner: Spawner, p: Peripherals) {
info!("Hello World!");
let mut rng = Random::new(Rng::new(p.RNG));
loop {
info!("random {}", unwrap!(rng.next_u8(16).await));
Timer::after(Duration::from_secs(1)).await;
}
}