stm32f0/stm32f0x0/i2c1/
timeoutr.rs1#[doc = "Register `TIMEOUTR` reader"]
2pub struct R(crate::R<TIMEOUTR_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<TIMEOUTR_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<TIMEOUTR_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<TIMEOUTR_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `TIMEOUTR` writer"]
17pub struct W(crate::W<TIMEOUTR_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<TIMEOUTR_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<TIMEOUTR_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<TIMEOUTR_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `TIMEOUTA` reader - Bus timeout A"]
38pub type TIMEOUTA_R = crate::FieldReader<u16, u16>;
39#[doc = "Field `TIMEOUTA` writer - Bus timeout A"]
40pub type TIMEOUTA_W<'a, const O: u8> =
41 crate::FieldWriterSafe<'a, u32, TIMEOUTR_SPEC, u16, u16, 12, O>;
42#[doc = "Idle clock timeout detection\n\nValue on reset: 0"]
43#[derive(Clone, Copy, Debug, PartialEq)]
44pub enum TIDLE_A {
45 #[doc = "0: TIMEOUTA is used to detect SCL low timeout"]
46 Disabled = 0,
47 #[doc = "1: TIMEOUTA is used to detect both SCL and SDA high timeout (bus idle condition)"]
48 Enabled = 1,
49}
50impl From<TIDLE_A> for bool {
51 #[inline(always)]
52 fn from(variant: TIDLE_A) -> Self {
53 variant as u8 != 0
54 }
55}
56#[doc = "Field `TIDLE` reader - Idle clock timeout detection"]
57pub type TIDLE_R = crate::BitReader<TIDLE_A>;
58impl TIDLE_R {
59 #[doc = "Get enumerated values variant"]
60 #[inline(always)]
61 pub fn variant(&self) -> TIDLE_A {
62 match self.bits {
63 false => TIDLE_A::Disabled,
64 true => TIDLE_A::Enabled,
65 }
66 }
67 #[doc = "Checks if the value of the field is `Disabled`"]
68 #[inline(always)]
69 pub fn is_disabled(&self) -> bool {
70 *self == TIDLE_A::Disabled
71 }
72 #[doc = "Checks if the value of the field is `Enabled`"]
73 #[inline(always)]
74 pub fn is_enabled(&self) -> bool {
75 *self == TIDLE_A::Enabled
76 }
77}
78#[doc = "Field `TIDLE` writer - Idle clock timeout detection"]
79pub type TIDLE_W<'a, const O: u8> = crate::BitWriter<'a, u32, TIMEOUTR_SPEC, TIDLE_A, O>;
80impl<'a, const O: u8> TIDLE_W<'a, O> {
81 #[doc = "TIMEOUTA is used to detect SCL low timeout"]
82 #[inline(always)]
83 pub fn disabled(self) -> &'a mut W {
84 self.variant(TIDLE_A::Disabled)
85 }
86 #[doc = "TIMEOUTA is used to detect both SCL and SDA high timeout (bus idle condition)"]
87 #[inline(always)]
88 pub fn enabled(self) -> &'a mut W {
89 self.variant(TIDLE_A::Enabled)
90 }
91}
92#[doc = "Clock timeout enable\n\nValue on reset: 0"]
93#[derive(Clone, Copy, Debug, PartialEq)]
94pub enum TIMOUTEN_A {
95 #[doc = "0: SCL timeout detection is disabled"]
96 Disabled = 0,
97 #[doc = "1: SCL timeout detection is enabled"]
98 Enabled = 1,
99}
100impl From<TIMOUTEN_A> for bool {
101 #[inline(always)]
102 fn from(variant: TIMOUTEN_A) -> Self {
103 variant as u8 != 0
104 }
105}
106#[doc = "Field `TIMOUTEN` reader - Clock timeout enable"]
107pub type TIMOUTEN_R = crate::BitReader<TIMOUTEN_A>;
108impl TIMOUTEN_R {
109 #[doc = "Get enumerated values variant"]
110 #[inline(always)]
111 pub fn variant(&self) -> TIMOUTEN_A {
112 match self.bits {
113 false => TIMOUTEN_A::Disabled,
114 true => TIMOUTEN_A::Enabled,
115 }
116 }
117 #[doc = "Checks if the value of the field is `Disabled`"]
118 #[inline(always)]
119 pub fn is_disabled(&self) -> bool {
120 *self == TIMOUTEN_A::Disabled
121 }
122 #[doc = "Checks if the value of the field is `Enabled`"]
123 #[inline(always)]
124 pub fn is_enabled(&self) -> bool {
125 *self == TIMOUTEN_A::Enabled
126 }
127}
128#[doc = "Field `TIMOUTEN` writer - Clock timeout enable"]
129pub type TIMOUTEN_W<'a, const O: u8> = crate::BitWriter<'a, u32, TIMEOUTR_SPEC, TIMOUTEN_A, O>;
130impl<'a, const O: u8> TIMOUTEN_W<'a, O> {
131 #[doc = "SCL timeout detection is disabled"]
132 #[inline(always)]
133 pub fn disabled(self) -> &'a mut W {
134 self.variant(TIMOUTEN_A::Disabled)
135 }
136 #[doc = "SCL timeout detection is enabled"]
137 #[inline(always)]
138 pub fn enabled(self) -> &'a mut W {
139 self.variant(TIMOUTEN_A::Enabled)
140 }
141}
142#[doc = "Field `TIMEOUTB` reader - Bus timeout B"]
143pub type TIMEOUTB_R = crate::FieldReader<u16, u16>;
144#[doc = "Field `TIMEOUTB` writer - Bus timeout B"]
145pub type TIMEOUTB_W<'a, const O: u8> =
146 crate::FieldWriterSafe<'a, u32, TIMEOUTR_SPEC, u16, u16, 12, O>;
147#[doc = "Extended clock timeout enable\n\nValue on reset: 0"]
148#[derive(Clone, Copy, Debug, PartialEq)]
149pub enum TEXTEN_A {
150 #[doc = "0: Extended clock timeout detection is disabled"]
151 Disabled = 0,
152 #[doc = "1: Extended clock timeout detection is enabled"]
153 Enabled = 1,
154}
155impl From<TEXTEN_A> for bool {
156 #[inline(always)]
157 fn from(variant: TEXTEN_A) -> Self {
158 variant as u8 != 0
159 }
160}
161#[doc = "Field `TEXTEN` reader - Extended clock timeout enable"]
162pub type TEXTEN_R = crate::BitReader<TEXTEN_A>;
163impl TEXTEN_R {
164 #[doc = "Get enumerated values variant"]
165 #[inline(always)]
166 pub fn variant(&self) -> TEXTEN_A {
167 match self.bits {
168 false => TEXTEN_A::Disabled,
169 true => TEXTEN_A::Enabled,
170 }
171 }
172 #[doc = "Checks if the value of the field is `Disabled`"]
173 #[inline(always)]
174 pub fn is_disabled(&self) -> bool {
175 *self == TEXTEN_A::Disabled
176 }
177 #[doc = "Checks if the value of the field is `Enabled`"]
178 #[inline(always)]
179 pub fn is_enabled(&self) -> bool {
180 *self == TEXTEN_A::Enabled
181 }
182}
183#[doc = "Field `TEXTEN` writer - Extended clock timeout enable"]
184pub type TEXTEN_W<'a, const O: u8> = crate::BitWriter<'a, u32, TIMEOUTR_SPEC, TEXTEN_A, O>;
185impl<'a, const O: u8> TEXTEN_W<'a, O> {
186 #[doc = "Extended clock timeout detection is disabled"]
187 #[inline(always)]
188 pub fn disabled(self) -> &'a mut W {
189 self.variant(TEXTEN_A::Disabled)
190 }
191 #[doc = "Extended clock timeout detection is enabled"]
192 #[inline(always)]
193 pub fn enabled(self) -> &'a mut W {
194 self.variant(TEXTEN_A::Enabled)
195 }
196}
197impl R {
198 #[doc = "Bits 0:11 - Bus timeout A"]
199 #[inline(always)]
200 pub fn timeouta(&self) -> TIMEOUTA_R {
201 TIMEOUTA_R::new((self.bits & 0x0fff) as u16)
202 }
203 #[doc = "Bit 12 - Idle clock timeout detection"]
204 #[inline(always)]
205 pub fn tidle(&self) -> TIDLE_R {
206 TIDLE_R::new(((self.bits >> 12) & 1) != 0)
207 }
208 #[doc = "Bit 15 - Clock timeout enable"]
209 #[inline(always)]
210 pub fn timouten(&self) -> TIMOUTEN_R {
211 TIMOUTEN_R::new(((self.bits >> 15) & 1) != 0)
212 }
213 #[doc = "Bits 16:27 - Bus timeout B"]
214 #[inline(always)]
215 pub fn timeoutb(&self) -> TIMEOUTB_R {
216 TIMEOUTB_R::new(((self.bits >> 16) & 0x0fff) as u16)
217 }
218 #[doc = "Bit 31 - Extended clock timeout enable"]
219 #[inline(always)]
220 pub fn texten(&self) -> TEXTEN_R {
221 TEXTEN_R::new(((self.bits >> 31) & 1) != 0)
222 }
223}
224impl W {
225 #[doc = "Bits 0:11 - Bus timeout A"]
226 #[inline(always)]
227 pub fn timeouta(&mut self) -> TIMEOUTA_W<0> {
228 TIMEOUTA_W::new(self)
229 }
230 #[doc = "Bit 12 - Idle clock timeout detection"]
231 #[inline(always)]
232 pub fn tidle(&mut self) -> TIDLE_W<12> {
233 TIDLE_W::new(self)
234 }
235 #[doc = "Bit 15 - Clock timeout enable"]
236 #[inline(always)]
237 pub fn timouten(&mut self) -> TIMOUTEN_W<15> {
238 TIMOUTEN_W::new(self)
239 }
240 #[doc = "Bits 16:27 - Bus timeout B"]
241 #[inline(always)]
242 pub fn timeoutb(&mut self) -> TIMEOUTB_W<16> {
243 TIMEOUTB_W::new(self)
244 }
245 #[doc = "Bit 31 - Extended clock timeout enable"]
246 #[inline(always)]
247 pub fn texten(&mut self) -> TEXTEN_W<31> {
248 TEXTEN_W::new(self)
249 }
250 #[doc = "Writes raw bits to the register."]
251 #[inline(always)]
252 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
253 self.0.bits(bits);
254 self
255 }
256}
257#[doc = "Status register 1\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 [timeoutr](index.html) module"]
258pub struct TIMEOUTR_SPEC;
259impl crate::RegisterSpec for TIMEOUTR_SPEC {
260 type Ux = u32;
261}
262#[doc = "`read()` method returns [timeoutr::R](R) reader structure"]
263impl crate::Readable for TIMEOUTR_SPEC {
264 type Reader = R;
265}
266#[doc = "`write(|w| ..)` method takes [timeoutr::W](W) writer structure"]
267impl crate::Writable for TIMEOUTR_SPEC {
268 type Writer = W;
269}
270#[doc = "`reset()` method sets TIMEOUTR to value 0"]
271impl crate::Resettable for TIMEOUTR_SPEC {
272 #[inline(always)]
273 fn reset_value() -> Self::Ux {
274 0
275 }
276}