vorago_shared_hal/spi/
pins_vor1x.rs

1use super::{HwCsProvider, PinMiso, PinMosi, PinSck};
2use crate::FunctionSelect;
3use crate::gpio::{DynPinId, PinId};
4
5use crate::pins::{
6    Pa10, Pa11, Pa12, Pa13, Pa14, Pa15, Pa16, Pa17, Pa18, Pa19, Pa20, Pa21, Pa22, Pa23, Pa24, Pa25,
7    Pa26, Pa27, Pa28, Pa29, Pa30, Pa31, Pb0, Pb1, Pb2, Pb3, Pb4, Pb5, Pb6, Pb7, Pb8, Pb9, Pb10,
8    Pb11, Pb12, Pb13, Pb14, Pb15, Pb16, Pb17, Pb18, Pb19, Pb22, Pb23, Pin,
9};
10
11use super::{Bank, HwChipSelectId};
12
13// SPIA
14
15impl PinSck for Pin<Pa31> {
16    const SPI_ID: Bank = Bank::Spi0;
17    const FUN_SEL: FunctionSelect = FunctionSelect::Sel1;
18}
19impl PinMosi for Pin<Pa30> {
20    const SPI_ID: Bank = Bank::Spi0;
21    const FUN_SEL: FunctionSelect = FunctionSelect::Sel1;
22}
23impl PinMiso for Pin<Pa29> {
24    const SPI_ID: Bank = Bank::Spi0;
25    const FUN_SEL: FunctionSelect = FunctionSelect::Sel1;
26}
27
28impl PinSck for Pin<Pb9> {
29    const SPI_ID: Bank = Bank::Spi0;
30    const FUN_SEL: FunctionSelect = FunctionSelect::Sel2;
31}
32impl PinMosi for Pin<Pb8> {
33    const SPI_ID: Bank = Bank::Spi0;
34    const FUN_SEL: FunctionSelect = FunctionSelect::Sel2;
35}
36impl PinMiso for Pin<Pb7> {
37    const SPI_ID: Bank = Bank::Spi0;
38    const FUN_SEL: FunctionSelect = FunctionSelect::Sel2;
39}
40
41hw_cs_pins!(
42    Bank::Spi0,
43    (Pb0, FunctionSelect::Sel2, HwChipSelectId::Id1),
44    (Pb1, FunctionSelect::Sel2, HwChipSelectId::Id2),
45    (Pb2, FunctionSelect::Sel2, HwChipSelectId::Id3),
46    (Pb3, FunctionSelect::Sel2, HwChipSelectId::Id4),
47    (Pb4, FunctionSelect::Sel2, HwChipSelectId::Id5),
48    (Pb5, FunctionSelect::Sel2, HwChipSelectId::Id6),
49    (Pb6, FunctionSelect::Sel2, HwChipSelectId::Id0),
50    (Pa24, FunctionSelect::Sel1, HwChipSelectId::Id4),
51    (Pa25, FunctionSelect::Sel1, HwChipSelectId::Id3),
52    (Pa26, FunctionSelect::Sel1, HwChipSelectId::Id2),
53    (Pa27, FunctionSelect::Sel1, HwChipSelectId::Id1),
54    (Pa28, FunctionSelect::Sel1, HwChipSelectId::Id0),
55);
56
57hw_cs_multi_pin!(
58    PinPb0SpiaHwCsId1,
59    Pb0,
60    Bank::Spi0,
61    FunctionSelect::Sel2,
62    HwChipSelectId::Id1
63);
64hw_cs_multi_pin!(
65    PinPb1SpiaHwCsId2,
66    Pb1,
67    Bank::Spi0,
68    FunctionSelect::Sel2,
69    HwChipSelectId::Id2
70);
71hw_cs_multi_pin!(
72    PinPb2SpiaHwCsId3,
73    Pb2,
74    Bank::Spi0,
75    FunctionSelect::Sel2,
76    HwChipSelectId::Id3
77);
78
79hw_cs_multi_pin!(
80    PinPa21SpiaHwCsId7,
81    Pa21,
82    Bank::Spi0,
83    FunctionSelect::Sel1,
84    HwChipSelectId::Id7
85);
86hw_cs_multi_pin!(
87    PinPa22SpiaHwCsId6,
88    Pa22,
89    Bank::Spi0,
90    FunctionSelect::Sel1,
91    HwChipSelectId::Id6
92);
93hw_cs_multi_pin!(
94    PinPa23SpiaHwCsId5,
95    Pa23,
96    Bank::Spi0,
97    FunctionSelect::Sel1,
98    HwChipSelectId::Id5
99);
100
101// SPIB
102
103impl PinSck for Pin<Pa20> {
104    const SPI_ID: Bank = Bank::Spi1;
105    const FUN_SEL: FunctionSelect = FunctionSelect::Sel2;
106}
107impl PinMosi for Pin<Pa19> {
108    const SPI_ID: Bank = Bank::Spi1;
109    const FUN_SEL: FunctionSelect = FunctionSelect::Sel2;
110}
111impl PinMiso for Pin<Pa18> {
112    const SPI_ID: Bank = Bank::Spi1;
113    const FUN_SEL: FunctionSelect = FunctionSelect::Sel2;
114}
115
116pub type SpiBPortASck = Pin<Pa20>;
117pub type SpiBPortAMosi = Pin<Pa19>;
118pub type SpiBPortAMiso = Pin<Pa18>;
119
120impl PinSck for Pin<Pb19> {
121    const SPI_ID: Bank = Bank::Spi1;
122    const FUN_SEL: FunctionSelect = FunctionSelect::Sel1;
123}
124impl PinMosi for Pin<Pb18> {
125    const SPI_ID: Bank = Bank::Spi1;
126    const FUN_SEL: FunctionSelect = FunctionSelect::Sel1;
127}
128impl PinMiso for Pin<Pb17> {
129    const SPI_ID: Bank = Bank::Spi1;
130    const FUN_SEL: FunctionSelect = FunctionSelect::Sel1;
131}
132
133impl PinSck for Pin<Pb5> {
134    const SPI_ID: Bank = Bank::Spi1;
135    const FUN_SEL: FunctionSelect = FunctionSelect::Sel1;
136}
137impl PinMosi for Pin<Pb4> {
138    const SPI_ID: Bank = Bank::Spi1;
139    const FUN_SEL: FunctionSelect = FunctionSelect::Sel1;
140}
141impl PinMiso for Pin<Pb3> {
142    const SPI_ID: Bank = Bank::Spi1;
143    const FUN_SEL: FunctionSelect = FunctionSelect::Sel1;
144}
145
146// TODO: Need to deal with these duplications..
147hw_cs_pins!(
148    Bank::Spi1,
149    (Pb16, FunctionSelect::Sel1, HwChipSelectId::Id0),
150    (Pb15, FunctionSelect::Sel1, HwChipSelectId::Id1),
151    (Pb14, FunctionSelect::Sel1, HwChipSelectId::Id2),
152    (Pb13, FunctionSelect::Sel1, HwChipSelectId::Id3),
153    (Pa17, FunctionSelect::Sel2, HwChipSelectId::Id0),
154    (Pa16, FunctionSelect::Sel2, HwChipSelectId::Id1),
155    (Pa15, FunctionSelect::Sel2, HwChipSelectId::Id2),
156    (Pa14, FunctionSelect::Sel2, HwChipSelectId::Id3),
157    (Pa13, FunctionSelect::Sel2, HwChipSelectId::Id4),
158    (Pa12, FunctionSelect::Sel2, HwChipSelectId::Id5),
159    (Pa11, FunctionSelect::Sel2, HwChipSelectId::Id6),
160    (Pa10, FunctionSelect::Sel2, HwChipSelectId::Id7),
161    (Pa23, FunctionSelect::Sel2, HwChipSelectId::Id5),
162    (Pa22, FunctionSelect::Sel2, HwChipSelectId::Id6),
163    (Pa21, FunctionSelect::Sel2, HwChipSelectId::Id7),
164);
165
166hw_cs_multi_pin!(
167    PinPb0SpibHwCsId2,
168    Pb0,
169    Bank::Spi1,
170    FunctionSelect::Sel1,
171    HwChipSelectId::Id2
172);
173hw_cs_multi_pin!(
174    PinPb1SpibHwCsId1,
175    Pb1,
176    Bank::Spi1,
177    FunctionSelect::Sel1,
178    HwChipSelectId::Id1
179);
180hw_cs_multi_pin!(
181    PinPb2SpibHwCsId0,
182    Pb2,
183    Bank::Spi1,
184    FunctionSelect::Sel1,
185    HwChipSelectId::Id0
186);
187
188hw_cs_multi_pin!(
189    PinPb10SpibHwCsId6,
190    Pb10,
191    Bank::Spi1,
192    FunctionSelect::Sel1,
193    HwChipSelectId::Id6
194);
195hw_cs_multi_pin!(
196    PinPb11SpibHwCsId5,
197    Pb11,
198    Bank::Spi1,
199    FunctionSelect::Sel1,
200    HwChipSelectId::Id5
201);
202hw_cs_multi_pin!(
203    PinPb12SpibHwCsId4,
204    Pb12,
205    Bank::Spi1,
206    FunctionSelect::Sel1,
207    HwChipSelectId::Id4
208);
209
210hw_cs_multi_pin!(
211    PinPb10SpibHwCsId2,
212    Pb10,
213    Bank::Spi1,
214    FunctionSelect::Sel2,
215    HwChipSelectId::Id2
216);
217hw_cs_multi_pin!(
218    PinPb11SpibHwCsId1,
219    Pb11,
220    Bank::Spi1,
221    FunctionSelect::Sel2,
222    HwChipSelectId::Id1
223);
224hw_cs_multi_pin!(
225    PinPb12SpibHwCsId0,
226    Pb12,
227    Bank::Spi1,
228    FunctionSelect::Sel2,
229    HwChipSelectId::Id0
230);
231
232hw_cs_multi_pin!(
233    PinPa21SpibHwCsId7,
234    Pa21,
235    Bank::Spi1,
236    FunctionSelect::Sel2,
237    HwChipSelectId::Id7
238);
239hw_cs_multi_pin!(
240    PinPa22SpibHwCsId6,
241    Pa22,
242    Bank::Spi1,
243    FunctionSelect::Sel2,
244    HwChipSelectId::Id6
245);
246hw_cs_multi_pin!(
247    PinPa23SpibHwCsId5,
248    Pa23,
249    Bank::Spi1,
250    FunctionSelect::Sel2,
251    HwChipSelectId::Id5
252);
253
254// SPIC
255
256hw_cs_pins!(
257    Bank::Spi2,
258    (Pb9, FunctionSelect::Sel3, HwChipSelectId::Id1),
259    (Pb8, FunctionSelect::Sel3, HwChipSelectId::Id2),
260    (Pb7, FunctionSelect::Sel3, HwChipSelectId::Id3),
261    (Pb23, FunctionSelect::Sel3, HwChipSelectId::Id2),
262    (Pb22, FunctionSelect::Sel3, HwChipSelectId::Id1),
263    (Pa20, FunctionSelect::Sel1, HwChipSelectId::Id1),
264    (Pa19, FunctionSelect::Sel1, HwChipSelectId::Id2),
265    (Pb18, FunctionSelect::Sel1, HwChipSelectId::Id3),
266);
267
268hw_cs_multi_pin!(
269    PinPa21SpicHwCsId3,
270    Pa21,
271    Bank::Spi2,
272    FunctionSelect::Sel3,
273    HwChipSelectId::Id3
274);
275hw_cs_multi_pin!(
276    PinPa22SpicHwCsId2,
277    Pa22,
278    Bank::Spi2,
279    FunctionSelect::Sel3,
280    HwChipSelectId::Id2
281);
282hw_cs_multi_pin!(
283    PinPa23SpicHwCsId1,
284    Pa23,
285    Bank::Spi2,
286    FunctionSelect::Sel3,
287    HwChipSelectId::Id1
288);
289
290hw_cs_multi_pin!(
291    PinPa20SpicHwCsId1,
292    Pa20,
293    Bank::Spi2,
294    FunctionSelect::Sel1,
295    HwChipSelectId::Id1
296);
297hw_cs_multi_pin!(
298    PinPa20SpicHwCsId4,
299    Pa20,
300    Bank::Spi2,
301    FunctionSelect::Sel3,
302    HwChipSelectId::Id4
303);