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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//! 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, joined by our own [`BpsExtU32`] for bit
//! rates, which `fugit` has no suffix for. 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;
/// Bit rate in symbols per second.
///
/// The very same type as [`Hertz`], a bit rate being a rate on the one-second
/// scale: the name reads right in a signature but checks nothing, and a clock
/// frequency passed as a bit rate still compiles.
pub type Bps = Rate;
/// 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;
/// Suffix for bit rates, `fugit` having none: `115_200.bps()`.