atsamd51g/rtc/mode2/
clock.rs
1#[doc = "Register `CLOCK` reader"]
2pub type R = crate::R<ClockSpec>;
3#[doc = "Register `CLOCK` writer"]
4pub type W = crate::W<ClockSpec>;
5#[doc = "Field `SECOND` reader - Second"]
6pub type SecondR = crate::FieldReader;
7#[doc = "Field `SECOND` writer - Second"]
8pub type SecondW<'a, REG> = crate::FieldWriter<'a, REG, 6>;
9#[doc = "Field `MINUTE` reader - Minute"]
10pub type MinuteR = crate::FieldReader;
11#[doc = "Field `MINUTE` writer - Minute"]
12pub type MinuteW<'a, REG> = crate::FieldWriter<'a, REG, 6>;
13#[doc = "Hour\n\nValue on reset: 0"]
14#[derive(Clone, Copy, Debug, PartialEq, Eq)]
15#[repr(u8)]
16pub enum Hourselect {
17 #[doc = "0: AM when CLKREP in 12-hour"]
18 Am = 0,
19 #[doc = "16: PM when CLKREP in 12-hour"]
20 Pm = 16,
21}
22impl From<Hourselect> for u8 {
23 #[inline(always)]
24 fn from(variant: Hourselect) -> Self {
25 variant as _
26 }
27}
28impl crate::FieldSpec for Hourselect {
29 type Ux = u8;
30}
31impl crate::IsEnum for Hourselect {}
32#[doc = "Field `HOUR` reader - Hour"]
33pub type HourR = crate::FieldReader<Hourselect>;
34impl HourR {
35 #[doc = "Get enumerated values variant"]
36 #[inline(always)]
37 pub const fn variant(&self) -> Option<Hourselect> {
38 match self.bits {
39 0 => Some(Hourselect::Am),
40 16 => Some(Hourselect::Pm),
41 _ => None,
42 }
43 }
44 #[doc = "AM when CLKREP in 12-hour"]
45 #[inline(always)]
46 pub fn is_am(&self) -> bool {
47 *self == Hourselect::Am
48 }
49 #[doc = "PM when CLKREP in 12-hour"]
50 #[inline(always)]
51 pub fn is_pm(&self) -> bool {
52 *self == Hourselect::Pm
53 }
54}
55#[doc = "Field `HOUR` writer - Hour"]
56pub type HourW<'a, REG> = crate::FieldWriter<'a, REG, 5, Hourselect>;
57impl<'a, REG> HourW<'a, REG>
58where
59 REG: crate::Writable + crate::RegisterSpec,
60 REG::Ux: From<u8>,
61{
62 #[doc = "AM when CLKREP in 12-hour"]
63 #[inline(always)]
64 pub fn am(self) -> &'a mut crate::W<REG> {
65 self.variant(Hourselect::Am)
66 }
67 #[doc = "PM when CLKREP in 12-hour"]
68 #[inline(always)]
69 pub fn pm(self) -> &'a mut crate::W<REG> {
70 self.variant(Hourselect::Pm)
71 }
72}
73#[doc = "Field `DAY` reader - Day"]
74pub type DayR = crate::FieldReader;
75#[doc = "Field `DAY` writer - Day"]
76pub type DayW<'a, REG> = crate::FieldWriter<'a, REG, 5>;
77#[doc = "Field `MONTH` reader - Month"]
78pub type MonthR = crate::FieldReader;
79#[doc = "Field `MONTH` writer - Month"]
80pub type MonthW<'a, REG> = crate::FieldWriter<'a, REG, 4>;
81#[doc = "Field `YEAR` reader - Year"]
82pub type YearR = crate::FieldReader;
83#[doc = "Field `YEAR` writer - Year"]
84pub type YearW<'a, REG> = crate::FieldWriter<'a, REG, 6>;
85impl R {
86 #[doc = "Bits 0:5 - Second"]
87 #[inline(always)]
88 pub fn second(&self) -> SecondR {
89 SecondR::new((self.bits & 0x3f) as u8)
90 }
91 #[doc = "Bits 6:11 - Minute"]
92 #[inline(always)]
93 pub fn minute(&self) -> MinuteR {
94 MinuteR::new(((self.bits >> 6) & 0x3f) as u8)
95 }
96 #[doc = "Bits 12:16 - Hour"]
97 #[inline(always)]
98 pub fn hour(&self) -> HourR {
99 HourR::new(((self.bits >> 12) & 0x1f) as u8)
100 }
101 #[doc = "Bits 17:21 - Day"]
102 #[inline(always)]
103 pub fn day(&self) -> DayR {
104 DayR::new(((self.bits >> 17) & 0x1f) as u8)
105 }
106 #[doc = "Bits 22:25 - Month"]
107 #[inline(always)]
108 pub fn month(&self) -> MonthR {
109 MonthR::new(((self.bits >> 22) & 0x0f) as u8)
110 }
111 #[doc = "Bits 26:31 - Year"]
112 #[inline(always)]
113 pub fn year(&self) -> YearR {
114 YearR::new(((self.bits >> 26) & 0x3f) as u8)
115 }
116}
117impl W {
118 #[doc = "Bits 0:5 - Second"]
119 #[inline(always)]
120 #[must_use]
121 pub fn second(&mut self) -> SecondW<ClockSpec> {
122 SecondW::new(self, 0)
123 }
124 #[doc = "Bits 6:11 - Minute"]
125 #[inline(always)]
126 #[must_use]
127 pub fn minute(&mut self) -> MinuteW<ClockSpec> {
128 MinuteW::new(self, 6)
129 }
130 #[doc = "Bits 12:16 - Hour"]
131 #[inline(always)]
132 #[must_use]
133 pub fn hour(&mut self) -> HourW<ClockSpec> {
134 HourW::new(self, 12)
135 }
136 #[doc = "Bits 17:21 - Day"]
137 #[inline(always)]
138 #[must_use]
139 pub fn day(&mut self) -> DayW<ClockSpec> {
140 DayW::new(self, 17)
141 }
142 #[doc = "Bits 22:25 - Month"]
143 #[inline(always)]
144 #[must_use]
145 pub fn month(&mut self) -> MonthW<ClockSpec> {
146 MonthW::new(self, 22)
147 }
148 #[doc = "Bits 26:31 - Year"]
149 #[inline(always)]
150 #[must_use]
151 pub fn year(&mut self) -> YearW<ClockSpec> {
152 YearW::new(self, 26)
153 }
154}
155#[doc = "MODE2 Clock Value\n\nYou can [`read`](crate::Reg::read) this register and get [`clock::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`clock::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
156pub struct ClockSpec;
157impl crate::RegisterSpec for ClockSpec {
158 type Ux = u32;
159}
160#[doc = "`read()` method returns [`clock::R`](R) reader structure"]
161impl crate::Readable for ClockSpec {}
162#[doc = "`write(|w| ..)` method takes [`clock::W`](W) writer structure"]
163impl crate::Writable for ClockSpec {
164 type Safety = crate::Unsafe;
165 const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
166 const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
167}
168#[doc = "`reset()` method sets CLOCK to value 0"]
169impl crate::Resettable for ClockSpec {
170 const RESET_VALUE: u32 = 0;
171}