浏览代码

first time

june9152 6 年之前
当前提交
dd1dc503c7
共有 100 个文件被更改,包括 70920 次插入0 次删除
  1. 284 0
      .cproject
  2. 14 0
      .mxproject
  3. 76 0
      .project
  4. 73 0
      .project.bak
  5. 11 0
      .settings/com.atollic.truestudio.debug.hardware_device.prefs
  6. 20 0
      .settings/language.settings.xml
  7. 11 0
      .settings/org.eclipse.cdt.managedbuilder.core.prefs
  8. 二进制
      Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.o
  9. 23 0
      Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.su
  10. 二进制
      Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.o
  11. 15 0
      Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.su
  12. 二进制
      Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.o
  13. 12 0
      Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.su
  14. 二进制
      Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.o
  15. 13 0
      Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.su
  16. 二进制
      Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.o
  17. 9 0
      Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.su
  18. 二进制
      Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.o
  19. 8 0
      Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.su
  20. 二进制
      Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.o
  21. 3 0
      Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.su
  22. 二进制
      Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.o
  23. 18 0
      Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.su
  24. 二进制
      Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.o
  25. 14 0
      Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.su
  26. 二进制
      Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.o
  27. 3 0
      Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.su
  28. 二进制
      Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.o
  29. 99 0
      Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.su
  30. 二进制
      Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.o
  31. 36 0
      Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.su
  32. 二进制
      Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.o
  33. 52 0
      Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.su
  34. 二进制
      Debug/STM32F100_LoraTestBootloader.elf
  35. 778 0
      Debug/STM32F100_LoraTestBootloader.hex
  36. 6663 0
      Debug/STM32F100_LoraTestBootloader.list
  37. 1962 0
      Debug/STM32F100_LoraTestBootloader.map
  38. 二进制
      Debug/Src/flash_if.o
  39. 5 0
      Debug/Src/flash_if.su
  40. 二进制
      Debug/Src/main.o
  41. 12 0
      Debug/Src/main.su
  42. 二进制
      Debug/Src/sth30_crc.o
  43. 3 0
      Debug/Src/sth30_crc.su
  44. 二进制
      Debug/Src/stm32f1xx_hal_msp.o
  45. 5 0
      Debug/Src/stm32f1xx_hal_msp.su
  46. 二进制
      Debug/Src/stm32f1xx_it.o
  47. 11 0
      Debug/Src/stm32f1xx_it.su
  48. 二进制
      Debug/Src/system_stm32f1xx.o
  49. 2 0
      Debug/Src/system_stm32f1xx.su
  50. 二进制
      Debug/startup/startup_stm32f100xb.o
  51. 6375 0
      Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f100xb.h
  52. 238 0
      Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h
  53. 116 0
      Drivers/CMSIS/Device/ST/STM32F1xx/Include/system_stm32f1xx.h
  54. 136 0
      Drivers/CMSIS/Include/arm_common_tables.h
  55. 79 0
      Drivers/CMSIS/Include/arm_const_structs.h
  56. 7154 0
      Drivers/CMSIS/Include/arm_math.h
  57. 734 0
      Drivers/CMSIS/Include/cmsis_armcc.h
  58. 1800 0
      Drivers/CMSIS/Include/cmsis_armcc_V6.h
  59. 1373 0
      Drivers/CMSIS/Include/cmsis_gcc.h
  60. 798 0
      Drivers/CMSIS/Include/core_cm0.h
  61. 914 0
      Drivers/CMSIS/Include/core_cm0plus.h
  62. 1763 0
      Drivers/CMSIS/Include/core_cm3.h
  63. 1937 0
      Drivers/CMSIS/Include/core_cm4.h
  64. 2512 0
      Drivers/CMSIS/Include/core_cm7.h
  65. 87 0
      Drivers/CMSIS/Include/core_cmFunc.h
  66. 87 0
      Drivers/CMSIS/Include/core_cmInstr.h
  67. 96 0
      Drivers/CMSIS/Include/core_cmSimd.h
  68. 926 0
      Drivers/CMSIS/Include/core_sc000.h
  69. 1745 0
      Drivers/CMSIS/Include/core_sc300.h
  70. 3219 0
      Drivers/STM32F1xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h
  71. 367 0
      Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h
  72. 426 0
      Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_cortex.h
  73. 214 0
      Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h
  74. 473 0
      Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma.h
  75. 293 0
      Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma_ex.h
  76. 344 0
      Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash.h
  77. 802 0
      Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash_ex.h
  78. 324 0
      Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio.h
  79. 910 0
      Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio_ex.h
  80. 404 0
      Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pwr.h
  81. 1393 0
      Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc.h
  82. 1924 0
      Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc_ex.h
  83. 1793 0
      Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim.h
  84. 343 0
      Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim_ex.h
  85. 785 0
      Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_uart.h
  86. 595 0
      Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c
  87. 521 0
      Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c
  88. 902 0
      Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c
  89. 983 0
      Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c
  90. 1143 0
      Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c
  91. 595 0
      Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c
  92. 143 0
      Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c
  93. 637 0
      Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c
  94. 1416 0
      Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c
  95. 879 0
      Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c
  96. 5419 0
      Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c
  97. 1773 0
      Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c
  98. 2556 0
      Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c
  99. 239 0
      Inc/flash_if.h
  100. 0 0
      Inc/main.h

文件差异内容过多而无法显示
+ 284 - 0
.cproject


文件差异内容过多而无法显示
+ 14 - 0
.mxproject


+ 76 - 0
.project

@@ -0,0 +1,76 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<projectDescription>
3
+	<name>STM32F100_LoraTestBootloader</name>
4
+	<comment />
5
+	<projects>
6
+	</projects>
7
+	<buildSpec>
8
+		<buildCommand>
9
+			<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
10
+			<triggers>clean,full,incremental,</triggers>
11
+			<arguments>
12
+				<dictionary>
13
+					<key>?children?</key>
14
+					<value>?name?=outputEntries\|?children?=?name?=entry\\\\\\\|\\\|\||</value>
15
+				</dictionary>
16
+				<dictionary>
17
+					<key>?name?</key>
18
+					<value />
19
+				</dictionary>
20
+				<dictionary>
21
+					<key>org.eclipse.cdt.make.core.append_environment</key>
22
+					<value>true</value>
23
+				</dictionary>
24
+				<dictionary>
25
+					<key>org.eclipse.cdt.make.core.buildArguments</key>
26
+					<value />
27
+				</dictionary>
28
+				<dictionary>
29
+					<key>org.eclipse.cdt.make.core.buildCommand</key>
30
+					<value>make</value>
31
+				</dictionary>
32
+				<dictionary>
33
+					<key>org.eclipse.cdt.make.core.buildLocation</key>
34
+					<value>${workspace_loc:/STM32100B-EVAL/Debug}</value>
35
+				</dictionary>
36
+				<dictionary>
37
+					<key>org.eclipse.cdt.make.core.contents</key>
38
+					<value>org.eclipse.cdt.make.core.activeConfigSettings</value>
39
+				</dictionary>
40
+				<dictionary>
41
+					<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
42
+					<value>false</value>
43
+				</dictionary>
44
+				<dictionary>
45
+					<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
46
+					<value>true</value>
47
+				</dictionary>
48
+				<dictionary>
49
+					<key>org.eclipse.cdt.make.core.enableFullBuild</key>
50
+					<value>true</value>
51
+				</dictionary>
52
+				<dictionary>
53
+					<key>org.eclipse.cdt.make.core.stopOnError</key>
54
+					<value>true</value>
55
+				</dictionary>
56
+				<dictionary>
57
+					<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
58
+					<value>true</value>
59
+				</dictionary>
60
+			</arguments>
61
+		</buildCommand>
62
+		<buildCommand>
63
+			<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
64
+			<arguments>
65
+			</arguments>
66
+		</buildCommand>
67
+	</buildSpec>
68
+	<natures>
69
+		<nature>org.eclipse.cdt.core.cnature</nature>
70
+		<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
71
+		<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
72
+	</natures>
73
+	<linkedResources>
74
+		
75
+	</linkedResources>
76
+</projectDescription>

+ 73 - 0
.project.bak

@@ -0,0 +1,73 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<projectDescription>
3
+	<name>STM32F100_LoraTestBootloader</name>
4
+	<comment></comment>
5
+	<projects>
6
+	</projects>
7
+	<buildSpec>
8
+		<buildCommand>
9
+			<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
10
+			<triggers>clean,full,incremental,</triggers>
11
+			<arguments>
12
+				<dictionary>
13
+					<key>?children?</key>
14
+					<value>?name?=outputEntries\|?children?=?name?=entry\\\\\\\|\\\|\||</value>
15
+				</dictionary>
16
+				<dictionary>
17
+					<key>?name?</key>
18
+					<value></value>
19
+				</dictionary>
20
+				<dictionary>
21
+					<key>org.eclipse.cdt.make.core.append_environment</key>
22
+					<value>true</value>
23
+				</dictionary>
24
+				<dictionary>
25
+					<key>org.eclipse.cdt.make.core.buildArguments</key>
26
+					<value></value>
27
+				</dictionary>
28
+				<dictionary>
29
+					<key>org.eclipse.cdt.make.core.buildCommand</key>
30
+					<value>make</value>
31
+				</dictionary>
32
+				<dictionary>
33
+					<key>org.eclipse.cdt.make.core.buildLocation</key>
34
+					<value>${workspace_loc:/STM32100B-EVAL/Debug}</value>
35
+				</dictionary>
36
+				<dictionary>
37
+					<key>org.eclipse.cdt.make.core.contents</key>
38
+					<value>org.eclipse.cdt.make.core.activeConfigSettings</value>
39
+				</dictionary>
40
+				<dictionary>
41
+					<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
42
+					<value>false</value>
43
+				</dictionary>
44
+				<dictionary>
45
+					<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
46
+					<value>true</value>
47
+				</dictionary>
48
+				<dictionary>
49
+					<key>org.eclipse.cdt.make.core.enableFullBuild</key>
50
+					<value>true</value>
51
+				</dictionary>
52
+				<dictionary>
53
+					<key>org.eclipse.cdt.make.core.stopOnError</key>
54
+					<value>true</value>
55
+				</dictionary>
56
+				<dictionary>
57
+					<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
58
+					<value>true</value>
59
+				</dictionary>
60
+			</arguments>
61
+		</buildCommand>
62
+		<buildCommand>
63
+			<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
64
+			<arguments>
65
+			</arguments>
66
+		</buildCommand>
67
+	</buildSpec>
68
+	<natures>
69
+		<nature>org.eclipse.cdt.core.cnature</nature>
70
+		<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
71
+		<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
72
+	</natures>
73
+</projectDescription>

+ 11 - 0
.settings/com.atollic.truestudio.debug.hardware_device.prefs

@@ -0,0 +1,11 @@
1
+BOARD=None
2
+CODE_LOCATION=FLASH
3
+ENDIAN=Little-endian
4
+MCU=STM32F100C6
5
+MCU_VENDOR=STMicroelectronics
6
+MODEL=Lite
7
+PROBE=ST-LINK
8
+PROJECT_FORMAT_VERSION=2
9
+TARGET=ARM\u00AE
10
+VERSION=4.1.0
11
+eclipse.preferences.version=1

+ 20 - 0
.settings/language.settings.xml

@@ -0,0 +1,20 @@
1
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+<project>
3
+	<configuration id="com.atollic.truestudio.exe.debug.1518366166" name="Debug">
4
+		<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
5
+			<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
6
+			<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
7
+			<provider class="com.atollic.truestudio.mbs.GCCSpecsDetectorAtollicArm" console="false" env-hash="-840853398896664778" id="com.atollic.truestudio.mbs.provider" keep-relative-paths="false" name="Atollic ARM Tools Language Settings" parameter="${COMMAND} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
8
+				<language-scope id="org.eclipse.cdt.core.gcc"/>
9
+				<language-scope id="org.eclipse.cdt.core.g++"/>
10
+			</provider>
11
+		</extension>
12
+	</configuration>
13
+	<configuration id="com.atollic.truestudio.exe.release.1518366166" name="Release">
14
+		<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
15
+			<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
16
+			<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
17
+			<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
18
+		</extension>
19
+	</configuration>
20
+</project>

+ 11 - 0
.settings/org.eclipse.cdt.managedbuilder.core.prefs

@@ -0,0 +1,11 @@
1
+eclipse.preferences.version=1
2
+environment/buildEnvironmentInclude/com.atollic.truestudio.exe.debug.1518366166/CPATH/delimiter=;
3
+environment/buildEnvironmentInclude/com.atollic.truestudio.exe.debug.1518366166/CPATH/operation=remove
4
+environment/buildEnvironmentInclude/com.atollic.truestudio.exe.debug.1518366166/C_INCLUDE_PATH/delimiter=;
5
+environment/buildEnvironmentInclude/com.atollic.truestudio.exe.debug.1518366166/C_INCLUDE_PATH/operation=remove
6
+environment/buildEnvironmentInclude/com.atollic.truestudio.exe.debug.1518366166/append=true
7
+environment/buildEnvironmentInclude/com.atollic.truestudio.exe.debug.1518366166/appendContributed=true
8
+environment/buildEnvironmentLibrary/com.atollic.truestudio.exe.debug.1518366166/LIBRARY_PATH/delimiter=;
9
+environment/buildEnvironmentLibrary/com.atollic.truestudio.exe.debug.1518366166/LIBRARY_PATH/operation=remove
10
+environment/buildEnvironmentLibrary/com.atollic.truestudio.exe.debug.1518366166/append=true
11
+environment/buildEnvironmentLibrary/com.atollic.truestudio.exe.debug.1518366166/appendContributed=true

二进制
Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.o


+ 23 - 0
Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.su

@@ -0,0 +1,23 @@
1
+stm32f1xx_hal.c:216:13:HAL_MspInit	0	static
2
+stm32f1xx_hal.c:227:13:HAL_MspDeInit	0	static
3
+stm32f1xx_hal.c:191:19:HAL_DeInit	8	static
4
+stm32f1xx_hal.c:250:26:HAL_InitTick	16	static
5
+stm32f1xx_hal.c:158:19:HAL_Init	8	static
6
+stm32f1xx_hal.c:309:13:HAL_IncTick	0	static
7
+stm32f1xx_hal.c:320:17:HAL_GetTick	0	static
8
+stm32f1xx_hal.c:329:10:HAL_GetTickPrio	0	static
9
+stm32f1xx_hal.c:338:19:HAL_SetTickFreq	8	static
10
+stm32f1xx_hal.c:358:21:HAL_GetTickFreq	0	static
11
+stm32f1xx_hal.c:374:13:HAL_Delay	16	static
12
+stm32f1xx_hal.c:400:13:HAL_SuspendTick	0	static
13
+stm32f1xx_hal.c:416:13:HAL_ResumeTick	0	static
14
+stm32f1xx_hal.c:426:10:HAL_GetHalVersion	0	static
15
+stm32f1xx_hal.c:442:10:HAL_GetREVID	0	static
16
+stm32f1xx_hal.c:458:10:HAL_GetDEVID	0	static
17
+stm32f1xx_hal.c:467:6:HAL_DBGMCU_EnableDBGSleepMode	0	static
18
+stm32f1xx_hal.c:483:6:HAL_DBGMCU_DisableDBGSleepMode	0	static
19
+stm32f1xx_hal.c:513:6:HAL_DBGMCU_EnableDBGStopMode	0	static
20
+stm32f1xx_hal.c:529:6:HAL_DBGMCU_DisableDBGStopMode	0	static
21
+stm32f1xx_hal.c:545:6:HAL_DBGMCU_EnableDBGStandbyMode	0	static
22
+stm32f1xx_hal.c:561:6:HAL_DBGMCU_DisableDBGStandbyMode	0	static
23
+stm32f1xx_hal.c:571:6:HAL_GetUID	0	static

二进制
Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.o


+ 15 - 0
Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.su

@@ -0,0 +1,15 @@
1
+stm32f1xx_hal_cortex.c:159:6:HAL_NVIC_SetPriorityGrouping	0	static
2
+stm32f1xx_hal_cortex.c:181:6:HAL_NVIC_SetPriority	12	static
3
+stm32f1xx_hal_cortex.c:203:6:HAL_NVIC_EnableIRQ	0	static
4
+stm32f1xx_hal_cortex.c:219:6:HAL_NVIC_DisableIRQ	0	static
5
+stm32f1xx_hal_cortex.c:232:6:HAL_NVIC_SystemReset	0	static
6
+stm32f1xx_hal_cortex.c:245:10:HAL_SYSTICK_Config	0	static
7
+stm32f1xx_hal_cortex.c:360:10:HAL_NVIC_GetPriorityGrouping	0	static
8
+stm32f1xx_hal_cortex.c:387:6:HAL_NVIC_GetPriority	16	static
9
+stm32f1xx_hal_cortex.c:402:6:HAL_NVIC_SetPendingIRQ	0	static
10
+stm32f1xx_hal_cortex.c:420:10:HAL_NVIC_GetPendingIRQ	0	static
11
+stm32f1xx_hal_cortex.c:436:6:HAL_NVIC_ClearPendingIRQ	0	static
12
+stm32f1xx_hal_cortex.c:453:10:HAL_NVIC_GetActive	0	static
13
+stm32f1xx_hal_cortex.c:470:6:HAL_SYSTICK_CLKSourceConfig	0	static
14
+stm32f1xx_hal_cortex.c:497:13:HAL_SYSTICK_Callback	0	static
15
+stm32f1xx_hal_cortex.c:488:6:HAL_SYSTICK_IRQHandler	8	static

二进制
Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.o


+ 12 - 0
Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.su

@@ -0,0 +1,12 @@
1
+stm32f1xx_hal_dma.c:159:19:HAL_DMA_Init	8	static
2
+stm32f1xx_hal_dma.c:236:19:HAL_DMA_DeInit	8	static
3
+stm32f1xx_hal_dma.c:335:19:HAL_DMA_Start	20	static
4
+stm32f1xx_hal_dma.c:378:19:HAL_DMA_Start_IT	20	static
5
+stm32f1xx_hal_dma.c:432:19:HAL_DMA_Abort	0	static
6
+stm32f1xx_hal_dma.c:460:19:HAL_DMA_Abort_IT	8	static
7
+stm32f1xx_hal_dma.c:505:19:HAL_DMA_PollForTransfer	40	static
8
+stm32f1xx_hal_dma.c:606:6:HAL_DMA_IRQHandler	12	static
9
+stm32f1xx_hal_dma.c:696:19:HAL_DMA_RegisterCallback	8	static
10
+stm32f1xx_hal_dma.c:747:19:HAL_DMA_UnRegisterCallback	0	static
11
+stm32f1xx_hal_dma.c:823:22:HAL_DMA_GetState	0	static
12
+stm32f1xx_hal_dma.c:835:10:HAL_DMA_GetError	0	static

二进制
Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.o


+ 13 - 0
Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.su

@@ -0,0 +1,13 @@
1
+stm32f1xx_hal_flash.c:930:13:FLASH_SetErrorCode	0	static
2
+stm32f1xx_hal_flash.c:283:19:HAL_FLASH_Program_IT	16	static
3
+stm32f1xx_hal_flash.c:622:13:HAL_FLASH_EndOfOperationCallback	0	static
4
+stm32f1xx_hal_flash.c:640:13:HAL_FLASH_OperationErrorCallback	0	static
5
+stm32f1xx_hal_flash.c:348:6:HAL_FLASH_IRQHandler	16	static
6
+stm32f1xx_hal_flash.c:673:19:HAL_FLASH_Unlock	0	static
7
+stm32f1xx_hal_flash.c:711:19:HAL_FLASH_Lock	0	static
8
+stm32f1xx_hal_flash.c:728:19:HAL_FLASH_OB_Unlock	0	static
9
+stm32f1xx_hal_flash.c:748:19:HAL_FLASH_OB_Lock	0	static
10
+stm32f1xx_hal_flash.c:761:6:HAL_FLASH_OB_Launch	0	static
11
+stm32f1xx_hal_flash.c:790:10:HAL_FLASH_GetError	0	static
12
+stm32f1xx_hal_flash.c:842:19:FLASH_WaitForLastOperation	24	static
13
+stm32f1xx_hal_flash.c:184:19:HAL_FLASH_Program	40	static

二进制
Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.o


+ 9 - 0
Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.su

@@ -0,0 +1,9 @@
1
+stm32f1xx_hal_flash_ex.c:611:13:FLASH_MassErase.isra.0	0	static
2
+stm32f1xx_hal_flash_ex.c:902:26:FLASH_OB_RDP_LevelConfig	16	static
3
+stm32f1xx_hal_flash_ex.c:413:19:HAL_FLASHEx_OBErase	16	static
4
+stm32f1xx_hal_flash_ex.c:462:19:HAL_FLASHEx_OBProgram	24	static
5
+stm32f1xx_hal_flash_ex.c:543:6:HAL_FLASHEx_OBGetConfig	0	static
6
+stm32f1xx_hal_flash_ex.c:565:10:HAL_FLASHEx_OBGetUserData	0	static
7
+stm32f1xx_hal_flash_ex.c:1105:6:FLASH_PageErase	0	static
8
+stm32f1xx_hal_flash_ex.c:175:19:HAL_FLASHEx_Erase	24	static
9
+stm32f1xx_hal_flash_ex.c:335:19:HAL_FLASHEx_Erase_IT	16	static

二进制
Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.o


+ 8 - 0
Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.su

@@ -0,0 +1,8 @@
1
+stm32f1xx_hal_gpio.c:194:6:HAL_GPIO_Init	48	static
2
+stm32f1xx_hal_gpio.c:365:6:HAL_GPIO_DeInit	36	static
3
+stm32f1xx_hal_gpio.c:446:15:HAL_GPIO_ReadPin	0	static
4
+stm32f1xx_hal_gpio.c:480:6:HAL_GPIO_WritePin	0	static
5
+stm32f1xx_hal_gpio.c:502:6:HAL_GPIO_TogglePin	0	static
6
+stm32f1xx_hal_gpio.c:520:19:HAL_GPIO_LockPin	8	static
7
+stm32f1xx_hal_gpio.c:569:13:HAL_GPIO_EXTI_Callback	0	static
8
+stm32f1xx_hal_gpio.c:554:6:HAL_GPIO_EXTI_IRQHandler	8	static

二进制
Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.o


+ 3 - 0
Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.su

@@ -0,0 +1,3 @@
1
+stm32f1xx_hal_gpio_ex.c:97:6:HAL_GPIOEx_ConfigEventout	0	static
2
+stm32f1xx_hal_gpio_ex.c:111:6:HAL_GPIOEx_EnableEventout	0	static
3
+stm32f1xx_hal_gpio_ex.c:120:6:HAL_GPIOEx_DisableEventout	0	static

二进制
Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.o


+ 18 - 0
Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.su

@@ -0,0 +1,18 @@
1
+stm32f1xx_hal_pwr.c:133:13:PWR_OverloadWfe	0	static
2
+stm32f1xx_hal_pwr.c:172:6:HAL_PWR_DeInit	0	static
3
+stm32f1xx_hal_pwr.c:185:6:HAL_PWR_EnableBkUpAccess	0	static
4
+stm32f1xx_hal_pwr.c:198:6:HAL_PWR_DisableBkUpAccess	0	static
5
+stm32f1xx_hal_pwr.c:332:6:HAL_PWR_ConfigPVD	0	static
6
+stm32f1xx_hal_pwr.c:375:6:HAL_PWR_EnablePVD	0	static
7
+stm32f1xx_hal_pwr.c:385:6:HAL_PWR_DisablePVD	0	static
8
+stm32f1xx_hal_pwr.c:398:6:HAL_PWR_EnableWakeUpPin	0	static
9
+stm32f1xx_hal_pwr.c:413:6:HAL_PWR_DisableWakeUpPin	0	static
10
+stm32f1xx_hal_pwr.c:433:6:HAL_PWR_EnterSLEEPMode	0	static
11
+stm32f1xx_hal_pwr.c:479:6:HAL_PWR_EnterSTOPMode	8	static
12
+stm32f1xx_hal_pwr.c:519:6:HAL_PWR_EnterSTANDBYMode	0	static
13
+stm32f1xx_hal_pwr.c:544:6:HAL_PWR_EnableSleepOnExit	0	static
14
+stm32f1xx_hal_pwr.c:557:6:HAL_PWR_DisableSleepOnExit	0	static
15
+stm32f1xx_hal_pwr.c:570:6:HAL_PWR_EnableSEVOnPend	0	static
16
+stm32f1xx_hal_pwr.c:583:6:HAL_PWR_DisableSEVOnPend	0	static
17
+stm32f1xx_hal_pwr.c:613:13:HAL_PWR_PVDCallback	0	static
18
+stm32f1xx_hal_pwr.c:596:6:HAL_PWR_PVD_IRQHandler	8	static

二进制
Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.o


+ 14 - 0
Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.su

@@ -0,0 +1,14 @@
1
+stm32f1xx_hal_rcc.c:218:19:HAL_RCC_DeInit	16	static
2
+stm32f1xx_hal_rcc.c:363:19:HAL_RCC_OscConfig	32	static
3
+stm32f1xx_hal_rcc.c:1015:6:HAL_RCC_MCOConfig	40	static
4
+stm32f1xx_hal_rcc.c:1052:6:HAL_RCC_EnableCSS	0	static
5
+stm32f1xx_hal_rcc.c:1061:6:HAL_RCC_DisableCSS	0	static
6
+stm32f1xx_hal_rcc.c:1095:10:HAL_RCC_GetSysClockFreq	48	static
7
+stm32f1xx_hal_rcc.c:809:19:HAL_RCC_ClockConfig	24	static
8
+stm32f1xx_hal_rcc.c:1189:10:HAL_RCC_GetHCLKFreq	0	static
9
+stm32f1xx_hal_rcc.c:1200:10:HAL_RCC_GetPCLK1Freq	0	static
10
+stm32f1xx_hal_rcc.c:1212:10:HAL_RCC_GetPCLK2Freq	0	static
11
+stm32f1xx_hal_rcc.c:1225:6:HAL_RCC_GetOscConfig	0	static
12
+stm32f1xx_hal_rcc.c:1325:6:HAL_RCC_GetClockConfig	0	static
13
+stm32f1xx_hal_rcc.c:1392:13:HAL_RCC_CSSCallback	0	static
14
+stm32f1xx_hal_rcc.c:1360:6:HAL_RCC_NMI_IRQHandler	8	static

二进制
Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.o


+ 3 - 0
Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.su

@@ -0,0 +1,3 @@
1
+stm32f1xx_hal_rcc_ex.c:116:19:HAL_RCCEx_PeriphCLKConfig	32	static
2
+stm32f1xx_hal_rcc_ex.c:310:6:HAL_RCCEx_GetPeriphCLKConfig	0	static
3
+stm32f1xx_hal_rcc_ex.c:403:10:HAL_RCCEx_GetPeriphCLKFreq	8	static

二进制
Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.o


+ 99 - 0
Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.su

@@ -0,0 +1,99 @@
1
+stm32f1xx_hal_tim.c:4640:13:TIM_OC1_SetConfig	16	static
2
+stm32f1xx_hal_tim.c:4790:13:TIM_OC3_SetConfig	16	static
3
+stm32f1xx_hal_tim.c:4864:13:TIM_OC4_SetConfig	12	static
4
+stm32f1xx_hal_tim.c:4924:13:TIM_SlaveTimer_SetConfig	12	static
5
+stm32f1xx_hal_tim.c:275:13:HAL_TIM_Base_MspInit	0	static
6
+stm32f1xx_hal_tim.c:289:13:HAL_TIM_Base_MspDeInit	0	static
7
+stm32f1xx_hal_tim.c:248:19:HAL_TIM_Base_DeInit	8	static
8
+stm32f1xx_hal_tim.c:304:19:HAL_TIM_Base_Start	0	static
9
+stm32f1xx_hal_tim.c:327:19:HAL_TIM_Base_Stop	0	static
10
+stm32f1xx_hal_tim.c:350:19:HAL_TIM_Base_Start_IT	0	static
11
+stm32f1xx_hal_tim.c:370:19:HAL_TIM_Base_Stop_IT	0	static
12
+stm32f1xx_hal_tim.c:391:19:HAL_TIM_Base_Start_DMA	8	static
13
+stm32f1xx_hal_tim.c:435:19:HAL_TIM_Base_Stop_DMA	0	static
14
+stm32f1xx_hal_tim.c:555:13:HAL_TIM_OC_MspInit	0	static
15
+stm32f1xx_hal_tim.c:569:13:HAL_TIM_OC_MspDeInit	0	static
16
+stm32f1xx_hal_tim.c:528:19:HAL_TIM_OC_DeInit	8	static
17
+stm32f1xx_hal_tim.c:1064:13:HAL_TIM_PWM_MspInit	0	static
18
+stm32f1xx_hal_tim.c:1078:13:HAL_TIM_PWM_MspDeInit	0	static
19
+stm32f1xx_hal_tim.c:1037:19:HAL_TIM_PWM_DeInit	8	static
20
+stm32f1xx_hal_tim.c:1576:13:HAL_TIM_IC_MspInit	0	static
21
+stm32f1xx_hal_tim.c:1590:13:HAL_TIM_IC_MspDeInit	0	static
22
+stm32f1xx_hal_tim.c:1549:19:HAL_TIM_IC_DeInit	8	static
23
+stm32f1xx_hal_tim.c:2061:13:HAL_TIM_OnePulse_MspInit	0	static
24
+stm32f1xx_hal_tim.c:2075:13:HAL_TIM_OnePulse_MspDeInit	0	static
25
+stm32f1xx_hal_tim.c:2034:19:HAL_TIM_OnePulse_DeInit	8	static
26
+stm32f1xx_hal_tim.c:2093:19:HAL_TIM_OnePulse_Start	0	static
27
+stm32f1xx_hal_tim.c:2129:19:HAL_TIM_OnePulse_Stop	0	static
28
+stm32f1xx_hal_tim.c:2165:19:HAL_TIM_OnePulse_Start_IT	0	static
29
+stm32f1xx_hal_tim.c:2207:19:HAL_TIM_OnePulse_Stop_IT	0	static
30
+stm32f1xx_hal_tim.c:2394:13:HAL_TIM_Encoder_MspInit	0	static
31
+stm32f1xx_hal_tim.c:2408:13:HAL_TIM_Encoder_MspDeInit	0	static
32
+stm32f1xx_hal_tim.c:2367:19:HAL_TIM_Encoder_DeInit	8	static
33
+stm32f1xx_hal_tim.c:2427:19:HAL_TIM_Encoder_Start	0	static
34
+stm32f1xx_hal_tim.c:2469:19:HAL_TIM_Encoder_Stop	0	static
35
+stm32f1xx_hal_tim.c:2513:19:HAL_TIM_Encoder_Start_IT	0	static
36
+stm32f1xx_hal_tim.c:2561:19:HAL_TIM_Encoder_Stop_IT	0	static
37
+stm32f1xx_hal_tim.c:2615:19:HAL_TIM_Encoder_Start_DMA	24	static
38
+stm32f1xx_hal_tim.c:2732:19:HAL_TIM_Encoder_Stop_DMA	0	static
39
+stm32f1xx_hal_tim.c:3358:19:HAL_TIM_DMABurst_WriteStart	24	static
40
+stm32f1xx_hal_tim.c:3581:19:HAL_TIM_DMABurst_ReadStart	24	static
41
+stm32f1xx_hal_tim.c:3713:19:HAL_TIM_DMABurst_ReadStop	16	static
42
+stm32f1xx_hal_tim.c:3489:19:HAL_TIM_DMABurst_WriteStop	0	static
43
+stm32f1xx_hal_tim.c:3785:19:HAL_TIM_GenerateEvent	0	static
44
+stm32f1xx_hal_tim.c:3822:19:HAL_TIM_ConfigOCrefClear	16	static
45
+stm32f1xx_hal_tim.c:3943:19:HAL_TIM_ConfigClockSource	16	static
46
+stm32f1xx_hal_tim.c:4117:19:HAL_TIM_ConfigTI1Input	0	static
47
+stm32f1xx_hal_tim.c:4149:19:HAL_TIM_SlaveConfigSynchronization	16	static
48
+stm32f1xx_hal_tim.c:4184:19:HAL_TIM_SlaveConfigSynchronization_IT	16	static
49
+stm32f1xx_hal_tim.c:4222:10:HAL_TIM_ReadCapturedValue	0	static
50
+stm32f1xx_hal_tim.c:4309:13:HAL_TIM_PeriodElapsedCallback	0	static
51
+stm32f1xx_hal_tim.c:4562:13:TIM_DMAPeriodElapsedCplt	8	static
52
+stm32f1xx_hal_tim.c:4323:13:HAL_TIM_OC_DelayElapsedCallback	0	static
53
+stm32f1xx_hal_tim.c:4336:13:HAL_TIM_IC_CaptureCallback	0	static
54
+stm32f1xx_hal_tim.c:4529:6:TIM_DMACaptureCplt	8	static
55
+stm32f1xx_hal_tim.c:4350:13:HAL_TIM_PWM_PulseFinishedCallback	0	static
56
+stm32f1xx_hal_tim.c:4497:6:TIM_DMADelayPulseCplt	8	static
57
+stm32f1xx_hal_tim.c:4364:13:HAL_TIM_TriggerCallback	0	static
58
+stm32f1xx_hal_tim.c:2794:6:HAL_TIM_IRQHandler	8	static
59
+stm32f1xx_hal_tim.c:4576:13:TIM_DMATriggerCplt	8	static
60
+stm32f1xx_hal_tim.c:4378:13:HAL_TIM_ErrorCallback	0	static
61
+stm32f1xx_hal_tim.c:4483:6:TIM_DMAError	8	static
62
+stm32f1xx_hal_tim.c:4411:22:HAL_TIM_Base_GetState	0	static
63
+stm32f1xx_hal_tim.c:4421:22:HAL_TIM_OC_GetState	0	static
64
+stm32f1xx_hal_tim.c:4431:22:HAL_TIM_PWM_GetState	0	static
65
+stm32f1xx_hal_tim.c:4441:22:HAL_TIM_IC_GetState	0	static
66
+stm32f1xx_hal_tim.c:4451:22:HAL_TIM_OnePulse_GetState	0	static
67
+stm32f1xx_hal_tim.c:4461:22:HAL_TIM_Encoder_GetState	0	static
68
+stm32f1xx_hal_tim.c:4591:6:TIM_Base_SetConfig	0	static
69
+stm32f1xx_hal_tim.c:208:19:HAL_TIM_Base_Init	8	static
70
+stm32f1xx_hal_tim.c:488:19:HAL_TIM_OC_Init	8	static
71
+stm32f1xx_hal_tim.c:997:19:HAL_TIM_PWM_Init	8	static
72
+stm32f1xx_hal_tim.c:1509:19:HAL_TIM_IC_Init	8	static
73
+stm32f1xx_hal_tim.c:1987:19:HAL_TIM_OnePulse_Init	16	static
74
+stm32f1xx_hal_tim.c:2274:19:HAL_TIM_Encoder_Init	24	static
75
+stm32f1xx_hal_tim.c:4714:6:TIM_OC2_SetConfig	16	static
76
+stm32f1xx_hal_tim.c:2957:19:HAL_TIM_OC_ConfigChannel	16	static
77
+stm32f1xx_hal_tim.c:3122:19:HAL_TIM_PWM_ConfigChannel	16	static
78
+stm32f1xx_hal_tim.c:5068:6:TIM_TI1_SetConfig	16	static
79
+stm32f1xx_hal_tim.c:3026:19:HAL_TIM_IC_ConfigChannel	24	static
80
+stm32f1xx_hal_tim.c:3222:19:HAL_TIM_OnePulse_ConfigChannel	48	static
81
+stm32f1xx_hal_tim.c:5390:6:TIM_CCxChannelCmd	8	static
82
+stm32f1xx_hal_tim.c:621:19:HAL_TIM_OC_Stop	8	static
83
+stm32f1xx_hal_tim.c:1098:19:HAL_TIM_PWM_Start	8	static
84
+stm32f1xx_hal_tim.c:589:19:HAL_TIM_OC_Start	0	static
85
+stm32f1xx_hal_tim.c:1130:19:HAL_TIM_PWM_Stop	8	static
86
+stm32f1xx_hal_tim.c:1165:19:HAL_TIM_PWM_Start_IT	8	static
87
+stm32f1xx_hal_tim.c:653:19:HAL_TIM_OC_Start_IT	0	static
88
+stm32f1xx_hal_tim.c:1231:19:HAL_TIM_PWM_Stop_IT	8	static
89
+stm32f1xx_hal_tim.c:719:19:HAL_TIM_OC_Stop_IT	0	static
90
+stm32f1xx_hal_tim.c:1299:19:HAL_TIM_PWM_Start_DMA	16	static
91
+stm32f1xx_hal_tim.c:787:19:HAL_TIM_OC_Start_DMA	0	static
92
+stm32f1xx_hal_tim.c:1416:19:HAL_TIM_PWM_Stop_DMA	8	static
93
+stm32f1xx_hal_tim.c:904:19:HAL_TIM_OC_Stop_DMA	0	static
94
+stm32f1xx_hal_tim.c:1610:19:HAL_TIM_IC_Start	8	static
95
+stm32f1xx_hal_tim.c:1636:19:HAL_TIM_IC_Stop	8	static
96
+stm32f1xx_hal_tim.c:1662:19:HAL_TIM_IC_Start_IT	8	static
97
+stm32f1xx_hal_tim.c:1721:19:HAL_TIM_IC_Stop_IT	8	static
98
+stm32f1xx_hal_tim.c:1783:19:HAL_TIM_IC_Start_DMA	16	static
99
+stm32f1xx_hal_tim.c:1896:19:HAL_TIM_IC_Stop_DMA	8	static

二进制
Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.o


+ 36 - 0
Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.su

@@ -0,0 +1,36 @@
1
+stm32f1xx_hal_tim_ex.c:1743:13:TIM_CCxNChannelCmd	8	static
2
+stm32f1xx_hal_tim_ex.c:271:13:HAL_TIMEx_HallSensor_MspInit	0	static
3
+stm32f1xx_hal_tim_ex.c:165:19:HAL_TIMEx_HallSensor_Init	48	static
4
+stm32f1xx_hal_tim_ex.c:285:13:HAL_TIMEx_HallSensor_MspDeInit	0	static
5
+stm32f1xx_hal_tim_ex.c:244:19:HAL_TIMEx_HallSensor_DeInit	8	static
6
+stm32f1xx_hal_tim_ex.c:299:19:HAL_TIMEx_HallSensor_Start	8	static
7
+stm32f1xx_hal_tim_ex.c:320:19:HAL_TIMEx_HallSensor_Stop	8	static
8
+stm32f1xx_hal_tim_ex.c:341:19:HAL_TIMEx_HallSensor_Start_IT	8	static
9
+stm32f1xx_hal_tim_ex.c:365:19:HAL_TIMEx_HallSensor_Stop_IT	8	static
10
+stm32f1xx_hal_tim_ex.c:391:19:HAL_TIMEx_HallSensor_Start_DMA	16	static
11
+stm32f1xx_hal_tim_ex.c:438:19:HAL_TIMEx_HallSensor_Stop_DMA	8	static
12
+stm32f1xx_hal_tim_ex.c:871:19:HAL_TIMEx_PWMN_Start	8	static
13
+stm32f1xx_hal_tim_ex.c:497:19:HAL_TIMEx_OCN_Start	0	static
14
+stm32f1xx_hal_tim_ex.c:928:19:HAL_TIMEx_PWMN_Start_IT	8	static
15
+stm32f1xx_hal_tim_ex.c:555:19:HAL_TIMEx_OCN_Start_IT	0	static
16
+stm32f1xx_hal_tim_ex.c:987:19:HAL_TIMEx_PWMN_Stop_IT	8	static
17
+stm32f1xx_hal_tim_ex.c:614:19:HAL_TIMEx_OCN_Stop_IT	0	static
18
+stm32f1xx_hal_tim_ex.c:1054:19:HAL_TIMEx_PWMN_Start_DMA	16	static
19
+stm32f1xx_hal_tim_ex.c:681:19:HAL_TIMEx_OCN_Start_DMA	0	static
20
+stm32f1xx_hal_tim_ex.c:1152:19:HAL_TIMEx_PWMN_Stop_DMA	8	static
21
+stm32f1xx_hal_tim_ex.c:779:19:HAL_TIMEx_OCN_Stop_DMA	0	static
22
+stm32f1xx_hal_tim_ex.c:1232:19:HAL_TIMEx_OnePulseN_Start	8	static
23
+stm32f1xx_hal_tim_ex.c:1257:19:HAL_TIMEx_OnePulseN_Stop	8	static
24
+stm32f1xx_hal_tim_ex.c:899:19:HAL_TIMEx_PWMN_Stop	0	static
25
+stm32f1xx_hal_tim_ex.c:526:19:HAL_TIMEx_OCN_Stop	0	static
26
+stm32f1xx_hal_tim_ex.c:1286:19:HAL_TIMEx_OnePulseN_Start_IT	8	static
27
+stm32f1xx_hal_tim_ex.c:1317:19:HAL_TIMEx_OnePulseN_Stop_IT	8	static
28
+stm32f1xx_hal_tim_ex.c:1392:19:HAL_TIMEx_ConfigCommutationEvent	8	static
29
+stm32f1xx_hal_tim_ex.c:1441:19:HAL_TIMEx_ConfigCommutationEvent_IT	8	static
30
+stm32f1xx_hal_tim_ex.c:1494:19:HAL_TIMEx_ConfigCommutationEvent_DMA	8	static
31
+stm32f1xx_hal_tim_ex.c:1538:19:HAL_TIMEx_ConfigBreakDeadTime	0	static
32
+stm32f1xx_hal_tim_ex.c:1589:19:HAL_TIMEx_MasterConfigSynchronization	8	static
33
+stm32f1xx_hal_tim_ex.c:1642:13:HAL_TIMEx_CommutationCallback	0	static
34
+stm32f1xx_hal_tim_ex.c:1670:6:TIMEx_DMACommutationCplt	8	static
35
+stm32f1xx_hal_tim_ex.c:1656:13:HAL_TIMEx_BreakCallback	0	static
36
+stm32f1xx_hal_tim_ex.c:1707:22:HAL_TIMEx_HallSensor_GetState	0	static

二进制
Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.o


+ 52 - 0
Debug/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.su

@@ -0,0 +1,52 @@
1
+stm32f1xx_hal_uart.c:2188:13:UART_EndRxTransfer	0	static
2
+stm32f1xx_hal_uart.c:2466:13:UART_SetConfig	32	static
3
+stm32f1xx_hal_uart.c:2141:26:UART_WaitOnFlagUntilTimeout.constprop	24	static
4
+stm32f1xx_hal_uart.c:549:13:HAL_UART_MspInit	0	static
5
+stm32f1xx_hal_uart.c:259:19:HAL_UART_Init	8	static
6
+stm32f1xx_hal_uart.c:324:19:HAL_HalfDuplex_Init	8	static
7
+stm32f1xx_hal_uart.c:385:19:HAL_LIN_Init	16	static
8
+stm32f1xx_hal_uart.c:453:19:HAL_MultiProcessor_Init	16	static
9
+stm32f1xx_hal_uart.c:564:13:HAL_UART_MspDeInit	0	static
10
+stm32f1xx_hal_uart.c:517:19:HAL_UART_DeInit	8	static
11
+stm32f1xx_hal_uart.c:643:19:HAL_UART_Transmit	24	static
12
+stm32f1xx_hal_uart.c:725:19:HAL_UART_Receive	24	static
13
+stm32f1xx_hal_uart.c:813:19:HAL_UART_Transmit_IT	0	static
14
+stm32f1xx_hal_uart.c:854:19:HAL_UART_Receive_IT	0	static
15
+stm32f1xx_hal_uart.c:902:19:HAL_UART_Transmit_DMA	16	static
16
+stm32f1xx_hal_uart.c:967:19:HAL_UART_Receive_DMA	24	static
17
+stm32f1xx_hal_uart.c:1034:19:HAL_UART_DMAPause	0	static
18
+stm32f1xx_hal_uart.c:1071:19:HAL_UART_DMAResume	8	static
19
+stm32f1xx_hal_uart.c:1107:19:HAL_UART_DMAStop	8	static
20
+stm32f1xx_hal_uart.c:1159:19:HAL_UART_Abort	8	static
21
+stm32f1xx_hal_uart.c:1223:19:HAL_UART_AbortTransmit	8	static
22
+stm32f1xx_hal_uart.c:1265:19:HAL_UART_AbortReceive	8	static
23
+stm32f1xx_hal_uart.c:1682:14:HAL_UART_TxCpltCallback	0	static
24
+stm32f1xx_hal_uart.c:2026:13:UART_DMATransmitCplt	8	static
25
+stm32f1xx_hal_uart.c:1697:14:HAL_UART_TxHalfCpltCallback	0	static
26
+stm32f1xx_hal_uart.c:2055:13:UART_DMATxHalfCplt	8	static
27
+stm32f1xx_hal_uart.c:1712:13:HAL_UART_RxCpltCallback	0	static
28
+stm32f1xx_hal_uart.c:2067:13:UART_DMAReceiveCplt	8	static
29
+stm32f1xx_hal_uart.c:2402:26:UART_Receive_IT	8	static
30
+stm32f1xx_hal_uart.c:1727:13:HAL_UART_RxHalfCpltCallback	0	static
31
+stm32f1xx_hal_uart.c:2095:13:UART_DMARxHalfCplt	8	static
32
+stm32f1xx_hal_uart.c:1742:14:HAL_UART_ErrorCallback	0	static
33
+stm32f1xx_hal_uart.c:2106:13:UART_DMAError	8	static
34
+stm32f1xx_hal_uart.c:1555:6:HAL_UART_IRQHandler	16	static
35
+stm32f1xx_hal_uart.c:2204:13:UART_DMAAbortOnError	8	static
36
+stm32f1xx_hal_uart.c:1756:13:HAL_UART_AbortCpltCallback	0	static
37
+stm32f1xx_hal_uart.c:1310:19:HAL_UART_Abort_IT	8	static
38
+stm32f1xx_hal_uart.c:2259:13:UART_DMARxAbortCallback	8	static
39
+stm32f1xx_hal_uart.c:2221:13:UART_DMATxAbortCallback	8	static
40
+stm32f1xx_hal_uart.c:1770:13:HAL_UART_AbortTransmitCpltCallback	0	static
41
+stm32f1xx_hal_uart.c:1432:19:HAL_UART_AbortTransmit_IT	8	static
42
+stm32f1xx_hal_uart.c:2297:13:UART_DMATxOnlyAbortCallback	8	static
43
+stm32f1xx_hal_uart.c:1785:13:HAL_UART_AbortReceiveCpltCallback	0	static
44
+stm32f1xx_hal_uart.c:1497:19:HAL_UART_AbortReceive_IT	8	static
45
+stm32f1xx_hal_uart.c:2318:13:UART_DMARxOnlyAbortCallback	8	static
46
+stm32f1xx_hal_uart.c:1824:19:HAL_LIN_SendBreak	0	static
47
+stm32f1xx_hal_uart.c:1851:19:HAL_MultiProcessor_EnterMuteMode	0	static
48
+stm32f1xx_hal_uart.c:1878:19:HAL_MultiProcessor_ExitMuteMode	0	static
49
+stm32f1xx_hal_uart.c:1905:19:HAL_HalfDuplex_EnableTransmitter	0	static
50
+stm32f1xx_hal_uart.c:1940:19:HAL_HalfDuplex_EnableReceiver	0	static
51
+stm32f1xx_hal_uart.c:1997:23:HAL_UART_GetState	0	static
52
+stm32f1xx_hal_uart.c:2012:10:HAL_UART_GetError	0	static

二进制
Debug/STM32F100_LoraTestBootloader.elf


+ 778 - 0
Debug/STM32F100_LoraTestBootloader.hex

@@ -0,0 +1,778 @@
1
+:020000040800F2
2
+:1000000000100020991C00081D1C00081F1C00087F
3
+:10001000211C0008231C0008251C0008000000000B
4
+:10002000000000000000000000000000271C000885
5
+:10003000291C0008000000002B1C00082D1C0008D3
6
+:10004000E11C0008E11C0008E11C0008E11C00089C
7
+:10005000E11C0008E11C0008E11C0008E11C00088C
8
+:10006000E11C0008E11C0008E11C0008E11C00087C
9
+:10007000E11C0008E11C0008E11C0008E11C00086C
10
+:10008000E11C0008E11C0008E11C00080000000061
11
+:10009000000000000000000000000000E11C00085B
12
+:1000A000E11C0008E11C0008E11C0008E11C00083C
13
+:1000B000E11C0008E11C0008E11C0008E11C00082C
14
+:1000C000E11C00080000000000000000E11C000826
15
+:1000D000E11C0008311C0008E11C0008E11C0008BC
16
+:1000E000E11C0008E11C0008E11C00080000000001
17
+:1000F0000000000000000000000000000000000000
18
+:1001000000000000000000000000000000000000EF
19
+:100110000000000000000000E11C00083D1C000879
20
+:1001200000000000000000000000000000000000CF
21
+:1001300000000000000000000000000000000000BF
22
+:1001400000000000000000000000000000000000AF
23
+:10015000000000000000000000000000000000009F
24
+:10016000000000000000000000000000000000008F
25
+:10017000000000000000000000000000000000007F
26
+:10018000000000000000000000000000000000006F
27
+:10019000000000000000000000000000000000005F
28
+:1001A000000000000000000000000000000000004F
29
+:1001B000000000000000000000000000000000003F
30
+:1001C0000000000000000000000000005FF808F1DF
31
+:1001D00010B5054C237833B9044B13B10448AFF381
32
+:1001E00000800123237010BD780000200000000073
33
+:1001F000F42D000808B5034B1BB103490348AFF3C6
34
+:10020000008008BD000000007C000020F42D0008E4
35
+:10021000D0400B1CD1409C46203AD3401843524258
36
+:10022000634693401843704738B50E4B054618781F
37
+:100230004FF47A73B3FBF0F30B4A1068B0FBF3F0A2
38
+:1002400000F098F8044658B90F2D09D802462946FF
39
+:100250004FF0FF3000F04EF8044B20461D6038BDD3
40
+:10026000012038BD000000200C0000200400002008
41
+:1002700008B5032000F02CF80020FFF7D5FF01F0AF
42
+:100280005BFC002008BD0000034A044B11681B788A
43
+:100290000B441360704700BFD00000200000002016
44
+:1002A000014B1868704700BFD000002038B50446E5
45
+:1002B000FFF7F6FF0546631C1EBF044B1B78E418CE
46
+:1002C000FFF7EEFF401B8442FAD838BD0000002043
47
+:1002D000074A0002D36800F4E06023F4E0631B04E3
48
+:1002E0001B0C43F0BF6343F400330343D3607047F8
49
+:1002F00000ED00E0174B30B5DC68C4F30224C4F114
50
+:100300000703251D042B28BF0423062D4FF00105EC
51
+:1003100098BF002405FA03F303F1FF3388BF033CC1
52
+:100320001940A14005FA04F4013C2240002842EAA9
53
+:1003300001024FEA0212AFBF00F16040064B00F02D
54
+:100340000F00D2B2A5BFD2B200F561401A5480F8B6
55
+:10035000002330BD00ED00E014ED00E00123420970
56
+:1003600000F01F0003FA00F0014B43F82200704731
57
+:1003700000E100E00138B0F1807F0AD2F021064BA5
58
+:10038000064A586082F823100020072298601A60FD
59
+:1003900070470120704700BF10E000E000ED00E072
60
+:1003A00090F8213010B5022B03D004238363012081
61
+:1003B00010BD03681A6822F00E021A601A6822F053
62
+:1003C00001021A60184A93421FD0143293421ED081
63
+:1003D000143293421DD0143293421DD014329342F2
64
+:1003E0001DD0143293420CBF4FF480134FF0807332
65
+:1003F0000E4A00245360012380F82130436B80F8BB
66
+:1004000020407BB19847204610BD0123F0E7102320
67
+:10041000EEE74FF48073EBE74FF48053E8E74FF4D7
68
+:100420008033E5E7184610BD080002400000024096
69
+:10043000114AD36813F0100305D01049CB6943F07B
70
+:100440000203CB611023D268500706D50B4943F055
71
+:100450000403CA6942F00102CA61074AD169C907A7
72
+:1004600008D50648C16941F00401C161D16921F094
73
+:100470000101D161D360704700200240D800002004
74
+:10048000064B186910F0800007D0054A5A6002F147
75
+:1004900088325A601869C0F3C010704700200240CB
76
+:1004A00023016745034A0020136943F08003136169
77
+:1004B000704700BF00200240F8B50646FFF7F0FE87
78
+:1004C000114C07462546E368D80712D4E36899061D
79
+:1004D00044BF2023E360EB68DA0606D4EB69DB0750
80
+:1004E00003D4E86810F0040002D0FFF7A1FF012058
81
+:1004F000F8BD731CE7D00EB90320F8BDFFF7D0FE9E
82
+:10050000C01B8642DFD2F7E7002002402DE9F84FFA
83
+:100510001F4C9946237E0546012B0F46904633D04B
84
+:1005200001234CF250302376FFF7C6FF40BB012D6C
85
+:1005300003D0022D0CBF022504250026B246DFF8A9
86
+:1005400054B0320140464946FFF762FEC4F81CA091
87
+:10055000DBF8103080B243F00103CBF8103027F8FD
88
+:1005600016004CF25030FFF7A7FFDBF8103023F0F5
89
+:100570000103CBF8103018B90136F3B29D42E0D830
90
+:1005800000232376BDE8F88F0220BDE8F88F00BF76
91
+:10059000D8000020002002400022064BDA61064B02
92
+:1005A0001A6942F004021A611A6942F040021A61A3
93
+:1005B000704700BFD8000020002002400022064BF8
94
+:1005C000DA61064B1A6942F002021A6158611A692F
95
+:1005D00042F040021A617047D8000020002002401B
96
+:1005E0002DE9F041234D07462B7E8846012B3DD057
97
+:1005F000012403682C76022B4CF2503013D1FFF704
98
+:100600005BFF20B1012000232B76BDE8F081FFF7CE
99
+:10061000C3FF4CF25030FFF74FFF174A136923F026
100
+:1006200004031361EFE7FFF747FF0028EAD14FF01B
101
+:10063000FF33C8F800302046BE680F4CFA68BB682C
102
+:1006400003EB82239E42DED23046FFF7B7FF4CF227
103
+:100650005030FFF731FF236923F00203236110B10B
104
+:10066000C8F80060CFE706F58066E7E70220BDE83E
105
+:10067000F08100BFD8000020002002402DE9F74F94
106
+:1006800000221646654BDFF8A4E1DFF8A4C14FF065
107
+:1006900001080C6808FA06F808EA0404A0457FD1AE
108
+:1006A0004D68122D00F0AF8000F28880022D00F01E
109
+:1006B000A7807CD8002D00F08E80012D00F09E8058
110
+:1006C0004FF00F09FF2C93BF824606F18045083D8D
111
+:1006D000D0F800B092BFB500D0F804B0AD0009FA70
112
+:1006E00005F82BEA080802FA05F588BF00F1040AAC
113
+:1006F00048EA0505CAF80050D1F804A01AF0805F56
114
+:100700004ED0474D464FAD6926F0030845F0010530
115
+:10071000BD61BD6908F1804805F00105019508F546
116
+:10072000803806F0030B019D4FEA8B0BD8F8085078
117
+:1007300009FA0BF925EA09093A4DA84268D005F5EE
118
+:100740008065A84266D005F58065A84264D005F5AD
119
+:100750008065A8420CBF0325042505FA0BF545EA80
120
+:100760000905C8F808501D681AF4803F14BF2543D6
121
+:10077000A5431D605D681AF4003F14BF2543A543DF
122
+:100780005D609D681AF4801F14BF2543A5439D60DA
123
+:10079000DD681AF4001F14BF2C4325EA0404DC6052
124
+:1007A0000136102E7FF473AF03B0BDE8F08F032D38
125
+:1007B00022D0112D84D1CA68043281E71A4FBD427C
126
+:1007C00009D012D8DFF86C904D4504D009F5803976
127
+:1007D0004D457FF475AF8A68C2B1012A0CBFC0F8DD
128
+:1007E0001080C0F8148008226AE77545F3D065458B
129
+:1007F000F1D0DFF84490EBE7002261E7CA685FE7D9
130
+:10080000CA6808325CE7CA680C3259E7042257E725
131
+:100810000025A2E70125A0E702259EE7000401408C
132
+:1008200000100240000801400000211000003110BB
133
+:100830000000321000001110000022100AB1016106
134
+:1008400070470904FBE7C3685940C1607047000066
135
+:1008500003682DE9F341DB07054610D42B689F0799
136
+:100860005ED42B68190700F195802B685A0700F1B8
137
+:10087000BF80EA69002A40F02D81002014E0904CEE
138
+:10088000636803F00C03042B07D0636803F00C03C8
139
+:10089000082B0CD16368DE0309D523689C03DDD5E2
140
+:1008A0006B68002BDAD1012002B0BDE8F0816B68E3
141
+:1008B000B3F5803F10D1236843F480332360FFF702
142
+:1008C000EFFC064623689803C8D4FFF7E9FC801BB9
143
+:1008D0006428F7D90320E7E79BB9236823F4803322
144
+:1008E0002360236823F480232360FFF7D9FC0646A6
145
+:1008F00023689903B2D5FFF7D3FC801B6428F7D98E
146
+:10090000E8E7B3F5A02F236803D143F480232360E5
147
+:10091000D1E723F480332360236823F48023CDE7D9
148
+:10092000674C636813F00C0F07D0636803F00C0387
149
+:10093000082B10D16368DA030DD423689B0702D516
150
+:100940002B69012BAFD123686A6923F0F80343EACE
151
+:10095000C203236085E72A695A4B6AB101221A60F3
152
+:10096000FFF79EFC064623689F07ECD4FFF798FC30
153
+:10097000801B0228F7D9ADE71A60FFF791FC064605
154
+:10098000236898077FF56DAFFFF78AFC801B02286C
155
+:10099000F6D99FE7AA694A4C4B4BDAB101221A609B
156
+:1009A000FFF77EFC0646636A9B070DD54FF4FA52AB
157
+:1009B000464B1B68B3FBF2F3019300BF019B5A1E29
158
+:1009C0000192002BF9D150E7FFF76AFC801B022847
159
+:1009D000E9D97FE71A60FFF763FC0646636A9F0761
160
+:1009E0007FF543AFFFF75CFC801B0228F6D971E767
161
+:1009F000334CE369D80024D40127E36943F08053E2
162
+:100A0000E361E36903F080530093009B304E336849
163
+:100A1000D90518D5EB68012B26D1236A43F00103D1
164
+:100A20002362FFF73DFC41F288368046236A9B072C
165
+:100A30003FD5002F3FF41DAFE36923F08053E361FE
166
+:100A400017E70027E2E7336843F480733360FFF76A
167
+:100A500027FC80463368DA05DCD4FFF721FCA0EBE5
168
+:100A600008006428F6D935E7ABB9236A41F2883823
169
+:100A700023F001032362236A23F004032362FFF7B8
170
+:100A80000FFC0646236A9807D3D5FFF709FC801BA5
171
+:100A90004045F7D91EE7052B236A03D143F0040331
172
+:100AA0002362BAE723F001032362236A23F00403DD
173
+:100AB000B6E7FFF7F5FBA0EB0800B042B6D909E7AF
174
+:100AC0000010024000004242800442420C0000201C
175
+:100AD00000700040224C636803F00C03082B3FF4C5
176
+:100AE000E2AE00231F4E022A33602BD1FFF7D8FB62
177
+:100AF0000746236899011FD42B6AB3F5803F05D1BF
178
+:100B0000E26AA96822F00F020A43E262696A626837
179
+:100B10000B4322F474121343636001233360FFF725
180
+:100B2000BFFB054623689A013FF5A7AEFFF7B8FB68
181
+:100B3000401B0228F6D9CDE6FFF7B2FBC01B022806
182
+:100B4000D7D9C7E6FFF7ACFB054623689B017FF5C5
183
+:100B500094AEFFF7A5FB401B0228F6D9BAE600BF0A
184
+:100B6000001002406000424230B589B06C461B4B19
185
+:100B700003F11005224618685968083303C2AB42D6
186
+:100B80001446F7D1164B04AC03F110052246186841
187
+:100B90005968083303C2AB421446F7D111494B6878
188
+:100BA00003F00C02082A17D1C3F3834208A80244B9
189
+:100BB000DB0312F8202C0CD5CB6A0B4803F00F0393
190
+:100BC000504308AA134413F8103CB0FBF3F009B0EB
191
+:100BD00030BD06485043FAE70348F8E70C2E0008FA
192
+:100BE0001C2E00080010024000127A0000093D008F
193
+:100BF0000268F8B512F0020F05463C4C11D05707B9
194
+:100C000042BF636843F4E0636360160742BF6368F2
195
+:100C100043F4605363606368816823F0F0030B431F
196
+:100C20006360D0071AD42A68510756D4130706D533
197
+:100C300063682A6923F4605343EAC2036360FFF7E1
198
+:100C400093FF63682A4AC3F30313D35CD840294B4C
199
+:100C500018600020FFF7E8FA0020F8BD68682368F4
200
+:100C6000012802D19A0305D4F8BD02281BD113F044
201
+:100C7000007F39D0636841F2883723F003031843BB
202
+:100C80006060FFF70DFB6B680646012B0ED16368B1
203
+:100C900003F00C03042BC6D0FFF702FB801BB84205
204
+:100CA000F5D90320F8BD13F0020FE2E7022B0FD1B4
205
+:100CB000636803F00C03082BB5D0FFF7F1FA801B33
206
+:100CC000B842F5D9EDE7FFF7EBFA801BB842E8D858
207
+:100CD000636813F00C0FF6D1A5E76368E96823F4A5
208
+:100CE000E0630B436360A1E70120F8BD0010024000
209
+:100CF0001A2F00080C000020044B054A5B68C3F360
210
+:100D00000223D35C034A1068D840704700100240A9
211
+:100D10002A2F00080C000020044B054A5B68C3F32F
212
+:100D2000C223D35C034A1068D840704700100240C9
213
+:100D30002A2F00080C00002003680020DA6842F027
214
+:100D40000102DA601A6842F001021A6070477047C7
215
+:100D5000704770477047036810B51A6904469107D9
216
+:100D60000ED5DA6892070BD56FF002021A610122E4
217
+:100D70009B6902779B0777D0FFF7EAFF0023237771
218
+:100D800023681A69500710D5DA6851070DD56FF03E
219
+:100D900004021A6102229B69227713F4407F2046E5
220
+:100DA00068D0FFF7D5FF0023237723681A6912075D
221
+:100DB0000FD5DA6810070CD56FF008021A6104220B
222
+:100DC000DB692277990720465AD0FFF7C1FF00233D
223
+:100DD000237723681A69D20610D5DA68D0060DD5B4
224
+:100DE0006FF010021A610822DB69227713F4407F4A
225
+:100DF00020464BD0FFF7ACFF0023237723681A6906
226
+:100E0000D10708D5DA68D20705D56FF00102204670
227
+:100E10001A6100F0F1FB23681A69100608D5DA6838
228
+:100E2000110605D56FF0800220461A6100F0C5F862
229
+:100E300023681A69520608D5DA68500605D56FF09E
230
+:100E4000400220461A61FFF785FF23681A69910660
231
+:100E500022D5DA6892061FD56FF020022046BDE841
232
+:100E600010401A6100F0A8B8FFF771FF2046FFF7A5
233
+:100E700070FF83E7FFF76BFF2046FFF76AFF92E7FB
234
+:100E8000FFF765FF2046FFF764FFA0E7FFF75FFF6E
235
+:100E90002046FFF75EFFAFE710BD0000264A03685B
236
+:100EA00090420AD0B0F1804F07D0A2F59432904220
237
+:100EB00003D002F58062904211D14A6823F070039A
238
+:100EC00013431D4A904215D0B0F1804F12D0A2F5C5
239
+:100ED000943290420ED002F5806290420AD0174AB6
240
+:100EE000904207D002F58062904203D002F5806202
241
+:100EF000904203D1CA6823F4407313434A6923F034
242
+:100F00008003134303608B68C3620B6883620A4BE0
243
+:100F100098420BD003F5A053984207D003F58063A5
244
+:100F2000984203D003F58063984201D10B690363B3
245
+:100F300001234361704700BF002C01400040014085
246
+:100F400010B50446A0B190F83D3003F0FF021BB984
247
+:100F500080F83C2000F012FE0223206884F83D3027
248
+:100F6000211DFFF79BFF0123002084F83D3010BDB9
249
+:100F7000012010BD90F83C3010B5012B4FF002035A
250
+:100F800018D080F83D3003680C685A68496822F030
251
+:100F900070025A605A6822435A609A6822F08002AE
252
+:100FA0009A609A680A439A60012380F83D300023D2
253
+:100FB00080F83C30184610BD704770470368DA6807
254
+:100FC00022F49072DA605A6922F001025A612023F9
255
+:100FD00080F83A30704700002DE9F04781460568F7
256
+:100FE000C2682B69C16923F4405313432B618368A2
257
+:100FF0000069EA680343D9F8140022F41642034357
258
+:1010000022F00C020B431343EB606B69D9F81820F4
259
+:1010100023F440731343B1F5004F6B617E4B7FD1D6
260
+:101020009D424FF0190447D1FFF776FE04FB00F311
261
+:10103000D9F804704FF064087F00B3FBF7F3B3FBFB
262
+:10104000F8F31F01FFF768FE6043D9F804305B0036
263
+:10105000B0FBF3F6FFF760FE6043D9F804305B00A5
264
+:10106000B0FBF3F3B3FBF8F308FB1363DB0032339D
265
+:10107000B3FBF8F35B0003F4F876FFF74DFE604333
266
+:10108000D9F804205200B0FBF2FAFFF745FE6043A6
267
+:10109000D9F804305B00B0FBF3F3B3FBF8F308FBC3
268
+:1010A00013A3DB003233B3FBF8F303F007033B4435
269
+:1010B0003344AB60BDE8F087FFF71EFE04FB00F38E
270
+:1010C000D9F804704FF064087F00B3FBF7F3B3FB6B
271
+:1010D000F8F31F01FFF710FE6043D9F804305B00FE
272
+:1010E000B0FBF3F6FFF708FE6043D9F804305B006D
273
+:1010F000B0FBF3F3B3FBF8F308FB1363DB0032330D
274
+:10110000B3FBF8F35B0003F4F876FFF7F5FD6043FB
275
+:10111000D9F804205200B0FBF2FAFFF7EDFDB6E774
276
+:101120009D424FF0190443D1FFF7F6FD04FB00F395
277
+:10113000D9F804604FF06408B600B3FBF6F3B3FBD4
278
+:10114000F8F31E01FFF7E8FD6043D9F804309B0077
279
+:10115000B0FBF3F7FFF7E0FD6043D9F804309B00E4
280
+:10116000B0FBF3F3B3FBF8F308FB13731B0132334B
281
+:10117000B3FBF8F303F0F007FFF7CEFD6043D9F8B7
282
+:1011800004209200B0FBF2FAFFF7C6FD6043D9F8E5
283
+:1011900004309B00B0FBF3F3B3FBF8F308FB13A39D
284
+:1011A0001B013233B3FBF8F303F00F033B437FE73C
285
+:1011B000FFF7A2FD04FB00F3D9F804604FF06408C8
286
+:1011C000B600B3FBF6F3B3FBF8F31E01FFF794FD93
287
+:1011D0006043D9F804309B00B0FBF3F7FFF78CFDB8
288
+:1011E0006043D9F804309B00B0FBF3F3B3FBF8F392
289
+:1011F00008FB13731B013233B3FBF8F303F0F00762
290
+:10120000FFF77AFD6043D9F804209200B0FBF2FAB0
291
+:10121000FFF772FDBAE700BF00380140F8B5044699
292
+:101220000E4617461D4621680B6836EA030301D1B6
293
+:101230000020F8BD6B1CF7D095B923680320DA684D
294
+:1012400022F4D072DA605A6922F001025A61202336
295
+:1012500084F8393084F83A30002384F83830F8BD07
296
+:10126000FFF71EF8C01B8542DDD2E6E710B5044645
297
+:1012700040B390F8393003F0FF021BB980F83820F2
298
+:1012800000F090FC2423226884F83930D36820468B
299
+:1012900023F40053D360FFF79FFE236800201A69F0
300
+:1012A00022F490421A615A6922F02A025A61DA68DD
301
+:1012B00042F40052DA602023E06384F8393084F885
302
+:1012C0003A3010BD012010BD2DE9F0411F4690F8C5
303
+:1012D00039300446202B0D4690464ED1002949D086
304
+:1012E000002A47D090F83830012B46D0012380F8EF
305
+:1012F00038300023C363212380F83930FEF7D0FF54
306
+:101300000646A4F82480A4F82680E38C9BB26BB92F
307
+:101310003B46324640212046FFF780FFA8B92023F4
308
+:1013200084F8380084F83930BDE8F081E38C324627
309
+:10133000013B9BB2E384A3688021B3F5805F204624
310
+:101340003B460ED1FFF76AFF10B10320BDE8F081E4
311
+:101350002B882268C3F308035360236943B902351D
312
+:10136000D3E7FFF75BFF0028EFD123682A785A60A4
313
+:101370000135CAE70120BDE8F0810220BDE8F08117
314
+:1013800090F83A30202B20D1E9B1E2B190F8383012
315
+:10139000012B1AD0C285828500232222C36380F8E4
316
+:1013A0003A2002688162D16880F8383041F4807157
317
+:1013B000D1605169184641F001015161D16841F095
318
+:1013C0002001D160704701207047022070477047AC
319
+:1013D00090F83A3010B5222B36D183680169B3F505
320
+:1013E000805F0268836A23D15268E9B9C2F30802B8
321
+:1013F00023F8022B8362C48D013CA4B2C4858CB94E
322
+:101400000368DA6822F02002DA60DA6822F4807277
323
+:10141000DA605A6922F001025A61202380F83A30DA
324
+:1014200000F0CAF8002010BDD2B223F8012BE1E78A
325
+:1014300021B9591C526881621A70DCE75268591C44
326
+:10144000816202F07F02F7E7022010BD70470000C2
327
+:10145000036870B51A6804461607D9685D6907D134
328
+:1014600096065AD58D0658D5BDE87040FFF7B0BF37
329
+:1014700015F0010502D111F4907F4ED0D30705D5A8
330
+:10148000CE0542BFE36B43F00103E363500704D58D
331
+:101490001DB1E36B43F00203E363930704D51DB171
332
+:1014A000E36B43F00403E363160704D51DB1E36B5C
333
+:1014B00043F00803E363E36B002B66D0950604D585
334
+:1014C000880602D52046FFF783FF236820465D6922
335
+:1014D000E26B110702D415F040051AD0FFF76EFD3C
336
+:1014E00023685A69520610D55A69606B22F040028F
337
+:1014F0005A6150B1254B4363FEF752FF002844D098
338
+:10150000606BBDE87040436B18472046FFF79EFFB5
339
+:1015100070BDFFF79BFFE56370BD160627D50D066E
340
+:1015200025D594F83920212A2FD1A268B2F5805F01
341
+:10153000226A17D11188C1F308015960216979B96C
342
+:1015400002322262E28C013A92B2E284EAB9DA68AB
343
+:1015500022F08002DA60DA6842F04002DA6070BDA0
344
+:101560000132EEE7511C216212785A60EAE7500618
345
+:101570000BD54A0609D5DA68204622F04002DA6027
346
+:10158000202384F83930FFF722FF70BD9115000841
347
+:1015900008B50023406AC385C384FFF757FF08BD21
348
+:1015A00008B5FEF76DFF3422024BDA60BDE8084053
349
+:1015B000FEF778BF0020024002680A4B9A420FD122
350
+:1015C000094A0A49136808780949C8540133632B4A
351
+:1015D00088BF00230549136006480122FFF7D0BEEB
352
+:1015E000704700BF00380140B8000020C000002054
353
+:1015F00088010020FC0000200268084B9A420BD1B1
354
+:10160000074A136801331360064A136801331360F5
355
+:10161000054A136801331360704700BF001400408F
356
+:10162000B0000020A8000020A40000200A460A23E1
357
+:1016300001460148FFF748BEFC00002010B51446E3
358
+:101640000A230248FFF740FE204610BDFC000020A0
359
+:101650002DE9F041002407462646104DDFF8408072
360
+:10166000BB78023B9C4202DB3046BDE8F0813B196F
361
+:10167000DA781B79296802EB032292B20023012059
362
+:10168000FEF744FF18B1404600F0CCFB01262B6862
363
+:10169000023402332B60E4B2E2E700BF080000200E
364
+:1016A0006C2E0008002373B5164D174C2B60174B9A
365
+:1016B0000646AB603F23EB60E36923F02003E36160
366
+:1016C000FEF7DEFE124B1A784AB90122114928466C
367
+:1016D0001A70FEF785FF10B10F4800F0A3FB3046EB
368
+:1016E000FFF7B6FF0546FEF7DDFE2846E36943F047
369
+:1016F0002003E361E36903F020030193019B02B03F
370
+:1017000070BD00BF9400002000100240004000089F
371
+:10171000B4000020AC000020782E000870B5064C04
372
+:10172000064E074D227821463046013400F006FB74
373
+:10173000AC42F7D170BD00BF004000085E2E00082B
374
+:1017400010400008B0B50D4A00AFD3690C4823F033
375
+:101750002003D36100F066FB0A4B0B4A1B680B4C5D
376
+:101760000B481360236000F05DFB0A4B1B6883F39A
377
+:1017700008882368BD46BDE8B04018470010024005
378
+:10178000872E0008044000083C010020840100204E
379
+:10179000992E00080040000873B50446254BA17837
380
+:1017A00018681B7900908DF8043063185A78601C13
381
+:1017B00000F0A5F901280BD000231F4EA2785D1C74
382
+:1017C0000232DBB29A422FDA1C4800F02BFB0CE00D
383
+:1017D00011238DF801306378DD2B01D0EE2B07D17A
384
+:1017E0002046FFF75FFF012802D122238DF8013048
385
+:1017F0009DF802100DF1010000F066F963788DF894
386
+:101800000300EE2B08D00A2B06D09DF80210684684
387
+:101810000331C9B2FFF70AFF6378EE2B02D1084803
388
+:1018200000F000FB02B070BDE15C304600F086FACB
389
+:101830002B46C3E72C2E0008362E00083C2E00084D
390
+:101840004D2E000810B590B02822002106A800F007
391
+:101850006DFA1422002101A800F068FA01230A930E
392
+:10186000102302240B934FF4002306A80F93069431
393
+:101870000D94FEF7EDFF0F23002101934FF48063D9
394
+:1018800001A80294039104930591FFF7B1F910B0F8
395
+:1018900010BD00002DE9F047C8B008AFFF220021BD
396
+:1018A000384600F043FA734B002418681B79029005
397
+:1018B0008DF80C30FEF7DCFCFFF7C4FF102200218E
398
+:1018C0000DEB020000F032FA6B4B4FF400419A69C5
399
+:1018D0006A4842F010029A619A694FF0010802F0DA
400
+:1018E00010020092009A9A69654D42F004029A61D2
401
+:1018F0009B69002203F004030193019BFEF79EFF06
402
+:101900004FF400430493022304A95C48CDF81480EB
403
+:1019100007930694FEF7B2FE4FF4E133594A284686
404
+:1019200085E80C000C23AC606B61EC602C61AC6151
405
+:10193000EC61FFF79BFC40F23F63534E5349304646
406
+:1019400086E80A000923B460F360B4610494059446
407
+:10195000FFF7F6FA04A9304604940594FFF70AFB52
408
+:10196000224621462520FEF7C5FC2520FEF7F6FC81
409
+:10197000224621463720FEF7BDFC3720FEF7EEFC5D
410
+:101980003046FFF7D9F9424641492846FFF7F8FCAF
411
+:10199000404B21461B68404E986800F04BFA3F4888
412
+:1019A00000F040FA3E4800F03DFA3E4A3E493F48CA
413
+:1019B00000F0C4F93E4800F035FA384800F032FA39
414
+:1019C000FFF7EEFDFFF7AAFE9DF80A100DF10900E2
415
+:1019D00000F07AF88DF80B006420FEF767FC9DF8A4
416
+:1019E0000A1002A80331C9B2FFF720FE2546B1460E
417
+:1019F000DFF8888040F6B83332689A4201D9FFF7A1
418
+:101A0000A1FE2C4A2C4B11681B6899421ED02B4C0E
419
+:101A1000481C615C6B1C79550021DBB21D466328B4
420
+:101A2000106088BF1160264A1160254B1B68642B2B
421
+:101A30001ED900253846FFF7AFFE64220021384644
422
+:101A400000F074F92C46C9F8005001E0002CECD1EC
423
+:101A5000DFF870A0DAF80030B3F5FA7FCAD94FF496
424
+:101A600000414046FEF7EFFE0023CAF80030C1E710
425
+:101A70000124EDE7312E0008001002400010014063
426
+:101A8000FC00002000380140440100200014004008
427
+:101A9000C000002010000020A40000209F2E00089D
428
+:101AA000C92E0008D62E0008DF2E0008EB2E0008F5
429
+:101AB000FC2E0008BC000020B80000208801002097
430
+:101AC000B0000020A800002010B5FF230446221A11
431
+:101AD000D2B2914201D8184610BD14F8012B5340E0
432
+:101AE000082213F0800F02F1FF324FEA430318BFC0
433
+:101AF00083F0310312F0FF02DBB2F2D1E7E730B539
434
+:101B0000FF2305462C1AE4B2A14203D89B1A58427F
435
+:101B1000584130BD15F8014B6340082413F0800F85
436
+:101B200004F1FF344FEA430318BF83F0310314F08C
437
+:101B3000FF04DBB2F2D1E5E70E4B82B09A6942F0C6
438
+:101B400001029A619A6902F001020092009ADA6930
439
+:101B500042F08052DA61DB69074A03F08053019357
440
+:101B6000019B536823F0E06343F08063536002B04D
441
+:101B7000704700BF00100240000001400268084B9F
442
+:101B800082B09A420AD103F5FE33DA6942F02002AC
443
+:101B9000DA61DB6903F020030193019B02B0704717
444
+:101BA0000014004010B5044686B01022002102A89F
445
+:101BB00000F0BCF82268174B9A4228D103F558432D
446
+:101BC0009A6902A942F480429A619A69124802F421
447
+:101BD00080420092009A9A6942F004029A619B69DD
448
+:101BE00003F004030193019B4FF40073029302235B
449
+:101BF000039303230593FEF741FD4FF480630293A3
450
+:101C0000002302A9044803930493FEF737FD06B0AE
451
+:101C100010BD00BF00380140000801407047FEE7DA
452
+:101C2000FEE7FEE7FEE7704770477047FEF72CBB04
453
+:101C30000148FFF70DBC00BFFC0000200148FFF782
454
+:101C40008AB800BF44010020104B1A6842F001021C
455
+:101C50001A6059680E4A0A405A601A6822F0847263
456
+:101C600022F480321A601A6822F480221A605A68BC
457
+:101C700022F4FE025A604FF41F029A600022DA62D8
458
+:101C80004FF00062034B9A60704700BF00100240A3
459
+:101C90000000FFF800ED00E0002103E00B4B5B5873
460
+:101CA000435004310A480B4B42189A42F6D30A4A71
461
+:101CB00002E0002342F8043B084B9A42F9D3FFF7B5
462
+:101CC000C3FF00F00FF8FFF7E5FD7047D42F0008C1
463
+:101CD0000000002074000020780000208C0200200A
464
+:101CE000FEE7000070B500250C4E0D4CA41BA4109F
465
+:101CF000A54209D101F07EF800250A4E0A4CA41B2A
466
+:101D0000A410A54205D170BD56F82530984701357D
467
+:101D1000EEE756F8253098470135F2E7CC2F00085A
468
+:101D2000CC2F0008CC2F0008D02F00080346024417
469
+:101D3000934200D1704703F8011BF9E70FB40A4B37
470
+:101D400013B51C6824B1A36913B9204600F0DAFA70
471
+:101D500005AB049AA1682046019300F09BFC02B0F9
472
+:101D6000BDE8104004B070471000002070B50E466A
473
+:101D7000054618B183690BB900F0C4FAAB69AC68C9
474
+:101D800013B9284600F0BEFA234B9C4217D16C6869
475
+:101D9000A3891B071DD52369DBB1013EA36816F893
476
+:101DA000011F013BA360E9B9002B2EDA22460A216C
477
+:101DB000284600F0F5F8013011D00A2070BD174B0D
478
+:101DC0009C4201D1AC68E3E7154B9C4208BFEC682C
479
+:101DD000DEE72146284600F035F90028DDD04FF037
480
+:101DE000FF3070BD002B04DAA269934206DB0A299A
481
+:101DF00004D023685A1C22601970CFE72246284677
482
+:101E000000F0CEF80130C9D1E9E70A2023685A1C56
483
+:101E10002260187070BD00BF582F0008782F00088E
484
+:101E2000382F0008024B01461868FFF79FBF00BF1C
485
+:101E30001000002000294FF480630CBF0222002212
486
+:101E400000F000B82DE9F7431D46514B04461E68CB
487
+:101E50000F46904626B1B36913B9304600F052FAE6
488
+:101E60004C4B9C4252D17468B8F1020F06D0B8F1C5
489
+:101E7000010F00F28980002DC0F286802146304695
490
+:101E800000F0D6F9616B41B104F14403994202D0EC
491
+:101E9000304600F02DFB002363630023A3616360E1
492
+:101EA000A3891B0603D52169304600F021FBA389D5
493
+:101EB000B8F1020F23F44A6323F00303A3815DD03A
494
+:101EC00001AB6A462146304600F0A6FAA3891843C2
495
+:101ED000A0812DBB009D284600F002FB074600288C
496
+:101EE0004ED1DDF80090A9453CD14FF0FF30A389D9
497
+:101EF00043F00203A3810023A36004F1470323609E
498
+:101F000023610123636103B0BDE8F083224B9C424F
499
+:101F100001D1B468A8E7214B9C4208BFF468A3E74D
500
+:101F2000002FD8D0B36913B9304600F0EBF9B8F1FF
501
+:101F3000010F08BFA389276004BF43F00103A381F9
502
+:101F4000A389276113F0080065611BD013F001001D
503
+:101F50004FF000031FBF6D42A360A561184608BF84
504
+:101F6000A560D0E7484600F0BBFA07460028BCD081
505
+:101F7000A3894D4643F08003A381D3E70020B6E751
506
+:101F8000A946F5E7A060BEE74FF0FF30BBE700BF12
507
+:101F900010000020582F0008782F0008382F000864
508
+:101FA000F8B50E461446054618B183690BB900F022
509
+:101FB000A9F9214B9C422AD16C68A369A360A3892B
510
+:101FC0001A072ED5236963B323692068F6B2C01AB5
511
+:101FD00063693746984204DB2146284600F028F919
512
+:101FE00028BBA3680130013BA36023685A1C226010
513
+:101FF0001E706369984204D0A389DB0719D50A2EA5
514
+:1020000017D12146284600F013F990B10FE00B4B91
515
+:102010009C4201D1AC68D0E7094B9C4208BFEC68F8
516
+:10202000CBE72146284600F00DF80028CCD04FF031
517
+:10203000FF373846F8BD00BF582F0008782F00083A
518
+:10204000382F0008324B70B51D6806460C4625B186
519
+:10205000AB6913B9284600F055F92E4B9C420FD1BD
520
+:102060006C68B4F90C309AB215072CD4D00611D490
521
+:102070000922326043F04003A3814FF0FF3070BD6E
522
+:10208000254B9C4201D1AC68EBE7244B9C4208BF36
523
+:10209000EC68E6E7510712D5616B41B104F14403E6
524
+:1020A000994202D0304600F023FA00236363A389EB
525
+:1020B00023F02403A3810023636023692360A389A1
526
+:1020C00043F00803A38123694BB9A38903F4207368
527
+:1020D000B3F5007F03D02146304600F0C1F9A28954
528
+:1020E00012F001030CD00023A36063695B42A3617B
529
+:1020F000236953B9B4F90C3013F08000BAD170BD24
530
+:10210000920758BF6369A360F2E70020F7E700BFBA
531
+:1021100010000020582F0008782F0008382F0008E2
532
+:102120008A892DE9F041054610070C465AD44B68C0
533
+:10213000002B05DC0B6C002B02DC0020BDE8F081DD
534
+:10214000E66A002EF9D0002312F480522F682B602B
535
+:1021500033D0606DA3895A0705D56368C01A636BD5
536
+:102160000BB1236CC01A00230246E66A216A284696
537
+:10217000B047431CA38906D129681D294BD82B4A97
538
+:10218000CA40D60747D5002262602269D90422607E
539
+:1021900004D5421C01D12B6803B96065616B2F60C7
540
+:1021A0000029CAD004F14403994202D0284600F025
541
+:1021B0009FF900206063BDE8F081216A0123284671
542
+:1021C000B047411CC6D12B68002BC3D01D2B01D0BA
543
+:1021D000162B01D12F60B0E7A38943F04003A38100
544
+:1021E000BDE8F0810F69002FA7D0930718BF002327
545
+:1021F0000E6808BF4B69A6EB07080F608B60B8F14B
546
+:10220000000F9ADD43463A46216A2846A66AB0473F
547
+:10221000002807DCA38943F04003A3814FF0FF307F
548
+:10222000BDE8F0810744A8EB0008E8E70100402082
549
+:1022300038B50B6905460C46DBB118B183690BB99B
550
+:1022400000F060F80C4B9C4209D16C68B4F90C307A
551
+:102250007BB121462846BDE83840FFF761BF074BF8
552
+:102260009C4201D1AC68F1E7054B9C4208BFEC6889
553
+:10227000ECE7002038BD00BF582F0008782F000879
554
+:10228000382F0008014900F0A9B800BF312200082A
555
+:10229000002310B504460360436083608181436678
556
+:1022A000C281036143618361194608225C30FFF7F4
557
+:1022B0003DFD054B24626362044BA362044BE36261
558
+:1022C000044B236310BD00BF112C0008332C000801
559
+:1022D0006B2C00088F2C000870B568254A1E5543EA
560
+:1022E0000E4605F1740100F04FF9044640B100219B
561
+:1022F00080E842000C30A06005F16802FFF716FD8F
562
+:10230000204670BD836910B5044633BB8364C36443
563
+:102310000365124B124A1B688262984204BF012374
564
+:10232000836100F01FF86060204600F01BF8A06099
565
+:10233000204600F017F80022E06004216068FFF7F3
566
+:10234000A7FF01220921A068FFF7A2FF02221221A4
567
+:10235000E068FFF79DFF0123A36110BD342F000843
568
+:1023600085220008F8B51C4B07461E68B36913B9EF
569
+:102370003046FFF7C7FF4836B4687368013B03D5A2
570
+:10238000336833B13668F7E7B4F90C506DB168348F
571
+:10239000F4E704213846FFF79FFF30600028F1D1B1
572
+:1023A0000C2304463B602046F8BD4FF6FF73E381E3
573
+:1023B00001236566A3812560A5606560256165616F
574
+:1023C000A5610822294604F15C00FFF7AFFC6563B4
575
+:1023D000A563A564E564E6E7342F00082DE9F8431A
576
+:1023E00080468946002600F1480414B93046BDE80D
577
+:1023F000F883A5686768013F01D52468F5E7AB89D4
578
+:10240000012B07D9B5F90E30013303D029464046D8
579
+:10241000C84706436835EEE770B50E46B1F90E10B1
580
+:1024200090B0002914461D4607DA00232B60B389BB
581
+:102430001A0610D44FF480630EE001AA00F04EFC9F
582
+:102440000028F2DB029A02F47042A2F500535A42CD
583
+:102450005A412A60EEE740230020236010B070BD8F
584
+:102460008B8973B59D0706460C4607D504F14703D3
585
+:10247000236023610123636102B070BD01AB6A4632
586
+:10248000FFF7CAFF00990546304600F07DF848B9CD
587
+:10249000B4F90C309A05EFD423F0030343F00203A0
588
+:1024A000A381E3E70D4BB362A389206043F080036F
589
+:1024B000A381009B20616361019B5BB1B4F90E10A5
590
+:1024C000304600F01DFC28B1A38923F0030343F03C
591
+:1024D0000103A381A3891D43A581CDE785220008BF
592
+:1024E000024B0146186800F04FB800BF10000020F2
593
+:1024F00038B50546002943D051F8043C0C1F002B89
594
+:10250000B8BFE41800F02CFC1E4A1368104633B91B
595
+:10251000636014602846BDE8384000F022BCA34246
596
+:102520000BD921686218934201BF1A685B68521880
597
+:10253000226063600460EDE713465A680AB1A24264
598
+:10254000FAD919685818A0420BD1206801445818CC
599
+:1025500082421960DED110685268014419605A60E5
600
+:10256000D8E702D90C232B60D4E7206821188A42CF
601
+:1025700001BF116852680918216062605C60C9E798
602
+:1025800038BD00BFC400002070B5CD1C25F0030588
603
+:1025900008350C2D38BF0C25002D064601DBA9425D
604
+:1025A00003D90C233360002070BD00F0D9FB234A0F
605
+:1025B0001468214691B9224C23681BB9304600F0BB
606
+:1025C00017FB20602946304600F012FB431C26D141
607
+:1025D0000C233046336000F0C4FBE4E70B685B1B60
608
+:1025E0001AD40B2B0FD90B60CC18CD50304600F00D
609
+:1025F000B8FB04F10B00231D20F00700C31A1BD009
610
+:102600005A42E25070BD8C420BBF63684B68136046
611
+:10261000636018BF0C46E9E70C464968CAE7C41C6A
612
+:1026200024F00304A04205D0211A304600F0E0FA5D
613
+:102630000130CDD02560D9E770BD00BFC4000020B7
614
+:10264000C8000020936810B4013B002B936008DAA7
615
+:102650009469A34202DBCBB20A2B02D110BCFFF774
616
+:102660009FBC1368581C10601970C8B210BC70472A
617
+:10267000F8B506460F461446D518AC4201D10020E5
618
+:1026800007E03A4614F8011B3046FFF7DBFF431C16
619
+:10269000F3D1F8BD2DE9F04F9DB00C4617460393DA
620
+:1026A000064618B183690BB9FFF72CFE7C4B9C42A0
621
+:1026B00057D17468A38918075DD52369002B5AD0B8
622
+:1026C0000023099320238DF8293030234FF0010B8C
623
+:1026D0008DF82A30B846454615F8013B002B55D1F8
624
+:1026E000B8EB070A0BD053463A4621463046FFF76F
625
+:1026F000BFFF013000F0C480099B5344099398F850
626
+:102700000030002B00F0BC8000234FF0FF32049318
627
+:102710000793059206938DF853301A930522297872
628
+:10272000604800F00FFB05F10108049B002831D13F
629
+:10273000D90644BF20228DF853201A0744BF2B220C
630
+:102740008DF853202A782A2A2CD000210A20079AB3
631
+:10275000A84698F800300135303B092B6DD971B38C
632
+:1027600026E0514B9C4201D1B468A3E74F4B9C42F9
633
+:1027700008BFF4689EE721463046FFF763FC002857
634
+:102780009ED04FF0FF301DB0BDE8F08F252BA7D0B5
635
+:10279000A846A0E7434A4546801A0BFA00F01843C2
636
+:1027A0000490BBE7039A111D12680391002A01DB14
637
+:1027B000079204E0524243F002030792049398F810
638
+:1027C00000302E2B10D198F8013008F101012A2B8E
639
+:1027D00037D1039B08F102081A1D1B680392002BD6
640
+:1027E000B8BF4FF0FF330593314D032298F8001026
641
+:1027F000284600F0A7FA40B14023401B03FA00F03E
642
+:10280000049B08F101080343049398F80010062282
643
+:10281000284808F101078DF8281000F093FA0028E5
644
+:1028200034D0254B03BB039B073323F00703083346
645
+:102830000393099B4B4409934CE700FB02320121AF
646
+:1028400086E700230A2518460593884698F8002055
647
+:102850000131303A092A03D9002BC5D00590C3E7CE
648
+:1028600005FB00200123F0E703AB00932246134B46
649
+:1028700004A93046AFF30080B0F1FF3F8146D8D1C4
650
+:10288000A3895B063FF57DAF09987CE703AB009316
651
+:1028900022460A4B04A9304600F08AF8ECE700BF54
652
+:1028A000582F0008982F0008782F0008382F0008AC
653
+:1028B0009E2F0008A22F00080000000071260008CB
654
+:1028C0002DE9F04791461F468A680B6906469342F8
655
+:1028D000B8BF1346C9F8003091F843200C46DDF824
656
+:1028E000208012B10133C9F800302368990642BF35
657
+:1028F000D9F800300233C9F80030256815F0060514
658
+:1029000007D104F1190AE368D9F800209B1A9D4207
659
+:102910002ADB94F843302268003318BF0123920663
660
+:102920002FD404F1430239463046C047013022D04B
661
+:102930002368E56803F00603042B18BF0025D9F8C7
662
+:1029400000204FF0000908BFAD1AA368226908BF34
663
+:1029500025EAE5759342C4BF9B1AED181A344D451C
664
+:102960001BD10020BDE8F08701235246394630468E
665
+:10297000C047013003D14FF0FF30BDE8F08701358B
666
+:10298000C1E73020E11881F843005A1C94F8451043
667
+:102990002244023382F84310C3E70123224639461A
668
+:1029A0003046C0470130E6D009F10109D7E7000001
669
+:1029B0002DE9F04317460A7E85B06E2A98460646F2
670
+:1029C0000C460C9B01F1430E00F0BC801AD8632A20
671
+:1029D0002ED00AD8002A00F0C880582A00F08A8039
672
+:1029E00004F1420584F842202AE0642A01D0692AD1
673
+:1029F000F6D121681A6811F0800F23D0111D1960DB
674
+:102A0000136827E0732A00F0B48008D86F2A2AD010
675
+:102A1000702AE5D10A6842F020020A6003E0752AB4
676
+:102A200021D0782ADCD178226F4984F8452064E0EF
677
+:102A30001A6801F14205111D1960136884F84230CB
678
+:102A40000123A3E011F0400F02F104011960D7D077
679
+:102A5000B2F90030002B03DA2D225B4284F84320C8
680
+:102A600062490A2217E02068196810F0800F03D02D
681
+:102A7000081D18600B6806E010F0400F01F104001B
682
+:102A80001860F7D00B886F2A14BF0A220822574912
683
+:102A9000002084F843006568002DA560C0F29C808A
684
+:102AA000206820F004002060002B3FD1002D40F072
685
+:102AB00095807546082A0BD12368DA0708D5236963
686
+:102AC00062689A42DEBF302305F8013C05F1FF350C
687
+:102AD000AEEB05032361CDF800803B4603AA2146F7
688
+:102AE0003046FFF7EDFE013055D14FF0FF3005B015
689
+:102AF000BDE8F08381F845203C492268186812F04F
690
+:102B0000800F00F104051D6001D0036802E0550646
691
+:102B1000FBD50388D00744BF42F0200222601BB9D6
692
+:102B2000226822F0200222601022B1E77546B3FB32
693
+:102B3000F2F002FB1033CB5C05F8013D03460028A0
694
+:102B4000F5D1B7E708681A6810F0800F496904D01A
695
+:102B5000101D18601368196007E010F0400F02F1B3
696
+:102B6000040018601368F6D01980002375462361AD
697
+:102B7000B1E71A68111D19601568002162682846BE
698
+:102B800000F0E0F808B1401B606063682361002337
699
+:102B900084F843309FE723692A4639463046C047C8
700
+:102BA0000130A2D023689B0707D5002504F119093D
701
+:102BB000E368039A9B1A9D4205DBE068039B9842F9
702
+:102BC000B8BF184693E701234A4639463046C04706
703
+:102BD00001308AD00135EBE7002BA7D10B7804F147
704
+:102BE000420584F8423065E7BA2F0008A92F000893
705
+:102BF00038B50023054C05460846236000F0ECF884
706
+:102C0000431C02D1236803B12B6038BD8802002029
707
+:102C100010B50C46B1F90E1000F0A4F80028ABBFB7
708
+:102C2000636DA3891B1823F48053ACBF6365A38134
709
+:102C300010BD2DE9F0411F468B890546DB050C468A
710
+:102C4000164605D502230022B1F90E1000F068F8EF
711
+:102C5000A389324623F48053A381B4F90E103B4676
712
+:102C60002846BDE8F04100F017B810B50C46B1F9A0
713
+:102C70000E1000F055F8431CA38915BF606523F4BE
714
+:102C8000805343F48053A38118BFA38110BDB1F9D1
715
+:102C90000E1000F013B8000038B50546084611467E
716
+:102CA0000022054C22601A46FEF7C8FC431C02D1E4
717
+:102CB000236803B12B6038BD8802002038B500239B
718
+:102CC000054C05460846236000F05EF8431C02D11F
719
+:102CD000236803B12B6038BD8802002038B500237B
720
+:102CE000064C054608461146236000F055F8431C83
721
+:102CF00002D1236803B12B6038BD00BF88020020D9
722
+:102D000038B50023054C05460846236000F04CF812
723
+:102D1000431C02D1236803B12B6038BD8802002018
724
+:102D200038B50546084611460022054C22601A4671
725
+:102D300000F042F8431C02D1236803B12B6038BD78
726
+:102D40008802002010B5C9B202449042034601D166
727
+:102D5000002010BD1C7801308C42F6D1184610BD01
728
+:102D60007047704738B50546084611460022054CA5
729
+:102D700022601A4600F028F8431C02D1236803B1F0
730
+:102D80002B6038BD880200205822024B4FF0FF30E4
731
+:102D90001A607047880200205822024B4FF0FF3023
732
+:102DA0001A607047880200205822024B00201A60E7
733
+:102DB000704700BF880200205822024B4FF0FF30BE
734
+:102DC0001A607047880200205822024B4FF0FF30F3
735
+:102DD0001A60704788020020044B0246196809B93E
736
+:102DE00003491960186802441A607047CC0000203B
737
+:102DF0008C020020F8B500BFF8BC08BC9E467047A6
738
+:0C2E0000F8B500BFF8BC08BC9E46704747
739
+:102E0C0002030405060708090A0B0C0D0E0F10101F
740
+:102E1C000102030405060708090A0B0C0D0E0F101E
741
+:102E2C00BE110200BEBE0B0200EB25303278200032
742
+:102E3C00436865636B2053756D206572726F7220E9
743
+:102E4C000075706461746520436F6D706C6574659A
744
+:102E5C00200025303878203A2025303258200A00BE
745
+:102E6C0048414C204E4F54204F4B2000457261730B
746
+:102E7C0065204661696C6564200D00626F6F74207B
747
+:102E8C006C6F61646572207374617274006A756D25
748
+:102E9C007021002A2A2A2A2A2A2A2A2A2A2A2A2A73
749
+:102EAC002A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A76
750
+:102EBC002A2A2A2A2A2A2A2A2A2A2A0D0052474250
751
+:102ECC002050726F6A6563740D0031343A31353AB3
752
+:102EDC0033300041707220203120323031390042C1
753
+:102EEC0075696C642061742025732025730D0A00AC
754
+:102EFC00436F7079726967687420286329203230B7
755
+:102F0C0031392E20424C554543454C4C0D000000A8
756
+:102F1C00000000000000010203040607080900007D
757
+:102F2C000000010203040000140000200000000057
758
+:102F3C000000000000000000000000000000000085
759
+:102F4C000000000000000000000000000000000075
760
+:102F5C000000000000000000000000000000000065
761
+:102F6C000000000000000000000000000000000055
762
+:102F7C000000000000000000000000000000000045
763
+:102F8C00000000000000000000000000232D302B8A
764
+:102F9C002000686C4C00656667454647003031324E
765
+:102FAC0033343536373839414243444546003031A5
766
+:102FBC003233343536373839616263646566000004
767
+:042FCC00F501000803
768
+:042FD000D101000823
769
+:102FD40001000000100000000040000800366E01EF
770
+:102FE4001400002000000000582F0008782F00086B
771
+:102FF400382F00080000000000000000000000005E
772
+:1030040000000000000000000000000000000000BC
773
+:1030140000000000000000000000000000000000AC
774
+:10302400000000000000000000000000000000009C
775
+:10303400000000000000000000000000000000008C
776
+:043044000000000088
777
+:0400000508001C993A
778
+:00000001FF

文件差异内容过多而无法显示
+ 6663 - 0
Debug/STM32F100_LoraTestBootloader.list


文件差异内容过多而无法显示
+ 1962 - 0
Debug/STM32F100_LoraTestBootloader.map


二进制
Debug/Src/flash_if.o


+ 5 - 0
Debug/Src/flash_if.su

@@ -0,0 +1,5 @@
1
+flash_if.c:58:6:FLASH_If_Init	8	static
2
+flash_if.c:75:10:FLASH_If_Erase	40	static
3
+flash_if.c:118:10:FLASH_If_Write	24	static
4
+flash_if.c:161:10:FLASH_If_GetWriteProtectionStatus	40	static
5
+flash_if.c:197:10:FLASH_If_WriteProtectionConfig	64	static

二进制
Debug/Src/main.o


+ 12 - 0
Debug/Src/main.su

@@ -0,0 +1,12 @@
1
+main.c:103:6:HAL_UART_RxCpltCallback	0	static
2
+main.c:116:6:HAL_TIM_PeriodElapsedCallback	0	static
3
+main.c:127:6:Uart1_Data_Send	0	static
4
+main.c:131:5:_write	8	static
5
+main.c:144:9:Flash_RGB_Data_Write	24	static
6
+main.c:159:9:Flash_write	24	static
7
+main.c:186:6:Flash_InitRead	16	static
8
+main.c:198:6:Jump_App	16	static
9
+main.c:209:6:FirmwareUpdateStart	24	static
10
+main.c:332:6:SystemClock_Config	72	static
11
+main.c:245:5:main	320	static
12
+main.c:482:6:Error_Handler	0	static

二进制
Debug/Src/sth30_crc.o


+ 3 - 0
Debug/Src/sth30_crc.su

@@ -0,0 +1,3 @@
1
+sth30_crc.c:38:9:STH30_CreateCrc	8	static
2
+sth30_crc.c:56:9:STH30_CheckCrc	12	static
3
+sth30_crc.c:78:16:genCRC16	8	static

二进制
Debug/Src/stm32f1xx_hal_msp.o


+ 5 - 0
Debug/Src/stm32f1xx_hal_msp.su

@@ -0,0 +1,5 @@
1
+stm32f1xx_hal_msp.c:84:6:HAL_MspInit	8	static
2
+stm32f1xx_hal_msp.c:110:6:HAL_TIM_Base_MspInit	8	static
3
+stm32f1xx_hal_msp.c:134:6:HAL_TIM_Base_MspDeInit	0	static
4
+stm32f1xx_hal_msp.c:160:6:HAL_UART_MspInit	32	static
5
+stm32f1xx_hal_msp.c:201:6:HAL_UART_MspDeInit	8	static

二进制
Debug/Src/stm32f1xx_it.o


+ 11 - 0
Debug/Src/stm32f1xx_it.su

@@ -0,0 +1,11 @@
1
+stm32f1xx_it.c:86:6:NMI_Handler	0	static
2
+stm32f1xx_it.c:99:6:HardFault_Handler	0	static
3
+stm32f1xx_it.c:114:6:MemManage_Handler	0	static
4
+stm32f1xx_it.c:129:6:BusFault_Handler	0	static
5
+stm32f1xx_it.c:144:6:UsageFault_Handler	0	static
6
+stm32f1xx_it.c:159:6:SVC_Handler	0	static
7
+stm32f1xx_it.c:172:6:DebugMon_Handler	0	static
8
+stm32f1xx_it.c:185:6:PendSV_Handler	0	static
9
+stm32f1xx_it.c:198:6:SysTick_Handler	0	static
10
+stm32f1xx_it.c:219:6:USART1_IRQHandler	0	static
11
+stm32f1xx_it.c:233:6:TIM7_IRQHandler	0	static

二进制
Debug/Src/system_stm32f1xx.o


+ 2 - 0
Debug/Src/system_stm32f1xx.su

@@ -0,0 +1,2 @@
1
+system_stm32f1xx.c:175:6:SystemInit	0	static
2
+system_stm32f1xx.c:265:6:SystemCoreClockUpdate	8	static

二进制
Debug/startup/startup_stm32f100xb.o


文件差异内容过多而无法显示
+ 6375 - 0
Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f100xb.h


+ 238 - 0
Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h

@@ -0,0 +1,238 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx.h
4
+  * @author  MCD Application Team
5
+  * @version V4.2.0
6
+  * @date    31-March-2017
7
+  * @brief   CMSIS STM32F1xx Device Peripheral Access Layer Header File. 
8
+  *
9
+  *          The file is the unique include file that the application programmer
10
+  *          is using in the C source code, usually in main.c. This file contains:
11
+  *            - Configuration section that allows to select:
12
+  *              - The STM32F1xx device used in the target application
13
+  *              - To use or not the peripheral’s drivers in application code(i.e. 
14
+  *                code will be based on direct access to peripheral’s registers 
15
+  *                rather than drivers API), this option is controlled by 
16
+  *                "#define USE_HAL_DRIVER"
17
+  *  
18
+  ******************************************************************************
19
+  * @attention
20
+  *
21
+  * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
22
+  *
23
+  * Redistribution and use in source and binary forms, with or without modification,
24
+  * are permitted provided that the following conditions are met:
25
+  *   1. Redistributions of source code must retain the above copyright notice,
26
+  *      this list of conditions and the following disclaimer.
27
+  *   2. Redistributions in binary form must reproduce the above copyright notice,
28
+  *      this list of conditions and the following disclaimer in the documentation
29
+  *      and/or other materials provided with the distribution.
30
+  *   3. Neither the name of STMicroelectronics nor the names of its contributors
31
+  *      may be used to endorse or promote products derived from this software
32
+  *      without specific prior written permission.
33
+  *
34
+  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
35
+  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
36
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
37
+  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
38
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
39
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
40
+  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
41
+  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
42
+  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
43
+  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44
+  *
45
+  ******************************************************************************
46
+  */
47
+
48
+/** @addtogroup CMSIS
49
+  * @{
50
+  */
51
+
52
+/** @addtogroup stm32f1xx
53
+  * @{
54
+  */
55
+    
56
+#ifndef __STM32F1XX_H
57
+#define __STM32F1XX_H
58
+
59
+#ifdef __cplusplus
60
+ extern "C" {
61
+#endif /* __cplusplus */
62
+  
63
+/** @addtogroup Library_configuration_section
64
+  * @{
65
+  */
66
+
67
+/**
68
+  * @brief STM32 Family
69
+  */
70
+#if !defined (STM32F1)
71
+#define STM32F1
72
+#endif /* STM32F1 */
73
+
74
+/* Uncomment the line below according to the target STM32L device used in your 
75
+   application 
76
+  */
77
+
78
+#if !defined (STM32F100xB) && !defined (STM32F100xE) && !defined (STM32F101x6) && \
79
+    !defined (STM32F101xB) && !defined (STM32F101xE) && !defined (STM32F101xG) && !defined (STM32F102x6) && !defined (STM32F102xB) && !defined (STM32F103x6) && \
80
+    !defined (STM32F103xB) && !defined (STM32F103xE) && !defined (STM32F103xG) && !defined (STM32F105xC) && !defined (STM32F107xC)
81
+  /* #define STM32F100xB  */   /*!< STM32F100C4, STM32F100R4, STM32F100C6, STM32F100R6, STM32F100C8, STM32F100R8, STM32F100V8, STM32F100CB, STM32F100RB and STM32F100VB */
82
+  /* #define STM32F100xE */    /*!< STM32F100RC, STM32F100VC, STM32F100ZC, STM32F100RD, STM32F100VD, STM32F100ZD, STM32F100RE, STM32F100VE and STM32F100ZE */
83
+  /* #define STM32F101x6  */   /*!< STM32F101C4, STM32F101R4, STM32F101T4, STM32F101C6, STM32F101R6 and STM32F101T6 Devices */
84
+  /* #define STM32F101xB  */   /*!< STM32F101C8, STM32F101R8, STM32F101T8, STM32F101V8, STM32F101CB, STM32F101RB, STM32F101TB and STM32F101VB */
85
+  /* #define STM32F101xE */    /*!< STM32F101RC, STM32F101VC, STM32F101ZC, STM32F101RD, STM32F101VD, STM32F101ZD, STM32F101RE, STM32F101VE and STM32F101ZE */ 
86
+  /* #define STM32F101xG  */   /*!< STM32F101RF, STM32F101VF, STM32F101ZF, STM32F101RG, STM32F101VG and STM32F101ZG */
87
+  /* #define STM32F102x6 */    /*!< STM32F102C4, STM32F102R4, STM32F102C6 and STM32F102R6 */
88
+  /* #define STM32F102xB  */   /*!< STM32F102C8, STM32F102R8, STM32F102CB and STM32F102RB */
89
+  /* #define STM32F103x6  */   /*!< STM32F103C4, STM32F103R4, STM32F103T4, STM32F103C6, STM32F103R6 and STM32F103T6 */
90
+  /* #define STM32F103xB  */   /*!< STM32F103C8, STM32F103R8, STM32F103T8, STM32F103V8, STM32F103CB, STM32F103RB, STM32F103TB and STM32F103VB */
91
+  /* #define STM32F103xE */    /*!< STM32F103RC, STM32F103VC, STM32F103ZC, STM32F103RD, STM32F103VD, STM32F103ZD, STM32F103RE, STM32F103VE and STM32F103ZE */
92
+  /* #define STM32F103xG  */   /*!< STM32F103RF, STM32F103VF, STM32F103ZF, STM32F103RG, STM32F103VG and STM32F103ZG */
93
+  /* #define STM32F105xC */    /*!< STM32F105R8, STM32F105V8, STM32F105RB, STM32F105VB, STM32F105RC and STM32F105VC */
94
+  /* #define STM32F107xC  */   /*!< STM32F107RB, STM32F107VB, STM32F107RC and STM32F107VC */  
95
+#endif
96
+
97
+/*  Tip: To avoid modifying this file each time you need to switch between these
98
+        devices, you can define the device in your toolchain compiler preprocessor.
99
+  */
100
+  
101
+#if !defined  (USE_HAL_DRIVER)
102
+/**
103
+ * @brief Comment the line below if you will not use the peripherals drivers.
104
+   In this case, these drivers will not be included and the application code will 
105
+   be based on direct access to peripherals registers 
106
+   */
107
+  /*#define USE_HAL_DRIVER */
108
+#endif /* USE_HAL_DRIVER */
109
+
110
+/**
111
+  * @brief CMSIS Device version number V4.2.0
112
+  */
113
+#define __STM32F1_CMSIS_VERSION_MAIN   (0x04) /*!< [31:24] main version */
114
+#define __STM32F1_CMSIS_VERSION_SUB1   (0x02) /*!< [23:16] sub1 version */
115
+#define __STM32F1_CMSIS_VERSION_SUB2   (0x00) /*!< [15:8]  sub2 version */
116
+#define __STM32F1_CMSIS_VERSION_RC     (0x00) /*!< [7:0]  release candidate */ 
117
+#define __STM32F1_CMSIS_VERSION        ((__STM32F1_CMSIS_VERSION_MAIN << 24)\
118
+                                       |(__STM32F1_CMSIS_VERSION_SUB1 << 16)\
119
+                                       |(__STM32F1_CMSIS_VERSION_SUB2 << 8 )\
120
+                                       |(__STM32F1_CMSIS_VERSION_RC))
121
+
122
+/**
123
+  * @}
124
+  */
125
+
126
+/** @addtogroup Device_Included
127
+  * @{
128
+  */
129
+
130
+#if defined(STM32F100xB)
131
+  #include "stm32f100xb.h"
132
+#elif defined(STM32F100xE)
133
+  #include "stm32f100xe.h"
134
+#elif defined(STM32F101x6)
135
+  #include "stm32f101x6.h"
136
+#elif defined(STM32F101xB)
137
+  #include "stm32f101xb.h"
138
+#elif defined(STM32F101xE)
139
+  #include "stm32f101xe.h"
140
+#elif defined(STM32F101xG)
141
+  #include "stm32f101xg.h"
142
+#elif defined(STM32F102x6)
143
+  #include "stm32f102x6.h"
144
+#elif defined(STM32F102xB)
145
+  #include "stm32f102xb.h"
146
+#elif defined(STM32F103x6)
147
+  #include "stm32f103x6.h"
148
+#elif defined(STM32F103xB)
149
+  #include "stm32f103xb.h"
150
+#elif defined(STM32F103xE)
151
+  #include "stm32f103xe.h"
152
+#elif defined(STM32F103xG)
153
+  #include "stm32f103xg.h"
154
+#elif defined(STM32F105xC)
155
+  #include "stm32f105xc.h"
156
+#elif defined(STM32F107xC)
157
+  #include "stm32f107xc.h"
158
+#else
159
+ #error "Please select first the target STM32F1xx device used in your application (in stm32f1xx.h file)"
160
+#endif
161
+
162
+/**
163
+  * @}
164
+  */
165
+
166
+/** @addtogroup Exported_types
167
+  * @{
168
+  */  
169
+typedef enum 
170
+{
171
+  RESET = 0, 
172
+  SET = !RESET
173
+} FlagStatus, ITStatus;
174
+
175
+typedef enum 
176
+{
177
+  DISABLE = 0, 
178
+  ENABLE = !DISABLE
179
+} FunctionalState;
180
+#define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE))
181
+
182
+typedef enum 
183
+{
184
+  ERROR = 0, 
185
+  SUCCESS = !ERROR
186
+} ErrorStatus;
187
+
188
+/**
189
+  * @}
190
+  */
191
+
192
+
193
+/** @addtogroup Exported_macros
194
+  * @{
195
+  */
196
+#define SET_BIT(REG, BIT)     ((REG) |= (BIT))
197
+
198
+#define CLEAR_BIT(REG, BIT)   ((REG) &= ~(BIT))
199
+
200
+#define READ_BIT(REG, BIT)    ((REG) & (BIT))
201
+
202
+#define CLEAR_REG(REG)        ((REG) = (0x0))
203
+
204
+#define WRITE_REG(REG, VAL)   ((REG) = (VAL))
205
+
206
+#define READ_REG(REG)         ((REG))
207
+
208
+#define MODIFY_REG(REG, CLEARMASK, SETMASK)  WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK)))
209
+
210
+#define POSITION_VAL(VAL)     (__CLZ(__RBIT(VAL))) 
211
+
212
+
213
+/**
214
+  * @}
215
+  */
216
+
217
+#if defined (USE_HAL_DRIVER)
218
+ #include "stm32f1xx_hal.h"
219
+#endif /* USE_HAL_DRIVER */
220
+
221
+
222
+#ifdef __cplusplus
223
+}
224
+#endif /* __cplusplus */
225
+
226
+#endif /* __STM32F1xx_H */
227
+/**
228
+  * @}
229
+  */
230
+
231
+/**
232
+  * @}
233
+  */
234
+  
235
+
236
+
237
+
238
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 116 - 0
Drivers/CMSIS/Device/ST/STM32F1xx/Include/system_stm32f1xx.h

@@ -0,0 +1,116 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    system_stm32f10x.h
4
+  * @author  MCD Application Team
5
+  * @version V4.2.0
6
+  * @date    31-March-2017
7
+  * @brief   CMSIS Cortex-M3 Device Peripheral Access Layer System Header File.
8
+  ******************************************************************************
9
+  * @attention
10
+  *
11
+  * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
12
+  *
13
+  * Redistribution and use in source and binary forms, with or without modification,
14
+  * are permitted provided that the following conditions are met:
15
+  *   1. Redistributions of source code must retain the above copyright notice,
16
+  *      this list of conditions and the following disclaimer.
17
+  *   2. Redistributions in binary form must reproduce the above copyright notice,
18
+  *      this list of conditions and the following disclaimer in the documentation
19
+  *      and/or other materials provided with the distribution.
20
+  *   3. Neither the name of STMicroelectronics nor the names of its contributors
21
+  *      may be used to endorse or promote products derived from this software
22
+  *      without specific prior written permission.
23
+  *
24
+  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25
+  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27
+  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
28
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30
+  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31
+  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32
+  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
+  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+  *
35
+  ******************************************************************************
36
+  */
37
+
38
+/** @addtogroup CMSIS
39
+  * @{
40
+  */
41
+
42
+/** @addtogroup stm32f10x_system
43
+  * @{
44
+  */  
45
+  
46
+/**
47
+  * @brief Define to prevent recursive inclusion
48
+  */
49
+#ifndef __SYSTEM_STM32F10X_H
50
+#define __SYSTEM_STM32F10X_H
51
+
52
+#ifdef __cplusplus
53
+ extern "C" {
54
+#endif 
55
+
56
+/** @addtogroup STM32F10x_System_Includes
57
+  * @{
58
+  */
59
+
60
+/**
61
+  * @}
62
+  */
63
+
64
+
65
+/** @addtogroup STM32F10x_System_Exported_types
66
+  * @{
67
+  */
68
+
69
+extern uint32_t SystemCoreClock;          /*!< System Clock Frequency (Core Clock) */
70
+extern const uint8_t  AHBPrescTable[16U];  /*!< AHB prescalers table values */
71
+extern const uint8_t  APBPrescTable[8U];   /*!< APB prescalers table values */
72
+
73
+/**
74
+  * @}
75
+  */
76
+
77
+/** @addtogroup STM32F10x_System_Exported_Constants
78
+  * @{
79
+  */
80
+
81
+/**
82
+  * @}
83
+  */
84
+
85
+/** @addtogroup STM32F10x_System_Exported_Macros
86
+  * @{
87
+  */
88
+
89
+/**
90
+  * @}
91
+  */
92
+
93
+/** @addtogroup STM32F10x_System_Exported_Functions
94
+  * @{
95
+  */
96
+  
97
+extern void SystemInit(void);
98
+extern void SystemCoreClockUpdate(void);
99
+/**
100
+  * @}
101
+  */
102
+
103
+#ifdef __cplusplus
104
+}
105
+#endif
106
+
107
+#endif /*__SYSTEM_STM32F10X_H */
108
+
109
+/**
110
+  * @}
111
+  */
112
+  
113
+/**
114
+  * @}
115
+  */  
116
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 136 - 0
Drivers/CMSIS/Include/arm_common_tables.h

@@ -0,0 +1,136 @@
1
+/* ----------------------------------------------------------------------
2
+* Copyright (C) 2010-2014 ARM Limited. All rights reserved.
3
+*
4
+* $Date:        19. October 2015
5
+* $Revision: 	V.1.4.5 a
6
+*
7
+* Project: 	    CMSIS DSP Library
8
+* Title:	    arm_common_tables.h
9
+*
10
+* Description:	This file has extern declaration for common tables like Bitreverse, reciprocal etc which are used across different functions
11
+*
12
+* Target Processor: Cortex-M4/Cortex-M3
13
+*
14
+* Redistribution and use in source and binary forms, with or without
15
+* modification, are permitted provided that the following conditions
16
+* are met:
17
+*   - Redistributions of source code must retain the above copyright
18
+*     notice, this list of conditions and the following disclaimer.
19
+*   - Redistributions in binary form must reproduce the above copyright
20
+*     notice, this list of conditions and the following disclaimer in
21
+*     the documentation and/or other materials provided with the
22
+*     distribution.
23
+*   - Neither the name of ARM LIMITED nor the names of its contributors
24
+*     may be used to endorse or promote products derived from this
25
+*     software without specific prior written permission.
26
+*
27
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28
+* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
30
+* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
31
+* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
32
+* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
33
+* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
34
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
35
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36
+* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
37
+* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38
+* POSSIBILITY OF SUCH DAMAGE.
39
+* -------------------------------------------------------------------- */
40
+
41
+#ifndef _ARM_COMMON_TABLES_H
42
+#define _ARM_COMMON_TABLES_H
43
+
44
+#include "arm_math.h"
45
+
46
+extern const uint16_t armBitRevTable[1024];
47
+extern const q15_t armRecipTableQ15[64];
48
+extern const q31_t armRecipTableQ31[64];
49
+/* extern const q31_t realCoefAQ31[1024]; */
50
+/* extern const q31_t realCoefBQ31[1024]; */
51
+extern const float32_t twiddleCoef_16[32];
52
+extern const float32_t twiddleCoef_32[64];
53
+extern const float32_t twiddleCoef_64[128];
54
+extern const float32_t twiddleCoef_128[256];
55
+extern const float32_t twiddleCoef_256[512];
56
+extern const float32_t twiddleCoef_512[1024];
57
+extern const float32_t twiddleCoef_1024[2048];
58
+extern const float32_t twiddleCoef_2048[4096];
59
+extern const float32_t twiddleCoef_4096[8192];
60
+#define twiddleCoef twiddleCoef_4096
61
+extern const q31_t twiddleCoef_16_q31[24];
62
+extern const q31_t twiddleCoef_32_q31[48];
63
+extern const q31_t twiddleCoef_64_q31[96];
64
+extern const q31_t twiddleCoef_128_q31[192];
65
+extern const q31_t twiddleCoef_256_q31[384];
66
+extern const q31_t twiddleCoef_512_q31[768];
67
+extern const q31_t twiddleCoef_1024_q31[1536];
68
+extern const q31_t twiddleCoef_2048_q31[3072];
69
+extern const q31_t twiddleCoef_4096_q31[6144];
70
+extern const q15_t twiddleCoef_16_q15[24];
71
+extern const q15_t twiddleCoef_32_q15[48];
72
+extern const q15_t twiddleCoef_64_q15[96];
73
+extern const q15_t twiddleCoef_128_q15[192];
74
+extern const q15_t twiddleCoef_256_q15[384];
75
+extern const q15_t twiddleCoef_512_q15[768];
76
+extern const q15_t twiddleCoef_1024_q15[1536];
77
+extern const q15_t twiddleCoef_2048_q15[3072];
78
+extern const q15_t twiddleCoef_4096_q15[6144];
79
+extern const float32_t twiddleCoef_rfft_32[32];
80
+extern const float32_t twiddleCoef_rfft_64[64];
81
+extern const float32_t twiddleCoef_rfft_128[128];
82
+extern const float32_t twiddleCoef_rfft_256[256];
83
+extern const float32_t twiddleCoef_rfft_512[512];
84
+extern const float32_t twiddleCoef_rfft_1024[1024];
85
+extern const float32_t twiddleCoef_rfft_2048[2048];
86
+extern const float32_t twiddleCoef_rfft_4096[4096];
87
+
88
+
89
+/* floating-point bit reversal tables */
90
+#define ARMBITREVINDEXTABLE__16_TABLE_LENGTH ((uint16_t)20  )
91
+#define ARMBITREVINDEXTABLE__32_TABLE_LENGTH ((uint16_t)48  )
92
+#define ARMBITREVINDEXTABLE__64_TABLE_LENGTH ((uint16_t)56  )
93
+#define ARMBITREVINDEXTABLE_128_TABLE_LENGTH ((uint16_t)208 )
94
+#define ARMBITREVINDEXTABLE_256_TABLE_LENGTH ((uint16_t)440 )
95
+#define ARMBITREVINDEXTABLE_512_TABLE_LENGTH ((uint16_t)448 )
96
+#define ARMBITREVINDEXTABLE1024_TABLE_LENGTH ((uint16_t)1800)
97
+#define ARMBITREVINDEXTABLE2048_TABLE_LENGTH ((uint16_t)3808)
98
+#define ARMBITREVINDEXTABLE4096_TABLE_LENGTH ((uint16_t)4032)
99
+
100
+extern const uint16_t armBitRevIndexTable16[ARMBITREVINDEXTABLE__16_TABLE_LENGTH];
101
+extern const uint16_t armBitRevIndexTable32[ARMBITREVINDEXTABLE__32_TABLE_LENGTH];
102
+extern const uint16_t armBitRevIndexTable64[ARMBITREVINDEXTABLE__64_TABLE_LENGTH];
103
+extern const uint16_t armBitRevIndexTable128[ARMBITREVINDEXTABLE_128_TABLE_LENGTH];
104
+extern const uint16_t armBitRevIndexTable256[ARMBITREVINDEXTABLE_256_TABLE_LENGTH];
105
+extern const uint16_t armBitRevIndexTable512[ARMBITREVINDEXTABLE_512_TABLE_LENGTH];
106
+extern const uint16_t armBitRevIndexTable1024[ARMBITREVINDEXTABLE1024_TABLE_LENGTH];
107
+extern const uint16_t armBitRevIndexTable2048[ARMBITREVINDEXTABLE2048_TABLE_LENGTH];
108
+extern const uint16_t armBitRevIndexTable4096[ARMBITREVINDEXTABLE4096_TABLE_LENGTH];
109
+
110
+/* fixed-point bit reversal tables */
111
+#define ARMBITREVINDEXTABLE_FIXED___16_TABLE_LENGTH ((uint16_t)12  )
112
+#define ARMBITREVINDEXTABLE_FIXED___32_TABLE_LENGTH ((uint16_t)24  )
113
+#define ARMBITREVINDEXTABLE_FIXED___64_TABLE_LENGTH ((uint16_t)56  )
114
+#define ARMBITREVINDEXTABLE_FIXED__128_TABLE_LENGTH ((uint16_t)112 )
115
+#define ARMBITREVINDEXTABLE_FIXED__256_TABLE_LENGTH ((uint16_t)240 )
116
+#define ARMBITREVINDEXTABLE_FIXED__512_TABLE_LENGTH ((uint16_t)480 )
117
+#define ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH ((uint16_t)992 )
118
+#define ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH ((uint16_t)1984)
119
+#define ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH ((uint16_t)4032)
120
+
121
+extern const uint16_t armBitRevIndexTable_fixed_16[ARMBITREVINDEXTABLE_FIXED___16_TABLE_LENGTH];
122
+extern const uint16_t armBitRevIndexTable_fixed_32[ARMBITREVINDEXTABLE_FIXED___32_TABLE_LENGTH];
123
+extern const uint16_t armBitRevIndexTable_fixed_64[ARMBITREVINDEXTABLE_FIXED___64_TABLE_LENGTH];
124
+extern const uint16_t armBitRevIndexTable_fixed_128[ARMBITREVINDEXTABLE_FIXED__128_TABLE_LENGTH];
125
+extern const uint16_t armBitRevIndexTable_fixed_256[ARMBITREVINDEXTABLE_FIXED__256_TABLE_LENGTH];
126
+extern const uint16_t armBitRevIndexTable_fixed_512[ARMBITREVINDEXTABLE_FIXED__512_TABLE_LENGTH];
127
+extern const uint16_t armBitRevIndexTable_fixed_1024[ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH];
128
+extern const uint16_t armBitRevIndexTable_fixed_2048[ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH];
129
+extern const uint16_t armBitRevIndexTable_fixed_4096[ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH];
130
+
131
+/* Tables for Fast Math Sine and Cosine */
132
+extern const float32_t sinTable_f32[FAST_MATH_TABLE_SIZE + 1];
133
+extern const q31_t sinTable_q31[FAST_MATH_TABLE_SIZE + 1];
134
+extern const q15_t sinTable_q15[FAST_MATH_TABLE_SIZE + 1];
135
+
136
+#endif /*  ARM_COMMON_TABLES_H */

+ 79 - 0
Drivers/CMSIS/Include/arm_const_structs.h

@@ -0,0 +1,79 @@
1
+/* ----------------------------------------------------------------------
2
+* Copyright (C) 2010-2014 ARM Limited. All rights reserved.
3
+*
4
+* $Date:        19. March 2015
5
+* $Revision: 	V.1.4.5
6
+*
7
+* Project: 	    CMSIS DSP Library
8
+* Title:	    arm_const_structs.h
9
+*
10
+* Description:	This file has constant structs that are initialized for
11
+*              user convenience.  For example, some can be given as
12
+*              arguments to the arm_cfft_f32() function.
13
+*
14
+* Target Processor: Cortex-M4/Cortex-M3
15
+*
16
+* Redistribution and use in source and binary forms, with or without
17
+* modification, are permitted provided that the following conditions
18
+* are met:
19
+*   - Redistributions of source code must retain the above copyright
20
+*     notice, this list of conditions and the following disclaimer.
21
+*   - Redistributions in binary form must reproduce the above copyright
22
+*     notice, this list of conditions and the following disclaimer in
23
+*     the documentation and/or other materials provided with the
24
+*     distribution.
25
+*   - Neither the name of ARM LIMITED nor the names of its contributors
26
+*     may be used to endorse or promote products derived from this
27
+*     software without specific prior written permission.
28
+*
29
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30
+* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
32
+* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
33
+* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
34
+* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
35
+* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
36
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
37
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
38
+* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
39
+* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
40
+* POSSIBILITY OF SUCH DAMAGE.
41
+* -------------------------------------------------------------------- */
42
+
43
+#ifndef _ARM_CONST_STRUCTS_H
44
+#define _ARM_CONST_STRUCTS_H
45
+
46
+#include "arm_math.h"
47
+#include "arm_common_tables.h"
48
+
49
+   extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len16;
50
+   extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len32;
51
+   extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len64;
52
+   extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len128;
53
+   extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len256;
54
+   extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len512;
55
+   extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len1024;
56
+   extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len2048;
57
+   extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len4096;
58
+
59
+   extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len16;
60
+   extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len32;
61
+   extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len64;
62
+   extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len128;
63
+   extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len256;
64
+   extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len512;
65
+   extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len1024;
66
+   extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len2048;
67
+   extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len4096;
68
+
69
+   extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len16;
70
+   extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len32;
71
+   extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len64;
72
+   extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len128;
73
+   extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len256;
74
+   extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len512;
75
+   extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len1024;
76
+   extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len2048;
77
+   extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len4096;
78
+
79
+#endif

文件差异内容过多而无法显示
+ 7154 - 0
Drivers/CMSIS/Include/arm_math.h


+ 734 - 0
Drivers/CMSIS/Include/cmsis_armcc.h

@@ -0,0 +1,734 @@
1
+/**************************************************************************//**
2
+ * @file     cmsis_armcc.h
3
+ * @brief    CMSIS Cortex-M Core Function/Instruction Header File
4
+ * @version  V4.30
5
+ * @date     20. October 2015
6
+ ******************************************************************************/
7
+/* Copyright (c) 2009 - 2015 ARM LIMITED
8
+
9
+   All rights reserved.
10
+   Redistribution and use in source and binary forms, with or without
11
+   modification, are permitted provided that the following conditions are met:
12
+   - Redistributions of source code must retain the above copyright
13
+     notice, this list of conditions and the following disclaimer.
14
+   - Redistributions in binary form must reproduce the above copyright
15
+     notice, this list of conditions and the following disclaimer in the
16
+     documentation and/or other materials provided with the distribution.
17
+   - Neither the name of ARM nor the names of its contributors may be used
18
+     to endorse or promote products derived from this software without
19
+     specific prior written permission.
20
+   *
21
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22
+   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23
+   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24
+   ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
25
+   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26
+   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27
+   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
+   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
+   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
+   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
+   POSSIBILITY OF SUCH DAMAGE.
32
+   ---------------------------------------------------------------------------*/
33
+
34
+
35
+#ifndef __CMSIS_ARMCC_H
36
+#define __CMSIS_ARMCC_H
37
+
38
+
39
+#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 400677)
40
+  #error "Please use ARM Compiler Toolchain V4.0.677 or later!"
41
+#endif
42
+
43
+/* ###########################  Core Function Access  ########################### */
44
+/** \ingroup  CMSIS_Core_FunctionInterface
45
+    \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
46
+  @{
47
+ */
48
+
49
+/* intrinsic void __enable_irq();     */
50
+/* intrinsic void __disable_irq();    */
51
+
52
+/**
53
+  \brief   Get Control Register
54
+  \details Returns the content of the Control Register.
55
+  \return               Control Register value
56
+ */
57
+__STATIC_INLINE uint32_t __get_CONTROL(void)
58
+{
59
+  register uint32_t __regControl         __ASM("control");
60
+  return(__regControl);
61
+}
62
+
63
+
64
+/**
65
+  \brief   Set Control Register
66
+  \details Writes the given value to the Control Register.
67
+  \param [in]    control  Control Register value to set
68
+ */
69
+__STATIC_INLINE void __set_CONTROL(uint32_t control)
70
+{
71
+  register uint32_t __regControl         __ASM("control");
72
+  __regControl = control;
73
+}
74
+
75
+
76
+/**
77
+  \brief   Get IPSR Register
78
+  \details Returns the content of the IPSR Register.
79
+  \return               IPSR Register value
80
+ */
81
+__STATIC_INLINE uint32_t __get_IPSR(void)
82
+{
83
+  register uint32_t __regIPSR          __ASM("ipsr");
84
+  return(__regIPSR);
85
+}
86
+
87
+
88
+/**
89
+  \brief   Get APSR Register
90
+  \details Returns the content of the APSR Register.
91
+  \return               APSR Register value
92
+ */
93
+__STATIC_INLINE uint32_t __get_APSR(void)
94
+{
95
+  register uint32_t __regAPSR          __ASM("apsr");
96
+  return(__regAPSR);
97
+}
98
+
99
+
100
+/**
101
+  \brief   Get xPSR Register
102
+  \details Returns the content of the xPSR Register.
103
+  \return               xPSR Register value
104
+ */
105
+__STATIC_INLINE uint32_t __get_xPSR(void)
106
+{
107
+  register uint32_t __regXPSR          __ASM("xpsr");
108
+  return(__regXPSR);
109
+}
110
+
111
+
112
+/**
113
+  \brief   Get Process Stack Pointer
114
+  \details Returns the current value of the Process Stack Pointer (PSP).
115
+  \return               PSP Register value
116
+ */
117
+__STATIC_INLINE uint32_t __get_PSP(void)
118
+{
119
+  register uint32_t __regProcessStackPointer  __ASM("psp");
120
+  return(__regProcessStackPointer);
121
+}
122
+
123
+
124
+/**
125
+  \brief   Set Process Stack Pointer
126
+  \details Assigns the given value to the Process Stack Pointer (PSP).
127
+  \param [in]    topOfProcStack  Process Stack Pointer value to set
128
+ */
129
+__STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
130
+{
131
+  register uint32_t __regProcessStackPointer  __ASM("psp");
132
+  __regProcessStackPointer = topOfProcStack;
133
+}
134
+
135
+
136
+/**
137
+  \brief   Get Main Stack Pointer
138
+  \details Returns the current value of the Main Stack Pointer (MSP).
139
+  \return               MSP Register value
140
+ */
141
+__STATIC_INLINE uint32_t __get_MSP(void)
142
+{
143
+  register uint32_t __regMainStackPointer     __ASM("msp");
144
+  return(__regMainStackPointer);
145
+}
146
+
147
+
148
+/**
149
+  \brief   Set Main Stack Pointer
150
+  \details Assigns the given value to the Main Stack Pointer (MSP).
151
+  \param [in]    topOfMainStack  Main Stack Pointer value to set
152
+ */
153
+__STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
154
+{
155
+  register uint32_t __regMainStackPointer     __ASM("msp");
156
+  __regMainStackPointer = topOfMainStack;
157
+}
158
+
159
+
160
+/**
161
+  \brief   Get Priority Mask
162
+  \details Returns the current state of the priority mask bit from the Priority Mask Register.
163
+  \return               Priority Mask value
164
+ */
165
+__STATIC_INLINE uint32_t __get_PRIMASK(void)
166
+{
167
+  register uint32_t __regPriMask         __ASM("primask");
168
+  return(__regPriMask);
169
+}
170
+
171
+
172
+/**
173
+  \brief   Set Priority Mask
174
+  \details Assigns the given value to the Priority Mask Register.
175
+  \param [in]    priMask  Priority Mask
176
+ */
177
+__STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
178
+{
179
+  register uint32_t __regPriMask         __ASM("primask");
180
+  __regPriMask = (priMask);
181
+}
182
+
183
+
184
+#if       (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U)
185
+
186
+/**
187
+  \brief   Enable FIQ
188
+  \details Enables FIQ interrupts by clearing the F-bit in the CPSR.
189
+           Can only be executed in Privileged modes.
190
+ */
191
+#define __enable_fault_irq                __enable_fiq
192
+
193
+
194
+/**
195
+  \brief   Disable FIQ
196
+  \details Disables FIQ interrupts by setting the F-bit in the CPSR.
197
+           Can only be executed in Privileged modes.
198
+ */
199
+#define __disable_fault_irq               __disable_fiq
200
+
201
+
202
+/**
203
+  \brief   Get Base Priority
204
+  \details Returns the current value of the Base Priority register.
205
+  \return               Base Priority register value
206
+ */
207
+__STATIC_INLINE uint32_t  __get_BASEPRI(void)
208
+{
209
+  register uint32_t __regBasePri         __ASM("basepri");
210
+  return(__regBasePri);
211
+}
212
+
213
+
214
+/**
215
+  \brief   Set Base Priority
216
+  \details Assigns the given value to the Base Priority register.
217
+  \param [in]    basePri  Base Priority value to set
218
+ */
219
+__STATIC_INLINE void __set_BASEPRI(uint32_t basePri)
220
+{
221
+  register uint32_t __regBasePri         __ASM("basepri");
222
+  __regBasePri = (basePri & 0xFFU);
223
+}
224
+
225
+
226
+/**
227
+  \brief   Set Base Priority with condition
228
+  \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled,
229
+           or the new value increases the BASEPRI priority level.
230
+  \param [in]    basePri  Base Priority value to set
231
+ */
232
+__STATIC_INLINE void __set_BASEPRI_MAX(uint32_t basePri)
233
+{
234
+  register uint32_t __regBasePriMax      __ASM("basepri_max");
235
+  __regBasePriMax = (basePri & 0xFFU);
236
+}
237
+
238
+
239
+/**
240
+  \brief   Get Fault Mask
241
+  \details Returns the current value of the Fault Mask register.
242
+  \return               Fault Mask register value
243
+ */
244
+__STATIC_INLINE uint32_t __get_FAULTMASK(void)
245
+{
246
+  register uint32_t __regFaultMask       __ASM("faultmask");
247
+  return(__regFaultMask);
248
+}
249
+
250
+
251
+/**
252
+  \brief   Set Fault Mask
253
+  \details Assigns the given value to the Fault Mask register.
254
+  \param [in]    faultMask  Fault Mask value to set
255
+ */
256
+__STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
257
+{
258
+  register uint32_t __regFaultMask       __ASM("faultmask");
259
+  __regFaultMask = (faultMask & (uint32_t)1);
260
+}
261
+
262
+#endif /* (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U) */
263
+
264
+
265
+#if       (__CORTEX_M == 0x04U) || (__CORTEX_M == 0x07U)
266
+
267
+/**
268
+  \brief   Get FPSCR
269
+  \details Returns the current value of the Floating Point Status/Control register.
270
+  \return               Floating Point Status/Control register value
271
+ */
272
+__STATIC_INLINE uint32_t __get_FPSCR(void)
273
+{
274
+#if (__FPU_PRESENT == 1U) && (__FPU_USED == 1U)
275
+  register uint32_t __regfpscr         __ASM("fpscr");
276
+  return(__regfpscr);
277
+#else
278
+   return(0U);
279
+#endif
280
+}
281
+
282
+
283
+/**
284
+  \brief   Set FPSCR
285
+  \details Assigns the given value to the Floating Point Status/Control register.
286
+  \param [in]    fpscr  Floating Point Status/Control value to set
287
+ */
288
+__STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
289
+{
290
+#if (__FPU_PRESENT == 1U) && (__FPU_USED == 1U)
291
+  register uint32_t __regfpscr         __ASM("fpscr");
292
+  __regfpscr = (fpscr);
293
+#endif
294
+}
295
+
296
+#endif /* (__CORTEX_M == 0x04U) || (__CORTEX_M == 0x07U) */
297
+
298
+
299
+
300
+/*@} end of CMSIS_Core_RegAccFunctions */
301
+
302
+
303
+/* ##########################  Core Instruction Access  ######################### */
304
+/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
305
+  Access to dedicated instructions
306
+  @{
307
+*/
308
+
309
+/**
310
+  \brief   No Operation
311
+  \details No Operation does nothing. This instruction can be used for code alignment purposes.
312
+ */
313
+#define __NOP                             __nop
314
+
315
+
316
+/**
317
+  \brief   Wait For Interrupt
318
+  \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs.
319
+ */
320
+#define __WFI                             __wfi
321
+
322
+
323
+/**
324
+  \brief   Wait For Event
325
+  \details Wait For Event is a hint instruction that permits the processor to enter
326
+           a low-power state until one of a number of events occurs.
327
+ */
328
+#define __WFE                             __wfe
329
+
330
+
331
+/**
332
+  \brief   Send Event
333
+  \details Send Event is a hint instruction. It causes an event to be signaled to the CPU.
334
+ */
335
+#define __SEV                             __sev
336
+
337
+
338
+/**
339
+  \brief   Instruction Synchronization Barrier
340
+  \details Instruction Synchronization Barrier flushes the pipeline in the processor,
341
+           so that all instructions following the ISB are fetched from cache or memory,
342
+           after the instruction has been completed.
343
+ */
344
+#define __ISB() do {\
345
+                   __schedule_barrier();\
346
+                   __isb(0xF);\
347
+                   __schedule_barrier();\
348
+                } while (0U)
349
+
350
+/**
351
+  \brief   Data Synchronization Barrier
352
+  \details Acts as a special kind of Data Memory Barrier.
353
+           It completes when all explicit memory accesses before this instruction complete.
354
+ */
355
+#define __DSB() do {\
356
+                   __schedule_barrier();\
357
+                   __dsb(0xF);\
358
+                   __schedule_barrier();\
359
+                } while (0U)
360
+
361
+/**
362
+  \brief   Data Memory Barrier
363
+  \details Ensures the apparent order of the explicit memory operations before
364
+           and after the instruction, without ensuring their completion.
365
+ */
366
+#define __DMB() do {\
367
+                   __schedule_barrier();\
368
+                   __dmb(0xF);\
369
+                   __schedule_barrier();\
370
+                } while (0U)
371
+
372
+/**
373
+  \brief   Reverse byte order (32 bit)
374
+  \details Reverses the byte order in integer value.
375
+  \param [in]    value  Value to reverse
376
+  \return               Reversed value
377
+ */
378
+#define __REV                             __rev
379
+
380
+
381
+/**
382
+  \brief   Reverse byte order (16 bit)
383
+  \details Reverses the byte order in two unsigned short values.
384
+  \param [in]    value  Value to reverse
385
+  \return               Reversed value
386
+ */
387
+#ifndef __NO_EMBEDDED_ASM
388
+__attribute__((section(".rev16_text"))) __STATIC_INLINE __ASM uint32_t __REV16(uint32_t value)
389
+{
390
+  rev16 r0, r0
391
+  bx lr
392
+}
393
+#endif
394
+
395
+/**
396
+  \brief   Reverse byte order in signed short value
397
+  \details Reverses the byte order in a signed short value with sign extension to integer.
398
+  \param [in]    value  Value to reverse
399
+  \return               Reversed value
400
+ */
401
+#ifndef __NO_EMBEDDED_ASM
402
+__attribute__((section(".revsh_text"))) __STATIC_INLINE __ASM int32_t __REVSH(int32_t value)
403
+{
404
+  revsh r0, r0
405
+  bx lr
406
+}
407
+#endif
408
+
409
+
410
+/**
411
+  \brief   Rotate Right in unsigned value (32 bit)
412
+  \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
413
+  \param [in]    value  Value to rotate
414
+  \param [in]    value  Number of Bits to rotate
415
+  \return               Rotated value
416
+ */
417
+#define __ROR                             __ror
418
+
419
+
420
+/**
421
+  \brief   Breakpoint
422
+  \details Causes the processor to enter Debug state.
423
+           Debug tools can use this to investigate system state when the instruction at a particular address is reached.
424
+  \param [in]    value  is ignored by the processor.
425
+                 If required, a debugger can use it to store additional information about the breakpoint.
426
+ */
427
+#define __BKPT(value)                       __breakpoint(value)
428
+
429
+
430
+/**
431
+  \brief   Reverse bit order of value
432
+  \details Reverses the bit order of the given value.
433
+  \param [in]    value  Value to reverse
434
+  \return               Reversed value
435
+ */
436
+#if       (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U)
437
+  #define __RBIT                          __rbit
438
+#else
439
+__attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
440
+{
441
+  uint32_t result;
442
+  int32_t s = 4 /*sizeof(v)*/ * 8 - 1; /* extra shift needed at end */
443
+
444
+  result = value;                      /* r will be reversed bits of v; first get LSB of v */
445
+  for (value >>= 1U; value; value >>= 1U)
446
+  {
447
+    result <<= 1U;
448
+    result |= value & 1U;
449
+    s--;
450
+  }
451
+  result <<= s;                        /* shift when v's highest bits are zero */
452
+  return(result);
453
+}
454
+#endif
455
+
456
+
457
+/**
458
+  \brief   Count leading zeros
459
+  \details Counts the number of leading zeros of a data value.
460
+  \param [in]  value  Value to count the leading zeros
461
+  \return             number of leading zeros in value
462
+ */
463
+#define __CLZ                             __clz
464
+
465
+
466
+#if       (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U)
467
+
468
+/**
469
+  \brief   LDR Exclusive (8 bit)
470
+  \details Executes a exclusive LDR instruction for 8 bit value.
471
+  \param [in]    ptr  Pointer to data
472
+  \return             value of type uint8_t at (*ptr)
473
+ */
474
+#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
475
+  #define __LDREXB(ptr)                                                        ((uint8_t ) __ldrex(ptr))
476
+#else
477
+  #define __LDREXB(ptr)          _Pragma("push") _Pragma("diag_suppress 3731") ((uint8_t ) __ldrex(ptr))  _Pragma("pop")
478
+#endif
479
+
480
+
481
+/**
482
+  \brief   LDR Exclusive (16 bit)
483
+  \details Executes a exclusive LDR instruction for 16 bit values.
484
+  \param [in]    ptr  Pointer to data
485
+  \return        value of type uint16_t at (*ptr)
486
+ */
487
+#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
488
+  #define __LDREXH(ptr)                                                        ((uint16_t) __ldrex(ptr))
489
+#else
490
+  #define __LDREXH(ptr)          _Pragma("push") _Pragma("diag_suppress 3731") ((uint16_t) __ldrex(ptr))  _Pragma("pop")
491
+#endif
492
+
493
+
494
+/**
495
+  \brief   LDR Exclusive (32 bit)
496
+  \details Executes a exclusive LDR instruction for 32 bit values.
497
+  \param [in]    ptr  Pointer to data
498
+  \return        value of type uint32_t at (*ptr)
499
+ */
500
+#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
501
+  #define __LDREXW(ptr)                                                        ((uint32_t ) __ldrex(ptr))
502
+#else
503
+  #define __LDREXW(ptr)          _Pragma("push") _Pragma("diag_suppress 3731") ((uint32_t ) __ldrex(ptr))  _Pragma("pop")
504
+#endif
505
+
506
+
507
+/**
508
+  \brief   STR Exclusive (8 bit)
509
+  \details Executes a exclusive STR instruction for 8 bit values.
510
+  \param [in]  value  Value to store
511
+  \param [in]    ptr  Pointer to location
512
+  \return          0  Function succeeded
513
+  \return          1  Function failed
514
+ */
515
+#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
516
+  #define __STREXB(value, ptr)                                                 __strex(value, ptr)
517
+#else
518
+  #define __STREXB(value, ptr)   _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr)        _Pragma("pop")
519
+#endif
520
+
521
+
522
+/**
523
+  \brief   STR Exclusive (16 bit)
524
+  \details Executes a exclusive STR instruction for 16 bit values.
525
+  \param [in]  value  Value to store
526
+  \param [in]    ptr  Pointer to location
527
+  \return          0  Function succeeded
528
+  \return          1  Function failed
529
+ */
530
+#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
531
+  #define __STREXH(value, ptr)                                                 __strex(value, ptr)
532
+#else
533
+  #define __STREXH(value, ptr)   _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr)        _Pragma("pop")
534
+#endif
535
+
536
+
537
+/**
538
+  \brief   STR Exclusive (32 bit)
539
+  \details Executes a exclusive STR instruction for 32 bit values.
540
+  \param [in]  value  Value to store
541
+  \param [in]    ptr  Pointer to location
542
+  \return          0  Function succeeded
543
+  \return          1  Function failed
544
+ */
545
+#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
546
+  #define __STREXW(value, ptr)                                                 __strex(value, ptr)
547
+#else
548
+  #define __STREXW(value, ptr)   _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr)        _Pragma("pop")
549
+#endif
550
+
551
+
552
+/**
553
+  \brief   Remove the exclusive lock
554
+  \details Removes the exclusive lock which is created by LDREX.
555
+ */
556
+#define __CLREX                           __clrex
557
+
558
+
559
+/**
560
+  \brief   Signed Saturate
561
+  \details Saturates a signed value.
562
+  \param [in]  value  Value to be saturated
563
+  \param [in]    sat  Bit position to saturate to (1..32)
564
+  \return             Saturated value
565
+ */
566
+#define __SSAT                            __ssat
567
+
568
+
569
+/**
570
+  \brief   Unsigned Saturate
571
+  \details Saturates an unsigned value.
572
+  \param [in]  value  Value to be saturated
573
+  \param [in]    sat  Bit position to saturate to (0..31)
574
+  \return             Saturated value
575
+ */
576
+#define __USAT                            __usat
577
+
578
+
579
+/**
580
+  \brief   Rotate Right with Extend (32 bit)
581
+  \details Moves each bit of a bitstring right by one bit.
582
+           The carry input is shifted in at the left end of the bitstring.
583
+  \param [in]    value  Value to rotate
584
+  \return               Rotated value
585
+ */
586
+#ifndef __NO_EMBEDDED_ASM
587
+__attribute__((section(".rrx_text"))) __STATIC_INLINE __ASM uint32_t __RRX(uint32_t value)
588
+{
589
+  rrx r0, r0
590
+  bx lr
591
+}
592
+#endif
593
+
594
+
595
+/**
596
+  \brief   LDRT Unprivileged (8 bit)
597
+  \details Executes a Unprivileged LDRT instruction for 8 bit value.
598
+  \param [in]    ptr  Pointer to data
599
+  \return             value of type uint8_t at (*ptr)
600
+ */
601
+#define __LDRBT(ptr)                      ((uint8_t )  __ldrt(ptr))
602
+
603
+
604
+/**
605
+  \brief   LDRT Unprivileged (16 bit)
606
+  \details Executes a Unprivileged LDRT instruction for 16 bit values.
607
+  \param [in]    ptr  Pointer to data
608
+  \return        value of type uint16_t at (*ptr)
609
+ */
610
+#define __LDRHT(ptr)                      ((uint16_t)  __ldrt(ptr))
611
+
612
+
613
+/**
614
+  \brief   LDRT Unprivileged (32 bit)
615
+  \details Executes a Unprivileged LDRT instruction for 32 bit values.
616
+  \param [in]    ptr  Pointer to data
617
+  \return        value of type uint32_t at (*ptr)
618
+ */
619
+#define __LDRT(ptr)                       ((uint32_t ) __ldrt(ptr))
620
+
621
+
622
+/**
623
+  \brief   STRT Unprivileged (8 bit)
624
+  \details Executes a Unprivileged STRT instruction for 8 bit values.
625
+  \param [in]  value  Value to store
626
+  \param [in]    ptr  Pointer to location
627
+ */
628
+#define __STRBT(value, ptr)               __strt(value, ptr)
629
+
630
+
631
+/**
632
+  \brief   STRT Unprivileged (16 bit)
633
+  \details Executes a Unprivileged STRT instruction for 16 bit values.
634
+  \param [in]  value  Value to store
635
+  \param [in]    ptr  Pointer to location
636
+ */
637
+#define __STRHT(value, ptr)               __strt(value, ptr)
638
+
639
+
640
+/**
641
+  \brief   STRT Unprivileged (32 bit)
642
+  \details Executes a Unprivileged STRT instruction for 32 bit values.
643
+  \param [in]  value  Value to store
644
+  \param [in]    ptr  Pointer to location
645
+ */
646
+#define __STRT(value, ptr)                __strt(value, ptr)
647
+
648
+#endif /* (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U) */
649
+
650
+/*@}*/ /* end of group CMSIS_Core_InstructionInterface */
651
+
652
+
653
+/* ###################  Compiler specific Intrinsics  ########################### */
654
+/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
655
+  Access to dedicated SIMD instructions
656
+  @{
657
+*/
658
+
659
+#if (__CORTEX_M >= 0x04U)  /* only for Cortex-M4 and above */
660
+
661
+#define __SADD8                           __sadd8
662
+#define __QADD8                           __qadd8
663
+#define __SHADD8                          __shadd8
664
+#define __UADD8                           __uadd8
665
+#define __UQADD8                          __uqadd8
666
+#define __UHADD8                          __uhadd8
667
+#define __SSUB8                           __ssub8
668
+#define __QSUB8                           __qsub8
669
+#define __SHSUB8                          __shsub8
670
+#define __USUB8                           __usub8
671
+#define __UQSUB8                          __uqsub8
672
+#define __UHSUB8                          __uhsub8
673
+#define __SADD16                          __sadd16
674
+#define __QADD16                          __qadd16
675
+#define __SHADD16                         __shadd16
676
+#define __UADD16                          __uadd16
677
+#define __UQADD16                         __uqadd16
678
+#define __UHADD16                         __uhadd16
679
+#define __SSUB16                          __ssub16
680
+#define __QSUB16                          __qsub16
681
+#define __SHSUB16                         __shsub16
682
+#define __USUB16                          __usub16
683
+#define __UQSUB16                         __uqsub16
684
+#define __UHSUB16                         __uhsub16
685
+#define __SASX                            __sasx
686
+#define __QASX                            __qasx
687
+#define __SHASX                           __shasx
688
+#define __UASX                            __uasx
689
+#define __UQASX                           __uqasx
690
+#define __UHASX                           __uhasx
691
+#define __SSAX                            __ssax
692
+#define __QSAX                            __qsax
693
+#define __SHSAX                           __shsax
694
+#define __USAX                            __usax
695
+#define __UQSAX                           __uqsax
696
+#define __UHSAX                           __uhsax
697
+#define __USAD8                           __usad8
698
+#define __USADA8                          __usada8
699
+#define __SSAT16                          __ssat16
700
+#define __USAT16                          __usat16
701
+#define __UXTB16                          __uxtb16
702
+#define __UXTAB16                         __uxtab16
703
+#define __SXTB16                          __sxtb16
704
+#define __SXTAB16                         __sxtab16
705
+#define __SMUAD                           __smuad
706
+#define __SMUADX                          __smuadx
707
+#define __SMLAD                           __smlad
708
+#define __SMLADX                          __smladx
709
+#define __SMLALD                          __smlald
710
+#define __SMLALDX                         __smlaldx
711
+#define __SMUSD                           __smusd
712
+#define __SMUSDX                          __smusdx
713
+#define __SMLSD                           __smlsd
714
+#define __SMLSDX                          __smlsdx
715
+#define __SMLSLD                          __smlsld
716
+#define __SMLSLDX                         __smlsldx
717
+#define __SEL                             __sel
718
+#define __QADD                            __qadd
719
+#define __QSUB                            __qsub
720
+
721
+#define __PKHBT(ARG1,ARG2,ARG3)          ( ((((uint32_t)(ARG1))          ) & 0x0000FFFFUL) |  \
722
+                                           ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL)  )
723
+
724
+#define __PKHTB(ARG1,ARG2,ARG3)          ( ((((uint32_t)(ARG1))          ) & 0xFFFF0000UL) |  \
725
+                                           ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL)  )
726
+
727
+#define __SMMLA(ARG1,ARG2,ARG3)          ( (int32_t)((((int64_t)(ARG1) * (ARG2)) + \
728
+                                                      ((int64_t)(ARG3) << 32U)     ) >> 32U))
729
+
730
+#endif /* (__CORTEX_M >= 0x04) */
731
+/*@} end of group CMSIS_SIMD_intrinsics */
732
+
733
+
734
+#endif /* __CMSIS_ARMCC_H */

文件差异内容过多而无法显示
+ 1800 - 0
Drivers/CMSIS/Include/cmsis_armcc_V6.h


文件差异内容过多而无法显示
+ 1373 - 0
Drivers/CMSIS/Include/cmsis_gcc.h


+ 798 - 0
Drivers/CMSIS/Include/core_cm0.h

@@ -0,0 +1,798 @@
1
+/**************************************************************************//**
2
+ * @file     core_cm0.h
3
+ * @brief    CMSIS Cortex-M0 Core Peripheral Access Layer Header File
4
+ * @version  V4.30
5
+ * @date     20. October 2015
6
+ ******************************************************************************/
7
+/* Copyright (c) 2009 - 2015 ARM LIMITED
8
+
9
+   All rights reserved.
10
+   Redistribution and use in source and binary forms, with or without
11
+   modification, are permitted provided that the following conditions are met:
12
+   - Redistributions of source code must retain the above copyright
13
+     notice, this list of conditions and the following disclaimer.
14
+   - Redistributions in binary form must reproduce the above copyright
15
+     notice, this list of conditions and the following disclaimer in the
16
+     documentation and/or other materials provided with the distribution.
17
+   - Neither the name of ARM nor the names of its contributors may be used
18
+     to endorse or promote products derived from this software without
19
+     specific prior written permission.
20
+   *
21
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22
+   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23
+   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24
+   ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
25
+   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26
+   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27
+   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
+   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
+   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
+   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
+   POSSIBILITY OF SUCH DAMAGE.
32
+   ---------------------------------------------------------------------------*/
33
+
34
+
35
+#if   defined ( __ICCARM__ )
36
+ #pragma system_include         /* treat file as system include file for MISRA check */
37
+#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
38
+  #pragma clang system_header   /* treat file as system include file */
39
+#endif
40
+
41
+#ifndef __CORE_CM0_H_GENERIC
42
+#define __CORE_CM0_H_GENERIC
43
+
44
+#include <stdint.h>
45
+
46
+#ifdef __cplusplus
47
+ extern "C" {
48
+#endif
49
+
50
+/**
51
+  \page CMSIS_MISRA_Exceptions  MISRA-C:2004 Compliance Exceptions
52
+  CMSIS violates the following MISRA-C:2004 rules:
53
+
54
+   \li Required Rule 8.5, object/function definition in header file.<br>
55
+     Function definitions in header files are used to allow 'inlining'.
56
+
57
+   \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.<br>
58
+     Unions are used for effective representation of core registers.
59
+
60
+   \li Advisory Rule 19.7, Function-like macro defined.<br>
61
+     Function-like macros are used to allow more efficient code.
62
+ */
63
+
64
+
65
+/*******************************************************************************
66
+ *                 CMSIS definitions
67
+ ******************************************************************************/
68
+/**
69
+  \ingroup Cortex_M0
70
+  @{
71
+ */
72
+
73
+/*  CMSIS CM0 definitions */
74
+#define __CM0_CMSIS_VERSION_MAIN  (0x04U)                                      /*!< [31:16] CMSIS HAL main version */
75
+#define __CM0_CMSIS_VERSION_SUB   (0x1EU)                                      /*!< [15:0]  CMSIS HAL sub version */
76
+#define __CM0_CMSIS_VERSION       ((__CM0_CMSIS_VERSION_MAIN << 16U) | \
77
+                                    __CM0_CMSIS_VERSION_SUB           )        /*!< CMSIS HAL version number */
78
+
79
+#define __CORTEX_M                (0x00U)                                      /*!< Cortex-M Core */
80
+
81
+
82
+#if   defined ( __CC_ARM )
83
+  #define __ASM            __asm                                      /*!< asm keyword for ARM Compiler */
84
+  #define __INLINE         __inline                                   /*!< inline keyword for ARM Compiler */
85
+  #define __STATIC_INLINE  static __inline
86
+
87
+#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
88
+  #define __ASM            __asm                                      /*!< asm keyword for ARM Compiler */
89
+  #define __INLINE         __inline                                   /*!< inline keyword for ARM Compiler */
90
+  #define __STATIC_INLINE  static __inline
91
+
92
+#elif defined ( __GNUC__ )
93
+  #define __ASM            __asm                                      /*!< asm keyword for GNU Compiler */
94
+  #define __INLINE         inline                                     /*!< inline keyword for GNU Compiler */
95
+  #define __STATIC_INLINE  static inline
96
+
97
+#elif defined ( __ICCARM__ )
98
+  #define __ASM            __asm                                      /*!< asm keyword for IAR Compiler */
99
+  #define __INLINE         inline                                     /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */
100
+  #define __STATIC_INLINE  static inline
101
+
102
+#elif defined ( __TMS470__ )
103
+  #define __ASM            __asm                                      /*!< asm keyword for TI CCS Compiler */
104
+  #define __STATIC_INLINE  static inline
105
+
106
+#elif defined ( __TASKING__ )
107
+  #define __ASM            __asm                                      /*!< asm keyword for TASKING Compiler */
108
+  #define __INLINE         inline                                     /*!< inline keyword for TASKING Compiler */
109
+  #define __STATIC_INLINE  static inline
110
+
111
+#elif defined ( __CSMC__ )
112
+  #define __packed
113
+  #define __ASM            _asm                                      /*!< asm keyword for COSMIC Compiler */
114
+  #define __INLINE         inline                                    /*!< inline keyword for COSMIC Compiler. Use -pc99 on compile line */
115
+  #define __STATIC_INLINE  static inline
116
+
117
+#else
118
+  #error Unknown compiler
119
+#endif
120
+
121
+/** __FPU_USED indicates whether an FPU is used or not.
122
+    This core does not support an FPU at all
123
+*/
124
+#define __FPU_USED       0U
125
+
126
+#if defined ( __CC_ARM )
127
+  #if defined __TARGET_FPU_VFP
128
+    #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
129
+  #endif
130
+
131
+#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
132
+  #if defined __ARM_PCS_VFP
133
+    #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
134
+  #endif
135
+
136
+#elif defined ( __GNUC__ )
137
+  #if defined (__VFP_FP__) && !defined(__SOFTFP__)
138
+    #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
139
+  #endif
140
+
141
+#elif defined ( __ICCARM__ )
142
+  #if defined __ARMVFP__
143
+    #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
144
+  #endif
145
+
146
+#elif defined ( __TMS470__ )
147
+  #if defined __TI_VFP_SUPPORT__
148
+    #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
149
+  #endif
150
+
151
+#elif defined ( __TASKING__ )
152
+  #if defined __FPU_VFP__
153
+    #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
154
+  #endif
155
+
156
+#elif defined ( __CSMC__ )
157
+  #if ( __CSMC__ & 0x400U)
158
+    #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
159
+  #endif
160
+
161
+#endif
162
+
163
+#include "core_cmInstr.h"                /* Core Instruction Access */
164
+#include "core_cmFunc.h"                 /* Core Function Access */
165
+
166
+#ifdef __cplusplus
167
+}
168
+#endif
169
+
170
+#endif /* __CORE_CM0_H_GENERIC */
171
+
172
+#ifndef __CMSIS_GENERIC
173
+
174
+#ifndef __CORE_CM0_H_DEPENDANT
175
+#define __CORE_CM0_H_DEPENDANT
176
+
177
+#ifdef __cplusplus
178
+ extern "C" {
179
+#endif
180
+
181
+/* check device defines and use defaults */
182
+#if defined __CHECK_DEVICE_DEFINES
183
+  #ifndef __CM0_REV
184
+    #define __CM0_REV               0x0000U
185
+    #warning "__CM0_REV not defined in device header file; using default!"
186
+  #endif
187
+
188
+  #ifndef __NVIC_PRIO_BITS
189
+    #define __NVIC_PRIO_BITS          2U
190
+    #warning "__NVIC_PRIO_BITS not defined in device header file; using default!"
191
+  #endif
192
+
193
+  #ifndef __Vendor_SysTickConfig
194
+    #define __Vendor_SysTickConfig    0U
195
+    #warning "__Vendor_SysTickConfig not defined in device header file; using default!"
196
+  #endif
197
+#endif
198
+
199
+/* IO definitions (access restrictions to peripheral registers) */
200
+/**
201
+    \defgroup CMSIS_glob_defs CMSIS Global Defines
202
+
203
+    <strong>IO Type Qualifiers</strong> are used
204
+    \li to specify the access to peripheral variables.
205
+    \li for automatic generation of peripheral register debug information.
206
+*/
207
+#ifdef __cplusplus
208
+  #define   __I     volatile             /*!< Defines 'read only' permissions */
209
+#else
210
+  #define   __I     volatile const       /*!< Defines 'read only' permissions */
211
+#endif
212
+#define     __O     volatile             /*!< Defines 'write only' permissions */
213
+#define     __IO    volatile             /*!< Defines 'read / write' permissions */
214
+
215
+/* following defines should be used for structure members */
216
+#define     __IM     volatile const      /*! Defines 'read only' structure member permissions */
217
+#define     __OM     volatile            /*! Defines 'write only' structure member permissions */
218
+#define     __IOM    volatile            /*! Defines 'read / write' structure member permissions */
219
+
220
+/*@} end of group Cortex_M0 */
221
+
222
+
223
+
224
+/*******************************************************************************
225
+ *                 Register Abstraction
226
+  Core Register contain:
227
+  - Core Register
228
+  - Core NVIC Register
229
+  - Core SCB Register
230
+  - Core SysTick Register
231
+ ******************************************************************************/
232
+/**
233
+  \defgroup CMSIS_core_register Defines and Type Definitions
234
+  \brief Type definitions and defines for Cortex-M processor based devices.
235
+*/
236
+
237
+/**
238
+  \ingroup    CMSIS_core_register
239
+  \defgroup   CMSIS_CORE  Status and Control Registers
240
+  \brief      Core Register type definitions.
241
+  @{
242
+ */
243
+
244
+/**
245
+  \brief  Union type to access the Application Program Status Register (APSR).
246
+ */
247
+typedef union
248
+{
249
+  struct
250
+  {
251
+    uint32_t _reserved0:28;              /*!< bit:  0..27  Reserved */
252
+    uint32_t V:1;                        /*!< bit:     28  Overflow condition code flag */
253
+    uint32_t C:1;                        /*!< bit:     29  Carry condition code flag */
254
+    uint32_t Z:1;                        /*!< bit:     30  Zero condition code flag */
255
+    uint32_t N:1;                        /*!< bit:     31  Negative condition code flag */
256
+  } b;                                   /*!< Structure used for bit  access */
257
+  uint32_t w;                            /*!< Type      used for word access */
258
+} APSR_Type;
259
+
260
+/* APSR Register Definitions */
261
+#define APSR_N_Pos                         31U                                            /*!< APSR: N Position */
262
+#define APSR_N_Msk                         (1UL << APSR_N_Pos)                            /*!< APSR: N Mask */
263
+
264
+#define APSR_Z_Pos                         30U                                            /*!< APSR: Z Position */
265
+#define APSR_Z_Msk                         (1UL << APSR_Z_Pos)                            /*!< APSR: Z Mask */
266
+
267
+#define APSR_C_Pos                         29U                                            /*!< APSR: C Position */
268
+#define APSR_C_Msk                         (1UL << APSR_C_Pos)                            /*!< APSR: C Mask */
269
+
270
+#define APSR_V_Pos                         28U                                            /*!< APSR: V Position */
271
+#define APSR_V_Msk                         (1UL << APSR_V_Pos)                            /*!< APSR: V Mask */
272
+
273
+
274
+/**
275
+  \brief  Union type to access the Interrupt Program Status Register (IPSR).
276
+ */
277
+typedef union
278
+{
279
+  struct
280
+  {
281
+    uint32_t ISR:9;                      /*!< bit:  0.. 8  Exception number */
282
+    uint32_t _reserved0:23;              /*!< bit:  9..31  Reserved */
283
+  } b;                                   /*!< Structure used for bit  access */
284
+  uint32_t w;                            /*!< Type      used for word access */
285
+} IPSR_Type;
286
+
287
+/* IPSR Register Definitions */
288
+#define IPSR_ISR_Pos                        0U                                            /*!< IPSR: ISR Position */
289
+#define IPSR_ISR_Msk                       (0x1FFUL /*<< IPSR_ISR_Pos*/)                  /*!< IPSR: ISR Mask */
290
+
291
+
292
+/**
293
+  \brief  Union type to access the Special-Purpose Program Status Registers (xPSR).
294
+ */
295
+typedef union
296
+{
297
+  struct
298
+  {
299
+    uint32_t ISR:9;                      /*!< bit:  0.. 8  Exception number */
300
+    uint32_t _reserved0:15;              /*!< bit:  9..23  Reserved */
301
+    uint32_t T:1;                        /*!< bit:     24  Thumb bit        (read 0) */
302
+    uint32_t _reserved1:3;               /*!< bit: 25..27  Reserved */
303
+    uint32_t V:1;                        /*!< bit:     28  Overflow condition code flag */
304
+    uint32_t C:1;                        /*!< bit:     29  Carry condition code flag */
305
+    uint32_t Z:1;                        /*!< bit:     30  Zero condition code flag */
306
+    uint32_t N:1;                        /*!< bit:     31  Negative condition code flag */
307
+  } b;                                   /*!< Structure used for bit  access */
308
+  uint32_t w;                            /*!< Type      used for word access */
309
+} xPSR_Type;
310
+
311
+/* xPSR Register Definitions */
312
+#define xPSR_N_Pos                         31U                                            /*!< xPSR: N Position */
313
+#define xPSR_N_Msk                         (1UL << xPSR_N_Pos)                            /*!< xPSR: N Mask */
314
+
315
+#define xPSR_Z_Pos                         30U                                            /*!< xPSR: Z Position */
316
+#define xPSR_Z_Msk                         (1UL << xPSR_Z_Pos)                            /*!< xPSR: Z Mask */
317
+
318
+#define xPSR_C_Pos                         29U                                            /*!< xPSR: C Position */
319
+#define xPSR_C_Msk                         (1UL << xPSR_C_Pos)                            /*!< xPSR: C Mask */
320
+
321
+#define xPSR_V_Pos                         28U                                            /*!< xPSR: V Position */
322
+#define xPSR_V_Msk                         (1UL << xPSR_V_Pos)                            /*!< xPSR: V Mask */
323
+
324
+#define xPSR_T_Pos                         24U                                            /*!< xPSR: T Position */
325
+#define xPSR_T_Msk                         (1UL << xPSR_T_Pos)                            /*!< xPSR: T Mask */
326
+
327
+#define xPSR_ISR_Pos                        0U                                            /*!< xPSR: ISR Position */
328
+#define xPSR_ISR_Msk                       (0x1FFUL /*<< xPSR_ISR_Pos*/)                  /*!< xPSR: ISR Mask */
329
+
330
+
331
+/**
332
+  \brief  Union type to access the Control Registers (CONTROL).
333
+ */
334
+typedef union
335
+{
336
+  struct
337
+  {
338
+    uint32_t _reserved0:1;               /*!< bit:      0  Reserved */
339
+    uint32_t SPSEL:1;                    /*!< bit:      1  Stack to be used */
340
+    uint32_t _reserved1:30;              /*!< bit:  2..31  Reserved */
341
+  } b;                                   /*!< Structure used for bit  access */
342
+  uint32_t w;                            /*!< Type      used for word access */
343
+} CONTROL_Type;
344
+
345
+/* CONTROL Register Definitions */
346
+#define CONTROL_SPSEL_Pos                   1U                                            /*!< CONTROL: SPSEL Position */
347
+#define CONTROL_SPSEL_Msk                  (1UL << CONTROL_SPSEL_Pos)                     /*!< CONTROL: SPSEL Mask */
348
+
349
+/*@} end of group CMSIS_CORE */
350
+
351
+
352
+/**
353
+  \ingroup    CMSIS_core_register
354
+  \defgroup   CMSIS_NVIC  Nested Vectored Interrupt Controller (NVIC)
355
+  \brief      Type definitions for the NVIC Registers
356
+  @{
357
+ */
358
+
359
+/**
360
+  \brief  Structure type to access the Nested Vectored Interrupt Controller (NVIC).
361
+ */
362
+typedef struct
363
+{
364
+  __IOM uint32_t ISER[1U];               /*!< Offset: 0x000 (R/W)  Interrupt Set Enable Register */
365
+        uint32_t RESERVED0[31U];
366
+  __IOM uint32_t ICER[1U];               /*!< Offset: 0x080 (R/W)  Interrupt Clear Enable Register */
367
+        uint32_t RSERVED1[31U];
368
+  __IOM uint32_t ISPR[1U];               /*!< Offset: 0x100 (R/W)  Interrupt Set Pending Register */
369
+        uint32_t RESERVED2[31U];
370
+  __IOM uint32_t ICPR[1U];               /*!< Offset: 0x180 (R/W)  Interrupt Clear Pending Register */
371
+        uint32_t RESERVED3[31U];
372
+        uint32_t RESERVED4[64U];
373
+  __IOM uint32_t IP[8U];                 /*!< Offset: 0x300 (R/W)  Interrupt Priority Register */
374
+}  NVIC_Type;
375
+
376
+/*@} end of group CMSIS_NVIC */
377
+
378
+
379
+/**
380
+  \ingroup  CMSIS_core_register
381
+  \defgroup CMSIS_SCB     System Control Block (SCB)
382
+  \brief    Type definitions for the System Control Block Registers
383
+  @{
384
+ */
385
+
386
+/**
387
+  \brief  Structure type to access the System Control Block (SCB).
388
+ */
389
+typedef struct
390
+{
391
+  __IM  uint32_t CPUID;                  /*!< Offset: 0x000 (R/ )  CPUID Base Register */
392
+  __IOM uint32_t ICSR;                   /*!< Offset: 0x004 (R/W)  Interrupt Control and State Register */
393
+        uint32_t RESERVED0;
394
+  __IOM uint32_t AIRCR;                  /*!< Offset: 0x00C (R/W)  Application Interrupt and Reset Control Register */
395
+  __IOM uint32_t SCR;                    /*!< Offset: 0x010 (R/W)  System Control Register */
396
+  __IOM uint32_t CCR;                    /*!< Offset: 0x014 (R/W)  Configuration Control Register */
397
+        uint32_t RESERVED1;
398
+  __IOM uint32_t SHP[2U];                /*!< Offset: 0x01C (R/W)  System Handlers Priority Registers. [0] is RESERVED */
399
+  __IOM uint32_t SHCSR;                  /*!< Offset: 0x024 (R/W)  System Handler Control and State Register */
400
+} SCB_Type;
401
+
402
+/* SCB CPUID Register Definitions */
403
+#define SCB_CPUID_IMPLEMENTER_Pos          24U                                            /*!< SCB CPUID: IMPLEMENTER Position */
404
+#define SCB_CPUID_IMPLEMENTER_Msk          (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos)          /*!< SCB CPUID: IMPLEMENTER Mask */
405
+
406
+#define SCB_CPUID_VARIANT_Pos              20U                                            /*!< SCB CPUID: VARIANT Position */
407
+#define SCB_CPUID_VARIANT_Msk              (0xFUL << SCB_CPUID_VARIANT_Pos)               /*!< SCB CPUID: VARIANT Mask */
408
+
409
+#define SCB_CPUID_ARCHITECTURE_Pos         16U                                            /*!< SCB CPUID: ARCHITECTURE Position */
410
+#define SCB_CPUID_ARCHITECTURE_Msk         (0xFUL << SCB_CPUID_ARCHITECTURE_Pos)          /*!< SCB CPUID: ARCHITECTURE Mask */
411
+
412
+#define SCB_CPUID_PARTNO_Pos                4U                                            /*!< SCB CPUID: PARTNO Position */
413
+#define SCB_CPUID_PARTNO_Msk               (0xFFFUL << SCB_CPUID_PARTNO_Pos)              /*!< SCB CPUID: PARTNO Mask */
414
+
415
+#define SCB_CPUID_REVISION_Pos              0U                                            /*!< SCB CPUID: REVISION Position */
416
+#define SCB_CPUID_REVISION_Msk             (0xFUL /*<< SCB_CPUID_REVISION_Pos*/)          /*!< SCB CPUID: REVISION Mask */
417
+
418
+/* SCB Interrupt Control State Register Definitions */
419
+#define SCB_ICSR_NMIPENDSET_Pos            31U                                            /*!< SCB ICSR: NMIPENDSET Position */
420
+#define SCB_ICSR_NMIPENDSET_Msk            (1UL << SCB_ICSR_NMIPENDSET_Pos)               /*!< SCB ICSR: NMIPENDSET Mask */
421
+
422
+#define SCB_ICSR_PENDSVSET_Pos             28U                                            /*!< SCB ICSR: PENDSVSET Position */
423
+#define SCB_ICSR_PENDSVSET_Msk             (1UL << SCB_ICSR_PENDSVSET_Pos)                /*!< SCB ICSR: PENDSVSET Mask */
424
+
425
+#define SCB_ICSR_PENDSVCLR_Pos             27U                                            /*!< SCB ICSR: PENDSVCLR Position */
426
+#define SCB_ICSR_PENDSVCLR_Msk             (1UL << SCB_ICSR_PENDSVCLR_Pos)                /*!< SCB ICSR: PENDSVCLR Mask */
427
+
428
+#define SCB_ICSR_PENDSTSET_Pos             26U                                            /*!< SCB ICSR: PENDSTSET Position */
429
+#define SCB_ICSR_PENDSTSET_Msk             (1UL << SCB_ICSR_PENDSTSET_Pos)                /*!< SCB ICSR: PENDSTSET Mask */
430
+
431
+#define SCB_ICSR_PENDSTCLR_Pos             25U                                            /*!< SCB ICSR: PENDSTCLR Position */
432
+#define SCB_ICSR_PENDSTCLR_Msk             (1UL << SCB_ICSR_PENDSTCLR_Pos)                /*!< SCB ICSR: PENDSTCLR Mask */
433
+
434
+#define SCB_ICSR_ISRPREEMPT_Pos            23U                                            /*!< SCB ICSR: ISRPREEMPT Position */
435
+#define SCB_ICSR_ISRPREEMPT_Msk            (1UL << SCB_ICSR_ISRPREEMPT_Pos)               /*!< SCB ICSR: ISRPREEMPT Mask */
436
+
437
+#define SCB_ICSR_ISRPENDING_Pos            22U                                            /*!< SCB ICSR: ISRPENDING Position */
438
+#define SCB_ICSR_ISRPENDING_Msk            (1UL << SCB_ICSR_ISRPENDING_Pos)               /*!< SCB ICSR: ISRPENDING Mask */
439
+
440
+#define SCB_ICSR_VECTPENDING_Pos           12U                                            /*!< SCB ICSR: VECTPENDING Position */
441
+#define SCB_ICSR_VECTPENDING_Msk           (0x1FFUL << SCB_ICSR_VECTPENDING_Pos)          /*!< SCB ICSR: VECTPENDING Mask */
442
+
443
+#define SCB_ICSR_VECTACTIVE_Pos             0U                                            /*!< SCB ICSR: VECTACTIVE Position */
444
+#define SCB_ICSR_VECTACTIVE_Msk            (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/)       /*!< SCB ICSR: VECTACTIVE Mask */
445
+
446
+/* SCB Application Interrupt and Reset Control Register Definitions */
447
+#define SCB_AIRCR_VECTKEY_Pos              16U                                            /*!< SCB AIRCR: VECTKEY Position */
448
+#define SCB_AIRCR_VECTKEY_Msk              (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos)            /*!< SCB AIRCR: VECTKEY Mask */
449
+
450
+#define SCB_AIRCR_VECTKEYSTAT_Pos          16U                                            /*!< SCB AIRCR: VECTKEYSTAT Position */
451
+#define SCB_AIRCR_VECTKEYSTAT_Msk          (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos)        /*!< SCB AIRCR: VECTKEYSTAT Mask */
452
+
453
+#define SCB_AIRCR_ENDIANESS_Pos            15U                                            /*!< SCB AIRCR: ENDIANESS Position */
454
+#define SCB_AIRCR_ENDIANESS_Msk            (1UL << SCB_AIRCR_ENDIANESS_Pos)               /*!< SCB AIRCR: ENDIANESS Mask */
455
+
456
+#define SCB_AIRCR_SYSRESETREQ_Pos           2U                                            /*!< SCB AIRCR: SYSRESETREQ Position */
457
+#define SCB_AIRCR_SYSRESETREQ_Msk          (1UL << SCB_AIRCR_SYSRESETREQ_Pos)             /*!< SCB AIRCR: SYSRESETREQ Mask */
458
+
459
+#define SCB_AIRCR_VECTCLRACTIVE_Pos         1U                                            /*!< SCB AIRCR: VECTCLRACTIVE Position */
460
+#define SCB_AIRCR_VECTCLRACTIVE_Msk        (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos)           /*!< SCB AIRCR: VECTCLRACTIVE Mask */
461
+
462
+/* SCB System Control Register Definitions */
463
+#define SCB_SCR_SEVONPEND_Pos               4U                                            /*!< SCB SCR: SEVONPEND Position */
464
+#define SCB_SCR_SEVONPEND_Msk              (1UL << SCB_SCR_SEVONPEND_Pos)                 /*!< SCB SCR: SEVONPEND Mask */
465
+
466
+#define SCB_SCR_SLEEPDEEP_Pos               2U                                            /*!< SCB SCR: SLEEPDEEP Position */
467
+#define SCB_SCR_SLEEPDEEP_Msk              (1UL << SCB_SCR_SLEEPDEEP_Pos)                 /*!< SCB SCR: SLEEPDEEP Mask */
468
+
469
+#define SCB_SCR_SLEEPONEXIT_Pos             1U                                            /*!< SCB SCR: SLEEPONEXIT Position */
470
+#define SCB_SCR_SLEEPONEXIT_Msk            (1UL << SCB_SCR_SLEEPONEXIT_Pos)               /*!< SCB SCR: SLEEPONEXIT Mask */
471
+
472
+/* SCB Configuration Control Register Definitions */
473
+#define SCB_CCR_STKALIGN_Pos                9U                                            /*!< SCB CCR: STKALIGN Position */
474
+#define SCB_CCR_STKALIGN_Msk               (1UL << SCB_CCR_STKALIGN_Pos)                  /*!< SCB CCR: STKALIGN Mask */
475
+
476
+#define SCB_CCR_UNALIGN_TRP_Pos             3U                                            /*!< SCB CCR: UNALIGN_TRP Position */
477
+#define SCB_CCR_UNALIGN_TRP_Msk            (1UL << SCB_CCR_UNALIGN_TRP_Pos)               /*!< SCB CCR: UNALIGN_TRP Mask */
478
+
479
+/* SCB System Handler Control and State Register Definitions */
480
+#define SCB_SHCSR_SVCALLPENDED_Pos         15U                                            /*!< SCB SHCSR: SVCALLPENDED Position */
481
+#define SCB_SHCSR_SVCALLPENDED_Msk         (1UL << SCB_SHCSR_SVCALLPENDED_Pos)            /*!< SCB SHCSR: SVCALLPENDED Mask */
482
+
483
+/*@} end of group CMSIS_SCB */
484
+
485
+
486
+/**
487
+  \ingroup  CMSIS_core_register
488
+  \defgroup CMSIS_SysTick     System Tick Timer (SysTick)
489
+  \brief    Type definitions for the System Timer Registers.
490
+  @{
491
+ */
492
+
493
+/**
494
+  \brief  Structure type to access the System Timer (SysTick).
495
+ */
496
+typedef struct
497
+{
498
+  __IOM uint32_t CTRL;                   /*!< Offset: 0x000 (R/W)  SysTick Control and Status Register */
499
+  __IOM uint32_t LOAD;                   /*!< Offset: 0x004 (R/W)  SysTick Reload Value Register */
500
+  __IOM uint32_t VAL;                    /*!< Offset: 0x008 (R/W)  SysTick Current Value Register */
501
+  __IM  uint32_t CALIB;                  /*!< Offset: 0x00C (R/ )  SysTick Calibration Register */
502
+} SysTick_Type;
503
+
504
+/* SysTick Control / Status Register Definitions */
505
+#define SysTick_CTRL_COUNTFLAG_Pos         16U                                            /*!< SysTick CTRL: COUNTFLAG Position */
506
+#define SysTick_CTRL_COUNTFLAG_Msk         (1UL << SysTick_CTRL_COUNTFLAG_Pos)            /*!< SysTick CTRL: COUNTFLAG Mask */
507
+
508
+#define SysTick_CTRL_CLKSOURCE_Pos          2U                                            /*!< SysTick CTRL: CLKSOURCE Position */
509
+#define SysTick_CTRL_CLKSOURCE_Msk         (1UL << SysTick_CTRL_CLKSOURCE_Pos)            /*!< SysTick CTRL: CLKSOURCE Mask */
510
+
511
+#define SysTick_CTRL_TICKINT_Pos            1U                                            /*!< SysTick CTRL: TICKINT Position */
512
+#define SysTick_CTRL_TICKINT_Msk           (1UL << SysTick_CTRL_TICKINT_Pos)              /*!< SysTick CTRL: TICKINT Mask */
513
+
514
+#define SysTick_CTRL_ENABLE_Pos             0U                                            /*!< SysTick CTRL: ENABLE Position */
515
+#define SysTick_CTRL_ENABLE_Msk            (1UL /*<< SysTick_CTRL_ENABLE_Pos*/)           /*!< SysTick CTRL: ENABLE Mask */
516
+
517
+/* SysTick Reload Register Definitions */
518
+#define SysTick_LOAD_RELOAD_Pos             0U                                            /*!< SysTick LOAD: RELOAD Position */
519
+#define SysTick_LOAD_RELOAD_Msk            (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/)    /*!< SysTick LOAD: RELOAD Mask */
520
+
521
+/* SysTick Current Register Definitions */
522
+#define SysTick_VAL_CURRENT_Pos             0U                                            /*!< SysTick VAL: CURRENT Position */
523
+#define SysTick_VAL_CURRENT_Msk            (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/)    /*!< SysTick VAL: CURRENT Mask */
524
+
525
+/* SysTick Calibration Register Definitions */
526
+#define SysTick_CALIB_NOREF_Pos            31U                                            /*!< SysTick CALIB: NOREF Position */
527
+#define SysTick_CALIB_NOREF_Msk            (1UL << SysTick_CALIB_NOREF_Pos)               /*!< SysTick CALIB: NOREF Mask */
528
+
529
+#define SysTick_CALIB_SKEW_Pos             30U                                            /*!< SysTick CALIB: SKEW Position */
530
+#define SysTick_CALIB_SKEW_Msk             (1UL << SysTick_CALIB_SKEW_Pos)                /*!< SysTick CALIB: SKEW Mask */
531
+
532
+#define SysTick_CALIB_TENMS_Pos             0U                                            /*!< SysTick CALIB: TENMS Position */
533
+#define SysTick_CALIB_TENMS_Msk            (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/)    /*!< SysTick CALIB: TENMS Mask */
534
+
535
+/*@} end of group CMSIS_SysTick */
536
+
537
+
538
+/**
539
+  \ingroup  CMSIS_core_register
540
+  \defgroup CMSIS_CoreDebug       Core Debug Registers (CoreDebug)
541
+  \brief    Cortex-M0 Core Debug Registers (DCB registers, SHCSR, and DFSR) are only accessible over DAP and not via processor.
542
+            Therefore they are not covered by the Cortex-M0 header file.
543
+  @{
544
+ */
545
+/*@} end of group CMSIS_CoreDebug */
546
+
547
+
548
+/**
549
+  \ingroup    CMSIS_core_register
550
+  \defgroup   CMSIS_core_bitfield     Core register bit field macros
551
+  \brief      Macros for use with bit field definitions (xxx_Pos, xxx_Msk).
552
+  @{
553
+ */
554
+
555
+/**
556
+  \brief   Mask and shift a bit field value for use in a register bit range.
557
+  \param[in] field  Name of the register bit field.
558
+  \param[in] value  Value of the bit field.
559
+  \return           Masked and shifted value.
560
+*/
561
+#define _VAL2FLD(field, value)    ((value << field ## _Pos) & field ## _Msk)
562
+
563
+/**
564
+  \brief     Mask and shift a register value to extract a bit filed value.
565
+  \param[in] field  Name of the register bit field.
566
+  \param[in] value  Value of register.
567
+  \return           Masked and shifted bit field value.
568
+*/
569
+#define _FLD2VAL(field, value)    ((value & field ## _Msk) >> field ## _Pos)
570
+
571
+/*@} end of group CMSIS_core_bitfield */
572
+
573
+
574
+/**
575
+  \ingroup    CMSIS_core_register
576
+  \defgroup   CMSIS_core_base     Core Definitions
577
+  \brief      Definitions for base addresses, unions, and structures.
578
+  @{
579
+ */
580
+
581
+/* Memory mapping of Cortex-M0 Hardware */
582
+#define SCS_BASE            (0xE000E000UL)                            /*!< System Control Space Base Address */
583
+#define SysTick_BASE        (SCS_BASE +  0x0010UL)                    /*!< SysTick Base Address */
584
+#define NVIC_BASE           (SCS_BASE +  0x0100UL)                    /*!< NVIC Base Address */
585
+#define SCB_BASE            (SCS_BASE +  0x0D00UL)                    /*!< System Control Block Base Address */
586
+
587
+#define SCB                 ((SCB_Type       *)     SCB_BASE      )   /*!< SCB configuration struct */
588
+#define SysTick             ((SysTick_Type   *)     SysTick_BASE  )   /*!< SysTick configuration struct */
589
+#define NVIC                ((NVIC_Type      *)     NVIC_BASE     )   /*!< NVIC configuration struct */
590
+
591
+
592
+/*@} */
593
+
594
+
595
+
596
+/*******************************************************************************
597
+ *                Hardware Abstraction Layer
598
+  Core Function Interface contains:
599
+  - Core NVIC Functions
600
+  - Core SysTick Functions
601
+  - Core Register Access Functions
602
+ ******************************************************************************/
603
+/**
604
+  \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference
605
+*/
606
+
607
+
608
+
609
+/* ##########################   NVIC functions  #################################### */
610
+/**
611
+  \ingroup  CMSIS_Core_FunctionInterface
612
+  \defgroup CMSIS_Core_NVICFunctions NVIC Functions
613
+  \brief    Functions that manage interrupts and exceptions via the NVIC.
614
+  @{
615
+ */
616
+
617
+/* Interrupt Priorities are WORD accessible only under ARMv6M                   */
618
+/* The following MACROS handle generation of the register offset and byte masks */
619
+#define _BIT_SHIFT(IRQn)         (  ((((uint32_t)(int32_t)(IRQn))         )      &  0x03UL) * 8UL)
620
+#define _SHP_IDX(IRQn)           ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >>    2UL)      )
621
+#define _IP_IDX(IRQn)            (   (((uint32_t)(int32_t)(IRQn))                >>    2UL)      )
622
+
623
+
624
+/**
625
+  \brief   Enable External Interrupt
626
+  \details Enables a device-specific interrupt in the NVIC interrupt controller.
627
+  \param [in]      IRQn  External interrupt number. Value cannot be negative.
628
+ */
629
+__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)
630
+{
631
+  NVIC->ISER[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
632
+}
633
+
634
+
635
+/**
636
+  \brief   Disable External Interrupt
637
+  \details Disables a device-specific interrupt in the NVIC interrupt controller.
638
+  \param [in]      IRQn  External interrupt number. Value cannot be negative.
639
+ */
640
+__STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn)
641
+{
642
+  NVIC->ICER[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
643
+}
644
+
645
+
646
+/**
647
+  \brief   Get Pending Interrupt
648
+  \details Reads the pending register in the NVIC and returns the pending bit for the specified interrupt.
649
+  \param [in]      IRQn  Interrupt number.
650
+  \return             0  Interrupt status is not pending.
651
+  \return             1  Interrupt status is pending.
652
+ */
653
+__STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn)
654
+{
655
+  return((uint32_t)(((NVIC->ISPR[0U] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
656
+}
657
+
658
+
659
+/**
660
+  \brief   Set Pending Interrupt
661
+  \details Sets the pending bit of an external interrupt.
662
+  \param [in]      IRQn  Interrupt number. Value cannot be negative.
663
+ */
664
+__STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn)
665
+{
666
+  NVIC->ISPR[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
667
+}
668
+
669
+
670
+/**
671
+  \brief   Clear Pending Interrupt
672
+  \details Clears the pending bit of an external interrupt.
673
+  \param [in]      IRQn  External interrupt number. Value cannot be negative.
674
+ */
675
+__STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn)
676
+{
677
+  NVIC->ICPR[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
678
+}
679
+
680
+
681
+/**
682
+  \brief   Set Interrupt Priority
683
+  \details Sets the priority of an interrupt.
684
+  \note    The priority cannot be set for every core interrupt.
685
+  \param [in]      IRQn  Interrupt number.
686
+  \param [in]  priority  Priority to set.
687
+ */
688
+__STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
689
+{
690
+  if ((int32_t)(IRQn) < 0)
691
+  {
692
+    SCB->SHP[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) |
693
+       (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn)));
694
+  }
695
+  else
696
+  {
697
+    NVIC->IP[_IP_IDX(IRQn)]  = ((uint32_t)(NVIC->IP[_IP_IDX(IRQn)]  & ~(0xFFUL << _BIT_SHIFT(IRQn))) |
698
+       (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn)));
699
+  }
700
+}
701
+
702
+
703
+/**
704
+  \brief   Get Interrupt Priority
705
+  \details Reads the priority of an interrupt.
706
+           The interrupt number can be positive to specify an external (device specific) interrupt,
707
+           or negative to specify an internal (core) interrupt.
708
+  \param [in]   IRQn  Interrupt number.
709
+  \return             Interrupt Priority.
710
+                      Value is aligned automatically to the implemented priority bits of the microcontroller.
711
+ */
712
+__STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn)
713
+{
714
+
715
+  if ((int32_t)(IRQn) < 0)
716
+  {
717
+    return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS)));
718
+  }
719
+  else
720
+  {
721
+    return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS)));
722
+  }
723
+}
724
+
725
+
726
+/**
727
+  \brief   System Reset
728
+  \details Initiates a system reset request to reset the MCU.
729
+ */
730
+__STATIC_INLINE void NVIC_SystemReset(void)
731
+{
732
+  __DSB();                                                          /* Ensure all outstanding memory accesses included
733
+                                                                       buffered write are completed before reset */
734
+  SCB->AIRCR  = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) |
735
+                 SCB_AIRCR_SYSRESETREQ_Msk);
736
+  __DSB();                                                          /* Ensure completion of memory access */
737
+
738
+  for(;;)                                                           /* wait until reset */
739
+  {
740
+    __NOP();
741
+  }
742
+}
743
+
744
+/*@} end of CMSIS_Core_NVICFunctions */
745
+
746
+
747
+
748
+/* ##################################    SysTick function  ############################################ */
749
+/**
750
+  \ingroup  CMSIS_Core_FunctionInterface
751
+  \defgroup CMSIS_Core_SysTickFunctions SysTick Functions
752
+  \brief    Functions that configure the System.
753
+  @{
754
+ */
755
+
756
+#if (__Vendor_SysTickConfig == 0U)
757
+
758
+/**
759
+  \brief   System Tick Configuration
760
+  \details Initializes the System Timer and its interrupt, and starts the System Tick Timer.
761
+           Counter is in free running mode to generate periodic interrupts.
762
+  \param [in]  ticks  Number of ticks between two interrupts.
763
+  \return          0  Function succeeded.
764
+  \return          1  Function failed.
765
+  \note    When the variable <b>__Vendor_SysTickConfig</b> is set to 1, then the
766
+           function <b>SysTick_Config</b> is not included. In this case, the file <b><i>device</i>.h</b>
767
+           must contain a vendor-specific implementation of this function.
768
+ */
769
+__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks)
770
+{
771
+  if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk)
772
+  {
773
+    return (1UL);                                                   /* Reload value impossible */
774
+  }
775
+
776
+  SysTick->LOAD  = (uint32_t)(ticks - 1UL);                         /* set reload register */
777
+  NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */
778
+  SysTick->VAL   = 0UL;                                             /* Load the SysTick Counter Value */
779
+  SysTick->CTRL  = SysTick_CTRL_CLKSOURCE_Msk |
780
+                   SysTick_CTRL_TICKINT_Msk   |
781
+                   SysTick_CTRL_ENABLE_Msk;                         /* Enable SysTick IRQ and SysTick Timer */
782
+  return (0UL);                                                     /* Function successful */
783
+}
784
+
785
+#endif
786
+
787
+/*@} end of CMSIS_Core_SysTickFunctions */
788
+
789
+
790
+
791
+
792
+#ifdef __cplusplus
793
+}
794
+#endif
795
+
796
+#endif /* __CORE_CM0_H_DEPENDANT */
797
+
798
+#endif /* __CMSIS_GENERIC */

+ 914 - 0
Drivers/CMSIS/Include/core_cm0plus.h

@@ -0,0 +1,914 @@
1
+/**************************************************************************//**
2
+ * @file     core_cm0plus.h
3
+ * @brief    CMSIS Cortex-M0+ Core Peripheral Access Layer Header File
4
+ * @version  V4.30
5
+ * @date     20. October 2015
6
+ ******************************************************************************/
7
+/* Copyright (c) 2009 - 2015 ARM LIMITED
8
+
9
+   All rights reserved.
10
+   Redistribution and use in source and binary forms, with or without
11
+   modification, are permitted provided that the following conditions are met:
12
+   - Redistributions of source code must retain the above copyright
13
+     notice, this list of conditions and the following disclaimer.
14
+   - Redistributions in binary form must reproduce the above copyright
15
+     notice, this list of conditions and the following disclaimer in the
16
+     documentation and/or other materials provided with the distribution.
17
+   - Neither the name of ARM nor the names of its contributors may be used
18
+     to endorse or promote products derived from this software without
19
+     specific prior written permission.
20
+   *
21
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22
+   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23
+   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24
+   ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
25
+   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26
+   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27
+   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
+   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
+   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
+   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
+   POSSIBILITY OF SUCH DAMAGE.
32
+   ---------------------------------------------------------------------------*/
33
+
34
+
35
+#if   defined ( __ICCARM__ )
36
+ #pragma system_include         /* treat file as system include file for MISRA check */
37
+#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
38
+  #pragma clang system_header   /* treat file as system include file */
39
+#endif
40
+
41
+#ifndef __CORE_CM0PLUS_H_GENERIC
42
+#define __CORE_CM0PLUS_H_GENERIC
43
+
44
+#include <stdint.h>
45
+
46
+#ifdef __cplusplus
47
+ extern "C" {
48
+#endif
49
+
50
+/**
51
+  \page CMSIS_MISRA_Exceptions  MISRA-C:2004 Compliance Exceptions
52
+  CMSIS violates the following MISRA-C:2004 rules:
53
+
54
+   \li Required Rule 8.5, object/function definition in header file.<br>
55
+     Function definitions in header files are used to allow 'inlining'.
56
+
57
+   \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.<br>
58
+     Unions are used for effective representation of core registers.
59
+
60
+   \li Advisory Rule 19.7, Function-like macro defined.<br>
61
+     Function-like macros are used to allow more efficient code.
62
+ */
63
+
64
+
65
+/*******************************************************************************
66
+ *                 CMSIS definitions
67
+ ******************************************************************************/
68
+/**
69
+  \ingroup Cortex-M0+
70
+  @{
71
+ */
72
+
73
+/*  CMSIS CM0+ definitions */
74
+#define __CM0PLUS_CMSIS_VERSION_MAIN (0x04U)                                   /*!< [31:16] CMSIS HAL main version */
75
+#define __CM0PLUS_CMSIS_VERSION_SUB  (0x1EU)                                   /*!< [15:0]  CMSIS HAL sub version */
76
+#define __CM0PLUS_CMSIS_VERSION      ((__CM0PLUS_CMSIS_VERSION_MAIN << 16U) | \
77
+                                       __CM0PLUS_CMSIS_VERSION_SUB           ) /*!< CMSIS HAL version number */
78
+
79
+#define __CORTEX_M                (0x00U)                                      /*!< Cortex-M Core */
80
+
81
+
82
+#if   defined ( __CC_ARM )
83
+  #define __ASM            __asm                                      /*!< asm keyword for ARM Compiler */
84
+  #define __INLINE         __inline                                   /*!< inline keyword for ARM Compiler */
85
+  #define __STATIC_INLINE  static __inline
86
+
87
+#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
88
+  #define __ASM            __asm                                      /*!< asm keyword for ARM Compiler */
89
+  #define __INLINE         __inline                                   /*!< inline keyword for ARM Compiler */
90
+  #define __STATIC_INLINE  static __inline
91
+
92
+#elif defined ( __GNUC__ )
93
+  #define __ASM            __asm                                      /*!< asm keyword for GNU Compiler */
94
+  #define __INLINE         inline                                     /*!< inline keyword for GNU Compiler */
95
+  #define __STATIC_INLINE  static inline
96
+
97
+#elif defined ( __ICCARM__ )
98
+  #define __ASM            __asm                                      /*!< asm keyword for IAR Compiler */
99
+  #define __INLINE         inline                                     /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */
100
+  #define __STATIC_INLINE  static inline
101
+
102
+#elif defined ( __TMS470__ )
103
+  #define __ASM            __asm                                      /*!< asm keyword for TI CCS Compiler */
104
+  #define __STATIC_INLINE  static inline
105
+
106
+#elif defined ( __TASKING__ )
107
+  #define __ASM            __asm                                      /*!< asm keyword for TASKING Compiler */
108
+  #define __INLINE         inline                                     /*!< inline keyword for TASKING Compiler */
109
+  #define __STATIC_INLINE  static inline
110
+
111
+#elif defined ( __CSMC__ )
112
+  #define __packed
113
+  #define __ASM            _asm                                      /*!< asm keyword for COSMIC Compiler */
114
+  #define __INLINE         inline                                    /*!< inline keyword for COSMIC Compiler. Use -pc99 on compile line */
115
+  #define __STATIC_INLINE  static inline
116
+
117
+#else
118
+  #error Unknown compiler
119
+#endif
120
+
121
+/** __FPU_USED indicates whether an FPU is used or not.
122
+    This core does not support an FPU at all
123
+*/
124
+#define __FPU_USED       0U
125
+
126
+#if defined ( __CC_ARM )
127
+  #if defined __TARGET_FPU_VFP
128
+    #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
129
+  #endif
130
+
131
+#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
132
+  #if defined __ARM_PCS_VFP
133
+    #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
134
+  #endif
135
+
136
+#elif defined ( __GNUC__ )
137
+  #if defined (__VFP_FP__) && !defined(__SOFTFP__)
138
+    #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
139
+  #endif
140
+
141
+#elif defined ( __ICCARM__ )
142
+  #if defined __ARMVFP__
143
+    #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
144
+  #endif
145
+
146
+#elif defined ( __TMS470__ )
147
+  #if defined __TI_VFP_SUPPORT__
148
+    #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
149
+  #endif
150
+
151
+#elif defined ( __TASKING__ )
152
+  #if defined __FPU_VFP__
153
+    #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
154
+  #endif
155
+
156
+#elif defined ( __CSMC__ )
157
+  #if ( __CSMC__ & 0x400U)
158
+    #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
159
+  #endif
160
+
161
+#endif
162
+
163
+#include "core_cmInstr.h"                /* Core Instruction Access */
164
+#include "core_cmFunc.h"                 /* Core Function Access */
165
+
166
+#ifdef __cplusplus
167
+}
168
+#endif
169
+
170
+#endif /* __CORE_CM0PLUS_H_GENERIC */
171
+
172
+#ifndef __CMSIS_GENERIC
173
+
174
+#ifndef __CORE_CM0PLUS_H_DEPENDANT
175
+#define __CORE_CM0PLUS_H_DEPENDANT
176
+
177
+#ifdef __cplusplus
178
+ extern "C" {
179
+#endif
180
+
181
+/* check device defines and use defaults */
182
+#if defined __CHECK_DEVICE_DEFINES
183
+  #ifndef __CM0PLUS_REV
184
+    #define __CM0PLUS_REV             0x0000U
185
+    #warning "__CM0PLUS_REV not defined in device header file; using default!"
186
+  #endif
187
+
188
+  #ifndef __MPU_PRESENT
189
+    #define __MPU_PRESENT             0U
190
+    #warning "__MPU_PRESENT not defined in device header file; using default!"
191
+  #endif
192
+
193
+  #ifndef __VTOR_PRESENT
194
+    #define __VTOR_PRESENT            0U
195
+    #warning "__VTOR_PRESENT not defined in device header file; using default!"
196
+  #endif
197
+
198
+  #ifndef __NVIC_PRIO_BITS
199
+    #define __NVIC_PRIO_BITS          2U
200
+    #warning "__NVIC_PRIO_BITS not defined in device header file; using default!"
201
+  #endif
202
+
203
+  #ifndef __Vendor_SysTickConfig
204
+    #define __Vendor_SysTickConfig    0U
205
+    #warning "__Vendor_SysTickConfig not defined in device header file; using default!"
206
+  #endif
207
+#endif
208
+
209
+/* IO definitions (access restrictions to peripheral registers) */
210
+/**
211
+    \defgroup CMSIS_glob_defs CMSIS Global Defines
212
+
213
+    <strong>IO Type Qualifiers</strong> are used
214
+    \li to specify the access to peripheral variables.
215
+    \li for automatic generation of peripheral register debug information.
216
+*/
217
+#ifdef __cplusplus
218
+  #define   __I     volatile             /*!< Defines 'read only' permissions */
219
+#else
220
+  #define   __I     volatile const       /*!< Defines 'read only' permissions */
221
+#endif
222
+#define     __O     volatile             /*!< Defines 'write only' permissions */
223
+#define     __IO    volatile             /*!< Defines 'read / write' permissions */
224
+
225
+/* following defines should be used for structure members */
226
+#define     __IM     volatile const      /*! Defines 'read only' structure member permissions */
227
+#define     __OM     volatile            /*! Defines 'write only' structure member permissions */
228
+#define     __IOM    volatile            /*! Defines 'read / write' structure member permissions */
229
+
230
+/*@} end of group Cortex-M0+ */
231
+
232
+
233
+
234
+/*******************************************************************************
235
+ *                 Register Abstraction
236
+  Core Register contain:
237
+  - Core Register
238
+  - Core NVIC Register
239
+  - Core SCB Register
240
+  - Core SysTick Register
241
+  - Core MPU Register
242
+ ******************************************************************************/
243
+/**
244
+  \defgroup CMSIS_core_register Defines and Type Definitions
245
+  \brief Type definitions and defines for Cortex-M processor based devices.
246
+*/
247
+
248
+/**
249
+  \ingroup    CMSIS_core_register
250
+  \defgroup   CMSIS_CORE  Status and Control Registers
251
+  \brief      Core Register type definitions.
252
+  @{
253
+ */
254
+
255
+/**
256
+  \brief  Union type to access the Application Program Status Register (APSR).
257
+ */
258
+typedef union
259
+{
260
+  struct
261
+  {
262
+    uint32_t _reserved0:28;              /*!< bit:  0..27  Reserved */
263
+    uint32_t V:1;                        /*!< bit:     28  Overflow condition code flag */
264
+    uint32_t C:1;                        /*!< bit:     29  Carry condition code flag */
265
+    uint32_t Z:1;                        /*!< bit:     30  Zero condition code flag */
266
+    uint32_t N:1;                        /*!< bit:     31  Negative condition code flag */
267
+  } b;                                   /*!< Structure used for bit  access */
268
+  uint32_t w;                            /*!< Type      used for word access */
269
+} APSR_Type;
270
+
271
+/* APSR Register Definitions */
272
+#define APSR_N_Pos                         31U                                            /*!< APSR: N Position */
273
+#define APSR_N_Msk                         (1UL << APSR_N_Pos)                            /*!< APSR: N Mask */
274
+
275
+#define APSR_Z_Pos                         30U                                            /*!< APSR: Z Position */
276
+#define APSR_Z_Msk                         (1UL << APSR_Z_Pos)                            /*!< APSR: Z Mask */
277
+
278
+#define APSR_C_Pos                         29U                                            /*!< APSR: C Position */
279
+#define APSR_C_Msk                         (1UL << APSR_C_Pos)                            /*!< APSR: C Mask */
280
+
281
+#define APSR_V_Pos                         28U                                            /*!< APSR: V Position */
282
+#define APSR_V_Msk                         (1UL << APSR_V_Pos)                            /*!< APSR: V Mask */
283
+
284
+
285
+/**
286
+  \brief  Union type to access the Interrupt Program Status Register (IPSR).
287
+ */
288
+typedef union
289
+{
290
+  struct
291
+  {
292
+    uint32_t ISR:9;                      /*!< bit:  0.. 8  Exception number */
293
+    uint32_t _reserved0:23;              /*!< bit:  9..31  Reserved */
294
+  } b;                                   /*!< Structure used for bit  access */
295
+  uint32_t w;                            /*!< Type      used for word access */
296
+} IPSR_Type;
297
+
298
+/* IPSR Register Definitions */
299
+#define IPSR_ISR_Pos                        0U                                            /*!< IPSR: ISR Position */
300
+#define IPSR_ISR_Msk                       (0x1FFUL /*<< IPSR_ISR_Pos*/)                  /*!< IPSR: ISR Mask */
301
+
302
+
303
+/**
304
+  \brief  Union type to access the Special-Purpose Program Status Registers (xPSR).
305
+ */
306
+typedef union
307
+{
308
+  struct
309
+  {
310
+    uint32_t ISR:9;                      /*!< bit:  0.. 8  Exception number */
311
+    uint32_t _reserved0:15;              /*!< bit:  9..23  Reserved */
312
+    uint32_t T:1;                        /*!< bit:     24  Thumb bit        (read 0) */
313
+    uint32_t _reserved1:3;               /*!< bit: 25..27  Reserved */
314
+    uint32_t V:1;                        /*!< bit:     28  Overflow condition code flag */
315
+    uint32_t C:1;                        /*!< bit:     29  Carry condition code flag */
316
+    uint32_t Z:1;                        /*!< bit:     30  Zero condition code flag */
317
+    uint32_t N:1;                        /*!< bit:     31  Negative condition code flag */
318
+  } b;                                   /*!< Structure used for bit  access */
319
+  uint32_t w;                            /*!< Type      used for word access */
320
+} xPSR_Type;
321
+
322
+/* xPSR Register Definitions */
323
+#define xPSR_N_Pos                         31U                                            /*!< xPSR: N Position */
324
+#define xPSR_N_Msk                         (1UL << xPSR_N_Pos)                            /*!< xPSR: N Mask */
325
+
326
+#define xPSR_Z_Pos                         30U                                            /*!< xPSR: Z Position */
327
+#define xPSR_Z_Msk                         (1UL << xPSR_Z_Pos)                            /*!< xPSR: Z Mask */
328
+
329
+#define xPSR_C_Pos                         29U                                            /*!< xPSR: C Position */
330
+#define xPSR_C_Msk                         (1UL << xPSR_C_Pos)                            /*!< xPSR: C Mask */
331
+
332
+#define xPSR_V_Pos                         28U                                            /*!< xPSR: V Position */
333
+#define xPSR_V_Msk                         (1UL << xPSR_V_Pos)                            /*!< xPSR: V Mask */
334
+
335
+#define xPSR_T_Pos                         24U                                            /*!< xPSR: T Position */
336
+#define xPSR_T_Msk                         (1UL << xPSR_T_Pos)                            /*!< xPSR: T Mask */
337
+
338
+#define xPSR_ISR_Pos                        0U                                            /*!< xPSR: ISR Position */
339
+#define xPSR_ISR_Msk                       (0x1FFUL /*<< xPSR_ISR_Pos*/)                  /*!< xPSR: ISR Mask */
340
+
341
+
342
+/**
343
+  \brief  Union type to access the Control Registers (CONTROL).
344
+ */
345
+typedef union
346
+{
347
+  struct
348
+  {
349
+    uint32_t nPRIV:1;                    /*!< bit:      0  Execution privilege in Thread mode */
350
+    uint32_t SPSEL:1;                    /*!< bit:      1  Stack to be used */
351
+    uint32_t _reserved1:30;              /*!< bit:  2..31  Reserved */
352
+  } b;                                   /*!< Structure used for bit  access */
353
+  uint32_t w;                            /*!< Type      used for word access */
354
+} CONTROL_Type;
355
+
356
+/* CONTROL Register Definitions */
357
+#define CONTROL_SPSEL_Pos                   1U                                            /*!< CONTROL: SPSEL Position */
358
+#define CONTROL_SPSEL_Msk                  (1UL << CONTROL_SPSEL_Pos)                     /*!< CONTROL: SPSEL Mask */
359
+
360
+#define CONTROL_nPRIV_Pos                   0U                                            /*!< CONTROL: nPRIV Position */
361
+#define CONTROL_nPRIV_Msk                  (1UL /*<< CONTROL_nPRIV_Pos*/)                 /*!< CONTROL: nPRIV Mask */
362
+
363
+/*@} end of group CMSIS_CORE */
364
+
365
+
366
+/**
367
+  \ingroup    CMSIS_core_register
368
+  \defgroup   CMSIS_NVIC  Nested Vectored Interrupt Controller (NVIC)
369
+  \brief      Type definitions for the NVIC Registers
370
+  @{
371
+ */
372
+
373
+/**
374
+  \brief  Structure type to access the Nested Vectored Interrupt Controller (NVIC).
375
+ */
376
+typedef struct
377
+{
378
+  __IOM uint32_t ISER[1U];               /*!< Offset: 0x000 (R/W)  Interrupt Set Enable Register */
379
+        uint32_t RESERVED0[31U];
380
+  __IOM uint32_t ICER[1U];               /*!< Offset: 0x080 (R/W)  Interrupt Clear Enable Register */
381
+        uint32_t RSERVED1[31U];
382
+  __IOM uint32_t ISPR[1U];               /*!< Offset: 0x100 (R/W)  Interrupt Set Pending Register */
383
+        uint32_t RESERVED2[31U];
384
+  __IOM uint32_t ICPR[1U];               /*!< Offset: 0x180 (R/W)  Interrupt Clear Pending Register */
385
+        uint32_t RESERVED3[31U];
386
+        uint32_t RESERVED4[64U];
387
+  __IOM uint32_t IP[8U];                 /*!< Offset: 0x300 (R/W)  Interrupt Priority Register */
388
+}  NVIC_Type;
389
+
390
+/*@} end of group CMSIS_NVIC */
391
+
392
+
393
+/**
394
+  \ingroup  CMSIS_core_register
395
+  \defgroup CMSIS_SCB     System Control Block (SCB)
396
+  \brief    Type definitions for the System Control Block Registers
397
+  @{
398
+ */
399
+
400
+/**
401
+  \brief  Structure type to access the System Control Block (SCB).
402
+ */
403
+typedef struct
404
+{
405
+  __IM  uint32_t CPUID;                  /*!< Offset: 0x000 (R/ )  CPUID Base Register */
406
+  __IOM uint32_t ICSR;                   /*!< Offset: 0x004 (R/W)  Interrupt Control and State Register */
407
+#if (__VTOR_PRESENT == 1U)
408
+  __IOM uint32_t VTOR;                   /*!< Offset: 0x008 (R/W)  Vector Table Offset Register */
409
+#else
410
+        uint32_t RESERVED0;
411
+#endif
412
+  __IOM uint32_t AIRCR;                  /*!< Offset: 0x00C (R/W)  Application Interrupt and Reset Control Register */
413
+  __IOM uint32_t SCR;                    /*!< Offset: 0x010 (R/W)  System Control Register */
414
+  __IOM uint32_t CCR;                    /*!< Offset: 0x014 (R/W)  Configuration Control Register */
415
+        uint32_t RESERVED1;
416
+  __IOM uint32_t SHP[2U];                /*!< Offset: 0x01C (R/W)  System Handlers Priority Registers. [0] is RESERVED */
417
+  __IOM uint32_t SHCSR;                  /*!< Offset: 0x024 (R/W)  System Handler Control and State Register */
418
+} SCB_Type;
419
+
420
+/* SCB CPUID Register Definitions */
421
+#define SCB_CPUID_IMPLEMENTER_Pos          24U                                            /*!< SCB CPUID: IMPLEMENTER Position */
422
+#define SCB_CPUID_IMPLEMENTER_Msk          (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos)          /*!< SCB CPUID: IMPLEMENTER Mask */
423
+
424
+#define SCB_CPUID_VARIANT_Pos              20U                                            /*!< SCB CPUID: VARIANT Position */
425
+#define SCB_CPUID_VARIANT_Msk              (0xFUL << SCB_CPUID_VARIANT_Pos)               /*!< SCB CPUID: VARIANT Mask */
426
+
427
+#define SCB_CPUID_ARCHITECTURE_Pos         16U                                            /*!< SCB CPUID: ARCHITECTURE Position */
428
+#define SCB_CPUID_ARCHITECTURE_Msk         (0xFUL << SCB_CPUID_ARCHITECTURE_Pos)          /*!< SCB CPUID: ARCHITECTURE Mask */
429
+
430
+#define SCB_CPUID_PARTNO_Pos                4U                                            /*!< SCB CPUID: PARTNO Position */
431
+#define SCB_CPUID_PARTNO_Msk               (0xFFFUL << SCB_CPUID_PARTNO_Pos)              /*!< SCB CPUID: PARTNO Mask */
432
+
433
+#define SCB_CPUID_REVISION_Pos              0U                                            /*!< SCB CPUID: REVISION Position */
434
+#define SCB_CPUID_REVISION_Msk             (0xFUL /*<< SCB_CPUID_REVISION_Pos*/)          /*!< SCB CPUID: REVISION Mask */
435
+
436
+/* SCB Interrupt Control State Register Definitions */
437
+#define SCB_ICSR_NMIPENDSET_Pos            31U                                            /*!< SCB ICSR: NMIPENDSET Position */
438
+#define SCB_ICSR_NMIPENDSET_Msk            (1UL << SCB_ICSR_NMIPENDSET_Pos)               /*!< SCB ICSR: NMIPENDSET Mask */
439
+
440
+#define SCB_ICSR_PENDSVSET_Pos             28U                                            /*!< SCB ICSR: PENDSVSET Position */
441
+#define SCB_ICSR_PENDSVSET_Msk             (1UL << SCB_ICSR_PENDSVSET_Pos)                /*!< SCB ICSR: PENDSVSET Mask */
442
+
443
+#define SCB_ICSR_PENDSVCLR_Pos             27U                                            /*!< SCB ICSR: PENDSVCLR Position */
444
+#define SCB_ICSR_PENDSVCLR_Msk             (1UL << SCB_ICSR_PENDSVCLR_Pos)                /*!< SCB ICSR: PENDSVCLR Mask */
445
+
446
+#define SCB_ICSR_PENDSTSET_Pos             26U                                            /*!< SCB ICSR: PENDSTSET Position */
447
+#define SCB_ICSR_PENDSTSET_Msk             (1UL << SCB_ICSR_PENDSTSET_Pos)                /*!< SCB ICSR: PENDSTSET Mask */
448
+
449
+#define SCB_ICSR_PENDSTCLR_Pos             25U                                            /*!< SCB ICSR: PENDSTCLR Position */
450
+#define SCB_ICSR_PENDSTCLR_Msk             (1UL << SCB_ICSR_PENDSTCLR_Pos)                /*!< SCB ICSR: PENDSTCLR Mask */
451
+
452
+#define SCB_ICSR_ISRPREEMPT_Pos            23U                                            /*!< SCB ICSR: ISRPREEMPT Position */
453
+#define SCB_ICSR_ISRPREEMPT_Msk            (1UL << SCB_ICSR_ISRPREEMPT_Pos)               /*!< SCB ICSR: ISRPREEMPT Mask */
454
+
455
+#define SCB_ICSR_ISRPENDING_Pos            22U                                            /*!< SCB ICSR: ISRPENDING Position */
456
+#define SCB_ICSR_ISRPENDING_Msk            (1UL << SCB_ICSR_ISRPENDING_Pos)               /*!< SCB ICSR: ISRPENDING Mask */
457
+
458
+#define SCB_ICSR_VECTPENDING_Pos           12U                                            /*!< SCB ICSR: VECTPENDING Position */
459
+#define SCB_ICSR_VECTPENDING_Msk           (0x1FFUL << SCB_ICSR_VECTPENDING_Pos)          /*!< SCB ICSR: VECTPENDING Mask */
460
+
461
+#define SCB_ICSR_VECTACTIVE_Pos             0U                                            /*!< SCB ICSR: VECTACTIVE Position */
462
+#define SCB_ICSR_VECTACTIVE_Msk            (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/)       /*!< SCB ICSR: VECTACTIVE Mask */
463
+
464
+#if (__VTOR_PRESENT == 1U)
465
+/* SCB Interrupt Control State Register Definitions */
466
+#define SCB_VTOR_TBLOFF_Pos                 8U                                            /*!< SCB VTOR: TBLOFF Position */
467
+#define SCB_VTOR_TBLOFF_Msk                (0xFFFFFFUL << SCB_VTOR_TBLOFF_Pos)            /*!< SCB VTOR: TBLOFF Mask */
468
+#endif
469
+
470
+/* SCB Application Interrupt and Reset Control Register Definitions */
471
+#define SCB_AIRCR_VECTKEY_Pos              16U                                            /*!< SCB AIRCR: VECTKEY Position */
472
+#define SCB_AIRCR_VECTKEY_Msk              (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos)            /*!< SCB AIRCR: VECTKEY Mask */
473
+
474
+#define SCB_AIRCR_VECTKEYSTAT_Pos          16U                                            /*!< SCB AIRCR: VECTKEYSTAT Position */
475
+#define SCB_AIRCR_VECTKEYSTAT_Msk          (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos)        /*!< SCB AIRCR: VECTKEYSTAT Mask */
476
+
477
+#define SCB_AIRCR_ENDIANESS_Pos            15U                                            /*!< SCB AIRCR: ENDIANESS Position */
478
+#define SCB_AIRCR_ENDIANESS_Msk            (1UL << SCB_AIRCR_ENDIANESS_Pos)               /*!< SCB AIRCR: ENDIANESS Mask */
479
+
480
+#define SCB_AIRCR_SYSRESETREQ_Pos           2U                                            /*!< SCB AIRCR: SYSRESETREQ Position */
481
+#define SCB_AIRCR_SYSRESETREQ_Msk          (1UL << SCB_AIRCR_SYSRESETREQ_Pos)             /*!< SCB AIRCR: SYSRESETREQ Mask */
482
+
483
+#define SCB_AIRCR_VECTCLRACTIVE_Pos         1U                                            /*!< SCB AIRCR: VECTCLRACTIVE Position */
484
+#define SCB_AIRCR_VECTCLRACTIVE_Msk        (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos)           /*!< SCB AIRCR: VECTCLRACTIVE Mask */
485
+
486
+/* SCB System Control Register Definitions */
487
+#define SCB_SCR_SEVONPEND_Pos               4U                                            /*!< SCB SCR: SEVONPEND Position */
488
+#define SCB_SCR_SEVONPEND_Msk              (1UL << SCB_SCR_SEVONPEND_Pos)                 /*!< SCB SCR: SEVONPEND Mask */
489
+
490
+#define SCB_SCR_SLEEPDEEP_Pos               2U                                            /*!< SCB SCR: SLEEPDEEP Position */
491
+#define SCB_SCR_SLEEPDEEP_Msk              (1UL << SCB_SCR_SLEEPDEEP_Pos)                 /*!< SCB SCR: SLEEPDEEP Mask */
492
+
493
+#define SCB_SCR_SLEEPONEXIT_Pos             1U                                            /*!< SCB SCR: SLEEPONEXIT Position */
494
+#define SCB_SCR_SLEEPONEXIT_Msk            (1UL << SCB_SCR_SLEEPONEXIT_Pos)               /*!< SCB SCR: SLEEPONEXIT Mask */
495
+
496
+/* SCB Configuration Control Register Definitions */
497
+#define SCB_CCR_STKALIGN_Pos                9U                                            /*!< SCB CCR: STKALIGN Position */
498
+#define SCB_CCR_STKALIGN_Msk               (1UL << SCB_CCR_STKALIGN_Pos)                  /*!< SCB CCR: STKALIGN Mask */
499
+
500
+#define SCB_CCR_UNALIGN_TRP_Pos             3U                                            /*!< SCB CCR: UNALIGN_TRP Position */
501
+#define SCB_CCR_UNALIGN_TRP_Msk            (1UL << SCB_CCR_UNALIGN_TRP_Pos)               /*!< SCB CCR: UNALIGN_TRP Mask */
502
+
503
+/* SCB System Handler Control and State Register Definitions */
504
+#define SCB_SHCSR_SVCALLPENDED_Pos         15U                                            /*!< SCB SHCSR: SVCALLPENDED Position */
505
+#define SCB_SHCSR_SVCALLPENDED_Msk         (1UL << SCB_SHCSR_SVCALLPENDED_Pos)            /*!< SCB SHCSR: SVCALLPENDED Mask */
506
+
507
+/*@} end of group CMSIS_SCB */
508
+
509
+
510
+/**
511
+  \ingroup  CMSIS_core_register
512
+  \defgroup CMSIS_SysTick     System Tick Timer (SysTick)
513
+  \brief    Type definitions for the System Timer Registers.
514
+  @{
515
+ */
516
+
517
+/**
518
+  \brief  Structure type to access the System Timer (SysTick).
519
+ */
520
+typedef struct
521
+{
522
+  __IOM uint32_t CTRL;                   /*!< Offset: 0x000 (R/W)  SysTick Control and Status Register */
523
+  __IOM uint32_t LOAD;                   /*!< Offset: 0x004 (R/W)  SysTick Reload Value Register */
524
+  __IOM uint32_t VAL;                    /*!< Offset: 0x008 (R/W)  SysTick Current Value Register */
525
+  __IM  uint32_t CALIB;                  /*!< Offset: 0x00C (R/ )  SysTick Calibration Register */
526
+} SysTick_Type;
527
+
528
+/* SysTick Control / Status Register Definitions */
529
+#define SysTick_CTRL_COUNTFLAG_Pos         16U                                            /*!< SysTick CTRL: COUNTFLAG Position */
530
+#define SysTick_CTRL_COUNTFLAG_Msk         (1UL << SysTick_CTRL_COUNTFLAG_Pos)            /*!< SysTick CTRL: COUNTFLAG Mask */
531
+
532
+#define SysTick_CTRL_CLKSOURCE_Pos          2U                                            /*!< SysTick CTRL: CLKSOURCE Position */
533
+#define SysTick_CTRL_CLKSOURCE_Msk         (1UL << SysTick_CTRL_CLKSOURCE_Pos)            /*!< SysTick CTRL: CLKSOURCE Mask */
534
+
535
+#define SysTick_CTRL_TICKINT_Pos            1U                                            /*!< SysTick CTRL: TICKINT Position */
536
+#define SysTick_CTRL_TICKINT_Msk           (1UL << SysTick_CTRL_TICKINT_Pos)              /*!< SysTick CTRL: TICKINT Mask */
537
+
538
+#define SysTick_CTRL_ENABLE_Pos             0U                                            /*!< SysTick CTRL: ENABLE Position */
539
+#define SysTick_CTRL_ENABLE_Msk            (1UL /*<< SysTick_CTRL_ENABLE_Pos*/)           /*!< SysTick CTRL: ENABLE Mask */
540
+
541
+/* SysTick Reload Register Definitions */
542
+#define SysTick_LOAD_RELOAD_Pos             0U                                            /*!< SysTick LOAD: RELOAD Position */
543
+#define SysTick_LOAD_RELOAD_Msk            (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/)    /*!< SysTick LOAD: RELOAD Mask */
544
+
545
+/* SysTick Current Register Definitions */
546
+#define SysTick_VAL_CURRENT_Pos             0U                                            /*!< SysTick VAL: CURRENT Position */
547
+#define SysTick_VAL_CURRENT_Msk            (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/)    /*!< SysTick VAL: CURRENT Mask */
548
+
549
+/* SysTick Calibration Register Definitions */
550
+#define SysTick_CALIB_NOREF_Pos            31U                                            /*!< SysTick CALIB: NOREF Position */
551
+#define SysTick_CALIB_NOREF_Msk            (1UL << SysTick_CALIB_NOREF_Pos)               /*!< SysTick CALIB: NOREF Mask */
552
+
553
+#define SysTick_CALIB_SKEW_Pos             30U                                            /*!< SysTick CALIB: SKEW Position */
554
+#define SysTick_CALIB_SKEW_Msk             (1UL << SysTick_CALIB_SKEW_Pos)                /*!< SysTick CALIB: SKEW Mask */
555
+
556
+#define SysTick_CALIB_TENMS_Pos             0U                                            /*!< SysTick CALIB: TENMS Position */
557
+#define SysTick_CALIB_TENMS_Msk            (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/)    /*!< SysTick CALIB: TENMS Mask */
558
+
559
+/*@} end of group CMSIS_SysTick */
560
+
561
+#if (__MPU_PRESENT == 1U)
562
+/**
563
+  \ingroup  CMSIS_core_register
564
+  \defgroup CMSIS_MPU     Memory Protection Unit (MPU)
565
+  \brief    Type definitions for the Memory Protection Unit (MPU)
566
+  @{
567
+ */
568
+
569
+/**
570
+  \brief  Structure type to access the Memory Protection Unit (MPU).
571
+ */
572
+typedef struct
573
+{
574
+  __IM  uint32_t TYPE;                   /*!< Offset: 0x000 (R/ )  MPU Type Register */
575
+  __IOM uint32_t CTRL;                   /*!< Offset: 0x004 (R/W)  MPU Control Register */
576
+  __IOM uint32_t RNR;                    /*!< Offset: 0x008 (R/W)  MPU Region RNRber Register */
577
+  __IOM uint32_t RBAR;                   /*!< Offset: 0x00C (R/W)  MPU Region Base Address Register */
578
+  __IOM uint32_t RASR;                   /*!< Offset: 0x010 (R/W)  MPU Region Attribute and Size Register */
579
+} MPU_Type;
580
+
581
+/* MPU Type Register Definitions */
582
+#define MPU_TYPE_IREGION_Pos               16U                                            /*!< MPU TYPE: IREGION Position */
583
+#define MPU_TYPE_IREGION_Msk               (0xFFUL << MPU_TYPE_IREGION_Pos)               /*!< MPU TYPE: IREGION Mask */
584
+
585
+#define MPU_TYPE_DREGION_Pos                8U                                            /*!< MPU TYPE: DREGION Position */
586
+#define MPU_TYPE_DREGION_Msk               (0xFFUL << MPU_TYPE_DREGION_Pos)               /*!< MPU TYPE: DREGION Mask */
587
+
588
+#define MPU_TYPE_SEPARATE_Pos               0U                                            /*!< MPU TYPE: SEPARATE Position */
589
+#define MPU_TYPE_SEPARATE_Msk              (1UL /*<< MPU_TYPE_SEPARATE_Pos*/)             /*!< MPU TYPE: SEPARATE Mask */
590
+
591
+/* MPU Control Register Definitions */
592
+#define MPU_CTRL_PRIVDEFENA_Pos             2U                                            /*!< MPU CTRL: PRIVDEFENA Position */
593
+#define MPU_CTRL_PRIVDEFENA_Msk            (1UL << MPU_CTRL_PRIVDEFENA_Pos)               /*!< MPU CTRL: PRIVDEFENA Mask */
594
+
595
+#define MPU_CTRL_HFNMIENA_Pos               1U                                            /*!< MPU CTRL: HFNMIENA Position */
596
+#define MPU_CTRL_HFNMIENA_Msk              (1UL << MPU_CTRL_HFNMIENA_Pos)                 /*!< MPU CTRL: HFNMIENA Mask */
597
+
598
+#define MPU_CTRL_ENABLE_Pos                 0U                                            /*!< MPU CTRL: ENABLE Position */
599
+#define MPU_CTRL_ENABLE_Msk                (1UL /*<< MPU_CTRL_ENABLE_Pos*/)               /*!< MPU CTRL: ENABLE Mask */
600
+
601
+/* MPU Region Number Register Definitions */
602
+#define MPU_RNR_REGION_Pos                  0U                                            /*!< MPU RNR: REGION Position */
603
+#define MPU_RNR_REGION_Msk                 (0xFFUL /*<< MPU_RNR_REGION_Pos*/)             /*!< MPU RNR: REGION Mask */
604
+
605
+/* MPU Region Base Address Register Definitions */
606
+#define MPU_RBAR_ADDR_Pos                   8U                                            /*!< MPU RBAR: ADDR Position */
607
+#define MPU_RBAR_ADDR_Msk                  (0xFFFFFFUL << MPU_RBAR_ADDR_Pos)              /*!< MPU RBAR: ADDR Mask */
608
+
609
+#define MPU_RBAR_VALID_Pos                  4U                                            /*!< MPU RBAR: VALID Position */
610
+#define MPU_RBAR_VALID_Msk                 (1UL << MPU_RBAR_VALID_Pos)                    /*!< MPU RBAR: VALID Mask */
611
+
612
+#define MPU_RBAR_REGION_Pos                 0U                                            /*!< MPU RBAR: REGION Position */
613
+#define MPU_RBAR_REGION_Msk                (0xFUL /*<< MPU_RBAR_REGION_Pos*/)             /*!< MPU RBAR: REGION Mask */
614
+
615
+/* MPU Region Attribute and Size Register Definitions */
616
+#define MPU_RASR_ATTRS_Pos                 16U                                            /*!< MPU RASR: MPU Region Attribute field Position */
617
+#define MPU_RASR_ATTRS_Msk                 (0xFFFFUL << MPU_RASR_ATTRS_Pos)               /*!< MPU RASR: MPU Region Attribute field Mask */
618
+
619
+#define MPU_RASR_XN_Pos                    28U                                            /*!< MPU RASR: ATTRS.XN Position */
620
+#define MPU_RASR_XN_Msk                    (1UL << MPU_RASR_XN_Pos)                       /*!< MPU RASR: ATTRS.XN Mask */
621
+
622
+#define MPU_RASR_AP_Pos                    24U                                            /*!< MPU RASR: ATTRS.AP Position */
623
+#define MPU_RASR_AP_Msk                    (0x7UL << MPU_RASR_AP_Pos)                     /*!< MPU RASR: ATTRS.AP Mask */
624
+
625
+#define MPU_RASR_TEX_Pos                   19U                                            /*!< MPU RASR: ATTRS.TEX Position */
626
+#define MPU_RASR_TEX_Msk                   (0x7UL << MPU_RASR_TEX_Pos)                    /*!< MPU RASR: ATTRS.TEX Mask */
627
+
628
+#define MPU_RASR_S_Pos                     18U                                            /*!< MPU RASR: ATTRS.S Position */
629
+#define MPU_RASR_S_Msk                     (1UL << MPU_RASR_S_Pos)                        /*!< MPU RASR: ATTRS.S Mask */
630
+
631
+#define MPU_RASR_C_Pos                     17U                                            /*!< MPU RASR: ATTRS.C Position */
632
+#define MPU_RASR_C_Msk                     (1UL << MPU_RASR_C_Pos)                        /*!< MPU RASR: ATTRS.C Mask */
633
+
634
+#define MPU_RASR_B_Pos                     16U                                            /*!< MPU RASR: ATTRS.B Position */
635
+#define MPU_RASR_B_Msk                     (1UL << MPU_RASR_B_Pos)                        /*!< MPU RASR: ATTRS.B Mask */
636
+
637
+#define MPU_RASR_SRD_Pos                    8U                                            /*!< MPU RASR: Sub-Region Disable Position */
638
+#define MPU_RASR_SRD_Msk                   (0xFFUL << MPU_RASR_SRD_Pos)                   /*!< MPU RASR: Sub-Region Disable Mask */
639
+
640
+#define MPU_RASR_SIZE_Pos                   1U                                            /*!< MPU RASR: Region Size Field Position */
641
+#define MPU_RASR_SIZE_Msk                  (0x1FUL << MPU_RASR_SIZE_Pos)                  /*!< MPU RASR: Region Size Field Mask */
642
+
643
+#define MPU_RASR_ENABLE_Pos                 0U                                            /*!< MPU RASR: Region enable bit Position */
644
+#define MPU_RASR_ENABLE_Msk                (1UL /*<< MPU_RASR_ENABLE_Pos*/)               /*!< MPU RASR: Region enable bit Disable Mask */
645
+
646
+/*@} end of group CMSIS_MPU */
647
+#endif
648
+
649
+
650
+/**
651
+  \ingroup  CMSIS_core_register
652
+  \defgroup CMSIS_CoreDebug       Core Debug Registers (CoreDebug)
653
+  \brief    Cortex-M0+ Core Debug Registers (DCB registers, SHCSR, and DFSR) are only accessible over DAP and not via processor.
654
+            Therefore they are not covered by the Cortex-M0+ header file.
655
+  @{
656
+ */
657
+/*@} end of group CMSIS_CoreDebug */
658
+
659
+
660
+/**
661
+  \ingroup    CMSIS_core_register
662
+  \defgroup   CMSIS_core_bitfield     Core register bit field macros
663
+  \brief      Macros for use with bit field definitions (xxx_Pos, xxx_Msk).
664
+  @{
665
+ */
666
+
667
+/**
668
+  \brief   Mask and shift a bit field value for use in a register bit range.
669
+  \param[in] field  Name of the register bit field.
670
+  \param[in] value  Value of the bit field.
671
+  \return           Masked and shifted value.
672
+*/
673
+#define _VAL2FLD(field, value)    ((value << field ## _Pos) & field ## _Msk)
674
+
675
+/**
676
+  \brief     Mask and shift a register value to extract a bit filed value.
677
+  \param[in] field  Name of the register bit field.
678
+  \param[in] value  Value of register.
679
+  \return           Masked and shifted bit field value.
680
+*/
681
+#define _FLD2VAL(field, value)    ((value & field ## _Msk) >> field ## _Pos)
682
+
683
+/*@} end of group CMSIS_core_bitfield */
684
+
685
+
686
+/**
687
+  \ingroup    CMSIS_core_register
688
+  \defgroup   CMSIS_core_base     Core Definitions
689
+  \brief      Definitions for base addresses, unions, and structures.
690
+  @{
691
+ */
692
+
693
+/* Memory mapping of Cortex-M0+ Hardware */
694
+#define SCS_BASE            (0xE000E000UL)                            /*!< System Control Space Base Address */
695
+#define SysTick_BASE        (SCS_BASE +  0x0010UL)                    /*!< SysTick Base Address */
696
+#define NVIC_BASE           (SCS_BASE +  0x0100UL)                    /*!< NVIC Base Address */
697
+#define SCB_BASE            (SCS_BASE +  0x0D00UL)                    /*!< System Control Block Base Address */
698
+
699
+#define SCB                 ((SCB_Type       *)     SCB_BASE      )   /*!< SCB configuration struct */
700
+#define SysTick             ((SysTick_Type   *)     SysTick_BASE  )   /*!< SysTick configuration struct */
701
+#define NVIC                ((NVIC_Type      *)     NVIC_BASE     )   /*!< NVIC configuration struct */
702
+
703
+#if (__MPU_PRESENT == 1U)
704
+  #define MPU_BASE          (SCS_BASE +  0x0D90UL)                    /*!< Memory Protection Unit */
705
+  #define MPU               ((MPU_Type       *)     MPU_BASE      )   /*!< Memory Protection Unit */
706
+#endif
707
+
708
+/*@} */
709
+
710
+
711
+
712
+/*******************************************************************************
713
+ *                Hardware Abstraction Layer
714
+  Core Function Interface contains:
715
+  - Core NVIC Functions
716
+  - Core SysTick Functions
717
+  - Core Register Access Functions
718
+ ******************************************************************************/
719
+/**
720
+  \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference
721
+*/
722
+
723
+
724
+
725
+/* ##########################   NVIC functions  #################################### */
726
+/**
727
+  \ingroup  CMSIS_Core_FunctionInterface
728
+  \defgroup CMSIS_Core_NVICFunctions NVIC Functions
729
+  \brief    Functions that manage interrupts and exceptions via the NVIC.
730
+  @{
731
+ */
732
+
733
+/* Interrupt Priorities are WORD accessible only under ARMv6M                   */
734
+/* The following MACROS handle generation of the register offset and byte masks */
735
+#define _BIT_SHIFT(IRQn)         (  ((((uint32_t)(int32_t)(IRQn))         )      &  0x03UL) * 8UL)
736
+#define _SHP_IDX(IRQn)           ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >>    2UL)      )
737
+#define _IP_IDX(IRQn)            (   (((uint32_t)(int32_t)(IRQn))                >>    2UL)      )
738
+
739
+
740
+/**
741
+  \brief   Enable External Interrupt
742
+  \details Enables a device-specific interrupt in the NVIC interrupt controller.
743
+  \param [in]      IRQn  External interrupt number. Value cannot be negative.
744
+ */
745
+__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)
746
+{
747
+  NVIC->ISER[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
748
+}
749
+
750
+
751
+/**
752
+  \brief   Disable External Interrupt
753
+  \details Disables a device-specific interrupt in the NVIC interrupt controller.
754
+  \param [in]      IRQn  External interrupt number. Value cannot be negative.
755
+ */
756
+__STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn)
757
+{
758
+  NVIC->ICER[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
759
+}
760
+
761
+
762
+/**
763
+  \brief   Get Pending Interrupt
764
+  \details Reads the pending register in the NVIC and returns the pending bit for the specified interrupt.
765
+  \param [in]      IRQn  Interrupt number.
766
+  \return             0  Interrupt status is not pending.
767
+  \return             1  Interrupt status is pending.
768
+ */
769
+__STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn)
770
+{
771
+  return((uint32_t)(((NVIC->ISPR[0U] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
772
+}
773
+
774
+
775
+/**
776
+  \brief   Set Pending Interrupt
777
+  \details Sets the pending bit of an external interrupt.
778
+  \param [in]      IRQn  Interrupt number. Value cannot be negative.
779
+ */
780
+__STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn)
781
+{
782
+  NVIC->ISPR[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
783
+}
784
+
785
+
786
+/**
787
+  \brief   Clear Pending Interrupt
788
+  \details Clears the pending bit of an external interrupt.
789
+  \param [in]      IRQn  External interrupt number. Value cannot be negative.
790
+ */
791
+__STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn)
792
+{
793
+  NVIC->ICPR[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
794
+}
795
+
796
+
797
+/**
798
+  \brief   Set Interrupt Priority
799
+  \details Sets the priority of an interrupt.
800
+  \note    The priority cannot be set for every core interrupt.
801
+  \param [in]      IRQn  Interrupt number.
802
+  \param [in]  priority  Priority to set.
803
+ */
804
+__STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
805
+{
806
+  if ((int32_t)(IRQn) < 0)
807
+  {
808
+    SCB->SHP[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) |
809
+       (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn)));
810
+  }
811
+  else
812
+  {
813
+    NVIC->IP[_IP_IDX(IRQn)]  = ((uint32_t)(NVIC->IP[_IP_IDX(IRQn)]  & ~(0xFFUL << _BIT_SHIFT(IRQn))) |
814
+       (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn)));
815
+  }
816
+}
817
+
818
+
819
+/**
820
+  \brief   Get Interrupt Priority
821
+  \details Reads the priority of an interrupt.
822
+           The interrupt number can be positive to specify an external (device specific) interrupt,
823
+           or negative to specify an internal (core) interrupt.
824
+  \param [in]   IRQn  Interrupt number.
825
+  \return             Interrupt Priority.
826
+                      Value is aligned automatically to the implemented priority bits of the microcontroller.
827
+ */
828
+__STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn)
829
+{
830
+
831
+  if ((int32_t)(IRQn) < 0)
832
+  {
833
+    return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS)));
834
+  }
835
+  else
836
+  {
837
+    return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS)));
838
+  }
839
+}
840
+
841
+
842
+/**
843
+  \brief   System Reset
844
+  \details Initiates a system reset request to reset the MCU.
845
+ */
846
+__STATIC_INLINE void NVIC_SystemReset(void)
847
+{
848
+  __DSB();                                                          /* Ensure all outstanding memory accesses included
849
+                                                                       buffered write are completed before reset */
850
+  SCB->AIRCR  = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) |
851
+                 SCB_AIRCR_SYSRESETREQ_Msk);
852
+  __DSB();                                                          /* Ensure completion of memory access */
853
+
854
+  for(;;)                                                           /* wait until reset */
855
+  {
856
+    __NOP();
857
+  }
858
+}
859
+
860
+/*@} end of CMSIS_Core_NVICFunctions */
861
+
862
+
863
+
864
+/* ##################################    SysTick function  ############################################ */
865
+/**
866
+  \ingroup  CMSIS_Core_FunctionInterface
867
+  \defgroup CMSIS_Core_SysTickFunctions SysTick Functions
868
+  \brief    Functions that configure the System.
869
+  @{
870
+ */
871
+
872
+#if (__Vendor_SysTickConfig == 0U)
873
+
874
+/**
875
+  \brief   System Tick Configuration
876
+  \details Initializes the System Timer and its interrupt, and starts the System Tick Timer.
877
+           Counter is in free running mode to generate periodic interrupts.
878
+  \param [in]  ticks  Number of ticks between two interrupts.
879
+  \return          0  Function succeeded.
880
+  \return          1  Function failed.
881
+  \note    When the variable <b>__Vendor_SysTickConfig</b> is set to 1, then the
882
+           function <b>SysTick_Config</b> is not included. In this case, the file <b><i>device</i>.h</b>
883
+           must contain a vendor-specific implementation of this function.
884
+ */
885
+__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks)
886
+{
887
+  if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk)
888
+  {
889
+    return (1UL);                                                   /* Reload value impossible */
890
+  }
891
+
892
+  SysTick->LOAD  = (uint32_t)(ticks - 1UL);                         /* set reload register */
893
+  NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */
894
+  SysTick->VAL   = 0UL;                                             /* Load the SysTick Counter Value */
895
+  SysTick->CTRL  = SysTick_CTRL_CLKSOURCE_Msk |
896
+                   SysTick_CTRL_TICKINT_Msk   |
897
+                   SysTick_CTRL_ENABLE_Msk;                         /* Enable SysTick IRQ and SysTick Timer */
898
+  return (0UL);                                                     /* Function successful */
899
+}
900
+
901
+#endif
902
+
903
+/*@} end of CMSIS_Core_SysTickFunctions */
904
+
905
+
906
+
907
+
908
+#ifdef __cplusplus
909
+}
910
+#endif
911
+
912
+#endif /* __CORE_CM0PLUS_H_DEPENDANT */
913
+
914
+#endif /* __CMSIS_GENERIC */

文件差异内容过多而无法显示
+ 1763 - 0
Drivers/CMSIS/Include/core_cm3.h


文件差异内容过多而无法显示
+ 1937 - 0
Drivers/CMSIS/Include/core_cm4.h


文件差异内容过多而无法显示
+ 2512 - 0
Drivers/CMSIS/Include/core_cm7.h


+ 87 - 0
Drivers/CMSIS/Include/core_cmFunc.h

@@ -0,0 +1,87 @@
1
+/**************************************************************************//**
2
+ * @file     core_cmFunc.h
3
+ * @brief    CMSIS Cortex-M Core Function Access Header File
4
+ * @version  V4.30
5
+ * @date     20. October 2015
6
+ ******************************************************************************/
7
+/* Copyright (c) 2009 - 2015 ARM LIMITED
8
+
9
+   All rights reserved.
10
+   Redistribution and use in source and binary forms, with or without
11
+   modification, are permitted provided that the following conditions are met:
12
+   - Redistributions of source code must retain the above copyright
13
+     notice, this list of conditions and the following disclaimer.
14
+   - Redistributions in binary form must reproduce the above copyright
15
+     notice, this list of conditions and the following disclaimer in the
16
+     documentation and/or other materials provided with the distribution.
17
+   - Neither the name of ARM nor the names of its contributors may be used
18
+     to endorse or promote products derived from this software without
19
+     specific prior written permission.
20
+   *
21
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22
+   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23
+   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24
+   ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
25
+   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26
+   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27
+   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
+   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
+   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
+   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
+   POSSIBILITY OF SUCH DAMAGE.
32
+   ---------------------------------------------------------------------------*/
33
+
34
+
35
+#if   defined ( __ICCARM__ )
36
+ #pragma system_include         /* treat file as system include file for MISRA check */
37
+#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
38
+  #pragma clang system_header   /* treat file as system include file */
39
+#endif
40
+
41
+#ifndef __CORE_CMFUNC_H
42
+#define __CORE_CMFUNC_H
43
+
44
+
45
+/* ###########################  Core Function Access  ########################### */
46
+/** \ingroup  CMSIS_Core_FunctionInterface
47
+    \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
48
+  @{
49
+*/
50
+
51
+/*------------------ RealView Compiler -----------------*/
52
+#if   defined ( __CC_ARM )
53
+  #include "cmsis_armcc.h"
54
+
55
+/*------------------ ARM Compiler V6 -------------------*/
56
+#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
57
+  #include "cmsis_armcc_V6.h"
58
+
59
+/*------------------ GNU Compiler ----------------------*/
60
+#elif defined ( __GNUC__ )
61
+  #include "cmsis_gcc.h"
62
+
63
+/*------------------ ICC Compiler ----------------------*/
64
+#elif defined ( __ICCARM__ )
65
+  #include <cmsis_iar.h>
66
+
67
+/*------------------ TI CCS Compiler -------------------*/
68
+#elif defined ( __TMS470__ )
69
+  #include <cmsis_ccs.h>
70
+
71
+/*------------------ TASKING Compiler ------------------*/
72
+#elif defined ( __TASKING__ )
73
+  /*
74
+   * The CMSIS functions have been implemented as intrinsics in the compiler.
75
+   * Please use "carm -?i" to get an up to date list of all intrinsics,
76
+   * Including the CMSIS ones.
77
+   */
78
+
79
+/*------------------ COSMIC Compiler -------------------*/
80
+#elif defined ( __CSMC__ )
81
+  #include <cmsis_csm.h>
82
+
83
+#endif
84
+
85
+/*@} end of CMSIS_Core_RegAccFunctions */
86
+
87
+#endif /* __CORE_CMFUNC_H */

+ 87 - 0
Drivers/CMSIS/Include/core_cmInstr.h

@@ -0,0 +1,87 @@
1
+/**************************************************************************//**
2
+ * @file     core_cmInstr.h
3
+ * @brief    CMSIS Cortex-M Core Instruction Access Header File
4
+ * @version  V4.30
5
+ * @date     20. October 2015
6
+ ******************************************************************************/
7
+/* Copyright (c) 2009 - 2015 ARM LIMITED
8
+
9
+   All rights reserved.
10
+   Redistribution and use in source and binary forms, with or without
11
+   modification, are permitted provided that the following conditions are met:
12
+   - Redistributions of source code must retain the above copyright
13
+     notice, this list of conditions and the following disclaimer.
14
+   - Redistributions in binary form must reproduce the above copyright
15
+     notice, this list of conditions and the following disclaimer in the
16
+     documentation and/or other materials provided with the distribution.
17
+   - Neither the name of ARM nor the names of its contributors may be used
18
+     to endorse or promote products derived from this software without
19
+     specific prior written permission.
20
+   *
21
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22
+   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23
+   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24
+   ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
25
+   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26
+   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27
+   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
+   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
+   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
+   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
+   POSSIBILITY OF SUCH DAMAGE.
32
+   ---------------------------------------------------------------------------*/
33
+
34
+
35
+#if   defined ( __ICCARM__ )
36
+ #pragma system_include         /* treat file as system include file for MISRA check */
37
+#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
38
+  #pragma clang system_header   /* treat file as system include file */
39
+#endif
40
+
41
+#ifndef __CORE_CMINSTR_H
42
+#define __CORE_CMINSTR_H
43
+
44
+
45
+/* ##########################  Core Instruction Access  ######################### */
46
+/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
47
+  Access to dedicated instructions
48
+  @{
49
+*/
50
+
51
+/*------------------ RealView Compiler -----------------*/
52
+#if   defined ( __CC_ARM )
53
+  #include "cmsis_armcc.h"
54
+
55
+/*------------------ ARM Compiler V6 -------------------*/
56
+#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
57
+  #include "cmsis_armcc_V6.h"
58
+
59
+/*------------------ GNU Compiler ----------------------*/
60
+#elif defined ( __GNUC__ )
61
+  #include "cmsis_gcc.h"
62
+
63
+/*------------------ ICC Compiler ----------------------*/
64
+#elif defined ( __ICCARM__ )
65
+  #include <cmsis_iar.h>
66
+
67
+/*------------------ TI CCS Compiler -------------------*/
68
+#elif defined ( __TMS470__ )
69
+  #include <cmsis_ccs.h>
70
+
71
+/*------------------ TASKING Compiler ------------------*/
72
+#elif defined ( __TASKING__ )
73
+  /*
74
+   * The CMSIS functions have been implemented as intrinsics in the compiler.
75
+   * Please use "carm -?i" to get an up to date list of all intrinsics,
76
+   * Including the CMSIS ones.
77
+   */
78
+
79
+/*------------------ COSMIC Compiler -------------------*/
80
+#elif defined ( __CSMC__ )
81
+  #include <cmsis_csm.h>
82
+
83
+#endif
84
+
85
+/*@}*/ /* end of group CMSIS_Core_InstructionInterface */
86
+
87
+#endif /* __CORE_CMINSTR_H */

+ 96 - 0
Drivers/CMSIS/Include/core_cmSimd.h

@@ -0,0 +1,96 @@
1
+/**************************************************************************//**
2
+ * @file     core_cmSimd.h
3
+ * @brief    CMSIS Cortex-M SIMD Header File
4
+ * @version  V4.30
5
+ * @date     20. October 2015
6
+ ******************************************************************************/
7
+/* Copyright (c) 2009 - 2015 ARM LIMITED
8
+
9
+   All rights reserved.
10
+   Redistribution and use in source and binary forms, with or without
11
+   modification, are permitted provided that the following conditions are met:
12
+   - Redistributions of source code must retain the above copyright
13
+     notice, this list of conditions and the following disclaimer.
14
+   - Redistributions in binary form must reproduce the above copyright
15
+     notice, this list of conditions and the following disclaimer in the
16
+     documentation and/or other materials provided with the distribution.
17
+   - Neither the name of ARM nor the names of its contributors may be used
18
+     to endorse or promote products derived from this software without
19
+     specific prior written permission.
20
+   *
21
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22
+   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23
+   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24
+   ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
25
+   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26
+   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27
+   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
+   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
+   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
+   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
+   POSSIBILITY OF SUCH DAMAGE.
32
+   ---------------------------------------------------------------------------*/
33
+
34
+
35
+#if   defined ( __ICCARM__ )
36
+ #pragma system_include         /* treat file as system include file for MISRA check */
37
+#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
38
+  #pragma clang system_header   /* treat file as system include file */
39
+#endif
40
+
41
+#ifndef __CORE_CMSIMD_H
42
+#define __CORE_CMSIMD_H
43
+
44
+#ifdef __cplusplus
45
+ extern "C" {
46
+#endif
47
+
48
+
49
+/* ###################  Compiler specific Intrinsics  ########################### */
50
+/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
51
+  Access to dedicated SIMD instructions
52
+  @{
53
+*/
54
+
55
+/*------------------ RealView Compiler -----------------*/
56
+#if   defined ( __CC_ARM )
57
+  #include "cmsis_armcc.h"
58
+
59
+/*------------------ ARM Compiler V6 -------------------*/
60
+#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
61
+  #include "cmsis_armcc_V6.h"
62
+
63
+/*------------------ GNU Compiler ----------------------*/
64
+#elif defined ( __GNUC__ )
65
+  #include "cmsis_gcc.h"
66
+
67
+/*------------------ ICC Compiler ----------------------*/
68
+#elif defined ( __ICCARM__ )
69
+  #include <cmsis_iar.h>
70
+
71
+/*------------------ TI CCS Compiler -------------------*/
72
+#elif defined ( __TMS470__ )
73
+  #include <cmsis_ccs.h>
74
+
75
+/*------------------ TASKING Compiler ------------------*/
76
+#elif defined ( __TASKING__ )
77
+  /*
78
+   * The CMSIS functions have been implemented as intrinsics in the compiler.
79
+   * Please use "carm -?i" to get an up to date list of all intrinsics,
80
+   * Including the CMSIS ones.
81
+   */
82
+
83
+/*------------------ COSMIC Compiler -------------------*/
84
+#elif defined ( __CSMC__ )
85
+  #include <cmsis_csm.h>
86
+
87
+#endif
88
+
89
+/*@} end of group CMSIS_SIMD_intrinsics */
90
+
91
+
92
+#ifdef __cplusplus
93
+}
94
+#endif
95
+
96
+#endif /* __CORE_CMSIMD_H */

+ 926 - 0
Drivers/CMSIS/Include/core_sc000.h

@@ -0,0 +1,926 @@
1
+/**************************************************************************//**
2
+ * @file     core_sc000.h
3
+ * @brief    CMSIS SC000 Core Peripheral Access Layer Header File
4
+ * @version  V4.30
5
+ * @date     20. October 2015
6
+ ******************************************************************************/
7
+/* Copyright (c) 2009 - 2015 ARM LIMITED
8
+
9
+   All rights reserved.
10
+   Redistribution and use in source and binary forms, with or without
11
+   modification, are permitted provided that the following conditions are met:
12
+   - Redistributions of source code must retain the above copyright
13
+     notice, this list of conditions and the following disclaimer.
14
+   - Redistributions in binary form must reproduce the above copyright
15
+     notice, this list of conditions and the following disclaimer in the
16
+     documentation and/or other materials provided with the distribution.
17
+   - Neither the name of ARM nor the names of its contributors may be used
18
+     to endorse or promote products derived from this software without
19
+     specific prior written permission.
20
+   *
21
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22
+   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23
+   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24
+   ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
25
+   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26
+   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27
+   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
+   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
+   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
+   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
+   POSSIBILITY OF SUCH DAMAGE.
32
+   ---------------------------------------------------------------------------*/
33
+
34
+
35
+#if   defined ( __ICCARM__ )
36
+ #pragma system_include         /* treat file as system include file for MISRA check */
37
+#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
38
+  #pragma clang system_header   /* treat file as system include file */
39
+#endif
40
+
41
+#ifndef __CORE_SC000_H_GENERIC
42
+#define __CORE_SC000_H_GENERIC
43
+
44
+#include <stdint.h>
45
+
46
+#ifdef __cplusplus
47
+ extern "C" {
48
+#endif
49
+
50
+/**
51
+  \page CMSIS_MISRA_Exceptions  MISRA-C:2004 Compliance Exceptions
52
+  CMSIS violates the following MISRA-C:2004 rules:
53
+
54
+   \li Required Rule 8.5, object/function definition in header file.<br>
55
+     Function definitions in header files are used to allow 'inlining'.
56
+
57
+   \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.<br>
58
+     Unions are used for effective representation of core registers.
59
+
60
+   \li Advisory Rule 19.7, Function-like macro defined.<br>
61
+     Function-like macros are used to allow more efficient code.
62
+ */
63
+
64
+
65
+/*******************************************************************************
66
+ *                 CMSIS definitions
67
+ ******************************************************************************/
68
+/**
69
+  \ingroup SC000
70
+  @{
71
+ */
72
+
73
+/*  CMSIS SC000 definitions */
74
+#define __SC000_CMSIS_VERSION_MAIN  (0x04U)                                    /*!< [31:16] CMSIS HAL main version */
75
+#define __SC000_CMSIS_VERSION_SUB   (0x1EU)                                    /*!< [15:0]  CMSIS HAL sub version */
76
+#define __SC000_CMSIS_VERSION       ((__SC000_CMSIS_VERSION_MAIN << 16U) | \
77
+                                      __SC000_CMSIS_VERSION_SUB           )    /*!< CMSIS HAL version number */
78
+
79
+#define __CORTEX_SC                 (000U)                                     /*!< Cortex secure core */
80
+
81
+
82
+#if   defined ( __CC_ARM )
83
+  #define __ASM            __asm                                      /*!< asm keyword for ARM Compiler */
84
+  #define __INLINE         __inline                                   /*!< inline keyword for ARM Compiler */
85
+  #define __STATIC_INLINE  static __inline
86
+
87
+#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
88
+  #define __ASM            __asm                                      /*!< asm keyword for ARM Compiler */
89
+  #define __INLINE         __inline                                   /*!< inline keyword for ARM Compiler */
90
+  #define __STATIC_INLINE  static __inline
91
+
92
+#elif defined ( __GNUC__ )
93
+  #define __ASM            __asm                                      /*!< asm keyword for GNU Compiler */
94
+  #define __INLINE         inline                                     /*!< inline keyword for GNU Compiler */
95
+  #define __STATIC_INLINE  static inline
96
+
97
+#elif defined ( __ICCARM__ )
98
+  #define __ASM            __asm                                      /*!< asm keyword for IAR Compiler */
99
+  #define __INLINE         inline                                     /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */
100
+  #define __STATIC_INLINE  static inline
101
+
102
+#elif defined ( __TMS470__ )
103
+  #define __ASM            __asm                                      /*!< asm keyword for TI CCS Compiler */
104
+  #define __STATIC_INLINE  static inline
105
+
106
+#elif defined ( __TASKING__ )
107
+  #define __ASM            __asm                                      /*!< asm keyword for TASKING Compiler */
108
+  #define __INLINE         inline                                     /*!< inline keyword for TASKING Compiler */
109
+  #define __STATIC_INLINE  static inline
110
+
111
+#elif defined ( __CSMC__ )
112
+  #define __packed
113
+  #define __ASM            _asm                                      /*!< asm keyword for COSMIC Compiler */
114
+  #define __INLINE         inline                                    /*!< inline keyword for COSMIC Compiler. Use -pc99 on compile line */
115
+  #define __STATIC_INLINE  static inline
116
+
117
+#else
118
+  #error Unknown compiler
119
+#endif
120
+
121
+/** __FPU_USED indicates whether an FPU is used or not.
122
+    This core does not support an FPU at all
123
+*/
124
+#define __FPU_USED       0U
125
+
126
+#if defined ( __CC_ARM )
127
+  #if defined __TARGET_FPU_VFP
128
+    #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
129
+  #endif
130
+
131
+#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
132
+  #if defined __ARM_PCS_VFP
133
+    #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
134
+  #endif
135
+
136
+#elif defined ( __GNUC__ )
137
+  #if defined (__VFP_FP__) && !defined(__SOFTFP__)
138
+    #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
139
+  #endif
140
+
141
+#elif defined ( __ICCARM__ )
142
+  #if defined __ARMVFP__
143
+    #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
144
+  #endif
145
+
146
+#elif defined ( __TMS470__ )
147
+  #if defined __TI_VFP_SUPPORT__
148
+    #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
149
+  #endif
150
+
151
+#elif defined ( __TASKING__ )
152
+  #if defined __FPU_VFP__
153
+    #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
154
+  #endif
155
+
156
+#elif defined ( __CSMC__ )
157
+  #if ( __CSMC__ & 0x400U)
158
+    #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
159
+  #endif
160
+
161
+#endif
162
+
163
+#include "core_cmInstr.h"                /* Core Instruction Access */
164
+#include "core_cmFunc.h"                 /* Core Function Access */
165
+
166
+#ifdef __cplusplus
167
+}
168
+#endif
169
+
170
+#endif /* __CORE_SC000_H_GENERIC */
171
+
172
+#ifndef __CMSIS_GENERIC
173
+
174
+#ifndef __CORE_SC000_H_DEPENDANT
175
+#define __CORE_SC000_H_DEPENDANT
176
+
177
+#ifdef __cplusplus
178
+ extern "C" {
179
+#endif
180
+
181
+/* check device defines and use defaults */
182
+#if defined __CHECK_DEVICE_DEFINES
183
+  #ifndef __SC000_REV
184
+    #define __SC000_REV             0x0000U
185
+    #warning "__SC000_REV not defined in device header file; using default!"
186
+  #endif
187
+
188
+  #ifndef __MPU_PRESENT
189
+    #define __MPU_PRESENT             0U
190
+    #warning "__MPU_PRESENT not defined in device header file; using default!"
191
+  #endif
192
+
193
+  #ifndef __NVIC_PRIO_BITS
194
+    #define __NVIC_PRIO_BITS          2U
195
+    #warning "__NVIC_PRIO_BITS not defined in device header file; using default!"
196
+  #endif
197
+
198
+  #ifndef __Vendor_SysTickConfig
199
+    #define __Vendor_SysTickConfig    0U
200
+    #warning "__Vendor_SysTickConfig not defined in device header file; using default!"
201
+  #endif
202
+#endif
203
+
204
+/* IO definitions (access restrictions to peripheral registers) */
205
+/**
206
+    \defgroup CMSIS_glob_defs CMSIS Global Defines
207
+
208
+    <strong>IO Type Qualifiers</strong> are used
209
+    \li to specify the access to peripheral variables.
210
+    \li for automatic generation of peripheral register debug information.
211
+*/
212
+#ifdef __cplusplus
213
+  #define   __I     volatile             /*!< Defines 'read only' permissions */
214
+#else
215
+  #define   __I     volatile const       /*!< Defines 'read only' permissions */
216
+#endif
217
+#define     __O     volatile             /*!< Defines 'write only' permissions */
218
+#define     __IO    volatile             /*!< Defines 'read / write' permissions */
219
+
220
+/* following defines should be used for structure members */
221
+#define     __IM     volatile const      /*! Defines 'read only' structure member permissions */
222
+#define     __OM     volatile            /*! Defines 'write only' structure member permissions */
223
+#define     __IOM    volatile            /*! Defines 'read / write' structure member permissions */
224
+
225
+/*@} end of group SC000 */
226
+
227
+
228
+
229
+/*******************************************************************************
230
+ *                 Register Abstraction
231
+  Core Register contain:
232
+  - Core Register
233
+  - Core NVIC Register
234
+  - Core SCB Register
235
+  - Core SysTick Register
236
+  - Core MPU Register
237
+ ******************************************************************************/
238
+/**
239
+  \defgroup CMSIS_core_register Defines and Type Definitions
240
+  \brief Type definitions and defines for Cortex-M processor based devices.
241
+*/
242
+
243
+/**
244
+  \ingroup    CMSIS_core_register
245
+  \defgroup   CMSIS_CORE  Status and Control Registers
246
+  \brief      Core Register type definitions.
247
+  @{
248
+ */
249
+
250
+/**
251
+  \brief  Union type to access the Application Program Status Register (APSR).
252
+ */
253
+typedef union
254
+{
255
+  struct
256
+  {
257
+    uint32_t _reserved0:28;              /*!< bit:  0..27  Reserved */
258
+    uint32_t V:1;                        /*!< bit:     28  Overflow condition code flag */
259
+    uint32_t C:1;                        /*!< bit:     29  Carry condition code flag */
260
+    uint32_t Z:1;                        /*!< bit:     30  Zero condition code flag */
261
+    uint32_t N:1;                        /*!< bit:     31  Negative condition code flag */
262
+  } b;                                   /*!< Structure used for bit  access */
263
+  uint32_t w;                            /*!< Type      used for word access */
264
+} APSR_Type;
265
+
266
+/* APSR Register Definitions */
267
+#define APSR_N_Pos                         31U                                            /*!< APSR: N Position */
268
+#define APSR_N_Msk                         (1UL << APSR_N_Pos)                            /*!< APSR: N Mask */
269
+
270
+#define APSR_Z_Pos                         30U                                            /*!< APSR: Z Position */
271
+#define APSR_Z_Msk                         (1UL << APSR_Z_Pos)                            /*!< APSR: Z Mask */
272
+
273
+#define APSR_C_Pos                         29U                                            /*!< APSR: C Position */
274
+#define APSR_C_Msk                         (1UL << APSR_C_Pos)                            /*!< APSR: C Mask */
275
+
276
+#define APSR_V_Pos                         28U                                            /*!< APSR: V Position */
277
+#define APSR_V_Msk                         (1UL << APSR_V_Pos)                            /*!< APSR: V Mask */
278
+
279
+
280
+/**
281
+  \brief  Union type to access the Interrupt Program Status Register (IPSR).
282
+ */
283
+typedef union
284
+{
285
+  struct
286
+  {
287
+    uint32_t ISR:9;                      /*!< bit:  0.. 8  Exception number */
288
+    uint32_t _reserved0:23;              /*!< bit:  9..31  Reserved */
289
+  } b;                                   /*!< Structure used for bit  access */
290
+  uint32_t w;                            /*!< Type      used for word access */
291
+} IPSR_Type;
292
+
293
+/* IPSR Register Definitions */
294
+#define IPSR_ISR_Pos                        0U                                            /*!< IPSR: ISR Position */
295
+#define IPSR_ISR_Msk                       (0x1FFUL /*<< IPSR_ISR_Pos*/)                  /*!< IPSR: ISR Mask */
296
+
297
+
298
+/**
299
+  \brief  Union type to access the Special-Purpose Program Status Registers (xPSR).
300
+ */
301
+typedef union
302
+{
303
+  struct
304
+  {
305
+    uint32_t ISR:9;                      /*!< bit:  0.. 8  Exception number */
306
+    uint32_t _reserved0:15;              /*!< bit:  9..23  Reserved */
307
+    uint32_t T:1;                        /*!< bit:     24  Thumb bit        (read 0) */
308
+    uint32_t _reserved1:3;               /*!< bit: 25..27  Reserved */
309
+    uint32_t V:1;                        /*!< bit:     28  Overflow condition code flag */
310
+    uint32_t C:1;                        /*!< bit:     29  Carry condition code flag */
311
+    uint32_t Z:1;                        /*!< bit:     30  Zero condition code flag */
312
+    uint32_t N:1;                        /*!< bit:     31  Negative condition code flag */
313
+  } b;                                   /*!< Structure used for bit  access */
314
+  uint32_t w;                            /*!< Type      used for word access */
315
+} xPSR_Type;
316
+
317
+/* xPSR Register Definitions */
318
+#define xPSR_N_Pos                         31U                                            /*!< xPSR: N Position */
319
+#define xPSR_N_Msk                         (1UL << xPSR_N_Pos)                            /*!< xPSR: N Mask */
320
+
321
+#define xPSR_Z_Pos                         30U                                            /*!< xPSR: Z Position */
322
+#define xPSR_Z_Msk                         (1UL << xPSR_Z_Pos)                            /*!< xPSR: Z Mask */
323
+
324
+#define xPSR_C_Pos                         29U                                            /*!< xPSR: C Position */
325
+#define xPSR_C_Msk                         (1UL << xPSR_C_Pos)                            /*!< xPSR: C Mask */
326
+
327
+#define xPSR_V_Pos                         28U                                            /*!< xPSR: V Position */
328
+#define xPSR_V_Msk                         (1UL << xPSR_V_Pos)                            /*!< xPSR: V Mask */
329
+
330
+#define xPSR_T_Pos                         24U                                            /*!< xPSR: T Position */
331
+#define xPSR_T_Msk                         (1UL << xPSR_T_Pos)                            /*!< xPSR: T Mask */
332
+
333
+#define xPSR_ISR_Pos                        0U                                            /*!< xPSR: ISR Position */
334
+#define xPSR_ISR_Msk                       (0x1FFUL /*<< xPSR_ISR_Pos*/)                  /*!< xPSR: ISR Mask */
335
+
336
+
337
+/**
338
+  \brief  Union type to access the Control Registers (CONTROL).
339
+ */
340
+typedef union
341
+{
342
+  struct
343
+  {
344
+    uint32_t _reserved0:1;               /*!< bit:      0  Reserved */
345
+    uint32_t SPSEL:1;                    /*!< bit:      1  Stack to be used */
346
+    uint32_t _reserved1:30;              /*!< bit:  2..31  Reserved */
347
+  } b;                                   /*!< Structure used for bit  access */
348
+  uint32_t w;                            /*!< Type      used for word access */
349
+} CONTROL_Type;
350
+
351
+/* CONTROL Register Definitions */
352
+#define CONTROL_SPSEL_Pos                   1U                                            /*!< CONTROL: SPSEL Position */
353
+#define CONTROL_SPSEL_Msk                  (1UL << CONTROL_SPSEL_Pos)                     /*!< CONTROL: SPSEL Mask */
354
+
355
+/*@} end of group CMSIS_CORE */
356
+
357
+
358
+/**
359
+  \ingroup    CMSIS_core_register
360
+  \defgroup   CMSIS_NVIC  Nested Vectored Interrupt Controller (NVIC)
361
+  \brief      Type definitions for the NVIC Registers
362
+  @{
363
+ */
364
+
365
+/**
366
+  \brief  Structure type to access the Nested Vectored Interrupt Controller (NVIC).
367
+ */
368
+typedef struct
369
+{
370
+  __IOM uint32_t ISER[1U];               /*!< Offset: 0x000 (R/W)  Interrupt Set Enable Register */
371
+        uint32_t RESERVED0[31U];
372
+  __IOM uint32_t ICER[1U];               /*!< Offset: 0x080 (R/W)  Interrupt Clear Enable Register */
373
+        uint32_t RSERVED1[31U];
374
+  __IOM uint32_t ISPR[1U];               /*!< Offset: 0x100 (R/W)  Interrupt Set Pending Register */
375
+        uint32_t RESERVED2[31U];
376
+  __IOM uint32_t ICPR[1U];               /*!< Offset: 0x180 (R/W)  Interrupt Clear Pending Register */
377
+        uint32_t RESERVED3[31U];
378
+        uint32_t RESERVED4[64U];
379
+  __IOM uint32_t IP[8U];                 /*!< Offset: 0x300 (R/W)  Interrupt Priority Register */
380
+}  NVIC_Type;
381
+
382
+/*@} end of group CMSIS_NVIC */
383
+
384
+
385
+/**
386
+  \ingroup  CMSIS_core_register
387
+  \defgroup CMSIS_SCB     System Control Block (SCB)
388
+  \brief    Type definitions for the System Control Block Registers
389
+  @{
390
+ */
391
+
392
+/**
393
+  \brief  Structure type to access the System Control Block (SCB).
394
+ */
395
+typedef struct
396
+{
397
+  __IM  uint32_t CPUID;                  /*!< Offset: 0x000 (R/ )  CPUID Base Register */
398
+  __IOM uint32_t ICSR;                   /*!< Offset: 0x004 (R/W)  Interrupt Control and State Register */
399
+  __IOM uint32_t VTOR;                   /*!< Offset: 0x008 (R/W)  Vector Table Offset Register */
400
+  __IOM uint32_t AIRCR;                  /*!< Offset: 0x00C (R/W)  Application Interrupt and Reset Control Register */
401
+  __IOM uint32_t SCR;                    /*!< Offset: 0x010 (R/W)  System Control Register */
402
+  __IOM uint32_t CCR;                    /*!< Offset: 0x014 (R/W)  Configuration Control Register */
403
+        uint32_t RESERVED0[1U];
404
+  __IOM uint32_t SHP[2U];                /*!< Offset: 0x01C (R/W)  System Handlers Priority Registers. [0] is RESERVED */
405
+  __IOM uint32_t SHCSR;                  /*!< Offset: 0x024 (R/W)  System Handler Control and State Register */
406
+        uint32_t RESERVED1[154U];
407
+  __IOM uint32_t SFCR;                   /*!< Offset: 0x290 (R/W)  Security Features Control Register */
408
+} SCB_Type;
409
+
410
+/* SCB CPUID Register Definitions */
411
+#define SCB_CPUID_IMPLEMENTER_Pos          24U                                            /*!< SCB CPUID: IMPLEMENTER Position */
412
+#define SCB_CPUID_IMPLEMENTER_Msk          (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos)          /*!< SCB CPUID: IMPLEMENTER Mask */
413
+
414
+#define SCB_CPUID_VARIANT_Pos              20U                                            /*!< SCB CPUID: VARIANT Position */
415
+#define SCB_CPUID_VARIANT_Msk              (0xFUL << SCB_CPUID_VARIANT_Pos)               /*!< SCB CPUID: VARIANT Mask */
416
+
417
+#define SCB_CPUID_ARCHITECTURE_Pos         16U                                            /*!< SCB CPUID: ARCHITECTURE Position */
418
+#define SCB_CPUID_ARCHITECTURE_Msk         (0xFUL << SCB_CPUID_ARCHITECTURE_Pos)          /*!< SCB CPUID: ARCHITECTURE Mask */
419
+
420
+#define SCB_CPUID_PARTNO_Pos                4U                                            /*!< SCB CPUID: PARTNO Position */
421
+#define SCB_CPUID_PARTNO_Msk               (0xFFFUL << SCB_CPUID_PARTNO_Pos)              /*!< SCB CPUID: PARTNO Mask */
422
+
423
+#define SCB_CPUID_REVISION_Pos              0U                                            /*!< SCB CPUID: REVISION Position */
424
+#define SCB_CPUID_REVISION_Msk             (0xFUL /*<< SCB_CPUID_REVISION_Pos*/)          /*!< SCB CPUID: REVISION Mask */
425
+
426
+/* SCB Interrupt Control State Register Definitions */
427
+#define SCB_ICSR_NMIPENDSET_Pos            31U                                            /*!< SCB ICSR: NMIPENDSET Position */
428
+#define SCB_ICSR_NMIPENDSET_Msk            (1UL << SCB_ICSR_NMIPENDSET_Pos)               /*!< SCB ICSR: NMIPENDSET Mask */
429
+
430
+#define SCB_ICSR_PENDSVSET_Pos             28U                                            /*!< SCB ICSR: PENDSVSET Position */
431
+#define SCB_ICSR_PENDSVSET_Msk             (1UL << SCB_ICSR_PENDSVSET_Pos)                /*!< SCB ICSR: PENDSVSET Mask */
432
+
433
+#define SCB_ICSR_PENDSVCLR_Pos             27U                                            /*!< SCB ICSR: PENDSVCLR Position */
434
+#define SCB_ICSR_PENDSVCLR_Msk             (1UL << SCB_ICSR_PENDSVCLR_Pos)                /*!< SCB ICSR: PENDSVCLR Mask */
435
+
436
+#define SCB_ICSR_PENDSTSET_Pos             26U                                            /*!< SCB ICSR: PENDSTSET Position */
437
+#define SCB_ICSR_PENDSTSET_Msk             (1UL << SCB_ICSR_PENDSTSET_Pos)                /*!< SCB ICSR: PENDSTSET Mask */
438
+
439
+#define SCB_ICSR_PENDSTCLR_Pos             25U                                            /*!< SCB ICSR: PENDSTCLR Position */
440
+#define SCB_ICSR_PENDSTCLR_Msk             (1UL << SCB_ICSR_PENDSTCLR_Pos)                /*!< SCB ICSR: PENDSTCLR Mask */
441
+
442
+#define SCB_ICSR_ISRPREEMPT_Pos            23U                                            /*!< SCB ICSR: ISRPREEMPT Position */
443
+#define SCB_ICSR_ISRPREEMPT_Msk            (1UL << SCB_ICSR_ISRPREEMPT_Pos)               /*!< SCB ICSR: ISRPREEMPT Mask */
444
+
445
+#define SCB_ICSR_ISRPENDING_Pos            22U                                            /*!< SCB ICSR: ISRPENDING Position */
446
+#define SCB_ICSR_ISRPENDING_Msk            (1UL << SCB_ICSR_ISRPENDING_Pos)               /*!< SCB ICSR: ISRPENDING Mask */
447
+
448
+#define SCB_ICSR_VECTPENDING_Pos           12U                                            /*!< SCB ICSR: VECTPENDING Position */
449
+#define SCB_ICSR_VECTPENDING_Msk           (0x1FFUL << SCB_ICSR_VECTPENDING_Pos)          /*!< SCB ICSR: VECTPENDING Mask */
450
+
451
+#define SCB_ICSR_VECTACTIVE_Pos             0U                                            /*!< SCB ICSR: VECTACTIVE Position */
452
+#define SCB_ICSR_VECTACTIVE_Msk            (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/)       /*!< SCB ICSR: VECTACTIVE Mask */
453
+
454
+/* SCB Interrupt Control State Register Definitions */
455
+#define SCB_VTOR_TBLOFF_Pos                 7U                                            /*!< SCB VTOR: TBLOFF Position */
456
+#define SCB_VTOR_TBLOFF_Msk                (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos)           /*!< SCB VTOR: TBLOFF Mask */
457
+
458
+/* SCB Application Interrupt and Reset Control Register Definitions */
459
+#define SCB_AIRCR_VECTKEY_Pos              16U                                            /*!< SCB AIRCR: VECTKEY Position */
460
+#define SCB_AIRCR_VECTKEY_Msk              (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos)            /*!< SCB AIRCR: VECTKEY Mask */
461
+
462
+#define SCB_AIRCR_VECTKEYSTAT_Pos          16U                                            /*!< SCB AIRCR: VECTKEYSTAT Position */
463
+#define SCB_AIRCR_VECTKEYSTAT_Msk          (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos)        /*!< SCB AIRCR: VECTKEYSTAT Mask */
464
+
465
+#define SCB_AIRCR_ENDIANESS_Pos            15U                                            /*!< SCB AIRCR: ENDIANESS Position */
466
+#define SCB_AIRCR_ENDIANESS_Msk            (1UL << SCB_AIRCR_ENDIANESS_Pos)               /*!< SCB AIRCR: ENDIANESS Mask */
467
+
468
+#define SCB_AIRCR_SYSRESETREQ_Pos           2U                                            /*!< SCB AIRCR: SYSRESETREQ Position */
469
+#define SCB_AIRCR_SYSRESETREQ_Msk          (1UL << SCB_AIRCR_SYSRESETREQ_Pos)             /*!< SCB AIRCR: SYSRESETREQ Mask */
470
+
471
+#define SCB_AIRCR_VECTCLRACTIVE_Pos         1U                                            /*!< SCB AIRCR: VECTCLRACTIVE Position */
472
+#define SCB_AIRCR_VECTCLRACTIVE_Msk        (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos)           /*!< SCB AIRCR: VECTCLRACTIVE Mask */
473
+
474
+/* SCB System Control Register Definitions */
475
+#define SCB_SCR_SEVONPEND_Pos               4U                                            /*!< SCB SCR: SEVONPEND Position */
476
+#define SCB_SCR_SEVONPEND_Msk              (1UL << SCB_SCR_SEVONPEND_Pos)                 /*!< SCB SCR: SEVONPEND Mask */
477
+
478
+#define SCB_SCR_SLEEPDEEP_Pos               2U                                            /*!< SCB SCR: SLEEPDEEP Position */
479
+#define SCB_SCR_SLEEPDEEP_Msk              (1UL << SCB_SCR_SLEEPDEEP_Pos)                 /*!< SCB SCR: SLEEPDEEP Mask */
480
+
481
+#define SCB_SCR_SLEEPONEXIT_Pos             1U                                            /*!< SCB SCR: SLEEPONEXIT Position */
482
+#define SCB_SCR_SLEEPONEXIT_Msk            (1UL << SCB_SCR_SLEEPONEXIT_Pos)               /*!< SCB SCR: SLEEPONEXIT Mask */
483
+
484
+/* SCB Configuration Control Register Definitions */
485
+#define SCB_CCR_STKALIGN_Pos                9U                                            /*!< SCB CCR: STKALIGN Position */
486
+#define SCB_CCR_STKALIGN_Msk               (1UL << SCB_CCR_STKALIGN_Pos)                  /*!< SCB CCR: STKALIGN Mask */
487
+
488
+#define SCB_CCR_UNALIGN_TRP_Pos             3U                                            /*!< SCB CCR: UNALIGN_TRP Position */
489
+#define SCB_CCR_UNALIGN_TRP_Msk            (1UL << SCB_CCR_UNALIGN_TRP_Pos)               /*!< SCB CCR: UNALIGN_TRP Mask */
490
+
491
+/* SCB System Handler Control and State Register Definitions */
492
+#define SCB_SHCSR_SVCALLPENDED_Pos         15U                                            /*!< SCB SHCSR: SVCALLPENDED Position */
493
+#define SCB_SHCSR_SVCALLPENDED_Msk         (1UL << SCB_SHCSR_SVCALLPENDED_Pos)            /*!< SCB SHCSR: SVCALLPENDED Mask */
494
+
495
+/*@} end of group CMSIS_SCB */
496
+
497
+
498
+/**
499
+  \ingroup  CMSIS_core_register
500
+  \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB)
501
+  \brief    Type definitions for the System Control and ID Register not in the SCB
502
+  @{
503
+ */
504
+
505
+/**
506
+  \brief  Structure type to access the System Control and ID Register not in the SCB.
507
+ */
508
+typedef struct
509
+{
510
+        uint32_t RESERVED0[2U];
511
+  __IOM uint32_t ACTLR;                  /*!< Offset: 0x008 (R/W)  Auxiliary Control Register */
512
+} SCnSCB_Type;
513
+
514
+/* Auxiliary Control Register Definitions */
515
+#define SCnSCB_ACTLR_DISMCYCINT_Pos         0U                                         /*!< ACTLR: DISMCYCINT Position */
516
+#define SCnSCB_ACTLR_DISMCYCINT_Msk        (1UL /*<< SCnSCB_ACTLR_DISMCYCINT_Pos*/)    /*!< ACTLR: DISMCYCINT Mask */
517
+
518
+/*@} end of group CMSIS_SCnotSCB */
519
+
520
+
521
+/**
522
+  \ingroup  CMSIS_core_register
523
+  \defgroup CMSIS_SysTick     System Tick Timer (SysTick)
524
+  \brief    Type definitions for the System Timer Registers.
525
+  @{
526
+ */
527
+
528
+/**
529
+  \brief  Structure type to access the System Timer (SysTick).
530
+ */
531
+typedef struct
532
+{
533
+  __IOM uint32_t CTRL;                   /*!< Offset: 0x000 (R/W)  SysTick Control and Status Register */
534
+  __IOM uint32_t LOAD;                   /*!< Offset: 0x004 (R/W)  SysTick Reload Value Register */
535
+  __IOM uint32_t VAL;                    /*!< Offset: 0x008 (R/W)  SysTick Current Value Register */
536
+  __IM  uint32_t CALIB;                  /*!< Offset: 0x00C (R/ )  SysTick Calibration Register */
537
+} SysTick_Type;
538
+
539
+/* SysTick Control / Status Register Definitions */
540
+#define SysTick_CTRL_COUNTFLAG_Pos         16U                                            /*!< SysTick CTRL: COUNTFLAG Position */
541
+#define SysTick_CTRL_COUNTFLAG_Msk         (1UL << SysTick_CTRL_COUNTFLAG_Pos)            /*!< SysTick CTRL: COUNTFLAG Mask */
542
+
543
+#define SysTick_CTRL_CLKSOURCE_Pos          2U                                            /*!< SysTick CTRL: CLKSOURCE Position */
544
+#define SysTick_CTRL_CLKSOURCE_Msk         (1UL << SysTick_CTRL_CLKSOURCE_Pos)            /*!< SysTick CTRL: CLKSOURCE Mask */
545
+
546
+#define SysTick_CTRL_TICKINT_Pos            1U                                            /*!< SysTick CTRL: TICKINT Position */
547
+#define SysTick_CTRL_TICKINT_Msk           (1UL << SysTick_CTRL_TICKINT_Pos)              /*!< SysTick CTRL: TICKINT Mask */
548
+
549
+#define SysTick_CTRL_ENABLE_Pos             0U                                            /*!< SysTick CTRL: ENABLE Position */
550
+#define SysTick_CTRL_ENABLE_Msk            (1UL /*<< SysTick_CTRL_ENABLE_Pos*/)           /*!< SysTick CTRL: ENABLE Mask */
551
+
552
+/* SysTick Reload Register Definitions */
553
+#define SysTick_LOAD_RELOAD_Pos             0U                                            /*!< SysTick LOAD: RELOAD Position */
554
+#define SysTick_LOAD_RELOAD_Msk            (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/)    /*!< SysTick LOAD: RELOAD Mask */
555
+
556
+/* SysTick Current Register Definitions */
557
+#define SysTick_VAL_CURRENT_Pos             0U                                            /*!< SysTick VAL: CURRENT Position */
558
+#define SysTick_VAL_CURRENT_Msk            (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/)    /*!< SysTick VAL: CURRENT Mask */
559
+
560
+/* SysTick Calibration Register Definitions */
561
+#define SysTick_CALIB_NOREF_Pos            31U                                            /*!< SysTick CALIB: NOREF Position */
562
+#define SysTick_CALIB_NOREF_Msk            (1UL << SysTick_CALIB_NOREF_Pos)               /*!< SysTick CALIB: NOREF Mask */
563
+
564
+#define SysTick_CALIB_SKEW_Pos             30U                                            /*!< SysTick CALIB: SKEW Position */
565
+#define SysTick_CALIB_SKEW_Msk             (1UL << SysTick_CALIB_SKEW_Pos)                /*!< SysTick CALIB: SKEW Mask */
566
+
567
+#define SysTick_CALIB_TENMS_Pos             0U                                            /*!< SysTick CALIB: TENMS Position */
568
+#define SysTick_CALIB_TENMS_Msk            (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/)    /*!< SysTick CALIB: TENMS Mask */
569
+
570
+/*@} end of group CMSIS_SysTick */
571
+
572
+#if (__MPU_PRESENT == 1U)
573
+/**
574
+  \ingroup  CMSIS_core_register
575
+  \defgroup CMSIS_MPU     Memory Protection Unit (MPU)
576
+  \brief    Type definitions for the Memory Protection Unit (MPU)
577
+  @{
578
+ */
579
+
580
+/**
581
+  \brief  Structure type to access the Memory Protection Unit (MPU).
582
+ */
583
+typedef struct
584
+{
585
+  __IM  uint32_t TYPE;                   /*!< Offset: 0x000 (R/ )  MPU Type Register */
586
+  __IOM uint32_t CTRL;                   /*!< Offset: 0x004 (R/W)  MPU Control Register */
587
+  __IOM uint32_t RNR;                    /*!< Offset: 0x008 (R/W)  MPU Region RNRber Register */
588
+  __IOM uint32_t RBAR;                   /*!< Offset: 0x00C (R/W)  MPU Region Base Address Register */
589
+  __IOM uint32_t RASR;                   /*!< Offset: 0x010 (R/W)  MPU Region Attribute and Size Register */
590
+} MPU_Type;
591
+
592
+/* MPU Type Register Definitions */
593
+#define MPU_TYPE_IREGION_Pos               16U                                            /*!< MPU TYPE: IREGION Position */
594
+#define MPU_TYPE_IREGION_Msk               (0xFFUL << MPU_TYPE_IREGION_Pos)               /*!< MPU TYPE: IREGION Mask */
595
+
596
+#define MPU_TYPE_DREGION_Pos                8U                                            /*!< MPU TYPE: DREGION Position */
597
+#define MPU_TYPE_DREGION_Msk               (0xFFUL << MPU_TYPE_DREGION_Pos)               /*!< MPU TYPE: DREGION Mask */
598
+
599
+#define MPU_TYPE_SEPARATE_Pos               0U                                            /*!< MPU TYPE: SEPARATE Position */
600
+#define MPU_TYPE_SEPARATE_Msk              (1UL /*<< MPU_TYPE_SEPARATE_Pos*/)             /*!< MPU TYPE: SEPARATE Mask */
601
+
602
+/* MPU Control Register Definitions */
603
+#define MPU_CTRL_PRIVDEFENA_Pos             2U                                            /*!< MPU CTRL: PRIVDEFENA Position */
604
+#define MPU_CTRL_PRIVDEFENA_Msk            (1UL << MPU_CTRL_PRIVDEFENA_Pos)               /*!< MPU CTRL: PRIVDEFENA Mask */
605
+
606
+#define MPU_CTRL_HFNMIENA_Pos               1U                                            /*!< MPU CTRL: HFNMIENA Position */
607
+#define MPU_CTRL_HFNMIENA_Msk              (1UL << MPU_CTRL_HFNMIENA_Pos)                 /*!< MPU CTRL: HFNMIENA Mask */
608
+
609
+#define MPU_CTRL_ENABLE_Pos                 0U                                            /*!< MPU CTRL: ENABLE Position */
610
+#define MPU_CTRL_ENABLE_Msk                (1UL /*<< MPU_CTRL_ENABLE_Pos*/)               /*!< MPU CTRL: ENABLE Mask */
611
+
612
+/* MPU Region Number Register Definitions */
613
+#define MPU_RNR_REGION_Pos                  0U                                            /*!< MPU RNR: REGION Position */
614
+#define MPU_RNR_REGION_Msk                 (0xFFUL /*<< MPU_RNR_REGION_Pos*/)             /*!< MPU RNR: REGION Mask */
615
+
616
+/* MPU Region Base Address Register Definitions */
617
+#define MPU_RBAR_ADDR_Pos                   8U                                            /*!< MPU RBAR: ADDR Position */
618
+#define MPU_RBAR_ADDR_Msk                  (0xFFFFFFUL << MPU_RBAR_ADDR_Pos)              /*!< MPU RBAR: ADDR Mask */
619
+
620
+#define MPU_RBAR_VALID_Pos                  4U                                            /*!< MPU RBAR: VALID Position */
621
+#define MPU_RBAR_VALID_Msk                 (1UL << MPU_RBAR_VALID_Pos)                    /*!< MPU RBAR: VALID Mask */
622
+
623
+#define MPU_RBAR_REGION_Pos                 0U                                            /*!< MPU RBAR: REGION Position */
624
+#define MPU_RBAR_REGION_Msk                (0xFUL /*<< MPU_RBAR_REGION_Pos*/)             /*!< MPU RBAR: REGION Mask */
625
+
626
+/* MPU Region Attribute and Size Register Definitions */
627
+#define MPU_RASR_ATTRS_Pos                 16U                                            /*!< MPU RASR: MPU Region Attribute field Position */
628
+#define MPU_RASR_ATTRS_Msk                 (0xFFFFUL << MPU_RASR_ATTRS_Pos)               /*!< MPU RASR: MPU Region Attribute field Mask */
629
+
630
+#define MPU_RASR_XN_Pos                    28U                                            /*!< MPU RASR: ATTRS.XN Position */
631
+#define MPU_RASR_XN_Msk                    (1UL << MPU_RASR_XN_Pos)                       /*!< MPU RASR: ATTRS.XN Mask */
632
+
633
+#define MPU_RASR_AP_Pos                    24U                                            /*!< MPU RASR: ATTRS.AP Position */
634
+#define MPU_RASR_AP_Msk                    (0x7UL << MPU_RASR_AP_Pos)                     /*!< MPU RASR: ATTRS.AP Mask */
635
+
636
+#define MPU_RASR_TEX_Pos                   19U                                            /*!< MPU RASR: ATTRS.TEX Position */
637
+#define MPU_RASR_TEX_Msk                   (0x7UL << MPU_RASR_TEX_Pos)                    /*!< MPU RASR: ATTRS.TEX Mask */
638
+
639
+#define MPU_RASR_S_Pos                     18U                                            /*!< MPU RASR: ATTRS.S Position */
640
+#define MPU_RASR_S_Msk                     (1UL << MPU_RASR_S_Pos)                        /*!< MPU RASR: ATTRS.S Mask */
641
+
642
+#define MPU_RASR_C_Pos                     17U                                            /*!< MPU RASR: ATTRS.C Position */
643
+#define MPU_RASR_C_Msk                     (1UL << MPU_RASR_C_Pos)                        /*!< MPU RASR: ATTRS.C Mask */
644
+
645
+#define MPU_RASR_B_Pos                     16U                                            /*!< MPU RASR: ATTRS.B Position */
646
+#define MPU_RASR_B_Msk                     (1UL << MPU_RASR_B_Pos)                        /*!< MPU RASR: ATTRS.B Mask */
647
+
648
+#define MPU_RASR_SRD_Pos                    8U                                            /*!< MPU RASR: Sub-Region Disable Position */
649
+#define MPU_RASR_SRD_Msk                   (0xFFUL << MPU_RASR_SRD_Pos)                   /*!< MPU RASR: Sub-Region Disable Mask */
650
+
651
+#define MPU_RASR_SIZE_Pos                   1U                                            /*!< MPU RASR: Region Size Field Position */
652
+#define MPU_RASR_SIZE_Msk                  (0x1FUL << MPU_RASR_SIZE_Pos)                  /*!< MPU RASR: Region Size Field Mask */
653
+
654
+#define MPU_RASR_ENABLE_Pos                 0U                                            /*!< MPU RASR: Region enable bit Position */
655
+#define MPU_RASR_ENABLE_Msk                (1UL /*<< MPU_RASR_ENABLE_Pos*/)               /*!< MPU RASR: Region enable bit Disable Mask */
656
+
657
+/*@} end of group CMSIS_MPU */
658
+#endif
659
+
660
+
661
+/**
662
+  \ingroup  CMSIS_core_register
663
+  \defgroup CMSIS_CoreDebug       Core Debug Registers (CoreDebug)
664
+  \brief    SC000 Core Debug Registers (DCB registers, SHCSR, and DFSR) are only accessible over DAP and not via processor.
665
+            Therefore they are not covered by the SC000 header file.
666
+  @{
667
+ */
668
+/*@} end of group CMSIS_CoreDebug */
669
+
670
+
671
+/**
672
+  \ingroup    CMSIS_core_register
673
+  \defgroup   CMSIS_core_bitfield     Core register bit field macros
674
+  \brief      Macros for use with bit field definitions (xxx_Pos, xxx_Msk).
675
+  @{
676
+ */
677
+
678
+/**
679
+  \brief   Mask and shift a bit field value for use in a register bit range.
680
+  \param[in] field  Name of the register bit field.
681
+  \param[in] value  Value of the bit field.
682
+  \return           Masked and shifted value.
683
+*/
684
+#define _VAL2FLD(field, value)    ((value << field ## _Pos) & field ## _Msk)
685
+
686
+/**
687
+  \brief     Mask and shift a register value to extract a bit filed value.
688
+  \param[in] field  Name of the register bit field.
689
+  \param[in] value  Value of register.
690
+  \return           Masked and shifted bit field value.
691
+*/
692
+#define _FLD2VAL(field, value)    ((value & field ## _Msk) >> field ## _Pos)
693
+
694
+/*@} end of group CMSIS_core_bitfield */
695
+
696
+
697
+/**
698
+  \ingroup    CMSIS_core_register
699
+  \defgroup   CMSIS_core_base     Core Definitions
700
+  \brief      Definitions for base addresses, unions, and structures.
701
+  @{
702
+ */
703
+
704
+/* Memory mapping of SC000 Hardware */
705
+#define SCS_BASE            (0xE000E000UL)                            /*!< System Control Space Base Address */
706
+#define SysTick_BASE        (SCS_BASE +  0x0010UL)                    /*!< SysTick Base Address */
707
+#define NVIC_BASE           (SCS_BASE +  0x0100UL)                    /*!< NVIC Base Address */
708
+#define SCB_BASE            (SCS_BASE +  0x0D00UL)                    /*!< System Control Block Base Address */
709
+
710
+#define SCnSCB              ((SCnSCB_Type    *)     SCS_BASE      )   /*!< System control Register not in SCB */
711
+#define SCB                 ((SCB_Type       *)     SCB_BASE      )   /*!< SCB configuration struct */
712
+#define SysTick             ((SysTick_Type   *)     SysTick_BASE  )   /*!< SysTick configuration struct */
713
+#define NVIC                ((NVIC_Type      *)     NVIC_BASE     )   /*!< NVIC configuration struct */
714
+
715
+#if (__MPU_PRESENT == 1U)
716
+  #define MPU_BASE          (SCS_BASE +  0x0D90UL)                    /*!< Memory Protection Unit */
717
+  #define MPU               ((MPU_Type       *)     MPU_BASE      )   /*!< Memory Protection Unit */
718
+#endif
719
+
720
+/*@} */
721
+
722
+
723
+
724
+/*******************************************************************************
725
+ *                Hardware Abstraction Layer
726
+  Core Function Interface contains:
727
+  - Core NVIC Functions
728
+  - Core SysTick Functions
729
+  - Core Register Access Functions
730
+ ******************************************************************************/
731
+/**
732
+  \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference
733
+*/
734
+
735
+
736
+
737
+/* ##########################   NVIC functions  #################################### */
738
+/**
739
+  \ingroup  CMSIS_Core_FunctionInterface
740
+  \defgroup CMSIS_Core_NVICFunctions NVIC Functions
741
+  \brief    Functions that manage interrupts and exceptions via the NVIC.
742
+  @{
743
+ */
744
+
745
+/* Interrupt Priorities are WORD accessible only under ARMv6M                   */
746
+/* The following MACROS handle generation of the register offset and byte masks */
747
+#define _BIT_SHIFT(IRQn)         (  ((((uint32_t)(int32_t)(IRQn))         )      &  0x03UL) * 8UL)
748
+#define _SHP_IDX(IRQn)           ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >>    2UL)      )
749
+#define _IP_IDX(IRQn)            (   (((uint32_t)(int32_t)(IRQn))                >>    2UL)      )
750
+
751
+
752
+/**
753
+  \brief   Enable External Interrupt
754
+  \details Enables a device-specific interrupt in the NVIC interrupt controller.
755
+  \param [in]      IRQn  External interrupt number. Value cannot be negative.
756
+ */
757
+__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)
758
+{
759
+  NVIC->ISER[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
760
+}
761
+
762
+
763
+/**
764
+  \brief   Disable External Interrupt
765
+  \details Disables a device-specific interrupt in the NVIC interrupt controller.
766
+  \param [in]      IRQn  External interrupt number. Value cannot be negative.
767
+ */
768
+__STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn)
769
+{
770
+  NVIC->ICER[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
771
+}
772
+
773
+
774
+/**
775
+  \brief   Get Pending Interrupt
776
+  \details Reads the pending register in the NVIC and returns the pending bit for the specified interrupt.
777
+  \param [in]      IRQn  Interrupt number.
778
+  \return             0  Interrupt status is not pending.
779
+  \return             1  Interrupt status is pending.
780
+ */
781
+__STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn)
782
+{
783
+  return((uint32_t)(((NVIC->ISPR[0U] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
784
+}
785
+
786
+
787
+/**
788
+  \brief   Set Pending Interrupt
789
+  \details Sets the pending bit of an external interrupt.
790
+  \param [in]      IRQn  Interrupt number. Value cannot be negative.
791
+ */
792
+__STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn)
793
+{
794
+  NVIC->ISPR[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
795
+}
796
+
797
+
798
+/**
799
+  \brief   Clear Pending Interrupt
800
+  \details Clears the pending bit of an external interrupt.
801
+  \param [in]      IRQn  External interrupt number. Value cannot be negative.
802
+ */
803
+__STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn)
804
+{
805
+  NVIC->ICPR[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
806
+}
807
+
808
+
809
+/**
810
+  \brief   Set Interrupt Priority
811
+  \details Sets the priority of an interrupt.
812
+  \note    The priority cannot be set for every core interrupt.
813
+  \param [in]      IRQn  Interrupt number.
814
+  \param [in]  priority  Priority to set.
815
+ */
816
+__STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
817
+{
818
+  if ((int32_t)(IRQn) < 0)
819
+  {
820
+    SCB->SHP[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) |
821
+       (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn)));
822
+  }
823
+  else
824
+  {
825
+    NVIC->IP[_IP_IDX(IRQn)]  = ((uint32_t)(NVIC->IP[_IP_IDX(IRQn)]  & ~(0xFFUL << _BIT_SHIFT(IRQn))) |
826
+       (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn)));
827
+  }
828
+}
829
+
830
+
831
+/**
832
+  \brief   Get Interrupt Priority
833
+  \details Reads the priority of an interrupt.
834
+           The interrupt number can be positive to specify an external (device specific) interrupt,
835
+           or negative to specify an internal (core) interrupt.
836
+  \param [in]   IRQn  Interrupt number.
837
+  \return             Interrupt Priority.
838
+                      Value is aligned automatically to the implemented priority bits of the microcontroller.
839
+ */
840
+__STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn)
841
+{
842
+
843
+  if ((int32_t)(IRQn) < 0)
844
+  {
845
+    return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS)));
846
+  }
847
+  else
848
+  {
849
+    return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS)));
850
+  }
851
+}
852
+
853
+
854
+/**
855
+  \brief   System Reset
856
+  \details Initiates a system reset request to reset the MCU.
857
+ */
858
+__STATIC_INLINE void NVIC_SystemReset(void)
859
+{
860
+  __DSB();                                                          /* Ensure all outstanding memory accesses included
861
+                                                                       buffered write are completed before reset */
862
+  SCB->AIRCR  = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) |
863
+                 SCB_AIRCR_SYSRESETREQ_Msk);
864
+  __DSB();                                                          /* Ensure completion of memory access */
865
+
866
+  for(;;)                                                           /* wait until reset */
867
+  {
868
+    __NOP();
869
+  }
870
+}
871
+
872
+/*@} end of CMSIS_Core_NVICFunctions */
873
+
874
+
875
+
876
+/* ##################################    SysTick function  ############################################ */
877
+/**
878
+  \ingroup  CMSIS_Core_FunctionInterface
879
+  \defgroup CMSIS_Core_SysTickFunctions SysTick Functions
880
+  \brief    Functions that configure the System.
881
+  @{
882
+ */
883
+
884
+#if (__Vendor_SysTickConfig == 0U)
885
+
886
+/**
887
+  \brief   System Tick Configuration
888
+  \details Initializes the System Timer and its interrupt, and starts the System Tick Timer.
889
+           Counter is in free running mode to generate periodic interrupts.
890
+  \param [in]  ticks  Number of ticks between two interrupts.
891
+  \return          0  Function succeeded.
892
+  \return          1  Function failed.
893
+  \note    When the variable <b>__Vendor_SysTickConfig</b> is set to 1, then the
894
+           function <b>SysTick_Config</b> is not included. In this case, the file <b><i>device</i>.h</b>
895
+           must contain a vendor-specific implementation of this function.
896
+ */
897
+__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks)
898
+{
899
+  if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk)
900
+  {
901
+    return (1UL);                                                   /* Reload value impossible */
902
+  }
903
+
904
+  SysTick->LOAD  = (uint32_t)(ticks - 1UL);                         /* set reload register */
905
+  NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */
906
+  SysTick->VAL   = 0UL;                                             /* Load the SysTick Counter Value */
907
+  SysTick->CTRL  = SysTick_CTRL_CLKSOURCE_Msk |
908
+                   SysTick_CTRL_TICKINT_Msk   |
909
+                   SysTick_CTRL_ENABLE_Msk;                         /* Enable SysTick IRQ and SysTick Timer */
910
+  return (0UL);                                                     /* Function successful */
911
+}
912
+
913
+#endif
914
+
915
+/*@} end of CMSIS_Core_SysTickFunctions */
916
+
917
+
918
+
919
+
920
+#ifdef __cplusplus
921
+}
922
+#endif
923
+
924
+#endif /* __CORE_SC000_H_DEPENDANT */
925
+
926
+#endif /* __CMSIS_GENERIC */

文件差异内容过多而无法显示
+ 1745 - 0
Drivers/CMSIS/Include/core_sc300.h


文件差异内容过多而无法显示
+ 3219 - 0
Drivers/STM32F1xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h


+ 367 - 0
Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h

@@ -0,0 +1,367 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx_hal.h
4
+  * @author  MCD Application Team
5
+  * @brief   This file contains all the functions prototypes for the HAL
6
+  *          module driver.
7
+  ******************************************************************************
8
+  * @attention
9
+  *
10
+  * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
11
+  *
12
+  * Redistribution and use in source and binary forms, with or without modification,
13
+  * are permitted provided that the following conditions are met:
14
+  *   1. Redistributions of source code must retain the above copyright notice,
15
+  *      this list of conditions and the following disclaimer.
16
+  *   2. Redistributions in binary form must reproduce the above copyright notice,
17
+  *      this list of conditions and the following disclaimer in the documentation
18
+  *      and/or other materials provided with the distribution.
19
+  *   3. Neither the name of STMicroelectronics nor the names of its contributors
20
+  *      may be used to endorse or promote products derived from this software
21
+  *      without specific prior written permission.
22
+  *
23
+  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24
+  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26
+  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
27
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29
+  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30
+  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
31
+  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32
+  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
+  *
34
+  ******************************************************************************
35
+  */
36
+
37
+/* Define to prevent recursive inclusion -------------------------------------*/
38
+#ifndef __STM32F1xx_HAL_H
39
+#define __STM32F1xx_HAL_H
40
+
41
+#ifdef __cplusplus
42
+extern "C" {
43
+#endif
44
+
45
+/* Includes ------------------------------------------------------------------*/
46
+#include "stm32f1xx_hal_conf.h"
47
+
48
+/** @addtogroup STM32F1xx_HAL_Driver
49
+  * @{
50
+  */
51
+
52
+/** @addtogroup HAL
53
+  * @{
54
+  */
55
+
56
+/* Exported constants --------------------------------------------------------*/
57
+
58
+/** @defgroup HAL_Exported_Constants HAL Exported Constants
59
+  * @{
60
+  */
61
+
62
+/** @defgroup HAL_TICK_FREQ Tick Frequency
63
+  * @{
64
+  */
65
+typedef enum
66
+{
67
+  HAL_TICK_FREQ_10HZ         = 100U,
68
+  HAL_TICK_FREQ_100HZ        = 10U,
69
+  HAL_TICK_FREQ_1KHZ         = 1U,
70
+  HAL_TICK_FREQ_DEFAULT      = HAL_TICK_FREQ_1KHZ
71
+} HAL_TickFreqTypeDef;
72
+/**
73
+  * @}
74
+  */
75
+/* Exported types ------------------------------------------------------------*/
76
+extern uint32_t uwTickPrio;
77
+extern HAL_TickFreqTypeDef uwTickFreq;
78
+
79
+/**
80
+  * @}
81
+  */
82
+/* Exported macro ------------------------------------------------------------*/
83
+/** @defgroup HAL_Exported_Macros HAL Exported Macros
84
+  * @{
85
+  */
86
+
87
+/** @defgroup DBGMCU_Freeze_Unfreeze Freeze Unfreeze Peripherals in Debug mode
88
+  * @brief   Freeze/Unfreeze Peripherals in Debug mode
89
+  * Note: On devices STM32F10xx8 and STM32F10xxB,
90
+  *                  STM32F101xC/D/E and STM32F103xC/D/E,
91
+  *                  STM32F101xF/G and STM32F103xF/G
92
+  *                  STM32F10xx4 and STM32F10xx6
93
+  *       Debug registers DBGMCU_IDCODE and DBGMCU_CR are accessible only in
94
+  *       debug mode (not accessible by the user software in normal mode).
95
+  *       Refer to errata sheet of these devices for more details.
96
+  * @{
97
+  */
98
+
99
+/* Peripherals on APB1 */
100
+/**
101
+  * @brief  TIM2 Peripherals Debug mode
102
+  */
103
+#define __HAL_DBGMCU_FREEZE_TIM2()            SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM2_STOP)
104
+#define __HAL_DBGMCU_UNFREEZE_TIM2()          CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM2_STOP)
105
+
106
+/**
107
+  * @brief  TIM3 Peripherals Debug mode
108
+  */
109
+#define __HAL_DBGMCU_FREEZE_TIM3()            SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM3_STOP)
110
+#define __HAL_DBGMCU_UNFREEZE_TIM3()          CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM3_STOP)
111
+
112
+#if defined (DBGMCU_CR_DBG_TIM4_STOP)
113
+/**
114
+  * @brief  TIM4 Peripherals Debug mode
115
+  */
116
+#define __HAL_DBGMCU_FREEZE_TIM4()            SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM4_STOP)
117
+#define __HAL_DBGMCU_UNFREEZE_TIM4()          CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM4_STOP)
118
+#endif
119
+
120
+#if defined (DBGMCU_CR_DBG_TIM5_STOP)
121
+/**
122
+  * @brief  TIM5 Peripherals Debug mode
123
+  */
124
+#define __HAL_DBGMCU_FREEZE_TIM5()            SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM5_STOP)
125
+#define __HAL_DBGMCU_UNFREEZE_TIM5()          CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM5_STOP)
126
+#endif
127
+
128
+#if defined (DBGMCU_CR_DBG_TIM6_STOP)
129
+/**
130
+  * @brief  TIM6 Peripherals Debug mode
131
+  */
132
+#define __HAL_DBGMCU_FREEZE_TIM6()            SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM6_STOP)
133
+#define __HAL_DBGMCU_UNFREEZE_TIM6()          CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM6_STOP)
134
+#endif
135
+
136
+#if defined (DBGMCU_CR_DBG_TIM7_STOP)
137
+/**
138
+  * @brief  TIM7 Peripherals Debug mode
139
+  */
140
+#define __HAL_DBGMCU_FREEZE_TIM7()            SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM7_STOP)
141
+#define __HAL_DBGMCU_UNFREEZE_TIM7()          CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM7_STOP)
142
+#endif
143
+
144
+#if defined (DBGMCU_CR_DBG_TIM12_STOP)
145
+/**
146
+  * @brief  TIM12 Peripherals Debug mode
147
+  */
148
+#define __HAL_DBGMCU_FREEZE_TIM12()            SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM12_STOP)
149
+#define __HAL_DBGMCU_UNFREEZE_TIM12()          CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM12_STOP)
150
+#endif
151
+
152
+#if defined (DBGMCU_CR_DBG_TIM13_STOP)
153
+/**
154
+  * @brief  TIM13 Peripherals Debug mode
155
+  */
156
+#define __HAL_DBGMCU_FREEZE_TIM13()            SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM13_STOP)
157
+#define __HAL_DBGMCU_UNFREEZE_TIM13()          CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM13_STOP)
158
+#endif
159
+
160
+#if defined (DBGMCU_CR_DBG_TIM14_STOP)
161
+/**
162
+  * @brief  TIM14 Peripherals Debug mode
163
+  */
164
+#define __HAL_DBGMCU_FREEZE_TIM14()            SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM14_STOP)
165
+#define __HAL_DBGMCU_UNFREEZE_TIM14()          CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM14_STOP)
166
+#endif
167
+
168
+/**
169
+  * @brief  WWDG Peripherals Debug mode
170
+  */
171
+#define __HAL_DBGMCU_FREEZE_WWDG()            SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_WWDG_STOP)
172
+#define __HAL_DBGMCU_UNFREEZE_WWDG()          CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_WWDG_STOP)
173
+
174
+/**
175
+  * @brief  IWDG Peripherals Debug mode
176
+  */
177
+#define __HAL_DBGMCU_FREEZE_IWDG()            SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_IWDG_STOP)
178
+#define __HAL_DBGMCU_UNFREEZE_IWDG()          CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_IWDG_STOP)
179
+
180
+/**
181
+  * @brief  I2C1 Peripherals Debug mode
182
+  */
183
+#define __HAL_DBGMCU_FREEZE_I2C1_TIMEOUT()    SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_I2C1_SMBUS_TIMEOUT)
184
+#define __HAL_DBGMCU_UNFREEZE_I2C1_TIMEOUT()  CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_I2C1_SMBUS_TIMEOUT)
185
+
186
+#if defined (DBGMCU_CR_DBG_I2C2_SMBUS_TIMEOUT)
187
+/**
188
+  * @brief  I2C2 Peripherals Debug mode
189
+  */
190
+#define __HAL_DBGMCU_FREEZE_I2C2_TIMEOUT()    SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_I2C2_SMBUS_TIMEOUT)
191
+#define __HAL_DBGMCU_UNFREEZE_I2C2_TIMEOUT()  CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_I2C2_SMBUS_TIMEOUT)
192
+#endif
193
+
194
+#if defined (DBGMCU_CR_DBG_CAN1_STOP)
195
+/**
196
+  * @brief  CAN1 Peripherals Debug mode
197
+  */
198
+#define __HAL_DBGMCU_FREEZE_CAN1()            SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_CAN1_STOP)
199
+#define __HAL_DBGMCU_UNFREEZE_CAN1()          CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_CAN1_STOP)
200
+#endif
201
+
202
+#if defined (DBGMCU_CR_DBG_CAN2_STOP)
203
+/**
204
+  * @brief  CAN2 Peripherals Debug mode
205
+  */
206
+#define __HAL_DBGMCU_FREEZE_CAN2()            SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_CAN2_STOP)
207
+#define __HAL_DBGMCU_UNFREEZE_CAN2()          CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_CAN2_STOP)
208
+#endif
209
+
210
+/* Peripherals on APB2 */
211
+#if defined (DBGMCU_CR_DBG_TIM1_STOP)
212
+/**
213
+  * @brief  TIM1 Peripherals Debug mode
214
+  */
215
+#define __HAL_DBGMCU_FREEZE_TIM1()            SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM1_STOP)
216
+#define __HAL_DBGMCU_UNFREEZE_TIM1()          CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM1_STOP)
217
+#endif
218
+
219
+#if defined (DBGMCU_CR_DBG_TIM8_STOP)
220
+/**
221
+  * @brief  TIM8 Peripherals Debug mode
222
+  */
223
+#define __HAL_DBGMCU_FREEZE_TIM8()            SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM8_STOP)
224
+#define __HAL_DBGMCU_UNFREEZE_TIM8()          CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM8_STOP)
225
+#endif
226
+
227
+#if defined (DBGMCU_CR_DBG_TIM9_STOP)
228
+/**
229
+  * @brief  TIM9 Peripherals Debug mode
230
+  */
231
+#define __HAL_DBGMCU_FREEZE_TIM9()            SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM9_STOP)
232
+#define __HAL_DBGMCU_UNFREEZE_TIM9()          CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM9_STOP)
233
+#endif
234
+
235
+#if defined (DBGMCU_CR_DBG_TIM10_STOP)
236
+/**
237
+  * @brief  TIM10 Peripherals Debug mode
238
+  */
239
+#define __HAL_DBGMCU_FREEZE_TIM10()            SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM10_STOP)
240
+#define __HAL_DBGMCU_UNFREEZE_TIM10()          CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM10_STOP)
241
+#endif
242
+
243
+#if defined (DBGMCU_CR_DBG_TIM11_STOP)
244
+/**
245
+  * @brief  TIM11 Peripherals Debug mode
246
+  */
247
+#define __HAL_DBGMCU_FREEZE_TIM11()            SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM11_STOP)
248
+#define __HAL_DBGMCU_UNFREEZE_TIM11()          CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM11_STOP)
249
+#endif
250
+
251
+
252
+#if defined (DBGMCU_CR_DBG_TIM15_STOP)
253
+/**
254
+  * @brief  TIM15 Peripherals Debug mode
255
+  */
256
+#define __HAL_DBGMCU_FREEZE_TIM15()            SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM15_STOP)
257
+#define __HAL_DBGMCU_UNFREEZE_TIM15()          CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM15_STOP)
258
+#endif
259
+
260
+#if defined (DBGMCU_CR_DBG_TIM16_STOP)
261
+/**
262
+  * @brief  TIM16 Peripherals Debug mode
263
+  */
264
+#define __HAL_DBGMCU_FREEZE_TIM16()            SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM16_STOP)
265
+#define __HAL_DBGMCU_UNFREEZE_TIM16()          CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM16_STOP)
266
+#endif
267
+
268
+#if defined (DBGMCU_CR_DBG_TIM17_STOP)
269
+/**
270
+  * @brief  TIM17 Peripherals Debug mode
271
+  */
272
+#define __HAL_DBGMCU_FREEZE_TIM17()            SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM17_STOP)
273
+#define __HAL_DBGMCU_UNFREEZE_TIM17()          CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM17_STOP)
274
+#endif
275
+
276
+/**
277
+  * @}
278
+  */
279
+
280
+/** @defgroup HAL_Private_Macros HAL Private Macros
281
+  * @{
282
+  */
283
+#define IS_TICKFREQ(FREQ) (((FREQ) == HAL_TICK_FREQ_10HZ)  || \
284
+                           ((FREQ) == HAL_TICK_FREQ_100HZ) || \
285
+                           ((FREQ) == HAL_TICK_FREQ_1KHZ))
286
+/**
287
+  * @}
288
+  */
289
+
290
+/* Exported functions --------------------------------------------------------*/
291
+/** @addtogroup HAL_Exported_Functions
292
+  * @{
293
+  */
294
+/** @addtogroup HAL_Exported_Functions_Group1
295
+  * @{
296
+  */
297
+/* Initialization and de-initialization functions  ******************************/
298
+HAL_StatusTypeDef HAL_Init(void);
299
+HAL_StatusTypeDef HAL_DeInit(void);
300
+void HAL_MspInit(void);
301
+void HAL_MspDeInit(void);
302
+HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority);
303
+/**
304
+  * @}
305
+  */
306
+
307
+/** @addtogroup HAL_Exported_Functions_Group2
308
+  * @{
309
+  */
310
+/* Peripheral Control functions  ************************************************/
311
+void HAL_IncTick(void);
312
+void HAL_Delay(uint32_t Delay);
313
+uint32_t HAL_GetTick(void);
314
+uint32_t HAL_GetTickPrio(void);
315
+HAL_StatusTypeDef HAL_SetTickFreq(HAL_TickFreqTypeDef Freq);
316
+HAL_TickFreqTypeDef HAL_GetTickFreq(void);
317
+void HAL_SuspendTick(void);
318
+void HAL_ResumeTick(void);
319
+uint32_t HAL_GetHalVersion(void);
320
+uint32_t HAL_GetREVID(void);
321
+uint32_t HAL_GetDEVID(void);
322
+void HAL_DBGMCU_EnableDBGSleepMode(void);
323
+void HAL_DBGMCU_DisableDBGSleepMode(void);
324
+void HAL_DBGMCU_EnableDBGStopMode(void);
325
+void HAL_DBGMCU_DisableDBGStopMode(void);
326
+void HAL_DBGMCU_EnableDBGStandbyMode(void);
327
+void HAL_DBGMCU_DisableDBGStandbyMode(void);
328
+void HAL_GetUID(uint32_t *UID);
329
+/**
330
+  * @}
331
+  */
332
+
333
+/**
334
+  * @}
335
+  */
336
+/* Private types -------------------------------------------------------------*/
337
+/* Private variables ---------------------------------------------------------*/
338
+/** @defgroup HAL_Private_Variables HAL Private Variables
339
+  * @{
340
+  */
341
+/**
342
+  * @}
343
+  */
344
+/* Private constants ---------------------------------------------------------*/
345
+/** @defgroup HAL_Private_Constants HAL Private Constants
346
+  * @{
347
+  */
348
+/**
349
+  * @}
350
+  */
351
+/* Private macros ------------------------------------------------------------*/
352
+/* Private functions ---------------------------------------------------------*/
353
+/**
354
+  * @}
355
+  */
356
+
357
+/**
358
+  * @}
359
+  */
360
+
361
+#ifdef __cplusplus
362
+}
363
+#endif
364
+
365
+#endif /* __STM32F1xx_HAL_H */
366
+
367
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 426 - 0
Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_cortex.h

@@ -0,0 +1,426 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx_hal_cortex.h
4
+  * @author  MCD Application Team
5
+  * @brief   Header file of CORTEX HAL module.
6
+  ******************************************************************************
7
+  * @attention
8
+  *
9
+  * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
10
+  *
11
+  * Redistribution and use in source and binary forms, with or without modification,
12
+  * are permitted provided that the following conditions are met:
13
+  *   1. Redistributions of source code must retain the above copyright notice,
14
+  *      this list of conditions and the following disclaimer.
15
+  *   2. Redistributions in binary form must reproduce the above copyright notice,
16
+  *      this list of conditions and the following disclaimer in the documentation
17
+  *      and/or other materials provided with the distribution.
18
+  *   3. Neither the name of STMicroelectronics nor the names of its contributors
19
+  *      may be used to endorse or promote products derived from this software
20
+  *      without specific prior written permission.
21
+  *
22
+  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
+  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25
+  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28
+  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29
+  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30
+  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
+  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
+  *
33
+  ******************************************************************************
34
+  */ 
35
+
36
+/* Define to prevent recursive inclusion -------------------------------------*/
37
+#ifndef __STM32F1xx_HAL_CORTEX_H
38
+#define __STM32F1xx_HAL_CORTEX_H
39
+
40
+#ifdef __cplusplus
41
+ extern "C" {
42
+#endif
43
+
44
+/* Includes ------------------------------------------------------------------*/
45
+#include "stm32f1xx_hal_def.h"
46
+
47
+/** @addtogroup STM32F1xx_HAL_Driver
48
+  * @{
49
+  */
50
+
51
+/** @addtogroup CORTEX
52
+  * @{
53
+  */ 
54
+/* Exported types ------------------------------------------------------------*/
55
+/** @defgroup CORTEX_Exported_Types Cortex Exported Types
56
+  * @{
57
+  */
58
+
59
+#if (__MPU_PRESENT == 1U)
60
+/** @defgroup CORTEX_MPU_Region_Initialization_Structure_definition MPU Region Initialization Structure Definition
61
+  * @brief  MPU Region initialization structure 
62
+  * @{
63
+  */
64
+typedef struct
65
+{
66
+  uint8_t                Enable;                /*!< Specifies the status of the region. 
67
+                                                     This parameter can be a value of @ref CORTEX_MPU_Region_Enable                 */
68
+  uint8_t                Number;                /*!< Specifies the number of the region to protect. 
69
+                                                     This parameter can be a value of @ref CORTEX_MPU_Region_Number                 */
70
+  uint32_t               BaseAddress;           /*!< Specifies the base address of the region to protect.                           */
71
+  uint8_t                Size;                  /*!< Specifies the size of the region to protect. 
72
+                                                     This parameter can be a value of @ref CORTEX_MPU_Region_Size                   */
73
+  uint8_t                SubRegionDisable;      /*!< Specifies the number of the subregion protection to disable. 
74
+                                                     This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF    */         
75
+  uint8_t                TypeExtField;          /*!< Specifies the TEX field level.
76
+                                                     This parameter can be a value of @ref CORTEX_MPU_TEX_Levels                    */                 
77
+  uint8_t                AccessPermission;      /*!< Specifies the region access permission type. 
78
+                                                     This parameter can be a value of @ref CORTEX_MPU_Region_Permission_Attributes  */
79
+  uint8_t                DisableExec;           /*!< Specifies the instruction access status. 
80
+                                                     This parameter can be a value of @ref CORTEX_MPU_Instruction_Access            */
81
+  uint8_t                IsShareable;           /*!< Specifies the shareability status of the protected region. 
82
+                                                     This parameter can be a value of @ref CORTEX_MPU_Access_Shareable              */
83
+  uint8_t                IsCacheable;           /*!< Specifies the cacheable status of the region protected. 
84
+                                                     This parameter can be a value of @ref CORTEX_MPU_Access_Cacheable              */
85
+  uint8_t                IsBufferable;          /*!< Specifies the bufferable status of the protected region. 
86
+                                                     This parameter can be a value of @ref CORTEX_MPU_Access_Bufferable             */
87
+}MPU_Region_InitTypeDef;
88
+/**
89
+  * @}
90
+  */
91
+#endif /* __MPU_PRESENT */
92
+
93
+/**
94
+  * @}
95
+  */
96
+
97
+/* Exported constants --------------------------------------------------------*/
98
+
99
+/** @defgroup CORTEX_Exported_Constants CORTEX Exported Constants
100
+  * @{
101
+  */
102
+
103
+/** @defgroup CORTEX_Preemption_Priority_Group CORTEX Preemption Priority Group
104
+  * @{
105
+  */
106
+#define NVIC_PRIORITYGROUP_0         0x00000007U /*!< 0 bits for pre-emption priority
107
+                                                      4 bits for subpriority */
108
+#define NVIC_PRIORITYGROUP_1         0x00000006U /*!< 1 bits for pre-emption priority
109
+                                                      3 bits for subpriority */
110
+#define NVIC_PRIORITYGROUP_2         0x00000005U /*!< 2 bits for pre-emption priority
111
+                                                      2 bits for subpriority */
112
+#define NVIC_PRIORITYGROUP_3         0x00000004U /*!< 3 bits for pre-emption priority
113
+                                                      1 bits for subpriority */
114
+#define NVIC_PRIORITYGROUP_4         0x00000003U /*!< 4 bits for pre-emption priority
115
+                                                      0 bits for subpriority */
116
+/**
117
+  * @}
118
+  */
119
+
120
+/** @defgroup CORTEX_SysTick_clock_source CORTEX _SysTick clock source 
121
+  * @{
122
+  */
123
+#define SYSTICK_CLKSOURCE_HCLK_DIV8    0x00000000U
124
+#define SYSTICK_CLKSOURCE_HCLK         0x00000004U
125
+
126
+/**
127
+  * @}
128
+  */
129
+
130
+#if (__MPU_PRESENT == 1)
131
+/** @defgroup CORTEX_MPU_HFNMI_PRIVDEF_Control MPU HFNMI and PRIVILEGED Access control
132
+  * @{
133
+  */
134
+#define  MPU_HFNMI_PRIVDEF_NONE           0x00000000U
135
+#define  MPU_HARDFAULT_NMI                MPU_CTRL_HFNMIENA_Msk
136
+#define  MPU_PRIVILEGED_DEFAULT           MPU_CTRL_PRIVDEFENA_Msk
137
+#define  MPU_HFNMI_PRIVDEF               (MPU_CTRL_HFNMIENA_Msk | MPU_CTRL_PRIVDEFENA_Msk)
138
+
139
+/**
140
+  * @}
141
+  */
142
+
143
+/** @defgroup CORTEX_MPU_Region_Enable CORTEX MPU Region Enable
144
+  * @{
145
+  */
146
+#define  MPU_REGION_ENABLE     ((uint8_t)0x01)
147
+#define  MPU_REGION_DISABLE    ((uint8_t)0x00)
148
+/**
149
+  * @}
150
+  */
151
+
152
+/** @defgroup CORTEX_MPU_Instruction_Access CORTEX MPU Instruction Access
153
+  * @{
154
+  */
155
+#define  MPU_INSTRUCTION_ACCESS_ENABLE      ((uint8_t)0x00)
156
+#define  MPU_INSTRUCTION_ACCESS_DISABLE     ((uint8_t)0x01)
157
+/**
158
+  * @}
159
+  */
160
+
161
+/** @defgroup CORTEX_MPU_Access_Shareable CORTEX MPU Instruction Access Shareable
162
+  * @{
163
+  */
164
+#define  MPU_ACCESS_SHAREABLE        ((uint8_t)0x01)
165
+#define  MPU_ACCESS_NOT_SHAREABLE    ((uint8_t)0x00)
166
+/**
167
+  * @}
168
+  */
169
+
170
+/** @defgroup CORTEX_MPU_Access_Cacheable CORTEX MPU Instruction Access Cacheable
171
+  * @{
172
+  */
173
+#define  MPU_ACCESS_CACHEABLE         ((uint8_t)0x01)
174
+#define  MPU_ACCESS_NOT_CACHEABLE     ((uint8_t)0x00)
175
+/**
176
+  * @}
177
+  */
178
+
179
+/** @defgroup CORTEX_MPU_Access_Bufferable CORTEX MPU Instruction Access Bufferable
180
+  * @{
181
+  */
182
+#define  MPU_ACCESS_BUFFERABLE         ((uint8_t)0x01)
183
+#define  MPU_ACCESS_NOT_BUFFERABLE     ((uint8_t)0x00)
184
+/**
185
+  * @}
186
+  */
187
+
188
+/** @defgroup CORTEX_MPU_TEX_Levels MPU TEX Levels
189
+  * @{
190
+  */
191
+#define  MPU_TEX_LEVEL0    ((uint8_t)0x00)
192
+#define  MPU_TEX_LEVEL1    ((uint8_t)0x01)
193
+#define  MPU_TEX_LEVEL2    ((uint8_t)0x02)
194
+/**
195
+  * @}
196
+  */
197
+
198
+/** @defgroup CORTEX_MPU_Region_Size CORTEX MPU Region Size
199
+  * @{
200
+  */
201
+#define   MPU_REGION_SIZE_32B      ((uint8_t)0x04)
202
+#define   MPU_REGION_SIZE_64B      ((uint8_t)0x05)
203
+#define   MPU_REGION_SIZE_128B     ((uint8_t)0x06)
204
+#define   MPU_REGION_SIZE_256B     ((uint8_t)0x07)
205
+#define   MPU_REGION_SIZE_512B     ((uint8_t)0x08)
206
+#define   MPU_REGION_SIZE_1KB      ((uint8_t)0x09)
207
+#define   MPU_REGION_SIZE_2KB      ((uint8_t)0x0A)
208
+#define   MPU_REGION_SIZE_4KB      ((uint8_t)0x0B)
209
+#define   MPU_REGION_SIZE_8KB      ((uint8_t)0x0C)
210
+#define   MPU_REGION_SIZE_16KB     ((uint8_t)0x0D)
211
+#define   MPU_REGION_SIZE_32KB     ((uint8_t)0x0E)
212
+#define   MPU_REGION_SIZE_64KB     ((uint8_t)0x0F)
213
+#define   MPU_REGION_SIZE_128KB    ((uint8_t)0x10)
214
+#define   MPU_REGION_SIZE_256KB    ((uint8_t)0x11)
215
+#define   MPU_REGION_SIZE_512KB    ((uint8_t)0x12)
216
+#define   MPU_REGION_SIZE_1MB      ((uint8_t)0x13)
217
+#define   MPU_REGION_SIZE_2MB      ((uint8_t)0x14)
218
+#define   MPU_REGION_SIZE_4MB      ((uint8_t)0x15)
219
+#define   MPU_REGION_SIZE_8MB      ((uint8_t)0x16)
220
+#define   MPU_REGION_SIZE_16MB     ((uint8_t)0x17)
221
+#define   MPU_REGION_SIZE_32MB     ((uint8_t)0x18)
222
+#define   MPU_REGION_SIZE_64MB     ((uint8_t)0x19)
223
+#define   MPU_REGION_SIZE_128MB    ((uint8_t)0x1A)
224
+#define   MPU_REGION_SIZE_256MB    ((uint8_t)0x1B)
225
+#define   MPU_REGION_SIZE_512MB    ((uint8_t)0x1C)
226
+#define   MPU_REGION_SIZE_1GB      ((uint8_t)0x1D)
227
+#define   MPU_REGION_SIZE_2GB      ((uint8_t)0x1E)
228
+#define   MPU_REGION_SIZE_4GB      ((uint8_t)0x1F)
229
+/**
230
+  * @}
231
+  */
232
+   
233
+/** @defgroup CORTEX_MPU_Region_Permission_Attributes CORTEX MPU Region Permission Attributes 
234
+  * @{
235
+  */
236
+#define  MPU_REGION_NO_ACCESS      ((uint8_t)0x00)
237
+#define  MPU_REGION_PRIV_RW        ((uint8_t)0x01)
238
+#define  MPU_REGION_PRIV_RW_URO    ((uint8_t)0x02)
239
+#define  MPU_REGION_FULL_ACCESS    ((uint8_t)0x03)
240
+#define  MPU_REGION_PRIV_RO        ((uint8_t)0x05)
241
+#define  MPU_REGION_PRIV_RO_URO    ((uint8_t)0x06)
242
+/**
243
+  * @}
244
+  */
245
+
246
+/** @defgroup CORTEX_MPU_Region_Number CORTEX MPU Region Number
247
+  * @{
248
+  */
249
+#define  MPU_REGION_NUMBER0    ((uint8_t)0x00)
250
+#define  MPU_REGION_NUMBER1    ((uint8_t)0x01)
251
+#define  MPU_REGION_NUMBER2    ((uint8_t)0x02)
252
+#define  MPU_REGION_NUMBER3    ((uint8_t)0x03)
253
+#define  MPU_REGION_NUMBER4    ((uint8_t)0x04)
254
+#define  MPU_REGION_NUMBER5    ((uint8_t)0x05)
255
+#define  MPU_REGION_NUMBER6    ((uint8_t)0x06)
256
+#define  MPU_REGION_NUMBER7    ((uint8_t)0x07)
257
+/**
258
+  * @}
259
+  */
260
+#endif /* __MPU_PRESENT */
261
+
262
+/**
263
+  * @}
264
+  */
265
+
266
+
267
+/* Exported Macros -----------------------------------------------------------*/
268
+
269
+/* Exported functions --------------------------------------------------------*/
270
+/** @addtogroup CORTEX_Exported_Functions
271
+  * @{
272
+  */
273
+  
274
+/** @addtogroup CORTEX_Exported_Functions_Group1
275
+  * @{
276
+  */
277
+/* Initialization and de-initialization functions *****************************/
278
+void HAL_NVIC_SetPriorityGrouping(uint32_t PriorityGroup);
279
+void HAL_NVIC_SetPriority(IRQn_Type IRQn, uint32_t PreemptPriority, uint32_t SubPriority);
280
+void HAL_NVIC_EnableIRQ(IRQn_Type IRQn);
281
+void HAL_NVIC_DisableIRQ(IRQn_Type IRQn);
282
+void HAL_NVIC_SystemReset(void);
283
+uint32_t HAL_SYSTICK_Config(uint32_t TicksNumb);
284
+/**
285
+  * @}
286
+  */
287
+
288
+/** @addtogroup CORTEX_Exported_Functions_Group2
289
+  * @{
290
+  */
291
+/* Peripheral Control functions ***********************************************/
292
+uint32_t HAL_NVIC_GetPriorityGrouping(void);
293
+void HAL_NVIC_GetPriority(IRQn_Type IRQn, uint32_t PriorityGroup, uint32_t* pPreemptPriority, uint32_t* pSubPriority);
294
+uint32_t HAL_NVIC_GetPendingIRQ(IRQn_Type IRQn);
295
+void HAL_NVIC_SetPendingIRQ(IRQn_Type IRQn);
296
+void HAL_NVIC_ClearPendingIRQ(IRQn_Type IRQn);
297
+uint32_t HAL_NVIC_GetActive(IRQn_Type IRQn);
298
+void HAL_SYSTICK_CLKSourceConfig(uint32_t CLKSource);
299
+void HAL_SYSTICK_IRQHandler(void);
300
+void HAL_SYSTICK_Callback(void);
301
+
302
+#if (__MPU_PRESENT == 1U)
303
+void HAL_MPU_Enable(uint32_t MPU_Control);
304
+void HAL_MPU_Disable(void);
305
+void HAL_MPU_ConfigRegion(MPU_Region_InitTypeDef *MPU_Init);
306
+#endif /* __MPU_PRESENT */
307
+/**
308
+  * @}
309
+  */
310
+
311
+/**
312
+  * @}
313
+  */
314
+
315
+/* Private types -------------------------------------------------------------*/
316
+/* Private variables ---------------------------------------------------------*/
317
+/* Private constants ---------------------------------------------------------*/
318
+/* Private macros ------------------------------------------------------------*/
319
+/** @defgroup CORTEX_Private_Macros CORTEX Private Macros
320
+  * @{
321
+  */
322
+#define IS_NVIC_PRIORITY_GROUP(GROUP) (((GROUP) == NVIC_PRIORITYGROUP_0) || \
323
+                                       ((GROUP) == NVIC_PRIORITYGROUP_1) || \
324
+                                       ((GROUP) == NVIC_PRIORITYGROUP_2) || \
325
+                                       ((GROUP) == NVIC_PRIORITYGROUP_3) || \
326
+                                       ((GROUP) == NVIC_PRIORITYGROUP_4))
327
+
328
+#define IS_NVIC_PREEMPTION_PRIORITY(PRIORITY)  ((PRIORITY) < 0x10U)
329
+
330
+#define IS_NVIC_SUB_PRIORITY(PRIORITY)         ((PRIORITY) < 0x10U)
331
+
332
+#define IS_NVIC_DEVICE_IRQ(IRQ)                ((IRQ) >= (IRQn_Type)0x00U)
333
+
334
+#define IS_SYSTICK_CLK_SOURCE(SOURCE) (((SOURCE) == SYSTICK_CLKSOURCE_HCLK) || \
335
+                                       ((SOURCE) == SYSTICK_CLKSOURCE_HCLK_DIV8))
336
+
337
+#if (__MPU_PRESENT == 1U)
338
+#define IS_MPU_REGION_ENABLE(STATE) (((STATE) == MPU_REGION_ENABLE) || \
339
+                                     ((STATE) == MPU_REGION_DISABLE))
340
+
341
+#define IS_MPU_INSTRUCTION_ACCESS(STATE) (((STATE) == MPU_INSTRUCTION_ACCESS_ENABLE) || \
342
+                                          ((STATE) == MPU_INSTRUCTION_ACCESS_DISABLE))
343
+
344
+#define IS_MPU_ACCESS_SHAREABLE(STATE)   (((STATE) == MPU_ACCESS_SHAREABLE) || \
345
+                                          ((STATE) == MPU_ACCESS_NOT_SHAREABLE))
346
+
347
+#define IS_MPU_ACCESS_CACHEABLE(STATE)   (((STATE) == MPU_ACCESS_CACHEABLE) || \
348
+                                          ((STATE) == MPU_ACCESS_NOT_CACHEABLE))
349
+
350
+#define IS_MPU_ACCESS_BUFFERABLE(STATE)   (((STATE) == MPU_ACCESS_BUFFERABLE) || \
351
+                                          ((STATE) == MPU_ACCESS_NOT_BUFFERABLE))
352
+
353
+#define IS_MPU_TEX_LEVEL(TYPE) (((TYPE) == MPU_TEX_LEVEL0)  || \
354
+                                ((TYPE) == MPU_TEX_LEVEL1)  || \
355
+                                ((TYPE) == MPU_TEX_LEVEL2))
356
+
357
+#define IS_MPU_REGION_PERMISSION_ATTRIBUTE(TYPE) (((TYPE) == MPU_REGION_NO_ACCESS)   || \
358
+                                                  ((TYPE) == MPU_REGION_PRIV_RW)     || \
359
+                                                  ((TYPE) == MPU_REGION_PRIV_RW_URO) || \
360
+                                                  ((TYPE) == MPU_REGION_FULL_ACCESS) || \
361
+                                                  ((TYPE) == MPU_REGION_PRIV_RO)     || \
362
+                                                  ((TYPE) == MPU_REGION_PRIV_RO_URO))
363
+
364
+#define IS_MPU_REGION_NUMBER(NUMBER)    (((NUMBER) == MPU_REGION_NUMBER0) || \
365
+                                         ((NUMBER) == MPU_REGION_NUMBER1) || \
366
+                                         ((NUMBER) == MPU_REGION_NUMBER2) || \
367
+                                         ((NUMBER) == MPU_REGION_NUMBER3) || \
368
+                                         ((NUMBER) == MPU_REGION_NUMBER4) || \
369
+                                         ((NUMBER) == MPU_REGION_NUMBER5) || \
370
+                                         ((NUMBER) == MPU_REGION_NUMBER6) || \
371
+                                         ((NUMBER) == MPU_REGION_NUMBER7))
372
+
373
+#define IS_MPU_REGION_SIZE(SIZE)    (((SIZE) == MPU_REGION_SIZE_32B)   || \
374
+                                     ((SIZE) == MPU_REGION_SIZE_64B)   || \
375
+                                     ((SIZE) == MPU_REGION_SIZE_128B)  || \
376
+                                     ((SIZE) == MPU_REGION_SIZE_256B)  || \
377
+                                     ((SIZE) == MPU_REGION_SIZE_512B)  || \
378
+                                     ((SIZE) == MPU_REGION_SIZE_1KB)   || \
379
+                                     ((SIZE) == MPU_REGION_SIZE_2KB)   || \
380
+                                     ((SIZE) == MPU_REGION_SIZE_4KB)   || \
381
+                                     ((SIZE) == MPU_REGION_SIZE_8KB)   || \
382
+                                     ((SIZE) == MPU_REGION_SIZE_16KB)  || \
383
+                                     ((SIZE) == MPU_REGION_SIZE_32KB)  || \
384
+                                     ((SIZE) == MPU_REGION_SIZE_64KB)  || \
385
+                                     ((SIZE) == MPU_REGION_SIZE_128KB) || \
386
+                                     ((SIZE) == MPU_REGION_SIZE_256KB) || \
387
+                                     ((SIZE) == MPU_REGION_SIZE_512KB) || \
388
+                                     ((SIZE) == MPU_REGION_SIZE_1MB)   || \
389
+                                     ((SIZE) == MPU_REGION_SIZE_2MB)   || \
390
+                                     ((SIZE) == MPU_REGION_SIZE_4MB)   || \
391
+                                     ((SIZE) == MPU_REGION_SIZE_8MB)   || \
392
+                                     ((SIZE) == MPU_REGION_SIZE_16MB)  || \
393
+                                     ((SIZE) == MPU_REGION_SIZE_32MB)  || \
394
+                                     ((SIZE) == MPU_REGION_SIZE_64MB)  || \
395
+                                     ((SIZE) == MPU_REGION_SIZE_128MB) || \
396
+                                     ((SIZE) == MPU_REGION_SIZE_256MB) || \
397
+                                     ((SIZE) == MPU_REGION_SIZE_512MB) || \
398
+                                     ((SIZE) == MPU_REGION_SIZE_1GB)   || \
399
+                                     ((SIZE) == MPU_REGION_SIZE_2GB)   || \
400
+                                     ((SIZE) == MPU_REGION_SIZE_4GB))
401
+
402
+#define IS_MPU_SUB_REGION_DISABLE(SUBREGION)  ((SUBREGION) < (uint16_t)0x00FF)
403
+#endif /* __MPU_PRESENT */
404
+
405
+/**                                                                          
406
+  * @}                                                                  
407
+  */
408
+
409
+/* Private functions ---------------------------------------------------------*/
410
+
411
+/**
412
+  * @}
413
+  */ 
414
+
415
+/**
416
+  * @}
417
+  */
418
+  
419
+#ifdef __cplusplus
420
+}
421
+#endif
422
+
423
+#endif /* __STM32F1xx_HAL_CORTEX_H */
424
+ 
425
+
426
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 214 - 0
Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h

@@ -0,0 +1,214 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx_hal_def.h
4
+  * @author  MCD Application Team
5
+  * @brief   This file contains HAL common defines, enumeration, macros and
6
+  *          structures definitions.
7
+  ******************************************************************************
8
+  * @attention
9
+  *
10
+  * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
11
+  *
12
+  * Redistribution and use in source and binary forms, with or without modification,
13
+  * are permitted provided that the following conditions are met:
14
+  *   1. Redistributions of source code must retain the above copyright notice,
15
+  *      this list of conditions and the following disclaimer.
16
+  *   2. Redistributions in binary form must reproduce the above copyright notice,
17
+  *      this list of conditions and the following disclaimer in the documentation
18
+  *      and/or other materials provided with the distribution.
19
+  *   3. Neither the name of STMicroelectronics nor the names of its contributors
20
+  *      may be used to endorse or promote products derived from this software
21
+  *      without specific prior written permission.
22
+  *
23
+  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24
+  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26
+  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
27
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29
+  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30
+  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
31
+  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32
+  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
+  *
34
+  ******************************************************************************
35
+  */
36
+
37
+/* Define to prevent recursive inclusion -------------------------------------*/
38
+#ifndef __STM32F1xx_HAL_DEF
39
+#define __STM32F1xx_HAL_DEF
40
+
41
+#ifdef __cplusplus
42
+extern "C" {
43
+#endif
44
+
45
+/* Includes ------------------------------------------------------------------*/
46
+#include "stm32f1xx.h"
47
+#if defined(USE_HAL_LEGACY)
48
+#include "Legacy/stm32_hal_legacy.h"
49
+#endif
50
+#include <stdio.h>
51
+
52
+/* Exported types ------------------------------------------------------------*/
53
+
54
+/**
55
+  * @brief  HAL Status structures definition
56
+  */
57
+typedef enum
58
+{
59
+  HAL_OK       = 0x00U,
60
+  HAL_ERROR    = 0x01U,
61
+  HAL_BUSY     = 0x02U,
62
+  HAL_TIMEOUT  = 0x03U
63
+} HAL_StatusTypeDef;
64
+
65
+/**
66
+  * @brief  HAL Lock structures definition
67
+  */
68
+typedef enum
69
+{
70
+  HAL_UNLOCKED = 0x00U,
71
+  HAL_LOCKED   = 0x01U
72
+} HAL_LockTypeDef;
73
+
74
+/* Exported macro ------------------------------------------------------------*/
75
+#define HAL_MAX_DELAY      0xFFFFFFFFU
76
+
77
+#define HAL_IS_BIT_SET(REG, BIT)         (((REG) & (BIT)) != 0U)
78
+#define HAL_IS_BIT_CLR(REG, BIT)         (((REG) & (BIT)) == 0U)
79
+
80
+#define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__)               \
81
+                        do{                                                      \
82
+                              (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \
83
+                              (__DMA_HANDLE__).Parent = (__HANDLE__);             \
84
+                          } while(0U)
85
+
86
+#define UNUSED(X) (void)X      /* To avoid gcc/g++ warnings */
87
+
88
+/** @brief Reset the Handle's State field.
89
+  * @param __HANDLE__: specifies the Peripheral Handle.
90
+  * @note  This macro can be used for the following purpose:
91
+  *          - When the Handle is declared as local variable; before passing it as parameter
92
+  *            to HAL_PPP_Init() for the first time, it is mandatory to use this macro
93
+  *            to set to 0 the Handle's "State" field.
94
+  *            Otherwise, "State" field may have any random value and the first time the function
95
+  *            HAL_PPP_Init() is called, the low level hardware initialization will be missed
96
+  *            (i.e. HAL_PPP_MspInit() will not be executed).
97
+  *          - When there is a need to reconfigure the low level hardware: instead of calling
98
+  *            HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init().
99
+  *            In this later function, when the Handle's "State" field is set to 0, it will execute the function
100
+  *            HAL_PPP_MspInit() which will reconfigure the low level hardware.
101
+  * @retval None
102
+  */
103
+#define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0U)
104
+
105
+#if (USE_RTOS == 1U)
106
+/* Reserved for future use */
107
+#error "USE_RTOS should be 0 in the current HAL release"
108
+#else
109
+#define __HAL_LOCK(__HANDLE__)                                           \
110
+                                do{                                        \
111
+                                    if((__HANDLE__)->Lock == HAL_LOCKED)   \
112
+                                    {                                      \
113
+                                       return HAL_BUSY;                    \
114
+                                    }                                      \
115
+                                    else                                   \
116
+                                    {                                      \
117
+                                       (__HANDLE__)->Lock = HAL_LOCKED;    \
118
+                                    }                                      \
119
+                                  }while (0U)
120
+
121
+#define __HAL_UNLOCK(__HANDLE__)                                          \
122
+                                  do{                                       \
123
+                                      (__HANDLE__)->Lock = HAL_UNLOCKED;    \
124
+                                    }while (0U)
125
+#endif /* USE_RTOS */
126
+
127
+#if defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */
128
+#ifndef __weak
129
+#define __weak   __attribute__((weak))
130
+#endif /* __weak */
131
+#ifndef __packed
132
+#define __packed __attribute__((__packed__))
133
+#endif /* __packed */
134
+#endif /* __GNUC__ */
135
+
136
+
137
+/* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */
138
+#if defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */
139
+#ifndef __ALIGN_END
140
+#define __ALIGN_END    __attribute__ ((aligned (4)))
141
+#endif /* __ALIGN_END */
142
+#ifndef __ALIGN_BEGIN
143
+#define __ALIGN_BEGIN
144
+#endif /* __ALIGN_BEGIN */
145
+#else
146
+#ifndef __ALIGN_END
147
+#define __ALIGN_END
148
+#endif /* __ALIGN_END */
149
+#ifndef __ALIGN_BEGIN
150
+#if defined   (__CC_ARM)      /* ARM Compiler */
151
+#define __ALIGN_BEGIN    __align(4)
152
+#elif defined (__ICCARM__)    /* IAR Compiler */
153
+#define __ALIGN_BEGIN
154
+#endif /* __CC_ARM */
155
+#endif /* __ALIGN_BEGIN */
156
+#endif /* __GNUC__ */
157
+
158
+
159
+/**
160
+  * @brief  __RAM_FUNC definition
161
+  */
162
+#if defined ( __CC_ARM   )
163
+/* ARM Compiler
164
+   ------------
165
+   RAM functions are defined using the toolchain options.
166
+   Functions that are executed in RAM should reside in a separate source module.
167
+   Using the 'Options for File' dialog you can simply change the 'Code / Const'
168
+   area of a module to a memory space in physical RAM.
169
+   Available memory areas are declared in the 'Target' tab of the 'Options for Target'
170
+   dialog.
171
+*/
172
+#define __RAM_FUNC
173
+
174
+#elif defined ( __ICCARM__ )
175
+/* ICCARM Compiler
176
+   ---------------
177
+   RAM functions are defined using a specific toolchain keyword "__ramfunc".
178
+*/
179
+#define __RAM_FUNC __ramfunc
180
+
181
+#elif defined   (  __GNUC__  )
182
+/* GNU Compiler
183
+   ------------
184
+  RAM functions are defined using a specific toolchain attribute
185
+   "__attribute__((section(".RamFunc")))".
186
+*/
187
+#define __RAM_FUNC __attribute__((section(".RamFunc")))
188
+
189
+#endif
190
+
191
+/**
192
+  * @brief  __NOINLINE definition
193
+  */
194
+#if defined ( __CC_ARM   ) || defined   (  __GNUC__  )
195
+/* ARM & GNUCompiler
196
+   ----------------
197
+*/
198
+#define __NOINLINE __attribute__ ( (noinline) )
199
+
200
+#elif defined ( __ICCARM__ )
201
+/* ICCARM Compiler
202
+   ---------------
203
+*/
204
+#define __NOINLINE _Pragma("optimize = no_inline")
205
+
206
+#endif
207
+
208
+#ifdef __cplusplus
209
+}
210
+#endif
211
+
212
+#endif /* ___STM32F1xx_HAL_DEF */
213
+
214
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 473 - 0
Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma.h

@@ -0,0 +1,473 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx_hal_dma.h
4
+  * @author  MCD Application Team
5
+  * @brief   Header file of DMA HAL module.
6
+  ******************************************************************************
7
+  * @attention
8
+  *
9
+  * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
10
+  *
11
+  * Redistribution and use in source and binary forms, with or without modification,
12
+  * are permitted provided that the following conditions are met:
13
+  *   1. Redistributions of source code must retain the above copyright notice,
14
+  *      this list of conditions and the following disclaimer.
15
+  *   2. Redistributions in binary form must reproduce the above copyright notice,
16
+  *      this list of conditions and the following disclaimer in the documentation
17
+  *      and/or other materials provided with the distribution.
18
+  *   3. Neither the name of STMicroelectronics nor the names of its contributors
19
+  *      may be used to endorse or promote products derived from this software
20
+  *      without specific prior written permission.
21
+  *
22
+  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
+  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25
+  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28
+  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29
+  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30
+  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
+  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
+  *
33
+  ******************************************************************************
34
+  */
35
+
36
+/* Define to prevent recursive inclusion -------------------------------------*/
37
+#ifndef __STM32F1xx_HAL_DMA_H
38
+#define __STM32F1xx_HAL_DMA_H
39
+
40
+#ifdef __cplusplus
41
+ extern "C" {
42
+#endif
43
+
44
+/* Includes ------------------------------------------------------------------*/
45
+#include "stm32f1xx_hal_def.h"
46
+
47
+/** @addtogroup STM32F1xx_HAL_Driver
48
+  * @{
49
+  */
50
+
51
+/** @addtogroup DMA
52
+  * @{
53
+  */
54
+
55
+/* Exported types ------------------------------------------------------------*/
56
+
57
+/** @defgroup DMA_Exported_Types DMA Exported Types
58
+  * @{
59
+  */
60
+
61
+/**
62
+  * @brief  DMA Configuration Structure definition
63
+  */
64
+typedef struct
65
+{
66
+  uint32_t Direction;                 /*!< Specifies if the data will be transferred from memory to peripheral, 
67
+                                           from memory to memory or from peripheral to memory.
68
+                                           This parameter can be a value of @ref DMA_Data_transfer_direction */
69
+
70
+  uint32_t PeriphInc;                 /*!< Specifies whether the Peripheral address register should be incremented or not.
71
+                                           This parameter can be a value of @ref DMA_Peripheral_incremented_mode */
72
+
73
+  uint32_t MemInc;                    /*!< Specifies whether the memory address register should be incremented or not.
74
+                                           This parameter can be a value of @ref DMA_Memory_incremented_mode */
75
+
76
+  uint32_t PeriphDataAlignment;       /*!< Specifies the Peripheral data width.
77
+                                           This parameter can be a value of @ref DMA_Peripheral_data_size */
78
+
79
+  uint32_t MemDataAlignment;          /*!< Specifies the Memory data width.
80
+                                           This parameter can be a value of @ref DMA_Memory_data_size */
81
+
82
+  uint32_t Mode;                      /*!< Specifies the operation mode of the DMAy Channelx.
83
+                                           This parameter can be a value of @ref DMA_mode
84
+                                           @note The circular buffer mode cannot be used if the memory-to-memory
85
+                                                 data transfer is configured on the selected Channel */
86
+
87
+  uint32_t Priority;                  /*!< Specifies the software priority for the DMAy Channelx.
88
+                                           This parameter can be a value of @ref DMA_Priority_level */
89
+} DMA_InitTypeDef;
90
+
91
+/**
92
+  * @brief  HAL DMA State structures definition
93
+  */
94
+typedef enum
95
+{
96
+  HAL_DMA_STATE_RESET             = 0x00U,  /*!< DMA not yet initialized or disabled    */
97
+  HAL_DMA_STATE_READY             = 0x01U,  /*!< DMA initialized and ready for use      */
98
+  HAL_DMA_STATE_BUSY              = 0x02U,  /*!< DMA process is ongoing                 */
99
+  HAL_DMA_STATE_TIMEOUT           = 0x03U   /*!< DMA timeout state                      */
100
+}HAL_DMA_StateTypeDef;
101
+
102
+/**
103
+  * @brief  HAL DMA Error Code structure definition
104
+  */
105
+typedef enum
106
+{
107
+  HAL_DMA_FULL_TRANSFER           = 0x00U,    /*!< Full transfer     */
108
+  HAL_DMA_HALF_TRANSFER           = 0x01U     /*!< Half Transfer     */
109
+}HAL_DMA_LevelCompleteTypeDef;
110
+
111
+/** 
112
+  * @brief  HAL DMA Callback ID structure definition
113
+  */
114
+typedef enum
115
+{
116
+  HAL_DMA_XFER_CPLT_CB_ID          = 0x00U,    /*!< Full transfer     */
117
+  HAL_DMA_XFER_HALFCPLT_CB_ID      = 0x01U,    /*!< Half transfer     */
118
+  HAL_DMA_XFER_ERROR_CB_ID         = 0x02U,    /*!< Error             */ 
119
+  HAL_DMA_XFER_ABORT_CB_ID         = 0x03U,    /*!< Abort             */ 
120
+  HAL_DMA_XFER_ALL_CB_ID           = 0x04U     /*!< All               */ 
121
+    
122
+}HAL_DMA_CallbackIDTypeDef;
123
+
124
+/** 
125
+  * @brief  DMA handle Structure definition
126
+  */
127
+typedef struct __DMA_HandleTypeDef
128
+{
129
+  DMA_Channel_TypeDef   *Instance;                       /*!< Register base address                  */
130
+  
131
+  DMA_InitTypeDef       Init;                            /*!< DMA communication parameters           */ 
132
+  
133
+  HAL_LockTypeDef       Lock;                            /*!< DMA locking object                     */  
134
+  
135
+  HAL_DMA_StateTypeDef  State;                           /*!< DMA transfer state                     */
136
+  
137
+  void                  *Parent;                                                      /*!< Parent object state                    */  
138
+  
139
+  void                  (* XferCpltCallback)( struct __DMA_HandleTypeDef * hdma);     /*!< DMA transfer complete callback         */
140
+  
141
+  void                  (* XferHalfCpltCallback)( struct __DMA_HandleTypeDef * hdma); /*!< DMA Half transfer complete callback    */
142
+  
143
+  void                  (* XferErrorCallback)( struct __DMA_HandleTypeDef * hdma);    /*!< DMA transfer error callback            */
144
+
145
+  void                  (* XferAbortCallback)( struct __DMA_HandleTypeDef * hdma);    /*!< DMA transfer abort callback            */  
146
+  
147
+  __IO uint32_t         ErrorCode;                                                    /*!< DMA Error code                         */
148
+
149
+  DMA_TypeDef            *DmaBaseAddress;                                             /*!< DMA Channel Base Address               */
150
+  
151
+  uint32_t               ChannelIndex;                                                /*!< DMA Channel Index                      */  
152
+
153
+} DMA_HandleTypeDef;    
154
+/**
155
+  * @}
156
+  */
157
+
158
+/* Exported constants --------------------------------------------------------*/
159
+
160
+/** @defgroup DMA_Exported_Constants DMA Exported Constants
161
+  * @{
162
+  */
163
+
164
+/** @defgroup DMA_Error_Code DMA Error Code
165
+  * @{
166
+  */
167
+#define HAL_DMA_ERROR_NONE                     0x00000000U    /*!< No error             */
168
+#define HAL_DMA_ERROR_TE                       0x00000001U    /*!< Transfer error       */
169
+#define HAL_DMA_ERROR_NO_XFER                  0x00000004U    /*!< no ongoing transfer  */
170
+#define HAL_DMA_ERROR_TIMEOUT                  0x00000020U    /*!< Timeout error        */
171
+#define HAL_DMA_ERROR_NOT_SUPPORTED            0x00000100U    /*!< Not supported mode                    */ 
172
+/**
173
+  * @}
174
+  */
175
+
176
+/** @defgroup DMA_Data_transfer_direction DMA Data transfer direction
177
+  * @{
178
+  */
179
+#define DMA_PERIPH_TO_MEMORY         0x00000000U                 /*!< Peripheral to memory direction */
180
+#define DMA_MEMORY_TO_PERIPH         ((uint32_t)DMA_CCR_DIR)     /*!< Memory to peripheral direction */
181
+#define DMA_MEMORY_TO_MEMORY         ((uint32_t)DMA_CCR_MEM2MEM) /*!< Memory to memory direction     */
182
+
183
+/**
184
+  * @}
185
+  */
186
+
187
+/** @defgroup DMA_Peripheral_incremented_mode DMA Peripheral incremented mode
188
+  * @{
189
+  */
190
+#define DMA_PINC_ENABLE        ((uint32_t)DMA_CCR_PINC)  /*!< Peripheral increment mode Enable */
191
+#define DMA_PINC_DISABLE       0x00000000U               /*!< Peripheral increment mode Disable */
192
+/**
193
+  * @}
194
+  */
195
+
196
+/** @defgroup DMA_Memory_incremented_mode DMA Memory incremented mode
197
+  * @{
198
+  */
199
+#define DMA_MINC_ENABLE         ((uint32_t)DMA_CCR_MINC)  /*!< Memory increment mode Enable  */
200
+#define DMA_MINC_DISABLE        0x00000000U               /*!< Memory increment mode Disable */
201
+/**
202
+  * @}
203
+  */
204
+
205
+/** @defgroup DMA_Peripheral_data_size DMA Peripheral data size
206
+  * @{
207
+  */
208
+#define DMA_PDATAALIGN_BYTE          0x00000000U                  /*!< Peripheral data alignment: Byte     */
209
+#define DMA_PDATAALIGN_HALFWORD      ((uint32_t)DMA_CCR_PSIZE_0)  /*!< Peripheral data alignment: HalfWord */
210
+#define DMA_PDATAALIGN_WORD          ((uint32_t)DMA_CCR_PSIZE_1)  /*!< Peripheral data alignment: Word     */
211
+/**
212
+  * @}
213
+  */
214
+
215
+/** @defgroup DMA_Memory_data_size DMA Memory data size
216
+  * @{
217
+  */
218
+#define DMA_MDATAALIGN_BYTE          0x00000000U                  /*!< Memory data alignment: Byte     */
219
+#define DMA_MDATAALIGN_HALFWORD      ((uint32_t)DMA_CCR_MSIZE_0)  /*!< Memory data alignment: HalfWord */
220
+#define DMA_MDATAALIGN_WORD          ((uint32_t)DMA_CCR_MSIZE_1)  /*!< Memory data alignment: Word     */
221
+/**
222
+  * @}
223
+  */
224
+
225
+/** @defgroup DMA_mode DMA mode
226
+  * @{
227
+  */
228
+#define DMA_NORMAL         0x00000000U                  /*!< Normal mode                  */
229
+#define DMA_CIRCULAR       ((uint32_t)DMA_CCR_CIRC)     /*!< Circular mode                */
230
+/**
231
+  * @}
232
+  */
233
+
234
+/** @defgroup DMA_Priority_level DMA Priority level
235
+  * @{
236
+  */
237
+#define DMA_PRIORITY_LOW             0x00000000U               /*!< Priority level : Low       */
238
+#define DMA_PRIORITY_MEDIUM          ((uint32_t)DMA_CCR_PL_0)  /*!< Priority level : Medium    */
239
+#define DMA_PRIORITY_HIGH            ((uint32_t)DMA_CCR_PL_1)  /*!< Priority level : High      */
240
+#define DMA_PRIORITY_VERY_HIGH       ((uint32_t)DMA_CCR_PL)    /*!< Priority level : Very_High */
241
+/**
242
+  * @}
243
+  */
244
+
245
+
246
+/** @defgroup DMA_interrupt_enable_definitions DMA interrupt enable definitions
247
+  * @{
248
+  */
249
+#define DMA_IT_TC                         ((uint32_t)DMA_CCR_TCIE)
250
+#define DMA_IT_HT                         ((uint32_t)DMA_CCR_HTIE)
251
+#define DMA_IT_TE                         ((uint32_t)DMA_CCR_TEIE)
252
+/**
253
+  * @}
254
+  */
255
+
256
+/** @defgroup DMA_flag_definitions DMA flag definitions
257
+  * @{
258
+  */
259
+#define DMA_FLAG_GL1                      0x00000001U
260
+#define DMA_FLAG_TC1                      0x00000002U
261
+#define DMA_FLAG_HT1                      0x00000004U
262
+#define DMA_FLAG_TE1                      0x00000008U
263
+#define DMA_FLAG_GL2                      0x00000010U
264
+#define DMA_FLAG_TC2                      0x00000020U
265
+#define DMA_FLAG_HT2                      0x00000040U
266
+#define DMA_FLAG_TE2                      0x00000080U
267
+#define DMA_FLAG_GL3                      0x00000100U
268
+#define DMA_FLAG_TC3                      0x00000200U
269
+#define DMA_FLAG_HT3                      0x00000400U
270
+#define DMA_FLAG_TE3                      0x00000800U
271
+#define DMA_FLAG_GL4                      0x00001000U
272
+#define DMA_FLAG_TC4                      0x00002000U
273
+#define DMA_FLAG_HT4                      0x00004000U
274
+#define DMA_FLAG_TE4                      0x00008000U
275
+#define DMA_FLAG_GL5                      0x00010000U
276
+#define DMA_FLAG_TC5                      0x00020000U
277
+#define DMA_FLAG_HT5                      0x00040000U
278
+#define DMA_FLAG_TE5                      0x00080000U
279
+#define DMA_FLAG_GL6                      0x00100000U
280
+#define DMA_FLAG_TC6                      0x00200000U
281
+#define DMA_FLAG_HT6                      0x00400000U
282
+#define DMA_FLAG_TE6                      0x00800000U
283
+#define DMA_FLAG_GL7                      0x01000000U
284
+#define DMA_FLAG_TC7                      0x02000000U
285
+#define DMA_FLAG_HT7                      0x04000000U
286
+#define DMA_FLAG_TE7                      0x08000000U
287
+/**
288
+  * @}
289
+  */
290
+
291
+/**
292
+  * @}
293
+  */
294
+
295
+
296
+/* Exported macros -----------------------------------------------------------*/
297
+/** @defgroup DMA_Exported_Macros DMA Exported Macros
298
+  * @{
299
+  */
300
+
301
+/** @brief  Reset DMA handle state.
302
+  * @param  __HANDLE__: DMA handle
303
+  * @retval None
304
+  */
305
+#define __HAL_DMA_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_DMA_STATE_RESET)
306
+
307
+/**
308
+  * @brief  Enable the specified DMA Channel.
309
+  * @param  __HANDLE__: DMA handle
310
+  * @retval None
311
+  */
312
+#define __HAL_DMA_ENABLE(__HANDLE__)        (SET_BIT((__HANDLE__)->Instance->CCR, DMA_CCR_EN))
313
+
314
+/**
315
+  * @brief  Disable the specified DMA Channel.
316
+  * @param  __HANDLE__: DMA handle
317
+  * @retval None
318
+  */
319
+#define __HAL_DMA_DISABLE(__HANDLE__)       (CLEAR_BIT((__HANDLE__)->Instance->CCR, DMA_CCR_EN))
320
+
321
+
322
+/* Interrupt & Flag management */
323
+
324
+/**
325
+  * @brief  Enables the specified DMA Channel interrupts.
326
+  * @param  __HANDLE__: DMA handle
327
+  * @param __INTERRUPT__: specifies the DMA interrupt sources to be enabled or disabled.
328
+  *          This parameter can be any combination of the following values:
329
+  *            @arg DMA_IT_TC:  Transfer complete interrupt mask
330
+  *            @arg DMA_IT_HT:  Half transfer complete interrupt mask
331
+  *            @arg DMA_IT_TE:  Transfer error interrupt mask
332
+  * @retval None
333
+  */
334
+#define __HAL_DMA_ENABLE_IT(__HANDLE__, __INTERRUPT__)   (SET_BIT((__HANDLE__)->Instance->CCR, (__INTERRUPT__)))
335
+
336
+/**
337
+  * @brief  Disable the specified DMA Channel interrupts.
338
+  * @param  __HANDLE__: DMA handle
339
+  * @param  __INTERRUPT__: specifies the DMA interrupt sources to be enabled or disabled.
340
+  *          This parameter can be any combination of the following values:
341
+  *            @arg DMA_IT_TC:  Transfer complete interrupt mask
342
+  *            @arg DMA_IT_HT:  Half transfer complete interrupt mask
343
+  *            @arg DMA_IT_TE:  Transfer error interrupt mask
344
+  * @retval None
345
+  */
346
+#define __HAL_DMA_DISABLE_IT(__HANDLE__, __INTERRUPT__)  (CLEAR_BIT((__HANDLE__)->Instance->CCR , (__INTERRUPT__)))
347
+
348
+/**
349
+  * @brief  Check whether the specified DMA Channel interrupt is enabled or not.
350
+  * @param  __HANDLE__: DMA handle
351
+  * @param  __INTERRUPT__: specifies the DMA interrupt source to check.
352
+  *          This parameter can be one of the following values:
353
+  *            @arg DMA_IT_TC:  Transfer complete interrupt mask
354
+  *            @arg DMA_IT_HT:  Half transfer complete interrupt mask
355
+  *            @arg DMA_IT_TE:  Transfer error interrupt mask
356
+  * @retval The state of DMA_IT (SET or RESET).
357
+  */
358
+#define __HAL_DMA_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__)  ((((__HANDLE__)->Instance->CCR & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
359
+
360
+/**
361
+  * @brief  Return the number of remaining data units in the current DMA Channel transfer.
362
+  * @param  __HANDLE__: DMA handle
363
+  * @retval The number of remaining data units in the current DMA Channel transfer.
364
+  */
365
+#define __HAL_DMA_GET_COUNTER(__HANDLE__) ((__HANDLE__)->Instance->CNDTR)
366
+
367
+/**
368
+  * @}
369
+  */
370
+
371
+/* Include DMA HAL Extension module */
372
+#include "stm32f1xx_hal_dma_ex.h"   
373
+
374
+/* Exported functions --------------------------------------------------------*/
375
+/** @addtogroup DMA_Exported_Functions
376
+  * @{
377
+  */
378
+
379
+/** @addtogroup DMA_Exported_Functions_Group1
380
+  * @{
381
+  */
382
+/* Initialization and de-initialization functions *****************************/
383
+HAL_StatusTypeDef HAL_DMA_Init(DMA_HandleTypeDef *hdma);
384
+HAL_StatusTypeDef HAL_DMA_DeInit (DMA_HandleTypeDef *hdma);
385
+/**
386
+  * @}
387
+  */
388
+
389
+/** @addtogroup DMA_Exported_Functions_Group2
390
+  * @{
391
+  */
392
+/* IO operation functions *****************************************************/
393
+HAL_StatusTypeDef HAL_DMA_Start (DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength);
394
+HAL_StatusTypeDef HAL_DMA_Start_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength);
395
+HAL_StatusTypeDef HAL_DMA_Abort(DMA_HandleTypeDef *hdma);
396
+HAL_StatusTypeDef HAL_DMA_Abort_IT(DMA_HandleTypeDef *hdma);
397
+HAL_StatusTypeDef HAL_DMA_PollForTransfer(DMA_HandleTypeDef *hdma, uint32_t CompleteLevel, uint32_t Timeout);
398
+void HAL_DMA_IRQHandler(DMA_HandleTypeDef *hdma);
399
+HAL_StatusTypeDef HAL_DMA_RegisterCallback(DMA_HandleTypeDef *hdma, HAL_DMA_CallbackIDTypeDef CallbackID, void (* pCallback)( DMA_HandleTypeDef * _hdma));
400
+HAL_StatusTypeDef HAL_DMA_UnRegisterCallback(DMA_HandleTypeDef *hdma, HAL_DMA_CallbackIDTypeDef CallbackID);
401
+
402
+/**
403
+  * @}
404
+  */
405
+
406
+/** @addtogroup DMA_Exported_Functions_Group3
407
+  * @{
408
+  */
409
+/* Peripheral State and Error functions ***************************************/
410
+HAL_DMA_StateTypeDef HAL_DMA_GetState(DMA_HandleTypeDef *hdma);
411
+uint32_t HAL_DMA_GetError(DMA_HandleTypeDef *hdma);
412
+/**
413
+  * @}
414
+  */
415
+
416
+/**
417
+  * @}
418
+  */
419
+
420
+/* Private macros ------------------------------------------------------------*/
421
+/** @defgroup DMA_Private_Macros DMA Private Macros
422
+  * @{
423
+  */
424
+
425
+#define IS_DMA_DIRECTION(DIRECTION) (((DIRECTION) == DMA_PERIPH_TO_MEMORY ) || \
426
+                                     ((DIRECTION) == DMA_MEMORY_TO_PERIPH)  || \
427
+                                     ((DIRECTION) == DMA_MEMORY_TO_MEMORY))
428
+
429
+#define IS_DMA_BUFFER_SIZE(SIZE) (((SIZE) >= 0x1U) && ((SIZE) < 0x10000U))
430
+
431
+#define IS_DMA_PERIPHERAL_INC_STATE(STATE) (((STATE) == DMA_PINC_ENABLE) || \
432
+                                            ((STATE) == DMA_PINC_DISABLE))
433
+
434
+#define IS_DMA_MEMORY_INC_STATE(STATE) (((STATE) == DMA_MINC_ENABLE)  || \
435
+                                        ((STATE) == DMA_MINC_DISABLE))
436
+
437
+#define IS_DMA_PERIPHERAL_DATA_SIZE(SIZE) (((SIZE) == DMA_PDATAALIGN_BYTE)     || \
438
+                                           ((SIZE) == DMA_PDATAALIGN_HALFWORD) || \
439
+                                           ((SIZE) == DMA_PDATAALIGN_WORD))
440
+
441
+#define IS_DMA_MEMORY_DATA_SIZE(SIZE) (((SIZE) == DMA_MDATAALIGN_BYTE)     || \
442
+                                       ((SIZE) == DMA_MDATAALIGN_HALFWORD) || \
443
+                                       ((SIZE) == DMA_MDATAALIGN_WORD ))
444
+
445
+#define IS_DMA_MODE(MODE) (((MODE) == DMA_NORMAL )  || \
446
+                           ((MODE) == DMA_CIRCULAR))
447
+
448
+#define IS_DMA_PRIORITY(PRIORITY) (((PRIORITY) == DMA_PRIORITY_LOW )   || \
449
+                                   ((PRIORITY) == DMA_PRIORITY_MEDIUM) || \
450
+                                   ((PRIORITY) == DMA_PRIORITY_HIGH)   || \
451
+                                   ((PRIORITY) == DMA_PRIORITY_VERY_HIGH))
452
+
453
+/**
454
+  * @}
455
+  */ 
456
+
457
+/* Private functions ---------------------------------------------------------*/
458
+
459
+/**
460
+  * @}
461
+  */
462
+
463
+/**
464
+  * @}
465
+  */
466
+
467
+#ifdef __cplusplus
468
+}
469
+#endif
470
+
471
+#endif /* __STM32F1xx_HAL_DMA_H */
472
+
473
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 293 - 0
Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma_ex.h

@@ -0,0 +1,293 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx_hal_dma_ex.h
4
+  * @author  MCD Application Team
5
+  * @brief   Header file of DMA HAL extension module.
6
+  ******************************************************************************
7
+  * @attention
8
+  *
9
+  * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
10
+  *
11
+  * Redistribution and use in source and binary forms, with or without modification,
12
+  * are permitted provided that the following conditions are met:
13
+  *   1. Redistributions of source code must retain the above copyright notice,
14
+  *      this list of conditions and the following disclaimer.
15
+  *   2. Redistributions in binary form must reproduce the above copyright notice,
16
+  *      this list of conditions and the following disclaimer in the documentation
17
+  *      and/or other materials provided with the distribution.
18
+  *   3. Neither the name of STMicroelectronics nor the names of its contributors
19
+  *      may be used to endorse or promote products derived from this software
20
+  *      without specific prior written permission.
21
+  *
22
+  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
+  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25
+  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28
+  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29
+  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30
+  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
+  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
+  *
33
+  ******************************************************************************
34
+  */
35
+
36
+/* Define to prevent recursive inclusion -------------------------------------*/
37
+#ifndef __STM32F1xx_HAL_DMA_EX_H
38
+#define __STM32F1xx_HAL_DMA_EX_H
39
+
40
+#ifdef __cplusplus
41
+ extern "C" {
42
+#endif
43
+
44
+/* Includes ------------------------------------------------------------------*/
45
+#include "stm32f1xx_hal_def.h"
46
+
47
+/** @addtogroup STM32F1xx_HAL_Driver
48
+  * @{
49
+  */
50
+
51
+/** @defgroup DMAEx DMAEx
52
+  * @{
53
+  */
54
+
55
+/* Exported types ------------------------------------------------------------*/ 
56
+/* Exported constants --------------------------------------------------------*/
57
+/* Exported macro ------------------------------------------------------------*/
58
+/** @defgroup DMAEx_Exported_Macros DMA Extended Exported Macros
59
+  * @{
60
+  */
61
+/* Interrupt & Flag management */
62
+#if defined (STM32F100xE) || defined (STM32F101xE) || defined (STM32F101xG) || defined (STM32F103xE) || \
63
+    defined (STM32F103xG) || defined (STM32F105xC) || defined (STM32F107xC)
64
+/** @defgroup DMAEx_High_density_XL_density_Product_devices DMAEx High density and XL density product devices
65
+  * @{
66
+  */
67
+
68
+/**
69
+  * @brief  Returns the current DMA Channel transfer complete flag.
70
+  * @param  __HANDLE__: DMA handle
71
+  * @retval The specified transfer complete flag index.
72
+  */
73
+#define __HAL_DMA_GET_TC_FLAG_INDEX(__HANDLE__) \
74
+(((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel1))? DMA_FLAG_TC1 :\
75
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel2))? DMA_FLAG_TC2 :\
76
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel3))? DMA_FLAG_TC3 :\
77
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel4))? DMA_FLAG_TC4 :\
78
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel5))? DMA_FLAG_TC5 :\
79
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel6))? DMA_FLAG_TC6 :\
80
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel7))? DMA_FLAG_TC7 :\
81
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel1))? DMA_FLAG_TC1 :\
82
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel2))? DMA_FLAG_TC2 :\
83
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel3))? DMA_FLAG_TC3 :\
84
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel4))? DMA_FLAG_TC4 :\
85
+   DMA_FLAG_TC5)
86
+
87
+/**
88
+  * @brief  Returns the current DMA Channel half transfer complete flag.
89
+  * @param  __HANDLE__: DMA handle
90
+  * @retval The specified half transfer complete flag index.
91
+  */      
92
+#define __HAL_DMA_GET_HT_FLAG_INDEX(__HANDLE__)\
93
+(((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel1))? DMA_FLAG_HT1 :\
94
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel2))? DMA_FLAG_HT2 :\
95
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel3))? DMA_FLAG_HT3 :\
96
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel4))? DMA_FLAG_HT4 :\
97
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel5))? DMA_FLAG_HT5 :\
98
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel6))? DMA_FLAG_HT6 :\
99
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel7))? DMA_FLAG_HT7 :\
100
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel1))? DMA_FLAG_HT1 :\
101
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel2))? DMA_FLAG_HT2 :\
102
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel3))? DMA_FLAG_HT3 :\
103
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel4))? DMA_FLAG_HT4 :\
104
+   DMA_FLAG_HT5)
105
+
106
+/**
107
+  * @brief  Returns the current DMA Channel transfer error flag.
108
+  * @param  __HANDLE__: DMA handle
109
+  * @retval The specified transfer error flag index.
110
+  */
111
+#define __HAL_DMA_GET_TE_FLAG_INDEX(__HANDLE__)\
112
+(((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel1))? DMA_FLAG_TE1 :\
113
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel2))? DMA_FLAG_TE2 :\
114
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel3))? DMA_FLAG_TE3 :\
115
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel4))? DMA_FLAG_TE4 :\
116
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel5))? DMA_FLAG_TE5 :\
117
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel6))? DMA_FLAG_TE6 :\
118
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel7))? DMA_FLAG_TE7 :\
119
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel1))? DMA_FLAG_TE1 :\
120
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel2))? DMA_FLAG_TE2 :\
121
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel3))? DMA_FLAG_TE3 :\
122
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel4))? DMA_FLAG_TE4 :\
123
+   DMA_FLAG_TE5)
124
+
125
+/**
126
+  * @brief  Return the current DMA Channel Global interrupt flag.
127
+  * @param  __HANDLE__: DMA handle
128
+  * @retval The specified transfer error flag index.
129
+  */
130
+#define __HAL_DMA_GET_GI_FLAG_INDEX(__HANDLE__)\
131
+(((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel1))? DMA_FLAG_GL1 :\
132
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel2))? DMA_FLAG_GL2 :\
133
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel3))? DMA_FLAG_GL3 :\
134
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel4))? DMA_FLAG_GL4 :\
135
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel5))? DMA_FLAG_GL5 :\
136
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel6))? DMA_FLAG_GL6 :\
137
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel7))? DMA_FLAG_GL7 :\
138
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel1))? DMA_FLAG_GL1 :\
139
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel2))? DMA_FLAG_GL2 :\
140
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel3))? DMA_FLAG_GL3 :\
141
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA2_Channel4))? DMA_FLAG_GL4 :\
142
+   DMA_FLAG_GL5)
143
+   
144
+/**
145
+  * @brief  Get the DMA Channel pending flags.
146
+  * @param  __HANDLE__: DMA handle
147
+  * @param  __FLAG__: Get the specified flag.
148
+  *          This parameter can be any combination of the following values:
149
+  *            @arg DMA_FLAG_TCx:  Transfer complete flag
150
+  *            @arg DMA_FLAG_HTx:  Half transfer complete flag
151
+  *            @arg DMA_FLAG_TEx:  Transfer error flag
152
+  *         Where x can be 1_7 or 1_5 (depending on DMA1 or DMA2) to select the DMA Channel flag.   
153
+  * @retval The state of FLAG (SET or RESET).
154
+  */
155
+#define __HAL_DMA_GET_FLAG(__HANDLE__, __FLAG__)\
156
+(((uint32_t)((__HANDLE__)->Instance) > (uint32_t)DMA1_Channel7)? (DMA2->ISR & (__FLAG__)) :\
157
+  (DMA1->ISR & (__FLAG__)))
158
+
159
+/**
160
+  * @brief  Clears the DMA Channel pending flags.
161
+  * @param  __HANDLE__: DMA handle
162
+  * @param  __FLAG__: specifies the flag to clear.
163
+  *          This parameter can be any combination of the following values:
164
+  *            @arg DMA_FLAG_TCx:  Transfer complete flag
165
+  *            @arg DMA_FLAG_HTx:  Half transfer complete flag
166
+  *            @arg DMA_FLAG_TEx:  Transfer error flag
167
+  *         Where x can be 1_7 or 1_5 (depending on DMA1 or DMA2) to select the DMA Channel flag.   
168
+  * @retval None
169
+  */
170
+#define __HAL_DMA_CLEAR_FLAG(__HANDLE__, __FLAG__) \
171
+(((uint32_t)((__HANDLE__)->Instance) > (uint32_t)DMA1_Channel7)? (DMA2->IFCR = (__FLAG__)) :\
172
+  (DMA1->IFCR = (__FLAG__)))
173
+
174
+/**
175
+  * @}
176
+  */
177
+
178
+#else
179
+/** @defgroup DMA_Low_density_Medium_density_Product_devices DMA Low density and Medium density product devices
180
+  * @{
181
+  */
182
+
183
+/**
184
+  * @brief  Returns the current DMA Channel transfer complete flag.
185
+  * @param  __HANDLE__: DMA handle
186
+  * @retval The specified transfer complete flag index.
187
+  */
188
+#define __HAL_DMA_GET_TC_FLAG_INDEX(__HANDLE__) \
189
+(((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel1))? DMA_FLAG_TC1 :\
190
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel2))? DMA_FLAG_TC2 :\
191
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel3))? DMA_FLAG_TC3 :\
192
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel4))? DMA_FLAG_TC4 :\
193
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel5))? DMA_FLAG_TC5 :\
194
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel6))? DMA_FLAG_TC6 :\
195
+   DMA_FLAG_TC7)
196
+
197
+/**
198
+  * @brief  Return the current DMA Channel half transfer complete flag.
199
+  * @param  __HANDLE__: DMA handle
200
+  * @retval The specified half transfer complete flag index.
201
+  */
202
+#define __HAL_DMA_GET_HT_FLAG_INDEX(__HANDLE__)\
203
+(((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel1))? DMA_FLAG_HT1 :\
204
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel2))? DMA_FLAG_HT2 :\
205
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel3))? DMA_FLAG_HT3 :\
206
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel4))? DMA_FLAG_HT4 :\
207
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel5))? DMA_FLAG_HT5 :\
208
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel6))? DMA_FLAG_HT6 :\
209
+   DMA_FLAG_HT7)
210
+
211
+/**
212
+  * @brief  Return the current DMA Channel transfer error flag.
213
+  * @param  __HANDLE__: DMA handle
214
+  * @retval The specified transfer error flag index.
215
+  */
216
+#define __HAL_DMA_GET_TE_FLAG_INDEX(__HANDLE__)\
217
+(((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel1))? DMA_FLAG_TE1 :\
218
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel2))? DMA_FLAG_TE2 :\
219
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel3))? DMA_FLAG_TE3 :\
220
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel4))? DMA_FLAG_TE4 :\
221
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel5))? DMA_FLAG_TE5 :\
222
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel6))? DMA_FLAG_TE6 :\
223
+   DMA_FLAG_TE7)
224
+
225
+/**
226
+  * @brief  Return the current DMA Channel Global interrupt flag.
227
+  * @param  __HANDLE__: DMA handle
228
+  * @retval The specified transfer error flag index.
229
+  */
230
+#define __HAL_DMA_GET_GI_FLAG_INDEX(__HANDLE__)\
231
+(((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel1))? DMA_FLAG_GL1 :\
232
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel2))? DMA_FLAG_GL2 :\
233
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel3))? DMA_FLAG_GL3 :\
234
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel4))? DMA_FLAG_GL4 :\
235
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel5))? DMA_FLAG_GL5 :\
236
+ ((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel6))? DMA_FLAG_GL6 :\
237
+   DMA_FLAG_GL7)
238
+
239
+/**
240
+  * @brief  Get the DMA Channel pending flags.
241
+  * @param  __HANDLE__: DMA handle
242
+  * @param  __FLAG__: Get the specified flag.
243
+  *          This parameter can be any combination of the following values:
244
+  *            @arg DMA_FLAG_TCx:  Transfer complete flag
245
+  *            @arg DMA_FLAG_HTx:  Half transfer complete flag
246
+  *            @arg DMA_FLAG_TEx:  Transfer error flag
247
+  *            @arg DMA_FLAG_GLx:  Global interrupt flag
248
+  *         Where x can be 1_7 to select the DMA Channel flag.   
249
+  * @retval The state of FLAG (SET or RESET).
250
+  */
251
+
252
+#define __HAL_DMA_GET_FLAG(__HANDLE__, __FLAG__)   (DMA1->ISR & (__FLAG__))
253
+
254
+/**
255
+  * @brief  Clear the DMA Channel pending flags.
256
+  * @param  __HANDLE__: DMA handle
257
+  * @param  __FLAG__: specifies the flag to clear.
258
+  *          This parameter can be any combination of the following values:
259
+  *            @arg DMA_FLAG_TCx:  Transfer complete flag
260
+  *            @arg DMA_FLAG_HTx:  Half transfer complete flag
261
+  *            @arg DMA_FLAG_TEx:  Transfer error flag
262
+  *            @arg DMA_FLAG_GLx:  Global interrupt flag
263
+  *         Where x can be 1_7 to select the DMA Channel flag.   
264
+  * @retval None
265
+  */
266
+#define __HAL_DMA_CLEAR_FLAG(__HANDLE__, __FLAG__) (DMA1->IFCR = (__FLAG__))
267
+
268
+/**
269
+  * @}
270
+  */
271
+
272
+#endif
273
+  
274
+/**
275
+  * @}
276
+  */
277
+
278
+/**
279
+  * @}
280
+  */
281
+
282
+/**
283
+  * @}
284
+  */
285
+
286
+#ifdef __cplusplus
287
+}
288
+#endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || */
289
+       /* STM32F103xG || STM32F105xC || STM32F107xC */
290
+
291
+#endif /* __STM32F1xx_HAL_DMA_H */
292
+
293
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 344 - 0
Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash.h

@@ -0,0 +1,344 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx_hal_flash.h
4
+  * @author  MCD Application Team
5
+  * @brief   Header file of Flash HAL module.
6
+  ******************************************************************************
7
+  * @attention
8
+  *
9
+  * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
10
+  *
11
+  * Redistribution and use in source and binary forms, with or without modification,
12
+  * are permitted provided that the following conditions are met:
13
+  *   1. Redistributions of source code must retain the above copyright notice,
14
+  *      this list of conditions and the following disclaimer.
15
+  *   2. Redistributions in binary form must reproduce the above copyright notice,
16
+  *      this list of conditions and the following disclaimer in the documentation
17
+  *      and/or other materials provided with the distribution.
18
+  *   3. Neither the name of STMicroelectronics nor the names of its contributors
19
+  *      may be used to endorse or promote products derived from this software
20
+  *      without specific prior written permission.
21
+  *
22
+  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
+  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25
+  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28
+  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29
+  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30
+  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
+  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
+  *
33
+  ******************************************************************************  
34
+  */
35
+
36
+/* Define to prevent recursive inclusion -------------------------------------*/
37
+#ifndef __STM32F1xx_HAL_FLASH_H
38
+#define __STM32F1xx_HAL_FLASH_H
39
+
40
+#ifdef __cplusplus
41
+ extern "C" {
42
+#endif
43
+
44
+/* Includes ------------------------------------------------------------------*/
45
+#include "stm32f1xx_hal_def.h"
46
+   
47
+/** @addtogroup STM32F1xx_HAL_Driver
48
+  * @{
49
+  */
50
+
51
+/** @addtogroup FLASH
52
+  * @{
53
+  */
54
+  
55
+/** @addtogroup FLASH_Private_Constants
56
+  * @{
57
+  */
58
+#define FLASH_TIMEOUT_VALUE              50000U /* 50 s */
59
+/**
60
+  * @}
61
+  */
62
+
63
+/** @addtogroup FLASH_Private_Macros
64
+  * @{
65
+  */
66
+
67
+#define IS_FLASH_TYPEPROGRAM(VALUE)  (((VALUE) == FLASH_TYPEPROGRAM_HALFWORD) || \
68
+                                      ((VALUE) == FLASH_TYPEPROGRAM_WORD)     || \
69
+                                      ((VALUE) == FLASH_TYPEPROGRAM_DOUBLEWORD))  
70
+
71
+#if   defined(FLASH_ACR_LATENCY)
72
+#define IS_FLASH_LATENCY(__LATENCY__) (((__LATENCY__) == FLASH_LATENCY_0) || \
73
+                                       ((__LATENCY__) == FLASH_LATENCY_1) || \
74
+                                       ((__LATENCY__) == FLASH_LATENCY_2))
75
+
76
+#else
77
+#define IS_FLASH_LATENCY(__LATENCY__)   ((__LATENCY__) == FLASH_LATENCY_0)
78
+#endif /* FLASH_ACR_LATENCY */
79
+/**
80
+  * @}
81
+  */  
82
+
83
+/* Exported types ------------------------------------------------------------*/ 
84
+/** @defgroup FLASH_Exported_Types FLASH Exported Types
85
+  * @{
86
+  */  
87
+
88
+/**
89
+  * @brief  FLASH Procedure structure definition
90
+  */
91
+typedef enum 
92
+{
93
+  FLASH_PROC_NONE              = 0U, 
94
+  FLASH_PROC_PAGEERASE         = 1U,
95
+  FLASH_PROC_MASSERASE         = 2U,
96
+  FLASH_PROC_PROGRAMHALFWORD   = 3U,
97
+  FLASH_PROC_PROGRAMWORD       = 4U,
98
+  FLASH_PROC_PROGRAMDOUBLEWORD = 5U
99
+} FLASH_ProcedureTypeDef;
100
+
101
+/** 
102
+  * @brief  FLASH handle Structure definition  
103
+  */
104
+typedef struct
105
+{
106
+  __IO FLASH_ProcedureTypeDef ProcedureOnGoing; /*!< Internal variable to indicate which procedure is ongoing or not in IT context */
107
+  
108
+  __IO uint32_t               DataRemaining;    /*!< Internal variable to save the remaining pages to erase or half-word to program in IT context */
109
+
110
+  __IO uint32_t               Address;          /*!< Internal variable to save address selected for program or erase */
111
+
112
+  __IO uint64_t               Data;             /*!< Internal variable to save data to be programmed */
113
+
114
+  HAL_LockTypeDef             Lock;             /*!< FLASH locking object                */
115
+
116
+  __IO uint32_t               ErrorCode;        /*!< FLASH error code                    
117
+                                                     This parameter can be a value of @ref FLASH_Error_Codes  */
118
+} FLASH_ProcessTypeDef;
119
+
120
+/**
121
+  * @}
122
+  */
123
+
124
+/* Exported constants --------------------------------------------------------*/
125
+/** @defgroup FLASH_Exported_Constants FLASH Exported Constants
126
+  * @{
127
+  */  
128
+
129
+/** @defgroup FLASH_Error_Codes FLASH Error Codes
130
+  * @{
131
+  */
132
+
133
+#define HAL_FLASH_ERROR_NONE      0x00U  /*!< No error */
134
+#define HAL_FLASH_ERROR_PROG      0x01U  /*!< Programming error */
135
+#define HAL_FLASH_ERROR_WRP       0x02U  /*!< Write protection error */
136
+#define HAL_FLASH_ERROR_OPTV      0x04U  /*!< Option validity error */
137
+
138
+/**
139
+  * @}
140
+  */
141
+
142
+/** @defgroup FLASH_Type_Program FLASH Type Program
143
+  * @{
144
+  */ 
145
+#define FLASH_TYPEPROGRAM_HALFWORD             0x01U  /*!<Program a half-word (16-bit) at a specified address.*/
146
+#define FLASH_TYPEPROGRAM_WORD                 0x02U  /*!<Program a word (32-bit) at a specified address.*/
147
+#define FLASH_TYPEPROGRAM_DOUBLEWORD           0x03U  /*!<Program a double word (64-bit) at a specified address*/
148
+
149
+/**
150
+  * @}
151
+  */
152
+
153
+#if   defined(FLASH_ACR_LATENCY)
154
+/** @defgroup FLASH_Latency FLASH Latency
155
+  * @{
156
+  */
157
+#define FLASH_LATENCY_0            0x00000000U               /*!< FLASH Zero Latency cycle */
158
+#define FLASH_LATENCY_1            FLASH_ACR_LATENCY_0       /*!< FLASH One Latency cycle */
159
+#define FLASH_LATENCY_2            FLASH_ACR_LATENCY_1       /*!< FLASH Two Latency cycles */
160
+
161
+/**
162
+  * @}
163
+  */
164
+
165
+#else
166
+/** @defgroup FLASH_Latency FLASH Latency
167
+  * @{
168
+  */
169
+#define FLASH_LATENCY_0            0x00000000U    /*!< FLASH Zero Latency cycle */
170
+
171
+/**
172
+  * @}
173
+  */
174
+
175
+#endif /* FLASH_ACR_LATENCY */
176
+/**
177
+  * @}
178
+  */  
179
+  
180
+/* Exported macro ------------------------------------------------------------*/
181
+
182
+/** @defgroup FLASH_Exported_Macros FLASH Exported Macros
183
+ *  @brief macros to control FLASH features 
184
+ *  @{
185
+ */
186
+ 
187
+/** @defgroup FLASH_Half_Cycle FLASH Half Cycle
188
+ *  @brief macros to handle FLASH half cycle
189
+ * @{
190
+ */
191
+
192
+/**
193
+  * @brief  Enable the FLASH half cycle access.
194
+  * @note   half cycle access can only be used with a low-frequency clock of less than
195
+            8 MHz that can be obtained with the use of HSI or HSE but not of PLL.
196
+  * @retval None
197
+  */
198
+#define __HAL_FLASH_HALF_CYCLE_ACCESS_ENABLE()  (FLASH->ACR |= FLASH_ACR_HLFCYA)
199
+
200
+/**
201
+  * @brief  Disable the FLASH half cycle access.
202
+  * @note   half cycle access can only be used with a low-frequency clock of less than
203
+            8 MHz that can be obtained with the use of HSI or HSE but not of PLL.
204
+  * @retval None
205
+  */
206
+#define __HAL_FLASH_HALF_CYCLE_ACCESS_DISABLE() (FLASH->ACR &= (~FLASH_ACR_HLFCYA))
207
+
208
+/**
209
+  * @}
210
+  */
211
+
212
+#if defined(FLASH_ACR_LATENCY)
213
+/** @defgroup FLASH_EM_Latency FLASH Latency
214
+ *  @brief macros to handle FLASH Latency
215
+ * @{
216
+ */ 
217
+  
218
+/**
219
+  * @brief  Set the FLASH Latency.
220
+  * @param  __LATENCY__ FLASH Latency                   
221
+  *         The value of this parameter depend on device used within the same series
222
+  * @retval None
223
+  */ 
224
+#define __HAL_FLASH_SET_LATENCY(__LATENCY__)    (FLASH->ACR = (FLASH->ACR&(~FLASH_ACR_LATENCY)) | (__LATENCY__))
225
+
226
+
227
+/**
228
+  * @brief  Get the FLASH Latency.
229
+  * @retval FLASH Latency                   
230
+  *         The value of this parameter depend on device used within the same series
231
+  */ 
232
+#define __HAL_FLASH_GET_LATENCY()     (READ_BIT((FLASH->ACR), FLASH_ACR_LATENCY))
233
+
234
+/**
235
+  * @}
236
+  */
237
+
238
+#endif /* FLASH_ACR_LATENCY */
239
+/** @defgroup FLASH_Prefetch FLASH Prefetch
240
+ *  @brief macros to handle FLASH Prefetch buffer
241
+ * @{
242
+ */   
243
+/**
244
+  * @brief  Enable the FLASH prefetch buffer.
245
+  * @retval None
246
+  */ 
247
+#define __HAL_FLASH_PREFETCH_BUFFER_ENABLE()    (FLASH->ACR |= FLASH_ACR_PRFTBE)
248
+
249
+/**
250
+  * @brief  Disable the FLASH prefetch buffer.
251
+  * @retval None
252
+  */
253
+#define __HAL_FLASH_PREFETCH_BUFFER_DISABLE()   (FLASH->ACR &= (~FLASH_ACR_PRFTBE))
254
+
255
+/**
256
+  * @}
257
+  */
258
+  
259
+/**
260
+  * @}
261
+  */ 
262
+
263
+/* Include FLASH HAL Extended module */
264
+#include "stm32f1xx_hal_flash_ex.h"  
265
+
266
+/* Exported functions --------------------------------------------------------*/
267
+/** @addtogroup FLASH_Exported_Functions
268
+  * @{
269
+  */
270
+  
271
+/** @addtogroup FLASH_Exported_Functions_Group1
272
+  * @{
273
+  */
274
+/* IO operation functions *****************************************************/
275
+HAL_StatusTypeDef HAL_FLASH_Program(uint32_t TypeProgram, uint32_t Address, uint64_t Data);
276
+HAL_StatusTypeDef HAL_FLASH_Program_IT(uint32_t TypeProgram, uint32_t Address, uint64_t Data);
277
+
278
+/* FLASH IRQ handler function */
279
+void       HAL_FLASH_IRQHandler(void);
280
+/* Callbacks in non blocking modes */ 
281
+void       HAL_FLASH_EndOfOperationCallback(uint32_t ReturnValue);
282
+void       HAL_FLASH_OperationErrorCallback(uint32_t ReturnValue);
283
+
284
+/**
285
+  * @}
286
+  */
287
+
288
+/** @addtogroup FLASH_Exported_Functions_Group2
289
+  * @{
290
+  */
291
+/* Peripheral Control functions ***********************************************/
292
+HAL_StatusTypeDef HAL_FLASH_Unlock(void);
293
+HAL_StatusTypeDef HAL_FLASH_Lock(void);
294
+HAL_StatusTypeDef HAL_FLASH_OB_Unlock(void);
295
+HAL_StatusTypeDef HAL_FLASH_OB_Lock(void);
296
+void HAL_FLASH_OB_Launch(void);
297
+
298
+/**
299
+  * @}
300
+  */
301
+
302
+/** @addtogroup FLASH_Exported_Functions_Group3
303
+  * @{
304
+  */
305
+/* Peripheral State and Error functions ***************************************/
306
+uint32_t HAL_FLASH_GetError(void);
307
+
308
+/**
309
+  * @}
310
+  */
311
+
312
+/**
313
+  * @}
314
+  */
315
+
316
+/* Private function -------------------------------------------------*/
317
+/** @addtogroup FLASH_Private_Functions
318
+ * @{
319
+ */
320
+HAL_StatusTypeDef       FLASH_WaitForLastOperation(uint32_t Timeout);
321
+#if defined(FLASH_BANK2_END)
322
+HAL_StatusTypeDef       FLASH_WaitForLastOperationBank2(uint32_t Timeout);
323
+#endif /* FLASH_BANK2_END */
324
+
325
+/**
326
+  * @}
327
+  */
328
+
329
+/**
330
+  * @}
331
+  */
332
+
333
+/**
334
+  * @}
335
+  */
336
+
337
+#ifdef __cplusplus
338
+}
339
+#endif
340
+
341
+#endif /* __STM32F1xx_HAL_FLASH_H */
342
+
343
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
344
+

+ 802 - 0
Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash_ex.h

@@ -0,0 +1,802 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx_hal_flash_ex.h
4
+  * @author  MCD Application Team
5
+  * @brief   Header file of Flash HAL Extended module.
6
+  ******************************************************************************
7
+  * @attention
8
+  *
9
+  * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
10
+  *
11
+  * Redistribution and use in source and binary forms, with or without modification,
12
+  * are permitted provided that the following conditions are met:
13
+  *   1. Redistributions of source code must retain the above copyright notice,
14
+  *      this list of conditions and the following disclaimer.
15
+  *   2. Redistributions in binary form must reproduce the above copyright notice,
16
+  *      this list of conditions and the following disclaimer in the documentation
17
+  *      and/or other materials provided with the distribution.
18
+  *   3. Neither the name of STMicroelectronics nor the names of its contributors
19
+  *      may be used to endorse or promote products derived from this software
20
+  *      without specific prior written permission.
21
+  *
22
+  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
+  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25
+  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28
+  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29
+  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30
+  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
+  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
+  *
33
+  ******************************************************************************
34
+  */
35
+
36
+/* Define to prevent recursive inclusion -------------------------------------*/
37
+#ifndef __STM32F1xx_HAL_FLASH_EX_H
38
+#define __STM32F1xx_HAL_FLASH_EX_H
39
+
40
+#ifdef __cplusplus
41
+ extern "C" {
42
+#endif
43
+
44
+/* Includes ------------------------------------------------------------------*/
45
+#include "stm32f1xx_hal_def.h"
46
+
47
+/** @addtogroup STM32F1xx_HAL_Driver
48
+  * @{
49
+  */
50
+
51
+/** @addtogroup FLASHEx
52
+  * @{
53
+  */ 
54
+
55
+/** @addtogroup FLASHEx_Private_Constants
56
+  * @{
57
+  */
58
+
59
+#define FLASH_SIZE_DATA_REGISTER     0x1FFFF7E0U
60
+#define OBR_REG_INDEX                1U
61
+#define SR_FLAG_MASK                 ((uint32_t)(FLASH_SR_BSY | FLASH_SR_PGERR | FLASH_SR_WRPRTERR | FLASH_SR_EOP))
62
+
63
+/**
64
+  * @}
65
+  */  
66
+
67
+/** @addtogroup FLASHEx_Private_Macros
68
+  * @{
69
+  */
70
+
71
+#define IS_FLASH_TYPEERASE(VALUE)   (((VALUE) == FLASH_TYPEERASE_PAGES) || ((VALUE) == FLASH_TYPEERASE_MASSERASE))
72
+
73
+#define IS_OPTIONBYTE(VALUE)        (((VALUE) <= (OPTIONBYTE_WRP | OPTIONBYTE_RDP | OPTIONBYTE_USER | OPTIONBYTE_DATA)))
74
+
75
+#define IS_WRPSTATE(VALUE)          (((VALUE) == OB_WRPSTATE_DISABLE) || ((VALUE) == OB_WRPSTATE_ENABLE))
76
+
77
+#define IS_OB_RDP_LEVEL(LEVEL)      (((LEVEL) == OB_RDP_LEVEL_0) || ((LEVEL) == OB_RDP_LEVEL_1))
78
+
79
+#define IS_OB_DATA_ADDRESS(ADDRESS) (((ADDRESS) == OB_DATA_ADDRESS_DATA0) || ((ADDRESS) == OB_DATA_ADDRESS_DATA1)) 
80
+
81
+#define IS_OB_IWDG_SOURCE(SOURCE)   (((SOURCE) == OB_IWDG_SW) || ((SOURCE) == OB_IWDG_HW))
82
+
83
+#define IS_OB_STOP_SOURCE(SOURCE)   (((SOURCE) == OB_STOP_NO_RST) || ((SOURCE) == OB_STOP_RST))
84
+
85
+#define IS_OB_STDBY_SOURCE(SOURCE)  (((SOURCE) == OB_STDBY_NO_RST) || ((SOURCE) == OB_STDBY_RST))
86
+
87
+#if defined(FLASH_BANK2_END)
88
+#define IS_OB_BOOT1(BOOT1)         (((BOOT1) == OB_BOOT1_RESET) || ((BOOT1) == OB_BOOT1_SET))
89
+#endif /* FLASH_BANK2_END */
90
+
91
+/* Low Density */
92
+#if (defined(STM32F101x6) || defined(STM32F102x6) || defined(STM32F103x6))
93
+#define IS_FLASH_NB_PAGES(ADDRESS,NBPAGES) (((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) == 0x20U) ? ((ADDRESS)+((NBPAGES)*FLASH_PAGE_SIZE)- 1 <= 0x08007FFFU) : \
94
+                                           ((ADDRESS)+((NBPAGES)*FLASH_PAGE_SIZE)- 1 <= 0x08003FFFU))
95
+#endif /* STM32F101x6 || STM32F102x6 || STM32F103x6 */
96
+
97
+/* Medium Density */
98
+#if (defined(STM32F100xB) || defined(STM32F101xB) || defined(STM32F102xB) || defined(STM32F103xB))
99
+#define IS_FLASH_NB_PAGES(ADDRESS,NBPAGES) (((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) == 0x80U) ? ((ADDRESS)+((NBPAGES)*FLASH_PAGE_SIZE)-1 <= 0x0801FFFFU) : \
100
+                                           (((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) == 0x40U) ? ((ADDRESS)+((NBPAGES)*FLASH_PAGE_SIZE)-1 <= 0x0800FFFFU) : \
101
+                                           (((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) == 0x20U) ? ((ADDRESS)+((NBPAGES)*FLASH_PAGE_SIZE)-1 <= 0x08007FFFU) : \
102
+                                           ((ADDRESS)+((NBPAGES)*FLASH_PAGE_SIZE)-1 <= 0x08003FFFU))))
103
+#endif /* STM32F100xB || STM32F101xB || STM32F102xB || STM32F103xB*/
104
+
105
+/* High Density */
106
+#if (defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F103xE))
107
+#define IS_FLASH_NB_PAGES(ADDRESS,NBPAGES) (((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) == 0x200U) ? ((ADDRESS)+((NBPAGES)*FLASH_PAGE_SIZE)-1 <= 0x0807FFFFU) : \
108
+                                           (((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) == 0x180U) ? ((ADDRESS)+((NBPAGES)*FLASH_PAGE_SIZE)-1 <= 0x0805FFFFU) : \
109
+                                           ((ADDRESS)+((NBPAGES)*FLASH_PAGE_SIZE)-1 <= 0x0803FFFFU)))
110
+#endif /* STM32F100xE || STM32F101xE || STM32F103xE */
111
+
112
+/* XL Density */
113
+#if defined(FLASH_BANK2_END)
114
+#define IS_FLASH_NB_PAGES(ADDRESS,NBPAGES) (((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) == 0x400U) ? ((ADDRESS)+((NBPAGES)*FLASH_PAGE_SIZE)-1 <= 0x080FFFFFU) : \
115
+                                           ((ADDRESS)+((NBPAGES)*FLASH_PAGE_SIZE)-1 <= 0x080BFFFFU))
116
+#endif /* FLASH_BANK2_END */
117
+
118
+/* Connectivity Line */
119
+#if (defined(STM32F105xC) || defined(STM32F107xC))
120
+#define IS_FLASH_NB_PAGES(ADDRESS,NBPAGES) (((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) == 0x100U) ? ((ADDRESS)+((NBPAGES)*FLASH_PAGE_SIZE)-1 <= 0x0803FFFFU) : \
121
+                                           (((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) ==  0x80U) ? ((ADDRESS)+((NBPAGES)*FLASH_PAGE_SIZE)-1 <= 0x0801FFFFU) : \
122
+                                           ((ADDRESS)+((NBPAGES)*FLASH_PAGE_SIZE)-1 <= 0x0800FFFFU)))
123
+#endif /* STM32F105xC || STM32F107xC */
124
+
125
+#define IS_OB_WRP(PAGE) (((PAGE) != 0x0000000U))
126
+
127
+#if defined(FLASH_BANK2_END)
128
+#define IS_FLASH_BANK(BANK) (((BANK) == FLASH_BANK_1)  || \
129
+                             ((BANK) == FLASH_BANK_2)  || \
130
+                             ((BANK) == FLASH_BANK_BOTH))
131
+#else
132
+#define IS_FLASH_BANK(BANK) (((BANK) == FLASH_BANK_1))
133
+#endif /* FLASH_BANK2_END */
134
+
135
+/* Low Density */
136
+#if (defined(STM32F101x6) || defined(STM32F102x6) || defined(STM32F103x6))
137
+#define IS_FLASH_PROGRAM_ADDRESS(ADDRESS)  (((ADDRESS) >= FLASH_BASE) && (((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) == 0x20U) ? \
138
+                                            ((ADDRESS) <= FLASH_BANK1_END) :  ((ADDRESS) <= 0x08003FFFU)))
139
+
140
+#endif /* STM32F101x6 || STM32F102x6 || STM32F103x6 */
141
+
142
+/* Medium Density */
143
+#if (defined(STM32F100xB) || defined(STM32F101xB) || defined(STM32F102xB) || defined(STM32F103xB))
144
+#define IS_FLASH_PROGRAM_ADDRESS(ADDRESS) (((ADDRESS) >= FLASH_BASE) && (((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) == 0x80U) ? \
145
+                                           ((ADDRESS) <= FLASH_BANK1_END) :  (((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) == 0x40U) ? \
146
+                                           ((ADDRESS) <= 0x0800FFFF) :  (((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) == 0x20U) ? \
147
+                                           ((ADDRESS) <= 0x08007FFF) :  ((ADDRESS) <= 0x08003FFFU)))))
148
+
149
+#endif /* STM32F100xB || STM32F101xB || STM32F102xB || STM32F103xB*/
150
+
151
+/* High Density */
152
+#if (defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F103xE))
153
+#define IS_FLASH_PROGRAM_ADDRESS(ADDRESS) (((ADDRESS) >= FLASH_BASE) && (((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) == 0x200U) ? \
154
+                                           ((ADDRESS) <= FLASH_BANK1_END) :  (((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) == 0x180U) ? \
155
+                                           ((ADDRESS) <= 0x0805FFFFU) :  ((ADDRESS) <= 0x0803FFFFU))))
156
+
157
+#endif /* STM32F100xE || STM32F101xE || STM32F103xE */
158
+
159
+/* XL Density */
160
+#if defined(FLASH_BANK2_END)
161
+#define IS_FLASH_PROGRAM_ADDRESS(ADDRESS) (((ADDRESS) >= FLASH_BASE) && (((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) == 0x400U) ? \
162
+                                           ((ADDRESS) <= FLASH_BANK2_END) :  ((ADDRESS) <= 0x080BFFFFU)))
163
+
164
+#endif /* FLASH_BANK2_END */
165
+
166
+/* Connectivity Line */
167
+#if (defined(STM32F105xC) || defined(STM32F107xC))
168
+#define IS_FLASH_PROGRAM_ADDRESS(ADDRESS) (((ADDRESS) >= FLASH_BASE) && (((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) == 0x100U) ? \
169
+                                           ((ADDRESS) <= FLASH_BANK1_END) :  (((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) == 0x80U) ? \
170
+                                           ((ADDRESS) <= 0x0801FFFFU) :  ((ADDRESS) <= 0x0800FFFFU))))
171
+
172
+#endif /* STM32F105xC || STM32F107xC */
173
+
174
+/**
175
+  * @}
176
+  */  
177
+
178
+/* Exported types ------------------------------------------------------------*/ 
179
+/** @defgroup FLASHEx_Exported_Types FLASHEx Exported Types
180
+  * @{
181
+  */  
182
+
183
+/**
184
+  * @brief  FLASH Erase structure definition
185
+  */
186
+typedef struct
187
+{
188
+  uint32_t TypeErase;   /*!< TypeErase: Mass erase or page erase.
189
+                             This parameter can be a value of @ref FLASHEx_Type_Erase */
190
+  
191
+  uint32_t Banks;       /*!< Select banks to erase when Mass erase is enabled.
192
+                             This parameter must be a value of @ref FLASHEx_Banks */    
193
+  
194
+  uint32_t PageAddress; /*!< PageAdress: Initial FLASH page address to erase when mass erase is disabled
195
+                             This parameter must be a number between Min_Data = 0x08000000 and Max_Data = FLASH_BANKx_END 
196
+                             (x = 1 or 2 depending on devices)*/
197
+  
198
+  uint32_t NbPages;     /*!< NbPages: Number of pagess to be erased.
199
+                             This parameter must be a value between Min_Data = 1 and Max_Data = (max number of pages - value of initial page)*/
200
+                                                          
201
+} FLASH_EraseInitTypeDef;
202
+
203
+/**
204
+  * @brief  FLASH Options bytes program structure definition
205
+  */
206
+typedef struct
207
+{
208
+  uint32_t OptionType;  /*!< OptionType: Option byte to be configured.
209
+                             This parameter can be a value of @ref FLASHEx_OB_Type */
210
+
211
+  uint32_t WRPState;    /*!< WRPState: Write protection activation or deactivation.
212
+                             This parameter can be a value of @ref FLASHEx_OB_WRP_State */
213
+
214
+  uint32_t WRPPage;     /*!< WRPPage: specifies the page(s) to be write protected
215
+                             This parameter can be a value of @ref FLASHEx_OB_Write_Protection */
216
+
217
+  uint32_t Banks;        /*!< Select banks for WRP activation/deactivation of all sectors.
218
+                              This parameter must be a value of @ref FLASHEx_Banks */ 
219
+    
220
+  uint8_t RDPLevel;     /*!< RDPLevel: Set the read protection level..
221
+                             This parameter can be a value of @ref FLASHEx_OB_Read_Protection */
222
+
223
+#if defined(FLASH_BANK2_END)
224
+  uint8_t USERConfig;   /*!< USERConfig: Program the FLASH User Option Byte: 
225
+                             IWDG / STOP / STDBY / BOOT1
226
+                             This parameter can be a combination of @ref FLASHEx_OB_IWatchdog, @ref FLASHEx_OB_nRST_STOP, 
227
+                             @ref FLASHEx_OB_nRST_STDBY, @ref FLASHEx_OB_BOOT1 */
228
+#else
229
+  uint8_t USERConfig;   /*!< USERConfig: Program the FLASH User Option Byte: 
230
+                             IWDG / STOP / STDBY
231
+                             This parameter can be a combination of @ref FLASHEx_OB_IWatchdog, @ref FLASHEx_OB_nRST_STOP, 
232
+                             @ref FLASHEx_OB_nRST_STDBY */
233
+#endif /* FLASH_BANK2_END */
234
+
235
+  uint32_t DATAAddress; /*!< DATAAddress: Address of the option byte DATA to be programmed
236
+                             This parameter can be a value of @ref FLASHEx_OB_Data_Address */
237
+  
238
+  uint8_t DATAData;     /*!< DATAData: Data to be stored in the option byte DATA
239
+                             This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF */
240
+} FLASH_OBProgramInitTypeDef;
241
+
242
+/**
243
+  * @}
244
+  */
245
+
246
+/* Exported constants --------------------------------------------------------*/
247
+/** @defgroup FLASHEx_Exported_Constants FLASHEx Exported Constants
248
+  * @{
249
+  */  
250
+
251
+/** @defgroup FLASHEx_Constants FLASH Constants
252
+  * @{
253
+  */ 
254
+
255
+/** @defgroup FLASHEx_Page_Size Page Size
256
+  * @{
257
+  */ 
258
+#if (defined(STM32F101x6) || defined(STM32F102x6) || defined(STM32F103x6) || defined(STM32F100xB) || defined(STM32F101xB) || defined(STM32F102xB) || defined(STM32F103xB))
259
+#define FLASH_PAGE_SIZE          0x400U
260
+#endif /* STM32F101x6 || STM32F102x6 || STM32F103x6 */
261
+       /* STM32F100xB || STM32F101xB || STM32F102xB || STM32F103xB */
262
+
263
+#if (defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F103xE) || defined(STM32F101xG) || defined(STM32F103xG) || defined(STM32F105xC) || defined(STM32F107xC))
264
+#define FLASH_PAGE_SIZE          0x800U
265
+#endif /* STM32F100xB || STM32F101xB || STM32F102xB || STM32F103xB */
266
+       /* STM32F101xG || STM32F103xG */ 
267
+       /* STM32F105xC || STM32F107xC */
268
+
269
+/**
270
+  * @}
271
+  */
272
+
273
+/** @defgroup FLASHEx_Type_Erase Type Erase
274
+  * @{
275
+  */ 
276
+#define FLASH_TYPEERASE_PAGES     0x00U  /*!<Pages erase only*/
277
+#define FLASH_TYPEERASE_MASSERASE 0x02U  /*!<Flash mass erase activation*/
278
+
279
+/**
280
+  * @}
281
+  */
282
+
283
+/** @defgroup FLASHEx_Banks Banks
284
+  * @{
285
+  */
286
+#if defined(FLASH_BANK2_END)
287
+#define FLASH_BANK_1     1U /*!< Bank 1   */
288
+#define FLASH_BANK_2     2U /*!< Bank 2   */
289
+#define FLASH_BANK_BOTH  ((uint32_t)FLASH_BANK_1 | FLASH_BANK_2) /*!< Bank1 and Bank2  */
290
+
291
+#else
292
+#define FLASH_BANK_1     1U /*!< Bank 1   */
293
+#endif
294
+/**
295
+  * @}
296
+  */
297
+
298
+/**
299
+  * @}
300
+  */
301
+
302
+/** @defgroup FLASHEx_OptionByte_Constants Option Byte Constants
303
+  * @{
304
+  */ 
305
+
306
+/** @defgroup FLASHEx_OB_Type Option Bytes Type
307
+  * @{
308
+  */
309
+#define OPTIONBYTE_WRP            0x01U  /*!<WRP option byte configuration*/
310
+#define OPTIONBYTE_RDP            0x02U  /*!<RDP option byte configuration*/
311
+#define OPTIONBYTE_USER           0x04U  /*!<USER option byte configuration*/
312
+#define OPTIONBYTE_DATA           0x08U  /*!<DATA option byte configuration*/
313
+
314
+/**
315
+  * @}
316
+  */
317
+
318
+/** @defgroup FLASHEx_OB_WRP_State Option Byte WRP State
319
+  * @{
320
+  */ 
321
+#define OB_WRPSTATE_DISABLE       0x00U  /*!<Disable the write protection of the desired pages*/
322
+#define OB_WRPSTATE_ENABLE        0x01U  /*!<Enable the write protection of the desired pagess*/
323
+
324
+/**
325
+  * @}
326
+  */
327
+
328
+/** @defgroup FLASHEx_OB_Write_Protection Option Bytes Write Protection
329
+  * @{
330
+  */
331
+/* STM32 Low and Medium density devices */
332
+#if  defined(STM32F101x6) || defined(STM32F102x6) || defined(STM32F103x6) \
333
+  || defined(STM32F100xB) || defined(STM32F101xB) || defined(STM32F102xB) \
334
+  || defined(STM32F103xB)
335
+#define OB_WRP_PAGES0TO3               0x00000001U /*!< Write protection of page 0 to 3 */
336
+#define OB_WRP_PAGES4TO7               0x00000002U /*!< Write protection of page 4 to 7 */
337
+#define OB_WRP_PAGES8TO11              0x00000004U /*!< Write protection of page 8 to 11 */
338
+#define OB_WRP_PAGES12TO15             0x00000008U /*!< Write protection of page 12 to 15 */
339
+#define OB_WRP_PAGES16TO19             0x00000010U /*!< Write protection of page 16 to 19 */
340
+#define OB_WRP_PAGES20TO23             0x00000020U /*!< Write protection of page 20 to 23 */
341
+#define OB_WRP_PAGES24TO27             0x00000040U /*!< Write protection of page 24 to 27 */
342
+#define OB_WRP_PAGES28TO31             0x00000080U /*!< Write protection of page 28 to 31 */
343
+#endif /* STM32F101x6 || STM32F102x6 || STM32F103x6 */
344
+       /* STM32F100xB || STM32F101xB || STM32F102xB || STM32F103xB */
345
+       
346
+/* STM32 Medium-density devices */
347
+#if  defined(STM32F100xB) || defined(STM32F101xB) || defined(STM32F102xB) || defined(STM32F103xB)
348
+#define OB_WRP_PAGES32TO35             0x00000100U   /*!< Write protection of page 32 to 35 */
349
+#define OB_WRP_PAGES36TO39             0x00000200U   /*!< Write protection of page 36 to 39 */
350
+#define OB_WRP_PAGES40TO43             0x00000400U   /*!< Write protection of page 40 to 43 */
351
+#define OB_WRP_PAGES44TO47             0x00000800U   /*!< Write protection of page 44 to 47 */
352
+#define OB_WRP_PAGES48TO51             0x00001000U   /*!< Write protection of page 48 to 51 */
353
+#define OB_WRP_PAGES52TO55             0x00002000U   /*!< Write protection of page 52 to 55 */
354
+#define OB_WRP_PAGES56TO59             0x00004000U   /*!< Write protection of page 56 to 59 */
355
+#define OB_WRP_PAGES60TO63             0x00008000U   /*!< Write protection of page 60 to 63 */
356
+#define OB_WRP_PAGES64TO67             0x00010000U   /*!< Write protection of page 64 to 67 */
357
+#define OB_WRP_PAGES68TO71             0x00020000U   /*!< Write protection of page 68 to 71 */
358
+#define OB_WRP_PAGES72TO75             0x00040000U   /*!< Write protection of page 72 to 75 */
359
+#define OB_WRP_PAGES76TO79             0x00080000U   /*!< Write protection of page 76 to 79 */
360
+#define OB_WRP_PAGES80TO83             0x00100000U   /*!< Write protection of page 80 to 83 */
361
+#define OB_WRP_PAGES84TO87             0x00200000U   /*!< Write protection of page 84 to 87 */
362
+#define OB_WRP_PAGES88TO91             0x00400000U   /*!< Write protection of page 88 to 91 */
363
+#define OB_WRP_PAGES92TO95             0x00800000U   /*!< Write protection of page 92 to 95 */
364
+#define OB_WRP_PAGES96TO99             0x01000000U   /*!< Write protection of page 96 to 99 */
365
+#define OB_WRP_PAGES100TO103           0x02000000U   /*!< Write protection of page 100 to 103 */
366
+#define OB_WRP_PAGES104TO107           0x04000000U   /*!< Write protection of page 104 to 107 */
367
+#define OB_WRP_PAGES108TO111           0x08000000U   /*!< Write protection of page 108 to 111 */
368
+#define OB_WRP_PAGES112TO115           0x10000000U   /*!< Write protection of page 112 to 115 */
369
+#define OB_WRP_PAGES116TO119           0x20000000U   /*!< Write protection of page 115 to 119 */
370
+#define OB_WRP_PAGES120TO123           0x40000000U   /*!< Write protection of page 120 to 123 */
371
+#define OB_WRP_PAGES124TO127           0x80000000U    /*!< Write protection of page 124 to 127 */
372
+#endif /* STM32F100xB || STM32F101xB || STM32F102xB || STM32F103xB */
373
+
374
+
375
+/* STM32 High-density, XL-density and Connectivity line devices */
376
+#if  defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F103xE) \
377
+  || defined(STM32F101xG) || defined(STM32F103xG) \
378
+  || defined(STM32F105xC) || defined(STM32F107xC)
379
+#define OB_WRP_PAGES0TO1               0x00000001U  /*!< Write protection of page 0 TO 1 */
380
+#define OB_WRP_PAGES2TO3               0x00000002U  /*!< Write protection of page 2 TO 3 */
381
+#define OB_WRP_PAGES4TO5               0x00000004U  /*!< Write protection of page 4 TO 5 */
382
+#define OB_WRP_PAGES6TO7               0x00000008U  /*!< Write protection of page 6 TO 7 */
383
+#define OB_WRP_PAGES8TO9               0x00000010U  /*!< Write protection of page 8 TO 9 */
384
+#define OB_WRP_PAGES10TO11             0x00000020U  /*!< Write protection of page 10 TO 11 */
385
+#define OB_WRP_PAGES12TO13             0x00000040U  /*!< Write protection of page 12 TO 13 */
386
+#define OB_WRP_PAGES14TO15             0x00000080U  /*!< Write protection of page 14 TO 15 */
387
+#define OB_WRP_PAGES16TO17             0x00000100U  /*!< Write protection of page 16 TO 17 */
388
+#define OB_WRP_PAGES18TO19             0x00000200U  /*!< Write protection of page 18 TO 19 */
389
+#define OB_WRP_PAGES20TO21             0x00000400U  /*!< Write protection of page 20 TO 21 */
390
+#define OB_WRP_PAGES22TO23             0x00000800U  /*!< Write protection of page 22 TO 23 */
391
+#define OB_WRP_PAGES24TO25             0x00001000U  /*!< Write protection of page 24 TO 25 */
392
+#define OB_WRP_PAGES26TO27             0x00002000U  /*!< Write protection of page 26 TO 27 */
393
+#define OB_WRP_PAGES28TO29             0x00004000U  /*!< Write protection of page 28 TO 29 */
394
+#define OB_WRP_PAGES30TO31             0x00008000U  /*!< Write protection of page 30 TO 31 */
395
+#define OB_WRP_PAGES32TO33             0x00010000U  /*!< Write protection of page 32 TO 33 */
396
+#define OB_WRP_PAGES34TO35             0x00020000U  /*!< Write protection of page 34 TO 35 */
397
+#define OB_WRP_PAGES36TO37             0x00040000U  /*!< Write protection of page 36 TO 37 */
398
+#define OB_WRP_PAGES38TO39             0x00080000U  /*!< Write protection of page 38 TO 39 */
399
+#define OB_WRP_PAGES40TO41             0x00100000U  /*!< Write protection of page 40 TO 41 */
400
+#define OB_WRP_PAGES42TO43             0x00200000U  /*!< Write protection of page 42 TO 43 */
401
+#define OB_WRP_PAGES44TO45             0x00400000U  /*!< Write protection of page 44 TO 45 */
402
+#define OB_WRP_PAGES46TO47             0x00800000U  /*!< Write protection of page 46 TO 47 */
403
+#define OB_WRP_PAGES48TO49             0x01000000U  /*!< Write protection of page 48 TO 49 */
404
+#define OB_WRP_PAGES50TO51             0x02000000U  /*!< Write protection of page 50 TO 51 */
405
+#define OB_WRP_PAGES52TO53             0x04000000U  /*!< Write protection of page 52 TO 53 */
406
+#define OB_WRP_PAGES54TO55             0x08000000U  /*!< Write protection of page 54 TO 55 */
407
+#define OB_WRP_PAGES56TO57             0x10000000U  /*!< Write protection of page 56 TO 57 */
408
+#define OB_WRP_PAGES58TO59             0x20000000U  /*!< Write protection of page 58 TO 59 */
409
+#define OB_WRP_PAGES60TO61             0x40000000U  /*!< Write protection of page 60 TO 61 */
410
+#define OB_WRP_PAGES62TO127            0x80000000U   /*!< Write protection of page 62 TO 127 */
411
+#define OB_WRP_PAGES62TO255            0x80000000U   /*!< Write protection of page 62 TO 255 */
412
+#define OB_WRP_PAGES62TO511            0x80000000U   /*!< Write protection of page 62 TO 511 */
413
+#endif /* STM32F100xB || STM32F101xB || STM32F102xB || STM32F103xB */
414
+       /* STM32F101xG || STM32F103xG */ 
415
+       /* STM32F105xC || STM32F107xC */
416
+
417
+#define OB_WRP_ALLPAGES                0xFFFFFFFFU  /*!< Write protection of all Pages */
418
+ 
419
+/* Low Density */
420
+#if  defined(STM32F101x6) || defined(STM32F102x6) || defined(STM32F103x6)
421
+#define OB_WRP_PAGES0TO31MASK          0x000000FFU 
422
+#endif /* STM32F101x6 || STM32F102x6 || STM32F103x6 */
423
+
424
+/* Medium Density */
425
+#if  defined(STM32F100xB) || defined(STM32F101xB) || defined(STM32F102xB) || defined(STM32F103xB)
426
+#define OB_WRP_PAGES0TO31MASK          0x000000FFU
427
+#define OB_WRP_PAGES32TO63MASK         0x0000FF00U
428
+#define OB_WRP_PAGES64TO95MASK         0x00FF0000U
429
+#define OB_WRP_PAGES96TO127MASK        0xFF000000U
430
+#endif /* STM32F100xB || STM32F101xB || STM32F102xB || STM32F103xB*/
431
+       
432
+/* High Density */
433
+#if  defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F103xE)  
434
+#define OB_WRP_PAGES0TO15MASK          0x000000FFU
435
+#define OB_WRP_PAGES16TO31MASK         0x0000FF00U
436
+#define OB_WRP_PAGES32TO47MASK         0x00FF0000U
437
+#define OB_WRP_PAGES48TO255MASK        0xFF000000U
438
+#endif /* STM32F100xE || STM32F101xE || STM32F103xE */
439
+
440
+/* XL Density */
441
+#if  defined(STM32F101xG) || defined(STM32F103xG) 
442
+#define OB_WRP_PAGES0TO15MASK          0x000000FFU
443
+#define OB_WRP_PAGES16TO31MASK         0x0000FF00U
444
+#define OB_WRP_PAGES32TO47MASK         0x00FF0000U
445
+#define OB_WRP_PAGES48TO511MASK        0xFF000000U
446
+#endif /* STM32F101xG || STM32F103xG */
447
+      
448
+/* Connectivity line devices */
449
+#if defined(STM32F105xC) || defined(STM32F107xC)
450
+#define OB_WRP_PAGES0TO15MASK          0x000000FFU
451
+#define OB_WRP_PAGES16TO31MASK         0x0000FF00U
452
+#define OB_WRP_PAGES32TO47MASK         0x00FF0000U
453
+#define OB_WRP_PAGES48TO127MASK        0xFF000000U
454
+#endif /* STM32F105xC || STM32F107xC */
455
+
456
+/**
457
+  * @}
458
+  */
459
+
460
+/** @defgroup FLASHEx_OB_Read_Protection Option Byte Read Protection
461
+  * @{
462
+  */
463
+#define OB_RDP_LEVEL_0            ((uint8_t)0xA5)
464
+#define OB_RDP_LEVEL_1            ((uint8_t)0x00)
465
+/**
466
+  * @}
467
+  */
468
+  
469
+/** @defgroup FLASHEx_OB_IWatchdog Option Byte IWatchdog
470
+  * @{
471
+  */ 
472
+#define OB_IWDG_SW                ((uint16_t)0x0001)  /*!< Software IWDG selected */
473
+#define OB_IWDG_HW                ((uint16_t)0x0000)  /*!< Hardware IWDG selected */
474
+/**
475
+  * @}
476
+  */
477
+
478
+/** @defgroup FLASHEx_OB_nRST_STOP Option Byte nRST STOP
479
+  * @{
480
+  */ 
481
+#define OB_STOP_NO_RST            ((uint16_t)0x0002) /*!< No reset generated when entering in STOP */
482
+#define OB_STOP_RST               ((uint16_t)0x0000) /*!< Reset generated when entering in STOP */
483
+/**
484
+  * @}
485
+  */ 
486
+
487
+/** @defgroup FLASHEx_OB_nRST_STDBY Option Byte nRST STDBY
488
+  * @{
489
+  */ 
490
+#define OB_STDBY_NO_RST           ((uint16_t)0x0004) /*!< No reset generated when entering in STANDBY */
491
+#define OB_STDBY_RST              ((uint16_t)0x0000) /*!< Reset generated when entering in STANDBY */
492
+/**
493
+  * @}
494
+  */
495
+
496
+#if defined(FLASH_BANK2_END)
497
+/** @defgroup FLASHEx_OB_BOOT1 Option Byte BOOT1
498
+  * @{
499
+  */
500
+#define OB_BOOT1_RESET            ((uint16_t)0x0000) /*!< BOOT1 Reset */
501
+#define OB_BOOT1_SET              ((uint16_t)0x0008) /*!< BOOT1 Set */
502
+/**
503
+  * @}
504
+  */
505
+#endif /* FLASH_BANK2_END */
506
+
507
+/** @defgroup FLASHEx_OB_Data_Address  Option Byte Data Address
508
+  * @{
509
+  */
510
+#define OB_DATA_ADDRESS_DATA0     0x1FFFF804U
511
+#define OB_DATA_ADDRESS_DATA1     0x1FFFF806U
512
+/**
513
+  * @}
514
+  */
515
+
516
+/**
517
+  * @}
518
+  */
519
+
520
+/** @addtogroup FLASHEx_Constants
521
+  * @{
522
+  */ 
523
+
524
+/** @defgroup FLASH_Flag_definition Flag definition
525
+  * @brief Flag definition
526
+  * @{
527
+  */
528
+#if defined(FLASH_BANK2_END)
529
+ #define FLASH_FLAG_BSY             FLASH_FLAG_BSY_BANK1       /*!< FLASH Bank1 Busy flag                   */ 
530
+ #define FLASH_FLAG_PGERR           FLASH_FLAG_PGERR_BANK1     /*!< FLASH Bank1 Programming error flag      */
531
+ #define FLASH_FLAG_WRPERR          FLASH_FLAG_WRPERR_BANK1    /*!< FLASH Bank1 Write protected error flag  */
532
+ #define FLASH_FLAG_EOP             FLASH_FLAG_EOP_BANK1       /*!< FLASH Bank1 End of Operation flag       */
533
+
534
+ #define FLASH_FLAG_BSY_BANK1       FLASH_SR_BSY               /*!< FLASH Bank1 Busy flag                   */ 
535
+ #define FLASH_FLAG_PGERR_BANK1     FLASH_SR_PGERR             /*!< FLASH Bank1 Programming error flag      */
536
+ #define FLASH_FLAG_WRPERR_BANK1    FLASH_SR_WRPRTERR          /*!< FLASH Bank1 Write protected error flag  */
537
+ #define FLASH_FLAG_EOP_BANK1       FLASH_SR_EOP               /*!< FLASH Bank1 End of Operation flag       */
538
+       
539
+ #define FLASH_FLAG_BSY_BANK2       (FLASH_SR2_BSY << 16U)      /*!< FLASH Bank2 Busy flag                   */ 
540
+ #define FLASH_FLAG_PGERR_BANK2     (FLASH_SR2_PGERR << 16U)    /*!< FLASH Bank2 Programming error flag      */
541
+ #define FLASH_FLAG_WRPERR_BANK2    (FLASH_SR2_WRPRTERR << 16U) /*!< FLASH Bank2 Write protected error flag  */
542
+ #define FLASH_FLAG_EOP_BANK2       (FLASH_SR2_EOP << 16U)      /*!< FLASH Bank2 End of Operation flag       */
543
+
544
+#else  
545
+
546
+ #define FLASH_FLAG_BSY             FLASH_SR_BSY              /*!< FLASH Busy flag                          */ 
547
+ #define FLASH_FLAG_PGERR           FLASH_SR_PGERR            /*!< FLASH Programming error flag             */
548
+ #define FLASH_FLAG_WRPERR          FLASH_SR_WRPRTERR         /*!< FLASH Write protected error flag         */
549
+ #define FLASH_FLAG_EOP             FLASH_SR_EOP              /*!< FLASH End of Operation flag              */
550
+
551
+#endif
552
+ #define FLASH_FLAG_OPTVERR         ((OBR_REG_INDEX << 8U | FLASH_OBR_OPTERR)) /*!< Option Byte Error        */
553
+/**
554
+  * @}
555
+  */
556
+  
557
+/** @defgroup FLASH_Interrupt_definition Interrupt definition
558
+  * @brief FLASH Interrupt definition
559
+  * @{
560
+  */
561
+#if defined(FLASH_BANK2_END)
562
+ #define FLASH_IT_EOP               FLASH_IT_EOP_BANK1        /*!< End of FLASH Operation Interrupt source Bank1 */
563
+ #define FLASH_IT_ERR               FLASH_IT_ERR_BANK1        /*!< Error Interrupt source Bank1                  */
564
+
565
+ #define FLASH_IT_EOP_BANK1         FLASH_CR_EOPIE            /*!< End of FLASH Operation Interrupt source Bank1 */
566
+ #define FLASH_IT_ERR_BANK1         FLASH_CR_ERRIE            /*!< Error Interrupt source Bank1                  */
567
+
568
+ #define FLASH_IT_EOP_BANK2         (FLASH_CR2_EOPIE << 16U)   /*!< End of FLASH Operation Interrupt source Bank2 */
569
+ #define FLASH_IT_ERR_BANK2         (FLASH_CR2_ERRIE << 16U)   /*!< Error Interrupt source Bank2                  */
570
+
571
+#else
572
+
573
+ #define FLASH_IT_EOP               FLASH_CR_EOPIE          /*!< End of FLASH Operation Interrupt source */
574
+ #define FLASH_IT_ERR               FLASH_CR_ERRIE          /*!< Error Interrupt source                  */
575
+
576
+#endif
577
+/**
578
+  * @}
579
+  */  
580
+
581
+/**
582
+  * @}
583
+  */
584
+  
585
+
586
+/**
587
+  * @}
588
+  */
589
+
590
+/* Exported macro ------------------------------------------------------------*/
591
+/** @defgroup FLASHEx_Exported_Macros FLASHEx Exported Macros
592
+  * @{
593
+  */
594
+
595
+/** @defgroup FLASH_Interrupt Interrupt
596
+ *  @brief macros to handle FLASH interrupts
597
+ * @{
598
+ */ 
599
+
600
+#if defined(FLASH_BANK2_END)
601
+/**
602
+  * @brief  Enable the specified FLASH interrupt.
603
+  * @param  __INTERRUPT__  FLASH interrupt 
604
+  *     This parameter can be any combination of the following values:
605
+  *     @arg @ref FLASH_IT_EOP_BANK1 End of FLASH Operation Interrupt on bank1
606
+  *     @arg @ref FLASH_IT_ERR_BANK1 Error Interrupt on bank1
607
+  *     @arg @ref FLASH_IT_EOP_BANK2 End of FLASH Operation Interrupt on bank2
608
+  *     @arg @ref FLASH_IT_ERR_BANK2 Error Interrupt on bank2
609
+  * @retval none
610
+  */ 
611
+#define __HAL_FLASH_ENABLE_IT(__INTERRUPT__)  do { \
612
+                          /* Enable Bank1 IT */ \
613
+                          SET_BIT(FLASH->CR, ((__INTERRUPT__) & 0x0000FFFFU)); \
614
+                          /* Enable Bank2 IT */ \
615
+                          SET_BIT(FLASH->CR2, ((__INTERRUPT__) >> 16U)); \
616
+                    } while(0U)
617
+
618
+/**
619
+  * @brief  Disable the specified FLASH interrupt.
620
+  * @param  __INTERRUPT__  FLASH interrupt 
621
+  *     This parameter can be any combination of the following values:
622
+  *     @arg @ref FLASH_IT_EOP_BANK1 End of FLASH Operation Interrupt on bank1
623
+  *     @arg @ref FLASH_IT_ERR_BANK1 Error Interrupt on bank1
624
+  *     @arg @ref FLASH_IT_EOP_BANK2 End of FLASH Operation Interrupt on bank2
625
+  *     @arg @ref FLASH_IT_ERR_BANK2 Error Interrupt on bank2
626
+  * @retval none
627
+  */ 
628
+#define __HAL_FLASH_DISABLE_IT(__INTERRUPT__)  do { \
629
+                          /* Disable Bank1 IT */ \
630
+                          CLEAR_BIT(FLASH->CR, ((__INTERRUPT__) & 0x0000FFFFU)); \
631
+                          /* Disable Bank2 IT */ \
632
+                          CLEAR_BIT(FLASH->CR2, ((__INTERRUPT__) >> 16U)); \
633
+                    } while(0U)
634
+
635
+/**
636
+  * @brief  Get the specified FLASH flag status. 
637
+  * @param  __FLAG__ specifies the FLASH flag to check.
638
+  *          This parameter can be one of the following values:
639
+  *            @arg @ref FLASH_FLAG_EOP_BANK1    FLASH End of Operation flag on bank1
640
+  *            @arg @ref FLASH_FLAG_WRPERR_BANK1 FLASH Write protected error flag on bank1
641
+  *            @arg @ref FLASH_FLAG_PGERR_BANK1  FLASH Programming error flag on bank1
642
+  *            @arg @ref FLASH_FLAG_BSY_BANK1    FLASH Busy flag on bank1
643
+  *            @arg @ref FLASH_FLAG_EOP_BANK2    FLASH End of Operation flag on bank2
644
+  *            @arg @ref FLASH_FLAG_WRPERR_BANK2 FLASH Write protected error flag on bank2
645
+  *            @arg @ref FLASH_FLAG_PGERR_BANK2  FLASH Programming error flag on bank2
646
+  *            @arg @ref FLASH_FLAG_BSY_BANK2    FLASH Busy flag on bank2
647
+  *            @arg @ref FLASH_FLAG_OPTVERR  Loaded OB and its complement do not match
648
+  * @retval The new state of __FLAG__ (SET or RESET).
649
+  */
650
+#define __HAL_FLASH_GET_FLAG(__FLAG__) (((__FLAG__) == FLASH_FLAG_OPTVERR) ? \
651
+                                            (FLASH->OBR & FLASH_OBR_OPTERR) : \
652
+                                        ((((__FLAG__) & SR_FLAG_MASK) != RESET)? \
653
+                                            (FLASH->SR & ((__FLAG__) & SR_FLAG_MASK)) : \
654
+                                            (FLASH->SR2 & ((__FLAG__) >> 16U))))
655
+
656
+/**
657
+  * @brief  Clear the specified FLASH flag.
658
+  * @param  __FLAG__ specifies the FLASH flags to clear.
659
+  *          This parameter can be any combination of the following values:
660
+  *            @arg @ref FLASH_FLAG_EOP_BANK1    FLASH End of Operation flag on bank1
661
+  *            @arg @ref FLASH_FLAG_WRPERR_BANK1 FLASH Write protected error flag on bank1
662
+  *            @arg @ref FLASH_FLAG_PGERR_BANK1  FLASH Programming error flag on bank1
663
+  *            @arg @ref FLASH_FLAG_BSY_BANK1    FLASH Busy flag on bank1
664
+  *            @arg @ref FLASH_FLAG_EOP_BANK2    FLASH End of Operation flag on bank2
665
+  *            @arg @ref FLASH_FLAG_WRPERR_BANK2 FLASH Write protected error flag on bank2
666
+  *            @arg @ref FLASH_FLAG_PGERR_BANK2  FLASH Programming error flag on bank2
667
+  *            @arg @ref FLASH_FLAG_BSY_BANK2    FLASH Busy flag on bank2
668
+  *            @arg @ref FLASH_FLAG_OPTVERR  Loaded OB and its complement do not match
669
+  * @retval none
670
+  */
671
+#define __HAL_FLASH_CLEAR_FLAG(__FLAG__)  do { \
672
+                          /* Clear FLASH_FLAG_OPTVERR flag */ \
673
+                          if ((__FLAG__) == FLASH_FLAG_OPTVERR) \
674
+                          { \
675
+                            CLEAR_BIT(FLASH->OBR, FLASH_OBR_OPTERR); \
676
+                          } \
677
+                          else { \
678
+                          /* Clear Flag in Bank1 */ \
679
+                          if (((__FLAG__) & SR_FLAG_MASK) != RESET) \
680
+                          { \
681
+                            FLASH->SR  = ((__FLAG__) & SR_FLAG_MASK); \
682
+                          } \
683
+                          /* Clear Flag in Bank2 */ \
684
+                          if (((__FLAG__) >> 16U) != RESET) \
685
+                          { \
686
+                            FLASH->SR2 = ((__FLAG__) >> 16U); \
687
+                          } \
688
+                          } \
689
+                    } while(0U)
690
+#else
691
+/**
692
+  * @brief  Enable the specified FLASH interrupt.
693
+  * @param  __INTERRUPT__  FLASH interrupt 
694
+  *         This parameter can be any combination of the following values:
695
+  *     @arg @ref FLASH_IT_EOP End of FLASH Operation Interrupt
696
+  *     @arg @ref FLASH_IT_ERR Error Interrupt    
697
+  * @retval none
698
+  */ 
699
+#define __HAL_FLASH_ENABLE_IT(__INTERRUPT__)  (FLASH->CR |= (__INTERRUPT__))
700
+
701
+/**
702
+  * @brief  Disable the specified FLASH interrupt.
703
+  * @param  __INTERRUPT__  FLASH interrupt 
704
+  *         This parameter can be any combination of the following values:
705
+  *     @arg @ref FLASH_IT_EOP End of FLASH Operation Interrupt
706
+  *     @arg @ref FLASH_IT_ERR Error Interrupt    
707
+  * @retval none
708
+  */ 
709
+#define __HAL_FLASH_DISABLE_IT(__INTERRUPT__)   (FLASH->CR &= ~(__INTERRUPT__))
710
+
711
+/**
712
+  * @brief  Get the specified FLASH flag status. 
713
+  * @param  __FLAG__ specifies the FLASH flag to check.
714
+  *          This parameter can be one of the following values:
715
+  *            @arg @ref FLASH_FLAG_EOP    FLASH End of Operation flag 
716
+  *            @arg @ref FLASH_FLAG_WRPERR FLASH Write protected error flag 
717
+  *            @arg @ref FLASH_FLAG_PGERR  FLASH Programming error flag
718
+  *            @arg @ref FLASH_FLAG_BSY    FLASH Busy flag
719
+  *            @arg @ref FLASH_FLAG_OPTVERR  Loaded OB and its complement do not match
720
+  * @retval The new state of __FLAG__ (SET or RESET).
721
+  */
722
+#define __HAL_FLASH_GET_FLAG(__FLAG__)  (((__FLAG__) == FLASH_FLAG_OPTVERR) ? \
723
+                                            (FLASH->OBR & FLASH_OBR_OPTERR) : \
724
+                                            (FLASH->SR & (__FLAG__)))
725
+/**
726
+  * @brief  Clear the specified FLASH flag.
727
+  * @param  __FLAG__ specifies the FLASH flags to clear.
728
+  *          This parameter can be any combination of the following values:
729
+  *            @arg @ref FLASH_FLAG_EOP    FLASH End of Operation flag 
730
+  *            @arg @ref FLASH_FLAG_WRPERR FLASH Write protected error flag 
731
+  *            @arg @ref FLASH_FLAG_PGERR  FLASH Programming error flag 
732
+  *            @arg @ref FLASH_FLAG_OPTVERR  Loaded OB and its complement do not match
733
+  * @retval none
734
+  */
735
+#define __HAL_FLASH_CLEAR_FLAG(__FLAG__)   do { \
736
+                          /* Clear FLASH_FLAG_OPTVERR flag */ \
737
+                          if ((__FLAG__) == FLASH_FLAG_OPTVERR) \
738
+                          { \
739
+                            CLEAR_BIT(FLASH->OBR, FLASH_OBR_OPTERR); \
740
+                          } \
741
+                          else { \
742
+                            /* Clear Flag in Bank1 */ \
743
+                            FLASH->SR  = (__FLAG__); \
744
+                          } \
745
+                    } while(0U)
746
+
747
+#endif
748
+
749
+/**
750
+  * @}
751
+  */
752
+
753
+/**
754
+  * @}
755
+  */
756
+
757
+/* Exported functions --------------------------------------------------------*/
758
+/** @addtogroup FLASHEx_Exported_Functions
759
+  * @{
760
+  */
761
+
762
+/** @addtogroup FLASHEx_Exported_Functions_Group1
763
+  * @{
764
+  */
765
+/* IO operation functions *****************************************************/
766
+HAL_StatusTypeDef  HAL_FLASHEx_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t *PageError);
767
+HAL_StatusTypeDef  HAL_FLASHEx_Erase_IT(FLASH_EraseInitTypeDef *pEraseInit);
768
+
769
+/**
770
+  * @}
771
+  */
772
+
773
+/** @addtogroup FLASHEx_Exported_Functions_Group2
774
+  * @{
775
+  */
776
+/* Peripheral Control functions ***********************************************/
777
+HAL_StatusTypeDef  HAL_FLASHEx_OBErase(void);
778
+HAL_StatusTypeDef  HAL_FLASHEx_OBProgram(FLASH_OBProgramInitTypeDef *pOBInit);
779
+void               HAL_FLASHEx_OBGetConfig(FLASH_OBProgramInitTypeDef *pOBInit);
780
+uint32_t           HAL_FLASHEx_OBGetUserData(uint32_t DATAAdress);
781
+/**
782
+  * @}
783
+  */
784
+
785
+/**
786
+  * @}
787
+  */
788
+
789
+/**
790
+  * @}
791
+  */
792
+
793
+/**
794
+  * @}
795
+  */
796
+#ifdef __cplusplus
797
+}
798
+#endif
799
+
800
+#endif /* __STM32F1xx_HAL_FLASH_EX_H */
801
+
802
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 324 - 0
Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio.h

@@ -0,0 +1,324 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx_hal_gpio.h
4
+  * @author  MCD Application Team
5
+  * @brief   Header file of GPIO HAL module.
6
+  ******************************************************************************
7
+  * @attention
8
+  *
9
+  * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
10
+  *
11
+  * Redistribution and use in source and binary forms, with or without modification,
12
+  * are permitted provided that the following conditions are met:
13
+  *   1. Redistributions of source code must retain the above copyright notice,
14
+  *      this list of conditions and the following disclaimer.
15
+  *   2. Redistributions in binary form must reproduce the above copyright notice,
16
+  *      this list of conditions and the following disclaimer in the documentation
17
+  *      and/or other materials provided with the distribution.
18
+  *   3. Neither the name of STMicroelectronics nor the names of its contributors
19
+  *      may be used to endorse or promote products derived from this software
20
+  *      without specific prior written permission.
21
+  *
22
+  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
+  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25
+  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28
+  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29
+  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30
+  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
+  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
+  *
33
+  ******************************************************************************
34
+  */
35
+
36
+/* Define to prevent recursive inclusion -------------------------------------*/
37
+#ifndef __STM32F1xx_HAL_GPIO_H
38
+#define __STM32F1xx_HAL_GPIO_H
39
+
40
+#ifdef __cplusplus
41
+extern "C" {
42
+#endif
43
+
44
+/* Includes ------------------------------------------------------------------*/
45
+#include "stm32f1xx_hal_def.h"
46
+
47
+/** @addtogroup STM32F1xx_HAL_Driver
48
+  * @{
49
+  */
50
+
51
+/** @addtogroup GPIO
52
+  * @{
53
+  */
54
+
55
+/* Exported types ------------------------------------------------------------*/
56
+/** @defgroup GPIO_Exported_Types GPIO Exported Types
57
+  * @{
58
+  */
59
+
60
+/**
61
+  * @brief GPIO Init structure definition
62
+  */
63
+typedef struct
64
+{
65
+  uint32_t Pin;       /*!< Specifies the GPIO pins to be configured.
66
+                           This parameter can be any value of @ref GPIO_pins_define */
67
+
68
+  uint32_t Mode;      /*!< Specifies the operating mode for the selected pins.
69
+                           This parameter can be a value of @ref GPIO_mode_define */
70
+
71
+  uint32_t Pull;      /*!< Specifies the Pull-up or Pull-Down activation for the selected pins.
72
+                           This parameter can be a value of @ref GPIO_pull_define */
73
+
74
+  uint32_t Speed;     /*!< Specifies the speed for the selected pins.
75
+                           This parameter can be a value of @ref GPIO_speed_define */
76
+} GPIO_InitTypeDef;
77
+
78
+/**
79
+  * @brief  GPIO Bit SET and Bit RESET enumeration
80
+  */
81
+typedef enum
82
+{
83
+  GPIO_PIN_RESET = 0U,
84
+  GPIO_PIN_SET
85
+} GPIO_PinState;
86
+/**
87
+  * @}
88
+  */
89
+
90
+/* Exported constants --------------------------------------------------------*/
91
+
92
+/** @defgroup GPIO_Exported_Constants GPIO Exported Constants
93
+  * @{
94
+  */
95
+
96
+/** @defgroup GPIO_pins_define GPIO pins define
97
+  * @{
98
+  */
99
+#define GPIO_PIN_0                 ((uint16_t)0x0001)  /* Pin 0 selected    */
100
+#define GPIO_PIN_1                 ((uint16_t)0x0002)  /* Pin 1 selected    */
101
+#define GPIO_PIN_2                 ((uint16_t)0x0004)  /* Pin 2 selected    */
102
+#define GPIO_PIN_3                 ((uint16_t)0x0008)  /* Pin 3 selected    */
103
+#define GPIO_PIN_4                 ((uint16_t)0x0010)  /* Pin 4 selected    */
104
+#define GPIO_PIN_5                 ((uint16_t)0x0020)  /* Pin 5 selected    */
105
+#define GPIO_PIN_6                 ((uint16_t)0x0040)  /* Pin 6 selected    */
106
+#define GPIO_PIN_7                 ((uint16_t)0x0080)  /* Pin 7 selected    */
107
+#define GPIO_PIN_8                 ((uint16_t)0x0100)  /* Pin 8 selected    */
108
+#define GPIO_PIN_9                 ((uint16_t)0x0200)  /* Pin 9 selected    */
109
+#define GPIO_PIN_10                ((uint16_t)0x0400)  /* Pin 10 selected   */
110
+#define GPIO_PIN_11                ((uint16_t)0x0800)  /* Pin 11 selected   */
111
+#define GPIO_PIN_12                ((uint16_t)0x1000)  /* Pin 12 selected   */
112
+#define GPIO_PIN_13                ((uint16_t)0x2000)  /* Pin 13 selected   */
113
+#define GPIO_PIN_14                ((uint16_t)0x4000)  /* Pin 14 selected   */
114
+#define GPIO_PIN_15                ((uint16_t)0x8000)  /* Pin 15 selected   */
115
+#define GPIO_PIN_All               ((uint16_t)0xFFFF)  /* All pins selected */
116
+
117
+#define GPIO_PIN_MASK              0x0000FFFFU /* PIN mask for assert test */
118
+/**
119
+  * @}
120
+  */
121
+
122
+/** @defgroup GPIO_mode_define GPIO mode define
123
+  * @brief GPIO Configuration Mode
124
+  *        Elements values convention: 0xX0yz00YZ
125
+  *           - X  : GPIO mode or EXTI Mode
126
+  *           - y  : External IT or Event trigger detection
127
+  *           - z  : IO configuration on External IT or Event
128
+  *           - Y  : Output type (Push Pull or Open Drain)
129
+  *           - Z  : IO Direction mode (Input, Output, Alternate or Analog)
130
+  * @{
131
+  */
132
+#define  GPIO_MODE_INPUT                        0x00000000U   /*!< Input Floating Mode                   */
133
+#define  GPIO_MODE_OUTPUT_PP                    0x00000001U   /*!< Output Push Pull Mode                 */
134
+#define  GPIO_MODE_OUTPUT_OD                    0x00000011U   /*!< Output Open Drain Mode                */
135
+#define  GPIO_MODE_AF_PP                        0x00000002U   /*!< Alternate Function Push Pull Mode     */
136
+#define  GPIO_MODE_AF_OD                        0x00000012U   /*!< Alternate Function Open Drain Mode    */
137
+#define  GPIO_MODE_AF_INPUT                     GPIO_MODE_INPUT          /*!< Alternate Function Input Mode         */
138
+
139
+#define  GPIO_MODE_ANALOG                       0x00000003U   /*!< Analog Mode  */
140
+
141
+#define  GPIO_MODE_IT_RISING                    0x10110000U   /*!< External Interrupt Mode with Rising edge trigger detection          */
142
+#define  GPIO_MODE_IT_FALLING                   0x10210000U   /*!< External Interrupt Mode with Falling edge trigger detection         */
143
+#define  GPIO_MODE_IT_RISING_FALLING            0x10310000U   /*!< External Interrupt Mode with Rising/Falling edge trigger detection  */
144
+
145
+#define  GPIO_MODE_EVT_RISING                   0x10120000U   /*!< External Event Mode with Rising edge trigger detection               */
146
+#define  GPIO_MODE_EVT_FALLING                  0x10220000U   /*!< External Event Mode with Falling edge trigger detection              */
147
+#define  GPIO_MODE_EVT_RISING_FALLING           0x10320000U   /*!< External Event Mode with Rising/Falling edge trigger detection       */
148
+
149
+/**
150
+  * @}
151
+  */
152
+
153
+/** @defgroup GPIO_speed_define  GPIO speed define
154
+  * @brief GPIO Output Maximum frequency
155
+  * @{
156
+  */
157
+#define  GPIO_SPEED_FREQ_LOW              (GPIO_CRL_MODE0_1) /*!< Low speed */
158
+#define  GPIO_SPEED_FREQ_MEDIUM           (GPIO_CRL_MODE0_0) /*!< Medium speed */
159
+#define  GPIO_SPEED_FREQ_HIGH             (GPIO_CRL_MODE0)   /*!< High speed */
160
+
161
+/**
162
+  * @}
163
+  */
164
+
165
+/** @defgroup GPIO_pull_define GPIO pull define
166
+  * @brief GPIO Pull-Up or Pull-Down Activation
167
+  * @{
168
+  */
169
+#define  GPIO_NOPULL        0x00000000U   /*!< No Pull-up or Pull-down activation  */
170
+#define  GPIO_PULLUP        0x00000001U   /*!< Pull-up activation                  */
171
+#define  GPIO_PULLDOWN      0x00000002U   /*!< Pull-down activation                */
172
+/**
173
+  * @}
174
+  */
175
+
176
+/**
177
+  * @}
178
+  */
179
+
180
+/* Exported macro ------------------------------------------------------------*/
181
+/** @defgroup GPIO_Exported_Macros GPIO Exported Macros
182
+  * @{
183
+  */
184
+
185
+/**
186
+  * @brief  Checks whether the specified EXTI line flag is set or not.
187
+  * @param  __EXTI_LINE__: specifies the EXTI line flag to check.
188
+  *         This parameter can be GPIO_PIN_x where x can be(0..15)
189
+  * @retval The new state of __EXTI_LINE__ (SET or RESET).
190
+  */
191
+#define __HAL_GPIO_EXTI_GET_FLAG(__EXTI_LINE__) (EXTI->PR & (__EXTI_LINE__))
192
+
193
+/**
194
+  * @brief  Clears the EXTI's line pending flags.
195
+  * @param  __EXTI_LINE__: specifies the EXTI lines flags to clear.
196
+  *         This parameter can be any combination of GPIO_PIN_x where x can be (0..15)
197
+  * @retval None
198
+  */
199
+#define __HAL_GPIO_EXTI_CLEAR_FLAG(__EXTI_LINE__) (EXTI->PR = (__EXTI_LINE__))
200
+
201
+/**
202
+  * @brief  Checks whether the specified EXTI line is asserted or not.
203
+  * @param  __EXTI_LINE__: specifies the EXTI line to check.
204
+  *          This parameter can be GPIO_PIN_x where x can be(0..15)
205
+  * @retval The new state of __EXTI_LINE__ (SET or RESET).
206
+  */
207
+#define __HAL_GPIO_EXTI_GET_IT(__EXTI_LINE__) (EXTI->PR & (__EXTI_LINE__))
208
+
209
+/**
210
+  * @brief  Clears the EXTI's line pending bits.
211
+  * @param  __EXTI_LINE__: specifies the EXTI lines to clear.
212
+  *          This parameter can be any combination of GPIO_PIN_x where x can be (0..15)
213
+  * @retval None
214
+  */
215
+#define __HAL_GPIO_EXTI_CLEAR_IT(__EXTI_LINE__) (EXTI->PR = (__EXTI_LINE__))
216
+
217
+/**
218
+  * @brief  Generates a Software interrupt on selected EXTI line.
219
+  * @param  __EXTI_LINE__: specifies the EXTI line to check.
220
+  *          This parameter can be GPIO_PIN_x where x can be(0..15)
221
+  * @retval None
222
+  */
223
+#define __HAL_GPIO_EXTI_GENERATE_SWIT(__EXTI_LINE__) (EXTI->SWIER |= (__EXTI_LINE__))
224
+/**
225
+  * @}
226
+  */
227
+
228
+/* Include GPIO HAL Extension module */
229
+#include "stm32f1xx_hal_gpio_ex.h"
230
+
231
+/* Exported functions --------------------------------------------------------*/
232
+/** @addtogroup GPIO_Exported_Functions
233
+  * @{
234
+  */
235
+
236
+/** @addtogroup GPIO_Exported_Functions_Group1
237
+  * @{
238
+  */
239
+/* Initialization and de-initialization functions *****************************/
240
+void  HAL_GPIO_Init(GPIO_TypeDef  *GPIOx, GPIO_InitTypeDef *GPIO_Init);
241
+void  HAL_GPIO_DeInit(GPIO_TypeDef  *GPIOx, uint32_t GPIO_Pin);
242
+/**
243
+  * @}
244
+  */
245
+
246
+/** @addtogroup GPIO_Exported_Functions_Group2
247
+  * @{
248
+  */
249
+/* IO operation functions *****************************************************/
250
+GPIO_PinState HAL_GPIO_ReadPin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin);
251
+void HAL_GPIO_WritePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState);
252
+void HAL_GPIO_TogglePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin);
253
+HAL_StatusTypeDef HAL_GPIO_LockPin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin);
254
+void HAL_GPIO_EXTI_IRQHandler(uint16_t GPIO_Pin);
255
+void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin);
256
+
257
+/**
258
+  * @}
259
+  */
260
+
261
+/**
262
+  * @}
263
+  */
264
+/* Private types -------------------------------------------------------------*/
265
+/* Private variables ---------------------------------------------------------*/
266
+/* Private constants ---------------------------------------------------------*/
267
+/** @defgroup GPIO_Private_Constants GPIO Private Constants
268
+  * @{
269
+  */
270
+
271
+/**
272
+  * @}
273
+  */
274
+
275
+/* Private macros ------------------------------------------------------------*/
276
+/** @defgroup GPIO_Private_Macros GPIO Private Macros
277
+  * @{
278
+  */
279
+#define IS_GPIO_PIN_ACTION(ACTION) (((ACTION) == GPIO_PIN_RESET) || ((ACTION) == GPIO_PIN_SET))
280
+#define IS_GPIO_PIN(PIN)           ((((PIN) & GPIO_PIN_MASK ) != 0x00U) && (((PIN) & ~GPIO_PIN_MASK) == 0x00U))
281
+#define IS_GPIO_MODE(MODE) (((MODE) == GPIO_MODE_INPUT)              ||\
282
+                            ((MODE) == GPIO_MODE_OUTPUT_PP)          ||\
283
+                            ((MODE) == GPIO_MODE_OUTPUT_OD)          ||\
284
+                            ((MODE) == GPIO_MODE_AF_PP)              ||\
285
+                            ((MODE) == GPIO_MODE_AF_OD)              ||\
286
+                            ((MODE) == GPIO_MODE_IT_RISING)          ||\
287
+                            ((MODE) == GPIO_MODE_IT_FALLING)         ||\
288
+                            ((MODE) == GPIO_MODE_IT_RISING_FALLING)  ||\
289
+                            ((MODE) == GPIO_MODE_EVT_RISING)         ||\
290
+                            ((MODE) == GPIO_MODE_EVT_FALLING)        ||\
291
+                            ((MODE) == GPIO_MODE_EVT_RISING_FALLING) ||\
292
+                            ((MODE) == GPIO_MODE_ANALOG))
293
+#define IS_GPIO_SPEED(SPEED) (((SPEED) == GPIO_SPEED_FREQ_LOW) || \
294
+                              ((SPEED) == GPIO_SPEED_FREQ_MEDIUM) || ((SPEED) == GPIO_SPEED_FREQ_HIGH))
295
+#define IS_GPIO_PULL(PULL) (((PULL) == GPIO_NOPULL) || ((PULL) == GPIO_PULLUP) || \
296
+                            ((PULL) == GPIO_PULLDOWN))
297
+/**
298
+  * @}
299
+  */
300
+
301
+/* Private functions ---------------------------------------------------------*/
302
+/** @defgroup GPIO_Private_Functions GPIO Private Functions
303
+  * @{
304
+  */
305
+
306
+/**
307
+  * @}
308
+  */
309
+
310
+/**
311
+  * @}
312
+  */
313
+
314
+/**
315
+  * @}
316
+  */
317
+
318
+#ifdef __cplusplus
319
+}
320
+#endif
321
+
322
+#endif /* __STM32F1xx_HAL_GPIO_H */
323
+
324
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 910 - 0
Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio_ex.h

@@ -0,0 +1,910 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx_hal_gpio_ex.h
4
+  * @author  MCD Application Team
5
+  * @brief   Header file of GPIO HAL Extension module.
6
+  ******************************************************************************
7
+  * @attention
8
+  *
9
+  * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
10
+  *
11
+  * Redistribution and use in source and binary forms, with or without modification,
12
+  * are permitted provided that the following conditions are met:
13
+  *   1. Redistributions of source code must retain the above copyright notice,
14
+  *      this list of conditions and the following disclaimer.
15
+  *   2. Redistributions in binary form must reproduce the above copyright notice,
16
+  *      this list of conditions and the following disclaimer in the documentation
17
+  *      and/or other materials provided with the distribution.
18
+  *   3. Neither the name of STMicroelectronics nor the names of its contributors
19
+  *      may be used to endorse or promote products derived from this software
20
+  *      without specific prior written permission.
21
+  *
22
+  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
+  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25
+  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28
+  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29
+  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30
+  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
+  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
+  *
33
+  ******************************************************************************
34
+  */
35
+
36
+/* Define to prevent recursive inclusion -------------------------------------*/
37
+#ifndef __STM32F1xx_HAL_GPIO_EX_H
38
+#define __STM32F1xx_HAL_GPIO_EX_H
39
+
40
+#ifdef __cplusplus
41
+extern "C" {
42
+#endif
43
+
44
+/* Includes ------------------------------------------------------------------*/
45
+#include "stm32f1xx_hal_def.h"
46
+
47
+/** @addtogroup STM32F1xx_HAL_Driver
48
+  * @{
49
+  */
50
+
51
+/** @defgroup GPIOEx GPIOEx
52
+  * @{
53
+  */
54
+/* Exported types ------------------------------------------------------------*/
55
+/* Exported constants --------------------------------------------------------*/
56
+
57
+/** @defgroup GPIOEx_Exported_Constants GPIOEx Exported Constants
58
+  * @{
59
+  */
60
+
61
+/** @defgroup GPIOEx_EVENTOUT EVENTOUT Cortex Configuration
62
+  * @brief This section propose definition to use the Cortex EVENTOUT signal.
63
+  * @{
64
+  */
65
+
66
+/** @defgroup GPIOEx_EVENTOUT_PIN EVENTOUT Pin
67
+  * @{
68
+  */
69
+
70
+#define AFIO_EVENTOUT_PIN_0  AFIO_EVCR_PIN_PX0 /*!< EVENTOUT on pin 0 */
71
+#define AFIO_EVENTOUT_PIN_1  AFIO_EVCR_PIN_PX1 /*!< EVENTOUT on pin 1 */
72
+#define AFIO_EVENTOUT_PIN_2  AFIO_EVCR_PIN_PX2 /*!< EVENTOUT on pin 2 */
73
+#define AFIO_EVENTOUT_PIN_3  AFIO_EVCR_PIN_PX3 /*!< EVENTOUT on pin 3 */
74
+#define AFIO_EVENTOUT_PIN_4  AFIO_EVCR_PIN_PX4 /*!< EVENTOUT on pin 4 */
75
+#define AFIO_EVENTOUT_PIN_5  AFIO_EVCR_PIN_PX5 /*!< EVENTOUT on pin 5 */
76
+#define AFIO_EVENTOUT_PIN_6  AFIO_EVCR_PIN_PX6 /*!< EVENTOUT on pin 6 */
77
+#define AFIO_EVENTOUT_PIN_7  AFIO_EVCR_PIN_PX7 /*!< EVENTOUT on pin 7 */
78
+#define AFIO_EVENTOUT_PIN_8  AFIO_EVCR_PIN_PX8 /*!< EVENTOUT on pin 8 */
79
+#define AFIO_EVENTOUT_PIN_9  AFIO_EVCR_PIN_PX9 /*!< EVENTOUT on pin 9 */
80
+#define AFIO_EVENTOUT_PIN_10 AFIO_EVCR_PIN_PX10 /*!< EVENTOUT on pin 10 */
81
+#define AFIO_EVENTOUT_PIN_11 AFIO_EVCR_PIN_PX11 /*!< EVENTOUT on pin 11 */
82
+#define AFIO_EVENTOUT_PIN_12 AFIO_EVCR_PIN_PX12 /*!< EVENTOUT on pin 12 */
83
+#define AFIO_EVENTOUT_PIN_13 AFIO_EVCR_PIN_PX13 /*!< EVENTOUT on pin 13 */
84
+#define AFIO_EVENTOUT_PIN_14 AFIO_EVCR_PIN_PX14 /*!< EVENTOUT on pin 14 */
85
+#define AFIO_EVENTOUT_PIN_15 AFIO_EVCR_PIN_PX15 /*!< EVENTOUT on pin 15 */
86
+
87
+#define IS_AFIO_EVENTOUT_PIN(__PIN__) (((__PIN__) == AFIO_EVENTOUT_PIN_0) || \
88
+                                       ((__PIN__) == AFIO_EVENTOUT_PIN_1) || \
89
+                                       ((__PIN__) == AFIO_EVENTOUT_PIN_2) || \
90
+                                       ((__PIN__) == AFIO_EVENTOUT_PIN_3) || \
91
+                                       ((__PIN__) == AFIO_EVENTOUT_PIN_4) || \
92
+                                       ((__PIN__) == AFIO_EVENTOUT_PIN_5) || \
93
+                                       ((__PIN__) == AFIO_EVENTOUT_PIN_6) || \
94
+                                       ((__PIN__) == AFIO_EVENTOUT_PIN_7) || \
95
+                                       ((__PIN__) == AFIO_EVENTOUT_PIN_8) || \
96
+                                       ((__PIN__) == AFIO_EVENTOUT_PIN_9) || \
97
+                                       ((__PIN__) == AFIO_EVENTOUT_PIN_10) || \
98
+                                       ((__PIN__) == AFIO_EVENTOUT_PIN_11) || \
99
+                                       ((__PIN__) == AFIO_EVENTOUT_PIN_12) || \
100
+                                       ((__PIN__) == AFIO_EVENTOUT_PIN_13) || \
101
+                                       ((__PIN__) == AFIO_EVENTOUT_PIN_14) || \
102
+                                       ((__PIN__) == AFIO_EVENTOUT_PIN_15))
103
+/**
104
+  * @}
105
+  */
106
+
107
+/** @defgroup GPIOEx_EVENTOUT_PORT EVENTOUT Port
108
+  * @{
109
+  */
110
+
111
+#define AFIO_EVENTOUT_PORT_A AFIO_EVCR_PORT_PA /*!< EVENTOUT on port A */
112
+#define AFIO_EVENTOUT_PORT_B AFIO_EVCR_PORT_PB /*!< EVENTOUT on port B */
113
+#define AFIO_EVENTOUT_PORT_C AFIO_EVCR_PORT_PC /*!< EVENTOUT on port C */
114
+#define AFIO_EVENTOUT_PORT_D AFIO_EVCR_PORT_PD /*!< EVENTOUT on port D */
115
+#define AFIO_EVENTOUT_PORT_E AFIO_EVCR_PORT_PE /*!< EVENTOUT on port E */
116
+
117
+#define IS_AFIO_EVENTOUT_PORT(__PORT__) (((__PORT__) == AFIO_EVENTOUT_PORT_A) || \
118
+                                         ((__PORT__) == AFIO_EVENTOUT_PORT_B) || \
119
+                                         ((__PORT__) == AFIO_EVENTOUT_PORT_C) || \
120
+                                         ((__PORT__) == AFIO_EVENTOUT_PORT_D) || \
121
+                                         ((__PORT__) == AFIO_EVENTOUT_PORT_E))
122
+/**
123
+  * @}
124
+  */
125
+
126
+/**
127
+  * @}
128
+  */
129
+
130
+/** @defgroup GPIOEx_AFIO_AF_REMAPPING Alternate Function Remapping
131
+  * @brief This section propose definition to remap the alternate function to some other port/pins.
132
+  * @{
133
+  */
134
+
135
+/**
136
+  * @brief Enable the remapping of SPI1 alternate function NSS, SCK, MISO and MOSI.
137
+  * @note  ENABLE: Remap     (NSS/PA15, SCK/PB3, MISO/PB4, MOSI/PB5)
138
+  * @retval None
139
+  */
140
+#define __HAL_AFIO_REMAP_SPI1_ENABLE()  AFIO_REMAP_ENABLE(AFIO_MAPR_SPI1_REMAP)
141
+
142
+/**
143
+  * @brief Disable the remapping of SPI1 alternate function NSS, SCK, MISO and MOSI.
144
+  * @note  DISABLE: No remap (NSS/PA4,  SCK/PA5, MISO/PA6, MOSI/PA7)
145
+  * @retval None
146
+  */
147
+#define __HAL_AFIO_REMAP_SPI1_DISABLE()  AFIO_REMAP_DISABLE(AFIO_MAPR_SPI1_REMAP)
148
+
149
+/**
150
+  * @brief Enable the remapping of I2C1 alternate function SCL and SDA.
151
+  * @note  ENABLE: Remap     (SCL/PB8, SDA/PB9)
152
+  * @retval None
153
+  */
154
+#define __HAL_AFIO_REMAP_I2C1_ENABLE()  AFIO_REMAP_ENABLE(AFIO_MAPR_I2C1_REMAP)
155
+
156
+/**
157
+  * @brief Disable the remapping of I2C1 alternate function SCL and SDA.
158
+  * @note  DISABLE: No remap (SCL/PB6, SDA/PB7)
159
+  * @retval None
160
+  */
161
+#define __HAL_AFIO_REMAP_I2C1_DISABLE() AFIO_REMAP_DISABLE(AFIO_MAPR_I2C1_REMAP)
162
+
163
+/**
164
+  * @brief Enable the remapping of USART1 alternate function TX and RX.
165
+  * @note  ENABLE: Remap     (TX/PB6, RX/PB7)
166
+  * @retval None
167
+  */
168
+#define __HAL_AFIO_REMAP_USART1_ENABLE()  AFIO_REMAP_ENABLE(AFIO_MAPR_USART1_REMAP)
169
+
170
+/**
171
+  * @brief Disable the remapping of USART1 alternate function TX and RX.
172
+  * @note  DISABLE: No remap (TX/PA9, RX/PA10)
173
+  * @retval None
174
+  */
175
+#define __HAL_AFIO_REMAP_USART1_DISABLE() AFIO_REMAP_DISABLE(AFIO_MAPR_USART1_REMAP)
176
+
177
+/**
178
+  * @brief Enable the remapping of USART2 alternate function CTS, RTS, CK, TX and RX.
179
+  * @note  ENABLE: Remap     (CTS/PD3, RTS/PD4, TX/PD5, RX/PD6, CK/PD7)
180
+  * @retval None
181
+  */
182
+#define __HAL_AFIO_REMAP_USART2_ENABLE()  AFIO_REMAP_ENABLE(AFIO_MAPR_USART2_REMAP)
183
+
184
+/**
185
+  * @brief Disable the remapping of USART2 alternate function CTS, RTS, CK, TX and RX.
186
+  * @note  DISABLE: No remap (CTS/PA0, RTS/PA1, TX/PA2, RX/PA3, CK/PA4)
187
+  * @retval None
188
+  */
189
+#define __HAL_AFIO_REMAP_USART2_DISABLE() AFIO_REMAP_DISABLE(AFIO_MAPR_USART2_REMAP)
190
+
191
+/**
192
+  * @brief Enable the remapping of USART3 alternate function CTS, RTS, CK, TX and RX.
193
+  * @note  ENABLE: Full remap     (TX/PD8,  RX/PD9,  CK/PD10, CTS/PD11, RTS/PD12)
194
+  * @retval None
195
+  */
196
+#define __HAL_AFIO_REMAP_USART3_ENABLE()  AFIO_REMAP_PARTIAL(AFIO_MAPR_USART3_REMAP_FULLREMAP, AFIO_MAPR_USART3_REMAP_FULLREMAP)
197
+
198
+/**
199
+  * @brief Enable the remapping of USART3 alternate function CTS, RTS, CK, TX and RX.
200
+  * @note  PARTIAL: Partial remap (TX/PC10, RX/PC11, CK/PC12, CTS/PB13, RTS/PB14)
201
+  * @retval None
202
+  */
203
+#define __HAL_AFIO_REMAP_USART3_PARTIAL()  AFIO_REMAP_PARTIAL(AFIO_MAPR_USART3_REMAP_PARTIALREMAP, AFIO_MAPR_USART3_REMAP_FULLREMAP)
204
+
205
+/**
206
+  * @brief Disable the remapping of USART3 alternate function CTS, RTS, CK, TX and RX.
207
+  * @note  DISABLE: No remap      (TX/PB10, RX/PB11, CK/PB12, CTS/PB13, RTS/PB14)
208
+  * @retval None
209
+  */
210
+#define __HAL_AFIO_REMAP_USART3_DISABLE()  AFIO_REMAP_PARTIAL(AFIO_MAPR_USART3_REMAP_NOREMAP, AFIO_MAPR_USART3_REMAP_FULLREMAP)
211
+
212
+/**
213
+  * @brief Enable the remapping of TIM1 alternate function channels 1 to 4, 1N to 3N, external trigger (ETR) and Break input (BKIN)
214
+  * @note  ENABLE: Full remap     (ETR/PE7,  CH1/PE9, CH2/PE11, CH3/PE13, CH4/PE14, BKIN/PE15, CH1N/PE8,  CH2N/PE10, CH3N/PE12)
215
+  * @retval None
216
+  */
217
+#define __HAL_AFIO_REMAP_TIM1_ENABLE()  AFIO_REMAP_PARTIAL(AFIO_MAPR_TIM1_REMAP_FULLREMAP, AFIO_MAPR_TIM1_REMAP_FULLREMAP)
218
+
219
+/**
220
+  * @brief Enable the remapping of TIM1 alternate function channels 1 to 4, 1N to 3N, external trigger (ETR) and Break input (BKIN)
221
+  * @note  PARTIAL: Partial remap (ETR/PA12, CH1/PA8, CH2/PA9,  CH3/PA10, CH4/PA11, BKIN/PA6,  CH1N/PA7,  CH2N/PB0,  CH3N/PB1)
222
+  * @retval None
223
+  */
224
+#define __HAL_AFIO_REMAP_TIM1_PARTIAL()  AFIO_REMAP_PARTIAL(AFIO_MAPR_TIM1_REMAP_PARTIALREMAP, AFIO_MAPR_TIM1_REMAP_FULLREMAP)
225
+
226
+/**
227
+  * @brief Disable the remapping of TIM1 alternate function channels 1 to 4, 1N to 3N, external trigger (ETR) and Break input (BKIN)
228
+  * @note  DISABLE: No remap      (ETR/PA12, CH1/PA8, CH2/PA9,  CH3/PA10, CH4/PA11, BKIN/PB12, CH1N/PB13, CH2N/PB14, CH3N/PB15)
229
+  * @retval None
230
+  */
231
+#define __HAL_AFIO_REMAP_TIM1_DISABLE()  AFIO_REMAP_PARTIAL(AFIO_MAPR_TIM1_REMAP_NOREMAP, AFIO_MAPR_TIM1_REMAP_FULLREMAP)
232
+
233
+/**
234
+  * @brief Enable the remapping of TIM2 alternate function channels 1 to 4 and external trigger (ETR)
235
+  * @note  ENABLE: Full remap       (CH1/ETR/PA15, CH2/PB3, CH3/PB10, CH4/PB11)
236
+  * @retval None
237
+  */
238
+#define __HAL_AFIO_REMAP_TIM2_ENABLE()  AFIO_REMAP_PARTIAL(AFIO_MAPR_TIM2_REMAP_FULLREMAP, AFIO_MAPR_TIM2_REMAP_FULLREMAP)
239
+
240
+/**
241
+  * @brief Enable the remapping of TIM2 alternate function channels 1 to 4 and external trigger (ETR)
242
+  * @note  PARTIAL_2: Partial remap (CH1/ETR/PA0,  CH2/PA1, CH3/PB10, CH4/PB11)
243
+  * @retval None
244
+  */
245
+#define __HAL_AFIO_REMAP_TIM2_PARTIAL_2()  AFIO_REMAP_PARTIAL(AFIO_MAPR_TIM2_REMAP_PARTIALREMAP2, AFIO_MAPR_TIM2_REMAP_FULLREMAP)
246
+
247
+/**
248
+  * @brief Enable the remapping of TIM2 alternate function channels 1 to 4 and external trigger (ETR)
249
+  * @note  PARTIAL_1: Partial remap (CH1/ETR/PA15, CH2/PB3, CH3/PA2,  CH4/PA3)
250
+  * @retval None
251
+  */
252
+#define __HAL_AFIO_REMAP_TIM2_PARTIAL_1()  AFIO_REMAP_PARTIAL(AFIO_MAPR_TIM2_REMAP_PARTIALREMAP1, AFIO_MAPR_TIM2_REMAP_FULLREMAP)
253
+
254
+/**
255
+  * @brief Disable the remapping of TIM2 alternate function channels 1 to 4 and external trigger (ETR)
256
+  * @note  DISABLE: No remap        (CH1/ETR/PA0,  CH2/PA1, CH3/PA2,  CH4/PA3)
257
+  * @retval None
258
+  */
259
+#define __HAL_AFIO_REMAP_TIM2_DISABLE()  AFIO_REMAP_PARTIAL(AFIO_MAPR_TIM2_REMAP_NOREMAP, AFIO_MAPR_TIM2_REMAP_FULLREMAP)
260
+
261
+/**
262
+  * @brief Enable the remapping of TIM3 alternate function channels 1 to 4
263
+  * @note  ENABLE: Full remap     (CH1/PC6, CH2/PC7, CH3/PC8, CH4/PC9)
264
+  * @note  TIM3_ETR on PE0 is not re-mapped.
265
+  * @retval None
266
+  */
267
+#define __HAL_AFIO_REMAP_TIM3_ENABLE()  AFIO_REMAP_PARTIAL(AFIO_MAPR_TIM3_REMAP_FULLREMAP, AFIO_MAPR_TIM3_REMAP_FULLREMAP)
268
+
269
+/**
270
+  * @brief Enable the remapping of TIM3 alternate function channels 1 to 4
271
+  * @note  PARTIAL: Partial remap (CH1/PB4, CH2/PB5, CH3/PB0, CH4/PB1)
272
+  * @note  TIM3_ETR on PE0 is not re-mapped.
273
+  * @retval None
274
+  */
275
+#define __HAL_AFIO_REMAP_TIM3_PARTIAL()  AFIO_REMAP_PARTIAL(AFIO_MAPR_TIM3_REMAP_PARTIALREMAP, AFIO_MAPR_TIM3_REMAP_FULLREMAP)
276
+
277
+/**
278
+  * @brief Disable the remapping of TIM3 alternate function channels 1 to 4
279
+  * @note  DISABLE: No remap      (CH1/PA6, CH2/PA7, CH3/PB0, CH4/PB1)
280
+  * @note  TIM3_ETR on PE0 is not re-mapped.
281
+  * @retval None
282
+  */
283
+#define __HAL_AFIO_REMAP_TIM3_DISABLE()  AFIO_REMAP_PARTIAL(AFIO_MAPR_TIM3_REMAP_NOREMAP, AFIO_MAPR_TIM3_REMAP_FULLREMAP)
284
+
285
+/**
286
+  * @brief Enable the remapping of TIM4 alternate function channels 1 to 4.
287
+  * @note  ENABLE: Full remap (TIM4_CH1/PD12, TIM4_CH2/PD13, TIM4_CH3/PD14, TIM4_CH4/PD15)
288
+  * @note  TIM4_ETR on PE0 is not re-mapped.
289
+  * @retval None
290
+  */
291
+#define __HAL_AFIO_REMAP_TIM4_ENABLE()  AFIO_REMAP_ENABLE(AFIO_MAPR_TIM4_REMAP)
292
+
293
+/**
294
+  * @brief Disable the remapping of TIM4 alternate function channels 1 to 4.
295
+  * @note  DISABLE: No remap  (TIM4_CH1/PB6,  TIM4_CH2/PB7,  TIM4_CH3/PB8,  TIM4_CH4/PB9)
296
+  * @note  TIM4_ETR on PE0 is not re-mapped.
297
+  * @retval None
298
+  */
299
+#define __HAL_AFIO_REMAP_TIM4_DISABLE() AFIO_REMAP_DISABLE(AFIO_MAPR_TIM4_REMAP)
300
+
301
+#if defined(AFIO_MAPR_CAN_REMAP_REMAP1)
302
+
303
+/**
304
+  * @brief Enable or disable the remapping of CAN alternate function CAN_RX and CAN_TX in devices with a single CAN interface.
305
+  * @note  CASE 1: CAN_RX mapped to PA11, CAN_TX mapped to PA12
306
+  * @retval None
307
+  */
308
+#define __HAL_AFIO_REMAP_CAN1_1()  AFIO_REMAP_PARTIAL(AFIO_MAPR_CAN_REMAP_REMAP1, AFIO_MAPR_CAN_REMAP)
309
+
310
+/**
311
+  * @brief Enable or disable the remapping of CAN alternate function CAN_RX and CAN_TX in devices with a single CAN interface.
312
+  * @note  CASE 2: CAN_RX mapped to PB8,  CAN_TX mapped to PB9 (not available on 36-pin package)
313
+  * @retval None
314
+  */
315
+#define __HAL_AFIO_REMAP_CAN1_2()  AFIO_REMAP_PARTIAL(AFIO_MAPR_CAN_REMAP_REMAP2, AFIO_MAPR_CAN_REMAP)
316
+
317
+/**
318
+  * @brief Enable or disable the remapping of CAN alternate function CAN_RX and CAN_TX in devices with a single CAN interface.
319
+  * @note  CASE 3: CAN_RX mapped to PD0,  CAN_TX mapped to PD1
320
+  * @retval None
321
+  */
322
+#define __HAL_AFIO_REMAP_CAN1_3()  AFIO_REMAP_PARTIAL(AFIO_MAPR_CAN_REMAP_REMAP3, AFIO_MAPR_CAN_REMAP)
323
+
324
+#endif
325
+
326
+/**
327
+  * @brief Enable the remapping of PD0 and PD1. When the HSE oscillator is not used
328
+  *        (application running on internal 8 MHz RC) PD0 and PD1 can be mapped on OSC_IN and
329
+  *        OSC_OUT. This is available only on 36, 48 and 64 pins packages (PD0 and PD1 are available
330
+  *        on 100-pin and 144-pin packages, no need for remapping).
331
+  * @note  ENABLE: PD0 remapped on OSC_IN, PD1 remapped on OSC_OUT.
332
+  * @retval None
333
+  */
334
+#define __HAL_AFIO_REMAP_PD01_ENABLE()  AFIO_REMAP_ENABLE(AFIO_MAPR_PD01_REMAP)
335
+
336
+/**
337
+  * @brief Disable the remapping of PD0 and PD1. When the HSE oscillator is not used
338
+  *        (application running on internal 8 MHz RC) PD0 and PD1 can be mapped on OSC_IN and
339
+  *        OSC_OUT. This is available only on 36, 48 and 64 pins packages (PD0 and PD1 are available
340
+  *        on 100-pin and 144-pin packages, no need for remapping).
341
+  * @note  DISABLE: No remapping of PD0 and PD1
342
+  * @retval None
343
+  */
344
+#define __HAL_AFIO_REMAP_PD01_DISABLE() AFIO_REMAP_DISABLE(AFIO_MAPR_PD01_REMAP)
345
+
346
+#if defined(AFIO_MAPR_TIM5CH4_IREMAP)
347
+/**
348
+  * @brief Enable the remapping of TIM5CH4.
349
+  * @note  ENABLE: LSI internal clock is connected to TIM5_CH4 input for calibration purpose.
350
+  * @note  This function is available only in high density value line devices.
351
+  * @retval None
352
+  */
353
+#define __HAL_AFIO_REMAP_TIM5CH4_ENABLE()  AFIO_REMAP_ENABLE(AFIO_MAPR_TIM5CH4_IREMAP)
354
+
355
+/**
356
+  * @brief Disable the remapping of TIM5CH4.
357
+  * @note  DISABLE: TIM5_CH4 is connected to PA3
358
+  * @note  This function is available only in high density value line devices.
359
+  * @retval None
360
+  */
361
+#define __HAL_AFIO_REMAP_TIM5CH4_DISABLE() AFIO_REMAP_DISABLE(AFIO_MAPR_TIM5CH4_IREMAP)
362
+#endif
363
+
364
+#if defined(AFIO_MAPR_ETH_REMAP)
365
+/**
366
+  * @brief Enable the remapping of Ethernet MAC connections with the PHY.
367
+  * @note  ENABLE: Remap     (RX_DV-CRS_DV/PD8, RXD0/PD9, RXD1/PD10, RXD2/PD11, RXD3/PD12)
368
+  * @note  This bit is available only in connectivity line devices and is reserved otherwise.
369
+  * @retval None
370
+  */
371
+#define __HAL_AFIO_REMAP_ETH_ENABLE()  AFIO_REMAP_ENABLE(AFIO_MAPR_ETH_REMAP)
372
+
373
+/**
374
+  * @brief Disable the remapping of Ethernet MAC connections with the PHY.
375
+  * @note  DISABLE: No remap (RX_DV-CRS_DV/PA7, RXD0/PC4, RXD1/PC5,  RXD2/PB0,  RXD3/PB1)
376
+  * @note  This bit is available only in connectivity line devices and is reserved otherwise.
377
+  * @retval None
378
+  */
379
+#define __HAL_AFIO_REMAP_ETH_DISABLE() AFIO_REMAP_DISABLE(AFIO_MAPR_ETH_REMAP)
380
+#endif
381
+
382
+#if defined(AFIO_MAPR_CAN2_REMAP)
383
+
384
+/**
385
+  * @brief Enable the remapping of CAN2 alternate function CAN2_RX and CAN2_TX.
386
+  * @note  ENABLE: Remap     (CAN2_RX/PB5,  CAN2_TX/PB6)
387
+  * @note  This bit is available only in connectivity line devices and is reserved otherwise.
388
+  * @retval None
389
+  */
390
+#define __HAL_AFIO_REMAP_CAN2_ENABLE()  AFIO_REMAP_ENABLE(AFIO_MAPR_CAN2_REMAP)
391
+
392
+/**
393
+  * @brief Disable the remapping of CAN2 alternate function CAN2_RX and CAN2_TX.
394
+  * @note  DISABLE: No remap (CAN2_RX/PB12, CAN2_TX/PB13)
395
+  * @note  This bit is available only in connectivity line devices and is reserved otherwise.
396
+  * @retval None
397
+  */
398
+#define __HAL_AFIO_REMAP_CAN2_DISABLE() AFIO_REMAP_DISABLE(AFIO_MAPR_CAN2_REMAP)
399
+#endif
400
+
401
+#if defined(AFIO_MAPR_MII_RMII_SEL)
402
+/**
403
+  * @brief Configures the Ethernet MAC internally for use with an external MII or RMII PHY.
404
+  * @note  ETH_RMII: Configure Ethernet MAC for connection with an RMII PHY
405
+  * @note  This bit is available only in connectivity line devices and is reserved otherwise.
406
+  * @retval None
407
+  */
408
+#define __HAL_AFIO_ETH_RMII() AFIO_REMAP_ENABLE(AFIO_MAPR_MII_RMII_SEL)
409
+
410
+/**
411
+  * @brief Configures the Ethernet MAC internally for use with an external MII or RMII PHY.
412
+  * @note  ETH_MII: Configure Ethernet MAC for connection with an MII PHY
413
+  * @note  This bit is available only in connectivity line devices and is reserved otherwise.
414
+  * @retval None
415
+  */
416
+#define __HAL_AFIO_ETH_MII()  AFIO_REMAP_DISABLE(AFIO_MAPR_MII_RMII_SEL)
417
+#endif
418
+
419
+/**
420
+  * @brief Enable the remapping of ADC1_ETRGINJ (ADC 1 External trigger injected conversion).
421
+  * @note  ENABLE: ADC1 External Event injected conversion is connected to TIM8 Channel4.
422
+  * @retval None
423
+  */
424
+#define __HAL_AFIO_REMAP_ADC1_ETRGINJ_ENABLE()  AFIO_REMAP_ENABLE(AFIO_MAPR_ADC1_ETRGINJ_REMAP)
425
+
426
+/**
427
+  * @brief Disable the remapping of ADC1_ETRGINJ (ADC 1 External trigger injected conversion).
428
+  * @note  DISABLE: ADC1 External trigger injected conversion is connected to EXTI15
429
+  * @retval None
430
+  */
431
+#define __HAL_AFIO_REMAP_ADC1_ETRGINJ_DISABLE() AFIO_REMAP_DISABLE(AFIO_MAPR_ADC1_ETRGINJ_REMAP)
432
+
433
+/**
434
+  * @brief Enable the remapping of ADC1_ETRGREG (ADC 1 External trigger regular conversion).
435
+  * @note  ENABLE: ADC1 External Event regular conversion is connected to TIM8 TRG0.
436
+  * @retval None
437
+  */
438
+#define __HAL_AFIO_REMAP_ADC1_ETRGREG_ENABLE()  AFIO_REMAP_ENABLE(AFIO_MAPR_ADC1_ETRGREG_REMAP)
439
+
440
+/**
441
+  * @brief Disable the remapping of ADC1_ETRGREG (ADC 1 External trigger regular conversion).
442
+  * @note  DISABLE: ADC1 External trigger regular conversion is connected to EXTI11
443
+  * @retval None
444
+  */
445
+#define __HAL_AFIO_REMAP_ADC1_ETRGREG_DISABLE() AFIO_REMAP_DISABLE(AFIO_MAPR_ADC1_ETRGREG_REMAP)
446
+
447
+#if defined(AFIO_MAPR_ADC2_ETRGINJ_REMAP)
448
+
449
+/**
450
+  * @brief Enable the remapping of ADC2_ETRGREG (ADC 2 External trigger injected conversion).
451
+  * @note  ENABLE: ADC2 External Event injected conversion is connected to TIM8 Channel4.
452
+  * @retval None
453
+  */
454
+#define __HAL_AFIO_REMAP_ADC2_ETRGINJ_ENABLE()  AFIO_REMAP_ENABLE(AFIO_MAPR_ADC2_ETRGINJ_REMAP)
455
+
456
+/**
457
+  * @brief Disable the remapping of ADC2_ETRGREG (ADC 2 External trigger injected conversion).
458
+  * @note  DISABLE: ADC2 External trigger injected conversion is connected to EXTI15
459
+  * @retval None
460
+  */
461
+#define __HAL_AFIO_REMAP_ADC2_ETRGINJ_DISABLE() AFIO_REMAP_DISABLE(AFIO_MAPR_ADC2_ETRGINJ_REMAP)
462
+#endif
463
+
464
+#if defined (AFIO_MAPR_ADC2_ETRGREG_REMAP)
465
+
466
+/**
467
+  * @brief Enable the remapping of ADC2_ETRGREG (ADC 2 External trigger regular conversion).
468
+  * @note  ENABLE: ADC2 External Event regular conversion is connected to TIM8 TRG0.
469
+  * @retval None
470
+  */
471
+#define __HAL_AFIO_REMAP_ADC2_ETRGREG_ENABLE()  AFIO_REMAP_ENABLE(AFIO_MAPR_ADC2_ETRGREG_REMAP)
472
+
473
+/**
474
+  * @brief Disable the remapping of ADC2_ETRGREG (ADC 2 External trigger regular conversion).
475
+  * @note  DISABLE: ADC2 External trigger regular conversion is connected to EXTI11
476
+  * @retval None
477
+  */
478
+#define __HAL_AFIO_REMAP_ADC2_ETRGREG_DISABLE() AFIO_REMAP_DISABLE(AFIO_MAPR_ADC2_ETRGREG_REMAP)
479
+#endif
480
+
481
+/**
482
+  * @brief Enable the Serial wire JTAG configuration
483
+  * @note  ENABLE: Full SWJ (JTAG-DP + SW-DP): Reset State
484
+  * @retval None
485
+  */
486
+#define __HAL_AFIO_REMAP_SWJ_ENABLE()  AFIO_DBGAFR_CONFIG(AFIO_MAPR_SWJ_CFG_RESET)
487
+
488
+/**
489
+  * @brief Enable the Serial wire JTAG configuration
490
+  * @note  NONJTRST: Full SWJ (JTAG-DP + SW-DP) but without NJTRST
491
+  * @retval None
492
+  */
493
+#define __HAL_AFIO_REMAP_SWJ_NONJTRST()  AFIO_DBGAFR_CONFIG(AFIO_MAPR_SWJ_CFG_NOJNTRST)
494
+
495
+/**
496
+  * @brief Enable the Serial wire JTAG configuration
497
+  * @note  NOJTAG: JTAG-DP Disabled and SW-DP Enabled
498
+  * @retval None
499
+  */
500
+
501
+#define __HAL_AFIO_REMAP_SWJ_NOJTAG()  AFIO_DBGAFR_CONFIG(AFIO_MAPR_SWJ_CFG_JTAGDISABLE)
502
+
503
+/**
504
+  * @brief Disable the Serial wire JTAG configuration
505
+  * @note  DISABLE: JTAG-DP Disabled and SW-DP Disabled
506
+  * @retval None
507
+  */
508
+#define __HAL_AFIO_REMAP_SWJ_DISABLE()  AFIO_DBGAFR_CONFIG(AFIO_MAPR_SWJ_CFG_DISABLE)
509
+
510
+#if defined(AFIO_MAPR_SPI3_REMAP)
511
+
512
+/**
513
+  * @brief Enable the remapping of SPI3 alternate functions SPI3_NSS/I2S3_WS, SPI3_SCK/I2S3_CK, SPI3_MISO, SPI3_MOSI/I2S3_SD.
514
+  * @note  ENABLE: Remap     (SPI3_NSS-I2S3_WS/PA4,  SPI3_SCK-I2S3_CK/PC10, SPI3_MISO/PC11, SPI3_MOSI-I2S3_SD/PC12)
515
+  * @note  This bit is available only in connectivity line devices and is reserved otherwise.
516
+  * @retval None
517
+  */
518
+#define __HAL_AFIO_REMAP_SPI3_ENABLE()  AFIO_REMAP_ENABLE(AFIO_MAPR_SPI3_REMAP)
519
+
520
+/**
521
+  * @brief Disable the remapping of SPI3 alternate functions SPI3_NSS/I2S3_WS, SPI3_SCK/I2S3_CK, SPI3_MISO, SPI3_MOSI/I2S3_SD.
522
+  * @note  DISABLE: No remap (SPI3_NSS-I2S3_WS/PA15, SPI3_SCK-I2S3_CK/PB3,  SPI3_MISO/PB4,  SPI3_MOSI-I2S3_SD/PB5).
523
+  * @note  This bit is available only in connectivity line devices and is reserved otherwise.
524
+  * @retval None
525
+  */
526
+#define __HAL_AFIO_REMAP_SPI3_DISABLE() AFIO_REMAP_DISABLE(AFIO_MAPR_SPI3_REMAP)
527
+#endif
528
+
529
+#if defined(AFIO_MAPR_TIM2ITR1_IREMAP)
530
+
531
+/**
532
+  * @brief Control of TIM2_ITR1 internal mapping.
533
+  * @note  TO_USB: Connect USB OTG SOF (Start of Frame) output to TIM2_ITR1 for calibration purposes.
534
+  * @note  This bit is available only in connectivity line devices and is reserved otherwise.
535
+  * @retval None
536
+  */
537
+#define __HAL_AFIO_TIM2ITR1_TO_USB() AFIO_REMAP_ENABLE(AFIO_MAPR_TIM2ITR1_IREMAP)
538
+
539
+/**
540
+  * @brief Control of TIM2_ITR1 internal mapping.
541
+  * @note  TO_ETH: Connect TIM2_ITR1 internally to the Ethernet PTP output for calibration purposes.
542
+  * @note  This bit is available only in connectivity line devices and is reserved otherwise.
543
+  * @retval None
544
+  */
545
+#define __HAL_AFIO_TIM2ITR1_TO_ETH() AFIO_REMAP_DISABLE(AFIO_MAPR_TIM2ITR1_IREMAP)
546
+#endif
547
+
548
+#if defined(AFIO_MAPR_PTP_PPS_REMAP)
549
+
550
+/**
551
+  * @brief Enable the remapping of ADC2_ETRGREG (ADC 2 External trigger regular conversion).
552
+  * @note  ENABLE: PTP_PPS is output on PB5 pin.
553
+  * @note  This bit is available only in connectivity line devices and is reserved otherwise.
554
+  * @retval None
555
+  */
556
+#define __HAL_AFIO_ETH_PTP_PPS_ENABLE()  AFIO_REMAP_ENABLE(AFIO_MAPR_PTP_PPS_REMAP)
557
+
558
+/**
559
+  * @brief Disable the remapping of ADC2_ETRGREG (ADC 2 External trigger regular conversion).
560
+  * @note  DISABLE: PTP_PPS not output on PB5 pin.
561
+  * @note  This bit is available only in connectivity line devices and is reserved otherwise.
562
+  * @retval None
563
+  */
564
+#define __HAL_AFIO_ETH_PTP_PPS_DISABLE() AFIO_REMAP_DISABLE(AFIO_MAPR_PTP_PPS_REMAP)
565
+#endif
566
+
567
+#if defined(AFIO_MAPR2_TIM9_REMAP)
568
+
569
+/**
570
+  * @brief Enable the remapping of TIM9_CH1 and TIM9_CH2.
571
+  * @note  ENABLE: Remap     (TIM9_CH1 on PE5 and TIM9_CH2 on PE6).
572
+  * @retval None
573
+  */
574
+#define __HAL_AFIO_REMAP_TIM9_ENABLE()  SET_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM9_REMAP)
575
+
576
+/**
577
+  * @brief Disable the remapping of TIM9_CH1 and TIM9_CH2.
578
+  * @note  DISABLE: No remap (TIM9_CH1 on PA2 and TIM9_CH2 on PA3).
579
+  * @retval None
580
+  */
581
+#define __HAL_AFIO_REMAP_TIM9_DISABLE() CLEAR_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM9_REMAP)
582
+#endif
583
+
584
+#if defined(AFIO_MAPR2_TIM10_REMAP)
585
+
586
+/**
587
+  * @brief Enable the remapping of TIM10_CH1.
588
+  * @note  ENABLE: Remap     (TIM10_CH1 on PF6).
589
+  * @retval None
590
+  */
591
+#define __HAL_AFIO_REMAP_TIM10_ENABLE()  SET_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM10_REMAP)
592
+
593
+/**
594
+  * @brief Disable the remapping of TIM10_CH1.
595
+  * @note  DISABLE: No remap (TIM10_CH1 on PB8).
596
+  * @retval None
597
+  */
598
+#define __HAL_AFIO_REMAP_TIM10_DISABLE() CLEAR_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM10_REMAP)
599
+#endif
600
+
601
+#if defined(AFIO_MAPR2_TIM11_REMAP)
602
+/**
603
+  * @brief Enable the remapping of TIM11_CH1.
604
+  * @note  ENABLE: Remap     (TIM11_CH1 on PF7).
605
+  * @retval None
606
+  */
607
+#define __HAL_AFIO_REMAP_TIM11_ENABLE()  SET_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM11_REMAP)
608
+
609
+/**
610
+  * @brief Disable the remapping of TIM11_CH1.
611
+  * @note  DISABLE: No remap (TIM11_CH1 on PB9).
612
+  * @retval None
613
+  */
614
+#define __HAL_AFIO_REMAP_TIM11_DISABLE() CLEAR_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM11_REMAP)
615
+#endif
616
+
617
+#if defined(AFIO_MAPR2_TIM13_REMAP)
618
+
619
+/**
620
+  * @brief Enable the remapping of TIM13_CH1.
621
+  * @note  ENABLE: Remap     STM32F100:(TIM13_CH1 on PF8). Others:(TIM13_CH1 on PB0).
622
+  * @retval None
623
+  */
624
+#define __HAL_AFIO_REMAP_TIM13_ENABLE()  SET_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM13_REMAP)
625
+
626
+/**
627
+  * @brief Disable the remapping of TIM13_CH1.
628
+  * @note  DISABLE: No remap STM32F100:(TIM13_CH1 on PA6). Others:(TIM13_CH1 on PC8).
629
+  * @retval None
630
+  */
631
+#define __HAL_AFIO_REMAP_TIM13_DISABLE() CLEAR_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM13_REMAP)
632
+#endif
633
+
634
+#if defined(AFIO_MAPR2_TIM14_REMAP)
635
+
636
+/**
637
+  * @brief Enable the remapping of TIM14_CH1.
638
+  * @note  ENABLE: Remap     STM32F100:(TIM14_CH1 on PB1). Others:(TIM14_CH1 on PF9).
639
+  * @retval None
640
+  */
641
+#define __HAL_AFIO_REMAP_TIM14_ENABLE()  SET_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM14_REMAP)
642
+
643
+/**
644
+  * @brief Disable the remapping of TIM14_CH1.
645
+  * @note  DISABLE: No remap STM32F100:(TIM14_CH1 on PC9). Others:(TIM14_CH1 on PA7).
646
+  * @retval None
647
+  */
648
+#define __HAL_AFIO_REMAP_TIM14_DISABLE() CLEAR_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM14_REMAP)
649
+#endif
650
+
651
+#if defined(AFIO_MAPR2_FSMC_NADV_REMAP)
652
+
653
+/**
654
+  * @brief Controls the use of the optional FSMC_NADV signal.
655
+  * @note  DISCONNECTED: The NADV signal is not connected. The I/O pin can be used by another peripheral.
656
+  * @retval None
657
+  */
658
+#define __HAL_AFIO_FSMCNADV_DISCONNECTED() SET_BIT(AFIO->MAPR2, AFIO_MAPR2_FSMC_NADV_REMAP)
659
+
660
+/**
661
+  * @brief Controls the use of the optional FSMC_NADV signal.
662
+  * @note  CONNECTED: The NADV signal is connected to the output (default).
663
+  * @retval None
664
+  */
665
+#define __HAL_AFIO_FSMCNADV_CONNECTED()    CLEAR_BIT(AFIO->MAPR2, AFIO_MAPR2_FSMC_NADV_REMAP)
666
+#endif
667
+
668
+#if defined(AFIO_MAPR2_TIM15_REMAP)
669
+
670
+/**
671
+  * @brief Enable the remapping of TIM15_CH1 and TIM15_CH2.
672
+  * @note  ENABLE: Remap     (TIM15_CH1 on PB14 and TIM15_CH2 on PB15).
673
+  * @retval None
674
+  */
675
+#define __HAL_AFIO_REMAP_TIM15_ENABLE()  SET_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM15_REMAP)
676
+
677
+/**
678
+  * @brief Disable the remapping of TIM15_CH1 and TIM15_CH2.
679
+  * @note  DISABLE: No remap (TIM15_CH1 on PA2  and TIM15_CH2 on PA3).
680
+  * @retval None
681
+  */
682
+#define __HAL_AFIO_REMAP_TIM15_DISABLE() CLEAR_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM15_REMAP)
683
+#endif
684
+
685
+#if defined(AFIO_MAPR2_TIM16_REMAP)
686
+
687
+/**
688
+  * @brief Enable the remapping of TIM16_CH1.
689
+  * @note  ENABLE: Remap     (TIM16_CH1 on PA6).
690
+  * @retval None
691
+  */
692
+#define __HAL_AFIO_REMAP_TIM16_ENABLE()  SET_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM16_REMAP)
693
+
694
+/**
695
+  * @brief Disable the remapping of TIM16_CH1.
696
+  * @note  DISABLE: No remap (TIM16_CH1 on PB8).
697
+  * @retval None
698
+  */
699
+#define __HAL_AFIO_REMAP_TIM16_DISABLE() CLEAR_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM16_REMAP)
700
+#endif
701
+
702
+#if defined(AFIO_MAPR2_TIM17_REMAP)
703
+
704
+/**
705
+  * @brief Enable the remapping of TIM17_CH1.
706
+  * @note  ENABLE: Remap     (TIM17_CH1 on PA7).
707
+  * @retval None
708
+  */
709
+#define __HAL_AFIO_REMAP_TIM17_ENABLE()  SET_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM17_REMAP)
710
+
711
+/**
712
+  * @brief Disable the remapping of TIM17_CH1.
713
+  * @note  DISABLE: No remap (TIM17_CH1 on PB9).
714
+  * @retval None
715
+  */
716
+#define __HAL_AFIO_REMAP_TIM17_DISABLE() CLEAR_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM17_REMAP)
717
+#endif
718
+
719
+#if defined(AFIO_MAPR2_CEC_REMAP)
720
+
721
+/**
722
+  * @brief Enable the remapping of CEC.
723
+  * @note  ENABLE: Remap     (CEC on PB10).
724
+  * @retval None
725
+  */
726
+#define __HAL_AFIO_REMAP_CEC_ENABLE()  SET_BIT(AFIO->MAPR2, AFIO_MAPR2_CEC_REMAP)
727
+
728
+/**
729
+  * @brief Disable the remapping of CEC.
730
+  * @note  DISABLE: No remap (CEC on PB8).
731
+  * @retval None
732
+  */
733
+#define __HAL_AFIO_REMAP_CEC_DISABLE() CLEAR_BIT(AFIO->MAPR2, AFIO_MAPR2_CEC_REMAP)
734
+#endif
735
+
736
+#if defined(AFIO_MAPR2_TIM1_DMA_REMAP)
737
+
738
+/**
739
+  * @brief Controls the mapping of the TIM1_CH1 TIM1_CH2 DMA requests onto the DMA1 channels.
740
+  * @note  ENABLE: Remap (TIM1_CH1 DMA request/DMA1 Channel6, TIM1_CH2 DMA request/DMA1 Channel6)
741
+  * @retval None
742
+  */
743
+#define __HAL_AFIO_REMAP_TIM1DMA_ENABLE()  SET_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM1_DMA_REMAP)
744
+
745
+/**
746
+  * @brief Controls the mapping of the TIM1_CH1 TIM1_CH2 DMA requests onto the DMA1 channels.
747
+  * @note  DISABLE: No remap (TIM1_CH1 DMA request/DMA1 Channel2, TIM1_CH2 DMA request/DMA1 Channel3).
748
+  * @retval None
749
+  */
750
+#define __HAL_AFIO_REMAP_TIM1DMA_DISABLE() CLEAR_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM1_DMA_REMAP)
751
+#endif
752
+
753
+#if defined(AFIO_MAPR2_TIM67_DAC_DMA_REMAP)
754
+
755
+/**
756
+  * @brief Controls the mapping of the TIM6_DAC1 and TIM7_DAC2 DMA requests onto the DMA1 channels.
757
+  * @note  ENABLE: Remap (TIM6_DAC1 DMA request/DMA1 Channel3, TIM7_DAC2 DMA request/DMA1 Channel4)
758
+  * @retval None
759
+  */
760
+#define __HAL_AFIO_REMAP_TIM67DACDMA_ENABLE()  SET_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM67_DAC_DMA_REMAP)
761
+
762
+/**
763
+  * @brief Controls the mapping of the TIM6_DAC1 and TIM7_DAC2 DMA requests onto the DMA1 channels.
764
+  * @note  DISABLE: No remap (TIM6_DAC1 DMA request/DMA2 Channel3, TIM7_DAC2 DMA request/DMA2 Channel4)
765
+  * @retval None
766
+  */
767
+#define __HAL_AFIO_REMAP_TIM67DACDMA_DISABLE() CLEAR_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM67_DAC_DMA_REMAP)
768
+#endif
769
+
770
+#if defined(AFIO_MAPR2_TIM12_REMAP)
771
+
772
+/**
773
+  * @brief Enable the remapping of TIM12_CH1 and TIM12_CH2.
774
+  * @note  ENABLE: Remap     (TIM12_CH1 on PB12 and TIM12_CH2 on PB13).
775
+  * @note  This bit is available only in high density value line devices.
776
+  * @retval None
777
+  */
778
+#define __HAL_AFIO_REMAP_TIM12_ENABLE()  SET_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM12_REMAP)
779
+
780
+/**
781
+  * @brief Disable the remapping of TIM12_CH1 and TIM12_CH2.
782
+  * @note  DISABLE: No remap (TIM12_CH1 on PC4  and TIM12_CH2 on PC5).
783
+  * @note  This bit is available only in high density value line devices.
784
+  * @retval None
785
+  */
786
+#define __HAL_AFIO_REMAP_TIM12_DISABLE() CLEAR_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM12_REMAP)
787
+#endif
788
+
789
+#if defined(AFIO_MAPR2_MISC_REMAP)
790
+
791
+/**
792
+  * @brief Miscellaneous features remapping.
793
+  *        This bit is set and cleared by software. It controls miscellaneous features.
794
+  *        The DMA2 channel 5 interrupt position in the vector table.
795
+  *        The timer selection for DAC trigger 3 (TSEL[2:0] = 011, for more details refer to the DAC_CR register).
796
+  * @note  ENABLE: DMA2 channel 5 interrupt is mapped separately at position 60 and TIM15 TRGO event is
797
+  *        selected as DAC Trigger 3, TIM15 triggers TIM1/3.
798
+  * @note  This bit is available only in high density value line devices.
799
+  * @retval None
800
+  */
801
+#define __HAL_AFIO_REMAP_MISC_ENABLE()  SET_BIT(AFIO->MAPR2, AFIO_MAPR2_MISC_REMAP)
802
+
803
+/**
804
+  * @brief Miscellaneous features remapping.
805
+  *        This bit is set and cleared by software. It controls miscellaneous features.
806
+  *        The DMA2 channel 5 interrupt position in the vector table.
807
+  *        The timer selection for DAC trigger 3 (TSEL[2:0] = 011, for more details refer to the DAC_CR register).
808
+  * @note  DISABLE: DMA2 channel 5 interrupt is mapped with DMA2 channel 4 at position 59, TIM5 TRGO
809
+  *        event is selected as DAC Trigger 3, TIM5 triggers TIM1/3.
810
+  * @note  This bit is available only in high density value line devices.
811
+  * @retval None
812
+  */
813
+#define __HAL_AFIO_REMAP_MISC_DISABLE() CLEAR_BIT(AFIO->MAPR2, AFIO_MAPR2_MISC_REMAP)
814
+#endif
815
+
816
+/**
817
+  * @}
818
+  */
819
+
820
+/**
821
+  * @}
822
+  */
823
+
824
+/** @defgroup GPIOEx_Private_Macros GPIOEx Private Macros
825
+  * @{
826
+  */
827
+#if defined(STM32F101x6) || defined(STM32F102x6) || defined(STM32F102xB) || defined(STM32F103x6)
828
+#define GPIO_GET_INDEX(__GPIOx__) (((__GPIOx__) == (GPIOA))? 0U :\
829
+                                   ((__GPIOx__) == (GPIOB))? 1U :\
830
+                                   ((__GPIOx__) == (GPIOC))? 2U :3U)
831
+#elif defined(STM32F100xB) || defined(STM32F101xB) || defined(STM32F103xB) || defined(STM32F105xC) || defined(STM32F107xC)
832
+#define GPIO_GET_INDEX(__GPIOx__) (((__GPIOx__) == (GPIOA))? 0U :\
833
+                                   ((__GPIOx__) == (GPIOB))? 1U :\
834
+                                   ((__GPIOx__) == (GPIOC))? 2U :\
835
+                                   ((__GPIOx__) == (GPIOD))? 3U :4U)
836
+#elif defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG)
837
+#define GPIO_GET_INDEX(__GPIOx__) (((__GPIOx__) == (GPIOA))? 0U :\
838
+                                   ((__GPIOx__) == (GPIOB))? 1U :\
839
+                                   ((__GPIOx__) == (GPIOC))? 2U :\
840
+                                   ((__GPIOx__) == (GPIOD))? 3U :\
841
+                                   ((__GPIOx__) == (GPIOE))? 4U :\
842
+                                   ((__GPIOx__) == (GPIOF))? 5U :6U)
843
+#endif
844
+
845
+#define AFIO_REMAP_ENABLE(REMAP_PIN)       do{ uint32_t tmpreg = AFIO->MAPR; \
846
+                                               tmpreg |= AFIO_MAPR_SWJ_CFG;  \
847
+                                               tmpreg |= REMAP_PIN;          \
848
+                                               AFIO->MAPR = tmpreg;          \
849
+                                               }while(0U)
850
+
851
+#define AFIO_REMAP_DISABLE(REMAP_PIN)      do{ uint32_t tmpreg = AFIO->MAPR;  \
852
+                                               tmpreg |= AFIO_MAPR_SWJ_CFG;   \
853
+                                               tmpreg &= ~REMAP_PIN;          \
854
+                                               AFIO->MAPR = tmpreg;           \
855
+                                               }while(0U)
856
+
857
+#define AFIO_REMAP_PARTIAL(REMAP_PIN, REMAP_PIN_MASK) do{ uint32_t tmpreg = AFIO->MAPR; \
858
+                                                          tmpreg &= ~REMAP_PIN_MASK;    \
859
+                                                          tmpreg |= AFIO_MAPR_SWJ_CFG;  \
860
+                                                          tmpreg |= REMAP_PIN;          \
861
+                                                          AFIO->MAPR = tmpreg;          \
862
+                                                          }while(0U)
863
+
864
+#define AFIO_DBGAFR_CONFIG(DBGAFR_SWJCFG)  do{ uint32_t tmpreg = AFIO->MAPR;     \
865
+                                               tmpreg &= ~AFIO_MAPR_SWJ_CFG_Msk; \
866
+                                               tmpreg |= DBGAFR_SWJCFG;          \
867
+                                               AFIO->MAPR = tmpreg;              \
868
+                                               }while(0U)
869
+
870
+/**
871
+  * @}
872
+  */
873
+
874
+/* Exported macro ------------------------------------------------------------*/
875
+/* Exported functions --------------------------------------------------------*/
876
+
877
+/** @addtogroup GPIOEx_Exported_Functions
878
+  * @{
879
+  */
880
+
881
+/** @addtogroup GPIOEx_Exported_Functions_Group1
882
+  * @{
883
+  */
884
+void HAL_GPIOEx_ConfigEventout(uint32_t GPIO_PortSource, uint32_t GPIO_PinSource);
885
+void HAL_GPIOEx_EnableEventout(void);
886
+void HAL_GPIOEx_DisableEventout(void);
887
+
888
+/**
889
+  * @}
890
+  */
891
+
892
+/**
893
+  * @}
894
+  */
895
+
896
+/**
897
+  * @}
898
+  */
899
+
900
+/**
901
+  * @}
902
+  */
903
+
904
+#ifdef __cplusplus
905
+}
906
+#endif
907
+
908
+#endif /* __STM32F1xx_HAL_GPIO_EX_H */
909
+
910
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 404 - 0
Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pwr.h

@@ -0,0 +1,404 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx_hal_pwr.h
4
+  * @author  MCD Application Team
5
+  * @brief   Header file of PWR HAL module.
6
+  ******************************************************************************
7
+  * @attention
8
+  *
9
+  * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
10
+  *
11
+  * Redistribution and use in source and binary forms, with or without modification,
12
+  * are permitted provided that the following conditions are met:
13
+  *   1. Redistributions of source code must retain the above copyright notice,
14
+  *      this list of conditions and the following disclaimer.
15
+  *   2. Redistributions in binary form must reproduce the above copyright notice,
16
+  *      this list of conditions and the following disclaimer in the documentation
17
+  *      and/or other materials provided with the distribution.
18
+  *   3. Neither the name of STMicroelectronics nor the names of its contributors
19
+  *      may be used to endorse or promote products derived from this software
20
+  *      without specific prior written permission.
21
+  *
22
+  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
+  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25
+  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28
+  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29
+  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30
+  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
+  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
+  *
33
+  ******************************************************************************
34
+  */
35
+
36
+/* Define to prevent recursive inclusion -------------------------------------*/
37
+#ifndef __STM32F1xx_HAL_PWR_H
38
+#define __STM32F1xx_HAL_PWR_H
39
+
40
+#ifdef __cplusplus
41
+ extern "C" {
42
+#endif
43
+
44
+/* Includes ------------------------------------------------------------------*/
45
+#include "stm32f1xx_hal_def.h"
46
+
47
+/** @addtogroup STM32F1xx_HAL_Driver
48
+  * @{
49
+  */
50
+
51
+/** @addtogroup PWR
52
+  * @{
53
+  */
54
+
55
+/* Exported types ------------------------------------------------------------*/
56
+
57
+/** @defgroup PWR_Exported_Types PWR Exported Types
58
+  * @{
59
+  */ 
60
+
61
+/**
62
+  * @brief  PWR PVD configuration structure definition
63
+  */
64
+typedef struct
65
+{
66
+  uint32_t PVDLevel;   /*!< PVDLevel: Specifies the PVD detection level.
67
+                            This parameter can be a value of @ref PWR_PVD_detection_level */
68
+
69
+  uint32_t Mode;      /*!< Mode: Specifies the operating mode for the selected pins.
70
+                           This parameter can be a value of @ref PWR_PVD_Mode */
71
+}PWR_PVDTypeDef;
72
+
73
+
74
+/**
75
+  * @}
76
+  */
77
+
78
+
79
+/* Internal constants --------------------------------------------------------*/
80
+
81
+/** @addtogroup PWR_Private_Constants
82
+  * @{
83
+  */ 
84
+
85
+#define PWR_EXTI_LINE_PVD  ((uint32_t)0x00010000)  /*!< External interrupt line 16 Connected to the PVD EXTI Line */
86
+
87
+/**
88
+  * @}
89
+  */
90
+
91
+ 
92
+/* Exported constants --------------------------------------------------------*/
93
+
94
+/** @defgroup PWR_Exported_Constants PWR Exported Constants
95
+  * @{
96
+  */ 
97
+
98
+/** @defgroup PWR_PVD_detection_level PWR PVD detection level
99
+  * @{
100
+  */
101
+#define PWR_PVDLEVEL_0                  PWR_CR_PLS_2V2
102
+#define PWR_PVDLEVEL_1                  PWR_CR_PLS_2V3
103
+#define PWR_PVDLEVEL_2                  PWR_CR_PLS_2V4
104
+#define PWR_PVDLEVEL_3                  PWR_CR_PLS_2V5
105
+#define PWR_PVDLEVEL_4                  PWR_CR_PLS_2V6
106
+#define PWR_PVDLEVEL_5                  PWR_CR_PLS_2V7
107
+#define PWR_PVDLEVEL_6                  PWR_CR_PLS_2V8
108
+#define PWR_PVDLEVEL_7                  PWR_CR_PLS_2V9 
109
+                                                          
110
+/**
111
+  * @}
112
+  */
113
+
114
+/** @defgroup PWR_PVD_Mode PWR PVD Mode
115
+  * @{
116
+  */
117
+#define PWR_PVD_MODE_NORMAL                 0x00000000U   /*!< basic mode is used */
118
+#define PWR_PVD_MODE_IT_RISING              0x00010001U   /*!< External Interrupt Mode with Rising edge trigger detection */
119
+#define PWR_PVD_MODE_IT_FALLING             0x00010002U   /*!< External Interrupt Mode with Falling edge trigger detection */
120
+#define PWR_PVD_MODE_IT_RISING_FALLING      0x00010003U   /*!< External Interrupt Mode with Rising/Falling edge trigger detection */
121
+#define PWR_PVD_MODE_EVENT_RISING           0x00020001U   /*!< Event Mode with Rising edge trigger detection */
122
+#define PWR_PVD_MODE_EVENT_FALLING          0x00020002U   /*!< Event Mode with Falling edge trigger detection */
123
+#define PWR_PVD_MODE_EVENT_RISING_FALLING   0x00020003U   /*!< Event Mode with Rising/Falling edge trigger detection */
124
+
125
+/**
126
+  * @}
127
+  */
128
+
129
+
130
+/** @defgroup PWR_WakeUp_Pins PWR WakeUp Pins
131
+  * @{
132
+  */
133
+
134
+#define PWR_WAKEUP_PIN1                 PWR_CSR_EWUP
135
+
136
+/**
137
+  * @}
138
+  */
139
+
140
+/** @defgroup PWR_Regulator_state_in_SLEEP_STOP_mode PWR Regulator state in SLEEP/STOP mode
141
+  * @{
142
+  */
143
+#define PWR_MAINREGULATOR_ON                        0x00000000U
144
+#define PWR_LOWPOWERREGULATOR_ON                    PWR_CR_LPDS
145
+
146
+/**
147
+  * @}
148
+  */
149
+
150
+/** @defgroup PWR_SLEEP_mode_entry PWR SLEEP mode entry
151
+  * @{
152
+  */
153
+#define PWR_SLEEPENTRY_WFI              ((uint8_t)0x01)
154
+#define PWR_SLEEPENTRY_WFE              ((uint8_t)0x02)
155
+
156
+/**
157
+  * @}
158
+  */
159
+
160
+/** @defgroup PWR_STOP_mode_entry PWR STOP mode entry
161
+  * @{
162
+  */
163
+#define PWR_STOPENTRY_WFI               ((uint8_t)0x01)
164
+#define PWR_STOPENTRY_WFE               ((uint8_t)0x02)
165
+
166
+/**
167
+  * @}
168
+  */
169
+
170
+/** @defgroup PWR_Flag PWR Flag
171
+  * @{
172
+  */
173
+#define PWR_FLAG_WU                     PWR_CSR_WUF
174
+#define PWR_FLAG_SB                     PWR_CSR_SBF
175
+#define PWR_FLAG_PVDO                   PWR_CSR_PVDO
176
+
177
+
178
+/**
179
+  * @}
180
+  */
181
+
182
+/**
183
+  * @}
184
+  */
185
+
186
+/* Exported macro ------------------------------------------------------------*/
187
+/** @defgroup PWR_Exported_Macros PWR Exported Macros
188
+  * @{
189
+  */
190
+
191
+/** @brief  Check PWR flag is set or not.
192
+  * @param  __FLAG__: specifies the flag to check.
193
+  *           This parameter can be one of the following values:
194
+  *            @arg PWR_FLAG_WU: Wake Up flag. This flag indicates that a wakeup event
195
+  *                  was received from the WKUP pin or from the RTC alarm
196
+  *                  An additional wakeup event is detected if the WKUP pin is enabled
197
+  *                  (by setting the EWUP bit) when the WKUP pin level is already high.
198
+  *            @arg PWR_FLAG_SB: StandBy flag. This flag indicates that the system was
199
+  *                  resumed from StandBy mode.
200
+  *            @arg PWR_FLAG_PVDO: PVD Output. This flag is valid only if PVD is enabled
201
+  *                  by the HAL_PWR_EnablePVD() function. The PVD is stopped by Standby mode
202
+  *                  For this reason, this bit is equal to 0 after Standby or reset
203
+  *                  until the PVDE bit is set.
204
+  * @retval The new state of __FLAG__ (TRUE or FALSE).
205
+  */
206
+#define __HAL_PWR_GET_FLAG(__FLAG__) ((PWR->CSR & (__FLAG__)) == (__FLAG__))
207
+
208
+/** @brief  Clear the PWR's pending flags.
209
+  * @param  __FLAG__: specifies the flag to clear.
210
+  *          This parameter can be one of the following values:
211
+  *            @arg PWR_FLAG_WU: Wake Up flag
212
+  *            @arg PWR_FLAG_SB: StandBy flag
213
+  */
214
+#define __HAL_PWR_CLEAR_FLAG(__FLAG__) SET_BIT(PWR->CR, ((__FLAG__) << 2))
215
+
216
+/**
217
+  * @brief Enable interrupt on PVD Exti Line 16.
218
+  * @retval None.
219
+  */
220
+#define __HAL_PWR_PVD_EXTI_ENABLE_IT()      SET_BIT(EXTI->IMR, PWR_EXTI_LINE_PVD)
221
+
222
+/**
223
+  * @brief Disable interrupt on PVD Exti Line 16. 
224
+  * @retval None.
225
+  */
226
+#define __HAL_PWR_PVD_EXTI_DISABLE_IT()     CLEAR_BIT(EXTI->IMR, PWR_EXTI_LINE_PVD)
227
+
228
+/**
229
+  * @brief Enable event on PVD Exti Line 16.
230
+  * @retval None.
231
+  */
232
+#define __HAL_PWR_PVD_EXTI_ENABLE_EVENT()   SET_BIT(EXTI->EMR, PWR_EXTI_LINE_PVD)
233
+
234
+/**
235
+  * @brief Disable event on PVD Exti Line 16.
236
+  * @retval None.
237
+  */
238
+#define __HAL_PWR_PVD_EXTI_DISABLE_EVENT()  CLEAR_BIT(EXTI->EMR, PWR_EXTI_LINE_PVD)
239
+
240
+
241
+/**
242
+  * @brief  PVD EXTI line configuration: set falling edge trigger.  
243
+  * @retval None.
244
+  */
245
+#define __HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE()  SET_BIT(EXTI->FTSR, PWR_EXTI_LINE_PVD)
246
+
247
+
248
+/**
249
+  * @brief Disable the PVD Extended Interrupt Falling Trigger.
250
+  * @retval None.
251
+  */
252
+#define __HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE()  CLEAR_BIT(EXTI->FTSR, PWR_EXTI_LINE_PVD)
253
+
254
+
255
+/**
256
+  * @brief  PVD EXTI line configuration: set rising edge trigger.
257
+  * @retval None.
258
+  */
259
+#define __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE()   SET_BIT(EXTI->RTSR, PWR_EXTI_LINE_PVD)
260
+
261
+/**
262
+  * @brief Disable the PVD Extended Interrupt Rising Trigger.
263
+  * This parameter can be:
264
+  * @retval None.
265
+  */
266
+#define __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE()  CLEAR_BIT(EXTI->RTSR, PWR_EXTI_LINE_PVD)
267
+
268
+/**
269
+  * @brief  PVD EXTI line configuration: set rising & falling edge trigger.
270
+  * @retval None.
271
+  */
272
+#define __HAL_PWR_PVD_EXTI_ENABLE_RISING_FALLING_EDGE()   __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE();__HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE();
273
+
274
+/**
275
+  * @brief Disable the PVD Extended Interrupt Rising & Falling Trigger.
276
+  * This parameter can be:
277
+  * @retval None.
278
+  */
279
+#define __HAL_PWR_PVD_EXTI_DISABLE_RISING_FALLING_EDGE()  __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE();__HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE();
280
+
281
+
282
+
283
+/**
284
+  * @brief Check whether the specified PVD EXTI interrupt flag is set or not.
285
+  * @retval EXTI PVD Line Status.
286
+  */
287
+#define __HAL_PWR_PVD_EXTI_GET_FLAG()       (EXTI->PR & (PWR_EXTI_LINE_PVD))
288
+
289
+/**
290
+  * @brief Clear the PVD EXTI flag.
291
+  * @retval None.
292
+  */
293
+#define __HAL_PWR_PVD_EXTI_CLEAR_FLAG()     (EXTI->PR = (PWR_EXTI_LINE_PVD))
294
+
295
+/**
296
+  * @brief Generate a Software interrupt on selected EXTI line.
297
+  * @retval None.
298
+  */
299
+#define __HAL_PWR_PVD_EXTI_GENERATE_SWIT()  SET_BIT(EXTI->SWIER, PWR_EXTI_LINE_PVD)
300
+/**
301
+  * @}
302
+  */
303
+
304
+/* Private macro -------------------------------------------------------------*/
305
+/** @defgroup PWR_Private_Macros PWR Private Macros
306
+  * @{
307
+  */
308
+#define IS_PWR_PVD_LEVEL(LEVEL) (((LEVEL) == PWR_PVDLEVEL_0) || ((LEVEL) == PWR_PVDLEVEL_1)|| \
309
+                                 ((LEVEL) == PWR_PVDLEVEL_2) || ((LEVEL) == PWR_PVDLEVEL_3)|| \
310
+                                 ((LEVEL) == PWR_PVDLEVEL_4) || ((LEVEL) == PWR_PVDLEVEL_5)|| \
311
+                                 ((LEVEL) == PWR_PVDLEVEL_6) || ((LEVEL) == PWR_PVDLEVEL_7))
312
+
313
+
314
+#define IS_PWR_PVD_MODE(MODE) (((MODE) == PWR_PVD_MODE_IT_RISING)|| ((MODE) == PWR_PVD_MODE_IT_FALLING) || \
315
+                              ((MODE) == PWR_PVD_MODE_IT_RISING_FALLING) || ((MODE) == PWR_PVD_MODE_EVENT_RISING) || \
316
+                              ((MODE) == PWR_PVD_MODE_EVENT_FALLING) || ((MODE) == PWR_PVD_MODE_EVENT_RISING_FALLING) || \
317
+                              ((MODE) == PWR_PVD_MODE_NORMAL)) 
318
+
319
+#define IS_PWR_WAKEUP_PIN(PIN) (((PIN) == PWR_WAKEUP_PIN1))
320
+
321
+#define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_MAINREGULATOR_ON) || \
322
+                                     ((REGULATOR) == PWR_LOWPOWERREGULATOR_ON))
323
+
324
+#define IS_PWR_SLEEP_ENTRY(ENTRY) (((ENTRY) == PWR_SLEEPENTRY_WFI) || ((ENTRY) == PWR_SLEEPENTRY_WFE))
325
+
326
+#define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPENTRY_WFI) || ((ENTRY) == PWR_STOPENTRY_WFE))
327
+
328
+/**
329
+  * @}
330
+  */
331
+
332
+
333
+
334
+/* Exported functions --------------------------------------------------------*/
335
+
336
+/** @addtogroup PWR_Exported_Functions PWR Exported Functions
337
+  * @{
338
+  */
339
+  
340
+/** @addtogroup PWR_Exported_Functions_Group1 Initialization and de-initialization functions 
341
+  * @{
342
+  */
343
+
344
+/* Initialization and de-initialization functions *******************************/
345
+void HAL_PWR_DeInit(void);
346
+void HAL_PWR_EnableBkUpAccess(void);
347
+void HAL_PWR_DisableBkUpAccess(void);
348
+
349
+/**
350
+  * @}
351
+  */
352
+
353
+/** @addtogroup PWR_Exported_Functions_Group2 Peripheral Control functions 
354
+  * @{
355
+  */
356
+
357
+/* Peripheral Control functions  ************************************************/
358
+void HAL_PWR_ConfigPVD(PWR_PVDTypeDef *sConfigPVD);
359
+/* #define HAL_PWR_ConfigPVD 12*/
360
+void HAL_PWR_EnablePVD(void);
361
+void HAL_PWR_DisablePVD(void);
362
+
363
+/* WakeUp pins configuration functions ****************************************/
364
+void HAL_PWR_EnableWakeUpPin(uint32_t WakeUpPinx);
365
+void HAL_PWR_DisableWakeUpPin(uint32_t WakeUpPinx);
366
+
367
+/* Low Power modes configuration functions ************************************/
368
+void HAL_PWR_EnterSTOPMode(uint32_t Regulator, uint8_t STOPEntry);
369
+void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry);
370
+void HAL_PWR_EnterSTANDBYMode(void);
371
+
372
+void HAL_PWR_EnableSleepOnExit(void);
373
+void HAL_PWR_DisableSleepOnExit(void);
374
+void HAL_PWR_EnableSEVOnPend(void);
375
+void HAL_PWR_DisableSEVOnPend(void);
376
+
377
+
378
+
379
+void HAL_PWR_PVD_IRQHandler(void);
380
+void HAL_PWR_PVDCallback(void);
381
+/**
382
+  * @}
383
+  */
384
+
385
+/**
386
+  * @}
387
+  */
388
+
389
+/**
390
+  * @}
391
+  */
392
+
393
+/**
394
+  * @}
395
+  */
396
+
397
+#ifdef __cplusplus
398
+}
399
+#endif
400
+
401
+
402
+#endif /* __STM32F1xx_HAL_PWR_H */
403
+
404
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

文件差异内容过多而无法显示
+ 1393 - 0
Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc.h


文件差异内容过多而无法显示
+ 1924 - 0
Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc_ex.h


文件差异内容过多而无法显示
+ 1793 - 0
Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim.h


+ 343 - 0
Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim_ex.h

@@ -0,0 +1,343 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx_hal_tim_ex.h
4
+  * @author  MCD Application Team
5
+  * @brief   Header file of TIM HAL Extension module.
6
+  ******************************************************************************
7
+  * @attention
8
+  *
9
+  * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
10
+  *
11
+  * Redistribution and use in source and binary forms, with or without modification,
12
+  * are permitted provided that the following conditions are met:
13
+  *   1. Redistributions of source code must retain the above copyright notice,
14
+  *      this list of conditions and the following disclaimer.
15
+  *   2. Redistributions in binary form must reproduce the above copyright notice,
16
+  *      this list of conditions and the following disclaimer in the documentation
17
+  *      and/or other materials provided with the distribution.
18
+  *   3. Neither the name of STMicroelectronics nor the names of its contributors
19
+  *      may be used to endorse or promote products derived from this software
20
+  *      without specific prior written permission.
21
+  *
22
+  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
+  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25
+  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28
+  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29
+  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30
+  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
+  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
+  *
33
+  ******************************************************************************
34
+  */ 
35
+
36
+/* Define to prevent recursive inclusion -------------------------------------*/
37
+#ifndef __STM32F1xx_HAL_TIM_EX_H
38
+#define __STM32F1xx_HAL_TIM_EX_H
39
+
40
+#ifdef __cplusplus
41
+ extern "C" {
42
+#endif
43
+
44
+/* Includes ------------------------------------------------------------------*/
45
+#include "stm32f1xx_hal_def.h"
46
+
47
+/** @addtogroup STM32F1xx_HAL_Driver
48
+  * @{
49
+  */
50
+
51
+/** @addtogroup TIMEx
52
+  * @{
53
+  */ 
54
+
55
+/* Exported types ------------------------------------------------------------*/ 
56
+/** @defgroup TIMEx_Exported_Types TIMEx Exported Types
57
+  * @{
58
+  */
59
+
60
+
61
+/** 
62
+  * @brief  TIM Hall sensor Configuration Structure definition  
63
+  */
64
+
65
+typedef struct
66
+{
67
+
68
+  uint32_t IC1Polarity;            /*!< Specifies the active edge of the input signal.
69
+                                        This parameter can be a value of @ref TIM_Input_Capture_Polarity */
70
+
71
+  uint32_t IC1Prescaler;        /*!< Specifies the Input Capture Prescaler.
72
+                                     This parameter can be a value of @ref TIM_Input_Capture_Prescaler */
73
+
74
+  uint32_t IC1Filter;           /*!< Specifies the input capture filter.
75
+                                     This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */  
76
+  uint32_t Commutation_Delay;  /*!< Specifies the pulse value to be loaded into the Capture Compare Register. 
77
+                                    This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF */
78
+} TIM_HallSensor_InitTypeDef;
79
+
80
+
81
+#if defined (STM32F100xB) || defined (STM32F100xE) ||                                                   \
82
+    defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F103xE) || defined (STM32F103xG) || \
83
+    defined (STM32F105xC) || defined (STM32F107xC)
84
+
85
+/** 
86
+  * @brief  TIM Break and Dead time configuration Structure definition  
87
+  */ 
88
+typedef struct
89
+{
90
+  uint32_t OffStateRunMode;       /*!< TIM off state in run mode
91
+                                     This parameter can be a value of @ref TIM_OSSR_Off_State_Selection_for_Run_mode_state */
92
+  uint32_t OffStateIDLEMode;      /*!< TIM off state in IDLE mode
93
+                                     This parameter can be a value of @ref TIM_OSSI_Off_State_Selection_for_Idle_mode_state */
94
+  uint32_t LockLevel;             /*!< TIM Lock level
95
+                                     This parameter can be a value of @ref TIM_Lock_level */                             
96
+  uint32_t DeadTime;              /*!< TIM dead Time 
97
+                                     This parameter can be a number between Min_Data = 0x00 and Max_Data = 0xFF */
98
+  uint32_t BreakState;            /*!< TIM Break State 
99
+                                     This parameter can be a value of @ref TIM_Break_Input_enable_disable */
100
+  uint32_t BreakPolarity;         /*!< TIM Break input polarity 
101
+                                     This parameter can be a value of @ref TIM_Break_Polarity */
102
+  uint32_t AutomaticOutput;       /*!< TIM Automatic Output Enable state 
103
+                                     This parameter can be a value of @ref TIM_AOE_Bit_Set_Reset */           
104
+} TIM_BreakDeadTimeConfigTypeDef;
105
+
106
+#endif /* defined(STM32F100xB) || defined(STM32F100xE) ||                                                 */
107
+       /* defined(STM32F103x6) || defined(STM32F103xB) || defined(STM32F103xE) || defined(STM32F103xG) || */
108
+       /* defined(STM32F105xC) || defined(STM32F107xC)                                                    */
109
+
110
+/** 
111
+  * @brief  TIM Master configuration Structure definition  
112
+  */ 
113
+typedef struct {
114
+  uint32_t  MasterOutputTrigger;   /*!< Trigger output (TRGO) selection 
115
+                                      This parameter can be a value of @ref TIM_Master_Mode_Selection */ 
116
+  uint32_t  MasterSlaveMode;       /*!< Master/slave mode selection 
117
+                                      This parameter can be a value of @ref TIM_Master_Slave_Mode */
118
+}TIM_MasterConfigTypeDef;
119
+
120
+/**
121
+  * @}
122
+  */ 
123
+
124
+/* Exported constants --------------------------------------------------------*/
125
+#if defined (STM32F100xB) || defined (STM32F100xE) ||                                                   \
126
+    defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F103xE) || defined (STM32F103xG) || \
127
+    defined (STM32F105xC) || defined (STM32F107xC)
128
+/** @defgroup TIMEx_Exported_Constants TIMEx Exported Constants
129
+  * @{
130
+  */
131
+    
132
+/** @defgroup TIMEx_Clock_Filter TIMEx Clock Filter
133
+  * @{
134
+  */
135
+#define IS_TIM_DEADTIME(DEADTIME)      ((DEADTIME) <= 0xFFU)          /*!< BreakDead Time */
136
+/**
137
+  * @}
138
+  */
139
+
140
+/**
141
+  * @}
142
+  */
143
+#endif /* defined(STM32F100xB) || defined(STM32F100xE) ||                                                 */
144
+       /* defined(STM32F103x6) || defined(STM32F103xB) || defined(STM32F103xE) || defined(STM32F103xG) || */
145
+       /* defined(STM32F105xC) || defined(STM32F107xC)                                                    */
146
+
147
+/* Exported macro ------------------------------------------------------------*/
148
+/**
149
+  * @brief  Sets the TIM Output compare preload.
150
+  * @param  __HANDLE__: TIM handle.
151
+  * @param  __CHANNEL__: TIM Channels to be configured.
152
+  *          This parameter can be one of the following values:
153
+  *            @arg TIM_CHANNEL_1: TIM Channel 1 selected
154
+  *            @arg TIM_CHANNEL_2: TIM Channel 2 selected
155
+  *            @arg TIM_CHANNEL_3: TIM Channel 3 selected
156
+  *            @arg TIM_CHANNEL_4: TIM Channel 4 selected
157
+  * @retval None
158
+  */
159
+#define __HAL_TIM_ENABLE_OCxPRELOAD(__HANDLE__, __CHANNEL__)    \
160
+        (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCMR1 |= TIM_CCMR1_OC1PE) :\
161
+         ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCMR1 |= TIM_CCMR1_OC2PE) :\
162
+         ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCMR2 |= TIM_CCMR2_OC3PE) :\
163
+         ((__HANDLE__)->Instance->CCMR2 |= TIM_CCMR2_OC4PE))
164
+
165
+/**
166
+  * @brief  Resets the TIM Output compare preload.
167
+  * @param  __HANDLE__: TIM handle.
168
+  * @param  __CHANNEL__: TIM Channels to be configured.
169
+  *          This parameter can be one of the following values:
170
+  *            @arg TIM_CHANNEL_1: TIM Channel 1 selected
171
+  *            @arg TIM_CHANNEL_2: TIM Channel 2 selected
172
+  *            @arg TIM_CHANNEL_3: TIM Channel 3 selected
173
+  *            @arg TIM_CHANNEL_4: TIM Channel 4 selected
174
+  * @retval None
175
+  */
176
+#define __HAL_TIM_DISABLE_OCxPRELOAD(__HANDLE__, __CHANNEL__)    \
177
+        (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCMR1 &= (uint16_t)~TIM_CCMR1_OC1PE) :\
178
+         ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCMR1 &= (uint16_t)~TIM_CCMR1_OC2PE) :\
179
+         ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCMR2 &= (uint16_t)~TIM_CCMR2_OC3PE) :\
180
+         ((__HANDLE__)->Instance->CCMR2 &= (uint16_t)~TIM_CCMR2_OC4PE))
181
+
182
+/* Exported functions --------------------------------------------------------*/
183
+/** @addtogroup TIMEx_Exported_Functions
184
+  * @{
185
+  */
186
+
187
+/** @addtogroup TIMEx_Exported_Functions_Group1
188
+  * @{
189
+ */
190
+/* Timer Hall Sensor functions  **********************************************/
191
+HAL_StatusTypeDef HAL_TIMEx_HallSensor_Init(TIM_HandleTypeDef *htim, TIM_HallSensor_InitTypeDef* sConfig);
192
+HAL_StatusTypeDef HAL_TIMEx_HallSensor_DeInit(TIM_HandleTypeDef *htim);
193
+
194
+void HAL_TIMEx_HallSensor_MspInit(TIM_HandleTypeDef *htim);
195
+void HAL_TIMEx_HallSensor_MspDeInit(TIM_HandleTypeDef *htim);
196
+
197
+ /* Blocking mode: Polling */
198
+HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start(TIM_HandleTypeDef *htim);
199
+HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop(TIM_HandleTypeDef *htim);
200
+/* Non-Blocking mode: Interrupt */
201
+HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_IT(TIM_HandleTypeDef *htim);
202
+HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_IT(TIM_HandleTypeDef *htim);
203
+/* Non-Blocking mode: DMA */
204
+HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_DMA(TIM_HandleTypeDef *htim, uint32_t *pData, uint16_t Length);
205
+HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_DMA(TIM_HandleTypeDef *htim);
206
+/**
207
+  * @}
208
+  */
209
+
210
+#if defined (STM32F100xB) || defined (STM32F100xE) ||                                                   \
211
+    defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F103xE) || defined (STM32F103xG) || \
212
+    defined (STM32F105xC) || defined (STM32F107xC)
213
+
214
+/** @addtogroup TIMEx_Exported_Functions_Group2
215
+ * @{
216
+ */
217
+/* Timer Complementary Output Compare functions  *****************************/
218
+/* Blocking mode: Polling */
219
+HAL_StatusTypeDef HAL_TIMEx_OCN_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
220
+HAL_StatusTypeDef HAL_TIMEx_OCN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
221
+
222
+/* Non-Blocking mode: Interrupt */
223
+HAL_StatusTypeDef HAL_TIMEx_OCN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
224
+HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
225
+
226
+/* Non-Blocking mode: DMA */
227
+HAL_StatusTypeDef HAL_TIMEx_OCN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length);
228
+HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
229
+/**
230
+  * @}
231
+  */
232
+
233
+/** @addtogroup TIMEx_Exported_Functions_Group3
234
+ * @{
235
+ */
236
+/* Timer Complementary PWM functions  ****************************************/
237
+/* Blocking mode: Polling */
238
+HAL_StatusTypeDef HAL_TIMEx_PWMN_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
239
+HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
240
+
241
+/* Non-Blocking mode: Interrupt */
242
+HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
243
+HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
244
+/* Non-Blocking mode: DMA */
245
+HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length);
246
+HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
247
+/**
248
+  * @}
249
+  */
250
+
251
+/** @addtogroup TIMEx_Exported_Functions_Group4
252
+ * @{
253
+ */
254
+/* Timer Complementary One Pulse functions  **********************************/
255
+/* Blocking mode: Polling */
256
+HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
257
+HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
258
+
259
+/* Non-Blocking mode: Interrupt */
260
+HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
261
+HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
262
+/**
263
+  * @}
264
+  */
265
+#endif /* defined(STM32F100xB) || defined(STM32F100xE) ||                                                 */
266
+       /* defined(STM32F103x6) || defined(STM32F103xB) || defined(STM32F103xE) || defined(STM32F103xG) || */
267
+       /* defined(STM32F105xC) || defined(STM32F107xC)                                                    */
268
+
269
+/** @addtogroup TIMEx_Exported_Functions_Group5
270
+ * @{
271
+ */
272
+/* Extended Control functions  ************************************************/
273
+#if defined (STM32F100xB) || defined (STM32F100xE) ||                                                   \
274
+    defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F103xE) || defined (STM32F103xG) || \
275
+    defined (STM32F105xC) || defined (STM32F107xC)
276
+HAL_StatusTypeDef HAL_TIMEx_ConfigCommutationEvent(TIM_HandleTypeDef *htim, uint32_t  InputTrigger, uint32_t  CommutationSource);
277
+HAL_StatusTypeDef HAL_TIMEx_ConfigCommutationEvent_IT(TIM_HandleTypeDef *htim, uint32_t  InputTrigger, uint32_t  CommutationSource);
278
+HAL_StatusTypeDef HAL_TIMEx_ConfigCommutationEvent_DMA(TIM_HandleTypeDef *htim, uint32_t  InputTrigger, uint32_t  CommutationSource);
279
+HAL_StatusTypeDef HAL_TIMEx_ConfigBreakDeadTime(TIM_HandleTypeDef *htim, TIM_BreakDeadTimeConfigTypeDef *sBreakDeadTimeConfig);
280
+#endif /* defined(STM32F100xB) || defined(STM32F100xE) ||                                                 */
281
+       /* defined(STM32F103x6) || defined(STM32F103xB) || defined(STM32F103xE) || defined(STM32F103xG) || */
282
+       /* defined(STM32F105xC) || defined(STM32F107xC)                                                    */
283
+HAL_StatusTypeDef HAL_TIMEx_MasterConfigSynchronization(TIM_HandleTypeDef *htim, TIM_MasterConfigTypeDef * sMasterConfig);
284
+/**
285
+  * @}
286
+  */
287
+
288
+/** @addtogroup TIMEx_Exported_Functions_Group6
289
+  * @{
290
+  */
291
+/* Extension Callback *********************************************************/
292
+void HAL_TIMEx_CommutationCallback(TIM_HandleTypeDef *htim);
293
+void HAL_TIMEx_BreakCallback(TIM_HandleTypeDef *htim);
294
+/**
295
+  * @}
296
+  */
297
+
298
+#if defined (STM32F100xB) || defined (STM32F100xE) ||                                                   \
299
+    defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F103xE) || defined (STM32F103xG) || \
300
+    defined (STM32F105xC) || defined (STM32F107xC)
301
+/** @addtogroup TIMEx_Exported_Functions_Group7
302
+  * @{
303
+  */
304
+/* Extension Peripheral State functions  **************************************/
305
+HAL_TIM_StateTypeDef HAL_TIMEx_HallSensor_GetState(TIM_HandleTypeDef *htim);
306
+/**
307
+  * @}
308
+  */
309
+#endif /* defined(STM32F100xB) || defined(STM32F100xE) ||                                                 */
310
+       /* defined(STM32F103x6) || defined(STM32F103xB) || defined(STM32F103xE) || defined(STM32F103xG) || */
311
+       /* defined(STM32F105xC) || defined(STM32F107xC)                                                    */
312
+
313
+/**
314
+  * @}
315
+  */ 
316
+/* End of exported functions -------------------------------------------------*/
317
+
318
+/* Private functions----------------------------------------------------------*/
319
+/** @defgroup TIMEx_Private_Functions TIMEx Private Functions
320
+* @{
321
+*/
322
+void TIMEx_DMACommutationCplt(DMA_HandleTypeDef *hdma);
323
+/**
324
+* @}
325
+*/ 
326
+/* End of private functions --------------------------------------------------*/
327
+
328
+/**
329
+  * @}
330
+  */ 
331
+
332
+/**
333
+  * @}
334
+  */
335
+  
336
+#ifdef __cplusplus
337
+}
338
+#endif
339
+
340
+
341
+#endif /* __STM32F1xx_HAL_TIM_EX_H */
342
+
343
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 785 - 0
Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_uart.h

@@ -0,0 +1,785 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx_hal_uart.h
4
+  * @author  MCD Application Team
5
+  * @brief   Header file of UART HAL module.
6
+  ******************************************************************************
7
+  * @attention
8
+  *
9
+  * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
10
+  *
11
+  * Redistribution and use in source and binary forms, with or without modification,
12
+  * are permitted provided that the following conditions are met:
13
+  *   1. Redistributions of source code must retain the above copyright notice,
14
+  *      this list of conditions and the following disclaimer.
15
+  *   2. Redistributions in binary form must reproduce the above copyright notice,
16
+  *      this list of conditions and the following disclaimer in the documentation
17
+  *      and/or other materials provided with the distribution.
18
+  *   3. Neither the name of STMicroelectronics nor the names of its contributors
19
+  *      may be used to endorse or promote products derived from this software
20
+  *      without specific prior written permission.
21
+  *
22
+  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
+  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25
+  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28
+  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29
+  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30
+  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
+  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
+  *
33
+  ******************************************************************************
34
+  */
35
+
36
+/* Define to prevent recursive inclusion -------------------------------------*/
37
+#ifndef __STM32F1xx_HAL_UART_H
38
+#define __STM32F1xx_HAL_UART_H
39
+
40
+#ifdef __cplusplus
41
+ extern "C" {
42
+#endif
43
+
44
+/* Includes ------------------------------------------------------------------*/
45
+#include "stm32f1xx_hal_def.h"
46
+
47
+/** @addtogroup STM32F1xx_HAL_Driver
48
+  * @{
49
+  */
50
+
51
+/** @addtogroup UART
52
+  * @{
53
+  */
54
+
55
+/* Exported types ------------------------------------------------------------*/ 
56
+/** @defgroup UART_Exported_Types UART Exported Types
57
+  * @{
58
+  */
59
+
60
+/**
61
+  * @brief UART Init Structure definition
62
+  */
63
+typedef struct
64
+{
65
+  uint32_t BaudRate;                  /*!< This member configures the UART communication baud rate.
66
+                                           The baud rate is computed using the following formula:
67
+                                           - IntegerDivider = ((PCLKx) / (16 * (huart->Init.BaudRate)))
68
+                                           - FractionalDivider = ((IntegerDivider - ((uint32_t) IntegerDivider)) * 16) + 0.5 */
69
+
70
+  uint32_t WordLength;                /*!< Specifies the number of data bits transmitted or received in a frame.
71
+                                           This parameter can be a value of @ref UART_Word_Length */
72
+
73
+  uint32_t StopBits;                  /*!< Specifies the number of stop bits transmitted.
74
+                                           This parameter can be a value of @ref UART_Stop_Bits */
75
+
76
+  uint32_t Parity;                    /*!< Specifies the parity mode.
77
+                                           This parameter can be a value of @ref UART_Parity
78
+                                           @note When parity is enabled, the computed parity is inserted
79
+                                                 at the MSB position of the transmitted data (9th bit when
80
+                                                 the word length is set to 9 data bits; 8th bit when the
81
+                                                 word length is set to 8 data bits). */
82
+
83
+  uint32_t Mode;                      /*!< Specifies whether the Receive or Transmit mode is enabled or disabled.
84
+                                           This parameter can be a value of @ref UART_Mode */
85
+
86
+  uint32_t HwFlowCtl;                 /*!< Specifies whether the hardware flow control mode is enabled or disabled.
87
+                                           This parameter can be a value of @ref UART_Hardware_Flow_Control */
88
+
89
+  uint32_t OverSampling;              /*!< Specifies whether the Over sampling 8 is enabled or disabled, to achieve higher speed (up to fPCLK/8).
90
+                                           This parameter can be a value of @ref UART_Over_Sampling. This feature is only available 
91
+                                           on STM32F100xx family, so OverSampling parameter should always be set to 16. */
92
+}UART_InitTypeDef;
93
+
94
+/** 
95
+  * @brief HAL UART State structures definition
96
+  * @note  HAL UART State value is a combination of 2 different substates: gState and RxState.
97
+  *        - gState contains UART state information related to global Handle management 
98
+  *          and also information related to Tx operations.
99
+  *          gState value coding follow below described bitmap :
100
+  *          b7-b6  Error information 
101
+  *             00 : No Error
102
+  *             01 : (Not Used)
103
+  *             10 : Timeout
104
+  *             11 : Error
105
+  *          b5     IP initilisation status
106
+  *             0  : Reset (IP not initialized)
107
+  *             1  : Init done (IP not initialized. HAL UART Init function already called)
108
+  *          b4-b3  (not used)
109
+  *             xx : Should be set to 00
110
+  *          b2     Intrinsic process state
111
+  *             0  : Ready
112
+  *             1  : Busy (IP busy with some configuration or internal operations)
113
+  *          b1     (not used)
114
+  *             x  : Should be set to 0
115
+  *          b0     Tx state
116
+  *             0  : Ready (no Tx operation ongoing)
117
+  *             1  : Busy (Tx operation ongoing)
118
+  *        - RxState contains information related to Rx operations.
119
+  *          RxState value coding follow below described bitmap :
120
+  *          b7-b6  (not used)
121
+  *             xx : Should be set to 00
122
+  *          b5     IP initilisation status
123
+  *             0  : Reset (IP not initialized)
124
+  *             1  : Init done (IP not initialized)
125
+  *          b4-b2  (not used)
126
+  *            xxx : Should be set to 000
127
+  *          b1     Rx state
128
+  *             0  : Ready (no Rx operation ongoing)
129
+  *             1  : Busy (Rx operation ongoing)
130
+  *          b0     (not used)
131
+  *             x  : Should be set to 0.
132
+  */
133
+typedef enum
134
+{
135
+  HAL_UART_STATE_RESET             = 0x00U,    /*!< Peripheral is not yet Initialized 
136
+                                                   Value is allowed for gState and RxState */
137
+  HAL_UART_STATE_READY             = 0x20U,    /*!< Peripheral Initialized and ready for use
138
+                                                   Value is allowed for gState and RxState */
139
+  HAL_UART_STATE_BUSY              = 0x24U,    /*!< an internal process is ongoing
140
+                                                   Value is allowed for gState only */
141
+  HAL_UART_STATE_BUSY_TX           = 0x21U,    /*!< Data Transmission process is ongoing 
142
+                                                   Value is allowed for gState only */
143
+  HAL_UART_STATE_BUSY_RX           = 0x22U,    /*!< Data Reception process is ongoing
144
+                                                   Value is allowed for RxState only */
145
+  HAL_UART_STATE_BUSY_TX_RX        = 0x23U,    /*!< Data Transmission and Reception process is ongoing 
146
+                                                   Not to be used for neither gState nor RxState.
147
+                                                   Value is result of combination (Or) between gState and RxState values */
148
+  HAL_UART_STATE_TIMEOUT           = 0xA0U,    /*!< Timeout state    
149
+                                                   Value is allowed for gState only */
150
+  HAL_UART_STATE_ERROR             = 0xE0U     /*!< Error   
151
+                                                   Value is allowed for gState only */
152
+}HAL_UART_StateTypeDef;
153
+
154
+/** 
155
+  * @brief  UART handle Structure definition
156
+  */
157
+typedef struct
158
+{
159
+  USART_TypeDef                 *Instance;        /*!< UART registers base address        */
160
+
161
+  UART_InitTypeDef              Init;             /*!< UART communication parameters      */
162
+
163
+  uint8_t                       *pTxBuffPtr;      /*!< Pointer to UART Tx transfer Buffer */
164
+
165
+  uint16_t                      TxXferSize;       /*!< UART Tx Transfer size              */
166
+
167
+  __IO uint16_t                 TxXferCount;      /*!< UART Tx Transfer Counter           */
168
+
169
+  uint8_t                       *pRxBuffPtr;      /*!< Pointer to UART Rx transfer Buffer */
170
+
171
+  uint16_t                      RxXferSize;       /*!< UART Rx Transfer size              */
172
+
173
+  __IO uint16_t                 RxXferCount;      /*!< UART Rx Transfer Counter           */
174
+
175
+  DMA_HandleTypeDef             *hdmatx;          /*!< UART Tx DMA Handle parameters      */
176
+
177
+  DMA_HandleTypeDef             *hdmarx;          /*!< UART Rx DMA Handle parameters      */
178
+
179
+  HAL_LockTypeDef               Lock;             /*!< Locking object                     */
180
+
181
+  __IO HAL_UART_StateTypeDef    gState;           /*!< UART state information related to global Handle management 
182
+                                                       and also related to Tx operations.
183
+                                                       This parameter can be a value of @ref HAL_UART_StateTypeDef */
184
+  
185
+  __IO HAL_UART_StateTypeDef    RxState;          /*!< UART state information related to Rx operations.
186
+                                                       This parameter can be a value of @ref HAL_UART_StateTypeDef */
187
+
188
+  __IO uint32_t                 ErrorCode;        /*!< UART Error code                    */
189
+}UART_HandleTypeDef;
190
+
191
+/**
192
+  * @}
193
+  */
194
+
195
+/* Exported constants --------------------------------------------------------*/
196
+/** @defgroup UART_Exported_Constants UART Exported constants
197
+  * @{
198
+  */
199
+
200
+/** @defgroup UART_Error_Code UART Error Code
201
+  * @{
202
+  */
203
+#define HAL_UART_ERROR_NONE         0x00000000U   /*!< No error            */
204
+#define HAL_UART_ERROR_PE           0x00000001U   /*!< Parity error        */
205
+#define HAL_UART_ERROR_NE           0x00000002U   /*!< Noise error         */
206
+#define HAL_UART_ERROR_FE           0x00000004U   /*!< Frame error         */
207
+#define HAL_UART_ERROR_ORE          0x00000008U   /*!< Overrun error       */
208
+#define HAL_UART_ERROR_DMA          0x00000010U   /*!< DMA transfer error  */
209
+/**
210
+  * @}
211
+  */
212
+
213
+/** @defgroup UART_Word_Length UART Word Length
214
+  * @{
215
+  */
216
+#define UART_WORDLENGTH_8B                  0x00000000U
217
+#define UART_WORDLENGTH_9B                  ((uint32_t)USART_CR1_M)
218
+/**
219
+  * @}
220
+  */
221
+
222
+/** @defgroup UART_Stop_Bits  UART Number of Stop Bits
223
+  * @{
224
+  */
225
+#define UART_STOPBITS_1                     0x00000000U
226
+#define UART_STOPBITS_2                     ((uint32_t)USART_CR2_STOP_1)
227
+/**
228
+  * @}
229
+  */
230
+
231
+/** @defgroup UART_Parity  UART Parity
232
+  * @{
233
+  */
234
+#define UART_PARITY_NONE                    0x00000000U
235
+#define UART_PARITY_EVEN                    ((uint32_t)USART_CR1_PCE)
236
+#define UART_PARITY_ODD                     ((uint32_t)(USART_CR1_PCE | USART_CR1_PS)) 
237
+/**
238
+  * @}
239
+  */
240
+
241
+/** @defgroup UART_Hardware_Flow_Control UART Hardware Flow Control
242
+  * @{
243
+  */
244
+#define UART_HWCONTROL_NONE                  0x00000000U
245
+#define UART_HWCONTROL_RTS                   ((uint32_t)USART_CR3_RTSE)
246
+#define UART_HWCONTROL_CTS                   ((uint32_t)USART_CR3_CTSE)
247
+#define UART_HWCONTROL_RTS_CTS               ((uint32_t)(USART_CR3_RTSE | USART_CR3_CTSE))
248
+/**
249
+  * @}
250
+  */
251
+
252
+/** @defgroup UART_Mode UART Transfer Mode
253
+  * @{
254
+  */ 
255
+#define UART_MODE_RX                        ((uint32_t)USART_CR1_RE)
256
+#define UART_MODE_TX                        ((uint32_t)USART_CR1_TE)
257
+#define UART_MODE_TX_RX                     ((uint32_t)(USART_CR1_TE |USART_CR1_RE))
258
+/**
259
+  * @}
260
+  */
261
+
262
+/** @defgroup UART_State  UART State
263
+  * @{
264
+  */
265
+#define UART_STATE_DISABLE                  0x00000000U
266
+#define UART_STATE_ENABLE                   ((uint32_t)USART_CR1_UE)
267
+/**
268
+  * @}
269
+  */
270
+
271
+
272
+/** @defgroup UART_Over_Sampling UART Over Sampling
273
+  * @{
274
+  */
275
+#define UART_OVERSAMPLING_16                    0x00000000U
276
+#if defined(USART_CR1_OVER8)
277
+#define UART_OVERSAMPLING_8                     ((uint32_t)USART_CR1_OVER8)
278
+#endif /* USART_CR1_OVER8 */
279
+/**
280
+  * @}
281
+  */
282
+
283
+
284
+/** @defgroup UART_LIN_Break_Detection_Length  UART LIN Break Detection Length
285
+  * @{
286
+  */  
287
+#define UART_LINBREAKDETECTLENGTH_10B      0x00000000U
288
+#define UART_LINBREAKDETECTLENGTH_11B      ((uint32_t)USART_CR2_LBDL)
289
+/**
290
+  * @}
291
+  */
292
+/** @defgroup UART_WakeUp_functions  UART Wakeup Functions
293
+  * @{
294
+  */
295
+#define UART_WAKEUPMETHOD_IDLELINE                0x00000000U
296
+#define UART_WAKEUPMETHOD_ADDRESSMARK             ((uint32_t)USART_CR1_WAKE)
297
+/**
298
+  * @}
299
+  */
300
+
301
+/** @defgroup UART_Flags   UART FLags
302
+  *        Elements values convention: 0xXXXX
303
+  *           - 0xXXXX  : Flag mask in the SR register
304
+  * @{
305
+  */
306
+#define UART_FLAG_CTS                       ((uint32_t)USART_SR_CTS)
307
+#define UART_FLAG_LBD                       ((uint32_t)USART_SR_LBD)
308
+#define UART_FLAG_TXE                       ((uint32_t)USART_SR_TXE)
309
+#define UART_FLAG_TC                        ((uint32_t)USART_SR_TC)
310
+#define UART_FLAG_RXNE                      ((uint32_t)USART_SR_RXNE)
311
+#define UART_FLAG_IDLE                      ((uint32_t)USART_SR_IDLE)
312
+#define UART_FLAG_ORE                       ((uint32_t)USART_SR_ORE)
313
+#define UART_FLAG_NE                        ((uint32_t)USART_SR_NE)
314
+#define UART_FLAG_FE                        ((uint32_t)USART_SR_FE)
315
+#define UART_FLAG_PE                        ((uint32_t)USART_SR_PE)
316
+/**
317
+  * @}
318
+  */
319
+
320
+/** @defgroup UART_Interrupt_definition  UART Interrupt Definitions
321
+  *        Elements values convention: 0xY000XXXX
322
+  *           - XXXX  : Interrupt mask (16 bits) in the Y register
323
+  *           - Y  : Interrupt source register (2bits)
324
+  *                   - 01: CR1 register
325
+  *                   - 10: CR2 register
326
+  *                   - 11: CR3 register
327
+  * @{
328
+  */
329
+
330
+#define UART_IT_PE                       ((uint32_t)(UART_CR1_REG_INDEX << 28U | USART_CR1_PEIE))
331
+#define UART_IT_TXE                      ((uint32_t)(UART_CR1_REG_INDEX << 28U | USART_CR1_TXEIE))
332
+#define UART_IT_TC                       ((uint32_t)(UART_CR1_REG_INDEX << 28U | USART_CR1_TCIE))
333
+#define UART_IT_RXNE                     ((uint32_t)(UART_CR1_REG_INDEX << 28U | USART_CR1_RXNEIE))
334
+#define UART_IT_IDLE                     ((uint32_t)(UART_CR1_REG_INDEX << 28U | USART_CR1_IDLEIE))
335
+
336
+#define UART_IT_LBD                      ((uint32_t)(UART_CR2_REG_INDEX << 28U | USART_CR2_LBDIE))
337
+
338
+#define UART_IT_CTS                      ((uint32_t)(UART_CR3_REG_INDEX << 28U | USART_CR3_CTSIE))
339
+#define UART_IT_ERR                      ((uint32_t)(UART_CR3_REG_INDEX << 28U | USART_CR3_EIE))
340
+/**
341
+  * @}
342
+  */
343
+
344
+/**
345
+  * @}
346
+  */
347
+
348
+/* Exported macro ------------------------------------------------------------*/
349
+/** @defgroup UART_Exported_Macros UART Exported Macros
350
+  * @{
351
+  */
352
+
353
+/** @brief Reset UART handle gstate & RxState
354
+  * @param  __HANDLE__: specifies the UART Handle.
355
+  *         UART Handle selects the USARTx or UARTy peripheral 
356
+  *         (USART,UART availability and x,y values depending on device).
357
+  */
358
+#define __HAL_UART_RESET_HANDLE_STATE(__HANDLE__)  do{                                                   \
359
+                                                       (__HANDLE__)->gState = HAL_UART_STATE_RESET;      \
360
+                                                       (__HANDLE__)->RxState = HAL_UART_STATE_RESET;     \
361
+                                                     } while(0U)
362
+
363
+/** @brief  Flushs the UART DR register 
364
+  * @param  __HANDLE__: specifies the UART Handle.
365
+  *         UART Handle selects the USARTx or UARTy peripheral 
366
+  *         (USART,UART availability and x,y values depending on device).
367
+  */
368
+#define __HAL_UART_FLUSH_DRREGISTER(__HANDLE__) ((__HANDLE__)->Instance->DR)
369
+
370
+/** @brief  Checks whether the specified UART flag is set or not.
371
+  * @param  __HANDLE__: specifies the UART Handle.
372
+  *         This parameter can be UARTx where x: 1, 2, 3, 4 or 5 to select the USART or 
373
+  *         UART peripheral.
374
+  * @param  __FLAG__: specifies the flag to check.
375
+  *        This parameter can be one of the following values:
376
+  *            @arg UART_FLAG_CTS:  CTS Change flag (not available for UART4 and UART5)
377
+  *            @arg UART_FLAG_LBD:  LIN Break detection flag
378
+  *            @arg UART_FLAG_TXE:  Transmit data register empty flag
379
+  *            @arg UART_FLAG_TC:   Transmission Complete flag
380
+  *            @arg UART_FLAG_RXNE: Receive data register not empty flag
381
+  *            @arg UART_FLAG_IDLE: Idle Line detection flag
382
+  *            @arg UART_FLAG_ORE:  OverRun Error flag
383
+  *            @arg UART_FLAG_NE:   Noise Error flag
384
+  *            @arg UART_FLAG_FE:   Framing Error flag
385
+  *            @arg UART_FLAG_PE:   Parity Error flag
386
+  * @retval The new state of __FLAG__ (TRUE or FALSE).
387
+  */
388
+#define __HAL_UART_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__))   
389
+
390
+/** @brief  Clears the specified UART pending flag.
391
+  * @param  __HANDLE__: specifies the UART Handle.
392
+  *         UART Handle selects the USARTx or UARTy peripheral 
393
+  *         (USART,UART availability and x,y values depending on device).
394
+  * @param  __FLAG__: specifies the flag to check.
395
+  *          This parameter can be any combination of the following values:
396
+  *            @arg UART_FLAG_CTS:  CTS Change flag (not available for UART4 and UART5).
397
+  *            @arg UART_FLAG_LBD:  LIN Break detection flag.
398
+  *            @arg UART_FLAG_TC:   Transmission Complete flag.
399
+  *            @arg UART_FLAG_RXNE: Receive data register not empty flag.
400
+  *   
401
+  * @note   PE (Parity error), FE (Framing error), NE (Noise error), ORE (OverRun 
402
+  *          error) and IDLE (Idle line detected) flags are cleared by software 
403
+  *          sequence: a read operation to USART_SR register followed by a read
404
+  *          operation to USART_DR register.
405
+  * @note   RXNE flag can be also cleared by a read to the USART_DR register.
406
+  * @note   TC flag can be also cleared by software sequence: a read operation to 
407
+  *          USART_SR register followed by a write operation to USART_DR register.
408
+  * @note   TXE flag is cleared only by a write to the USART_DR register.
409
+  *   
410
+  */
411
+#define __HAL_UART_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR = ~(__FLAG__))
412
+
413
+/** @brief  Clears the UART PE pending flag.
414
+  * @param  __HANDLE__: specifies the UART Handle.
415
+  *         UART Handle selects the USARTx or UARTy peripheral 
416
+  *         (USART,UART availability and x,y values depending on device).
417
+  */
418
+#define __HAL_UART_CLEAR_PEFLAG(__HANDLE__)     \
419
+  do{                                           \
420
+    __IO uint32_t tmpreg = 0x00U;               \
421
+    tmpreg = (__HANDLE__)->Instance->SR;        \
422
+    tmpreg = (__HANDLE__)->Instance->DR;        \
423
+    UNUSED(tmpreg);                             \
424
+  } while(0U)
425
+
426
+/** @brief  Clears the UART FE pending flag.
427
+  * @param  __HANDLE__: specifies the UART Handle.
428
+  *         UART Handle selects the USARTx or UARTy peripheral 
429
+  *         (USART,UART availability and x,y values depending on device).
430
+  */
431
+#define __HAL_UART_CLEAR_FEFLAG(__HANDLE__) __HAL_UART_CLEAR_PEFLAG(__HANDLE__)
432
+
433
+/** @brief  Clears the UART NE pending flag.
434
+  * @param  __HANDLE__: specifies the UART Handle.
435
+  *         UART Handle selects the USARTx or UARTy peripheral 
436
+  *         (USART,UART availability and x,y values depending on device).
437
+  */
438
+#define __HAL_UART_CLEAR_NEFLAG(__HANDLE__) __HAL_UART_CLEAR_PEFLAG(__HANDLE__)
439
+
440
+/** @brief  Clears the UART ORE pending flag.
441
+  * @param  __HANDLE__: specifies the UART Handle.
442
+  *         UART Handle selects the USARTx or UARTy peripheral 
443
+  *         (USART,UART availability and x,y values depending on device).
444
+  */
445
+#define __HAL_UART_CLEAR_OREFLAG(__HANDLE__) __HAL_UART_CLEAR_PEFLAG(__HANDLE__)
446
+
447
+/** @brief  Clears the UART IDLE pending flag.
448
+  * @param  __HANDLE__: specifies the UART Handle.
449
+  *         UART Handle selects the USARTx or UARTy peripheral 
450
+  *         (USART,UART availability and x,y values depending on device).
451
+  */
452
+#define __HAL_UART_CLEAR_IDLEFLAG(__HANDLE__) __HAL_UART_CLEAR_PEFLAG(__HANDLE__)
453
+
454
+/** @brief  Enable the specified UART interrupt.
455
+  * @param  __HANDLE__: specifies the UART Handle.
456
+  *         UART Handle selects the USARTx or UARTy peripheral 
457
+  *         (USART,UART availability and x,y values depending on device).
458
+  * @param  __INTERRUPT__: specifies the UART interrupt source to enable.
459
+  *          This parameter can be one of the following values:
460
+  *            @arg UART_IT_CTS:  CTS change interrupt
461
+  *            @arg UART_IT_LBD:  LIN Break detection interrupt
462
+  *            @arg UART_IT_TXE:  Transmit Data Register empty interrupt
463
+  *            @arg UART_IT_TC:   Transmission complete interrupt
464
+  *            @arg UART_IT_RXNE: Receive Data register not empty interrupt
465
+  *            @arg UART_IT_IDLE: Idle line detection interrupt
466
+  *            @arg UART_IT_PE:   Parity Error interrupt
467
+  *            @arg UART_IT_ERR:  Error interrupt(Frame error, noise error, overrun error)
468
+  */
469
+#define __HAL_UART_ENABLE_IT(__HANDLE__, __INTERRUPT__)   ((((__INTERRUPT__) >> 28U) == UART_CR1_REG_INDEX)? ((__HANDLE__)->Instance->CR1 |= ((__INTERRUPT__) & UART_IT_MASK)): \
470
+                                                           (((__INTERRUPT__) >> 28U) == UART_CR2_REG_INDEX)? ((__HANDLE__)->Instance->CR2 |= ((__INTERRUPT__) & UART_IT_MASK)): \
471
+                                                           ((__HANDLE__)->Instance->CR3 |= ((__INTERRUPT__) & UART_IT_MASK)))
472
+
473
+/** @brief  Disable the specified UART interrupt.
474
+  * @param  __HANDLE__: specifies the UART Handle.
475
+  *         UART Handle selects the USARTx or UARTy peripheral 
476
+  *         (USART,UART availability and x,y values depending on device).
477
+  * @param  __INTERRUPT__: specifies the UART interrupt source to disable.
478
+  *          This parameter can be one of the following values:
479
+  *            @arg UART_IT_CTS:  CTS change interrupt
480
+  *            @arg UART_IT_LBD:  LIN Break detection interrupt
481
+  *            @arg UART_IT_TXE:  Transmit Data Register empty interrupt
482
+  *            @arg UART_IT_TC:   Transmission complete interrupt
483
+  *            @arg UART_IT_RXNE: Receive Data register not empty interrupt
484
+  *            @arg UART_IT_IDLE: Idle line detection interrupt
485
+  *            @arg UART_IT_PE:   Parity Error interrupt
486
+  *            @arg UART_IT_ERR:  Error interrupt(Frame error, noise error, overrun error)
487
+  */
488
+#define __HAL_UART_DISABLE_IT(__HANDLE__, __INTERRUPT__)  ((((__INTERRUPT__) >> 28U) == UART_CR1_REG_INDEX)? ((__HANDLE__)->Instance->CR1 &= ~((__INTERRUPT__) & UART_IT_MASK)): \
489
+                                                           (((__INTERRUPT__) >> 28U) == UART_CR2_REG_INDEX)? ((__HANDLE__)->Instance->CR2 &= ~((__INTERRUPT__) & UART_IT_MASK)): \
490
+                                                           ((__HANDLE__)->Instance->CR3 &= ~ ((__INTERRUPT__) & UART_IT_MASK)))
491
+
492
+/** @brief  Checks whether the specified UART interrupt has occurred or not.
493
+  * @param  __HANDLE__: specifies the UART Handle.
494
+  *         UART Handle selects the USARTx or UARTy peripheral 
495
+  *         (USART,UART availability and x,y values depending on device).
496
+  * @param  __IT__: specifies the UART interrupt source to check.
497
+  *          This parameter can be one of the following values:
498
+  *            @arg UART_IT_CTS: CTS change interrupt (not available for UART4 and UART5)
499
+  *            @arg UART_IT_LBD: LIN Break detection interrupt
500
+  *            @arg UART_IT_TXE: Transmit Data Register empty interrupt
501
+  *            @arg UART_IT_TC:  Transmission complete interrupt
502
+  *            @arg UART_IT_RXNE: Receive Data register not empty interrupt
503
+  *            @arg UART_IT_IDLE: Idle line detection interrupt
504
+  *            @arg UART_IT_ERR: Error interrupt
505
+  * @retval The new state of __IT__ (TRUE or FALSE).
506
+  */
507
+#define __HAL_UART_GET_IT_SOURCE(__HANDLE__, __IT__) (((((__IT__) >> 28U) == UART_CR1_REG_INDEX)? (__HANDLE__)->Instance->CR1:(((((uint32_t)(__IT__)) >> 28U) == UART_CR2_REG_INDEX)? \
508
+                                                      (__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & (((uint32_t)(__IT__)) & UART_IT_MASK))
509
+
510
+/** @brief  Enable CTS flow control 
511
+  *         This macro allows to enable CTS hardware flow control for a given UART instance, 
512
+  *         without need to call HAL_UART_Init() function.
513
+  *         As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
514
+  * @note   As macro is expected to be used for modifying CTS Hw flow control feature activation, without need
515
+  *         for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
516
+  *           - UART instance should have already been initialised (through call of HAL_UART_Init() )
517
+  *           - macro could only be called when corresponding UART instance is disabled (i.e __HAL_UART_DISABLE(__HANDLE__))
518
+  *             and should be followed by an Enable macro (i.e __HAL_UART_ENABLE(__HANDLE__)).                                                                                                                  
519
+  * @param  __HANDLE__: specifies the UART Handle.
520
+  *         The Handle Instance can be any USARTx (supporting the HW Flow control feature).
521
+  *         It is used to select the USART peripheral (USART availability and x value depending on device).
522
+  */
523
+#define __HAL_UART_HWCONTROL_CTS_ENABLE(__HANDLE__)        \
524
+  do{                                                      \
525
+    SET_BIT((__HANDLE__)->Instance->CR3, USART_CR3_CTSE);  \
526
+    (__HANDLE__)->Init.HwFlowCtl |= USART_CR3_CTSE;        \
527
+  } while(0U)
528
+
529
+/** @brief  Disable CTS flow control 
530
+  *         This macro allows to disable CTS hardware flow control for a given UART instance, 
531
+  *         without need to call HAL_UART_Init() function.
532
+  *         As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
533
+  * @note   As macro is expected to be used for modifying CTS Hw flow control feature activation, without need
534
+  *         for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
535
+  *           - UART instance should have already been initialised (through call of HAL_UART_Init() )
536
+  *           - macro could only be called when corresponding UART instance is disabled (i.e __HAL_UART_DISABLE(__HANDLE__))
537
+  *             and should be followed by an Enable macro (i.e __HAL_UART_ENABLE(__HANDLE__)). 
538
+  * @param  __HANDLE__: specifies the UART Handle.
539
+  *         The Handle Instance can be any USARTx (supporting the HW Flow control feature).
540
+  *         It is used to select the USART peripheral (USART availability and x value depending on device).
541
+  */
542
+#define __HAL_UART_HWCONTROL_CTS_DISABLE(__HANDLE__)        \
543
+  do{                                                       \
544
+    CLEAR_BIT((__HANDLE__)->Instance->CR3, USART_CR3_CTSE); \
545
+    (__HANDLE__)->Init.HwFlowCtl &= ~(USART_CR3_CTSE);      \
546
+  } while(0U)
547
+
548
+/** @brief  Enable RTS flow control 
549
+  *         This macro allows to enable RTS hardware flow control for a given UART instance, 
550
+  *         without need to call HAL_UART_Init() function.
551
+  *         As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
552
+  * @note   As macro is expected to be used for modifying RTS Hw flow control feature activation, without need
553
+  *         for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
554
+  *           - UART instance should have already been initialised (through call of HAL_UART_Init() )
555
+  *           - macro could only be called when corresponding UART instance is disabled (i.e __HAL_UART_DISABLE(__HANDLE__))
556
+  *             and should be followed by an Enable macro (i.e __HAL_UART_ENABLE(__HANDLE__)). 
557
+  * @param  __HANDLE__: specifies the UART Handle.
558
+  *         The Handle Instance can be any USARTx (supporting the HW Flow control feature).
559
+  *         It is used to select the USART peripheral (USART availability and x value depending on device).
560
+  */
561
+#define __HAL_UART_HWCONTROL_RTS_ENABLE(__HANDLE__)       \
562
+  do{                                                     \
563
+    SET_BIT((__HANDLE__)->Instance->CR3, USART_CR3_RTSE); \
564
+    (__HANDLE__)->Init.HwFlowCtl |= USART_CR3_RTSE;       \
565
+  } while(0U)
566
+
567
+/** @brief  Disable RTS flow control 
568
+  *         This macro allows to disable RTS hardware flow control for a given UART instance, 
569
+  *         without need to call HAL_UART_Init() function.
570
+  *         As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
571
+  * @note   As macro is expected to be used for modifying RTS Hw flow control feature activation, without need
572
+  *         for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
573
+  *           - UART instance should have already been initialised (through call of HAL_UART_Init() )
574
+  *           - macro could only be called when corresponding UART instance is disabled (i.e __HAL_UART_DISABLE(__HANDLE__))
575
+  *             and should be followed by an Enable macro (i.e __HAL_UART_ENABLE(__HANDLE__)). 
576
+  * @param  __HANDLE__: specifies the UART Handle.
577
+  *         The Handle Instance can be any USARTx (supporting the HW Flow control feature).
578
+  *         It is used to select the USART peripheral (USART availability and x value depending on device).
579
+  */
580
+#define __HAL_UART_HWCONTROL_RTS_DISABLE(__HANDLE__)       \
581
+  do{                                                      \
582
+    CLEAR_BIT((__HANDLE__)->Instance->CR3, USART_CR3_RTSE);\
583
+    (__HANDLE__)->Init.HwFlowCtl &= ~(USART_CR3_RTSE);     \
584
+  } while(0U)
585
+
586
+#if defined(USART_CR3_ONEBIT)
587
+/** @brief  macros to enables the UART's one bit sample method
588
+  * @param  __HANDLE__: specifies the UART Handle.  
589
+  */
590
+#define __HAL_UART_ONE_BIT_SAMPLE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT)
591
+
592
+/** @brief  macros to disables the UART's one bit sample method
593
+  * @param  __HANDLE__: specifies the UART Handle.  
594
+  * @retval None
595
+  */
596
+#define __HAL_UART_ONE_BIT_SAMPLE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3 &= (uint16_t)~((uint16_t)USART_CR3_ONEBIT))
597
+#endif /* USART_CR3_ONEBIT */
598
+
599
+/** @brief  Enable UART
600
+  * @param  __HANDLE__: specifies the UART Handle.
601
+  */
602
+#define __HAL_UART_ENABLE(__HANDLE__)               ((__HANDLE__)->Instance->CR1 |=  USART_CR1_UE)
603
+
604
+/** @brief  Disable UART
605
+  * @param  __HANDLE__: specifies the UART Handle.
606
+  */
607
+#define __HAL_UART_DISABLE(__HANDLE__)              ((__HANDLE__)->Instance->CR1 &=  ~USART_CR1_UE)
608
+/**
609
+  * @}
610
+  */
611
+/* Exported functions --------------------------------------------------------*/
612
+/** @addtogroup UART_Exported_Functions
613
+  * @{
614
+  */
615
+
616
+/** @addtogroup UART_Exported_Functions_Group1
617
+  * @{
618
+  */
619
+/* Initialization/de-initialization functions  **********************************/
620
+HAL_StatusTypeDef HAL_UART_Init(UART_HandleTypeDef *huart);
621
+HAL_StatusTypeDef HAL_HalfDuplex_Init(UART_HandleTypeDef *huart);
622
+HAL_StatusTypeDef HAL_LIN_Init(UART_HandleTypeDef *huart, uint32_t BreakDetectLength);
623
+HAL_StatusTypeDef HAL_MultiProcessor_Init(UART_HandleTypeDef *huart, uint8_t Address, uint32_t WakeUpMethod);
624
+HAL_StatusTypeDef HAL_UART_DeInit (UART_HandleTypeDef *huart);
625
+void HAL_UART_MspInit(UART_HandleTypeDef *huart);
626
+void HAL_UART_MspDeInit(UART_HandleTypeDef *huart);
627
+/**
628
+  * @}
629
+  */
630
+
631
+/** @addtogroup UART_Exported_Functions_Group2
632
+  * @{
633
+  */
634
+/* IO operation functions *******************************************************/
635
+HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout);
636
+HAL_StatusTypeDef HAL_UART_Receive(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout);
637
+HAL_StatusTypeDef HAL_UART_Transmit_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
638
+HAL_StatusTypeDef HAL_UART_Receive_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
639
+HAL_StatusTypeDef HAL_UART_Transmit_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
640
+HAL_StatusTypeDef HAL_UART_Receive_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
641
+HAL_StatusTypeDef HAL_UART_DMAPause(UART_HandleTypeDef *huart);
642
+HAL_StatusTypeDef HAL_UART_DMAResume(UART_HandleTypeDef *huart);
643
+HAL_StatusTypeDef HAL_UART_DMAStop(UART_HandleTypeDef *huart);
644
+/* Transfer Abort functions */
645
+HAL_StatusTypeDef HAL_UART_Abort(UART_HandleTypeDef *huart);
646
+HAL_StatusTypeDef HAL_UART_AbortTransmit(UART_HandleTypeDef *huart);
647
+HAL_StatusTypeDef HAL_UART_AbortReceive(UART_HandleTypeDef *huart);
648
+HAL_StatusTypeDef HAL_UART_Abort_IT(UART_HandleTypeDef *huart);
649
+HAL_StatusTypeDef HAL_UART_AbortTransmit_IT(UART_HandleTypeDef *huart);
650
+HAL_StatusTypeDef HAL_UART_AbortReceive_IT(UART_HandleTypeDef *huart);
651
+
652
+void HAL_UART_IRQHandler(UART_HandleTypeDef *huart);
653
+void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart);
654
+void HAL_UART_TxHalfCpltCallback(UART_HandleTypeDef *huart);
655
+void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart);
656
+void HAL_UART_RxHalfCpltCallback(UART_HandleTypeDef *huart);
657
+void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart);
658
+void HAL_UART_AbortCpltCallback (UART_HandleTypeDef *huart);
659
+void HAL_UART_AbortTransmitCpltCallback (UART_HandleTypeDef *huart);
660
+void HAL_UART_AbortReceiveCpltCallback (UART_HandleTypeDef *huart);
661
+/**
662
+  * @}
663
+  */
664
+
665
+/** @addtogroup UART_Exported_Functions_Group3
666
+  * @{
667
+  */
668
+/* Peripheral Control functions  ************************************************/
669
+HAL_StatusTypeDef HAL_LIN_SendBreak(UART_HandleTypeDef *huart);
670
+HAL_StatusTypeDef HAL_MultiProcessor_EnterMuteMode(UART_HandleTypeDef *huart);
671
+HAL_StatusTypeDef HAL_MultiProcessor_ExitMuteMode(UART_HandleTypeDef *huart);
672
+HAL_StatusTypeDef HAL_HalfDuplex_EnableTransmitter(UART_HandleTypeDef *huart);
673
+HAL_StatusTypeDef HAL_HalfDuplex_EnableReceiver(UART_HandleTypeDef *huart);
674
+/**
675
+  * @}
676
+  */
677
+
678
+/** @addtogroup UART_Exported_Functions_Group4
679
+  * @{
680
+  */
681
+/* Peripheral State functions  **************************************************/
682
+HAL_UART_StateTypeDef HAL_UART_GetState(UART_HandleTypeDef *huart);
683
+uint32_t HAL_UART_GetError(UART_HandleTypeDef *huart);
684
+/**
685
+  * @}
686
+  */
687
+
688
+/**
689
+  * @}
690
+  */
691
+/* Private types -------------------------------------------------------------*/
692
+/* Private variables ---------------------------------------------------------*/
693
+/* Private constants ---------------------------------------------------------*/
694
+/** @defgroup UART_Private_Constants UART Private Constants
695
+  * @{
696
+  */
697
+/** @brief UART interruptions flag mask
698
+  * 
699
+  */
700
+#define UART_IT_MASK                     0x0000FFFFU
701
+
702
+#define UART_CR1_REG_INDEX               1U
703
+#define UART_CR2_REG_INDEX               2U
704
+#define UART_CR3_REG_INDEX               3U
705
+/**
706
+  * @}
707
+  */
708
+
709
+/* Private macros ------------------------------------------------------------*/
710
+/** @defgroup UART_Private_Macros UART Private Macros
711
+  * @{
712
+  */
713
+#define IS_UART_WORD_LENGTH(LENGTH) (((LENGTH) == UART_WORDLENGTH_8B) || \
714
+                                     ((LENGTH) == UART_WORDLENGTH_9B))
715
+#define IS_UART_LIN_WORD_LENGTH(LENGTH) (((LENGTH) == UART_WORDLENGTH_8B))
716
+#define IS_UART_STOPBITS(STOPBITS) (((STOPBITS) == UART_STOPBITS_1) || \
717
+                                    ((STOPBITS) == UART_STOPBITS_2))
718
+#define IS_UART_PARITY(PARITY) (((PARITY) == UART_PARITY_NONE) || \
719
+                                ((PARITY) == UART_PARITY_EVEN) || \
720
+                                ((PARITY) == UART_PARITY_ODD))
721
+#define IS_UART_HARDWARE_FLOW_CONTROL(CONTROL)\
722
+                              (((CONTROL) == UART_HWCONTROL_NONE) || \
723
+                               ((CONTROL) == UART_HWCONTROL_RTS) || \
724
+                               ((CONTROL) == UART_HWCONTROL_CTS) || \
725
+                               ((CONTROL) == UART_HWCONTROL_RTS_CTS))
726
+#define IS_UART_MODE(MODE) ((((MODE) & 0x0000FFF3U) == 0x00U) && ((MODE) != 0x00U))
727
+#define IS_UART_STATE(STATE) (((STATE) == UART_STATE_DISABLE) || \
728
+                              ((STATE) == UART_STATE_ENABLE))
729
+#if defined(USART_CR1_OVER8)
730
+#define IS_UART_OVERSAMPLING(SAMPLING) (((SAMPLING) == UART_OVERSAMPLING_16) || \
731
+                                        ((SAMPLING) == UART_OVERSAMPLING_8))
732
+#endif /* USART_CR1_OVER8 */
733
+#define IS_UART_LIN_OVERSAMPLING(SAMPLING) (((SAMPLING) == UART_OVERSAMPLING_16))
734
+#define IS_UART_LIN_BREAK_DETECT_LENGTH(LENGTH) (((LENGTH) == UART_LINBREAKDETECTLENGTH_10B) || \
735
+                                                 ((LENGTH) == UART_LINBREAKDETECTLENGTH_11B))
736
+#define IS_UART_WAKEUPMETHOD(WAKEUP) (((WAKEUP) == UART_WAKEUPMETHOD_IDLELINE) || \
737
+                                      ((WAKEUP) == UART_WAKEUPMETHOD_ADDRESSMARK))
738
+#define IS_UART_BAUDRATE(BAUDRATE) ((BAUDRATE) < 4500001U)
739
+#define IS_UART_ADDRESS(ADDRESS) ((ADDRESS) <= 0x0FU)
740
+
741
+#define UART_DIV_SAMPLING16(_PCLK_, _BAUD_)            (((_PCLK_)*25U)/(4U*(_BAUD_)))
742
+#define UART_DIVMANT_SAMPLING16(_PCLK_, _BAUD_)        (UART_DIV_SAMPLING16((_PCLK_), (_BAUD_))/100U)
743
+#define UART_DIVFRAQ_SAMPLING16(_PCLK_, _BAUD_)        (((UART_DIV_SAMPLING16((_PCLK_), (_BAUD_)) - (UART_DIVMANT_SAMPLING16((_PCLK_), (_BAUD_)) * 100U)) * 16U + 50U) / 100U)
744
+/* UART BRR = mantissa + overflow + fraction
745
+            = (UART DIVMANT << 4) + (UART DIVFRAQ & 0xF0) + (UART DIVFRAQ & 0x0FU) */
746
+#define UART_BRR_SAMPLING16(_PCLK_, _BAUD_)            (((UART_DIVMANT_SAMPLING16((_PCLK_), (_BAUD_)) << 4U) + \
747
+                                                        (UART_DIVFRAQ_SAMPLING16((_PCLK_), (_BAUD_)) & 0xF0U)) + \
748
+                                                        (UART_DIVFRAQ_SAMPLING16((_PCLK_), (_BAUD_)) & 0x0FU))
749
+
750
+#define UART_DIV_SAMPLING8(_PCLK_, _BAUD_)             (((_PCLK_)*25U)/(2U*(_BAUD_)))
751
+#define UART_DIVMANT_SAMPLING8(_PCLK_, _BAUD_)         (UART_DIV_SAMPLING8((_PCLK_), (_BAUD_))/100U)
752
+#define UART_DIVFRAQ_SAMPLING8(_PCLK_, _BAUD_)         (((UART_DIV_SAMPLING8((_PCLK_), (_BAUD_)) - (UART_DIVMANT_SAMPLING8((_PCLK_), (_BAUD_)) * 100U)) * 8U + 50U) / 100U)
753
+/* UART BRR = mantissa + overflow + fraction
754
+            = (UART DIVMANT << 4) + ((UART DIVFRAQ & 0xF8) << 1) + (UART DIVFRAQ & 0x07U) */
755
+#define UART_BRR_SAMPLING8(_PCLK_, _BAUD_)             (((UART_DIVMANT_SAMPLING8((_PCLK_), (_BAUD_)) << 4U) + \
756
+                                                        ((UART_DIVFRAQ_SAMPLING8((_PCLK_), (_BAUD_)) & 0xF8U) << 1U)) + \
757
+                                                        (UART_DIVFRAQ_SAMPLING8((_PCLK_), (_BAUD_)) & 0x07U))
758
+/**
759
+  * @}
760
+  */
761
+
762
+/* Private functions ---------------------------------------------------------*/
763
+/** @defgroup UART_Private_Functions UART Private Functions
764
+  * @{
765
+  */
766
+
767
+/**
768
+  * @}
769
+  */
770
+
771
+/**
772
+  * @}
773
+  */ 
774
+
775
+/**
776
+  * @}
777
+  */
778
+
779
+#ifdef __cplusplus
780
+}
781
+#endif
782
+
783
+#endif /* __STM32F1xx_HAL_UART_H */
784
+
785
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 595 - 0
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c

@@ -0,0 +1,595 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx_hal.c
4
+  * @author  MCD Application Team
5
+  * @brief   HAL module driver.
6
+  *          This is the common part of the HAL initialization
7
+  *
8
+  @verbatim
9
+  ==============================================================================
10
+                     ##### How to use this driver #####
11
+  ==============================================================================
12
+    [..]
13
+    The common HAL driver contains a set of generic and common APIs that can be
14
+    used by the PPP peripheral drivers and the user to start using the HAL.
15
+    [..]
16
+    The HAL contains two APIs' categories:
17
+         (+) Common HAL APIs
18
+         (+) Services HAL APIs
19
+
20
+  @endverbatim
21
+  ******************************************************************************
22
+  * @attention
23
+  *
24
+  * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
25
+  *
26
+  * Redistribution and use in source and binary forms, with or without modification,
27
+  * are permitted provided that the following conditions are met:
28
+  *   1. Redistributions of source code must retain the above copyright notice,
29
+  *      this list of conditions and the following disclaimer.
30
+  *   2. Redistributions in binary form must reproduce the above copyright notice,
31
+  *      this list of conditions and the following disclaimer in the documentation
32
+  *      and/or other materials provided with the distribution.
33
+  *   3. Neither the name of STMicroelectronics nor the names of its contributors
34
+  *      may be used to endorse or promote products derived from this software
35
+  *      without specific prior written permission.
36
+  *
37
+  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
38
+  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
39
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
40
+  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
41
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
42
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
43
+  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
44
+  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45
+  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
46
+  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
47
+  *
48
+  ******************************************************************************
49
+  */
50
+
51
+/* Includes ------------------------------------------------------------------*/
52
+#include "stm32f1xx_hal.h"
53
+
54
+/** @addtogroup STM32F1xx_HAL_Driver
55
+  * @{
56
+  */
57
+
58
+/** @defgroup HAL HAL
59
+  * @brief HAL module driver.
60
+  * @{
61
+  */
62
+
63
+#ifdef HAL_MODULE_ENABLED
64
+
65
+/* Private typedef -----------------------------------------------------------*/
66
+/* Private define ------------------------------------------------------------*/
67
+
68
+/** @defgroup HAL_Private_Constants HAL Private Constants
69
+  * @{
70
+  */
71
+/**
72
+ * @brief STM32F1xx HAL Driver version number V1.1.3
73
+   */
74
+#define __STM32F1xx_HAL_VERSION_MAIN   (0x01U) /*!< [31:24] main version */
75
+#define __STM32F1xx_HAL_VERSION_SUB1   (0x01U) /*!< [23:16] sub1 version */
76
+#define __STM32F1xx_HAL_VERSION_SUB2   (0x03U) /*!< [15:8]  sub2 version */
77
+#define __STM32F1xx_HAL_VERSION_RC     (0x00U) /*!< [7:0]  release candidate */
78
+#define __STM32F1xx_HAL_VERSION         ((__STM32F1xx_HAL_VERSION_MAIN << 24)\
79
+                                        |(__STM32F1xx_HAL_VERSION_SUB1 << 16)\
80
+                                        |(__STM32F1xx_HAL_VERSION_SUB2 << 8 )\
81
+                                        |(__STM32F1xx_HAL_VERSION_RC))
82
+
83
+#define IDCODE_DEVID_MASK    0x00000FFFU
84
+
85
+/**
86
+  * @}
87
+  */
88
+
89
+/* Private macro -------------------------------------------------------------*/
90
+/* Private variables ---------------------------------------------------------*/
91
+
92
+/** @defgroup HAL_Private_Variables HAL Private Variables
93
+  * @{
94
+  */
95
+__IO uint32_t uwTick;
96
+uint32_t uwTickPrio   = (1UL << __NVIC_PRIO_BITS); /* Invalid PRIO */
97
+HAL_TickFreqTypeDef uwTickFreq = HAL_TICK_FREQ_DEFAULT;  /* 1KHz */
98
+/**
99
+  * @}
100
+  */
101
+/* Private function prototypes -----------------------------------------------*/
102
+/* Exported functions ---------------------------------------------------------*/
103
+
104
+/** @defgroup HAL_Exported_Functions HAL Exported Functions
105
+  * @{
106
+  */
107
+
108
+/** @defgroup HAL_Exported_Functions_Group1 Initialization and de-initialization Functions
109
+ *  @brief    Initialization and de-initialization functions
110
+ *
111
+@verbatim
112
+ ===============================================================================
113
+              ##### Initialization and de-initialization functions #####
114
+ ===============================================================================
115
+   [..]  This section provides functions allowing to:
116
+      (+) Initializes the Flash interface, the NVIC allocation and initial clock
117
+          configuration. It initializes the systick also when timeout is needed
118
+          and the backup domain when enabled.
119
+      (+) de-Initializes common part of the HAL.
120
+      (+) Configure The time base source to have 1ms time base with a dedicated
121
+          Tick interrupt priority.
122
+        (++) SysTick timer is used by default as source of time base, but user
123
+             can eventually implement his proper time base source (a general purpose
124
+             timer for example or other time source), keeping in mind that Time base
125
+             duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
126
+             handled in milliseconds basis.
127
+        (++) Time base configuration function (HAL_InitTick ()) is called automatically
128
+             at the beginning of the program after reset by HAL_Init() or at any time
129
+             when clock is configured, by HAL_RCC_ClockConfig().
130
+        (++) Source of time base is configured  to generate interrupts at regular
131
+             time intervals. Care must be taken if HAL_Delay() is called from a
132
+             peripheral ISR process, the Tick interrupt line must have higher priority
133
+            (numerically lower) than the peripheral interrupt. Otherwise the caller
134
+            ISR process will be blocked.
135
+       (++) functions affecting time base configurations are declared as __weak
136
+             to make  override possible  in case of other  implementations in user file.
137
+@endverbatim
138
+  * @{
139
+  */
140
+
141
+/**
142
+  * @brief  This function is used to initialize the HAL Library; it must be the first
143
+  *         instruction to be executed in the main program (before to call any other
144
+  *         HAL function), it performs the following:
145
+  *           Configure the Flash prefetch.
146
+  *           Configures the SysTick to generate an interrupt each 1 millisecond,
147
+  *           which is clocked by the HSI (at this stage, the clock is not yet
148
+  *           configured and thus the system is running from the internal HSI at 16 MHz).
149
+  *           Set NVIC Group Priority to 4.
150
+  *           Calls the HAL_MspInit() callback function defined in user file
151
+  *           "stm32f1xx_hal_msp.c" to do the global low level hardware initialization
152
+  *
153
+  * @note   SysTick is used as time base for the HAL_Delay() function, the application
154
+  *         need to ensure that the SysTick time base is always set to 1 millisecond
155
+  *         to have correct HAL operation.
156
+  * @retval HAL status
157
+  */
158
+HAL_StatusTypeDef HAL_Init(void)
159
+{
160
+  /* Configure Flash prefetch */
161
+#if (PREFETCH_ENABLE != 0)
162
+#if defined(STM32F101x6) || defined(STM32F101xB) || defined(STM32F101xE) || defined(STM32F101xG) || \
163
+    defined(STM32F102x6) || defined(STM32F102xB) || \
164
+    defined(STM32F103x6) || defined(STM32F103xB) || defined(STM32F103xE) || defined(STM32F103xG) || \
165
+    defined(STM32F105xC) || defined(STM32F107xC)
166
+
167
+  /* Prefetch buffer is not available on value line devices */
168
+  __HAL_FLASH_PREFETCH_BUFFER_ENABLE();
169
+#endif
170
+#endif /* PREFETCH_ENABLE */
171
+
172
+  /* Set Interrupt Group Priority */
173
+  HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
174
+
175
+  /* Use systick as time base source and configure 1ms tick (default clock after Reset is HSI) */
176
+  HAL_InitTick(TICK_INT_PRIORITY);
177
+
178
+  /* Init the low level hardware */
179
+  HAL_MspInit();
180
+
181
+  /* Return function status */
182
+  return HAL_OK;
183
+}
184
+
185
+/**
186
+  * @brief This function de-Initializes common part of the HAL and stops the systick.
187
+  *        of time base.
188
+  * @note This function is optional.
189
+  * @retval HAL status
190
+  */
191
+HAL_StatusTypeDef HAL_DeInit(void)
192
+{
193
+  /* Reset of all peripherals */
194
+  __HAL_RCC_APB1_FORCE_RESET();
195
+  __HAL_RCC_APB1_RELEASE_RESET();
196
+
197
+  __HAL_RCC_APB2_FORCE_RESET();
198
+  __HAL_RCC_APB2_RELEASE_RESET();
199
+
200
+#if defined(STM32F105xC) || defined(STM32F107xC)
201
+  __HAL_RCC_AHB_FORCE_RESET();
202
+  __HAL_RCC_AHB_RELEASE_RESET();
203
+#endif
204
+
205
+  /* De-Init the low level hardware */
206
+  HAL_MspDeInit();
207
+
208
+  /* Return function status */
209
+  return HAL_OK;
210
+}
211
+
212
+/**
213
+  * @brief  Initialize the MSP.
214
+  * @retval None
215
+  */
216
+__weak void HAL_MspInit(void)
217
+{
218
+  /* NOTE : This function should not be modified, when the callback is needed,
219
+            the HAL_MspInit could be implemented in the user file
220
+   */
221
+}
222
+
223
+/**
224
+  * @brief  DeInitializes the MSP.
225
+  * @retval None
226
+  */
227
+__weak void HAL_MspDeInit(void)
228
+{
229
+  /* NOTE : This function should not be modified, when the callback is needed,
230
+            the HAL_MspDeInit could be implemented in the user file
231
+   */
232
+}
233
+
234
+/**
235
+  * @brief This function configures the source of the time base.
236
+  *        The time source is configured  to have 1ms time base with a dedicated
237
+  *        Tick interrupt priority.
238
+  * @note This function is called  automatically at the beginning of program after
239
+  *       reset by HAL_Init() or at any time when clock is reconfigured  by HAL_RCC_ClockConfig().
240
+  * @note In the default implementation, SysTick timer is the source of time base.
241
+  *       It is used to generate interrupts at regular time intervals.
242
+  *       Care must be taken if HAL_Delay() is called from a peripheral ISR process,
243
+  *       The SysTick interrupt must have higher priority (numerically lower)
244
+  *       than the peripheral interrupt. Otherwise the caller ISR process will be blocked.
245
+  *       The function is declared as __weak  to be overwritten  in case of other
246
+  *       implementation  in user file.
247
+  * @param TickPriority Tick interrupt priority.
248
+  * @retval HAL status
249
+  */
250
+__weak HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
251
+{
252
+  /* Configure the SysTick to have interrupt in 1ms time basis*/
253
+  if (HAL_SYSTICK_Config(SystemCoreClock / (1000U / uwTickFreq)) > 0U)
254
+  {
255
+    return HAL_ERROR;
256
+  }
257
+
258
+  /* Configure the SysTick IRQ priority */
259
+  if (TickPriority < (1UL << __NVIC_PRIO_BITS))
260
+  {
261
+    HAL_NVIC_SetPriority(SysTick_IRQn, TickPriority, 0U);
262
+    uwTickPrio = TickPriority;
263
+  }
264
+  else
265
+  {
266
+    return HAL_ERROR;
267
+  }
268
+
269
+  /* Return function status */
270
+  return HAL_OK;
271
+}
272
+
273
+/**
274
+  * @}
275
+  */
276
+
277
+/** @defgroup HAL_Exported_Functions_Group2 HAL Control functions
278
+  *  @brief    HAL Control functions
279
+  *
280
+@verbatim
281
+ ===============================================================================
282
+                      ##### HAL Control functions #####
283
+ ===============================================================================
284
+    [..]  This section provides functions allowing to:
285
+      (+) Provide a tick value in millisecond
286
+      (+) Provide a blocking delay in millisecond
287
+      (+) Suspend the time base source interrupt
288
+      (+) Resume the time base source interrupt
289
+      (+) Get the HAL API driver version
290
+      (+) Get the device identifier
291
+      (+) Get the device revision identifier
292
+      (+) Enable/Disable Debug module during SLEEP mode
293
+      (+) Enable/Disable Debug module during STOP mode
294
+      (+) Enable/Disable Debug module during STANDBY mode
295
+
296
+@endverbatim
297
+  * @{
298
+  */
299
+
300
+/**
301
+  * @brief This function is called to increment  a global variable "uwTick"
302
+  *        used as application time base.
303
+  * @note In the default implementation, this variable is incremented each 1ms
304
+  *       in SysTick ISR.
305
+  * @note This function is declared as __weak to be overwritten in case of other
306
+  *      implementations in user file.
307
+  * @retval None
308
+  */
309
+__weak void HAL_IncTick(void)
310
+{
311
+  uwTick += uwTickFreq;
312
+}
313
+
314
+/**
315
+  * @brief Provides a tick value in millisecond.
316
+  * @note  This function is declared as __weak to be overwritten in case of other
317
+  *       implementations in user file.
318
+  * @retval tick value
319
+  */
320
+__weak uint32_t HAL_GetTick(void)
321
+{
322
+  return uwTick;
323
+}
324
+
325
+/**
326
+  * @brief This function returns a tick priority.
327
+  * @retval tick priority
328
+  */
329
+uint32_t HAL_GetTickPrio(void)
330
+{
331
+  return uwTickPrio;
332
+}
333
+
334
+/**
335
+  * @brief Set new tick Freq.
336
+  * @retval Status
337
+  */
338
+HAL_StatusTypeDef HAL_SetTickFreq(HAL_TickFreqTypeDef Freq)
339
+{
340
+  HAL_StatusTypeDef status  = HAL_OK;
341
+  assert_param(IS_TICKFREQ(Freq));
342
+
343
+  if (uwTickFreq != Freq)
344
+  {
345
+    uwTickFreq = Freq;
346
+
347
+    /* Apply the new tick Freq  */
348
+    status = HAL_InitTick(uwTickPrio);
349
+  }
350
+
351
+  return status;
352
+}
353
+
354
+/**
355
+  * @brief Return tick frequency.
356
+  * @retval tick period in Hz
357
+  */
358
+HAL_TickFreqTypeDef HAL_GetTickFreq(void)
359
+{
360
+  return uwTickFreq;
361
+}
362
+
363
+/**
364
+  * @brief This function provides minimum delay (in milliseconds) based
365
+  *        on variable incremented.
366
+  * @note In the default implementation , SysTick timer is the source of time base.
367
+  *       It is used to generate interrupts at regular time intervals where uwTick
368
+  *       is incremented.
369
+  * @note This function is declared as __weak to be overwritten in case of other
370
+  *       implementations in user file.
371
+  * @param Delay specifies the delay time length, in milliseconds.
372
+  * @retval None
373
+  */
374
+__weak void HAL_Delay(uint32_t Delay)
375
+{
376
+  uint32_t tickstart = HAL_GetTick();
377
+  uint32_t wait = Delay;
378
+
379
+  /* Add a freq to guarantee minimum wait */
380
+  if (wait < HAL_MAX_DELAY)
381
+  {
382
+    wait += (uint32_t)(uwTickFreq);
383
+  }
384
+
385
+  while ((HAL_GetTick() - tickstart) < wait)
386
+  {
387
+  }
388
+}
389
+
390
+/**
391
+  * @brief Suspend Tick increment.
392
+  * @note In the default implementation , SysTick timer is the source of time base. It is
393
+  *       used to generate interrupts at regular time intervals. Once HAL_SuspendTick()
394
+  *       is called, the SysTick interrupt will be disabled and so Tick increment
395
+  *       is suspended.
396
+  * @note This function is declared as __weak to be overwritten in case of other
397
+  *       implementations in user file.
398
+  * @retval None
399
+  */
400
+__weak void HAL_SuspendTick(void)
401
+{
402
+  /* Disable SysTick Interrupt */
403
+  CLEAR_BIT(SysTick->CTRL, SysTick_CTRL_TICKINT_Msk);
404
+}
405
+
406
+/**
407
+  * @brief Resume Tick increment.
408
+  * @note In the default implementation , SysTick timer is the source of time base. It is
409
+  *       used to generate interrupts at regular time intervals. Once HAL_ResumeTick()
410
+  *       is called, the SysTick interrupt will be enabled and so Tick increment
411
+  *       is resumed.
412
+  * @note This function is declared as __weak to be overwritten in case of other
413
+  *       implementations in user file.
414
+  * @retval None
415
+  */
416
+__weak void HAL_ResumeTick(void)
417
+{
418
+  /* Enable SysTick Interrupt */
419
+  SET_BIT(SysTick->CTRL, SysTick_CTRL_TICKINT_Msk);
420
+}
421
+
422
+/**
423
+  * @brief  Returns the HAL revision
424
+  * @retval version 0xXYZR (8bits for each decimal, R for RC)
425
+  */
426
+uint32_t HAL_GetHalVersion(void)
427
+{
428
+  return __STM32F1xx_HAL_VERSION;
429
+}
430
+
431
+/**
432
+  * @brief Returns the device revision identifier.
433
+  * Note: On devices STM32F10xx8 and STM32F10xxB,
434
+  *                  STM32F101xC/D/E and STM32F103xC/D/E,
435
+  *                  STM32F101xF/G and STM32F103xF/G
436
+  *                  STM32F10xx4 and STM32F10xx6
437
+  *       Debug registers DBGMCU_IDCODE and DBGMCU_CR are accessible only in
438
+  *       debug mode (not accessible by the user software in normal mode).
439
+  *       Refer to errata sheet of these devices for more details.
440
+  * @retval Device revision identifier
441
+  */
442
+uint32_t HAL_GetREVID(void)
443
+{
444
+  return ((DBGMCU->IDCODE) >> DBGMCU_IDCODE_REV_ID_Pos);
445
+}
446
+
447
+/**
448
+  * @brief  Returns the device identifier.
449
+  * Note: On devices STM32F10xx8 and STM32F10xxB,
450
+  *                  STM32F101xC/D/E and STM32F103xC/D/E,
451
+  *                  STM32F101xF/G and STM32F103xF/G
452
+  *                  STM32F10xx4 and STM32F10xx6
453
+  *       Debug registers DBGMCU_IDCODE and DBGMCU_CR are accessible only in
454
+  *       debug mode (not accessible by the user software in normal mode).
455
+  *       Refer to errata sheet of these devices for more details.
456
+  * @retval Device identifier
457
+  */
458
+uint32_t HAL_GetDEVID(void)
459
+{
460
+  return ((DBGMCU->IDCODE) & IDCODE_DEVID_MASK);
461
+}
462
+
463
+/**
464
+  * @brief  Enable the Debug Module during SLEEP mode
465
+  * @retval None
466
+  */
467
+void HAL_DBGMCU_EnableDBGSleepMode(void)
468
+{
469
+  SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEP);
470
+}
471
+
472
+/**
473
+  * @brief  Disable the Debug Module during SLEEP mode
474
+  * Note: On devices STM32F10xx8 and STM32F10xxB,
475
+  *                  STM32F101xC/D/E and STM32F103xC/D/E,
476
+  *                  STM32F101xF/G and STM32F103xF/G
477
+  *                  STM32F10xx4 and STM32F10xx6
478
+  *       Debug registers DBGMCU_IDCODE and DBGMCU_CR are accessible only in
479
+  *       debug mode (not accessible by the user software in normal mode).
480
+  *       Refer to errata sheet of these devices for more details.
481
+  * @retval None
482
+  */
483
+void HAL_DBGMCU_DisableDBGSleepMode(void)
484
+{
485
+  CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEP);
486
+}
487
+
488
+/**
489
+  * @brief  Enable the Debug Module during STOP mode
490
+  * Note: On devices STM32F10xx8 and STM32F10xxB,
491
+  *                  STM32F101xC/D/E and STM32F103xC/D/E,
492
+  *                  STM32F101xF/G and STM32F103xF/G
493
+  *                  STM32F10xx4 and STM32F10xx6
494
+  *       Debug registers DBGMCU_IDCODE and DBGMCU_CR are accessible only in
495
+  *       debug mode (not accessible by the user software in normal mode).
496
+  *       Refer to errata sheet of these devices for more details.
497
+  * Note: On all STM32F1 devices:
498
+  *       If the system tick timer interrupt is enabled during the Stop mode
499
+  *       debug (DBG_STOP bit set in the DBGMCU_CR register ), it will wakeup
500
+  *       the system from Stop mode.
501
+  *       Workaround: To debug the Stop mode, disable the system tick timer
502
+  *       interrupt.
503
+  *       Refer to errata sheet of these devices for more details.
504
+  * Note: On all STM32F1 devices:
505
+  *       If the system tick timer interrupt is enabled during the Stop mode
506
+  *       debug (DBG_STOP bit set in the DBGMCU_CR register ), it will wakeup
507
+  *       the system from Stop mode.
508
+  *       Workaround: To debug the Stop mode, disable the system tick timer
509
+  *       interrupt.
510
+  *       Refer to errata sheet of these devices for more details.
511
+  * @retval None
512
+  */
513
+void HAL_DBGMCU_EnableDBGStopMode(void)
514
+{
515
+  SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP);
516
+}
517
+
518
+/**
519
+  * @brief  Disable the Debug Module during STOP mode
520
+  * Note: On devices STM32F10xx8 and STM32F10xxB,
521
+  *                  STM32F101xC/D/E and STM32F103xC/D/E,
522
+  *                  STM32F101xF/G and STM32F103xF/G
523
+  *                  STM32F10xx4 and STM32F10xx6
524
+  *       Debug registers DBGMCU_IDCODE and DBGMCU_CR are accessible only in
525
+  *       debug mode (not accessible by the user software in normal mode).
526
+  *       Refer to errata sheet of these devices for more details.
527
+  * @retval None
528
+  */
529
+void HAL_DBGMCU_DisableDBGStopMode(void)
530
+{
531
+  CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP);
532
+}
533
+
534
+/**
535
+  * @brief  Enable the Debug Module during STANDBY mode
536
+  * Note: On devices STM32F10xx8 and STM32F10xxB,
537
+  *                  STM32F101xC/D/E and STM32F103xC/D/E,
538
+  *                  STM32F101xF/G and STM32F103xF/G
539
+  *                  STM32F10xx4 and STM32F10xx6
540
+  *       Debug registers DBGMCU_IDCODE and DBGMCU_CR are accessible only in
541
+  *       debug mode (not accessible by the user software in normal mode).
542
+  *       Refer to errata sheet of these devices for more details.
543
+  * @retval None
544
+  */
545
+void HAL_DBGMCU_EnableDBGStandbyMode(void)
546
+{
547
+  SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY);
548
+}
549
+
550
+/**
551
+  * @brief  Disable the Debug Module during STANDBY mode
552
+  * Note: On devices STM32F10xx8 and STM32F10xxB,
553
+  *                  STM32F101xC/D/E and STM32F103xC/D/E,
554
+  *                  STM32F101xF/G and STM32F103xF/G
555
+  *                  STM32F10xx4 and STM32F10xx6
556
+  *       Debug registers DBGMCU_IDCODE and DBGMCU_CR are accessible only in
557
+  *       debug mode (not accessible by the user software in normal mode).
558
+  *       Refer to errata sheet of these devices for more details.
559
+  * @retval None
560
+  */
561
+void HAL_DBGMCU_DisableDBGStandbyMode(void)
562
+{
563
+  CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY);
564
+}
565
+
566
+/**
567
+  * @brief Return the unique device identifier (UID based on 96 bits)
568
+  * @param UID pointer to 3 words array.
569
+  * @retval Device identifier
570
+  */
571
+void HAL_GetUID(uint32_t *UID)
572
+{
573
+  UID[0] = (uint32_t)(READ_REG(*((uint32_t *)UID_BASE)));
574
+  UID[1] = (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE + 4U))));
575
+  UID[2] = (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE + 8U))));
576
+}
577
+
578
+/**
579
+  * @}
580
+  */
581
+
582
+/**
583
+  * @}
584
+  */
585
+
586
+#endif /* HAL_MODULE_ENABLED */
587
+/**
588
+  * @}
589
+  */
590
+
591
+/**
592
+  * @}
593
+  */
594
+
595
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 521 - 0
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c

@@ -0,0 +1,521 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx_hal_cortex.c
4
+  * @author  MCD Application Team
5
+  * @brief   CORTEX HAL module driver.
6
+  *          This file provides firmware functions to manage the following 
7
+  *          functionalities of the CORTEX:
8
+  *           + Initialization and de-initialization functions
9
+  *           + Peripheral Control functions 
10
+  *
11
+  @verbatim  
12
+  ==============================================================================
13
+                        ##### How to use this driver #####
14
+  ==============================================================================
15
+
16
+    [..]  
17
+    *** How to configure Interrupts using CORTEX HAL driver ***
18
+    ===========================================================
19
+    [..]     
20
+    This section provides functions allowing to configure the NVIC interrupts (IRQ).
21
+    The Cortex-M3 exceptions are managed by CMSIS functions.
22
+   
23
+    (#) Configure the NVIC Priority Grouping using HAL_NVIC_SetPriorityGrouping()
24
+        function according to the following table.
25
+    (#) Configure the priority of the selected IRQ Channels using HAL_NVIC_SetPriority(). 
26
+    (#) Enable the selected IRQ Channels using HAL_NVIC_EnableIRQ().
27
+    (#) please refer to programming manual for details in how to configure priority. 
28
+      
29
+     -@- When the NVIC_PRIORITYGROUP_0 is selected, IRQ preemption is no more possible. 
30
+         The pending IRQ priority will be managed only by the sub priority.
31
+   
32
+     -@- IRQ priority order (sorted by highest to lowest priority):
33
+        (+@) Lowest preemption priority
34
+        (+@) Lowest sub priority
35
+        (+@) Lowest hardware priority (IRQ number)
36
+ 
37
+    [..]  
38
+    *** How to configure Systick using CORTEX HAL driver ***
39
+    ========================================================
40
+    [..]
41
+    Setup SysTick Timer for time base.
42
+           
43
+   (+) The HAL_SYSTICK_Config()function calls the SysTick_Config() function which
44
+       is a CMSIS function that:
45
+        (++) Configures the SysTick Reload register with value passed as function parameter.
46
+        (++) Configures the SysTick IRQ priority to the lowest value 0x0F.
47
+        (++) Resets the SysTick Counter register.
48
+        (++) Configures the SysTick Counter clock source to be Core Clock Source (HCLK).
49
+        (++) Enables the SysTick Interrupt.
50
+        (++) Starts the SysTick Counter.
51
+    
52
+   (+) You can change the SysTick Clock source to be HCLK_Div8 by calling the macro
53
+       __HAL_CORTEX_SYSTICKCLK_CONFIG(SYSTICK_CLKSOURCE_HCLK_DIV8) just after the
54
+       HAL_SYSTICK_Config() function call. The __HAL_CORTEX_SYSTICKCLK_CONFIG() macro is defined
55
+       inside the stm32f1xx_hal_cortex.h file.
56
+
57
+   (+) You can change the SysTick IRQ priority by calling the
58
+       HAL_NVIC_SetPriority(SysTick_IRQn,...) function just after the HAL_SYSTICK_Config() function 
59
+       call. The HAL_NVIC_SetPriority() call the NVIC_SetPriority() function which is a CMSIS function.
60
+
61
+   (+) To adjust the SysTick time base, use the following formula:
62
+                            
63
+       Reload Value = SysTick Counter Clock (Hz) x  Desired Time base (s)
64
+       (++) Reload Value is the parameter to be passed for HAL_SYSTICK_Config() function
65
+       (++) Reload Value should not exceed 0xFFFFFF
66
+   
67
+  @endverbatim
68
+  ******************************************************************************
69
+  * @attention
70
+  *
71
+  * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
72
+  *
73
+  * Redistribution and use in source and binary forms, with or without modification,
74
+  * are permitted provided that the following conditions are met:
75
+  *   1. Redistributions of source code must retain the above copyright notice,
76
+  *      this list of conditions and the following disclaimer.
77
+  *   2. Redistributions in binary form must reproduce the above copyright notice,
78
+  *      this list of conditions and the following disclaimer in the documentation
79
+  *      and/or other materials provided with the distribution.
80
+  *   3. Neither the name of STMicroelectronics nor the names of its contributors
81
+  *      may be used to endorse or promote products derived from this software
82
+  *      without specific prior written permission.
83
+  *
84
+  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
85
+  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
86
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
87
+  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
88
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
89
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
90
+  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
91
+  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
92
+  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
93
+  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
94
+  *
95
+  ******************************************************************************
96
+  */
97
+
98
+/* Includes ------------------------------------------------------------------*/
99
+#include "stm32f1xx_hal.h"
100
+
101
+/** @addtogroup STM32F1xx_HAL_Driver
102
+  * @{
103
+  */
104
+
105
+/** @defgroup CORTEX CORTEX
106
+  * @brief CORTEX HAL module driver
107
+  * @{
108
+  */
109
+
110
+#ifdef HAL_CORTEX_MODULE_ENABLED
111
+
112
+/* Private types -------------------------------------------------------------*/
113
+/* Private variables ---------------------------------------------------------*/
114
+/* Private constants ---------------------------------------------------------*/
115
+/* Private macros ------------------------------------------------------------*/
116
+/* Private functions ---------------------------------------------------------*/
117
+/* Exported functions --------------------------------------------------------*/
118
+
119
+/** @defgroup CORTEX_Exported_Functions CORTEX Exported Functions
120
+  * @{
121
+  */
122
+
123
+
124
+/** @defgroup CORTEX_Exported_Functions_Group1 Initialization and de-initialization functions
125
+  *  @brief    Initialization and Configuration functions 
126
+  *
127
+@verbatim    
128
+  ==============================================================================
129
+              ##### Initialization and de-initialization functions #####
130
+  ==============================================================================
131
+    [..]
132
+      This section provides the CORTEX HAL driver functions allowing to configure Interrupts
133
+      Systick functionalities 
134
+
135
+@endverbatim
136
+  * @{
137
+  */
138
+
139
+
140
+/**
141
+  * @brief  Sets the priority grouping field (preemption priority and subpriority)
142
+  *         using the required unlock sequence.
143
+  * @param  PriorityGroup: The priority grouping bits length. 
144
+  *         This parameter can be one of the following values:
145
+  *         @arg NVIC_PRIORITYGROUP_0: 0 bits for preemption priority
146
+  *                                    4 bits for subpriority
147
+  *         @arg NVIC_PRIORITYGROUP_1: 1 bits for preemption priority
148
+  *                                    3 bits for subpriority
149
+  *         @arg NVIC_PRIORITYGROUP_2: 2 bits for preemption priority
150
+  *                                    2 bits for subpriority
151
+  *         @arg NVIC_PRIORITYGROUP_3: 3 bits for preemption priority
152
+  *                                    1 bits for subpriority
153
+  *         @arg NVIC_PRIORITYGROUP_4: 4 bits for preemption priority
154
+  *                                    0 bits for subpriority
155
+  * @note   When the NVIC_PriorityGroup_0 is selected, IRQ preemption is no more possible. 
156
+  *         The pending IRQ priority will be managed only by the subpriority. 
157
+  * @retval None
158
+  */
159
+void HAL_NVIC_SetPriorityGrouping(uint32_t PriorityGroup)
160
+{
161
+  /* Check the parameters */
162
+  assert_param(IS_NVIC_PRIORITY_GROUP(PriorityGroup));
163
+  
164
+  /* Set the PRIGROUP[10:8] bits according to the PriorityGroup parameter value */
165
+  NVIC_SetPriorityGrouping(PriorityGroup);
166
+}
167
+
168
+/**
169
+  * @brief  Sets the priority of an interrupt.
170
+  * @param  IRQn: External interrupt number.
171
+  *         This parameter can be an enumerator of IRQn_Type enumeration
172
+  *         (For the complete STM32 Devices IRQ Channels list, please refer to the appropriate CMSIS device file (stm32f10xx.h))
173
+  * @param  PreemptPriority: The preemption priority for the IRQn channel.
174
+  *         This parameter can be a value between 0 and 15
175
+  *         A lower priority value indicates a higher priority 
176
+  * @param  SubPriority: the subpriority level for the IRQ channel.
177
+  *         This parameter can be a value between 0 and 15
178
+  *         A lower priority value indicates a higher priority.          
179
+  * @retval None
180
+  */
181
+void HAL_NVIC_SetPriority(IRQn_Type IRQn, uint32_t PreemptPriority, uint32_t SubPriority)
182
+{ 
183
+  uint32_t prioritygroup = 0x00U;
184
+  
185
+  /* Check the parameters */
186
+  assert_param(IS_NVIC_SUB_PRIORITY(SubPriority));
187
+  assert_param(IS_NVIC_PREEMPTION_PRIORITY(PreemptPriority));
188
+  
189
+  prioritygroup = NVIC_GetPriorityGrouping();
190
+  
191
+  NVIC_SetPriority(IRQn, NVIC_EncodePriority(prioritygroup, PreemptPriority, SubPriority));
192
+}
193
+
194
+/**
195
+  * @brief  Enables a device specific interrupt in the NVIC interrupt controller.
196
+  * @note   To configure interrupts priority correctly, the NVIC_PriorityGroupConfig()
197
+  *         function should be called before. 
198
+  * @param  IRQn External interrupt number.
199
+  *         This parameter can be an enumerator of IRQn_Type enumeration
200
+  *         (For the complete STM32 Devices IRQ Channels list, please refer to the appropriate CMSIS device file (stm32f10xxx.h))
201
+  * @retval None
202
+  */
203
+void HAL_NVIC_EnableIRQ(IRQn_Type IRQn)
204
+{
205
+  /* Check the parameters */
206
+  assert_param(IS_NVIC_DEVICE_IRQ(IRQn));
207
+
208
+  /* Enable interrupt */
209
+  NVIC_EnableIRQ(IRQn);
210
+}
211
+
212
+/**
213
+  * @brief  Disables a device specific interrupt in the NVIC interrupt controller.
214
+  * @param  IRQn External interrupt number.
215
+  *         This parameter can be an enumerator of IRQn_Type enumeration
216
+  *         (For the complete STM32 Devices IRQ Channels list, please refer to the appropriate CMSIS device file (stm32f10xxx.h))  
217
+  * @retval None
218
+  */
219
+void HAL_NVIC_DisableIRQ(IRQn_Type IRQn)
220
+{
221
+  /* Check the parameters */
222
+  assert_param(IS_NVIC_DEVICE_IRQ(IRQn));
223
+
224
+  /* Disable interrupt */
225
+  NVIC_DisableIRQ(IRQn);
226
+}
227
+
228
+/**
229
+  * @brief  Initiates a system reset request to reset the MCU.
230
+  * @retval None
231
+  */
232
+void HAL_NVIC_SystemReset(void)
233
+{
234
+  /* System Reset */
235
+  NVIC_SystemReset();
236
+}
237
+
238
+/**
239
+  * @brief  Initializes the System Timer and its interrupt, and starts the System Tick Timer.
240
+  *         Counter is in free running mode to generate periodic interrupts.
241
+  * @param  TicksNumb: Specifies the ticks Number of ticks between two interrupts.
242
+  * @retval status:  - 0  Function succeeded.
243
+  *                  - 1  Function failed.
244
+  */
245
+uint32_t HAL_SYSTICK_Config(uint32_t TicksNumb)
246
+{
247
+   return SysTick_Config(TicksNumb);
248
+}
249
+/**
250
+  * @}
251
+  */
252
+
253
+/** @defgroup CORTEX_Exported_Functions_Group2 Peripheral Control functions
254
+  *  @brief   Cortex control functions 
255
+  *
256
+@verbatim   
257
+  ==============================================================================
258
+                      ##### Peripheral Control functions #####
259
+  ==============================================================================
260
+    [..]
261
+      This subsection provides a set of functions allowing to control the CORTEX
262
+      (NVIC, SYSTICK, MPU) functionalities. 
263
+ 
264
+      
265
+@endverbatim
266
+  * @{
267
+  */
268
+
269
+#if (__MPU_PRESENT == 1U)
270
+/**
271
+  * @brief  Disables the MPU
272
+  * @retval None
273
+  */
274
+void HAL_MPU_Disable(void)
275
+{
276
+  /* Make sure outstanding transfers are done */
277
+  __DMB();
278
+
279
+  /* Disable fault exceptions */
280
+  SCB->SHCSR &= ~SCB_SHCSR_MEMFAULTENA_Msk;
281
+  
282
+  /* Disable the MPU and clear the control register*/
283
+  MPU->CTRL = 0U;
284
+}
285
+
286
+/**
287
+  * @brief  Enable the MPU.
288
+  * @param  MPU_Control: Specifies the control mode of the MPU during hard fault, 
289
+  *          NMI, FAULTMASK and privileged access to the default memory 
290
+  *          This parameter can be one of the following values:
291
+  *            @arg MPU_HFNMI_PRIVDEF_NONE
292
+  *            @arg MPU_HARDFAULT_NMI
293
+  *            @arg MPU_PRIVILEGED_DEFAULT
294
+  *            @arg MPU_HFNMI_PRIVDEF
295
+  * @retval None
296
+  */
297
+void HAL_MPU_Enable(uint32_t MPU_Control)
298
+{
299
+  /* Enable the MPU */
300
+  MPU->CTRL = MPU_Control | MPU_CTRL_ENABLE_Msk;
301
+  
302
+  /* Enable fault exceptions */
303
+  SCB->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk;
304
+  
305
+  /* Ensure MPU setting take effects */
306
+  __DSB();
307
+  __ISB();
308
+}
309
+
310
+/**
311
+  * @brief  Initializes and configures the Region and the memory to be protected.
312
+  * @param  MPU_Init: Pointer to a MPU_Region_InitTypeDef structure that contains
313
+  *                the initialization and configuration information.
314
+  * @retval None
315
+  */
316
+void HAL_MPU_ConfigRegion(MPU_Region_InitTypeDef *MPU_Init)
317
+{
318
+  /* Check the parameters */
319
+  assert_param(IS_MPU_REGION_NUMBER(MPU_Init->Number));
320
+  assert_param(IS_MPU_REGION_ENABLE(MPU_Init->Enable));
321
+
322
+  /* Set the Region number */
323
+  MPU->RNR = MPU_Init->Number;
324
+
325
+  if ((MPU_Init->Enable) != RESET)
326
+  {
327
+    /* Check the parameters */
328
+    assert_param(IS_MPU_INSTRUCTION_ACCESS(MPU_Init->DisableExec));
329
+    assert_param(IS_MPU_REGION_PERMISSION_ATTRIBUTE(MPU_Init->AccessPermission));
330
+    assert_param(IS_MPU_TEX_LEVEL(MPU_Init->TypeExtField));
331
+    assert_param(IS_MPU_ACCESS_SHAREABLE(MPU_Init->IsShareable));
332
+    assert_param(IS_MPU_ACCESS_CACHEABLE(MPU_Init->IsCacheable));
333
+    assert_param(IS_MPU_ACCESS_BUFFERABLE(MPU_Init->IsBufferable));
334
+    assert_param(IS_MPU_SUB_REGION_DISABLE(MPU_Init->SubRegionDisable));
335
+    assert_param(IS_MPU_REGION_SIZE(MPU_Init->Size));
336
+    
337
+    MPU->RBAR = MPU_Init->BaseAddress;
338
+    MPU->RASR = ((uint32_t)MPU_Init->DisableExec             << MPU_RASR_XN_Pos)   |
339
+                ((uint32_t)MPU_Init->AccessPermission        << MPU_RASR_AP_Pos)   |
340
+                ((uint32_t)MPU_Init->TypeExtField            << MPU_RASR_TEX_Pos)  |
341
+                ((uint32_t)MPU_Init->IsShareable             << MPU_RASR_S_Pos)    |
342
+                ((uint32_t)MPU_Init->IsCacheable             << MPU_RASR_C_Pos)    |
343
+                ((uint32_t)MPU_Init->IsBufferable            << MPU_RASR_B_Pos)    |
344
+                ((uint32_t)MPU_Init->SubRegionDisable        << MPU_RASR_SRD_Pos)  |
345
+                ((uint32_t)MPU_Init->Size                    << MPU_RASR_SIZE_Pos) |
346
+                ((uint32_t)MPU_Init->Enable                  << MPU_RASR_ENABLE_Pos);
347
+  }
348
+  else
349
+  {
350
+    MPU->RBAR = 0x00U;
351
+    MPU->RASR = 0x00U;
352
+  }
353
+}
354
+#endif /* __MPU_PRESENT */
355
+
356
+/**
357
+  * @brief  Gets the priority grouping field from the NVIC Interrupt Controller.
358
+  * @retval Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field)
359
+  */
360
+uint32_t HAL_NVIC_GetPriorityGrouping(void)
361
+{
362
+  /* Get the PRIGROUP[10:8] field value */
363
+  return NVIC_GetPriorityGrouping();
364
+}
365
+
366
+/**
367
+  * @brief  Gets the priority of an interrupt.
368
+  * @param  IRQn: External interrupt number.
369
+  *         This parameter can be an enumerator of IRQn_Type enumeration
370
+  *         (For the complete STM32 Devices IRQ Channels list, please refer to the appropriate CMSIS device file (stm32f10xxx.h))
371
+  * @param   PriorityGroup: the priority grouping bits length.
372
+  *         This parameter can be one of the following values:
373
+  *           @arg NVIC_PRIORITYGROUP_0: 0 bits for preemption priority
374
+  *                                      4 bits for subpriority
375
+  *           @arg NVIC_PRIORITYGROUP_1: 1 bits for preemption priority
376
+  *                                      3 bits for subpriority
377
+  *           @arg NVIC_PRIORITYGROUP_2: 2 bits for preemption priority
378
+  *                                      2 bits for subpriority
379
+  *           @arg NVIC_PRIORITYGROUP_3: 3 bits for preemption priority
380
+  *                                      1 bits for subpriority
381
+  *           @arg NVIC_PRIORITYGROUP_4: 4 bits for preemption priority
382
+  *                                      0 bits for subpriority
383
+  * @param  pPreemptPriority: Pointer on the Preemptive priority value (starting from 0).
384
+  * @param  pSubPriority: Pointer on the Subpriority value (starting from 0).
385
+  * @retval None
386
+  */
387
+void HAL_NVIC_GetPriority(IRQn_Type IRQn, uint32_t PriorityGroup, uint32_t *pPreemptPriority, uint32_t *pSubPriority)
388
+{
389
+  /* Check the parameters */
390
+  assert_param(IS_NVIC_PRIORITY_GROUP(PriorityGroup));
391
+ /* Get priority for Cortex-M system or device specific interrupts */
392
+  NVIC_DecodePriority(NVIC_GetPriority(IRQn), PriorityGroup, pPreemptPriority, pSubPriority);
393
+}
394
+
395
+/**
396
+  * @brief  Sets Pending bit of an external interrupt.
397
+  * @param  IRQn External interrupt number
398
+  *         This parameter can be an enumerator of IRQn_Type enumeration
399
+  *         (For the complete STM32 Devices IRQ Channels list, please refer to the appropriate CMSIS device file (stm32f10xxx.h))  
400
+  * @retval None
401
+  */
402
+void HAL_NVIC_SetPendingIRQ(IRQn_Type IRQn)
403
+{
404
+  /* Check the parameters */
405
+  assert_param(IS_NVIC_DEVICE_IRQ(IRQn));
406
+  
407
+  /* Set interrupt pending */
408
+  NVIC_SetPendingIRQ(IRQn);
409
+}
410
+
411
+/**
412
+  * @brief  Gets Pending Interrupt (reads the pending register in the NVIC 
413
+  *         and returns the pending bit for the specified interrupt).
414
+  * @param  IRQn External interrupt number.
415
+  *         This parameter can be an enumerator of IRQn_Type enumeration
416
+  *         (For the complete STM32 Devices IRQ Channels list, please refer to the appropriate CMSIS device file (stm32f10xxx.h))  
417
+  * @retval status: - 0  Interrupt status is not pending.
418
+  *                 - 1  Interrupt status is pending.
419
+  */
420
+uint32_t HAL_NVIC_GetPendingIRQ(IRQn_Type IRQn)
421
+{
422
+  /* Check the parameters */
423
+  assert_param(IS_NVIC_DEVICE_IRQ(IRQn));
424
+
425
+  /* Return 1 if pending else 0 */
426
+  return NVIC_GetPendingIRQ(IRQn);
427
+}
428
+
429
+/**
430
+  * @brief  Clears the pending bit of an external interrupt.
431
+  * @param  IRQn External interrupt number.
432
+  *         This parameter can be an enumerator of IRQn_Type enumeration
433
+  *         (For the complete STM32 Devices IRQ Channels list, please refer to the appropriate CMSIS device file (stm32f10xxx.h))  
434
+  * @retval None
435
+  */
436
+void HAL_NVIC_ClearPendingIRQ(IRQn_Type IRQn)
437
+{
438
+  /* Check the parameters */
439
+  assert_param(IS_NVIC_DEVICE_IRQ(IRQn));
440
+
441
+  /* Clear pending interrupt */
442
+  NVIC_ClearPendingIRQ(IRQn);
443
+}
444
+
445
+/**
446
+  * @brief Gets active interrupt ( reads the active register in NVIC and returns the active bit).
447
+  * @param IRQn External interrupt number
448
+  *         This parameter can be an enumerator of IRQn_Type enumeration
449
+  *         (For the complete STM32 Devices IRQ Channels list, please refer to the appropriate CMSIS device file (stm32f10xxx.h))  
450
+  * @retval status: - 0  Interrupt status is not pending.
451
+  *                 - 1  Interrupt status is pending.
452
+  */
453
+uint32_t HAL_NVIC_GetActive(IRQn_Type IRQn)
454
+{
455
+  /* Check the parameters */
456
+  assert_param(IS_NVIC_DEVICE_IRQ(IRQn));
457
+
458
+  /* Return 1 if active else 0 */
459
+  return NVIC_GetActive(IRQn);
460
+}
461
+
462
+/**
463
+  * @brief  Configures the SysTick clock source.
464
+  * @param  CLKSource: specifies the SysTick clock source.
465
+  *         This parameter can be one of the following values:
466
+  *             @arg SYSTICK_CLKSOURCE_HCLK_DIV8: AHB clock divided by 8 selected as SysTick clock source.
467
+  *             @arg SYSTICK_CLKSOURCE_HCLK: AHB clock selected as SysTick clock source.
468
+  * @retval None
469
+  */
470
+void HAL_SYSTICK_CLKSourceConfig(uint32_t CLKSource)
471
+{
472
+  /* Check the parameters */
473
+  assert_param(IS_SYSTICK_CLK_SOURCE(CLKSource));
474
+  if (CLKSource == SYSTICK_CLKSOURCE_HCLK)
475
+  {
476
+    SysTick->CTRL |= SYSTICK_CLKSOURCE_HCLK;
477
+  }
478
+  else
479
+  {
480
+    SysTick->CTRL &= ~SYSTICK_CLKSOURCE_HCLK;
481
+  }
482
+}
483
+
484
+/**
485
+  * @brief  This function handles SYSTICK interrupt request.
486
+  * @retval None
487
+  */
488
+void HAL_SYSTICK_IRQHandler(void)
489
+{
490
+  HAL_SYSTICK_Callback();
491
+}
492
+
493
+/**
494
+  * @brief  SYSTICK callback.
495
+  * @retval None
496
+  */
497
+__weak void HAL_SYSTICK_Callback(void)
498
+{
499
+  /* NOTE : This function Should not be modified, when the callback is needed,
500
+            the HAL_SYSTICK_Callback could be implemented in the user file
501
+   */
502
+}
503
+
504
+/**
505
+  * @}
506
+  */
507
+
508
+/**
509
+  * @}
510
+  */
511
+
512
+#endif /* HAL_CORTEX_MODULE_ENABLED */
513
+/**
514
+  * @}
515
+  */
516
+
517
+/**
518
+  * @}
519
+  */
520
+
521
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 902 - 0
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c

@@ -0,0 +1,902 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx_hal_dma.c
4
+  * @author  MCD Application Team
5
+  * @brief   DMA HAL module driver.
6
+  *         This file provides firmware functions to manage the following
7
+  *         functionalities of the Direct Memory Access (DMA) peripheral:
8
+  *           + Initialization and de-initialization functions
9
+  *           + IO operation functions
10
+  *           + Peripheral State and errors functions
11
+  @verbatim
12
+  ==============================================================================
13
+                        ##### How to use this driver #####
14
+  ==============================================================================
15
+  [..]
16
+   (#) Enable and configure the peripheral to be connected to the DMA Channel
17
+       (except for internal SRAM / FLASH memories: no initialization is 
18
+       necessary). Please refer to the Reference manual for connection between peripherals
19
+       and DMA requests.
20
+
21
+   (#) For a given Channel, program the required configuration through the following parameters:
22
+       Channel request, Transfer Direction, Source and Destination data formats,
23
+       Circular or Normal mode, Channel Priority level, Source and Destination Increment mode
24
+       using HAL_DMA_Init() function.
25
+
26
+   (#) Use HAL_DMA_GetState() function to return the DMA state and HAL_DMA_GetError() in case of error 
27
+       detection.
28
+                    
29
+   (#) Use HAL_DMA_Abort() function to abort the current transfer
30
+                   
31
+     -@-   In Memory-to-Memory transfer mode, Circular mode is not allowed.
32
+     *** Polling mode IO operation ***
33
+     =================================
34
+    [..]
35
+          (+) Use HAL_DMA_Start() to start DMA transfer after the configuration of Source
36
+              address and destination address and the Length of data to be transferred
37
+          (+) Use HAL_DMA_PollForTransfer() to poll for the end of current transfer, in this
38
+              case a fixed Timeout can be configured by User depending from his application.
39
+
40
+     *** Interrupt mode IO operation ***
41
+     ===================================
42
+    [..]
43
+          (+) Configure the DMA interrupt priority using HAL_NVIC_SetPriority()
44
+          (+) Enable the DMA IRQ handler using HAL_NVIC_EnableIRQ()
45
+          (+) Use HAL_DMA_Start_IT() to start DMA transfer after the configuration of
46
+              Source address and destination address and the Length of data to be transferred.
47
+              In this case the DMA interrupt is configured
48
+          (+) Use HAL_DMA_IRQHandler() called under DMA_IRQHandler() Interrupt subroutine
49
+          (+) At the end of data transfer HAL_DMA_IRQHandler() function is executed and user can
50
+              add his own function by customization of function pointer XferCpltCallback and
51
+              XferErrorCallback (i.e. a member of DMA handle structure).
52
+
53
+     *** DMA HAL driver macros list ***
54
+     ============================================= 
55
+      [..]
56
+       Below the list of most used macros in DMA HAL driver.
57
+
58
+       (+) __HAL_DMA_ENABLE: Enable the specified DMA Channel.
59
+       (+) __HAL_DMA_DISABLE: Disable the specified DMA Channel.
60
+       (+) __HAL_DMA_GET_FLAG: Get the DMA Channel pending flags.
61
+       (+) __HAL_DMA_CLEAR_FLAG: Clear the DMA Channel pending flags.
62
+       (+) __HAL_DMA_ENABLE_IT: Enable the specified DMA Channel interrupts.
63
+       (+) __HAL_DMA_DISABLE_IT: Disable the specified DMA Channel interrupts.
64
+       (+) __HAL_DMA_GET_IT_SOURCE: Check whether the specified DMA Channel interrupt has occurred or not. 
65
+
66
+     [..] 
67
+      (@) You can refer to the DMA HAL driver header file for more useful macros  
68
+
69
+  @endverbatim
70
+  ******************************************************************************
71
+  * @attention
72
+  *
73
+  * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
74
+  *
75
+  * Redistribution and use in source and binary forms, with or without modification,
76
+  * are permitted provided that the following conditions are met:
77
+  *   1. Redistributions of source code must retain the above copyright notice,
78
+  *      this list of conditions and the following disclaimer.
79
+  *   2. Redistributions in binary form must reproduce the above copyright notice,
80
+  *      this list of conditions and the following disclaimer in the documentation
81
+  *      and/or other materials provided with the distribution.
82
+  *   3. Neither the name of STMicroelectronics nor the names of its contributors
83
+  *      may be used to endorse or promote products derived from this software
84
+  *      without specific prior written permission.
85
+  *
86
+  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
87
+  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
88
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
89
+  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
90
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
91
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
92
+  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
93
+  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
94
+  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
95
+  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
96
+  *
97
+  ******************************************************************************
98
+  */
99
+
100
+/* Includes ------------------------------------------------------------------*/
101
+#include "stm32f1xx_hal.h"
102
+
103
+/** @addtogroup STM32F1xx_HAL_Driver
104
+  * @{
105
+  */
106
+
107
+/** @defgroup DMA DMA
108
+  * @brief DMA HAL module driver
109
+  * @{
110
+  */
111
+
112
+#ifdef HAL_DMA_MODULE_ENABLED
113
+
114
+/* Private typedef -----------------------------------------------------------*/
115
+/* Private define ------------------------------------------------------------*/
116
+/* Private macro -------------------------------------------------------------*/
117
+/* Private variables ---------------------------------------------------------*/
118
+/* Private function prototypes -----------------------------------------------*/
119
+/** @defgroup DMA_Private_Functions DMA Private Functions
120
+  * @{
121
+  */
122
+static void DMA_SetConfig(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength);
123
+/**
124
+  * @}
125
+  */
126
+
127
+/* Exported functions ---------------------------------------------------------*/
128
+
129
+/** @defgroup DMA_Exported_Functions DMA Exported Functions
130
+  * @{
131
+  */
132
+
133
+/** @defgroup DMA_Exported_Functions_Group1 Initialization and de-initialization functions
134
+  *  @brief   Initialization and de-initialization functions 
135
+  *
136
+@verbatim
137
+ ===============================================================================
138
+             ##### Initialization and de-initialization functions  #####
139
+ ===============================================================================
140
+    [..]
141
+    This section provides functions allowing to initialize the DMA Channel source
142
+    and destination addresses, incrementation and data sizes, transfer direction, 
143
+    circular/normal mode selection, memory-to-memory mode selection and Channel priority value.
144
+    [..]
145
+    The HAL_DMA_Init() function follows the DMA configuration procedures as described in
146
+    reference manual.  
147
+
148
+@endverbatim
149
+  * @{
150
+  */
151
+
152
+/**
153
+  * @brief  Initialize the DMA according to the specified
154
+  *         parameters in the DMA_InitTypeDef and initialize the associated handle.
155
+  * @param  hdma: Pointer to a DMA_HandleTypeDef structure that contains
156
+  *               the configuration information for the specified DMA Channel.
157
+  * @retval HAL status
158
+  */
159
+HAL_StatusTypeDef HAL_DMA_Init(DMA_HandleTypeDef *hdma)
160
+{
161
+  uint32_t tmp = 0U;
162
+
163
+  /* Check the DMA handle allocation */
164
+  if(hdma == NULL)
165
+  {
166
+    return HAL_ERROR;
167
+  }
168
+
169
+  /* Check the parameters */
170
+  assert_param(IS_DMA_ALL_INSTANCE(hdma->Instance));
171
+  assert_param(IS_DMA_DIRECTION(hdma->Init.Direction));
172
+  assert_param(IS_DMA_PERIPHERAL_INC_STATE(hdma->Init.PeriphInc));
173
+  assert_param(IS_DMA_MEMORY_INC_STATE(hdma->Init.MemInc));
174
+  assert_param(IS_DMA_PERIPHERAL_DATA_SIZE(hdma->Init.PeriphDataAlignment));
175
+  assert_param(IS_DMA_MEMORY_DATA_SIZE(hdma->Init.MemDataAlignment));
176
+  assert_param(IS_DMA_MODE(hdma->Init.Mode));
177
+  assert_param(IS_DMA_PRIORITY(hdma->Init.Priority));
178
+
179
+#if defined (STM32F101xE) || defined (STM32F101xG) || defined (STM32F103xE) || defined (STM32F103xG) || defined (STM32F100xE) || defined (STM32F105xC) || defined (STM32F107xC)
180
+  /* calculation of the channel index */
181
+  if ((uint32_t)(hdma->Instance) < (uint32_t)(DMA2_Channel1))
182
+  {
183
+    /* DMA1 */
184
+    hdma->ChannelIndex = (((uint32_t)hdma->Instance - (uint32_t)DMA1_Channel1) / ((uint32_t)DMA1_Channel2 - (uint32_t)DMA1_Channel1)) << 2;
185
+    hdma->DmaBaseAddress = DMA1;
186
+  }
187
+  else 
188
+  {
189
+    /* DMA2 */
190
+    hdma->ChannelIndex = (((uint32_t)hdma->Instance - (uint32_t)DMA2_Channel1) / ((uint32_t)DMA2_Channel2 - (uint32_t)DMA2_Channel1)) << 2;
191
+    hdma->DmaBaseAddress = DMA2;
192
+  }
193
+#else
194
+  /* DMA1 */
195
+  hdma->ChannelIndex = (((uint32_t)hdma->Instance - (uint32_t)DMA1_Channel1) / ((uint32_t)DMA1_Channel2 - (uint32_t)DMA1_Channel1)) << 2;
196
+  hdma->DmaBaseAddress = DMA1;
197
+#endif /* STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG || STM32F100xE || STM32F105xC || STM32F107xC */
198
+
199
+  /* Change DMA peripheral state */
200
+  hdma->State = HAL_DMA_STATE_BUSY;
201
+
202
+  /* Get the CR register value */
203
+  tmp = hdma->Instance->CCR;
204
+
205
+  /* Clear PL, MSIZE, PSIZE, MINC, PINC, CIRC and DIR bits */
206
+  tmp &= ((uint32_t)~(DMA_CCR_PL    | DMA_CCR_MSIZE  | DMA_CCR_PSIZE  | \
207
+                      DMA_CCR_MINC  | DMA_CCR_PINC   | DMA_CCR_CIRC   | \
208
+                      DMA_CCR_DIR));
209
+
210
+  /* Prepare the DMA Channel configuration */
211
+  tmp |=  hdma->Init.Direction        |
212
+          hdma->Init.PeriphInc           | hdma->Init.MemInc           |
213
+          hdma->Init.PeriphDataAlignment | hdma->Init.MemDataAlignment |
214
+          hdma->Init.Mode                | hdma->Init.Priority;
215
+
216
+  /* Write to DMA Channel CR register */
217
+  hdma->Instance->CCR = tmp;
218
+
219
+  /* Initialise the error code */
220
+  hdma->ErrorCode = HAL_DMA_ERROR_NONE;
221
+
222
+  /* Initialize the DMA state*/
223
+  hdma->State = HAL_DMA_STATE_READY;
224
+  /* Allocate lock resource and initialize it */
225
+  hdma->Lock = HAL_UNLOCKED;
226
+
227
+  return HAL_OK;
228
+}
229
+
230
+/**
231
+  * @brief  DeInitialize the DMA peripheral.
232
+  * @param  hdma: pointer to a DMA_HandleTypeDef structure that contains
233
+  *               the configuration information for the specified DMA Channel.
234
+  * @retval HAL status
235
+  */
236
+HAL_StatusTypeDef HAL_DMA_DeInit(DMA_HandleTypeDef *hdma)
237
+{
238
+  /* Check the DMA handle allocation */
239
+  if(hdma == NULL)
240
+  {
241
+    return HAL_ERROR;
242
+  }
243
+
244
+  /* Check the parameters */
245
+  assert_param(IS_DMA_ALL_INSTANCE(hdma->Instance));
246
+
247
+  /* Disable the selected DMA Channelx */
248
+  __HAL_DMA_DISABLE(hdma);
249
+
250
+  /* Reset DMA Channel control register */
251
+  hdma->Instance->CCR  = 0U;
252
+
253
+  /* Reset DMA Channel Number of Data to Transfer register */
254
+  hdma->Instance->CNDTR = 0U;
255
+
256
+  /* Reset DMA Channel peripheral address register */
257
+  hdma->Instance->CPAR  = 0U;
258
+
259
+  /* Reset DMA Channel memory address register */
260
+  hdma->Instance->CMAR = 0U;
261
+
262
+#if defined (STM32F101xE) || defined (STM32F101xG) || defined (STM32F103xE) || defined (STM32F103xG) || defined (STM32F100xE) || defined (STM32F105xC) || defined (STM32F107xC)
263
+  /* calculation of the channel index */
264
+  if ((uint32_t)(hdma->Instance) < (uint32_t)(DMA2_Channel1))
265
+  {
266
+    /* DMA1 */
267
+    hdma->ChannelIndex = (((uint32_t)hdma->Instance - (uint32_t)DMA1_Channel1) / ((uint32_t)DMA1_Channel2 - (uint32_t)DMA1_Channel1)) << 2;
268
+    hdma->DmaBaseAddress = DMA1;
269
+  }
270
+  else
271
+  {
272
+    /* DMA2 */
273
+    hdma->ChannelIndex = (((uint32_t)hdma->Instance - (uint32_t)DMA2_Channel1) / ((uint32_t)DMA2_Channel2 - (uint32_t)DMA2_Channel1)) << 2;
274
+    hdma->DmaBaseAddress = DMA2;
275
+  }
276
+#else
277
+  /* DMA1 */
278
+  hdma->ChannelIndex = (((uint32_t)hdma->Instance - (uint32_t)DMA1_Channel1) / ((uint32_t)DMA1_Channel2 - (uint32_t)DMA1_Channel1)) << 2;
279
+  hdma->DmaBaseAddress = DMA1;
280
+#endif /* STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG || STM32F100xE || STM32F105xC || STM32F107xC */
281
+
282
+  /* Clear all flags */
283
+  hdma->DmaBaseAddress->IFCR = (DMA_ISR_GIF1 << (hdma->ChannelIndex));
284
+
285
+  /* Clean all callbacks */
286
+  hdma->XferCpltCallback = NULL;
287
+  hdma->XferHalfCpltCallback = NULL;
288
+  hdma->XferErrorCallback = NULL;
289
+  hdma->XferAbortCallback = NULL;
290
+
291
+  /* Reset the error code */
292
+  hdma->ErrorCode = HAL_DMA_ERROR_NONE;
293
+
294
+  /* Reset the DMA state */
295
+  hdma->State = HAL_DMA_STATE_RESET;
296
+
297
+  /* Release Lock */
298
+  __HAL_UNLOCK(hdma);
299
+
300
+  return HAL_OK;
301
+}
302
+
303
+/**
304
+  * @}
305
+  */
306
+
307
+/** @defgroup DMA_Exported_Functions_Group2 Input and Output operation functions
308
+  *  @brief   Input and Output operation functions
309
+  *
310
+@verbatim
311
+ ===============================================================================
312
+                      #####  IO operation functions  #####
313
+ ===============================================================================
314
+    [..]  This section provides functions allowing to:
315
+      (+) Configure the source, destination address and data length and Start DMA transfer
316
+      (+) Configure the source, destination address and data length and
317
+          Start DMA transfer with interrupt
318
+      (+) Abort DMA transfer
319
+      (+) Poll for transfer complete
320
+      (+) Handle DMA interrupt request
321
+
322
+@endverbatim
323
+  * @{
324
+  */
325
+
326
+/**
327
+  * @brief  Start the DMA Transfer.
328
+  * @param  hdma: pointer to a DMA_HandleTypeDef structure that contains
329
+  *               the configuration information for the specified DMA Channel.
330
+  * @param  SrcAddress: The source memory Buffer address
331
+  * @param  DstAddress: The destination memory Buffer address
332
+  * @param  DataLength: The length of data to be transferred from source to destination
333
+  * @retval HAL status
334
+  */
335
+HAL_StatusTypeDef HAL_DMA_Start(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength)
336
+{
337
+  HAL_StatusTypeDef status = HAL_OK;
338
+
339
+  /* Check the parameters */
340
+  assert_param(IS_DMA_BUFFER_SIZE(DataLength));
341
+
342
+  /* Process locked */
343
+  __HAL_LOCK(hdma);
344
+
345
+  if(HAL_DMA_STATE_READY == hdma->State)
346
+  {
347
+    /* Change DMA peripheral state */
348
+    hdma->State = HAL_DMA_STATE_BUSY;
349
+    hdma->ErrorCode = HAL_DMA_ERROR_NONE;
350
+            
351
+    /* Disable the peripheral */
352
+    __HAL_DMA_DISABLE(hdma);
353
+    
354
+    /* Configure the source, destination address and the data length & clear flags*/
355
+    DMA_SetConfig(hdma, SrcAddress, DstAddress, DataLength);
356
+    
357
+    /* Enable the Peripheral */
358
+    __HAL_DMA_ENABLE(hdma);
359
+  }
360
+  else
361
+  {
362
+   /* Process Unlocked */
363
+   __HAL_UNLOCK(hdma);  
364
+   status = HAL_BUSY;
365
+  }  
366
+  return status;
367
+}
368
+
369
+/**
370
+  * @brief  Start the DMA Transfer with interrupt enabled.
371
+  * @param  hdma: pointer to a DMA_HandleTypeDef structure that contains
372
+  *               the configuration information for the specified DMA Channel.
373
+  * @param  SrcAddress: The source memory Buffer address
374
+  * @param  DstAddress: The destination memory Buffer address
375
+  * @param  DataLength: The length of data to be transferred from source to destination
376
+  * @retval HAL status
377
+  */
378
+HAL_StatusTypeDef HAL_DMA_Start_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength)
379
+{
380
+  HAL_StatusTypeDef status = HAL_OK;
381
+
382
+  /* Check the parameters */
383
+  assert_param(IS_DMA_BUFFER_SIZE(DataLength));
384
+
385
+  /* Process locked */
386
+  __HAL_LOCK(hdma);
387
+  
388
+  if(HAL_DMA_STATE_READY == hdma->State)
389
+  {
390
+    /* Change DMA peripheral state */
391
+    hdma->State = HAL_DMA_STATE_BUSY;
392
+    hdma->ErrorCode = HAL_DMA_ERROR_NONE;
393
+    
394
+    /* Disable the peripheral */
395
+    __HAL_DMA_DISABLE(hdma);
396
+    
397
+    /* Configure the source, destination address and the data length & clear flags*/
398
+    DMA_SetConfig(hdma, SrcAddress, DstAddress, DataLength);
399
+    
400
+    /* Enable the transfer complete interrupt */
401
+    /* Enable the transfer Error interrupt */
402
+    if(NULL != hdma->XferHalfCpltCallback)
403
+    {
404
+      /* Enable the Half transfer complete interrupt as well */
405
+      __HAL_DMA_ENABLE_IT(hdma, (DMA_IT_TC | DMA_IT_HT | DMA_IT_TE));
406
+    }
407
+    else
408
+    {
409
+      __HAL_DMA_DISABLE_IT(hdma, DMA_IT_HT);
410
+      __HAL_DMA_ENABLE_IT(hdma, (DMA_IT_TC | DMA_IT_TE));
411
+    }
412
+    /* Enable the Peripheral */
413
+    __HAL_DMA_ENABLE(hdma);
414
+  }
415
+  else
416
+  {      
417
+    /* Process Unlocked */
418
+    __HAL_UNLOCK(hdma); 
419
+
420
+    /* Remain BUSY */
421
+    status = HAL_BUSY;
422
+  }    
423
+  return status;
424
+}
425
+
426
+/**
427
+  * @brief  Abort the DMA Transfer.
428
+  * @param  hdma: pointer to a DMA_HandleTypeDef structure that contains
429
+  *               the configuration information for the specified DMA Channel.
430
+  * @retval HAL status
431
+  */
432
+HAL_StatusTypeDef HAL_DMA_Abort(DMA_HandleTypeDef *hdma)
433
+{
434
+  HAL_StatusTypeDef status = HAL_OK;
435
+
436
+  /* Disable DMA IT */
437
+  __HAL_DMA_DISABLE_IT(hdma, (DMA_IT_TC | DMA_IT_HT | DMA_IT_TE));
438
+    
439
+  /* Disable the channel */
440
+  __HAL_DMA_DISABLE(hdma);
441
+    
442
+  /* Clear all flags */
443
+  hdma->DmaBaseAddress->IFCR = (DMA_ISR_GIF1 << hdma->ChannelIndex);
444
+
445
+  /* Change the DMA state */
446
+  hdma->State = HAL_DMA_STATE_READY;
447
+
448
+  /* Process Unlocked */
449
+  __HAL_UNLOCK(hdma);      
450
+  
451
+  return status; 
452
+}
453
+
454
+/**
455
+  * @brief  Aborts the DMA Transfer in Interrupt mode.
456
+  * @param  hdma  : pointer to a DMA_HandleTypeDef structure that contains
457
+  *                 the configuration information for the specified DMA Channel.
458
+  * @retval HAL status
459
+  */
460
+HAL_StatusTypeDef HAL_DMA_Abort_IT(DMA_HandleTypeDef *hdma)
461
+{  
462
+  HAL_StatusTypeDef status = HAL_OK;
463
+  
464
+  if(HAL_DMA_STATE_BUSY != hdma->State)
465
+  {
466
+    /* no transfer ongoing */
467
+    hdma->ErrorCode = HAL_DMA_ERROR_NO_XFER;
468
+        
469
+    status = HAL_ERROR;
470
+  }
471
+  else
472
+  { 
473
+    /* Disable DMA IT */
474
+    __HAL_DMA_DISABLE_IT(hdma, (DMA_IT_TC | DMA_IT_HT | DMA_IT_TE));
475
+
476
+    /* Disable the channel */
477
+    __HAL_DMA_DISABLE(hdma);
478
+
479
+    /* Clear all flags */
480
+    __HAL_DMA_CLEAR_FLAG(hdma, __HAL_DMA_GET_GI_FLAG_INDEX(hdma));
481
+
482
+    /* Change the DMA state */
483
+    hdma->State = HAL_DMA_STATE_READY;
484
+
485
+    /* Process Unlocked */
486
+    __HAL_UNLOCK(hdma);
487
+
488
+    /* Call User Abort callback */
489
+    if(hdma->XferAbortCallback != NULL)
490
+    {
491
+      hdma->XferAbortCallback(hdma);
492
+    } 
493
+  }
494
+  return status;
495
+}
496
+
497
+/**
498
+  * @brief  Polling for transfer complete.
499
+  * @param  hdma:    pointer to a DMA_HandleTypeDef structure that contains
500
+  *                  the configuration information for the specified DMA Channel.
501
+  * @param  CompleteLevel: Specifies the DMA level complete.
502
+  * @param  Timeout:       Timeout duration.
503
+  * @retval HAL status
504
+  */
505
+HAL_StatusTypeDef HAL_DMA_PollForTransfer(DMA_HandleTypeDef *hdma, uint32_t CompleteLevel, uint32_t Timeout)
506
+{
507
+  uint32_t temp;
508
+  uint32_t tickstart = 0U;
509
+
510
+  if(HAL_DMA_STATE_BUSY != hdma->State)
511
+  {
512
+    /* no transfer ongoing */
513
+    hdma->ErrorCode = HAL_DMA_ERROR_NO_XFER;
514
+    __HAL_UNLOCK(hdma);
515
+    return HAL_ERROR;
516
+  }
517
+
518
+  /* Polling mode not supported in circular mode */
519
+  if (RESET != (hdma->Instance->CCR & DMA_CCR_CIRC))
520
+  {
521
+    hdma->ErrorCode = HAL_DMA_ERROR_NOT_SUPPORTED;
522
+    return HAL_ERROR;
523
+  }
524
+  
525
+  /* Get the level transfer complete flag */
526
+  if(CompleteLevel == HAL_DMA_FULL_TRANSFER)
527
+  {
528
+    /* Transfer Complete flag */
529
+    temp = __HAL_DMA_GET_TC_FLAG_INDEX(hdma);
530
+  }
531
+  else
532
+  {
533
+    /* Half Transfer Complete flag */
534
+    temp = __HAL_DMA_GET_HT_FLAG_INDEX(hdma);
535
+  }
536
+
537
+  /* Get tick */
538
+  tickstart = HAL_GetTick();
539
+
540
+  while(__HAL_DMA_GET_FLAG(hdma, temp) == RESET)
541
+  {
542
+    if((__HAL_DMA_GET_FLAG(hdma, __HAL_DMA_GET_TE_FLAG_INDEX(hdma)) != RESET))
543
+    {
544
+      /* When a DMA transfer error occurs */
545
+      /* A hardware clear of its EN bits is performed */
546
+      /* Clear all flags */
547
+      hdma->DmaBaseAddress->IFCR = (DMA_ISR_GIF1 << hdma->ChannelIndex);
548
+
549
+      /* Update error code */
550
+      SET_BIT(hdma->ErrorCode, HAL_DMA_ERROR_TE);
551
+
552
+      /* Change the DMA state */
553
+      hdma->State= HAL_DMA_STATE_READY;
554
+
555
+      /* Process Unlocked */
556
+      __HAL_UNLOCK(hdma);
557
+
558
+      return HAL_ERROR;
559
+    }
560
+    /* Check for the Timeout */
561
+    if(Timeout != HAL_MAX_DELAY)
562
+    {
563
+      if((Timeout == 0U) || ((HAL_GetTick() - tickstart) > Timeout))
564
+      {
565
+        /* Update error code */
566
+        SET_BIT(hdma->ErrorCode, HAL_DMA_ERROR_TIMEOUT);
567
+
568
+        /* Change the DMA state */
569
+        hdma->State = HAL_DMA_STATE_READY;
570
+
571
+        /* Process Unlocked */
572
+        __HAL_UNLOCK(hdma);
573
+
574
+        return HAL_ERROR;
575
+      }
576
+    }
577
+  }
578
+
579
+  if(CompleteLevel == HAL_DMA_FULL_TRANSFER)
580
+  {
581
+    /* Clear the transfer complete flag */
582
+    __HAL_DMA_CLEAR_FLAG(hdma, __HAL_DMA_GET_TC_FLAG_INDEX(hdma));
583
+
584
+    /* The selected Channelx EN bit is cleared (DMA is disabled and
585
+    all transfers are complete) */
586
+    hdma->State = HAL_DMA_STATE_READY;
587
+  }
588
+  else
589
+  {
590
+    /* Clear the half transfer complete flag */
591
+    __HAL_DMA_CLEAR_FLAG(hdma, __HAL_DMA_GET_HT_FLAG_INDEX(hdma));
592
+  }
593
+  
594
+  /* Process unlocked */
595
+  __HAL_UNLOCK(hdma);
596
+
597
+  return HAL_OK;
598
+}
599
+
600
+/**
601
+  * @brief  Handles DMA interrupt request.
602
+  * @param  hdma: pointer to a DMA_HandleTypeDef structure that contains
603
+  *               the configuration information for the specified DMA Channel.  
604
+  * @retval None
605
+  */
606
+void HAL_DMA_IRQHandler(DMA_HandleTypeDef *hdma)
607
+{
608
+  uint32_t flag_it = hdma->DmaBaseAddress->ISR;
609
+  uint32_t source_it = hdma->Instance->CCR;
610
+  
611
+  /* Half Transfer Complete Interrupt management ******************************/
612
+  if (((flag_it & (DMA_FLAG_HT1 << hdma->ChannelIndex)) != RESET) && ((source_it & DMA_IT_HT) != RESET))
613
+  {
614
+    /* Disable the half transfer interrupt if the DMA mode is not CIRCULAR */
615
+    if((hdma->Instance->CCR & DMA_CCR_CIRC) == 0U)
616
+    {
617
+      /* Disable the half transfer interrupt */
618
+      __HAL_DMA_DISABLE_IT(hdma, DMA_IT_HT);
619
+    }
620
+    /* Clear the half transfer complete flag */
621
+    __HAL_DMA_CLEAR_FLAG(hdma, __HAL_DMA_GET_HT_FLAG_INDEX(hdma));
622
+
623
+    /* DMA peripheral state is not updated in Half Transfer */
624
+    /* but in Transfer Complete case */
625
+
626
+    if(hdma->XferHalfCpltCallback != NULL)
627
+    {
628
+      /* Half transfer callback */
629
+      hdma->XferHalfCpltCallback(hdma);
630
+    }
631
+  }
632
+
633
+  /* Transfer Complete Interrupt management ***********************************/
634
+  else if (((flag_it & (DMA_FLAG_TC1 << hdma->ChannelIndex)) != RESET) && ((source_it & DMA_IT_TC) != RESET))
635
+  {
636
+    if((hdma->Instance->CCR & DMA_CCR_CIRC) == 0U)
637
+    {
638
+      /* Disable the transfer complete and error interrupt */
639
+      __HAL_DMA_DISABLE_IT(hdma, DMA_IT_TE | DMA_IT_TC);  
640
+
641
+      /* Change the DMA state */
642
+      hdma->State = HAL_DMA_STATE_READY;
643
+    }
644
+    /* Clear the transfer complete flag */
645
+      __HAL_DMA_CLEAR_FLAG(hdma, __HAL_DMA_GET_TC_FLAG_INDEX(hdma));
646
+
647
+    /* Process Unlocked */
648
+    __HAL_UNLOCK(hdma);
649
+
650
+    if(hdma->XferCpltCallback != NULL)
651
+    {
652
+      /* Transfer complete callback */
653
+      hdma->XferCpltCallback(hdma);
654
+    }
655
+  }
656
+
657
+  /* Transfer Error Interrupt management **************************************/
658
+  else if (( RESET != (flag_it & (DMA_FLAG_TE1 << hdma->ChannelIndex))) && (RESET != (source_it & DMA_IT_TE)))
659
+  {
660
+    /* When a DMA transfer error occurs */
661
+    /* A hardware clear of its EN bits is performed */
662
+    /* Disable ALL DMA IT */
663
+    __HAL_DMA_DISABLE_IT(hdma, (DMA_IT_TC | DMA_IT_HT | DMA_IT_TE));
664
+
665
+    /* Clear all flags */
666
+    hdma->DmaBaseAddress->IFCR = (DMA_ISR_GIF1 << hdma->ChannelIndex);
667
+
668
+    /* Update error code */
669
+    hdma->ErrorCode = HAL_DMA_ERROR_TE;
670
+
671
+    /* Change the DMA state */
672
+    hdma->State = HAL_DMA_STATE_READY;
673
+
674
+    /* Process Unlocked */
675
+    __HAL_UNLOCK(hdma);
676
+
677
+    if (hdma->XferErrorCallback != NULL)
678
+    {
679
+      /* Transfer error callback */
680
+      hdma->XferErrorCallback(hdma);
681
+    }
682
+  }
683
+  return;
684
+}
685
+
686
+/**
687
+  * @brief Register callbacks
688
+  * @param hdma: pointer to a DMA_HandleTypeDef structure that contains
689
+  *              the configuration information for the specified DMA Channel.
690
+  * @param CallbackID: User Callback identifer
691
+  *                    a HAL_DMA_CallbackIDTypeDef ENUM as parameter.
692
+  * @param pCallback: pointer to private callbacsk function which has pointer to 
693
+  *                   a DMA_HandleTypeDef structure as parameter.
694
+  * @retval HAL status
695
+  */                          
696
+HAL_StatusTypeDef HAL_DMA_RegisterCallback(DMA_HandleTypeDef *hdma, HAL_DMA_CallbackIDTypeDef CallbackID, void (* pCallback)( DMA_HandleTypeDef * _hdma))
697
+{
698
+  HAL_StatusTypeDef status = HAL_OK;
699
+  
700
+  /* Process locked */
701
+  __HAL_LOCK(hdma);
702
+  
703
+  if(HAL_DMA_STATE_READY == hdma->State)
704
+  {
705
+    switch (CallbackID)
706
+    {
707
+    case  HAL_DMA_XFER_CPLT_CB_ID:
708
+      hdma->XferCpltCallback = pCallback;
709
+      break;
710
+      
711
+    case  HAL_DMA_XFER_HALFCPLT_CB_ID:
712
+      hdma->XferHalfCpltCallback = pCallback;
713
+      break;         
714
+
715
+    case  HAL_DMA_XFER_ERROR_CB_ID:
716
+      hdma->XferErrorCallback = pCallback;
717
+      break;         
718
+      
719
+    case  HAL_DMA_XFER_ABORT_CB_ID:
720
+      hdma->XferAbortCallback = pCallback;
721
+      break; 
722
+      
723
+    default:
724
+      status = HAL_ERROR;
725
+      break;                                                            
726
+    }
727
+  }
728
+  else
729
+  {
730
+    status = HAL_ERROR;
731
+  } 
732
+  
733
+  /* Release Lock */
734
+  __HAL_UNLOCK(hdma);
735
+  
736
+  return status;
737
+}
738
+
739
+/**
740
+  * @brief UnRegister callbacks
741
+  * @param hdma: pointer to a DMA_HandleTypeDef structure that contains
742
+  *              the configuration information for the specified DMA Channel.
743
+  * @param CallbackID: User Callback identifer
744
+  *                    a HAL_DMA_CallbackIDTypeDef ENUM as parameter.
745
+  * @retval HAL status
746
+  */              
747
+HAL_StatusTypeDef HAL_DMA_UnRegisterCallback(DMA_HandleTypeDef *hdma, HAL_DMA_CallbackIDTypeDef CallbackID)
748
+{
749
+  HAL_StatusTypeDef status = HAL_OK;
750
+
751
+  /* Process locked */
752
+  __HAL_LOCK(hdma);
753
+  
754
+  if(HAL_DMA_STATE_READY == hdma->State)
755
+  {
756
+    switch (CallbackID)
757
+    {
758
+    case  HAL_DMA_XFER_CPLT_CB_ID:
759
+      hdma->XferCpltCallback = NULL;
760
+      break;
761
+
762
+    case  HAL_DMA_XFER_HALFCPLT_CB_ID:
763
+      hdma->XferHalfCpltCallback = NULL;
764
+      break;         
765
+
766
+    case  HAL_DMA_XFER_ERROR_CB_ID:
767
+      hdma->XferErrorCallback = NULL;
768
+      break;         
769
+
770
+    case  HAL_DMA_XFER_ABORT_CB_ID:
771
+      hdma->XferAbortCallback = NULL;
772
+      break; 
773
+
774
+    case   HAL_DMA_XFER_ALL_CB_ID:
775
+      hdma->XferCpltCallback = NULL;
776
+      hdma->XferHalfCpltCallback = NULL;
777
+      hdma->XferErrorCallback = NULL;
778
+      hdma->XferAbortCallback = NULL;
779
+      break; 
780
+
781
+    default:
782
+      status = HAL_ERROR;
783
+      break;
784
+    }
785
+  }
786
+  else
787
+  {
788
+    status = HAL_ERROR;
789
+  } 
790
+  
791
+  /* Release Lock */
792
+  __HAL_UNLOCK(hdma);
793
+  
794
+  return status;
795
+}
796
+  
797
+/**
798
+  * @}
799
+  */
800
+
801
+/** @defgroup DMA_Exported_Functions_Group3 Peripheral State and Errors functions
802
+  *  @brief    Peripheral State and Errors functions
803
+  *
804
+@verbatim
805
+ ===============================================================================
806
+            ##### Peripheral State and Errors functions #####
807
+ ===============================================================================  
808
+    [..]
809
+    This subsection provides functions allowing to
810
+      (+) Check the DMA state
811
+      (+) Get error code
812
+
813
+@endverbatim
814
+  * @{
815
+  */
816
+
817
+/**
818
+  * @brief  Return the DMA hande state.
819
+  * @param  hdma: pointer to a DMA_HandleTypeDef structure that contains
820
+  *               the configuration information for the specified DMA Channel.
821
+  * @retval HAL state
822
+  */
823
+HAL_DMA_StateTypeDef HAL_DMA_GetState(DMA_HandleTypeDef *hdma)
824
+{
825
+  /* Return DMA handle state */
826
+  return hdma->State;
827
+}
828
+
829
+/**
830
+  * @brief  Return the DMA error code.
831
+  * @param  hdma : pointer to a DMA_HandleTypeDef structure that contains
832
+  *              the configuration information for the specified DMA Channel.
833
+  * @retval DMA Error Code
834
+  */
835
+uint32_t HAL_DMA_GetError(DMA_HandleTypeDef *hdma)
836
+{
837
+  return hdma->ErrorCode;
838
+}
839
+
840
+/**
841
+  * @}
842
+  */
843
+
844
+/**
845
+  * @}
846
+  */
847
+
848
+/** @addtogroup DMA_Private_Functions
849
+  * @{
850
+  */
851
+
852
+/**
853
+  * @brief  Sets the DMA Transfer parameter.
854
+  * @param  hdma:       pointer to a DMA_HandleTypeDef structure that contains
855
+  *                     the configuration information for the specified DMA Channel.
856
+  * @param  SrcAddress: The source memory Buffer address
857
+  * @param  DstAddress: The destination memory Buffer address
858
+  * @param  DataLength: The length of data to be transferred from source to destination
859
+  * @retval HAL status
860
+  */
861
+static void DMA_SetConfig(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength)
862
+{
863
+  /* Clear all flags */
864
+  hdma->DmaBaseAddress->IFCR = (DMA_ISR_GIF1 << hdma->ChannelIndex);
865
+
866
+  /* Configure DMA Channel data length */
867
+  hdma->Instance->CNDTR = DataLength;
868
+
869
+  /* Memory to Peripheral */
870
+  if((hdma->Init.Direction) == DMA_MEMORY_TO_PERIPH)
871
+  {
872
+    /* Configure DMA Channel destination address */
873
+    hdma->Instance->CPAR = DstAddress;
874
+
875
+    /* Configure DMA Channel source address */
876
+    hdma->Instance->CMAR = SrcAddress;
877
+  }
878
+  /* Peripheral to Memory */
879
+  else
880
+  {
881
+    /* Configure DMA Channel source address */
882
+    hdma->Instance->CPAR = SrcAddress;
883
+
884
+    /* Configure DMA Channel destination address */
885
+    hdma->Instance->CMAR = DstAddress;
886
+  }
887
+}
888
+
889
+/**
890
+  * @}
891
+  */
892
+
893
+#endif /* HAL_DMA_MODULE_ENABLED */
894
+/**
895
+  * @}
896
+  */
897
+
898
+/**
899
+  * @}
900
+  */
901
+
902
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 983 - 0
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c

@@ -0,0 +1,983 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx_hal_flash.c
4
+  * @author  MCD Application Team
5
+  * @brief   FLASH HAL module driver.
6
+  *          This file provides firmware functions to manage the following 
7
+  *          functionalities of the internal FLASH memory:
8
+  *           + Program operations functions
9
+  *           + Memory Control functions 
10
+  *           + Peripheral State functions
11
+  *         
12
+  @verbatim
13
+  ==============================================================================
14
+                        ##### FLASH peripheral features #####
15
+  ==============================================================================
16
+  [..] The Flash memory interface manages CPU AHB I-Code and D-Code accesses 
17
+       to the Flash memory. It implements the erase and program Flash memory operations 
18
+       and the read and write protection mechanisms.
19
+
20
+  [..] The Flash memory interface accelerates code execution with a system of instruction
21
+      prefetch. 
22
+
23
+  [..] The FLASH main features are:
24
+      (+) Flash memory read operations
25
+      (+) Flash memory program/erase operations
26
+      (+) Read / write protections
27
+      (+) Prefetch on I-Code
28
+      (+) Option Bytes programming
29
+
30
+
31
+                     ##### How to use this driver #####
32
+  ==============================================================================
33
+  [..]                             
34
+      This driver provides functions and macros to configure and program the FLASH 
35
+      memory of all STM32F1xx devices.
36
+    
37
+      (#) FLASH Memory I/O Programming functions: this group includes all needed
38
+          functions to erase and program the main memory:
39
+        (++) Lock and Unlock the FLASH interface
40
+        (++) Erase function: Erase page, erase all pages
41
+        (++) Program functions: half word, word and doubleword
42
+      (#) FLASH Option Bytes Programming functions: this group includes all needed
43
+          functions to manage the Option Bytes:
44
+        (++) Lock and Unlock the Option Bytes
45
+        (++) Set/Reset the write protection
46
+        (++) Set the Read protection Level
47
+        (++) Program the user Option Bytes
48
+        (++) Launch the Option Bytes loader
49
+        (++) Erase Option Bytes
50
+        (++) Program the data Option Bytes
51
+        (++) Get the Write protection.
52
+        (++) Get the user option bytes.
53
+    
54
+      (#) Interrupts and flags management functions : this group 
55
+          includes all needed functions to:
56
+        (++) Handle FLASH interrupts
57
+        (++) Wait for last FLASH operation according to its status
58
+        (++) Get error flag status
59
+
60
+  [..] In addition to these function, this driver includes a set of macros allowing
61
+       to handle the following operations:
62
+      
63
+      (+) Set/Get the latency
64
+      (+) Enable/Disable the prefetch buffer
65
+      (+) Enable/Disable the half cycle access
66
+      (+) Enable/Disable the FLASH interrupts
67
+      (+) Monitor the FLASH flags status
68
+          
69
+  @endverbatim
70
+  ******************************************************************************
71
+  * @attention
72
+  *
73
+  * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
74
+  *
75
+  * Redistribution and use in source and binary forms, with or without modification,
76
+  * are permitted provided that the following conditions are met:
77
+  *   1. Redistributions of source code must retain the above copyright notice,
78
+  *      this list of conditions and the following disclaimer.
79
+  *   2. Redistributions in binary form must reproduce the above copyright notice,
80
+  *      this list of conditions and the following disclaimer in the documentation
81
+  *      and/or other materials provided with the distribution.
82
+  *   3. Neither the name of STMicroelectronics nor the names of its contributors
83
+  *      may be used to endorse or promote products derived from this software
84
+  *      without specific prior written permission.
85
+  *
86
+  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
87
+  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
88
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
89
+  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
90
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
91
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
92
+  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
93
+  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
94
+  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
95
+  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
96
+  *
97
+  ******************************************************************************  
98
+  */
99
+
100
+/* Includes ------------------------------------------------------------------*/
101
+#include "stm32f1xx_hal.h"
102
+
103
+/** @addtogroup STM32F1xx_HAL_Driver
104
+  * @{
105
+  */
106
+
107
+#ifdef HAL_FLASH_MODULE_ENABLED
108
+
109
+/** @defgroup FLASH FLASH
110
+  * @brief FLASH HAL module driver
111
+  * @{
112
+  */
113
+
114
+/* Private typedef -----------------------------------------------------------*/
115
+/* Private define ------------------------------------------------------------*/
116
+/** @defgroup FLASH_Private_Constants FLASH Private Constants
117
+  * @{
118
+  */
119
+/**
120
+  * @}
121
+  */
122
+
123
+/* Private macro ---------------------------- ---------------------------------*/
124
+/** @defgroup FLASH_Private_Macros FLASH Private Macros
125
+  * @{
126
+  */
127
+ 
128
+/**
129
+  * @}
130
+  */
131
+
132
+/* Private variables ---------------------------------------------------------*/
133
+/** @defgroup FLASH_Private_Variables FLASH Private Variables
134
+  * @{
135
+  */
136
+/* Variables used for Erase pages under interruption*/
137
+FLASH_ProcessTypeDef pFlash;
138
+/**
139
+  * @}
140
+  */
141
+
142
+/* Private function prototypes -----------------------------------------------*/
143
+/** @defgroup FLASH_Private_Functions FLASH Private Functions
144
+  * @{
145
+  */
146
+static  void   FLASH_Program_HalfWord(uint32_t Address, uint16_t Data);
147
+static  void   FLASH_SetErrorCode(void);
148
+extern void    FLASH_PageErase(uint32_t PageAddress);
149
+/**
150
+  * @}
151
+  */
152
+
153
+/* Exported functions ---------------------------------------------------------*/
154
+/** @defgroup FLASH_Exported_Functions FLASH Exported Functions
155
+  * @{
156
+  */
157
+  
158
+/** @defgroup FLASH_Exported_Functions_Group1 Programming operation functions 
159
+  *  @brief   Programming operation functions 
160
+  *
161
+@verbatim   
162
+@endverbatim
163
+  * @{
164
+  */
165
+
166
+/**
167
+  * @brief  Program halfword, word or double word at a specified address
168
+  * @note   The function HAL_FLASH_Unlock() should be called before to unlock the FLASH interface
169
+  *         The function HAL_FLASH_Lock() should be called after to lock the FLASH interface
170
+  *
171
+  * @note   If an erase and a program operations are requested simultaneously,    
172
+  *         the erase operation is performed before the program one.
173
+  *  
174
+  * @note   FLASH should be previously erased before new programmation (only exception to this 
175
+  *         is when 0x0000 is programmed)
176
+  *
177
+  * @param  TypeProgram:  Indicate the way to program at a specified address.
178
+  *                       This parameter can be a value of @ref FLASH_Type_Program
179
+  * @param  Address:      Specifies the address to be programmed.
180
+  * @param  Data:         Specifies the data to be programmed
181
+  * 
182
+  * @retval HAL_StatusTypeDef HAL Status
183
+  */
184
+HAL_StatusTypeDef HAL_FLASH_Program(uint32_t TypeProgram, uint32_t Address, uint64_t Data)
185
+{
186
+  HAL_StatusTypeDef status = HAL_ERROR;
187
+  uint8_t index = 0;
188
+  uint8_t nbiterations = 0;
189
+  
190
+  /* Process Locked */
191
+  __HAL_LOCK(&pFlash);
192
+
193
+  /* Check the parameters */
194
+  assert_param(IS_FLASH_TYPEPROGRAM(TypeProgram));
195
+  assert_param(IS_FLASH_PROGRAM_ADDRESS(Address));
196
+
197
+#if defined(FLASH_BANK2_END)
198
+  if(Address <= FLASH_BANK1_END)
199
+  {
200
+#endif /* FLASH_BANK2_END */
201
+    /* Wait for last operation to be completed */
202
+    status = FLASH_WaitForLastOperation(FLASH_TIMEOUT_VALUE);
203
+#if defined(FLASH_BANK2_END)
204
+  }
205
+  else
206
+  {
207
+    /* Wait for last operation to be completed */
208
+    status = FLASH_WaitForLastOperationBank2(FLASH_TIMEOUT_VALUE);
209
+  }
210
+#endif /* FLASH_BANK2_END */
211
+  
212
+  if(status == HAL_OK)
213
+  {
214
+    if(TypeProgram == FLASH_TYPEPROGRAM_HALFWORD)
215
+    {
216
+      /* Program halfword (16-bit) at a specified address. */
217
+      nbiterations = 1U;
218
+    }
219
+    else if(TypeProgram == FLASH_TYPEPROGRAM_WORD)
220
+    {
221
+      /* Program word (32-bit = 2*16-bit) at a specified address. */
222
+      nbiterations = 2U;
223
+    }
224
+    else
225
+    {
226
+      /* Program double word (64-bit = 4*16-bit) at a specified address. */
227
+      nbiterations = 4U;
228
+    }
229
+
230
+    for (index = 0U; index < nbiterations; index++)
231
+    {
232
+      FLASH_Program_HalfWord((Address + (2U*index)), (uint16_t)(Data >> (16U*index)));
233
+
234
+#if defined(FLASH_BANK2_END)
235
+      if(Address <= FLASH_BANK1_END)
236
+      {
237
+#endif /* FLASH_BANK2_END */
238
+        /* Wait for last operation to be completed */
239
+        status = FLASH_WaitForLastOperation(FLASH_TIMEOUT_VALUE);
240
+    
241
+        /* If the program operation is completed, disable the PG Bit */
242
+        CLEAR_BIT(FLASH->CR, FLASH_CR_PG);
243
+#if defined(FLASH_BANK2_END)
244
+      }
245
+      else
246
+      {
247
+        /* Wait for last operation to be completed */
248
+        status = FLASH_WaitForLastOperationBank2(FLASH_TIMEOUT_VALUE);
249
+        
250
+        /* If the program operation is completed, disable the PG Bit */
251
+        CLEAR_BIT(FLASH->CR2, FLASH_CR2_PG);
252
+      }
253
+#endif /* FLASH_BANK2_END */
254
+      /* In case of error, stop programation procedure */
255
+      if (status != HAL_OK)
256
+      {
257
+        break;
258
+      }
259
+    }
260
+  }
261
+
262
+  /* Process Unlocked */
263
+  __HAL_UNLOCK(&pFlash);
264
+
265
+  return status;
266
+}
267
+
268
+/**
269
+  * @brief  Program halfword, word or double word at a specified address  with interrupt enabled.
270
+  * @note   The function HAL_FLASH_Unlock() should be called before to unlock the FLASH interface
271
+  *         The function HAL_FLASH_Lock() should be called after to lock the FLASH interface
272
+  *
273
+  * @note   If an erase and a program operations are requested simultaneously,    
274
+  *         the erase operation is performed before the program one.
275
+  *
276
+  * @param  TypeProgram: Indicate the way to program at a specified address.
277
+  *                      This parameter can be a value of @ref FLASH_Type_Program
278
+  * @param  Address:     Specifies the address to be programmed.
279
+  * @param  Data:        Specifies the data to be programmed
280
+  * 
281
+  * @retval HAL_StatusTypeDef HAL Status
282
+  */
283
+HAL_StatusTypeDef HAL_FLASH_Program_IT(uint32_t TypeProgram, uint32_t Address, uint64_t Data)
284
+{
285
+  HAL_StatusTypeDef status = HAL_OK;
286
+  
287
+  /* Process Locked */
288
+  __HAL_LOCK(&pFlash);
289
+
290
+  /* Check the parameters */
291
+  assert_param(IS_FLASH_TYPEPROGRAM(TypeProgram));
292
+  assert_param(IS_FLASH_PROGRAM_ADDRESS(Address));
293
+
294
+#if defined(FLASH_BANK2_END)
295
+  /* If procedure already ongoing, reject the next one */
296
+  if (pFlash.ProcedureOnGoing != FLASH_PROC_NONE)
297
+  {
298
+    return HAL_ERROR;
299
+  }
300
+  
301
+  if(Address <= FLASH_BANK1_END)
302
+  {
303
+    /* Enable End of FLASH Operation and Error source interrupts */
304
+    __HAL_FLASH_ENABLE_IT(FLASH_IT_EOP_BANK1 | FLASH_IT_ERR_BANK1);
305
+
306
+  }else
307
+  {
308
+    /* Enable End of FLASH Operation and Error source interrupts */
309
+    __HAL_FLASH_ENABLE_IT(FLASH_IT_EOP_BANK2 | FLASH_IT_ERR_BANK2);
310
+  }
311
+#else
312
+  /* Enable End of FLASH Operation and Error source interrupts */
313
+  __HAL_FLASH_ENABLE_IT(FLASH_IT_EOP | FLASH_IT_ERR);
314
+#endif /* FLASH_BANK2_END */
315
+  
316
+  pFlash.Address = Address;
317
+  pFlash.Data = Data;
318
+
319
+  if(TypeProgram == FLASH_TYPEPROGRAM_HALFWORD)
320
+  {
321
+    pFlash.ProcedureOnGoing = FLASH_PROC_PROGRAMHALFWORD;
322
+    /* Program halfword (16-bit) at a specified address. */
323
+    pFlash.DataRemaining = 1U;
324
+  }
325
+  else if(TypeProgram == FLASH_TYPEPROGRAM_WORD)
326
+  {
327
+    pFlash.ProcedureOnGoing = FLASH_PROC_PROGRAMWORD;
328
+    /* Program word (32-bit : 2*16-bit) at a specified address. */
329
+    pFlash.DataRemaining = 2U;
330
+  }
331
+  else
332
+  {
333
+    pFlash.ProcedureOnGoing = FLASH_PROC_PROGRAMDOUBLEWORD;
334
+    /* Program double word (64-bit : 4*16-bit) at a specified address. */
335
+    pFlash.DataRemaining = 4U;
336
+  }
337
+
338
+  /* Program halfword (16-bit) at a specified address. */
339
+  FLASH_Program_HalfWord(Address, (uint16_t)Data);
340
+
341
+  return status;
342
+}
343
+
344
+/**
345
+  * @brief This function handles FLASH interrupt request.
346
+  * @retval None
347
+  */
348
+void HAL_FLASH_IRQHandler(void)
349
+{
350
+  uint32_t addresstmp = 0U;
351
+  
352
+  /* Check FLASH operation error flags */
353
+#if defined(FLASH_BANK2_END)
354
+  if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_WRPERR_BANK1) || __HAL_FLASH_GET_FLAG(FLASH_FLAG_PGERR_BANK1) || \
355
+    (__HAL_FLASH_GET_FLAG(FLASH_FLAG_WRPERR_BANK2) || __HAL_FLASH_GET_FLAG(FLASH_FLAG_PGERR_BANK2)))
356
+#else
357
+  if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_WRPERR) ||__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGERR))
358
+#endif /* FLASH_BANK2_END */
359
+  {
360
+    /* Return the faulty address */
361
+    addresstmp = pFlash.Address;
362
+    /* Reset address */
363
+    pFlash.Address = 0xFFFFFFFFU;
364
+  
365
+    /* Save the Error code */
366
+    FLASH_SetErrorCode();
367
+    
368
+    /* FLASH error interrupt user callback */
369
+    HAL_FLASH_OperationErrorCallback(addresstmp);
370
+
371
+    /* Stop the procedure ongoing */
372
+    pFlash.ProcedureOnGoing = FLASH_PROC_NONE;
373
+  }
374
+
375
+  /* Check FLASH End of Operation flag  */
376
+#if defined(FLASH_BANK2_END)
377
+  if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_EOP_BANK1))
378
+  {
379
+    /* Clear FLASH End of Operation pending bit */
380
+    __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP_BANK1);
381
+#else
382
+  if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_EOP))
383
+  {
384
+    /* Clear FLASH End of Operation pending bit */
385
+    __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP);
386
+#endif /* FLASH_BANK2_END */
387
+    
388
+    /* Process can continue only if no error detected */
389
+    if(pFlash.ProcedureOnGoing != FLASH_PROC_NONE)
390
+    {
391
+      if(pFlash.ProcedureOnGoing == FLASH_PROC_PAGEERASE)
392
+      {
393
+        /* Nb of pages to erased can be decreased */
394
+        pFlash.DataRemaining--;
395
+
396
+        /* Check if there are still pages to erase */
397
+        if(pFlash.DataRemaining != 0U)
398
+        {
399
+          addresstmp = pFlash.Address;
400
+          /*Indicate user which sector has been erased */
401
+          HAL_FLASH_EndOfOperationCallback(addresstmp);
402
+
403
+          /*Increment sector number*/
404
+          addresstmp = pFlash.Address + FLASH_PAGE_SIZE;
405
+          pFlash.Address = addresstmp;
406
+
407
+          /* If the erase operation is completed, disable the PER Bit */
408
+          CLEAR_BIT(FLASH->CR, FLASH_CR_PER);
409
+
410
+          FLASH_PageErase(addresstmp);
411
+        }
412
+        else
413
+        {
414
+          /* No more pages to Erase, user callback can be called. */
415
+          /* Reset Sector and stop Erase pages procedure */
416
+          pFlash.Address = addresstmp = 0xFFFFFFFFU;
417
+          pFlash.ProcedureOnGoing = FLASH_PROC_NONE;
418
+          /* FLASH EOP interrupt user callback */
419
+          HAL_FLASH_EndOfOperationCallback(addresstmp);
420
+        }
421
+      }
422
+      else if(pFlash.ProcedureOnGoing == FLASH_PROC_MASSERASE)
423
+      {
424
+        /* Operation is completed, disable the MER Bit */
425
+        CLEAR_BIT(FLASH->CR, FLASH_CR_MER);
426
+
427
+#if defined(FLASH_BANK2_END)
428
+        /* Stop Mass Erase procedure if no pending mass erase on other bank */
429
+        if (HAL_IS_BIT_CLR(FLASH->CR2, FLASH_CR2_MER))
430
+        {
431
+#endif /* FLASH_BANK2_END */
432
+          /* MassErase ended. Return the selected bank */
433
+          /* FLASH EOP interrupt user callback */
434
+          HAL_FLASH_EndOfOperationCallback(0U);
435
+
436
+          /* Stop Mass Erase procedure*/
437
+          pFlash.ProcedureOnGoing = FLASH_PROC_NONE;
438
+        }
439
+#if defined(FLASH_BANK2_END)
440
+      }
441
+#endif /* FLASH_BANK2_END */
442
+      else
443
+      {
444
+        /* Nb of 16-bit data to program can be decreased */
445
+        pFlash.DataRemaining--;
446
+        
447
+        /* Check if there are still 16-bit data to program */
448
+        if(pFlash.DataRemaining != 0U)
449
+        {
450
+          /* Increment address to 16-bit */
451
+          pFlash.Address += 2U;
452
+          addresstmp = pFlash.Address;
453
+          
454
+          /* Shift to have next 16-bit data */
455
+          pFlash.Data = (pFlash.Data >> 16U);
456
+          
457
+          /* Operation is completed, disable the PG Bit */
458
+          CLEAR_BIT(FLASH->CR, FLASH_CR_PG);
459
+
460
+          /*Program halfword (16-bit) at a specified address.*/
461
+          FLASH_Program_HalfWord(addresstmp, (uint16_t)pFlash.Data);
462
+        }
463
+        else
464
+        {
465
+          /* Program ended. Return the selected address */
466
+          /* FLASH EOP interrupt user callback */
467
+          if (pFlash.ProcedureOnGoing == FLASH_PROC_PROGRAMHALFWORD)
468
+          {
469
+            HAL_FLASH_EndOfOperationCallback(pFlash.Address);
470
+          }
471
+          else if (pFlash.ProcedureOnGoing == FLASH_PROC_PROGRAMWORD)
472
+          {
473
+            HAL_FLASH_EndOfOperationCallback(pFlash.Address - 2U);
474
+          }
475
+          else 
476
+          {
477
+            HAL_FLASH_EndOfOperationCallback(pFlash.Address - 6U);
478
+          }
479
+        
480
+          /* Reset Address and stop Program procedure */
481
+          pFlash.Address = 0xFFFFFFFFU;
482
+          pFlash.ProcedureOnGoing = FLASH_PROC_NONE;
483
+        }
484
+      }
485
+    }
486
+  }
487
+  
488
+#if defined(FLASH_BANK2_END)
489
+  /* Check FLASH End of Operation flag  */
490
+  if(__HAL_FLASH_GET_FLAG( FLASH_FLAG_EOP_BANK2))
491
+  {
492
+    /* Clear FLASH End of Operation pending bit */
493
+    __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP_BANK2);
494
+    
495
+    /* Process can continue only if no error detected */
496
+    if(pFlash.ProcedureOnGoing != FLASH_PROC_NONE)
497
+    {
498
+      if(pFlash.ProcedureOnGoing == FLASH_PROC_PAGEERASE)
499
+      {
500
+        /* Nb of pages to erased can be decreased */
501
+        pFlash.DataRemaining--;
502
+        
503
+        /* Check if there are still pages to erase*/
504
+        if(pFlash.DataRemaining != 0U)
505
+        {
506
+          /* Indicate user which page address has been erased*/
507
+          HAL_FLASH_EndOfOperationCallback(pFlash.Address);
508
+        
509
+          /* Increment page address to next page */
510
+          pFlash.Address += FLASH_PAGE_SIZE;
511
+          addresstmp = pFlash.Address;
512
+
513
+          /* Operation is completed, disable the PER Bit */
514
+          CLEAR_BIT(FLASH->CR2, FLASH_CR2_PER);
515
+
516
+          FLASH_PageErase(addresstmp);
517
+        }
518
+        else
519
+        {
520
+          /*No more pages to Erase*/
521
+          
522
+          /*Reset Address and stop Erase pages procedure*/
523
+          pFlash.Address = 0xFFFFFFFFU;
524
+          pFlash.ProcedureOnGoing = FLASH_PROC_NONE;
525
+
526
+          /* FLASH EOP interrupt user callback */
527
+          HAL_FLASH_EndOfOperationCallback(pFlash.Address);
528
+        }
529
+      }
530
+      else if(pFlash.ProcedureOnGoing == FLASH_PROC_MASSERASE)
531
+      {
532
+        /* Operation is completed, disable the MER Bit */
533
+        CLEAR_BIT(FLASH->CR2, FLASH_CR2_MER);
534
+
535
+        if (HAL_IS_BIT_CLR(FLASH->CR, FLASH_CR_MER))
536
+        {
537
+          /* MassErase ended. Return the selected bank*/
538
+          /* FLASH EOP interrupt user callback */
539
+          HAL_FLASH_EndOfOperationCallback(0U);
540
+        
541
+          pFlash.ProcedureOnGoing = FLASH_PROC_NONE;
542
+        }
543
+      }
544
+      else
545
+      {
546
+        /* Nb of 16-bit data to program can be decreased */
547
+        pFlash.DataRemaining--;
548
+        
549
+        /* Check if there are still 16-bit data to program */
550
+        if(pFlash.DataRemaining != 0U)
551
+        {
552
+          /* Increment address to 16-bit */
553
+          pFlash.Address += 2U;
554
+          addresstmp = pFlash.Address;
555
+          
556
+          /* Shift to have next 16-bit data */
557
+          pFlash.Data = (pFlash.Data >> 16U);
558
+          
559
+          /* Operation is completed, disable the PG Bit */
560
+          CLEAR_BIT(FLASH->CR2, FLASH_CR2_PG);
561
+
562
+          /*Program halfword (16-bit) at a specified address.*/
563
+          FLASH_Program_HalfWord(addresstmp, (uint16_t)pFlash.Data);
564
+        }
565
+        else
566
+        {
567
+          /*Program ended. Return the selected address*/
568
+          /* FLASH EOP interrupt user callback */
569
+          if (pFlash.ProcedureOnGoing == FLASH_PROC_PROGRAMHALFWORD)
570
+          {
571
+            HAL_FLASH_EndOfOperationCallback(pFlash.Address);
572
+          }
573
+          else if (pFlash.ProcedureOnGoing == FLASH_PROC_PROGRAMWORD)
574
+          {
575
+            HAL_FLASH_EndOfOperationCallback(pFlash.Address-2U);
576
+          }
577
+          else 
578
+          {
579
+            HAL_FLASH_EndOfOperationCallback(pFlash.Address-6U);
580
+          }
581
+          
582
+          /* Reset Address and stop Program procedure*/
583
+          pFlash.Address = 0xFFFFFFFFU;
584
+          pFlash.ProcedureOnGoing = FLASH_PROC_NONE;
585
+        }
586
+      }
587
+    }
588
+  }
589
+#endif 
590
+
591
+  if(pFlash.ProcedureOnGoing == FLASH_PROC_NONE)
592
+  {
593
+#if defined(FLASH_BANK2_END)
594
+    /* Operation is completed, disable the PG, PER and MER Bits for both bank */
595
+    CLEAR_BIT(FLASH->CR, (FLASH_CR_PG | FLASH_CR_PER | FLASH_CR_MER));
596
+    CLEAR_BIT(FLASH->CR2, (FLASH_CR2_PG | FLASH_CR2_PER | FLASH_CR2_MER));  
597
+  
598
+    /* Disable End of FLASH Operation and Error source interrupts for both banks */
599
+    __HAL_FLASH_DISABLE_IT(FLASH_IT_EOP_BANK1 | FLASH_IT_ERR_BANK1 | FLASH_IT_EOP_BANK2 | FLASH_IT_ERR_BANK2);
600
+#else
601
+    /* Operation is completed, disable the PG, PER and MER Bits */
602
+    CLEAR_BIT(FLASH->CR, (FLASH_CR_PG | FLASH_CR_PER | FLASH_CR_MER));
603
+
604
+    /* Disable End of FLASH Operation and Error source interrupts */
605
+    __HAL_FLASH_DISABLE_IT(FLASH_IT_EOP | FLASH_IT_ERR);
606
+#endif /* FLASH_BANK2_END */
607
+
608
+    /* Process Unlocked */
609
+    __HAL_UNLOCK(&pFlash);
610
+  }
611
+}
612
+
613
+/**
614
+  * @brief  FLASH end of operation interrupt callback
615
+  * @param  ReturnValue: The value saved in this parameter depends on the ongoing procedure
616
+  *                 - Mass Erase: No return value expected
617
+  *                 - Pages Erase: Address of the page which has been erased 
618
+  *                    (if 0xFFFFFFFF, it means that all the selected pages have been erased)
619
+  *                 - Program: Address which was selected for data program
620
+  * @retval none
621
+  */
622
+__weak void HAL_FLASH_EndOfOperationCallback(uint32_t ReturnValue)
623
+{
624
+  /* Prevent unused argument(s) compilation warning */
625
+  UNUSED(ReturnValue);
626
+
627
+  /* NOTE : This function Should not be modified, when the callback is needed,
628
+            the HAL_FLASH_EndOfOperationCallback could be implemented in the user file
629
+   */ 
630
+}
631
+
632
+/**
633
+  * @brief  FLASH operation error interrupt callback
634
+  * @param  ReturnValue: The value saved in this parameter depends on the ongoing procedure
635
+  *                 - Mass Erase: No return value expected
636
+  *                 - Pages Erase: Address of the page which returned an error
637
+  *                 - Program: Address which was selected for data program
638
+  * @retval none
639
+  */
640
+__weak void HAL_FLASH_OperationErrorCallback(uint32_t ReturnValue)
641
+{
642
+  /* Prevent unused argument(s) compilation warning */
643
+  UNUSED(ReturnValue);
644
+
645
+  /* NOTE : This function Should not be modified, when the callback is needed,
646
+            the HAL_FLASH_OperationErrorCallback could be implemented in the user file
647
+   */ 
648
+}
649
+
650
+/**
651
+  * @}
652
+  */
653
+
654
+/** @defgroup FLASH_Exported_Functions_Group2 Peripheral Control functions 
655
+ *  @brief   management functions 
656
+ *
657
+@verbatim   
658
+ ===============================================================================
659
+                      ##### Peripheral Control functions #####
660
+ ===============================================================================  
661
+    [..]
662
+    This subsection provides a set of functions allowing to control the FLASH 
663
+    memory operations.
664
+
665
+@endverbatim
666
+  * @{
667
+  */
668
+
669
+/**
670
+  * @brief  Unlock the FLASH control register access
671
+  * @retval HAL Status
672
+  */
673
+HAL_StatusTypeDef HAL_FLASH_Unlock(void)
674
+{
675
+  HAL_StatusTypeDef status = HAL_OK;
676
+
677
+  if(READ_BIT(FLASH->CR, FLASH_CR_LOCK) != RESET)
678
+  {
679
+    /* Authorize the FLASH Registers access */
680
+    WRITE_REG(FLASH->KEYR, FLASH_KEY1);
681
+    WRITE_REG(FLASH->KEYR, FLASH_KEY2);
682
+
683
+    /* Verify Flash is unlocked */
684
+    if(READ_BIT(FLASH->CR, FLASH_CR_LOCK) != RESET)
685
+    {
686
+      status = HAL_ERROR;
687
+    }
688
+  }
689
+#if defined(FLASH_BANK2_END)
690
+  if(READ_BIT(FLASH->CR2, FLASH_CR2_LOCK) != RESET)
691
+  {
692
+    /* Authorize the FLASH BANK2 Registers access */
693
+    WRITE_REG(FLASH->KEYR2, FLASH_KEY1);
694
+    WRITE_REG(FLASH->KEYR2, FLASH_KEY2);
695
+    
696
+    /* Verify Flash BANK2 is unlocked */
697
+    if(READ_BIT(FLASH->CR2, FLASH_CR2_LOCK) != RESET)
698
+    {
699
+      status = HAL_ERROR;
700
+    }
701
+  }
702
+#endif /* FLASH_BANK2_END */
703
+
704
+  return status;
705
+}
706
+
707
+/**
708
+  * @brief  Locks the FLASH control register access
709
+  * @retval HAL Status
710
+  */
711
+HAL_StatusTypeDef HAL_FLASH_Lock(void)
712
+{
713
+  /* Set the LOCK Bit to lock the FLASH Registers access */
714
+  SET_BIT(FLASH->CR, FLASH_CR_LOCK);
715
+  
716
+#if defined(FLASH_BANK2_END)
717
+  /* Set the LOCK Bit to lock the FLASH BANK2 Registers access */
718
+  SET_BIT(FLASH->CR2, FLASH_CR2_LOCK);
719
+
720
+#endif /* FLASH_BANK2_END */
721
+  return HAL_OK;  
722
+}
723
+
724
+/**
725
+  * @brief  Unlock the FLASH Option Control Registers access.
726
+  * @retval HAL Status
727
+  */
728
+HAL_StatusTypeDef HAL_FLASH_OB_Unlock(void)
729
+{
730
+  if (HAL_IS_BIT_CLR(FLASH->CR, FLASH_CR_OPTWRE))
731
+  {
732
+    /* Authorizes the Option Byte register programming */
733
+    WRITE_REG(FLASH->OPTKEYR, FLASH_OPTKEY1);
734
+    WRITE_REG(FLASH->OPTKEYR, FLASH_OPTKEY2);
735
+  }
736
+  else
737
+  {
738
+    return HAL_ERROR;
739
+  }  
740
+  
741
+  return HAL_OK;  
742
+}
743
+
744
+/**
745
+  * @brief  Lock the FLASH Option Control Registers access.
746
+  * @retval HAL Status 
747
+  */
748
+HAL_StatusTypeDef HAL_FLASH_OB_Lock(void)
749
+{
750
+  /* Clear the OPTWRE Bit to lock the FLASH Option Byte Registers access */
751
+  CLEAR_BIT(FLASH->CR, FLASH_CR_OPTWRE);
752
+  
753
+  return HAL_OK;  
754
+}
755
+  
756
+/**
757
+  * @brief  Launch the option byte loading.
758
+  * @note   This function will reset automatically the MCU.
759
+  * @retval None
760
+  */
761
+void HAL_FLASH_OB_Launch(void)
762
+{
763
+  /* Initiates a system reset request to launch the option byte loading */
764
+  HAL_NVIC_SystemReset();
765
+}
766
+
767
+/**
768
+  * @}
769
+  */  
770
+
771
+/** @defgroup FLASH_Exported_Functions_Group3 Peripheral errors functions 
772
+ *  @brief    Peripheral errors functions 
773
+ *
774
+@verbatim   
775
+ ===============================================================================
776
+                      ##### Peripheral Errors functions #####
777
+ ===============================================================================  
778
+    [..]
779
+    This subsection permit to get in run-time errors of  the FLASH peripheral.
780
+
781
+@endverbatim
782
+  * @{
783
+  */
784
+
785
+/**
786
+  * @brief  Get the specific FLASH error flag.
787
+  * @retval FLASH_ErrorCode The returned value can be:
788
+  *            @ref FLASH_Error_Codes
789
+  */
790
+uint32_t HAL_FLASH_GetError(void)
791
+{
792
+   return pFlash.ErrorCode;
793
+}
794
+
795
+/**
796
+  * @}
797
+  */
798
+
799
+/**
800
+  * @}
801
+  */
802
+
803
+/** @addtogroup FLASH_Private_Functions
804
+ * @{
805
+ */
806
+
807
+/**
808
+  * @brief  Program a half-word (16-bit) at a specified address.
809
+  * @param  Address specify the address to be programmed.
810
+  * @param  Data    specify the data to be programmed.
811
+  * @retval None
812
+  */
813
+static void FLASH_Program_HalfWord(uint32_t Address, uint16_t Data)
814
+{
815
+  /* Clean the error context */
816
+  pFlash.ErrorCode = HAL_FLASH_ERROR_NONE;
817
+  
818
+#if defined(FLASH_BANK2_END)
819
+  if(Address <= FLASH_BANK1_END)
820
+  {
821
+#endif /* FLASH_BANK2_END */
822
+    /* Proceed to program the new data */
823
+    SET_BIT(FLASH->CR, FLASH_CR_PG);
824
+#if defined(FLASH_BANK2_END)
825
+  }
826
+  else
827
+  {
828
+    /* Proceed to program the new data */
829
+    SET_BIT(FLASH->CR2, FLASH_CR2_PG);
830
+  }
831
+#endif /* FLASH_BANK2_END */
832
+
833
+  /* Write data in the address */
834
+  *(__IO uint16_t*)Address = Data;
835
+}
836
+
837
+/**
838
+  * @brief  Wait for a FLASH operation to complete.
839
+  * @param  Timeout  maximum flash operation timeout
840
+  * @retval HAL Status
841
+  */
842
+HAL_StatusTypeDef FLASH_WaitForLastOperation(uint32_t Timeout)
843
+{
844
+  /* Wait for the FLASH operation to complete by polling on BUSY flag to be reset.
845
+     Even if the FLASH operation fails, the BUSY flag will be reset and an error
846
+     flag will be set */
847
+     
848
+  uint32_t tickstart = HAL_GetTick();
849
+     
850
+  while(__HAL_FLASH_GET_FLAG(FLASH_FLAG_BSY)) 
851
+  { 
852
+    if (Timeout != HAL_MAX_DELAY)
853
+    {
854
+      if((Timeout == 0U) || ((HAL_GetTick()-tickstart) > Timeout))
855
+      {
856
+        return HAL_TIMEOUT;
857
+      }
858
+    }
859
+  }
860
+  
861
+  /* Check FLASH End of Operation flag  */
862
+  if (__HAL_FLASH_GET_FLAG(FLASH_FLAG_EOP))
863
+  {
864
+    /* Clear FLASH End of Operation pending bit */
865
+    __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP);
866
+  }
867
+  
868
+  if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_WRPERR)  || 
869
+     __HAL_FLASH_GET_FLAG(FLASH_FLAG_OPTVERR) || 
870
+     __HAL_FLASH_GET_FLAG(FLASH_FLAG_PGERR))
871
+  {
872
+    /*Save the error code*/
873
+    FLASH_SetErrorCode();
874
+    return HAL_ERROR;
875
+  }
876
+
877
+  /* There is no error flag set */
878
+  return HAL_OK;
879
+}
880
+
881
+#if defined(FLASH_BANK2_END)
882
+/**
883
+  * @brief  Wait for a FLASH BANK2 operation to complete.
884
+  * @param  Timeout maximum flash operation timeout
885
+  * @retval HAL_StatusTypeDef HAL Status
886
+  */
887
+HAL_StatusTypeDef FLASH_WaitForLastOperationBank2(uint32_t Timeout)
888
+{ 
889
+  /* Wait for the FLASH BANK2 operation to complete by polling on BUSY flag to be reset.
890
+     Even if the FLASH BANK2 operation fails, the BUSY flag will be reset and an error
891
+     flag will be set */
892
+     
893
+  uint32_t tickstart = HAL_GetTick();
894
+     
895
+  while(__HAL_FLASH_GET_FLAG(FLASH_FLAG_BSY_BANK2)) 
896
+  { 
897
+    if (Timeout != HAL_MAX_DELAY)
898
+    {
899
+      if((Timeout == 0U) || ((HAL_GetTick()-tickstart) > Timeout))
900
+      {
901
+        return HAL_TIMEOUT;
902
+      }
903
+    }
904
+  }
905
+  
906
+  /* Check FLASH End of Operation flag  */
907
+  if (__HAL_FLASH_GET_FLAG(FLASH_FLAG_EOP_BANK2))
908
+  {
909
+    /* Clear FLASH End of Operation pending bit */
910
+    __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP_BANK2);
911
+  }
912
+
913
+  if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_WRPERR_BANK2) || __HAL_FLASH_GET_FLAG(FLASH_FLAG_PGERR_BANK2))
914
+  {
915
+    /*Save the error code*/
916
+    FLASH_SetErrorCode();
917
+    return HAL_ERROR;
918
+  }
919
+
920
+  /* If there is an error flag set */
921
+  return HAL_OK;
922
+  
923
+}
924
+#endif /* FLASH_BANK2_END */
925
+
926
+/**
927
+  * @brief  Set the specific FLASH error flag.
928
+  * @retval None
929
+  */
930
+static void FLASH_SetErrorCode(void)
931
+{
932
+  uint32_t flags = 0U;
933
+  
934
+#if defined(FLASH_BANK2_END)
935
+  if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_WRPERR) || __HAL_FLASH_GET_FLAG(FLASH_FLAG_WRPERR_BANK2))
936
+#else
937
+  if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_WRPERR))
938
+#endif /* FLASH_BANK2_END */
939
+  {
940
+    pFlash.ErrorCode |= HAL_FLASH_ERROR_WRP;
941
+#if defined(FLASH_BANK2_END)
942
+    flags |= FLASH_FLAG_WRPERR | FLASH_FLAG_WRPERR_BANK2;
943
+#else
944
+    flags |= FLASH_FLAG_WRPERR;
945
+#endif /* FLASH_BANK2_END */
946
+  }
947
+#if defined(FLASH_BANK2_END)
948
+  if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGERR) || __HAL_FLASH_GET_FLAG(FLASH_FLAG_PGERR_BANK2))
949
+#else
950
+  if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGERR))
951
+#endif /* FLASH_BANK2_END */
952
+  {
953
+    pFlash.ErrorCode |= HAL_FLASH_ERROR_PROG;
954
+#if defined(FLASH_BANK2_END)
955
+    flags |= FLASH_FLAG_PGERR | FLASH_FLAG_PGERR_BANK2;
956
+#else
957
+    flags |= FLASH_FLAG_PGERR;
958
+#endif /* FLASH_BANK2_END */
959
+  }
960
+  if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_OPTVERR))
961
+  {
962
+    pFlash.ErrorCode |= HAL_FLASH_ERROR_OPTV;
963
+  __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_OPTVERR);
964
+  }
965
+
966
+  /* Clear FLASH error pending bits */
967
+  __HAL_FLASH_CLEAR_FLAG(flags);
968
+}  
969
+/**
970
+  * @}
971
+  */
972
+
973
+/**
974
+  * @}
975
+  */
976
+
977
+#endif /* HAL_FLASH_MODULE_ENABLED */
978
+
979
+/**
980
+  * @}
981
+  */
982
+
983
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

文件差异内容过多而无法显示
+ 1143 - 0
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c


+ 595 - 0
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c

@@ -0,0 +1,595 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx_hal_gpio.c
4
+  * @author  MCD Application Team
5
+  * @brief   GPIO HAL module driver.
6
+  *          This file provides firmware functions to manage the following
7
+  *          functionalities of the General Purpose Input/Output (GPIO) peripheral:
8
+  *           + Initialization and de-initialization functions
9
+  *           + IO operation functions
10
+  *
11
+  @verbatim
12
+  ==============================================================================
13
+                    ##### GPIO Peripheral features #####
14
+  ==============================================================================
15
+  [..]
16
+  Subject to the specific hardware characteristics of each I/O port listed in the datasheet, each
17
+  port bit of the General Purpose IO (GPIO) Ports, can be individually configured by software
18
+  in several modes:
19
+  (+) Input mode
20
+  (+) Analog mode
21
+  (+) Output mode
22
+  (+) Alternate function mode
23
+  (+) External interrupt/event lines
24
+
25
+  [..]
26
+  During and just after reset, the alternate functions and external interrupt
27
+  lines are not active and the I/O ports are configured in input floating mode.
28
+
29
+  [..]
30
+  All GPIO pins have weak internal pull-up and pull-down resistors, which can be
31
+  activated or not.
32
+
33
+  [..]
34
+  In Output or Alternate mode, each IO can be configured on open-drain or push-pull
35
+  type and the IO speed can be selected depending on the VDD value.
36
+
37
+  [..]
38
+  All ports have external interrupt/event capability. To use external interrupt
39
+  lines, the port must be configured in input mode. All available GPIO pins are
40
+  connected to the 16 external interrupt/event lines from EXTI0 to EXTI15.
41
+
42
+  [..]
43
+  The external interrupt/event controller consists of up to 20 edge detectors in connectivity
44
+  line devices, or 19 edge detectors in other devices for generating event/interrupt requests.
45
+  Each input line can be independently configured to select the type (event or interrupt) and
46
+  the corresponding trigger event (rising or falling or both). Each line can also masked
47
+  independently. A pending register maintains the status line of the interrupt requests
48
+
49
+                     ##### How to use this driver #####
50
+  ==============================================================================
51
+ [..]
52
+   (#) Enable the GPIO APB2 clock using the following function : __HAL_RCC_GPIOx_CLK_ENABLE().
53
+
54
+   (#) Configure the GPIO pin(s) using HAL_GPIO_Init().
55
+       (++) Configure the IO mode using "Mode" member from GPIO_InitTypeDef structure
56
+       (++) Activate Pull-up, Pull-down resistor using "Pull" member from GPIO_InitTypeDef
57
+            structure.
58
+       (++) In case of Output or alternate function mode selection: the speed is
59
+            configured through "Speed" member from GPIO_InitTypeDef structure
60
+       (++) Analog mode is required when a pin is to be used as ADC channel
61
+            or DAC output.
62
+       (++) In case of external interrupt/event selection the "Mode" member from
63
+            GPIO_InitTypeDef structure select the type (interrupt or event) and
64
+            the corresponding trigger event (rising or falling or both).
65
+
66
+   (#) In case of external interrupt/event mode selection, configure NVIC IRQ priority
67
+       mapped to the EXTI line using HAL_NVIC_SetPriority() and enable it using
68
+       HAL_NVIC_EnableIRQ().
69
+
70
+   (#) To get the level of a pin configured in input mode use HAL_GPIO_ReadPin().
71
+
72
+   (#) To set/reset the level of a pin configured in output mode use
73
+       HAL_GPIO_WritePin()/HAL_GPIO_TogglePin().
74
+
75
+   (#) To lock pin configuration until next reset use HAL_GPIO_LockPin().
76
+
77
+   (#) During and just after reset, the alternate functions are not
78
+       active and the GPIO pins are configured in input floating mode (except JTAG
79
+       pins).
80
+
81
+   (#) The LSE oscillator pins OSC32_IN and OSC32_OUT can be used as general purpose
82
+       (PC14 and PC15, respectively) when the LSE oscillator is off. The LSE has
83
+       priority over the GPIO function.
84
+
85
+   (#) The HSE oscillator pins OSC_IN/OSC_OUT can be used as
86
+       general purpose PD0 and PD1, respectively, when the HSE oscillator is off.
87
+       The HSE has priority over the GPIO function.
88
+
89
+  @endverbatim
90
+  ******************************************************************************
91
+  * @attention
92
+  *
93
+  * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
94
+  *
95
+  * Redistribution and use in source and binary forms, with or without modification,
96
+  * are permitted provided that the following conditions are met:
97
+  *   1. Redistributions of source code must retain the above copyright notice,
98
+  *      this list of conditions and the following disclaimer.
99
+  *   2. Redistributions in binary form must reproduce the above copyright notice,
100
+  *      this list of conditions and the following disclaimer in the documentation
101
+  *      and/or other materials provided with the distribution.
102
+  *   3. Neither the name of STMicroelectronics nor the names of its contributors
103
+  *      may be used to endorse or promote products derived from this software
104
+  *      without specific prior written permission.
105
+  *
106
+  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
107
+  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
108
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
109
+  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
110
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
111
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
112
+  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
113
+  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
114
+  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
115
+  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
116
+  *
117
+  ******************************************************************************
118
+  */
119
+
120
+/* Includes ------------------------------------------------------------------*/
121
+#include "stm32f1xx_hal.h"
122
+
123
+/** @addtogroup STM32F1xx_HAL_Driver
124
+  * @{
125
+  */
126
+
127
+/** @defgroup GPIO GPIO
128
+  * @brief GPIO HAL module driver
129
+  * @{
130
+  */
131
+
132
+#ifdef HAL_GPIO_MODULE_ENABLED
133
+
134
+/* Private typedef -----------------------------------------------------------*/
135
+/* Private define ------------------------------------------------------------*/
136
+/** @addtogroup GPIO_Private_Constants GPIO Private Constants
137
+  * @{
138
+  */
139
+#define GPIO_MODE             0x00000003U
140
+#define EXTI_MODE             0x10000000U
141
+#define GPIO_MODE_IT          0x00010000U
142
+#define GPIO_MODE_EVT         0x00020000U
143
+#define RISING_EDGE           0x00100000U
144
+#define FALLING_EDGE          0x00200000U
145
+#define GPIO_OUTPUT_TYPE      0x00000010U
146
+
147
+#define GPIO_NUMBER           16U
148
+
149
+/* Definitions for bit manipulation of CRL and CRH register */
150
+#define  GPIO_CR_MODE_INPUT         0x00000000U /*!< 00: Input mode (reset state)  */
151
+#define  GPIO_CR_CNF_ANALOG         0x00000000U /*!< 00: Analog mode  */
152
+#define  GPIO_CR_CNF_INPUT_FLOATING 0x00000004U /*!< 01: Floating input (reset state)  */
153
+#define  GPIO_CR_CNF_INPUT_PU_PD    0x00000008U /*!< 10: Input with pull-up / pull-down  */
154
+#define  GPIO_CR_CNF_GP_OUTPUT_PP   0x00000000U /*!< 00: General purpose output push-pull  */
155
+#define  GPIO_CR_CNF_GP_OUTPUT_OD   0x00000004U /*!< 01: General purpose output Open-drain  */
156
+#define  GPIO_CR_CNF_AF_OUTPUT_PP   0x00000008U /*!< 10: Alternate function output Push-pull  */
157
+#define  GPIO_CR_CNF_AF_OUTPUT_OD   0x0000000CU /*!< 11: Alternate function output Open-drain  */
158
+
159
+/**
160
+  * @}
161
+  */
162
+/* Private macro -------------------------------------------------------------*/
163
+/* Private variables ---------------------------------------------------------*/
164
+/* Private function prototypes -----------------------------------------------*/
165
+/* Private functions ---------------------------------------------------------*/
166
+/* Exported functions --------------------------------------------------------*/
167
+/** @defgroup GPIO_Exported_Functions GPIO Exported Functions
168
+  * @{
169
+  */
170
+
171
+/** @defgroup GPIO_Exported_Functions_Group1 Initialization and de-initialization functions
172
+ *  @brief    Initialization and Configuration functions
173
+ *
174
+@verbatim
175
+ ===============================================================================
176
+              ##### Initialization and de-initialization functions #####
177
+ ===============================================================================
178
+  [..]
179
+    This section provides functions allowing to initialize and de-initialize the GPIOs
180
+    to be ready for use.
181
+
182
+@endverbatim
183
+  * @{
184
+  */
185
+
186
+
187
+/**
188
+  * @brief  Initializes the GPIOx peripheral according to the specified parameters in the GPIO_Init.
189
+  * @param  GPIOx: where x can be (A..G depending on device used) to select the GPIO peripheral
190
+  * @param  GPIO_Init: pointer to a GPIO_InitTypeDef structure that contains
191
+  *         the configuration information for the specified GPIO peripheral.
192
+  * @retval None
193
+  */
194
+void HAL_GPIO_Init(GPIO_TypeDef  *GPIOx, GPIO_InitTypeDef *GPIO_Init)
195
+{
196
+  uint32_t position;
197
+  uint32_t ioposition = 0x00U;
198
+  uint32_t iocurrent = 0x00U;
199
+  uint32_t temp = 0x00U;
200
+  uint32_t config = 0x00U;
201
+  __IO uint32_t *configregister; /* Store the address of CRL or CRH register based on pin number */
202
+  uint32_t registeroffset = 0U; /* offset used during computation of CNF and MODE bits placement inside CRL or CRH register */
203
+
204
+  /* Check the parameters */
205
+  assert_param(IS_GPIO_ALL_INSTANCE(GPIOx));
206
+  assert_param(IS_GPIO_PIN(GPIO_Init->Pin));
207
+  assert_param(IS_GPIO_MODE(GPIO_Init->Mode));
208
+
209
+  /* Configure the port pins */
210
+  for (position = 0U; position < GPIO_NUMBER; position++)
211
+  {
212
+    /* Get the IO position */
213
+    ioposition = (0x01U << position);
214
+
215
+    /* Get the current IO position */
216
+    iocurrent = (uint32_t)(GPIO_Init->Pin) & ioposition;
217
+
218
+    if (iocurrent == ioposition)
219
+    {
220
+      /* Check the Alternate function parameters */
221
+      assert_param(IS_GPIO_AF_INSTANCE(GPIOx));
222
+
223
+      /* Based on the required mode, filling config variable with MODEy[1:0] and CNFy[3:2] corresponding bits */
224
+      switch (GPIO_Init->Mode)
225
+      {
226
+        /* If we are configuring the pin in OUTPUT push-pull mode */
227
+        case GPIO_MODE_OUTPUT_PP:
228
+          /* Check the GPIO speed parameter */
229
+          assert_param(IS_GPIO_SPEED(GPIO_Init->Speed));
230
+          config = GPIO_Init->Speed + GPIO_CR_CNF_GP_OUTPUT_PP;
231
+          break;
232
+
233
+        /* If we are configuring the pin in OUTPUT open-drain mode */
234
+        case GPIO_MODE_OUTPUT_OD:
235
+          /* Check the GPIO speed parameter */
236
+          assert_param(IS_GPIO_SPEED(GPIO_Init->Speed));
237
+          config = GPIO_Init->Speed + GPIO_CR_CNF_GP_OUTPUT_OD;
238
+          break;
239
+
240
+        /* If we are configuring the pin in ALTERNATE FUNCTION push-pull mode */
241
+        case GPIO_MODE_AF_PP:
242
+          /* Check the GPIO speed parameter */
243
+          assert_param(IS_GPIO_SPEED(GPIO_Init->Speed));
244
+          config = GPIO_Init->Speed + GPIO_CR_CNF_AF_OUTPUT_PP;
245
+          break;
246
+
247
+        /* If we are configuring the pin in ALTERNATE FUNCTION open-drain mode */
248
+        case GPIO_MODE_AF_OD:
249
+          /* Check the GPIO speed parameter */
250
+          assert_param(IS_GPIO_SPEED(GPIO_Init->Speed));
251
+          config = GPIO_Init->Speed + GPIO_CR_CNF_AF_OUTPUT_OD;
252
+          break;
253
+
254
+        /* If we are configuring the pin in INPUT (also applicable to EVENT and IT mode) */
255
+        case GPIO_MODE_INPUT:
256
+        case GPIO_MODE_IT_RISING:
257
+        case GPIO_MODE_IT_FALLING:
258
+        case GPIO_MODE_IT_RISING_FALLING:
259
+        case GPIO_MODE_EVT_RISING:
260
+        case GPIO_MODE_EVT_FALLING:
261
+        case GPIO_MODE_EVT_RISING_FALLING:
262
+          /* Check the GPIO pull parameter */
263
+          assert_param(IS_GPIO_PULL(GPIO_Init->Pull));
264
+          if (GPIO_Init->Pull == GPIO_NOPULL)
265
+          {
266
+            config = GPIO_CR_MODE_INPUT + GPIO_CR_CNF_INPUT_FLOATING;
267
+          }
268
+          else if (GPIO_Init->Pull == GPIO_PULLUP)
269
+          {
270
+            config = GPIO_CR_MODE_INPUT + GPIO_CR_CNF_INPUT_PU_PD;
271
+
272
+            /* Set the corresponding ODR bit */
273
+            GPIOx->BSRR = ioposition;
274
+          }
275
+          else /* GPIO_PULLDOWN */
276
+          {
277
+            config = GPIO_CR_MODE_INPUT + GPIO_CR_CNF_INPUT_PU_PD;
278
+
279
+            /* Reset the corresponding ODR bit */
280
+            GPIOx->BRR = ioposition;
281
+          }
282
+          break;
283
+
284
+        /* If we are configuring the pin in INPUT analog mode */
285
+        case GPIO_MODE_ANALOG:
286
+          config = GPIO_CR_MODE_INPUT + GPIO_CR_CNF_ANALOG;
287
+          break;
288
+
289
+        /* Parameters are checked with assert_param */
290
+        default:
291
+          break;
292
+      }
293
+
294
+      /* Check if the current bit belongs to first half or last half of the pin count number
295
+       in order to address CRH or CRL register*/
296
+      configregister = (iocurrent < GPIO_PIN_8) ? &GPIOx->CRL     : &GPIOx->CRH;
297
+      registeroffset = (iocurrent < GPIO_PIN_8) ? (position << 2U) : ((position - 8U) << 2U);
298
+
299
+      /* Apply the new configuration of the pin to the register */
300
+      MODIFY_REG((*configregister), ((GPIO_CRL_MODE0 | GPIO_CRL_CNF0) << registeroffset), (config << registeroffset));
301
+
302
+      /*--------------------- EXTI Mode Configuration ------------------------*/
303
+      /* Configure the External Interrupt or event for the current IO */
304
+      if ((GPIO_Init->Mode & EXTI_MODE) == EXTI_MODE)
305
+      {
306
+        /* Enable AFIO Clock */
307
+        __HAL_RCC_AFIO_CLK_ENABLE();
308
+        temp = AFIO->EXTICR[position >> 2U];
309
+        CLEAR_BIT(temp, (0x0FU) << (4U * (position & 0x03U)));
310
+        SET_BIT(temp, (GPIO_GET_INDEX(GPIOx)) << (4U * (position & 0x03U)));
311
+        AFIO->EXTICR[position >> 2U] = temp;
312
+
313
+
314
+        /* Configure the interrupt mask */
315
+        if ((GPIO_Init->Mode & GPIO_MODE_IT) == GPIO_MODE_IT)
316
+        {
317
+          SET_BIT(EXTI->IMR, iocurrent);
318
+        }
319
+        else
320
+        {
321
+          CLEAR_BIT(EXTI->IMR, iocurrent);
322
+        }
323
+
324
+        /* Configure the event mask */
325
+        if ((GPIO_Init->Mode & GPIO_MODE_EVT) == GPIO_MODE_EVT)
326
+        {
327
+          SET_BIT(EXTI->EMR, iocurrent);
328
+        }
329
+        else
330
+        {
331
+          CLEAR_BIT(EXTI->EMR, iocurrent);
332
+        }
333
+
334
+        /* Enable or disable the rising trigger */
335
+        if ((GPIO_Init->Mode & RISING_EDGE) == RISING_EDGE)
336
+        {
337
+          SET_BIT(EXTI->RTSR, iocurrent);
338
+        }
339
+        else
340
+        {
341
+          CLEAR_BIT(EXTI->RTSR, iocurrent);
342
+        }
343
+
344
+        /* Enable or disable the falling trigger */
345
+        if ((GPIO_Init->Mode & FALLING_EDGE) == FALLING_EDGE)
346
+        {
347
+          SET_BIT(EXTI->FTSR, iocurrent);
348
+        }
349
+        else
350
+        {
351
+          CLEAR_BIT(EXTI->FTSR, iocurrent);
352
+        }
353
+      }
354
+    }
355
+  }
356
+}
357
+
358
+/**
359
+  * @brief  De-initializes the GPIOx peripheral registers to their default reset values.
360
+  * @param  GPIOx: where x can be (A..G depending on device used) to select the GPIO peripheral
361
+  * @param  GPIO_Pin: specifies the port bit to be written.
362
+  *         This parameter can be one of GPIO_PIN_x where x can be (0..15).
363
+  * @retval None
364
+  */
365
+void HAL_GPIO_DeInit(GPIO_TypeDef  *GPIOx, uint32_t GPIO_Pin)
366
+{
367
+  uint32_t position = 0x00U;
368
+  uint32_t iocurrent = 0x00U;
369
+  uint32_t tmp = 0x00U;
370
+  __IO uint32_t *configregister; /* Store the address of CRL or CRH register based on pin number */
371
+  uint32_t registeroffset = 0U;
372
+
373
+  /* Check the parameters */
374
+  assert_param(IS_GPIO_ALL_INSTANCE(GPIOx));
375
+  assert_param(IS_GPIO_PIN(GPIO_Pin));
376
+
377
+  /* Configure the port pins */
378
+  while ((GPIO_Pin >> position) != 0U)
379
+  {
380
+    /* Get current io position */
381
+    iocurrent = (GPIO_Pin) & (1U << position);
382
+
383
+    if (iocurrent)
384
+    {
385
+      /*------------------------- GPIO Mode Configuration --------------------*/
386
+      /* Check if the current bit belongs to first half or last half of the pin count number
387
+       in order to address CRH or CRL register */
388
+      configregister = (iocurrent < GPIO_PIN_8) ? &GPIOx->CRL     : &GPIOx->CRH;
389
+      registeroffset = (iocurrent < GPIO_PIN_8) ? (position << 2U) : ((position - 8U) << 2U);
390
+
391
+      /* CRL/CRH default value is floating input(0x04) shifted to correct position */
392
+      MODIFY_REG(*configregister, ((GPIO_CRL_MODE0 | GPIO_CRL_CNF0) << registeroffset), GPIO_CRL_CNF0_0 << registeroffset);
393
+
394
+      /* ODR default value is 0 */
395
+      CLEAR_BIT(GPIOx->ODR, iocurrent);
396
+
397
+      /*------------------------- EXTI Mode Configuration --------------------*/
398
+      /* Clear the External Interrupt or Event for the current IO */
399
+
400
+      tmp = AFIO->EXTICR[position >> 2U];
401
+      tmp &= 0x0FU << (4U * (position & 0x03U));
402
+      if (tmp == (GPIO_GET_INDEX(GPIOx) << (4U * (position & 0x03U))))
403
+      {
404
+        tmp = 0x0FU << (4U * (position & 0x03U));
405
+        CLEAR_BIT(AFIO->EXTICR[position >> 2U], tmp);
406
+
407
+        /* Clear EXTI line configuration */
408
+        CLEAR_BIT(EXTI->IMR, (uint32_t)iocurrent);
409
+        CLEAR_BIT(EXTI->EMR, (uint32_t)iocurrent);
410
+
411
+        /* Clear Rising Falling edge configuration */
412
+        CLEAR_BIT(EXTI->RTSR, (uint32_t)iocurrent);
413
+        CLEAR_BIT(EXTI->FTSR, (uint32_t)iocurrent);
414
+      }
415
+    }
416
+
417
+    position++;
418
+  }
419
+}
420
+
421
+/**
422
+  * @}
423
+  */
424
+
425
+/** @defgroup GPIO_Exported_Functions_Group2 IO operation functions
426
+ *  @brief   GPIO Read and Write
427
+ *
428
+@verbatim
429
+ ===============================================================================
430
+                       ##### IO operation functions #####
431
+ ===============================================================================
432
+  [..]
433
+    This subsection provides a set of functions allowing to manage the GPIOs.
434
+
435
+@endverbatim
436
+  * @{
437
+  */
438
+
439
+/**
440
+  * @brief  Reads the specified input port pin.
441
+  * @param  GPIOx: where x can be (A..G depending on device used) to select the GPIO peripheral
442
+  * @param  GPIO_Pin: specifies the port bit to read.
443
+  *         This parameter can be GPIO_PIN_x where x can be (0..15).
444
+  * @retval The input port pin value.
445
+  */
446
+GPIO_PinState HAL_GPIO_ReadPin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
447
+{
448
+  GPIO_PinState bitstatus;
449
+
450
+  /* Check the parameters */
451
+  assert_param(IS_GPIO_PIN(GPIO_Pin));
452
+
453
+  if ((GPIOx->IDR & GPIO_Pin) != (uint32_t)GPIO_PIN_RESET)
454
+  {
455
+    bitstatus = GPIO_PIN_SET;
456
+  }
457
+  else
458
+  {
459
+    bitstatus = GPIO_PIN_RESET;
460
+  }
461
+  return bitstatus;
462
+}
463
+
464
+/**
465
+  * @brief  Sets or clears the selected data port bit.
466
+  *
467
+  * @note   This function uses GPIOx_BSRR register to allow atomic read/modify
468
+  *         accesses. In this way, there is no risk of an IRQ occurring between
469
+  *         the read and the modify access.
470
+  *
471
+  * @param  GPIOx: where x can be (A..G depending on device used) to select the GPIO peripheral
472
+  * @param  GPIO_Pin: specifies the port bit to be written.
473
+  *          This parameter can be one of GPIO_PIN_x where x can be (0..15).
474
+  * @param  PinState: specifies the value to be written to the selected bit.
475
+  *          This parameter can be one of the GPIO_PinState enum values:
476
+  *            @arg GPIO_PIN_RESET: to clear the port pin
477
+  *            @arg GPIO_PIN_SET: to set the port pin
478
+  * @retval None
479
+  */
480
+void HAL_GPIO_WritePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState)
481
+{
482
+  /* Check the parameters */
483
+  assert_param(IS_GPIO_PIN(GPIO_Pin));
484
+  assert_param(IS_GPIO_PIN_ACTION(PinState));
485
+
486
+  if (PinState != GPIO_PIN_RESET)
487
+  {
488
+    GPIOx->BSRR = GPIO_Pin;
489
+  }
490
+  else
491
+  {
492
+    GPIOx->BSRR = (uint32_t)GPIO_Pin << 16U;
493
+  }
494
+}
495
+
496
+/**
497
+  * @brief  Toggles the specified GPIO pin
498
+  * @param  GPIOx: where x can be (A..G depending on device used) to select the GPIO peripheral
499
+  * @param  GPIO_Pin: Specifies the pins to be toggled.
500
+  * @retval None
501
+  */
502
+void HAL_GPIO_TogglePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
503
+{
504
+  /* Check the parameters */
505
+  assert_param(IS_GPIO_PIN(GPIO_Pin));
506
+
507
+  GPIOx->ODR ^= GPIO_Pin;
508
+}
509
+
510
+/**
511
+* @brief  Locks GPIO Pins configuration registers.
512
+* @note   The locking mechanism allows the IO configuration to be frozen. When the LOCK sequence
513
+*         has been applied on a port bit, it is no longer possible to modify the value of the port bit until
514
+*         the next reset.
515
+* @param  GPIOx: where x can be (A..G depending on device used) to select the GPIO peripheral
516
+* @param  GPIO_Pin: specifies the port bit to be locked.
517
+*         This parameter can be any combination of GPIO_Pin_x where x can be (0..15).
518
+* @retval None
519
+*/
520
+HAL_StatusTypeDef HAL_GPIO_LockPin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
521
+{
522
+  __IO uint32_t tmp = GPIO_LCKR_LCKK;
523
+
524
+  /* Check the parameters */
525
+  assert_param(IS_GPIO_LOCK_INSTANCE(GPIOx));
526
+  assert_param(IS_GPIO_PIN(GPIO_Pin));
527
+
528
+  /* Apply lock key write sequence */
529
+  SET_BIT(tmp, GPIO_Pin);
530
+  /* Set LCKx bit(s): LCKK='1' + LCK[15-0] */
531
+  GPIOx->LCKR = tmp;
532
+  /* Reset LCKx bit(s): LCKK='0' + LCK[15-0] */
533
+  GPIOx->LCKR = GPIO_Pin;
534
+  /* Set LCKx bit(s): LCKK='1' + LCK[15-0] */
535
+  GPIOx->LCKR = tmp;
536
+  /* Read LCKK bit*/
537
+  tmp = GPIOx->LCKR;
538
+
539
+  if ((uint32_t)(GPIOx->LCKR & GPIO_LCKR_LCKK))
540
+  {
541
+    return HAL_OK;
542
+  }
543
+  else
544
+  {
545
+    return HAL_ERROR;
546
+  }
547
+}
548
+
549
+/**
550
+  * @brief  This function handles EXTI interrupt request.
551
+  * @param  GPIO_Pin: Specifies the pins connected EXTI line
552
+  * @retval None
553
+  */
554
+void HAL_GPIO_EXTI_IRQHandler(uint16_t GPIO_Pin)
555
+{
556
+  /* EXTI line interrupt detected */
557
+  if (__HAL_GPIO_EXTI_GET_IT(GPIO_Pin) != RESET)
558
+  {
559
+    __HAL_GPIO_EXTI_CLEAR_IT(GPIO_Pin);
560
+    HAL_GPIO_EXTI_Callback(GPIO_Pin);
561
+  }
562
+}
563
+
564
+/**
565
+  * @brief  EXTI line detection callbacks.
566
+  * @param  GPIO_Pin: Specifies the pins connected EXTI line
567
+  * @retval None
568
+  */
569
+__weak void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
570
+{
571
+  /* Prevent unused argument(s) compilation warning */
572
+  UNUSED(GPIO_Pin);
573
+  /* NOTE: This function Should not be modified, when the callback is needed,
574
+           the HAL_GPIO_EXTI_Callback could be implemented in the user file
575
+   */
576
+}
577
+
578
+/**
579
+  * @}
580
+  */
581
+
582
+/**
583
+  * @}
584
+  */
585
+
586
+#endif /* HAL_GPIO_MODULE_ENABLED */
587
+/**
588
+  * @}
589
+  */
590
+
591
+/**
592
+  * @}
593
+  */
594
+
595
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 143 - 0
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c

@@ -0,0 +1,143 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx_hal_gpio_ex.c
4
+  * @author  MCD Application Team
5
+  * @brief   GPIO Extension HAL module driver.
6
+  *         This file provides firmware functions to manage the following
7
+  *          functionalities of the General Purpose Input/Output (GPIO) extension peripheral.
8
+  *           + Extended features functions
9
+  *
10
+  @verbatim
11
+  ==============================================================================
12
+                    ##### GPIO Peripheral extension features #####
13
+  ==============================================================================
14
+  [..] GPIO module on STM32F1 family, manage also the AFIO register:
15
+       (+) Possibility to use the EVENTOUT Cortex feature
16
+
17
+                     ##### How to use this driver #####
18
+  ==============================================================================
19
+  [..] This driver provides functions to use EVENTOUT Cortex feature
20
+    (#) Configure EVENTOUT Cortex feature using the function HAL_GPIOEx_ConfigEventout()
21
+    (#) Activate EVENTOUT Cortex feature using the HAL_GPIOEx_EnableEventout()
22
+    (#) Deactivate EVENTOUT Cortex feature using the HAL_GPIOEx_DisableEventout()
23
+
24
+  @endverbatim
25
+  ******************************************************************************
26
+  * @attention
27
+  *
28
+  * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
29
+  *
30
+  * Redistribution and use in source and binary forms, with or without modification,
31
+  * are permitted provided that the following conditions are met:
32
+  *   1. Redistributions of source code must retain the above copyright notice,
33
+  *      this list of conditions and the following disclaimer.
34
+  *   2. Redistributions in binary form must reproduce the above copyright notice,
35
+  *      this list of conditions and the following disclaimer in the documentation
36
+  *      and/or other materials provided with the distribution.
37
+  *   3. Neither the name of STMicroelectronics nor the names of its contributors
38
+  *      may be used to endorse or promote products derived from this software
39
+  *      without specific prior written permission.
40
+  *
41
+  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
42
+  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
44
+  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
45
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
47
+  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
48
+  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
49
+  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
50
+  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
51
+  *
52
+  ******************************************************************************
53
+  */
54
+
55
+/* Includes ------------------------------------------------------------------*/
56
+#include "stm32f1xx_hal.h"
57
+
58
+/** @addtogroup STM32F1xx_HAL_Driver
59
+  * @{
60
+  */
61
+
62
+/** @defgroup GPIOEx GPIOEx
63
+  * @brief GPIO HAL module driver
64
+  * @{
65
+  */
66
+
67
+#ifdef HAL_GPIO_MODULE_ENABLED
68
+
69
+/** @defgroup GPIOEx_Exported_Functions GPIOEx Exported Functions
70
+  * @{
71
+  */
72
+
73
+/** @defgroup GPIOEx_Exported_Functions_Group1 Extended features functions
74
+ *  @brief    Extended features functions
75
+ *
76
+@verbatim
77
+  ==============================================================================
78
+                 ##### Extended features functions #####
79
+  ==============================================================================
80
+    [..]  This section provides functions allowing to:
81
+    (+) Configure EVENTOUT Cortex feature using the function HAL_GPIOEx_ConfigEventout()
82
+    (+) Activate EVENTOUT Cortex feature using the HAL_GPIOEx_EnableEventout()
83
+    (+) Deactivate EVENTOUT Cortex feature using the HAL_GPIOEx_DisableEventout()
84
+
85
+@endverbatim
86
+  * @{
87
+  */
88
+
89
+/**
90
+  * @brief  Configures the port and pin on which the EVENTOUT Cortex signal will be connected.
91
+  * @param  GPIO_PortSource Select the port used to output the Cortex EVENTOUT signal.
92
+  *   This parameter can be a value of @ref GPIOEx_EVENTOUT_PORT.
93
+  * @param  GPIO_PinSource Select the pin used to output the Cortex EVENTOUT signal.
94
+  *   This parameter can be a value of @ref GPIOEx_EVENTOUT_PIN.
95
+  * @retval None
96
+  */
97
+void HAL_GPIOEx_ConfigEventout(uint32_t GPIO_PortSource, uint32_t GPIO_PinSource)
98
+{
99
+  /* Verify the parameters */
100
+  assert_param(IS_AFIO_EVENTOUT_PORT(GPIO_PortSource));
101
+  assert_param(IS_AFIO_EVENTOUT_PIN(GPIO_PinSource));
102
+
103
+  /* Apply the new configuration */
104
+  MODIFY_REG(AFIO->EVCR, (AFIO_EVCR_PORT) | (AFIO_EVCR_PIN), (GPIO_PortSource) | (GPIO_PinSource));
105
+}
106
+
107
+/**
108
+  * @brief  Enables the Event Output.
109
+  * @retval None
110
+  */
111
+void HAL_GPIOEx_EnableEventout(void)
112
+{
113
+  SET_BIT(AFIO->EVCR, AFIO_EVCR_EVOE);
114
+}
115
+
116
+/**
117
+  * @brief  Disables the Event Output.
118
+  * @retval None
119
+  */
120
+void HAL_GPIOEx_DisableEventout(void)
121
+{
122
+  CLEAR_BIT(AFIO->EVCR, AFIO_EVCR_EVOE);
123
+}
124
+
125
+/**
126
+  * @}
127
+  */
128
+
129
+/**
130
+  * @}
131
+  */
132
+
133
+#endif /* HAL_GPIO_MODULE_ENABLED */
134
+
135
+/**
136
+  * @}
137
+  */
138
+
139
+/**
140
+  * @}
141
+  */
142
+
143
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 637 - 0
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c

@@ -0,0 +1,637 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx_hal_pwr.c
4
+  * @author  MCD Application Team
5
+  * @brief   PWR HAL module driver.
6
+  *
7
+  *          This file provides firmware functions to manage the following
8
+  *          functionalities of the Power Controller (PWR) peripheral:
9
+  *           + Initialization/de-initialization functions
10
+  *           + Peripheral Control functions 
11
+  *
12
+  ******************************************************************************
13
+  * @attention
14
+  *
15
+  * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
16
+  *
17
+  * Redistribution and use in source and binary forms, with or without modification,
18
+  * are permitted provided that the following conditions are met:
19
+  *   1. Redistributions of source code must retain the above copyright notice,
20
+  *      this list of conditions and the following disclaimer.
21
+  *   2. Redistributions in binary form must reproduce the above copyright notice,
22
+  *      this list of conditions and the following disclaimer in the documentation
23
+  *      and/or other materials provided with the distribution.
24
+  *   3. Neither the name of STMicroelectronics nor the names of its contributors
25
+  *      may be used to endorse or promote products derived from this software
26
+  *      without specific prior written permission.
27
+  *
28
+  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29
+  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
31
+  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
32
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
34
+  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
35
+  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
36
+  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37
+  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38
+  *
39
+  ******************************************************************************
40
+  */
41
+
42
+/* Includes ------------------------------------------------------------------*/
43
+#include "stm32f1xx_hal.h"
44
+
45
+/** @addtogroup STM32F1xx_HAL_Driver
46
+  * @{
47
+  */
48
+
49
+/** @defgroup PWR PWR
50
+  * @brief    PWR HAL module driver
51
+  * @{
52
+  */
53
+
54
+#ifdef HAL_PWR_MODULE_ENABLED
55
+
56
+/* Private typedef -----------------------------------------------------------*/
57
+/* Private define ------------------------------------------------------------*/
58
+
59
+/** @defgroup PWR_Private_Constants PWR Private Constants
60
+  * @{
61
+  */
62
+  
63
+/** @defgroup PWR_PVD_Mode_Mask PWR PVD Mode Mask
64
+  * @{
65
+  */ 
66
+#define PVD_MODE_IT               0x00010000U
67
+#define PVD_MODE_EVT              0x00020000U
68
+#define PVD_RISING_EDGE           0x00000001U
69
+#define PVD_FALLING_EDGE          0x00000002U
70
+/**
71
+  * @}
72
+  */
73
+
74
+
75
+/** @defgroup PWR_register_alias_address PWR Register alias address
76
+  * @{
77
+  */ 
78
+/* ------------- PWR registers bit address in the alias region ---------------*/
79
+#define PWR_OFFSET               (PWR_BASE - PERIPH_BASE)
80
+#define PWR_CR_OFFSET            0x00U
81
+#define PWR_CSR_OFFSET           0x04U
82
+#define PWR_CR_OFFSET_BB         (PWR_OFFSET + PWR_CR_OFFSET)
83
+#define PWR_CSR_OFFSET_BB        (PWR_OFFSET + PWR_CSR_OFFSET)
84
+/**
85
+  * @}
86
+  */
87
+   
88
+/** @defgroup PWR_CR_register_alias PWR CR Register alias address
89
+  * @{
90
+  */  
91
+/* --- CR Register ---*/
92
+/* Alias word address of LPSDSR bit */
93
+#define LPSDSR_BIT_NUMBER        PWR_CR_LPDS_Pos
94
+#define CR_LPSDSR_BB             ((uint32_t)(PERIPH_BB_BASE + (PWR_CR_OFFSET_BB * 32U) + (LPSDSR_BIT_NUMBER * 4U)))
95
+
96
+/* Alias word address of DBP bit */
97
+#define DBP_BIT_NUMBER            PWR_CR_DBP_Pos
98
+#define CR_DBP_BB                ((uint32_t)(PERIPH_BB_BASE + (PWR_CR_OFFSET_BB * 32U) + (DBP_BIT_NUMBER * 4U)))
99
+
100
+/* Alias word address of PVDE bit */
101
+#define PVDE_BIT_NUMBER           PWR_CR_PVDE_Pos
102
+#define CR_PVDE_BB               ((uint32_t)(PERIPH_BB_BASE + (PWR_CR_OFFSET_BB * 32U) + (PVDE_BIT_NUMBER * 4U)))
103
+
104
+/**
105
+  * @}
106
+  */
107
+
108
+/** @defgroup PWR_CSR_register_alias PWR CSR Register alias address
109
+  * @{
110
+  */
111
+
112
+/* --- CSR Register ---*/
113
+/* Alias word address of EWUP1 bit */
114
+#define CSR_EWUP_BB(VAL)         ((uint32_t)(PERIPH_BB_BASE + (PWR_CSR_OFFSET_BB * 32U) + (POSITION_VAL(VAL) * 4U)))
115
+/**
116
+  * @}
117
+  */
118
+  
119
+/**
120
+  * @}
121
+  */
122
+
123
+/* Private variables ---------------------------------------------------------*/
124
+/* Private function prototypes -----------------------------------------------*/
125
+/** @defgroup PWR_Private_Functions PWR Private Functions
126
+ * brief   WFE cortex command overloaded for HAL_PWR_EnterSTOPMode usage only (see Workaround section)
127
+ * @{
128
+ */
129
+static void PWR_OverloadWfe(void);
130
+
131
+/* Private functions ---------------------------------------------------------*/
132
+__NOINLINE
133
+static void PWR_OverloadWfe(void)
134
+{
135
+  __asm volatile( "wfe" );
136
+  __asm volatile( "nop" );
137
+}
138
+
139
+/**
140
+  * @}
141
+  */
142
+
143
+
144
+/** @defgroup PWR_Exported_Functions PWR Exported Functions
145
+  * @{
146
+  */
147
+
148
+/** @defgroup PWR_Exported_Functions_Group1 Initialization and de-initialization functions 
149
+  *  @brief   Initialization and de-initialization functions
150
+  *
151
+@verbatim
152
+ ===============================================================================
153
+              ##### Initialization and de-initialization functions #####
154
+ ===============================================================================
155
+    [..]
156
+      After reset, the backup domain (RTC registers, RTC backup data
157
+      registers) is protected against possible unwanted
158
+      write accesses.
159
+      To enable access to the RTC Domain and RTC registers, proceed as follows:
160
+        (+) Enable the Power Controller (PWR) APB1 interface clock using the
161
+            __HAL_RCC_PWR_CLK_ENABLE() macro.
162
+        (+) Enable access to RTC domain using the HAL_PWR_EnableBkUpAccess() function.
163
+
164
+@endverbatim
165
+  * @{
166
+  */
167
+
168
+/**
169
+  * @brief  Deinitializes the PWR peripheral registers to their default reset values.  
170
+  * @retval None
171
+  */
172
+void HAL_PWR_DeInit(void)
173
+{
174
+  __HAL_RCC_PWR_FORCE_RESET();
175
+  __HAL_RCC_PWR_RELEASE_RESET();
176
+}
177
+
178
+/**
179
+  * @brief  Enables access to the backup domain (RTC registers, RTC
180
+  *         backup data registers ).
181
+  * @note   If the HSE divided by 128 is used as the RTC clock, the
182
+  *         Backup Domain Access should be kept enabled.
183
+  * @retval None
184
+  */
185
+void HAL_PWR_EnableBkUpAccess(void)
186
+{
187
+  /* Enable access to RTC and backup registers */
188
+  *(__IO uint32_t *) CR_DBP_BB = (uint32_t)ENABLE;
189
+}
190
+
191
+/**
192
+  * @brief  Disables access to the backup domain (RTC registers, RTC
193
+  *         backup data registers).
194
+  * @note   If the HSE divided by 128 is used as the RTC clock, the
195
+  *         Backup Domain Access should be kept enabled.
196
+  * @retval None
197
+  */
198
+void HAL_PWR_DisableBkUpAccess(void)
199
+{
200
+  /* Disable access to RTC and backup registers */
201
+  *(__IO uint32_t *) CR_DBP_BB = (uint32_t)DISABLE;
202
+}
203
+
204
+/**
205
+  * @}
206
+  */
207
+
208
+/** @defgroup PWR_Exported_Functions_Group2 Peripheral Control functions 
209
+  * @brief    Low Power modes configuration functions
210
+  *
211
+@verbatim
212
+ ===============================================================================
213
+                 ##### Peripheral Control functions #####
214
+ ===============================================================================
215
+     
216
+    *** PVD configuration ***
217
+    =========================
218
+    [..]
219
+      (+) The PVD is used to monitor the VDD power supply by comparing it to a
220
+          threshold selected by the PVD Level (PLS[2:0] bits in the PWR_CR).
221
+
222
+      (+) A PVDO flag is available to indicate if VDD/VDDA is higher or lower
223
+          than the PVD threshold. This event is internally connected to the EXTI
224
+          line16 and can generate an interrupt if enabled. This is done through
225
+          __HAL_PVD_EXTI_ENABLE_IT() macro.
226
+      (+) The PVD is stopped in Standby mode.
227
+
228
+    *** WakeUp pin configuration ***
229
+    ================================
230
+    [..]
231
+      (+) WakeUp pin is used to wake up the system from Standby mode. This pin is
232
+          forced in input pull-down configuration and is active on rising edges.
233
+      (+) There is one WakeUp pin:
234
+          WakeUp Pin 1 on PA.00.
235
+
236
+    [..]
237
+
238
+    *** Low Power modes configuration ***
239
+    =====================================
240
+     [..]
241
+      The device features 3 low-power modes:
242
+      (+) Sleep mode: CPU clock off, all peripherals including Cortex-M3 core peripherals like 
243
+                      NVIC, SysTick, etc. are kept running
244
+      (+) Stop mode: All clocks are stopped
245
+      (+) Standby mode: 1.8V domain powered off
246
+  
247
+  
248
+   *** Sleep mode ***
249
+   ==================
250
+    [..]
251
+      (+) Entry:
252
+          The Sleep mode is entered by using the HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFx)
253
+              functions with
254
+          (++) PWR_SLEEPENTRY_WFI: enter SLEEP mode with WFI instruction
255
+          (++) PWR_SLEEPENTRY_WFE: enter SLEEP mode with WFE instruction
256
+     
257
+      (+) Exit:
258
+        (++) WFI entry mode, Any peripheral interrupt acknowledged by the nested vectored interrupt
259
+             controller (NVIC) can wake up the device from Sleep mode.
260
+        (++) WFE entry mode, Any wakeup event can wake up the device from Sleep mode.
261
+           (+++) Any peripheral interrupt w/o NVIC configuration & SEVONPEND bit set in the Cortex (HAL_PWR_EnableSEVOnPend)
262
+           (+++) Any EXTI Line (Internal or External) configured in Event mode
263
+
264
+   *** Stop mode ***
265
+   =================
266
+    [..]
267
+      The Stop mode is based on the Cortex-M3 deepsleep mode combined with peripheral
268
+      clock gating. The voltage regulator can be configured either in normal or low-power mode.
269
+      In Stop mode, all clocks in the 1.8 V domain are stopped, the PLL, the HSI and the HSE RC 
270
+      oscillators are disabled. SRAM and register contents are preserved.
271
+      In Stop mode, all I/O pins keep the same state as in Run mode.
272
+
273
+      (+) Entry:
274
+           The Stop mode is entered using the HAL_PWR_EnterSTOPMode(PWR_REGULATOR_VALUE, PWR_SLEEPENTRY_WFx )
275
+             function with:
276
+          (++) PWR_REGULATOR_VALUE= PWR_MAINREGULATOR_ON: Main regulator ON.
277
+          (++) PWR_REGULATOR_VALUE= PWR_LOWPOWERREGULATOR_ON: Low Power regulator ON.
278
+          (++) PWR_SLEEPENTRY_WFx= PWR_SLEEPENTRY_WFI: enter STOP mode with WFI instruction
279
+          (++) PWR_SLEEPENTRY_WFx= PWR_SLEEPENTRY_WFE: enter STOP mode with WFE instruction
280
+      (+) Exit:
281
+          (++) WFI entry mode, Any EXTI Line (Internal or External) configured in Interrupt mode with NVIC configured
282
+          (++) WFE entry mode, Any EXTI Line (Internal or External) configured in Event mode.
283
+
284
+   *** Standby mode ***
285
+   ====================
286
+     [..]
287
+      The Standby mode allows to achieve the lowest power consumption. It is based on the
288
+      Cortex-M3 deepsleep mode, with the voltage regulator disabled. The 1.8 V domain is 
289
+      consequently powered off. The PLL, the HSI oscillator and the HSE oscillator are also 
290
+      switched off. SRAM and register contents are lost except for registers in the Backup domain 
291
+      and Standby circuitry
292
+      
293
+      (+) Entry:
294
+        (++) The Standby mode is entered using the HAL_PWR_EnterSTANDBYMode() function.
295
+      (+) Exit:
296
+        (++) WKUP pin rising edge, RTC alarm event rising edge, external Reset in 
297
+             NRSTpin, IWDG Reset
298
+
299
+   *** Auto-wakeup (AWU) from low-power mode ***
300
+       =============================================
301
+       [..]
302
+        
303
+       (+) The MCU can be woken up from low-power mode by an RTC Alarm event, 
304
+           without depending on an external interrupt (Auto-wakeup mode).
305
+   
306
+       (+) RTC auto-wakeup (AWU) from the Stop and Standby modes
307
+
308
+           (++) To wake up from the Stop mode with an RTC alarm event, it is necessary to 
309
+                configure the RTC to generate the RTC alarm using the HAL_RTC_SetAlarm_IT() function.
310
+
311
+   *** PWR Workarounds linked to Silicon Limitation ***
312
+       ====================================================
313
+       [..]
314
+       Below the list of all silicon limitations known on STM32F1xx prouct.
315
+
316
+       (#)Workarounds Implemented inside PWR HAL Driver
317
+          (##)Debugging Stop mode with WFE entry - overloaded the WFE by an internal function    
318
+        
319
+@endverbatim
320
+  * @{
321
+  */
322
+
323
+/**
324
+  * @brief  Configures the voltage threshold detected by the Power Voltage Detector(PVD).
325
+  * @param  sConfigPVD: pointer to an PWR_PVDTypeDef structure that contains the configuration
326
+  *         information for the PVD.
327
+  * @note   Refer to the electrical characteristics of your device datasheet for
328
+  *         more details about the voltage threshold corresponding to each
329
+  *         detection level.
330
+  * @retval None
331
+  */
332
+void HAL_PWR_ConfigPVD(PWR_PVDTypeDef *sConfigPVD)
333
+{
334
+  /* Check the parameters */
335
+  assert_param(IS_PWR_PVD_LEVEL(sConfigPVD->PVDLevel));
336
+  assert_param(IS_PWR_PVD_MODE(sConfigPVD->Mode));
337
+
338
+  /* Set PLS[7:5] bits according to PVDLevel value */
339
+  MODIFY_REG(PWR->CR, PWR_CR_PLS, sConfigPVD->PVDLevel);
340
+  
341
+  /* Clear any previous config. Keep it clear if no event or IT mode is selected */
342
+  __HAL_PWR_PVD_EXTI_DISABLE_EVENT();
343
+  __HAL_PWR_PVD_EXTI_DISABLE_IT();
344
+  __HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE(); 
345
+  __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE();
346
+
347
+  /* Configure interrupt mode */
348
+  if((sConfigPVD->Mode & PVD_MODE_IT) == PVD_MODE_IT)
349
+  {
350
+    __HAL_PWR_PVD_EXTI_ENABLE_IT();
351
+  }
352
+  
353
+  /* Configure event mode */
354
+  if((sConfigPVD->Mode & PVD_MODE_EVT) == PVD_MODE_EVT)
355
+  {
356
+    __HAL_PWR_PVD_EXTI_ENABLE_EVENT();
357
+  }
358
+  
359
+  /* Configure the edge */
360
+  if((sConfigPVD->Mode & PVD_RISING_EDGE) == PVD_RISING_EDGE)
361
+  {
362
+    __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE();
363
+  }
364
+  
365
+  if((sConfigPVD->Mode & PVD_FALLING_EDGE) == PVD_FALLING_EDGE)
366
+  {
367
+    __HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE();
368
+  }
369
+}
370
+
371
+/**
372
+  * @brief  Enables the Power Voltage Detector(PVD).
373
+  * @retval None
374
+  */
375
+void HAL_PWR_EnablePVD(void)
376
+{
377
+  /* Enable the power voltage detector */
378
+  *(__IO uint32_t *) CR_PVDE_BB = (uint32_t)ENABLE;
379
+}
380
+
381
+/**
382
+  * @brief  Disables the Power Voltage Detector(PVD).
383
+  * @retval None
384
+  */
385
+void HAL_PWR_DisablePVD(void)
386
+{
387
+  /* Disable the power voltage detector */
388
+  *(__IO uint32_t *) CR_PVDE_BB = (uint32_t)DISABLE;
389
+}
390
+
391
+/**
392
+  * @brief Enables the WakeUp PINx functionality.
393
+  * @param WakeUpPinx: Specifies the Power Wake-Up pin to enable.
394
+  *        This parameter can be one of the following values:
395
+  *           @arg PWR_WAKEUP_PIN1
396
+  * @retval None
397
+  */
398
+void HAL_PWR_EnableWakeUpPin(uint32_t WakeUpPinx)
399
+{
400
+  /* Check the parameter */
401
+  assert_param(IS_PWR_WAKEUP_PIN(WakeUpPinx));
402
+  /* Enable the EWUPx pin */
403
+  *(__IO uint32_t *) CSR_EWUP_BB(WakeUpPinx) = (uint32_t)ENABLE;
404
+}
405
+
406
+/**
407
+  * @brief Disables the WakeUp PINx functionality.
408
+  * @param WakeUpPinx: Specifies the Power Wake-Up pin to disable.
409
+  *        This parameter can be one of the following values:
410
+  *           @arg PWR_WAKEUP_PIN1
411
+  * @retval None
412
+  */
413
+void HAL_PWR_DisableWakeUpPin(uint32_t WakeUpPinx)
414
+{
415
+  /* Check the parameter */
416
+  assert_param(IS_PWR_WAKEUP_PIN(WakeUpPinx));
417
+  /* Disable the EWUPx pin */
418
+  *(__IO uint32_t *) CSR_EWUP_BB(WakeUpPinx) = (uint32_t)DISABLE;
419
+}
420
+
421
+/**
422
+  * @brief Enters Sleep mode.
423
+  * @note  In Sleep mode, all I/O pins keep the same state as in Run mode.
424
+  * @param Regulator: Regulator state as no effect in SLEEP mode -  allows to support portability from legacy software
425
+  * @param SLEEPEntry: Specifies if SLEEP mode is entered with WFI or WFE instruction.
426
+  *           When WFI entry is used, tick interrupt have to be disabled if not desired as 
427
+  *           the interrupt wake up source.
428
+  *           This parameter can be one of the following values:
429
+  *            @arg PWR_SLEEPENTRY_WFI: enter SLEEP mode with WFI instruction
430
+  *            @arg PWR_SLEEPENTRY_WFE: enter SLEEP mode with WFE instruction
431
+  * @retval None
432
+  */
433
+void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry)
434
+{
435
+  /* Check the parameters */
436
+  /* No check on Regulator because parameter not used in SLEEP mode */
437
+  /* Prevent unused argument(s) compilation warning */
438
+  UNUSED(Regulator);
439
+
440
+  assert_param(IS_PWR_SLEEP_ENTRY(SLEEPEntry));
441
+
442
+  /* Clear SLEEPDEEP bit of Cortex System Control Register */
443
+  CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
444
+
445
+  /* Select SLEEP mode entry -------------------------------------------------*/
446
+  if(SLEEPEntry == PWR_SLEEPENTRY_WFI)
447
+  {
448
+    /* Request Wait For Interrupt */
449
+    __WFI();
450
+  }
451
+  else
452
+  {
453
+    /* Request Wait For Event */
454
+    __SEV();
455
+    __WFE();
456
+    __WFE();
457
+  }
458
+}
459
+
460
+/**
461
+  * @brief Enters Stop mode. 
462
+  * @note  In Stop mode, all I/O pins keep the same state as in Run mode.
463
+  * @note  When exiting Stop mode by using an interrupt or a wakeup event,
464
+  *        HSI RC oscillator is selected as system clock.
465
+  * @note  When the voltage regulator operates in low power mode, an additional
466
+  *         startup delay is incurred when waking up from Stop mode. 
467
+  *         By keeping the internal regulator ON during Stop mode, the consumption
468
+  *         is higher although the startup time is reduced.    
469
+  * @param Regulator: Specifies the regulator state in Stop mode.
470
+  *          This parameter can be one of the following values:
471
+  *            @arg PWR_MAINREGULATOR_ON: Stop mode with regulator ON
472
+  *            @arg PWR_LOWPOWERREGULATOR_ON: Stop mode with low power regulator ON
473
+  * @param STOPEntry: Specifies if Stop mode in entered with WFI or WFE instruction.
474
+  *          This parameter can be one of the following values:
475
+  *            @arg PWR_STOPENTRY_WFI: Enter Stop mode with WFI instruction
476
+  *            @arg PWR_STOPENTRY_WFE: Enter Stop mode with WFE instruction   
477
+  * @retval None
478
+  */
479
+void HAL_PWR_EnterSTOPMode(uint32_t Regulator, uint8_t STOPEntry)
480
+{
481
+  /* Check the parameters */
482
+  assert_param(IS_PWR_REGULATOR(Regulator));
483
+  assert_param(IS_PWR_STOP_ENTRY(STOPEntry));
484
+
485
+  /* Clear PDDS bit in PWR register to specify entering in STOP mode when CPU enter in Deepsleep */ 
486
+  CLEAR_BIT(PWR->CR,  PWR_CR_PDDS);
487
+
488
+  /* Select the voltage regulator mode by setting LPDS bit in PWR register according to Regulator parameter value */
489
+  MODIFY_REG(PWR->CR, PWR_CR_LPDS, Regulator);
490
+
491
+  /* Set SLEEPDEEP bit of Cortex System Control Register */
492
+  SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
493
+
494
+  /* Select Stop mode entry --------------------------------------------------*/
495
+  if(STOPEntry == PWR_STOPENTRY_WFI)
496
+  {
497
+    /* Request Wait For Interrupt */
498
+    __WFI();
499
+  }
500
+  else
501
+  {
502
+    /* Request Wait For Event */
503
+    __SEV();
504
+    PWR_OverloadWfe(); /* WFE redefine locally */
505
+    PWR_OverloadWfe(); /* WFE redefine locally */
506
+  }
507
+  /* Reset SLEEPDEEP bit of Cortex System Control Register */
508
+  CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
509
+}
510
+
511
+/**
512
+  * @brief Enters Standby mode.
513
+  * @note  In Standby mode, all I/O pins are high impedance except for:
514
+  *          - Reset pad (still available) 
515
+  *          - TAMPER pin if configured for tamper or calibration out.
516
+  *          - WKUP pin (PA0) if enabled.
517
+  * @retval None
518
+  */
519
+void HAL_PWR_EnterSTANDBYMode(void)
520
+{
521
+  /* Select Standby mode */
522
+  SET_BIT(PWR->CR, PWR_CR_PDDS);
523
+
524
+  /* Set SLEEPDEEP bit of Cortex System Control Register */
525
+  SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
526
+
527
+  /* This option is used to ensure that store operations are completed */
528
+#if defined ( __CC_ARM)
529
+  __force_stores();
530
+#endif
531
+  /* Request Wait For Interrupt */
532
+  __WFI();
533
+}
534
+
535
+
536
+/**
537
+  * @brief Indicates Sleep-On-Exit when returning from Handler mode to Thread mode. 
538
+  * @note Set SLEEPONEXIT bit of SCR register. When this bit is set, the processor 
539
+  *       re-enters SLEEP mode when an interruption handling is over.
540
+  *       Setting this bit is useful when the processor is expected to run only on
541
+  *       interruptions handling.         
542
+  * @retval None
543
+  */
544
+void HAL_PWR_EnableSleepOnExit(void)
545
+{
546
+  /* Set SLEEPONEXIT bit of Cortex System Control Register */
547
+  SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPONEXIT_Msk));
548
+}
549
+
550
+
551
+/**
552
+  * @brief Disables Sleep-On-Exit feature when returning from Handler mode to Thread mode. 
553
+  * @note Clears SLEEPONEXIT bit of SCR register. When this bit is set, the processor 
554
+  *       re-enters SLEEP mode when an interruption handling is over.          
555
+  * @retval None
556
+  */
557
+void HAL_PWR_DisableSleepOnExit(void)
558
+{
559
+  /* Clear SLEEPONEXIT bit of Cortex System Control Register */
560
+  CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPONEXIT_Msk));
561
+}
562
+
563
+
564
+/**
565
+  * @brief Enables CORTEX M3 SEVONPEND bit. 
566
+  * @note Sets SEVONPEND bit of SCR register. When this bit is set, this causes 
567
+  *       WFE to wake up when an interrupt moves from inactive to pended.
568
+  * @retval None
569
+  */
570
+void HAL_PWR_EnableSEVOnPend(void)
571
+{
572
+  /* Set SEVONPEND bit of Cortex System Control Register */
573
+  SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SEVONPEND_Msk));
574
+}
575
+
576
+
577
+/**
578
+  * @brief Disables CORTEX M3 SEVONPEND bit. 
579
+  * @note Clears SEVONPEND bit of SCR register. When this bit is set, this causes 
580
+  *       WFE to wake up when an interrupt moves from inactive to pended.         
581
+  * @retval None
582
+  */
583
+void HAL_PWR_DisableSEVOnPend(void)
584
+{
585
+  /* Clear SEVONPEND bit of Cortex System Control Register */
586
+  CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SEVONPEND_Msk));
587
+}
588
+
589
+
590
+
591
+/**
592
+  * @brief  This function handles the PWR PVD interrupt request.
593
+  * @note   This API should be called under the PVD_IRQHandler().
594
+  * @retval None
595
+  */
596
+void HAL_PWR_PVD_IRQHandler(void)
597
+{
598
+  /* Check PWR exti flag */
599
+  if(__HAL_PWR_PVD_EXTI_GET_FLAG() != RESET)
600
+  {
601
+    /* PWR PVD interrupt user callback */
602
+    HAL_PWR_PVDCallback();
603
+
604
+    /* Clear PWR Exti pending bit */
605
+    __HAL_PWR_PVD_EXTI_CLEAR_FLAG();
606
+  }
607
+}
608
+
609
+/**
610
+  * @brief  PWR PVD interrupt callback
611
+  * @retval None
612
+  */
613
+__weak void HAL_PWR_PVDCallback(void)
614
+{
615
+  /* NOTE : This function Should not be modified, when the callback is needed,
616
+            the HAL_PWR_PVDCallback could be implemented in the user file
617
+   */ 
618
+}
619
+
620
+/**
621
+  * @}
622
+  */
623
+
624
+/**
625
+  * @}
626
+  */
627
+
628
+#endif /* HAL_PWR_MODULE_ENABLED */
629
+/**
630
+  * @}
631
+  */
632
+
633
+/**
634
+  * @}
635
+  */
636
+
637
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

文件差异内容过多而无法显示
+ 1416 - 0
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c


+ 879 - 0
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c

@@ -0,0 +1,879 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx_hal_rcc_ex.c
4
+  * @author  MCD Application Team
5
+  * @brief   Extended RCC HAL module driver.
6
+  *          This file provides firmware functions to manage the following 
7
+  *          functionalities RCC extension peripheral:
8
+  *           + Extended Peripheral Control functions
9
+  *  
10
+  ******************************************************************************
11
+  * @attention
12
+  *
13
+  * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
14
+  *
15
+  * Redistribution and use in source and binary forms, with or without modification,
16
+  * are permitted provided that the following conditions are met:
17
+  *   1. Redistributions of source code must retain the above copyright notice,
18
+  *      this list of conditions and the following disclaimer.
19
+  *   2. Redistributions in binary form must reproduce the above copyright notice,
20
+  *      this list of conditions and the following disclaimer in the documentation
21
+  *      and/or other materials provided with the distribution.
22
+  *   3. Neither the name of STMicroelectronics nor the names of its contributors
23
+  *      may be used to endorse or promote products derived from this software
24
+  *      without specific prior written permission.
25
+  *
26
+  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27
+  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29
+  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
30
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32
+  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33
+  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
34
+  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35
+  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
+  *
37
+  ******************************************************************************  
38
+  */ 
39
+
40
+/* Includes ------------------------------------------------------------------*/
41
+#include "stm32f1xx_hal.h"
42
+
43
+/** @addtogroup STM32F1xx_HAL_Driver
44
+  * @{
45
+  */
46
+
47
+#ifdef HAL_RCC_MODULE_ENABLED
48
+
49
+/** @defgroup RCCEx RCCEx
50
+  * @brief RCC Extension HAL module driver.
51
+  * @{
52
+  */
53
+
54
+/* Private typedef -----------------------------------------------------------*/
55
+/* Private define ------------------------------------------------------------*/
56
+/** @defgroup RCCEx_Private_Constants RCCEx Private Constants
57
+  * @{
58
+  */
59
+/**
60
+  * @}
61
+  */
62
+
63
+/* Private macro -------------------------------------------------------------*/
64
+/** @defgroup RCCEx_Private_Macros RCCEx Private Macros
65
+  * @{
66
+  */
67
+/**
68
+  * @}
69
+  */
70
+
71
+/* Private variables ---------------------------------------------------------*/
72
+/* Private function prototypes -----------------------------------------------*/
73
+/* Private functions ---------------------------------------------------------*/
74
+
75
+/** @defgroup RCCEx_Exported_Functions RCCEx Exported Functions
76
+  * @{
77
+  */
78
+
79
+/** @defgroup RCCEx_Exported_Functions_Group1 Peripheral Control functions 
80
+  *  @brief  Extended Peripheral Control functions  
81
+  *
82
+@verbatim   
83
+ ===============================================================================
84
+                ##### Extended Peripheral Control functions  #####
85
+ ===============================================================================  
86
+    [..]
87
+    This subsection provides a set of functions allowing to control the RCC Clocks 
88
+    frequencies.
89
+    [..] 
90
+    (@) Important note: Care must be taken when HAL_RCCEx_PeriphCLKConfig() is used to
91
+        select the RTC clock source; in this case the Backup domain will be reset in  
92
+        order to modify the RTC Clock source, as consequence RTC registers (including 
93
+        the backup registers) are set to their reset values.
94
+      
95
+@endverbatim
96
+  * @{
97
+  */
98
+
99
+/**
100
+  * @brief  Initializes the RCC extended peripherals clocks according to the specified parameters in the
101
+  *         RCC_PeriphCLKInitTypeDef.
102
+  * @param  PeriphClkInit pointer to an RCC_PeriphCLKInitTypeDef structure that
103
+  *         contains the configuration information for the Extended Peripherals clocks(RTC clock).
104
+  *
105
+  * @note   Care must be taken when HAL_RCCEx_PeriphCLKConfig() is used to select 
106
+  *         the RTC clock source; in this case the Backup domain will be reset in  
107
+  *         order to modify the RTC Clock source, as consequence RTC registers (including 
108
+  *         the backup registers) are set to their reset values.
109
+  *
110
+  * @note   In case of STM32F105xC or STM32F107xC devices, PLLI2S will be enabled if requested on 
111
+  *         one of 2 I2S interfaces. When PLLI2S is enabled, you need to call HAL_RCCEx_DisablePLLI2S to
112
+  *         manually disable it.
113
+  *
114
+  * @retval HAL status
115
+  */
116
+HAL_StatusTypeDef HAL_RCCEx_PeriphCLKConfig(RCC_PeriphCLKInitTypeDef  *PeriphClkInit)
117
+{
118
+  uint32_t tickstart = 0U, temp_reg = 0U;
119
+#if defined(STM32F105xC) || defined(STM32F107xC)
120
+  uint32_t  pllactive = 0U;
121
+#endif /* STM32F105xC || STM32F107xC */
122
+
123
+  /* Check the parameters */
124
+  assert_param(IS_RCC_PERIPHCLOCK(PeriphClkInit->PeriphClockSelection));
125
+  
126
+  /*------------------------------- RTC/LCD Configuration ------------------------*/ 
127
+  if ((((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_RTC) == RCC_PERIPHCLK_RTC))
128
+  {
129
+    /* check for RTC Parameters used to output RTCCLK */
130
+    assert_param(IS_RCC_RTCCLKSOURCE(PeriphClkInit->RTCClockSelection));
131
+
132
+    FlagStatus       pwrclkchanged = RESET;
133
+
134
+    /* As soon as function is called to change RTC clock source, activation of the 
135
+       power domain is done. */
136
+    /* Requires to enable write access to Backup Domain of necessary */
137
+    if(__HAL_RCC_PWR_IS_CLK_DISABLED())
138
+    {
139
+    __HAL_RCC_PWR_CLK_ENABLE();
140
+      pwrclkchanged = SET;
141
+    }
142
+    
143
+    if(HAL_IS_BIT_CLR(PWR->CR, PWR_CR_DBP))
144
+    {
145
+      /* Enable write access to Backup domain */
146
+      SET_BIT(PWR->CR, PWR_CR_DBP);
147
+      
148
+      /* Wait for Backup domain Write protection disable */
149
+      tickstart = HAL_GetTick();
150
+      
151
+      while(HAL_IS_BIT_CLR(PWR->CR, PWR_CR_DBP))
152
+      {
153
+        if((HAL_GetTick() - tickstart) > RCC_DBP_TIMEOUT_VALUE)
154
+        {
155
+          return HAL_TIMEOUT;
156
+        }
157
+      }
158
+    }
159
+      
160
+    /* Reset the Backup domain only if the RTC Clock source selection is modified from reset value */ 
161
+    temp_reg = (RCC->BDCR & RCC_BDCR_RTCSEL);
162
+    if((temp_reg != 0x00000000U) && (temp_reg != (PeriphClkInit->RTCClockSelection & RCC_BDCR_RTCSEL)))
163
+    {
164
+      /* Store the content of BDCR register before the reset of Backup Domain */
165
+      temp_reg = (RCC->BDCR & ~(RCC_BDCR_RTCSEL));
166
+      /* RTC Clock selection can be changed only if the Backup Domain is reset */
167
+      __HAL_RCC_BACKUPRESET_FORCE();
168
+      __HAL_RCC_BACKUPRESET_RELEASE();
169
+      /* Restore the Content of BDCR register */
170
+      RCC->BDCR = temp_reg;
171
+
172
+      /* Wait for LSERDY if LSE was enabled */
173
+      if (HAL_IS_BIT_SET(temp_reg, RCC_BDCR_LSEON))
174
+      {
175
+        /* Get Start Tick */
176
+        tickstart = HAL_GetTick();
177
+      
178
+        /* Wait till LSE is ready */  
179
+        while(__HAL_RCC_GET_FLAG(RCC_FLAG_LSERDY) == RESET)
180
+        {
181
+          if((HAL_GetTick() - tickstart) > RCC_LSE_TIMEOUT_VALUE)
182
+          {
183
+            return HAL_TIMEOUT;
184
+          }      
185
+        }  
186
+      }
187
+    }
188
+    __HAL_RCC_RTC_CONFIG(PeriphClkInit->RTCClockSelection); 
189
+
190
+    /* Require to disable power clock if necessary */
191
+    if(pwrclkchanged == SET)
192
+    {
193
+      __HAL_RCC_PWR_CLK_DISABLE();
194
+    }
195
+  }
196
+
197
+  /*------------------------------ ADC clock Configuration ------------------*/ 
198
+  if(((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_ADC) == RCC_PERIPHCLK_ADC)
199
+  {
200
+    /* Check the parameters */
201
+    assert_param(IS_RCC_ADCPLLCLK_DIV(PeriphClkInit->AdcClockSelection));
202
+    
203
+    /* Configure the ADC clock source */
204
+    __HAL_RCC_ADC_CONFIG(PeriphClkInit->AdcClockSelection);
205
+  }
206
+
207
+#if defined(STM32F105xC) || defined(STM32F107xC)
208
+  /*------------------------------ I2S2 Configuration ------------------------*/ 
209
+  if(((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_I2S2) == RCC_PERIPHCLK_I2S2)
210
+  {
211
+    /* Check the parameters */
212
+    assert_param(IS_RCC_I2S2CLKSOURCE(PeriphClkInit->I2s2ClockSelection));
213
+
214
+    /* Configure the I2S2 clock source */
215
+    __HAL_RCC_I2S2_CONFIG(PeriphClkInit->I2s2ClockSelection);
216
+  }
217
+
218
+  /*------------------------------ I2S3 Configuration ------------------------*/ 
219
+  if(((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_I2S3) == RCC_PERIPHCLK_I2S3)
220
+  {
221
+    /* Check the parameters */
222
+    assert_param(IS_RCC_I2S3CLKSOURCE(PeriphClkInit->I2s3ClockSelection));
223
+    
224
+    /* Configure the I2S3 clock source */
225
+    __HAL_RCC_I2S3_CONFIG(PeriphClkInit->I2s3ClockSelection);
226
+  }
227
+
228
+  /*------------------------------ PLL I2S Configuration ----------------------*/ 
229
+  /* Check that PLLI2S need to be enabled */
230
+  if (HAL_IS_BIT_SET(RCC->CFGR2, RCC_CFGR2_I2S2SRC) || HAL_IS_BIT_SET(RCC->CFGR2, RCC_CFGR2_I2S3SRC))
231
+  {
232
+    /* Update flag to indicate that PLL I2S should be active */
233
+    pllactive = 1;
234
+  }
235
+
236
+  /* Check if PLL I2S need to be enabled */
237
+  if (pllactive == 1)
238
+  {
239
+    /* Enable PLL I2S only if not active */
240
+    if (HAL_IS_BIT_CLR(RCC->CR, RCC_CR_PLL3ON))
241
+    {
242
+      /* Check the parameters */
243
+      assert_param(IS_RCC_PLLI2S_MUL(PeriphClkInit->PLLI2S.PLLI2SMUL));
244
+      assert_param(IS_RCC_HSE_PREDIV2(PeriphClkInit->PLLI2S.HSEPrediv2Value));
245
+
246
+      /* Prediv2 can be written only when the PLL2 is disabled. */
247
+      /* Return an error only if new value is different from the programmed value */
248
+      if (HAL_IS_BIT_SET(RCC->CR,RCC_CR_PLL2ON) && \
249
+        (__HAL_RCC_HSE_GET_PREDIV2() != PeriphClkInit->PLLI2S.HSEPrediv2Value))
250
+      {
251
+        return HAL_ERROR;
252
+      }
253
+
254
+      /* Configure the HSE prediv2 factor --------------------------------*/
255
+      __HAL_RCC_HSE_PREDIV2_CONFIG(PeriphClkInit->PLLI2S.HSEPrediv2Value);
256
+
257
+      /* Configure the main PLLI2S multiplication factors. */
258
+      __HAL_RCC_PLLI2S_CONFIG(PeriphClkInit->PLLI2S.PLLI2SMUL);
259
+      
260
+      /* Enable the main PLLI2S. */
261
+      __HAL_RCC_PLLI2S_ENABLE();
262
+      
263
+      /* Get Start Tick*/
264
+      tickstart = HAL_GetTick();
265
+      
266
+      /* Wait till PLLI2S is ready */
267
+      while(__HAL_RCC_GET_FLAG(RCC_FLAG_PLLI2SRDY)  == RESET)
268
+      {
269
+        if((HAL_GetTick() - tickstart ) > PLLI2S_TIMEOUT_VALUE)
270
+        {
271
+          return HAL_TIMEOUT;
272
+        }
273
+      }
274
+    }
275
+    else
276
+    {
277
+      /* Return an error only if user wants to change the PLLI2SMUL whereas PLLI2S is active */
278
+      if (READ_BIT(RCC->CFGR2, RCC_CFGR2_PLL3MUL) != PeriphClkInit->PLLI2S.PLLI2SMUL)
279
+      {
280
+          return HAL_ERROR;
281
+      }
282
+    }
283
+  }
284
+#endif /* STM32F105xC || STM32F107xC */
285
+
286
+#if defined(STM32F102x6) || defined(STM32F102xB) || defined(STM32F103x6)\
287
+ || defined(STM32F103xB) || defined(STM32F103xE) || defined(STM32F103xG)\
288
+ || defined(STM32F105xC) || defined(STM32F107xC)
289
+  /*------------------------------ USB clock Configuration ------------------*/ 
290
+  if(((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_USB) == RCC_PERIPHCLK_USB)
291
+  {
292
+    /* Check the parameters */
293
+    assert_param(IS_RCC_USBPLLCLK_DIV(PeriphClkInit->UsbClockSelection));
294
+    
295
+    /* Configure the USB clock source */
296
+    __HAL_RCC_USB_CONFIG(PeriphClkInit->UsbClockSelection);
297
+  }
298
+#endif /* STM32F102x6 || STM32F102xB || STM32F103x6 || STM32F103xB || STM32F103xE || STM32F103xG || STM32F105xC || STM32F107xC */
299
+
300
+  return HAL_OK;
301
+}
302
+
303
+/**
304
+  * @brief  Get the PeriphClkInit according to the internal
305
+  * RCC configuration registers.
306
+  * @param  PeriphClkInit pointer to an RCC_PeriphCLKInitTypeDef structure that 
307
+  *         returns the configuration information for the Extended Peripherals clocks(RTC, I2S, ADC clocks).
308
+  * @retval None
309
+  */
310
+void HAL_RCCEx_GetPeriphCLKConfig(RCC_PeriphCLKInitTypeDef  *PeriphClkInit)
311
+{
312
+  uint32_t srcclk = 0U;
313
+  
314
+  /* Set all possible values for the extended clock type parameter------------*/
315
+  PeriphClkInit->PeriphClockSelection = RCC_PERIPHCLK_RTC;
316
+
317
+  /* Get the RTC configuration -----------------------------------------------*/
318
+  srcclk = __HAL_RCC_GET_RTC_SOURCE();
319
+  /* Source clock is LSE or LSI*/
320
+  PeriphClkInit->RTCClockSelection = srcclk;
321
+
322
+  /* Get the ADC clock configuration -----------------------------------------*/
323
+  PeriphClkInit->PeriphClockSelection |= RCC_PERIPHCLK_ADC;
324
+  PeriphClkInit->AdcClockSelection = __HAL_RCC_GET_ADC_SOURCE();
325
+
326
+#if defined(STM32F105xC) || defined(STM32F107xC)
327
+  /* Get the I2S2 clock configuration -----------------------------------------*/
328
+  PeriphClkInit->PeriphClockSelection |= RCC_PERIPHCLK_I2S2;
329
+  PeriphClkInit->I2s2ClockSelection = __HAL_RCC_GET_I2S2_SOURCE();
330
+
331
+  /* Get the I2S3 clock configuration -----------------------------------------*/
332
+  PeriphClkInit->PeriphClockSelection |= RCC_PERIPHCLK_I2S3;
333
+  PeriphClkInit->I2s3ClockSelection = __HAL_RCC_GET_I2S3_SOURCE();
334
+
335
+#endif /* STM32F105xC || STM32F107xC */
336
+
337
+#if defined(STM32F103xE) || defined(STM32F103xG)
338
+  /* Get the I2S2 clock configuration -----------------------------------------*/
339
+  PeriphClkInit->PeriphClockSelection |= RCC_PERIPHCLK_I2S2;
340
+  PeriphClkInit->I2s2ClockSelection = RCC_I2S2CLKSOURCE_SYSCLK;
341
+
342
+  /* Get the I2S3 clock configuration -----------------------------------------*/
343
+  PeriphClkInit->PeriphClockSelection |= RCC_PERIPHCLK_I2S3;
344
+  PeriphClkInit->I2s3ClockSelection = RCC_I2S3CLKSOURCE_SYSCLK;
345
+
346
+#endif /* STM32F103xE || STM32F103xG */
347
+
348
+#if defined(STM32F102x6) || defined(STM32F102xB) || defined(STM32F103x6)\
349
+ || defined(STM32F103xB) || defined(STM32F103xE) || defined(STM32F103xG)\
350
+ || defined(STM32F105xC) || defined(STM32F107xC)
351
+  /* Get the USB clock configuration -----------------------------------------*/
352
+  PeriphClkInit->PeriphClockSelection |= RCC_PERIPHCLK_USB;
353
+  PeriphClkInit->UsbClockSelection = __HAL_RCC_GET_USB_SOURCE();
354
+#endif /* STM32F102x6 || STM32F102xB || STM32F103x6 || STM32F103xB || STM32F103xE || STM32F103xG || STM32F105xC || STM32F107xC */
355
+}
356
+
357
+/**
358
+  * @brief  Returns the peripheral clock frequency
359
+  * @note   Returns 0 if peripheral clock is unknown
360
+  * @param  PeriphClk Peripheral clock identifier
361
+  *         This parameter can be one of the following values:
362
+  *            @arg @ref RCC_PERIPHCLK_RTC  RTC peripheral clock
363
+  *            @arg @ref RCC_PERIPHCLK_ADC  ADC peripheral clock
364
+  @if STM32F103xE
365
+  *            @arg @ref RCC_PERIPHCLK_I2S2 I2S2 peripheral clock
366
+  *            @arg @ref RCC_PERIPHCLK_I2S3 I2S3 peripheral clock
367
+  *            @arg @ref RCC_PERIPHCLK_I2S3 I2S3 peripheral clock
368
+  @endif
369
+  @if STM32F103xG
370
+  *            @arg @ref RCC_PERIPHCLK_I2S2 I2S2 peripheral clock
371
+  *            @arg @ref RCC_PERIPHCLK_I2S3 I2S3 peripheral clock
372
+  *            @arg @ref RCC_PERIPHCLK_I2S3 I2S3 peripheral clock
373
+  *            @arg @ref RCC_PERIPHCLK_I2S2 I2S2 peripheral clock
374
+  @endif
375
+  @if STM32F105xC
376
+  *            @arg @ref RCC_PERIPHCLK_I2S2 I2S2 peripheral clock
377
+  *            @arg @ref RCC_PERIPHCLK_I2S3 I2S3 peripheral clock
378
+  *            @arg @ref RCC_PERIPHCLK_I2S3 I2S3 peripheral clock
379
+  *            @arg @ref RCC_PERIPHCLK_I2S2 I2S2 peripheral clock
380
+  *            @arg @ref RCC_PERIPHCLK_I2S3 I2S3 peripheral clock
381
+  *            @arg @ref RCC_PERIPHCLK_I2S3 I2S3 peripheral clock
382
+  *            @arg @ref RCC_PERIPHCLK_I2S2 I2S2 peripheral clock
383
+  *            @arg @ref RCC_PERIPHCLK_USB  USB peripheral clock
384
+  @endif
385
+  @if STM32F107xC
386
+  *            @arg @ref RCC_PERIPHCLK_I2S2 I2S2 peripheral clock
387
+  *            @arg @ref RCC_PERIPHCLK_I2S3 I2S3 peripheral clock
388
+  *            @arg @ref RCC_PERIPHCLK_I2S3 I2S3 peripheral clock
389
+  *            @arg @ref RCC_PERIPHCLK_I2S2 I2S2 peripheral clock
390
+  *            @arg @ref RCC_PERIPHCLK_I2S3 I2S3 peripheral clock
391
+  *            @arg @ref RCC_PERIPHCLK_I2S3 I2S3 peripheral clock
392
+  *            @arg @ref RCC_PERIPHCLK_I2S2 I2S2 peripheral clock
393
+  *            @arg @ref RCC_PERIPHCLK_USB  USB peripheral clock
394
+  @endif
395
+  @if STM32F102xx
396
+  *            @arg @ref RCC_PERIPHCLK_USB  USB peripheral clock
397
+  @endif
398
+  @if STM32F103xx
399
+  *            @arg @ref RCC_PERIPHCLK_USB  USB peripheral clock
400
+  @endif
401
+  * @retval Frequency in Hz (0: means that no available frequency for the peripheral)
402
+  */
403
+uint32_t HAL_RCCEx_GetPeriphCLKFreq(uint32_t PeriphClk)
404
+{
405
+#if defined(STM32F105xC) || defined(STM32F107xC)
406
+  const uint8_t aPLLMULFactorTable[14] = {0, 0, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 13};
407
+  const uint8_t aPredivFactorTable[16] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
408
+
409
+  uint32_t prediv1 = 0U, pllclk = 0U, pllmul = 0U;
410
+  uint32_t pll2mul = 0U, pll3mul = 0U, prediv2 = 0U;
411
+#endif /* STM32F105xC || STM32F107xC */
412
+#if defined(STM32F102x6) || defined(STM32F102xB) || defined(STM32F103x6) || \
413
+    defined(STM32F103xB) || defined(STM32F103xE) || defined(STM32F103xG)
414
+  const uint8_t aPLLMULFactorTable[16] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 16};
415
+  const uint8_t aPredivFactorTable[2] = {1, 2};
416
+
417
+  uint32_t prediv1 = 0U, pllclk = 0U, pllmul = 0U;
418
+#endif /* STM32F102x6 || STM32F102xB || STM32F103x6 || STM32F103xB || STM32F103xE || STM32F103xG */
419
+  uint32_t temp_reg = 0U, frequency = 0U;
420
+
421
+  /* Check the parameters */
422
+  assert_param(IS_RCC_PERIPHCLOCK(PeriphClk));
423
+  
424
+  switch (PeriphClk)
425
+  {
426
+#if defined(STM32F102x6) || defined(STM32F102xB) || defined(STM32F103x6)\
427
+ || defined(STM32F103xB) || defined(STM32F103xE) || defined(STM32F103xG)\
428
+ || defined(STM32F105xC) || defined(STM32F107xC)
429
+  case RCC_PERIPHCLK_USB:  
430
+    {
431
+      /* Get RCC configuration ------------------------------------------------------*/
432
+      temp_reg = RCC->CFGR;
433
+  
434
+      /* Check if PLL is enabled */
435
+      if (HAL_IS_BIT_SET(RCC->CR,RCC_CR_PLLON))
436
+      {
437
+        pllmul = aPLLMULFactorTable[(uint32_t)(temp_reg & RCC_CFGR_PLLMULL) >> RCC_CFGR_PLLMULL_Pos];
438
+        if ((temp_reg & RCC_CFGR_PLLSRC) != RCC_PLLSOURCE_HSI_DIV2)
439
+        {
440
+#if defined(STM32F105xC) || defined(STM32F107xC) || defined(STM32F100xB)\
441
+ || defined(STM32F100xE)
442
+          prediv1 = aPredivFactorTable[(uint32_t)(RCC->CFGR2 & RCC_CFGR2_PREDIV1) >> RCC_CFGR2_PREDIV1_Pos];
443
+#else
444
+          prediv1 = aPredivFactorTable[(uint32_t)(RCC->CFGR & RCC_CFGR_PLLXTPRE) >> RCC_CFGR_PLLXTPRE_Pos];
445
+#endif /* STM32F105xC || STM32F107xC || STM32F100xB || STM32F100xE */
446
+
447
+#if defined(STM32F105xC) || defined(STM32F107xC)
448
+          if(HAL_IS_BIT_SET(RCC->CFGR2, RCC_CFGR2_PREDIV1SRC))
449
+          {
450
+            /* PLL2 selected as Prediv1 source */
451
+            /* PLLCLK = PLL2CLK / PREDIV1 * PLLMUL with PLL2CLK = HSE/PREDIV2 * PLL2MUL */
452
+            prediv2 = ((RCC->CFGR2 & RCC_CFGR2_PREDIV2) >> RCC_CFGR2_PREDIV2_Pos) + 1;
453
+            pll2mul = ((RCC->CFGR2 & RCC_CFGR2_PLL2MUL) >> RCC_CFGR2_PLL2MUL_Pos) + 2;
454
+            pllclk = (uint32_t)((((HSE_VALUE / prediv2) * pll2mul) / prediv1) * pllmul);
455
+          }
456
+          else
457
+          {
458
+            /* HSE used as PLL clock source : PLLCLK = HSE/PREDIV1 * PLLMUL */
459
+            pllclk = (uint32_t)((HSE_VALUE / prediv1) * pllmul);
460
+          }
461
+          
462
+          /* If PLLMUL was set to 13 means that it was to cover the case PLLMUL 6.5 (avoid using float) */
463
+          /* In this case need to divide pllclk by 2 */
464
+          if (pllmul == aPLLMULFactorTable[(uint32_t)(RCC_CFGR_PLLMULL6_5) >> RCC_CFGR_PLLMULL_Pos])
465
+          {
466
+              pllclk = pllclk / 2;
467
+          }
468
+#else
469
+          if ((temp_reg & RCC_CFGR_PLLSRC) != RCC_PLLSOURCE_HSI_DIV2)
470
+          {
471
+            /* HSE used as PLL clock source : PLLCLK = HSE/PREDIV1 * PLLMUL */
472
+            pllclk = (uint32_t)((HSE_VALUE / prediv1) * pllmul);
473
+          }
474
+#endif /* STM32F105xC || STM32F107xC */
475
+        }
476
+        else
477
+        {
478
+          /* HSI used as PLL clock source : PLLCLK = HSI/2 * PLLMUL */
479
+          pllclk = (uint32_t)((HSI_VALUE >> 1) * pllmul);
480
+        }
481
+
482
+        /* Calcul of the USB frequency*/
483
+#if defined(STM32F105xC) || defined(STM32F107xC)
484
+        /* USBCLK = PLLVCO = (2 x PLLCLK) / USB prescaler */
485
+        if (__HAL_RCC_GET_USB_SOURCE() == RCC_USBCLKSOURCE_PLL_DIV2)
486
+        {
487
+          /* Prescaler of 2 selected for USB */ 
488
+          frequency = pllclk;
489
+        }
490
+        else
491
+        {
492
+          /* Prescaler of 3 selected for USB */ 
493
+          frequency = (2 * pllclk) / 3;
494
+        }
495
+#else
496
+        /* USBCLK = PLLCLK / USB prescaler */
497
+        if (__HAL_RCC_GET_USB_SOURCE() == RCC_USBCLKSOURCE_PLL)
498
+        {
499
+          /* No prescaler selected for USB */
500
+          frequency = pllclk;
501
+        }
502
+        else
503
+        {
504
+          /* Prescaler of 1.5 selected for USB */ 
505
+          frequency = (pllclk * 2) / 3;
506
+        }
507
+#endif
508
+      }
509
+      break;
510
+    }
511
+#endif /* STM32F102x6 || STM32F102xB || STM32F103x6 || STM32F103xB || STM32F103xE || STM32F103xG || STM32F105xC || STM32F107xC */
512
+#if defined(STM32F103xE) || defined(STM32F103xG) || defined(STM32F105xC) || defined(STM32F107xC)
513
+  case RCC_PERIPHCLK_I2S2:  
514
+    {
515
+#if defined(STM32F103xE) || defined(STM32F103xG)
516
+      /* SYSCLK used as source clock for I2S2 */
517
+      frequency = HAL_RCC_GetSysClockFreq();
518
+#else
519
+      if (__HAL_RCC_GET_I2S2_SOURCE() == RCC_I2S2CLKSOURCE_SYSCLK)
520
+      {
521
+        /* SYSCLK used as source clock for I2S2 */
522
+        frequency = HAL_RCC_GetSysClockFreq();
523
+      }
524
+      else
525
+      {
526
+         /* Check if PLLI2S is enabled */
527
+        if (HAL_IS_BIT_SET(RCC->CR, RCC_CR_PLL3ON))
528
+        {
529
+          /* PLLI2SVCO = 2 * PLLI2SCLK = 2 * (HSE/PREDIV2 * PLL3MUL) */
530
+          prediv2 = ((RCC->CFGR2 & RCC_CFGR2_PREDIV2) >> RCC_CFGR2_PREDIV2_Pos) + 1;
531
+          pll3mul = ((RCC->CFGR2 & RCC_CFGR2_PLL3MUL) >> RCC_CFGR2_PLL3MUL_Pos) + 2;
532
+          frequency = (uint32_t)(2 * ((HSE_VALUE / prediv2) * pll3mul));
533
+        }
534
+      }
535
+#endif /* STM32F103xE || STM32F103xG */
536
+      break;
537
+    }
538
+  case RCC_PERIPHCLK_I2S3:
539
+    {
540
+#if defined(STM32F103xE) || defined(STM32F103xG)
541
+      /* SYSCLK used as source clock for I2S3 */
542
+      frequency = HAL_RCC_GetSysClockFreq();
543
+#else
544
+      if (__HAL_RCC_GET_I2S3_SOURCE() == RCC_I2S3CLKSOURCE_SYSCLK)
545
+      {
546
+        /* SYSCLK used as source clock for I2S3 */
547
+        frequency = HAL_RCC_GetSysClockFreq();
548
+      }
549
+      else
550
+      {
551
+         /* Check if PLLI2S is enabled */
552
+        if (HAL_IS_BIT_SET(RCC->CR, RCC_CR_PLL3ON))
553
+        {
554
+          /* PLLI2SVCO = 2 * PLLI2SCLK = 2 * (HSE/PREDIV2 * PLL3MUL) */
555
+          prediv2 = ((RCC->CFGR2 & RCC_CFGR2_PREDIV2) >> RCC_CFGR2_PREDIV2_Pos) + 1;
556
+          pll3mul = ((RCC->CFGR2 & RCC_CFGR2_PLL3MUL) >> RCC_CFGR2_PLL3MUL_Pos) + 2;
557
+          frequency = (uint32_t)(2 * ((HSE_VALUE / prediv2) * pll3mul));
558
+        }
559
+      }
560
+#endif /* STM32F103xE || STM32F103xG */
561
+      break;
562
+    }
563
+#endif /* STM32F103xE || STM32F103xG || STM32F105xC || STM32F107xC */
564
+  case RCC_PERIPHCLK_RTC:  
565
+    {
566
+      /* Get RCC BDCR configuration ------------------------------------------------------*/
567
+      temp_reg = RCC->BDCR;
568
+
569
+      /* Check if LSE is ready if RTC clock selection is LSE */
570
+      if (((temp_reg & RCC_BDCR_RTCSEL) == RCC_RTCCLKSOURCE_LSE) && (HAL_IS_BIT_SET(temp_reg, RCC_BDCR_LSERDY)))
571
+      {
572
+        frequency = LSE_VALUE;
573
+      }
574
+      /* Check if LSI is ready if RTC clock selection is LSI */
575
+      else if (((temp_reg & RCC_BDCR_RTCSEL) == RCC_RTCCLKSOURCE_LSI) && (HAL_IS_BIT_SET(RCC->CSR, RCC_CSR_LSIRDY)))
576
+      {
577
+        frequency = LSI_VALUE;
578
+      }
579
+      else if (((temp_reg & RCC_BDCR_RTCSEL) == RCC_RTCCLKSOURCE_HSE_DIV128) && (HAL_IS_BIT_SET(RCC->CR, RCC_CR_HSERDY)))
580
+      {
581
+        frequency = HSE_VALUE / 128U;
582
+      }
583
+      /* Clock not enabled for RTC*/
584
+      else
585
+      {
586
+        frequency = 0U;
587
+      }
588
+      break;
589
+    }
590
+  case RCC_PERIPHCLK_ADC:  
591
+    {
592
+      frequency = HAL_RCC_GetPCLK2Freq() / (((__HAL_RCC_GET_ADC_SOURCE() >> RCC_CFGR_ADCPRE_Pos) + 1) * 2);
593
+      break;
594
+    }
595
+  default: 
596
+    {
597
+      break;
598
+    }
599
+  }
600
+  return(frequency);
601
+}
602
+
603
+/**
604
+  * @}
605
+  */
606
+
607
+#if defined(STM32F105xC) || defined(STM32F107xC)
608
+/** @defgroup RCCEx_Exported_Functions_Group2 PLLI2S Management function
609
+  *  @brief  PLLI2S Management functions
610
+  *
611
+@verbatim   
612
+ ===============================================================================
613
+                ##### Extended PLLI2S Management functions  #####
614
+ ===============================================================================  
615
+    [..]
616
+    This subsection provides a set of functions allowing to control the PLLI2S
617
+    activation or deactivation
618
+@endverbatim
619
+  * @{
620
+  */
621
+
622
+/**
623
+  * @brief  Enable PLLI2S
624
+  * @param  PLLI2SInit pointer to an RCC_PLLI2SInitTypeDef structure that
625
+  *         contains the configuration information for the PLLI2S
626
+  * @note   The PLLI2S configuration not modified if used by I2S2 or I2S3 Interface.
627
+  * @retval HAL status
628
+  */
629
+HAL_StatusTypeDef HAL_RCCEx_EnablePLLI2S(RCC_PLLI2SInitTypeDef  *PLLI2SInit)
630
+{
631
+  uint32_t tickstart = 0U;
632
+
633
+  /* Check that PLL I2S has not been already enabled by I2S2 or I2S3*/
634
+  if (HAL_IS_BIT_CLR(RCC->CFGR2, RCC_CFGR2_I2S2SRC) && HAL_IS_BIT_CLR(RCC->CFGR2, RCC_CFGR2_I2S3SRC))
635
+  {
636
+    /* Check the parameters */
637
+    assert_param(IS_RCC_PLLI2S_MUL(PLLI2SInit->PLLI2SMUL));
638
+    assert_param(IS_RCC_HSE_PREDIV2(PLLI2SInit->HSEPrediv2Value));
639
+
640
+    /* Prediv2 can be written only when the PLL2 is disabled. */
641
+    /* Return an error only if new value is different from the programmed value */
642
+    if (HAL_IS_BIT_SET(RCC->CR,RCC_CR_PLL2ON) && \
643
+      (__HAL_RCC_HSE_GET_PREDIV2() != PLLI2SInit->HSEPrediv2Value))
644
+    {
645
+      return HAL_ERROR;
646
+    }
647
+
648
+    /* Disable the main PLLI2S. */
649
+    __HAL_RCC_PLLI2S_DISABLE();
650
+
651
+    /* Get Start Tick*/
652
+    tickstart = HAL_GetTick();
653
+    
654
+    /* Wait till PLLI2S is ready */  
655
+    while(__HAL_RCC_GET_FLAG(RCC_FLAG_PLLI2SRDY)  != RESET)
656
+    {
657
+      if((HAL_GetTick() - tickstart ) > PLLI2S_TIMEOUT_VALUE)
658
+      {
659
+        return HAL_TIMEOUT;
660
+      }
661
+    }
662
+
663
+    /* Configure the HSE prediv2 factor --------------------------------*/
664
+    __HAL_RCC_HSE_PREDIV2_CONFIG(PLLI2SInit->HSEPrediv2Value);
665
+    
666
+
667
+    /* Configure the main PLLI2S multiplication factors. */
668
+    __HAL_RCC_PLLI2S_CONFIG(PLLI2SInit->PLLI2SMUL);
669
+    
670
+    /* Enable the main PLLI2S. */
671
+    __HAL_RCC_PLLI2S_ENABLE();
672
+    
673
+    /* Get Start Tick*/
674
+    tickstart = HAL_GetTick();
675
+    
676
+    /* Wait till PLLI2S is ready */
677
+    while(__HAL_RCC_GET_FLAG(RCC_FLAG_PLLI2SRDY)  == RESET)
678
+    {
679
+      if((HAL_GetTick() - tickstart ) > PLLI2S_TIMEOUT_VALUE)
680
+      {
681
+        return HAL_TIMEOUT;
682
+      }
683
+    }
684
+  }
685
+  else
686
+  {
687
+    /* PLLI2S cannot be modified as already used by I2S2 or I2S3 */
688
+    return HAL_ERROR;
689
+  }
690
+
691
+  return HAL_OK;
692
+}
693
+
694
+/**
695
+  * @brief  Disable PLLI2S
696
+  * @note   PLLI2S is not disabled if used by I2S2 or I2S3 Interface.
697
+  * @retval HAL status
698
+  */
699
+HAL_StatusTypeDef HAL_RCCEx_DisablePLLI2S(void)
700
+{
701
+  uint32_t tickstart = 0U;
702
+
703
+  /* Disable PLL I2S as not requested by I2S2 or I2S3*/
704
+  if (HAL_IS_BIT_CLR(RCC->CFGR2, RCC_CFGR2_I2S2SRC) && HAL_IS_BIT_CLR(RCC->CFGR2, RCC_CFGR2_I2S3SRC))
705
+  {
706
+    /* Disable the main PLLI2S. */
707
+    __HAL_RCC_PLLI2S_DISABLE();
708
+
709
+    /* Get Start Tick*/
710
+    tickstart = HAL_GetTick();
711
+    
712
+    /* Wait till PLLI2S is ready */  
713
+    while(__HAL_RCC_GET_FLAG(RCC_FLAG_PLLI2SRDY)  != RESET)
714
+    {
715
+      if((HAL_GetTick() - tickstart ) > PLLI2S_TIMEOUT_VALUE)
716
+      {
717
+        return HAL_TIMEOUT;
718
+      }
719
+    }
720
+  }
721
+  else
722
+  {
723
+    /* PLLI2S is currently used by I2S2 or I2S3. Cannot be disabled.*/
724
+    return HAL_ERROR;
725
+  }
726
+  
727
+  return HAL_OK;
728
+}
729
+
730
+/**
731
+  * @}
732
+  */
733
+
734
+/** @defgroup RCCEx_Exported_Functions_Group3 PLL2 Management function
735
+  *  @brief  PLL2 Management functions
736
+  *
737
+@verbatim   
738
+ ===============================================================================
739
+                ##### Extended PLL2 Management functions  #####
740
+ ===============================================================================  
741
+    [..]
742
+    This subsection provides a set of functions allowing to control the PLL2
743
+    activation or deactivation
744
+@endverbatim
745
+  * @{
746
+  */
747
+
748
+/**
749
+  * @brief  Enable PLL2
750
+  * @param  PLL2Init pointer to an RCC_PLL2InitTypeDef structure that
751
+  *         contains the configuration information for the PLL2
752
+  * @note   The PLL2 configuration not modified if used indirectly as system clock.
753
+  * @retval HAL status
754
+  */
755
+HAL_StatusTypeDef HAL_RCCEx_EnablePLL2(RCC_PLL2InitTypeDef  *PLL2Init)
756
+{
757
+  uint32_t tickstart = 0U;
758
+
759
+  /* This bit can not be cleared if the PLL2 clock is used indirectly as system 
760
+    clock (i.e. it is used as PLL clock entry that is used as system clock). */
761
+  if((__HAL_RCC_GET_PLL_OSCSOURCE() == RCC_PLLSOURCE_HSE) && \
762
+        (__HAL_RCC_GET_SYSCLK_SOURCE() == RCC_SYSCLKSOURCE_STATUS_PLLCLK) && \
763
+        ((READ_BIT(RCC->CFGR2,RCC_CFGR2_PREDIV1SRC)) == RCC_CFGR2_PREDIV1SRC_PLL2))
764
+  {
765
+    return HAL_ERROR;
766
+  }
767
+  else
768
+  {
769
+    /* Check the parameters */
770
+    assert_param(IS_RCC_PLL2_MUL(PLL2Init->PLL2MUL));
771
+    assert_param(IS_RCC_HSE_PREDIV2(PLL2Init->HSEPrediv2Value));
772
+
773
+    /* Prediv2 can be written only when the PLLI2S is disabled. */
774
+    /* Return an error only if new value is different from the programmed value */
775
+    if (HAL_IS_BIT_SET(RCC->CR,RCC_CR_PLL3ON) && \
776
+      (__HAL_RCC_HSE_GET_PREDIV2() != PLL2Init->HSEPrediv2Value))
777
+    {
778
+      return HAL_ERROR;
779
+    }
780
+
781
+    /* Disable the main PLL2. */
782
+    __HAL_RCC_PLL2_DISABLE();
783
+    
784
+    /* Get Start Tick*/
785
+    tickstart = HAL_GetTick();
786
+    
787
+    /* Wait till PLL2 is disabled */
788
+    while(__HAL_RCC_GET_FLAG(RCC_FLAG_PLL2RDY) != RESET)
789
+    {
790
+      if((HAL_GetTick() - tickstart ) > PLL2_TIMEOUT_VALUE)
791
+      {
792
+        return HAL_TIMEOUT;
793
+      }
794
+    }
795
+    
796
+    /* Configure the HSE prediv2 factor --------------------------------*/
797
+    __HAL_RCC_HSE_PREDIV2_CONFIG(PLL2Init->HSEPrediv2Value);
798
+
799
+    /* Configure the main PLL2 multiplication factors. */
800
+    __HAL_RCC_PLL2_CONFIG(PLL2Init->PLL2MUL);
801
+    
802
+    /* Enable the main PLL2. */
803
+    __HAL_RCC_PLL2_ENABLE();
804
+    
805
+    /* Get Start Tick*/
806
+    tickstart = HAL_GetTick();
807
+    
808
+    /* Wait till PLL2 is ready */
809
+    while(__HAL_RCC_GET_FLAG(RCC_FLAG_PLL2RDY)  == RESET)
810
+    {
811
+      if((HAL_GetTick() - tickstart ) > PLL2_TIMEOUT_VALUE)
812
+      {
813
+        return HAL_TIMEOUT;
814
+      }
815
+    }
816
+  }
817
+
818
+  return HAL_OK;
819
+}
820
+
821
+/**
822
+  * @brief  Disable PLL2
823
+  * @note   PLL2 is not disabled if used indirectly as system clock.
824
+  * @retval HAL status
825
+  */
826
+HAL_StatusTypeDef HAL_RCCEx_DisablePLL2(void)
827
+{
828
+  uint32_t tickstart = 0U;
829
+
830
+  /* This bit can not be cleared if the PLL2 clock is used indirectly as system 
831
+    clock (i.e. it is used as PLL clock entry that is used as system clock). */
832
+  if((__HAL_RCC_GET_PLL_OSCSOURCE() == RCC_PLLSOURCE_HSE) && \
833
+        (__HAL_RCC_GET_SYSCLK_SOURCE() == RCC_SYSCLKSOURCE_STATUS_PLLCLK) && \
834
+        ((READ_BIT(RCC->CFGR2,RCC_CFGR2_PREDIV1SRC)) == RCC_CFGR2_PREDIV1SRC_PLL2))
835
+  {
836
+    return HAL_ERROR;
837
+  }
838
+  else
839
+  {
840
+    /* Disable the main PLL2. */
841
+    __HAL_RCC_PLL2_DISABLE();
842
+
843
+    /* Get Start Tick*/
844
+    tickstart = HAL_GetTick();
845
+    
846
+    /* Wait till PLL2 is disabled */  
847
+    while(__HAL_RCC_GET_FLAG(RCC_FLAG_PLL2RDY)  != RESET)
848
+    {
849
+      if((HAL_GetTick() - tickstart ) > PLL2_TIMEOUT_VALUE)
850
+      {
851
+        return HAL_TIMEOUT;
852
+      }
853
+    }
854
+  }
855
+
856
+  return HAL_OK;
857
+}
858
+
859
+/**
860
+  * @}
861
+  */
862
+#endif /* STM32F105xC || STM32F107xC */
863
+
864
+/**
865
+  * @}
866
+  */
867
+
868
+/**
869
+  * @}
870
+  */
871
+
872
+#endif /* HAL_RCC_MODULE_ENABLED */
873
+
874
+/**
875
+  * @}
876
+  */
877
+
878
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
879
+

文件差异内容过多而无法显示
+ 5419 - 0
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c


文件差异内容过多而无法显示
+ 1773 - 0
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c


文件差异内容过多而无法显示
+ 2556 - 0
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c


+ 239 - 0
Inc/flash_if.h

@@ -0,0 +1,239 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    IAP_Main/Inc/flash_if.h 
4
+  * @author  MCD Application Team
5
+  * @version 1.0.0
6
+  * @date    8-April-2015
7
+  * @brief   This file provides all the headers of the flash_if functions.
8
+  ******************************************************************************
9
+  * @attention
10
+  *
11
+  * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
12
+  *
13
+  * Redistribution and use in source and binary forms, with or without modification,
14
+  * are permitted provided that the following conditions are met:
15
+  *   1. Redistributions of source code must retain the above copyright notice,
16
+  *      this list of conditions and the following disclaimer.
17
+  *   2. Redistributions in binary form must reproduce the above copyright notice,
18
+  *      this list of conditions and the following disclaimer in the documentation
19
+  *      and/or other materials provided with the distribution.
20
+  *   3. Neither the name of STMicroelectronics nor the names of its contributors
21
+  *      may be used to endorse or promote products derived from this software
22
+  *      without specific prior written permission.
23
+  *
24
+  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25
+  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27
+  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
28
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30
+  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31
+  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32
+  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
+  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+  *
35
+  ******************************************************************************
36
+  */
37
+
38
+/* Define to prevent recursive inclusion -------------------------------------*/
39
+#ifndef __FLASH_IF_H
40
+#define __FLASH_IF_H
41
+
42
+/* Includes ------------------------------------------------------------------*/
43
+#include "stm32f1xx_hal.h"
44
+
45
+/* Exported types ------------------------------------------------------------*/
46
+/* Exported constants --------------------------------------------------------*/
47
+
48
+/* Base address of the Flash sectors */
49
+#define ADDR_FLASH_PAGE_0     ((uint32_t)0x08000000) /* Base @ of Page 0, 2 Kbytes */
50
+#define ADDR_FLASH_PAGE_1     ((uint32_t)0x08000800) /* Base @ of Page 1, 2 Kbytes */
51
+#define ADDR_FLASH_PAGE_2     ((uint32_t)0x08001000) /* Base @ of Page 2, 2 Kbytes */
52
+#define ADDR_FLASH_PAGE_3     ((uint32_t)0x08001800) /* Base @ of Page 3, 2 Kbytes */
53
+#define ADDR_FLASH_PAGE_4     ((uint32_t)0x08002000) /* Base @ of Page 4, 2 Kbytes */
54
+#define ADDR_FLASH_PAGE_5     ((uint32_t)0x08002800) /* Base @ of Page 5, 2 Kbytes */
55
+#define ADDR_FLASH_PAGE_6     ((uint32_t)0x08003000) /* Base @ of Page 6, 2 Kbytes */
56
+#define ADDR_FLASH_PAGE_7     ((uint32_t)0x08003800) /* Base @ of Page 7, 2 Kbytes */
57
+#define ADDR_FLASH_PAGE_8     ((uint32_t)0x08004000) /* Base @ of Page 8, 2 Kbytes */
58
+#define ADDR_FLASH_PAGE_9     ((uint32_t)0x08004800) /* Base @ of Page 9, 2 Kbytes */
59
+#define ADDR_FLASH_PAGE_10    ((uint32_t)0x08005000) /* Base @ of Page 10, 2 Kbytes */
60
+#define ADDR_FLASH_PAGE_11    ((uint32_t)0x08005800) /* Base @ of Page 11, 2 Kbytes */
61
+#define ADDR_FLASH_PAGE_12    ((uint32_t)0x08006000) /* Base @ of Page 12, 2 Kbytes */
62
+#define ADDR_FLASH_PAGE_13    ((uint32_t)0x08006800) /* Base @ of Page 13, 2 Kbytes */
63
+#define ADDR_FLASH_PAGE_14    ((uint32_t)0x08007000) /* Base @ of Page 14, 2 Kbytes */
64
+#define ADDR_FLASH_PAGE_15    ((uint32_t)0x08007800) /* Base @ of Page 15, 2 Kbytes */
65
+#define ADDR_FLASH_PAGE_16    ((uint32_t)0x08008000) /* Base @ of Page 16, 2 Kbytes */
66
+#define ADDR_FLASH_PAGE_17    ((uint32_t)0x08008800) /* Base @ of Page 17, 2 Kbytes */
67
+#define ADDR_FLASH_PAGE_18    ((uint32_t)0x08009000) /* Base @ of Page 18, 2 Kbytes */
68
+#define ADDR_FLASH_PAGE_19    ((uint32_t)0x08009800) /* Base @ of Page 19, 2 Kbytes */
69
+#define ADDR_FLASH_PAGE_20    ((uint32_t)0x0800A000) /* Base @ of Page 20, 2 Kbytes */
70
+#define ADDR_FLASH_PAGE_21    ((uint32_t)0x0800A800) /* Base @ of Page 21, 2 Kbytes  */
71
+#define ADDR_FLASH_PAGE_22    ((uint32_t)0x0800B000) /* Base @ of Page 22, 2 Kbytes  */
72
+#define ADDR_FLASH_PAGE_23    ((uint32_t)0x0800B800) /* Base @ of Page 23, 2 Kbytes */
73
+#define ADDR_FLASH_PAGE_24    ((uint32_t)0x0800C000) /* Base @ of Page 24, 2 Kbytes */
74
+#define ADDR_FLASH_PAGE_25    ((uint32_t)0x0800C800) /* Base @ of Page 25, 2 Kbytes */
75
+#define ADDR_FLASH_PAGE_26    ((uint32_t)0x0800D000) /* Base @ of Page 26, 2 Kbytes */
76
+#define ADDR_FLASH_PAGE_27    ((uint32_t)0x0800D800) /* Base @ of Page 27, 2 Kbytes */
77
+#define ADDR_FLASH_PAGE_28    ((uint32_t)0x0800E000) /* Base @ of Page 28, 2 Kbytes */
78
+#define ADDR_FLASH_PAGE_29    ((uint32_t)0x0800E800) /* Base @ of Page 29, 2 Kbytes */
79
+#define ADDR_FLASH_PAGE_30    ((uint32_t)0x0800F000) /* Base @ of Page 30, 2 Kbytes */
80
+#define ADDR_FLASH_PAGE_31    ((uint32_t)0x0800F800) /* Base @ of Page 31, 2 Kbytes */
81
+#define ADDR_FLASH_PAGE_32    ((uint32_t)0x08010000) /* Base @ of Page 32, 2 Kbytes */
82
+#define ADDR_FLASH_PAGE_33    ((uint32_t)0x08010800) /* Base @ of Page 33, 2 Kbytes */
83
+#define ADDR_FLASH_PAGE_34    ((uint32_t)0x08011000) /* Base @ of Page 34, 2 Kbytes */
84
+#define ADDR_FLASH_PAGE_35    ((uint32_t)0x08011800) /* Base @ of Page 35, 2 Kbytes */
85
+#define ADDR_FLASH_PAGE_36    ((uint32_t)0x08012000) /* Base @ of Page 36, 2 Kbytes */
86
+#define ADDR_FLASH_PAGE_37    ((uint32_t)0x08012800) /* Base @ of Page 37, 2 Kbytes */
87
+#define ADDR_FLASH_PAGE_38    ((uint32_t)0x08013000) /* Base @ of Page 38, 2 Kbytes */
88
+#define ADDR_FLASH_PAGE_39    ((uint32_t)0x08013800) /* Base @ of Page 39, 2 Kbytes */
89
+#define ADDR_FLASH_PAGE_40    ((uint32_t)0x08014000) /* Base @ of Page 40, 2 Kbytes */
90
+#define ADDR_FLASH_PAGE_41    ((uint32_t)0x08014800) /* Base @ of Page 41, 2 Kbytes */
91
+#define ADDR_FLASH_PAGE_42    ((uint32_t)0x08015000) /* Base @ of Page 42, 2 Kbytes */
92
+#define ADDR_FLASH_PAGE_43    ((uint32_t)0x08015800) /* Base @ of Page 43, 2 Kbytes */
93
+#define ADDR_FLASH_PAGE_44    ((uint32_t)0x08016000) /* Base @ of Page 44, 2 Kbytes */
94
+#define ADDR_FLASH_PAGE_45    ((uint32_t)0x08016800) /* Base @ of Page 45, 2 Kbytes */
95
+#define ADDR_FLASH_PAGE_46    ((uint32_t)0x08017000) /* Base @ of Page 46, 2 Kbytes */
96
+#define ADDR_FLASH_PAGE_47    ((uint32_t)0x08017800) /* Base @ of Page 47, 2 Kbytes */
97
+#define ADDR_FLASH_PAGE_48    ((uint32_t)0x08018000) /* Base @ of Page 48, 2 Kbytes */
98
+#define ADDR_FLASH_PAGE_49    ((uint32_t)0x08018800) /* Base @ of Page 49, 2 Kbytes */
99
+#define ADDR_FLASH_PAGE_50    ((uint32_t)0x08019000) /* Base @ of Page 50, 2 Kbytes */
100
+#define ADDR_FLASH_PAGE_51    ((uint32_t)0x08019800) /* Base @ of Page 51, 2 Kbytes */
101
+#define ADDR_FLASH_PAGE_52    ((uint32_t)0x0801A000) /* Base @ of Page 52, 2 Kbytes */
102
+#define ADDR_FLASH_PAGE_53    ((uint32_t)0x0801A800) /* Base @ of Page 53, 2 Kbytes */
103
+#define ADDR_FLASH_PAGE_54    ((uint32_t)0x0801B000) /* Base @ of Page 54, 2 Kbytes */
104
+#define ADDR_FLASH_PAGE_55    ((uint32_t)0x0801B800) /* Base @ of Page 55, 2 Kbytes */
105
+#define ADDR_FLASH_PAGE_56    ((uint32_t)0x0801C000) /* Base @ of Page 56, 2 Kbytes */
106
+#define ADDR_FLASH_PAGE_57    ((uint32_t)0x0801C800) /* Base @ of Page 57, 2 Kbytes */
107
+#define ADDR_FLASH_PAGE_58    ((uint32_t)0x0801D000) /* Base @ of Page 58, 2 Kbytes */
108
+#define ADDR_FLASH_PAGE_59    ((uint32_t)0x0801D800) /* Base @ of Page 59, 2 Kbytes */
109
+#define ADDR_FLASH_PAGE_60    ((uint32_t)0x0801E000) /* Base @ of Page 60, 2 Kbytes */
110
+#define ADDR_FLASH_PAGE_61    ((uint32_t)0x0801E800) /* Base @ of Page 61, 2 Kbytes */
111
+#define ADDR_FLASH_PAGE_62    ((uint32_t)0x0801F000) /* Base @ of Page 62, 2 Kbytes */
112
+#define ADDR_FLASH_PAGE_63    ((uint32_t)0x0801F800) /* Base @ of Page 63, 2 Kbytes */
113
+#define ADDR_FLASH_PAGE_64    ((uint32_t)0x08020000) /* Base @ of Page 64, 2 Kbytes */
114
+#define ADDR_FLASH_PAGE_65    ((uint32_t)0x08020800) /* Base @ of Page 65, 2 Kbytes */
115
+#define ADDR_FLASH_PAGE_66    ((uint32_t)0x08021000) /* Base @ of Page 66, 2 Kbytes */
116
+#define ADDR_FLASH_PAGE_67    ((uint32_t)0x08021800) /* Base @ of Page 67, 2 Kbytes */
117
+#define ADDR_FLASH_PAGE_68    ((uint32_t)0x08022000) /* Base @ of Page 68, 2 Kbytes */
118
+#define ADDR_FLASH_PAGE_69    ((uint32_t)0x08022800) /* Base @ of Page 69, 2 Kbytes */
119
+#define ADDR_FLASH_PAGE_70    ((uint32_t)0x08023000) /* Base @ of Page 70, 2 Kbytes */
120
+#define ADDR_FLASH_PAGE_71    ((uint32_t)0x08023800) /* Base @ of Page 71, 2 Kbytes */
121
+#define ADDR_FLASH_PAGE_72    ((uint32_t)0x08024000) /* Base @ of Page 72, 2 Kbytes */
122
+#define ADDR_FLASH_PAGE_73    ((uint32_t)0x08024800) /* Base @ of Page 73, 2 Kbytes */
123
+#define ADDR_FLASH_PAGE_74    ((uint32_t)0x08025000) /* Base @ of Page 74, 2 Kbytes */
124
+#define ADDR_FLASH_PAGE_75    ((uint32_t)0x08025800) /* Base @ of Page 75, 2 Kbytes */
125
+#define ADDR_FLASH_PAGE_76    ((uint32_t)0x08026000) /* Base @ of Page 76, 2 Kbytes */
126
+#define ADDR_FLASH_PAGE_77    ((uint32_t)0x08026800) /* Base @ of Page 77, 2 Kbytes */
127
+#define ADDR_FLASH_PAGE_78    ((uint32_t)0x08027000) /* Base @ of Page 78, 2 Kbytes */
128
+#define ADDR_FLASH_PAGE_79    ((uint32_t)0x08027800) /* Base @ of Page 79, 2 Kbytes */
129
+#define ADDR_FLASH_PAGE_80    ((uint32_t)0x08028000) /* Base @ of Page 80, 2 Kbytes */
130
+#define ADDR_FLASH_PAGE_81    ((uint32_t)0x08028800) /* Base @ of Page 81, 2 Kbytes */
131
+#define ADDR_FLASH_PAGE_82    ((uint32_t)0x08029000) /* Base @ of Page 82, 2 Kbytes */
132
+#define ADDR_FLASH_PAGE_83    ((uint32_t)0x08029800) /* Base @ of Page 83, 2 Kbytes */
133
+#define ADDR_FLASH_PAGE_84    ((uint32_t)0x0802A000) /* Base @ of Page 84, 2 Kbytes */
134
+#define ADDR_FLASH_PAGE_85    ((uint32_t)0x0802A800) /* Base @ of Page 85, 2 Kbytes */
135
+#define ADDR_FLASH_PAGE_86    ((uint32_t)0x0802B000) /* Base @ of Page 86, 2 Kbytes */
136
+#define ADDR_FLASH_PAGE_87    ((uint32_t)0x0802B800) /* Base @ of Page 87, 2 Kbytes */
137
+#define ADDR_FLASH_PAGE_88    ((uint32_t)0x0802C000) /* Base @ of Page 88, 2 Kbytes */
138
+#define ADDR_FLASH_PAGE_89    ((uint32_t)0x0802C800) /* Base @ of Page 89, 2 Kbytes */
139
+#define ADDR_FLASH_PAGE_90    ((uint32_t)0x0802D000) /* Base @ of Page 90, 2 Kbytes */
140
+#define ADDR_FLASH_PAGE_91    ((uint32_t)0x0802D800) /* Base @ of Page 91, 2 Kbytes */
141
+#define ADDR_FLASH_PAGE_92    ((uint32_t)0x0802E000) /* Base @ of Page 92, 2 Kbytes */
142
+#define ADDR_FLASH_PAGE_93    ((uint32_t)0x0802E800) /* Base @ of Page 93, 2 Kbytes */
143
+#define ADDR_FLASH_PAGE_94    ((uint32_t)0x0802F000) /* Base @ of Page 94, 2 Kbytes */
144
+#define ADDR_FLASH_PAGE_95    ((uint32_t)0x0802F800) /* Base @ of Page 95, 2 Kbytes */
145
+#define ADDR_FLASH_PAGE_96    ((uint32_t)0x08030000) /* Base @ of Page 96, 2 Kbytes */
146
+#define ADDR_FLASH_PAGE_97    ((uint32_t)0x08030800) /* Base @ of Page 97, 2 Kbytes */
147
+#define ADDR_FLASH_PAGE_98    ((uint32_t)0x08031000) /* Base @ of Page 98, 2 Kbytes */
148
+#define ADDR_FLASH_PAGE_99    ((uint32_t)0x08031800) /* Base @ of Page 99, 2 Kbytes */
149
+#define ADDR_FLASH_PAGE_100   ((uint32_t)0x08032000) /* Base @ of Page 100, 2 Kbytes */
150
+#define ADDR_FLASH_PAGE_101   ((uint32_t)0x08032800) /* Base @ of Page 101, 2 Kbytes */
151
+#define ADDR_FLASH_PAGE_102   ((uint32_t)0x08033000) /* Base @ of Page 102, 2 Kbytes */
152
+#define ADDR_FLASH_PAGE_103   ((uint32_t)0x08033800) /* Base @ of Page 103, 2 Kbytes */
153
+#define ADDR_FLASH_PAGE_104   ((uint32_t)0x08034000) /* Base @ of Page 104, 2 Kbytes */
154
+#define ADDR_FLASH_PAGE_105   ((uint32_t)0x08034800) /* Base @ of Page 105, 2 Kbytes */
155
+#define ADDR_FLASH_PAGE_106   ((uint32_t)0x08035000) /* Base @ of Page 106, 2 Kbytes */
156
+#define ADDR_FLASH_PAGE_107   ((uint32_t)0x08035800) /* Base @ of Page 107, 2 Kbytes */
157
+#define ADDR_FLASH_PAGE_108   ((uint32_t)0x08036000) /* Base @ of Page 108, 2 Kbytes */
158
+#define ADDR_FLASH_PAGE_109   ((uint32_t)0x08036800) /* Base @ of Page 109, 2 Kbytes */
159
+#define ADDR_FLASH_PAGE_110   ((uint32_t)0x08037000) /* Base @ of Page 110, 2 Kbytes */
160
+#define ADDR_FLASH_PAGE_111   ((uint32_t)0x08037800) /* Base @ of Page 111, 2 Kbytes */
161
+#define ADDR_FLASH_PAGE_112   ((uint32_t)0x08038000) /* Base @ of Page 112, 2 Kbytes */
162
+#define ADDR_FLASH_PAGE_113   ((uint32_t)0x08038800) /* Base @ of Page 113, 2 Kbytes */
163
+#define ADDR_FLASH_PAGE_114   ((uint32_t)0x08039000) /* Base @ of Page 114, 2 Kbytes */
164
+#define ADDR_FLASH_PAGE_115   ((uint32_t)0x08039800) /* Base @ of Page 115, 2 Kbytes */
165
+#define ADDR_FLASH_PAGE_116   ((uint32_t)0x0803A000) /* Base @ of Page 116, 2 Kbytes */
166
+#define ADDR_FLASH_PAGE_117   ((uint32_t)0x0803A800) /* Base @ of Page 117, 2 Kbytes  */
167
+#define ADDR_FLASH_PAGE_118   ((uint32_t)0x0803B000) /* Base @ of Page 118, 2 Kbytes  */
168
+#define ADDR_FLASH_PAGE_119   ((uint32_t)0x0803B800) /* Base @ of Page 119, 2 Kbytes */
169
+#define ADDR_FLASH_PAGE_120   ((uint32_t)0x0803C000) /* Base @ of Page 120, 2 Kbytes */
170
+#define ADDR_FLASH_PAGE_121   ((uint32_t)0x0803C800) /* Base @ of Page 121, 2 Kbytes */
171
+#define ADDR_FLASH_PAGE_122   ((uint32_t)0x0803D000) /* Base @ of Page 122, 2 Kbytes */
172
+#define ADDR_FLASH_PAGE_123   ((uint32_t)0x0803D800) /* Base @ of Page 123, 2 Kbytes */
173
+#define ADDR_FLASH_PAGE_124   ((uint32_t)0x0803E000) /* Base @ of Page 124, 2 Kbytes */
174
+#define ADDR_FLASH_PAGE_125   ((uint32_t)0x0803E800) /* Base @ of Page 125, 2 Kbytes */
175
+#define ADDR_FLASH_PAGE_126   ((uint32_t)0x0803F000) /* Base @ of Page 126, 2 Kbytes */
176
+#define ADDR_FLASH_PAGE_127   ((uint32_t)0x0803F800) /* Base @ of Page 127, 2 Kbytes */
177
+
178
+/* Error code */
179
+enum 
180
+{
181
+  FLASHIF_OK = 0,
182
+  FLASHIF_ERASEKO,
183
+  FLASHIF_WRITINGCTRL_ERROR,
184
+  FLASHIF_WRITING_ERROR,
185
+  FLASHIF_PROTECTION_ERRROR
186
+};
187
+
188
+/* protection type */  
189
+enum{
190
+  FLASHIF_PROTECTION_NONE         = 0,
191
+  FLASHIF_PROTECTION_PCROPENABLED = 0x1,
192
+  FLASHIF_PROTECTION_WRPENABLED   = 0x2,
193
+  FLASHIF_PROTECTION_RDPENABLED   = 0x4,
194
+};
195
+
196
+/* protection update */
197
+enum {
198
+	FLASHIF_WRP_ENABLE,
199
+	FLASHIF_WRP_DISABLE
200
+};
201
+
202
+/* Define the address from where user application will be loaded.
203
+   Note: this area is reserved for the IAP code                  */
204
+#define FLASH_PAGE_STEP         FLASH_PAGE_SIZE           /* Size of page : 2 Kbytes */
205
+#define APPLICATION_ADDRESS     (uint32_t)0x08004000      /* Start user code address: ADDR_FLASH_PAGE_8 */
206
+
207
+/* Notable Flash addresses */
208
+#define USER_FLASH_END_ADDRESS        0x08040000
209
+
210
+/* Define the user application size */
211
+#define USER_FLASH_SIZE               ((uint32_t)0x00003000) /* Small default template application */
212
+
213
+/* Define bitmap representing user flash area that could be write protected (check restricted to pages 8-39). */
214
+/*#define FLASH_PAGE_TO_BE_PROTECTED (OB_WRP_PAGES8TO9 | OB_WRP_PAGES10TO11 | OB_WRP_PAGES12TO13 | OB_WRP_PAGES14TO15 | \
215
+                                    OB_WRP_PAGES16TO17 | OB_WRP_PAGES18TO19 | OB_WRP_PAGES20TO21 | OB_WRP_PAGES22TO23 | \
216
+                                    OB_WRP_PAGES24TO25 | OB_WRP_PAGES26TO27 | OB_WRP_PAGES28TO29 | OB_WRP_PAGES30TO31 | \
217
+                                    OB_WRP_PAGES32TO33 | OB_WRP_PAGES34TO35 | OB_WRP_PAGES36TO37 | OB_WRP_PAGES38TO39  )  
218
+*/
219
+
220
+/* Exported macro ------------------------------------------------------------*/
221
+/* ABSoulute value */
222
+#define ABS_RETURN(x,y)               ((x) < (y)) ? ((y)-(x)) : ((x)-(y))
223
+
224
+/* Get the number of sectors from where the user program will be loaded */
225
+#define FLASH_SECTOR_NUMBER           ((uint32_t)(ABS_RETURN(APPLICATION_ADDRESS,FLASH_START_BANK1))>>12)
226
+
227
+/* Compute the mask to test if the Flash memory, where the user program will be
228
+  loaded, is write protected */
229
+#define FLASH_PROTECTED_SECTORS       (~(uint32_t)((1 << FLASH_SECTOR_NUMBER) - 1))
230
+/* Exported functions ------------------------------------------------------- */
231
+void FLASH_If_Init(void);
232
+uint32_t FLASH_If_Erase(uint32_t StartSector);
233
+uint32_t FLASH_If_GetWriteProtectionStatus(void);
234
+uint32_t FLASH_If_Write(uint32_t destination, uint32_t *p_source, uint32_t length);
235
+uint32_t FLASH_If_WriteProtectionConfig(uint32_t modifier);
236
+
237
+#endif  /* __FLASH_IF_H */
238
+
239
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 0 - 0
Inc/main.h


部分文件因为文件数量过多而无法显示