avr_device/devices/atmega4809/twi0/
ctrla.rs1#[doc = "Register `CTRLA` reader"]
2pub struct R(crate::R<CTRLA_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<CTRLA_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<CTRLA_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<CTRLA_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `CTRLA` writer"]
17pub struct W(crate::W<CTRLA_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<CTRLA_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<CTRLA_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<CTRLA_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `DEFAULT_FMPEN` reader - FM Plus Enable"]
38pub type DEFAULT_FMPEN_R = crate::BitReader<bool>;
39#[doc = "Field `DEFAULT_FMPEN` writer - FM Plus Enable"]
40pub type DEFAULT_FMPEN_W<'a, const O: u8> = crate::BitWriter<'a, u8, CTRLA_SPEC, bool, O>;
41#[doc = "Field `DEFAULT_SDAHOLD` reader - SDA Hold Time"]
42pub type DEFAULT_SDAHOLD_R = crate::FieldReader<u8, DEFAULT_SDAHOLD_A>;
43#[doc = "SDA Hold Time\n\nValue on reset: 0"]
44#[derive(Clone, Copy, Debug, PartialEq, Eq)]
45#[repr(u8)]
46pub enum DEFAULT_SDAHOLD_A {
47 #[doc = "0: SDA hold time off"]
48 OFF = 0,
49 #[doc = "1: Typical 50ns hold time"]
50 _50NS = 1,
51 #[doc = "2: Typical 300ns hold time"]
52 _300NS = 2,
53 #[doc = "3: Typical 500ns hold time"]
54 _500NS = 3,
55}
56impl From<DEFAULT_SDAHOLD_A> for u8 {
57 #[inline(always)]
58 fn from(variant: DEFAULT_SDAHOLD_A) -> Self {
59 variant as _
60 }
61}
62impl DEFAULT_SDAHOLD_R {
63 #[doc = "Get enumerated values variant"]
64 #[inline(always)]
65 pub fn variant(&self) -> DEFAULT_SDAHOLD_A {
66 match self.bits {
67 0 => DEFAULT_SDAHOLD_A::OFF,
68 1 => DEFAULT_SDAHOLD_A::_50NS,
69 2 => DEFAULT_SDAHOLD_A::_300NS,
70 3 => DEFAULT_SDAHOLD_A::_500NS,
71 _ => unreachable!(),
72 }
73 }
74 #[doc = "Checks if the value of the field is `OFF`"]
75 #[inline(always)]
76 pub fn is_off(&self) -> bool {
77 *self == DEFAULT_SDAHOLD_A::OFF
78 }
79 #[doc = "Checks if the value of the field is `_50NS`"]
80 #[inline(always)]
81 pub fn is_50ns(&self) -> bool {
82 *self == DEFAULT_SDAHOLD_A::_50NS
83 }
84 #[doc = "Checks if the value of the field is `_300NS`"]
85 #[inline(always)]
86 pub fn is_300ns(&self) -> bool {
87 *self == DEFAULT_SDAHOLD_A::_300NS
88 }
89 #[doc = "Checks if the value of the field is `_500NS`"]
90 #[inline(always)]
91 pub fn is_500ns(&self) -> bool {
92 *self == DEFAULT_SDAHOLD_A::_500NS
93 }
94}
95#[doc = "Field `DEFAULT_SDAHOLD` writer - SDA Hold Time"]
96pub type DEFAULT_SDAHOLD_W<'a, const O: u8> =
97 crate::FieldWriterSafe<'a, u8, CTRLA_SPEC, u8, DEFAULT_SDAHOLD_A, 2, O>;
98impl<'a, const O: u8> DEFAULT_SDAHOLD_W<'a, O> {
99 #[doc = "SDA hold time off"]
100 #[inline(always)]
101 pub fn off(self) -> &'a mut W {
102 self.variant(DEFAULT_SDAHOLD_A::OFF)
103 }
104 #[doc = "Typical 50ns hold time"]
105 #[inline(always)]
106 pub fn _50ns(self) -> &'a mut W {
107 self.variant(DEFAULT_SDAHOLD_A::_50NS)
108 }
109 #[doc = "Typical 300ns hold time"]
110 #[inline(always)]
111 pub fn _300ns(self) -> &'a mut W {
112 self.variant(DEFAULT_SDAHOLD_A::_300NS)
113 }
114 #[doc = "Typical 500ns hold time"]
115 #[inline(always)]
116 pub fn _500ns(self) -> &'a mut W {
117 self.variant(DEFAULT_SDAHOLD_A::_500NS)
118 }
119}
120#[doc = "Field `DEFAULT_SDASETUP` reader - SDA Setup Time"]
121pub type DEFAULT_SDASETUP_R = crate::BitReader<DEFAULT_SDASETUP_A>;
122#[doc = "SDA Setup Time\n\nValue on reset: 0"]
123#[derive(Clone, Copy, Debug, PartialEq, Eq)]
124pub enum DEFAULT_SDASETUP_A {
125 #[doc = "0: SDA setup time is 4 clock cycles"]
126 _4CYC = 0,
127 #[doc = "1: SDA setup time is 8 clock cycles"]
128 _8CYC = 1,
129}
130impl From<DEFAULT_SDASETUP_A> for bool {
131 #[inline(always)]
132 fn from(variant: DEFAULT_SDASETUP_A) -> Self {
133 variant as u8 != 0
134 }
135}
136impl DEFAULT_SDASETUP_R {
137 #[doc = "Get enumerated values variant"]
138 #[inline(always)]
139 pub fn variant(&self) -> DEFAULT_SDASETUP_A {
140 match self.bits {
141 false => DEFAULT_SDASETUP_A::_4CYC,
142 true => DEFAULT_SDASETUP_A::_8CYC,
143 }
144 }
145 #[doc = "Checks if the value of the field is `_4CYC`"]
146 #[inline(always)]
147 pub fn is_4cyc(&self) -> bool {
148 *self == DEFAULT_SDASETUP_A::_4CYC
149 }
150 #[doc = "Checks if the value of the field is `_8CYC`"]
151 #[inline(always)]
152 pub fn is_8cyc(&self) -> bool {
153 *self == DEFAULT_SDASETUP_A::_8CYC
154 }
155}
156#[doc = "Field `DEFAULT_SDASETUP` writer - SDA Setup Time"]
157pub type DEFAULT_SDASETUP_W<'a, const O: u8> =
158 crate::BitWriter<'a, u8, CTRLA_SPEC, DEFAULT_SDASETUP_A, O>;
159impl<'a, const O: u8> DEFAULT_SDASETUP_W<'a, O> {
160 #[doc = "SDA setup time is 4 clock cycles"]
161 #[inline(always)]
162 pub fn _4cyc(self) -> &'a mut W {
163 self.variant(DEFAULT_SDASETUP_A::_4CYC)
164 }
165 #[doc = "SDA setup time is 8 clock cycles"]
166 #[inline(always)]
167 pub fn _8cyc(self) -> &'a mut W {
168 self.variant(DEFAULT_SDASETUP_A::_8CYC)
169 }
170}
171impl R {
172 #[doc = "Bit 1 - FM Plus Enable"]
173 #[inline(always)]
174 pub fn default_fmpen(&self) -> DEFAULT_FMPEN_R {
175 DEFAULT_FMPEN_R::new(((self.bits >> 1) & 1) != 0)
176 }
177 #[doc = "Bits 2:3 - SDA Hold Time"]
178 #[inline(always)]
179 pub fn default_sdahold(&self) -> DEFAULT_SDAHOLD_R {
180 DEFAULT_SDAHOLD_R::new((self.bits >> 2) & 3)
181 }
182 #[doc = "Bit 4 - SDA Setup Time"]
183 #[inline(always)]
184 pub fn default_sdasetup(&self) -> DEFAULT_SDASETUP_R {
185 DEFAULT_SDASETUP_R::new(((self.bits >> 4) & 1) != 0)
186 }
187}
188impl W {
189 #[doc = "Bit 1 - FM Plus Enable"]
190 #[inline(always)]
191 #[must_use]
192 pub fn default_fmpen(&mut self) -> DEFAULT_FMPEN_W<1> {
193 DEFAULT_FMPEN_W::new(self)
194 }
195 #[doc = "Bits 2:3 - SDA Hold Time"]
196 #[inline(always)]
197 #[must_use]
198 pub fn default_sdahold(&mut self) -> DEFAULT_SDAHOLD_W<2> {
199 DEFAULT_SDAHOLD_W::new(self)
200 }
201 #[doc = "Bit 4 - SDA Setup Time"]
202 #[inline(always)]
203 #[must_use]
204 pub fn default_sdasetup(&mut self) -> DEFAULT_SDASETUP_W<4> {
205 DEFAULT_SDASETUP_W::new(self)
206 }
207 #[doc = "Writes raw bits to the register."]
208 #[inline(always)]
209 pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
210 self.0.bits(bits);
211 self
212 }
213}
214#[doc = "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 [ctrla](index.html) module"]
215pub struct CTRLA_SPEC;
216impl crate::RegisterSpec for CTRLA_SPEC {
217 type Ux = u8;
218}
219#[doc = "`read()` method returns [ctrla::R](R) reader structure"]
220impl crate::Readable for CTRLA_SPEC {
221 type Reader = R;
222}
223#[doc = "`write(|w| ..)` method takes [ctrla::W](W) writer structure"]
224impl crate::Writable for CTRLA_SPEC {
225 type Writer = W;
226 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
227 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
228}
229#[doc = "`reset()` method sets CTRLA to value 0"]
230impl crate::Resettable for CTRLA_SPEC {
231 const RESET_VALUE: Self::Ux = 0;
232}