feagi_hal/hal/time.rs
1// Copyright 2025 Neuraville Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4/// Time and delay abstraction for embedded platforms
5pub trait TimeProvider {
6 /// Get current time in microseconds since system boot
7 ///
8 /// # Returns
9 /// Monotonic timestamp in microseconds
10 fn get_time_us(&self) -> u64;
11
12 /// Block for the specified number of microseconds
13 ///
14 /// # Arguments
15 /// * `us` - Microseconds to delay
16 fn delay_us(&self, us: u32);
17
18 /// Block for the specified number of milliseconds
19 ///
20 /// # Arguments
21 /// * `ms` - Milliseconds to delay
22 fn delay_ms(&self, ms: u32) {
23 self.delay_us(ms * 1000);
24 }
25
26 /// Block for the specified number of seconds
27 ///
28 /// # Arguments
29 /// * `s` - Seconds to delay
30 fn delay_s(&self, s: u32) {
31 self.delay_ms(s * 1000);
32 }
33}