-
-
Notifications
You must be signed in to change notification settings - Fork 345
/
hal.h
2893 lines (2827 loc) · 138 KB
/
hal.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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#pragma once
#if defined(STM32F413xx)
#define CPU_FREQ 100000000
#define PERI1_FREQUENCY 50000000
#define PERI2_FREQUENCY 100000000
#define TIMER_MULT_APB1 1
#define TIMER_MULT_APB2 1
#elif defined(STM32F4)
#define CPU_FREQ 168000000
#define PERI1_FREQUENCY 42000000
#define PERI2_FREQUENCY 84000000
#define TIMER_MULT_APB1 2
#define TIMER_MULT_APB2 2
#else
#define CPU_FREQ 120000000
#define PERI1_FREQUENCY 30000000
#define PERI2_FREQUENCY 60000000
#define TIMER_MULT_APB1 2
#define TIMER_MULT_APB2 2
#endif
#define TELEMETRY_EXTI_PRIO 0 // required for soft serial
// Keys
#if defined(PCBX9E)
#define KEYS_GPIO_REG_MENU GPIOD
#define KEYS_GPIO_PIN_MENU LL_GPIO_PIN_7 // PD.07
#define KEYS_GPIO_REG_EXIT GPIOD
#define KEYS_GPIO_PIN_EXIT LL_GPIO_PIN_2 // PD.02
#define KEYS_GPIO_REG_PAGEDN GPIOD
#define KEYS_GPIO_PIN_PAGEDN LL_GPIO_PIN_3 // PD.03
#define KEYS_GPIO_REG_ENTER GPIOF
#define KEYS_GPIO_PIN_ENTER LL_GPIO_PIN_0 // PF.00
#elif defined(PCBXLITE)
#define KEYS_GPIO_REG_SHIFT GPIOE
#define KEYS_GPIO_PIN_SHIFT LL_GPIO_PIN_8 // PE.08
#define KEYS_GPIO_REG_EXIT GPIOE
#define KEYS_GPIO_PIN_EXIT LL_GPIO_PIN_7 // PE.07
#define KEYS_GPIO_REG_ENTER GPIOE
#define KEYS_GPIO_PIN_ENTER LL_GPIO_PIN_11 // PE.11
#define KEYS_GPIO_REG_UP GPIOE
#define KEYS_GPIO_PIN_UP LL_GPIO_PIN_10 // PE.10
#define KEYS_GPIO_REG_DOWN GPIOE
#define KEYS_GPIO_PIN_DOWN LL_GPIO_PIN_14 // PE.14
#define KEYS_GPIO_REG_LEFT GPIOE
#define KEYS_GPIO_PIN_LEFT LL_GPIO_PIN_12 // PE.12
#define KEYS_GPIO_REG_RIGHT GPIOE
#define KEYS_GPIO_PIN_RIGHT LL_GPIO_PIN_13 // PE.13
#elif defined(RADIO_TPROS)
#define KEYS_GPIO_REG_PAGEDN GPIOD
#define KEYS_GPIO_PIN_PAGEDN LL_GPIO_PIN_3 // PD.03
#define KEYS_GPIO_REG_MENU GPIOD
#define KEYS_GPIO_PIN_MENU LL_GPIO_PIN_7 // PD.07
#define KEYS_GPIO_REG_EXIT GPIOD
#define KEYS_GPIO_PIN_EXIT LL_GPIO_PIN_2 // PD.02
#define KEYS_GPIO_REG_ENTER GPIOA
#define KEYS_GPIO_PIN_ENTER LL_GPIO_PIN_13 // PA.13
#elif defined(RADIO_FAMILY_JUMPER_T12) && !defined(RADIO_TPRO) && !defined(RADIO_TPROV2)
#define KEYS_GPIO_REG_EXIT GPIOD
#define KEYS_GPIO_PIN_EXIT LL_GPIO_PIN_2 // PD.02
#define KEYS_GPIO_REG_ENTER GPIOE
#define KEYS_GPIO_PIN_ENTER LL_GPIO_PIN_10 // PE.10
#define KEYS_GPIO_REG_UP GPIOE
#define KEYS_GPIO_PIN_UP LL_GPIO_PIN_9 // PE.09
#define KEYS_GPIO_REG_DOWN GPIOE
#define KEYS_GPIO_PIN_DOWN LL_GPIO_PIN_11 // PE.11
#define KEYS_GPIO_REG_LEFT GPIOD
#define KEYS_GPIO_PIN_LEFT LL_GPIO_PIN_7 // PD.07
#define KEYS_GPIO_REG_RIGHT GPIOD
#define KEYS_GPIO_PIN_RIGHT LL_GPIO_PIN_3 // PD.03
#elif defined(RADIO_TX12) || defined(RADIO_TX12MK2) || defined(RADIO_BOXER) || defined(RADIO_ZORRO) || defined(RADIO_MT12) || defined(RADIO_POCKET)
#if defined(RADIO_MT12)
#define KEYS_GPIO_REG_PAGEUP GPIOD
#define KEYS_GPIO_PIN_PAGEUP LL_GPIO_PIN_7 // PD.07
#define KEYS_GPIO_REG_PAGEDN GPIOD
#define KEYS_GPIO_PIN_PAGEDN LL_GPIO_PIN_3 // PD.03
#else
#define KEYS_GPIO_REG_PAGEUP GPIOD
#define KEYS_GPIO_PIN_PAGEUP LL_GPIO_PIN_3 // PD.03
#define KEYS_GPIO_REG_PAGEDN GPIOD
#define KEYS_GPIO_PIN_PAGEDN LL_GPIO_PIN_7 // PD.07
#endif
#if defined(RADIO_TX12)
#define KEYS_GPIO_REG_EXIT GPIOB
#define KEYS_GPIO_PIN_EXIT LL_GPIO_PIN_3 // PB.03
#else
#define KEYS_GPIO_REG_EXIT GPIOC
#define KEYS_GPIO_PIN_EXIT LL_GPIO_PIN_5 // PC.05
#endif
#if defined(RADIO_TX12MK2) || defined(RADIO_BOXER) || defined(RADIO_MT12)
#define KEYS_GPIO_REG_ENTER GPIOA
#define KEYS_GPIO_PIN_ENTER LL_GPIO_PIN_10 // PA.10
#else
#define KEYS_GPIO_REG_ENTER GPIOA
#define KEYS_GPIO_PIN_ENTER LL_GPIO_PIN_13 // PA.13
#endif
#define KEYS_GPIO_REG_SYS GPIOB
#define KEYS_GPIO_PIN_SYS LL_GPIO_PIN_4 // PB.04
#define KEYS_GPIO_REG_MDL GPIOE
#define KEYS_GPIO_PIN_MDL LL_GPIO_PIN_11 // PE.11
#define KEYS_GPIO_REG_TELE GPIOD
#define KEYS_GPIO_PIN_TELE LL_GPIO_PIN_2 // PD.02
#elif defined(RADIO_T8)
#define KEYS_GPIO_REG_PAGEUP GPIOD
#define KEYS_GPIO_PIN_PAGEUP LL_GPIO_PIN_3 // PD.03
#define KEYS_GPIO_REG_PAGEDN GPIOD
#define KEYS_GPIO_PIN_PAGEDN LL_GPIO_PIN_7 // PD.07
#define KEYS_GPIO_REG_EXIT GPIOB
#define KEYS_GPIO_PIN_EXIT LL_GPIO_PIN_3 // PB.03
#define KEYS_GPIO_REG_ENTER GPIOA
#define KEYS_GPIO_PIN_ENTER LL_GPIO_PIN_13 // PA.13
#define KEYS_GPIO_REG_SYS GPIOB
#define KEYS_GPIO_PIN_SYS LL_GPIO_PIN_4 // PB.04
#define KEYS_GPIO_REG_MDL GPIOE
#define KEYS_GPIO_PIN_MDL LL_GPIO_PIN_11 // PE.11
#define KEYS_GPIO_REG_PLUS GPIOE
#define KEYS_GPIO_PIN_PLUS LL_GPIO_PIN_9 // PE.09
#define KEYS_GPIO_REG_MINUS GPIOE
#define KEYS_GPIO_PIN_MINUS LL_GPIO_PIN_10 // PE.10
#define KEYS_GPIO_REG_BIND GPIOA
#define KEYS_GPIO_PIN_BIND LL_GPIO_PIN_10 // PA.10
#elif defined(RADIO_COMMANDO8)
#define KEYS_GPIO_REG_PAGEUP GPIOE
#define KEYS_GPIO_PIN_PAGEUP LL_GPIO_PIN_11 // PE.11
#define KEYS_GPIO_REG_PAGEDN GPIOE
#define KEYS_GPIO_PIN_PAGEDN LL_GPIO_PIN_13 // PE.13
#define KEYS_GPIO_REG_EXIT GPIOD
#define KEYS_GPIO_PIN_EXIT LL_GPIO_PIN_2 // PD.02
#define KEYS_GPIO_REG_ENTER GPIOE
#define KEYS_GPIO_PIN_ENTER LL_GPIO_PIN_10 // PE.10
#define KEYS_GPIO_REG_SYS GPIOD
#define KEYS_GPIO_PIN_SYS LL_GPIO_PIN_1 // PD.01
#define KEYS_GPIO_REG_MDL GPIOD
#define KEYS_GPIO_PIN_MDL LL_GPIO_PIN_0 // PD.00
#define KEYS_GPIO_REG_PLUS GPIOE
#define KEYS_GPIO_PIN_PLUS LL_GPIO_PIN_12 // PE.12
#define KEYS_GPIO_REG_MINUS GPIOE
#define KEYS_GPIO_PIN_MINUS LL_GPIO_PIN_14 // PE.14
#define KEYS_GPIO_REG_BIND GPIOD
#define KEYS_GPIO_PIN_BIND LL_GPIO_PIN_9 // PD.09
#elif defined(RADIO_FAMILY_T20)
#define KEYS_GPIO_REG_PAGEDN GPIOD
#define KEYS_GPIO_PIN_PAGEDN LL_GPIO_PIN_11 // PD.11
#define KEYS_GPIO_REG_MENU GPIOD
#define KEYS_GPIO_PIN_MENU LL_GPIO_PIN_10 // PD.10
#define KEYS_GPIO_REG_EXIT GPIOD
#define KEYS_GPIO_PIN_EXIT LL_GPIO_PIN_12 // PD.12
#define KEYS_GPIO_REG_ENTER GPIOE
#define KEYS_GPIO_PIN_ENTER LL_GPIO_PIN_7 // PE.7
#elif defined(RADIO_T14) || defined(RADIO_T12MAX)
#define KEYS_GPIO_REG_PAGEDN GPIOD
#define KEYS_GPIO_PIN_PAGEDN LL_GPIO_PIN_3 // PD.03
#define KEYS_GPIO_REG_MENU GPIOD
#define KEYS_GPIO_PIN_MENU LL_GPIO_PIN_7 // PD.07
#define KEYS_GPIO_REG_EXIT GPIOD
#define KEYS_GPIO_PIN_EXIT LL_GPIO_PIN_2 // PD.02
#define KEYS_GPIO_REG_ENTER GPIOA
#define KEYS_GPIO_PIN_ENTER LL_GPIO_PIN_13 // PA.13
#elif defined(RADIO_V14) || defined(RADIO_V12)
#define KEYS_GPIO_REG_PAGEUP GPIOD
#define KEYS_GPIO_PIN_PAGEUP LL_GPIO_PIN_3 // PD.03
#define KEYS_GPIO_REG_PAGEDN GPIOD
#define KEYS_GPIO_PIN_PAGEDN LL_GPIO_PIN_7 // PD.07
#define KEYS_GPIO_REG_EXIT GPIOE
#define KEYS_GPIO_PIN_EXIT LL_GPIO_PIN_1 // PE.01
#define KEYS_GPIO_REG_ENTER GPIOD
#define KEYS_GPIO_PIN_ENTER LL_GPIO_PIN_11 // PD.11
#define KEYS_GPIO_REG_SYS GPIOB
#define KEYS_GPIO_PIN_SYS LL_GPIO_PIN_4 // PB.04
#define KEYS_GPIO_REG_MDL GPIOE
#define KEYS_GPIO_PIN_MDL LL_GPIO_PIN_11 // PE.11
#define KEYS_GPIO_REG_TELE GPIOD
#define KEYS_GPIO_PIN_TELE LL_GPIO_PIN_2 // PD.02
#elif defined(PCBX7)
#define KEYS_GPIO_REG_PAGEDN GPIOD
#define KEYS_GPIO_PIN_PAGEDN LL_GPIO_PIN_3 // PD.03
#define KEYS_GPIO_REG_MENU GPIOD
#define KEYS_GPIO_PIN_MENU LL_GPIO_PIN_7 // PD.07
#define KEYS_GPIO_REG_EXIT GPIOD
#define KEYS_GPIO_PIN_EXIT LL_GPIO_PIN_2 // PD.02
#define KEYS_GPIO_REG_ENTER GPIOE
#define KEYS_GPIO_PIN_ENTER LL_GPIO_PIN_10 // PE.10
#elif defined(PCBX9LITE)
#define KEYS_GPIO_REG_PAGEDN GPIOE
#define KEYS_GPIO_PIN_PAGEDN LL_GPIO_PIN_8 // PE.08
#define KEYS_GPIO_REG_MENU GPIOE
#define KEYS_GPIO_PIN_MENU LL_GPIO_PIN_7 // PE.07
#define KEYS_GPIO_REG_EXIT GPIOE
#define KEYS_GPIO_PIN_EXIT LL_GPIO_PIN_9 // PE.09
#define KEYS_GPIO_REG_ENTER GPIOE
#define KEYS_GPIO_PIN_ENTER LL_GPIO_PIN_11 // PE.11
#elif defined(RADIO_X9DP2019)
#define KEYS_GPIO_REG_MENU GPIOD
#define KEYS_GPIO_PIN_MENU LL_GPIO_PIN_2 // PD.02
#define KEYS_GPIO_REG_EXIT GPIOD
#define KEYS_GPIO_PIN_EXIT LL_GPIO_PIN_7 // PD.07
#define KEYS_GPIO_REG_PAGEDN GPIOD
#define KEYS_GPIO_PIN_PAGEDN LL_GPIO_PIN_3 // PD.03
#define KEYS_GPIO_REG_ENTER GPIOE
#define KEYS_GPIO_PIN_ENTER LL_GPIO_PIN_12 // PE.12
#else
#define KEYS_GPIO_REG_MENU GPIOD
#define KEYS_GPIO_PIN_MENU LL_GPIO_PIN_7 // PD.07
#define KEYS_GPIO_REG_EXIT GPIOD
#define KEYS_GPIO_PIN_EXIT LL_GPIO_PIN_2 // PD.02
#define KEYS_GPIO_REG_PAGEDN GPIOD
#define KEYS_GPIO_PIN_PAGEDN LL_GPIO_PIN_3 // PD.03
#define KEYS_GPIO_REG_PLUS GPIOE
#define KEYS_GPIO_PIN_PLUS LL_GPIO_PIN_10 // PE.10
#define KEYS_GPIO_REG_MINUS GPIOE
#define KEYS_GPIO_PIN_MINUS LL_GPIO_PIN_11 // PE.11
#define KEYS_GPIO_REG_ENTER GPIOE
#define KEYS_GPIO_PIN_ENTER LL_GPIO_PIN_12 // PE.12
#endif
// Rotary Encoder
#if defined(PCBX9E)
#define ROTARY_ENCODER_NAVIGATION
#define ROTARY_ENCODER_GPIO GPIOD
#define ROTARY_ENCODER_GPIO_PIN_A LL_GPIO_PIN_12 // PD.12
#define ROTARY_ENCODER_GPIO_PIN_B LL_GPIO_PIN_13 // PD.13
#define ROTARY_ENCODER_POSITION() (ROTARY_ENCODER_GPIO->IDR >> 12) & 0x03
#define ROTARY_ENCODER_EXTI_LINE1 LL_EXTI_LINE_12
#define ROTARY_ENCODER_EXTI_LINE2 LL_EXTI_LINE_13
#define ROTARY_ENCODER_EXTI_PORT LL_SYSCFG_EXTI_PORTD
#define ROTARY_ENCODER_EXTI_SYS_LINE1 LL_SYSCFG_EXTI_LINE12
#define ROTARY_ENCODER_EXTI_SYS_LINE2 LL_SYSCFG_EXTI_LINE13
// ROTARY_ENCODER_EXTI IRQ
#if !defined(USE_EXTI15_10_IRQ)
#define USE_EXTI15_10_IRQ
#define EXTI15_10_IRQ_Priority 5
#endif
#elif defined(RADIO_X9DP2019)
#define ROTARY_ENCODER_NAVIGATION
#define ROTARY_ENCODER_GPIO GPIOE
#define ROTARY_ENCODER_GPIO_PIN_A LL_GPIO_PIN_10 // PE.10
#define ROTARY_ENCODER_GPIO_PIN_B LL_GPIO_PIN_11 // PE.11
#define ROTARY_ENCODER_POSITION() (((ROTARY_ENCODER_GPIO->IDR >> 9) & 0x02) + ((ROTARY_ENCODER_GPIO->IDR >> 11) & 0x01))
#define ROTARY_ENCODER_EXTI_LINE1 LL_EXTI_LINE_10
#define ROTARY_ENCODER_EXTI_LINE2 LL_EXTI_LINE_11
#define ROTARY_ENCODER_EXTI_PORT LL_SYSCFG_EXTI_PORTE
#define ROTARY_ENCODER_EXTI_SYS_LINE1 LL_SYSCFG_EXTI_LINE10
#define ROTARY_ENCODER_EXTI_SYS_LINE2 LL_SYSCFG_EXTI_LINE11
// ROTARY_ENCODER_EXTI IRQ
#if !defined(USE_EXTI15_10_IRQ)
#define USE_EXTI15_10_IRQ
#define EXTI15_10_IRQ_Priority 5
#endif
#elif defined(RADIO_X7) || defined(RADIO_X7ACCESS) || defined(RADIO_TPRO) || defined(RADIO_TPROV2) || defined(RADIO_FAMILY_T20)
#define ROTARY_ENCODER_NAVIGATION
#define ROTARY_ENCODER_GPIO GPIOE
#define ROTARY_ENCODER_GPIO_PIN_A LL_GPIO_PIN_9 // PE.09
#define ROTARY_ENCODER_GPIO_PIN_B LL_GPIO_PIN_11 // PE.11
#define ROTARY_ENCODER_POSITION() (((ROTARY_ENCODER_GPIO->IDR >> 10) & 0x02) + ((ROTARY_ENCODER_GPIO->IDR >> 9) & 0x01))
#define ROTARY_ENCODER_EXTI_LINE1 LL_EXTI_LINE_9
#define ROTARY_ENCODER_EXTI_LINE2 LL_EXTI_LINE_11
// ROTARY_ENCODER_EXTI_LINE1 IRQ
#if !defined(USE_EXTI9_5_IRQ)
#define USE_EXTI9_5_IRQ
#define EXTI9_5_IRQ_Priority 5
#endif
// ROTARY_ENCODER_EXTI_LINE2 IRQ
#if !defined(USE_EXTI15_10_IRQ)
#define USE_EXTI15_10_IRQ
#define EXTI15_10_IRQ_Priority 5
#endif
#define ROTARY_ENCODER_EXTI_PORT LL_SYSCFG_EXTI_PORTE
#define ROTARY_ENCODER_EXTI_SYS_LINE1 LL_SYSCFG_EXTI_LINE9
#define ROTARY_ENCODER_EXTI_SYS_LINE2 LL_SYSCFG_EXTI_LINE11
#elif defined(PCBX9LITE)
#define ROTARY_ENCODER_NAVIGATION
#define ROTARY_ENCODER_GPIO GPIOE
#define ROTARY_ENCODER_GPIO_PIN_A LL_GPIO_PIN_10 // PE.10
#define ROTARY_ENCODER_GPIO_PIN_B LL_GPIO_PIN_12 // PE.12
#define ROTARY_ENCODER_POSITION() (((ROTARY_ENCODER_GPIO->IDR >> 12) & 0x01) + ((ROTARY_ENCODER_GPIO->IDR >> 9) & 0x02))
#define ROTARY_ENCODER_EXTI_LINE1 LL_EXTI_LINE_10
#define ROTARY_ENCODER_EXTI_LINE2 LL_EXTI_LINE_12
#define ROTARY_ENCODER_EXTI_PORT LL_SYSCFG_EXTI_PORTE
#define ROTARY_ENCODER_EXTI_SYS_LINE1 LL_SYSCFG_EXTI_LINE10
#define ROTARY_ENCODER_EXTI_SYS_LINE2 LL_SYSCFG_EXTI_LINE12
// ROTARY_ENCODER_EXTI IRQ
#if !defined(USE_EXTI15_10_IRQ)
#define USE_EXTI15_10_IRQ
#define EXTI15_10_IRQ_Priority 5
#endif
#elif defined(RADIO_TX12) || defined(RADIO_TX12MK2) || defined(RADIO_BOXER) || defined(RADIO_ZORRO) || defined(RADIO_MT12) || defined(RADIO_POCKET) || defined(RADIO_T14) || defined(RADIO_T12MAX) || defined(RADIO_TPROS) || defined(RADIO_V14) || defined(RADIO_V12)
#define ROTARY_ENCODER_NAVIGATION
#define ROTARY_ENCODER_GPIO GPIOE
#define ROTARY_ENCODER_GPIO_PIN_A LL_GPIO_PIN_9 // PE.9
#define ROTARY_ENCODER_GPIO_PIN_B LL_GPIO_PIN_10 // PE.10
#define ROTARY_ENCODER_POSITION() ((ROTARY_ENCODER_GPIO->IDR >> 9) & 0x03)
#define ROTARY_ENCODER_EXTI_LINE1 LL_EXTI_LINE_9
#define ROTARY_ENCODER_EXTI_LINE2 LL_EXTI_LINE_10
#define ROTARY_ENCODER_EXTI_PORT LL_SYSCFG_EXTI_PORTE
#define ROTARY_ENCODER_EXTI_SYS_LINE1 LL_SYSCFG_EXTI_LINE9
#define ROTARY_ENCODER_EXTI_SYS_LINE2 LL_SYSCFG_EXTI_LINE10
// ROTARY_ENCODER_EXTI_LINE1 IRQ
#if !defined(USE_EXTI9_5_IRQ)
#define USE_EXTI9_5_IRQ
#define EXTI9_5_IRQ_Priority 5
#endif
// ROTARY_ENCODER_EXTI_LINE2 IRQ
#if !defined(USE_EXTI15_10_IRQ)
#define USE_EXTI15_10_IRQ
#define EXTI15_10_IRQ_Priority 5
#endif
#if defined(RADIO_TX12MK2) || defined(RADIO_BOXER) || defined(RADIO_ZORRO) || defined(RADIO_MT12) || defined(RADIO_POCKET) || defined(RADIO_T14) || defined(RADIO_TPROS) || defined(RADIO_V14) || defined(RADIO_V12)
#define ROTARY_ENCODER_INVERTED
#endif
#endif
#if defined(ROTARY_ENCODER_NAVIGATION)
#define ROTARY_ENCODER_TIMER TIM5
#define ROTARY_ENCODER_TIMER_IRQn TIM5_IRQn
#define ROTARY_ENCODER_TIMER_IRQHandler TIM5_IRQHandler
#endif
// Trims
#if defined(PCBX9E)
#define TRIMS_GPIO_REG_LHL GPIOG
#define TRIMS_GPIO_PIN_LHL LL_GPIO_PIN_1 // PG.01
#define TRIMS_GPIO_REG_LHR GPIOG
#define TRIMS_GPIO_PIN_LHR LL_GPIO_PIN_0 // PG.00
#define TRIMS_GPIO_REG_LVD GPIOE
#define TRIMS_GPIO_PIN_LVD LL_GPIO_PIN_4 // PE.04
#define TRIMS_GPIO_REG_LVU GPIOE
#define TRIMS_GPIO_PIN_LVU LL_GPIO_PIN_3 // PE.03
#define TRIMS_GPIO_REG_RVD GPIOC
#define TRIMS_GPIO_PIN_RVD LL_GPIO_PIN_3 // PC.03
#define TRIMS_GPIO_REG_RHL GPIOC
#define TRIMS_GPIO_PIN_RHL LL_GPIO_PIN_1 // PC.01
#define TRIMS_GPIO_REG_RVU GPIOC
#define TRIMS_GPIO_PIN_RVU LL_GPIO_PIN_2 // PC.02
#define TRIMS_GPIO_REG_RHR GPIOC
#define TRIMS_GPIO_PIN_RHR LL_GPIO_PIN_13 // PC.13
#elif defined(PCBXLITE)
#define TRIMS_GPIO_REG_LHL GPIOC
#define TRIMS_GPIO_PIN_LHL LL_GPIO_PIN_4 // PC.04
#define TRIMS_GPIO_REG_LHR GPIOC
#define TRIMS_GPIO_PIN_LHR LL_GPIO_PIN_5 // PC.05
#define TRIMS_GPIO_REG_LVU GPIOB
#define TRIMS_GPIO_PIN_LVU LL_GPIO_PIN_0 // PB.00
#define TRIMS_GPIO_REG_LVD GPIOB
#define TRIMS_GPIO_PIN_LVD LL_GPIO_PIN_1 // PB.01
#define TRIMS_VIRTUAL_RV
#define TRIMS_VIRTUAL_RH
#elif defined(RADIO_X7ACCESS)
#define TRIMS_GPIO_REG_LHR GPIOD
#define TRIMS_GPIO_PIN_LHR LL_GPIO_PIN_15 // PD.15
#define TRIMS_GPIO_REG_LHL GPIOC
#define TRIMS_GPIO_PIN_LHL LL_GPIO_PIN_1 // PC.01
#define TRIMS_GPIO_REG_LVD GPIOE
#define TRIMS_GPIO_PIN_LVD LL_GPIO_PIN_6 // PE.06
#define TRIMS_GPIO_REG_LVU GPIOE
#define TRIMS_GPIO_PIN_LVU LL_GPIO_PIN_5 // PE.05
#define TRIMS_GPIO_REG_RVD GPIOC
#define TRIMS_GPIO_PIN_RVD LL_GPIO_PIN_3 // PC.03
#define TRIMS_GPIO_REG_RHR GPIOE
#define TRIMS_GPIO_PIN_RHR LL_GPIO_PIN_3 // PE.03
#define TRIMS_GPIO_REG_RVU GPIOC
#define TRIMS_GPIO_PIN_RVU LL_GPIO_PIN_2 // PC.02
#define TRIMS_GPIO_REG_RHL GPIOE
#define TRIMS_GPIO_PIN_RHL LL_GPIO_PIN_4 // PE.04
#elif defined(RADIO_FAMILY_T20)
#define TRIMS_GPIO_REG_LHL GPIOD
#define TRIMS_GPIO_PIN_LHL LL_GPIO_PIN_13 // PD.13
#define TRIMS_GPIO_REG_LHR GPIOG
#define TRIMS_GPIO_PIN_LHR LL_GPIO_PIN_2 // PG.02
#define TRIMS_GPIO_REG_LVD GPIOG
#define TRIMS_GPIO_PIN_LVD LL_GPIO_PIN_3 // PG.03
#define TRIMS_GPIO_REG_LVU GPIOD
#define TRIMS_GPIO_PIN_LVU LL_GPIO_PIN_14 // PD.14
#define TRIMS_GPIO_REG_RVD GPIOF
#define TRIMS_GPIO_PIN_RVD LL_GPIO_PIN_2 // PF.02
#define TRIMS_GPIO_REG_RVU GPIOE
#define TRIMS_GPIO_PIN_RVU LL_GPIO_PIN_6 // PE.06
#define TRIMS_GPIO_REG_RHL GPIOE
#define TRIMS_GPIO_PIN_RHL LL_GPIO_PIN_5 // PE.05
#define TRIMS_GPIO_REG_RHR GPIOF
#define TRIMS_GPIO_PIN_RHR LL_GPIO_PIN_1 // PF.01
#define TRIMS_GPIO_REG_LSD GPIOG
#define TRIMS_GPIO_PIN_LSD LL_GPIO_PIN_9 // PG.09
#define TRIMS_GPIO_REG_LSU GPIOG
#define TRIMS_GPIO_PIN_LSU LL_GPIO_PIN_10 // PG.10
#define TRIMS_GPIO_REG_RSD GPIOD
#define TRIMS_GPIO_PIN_RSD LL_GPIO_PIN_7 // PD.07
#define TRIMS_GPIO_REG_RSU GPIOG
#define TRIMS_GPIO_PIN_RSU LL_GPIO_PIN_12 // PG.12
#if defined(RADIO_T20V2)
#define TRIMS_GPIO_REG_T7L GPIOC
#define TRIMS_GPIO_PIN_T7L LL_GPIO_PIN_13 // PC.13
#else
#define TRIMS_GPIO_REG_T7L GPIOB
#define TRIMS_GPIO_PIN_T7L LL_GPIO_PIN_3 // PB.03
#endif
#define TRIMS_GPIO_REG_T7R GPIOG
#define TRIMS_GPIO_PIN_T7R LL_GPIO_PIN_15 // PG.15
#define TRIMS_GPIO_REG_T8D GPIOG
#define TRIMS_GPIO_PIN_T8D LL_GPIO_PIN_13 // PG.13
#define TRIMS_GPIO_REG_T8U GPIOB
#define TRIMS_GPIO_PIN_T8U LL_GPIO_PIN_4 // PB.04
#elif defined(RADIO_MT12)
#define TRIMS_GPIO_REG_T1R GPIOE
#define TRIMS_GPIO_PIN_T1R LL_GPIO_PIN_3 // PE.03
#define TRIMS_GPIO_REG_T1L GPIOE
#define TRIMS_GPIO_PIN_T1L LL_GPIO_PIN_4 // PE.04
#define TRIMS_GPIO_REG_T2R GPIOC
#define TRIMS_GPIO_PIN_T2R LL_GPIO_PIN_1 // PC.01
#define TRIMS_GPIO_REG_T2L GPIOC
#define TRIMS_GPIO_PIN_T2L LL_GPIO_PIN_2 // PC.02
#define TRIMS_GPIO_REG_T3R GPIOE
#define TRIMS_GPIO_PIN_T3R LL_GPIO_PIN_5 // PE.05
#define TRIMS_GPIO_REG_T3L GPIOE
#define TRIMS_GPIO_PIN_T3L LL_GPIO_PIN_6 // PE.06
#define TRIMS_GPIO_REG_T4R GPIOE
#define TRIMS_GPIO_PIN_T4R LL_GPIO_PIN_7 // PE.07
#define TRIMS_GPIO_REG_T4L GPIOE
#define TRIMS_GPIO_PIN_T4L LL_GPIO_PIN_8 // PE.08
#define TRIMS_GPIO_REG_T5R GPIOE
#define TRIMS_GPIO_PIN_T5R LL_GPIO_PIN_15 // PE.15
#define TRIMS_GPIO_REG_T5L GPIOE
#define TRIMS_GPIO_PIN_T5L LL_GPIO_PIN_14 // PE.14
#elif defined(RADIO_TPROS)
#define TRIMS_GPIO_REG_LHL GPIOC
#define TRIMS_GPIO_PIN_LHL LL_GPIO_PIN_3 // PC.03
#define TRIMS_GPIO_REG_LHR GPIOC
#define TRIMS_GPIO_PIN_LHR LL_GPIO_PIN_2 // PC.02
#define TRIMS_GPIO_REG_LVD GPIOE
#define TRIMS_GPIO_PIN_LVD LL_GPIO_PIN_4 // PE.04
#define TRIMS_GPIO_REG_LVU GPIOE
#define TRIMS_GPIO_PIN_LVU LL_GPIO_PIN_3 // PE.03
#define TRIMS_GPIO_REG_RVD GPIOC
#define TRIMS_GPIO_PIN_RVD LL_GPIO_PIN_1 // PC.01
#define TRIMS_GPIO_REG_RHL GPIOE
#define TRIMS_GPIO_PIN_RHL LL_GPIO_PIN_6 // PE.06
#define TRIMS_GPIO_REG_RVU GPIOD
#define TRIMS_GPIO_PIN_RVU LL_GPIO_PIN_15 // PD.15
#define TRIMS_GPIO_REG_RHR GPIOE
#define TRIMS_GPIO_PIN_RHR LL_GPIO_PIN_5 // PE.05
#elif defined(RADIO_T14) || defined(RADIO_T12MAX)
#define TRIMS_GPIO_REG_LHL GPIOE
#define TRIMS_GPIO_PIN_LHL LL_GPIO_PIN_3 // PE.03
#define TRIMS_GPIO_REG_LHR GPIOE
#define TRIMS_GPIO_PIN_LHR LL_GPIO_PIN_4 // PE.04
#define TRIMS_GPIO_REG_LVD GPIOC
#define TRIMS_GPIO_PIN_LVD LL_GPIO_PIN_3 // PC.03
#define TRIMS_GPIO_REG_LVU GPIOC
#define TRIMS_GPIO_PIN_LVU LL_GPIO_PIN_2 // PC.02
#define TRIMS_GPIO_REG_RVD GPIOE
#define TRIMS_GPIO_PIN_RVD LL_GPIO_PIN_6 // PE.06
#define TRIMS_GPIO_REG_RHL GPIOD
#define TRIMS_GPIO_PIN_RHL LL_GPIO_PIN_15 // PD.15
#define TRIMS_GPIO_REG_RVU GPIOE
#define TRIMS_GPIO_PIN_RVU LL_GPIO_PIN_5 // PE.05
#define TRIMS_GPIO_REG_RHR GPIOC
#define TRIMS_GPIO_PIN_RHR LL_GPIO_PIN_1 // PC.01
#elif defined(RADIO_V14) || defined(RADIO_V12)
#define TRIMS_GPIO_REG_LHL GPIOD
#define TRIMS_GPIO_PIN_LHL LL_GPIO_PIN_15 // PD.15
#define TRIMS_GPIO_REG_LHR GPIOC
#define TRIMS_GPIO_PIN_LHR LL_GPIO_PIN_1 // PC.01
#define TRIMS_GPIO_REG_LVD GPIOE
#define TRIMS_GPIO_PIN_LVD LL_GPIO_PIN_6 // PE.06
#define TRIMS_GPIO_REG_LVU GPIOE
#define TRIMS_GPIO_PIN_LVU LL_GPIO_PIN_5 // PE.05
#define TRIMS_GPIO_REG_RVD GPIOC
#define TRIMS_GPIO_PIN_RVD LL_GPIO_PIN_3 // PC.03
#define TRIMS_GPIO_REG_RHL GPIOE
#define TRIMS_GPIO_PIN_RHL LL_GPIO_PIN_3 // PE.03
#define TRIMS_GPIO_REG_RVU GPIOD
#define TRIMS_GPIO_PIN_RVU LL_GPIO_PIN_0 // PD.00
#define TRIMS_GPIO_REG_RHR GPIOE
#define TRIMS_GPIO_PIN_RHR LL_GPIO_PIN_4 // PE.04
#elif defined(PCBX7) && !defined(RADIO_COMMANDO8)
#define TRIMS_GPIO_REG_LHL GPIOD
#define TRIMS_GPIO_PIN_LHL LL_GPIO_PIN_15 // PD.15
#define TRIMS_GPIO_REG_LHR GPIOC
#define TRIMS_GPIO_PIN_LHR LL_GPIO_PIN_1 // PC.01
#define TRIMS_GPIO_REG_LVD GPIOE
#define TRIMS_GPIO_PIN_LVD LL_GPIO_PIN_6 // PE.06
#define TRIMS_GPIO_REG_LVU GPIOE
#define TRIMS_GPIO_PIN_LVU LL_GPIO_PIN_5 // PE.05
#define TRIMS_GPIO_REG_RVD GPIOC
#define TRIMS_GPIO_PIN_RVD LL_GPIO_PIN_3 // PC.03
#define TRIMS_GPIO_REG_RHL GPIOE
#define TRIMS_GPIO_PIN_RHL LL_GPIO_PIN_3 // PE.03
#define TRIMS_GPIO_REG_RVU GPIOC
#define TRIMS_GPIO_PIN_RVU LL_GPIO_PIN_2 // PC.02
#define TRIMS_GPIO_REG_RHR GPIOE
#define TRIMS_GPIO_PIN_RHR LL_GPIO_PIN_4 // PE.04
#elif defined(RADIO_COMMANDO8)
#define TRIMS_GPIO_REG_LHL GPIOD
#define TRIMS_GPIO_PIN_LHL LL_GPIO_PIN_15 // PD.15
#define TRIMS_GPIO_REG_LHR GPIOC
#define TRIMS_GPIO_PIN_LHR LL_GPIO_PIN_6 // PC.06
#define TRIMS_GPIO_REG_LVD GPIOE
#define TRIMS_GPIO_PIN_LVD LL_GPIO_PIN_6 // PE.06
#define TRIMS_GPIO_REG_LVU GPIOE
#define TRIMS_GPIO_PIN_LVU LL_GPIO_PIN_1 // PE.01
#define TRIMS_GPIO_REG_RVD GPIOC
#define TRIMS_GPIO_PIN_RVD LL_GPIO_PIN_3 // PC.03
#define TRIMS_GPIO_REG_RHL GPIOE
#define TRIMS_GPIO_PIN_RHL LL_GPIO_PIN_0 // PE.00
#define TRIMS_GPIO_REG_RVU GPIOC
#define TRIMS_GPIO_PIN_RVU LL_GPIO_PIN_7 // PC.07
#define TRIMS_GPIO_REG_RHR GPIOE
#define TRIMS_GPIO_PIN_RHR LL_GPIO_PIN_15 // PE.15
#elif defined(PCBX9LITE)
#define TRIMS_GPIO_REG_LHR GPIOC
#define TRIMS_GPIO_PIN_LHR LL_GPIO_PIN_4 // PC.04
#define TRIMS_GPIO_REG_LHL GPIOC
#define TRIMS_GPIO_PIN_LHL LL_GPIO_PIN_5 // PC.05
#define TRIMS_GPIO_REG_LVU GPIOB
#define TRIMS_GPIO_PIN_LVU LL_GPIO_PIN_0 // PB.00
#define TRIMS_GPIO_REG_LVD GPIOB
#define TRIMS_GPIO_PIN_LVD LL_GPIO_PIN_1 // PB.01
#define TRIMS_GPIO_REG_RVU GPIOE
#define TRIMS_GPIO_PIN_RVU LL_GPIO_PIN_13 // PE.13
#define TRIMS_GPIO_REG_RHR GPIOD
#define TRIMS_GPIO_PIN_RHR LL_GPIO_PIN_8 // PD.08
#define TRIMS_GPIO_REG_RVD GPIOE
#define TRIMS_GPIO_PIN_RVD LL_GPIO_PIN_14 // PE.14
#define TRIMS_GPIO_REG_RHL GPIOD
#define TRIMS_GPIO_PIN_RHL LL_GPIO_PIN_9 // PD.09
#elif defined(RADIO_X9DP2019)
#define TRIMS_GPIO_REG_LHL GPIOE
#define TRIMS_GPIO_PIN_LHL LL_GPIO_PIN_3 // PE.03
#define TRIMS_GPIO_REG_LHR GPIOE
#define TRIMS_GPIO_PIN_LHR LL_GPIO_PIN_4 // PE.04
#define TRIMS_GPIO_REG_LVD GPIOE
#define TRIMS_GPIO_PIN_LVD LL_GPIO_PIN_6 // PE.06
#define TRIMS_GPIO_REG_LVU GPIOE
#define TRIMS_GPIO_PIN_LVU LL_GPIO_PIN_5 // PE.05
#define TRIMS_GPIO_REG_RVD GPIOC
#define TRIMS_GPIO_PIN_RVD LL_GPIO_PIN_3 // PC.03
#define TRIMS_GPIO_REG_RVU GPIOC
#define TRIMS_GPIO_PIN_RVU LL_GPIO_PIN_2 // PC.02
#define TRIMS_GPIO_REG_RHL GPIOC
#define TRIMS_GPIO_PIN_RHL LL_GPIO_PIN_13 // PC.13
#define TRIMS_GPIO_REG_RHR GPIOC
#define TRIMS_GPIO_PIN_RHR LL_GPIO_PIN_1 // PC.01
#else
#define TRIMS_GPIO_REG_LHL GPIOE
#define TRIMS_GPIO_PIN_LHL LL_GPIO_PIN_4 // PE.04
#define TRIMS_GPIO_REG_LHR GPIOE
#define TRIMS_GPIO_PIN_LHR LL_GPIO_PIN_3 // PE.03
#define TRIMS_GPIO_REG_LVD GPIOE
#define TRIMS_GPIO_PIN_LVD LL_GPIO_PIN_6 // PE.06
#define TRIMS_GPIO_REG_LVU GPIOE
#define TRIMS_GPIO_PIN_LVU LL_GPIO_PIN_5 // PE.05
#define TRIMS_GPIO_REG_RVD GPIOC
#define TRIMS_GPIO_PIN_RVD LL_GPIO_PIN_3 // PC.03
#define TRIMS_GPIO_REG_RHL GPIOC
#define TRIMS_GPIO_PIN_RHL LL_GPIO_PIN_1 // PC.01
#define TRIMS_GPIO_REG_RVU GPIOC
#define TRIMS_GPIO_PIN_RVU LL_GPIO_PIN_2 // PC.02
#define TRIMS_GPIO_REG_RHR GPIOC
#define TRIMS_GPIO_PIN_RHR LL_GPIO_PIN_13 // PC.13
#endif
// Switches
#if defined(PCBX9E)
#define STORAGE_SWITCH_A
#define HARDWARE_SWITCH_A
#define HARDWARE_SWITCH_A
#define SWITCHES_GPIO_REG_A_H GPIOD
#define SWITCHES_GPIO_PIN_A_H LL_GPIO_PIN_10 // PD.10
#define SWITCHES_GPIO_REG_A_L GPIOD
#define SWITCHES_GPIO_PIN_A_L LL_GPIO_PIN_14 // PD.14
#elif defined(PCBXLITE) || defined(PCBX9LITE) || defined(RADIO_MT12)
#define STORAGE_SWITCH_A
#define HARDWARE_SWITCH_A
#define SWITCHES_GPIO_REG_A_H GPIOE
#define SWITCHES_GPIO_PIN_A_H LL_GPIO_PIN_1 // PE.01
#define SWITCHES_GPIO_REG_A_L GPIOE
#define SWITCHES_GPIO_PIN_A_L LL_GPIO_PIN_0 // PE.00
#elif defined(RADIO_TX12) || defined(RADIO_TX12MK2) || defined(RADIO_BOXER) || defined(RADIO_ZORRO) || defined(RADIO_POCKET)
#define STORAGE_SWITCH_A
#define HARDWARE_SWITCH_A
#define SWITCHES_GPIO_REG_A GPIOC
#define SWITCHES_GPIO_PIN_A LL_GPIO_PIN_13 // PC.13
#elif defined(RADIO_T14) || defined(RADIO_T12MAX)
#define STORAGE_SWITCH_A
#define HARDWARE_SWITCH_A
#define SWITCHES_GPIO_REG_A GPIOC
#define SWITCHES_GPIO_PIN_A LL_GPIO_PIN_5 // PC.05
#elif defined(RADIO_T8)
#define STORAGE_SWITCH_A
#define HARDWARE_SWITCH_A
#define SWITCHES_GPIO_REG_A GPIOE
#define SWITCHES_GPIO_PIN_A LL_GPIO_PIN_14 // PE.14
#elif defined(RADIO_COMMANDO8)
#define STORAGE_SWITCH_A
#define HARDWARE_SWITCH_A
#define SWITCHES_GPIO_REG_A GPIOE
#define SWITCHES_GPIO_PIN_A LL_GPIO_PIN_3 // PE.03
#elif defined(RADIO_TPRO) || defined(RADIO_TPROV2)
#define STORAGE_SWITCH_A
#define HARDWARE_SWITCH_A
#define SWITCHES_GPIO_REG_A_L GPIOE
#define SWITCHES_GPIO_PIN_A_L LL_GPIO_PIN_13 // PE.13
#define SWITCHES_GPIO_REG_A_H GPIOE
#define SWITCHES_GPIO_PIN_A_H LL_GPIO_PIN_7 // PE.07
#elif defined(RADIO_TPROS)
#define STORAGE_SWITCH_A
#define HARDWARE_SWITCH_A
#define SWITCHES_GPIO_REG_A_H GPIOE
#define SWITCHES_GPIO_PIN_A_H LL_GPIO_PIN_0 // PE.00
#define SWITCHES_GPIO_REG_A_L GPIOD
#define SWITCHES_GPIO_PIN_A_L LL_GPIO_PIN_11 // PD.11
#elif defined(RADIO_FAMILY_T20)
#define STORAGE_SWITCH_A
#define HARDWARE_SWITCH_A
#define SWITCHES_A_INVERTED
#define SWITCHES_GPIO_REG_A GPIOD
#define SWITCHES_GPIO_PIN_A LL_GPIO_PIN_0 // PD.00
#elif defined(RADIO_V14) || defined(RADIO_V12)
// ADC based switch
#elif defined(PCBX7)
#define STORAGE_SWITCH_A
#define HARDWARE_SWITCH_A
#define SWITCHES_GPIO_REG_A_L GPIOE
#define SWITCHES_GPIO_PIN_A_L LL_GPIO_PIN_7 // PE.07
#define SWITCHES_GPIO_REG_A_H GPIOE
#define SWITCHES_GPIO_PIN_A_H LL_GPIO_PIN_13 // PE.13
#else
#define STORAGE_SWITCH_A
#define HARDWARE_SWITCH_A
#define SWITCHES_GPIO_REG_A_H GPIOB
#define SWITCHES_GPIO_PIN_A_H LL_GPIO_PIN_5 // PB.05
#define SWITCHES_GPIO_REG_A_L GPIOE
#define SWITCHES_GPIO_PIN_A_L LL_GPIO_PIN_0 // PE.00
#endif
#if defined(PCBX9E)
#define STORAGE_SWITCH_B
#define HARDWARE_SWITCH_B
#define SWITCHES_GPIO_REG_B_H GPIOG
#define SWITCHES_GPIO_PIN_B_H LL_GPIO_PIN_11 // PG.11
#define SWITCHES_GPIO_REG_B_L GPIOG
#define SWITCHES_GPIO_PIN_B_L LL_GPIO_PIN_10 // PG.10
#elif defined(PCBXLITE)
#define STORAGE_SWITCH_B
#define HARDWARE_SWITCH_B
#define SWITCHES_GPIO_REG_B_L GPIOA
#define SWITCHES_GPIO_PIN_B_L LL_GPIO_PIN_6 // PA.06
#define SWITCHES_GPIO_REG_B_H GPIOA
#define SWITCHES_GPIO_PIN_B_H LL_GPIO_PIN_5 // PA.05
#elif defined(RADIO_T8)
#define STORAGE_SWITCH_B
#define HARDWARE_SWITCH_B
#define SWITCHES_GPIO_REG_B_L GPIOE
#define SWITCHES_GPIO_PIN_B_L LL_GPIO_PIN_7 // PE.07
#define SWITCHES_GPIO_REG_B_H GPIOE
#define SWITCHES_GPIO_PIN_B_H LL_GPIO_PIN_13 // PE.13
#elif defined(RADIO_COMMANDO8)
#define STORAGE_SWITCH_B
#define HARDWARE_SWITCH_B
#define SWITCHES_GPIO_REG_B_L GPIOE
#define SWITCHES_GPIO_PIN_B_L LL_GPIO_PIN_5 // PE.05
#define SWITCHES_GPIO_REG_B_H GPIOE
#define SWITCHES_GPIO_PIN_B_H LL_GPIO_PIN_4 // PE.04
#elif defined(RADIO_TLITE) || defined(RADIO_TPRO) || defined(RADIO_TPROV2)
#define STORAGE_SWITCH_B
#define HARDWARE_SWITCH_B
#define SWITCHES_GPIO_REG_B_L GPIOE
#define SWITCHES_GPIO_PIN_B_L LL_GPIO_PIN_1 // PE.01
#define SWITCHES_GPIO_REG_B_H GPIOE
#define SWITCHES_GPIO_PIN_B_H LL_GPIO_PIN_2 // PE.02
#elif defined(RADIO_TPROS)
#define STORAGE_SWITCH_B
#define HARDWARE_SWITCH_B
#define SWITCHES_GPIO_REG_B_L GPIOA
#define SWITCHES_GPIO_PIN_B_L LL_GPIO_PIN_5 // PA.05
#define SWITCHES_GPIO_REG_B_H GPIOE
#define SWITCHES_GPIO_PIN_B_H LL_GPIO_PIN_15 // PE.15
#elif defined(RADIO_FAMILY_T20)
#define STORAGE_SWITCH_B
#define HARDWARE_SWITCH_B
#define SWITCHES_B_INVERTED
#define SWITCHES_GPIO_REG_B GPIOE
#define SWITCHES_GPIO_PIN_B LL_GPIO_PIN_2 // PE.02
#elif (RADIO_LR3PRO)
#define STORAGE_SWITCH_B
#define HARDWARE_SWITCH_B
#define SWITCHES_GPIO_REG_B_L GPIOE
#define SWITCHES_GPIO_PIN_B_L LL_GPIO_PIN_15 // PE.15
#define SWITCHES_GPIO_REG_B_H GPIOA
#define SWITCHES_GPIO_PIN_B_H LL_GPIO_PIN_5 // PA.05
#elif defined(RADIO_BOXER)
#define STORAGE_SWITCH_B
#define HARDWARE_SWITCH_B
#define SWITCHES_GPIO_REG_B_L GPIOE
#define SWITCHES_GPIO_PIN_B_L LL_GPIO_PIN_15 // PE.15
#define SWITCHES_GPIO_REG_B_H GPIOE
#define SWITCHES_GPIO_PIN_B_H LL_GPIO_PIN_7 // PE.07
#elif defined(RADIO_T14) || defined(RADIO_T12MAX)
#define STORAGE_SWITCH_B
#define HARDWARE_SWITCH_B
#define SWITCHES_GPIO_REG_B GPIOE
#define SWITCHES_GPIO_PIN_B LL_GPIO_PIN_7 // PE.07
#elif defined(RADIO_MT12)
#define STORAGE_SWITCH_B
#define HARDWARE_SWITCH_B
#define SWITCHES_GPIO_REG_B GPIOD
#define SWITCHES_GPIO_PIN_B LL_GPIO_PIN_11 // PD.11
#elif defined(RADIO_V14) || defined(RADIO_V12)
// ADC based switch
#elif defined(PCBX7)
#define STORAGE_SWITCH_B
#define HARDWARE_SWITCH_B
#define SWITCHES_GPIO_REG_B_L GPIOE
#define SWITCHES_GPIO_PIN_B_L LL_GPIO_PIN_15 // PE.15
#define SWITCHES_GPIO_REG_B_H GPIOA
#define SWITCHES_GPIO_PIN_B_H LL_GPIO_PIN_5 // PA.05
#elif defined(PCBX9LITE)
#define STORAGE_SWITCH_B
#define HARDWARE_SWITCH_B
#define SWITCHES_GPIO_REG_B_L GPIOB
#define SWITCHES_GPIO_PIN_B_L LL_GPIO_PIN_4 // PB.04
#define SWITCHES_GPIO_REG_B_H GPIOB
#define SWITCHES_GPIO_PIN_B_H LL_GPIO_PIN_5 // PB.05
#else
#define STORAGE_SWITCH_B
#define HARDWARE_SWITCH_B
#define SWITCHES_GPIO_REG_B_H GPIOE
#define SWITCHES_GPIO_PIN_B_H LL_GPIO_PIN_1 // PE.01
#define SWITCHES_GPIO_REG_B_L GPIOE
#define SWITCHES_GPIO_PIN_B_L LL_GPIO_PIN_2 // PE.02
#endif
#if defined(PCBX9E)
#define STORAGE_SWITCH_C
#define HARDWARE_SWITCH_C
#define SWITCHES_GPIO_REG_C_H GPIOF
#define SWITCHES_GPIO_PIN_C_H LL_GPIO_PIN_13 // PF.13
#define SWITCHES_GPIO_REG_C_L GPIOF
#define SWITCHES_GPIO_PIN_C_L LL_GPIO_PIN_14 // PF.14
#elif defined(PCBXLITE) || defined(PCBX9LITE)
#define STORAGE_SWITCH_C
#define HARDWARE_SWITCH_C
#define SWITCHES_GPIO_REG_C_L GPIOE
#define SWITCHES_GPIO_PIN_C_L LL_GPIO_PIN_2 // PE.02
#define SWITCHES_GPIO_REG_C_H GPIOE
#define SWITCHES_GPIO_PIN_C_H LL_GPIO_PIN_3 // PE.03
#elif defined(RADIO_TX12MK2) || defined(RADIO_BOXER)
#define STORAGE_SWITCH_C
#define HARDWARE_SWITCH_C
#define SWITCHES_GPIO_REG_C_L GPIOE
#define SWITCHES_GPIO_PIN_C_L LL_GPIO_PIN_0 // PE.00
#define SWITCHES_GPIO_REG_C_H GPIOD
#define SWITCHES_GPIO_PIN_C_H LL_GPIO_PIN_11 // PD.11
#elif defined(RADIO_T14) || defined(RADIO_T12MAX)
#define STORAGE_SWITCH_C
#define HARDWARE_SWITCH_C
#define SWITCHES_GPIO_REG_C_H GPIOE
#define SWITCHES_GPIO_PIN_C_H LL_GPIO_PIN_0 // PE.00
#define SWITCHES_GPIO_REG_C_L GPIOD
#define SWITCHES_GPIO_PIN_C_L LL_GPIO_PIN_11 // PD.11
#elif defined(RADIO_TX12)
#define STORAGE_SWITCH_C
#define HARDWARE_SWITCH_C
#define SWITCHES_GPIO_REG_C_L GPIOD
#define SWITCHES_GPIO_PIN_C_L LL_GPIO_PIN_11 // PD.11
#define SWITCHES_GPIO_REG_C_H GPIOE
#define SWITCHES_GPIO_PIN_C_H LL_GPIO_PIN_0 // PE.00
#elif defined(RADIO_ZORRO) || defined(RADIO_POCKET)
#define STORAGE_SWITCH_C
#define HARDWARE_SWITCH_C
#define SWITCHES_GPIO_REG_C_L GPIOE
#define SWITCHES_GPIO_PIN_C_L LL_GPIO_PIN_0 // PE.00
#define SWITCHES_GPIO_REG_C_H GPIOD
#define SWITCHES_GPIO_PIN_C_H LL_GPIO_PIN_11 // PD.11
#elif defined(RADIO_T8)
#define STORAGE_SWITCH_C
#define HARDWARE_SWITCH_C
#define SWITCHES_GPIO_REG_C_L GPIOE
#define SWITCHES_GPIO_PIN_C_L LL_GPIO_PIN_2 // PE.02
#define SWITCHES_GPIO_REG_C_H GPIOE
#define SWITCHES_GPIO_PIN_C_H LL_GPIO_PIN_1 // PE.01
#elif defined(RADIO_COMMANDO8)
#define STORAGE_SWITCH_C
#define HARDWARE_SWITCH_C
#define SWITCHES_GPIO_REG_C_L GPIOC
#define SWITCHES_GPIO_PIN_C_L LL_GPIO_PIN_4 // PC.04
#define SWITCHES_GPIO_REG_C_H GPIOA
#define SWITCHES_GPIO_PIN_C_H LL_GPIO_PIN_6 // PA.06
#elif defined(RADIO_TLITE) || defined(RADIO_TPRO) || defined(RADIO_TPROV2) || defined(RADIO_LR3PRO)
#define STORAGE_SWITCH_C
#define HARDWARE_SWITCH_C
#define SWITCHES_GPIO_REG_C GPIOE
#define SWITCHES_GPIO_PIN_C LL_GPIO_PIN_14 // PE.14
#elif defined(RADIO_TPROS)
#define STORAGE_SWITCH_C
#define HARDWARE_SWITCH_C
#define SWITCHES_GPIO_REG_C GPIOE
#define SWITCHES_GPIO_PIN_C LL_GPIO_PIN_8 // PE.08
#elif defined(RADIO_FAMILY_T20)
#define STORAGE_SWITCH_C
#define HARDWARE_SWITCH_C
#define SWITCHES_GPIO_REG_C_L GPIOD
#define SWITCHES_GPIO_PIN_C_L LL_GPIO_PIN_2 // PD.02
#define SWITCHES_GPIO_REG_C_H GPIOD
#define SWITCHES_GPIO_PIN_C_H LL_GPIO_PIN_1 // PD.01
#elif defined(RADIO_MT12)
#define STORAGE_SWITCH_C
#define HARDWARE_SWITCH_C
#define SWITCHES_GPIO_REG_C GPIOC
#define SWITCHES_GPIO_PIN_C LL_GPIO_PIN_13 // PC.13
#elif defined(RADIO_V14) || defined(RADIO_V12)
// ADC based switch
#elif defined(PCBX7)
#define STORAGE_SWITCH_C
#define HARDWARE_SWITCH_C
#define SWITCHES_GPIO_REG_C_L GPIOD
#define SWITCHES_GPIO_PIN_C_L LL_GPIO_PIN_11 // PD.11
#if defined(PCBX7ACCESS)
#define SWITCHES_GPIO_REG_C_H GPIOD
#define SWITCHES_GPIO_PIN_C_H LL_GPIO_PIN_10 // PD.10
#else
#define SWITCHES_GPIO_REG_C_H GPIOE
#define SWITCHES_GPIO_PIN_C_H LL_GPIO_PIN_0 // PE.00
#endif
#else
#define STORAGE_SWITCH_C
#define HARDWARE_SWITCH_C
#define SWITCHES_GPIO_REG_C_H GPIOE
#define SWITCHES_GPIO_PIN_C_H LL_GPIO_PIN_15 // PE.15
#define SWITCHES_GPIO_REG_C_L GPIOA
#define SWITCHES_GPIO_PIN_C_L LL_GPIO_PIN_5 // PA.05
#endif
#if defined(PCBX9E)
#define STORAGE_SWITCH_D
#define HARDWARE_SWITCH_D
#define SWITCHES_GPIO_REG_D_H GPIOE
#define SWITCHES_GPIO_PIN_D_H LL_GPIO_PIN_1 // PE.01
#define SWITCHES_GPIO_REG_D_L GPIOE
#define SWITCHES_GPIO_PIN_D_L LL_GPIO_PIN_2 // PE.02
#elif defined(PCBX9DP)
#define STORAGE_SWITCH_D
#define HARDWARE_SWITCH_D
#define SWITCHES_GPIO_REG_D_H GPIOE
#define SWITCHES_GPIO_PIN_D_H LL_GPIO_PIN_7 // PE.07
#define SWITCHES_GPIO_REG_D_L GPIOE
#define SWITCHES_GPIO_PIN_D_L LL_GPIO_PIN_13 // PE.13
#elif defined(PCBXLITE)
#define STORAGE_SWITCH_D
#define HARDWARE_SWITCH_D
#define SWITCHES_GPIO_REG_D_L GPIOB
#define SWITCHES_GPIO_PIN_D_L LL_GPIO_PIN_4 // PB.04
#define SWITCHES_GPIO_REG_D_H GPIOB
#define SWITCHES_GPIO_PIN_D_H LL_GPIO_PIN_5 // PB.05
#elif defined(RADIO_T8)
#define STORAGE_SWITCH_D
#define HARDWARE_SWITCH_D
#define SWITCHES_GPIO_REG_D GPIOD
#define SWITCHES_GPIO_PIN_D LL_GPIO_PIN_14 // PD.14
#elif defined(RADIO_COMMANDO8)
#define STORAGE_SWITCH_D
#define HARDWARE_SWITCH_D
#define SWITCHES_GPIO_REG_D GPIOA
#define SWITCHES_GPIO_PIN_D LL_GPIO_PIN_5 // PA.05
#elif defined(RADIO_TX12) || defined(RADIO_TX12MK2) || defined(RADIO_BOXER) || defined(RADIO_ZORRO) || defined(RADIO_POCKET)
#define STORAGE_SWITCH_D
#define HARDWARE_SWITCH_D
#define SWITCHES_GPIO_REG_D GPIOE
#define SWITCHES_GPIO_PIN_D LL_GPIO_PIN_8 // PE.08
#elif defined(RADIO_TLITE) || defined(RADIO_TPRO) || defined(RADIO_TPROV2) || defined(RADIO_LR3PRO)
#define STORAGE_SWITCH_D
#define HARDWARE_SWITCH_D
#define SWITCHES_GPIO_REG_D GPIOD
#define SWITCHES_GPIO_PIN_D LL_GPIO_PIN_14 // PD.14
#elif defined(RADIO_TPROS)
#define STORAGE_SWITCH_D
#define HARDWARE_SWITCH_D
#define SWITCHES_GPIO_REG_D GPIOC
#define SWITCHES_GPIO_PIN_D LL_GPIO_PIN_13// PC.13
#elif defined(RADIO_T14) || defined(RADIO_T12MAX)
#define STORAGE_SWITCH_D
#define HARDWARE_SWITCH_D
#define SWITCHES_GPIO_REG_D_L GPIOA
#define SWITCHES_GPIO_PIN_D_L LL_GPIO_PIN_5 // PA.05
#define SWITCHES_GPIO_REG_D_H GPIOE
#define SWITCHES_GPIO_PIN_D_H LL_GPIO_PIN_15 // PE.15
#elif defined(RADIO_FAMILY_T20)
#define STORAGE_SWITCH_D
#define HARDWARE_SWITCH_D
#define SWITCHES_GPIO_REG_D_L GPIOE
#define SWITCHES_GPIO_PIN_D_L LL_GPIO_PIN_0 // PE.00
#define SWITCHES_GPIO_REG_D_H GPIOE
#define SWITCHES_GPIO_PIN_D_H LL_GPIO_PIN_1 // PE.01
#elif defined(RADIO_MT12)
#define STORAGE_SWITCH_D
#define HARDWARE_SWITCH_D
#define SWITCHES_GPIO_REG_D GPIOC
#define SWITCHES_GPIO_PIN_D LL_GPIO_PIN_3 // PC.03
#elif defined(RADIO_V14) || defined(RADIO_V12)
// ADC based switch
#elif defined(PCBX7) && !defined(RADIO_COMMANDO8)
#define STORAGE_SWITCH_D
#define HARDWARE_SWITCH_D
#define SWITCHES_GPIO_REG_D_L GPIOE
#define SWITCHES_GPIO_PIN_D_L LL_GPIO_PIN_1 // PE.01
#define SWITCHES_GPIO_REG_D_H GPIOE
#define SWITCHES_GPIO_PIN_D_H LL_GPIO_PIN_2 // PE.02
#elif defined(PCBX7) && defined(RADIO_COMMANDO8)
#define STORAGE_SWITCH_D
#define HARDWARE_SWITCH_D
#define SWITCHES_GPIO_REG_D_L GPIOE
#define SWITCHES_GPIO_PIN_D_L LL_GPIO_PIN_1 // PE.01
#define SWITCHES_GPIO_REG_D_H GPIOE
#define SWITCHES_GPIO_PIN_D_H LL_GPIO_PIN_2 // PE.02
#elif defined(PCBX9LITE)
#define STORAGE_SWITCH_D
#define HARDWARE_SWITCH_D
#define SWITCHES_GPIO_REG_D GPIOC
#define SWITCHES_GPIO_PIN_D LL_GPIO_PIN_13 // PC.13
#else
#define STORAGE_SWITCH_D
#define HARDWARE_SWITCH_D
#define SWITCHES_GPIO_REG_D_H GPIOE
#define SWITCHES_GPIO_PIN_D_H LL_GPIO_PIN_7 // PE.07
#define SWITCHES_GPIO_REG_D_L GPIOB
#define SWITCHES_GPIO_PIN_D_L LL_GPIO_PIN_1 // PB.01
#endif
#if defined(PCBX9E)
#define STORAGE_SWITCH_E
#define HARDWARE_SWITCH_E
#define SWITCHES_GPIO_REG_E_H GPIOE
#define SWITCHES_GPIO_PIN_E_H LL_GPIO_PIN_7 // PE.07
#define SWITCHES_GPIO_REG_E_L GPIOE
#define SWITCHES_GPIO_PIN_E_L LL_GPIO_PIN_13 // PE.13
#elif defined(PCBXLITES)
#define STORAGE_SWITCH_E
#define HARDWARE_SWITCH_E
#define SWITCHES_GPIO_REG_E GPIOE
#define SWITCHES_GPIO_PIN_E LL_GPIO_PIN_5 // PE.05
#elif defined(PCBXLITE)
// no SWE but we want to remain compatible with XLiteS
#define STORAGE_SWITCH_E
#elif defined(PCBX9LITE)
#define STORAGE_SWITCH_E
#define HARDWARE_SWITCH_E
#define SWITCHES_GPIO_REG_E GPIOA
#define SWITCHES_GPIO_PIN_E LL_GPIO_PIN_5 // PA.05
#elif defined(RADIO_ZORRO) || defined(RADIO_POCKET)
#define STORAGE_SWITCH_E
#define HARDWARE_SWITCH_E
#define SWITCHES_GPIO_REG_E GPIOE
#define SWITCHES_GPIO_PIN_E LL_GPIO_PIN_7 // PE.07
#elif defined(RADIO_BOXER)
#define STORAGE_SWITCH_E
#define HARDWARE_SWITCH_E
#define SWITCHES_GPIO_REG_E GPIOE
#define SWITCHES_GPIO_PIN_E LL_GPIO_PIN_14 // PE.14
#elif defined(RADIO_TX12)
#define STORAGE_SWITCH_E
#define HARDWARE_SWITCH_E
#define SWITCHES_GPIO_REG_E_H GPIOE
#define SWITCHES_GPIO_PIN_E_H LL_GPIO_PIN_13 // PE.13
#define SWITCHES_GPIO_REG_E_L GPIOE
#define SWITCHES_GPIO_PIN_E_L LL_GPIO_PIN_7 // PE.07
#elif defined(RADIO_TX12MK2)
#define STORAGE_SWITCH_E
#define HARDWARE_SWITCH_E
#define SWITCHES_GPIO_REG_E_H GPIOE
#define SWITCHES_GPIO_PIN_E_H LL_GPIO_PIN_14 // PE.14
#define SWITCHES_GPIO_REG_E_L GPIOE
#define SWITCHES_GPIO_PIN_E_L LL_GPIO_PIN_7 // PE.07
#elif defined(RADIO_TPROS)
#define STORAGE_SWITCH_E
#define HARDWARE_SWITCH_E
#define SWITCHES_GPIO_REG_E GPIOC
#define SWITCHES_GPIO_PIN_E LL_GPIO_PIN_5 // PC.05
#elif defined(RADIO_TPROV2)
#define STORAGE_SWITCH_E