Browse Source

firmware: Update pins according to current schematics.

Mathias Gottschlag 5 years ago
parent
commit
1dfe8b1474
1 changed files with 153 additions and 139 deletions
  1. 153
    139
      hackamp/firmware/src/pins.rs

+ 153
- 139
hackamp/firmware/src/pins.rs View File

@@ -2,18 +2,14 @@
2 2
 #![warn(missing_docs)]
3 3
 #![allow(unused)] // TODO: Enable this warning again.
4 4
 
5
-use stm32f4xx_hal::gpio::gpioa::{PA0, PA1, PA10, PA11, PA12, PA15, PA2, PA3, PA4, PA5, PA6, PA7};
6
-use stm32f4xx_hal::gpio::gpiob::{PB10, PB13, PB14, PB15, PB3, PB4, PB5, PB6, PB7, PB9};
7
-use stm32f4xx_hal::gpio::gpioc::{PC0, PC1, PC15, PC2, PC3, PC6};
8
-use stm32f4xx_hal::gpio::gpiod::{PD0, PD1, PD10, PD11, PD12, PD13, PD14, PD15, PD7, PD8, PD9};
9
-use stm32f4xx_hal::gpio::gpioe::{PE3, PE4, PE5, PE6};
10
-use stm32f4xx_hal::gpio::gpiof::{
11
-    PF0, PF1, PF10, PF13, PF14, PF15, PF2, PF3, PF4, PF5, PF6, PF7, PF8, PF9,
12
-};
13
-use stm32f4xx_hal::gpio::gpiog::{PG10, PG11, PG13, PG14, PG15, PG2, PG3, PG4, PG5, PG6};
14
-use stm32f4xx_hal::gpio::{
15
-    Alternate, Floating, Input, OpenDrain, Output, PushPull, AF10, AF12, AF4, AF5, AF6, AF7,
16
-};
5
+use stm32f4xx_hal::gpio::gpioa::*;
6
+use stm32f4xx_hal::gpio::gpiob::*;
7
+use stm32f4xx_hal::gpio::gpioc::*;
8
+use stm32f4xx_hal::gpio::gpiod::*;
9
+use stm32f4xx_hal::gpio::gpioe::*;
10
+use stm32f4xx_hal::gpio::gpiof::*;
11
+use stm32f4xx_hal::gpio::gpiog::*;
12
+use stm32f4xx_hal::gpio::*;
17 13
 use stm32f4xx_hal::prelude::*;
18 14
 use stm32f4xx_hal::stm32::{DMA1, GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, I2S2EXT, SPI2};
19 15
 
@@ -21,91 +17,109 @@ use super::halext::i2s::I2SClocks;
21 17
 
22 18
 /// Front panel LEDs.
23 19
 pub struct LedPins {
24
-    vol0: PF2<Output<OpenDrain>>,
25
-    vol1: PF3<Output<OpenDrain>>,
26
-    vol2: PF4<Output<OpenDrain>>,
27
-    vol3: PF5<Output<OpenDrain>>,
28
-    vol4: PF6<Output<OpenDrain>>,
29
-    vol5: PF7<Output<OpenDrain>>,
30
-    vol6: PF8<Output<OpenDrain>>,
31
-    vol7: PF9<Output<OpenDrain>>,
32
-    vol8: PF10<Output<OpenDrain>>,
33
-    vol9: PC0<Output<OpenDrain>>,
34
-    vol10: PC1<Output<OpenDrain>>,
35
-    vol11: PA0<Output<OpenDrain>>,
36
-    vol12: PA1<Output<OpenDrain>>,
37
-    vol13: PA2<Output<OpenDrain>>,
38
-    vol14: PA3<Output<OpenDrain>>,
39
-    vol15: PA4<Output<OpenDrain>>,
40
-
41
-    front_rst: PG11<Output<PushPull>>,
42
-    front_sclk: PG13<Output<PushPull>>,
43
-    front_mosi: PG14<Output<PushPull>>,
44
-    front_rclk: PG15<Output<PushPull>>,
20
+    vol0: PC0<Output<OpenDrain>>,
21
+    vol1: PC1<Output<OpenDrain>>,
22
+    vol2: PA0<Output<OpenDrain>>,
23
+    vol3: PA1<Output<OpenDrain>>,
24
+    vol4: PA2<Output<OpenDrain>>,
25
+    vol5: PA3<Output<OpenDrain>>,
26
+    vol6: PC5<Output<OpenDrain>>,
27
+    vol7: PB0<Output<OpenDrain>>,
28
+    vol8: PB1<Output<OpenDrain>>,
29
+    vol9: PF11<Output<OpenDrain>>,
30
+    vol10: PF12<Output<OpenDrain>>,
31
+    vol11: PF13<Output<OpenDrain>>,
32
+    vol12: PF14<Output<OpenDrain>>,
33
+    vol13: PF15<Output<OpenDrain>>,
34
+    vol14: PG0<Output<OpenDrain>>,
35
+    vol15: PG1<Output<OpenDrain>>,
36
+
37
+    front_rst: PA4<Output<PushPull>>,
38
+    front_sclk: PA5<Alternate<AF5>>,
39
+    front_mosi: PA6<Alternate<AF5>>,
40
+    front_rclk: PA7<Output<PushPull>>,
45 41
 }
46 42
 
47 43
 /// Connection to the bluetooth module.
48 44
 pub struct BluetoothModulePins {
49
-    mfb: PG2<Output<PushPull>>,
50
-    p6: PG4<Output<PushPull>>,
51
-    p7: PG5<Output<PushPull>>,
52
-    p8: PG6<Input<Floating>>,
53
-    p9: PD15<Input<Floating>>,
54
-    p16: PD14<Output<PushPull>>,
55
-    p17: PD13<Output<PushPull>>,
56
-    p18: PD12<Output<PushPull>>,
57
-    p21: PD11<Output<PushPull>>,
58
-    p29: PD10<Input<Floating>>,
59
-    p30: PD9<Input<Floating>>,
60
-    p31: PD8<Input<Floating>>,
45
+    mfb: PG10<Output<PushPull>>,
46
+    p6: PG12<Output<PushPull>>,
47
+    p7: PG13<Output<PushPull>>,
48
+    p8: PG14<Input<Floating>>,
49
+    p9: PD7<Input<Floating>>,
50
+    p16: PD6<Output<PushPull>>,
51
+    p17: PD5<Output<PushPull>>,
52
+    p18: PD4<Output<PushPull>>,
53
+    p21: PD3<Output<PushPull>>,
54
+    p29: PD2<Input<Floating>>,
55
+    p30: PD1<Input<Floating>>,
56
+    p31: PD0<Input<Floating>>,
61 57
 
62
-    sda: PF0<Alternate<AF4>>,
63
-    scl: PF1<Alternate<AF4>>,
58
+    sda: PB7<Alternate<AF4>>,
59
+    scl: PB6<Alternate<AF4>>,
64 60
 
65
-    spi_pcm: PG3<Output<PushPull>>,
61
+    spi_pcm: PG11<Output<PushPull>>,
66 62
     i2s_ws: PA15<Alternate<AF6>>,
67
-    i2s_ck: PB3<Alternate<AF6>>,
68
-    i2s_sdi: PB4<Alternate<AF7>>,
69
-    i2s_sdo: PB5<Alternate<AF6>>,
63
+    i2s_ck: PC10<Alternate<AF6>>,
64
+    i2s_sdi: PC11<Alternate<AF5>>,
65
+    i2s_sdo: PC12<Alternate<AF6>>,
70 66
 }
71 67
 
72 68
 /// Front panel input pins.
73 69
 pub struct InputPins {
74
-    ir: PG10<Input<Floating>>,
75
-    hp_detect: PD7<Input<Floating>>,
76
-    pwr: PE3<Input<Floating>>,
77
-    mic1: PE4<Input<Floating>>,
78
-    mic2: PE5<Input<Floating>>,
79
-    bt1: PE6<Input<Floating>>,
80
-    bt2: PC15<Input<Floating>>,
81
-    enc_a: PA5<Input<Floating>>,
82
-    enc_b: PA6<Input<Floating>>,
83
-    enc_sw: PA7<Input<Floating>>,
70
+    ir: PC4<Input<Floating>>,
71
+    hp_detect: PC13<Input<Floating>>,
72
+    pwr: PF2<Input<Floating>>,
73
+    mic1: PF3<Input<Floating>>,
74
+    mic2: PF4<Input<Floating>>,
75
+    bt1: PF5<Input<Floating>>,
76
+    bt2: PF6<Input<Floating>>,
77
+    enc_a: PE7<Input<Floating>>,
78
+    enc_b: PE8<Input<Floating>>,
79
+    enc_sw: PE9<Input<Floating>>,
84 80
 }
85 81
 /// Connection to the amplifier ICs.
86 82
 pub struct AmplifierPins {
87
-    spk_fault: PD0<Input<Floating>>,
88
-    spk_shutdown: PD1<Output<PushPull>>,
83
+    spk_fault: PE0<Input<Floating>>,
84
+    spk_shutdown: PE1<Output<PushPull>>,
89 85
 
90
-    sda: PB7<Alternate<AF4>>,
91
-    scl: PB6<Alternate<AF4>>,
86
+    sda: PF0<Alternate<AF4>>,
87
+    scl: PF1<Alternate<AF4>>,
88
+
89
+    i2s_mck: PE2<Alternate<AF5>>,
90
+    i2s_ws: PE4<Alternate<AF5>>,
91
+    i2s_ck: PE5<Alternate<AF5>>,
92
+    i2s_sdi: PE6<Alternate<AF6>>,
93
+    i2s_sdo: PE3<Alternate<AF5>>,
94
+}
95
+
96
+/// USB pins.
97
+pub struct UsbPins {
98
+    usb1_detect: PB13<Input<Floating>>,
99
+    usb1_dm: PB14<Alternate<AF12>>,
100
+    usb1_dp: PB15<Alternate<AF12>>,
101
+    usb2_detect: PA10<Input<Floating>>,
102
+    usb2_dm: PA11<Alternate<AF10>>,
103
+    usb2_dp: PA12<Alternate<AF10>>,
104
+}
105
+
106
+/// Extension header pins.
107
+pub struct ExtensionPins {
108
+    amp_ready: PE10<Output<PushPull>>,
109
+    ext_ready: PE15<Input<Floating>>,
110
+
111
+    spi_ss: PE11<Alternate<AF5>>,
112
+    spi_sck: PE12<Alternate<AF5>>,
113
+    spi_miso: PE13<Alternate<AF5>>,
114
+    spi_mosi: PE14<Alternate<AF5>>,
92 115
 
93 116
     i2s_mck: PC6<Alternate<AF5>>,
94
-    i2s_ws: PB9<Alternate<AF5>>,
117
+    i2s_ws: PB12<Alternate<AF5>>,
95 118
     i2s_ck: PB10<Alternate<AF5>>,
96 119
     i2s_sdi: PC2<Alternate<AF6>>,
97 120
     i2s_sdo: PC3<Alternate<AF5>>,
98 121
 }
99 122
 
100
-/// USB pins.
101
-pub struct UsbPins {
102
-    usb1_detect: PA10<Input<Floating>>,
103
-    usb1_dm: PA11<Alternate<AF10>>,
104
-    usb1_dp: PA12<Alternate<AF10>>,
105
-    usb2_detect: PB13<Input<Floating>>,
106
-    usb2_dm: PB14<Alternate<AF12>>,
107
-    usb2_dp: PB15<Alternate<AF12>>,
108
-}
109 123
 
110 124
 /// Type which contains all GPIO pins.
111 125
 ///
@@ -143,88 +157,88 @@ impl Pins {
143 157
         let gpiog = gpiog.split();
144 158
 
145 159
         let leds = LedPins {
146
-            vol0: gpiof.pf2.into_open_drain_output(),
147
-            vol1: gpiof.pf3.into_open_drain_output(),
148
-            vol2: gpiof.pf4.into_open_drain_output(),
149
-            vol3: gpiof.pf5.into_open_drain_output(),
150
-            vol4: gpiof.pf6.into_open_drain_output(),
151
-            vol5: gpiof.pf7.into_open_drain_output(),
152
-            vol6: gpiof.pf8.into_open_drain_output(),
153
-            vol7: gpiof.pf9.into_open_drain_output(),
154
-            vol8: gpiof.pf10.into_open_drain_output(),
155
-            vol9: gpioc.pc0.into_open_drain_output(),
156
-            vol10: gpioc.pc1.into_open_drain_output(),
157
-            vol11: gpioa.pa0.into_open_drain_output(),
158
-            vol12: gpioa.pa1.into_open_drain_output(),
159
-            vol13: gpioa.pa2.into_open_drain_output(),
160
-            vol14: gpioa.pa3.into_open_drain_output(),
161
-            vol15: gpioa.pa4.into_open_drain_output(),
162
-
163
-            front_rst: gpiog.pg11.into_push_pull_output(),
164
-            front_sclk: gpiog.pg13.into_push_pull_output(),
165
-            front_mosi: gpiog.pg14.into_push_pull_output(),
166
-            front_rclk: gpiog.pg15.into_push_pull_output(),
160
+            vol0: gpioc.pc0.into_open_drain_output(),
161
+            vol1: gpioc.pc1.into_open_drain_output(),
162
+            vol2: gpioa.pa0.into_open_drain_output(),
163
+            vol3: gpioa.pa1.into_open_drain_output(),
164
+            vol4: gpioa.pa2.into_open_drain_output(),
165
+            vol5: gpioa.pa3.into_open_drain_output(),
166
+            vol6: gpioc.pc5.into_open_drain_output(),
167
+            vol7: gpiob.pb0.into_open_drain_output(),
168
+            vol8: gpiob.pb1.into_open_drain_output(),
169
+            vol9: gpiof.pf11.into_open_drain_output(),
170
+            vol10: gpiof.pf12.into_open_drain_output(),
171
+            vol11: gpiof.pf13.into_open_drain_output(),
172
+            vol12: gpiof.pf14.into_open_drain_output(),
173
+            vol13: gpiof.pf15.into_open_drain_output(),
174
+            vol14: gpiog.pg0.into_open_drain_output(),
175
+            vol15: gpiog.pg1.into_open_drain_output(),
176
+
177
+            front_rst: gpioa.pa4.into_push_pull_output(),
178
+            front_sclk: gpioa.pa5.into_alternate_af5(),
179
+            front_mosi: gpioa.pa6.into_alternate_af5(),
180
+            front_rclk: gpioa.pa7.into_push_pull_output(),
167 181
         };
168 182
         // TODO: Initial LED values.
169 183
 
170 184
         let bluetooth_module = BluetoothModulePins {
171
-            mfb: gpiog.pg2.into_push_pull_output(),
172
-            p6: gpiog.pg4.into_push_pull_output(),
173
-            p7: gpiog.pg5.into_push_pull_output(),
174
-            p8: gpiog.pg6.into_floating_input(),
175
-            p9: gpiod.pd15.into_floating_input(),
176
-            p16: gpiod.pd14.into_push_pull_output(),
177
-            p17: gpiod.pd13.into_push_pull_output(),
178
-            p18: gpiod.pd12.into_push_pull_output(),
179
-            p21: gpiod.pd11.into_push_pull_output(),
180
-            p29: gpiod.pd10.into_floating_input(),
181
-            p30: gpiod.pd9.into_floating_input(),
182
-            p31: gpiod.pd8.into_floating_input(),
185
+            mfb: gpiog.pg10.into_push_pull_output(),
186
+            p6: gpiog.pg12.into_push_pull_output(),
187
+            p7: gpiog.pg13.into_push_pull_output(),
188
+            p8: gpiog.pg14.into_floating_input(),
189
+            p9: gpiod.pd7.into_floating_input(),
190
+            p16: gpiod.pd6.into_push_pull_output(),
191
+            p17: gpiod.pd5.into_push_pull_output(),
192
+            p18: gpiod.pd4.into_push_pull_output(),
193
+            p21: gpiod.pd3.into_push_pull_output(),
194
+            p29: gpiod.pd2.into_floating_input(),
195
+            p30: gpiod.pd1.into_floating_input(),
196
+            p31: gpiod.pd0.into_floating_input(),
183 197
 
184
-            sda: gpiof.pf0.into_alternate_af4(),
185
-            scl: gpiof.pf1.into_alternate_af4(),
198
+            sda: gpiob.pb7.into_alternate_af4(),
199
+            scl: gpiob.pb6.into_alternate_af4(),
186 200
 
187
-            spi_pcm: gpiog.pg3.into_push_pull_output(),
201
+            spi_pcm: gpiog.pg11.into_push_pull_output(),
188 202
             i2s_ws: gpioa.pa15.into_alternate_af6(),
189
-            i2s_ck: gpiob.pb3.into_alternate_af6(),
190
-            i2s_sdi: gpiob.pb4.into_alternate_af7(),
191
-            i2s_sdo: gpiob.pb5.into_alternate_af6(),
203
+            i2s_ck: gpioc.pc10.into_alternate_af6(),
204
+            i2s_sdi: gpioc.pc11.into_alternate_af5(),
205
+            i2s_sdo: gpioc.pc12.into_alternate_af6(),
192 206
         };
193 207
 
194 208
         let input = InputPins {
195
-            ir: gpiog.pg10.into_floating_input(),
196
-            hp_detect: gpiod.pd7.into_floating_input(),
197
-            pwr: gpioe.pe3.into_floating_input(),
198
-            mic1: gpioe.pe4.into_floating_input(),
199
-            mic2: gpioe.pe5.into_floating_input(),
200
-            bt1: gpioe.pe6.into_floating_input(),
201
-            bt2: gpioc.pc15.into_floating_input(),
202
-            enc_a: gpioa.pa5.into_floating_input(),
203
-            enc_b: gpioa.pa6.into_floating_input(),
204
-            enc_sw: gpioa.pa7.into_floating_input(),
209
+            ir: gpioc.pc4.into_floating_input(),
210
+            hp_detect: gpioc.pc13.into_floating_input(),
211
+            pwr: gpiof.pf2.into_floating_input(),
212
+            mic1: gpiof.pf3.into_floating_input(),
213
+            mic2: gpiof.pf4.into_floating_input(),
214
+            bt1: gpiof.pf5.into_floating_input(),
215
+            bt2: gpiof.pf6.into_floating_input(),
216
+            enc_a: gpioe.pe7.into_floating_input(),
217
+            enc_b: gpioe.pe8.into_floating_input(),
218
+            enc_sw: gpioe.pe9.into_floating_input(),
205 219
         };
206 220
 
207 221
         let amplifier = AmplifierPins {
208
-            spk_fault: gpiod.pd0.into_floating_input(),
209
-            spk_shutdown: gpiod.pd1.into_push_pull_output(),
222
+            spk_fault: gpioe.pe0.into_floating_input(),
223
+            spk_shutdown: gpioe.pe1.into_push_pull_output(),
210 224
 
211
-            sda: gpiob.pb7.into_alternate_af4(),
212
-            scl: gpiob.pb6.into_alternate_af4(),
225
+            sda: gpiof.pf0.into_alternate_af4(),
226
+            scl: gpiof.pf1.into_alternate_af4(),
213 227
 
214
-            i2s_mck: gpioc.pc6.into_alternate_af5(),
215
-            i2s_ws: gpiob.pb9.into_alternate_af5(),
216
-            i2s_ck: gpiob.pb10.into_alternate_af5(),
217
-            i2s_sdi: gpioc.pc2.into_alternate_af6(),
218
-            i2s_sdo: gpioc.pc3.into_alternate_af5(),
228
+            i2s_mck: gpioe.pe2.into_alternate_af5(),
229
+            i2s_ws: gpioe.pe4.into_alternate_af5(),
230
+            i2s_ck: gpioe.pe5.into_alternate_af5(),
231
+            i2s_sdi: gpioe.pe6.into_alternate_af6(),
232
+            i2s_sdo: gpioe.pe3.into_alternate_af5(),
219 233
         };
220 234
 
221 235
         let usb = UsbPins {
222
-            usb1_detect: gpioa.pa10.into_floating_input(),
223
-            usb1_dm: gpioa.pa11.into_alternate_af10(),
224
-            usb1_dp: gpioa.pa12.into_alternate_af10(),
225
-            usb2_detect: gpiob.pb13.into_floating_input(),
226
-            usb2_dm: gpiob.pb14.into_alternate_af12(),
227
-            usb2_dp: gpiob.pb15.into_alternate_af12(),
236
+            usb1_detect: gpiob.pb13.into_floating_input(),
237
+            usb1_dm: gpiob.pb14.into_alternate_af12(),
238
+            usb1_dp: gpiob.pb15.into_alternate_af12(),
239
+            usb2_detect: gpioa.pa10.into_floating_input(),
240
+            usb2_dm: gpioa.pa11.into_alternate_af10(),
241
+            usb2_dp: gpioa.pa12.into_alternate_af10(),
228 242
         };
229 243
 
230 244
         /*let dma = StreamsTuple::new(dma1);

Loading…
Cancel
Save