diff options
-rw-r--r-- | cortex-m-rt/Cargo.toml | 4 | ||||
-rw-r--r-- | cortex-m-rt/ci/script.sh | 3 | ||||
-rw-r--r-- | cortex-m-rt/examples/rand.rs | 24 |
3 files changed, 30 insertions, 1 deletions
diff --git a/cortex-m-rt/Cargo.toml b/cortex-m-rt/Cargo.toml index 276f33c..9d82794 100644 --- a/cortex-m-rt/Cargo.toml +++ b/cortex-m-rt/Cargo.toml @@ -19,6 +19,10 @@ cortex-m = "0.5.4" panic-abort = "0.3.0" panic-semihosting = "0.4.0" +[dev-dependencies.rand] +default-features = false +version = "0.5.5" + [target.'cfg(not(target_os = "none"))'.dev-dependencies] compiletest_rs = "0.3.14" diff --git a/cortex-m-rt/ci/script.sh b/cortex-m-rt/ci/script.sh index cecb975..9933372 100644 --- a/cortex-m-rt/ci/script.sh +++ b/cortex-m-rt/ci/script.sh @@ -20,11 +20,12 @@ main() { minimal override-exception pre_init + rand state unsafe-default-handler - unsafe-hard-fault unsafe-entry unsafe-exception + unsafe-hard-fault ) local fail_examples=( data_overflow diff --git a/cortex-m-rt/examples/rand.rs b/cortex-m-rt/examples/rand.rs new file mode 100644 index 0000000..e0cfd31 --- /dev/null +++ b/cortex-m-rt/examples/rand.rs @@ -0,0 +1,24 @@ +//! Use rand crate to ensure it's configured for no_std compatbility + +#![deny(warnings)] +#![no_main] +#![no_std] + +extern crate cortex_m_rt as rt; +use rt::entry; + +extern crate panic_semihosting; + +extern crate rand; +use rand::Rng; +use rand::SeedableRng; + +// the program entry point +#[entry] +fn main() -> ! { + let seed: [u8; 32] = [0; 32]; + let mut rng = rand::ChaChaRng::from_seed(seed); + let _ = rng.gen::<u32>(); + + loop {} +} |