Skip to main content

mcxa_pac/scg0/
csr.rs

1#[doc = "Register `CSR` reader"]
2pub type R = crate::R<CsrSpec>;
3#[doc = "System Clock Source\n\nValue on reset: 3"]
4#[cfg_attr(feature = "defmt", derive(defmt::Format))]
5#[derive(Clone, Copy, Debug, PartialEq, Eq)]
6#[repr(u8)]
7pub enum Scs {
8    #[doc = "1: SOSC"]
9    Sosc = 1,
10    #[doc = "2: SIRC"]
11    Sirc = 2,
12    #[doc = "3: FIRC"]
13    Firc = 3,
14    #[doc = "4: ROSC"]
15    Rosc = 4,
16    #[doc = "6: SPLL"]
17    Spll = 6,
18}
19impl From<Scs> for u8 {
20    #[inline(always)]
21    fn from(variant: Scs) -> Self {
22        variant as _
23    }
24}
25impl crate::FieldSpec for Scs {
26    type Ux = u8;
27}
28impl crate::IsEnum for Scs {}
29#[doc = "Field `SCS` reader - System Clock Source"]
30pub type ScsR = crate::FieldReader<Scs>;
31impl ScsR {
32    #[doc = "Get enumerated values variant"]
33    #[inline(always)]
34    pub const fn variant(&self) -> Option<Scs> {
35        match self.bits {
36            1 => Some(Scs::Sosc),
37            2 => Some(Scs::Sirc),
38            3 => Some(Scs::Firc),
39            4 => Some(Scs::Rosc),
40            6 => Some(Scs::Spll),
41            _ => None,
42        }
43    }
44    #[doc = "SOSC"]
45    #[inline(always)]
46    pub fn is_sosc(&self) -> bool {
47        *self == Scs::Sosc
48    }
49    #[doc = "SIRC"]
50    #[inline(always)]
51    pub fn is_sirc(&self) -> bool {
52        *self == Scs::Sirc
53    }
54    #[doc = "FIRC"]
55    #[inline(always)]
56    pub fn is_firc(&self) -> bool {
57        *self == Scs::Firc
58    }
59    #[doc = "ROSC"]
60    #[inline(always)]
61    pub fn is_rosc(&self) -> bool {
62        *self == Scs::Rosc
63    }
64    #[doc = "SPLL"]
65    #[inline(always)]
66    pub fn is_spll(&self) -> bool {
67        *self == Scs::Spll
68    }
69}
70impl R {
71    #[doc = "Bits 24:26 - System Clock Source"]
72    #[inline(always)]
73    pub fn scs(&self) -> ScsR {
74        ScsR::new(((self.bits >> 24) & 7) as u8)
75    }
76}
77#[cfg(feature = "debug")]
78impl core::fmt::Debug for R {
79    fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
80        f.debug_struct("CSR").field("scs", &self.scs()).finish()
81    }
82}
83#[doc = "Clock Status Register\n\nYou can [`read`](crate::Reg::read) this register and get [`csr::R`](R). See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
84pub struct CsrSpec;
85impl crate::RegisterSpec for CsrSpec {
86    type Ux = u32;
87}
88#[doc = "`read()` method returns [`csr::R`](R) reader structure"]
89impl crate::Readable for CsrSpec {}
90#[doc = "`reset()` method sets CSR to value 0x0300_0000"]
91impl crate::Resettable for CsrSpec {
92    const RESET_VALUE: u32 = 0x0300_0000;
93}