eos_s3/cru/
cru_general.rs1#[doc = "Register `CRU_GENERAL` reader"]
2pub struct R(crate::R<CRU_GENERAL_SPEC>);
3impl core::ops::Deref for R {
4 type Target = crate::R<CRU_GENERAL_SPEC>;
5 #[inline(always)]
6 fn deref(&self) -> &Self::Target {
7 &self.0
8 }
9}
10impl From<crate::R<CRU_GENERAL_SPEC>> for R {
11 #[inline(always)]
12 fn from(reader: crate::R<CRU_GENERAL_SPEC>) -> Self {
13 R(reader)
14 }
15}
16#[doc = "Register `CRU_GENERAL` writer"]
17pub struct W(crate::W<CRU_GENERAL_SPEC>);
18impl core::ops::Deref for W {
19 type Target = crate::W<CRU_GENERAL_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<CRU_GENERAL_SPEC>> for W {
32 #[inline(always)]
33 fn from(writer: crate::W<CRU_GENERAL_SPEC>) -> Self {
34 W(writer)
35 }
36}
37#[doc = "Controls wether the SPI clock is always on or not\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39pub enum SPICLK_ALWAYS_ON_A {
40 #[doc = "0: Internal SPI Clock (C00) will be gated off if SPI CS is de-asserted even SPI Clock on the PAD is still running."]
41 ALWAYS_OFF = 0,
42 #[doc = "1: Internal SPIC Clock (C00) is running if SPI Clock on the PAD is toggling regardless of SPI CS value."]
43 ALWAYS_ON = 1,
44}
45impl From<SPICLK_ALWAYS_ON_A> for bool {
46 #[inline(always)]
47 fn from(variant: SPICLK_ALWAYS_ON_A) -> Self {
48 variant as u8 != 0
49 }
50}
51#[doc = "Field `SPICLK_ALWAYS_ON` reader - Controls wether the SPI clock is always on or not"]
52pub struct SPICLK_ALWAYS_ON_R(crate::FieldReader<bool, SPICLK_ALWAYS_ON_A>);
53impl SPICLK_ALWAYS_ON_R {
54 #[inline(always)]
55 pub(crate) fn new(bits: bool) -> Self {
56 SPICLK_ALWAYS_ON_R(crate::FieldReader::new(bits))
57 }
58 #[doc = r"Get enumerated values variant"]
59 #[inline(always)]
60 pub fn variant(&self) -> SPICLK_ALWAYS_ON_A {
61 match self.bits {
62 false => SPICLK_ALWAYS_ON_A::ALWAYS_OFF,
63 true => SPICLK_ALWAYS_ON_A::ALWAYS_ON,
64 }
65 }
66 #[doc = "Checks if the value of the field is `ALWAYS_OFF`"]
67 #[inline(always)]
68 pub fn is_always_off(&self) -> bool {
69 **self == SPICLK_ALWAYS_ON_A::ALWAYS_OFF
70 }
71 #[doc = "Checks if the value of the field is `ALWAYS_ON`"]
72 #[inline(always)]
73 pub fn is_always_on(&self) -> bool {
74 **self == SPICLK_ALWAYS_ON_A::ALWAYS_ON
75 }
76}
77impl core::ops::Deref for SPICLK_ALWAYS_ON_R {
78 type Target = crate::FieldReader<bool, SPICLK_ALWAYS_ON_A>;
79 #[inline(always)]
80 fn deref(&self) -> &Self::Target {
81 &self.0
82 }
83}
84#[doc = "Field `SPICLK_ALWAYS_ON` writer - Controls wether the SPI clock is always on or not"]
85pub struct SPICLK_ALWAYS_ON_W<'a> {
86 w: &'a mut W,
87}
88impl<'a> SPICLK_ALWAYS_ON_W<'a> {
89 #[doc = r"Writes `variant` to the field"]
90 #[inline(always)]
91 pub fn variant(self, variant: SPICLK_ALWAYS_ON_A) -> &'a mut W {
92 self.bit(variant.into())
93 }
94 #[doc = "Internal SPI Clock (C00) will be gated off if SPI CS is de-asserted even SPI Clock on the PAD is still running."]
95 #[inline(always)]
96 pub fn always_off(self) -> &'a mut W {
97 self.variant(SPICLK_ALWAYS_ON_A::ALWAYS_OFF)
98 }
99 #[doc = "Internal SPIC Clock (C00) is running if SPI Clock on the PAD is toggling regardless of SPI CS value."]
100 #[inline(always)]
101 pub fn always_on(self) -> &'a mut W {
102 self.variant(SPICLK_ALWAYS_ON_A::ALWAYS_ON)
103 }
104 #[doc = r"Sets the field bit"]
105 #[inline(always)]
106 pub fn set_bit(self) -> &'a mut W {
107 self.bit(true)
108 }
109 #[doc = r"Clears the field bit"]
110 #[inline(always)]
111 pub fn clear_bit(self) -> &'a mut W {
112 self.bit(false)
113 }
114 #[doc = r"Writes raw bits to the field"]
115 #[inline(always)]
116 pub fn bit(self, value: bool) -> &'a mut W {
117 self.w.bits = (self.w.bits & !0x01) | (value as u32 & 0x01);
118 self.w
119 }
120}
121#[doc = "Field `General` reader - General purpose register"]
122pub struct GENERAL_R(crate::FieldReader<u8, u8>);
123impl GENERAL_R {
124 #[inline(always)]
125 pub(crate) fn new(bits: u8) -> Self {
126 GENERAL_R(crate::FieldReader::new(bits))
127 }
128}
129impl core::ops::Deref for GENERAL_R {
130 type Target = crate::FieldReader<u8, u8>;
131 #[inline(always)]
132 fn deref(&self) -> &Self::Target {
133 &self.0
134 }
135}
136#[doc = "Field `General` writer - General purpose register"]
137pub struct GENERAL_W<'a> {
138 w: &'a mut W,
139}
140impl<'a> GENERAL_W<'a> {
141 #[doc = r"Writes raw bits to the field"]
142 #[inline(always)]
143 pub unsafe fn bits(self, value: u8) -> &'a mut W {
144 self.w.bits =
145 (self.w.bits & !(0x7f << 1)) | ((value as u32 & 0x7f) << 1);
146 self.w
147 }
148}
149impl R {
150 #[doc = "Bit 0 - Controls wether the SPI clock is always on or not"]
151 #[inline(always)]
152 pub fn spiclk_always_on(&self) -> SPICLK_ALWAYS_ON_R {
153 SPICLK_ALWAYS_ON_R::new((self.bits & 0x01) != 0)
154 }
155 #[doc = "Bits 1:7 - General purpose register"]
156 #[inline(always)]
157 pub fn general(&self) -> GENERAL_R {
158 GENERAL_R::new(((self.bits >> 1) & 0x7f) as u8)
159 }
160}
161impl W {
162 #[doc = "Bit 0 - Controls wether the SPI clock is always on or not"]
163 #[inline(always)]
164 pub fn spiclk_always_on(&mut self) -> SPICLK_ALWAYS_ON_W {
165 SPICLK_ALWAYS_ON_W { w: self }
166 }
167 #[doc = "Bits 1:7 - General purpose register"]
168 #[inline(always)]
169 pub fn general(&mut self) -> GENERAL_W {
170 GENERAL_W { w: self }
171 }
172 #[doc = "Writes raw bits to the register."]
173 #[inline(always)]
174 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
175 self.0.bits(bits);
176 self
177 }
178}
179#[doc = "General reg and SPI ALWAYS ON 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 [cru_general](index.html) module"]
180pub struct CRU_GENERAL_SPEC;
181impl crate::RegisterSpec for CRU_GENERAL_SPEC {
182 type Ux = u32;
183}
184#[doc = "`read()` method returns [cru_general::R](R) reader structure"]
185impl crate::Readable for CRU_GENERAL_SPEC {
186 type Reader = R;
187}
188#[doc = "`write(|w| ..)` method takes [cru_general::W](W) writer structure"]
189impl crate::Writable for CRU_GENERAL_SPEC {
190 type Writer = W;
191}
192#[doc = "`reset()` method sets CRU_GENERAL to value 0"]
193impl crate::Resettable for CRU_GENERAL_SPEC {
194 #[inline(always)]
195 fn reset_value() -> Self::Ux {
196 0
197 }
198}