28
28
#include " delays_driver.h"
29
29
#include " keys.h"
30
30
31
-
32
-
33
31
/* The output bit-order has to be (D = L, U = R):
34
- PL18 PL18U
35
- 0 LHL TR7D(L) TR5D(L)
36
- 1 LHR TR7U(R) TR5U(R)
37
- 2 LVD TR5D TR3D
38
- 3 LVU TR5U TR3U
39
- 4 RVD TR6D TR4D
40
- 5 RVU TR6U TR4U
41
- 6 RHL TR8D(L) TR6D(L)
42
- 7 RHR TR8U(R) TR6U(R)
43
- 8 LSD TR1D TR1D
44
- 9 LSU TR1U TR1U
45
- 10 RSD TR2D TR2D
46
- 11 RSU TR2U TR2U
47
- 12 EX1D TR3D TR7D
48
- 13 EX1U TR3U TR7U
49
- 14 EX2D TR4D TR8D
50
- 15 EX2U TR4U TR8U
32
+ PL18/PL18EV
33
+ 0 LHL TR7L
34
+ 1 LHR TR7R
35
+ 2 LVD TR5D
36
+ 3 LVU TR5U
37
+ 4 RVD TR6D
38
+ 5 RVU TR6U
39
+ 6 RHL TR8L
40
+ 7 RHR TR8R
41
+ 8 LSD TR1D
42
+ 9 LSU TR1U
43
+ 10 RSD TR2D
44
+ 11 RSU TR2U
45
+ 12 EX1D TR3D
46
+ 13 EX1U TR3U
47
+ 14 EX2D TR4D
48
+ 15 EX2U TR4U
51
49
*/
52
50
53
51
enum PhysicalTrims
54
52
{
55
- #if defined(RADIO_PL18U)
56
- TR5D = 0 ,
57
- TR5U,
58
- TR3D = 2 ,
59
- TR3U,
60
- TR4D = 4 ,
61
- TR4U,
62
- TR6D = 6 ,
63
- TR6U,
64
- TR1D = 8 ,
65
- TR1U,
66
- TR2D = 10 ,
67
- TR2U,
68
- TR7D = 12 ,
69
- TR7U,
70
- TR8D = 14 ,
71
- TR8U,
72
- #else
73
- TR7D = 0 ,
74
- TR7U,
53
+ TR7L = 0 ,
54
+ TR7R,
75
55
TR5D = 2 ,
76
56
TR5U,
77
57
TR6D = 4 ,
78
58
TR6U,
79
- TR8D = 6 ,
80
- TR8U ,
59
+ TR8L = 6 ,
60
+ TR8R ,
81
61
TR1D = 8 ,
82
62
TR1U,
83
63
TR2D = 10 ,
@@ -86,7 +66,6 @@ enum PhysicalTrims
86
66
TR3U,
87
67
TR4D = 14 ,
88
68
TR4U,
89
- #endif
90
69
};
91
70
92
71
void keysInit ()
@@ -96,9 +75,6 @@ void keysInit()
96
75
stm32_gpio_enable_clock (GPIOD);
97
76
stm32_gpio_enable_clock (GPIOG);
98
77
stm32_gpio_enable_clock (GPIOH);
99
- #if defined(RADIO_PL18U)
100
- stm32_gpio_enable_clock (GPIOI);
101
- #endif
102
78
stm32_gpio_enable_clock (GPIOJ);
103
79
104
80
LL_GPIO_InitTypeDef pinInit;
@@ -115,10 +91,8 @@ void keysInit()
115
91
pinInit.Pin = KEYS_GPIOD_PINS;
116
92
LL_GPIO_Init (GPIOD, &pinInit);
117
93
118
- #if defined(KEYS_GPIOH_PINS)
119
94
pinInit.Pin = KEYS_GPIOH_PINS;
120
95
LL_GPIO_Init (GPIOH, &pinInit);
121
- #endif
122
96
123
97
pinInit.Pin = KEYS_GPIOJ_PINS;
124
98
LL_GPIO_Init (GPIOJ, &pinInit);
@@ -130,15 +104,8 @@ void keysInit()
130
104
pinInit.Pin = KEYS_OUT_GPIOG_PINS;
131
105
LL_GPIO_Init (GPIOG, &pinInit);
132
106
133
- #if defined(KEYS_OUT_GPIOH_PINS)
134
107
pinInit.Pin = KEYS_OUT_GPIOH_PINS;
135
108
LL_GPIO_Init (GPIOH, &pinInit);
136
- #endif
137
-
138
- #if defined(KEYS_OUT_GPIOI_PINS)
139
- pinInit.Pin = KEYS_OUT_GPIOI_PINS;
140
- LL_GPIO_Init (GPIOI, &pinInit);
141
- #endif
142
109
}
143
110
144
111
static uint32_t _readKeyMatrix ()
@@ -165,16 +132,11 @@ static uint32_t _readKeyMatrix()
165
132
LL_GPIO_ResetOutputPin (TRIMS_GPIO_OUT1, TRIMS_GPIO_OUT1_PIN);
166
133
LL_GPIO_SetOutputPin (TRIMS_GPIO_OUT2, TRIMS_GPIO_OUT2_PIN);
167
134
LL_GPIO_SetOutputPin (TRIMS_GPIO_OUT3, TRIMS_GPIO_OUT3_PIN);
168
-
169
- #if defined(TRIMS_GPIO_OUT4)
170
- LL_GPIO_SetOutputPin (TRIMS_GPIO_OUT4, TRIMS_GPIO_OUT4_PIN);
171
- #endif
172
-
173
135
delay_us (10 );
174
136
if (~TRIMS_GPIO_REG_IN1 & TRIMS_GPIO_PIN_IN1)
175
- result |= 1 << TR7D ;
137
+ result |= 1 << TR7L ;
176
138
if (~TRIMS_GPIO_REG_IN2 & TRIMS_GPIO_PIN_IN2)
177
- result |= 1 << TR7U ;
139
+ result |= 1 << TR7R ;
178
140
if (~TRIMS_GPIO_REG_IN3 & TRIMS_GPIO_PIN_IN3)
179
141
result |= 1 << TR5D;
180
142
if (~TRIMS_GPIO_REG_IN4 & TRIMS_GPIO_PIN_IN4)
@@ -200,26 +162,12 @@ static uint32_t _readKeyMatrix()
200
162
if (~TRIMS_GPIO_REG_IN2 & TRIMS_GPIO_PIN_IN2)
201
163
result |= 1 << TR6D;
202
164
if (~TRIMS_GPIO_REG_IN3 & TRIMS_GPIO_PIN_IN3)
203
- result |= 1 << TR8D ;
165
+ result |= 1 << TR8L ;
204
166
if (~TRIMS_GPIO_REG_IN4 & TRIMS_GPIO_PIN_IN4)
205
- result |= 1 << TR8U ;
167
+ result |= 1 << TR8R ;
206
168
207
169
LL_GPIO_SetOutputPin (TRIMS_GPIO_OUT3, TRIMS_GPIO_OUT3_PIN);
208
170
209
- #if defined(TRIMS_GPIO_OUT4)
210
- LL_GPIO_ResetOutputPin (TRIMS_GPIO_OUT4, TRIMS_GPIO_OUT4_PIN);
211
- delay_us (10 );
212
- if (~TRIMS_GPIO_REG_IN1 & TRIMS_GPIO_PIN_IN1)
213
- result |= 1 << TR1U;
214
- if (~TRIMS_GPIO_REG_IN2 & TRIMS_GPIO_PIN_IN2)
215
- result |= 1 << TR1D;
216
- if (~TRIMS_GPIO_REG_IN3 & TRIMS_GPIO_PIN_IN3)
217
- result |= 1 << TR2D;
218
- if (~TRIMS_GPIO_REG_IN4 & TRIMS_GPIO_PIN_IN4)
219
- result |= 1 << TR2U;
220
- LL_GPIO_SetOutputPin (TRIMS_GPIO_OUT4, TRIMS_GPIO_OUT4_PIN);
221
- #endif
222
-
223
171
syncelem.oldResult = result;
224
172
syncelem.ui8ReadInProgress = 0 ;
225
173
@@ -232,13 +180,8 @@ uint32_t readKeys()
232
180
233
181
if (getHatsAsKeys ()) {
234
182
uint32_t mkeys = _readKeyMatrix ();
235
- #if defined(RADIO_PL18U)
236
- if (mkeys & (1 << TR2D)) result |= 1 << KEY_ENTER;
237
- if (mkeys & (1 << TR2U)) result |= 1 << KEY_EXIT;
238
- #else
239
183
if (mkeys & (1 << TR4D)) result |= 1 << KEY_ENTER;
240
184
if (mkeys & (1 << TR4U)) result |= 1 << KEY_EXIT;
241
- #endif
242
185
}
243
186
244
187
return result;
@@ -250,22 +193,15 @@ uint32_t readTrims()
250
193
251
194
result |= _readKeyMatrix ();
252
195
253
- #if defined(TRIMS_GPIO_REG_TR1U)
254
196
if (~TRIMS_GPIO_REG_TR1U & TRIMS_GPIO_PIN_TR1U)
255
197
result |= 1 << (TR1U);
256
- #endif
257
- #if defined(TRIMS_GPIO_REG_TR1D)
258
198
if (~TRIMS_GPIO_REG_TR1D & TRIMS_GPIO_PIN_TR1D)
259
199
result |= 1 << (TR1D);
260
- #endif
261
- #if defined(TRIMS_GPIO_REG_TR2U)
200
+
262
201
if (~TRIMS_GPIO_REG_TR2U & TRIMS_GPIO_PIN_TR2U)
263
202
result |= 1 << (TR2U);
264
- #endif
265
- #if defined(TRIMS_GPIO_REG_TR2D)
266
203
if (~TRIMS_GPIO_REG_TR2D & TRIMS_GPIO_PIN_TR2D)
267
204
result |= 1 << (TR2D);
268
- #endif
269
205
270
206
return result;
271
207
}
0 commit comments