1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
#[doc = "Register `SPI_CTRLR0` reader"]
pub type R = crate::R<SPI_CTRLR0_SPEC>;
#[doc = "Register `SPI_CTRLR0` writer"]
pub type W = crate::W<SPI_CTRLR0_SPEC>;
#[doc = "Field `TRANS_TYPE` reader - Address and instruction transfer format"]
pub type TRANS_TYPE_R = crate::FieldReader<TRANS_TYPE_A>;
#[doc = "Address and instruction transfer format  

Value on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum TRANS_TYPE_A {
    #[doc = "0: Command and address both in standard SPI frame format"]
    _1C1A = 0,
    #[doc = "1: Command in standard SPI format, address in format specified by FRF"]
    _1C2A = 1,
    #[doc = "2: Command and address both in format specified by FRF (e.g. Dual-SPI)"]
    _2C2A = 2,
}
impl From<TRANS_TYPE_A> for u8 {
    #[inline(always)]
    fn from(variant: TRANS_TYPE_A) -> Self {
        variant as _
    }
}
impl crate::FieldSpec for TRANS_TYPE_A {
    type Ux = u8;
}
impl TRANS_TYPE_R {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub const fn variant(&self) -> Option<TRANS_TYPE_A> {
        match self.bits {
            0 => Some(TRANS_TYPE_A::_1C1A),
            1 => Some(TRANS_TYPE_A::_1C2A),
            2 => Some(TRANS_TYPE_A::_2C2A),
            _ => None,
        }
    }
    #[doc = "Command and address both in standard SPI frame format"]
    #[inline(always)]
    pub fn is_1c1a(&self) -> bool {
        *self == TRANS_TYPE_A::_1C1A
    }
    #[doc = "Command in standard SPI format, address in format specified by FRF"]
    #[inline(always)]
    pub fn is_1c2a(&self) -> bool {
        *self == TRANS_TYPE_A::_1C2A
    }
    #[doc = "Command and address both in format specified by FRF (e.g. Dual-SPI)"]
    #[inline(always)]
    pub fn is_2c2a(&self) -> bool {
        *self == TRANS_TYPE_A::_2C2A
    }
}
#[doc = "Field `TRANS_TYPE` writer - Address and instruction transfer format"]
pub type TRANS_TYPE_W<'a, REG> = crate::FieldWriter<'a, REG, 2, TRANS_TYPE_A>;
impl<'a, REG> TRANS_TYPE_W<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
    REG::Ux: From<u8>,
{
    #[doc = "Command and address both in standard SPI frame format"]
    #[inline(always)]
    pub fn _1c1a(self) -> &'a mut crate::W<REG> {
        self.variant(TRANS_TYPE_A::_1C1A)
    }
    #[doc = "Command in standard SPI format, address in format specified by FRF"]
    #[inline(always)]
    pub fn _1c2a(self) -> &'a mut crate::W<REG> {
        self.variant(TRANS_TYPE_A::_1C2A)
    }
    #[doc = "Command and address both in format specified by FRF (e.g. Dual-SPI)"]
    #[inline(always)]
    pub fn _2c2a(self) -> &'a mut crate::W<REG> {
        self.variant(TRANS_TYPE_A::_2C2A)
    }
}
#[doc = "Field `ADDR_L` reader - Address length (0b-60b in 4b increments)"]
pub type ADDR_L_R = crate::FieldReader;
#[doc = "Field `ADDR_L` writer - Address length (0b-60b in 4b increments)"]
pub type ADDR_L_W<'a, REG> = crate::FieldWriter<'a, REG, 4>;
#[doc = "Field `INST_L` reader - Instruction length (0/4/8/16b)"]
pub type INST_L_R = crate::FieldReader<INST_L_A>;
#[doc = "Instruction length (0/4/8/16b)  

Value on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum INST_L_A {
    #[doc = "0: No instruction"]
    NONE = 0,
    #[doc = "1: 4-bit instruction"]
    _4B = 1,
    #[doc = "2: 8-bit instruction"]
    _8B = 2,
    #[doc = "3: 16-bit instruction"]
    _16B = 3,
}
impl From<INST_L_A> for u8 {
    #[inline(always)]
    fn from(variant: INST_L_A) -> Self {
        variant as _
    }
}
impl crate::FieldSpec for INST_L_A {
    type Ux = u8;
}
impl INST_L_R {
    #[doc = "Get enumerated values variant"]
    #[inline(always)]
    pub const fn variant(&self) -> INST_L_A {
        match self.bits {
            0 => INST_L_A::NONE,
            1 => INST_L_A::_4B,
            2 => INST_L_A::_8B,
            3 => INST_L_A::_16B,
            _ => unreachable!(),
        }
    }
    #[doc = "No instruction"]
    #[inline(always)]
    pub fn is_none(&self) -> bool {
        *self == INST_L_A::NONE
    }
    #[doc = "4-bit instruction"]
    #[inline(always)]
    pub fn is_4b(&self) -> bool {
        *self == INST_L_A::_4B
    }
    #[doc = "8-bit instruction"]
    #[inline(always)]
    pub fn is_8b(&self) -> bool {
        *self == INST_L_A::_8B
    }
    #[doc = "16-bit instruction"]
    #[inline(always)]
    pub fn is_16b(&self) -> bool {
        *self == INST_L_A::_16B
    }
}
#[doc = "Field `INST_L` writer - Instruction length (0/4/8/16b)"]
pub type INST_L_W<'a, REG> = crate::FieldWriterSafe<'a, REG, 2, INST_L_A>;
impl<'a, REG> INST_L_W<'a, REG>
where
    REG: crate::Writable + crate::RegisterSpec,
    REG::Ux: From<u8>,
{
    #[doc = "No instruction"]
    #[inline(always)]
    pub fn none(self) -> &'a mut crate::W<REG> {
        self.variant(INST_L_A::NONE)
    }
    #[doc = "4-bit instruction"]
    #[inline(always)]
    pub fn _4b(self) -> &'a mut crate::W<REG> {
        self.variant(INST_L_A::_4B)
    }
    #[doc = "8-bit instruction"]
    #[inline(always)]
    pub fn _8b(self) -> &'a mut crate::W<REG> {
        self.variant(INST_L_A::_8B)
    }
    #[doc = "16-bit instruction"]
    #[inline(always)]
    pub fn _16b(self) -> &'a mut crate::W<REG> {
        self.variant(INST_L_A::_16B)
    }
}
#[doc = "Field `WAIT_CYCLES` reader - Wait cycles between control frame transmit and data reception (in SCLK cycles)"]
pub type WAIT_CYCLES_R = crate::FieldReader;
#[doc = "Field `WAIT_CYCLES` writer - Wait cycles between control frame transmit and data reception (in SCLK cycles)"]
pub type WAIT_CYCLES_W<'a, REG> = crate::FieldWriter<'a, REG, 5>;
#[doc = "Field `SPI_DDR_EN` reader - SPI DDR transfer enable"]
pub type SPI_DDR_EN_R = crate::BitReader;
#[doc = "Field `SPI_DDR_EN` writer - SPI DDR transfer enable"]
pub type SPI_DDR_EN_W<'a, REG> = crate::BitWriter<'a, REG>;
#[doc = "Field `INST_DDR_EN` reader - Instruction DDR transfer enable"]
pub type INST_DDR_EN_R = crate::BitReader;
#[doc = "Field `INST_DDR_EN` writer - Instruction DDR transfer enable"]
pub type INST_DDR_EN_W<'a, REG> = crate::BitWriter<'a, REG>;
#[doc = "Field `SPI_RXDS_EN` reader - Read data strobe enable"]
pub type SPI_RXDS_EN_R = crate::BitReader;
#[doc = "Field `SPI_RXDS_EN` writer - Read data strobe enable"]
pub type SPI_RXDS_EN_W<'a, REG> = crate::BitWriter<'a, REG>;
#[doc = "Field `XIP_CMD` reader - SPI Command to send in XIP mode (INST_L = 8-bit) or to append to Address (INST_L = 0-bit)"]
pub type XIP_CMD_R = crate::FieldReader;
#[doc = "Field `XIP_CMD` writer - SPI Command to send in XIP mode (INST_L = 8-bit) or to append to Address (INST_L = 0-bit)"]
pub type XIP_CMD_W<'a, REG> = crate::FieldWriter<'a, REG, 8>;
impl R {
    #[doc = "Bits 0:1 - Address and instruction transfer format"]
    #[inline(always)]
    pub fn trans_type(&self) -> TRANS_TYPE_R {
        TRANS_TYPE_R::new((self.bits & 3) as u8)
    }
    #[doc = "Bits 2:5 - Address length (0b-60b in 4b increments)"]
    #[inline(always)]
    pub fn addr_l(&self) -> ADDR_L_R {
        ADDR_L_R::new(((self.bits >> 2) & 0x0f) as u8)
    }
    #[doc = "Bits 8:9 - Instruction length (0/4/8/16b)"]
    #[inline(always)]
    pub fn inst_l(&self) -> INST_L_R {
        INST_L_R::new(((self.bits >> 8) & 3) as u8)
    }
    #[doc = "Bits 11:15 - Wait cycles between control frame transmit and data reception (in SCLK cycles)"]
    #[inline(always)]
    pub fn wait_cycles(&self) -> WAIT_CYCLES_R {
        WAIT_CYCLES_R::new(((self.bits >> 11) & 0x1f) as u8)
    }
    #[doc = "Bit 16 - SPI DDR transfer enable"]
    #[inline(always)]
    pub fn spi_ddr_en(&self) -> SPI_DDR_EN_R {
        SPI_DDR_EN_R::new(((self.bits >> 16) & 1) != 0)
    }
    #[doc = "Bit 17 - Instruction DDR transfer enable"]
    #[inline(always)]
    pub fn inst_ddr_en(&self) -> INST_DDR_EN_R {
        INST_DDR_EN_R::new(((self.bits >> 17) & 1) != 0)
    }
    #[doc = "Bit 18 - Read data strobe enable"]
    #[inline(always)]
    pub fn spi_rxds_en(&self) -> SPI_RXDS_EN_R {
        SPI_RXDS_EN_R::new(((self.bits >> 18) & 1) != 0)
    }
    #[doc = "Bits 24:31 - SPI Command to send in XIP mode (INST_L = 8-bit) or to append to Address (INST_L = 0-bit)"]
    #[inline(always)]
    pub fn xip_cmd(&self) -> XIP_CMD_R {
        XIP_CMD_R::new(((self.bits >> 24) & 0xff) as u8)
    }
}
impl W {
    #[doc = "Bits 0:1 - Address and instruction transfer format"]
    #[inline(always)]
    #[must_use]
    pub fn trans_type(&mut self) -> TRANS_TYPE_W<SPI_CTRLR0_SPEC> {
        TRANS_TYPE_W::new(self, 0)
    }
    #[doc = "Bits 2:5 - Address length (0b-60b in 4b increments)"]
    #[inline(always)]
    #[must_use]
    pub fn addr_l(&mut self) -> ADDR_L_W<SPI_CTRLR0_SPEC> {
        ADDR_L_W::new(self, 2)
    }
    #[doc = "Bits 8:9 - Instruction length (0/4/8/16b)"]
    #[inline(always)]
    #[must_use]
    pub fn inst_l(&mut self) -> INST_L_W<SPI_CTRLR0_SPEC> {
        INST_L_W::new(self, 8)
    }
    #[doc = "Bits 11:15 - Wait cycles between control frame transmit and data reception (in SCLK cycles)"]
    #[inline(always)]
    #[must_use]
    pub fn wait_cycles(&mut self) -> WAIT_CYCLES_W<SPI_CTRLR0_SPEC> {
        WAIT_CYCLES_W::new(self, 11)
    }
    #[doc = "Bit 16 - SPI DDR transfer enable"]
    #[inline(always)]
    #[must_use]
    pub fn spi_ddr_en(&mut self) -> SPI_DDR_EN_W<SPI_CTRLR0_SPEC> {
        SPI_DDR_EN_W::new(self, 16)
    }
    #[doc = "Bit 17 - Instruction DDR transfer enable"]
    #[inline(always)]
    #[must_use]
    pub fn inst_ddr_en(&mut self) -> INST_DDR_EN_W<SPI_CTRLR0_SPEC> {
        INST_DDR_EN_W::new(self, 17)
    }
    #[doc = "Bit 18 - Read data strobe enable"]
    #[inline(always)]
    #[must_use]
    pub fn spi_rxds_en(&mut self) -> SPI_RXDS_EN_W<SPI_CTRLR0_SPEC> {
        SPI_RXDS_EN_W::new(self, 18)
    }
    #[doc = "Bits 24:31 - SPI Command to send in XIP mode (INST_L = 8-bit) or to append to Address (INST_L = 0-bit)"]
    #[inline(always)]
    #[must_use]
    pub fn xip_cmd(&mut self) -> XIP_CMD_W<SPI_CTRLR0_SPEC> {
        XIP_CMD_W::new(self, 24)
    }
    #[doc = r" Writes raw bits to the register."]
    #[doc = r""]
    #[doc = r" # Safety"]
    #[doc = r""]
    #[doc = r" Passing incorrect value can cause undefined behaviour. See reference manual"]
    #[inline(always)]
    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
        self.bits = bits;
        self
    }
}
#[doc = "SPI control  

You can [`read`](crate::generic::Reg::read) this register and get [`spi_ctrlr0::R`](R).  You can [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero) this register using [`spi_ctrlr0::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
pub struct SPI_CTRLR0_SPEC;
impl crate::RegisterSpec for SPI_CTRLR0_SPEC {
    type Ux = u32;
}
#[doc = "`read()` method returns [`spi_ctrlr0::R`](R) reader structure"]
impl crate::Readable for SPI_CTRLR0_SPEC {}
#[doc = "`write(|w| ..)` method takes [`spi_ctrlr0::W`](W) writer structure"]
impl crate::Writable for SPI_CTRLR0_SPEC {
    const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
    const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
}
#[doc = "`reset()` method sets SPI_CTRLR0 to value 0x0300_0000"]
impl crate::Resettable for SPI_CTRLR0_SPEC {
    const RESET_VALUE: u32 = 0x0300_0000;
}