2020-03-28 12:25:50 +00:00
|
|
|
// SPDX-License-Identifier: MIT OR Apache-2.0
|
|
|
|
//
|
2021-01-01 10:28:32 +00:00
|
|
|
// Copyright (c) 2020-2021 Andre Richter <andre.o.richter@gmail.com>
|
2020-03-28 12:25:50 +00:00
|
|
|
|
|
|
|
//! Timer primitives.
|
|
|
|
|
|
|
|
#[cfg(target_arch = "aarch64")]
|
|
|
|
#[path = "_arch/aarch64/time.rs"]
|
|
|
|
mod arch_time;
|
|
|
|
pub use arch_time::*;
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
// Public Definitions
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/// Timekeeping interfaces.
|
|
|
|
pub mod interface {
|
|
|
|
use core::time::Duration;
|
|
|
|
|
|
|
|
/// Time management functions.
|
|
|
|
///
|
|
|
|
/// The `BSP` is supposed to supply one global instance.
|
|
|
|
pub trait TimeManager {
|
|
|
|
/// The timer's resolution.
|
|
|
|
fn resolution(&self) -> Duration;
|
|
|
|
|
|
|
|
/// The uptime since power-on of the device.
|
|
|
|
///
|
|
|
|
/// This includes time consumed by firmware and bootloaders.
|
|
|
|
fn uptime(&self) -> Duration;
|
|
|
|
|
|
|
|
/// Spin for a given duration.
|
|
|
|
fn spin_for(&self, duration: Duration);
|
|
|
|
}
|
|
|
|
}
|