atsamd11d/sercom0/spi/
ctrla.rs
1#[doc = "Register `CTRLA` reader"]
2pub type R = crate::R<CtrlaSpec>;
3#[doc = "Register `CTRLA` writer"]
4pub type W = crate::W<CtrlaSpec>;
5#[doc = "Field `SWRST` reader - Software Reset"]
6pub type SwrstR = crate::BitReader;
7#[doc = "Field `SWRST` writer - Software Reset"]
8pub type SwrstW<'a, REG> = crate::BitWriter<'a, REG>;
9#[doc = "Field `ENABLE` reader - Enable"]
10pub type EnableR = crate::BitReader;
11#[doc = "Field `ENABLE` writer - Enable"]
12pub type EnableW<'a, REG> = crate::BitWriter<'a, REG>;
13#[doc = "Operating Mode\n\nValue on reset: 0"]
14#[derive(Clone, Copy, Debug, PartialEq, Eq)]
15#[repr(u8)]
16pub enum Modeselect {
17 #[doc = "0: USART mode with external clock"]
18 UsartExtClk = 0,
19 #[doc = "1: USART mode with internal clock"]
20 UsartIntClk = 1,
21 #[doc = "2: SPI mode with external clock"]
22 SpiSlave = 2,
23 #[doc = "3: SPI mode with internal clock"]
24 SpiMaster = 3,
25 #[doc = "4: I2C mode with external clock"]
26 I2cSlave = 4,
27 #[doc = "5: I2C mode with internal clock"]
28 I2cMaster = 5,
29}
30impl From<Modeselect> for u8 {
31 #[inline(always)]
32 fn from(variant: Modeselect) -> Self {
33 variant as _
34 }
35}
36impl crate::FieldSpec for Modeselect {
37 type Ux = u8;
38}
39impl crate::IsEnum for Modeselect {}
40#[doc = "Field `MODE` reader - Operating Mode"]
41pub type ModeR = crate::FieldReader<Modeselect>;
42impl ModeR {
43 #[doc = "Get enumerated values variant"]
44 #[inline(always)]
45 pub const fn variant(&self) -> Option<Modeselect> {
46 match self.bits {
47 0 => Some(Modeselect::UsartExtClk),
48 1 => Some(Modeselect::UsartIntClk),
49 2 => Some(Modeselect::SpiSlave),
50 3 => Some(Modeselect::SpiMaster),
51 4 => Some(Modeselect::I2cSlave),
52 5 => Some(Modeselect::I2cMaster),
53 _ => None,
54 }
55 }
56 #[doc = "USART mode with external clock"]
57 #[inline(always)]
58 pub fn is_usart_ext_clk(&self) -> bool {
59 *self == Modeselect::UsartExtClk
60 }
61 #[doc = "USART mode with internal clock"]
62 #[inline(always)]
63 pub fn is_usart_int_clk(&self) -> bool {
64 *self == Modeselect::UsartIntClk
65 }
66 #[doc = "SPI mode with external clock"]
67 #[inline(always)]
68 pub fn is_spi_slave(&self) -> bool {
69 *self == Modeselect::SpiSlave
70 }
71 #[doc = "SPI mode with internal clock"]
72 #[inline(always)]
73 pub fn is_spi_master(&self) -> bool {
74 *self == Modeselect::SpiMaster
75 }
76 #[doc = "I2C mode with external clock"]
77 #[inline(always)]
78 pub fn is_i2c_slave(&self) -> bool {
79 *self == Modeselect::I2cSlave
80 }
81 #[doc = "I2C mode with internal clock"]
82 #[inline(always)]
83 pub fn is_i2c_master(&self) -> bool {
84 *self == Modeselect::I2cMaster
85 }
86}
87#[doc = "Field `MODE` writer - Operating Mode"]
88pub type ModeW<'a, REG> = crate::FieldWriter<'a, REG, 3, Modeselect>;
89impl<'a, REG> ModeW<'a, REG>
90where
91 REG: crate::Writable + crate::RegisterSpec,
92 REG::Ux: From<u8>,
93{
94 #[doc = "USART mode with external clock"]
95 #[inline(always)]
96 pub fn usart_ext_clk(self) -> &'a mut crate::W<REG> {
97 self.variant(Modeselect::UsartExtClk)
98 }
99 #[doc = "USART mode with internal clock"]
100 #[inline(always)]
101 pub fn usart_int_clk(self) -> &'a mut crate::W<REG> {
102 self.variant(Modeselect::UsartIntClk)
103 }
104 #[doc = "SPI mode with external clock"]
105 #[inline(always)]
106 pub fn spi_slave(self) -> &'a mut crate::W<REG> {
107 self.variant(Modeselect::SpiSlave)
108 }
109 #[doc = "SPI mode with internal clock"]
110 #[inline(always)]
111 pub fn spi_master(self) -> &'a mut crate::W<REG> {
112 self.variant(Modeselect::SpiMaster)
113 }
114 #[doc = "I2C mode with external clock"]
115 #[inline(always)]
116 pub fn i2c_slave(self) -> &'a mut crate::W<REG> {
117 self.variant(Modeselect::I2cSlave)
118 }
119 #[doc = "I2C mode with internal clock"]
120 #[inline(always)]
121 pub fn i2c_master(self) -> &'a mut crate::W<REG> {
122 self.variant(Modeselect::I2cMaster)
123 }
124}
125#[doc = "Field `RUNSTDBY` reader - Run during Standby"]
126pub type RunstdbyR = crate::BitReader;
127#[doc = "Field `RUNSTDBY` writer - Run during Standby"]
128pub type RunstdbyW<'a, REG> = crate::BitWriter<'a, REG>;
129#[doc = "Field `IBON` reader - Immediate Buffer Overflow Notification"]
130pub type IbonR = crate::BitReader;
131#[doc = "Field `IBON` writer - Immediate Buffer Overflow Notification"]
132pub type IbonW<'a, REG> = crate::BitWriter<'a, REG>;
133#[doc = "Field `DOPO` reader - Data Out Pinout"]
134pub type DopoR = crate::FieldReader;
135#[doc = "Field `DOPO` writer - Data Out Pinout"]
136pub type DopoW<'a, REG> = crate::FieldWriter<'a, REG, 2>;
137#[doc = "Field `DIPO` reader - Data In Pinout"]
138pub type DipoR = crate::FieldReader;
139#[doc = "Field `DIPO` writer - Data In Pinout"]
140pub type DipoW<'a, REG> = crate::FieldWriter<'a, REG, 2>;
141#[doc = "Field `FORM` reader - Frame Format"]
142pub type FormR = crate::FieldReader;
143#[doc = "Field `FORM` writer - Frame Format"]
144pub type FormW<'a, REG> = crate::FieldWriter<'a, REG, 4>;
145#[doc = "Field `CPHA` reader - Clock Phase"]
146pub type CphaR = crate::BitReader;
147#[doc = "Field `CPHA` writer - Clock Phase"]
148pub type CphaW<'a, REG> = crate::BitWriter<'a, REG>;
149#[doc = "Field `CPOL` reader - Clock Polarity"]
150pub type CpolR = crate::BitReader;
151#[doc = "Field `CPOL` writer - Clock Polarity"]
152pub type CpolW<'a, REG> = crate::BitWriter<'a, REG>;
153#[doc = "Field `DORD` reader - Data Order"]
154pub type DordR = crate::BitReader;
155#[doc = "Field `DORD` writer - Data Order"]
156pub type DordW<'a, REG> = crate::BitWriter<'a, REG>;
157impl R {
158 #[doc = "Bit 0 - Software Reset"]
159 #[inline(always)]
160 pub fn swrst(&self) -> SwrstR {
161 SwrstR::new((self.bits & 1) != 0)
162 }
163 #[doc = "Bit 1 - Enable"]
164 #[inline(always)]
165 pub fn enable(&self) -> EnableR {
166 EnableR::new(((self.bits >> 1) & 1) != 0)
167 }
168 #[doc = "Bits 2:4 - Operating Mode"]
169 #[inline(always)]
170 pub fn mode(&self) -> ModeR {
171 ModeR::new(((self.bits >> 2) & 7) as u8)
172 }
173 #[doc = "Bit 7 - Run during Standby"]
174 #[inline(always)]
175 pub fn runstdby(&self) -> RunstdbyR {
176 RunstdbyR::new(((self.bits >> 7) & 1) != 0)
177 }
178 #[doc = "Bit 8 - Immediate Buffer Overflow Notification"]
179 #[inline(always)]
180 pub fn ibon(&self) -> IbonR {
181 IbonR::new(((self.bits >> 8) & 1) != 0)
182 }
183 #[doc = "Bits 16:17 - Data Out Pinout"]
184 #[inline(always)]
185 pub fn dopo(&self) -> DopoR {
186 DopoR::new(((self.bits >> 16) & 3) as u8)
187 }
188 #[doc = "Bits 20:21 - Data In Pinout"]
189 #[inline(always)]
190 pub fn dipo(&self) -> DipoR {
191 DipoR::new(((self.bits >> 20) & 3) as u8)
192 }
193 #[doc = "Bits 24:27 - Frame Format"]
194 #[inline(always)]
195 pub fn form(&self) -> FormR {
196 FormR::new(((self.bits >> 24) & 0x0f) as u8)
197 }
198 #[doc = "Bit 28 - Clock Phase"]
199 #[inline(always)]
200 pub fn cpha(&self) -> CphaR {
201 CphaR::new(((self.bits >> 28) & 1) != 0)
202 }
203 #[doc = "Bit 29 - Clock Polarity"]
204 #[inline(always)]
205 pub fn cpol(&self) -> CpolR {
206 CpolR::new(((self.bits >> 29) & 1) != 0)
207 }
208 #[doc = "Bit 30 - Data Order"]
209 #[inline(always)]
210 pub fn dord(&self) -> DordR {
211 DordR::new(((self.bits >> 30) & 1) != 0)
212 }
213}
214impl W {
215 #[doc = "Bit 0 - Software Reset"]
216 #[inline(always)]
217 #[must_use]
218 pub fn swrst(&mut self) -> SwrstW<CtrlaSpec> {
219 SwrstW::new(self, 0)
220 }
221 #[doc = "Bit 1 - Enable"]
222 #[inline(always)]
223 #[must_use]
224 pub fn enable(&mut self) -> EnableW<CtrlaSpec> {
225 EnableW::new(self, 1)
226 }
227 #[doc = "Bits 2:4 - Operating Mode"]
228 #[inline(always)]
229 #[must_use]
230 pub fn mode(&mut self) -> ModeW<CtrlaSpec> {
231 ModeW::new(self, 2)
232 }
233 #[doc = "Bit 7 - Run during Standby"]
234 #[inline(always)]
235 #[must_use]
236 pub fn runstdby(&mut self) -> RunstdbyW<CtrlaSpec> {
237 RunstdbyW::new(self, 7)
238 }
239 #[doc = "Bit 8 - Immediate Buffer Overflow Notification"]
240 #[inline(always)]
241 #[must_use]
242 pub fn ibon(&mut self) -> IbonW<CtrlaSpec> {
243 IbonW::new(self, 8)
244 }
245 #[doc = "Bits 16:17 - Data Out Pinout"]
246 #[inline(always)]
247 #[must_use]
248 pub fn dopo(&mut self) -> DopoW<CtrlaSpec> {
249 DopoW::new(self, 16)
250 }
251 #[doc = "Bits 20:21 - Data In Pinout"]
252 #[inline(always)]
253 #[must_use]
254 pub fn dipo(&mut self) -> DipoW<CtrlaSpec> {
255 DipoW::new(self, 20)
256 }
257 #[doc = "Bits 24:27 - Frame Format"]
258 #[inline(always)]
259 #[must_use]
260 pub fn form(&mut self) -> FormW<CtrlaSpec> {
261 FormW::new(self, 24)
262 }
263 #[doc = "Bit 28 - Clock Phase"]
264 #[inline(always)]
265 #[must_use]
266 pub fn cpha(&mut self) -> CphaW<CtrlaSpec> {
267 CphaW::new(self, 28)
268 }
269 #[doc = "Bit 29 - Clock Polarity"]
270 #[inline(always)]
271 #[must_use]
272 pub fn cpol(&mut self) -> CpolW<CtrlaSpec> {
273 CpolW::new(self, 29)
274 }
275 #[doc = "Bit 30 - Data Order"]
276 #[inline(always)]
277 #[must_use]
278 pub fn dord(&mut self) -> DordW<CtrlaSpec> {
279 DordW::new(self, 30)
280 }
281}
282#[doc = "SPI Control A\n\nYou can [`read`](crate::Reg::read) this register and get [`ctrla::R`](R). You can [`reset`](crate::Reg::reset), [`write`](crate::Reg::write), [`write_with_zero`](crate::Reg::write_with_zero) this register using [`ctrla::W`](W). You can also [`modify`](crate::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
283pub struct CtrlaSpec;
284impl crate::RegisterSpec for CtrlaSpec {
285 type Ux = u32;
286}
287#[doc = "`read()` method returns [`ctrla::R`](R) reader structure"]
288impl crate::Readable for CtrlaSpec {}
289#[doc = "`write(|w| ..)` method takes [`ctrla::W`](W) writer structure"]
290impl crate::Writable for CtrlaSpec {
291 type Safety = crate::Unsafe;
292 const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
293 const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
294}
295#[doc = "`reset()` method sets CTRLA to value 0"]
296impl crate::Resettable for CtrlaSpec {
297 const RESET_VALUE: u32 = 0;
298}