-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ztimer: Add acquire(), now() and time()
Merges: #103
- Loading branch information
Showing
6 changed files
with
218 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[package] | ||
name = "riot-wrappers-test-ztimer" | ||
version = "0.1.0" | ||
authors = ["Christian Amsüss <chrysn@fsfe.org>"] | ||
edition = "2021" | ||
publish = false | ||
|
||
[lib] | ||
crate-type = ["staticlib"] | ||
|
||
[profile.release] | ||
panic = "abort" | ||
|
||
[dependencies] | ||
riot-wrappers = { path = "../..", features = [ "set_panic_handler", "panic_handler_format" ] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# name of your application | ||
APPLICATION = riot-wrappers-test-ztimer | ||
BOARD ?= native | ||
APPLICATION_RUST_MODULE = riot_wrappers_test_ztimer | ||
BASELIBS += $(APPLICATION_RUST_MODULE).module | ||
FEATURES_REQUIRED += rust_target | ||
|
||
USEMODULE += ztimer_usec | ||
USEMODULE += ztimer_msec | ||
|
||
include $(RIOTBASE)/Makefile.include |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#![no_std] | ||
|
||
use riot_wrappers::println; | ||
use riot_wrappers::riot_main; | ||
|
||
riot_main!(main); | ||
|
||
fn main() { | ||
use riot_wrappers::ztimer::*; | ||
|
||
let msec = Clock::msec(); | ||
|
||
println!("Waiting 500 ticks on the msec timer before doing anything else"); | ||
let duration = msec.time(|| { | ||
msec.sleep_ticks(500); | ||
}); | ||
let duration = | ||
duration.expect("That should not have taken so long that the milliseconds overflowed"); | ||
println!("That took {} ticks", duration.0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
import sys | ||
from testrunner import run | ||
|
||
def test(child): | ||
match_1 = child.expect("That took") | ||
|
||
if __name__ == "__main__": | ||
sys.exit(run(test)) |