lpc55_pac/flexcomm0/
pselid.rs

1#[doc = "Register `PSELID` reader"]
2pub struct R(crate::R<PSELID_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<PSELID_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<PSELID_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<PSELID_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `PSELID` writer"]
17pub struct W(crate::W<PSELID_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<PSELID_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<PSELID_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<PSELID_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Peripheral Select. This field is writable by software.\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39#[repr(u8)]
40pub enum PERSEL_A {
41    #[doc = "0: No peripheral selected."]
42    NO_PERIPH_SELECTED = 0,
43    #[doc = "1: USART function selected."]
44    USART = 1,
45    #[doc = "2: SPI function selected."]
46    SPI = 2,
47    #[doc = "3: I2C function selected."]
48    I2C = 3,
49    #[doc = "4: I2S transmit function selected."]
50    I2S_TRANSMIT = 4,
51    #[doc = "5: I2S receive function selected."]
52    I2S_RECEIVE = 5,
53}
54impl From<PERSEL_A> for u8 {
55    #[inline(always)]
56    fn from(variant: PERSEL_A) -> Self {
57        variant as _
58    }
59}
60#[doc = "Field `PERSEL` reader - Peripheral Select. This field is writable by software."]
61pub struct PERSEL_R(crate::FieldReader<u8, PERSEL_A>);
62impl PERSEL_R {
63    #[inline(always)]
64    pub(crate) fn new(bits: u8) -> Self {
65        PERSEL_R(crate::FieldReader::new(bits))
66    }
67    #[doc = r"Get enumerated values variant"]
68    #[inline(always)]
69    pub fn variant(&self) -> Option<PERSEL_A> {
70        match self.bits {
71            0 => Some(PERSEL_A::NO_PERIPH_SELECTED),
72            1 => Some(PERSEL_A::USART),
73            2 => Some(PERSEL_A::SPI),
74            3 => Some(PERSEL_A::I2C),
75            4 => Some(PERSEL_A::I2S_TRANSMIT),
76            5 => Some(PERSEL_A::I2S_RECEIVE),
77            _ => None,
78        }
79    }
80    #[doc = "Checks if the value of the field is `NO_PERIPH_SELECTED`"]
81    #[inline(always)]
82    pub fn is_no_periph_selected(&self) -> bool {
83        **self == PERSEL_A::NO_PERIPH_SELECTED
84    }
85    #[doc = "Checks if the value of the field is `USART`"]
86    #[inline(always)]
87    pub fn is_usart(&self) -> bool {
88        **self == PERSEL_A::USART
89    }
90    #[doc = "Checks if the value of the field is `SPI`"]
91    #[inline(always)]
92    pub fn is_spi(&self) -> bool {
93        **self == PERSEL_A::SPI
94    }
95    #[doc = "Checks if the value of the field is `I2C`"]
96    #[inline(always)]
97    pub fn is_i2c(&self) -> bool {
98        **self == PERSEL_A::I2C
99    }
100    #[doc = "Checks if the value of the field is `I2S_TRANSMIT`"]
101    #[inline(always)]
102    pub fn is_i2s_transmit(&self) -> bool {
103        **self == PERSEL_A::I2S_TRANSMIT
104    }
105    #[doc = "Checks if the value of the field is `I2S_RECEIVE`"]
106    #[inline(always)]
107    pub fn is_i2s_receive(&self) -> bool {
108        **self == PERSEL_A::I2S_RECEIVE
109    }
110}
111impl core::ops::Deref for PERSEL_R {
112    type Target = crate::FieldReader<u8, PERSEL_A>;
113    #[inline(always)]
114    fn deref(&self) -> &Self::Target {
115        &self.0
116    }
117}
118#[doc = "Field `PERSEL` writer - Peripheral Select. This field is writable by software."]
119pub struct PERSEL_W<'a> {
120    w: &'a mut W,
121}
122impl<'a> PERSEL_W<'a> {
123    #[doc = r"Writes `variant` to the field"]
124    #[inline(always)]
125    pub fn variant(self, variant: PERSEL_A) -> &'a mut W {
126        unsafe { self.bits(variant.into()) }
127    }
128    #[doc = "No peripheral selected."]
129    #[inline(always)]
130    pub fn no_periph_selected(self) -> &'a mut W {
131        self.variant(PERSEL_A::NO_PERIPH_SELECTED)
132    }
133    #[doc = "USART function selected."]
134    #[inline(always)]
135    pub fn usart(self) -> &'a mut W {
136        self.variant(PERSEL_A::USART)
137    }
138    #[doc = "SPI function selected."]
139    #[inline(always)]
140    pub fn spi(self) -> &'a mut W {
141        self.variant(PERSEL_A::SPI)
142    }
143    #[doc = "I2C function selected."]
144    #[inline(always)]
145    pub fn i2c(self) -> &'a mut W {
146        self.variant(PERSEL_A::I2C)
147    }
148    #[doc = "I2S transmit function selected."]
149    #[inline(always)]
150    pub fn i2s_transmit(self) -> &'a mut W {
151        self.variant(PERSEL_A::I2S_TRANSMIT)
152    }
153    #[doc = "I2S receive function selected."]
154    #[inline(always)]
155    pub fn i2s_receive(self) -> &'a mut W {
156        self.variant(PERSEL_A::I2S_RECEIVE)
157    }
158    #[doc = r"Writes raw bits to the field"]
159    #[inline(always)]
160    pub unsafe fn bits(self, value: u8) -> &'a mut W {
161        self.w.bits = (self.w.bits & !0x07) | (value as u32 & 0x07);
162        self.w
163    }
164}
165#[doc = "Lock the peripheral select. This field is writable by software.\n\nValue on reset: 0"]
166#[derive(Clone, Copy, Debug, PartialEq)]
167pub enum LOCK_A {
168    #[doc = "0: Peripheral select can be changed by software."]
169    UNLOCKED = 0,
170    #[doc = "1: Peripheral select is locked and cannot be changed until this Flexcomm or the entire device is reset."]
171    LOCKED = 1,
172}
173impl From<LOCK_A> for bool {
174    #[inline(always)]
175    fn from(variant: LOCK_A) -> Self {
176        variant as u8 != 0
177    }
178}
179#[doc = "Field `LOCK` reader - Lock the peripheral select. This field is writable by software."]
180pub struct LOCK_R(crate::FieldReader<bool, LOCK_A>);
181impl LOCK_R {
182    #[inline(always)]
183    pub(crate) fn new(bits: bool) -> Self {
184        LOCK_R(crate::FieldReader::new(bits))
185    }
186    #[doc = r"Get enumerated values variant"]
187    #[inline(always)]
188    pub fn variant(&self) -> LOCK_A {
189        match self.bits {
190            false => LOCK_A::UNLOCKED,
191            true => LOCK_A::LOCKED,
192        }
193    }
194    #[doc = "Checks if the value of the field is `UNLOCKED`"]
195    #[inline(always)]
196    pub fn is_unlocked(&self) -> bool {
197        **self == LOCK_A::UNLOCKED
198    }
199    #[doc = "Checks if the value of the field is `LOCKED`"]
200    #[inline(always)]
201    pub fn is_locked(&self) -> bool {
202        **self == LOCK_A::LOCKED
203    }
204}
205impl core::ops::Deref for LOCK_R {
206    type Target = crate::FieldReader<bool, LOCK_A>;
207    #[inline(always)]
208    fn deref(&self) -> &Self::Target {
209        &self.0
210    }
211}
212#[doc = "Field `LOCK` writer - Lock the peripheral select. This field is writable by software."]
213pub struct LOCK_W<'a> {
214    w: &'a mut W,
215}
216impl<'a> LOCK_W<'a> {
217    #[doc = r"Writes `variant` to the field"]
218    #[inline(always)]
219    pub fn variant(self, variant: LOCK_A) -> &'a mut W {
220        self.bit(variant.into())
221    }
222    #[doc = "Peripheral select can be changed by software."]
223    #[inline(always)]
224    pub fn unlocked(self) -> &'a mut W {
225        self.variant(LOCK_A::UNLOCKED)
226    }
227    #[doc = "Peripheral select is locked and cannot be changed until this Flexcomm or the entire device is reset."]
228    #[inline(always)]
229    pub fn locked(self) -> &'a mut W {
230        self.variant(LOCK_A::LOCKED)
231    }
232    #[doc = r"Sets the field bit"]
233    #[inline(always)]
234    pub fn set_bit(self) -> &'a mut W {
235        self.bit(true)
236    }
237    #[doc = r"Clears the field bit"]
238    #[inline(always)]
239    pub fn clear_bit(self) -> &'a mut W {
240        self.bit(false)
241    }
242    #[doc = r"Writes raw bits to the field"]
243    #[inline(always)]
244    pub fn bit(self, value: bool) -> &'a mut W {
245        self.w.bits = (self.w.bits & !(0x01 << 3)) | ((value as u32 & 0x01) << 3);
246        self.w
247    }
248}
249#[doc = "USART present indicator. This field is Read-only.\n\nValue on reset: 0"]
250#[derive(Clone, Copy, Debug, PartialEq)]
251pub enum USARTPRESENT_A {
252    #[doc = "0: This Flexcomm does not include the USART function."]
253    NOT_PRESENT = 0,
254    #[doc = "1: This Flexcomm includes the USART function."]
255    PRESENT = 1,
256}
257impl From<USARTPRESENT_A> for bool {
258    #[inline(always)]
259    fn from(variant: USARTPRESENT_A) -> Self {
260        variant as u8 != 0
261    }
262}
263#[doc = "Field `USARTPRESENT` reader - USART present indicator. This field is Read-only."]
264pub struct USARTPRESENT_R(crate::FieldReader<bool, USARTPRESENT_A>);
265impl USARTPRESENT_R {
266    #[inline(always)]
267    pub(crate) fn new(bits: bool) -> Self {
268        USARTPRESENT_R(crate::FieldReader::new(bits))
269    }
270    #[doc = r"Get enumerated values variant"]
271    #[inline(always)]
272    pub fn variant(&self) -> USARTPRESENT_A {
273        match self.bits {
274            false => USARTPRESENT_A::NOT_PRESENT,
275            true => USARTPRESENT_A::PRESENT,
276        }
277    }
278    #[doc = "Checks if the value of the field is `NOT_PRESENT`"]
279    #[inline(always)]
280    pub fn is_not_present(&self) -> bool {
281        **self == USARTPRESENT_A::NOT_PRESENT
282    }
283    #[doc = "Checks if the value of the field is `PRESENT`"]
284    #[inline(always)]
285    pub fn is_present(&self) -> bool {
286        **self == USARTPRESENT_A::PRESENT
287    }
288}
289impl core::ops::Deref for USARTPRESENT_R {
290    type Target = crate::FieldReader<bool, USARTPRESENT_A>;
291    #[inline(always)]
292    fn deref(&self) -> &Self::Target {
293        &self.0
294    }
295}
296#[doc = "SPI present indicator. This field is Read-only.\n\nValue on reset: 0"]
297#[derive(Clone, Copy, Debug, PartialEq)]
298pub enum SPIPRESENT_A {
299    #[doc = "0: This Flexcomm does not include the SPI function."]
300    NOT_PRESENT = 0,
301    #[doc = "1: This Flexcomm includes the SPI function."]
302    PRESENT = 1,
303}
304impl From<SPIPRESENT_A> for bool {
305    #[inline(always)]
306    fn from(variant: SPIPRESENT_A) -> Self {
307        variant as u8 != 0
308    }
309}
310#[doc = "Field `SPIPRESENT` reader - SPI present indicator. This field is Read-only."]
311pub struct SPIPRESENT_R(crate::FieldReader<bool, SPIPRESENT_A>);
312impl SPIPRESENT_R {
313    #[inline(always)]
314    pub(crate) fn new(bits: bool) -> Self {
315        SPIPRESENT_R(crate::FieldReader::new(bits))
316    }
317    #[doc = r"Get enumerated values variant"]
318    #[inline(always)]
319    pub fn variant(&self) -> SPIPRESENT_A {
320        match self.bits {
321            false => SPIPRESENT_A::NOT_PRESENT,
322            true => SPIPRESENT_A::PRESENT,
323        }
324    }
325    #[doc = "Checks if the value of the field is `NOT_PRESENT`"]
326    #[inline(always)]
327    pub fn is_not_present(&self) -> bool {
328        **self == SPIPRESENT_A::NOT_PRESENT
329    }
330    #[doc = "Checks if the value of the field is `PRESENT`"]
331    #[inline(always)]
332    pub fn is_present(&self) -> bool {
333        **self == SPIPRESENT_A::PRESENT
334    }
335}
336impl core::ops::Deref for SPIPRESENT_R {
337    type Target = crate::FieldReader<bool, SPIPRESENT_A>;
338    #[inline(always)]
339    fn deref(&self) -> &Self::Target {
340        &self.0
341    }
342}
343#[doc = "I2C present indicator. This field is Read-only.\n\nValue on reset: 0"]
344#[derive(Clone, Copy, Debug, PartialEq)]
345pub enum I2CPRESENT_A {
346    #[doc = "0: This Flexcomm does not include the I2C function."]
347    NOT_PRESENT = 0,
348    #[doc = "1: This Flexcomm includes the I2C function."]
349    PRESENT = 1,
350}
351impl From<I2CPRESENT_A> for bool {
352    #[inline(always)]
353    fn from(variant: I2CPRESENT_A) -> Self {
354        variant as u8 != 0
355    }
356}
357#[doc = "Field `I2CPRESENT` reader - I2C present indicator. This field is Read-only."]
358pub struct I2CPRESENT_R(crate::FieldReader<bool, I2CPRESENT_A>);
359impl I2CPRESENT_R {
360    #[inline(always)]
361    pub(crate) fn new(bits: bool) -> Self {
362        I2CPRESENT_R(crate::FieldReader::new(bits))
363    }
364    #[doc = r"Get enumerated values variant"]
365    #[inline(always)]
366    pub fn variant(&self) -> I2CPRESENT_A {
367        match self.bits {
368            false => I2CPRESENT_A::NOT_PRESENT,
369            true => I2CPRESENT_A::PRESENT,
370        }
371    }
372    #[doc = "Checks if the value of the field is `NOT_PRESENT`"]
373    #[inline(always)]
374    pub fn is_not_present(&self) -> bool {
375        **self == I2CPRESENT_A::NOT_PRESENT
376    }
377    #[doc = "Checks if the value of the field is `PRESENT`"]
378    #[inline(always)]
379    pub fn is_present(&self) -> bool {
380        **self == I2CPRESENT_A::PRESENT
381    }
382}
383impl core::ops::Deref for I2CPRESENT_R {
384    type Target = crate::FieldReader<bool, I2CPRESENT_A>;
385    #[inline(always)]
386    fn deref(&self) -> &Self::Target {
387        &self.0
388    }
389}
390#[doc = "I 2S present indicator. This field is Read-only.\n\nValue on reset: 0"]
391#[derive(Clone, Copy, Debug, PartialEq)]
392pub enum I2SPRESENT_A {
393    #[doc = "0: This Flexcomm does not include the I2S function."]
394    NOT_PRESENT = 0,
395    #[doc = "1: This Flexcomm includes the I2S function."]
396    PRESENT = 1,
397}
398impl From<I2SPRESENT_A> for bool {
399    #[inline(always)]
400    fn from(variant: I2SPRESENT_A) -> Self {
401        variant as u8 != 0
402    }
403}
404#[doc = "Field `I2SPRESENT` reader - I 2S present indicator. This field is Read-only."]
405pub struct I2SPRESENT_R(crate::FieldReader<bool, I2SPRESENT_A>);
406impl I2SPRESENT_R {
407    #[inline(always)]
408    pub(crate) fn new(bits: bool) -> Self {
409        I2SPRESENT_R(crate::FieldReader::new(bits))
410    }
411    #[doc = r"Get enumerated values variant"]
412    #[inline(always)]
413    pub fn variant(&self) -> I2SPRESENT_A {
414        match self.bits {
415            false => I2SPRESENT_A::NOT_PRESENT,
416            true => I2SPRESENT_A::PRESENT,
417        }
418    }
419    #[doc = "Checks if the value of the field is `NOT_PRESENT`"]
420    #[inline(always)]
421    pub fn is_not_present(&self) -> bool {
422        **self == I2SPRESENT_A::NOT_PRESENT
423    }
424    #[doc = "Checks if the value of the field is `PRESENT`"]
425    #[inline(always)]
426    pub fn is_present(&self) -> bool {
427        **self == I2SPRESENT_A::PRESENT
428    }
429}
430impl core::ops::Deref for I2SPRESENT_R {
431    type Target = crate::FieldReader<bool, I2SPRESENT_A>;
432    #[inline(always)]
433    fn deref(&self) -> &Self::Target {
434        &self.0
435    }
436}
437#[doc = "Field `ID` reader - Flexcomm ID."]
438pub struct ID_R(crate::FieldReader<u32, u32>);
439impl ID_R {
440    #[inline(always)]
441    pub(crate) fn new(bits: u32) -> Self {
442        ID_R(crate::FieldReader::new(bits))
443    }
444}
445impl core::ops::Deref for ID_R {
446    type Target = crate::FieldReader<u32, u32>;
447    #[inline(always)]
448    fn deref(&self) -> &Self::Target {
449        &self.0
450    }
451}
452impl R {
453    #[doc = "Bits 0:2 - Peripheral Select. This field is writable by software."]
454    #[inline(always)]
455    pub fn persel(&self) -> PERSEL_R {
456        PERSEL_R::new((self.bits & 0x07) as u8)
457    }
458    #[doc = "Bit 3 - Lock the peripheral select. This field is writable by software."]
459    #[inline(always)]
460    pub fn lock(&self) -> LOCK_R {
461        LOCK_R::new(((self.bits >> 3) & 0x01) != 0)
462    }
463    #[doc = "Bit 4 - USART present indicator. This field is Read-only."]
464    #[inline(always)]
465    pub fn usartpresent(&self) -> USARTPRESENT_R {
466        USARTPRESENT_R::new(((self.bits >> 4) & 0x01) != 0)
467    }
468    #[doc = "Bit 5 - SPI present indicator. This field is Read-only."]
469    #[inline(always)]
470    pub fn spipresent(&self) -> SPIPRESENT_R {
471        SPIPRESENT_R::new(((self.bits >> 5) & 0x01) != 0)
472    }
473    #[doc = "Bit 6 - I2C present indicator. This field is Read-only."]
474    #[inline(always)]
475    pub fn i2cpresent(&self) -> I2CPRESENT_R {
476        I2CPRESENT_R::new(((self.bits >> 6) & 0x01) != 0)
477    }
478    #[doc = "Bit 7 - I 2S present indicator. This field is Read-only."]
479    #[inline(always)]
480    pub fn i2spresent(&self) -> I2SPRESENT_R {
481        I2SPRESENT_R::new(((self.bits >> 7) & 0x01) != 0)
482    }
483    #[doc = "Bits 12:31 - Flexcomm ID."]
484    #[inline(always)]
485    pub fn id(&self) -> ID_R {
486        ID_R::new(((self.bits >> 12) & 0x000f_ffff) as u32)
487    }
488}
489impl W {
490    #[doc = "Bits 0:2 - Peripheral Select. This field is writable by software."]
491    #[inline(always)]
492    pub fn persel(&mut self) -> PERSEL_W {
493        PERSEL_W { w: self }
494    }
495    #[doc = "Bit 3 - Lock the peripheral select. This field is writable by software."]
496    #[inline(always)]
497    pub fn lock(&mut self) -> LOCK_W {
498        LOCK_W { w: self }
499    }
500    #[doc = "Writes raw bits to the register."]
501    #[inline(always)]
502    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
503        self.0.bits(bits);
504        self
505    }
506}
507#[doc = "Peripheral Select and Flexcomm ID register.\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 [pselid](index.html) module"]
508pub struct PSELID_SPEC;
509impl crate::RegisterSpec for PSELID_SPEC {
510    type Ux = u32;
511}
512#[doc = "`read()` method returns [pselid::R](R) reader structure"]
513impl crate::Readable for PSELID_SPEC {
514    type Reader = R;
515}
516#[doc = "`write(|w| ..)` method takes [pselid::W](W) writer structure"]
517impl crate::Writable for PSELID_SPEC {
518    type Writer = W;
519}
520#[doc = "`reset()` method sets PSELID to value 0x0010_1000"]
521impl crate::Resettable for PSELID_SPEC {
522    #[inline(always)]
523    fn reset_value() -> Self::Ux {
524        0x0010_1000
525    }
526}