avr_device/devices/atmega2560/twi/
twcr.rs1#[doc = "Register `TWCR` reader"]
2pub struct R(crate::R<TWCR_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<TWCR_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<TWCR_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<TWCR_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `TWCR` writer"]
17pub struct W(crate::W<TWCR_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<TWCR_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<TWCR_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<TWCR_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Field `TWIE` reader - TWI Interrupt Enable"]
38pub type TWIE_R = crate::BitReader<bool>;
39#[doc = "Field `TWIE` writer - TWI Interrupt Enable"]
40pub type TWIE_W<'a, const O: u8> = crate::BitWriter<'a, u8, TWCR_SPEC, bool, O>;
41#[doc = "Field `TWEN` reader - TWI Enable Bit"]
42pub type TWEN_R = crate::BitReader<bool>;
43#[doc = "Field `TWEN` writer - TWI Enable Bit"]
44pub type TWEN_W<'a, const O: u8> = crate::BitWriter<'a, u8, TWCR_SPEC, bool, O>;
45#[doc = "Field `TWWC` reader - TWI Write Collition Flag"]
46pub type TWWC_R = crate::BitReader<bool>;
47#[doc = "Field `TWSTO` reader - TWI Stop Condition Bit"]
48pub type TWSTO_R = crate::BitReader<bool>;
49#[doc = "Field `TWSTO` writer - TWI Stop Condition Bit"]
50pub type TWSTO_W<'a, const O: u8> = crate::BitWriter<'a, u8, TWCR_SPEC, bool, O>;
51#[doc = "Field `TWSTA` reader - TWI Start Condition Bit"]
52pub type TWSTA_R = crate::BitReader<bool>;
53#[doc = "Field `TWSTA` writer - TWI Start Condition Bit"]
54pub type TWSTA_W<'a, const O: u8> = crate::BitWriter<'a, u8, TWCR_SPEC, bool, O>;
55#[doc = "Field `TWEA` reader - TWI Enable Acknowledge Bit"]
56pub type TWEA_R = crate::BitReader<bool>;
57#[doc = "Field `TWEA` writer - TWI Enable Acknowledge Bit"]
58pub type TWEA_W<'a, const O: u8> = crate::BitWriter<'a, u8, TWCR_SPEC, bool, O>;
59#[doc = "Field `TWINT` reader - TWI Interrupt Flag"]
60pub type TWINT_R = crate::BitReader<bool>;
61#[doc = "Field `TWINT` writer - TWI Interrupt Flag"]
62pub type TWINT_W<'a, const O: u8> = crate::BitWriter<'a, u8, TWCR_SPEC, bool, O>;
63impl R {
64 #[doc = "Bit 0 - TWI Interrupt Enable"]
65 #[inline(always)]
66 pub fn twie(&self) -> TWIE_R {
67 TWIE_R::new((self.bits & 1) != 0)
68 }
69 #[doc = "Bit 2 - TWI Enable Bit"]
70 #[inline(always)]
71 pub fn twen(&self) -> TWEN_R {
72 TWEN_R::new(((self.bits >> 2) & 1) != 0)
73 }
74 #[doc = "Bit 3 - TWI Write Collition Flag"]
75 #[inline(always)]
76 pub fn twwc(&self) -> TWWC_R {
77 TWWC_R::new(((self.bits >> 3) & 1) != 0)
78 }
79 #[doc = "Bit 4 - TWI Stop Condition Bit"]
80 #[inline(always)]
81 pub fn twsto(&self) -> TWSTO_R {
82 TWSTO_R::new(((self.bits >> 4) & 1) != 0)
83 }
84 #[doc = "Bit 5 - TWI Start Condition Bit"]
85 #[inline(always)]
86 pub fn twsta(&self) -> TWSTA_R {
87 TWSTA_R::new(((self.bits >> 5) & 1) != 0)
88 }
89 #[doc = "Bit 6 - TWI Enable Acknowledge Bit"]
90 #[inline(always)]
91 pub fn twea(&self) -> TWEA_R {
92 TWEA_R::new(((self.bits >> 6) & 1) != 0)
93 }
94 #[doc = "Bit 7 - TWI Interrupt Flag"]
95 #[inline(always)]
96 pub fn twint(&self) -> TWINT_R {
97 TWINT_R::new(((self.bits >> 7) & 1) != 0)
98 }
99}
100impl W {
101 #[doc = "Bit 0 - TWI Interrupt Enable"]
102 #[inline(always)]
103 #[must_use]
104 pub fn twie(&mut self) -> TWIE_W<0> {
105 TWIE_W::new(self)
106 }
107 #[doc = "Bit 2 - TWI Enable Bit"]
108 #[inline(always)]
109 #[must_use]
110 pub fn twen(&mut self) -> TWEN_W<2> {
111 TWEN_W::new(self)
112 }
113 #[doc = "Bit 4 - TWI Stop Condition Bit"]
114 #[inline(always)]
115 #[must_use]
116 pub fn twsto(&mut self) -> TWSTO_W<4> {
117 TWSTO_W::new(self)
118 }
119 #[doc = "Bit 5 - TWI Start Condition Bit"]
120 #[inline(always)]
121 #[must_use]
122 pub fn twsta(&mut self) -> TWSTA_W<5> {
123 TWSTA_W::new(self)
124 }
125 #[doc = "Bit 6 - TWI Enable Acknowledge Bit"]
126 #[inline(always)]
127 #[must_use]
128 pub fn twea(&mut self) -> TWEA_W<6> {
129 TWEA_W::new(self)
130 }
131 #[doc = "Bit 7 - TWI Interrupt Flag"]
132 #[inline(always)]
133 #[must_use]
134 pub fn twint(&mut self) -> TWINT_W<7> {
135 TWINT_W::new(self)
136 }
137 #[doc = "Writes raw bits to the register."]
138 #[inline(always)]
139 pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
140 self.0.bits(bits);
141 self
142 }
143}
144#[doc = "TWI Control 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 [twcr](index.html) module"]
145pub struct TWCR_SPEC;
146impl crate::RegisterSpec for TWCR_SPEC {
147 type Ux = u8;
148}
149#[doc = "`read()` method returns [twcr::R](R) reader structure"]
150impl crate::Readable for TWCR_SPEC {
151 type Reader = R;
152}
153#[doc = "`write(|w| ..)` method takes [twcr::W](W) writer structure"]
154impl crate::Writable for TWCR_SPEC {
155 type Writer = W;
156 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
157 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
158}
159#[doc = "`reset()` method sets TWCR to value 0"]
160impl crate::Resettable for TWCR_SPEC {
161 const RESET_VALUE: Self::Ux = 0;
162}