avr_device/devices/atmega4809/spi0/
ctrlb.rs

1#[doc = "Register `CTRLB` reader"]
2pub struct R(crate::R<CTRLB_SPEC>);
3impl core::ops::Deref for R {
4    type Target = crate::R<CTRLB_SPEC>;
5    #[inline(always)]
6    fn deref(&self) -> &Self::Target {
7        &self.0
8    }
9}
10impl From<crate::R<CTRLB_SPEC>> for R {
11    #[inline(always)]
12    fn from(reader: crate::R<CTRLB_SPEC>) -> Self {
13        R(reader)
14    }
15}
16#[doc = "Register `CTRLB` writer"]
17pub struct W(crate::W<CTRLB_SPEC>);
18impl core::ops::Deref for W {
19    type Target = crate::W<CTRLB_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<CTRLB_SPEC>> for W {
32    #[inline(always)]
33    fn from(writer: crate::W<CTRLB_SPEC>) -> Self {
34        W(writer)
35    }
36}
37#[doc = "Field `MODE` reader - SPI Mode"]
38pub type MODE_R = crate::FieldReader<u8, MODE_A>;
39#[doc = "SPI Mode\n\nValue on reset: 0"]
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41#[repr(u8)]
42pub enum MODE_A {
43    #[doc = "0: SPI Mode 0"]
44    _0 = 0,
45    #[doc = "1: SPI Mode 1"]
46    _1 = 1,
47    #[doc = "2: SPI Mode 2"]
48    _2 = 2,
49    #[doc = "3: SPI Mode 3"]
50    _3 = 3,
51}
52impl From<MODE_A> for u8 {
53    #[inline(always)]
54    fn from(variant: MODE_A) -> Self {
55        variant as _
56    }
57}
58impl MODE_R {
59    #[doc = "Get enumerated values variant"]
60    #[inline(always)]
61    pub fn variant(&self) -> MODE_A {
62        match self.bits {
63            0 => MODE_A::_0,
64            1 => MODE_A::_1,
65            2 => MODE_A::_2,
66            3 => MODE_A::_3,
67            _ => unreachable!(),
68        }
69    }
70    #[doc = "Checks if the value of the field is `_0`"]
71    #[inline(always)]
72    pub fn is_0(&self) -> bool {
73        *self == MODE_A::_0
74    }
75    #[doc = "Checks if the value of the field is `_1`"]
76    #[inline(always)]
77    pub fn is_1(&self) -> bool {
78        *self == MODE_A::_1
79    }
80    #[doc = "Checks if the value of the field is `_2`"]
81    #[inline(always)]
82    pub fn is_2(&self) -> bool {
83        *self == MODE_A::_2
84    }
85    #[doc = "Checks if the value of the field is `_3`"]
86    #[inline(always)]
87    pub fn is_3(&self) -> bool {
88        *self == MODE_A::_3
89    }
90}
91#[doc = "Field `MODE` writer - SPI Mode"]
92pub type MODE_W<'a, const O: u8> = crate::FieldWriterSafe<'a, u8, CTRLB_SPEC, u8, MODE_A, 2, O>;
93impl<'a, const O: u8> MODE_W<'a, O> {
94    #[doc = "SPI Mode 0"]
95    #[inline(always)]
96    pub fn _0(self) -> &'a mut W {
97        self.variant(MODE_A::_0)
98    }
99    #[doc = "SPI Mode 1"]
100    #[inline(always)]
101    pub fn _1(self) -> &'a mut W {
102        self.variant(MODE_A::_1)
103    }
104    #[doc = "SPI Mode 2"]
105    #[inline(always)]
106    pub fn _2(self) -> &'a mut W {
107        self.variant(MODE_A::_2)
108    }
109    #[doc = "SPI Mode 3"]
110    #[inline(always)]
111    pub fn _3(self) -> &'a mut W {
112        self.variant(MODE_A::_3)
113    }
114}
115#[doc = "Field `SSD` reader - Slave Select Disable"]
116pub type SSD_R = crate::BitReader<bool>;
117#[doc = "Field `SSD` writer - Slave Select Disable"]
118pub type SSD_W<'a, const O: u8> = crate::BitWriter<'a, u8, CTRLB_SPEC, bool, O>;
119#[doc = "Field `BUFWR` reader - Buffer Write Mode"]
120pub type BUFWR_R = crate::BitReader<bool>;
121#[doc = "Field `BUFWR` writer - Buffer Write Mode"]
122pub type BUFWR_W<'a, const O: u8> = crate::BitWriter<'a, u8, CTRLB_SPEC, bool, O>;
123#[doc = "Field `BUFEN` reader - Buffer Mode Enable"]
124pub type BUFEN_R = crate::BitReader<bool>;
125#[doc = "Field `BUFEN` writer - Buffer Mode Enable"]
126pub type BUFEN_W<'a, const O: u8> = crate::BitWriter<'a, u8, CTRLB_SPEC, bool, O>;
127impl R {
128    #[doc = "Bits 0:1 - SPI Mode"]
129    #[inline(always)]
130    pub fn mode(&self) -> MODE_R {
131        MODE_R::new(self.bits & 3)
132    }
133    #[doc = "Bit 2 - Slave Select Disable"]
134    #[inline(always)]
135    pub fn ssd(&self) -> SSD_R {
136        SSD_R::new(((self.bits >> 2) & 1) != 0)
137    }
138    #[doc = "Bit 6 - Buffer Write Mode"]
139    #[inline(always)]
140    pub fn bufwr(&self) -> BUFWR_R {
141        BUFWR_R::new(((self.bits >> 6) & 1) != 0)
142    }
143    #[doc = "Bit 7 - Buffer Mode Enable"]
144    #[inline(always)]
145    pub fn bufen(&self) -> BUFEN_R {
146        BUFEN_R::new(((self.bits >> 7) & 1) != 0)
147    }
148}
149impl W {
150    #[doc = "Bits 0:1 - SPI Mode"]
151    #[inline(always)]
152    #[must_use]
153    pub fn mode(&mut self) -> MODE_W<0> {
154        MODE_W::new(self)
155    }
156    #[doc = "Bit 2 - Slave Select Disable"]
157    #[inline(always)]
158    #[must_use]
159    pub fn ssd(&mut self) -> SSD_W<2> {
160        SSD_W::new(self)
161    }
162    #[doc = "Bit 6 - Buffer Write Mode"]
163    #[inline(always)]
164    #[must_use]
165    pub fn bufwr(&mut self) -> BUFWR_W<6> {
166        BUFWR_W::new(self)
167    }
168    #[doc = "Bit 7 - Buffer Mode Enable"]
169    #[inline(always)]
170    #[must_use]
171    pub fn bufen(&mut self) -> BUFEN_W<7> {
172        BUFEN_W::new(self)
173    }
174    #[doc = "Writes raw bits to the register."]
175    #[inline(always)]
176    pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
177        self.0.bits(bits);
178        self
179    }
180}
181#[doc = "Control B\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 [ctrlb](index.html) module"]
182pub struct CTRLB_SPEC;
183impl crate::RegisterSpec for CTRLB_SPEC {
184    type Ux = u8;
185}
186#[doc = "`read()` method returns [ctrlb::R](R) reader structure"]
187impl crate::Readable for CTRLB_SPEC {
188    type Reader = R;
189}
190#[doc = "`write(|w| ..)` method takes [ctrlb::W](W) writer structure"]
191impl crate::Writable for CTRLB_SPEC {
192    type Writer = W;
193    const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
194    const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
195}
196#[doc = "`reset()` method sets CTRLB to value 0"]
197impl crate::Resettable for CTRLB_SPEC {
198    const RESET_VALUE: Self::Ux = 0;
199}