Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rtic-monotonics: Add documentation for i.MX RT and other doc fixes #833

Merged
merged 3 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions rtic-monotonics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ description = "A library that provides implementations of the Monotonic trait fr
license = "MIT OR Apache-2.0"

[package.metadata.docs.rs]
features = ["cortex-m-systick", "rp2040", "nrf52840"]
features = [
"cortex-m-systick",
"rp2040",
"nrf52840",
"imxrt_gpt1",
"imxrt_gpt2",
"imxrt-ral/imxrt1011",
]
rustdoc-flags = ["--cfg", "docsrs"]

[dependencies]
Expand Down Expand Up @@ -51,7 +58,9 @@ imxrt-ral = { version = "0.5.3", optional = true }
[build-dependencies]
proc-macro2 = { version = "1.0.36", optional = true }
quote = { version = "1.0.15", optional = true }
stm32-metapac = { version = "14.0.0", default-features = false, features = ["metadata"], optional = true }
stm32-metapac = { version = "14.0.0", default-features = false, features = [
"metadata",
], optional = true }

[features]
default = []
Expand Down
10 changes: 6 additions & 4 deletions rtic-monotonics/src/imxrt.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! [`Monotonic`] impl for the i.MX RT.
//! [`Monotonic`] implementations for i.MX RT's GPT peripherals.
//!
//! # Example
//!
Expand Down Expand Up @@ -55,7 +55,7 @@ macro_rules! __internal_create_imxrt_timer_interrupt {
}};
}

/// Register GPT1 interrupt for the monotonic.
/// Register the GPT1 interrupt for the monotonic.
#[cfg(feature = "imxrt_gpt1")]
#[macro_export]
macro_rules! create_imxrt_gpt1_token {
Expand All @@ -64,7 +64,7 @@ macro_rules! create_imxrt_gpt1_token {
}};
}

/// Register GPT2 interrupt for the monotonic.
/// Register the GPT2 interrupt for the monotonic.
#[cfg(feature = "imxrt_gpt2")]
#[macro_export]
macro_rules! create_imxrt_gpt2_token {
Expand Down Expand Up @@ -98,7 +98,7 @@ fn calc_now(period: u32, counter: u32) -> u64 {

macro_rules! make_timer {
($mono_name:ident, $timer:ident, $period:ident, $tq:ident$(, doc: ($($doc:tt)*))?) => {
/// Monotonic timer queue implementation.
/// Timer implementing [`Monotonic`] which runs at 1 MHz.
$(
#[cfg_attr(docsrs, doc(cfg($($doc)*)))]
)?
Expand All @@ -113,9 +113,11 @@ macro_rules! make_timer {

impl $mono_name {
/// Starts the monotonic timer.
///
/// - `tick_freq_hz`: The tick frequency of the given timer.
/// - `gpt`: The GPT timer register block instance.
/// - `_interrupt_token`: Required for correct timer interrupt handling.
///
/// This method must be called only once.
pub fn start(tick_freq_hz: u32, gpt: $timer, _interrupt_token: impl crate::InterruptToken<Self>) {
// Find a prescaler that creates our desired tick frequency
Expand Down
3 changes: 3 additions & 0 deletions rtic-monotonics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
//! # RP2040
//! The RP2040 monotonics require that the `rp2040` feature is enabled.
//!
//! # i.MX RT
//! The i.MX RT monotonics require that the feature `imxrt_gpt1` or `imxrt_gpt2` is enabled.
//!
//! # nRF
//! nRF monotonics require that one of the available `nrf52*` features is enabled.
//!
Expand Down
2 changes: 1 addition & 1 deletion rtic-monotonics/src/nrf/timer.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! [`Monotonic`] impl for the 32-bit timers of the nRF series.
//!
//! Not all timers are available on all parts. Ensure that only the available
//! timers are exposed by having the correct `nrf52*` feature enabled for `rtic-monotonic`.
//! timers are exposed by having the correct `nrf52*` feature enabled for `rtic-monotonics`.
//!
//! # Example
//!
Expand Down
2 changes: 1 addition & 1 deletion rtic-monotonics/src/rp2040.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use core::future::Future;
pub use fugit::{self, ExtU64};
use rp2040_pac::{timer, Interrupt, NVIC, RESETS, TIMER};

/// Timer implementing `rtic_monotonic::Monotonic` which runs at 1 MHz.
/// Timer implementing [`Monotonic`] which runs at 1 MHz.
pub struct Timer;

impl Timer {
Expand Down
4 changes: 3 additions & 1 deletion rtic-monotonics/src/stm32.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! [`Monotonic`] impl for the STM32.
//!
//! Not all timers are available on all parts. Ensure that only available
//! timers are exposed by having the correct `stm32*` feature enabled for `rtic-monotonic`.
//! timers are exposed by having the correct `stm32*` feature enabled for `rtic-monotonics`.
//!
//! # Example
//!
Expand Down Expand Up @@ -137,8 +137,10 @@ macro_rules! make_timer {

impl $mono_name {
/// Starts the monotonic timer.
///
/// - `tim_clock_hz`: `TIMx` peripheral clock frequency.
/// - `_interrupt_token`: Required for correct timer interrupt handling.
///
/// This method must be called only once.
pub fn start(tim_clock_hz: u32, _interrupt_token: impl crate::InterruptToken<Self>) {
_generated::$timer::enable();
Expand Down
6 changes: 3 additions & 3 deletions rtic-monotonics/src/systick.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
//!
//! | Feature | Tick rate | Precision |
//! |:----------------:|----------:|----------:|
//! | (none / default) | 1 Hz | 1 ms |
//! | (none / default) | 1 kHz | 1 ms |
//! | systick-100hz | 100 Hz | 10 ms |
//! | systick-10khz | 10 KHz | 0.1 ms |
//! | systick-10khz | 10 kHz | 0.1 ms |

//! # Example
//!
Expand Down Expand Up @@ -67,7 +67,7 @@ cfg_if::cfg_if! {
}
}

/// Systick implementing `rtic_monotonic::Monotonic` which runs at 1 kHz, 100Hz or 10 kHz.
/// Systick implementing [`Monotonic`] which runs at 1 kHz, 100Hz or 10 kHz.
pub struct Systick;

impl Systick {
Expand Down
Loading