Skip to content

Commit 9fed54e

Browse files
authored
Merge pull request #660 from stm32-rs/date-defmt
fix defmt compilation
2 parents 58edb9b + 2520ba0 commit 9fed54e

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"rust-analyzer.check.allTargets": false,
33
"rust-analyzer.check.targets": "thumbv7em-none-eabihf",
44
"rust-analyzer.cargo.features": [
5+
"defmt",
56
"rtic",
67
"stm32f411"
78
],

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10+
### Changed
11+
12+
- enable `defmt` feature for VSCode
13+
- `set_alarm` takes `Into<AlarmDay>`
14+
15+
### Fixed
16+
17+
- Compilation with `defmt` feature enabled
18+
1019
## [v0.16.1] - 2023-06-24
1120

1221
- bors bot replaced with GH merge queue

src/rtc.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,25 @@ impl From<Alarm> for Event {
4343
}
4444
}
4545

46-
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
4746
#[derive(Debug, Eq, PartialEq, Copy, Clone)]
4847
pub enum AlarmDay {
4948
Date(Date),
5049
Weekday(Weekday),
5150
EveryDay,
5251
}
5352

53+
impl From<Date> for AlarmDay {
54+
fn from(date: Date) -> Self {
55+
Self::Date(date)
56+
}
57+
}
58+
59+
impl From<Weekday> for AlarmDay {
60+
fn from(day: Weekday) -> Self {
61+
Self::Weekday(day)
62+
}
63+
}
64+
5465
/// RTC clock source LSE oscillator clock (type state)
5566
pub struct Lse;
5667
/// RTC clock source LSI oscillator clock (type state)
@@ -599,7 +610,13 @@ impl<CS> Rtc<CS> {
599610

600611
/// Sets the time at which an alarm will be triggered
601612
/// This also clears the alarm flag if it is set
602-
pub fn set_alarm(&mut self, alarm: Alarm, date: AlarmDay, time: Time) -> Result<(), Error> {
613+
pub fn set_alarm(
614+
&mut self,
615+
alarm: Alarm,
616+
date: impl Into<AlarmDay>,
617+
time: Time,
618+
) -> Result<(), Error> {
619+
let date = date.into();
603620
let (daymask, wdsel, (dt, du)) = match date {
604621
AlarmDay::Date(date) => (false, false, bcd2_encode(date.day().into())?),
605622
AlarmDay::Weekday(weekday) => (false, true, (0, weekday.number_days_from_monday())),

0 commit comments

Comments
 (0)