1#[doc = "Register `ledc_ctrl` reader"]
2pub type R = crate::R<LEDC_CTRL_SPEC>;
3#[doc = "Register `ledc_ctrl` writer"]
4pub type W = crate::W<LEDC_CTRL_SPEC>;
5#[doc = "Field `ledc_en` reader - "]
6pub type LEDC_EN_R = crate::BitReader<LEDC_EN_A>;
7#[doc = "\n\nValue on reset: 0"]
8#[derive(Clone, Copy, Debug, PartialEq, Eq)]
9pub enum LEDC_EN_A {
10 #[doc = "0: `0`"]
11 DISABLE = 0,
12 #[doc = "1: `1`"]
13 ENABLE = 1,
14}
15impl From<LEDC_EN_A> for bool {
16 #[inline(always)]
17 fn from(variant: LEDC_EN_A) -> Self {
18 variant as u8 != 0
19 }
20}
21impl LEDC_EN_R {
22 #[doc = "Get enumerated values variant"]
23 #[inline(always)]
24 pub const fn variant(&self) -> LEDC_EN_A {
25 match self.bits {
26 false => LEDC_EN_A::DISABLE,
27 true => LEDC_EN_A::ENABLE,
28 }
29 }
30 #[doc = "`0`"]
31 #[inline(always)]
32 pub fn is_disable(&self) -> bool {
33 *self == LEDC_EN_A::DISABLE
34 }
35 #[doc = "`1`"]
36 #[inline(always)]
37 pub fn is_enable(&self) -> bool {
38 *self == LEDC_EN_A::ENABLE
39 }
40}
41#[doc = "Field `ledc_en` writer - "]
42pub type LEDC_EN_W<'a, REG> = crate::BitWriter<'a, REG, LEDC_EN_A>;
43impl<'a, REG> LEDC_EN_W<'a, REG>
44where
45 REG: crate::Writable + crate::RegisterSpec,
46{
47 #[doc = "`0`"]
48 #[inline(always)]
49 pub fn disable(self) -> &'a mut crate::W<REG> {
50 self.variant(LEDC_EN_A::DISABLE)
51 }
52 #[doc = "`1`"]
53 #[inline(always)]
54 pub fn enable(self) -> &'a mut crate::W<REG> {
55 self.variant(LEDC_EN_A::ENABLE)
56 }
57}
58#[doc = "Field `ledc_soft_reset` reader - "]
59pub type LEDC_SOFT_RESET_R = crate::BitReader;
60#[doc = "Field `ledc_soft_reset` writer - "]
61pub type LEDC_SOFT_RESET_W<'a, REG> = crate::BitWriter<'a, REG>;
62#[doc = "Field `led_msb_[B,R,G,TOP]` reader - "]
63pub type LED_MSB__R = crate::BitReader<LED_MSB__A>;
64#[doc = "\n\nValue on reset: 0"]
65#[derive(Clone, Copy, Debug, PartialEq, Eq)]
66pub enum LED_MSB__A {
67 #[doc = "0: `0`"]
68 LSB = 0,
69 #[doc = "1: `1`"]
70 MSB = 1,
71}
72impl From<LED_MSB__A> for bool {
73 #[inline(always)]
74 fn from(variant: LED_MSB__A) -> Self {
75 variant as u8 != 0
76 }
77}
78impl LED_MSB__R {
79 #[doc = "Get enumerated values variant"]
80 #[inline(always)]
81 pub const fn variant(&self) -> LED_MSB__A {
82 match self.bits {
83 false => LED_MSB__A::LSB,
84 true => LED_MSB__A::MSB,
85 }
86 }
87 #[doc = "`0`"]
88 #[inline(always)]
89 pub fn is_lsb(&self) -> bool {
90 *self == LED_MSB__A::LSB
91 }
92 #[doc = "`1`"]
93 #[inline(always)]
94 pub fn is_msb(&self) -> bool {
95 *self == LED_MSB__A::MSB
96 }
97}
98#[doc = "Field `led_msb_[B,R,G,TOP]` writer - "]
99pub type LED_MSB__W<'a, REG> = crate::BitWriter<'a, REG, LED_MSB__A>;
100impl<'a, REG> LED_MSB__W<'a, REG>
101where
102 REG: crate::Writable + crate::RegisterSpec,
103{
104 #[doc = "`0`"]
105 #[inline(always)]
106 pub fn lsb(self) -> &'a mut crate::W<REG> {
107 self.variant(LED_MSB__A::LSB)
108 }
109 #[doc = "`1`"]
110 #[inline(always)]
111 pub fn msb(self) -> &'a mut crate::W<REG> {
112 self.variant(LED_MSB__A::MSB)
113 }
114}
115#[doc = "Field `led_rgb_mode` reader - "]
116pub type LED_RGB_MODE_R = crate::FieldReader<LED_RGB_MODE_A>;
117#[doc = "\n\nValue on reset: 0"]
118#[derive(Clone, Copy, Debug, PartialEq, Eq)]
119#[repr(u8)]
120pub enum LED_RGB_MODE_A {
121 #[doc = "0: `0`"]
122 GRB = 0,
123 #[doc = "1: `1`"]
124 GBR = 1,
125 #[doc = "2: `10`"]
126 RGB = 2,
127 #[doc = "3: `11`"]
128 RBG = 3,
129 #[doc = "4: `100`"]
130 BGR = 4,
131 #[doc = "5: `101`"]
132 BRG = 5,
133}
134impl From<LED_RGB_MODE_A> for u8 {
135 #[inline(always)]
136 fn from(variant: LED_RGB_MODE_A) -> Self {
137 variant as _
138 }
139}
140impl crate::FieldSpec for LED_RGB_MODE_A {
141 type Ux = u8;
142}
143impl LED_RGB_MODE_R {
144 #[doc = "Get enumerated values variant"]
145 #[inline(always)]
146 pub const fn variant(&self) -> Option<LED_RGB_MODE_A> {
147 match self.bits {
148 0 => Some(LED_RGB_MODE_A::GRB),
149 1 => Some(LED_RGB_MODE_A::GBR),
150 2 => Some(LED_RGB_MODE_A::RGB),
151 3 => Some(LED_RGB_MODE_A::RBG),
152 4 => Some(LED_RGB_MODE_A::BGR),
153 5 => Some(LED_RGB_MODE_A::BRG),
154 _ => None,
155 }
156 }
157 #[doc = "`0`"]
158 #[inline(always)]
159 pub fn is_grb(&self) -> bool {
160 *self == LED_RGB_MODE_A::GRB
161 }
162 #[doc = "`1`"]
163 #[inline(always)]
164 pub fn is_gbr(&self) -> bool {
165 *self == LED_RGB_MODE_A::GBR
166 }
167 #[doc = "`10`"]
168 #[inline(always)]
169 pub fn is_rgb(&self) -> bool {
170 *self == LED_RGB_MODE_A::RGB
171 }
172 #[doc = "`11`"]
173 #[inline(always)]
174 pub fn is_rbg(&self) -> bool {
175 *self == LED_RGB_MODE_A::RBG
176 }
177 #[doc = "`100`"]
178 #[inline(always)]
179 pub fn is_bgr(&self) -> bool {
180 *self == LED_RGB_MODE_A::BGR
181 }
182 #[doc = "`101`"]
183 #[inline(always)]
184 pub fn is_brg(&self) -> bool {
185 *self == LED_RGB_MODE_A::BRG
186 }
187}
188#[doc = "Field `led_rgb_mode` writer - "]
189pub type LED_RGB_MODE_W<'a, REG> = crate::FieldWriter<'a, REG, 3, LED_RGB_MODE_A>;
190impl<'a, REG> LED_RGB_MODE_W<'a, REG>
191where
192 REG: crate::Writable + crate::RegisterSpec,
193 REG::Ux: From<u8>,
194{
195 #[doc = "`0`"]
196 #[inline(always)]
197 pub fn grb(self) -> &'a mut crate::W<REG> {
198 self.variant(LED_RGB_MODE_A::GRB)
199 }
200 #[doc = "`1`"]
201 #[inline(always)]
202 pub fn gbr(self) -> &'a mut crate::W<REG> {
203 self.variant(LED_RGB_MODE_A::GBR)
204 }
205 #[doc = "`10`"]
206 #[inline(always)]
207 pub fn rgb(self) -> &'a mut crate::W<REG> {
208 self.variant(LED_RGB_MODE_A::RGB)
209 }
210 #[doc = "`11`"]
211 #[inline(always)]
212 pub fn rbg(self) -> &'a mut crate::W<REG> {
213 self.variant(LED_RGB_MODE_A::RBG)
214 }
215 #[doc = "`100`"]
216 #[inline(always)]
217 pub fn bgr(self) -> &'a mut crate::W<REG> {
218 self.variant(LED_RGB_MODE_A::BGR)
219 }
220 #[doc = "`101`"]
221 #[inline(always)]
222 pub fn brg(self) -> &'a mut crate::W<REG> {
223 self.variant(LED_RGB_MODE_A::BRG)
224 }
225}
226#[doc = "Field `reset_led_en` reader - "]
227pub type RESET_LED_EN_R = crate::BitReader;
228#[doc = "Field `reset_led_en` writer - "]
229pub type RESET_LED_EN_W<'a, REG> = crate::BitWriter<'a, REG>;
230#[doc = "Field `total_data_length` reader - "]
231pub type TOTAL_DATA_LENGTH_R = crate::FieldReader<u16>;
232#[doc = "Field `total_data_length` writer - "]
233pub type TOTAL_DATA_LENGTH_W<'a, REG> = crate::FieldWriter<'a, REG, 13, u16>;
234impl R {
235 #[doc = "Bit 0"]
236 #[inline(always)]
237 pub fn ledc_en(&self) -> LEDC_EN_R {
238 LEDC_EN_R::new((self.bits & 1) != 0)
239 }
240 #[doc = "Bit 1"]
241 #[inline(always)]
242 pub fn ledc_soft_reset(&self) -> LEDC_SOFT_RESET_R {
243 LEDC_SOFT_RESET_R::new(((self.bits >> 1) & 1) != 0)
244 }
245 #[doc = "\n\nNOTE: `n` is number of field in register. `n == 0` corresponds to `led_msb_B` field"]
246 #[inline(always)]
247 pub fn led_msb_(&self, n: u8) -> LED_MSB__R {
248 #[allow(clippy::no_effect)]
249 [(); 4][n as usize];
250 LED_MSB__R::new(((self.bits >> (n + 2)) & 1) != 0)
251 }
252 #[doc = "Bit 2 - led_msb_B"]
253 #[inline(always)]
254 pub fn led_msb_b(&self) -> LED_MSB__R {
255 LED_MSB__R::new(((self.bits >> 2) & 1) != 0)
256 }
257 #[doc = "Bit 3 - led_msb_R"]
258 #[inline(always)]
259 pub fn led_msb_r(&self) -> LED_MSB__R {
260 LED_MSB__R::new(((self.bits >> 3) & 1) != 0)
261 }
262 #[doc = "Bit 4 - led_msb_G"]
263 #[inline(always)]
264 pub fn led_msb_g(&self) -> LED_MSB__R {
265 LED_MSB__R::new(((self.bits >> 4) & 1) != 0)
266 }
267 #[doc = "Bit 5 - led_msb_TOP"]
268 #[inline(always)]
269 pub fn led_msb_top(&self) -> LED_MSB__R {
270 LED_MSB__R::new(((self.bits >> 5) & 1) != 0)
271 }
272 #[doc = "Bits 6:8"]
273 #[inline(always)]
274 pub fn led_rgb_mode(&self) -> LED_RGB_MODE_R {
275 LED_RGB_MODE_R::new(((self.bits >> 6) & 7) as u8)
276 }
277 #[doc = "Bit 10"]
278 #[inline(always)]
279 pub fn reset_led_en(&self) -> RESET_LED_EN_R {
280 RESET_LED_EN_R::new(((self.bits >> 10) & 1) != 0)
281 }
282 #[doc = "Bits 16:28"]
283 #[inline(always)]
284 pub fn total_data_length(&self) -> TOTAL_DATA_LENGTH_R {
285 TOTAL_DATA_LENGTH_R::new(((self.bits >> 16) & 0x1fff) as u16)
286 }
287}
288impl W {
289 #[doc = "Bit 0"]
290 #[inline(always)]
291 #[must_use]
292 pub fn ledc_en(&mut self) -> LEDC_EN_W<LEDC_CTRL_SPEC> {
293 LEDC_EN_W::new(self, 0)
294 }
295 #[doc = "Bit 1"]
296 #[inline(always)]
297 #[must_use]
298 pub fn ledc_soft_reset(&mut self) -> LEDC_SOFT_RESET_W<LEDC_CTRL_SPEC> {
299 LEDC_SOFT_RESET_W::new(self, 1)
300 }
301 #[doc = "\n\nNOTE: `n` is number of field in register. `n == 0` corresponds to `led_msb_B` field"]
302 #[inline(always)]
303 #[must_use]
304 pub fn led_msb_(&mut self, n: u8) -> LED_MSB__W<LEDC_CTRL_SPEC> {
305 #[allow(clippy::no_effect)]
306 [(); 4][n as usize];
307 LED_MSB__W::new(self, n + 2)
308 }
309 #[doc = "Bit 2 - led_msb_B"]
310 #[inline(always)]
311 #[must_use]
312 pub fn led_msb_b(&mut self) -> LED_MSB__W<LEDC_CTRL_SPEC> {
313 LED_MSB__W::new(self, 2)
314 }
315 #[doc = "Bit 3 - led_msb_R"]
316 #[inline(always)]
317 #[must_use]
318 pub fn led_msb_r(&mut self) -> LED_MSB__W<LEDC_CTRL_SPEC> {
319 LED_MSB__W::new(self, 3)
320 }
321 #[doc = "Bit 4 - led_msb_G"]
322 #[inline(always)]
323 #[must_use]
324 pub fn led_msb_g(&mut self) -> LED_MSB__W<LEDC_CTRL_SPEC> {
325 LED_MSB__W::new(self, 4)
326 }
327 #[doc = "Bit 5 - led_msb_TOP"]
328 #[inline(always)]
329 #[must_use]
330 pub fn led_msb_top(&mut self) -> LED_MSB__W<LEDC_CTRL_SPEC> {
331 LED_MSB__W::new(self, 5)
332 }
333 #[doc = "Bits 6:8"]
334 #[inline(always)]
335 #[must_use]
336 pub fn led_rgb_mode(&mut self) -> LED_RGB_MODE_W<LEDC_CTRL_SPEC> {
337 LED_RGB_MODE_W::new(self, 6)
338 }
339 #[doc = "Bit 10"]
340 #[inline(always)]
341 #[must_use]
342 pub fn reset_led_en(&mut self) -> RESET_LED_EN_W<LEDC_CTRL_SPEC> {
343 RESET_LED_EN_W::new(self, 10)
344 }
345 #[doc = "Bits 16:28"]
346 #[inline(always)]
347 #[must_use]
348 pub fn total_data_length(&mut self) -> TOTAL_DATA_LENGTH_W<LEDC_CTRL_SPEC> {
349 TOTAL_DATA_LENGTH_W::new(self, 16)
350 }
351 #[doc = r" Writes raw bits to the register."]
352 #[doc = r""]
353 #[doc = r" # Safety"]
354 #[doc = r""]
355 #[doc = r" Passing incorrect value can cause undefined behaviour. See reference manual"]
356 #[inline(always)]
357 pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
358 self.bits = bits;
359 self
360 }
361}
362#[doc = "LEDC Control Register\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`ledc_ctrl::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 [`ledc_ctrl::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
363pub struct LEDC_CTRL_SPEC;
364impl crate::RegisterSpec for LEDC_CTRL_SPEC {
365 type Ux = u32;
366}
367#[doc = "`read()` method returns [`ledc_ctrl::R`](R) reader structure"]
368impl crate::Readable for LEDC_CTRL_SPEC {}
369#[doc = "`write(|w| ..)` method takes [`ledc_ctrl::W`](W) writer structure"]
370impl crate::Writable for LEDC_CTRL_SPEC {
371 const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
372 const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
373}
374#[doc = "`reset()` method sets ledc_ctrl to value 0"]
375impl crate::Resettable for LEDC_CTRL_SPEC {
376 const RESET_VALUE: Self::Ux = 0;
377}