corstone300_pac/ethernet/
gpio_cfg.rs

1// Copyright 2022 Arm Limited and/or its affiliates <open-source-office@arm.com>
2//
3// SPDX-License-Identifier: MIT
4
5#[doc = "Register `GPIO_CFG` reader"]
6pub struct R(crate::R<GPIO_CFG_SPEC>);
7impl core::ops::Deref for R {
8    type Target = crate::R<GPIO_CFG_SPEC>;
9    #[inline(always)]
10    fn deref(&self) -> &Self::Target {
11        &self.0
12    }
13}
14impl From<crate::R<GPIO_CFG_SPEC>> for R {
15    #[inline(always)]
16    fn from(reader: crate::R<GPIO_CFG_SPEC>) -> Self {
17        R(reader)
18    }
19}
20#[doc = "Register `GPIO_CFG` writer"]
21pub struct W(crate::W<GPIO_CFG_SPEC>);
22impl core::ops::Deref for W {
23    type Target = crate::W<GPIO_CFG_SPEC>;
24    #[inline(always)]
25    fn deref(&self) -> &Self::Target {
26        &self.0
27    }
28}
29impl core::ops::DerefMut for W {
30    #[inline(always)]
31    fn deref_mut(&mut self) -> &mut Self::Target {
32        &mut self.0
33    }
34}
35impl From<crate::W<GPIO_CFG_SPEC>> for W {
36    #[inline(always)]
37    fn from(writer: crate::W<GPIO_CFG_SPEC>) -> Self {
38        W(writer)
39    }
40}
41#[doc = "Field `GPIOD0` reader - GPIO Data"]
42pub type GPIOD0_R = crate::BitReader<bool>;
43#[doc = "Field `GPIOD0` writer - GPIO Data"]
44pub type GPIOD0_W<'a, const O: u8> = crate::BitWriter<'a, u32, GPIO_CFG_SPEC, bool, O>;
45#[doc = "Field `GPIOD1` reader - GPIO Data"]
46pub type GPIOD1_R = crate::BitReader<bool>;
47#[doc = "Field `GPIOD1` writer - GPIO Data"]
48pub type GPIOD1_W<'a, const O: u8> = crate::BitWriter<'a, u32, GPIO_CFG_SPEC, bool, O>;
49#[doc = "Field `GPIOD2` reader - GPIO Data"]
50pub type GPIOD2_R = crate::BitReader<bool>;
51#[doc = "Field `GPIOD2` writer - GPIO Data"]
52pub type GPIOD2_W<'a, const O: u8> = crate::BitWriter<'a, u32, GPIO_CFG_SPEC, bool, O>;
53#[doc = "Field `GPOD3` reader - GPO Data"]
54pub type GPOD3_R = crate::BitReader<bool>;
55#[doc = "Field `GPOD3` writer - GPO Data"]
56pub type GPOD3_W<'a, const O: u8> = crate::BitWriter<'a, u32, GPIO_CFG_SPEC, bool, O>;
57#[doc = "Field `GPOD4` reader - GPO Data"]
58pub type GPOD4_R = crate::BitReader<bool>;
59#[doc = "Field `GPOD4` writer - GPO Data"]
60pub type GPOD4_W<'a, const O: u8> = crate::BitWriter<'a, u32, GPIO_CFG_SPEC, bool, O>;
61#[doc = "Field `GPDIR0` reader - GPIO Direction"]
62pub type GPDIR0_R = crate::BitReader<bool>;
63#[doc = "Field `GPDIR0` writer - GPIO Direction"]
64pub type GPDIR0_W<'a, const O: u8> = crate::BitWriter<'a, u32, GPIO_CFG_SPEC, bool, O>;
65#[doc = "Field `GPDIR1` reader - GPIO Direction"]
66pub type GPDIR1_R = crate::BitReader<bool>;
67#[doc = "Field `GPDIR1` writer - GPIO Direction"]
68pub type GPDIR1_W<'a, const O: u8> = crate::BitWriter<'a, u32, GPIO_CFG_SPEC, bool, O>;
69#[doc = "Field `GPDIR2` reader - GPIO Direction"]
70pub type GPDIR2_R = crate::BitReader<bool>;
71#[doc = "Field `GPDIR2` writer - GPIO Direction"]
72pub type GPDIR2_W<'a, const O: u8> = crate::BitWriter<'a, u32, GPIO_CFG_SPEC, bool, O>;
73#[doc = "Field `GPIOBUF0` reader - GPIO Buffer Type"]
74pub type GPIOBUF0_R = crate::BitReader<bool>;
75#[doc = "Field `GPIOBUF0` writer - GPIO Buffer Type"]
76pub type GPIOBUF0_W<'a, const O: u8> = crate::BitWriter<'a, u32, GPIO_CFG_SPEC, bool, O>;
77#[doc = "Field `GPIOBUF1` reader - GPIO Buffer Type"]
78pub type GPIOBUF1_R = crate::BitReader<bool>;
79#[doc = "Field `GPIOBUF1` writer - GPIO Buffer Type"]
80pub type GPIOBUF1_W<'a, const O: u8> = crate::BitWriter<'a, u32, GPIO_CFG_SPEC, bool, O>;
81#[doc = "Field `GPIOBUF2` reader - GPIO Buffer Type"]
82pub type GPIOBUF2_R = crate::BitReader<bool>;
83#[doc = "Field `GPIOBUF2` writer - GPIO Buffer Type"]
84pub type GPIOBUF2_W<'a, const O: u8> = crate::BitWriter<'a, u32, GPIO_CFG_SPEC, bool, O>;
85#[doc = "Field `EEPR_EN` reader - EEPROM Enable"]
86pub type EEPR_EN_R = crate::FieldReader<u8, EEPR_EN_A>;
87#[doc = "EEPROM Enable\n\nValue on reset: 0"]
88#[derive(Clone, Copy, Debug, PartialEq, Eq)]
89#[repr(u8)]
90pub enum EEPR_EN_A {
91    #[doc = "0: `0`"]
92    EEDIO_EECLK = 0,
93    #[doc = "1: `1`"]
94    GPO3_GPO4 = 1,
95    #[doc = "3: `11`"]
96    GPO3_RX_DV = 3,
97    #[doc = "5: `101`"]
98    TX_EN_GPO4 = 5,
99    #[doc = "6: `110`"]
100    TX_EN_RX_DV = 6,
101    #[doc = "7: `111`"]
102    TX_CLK_RX_CLK = 7,
103}
104impl From<EEPR_EN_A> for u8 {
105    #[inline(always)]
106    fn from(variant: EEPR_EN_A) -> Self {
107        variant as _
108    }
109}
110impl EEPR_EN_R {
111    #[doc = "Get enumerated values variant"]
112    #[inline(always)]
113    pub fn variant(&self) -> Option<EEPR_EN_A> {
114        match self.bits {
115            0 => Some(EEPR_EN_A::EEDIO_EECLK),
116            1 => Some(EEPR_EN_A::GPO3_GPO4),
117            3 => Some(EEPR_EN_A::GPO3_RX_DV),
118            5 => Some(EEPR_EN_A::TX_EN_GPO4),
119            6 => Some(EEPR_EN_A::TX_EN_RX_DV),
120            7 => Some(EEPR_EN_A::TX_CLK_RX_CLK),
121            _ => None,
122        }
123    }
124    #[doc = "Checks if the value of the field is `EEDIO_EECLK`"]
125    #[inline(always)]
126    pub fn is_eedio_eeclk(&self) -> bool {
127        *self == EEPR_EN_A::EEDIO_EECLK
128    }
129    #[doc = "Checks if the value of the field is `GPO3_GPO4`"]
130    #[inline(always)]
131    pub fn is_gpo3_gpo4(&self) -> bool {
132        *self == EEPR_EN_A::GPO3_GPO4
133    }
134    #[doc = "Checks if the value of the field is `GPO3_RX_DV`"]
135    #[inline(always)]
136    pub fn is_gpo3_rx_dv(&self) -> bool {
137        *self == EEPR_EN_A::GPO3_RX_DV
138    }
139    #[doc = "Checks if the value of the field is `TX_EN_GPO4`"]
140    #[inline(always)]
141    pub fn is_tx_en_gpo4(&self) -> bool {
142        *self == EEPR_EN_A::TX_EN_GPO4
143    }
144    #[doc = "Checks if the value of the field is `TX_EN_RX_DV`"]
145    #[inline(always)]
146    pub fn is_tx_en_rx_dv(&self) -> bool {
147        *self == EEPR_EN_A::TX_EN_RX_DV
148    }
149    #[doc = "Checks if the value of the field is `TX_CLK_RX_CLK`"]
150    #[inline(always)]
151    pub fn is_tx_clk_rx_clk(&self) -> bool {
152        *self == EEPR_EN_A::TX_CLK_RX_CLK
153    }
154}
155#[doc = "Field `EEPR_EN` writer - EEPROM Enable"]
156pub type EEPR_EN_W<'a, const O: u8> =
157    crate::FieldWriter<'a, u32, GPIO_CFG_SPEC, u8, EEPR_EN_A, 3, O>;
158impl<'a, const O: u8> EEPR_EN_W<'a, O> {
159    #[doc = "`0`"]
160    #[inline(always)]
161    pub fn eedio_eeclk(self) -> &'a mut W {
162        self.variant(EEPR_EN_A::EEDIO_EECLK)
163    }
164    #[doc = "`1`"]
165    #[inline(always)]
166    pub fn gpo3_gpo4(self) -> &'a mut W {
167        self.variant(EEPR_EN_A::GPO3_GPO4)
168    }
169    #[doc = "`11`"]
170    #[inline(always)]
171    pub fn gpo3_rx_dv(self) -> &'a mut W {
172        self.variant(EEPR_EN_A::GPO3_RX_DV)
173    }
174    #[doc = "`101`"]
175    #[inline(always)]
176    pub fn tx_en_gpo4(self) -> &'a mut W {
177        self.variant(EEPR_EN_A::TX_EN_GPO4)
178    }
179    #[doc = "`110`"]
180    #[inline(always)]
181    pub fn tx_en_rx_dv(self) -> &'a mut W {
182        self.variant(EEPR_EN_A::TX_EN_RX_DV)
183    }
184    #[doc = "`111`"]
185    #[inline(always)]
186    pub fn tx_clk_rx_clk(self) -> &'a mut W {
187        self.variant(EEPR_EN_A::TX_CLK_RX_CLK)
188    }
189}
190#[doc = "Field `GPIO0_INT_POL` reader - GPIO Interrupt Polarity"]
191pub type GPIO0_INT_POL_R = crate::BitReader<bool>;
192#[doc = "Field `GPIO0_INT_POL` writer - GPIO Interrupt Polarity"]
193pub type GPIO0_INT_POL_W<'a, const O: u8> = crate::BitWriter<'a, u32, GPIO_CFG_SPEC, bool, O>;
194#[doc = "Field `GPIO1_INT_POL` reader - GPIO Interrupt Polarity"]
195pub type GPIO1_INT_POL_R = crate::BitReader<bool>;
196#[doc = "Field `GPIO1_INT_POL` writer - GPIO Interrupt Polarity"]
197pub type GPIO1_INT_POL_W<'a, const O: u8> = crate::BitWriter<'a, u32, GPIO_CFG_SPEC, bool, O>;
198#[doc = "Field `GPIO2_INT_POL` reader - GPIO Interrupt Polarity"]
199pub type GPIO2_INT_POL_R = crate::BitReader<bool>;
200#[doc = "Field `GPIO2_INT_POL` writer - GPIO Interrupt Polarity"]
201pub type GPIO2_INT_POL_W<'a, const O: u8> = crate::BitWriter<'a, u32, GPIO_CFG_SPEC, bool, O>;
202#[doc = "Field `LED0_EN` reader - Led Enable"]
203pub type LED0_EN_R = crate::BitReader<bool>;
204#[doc = "Field `LED0_EN` writer - Led Enable"]
205pub type LED0_EN_W<'a, const O: u8> = crate::BitWriter<'a, u32, GPIO_CFG_SPEC, bool, O>;
206#[doc = "Field `LED1_EN` reader - Led Enable"]
207pub type LED1_EN_R = crate::BitReader<bool>;
208#[doc = "Field `LED1_EN` writer - Led Enable"]
209pub type LED1_EN_W<'a, const O: u8> = crate::BitWriter<'a, u32, GPIO_CFG_SPEC, bool, O>;
210#[doc = "Field `LED2_EN` reader - Led Enable"]
211pub type LED2_EN_R = crate::BitReader<bool>;
212#[doc = "Field `LED2_EN` writer - Led Enable"]
213pub type LED2_EN_W<'a, const O: u8> = crate::BitWriter<'a, u32, GPIO_CFG_SPEC, bool, O>;
214impl R {
215    #[doc = "Bit 0 - GPIO Data"]
216    #[inline(always)]
217    pub fn gpiod0(&self) -> GPIOD0_R {
218        GPIOD0_R::new((self.bits & 1) != 0)
219    }
220    #[doc = "Bit 1 - GPIO Data"]
221    #[inline(always)]
222    pub fn gpiod1(&self) -> GPIOD1_R {
223        GPIOD1_R::new(((self.bits >> 1) & 1) != 0)
224    }
225    #[doc = "Bit 2 - GPIO Data"]
226    #[inline(always)]
227    pub fn gpiod2(&self) -> GPIOD2_R {
228        GPIOD2_R::new(((self.bits >> 2) & 1) != 0)
229    }
230    #[doc = "Bit 3 - GPO Data"]
231    #[inline(always)]
232    pub fn gpod3(&self) -> GPOD3_R {
233        GPOD3_R::new(((self.bits >> 3) & 1) != 0)
234    }
235    #[doc = "Bit 4 - GPO Data"]
236    #[inline(always)]
237    pub fn gpod4(&self) -> GPOD4_R {
238        GPOD4_R::new(((self.bits >> 4) & 1) != 0)
239    }
240    #[doc = "Bit 8 - GPIO Direction"]
241    #[inline(always)]
242    pub fn gpdir0(&self) -> GPDIR0_R {
243        GPDIR0_R::new(((self.bits >> 8) & 1) != 0)
244    }
245    #[doc = "Bit 9 - GPIO Direction"]
246    #[inline(always)]
247    pub fn gpdir1(&self) -> GPDIR1_R {
248        GPDIR1_R::new(((self.bits >> 9) & 1) != 0)
249    }
250    #[doc = "Bit 10 - GPIO Direction"]
251    #[inline(always)]
252    pub fn gpdir2(&self) -> GPDIR2_R {
253        GPDIR2_R::new(((self.bits >> 10) & 1) != 0)
254    }
255    #[doc = "Bit 16 - GPIO Buffer Type"]
256    #[inline(always)]
257    pub fn gpiobuf0(&self) -> GPIOBUF0_R {
258        GPIOBUF0_R::new(((self.bits >> 16) & 1) != 0)
259    }
260    #[doc = "Bit 17 - GPIO Buffer Type"]
261    #[inline(always)]
262    pub fn gpiobuf1(&self) -> GPIOBUF1_R {
263        GPIOBUF1_R::new(((self.bits >> 17) & 1) != 0)
264    }
265    #[doc = "Bit 18 - GPIO Buffer Type"]
266    #[inline(always)]
267    pub fn gpiobuf2(&self) -> GPIOBUF2_R {
268        GPIOBUF2_R::new(((self.bits >> 18) & 1) != 0)
269    }
270    #[doc = "Bits 20:22 - EEPROM Enable"]
271    #[inline(always)]
272    pub fn eepr_en(&self) -> EEPR_EN_R {
273        EEPR_EN_R::new(((self.bits >> 20) & 7) as u8)
274    }
275    #[doc = "Bit 24 - GPIO Interrupt Polarity"]
276    #[inline(always)]
277    pub fn gpio0_int_pol(&self) -> GPIO0_INT_POL_R {
278        GPIO0_INT_POL_R::new(((self.bits >> 24) & 1) != 0)
279    }
280    #[doc = "Bit 25 - GPIO Interrupt Polarity"]
281    #[inline(always)]
282    pub fn gpio1_int_pol(&self) -> GPIO1_INT_POL_R {
283        GPIO1_INT_POL_R::new(((self.bits >> 25) & 1) != 0)
284    }
285    #[doc = "Bit 26 - GPIO Interrupt Polarity"]
286    #[inline(always)]
287    pub fn gpio2_int_pol(&self) -> GPIO2_INT_POL_R {
288        GPIO2_INT_POL_R::new(((self.bits >> 26) & 1) != 0)
289    }
290    #[doc = "Bit 28 - Led Enable"]
291    #[inline(always)]
292    pub fn led0_en(&self) -> LED0_EN_R {
293        LED0_EN_R::new(((self.bits >> 28) & 1) != 0)
294    }
295    #[doc = "Bit 29 - Led Enable"]
296    #[inline(always)]
297    pub fn led1_en(&self) -> LED1_EN_R {
298        LED1_EN_R::new(((self.bits >> 29) & 1) != 0)
299    }
300    #[doc = "Bit 30 - Led Enable"]
301    #[inline(always)]
302    pub fn led2_en(&self) -> LED2_EN_R {
303        LED2_EN_R::new(((self.bits >> 30) & 1) != 0)
304    }
305}
306impl W {
307    #[doc = "Bit 0 - GPIO Data"]
308    #[inline(always)]
309    pub fn gpiod0(&mut self) -> GPIOD0_W<0> {
310        GPIOD0_W::new(self)
311    }
312    #[doc = "Bit 1 - GPIO Data"]
313    #[inline(always)]
314    pub fn gpiod1(&mut self) -> GPIOD1_W<1> {
315        GPIOD1_W::new(self)
316    }
317    #[doc = "Bit 2 - GPIO Data"]
318    #[inline(always)]
319    pub fn gpiod2(&mut self) -> GPIOD2_W<2> {
320        GPIOD2_W::new(self)
321    }
322    #[doc = "Bit 3 - GPO Data"]
323    #[inline(always)]
324    pub fn gpod3(&mut self) -> GPOD3_W<3> {
325        GPOD3_W::new(self)
326    }
327    #[doc = "Bit 4 - GPO Data"]
328    #[inline(always)]
329    pub fn gpod4(&mut self) -> GPOD4_W<4> {
330        GPOD4_W::new(self)
331    }
332    #[doc = "Bit 8 - GPIO Direction"]
333    #[inline(always)]
334    pub fn gpdir0(&mut self) -> GPDIR0_W<8> {
335        GPDIR0_W::new(self)
336    }
337    #[doc = "Bit 9 - GPIO Direction"]
338    #[inline(always)]
339    pub fn gpdir1(&mut self) -> GPDIR1_W<9> {
340        GPDIR1_W::new(self)
341    }
342    #[doc = "Bit 10 - GPIO Direction"]
343    #[inline(always)]
344    pub fn gpdir2(&mut self) -> GPDIR2_W<10> {
345        GPDIR2_W::new(self)
346    }
347    #[doc = "Bit 16 - GPIO Buffer Type"]
348    #[inline(always)]
349    pub fn gpiobuf0(&mut self) -> GPIOBUF0_W<16> {
350        GPIOBUF0_W::new(self)
351    }
352    #[doc = "Bit 17 - GPIO Buffer Type"]
353    #[inline(always)]
354    pub fn gpiobuf1(&mut self) -> GPIOBUF1_W<17> {
355        GPIOBUF1_W::new(self)
356    }
357    #[doc = "Bit 18 - GPIO Buffer Type"]
358    #[inline(always)]
359    pub fn gpiobuf2(&mut self) -> GPIOBUF2_W<18> {
360        GPIOBUF2_W::new(self)
361    }
362    #[doc = "Bits 20:22 - EEPROM Enable"]
363    #[inline(always)]
364    pub fn eepr_en(&mut self) -> EEPR_EN_W<20> {
365        EEPR_EN_W::new(self)
366    }
367    #[doc = "Bit 24 - GPIO Interrupt Polarity"]
368    #[inline(always)]
369    pub fn gpio0_int_pol(&mut self) -> GPIO0_INT_POL_W<24> {
370        GPIO0_INT_POL_W::new(self)
371    }
372    #[doc = "Bit 25 - GPIO Interrupt Polarity"]
373    #[inline(always)]
374    pub fn gpio1_int_pol(&mut self) -> GPIO1_INT_POL_W<25> {
375        GPIO1_INT_POL_W::new(self)
376    }
377    #[doc = "Bit 26 - GPIO Interrupt Polarity"]
378    #[inline(always)]
379    pub fn gpio2_int_pol(&mut self) -> GPIO2_INT_POL_W<26> {
380        GPIO2_INT_POL_W::new(self)
381    }
382    #[doc = "Bit 28 - Led Enable"]
383    #[inline(always)]
384    pub fn led0_en(&mut self) -> LED0_EN_W<28> {
385        LED0_EN_W::new(self)
386    }
387    #[doc = "Bit 29 - Led Enable"]
388    #[inline(always)]
389    pub fn led1_en(&mut self) -> LED1_EN_W<29> {
390        LED1_EN_W::new(self)
391    }
392    #[doc = "Bit 30 - Led Enable"]
393    #[inline(always)]
394    pub fn led2_en(&mut self) -> LED2_EN_W<30> {
395        LED2_EN_W::new(self)
396    }
397    #[doc = "Writes raw bits to the register."]
398    #[inline(always)]
399    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
400        self.0.bits(bits);
401        self
402    }
403}
404#[doc = "General Purpose IO Configuration\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 [gpio_cfg](index.html) module"]
405pub struct GPIO_CFG_SPEC;
406impl crate::RegisterSpec for GPIO_CFG_SPEC {
407    type Ux = u32;
408}
409#[doc = "`read()` method returns [gpio_cfg::R](R) reader structure"]
410impl crate::Readable for GPIO_CFG_SPEC {
411    type Reader = R;
412}
413#[doc = "`write(|w| ..)` method takes [gpio_cfg::W](W) writer structure"]
414impl crate::Writable for GPIO_CFG_SPEC {
415    type Writer = W;
416}
417#[doc = "`reset()` method sets GPIO_CFG to value 0"]
418impl crate::Resettable for GPIO_CFG_SPEC {
419    #[inline(always)]
420    fn reset_value() -> Self::Ux {
421        0
422    }
423}