Skip to content

Commit

Permalink
feat(rtic-v2-rtc-monotonics): Addresses some minor issues when checki…
Browse files Browse the repository at this point in the history
…ng things with the `build-all.py` script.

* Renames the `wait_for_count_change` to `_wait_for_count_change` function name to suppress an unused warning for SAMD11/21 chips.
* Fixes the `metro_m0` example `blinky_rtic.rs` to fix an RTIC v1 item location change.
  • Loading branch information
Dan Whitman committed Dec 21, 2024
1 parent 9d77960 commit b81f752
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion boards/metro_m0/examples/blinky_rtic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ mod app {
use hal::clock::{ClockGenId, ClockSource, GenericClockController};
use hal::pac::Peripherals;
use hal::prelude::*;
use hal::rtc::{Count32Mode, Duration, Rtc};
use hal::rtc::{rtic::v1::Duration, Count32Mode, Rtc};

#[local]
struct Local {}
Expand Down
1 change: 1 addition & 0 deletions hal/src/rtc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use core::marker::PhantomData;
#[cfg(feature = "sdmmc")]
use embedded_sdmmc::{TimeSource, Timestamp};

#[cfg(feature = "rtic")]
mod modes;

#[cfg(feature = "rtic")]
Expand Down
4 changes: 2 additions & 2 deletions hal/src/rtc/modes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ pub trait RtcMode {

// Errata: The first read of the count is incorrect so we need to read it
// then wait for it to change.
Self::wait_for_count_change(rtc);
Self::_wait_for_count_change(rtc);
}
}

Expand Down Expand Up @@ -189,7 +189,7 @@ pub trait RtcMode {
/// Note that this may not necessarily be the next tick due sync delay.
/// Beware that this will wait forever if the RTC is disabled!
#[inline]
fn wait_for_count_change(rtc: &Rtc) -> Self::Count {
fn _wait_for_count_change(rtc: &Rtc) -> Self::Count {
let mut last_count = Self::count(rtc);

loop {
Expand Down
14 changes: 9 additions & 5 deletions hal/src/rtc/rtic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,21 @@
//! changes. This is true regardless of the clock rate used, as the
//! synchronization delay scales along with the clock period.
// TODO: Need to revisit this and either modernize (e.g. it does not use period
// counting) it or remove it.
mod v1 {
/// Items for RTIC v1.
///
/// TODO: This probably needs to be modernized (e.g. it does not implement
/// half-period counting) or deprecated/removed.
pub mod v1 {
use crate::rtc::{Count32Mode, Rtc};
use rtic_monotonic::Monotonic;

/// The RTC clock frequency in Hz.
pub const CLOCK_FREQ: u32 = 32_768;

type Instant = fugit::Instant<u32, 1, CLOCK_FREQ>;
type Duration = fugit::Duration<u32, 1, CLOCK_FREQ>;
/// The [`fugit`] time instant.
pub type Instant = fugit::Instant<u32, 1, CLOCK_FREQ>;
/// The [`fugit`] time duration.
pub type Duration = fugit::Duration<u32, 1, CLOCK_FREQ>;

impl Monotonic for Rtc<Count32Mode> {
type Instant = Instant;
Expand Down

0 comments on commit b81f752

Please sign in to comment.