ambiq_apollo3_pac2/clkgen/
status.rs

1#[doc = "Register `STATUS` reader"]
2pub struct R(crate::R<STATUS_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<STATUS_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<STATUS_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<STATUS_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `STATUS` writer"]
17pub struct W(crate::W<STATUS_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<STATUS_SPEC>;
20    #[inline(always)]
21    fn deref(&self) -> &Self::Target {
22        &self.0
23    }
24}
25impl core::ops::DerefMut for W {
26    #[inline(always)]
27    fn deref_mut(&mut self) -> &mut Self::Target {
28        &mut self.0
29    }
30}
31impl From<crate::W<STATUS_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<STATUS_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `OSCF` reader - XT Oscillator is enabled but not oscillating"]
38pub struct OSCF_R(crate::FieldReader<bool, bool>);
39impl OSCF_R {
40    pub(crate) fn new(bits: bool) -> Self {
41        OSCF_R(crate::FieldReader::new(bits))
42    }
43}
44impl core::ops::Deref for OSCF_R {
45    type Target = crate::FieldReader<bool, bool>;
46    #[inline(always)]
47    fn deref(&self) -> &Self::Target {
48        &self.0
49    }
50}
51#[doc = "Field `OSCF` writer - XT Oscillator is enabled but not oscillating"]
52pub struct OSCF_W<'a> {
53    w: &'a mut W,
54}
55impl<'a> OSCF_W<'a> {
56    #[doc = r"Sets the field bit"]
57    #[inline(always)]
58    pub fn set_bit(self) -> &'a mut W {
59        self.bit(true)
60    }
61    #[doc = r"Clears the field bit"]
62    #[inline(always)]
63    pub fn clear_bit(self) -> &'a mut W {
64        self.bit(false)
65    }
66    #[doc = r"Writes raw bits to the field"]
67    #[inline(always)]
68    pub fn bit(self, value: bool) -> &'a mut W {
69        self.w.bits = (self.w.bits & !(0x01 << 1)) | ((value as u32 & 0x01) << 1);
70        self.w
71    }
72}
73#[doc = "Field `OMODE` reader - Current RTC oscillator (1 => LFRC, 0 => XT). After an RTC oscillator change, it may take up to 2 seconds for this field to reflect the new oscillator."]
74pub struct OMODE_R(crate::FieldReader<bool, bool>);
75impl OMODE_R {
76    pub(crate) fn new(bits: bool) -> Self {
77        OMODE_R(crate::FieldReader::new(bits))
78    }
79}
80impl core::ops::Deref for OMODE_R {
81    type Target = crate::FieldReader<bool, bool>;
82    #[inline(always)]
83    fn deref(&self) -> &Self::Target {
84        &self.0
85    }
86}
87#[doc = "Field `OMODE` writer - Current RTC oscillator (1 => LFRC, 0 => XT). After an RTC oscillator change, it may take up to 2 seconds for this field to reflect the new oscillator."]
88pub struct OMODE_W<'a> {
89    w: &'a mut W,
90}
91impl<'a> OMODE_W<'a> {
92    #[doc = r"Sets the field bit"]
93    #[inline(always)]
94    pub fn set_bit(self) -> &'a mut W {
95        self.bit(true)
96    }
97    #[doc = r"Clears the field bit"]
98    #[inline(always)]
99    pub fn clear_bit(self) -> &'a mut W {
100        self.bit(false)
101    }
102    #[doc = r"Writes raw bits to the field"]
103    #[inline(always)]
104    pub fn bit(self, value: bool) -> &'a mut W {
105        self.w.bits = (self.w.bits & !0x01) | (value as u32 & 0x01);
106        self.w
107    }
108}
109impl R {
110    #[doc = "Bit 1 - XT Oscillator is enabled but not oscillating"]
111    #[inline(always)]
112    pub fn oscf(&self) -> OSCF_R {
113        OSCF_R::new(((self.bits >> 1) & 0x01) != 0)
114    }
115    #[doc = "Bit 0 - Current RTC oscillator (1 => LFRC, 0 => XT). After an RTC oscillator change, it may take up to 2 seconds for this field to reflect the new oscillator."]
116    #[inline(always)]
117    pub fn omode(&self) -> OMODE_R {
118        OMODE_R::new((self.bits & 0x01) != 0)
119    }
120}
121impl W {
122    #[doc = "Bit 1 - XT Oscillator is enabled but not oscillating"]
123    #[inline(always)]
124    pub fn oscf(&mut self) -> OSCF_W {
125        OSCF_W { w: self }
126    }
127    #[doc = "Bit 0 - Current RTC oscillator (1 => LFRC, 0 => XT). After an RTC oscillator change, it may take up to 2 seconds for this field to reflect the new oscillator."]
128    #[inline(always)]
129    pub fn omode(&mut self) -> OMODE_W {
130        OMODE_W { w: self }
131    }
132    #[doc = "Writes raw bits to the register."]
133    #[inline(always)]
134    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
135        self.0.bits(bits);
136        self
137    }
138}
139#[doc = "Clock Generator Status\n\nThis register you can [`read`](crate::generic::Reg::read), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [status](index.html) module"]
140pub struct STATUS_SPEC;
141impl crate::RegisterSpec for STATUS_SPEC {
142    type Ux = u32;
143}
144#[doc = "`read()` method returns [status::R](R) reader structure"]
145impl crate::Readable for STATUS_SPEC {
146    type Reader = R;
147}
148#[doc = "`write(|w| ..)` method takes [status::W](W) writer structure"]
149impl crate::Writable for STATUS_SPEC {
150    type Writer = W;
151}
152#[doc = "`reset()` method sets STATUS to value 0"]
153impl crate::Resettable for STATUS_SPEC {
154    #[inline(always)]
155    fn reset_value() -> Self::Ux {
156        0
157    }
158}