atsame70j21/gmac/
gmac_st2cw115.rs

1#[doc = "Register `GMAC_ST2CW115` reader"]
2pub struct R(crate::R<GMAC_ST2CW115_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<GMAC_ST2CW115_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<GMAC_ST2CW115_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<GMAC_ST2CW115_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `GMAC_ST2CW115` writer"]
17pub struct W(crate::W<GMAC_ST2CW115_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<GMAC_ST2CW115_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<GMAC_ST2CW115_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<GMAC_ST2CW115_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `OFFSVAL` reader - Offset Value in Bytes"]
38pub struct OFFSVAL_R(crate::FieldReader<u8, u8>);
39impl OFFSVAL_R {
40    #[inline(always)]
41    pub(crate) fn new(bits: u8) -> Self {
42        OFFSVAL_R(crate::FieldReader::new(bits))
43    }
44}
45impl core::ops::Deref for OFFSVAL_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 `OFFSVAL` writer - Offset Value in Bytes"]
53pub struct OFFSVAL_W<'a> {
54    w: &'a mut W,
55}
56impl<'a> OFFSVAL_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 & !0x7f) | (value as u32 & 0x7f);
61        self.w
62    }
63}
64#[doc = "Ethernet Frame Offset Start\n\nValue on reset: 0"]
65#[derive(Clone, Copy, Debug, PartialEq)]
66#[repr(u8)]
67pub enum OFFSSTRT_A {
68    #[doc = "0: Offset from the start of the frame"]
69    FRAMESTART = 0,
70    #[doc = "1: Offset from the byte after the EtherType field"]
71    ETHERTYPE = 1,
72    #[doc = "2: Offset from the byte after the IP header field"]
73    IP = 2,
74    #[doc = "3: Offset from the byte after the TCP/UDP header field"]
75    TCP_UDP = 3,
76}
77impl From<OFFSSTRT_A> for u8 {
78    #[inline(always)]
79    fn from(variant: OFFSSTRT_A) -> Self {
80        variant as _
81    }
82}
83#[doc = "Field `OFFSSTRT` reader - Ethernet Frame Offset Start"]
84pub struct OFFSSTRT_R(crate::FieldReader<u8, OFFSSTRT_A>);
85impl OFFSSTRT_R {
86    #[inline(always)]
87    pub(crate) fn new(bits: u8) -> Self {
88        OFFSSTRT_R(crate::FieldReader::new(bits))
89    }
90    #[doc = r"Get enumerated values variant"]
91    #[inline(always)]
92    pub fn variant(&self) -> OFFSSTRT_A {
93        match self.bits {
94            0 => OFFSSTRT_A::FRAMESTART,
95            1 => OFFSSTRT_A::ETHERTYPE,
96            2 => OFFSSTRT_A::IP,
97            3 => OFFSSTRT_A::TCP_UDP,
98            _ => unreachable!(),
99        }
100    }
101    #[doc = "Checks if the value of the field is `FRAMESTART`"]
102    #[inline(always)]
103    pub fn is_framestart(&self) -> bool {
104        **self == OFFSSTRT_A::FRAMESTART
105    }
106    #[doc = "Checks if the value of the field is `ETHERTYPE`"]
107    #[inline(always)]
108    pub fn is_ethertype(&self) -> bool {
109        **self == OFFSSTRT_A::ETHERTYPE
110    }
111    #[doc = "Checks if the value of the field is `IP`"]
112    #[inline(always)]
113    pub fn is_ip(&self) -> bool {
114        **self == OFFSSTRT_A::IP
115    }
116    #[doc = "Checks if the value of the field is `TCP_UDP`"]
117    #[inline(always)]
118    pub fn is_tcp_udp(&self) -> bool {
119        **self == OFFSSTRT_A::TCP_UDP
120    }
121}
122impl core::ops::Deref for OFFSSTRT_R {
123    type Target = crate::FieldReader<u8, OFFSSTRT_A>;
124    #[inline(always)]
125    fn deref(&self) -> &Self::Target {
126        &self.0
127    }
128}
129#[doc = "Field `OFFSSTRT` writer - Ethernet Frame Offset Start"]
130pub struct OFFSSTRT_W<'a> {
131    w: &'a mut W,
132}
133impl<'a> OFFSSTRT_W<'a> {
134    #[doc = r"Writes `variant` to the field"]
135    #[inline(always)]
136    pub fn variant(self, variant: OFFSSTRT_A) -> &'a mut W {
137        self.bits(variant.into())
138    }
139    #[doc = "Offset from the start of the frame"]
140    #[inline(always)]
141    pub fn framestart(self) -> &'a mut W {
142        self.variant(OFFSSTRT_A::FRAMESTART)
143    }
144    #[doc = "Offset from the byte after the EtherType field"]
145    #[inline(always)]
146    pub fn ethertype(self) -> &'a mut W {
147        self.variant(OFFSSTRT_A::ETHERTYPE)
148    }
149    #[doc = "Offset from the byte after the IP header field"]
150    #[inline(always)]
151    pub fn ip(self) -> &'a mut W {
152        self.variant(OFFSSTRT_A::IP)
153    }
154    #[doc = "Offset from the byte after the TCP/UDP header field"]
155    #[inline(always)]
156    pub fn tcp_udp(self) -> &'a mut W {
157        self.variant(OFFSSTRT_A::TCP_UDP)
158    }
159    #[doc = r"Writes raw bits to the field"]
160    #[inline(always)]
161    pub fn bits(self, value: u8) -> &'a mut W {
162        self.w.bits = (self.w.bits & !(0x03 << 7)) | ((value as u32 & 0x03) << 7);
163        self.w
164    }
165}
166impl R {
167    #[doc = "Bits 0:6 - Offset Value in Bytes"]
168    #[inline(always)]
169    pub fn offsval(&self) -> OFFSVAL_R {
170        OFFSVAL_R::new((self.bits & 0x7f) as u8)
171    }
172    #[doc = "Bits 7:8 - Ethernet Frame Offset Start"]
173    #[inline(always)]
174    pub fn offsstrt(&self) -> OFFSSTRT_R {
175        OFFSSTRT_R::new(((self.bits >> 7) & 0x03) as u8)
176    }
177}
178impl W {
179    #[doc = "Bits 0:6 - Offset Value in Bytes"]
180    #[inline(always)]
181    pub fn offsval(&mut self) -> OFFSVAL_W {
182        OFFSVAL_W { w: self }
183    }
184    #[doc = "Bits 7:8 - Ethernet Frame Offset Start"]
185    #[inline(always)]
186    pub fn offsstrt(&mut self) -> OFFSSTRT_W {
187        OFFSSTRT_W { w: self }
188    }
189    #[doc = "Writes raw bits to the register."]
190    #[inline(always)]
191    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
192        self.0.bits(bits);
193        self
194    }
195}
196#[doc = "Screening Type 2 Compare Word 1 Register (index = 15)\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 [gmac_st2cw115](index.html) module"]
197pub struct GMAC_ST2CW115_SPEC;
198impl crate::RegisterSpec for GMAC_ST2CW115_SPEC {
199    type Ux = u32;
200}
201#[doc = "`read()` method returns [gmac_st2cw115::R](R) reader structure"]
202impl crate::Readable for GMAC_ST2CW115_SPEC {
203    type Reader = R;
204}
205#[doc = "`write(|w| ..)` method takes [gmac_st2cw115::W](W) writer structure"]
206impl crate::Writable for GMAC_ST2CW115_SPEC {
207    type Writer = W;
208}
209#[doc = "`reset()` method sets GMAC_ST2CW115 to value 0"]
210impl crate::Resettable for GMAC_ST2CW115_SPEC {
211    #[inline(always)]
212    fn reset_value() -> Self::Ux {
213        0
214    }
215}