-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSystemInitial.c
8285 lines (7828 loc) · 207 KB
/
SystemInitial.c
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
/*
#####################################################################################
# In the name of ALLAH #
# Project : STM32F407 Test Project #
# Date : 2013/11/18 #
# file : SystemInitial.c #
# #
#####################################################################################
*/
// *** <<< Use Configuration Wizard in Context Menu >>> ***
#include "stm32f4xx.h"
#include "types.h"
#include "SystemInitial.h"
/******************************************************************************************************/
/*------------------------------------ Power Control Registers ---------------------------------------*/
//<h> Embedded Flash Memory Interface
// <h> Flash Access Control Register (FLASH_ACR)
// <q0.10> Data cache enable (DCEN)
// <q0.9> Instruction cache enable (ICEN)
// <q0.8> Prefetch enable (PRFTEN)
// <o0.0..2> Latency (LATENCY)
// <0=> 0 wait state
// <1=> 1 wait state
// <2=> 2 wait states
// <3=> 3 wait states
// <4=> 4 wait states
// <5=> 5 wait states
// <6=> 6 wait states
// <7=> 7 wait states
// </h>
#define FLASH_ACR_VALUE 0x00000305
// <h> Flash Control Register (FLASH_CR)
// <q0.25> Error interrupt enable (ERRIE
// <q0.24> End of operation interrupt enable (EOPIE)
// <o0.8..9> Program size (PSIZE)
// <0=> Program x8
// <1=> Program x16
// <2=> Program x32
// <3=> Program x64
// </h>
#define FLASH_CR_VALUE 0x00000200
//</h>
//<h> Power Controler (PWR)
// <h> PWR power control register (PWR_CR)
// <o0.14> Regulator voltage scaling output selection (VOS)
// <0=> Scale 2 mode
// <1=> Scale 1 mode (default value at reset)
// <q0.9> Flash power-down in Stop mode (FPDS)
// <q0.8> Disable backup domain write protection (DBP)
// <i> 0: Access to RTC and RTC Backup registers and backup SRAM disabled
// <i> 1: Access to RTC and RTC Backup registers and backup SRAM enabled
// <o0.5..7> PVD level selection (PLS[2:0])
// <0=> 2.0 V
// <1=> 2.1 V
// <2=> 2.3 V
// <3=> 2.5 V
// <4=> 2.6 V
// <5=> 2.7 V
// <6=> 2.8 V
// <7=> 2.9 V
// <q0.4> Power voltage detector enable (PVDE)
// <q0.1> Power-down deepsleep (PDDS)
// <i> 0: Enter Stop mode when the CPU enters deepsleep. The regulator status depends on the LPDS bit.
// <i> 1: Enter Standby mode when the CPU enters deepsleep.
// <q0.0> Low-power deepsleep (LPDS)
// <i> 0: Voltage regulator on during Stop mode
// <i> 1: Voltage regulator in low-power mode during Stop mode
// </h>
#define PWR_CR_VALUE 0x00004100
// <h> PWR Power Control/Status Register (PWR_CSR)
// <q0.9> Backup regulator enable (BRE)
// <i> When set, the Backup regulator (used to maintain backup SRAM content in Standby and
// <i> VBAT modes) is enabled. If BRE is reset, the backup regulator is switched off. The backup
// <i> SRAM can still be used but its content will be lost in the Standby and VBAT modes. Once set,
// <i> the application must wait that the Backup Regulator Ready flag (BRR) is set to indicate that
// <i> the data written into the RAM will be maintained in the Standby and VBAT modes.
// <q0.8> Enable WKUP pin (EWUP)
// <i> 0: WKUP pin is used for general purpose I/O. An event on the WKUP pin does not wakeup the device from Standby mode.
// <i> 1: WKUP pin is used for wakeup from Standby mode and forced in input pull down configuration
// <i> (rising edge on WKUP pin wakes-up the system from Standby mode).
// </h>
//</h>
#define PWR_CSR_VALUE 0x00000000
/*------------------------------- Reset and Clock Control Registers --------------------------------*/
//<h> Reset and Clock Control (RCC)
// <h> Reset
//
// </h>
// <h> Clock
// <h> Clock Control Register (RCC_CR)
// <q0.28> PLLSAI Enable (PLLISAION)
// <i> Set and cleared by software to enable PLLSAI.
// <q0.26> PLLI2C Enable (PLLI2SON)
// <i> Set and cleared by software to enable PLLI2S.
// <q0.24> Main PLL (PLL) enable (PLLON)
// <i> Set and cleared by software to enable PLL.
// <q0.19> Clock security system enable (CSSON)
// <q0.18> HSE clock bypass (HSEBYP)
// <q0.16> HSE clock enable (HSEON)
// <o0.3..7> Internal high-speed clock trimming (HSITRIM[4:0]) <0-31>
// <q0.0> Internal high-speed clock enable (HSION)
// </h>
#define RCC_CR_VALUE 0x01010001
// <h> PLL Configuration Register (RCC_PLLCFGR)
// <o0.24..27> Main PLL Division for USB OTG FS, SDIO and RNG (PLLQ) <2-15>
// <i> These bits should be written only if PLL is disabled.
// <o0.22> Main PLL(PLL) and audio PLL(PLLI2S) source clock (PLLSRC)
// <0=> HSI Clock
// <1=> HSE Oscillator Clock
// <o0.16..17> Main PLL (PLL) Division for main system clock (PLLP)
// <0=> Division by 2
// <1=> Division by 4
// <2=> Division by 6
// <3=> Division by 8
// <o0.6..14> Main PLL (PLL) Multiplication for VCO (PLLN) <192-432>
// <i> The software has to set these bits correctly to ensure that
// <i> the VCO output frequency is between 192 and 432 MHz
// <o0.0..5> Division for the main PLL (PLL) and audio PLL (PLLI2S) input clock (PLLM) <2-63>
// <i> The software has to set these bits correctly to ensure that the VCO input frequency
// <i> ranges from 1 to 2 MHz. It is recommended to select a frequency of 2 MHz to limit
// <i> PLL jitter.
// </h>
#define RCC_PLLCFGR_VALUE 0x07404B08
// <h> RCC Clock Configuration Register (RCC_CFGR)
// <o0.30..31> Microcontroller Clock Output 2 (MCO2[1:0])
// <0=> System Clock (SYSCLK)
// <1=> PLLI2S Clock
// <2=> HSE Oscillator Clock
// <3=> PLL Clock
// <o0.27..29> MCO2 Prescaler (MCO2PRE)
// <0=> No Division
// <4=> Division by 2
// <5=> Division by 3
// <6=> Division by 4
// <7=> Division by 5
// <o0.24..26> MCO1 Prescaler (MCO1PRE)
// <0=> No Division
// <4=> Division by 2
// <5=> Division by 3
// <6=> Division by 4
// <7=> Division by 5
// <o0.23> I2S Clock Source (I2SSRC)
// <0=> PLLI2S Clock Clock
// <1=> I2S_CKIN Pin Clock
// <o0.21..22> Microcontroller clock output 1 (MCO1)
// <0=> HSI Clock
// <1=> LSE Scillator
// <2=> HSE Oscillator Clock
// <3=> PLL Clock
// <o0.16..20> HSE Division Factor for RTC Clock (RTCPRE) <0-31>
// <i> The software has to set these bits correctly to ensure that the clock supplied to the
// <i> RTC is 1 MHz. These bits must be configured if needed before selecting the RTC
// <i> clock source (0 , 1 = No Clock)
// <o0.13..15> APB high-speed prescaler (APB2) (PPRE2)
// <0=> AHB clock not divided
// <4=> AHB clock divided by 2
// <5=> AHB clock divided by 4
// <6=> AHB clock divided by 8
// <7=> AHB clock divided by 16
// <i> The software has to set these bits correctly not to exceed 84 MHz on this domain.
// <i> The clocks are divided with the new prescaler factor from 1 to 16 AHB cycles after
// <i> PPRE2 write.
// <o0.10..12> APB Low speed prescaler (APB1) (PPRE1)
// <0=> AHB clock not divided
// <4=> AHB clock divided by 2
// <5=> AHB clock divided by 4
// <6=> AHB clock divided by 8
// <7=> AHB clock divided by 16
// <i> The software has to set these bits correctly not to exceed 42 MHz on this domain.
// <i> The clocks are divided with the new prescaler factor from 1 to 16 AHB cycles after
// <i> PPRE1 write.
// <o0.4..7> AHB prescaler (HPRE)
// <0=> system clock not divided
// <8=> system clock divided by 2
// <9=> system clock divided by 4
// <10=> system clock divided by 8
// <11=> system clock divided by 16
// <12=> system clock divided by 64
// <13=> system clock divided by 128
// <14=> system clock divided by 256
// <15=> system clock divided by 512
// <i> The clocks are divided with the new prescaler factor from 1 to 16 AHB cycles after HPRE write.
// <i> The AHB clock frequency must be at least 25 MHz when the Ethernet is used.
// <o0.0..1> System clock switch (SW)
// <0=> HSI Oscillator
// <1=> HSE Oscillator
// <2=> PLL
// </h>
#define RCC_CFGR_VALUE 0x3D609402
// <h> RCC Clock Interrupt Register (RCC_CIR)
// <q0.13> PLLI2S ready interrupt enable (CPLLI2SRDYIE)
// <q0.12> Main PLL (PLL) ready interrupt enable (PLLRDYIE)
// <q0.11> HSE ready interrupt enable (HSERDYIE)
// <q0.10> HSI ready interrupt enable (HSIRDYIE)
// <q0.9> LSE ready interrupt enable (LSERDYIE)
// <q0.8> LSI ready interrupt enable (LSIRDYIE)
// </h>
#define RCC_CIR_VALUE 0x00000000
// <h> RCC AHB1 Peripheral Clock Enable Register (RCC_AHB1ENR)
// <q0.30> USB OTG HSULPI clock enable (OTGHSULPIEN)
// <q0.29> USB OTG HS clock enable (OTGHSEN)
// <q0.29> Ethernet PTP clock enable (ETHMACPTPEN)
// <q0.27> Ethernet Reception clock enable (ETHMACRXEN)
// <q0.26> Ethernet Transmission clock enable (ETHMACTXEN)
// <q0.25> Ethernet MAC clock enable (ETHMACEN)
// <q0.22> DMA2 clock enable (DMA2EN)
// <q0.21> DMA1 clock enable (DMA1EN)
// <q0.20> CCM data RAM clock enable (CCMDATARAMEN)
// <q0.18> Backup SRAM interface clock enable (BKPSRAMEN)
// <q0.12> CRC clock enable (CRCEN)
// <q0.8> IO port I clock enable (GPIOIEN)
// <q0.7> IO port H clock enable (GPIOHEN)
// <q0.6> IO port G clock enable (GPIOGEN)
// <q0.5> IO port F clock enable (GPIOFEN)
// <q0.4> IO port E clock enable (GPIOEEN)
// <q0.3> IO port D clock enable (GPIODEN)
// <q0.2> IO port C clock enable (GPIOCEN)
// <q0.1> IO port B clock enable (GPIOBEN)
// <q0.0> IO port A clock enable (GPIOAEN)
// </h>
#define RCC_AHB1ENR_VALUE 0x2E60011F
// <h> RCC AHB2 Peripheral Clock Enable Register (RCC_AHB2ENR)
// <q0.7> USB OTG FS clock enable (OTGFSEN)
// <q0.6> Random number generator clock enable (RNGEN)
// <q0.5> Hash modules clock enable (HASHEN)
// <q0.4> Cryptographic modules clock enable (CRYPEN)
// <q0.0> Camera interface enable (DCMIEN)
// </h>
#define RCC_AHB2ENR_VALUE 0x00000000
// <h> RCC AHB3 Peripheral Clock Enable Register (RCC_AHB3ENR)
// <q0.0> Flexible static memory controller module clock enable (FSMCEN)
// </h>
#define RCC_AHB3ENR_VALUE 0x00000000
// <h> RCC APB1 Peripheral Clock Enable Register (RCC_APB1ENR)
// <q0.29> DAC interface clock enable (DACEN)
// <q0.28> Power interface clock enable (PWREN)
// <q0.26> CAN 2 clock enable (CAN2EN)
// <q0.25> CAN 1 clock enable (CAN1EN)
// <q0.23> I2C3 clock enable (I2C3EN)
// <q0.22> I2C2 clock enable (I2C2EN)
// <q0.21> I2C1 clock enable (I2C1EN)
// <q0.20> UART5 clock enable (UART5EN)
// <q0.19> UART4 clock enable (UART4EN)
// <q0.18> USART3 clock enable (USART3EN)
// <q0.17> USART2 clock enable (USART2EN)
// <q0.15> SPI3 clock enable (SPI3EN)
// <q0.14> SPI2 clock enable (SPI2EN)
// <q0.11> Window watchdog clock enable (WWDGEN)
// <q0.8> TIM14 clock enable (TIM14EN)
// <q0.7> TIM13 clock enable (TIM13EN)
// <q0.6> TIM12 clock enable (TIM12EN)
// <q0.5> TIM7 clock enable (TIM7EN)
// <q0.4> TIM6 clock enable (TIM6EN)
// <q0.3> TIM5 clock enable (TIM5EN)
// <q0.2> TIM4 clock enable (TIM4EN)
// <q0.1> TIM3 clock enable (TIM3EN)
// <q0.0> TIM2 clock enable (TIM2EN)
// </h>
#define RCC_APB1ENR_VALUE 0x10040000
// <h> RCC APB2 Peripheral Clock Enable Register (RCC_APB2ENR)
// <q0.21> SPI6 clock enable (SPI6EN)
// <q0.20> SPI5 clock enable (SPI5EN)
// <q0.18> TIM11 clock enable (TIM11EN)
// <q0.17> TIM10 clock enable (TIM10EN)
// <q0.16> TIM9 clock enable (TIM9EN)
// <q0.14> System configuration controller clock enable (SYSCFGEN)
// <q0.13> SPI4 clock enable (SPI4EN)
// <q0.12> SPI1 clock enable (SPI1EN)
// <q0.11> SDIO clock enable (SDIOEN)
// <q0.10> ADC3 clock enable (ADC3EN)
// <q0.9> ADC2 clock enable (ADC2EN)
// <q0.8> ADC1 clock enable (ADC1EN)
// <q0.5> USART6 clock enable (USART6EN)
// <q0.4> USART1 clock enable (USART1EN)
// <q0.1> TIM8 clock enable (TIM8EN)
// <q0.0> TIM1 clock enable (TIM1EN)
// </h>
#define RCC_APB2ENR_VALUE 0x00005010
// <h> RCC AHB1 Peripheral Clock Enable in Low Power Mode Register (RCC_AHB1LPENR)
// <q0.30> USB OTG HS ULPI clock enable during Sleep mode (OTGHSULPILPEN)
// <q0.29> USB OTG HS clock enable during Sleep mode (OTGHSLPEN)
// <q0.28> Ethernet PTP clock enable during Sleep mode (ETHMACPTPLPEN)
// <q0.27> Ethernet reception clock enable during Sleep mode (ETHMACRXLPEN)
// <q0.26> Ethernet transmission clock enable during Sleep mode (ETHMACTXLPEN)
// <q0.25> Ethernet MAC clock enable during Sleep mode (ETHMACLPEN)
// <q0.22> DMA2 clock enable during Sleep mode (DMA2LPEN)
// <q0.21> DMA1 clock enable during Sleep mode (DMA1LPEN)
// <q0.18> Backup SRAM interface clock enable during Sleep mode (BKPSRAMLPEN)
// <q0.17> SRAM 2 interface clock enable during Sleep mode (SRAM2LPEN)
// <q0.16> SRAM 1interface clock enable during Sleep mode (SRAM1LPEN)
// <q0.15> Flash interface clock enable during Sleep mode (FLITFLPEN)
// <q0.12> CRC clock enable during Sleep mode (CRCLPEN)
// <q0.8> IO port I clock enable during Sleep mode (GPIOILPEN)
// <q0.7> IO port H clock enable during Sleep mode (GPIOHLPEN)
// <q0.6> IO port G clock enable during Sleep mode (GPIOGLPEN)
// <q0.5> IO port F clock enable during Sleep mode (GPIOFLPEN)
// <q0.4> IO port E clock enable during Sleep mode (GPIOELPEN)
// <q0.3> IO port D clock enable during Sleep mode (GPIODLPEN)
// <q0.2> IO port C clock enable during Sleep mode (GPIOCLPEN)
// <q0.1> IO port B clock enable during Sleep mode (GPIOBLPEN)
// <q0.0> IO port A clock enable during sleep mode (GPIOALPEN)
// </h>
#define RCC_AHB1LPENR_VALUE 0x00000000
// <h> RCC AHB2 Peripheral Clock Enable in Low Power Mode Register (RCC_AHB2LPENR)
// <q0.7> USB OTG FS clock enable during Sleep mode (OTGFSLPEN)
// <q0.6> Random number generator clock enable during Sleep mode (RNGLPEN)
// <q0.5> Hash modules clock enable during Sleep mode (HASHLPEN)
// <q0.4> Cryptography modules clock enable during Sleep mode (CRYPLPEN)
// <q0.0> Camera interface enable during Sleep mode (DCMILPEN)
// </h>
#define RCC_AHB2LPENR_VALUE 0x00000000
// <h> RCC AHB3 Peripheral Clock Enable in Low Power Mode Register (RCC_AHB3LPENR)
// <q0.0> Flexible static memory controller module clock enable during Sleep mode (FSMCLPEN)
// </h>
#define RCC_AHB3LPENR_VALUE 0x00000000
// <h> RCC APB1 Peripheral Clock Enable in Low Power Mode Register (RCC_APB1LPENR)
// <q0.29> DAC interface clock enable during Sleep mode (DACLPEN)
// <q0.28> Power interface clock enable during Sleep mode (PWRLPEN)
// <q0.26> CAN 2 clock enable during Sleep mode (CAN2LPEN)
// <q0.25> CAN 1 clock enable during Sleep mode (CAN1LPEN)
// <q0.23> I2C3 clock enable during Sleep mode (I2C3LPEN)
// <q0.22> I2C2 clock enable during Sleep mode (I2C2LPEN)
// <q0.21> I2C1 clock enable during Sleep mode (I2C1LPEN)
// <q0.20> UART5 clock enable during Sleep mode (UART5LPEN)
// <q0.19> UART4 clock enable during Sleep mode (UART4LPEN)
// <q0.18> USART3 clock enable during Sleep mode (USART3LPEN)
// <q0.17> USART2 clock enable during Sleep mode (USART2LPEN)
// <q0.15> SPI3 clock enable during Sleep mode (SPI3LPEN)
// <q0.14> SPI2 clock enable during Sleep mode (SPI2LPEN)
// <q0.11> Window watchdog clock enable during Sleep mode (WWDGLPEN)
// <q0.8> TIM14 clock enable during Sleep mode (TIM14LPEN)
// <q0.7> TIM13 clock enable during Sleep mode (TIM13LPEN)
// <q0.6> TIM12 clock enable during Sleep mode (TIM12LPEN)
// <q0.5> TIM7 clock enable during Sleep mode (TIM7LPEN)
// <q0.4> TIM6 clock enable during Sleep mode (TIM6LPEN)
// <q0.3> TIM5 clock enable during Sleep mode (TIM5LPEN)
// <q0.2> TIM4 clock enable during Sleep mode (TIM4LPEN)
// <q0.1> TIM3 clock enable during Sleep mode (TIM3LPEN)
// <q0.0> TIM2 clock enable during Sleep mode (TIM2LPEN)
// </h>
#define RCC_APB1LPENR_VALUE 0x00000000
// <h> RCC APB2 Peripheral Clock Enabled in Low Power Mode Register (RCC_APB2LPENR)
// <q0.18> TIM11 clock enable during Sleep mode (TIM11LPEN)
// <q0.17> TIM10 clock enable during Sleep mode (TIM10LPEN)
// <q0.16> TIM9 clock enable during sleep mode (TIM9LPEN)
// <q0.14> System configuration controller clock enable during Sleep mode (SYSCFGLPEN)
// <q0.12> SPI1 clock enable during Sleep mode (SPI1LPEN)
// <q0.11> SDIO clock enable during Sleep mode (SDIOLPEN)
// <q0.10> ADC 3 clock enable during Sleep mode (ADC3LPEN)
// <q0.9> ADC2 clock enable during Sleep mode (ADC2LPEN)
// <q0.8> ADC1 clock enable during Sleep mode (ADC1LPEN)
// <q0.5> USART6 clock enable during Sleep mode (USART6LPEN)
// <q0.4> USART1 clock enable during Sleep mode (USART1LPEN)
// <q0.1> TIM8 clock enable during Sleep mode (TIM8LPEN)
// <q0.0> TIM1 clock enable during Sleep mode (TIM1LPEN)
// </h>
#define RCC_APB2LPENR_VALUE 0x00000000
// <h> RCC Backup Domain Control Register (RCC_BDCR)
// <o0.16> Backup domain software reset (BDRST)
// <i> The LSEON, LSEBYP, RTCSEL and RTCEN bits in the RCC Backup domain control register (RCC_BDCR) are in the Backup domain. As a result, after Reset, these bits are
// <i> write-protected and the DBP bit in the PWR power control register (PWR_CR) for STM32F405xx/07xx and STM32F415xx/17xx has to be set before these can be modified.
// <o0.15> RTC clock enable (RTCEN)
// <i> The LSEON, LSEBYP, RTCSEL and RTCEN bits in the RCC Backup domain control register (RCC_BDCR) are in the Backup domain. As a result, after Reset, these bits are
// <i> write-protected and the DBP bit in the PWR power control register (PWR_CR) for STM32F405xx/07xx and STM32F415xx/17xx has to be set before these can be modified.
// <o0.8..9> RTC clock source selection (RTCSEL[1:0])
// <0=> No clock
// <1=> LSE Clock
// <2=> LSI Clock
// <3=> HSE Clock DIV by RTCPRE
// <i> HSE oscillator clock divided by a programmable prescaler (selection through the RTCPRE[4:0] bits in the RCC clock configuration register (RCC_CFGR)) used as the RTC clock
// <i> .
// <i> The LSEON, LSEBYP, RTCSEL and RTCEN bits in the RCC Backup domain control register (RCC_BDCR) are in the Backup domain. As a result, after Reset, these bits are
// <i> write-protected and the DBP bit in the PWR power control register (PWR_CR) for STM32F405xx/07xx and STM32F415xx/17xx has to be set before these can be modified.
// <o0.2> External low-speed oscillator bypass (LSEBYP)
// <i> The LSEON, LSEBYP, RTCSEL and RTCEN bits in the RCC Backup domain control register (RCC_BDCR) are in the Backup domain. As a result, after Reset, these bits are
// <i> write-protected and the DBP bit in the PWR power control register (PWR_CR) for STM32F405xx/07xx and STM32F415xx/17xx has to be set before these can be modified.
// <o0.1> External low-speed oscillator ready (LSERDY)
// <i> The LSEON, LSEBYP, RTCSEL and RTCEN bits in the RCC Backup domain control register (RCC_BDCR) are in the Backup domain. As a result, after Reset, these bits are
// <i> write-protected and the DBP bit in the PWR power control register (PWR_CR) for STM32F405xx/07xx and STM32F415xx/17xx has to be set before these can be modified.
// <o0.0> External low-speed oscillator enable (LSEON)
// <i> The LSEON, LSEBYP, RTCSEL and RTCEN bits in the RCC Backup domain control register (RCC_BDCR) are in the Backup domain. As a result, after Reset, these bits are
// <i> write-protected and the DBP bit in the PWR power control register (PWR_CR) for STM32F405xx/07xx and STM32F415xx/17xx has to be set before these can be modified.
// </h>
#define RCC_BDCR_VALUE 0x00000000
// <h> RCC Clock Control & Status Register (RCC_CSR)
// <o0.0> Internal low-speed oscillator enable (LSION)
// </h>
#define RCC_CSR_VALUE 0x00000000
// <h> RCC PLLI2S Configuration Register (RCC_PLLI2SCFGR)
// <o0.28..30> PLLI2S division factor for I2S clocks (PLLI2SR) <2-7>
// <o0.6..14> PLLI2S multiplication factor for VCO (PLLI2SN) <192-432>
// </h>
// </h>
//</h>
#define RCC_PLLI2SCFGR_VALUE 0x00000000
/*------------------------------------------ GPIO Registers -----------------------------------------*/
//<h> General Purpose I/O (GPIO)
// <h> GPIO Port Mode Register (GPIOx_MODER)
// <h> GPIO PORTA
// <o0.0..1> PORT0
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.2..3> PORT1
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.4..5> PORT2
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.6..7> PORT3
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.8..9> PORT4
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.10..11> PORT5
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.12..13> PORT6
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.14..15> PORT7
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.16..17> PORT8
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.18..19> PORT9
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.20..21> PORT10
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.22..23> PORT11
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.24..25> PORT12
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.26..27> PORT13
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.28..29> PORT14
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.30..31> PORT15
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// </h> GPIO PORTA
#define GPIOA_MODER_VALUE 0xA80280AA
// <h> GPIO PORTB
// <o0.0..1> PORT0
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.2..3> PORT1
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.4..5> PORT2
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.6..7> PORT3
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.8..9> PORT4
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.10..11> PORT5
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.12..13> PORT6
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.14..15> PORT7
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.16..17> PORT8
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.18..19> PORT9
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.20..21> PORT10
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.22..23> PORT11
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.24..25> PORT12
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.26..27> PORT13
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.28..29> PORT14
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.30..31> PORT15
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// </h> GPIO PORTB
#define GPIOB_MODER_VALUE 0x0AA22A8A
// <h> GPIO PORTC
// <o0.0..1> PORT0
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.2..3> PORT1
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.4..5> PORT2
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.6..7> PORT3
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.8..9> PORT4
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.10..11> PORT5
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.12..13> PORT6
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.14..15> PORT7
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.16..17> PORT8
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.18..19> PORT9
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.20..21> PORT10
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.22..23> PORT11
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.24..25> PORT12
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.26..27> PORT13
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.28..29> PORT14
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.30..31> PORT15
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// </h> GPIO PORTC
#define GPIOC_MODER_VALUE 0x00011AA8
// <h> GPIO PORTD
// <o0.0..1> PORT0
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.2..3> PORT1
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.4..5> PORT2
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.6..7> PORT3
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.8..9> PORT4
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.10..11> PORT5
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.12..13> PORT6
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.14..15> PORT7
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.16..17> PORT8
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.18..19> PORT9
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.20..21> PORT10
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.22..23> PORT11
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.24..25> PORT12
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.26..27> PORT13
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.28..29> PORT14
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.30..31> PORT15
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// </h> GPIO PORTD
#define GPIOD_MODER_VALUE 0x551A0400
// <h> GPIO PORTE
// <o0.0..1> PORT0
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.2..3> PORT1
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.4..5> PORT2
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.6..7> PORT3
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.8..9> PORT4
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.10..11> PORT5
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.12..13> PORT6
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.14..15> PORT7
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.16..17> PORT8
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.18..19> PORT9
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.20..21> PORT10
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.22..23> PORT11
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.24..25> PORT12
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.26..27> PORT13
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.28..29> PORT14
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.30..31> PORT15
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// </h> GPIO PORTE
#define GPIOE_MODER_VALUE 0x15504000
// <h> GPIO PORTF
// <o0.0..1> PORT0
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.2..3> PORT1
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.4..5> PORT2
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.6..7> PORT3
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.8..9> PORT4
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.10..11> PORT5
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.12..13> PORT6
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.14..15> PORT7
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.16..17> PORT8
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.18..19> PORT9
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.20..21> PORT10
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.22..23> PORT11
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.24..25> PORT12
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.26..27> PORT13
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.28..29> PORT14
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.30..31> PORT15
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// </h> GPIO PORTF
#define GPIOF_MODER_VALUE 0x00000000
// <h> GPIO PORTG
// <o0.0..1> PORT0
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.2..3> PORT1
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.4..5> PORT2
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.6..7> PORT3
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.8..9> PORT4
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.10..11> PORT5
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.12..13> PORT6
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.14..15> PORT7
// <0=> Input
// <1=> General Purpose Output
// <2=> Alternate Function
// <3=> Analog Mode
// <o0.16..17> PORT8
// <0=> Input