stm32f3_staging/stm32f373/gpioa/
moder.rs

1///Register `MODER` reader
2pub type R = crate::R<MODERrs>;
3///Register `MODER` writer
4pub type W = crate::W<MODERrs>;
5/**Port x configuration pin %s
6
7Value on reset: 0*/
8#[cfg_attr(feature = "defmt", derive(defmt::Format))]
9#[derive(Clone, Copy, Debug, PartialEq, Eq)]
10#[repr(u8)]
11pub enum MODER0 {
12    ///0: Input mode (reset state)
13    Input = 0,
14    ///1: General purpose output mode
15    Output = 1,
16    ///2: Alternate function mode
17    Alternate = 2,
18    ///3: Analog mode
19    Analog = 3,
20}
21impl From<MODER0> for u8 {
22    #[inline(always)]
23    fn from(variant: MODER0) -> Self {
24        variant as _
25    }
26}
27impl crate::FieldSpec for MODER0 {
28    type Ux = u8;
29}
30impl crate::IsEnum for MODER0 {}
31///Field `MODER(0-15)` reader - Port x configuration pin %s
32pub type MODER_R = crate::FieldReader<MODER0>;
33impl MODER_R {
34    ///Get enumerated values variant
35    #[inline(always)]
36    pub const fn variant(&self) -> MODER0 {
37        match self.bits {
38            0 => MODER0::Input,
39            1 => MODER0::Output,
40            2 => MODER0::Alternate,
41            3 => MODER0::Analog,
42            _ => unreachable!(),
43        }
44    }
45    ///Input mode (reset state)
46    #[inline(always)]
47    pub fn is_input(&self) -> bool {
48        *self == MODER0::Input
49    }
50    ///General purpose output mode
51    #[inline(always)]
52    pub fn is_output(&self) -> bool {
53        *self == MODER0::Output
54    }
55    ///Alternate function mode
56    #[inline(always)]
57    pub fn is_alternate(&self) -> bool {
58        *self == MODER0::Alternate
59    }
60    ///Analog mode
61    #[inline(always)]
62    pub fn is_analog(&self) -> bool {
63        *self == MODER0::Analog
64    }
65}
66///Field `MODER(0-15)` writer - Port x configuration pin %s
67pub type MODER_W<'a, REG> = crate::FieldWriter<'a, REG, 2, MODER0, crate::Safe>;
68impl<'a, REG> MODER_W<'a, REG>
69where
70    REG: crate::Writable + crate::RegisterSpec,
71    REG::Ux: From<u8>,
72{
73    ///Input mode (reset state)
74    #[inline(always)]
75    pub fn input(self) -> &'a mut crate::W<REG> {
76        self.variant(MODER0::Input)
77    }
78    ///General purpose output mode
79    #[inline(always)]
80    pub fn output(self) -> &'a mut crate::W<REG> {
81        self.variant(MODER0::Output)
82    }
83    ///Alternate function mode
84    #[inline(always)]
85    pub fn alternate(self) -> &'a mut crate::W<REG> {
86        self.variant(MODER0::Alternate)
87    }
88    ///Analog mode
89    #[inline(always)]
90    pub fn analog(self) -> &'a mut crate::W<REG> {
91        self.variant(MODER0::Analog)
92    }
93}
94impl R {
95    ///Port x configuration pin (0-15)
96    ///
97    ///<div class="warning">`n` is number of field in register. `n == 0` corresponds to `MODER0` field.</div>
98    #[inline(always)]
99    pub fn moder(&self, n: u8) -> MODER_R {
100        #[allow(clippy::no_effect)] [(); 16][n as usize];
101        MODER_R::new(((self.bits >> (n * 2)) & 3) as u8)
102    }
103    ///Iterator for array of:
104    ///Port x configuration pin (0-15)
105    #[inline(always)]
106    pub fn moder_iter(&self) -> impl Iterator<Item = MODER_R> + '_ {
107        (0..16).map(move |n| MODER_R::new(((self.bits >> (n * 2)) & 3) as u8))
108    }
109    ///Bits 0:1 - Port x configuration pin 0
110    #[inline(always)]
111    pub fn moder0(&self) -> MODER_R {
112        MODER_R::new((self.bits & 3) as u8)
113    }
114    ///Bits 2:3 - Port x configuration pin 1
115    #[inline(always)]
116    pub fn moder1(&self) -> MODER_R {
117        MODER_R::new(((self.bits >> 2) & 3) as u8)
118    }
119    ///Bits 4:5 - Port x configuration pin 2
120    #[inline(always)]
121    pub fn moder2(&self) -> MODER_R {
122        MODER_R::new(((self.bits >> 4) & 3) as u8)
123    }
124    ///Bits 6:7 - Port x configuration pin 3
125    #[inline(always)]
126    pub fn moder3(&self) -> MODER_R {
127        MODER_R::new(((self.bits >> 6) & 3) as u8)
128    }
129    ///Bits 8:9 - Port x configuration pin 4
130    #[inline(always)]
131    pub fn moder4(&self) -> MODER_R {
132        MODER_R::new(((self.bits >> 8) & 3) as u8)
133    }
134    ///Bits 10:11 - Port x configuration pin 5
135    #[inline(always)]
136    pub fn moder5(&self) -> MODER_R {
137        MODER_R::new(((self.bits >> 10) & 3) as u8)
138    }
139    ///Bits 12:13 - Port x configuration pin 6
140    #[inline(always)]
141    pub fn moder6(&self) -> MODER_R {
142        MODER_R::new(((self.bits >> 12) & 3) as u8)
143    }
144    ///Bits 14:15 - Port x configuration pin 7
145    #[inline(always)]
146    pub fn moder7(&self) -> MODER_R {
147        MODER_R::new(((self.bits >> 14) & 3) as u8)
148    }
149    ///Bits 16:17 - Port x configuration pin 8
150    #[inline(always)]
151    pub fn moder8(&self) -> MODER_R {
152        MODER_R::new(((self.bits >> 16) & 3) as u8)
153    }
154    ///Bits 18:19 - Port x configuration pin 9
155    #[inline(always)]
156    pub fn moder9(&self) -> MODER_R {
157        MODER_R::new(((self.bits >> 18) & 3) as u8)
158    }
159    ///Bits 20:21 - Port x configuration pin 10
160    #[inline(always)]
161    pub fn moder10(&self) -> MODER_R {
162        MODER_R::new(((self.bits >> 20) & 3) as u8)
163    }
164    ///Bits 22:23 - Port x configuration pin 11
165    #[inline(always)]
166    pub fn moder11(&self) -> MODER_R {
167        MODER_R::new(((self.bits >> 22) & 3) as u8)
168    }
169    ///Bits 24:25 - Port x configuration pin 12
170    #[inline(always)]
171    pub fn moder12(&self) -> MODER_R {
172        MODER_R::new(((self.bits >> 24) & 3) as u8)
173    }
174    ///Bits 26:27 - Port x configuration pin 13
175    #[inline(always)]
176    pub fn moder13(&self) -> MODER_R {
177        MODER_R::new(((self.bits >> 26) & 3) as u8)
178    }
179    ///Bits 28:29 - Port x configuration pin 14
180    #[inline(always)]
181    pub fn moder14(&self) -> MODER_R {
182        MODER_R::new(((self.bits >> 28) & 3) as u8)
183    }
184    ///Bits 30:31 - Port x configuration pin 15
185    #[inline(always)]
186    pub fn moder15(&self) -> MODER_R {
187        MODER_R::new(((self.bits >> 30) & 3) as u8)
188    }
189}
190impl core::fmt::Debug for R {
191    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
192        f.debug_struct("MODER")
193            .field("moder0", &self.moder0())
194            .field("moder1", &self.moder1())
195            .field("moder2", &self.moder2())
196            .field("moder3", &self.moder3())
197            .field("moder4", &self.moder4())
198            .field("moder5", &self.moder5())
199            .field("moder6", &self.moder6())
200            .field("moder7", &self.moder7())
201            .field("moder8", &self.moder8())
202            .field("moder9", &self.moder9())
203            .field("moder10", &self.moder10())
204            .field("moder11", &self.moder11())
205            .field("moder12", &self.moder12())
206            .field("moder13", &self.moder13())
207            .field("moder14", &self.moder14())
208            .field("moder15", &self.moder15())
209            .finish()
210    }
211}
212impl W {
213    ///Port x configuration pin (0-15)
214    ///
215    ///<div class="warning">`n` is number of field in register. `n == 0` corresponds to `MODER0` field.</div>
216    #[inline(always)]
217    pub fn moder(&mut self, n: u8) -> MODER_W<MODERrs> {
218        #[allow(clippy::no_effect)] [(); 16][n as usize];
219        MODER_W::new(self, n * 2)
220    }
221    ///Bits 0:1 - Port x configuration pin 0
222    #[inline(always)]
223    pub fn moder0(&mut self) -> MODER_W<MODERrs> {
224        MODER_W::new(self, 0)
225    }
226    ///Bits 2:3 - Port x configuration pin 1
227    #[inline(always)]
228    pub fn moder1(&mut self) -> MODER_W<MODERrs> {
229        MODER_W::new(self, 2)
230    }
231    ///Bits 4:5 - Port x configuration pin 2
232    #[inline(always)]
233    pub fn moder2(&mut self) -> MODER_W<MODERrs> {
234        MODER_W::new(self, 4)
235    }
236    ///Bits 6:7 - Port x configuration pin 3
237    #[inline(always)]
238    pub fn moder3(&mut self) -> MODER_W<MODERrs> {
239        MODER_W::new(self, 6)
240    }
241    ///Bits 8:9 - Port x configuration pin 4
242    #[inline(always)]
243    pub fn moder4(&mut self) -> MODER_W<MODERrs> {
244        MODER_W::new(self, 8)
245    }
246    ///Bits 10:11 - Port x configuration pin 5
247    #[inline(always)]
248    pub fn moder5(&mut self) -> MODER_W<MODERrs> {
249        MODER_W::new(self, 10)
250    }
251    ///Bits 12:13 - Port x configuration pin 6
252    #[inline(always)]
253    pub fn moder6(&mut self) -> MODER_W<MODERrs> {
254        MODER_W::new(self, 12)
255    }
256    ///Bits 14:15 - Port x configuration pin 7
257    #[inline(always)]
258    pub fn moder7(&mut self) -> MODER_W<MODERrs> {
259        MODER_W::new(self, 14)
260    }
261    ///Bits 16:17 - Port x configuration pin 8
262    #[inline(always)]
263    pub fn moder8(&mut self) -> MODER_W<MODERrs> {
264        MODER_W::new(self, 16)
265    }
266    ///Bits 18:19 - Port x configuration pin 9
267    #[inline(always)]
268    pub fn moder9(&mut self) -> MODER_W<MODERrs> {
269        MODER_W::new(self, 18)
270    }
271    ///Bits 20:21 - Port x configuration pin 10
272    #[inline(always)]
273    pub fn moder10(&mut self) -> MODER_W<MODERrs> {
274        MODER_W::new(self, 20)
275    }
276    ///Bits 22:23 - Port x configuration pin 11
277    #[inline(always)]
278    pub fn moder11(&mut self) -> MODER_W<MODERrs> {
279        MODER_W::new(self, 22)
280    }
281    ///Bits 24:25 - Port x configuration pin 12
282    #[inline(always)]
283    pub fn moder12(&mut self) -> MODER_W<MODERrs> {
284        MODER_W::new(self, 24)
285    }
286    ///Bits 26:27 - Port x configuration pin 13
287    #[inline(always)]
288    pub fn moder13(&mut self) -> MODER_W<MODERrs> {
289        MODER_W::new(self, 26)
290    }
291    ///Bits 28:29 - Port x configuration pin 14
292    #[inline(always)]
293    pub fn moder14(&mut self) -> MODER_W<MODERrs> {
294        MODER_W::new(self, 28)
295    }
296    ///Bits 30:31 - Port x configuration pin 15
297    #[inline(always)]
298    pub fn moder15(&mut self) -> MODER_W<MODERrs> {
299        MODER_W::new(self, 30)
300    }
301}
302/**GPIO port mode register
303
304You can [`read`](crate::Reg::read) this register and get [`moder::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`moder::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api).
305
306See register [structure](https://stm32-rs.github.io/stm32-rs/STM32F373.html#GPIOA:MODER)*/
307pub struct MODERrs;
308impl crate::RegisterSpec for MODERrs {
309    type Ux = u32;
310}
311///`read()` method returns [`moder::R`](R) reader structure
312impl crate::Readable for MODERrs {}
313///`write(|w| ..)` method takes [`moder::W`](W) writer structure
314impl crate::Writable for MODERrs {
315    type Safety = crate::Unsafe;
316    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
317    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
318}
319///`reset()` method sets MODER to value 0xa800_0000
320impl crate::Resettable for MODERrs {
321    const RESET_VALUE: u32 = 0xa800_0000;
322}