#raspberry-pi #bare-metal #timer #ruspiro

no-std ruspiro-timer

This crates provides simple timing functions to pause the current processing for a specific amount of time. The core pausing is called on will block.

9 releases (5 breaking)

0.6.0 Nov 26, 2021
0.5.2 Sep 6, 2021
0.5.1 May 13, 2021
0.4.1 Sep 12, 2020
0.0.1 Aug 1, 2019

#1523 in Embedded development

Download history 5/week @ 2024-07-07 47/week @ 2024-07-28 2/week @ 2024-09-22 62/week @ 2024-09-29

64 downloads per month
Used in 3 crates

Apache-2.0 OR MIT

24KB
211 lines

Timer RusPiRo crate

This crate provides simple functions to pause execution on the current core for a given amount of time. It uses the free-running counter of the Raspberry Pi to provide micro second accurate pause timings.

CI Latest Version Documentation License

Features

Feature Description
pi3 active to use the proper timer MMIO base memory address for Raspberry Pi 3 when accessing the system timer peripheral
pi4_low active to use the proper timer MMIO base memory address for Raspberry Pi 4 in Low-Peripheral mode when accessing the system timer peripheral
pi4_high active to use the proper timer MMIO base memory address for Raspberry Pi 4 in High-Peripheral mode when accessing the system timer peripheral

Usage

To use the crate just add the following dependency to your Cargo.toml file:

[dependencies]
ruspiro-timer = "0.6.0"

Once done the access to the timer functions is available in your rust files like so:

use rusprio_timer::*;

fn foo() {
    sleep(Duration::from_millis(1)); // pause for 1 millisecond
    sleepcycles(200); // pause for 200 CPU cycles
}

Scheduling the execution of a function/closure is as simple as this:

use ruspiro_timer::*;

fn foo() {
    // print after 100 milliseconds
    schedule(Duration:from_millis(100), || println!("delayed execution"));
}

License

Licensed under Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0) or MIT (LICENSE-MIT or http://opensource.org/licenses/MIT)) at your choice.

Dependencies

~1.5MB
~39K SLoC