diff options
author | 2018-09-06 23:11:59 +0200 | |
---|---|---|
committer | 2018-09-07 21:23:53 +0200 | |
commit | f6902b4250203098a21d236a9935bcd4fa3e4c2b (patch) | |
tree | 38921c4cff20f394c05c38828a155266216f8a3e | |
parent | 04ef312936e4a799f877de0fc46a5c7bb2a63307 (diff) | |
download | cortex-m-f6902b4250203098a21d236a9935bcd4fa3e4c2b.tar.gz cortex-m-f6902b4250203098a21d236a9935bcd4fa3e4c2b.tar.zst cortex-m-f6902b4250203098a21d236a9935bcd4fa3e4c2b.zip |
Added example using rand crate to ensure no_std compatibility
Signed-off-by: Daniel Egger <daniel@eggers-club.de>
-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 {} +} |