avr_device/devices/atmega4809/clkctrl/
xosc32kctrla.rs

1#[doc = "Register `XOSC32KCTRLA` reader"]
2pub struct R(crate::R<XOSC32KCTRLA_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<XOSC32KCTRLA_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<XOSC32KCTRLA_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<XOSC32KCTRLA_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `XOSC32KCTRLA` writer"]
17pub struct W(crate::W<XOSC32KCTRLA_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<XOSC32KCTRLA_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<XOSC32KCTRLA_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<XOSC32KCTRLA_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `ENABLE` reader - Enable"]
38pub type ENABLE_R = crate::BitReader<bool>;
39#[doc = "Field `ENABLE` writer - Enable"]
40pub type ENABLE_W<'a, const O: u8> = crate::BitWriter<'a, u8, XOSC32KCTRLA_SPEC, bool, O>;
41#[doc = "Field `RUNSTDBY` reader - Run standby"]
42pub type RUNSTDBY_R = crate::BitReader<bool>;
43#[doc = "Field `RUNSTDBY` writer - Run standby"]
44pub type RUNSTDBY_W<'a, const O: u8> = crate::BitWriter<'a, u8, XOSC32KCTRLA_SPEC, bool, O>;
45#[doc = "Field `SEL` reader - Select"]
46pub type SEL_R = crate::BitReader<bool>;
47#[doc = "Field `SEL` writer - Select"]
48pub type SEL_W<'a, const O: u8> = crate::BitWriter<'a, u8, XOSC32KCTRLA_SPEC, bool, O>;
49#[doc = "Field `CSUT` reader - Crystal startup time"]
50pub type CSUT_R = crate::FieldReader<u8, CSUT_A>;
51#[doc = "Crystal startup time\n\nValue on reset: 0"]
52#[derive(Clone, Copy, Debug, PartialEq, Eq)]
53#[repr(u8)]
54pub enum CSUT_A {
55    #[doc = "0: 1k cycles"]
56    _1K = 0,
57    #[doc = "1: 16k cycles"]
58    _16K = 1,
59    #[doc = "2: 32k cycles"]
60    _32K = 2,
61    #[doc = "3: 64k cycles"]
62    _64K = 3,
63}
64impl From<CSUT_A> for u8 {
65    #[inline(always)]
66    fn from(variant: CSUT_A) -> Self {
67        variant as _
68    }
69}
70impl CSUT_R {
71    #[doc = "Get enumerated values variant"]
72    #[inline(always)]
73    pub fn variant(&self) -> CSUT_A {
74        match self.bits {
75            0 => CSUT_A::_1K,
76            1 => CSUT_A::_16K,
77            2 => CSUT_A::_32K,
78            3 => CSUT_A::_64K,
79            _ => unreachable!(),
80        }
81    }
82    #[doc = "Checks if the value of the field is `_1K`"]
83    #[inline(always)]
84    pub fn is_1k(&self) -> bool {
85        *self == CSUT_A::_1K
86    }
87    #[doc = "Checks if the value of the field is `_16K`"]
88    #[inline(always)]
89    pub fn is_16k(&self) -> bool {
90        *self == CSUT_A::_16K
91    }
92    #[doc = "Checks if the value of the field is `_32K`"]
93    #[inline(always)]
94    pub fn is_32k(&self) -> bool {
95        *self == CSUT_A::_32K
96    }
97    #[doc = "Checks if the value of the field is `_64K`"]
98    #[inline(always)]
99    pub fn is_64k(&self) -> bool {
100        *self == CSUT_A::_64K
101    }
102}
103#[doc = "Field `CSUT` writer - Crystal startup time"]
104pub type CSUT_W<'a, const O: u8> =
105    crate::FieldWriterSafe<'a, u8, XOSC32KCTRLA_SPEC, u8, CSUT_A, 2, O>;
106impl<'a, const O: u8> CSUT_W<'a, O> {
107    #[doc = "1k cycles"]
108    #[inline(always)]
109    pub fn _1k(self) -> &'a mut W {
110        self.variant(CSUT_A::_1K)
111    }
112    #[doc = "16k cycles"]
113    #[inline(always)]
114    pub fn _16k(self) -> &'a mut W {
115        self.variant(CSUT_A::_16K)
116    }
117    #[doc = "32k cycles"]
118    #[inline(always)]
119    pub fn _32k(self) -> &'a mut W {
120        self.variant(CSUT_A::_32K)
121    }
122    #[doc = "64k cycles"]
123    #[inline(always)]
124    pub fn _64k(self) -> &'a mut W {
125        self.variant(CSUT_A::_64K)
126    }
127}
128impl R {
129    #[doc = "Bit 0 - Enable"]
130    #[inline(always)]
131    pub fn enable(&self) -> ENABLE_R {
132        ENABLE_R::new((self.bits & 1) != 0)
133    }
134    #[doc = "Bit 1 - Run standby"]
135    #[inline(always)]
136    pub fn runstdby(&self) -> RUNSTDBY_R {
137        RUNSTDBY_R::new(((self.bits >> 1) & 1) != 0)
138    }
139    #[doc = "Bit 2 - Select"]
140    #[inline(always)]
141    pub fn sel(&self) -> SEL_R {
142        SEL_R::new(((self.bits >> 2) & 1) != 0)
143    }
144    #[doc = "Bits 4:5 - Crystal startup time"]
145    #[inline(always)]
146    pub fn csut(&self) -> CSUT_R {
147        CSUT_R::new((self.bits >> 4) & 3)
148    }
149}
150impl W {
151    #[doc = "Bit 0 - Enable"]
152    #[inline(always)]
153    #[must_use]
154    pub fn enable(&mut self) -> ENABLE_W<0> {
155        ENABLE_W::new(self)
156    }
157    #[doc = "Bit 1 - Run standby"]
158    #[inline(always)]
159    #[must_use]
160    pub fn runstdby(&mut self) -> RUNSTDBY_W<1> {
161        RUNSTDBY_W::new(self)
162    }
163    #[doc = "Bit 2 - Select"]
164    #[inline(always)]
165    #[must_use]
166    pub fn sel(&mut self) -> SEL_W<2> {
167        SEL_W::new(self)
168    }
169    #[doc = "Bits 4:5 - Crystal startup time"]
170    #[inline(always)]
171    #[must_use]
172    pub fn csut(&mut self) -> CSUT_W<4> {
173        CSUT_W::new(self)
174    }
175    #[doc = "Writes raw bits to the register."]
176    #[inline(always)]
177    pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
178        self.0.bits(bits);
179        self
180    }
181}
182#[doc = "XOSC32K Control A\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 [xosc32kctrla](index.html) module"]
183pub struct XOSC32KCTRLA_SPEC;
184impl crate::RegisterSpec for XOSC32KCTRLA_SPEC {
185    type Ux = u8;
186}
187#[doc = "`read()` method returns [xosc32kctrla::R](R) reader structure"]
188impl crate::Readable for XOSC32KCTRLA_SPEC {
189    type Reader = R;
190}
191#[doc = "`write(|w| ..)` method takes [xosc32kctrla::W](W) writer structure"]
192impl crate::Writable for XOSC32KCTRLA_SPEC {
193    type Writer = W;
194    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
195    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
196}
197#[doc = "`reset()` method sets XOSC32KCTRLA to value 0"]
198impl crate::Resettable for XOSC32KCTRLA_SPEC {
199    const RESET_VALUE: Self::Ux = 0;
200}