1//! Enums used in Hspi configuration.
2
3#[allow(dead_code)]
4#[derive(Copy, Clone, defmt::Format)]
5pub(crate) enum HspiMode {
6 IndirectWrite,
7 IndirectRead,
8 AutoPolling,
9 MemoryMapped,
10}
11
12impl Into<u8> for HspiMode {
13 fn into(self) -> u8 {
14 match self {
15 HspiMode::IndirectWrite => 0b00,
16 HspiMode::IndirectRead => 0b01,
17 HspiMode::AutoPolling => 0b10,
18 HspiMode::MemoryMapped => 0b11,
19 }
20 }
21}
22
23/// Hspi lane width
24#[allow(dead_code)]
25#[derive(Copy, Clone, defmt::Format)]
26pub enum HspiWidth {
27 /// None
28 NONE,
29 /// Single lane
30 SING,
31 /// Dual lanes
32 DUAL,
33 /// Quad lanes
34 QUAD,
35 /// Eight lanes
36 OCTO,
37 /// Sixteen lanes
38 HEXADECA,
39}
40
41impl Into<u8> for HspiWidth {
42 fn into(self) -> u8 {
43 match self {
44 HspiWidth::NONE => 0b00,
45 HspiWidth::SING => 0b01,
46 HspiWidth::DUAL => 0b10,
47 HspiWidth::QUAD => 0b11,
48 HspiWidth::OCTO => 0b100,
49 HspiWidth::HEXADECA => 0b101,
50 }
51 }
52}
53
54/// Flash bank selection
55#[allow(dead_code)]
56#[derive(Copy, Clone, defmt::Format)]
57pub enum FlashSelection {
58 /// Bank 1
59 Flash1,
60 /// Bank 2
61 Flash2,
62}
63
64impl Into<bool> for FlashSelection {
65 fn into(self) -> bool {
66 match self {
67 FlashSelection::Flash1 => false,
68 FlashSelection::Flash2 => true,
69 }
70 }
71}
72
73/// Wrap Size
74#[allow(dead_code)]
75#[allow(missing_docs)]
76#[derive(Copy, Clone, defmt::Format)]
77pub enum WrapSize {
78 None,
79 _16Bytes,
80 _32Bytes,
81 _64Bytes,
82 _128Bytes,
83}
84
85impl Into<u8> for WrapSize {
86 fn into(self) -> u8 {
87 match self {
88 WrapSize::None => 0x00,
89 WrapSize::_16Bytes => 0x02,
90 WrapSize::_32Bytes => 0x03,
91 WrapSize::_64Bytes => 0x04,
92 WrapSize::_128Bytes => 0x05,
93 }
94 }
95}
96
97/// Memory Type
98#[allow(missing_docs)]
99#[allow(dead_code)]
100#[derive(Copy, Clone, defmt::Format)]
101pub enum MemoryType {
102 Micron,
103 Macronix,
104 Standard,
105 MacronixRam,
106 HyperBusMemory,
107 HyperBusRegister,
108}
109
110impl Into<u8> for MemoryType {
111 fn into(self) -> u8 {
112 match self {
113 MemoryType::Micron => 0x00,
114 MemoryType::Macronix => 0x01,
115 MemoryType::Standard => 0x02,
116 MemoryType::MacronixRam => 0x03,
117 MemoryType::HyperBusMemory => 0x04,
118 MemoryType::HyperBusRegister => 0x04,
119 }
120 }
121}
122
123/// Hspi memory size.
124#[allow(missing_docs)]
125#[derive(Copy, Clone, defmt::Format)]
126pub enum MemorySize {
127 _1KiB,
128 _2KiB,
129 _4KiB,
130 _8KiB,
131 _16KiB,
132 _32KiB,
133 _64KiB,
134 _128KiB,
135 _256KiB,
136 _512KiB,
137 _1MiB,
138 _2MiB,
139 _4MiB,
140 _8MiB,
141 _16MiB,
142 _32MiB,
143 _64MiB,
144 _128MiB,
145 _256MiB,
146 _512MiB,
147 _1GiB,
148 _2GiB,
149 _4GiB,
150 Other(u8),
151}
152
153impl Into<u8> for MemorySize {
154 fn into(self) -> u8 {
155 match self {
156 MemorySize::_1KiB => 6,
157 MemorySize::_2KiB => 7,
158 MemorySize::_4KiB => 8,
159 MemorySize::_8KiB => 9,
160 MemorySize::_16KiB => 10,
161 MemorySize::_32KiB => 11,
162 MemorySize::_64KiB => 12,
163 MemorySize::_128KiB => 13,
164 MemorySize::_256KiB => 14,
165 MemorySize::_512KiB => 15,
166 MemorySize::_1MiB => 16,
167 MemorySize::_2MiB => 17,
168 MemorySize::_4MiB => 18,
169 MemorySize::_8MiB => 19,
170 MemorySize::_16MiB => 20,
171 MemorySize::_32MiB => 21,
172 MemorySize::_64MiB => 22,
173 MemorySize::_128MiB => 23,
174 MemorySize::_256MiB => 24,
175 MemorySize::_512MiB => 25,
176 MemorySize::_1GiB => 26,
177 MemorySize::_2GiB => 27,
178 MemorySize::_4GiB => 28,
179 MemorySize::Other(val) => val,
180 }
181 }
182}
183
184/// Hspi Address size
185#[derive(Copy, Clone, defmt::Format)]
186pub enum AddressSize {
187 /// 8-bit address
188 _8Bit,
189 /// 16-bit address
190 _16Bit,
191 /// 24-bit address
192 _24Bit,
193 /// 32-bit address
194 _32Bit,
195}
196
197impl Into<u8> for AddressSize {
198 fn into(self) -> u8 {
199 match self {
200 AddressSize::_8Bit => 0b00,
201 AddressSize::_16Bit => 0b01,
202 AddressSize::_24Bit => 0b10,
203 AddressSize::_32Bit => 0b11,
204 }
205 }
206}
207
208/// Time the Chip Select line stays high.
209#[allow(missing_docs)]
210#[derive(Copy, Clone, defmt::Format)]
211pub enum ChipSelectHighTime {
212 _1Cycle,
213 _2Cycle,
214 _3Cycle,
215 _4Cycle,
216 _5Cycle,
217 _6Cycle,
218 _7Cycle,
219 _8Cycle,
220}
221
222impl Into<u8> for ChipSelectHighTime {
223 fn into(self) -> u8 {
224 match self {
225 ChipSelectHighTime::_1Cycle => 0,
226 ChipSelectHighTime::_2Cycle => 1,
227 ChipSelectHighTime::_3Cycle => 2,
228 ChipSelectHighTime::_4Cycle => 3,
229 ChipSelectHighTime::_5Cycle => 4,
230 ChipSelectHighTime::_6Cycle => 5,
231 ChipSelectHighTime::_7Cycle => 6,
232 ChipSelectHighTime::_8Cycle => 7,
233 }
234 }
235}
236
237/// FIFO threshold.
238#[allow(missing_docs)]
239#[derive(Copy, Clone, defmt::Format)]
240pub enum FIFOThresholdLevel {
241 _1Bytes,
242 _2Bytes,
243 _3Bytes,
244 _4Bytes,
245 _5Bytes,
246 _6Bytes,
247 _7Bytes,
248 _8Bytes,
249 _9Bytes,
250 _10Bytes,
251 _11Bytes,
252 _12Bytes,
253 _13Bytes,
254 _14Bytes,
255 _15Bytes,
256 _16Bytes,
257 _17Bytes,
258 _18Bytes,
259 _19Bytes,
260 _20Bytes,
261 _21Bytes,
262 _22Bytes,
263 _23Bytes,
264 _24Bytes,
265 _25Bytes,
266 _26Bytes,
267 _27Bytes,
268 _28Bytes,
269 _29Bytes,
270 _30Bytes,
271 _31Bytes,
272 _32Bytes,
273}
274
275impl Into<u8> for FIFOThresholdLevel {
276 fn into(self) -> u8 {
277 match self {
278 FIFOThresholdLevel::_1Bytes => 0,
279 FIFOThresholdLevel::_2Bytes => 1,
280 FIFOThresholdLevel::_3Bytes => 2,
281 FIFOThresholdLevel::_4Bytes => 3,
282 FIFOThresholdLevel::_5Bytes => 4,
283 FIFOThresholdLevel::_6Bytes => 5,
284 FIFOThresholdLevel::_7Bytes => 6,
285 FIFOThresholdLevel::_8Bytes => 7,
286 FIFOThresholdLevel::_9Bytes => 8,
287 FIFOThresholdLevel::_10Bytes => 9,
288 FIFOThresholdLevel::_11Bytes => 10,
289 FIFOThresholdLevel::_12Bytes => 11,
290 FIFOThresholdLevel::_13Bytes => 12,
291 FIFOThresholdLevel::_14Bytes => 13,
292 FIFOThresholdLevel::_15Bytes => 14,
293 FIFOThresholdLevel::_16Bytes => 15,
294 FIFOThresholdLevel::_17Bytes => 16,
295 FIFOThresholdLevel::_18Bytes => 17,
296 FIFOThresholdLevel::_19Bytes => 18,
297 FIFOThresholdLevel::_20Bytes => 19,
298 FIFOThresholdLevel::_21Bytes => 20,
299 FIFOThresholdLevel::_22Bytes => 21,
300 FIFOThresholdLevel::_23Bytes => 22,
301 FIFOThresholdLevel::_24Bytes => 23,
302 FIFOThresholdLevel::_25Bytes => 24,
303 FIFOThresholdLevel::_26Bytes => 25,
304 FIFOThresholdLevel::_27Bytes => 26,
305 FIFOThresholdLevel::_28Bytes => 27,
306 FIFOThresholdLevel::_29Bytes => 28,
307 FIFOThresholdLevel::_30Bytes => 29,
308 FIFOThresholdLevel::_31Bytes => 30,
309 FIFOThresholdLevel::_32Bytes => 31,
310 }
311 }
312}
313
314/// Dummy cycle count
315#[allow(missing_docs)]
316#[derive(Copy, Clone, defmt::Format)]
317pub enum DummyCycles {
318 _0,
319 _1,
320 _2,
321 _3,
322 _4,
323 _5,
324 _6,
325 _7,
326 _8,
327 _9,
328 _10,
329 _11,
330 _12,
331 _13,
332 _14,
333 _15,
334 _16,
335 _17,
336 _18,
337 _19,
338 _20,
339 _21,
340 _22,
341 _23,
342 _24,
343 _25,
344 _26,
345 _27,
346 _28,
347 _29,
348 _30,
349 _31,
350}
351
352impl Into<u8> for DummyCycles {
353 fn into(self) -> u8 {
354 match self {
355 DummyCycles::_0 => 0,
356 DummyCycles::_1 => 1,
357 DummyCycles::_2 => 2,
358 DummyCycles::_3 => 3,
359 DummyCycles::_4 => 4,
360 DummyCycles::_5 => 5,
361 DummyCycles::_6 => 6,
362 DummyCycles::_7 => 7,
363 DummyCycles::_8 => 8,
364 DummyCycles::_9 => 9,
365 DummyCycles::_10 => 10,
366 DummyCycles::_11 => 11,
367 DummyCycles::_12 => 12,
368 DummyCycles::_13 => 13,
369 DummyCycles::_14 => 14,
370 DummyCycles::_15 => 15,
371 DummyCycles::_16 => 16,
372 DummyCycles::_17 => 17,
373 DummyCycles::_18 => 18,
374 DummyCycles::_19 => 19,
375 DummyCycles::_20 => 20,
376 DummyCycles::_21 => 21,
377 DummyCycles::_22 => 22,
378 DummyCycles::_23 => 23,
379 DummyCycles::_24 => 24,
380 DummyCycles::_25 => 25,
381 DummyCycles::_26 => 26,
382 DummyCycles::_27 => 27,
383 DummyCycles::_28 => 28,
384 DummyCycles::_29 => 29,
385 DummyCycles::_30 => 30,
386 DummyCycles::_31 => 31,
387 }
388 }
389}
390
391/// Functional mode
392#[allow(missing_docs)]
393#[allow(dead_code)]
394#[derive(Copy, Clone, defmt::Format)]
395pub enum FunctionalMode {
396 IndirectWrite,
397 IndirectRead,
398 AutoStatusPolling,
399 MemoryMapped,
400}
401
402impl Into<u8> for FunctionalMode {
403 fn into(self) -> u8 {
404 match self {
405 FunctionalMode::IndirectWrite => 0x00,
406 FunctionalMode::IndirectRead => 0x01,
407 FunctionalMode::AutoStatusPolling => 0x02,
408 FunctionalMode::MemoryMapped => 0x03,
409 }
410 }
411}
412