Struct stm32wlxx_hal::rtc::Alarm

source ·
pub struct Alarm { /* private fields */ }
Available on crate feature 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

source

pub const DEFAULT: Self = _

Default alarm settings, as a constant.

Example
use stm32wlxx_hal::rtc::Alarm;

assert_eq!(Alarm::DEFAULT, Alarm::default());
source

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);
source

pub const fn seconds(&self) -> u8

Get the seconds value of the alarm.

source

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);
source

pub const fn seconds_mask(&self) -> bool

Return true if the seconds mask is set.

source

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);
source

pub const fn minutes(&self) -> u8

Get the minutes value of the alarm.

source

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);
source

pub const fn minutes_mask(&self) -> bool

Return true if the minutes mask is set.

source

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);
source

pub const fn hours(&self) -> u8

Get the hours value of the alarm.

source

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);
source

pub const fn hours_mask(&self) -> bool

Return true if the hours mask is set.

source

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));
source

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));
source

pub fn day(&self) -> AlarmDay

Get the weekday or day of the alarm.

source

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);
source

pub const fn days_mask(&self) -> bool

Return true if the day mask is set.

source

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);
source

pub const fn subseconds(&self) -> u32

Get the sub-seconds value.

source

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);
source

pub const fn subseconds_mask(&self) -> u8

Get the sub-seconds mask.

Trait Implementations§

source§

impl Clone for Alarm

source§

fn clone(&self) -> Alarm

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Alarm

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Alarm

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl From<Alarm> for NaiveTime

source§

fn from(alarm: Alarm) -> Self

Converts to this type from the input type.
source§

impl From<NaiveTime> for Alarm

source§

fn from(time: NaiveTime) -> Self

Converts to this type from the input type.
source§

impl PartialEq for Alarm

source§

fn eq(&self, other: &Alarm) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for Alarm

source§

impl Eq for Alarm

source§

impl StructuralEq for Alarm

source§

impl StructuralPartialEq for Alarm

Auto Trait Implementations§

§

impl RefUnwindSafe for Alarm

§

impl Send for Alarm

§

impl Sync for Alarm

§

impl Unpin for Alarm

§

impl UnwindSafe for Alarm

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.