forked from tobyp/kthw
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pins.inc.h
228 lines (189 loc) · 4.51 KB
/
pins.inc.h
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
#define PIN_0 0
#define PIN_1 1
#define PIN_2 2
#define PIN_3 3
#define PIN_4 4
#define PIN_5 5
#define PIN_6 6
#define PIN_7 7
#define PIN_8 8
#define PIN_9 9
#define PIN_10 10
#define PIN_11 11
#define PIN_12 12
#define PIN_13 13
#define PIN_14 14
#define PIN_15 15
#define GM_MASK 0x3
#define GM_OUT 0x1
#define GM_IN 0x0
#define GPP_DOWN 0x2
/* Preprocessor magic. */
#define GPIO_OUT(bank, idx) {GPIO##bank##_BASE, GM_OUT, PIN_##idx}
#define GPIO_IN(bank, idx) {GPIO##bank##_BASE, GM_IN, PIN_##idx}
/*
//Useful if you temporarily want to disable a pin - just uncomment and use the DUMMY port
static const uint32_t dummy_gpio_port[10] = {0};
#define GPIODUMMY_BASE ((uint32_t)&dummy_gpio_port)
*/
/* To use new ports, adjust the GPIO section of main() */
enum {
GP_SR_SRCLK,
GP_SR_RCLK,
GP_TIMER0_SER,
GP_TIMER1_SER,
GP_TIMER2_SER,
GP_TIMER3_SER,
GP_BUZZER,
GP_BUZZER2,
GP_FLAGS0_SER,
GP_FLAGS1_SER,
GP_FLAGS0_IN,
GP_FLAGS1_IN,
GP_STRIKES_SER,
GP_SIMONSAYS_SER,
GP_SIMONSAYS_BTN,
GP_MORSE_FREQ0_SER,
GP_MORSE_FREQ1_SER,
GP_MORSE_FREQ2_SER,
GP_MORSE_FREQ3_SER,
GP_MORSE_LED,
GP_MORSE_BTN,
GP_WIRES_SER,
GP_CAP0_SER,
GP_CAP1_SER,
GP_CAP_IN,
GP_MEM0_SER,
GP_MEM1_SER,
GP_MEM2_SER,
GP_MEM3_SER,
GP_MEM_DISP_SER,
GP_MEM_STAGE_SER,
GP_MEM_BTN_SER,
GP_MEM_BTN_IN,
GP_PWD_SER,
GP_PWD_IN,
GP_PWD_LCD_SER,
GP_PWD_LCD_RS,
GP_PWD_LCD_EN,
};
struct gpio pins[] = {
GPIO_OUT(C, 3), //GP_SR_SRCLK
GPIO_OUT(C, 2), //GP_SR_RCLK
GPIO_OUT(A, 3), //GP_TIMER0_SER
GPIO_OUT(A, 5), //GP_TIMER1_SER
GPIO_OUT(A, 7), //GP_TIMER2_SER
GPIO_OUT(C, 5), //GP_TIMER3_SER
GPIO_OUT(B, 1), //GP_BUZZER
GPIO_OUT(B, 15), //GP_BUZZER2
GPIO_OUT(B, 12), //GP_FLAGS0_SER
GPIO_OUT(B, 14), //GP_FLAGS1_SER
GPIO_IN(D, 8), //GP_FLAGS0_IN
GPIO_IN(D, 10), //GP_FLAGS1_IN
GPIO_OUT(B, 0), //GP_STRIKES_SER
GPIO_OUT(D, 11), //GP_SIMONSAYS_SER
GPIO_IN(E, 8), //GP_SIMONSAYS_BTN
GPIO_OUT(E, 9), //GP_MORSE_FREQ0_SER
GPIO_OUT(E, 11), //GP_MORSE_FREQ1_SER
GPIO_OUT(E, 13), //GP_MORSE_FREQ2_SER
GPIO_OUT(E, 15), //GP_MORSE_FREQ3_SER
GPIO_OUT(E, 10), //GP_MORSE_LED
GPIO_IN(E, 12), //GP_MORSE_BTN
GPIO_OUT(E, 14), //GP_WIRES_SER
GPIO_OUT(E, 2), //GP_CAP0_SER
GPIO_OUT(C, 7), //GP_CAP1_SER
GPIO_IN(E, 3), //GP_CAP_IN
GPIO_OUT(E, 4), //GP_MEM0_SER
GPIO_OUT(E, 6), //GP_MEM1_SER
GPIO_OUT(C, 14), //GP_MEM2_SER
GPIO_OUT(B, 8), //GP_MEM3_SER
GPIO_OUT(B, 9), //GP_MEM_DISP_SER
GPIO_OUT(C, 15), //GP_MEM_STAGE_SER
GPIO_OUT(C, 13), //GP_MEM_BTN_SER
GPIO_IN(E, 5), //GP_MEM_BTN_IN
GPIO_OUT(D, 3), //GP_PWD_SER
GPIO_IN(C, 12), //GP_PWD_IN
GPIO_OUT(D, 4), //GP_PWD_LCD_SER
GPIO_OUT(D, 2), //GP_PWD_LCD_RS
GPIO_OUT(D, 0), //GP_PWD_LCD_EN
};
//pins that are hard-wired, or initialized to AF on reset:
//A13: JTMS
//A14: JLCK
//A15: JTDI
//B3: JLDO
//B4: NJTRST
//D5: STM32F4Discovery: red LED
//D12: STM32F4Discovery: green LED
//D13: STM32F4Discovery: orange LED
//D14: STM32F4Discovery: red LED
//D15: STM32F4Discovery: blue LED
enum {
SR_TIMER0, //seconds (ones), use util.h's sevenseg_digits
SR_TIMER1, //seconds (tens), use util.h's sevenseg_digits
SR_TIMER2, //minutes (ones), use util.h's sevenseg_digits
SR_TIMER3, //minutes (tens), use util.h's sevenseg_digits
SR_STRIKE_COMPLETE, //(MSB) complete 5..1, strike 3..1 (LSB)
SR_FLAGS0, //see BF_* constants in bomb.h
SR_FLAGS1, //(MSB) 6 bits = time / 15s; 2 bits = strike limit
SR_SIMON_SAYS,
SR_MORSE_FREQ0,
SR_MORSE_FREQ1,
SR_MORSE_FREQ2,
SR_MORSE_FREQ3,
SR_WIRES,
SR_CAP0,
SR_CAP1,
SR_MEM0,
SR_MEM1,
SR_MEM2,
SR_MEM3,
SR_MEM_DISP,
SR_MEM_STAGE,
SR_MEM_BTN,
SR_PWD_LCD,
SR_PWD_SER,
};
struct shreg shregs[] = {
{&pins[GP_TIMER0_SER], 0},
{&pins[GP_TIMER1_SER], 0},
{&pins[GP_TIMER2_SER], 0},
{&pins[GP_TIMER3_SER], 0},
{&pins[GP_STRIKES_SER], 0},
{&pins[GP_FLAGS0_SER], 0},
{&pins[GP_FLAGS1_SER], 0},
{&pins[GP_SIMONSAYS_SER], 0},
{&pins[GP_MORSE_FREQ0_SER], 0},
{&pins[GP_MORSE_FREQ1_SER], 0},
{&pins[GP_MORSE_FREQ2_SER], 0},
{&pins[GP_MORSE_FREQ3_SER], 0},
{&pins[GP_WIRES_SER], 0},
{&pins[GP_CAP0_SER], 0},
{&pins[GP_CAP1_SER], 0},
{&pins[GP_MEM0_SER], 0},
{&pins[GP_MEM1_SER], 0},
{&pins[GP_MEM2_SER], 0},
{&pins[GP_MEM3_SER], 0},
{&pins[GP_MEM_DISP_SER], 0},
{&pins[GP_MEM_STAGE_SER], 0},
{&pins[GP_MEM_BTN_SER], 0},
{&pins[GP_PWD_LCD_SER], 0},
{&pins[GP_PWD_SER], 0},
};
/* ADCs */
/* To add more ADCs, adjust the ADC section of main() */
enum {
ADC_MORSE,
ADC_WIRES,
};
struct adc adcs[] = {
{10, 0},
{11, 0},
};
/* LCDs */
enum {
LCD_PWD,
};
struct lcd lcds[] = {
{&pins[GP_PWD_LCD_RS], &pins[GP_PWD_LCD_EN], &shregs[SR_PWD_LCD], LCD_NONE, 0},
};