@@ -170,6 +170,71 @@ void HW_Main_Init()
170
170
HW_GpioInit ();
171
171
}
172
172
173
+ static bool goDumb () {
174
+ // Setup GPIOPB12 as input
175
+ GPIO_InitTypeDef initStruct = {0 };
176
+ initStruct .Mode = GPIO_MODE_INPUT ;
177
+ initStruct .Pull = GPIO_PULLUP ;
178
+ initStruct .Speed = GPIO_SPEED_HIGH ;
179
+
180
+ HW_GPIO_Init ( GPIOB , GPIO_PIN_12 , & initStruct );
181
+
182
+ return HW_GPIO_Read (GPIOB , GPIO_PIN_12 ) == 0 ;
183
+ }
184
+
185
+ void setupPassthrough () {
186
+ // input pins
187
+ GPIO_InitTypeDef initStruct = {0 };
188
+ initStruct .Mode = GPIO_MODE_INPUT ;
189
+ initStruct .Pull = GPIO_NOPULL ;
190
+ initStruct .Speed = GPIO_SPEED_HIGH ;
191
+
192
+ HW_GPIO_Init ( GPIOB , GPIO_PIN_13 , & initStruct );
193
+ HW_GPIO_Init ( GPIOA , GPIO_PIN_3 , & initStruct );
194
+ HW_GPIO_Init ( GPIOA , GPIO_PIN_6 , & initStruct );
195
+ HW_GPIO_Init ( GPIOB , GPIO_PIN_4 , & initStruct );
196
+
197
+ // output pins
198
+ initStruct .Mode = GPIO_MODE_OUTPUT_PP ;
199
+ initStruct .Pull = GPIO_NOPULL ;
200
+
201
+ HW_GPIO_Init ( GPIOB , GPIO_PIN_3 , & initStruct );
202
+ HW_GPIO_Init ( GPIOA , GPIO_PIN_7 , & initStruct );
203
+ HW_GPIO_Init ( GPIOA , GPIO_PIN_2 , & initStruct );
204
+ #ifdef USE_DIO0_IRQ
205
+ HW_GPIO_Init ( GPIOB , GPIO_PIN_12 , & initStruct );
206
+ #endif
207
+ HW_GPIO_Init ( GPIOB , GPIO_PIN_15 , & initStruct );
208
+
209
+ // reset and SS pins
210
+ SX1276Reset ();
211
+ HW_GPIO_Init ( RADIO_NSS_PORT , RADIO_NSS_PIN , & initStruct );
212
+ #ifdef USE_DIO0_IRQ
213
+ HW_GPIO_Write ( RADIO_NSS_PORT , RADIO_NSS_PIN , 0 );
214
+ #endif
215
+ }
216
+
217
+ static inline void runPassthrough () {
218
+ // PB13 -> PB3
219
+ // PA3 -> PA7
220
+ // PA6 -> PA2
221
+ // PB4 -> PB12
222
+
223
+ #define PORTA_OUT_MASK ((1 << 2) | (1 << 7) | (1 << 15))
224
+
225
+ uint32_t InPortA = READ_REG (GPIOA -> IDR );
226
+ uint32_t InPortB = READ_REG (GPIOB -> IDR );
227
+
228
+ uint32_t OutPortB = (((InPortB & GPIO_PIN_13 ) >> 10 ));
229
+ uint32_t OutPortA = ((InPortA & GPIO_PIN_3 ) << 4 ) | ((InPortA & GPIO_PIN_6 ) >> 4 ) | ((InPortB & GPIO_PIN_12 ) << 3 );
230
+
231
+ WRITE_REG (GPIOA -> BSRR , ((OutPortA & PORTA_OUT_MASK ) | ((~OutPortA & PORTA_OUT_MASK ) << 16 )));
232
+ WRITE_REG (GPIOB -> BSRR , ((OutPortB & (1 << 3 )) | (((~OutPortB & (1 << 3 )) << 16 ))));
233
+ return ;
234
+ }
235
+
236
+
237
+
173
238
LoRaMacRegion_t globalRegion = LORAMAC_REGION_EU868 ;
174
239
175
240
int main (void )
@@ -180,6 +245,13 @@ int main(void)
180
245
/* Configure the system clock*/
181
246
SystemClock_Config ();
182
247
248
+ /* Read SS input (GPIOPB12); if low, enter dumb mode */
249
+ if (goDumb ()) {
250
+ setupPassthrough ();
251
+ while (1 ) {
252
+ runPassthrough ();
253
+ }
254
+ }
183
255
/* Configure the hardware*/
184
256
HW_Init ();
185
257
0 commit comments