1#[derive(Clone, Copy, Debug, PartialEq)]
7#[cfg_attr(feature = "defmt", derive(defmt::Format))]
8#[allow(unused)]
9pub enum FmcBank {
10 Bank1,
12 Bank2,
14 Bank3,
16 Bank4,
18 Bank5,
20 Bank6,
22}
23impl FmcBank {
24 pub fn ptr(self) -> *mut u32 {
26 use FmcBank::*;
27 (match self {
28 Bank1 => 0x6000_0000u32,
29 Bank2 => 0x7000_0000u32,
30 Bank3 => 0x8000_0000u32,
31 Bank4 => 0x9000_0000u32, Bank5 => 0xC000_0000u32,
33 Bank6 => 0xD000_0000u32,
34 }) as *mut u32
35 }
36}
37
38pub trait AddressPinSet {
40 const ADDRESS_PINS: u8;
42}
43
44macro_rules! address_pin_markers {
45 ($($AddressPins:ident, $addr:tt, $doc:expr;)+) => {
46 $(
47 #[doc=$doc]
49 #[derive(Clone, Copy, Debug)]
51 pub struct $AddressPins;
52 impl AddressPinSet for $AddressPins {
53 const ADDRESS_PINS: u8 = $addr;
54 }
55 )+
56 };
57}
58address_pin_markers!(
59 AddressPins11, 11, "11";
60 AddressPins12, 12, "12";
61 AddressPins13, 13, "13";
62);
63
64#[cfg(feature = "sdram")]
67use crate::sdram::{PinsSdram, SdramBank1, SdramBank2};
68
69#[cfg(feature = "sdram")]
70macro_rules! impl_16bit_sdram {
71 ($($pins:tt: [$ckeN:tt, $neN:tt,
72 $nInternalB:expr
73 $(, $pba1:ident: $ba1:tt)* ; $addressPins:ident
75 [ $($pa:ident: $a:ident),* ] ]),+) => {
77 $(
78 #[rustfmt::skip]
79 impl<PA0, PA1, PA2, PA3, PA4, PA5, PA6, PA7, PA8, PA9, PA10, $($pa,)*
81 PBA0, $($pba1,)* PD0, PD1, PD2, PD3, PD4, PD5, PD6, PD7, PD8,
82 PD9, PD10, PD11, PD12, PD13, PD14, PD15, PNBL0, PNBL1, PSDCKEn,
83 PSDCLK, PSDNCAS, PSDNEn, PSDNRAS, PSDNWE>
84 PinsSdram<$pins, $addressPins>
85 for (PA0, PA1, PA2, PA3, PA4, PA5, PA6, PA7, PA8, PA9, PA10, $($pa,)*
86 PBA0, $($pba1,)* PD0, PD1, PD2, PD3, PD4, PD5, PD6, PD7,
87 PD8, PD9, PD10, PD11, PD12, PD13, PD14, PD15, PNBL0, PNBL1,
88 PSDCKEn, PSDCLK, PSDNCAS, PSDNEn, PSDNRAS, PSDNWE)
89 where PA0: A0, PA1: A1, PA2: A2, PA3: A3, PA4: A4, PA5: A5, PA6: A6,
90 PA7: A7, PA8: A8, PA9: A9, PA10: A10, $($pa:$a,)*
91 PBA0: BA0, $($pba1:$ba1,)*
92 PD0: D0, PD1: D1, PD2: D2, PD3: D3, PD4: D4, PD5: D5, PD6: D6,
93 PD7: D7, PD8: D8, PD9: D9, PD10: D10, PD11: D11, PD12: D12,
94 PD13: D13, PD14: D14, PD15: D15,
95 PNBL0: NBL0, PNBL1: NBL1, PSDCKEn: $ckeN, PSDCLK: SDCLK,
96 PSDNCAS: SDNCAS, PSDNEn: $neN, PSDNRAS: SDNRAS, PSDNWE: SDNWE {
97
98 const NUMBER_INTERNAL_BANKS: u8 = $nInternalB;
99 }
100 )+
101 }
102}
103
104#[cfg(feature = "sdram")]
105macro_rules! impl_32bit_sdram {
106 ($($pins:tt: [$ckeN:tt, $neN:tt,
107 $nInternalB:expr
108 $(, $pba1:ident: $ba1:tt)* ; $addressPins:ident
110 [ $($pa:ident: $a:ident),* ] ]),+) => {
112 $(
113 #[rustfmt::skip]
114 impl<PA0, PA1, PA2, PA3, PA4, PA5, PA6, PA7, PA8, PA9, PA10, $($pa,)*
116 PBA0, $($pba1,)* PD0, PD1, PD2, PD3, PD4, PD5, PD6, PD7, PD8,
117 PD9, PD10, PD11, PD12, PD13, PD14, PD15, PD16, PD17, PD18, PD19,
118 PD20, PD21, PD22, PD23, PD24, PD25, PD26, PD27, PD28, PD29, PD30,
119 PD31, PNBL0, PNBL1, PNBL2, PNBL3, PSDCKEn, PSDCLK, PSDNCAS,
120 PSDNEn, PSDNRAS, PSDNWE>
121 PinsSdram<$pins, $addressPins>
122 for (PA0, PA1, PA2, PA3, PA4, PA5, PA6, PA7, PA8, PA9, PA10, $($pa,)*
123 PBA0, $($pba1,)* PD0, PD1, PD2, PD3, PD4, PD5, PD6, PD7,
124 PD8, PD9, PD10, PD11, PD12, PD13, PD14, PD15, PD16, PD17,
125 PD18, PD19, PD20, PD21, PD22, PD23, PD24, PD25, PD26, PD27,
126 PD28, PD29, PD30, PD31, PNBL0, PNBL1, PNBL2, PNBL3, PSDCKEn,
127 PSDCLK, PSDNCAS, PSDNEn, PSDNRAS, PSDNWE)
128 where PA0: A0, PA1: A1, PA2: A2, PA3: A3, PA4: A4, PA5: A5, PA6: A6,
129 PA7: A7, PA8: A8, PA9: A9, PA10: A10, $($pa:$a,)*
130 PBA0: BA0, $($pba1:$ba1,)*
131 PD0: D0, PD1: D1, PD2: D2, PD3: D3, PD4: D4, PD5: D5, PD6: D6,
132 PD7: D7, PD8: D8, PD9: D9, PD10: D10, PD11: D11, PD12: D12,
133 PD13: D13, PD14: D14, PD15: D15, PD16: D16, PD17: D17,
134 PD18: D18, PD19: D19, PD20: D20, PD21: D21, PD22: D22,
135 PD23: D23, PD24: D24, PD25: D25, PD26: D26, PD27: D27,
136 PD28: D28, PD29: D29, PD30: D30, PD31: D31,
137 PNBL0: NBL0, PNBL1: NBL1, PNBL2: NBL2, PNBL3: NBL3,
138 PSDCKEn: $ckeN, PSDCLK: SDCLK,
139 PSDNCAS: SDNCAS, PSDNEn: $neN, PSDNRAS: SDNRAS, PSDNWE: SDNWE {
140
141 const NUMBER_INTERNAL_BANKS: u8 = $nInternalB;
142 }
143 )+
144 }
145}
146
147#[cfg(feature = "sdram")]
148impl_16bit_sdram! {
149 SdramBank1: [SDCKE0, SDNE0, 2; AddressPins11 []],
151 SdramBank2: [SDCKE1, SDNE1, 2; AddressPins11 []],
152 SdramBank1: [SDCKE0, SDNE0, 4, PBA1: BA1; AddressPins11 []],
154 SdramBank2: [SDCKE1, SDNE1, 4, PBA1: BA1; AddressPins11 []],
155 SdramBank1: [SDCKE0, SDNE0, 2; AddressPins12 [PA11: A11]],
157 SdramBank2: [SDCKE1, SDNE1, 2; AddressPins12 [PA11: A11]],
158 SdramBank1: [SDCKE0, SDNE0, 4, PBA1: BA1; AddressPins12 [PA11: A11]],
160 SdramBank2: [SDCKE1, SDNE1, 4, PBA1: BA1; AddressPins12 [PA11: A11]],
161 SdramBank1: [SDCKE0, SDNE0, 2; AddressPins13 [PA11: A11, PA12: A12]],
163 SdramBank2: [SDCKE1, SDNE1, 2; AddressPins13 [PA11: A11, PA12: A12]],
164 SdramBank1: [SDCKE0, SDNE0, 4, PBA1: BA1; AddressPins13 [PA11: A11, PA12: A12]],
166 SdramBank2: [SDCKE1, SDNE1, 4, PBA1: BA1; AddressPins13 [PA11: A11, PA12: A12]]
167}
168
169#[cfg(feature = "sdram")]
170impl_32bit_sdram! {
171 SdramBank1: [SDCKE0, SDNE0, 2; AddressPins11 []],
173 SdramBank2: [SDCKE1, SDNE1, 2; AddressPins11 []],
174 SdramBank1: [SDCKE0, SDNE0, 4, PBA1: BA1; AddressPins11 []],
176 SdramBank2: [SDCKE1, SDNE1, 4, PBA1: BA1; AddressPins11 []],
177 SdramBank1: [SDCKE0, SDNE0, 2; AddressPins12 [PA11: A11]],
179 SdramBank2: [SDCKE1, SDNE1, 2; AddressPins12 [PA11: A11]],
180 SdramBank1: [SDCKE0, SDNE0, 4, PBA1: BA1; AddressPins12 [PA11: A11]],
182 SdramBank2: [SDCKE1, SDNE1, 4, PBA1: BA1; AddressPins12 [PA11: A11]],
183 SdramBank1: [SDCKE0, SDNE0, 2; AddressPins13 [PA11: A11, PA12: A12]],
185 SdramBank2: [SDCKE1, SDNE1, 2; AddressPins13 [PA11: A11, PA12: A12]],
186 SdramBank1: [SDCKE0, SDNE0, 4, PBA1: BA1; AddressPins13 [PA11: A11, PA12: A12]],
188 SdramBank2: [SDCKE1, SDNE1, 4, PBA1: BA1; AddressPins13 [PA11: A11, PA12: A12]]
189}
190
191#[cfg(feature = "nand")]
194use crate::nand::PinsNand;
195
196#[cfg(feature = "nand")]
197#[rustfmt::skip]
198impl<ALE, CLE, PD0, PD1, PD2, PD3, PD4, PD5, PD6, PD7, PNCE, PNOE, PNWE, PNWAIT>
200 PinsNand
201 for (ALE, CLE, PD0, PD1, PD2, PD3, PD4, PD5, PD6, PD7, PNCE, PNOE, PNWE, PNWAIT)
202where ALE: A17, CLE: A16,
203 PD0: D0, PD1: D1, PD2: D2, PD3: D3, PD4: D4, PD5: D5, PD6: D6, PD7: D7,
204 PNCE: NCE, PNOE: NOE, PNWE: NWE, PNWAIT: NWAIT {
205 const N_DATA: usize = 8;
206}
207
208pub trait A0 {}
210pub trait A1 {}
212pub trait A10 {}
214pub trait A11 {}
216pub trait A12 {}
218pub trait A13 {}
220pub trait A14 {}
222pub trait A15 {}
224pub trait A16 {}
226pub trait A17 {}
228pub trait A18 {}
230pub trait A19 {}
232pub trait A2 {}
234pub trait A20 {}
236pub trait A21 {}
238pub trait A22 {}
240pub trait A23 {}
242pub trait A24 {}
244pub trait A25 {}
246pub trait A3 {}
248pub trait A4 {}
250pub trait A5 {}
252pub trait A6 {}
254pub trait A7 {}
256pub trait A8 {}
258pub trait A9 {}
260pub trait BA0 {}
262pub trait BA1 {}
264pub trait CLK {}
266pub trait D0 {}
268pub trait D1 {}
270pub trait D10 {}
272pub trait D11 {}
274pub trait D12 {}
276pub trait D13 {}
278pub trait D14 {}
280pub trait D15 {}
282pub trait D16 {}
284pub trait D17 {}
286pub trait D18 {}
288pub trait D19 {}
290pub trait D2 {}
292pub trait D20 {}
294pub trait D21 {}
296pub trait D22 {}
298pub trait D23 {}
300pub trait D24 {}
302pub trait D25 {}
304pub trait D26 {}
306pub trait D27 {}
308pub trait D28 {}
310pub trait D29 {}
312pub trait D3 {}
314pub trait D30 {}
316pub trait D31 {}
318pub trait D4 {}
320pub trait D5 {}
322pub trait D6 {}
324pub trait D7 {}
326pub trait D8 {}
328pub trait D9 {}
330pub trait DA0 {}
332pub trait DA1 {}
334pub trait DA10 {}
336pub trait DA11 {}
338pub trait DA12 {}
340pub trait DA13 {}
342pub trait DA14 {}
344pub trait DA15 {}
346pub trait DA2 {}
348pub trait DA3 {}
350pub trait DA4 {}
352pub trait DA5 {}
354pub trait DA6 {}
356pub trait DA7 {}
358pub trait DA8 {}
360pub trait DA9 {}
362pub trait INT {}
364pub trait NBL0 {}
366pub trait NBL1 {}
368pub trait NBL2 {}
370pub trait NBL3 {}
372pub trait NE1 {}
374pub trait NE2 {}
376pub trait NE3 {}
378pub trait NE4 {}
380pub trait NL {}
382pub trait NCE {}
384pub trait NOE {}
386pub trait NWAIT {}
388pub trait NWE {}
390pub trait SDCKE0 {}
392pub trait SDCKE1 {}
394pub trait SDCLK {}
396pub trait SDNCAS {}
398pub trait SDNE0 {}
400pub trait SDNE1 {}
402pub trait SDNRAS {}
404pub trait SDNWE {}
406
407use crate::ral::fmc;
408use crate::FmcPeripheral;
409
410#[derive(Copy, Clone)]
411pub(crate) struct FmcRegisters(usize);
412
413impl FmcRegisters {
414 #[inline(always)]
415 pub fn new<FMC: FmcPeripheral>() -> Self {
416 Self(FMC::REGISTERS as usize)
417 }
418
419 #[inline(always)]
420 pub fn global(&self) -> &'static fmc::RegisterBlock {
421 unsafe { &*(self.0 as *const _) }
422 }
423}