diff options
| author | Barnaby Walters <[email protected]> | 2023-12-22 17:08:39 +0100 |
|---|---|---|
| committer | Barnaby Walters <[email protected]> | 2023-12-22 17:08:39 +0100 |
| commit | 0fb57ef87d678830e2ccb3753432535897bbb1c3 (patch) | |
| tree | 48393d59a2a0b827df359240febbdf6b5c51b948 /embassy-time/README.md | |
| parent | 87c03037e320ce30c0cd34fe97e0365e1b11aa9a (diff) | |
Improved documentation
* Documented features including all tick rates
* Corrected some out-of-date information
* Sorted tick rate features
* Removed gen_tick.py dependency on toml
* Restructured README.md to better explain tick rate, more
clearly prioritise time driver docs, correct header levels
Diffstat (limited to 'embassy-time/README.md')
| -rw-r--r-- | embassy-time/README.md | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/embassy-time/README.md b/embassy-time/README.md index 2be80ff9c..a4a622700 100644 --- a/embassy-time/README.md +++ b/embassy-time/README.md | |||
| @@ -3,25 +3,40 @@ | |||
| 3 | Timekeeping, delays and timeouts. | 3 | Timekeeping, delays and timeouts. |
| 4 | 4 | ||
| 5 | Timekeeping is done with elapsed time since system boot. Time is represented in | 5 | Timekeeping is done with elapsed time since system boot. Time is represented in |
| 6 | ticks, where the tick rate is defined by the current driver, usually to match | 6 | ticks, where the tick rate is defined either by the driver (in the case of a fixed- |
| 7 | the tick rate of the hardware. | 7 | rate tick) or chosen by the user with a [tick rate](#tick-rate) feature. The chosen |
| 8 | tick rate applies to everything in `embassy-time` and thus determines the maximum | ||
| 9 | timing resolution of <code>(1 / tick_rate) seconds</code>. | ||
| 8 | 10 | ||
| 9 | Tick counts are 64 bits. At the highest supported tick rate of 1Mhz this supports | 11 | Tick counts are 64 bits. The default tick rate of 1Mhz supports |
| 10 | representing time spans of up to ~584558 years, which is big enough for all practical | 12 | representing time spans of up to ~584558 years, which is big enough for all practical |
| 11 | purposes and allows not having to worry about overflows. | 13 | purposes and allows not having to worry about overflows. |
| 12 | 14 | ||
| 15 | ## Time driver | ||
| 16 | |||
| 17 | The `time` module is backed by a global "time driver" specified at build time. | ||
| 18 | Only one driver can be active in a program. | ||
| 19 | |||
| 20 | All methods and structs transparently call into the active driver. This makes it | ||
| 21 | possible for libraries to use `embassy_time` in a driver-agnostic way without | ||
| 22 | requiring generic parameters. | ||
| 23 | |||
| 24 | For more details, check the [`driver`] module. | ||
| 25 | |||
| 26 | ## Instants and Durations | ||
| 27 | |||
| 13 | [`Instant`] represents a given instant of time (relative to system boot), and [`Duration`] | 28 | [`Instant`] represents a given instant of time (relative to system boot), and [`Duration`] |
| 14 | represents the duration of a span of time. They implement the math operations you'd expect, | 29 | represents the duration of a span of time. They implement the math operations you'd expect, |
| 15 | like addition and substraction. | 30 | like addition and substraction. |
| 16 | 31 | ||
| 17 | # Delays and timeouts | 32 | ## Delays and timeouts |
| 18 | 33 | ||
| 19 | [`Timer`] allows performing async delays. [`Ticker`] allows periodic delays without drifting over time. | 34 | [`Timer`] allows performing async delays. [`Ticker`] allows periodic delays without drifting over time. |
| 20 | 35 | ||
| 21 | An implementation of the `embedded-hal` delay traits is provided by [`Delay`], for compatibility | 36 | An implementation of the `embedded-hal` delay traits is provided by [`Delay`], for compatibility |
| 22 | with libraries from the ecosystem. | 37 | with libraries from the ecosystem. |
| 23 | 38 | ||
| 24 | # Wall-clock time | 39 | ## Wall-clock time |
| 25 | 40 | ||
| 26 | The `time` module deals exclusively with a monotonically increasing tick count. | 41 | The `time` module deals exclusively with a monotonically increasing tick count. |
| 27 | Therefore it has no direct support for wall-clock time ("real life" datetimes | 42 | Therefore it has no direct support for wall-clock time ("real life" datetimes |
| @@ -30,14 +45,3 @@ like `2021-08-24 13:33:21`). | |||
| 30 | If persistence across reboots is not needed, support can be built on top of | 45 | If persistence across reboots is not needed, support can be built on top of |
| 31 | `embassy_time` by storing the offset between "seconds elapsed since boot" | 46 | `embassy_time` by storing the offset between "seconds elapsed since boot" |
| 32 | and "seconds since unix epoch". | 47 | and "seconds since unix epoch". |
| 33 | |||
| 34 | # Time driver | ||
| 35 | |||
| 36 | The `time` module is backed by a global "time driver" specified at build time. | ||
| 37 | Only one driver can be active in a program. | ||
| 38 | |||
| 39 | All methods and structs transparently call into the active driver. This makes it | ||
| 40 | possible for libraries to use `embassy_time` in a driver-agnostic way without | ||
| 41 | requiring generic parameters. | ||
| 42 | |||
| 43 | For more details, check the [`driver`] module. | ||
