d1_pac/emac/
emac_basic_ctl0.rs1#[doc = "Register `emac_basic_ctl0` reader"]
2pub type R = crate::R<EMAC_BASIC_CTL0_SPEC>;
3#[doc = "Register `emac_basic_ctl0` writer"]
4pub type W = crate::W<EMAC_BASIC_CTL0_SPEC>;
5#[doc = "Field `duplex` reader - EMAC Transfer Mode"]
6pub type DUPLEX_R = crate::BitReader<DUPLEX_A>;
7#[doc = "EMAC Transfer Mode\n\nValue on reset: 0"]
8#[derive(Clone, Copy, Debug, PartialEq, Eq)]
9pub enum DUPLEX_A {
10 #[doc = "0: `0`"]
11 HALF_DUPLEX = 0,
12 #[doc = "1: `1`"]
13 FULL_DUPLEX = 1,
14}
15impl From<DUPLEX_A> for bool {
16 #[inline(always)]
17 fn from(variant: DUPLEX_A) -> Self {
18 variant as u8 != 0
19 }
20}
21impl DUPLEX_R {
22 #[doc = "Get enumerated values variant"]
23 #[inline(always)]
24 pub const fn variant(&self) -> DUPLEX_A {
25 match self.bits {
26 false => DUPLEX_A::HALF_DUPLEX,
27 true => DUPLEX_A::FULL_DUPLEX,
28 }
29 }
30 #[doc = "`0`"]
31 #[inline(always)]
32 pub fn is_half_duplex(&self) -> bool {
33 *self == DUPLEX_A::HALF_DUPLEX
34 }
35 #[doc = "`1`"]
36 #[inline(always)]
37 pub fn is_full_duplex(&self) -> bool {
38 *self == DUPLEX_A::FULL_DUPLEX
39 }
40}
41#[doc = "Field `duplex` writer - EMAC Transfer Mode"]
42pub type DUPLEX_W<'a, REG> = crate::BitWriter<'a, REG, DUPLEX_A>;
43impl<'a, REG> DUPLEX_W<'a, REG>
44where
45 REG: crate::Writable + crate::RegisterSpec,
46{
47 #[doc = "`0`"]
48 #[inline(always)]
49 pub fn half_duplex(self) -> &'a mut crate::W<REG> {
50 self.variant(DUPLEX_A::HALF_DUPLEX)
51 }
52 #[doc = "`1`"]
53 #[inline(always)]
54 pub fn full_duplex(self) -> &'a mut crate::W<REG> {
55 self.variant(DUPLEX_A::FULL_DUPLEX)
56 }
57}
58#[doc = "Field `loopback` reader - EMAC Loopback Mode For Test"]
59pub type LOOPBACK_R = crate::BitReader<LOOPBACK_A>;
60#[doc = "EMAC Loopback Mode For Test\n\nValue on reset: 0"]
61#[derive(Clone, Copy, Debug, PartialEq, Eq)]
62pub enum LOOPBACK_A {
63 #[doc = "0: `0`"]
64 DISABLE = 0,
65 #[doc = "1: `1`"]
66 ENABLE = 1,
67}
68impl From<LOOPBACK_A> for bool {
69 #[inline(always)]
70 fn from(variant: LOOPBACK_A) -> Self {
71 variant as u8 != 0
72 }
73}
74impl LOOPBACK_R {
75 #[doc = "Get enumerated values variant"]
76 #[inline(always)]
77 pub const fn variant(&self) -> LOOPBACK_A {
78 match self.bits {
79 false => LOOPBACK_A::DISABLE,
80 true => LOOPBACK_A::ENABLE,
81 }
82 }
83 #[doc = "`0`"]
84 #[inline(always)]
85 pub fn is_disable(&self) -> bool {
86 *self == LOOPBACK_A::DISABLE
87 }
88 #[doc = "`1`"]
89 #[inline(always)]
90 pub fn is_enable(&self) -> bool {
91 *self == LOOPBACK_A::ENABLE
92 }
93}
94#[doc = "Field `loopback` writer - EMAC Loopback Mode For Test"]
95pub type LOOPBACK_W<'a, REG> = crate::BitWriter<'a, REG, LOOPBACK_A>;
96impl<'a, REG> LOOPBACK_W<'a, REG>
97where
98 REG: crate::Writable + crate::RegisterSpec,
99{
100 #[doc = "`0`"]
101 #[inline(always)]
102 pub fn disable(self) -> &'a mut crate::W<REG> {
103 self.variant(LOOPBACK_A::DISABLE)
104 }
105 #[doc = "`1`"]
106 #[inline(always)]
107 pub fn enable(self) -> &'a mut crate::W<REG> {
108 self.variant(LOOPBACK_A::ENABLE)
109 }
110}
111#[doc = "Field `speed` reader - EMAC Working Speed"]
112pub type SPEED_R = crate::FieldReader<SPEED_A>;
113#[doc = "EMAC Working Speed\n\nValue on reset: 0"]
114#[derive(Clone, Copy, Debug, PartialEq, Eq)]
115#[repr(u8)]
116pub enum SPEED_A {
117 #[doc = "0: `0`"]
118 S1000 = 0,
119 #[doc = "2: `10`"]
120 S10 = 2,
121 #[doc = "3: `11`"]
122 S100 = 3,
123}
124impl From<SPEED_A> for u8 {
125 #[inline(always)]
126 fn from(variant: SPEED_A) -> Self {
127 variant as _
128 }
129}
130impl crate::FieldSpec for SPEED_A {
131 type Ux = u8;
132}
133impl SPEED_R {
134 #[doc = "Get enumerated values variant"]
135 #[inline(always)]
136 pub const fn variant(&self) -> SPEED_A {
137 match self.bits {
138 0 => SPEED_A::S1000,
139 2 => SPEED_A::S10,
140 3 => SPEED_A::S100,
141 _ => unreachable!(),
142 }
143 }
144 #[doc = "`0`"]
145 #[inline(always)]
146 pub fn is_s1000(&self) -> bool {
147 *self == SPEED_A::S1000
148 }
149 #[doc = "`10`"]
150 #[inline(always)]
151 pub fn is_s10(&self) -> bool {
152 *self == SPEED_A::S10
153 }
154 #[doc = "`11`"]
155 #[inline(always)]
156 pub fn is_s100(&self) -> bool {
157 *self == SPEED_A::S100
158 }
159}
160#[doc = "Field `speed` writer - EMAC Working Speed"]
161pub type SPEED_W<'a, REG> = crate::FieldWriter<'a, REG, 2, SPEED_A>;
162impl<'a, REG> SPEED_W<'a, REG>
163where
164 REG: crate::Writable + crate::RegisterSpec,
165 REG::Ux: From<u8>,
166{
167 #[doc = "`0`"]
168 #[inline(always)]
169 pub fn s1000(self) -> &'a mut crate::W<REG> {
170 self.variant(SPEED_A::S1000)
171 }
172 #[doc = "`10`"]
173 #[inline(always)]
174 pub fn s10(self) -> &'a mut crate::W<REG> {
175 self.variant(SPEED_A::S10)
176 }
177 #[doc = "`11`"]
178 #[inline(always)]
179 pub fn s100(self) -> &'a mut crate::W<REG> {
180 self.variant(SPEED_A::S100)
181 }
182}
183impl R {
184 #[doc = "Bit 0 - EMAC Transfer Mode"]
185 #[inline(always)]
186 pub fn duplex(&self) -> DUPLEX_R {
187 DUPLEX_R::new((self.bits & 1) != 0)
188 }
189 #[doc = "Bit 1 - EMAC Loopback Mode For Test"]
190 #[inline(always)]
191 pub fn loopback(&self) -> LOOPBACK_R {
192 LOOPBACK_R::new(((self.bits >> 1) & 1) != 0)
193 }
194 #[doc = "Bits 2:3 - EMAC Working Speed"]
195 #[inline(always)]
196 pub fn speed(&self) -> SPEED_R {
197 SPEED_R::new(((self.bits >> 2) & 3) as u8)
198 }
199}
200impl W {
201 #[doc = "Bit 0 - EMAC Transfer Mode"]
202 #[inline(always)]
203 #[must_use]
204 pub fn duplex(&mut self) -> DUPLEX_W<EMAC_BASIC_CTL0_SPEC> {
205 DUPLEX_W::new(self, 0)
206 }
207 #[doc = "Bit 1 - EMAC Loopback Mode For Test"]
208 #[inline(always)]
209 #[must_use]
210 pub fn loopback(&mut self) -> LOOPBACK_W<EMAC_BASIC_CTL0_SPEC> {
211 LOOPBACK_W::new(self, 1)
212 }
213 #[doc = "Bits 2:3 - EMAC Working Speed"]
214 #[inline(always)]
215 #[must_use]
216 pub fn speed(&mut self) -> SPEED_W<EMAC_BASIC_CTL0_SPEC> {
217 SPEED_W::new(self, 2)
218 }
219 #[doc = r" Writes raw bits to the register."]
220 #[doc = r""]
221 #[doc = r" # Safety"]
222 #[doc = r""]
223 #[doc = r" Passing incorrect value can cause undefined behaviour. See reference manual"]
224 #[inline(always)]
225 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
226 self.bits = bits;
227 self
228 }
229}
230#[doc = "EMAC Basic Control Register0\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`emac_basic_ctl0::R`](R). You can [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero) this register using [`emac_basic_ctl0::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
231pub struct EMAC_BASIC_CTL0_SPEC;
232impl crate::RegisterSpec for EMAC_BASIC_CTL0_SPEC {
233 type Ux = u32;
234}
235#[doc = "`read()` method returns [`emac_basic_ctl0::R`](R) reader structure"]
236impl crate::Readable for EMAC_BASIC_CTL0_SPEC {}
237#[doc = "`write(|w| ..)` method takes [`emac_basic_ctl0::W`](W) writer structure"]
238impl crate::Writable for EMAC_BASIC_CTL0_SPEC {
239 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
240 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
241}
242#[doc = "`reset()` method sets emac_basic_ctl0 to value 0"]
243impl crate::Resettable for EMAC_BASIC_CTL0_SPEC {
244 const RESET_VALUE: Self::Ux = 0;
245}