Module time

Module time 

Source
Expand description

Time units

See HertzU32, KilohertzU32 and MegahertzU32 for creating increasingly higher frequencies.

The fugit::ExtU32 U32Ext trait adds various methods like .Hz(), .MHz(), etc to the u32 primitive type, allowing it to be converted into frequencies.

§Examples

§Create a 2 MHz frequency

This example demonstrates various ways of creating a 2 MHz (2_000_000 Hz) frequency. They are all equivalent, however the 2.MHz() variant should be preferred for readability.

use stm32f1xx_hal::{
    time::HertzU32,
    // Imports U32Ext trait
    prelude::*,
};

let freq_hz = 2_000_000.Hz();
let freq_khz = 2_000.kHz();
let freq_mhz = 2.MHz();

assert_eq!(freq_hz, freq_khz);
assert_eq!(freq_khz, freq_mhz);

Structs§

Bps
Bits per second
Duration
Represents a duration of time.
DwtInstant
A TickInstant implementation
Instant
A measurement of a monotonically non-decreasing clock
MonoTimer
A monotonic non-decreasing timer

Traits§

RateExtU32
Extension trait for simple short-hands for u32 Rate
U32Ext
Extension trait that adds convenience methods to the u32 type

Functions§

Hz
MHz
kHz
ms
us

Type Aliases§

HertzU32
Alias for hertz rate (u32 backing storage)
KilohertzU32
Alias for kilohertz rate (u32 backing storage)
MegahertzU32
Alias for megahertz rate (u32 backing storage)
MicrosDurationU32
Alias for microsecond duration (u32 backing storage)
MillisDurationU32
Alias for millisecond duration (u32 backing storage)