atsamd51g/rtc/mode2/
timestamp.rs

1#[doc = "Register `TIMESTAMP` reader"]
2pub type R = crate::R<TimestampSpec>;
3#[doc = "Field `SECOND` reader - Second Timestamp Value"]
4pub type SecondR = crate::FieldReader;
5#[doc = "Field `MINUTE` reader - Minute Timestamp Value"]
6pub type MinuteR = crate::FieldReader;
7#[doc = "Hour Timestamp Value\n\nValue on reset: 0"]
8#[derive(Clone, Copy, Debug, PartialEq, Eq)]
9#[repr(u8)]
10pub enum Hourselect {
11    #[doc = "0: AM when CLKREP in 12-hour"]
12    Am = 0,
13    #[doc = "16: PM when CLKREP in 12-hour"]
14    Pm = 16,
15}
16impl From<Hourselect> for u8 {
17    #[inline(always)]
18    fn from(variant: Hourselect) -> Self {
19        variant as _
20    }
21}
22impl crate::FieldSpec for Hourselect {
23    type Ux = u8;
24}
25impl crate::IsEnum for Hourselect {}
26#[doc = "Field `HOUR` reader - Hour Timestamp Value"]
27pub type HourR = crate::FieldReader<Hourselect>;
28impl HourR {
29    #[doc = "Get enumerated values variant"]
30    #[inline(always)]
31    pub const fn variant(&self) -> Option<Hourselect> {
32        match self.bits {
33            0 => Some(Hourselect::Am),
34            16 => Some(Hourselect::Pm),
35            _ => None,
36        }
37    }
38    #[doc = "AM when CLKREP in 12-hour"]
39    #[inline(always)]
40    pub fn is_am(&self) -> bool {
41        *self == Hourselect::Am
42    }
43    #[doc = "PM when CLKREP in 12-hour"]
44    #[inline(always)]
45    pub fn is_pm(&self) -> bool {
46        *self == Hourselect::Pm
47    }
48}
49#[doc = "Field `DAY` reader - Day Timestamp Value"]
50pub type DayR = crate::FieldReader;
51#[doc = "Field `MONTH` reader - Month Timestamp Value"]
52pub type MonthR = crate::FieldReader;
53#[doc = "Field `YEAR` reader - Year Timestamp Value"]
54pub type YearR = crate::FieldReader;
55impl R {
56    #[doc = "Bits 0:5 - Second Timestamp Value"]
57    #[inline(always)]
58    pub fn second(&self) -> SecondR {
59        SecondR::new((self.bits & 0x3f) as u8)
60    }
61    #[doc = "Bits 6:11 - Minute Timestamp Value"]
62    #[inline(always)]
63    pub fn minute(&self) -> MinuteR {
64        MinuteR::new(((self.bits >> 6) & 0x3f) as u8)
65    }
66    #[doc = "Bits 12:16 - Hour Timestamp Value"]
67    #[inline(always)]
68    pub fn hour(&self) -> HourR {
69        HourR::new(((self.bits >> 12) & 0x1f) as u8)
70    }
71    #[doc = "Bits 17:21 - Day Timestamp Value"]
72    #[inline(always)]
73    pub fn day(&self) -> DayR {
74        DayR::new(((self.bits >> 17) & 0x1f) as u8)
75    }
76    #[doc = "Bits 22:25 - Month Timestamp Value"]
77    #[inline(always)]
78    pub fn month(&self) -> MonthR {
79        MonthR::new(((self.bits >> 22) & 0x0f) as u8)
80    }
81    #[doc = "Bits 26:31 - Year Timestamp Value"]
82    #[inline(always)]
83    pub fn year(&self) -> YearR {
84        YearR::new(((self.bits >> 26) & 0x3f) as u8)
85    }
86}
87#[doc = "MODE2 Timestamp\n\nYou can [`read`](crate::Reg::read) this register and get [`timestamp::R`](R). See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
88pub struct TimestampSpec;
89impl crate::RegisterSpec for TimestampSpec {
90    type Ux = u32;
91}
92#[doc = "`read()` method returns [`timestamp::R`](R) reader structure"]
93impl crate::Readable for TimestampSpec {}
94#[doc = "`reset()` method sets TIMESTAMP to value 0"]
95impl crate::Resettable for TimestampSpec {
96    const RESET_VALUE: u32 = 0;
97}