From a24163b3e357dc5e4ea4ae00817bc11a4c455d83 Mon Sep 17 00:00:00 2001 From: Wojciech Olech Date: Tue, 29 Aug 2023 17:52:48 +0200 Subject: [PATCH] Examples: Added printing of startup time to system time example of SAMV71 --- examples/samv71-system-time/src/main.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/examples/samv71-system-time/src/main.rs b/examples/samv71-system-time/src/main.rs index 97fc7354..8bd8b2ce 100644 --- a/examples/samv71-system-time/src/main.rs +++ b/examples/samv71-system-time/src/main.rs @@ -18,6 +18,20 @@ struct DummyTaskContext { fn dummy_task(_: (), context: &mut DummyTaskContext, api: &'static dyn RuntimeApi) { context.acc = context.acc.wrapping_add(1); + + if context.acc == 10 { + let startup_time = api.get_startup_time(); + let startup_secs = startup_time.unwrap().to_secs(); + let startup_ms = startup_time.unwrap().to_millis() % 1000; + let startup_us = startup_time.unwrap().to_micros() % (1000 * 1000); + logln!( + "Startup time is {}s, {}ms, {}ns", + startup_secs, + startup_ms, + startup_us + ); + } + if context.acc % 300 == 0 { let time = api.get_system_time().duration_since_epoch(); let time_seconds = time.to_secs();