nrf5340_app_pac/clock_ns/
hfclkstat.rs

1#[doc = "Register `HFCLKSTAT` reader"]
2pub struct R(crate::R<HFCLKSTAT_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<HFCLKSTAT_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<HFCLKSTAT_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<HFCLKSTAT_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Field `SRC` reader - Active clock source"]
17pub type SRC_R = crate::BitReader<SRC_A>;
18#[doc = "Active clock source\n\nValue on reset: 0"]
19#[derive(Clone, Copy, Debug, PartialEq)]
20pub enum SRC_A {
21    #[doc = "0: Clock source: HFINT - 128 MHz on-chip oscillator"]
22    HFINT = 0,
23    #[doc = "1: Clock source: HFXO - 128 MHz clock derived from external 32 MHz crystal oscillator"]
24    HFXO = 1,
25}
26impl From<SRC_A> for bool {
27    #[inline(always)]
28    fn from(variant: SRC_A) -> Self {
29        variant as u8 != 0
30    }
31}
32impl SRC_R {
33    #[doc = "Get enumerated values variant"]
34    #[inline(always)]
35    pub fn variant(&self) -> SRC_A {
36        match self.bits {
37            false => SRC_A::HFINT,
38            true => SRC_A::HFXO,
39        }
40    }
41    #[doc = "Checks if the value of the field is `HFINT`"]
42    #[inline(always)]
43    pub fn is_hfint(&self) -> bool {
44        *self == SRC_A::HFINT
45    }
46    #[doc = "Checks if the value of the field is `HFXO`"]
47    #[inline(always)]
48    pub fn is_hfxo(&self) -> bool {
49        *self == SRC_A::HFXO
50    }
51}
52#[doc = "Field `ALWAYSRUNNING` reader - ALWAYSRUN activated"]
53pub type ALWAYSRUNNING_R = crate::BitReader<ALWAYSRUNNING_A>;
54#[doc = "ALWAYSRUN activated\n\nValue on reset: 0"]
55#[derive(Clone, Copy, Debug, PartialEq)]
56pub enum ALWAYSRUNNING_A {
57    #[doc = "0: Automatic clock control enabled"]
58    NOT_RUNNING = 0,
59    #[doc = "1: Oscillator is always running"]
60    RUNNING = 1,
61}
62impl From<ALWAYSRUNNING_A> for bool {
63    #[inline(always)]
64    fn from(variant: ALWAYSRUNNING_A) -> Self {
65        variant as u8 != 0
66    }
67}
68impl ALWAYSRUNNING_R {
69    #[doc = "Get enumerated values variant"]
70    #[inline(always)]
71    pub fn variant(&self) -> ALWAYSRUNNING_A {
72        match self.bits {
73            false => ALWAYSRUNNING_A::NOT_RUNNING,
74            true => ALWAYSRUNNING_A::RUNNING,
75        }
76    }
77    #[doc = "Checks if the value of the field is `NOT_RUNNING`"]
78    #[inline(always)]
79    pub fn is_not_running(&self) -> bool {
80        *self == ALWAYSRUNNING_A::NOT_RUNNING
81    }
82    #[doc = "Checks if the value of the field is `RUNNING`"]
83    #[inline(always)]
84    pub fn is_running(&self) -> bool {
85        *self == ALWAYSRUNNING_A::RUNNING
86    }
87}
88#[doc = "Field `STATE` reader - HFCLK state"]
89pub type STATE_R = crate::BitReader<STATE_A>;
90#[doc = "HFCLK state\n\nValue on reset: 0"]
91#[derive(Clone, Copy, Debug, PartialEq)]
92pub enum STATE_A {
93    #[doc = "0: HFCLK not running"]
94    NOT_RUNNING = 0,
95    #[doc = "1: HFCLK running"]
96    RUNNING = 1,
97}
98impl From<STATE_A> for bool {
99    #[inline(always)]
100    fn from(variant: STATE_A) -> Self {
101        variant as u8 != 0
102    }
103}
104impl STATE_R {
105    #[doc = "Get enumerated values variant"]
106    #[inline(always)]
107    pub fn variant(&self) -> STATE_A {
108        match self.bits {
109            false => STATE_A::NOT_RUNNING,
110            true => STATE_A::RUNNING,
111        }
112    }
113    #[doc = "Checks if the value of the field is `NOT_RUNNING`"]
114    #[inline(always)]
115    pub fn is_not_running(&self) -> bool {
116        *self == STATE_A::NOT_RUNNING
117    }
118    #[doc = "Checks if the value of the field is `RUNNING`"]
119    #[inline(always)]
120    pub fn is_running(&self) -> bool {
121        *self == STATE_A::RUNNING
122    }
123}
124impl R {
125    #[doc = "Bit 0 - Active clock source"]
126    #[inline(always)]
127    pub fn src(&self) -> SRC_R {
128        SRC_R::new((self.bits & 1) != 0)
129    }
130    #[doc = "Bit 4 - ALWAYSRUN activated"]
131    #[inline(always)]
132    pub fn alwaysrunning(&self) -> ALWAYSRUNNING_R {
133        ALWAYSRUNNING_R::new(((self.bits >> 4) & 1) != 0)
134    }
135    #[doc = "Bit 16 - HFCLK state"]
136    #[inline(always)]
137    pub fn state(&self) -> STATE_R {
138        STATE_R::new(((self.bits >> 16) & 1) != 0)
139    }
140}
141#[doc = "Status indicating which HFCLK128M/HFCLK64M source is running This register value in any CLOCK instance reflects status only due to configurations/actions in that CLOCK instance.\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [hfclkstat](index.html) module"]
142pub struct HFCLKSTAT_SPEC;
143impl crate::RegisterSpec for HFCLKSTAT_SPEC {
144    type Ux = u32;
145}
146#[doc = "`read()` method returns [hfclkstat::R](R) reader structure"]
147impl crate::Readable for HFCLKSTAT_SPEC {
148    type Reader = R;
149}
150#[doc = "`reset()` method sets HFCLKSTAT to value 0"]
151impl crate::Resettable for HFCLKSTAT_SPEC {
152    #[inline(always)]
153    fn reset_value() -> Self::Ux {
154        0
155    }
156}