s32k116_pac/lpspi0/
cfgr0.rs

1#[doc = "Register `CFGR0` reader"]
2pub struct R(crate::R<CFGR0_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<CFGR0_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<CFGR0_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<CFGR0_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `CFGR0` writer"]
17pub struct W(crate::W<CFGR0_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<CFGR0_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<CFGR0_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<CFGR0_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Host Request Enable\n\nValue on reset: 0"]
38#[derive(Clone, Copy, Debug, PartialEq)]
39pub enum HREN_A {
40    #[doc = "0: Host request is disabled."]
41    _0 = 0,
42    #[doc = "1: Host request is enabled."]
43    _1 = 1,
44}
45impl From<HREN_A> for bool {
46    #[inline(always)]
47    fn from(variant: HREN_A) -> Self {
48        variant as u8 != 0
49    }
50}
51#[doc = "Field `HREN` reader - Host Request Enable"]
52pub struct HREN_R(crate::FieldReader<bool, HREN_A>);
53impl HREN_R {
54    #[inline(always)]
55    pub(crate) fn new(bits: bool) -> Self {
56        HREN_R(crate::FieldReader::new(bits))
57    }
58    #[doc = r"Get enumerated values variant"]
59    #[inline(always)]
60    pub fn variant(&self) -> HREN_A {
61        match self.bits {
62            false => HREN_A::_0,
63            true => HREN_A::_1,
64        }
65    }
66    #[doc = "Checks if the value of the field is `_0`"]
67    #[inline(always)]
68    pub fn is_0(&self) -> bool {
69        **self == HREN_A::_0
70    }
71    #[doc = "Checks if the value of the field is `_1`"]
72    #[inline(always)]
73    pub fn is_1(&self) -> bool {
74        **self == HREN_A::_1
75    }
76}
77impl core::ops::Deref for HREN_R {
78    type Target = crate::FieldReader<bool, HREN_A>;
79    #[inline(always)]
80    fn deref(&self) -> &Self::Target {
81        &self.0
82    }
83}
84#[doc = "Field `HREN` writer - Host Request Enable"]
85pub struct HREN_W<'a> {
86    w: &'a mut W,
87}
88impl<'a> HREN_W<'a> {
89    #[doc = r"Writes `variant` to the field"]
90    #[inline(always)]
91    pub fn variant(self, variant: HREN_A) -> &'a mut W {
92        self.bit(variant.into())
93    }
94    #[doc = "Host request is disabled."]
95    #[inline(always)]
96    pub fn _0(self) -> &'a mut W {
97        self.variant(HREN_A::_0)
98    }
99    #[doc = "Host request is enabled."]
100    #[inline(always)]
101    pub fn _1(self) -> &'a mut W {
102        self.variant(HREN_A::_1)
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 = "Host Request Polarity\n\nValue on reset: 0"]
122#[derive(Clone, Copy, Debug, PartialEq)]
123pub enum HRPOL_A {
124    #[doc = "0: Active low."]
125    _0 = 0,
126    #[doc = "1: Active high."]
127    _1 = 1,
128}
129impl From<HRPOL_A> for bool {
130    #[inline(always)]
131    fn from(variant: HRPOL_A) -> Self {
132        variant as u8 != 0
133    }
134}
135#[doc = "Field `HRPOL` reader - Host Request Polarity"]
136pub struct HRPOL_R(crate::FieldReader<bool, HRPOL_A>);
137impl HRPOL_R {
138    #[inline(always)]
139    pub(crate) fn new(bits: bool) -> Self {
140        HRPOL_R(crate::FieldReader::new(bits))
141    }
142    #[doc = r"Get enumerated values variant"]
143    #[inline(always)]
144    pub fn variant(&self) -> HRPOL_A {
145        match self.bits {
146            false => HRPOL_A::_0,
147            true => HRPOL_A::_1,
148        }
149    }
150    #[doc = "Checks if the value of the field is `_0`"]
151    #[inline(always)]
152    pub fn is_0(&self) -> bool {
153        **self == HRPOL_A::_0
154    }
155    #[doc = "Checks if the value of the field is `_1`"]
156    #[inline(always)]
157    pub fn is_1(&self) -> bool {
158        **self == HRPOL_A::_1
159    }
160}
161impl core::ops::Deref for HRPOL_R {
162    type Target = crate::FieldReader<bool, HRPOL_A>;
163    #[inline(always)]
164    fn deref(&self) -> &Self::Target {
165        &self.0
166    }
167}
168#[doc = "Field `HRPOL` writer - Host Request Polarity"]
169pub struct HRPOL_W<'a> {
170    w: &'a mut W,
171}
172impl<'a> HRPOL_W<'a> {
173    #[doc = r"Writes `variant` to the field"]
174    #[inline(always)]
175    pub fn variant(self, variant: HRPOL_A) -> &'a mut W {
176        self.bit(variant.into())
177    }
178    #[doc = "Active low."]
179    #[inline(always)]
180    pub fn _0(self) -> &'a mut W {
181        self.variant(HRPOL_A::_0)
182    }
183    #[doc = "Active high."]
184    #[inline(always)]
185    pub fn _1(self) -> &'a mut W {
186        self.variant(HRPOL_A::_1)
187    }
188    #[doc = r"Sets the field bit"]
189    #[inline(always)]
190    pub fn set_bit(self) -> &'a mut W {
191        self.bit(true)
192    }
193    #[doc = r"Clears the field bit"]
194    #[inline(always)]
195    pub fn clear_bit(self) -> &'a mut W {
196        self.bit(false)
197    }
198    #[doc = r"Writes raw bits to the field"]
199    #[inline(always)]
200    pub fn bit(self, value: bool) -> &'a mut W {
201        self.w.bits = (self.w.bits & !(0x01 << 1)) | ((value as u32 & 0x01) << 1);
202        self.w
203    }
204}
205#[doc = "Host Request Select\n\nValue on reset: 0"]
206#[derive(Clone, Copy, Debug, PartialEq)]
207pub enum HRSEL_A {
208    #[doc = "0: Host request input is pin LPSPI_HREQ."]
209    _0 = 0,
210    #[doc = "1: Host request input is input trigger."]
211    _1 = 1,
212}
213impl From<HRSEL_A> for bool {
214    #[inline(always)]
215    fn from(variant: HRSEL_A) -> Self {
216        variant as u8 != 0
217    }
218}
219#[doc = "Field `HRSEL` reader - Host Request Select"]
220pub struct HRSEL_R(crate::FieldReader<bool, HRSEL_A>);
221impl HRSEL_R {
222    #[inline(always)]
223    pub(crate) fn new(bits: bool) -> Self {
224        HRSEL_R(crate::FieldReader::new(bits))
225    }
226    #[doc = r"Get enumerated values variant"]
227    #[inline(always)]
228    pub fn variant(&self) -> HRSEL_A {
229        match self.bits {
230            false => HRSEL_A::_0,
231            true => HRSEL_A::_1,
232        }
233    }
234    #[doc = "Checks if the value of the field is `_0`"]
235    #[inline(always)]
236    pub fn is_0(&self) -> bool {
237        **self == HRSEL_A::_0
238    }
239    #[doc = "Checks if the value of the field is `_1`"]
240    #[inline(always)]
241    pub fn is_1(&self) -> bool {
242        **self == HRSEL_A::_1
243    }
244}
245impl core::ops::Deref for HRSEL_R {
246    type Target = crate::FieldReader<bool, HRSEL_A>;
247    #[inline(always)]
248    fn deref(&self) -> &Self::Target {
249        &self.0
250    }
251}
252#[doc = "Field `HRSEL` writer - Host Request Select"]
253pub struct HRSEL_W<'a> {
254    w: &'a mut W,
255}
256impl<'a> HRSEL_W<'a> {
257    #[doc = r"Writes `variant` to the field"]
258    #[inline(always)]
259    pub fn variant(self, variant: HRSEL_A) -> &'a mut W {
260        self.bit(variant.into())
261    }
262    #[doc = "Host request input is pin LPSPI_HREQ."]
263    #[inline(always)]
264    pub fn _0(self) -> &'a mut W {
265        self.variant(HRSEL_A::_0)
266    }
267    #[doc = "Host request input is input trigger."]
268    #[inline(always)]
269    pub fn _1(self) -> &'a mut W {
270        self.variant(HRSEL_A::_1)
271    }
272    #[doc = r"Sets the field bit"]
273    #[inline(always)]
274    pub fn set_bit(self) -> &'a mut W {
275        self.bit(true)
276    }
277    #[doc = r"Clears the field bit"]
278    #[inline(always)]
279    pub fn clear_bit(self) -> &'a mut W {
280        self.bit(false)
281    }
282    #[doc = r"Writes raw bits to the field"]
283    #[inline(always)]
284    pub fn bit(self, value: bool) -> &'a mut W {
285        self.w.bits = (self.w.bits & !(0x01 << 2)) | ((value as u32 & 0x01) << 2);
286        self.w
287    }
288}
289#[doc = "Circular FIFO Enable\n\nValue on reset: 0"]
290#[derive(Clone, Copy, Debug, PartialEq)]
291pub enum CIRFIFO_A {
292    #[doc = "0: Circular FIFO is disabled."]
293    _0 = 0,
294    #[doc = "1: Circular FIFO is enabled."]
295    _1 = 1,
296}
297impl From<CIRFIFO_A> for bool {
298    #[inline(always)]
299    fn from(variant: CIRFIFO_A) -> Self {
300        variant as u8 != 0
301    }
302}
303#[doc = "Field `CIRFIFO` reader - Circular FIFO Enable"]
304pub struct CIRFIFO_R(crate::FieldReader<bool, CIRFIFO_A>);
305impl CIRFIFO_R {
306    #[inline(always)]
307    pub(crate) fn new(bits: bool) -> Self {
308        CIRFIFO_R(crate::FieldReader::new(bits))
309    }
310    #[doc = r"Get enumerated values variant"]
311    #[inline(always)]
312    pub fn variant(&self) -> CIRFIFO_A {
313        match self.bits {
314            false => CIRFIFO_A::_0,
315            true => CIRFIFO_A::_1,
316        }
317    }
318    #[doc = "Checks if the value of the field is `_0`"]
319    #[inline(always)]
320    pub fn is_0(&self) -> bool {
321        **self == CIRFIFO_A::_0
322    }
323    #[doc = "Checks if the value of the field is `_1`"]
324    #[inline(always)]
325    pub fn is_1(&self) -> bool {
326        **self == CIRFIFO_A::_1
327    }
328}
329impl core::ops::Deref for CIRFIFO_R {
330    type Target = crate::FieldReader<bool, CIRFIFO_A>;
331    #[inline(always)]
332    fn deref(&self) -> &Self::Target {
333        &self.0
334    }
335}
336#[doc = "Field `CIRFIFO` writer - Circular FIFO Enable"]
337pub struct CIRFIFO_W<'a> {
338    w: &'a mut W,
339}
340impl<'a> CIRFIFO_W<'a> {
341    #[doc = r"Writes `variant` to the field"]
342    #[inline(always)]
343    pub fn variant(self, variant: CIRFIFO_A) -> &'a mut W {
344        self.bit(variant.into())
345    }
346    #[doc = "Circular FIFO is disabled."]
347    #[inline(always)]
348    pub fn _0(self) -> &'a mut W {
349        self.variant(CIRFIFO_A::_0)
350    }
351    #[doc = "Circular FIFO is enabled."]
352    #[inline(always)]
353    pub fn _1(self) -> &'a mut W {
354        self.variant(CIRFIFO_A::_1)
355    }
356    #[doc = r"Sets the field bit"]
357    #[inline(always)]
358    pub fn set_bit(self) -> &'a mut W {
359        self.bit(true)
360    }
361    #[doc = r"Clears the field bit"]
362    #[inline(always)]
363    pub fn clear_bit(self) -> &'a mut W {
364        self.bit(false)
365    }
366    #[doc = r"Writes raw bits to the field"]
367    #[inline(always)]
368    pub fn bit(self, value: bool) -> &'a mut W {
369        self.w.bits = (self.w.bits & !(0x01 << 8)) | ((value as u32 & 0x01) << 8);
370        self.w
371    }
372}
373#[doc = "Receive Data Match Only\n\nValue on reset: 0"]
374#[derive(Clone, Copy, Debug, PartialEq)]
375pub enum RDMO_A {
376    #[doc = "0: Received data is stored in the receive FIFO as normal."]
377    _0 = 0,
378    #[doc = "1: Received data is discarded unless the DMF is set."]
379    _1 = 1,
380}
381impl From<RDMO_A> for bool {
382    #[inline(always)]
383    fn from(variant: RDMO_A) -> Self {
384        variant as u8 != 0
385    }
386}
387#[doc = "Field `RDMO` reader - Receive Data Match Only"]
388pub struct RDMO_R(crate::FieldReader<bool, RDMO_A>);
389impl RDMO_R {
390    #[inline(always)]
391    pub(crate) fn new(bits: bool) -> Self {
392        RDMO_R(crate::FieldReader::new(bits))
393    }
394    #[doc = r"Get enumerated values variant"]
395    #[inline(always)]
396    pub fn variant(&self) -> RDMO_A {
397        match self.bits {
398            false => RDMO_A::_0,
399            true => RDMO_A::_1,
400        }
401    }
402    #[doc = "Checks if the value of the field is `_0`"]
403    #[inline(always)]
404    pub fn is_0(&self) -> bool {
405        **self == RDMO_A::_0
406    }
407    #[doc = "Checks if the value of the field is `_1`"]
408    #[inline(always)]
409    pub fn is_1(&self) -> bool {
410        **self == RDMO_A::_1
411    }
412}
413impl core::ops::Deref for RDMO_R {
414    type Target = crate::FieldReader<bool, RDMO_A>;
415    #[inline(always)]
416    fn deref(&self) -> &Self::Target {
417        &self.0
418    }
419}
420#[doc = "Field `RDMO` writer - Receive Data Match Only"]
421pub struct RDMO_W<'a> {
422    w: &'a mut W,
423}
424impl<'a> RDMO_W<'a> {
425    #[doc = r"Writes `variant` to the field"]
426    #[inline(always)]
427    pub fn variant(self, variant: RDMO_A) -> &'a mut W {
428        self.bit(variant.into())
429    }
430    #[doc = "Received data is stored in the receive FIFO as normal."]
431    #[inline(always)]
432    pub fn _0(self) -> &'a mut W {
433        self.variant(RDMO_A::_0)
434    }
435    #[doc = "Received data is discarded unless the DMF is set."]
436    #[inline(always)]
437    pub fn _1(self) -> &'a mut W {
438        self.variant(RDMO_A::_1)
439    }
440    #[doc = r"Sets the field bit"]
441    #[inline(always)]
442    pub fn set_bit(self) -> &'a mut W {
443        self.bit(true)
444    }
445    #[doc = r"Clears the field bit"]
446    #[inline(always)]
447    pub fn clear_bit(self) -> &'a mut W {
448        self.bit(false)
449    }
450    #[doc = r"Writes raw bits to the field"]
451    #[inline(always)]
452    pub fn bit(self, value: bool) -> &'a mut W {
453        self.w.bits = (self.w.bits & !(0x01 << 9)) | ((value as u32 & 0x01) << 9);
454        self.w
455    }
456}
457impl R {
458    #[doc = "Bit 0 - Host Request Enable"]
459    #[inline(always)]
460    pub fn hren(&self) -> HREN_R {
461        HREN_R::new((self.bits & 0x01) != 0)
462    }
463    #[doc = "Bit 1 - Host Request Polarity"]
464    #[inline(always)]
465    pub fn hrpol(&self) -> HRPOL_R {
466        HRPOL_R::new(((self.bits >> 1) & 0x01) != 0)
467    }
468    #[doc = "Bit 2 - Host Request Select"]
469    #[inline(always)]
470    pub fn hrsel(&self) -> HRSEL_R {
471        HRSEL_R::new(((self.bits >> 2) & 0x01) != 0)
472    }
473    #[doc = "Bit 8 - Circular FIFO Enable"]
474    #[inline(always)]
475    pub fn cirfifo(&self) -> CIRFIFO_R {
476        CIRFIFO_R::new(((self.bits >> 8) & 0x01) != 0)
477    }
478    #[doc = "Bit 9 - Receive Data Match Only"]
479    #[inline(always)]
480    pub fn rdmo(&self) -> RDMO_R {
481        RDMO_R::new(((self.bits >> 9) & 0x01) != 0)
482    }
483}
484impl W {
485    #[doc = "Bit 0 - Host Request Enable"]
486    #[inline(always)]
487    pub fn hren(&mut self) -> HREN_W {
488        HREN_W { w: self }
489    }
490    #[doc = "Bit 1 - Host Request Polarity"]
491    #[inline(always)]
492    pub fn hrpol(&mut self) -> HRPOL_W {
493        HRPOL_W { w: self }
494    }
495    #[doc = "Bit 2 - Host Request Select"]
496    #[inline(always)]
497    pub fn hrsel(&mut self) -> HRSEL_W {
498        HRSEL_W { w: self }
499    }
500    #[doc = "Bit 8 - Circular FIFO Enable"]
501    #[inline(always)]
502    pub fn cirfifo(&mut self) -> CIRFIFO_W {
503        CIRFIFO_W { w: self }
504    }
505    #[doc = "Bit 9 - Receive Data Match Only"]
506    #[inline(always)]
507    pub fn rdmo(&mut self) -> RDMO_W {
508        RDMO_W { w: self }
509    }
510    #[doc = "Writes raw bits to the register."]
511    #[inline(always)]
512    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
513        self.0.bits(bits);
514        self
515    }
516}
517#[doc = "Configuration Register 0\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 [cfgr0](index.html) module"]
518pub struct CFGR0_SPEC;
519impl crate::RegisterSpec for CFGR0_SPEC {
520    type Ux = u32;
521}
522#[doc = "`read()` method returns [cfgr0::R](R) reader structure"]
523impl crate::Readable for CFGR0_SPEC {
524    type Reader = R;
525}
526#[doc = "`write(|w| ..)` method takes [cfgr0::W](W) writer structure"]
527impl crate::Writable for CFGR0_SPEC {
528    type Writer = W;
529}
530#[doc = "`reset()` method sets CFGR0 to value 0"]
531impl crate::Resettable for CFGR0_SPEC {
532    #[inline(always)]
533    fn reset_value() -> Self::Ux {
534        0
535    }
536}