d1_pac/rtc/
losc_auto_swt_sta.rs1#[doc = "Register `losc_auto_swt_sta` reader"]
2pub type R = crate::R<LOSC_AUTO_SWT_STA_SPEC>;
3#[doc = "Register `losc_auto_swt_sta` writer"]
4pub type W = crate::W<LOSC_AUTO_SWT_STA_SPEC>;
5#[doc = "Field `losc_src_sel_sta` reader - Checking LOSC clock source status"]
6pub type LOSC_SRC_SEL_STA_R = crate::BitReader<LOSC_SRC_SEL_STA_A>;
7#[doc = "Checking LOSC clock source status\n\nValue on reset: 0"]
8#[derive(Clone, Copy, Debug, PartialEq, Eq)]
9pub enum LOSC_SRC_SEL_STA_A {
10 #[doc = "0: Low frequency clock from 16M RC"]
11 LOW = 0,
12 #[doc = "1: External 32.768 kHz OSC"]
13 EXTERNAL = 1,
14}
15impl From<LOSC_SRC_SEL_STA_A> for bool {
16 #[inline(always)]
17 fn from(variant: LOSC_SRC_SEL_STA_A) -> Self {
18 variant as u8 != 0
19 }
20}
21impl LOSC_SRC_SEL_STA_R {
22 #[doc = "Get enumerated values variant"]
23 #[inline(always)]
24 pub const fn variant(&self) -> LOSC_SRC_SEL_STA_A {
25 match self.bits {
26 false => LOSC_SRC_SEL_STA_A::LOW,
27 true => LOSC_SRC_SEL_STA_A::EXTERNAL,
28 }
29 }
30 #[doc = "Low frequency clock from 16M RC"]
31 #[inline(always)]
32 pub fn is_low(&self) -> bool {
33 *self == LOSC_SRC_SEL_STA_A::LOW
34 }
35 #[doc = "External 32.768 kHz OSC"]
36 #[inline(always)]
37 pub fn is_external(&self) -> bool {
38 *self == LOSC_SRC_SEL_STA_A::EXTERNAL
39 }
40}
41#[doc = "Field `losc_auto_swt_pend` reader - LOSC auto switch pending"]
42pub type LOSC_AUTO_SWT_PEND_R = crate::BitReader<LOSC_AUTO_SWT_PEND_A>;
43#[doc = "LOSC auto switch pending\n\nValue on reset: 0"]
44#[derive(Clone, Copy, Debug, PartialEq, Eq)]
45pub enum LOSC_AUTO_SWT_PEND_A {
46 #[doc = "0: No effect"]
47 NO_EFFECT = 0,
48 #[doc = "1: Auto switch pending, it means LOSC_SRC_SEL is changed from 1 to 0.\n\nSetting 1 to this bit will clear it."]
49 AUTO = 1,
50}
51impl From<LOSC_AUTO_SWT_PEND_A> for bool {
52 #[inline(always)]
53 fn from(variant: LOSC_AUTO_SWT_PEND_A) -> Self {
54 variant as u8 != 0
55 }
56}
57impl LOSC_AUTO_SWT_PEND_R {
58 #[doc = "Get enumerated values variant"]
59 #[inline(always)]
60 pub const fn variant(&self) -> LOSC_AUTO_SWT_PEND_A {
61 match self.bits {
62 false => LOSC_AUTO_SWT_PEND_A::NO_EFFECT,
63 true => LOSC_AUTO_SWT_PEND_A::AUTO,
64 }
65 }
66 #[doc = "No effect"]
67 #[inline(always)]
68 pub fn is_no_effect(&self) -> bool {
69 *self == LOSC_AUTO_SWT_PEND_A::NO_EFFECT
70 }
71 #[doc = "Auto switch pending, it means LOSC_SRC_SEL is changed from 1 to 0.\n\nSetting 1 to this bit will clear it."]
72 #[inline(always)]
73 pub fn is_auto(&self) -> bool {
74 *self == LOSC_AUTO_SWT_PEND_A::AUTO
75 }
76}
77#[doc = "Field `losc_auto_swt_pend` writer - LOSC auto switch pending"]
78pub type LOSC_AUTO_SWT_PEND_W<'a, REG> = crate::BitWriter1C<'a, REG, LOSC_AUTO_SWT_PEND_A>;
79impl<'a, REG> LOSC_AUTO_SWT_PEND_W<'a, REG>
80where
81 REG: crate::Writable + crate::RegisterSpec,
82{
83 #[doc = "No effect"]
84 #[inline(always)]
85 pub fn no_effect(self) -> &'a mut crate::W<REG> {
86 self.variant(LOSC_AUTO_SWT_PEND_A::NO_EFFECT)
87 }
88 #[doc = "Auto switch pending, it means LOSC_SRC_SEL is changed from 1 to 0.\n\nSetting 1 to this bit will clear it."]
89 #[inline(always)]
90 pub fn auto(self) -> &'a mut crate::W<REG> {
91 self.variant(LOSC_AUTO_SWT_PEND_A::AUTO)
92 }
93}
94#[doc = "Field `ext_losc_sta` reader - Work only when the auto switch function is enabled."]
95pub type EXT_LOSC_STA_R = crate::BitReader<EXT_LOSC_STA_A>;
96#[doc = "Work only when the auto switch function is enabled.\n\nValue on reset: 0"]
97#[derive(Clone, Copy, Debug, PartialEq, Eq)]
98pub enum EXT_LOSC_STA_A {
99 #[doc = "0: External 32.768 kHz OSC work normally"]
100 NORMALLY = 0,
101 #[doc = "1: External 32.768 kHz OSC work abnormally"]
102 ABNORMALLY = 1,
103}
104impl From<EXT_LOSC_STA_A> for bool {
105 #[inline(always)]
106 fn from(variant: EXT_LOSC_STA_A) -> Self {
107 variant as u8 != 0
108 }
109}
110impl EXT_LOSC_STA_R {
111 #[doc = "Get enumerated values variant"]
112 #[inline(always)]
113 pub const fn variant(&self) -> EXT_LOSC_STA_A {
114 match self.bits {
115 false => EXT_LOSC_STA_A::NORMALLY,
116 true => EXT_LOSC_STA_A::ABNORMALLY,
117 }
118 }
119 #[doc = "External 32.768 kHz OSC work normally"]
120 #[inline(always)]
121 pub fn is_normally(&self) -> bool {
122 *self == EXT_LOSC_STA_A::NORMALLY
123 }
124 #[doc = "External 32.768 kHz OSC work abnormally"]
125 #[inline(always)]
126 pub fn is_abnormally(&self) -> bool {
127 *self == EXT_LOSC_STA_A::ABNORMALLY
128 }
129}
130impl R {
131 #[doc = "Bit 0 - Checking LOSC clock source status"]
132 #[inline(always)]
133 pub fn losc_src_sel_sta(&self) -> LOSC_SRC_SEL_STA_R {
134 LOSC_SRC_SEL_STA_R::new((self.bits & 1) != 0)
135 }
136 #[doc = "Bit 1 - LOSC auto switch pending"]
137 #[inline(always)]
138 pub fn losc_auto_swt_pend(&self) -> LOSC_AUTO_SWT_PEND_R {
139 LOSC_AUTO_SWT_PEND_R::new(((self.bits >> 1) & 1) != 0)
140 }
141 #[doc = "Bit 2 - Work only when the auto switch function is enabled."]
142 #[inline(always)]
143 pub fn ext_losc_sta(&self) -> EXT_LOSC_STA_R {
144 EXT_LOSC_STA_R::new(((self.bits >> 2) & 1) != 0)
145 }
146}
147impl W {
148 #[doc = "Bit 1 - LOSC auto switch pending"]
149 #[inline(always)]
150 #[must_use]
151 pub fn losc_auto_swt_pend(&mut self) -> LOSC_AUTO_SWT_PEND_W<LOSC_AUTO_SWT_STA_SPEC> {
152 LOSC_AUTO_SWT_PEND_W::new(self, 1)
153 }
154 #[doc = r" Writes raw bits to the register."]
155 #[doc = r""]
156 #[doc = r" # Safety"]
157 #[doc = r""]
158 #[doc = r" Passing incorrect value can cause undefined behaviour. See reference manual"]
159 #[inline(always)]
160 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
161 self.bits = bits;
162 self
163 }
164}
165#[doc = "LOSC Auto Switch Status Register\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`losc_auto_swt_sta::R`](R). You can [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero) this register using [`losc_auto_swt_sta::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
166pub struct LOSC_AUTO_SWT_STA_SPEC;
167impl crate::RegisterSpec for LOSC_AUTO_SWT_STA_SPEC {
168 type Ux = u32;
169}
170#[doc = "`read()` method returns [`losc_auto_swt_sta::R`](R) reader structure"]
171impl crate::Readable for LOSC_AUTO_SWT_STA_SPEC {}
172#[doc = "`write(|w| ..)` method takes [`losc_auto_swt_sta::W`](W) writer structure"]
173impl crate::Writable for LOSC_AUTO_SWT_STA_SPEC {
174 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
175 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0x02;
176}
177#[doc = "`reset()` method sets losc_auto_swt_sta to value 0"]
178impl crate::Resettable for LOSC_AUTO_SWT_STA_SPEC {
179 const RESET_VALUE: Self::Ux = 0;
180}