py32f0/py32f003/i2c/
cr1.rs

1///Register `CR1` reader
2pub struct R(crate::R<CR1_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<CR1_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<CR1_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<CR1_SPEC>) -> Self {
13        R(reader)
14    }
15}
16///Register `CR1` writer
17pub struct W(crate::W<CR1_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<CR1_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<CR1_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<CR1_SPEC>) -> Self {
34        W(writer)
35    }
36}
37///Field `PE` reader - Peripheral enable
38pub type PE_R = crate::BitReader<PE_A>;
39/**Peripheral enable
40
41Value on reset: 0*/
42#[derive(Clone, Copy, Debug, PartialEq, Eq)]
43pub enum PE_A {
44    ///0: Peripheral disabled
45    Disabled = 0,
46    ///1: Peripheral enabled
47    Enabled = 1,
48}
49impl From<PE_A> for bool {
50    #[inline(always)]
51    fn from(variant: PE_A) -> Self {
52        variant as u8 != 0
53    }
54}
55impl PE_R {
56    ///Get enumerated values variant
57    #[inline(always)]
58    pub fn variant(&self) -> PE_A {
59        match self.bits {
60            false => PE_A::Disabled,
61            true => PE_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 == PE_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 == PE_A::Enabled
73    }
74}
75///Field `PE` writer - Peripheral enable
76pub type PE_W<'a, const O: u8> = crate::BitWriter<'a, u32, CR1_SPEC, PE_A, O>;
77impl<'a, const O: u8> PE_W<'a, O> {
78    ///Peripheral disabled
79    #[inline(always)]
80    pub fn disabled(self) -> &'a mut W {
81        self.variant(PE_A::Disabled)
82    }
83    ///Peripheral enabled
84    #[inline(always)]
85    pub fn enabled(self) -> &'a mut W {
86        self.variant(PE_A::Enabled)
87    }
88}
89///Field `ENPEC` reader - PEC enable
90pub type ENPEC_R = crate::BitReader<bool>;
91///Field `ENPEC` writer - PEC enable
92pub type ENPEC_W<'a, const O: u8> = crate::BitWriter<'a, u32, CR1_SPEC, bool, O>;
93///Field `ENGC` reader - General call enable
94pub type ENGC_R = crate::BitReader<ENGC_A>;
95/**General call enable
96
97Value on reset: 0*/
98#[derive(Clone, Copy, Debug, PartialEq, Eq)]
99pub enum ENGC_A {
100    ///0: General call disabled
101    Disabled = 0,
102    ///1: General call enabled
103    Enabled = 1,
104}
105impl From<ENGC_A> for bool {
106    #[inline(always)]
107    fn from(variant: ENGC_A) -> Self {
108        variant as u8 != 0
109    }
110}
111impl ENGC_R {
112    ///Get enumerated values variant
113    #[inline(always)]
114    pub fn variant(&self) -> ENGC_A {
115        match self.bits {
116            false => ENGC_A::Disabled,
117            true => ENGC_A::Enabled,
118        }
119    }
120    ///Checks if the value of the field is `Disabled`
121    #[inline(always)]
122    pub fn is_disabled(&self) -> bool {
123        *self == ENGC_A::Disabled
124    }
125    ///Checks if the value of the field is `Enabled`
126    #[inline(always)]
127    pub fn is_enabled(&self) -> bool {
128        *self == ENGC_A::Enabled
129    }
130}
131///Field `ENGC` writer - General call enable
132pub type ENGC_W<'a, const O: u8> = crate::BitWriter<'a, u32, CR1_SPEC, ENGC_A, O>;
133impl<'a, const O: u8> ENGC_W<'a, O> {
134    ///General call disabled
135    #[inline(always)]
136    pub fn disabled(self) -> &'a mut W {
137        self.variant(ENGC_A::Disabled)
138    }
139    ///General call enabled
140    #[inline(always)]
141    pub fn enabled(self) -> &'a mut W {
142        self.variant(ENGC_A::Enabled)
143    }
144}
145///Field `NOSTRETCH` reader - Clock stretching disable (Slave mode)
146pub type NOSTRETCH_R = crate::BitReader<NOSTRETCH_A>;
147/**Clock stretching disable (Slave mode)
148
149Value on reset: 0*/
150#[derive(Clone, Copy, Debug, PartialEq, Eq)]
151pub enum NOSTRETCH_A {
152    ///0: Clock stretching enabled
153    Enabled = 0,
154    ///1: Clock stretching disabled
155    Disabled = 1,
156}
157impl From<NOSTRETCH_A> for bool {
158    #[inline(always)]
159    fn from(variant: NOSTRETCH_A) -> Self {
160        variant as u8 != 0
161    }
162}
163impl NOSTRETCH_R {
164    ///Get enumerated values variant
165    #[inline(always)]
166    pub fn variant(&self) -> NOSTRETCH_A {
167        match self.bits {
168            false => NOSTRETCH_A::Enabled,
169            true => NOSTRETCH_A::Disabled,
170        }
171    }
172    ///Checks if the value of the field is `Enabled`
173    #[inline(always)]
174    pub fn is_enabled(&self) -> bool {
175        *self == NOSTRETCH_A::Enabled
176    }
177    ///Checks if the value of the field is `Disabled`
178    #[inline(always)]
179    pub fn is_disabled(&self) -> bool {
180        *self == NOSTRETCH_A::Disabled
181    }
182}
183///Field `NOSTRETCH` writer - Clock stretching disable (Slave mode)
184pub type NOSTRETCH_W<'a, const O: u8> = crate::BitWriter<'a, u32, CR1_SPEC, NOSTRETCH_A, O>;
185impl<'a, const O: u8> NOSTRETCH_W<'a, O> {
186    ///Clock stretching enabled
187    #[inline(always)]
188    pub fn enabled(self) -> &'a mut W {
189        self.variant(NOSTRETCH_A::Enabled)
190    }
191    ///Clock stretching disabled
192    #[inline(always)]
193    pub fn disabled(self) -> &'a mut W {
194        self.variant(NOSTRETCH_A::Disabled)
195    }
196}
197///Field `START` reader - Start generation
198pub type START_R = crate::BitReader<START_A>;
199/**Start generation
200
201Value on reset: 0*/
202#[derive(Clone, Copy, Debug, PartialEq, Eq)]
203pub enum START_A {
204    ///0: No Start generation
205    NoStart = 0,
206    ///1: In master mode: repeated start generation, in slave mode: start generation when bus is free
207    Start = 1,
208}
209impl From<START_A> for bool {
210    #[inline(always)]
211    fn from(variant: START_A) -> Self {
212        variant as u8 != 0
213    }
214}
215impl START_R {
216    ///Get enumerated values variant
217    #[inline(always)]
218    pub fn variant(&self) -> START_A {
219        match self.bits {
220            false => START_A::NoStart,
221            true => START_A::Start,
222        }
223    }
224    ///Checks if the value of the field is `NoStart`
225    #[inline(always)]
226    pub fn is_no_start(&self) -> bool {
227        *self == START_A::NoStart
228    }
229    ///Checks if the value of the field is `Start`
230    #[inline(always)]
231    pub fn is_start(&self) -> bool {
232        *self == START_A::Start
233    }
234}
235///Field `START` writer - Start generation
236pub type START_W<'a, const O: u8> = crate::BitWriter<'a, u32, CR1_SPEC, START_A, O>;
237impl<'a, const O: u8> START_W<'a, O> {
238    ///No Start generation
239    #[inline(always)]
240    pub fn no_start(self) -> &'a mut W {
241        self.variant(START_A::NoStart)
242    }
243    ///In master mode: repeated start generation, in slave mode: start generation when bus is free
244    #[inline(always)]
245    pub fn start(self) -> &'a mut W {
246        self.variant(START_A::Start)
247    }
248}
249///Field `STOP` reader - Stop generation
250pub type STOP_R = crate::BitReader<STOP_A>;
251/**Stop generation
252
253Value on reset: 0*/
254#[derive(Clone, Copy, Debug, PartialEq, Eq)]
255pub enum STOP_A {
256    ///0: No Stop generation
257    NoStop = 0,
258    ///1: In master mode: stop generation after current byte/start, in slave mode: release SCL and SDA after current byte
259    Stop = 1,
260}
261impl From<STOP_A> for bool {
262    #[inline(always)]
263    fn from(variant: STOP_A) -> Self {
264        variant as u8 != 0
265    }
266}
267impl STOP_R {
268    ///Get enumerated values variant
269    #[inline(always)]
270    pub fn variant(&self) -> STOP_A {
271        match self.bits {
272            false => STOP_A::NoStop,
273            true => STOP_A::Stop,
274        }
275    }
276    ///Checks if the value of the field is `NoStop`
277    #[inline(always)]
278    pub fn is_no_stop(&self) -> bool {
279        *self == STOP_A::NoStop
280    }
281    ///Checks if the value of the field is `Stop`
282    #[inline(always)]
283    pub fn is_stop(&self) -> bool {
284        *self == STOP_A::Stop
285    }
286}
287///Field `STOP` writer - Stop generation
288pub type STOP_W<'a, const O: u8> = crate::BitWriter<'a, u32, CR1_SPEC, STOP_A, O>;
289impl<'a, const O: u8> STOP_W<'a, O> {
290    ///No Stop generation
291    #[inline(always)]
292    pub fn no_stop(self) -> &'a mut W {
293        self.variant(STOP_A::NoStop)
294    }
295    ///In master mode: stop generation after current byte/start, in slave mode: release SCL and SDA after current byte
296    #[inline(always)]
297    pub fn stop(self) -> &'a mut W {
298        self.variant(STOP_A::Stop)
299    }
300}
301///Field `ACK` reader - Acknowledge enable
302pub type ACK_R = crate::BitReader<ACK_A>;
303/**Acknowledge enable
304
305Value on reset: 0*/
306#[derive(Clone, Copy, Debug, PartialEq, Eq)]
307pub enum ACK_A {
308    ///0: No acknowledge returned
309    Nak = 0,
310    ///1: Acknowledge returned after a byte is received
311    Ack = 1,
312}
313impl From<ACK_A> for bool {
314    #[inline(always)]
315    fn from(variant: ACK_A) -> Self {
316        variant as u8 != 0
317    }
318}
319impl ACK_R {
320    ///Get enumerated values variant
321    #[inline(always)]
322    pub fn variant(&self) -> ACK_A {
323        match self.bits {
324            false => ACK_A::Nak,
325            true => ACK_A::Ack,
326        }
327    }
328    ///Checks if the value of the field is `Nak`
329    #[inline(always)]
330    pub fn is_nak(&self) -> bool {
331        *self == ACK_A::Nak
332    }
333    ///Checks if the value of the field is `Ack`
334    #[inline(always)]
335    pub fn is_ack(&self) -> bool {
336        *self == ACK_A::Ack
337    }
338}
339///Field `ACK` writer - Acknowledge enable
340pub type ACK_W<'a, const O: u8> = crate::BitWriter<'a, u32, CR1_SPEC, ACK_A, O>;
341impl<'a, const O: u8> ACK_W<'a, O> {
342    ///No acknowledge returned
343    #[inline(always)]
344    pub fn nak(self) -> &'a mut W {
345        self.variant(ACK_A::Nak)
346    }
347    ///Acknowledge returned after a byte is received
348    #[inline(always)]
349    pub fn ack(self) -> &'a mut W {
350        self.variant(ACK_A::Ack)
351    }
352}
353///Field `POS` reader - Acknowledge/PEC Position (for data reception)
354pub type POS_R = crate::BitReader<POS_A>;
355/**Acknowledge/PEC Position (for data reception)
356
357Value on reset: 0*/
358#[derive(Clone, Copy, Debug, PartialEq, Eq)]
359pub enum POS_A {
360    ///0: ACK bit controls the (N)ACK of the current byte being received
361    Current = 0,
362    ///1: ACK bit controls the (N)ACK of the next byte to be received
363    Next = 1,
364}
365impl From<POS_A> for bool {
366    #[inline(always)]
367    fn from(variant: POS_A) -> Self {
368        variant as u8 != 0
369    }
370}
371impl POS_R {
372    ///Get enumerated values variant
373    #[inline(always)]
374    pub fn variant(&self) -> POS_A {
375        match self.bits {
376            false => POS_A::Current,
377            true => POS_A::Next,
378        }
379    }
380    ///Checks if the value of the field is `Current`
381    #[inline(always)]
382    pub fn is_current(&self) -> bool {
383        *self == POS_A::Current
384    }
385    ///Checks if the value of the field is `Next`
386    #[inline(always)]
387    pub fn is_next(&self) -> bool {
388        *self == POS_A::Next
389    }
390}
391///Field `POS` writer - Acknowledge/PEC Position (for data reception)
392pub type POS_W<'a, const O: u8> = crate::BitWriter<'a, u32, CR1_SPEC, POS_A, O>;
393impl<'a, const O: u8> POS_W<'a, O> {
394    ///ACK bit controls the (N)ACK of the current byte being received
395    #[inline(always)]
396    pub fn current(self) -> &'a mut W {
397        self.variant(POS_A::Current)
398    }
399    ///ACK bit controls the (N)ACK of the next byte to be received
400    #[inline(always)]
401    pub fn next(self) -> &'a mut W {
402        self.variant(POS_A::Next)
403    }
404}
405///Field `PEC` reader - Packet error checking
406pub type PEC_R = crate::BitReader<bool>;
407///Field `PEC` writer - Packet error checking
408pub type PEC_W<'a, const O: u8> = crate::BitWriter<'a, u32, CR1_SPEC, bool, O>;
409///Field `SWRST` reader - Software reset
410pub type SWRST_R = crate::BitReader<SWRST_A>;
411/**Software reset
412
413Value on reset: 0*/
414#[derive(Clone, Copy, Debug, PartialEq, Eq)]
415pub enum SWRST_A {
416    ///0: I2C peripheral not under reset
417    NotReset = 0,
418    ///1: I2C peripheral under reset
419    Reset = 1,
420}
421impl From<SWRST_A> for bool {
422    #[inline(always)]
423    fn from(variant: SWRST_A) -> Self {
424        variant as u8 != 0
425    }
426}
427impl SWRST_R {
428    ///Get enumerated values variant
429    #[inline(always)]
430    pub fn variant(&self) -> SWRST_A {
431        match self.bits {
432            false => SWRST_A::NotReset,
433            true => SWRST_A::Reset,
434        }
435    }
436    ///Checks if the value of the field is `NotReset`
437    #[inline(always)]
438    pub fn is_not_reset(&self) -> bool {
439        *self == SWRST_A::NotReset
440    }
441    ///Checks if the value of the field is `Reset`
442    #[inline(always)]
443    pub fn is_reset(&self) -> bool {
444        *self == SWRST_A::Reset
445    }
446}
447///Field `SWRST` writer - Software reset
448pub type SWRST_W<'a, const O: u8> = crate::BitWriter<'a, u32, CR1_SPEC, SWRST_A, O>;
449impl<'a, const O: u8> SWRST_W<'a, O> {
450    ///I2C peripheral not under reset
451    #[inline(always)]
452    pub fn not_reset(self) -> &'a mut W {
453        self.variant(SWRST_A::NotReset)
454    }
455    ///I2C peripheral under reset
456    #[inline(always)]
457    pub fn reset(self) -> &'a mut W {
458        self.variant(SWRST_A::Reset)
459    }
460}
461impl R {
462    ///Bit 0 - Peripheral enable
463    #[inline(always)]
464    pub fn pe(&self) -> PE_R {
465        PE_R::new((self.bits & 1) != 0)
466    }
467    ///Bit 5 - PEC enable
468    #[inline(always)]
469    pub fn enpec(&self) -> ENPEC_R {
470        ENPEC_R::new(((self.bits >> 5) & 1) != 0)
471    }
472    ///Bit 6 - General call enable
473    #[inline(always)]
474    pub fn engc(&self) -> ENGC_R {
475        ENGC_R::new(((self.bits >> 6) & 1) != 0)
476    }
477    ///Bit 7 - Clock stretching disable (Slave mode)
478    #[inline(always)]
479    pub fn nostretch(&self) -> NOSTRETCH_R {
480        NOSTRETCH_R::new(((self.bits >> 7) & 1) != 0)
481    }
482    ///Bit 8 - Start generation
483    #[inline(always)]
484    pub fn start(&self) -> START_R {
485        START_R::new(((self.bits >> 8) & 1) != 0)
486    }
487    ///Bit 9 - Stop generation
488    #[inline(always)]
489    pub fn stop(&self) -> STOP_R {
490        STOP_R::new(((self.bits >> 9) & 1) != 0)
491    }
492    ///Bit 10 - Acknowledge enable
493    #[inline(always)]
494    pub fn ack(&self) -> ACK_R {
495        ACK_R::new(((self.bits >> 10) & 1) != 0)
496    }
497    ///Bit 11 - Acknowledge/PEC Position (for data reception)
498    #[inline(always)]
499    pub fn pos(&self) -> POS_R {
500        POS_R::new(((self.bits >> 11) & 1) != 0)
501    }
502    ///Bit 12 - Packet error checking
503    #[inline(always)]
504    pub fn pec(&self) -> PEC_R {
505        PEC_R::new(((self.bits >> 12) & 1) != 0)
506    }
507    ///Bit 15 - Software reset
508    #[inline(always)]
509    pub fn swrst(&self) -> SWRST_R {
510        SWRST_R::new(((self.bits >> 15) & 1) != 0)
511    }
512}
513impl W {
514    ///Bit 0 - Peripheral enable
515    #[inline(always)]
516    #[must_use]
517    pub fn pe(&mut self) -> PE_W<0> {
518        PE_W::new(self)
519    }
520    ///Bit 5 - PEC enable
521    #[inline(always)]
522    #[must_use]
523    pub fn enpec(&mut self) -> ENPEC_W<5> {
524        ENPEC_W::new(self)
525    }
526    ///Bit 6 - General call enable
527    #[inline(always)]
528    #[must_use]
529    pub fn engc(&mut self) -> ENGC_W<6> {
530        ENGC_W::new(self)
531    }
532    ///Bit 7 - Clock stretching disable (Slave mode)
533    #[inline(always)]
534    #[must_use]
535    pub fn nostretch(&mut self) -> NOSTRETCH_W<7> {
536        NOSTRETCH_W::new(self)
537    }
538    ///Bit 8 - Start generation
539    #[inline(always)]
540    #[must_use]
541    pub fn start(&mut self) -> START_W<8> {
542        START_W::new(self)
543    }
544    ///Bit 9 - Stop generation
545    #[inline(always)]
546    #[must_use]
547    pub fn stop(&mut self) -> STOP_W<9> {
548        STOP_W::new(self)
549    }
550    ///Bit 10 - Acknowledge enable
551    #[inline(always)]
552    #[must_use]
553    pub fn ack(&mut self) -> ACK_W<10> {
554        ACK_W::new(self)
555    }
556    ///Bit 11 - Acknowledge/PEC Position (for data reception)
557    #[inline(always)]
558    #[must_use]
559    pub fn pos(&mut self) -> POS_W<11> {
560        POS_W::new(self)
561    }
562    ///Bit 12 - Packet error checking
563    #[inline(always)]
564    #[must_use]
565    pub fn pec(&mut self) -> PEC_W<12> {
566        PEC_W::new(self)
567    }
568    ///Bit 15 - Software reset
569    #[inline(always)]
570    #[must_use]
571    pub fn swrst(&mut self) -> SWRST_W<15> {
572        SWRST_W::new(self)
573    }
574    ///Writes raw bits to the register.
575    #[inline(always)]
576    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
577        self.0.bits(bits);
578        self
579    }
580}
581/**Control register 1
582
583This 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).
584
585For information about available fields see [cr1](index.html) module*/
586pub struct CR1_SPEC;
587impl crate::RegisterSpec for CR1_SPEC {
588    type Ux = u32;
589}
590///`read()` method returns [cr1::R](R) reader structure
591impl crate::Readable for CR1_SPEC {
592    type Reader = R;
593}
594///`write(|w| ..)` method takes [cr1::W](W) writer structure
595impl crate::Writable for CR1_SPEC {
596    type Writer = W;
597    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
598    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
599}
600///`reset()` method sets CR1 to value 0
601impl crate::Resettable for CR1_SPEC {
602    const RESET_VALUE: Self::Ux = 0;
603}