lpc55_pac/i2c0/
timeout.rs

1#[doc = "Register `TIMEOUT` reader"]
2pub struct R(crate::R<TIMEOUT_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<TIMEOUT_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<TIMEOUT_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<TIMEOUT_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `TIMEOUT` writer"]
17pub struct W(crate::W<TIMEOUT_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<TIMEOUT_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<TIMEOUT_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<TIMEOUT_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `TOMIN` reader - Time-out time value, bottom four bits. These are hard-wired to 0xF. This gives a minimum time-out of 16 I2C function clocks and also a time-out resolution of 16 I2C function clocks."]
38pub struct TOMIN_R(crate::FieldReader<u8, u8>);
39impl TOMIN_R {
40    #[inline(always)]
41    pub(crate) fn new(bits: u8) -> Self {
42        TOMIN_R(crate::FieldReader::new(bits))
43    }
44}
45impl core::ops::Deref for TOMIN_R {
46    type Target = crate::FieldReader<u8, u8>;
47    #[inline(always)]
48    fn deref(&self) -> &Self::Target {
49        &self.0
50    }
51}
52#[doc = "Field `TOMIN` writer - Time-out time value, bottom four bits. These are hard-wired to 0xF. This gives a minimum time-out of 16 I2C function clocks and also a time-out resolution of 16 I2C function clocks."]
53pub struct TOMIN_W<'a> {
54    w: &'a mut W,
55}
56impl<'a> TOMIN_W<'a> {
57    #[doc = r"Writes raw bits to the field"]
58    #[inline(always)]
59    pub unsafe fn bits(self, value: u8) -> &'a mut W {
60        self.w.bits = (self.w.bits & !0x0f) | (value as u32 & 0x0f);
61        self.w
62    }
63}
64#[doc = "Field `TO` reader - Time-out time value. Specifies the time-out interval value in increments of 16 I 2C function clocks, as defined by the CLKDIV register. To change this value while I2C is in operation, disable all time-outs, write a new value to TIMEOUT, then re-enable time-outs. 0x000 = A time-out will occur after 16 counts of the I2C function clock. 0x001 = A time-out will occur after 32 counts of the I2C function clock. 0xFFF = A time-out will occur after 65,536 counts of the I2C function clock."]
65pub struct TO_R(crate::FieldReader<u16, u16>);
66impl TO_R {
67    #[inline(always)]
68    pub(crate) fn new(bits: u16) -> Self {
69        TO_R(crate::FieldReader::new(bits))
70    }
71}
72impl core::ops::Deref for TO_R {
73    type Target = crate::FieldReader<u16, u16>;
74    #[inline(always)]
75    fn deref(&self) -> &Self::Target {
76        &self.0
77    }
78}
79#[doc = "Field `TO` writer - Time-out time value. Specifies the time-out interval value in increments of 16 I 2C function clocks, as defined by the CLKDIV register. To change this value while I2C is in operation, disable all time-outs, write a new value to TIMEOUT, then re-enable time-outs. 0x000 = A time-out will occur after 16 counts of the I2C function clock. 0x001 = A time-out will occur after 32 counts of the I2C function clock. 0xFFF = A time-out will occur after 65,536 counts of the I2C function clock."]
80pub struct TO_W<'a> {
81    w: &'a mut W,
82}
83impl<'a> TO_W<'a> {
84    #[doc = r"Writes raw bits to the field"]
85    #[inline(always)]
86    pub unsafe fn bits(self, value: u16) -> &'a mut W {
87        self.w.bits = (self.w.bits & !(0x0fff << 4)) | ((value as u32 & 0x0fff) << 4);
88        self.w
89    }
90}
91impl R {
92    #[doc = "Bits 0:3 - Time-out time value, bottom four bits. These are hard-wired to 0xF. This gives a minimum time-out of 16 I2C function clocks and also a time-out resolution of 16 I2C function clocks."]
93    #[inline(always)]
94    pub fn tomin(&self) -> TOMIN_R {
95        TOMIN_R::new((self.bits & 0x0f) as u8)
96    }
97    #[doc = "Bits 4:15 - Time-out time value. Specifies the time-out interval value in increments of 16 I 2C function clocks, as defined by the CLKDIV register. To change this value while I2C is in operation, disable all time-outs, write a new value to TIMEOUT, then re-enable time-outs. 0x000 = A time-out will occur after 16 counts of the I2C function clock. 0x001 = A time-out will occur after 32 counts of the I2C function clock. 0xFFF = A time-out will occur after 65,536 counts of the I2C function clock."]
98    #[inline(always)]
99    pub fn to(&self) -> TO_R {
100        TO_R::new(((self.bits >> 4) & 0x0fff) as u16)
101    }
102}
103impl W {
104    #[doc = "Bits 0:3 - Time-out time value, bottom four bits. These are hard-wired to 0xF. This gives a minimum time-out of 16 I2C function clocks and also a time-out resolution of 16 I2C function clocks."]
105    #[inline(always)]
106    pub fn tomin(&mut self) -> TOMIN_W {
107        TOMIN_W { w: self }
108    }
109    #[doc = "Bits 4:15 - Time-out time value. Specifies the time-out interval value in increments of 16 I 2C function clocks, as defined by the CLKDIV register. To change this value while I2C is in operation, disable all time-outs, write a new value to TIMEOUT, then re-enable time-outs. 0x000 = A time-out will occur after 16 counts of the I2C function clock. 0x001 = A time-out will occur after 32 counts of the I2C function clock. 0xFFF = A time-out will occur after 65,536 counts of the I2C function clock."]
110    #[inline(always)]
111    pub fn to(&mut self) -> TO_W {
112        TO_W { w: self }
113    }
114    #[doc = "Writes raw bits to the register."]
115    #[inline(always)]
116    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
117        self.0.bits(bits);
118        self
119    }
120}
121#[doc = "Time-out value register.\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 [timeout](index.html) module"]
122pub struct TIMEOUT_SPEC;
123impl crate::RegisterSpec for TIMEOUT_SPEC {
124    type Ux = u32;
125}
126#[doc = "`read()` method returns [timeout::R](R) reader structure"]
127impl crate::Readable for TIMEOUT_SPEC {
128    type Reader = R;
129}
130#[doc = "`write(|w| ..)` method takes [timeout::W](W) writer structure"]
131impl crate::Writable for TIMEOUT_SPEC {
132    type Writer = W;
133}
134#[doc = "`reset()` method sets TIMEOUT to value 0xffff"]
135impl crate::Resettable for TIMEOUT_SPEC {
136    #[inline(always)]
137    fn reset_value() -> Self::Ux {
138        0xffff
139    }
140}