rp2040_pac/xosc/
status.rs

1#[doc = "Register `STATUS` reader"]
2pub type R = crate::R<STATUS_SPEC>;
3#[doc = "Register `STATUS` writer"]
4pub type W = crate::W<STATUS_SPEC>;
5#[doc = "Field `FREQ_RANGE` reader - The current frequency range setting, always reads 0"]
6pub type FREQ_RANGE_R = crate::FieldReader<FREQ_RANGE_A>;
7#[doc = "The current frequency range setting, always reads 0  
8
9Value on reset: 0"]
10#[derive(Clone, Copy, Debug, PartialEq, Eq)]
11#[repr(u8)]
12pub enum FREQ_RANGE_A {
13    #[doc = "0: `0`"]
14    _1_15MHZ = 0,
15    #[doc = "1: `1`"]
16    RESERVED_1 = 1,
17    #[doc = "2: `10`"]
18    RESERVED_2 = 2,
19    #[doc = "3: `11`"]
20    RESERVED_3 = 3,
21}
22impl From<FREQ_RANGE_A> for u8 {
23    #[inline(always)]
24    fn from(variant: FREQ_RANGE_A) -> Self {
25        variant as _
26    }
27}
28impl crate::FieldSpec for FREQ_RANGE_A {
29    type Ux = u8;
30}
31impl FREQ_RANGE_R {
32    #[doc = "Get enumerated values variant"]
33    #[inline(always)]
34    pub const fn variant(&self) -> FREQ_RANGE_A {
35        match self.bits {
36            0 => FREQ_RANGE_A::_1_15MHZ,
37            1 => FREQ_RANGE_A::RESERVED_1,
38            2 => FREQ_RANGE_A::RESERVED_2,
39            3 => FREQ_RANGE_A::RESERVED_3,
40            _ => unreachable!(),
41        }
42    }
43    #[doc = "`0`"]
44    #[inline(always)]
45    pub fn is_1_15mhz(&self) -> bool {
46        *self == FREQ_RANGE_A::_1_15MHZ
47    }
48    #[doc = "`1`"]
49    #[inline(always)]
50    pub fn is_reserved_1(&self) -> bool {
51        *self == FREQ_RANGE_A::RESERVED_1
52    }
53    #[doc = "`10`"]
54    #[inline(always)]
55    pub fn is_reserved_2(&self) -> bool {
56        *self == FREQ_RANGE_A::RESERVED_2
57    }
58    #[doc = "`11`"]
59    #[inline(always)]
60    pub fn is_reserved_3(&self) -> bool {
61        *self == FREQ_RANGE_A::RESERVED_3
62    }
63}
64#[doc = "Field `ENABLED` reader - Oscillator is enabled but not necessarily running and stable, resets to 0"]
65pub type ENABLED_R = crate::BitReader;
66#[doc = "Field `BADWRITE` reader - An invalid value has been written to CTRL_ENABLE or CTRL_FREQ_RANGE or DORMANT"]
67pub type BADWRITE_R = crate::BitReader;
68#[doc = "Field `BADWRITE` writer - An invalid value has been written to CTRL_ENABLE or CTRL_FREQ_RANGE or DORMANT"]
69pub type BADWRITE_W<'a, REG> = crate::BitWriter1C<'a, REG>;
70#[doc = "Field `STABLE` reader - Oscillator is running and stable"]
71pub type STABLE_R = crate::BitReader;
72impl R {
73    #[doc = "Bits 0:1 - The current frequency range setting, always reads 0"]
74    #[inline(always)]
75    pub fn freq_range(&self) -> FREQ_RANGE_R {
76        FREQ_RANGE_R::new((self.bits & 3) as u8)
77    }
78    #[doc = "Bit 12 - Oscillator is enabled but not necessarily running and stable, resets to 0"]
79    #[inline(always)]
80    pub fn enabled(&self) -> ENABLED_R {
81        ENABLED_R::new(((self.bits >> 12) & 1) != 0)
82    }
83    #[doc = "Bit 24 - An invalid value has been written to CTRL_ENABLE or CTRL_FREQ_RANGE or DORMANT"]
84    #[inline(always)]
85    pub fn badwrite(&self) -> BADWRITE_R {
86        BADWRITE_R::new(((self.bits >> 24) & 1) != 0)
87    }
88    #[doc = "Bit 31 - Oscillator is running and stable"]
89    #[inline(always)]
90    pub fn stable(&self) -> STABLE_R {
91        STABLE_R::new(((self.bits >> 31) & 1) != 0)
92    }
93}
94impl W {
95    #[doc = "Bit 24 - An invalid value has been written to CTRL_ENABLE or CTRL_FREQ_RANGE or DORMANT"]
96    #[inline(always)]
97    #[must_use]
98    pub fn badwrite(&mut self) -> BADWRITE_W<STATUS_SPEC> {
99        BADWRITE_W::new(self, 24)
100    }
101    #[doc = r" Writes raw bits to the register."]
102    #[doc = r""]
103    #[doc = r" # Safety"]
104    #[doc = r""]
105    #[doc = r" Passing incorrect value can cause undefined behaviour. See reference manual"]
106    #[inline(always)]
107    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
108        self.bits = bits;
109        self
110    }
111}
112#[doc = "Crystal Oscillator Status  
113
114You can [`read`](crate::generic::Reg::read) this register and get [`status::R`](R).  You can [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero) this register using [`status::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
115pub struct STATUS_SPEC;
116impl crate::RegisterSpec for STATUS_SPEC {
117    type Ux = u32;
118}
119#[doc = "`read()` method returns [`status::R`](R) reader structure"]
120impl crate::Readable for STATUS_SPEC {}
121#[doc = "`write(|w| ..)` method takes [`status::W`](W) writer structure"]
122impl crate::Writable for STATUS_SPEC {
123    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
124    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0x0100_0000;
125}
126#[doc = "`reset()` method sets STATUS to value 0"]
127impl crate::Resettable for STATUS_SPEC {
128    const RESET_VALUE: u32 = 0;
129}