lpc845_pac/syscon/
frooscctrl.rs

1#[doc = "Register `FROOSCCTRL` reader"]
2pub struct R(crate::R<FROOSCCTRL_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<FROOSCCTRL_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<FROOSCCTRL_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<FROOSCCTRL_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `FROOSCCTRL` writer"]
17pub struct W(crate::W<FROOSCCTRL_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<FROOSCCTRL_SPEC>;
20    #[inline(always)]
21    fn deref(&self) -> &Self::Target {
22        &self.0
23    }
24}
25impl core::ops::DerefMut for W {
26    #[inline(always)]
27    fn deref_mut(&mut self) -> &mut Self::Target {
28        &mut self.0
29    }
30}
31impl From<crate::W<FROOSCCTRL_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<FROOSCCTRL_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "fro direct clock select\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39pub enum FRO_DIRECT_A {
40    #[doc = "0: fro clock is divider by 2 or 16,depend on FAIM slow boot value"]
41    DISABLED = 0,
42    #[doc = "1: fro clock is direct from FRO oscillator"]
43    ENABLED = 1,
44}
45impl From<FRO_DIRECT_A> for bool {
46    #[inline(always)]
47    fn from(variant: FRO_DIRECT_A) -> Self {
48        variant as u8 != 0
49    }
50}
51#[doc = "Field `FRO_DIRECT` reader - fro direct clock select"]
52pub struct FRO_DIRECT_R(crate::FieldReader<bool, FRO_DIRECT_A>);
53impl FRO_DIRECT_R {
54    pub(crate) fn new(bits: bool) -> Self {
55        FRO_DIRECT_R(crate::FieldReader::new(bits))
56    }
57    #[doc = r"Get enumerated values variant"]
58    #[inline(always)]
59    pub fn variant(&self) -> FRO_DIRECT_A {
60        match self.bits {
61            false => FRO_DIRECT_A::DISABLED,
62            true => FRO_DIRECT_A::ENABLED,
63        }
64    }
65    #[doc = "Checks if the value of the field is `DISABLED`"]
66    #[inline(always)]
67    pub fn is_disabled(&self) -> bool {
68        **self == FRO_DIRECT_A::DISABLED
69    }
70    #[doc = "Checks if the value of the field is `ENABLED`"]
71    #[inline(always)]
72    pub fn is_enabled(&self) -> bool {
73        **self == FRO_DIRECT_A::ENABLED
74    }
75}
76impl core::ops::Deref for FRO_DIRECT_R {
77    type Target = crate::FieldReader<bool, FRO_DIRECT_A>;
78    #[inline(always)]
79    fn deref(&self) -> &Self::Target {
80        &self.0
81    }
82}
83#[doc = "Field `FRO_DIRECT` writer - fro direct clock select"]
84pub struct FRO_DIRECT_W<'a> {
85    w: &'a mut W,
86}
87impl<'a> FRO_DIRECT_W<'a> {
88    #[doc = r"Writes `variant` to the field"]
89    #[inline(always)]
90    pub fn variant(self, variant: FRO_DIRECT_A) -> &'a mut W {
91        self.bit(variant.into())
92    }
93    #[doc = "fro clock is divider by 2 or 16,depend on FAIM slow boot value"]
94    #[inline(always)]
95    pub fn disabled(self) -> &'a mut W {
96        self.variant(FRO_DIRECT_A::DISABLED)
97    }
98    #[doc = "fro clock is direct from FRO oscillator"]
99    #[inline(always)]
100    pub fn enabled(self) -> &'a mut W {
101        self.variant(FRO_DIRECT_A::ENABLED)
102    }
103    #[doc = r"Sets the field bit"]
104    #[inline(always)]
105    pub fn set_bit(self) -> &'a mut W {
106        self.bit(true)
107    }
108    #[doc = r"Clears the field bit"]
109    #[inline(always)]
110    pub fn clear_bit(self) -> &'a mut W {
111        self.bit(false)
112    }
113    #[doc = r"Writes raw bits to the field"]
114    #[inline(always)]
115    pub fn bit(self, value: bool) -> &'a mut W {
116        self.w.bits = (self.w.bits & !(0x01 << 17)) | ((value as u32 & 0x01) << 17);
117        self.w
118    }
119}
120impl R {
121    #[doc = "Bit 17 - fro direct clock select"]
122    #[inline(always)]
123    pub fn fro_direct(&self) -> FRO_DIRECT_R {
124        FRO_DIRECT_R::new(((self.bits >> 17) & 0x01) != 0)
125    }
126}
127impl W {
128    #[doc = "Bit 17 - fro direct clock select"]
129    #[inline(always)]
130    pub fn fro_direct(&mut self) -> FRO_DIRECT_W {
131        FRO_DIRECT_W { w: self }
132    }
133    #[doc = "Writes raw bits to the register."]
134    #[inline(always)]
135    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
136        self.0.bits(bits);
137        self
138    }
139}
140#[doc = "FRO oscillator control\n\nThis register you can [`read`](crate::generic::Reg::read), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [frooscctrl](index.html) module"]
141pub struct FROOSCCTRL_SPEC;
142impl crate::RegisterSpec for FROOSCCTRL_SPEC {
143    type Ux = u32;
144}
145#[doc = "`read()` method returns [frooscctrl::R](R) reader structure"]
146impl crate::Readable for FROOSCCTRL_SPEC {
147    type Reader = R;
148}
149#[doc = "`write(|w| ..)` method takes [frooscctrl::W](W) writer structure"]
150impl crate::Writable for FROOSCCTRL_SPEC {
151    type Writer = W;
152}
153#[doc = "`reset()` method sets FROOSCCTRL to value 0"]
154impl crate::Resettable for FROOSCCTRL_SPEC {
155    #[inline(always)]
156    fn reset_value() -> Self::Ux {
157        0
158    }
159}