Skip to main content

mcxa_pac/port0/
config.rs

1#[doc = "Register `CONFIG` reader"]
2pub type R = crate::R<ConfigSpec>;
3#[doc = "Register `CONFIG` writer"]
4pub type W = crate::W<ConfigSpec>;
5#[doc = "Port Voltage Range\n\nValue on reset: 0"]
6#[cfg_attr(feature = "defmt", derive(defmt::Format))]
7#[derive(Clone, Copy, Debug, PartialEq, Eq)]
8pub enum Range {
9    #[doc = "0: 1.71 V-3.6 V"]
10    Range0 = 0,
11    #[doc = "1: 2.70 V-3.6 V"]
12    Range1 = 1,
13}
14impl From<Range> for bool {
15    #[inline(always)]
16    fn from(variant: Range) -> Self {
17        variant as u8 != 0
18    }
19}
20#[doc = "Field `RANGE` reader - Port Voltage Range"]
21pub type RangeR = crate::BitReader<Range>;
22impl RangeR {
23    #[doc = "Get enumerated values variant"]
24    #[inline(always)]
25    pub const fn variant(&self) -> Range {
26        match self.bits {
27            false => Range::Range0,
28            true => Range::Range1,
29        }
30    }
31    #[doc = "1.71 V-3.6 V"]
32    #[inline(always)]
33    pub fn is_range0(&self) -> bool {
34        *self == Range::Range0
35    }
36    #[doc = "2.70 V-3.6 V"]
37    #[inline(always)]
38    pub fn is_range1(&self) -> bool {
39        *self == Range::Range1
40    }
41}
42#[doc = "Field `RANGE` writer - Port Voltage Range"]
43pub type RangeW<'a, REG> = crate::BitWriter<'a, REG, Range>;
44impl<'a, REG> RangeW<'a, REG>
45where
46    REG: crate::Writable + crate::RegisterSpec,
47{
48    #[doc = "1.71 V-3.6 V"]
49    #[inline(always)]
50    pub fn range0(self) -> &'a mut crate::W<REG> {
51        self.variant(Range::Range0)
52    }
53    #[doc = "2.70 V-3.6 V"]
54    #[inline(always)]
55    pub fn range1(self) -> &'a mut crate::W<REG> {
56        self.variant(Range::Range1)
57    }
58}
59impl R {
60    #[doc = "Bit 0 - Port Voltage Range"]
61    #[inline(always)]
62    pub fn range(&self) -> RangeR {
63        RangeR::new((self.bits & 1) != 0)
64    }
65}
66#[cfg(feature = "debug")]
67impl core::fmt::Debug for R {
68    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
69        f.debug_struct("CONFIG").field("range", &self.range()).finish()
70    }
71}
72impl W {
73    #[doc = "Bit 0 - Port Voltage Range"]
74    #[inline(always)]
75    pub fn range(&mut self) -> RangeW<'_, ConfigSpec> {
76        RangeW::new(self, 0)
77    }
78}
79#[doc = "Configuration\n\nYou can [`read`](crate::Reg::read) this register and get [`config::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`config::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
80pub struct ConfigSpec;
81impl crate::RegisterSpec for ConfigSpec {
82    type Ux = u32;
83}
84#[doc = "`read()` method returns [`config::R`](R) reader structure"]
85impl crate::Readable for ConfigSpec {}
86#[doc = "`write(|w| ..)` method takes [`config::W`](W) writer structure"]
87impl crate::Writable for ConfigSpec {
88    type Safety = crate::Unsafe;
89}
90#[doc = "`reset()` method sets CONFIG to value 0"]
91impl crate::Resettable for ConfigSpec {}