Struct stm32wlxx_hal::rtc::Alarm
source · pub struct Alarm { /* private fields */ }
chrono
only.Expand description
Alarm settings.
By default the date, hour, minute, and second are compared, but not the sub-seconds.
Example
Compare only seconds:
use stm32wlxx_hal::rtc::Alarm;
const NO_COMPARE: Alarm = Alarm::DEFAULT
.set_days_mask(true)
.set_hours_mask(true)
.set_minutes_mask(true)
.set_seconds_mask(false);
Implementations§
source§impl Alarm
impl Alarm
sourcepub const DEFAULT: Self = _
pub const DEFAULT: Self = _
Default alarm settings, as a constant.
Example
use stm32wlxx_hal::rtc::Alarm;
assert_eq!(Alarm::DEFAULT, Alarm::default());
sourcepub const fn set_seconds(self, seconds: u8) -> Self
pub const fn set_seconds(self, seconds: u8) -> Self
Set the seconds value of the alarm.
If the seconds value is greater than 59 it will be truncated.
Example
use stm32wlxx_hal::rtc::Alarm;
let alarm: Alarm = Alarm::default();
assert_eq!(alarm.seconds(), 0);
let alarm: Alarm = alarm.set_seconds(31);
assert_eq!(alarm.seconds(), 31);
let alarm: Alarm = alarm.set_seconds(60);
assert_eq!(alarm.seconds(), 59);
sourcepub const fn set_seconds_mask(self, mask: bool) -> Self
pub const fn set_seconds_mask(self, mask: bool) -> Self
Set the alarm seconds mask.
false
: Alarm is set if the seconds match.true
: Seconds are “do not care” in the alarm comparison.
Example
use stm32wlxx_hal::rtc::Alarm;
let alarm: Alarm = Alarm::default();
assert_eq!(alarm.seconds_mask(), false);
let alarm: Alarm = alarm.set_seconds_mask(true);
assert_eq!(alarm.seconds_mask(), true);
let alarm: Alarm = alarm.set_seconds_mask(false);
assert_eq!(alarm.seconds_mask(), false);
sourcepub const fn seconds_mask(&self) -> bool
pub const fn seconds_mask(&self) -> bool
Return true
if the seconds mask is set.
sourcepub const fn set_minutes(self, minutes: u8) -> Self
pub const fn set_minutes(self, minutes: u8) -> Self
Set the minutes value of the alarm.
If the minutes value is greater than 59 it will be truncated.
Example
use stm32wlxx_hal::rtc::Alarm;
let alarm: Alarm = Alarm::default();
assert_eq!(alarm.minutes(), 0);
let alarm: Alarm = alarm.set_minutes(31);
assert_eq!(alarm.minutes(), 31);
let alarm: Alarm = alarm.set_minutes(60);
assert_eq!(alarm.minutes(), 59);
sourcepub const fn set_minutes_mask(self, mask: bool) -> Self
pub const fn set_minutes_mask(self, mask: bool) -> Self
Set the alarm minutes mask.
false
: Alarm is set if the minutes match.true
: Minutes are “do not care” in the alarm comparison.
Example
use stm32wlxx_hal::rtc::Alarm;
let alarm: Alarm = Alarm::default();
assert_eq!(alarm.minutes_mask(), false);
let alarm: Alarm = alarm.set_minutes_mask(true);
assert_eq!(alarm.minutes_mask(), true);
let alarm: Alarm = alarm.set_minutes_mask(false);
assert_eq!(alarm.minutes_mask(), false);
sourcepub const fn minutes_mask(&self) -> bool
pub const fn minutes_mask(&self) -> bool
Return true
if the minutes mask is set.
sourcepub const fn set_hours(self, hours: u8) -> Self
pub const fn set_hours(self, hours: u8) -> Self
Set the hours value of the alarm.
If the hours value is greater than 23 it will be truncated.
Example
use stm32wlxx_hal::rtc::Alarm;
let alarm: Alarm = Alarm::default();
assert_eq!(alarm.hours(), 0);
let alarm: Alarm = alarm.set_hours(15);
assert_eq!(alarm.hours(), 15);
let alarm: Alarm = alarm.set_hours(24);
assert_eq!(alarm.hours(), 23);
sourcepub const fn set_hours_mask(self, mask: bool) -> Self
pub const fn set_hours_mask(self, mask: bool) -> Self
Set the alarm hours mask.
false
: Alarm is set if the hours match.true
: Hours are “do not care” in the alarm comparison.
Example
use stm32wlxx_hal::rtc::Alarm;
let alarm: Alarm = Alarm::default();
assert_eq!(alarm.hours_mask(), false);
let alarm: Alarm = alarm.set_hours_mask(true);
assert_eq!(alarm.hours_mask(), true);
let alarm: Alarm = alarm.set_hours_mask(false);
assert_eq!(alarm.hours_mask(), false);
sourcepub const fn hours_mask(&self) -> bool
pub const fn hours_mask(&self) -> bool
Return true
if the hours mask is set.
sourcepub const fn set_days(self, day: u8) -> Self
pub const fn set_days(self, day: u8) -> Self
Set the day for the alarm.
This is mutually exclusive with set_weekday
.
If the day value is greater than 31 it will be truncated.
Example
use stm32wlxx_hal::rtc::{Alarm, AlarmDay};
let alarm: Alarm = Alarm::default();
assert_eq!(alarm.day(), AlarmDay::Day(0));
let alarm: Alarm = alarm.set_days(14);
assert_eq!(alarm.day(), AlarmDay::Day(14));
let alarm: Alarm = alarm.set_days(32);
assert_eq!(alarm.day(), AlarmDay::Day(31));
sourcepub fn set_weekday(self, wd: Weekday) -> Self
pub fn set_weekday(self, wd: Weekday) -> Self
Set the weekday for the alarm.
This is mutually exclusive with set_days
.
Example
use stm32wlxx_hal::{
chrono::Weekday,
rtc::{Alarm, AlarmDay},
};
let alarm: Alarm = Alarm::default();
assert_eq!(alarm.day(), AlarmDay::Day(0));
let alarm: Alarm = alarm.set_weekday(Weekday::Mon);
assert_eq!(alarm.day(), AlarmDay::Weekday(Weekday::Mon));
let alarm: Alarm = alarm.set_weekday(Weekday::Tue);
assert_eq!(alarm.day(), AlarmDay::Weekday(Weekday::Tue));
let alarm: Alarm = alarm.set_weekday(Weekday::Wed);
assert_eq!(alarm.day(), AlarmDay::Weekday(Weekday::Wed));
let alarm: Alarm = alarm.set_weekday(Weekday::Thu);
assert_eq!(alarm.day(), AlarmDay::Weekday(Weekday::Thu));
let alarm: Alarm = alarm.set_weekday(Weekday::Fri);
assert_eq!(alarm.day(), AlarmDay::Weekday(Weekday::Fri));
let alarm: Alarm = alarm.set_weekday(Weekday::Sat);
assert_eq!(alarm.day(), AlarmDay::Weekday(Weekday::Sat));
let alarm: Alarm = alarm.set_weekday(Weekday::Sun);
assert_eq!(alarm.day(), AlarmDay::Weekday(Weekday::Sun));
sourcepub const fn set_days_mask(self, mask: bool) -> Self
pub const fn set_days_mask(self, mask: bool) -> Self
Set the alarm day / weekday mask.
false
: Alarm is set if the days / weekdays match.true
: Days / weekdays are “do not care” in the alarm comparison.
Example
use stm32wlxx_hal::rtc::Alarm;
let alarm: Alarm = Alarm::default();
assert_eq!(alarm.days_mask(), false);
let alarm: Alarm = alarm.set_days_mask(true);
assert_eq!(alarm.days_mask(), true);
let alarm: Alarm = alarm.set_days_mask(false);
assert_eq!(alarm.days_mask(), false);
sourcepub const fn set_subseconds(self, ss: u32) -> Self
pub const fn set_subseconds(self, ss: u32) -> Self
Set the sub-seconds value.
Example
use stm32wlxx_hal::rtc::Alarm;
let alarm: Alarm = Alarm::default();
assert_eq!(alarm.subseconds(), 0);
let alarm: Alarm = alarm.set_subseconds(1);
assert_eq!(alarm.subseconds(), 1);
let alarm: Alarm = alarm.set_subseconds(u32::MAX);
assert_eq!(alarm.subseconds(), u32::MAX);
sourcepub const fn subseconds(&self) -> u32
pub const fn subseconds(&self) -> u32
Get the sub-seconds value.
sourcepub const fn set_subseconds_mask(self, mask: u8) -> Self
pub const fn set_subseconds_mask(self, mask: u8) -> Self
Set the sub-seconds mask.
- 0: No comparison on sub seconds for the alarm. The alarm is set when the seconds unit is incremented (assuming that the rest of the fields match).
- 1: SS[31:1] are “do not care” in the alarm comparison. Only SS[0] is compared.
- 2: SS[31:2] are “do not care” in the alarm comparison. Only SS[1:0] are compared.
- …
- 31: SS[31] is “do not care” in the alarm comparison. Only SS[30:0] are compared.
- 32 to 63: All 32 SS bits are compared and must match to activate the alarm.
Values greater than 63 will be truncated.
Example
use stm32wlxx_hal::rtc::Alarm;
let alarm: Alarm = Alarm::default();
assert_eq!(alarm.subseconds_mask(), 0);
let alarm: Alarm = alarm.set_subseconds_mask(17);
assert_eq!(alarm.subseconds_mask(), 17);
let alarm: Alarm = alarm.set_subseconds_mask(128);
assert_eq!(alarm.subseconds_mask(), 63);
sourcepub const fn subseconds_mask(&self) -> u8
pub const fn subseconds_mask(&self) -> u8
Get the sub-seconds mask.