mcxa_pac/i3c0/
smapctrl0.rs

1#[doc = "Register `SMAPCTRL0` reader"]
2pub type R = crate::R<Smapctrl0Spec>;
3#[doc = "Enable Primary Dynamic Address\n\nValue on reset: 0"]
4#[cfg_attr(feature = "defmt", derive(defmt::Format))]
5#[derive(Clone, Copy, Debug, PartialEq, Eq)]
6pub enum Ena {
7    #[doc = "0: Disabled"]
8    Disable = 0,
9    #[doc = "1: Enabled"]
10    Enable = 1,
11}
12impl From<Ena> for bool {
13    #[inline(always)]
14    fn from(variant: Ena) -> Self {
15        variant as u8 != 0
16    }
17}
18#[doc = "Field `ENA` reader - Enable Primary Dynamic Address"]
19pub type EnaR = crate::BitReader<Ena>;
20impl EnaR {
21    #[doc = "Get enumerated values variant"]
22    #[inline(always)]
23    pub const fn variant(&self) -> Ena {
24        match self.bits {
25            false => Ena::Disable,
26            true => Ena::Enable,
27        }
28    }
29    #[doc = "Disabled"]
30    #[inline(always)]
31    pub fn is_disable(&self) -> bool {
32        *self == Ena::Disable
33    }
34    #[doc = "Enabled"]
35    #[inline(always)]
36    pub fn is_enable(&self) -> bool {
37        *self == Ena::Enable
38    }
39}
40#[doc = "Field `DA` reader - Dynamic Address"]
41pub type DaR = crate::FieldReader;
42#[doc = "Cause\n\nValue on reset: 0"]
43#[cfg_attr(feature = "defmt", derive(defmt::Format))]
44#[derive(Clone, Copy, Debug, PartialEq, Eq)]
45#[repr(u8)]
46pub enum Cause {
47    #[doc = "0: No information (this value occurs when not configured to write DA)"]
48    None = 0,
49    #[doc = "1: Set using ENTDAA"]
50    Entdaa = 1,
51    #[doc = "2: Set using SETDASA, SETAASA, or SETNEWDA"]
52    Setdasa = 2,
53    #[doc = "3: Cleared using RSTDAA"]
54    Rstdaa = 3,
55    #[doc = "4: Auto MAP change happened last"]
56    Automap = 4,
57}
58impl From<Cause> for u8 {
59    #[inline(always)]
60    fn from(variant: Cause) -> Self {
61        variant as _
62    }
63}
64impl crate::FieldSpec for Cause {
65    type Ux = u8;
66}
67impl crate::IsEnum for Cause {}
68#[doc = "Field `CAUSE` reader - Cause"]
69pub type CauseR = crate::FieldReader<Cause>;
70impl CauseR {
71    #[doc = "Get enumerated values variant"]
72    #[inline(always)]
73    pub const fn variant(&self) -> Option<Cause> {
74        match self.bits {
75            0 => Some(Cause::None),
76            1 => Some(Cause::Entdaa),
77            2 => Some(Cause::Setdasa),
78            3 => Some(Cause::Rstdaa),
79            4 => Some(Cause::Automap),
80            _ => None,
81        }
82    }
83    #[doc = "No information (this value occurs when not configured to write DA)"]
84    #[inline(always)]
85    pub fn is_none(&self) -> bool {
86        *self == Cause::None
87    }
88    #[doc = "Set using ENTDAA"]
89    #[inline(always)]
90    pub fn is_entdaa(&self) -> bool {
91        *self == Cause::Entdaa
92    }
93    #[doc = "Set using SETDASA, SETAASA, or SETNEWDA"]
94    #[inline(always)]
95    pub fn is_setdasa(&self) -> bool {
96        *self == Cause::Setdasa
97    }
98    #[doc = "Cleared using RSTDAA"]
99    #[inline(always)]
100    pub fn is_rstdaa(&self) -> bool {
101        *self == Cause::Rstdaa
102    }
103    #[doc = "Auto MAP change happened last"]
104    #[inline(always)]
105    pub fn is_automap(&self) -> bool {
106        *self == Cause::Automap
107    }
108}
109impl R {
110    #[doc = "Bit 0 - Enable Primary Dynamic Address"]
111    #[inline(always)]
112    pub fn ena(&self) -> EnaR {
113        EnaR::new((self.bits & 1) != 0)
114    }
115    #[doc = "Bits 1:7 - Dynamic Address"]
116    #[inline(always)]
117    pub fn da(&self) -> DaR {
118        DaR::new(((self.bits >> 1) & 0x7f) as u8)
119    }
120    #[doc = "Bits 8:10 - Cause"]
121    #[inline(always)]
122    pub fn cause(&self) -> CauseR {
123        CauseR::new(((self.bits >> 8) & 7) as u8)
124    }
125}
126#[cfg(feature = "debug")]
127impl core::fmt::Debug for R {
128    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
129        f.debug_struct("SMAPCTRL0")
130            .field("ena", &self.ena())
131            .field("da", &self.da())
132            .field("cause", &self.cause())
133            .finish()
134    }
135}
136#[doc = "Map Feature Control 0\n\nYou can [`read`](crate::Reg::read) this register and get [`smapctrl0::R`](R). See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
137pub struct Smapctrl0Spec;
138impl crate::RegisterSpec for Smapctrl0Spec {
139    type Ux = u32;
140}
141#[doc = "`read()` method returns [`smapctrl0::R`](R) reader structure"]
142impl crate::Readable for Smapctrl0Spec {}
143#[doc = "`reset()` method sets SMAPCTRL0 to value 0"]
144impl crate::Resettable for Smapctrl0Spec {}