rust-raspberrypi-OS-tutorials/09_delays
Andre Richter 3f92aab6e7
Bump extern crates
cortex-a -> 2.2.1
panic-abort -> 0.3.1
2018-10-02 23:47:09 +02:00
..
.cargo Use aarch64-unknown-none target in nightly 🎉 2018-08-19 23:42:24 +02:00
raspi3_boot Bump extern crates 2018-10-02 23:47:09 +02:00
src Bump cortex-a to v2.0.1 2018-08-26 21:37:46 +02:00
Cargo.lock Bump extern crates 2018-10-02 23:47:09 +02:00
Cargo.toml Bump extern crates 2018-10-02 23:47:09 +02:00
kernel8 Bump extern crates 2018-10-02 23:47:09 +02:00
kernel8.img Bump extern crates 2018-10-02 23:47:09 +02:00
link.ld Alignment. Binaries from newer Rust version. 2018-10-02 23:16:04 +02:00
Makefile Makefile: Don't delete kernel8 2018-10-02 23:34:01 +02:00
README.md Add tutorial 0A_power 2018-04-23 22:05:22 +02:00

Tutorial 09 - Delays

It is very important to wait precise amounts of time while you are interfacing with low level hardware. In this tutorial, we'll cover thee ways. One is CPU frequency dependent (and useful if wait time is given in CPU clock cycles), the other two are µs based.

delays.rs

delays::wait_cycles(cyc: u32) this is very straightforward, we execute the nop instruction n times.

delays::wait_msec(n: u32) this implementation uses ARM system registers (available on all AArch64 CPUs).

delays::SysTmr::wait_msec_st(&self, n: u64) is a BCM specific implementation, which uses the System Timer peripheral (not available on qemu).

uart.rs

We can now conveniently use delays::wait_cycles() in Uart::init().

main.rs

We test our different wait implementations.