Compare commits

..

3 Commits

Author SHA1 Message Date
18e89d7410 Add implementation note for embassy-stm32's time-driver
This is a detail I didn't originally understand when hoping to use TIM16/17 as alternative embassy-time driver providers.

Adding my note here to hopefully save the next person a little time.
2023-12-04 15:57:46 +01:00
5f7cd821b5 Merge pull request #2249 from MathiasKoch/embassy-stm32/revert-day-of-week-fix
fix(embassy-stm32): Revert "fix day of the week conversion"
2023-12-04 13:35:27 +00:00
e9fa79bd77 Revert "fix day of the week conversion"
This reverts commit 59a5e84df5.
2023-12-04 14:19:30 +01:00
2 changed files with 12 additions and 1 deletions

View File

@ -211,7 +211,7 @@ pub enum DayOfWeek {
#[cfg(feature = "chrono")]
impl From<chrono::Weekday> for DayOfWeek {
fn from(weekday: Weekday) -> Self {
day_of_week_from_u8(weekday.num_days_from_monday() as u8).unwrap()
day_of_week_from_u8(weekday.number_from_monday() as u8).unwrap()
}
}

View File

@ -18,6 +18,17 @@ use crate::rtc::Rtc;
use crate::timer::sealed::{Basic16bitInstance as BasicInstance, GeneralPurpose16bitInstance as Instance};
use crate::{interrupt, peripherals};
// NOTE regarding ALARM_COUNT:
//
// As of 2023-12-04, this driver is implemented using CC1 as the halfway rollover interrupt, and any
// additional CC capabilities to provide timer alarms to embassy-time. embassy-time requires AT LEAST
// one alarm to be allocatable, which means timers that only have CC1, such as TIM16/TIM17, are not
// candidates for use as an embassy-time driver provider.
//
// The values of ALARM_COUNT below are not the TOTAL CC registers available, but rather the number
// available after reserving CC1 for regular time keeping. For example, TIM2 has four CC registers:
// CC1, CC2, CC3, and CC4, so it can provide ALARM_COUNT = 3.
#[cfg(not(any(time_driver_tim12, time_driver_tim15)))]
const ALARM_COUNT: usize = 3;