rust-raspberrypi-OS-tutorials/08_random
2018-08-26 21:37:46 +02:00
..
.cargo Use aarch64-unknown-none target in nightly 🎉 2018-08-19 23:42:24 +02:00
raspi3_boot Bump cortex-a to v2.0.1 2018-08-26 21:37:46 +02:00
src rust-fmt all 2018-08-26 14:02:07 +02:00
Cargo.lock Bump cortex-a to v2.0.1 2018-08-26 21:37:46 +02:00
Cargo.toml Bump cortex-a to v2.0.1 2018-08-26 21:37:46 +02:00
kernel8 Bump cortex-a to v2.0.1 2018-08-26 21:37:46 +02:00
kernel8.img Fix wrong Stack address 2018-08-26 13:58:12 +02:00
link.ld Correct linker issues 2018-08-20 17:07:18 +02:00
Makefile Use cargo-xbuild 2018-08-21 21:22:50 +02:00
README.md Rewrite for register-rs. 2018-07-16 21:24:33 +02: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] (https://github.com/torvalds/linux/blob/master/drivers/char/hw_random/bcm2835-rng.c).

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.