1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//! Typed units for frequencies and durations, aliased from `fugit`.
//!
//! The units themselves come from [`fugit`], which keeps rates and durations
//! apart as distinct kinds and converts between scales at compile time. This
//! module names its `u32` instances, so signatures stay short and the dependency
//! is pinned in one place; `u64` is not aliased, the core being 32-bit.
//!
//! The scale lives in the type and costs nothing at runtime, so a value crosses
//! between units by conversion rather than by arithmetic on a bare number.
//!
//! The generic [`Duration`] and [`Rate`] are re-exported for signatures that
//! stay open to any scale, as are the suffix traits: [`ExtU32`] for durations
//! and [`RateExtU32`] for frequencies. The whole crate is re-exported too, so
//! `Instant`, the tick-based `TimerDuration` and the `u64` widths are reachable
//! without adding a matching dependency downstream.
//!
//! ```ignore
//! use gd32e2_hal::time::ExtU32;
//! let period = 5.secs();
//! ```
pub use fugit;
pub use ;
/// Frequency in hertz.
pub type Hertz = HertzU32;
/// Frequency in kilohertz.
pub type Kilohertz = KilohertzU32;
/// Frequency in megahertz.
pub type Megahertz = MegahertzU32;
/// Frequency in gigahertz.
pub type Gigahertz = GigahertzU32;
/// Duration in picoseconds.
pub type PicosDuration = PicosDurationU32;
/// Duration in nanoseconds.
pub type NanosDuration = NanosDurationU32;
/// Duration in microseconds.
pub type MicrosDuration = MicrosDurationU32;
/// Duration in milliseconds.
pub type MillisDuration = MillisDurationU32;
/// Duration in seconds.
pub type SecsDuration = SecsDurationU32;
/// Duration in minutes.
pub type MinutesDuration = MinutesDurationU32;
/// Duration in hours.
pub type HoursDuration = HoursDurationU32;