nrf51_pac/twi0/
errorsrc.rs

1#[doc = "Register `ERRORSRC` reader"]
2pub struct R(crate::R<ERRORSRC_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<ERRORSRC_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<ERRORSRC_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<ERRORSRC_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `ERRORSRC` writer"]
17pub struct W(crate::W<ERRORSRC_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<ERRORSRC_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<ERRORSRC_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<ERRORSRC_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `OVERRUN` reader - Byte received in RXD register before read of the last received byte (data loss)."]
38pub type OVERRUN_R = crate::BitReader<OVERRUN_A>;
39#[doc = "Byte received in RXD register before read of the last received byte (data loss).\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq)]
41pub enum OVERRUN_A {
42    #[doc = "0: Error not present."]
43    NOT_PRESENT = 0,
44    #[doc = "1: Error present."]
45    PRESENT = 1,
46}
47impl From<OVERRUN_A> for bool {
48    #[inline(always)]
49    fn from(variant: OVERRUN_A) -> Self {
50        variant as u8 != 0
51    }
52}
53impl OVERRUN_R {
54    #[doc = "Get enumerated values variant"]
55    #[inline(always)]
56    pub fn variant(&self) -> OVERRUN_A {
57        match self.bits {
58            false => OVERRUN_A::NOT_PRESENT,
59            true => OVERRUN_A::PRESENT,
60        }
61    }
62    #[doc = "Checks if the value of the field is `NOT_PRESENT`"]
63    #[inline(always)]
64    pub fn is_not_present(&self) -> bool {
65        *self == OVERRUN_A::NOT_PRESENT
66    }
67    #[doc = "Checks if the value of the field is `PRESENT`"]
68    #[inline(always)]
69    pub fn is_present(&self) -> bool {
70        *self == OVERRUN_A::PRESENT
71    }
72}
73#[doc = "Byte received in RXD register before read of the last received byte (data loss).\n\nValue on reset: 0"]
74#[derive(Clone, Copy, Debug, PartialEq)]
75pub enum OVERRUN_AW {
76    #[doc = "1: Clear error on write."]
77    CLEAR = 1,
78}
79impl From<OVERRUN_AW> for bool {
80    #[inline(always)]
81    fn from(variant: OVERRUN_AW) -> Self {
82        variant as u8 != 0
83    }
84}
85#[doc = "Field `OVERRUN` writer - Byte received in RXD register before read of the last received byte (data loss)."]
86pub type OVERRUN_W<'a, const O: u8> = crate::BitWriter<'a, u32, ERRORSRC_SPEC, OVERRUN_AW, O>;
87impl<'a, const O: u8> OVERRUN_W<'a, O> {
88    #[doc = "Clear error on write."]
89    #[inline(always)]
90    pub fn clear(self) -> &'a mut W {
91        self.variant(OVERRUN_AW::CLEAR)
92    }
93}
94#[doc = "Field `ANACK` reader - NACK received after sending the address."]
95pub type ANACK_R = crate::BitReader<ANACK_A>;
96#[doc = "NACK received after sending the address.\n\nValue on reset: 0"]
97#[derive(Clone, Copy, Debug, PartialEq)]
98pub enum ANACK_A {
99    #[doc = "0: Error not present."]
100    NOT_PRESENT = 0,
101    #[doc = "1: Error present."]
102    PRESENT = 1,
103}
104impl From<ANACK_A> for bool {
105    #[inline(always)]
106    fn from(variant: ANACK_A) -> Self {
107        variant as u8 != 0
108    }
109}
110impl ANACK_R {
111    #[doc = "Get enumerated values variant"]
112    #[inline(always)]
113    pub fn variant(&self) -> ANACK_A {
114        match self.bits {
115            false => ANACK_A::NOT_PRESENT,
116            true => ANACK_A::PRESENT,
117        }
118    }
119    #[doc = "Checks if the value of the field is `NOT_PRESENT`"]
120    #[inline(always)]
121    pub fn is_not_present(&self) -> bool {
122        *self == ANACK_A::NOT_PRESENT
123    }
124    #[doc = "Checks if the value of the field is `PRESENT`"]
125    #[inline(always)]
126    pub fn is_present(&self) -> bool {
127        *self == ANACK_A::PRESENT
128    }
129}
130#[doc = "NACK received after sending the address.\n\nValue on reset: 0"]
131#[derive(Clone, Copy, Debug, PartialEq)]
132pub enum ANACK_AW {
133    #[doc = "1: Clear error on write."]
134    CLEAR = 1,
135}
136impl From<ANACK_AW> for bool {
137    #[inline(always)]
138    fn from(variant: ANACK_AW) -> Self {
139        variant as u8 != 0
140    }
141}
142#[doc = "Field `ANACK` writer - NACK received after sending the address."]
143pub type ANACK_W<'a, const O: u8> = crate::BitWriter<'a, u32, ERRORSRC_SPEC, ANACK_AW, O>;
144impl<'a, const O: u8> ANACK_W<'a, O> {
145    #[doc = "Clear error on write."]
146    #[inline(always)]
147    pub fn clear(self) -> &'a mut W {
148        self.variant(ANACK_AW::CLEAR)
149    }
150}
151#[doc = "Field `DNACK` reader - NACK received after sending a data byte."]
152pub type DNACK_R = crate::BitReader<DNACK_A>;
153#[doc = "NACK received after sending a data byte.\n\nValue on reset: 0"]
154#[derive(Clone, Copy, Debug, PartialEq)]
155pub enum DNACK_A {
156    #[doc = "0: Error not present."]
157    NOT_PRESENT = 0,
158    #[doc = "1: Error present."]
159    PRESENT = 1,
160}
161impl From<DNACK_A> for bool {
162    #[inline(always)]
163    fn from(variant: DNACK_A) -> Self {
164        variant as u8 != 0
165    }
166}
167impl DNACK_R {
168    #[doc = "Get enumerated values variant"]
169    #[inline(always)]
170    pub fn variant(&self) -> DNACK_A {
171        match self.bits {
172            false => DNACK_A::NOT_PRESENT,
173            true => DNACK_A::PRESENT,
174        }
175    }
176    #[doc = "Checks if the value of the field is `NOT_PRESENT`"]
177    #[inline(always)]
178    pub fn is_not_present(&self) -> bool {
179        *self == DNACK_A::NOT_PRESENT
180    }
181    #[doc = "Checks if the value of the field is `PRESENT`"]
182    #[inline(always)]
183    pub fn is_present(&self) -> bool {
184        *self == DNACK_A::PRESENT
185    }
186}
187#[doc = "NACK received after sending a data byte.\n\nValue on reset: 0"]
188#[derive(Clone, Copy, Debug, PartialEq)]
189pub enum DNACK_AW {
190    #[doc = "1: Clear error on write."]
191    CLEAR = 1,
192}
193impl From<DNACK_AW> for bool {
194    #[inline(always)]
195    fn from(variant: DNACK_AW) -> Self {
196        variant as u8 != 0
197    }
198}
199#[doc = "Field `DNACK` writer - NACK received after sending a data byte."]
200pub type DNACK_W<'a, const O: u8> = crate::BitWriter<'a, u32, ERRORSRC_SPEC, DNACK_AW, O>;
201impl<'a, const O: u8> DNACK_W<'a, O> {
202    #[doc = "Clear error on write."]
203    #[inline(always)]
204    pub fn clear(self) -> &'a mut W {
205        self.variant(DNACK_AW::CLEAR)
206    }
207}
208impl R {
209    #[doc = "Bit 0 - Byte received in RXD register before read of the last received byte (data loss)."]
210    #[inline(always)]
211    pub fn overrun(&self) -> OVERRUN_R {
212        OVERRUN_R::new((self.bits & 1) != 0)
213    }
214    #[doc = "Bit 1 - NACK received after sending the address."]
215    #[inline(always)]
216    pub fn anack(&self) -> ANACK_R {
217        ANACK_R::new(((self.bits >> 1) & 1) != 0)
218    }
219    #[doc = "Bit 2 - NACK received after sending a data byte."]
220    #[inline(always)]
221    pub fn dnack(&self) -> DNACK_R {
222        DNACK_R::new(((self.bits >> 2) & 1) != 0)
223    }
224}
225impl W {
226    #[doc = "Bit 0 - Byte received in RXD register before read of the last received byte (data loss)."]
227    #[inline(always)]
228    pub fn overrun(&mut self) -> OVERRUN_W<0> {
229        OVERRUN_W::new(self)
230    }
231    #[doc = "Bit 1 - NACK received after sending the address."]
232    #[inline(always)]
233    pub fn anack(&mut self) -> ANACK_W<1> {
234        ANACK_W::new(self)
235    }
236    #[doc = "Bit 2 - NACK received after sending a data byte."]
237    #[inline(always)]
238    pub fn dnack(&mut self) -> DNACK_W<2> {
239        DNACK_W::new(self)
240    }
241    #[doc = "Writes raw bits to the register."]
242    #[inline(always)]
243    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
244        self.0.bits(bits);
245        self
246    }
247}
248#[doc = "Two-wire error source. Write error field to 1 to clear error.\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 [errorsrc](index.html) module"]
249pub struct ERRORSRC_SPEC;
250impl crate::RegisterSpec for ERRORSRC_SPEC {
251    type Ux = u32;
252}
253#[doc = "`read()` method returns [errorsrc::R](R) reader structure"]
254impl crate::Readable for ERRORSRC_SPEC {
255    type Reader = R;
256}
257#[doc = "`write(|w| ..)` method takes [errorsrc::W](W) writer structure"]
258impl crate::Writable for ERRORSRC_SPEC {
259    type Writer = W;
260}
261#[doc = "`reset()` method sets ERRORSRC to value 0"]
262impl crate::Resettable for ERRORSRC_SPEC {
263    #[inline(always)]
264    fn reset_value() -> Self::Ux {
265        0
266    }
267}