stm32l4/stm32l4x5/adc1/
awd2cr.rs

1///Register `AWD2CR` reader
2pub type R = crate::R<AWD2CRrs>;
3///Register `AWD2CR` writer
4pub type W = crate::W<AWD2CRrs>;
5/**AWD2CH
6
7Value on reset: 0*/
8#[cfg_attr(feature = "defmt", derive(defmt::Format))]
9#[derive(Clone, Copy, Debug, PartialEq, Eq)]
10pub enum AWD2CH0 {
11    ///0: Input channel not monitored by AWDx
12    NotMonitored = 0,
13    ///1: Input channel monitored by AWDx
14    Monitored = 1,
15}
16impl From<AWD2CH0> for bool {
17    #[inline(always)]
18    fn from(variant: AWD2CH0) -> Self {
19        variant as u8 != 0
20    }
21}
22///Field `AWD2CH(0-17)` reader - AWD2CH
23pub type AWD2CH_R = crate::BitReader<AWD2CH0>;
24impl AWD2CH_R {
25    ///Get enumerated values variant
26    #[inline(always)]
27    pub const fn variant(&self) -> AWD2CH0 {
28        match self.bits {
29            false => AWD2CH0::NotMonitored,
30            true => AWD2CH0::Monitored,
31        }
32    }
33    ///Input channel not monitored by AWDx
34    #[inline(always)]
35    pub fn is_not_monitored(&self) -> bool {
36        *self == AWD2CH0::NotMonitored
37    }
38    ///Input channel monitored by AWDx
39    #[inline(always)]
40    pub fn is_monitored(&self) -> bool {
41        *self == AWD2CH0::Monitored
42    }
43}
44///Field `AWD2CH(0-17)` writer - AWD2CH
45pub type AWD2CH_W<'a, REG> = crate::BitWriter<'a, REG, AWD2CH0>;
46impl<'a, REG> AWD2CH_W<'a, REG>
47where
48    REG: crate::Writable + crate::RegisterSpec,
49{
50    ///Input channel not monitored by AWDx
51    #[inline(always)]
52    pub fn not_monitored(self) -> &'a mut crate::W<REG> {
53        self.variant(AWD2CH0::NotMonitored)
54    }
55    ///Input channel monitored by AWDx
56    #[inline(always)]
57    pub fn monitored(self) -> &'a mut crate::W<REG> {
58        self.variant(AWD2CH0::Monitored)
59    }
60}
61impl R {
62    ///AWD2CH
63    ///
64    ///<div class="warning">`n` is number of field in register. `n == 0` corresponds to `AWD2CH0` field.</div>
65    #[inline(always)]
66    pub fn awd2ch(&self, n: u8) -> AWD2CH_R {
67        #[allow(clippy::no_effect)]
68        [(); 18][n as usize];
69        AWD2CH_R::new(((self.bits >> (n + 1)) & 1) != 0)
70    }
71    ///Iterator for array of:
72    ///AWD2CH
73    #[inline(always)]
74    pub fn awd2ch_iter(&self) -> impl Iterator<Item = AWD2CH_R> + '_ {
75        (0..18).map(move |n| AWD2CH_R::new(((self.bits >> (n + 1)) & 1) != 0))
76    }
77    ///Bit 1 - AWD2CH
78    #[inline(always)]
79    pub fn awd2ch0(&self) -> AWD2CH_R {
80        AWD2CH_R::new(((self.bits >> 1) & 1) != 0)
81    }
82    ///Bit 2 - AWD2CH
83    #[inline(always)]
84    pub fn awd2ch1(&self) -> AWD2CH_R {
85        AWD2CH_R::new(((self.bits >> 2) & 1) != 0)
86    }
87    ///Bit 3 - AWD2CH
88    #[inline(always)]
89    pub fn awd2ch2(&self) -> AWD2CH_R {
90        AWD2CH_R::new(((self.bits >> 3) & 1) != 0)
91    }
92    ///Bit 4 - AWD2CH
93    #[inline(always)]
94    pub fn awd2ch3(&self) -> AWD2CH_R {
95        AWD2CH_R::new(((self.bits >> 4) & 1) != 0)
96    }
97    ///Bit 5 - AWD2CH
98    #[inline(always)]
99    pub fn awd2ch4(&self) -> AWD2CH_R {
100        AWD2CH_R::new(((self.bits >> 5) & 1) != 0)
101    }
102    ///Bit 6 - AWD2CH
103    #[inline(always)]
104    pub fn awd2ch5(&self) -> AWD2CH_R {
105        AWD2CH_R::new(((self.bits >> 6) & 1) != 0)
106    }
107    ///Bit 7 - AWD2CH
108    #[inline(always)]
109    pub fn awd2ch6(&self) -> AWD2CH_R {
110        AWD2CH_R::new(((self.bits >> 7) & 1) != 0)
111    }
112    ///Bit 8 - AWD2CH
113    #[inline(always)]
114    pub fn awd2ch7(&self) -> AWD2CH_R {
115        AWD2CH_R::new(((self.bits >> 8) & 1) != 0)
116    }
117    ///Bit 9 - AWD2CH
118    #[inline(always)]
119    pub fn awd2ch8(&self) -> AWD2CH_R {
120        AWD2CH_R::new(((self.bits >> 9) & 1) != 0)
121    }
122    ///Bit 10 - AWD2CH
123    #[inline(always)]
124    pub fn awd2ch9(&self) -> AWD2CH_R {
125        AWD2CH_R::new(((self.bits >> 10) & 1) != 0)
126    }
127    ///Bit 11 - AWD2CH
128    #[inline(always)]
129    pub fn awd2ch10(&self) -> AWD2CH_R {
130        AWD2CH_R::new(((self.bits >> 11) & 1) != 0)
131    }
132    ///Bit 12 - AWD2CH
133    #[inline(always)]
134    pub fn awd2ch11(&self) -> AWD2CH_R {
135        AWD2CH_R::new(((self.bits >> 12) & 1) != 0)
136    }
137    ///Bit 13 - AWD2CH
138    #[inline(always)]
139    pub fn awd2ch12(&self) -> AWD2CH_R {
140        AWD2CH_R::new(((self.bits >> 13) & 1) != 0)
141    }
142    ///Bit 14 - AWD2CH
143    #[inline(always)]
144    pub fn awd2ch13(&self) -> AWD2CH_R {
145        AWD2CH_R::new(((self.bits >> 14) & 1) != 0)
146    }
147    ///Bit 15 - AWD2CH
148    #[inline(always)]
149    pub fn awd2ch14(&self) -> AWD2CH_R {
150        AWD2CH_R::new(((self.bits >> 15) & 1) != 0)
151    }
152    ///Bit 16 - AWD2CH
153    #[inline(always)]
154    pub fn awd2ch15(&self) -> AWD2CH_R {
155        AWD2CH_R::new(((self.bits >> 16) & 1) != 0)
156    }
157    ///Bit 17 - AWD2CH
158    #[inline(always)]
159    pub fn awd2ch16(&self) -> AWD2CH_R {
160        AWD2CH_R::new(((self.bits >> 17) & 1) != 0)
161    }
162    ///Bit 18 - AWD2CH
163    #[inline(always)]
164    pub fn awd2ch17(&self) -> AWD2CH_R {
165        AWD2CH_R::new(((self.bits >> 18) & 1) != 0)
166    }
167}
168impl core::fmt::Debug for R {
169    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
170        f.debug_struct("AWD2CR")
171            .field("awd2ch0", &self.awd2ch0())
172            .field("awd2ch1", &self.awd2ch1())
173            .field("awd2ch2", &self.awd2ch2())
174            .field("awd2ch3", &self.awd2ch3())
175            .field("awd2ch4", &self.awd2ch4())
176            .field("awd2ch5", &self.awd2ch5())
177            .field("awd2ch6", &self.awd2ch6())
178            .field("awd2ch7", &self.awd2ch7())
179            .field("awd2ch8", &self.awd2ch8())
180            .field("awd2ch9", &self.awd2ch9())
181            .field("awd2ch10", &self.awd2ch10())
182            .field("awd2ch11", &self.awd2ch11())
183            .field("awd2ch12", &self.awd2ch12())
184            .field("awd2ch13", &self.awd2ch13())
185            .field("awd2ch14", &self.awd2ch14())
186            .field("awd2ch15", &self.awd2ch15())
187            .field("awd2ch16", &self.awd2ch16())
188            .field("awd2ch17", &self.awd2ch17())
189            .finish()
190    }
191}
192impl W {
193    ///AWD2CH
194    ///
195    ///<div class="warning">`n` is number of field in register. `n == 0` corresponds to `AWD2CH0` field.</div>
196    #[inline(always)]
197    pub fn awd2ch(&mut self, n: u8) -> AWD2CH_W<AWD2CRrs> {
198        #[allow(clippy::no_effect)]
199        [(); 18][n as usize];
200        AWD2CH_W::new(self, n + 1)
201    }
202    ///Bit 1 - AWD2CH
203    #[inline(always)]
204    pub fn awd2ch0(&mut self) -> AWD2CH_W<AWD2CRrs> {
205        AWD2CH_W::new(self, 1)
206    }
207    ///Bit 2 - AWD2CH
208    #[inline(always)]
209    pub fn awd2ch1(&mut self) -> AWD2CH_W<AWD2CRrs> {
210        AWD2CH_W::new(self, 2)
211    }
212    ///Bit 3 - AWD2CH
213    #[inline(always)]
214    pub fn awd2ch2(&mut self) -> AWD2CH_W<AWD2CRrs> {
215        AWD2CH_W::new(self, 3)
216    }
217    ///Bit 4 - AWD2CH
218    #[inline(always)]
219    pub fn awd2ch3(&mut self) -> AWD2CH_W<AWD2CRrs> {
220        AWD2CH_W::new(self, 4)
221    }
222    ///Bit 5 - AWD2CH
223    #[inline(always)]
224    pub fn awd2ch4(&mut self) -> AWD2CH_W<AWD2CRrs> {
225        AWD2CH_W::new(self, 5)
226    }
227    ///Bit 6 - AWD2CH
228    #[inline(always)]
229    pub fn awd2ch5(&mut self) -> AWD2CH_W<AWD2CRrs> {
230        AWD2CH_W::new(self, 6)
231    }
232    ///Bit 7 - AWD2CH
233    #[inline(always)]
234    pub fn awd2ch6(&mut self) -> AWD2CH_W<AWD2CRrs> {
235        AWD2CH_W::new(self, 7)
236    }
237    ///Bit 8 - AWD2CH
238    #[inline(always)]
239    pub fn awd2ch7(&mut self) -> AWD2CH_W<AWD2CRrs> {
240        AWD2CH_W::new(self, 8)
241    }
242    ///Bit 9 - AWD2CH
243    #[inline(always)]
244    pub fn awd2ch8(&mut self) -> AWD2CH_W<AWD2CRrs> {
245        AWD2CH_W::new(self, 9)
246    }
247    ///Bit 10 - AWD2CH
248    #[inline(always)]
249    pub fn awd2ch9(&mut self) -> AWD2CH_W<AWD2CRrs> {
250        AWD2CH_W::new(self, 10)
251    }
252    ///Bit 11 - AWD2CH
253    #[inline(always)]
254    pub fn awd2ch10(&mut self) -> AWD2CH_W<AWD2CRrs> {
255        AWD2CH_W::new(self, 11)
256    }
257    ///Bit 12 - AWD2CH
258    #[inline(always)]
259    pub fn awd2ch11(&mut self) -> AWD2CH_W<AWD2CRrs> {
260        AWD2CH_W::new(self, 12)
261    }
262    ///Bit 13 - AWD2CH
263    #[inline(always)]
264    pub fn awd2ch12(&mut self) -> AWD2CH_W<AWD2CRrs> {
265        AWD2CH_W::new(self, 13)
266    }
267    ///Bit 14 - AWD2CH
268    #[inline(always)]
269    pub fn awd2ch13(&mut self) -> AWD2CH_W<AWD2CRrs> {
270        AWD2CH_W::new(self, 14)
271    }
272    ///Bit 15 - AWD2CH
273    #[inline(always)]
274    pub fn awd2ch14(&mut self) -> AWD2CH_W<AWD2CRrs> {
275        AWD2CH_W::new(self, 15)
276    }
277    ///Bit 16 - AWD2CH
278    #[inline(always)]
279    pub fn awd2ch15(&mut self) -> AWD2CH_W<AWD2CRrs> {
280        AWD2CH_W::new(self, 16)
281    }
282    ///Bit 17 - AWD2CH
283    #[inline(always)]
284    pub fn awd2ch16(&mut self) -> AWD2CH_W<AWD2CRrs> {
285        AWD2CH_W::new(self, 17)
286    }
287    ///Bit 18 - AWD2CH
288    #[inline(always)]
289    pub fn awd2ch17(&mut self) -> AWD2CH_W<AWD2CRrs> {
290        AWD2CH_W::new(self, 18)
291    }
292}
293/**Analog Watchdog 2 Configuration Register
294
295You can [`read`](crate::Reg::read) this register and get [`awd2cr::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`awd2cr::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api).
296
297See register [structure](https://stm32-rs.github.io/stm32-rs/STM32L4x5.html#ADC1:AWD2CR)*/
298pub struct AWD2CRrs;
299impl crate::RegisterSpec for AWD2CRrs {
300    type Ux = u32;
301}
302///`read()` method returns [`awd2cr::R`](R) reader structure
303impl crate::Readable for AWD2CRrs {}
304///`write(|w| ..)` method takes [`awd2cr::W`](W) writer structure
305impl crate::Writable for AWD2CRrs {
306    type Safety = crate::Unsafe;
307}
308///`reset()` method sets AWD2CR to value 0
309impl crate::Resettable for AWD2CRrs {}