diff options
author | 2019-07-11 13:28:25 +0200 | |
---|---|---|
committer | 2019-07-11 13:28:25 +0200 | |
commit | a87cb2486f488666450636c9cb68f79681f5f358 (patch) | |
tree | 69d8ce0cda38b9ff7cef307fae53fd6a275df3ef /src/lib.rs | |
parent | 6a8404ac92a7d4a57188e962862c450be9b9b31a (diff) | |
download | rtic-a87cb2486f488666450636c9cb68f79681f5f358.tar.gz rtic-a87cb2486f488666450636c9cb68f79681f5f358.tar.zst rtic-a87cb2486f488666450636c9cb68f79681f5f358.zip |
change Monotonic::ratio return type to Fraction
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -116,13 +116,25 @@ impl From<cortex_m::Peripherals> for Peripherals { } } +/// A fraction +pub struct Fraction { + /// The numerator + pub numerator: u32, + + /// The denominator + pub denominator: u32, +} + /// A monotonic clock / counter pub trait Monotonic { /// A measurement of this clock type Instant: Copy + Ord + Sub; /// The ratio between the SysTick (system timer) frequency and this clock frequency - fn ratio() -> u32; + /// + /// The ratio must be expressed in *reduced* `Fraction` form to prevent overflows. That is + /// `2 / 3` instead of `4 / 6` + fn ratio() -> Fraction; /// Returns the current time fn now() -> Self::Instant; |