avr_device/devices/atmega4809/fuse/
osccfg.rs1#[doc = "Register `OSCCFG` reader"]
2pub struct R(crate::R<OSCCFG_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<OSCCFG_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<OSCCFG_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<OSCCFG_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `OSCCFG` writer"]
17pub struct W(crate::W<OSCCFG_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<OSCCFG_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<OSCCFG_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<OSCCFG_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `FREQSEL` reader - Frequency Select"]
38pub type FREQSEL_R = crate::FieldReader<u8, FREQSEL_A>;
39#[doc = "Frequency Select\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum FREQSEL_A {
43 #[doc = "1: 16 MHz"]
44 _16MHZ = 1,
45 #[doc = "2: 20 MHz"]
46 _20MHZ = 2,
47}
48impl From<FREQSEL_A> for u8 {
49 #[inline(always)]
50 fn from(variant: FREQSEL_A) -> Self {
51 variant as _
52 }
53}
54impl FREQSEL_R {
55 #[doc = "Get enumerated values variant"]
56 #[inline(always)]
57 pub fn variant(&self) -> Option<FREQSEL_A> {
58 match self.bits {
59 1 => Some(FREQSEL_A::_16MHZ),
60 2 => Some(FREQSEL_A::_20MHZ),
61 _ => None,
62 }
63 }
64 #[doc = "Checks if the value of the field is `_16MHZ`"]
65 #[inline(always)]
66 pub fn is_16mhz(&self) -> bool {
67 *self == FREQSEL_A::_16MHZ
68 }
69 #[doc = "Checks if the value of the field is `_20MHZ`"]
70 #[inline(always)]
71 pub fn is_20mhz(&self) -> bool {
72 *self == FREQSEL_A::_20MHZ
73 }
74}
75#[doc = "Field `FREQSEL` writer - Frequency Select"]
76pub type FREQSEL_W<'a, const O: u8> = crate::FieldWriter<'a, u8, OSCCFG_SPEC, u8, FREQSEL_A, 2, O>;
77impl<'a, const O: u8> FREQSEL_W<'a, O> {
78 #[doc = "16 MHz"]
79 #[inline(always)]
80 pub fn _16mhz(self) -> &'a mut W {
81 self.variant(FREQSEL_A::_16MHZ)
82 }
83 #[doc = "20 MHz"]
84 #[inline(always)]
85 pub fn _20mhz(self) -> &'a mut W {
86 self.variant(FREQSEL_A::_20MHZ)
87 }
88}
89#[doc = "Field `OSCLOCK` reader - Oscillator Lock"]
90pub type OSCLOCK_R = crate::BitReader<bool>;
91#[doc = "Field `OSCLOCK` writer - Oscillator Lock"]
92pub type OSCLOCK_W<'a, const O: u8> = crate::BitWriter<'a, u8, OSCCFG_SPEC, bool, O>;
93impl R {
94 #[doc = "Bits 0:1 - Frequency Select"]
95 #[inline(always)]
96 pub fn freqsel(&self) -> FREQSEL_R {
97 FREQSEL_R::new(self.bits & 3)
98 }
99 #[doc = "Bit 7 - Oscillator Lock"]
100 #[inline(always)]
101 pub fn osclock(&self) -> OSCLOCK_R {
102 OSCLOCK_R::new(((self.bits >> 7) & 1) != 0)
103 }
104}
105impl W {
106 #[doc = "Bits 0:1 - Frequency Select"]
107 #[inline(always)]
108 #[must_use]
109 pub fn freqsel(&mut self) -> FREQSEL_W<0> {
110 FREQSEL_W::new(self)
111 }
112 #[doc = "Bit 7 - Oscillator Lock"]
113 #[inline(always)]
114 #[must_use]
115 pub fn osclock(&mut self) -> OSCLOCK_W<7> {
116 OSCLOCK_W::new(self)
117 }
118 #[doc = "Writes raw bits to the register."]
119 #[inline(always)]
120 pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
121 self.0.bits(bits);
122 self
123 }
124}
125#[doc = "Oscillator Configuration\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 [osccfg](index.html) module"]
126pub struct OSCCFG_SPEC;
127impl crate::RegisterSpec for OSCCFG_SPEC {
128 type Ux = u8;
129}
130#[doc = "`read()` method returns [osccfg::R](R) reader structure"]
131impl crate::Readable for OSCCFG_SPEC {
132 type Reader = R;
133}
134#[doc = "`write(|w| ..)` method takes [osccfg::W](W) writer structure"]
135impl crate::Writable for OSCCFG_SPEC {
136 type Writer = W;
137 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
138 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
139}
140#[doc = "`reset()` method sets OSCCFG to value 0"]
141impl crate::Resettable for OSCCFG_SPEC {
142 const RESET_VALUE: Self::Ux = 0;
143}