mirror of
https://github.com/rtic-rs/rtic.git
synced 2025-12-19 06:15:45 +01:00
Monotonic trait is safe; add MultiCore trait
This commit is contained in:
parent
4e51bb68b9
commit
596cf585ea
7 changed files with 35 additions and 9 deletions
|
|
@ -116,6 +116,11 @@ pub struct Duration {
|
|||
}
|
||||
|
||||
impl Duration {
|
||||
/// Creates a new `Duration` from the specified number of clock cycles
|
||||
pub fn from_cycles(cycles: u32) -> Self {
|
||||
Duration { inner: cycles }
|
||||
}
|
||||
|
||||
/// Returns the total number of clock cycles contained by this `Duration`
|
||||
pub fn as_cycles(&self) -> u32 {
|
||||
self.inner
|
||||
|
|
@ -181,7 +186,7 @@ impl U32Ext for u32 {
|
|||
pub struct CYCCNT;
|
||||
|
||||
#[cfg(not(feature = "heterogeneous"))]
|
||||
unsafe impl crate::Monotonic for CYCCNT {
|
||||
impl crate::Monotonic for CYCCNT {
|
||||
type Instant = Instant;
|
||||
|
||||
fn ratio() -> u32 {
|
||||
|
|
|
|||
|
|
@ -108,6 +108,13 @@ where
|
|||
{
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn assert_multicore<T>()
|
||||
where
|
||||
T: super::MultiCore,
|
||||
{
|
||||
}
|
||||
|
||||
#[cfg(armv7m)]
|
||||
#[inline(always)]
|
||||
pub unsafe fn lock<T, R>(
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ impl From<cortex_m::Peripherals> for Peripherals {
|
|||
}
|
||||
|
||||
/// A monotonic clock / counter
|
||||
pub unsafe trait Monotonic {
|
||||
pub trait Monotonic {
|
||||
/// A measurement of this clock
|
||||
type Instant: Copy + Ord + Sub;
|
||||
|
||||
|
|
@ -134,6 +134,9 @@ pub unsafe trait Monotonic {
|
|||
fn zero() -> Self::Instant;
|
||||
}
|
||||
|
||||
/// A marker trait that indicates that it is correct to use this type in multi-core context
|
||||
pub trait MultiCore {}
|
||||
|
||||
/// Sets the given `interrupt` as pending
|
||||
///
|
||||
/// This is a convenience function around
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue