Skip to main content

mcxa_pac/syscon/
device_type.rs

1#[doc = "Register `DEVICE_TYPE` reader"]
2pub type R = crate::R<DeviceTypeSpec>;
3#[doc = "Field `DEVICE_TYPE_NUM` reader - Indicates the device part number"]
4pub type DeviceTypeNumR = crate::FieldReader<u16>;
5#[doc = "Indicates the device type\n\nValue on reset: 0"]
6#[cfg_attr(feature = "defmt", derive(defmt::Format))]
7#[derive(Clone, Copy, Debug, PartialEq, Eq)]
8pub enum DeviceTypeSec {
9    #[doc = "0: Non Secure"]
10    NonSec = 0,
11    #[doc = "1: Secure"]
12    Sec = 1,
13}
14impl From<DeviceTypeSec> for bool {
15    #[inline(always)]
16    fn from(variant: DeviceTypeSec) -> Self {
17        variant as u8 != 0
18    }
19}
20#[doc = "Field `DEVICE_TYPE_SEC` reader - Indicates the device type"]
21pub type DeviceTypeSecR = crate::BitReader<DeviceTypeSec>;
22impl DeviceTypeSecR {
23    #[doc = "Get enumerated values variant"]
24    #[inline(always)]
25    pub const fn variant(&self) -> DeviceTypeSec {
26        match self.bits {
27            false => DeviceTypeSec::NonSec,
28            true => DeviceTypeSec::Sec,
29        }
30    }
31    #[doc = "Non Secure"]
32    #[inline(always)]
33    pub fn is_non_sec(&self) -> bool {
34        *self == DeviceTypeSec::NonSec
35    }
36    #[doc = "Secure"]
37    #[inline(always)]
38    pub fn is_sec(&self) -> bool {
39        *self == DeviceTypeSec::Sec
40    }
41}
42#[doc = "Indicates the device's package type\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 DeviceTypePkg {
47    #[doc = "0: HLQFP"]
48    Hlqfp = 0,
49    #[doc = "1: HTQFP"]
50    Htqfp = 1,
51    #[doc = "2: BGA"]
52    Bga = 2,
53    #[doc = "3: HDQFP"]
54    Hdqfp = 3,
55    #[doc = "4: QFN"]
56    Qfn = 4,
57    #[doc = "5: CSP"]
58    Csp = 5,
59    #[doc = "6: LQFP"]
60    Lqfp = 6,
61}
62impl From<DeviceTypePkg> for u8 {
63    #[inline(always)]
64    fn from(variant: DeviceTypePkg) -> Self {
65        variant as _
66    }
67}
68impl crate::FieldSpec for DeviceTypePkg {
69    type Ux = u8;
70}
71impl crate::IsEnum for DeviceTypePkg {}
72#[doc = "Field `DEVICE_TYPE_PKG` reader - Indicates the device's package type"]
73pub type DeviceTypePkgR = crate::FieldReader<DeviceTypePkg>;
74impl DeviceTypePkgR {
75    #[doc = "Get enumerated values variant"]
76    #[inline(always)]
77    pub const fn variant(&self) -> Option<DeviceTypePkg> {
78        match self.bits {
79            0 => Some(DeviceTypePkg::Hlqfp),
80            1 => Some(DeviceTypePkg::Htqfp),
81            2 => Some(DeviceTypePkg::Bga),
82            3 => Some(DeviceTypePkg::Hdqfp),
83            4 => Some(DeviceTypePkg::Qfn),
84            5 => Some(DeviceTypePkg::Csp),
85            6 => Some(DeviceTypePkg::Lqfp),
86            _ => None,
87        }
88    }
89    #[doc = "HLQFP"]
90    #[inline(always)]
91    pub fn is_hlqfp(&self) -> bool {
92        *self == DeviceTypePkg::Hlqfp
93    }
94    #[doc = "HTQFP"]
95    #[inline(always)]
96    pub fn is_htqfp(&self) -> bool {
97        *self == DeviceTypePkg::Htqfp
98    }
99    #[doc = "BGA"]
100    #[inline(always)]
101    pub fn is_bga(&self) -> bool {
102        *self == DeviceTypePkg::Bga
103    }
104    #[doc = "HDQFP"]
105    #[inline(always)]
106    pub fn is_hdqfp(&self) -> bool {
107        *self == DeviceTypePkg::Hdqfp
108    }
109    #[doc = "QFN"]
110    #[inline(always)]
111    pub fn is_qfn(&self) -> bool {
112        *self == DeviceTypePkg::Qfn
113    }
114    #[doc = "CSP"]
115    #[inline(always)]
116    pub fn is_csp(&self) -> bool {
117        *self == DeviceTypePkg::Csp
118    }
119    #[doc = "LQFP"]
120    #[inline(always)]
121    pub fn is_lqfp(&self) -> bool {
122        *self == DeviceTypePkg::Lqfp
123    }
124}
125#[doc = "Field `DEVICE_TYPE_PIN` reader - Indicates the device's pin number"]
126pub type DeviceTypePinR = crate::FieldReader;
127impl R {
128    #[doc = "Bits 0:15 - Indicates the device part number"]
129    #[inline(always)]
130    pub fn device_type_num(&self) -> DeviceTypeNumR {
131        DeviceTypeNumR::new((self.bits & 0xffff) as u16)
132    }
133    #[doc = "Bit 16 - Indicates the device type"]
134    #[inline(always)]
135    pub fn device_type_sec(&self) -> DeviceTypeSecR {
136        DeviceTypeSecR::new(((self.bits >> 16) & 1) != 0)
137    }
138    #[doc = "Bits 20:23 - Indicates the device's package type"]
139    #[inline(always)]
140    pub fn device_type_pkg(&self) -> DeviceTypePkgR {
141        DeviceTypePkgR::new(((self.bits >> 20) & 0x0f) as u8)
142    }
143    #[doc = "Bits 24:31 - Indicates the device's pin number"]
144    #[inline(always)]
145    pub fn device_type_pin(&self) -> DeviceTypePinR {
146        DeviceTypePinR::new(((self.bits >> 24) & 0xff) as u8)
147    }
148}
149#[cfg(feature = "debug")]
150impl core::fmt::Debug for R {
151    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
152        f.debug_struct("DEVICE_TYPE")
153            .field("device_type_num", &self.device_type_num())
154            .field("device_type_sec", &self.device_type_sec())
155            .field("device_type_pkg", &self.device_type_pkg())
156            .field("device_type_pin", &self.device_type_pin())
157            .finish()
158    }
159}
160#[doc = "Device Type\n\nYou can [`read`](crate::Reg::read) this register and get [`device_type::R`](R). See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
161pub struct DeviceTypeSpec;
162impl crate::RegisterSpec for DeviceTypeSpec {
163    type Ux = u32;
164}
165#[doc = "`read()` method returns [`device_type::R`](R) reader structure"]
166impl crate::Readable for DeviceTypeSpec {}
167#[doc = "`reset()` method sets DEVICE_TYPE to value 0x2000"]
168impl crate::Resettable for DeviceTypeSpec {
169    const RESET_VALUE: u32 = 0x2000;
170}