rust-raspberrypi-OS-tutorials/08_random
2018-12-31 01:19:57 +01:00
..
.cargo Use aarch64-unknown-none target in nightly 🎉 2018-08-19 23:42:24 +02:00
raspi3_boot Streamlining, cleanup, and minor fixes. 2018-12-31 01:19:57 +01:00
src Streamlining, cleanup, and minor fixes. 2018-12-31 01:19:57 +01:00
Cargo.lock 🎉 Update to Rust 2018 🎉 2018-12-22 20:56:09 +01:00
Cargo.toml 🎉 Update to Rust 2018 🎉 2018-12-22 20:56:09 +01:00
kernel8 Streamlining, cleanup, and minor fixes. 2018-12-31 01:19:57 +01:00
kernel8.img Streamlining, cleanup, and minor fixes. 2018-12-31 01:19:57 +01:00
link.ld Alignment. Binaries from newer Rust version. 2018-10-02 23:16:04 +02:00
Makefile Streamlining, cleanup, and minor fixes. 2018-12-31 01:19:57 +01:00
README.md Update README.md 2018-10-29 22:53:54 +01:00

Tutorial 08 - Hardware Random Number Generator

This going to be an easy tutorial. We query a number from the (undocumented) hardware random number generator. You can use this to implement a simple, but accurate dice throw in any game. It is important as without hardware support you can only generate pseudo-random numbers.

rand.s

Due to lack of documentation, we mimic the respective Linux driver.

Rng::init(&self) initializes the hardware.

Rng::rand(&self, min: u32, max: u32) returns a random number between min and max.

main.rs

Press a key to query a random value and then display it on the serial console.