py32f0/py32f030/led/
cr.rs

1///Register `CR` reader
2pub struct R(crate::R<CR_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<CR_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<CR_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<CR_SPEC>) -> Self {
13        R(reader)
14    }
15}
16///Register `CR` writer
17pub struct W(crate::W<CR_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<CR_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<CR_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<CR_SPEC>) -> Self {
34        W(writer)
35    }
36}
37///Field `LEDON` reader - LED enable
38pub type LEDON_R = crate::BitReader<LEDON_A>;
39/**LED enable
40
41Value on reset: 0*/
42#[derive(Clone, Copy, Debug, PartialEq, Eq)]
43pub enum LEDON_A {
44    ///0: Disable LED controller
45    Disabled = 0,
46    ///1: Enable LED controller
47    Enabled = 1,
48}
49impl From<LEDON_A> for bool {
50    #[inline(always)]
51    fn from(variant: LEDON_A) -> Self {
52        variant as u8 != 0
53    }
54}
55impl LEDON_R {
56    ///Get enumerated values variant
57    #[inline(always)]
58    pub fn variant(&self) -> LEDON_A {
59        match self.bits {
60            false => LEDON_A::Disabled,
61            true => LEDON_A::Enabled,
62        }
63    }
64    ///Checks if the value of the field is `Disabled`
65    #[inline(always)]
66    pub fn is_disabled(&self) -> bool {
67        *self == LEDON_A::Disabled
68    }
69    ///Checks if the value of the field is `Enabled`
70    #[inline(always)]
71    pub fn is_enabled(&self) -> bool {
72        *self == LEDON_A::Enabled
73    }
74}
75///Field `LEDON` writer - LED enable
76pub type LEDON_W<'a, const O: u8> = crate::BitWriter<'a, u32, CR_SPEC, LEDON_A, O>;
77impl<'a, const O: u8> LEDON_W<'a, O> {
78    ///Disable LED controller
79    #[inline(always)]
80    pub fn disabled(self) -> &'a mut W {
81        self.variant(LEDON_A::Disabled)
82    }
83    ///Enable LED controller
84    #[inline(always)]
85    pub fn enabled(self) -> &'a mut W {
86        self.variant(LEDON_A::Enabled)
87    }
88}
89///Field `LED_COM_SEL` reader - LED COM Selection
90pub type LED_COM_SEL_R = crate::FieldReader<u8, LED_COM_SEL_A>;
91/**LED COM Selection
92
93Value on reset: 0*/
94#[derive(Clone, Copy, Debug, PartialEq, Eq)]
95#[repr(u8)]
96pub enum LED_COM_SEL_A {
97    ///0: One digit
98    OneDigit = 0,
99    ///1: Two digits sequentially
100    TwoDigits = 1,
101    ///2: Three digits sequentially
102    ThreeDigits = 2,
103    ///3: Four digits sequentially
104    FourDigits = 3,
105}
106impl From<LED_COM_SEL_A> for u8 {
107    #[inline(always)]
108    fn from(variant: LED_COM_SEL_A) -> Self {
109        variant as _
110    }
111}
112impl LED_COM_SEL_R {
113    ///Get enumerated values variant
114    #[inline(always)]
115    pub fn variant(&self) -> LED_COM_SEL_A {
116        match self.bits {
117            0 => LED_COM_SEL_A::OneDigit,
118            1 => LED_COM_SEL_A::TwoDigits,
119            2 => LED_COM_SEL_A::ThreeDigits,
120            3 => LED_COM_SEL_A::FourDigits,
121            _ => unreachable!(),
122        }
123    }
124    ///Checks if the value of the field is `OneDigit`
125    #[inline(always)]
126    pub fn is_one_digit(&self) -> bool {
127        *self == LED_COM_SEL_A::OneDigit
128    }
129    ///Checks if the value of the field is `TwoDigits`
130    #[inline(always)]
131    pub fn is_two_digits(&self) -> bool {
132        *self == LED_COM_SEL_A::TwoDigits
133    }
134    ///Checks if the value of the field is `ThreeDigits`
135    #[inline(always)]
136    pub fn is_three_digits(&self) -> bool {
137        *self == LED_COM_SEL_A::ThreeDigits
138    }
139    ///Checks if the value of the field is `FourDigits`
140    #[inline(always)]
141    pub fn is_four_digits(&self) -> bool {
142        *self == LED_COM_SEL_A::FourDigits
143    }
144}
145///Field `LED_COM_SEL` writer - LED COM Selection
146pub type LED_COM_SEL_W<'a, const O: u8> =
147    crate::FieldWriterSafe<'a, u32, CR_SPEC, u8, LED_COM_SEL_A, 2, O>;
148impl<'a, const O: u8> LED_COM_SEL_W<'a, O> {
149    ///One digit
150    #[inline(always)]
151    pub fn one_digit(self) -> &'a mut W {
152        self.variant(LED_COM_SEL_A::OneDigit)
153    }
154    ///Two digits sequentially
155    #[inline(always)]
156    pub fn two_digits(self) -> &'a mut W {
157        self.variant(LED_COM_SEL_A::TwoDigits)
158    }
159    ///Three digits sequentially
160    #[inline(always)]
161    pub fn three_digits(self) -> &'a mut W {
162        self.variant(LED_COM_SEL_A::ThreeDigits)
163    }
164    ///Four digits sequentially
165    #[inline(always)]
166    pub fn four_digits(self) -> &'a mut W {
167        self.variant(LED_COM_SEL_A::FourDigits)
168    }
169}
170///Field `IE` reader - LED interrupt enable
171pub type IE_R = crate::BitReader<IE_A>;
172/**LED interrupt enable
173
174Value on reset: 0*/
175#[derive(Clone, Copy, Debug, PartialEq, Eq)]
176pub enum IE_A {
177    ///0: Disable interrupt
178    Disabled = 0,
179    ///1: Enable interrupt
180    Enabled = 1,
181}
182impl From<IE_A> for bool {
183    #[inline(always)]
184    fn from(variant: IE_A) -> Self {
185        variant as u8 != 0
186    }
187}
188impl IE_R {
189    ///Get enumerated values variant
190    #[inline(always)]
191    pub fn variant(&self) -> IE_A {
192        match self.bits {
193            false => IE_A::Disabled,
194            true => IE_A::Enabled,
195        }
196    }
197    ///Checks if the value of the field is `Disabled`
198    #[inline(always)]
199    pub fn is_disabled(&self) -> bool {
200        *self == IE_A::Disabled
201    }
202    ///Checks if the value of the field is `Enabled`
203    #[inline(always)]
204    pub fn is_enabled(&self) -> bool {
205        *self == IE_A::Enabled
206    }
207}
208///Field `IE` writer - LED interrupt enable
209pub type IE_W<'a, const O: u8> = crate::BitWriter<'a, u32, CR_SPEC, IE_A, O>;
210impl<'a, const O: u8> IE_W<'a, O> {
211    ///Disable interrupt
212    #[inline(always)]
213    pub fn disabled(self) -> &'a mut W {
214        self.variant(IE_A::Disabled)
215    }
216    ///Enable interrupt
217    #[inline(always)]
218    pub fn enabled(self) -> &'a mut W {
219        self.variant(IE_A::Enabled)
220    }
221}
222///Field `EHS` reader - Light control
223pub type EHS_R = crate::FieldReader<u8, EHS_A>;
224/**Light control
225
226Value on reset: 0*/
227#[derive(Clone, Copy, Debug, PartialEq, Eq)]
228#[repr(u8)]
229pub enum EHS_A {
230    ///0: No COM output
231    NoComOutput = 0,
232    ///1: LED COM output high sink, driven level configured by GPIO_OSPEEDR
233    HighSink = 1,
234}
235impl From<EHS_A> for u8 {
236    #[inline(always)]
237    fn from(variant: EHS_A) -> Self {
238        variant as _
239    }
240}
241impl EHS_R {
242    ///Get enumerated values variant
243    #[inline(always)]
244    pub fn variant(&self) -> Option<EHS_A> {
245        match self.bits {
246            0 => Some(EHS_A::NoComOutput),
247            1 => Some(EHS_A::HighSink),
248            _ => None,
249        }
250    }
251    ///Checks if the value of the field is `NoComOutput`
252    #[inline(always)]
253    pub fn is_no_com_output(&self) -> bool {
254        *self == EHS_A::NoComOutput
255    }
256    ///Checks if the value of the field is `HighSink`
257    #[inline(always)]
258    pub fn is_high_sink(&self) -> bool {
259        *self == EHS_A::HighSink
260    }
261}
262///Field `EHS` writer - Light control
263pub type EHS_W<'a, const O: u8> = crate::FieldWriter<'a, u32, CR_SPEC, u8, EHS_A, 2, O>;
264impl<'a, const O: u8> EHS_W<'a, O> {
265    ///No COM output
266    #[inline(always)]
267    pub fn no_com_output(self) -> &'a mut W {
268        self.variant(EHS_A::NoComOutput)
269    }
270    ///LED COM output high sink, driven level configured by GPIO_OSPEEDR
271    #[inline(always)]
272    pub fn high_sink(self) -> &'a mut W {
273        self.variant(EHS_A::HighSink)
274    }
275}
276impl R {
277    ///Bit 0 - LED enable
278    #[inline(always)]
279    pub fn ledon(&self) -> LEDON_R {
280        LEDON_R::new((self.bits & 1) != 0)
281    }
282    ///Bits 1:2 - LED COM Selection
283    #[inline(always)]
284    pub fn led_com_sel(&self) -> LED_COM_SEL_R {
285        LED_COM_SEL_R::new(((self.bits >> 1) & 3) as u8)
286    }
287    ///Bit 3 - LED interrupt enable
288    #[inline(always)]
289    pub fn ie(&self) -> IE_R {
290        IE_R::new(((self.bits >> 3) & 1) != 0)
291    }
292    ///Bits 12:13 - Light control
293    #[inline(always)]
294    pub fn ehs(&self) -> EHS_R {
295        EHS_R::new(((self.bits >> 12) & 3) as u8)
296    }
297}
298impl W {
299    ///Bit 0 - LED enable
300    #[inline(always)]
301    #[must_use]
302    pub fn ledon(&mut self) -> LEDON_W<0> {
303        LEDON_W::new(self)
304    }
305    ///Bits 1:2 - LED COM Selection
306    #[inline(always)]
307    #[must_use]
308    pub fn led_com_sel(&mut self) -> LED_COM_SEL_W<1> {
309        LED_COM_SEL_W::new(self)
310    }
311    ///Bit 3 - LED interrupt enable
312    #[inline(always)]
313    #[must_use]
314    pub fn ie(&mut self) -> IE_W<3> {
315        IE_W::new(self)
316    }
317    ///Bits 12:13 - Light control
318    #[inline(always)]
319    #[must_use]
320    pub fn ehs(&mut self) -> EHS_W<12> {
321        EHS_W::new(self)
322    }
323    ///Writes raw bits to the register.
324    #[inline(always)]
325    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
326        self.0.bits(bits);
327        self
328    }
329}
330/**Control register
331
332This 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).
333
334For information about available fields see [cr](index.html) module*/
335pub struct CR_SPEC;
336impl crate::RegisterSpec for CR_SPEC {
337    type Ux = u32;
338}
339///`read()` method returns [cr::R](R) reader structure
340impl crate::Readable for CR_SPEC {
341    type Reader = R;
342}
343///`write(|w| ..)` method takes [cr::W](W) writer structure
344impl crate::Writable for CR_SPEC {
345    type Writer = W;
346    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
347    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
348}
349///`reset()` method sets CR to value 0
350impl crate::Resettable for CR_SPEC {
351    const RESET_VALUE: Self::Ux = 0;
352}