Compare commits
37 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c9b90a679e | |||
| ee3249beca | |||
| cc32a3092a | |||
| e65c4d612c | |||
| 7940c95b23 | |||
| 5bbbc9fe44 | |||
| 4c9c1ff2c8 | |||
| 0eb025d3d4 | |||
| 87eb642adc | |||
| 5c9846fce3 | |||
| 063ed8bb51 | |||
| 3ccc0ca0f3 | |||
| 9370ddbadd | |||
| ac75969758 | |||
| c74299dc0d | |||
| 8d41a30bff | |||
| 8b5bbd3e9a | |||
| 107a454051 | |||
| 01d4b75921 | |||
| 8878d1fd10 | |||
| 3300c5eebd | |||
| 0f1d8b71d7 | |||
| 117ba3202c | |||
| 207f9c9ddf | |||
| 8112ed27e8 | |||
| 13db07642e | |||
| 9a40b5a6fb | |||
| c6f2048d22 | |||
| 5f23a03009 | |||
| 5785093138 | |||
| 77f8faba9e | |||
| 1eb0c2c318 | |||
| 0b8a55a9e2 | |||
| 82a3907d8a | |||
| a2c5b2fe87 | |||
| 7e4820d8ac | |||
| a5269aae36 |
@@ -24,7 +24,7 @@
|
|||||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.755606893" name="Floating-point ABI" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi" useByScannerDiscovery="true" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.value.hard" valueType="enumerated"/>
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.755606893" name="Floating-point ABI" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi" useByScannerDiscovery="true" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.value.hard" valueType="enumerated"/>
|
||||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.1771260818" name="Board" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board" useByScannerDiscovery="false" value="genericBoard" valueType="string"/>
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.1771260818" name="Board" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board" useByScannerDiscovery="false" value="genericBoard" valueType="string"/>
|
||||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.1811760675" name="Defaults" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults" useByScannerDiscovery="false" value="com.st.stm32cube.ide.common.services.build.inputs.revA.1.0.6 || Debug || true || Executable || com.st.stm32cube.ide.mcu.gnu.managedbuild.option.toolchain.value.workspace || STM32F407VGTx || 0 || 0 || arm-none-eabi- || ${gnu_tools_for_stm32_compiler_path} || ../Core/Inc | ../Drivers/STM32F4xx_HAL_Driver/Inc | ../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy | ../Drivers/CMSIS/Device/ST/STM32F4xx/Include | ../Drivers/CMSIS/Include || || || USE_HAL_DRIVER | STM32F407xx || || Drivers | Core/Startup | Core || || || ${workspace_loc:/${ProjName}/STM32F407VGTX_FLASH.ld} || true || NonSecure || || secure_nsclib.o || || None || || || " valueType="string"/>
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.1811760675" name="Defaults" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults" useByScannerDiscovery="false" value="com.st.stm32cube.ide.common.services.build.inputs.revA.1.0.6 || Debug || true || Executable || com.st.stm32cube.ide.mcu.gnu.managedbuild.option.toolchain.value.workspace || STM32F407VGTx || 0 || 0 || arm-none-eabi- || ${gnu_tools_for_stm32_compiler_path} || ../Core/Inc | ../Drivers/STM32F4xx_HAL_Driver/Inc | ../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy | ../Drivers/CMSIS/Device/ST/STM32F4xx/Include | ../Drivers/CMSIS/Include || || || USE_HAL_DRIVER | STM32F407xx || || Drivers | Core/Startup | Core || || || ${workspace_loc:/${ProjName}/STM32F407VGTX_FLASH.ld} || true || NonSecure || || secure_nsclib.o || || None || || || " valueType="string"/>
|
||||||
<option id="com.st.stm32cube.ide.mcu.debug.option.cpuclock.2006503660" superClass="com.st.stm32cube.ide.mcu.debug.option.cpuclock" useByScannerDiscovery="false" value="16" valueType="string"/>
|
<option id="com.st.stm32cube.ide.mcu.debug.option.cpuclock.2006503660" name="Cpu clock frequence" superClass="com.st.stm32cube.ide.mcu.debug.option.cpuclock" useByScannerDiscovery="false" value="16" valueType="string"/>
|
||||||
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform.188797436" isAbstract="false" osList="all" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform"/>
|
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform.188797436" isAbstract="false" osList="all" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform"/>
|
||||||
<builder buildPath="${workspace_loc:/test1}/Debug" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder.901063855" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder"/>
|
<builder buildPath="${workspace_loc:/test1}/Debug" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder.901063855" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder"/>
|
||||||
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.1851291017" name="MCU/MPU GCC Assembler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler">
|
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.1851291017" name="MCU/MPU GCC Assembler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler">
|
||||||
@@ -97,28 +97,28 @@
|
|||||||
<configuration artifactExtension="elf" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" cleanCommand="rm -rf" description="" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.603779794" name="Release" parent="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release">
|
<configuration artifactExtension="elf" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" cleanCommand="rm -rf" description="" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.603779794" name="Release" parent="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release">
|
||||||
<folderInfo id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.603779794." name="/" resourcePath="">
|
<folderInfo id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.603779794." name="/" resourcePath="">
|
||||||
<toolChain id="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.release.846299435" name="MCU ARM GCC" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.release">
|
<toolChain id="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.release.846299435" name="MCU ARM GCC" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.release">
|
||||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu.1996532596" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu" useByScannerDiscovery="true" value="STM32F407VGTx" valueType="string"/>
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu.1996532596" name="MCU" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu" useByScannerDiscovery="true" value="STM32F407VGTx" valueType="string"/>
|
||||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_cpuid.1932354132" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_cpuid" useByScannerDiscovery="false" value="0" valueType="string"/>
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_cpuid.1932354132" name="CPU" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_cpuid" useByScannerDiscovery="false" value="0" valueType="string"/>
|
||||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid.783288720" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid" useByScannerDiscovery="false" value="0" valueType="string"/>
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid.783288720" name="Core" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid" useByScannerDiscovery="false" value="0" valueType="string"/>
|
||||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu.619251655" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu" useByScannerDiscovery="true" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu.value.fpv4-sp-d16" valueType="enumerated"/>
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu.619251655" name="Floating-point unit" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu" useByScannerDiscovery="true" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu.value.fpv4-sp-d16" valueType="enumerated"/>
|
||||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.1646548773" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi" useByScannerDiscovery="true" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.value.hard" valueType="enumerated"/>
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.1646548773" name="Floating-point ABI" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi" useByScannerDiscovery="true" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.value.hard" valueType="enumerated"/>
|
||||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.1901965124" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board" useByScannerDiscovery="false" value="genericBoard" valueType="string"/>
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.1901965124" name="Board" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board" useByScannerDiscovery="false" value="genericBoard" valueType="string"/>
|
||||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.859080388" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults" useByScannerDiscovery="false" value="com.st.stm32cube.ide.common.services.build.inputs.revA.1.0.6 || Release || false || Executable || com.st.stm32cube.ide.mcu.gnu.managedbuild.option.toolchain.value.workspace || STM32F407VGTx || 0 || 0 || arm-none-eabi- || ${gnu_tools_for_stm32_compiler_path} || ../Core/Inc | ../Drivers/STM32F4xx_HAL_Driver/Inc | ../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy | ../Drivers/CMSIS/Device/ST/STM32F4xx/Include | ../Drivers/CMSIS/Include || || || USE_HAL_DRIVER | STM32F407xx || || Drivers | Core/Startup | Core || || || ${workspace_loc:/${ProjName}/STM32F407VGTX_FLASH.ld} || true || NonSecure || || secure_nsclib.o || || None || || || " valueType="string"/>
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.859080388" name="Defaults" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults" useByScannerDiscovery="false" value="com.st.stm32cube.ide.common.services.build.inputs.revA.1.0.6 || Release || false || Executable || com.st.stm32cube.ide.mcu.gnu.managedbuild.option.toolchain.value.workspace || STM32F407VGTx || 0 || 0 || arm-none-eabi- || ${gnu_tools_for_stm32_compiler_path} || ../Core/Inc | ../Drivers/STM32F4xx_HAL_Driver/Inc | ../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy | ../Drivers/CMSIS/Device/ST/STM32F4xx/Include | ../Drivers/CMSIS/Include || || || USE_HAL_DRIVER | STM32F407xx || || Drivers | Core/Startup | Core || || || ${workspace_loc:/${ProjName}/STM32F407VGTX_FLASH.ld} || true || NonSecure || || secure_nsclib.o || || None || || || " valueType="string"/>
|
||||||
<option id="com.st.stm32cube.ide.mcu.debug.option.cpuclock.1202403298" superClass="com.st.stm32cube.ide.mcu.debug.option.cpuclock" useByScannerDiscovery="false" value="16" valueType="string"/>
|
<option id="com.st.stm32cube.ide.mcu.debug.option.cpuclock.1202403298" name="Cpu clock frequence" superClass="com.st.stm32cube.ide.mcu.debug.option.cpuclock" useByScannerDiscovery="false" value="16" valueType="string"/>
|
||||||
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform.584865598" isAbstract="false" osList="all" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform"/>
|
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform.584865598" isAbstract="false" osList="all" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform"/>
|
||||||
<builder buildPath="${workspace_loc:/test1}/Release" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder.1873374287" managedBuildOn="true" name="Gnu Make Builder.Release" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder"/>
|
<builder buildPath="${workspace_loc:/test1}/Release" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder.1873374287" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder"/>
|
||||||
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.1806292512" name="MCU/MPU GCC Assembler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler">
|
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.1806292512" name="MCU/MPU GCC Assembler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler">
|
||||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.623288838" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.value.g0" valueType="enumerated"/>
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.623288838" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.value.g0" valueType="enumerated"/>
|
||||||
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input.2013577938" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input"/>
|
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input.2013577938" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input"/>
|
||||||
</tool>
|
</tool>
|
||||||
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1063892447" name="MCU/MPU GCC Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler">
|
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1063892447" name="MCU/MPU GCC Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler">
|
||||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.318905510" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.value.g0" valueType="enumerated"/>
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.318905510" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.value.g0" valueType="enumerated"/>
|
||||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.187906977" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.value.os" valueType="enumerated"/>
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.187906977" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.value.os" valueType="enumerated"/>
|
||||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols.516585832" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols" useByScannerDiscovery="false" valueType="definedSymbols">
|
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols.516585832" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols" useByScannerDiscovery="false" valueType="definedSymbols">
|
||||||
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
|
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
|
||||||
<listOptionValue builtIn="false" value="STM32F407xx"/>
|
<listOptionValue builtIn="false" value="STM32F407xx"/>
|
||||||
</option>
|
</option>
|
||||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths.1500062626" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths" useByScannerDiscovery="false" valueType="includePath">
|
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths.1500062626" name="Include paths (-I)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths" useByScannerDiscovery="false" valueType="includePath">
|
||||||
<listOptionValue builtIn="false" value="../Core/Inc"/>
|
<listOptionValue builtIn="false" value="../Core/Inc"/>
|
||||||
<listOptionValue builtIn="false" value="../Drivers/STM32F4xx_HAL_Driver/Inc"/>
|
<listOptionValue builtIn="false" value="../Drivers/STM32F4xx_HAL_Driver/Inc"/>
|
||||||
<listOptionValue builtIn="false" value="../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy"/>
|
<listOptionValue builtIn="false" value="../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy"/>
|
||||||
@@ -128,11 +128,11 @@
|
|||||||
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.219678164" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c"/>
|
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.219678164" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c"/>
|
||||||
</tool>
|
</tool>
|
||||||
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.1427603543" name="MCU/MPU G++ Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler">
|
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.1427603543" name="MCU/MPU G++ Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler">
|
||||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.debuglevel.130697829" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.debuglevel" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.debuglevel.value.g0" valueType="enumerated"/>
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.debuglevel.130697829" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.debuglevel" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.debuglevel.value.g0" valueType="enumerated"/>
|
||||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.optimization.level.1547171342" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.optimization.level" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.optimization.level.value.os" valueType="enumerated"/>
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.optimization.level.1547171342" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.optimization.level" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.optimization.level.value.os" valueType="enumerated"/>
|
||||||
</tool>
|
</tool>
|
||||||
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.1754531090" name="MCU/MPU GCC Linker" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker">
|
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.1754531090" name="MCU/MPU GCC Linker" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker">
|
||||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.script.610449053" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.script" value="${workspace_loc:/${ProjName}/STM32F407VGTX_FLASH.ld}" valueType="string"/>
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.script.610449053" name="Linker Script (-T)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.script" value="${workspace_loc:/${ProjName}/STM32F407VGTX_FLASH.ld}" valueType="string"/>
|
||||||
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.input.1602204541" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.input">
|
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.input.1602204541" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.input">
|
||||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||||
@@ -150,7 +150,7 @@
|
|||||||
</toolChain>
|
</toolChain>
|
||||||
</folderInfo>
|
</folderInfo>
|
||||||
<sourceEntries>
|
<sourceEntries>
|
||||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Core"/>
|
<entry excluding="Src/mock_lcd.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Core"/>
|
||||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Drivers"/>
|
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Drivers"/>
|
||||||
</sourceEntries>
|
</sourceEntries>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
Debug/*
|
||||||
+2
-2
File diff suppressed because one or more lines are too long
@@ -0,0 +1,6 @@
|
|||||||
|
#ifndef __EEPROM_24AA02E48
|
||||||
|
#define __EEPROM_24AA02E48
|
||||||
|
|
||||||
|
int EEPROM_24AA02E48_run_test(void);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
#ifndef __CS43L22
|
||||||
|
#define __CS43L22
|
||||||
|
|
||||||
|
int CS43L22_run_test(void);
|
||||||
|
void CS43L22_cleanup(void);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
#ifndef __DNI
|
||||||
|
#define __DNI
|
||||||
|
|
||||||
|
extern ADC_HandleTypeDef hadc1;
|
||||||
|
|
||||||
|
int DNI_show_celsius(void);
|
||||||
|
int DNI_show_fahrenheit(void);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
#ifndef __LIS302DL
|
||||||
|
#define __LIS302DL
|
||||||
|
|
||||||
|
int LIS302DL_run_test(void);
|
||||||
|
int LIS302DL_run_test_dynamic(void);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
#ifndef __LSM9DS1
|
||||||
|
#define __LSM9DS1
|
||||||
|
|
||||||
|
int LSM9DS1_test_accel(void);
|
||||||
|
void LSM9DS1_cleanup_accel(void);
|
||||||
|
int LSM9DS1_test_magnet(void);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#ifndef __MP45DT02
|
||||||
|
#define __MP45DT02
|
||||||
|
|
||||||
|
int MP45DT02_run_test(void);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
#ifndef __PCA9685
|
||||||
|
#define __PCA9685
|
||||||
|
|
||||||
|
int PCA9685_run_test(void);
|
||||||
|
void PCA9685_cleanup(void);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#ifndef __SST25VF016B
|
||||||
|
#define __SST25VF016B
|
||||||
|
|
||||||
|
int SST25VF016B_run_test(void);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
#ifndef __GENERIC_MACROS
|
||||||
|
#define __GENERIC_MACROS
|
||||||
|
|
||||||
|
#define PANIC(status) \
|
||||||
|
do { \
|
||||||
|
GPIOD->ODR = status; \
|
||||||
|
while (1) {} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
#ifndef __LCD
|
||||||
|
#define __LCD
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#define DISPLAY_RS ((uint16_t) (0x1U << 7))
|
||||||
|
#define DISPLAY_RW ((uint16_t) (0x1U << 10))
|
||||||
|
#define DISPLAY_ENA ((uint16_t) (0x1U << 11))
|
||||||
|
|
||||||
|
#define DISPLAY_FRAMES_AVAILABLE 14
|
||||||
|
|
||||||
|
#define DISPLAY_POLL_UNTIL_READY do { while (display_read_status() & 0x80) {} } while (0)
|
||||||
|
|
||||||
|
#define DISPLAY_SET_INCREMENT do { display_write_instruction_byte(0x06); } while (0)
|
||||||
|
#define DISPLAY_SET_DECREMENT do { display_write_instruction_byte(0x04); } while (0)
|
||||||
|
|
||||||
|
#define DISPLAY_SET_CURSOR(line, position) do { display_write_instruction_byte(0x80 | (line << 6) | position); } while (0)
|
||||||
|
|
||||||
|
#define DISPLAY_CLEAR do { display_write_instruction_byte(0x01); } while (0)
|
||||||
|
|
||||||
|
struct Display_emu_state {
|
||||||
|
size_t cursor_offset:5;
|
||||||
|
size_t next:1;
|
||||||
|
};
|
||||||
|
|
||||||
|
void display_init(void);
|
||||||
|
void display_write_instruction_byte(uint8_t code);
|
||||||
|
void display_write_data_byte(uint8_t code);
|
||||||
|
void display_write_data_seq(char *codes);
|
||||||
|
void display_to_framebuffer(void);
|
||||||
|
void display_to_direct(void);
|
||||||
|
void display_load(uint32_t frame_no);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -32,6 +32,8 @@ extern "C" {
|
|||||||
/* Private includes ----------------------------------------------------------*/
|
/* Private includes ----------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN Includes */
|
/* USER CODE BEGIN Includes */
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
/* USER CODE END Includes */
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
/* Exported types ------------------------------------------------------------*/
|
/* Exported types ------------------------------------------------------------*/
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
#define HAL_MODULE_ENABLED
|
#define HAL_MODULE_ENABLED
|
||||||
|
|
||||||
/* #define HAL_CRYP_MODULE_ENABLED */
|
/* #define HAL_CRYP_MODULE_ENABLED */
|
||||||
/* #define HAL_ADC_MODULE_ENABLED */
|
#define HAL_ADC_MODULE_ENABLED
|
||||||
/* #define HAL_CAN_MODULE_ENABLED */
|
/* #define HAL_CAN_MODULE_ENABLED */
|
||||||
/* #define HAL_CRC_MODULE_ENABLED */
|
/* #define HAL_CRC_MODULE_ENABLED */
|
||||||
/* #define HAL_CAN_LEGACY_MODULE_ENABLED */
|
/* #define HAL_CAN_LEGACY_MODULE_ENABLED */
|
||||||
@@ -53,8 +53,8 @@
|
|||||||
/* #define HAL_SRAM_MODULE_ENABLED */
|
/* #define HAL_SRAM_MODULE_ENABLED */
|
||||||
/* #define HAL_SDRAM_MODULE_ENABLED */
|
/* #define HAL_SDRAM_MODULE_ENABLED */
|
||||||
/* #define HAL_HASH_MODULE_ENABLED */
|
/* #define HAL_HASH_MODULE_ENABLED */
|
||||||
/* #define HAL_I2C_MODULE_ENABLED */
|
#define HAL_I2C_MODULE_ENABLED
|
||||||
/* #define HAL_I2S_MODULE_ENABLED */
|
#define HAL_I2S_MODULE_ENABLED
|
||||||
/* #define HAL_IWDG_MODULE_ENABLED */
|
/* #define HAL_IWDG_MODULE_ENABLED */
|
||||||
/* #define HAL_LTDC_MODULE_ENABLED */
|
/* #define HAL_LTDC_MODULE_ENABLED */
|
||||||
/* #define HAL_RNG_MODULE_ENABLED */
|
/* #define HAL_RNG_MODULE_ENABLED */
|
||||||
@@ -62,8 +62,8 @@
|
|||||||
/* #define HAL_SAI_MODULE_ENABLED */
|
/* #define HAL_SAI_MODULE_ENABLED */
|
||||||
/* #define HAL_SD_MODULE_ENABLED */
|
/* #define HAL_SD_MODULE_ENABLED */
|
||||||
/* #define HAL_MMC_MODULE_ENABLED */
|
/* #define HAL_MMC_MODULE_ENABLED */
|
||||||
/* #define HAL_SPI_MODULE_ENABLED */
|
#define HAL_SPI_MODULE_ENABLED
|
||||||
/* #define HAL_TIM_MODULE_ENABLED */
|
#define HAL_TIM_MODULE_ENABLED
|
||||||
/* #define HAL_UART_MODULE_ENABLED */
|
/* #define HAL_UART_MODULE_ENABLED */
|
||||||
/* #define HAL_USART_MODULE_ENABLED */
|
/* #define HAL_USART_MODULE_ENABLED */
|
||||||
/* #define HAL_IRDA_MODULE_ENABLED */
|
/* #define HAL_IRDA_MODULE_ENABLED */
|
||||||
|
|||||||
@@ -55,9 +55,11 @@ void SVC_Handler(void);
|
|||||||
void DebugMon_Handler(void);
|
void DebugMon_Handler(void);
|
||||||
void PendSV_Handler(void);
|
void PendSV_Handler(void);
|
||||||
void SysTick_Handler(void);
|
void SysTick_Handler(void);
|
||||||
void EXTI0_IRQHandler(void);
|
|
||||||
/* USER CODE BEGIN EFP */
|
/* USER CODE BEGIN EFP */
|
||||||
|
|
||||||
|
void EXTI0_IRQHandler(void);
|
||||||
|
void EXTI9_5_IRQHandler(void);
|
||||||
|
|
||||||
/* USER CODE END EFP */
|
/* USER CODE END EFP */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@@ -0,0 +1,106 @@
|
|||||||
|
#include "main.h"
|
||||||
|
#include "lcd.h"
|
||||||
|
#include "24AA02E48.h"
|
||||||
|
|
||||||
|
extern I2C_HandleTypeDef hi2c1;
|
||||||
|
|
||||||
|
int EEPROM_24AA02E48_run_test(void)
|
||||||
|
{
|
||||||
|
DISPLAY_CLEAR;
|
||||||
|
display_write_data_seq("24AA02E48 EEPROM");
|
||||||
|
|
||||||
|
HAL_StatusTypeDef op_result;
|
||||||
|
size_t err_count = 0;
|
||||||
|
|
||||||
|
// write the Address Pointer register
|
||||||
|
uint8_t data_buffer[13];
|
||||||
|
data_buffer[12] = '\0';
|
||||||
|
data_buffer[0] = 0xF4;
|
||||||
|
|
||||||
|
for (size_t t = 0; t < 5; t++) {
|
||||||
|
op_result = HAL_I2C_Master_Transmit(&hi2c1, 0xA0, data_buffer, 1, 2000);
|
||||||
|
|
||||||
|
if (op_result) {
|
||||||
|
err_count++;
|
||||||
|
|
||||||
|
DISPLAY_CLEAR;
|
||||||
|
display_write_data_seq("24AA02E48 EEPROM");
|
||||||
|
|
||||||
|
DISPLAY_SET_CURSOR(1, 0);
|
||||||
|
display_write_data_seq("W ");
|
||||||
|
display_write_data_byte('1' + t);
|
||||||
|
display_write_data_seq("/5 ");
|
||||||
|
|
||||||
|
switch (op_result) {
|
||||||
|
case HAL_OK:
|
||||||
|
break;
|
||||||
|
case HAL_ERROR:
|
||||||
|
display_write_data_seq("ERROR");
|
||||||
|
break;
|
||||||
|
case HAL_BUSY:
|
||||||
|
display_write_data_seq("BUSY");
|
||||||
|
break;
|
||||||
|
case HAL_TIMEOUT:
|
||||||
|
display_write_data_seq("TIMEOUT");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
HAL_Delay(2000);
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t t = 0; t < 5; t++) {
|
||||||
|
op_result = HAL_I2C_Master_Receive(&hi2c1, 0xA1, data_buffer, 12, 2000);
|
||||||
|
|
||||||
|
if (op_result) {
|
||||||
|
err_count++;
|
||||||
|
|
||||||
|
DISPLAY_CLEAR;
|
||||||
|
display_write_data_seq("24AA02E48 EEPROM");
|
||||||
|
|
||||||
|
DISPLAY_SET_CURSOR(1, 0);
|
||||||
|
display_write_data_seq("R ");
|
||||||
|
display_write_data_byte('1' + t);
|
||||||
|
display_write_data_seq("/5 ");
|
||||||
|
|
||||||
|
switch (op_result) {
|
||||||
|
case HAL_OK:
|
||||||
|
break;
|
||||||
|
case HAL_ERROR:
|
||||||
|
display_write_data_seq("ERROR");
|
||||||
|
break;
|
||||||
|
case HAL_BUSY:
|
||||||
|
display_write_data_seq("BUSY");
|
||||||
|
break;
|
||||||
|
case HAL_TIMEOUT:
|
||||||
|
display_write_data_seq("TIMEOUT");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
HAL_Delay(2000);
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DISPLAY_CLEAR;
|
||||||
|
display_write_data_seq("24AA02E48 EEPROM");
|
||||||
|
|
||||||
|
if (err_count) {
|
||||||
|
DISPLAY_SET_CURSOR(1, 0);
|
||||||
|
display_write_data_byte('0' + err_count / 10 % 10);
|
||||||
|
display_write_data_byte('0' + err_count % 10);
|
||||||
|
display_write_data_seq("E ");
|
||||||
|
display_write_data_seq((char *) data_buffer);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
DISPLAY_SET_CURSOR(1, 1);
|
||||||
|
display_write_data_seq("OK ");
|
||||||
|
display_write_data_seq((char *) data_buffer);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
#include "main.h"
|
||||||
|
#include "lcd.h"
|
||||||
|
#include "CS43L22.h"
|
||||||
|
|
||||||
|
extern I2C_HandleTypeDef hi2c1;
|
||||||
|
|
||||||
|
int CS43L22_run_test(void)
|
||||||
|
{
|
||||||
|
DISPLAY_CLEAR;
|
||||||
|
display_write_data_seq("CS43L22 Audio");
|
||||||
|
|
||||||
|
HAL_StatusTypeDef op_result;
|
||||||
|
size_t err_count = 0;
|
||||||
|
|
||||||
|
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_4, GPIO_PIN_SET);
|
||||||
|
|
||||||
|
uint8_t data_buffer[2] = {0x0D, 0x01};
|
||||||
|
|
||||||
|
for (size_t t = 0; t < 5; t++) {
|
||||||
|
op_result = HAL_I2C_Master_Transmit(&hi2c1, 0x94, data_buffer, 2, 2000);
|
||||||
|
|
||||||
|
if (op_result) {
|
||||||
|
err_count++;
|
||||||
|
|
||||||
|
DISPLAY_CLEAR;
|
||||||
|
display_write_data_seq("CS43L22 Audio");
|
||||||
|
|
||||||
|
DISPLAY_SET_CURSOR(1, 0);
|
||||||
|
display_write_data_seq("W ");
|
||||||
|
display_write_data_byte('1' + t);
|
||||||
|
display_write_data_seq("/5 ");
|
||||||
|
|
||||||
|
switch (op_result) {
|
||||||
|
case HAL_OK:
|
||||||
|
break;
|
||||||
|
case HAL_ERROR:
|
||||||
|
display_write_data_seq("ERROR");
|
||||||
|
break;
|
||||||
|
case HAL_BUSY:
|
||||||
|
display_write_data_seq("BUSY");
|
||||||
|
break;
|
||||||
|
case HAL_TIMEOUT:
|
||||||
|
display_write_data_seq("TIMEOUT");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
HAL_Delay(2000);
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DISPLAY_CLEAR;
|
||||||
|
display_write_data_seq("CS43L22 Audio");
|
||||||
|
|
||||||
|
if (err_count) {
|
||||||
|
DISPLAY_SET_CURSOR(1, 1);
|
||||||
|
display_write_data_byte('0' + err_count % 10);
|
||||||
|
display_write_data_seq(" Errors");
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
DISPLAY_SET_CURSOR(1, 1);
|
||||||
|
display_write_data_seq("OK");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CS43L22_cleanup(void)
|
||||||
|
{
|
||||||
|
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_4, GPIO_PIN_RESET);
|
||||||
|
}
|
||||||
+102
@@ -0,0 +1,102 @@
|
|||||||
|
#include "main.h"
|
||||||
|
#include "generic_macros.h"
|
||||||
|
#include "lcd.h"
|
||||||
|
#include "DNI.h"
|
||||||
|
|
||||||
|
static uint32_t DNI_read(void)
|
||||||
|
{
|
||||||
|
HAL_ADC_Start(&hadc1);
|
||||||
|
if (HAL_ADC_PollForConversion(&hadc1, 100) != HAL_OK)
|
||||||
|
PANIC(0x4000);
|
||||||
|
|
||||||
|
return HAL_ADC_GetValue(&hadc1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DNI_convert_to_celsius(uint32_t value)
|
||||||
|
{
|
||||||
|
return (2512 - value) << 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int DNI_convert_to_fahrenheit(uint32_t value)
|
||||||
|
{
|
||||||
|
return (2953 - value) * 50 / 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void DNI_print(int temperature)
|
||||||
|
{
|
||||||
|
int add_sign = temperature < 0;
|
||||||
|
if (add_sign)
|
||||||
|
temperature = ~(temperature - 1); // if value is not positive, the string conversion will break
|
||||||
|
|
||||||
|
int temp1 = temperature;
|
||||||
|
|
||||||
|
for (int i = 0; i < 2; i++) {
|
||||||
|
temperature /= 10;
|
||||||
|
display_write_data_byte('0' + (char) (temp1 - temperature * 10));
|
||||||
|
temp1 = temperature;
|
||||||
|
}
|
||||||
|
|
||||||
|
display_write_data_byte('.');
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
temperature /= 10;
|
||||||
|
display_write_data_byte('0' + (char) (temp1 - temperature * 10));
|
||||||
|
temp1 = temperature;
|
||||||
|
|
||||||
|
if (temp1 == 0) {
|
||||||
|
display_write_data_seq(" ");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (add_sign) {
|
||||||
|
DISPLAY_SET_CURSOR(1, 0);
|
||||||
|
display_write_data_byte('-');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void DNI_print_celsius(int temperature)
|
||||||
|
{
|
||||||
|
DISPLAY_SET_CURSOR(1, 7);
|
||||||
|
DISPLAY_SET_DECREMENT;
|
||||||
|
display_write_data_seq("C ");
|
||||||
|
|
||||||
|
DNI_print(temperature);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void DNI_print_fahrenheit(int temperature)
|
||||||
|
{
|
||||||
|
DISPLAY_SET_CURSOR(1, 7);
|
||||||
|
DISPLAY_SET_DECREMENT;
|
||||||
|
display_write_data_seq("F ");
|
||||||
|
|
||||||
|
DNI_print(temperature);
|
||||||
|
}
|
||||||
|
|
||||||
|
int DNI_show_celsius(void)
|
||||||
|
{
|
||||||
|
DISPLAY_CLEAR;
|
||||||
|
DISPLAY_SET_INCREMENT;
|
||||||
|
|
||||||
|
display_write_data_seq("DNI Temperature");
|
||||||
|
|
||||||
|
uint32_t value = DNI_read();
|
||||||
|
int temp = DNI_convert_to_celsius(value);
|
||||||
|
DNI_print_celsius(temp);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int DNI_show_fahrenheit(void)
|
||||||
|
{
|
||||||
|
DISPLAY_CLEAR;
|
||||||
|
DISPLAY_SET_INCREMENT;
|
||||||
|
|
||||||
|
display_write_data_seq("DNI Temperature");
|
||||||
|
|
||||||
|
uint32_t value = DNI_read();
|
||||||
|
int temp = DNI_convert_to_fahrenheit(value);
|
||||||
|
DNI_print_fahrenheit(temp);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,174 @@
|
|||||||
|
#include "main.h"
|
||||||
|
#include "lcd.h"
|
||||||
|
#include "LIS302DL.h"
|
||||||
|
|
||||||
|
#define FAILSAFE_PRE_OP for (size_t t = 0; t < 5; t++) {
|
||||||
|
#define FAILSAFE_POST_OP(prefix) if (op_result) print_error_message(op_result, err_count, t, prefix, postfix); else break; }
|
||||||
|
|
||||||
|
extern I2C_HandleTypeDef hi2c1;
|
||||||
|
|
||||||
|
static char convert_char_at(uint8_t value, size_t position)
|
||||||
|
{
|
||||||
|
char d = (value >> (4 * position)) % 16;
|
||||||
|
|
||||||
|
if (d > 9)
|
||||||
|
d += 7;
|
||||||
|
|
||||||
|
return '0' + d;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void print_at(uint8_t value, size_t offset)
|
||||||
|
{
|
||||||
|
DISPLAY_SET_CURSOR(1, offset);
|
||||||
|
|
||||||
|
// most significant digit
|
||||||
|
display_write_data_byte(convert_char_at(value, 1));
|
||||||
|
|
||||||
|
// least significant digit
|
||||||
|
display_write_data_byte(convert_char_at(value, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void print_error_message(HAL_StatusTypeDef result, size_t *err_count, size_t t, char *prefix, char *postfix)
|
||||||
|
{
|
||||||
|
DISPLAY_CLEAR;
|
||||||
|
display_write_data_seq("LIS302DL Accel ");
|
||||||
|
display_write_data_seq(postfix);
|
||||||
|
DISPLAY_SET_CURSOR(1, 0);
|
||||||
|
display_write_data_seq(prefix);
|
||||||
|
display_write_data_byte(' ');
|
||||||
|
|
||||||
|
(*err_count)++;
|
||||||
|
|
||||||
|
display_write_data_byte('1' + t);
|
||||||
|
display_write_data_seq("/5 ");
|
||||||
|
|
||||||
|
switch (result) {
|
||||||
|
case HAL_OK:
|
||||||
|
break;
|
||||||
|
case HAL_ERROR:
|
||||||
|
display_write_data_seq("ERROR");
|
||||||
|
break;
|
||||||
|
case HAL_BUSY:
|
||||||
|
display_write_data_seq("BUSY");
|
||||||
|
break;
|
||||||
|
case HAL_TIMEOUT:
|
||||||
|
display_write_data_seq("TIMEOUT");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
HAL_Delay(2000);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void retrieve_data(size_t *err_count, uint8_t *data_xyz, char *postfix)
|
||||||
|
{
|
||||||
|
HAL_StatusTypeDef op_result;
|
||||||
|
uint8_t data_buffer[2];
|
||||||
|
|
||||||
|
// enable device
|
||||||
|
data_buffer[0] = 0x20;
|
||||||
|
data_buffer[1] = 0x47;
|
||||||
|
FAILSAFE_PRE_OP;
|
||||||
|
op_result = HAL_I2C_Master_Transmit(&hi2c1, 0xD6, data_buffer, 2, 2000);
|
||||||
|
FAILSAFE_POST_OP("E");
|
||||||
|
|
||||||
|
// select OutX register
|
||||||
|
data_buffer[0] = 0x29;
|
||||||
|
FAILSAFE_PRE_OP;
|
||||||
|
op_result = HAL_I2C_Master_Transmit(&hi2c1, 0xD6 | 0x1, data_buffer, 1, 2000);
|
||||||
|
FAILSAFE_POST_OP("SX");
|
||||||
|
|
||||||
|
// receive data from it
|
||||||
|
FAILSAFE_PRE_OP;
|
||||||
|
op_result = HAL_I2C_Master_Receive(&hi2c1, 0xD6 | 0x1, data_xyz, 1, 2000);
|
||||||
|
FAILSAFE_POST_OP("RX");
|
||||||
|
|
||||||
|
// select OutY register
|
||||||
|
data_buffer[0] = 0x2B;
|
||||||
|
FAILSAFE_PRE_OP;
|
||||||
|
op_result = HAL_I2C_Master_Transmit(&hi2c1, 0xD6 | 0x1, data_buffer, 1, 2000);
|
||||||
|
FAILSAFE_POST_OP("SY");
|
||||||
|
|
||||||
|
// receive data from it
|
||||||
|
FAILSAFE_PRE_OP;
|
||||||
|
op_result = HAL_I2C_Master_Receive(&hi2c1, 0xD6 | 0x1, &(data_xyz[1]), 1, 2000);
|
||||||
|
FAILSAFE_POST_OP("RY");
|
||||||
|
|
||||||
|
// select OutZ register
|
||||||
|
data_buffer[0] = 0x2D;
|
||||||
|
FAILSAFE_PRE_OP;
|
||||||
|
op_result = HAL_I2C_Master_Transmit(&hi2c1, 0xD6 | 0x1, data_buffer, 1, 2000);
|
||||||
|
FAILSAFE_POST_OP("SZ");
|
||||||
|
|
||||||
|
// receive data from it
|
||||||
|
FAILSAFE_PRE_OP;
|
||||||
|
op_result = HAL_I2C_Master_Receive(&hi2c1, 0xD6 | 0x1, &(data_xyz[2]), 1, 2000);
|
||||||
|
FAILSAFE_POST_OP("RZ");
|
||||||
|
}
|
||||||
|
|
||||||
|
int LIS302DL_run_test(void)
|
||||||
|
{
|
||||||
|
DISPLAY_CLEAR;
|
||||||
|
display_write_data_seq("LIS302DL Accel");
|
||||||
|
|
||||||
|
size_t err_count = 0;
|
||||||
|
uint8_t data_xyz[3];
|
||||||
|
|
||||||
|
retrieve_data(&err_count, data_xyz, "");
|
||||||
|
|
||||||
|
DISPLAY_CLEAR;
|
||||||
|
display_write_data_seq("LIS302DL Accel");
|
||||||
|
|
||||||
|
// output retrieved values
|
||||||
|
print_at(data_xyz[2], 14);
|
||||||
|
print_at(data_xyz[1], 11);
|
||||||
|
print_at(data_xyz[0], 8);
|
||||||
|
|
||||||
|
// print the execution stats
|
||||||
|
if (err_count) {
|
||||||
|
DISPLAY_SET_CURSOR(1, 0);
|
||||||
|
display_write_data_byte('0' + err_count / 10 % 10);
|
||||||
|
display_write_data_byte('0' + err_count % 10);
|
||||||
|
display_write_data_seq(" errs");
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
DISPLAY_SET_CURSOR(1, 1);
|
||||||
|
display_write_data_seq("OK");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int LIS302DL_run_test_dynamic(void)
|
||||||
|
{
|
||||||
|
DISPLAY_CLEAR;
|
||||||
|
display_write_data_seq("LIS302DL Accel D");
|
||||||
|
|
||||||
|
size_t err_count = 0;
|
||||||
|
uint8_t data_xyz[3];
|
||||||
|
|
||||||
|
retrieve_data(&err_count, data_xyz, "D");
|
||||||
|
|
||||||
|
DISPLAY_CLEAR;
|
||||||
|
display_write_data_seq("LIS302DL Accel D");
|
||||||
|
|
||||||
|
// output retrieved values
|
||||||
|
print_at(data_xyz[2], 14);
|
||||||
|
print_at(data_xyz[1], 11);
|
||||||
|
print_at(data_xyz[0], 8);
|
||||||
|
|
||||||
|
// print the execution stats
|
||||||
|
if (err_count) {
|
||||||
|
DISPLAY_SET_CURSOR(1, 0);
|
||||||
|
display_write_data_byte('0' + err_count / 10 % 10);
|
||||||
|
display_write_data_byte('0' + err_count % 10);
|
||||||
|
display_write_data_seq(" errs");
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
DISPLAY_SET_CURSOR(1, 1);
|
||||||
|
display_write_data_seq("OK");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,139 @@
|
|||||||
|
#include "main.h"
|
||||||
|
#include "LSM9DS1.h"
|
||||||
|
#include "lcd.h"
|
||||||
|
|
||||||
|
#define FAILSAFE_PRE_OP for (size_t t = 0; t < 5; t++) {
|
||||||
|
#define FAILSAFE_POST_OP_ACCEL(prefix) if (op_result) print_error_accel(op_result, &err_count, t, prefix); else break; }
|
||||||
|
#define FAILSAFE_POST_OP_MAGNET(prefix) if (op_result) print_error_magnet(op_result, &err_count, t, prefix); else break; }
|
||||||
|
|
||||||
|
extern I2C_HandleTypeDef hi2c1;
|
||||||
|
|
||||||
|
static void print_error_message(HAL_StatusTypeDef result, size_t *err_count, size_t t, char *prefix)
|
||||||
|
{
|
||||||
|
DISPLAY_SET_CURSOR(1, 0);
|
||||||
|
display_write_data_seq(prefix);
|
||||||
|
display_write_data_byte(' ');
|
||||||
|
|
||||||
|
(*err_count)++;
|
||||||
|
|
||||||
|
display_write_data_byte('1' + t);
|
||||||
|
display_write_data_seq("/5 ");
|
||||||
|
|
||||||
|
switch (result) {
|
||||||
|
case HAL_OK:
|
||||||
|
break;
|
||||||
|
case HAL_ERROR:
|
||||||
|
display_write_data_seq("ERROR");
|
||||||
|
break;
|
||||||
|
case HAL_BUSY:
|
||||||
|
display_write_data_seq("BUSY");
|
||||||
|
break;
|
||||||
|
case HAL_TIMEOUT:
|
||||||
|
display_write_data_seq("TIMEOUT");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
HAL_Delay(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void print_error_accel(HAL_StatusTypeDef result, size_t *err_count, size_t t, char *prefix)
|
||||||
|
{
|
||||||
|
DISPLAY_CLEAR;
|
||||||
|
display_write_data_seq("LSM9DS1 Accel");
|
||||||
|
|
||||||
|
print_error_message(result, err_count, t, prefix);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void print_error_magnet(HAL_StatusTypeDef result, size_t *err_count, size_t t, char *prefix)
|
||||||
|
{
|
||||||
|
DISPLAY_CLEAR;
|
||||||
|
display_write_data_seq("LSM9DS1 Magnet");
|
||||||
|
|
||||||
|
print_error_message(result, err_count, t, prefix);
|
||||||
|
}
|
||||||
|
|
||||||
|
int LSM9DS1_test_accel(void)
|
||||||
|
{
|
||||||
|
DISPLAY_CLEAR;
|
||||||
|
display_write_data_seq("LSM9DS1 Accel");
|
||||||
|
|
||||||
|
HAL_StatusTypeDef op_result;
|
||||||
|
uint8_t buffer[6];
|
||||||
|
size_t err_count = 0;
|
||||||
|
|
||||||
|
// enable sampling at 10 Hz
|
||||||
|
buffer[0] = 0x20;
|
||||||
|
buffer[1] = 0x20;
|
||||||
|
FAILSAFE_PRE_OP;
|
||||||
|
op_result = HAL_I2C_Master_Transmit(&hi2c1, 0xD6, buffer, 2, 1000);
|
||||||
|
FAILSAFE_POST_OP_ACCEL("E");
|
||||||
|
|
||||||
|
HAL_Delay(100);
|
||||||
|
|
||||||
|
// set future read address
|
||||||
|
buffer[0] = 0x28;
|
||||||
|
FAILSAFE_PRE_OP;
|
||||||
|
op_result = HAL_I2C_Master_Transmit(&hi2c1, 0xD6, buffer, 1, 1000);
|
||||||
|
FAILSAFE_POST_OP_ACCEL("A");
|
||||||
|
|
||||||
|
// read from registers sequentially
|
||||||
|
FAILSAFE_PRE_OP;
|
||||||
|
op_result = HAL_I2C_Master_Receive(&hi2c1, 0xD7, buffer, 6, 1000);
|
||||||
|
FAILSAFE_POST_OP_ACCEL("R");
|
||||||
|
|
||||||
|
if (!err_count) {
|
||||||
|
DISPLAY_SET_CURSOR(1, 1);
|
||||||
|
display_write_data_seq("OK");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
DISPLAY_SET_CURSOR(1, 0);
|
||||||
|
display_write_data_byte('0' + ((err_count / 10) % 10));
|
||||||
|
display_write_data_byte('0' + (err_count % 10));
|
||||||
|
display_write_data_seq(" errors");
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LSM9DS1_cleanup_accel(void)
|
||||||
|
{
|
||||||
|
// power down the accelerometer
|
||||||
|
uint8_t buffer[2] = {0x20, 0x00};
|
||||||
|
HAL_I2C_Master_Transmit(&hi2c1, 0xD6, buffer, 2, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
int LSM9DS1_test_magnet(void)
|
||||||
|
{
|
||||||
|
DISPLAY_CLEAR;
|
||||||
|
display_write_data_seq("LSM9DS1 Magnet");
|
||||||
|
|
||||||
|
HAL_StatusTypeDef op_result;
|
||||||
|
uint8_t buffer[6];
|
||||||
|
size_t err_count = 0;
|
||||||
|
|
||||||
|
// set future read address
|
||||||
|
buffer[0] = 0x28;
|
||||||
|
FAILSAFE_PRE_OP;
|
||||||
|
op_result = HAL_I2C_Master_Transmit(&hi2c1, 0x3C, buffer, 1, 1000);
|
||||||
|
FAILSAFE_POST_OP_MAGNET("A");
|
||||||
|
|
||||||
|
// read from registers sequentially
|
||||||
|
FAILSAFE_PRE_OP;
|
||||||
|
op_result = HAL_I2C_Master_Receive(&hi2c1, 0x3D, buffer, 6, 1000);
|
||||||
|
FAILSAFE_POST_OP_MAGNET("R");
|
||||||
|
|
||||||
|
if (!err_count) {
|
||||||
|
DISPLAY_SET_CURSOR(1, 1);
|
||||||
|
display_write_data_seq("OK");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
DISPLAY_SET_CURSOR(1, 0);
|
||||||
|
display_write_data_byte('0' + ((err_count / 10) % 10));
|
||||||
|
display_write_data_byte('0' + (err_count % 10));
|
||||||
|
display_write_data_seq(" errors");
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
#include "main.h"
|
||||||
|
#include "MP45DT02.h"
|
||||||
|
#include "lcd.h"
|
||||||
|
|
||||||
|
#define SAMPLE_AMOUNT 256
|
||||||
|
|
||||||
|
extern I2S_HandleTypeDef hi2s2;
|
||||||
|
|
||||||
|
int MP45DT02_run_test(void)
|
||||||
|
{
|
||||||
|
DISPLAY_CLEAR;
|
||||||
|
display_write_data_seq("MP45DT02 Mic");
|
||||||
|
|
||||||
|
uint16_t sample_buffer[SAMPLE_AMOUNT];
|
||||||
|
|
||||||
|
for (size_t t = 0; t < 5; t++) {
|
||||||
|
HAL_I2S_Receive(&hi2s2, sample_buffer, SAMPLE_AMOUNT, 1000);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < SAMPLE_AMOUNT / 2; i++)
|
||||||
|
if (((uint32_t *) sample_buffer)[i]) {
|
||||||
|
DISPLAY_CLEAR;
|
||||||
|
display_write_data_seq("MP45DT02 Mic");
|
||||||
|
|
||||||
|
if (!t) {
|
||||||
|
DISPLAY_SET_CURSOR(1, 1);
|
||||||
|
display_write_data_seq("OK");
|
||||||
|
} else {
|
||||||
|
DISPLAY_SET_CURSOR(1, 0);
|
||||||
|
display_write_data_byte('0' + t);
|
||||||
|
display_write_data_seq(" full 0 samples");
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if ended up here, then no samples equaled to 1; that is not a good sign
|
||||||
|
DISPLAY_CLEAR;
|
||||||
|
display_write_data_seq("MP45DT02 Mic");
|
||||||
|
|
||||||
|
DISPLAY_SET_CURSOR(1, 0);
|
||||||
|
display_write_data_byte('1' + t);
|
||||||
|
display_write_data_seq("/5: no 1 sampled");
|
||||||
|
|
||||||
|
HAL_Delay(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
// t = 5, not a single 1 was recorded; microphone might be broken
|
||||||
|
DISPLAY_CLEAR;
|
||||||
|
display_write_data_seq("MP45DT02 Mic");
|
||||||
|
|
||||||
|
DISPLAY_SET_CURSOR(1, 0);
|
||||||
|
display_write_data_seq("No good samples!");
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
#include "main.h"
|
||||||
|
#include "PCA9685.h"
|
||||||
|
#include "lcd.h"
|
||||||
|
|
||||||
|
extern I2C_HandleTypeDef hi2c1;
|
||||||
|
|
||||||
|
int PCA9685_run_test(void)
|
||||||
|
{
|
||||||
|
DISPLAY_CLEAR;
|
||||||
|
display_write_data_seq("PCA9685 PWM");
|
||||||
|
|
||||||
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_RESET);
|
||||||
|
|
||||||
|
HAL_StatusTypeDef op_result;
|
||||||
|
size_t err_count = 0;
|
||||||
|
uint8_t tx_data[10] = {
|
||||||
|
0x00, 0x01,
|
||||||
|
0x06, 0x00,
|
||||||
|
0x07, 0x00,
|
||||||
|
0x08, 0xFF,
|
||||||
|
0x09, 0x0C,
|
||||||
|
};
|
||||||
|
|
||||||
|
for (size_t i = 0; i < 10; i += 2) {
|
||||||
|
for (size_t t = 0; t < 5; t++) {
|
||||||
|
op_result = HAL_I2C_Master_Transmit(&hi2c1, 0x80, &(tx_data[i]), 2, 2000);
|
||||||
|
|
||||||
|
if (op_result) {
|
||||||
|
err_count++;
|
||||||
|
|
||||||
|
DISPLAY_CLEAR;
|
||||||
|
display_write_data_seq("PCA9685 PWM");
|
||||||
|
DISPLAY_SET_CURSOR(1, 0);
|
||||||
|
|
||||||
|
display_write_data_seq("B");
|
||||||
|
display_write_data_byte('0' + i);
|
||||||
|
display_write_data_byte(':');
|
||||||
|
|
||||||
|
display_write_data_byte('1' + t);
|
||||||
|
display_write_data_seq("/5 ");
|
||||||
|
|
||||||
|
switch (op_result) {
|
||||||
|
case HAL_OK:
|
||||||
|
break;
|
||||||
|
case HAL_ERROR:
|
||||||
|
display_write_data_seq("ERROR");
|
||||||
|
break;
|
||||||
|
case HAL_BUSY:
|
||||||
|
display_write_data_seq("BUSY");
|
||||||
|
break;
|
||||||
|
case HAL_TIMEOUT:
|
||||||
|
display_write_data_seq("TIMEOUT");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
HAL_Delay(2000);
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DISPLAY_CLEAR;
|
||||||
|
display_write_data_seq("PCA9685 PWM");
|
||||||
|
|
||||||
|
if (err_count) {
|
||||||
|
DISPLAY_SET_CURSOR(1, 0);
|
||||||
|
display_write_data_byte('0' + err_count / 10 % 10);
|
||||||
|
display_write_data_byte('0' + err_count % 10);
|
||||||
|
display_write_data_seq(" errors");
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
DISPLAY_SET_CURSOR(1, 1);
|
||||||
|
display_write_data_seq("OK");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PCA9685_cleanup(void)
|
||||||
|
{
|
||||||
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_SET);
|
||||||
|
}
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
#include "main.h"
|
||||||
|
#include "lcd.h"
|
||||||
|
#include "SST25VF016B.h"
|
||||||
|
|
||||||
|
extern SPI_HandleTypeDef hspi1;
|
||||||
|
|
||||||
|
int SST25VF016B_run_test(void)
|
||||||
|
{
|
||||||
|
DISPLAY_CLEAR;
|
||||||
|
display_write_data_seq("SST25VF016B Flas");
|
||||||
|
|
||||||
|
HAL_StatusTypeDef op_result;
|
||||||
|
size_t err_count = 0;
|
||||||
|
size_t chip_id_fault = 0;
|
||||||
|
|
||||||
|
uint8_t tx_buffer[8] = {0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||||
|
uint8_t rx_buffer[9];
|
||||||
|
rx_buffer[8] = '\0';
|
||||||
|
|
||||||
|
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_7, GPIO_PIN_SET);
|
||||||
|
HAL_Delay(50);
|
||||||
|
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_7, GPIO_PIN_RESET);
|
||||||
|
|
||||||
|
for (size_t t = 0; t < 5; t++) {
|
||||||
|
op_result = HAL_SPI_TransmitReceive(&hspi1, tx_buffer, rx_buffer, 8, 2000);
|
||||||
|
|
||||||
|
if (op_result) {
|
||||||
|
err_count++;
|
||||||
|
|
||||||
|
DISPLAY_CLEAR;
|
||||||
|
display_write_data_seq("SST25VF016B Flas");
|
||||||
|
|
||||||
|
DISPLAY_SET_CURSOR(1, 0);
|
||||||
|
display_write_data_byte('1' + t);
|
||||||
|
display_write_data_seq("/5 ");
|
||||||
|
|
||||||
|
switch (op_result) {
|
||||||
|
case HAL_OK:
|
||||||
|
break;
|
||||||
|
case HAL_ERROR:
|
||||||
|
display_write_data_seq("ERROR");
|
||||||
|
break;
|
||||||
|
case HAL_BUSY:
|
||||||
|
display_write_data_seq("BUSY");
|
||||||
|
break;
|
||||||
|
case HAL_TIMEOUT:
|
||||||
|
display_write_data_seq("TIMEOUT");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_7, GPIO_PIN_SET);
|
||||||
|
|
||||||
|
DISPLAY_CLEAR;
|
||||||
|
display_write_data_seq("SST25VF016B Flas");
|
||||||
|
|
||||||
|
if (err_count) {
|
||||||
|
DISPLAY_SET_CURSOR(1, 1);
|
||||||
|
display_write_data_byte('0' + err_count % 10);
|
||||||
|
display_write_data_seq(" Errors");
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
for (size_t i = 0; i < 4; i += 2) {
|
||||||
|
// odd reads MUST result in 0xBF
|
||||||
|
if (rx_buffer[4+i] != 0xBF) {
|
||||||
|
DISPLAY_SET_CURSOR(1, 0);
|
||||||
|
display_write_data_byte('B');
|
||||||
|
display_write_data_byte('1'+i);
|
||||||
|
display_write_data_seq(" WRONG");
|
||||||
|
|
||||||
|
chip_id_fault = 1;
|
||||||
|
|
||||||
|
goto write_retrieved_data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i = 1; i < 4; i += 2) {
|
||||||
|
// even reads MUST result in 0x41
|
||||||
|
if (rx_buffer[4+i] != 0x41) {
|
||||||
|
DISPLAY_SET_CURSOR(1, 0);
|
||||||
|
display_write_data_byte('B');
|
||||||
|
display_write_data_byte('1'+i);
|
||||||
|
display_write_data_seq(" WRONG");
|
||||||
|
|
||||||
|
chip_id_fault = 1;
|
||||||
|
|
||||||
|
goto write_retrieved_data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DISPLAY_SET_CURSOR(1, 1);
|
||||||
|
display_write_data_seq("OK");
|
||||||
|
}
|
||||||
|
|
||||||
|
write_retrieved_data:
|
||||||
|
DISPLAY_SET_CURSOR(1, 12);
|
||||||
|
display_write_data_seq((char *) &(rx_buffer[4]));
|
||||||
|
|
||||||
|
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_7, GPIO_PIN_SET);
|
||||||
|
|
||||||
|
return (err_count || chip_id_fault);
|
||||||
|
}
|
||||||
+184
@@ -0,0 +1,184 @@
|
|||||||
|
#include "main.h"
|
||||||
|
#include "lcd.h"
|
||||||
|
#include "generic_macros.h"
|
||||||
|
|
||||||
|
static char display_framebuffer[16*2*DISPLAY_FRAMES_AVAILABLE];
|
||||||
|
size_t display_current_frame;
|
||||||
|
static size_t display_framebuffer_mode;
|
||||||
|
|
||||||
|
static struct Display_emu_state des;
|
||||||
|
|
||||||
|
void display_init(void)
|
||||||
|
{
|
||||||
|
// prepare virtual framebuffer
|
||||||
|
display_current_frame = 0;
|
||||||
|
display_framebuffer_mode = 0;
|
||||||
|
des.cursor_offset = 0;
|
||||||
|
des.next = 0;
|
||||||
|
memset(display_framebuffer, 0x20, 16*2*DISPLAY_FRAMES_AVAILABLE);
|
||||||
|
|
||||||
|
// switch to 4-bit 2-line mode
|
||||||
|
display_write_instruction_byte(0x28);
|
||||||
|
|
||||||
|
// clear display
|
||||||
|
display_write_instruction_byte(0x01);
|
||||||
|
|
||||||
|
// enable display
|
||||||
|
display_write_instruction_byte(0x0C);
|
||||||
|
|
||||||
|
// move cursor to first line
|
||||||
|
display_write_instruction_byte(0x80);
|
||||||
|
}
|
||||||
|
|
||||||
|
void display_to_framebuffer(void)
|
||||||
|
{
|
||||||
|
display_framebuffer_mode = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void display_to_direct(void)
|
||||||
|
{
|
||||||
|
display_framebuffer_mode = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint8_t display_read_status(void)
|
||||||
|
{
|
||||||
|
// make sure GPIOE is in correct mode
|
||||||
|
GPIOE->MODER = 0x00504000;
|
||||||
|
|
||||||
|
if (GPIOE->MODER != 0x00504000)
|
||||||
|
PANIC(0x4000);
|
||||||
|
|
||||||
|
uint8_t status = 0;
|
||||||
|
|
||||||
|
GPIOE->ODR = 0x0;
|
||||||
|
GPIOE->BSRR = DISPLAY_RW;
|
||||||
|
|
||||||
|
GPIOE->BSRR = DISPLAY_ENA;
|
||||||
|
status |= (GPIOE->IDR & 0xF000) >> 8;
|
||||||
|
GPIOE->BSRR = (DISPLAY_ENA << 16);
|
||||||
|
|
||||||
|
GPIOE->BSRR = DISPLAY_ENA;
|
||||||
|
status |= (GPIOE->IDR & 0xF000) >> 12;
|
||||||
|
GPIOE->BSRR = (DISPLAY_ENA << 16);
|
||||||
|
|
||||||
|
GPIOE->ODR = 0x0;
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void display_write_instruction_byte_direct(uint8_t code)
|
||||||
|
{
|
||||||
|
DISPLAY_POLL_UNTIL_READY;
|
||||||
|
|
||||||
|
// make sure GPIOE is in correct mode
|
||||||
|
GPIOE->MODER = 0x55504000;
|
||||||
|
|
||||||
|
if (GPIOE->MODER != 0x55504000)
|
||||||
|
PANIC(0x4000);
|
||||||
|
|
||||||
|
GPIOE->ODR = (code & 0xF0) << 8;
|
||||||
|
GPIOE->BSRR = DISPLAY_ENA;
|
||||||
|
GPIOE->BSRR = (DISPLAY_ENA << 16);
|
||||||
|
|
||||||
|
GPIOE->ODR = (code & 0x0F) << 12;
|
||||||
|
GPIOE->BSRR = DISPLAY_ENA;
|
||||||
|
GPIOE->BSRR = (DISPLAY_ENA << 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void display_write_instruction_byte_framebuffer(uint8_t code)
|
||||||
|
{
|
||||||
|
// emulate physical display behavior on receiving instructions
|
||||||
|
if (code & 0x80) {
|
||||||
|
// decode new cursor offset
|
||||||
|
size_t offset = ((code & 0x40) >> 2) | (code & 0xF);
|
||||||
|
des.cursor_offset = offset;
|
||||||
|
} else if (code == 0x01) {
|
||||||
|
// reset screen
|
||||||
|
memset(&(display_framebuffer[16*2*display_current_frame]), 0x20, 16*2);
|
||||||
|
des.cursor_offset = 0;
|
||||||
|
des.next = 0;
|
||||||
|
} else if (code == 0x06) {
|
||||||
|
// set increment mode
|
||||||
|
des.next = 0;
|
||||||
|
} else if (code == 0x04) {
|
||||||
|
// set decrement mode
|
||||||
|
des.next = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void display_write_instruction_byte(uint8_t code)
|
||||||
|
{
|
||||||
|
if (display_framebuffer_mode) {
|
||||||
|
display_write_instruction_byte_framebuffer(code);
|
||||||
|
} else {
|
||||||
|
display_write_instruction_byte_direct(code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void display_write_data_byte_direct(uint8_t code)
|
||||||
|
{
|
||||||
|
DISPLAY_POLL_UNTIL_READY;
|
||||||
|
|
||||||
|
// make sure GPIOE is in correct mode
|
||||||
|
GPIOE->MODER = 0x55504000;
|
||||||
|
|
||||||
|
if (GPIOE->MODER != 0x55504000)
|
||||||
|
PANIC(0x4000);
|
||||||
|
|
||||||
|
GPIOE->ODR = ((code & 0xF0) << 8) | (DISPLAY_RS);
|
||||||
|
GPIOE->BSRR = DISPLAY_ENA;
|
||||||
|
GPIOE->BSRR = DISPLAY_ENA << 16;
|
||||||
|
|
||||||
|
GPIOE->ODR = ((code & 0x0F) << 12) | (DISPLAY_RS);
|
||||||
|
GPIOE->BSRR = DISPLAY_ENA;
|
||||||
|
GPIOE->BSRR = DISPLAY_ENA << 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void display_write_data_byte_framebuffer(uint8_t code)
|
||||||
|
{
|
||||||
|
if (display_current_frame >= DISPLAY_FRAMES_AVAILABLE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (((int) des.cursor_offset >= 32) || ((int) des.cursor_offset < 0))
|
||||||
|
return;
|
||||||
|
|
||||||
|
display_framebuffer[16*2*display_current_frame + des.cursor_offset] = (char) code;
|
||||||
|
des.cursor_offset += des.next ? -1 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void display_write_data_byte(uint8_t code)
|
||||||
|
{
|
||||||
|
if (display_framebuffer_mode) {
|
||||||
|
display_write_data_byte_framebuffer(code);
|
||||||
|
} else {
|
||||||
|
display_write_data_byte_direct(code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void display_write_data_seq(char *codes)
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < 16; i++) {
|
||||||
|
if (codes[i])
|
||||||
|
display_write_data_byte(codes[i]);
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void display_load(uint32_t frame_no)
|
||||||
|
{
|
||||||
|
if (display_framebuffer_mode)
|
||||||
|
return;
|
||||||
|
|
||||||
|
DISPLAY_CLEAR;
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i < 16; i++) {
|
||||||
|
display_write_data_byte_direct(display_framebuffer[16*2*display_current_frame + i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
DISPLAY_SET_CURSOR(1, 0);
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i < 16; i++) {
|
||||||
|
display_write_data_byte_direct(display_framebuffer[16*2*display_current_frame + i + 16]);
|
||||||
|
}
|
||||||
|
}
|
||||||
+430
-106
@@ -22,6 +22,17 @@
|
|||||||
/* Private includes ----------------------------------------------------------*/
|
/* Private includes ----------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN Includes */
|
/* USER CODE BEGIN Includes */
|
||||||
|
|
||||||
|
#include "generic_macros.h"
|
||||||
|
#include "lcd.h"
|
||||||
|
#include "DNI.h"
|
||||||
|
#include "PCA9685.h"
|
||||||
|
#include "24AA02E48.h"
|
||||||
|
#include "CS43L22.h"
|
||||||
|
#include "SST25VF016B.h"
|
||||||
|
#include "LIS302DL.h"
|
||||||
|
#include "MP45DT02.h"
|
||||||
|
#include "LSM9DS1.h"
|
||||||
|
|
||||||
/* USER CODE END Includes */
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
/* Private typedef -----------------------------------------------------------*/
|
/* Private typedef -----------------------------------------------------------*/
|
||||||
@@ -32,17 +43,19 @@
|
|||||||
/* Private define ------------------------------------------------------------*/
|
/* Private define ------------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN PD */
|
/* USER CODE BEGIN PD */
|
||||||
|
|
||||||
#define DISPLAY_RS ((uint16_t) (0x1U << 7))
|
#define WAIT_UNTIL_CB_PRESSED while (!HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_0) && HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_8))
|
||||||
#define DISPLAY_RW ((uint16_t) (0x1U << 10))
|
#define WAIT_UNTIL_CB_RELEASED while (HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_0) || !HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_8))
|
||||||
#define DISPLAY_ENA ((uint16_t) (0x1U << 11))
|
|
||||||
|
|
||||||
#define PANIC(status) \
|
#define UB (GPIOA->IDR & GPIO_PIN_0)
|
||||||
do { \
|
#define SWT1 !(GPIOC->IDR & GPIO_PIN_11)
|
||||||
GPIOD->ODR = status; \
|
#define SWT2 !(GPIOA->IDR & GPIO_PIN_15)
|
||||||
while (1) {} \
|
#define SWT3 !(GPIOC->IDR & GPIO_PIN_9)
|
||||||
} while (0)
|
#define SWT4 !(GPIOC->IDR & GPIO_PIN_6)
|
||||||
|
#define SWT5 !(GPIOC->IDR & GPIO_PIN_8)
|
||||||
|
|
||||||
#define POLL_UNTIL_READY do { while (read_status() & 0x80) {} } while (0)
|
#define WAIT_UNTIL_ALL_BUTTONS_RELEASED do {} while ( UB || SWT1 || SWT2 || SWT3 || SWT4 || SWT5 )
|
||||||
|
|
||||||
|
#define LEN(x) ( sizeof(x) / sizeof((x)[0]) )
|
||||||
|
|
||||||
/* USER CODE END PD */
|
/* USER CODE END PD */
|
||||||
|
|
||||||
@@ -52,16 +65,54 @@
|
|||||||
/* USER CODE END PM */
|
/* USER CODE END PM */
|
||||||
|
|
||||||
/* Private variables ---------------------------------------------------------*/
|
/* Private variables ---------------------------------------------------------*/
|
||||||
|
ADC_HandleTypeDef hadc1;
|
||||||
|
|
||||||
|
I2C_HandleTypeDef hi2c1;
|
||||||
|
|
||||||
|
I2S_HandleTypeDef hi2s2;
|
||||||
|
|
||||||
|
SPI_HandleTypeDef hspi1;
|
||||||
|
|
||||||
|
TIM_HandleTypeDef htim2;
|
||||||
|
|
||||||
|
extern size_t display_current_frame;
|
||||||
|
|
||||||
/* USER CODE BEGIN PV */
|
/* USER CODE BEGIN PV */
|
||||||
|
|
||||||
int change = 1;
|
static const int ((*executors[])(void)) = {
|
||||||
|
DNI_show_celsius,
|
||||||
|
PCA9685_run_test,
|
||||||
|
EEPROM_24AA02E48_run_test,
|
||||||
|
CS43L22_run_test,
|
||||||
|
SST25VF016B_run_test,
|
||||||
|
LIS302DL_run_test,
|
||||||
|
MP45DT02_run_test,
|
||||||
|
LSM9DS1_test_accel,
|
||||||
|
LSM9DS1_test_magnet
|
||||||
|
};
|
||||||
|
|
||||||
|
static const void ((*cleanup_functions[])(void)) = {
|
||||||
|
NULL,
|
||||||
|
PCA9685_cleanup,
|
||||||
|
NULL,
|
||||||
|
CS43L22_cleanup,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
LSM9DS1_cleanup_accel,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
/* USER CODE END PV */
|
/* USER CODE END PV */
|
||||||
|
|
||||||
/* Private function prototypes -----------------------------------------------*/
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
void SystemClock_Config(void);
|
void SystemClock_Config(void);
|
||||||
static void MX_GPIO_Init(void);
|
static void MX_GPIO_Init(void);
|
||||||
|
static void MX_ADC1_Init(void);
|
||||||
|
static void MX_I2C1_Init(void);
|
||||||
|
static void MX_SPI1_Init(void);
|
||||||
|
static void MX_TIM2_Init(void);
|
||||||
|
static void MX_I2S2_Init(void);
|
||||||
/* USER CODE BEGIN PFP */
|
/* USER CODE BEGIN PFP */
|
||||||
|
|
||||||
/* USER CODE END PFP */
|
/* USER CODE END PFP */
|
||||||
@@ -69,68 +120,70 @@ static void MX_GPIO_Init(void);
|
|||||||
/* Private user code ---------------------------------------------------------*/
|
/* Private user code ---------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN 0 */
|
/* USER CODE BEGIN 0 */
|
||||||
|
|
||||||
uint8_t read_status(void)
|
static void button_init_and_test(void)
|
||||||
{
|
{
|
||||||
// make sure GPIOE is in correct mode
|
// letting the buttons be tested
|
||||||
GPIOE->MODER = 0x00504000;
|
display_write_data_seq("Fill any bar:");
|
||||||
|
DISPLAY_SET_CURSOR(1, 5);
|
||||||
|
display_write_data_seq("[-] [-----]");
|
||||||
|
|
||||||
if (GPIOE->MODER != 0x00504000)
|
size_t pressed_elements;
|
||||||
PANIC(0x4000);
|
|
||||||
|
|
||||||
uint8_t status = 0;
|
uint32_t sw_button_locations[5][2] = {
|
||||||
|
{(uint32_t) GPIOC, (uint32_t) GPIO_PIN_11},
|
||||||
|
{(uint32_t) GPIOA, (uint32_t) GPIO_PIN_15},
|
||||||
|
{(uint32_t) GPIOC, (uint32_t) GPIO_PIN_9},
|
||||||
|
{(uint32_t) GPIOC, (uint32_t) GPIO_PIN_6},
|
||||||
|
{(uint32_t) GPIOC, (uint32_t) GPIO_PIN_8}
|
||||||
|
};
|
||||||
|
|
||||||
GPIOE->ODR = 0x0;
|
do {
|
||||||
GPIOE->BSRR = DISPLAY_RW;
|
HAL_Delay(100);
|
||||||
|
pressed_elements = 0;
|
||||||
|
|
||||||
GPIOE->BSRR = DISPLAY_ENA;
|
DISPLAY_SET_CURSOR(1, 6);
|
||||||
status |= (GPIOE->IDR & 0xF000) >> 8;
|
|
||||||
GPIOE->BSRR = (DISPLAY_ENA << 16);
|
|
||||||
|
|
||||||
GPIOE->BSRR = DISPLAY_ENA;
|
if (HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_0)) {
|
||||||
status |= (GPIOE->IDR & 0xF000) >> 12;
|
pressed_elements |= 0x20;
|
||||||
GPIOE->BSRR = (DISPLAY_ENA << 16);
|
display_write_data_byte('*');
|
||||||
|
} else {
|
||||||
|
display_write_data_byte('-');
|
||||||
|
}
|
||||||
|
|
||||||
GPIOE->ODR = 0x0;
|
DISPLAY_SET_CURSOR(1, 10);
|
||||||
|
|
||||||
return status;
|
for (size_t i = 0; i < 5; i++) {
|
||||||
}
|
pressed_elements >>= 1;
|
||||||
|
|
||||||
void write_instruction_byte(uint8_t code)
|
size_t input = !HAL_GPIO_ReadPin((GPIO_TypeDef *) sw_button_locations[i][0], sw_button_locations[i][1]);
|
||||||
{
|
|
||||||
POLL_UNTIL_READY;
|
|
||||||
|
|
||||||
// make sure GPIOE is in correct mode
|
if (input) {
|
||||||
GPIOE->MODER = 0x55504000;
|
pressed_elements |= 0x20;
|
||||||
|
display_write_data_byte('*');
|
||||||
|
} else {
|
||||||
|
display_write_data_byte('-');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} while (!(((pressed_elements & 0x1) == 0x1) || ((pressed_elements & 0x3E) == 0x3E)));
|
||||||
|
|
||||||
if (GPIOE->MODER != 0x55504000)
|
|
||||||
PANIC(0x4000);
|
|
||||||
|
|
||||||
GPIOE->ODR = (code & 0xF0) << 8;
|
// visual reaction to bar fill
|
||||||
GPIOE->BSRR = DISPLAY_ENA;
|
DISPLAY_SET_CURSOR(0, 0);
|
||||||
GPIOE->BSRR = (DISPLAY_ENA << 16);
|
display_write_data_seq("Release buttons");
|
||||||
|
|
||||||
GPIOE->ODR = (code & 0x0F) << 12;
|
GPIOD->ODR = 0x1000;
|
||||||
GPIOE->BSRR = DISPLAY_ENA;
|
HAL_Delay(300);
|
||||||
GPIOE->BSRR = (DISPLAY_ENA << 16);
|
GPIOD->ODR = 0x2000;
|
||||||
}
|
HAL_Delay(300);
|
||||||
|
GPIOD->ODR = 0x4000;
|
||||||
|
HAL_Delay(300);
|
||||||
|
GPIOD->ODR = 0x8000;
|
||||||
|
HAL_Delay(300);
|
||||||
|
|
||||||
void write_data_byte(uint8_t code)
|
// waiting for all buttons to be released
|
||||||
{
|
WAIT_UNTIL_ALL_BUTTONS_RELEASED;
|
||||||
POLL_UNTIL_READY;
|
GPIOD->ODR = 0x0000;
|
||||||
|
HAL_Delay(200);
|
||||||
// make sure GPIOE is in correct mode
|
|
||||||
GPIOE->MODER = 0x55504000;
|
|
||||||
|
|
||||||
if (GPIOE->MODER != 0x55504000)
|
|
||||||
PANIC(0x4000);
|
|
||||||
|
|
||||||
GPIOE->ODR = ((code & 0xF0) << 8) | (DISPLAY_RS);
|
|
||||||
GPIOE->BSRR = DISPLAY_ENA;
|
|
||||||
GPIOE->BSRR = DISPLAY_ENA << 16;
|
|
||||||
|
|
||||||
GPIOE->ODR = ((code & 0x0F) << 12) | (DISPLAY_RS);
|
|
||||||
GPIOE->BSRR = DISPLAY_ENA;
|
|
||||||
GPIOE->BSRR = DISPLAY_ENA << 16;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* USER CODE END 0 */
|
/* USER CODE END 0 */
|
||||||
@@ -164,67 +217,109 @@ int main(void)
|
|||||||
|
|
||||||
/* Initialize all configured peripherals */
|
/* Initialize all configured peripherals */
|
||||||
MX_GPIO_Init();
|
MX_GPIO_Init();
|
||||||
|
MX_ADC1_Init();
|
||||||
|
MX_I2C1_Init();
|
||||||
|
MX_SPI1_Init();
|
||||||
|
MX_TIM2_Init();
|
||||||
|
MX_I2S2_Init();
|
||||||
/* USER CODE BEGIN 2 */
|
/* USER CODE BEGIN 2 */
|
||||||
|
|
||||||
|
HAL_TIM_Base_Start(&htim2);
|
||||||
|
TIM2->CNT = 0;
|
||||||
|
HAL_TIM_Base_Stop(&htim2);
|
||||||
|
|
||||||
|
GPIOD->ODR = 0x1000;
|
||||||
|
display_init();
|
||||||
|
|
||||||
GPIOD->ODR = 0xF000;
|
GPIOD->ODR = 0xF000;
|
||||||
|
button_init_and_test();
|
||||||
|
|
||||||
// switch to 4-bit 2-line mode
|
// perform all tests
|
||||||
write_instruction_byte(0x28);
|
size_t successful_tests = 0;
|
||||||
|
size_t failed_tests = 0;
|
||||||
|
|
||||||
// reset display
|
for (display_current_frame = 1; display_current_frame < LEN(executors)+1; display_current_frame++)
|
||||||
write_instruction_byte(0x01);
|
{
|
||||||
|
DISPLAY_CLEAR;
|
||||||
|
display_write_data_seq("Testing...");
|
||||||
|
|
||||||
// enable display
|
DISPLAY_SET_CURSOR(1, 2);
|
||||||
write_instruction_byte(0x0C);
|
display_write_data_seq("P:");
|
||||||
|
display_write_data_byte('0' + (successful_tests / 10) % 10);
|
||||||
|
display_write_data_byte('0' + (successful_tests) % 10);
|
||||||
|
|
||||||
// move cursor to first line
|
DISPLAY_SET_CURSOR(1, 10);
|
||||||
write_instruction_byte(0x80);
|
display_write_data_seq("F:");
|
||||||
|
display_write_data_byte('0' + (failed_tests / 10) % 10);
|
||||||
|
display_write_data_byte('0' + (failed_tests) % 10);
|
||||||
|
|
||||||
// write string
|
display_to_framebuffer();
|
||||||
char a[] = "Well, hi there!";
|
|
||||||
for (int i = 0; i < sizeof(a)-1; i++) {
|
// test
|
||||||
write_data_byte(a[i]);
|
if (executors[display_current_frame-1]())
|
||||||
|
failed_tests++;
|
||||||
|
else
|
||||||
|
successful_tests++;
|
||||||
|
|
||||||
|
// cleanup (if required)
|
||||||
|
if (cleanup_functions[display_current_frame-1])
|
||||||
|
cleanup_functions[display_current_frame-1]();
|
||||||
|
|
||||||
|
display_to_direct();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// render final result to first framebuffer
|
||||||
// move cursor to second line
|
display_to_framebuffer();
|
||||||
write_instruction_byte(0xC0);
|
display_current_frame = 0;
|
||||||
while (read_status() & 0x80) {}
|
|
||||||
|
|
||||||
// write another string
|
DISPLAY_CLEAR;
|
||||||
char b[] = "I'm doing it!";
|
display_write_data_seq("All tests done!");
|
||||||
for (int i = 0; i < sizeof(b)-1; i++) {
|
|
||||||
write_data_byte(b[i]);
|
|
||||||
while (read_status() & 0x80) {}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
GPIOD->ODR = 0x0000;
|
DISPLAY_SET_CURSOR(1, 2);
|
||||||
|
display_write_data_seq("P:");
|
||||||
|
display_write_data_byte('0' + (successful_tests / 10) % 10);
|
||||||
|
display_write_data_byte('0' + (successful_tests) % 10);
|
||||||
|
|
||||||
unsigned int counter = 0;
|
DISPLAY_SET_CURSOR(1, 10);
|
||||||
write_instruction_byte(0x04); // set address decrement after write
|
display_write_data_seq("F:");
|
||||||
|
display_write_data_byte('0' + (failed_tests / 10) % 10);
|
||||||
|
display_write_data_byte('0' + (failed_tests) % 10);
|
||||||
|
|
||||||
|
display_to_direct();
|
||||||
|
|
||||||
/* USER CODE END 2 */
|
/* USER CODE END 2 */
|
||||||
|
|
||||||
/* Infinite loop */
|
/* Infinite loop */
|
||||||
/* USER CODE BEGIN WHILE */
|
/* USER CODE BEGIN WHILE */
|
||||||
while (1)
|
while (1) {
|
||||||
{
|
WAIT_UNTIL_ALL_BUTTONS_RELEASED;
|
||||||
counter += change;
|
|
||||||
counter &= 0xFFFF;
|
|
||||||
|
|
||||||
unsigned int c = counter;
|
display_load(display_current_frame);
|
||||||
|
|
||||||
write_instruction_byte(0xC4);
|
while (1) {
|
||||||
|
// go to next report
|
||||||
for (int i = 0; i < 5; i++) {
|
if (UB || SWT1 || SWT5) {
|
||||||
int current_digit = c % 10;
|
display_current_frame += 1;
|
||||||
c /= 10;
|
display_current_frame %= LEN(executors)+1;
|
||||||
|
break;
|
||||||
write_data_byte('0' + (char) current_digit);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HAL_Delay(70);
|
// go to previous report
|
||||||
|
else if (SWT3 || SWT4) {
|
||||||
|
display_current_frame -= 1;
|
||||||
|
|
||||||
|
if ((int) display_current_frame == -1)
|
||||||
|
display_current_frame = LEN(executors);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// return to summary frame
|
||||||
|
else if (SWT2) {
|
||||||
|
display_current_frame = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
/* USER CODE END WHILE */
|
/* USER CODE END WHILE */
|
||||||
|
|
||||||
/* USER CODE BEGIN 3 */
|
/* USER CODE BEGIN 3 */
|
||||||
@@ -241,6 +336,14 @@ void SystemClock_Config(void)
|
|||||||
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
|
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
|
||||||
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
|
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
|
||||||
|
|
||||||
|
/** Macro to configure the PLL multiplication factor
|
||||||
|
*/
|
||||||
|
__HAL_RCC_PLL_PLLM_CONFIG(16);
|
||||||
|
|
||||||
|
/** Macro to configure the PLL clock source
|
||||||
|
*/
|
||||||
|
__HAL_RCC_PLL_PLLSOURCE_CONFIG(RCC_PLLSOURCE_HSI);
|
||||||
|
|
||||||
/** Configure the main internal regulator output voltage
|
/** Configure the main internal regulator output voltage
|
||||||
*/
|
*/
|
||||||
__HAL_RCC_PWR_CLK_ENABLE();
|
__HAL_RCC_PWR_CLK_ENABLE();
|
||||||
@@ -253,6 +356,7 @@ void SystemClock_Config(void)
|
|||||||
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
|
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
|
||||||
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
|
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
|
||||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
|
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
|
||||||
|
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
|
||||||
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
||||||
{
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
@@ -273,6 +377,209 @@ void SystemClock_Config(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ADC1 Initialization Function
|
||||||
|
* @param None
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
static void MX_ADC1_Init(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* USER CODE BEGIN ADC1_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE END ADC1_Init 0 */
|
||||||
|
|
||||||
|
ADC_ChannelConfTypeDef sConfig = {0};
|
||||||
|
|
||||||
|
/* USER CODE BEGIN ADC1_Init 1 */
|
||||||
|
|
||||||
|
/* USER CODE END ADC1_Init 1 */
|
||||||
|
|
||||||
|
/** Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion)
|
||||||
|
*/
|
||||||
|
hadc1.Instance = ADC1;
|
||||||
|
hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV2;
|
||||||
|
hadc1.Init.Resolution = ADC_RESOLUTION_12B;
|
||||||
|
hadc1.Init.ScanConvMode = DISABLE;
|
||||||
|
hadc1.Init.ContinuousConvMode = DISABLE;
|
||||||
|
hadc1.Init.DiscontinuousConvMode = DISABLE;
|
||||||
|
hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
|
||||||
|
hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
|
||||||
|
hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
|
||||||
|
hadc1.Init.NbrOfConversion = 1;
|
||||||
|
hadc1.Init.DMAContinuousRequests = DISABLE;
|
||||||
|
hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
|
||||||
|
if (HAL_ADC_Init(&hadc1) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.
|
||||||
|
*/
|
||||||
|
sConfig.Channel = ADC_CHANNEL_9;
|
||||||
|
sConfig.Rank = 1;
|
||||||
|
sConfig.SamplingTime = ADC_SAMPLETIME_480CYCLES;
|
||||||
|
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
/* USER CODE BEGIN ADC1_Init 2 */
|
||||||
|
|
||||||
|
/* USER CODE END ADC1_Init 2 */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief I2C1 Initialization Function
|
||||||
|
* @param None
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
static void MX_I2C1_Init(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* USER CODE BEGIN I2C1_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE END I2C1_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE BEGIN I2C1_Init 1 */
|
||||||
|
|
||||||
|
/* USER CODE END I2C1_Init 1 */
|
||||||
|
hi2c1.Instance = I2C1;
|
||||||
|
hi2c1.Init.ClockSpeed = 100000;
|
||||||
|
hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2;
|
||||||
|
hi2c1.Init.OwnAddress1 = 0;
|
||||||
|
hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
|
||||||
|
hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
|
||||||
|
hi2c1.Init.OwnAddress2 = 0;
|
||||||
|
hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
|
||||||
|
hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
|
||||||
|
if (HAL_I2C_Init(&hi2c1) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
/* USER CODE BEGIN I2C1_Init 2 */
|
||||||
|
|
||||||
|
/* USER CODE END I2C1_Init 2 */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief I2S2 Initialization Function
|
||||||
|
* @param None
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
static void MX_I2S2_Init(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* USER CODE BEGIN I2S2_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE END I2S2_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE BEGIN I2S2_Init 1 */
|
||||||
|
|
||||||
|
/* USER CODE END I2S2_Init 1 */
|
||||||
|
hi2s2.Instance = SPI2;
|
||||||
|
hi2s2.Init.Mode = I2S_MODE_MASTER_RX;
|
||||||
|
hi2s2.Init.Standard = I2S_STANDARD_PHILIPS;
|
||||||
|
hi2s2.Init.DataFormat = I2S_DATAFORMAT_16B;
|
||||||
|
hi2s2.Init.MCLKOutput = I2S_MCLKOUTPUT_DISABLE;
|
||||||
|
hi2s2.Init.AudioFreq = I2S_AUDIOFREQ_48K;
|
||||||
|
hi2s2.Init.CPOL = I2S_CPOL_LOW;
|
||||||
|
hi2s2.Init.ClockSource = I2S_CLOCK_PLL;
|
||||||
|
hi2s2.Init.FullDuplexMode = I2S_FULLDUPLEXMODE_DISABLE;
|
||||||
|
if (HAL_I2S_Init(&hi2s2) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
/* USER CODE BEGIN I2S2_Init 2 */
|
||||||
|
|
||||||
|
/* USER CODE END I2S2_Init 2 */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief SPI1 Initialization Function
|
||||||
|
* @param None
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
static void MX_SPI1_Init(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* USER CODE BEGIN SPI1_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE END SPI1_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE BEGIN SPI1_Init 1 */
|
||||||
|
|
||||||
|
/* USER CODE END SPI1_Init 1 */
|
||||||
|
/* SPI1 parameter configuration*/
|
||||||
|
hspi1.Instance = SPI1;
|
||||||
|
hspi1.Init.Mode = SPI_MODE_MASTER;
|
||||||
|
hspi1.Init.Direction = SPI_DIRECTION_2LINES;
|
||||||
|
hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
|
||||||
|
hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
|
||||||
|
hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
|
||||||
|
hspi1.Init.NSS = SPI_NSS_SOFT;
|
||||||
|
hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16;
|
||||||
|
hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
|
||||||
|
hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
|
||||||
|
hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
|
||||||
|
hspi1.Init.CRCPolynomial = 10;
|
||||||
|
if (HAL_SPI_Init(&hspi1) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
/* USER CODE BEGIN SPI1_Init 2 */
|
||||||
|
|
||||||
|
/* USER CODE END SPI1_Init 2 */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TIM2 Initialization Function
|
||||||
|
* @param None
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
static void MX_TIM2_Init(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* USER CODE BEGIN TIM2_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM2_Init 0 */
|
||||||
|
|
||||||
|
TIM_ClockConfigTypeDef sClockSourceConfig = {0};
|
||||||
|
TIM_MasterConfigTypeDef sMasterConfig = {0};
|
||||||
|
|
||||||
|
/* USER CODE BEGIN TIM2_Init 1 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM2_Init 1 */
|
||||||
|
htim2.Instance = TIM2;
|
||||||
|
htim2.Init.Prescaler = 0;
|
||||||
|
htim2.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||||
|
htim2.Init.Period = 0xffffffff;
|
||||||
|
htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||||
|
htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
||||||
|
if (HAL_TIM_Base_Init(&htim2) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
|
||||||
|
if (HAL_TIM_ConfigClockSource(&htim2, &sClockSourceConfig) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
|
||||||
|
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
|
||||||
|
if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
/* USER CODE BEGIN TIM2_Init 2 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM2_Init 2 */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief GPIO Initialization Function
|
* @brief GPIO Initialization Function
|
||||||
* @param None
|
* @param None
|
||||||
@@ -285,7 +592,9 @@ static void MX_GPIO_Init(void)
|
|||||||
/* USER CODE END MX_GPIO_Init_1 */
|
/* USER CODE END MX_GPIO_Init_1 */
|
||||||
|
|
||||||
/* GPIO Ports Clock Enable */
|
/* GPIO Ports Clock Enable */
|
||||||
|
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||||
|
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||||
__HAL_RCC_GPIOE_CLK_ENABLE();
|
__HAL_RCC_GPIOE_CLK_ENABLE();
|
||||||
__HAL_RCC_GPIOD_CLK_ENABLE();
|
__HAL_RCC_GPIOD_CLK_ENABLE();
|
||||||
|
|
||||||
@@ -294,11 +603,15 @@ static void MX_GPIO_Init(void)
|
|||||||
|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15, GPIO_PIN_RESET);
|
|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15, GPIO_PIN_RESET);
|
||||||
|
|
||||||
/*Configure GPIO pin Output Level */
|
/*Configure GPIO pin Output Level */
|
||||||
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15, GPIO_PIN_RESET);
|
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14
|
||||||
|
|GPIO_PIN_15|GPIO_PIN_4|GPIO_PIN_7, GPIO_PIN_RESET);
|
||||||
|
|
||||||
/*Configure GPIO pin : PA0 */
|
/*Configure GPIO pin Output Level */
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_0;
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_RESET);
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
|
|
||||||
|
/*Configure GPIO pins : PA0 PA15 */
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_15;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
|
|
||||||
@@ -311,16 +624,27 @@ static void MX_GPIO_Init(void)
|
|||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||||
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
|
||||||
|
|
||||||
/*Configure GPIO pins : PD12 PD13 PD14 PD15 */
|
/*Configure GPIO pins : PD11 PD12 PD13 PD14
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15;
|
PD15 PD4 PD7 */
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14
|
||||||
|
|GPIO_PIN_15|GPIO_PIN_4|GPIO_PIN_7;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||||
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
||||||
|
|
||||||
/* EXTI interrupt init*/
|
/*Configure GPIO pins : PC6 PC8 PC9 PC11 */
|
||||||
HAL_NVIC_SetPriority(EXTI0_IRQn, 0, 0);
|
GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_11;
|
||||||
HAL_NVIC_EnableIRQ(EXTI0_IRQn);
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/*Configure GPIO pin : PB7 */
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_7;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||||
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||||
|
|
||||||
/* USER CODE BEGIN MX_GPIO_Init_2 */
|
/* USER CODE BEGIN MX_GPIO_Init_2 */
|
||||||
/* USER CODE END MX_GPIO_Init_2 */
|
/* USER CODE END MX_GPIO_Init_2 */
|
||||||
|
|||||||
@@ -78,6 +78,349 @@ void HAL_MspInit(void)
|
|||||||
/* USER CODE END MspInit 1 */
|
/* USER CODE END MspInit 1 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ADC MSP Initialization
|
||||||
|
* This function configures the hardware resources used in this example
|
||||||
|
* @param hadc: ADC handle pointer
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc)
|
||||||
|
{
|
||||||
|
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||||
|
if(hadc->Instance==ADC1)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN ADC1_MspInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END ADC1_MspInit 0 */
|
||||||
|
/* Peripheral clock enable */
|
||||||
|
__HAL_RCC_ADC1_CLK_ENABLE();
|
||||||
|
|
||||||
|
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||||
|
/**ADC1 GPIO Configuration
|
||||||
|
PB1 ------> ADC1_IN9
|
||||||
|
*/
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_1;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN ADC1_MspInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END ADC1_MspInit 1 */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ADC MSP De-Initialization
|
||||||
|
* This function freeze the hardware resources used in this example
|
||||||
|
* @param hadc: ADC handle pointer
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc)
|
||||||
|
{
|
||||||
|
if(hadc->Instance==ADC1)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN ADC1_MspDeInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END ADC1_MspDeInit 0 */
|
||||||
|
/* Peripheral clock disable */
|
||||||
|
__HAL_RCC_ADC1_CLK_DISABLE();
|
||||||
|
|
||||||
|
/**ADC1 GPIO Configuration
|
||||||
|
PB1 ------> ADC1_IN9
|
||||||
|
*/
|
||||||
|
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_1);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN ADC1_MspDeInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END ADC1_MspDeInit 1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief I2C MSP Initialization
|
||||||
|
* This function configures the hardware resources used in this example
|
||||||
|
* @param hi2c: I2C handle pointer
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c)
|
||||||
|
{
|
||||||
|
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||||
|
if(hi2c->Instance==I2C1)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN I2C1_MspInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END I2C1_MspInit 0 */
|
||||||
|
|
||||||
|
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||||
|
/**I2C1 GPIO Configuration
|
||||||
|
PB6 ------> I2C1_SCL
|
||||||
|
PB9 ------> I2C1_SDA
|
||||||
|
*/
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_9;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||||
|
GPIO_InitStruct.Alternate = GPIO_AF4_I2C1;
|
||||||
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/* Peripheral clock enable */
|
||||||
|
__HAL_RCC_I2C1_CLK_ENABLE();
|
||||||
|
/* USER CODE BEGIN I2C1_MspInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END I2C1_MspInit 1 */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief I2C MSP De-Initialization
|
||||||
|
* This function freeze the hardware resources used in this example
|
||||||
|
* @param hi2c: I2C handle pointer
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void HAL_I2C_MspDeInit(I2C_HandleTypeDef* hi2c)
|
||||||
|
{
|
||||||
|
if(hi2c->Instance==I2C1)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN I2C1_MspDeInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END I2C1_MspDeInit 0 */
|
||||||
|
/* Peripheral clock disable */
|
||||||
|
__HAL_RCC_I2C1_CLK_DISABLE();
|
||||||
|
|
||||||
|
/**I2C1 GPIO Configuration
|
||||||
|
PB6 ------> I2C1_SCL
|
||||||
|
PB9 ------> I2C1_SDA
|
||||||
|
*/
|
||||||
|
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_6);
|
||||||
|
|
||||||
|
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_9);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN I2C1_MspDeInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END I2C1_MspDeInit 1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief I2S MSP Initialization
|
||||||
|
* This function configures the hardware resources used in this example
|
||||||
|
* @param hi2s: I2S handle pointer
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void HAL_I2S_MspInit(I2S_HandleTypeDef* hi2s)
|
||||||
|
{
|
||||||
|
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||||
|
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
|
||||||
|
if(hi2s->Instance==SPI2)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN SPI2_MspInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END SPI2_MspInit 0 */
|
||||||
|
|
||||||
|
/** Initializes the peripherals clock
|
||||||
|
*/
|
||||||
|
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_I2S;
|
||||||
|
PeriphClkInitStruct.PLLI2S.PLLI2SN = 192;
|
||||||
|
PeriphClkInitStruct.PLLI2S.PLLI2SR = 2;
|
||||||
|
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Peripheral clock enable */
|
||||||
|
__HAL_RCC_SPI2_CLK_ENABLE();
|
||||||
|
|
||||||
|
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||||
|
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||||
|
/**I2S2 GPIO Configuration
|
||||||
|
PC3 ------> I2S2_SD
|
||||||
|
PB10 ------> I2S2_CK
|
||||||
|
PB12 ------> I2S2_WS
|
||||||
|
*/
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_3;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||||
|
GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
|
||||||
|
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_12;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||||
|
GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
|
||||||
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN SPI2_MspInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END SPI2_MspInit 1 */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief I2S MSP De-Initialization
|
||||||
|
* This function freeze the hardware resources used in this example
|
||||||
|
* @param hi2s: I2S handle pointer
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void HAL_I2S_MspDeInit(I2S_HandleTypeDef* hi2s)
|
||||||
|
{
|
||||||
|
if(hi2s->Instance==SPI2)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN SPI2_MspDeInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END SPI2_MspDeInit 0 */
|
||||||
|
/* Peripheral clock disable */
|
||||||
|
__HAL_RCC_SPI2_CLK_DISABLE();
|
||||||
|
|
||||||
|
/**I2S2 GPIO Configuration
|
||||||
|
PC3 ------> I2S2_SD
|
||||||
|
PB10 ------> I2S2_CK
|
||||||
|
PB12 ------> I2S2_WS
|
||||||
|
*/
|
||||||
|
HAL_GPIO_DeInit(GPIOC, GPIO_PIN_3);
|
||||||
|
|
||||||
|
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_10|GPIO_PIN_12);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN SPI2_MspDeInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END SPI2_MspDeInit 1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief SPI MSP Initialization
|
||||||
|
* This function configures the hardware resources used in this example
|
||||||
|
* @param hspi: SPI handle pointer
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
|
||||||
|
{
|
||||||
|
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||||
|
if(hspi->Instance==SPI1)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN SPI1_MspInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END SPI1_MspInit 0 */
|
||||||
|
/* Peripheral clock enable */
|
||||||
|
__HAL_RCC_SPI1_CLK_ENABLE();
|
||||||
|
|
||||||
|
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||||
|
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||||
|
/**SPI1 GPIO Configuration
|
||||||
|
PA5 ------> SPI1_SCK
|
||||||
|
PB4 ------> SPI1_MISO
|
||||||
|
PB5 ------> SPI1_MOSI
|
||||||
|
*/
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_5;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||||
|
GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;
|
||||||
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||||
|
GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;
|
||||||
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN SPI1_MspInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END SPI1_MspInit 1 */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief SPI MSP De-Initialization
|
||||||
|
* This function freeze the hardware resources used in this example
|
||||||
|
* @param hspi: SPI handle pointer
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)
|
||||||
|
{
|
||||||
|
if(hspi->Instance==SPI1)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN SPI1_MspDeInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END SPI1_MspDeInit 0 */
|
||||||
|
/* Peripheral clock disable */
|
||||||
|
__HAL_RCC_SPI1_CLK_DISABLE();
|
||||||
|
|
||||||
|
/**SPI1 GPIO Configuration
|
||||||
|
PA5 ------> SPI1_SCK
|
||||||
|
PB4 ------> SPI1_MISO
|
||||||
|
PB5 ------> SPI1_MOSI
|
||||||
|
*/
|
||||||
|
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5);
|
||||||
|
|
||||||
|
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_4|GPIO_PIN_5);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN SPI1_MspDeInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END SPI1_MspDeInit 1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TIM_Base MSP Initialization
|
||||||
|
* This function configures the hardware resources used in this example
|
||||||
|
* @param htim_base: TIM_Base handle pointer
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
|
||||||
|
{
|
||||||
|
if(htim_base->Instance==TIM2)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN TIM2_MspInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM2_MspInit 0 */
|
||||||
|
/* Peripheral clock enable */
|
||||||
|
__HAL_RCC_TIM2_CLK_ENABLE();
|
||||||
|
/* USER CODE BEGIN TIM2_MspInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM2_MspInit 1 */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TIM_Base MSP De-Initialization
|
||||||
|
* This function freeze the hardware resources used in this example
|
||||||
|
* @param htim_base: TIM_Base handle pointer
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base)
|
||||||
|
{
|
||||||
|
if(htim_base->Instance==TIM2)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN TIM2_MspDeInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM2_MspDeInit 0 */
|
||||||
|
/* Peripheral clock disable */
|
||||||
|
__HAL_RCC_TIM2_CLK_DISABLE();
|
||||||
|
/* USER CODE BEGIN TIM2_MspDeInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM2_MspDeInit 1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/* USER CODE BEGIN 1 */
|
/* USER CODE BEGIN 1 */
|
||||||
|
|
||||||
/* USER CODE END 1 */
|
/* USER CODE END 1 */
|
||||||
|
|||||||
+28
-19
@@ -41,12 +41,12 @@
|
|||||||
|
|
||||||
/* Private variables ---------------------------------------------------------*/
|
/* Private variables ---------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN PV */
|
/* USER CODE BEGIN PV */
|
||||||
extern int change;
|
extern size_t current_executor_id;
|
||||||
/* USER CODE END PV */
|
/* USER CODE END PV */
|
||||||
|
|
||||||
/* Private function prototypes -----------------------------------------------*/
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
/* USER CODE BEGIN PFP */
|
/* USER CODE BEGIN PFP */
|
||||||
|
void switch_to_next_test(void);
|
||||||
/* USER CODE END PFP */
|
/* USER CODE END PFP */
|
||||||
|
|
||||||
/* Private user code ---------------------------------------------------------*/
|
/* Private user code ---------------------------------------------------------*/
|
||||||
@@ -198,23 +198,32 @@ void SysTick_Handler(void)
|
|||||||
/* please refer to the startup file (startup_stm32f4xx.s). */
|
/* please refer to the startup file (startup_stm32f4xx.s). */
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This function handles EXTI line0 interrupt.
|
|
||||||
*/
|
|
||||||
void EXTI0_IRQHandler(void)
|
|
||||||
{
|
|
||||||
/* USER CODE BEGIN EXTI0_IRQn 0 */
|
|
||||||
|
|
||||||
change *= -1;
|
|
||||||
|
|
||||||
for (int i = 0; i < 200000; i++) {asm("nop");}
|
|
||||||
/* USER CODE END EXTI0_IRQn 0 */
|
|
||||||
HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_0);
|
|
||||||
/* USER CODE BEGIN EXTI0_IRQn 1 */
|
|
||||||
|
|
||||||
/* USER CODE END EXTI0_IRQn 1 */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* USER CODE BEGIN 1 */
|
/* USER CODE BEGIN 1 */
|
||||||
|
|
||||||
|
void EXTI0_IRQHandler(void)
|
||||||
|
{
|
||||||
|
GPIOD->ODR = 0x1000;
|
||||||
|
|
||||||
|
//switch_to_next_test();
|
||||||
|
|
||||||
|
for (int i = 300000; i > 0; i--) asm("nop");
|
||||||
|
|
||||||
|
GPIOD->ODR = 0x0000;
|
||||||
|
|
||||||
|
HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EXTI9_5_IRQHandler(void)
|
||||||
|
{
|
||||||
|
GPIOD->ODR = 0x1000;
|
||||||
|
|
||||||
|
//switch_to_next_test();
|
||||||
|
|
||||||
|
for (int i = 300000; i > 0; i--) asm("nop");
|
||||||
|
|
||||||
|
GPIOD->ODR = 0x0000;
|
||||||
|
|
||||||
|
HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_8);
|
||||||
|
}
|
||||||
|
|
||||||
/* USER CODE END 1 */
|
/* USER CODE END 1 */
|
||||||
|
|||||||
@@ -5,6 +5,15 @@
|
|||||||
|
|
||||||
# Add inputs and outputs from these tool invocations to the build variables
|
# Add inputs and outputs from these tool invocations to the build variables
|
||||||
C_SRCS += \
|
C_SRCS += \
|
||||||
|
../Core/Src/24AA02E48.c \
|
||||||
|
../Core/Src/CS43L22.c \
|
||||||
|
../Core/Src/DNI.c \
|
||||||
|
../Core/Src/LIS302DL.c \
|
||||||
|
../Core/Src/LSM9DS1.c \
|
||||||
|
../Core/Src/MP45DT02.c \
|
||||||
|
../Core/Src/PCA9685.c \
|
||||||
|
../Core/Src/SST25VF016B.c \
|
||||||
|
../Core/Src/lcd.c \
|
||||||
../Core/Src/main.c \
|
../Core/Src/main.c \
|
||||||
../Core/Src/stm32f4xx_hal_msp.c \
|
../Core/Src/stm32f4xx_hal_msp.c \
|
||||||
../Core/Src/stm32f4xx_it.c \
|
../Core/Src/stm32f4xx_it.c \
|
||||||
@@ -13,6 +22,15 @@ C_SRCS += \
|
|||||||
../Core/Src/system_stm32f4xx.c
|
../Core/Src/system_stm32f4xx.c
|
||||||
|
|
||||||
OBJS += \
|
OBJS += \
|
||||||
|
./Core/Src/24AA02E48.o \
|
||||||
|
./Core/Src/CS43L22.o \
|
||||||
|
./Core/Src/DNI.o \
|
||||||
|
./Core/Src/LIS302DL.o \
|
||||||
|
./Core/Src/LSM9DS1.o \
|
||||||
|
./Core/Src/MP45DT02.o \
|
||||||
|
./Core/Src/PCA9685.o \
|
||||||
|
./Core/Src/SST25VF016B.o \
|
||||||
|
./Core/Src/lcd.o \
|
||||||
./Core/Src/main.o \
|
./Core/Src/main.o \
|
||||||
./Core/Src/stm32f4xx_hal_msp.o \
|
./Core/Src/stm32f4xx_hal_msp.o \
|
||||||
./Core/Src/stm32f4xx_it.o \
|
./Core/Src/stm32f4xx_it.o \
|
||||||
@@ -21,6 +39,15 @@ OBJS += \
|
|||||||
./Core/Src/system_stm32f4xx.o
|
./Core/Src/system_stm32f4xx.o
|
||||||
|
|
||||||
C_DEPS += \
|
C_DEPS += \
|
||||||
|
./Core/Src/24AA02E48.d \
|
||||||
|
./Core/Src/CS43L22.d \
|
||||||
|
./Core/Src/DNI.d \
|
||||||
|
./Core/Src/LIS302DL.d \
|
||||||
|
./Core/Src/LSM9DS1.d \
|
||||||
|
./Core/Src/MP45DT02.d \
|
||||||
|
./Core/Src/PCA9685.d \
|
||||||
|
./Core/Src/SST25VF016B.d \
|
||||||
|
./Core/Src/lcd.d \
|
||||||
./Core/Src/main.d \
|
./Core/Src/main.d \
|
||||||
./Core/Src/stm32f4xx_hal_msp.d \
|
./Core/Src/stm32f4xx_hal_msp.d \
|
||||||
./Core/Src/stm32f4xx_it.d \
|
./Core/Src/stm32f4xx_it.d \
|
||||||
@@ -36,7 +63,7 @@ Core/Src/%.o Core/Src/%.su Core/Src/%.cyclo: ../Core/Src/%.c Core/Src/subdir.mk
|
|||||||
clean: clean-Core-2f-Src
|
clean: clean-Core-2f-Src
|
||||||
|
|
||||||
clean-Core-2f-Src:
|
clean-Core-2f-Src:
|
||||||
-$(RM) ./Core/Src/main.cyclo ./Core/Src/main.d ./Core/Src/main.o ./Core/Src/main.su ./Core/Src/stm32f4xx_hal_msp.cyclo ./Core/Src/stm32f4xx_hal_msp.d ./Core/Src/stm32f4xx_hal_msp.o ./Core/Src/stm32f4xx_hal_msp.su ./Core/Src/stm32f4xx_it.cyclo ./Core/Src/stm32f4xx_it.d ./Core/Src/stm32f4xx_it.o ./Core/Src/stm32f4xx_it.su ./Core/Src/syscalls.cyclo ./Core/Src/syscalls.d ./Core/Src/syscalls.o ./Core/Src/syscalls.su ./Core/Src/sysmem.cyclo ./Core/Src/sysmem.d ./Core/Src/sysmem.o ./Core/Src/sysmem.su ./Core/Src/system_stm32f4xx.cyclo ./Core/Src/system_stm32f4xx.d ./Core/Src/system_stm32f4xx.o ./Core/Src/system_stm32f4xx.su
|
-$(RM) ./Core/Src/24AA02E48.cyclo ./Core/Src/24AA02E48.d ./Core/Src/24AA02E48.o ./Core/Src/24AA02E48.su ./Core/Src/CS43L22.cyclo ./Core/Src/CS43L22.d ./Core/Src/CS43L22.o ./Core/Src/CS43L22.su ./Core/Src/DNI.cyclo ./Core/Src/DNI.d ./Core/Src/DNI.o ./Core/Src/DNI.su ./Core/Src/LIS302DL.cyclo ./Core/Src/LIS302DL.d ./Core/Src/LIS302DL.o ./Core/Src/LIS302DL.su ./Core/Src/LSM9DS1.cyclo ./Core/Src/LSM9DS1.d ./Core/Src/LSM9DS1.o ./Core/Src/LSM9DS1.su ./Core/Src/MP45DT02.cyclo ./Core/Src/MP45DT02.d ./Core/Src/MP45DT02.o ./Core/Src/MP45DT02.su ./Core/Src/PCA9685.cyclo ./Core/Src/PCA9685.d ./Core/Src/PCA9685.o ./Core/Src/PCA9685.su ./Core/Src/SST25VF016B.cyclo ./Core/Src/SST25VF016B.d ./Core/Src/SST25VF016B.o ./Core/Src/SST25VF016B.su ./Core/Src/lcd.cyclo ./Core/Src/lcd.d ./Core/Src/lcd.o ./Core/Src/lcd.su ./Core/Src/main.cyclo ./Core/Src/main.d ./Core/Src/main.o ./Core/Src/main.su ./Core/Src/stm32f4xx_hal_msp.cyclo ./Core/Src/stm32f4xx_hal_msp.d ./Core/Src/stm32f4xx_hal_msp.o ./Core/Src/stm32f4xx_hal_msp.su ./Core/Src/stm32f4xx_it.cyclo ./Core/Src/stm32f4xx_it.d ./Core/Src/stm32f4xx_it.o ./Core/Src/stm32f4xx_it.su ./Core/Src/syscalls.cyclo ./Core/Src/syscalls.d ./Core/Src/syscalls.o ./Core/Src/syscalls.su ./Core/Src/sysmem.cyclo ./Core/Src/sysmem.d ./Core/Src/sysmem.o ./Core/Src/sysmem.su ./Core/Src/system_stm32f4xx.cyclo ./Core/Src/system_stm32f4xx.d ./Core/Src/system_stm32f4xx.o ./Core/Src/system_stm32f4xx.su
|
||||||
|
|
||||||
.PHONY: clean-Core-2f-Src
|
.PHONY: clean-Core-2f-Src
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1,3 +1,12 @@
|
|||||||
|
"./Core/Src/24AA02E48.o"
|
||||||
|
"./Core/Src/CS43L22.o"
|
||||||
|
"./Core/Src/DNI.o"
|
||||||
|
"./Core/Src/LIS302DL.o"
|
||||||
|
"./Core/Src/LSM9DS1.o"
|
||||||
|
"./Core/Src/MP45DT02.o"
|
||||||
|
"./Core/Src/PCA9685.o"
|
||||||
|
"./Core/Src/SST25VF016B.o"
|
||||||
|
"./Core/Src/lcd.o"
|
||||||
"./Core/Src/main.o"
|
"./Core/Src/main.o"
|
||||||
"./Core/Src/stm32f4xx_hal_msp.o"
|
"./Core/Src/stm32f4xx_hal_msp.o"
|
||||||
"./Core/Src/stm32f4xx_it.o"
|
"./Core/Src/stm32f4xx_it.o"
|
||||||
@@ -6,6 +15,8 @@
|
|||||||
"./Core/Src/system_stm32f4xx.o"
|
"./Core/Src/system_stm32f4xx.o"
|
||||||
"./Core/Startup/startup_stm32f407vgtx.o"
|
"./Core/Startup/startup_stm32f407vgtx.o"
|
||||||
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.o"
|
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.o"
|
||||||
|
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc.o"
|
||||||
|
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc_ex.o"
|
||||||
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.o"
|
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.o"
|
||||||
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.o"
|
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.o"
|
||||||
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.o"
|
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.o"
|
||||||
@@ -14,7 +25,15 @@
|
|||||||
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.o"
|
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.o"
|
||||||
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.o"
|
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.o"
|
||||||
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.o"
|
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.o"
|
||||||
|
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.o"
|
||||||
|
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c_ex.o"
|
||||||
|
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2s.o"
|
||||||
|
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2s_ex.o"
|
||||||
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.o"
|
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.o"
|
||||||
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.o"
|
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.o"
|
||||||
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.o"
|
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.o"
|
||||||
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.o"
|
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.o"
|
||||||
|
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.o"
|
||||||
|
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.o"
|
||||||
|
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.o"
|
||||||
|
"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_adc.o"
|
||||||
|
|||||||
@@ -0,0 +1,898 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file stm32f4xx_hal_adc.h
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief Header file containing functions prototypes of ADC HAL library.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2017 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __STM32F4xx_ADC_H
|
||||||
|
#define __STM32F4xx_ADC_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "stm32f4xx_hal_def.h"
|
||||||
|
|
||||||
|
/* Include low level driver */
|
||||||
|
#include "stm32f4xx_ll_adc.h"
|
||||||
|
|
||||||
|
/** @addtogroup STM32F4xx_HAL_Driver
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup ADC
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Exported types ------------------------------------------------------------*/
|
||||||
|
/** @defgroup ADC_Exported_Types ADC Exported Types
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Structure definition of ADC and regular group initialization
|
||||||
|
* @note Parameters of this structure are shared within 2 scopes:
|
||||||
|
* - Scope entire ADC (affects regular and injected groups): ClockPrescaler, Resolution, ScanConvMode, DataAlign, ScanConvMode, EOCSelection, LowPowerAutoWait, LowPowerAutoPowerOff, ChannelsBank.
|
||||||
|
* - Scope regular group: ContinuousConvMode, NbrOfConversion, DiscontinuousConvMode, NbrOfDiscConversion, ExternalTrigConvEdge, ExternalTrigConv.
|
||||||
|
* @note The setting of these parameters with function HAL_ADC_Init() is conditioned to ADC state.
|
||||||
|
* ADC state can be either:
|
||||||
|
* - For all parameters: ADC disabled
|
||||||
|
* - For all parameters except 'Resolution', 'ScanConvMode', 'DiscontinuousConvMode', 'NbrOfDiscConversion' : ADC enabled without conversion on going on regular group.
|
||||||
|
* - For parameters 'ExternalTrigConv' and 'ExternalTrigConvEdge': ADC enabled, even with conversion on going.
|
||||||
|
* If ADC is not in the appropriate state to modify some parameters, these parameters setting is bypassed
|
||||||
|
* without error reporting (as it can be the expected behaviour in case of intended action to update another parameter (which fulfills the ADC state condition) on the fly).
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32_t ClockPrescaler; /*!< Select ADC clock prescaler. The clock is common for
|
||||||
|
all the ADCs.
|
||||||
|
This parameter can be a value of @ref ADC_ClockPrescaler */
|
||||||
|
uint32_t Resolution; /*!< Configures the ADC resolution.
|
||||||
|
This parameter can be a value of @ref ADC_Resolution */
|
||||||
|
uint32_t DataAlign; /*!< Specifies ADC data alignment to right (MSB on register bit 11 and LSB on register bit 0) (default setting)
|
||||||
|
or to left (if regular group: MSB on register bit 15 and LSB on register bit 4, if injected group (MSB kept as signed value due to potential negative value after offset application): MSB on register bit 14 and LSB on register bit 3).
|
||||||
|
This parameter can be a value of @ref ADC_Data_align */
|
||||||
|
uint32_t ScanConvMode; /*!< Configures the sequencer of regular and injected groups.
|
||||||
|
This parameter can be associated to parameter 'DiscontinuousConvMode' to have main sequence subdivided in successive parts.
|
||||||
|
If disabled: Conversion is performed in single mode (one channel converted, the one defined in rank 1).
|
||||||
|
Parameters 'NbrOfConversion' and 'InjectedNbrOfConversion' are discarded (equivalent to set to 1).
|
||||||
|
If enabled: Conversions are performed in sequence mode (multiple ranks defined by 'NbrOfConversion'/'InjectedNbrOfConversion' and each channel rank).
|
||||||
|
Scan direction is upward: from rank1 to rank 'n'.
|
||||||
|
This parameter can be set to ENABLE or DISABLE */
|
||||||
|
uint32_t EOCSelection; /*!< Specifies what EOC (End Of Conversion) flag is used for conversion by polling and interruption: end of conversion of each rank or complete sequence.
|
||||||
|
This parameter can be a value of @ref ADC_EOCSelection.
|
||||||
|
Note: For injected group, end of conversion (flag&IT) is raised only at the end of the sequence.
|
||||||
|
Therefore, if end of conversion is set to end of each conversion, injected group should not be used with interruption (HAL_ADCEx_InjectedStart_IT)
|
||||||
|
or polling (HAL_ADCEx_InjectedStart and HAL_ADCEx_InjectedPollForConversion). By the way, polling is still possible since driver will use an estimated timing for end of injected conversion.
|
||||||
|
Note: If overrun feature is intended to be used, use ADC in mode 'interruption' (function HAL_ADC_Start_IT() ) with parameter EOCSelection set to end of each conversion or in mode 'transfer by DMA' (function HAL_ADC_Start_DMA()).
|
||||||
|
If overrun feature is intended to be bypassed, use ADC in mode 'polling' or 'interruption' with parameter EOCSelection must be set to end of sequence */
|
||||||
|
FunctionalState ContinuousConvMode; /*!< Specifies whether the conversion is performed in single mode (one conversion) or continuous mode for regular group,
|
||||||
|
after the selected trigger occurred (software start or external trigger).
|
||||||
|
This parameter can be set to ENABLE or DISABLE. */
|
||||||
|
uint32_t NbrOfConversion; /*!< Specifies the number of ranks that will be converted within the regular group sequencer.
|
||||||
|
To use regular group sequencer and convert several ranks, parameter 'ScanConvMode' must be enabled.
|
||||||
|
This parameter must be a number between Min_Data = 1 and Max_Data = 16. */
|
||||||
|
FunctionalState DiscontinuousConvMode; /*!< Specifies whether the conversions sequence of regular group is performed in Complete-sequence/Discontinuous-sequence (main sequence subdivided in successive parts).
|
||||||
|
Discontinuous mode is used only if sequencer is enabled (parameter 'ScanConvMode'). If sequencer is disabled, this parameter is discarded.
|
||||||
|
Discontinuous mode can be enabled only if continuous mode is disabled. If continuous mode is enabled, this parameter setting is discarded.
|
||||||
|
This parameter can be set to ENABLE or DISABLE. */
|
||||||
|
uint32_t NbrOfDiscConversion; /*!< Specifies the number of discontinuous conversions in which the main sequence of regular group (parameter NbrOfConversion) will be subdivided.
|
||||||
|
If parameter 'DiscontinuousConvMode' is disabled, this parameter is discarded.
|
||||||
|
This parameter must be a number between Min_Data = 1 and Max_Data = 8. */
|
||||||
|
uint32_t ExternalTrigConv; /*!< Selects the external event used to trigger the conversion start of regular group.
|
||||||
|
If set to ADC_SOFTWARE_START, external triggers are disabled.
|
||||||
|
If set to external trigger source, triggering is on event rising edge by default.
|
||||||
|
This parameter can be a value of @ref ADC_External_trigger_Source_Regular */
|
||||||
|
uint32_t ExternalTrigConvEdge; /*!< Selects the external trigger edge of regular group.
|
||||||
|
If trigger is set to ADC_SOFTWARE_START, this parameter is discarded.
|
||||||
|
This parameter can be a value of @ref ADC_External_trigger_edge_Regular */
|
||||||
|
FunctionalState DMAContinuousRequests; /*!< Specifies whether the DMA requests are performed in one shot mode (DMA transfer stop when number of conversions is reached)
|
||||||
|
or in Continuous mode (DMA transfer unlimited, whatever number of conversions).
|
||||||
|
Note: In continuous mode, DMA must be configured in circular mode. Otherwise an overrun will be triggered when DMA buffer maximum pointer is reached.
|
||||||
|
Note: This parameter must be modified when no conversion is on going on both regular and injected groups (ADC disabled, or ADC enabled without continuous mode or external trigger that could launch a conversion).
|
||||||
|
This parameter can be set to ENABLE or DISABLE. */
|
||||||
|
} ADC_InitTypeDef;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Structure definition of ADC channel for regular group
|
||||||
|
* @note The setting of these parameters with function HAL_ADC_ConfigChannel() is conditioned to ADC state.
|
||||||
|
* ADC can be either disabled or enabled without conversion on going on regular group.
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32_t Channel; /*!< Specifies the channel to configure into ADC regular group.
|
||||||
|
This parameter can be a value of @ref ADC_channels */
|
||||||
|
uint32_t Rank; /*!< Specifies the rank in the regular group sequencer.
|
||||||
|
This parameter must be a number between Min_Data = 1 and Max_Data = 16 */
|
||||||
|
uint32_t SamplingTime; /*!< Sampling time value to be set for the selected channel.
|
||||||
|
Unit: ADC clock cycles
|
||||||
|
Conversion time is the addition of sampling time and processing time (12 ADC clock cycles at ADC resolution 12 bits, 11 cycles at 10 bits, 9 cycles at 8 bits, 7 cycles at 6 bits).
|
||||||
|
This parameter can be a value of @ref ADC_sampling_times
|
||||||
|
Caution: This parameter updates the parameter property of the channel, that can be used into regular and/or injected groups.
|
||||||
|
If this same channel has been previously configured in the other group (regular/injected), it will be updated to last setting.
|
||||||
|
Note: In case of usage of internal measurement channels (VrefInt/Vbat/TempSensor),
|
||||||
|
sampling time constraints must be respected (sampling time can be adjusted in function of ADC clock frequency and sampling time setting)
|
||||||
|
Refer to device datasheet for timings values, parameters TS_vrefint, TS_temp (values rough order: 4us min). */
|
||||||
|
uint32_t Offset; /*!< Reserved for future use, can be set to 0 */
|
||||||
|
} ADC_ChannelConfTypeDef;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ADC Configuration multi-mode structure definition
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32_t WatchdogMode; /*!< Configures the ADC analog watchdog mode.
|
||||||
|
This parameter can be a value of @ref ADC_analog_watchdog_selection */
|
||||||
|
uint32_t HighThreshold; /*!< Configures the ADC analog watchdog High threshold value.
|
||||||
|
This parameter must be a 12-bit value. */
|
||||||
|
uint32_t LowThreshold; /*!< Configures the ADC analog watchdog High threshold value.
|
||||||
|
This parameter must be a 12-bit value. */
|
||||||
|
uint32_t Channel; /*!< Configures ADC channel for the analog watchdog.
|
||||||
|
This parameter has an effect only if watchdog mode is configured on single channel
|
||||||
|
This parameter can be a value of @ref ADC_channels */
|
||||||
|
FunctionalState ITMode; /*!< Specifies whether the analog watchdog is configured
|
||||||
|
is interrupt mode or in polling mode.
|
||||||
|
This parameter can be set to ENABLE or DISABLE */
|
||||||
|
uint32_t WatchdogNumber; /*!< Reserved for future use, can be set to 0 */
|
||||||
|
} ADC_AnalogWDGConfTypeDef;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief HAL ADC state machine: ADC states definition (bitfields)
|
||||||
|
*/
|
||||||
|
/* States of ADC global scope */
|
||||||
|
#define HAL_ADC_STATE_RESET 0x00000000U /*!< ADC not yet initialized or disabled */
|
||||||
|
#define HAL_ADC_STATE_READY 0x00000001U /*!< ADC peripheral ready for use */
|
||||||
|
#define HAL_ADC_STATE_BUSY_INTERNAL 0x00000002U /*!< ADC is busy to internal process (initialization, calibration) */
|
||||||
|
#define HAL_ADC_STATE_TIMEOUT 0x00000004U /*!< TimeOut occurrence */
|
||||||
|
|
||||||
|
/* States of ADC errors */
|
||||||
|
#define HAL_ADC_STATE_ERROR_INTERNAL 0x00000010U /*!< Internal error occurrence */
|
||||||
|
#define HAL_ADC_STATE_ERROR_CONFIG 0x00000020U /*!< Configuration error occurrence */
|
||||||
|
#define HAL_ADC_STATE_ERROR_DMA 0x00000040U /*!< DMA error occurrence */
|
||||||
|
|
||||||
|
/* States of ADC group regular */
|
||||||
|
#define HAL_ADC_STATE_REG_BUSY 0x00000100U /*!< A conversion on group regular is ongoing or can occur (either by continuous mode,
|
||||||
|
external trigger, low power auto power-on (if feature available), multimode ADC master control (if feature available)) */
|
||||||
|
#define HAL_ADC_STATE_REG_EOC 0x00000200U /*!< Conversion data available on group regular */
|
||||||
|
#define HAL_ADC_STATE_REG_OVR 0x00000400U /*!< Overrun occurrence */
|
||||||
|
|
||||||
|
/* States of ADC group injected */
|
||||||
|
#define HAL_ADC_STATE_INJ_BUSY 0x00001000U /*!< A conversion on group injected is ongoing or can occur (either by auto-injection mode,
|
||||||
|
external trigger, low power auto power-on (if feature available), multimode ADC master control (if feature available)) */
|
||||||
|
#define HAL_ADC_STATE_INJ_EOC 0x00002000U /*!< Conversion data available on group injected */
|
||||||
|
|
||||||
|
/* States of ADC analog watchdogs */
|
||||||
|
#define HAL_ADC_STATE_AWD1 0x00010000U /*!< Out-of-window occurrence of analog watchdog 1 */
|
||||||
|
#define HAL_ADC_STATE_AWD2 0x00020000U /*!< Not available on STM32F4 device: Out-of-window occurrence of analog watchdog 2 */
|
||||||
|
#define HAL_ADC_STATE_AWD3 0x00040000U /*!< Not available on STM32F4 device: Out-of-window occurrence of analog watchdog 3 */
|
||||||
|
|
||||||
|
/* States of ADC multi-mode */
|
||||||
|
#define HAL_ADC_STATE_MULTIMODE_SLAVE 0x00100000U /*!< Not available on STM32F4 device: ADC in multimode slave state, controlled by another ADC master ( */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ADC handle Structure definition
|
||||||
|
*/
|
||||||
|
#if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
|
||||||
|
typedef struct __ADC_HandleTypeDef
|
||||||
|
#else
|
||||||
|
typedef struct
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
ADC_TypeDef *Instance; /*!< Register base address */
|
||||||
|
|
||||||
|
ADC_InitTypeDef Init; /*!< ADC required parameters */
|
||||||
|
|
||||||
|
__IO uint32_t NbrOfCurrentConversionRank; /*!< ADC number of current conversion rank */
|
||||||
|
|
||||||
|
DMA_HandleTypeDef *DMA_Handle; /*!< Pointer DMA Handler */
|
||||||
|
|
||||||
|
HAL_LockTypeDef Lock; /*!< ADC locking object */
|
||||||
|
|
||||||
|
__IO uint32_t State; /*!< ADC communication state */
|
||||||
|
|
||||||
|
__IO uint32_t ErrorCode; /*!< ADC Error code */
|
||||||
|
#if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
|
||||||
|
void (* ConvCpltCallback)(struct __ADC_HandleTypeDef *hadc); /*!< ADC conversion complete callback */
|
||||||
|
void (* ConvHalfCpltCallback)(struct __ADC_HandleTypeDef *hadc); /*!< ADC conversion DMA half-transfer callback */
|
||||||
|
void (* LevelOutOfWindowCallback)(struct __ADC_HandleTypeDef *hadc); /*!< ADC analog watchdog 1 callback */
|
||||||
|
void (* ErrorCallback)(struct __ADC_HandleTypeDef *hadc); /*!< ADC error callback */
|
||||||
|
void (* InjectedConvCpltCallback)(struct __ADC_HandleTypeDef *hadc); /*!< ADC group injected conversion complete callback */
|
||||||
|
void (* MspInitCallback)(struct __ADC_HandleTypeDef *hadc); /*!< ADC Msp Init callback */
|
||||||
|
void (* MspDeInitCallback)(struct __ADC_HandleTypeDef *hadc); /*!< ADC Msp DeInit callback */
|
||||||
|
#endif /* USE_HAL_ADC_REGISTER_CALLBACKS */
|
||||||
|
} ADC_HandleTypeDef;
|
||||||
|
|
||||||
|
#if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
|
||||||
|
/**
|
||||||
|
* @brief HAL ADC Callback ID enumeration definition
|
||||||
|
*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
HAL_ADC_CONVERSION_COMPLETE_CB_ID = 0x00U, /*!< ADC conversion complete callback ID */
|
||||||
|
HAL_ADC_CONVERSION_HALF_CB_ID = 0x01U, /*!< ADC conversion DMA half-transfer callback ID */
|
||||||
|
HAL_ADC_LEVEL_OUT_OF_WINDOW_1_CB_ID = 0x02U, /*!< ADC analog watchdog 1 callback ID */
|
||||||
|
HAL_ADC_ERROR_CB_ID = 0x03U, /*!< ADC error callback ID */
|
||||||
|
HAL_ADC_INJ_CONVERSION_COMPLETE_CB_ID = 0x04U, /*!< ADC group injected conversion complete callback ID */
|
||||||
|
HAL_ADC_MSPINIT_CB_ID = 0x05U, /*!< ADC Msp Init callback ID */
|
||||||
|
HAL_ADC_MSPDEINIT_CB_ID = 0x06U /*!< ADC Msp DeInit callback ID */
|
||||||
|
} HAL_ADC_CallbackIDTypeDef;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief HAL ADC Callback pointer definition
|
||||||
|
*/
|
||||||
|
typedef void (*pADC_CallbackTypeDef)(ADC_HandleTypeDef *hadc); /*!< pointer to a ADC callback function */
|
||||||
|
|
||||||
|
#endif /* USE_HAL_ADC_REGISTER_CALLBACKS */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Exported constants --------------------------------------------------------*/
|
||||||
|
/** @defgroup ADC_Exported_Constants ADC Exported Constants
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup ADC_Error_Code ADC Error Code
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define HAL_ADC_ERROR_NONE 0x00U /*!< No error */
|
||||||
|
#define HAL_ADC_ERROR_INTERNAL 0x01U /*!< ADC IP internal error: if problem of clocking,
|
||||||
|
enable/disable, erroneous state */
|
||||||
|
#define HAL_ADC_ERROR_OVR 0x02U /*!< Overrun error */
|
||||||
|
#define HAL_ADC_ERROR_DMA 0x04U /*!< DMA transfer error */
|
||||||
|
#if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
|
||||||
|
#define HAL_ADC_ERROR_INVALID_CALLBACK (0x10U) /*!< Invalid Callback error */
|
||||||
|
#endif /* USE_HAL_ADC_REGISTER_CALLBACKS */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/** @defgroup ADC_ClockPrescaler ADC Clock Prescaler
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define ADC_CLOCK_SYNC_PCLK_DIV2 0x00000000U
|
||||||
|
#define ADC_CLOCK_SYNC_PCLK_DIV4 ((uint32_t)ADC_CCR_ADCPRE_0)
|
||||||
|
#define ADC_CLOCK_SYNC_PCLK_DIV6 ((uint32_t)ADC_CCR_ADCPRE_1)
|
||||||
|
#define ADC_CLOCK_SYNC_PCLK_DIV8 ((uint32_t)ADC_CCR_ADCPRE)
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup ADC_delay_between_2_sampling_phases ADC Delay Between 2 Sampling Phases
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define ADC_TWOSAMPLINGDELAY_5CYCLES 0x00000000U
|
||||||
|
#define ADC_TWOSAMPLINGDELAY_6CYCLES ((uint32_t)ADC_CCR_DELAY_0)
|
||||||
|
#define ADC_TWOSAMPLINGDELAY_7CYCLES ((uint32_t)ADC_CCR_DELAY_1)
|
||||||
|
#define ADC_TWOSAMPLINGDELAY_8CYCLES ((uint32_t)(ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0))
|
||||||
|
#define ADC_TWOSAMPLINGDELAY_9CYCLES ((uint32_t)ADC_CCR_DELAY_2)
|
||||||
|
#define ADC_TWOSAMPLINGDELAY_10CYCLES ((uint32_t)(ADC_CCR_DELAY_2 | ADC_CCR_DELAY_0))
|
||||||
|
#define ADC_TWOSAMPLINGDELAY_11CYCLES ((uint32_t)(ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1))
|
||||||
|
#define ADC_TWOSAMPLINGDELAY_12CYCLES ((uint32_t)(ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0))
|
||||||
|
#define ADC_TWOSAMPLINGDELAY_13CYCLES ((uint32_t)ADC_CCR_DELAY_3)
|
||||||
|
#define ADC_TWOSAMPLINGDELAY_14CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_0))
|
||||||
|
#define ADC_TWOSAMPLINGDELAY_15CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_1))
|
||||||
|
#define ADC_TWOSAMPLINGDELAY_16CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0))
|
||||||
|
#define ADC_TWOSAMPLINGDELAY_17CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_2))
|
||||||
|
#define ADC_TWOSAMPLINGDELAY_18CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_2 | ADC_CCR_DELAY_0))
|
||||||
|
#define ADC_TWOSAMPLINGDELAY_19CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1))
|
||||||
|
#define ADC_TWOSAMPLINGDELAY_20CYCLES ((uint32_t)ADC_CCR_DELAY)
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup ADC_Resolution ADC Resolution
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define ADC_RESOLUTION_12B 0x00000000U
|
||||||
|
#define ADC_RESOLUTION_10B ((uint32_t)ADC_CR1_RES_0)
|
||||||
|
#define ADC_RESOLUTION_8B ((uint32_t)ADC_CR1_RES_1)
|
||||||
|
#define ADC_RESOLUTION_6B ((uint32_t)ADC_CR1_RES)
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup ADC_External_trigger_edge_Regular ADC External Trigger Edge Regular
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define ADC_EXTERNALTRIGCONVEDGE_NONE 0x00000000U
|
||||||
|
#define ADC_EXTERNALTRIGCONVEDGE_RISING ((uint32_t)ADC_CR2_EXTEN_0)
|
||||||
|
#define ADC_EXTERNALTRIGCONVEDGE_FALLING ((uint32_t)ADC_CR2_EXTEN_1)
|
||||||
|
#define ADC_EXTERNALTRIGCONVEDGE_RISINGFALLING ((uint32_t)ADC_CR2_EXTEN)
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup ADC_External_trigger_Source_Regular ADC External Trigger Source Regular
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/* Note: Parameter ADC_SOFTWARE_START is a software parameter used for */
|
||||||
|
/* compatibility with other STM32 devices. */
|
||||||
|
#define ADC_EXTERNALTRIGCONV_T1_CC1 0x00000000U
|
||||||
|
#define ADC_EXTERNALTRIGCONV_T1_CC2 ((uint32_t)ADC_CR2_EXTSEL_0)
|
||||||
|
#define ADC_EXTERNALTRIGCONV_T1_CC3 ((uint32_t)ADC_CR2_EXTSEL_1)
|
||||||
|
#define ADC_EXTERNALTRIGCONV_T2_CC2 ((uint32_t)(ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0))
|
||||||
|
#define ADC_EXTERNALTRIGCONV_T2_CC3 ((uint32_t)ADC_CR2_EXTSEL_2)
|
||||||
|
#define ADC_EXTERNALTRIGCONV_T2_CC4 ((uint32_t)(ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_0))
|
||||||
|
#define ADC_EXTERNALTRIGCONV_T2_TRGO ((uint32_t)(ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1))
|
||||||
|
#define ADC_EXTERNALTRIGCONV_T3_CC1 ((uint32_t)(ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0))
|
||||||
|
#define ADC_EXTERNALTRIGCONV_T3_TRGO ((uint32_t)ADC_CR2_EXTSEL_3)
|
||||||
|
#define ADC_EXTERNALTRIGCONV_T4_CC4 ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_0))
|
||||||
|
#define ADC_EXTERNALTRIGCONV_T5_CC1 ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_1))
|
||||||
|
#define ADC_EXTERNALTRIGCONV_T5_CC2 ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0))
|
||||||
|
#define ADC_EXTERNALTRIGCONV_T5_CC3 ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_2))
|
||||||
|
#define ADC_EXTERNALTRIGCONV_T8_CC1 ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_0))
|
||||||
|
#define ADC_EXTERNALTRIGCONV_T8_TRGO ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1))
|
||||||
|
#define ADC_EXTERNALTRIGCONV_Ext_IT11 ((uint32_t)ADC_CR2_EXTSEL)
|
||||||
|
#define ADC_SOFTWARE_START ((uint32_t)ADC_CR2_EXTSEL + 1U)
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup ADC_Data_align ADC Data Align
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define ADC_DATAALIGN_RIGHT 0x00000000U
|
||||||
|
#define ADC_DATAALIGN_LEFT ((uint32_t)ADC_CR2_ALIGN)
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup ADC_channels ADC Common Channels
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define ADC_CHANNEL_0 0x00000000U
|
||||||
|
#define ADC_CHANNEL_1 ((uint32_t)ADC_CR1_AWDCH_0)
|
||||||
|
#define ADC_CHANNEL_2 ((uint32_t)ADC_CR1_AWDCH_1)
|
||||||
|
#define ADC_CHANNEL_3 ((uint32_t)(ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0))
|
||||||
|
#define ADC_CHANNEL_4 ((uint32_t)ADC_CR1_AWDCH_2)
|
||||||
|
#define ADC_CHANNEL_5 ((uint32_t)(ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_0))
|
||||||
|
#define ADC_CHANNEL_6 ((uint32_t)(ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1))
|
||||||
|
#define ADC_CHANNEL_7 ((uint32_t)(ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0))
|
||||||
|
#define ADC_CHANNEL_8 ((uint32_t)ADC_CR1_AWDCH_3)
|
||||||
|
#define ADC_CHANNEL_9 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_0))
|
||||||
|
#define ADC_CHANNEL_10 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_1))
|
||||||
|
#define ADC_CHANNEL_11 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0))
|
||||||
|
#define ADC_CHANNEL_12 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2))
|
||||||
|
#define ADC_CHANNEL_13 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_0))
|
||||||
|
#define ADC_CHANNEL_14 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1))
|
||||||
|
#define ADC_CHANNEL_15 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0))
|
||||||
|
#define ADC_CHANNEL_16 ((uint32_t)ADC_CR1_AWDCH_4)
|
||||||
|
#define ADC_CHANNEL_17 ((uint32_t)(ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_0))
|
||||||
|
#define ADC_CHANNEL_18 ((uint32_t)(ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_1))
|
||||||
|
|
||||||
|
#define ADC_CHANNEL_VREFINT ((uint32_t)ADC_CHANNEL_17)
|
||||||
|
#define ADC_CHANNEL_VBAT ((uint32_t)ADC_CHANNEL_18)
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup ADC_sampling_times ADC Sampling Times
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define ADC_SAMPLETIME_3CYCLES 0x00000000U
|
||||||
|
#define ADC_SAMPLETIME_15CYCLES ((uint32_t)ADC_SMPR1_SMP10_0)
|
||||||
|
#define ADC_SAMPLETIME_28CYCLES ((uint32_t)ADC_SMPR1_SMP10_1)
|
||||||
|
#define ADC_SAMPLETIME_56CYCLES ((uint32_t)(ADC_SMPR1_SMP10_1 | ADC_SMPR1_SMP10_0))
|
||||||
|
#define ADC_SAMPLETIME_84CYCLES ((uint32_t)ADC_SMPR1_SMP10_2)
|
||||||
|
#define ADC_SAMPLETIME_112CYCLES ((uint32_t)(ADC_SMPR1_SMP10_2 | ADC_SMPR1_SMP10_0))
|
||||||
|
#define ADC_SAMPLETIME_144CYCLES ((uint32_t)(ADC_SMPR1_SMP10_2 | ADC_SMPR1_SMP10_1))
|
||||||
|
#define ADC_SAMPLETIME_480CYCLES ((uint32_t)ADC_SMPR1_SMP10)
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup ADC_EOCSelection ADC EOC Selection
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define ADC_EOC_SEQ_CONV 0x00000000U
|
||||||
|
#define ADC_EOC_SINGLE_CONV 0x00000001U
|
||||||
|
#define ADC_EOC_SINGLE_SEQ_CONV 0x00000002U /*!< reserved for future use */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup ADC_Event_type ADC Event Type
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define ADC_AWD_EVENT ((uint32_t)ADC_FLAG_AWD)
|
||||||
|
#define ADC_OVR_EVENT ((uint32_t)ADC_FLAG_OVR)
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup ADC_analog_watchdog_selection ADC Analog Watchdog Selection
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define ADC_ANALOGWATCHDOG_SINGLE_REG ((uint32_t)(ADC_CR1_AWDSGL | ADC_CR1_AWDEN))
|
||||||
|
#define ADC_ANALOGWATCHDOG_SINGLE_INJEC ((uint32_t)(ADC_CR1_AWDSGL | ADC_CR1_JAWDEN))
|
||||||
|
#define ADC_ANALOGWATCHDOG_SINGLE_REGINJEC ((uint32_t)(ADC_CR1_AWDSGL | ADC_CR1_AWDEN | ADC_CR1_JAWDEN))
|
||||||
|
#define ADC_ANALOGWATCHDOG_ALL_REG ((uint32_t)ADC_CR1_AWDEN)
|
||||||
|
#define ADC_ANALOGWATCHDOG_ALL_INJEC ((uint32_t)ADC_CR1_JAWDEN)
|
||||||
|
#define ADC_ANALOGWATCHDOG_ALL_REGINJEC ((uint32_t)(ADC_CR1_AWDEN | ADC_CR1_JAWDEN))
|
||||||
|
#define ADC_ANALOGWATCHDOG_NONE 0x00000000U
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup ADC_interrupts_definition ADC Interrupts Definition
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define ADC_IT_EOC ((uint32_t)ADC_CR1_EOCIE)
|
||||||
|
#define ADC_IT_AWD ((uint32_t)ADC_CR1_AWDIE)
|
||||||
|
#define ADC_IT_JEOC ((uint32_t)ADC_CR1_JEOCIE)
|
||||||
|
#define ADC_IT_OVR ((uint32_t)ADC_CR1_OVRIE)
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup ADC_flags_definition ADC Flags Definition
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define ADC_FLAG_AWD ((uint32_t)ADC_SR_AWD)
|
||||||
|
#define ADC_FLAG_EOC ((uint32_t)ADC_SR_EOC)
|
||||||
|
#define ADC_FLAG_JEOC ((uint32_t)ADC_SR_JEOC)
|
||||||
|
#define ADC_FLAG_JSTRT ((uint32_t)ADC_SR_JSTRT)
|
||||||
|
#define ADC_FLAG_STRT ((uint32_t)ADC_SR_STRT)
|
||||||
|
#define ADC_FLAG_OVR ((uint32_t)ADC_SR_OVR)
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup ADC_channels_type ADC Channels Type
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define ADC_ALL_CHANNELS 0x00000001U
|
||||||
|
#define ADC_REGULAR_CHANNELS 0x00000002U /*!< reserved for future use */
|
||||||
|
#define ADC_INJECTED_CHANNELS 0x00000003U /*!< reserved for future use */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Exported macro ------------------------------------------------------------*/
|
||||||
|
/** @defgroup ADC_Exported_Macros ADC Exported Macros
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @brief Reset ADC handle state
|
||||||
|
* @param __HANDLE__ ADC handle
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
|
||||||
|
#define __HAL_ADC_RESET_HANDLE_STATE(__HANDLE__) \
|
||||||
|
do{ \
|
||||||
|
(__HANDLE__)->State = HAL_ADC_STATE_RESET; \
|
||||||
|
(__HANDLE__)->MspInitCallback = NULL; \
|
||||||
|
(__HANDLE__)->MspDeInitCallback = NULL; \
|
||||||
|
} while(0)
|
||||||
|
#else
|
||||||
|
#define __HAL_ADC_RESET_HANDLE_STATE(__HANDLE__) \
|
||||||
|
((__HANDLE__)->State = HAL_ADC_STATE_RESET)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enable the ADC peripheral.
|
||||||
|
* @param __HANDLE__ ADC handle
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define __HAL_ADC_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR2 |= ADC_CR2_ADON)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Disable the ADC peripheral.
|
||||||
|
* @param __HANDLE__ ADC handle
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define __HAL_ADC_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR2 &= ~ADC_CR2_ADON)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enable the ADC end of conversion interrupt.
|
||||||
|
* @param __HANDLE__ specifies the ADC Handle.
|
||||||
|
* @param __INTERRUPT__ ADC Interrupt.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define __HAL_ADC_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR1) |= (__INTERRUPT__))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Disable the ADC end of conversion interrupt.
|
||||||
|
* @param __HANDLE__ specifies the ADC Handle.
|
||||||
|
* @param __INTERRUPT__ ADC interrupt.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define __HAL_ADC_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR1) &= ~(__INTERRUPT__))
|
||||||
|
|
||||||
|
/** @brief Check if the specified ADC interrupt source is enabled or disabled.
|
||||||
|
* @param __HANDLE__ specifies the ADC Handle.
|
||||||
|
* @param __INTERRUPT__ specifies the ADC interrupt source to check.
|
||||||
|
* @retval The new state of __IT__ (TRUE or FALSE).
|
||||||
|
*/
|
||||||
|
#define __HAL_ADC_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR1 & (__INTERRUPT__)) == (__INTERRUPT__))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Clear the ADC's pending flags.
|
||||||
|
* @param __HANDLE__ specifies the ADC Handle.
|
||||||
|
* @param __FLAG__ ADC flag.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define __HAL_ADC_CLEAR_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR) = ~(__FLAG__))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the selected ADC's flag status.
|
||||||
|
* @param __HANDLE__ specifies the ADC Handle.
|
||||||
|
* @param __FLAG__ ADC flag.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define __HAL_ADC_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Include ADC HAL Extension module */
|
||||||
|
#include "stm32f4xx_hal_adc_ex.h"
|
||||||
|
|
||||||
|
/* Exported functions --------------------------------------------------------*/
|
||||||
|
/** @addtogroup ADC_Exported_Functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup ADC_Exported_Functions_Group1
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/* Initialization/de-initialization functions ***********************************/
|
||||||
|
HAL_StatusTypeDef HAL_ADC_Init(ADC_HandleTypeDef *hadc);
|
||||||
|
HAL_StatusTypeDef HAL_ADC_DeInit(ADC_HandleTypeDef *hadc);
|
||||||
|
void HAL_ADC_MspInit(ADC_HandleTypeDef *hadc);
|
||||||
|
void HAL_ADC_MspDeInit(ADC_HandleTypeDef *hadc);
|
||||||
|
|
||||||
|
#if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
|
||||||
|
/* Callbacks Register/UnRegister functions ***********************************/
|
||||||
|
HAL_StatusTypeDef HAL_ADC_RegisterCallback(ADC_HandleTypeDef *hadc, HAL_ADC_CallbackIDTypeDef CallbackID, pADC_CallbackTypeDef pCallback);
|
||||||
|
HAL_StatusTypeDef HAL_ADC_UnRegisterCallback(ADC_HandleTypeDef *hadc, HAL_ADC_CallbackIDTypeDef CallbackID);
|
||||||
|
#endif /* USE_HAL_ADC_REGISTER_CALLBACKS */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup ADC_Exported_Functions_Group2
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/* I/O operation functions ******************************************************/
|
||||||
|
HAL_StatusTypeDef HAL_ADC_Start(ADC_HandleTypeDef *hadc);
|
||||||
|
HAL_StatusTypeDef HAL_ADC_Stop(ADC_HandleTypeDef *hadc);
|
||||||
|
HAL_StatusTypeDef HAL_ADC_PollForConversion(ADC_HandleTypeDef *hadc, uint32_t Timeout);
|
||||||
|
|
||||||
|
HAL_StatusTypeDef HAL_ADC_PollForEvent(ADC_HandleTypeDef *hadc, uint32_t EventType, uint32_t Timeout);
|
||||||
|
|
||||||
|
HAL_StatusTypeDef HAL_ADC_Start_IT(ADC_HandleTypeDef *hadc);
|
||||||
|
HAL_StatusTypeDef HAL_ADC_Stop_IT(ADC_HandleTypeDef *hadc);
|
||||||
|
|
||||||
|
void HAL_ADC_IRQHandler(ADC_HandleTypeDef *hadc);
|
||||||
|
|
||||||
|
HAL_StatusTypeDef HAL_ADC_Start_DMA(ADC_HandleTypeDef *hadc, uint32_t *pData, uint32_t Length);
|
||||||
|
HAL_StatusTypeDef HAL_ADC_Stop_DMA(ADC_HandleTypeDef *hadc);
|
||||||
|
|
||||||
|
uint32_t HAL_ADC_GetValue(ADC_HandleTypeDef *hadc);
|
||||||
|
|
||||||
|
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hadc);
|
||||||
|
void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef *hadc);
|
||||||
|
void HAL_ADC_LevelOutOfWindowCallback(ADC_HandleTypeDef *hadc);
|
||||||
|
void HAL_ADC_ErrorCallback(ADC_HandleTypeDef *hadc);
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup ADC_Exported_Functions_Group3
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/* Peripheral Control functions *************************************************/
|
||||||
|
HAL_StatusTypeDef HAL_ADC_ConfigChannel(ADC_HandleTypeDef *hadc, ADC_ChannelConfTypeDef *sConfig);
|
||||||
|
HAL_StatusTypeDef HAL_ADC_AnalogWDGConfig(ADC_HandleTypeDef *hadc, ADC_AnalogWDGConfTypeDef *AnalogWDGConfig);
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup ADC_Exported_Functions_Group4
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/* Peripheral State functions ***************************************************/
|
||||||
|
uint32_t HAL_ADC_GetState(ADC_HandleTypeDef *hadc);
|
||||||
|
uint32_t HAL_ADC_GetError(ADC_HandleTypeDef *hadc);
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
/* Private types -------------------------------------------------------------*/
|
||||||
|
/* Private variables ---------------------------------------------------------*/
|
||||||
|
/* Private constants ---------------------------------------------------------*/
|
||||||
|
/** @defgroup ADC_Private_Constants ADC Private Constants
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/* Delay for ADC stabilization time. */
|
||||||
|
/* Maximum delay is 1us (refer to device datasheet, parameter tSTAB). */
|
||||||
|
/* Unit: us */
|
||||||
|
#define ADC_STAB_DELAY_US 3U
|
||||||
|
/* Delay for temperature sensor stabilization time. */
|
||||||
|
/* Maximum delay is 10us (refer to device datasheet, parameter tSTART). */
|
||||||
|
/* Unit: us */
|
||||||
|
#define ADC_TEMPSENSOR_DELAY_US 10U
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Private macro ------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/** @defgroup ADC_Private_Macros ADC Private Macros
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/* Macro reserved for internal HAL driver usage, not intended to be used in
|
||||||
|
code of final user */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Verification of ADC state: enabled or disabled
|
||||||
|
* @param __HANDLE__ ADC handle
|
||||||
|
* @retval SET (ADC enabled) or RESET (ADC disabled)
|
||||||
|
*/
|
||||||
|
#define ADC_IS_ENABLE(__HANDLE__) \
|
||||||
|
((( ((__HANDLE__)->Instance->SR & ADC_SR_ADONS) == ADC_SR_ADONS ) \
|
||||||
|
) ? SET : RESET)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Test if conversion trigger of regular group is software start
|
||||||
|
* or external trigger.
|
||||||
|
* @param __HANDLE__ ADC handle
|
||||||
|
* @retval SET (software start) or RESET (external trigger)
|
||||||
|
*/
|
||||||
|
#define ADC_IS_SOFTWARE_START_REGULAR(__HANDLE__) \
|
||||||
|
(((__HANDLE__)->Instance->CR2 & ADC_CR2_EXTEN) == RESET)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Test if conversion trigger of injected group is software start
|
||||||
|
* or external trigger.
|
||||||
|
* @param __HANDLE__ ADC handle
|
||||||
|
* @retval SET (software start) or RESET (external trigger)
|
||||||
|
*/
|
||||||
|
#define ADC_IS_SOFTWARE_START_INJECTED(__HANDLE__) \
|
||||||
|
(((__HANDLE__)->Instance->CR2 & ADC_CR2_JEXTEN) == RESET)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Simultaneously clears and sets specific bits of the handle State
|
||||||
|
* @note: ADC_STATE_CLR_SET() macro is merely aliased to generic macro MODIFY_REG(),
|
||||||
|
* the first parameter is the ADC handle State, the second parameter is the
|
||||||
|
* bit field to clear, the third and last parameter is the bit field to set.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define ADC_STATE_CLR_SET MODIFY_REG
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Clear ADC error code (set it to error code: "no error")
|
||||||
|
* @param __HANDLE__ ADC handle
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define ADC_CLEAR_ERRORCODE(__HANDLE__) \
|
||||||
|
((__HANDLE__)->ErrorCode = HAL_ADC_ERROR_NONE)
|
||||||
|
|
||||||
|
|
||||||
|
#define IS_ADC_CLOCKPRESCALER(ADC_CLOCK) (((ADC_CLOCK) == ADC_CLOCK_SYNC_PCLK_DIV2) || \
|
||||||
|
((ADC_CLOCK) == ADC_CLOCK_SYNC_PCLK_DIV4) || \
|
||||||
|
((ADC_CLOCK) == ADC_CLOCK_SYNC_PCLK_DIV6) || \
|
||||||
|
((ADC_CLOCK) == ADC_CLOCK_SYNC_PCLK_DIV8))
|
||||||
|
#define IS_ADC_SAMPLING_DELAY(DELAY) (((DELAY) == ADC_TWOSAMPLINGDELAY_5CYCLES) || \
|
||||||
|
((DELAY) == ADC_TWOSAMPLINGDELAY_6CYCLES) || \
|
||||||
|
((DELAY) == ADC_TWOSAMPLINGDELAY_7CYCLES) || \
|
||||||
|
((DELAY) == ADC_TWOSAMPLINGDELAY_8CYCLES) || \
|
||||||
|
((DELAY) == ADC_TWOSAMPLINGDELAY_9CYCLES) || \
|
||||||
|
((DELAY) == ADC_TWOSAMPLINGDELAY_10CYCLES) || \
|
||||||
|
((DELAY) == ADC_TWOSAMPLINGDELAY_11CYCLES) || \
|
||||||
|
((DELAY) == ADC_TWOSAMPLINGDELAY_12CYCLES) || \
|
||||||
|
((DELAY) == ADC_TWOSAMPLINGDELAY_13CYCLES) || \
|
||||||
|
((DELAY) == ADC_TWOSAMPLINGDELAY_14CYCLES) || \
|
||||||
|
((DELAY) == ADC_TWOSAMPLINGDELAY_15CYCLES) || \
|
||||||
|
((DELAY) == ADC_TWOSAMPLINGDELAY_16CYCLES) || \
|
||||||
|
((DELAY) == ADC_TWOSAMPLINGDELAY_17CYCLES) || \
|
||||||
|
((DELAY) == ADC_TWOSAMPLINGDELAY_18CYCLES) || \
|
||||||
|
((DELAY) == ADC_TWOSAMPLINGDELAY_19CYCLES) || \
|
||||||
|
((DELAY) == ADC_TWOSAMPLINGDELAY_20CYCLES))
|
||||||
|
#define IS_ADC_RESOLUTION(RESOLUTION) (((RESOLUTION) == ADC_RESOLUTION_12B) || \
|
||||||
|
((RESOLUTION) == ADC_RESOLUTION_10B) || \
|
||||||
|
((RESOLUTION) == ADC_RESOLUTION_8B) || \
|
||||||
|
((RESOLUTION) == ADC_RESOLUTION_6B))
|
||||||
|
#define IS_ADC_EXT_TRIG_EDGE(EDGE) (((EDGE) == ADC_EXTERNALTRIGCONVEDGE_NONE) || \
|
||||||
|
((EDGE) == ADC_EXTERNALTRIGCONVEDGE_RISING) || \
|
||||||
|
((EDGE) == ADC_EXTERNALTRIGCONVEDGE_FALLING) || \
|
||||||
|
((EDGE) == ADC_EXTERNALTRIGCONVEDGE_RISINGFALLING))
|
||||||
|
#define IS_ADC_EXT_TRIG(REGTRIG) (((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC1) || \
|
||||||
|
((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC2) || \
|
||||||
|
((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC3) || \
|
||||||
|
((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_CC2) || \
|
||||||
|
((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_CC3) || \
|
||||||
|
((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_CC4) || \
|
||||||
|
((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_TRGO) || \
|
||||||
|
((REGTRIG) == ADC_EXTERNALTRIGCONV_T3_CC1) || \
|
||||||
|
((REGTRIG) == ADC_EXTERNALTRIGCONV_T3_TRGO) || \
|
||||||
|
((REGTRIG) == ADC_EXTERNALTRIGCONV_T4_CC4) || \
|
||||||
|
((REGTRIG) == ADC_EXTERNALTRIGCONV_T5_CC1) || \
|
||||||
|
((REGTRIG) == ADC_EXTERNALTRIGCONV_T5_CC2) || \
|
||||||
|
((REGTRIG) == ADC_EXTERNALTRIGCONV_T5_CC3) || \
|
||||||
|
((REGTRIG) == ADC_EXTERNALTRIGCONV_T8_CC1) || \
|
||||||
|
((REGTRIG) == ADC_EXTERNALTRIGCONV_T8_TRGO) || \
|
||||||
|
((REGTRIG) == ADC_EXTERNALTRIGCONV_Ext_IT11)|| \
|
||||||
|
((REGTRIG) == ADC_SOFTWARE_START))
|
||||||
|
#define IS_ADC_DATA_ALIGN(ALIGN) (((ALIGN) == ADC_DATAALIGN_RIGHT) || \
|
||||||
|
((ALIGN) == ADC_DATAALIGN_LEFT))
|
||||||
|
#define IS_ADC_SAMPLE_TIME(TIME) (((TIME) == ADC_SAMPLETIME_3CYCLES) || \
|
||||||
|
((TIME) == ADC_SAMPLETIME_15CYCLES) || \
|
||||||
|
((TIME) == ADC_SAMPLETIME_28CYCLES) || \
|
||||||
|
((TIME) == ADC_SAMPLETIME_56CYCLES) || \
|
||||||
|
((TIME) == ADC_SAMPLETIME_84CYCLES) || \
|
||||||
|
((TIME) == ADC_SAMPLETIME_112CYCLES) || \
|
||||||
|
((TIME) == ADC_SAMPLETIME_144CYCLES) || \
|
||||||
|
((TIME) == ADC_SAMPLETIME_480CYCLES))
|
||||||
|
#define IS_ADC_EOCSelection(EOCSelection) (((EOCSelection) == ADC_EOC_SINGLE_CONV) || \
|
||||||
|
((EOCSelection) == ADC_EOC_SEQ_CONV) || \
|
||||||
|
((EOCSelection) == ADC_EOC_SINGLE_SEQ_CONV))
|
||||||
|
#define IS_ADC_EVENT_TYPE(EVENT) (((EVENT) == ADC_AWD_EVENT) || \
|
||||||
|
((EVENT) == ADC_OVR_EVENT))
|
||||||
|
#define IS_ADC_ANALOG_WATCHDOG(WATCHDOG) (((WATCHDOG) == ADC_ANALOGWATCHDOG_SINGLE_REG) || \
|
||||||
|
((WATCHDOG) == ADC_ANALOGWATCHDOG_SINGLE_INJEC) || \
|
||||||
|
((WATCHDOG) == ADC_ANALOGWATCHDOG_SINGLE_REGINJEC) || \
|
||||||
|
((WATCHDOG) == ADC_ANALOGWATCHDOG_ALL_REG) || \
|
||||||
|
((WATCHDOG) == ADC_ANALOGWATCHDOG_ALL_INJEC) || \
|
||||||
|
((WATCHDOG) == ADC_ANALOGWATCHDOG_ALL_REGINJEC) || \
|
||||||
|
((WATCHDOG) == ADC_ANALOGWATCHDOG_NONE))
|
||||||
|
#define IS_ADC_CHANNELS_TYPE(CHANNEL_TYPE) (((CHANNEL_TYPE) == ADC_ALL_CHANNELS) || \
|
||||||
|
((CHANNEL_TYPE) == ADC_REGULAR_CHANNELS) || \
|
||||||
|
((CHANNEL_TYPE) == ADC_INJECTED_CHANNELS))
|
||||||
|
#define IS_ADC_THRESHOLD(THRESHOLD) ((THRESHOLD) <= 0xFFFU)
|
||||||
|
|
||||||
|
#define IS_ADC_REGULAR_LENGTH(LENGTH) (((LENGTH) >= 1U) && ((LENGTH) <= 16U))
|
||||||
|
#define IS_ADC_REGULAR_RANK(RANK) (((RANK) >= 1U) && ((RANK) <= (16U)))
|
||||||
|
#define IS_ADC_REGULAR_DISC_NUMBER(NUMBER) (((NUMBER) >= 1U) && ((NUMBER) <= 8U))
|
||||||
|
#define IS_ADC_RANGE(RESOLUTION, ADC_VALUE) \
|
||||||
|
((((RESOLUTION) == ADC_RESOLUTION_12B) && ((ADC_VALUE) <= 0x0FFFU)) || \
|
||||||
|
(((RESOLUTION) == ADC_RESOLUTION_10B) && ((ADC_VALUE) <= 0x03FFU)) || \
|
||||||
|
(((RESOLUTION) == ADC_RESOLUTION_8B) && ((ADC_VALUE) <= 0x00FFU)) || \
|
||||||
|
(((RESOLUTION) == ADC_RESOLUTION_6B) && ((ADC_VALUE) <= 0x003FU)))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set ADC Regular channel sequence length.
|
||||||
|
* @param _NbrOfConversion_ Regular channel sequence length.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define ADC_SQR1(_NbrOfConversion_) (((_NbrOfConversion_) - (uint8_t)1U) << 20U)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the ADC's sample time for channel numbers between 10 and 18.
|
||||||
|
* @param _SAMPLETIME_ Sample time parameter.
|
||||||
|
* @param _CHANNELNB_ Channel number.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define ADC_SMPR1(_SAMPLETIME_, _CHANNELNB_) ((_SAMPLETIME_) << (3U * (((uint32_t)((uint16_t)(_CHANNELNB_))) - 10U)))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the ADC's sample time for channel numbers between 0 and 9.
|
||||||
|
* @param _SAMPLETIME_ Sample time parameter.
|
||||||
|
* @param _CHANNELNB_ Channel number.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define ADC_SMPR2(_SAMPLETIME_, _CHANNELNB_) ((_SAMPLETIME_) << (3U * ((uint32_t)((uint16_t)(_CHANNELNB_)))))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the selected regular channel rank for rank between 1 and 6.
|
||||||
|
* @param _CHANNELNB_ Channel number.
|
||||||
|
* @param _RANKNB_ Rank number.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define ADC_SQR3_RK(_CHANNELNB_, _RANKNB_) (((uint32_t)((uint16_t)(_CHANNELNB_))) << (5U * ((_RANKNB_) - 1U)))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the selected regular channel rank for rank between 7 and 12.
|
||||||
|
* @param _CHANNELNB_ Channel number.
|
||||||
|
* @param _RANKNB_ Rank number.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define ADC_SQR2_RK(_CHANNELNB_, _RANKNB_) (((uint32_t)((uint16_t)(_CHANNELNB_))) << (5U * ((_RANKNB_) - 7U)))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the selected regular channel rank for rank between 13 and 16.
|
||||||
|
* @param _CHANNELNB_ Channel number.
|
||||||
|
* @param _RANKNB_ Rank number.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define ADC_SQR1_RK(_CHANNELNB_, _RANKNB_) (((uint32_t)((uint16_t)(_CHANNELNB_))) << (5U * ((_RANKNB_) - 13U)))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enable ADC continuous conversion mode.
|
||||||
|
* @param _CONTINUOUS_MODE_ Continuous mode.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define ADC_CR2_CONTINUOUS(_CONTINUOUS_MODE_) ((_CONTINUOUS_MODE_) << 1U)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Configures the number of discontinuous conversions for the regular group channels.
|
||||||
|
* @param _NBR_DISCONTINUOUSCONV_ Number of discontinuous conversions.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define ADC_CR1_DISCONTINUOUS(_NBR_DISCONTINUOUSCONV_) (((_NBR_DISCONTINUOUSCONV_) - 1U) << ADC_CR1_DISCNUM_Pos)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enable ADC scan mode.
|
||||||
|
* @param _SCANCONV_MODE_ Scan conversion mode.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define ADC_CR1_SCANCONV(_SCANCONV_MODE_) ((_SCANCONV_MODE_) << 8U)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enable the ADC end of conversion selection.
|
||||||
|
* @param _EOCSelection_MODE_ End of conversion selection mode.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define ADC_CR2_EOCSelection(_EOCSelection_MODE_) ((_EOCSelection_MODE_) << 10U)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enable the ADC DMA continuous request.
|
||||||
|
* @param _DMAContReq_MODE_ DMA continuous request mode.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define ADC_CR2_DMAContReq(_DMAContReq_MODE_) ((_DMAContReq_MODE_) << 9U)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Return resolution bits in CR1 register.
|
||||||
|
* @param __HANDLE__ ADC handle
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define ADC_GET_RESOLUTION(__HANDLE__) (((__HANDLE__)->Instance->CR1) & ADC_CR1_RES)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Private functions ---------------------------------------------------------*/
|
||||||
|
/** @defgroup ADC_Private_Functions ADC Private Functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /*__STM32F4xx_ADC_H */
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,407 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file stm32f4xx_hal_adc_ex.h
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief Header file of ADC HAL module.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2017 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __STM32F4xx_ADC_EX_H
|
||||||
|
#define __STM32F4xx_ADC_EX_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "stm32f4xx_hal_def.h"
|
||||||
|
|
||||||
|
/** @addtogroup STM32F4xx_HAL_Driver
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup ADCEx
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Exported types ------------------------------------------------------------*/
|
||||||
|
/** @defgroup ADCEx_Exported_Types ADC Exported Types
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ADC Configuration injected Channel structure definition
|
||||||
|
* @note Parameters of this structure are shared within 2 scopes:
|
||||||
|
* - Scope channel: InjectedChannel, InjectedRank, InjectedSamplingTime, InjectedOffset
|
||||||
|
* - Scope injected group (affects all channels of injected group): InjectedNbrOfConversion, InjectedDiscontinuousConvMode,
|
||||||
|
* AutoInjectedConv, ExternalTrigInjecConvEdge, ExternalTrigInjecConv.
|
||||||
|
* @note The setting of these parameters with function HAL_ADCEx_InjectedConfigChannel() is conditioned to ADC state.
|
||||||
|
* ADC state can be either:
|
||||||
|
* - For all parameters: ADC disabled
|
||||||
|
* - For all except parameters 'InjectedDiscontinuousConvMode' and 'AutoInjectedConv': ADC enabled without conversion on going on injected group.
|
||||||
|
* - For parameters 'ExternalTrigInjecConv' and 'ExternalTrigInjecConvEdge': ADC enabled, even with conversion on going on injected group.
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32_t InjectedChannel; /*!< Selection of ADC channel to configure
|
||||||
|
This parameter can be a value of @ref ADC_channels
|
||||||
|
Note: Depending on devices, some channels may not be available on package pins. Refer to device datasheet for channels availability. */
|
||||||
|
uint32_t InjectedRank; /*!< Rank in the injected group sequencer
|
||||||
|
This parameter must be a value of @ref ADCEx_injected_rank
|
||||||
|
Note: In case of need to disable a channel or change order of conversion sequencer, rank containing a previous channel setting can be overwritten by the new channel setting (or parameter number of conversions can be adjusted) */
|
||||||
|
uint32_t InjectedSamplingTime; /*!< Sampling time value to be set for the selected channel.
|
||||||
|
Unit: ADC clock cycles
|
||||||
|
Conversion time is the addition of sampling time and processing time (12 ADC clock cycles at ADC resolution 12 bits, 11 cycles at 10 bits, 9 cycles at 8 bits, 7 cycles at 6 bits).
|
||||||
|
This parameter can be a value of @ref ADC_sampling_times
|
||||||
|
Caution: This parameter updates the parameter property of the channel, that can be used into regular and/or injected groups.
|
||||||
|
If this same channel has been previously configured in the other group (regular/injected), it will be updated to last setting.
|
||||||
|
Note: In case of usage of internal measurement channels (VrefInt/Vbat/TempSensor),
|
||||||
|
sampling time constraints must be respected (sampling time can be adjusted in function of ADC clock frequency and sampling time setting)
|
||||||
|
Refer to device datasheet for timings values, parameters TS_vrefint, TS_temp (values rough order: 4us min). */
|
||||||
|
uint32_t InjectedOffset; /*!< Defines the offset to be subtracted from the raw converted data (for channels set on injected group only).
|
||||||
|
Offset value must be a positive number.
|
||||||
|
Depending of ADC resolution selected (12, 10, 8 or 6 bits),
|
||||||
|
this parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFF, 0x3FF, 0xFF or 0x3F respectively. */
|
||||||
|
uint32_t InjectedNbrOfConversion; /*!< Specifies the number of ranks that will be converted within the injected group sequencer.
|
||||||
|
To use the injected group sequencer and convert several ranks, parameter 'ScanConvMode' must be enabled.
|
||||||
|
This parameter must be a number between Min_Data = 1 and Max_Data = 4.
|
||||||
|
Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
|
||||||
|
configure a channel on injected group can impact the configuration of other channels previously set. */
|
||||||
|
FunctionalState InjectedDiscontinuousConvMode; /*!< Specifies whether the conversions sequence of injected group is performed in Complete-sequence/Discontinuous-sequence (main sequence subdivided in successive parts).
|
||||||
|
Discontinuous mode is used only if sequencer is enabled (parameter 'ScanConvMode'). If sequencer is disabled, this parameter is discarded.
|
||||||
|
Discontinuous mode can be enabled only if continuous mode is disabled. If continuous mode is enabled, this parameter setting is discarded.
|
||||||
|
This parameter can be set to ENABLE or DISABLE.
|
||||||
|
Note: For injected group, number of discontinuous ranks increment is fixed to one-by-one.
|
||||||
|
Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
|
||||||
|
configure a channel on injected group can impact the configuration of other channels previously set. */
|
||||||
|
FunctionalState AutoInjectedConv; /*!< Enables or disables the selected ADC automatic injected group conversion after regular one
|
||||||
|
This parameter can be set to ENABLE or DISABLE.
|
||||||
|
Note: To use Automatic injected conversion, discontinuous mode must be disabled ('DiscontinuousConvMode' and 'InjectedDiscontinuousConvMode' set to DISABLE)
|
||||||
|
Note: To use Automatic injected conversion, injected group external triggers must be disabled ('ExternalTrigInjecConv' set to ADC_SOFTWARE_START)
|
||||||
|
Note: In case of DMA used with regular group: if DMA configured in normal mode (single shot) JAUTO will be stopped upon DMA transfer complete.
|
||||||
|
To maintain JAUTO always enabled, DMA must be configured in circular mode.
|
||||||
|
Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
|
||||||
|
configure a channel on injected group can impact the configuration of other channels previously set. */
|
||||||
|
uint32_t ExternalTrigInjecConv; /*!< Selects the external event used to trigger the conversion start of injected group.
|
||||||
|
If set to ADC_INJECTED_SOFTWARE_START, external triggers are disabled.
|
||||||
|
If set to external trigger source, triggering is on event rising edge.
|
||||||
|
This parameter can be a value of @ref ADCEx_External_trigger_Source_Injected
|
||||||
|
Note: This parameter must be modified when ADC is disabled (before ADC start conversion or after ADC stop conversion).
|
||||||
|
If ADC is enabled, this parameter setting is bypassed without error reporting (as it can be the expected behaviour in case of another parameter update on the fly)
|
||||||
|
Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
|
||||||
|
configure a channel on injected group can impact the configuration of other channels previously set. */
|
||||||
|
uint32_t ExternalTrigInjecConvEdge; /*!< Selects the external trigger edge of injected group.
|
||||||
|
This parameter can be a value of @ref ADCEx_External_trigger_edge_Injected.
|
||||||
|
If trigger is set to ADC_INJECTED_SOFTWARE_START, this parameter is discarded.
|
||||||
|
Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
|
||||||
|
configure a channel on injected group can impact the configuration of other channels previously set. */
|
||||||
|
} ADC_InjectionConfTypeDef;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ADC Configuration multi-mode structure definition
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32_t Mode; /*!< Configures the ADC to operate in independent or multi mode.
|
||||||
|
This parameter can be a value of @ref ADCEx_Common_mode */
|
||||||
|
uint32_t DMAAccessMode; /*!< Configures the Direct memory access mode for multi ADC mode.
|
||||||
|
This parameter can be a value of @ref ADCEx_Direct_memory_access_mode_for_multi_mode */
|
||||||
|
uint32_t TwoSamplingDelay; /*!< Configures the Delay between 2 sampling phases.
|
||||||
|
This parameter can be a value of @ref ADC_delay_between_2_sampling_phases */
|
||||||
|
} ADC_MultiModeTypeDef;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Exported constants --------------------------------------------------------*/
|
||||||
|
/** @defgroup ADCEx_Exported_Constants ADC Exported Constants
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup ADCEx_Common_mode ADC Common Mode
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define ADC_MODE_INDEPENDENT 0x00000000U
|
||||||
|
#define ADC_DUALMODE_REGSIMULT_INJECSIMULT ((uint32_t)ADC_CCR_MULTI_0)
|
||||||
|
#define ADC_DUALMODE_REGSIMULT_ALTERTRIG ((uint32_t)ADC_CCR_MULTI_1)
|
||||||
|
#define ADC_DUALMODE_INJECSIMULT ((uint32_t)(ADC_CCR_MULTI_2 | ADC_CCR_MULTI_0))
|
||||||
|
#define ADC_DUALMODE_REGSIMULT ((uint32_t)(ADC_CCR_MULTI_2 | ADC_CCR_MULTI_1))
|
||||||
|
#define ADC_DUALMODE_INTERL ((uint32_t)(ADC_CCR_MULTI_2 | ADC_CCR_MULTI_1 | ADC_CCR_MULTI_0))
|
||||||
|
#define ADC_DUALMODE_ALTERTRIG ((uint32_t)(ADC_CCR_MULTI_3 | ADC_CCR_MULTI_0))
|
||||||
|
#define ADC_TRIPLEMODE_REGSIMULT_INJECSIMULT ((uint32_t)(ADC_CCR_MULTI_4 | ADC_CCR_MULTI_0))
|
||||||
|
#define ADC_TRIPLEMODE_REGSIMULT_AlterTrig ((uint32_t)(ADC_CCR_MULTI_4 | ADC_CCR_MULTI_1))
|
||||||
|
#define ADC_TRIPLEMODE_INJECSIMULT ((uint32_t)(ADC_CCR_MULTI_4 | ADC_CCR_MULTI_2 | ADC_CCR_MULTI_0))
|
||||||
|
#define ADC_TRIPLEMODE_REGSIMULT ((uint32_t)(ADC_CCR_MULTI_4 | ADC_CCR_MULTI_2 | ADC_CCR_MULTI_1))
|
||||||
|
#define ADC_TRIPLEMODE_INTERL ((uint32_t)(ADC_CCR_MULTI_4 | ADC_CCR_MULTI_2 | ADC_CCR_MULTI_1 | ADC_CCR_MULTI_0))
|
||||||
|
#define ADC_TRIPLEMODE_ALTERTRIG ((uint32_t)(ADC_CCR_MULTI_4 | ADC_CCR_MULTI_3 | ADC_CCR_MULTI_0))
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup ADCEx_Direct_memory_access_mode_for_multi_mode ADC Direct Memory Access Mode For Multi Mode
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define ADC_DMAACCESSMODE_DISABLED 0x00000000U /*!< DMA mode disabled */
|
||||||
|
#define ADC_DMAACCESSMODE_1 ((uint32_t)ADC_CCR_DMA_0) /*!< DMA mode 1 enabled (2 / 3 half-words one by one - 1 then 2 then 3)*/
|
||||||
|
#define ADC_DMAACCESSMODE_2 ((uint32_t)ADC_CCR_DMA_1) /*!< DMA mode 2 enabled (2 / 3 half-words by pairs - 2&1 then 1&3 then 3&2)*/
|
||||||
|
#define ADC_DMAACCESSMODE_3 ((uint32_t)ADC_CCR_DMA) /*!< DMA mode 3 enabled (2 / 3 bytes by pairs - 2&1 then 1&3 then 3&2) */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup ADCEx_External_trigger_edge_Injected ADC External Trigger Edge Injected
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define ADC_EXTERNALTRIGINJECCONVEDGE_NONE 0x00000000U
|
||||||
|
#define ADC_EXTERNALTRIGINJECCONVEDGE_RISING ((uint32_t)ADC_CR2_JEXTEN_0)
|
||||||
|
#define ADC_EXTERNALTRIGINJECCONVEDGE_FALLING ((uint32_t)ADC_CR2_JEXTEN_1)
|
||||||
|
#define ADC_EXTERNALTRIGINJECCONVEDGE_RISINGFALLING ((uint32_t)ADC_CR2_JEXTEN)
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup ADCEx_External_trigger_Source_Injected ADC External Trigger Source Injected
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define ADC_EXTERNALTRIGINJECCONV_T1_CC4 0x00000000U
|
||||||
|
#define ADC_EXTERNALTRIGINJECCONV_T1_TRGO ((uint32_t)ADC_CR2_JEXTSEL_0)
|
||||||
|
#define ADC_EXTERNALTRIGINJECCONV_T2_CC1 ((uint32_t)ADC_CR2_JEXTSEL_1)
|
||||||
|
#define ADC_EXTERNALTRIGINJECCONV_T2_TRGO ((uint32_t)(ADC_CR2_JEXTSEL_1 | ADC_CR2_JEXTSEL_0))
|
||||||
|
#define ADC_EXTERNALTRIGINJECCONV_T3_CC2 ((uint32_t)ADC_CR2_JEXTSEL_2)
|
||||||
|
#define ADC_EXTERNALTRIGINJECCONV_T3_CC4 ((uint32_t)(ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_0))
|
||||||
|
#define ADC_EXTERNALTRIGINJECCONV_T4_CC1 ((uint32_t)(ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_1))
|
||||||
|
#define ADC_EXTERNALTRIGINJECCONV_T4_CC2 ((uint32_t)(ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_1 | ADC_CR2_JEXTSEL_0))
|
||||||
|
#define ADC_EXTERNALTRIGINJECCONV_T4_CC3 ((uint32_t)ADC_CR2_JEXTSEL_3)
|
||||||
|
#define ADC_EXTERNALTRIGINJECCONV_T4_TRGO ((uint32_t)(ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_0))
|
||||||
|
#define ADC_EXTERNALTRIGINJECCONV_T5_CC4 ((uint32_t)(ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_1))
|
||||||
|
#define ADC_EXTERNALTRIGINJECCONV_T5_TRGO ((uint32_t)(ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_1 | ADC_CR2_JEXTSEL_0))
|
||||||
|
#define ADC_EXTERNALTRIGINJECCONV_T8_CC2 ((uint32_t)(ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_2))
|
||||||
|
#define ADC_EXTERNALTRIGINJECCONV_T8_CC3 ((uint32_t)(ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_0))
|
||||||
|
#define ADC_EXTERNALTRIGINJECCONV_T8_CC4 ((uint32_t)(ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_1))
|
||||||
|
#define ADC_EXTERNALTRIGINJECCONV_EXT_IT15 ((uint32_t)ADC_CR2_JEXTSEL)
|
||||||
|
#define ADC_INJECTED_SOFTWARE_START ((uint32_t)ADC_CR2_JEXTSEL + 1U)
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup ADCEx_injected_rank ADC Injected Rank
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define ADC_INJECTED_RANK_1 0x00000001U
|
||||||
|
#define ADC_INJECTED_RANK_2 0x00000002U
|
||||||
|
#define ADC_INJECTED_RANK_3 0x00000003U
|
||||||
|
#define ADC_INJECTED_RANK_4 0x00000004U
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup ADCEx_channels ADC Specific Channels
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || \
|
||||||
|
defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) || \
|
||||||
|
defined(STM32F410Rx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || \
|
||||||
|
defined(STM32F412Cx)
|
||||||
|
#define ADC_CHANNEL_TEMPSENSOR ((uint32_t)ADC_CHANNEL_16)
|
||||||
|
#endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F401xC || STM32F401xE || STM32F410xx || STM32F412Zx ||
|
||||||
|
STM32F412Vx || STM32F412Rx || STM32F412Cx */
|
||||||
|
|
||||||
|
#if defined(STM32F411xE) || defined(STM32F413xx) || defined(STM32F423xx) || defined(STM32F427xx) || defined(STM32F437xx) ||\
|
||||||
|
defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
|
||||||
|
#define ADC_CHANNEL_DIFFERENCIATION_TEMPSENSOR_VBAT 0x10000000U /* Dummy bit for driver internal usage, not used in ADC channel setting registers CR1 or SQRx */
|
||||||
|
#define ADC_CHANNEL_TEMPSENSOR ((uint32_t)ADC_CHANNEL_18 | ADC_CHANNEL_DIFFERENCIATION_TEMPSENSOR_VBAT)
|
||||||
|
#endif /* STM32F411xE || STM32F413xx || STM32F423xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Exported macro ------------------------------------------------------------*/
|
||||||
|
/** @defgroup ADC_Exported_Macros ADC Exported Macros
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx)
|
||||||
|
/**
|
||||||
|
* @brief Disable internal path of ADC channel Vbat
|
||||||
|
* @note Use case of this macro:
|
||||||
|
* On devices STM32F42x and STM32F43x, ADC internal channels
|
||||||
|
* Vbat and VrefInt share the same internal path, only
|
||||||
|
* one of them can be enabled.This macro is to be used when ADC
|
||||||
|
* channels Vbat and VrefInt are selected, and must be called
|
||||||
|
* before starting conversion of ADC channel VrefInt in order
|
||||||
|
* to disable ADC channel Vbat.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define __HAL_ADC_PATH_INTERNAL_VBAT_DISABLE() (ADC->CCR &= ~(ADC_CCR_VBATE))
|
||||||
|
#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Exported functions --------------------------------------------------------*/
|
||||||
|
/** @addtogroup ADCEx_Exported_Functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup ADCEx_Exported_Functions_Group1
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* I/O operation functions ******************************************************/
|
||||||
|
HAL_StatusTypeDef HAL_ADCEx_InjectedStart(ADC_HandleTypeDef *hadc);
|
||||||
|
HAL_StatusTypeDef HAL_ADCEx_InjectedStop(ADC_HandleTypeDef *hadc);
|
||||||
|
HAL_StatusTypeDef HAL_ADCEx_InjectedPollForConversion(ADC_HandleTypeDef *hadc, uint32_t Timeout);
|
||||||
|
HAL_StatusTypeDef HAL_ADCEx_InjectedStart_IT(ADC_HandleTypeDef *hadc);
|
||||||
|
HAL_StatusTypeDef HAL_ADCEx_InjectedStop_IT(ADC_HandleTypeDef *hadc);
|
||||||
|
uint32_t HAL_ADCEx_InjectedGetValue(ADC_HandleTypeDef *hadc, uint32_t InjectedRank);
|
||||||
|
HAL_StatusTypeDef HAL_ADCEx_MultiModeStart_DMA(ADC_HandleTypeDef *hadc, uint32_t *pData, uint32_t Length);
|
||||||
|
HAL_StatusTypeDef HAL_ADCEx_MultiModeStop_DMA(ADC_HandleTypeDef *hadc);
|
||||||
|
uint32_t HAL_ADCEx_MultiModeGetValue(ADC_HandleTypeDef *hadc);
|
||||||
|
void HAL_ADCEx_InjectedConvCpltCallback(ADC_HandleTypeDef *hadc);
|
||||||
|
|
||||||
|
/* Peripheral Control functions *************************************************/
|
||||||
|
HAL_StatusTypeDef HAL_ADCEx_InjectedConfigChannel(ADC_HandleTypeDef *hadc, ADC_InjectionConfTypeDef *sConfigInjected);
|
||||||
|
HAL_StatusTypeDef HAL_ADCEx_MultiModeConfigChannel(ADC_HandleTypeDef *hadc, ADC_MultiModeTypeDef *multimode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
/* Private types -------------------------------------------------------------*/
|
||||||
|
/* Private variables ---------------------------------------------------------*/
|
||||||
|
/* Private constants ---------------------------------------------------------*/
|
||||||
|
/** @defgroup ADCEx_Private_Constants ADC Private Constants
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Private macros ------------------------------------------------------------*/
|
||||||
|
/** @defgroup ADCEx_Private_Macros ADC Private Macros
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || \
|
||||||
|
defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) || \
|
||||||
|
defined(STM32F410Rx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || \
|
||||||
|
defined(STM32F412Cx)
|
||||||
|
#define IS_ADC_CHANNEL(CHANNEL) ((CHANNEL) <= ADC_CHANNEL_18)
|
||||||
|
#endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F401xC || STM32F401xE ||
|
||||||
|
STM32F410xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */
|
||||||
|
|
||||||
|
#if defined(STM32F411xE) || defined(STM32F413xx) || defined(STM32F423xx) || defined(STM32F427xx) || \
|
||||||
|
defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F446xx) || \
|
||||||
|
defined(STM32F469xx) || defined(STM32F479xx)
|
||||||
|
#define IS_ADC_CHANNEL(CHANNEL) (((CHANNEL) <= ADC_CHANNEL_18) || \
|
||||||
|
((CHANNEL) == ADC_CHANNEL_TEMPSENSOR))
|
||||||
|
#endif /* STM32F411xE || STM32F413xx || STM32F423xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */
|
||||||
|
|
||||||
|
#define IS_ADC_MODE(MODE) (((MODE) == ADC_MODE_INDEPENDENT) || \
|
||||||
|
((MODE) == ADC_DUALMODE_REGSIMULT_INJECSIMULT) || \
|
||||||
|
((MODE) == ADC_DUALMODE_REGSIMULT_ALTERTRIG) || \
|
||||||
|
((MODE) == ADC_DUALMODE_INJECSIMULT) || \
|
||||||
|
((MODE) == ADC_DUALMODE_REGSIMULT) || \
|
||||||
|
((MODE) == ADC_DUALMODE_INTERL) || \
|
||||||
|
((MODE) == ADC_DUALMODE_ALTERTRIG) || \
|
||||||
|
((MODE) == ADC_TRIPLEMODE_REGSIMULT_INJECSIMULT) || \
|
||||||
|
((MODE) == ADC_TRIPLEMODE_REGSIMULT_AlterTrig) || \
|
||||||
|
((MODE) == ADC_TRIPLEMODE_INJECSIMULT) || \
|
||||||
|
((MODE) == ADC_TRIPLEMODE_REGSIMULT) || \
|
||||||
|
((MODE) == ADC_TRIPLEMODE_INTERL) || \
|
||||||
|
((MODE) == ADC_TRIPLEMODE_ALTERTRIG))
|
||||||
|
#define IS_ADC_DMA_ACCESS_MODE(MODE) (((MODE) == ADC_DMAACCESSMODE_DISABLED) || \
|
||||||
|
((MODE) == ADC_DMAACCESSMODE_1) || \
|
||||||
|
((MODE) == ADC_DMAACCESSMODE_2) || \
|
||||||
|
((MODE) == ADC_DMAACCESSMODE_3))
|
||||||
|
#define IS_ADC_EXT_INJEC_TRIG_EDGE(EDGE) (((EDGE) == ADC_EXTERNALTRIGINJECCONVEDGE_NONE) || \
|
||||||
|
((EDGE) == ADC_EXTERNALTRIGINJECCONVEDGE_RISING) || \
|
||||||
|
((EDGE) == ADC_EXTERNALTRIGINJECCONVEDGE_FALLING) || \
|
||||||
|
((EDGE) == ADC_EXTERNALTRIGINJECCONVEDGE_RISINGFALLING))
|
||||||
|
#define IS_ADC_EXT_INJEC_TRIG(INJTRIG) (((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_CC4) || \
|
||||||
|
((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_TRGO) || \
|
||||||
|
((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_CC1) || \
|
||||||
|
((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_TRGO) || \
|
||||||
|
((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC2) || \
|
||||||
|
((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC4) || \
|
||||||
|
((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_CC1) || \
|
||||||
|
((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_CC2) || \
|
||||||
|
((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_CC3) || \
|
||||||
|
((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_TRGO) || \
|
||||||
|
((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T5_CC4) || \
|
||||||
|
((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T5_TRGO) || \
|
||||||
|
((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T8_CC2) || \
|
||||||
|
((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T8_CC3) || \
|
||||||
|
((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T8_CC4) || \
|
||||||
|
((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_EXT_IT15)|| \
|
||||||
|
((INJTRIG) == ADC_INJECTED_SOFTWARE_START))
|
||||||
|
#define IS_ADC_INJECTED_LENGTH(LENGTH) (((LENGTH) >= 1U) && ((LENGTH) <= 4U))
|
||||||
|
#define IS_ADC_INJECTED_RANK(RANK) (((RANK) >= 1U) && ((RANK) <= 4U))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the selected injected Channel rank.
|
||||||
|
* @param _CHANNELNB_ Channel number.
|
||||||
|
* @param _RANKNB_ Rank number.
|
||||||
|
* @param _JSQR_JL_ Sequence length.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define ADC_JSQR(_CHANNELNB_, _RANKNB_, _JSQR_JL_) (((uint32_t)((uint16_t)(_CHANNELNB_))) << (5U * (uint8_t)(((_RANKNB_) + 3U) - (_JSQR_JL_))))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Defines if the selected ADC is within ADC common register ADC123 or ADC1
|
||||||
|
* if available (ADC2, ADC3 availability depends on STM32 product)
|
||||||
|
* @param __HANDLE__ ADC handle
|
||||||
|
* @retval Common control register ADC123 or ADC1
|
||||||
|
*/
|
||||||
|
#if defined(STM32F405xx) || defined(STM32F407xx) || defined(STM32F415xx) || defined(STM32F417xx) || defined(STM32F427xx) || defined(STM32F429xx) || defined(STM32F437xx) || defined(STM32F439xx) || defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
|
||||||
|
#define ADC_COMMON_REGISTER(__HANDLE__) ADC123_COMMON
|
||||||
|
#else
|
||||||
|
#define ADC_COMMON_REGISTER(__HANDLE__) ADC1_COMMON
|
||||||
|
#endif /* STM32F405xx || STM32F407xx || STM32F415xx || STM32F417xx || STM32F427xx || STM32F429xx || STM32F437xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Private functions ---------------------------------------------------------*/
|
||||||
|
/** @defgroup ADCEx_Private_Functions ADC Private Functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /*__STM32F4xx_ADC_EX_H */
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,741 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file stm32f4xx_hal_i2c.h
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief Header file of I2C HAL module.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2016 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __STM32F4xx_HAL_I2C_H
|
||||||
|
#define __STM32F4xx_HAL_I2C_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "stm32f4xx_hal_def.h"
|
||||||
|
|
||||||
|
/** @addtogroup STM32F4xx_HAL_Driver
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup I2C
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Exported types ------------------------------------------------------------*/
|
||||||
|
/** @defgroup I2C_Exported_Types I2C Exported Types
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup I2C_Configuration_Structure_definition I2C Configuration Structure definition
|
||||||
|
* @brief I2C Configuration Structure definition
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32_t ClockSpeed; /*!< Specifies the clock frequency.
|
||||||
|
This parameter must be set to a value lower than 400kHz */
|
||||||
|
|
||||||
|
uint32_t DutyCycle; /*!< Specifies the I2C fast mode duty cycle.
|
||||||
|
This parameter can be a value of @ref I2C_duty_cycle_in_fast_mode */
|
||||||
|
|
||||||
|
uint32_t OwnAddress1; /*!< Specifies the first device own address.
|
||||||
|
This parameter can be a 7-bit or 10-bit address. */
|
||||||
|
|
||||||
|
uint32_t AddressingMode; /*!< Specifies if 7-bit or 10-bit addressing mode is selected.
|
||||||
|
This parameter can be a value of @ref I2C_addressing_mode */
|
||||||
|
|
||||||
|
uint32_t DualAddressMode; /*!< Specifies if dual addressing mode is selected.
|
||||||
|
This parameter can be a value of @ref I2C_dual_addressing_mode */
|
||||||
|
|
||||||
|
uint32_t OwnAddress2; /*!< Specifies the second device own address if dual addressing mode is selected
|
||||||
|
This parameter can be a 7-bit address. */
|
||||||
|
|
||||||
|
uint32_t GeneralCallMode; /*!< Specifies if general call mode is selected.
|
||||||
|
This parameter can be a value of @ref I2C_general_call_addressing_mode */
|
||||||
|
|
||||||
|
uint32_t NoStretchMode; /*!< Specifies if nostretch mode is selected.
|
||||||
|
This parameter can be a value of @ref I2C_nostretch_mode */
|
||||||
|
|
||||||
|
} I2C_InitTypeDef;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup HAL_state_structure_definition HAL state structure definition
|
||||||
|
* @brief HAL State structure definition
|
||||||
|
* @note HAL I2C State value coding follow below described bitmap :
|
||||||
|
* b7-b6 Error information
|
||||||
|
* 00 : No Error
|
||||||
|
* 01 : Abort (Abort user request on going)
|
||||||
|
* 10 : Timeout
|
||||||
|
* 11 : Error
|
||||||
|
* b5 Peripheral initialization status
|
||||||
|
* 0 : Reset (Peripheral not initialized)
|
||||||
|
* 1 : Init done (Peripheral initialized and ready to use. HAL I2C Init function called)
|
||||||
|
* b4 (not used)
|
||||||
|
* x : Should be set to 0
|
||||||
|
* b3
|
||||||
|
* 0 : Ready or Busy (No Listen mode ongoing)
|
||||||
|
* 1 : Listen (Peripheral in Address Listen Mode)
|
||||||
|
* b2 Intrinsic process state
|
||||||
|
* 0 : Ready
|
||||||
|
* 1 : Busy (Peripheral busy with some configuration or internal operations)
|
||||||
|
* b1 Rx state
|
||||||
|
* 0 : Ready (no Rx operation ongoing)
|
||||||
|
* 1 : Busy (Rx operation ongoing)
|
||||||
|
* b0 Tx state
|
||||||
|
* 0 : Ready (no Tx operation ongoing)
|
||||||
|
* 1 : Busy (Tx operation ongoing)
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
HAL_I2C_STATE_RESET = 0x00U, /*!< Peripheral is not yet Initialized */
|
||||||
|
HAL_I2C_STATE_READY = 0x20U, /*!< Peripheral Initialized and ready for use */
|
||||||
|
HAL_I2C_STATE_BUSY = 0x24U, /*!< An internal process is ongoing */
|
||||||
|
HAL_I2C_STATE_BUSY_TX = 0x21U, /*!< Data Transmission process is ongoing */
|
||||||
|
HAL_I2C_STATE_BUSY_RX = 0x22U, /*!< Data Reception process is ongoing */
|
||||||
|
HAL_I2C_STATE_LISTEN = 0x28U, /*!< Address Listen Mode is ongoing */
|
||||||
|
HAL_I2C_STATE_BUSY_TX_LISTEN = 0x29U, /*!< Address Listen Mode and Data Transmission
|
||||||
|
process is ongoing */
|
||||||
|
HAL_I2C_STATE_BUSY_RX_LISTEN = 0x2AU, /*!< Address Listen Mode and Data Reception
|
||||||
|
process is ongoing */
|
||||||
|
HAL_I2C_STATE_ABORT = 0x60U, /*!< Abort user request ongoing */
|
||||||
|
HAL_I2C_STATE_TIMEOUT = 0xA0U, /*!< Timeout state */
|
||||||
|
HAL_I2C_STATE_ERROR = 0xE0U /*!< Error */
|
||||||
|
|
||||||
|
} HAL_I2C_StateTypeDef;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup HAL_mode_structure_definition HAL mode structure definition
|
||||||
|
* @brief HAL Mode structure definition
|
||||||
|
* @note HAL I2C Mode value coding follow below described bitmap :\n
|
||||||
|
* b7 (not used)\n
|
||||||
|
* x : Should be set to 0\n
|
||||||
|
* b6\n
|
||||||
|
* 0 : None\n
|
||||||
|
* 1 : Memory (HAL I2C communication is in Memory Mode)\n
|
||||||
|
* b5\n
|
||||||
|
* 0 : None\n
|
||||||
|
* 1 : Slave (HAL I2C communication is in Slave Mode)\n
|
||||||
|
* b4\n
|
||||||
|
* 0 : None\n
|
||||||
|
* 1 : Master (HAL I2C communication is in Master Mode)\n
|
||||||
|
* b3-b2-b1-b0 (not used)\n
|
||||||
|
* xxxx : Should be set to 0000
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
HAL_I2C_MODE_NONE = 0x00U, /*!< No I2C communication on going */
|
||||||
|
HAL_I2C_MODE_MASTER = 0x10U, /*!< I2C communication is in Master Mode */
|
||||||
|
HAL_I2C_MODE_SLAVE = 0x20U, /*!< I2C communication is in Slave Mode */
|
||||||
|
HAL_I2C_MODE_MEM = 0x40U /*!< I2C communication is in Memory Mode */
|
||||||
|
|
||||||
|
} HAL_I2C_ModeTypeDef;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup I2C_Error_Code_definition I2C Error Code definition
|
||||||
|
* @brief I2C Error Code definition
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define HAL_I2C_ERROR_NONE 0x00000000U /*!< No error */
|
||||||
|
#define HAL_I2C_ERROR_BERR 0x00000001U /*!< BERR error */
|
||||||
|
#define HAL_I2C_ERROR_ARLO 0x00000002U /*!< ARLO error */
|
||||||
|
#define HAL_I2C_ERROR_AF 0x00000004U /*!< AF error */
|
||||||
|
#define HAL_I2C_ERROR_OVR 0x00000008U /*!< OVR error */
|
||||||
|
#define HAL_I2C_ERROR_DMA 0x00000010U /*!< DMA transfer error */
|
||||||
|
#define HAL_I2C_ERROR_TIMEOUT 0x00000020U /*!< Timeout Error */
|
||||||
|
#define HAL_I2C_ERROR_SIZE 0x00000040U /*!< Size Management error */
|
||||||
|
#define HAL_I2C_ERROR_DMA_PARAM 0x00000080U /*!< DMA Parameter Error */
|
||||||
|
#define HAL_I2C_WRONG_START 0x00000200U /*!< Wrong start Error */
|
||||||
|
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1)
|
||||||
|
#define HAL_I2C_ERROR_INVALID_CALLBACK 0x00000100U /*!< Invalid Callback error */
|
||||||
|
#endif /* USE_HAL_I2C_REGISTER_CALLBACKS */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup I2C_handle_Structure_definition I2C handle Structure definition
|
||||||
|
* @brief I2C handle Structure definition
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1)
|
||||||
|
typedef struct __I2C_HandleTypeDef
|
||||||
|
#else
|
||||||
|
typedef struct
|
||||||
|
#endif /* USE_HAL_I2C_REGISTER_CALLBACKS */
|
||||||
|
{
|
||||||
|
I2C_TypeDef *Instance; /*!< I2C registers base address */
|
||||||
|
|
||||||
|
I2C_InitTypeDef Init; /*!< I2C communication parameters */
|
||||||
|
|
||||||
|
uint8_t *pBuffPtr; /*!< Pointer to I2C transfer buffer */
|
||||||
|
|
||||||
|
uint16_t XferSize; /*!< I2C transfer size */
|
||||||
|
|
||||||
|
__IO uint16_t XferCount; /*!< I2C transfer counter */
|
||||||
|
|
||||||
|
__IO uint32_t XferOptions; /*!< I2C transfer options */
|
||||||
|
|
||||||
|
__IO uint32_t PreviousState; /*!< I2C communication Previous state and mode
|
||||||
|
context for internal usage */
|
||||||
|
|
||||||
|
DMA_HandleTypeDef *hdmatx; /*!< I2C Tx DMA handle parameters */
|
||||||
|
|
||||||
|
DMA_HandleTypeDef *hdmarx; /*!< I2C Rx DMA handle parameters */
|
||||||
|
|
||||||
|
HAL_LockTypeDef Lock; /*!< I2C locking object */
|
||||||
|
|
||||||
|
__IO HAL_I2C_StateTypeDef State; /*!< I2C communication state */
|
||||||
|
|
||||||
|
__IO HAL_I2C_ModeTypeDef Mode; /*!< I2C communication mode */
|
||||||
|
|
||||||
|
__IO uint32_t ErrorCode; /*!< I2C Error code */
|
||||||
|
|
||||||
|
__IO uint32_t Devaddress; /*!< I2C Target device address */
|
||||||
|
|
||||||
|
__IO uint32_t Memaddress; /*!< I2C Target memory address */
|
||||||
|
|
||||||
|
__IO uint32_t MemaddSize; /*!< I2C Target memory address size */
|
||||||
|
|
||||||
|
__IO uint32_t EventCount; /*!< I2C Event counter */
|
||||||
|
|
||||||
|
|
||||||
|
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1)
|
||||||
|
void (* MasterTxCpltCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Master Tx Transfer completed callback */
|
||||||
|
void (* MasterRxCpltCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Master Rx Transfer completed callback */
|
||||||
|
void (* SlaveTxCpltCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Slave Tx Transfer completed callback */
|
||||||
|
void (* SlaveRxCpltCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Slave Rx Transfer completed callback */
|
||||||
|
void (* ListenCpltCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Listen Complete callback */
|
||||||
|
void (* MemTxCpltCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Memory Tx Transfer completed callback */
|
||||||
|
void (* MemRxCpltCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Memory Rx Transfer completed callback */
|
||||||
|
void (* ErrorCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Error callback */
|
||||||
|
void (* AbortCpltCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Abort callback */
|
||||||
|
|
||||||
|
void (* AddrCallback)(struct __I2C_HandleTypeDef *hi2c, uint8_t TransferDirection, uint16_t AddrMatchCode); /*!< I2C Slave Address Match callback */
|
||||||
|
|
||||||
|
void (* MspInitCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Msp Init callback */
|
||||||
|
void (* MspDeInitCallback)(struct __I2C_HandleTypeDef *hi2c); /*!< I2C Msp DeInit callback */
|
||||||
|
|
||||||
|
#endif /* USE_HAL_I2C_REGISTER_CALLBACKS */
|
||||||
|
} I2C_HandleTypeDef;
|
||||||
|
|
||||||
|
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1)
|
||||||
|
/**
|
||||||
|
* @brief HAL I2C Callback ID enumeration definition
|
||||||
|
*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
HAL_I2C_MASTER_TX_COMPLETE_CB_ID = 0x00U, /*!< I2C Master Tx Transfer completed callback ID */
|
||||||
|
HAL_I2C_MASTER_RX_COMPLETE_CB_ID = 0x01U, /*!< I2C Master Rx Transfer completed callback ID */
|
||||||
|
HAL_I2C_SLAVE_TX_COMPLETE_CB_ID = 0x02U, /*!< I2C Slave Tx Transfer completed callback ID */
|
||||||
|
HAL_I2C_SLAVE_RX_COMPLETE_CB_ID = 0x03U, /*!< I2C Slave Rx Transfer completed callback ID */
|
||||||
|
HAL_I2C_LISTEN_COMPLETE_CB_ID = 0x04U, /*!< I2C Listen Complete callback ID */
|
||||||
|
HAL_I2C_MEM_TX_COMPLETE_CB_ID = 0x05U, /*!< I2C Memory Tx Transfer callback ID */
|
||||||
|
HAL_I2C_MEM_RX_COMPLETE_CB_ID = 0x06U, /*!< I2C Memory Rx Transfer completed callback ID */
|
||||||
|
HAL_I2C_ERROR_CB_ID = 0x07U, /*!< I2C Error callback ID */
|
||||||
|
HAL_I2C_ABORT_CB_ID = 0x08U, /*!< I2C Abort callback ID */
|
||||||
|
|
||||||
|
HAL_I2C_MSPINIT_CB_ID = 0x09U, /*!< I2C Msp Init callback ID */
|
||||||
|
HAL_I2C_MSPDEINIT_CB_ID = 0x0AU /*!< I2C Msp DeInit callback ID */
|
||||||
|
|
||||||
|
} HAL_I2C_CallbackIDTypeDef;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief HAL I2C Callback pointer definition
|
||||||
|
*/
|
||||||
|
typedef void (*pI2C_CallbackTypeDef)(I2C_HandleTypeDef *hi2c); /*!< pointer to an I2C callback function */
|
||||||
|
typedef void (*pI2C_AddrCallbackTypeDef)(I2C_HandleTypeDef *hi2c, uint8_t TransferDirection, uint16_t AddrMatchCode); /*!< pointer to an I2C Address Match callback function */
|
||||||
|
|
||||||
|
#endif /* USE_HAL_I2C_REGISTER_CALLBACKS */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
/* Exported constants --------------------------------------------------------*/
|
||||||
|
|
||||||
|
/** @defgroup I2C_Exported_Constants I2C Exported Constants
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup I2C_duty_cycle_in_fast_mode I2C duty cycle in fast mode
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define I2C_DUTYCYCLE_2 0x00000000U
|
||||||
|
#define I2C_DUTYCYCLE_16_9 I2C_CCR_DUTY
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup I2C_addressing_mode I2C addressing mode
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define I2C_ADDRESSINGMODE_7BIT 0x00004000U
|
||||||
|
#define I2C_ADDRESSINGMODE_10BIT (I2C_OAR1_ADDMODE | 0x00004000U)
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup I2C_dual_addressing_mode I2C dual addressing mode
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define I2C_DUALADDRESS_DISABLE 0x00000000U
|
||||||
|
#define I2C_DUALADDRESS_ENABLE I2C_OAR2_ENDUAL
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup I2C_general_call_addressing_mode I2C general call addressing mode
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define I2C_GENERALCALL_DISABLE 0x00000000U
|
||||||
|
#define I2C_GENERALCALL_ENABLE I2C_CR1_ENGC
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup I2C_nostretch_mode I2C nostretch mode
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define I2C_NOSTRETCH_DISABLE 0x00000000U
|
||||||
|
#define I2C_NOSTRETCH_ENABLE I2C_CR1_NOSTRETCH
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup I2C_Memory_Address_Size I2C Memory Address Size
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define I2C_MEMADD_SIZE_8BIT 0x00000001U
|
||||||
|
#define I2C_MEMADD_SIZE_16BIT 0x00000010U
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup I2C_XferDirection_definition I2C XferDirection definition
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define I2C_DIRECTION_RECEIVE 0x00000000U
|
||||||
|
#define I2C_DIRECTION_TRANSMIT 0x00000001U
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup I2C_XferOptions_definition I2C XferOptions definition
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define I2C_FIRST_FRAME 0x00000001U
|
||||||
|
#define I2C_FIRST_AND_NEXT_FRAME 0x00000002U
|
||||||
|
#define I2C_NEXT_FRAME 0x00000004U
|
||||||
|
#define I2C_FIRST_AND_LAST_FRAME 0x00000008U
|
||||||
|
#define I2C_LAST_FRAME_NO_STOP 0x00000010U
|
||||||
|
#define I2C_LAST_FRAME 0x00000020U
|
||||||
|
|
||||||
|
/* List of XferOptions in usage of :
|
||||||
|
* 1- Restart condition in all use cases (direction change or not)
|
||||||
|
*/
|
||||||
|
#define I2C_OTHER_FRAME (0x00AA0000U)
|
||||||
|
#define I2C_OTHER_AND_LAST_FRAME (0xAA000000U)
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup I2C_Interrupt_configuration_definition I2C Interrupt configuration definition
|
||||||
|
* @brief I2C Interrupt definition
|
||||||
|
* Elements values convention: 0xXXXXXXXX
|
||||||
|
* - XXXXXXXX : Interrupt control mask
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define I2C_IT_BUF I2C_CR2_ITBUFEN
|
||||||
|
#define I2C_IT_EVT I2C_CR2_ITEVTEN
|
||||||
|
#define I2C_IT_ERR I2C_CR2_ITERREN
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup I2C_Flag_definition I2C Flag definition
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define I2C_FLAG_OVR 0x00010800U
|
||||||
|
#define I2C_FLAG_AF 0x00010400U
|
||||||
|
#define I2C_FLAG_ARLO 0x00010200U
|
||||||
|
#define I2C_FLAG_BERR 0x00010100U
|
||||||
|
#define I2C_FLAG_TXE 0x00010080U
|
||||||
|
#define I2C_FLAG_RXNE 0x00010040U
|
||||||
|
#define I2C_FLAG_STOPF 0x00010010U
|
||||||
|
#define I2C_FLAG_ADD10 0x00010008U
|
||||||
|
#define I2C_FLAG_BTF 0x00010004U
|
||||||
|
#define I2C_FLAG_ADDR 0x00010002U
|
||||||
|
#define I2C_FLAG_SB 0x00010001U
|
||||||
|
#define I2C_FLAG_DUALF 0x00100080U
|
||||||
|
#define I2C_FLAG_GENCALL 0x00100010U
|
||||||
|
#define I2C_FLAG_TRA 0x00100004U
|
||||||
|
#define I2C_FLAG_BUSY 0x00100002U
|
||||||
|
#define I2C_FLAG_MSL 0x00100001U
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Exported macros -----------------------------------------------------------*/
|
||||||
|
|
||||||
|
/** @defgroup I2C_Exported_Macros I2C Exported Macros
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @brief Reset I2C handle state.
|
||||||
|
* @param __HANDLE__ specifies the I2C Handle.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1)
|
||||||
|
#define __HAL_I2C_RESET_HANDLE_STATE(__HANDLE__) do{ \
|
||||||
|
(__HANDLE__)->State = HAL_I2C_STATE_RESET; \
|
||||||
|
(__HANDLE__)->MspInitCallback = NULL; \
|
||||||
|
(__HANDLE__)->MspDeInitCallback = NULL; \
|
||||||
|
} while(0)
|
||||||
|
#else
|
||||||
|
#define __HAL_I2C_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_I2C_STATE_RESET)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** @brief Enable or disable the specified I2C interrupts.
|
||||||
|
* @param __HANDLE__ specifies the I2C Handle.
|
||||||
|
* @param __INTERRUPT__ specifies the interrupt source to enable or disable.
|
||||||
|
* This parameter can be one of the following values:
|
||||||
|
* @arg I2C_IT_BUF: Buffer interrupt enable
|
||||||
|
* @arg I2C_IT_EVT: Event interrupt enable
|
||||||
|
* @arg I2C_IT_ERR: Error interrupt enable
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define __HAL_I2C_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BIT((__HANDLE__)->Instance->CR2,(__INTERRUPT__))
|
||||||
|
#define __HAL_I2C_DISABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BIT((__HANDLE__)->Instance->CR2, (__INTERRUPT__))
|
||||||
|
|
||||||
|
/** @brief Checks if the specified I2C interrupt source is enabled or disabled.
|
||||||
|
* @param __HANDLE__ specifies the I2C Handle.
|
||||||
|
* @param __INTERRUPT__ specifies the I2C interrupt source to check.
|
||||||
|
* This parameter can be one of the following values:
|
||||||
|
* @arg I2C_IT_BUF: Buffer interrupt enable
|
||||||
|
* @arg I2C_IT_EVT: Event interrupt enable
|
||||||
|
* @arg I2C_IT_ERR: Error interrupt enable
|
||||||
|
* @retval The new state of __INTERRUPT__ (TRUE or FALSE).
|
||||||
|
*/
|
||||||
|
#define __HAL_I2C_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CR2 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
|
||||||
|
|
||||||
|
/** @brief Checks whether the specified I2C flag is set or not.
|
||||||
|
* @param __HANDLE__ specifies the I2C Handle.
|
||||||
|
* @param __FLAG__ specifies the flag to check.
|
||||||
|
* This parameter can be one of the following values:
|
||||||
|
* @arg I2C_FLAG_OVR: Overrun/Underrun flag
|
||||||
|
* @arg I2C_FLAG_AF: Acknowledge failure flag
|
||||||
|
* @arg I2C_FLAG_ARLO: Arbitration lost flag
|
||||||
|
* @arg I2C_FLAG_BERR: Bus error flag
|
||||||
|
* @arg I2C_FLAG_TXE: Data register empty flag
|
||||||
|
* @arg I2C_FLAG_RXNE: Data register not empty flag
|
||||||
|
* @arg I2C_FLAG_STOPF: Stop detection flag
|
||||||
|
* @arg I2C_FLAG_ADD10: 10-bit header sent flag
|
||||||
|
* @arg I2C_FLAG_BTF: Byte transfer finished flag
|
||||||
|
* @arg I2C_FLAG_ADDR: Address sent flag
|
||||||
|
* Address matched flag
|
||||||
|
* @arg I2C_FLAG_SB: Start bit flag
|
||||||
|
* @arg I2C_FLAG_DUALF: Dual flag
|
||||||
|
* @arg I2C_FLAG_GENCALL: General call header flag
|
||||||
|
* @arg I2C_FLAG_TRA: Transmitter/Receiver flag
|
||||||
|
* @arg I2C_FLAG_BUSY: Bus busy flag
|
||||||
|
* @arg I2C_FLAG_MSL: Master/Slave flag
|
||||||
|
* @retval The new state of __FLAG__ (TRUE or FALSE).
|
||||||
|
*/
|
||||||
|
#define __HAL_I2C_GET_FLAG(__HANDLE__, __FLAG__) ((((uint8_t)((__FLAG__) >> 16U)) == 0x01U) ? \
|
||||||
|
(((((__HANDLE__)->Instance->SR1) & ((__FLAG__) & I2C_FLAG_MASK)) == ((__FLAG__) & I2C_FLAG_MASK)) ? SET : RESET) : \
|
||||||
|
(((((__HANDLE__)->Instance->SR2) & ((__FLAG__) & I2C_FLAG_MASK)) == ((__FLAG__) & I2C_FLAG_MASK)) ? SET : RESET))
|
||||||
|
|
||||||
|
/** @brief Clears the I2C pending flags which are cleared by writing 0 in a specific bit.
|
||||||
|
* @param __HANDLE__ specifies the I2C Handle.
|
||||||
|
* @param __FLAG__ specifies the flag to clear.
|
||||||
|
* This parameter can be any combination of the following values:
|
||||||
|
* @arg I2C_FLAG_OVR: Overrun/Underrun flag (Slave mode)
|
||||||
|
* @arg I2C_FLAG_AF: Acknowledge failure flag
|
||||||
|
* @arg I2C_FLAG_ARLO: Arbitration lost flag (Master mode)
|
||||||
|
* @arg I2C_FLAG_BERR: Bus error flag
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define __HAL_I2C_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR1 = ~((__FLAG__) & I2C_FLAG_MASK))
|
||||||
|
|
||||||
|
/** @brief Clears the I2C ADDR pending flag.
|
||||||
|
* @param __HANDLE__ specifies the I2C Handle.
|
||||||
|
* This parameter can be I2C where x: 1, 2, or 3 to select the I2C peripheral.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define __HAL_I2C_CLEAR_ADDRFLAG(__HANDLE__) \
|
||||||
|
do{ \
|
||||||
|
__IO uint32_t tmpreg = 0x00U; \
|
||||||
|
tmpreg = (__HANDLE__)->Instance->SR1; \
|
||||||
|
tmpreg = (__HANDLE__)->Instance->SR2; \
|
||||||
|
UNUSED(tmpreg); \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
|
/** @brief Clears the I2C STOPF pending flag.
|
||||||
|
* @param __HANDLE__ specifies the I2C Handle.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define __HAL_I2C_CLEAR_STOPFLAG(__HANDLE__) \
|
||||||
|
do{ \
|
||||||
|
__IO uint32_t tmpreg = 0x00U; \
|
||||||
|
tmpreg = (__HANDLE__)->Instance->SR1; \
|
||||||
|
SET_BIT((__HANDLE__)->Instance->CR1, I2C_CR1_PE); \
|
||||||
|
UNUSED(tmpreg); \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
|
/** @brief Enable the specified I2C peripheral.
|
||||||
|
* @param __HANDLE__ specifies the I2C Handle.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define __HAL_I2C_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CR1, I2C_CR1_PE)
|
||||||
|
|
||||||
|
/** @brief Disable the specified I2C peripheral.
|
||||||
|
* @param __HANDLE__ specifies the I2C Handle.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define __HAL_I2C_DISABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CR1, I2C_CR1_PE)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Include I2C HAL Extension module */
|
||||||
|
#include "stm32f4xx_hal_i2c_ex.h"
|
||||||
|
|
||||||
|
/* Exported functions --------------------------------------------------------*/
|
||||||
|
/** @addtogroup I2C_Exported_Functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup I2C_Exported_Functions_Group1 Initialization and de-initialization functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/* Initialization and de-initialization functions******************************/
|
||||||
|
HAL_StatusTypeDef HAL_I2C_Init(I2C_HandleTypeDef *hi2c);
|
||||||
|
HAL_StatusTypeDef HAL_I2C_DeInit(I2C_HandleTypeDef *hi2c);
|
||||||
|
void HAL_I2C_MspInit(I2C_HandleTypeDef *hi2c);
|
||||||
|
void HAL_I2C_MspDeInit(I2C_HandleTypeDef *hi2c);
|
||||||
|
|
||||||
|
/* Callbacks Register/UnRegister functions ***********************************/
|
||||||
|
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1)
|
||||||
|
HAL_StatusTypeDef HAL_I2C_RegisterCallback(I2C_HandleTypeDef *hi2c, HAL_I2C_CallbackIDTypeDef CallbackID, pI2C_CallbackTypeDef pCallback);
|
||||||
|
HAL_StatusTypeDef HAL_I2C_UnRegisterCallback(I2C_HandleTypeDef *hi2c, HAL_I2C_CallbackIDTypeDef CallbackID);
|
||||||
|
|
||||||
|
HAL_StatusTypeDef HAL_I2C_RegisterAddrCallback(I2C_HandleTypeDef *hi2c, pI2C_AddrCallbackTypeDef pCallback);
|
||||||
|
HAL_StatusTypeDef HAL_I2C_UnRegisterAddrCallback(I2C_HandleTypeDef *hi2c);
|
||||||
|
#endif /* USE_HAL_I2C_REGISTER_CALLBACKS */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup I2C_Exported_Functions_Group2 Input and Output operation functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/* IO operation functions ****************************************************/
|
||||||
|
/******* Blocking mode: Polling */
|
||||||
|
HAL_StatusTypeDef HAL_I2C_Master_Transmit(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout);
|
||||||
|
HAL_StatusTypeDef HAL_I2C_Master_Receive(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout);
|
||||||
|
HAL_StatusTypeDef HAL_I2C_Slave_Transmit(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t Timeout);
|
||||||
|
HAL_StatusTypeDef HAL_I2C_Slave_Receive(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t Timeout);
|
||||||
|
HAL_StatusTypeDef HAL_I2C_Mem_Write(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size, uint32_t Timeout);
|
||||||
|
HAL_StatusTypeDef HAL_I2C_Mem_Read(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size, uint32_t Timeout);
|
||||||
|
HAL_StatusTypeDef HAL_I2C_IsDeviceReady(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint32_t Trials, uint32_t Timeout);
|
||||||
|
|
||||||
|
/******* Non-Blocking mode: Interrupt */
|
||||||
|
HAL_StatusTypeDef HAL_I2C_Master_Transmit_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size);
|
||||||
|
HAL_StatusTypeDef HAL_I2C_Master_Receive_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size);
|
||||||
|
HAL_StatusTypeDef HAL_I2C_Slave_Transmit_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size);
|
||||||
|
HAL_StatusTypeDef HAL_I2C_Slave_Receive_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size);
|
||||||
|
HAL_StatusTypeDef HAL_I2C_Mem_Write_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
|
||||||
|
HAL_StatusTypeDef HAL_I2C_Mem_Read_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
|
||||||
|
|
||||||
|
HAL_StatusTypeDef HAL_I2C_Master_Seq_Transmit_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t XferOptions);
|
||||||
|
HAL_StatusTypeDef HAL_I2C_Master_Seq_Receive_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t XferOptions);
|
||||||
|
HAL_StatusTypeDef HAL_I2C_Slave_Seq_Transmit_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t XferOptions);
|
||||||
|
HAL_StatusTypeDef HAL_I2C_Slave_Seq_Receive_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t XferOptions);
|
||||||
|
HAL_StatusTypeDef HAL_I2C_EnableListen_IT(I2C_HandleTypeDef *hi2c);
|
||||||
|
HAL_StatusTypeDef HAL_I2C_DisableListen_IT(I2C_HandleTypeDef *hi2c);
|
||||||
|
HAL_StatusTypeDef HAL_I2C_Master_Abort_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress);
|
||||||
|
|
||||||
|
/******* Non-Blocking mode: DMA */
|
||||||
|
HAL_StatusTypeDef HAL_I2C_Master_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size);
|
||||||
|
HAL_StatusTypeDef HAL_I2C_Master_Receive_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size);
|
||||||
|
HAL_StatusTypeDef HAL_I2C_Slave_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size);
|
||||||
|
HAL_StatusTypeDef HAL_I2C_Slave_Receive_DMA(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size);
|
||||||
|
HAL_StatusTypeDef HAL_I2C_Mem_Write_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
|
||||||
|
HAL_StatusTypeDef HAL_I2C_Mem_Read_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
|
||||||
|
|
||||||
|
HAL_StatusTypeDef HAL_I2C_Master_Seq_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t XferOptions);
|
||||||
|
HAL_StatusTypeDef HAL_I2C_Master_Seq_Receive_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t XferOptions);
|
||||||
|
HAL_StatusTypeDef HAL_I2C_Slave_Seq_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t XferOptions);
|
||||||
|
HAL_StatusTypeDef HAL_I2C_Slave_Seq_Receive_DMA(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t XferOptions);
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup I2C_IRQ_Handler_and_Callbacks IRQ Handler and Callbacks
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/******* I2C IRQHandler and Callbacks used in non blocking modes (Interrupt and DMA) */
|
||||||
|
void HAL_I2C_EV_IRQHandler(I2C_HandleTypeDef *hi2c);
|
||||||
|
void HAL_I2C_ER_IRQHandler(I2C_HandleTypeDef *hi2c);
|
||||||
|
void HAL_I2C_MasterTxCpltCallback(I2C_HandleTypeDef *hi2c);
|
||||||
|
void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c);
|
||||||
|
void HAL_I2C_SlaveTxCpltCallback(I2C_HandleTypeDef *hi2c);
|
||||||
|
void HAL_I2C_SlaveRxCpltCallback(I2C_HandleTypeDef *hi2c);
|
||||||
|
void HAL_I2C_AddrCallback(I2C_HandleTypeDef *hi2c, uint8_t TransferDirection, uint16_t AddrMatchCode);
|
||||||
|
void HAL_I2C_ListenCpltCallback(I2C_HandleTypeDef *hi2c);
|
||||||
|
void HAL_I2C_MemTxCpltCallback(I2C_HandleTypeDef *hi2c);
|
||||||
|
void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c);
|
||||||
|
void HAL_I2C_ErrorCallback(I2C_HandleTypeDef *hi2c);
|
||||||
|
void HAL_I2C_AbortCpltCallback(I2C_HandleTypeDef *hi2c);
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup I2C_Exported_Functions_Group3 Peripheral State, Mode and Error functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/* Peripheral State, Mode and Error functions *********************************/
|
||||||
|
HAL_I2C_StateTypeDef HAL_I2C_GetState(I2C_HandleTypeDef *hi2c);
|
||||||
|
HAL_I2C_ModeTypeDef HAL_I2C_GetMode(I2C_HandleTypeDef *hi2c);
|
||||||
|
uint32_t HAL_I2C_GetError(I2C_HandleTypeDef *hi2c);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
/* Private types -------------------------------------------------------------*/
|
||||||
|
/* Private variables ---------------------------------------------------------*/
|
||||||
|
/* Private constants ---------------------------------------------------------*/
|
||||||
|
/** @defgroup I2C_Private_Constants I2C Private Constants
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define I2C_FLAG_MASK 0x0000FFFFU
|
||||||
|
#define I2C_MIN_PCLK_FREQ_STANDARD 2000000U /*!< 2 MHz */
|
||||||
|
#define I2C_MIN_PCLK_FREQ_FAST 4000000U /*!< 4 MHz */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Private macros ------------------------------------------------------------*/
|
||||||
|
/** @defgroup I2C_Private_Macros I2C Private Macros
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define I2C_MIN_PCLK_FREQ(__PCLK__, __SPEED__) (((__SPEED__) <= 100000U) ? ((__PCLK__) < I2C_MIN_PCLK_FREQ_STANDARD) : ((__PCLK__) < I2C_MIN_PCLK_FREQ_FAST))
|
||||||
|
#define I2C_CCR_CALCULATION(__PCLK__, __SPEED__, __COEFF__) (((((__PCLK__) - 1U)/((__SPEED__) * (__COEFF__))) + 1U) & I2C_CCR_CCR)
|
||||||
|
#define I2C_FREQRANGE(__PCLK__) ((__PCLK__)/1000000U)
|
||||||
|
#define I2C_RISE_TIME(__FREQRANGE__, __SPEED__) (((__SPEED__) <= 100000U) ? ((__FREQRANGE__) + 1U) : ((((__FREQRANGE__) * 300U) / 1000U) + 1U))
|
||||||
|
#define I2C_SPEED_STANDARD(__PCLK__, __SPEED__) ((I2C_CCR_CALCULATION((__PCLK__), (__SPEED__), 2U) < 4U)? 4U:I2C_CCR_CALCULATION((__PCLK__), (__SPEED__), 2U))
|
||||||
|
#define I2C_SPEED_FAST(__PCLK__, __SPEED__, __DUTYCYCLE__) (((__DUTYCYCLE__) == I2C_DUTYCYCLE_2)? I2C_CCR_CALCULATION((__PCLK__), (__SPEED__), 3U) : (I2C_CCR_CALCULATION((__PCLK__), (__SPEED__), 25U) | I2C_DUTYCYCLE_16_9))
|
||||||
|
#define I2C_SPEED(__PCLK__, __SPEED__, __DUTYCYCLE__) (((__SPEED__) <= 100000U)? (I2C_SPEED_STANDARD((__PCLK__), (__SPEED__))) : \
|
||||||
|
((I2C_SPEED_FAST((__PCLK__), (__SPEED__), (__DUTYCYCLE__)) & I2C_CCR_CCR) == 0U)? 1U : \
|
||||||
|
((I2C_SPEED_FAST((__PCLK__), (__SPEED__), (__DUTYCYCLE__))) | I2C_CCR_FS))
|
||||||
|
|
||||||
|
#define I2C_7BIT_ADD_WRITE(__ADDRESS__) ((uint8_t)((__ADDRESS__) & (uint8_t)(~I2C_OAR1_ADD0)))
|
||||||
|
#define I2C_7BIT_ADD_READ(__ADDRESS__) ((uint8_t)((__ADDRESS__) | I2C_OAR1_ADD0))
|
||||||
|
|
||||||
|
#define I2C_10BIT_ADDRESS(__ADDRESS__) ((uint8_t)((uint16_t)((__ADDRESS__) & (uint16_t)0x00FF)))
|
||||||
|
#define I2C_10BIT_HEADER_WRITE(__ADDRESS__) ((uint8_t)((uint16_t)((uint16_t)(((uint16_t)((__ADDRESS__) & (uint16_t)0x0300)) >> 7) | (uint16_t)0x00F0)))
|
||||||
|
#define I2C_10BIT_HEADER_READ(__ADDRESS__) ((uint8_t)((uint16_t)((uint16_t)(((uint16_t)((__ADDRESS__) & (uint16_t)0x0300)) >> 7) | (uint16_t)(0x00F1))))
|
||||||
|
|
||||||
|
#define I2C_MEM_ADD_MSB(__ADDRESS__) ((uint8_t)((uint16_t)(((uint16_t)((__ADDRESS__) & (uint16_t)0xFF00)) >> 8)))
|
||||||
|
#define I2C_MEM_ADD_LSB(__ADDRESS__) ((uint8_t)((uint16_t)((__ADDRESS__) & (uint16_t)0x00FF)))
|
||||||
|
|
||||||
|
/** @defgroup I2C_IS_RTC_Definitions I2C Private macros to check input parameters
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define IS_I2C_DUTY_CYCLE(CYCLE) (((CYCLE) == I2C_DUTYCYCLE_2) || \
|
||||||
|
((CYCLE) == I2C_DUTYCYCLE_16_9))
|
||||||
|
#define IS_I2C_ADDRESSING_MODE(ADDRESS) (((ADDRESS) == I2C_ADDRESSINGMODE_7BIT) || \
|
||||||
|
((ADDRESS) == I2C_ADDRESSINGMODE_10BIT))
|
||||||
|
#define IS_I2C_DUAL_ADDRESS(ADDRESS) (((ADDRESS) == I2C_DUALADDRESS_DISABLE) || \
|
||||||
|
((ADDRESS) == I2C_DUALADDRESS_ENABLE))
|
||||||
|
#define IS_I2C_GENERAL_CALL(CALL) (((CALL) == I2C_GENERALCALL_DISABLE) || \
|
||||||
|
((CALL) == I2C_GENERALCALL_ENABLE))
|
||||||
|
#define IS_I2C_NO_STRETCH(STRETCH) (((STRETCH) == I2C_NOSTRETCH_DISABLE) || \
|
||||||
|
((STRETCH) == I2C_NOSTRETCH_ENABLE))
|
||||||
|
#define IS_I2C_MEMADD_SIZE(SIZE) (((SIZE) == I2C_MEMADD_SIZE_8BIT) || \
|
||||||
|
((SIZE) == I2C_MEMADD_SIZE_16BIT))
|
||||||
|
#define IS_I2C_CLOCK_SPEED(SPEED) (((SPEED) > 0U) && ((SPEED) <= 400000U))
|
||||||
|
#define IS_I2C_OWN_ADDRESS1(ADDRESS1) (((ADDRESS1) & 0xFFFFFC00U) == 0U)
|
||||||
|
#define IS_I2C_OWN_ADDRESS2(ADDRESS2) (((ADDRESS2) & 0xFFFFFF01U) == 0U)
|
||||||
|
#define IS_I2C_TRANSFER_OPTIONS_REQUEST(REQUEST) (((REQUEST) == I2C_FIRST_FRAME) || \
|
||||||
|
((REQUEST) == I2C_FIRST_AND_NEXT_FRAME) || \
|
||||||
|
((REQUEST) == I2C_NEXT_FRAME) || \
|
||||||
|
((REQUEST) == I2C_FIRST_AND_LAST_FRAME) || \
|
||||||
|
((REQUEST) == I2C_LAST_FRAME) || \
|
||||||
|
((REQUEST) == I2C_LAST_FRAME_NO_STOP) || \
|
||||||
|
IS_I2C_TRANSFER_OTHER_OPTIONS_REQUEST(REQUEST))
|
||||||
|
|
||||||
|
#define IS_I2C_TRANSFER_OTHER_OPTIONS_REQUEST(REQUEST) (((REQUEST) == I2C_OTHER_FRAME) || \
|
||||||
|
((REQUEST) == I2C_OTHER_AND_LAST_FRAME))
|
||||||
|
|
||||||
|
#define I2C_CHECK_FLAG(__ISR__, __FLAG__) ((((__ISR__) & ((__FLAG__) & I2C_FLAG_MASK)) == ((__FLAG__) & I2C_FLAG_MASK)) ? SET : RESET)
|
||||||
|
#define I2C_CHECK_IT_SOURCE(__CR1__, __IT__) ((((__CR1__) & (__IT__)) == (__IT__)) ? SET : RESET)
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Private functions ---------------------------------------------------------*/
|
||||||
|
/** @defgroup I2C_Private_Functions I2C Private Functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* __STM32F4xx_HAL_I2C_H */
|
||||||
|
|
||||||
@@ -0,0 +1,115 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file stm32f4xx_hal_i2c_ex.h
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief Header file of I2C HAL Extension module.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2016 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __STM32F4xx_HAL_I2C_EX_H
|
||||||
|
#define __STM32F4xx_HAL_I2C_EX_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(I2C_FLTR_ANOFF)&&defined(I2C_FLTR_DNF)
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "stm32f4xx_hal_def.h"
|
||||||
|
|
||||||
|
/** @addtogroup STM32F4xx_HAL_Driver
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup I2CEx
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Exported types ------------------------------------------------------------*/
|
||||||
|
/* Exported constants --------------------------------------------------------*/
|
||||||
|
/** @defgroup I2CEx_Exported_Constants I2C Exported Constants
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup I2CEx_Analog_Filter I2C Analog Filter
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define I2C_ANALOGFILTER_ENABLE 0x00000000U
|
||||||
|
#define I2C_ANALOGFILTER_DISABLE I2C_FLTR_ANOFF
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Exported macro ------------------------------------------------------------*/
|
||||||
|
/* Exported functions --------------------------------------------------------*/
|
||||||
|
/** @addtogroup I2CEx_Exported_Functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup I2CEx_Exported_Functions_Group1
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/* Peripheral Control functions ************************************************/
|
||||||
|
HAL_StatusTypeDef HAL_I2CEx_ConfigAnalogFilter(I2C_HandleTypeDef *hi2c, uint32_t AnalogFilter);
|
||||||
|
HAL_StatusTypeDef HAL_I2CEx_ConfigDigitalFilter(I2C_HandleTypeDef *hi2c, uint32_t DigitalFilter);
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
/* Private types -------------------------------------------------------------*/
|
||||||
|
/* Private variables ---------------------------------------------------------*/
|
||||||
|
/* Private constants ---------------------------------------------------------*/
|
||||||
|
/** @defgroup I2CEx_Private_Constants I2C Private Constants
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Private macros ------------------------------------------------------------*/
|
||||||
|
/** @defgroup I2CEx_Private_Macros I2C Private Macros
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define IS_I2C_ANALOG_FILTER(FILTER) (((FILTER) == I2C_ANALOGFILTER_ENABLE) || \
|
||||||
|
((FILTER) == I2C_ANALOGFILTER_DISABLE))
|
||||||
|
#define IS_I2C_DIGITAL_FILTER(FILTER) ((FILTER) <= 0x0000000FU)
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __STM32F4xx_HAL_I2C_EX_H */
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,618 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file stm32f4xx_hal_i2s.h
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief Header file of I2S HAL module.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2016 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef STM32F4xx_HAL_I2S_H
|
||||||
|
#define STM32F4xx_HAL_I2S_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "stm32f4xx_hal_def.h"
|
||||||
|
|
||||||
|
/** @addtogroup STM32F4xx_HAL_Driver
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup I2S
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Exported types ------------------------------------------------------------*/
|
||||||
|
/** @defgroup I2S_Exported_Types I2S Exported Types
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief I2S Init structure definition
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32_t Mode; /*!< Specifies the I2S operating mode.
|
||||||
|
This parameter can be a value of @ref I2S_Mode */
|
||||||
|
|
||||||
|
uint32_t Standard; /*!< Specifies the standard used for the I2S communication.
|
||||||
|
This parameter can be a value of @ref I2S_Standard */
|
||||||
|
|
||||||
|
uint32_t DataFormat; /*!< Specifies the data format for the I2S communication.
|
||||||
|
This parameter can be a value of @ref I2S_Data_Format */
|
||||||
|
|
||||||
|
uint32_t MCLKOutput; /*!< Specifies whether the I2S MCLK output is enabled or not.
|
||||||
|
This parameter can be a value of @ref I2S_MCLK_Output */
|
||||||
|
|
||||||
|
uint32_t AudioFreq; /*!< Specifies the frequency selected for the I2S communication.
|
||||||
|
This parameter can be a value of @ref I2S_Audio_Frequency */
|
||||||
|
|
||||||
|
uint32_t CPOL; /*!< Specifies the idle state of the I2S clock.
|
||||||
|
This parameter can be a value of @ref I2S_Clock_Polarity */
|
||||||
|
|
||||||
|
uint32_t ClockSource; /*!< Specifies the I2S Clock Source.
|
||||||
|
This parameter can be a value of @ref I2S_Clock_Source */
|
||||||
|
uint32_t FullDuplexMode; /*!< Specifies the I2S FullDuplex mode.
|
||||||
|
This parameter can be a value of @ref I2S_FullDuplex_Mode */
|
||||||
|
} I2S_InitTypeDef;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief HAL State structures definition
|
||||||
|
*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
HAL_I2S_STATE_RESET = 0x00U, /*!< I2S not yet initialized or disabled */
|
||||||
|
HAL_I2S_STATE_READY = 0x01U, /*!< I2S initialized and ready for use */
|
||||||
|
HAL_I2S_STATE_BUSY = 0x02U, /*!< I2S internal process is ongoing */
|
||||||
|
HAL_I2S_STATE_BUSY_TX = 0x03U, /*!< Data Transmission process is ongoing */
|
||||||
|
HAL_I2S_STATE_BUSY_RX = 0x04U, /*!< Data Reception process is ongoing */
|
||||||
|
HAL_I2S_STATE_BUSY_TX_RX = 0x05U, /*!< Data Transmission and Reception process is ongoing */
|
||||||
|
HAL_I2S_STATE_TIMEOUT = 0x06U, /*!< I2S timeout state */
|
||||||
|
HAL_I2S_STATE_ERROR = 0x07U /*!< I2S error state */
|
||||||
|
} HAL_I2S_StateTypeDef;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief I2S handle Structure definition
|
||||||
|
*/
|
||||||
|
typedef struct __I2S_HandleTypeDef
|
||||||
|
{
|
||||||
|
SPI_TypeDef *Instance; /*!< I2S registers base address */
|
||||||
|
|
||||||
|
I2S_InitTypeDef Init; /*!< I2S communication parameters */
|
||||||
|
|
||||||
|
uint16_t *pTxBuffPtr; /*!< Pointer to I2S Tx transfer buffer */
|
||||||
|
|
||||||
|
__IO uint16_t TxXferSize; /*!< I2S Tx transfer size */
|
||||||
|
|
||||||
|
__IO uint16_t TxXferCount; /*!< I2S Tx transfer Counter */
|
||||||
|
|
||||||
|
uint16_t *pRxBuffPtr; /*!< Pointer to I2S Rx transfer buffer */
|
||||||
|
|
||||||
|
__IO uint16_t RxXferSize; /*!< I2S Rx transfer size */
|
||||||
|
|
||||||
|
__IO uint16_t RxXferCount; /*!< I2S Rx transfer counter
|
||||||
|
(This field is initialized at the
|
||||||
|
same value as transfer size at the
|
||||||
|
beginning of the transfer and
|
||||||
|
decremented when a sample is received
|
||||||
|
NbSamplesReceived = RxBufferSize-RxBufferCount) */
|
||||||
|
void (*IrqHandlerISR)(struct __I2S_HandleTypeDef *hi2s); /*!< I2S function pointer on IrqHandler */
|
||||||
|
|
||||||
|
DMA_HandleTypeDef *hdmatx; /*!< I2S Tx DMA handle parameters */
|
||||||
|
|
||||||
|
DMA_HandleTypeDef *hdmarx; /*!< I2S Rx DMA handle parameters */
|
||||||
|
|
||||||
|
__IO HAL_LockTypeDef Lock; /*!< I2S locking object */
|
||||||
|
|
||||||
|
__IO HAL_I2S_StateTypeDef State; /*!< I2S communication state */
|
||||||
|
|
||||||
|
__IO uint32_t ErrorCode; /*!< I2S Error code
|
||||||
|
This parameter can be a value of @ref I2S_Error */
|
||||||
|
|
||||||
|
#if (USE_HAL_I2S_REGISTER_CALLBACKS == 1U)
|
||||||
|
void (* TxCpltCallback)(struct __I2S_HandleTypeDef *hi2s); /*!< I2S Tx Completed callback */
|
||||||
|
void (* RxCpltCallback)(struct __I2S_HandleTypeDef *hi2s); /*!< I2S Rx Completed callback */
|
||||||
|
void (* TxRxCpltCallback)(struct __I2S_HandleTypeDef *hi2s); /*!< I2S TxRx Completed callback */
|
||||||
|
void (* TxHalfCpltCallback)(struct __I2S_HandleTypeDef *hi2s); /*!< I2S Tx Half Completed callback */
|
||||||
|
void (* RxHalfCpltCallback)(struct __I2S_HandleTypeDef *hi2s); /*!< I2S Rx Half Completed callback */
|
||||||
|
void (* TxRxHalfCpltCallback)(struct __I2S_HandleTypeDef *hi2s); /*!< I2S TxRx Half Completed callback */
|
||||||
|
void (* ErrorCallback)(struct __I2S_HandleTypeDef *hi2s); /*!< I2S Error callback */
|
||||||
|
void (* MspInitCallback)(struct __I2S_HandleTypeDef *hi2s); /*!< I2S Msp Init callback */
|
||||||
|
void (* MspDeInitCallback)(struct __I2S_HandleTypeDef *hi2s); /*!< I2S Msp DeInit callback */
|
||||||
|
|
||||||
|
#endif /* USE_HAL_I2S_REGISTER_CALLBACKS */
|
||||||
|
} I2S_HandleTypeDef;
|
||||||
|
|
||||||
|
#if (USE_HAL_I2S_REGISTER_CALLBACKS == 1U)
|
||||||
|
/**
|
||||||
|
* @brief HAL I2S Callback ID enumeration definition
|
||||||
|
*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
HAL_I2S_TX_COMPLETE_CB_ID = 0x00U, /*!< I2S Tx Completed callback ID */
|
||||||
|
HAL_I2S_RX_COMPLETE_CB_ID = 0x01U, /*!< I2S Rx Completed callback ID */
|
||||||
|
HAL_I2S_TX_RX_COMPLETE_CB_ID = 0x02U, /*!< I2S TxRx Completed callback ID */
|
||||||
|
HAL_I2S_TX_HALF_COMPLETE_CB_ID = 0x03U, /*!< I2S Tx Half Completed callback ID */
|
||||||
|
HAL_I2S_RX_HALF_COMPLETE_CB_ID = 0x04U, /*!< I2S Rx Half Completed callback ID */
|
||||||
|
HAL_I2S_TX_RX_HALF_COMPLETE_CB_ID = 0x05U, /*!< I2S TxRx Half Completed callback ID */
|
||||||
|
HAL_I2S_ERROR_CB_ID = 0x06U, /*!< I2S Error callback ID */
|
||||||
|
HAL_I2S_MSPINIT_CB_ID = 0x07U, /*!< I2S Msp Init callback ID */
|
||||||
|
HAL_I2S_MSPDEINIT_CB_ID = 0x08U /*!< I2S Msp DeInit callback ID */
|
||||||
|
|
||||||
|
} HAL_I2S_CallbackIDTypeDef;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief HAL I2S Callback pointer definition
|
||||||
|
*/
|
||||||
|
typedef void (*pI2S_CallbackTypeDef)(I2S_HandleTypeDef *hi2s); /*!< pointer to an I2S callback function */
|
||||||
|
|
||||||
|
#endif /* USE_HAL_I2S_REGISTER_CALLBACKS */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Exported constants --------------------------------------------------------*/
|
||||||
|
/** @defgroup I2S_Exported_Constants I2S Exported Constants
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/** @defgroup I2S_Error I2S Error
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define HAL_I2S_ERROR_NONE (0x00000000U) /*!< No error */
|
||||||
|
#define HAL_I2S_ERROR_TIMEOUT (0x00000001U) /*!< Timeout error */
|
||||||
|
#define HAL_I2S_ERROR_OVR (0x00000002U) /*!< OVR error */
|
||||||
|
#define HAL_I2S_ERROR_UDR (0x00000004U) /*!< UDR error */
|
||||||
|
#define HAL_I2S_ERROR_DMA (0x00000008U) /*!< DMA transfer error */
|
||||||
|
#define HAL_I2S_ERROR_PRESCALER (0x00000010U) /*!< Prescaler Calculation error */
|
||||||
|
#if (USE_HAL_I2S_REGISTER_CALLBACKS == 1U)
|
||||||
|
#define HAL_I2S_ERROR_INVALID_CALLBACK (0x00000020U) /*!< Invalid Callback error */
|
||||||
|
#endif /* USE_HAL_I2S_REGISTER_CALLBACKS */
|
||||||
|
#define HAL_I2S_ERROR_BUSY_LINE_RX (0x00000040U) /*!< Busy Rx Line error */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup I2S_Mode I2S Mode
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define I2S_MODE_SLAVE_TX (0x00000000U)
|
||||||
|
#define I2S_MODE_SLAVE_RX (SPI_I2SCFGR_I2SCFG_0)
|
||||||
|
#define I2S_MODE_MASTER_TX (SPI_I2SCFGR_I2SCFG_1)
|
||||||
|
#define I2S_MODE_MASTER_RX ((SPI_I2SCFGR_I2SCFG_0 | SPI_I2SCFGR_I2SCFG_1))
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup I2S_Standard I2S Standard
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define I2S_STANDARD_PHILIPS (0x00000000U)
|
||||||
|
#define I2S_STANDARD_MSB (SPI_I2SCFGR_I2SSTD_0)
|
||||||
|
#define I2S_STANDARD_LSB (SPI_I2SCFGR_I2SSTD_1)
|
||||||
|
#define I2S_STANDARD_PCM_SHORT ((SPI_I2SCFGR_I2SSTD_0 | SPI_I2SCFGR_I2SSTD_1))
|
||||||
|
#define I2S_STANDARD_PCM_LONG ((SPI_I2SCFGR_I2SSTD_0 | SPI_I2SCFGR_I2SSTD_1 | SPI_I2SCFGR_PCMSYNC))
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup I2S_Data_Format I2S Data Format
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define I2S_DATAFORMAT_16B (0x00000000U)
|
||||||
|
#define I2S_DATAFORMAT_16B_EXTENDED (SPI_I2SCFGR_CHLEN)
|
||||||
|
#define I2S_DATAFORMAT_24B ((SPI_I2SCFGR_CHLEN | SPI_I2SCFGR_DATLEN_0))
|
||||||
|
#define I2S_DATAFORMAT_32B ((SPI_I2SCFGR_CHLEN | SPI_I2SCFGR_DATLEN_1))
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup I2S_MCLK_Output I2S MCLK Output
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define I2S_MCLKOUTPUT_ENABLE (SPI_I2SPR_MCKOE)
|
||||||
|
#define I2S_MCLKOUTPUT_DISABLE (0x00000000U)
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup I2S_Audio_Frequency I2S Audio Frequency
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define I2S_AUDIOFREQ_192K (192000U)
|
||||||
|
#define I2S_AUDIOFREQ_96K (96000U)
|
||||||
|
#define I2S_AUDIOFREQ_48K (48000U)
|
||||||
|
#define I2S_AUDIOFREQ_44K (44100U)
|
||||||
|
#define I2S_AUDIOFREQ_32K (32000U)
|
||||||
|
#define I2S_AUDIOFREQ_22K (22050U)
|
||||||
|
#define I2S_AUDIOFREQ_16K (16000U)
|
||||||
|
#define I2S_AUDIOFREQ_11K (11025U)
|
||||||
|
#define I2S_AUDIOFREQ_8K (8000U)
|
||||||
|
#define I2S_AUDIOFREQ_DEFAULT (2U)
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup I2S_FullDuplex_Mode I2S FullDuplex Mode
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define I2S_FULLDUPLEXMODE_DISABLE (0x00000000U)
|
||||||
|
#define I2S_FULLDUPLEXMODE_ENABLE (0x00000001U)
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup I2S_Clock_Polarity I2S Clock Polarity
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define I2S_CPOL_LOW (0x00000000U)
|
||||||
|
#define I2S_CPOL_HIGH (SPI_I2SCFGR_CKPOL)
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup I2S_Interrupts_Definition I2S Interrupts Definition
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define I2S_IT_TXE SPI_CR2_TXEIE
|
||||||
|
#define I2S_IT_RXNE SPI_CR2_RXNEIE
|
||||||
|
#define I2S_IT_ERR SPI_CR2_ERRIE
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup I2S_Flags_Definition I2S Flags Definition
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define I2S_FLAG_TXE SPI_SR_TXE
|
||||||
|
#define I2S_FLAG_RXNE SPI_SR_RXNE
|
||||||
|
|
||||||
|
#define I2S_FLAG_UDR SPI_SR_UDR
|
||||||
|
#define I2S_FLAG_OVR SPI_SR_OVR
|
||||||
|
#define I2S_FLAG_FRE SPI_SR_FRE
|
||||||
|
|
||||||
|
#define I2S_FLAG_CHSIDE SPI_SR_CHSIDE
|
||||||
|
#define I2S_FLAG_BSY SPI_SR_BSY
|
||||||
|
|
||||||
|
#define I2S_FLAG_MASK (SPI_SR_RXNE\
|
||||||
|
| SPI_SR_TXE | SPI_SR_UDR | SPI_SR_OVR | SPI_SR_FRE | SPI_SR_CHSIDE | SPI_SR_BSY)
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup I2S_Clock_Source I2S Clock Source Definition
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F469xx) || defined(STM32F479xx)
|
||||||
|
#define I2S_CLOCK_PLL (0x00000000U)
|
||||||
|
#define I2S_CLOCK_EXTERNAL (0x00000001U)
|
||||||
|
#endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx ||
|
||||||
|
STM32F401xC || STM32F401xE || STM32F411xE || STM32F469xx || STM32F479xx */
|
||||||
|
|
||||||
|
#if defined(STM32F446xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
|
||||||
|
#define I2S_CLOCK_PLL (0x00000000U)
|
||||||
|
#define I2S_CLOCK_EXTERNAL (0x00000001U)
|
||||||
|
#define I2S_CLOCK_PLLR (0x00000002U)
|
||||||
|
#define I2S_CLOCK_PLLSRC (0x00000003U)
|
||||||
|
#endif /* STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
|
||||||
|
|
||||||
|
#if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
|
||||||
|
#define I2S_CLOCK_PLLSRC (0x00000000U)
|
||||||
|
#define I2S_CLOCK_EXTERNAL (0x00000001U)
|
||||||
|
#define I2S_CLOCK_PLLR (0x00000002U)
|
||||||
|
#endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Exported macros -----------------------------------------------------------*/
|
||||||
|
/** @defgroup I2S_Exported_macros I2S Exported Macros
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @brief Reset I2S handle state
|
||||||
|
* @param __HANDLE__ specifies the I2S Handle.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#if (USE_HAL_I2S_REGISTER_CALLBACKS == 1U)
|
||||||
|
#define __HAL_I2S_RESET_HANDLE_STATE(__HANDLE__) do{ \
|
||||||
|
(__HANDLE__)->State = HAL_I2S_STATE_RESET; \
|
||||||
|
(__HANDLE__)->MspInitCallback = NULL; \
|
||||||
|
(__HANDLE__)->MspDeInitCallback = NULL; \
|
||||||
|
} while(0)
|
||||||
|
#else
|
||||||
|
#define __HAL_I2S_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_I2S_STATE_RESET)
|
||||||
|
#endif /* USE_HAL_I2S_REGISTER_CALLBACKS */
|
||||||
|
|
||||||
|
/** @brief Enable the specified SPI peripheral (in I2S mode).
|
||||||
|
* @param __HANDLE__ specifies the I2S Handle.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define __HAL_I2S_ENABLE(__HANDLE__) (SET_BIT((__HANDLE__)->Instance->I2SCFGR, SPI_I2SCFGR_I2SE))
|
||||||
|
|
||||||
|
/** @brief Disable the specified SPI peripheral (in I2S mode).
|
||||||
|
* @param __HANDLE__ specifies the I2S Handle.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define __HAL_I2S_DISABLE(__HANDLE__) (CLEAR_BIT((__HANDLE__)->Instance->I2SCFGR, SPI_I2SCFGR_I2SE))
|
||||||
|
|
||||||
|
/** @brief Enable the specified I2S interrupts.
|
||||||
|
* @param __HANDLE__ specifies the I2S Handle.
|
||||||
|
* @param __INTERRUPT__ specifies the interrupt source to enable or disable.
|
||||||
|
* This parameter can be one of the following values:
|
||||||
|
* @arg I2S_IT_TXE: Tx buffer empty interrupt enable
|
||||||
|
* @arg I2S_IT_RXNE: RX buffer not empty interrupt enable
|
||||||
|
* @arg I2S_IT_ERR: Error interrupt enable
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define __HAL_I2S_ENABLE_IT(__HANDLE__, __INTERRUPT__) (SET_BIT((__HANDLE__)->Instance->CR2,(__INTERRUPT__)))
|
||||||
|
|
||||||
|
/** @brief Disable the specified I2S interrupts.
|
||||||
|
* @param __HANDLE__ specifies the I2S Handle.
|
||||||
|
* @param __INTERRUPT__ specifies the interrupt source to enable or disable.
|
||||||
|
* This parameter can be one of the following values:
|
||||||
|
* @arg I2S_IT_TXE: Tx buffer empty interrupt enable
|
||||||
|
* @arg I2S_IT_RXNE: RX buffer not empty interrupt enable
|
||||||
|
* @arg I2S_IT_ERR: Error interrupt enable
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define __HAL_I2S_DISABLE_IT(__HANDLE__, __INTERRUPT__) (CLEAR_BIT((__HANDLE__)->Instance->CR2,(__INTERRUPT__)))
|
||||||
|
|
||||||
|
/** @brief Checks if the specified I2S interrupt source is enabled or disabled.
|
||||||
|
* @param __HANDLE__ specifies the I2S Handle.
|
||||||
|
* This parameter can be I2S where x: 1, 2, or 3 to select the I2S peripheral.
|
||||||
|
* @param __INTERRUPT__ specifies the I2S interrupt source to check.
|
||||||
|
* This parameter can be one of the following values:
|
||||||
|
* @arg I2S_IT_TXE: Tx buffer empty interrupt enable
|
||||||
|
* @arg I2S_IT_RXNE: RX buffer not empty interrupt enable
|
||||||
|
* @arg I2S_IT_ERR: Error interrupt enable
|
||||||
|
* @retval The new state of __IT__ (TRUE or FALSE).
|
||||||
|
*/
|
||||||
|
#define __HAL_I2S_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CR2\
|
||||||
|
& (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
|
||||||
|
|
||||||
|
/** @brief Checks whether the specified I2S flag is set or not.
|
||||||
|
* @param __HANDLE__ specifies the I2S Handle.
|
||||||
|
* @param __FLAG__ specifies the flag to check.
|
||||||
|
* This parameter can be one of the following values:
|
||||||
|
* @arg I2S_FLAG_RXNE: Receive buffer not empty flag
|
||||||
|
* @arg I2S_FLAG_TXE: Transmit buffer empty flag
|
||||||
|
* @arg I2S_FLAG_UDR: Underrun flag
|
||||||
|
* @arg I2S_FLAG_OVR: Overrun flag
|
||||||
|
* @arg I2S_FLAG_FRE: Frame error flag
|
||||||
|
* @arg I2S_FLAG_CHSIDE: Channel Side flag
|
||||||
|
* @arg I2S_FLAG_BSY: Busy flag
|
||||||
|
* @retval The new state of __FLAG__ (TRUE or FALSE).
|
||||||
|
*/
|
||||||
|
#define __HAL_I2S_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__))
|
||||||
|
|
||||||
|
/** @brief Clears the I2S OVR pending flag.
|
||||||
|
* @param __HANDLE__ specifies the I2S Handle.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define __HAL_I2S_CLEAR_OVRFLAG(__HANDLE__) do{ \
|
||||||
|
__IO uint32_t tmpreg_ovr = 0x00U; \
|
||||||
|
tmpreg_ovr = (__HANDLE__)->Instance->DR; \
|
||||||
|
tmpreg_ovr = (__HANDLE__)->Instance->SR; \
|
||||||
|
UNUSED(tmpreg_ovr); \
|
||||||
|
}while(0U)
|
||||||
|
/** @brief Clears the I2S UDR pending flag.
|
||||||
|
* @param __HANDLE__ specifies the I2S Handle.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define __HAL_I2S_CLEAR_UDRFLAG(__HANDLE__) do{\
|
||||||
|
__IO uint32_t tmpreg_udr = 0x00U;\
|
||||||
|
tmpreg_udr = ((__HANDLE__)->Instance->SR);\
|
||||||
|
UNUSED(tmpreg_udr); \
|
||||||
|
}while(0U)
|
||||||
|
/** @brief Flush the I2S DR Register.
|
||||||
|
* @param __HANDLE__ specifies the I2S Handle.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define __HAL_I2S_FLUSH_RX_DR(__HANDLE__) do{\
|
||||||
|
__IO uint32_t tmpreg_dr = 0x00U;\
|
||||||
|
tmpreg_dr = ((__HANDLE__)->Instance->DR);\
|
||||||
|
UNUSED(tmpreg_dr); \
|
||||||
|
}while(0U)
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Include I2S Extension module */
|
||||||
|
#include "stm32f4xx_hal_i2s_ex.h"
|
||||||
|
|
||||||
|
/* Exported functions --------------------------------------------------------*/
|
||||||
|
/** @addtogroup I2S_Exported_Functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup I2S_Exported_Functions_Group1
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/* Initialization/de-initialization functions ********************************/
|
||||||
|
HAL_StatusTypeDef HAL_I2S_Init(I2S_HandleTypeDef *hi2s);
|
||||||
|
HAL_StatusTypeDef HAL_I2S_DeInit(I2S_HandleTypeDef *hi2s);
|
||||||
|
void HAL_I2S_MspInit(I2S_HandleTypeDef *hi2s);
|
||||||
|
void HAL_I2S_MspDeInit(I2S_HandleTypeDef *hi2s);
|
||||||
|
|
||||||
|
/* Callbacks Register/UnRegister functions ***********************************/
|
||||||
|
#if (USE_HAL_I2S_REGISTER_CALLBACKS == 1U)
|
||||||
|
HAL_StatusTypeDef HAL_I2S_RegisterCallback(I2S_HandleTypeDef *hi2s, HAL_I2S_CallbackIDTypeDef CallbackID,
|
||||||
|
pI2S_CallbackTypeDef pCallback);
|
||||||
|
HAL_StatusTypeDef HAL_I2S_UnRegisterCallback(I2S_HandleTypeDef *hi2s, HAL_I2S_CallbackIDTypeDef CallbackID);
|
||||||
|
#endif /* USE_HAL_I2S_REGISTER_CALLBACKS */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup I2S_Exported_Functions_Group2
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/* I/O operation functions ***************************************************/
|
||||||
|
/* Blocking mode: Polling */
|
||||||
|
HAL_StatusTypeDef HAL_I2S_Transmit(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size, uint32_t Timeout);
|
||||||
|
HAL_StatusTypeDef HAL_I2S_Receive(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size, uint32_t Timeout);
|
||||||
|
|
||||||
|
/* Non-Blocking mode: Interrupt */
|
||||||
|
HAL_StatusTypeDef HAL_I2S_Transmit_IT(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size);
|
||||||
|
HAL_StatusTypeDef HAL_I2S_Receive_IT(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size);
|
||||||
|
void HAL_I2S_IRQHandler(I2S_HandleTypeDef *hi2s);
|
||||||
|
|
||||||
|
/* Non-Blocking mode: DMA */
|
||||||
|
HAL_StatusTypeDef HAL_I2S_Transmit_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size);
|
||||||
|
HAL_StatusTypeDef HAL_I2S_Receive_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size);
|
||||||
|
|
||||||
|
HAL_StatusTypeDef HAL_I2S_DMAPause(I2S_HandleTypeDef *hi2s);
|
||||||
|
HAL_StatusTypeDef HAL_I2S_DMAResume(I2S_HandleTypeDef *hi2s);
|
||||||
|
HAL_StatusTypeDef HAL_I2S_DMAStop(I2S_HandleTypeDef *hi2s);
|
||||||
|
|
||||||
|
/* Callbacks used in non blocking modes (Interrupt and DMA) *******************/
|
||||||
|
void HAL_I2S_TxHalfCpltCallback(I2S_HandleTypeDef *hi2s);
|
||||||
|
void HAL_I2S_TxCpltCallback(I2S_HandleTypeDef *hi2s);
|
||||||
|
void HAL_I2S_RxHalfCpltCallback(I2S_HandleTypeDef *hi2s);
|
||||||
|
void HAL_I2S_RxCpltCallback(I2S_HandleTypeDef *hi2s);
|
||||||
|
void HAL_I2S_ErrorCallback(I2S_HandleTypeDef *hi2s);
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup I2S_Exported_Functions_Group3
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/* Peripheral Control and State functions ************************************/
|
||||||
|
HAL_I2S_StateTypeDef HAL_I2S_GetState(I2S_HandleTypeDef *hi2s);
|
||||||
|
uint32_t HAL_I2S_GetError(I2S_HandleTypeDef *hi2s);
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Private types -------------------------------------------------------------*/
|
||||||
|
/* Private variables ---------------------------------------------------------*/
|
||||||
|
/* Private constants ---------------------------------------------------------*/
|
||||||
|
/* Private macros ------------------------------------------------------------*/
|
||||||
|
/** @defgroup I2S_Private_Macros I2S Private Macros
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @brief Check whether the specified SPI flag is set or not.
|
||||||
|
* @param __SR__ copy of I2S SR register.
|
||||||
|
* @param __FLAG__ specifies the flag to check.
|
||||||
|
* This parameter can be one of the following values:
|
||||||
|
* @arg I2S_FLAG_RXNE: Receive buffer not empty flag
|
||||||
|
* @arg I2S_FLAG_TXE: Transmit buffer empty flag
|
||||||
|
* @arg I2S_FLAG_UDR: Underrun error flag
|
||||||
|
* @arg I2S_FLAG_OVR: Overrun flag
|
||||||
|
* @arg I2S_FLAG_CHSIDE: Channel side flag
|
||||||
|
* @arg I2S_FLAG_BSY: Busy flag
|
||||||
|
* @retval SET or RESET.
|
||||||
|
*/
|
||||||
|
#define I2S_CHECK_FLAG(__SR__, __FLAG__) ((((__SR__)\
|
||||||
|
& ((__FLAG__) & I2S_FLAG_MASK)) == ((__FLAG__) & I2S_FLAG_MASK)) ? SET : RESET)
|
||||||
|
|
||||||
|
/** @brief Check whether the specified SPI Interrupt is set or not.
|
||||||
|
* @param __CR2__ copy of I2S CR2 register.
|
||||||
|
* @param __INTERRUPT__ specifies the SPI interrupt source to check.
|
||||||
|
* This parameter can be one of the following values:
|
||||||
|
* @arg I2S_IT_TXE: Tx buffer empty interrupt enable
|
||||||
|
* @arg I2S_IT_RXNE: RX buffer not empty interrupt enable
|
||||||
|
* @arg I2S_IT_ERR: Error interrupt enable
|
||||||
|
* @retval SET or RESET.
|
||||||
|
*/
|
||||||
|
#define I2S_CHECK_IT_SOURCE(__CR2__, __INTERRUPT__) ((((__CR2__)\
|
||||||
|
& (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
|
||||||
|
|
||||||
|
/** @brief Checks if I2S Mode parameter is in allowed range.
|
||||||
|
* @param __MODE__ specifies the I2S Mode.
|
||||||
|
* This parameter can be a value of @ref I2S_Mode
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define IS_I2S_MODE(__MODE__) (((__MODE__) == I2S_MODE_SLAVE_TX) || \
|
||||||
|
((__MODE__) == I2S_MODE_SLAVE_RX) || \
|
||||||
|
((__MODE__) == I2S_MODE_MASTER_TX) || \
|
||||||
|
((__MODE__) == I2S_MODE_MASTER_RX))
|
||||||
|
|
||||||
|
#define IS_I2S_STANDARD(__STANDARD__) (((__STANDARD__) == I2S_STANDARD_PHILIPS) || \
|
||||||
|
((__STANDARD__) == I2S_STANDARD_MSB) || \
|
||||||
|
((__STANDARD__) == I2S_STANDARD_LSB) || \
|
||||||
|
((__STANDARD__) == I2S_STANDARD_PCM_SHORT) || \
|
||||||
|
((__STANDARD__) == I2S_STANDARD_PCM_LONG))
|
||||||
|
|
||||||
|
#define IS_I2S_DATA_FORMAT(__FORMAT__) (((__FORMAT__) == I2S_DATAFORMAT_16B) || \
|
||||||
|
((__FORMAT__) == I2S_DATAFORMAT_16B_EXTENDED) || \
|
||||||
|
((__FORMAT__) == I2S_DATAFORMAT_24B) || \
|
||||||
|
((__FORMAT__) == I2S_DATAFORMAT_32B))
|
||||||
|
|
||||||
|
#define IS_I2S_MCLK_OUTPUT(__OUTPUT__) (((__OUTPUT__) == I2S_MCLKOUTPUT_ENABLE) || \
|
||||||
|
((__OUTPUT__) == I2S_MCLKOUTPUT_DISABLE))
|
||||||
|
|
||||||
|
#define IS_I2S_AUDIO_FREQ(__FREQ__) ((((__FREQ__) >= I2S_AUDIOFREQ_8K) && \
|
||||||
|
((__FREQ__) <= I2S_AUDIOFREQ_192K)) || \
|
||||||
|
((__FREQ__) == I2S_AUDIOFREQ_DEFAULT))
|
||||||
|
|
||||||
|
#define IS_I2S_FULLDUPLEX_MODE(MODE) (((MODE) == I2S_FULLDUPLEXMODE_DISABLE) || \
|
||||||
|
((MODE) == I2S_FULLDUPLEXMODE_ENABLE))
|
||||||
|
|
||||||
|
/** @brief Checks if I2S Serial clock steady state parameter is in allowed range.
|
||||||
|
* @param __CPOL__ specifies the I2S serial clock steady state.
|
||||||
|
* This parameter can be a value of @ref I2S_Clock_Polarity
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define IS_I2S_CPOL(__CPOL__) (((__CPOL__) == I2S_CPOL_LOW) || \
|
||||||
|
((__CPOL__) == I2S_CPOL_HIGH))
|
||||||
|
|
||||||
|
#if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F469xx) || defined(STM32F479xx)
|
||||||
|
#define IS_I2S_CLOCKSOURCE(CLOCK) (((CLOCK) == I2S_CLOCK_EXTERNAL) ||\
|
||||||
|
((CLOCK) == I2S_CLOCK_PLL))
|
||||||
|
#endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx ||
|
||||||
|
STM32F401xC || STM32F401xE || STM32F411xE || STM32F469xx || STM32F479xx */
|
||||||
|
|
||||||
|
#if defined(STM32F446xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined (STM32F413xx) || defined(STM32F423xx)
|
||||||
|
#define IS_I2S_CLOCKSOURCE(CLOCK) (((CLOCK) == I2S_CLOCK_EXTERNAL) ||\
|
||||||
|
((CLOCK) == I2S_CLOCK_PLL) ||\
|
||||||
|
((CLOCK) == I2S_CLOCK_PLLSRC) ||\
|
||||||
|
((CLOCK) == I2S_CLOCK_PLLR))
|
||||||
|
#endif /* STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
|
||||||
|
|
||||||
|
#if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
|
||||||
|
#define IS_I2S_CLOCKSOURCE(CLOCK) (((CLOCK) == I2S_CLOCK_EXTERNAL) ||\
|
||||||
|
((CLOCK) == I2S_CLOCK_PLLSRC) ||\
|
||||||
|
((CLOCK) == I2S_CLOCK_PLLR))
|
||||||
|
#endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* STM32F4xx_HAL_I2S_H */
|
||||||
|
|
||||||
@@ -0,0 +1,183 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file stm32f4xx_hal_i2s_ex.h
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief Header file of I2S HAL module.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2016 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef STM32F4xx_HAL_I2S_EX_H
|
||||||
|
#define STM32F4xx_HAL_I2S_EX_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "stm32f4xx_hal_def.h"
|
||||||
|
|
||||||
|
/** @addtogroup STM32F4xx_HAL_Driver
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#if defined(SPI_I2S_FULLDUPLEX_SUPPORT)
|
||||||
|
/** @addtogroup I2SEx I2SEx
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Exported types ------------------------------------------------------------*/
|
||||||
|
/* Exported constants --------------------------------------------------------*/
|
||||||
|
/* Exported macros -----------------------------------------------------------*/
|
||||||
|
/** @defgroup I2SEx_Exported_Macros I2S Extended Exported Macros
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define I2SxEXT(__INSTANCE__) ((__INSTANCE__) == (SPI2)? (SPI_TypeDef *)(I2S2ext_BASE): (SPI_TypeDef *)(I2S3ext_BASE))
|
||||||
|
|
||||||
|
/** @brief Enable or disable the specified I2SExt peripheral.
|
||||||
|
* @param __HANDLE__ specifies the I2S Handle.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define __HAL_I2SEXT_ENABLE(__HANDLE__) (I2SxEXT((__HANDLE__)->Instance)->I2SCFGR |= SPI_I2SCFGR_I2SE)
|
||||||
|
#define __HAL_I2SEXT_DISABLE(__HANDLE__) (I2SxEXT((__HANDLE__)->Instance)->I2SCFGR &= ~SPI_I2SCFGR_I2SE)
|
||||||
|
|
||||||
|
/** @brief Enable or disable the specified I2SExt interrupts.
|
||||||
|
* @param __HANDLE__ specifies the I2S Handle.
|
||||||
|
* @param __INTERRUPT__ specifies the interrupt source to enable or disable.
|
||||||
|
* This parameter can be one of the following values:
|
||||||
|
* @arg I2S_IT_TXE: Tx buffer empty interrupt enable
|
||||||
|
* @arg I2S_IT_RXNE: RX buffer not empty interrupt enable
|
||||||
|
* @arg I2S_IT_ERR: Error interrupt enable
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define __HAL_I2SEXT_ENABLE_IT(__HANDLE__, __INTERRUPT__) (I2SxEXT((__HANDLE__)->Instance)->CR2 |= (__INTERRUPT__))
|
||||||
|
#define __HAL_I2SEXT_DISABLE_IT(__HANDLE__, __INTERRUPT__) (I2SxEXT((__HANDLE__)->Instance)->CR2 &= ~(__INTERRUPT__))
|
||||||
|
|
||||||
|
/** @brief Checks if the specified I2SExt interrupt source is enabled or disabled.
|
||||||
|
* @param __HANDLE__ specifies the I2S Handle.
|
||||||
|
* This parameter can be I2S where x: 1, 2, or 3 to select the I2S peripheral.
|
||||||
|
* @param __INTERRUPT__ specifies the I2S interrupt source to check.
|
||||||
|
* This parameter can be one of the following values:
|
||||||
|
* @arg I2S_IT_TXE: Tx buffer empty interrupt enable
|
||||||
|
* @arg I2S_IT_RXNE: RX buffer not empty interrupt enable
|
||||||
|
* @arg I2S_IT_ERR: Error interrupt enable
|
||||||
|
* @retval The new state of __IT__ (TRUE or FALSE).
|
||||||
|
*/
|
||||||
|
#define __HAL_I2SEXT_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((I2SxEXT((__HANDLE__)->Instance)->CR2\
|
||||||
|
& (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
|
||||||
|
|
||||||
|
/** @brief Checks whether the specified I2SExt flag is set or not.
|
||||||
|
* @param __HANDLE__ specifies the I2S Handle.
|
||||||
|
* @param __FLAG__ specifies the flag to check.
|
||||||
|
* This parameter can be one of the following values:
|
||||||
|
* @arg I2S_FLAG_RXNE: Receive buffer not empty flag
|
||||||
|
* @arg I2S_FLAG_TXE: Transmit buffer empty flag
|
||||||
|
* @arg I2S_FLAG_UDR: Underrun flag
|
||||||
|
* @arg I2S_FLAG_OVR: Overrun flag
|
||||||
|
* @arg I2S_FLAG_FRE: Frame error flag
|
||||||
|
* @arg I2S_FLAG_CHSIDE: Channel Side flag
|
||||||
|
* @arg I2S_FLAG_BSY: Busy flag
|
||||||
|
* @retval The new state of __FLAG__ (TRUE or FALSE).
|
||||||
|
*/
|
||||||
|
#define __HAL_I2SEXT_GET_FLAG(__HANDLE__, __FLAG__) (((I2SxEXT((__HANDLE__)->Instance)->SR) & (__FLAG__)) == (__FLAG__))
|
||||||
|
|
||||||
|
/** @brief Clears the I2SExt OVR pending flag.
|
||||||
|
* @param __HANDLE__ specifies the I2S Handle.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define __HAL_I2SEXT_CLEAR_OVRFLAG(__HANDLE__) do{ \
|
||||||
|
__IO uint32_t tmpreg_ovr = 0x00U; \
|
||||||
|
tmpreg_ovr = I2SxEXT((__HANDLE__)->Instance)->DR;\
|
||||||
|
tmpreg_ovr = I2SxEXT((__HANDLE__)->Instance)->SR;\
|
||||||
|
UNUSED(tmpreg_ovr); \
|
||||||
|
}while(0U)
|
||||||
|
/** @brief Clears the I2SExt UDR pending flag.
|
||||||
|
* @param __HANDLE__ specifies the I2S Handle.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define __HAL_I2SEXT_CLEAR_UDRFLAG(__HANDLE__) do{ \
|
||||||
|
__IO uint32_t tmpreg_udr = 0x00U; \
|
||||||
|
tmpreg_udr = I2SxEXT((__HANDLE__)->Instance)->SR;\
|
||||||
|
UNUSED(tmpreg_udr); \
|
||||||
|
}while(0U)
|
||||||
|
/** @brief Flush the I2S and I2SExt DR Registers.
|
||||||
|
* @param __HANDLE__ specifies the I2S Handle.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define __HAL_I2SEXT_FLUSH_RX_DR(__HANDLE__) do{ \
|
||||||
|
__IO uint32_t tmpreg_dr = 0x00U; \
|
||||||
|
tmpreg_dr = I2SxEXT((__HANDLE__)->Instance)->DR; \
|
||||||
|
tmpreg_dr = ((__HANDLE__)->Instance->DR); \
|
||||||
|
UNUSED(tmpreg_dr); \
|
||||||
|
}while(0U)
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Exported functions --------------------------------------------------------*/
|
||||||
|
/** @addtogroup I2SEx_Exported_Functions I2S Extended Exported Functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup I2SEx_Exported_Functions_Group1 I2S Extended IO operation functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Extended features functions *************************************************/
|
||||||
|
/* Blocking mode: Polling */
|
||||||
|
HAL_StatusTypeDef HAL_I2SEx_TransmitReceive(I2S_HandleTypeDef *hi2s, uint16_t *pTxData, uint16_t *pRxData,
|
||||||
|
uint16_t Size, uint32_t Timeout);
|
||||||
|
/* Non-Blocking mode: Interrupt */
|
||||||
|
HAL_StatusTypeDef HAL_I2SEx_TransmitReceive_IT(I2S_HandleTypeDef *hi2s, uint16_t *pTxData, uint16_t *pRxData,
|
||||||
|
uint16_t Size);
|
||||||
|
/* Non-Blocking mode: DMA */
|
||||||
|
HAL_StatusTypeDef HAL_I2SEx_TransmitReceive_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pTxData, uint16_t *pRxData,
|
||||||
|
uint16_t Size);
|
||||||
|
/* I2S IRQHandler and Callbacks used in non blocking modes (Interrupt and DMA) */
|
||||||
|
void HAL_I2SEx_FullDuplex_IRQHandler(I2S_HandleTypeDef *hi2s);
|
||||||
|
void HAL_I2SEx_TxRxHalfCpltCallback(I2S_HandleTypeDef *hi2s);
|
||||||
|
void HAL_I2SEx_TxRxCpltCallback(I2S_HandleTypeDef *hi2s);
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
/* Private types -------------------------------------------------------------*/
|
||||||
|
/* Private variables ---------------------------------------------------------*/
|
||||||
|
/* Private constants ---------------------------------------------------------*/
|
||||||
|
/* Private macros ------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Private functions ---------------------------------------------------------*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endif /* SPI_I2S_FULLDUPLEX_SUPPORT */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* STM32F4xx_HAL_I2S_EX_H */
|
||||||
|
|
||||||
@@ -0,0 +1,729 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file stm32f4xx_hal_spi.h
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief Header file of SPI HAL module.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2016 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef STM32F4xx_HAL_SPI_H
|
||||||
|
#define STM32F4xx_HAL_SPI_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "stm32f4xx_hal_def.h"
|
||||||
|
|
||||||
|
/** @addtogroup STM32F4xx_HAL_Driver
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup SPI
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Exported types ------------------------------------------------------------*/
|
||||||
|
/** @defgroup SPI_Exported_Types SPI Exported Types
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief SPI Configuration Structure definition
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32_t Mode; /*!< Specifies the SPI operating mode.
|
||||||
|
This parameter can be a value of @ref SPI_Mode */
|
||||||
|
|
||||||
|
uint32_t Direction; /*!< Specifies the SPI bidirectional mode state.
|
||||||
|
This parameter can be a value of @ref SPI_Direction */
|
||||||
|
|
||||||
|
uint32_t DataSize; /*!< Specifies the SPI data size.
|
||||||
|
This parameter can be a value of @ref SPI_Data_Size */
|
||||||
|
|
||||||
|
uint32_t CLKPolarity; /*!< Specifies the serial clock steady state.
|
||||||
|
This parameter can be a value of @ref SPI_Clock_Polarity */
|
||||||
|
|
||||||
|
uint32_t CLKPhase; /*!< Specifies the clock active edge for the bit capture.
|
||||||
|
This parameter can be a value of @ref SPI_Clock_Phase */
|
||||||
|
|
||||||
|
uint32_t NSS; /*!< Specifies whether the NSS signal is managed by
|
||||||
|
hardware (NSS pin) or by software using the SSI bit.
|
||||||
|
This parameter can be a value of @ref SPI_Slave_Select_management */
|
||||||
|
|
||||||
|
uint32_t BaudRatePrescaler; /*!< Specifies the Baud Rate prescaler value which will be
|
||||||
|
used to configure the transmit and receive SCK clock.
|
||||||
|
This parameter can be a value of @ref SPI_BaudRate_Prescaler
|
||||||
|
@note The communication clock is derived from the master
|
||||||
|
clock. The slave clock does not need to be set. */
|
||||||
|
|
||||||
|
uint32_t FirstBit; /*!< Specifies whether data transfers start from MSB or LSB bit.
|
||||||
|
This parameter can be a value of @ref SPI_MSB_LSB_transmission */
|
||||||
|
|
||||||
|
uint32_t TIMode; /*!< Specifies if the TI mode is enabled or not.
|
||||||
|
This parameter can be a value of @ref SPI_TI_mode */
|
||||||
|
|
||||||
|
uint32_t CRCCalculation; /*!< Specifies if the CRC calculation is enabled or not.
|
||||||
|
This parameter can be a value of @ref SPI_CRC_Calculation */
|
||||||
|
|
||||||
|
uint32_t CRCPolynomial; /*!< Specifies the polynomial used for the CRC calculation.
|
||||||
|
This parameter must be an odd number between Min_Data = 1 and Max_Data = 65535 */
|
||||||
|
} SPI_InitTypeDef;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief HAL SPI State structure definition
|
||||||
|
*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
HAL_SPI_STATE_RESET = 0x00U, /*!< Peripheral not Initialized */
|
||||||
|
HAL_SPI_STATE_READY = 0x01U, /*!< Peripheral Initialized and ready for use */
|
||||||
|
HAL_SPI_STATE_BUSY = 0x02U, /*!< an internal process is ongoing */
|
||||||
|
HAL_SPI_STATE_BUSY_TX = 0x03U, /*!< Data Transmission process is ongoing */
|
||||||
|
HAL_SPI_STATE_BUSY_RX = 0x04U, /*!< Data Reception process is ongoing */
|
||||||
|
HAL_SPI_STATE_BUSY_TX_RX = 0x05U, /*!< Data Transmission and Reception process is ongoing */
|
||||||
|
HAL_SPI_STATE_ERROR = 0x06U, /*!< SPI error state */
|
||||||
|
HAL_SPI_STATE_ABORT = 0x07U /*!< SPI abort is ongoing */
|
||||||
|
} HAL_SPI_StateTypeDef;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief SPI handle Structure definition
|
||||||
|
*/
|
||||||
|
typedef struct __SPI_HandleTypeDef
|
||||||
|
{
|
||||||
|
SPI_TypeDef *Instance; /*!< SPI registers base address */
|
||||||
|
|
||||||
|
SPI_InitTypeDef Init; /*!< SPI communication parameters */
|
||||||
|
|
||||||
|
const uint8_t *pTxBuffPtr; /*!< Pointer to SPI Tx transfer Buffer */
|
||||||
|
|
||||||
|
uint16_t TxXferSize; /*!< SPI Tx Transfer size */
|
||||||
|
|
||||||
|
__IO uint16_t TxXferCount; /*!< SPI Tx Transfer Counter */
|
||||||
|
|
||||||
|
uint8_t *pRxBuffPtr; /*!< Pointer to SPI Rx transfer Buffer */
|
||||||
|
|
||||||
|
uint16_t RxXferSize; /*!< SPI Rx Transfer size */
|
||||||
|
|
||||||
|
__IO uint16_t RxXferCount; /*!< SPI Rx Transfer Counter */
|
||||||
|
|
||||||
|
void (*RxISR)(struct __SPI_HandleTypeDef *hspi); /*!< function pointer on Rx ISR */
|
||||||
|
|
||||||
|
void (*TxISR)(struct __SPI_HandleTypeDef *hspi); /*!< function pointer on Tx ISR */
|
||||||
|
|
||||||
|
DMA_HandleTypeDef *hdmatx; /*!< SPI Tx DMA Handle parameters */
|
||||||
|
|
||||||
|
DMA_HandleTypeDef *hdmarx; /*!< SPI Rx DMA Handle parameters */
|
||||||
|
|
||||||
|
HAL_LockTypeDef Lock; /*!< Locking object */
|
||||||
|
|
||||||
|
__IO HAL_SPI_StateTypeDef State; /*!< SPI communication state */
|
||||||
|
|
||||||
|
__IO uint32_t ErrorCode; /*!< SPI Error code */
|
||||||
|
|
||||||
|
#if (USE_HAL_SPI_REGISTER_CALLBACKS == 1U)
|
||||||
|
void (* TxCpltCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Tx Completed callback */
|
||||||
|
void (* RxCpltCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Rx Completed callback */
|
||||||
|
void (* TxRxCpltCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI TxRx Completed callback */
|
||||||
|
void (* TxHalfCpltCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Tx Half Completed callback */
|
||||||
|
void (* RxHalfCpltCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Rx Half Completed callback */
|
||||||
|
void (* TxRxHalfCpltCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI TxRx Half Completed callback */
|
||||||
|
void (* ErrorCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Error callback */
|
||||||
|
void (* AbortCpltCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Abort callback */
|
||||||
|
void (* MspInitCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Msp Init callback */
|
||||||
|
void (* MspDeInitCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Msp DeInit callback */
|
||||||
|
|
||||||
|
#endif /* USE_HAL_SPI_REGISTER_CALLBACKS */
|
||||||
|
} SPI_HandleTypeDef;
|
||||||
|
|
||||||
|
#if (USE_HAL_SPI_REGISTER_CALLBACKS == 1U)
|
||||||
|
/**
|
||||||
|
* @brief HAL SPI Callback ID enumeration definition
|
||||||
|
*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
HAL_SPI_TX_COMPLETE_CB_ID = 0x00U, /*!< SPI Tx Completed callback ID */
|
||||||
|
HAL_SPI_RX_COMPLETE_CB_ID = 0x01U, /*!< SPI Rx Completed callback ID */
|
||||||
|
HAL_SPI_TX_RX_COMPLETE_CB_ID = 0x02U, /*!< SPI TxRx Completed callback ID */
|
||||||
|
HAL_SPI_TX_HALF_COMPLETE_CB_ID = 0x03U, /*!< SPI Tx Half Completed callback ID */
|
||||||
|
HAL_SPI_RX_HALF_COMPLETE_CB_ID = 0x04U, /*!< SPI Rx Half Completed callback ID */
|
||||||
|
HAL_SPI_TX_RX_HALF_COMPLETE_CB_ID = 0x05U, /*!< SPI TxRx Half Completed callback ID */
|
||||||
|
HAL_SPI_ERROR_CB_ID = 0x06U, /*!< SPI Error callback ID */
|
||||||
|
HAL_SPI_ABORT_CB_ID = 0x07U, /*!< SPI Abort callback ID */
|
||||||
|
HAL_SPI_MSPINIT_CB_ID = 0x08U, /*!< SPI Msp Init callback ID */
|
||||||
|
HAL_SPI_MSPDEINIT_CB_ID = 0x09U /*!< SPI Msp DeInit callback ID */
|
||||||
|
|
||||||
|
} HAL_SPI_CallbackIDTypeDef;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief HAL SPI Callback pointer definition
|
||||||
|
*/
|
||||||
|
typedef void (*pSPI_CallbackTypeDef)(SPI_HandleTypeDef *hspi); /*!< pointer to an SPI callback function */
|
||||||
|
|
||||||
|
#endif /* USE_HAL_SPI_REGISTER_CALLBACKS */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Exported constants --------------------------------------------------------*/
|
||||||
|
/** @defgroup SPI_Exported_Constants SPI Exported Constants
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup SPI_Error_Code SPI Error Code
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define HAL_SPI_ERROR_NONE (0x00000000U) /*!< No error */
|
||||||
|
#define HAL_SPI_ERROR_MODF (0x00000001U) /*!< MODF error */
|
||||||
|
#define HAL_SPI_ERROR_CRC (0x00000002U) /*!< CRC error */
|
||||||
|
#define HAL_SPI_ERROR_OVR (0x00000004U) /*!< OVR error */
|
||||||
|
#define HAL_SPI_ERROR_FRE (0x00000008U) /*!< FRE error */
|
||||||
|
#define HAL_SPI_ERROR_DMA (0x00000010U) /*!< DMA transfer error */
|
||||||
|
#define HAL_SPI_ERROR_FLAG (0x00000020U) /*!< Error on RXNE/TXE/BSY Flag */
|
||||||
|
#define HAL_SPI_ERROR_ABORT (0x00000040U) /*!< Error during SPI Abort procedure */
|
||||||
|
#if (USE_HAL_SPI_REGISTER_CALLBACKS == 1U)
|
||||||
|
#define HAL_SPI_ERROR_INVALID_CALLBACK (0x00000080U) /*!< Invalid Callback error */
|
||||||
|
#endif /* USE_HAL_SPI_REGISTER_CALLBACKS */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup SPI_Mode SPI Mode
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define SPI_MODE_SLAVE (0x00000000U)
|
||||||
|
#define SPI_MODE_MASTER (SPI_CR1_MSTR | SPI_CR1_SSI)
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup SPI_Direction SPI Direction Mode
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define SPI_DIRECTION_2LINES (0x00000000U)
|
||||||
|
#define SPI_DIRECTION_2LINES_RXONLY SPI_CR1_RXONLY
|
||||||
|
#define SPI_DIRECTION_1LINE SPI_CR1_BIDIMODE
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup SPI_Data_Size SPI Data Size
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define SPI_DATASIZE_8BIT (0x00000000U)
|
||||||
|
#define SPI_DATASIZE_16BIT SPI_CR1_DFF
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup SPI_Clock_Polarity SPI Clock Polarity
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define SPI_POLARITY_LOW (0x00000000U)
|
||||||
|
#define SPI_POLARITY_HIGH SPI_CR1_CPOL
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup SPI_Clock_Phase SPI Clock Phase
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define SPI_PHASE_1EDGE (0x00000000U)
|
||||||
|
#define SPI_PHASE_2EDGE SPI_CR1_CPHA
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup SPI_Slave_Select_management SPI Slave Select Management
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define SPI_NSS_SOFT SPI_CR1_SSM
|
||||||
|
#define SPI_NSS_HARD_INPUT (0x00000000U)
|
||||||
|
#define SPI_NSS_HARD_OUTPUT (SPI_CR2_SSOE << 16U)
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup SPI_BaudRate_Prescaler SPI BaudRate Prescaler
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define SPI_BAUDRATEPRESCALER_2 (0x00000000U)
|
||||||
|
#define SPI_BAUDRATEPRESCALER_4 (SPI_CR1_BR_0)
|
||||||
|
#define SPI_BAUDRATEPRESCALER_8 (SPI_CR1_BR_1)
|
||||||
|
#define SPI_BAUDRATEPRESCALER_16 (SPI_CR1_BR_1 | SPI_CR1_BR_0)
|
||||||
|
#define SPI_BAUDRATEPRESCALER_32 (SPI_CR1_BR_2)
|
||||||
|
#define SPI_BAUDRATEPRESCALER_64 (SPI_CR1_BR_2 | SPI_CR1_BR_0)
|
||||||
|
#define SPI_BAUDRATEPRESCALER_128 (SPI_CR1_BR_2 | SPI_CR1_BR_1)
|
||||||
|
#define SPI_BAUDRATEPRESCALER_256 (SPI_CR1_BR_2 | SPI_CR1_BR_1 | SPI_CR1_BR_0)
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup SPI_MSB_LSB_transmission SPI MSB LSB Transmission
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define SPI_FIRSTBIT_MSB (0x00000000U)
|
||||||
|
#define SPI_FIRSTBIT_LSB SPI_CR1_LSBFIRST
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup SPI_TI_mode SPI TI Mode
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define SPI_TIMODE_DISABLE (0x00000000U)
|
||||||
|
#define SPI_TIMODE_ENABLE SPI_CR2_FRF
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup SPI_CRC_Calculation SPI CRC Calculation
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define SPI_CRCCALCULATION_DISABLE (0x00000000U)
|
||||||
|
#define SPI_CRCCALCULATION_ENABLE SPI_CR1_CRCEN
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup SPI_Interrupt_definition SPI Interrupt Definition
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define SPI_IT_TXE SPI_CR2_TXEIE
|
||||||
|
#define SPI_IT_RXNE SPI_CR2_RXNEIE
|
||||||
|
#define SPI_IT_ERR SPI_CR2_ERRIE
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup SPI_Flags_definition SPI Flags Definition
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define SPI_FLAG_RXNE SPI_SR_RXNE /* SPI status flag: Rx buffer not empty flag */
|
||||||
|
#define SPI_FLAG_TXE SPI_SR_TXE /* SPI status flag: Tx buffer empty flag */
|
||||||
|
#define SPI_FLAG_BSY SPI_SR_BSY /* SPI status flag: Busy flag */
|
||||||
|
#define SPI_FLAG_CRCERR SPI_SR_CRCERR /* SPI Error flag: CRC error flag */
|
||||||
|
#define SPI_FLAG_MODF SPI_SR_MODF /* SPI Error flag: Mode fault flag */
|
||||||
|
#define SPI_FLAG_OVR SPI_SR_OVR /* SPI Error flag: Overrun flag */
|
||||||
|
#define SPI_FLAG_FRE SPI_SR_FRE /* SPI Error flag: TI mode frame format error flag */
|
||||||
|
#define SPI_FLAG_MASK (SPI_SR_RXNE | SPI_SR_TXE | SPI_SR_BSY | SPI_SR_CRCERR\
|
||||||
|
| SPI_SR_MODF | SPI_SR_OVR | SPI_SR_FRE)
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Exported macros -----------------------------------------------------------*/
|
||||||
|
/** @defgroup SPI_Exported_Macros SPI Exported Macros
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @brief Reset SPI handle state.
|
||||||
|
* @param __HANDLE__ specifies the SPI Handle.
|
||||||
|
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#if (USE_HAL_SPI_REGISTER_CALLBACKS == 1U)
|
||||||
|
#define __HAL_SPI_RESET_HANDLE_STATE(__HANDLE__) do{ \
|
||||||
|
(__HANDLE__)->State = HAL_SPI_STATE_RESET; \
|
||||||
|
(__HANDLE__)->MspInitCallback = NULL; \
|
||||||
|
(__HANDLE__)->MspDeInitCallback = NULL; \
|
||||||
|
} while(0)
|
||||||
|
#else
|
||||||
|
#define __HAL_SPI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SPI_STATE_RESET)
|
||||||
|
#endif /* USE_HAL_SPI_REGISTER_CALLBACKS */
|
||||||
|
|
||||||
|
/** @brief Enable the specified SPI interrupts.
|
||||||
|
* @param __HANDLE__ specifies the SPI Handle.
|
||||||
|
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
||||||
|
* @param __INTERRUPT__ specifies the interrupt source to enable.
|
||||||
|
* This parameter can be one of the following values:
|
||||||
|
* @arg SPI_IT_TXE: Tx buffer empty interrupt enable
|
||||||
|
* @arg SPI_IT_RXNE: RX buffer not empty interrupt enable
|
||||||
|
* @arg SPI_IT_ERR: Error interrupt enable
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define __HAL_SPI_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BIT((__HANDLE__)->Instance->CR2, (__INTERRUPT__))
|
||||||
|
|
||||||
|
/** @brief Disable the specified SPI interrupts.
|
||||||
|
* @param __HANDLE__ specifies the SPI handle.
|
||||||
|
* This parameter can be SPIx where x: 1, 2, or 3 to select the SPI peripheral.
|
||||||
|
* @param __INTERRUPT__ specifies the interrupt source to disable.
|
||||||
|
* This parameter can be one of the following values:
|
||||||
|
* @arg SPI_IT_TXE: Tx buffer empty interrupt enable
|
||||||
|
* @arg SPI_IT_RXNE: RX buffer not empty interrupt enable
|
||||||
|
* @arg SPI_IT_ERR: Error interrupt enable
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define __HAL_SPI_DISABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BIT((__HANDLE__)->Instance->CR2, (__INTERRUPT__))
|
||||||
|
|
||||||
|
/** @brief Check whether the specified SPI interrupt source is enabled or not.
|
||||||
|
* @param __HANDLE__ specifies the SPI Handle.
|
||||||
|
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
||||||
|
* @param __INTERRUPT__ specifies the SPI interrupt source to check.
|
||||||
|
* This parameter can be one of the following values:
|
||||||
|
* @arg SPI_IT_TXE: Tx buffer empty interrupt enable
|
||||||
|
* @arg SPI_IT_RXNE: RX buffer not empty interrupt enable
|
||||||
|
* @arg SPI_IT_ERR: Error interrupt enable
|
||||||
|
* @retval The new state of __IT__ (TRUE or FALSE).
|
||||||
|
*/
|
||||||
|
#define __HAL_SPI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CR2\
|
||||||
|
& (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
|
||||||
|
|
||||||
|
/** @brief Check whether the specified SPI flag is set or not.
|
||||||
|
* @param __HANDLE__ specifies the SPI Handle.
|
||||||
|
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
||||||
|
* @param __FLAG__ specifies the flag to check.
|
||||||
|
* This parameter can be one of the following values:
|
||||||
|
* @arg SPI_FLAG_RXNE: Receive buffer not empty flag
|
||||||
|
* @arg SPI_FLAG_TXE: Transmit buffer empty flag
|
||||||
|
* @arg SPI_FLAG_CRCERR: CRC error flag
|
||||||
|
* @arg SPI_FLAG_MODF: Mode fault flag
|
||||||
|
* @arg SPI_FLAG_OVR: Overrun flag
|
||||||
|
* @arg SPI_FLAG_BSY: Busy flag
|
||||||
|
* @arg SPI_FLAG_FRE: Frame format error flag
|
||||||
|
* @retval The new state of __FLAG__ (TRUE or FALSE).
|
||||||
|
*/
|
||||||
|
#define __HAL_SPI_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__))
|
||||||
|
|
||||||
|
/** @brief Clear the SPI CRCERR pending flag.
|
||||||
|
* @param __HANDLE__ specifies the SPI Handle.
|
||||||
|
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define __HAL_SPI_CLEAR_CRCERRFLAG(__HANDLE__) ((__HANDLE__)->Instance->SR = (uint16_t)(~SPI_FLAG_CRCERR))
|
||||||
|
|
||||||
|
/** @brief Clear the SPI MODF pending flag.
|
||||||
|
* @param __HANDLE__ specifies the SPI Handle.
|
||||||
|
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define __HAL_SPI_CLEAR_MODFFLAG(__HANDLE__) \
|
||||||
|
do{ \
|
||||||
|
__IO uint32_t tmpreg_modf = 0x00U; \
|
||||||
|
tmpreg_modf = (__HANDLE__)->Instance->SR; \
|
||||||
|
CLEAR_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_SPE); \
|
||||||
|
UNUSED(tmpreg_modf); \
|
||||||
|
} while(0U)
|
||||||
|
|
||||||
|
/** @brief Clear the SPI OVR pending flag.
|
||||||
|
* @param __HANDLE__ specifies the SPI Handle.
|
||||||
|
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define __HAL_SPI_CLEAR_OVRFLAG(__HANDLE__) \
|
||||||
|
do{ \
|
||||||
|
__IO uint32_t tmpreg_ovr = 0x00U; \
|
||||||
|
tmpreg_ovr = (__HANDLE__)->Instance->DR; \
|
||||||
|
tmpreg_ovr = (__HANDLE__)->Instance->SR; \
|
||||||
|
UNUSED(tmpreg_ovr); \
|
||||||
|
} while(0U)
|
||||||
|
|
||||||
|
/** @brief Clear the SPI FRE pending flag.
|
||||||
|
* @param __HANDLE__ specifies the SPI Handle.
|
||||||
|
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define __HAL_SPI_CLEAR_FREFLAG(__HANDLE__) \
|
||||||
|
do{ \
|
||||||
|
__IO uint32_t tmpreg_fre = 0x00U; \
|
||||||
|
tmpreg_fre = (__HANDLE__)->Instance->SR; \
|
||||||
|
UNUSED(tmpreg_fre); \
|
||||||
|
}while(0U)
|
||||||
|
|
||||||
|
/** @brief Enable the SPI peripheral.
|
||||||
|
* @param __HANDLE__ specifies the SPI Handle.
|
||||||
|
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define __HAL_SPI_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_SPE)
|
||||||
|
|
||||||
|
/** @brief Disable the SPI peripheral.
|
||||||
|
* @param __HANDLE__ specifies the SPI Handle.
|
||||||
|
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define __HAL_SPI_DISABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_SPE)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Private macros ------------------------------------------------------------*/
|
||||||
|
/** @defgroup SPI_Private_Macros SPI Private Macros
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @brief Set the SPI transmit-only mode.
|
||||||
|
* @param __HANDLE__ specifies the SPI Handle.
|
||||||
|
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define SPI_1LINE_TX(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_BIDIOE)
|
||||||
|
|
||||||
|
/** @brief Set the SPI receive-only mode.
|
||||||
|
* @param __HANDLE__ specifies the SPI Handle.
|
||||||
|
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define SPI_1LINE_RX(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_BIDIOE)
|
||||||
|
|
||||||
|
/** @brief Reset the CRC calculation of the SPI.
|
||||||
|
* @param __HANDLE__ specifies the SPI Handle.
|
||||||
|
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define SPI_RESET_CRC(__HANDLE__) do{CLEAR_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_CRCEN);\
|
||||||
|
SET_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_CRCEN);}while(0U)
|
||||||
|
|
||||||
|
/** @brief Check whether the specified SPI flag is set or not.
|
||||||
|
* @param __SR__ copy of SPI SR register.
|
||||||
|
* @param __FLAG__ specifies the flag to check.
|
||||||
|
* This parameter can be one of the following values:
|
||||||
|
* @arg SPI_FLAG_RXNE: Receive buffer not empty flag
|
||||||
|
* @arg SPI_FLAG_TXE: Transmit buffer empty flag
|
||||||
|
* @arg SPI_FLAG_CRCERR: CRC error flag
|
||||||
|
* @arg SPI_FLAG_MODF: Mode fault flag
|
||||||
|
* @arg SPI_FLAG_OVR: Overrun flag
|
||||||
|
* @arg SPI_FLAG_BSY: Busy flag
|
||||||
|
* @arg SPI_FLAG_FRE: Frame format error flag
|
||||||
|
* @retval SET or RESET.
|
||||||
|
*/
|
||||||
|
#define SPI_CHECK_FLAG(__SR__, __FLAG__) ((((__SR__) & ((__FLAG__) & SPI_FLAG_MASK)) == \
|
||||||
|
((__FLAG__) & SPI_FLAG_MASK)) ? SET : RESET)
|
||||||
|
|
||||||
|
/** @brief Check whether the specified SPI Interrupt is set or not.
|
||||||
|
* @param __CR2__ copy of SPI CR2 register.
|
||||||
|
* @param __INTERRUPT__ specifies the SPI interrupt source to check.
|
||||||
|
* This parameter can be one of the following values:
|
||||||
|
* @arg SPI_IT_TXE: Tx buffer empty interrupt enable
|
||||||
|
* @arg SPI_IT_RXNE: RX buffer not empty interrupt enable
|
||||||
|
* @arg SPI_IT_ERR: Error interrupt enable
|
||||||
|
* @retval SET or RESET.
|
||||||
|
*/
|
||||||
|
#define SPI_CHECK_IT_SOURCE(__CR2__, __INTERRUPT__) ((((__CR2__) & (__INTERRUPT__)) == \
|
||||||
|
(__INTERRUPT__)) ? SET : RESET)
|
||||||
|
|
||||||
|
/** @brief Checks if SPI Mode parameter is in allowed range.
|
||||||
|
* @param __MODE__ specifies the SPI Mode.
|
||||||
|
* This parameter can be a value of @ref SPI_Mode
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define IS_SPI_MODE(__MODE__) (((__MODE__) == SPI_MODE_SLAVE) || \
|
||||||
|
((__MODE__) == SPI_MODE_MASTER))
|
||||||
|
|
||||||
|
/** @brief Checks if SPI Direction Mode parameter is in allowed range.
|
||||||
|
* @param __MODE__ specifies the SPI Direction Mode.
|
||||||
|
* This parameter can be a value of @ref SPI_Direction
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define IS_SPI_DIRECTION(__MODE__) (((__MODE__) == SPI_DIRECTION_2LINES) || \
|
||||||
|
((__MODE__) == SPI_DIRECTION_2LINES_RXONLY) || \
|
||||||
|
((__MODE__) == SPI_DIRECTION_1LINE))
|
||||||
|
|
||||||
|
/** @brief Checks if SPI Direction Mode parameter is 2 lines.
|
||||||
|
* @param __MODE__ specifies the SPI Direction Mode.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define IS_SPI_DIRECTION_2LINES(__MODE__) ((__MODE__) == SPI_DIRECTION_2LINES)
|
||||||
|
|
||||||
|
/** @brief Checks if SPI Direction Mode parameter is 1 or 2 lines.
|
||||||
|
* @param __MODE__ specifies the SPI Direction Mode.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define IS_SPI_DIRECTION_2LINES_OR_1LINE(__MODE__) (((__MODE__) == SPI_DIRECTION_2LINES) || \
|
||||||
|
((__MODE__) == SPI_DIRECTION_1LINE))
|
||||||
|
|
||||||
|
/** @brief Checks if SPI Data Size parameter is in allowed range.
|
||||||
|
* @param __DATASIZE__ specifies the SPI Data Size.
|
||||||
|
* This parameter can be a value of @ref SPI_Data_Size
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define IS_SPI_DATASIZE(__DATASIZE__) (((__DATASIZE__) == SPI_DATASIZE_16BIT) || \
|
||||||
|
((__DATASIZE__) == SPI_DATASIZE_8BIT))
|
||||||
|
|
||||||
|
/** @brief Checks if SPI Serial clock steady state parameter is in allowed range.
|
||||||
|
* @param __CPOL__ specifies the SPI serial clock steady state.
|
||||||
|
* This parameter can be a value of @ref SPI_Clock_Polarity
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define IS_SPI_CPOL(__CPOL__) (((__CPOL__) == SPI_POLARITY_LOW) || \
|
||||||
|
((__CPOL__) == SPI_POLARITY_HIGH))
|
||||||
|
|
||||||
|
/** @brief Checks if SPI Clock Phase parameter is in allowed range.
|
||||||
|
* @param __CPHA__ specifies the SPI Clock Phase.
|
||||||
|
* This parameter can be a value of @ref SPI_Clock_Phase
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define IS_SPI_CPHA(__CPHA__) (((__CPHA__) == SPI_PHASE_1EDGE) || \
|
||||||
|
((__CPHA__) == SPI_PHASE_2EDGE))
|
||||||
|
|
||||||
|
/** @brief Checks if SPI Slave Select parameter is in allowed range.
|
||||||
|
* @param __NSS__ specifies the SPI Slave Select management parameter.
|
||||||
|
* This parameter can be a value of @ref SPI_Slave_Select_management
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define IS_SPI_NSS(__NSS__) (((__NSS__) == SPI_NSS_SOFT) || \
|
||||||
|
((__NSS__) == SPI_NSS_HARD_INPUT) || \
|
||||||
|
((__NSS__) == SPI_NSS_HARD_OUTPUT))
|
||||||
|
|
||||||
|
/** @brief Checks if SPI Baudrate prescaler parameter is in allowed range.
|
||||||
|
* @param __PRESCALER__ specifies the SPI Baudrate prescaler.
|
||||||
|
* This parameter can be a value of @ref SPI_BaudRate_Prescaler
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define IS_SPI_BAUDRATE_PRESCALER(__PRESCALER__) (((__PRESCALER__) == SPI_BAUDRATEPRESCALER_2) || \
|
||||||
|
((__PRESCALER__) == SPI_BAUDRATEPRESCALER_4) || \
|
||||||
|
((__PRESCALER__) == SPI_BAUDRATEPRESCALER_8) || \
|
||||||
|
((__PRESCALER__) == SPI_BAUDRATEPRESCALER_16) || \
|
||||||
|
((__PRESCALER__) == SPI_BAUDRATEPRESCALER_32) || \
|
||||||
|
((__PRESCALER__) == SPI_BAUDRATEPRESCALER_64) || \
|
||||||
|
((__PRESCALER__) == SPI_BAUDRATEPRESCALER_128) || \
|
||||||
|
((__PRESCALER__) == SPI_BAUDRATEPRESCALER_256))
|
||||||
|
|
||||||
|
/** @brief Checks if SPI MSB LSB transmission parameter is in allowed range.
|
||||||
|
* @param __BIT__ specifies the SPI MSB LSB transmission (whether data transfer starts from MSB or LSB bit).
|
||||||
|
* This parameter can be a value of @ref SPI_MSB_LSB_transmission
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define IS_SPI_FIRST_BIT(__BIT__) (((__BIT__) == SPI_FIRSTBIT_MSB) || \
|
||||||
|
((__BIT__) == SPI_FIRSTBIT_LSB))
|
||||||
|
|
||||||
|
/** @brief Checks if SPI TI mode parameter is in allowed range.
|
||||||
|
* @param __MODE__ specifies the SPI TI mode.
|
||||||
|
* This parameter can be a value of @ref SPI_TI_mode
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define IS_SPI_TIMODE(__MODE__) (((__MODE__) == SPI_TIMODE_DISABLE) || \
|
||||||
|
((__MODE__) == SPI_TIMODE_ENABLE))
|
||||||
|
|
||||||
|
/** @brief Checks if SPI CRC calculation enabled state is in allowed range.
|
||||||
|
* @param __CALCULATION__ specifies the SPI CRC calculation enable state.
|
||||||
|
* This parameter can be a value of @ref SPI_CRC_Calculation
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define IS_SPI_CRC_CALCULATION(__CALCULATION__) (((__CALCULATION__) == SPI_CRCCALCULATION_DISABLE) || \
|
||||||
|
((__CALCULATION__) == SPI_CRCCALCULATION_ENABLE))
|
||||||
|
|
||||||
|
/** @brief Checks if SPI polynomial value to be used for the CRC calculation, is in allowed range.
|
||||||
|
* @param __POLYNOMIAL__ specifies the SPI polynomial value to be used for the CRC calculation.
|
||||||
|
* This parameter must be a number between Min_Data = 0 and Max_Data = 65535
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define IS_SPI_CRC_POLYNOMIAL(__POLYNOMIAL__) (((__POLYNOMIAL__) >= 0x1U) && \
|
||||||
|
((__POLYNOMIAL__) <= 0xFFFFU) && \
|
||||||
|
(((__POLYNOMIAL__)&0x1U) != 0U))
|
||||||
|
|
||||||
|
/** @brief Checks if DMA handle is valid.
|
||||||
|
* @param __HANDLE__ specifies a DMA Handle.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
#define IS_SPI_DMA_HANDLE(__HANDLE__) ((__HANDLE__) != NULL)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Exported functions --------------------------------------------------------*/
|
||||||
|
/** @addtogroup SPI_Exported_Functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup SPI_Exported_Functions_Group1
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/* Initialization/de-initialization functions ********************************/
|
||||||
|
HAL_StatusTypeDef HAL_SPI_Init(SPI_HandleTypeDef *hspi);
|
||||||
|
HAL_StatusTypeDef HAL_SPI_DeInit(SPI_HandleTypeDef *hspi);
|
||||||
|
void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi);
|
||||||
|
void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi);
|
||||||
|
|
||||||
|
/* Callbacks Register/UnRegister functions ***********************************/
|
||||||
|
#if (USE_HAL_SPI_REGISTER_CALLBACKS == 1U)
|
||||||
|
HAL_StatusTypeDef HAL_SPI_RegisterCallback(SPI_HandleTypeDef *hspi, HAL_SPI_CallbackIDTypeDef CallbackID,
|
||||||
|
pSPI_CallbackTypeDef pCallback);
|
||||||
|
HAL_StatusTypeDef HAL_SPI_UnRegisterCallback(SPI_HandleTypeDef *hspi, HAL_SPI_CallbackIDTypeDef CallbackID);
|
||||||
|
#endif /* USE_HAL_SPI_REGISTER_CALLBACKS */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup SPI_Exported_Functions_Group2
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/* I/O operation functions ***************************************************/
|
||||||
|
HAL_StatusTypeDef HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, const uint8_t *pData, uint16_t Size, uint32_t Timeout);
|
||||||
|
HAL_StatusTypeDef HAL_SPI_Receive(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout);
|
||||||
|
HAL_StatusTypeDef HAL_SPI_TransmitReceive(SPI_HandleTypeDef *hspi, const uint8_t *pTxData, uint8_t *pRxData,
|
||||||
|
uint16_t Size, uint32_t Timeout);
|
||||||
|
HAL_StatusTypeDef HAL_SPI_Transmit_IT(SPI_HandleTypeDef *hspi, const uint8_t *pData, uint16_t Size);
|
||||||
|
HAL_StatusTypeDef HAL_SPI_Receive_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size);
|
||||||
|
HAL_StatusTypeDef HAL_SPI_TransmitReceive_IT(SPI_HandleTypeDef *hspi, const uint8_t *pTxData, uint8_t *pRxData,
|
||||||
|
uint16_t Size);
|
||||||
|
HAL_StatusTypeDef HAL_SPI_Transmit_DMA(SPI_HandleTypeDef *hspi, const uint8_t *pData, uint16_t Size);
|
||||||
|
HAL_StatusTypeDef HAL_SPI_Receive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size);
|
||||||
|
HAL_StatusTypeDef HAL_SPI_TransmitReceive_DMA(SPI_HandleTypeDef *hspi, const uint8_t *pTxData, uint8_t *pRxData,
|
||||||
|
uint16_t Size);
|
||||||
|
HAL_StatusTypeDef HAL_SPI_DMAPause(SPI_HandleTypeDef *hspi);
|
||||||
|
HAL_StatusTypeDef HAL_SPI_DMAResume(SPI_HandleTypeDef *hspi);
|
||||||
|
HAL_StatusTypeDef HAL_SPI_DMAStop(SPI_HandleTypeDef *hspi);
|
||||||
|
/* Transfer Abort functions */
|
||||||
|
HAL_StatusTypeDef HAL_SPI_Abort(SPI_HandleTypeDef *hspi);
|
||||||
|
HAL_StatusTypeDef HAL_SPI_Abort_IT(SPI_HandleTypeDef *hspi);
|
||||||
|
|
||||||
|
void HAL_SPI_IRQHandler(SPI_HandleTypeDef *hspi);
|
||||||
|
void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi);
|
||||||
|
void HAL_SPI_RxCpltCallback(SPI_HandleTypeDef *hspi);
|
||||||
|
void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi);
|
||||||
|
void HAL_SPI_TxHalfCpltCallback(SPI_HandleTypeDef *hspi);
|
||||||
|
void HAL_SPI_RxHalfCpltCallback(SPI_HandleTypeDef *hspi);
|
||||||
|
void HAL_SPI_TxRxHalfCpltCallback(SPI_HandleTypeDef *hspi);
|
||||||
|
void HAL_SPI_ErrorCallback(SPI_HandleTypeDef *hspi);
|
||||||
|
void HAL_SPI_AbortCpltCallback(SPI_HandleTypeDef *hspi);
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup SPI_Exported_Functions_Group3
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/* Peripheral State and Error functions ***************************************/
|
||||||
|
HAL_SPI_StateTypeDef HAL_SPI_GetState(const SPI_HandleTypeDef *hspi);
|
||||||
|
uint32_t HAL_SPI_GetError(const SPI_HandleTypeDef *hspi);
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* STM32F4xx_HAL_SPI_H */
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,355 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file stm32f4xx_hal_tim_ex.h
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief Header file of TIM HAL Extended module.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2016 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef STM32F4xx_HAL_TIM_EX_H
|
||||||
|
#define STM32F4xx_HAL_TIM_EX_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "stm32f4xx_hal_def.h"
|
||||||
|
|
||||||
|
/** @addtogroup STM32F4xx_HAL_Driver
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup TIMEx
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Exported types ------------------------------------------------------------*/
|
||||||
|
/** @defgroup TIMEx_Exported_Types TIM Extended Exported Types
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TIM Hall sensor Configuration Structure definition
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32_t IC1Polarity; /*!< Specifies the active edge of the input signal.
|
||||||
|
This parameter can be a value of @ref TIM_Input_Capture_Polarity */
|
||||||
|
|
||||||
|
uint32_t IC1Prescaler; /*!< Specifies the Input Capture Prescaler.
|
||||||
|
This parameter can be a value of @ref TIM_Input_Capture_Prescaler */
|
||||||
|
|
||||||
|
uint32_t IC1Filter; /*!< Specifies the input capture filter.
|
||||||
|
This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
|
||||||
|
|
||||||
|
uint32_t Commutation_Delay; /*!< Specifies the pulse value to be loaded into the Capture Compare Register.
|
||||||
|
This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF */
|
||||||
|
} TIM_HallSensor_InitTypeDef;
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
/* End of exported types -----------------------------------------------------*/
|
||||||
|
|
||||||
|
/* Exported constants --------------------------------------------------------*/
|
||||||
|
/** @defgroup TIMEx_Exported_Constants TIM Extended Exported Constants
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup TIMEx_Remap TIM Extended Remapping
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#if defined (TIM2)
|
||||||
|
#if defined(TIM8)
|
||||||
|
#define TIM_TIM2_TIM8_TRGO 0x00000000U /*!< TIM2 ITR1 is connected to TIM8 TRGO */
|
||||||
|
#endif /* TIM8 */
|
||||||
|
#define TIM_TIM2_ETH_PTP TIM_OR_ITR1_RMP_0 /*!< TIM2 ITR1 is connected to PTP trigger output */
|
||||||
|
#define TIM_TIM2_USBFS_SOF TIM_OR_ITR1_RMP_1 /*!< TIM2 ITR1 is connected to OTG FS SOF */
|
||||||
|
#define TIM_TIM2_USBHS_SOF (TIM_OR_ITR1_RMP_1 | TIM_OR_ITR1_RMP_0) /*!< TIM2 ITR1 is connected to OTG HS SOF */
|
||||||
|
#endif /* TIM2 */
|
||||||
|
|
||||||
|
#define TIM_TIM5_GPIO 0x00000000U /*!< TIM5 TI4 is connected to GPIO */
|
||||||
|
#define TIM_TIM5_LSI TIM_OR_TI4_RMP_0 /*!< TIM5 TI4 is connected to LSI */
|
||||||
|
#define TIM_TIM5_LSE TIM_OR_TI4_RMP_1 /*!< TIM5 TI4 is connected to LSE */
|
||||||
|
#define TIM_TIM5_RTC (TIM_OR_TI4_RMP_1 | TIM_OR_TI4_RMP_0) /*!< TIM5 TI4 is connected to the RTC wakeup interrupt */
|
||||||
|
|
||||||
|
#define TIM_TIM11_GPIO 0x00000000U /*!< TIM11 TI1 is connected to GPIO */
|
||||||
|
#define TIM_TIM11_HSE TIM_OR_TI1_RMP_1 /*!< TIM11 TI1 is connected to HSE_RTC clock */
|
||||||
|
#if defined(SPDIFRX)
|
||||||
|
#define TIM_TIM11_SPDIFRX TIM_OR_TI1_RMP_0 /*!< TIM11 TI1 is connected to SPDIFRX_FRAME_SYNC */
|
||||||
|
#endif /* SPDIFRX*/
|
||||||
|
|
||||||
|
#if defined(LPTIM_OR_TIM1_ITR2_RMP) && defined(LPTIM_OR_TIM5_ITR1_RMP) && defined(LPTIM_OR_TIM5_ITR1_RMP)
|
||||||
|
#define LPTIM_REMAP_MASK 0x10000000U
|
||||||
|
|
||||||
|
#define TIM_TIM9_TIM3_TRGO LPTIM_REMAP_MASK /*!< TIM9 ITR1 is connected to TIM3 TRGO */
|
||||||
|
#define TIM_TIM9_LPTIM (LPTIM_REMAP_MASK | LPTIM_OR_TIM9_ITR1_RMP) /*!< TIM9 ITR1 is connected to LPTIM1 output */
|
||||||
|
|
||||||
|
#define TIM_TIM5_TIM3_TRGO LPTIM_REMAP_MASK /*!< TIM5 ITR1 is connected to TIM3 TRGO */
|
||||||
|
#define TIM_TIM5_LPTIM (LPTIM_REMAP_MASK | LPTIM_OR_TIM5_ITR1_RMP) /*!< TIM5 ITR1 is connected to LPTIM1 output */
|
||||||
|
|
||||||
|
#define TIM_TIM1_TIM3_TRGO LPTIM_REMAP_MASK /*!< TIM1 ITR2 is connected to TIM3 TRGO */
|
||||||
|
#define TIM_TIM1_LPTIM (LPTIM_REMAP_MASK | LPTIM_OR_TIM1_ITR2_RMP) /*!< TIM1 ITR2 is connected to LPTIM1 output */
|
||||||
|
#endif /* LPTIM_OR_TIM1_ITR2_RMP && LPTIM_OR_TIM5_ITR1_RMP && LPTIM_OR_TIM5_ITR1_RMP */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
/* End of exported constants -------------------------------------------------*/
|
||||||
|
|
||||||
|
/* Exported macro ------------------------------------------------------------*/
|
||||||
|
/** @defgroup TIMEx_Exported_Macros TIM Extended Exported Macros
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
/* End of exported macro -----------------------------------------------------*/
|
||||||
|
|
||||||
|
/* Private macro -------------------------------------------------------------*/
|
||||||
|
/** @defgroup TIMEx_Private_Macros TIM Extended Private Macros
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#if defined(SPDIFRX)
|
||||||
|
#define IS_TIM_REMAP(INSTANCE, TIM_REMAP) \
|
||||||
|
((((INSTANCE) == TIM2) && (((TIM_REMAP) == TIM_TIM2_TIM8_TRGO) || \
|
||||||
|
((TIM_REMAP) == TIM_TIM2_USBFS_SOF) || \
|
||||||
|
((TIM_REMAP) == TIM_TIM2_USBHS_SOF))) || \
|
||||||
|
(((INSTANCE) == TIM5) && (((TIM_REMAP) == TIM_TIM5_GPIO) || \
|
||||||
|
((TIM_REMAP) == TIM_TIM5_LSI) || \
|
||||||
|
((TIM_REMAP) == TIM_TIM5_LSE) || \
|
||||||
|
((TIM_REMAP) == TIM_TIM5_RTC))) || \
|
||||||
|
(((INSTANCE) == TIM11) && (((TIM_REMAP) == TIM_TIM11_GPIO) || \
|
||||||
|
((TIM_REMAP) == TIM_TIM11_SPDIFRX) || \
|
||||||
|
((TIM_REMAP) == TIM_TIM11_HSE))))
|
||||||
|
#elif defined(TIM2)
|
||||||
|
#if defined(LPTIM_OR_TIM1_ITR2_RMP) && defined(LPTIM_OR_TIM5_ITR1_RMP) && defined(LPTIM_OR_TIM5_ITR1_RMP)
|
||||||
|
#define IS_TIM_REMAP(INSTANCE, TIM_REMAP) \
|
||||||
|
((((INSTANCE) == TIM2) && (((TIM_REMAP) == TIM_TIM2_TIM8_TRGO) || \
|
||||||
|
((TIM_REMAP) == TIM_TIM2_USBFS_SOF) || \
|
||||||
|
((TIM_REMAP) == TIM_TIM2_USBHS_SOF))) || \
|
||||||
|
(((INSTANCE) == TIM5) && (((TIM_REMAP) == TIM_TIM5_GPIO) || \
|
||||||
|
((TIM_REMAP) == TIM_TIM5_LSI) || \
|
||||||
|
((TIM_REMAP) == TIM_TIM5_LSE) || \
|
||||||
|
((TIM_REMAP) == TIM_TIM5_RTC))) || \
|
||||||
|
(((INSTANCE) == TIM11) && (((TIM_REMAP) == TIM_TIM11_GPIO) || \
|
||||||
|
((TIM_REMAP) == TIM_TIM11_HSE))) || \
|
||||||
|
(((INSTANCE) == TIM1) && (((TIM_REMAP) == TIM_TIM1_TIM3_TRGO) || \
|
||||||
|
((TIM_REMAP) == TIM_TIM1_LPTIM))) || \
|
||||||
|
(((INSTANCE) == TIM5) && (((TIM_REMAP) == TIM_TIM5_TIM3_TRGO) || \
|
||||||
|
((TIM_REMAP) == TIM_TIM5_LPTIM))) || \
|
||||||
|
(((INSTANCE) == TIM9) && (((TIM_REMAP) == TIM_TIM9_TIM3_TRGO) || \
|
||||||
|
((TIM_REMAP) == TIM_TIM9_LPTIM))))
|
||||||
|
#elif defined(TIM8)
|
||||||
|
#define IS_TIM_REMAP(INSTANCE, TIM_REMAP) \
|
||||||
|
((((INSTANCE) == TIM2) && (((TIM_REMAP) == TIM_TIM2_TIM8_TRGO) || \
|
||||||
|
((TIM_REMAP) == TIM_TIM2_USBFS_SOF) || \
|
||||||
|
((TIM_REMAP) == TIM_TIM2_USBHS_SOF))) || \
|
||||||
|
(((INSTANCE) == TIM5) && (((TIM_REMAP) == TIM_TIM5_GPIO) || \
|
||||||
|
((TIM_REMAP) == TIM_TIM5_LSI) || \
|
||||||
|
((TIM_REMAP) == TIM_TIM5_LSE) || \
|
||||||
|
((TIM_REMAP) == TIM_TIM5_RTC))) || \
|
||||||
|
(((INSTANCE) == TIM11) && (((TIM_REMAP) == TIM_TIM11_GPIO) || \
|
||||||
|
((TIM_REMAP) == TIM_TIM11_HSE))))
|
||||||
|
#else
|
||||||
|
#define IS_TIM_REMAP(INSTANCE, TIM_REMAP) \
|
||||||
|
((((INSTANCE) == TIM2) && (((TIM_REMAP) == TIM_TIM2_ETH_PTP) || \
|
||||||
|
((TIM_REMAP) == TIM_TIM2_USBFS_SOF) || \
|
||||||
|
((TIM_REMAP) == TIM_TIM2_USBHS_SOF))) || \
|
||||||
|
(((INSTANCE) == TIM5) && (((TIM_REMAP) == TIM_TIM5_GPIO) || \
|
||||||
|
((TIM_REMAP) == TIM_TIM5_LSI) || \
|
||||||
|
((TIM_REMAP) == TIM_TIM5_LSE) || \
|
||||||
|
((TIM_REMAP) == TIM_TIM5_RTC))) || \
|
||||||
|
(((INSTANCE) == TIM11) && (((TIM_REMAP) == TIM_TIM11_GPIO) || \
|
||||||
|
((TIM_REMAP) == TIM_TIM11_HSE))))
|
||||||
|
#endif /* LPTIM_OR_TIM1_ITR2_RMP && LPTIM_OR_TIM5_ITR1_RMP && LPTIM_OR_TIM5_ITR1_RMP */
|
||||||
|
#else
|
||||||
|
#define IS_TIM_REMAP(INSTANCE, TIM_REMAP) \
|
||||||
|
((((INSTANCE) == TIM5) && (((TIM_REMAP) == TIM_TIM5_GPIO) || \
|
||||||
|
((TIM_REMAP) == TIM_TIM5_LSI) || \
|
||||||
|
((TIM_REMAP) == TIM_TIM5_LSE) || \
|
||||||
|
((TIM_REMAP) == TIM_TIM5_RTC))) || \
|
||||||
|
(((INSTANCE) == TIM11) && (((TIM_REMAP) == TIM_TIM11_GPIO) || \
|
||||||
|
((TIM_REMAP) == TIM_TIM11_HSE))))
|
||||||
|
#endif /* SPDIFRX */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
/* End of private macro ------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* Exported functions --------------------------------------------------------*/
|
||||||
|
/** @addtogroup TIMEx_Exported_Functions TIM Extended Exported Functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup TIMEx_Exported_Functions_Group1 Extended Timer Hall Sensor functions
|
||||||
|
* @brief Timer Hall Sensor functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/* Timer Hall Sensor functions **********************************************/
|
||||||
|
HAL_StatusTypeDef HAL_TIMEx_HallSensor_Init(TIM_HandleTypeDef *htim, const TIM_HallSensor_InitTypeDef *sConfig);
|
||||||
|
HAL_StatusTypeDef HAL_TIMEx_HallSensor_DeInit(TIM_HandleTypeDef *htim);
|
||||||
|
|
||||||
|
void HAL_TIMEx_HallSensor_MspInit(TIM_HandleTypeDef *htim);
|
||||||
|
void HAL_TIMEx_HallSensor_MspDeInit(TIM_HandleTypeDef *htim);
|
||||||
|
|
||||||
|
/* Blocking mode: Polling */
|
||||||
|
HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start(TIM_HandleTypeDef *htim);
|
||||||
|
HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop(TIM_HandleTypeDef *htim);
|
||||||
|
/* Non-Blocking mode: Interrupt */
|
||||||
|
HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_IT(TIM_HandleTypeDef *htim);
|
||||||
|
HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_IT(TIM_HandleTypeDef *htim);
|
||||||
|
/* Non-Blocking mode: DMA */
|
||||||
|
HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_DMA(TIM_HandleTypeDef *htim, uint32_t *pData, uint16_t Length);
|
||||||
|
HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_DMA(TIM_HandleTypeDef *htim);
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup TIMEx_Exported_Functions_Group2 Extended Timer Complementary Output Compare functions
|
||||||
|
* @brief Timer Complementary Output Compare functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/* Timer Complementary Output Compare functions *****************************/
|
||||||
|
/* Blocking mode: Polling */
|
||||||
|
HAL_StatusTypeDef HAL_TIMEx_OCN_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||||
|
HAL_StatusTypeDef HAL_TIMEx_OCN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||||
|
|
||||||
|
/* Non-Blocking mode: Interrupt */
|
||||||
|
HAL_StatusTypeDef HAL_TIMEx_OCN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||||
|
HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||||
|
|
||||||
|
/* Non-Blocking mode: DMA */
|
||||||
|
HAL_StatusTypeDef HAL_TIMEx_OCN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, const uint32_t *pData,
|
||||||
|
uint16_t Length);
|
||||||
|
HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup TIMEx_Exported_Functions_Group3 Extended Timer Complementary PWM functions
|
||||||
|
* @brief Timer Complementary PWM functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/* Timer Complementary PWM functions ****************************************/
|
||||||
|
/* Blocking mode: Polling */
|
||||||
|
HAL_StatusTypeDef HAL_TIMEx_PWMN_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||||
|
HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||||
|
|
||||||
|
/* Non-Blocking mode: Interrupt */
|
||||||
|
HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||||
|
HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||||
|
/* Non-Blocking mode: DMA */
|
||||||
|
HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, const uint32_t *pData,
|
||||||
|
uint16_t Length);
|
||||||
|
HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup TIMEx_Exported_Functions_Group4 Extended Timer Complementary One Pulse functions
|
||||||
|
* @brief Timer Complementary One Pulse functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/* Timer Complementary One Pulse functions **********************************/
|
||||||
|
/* Blocking mode: Polling */
|
||||||
|
HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
|
||||||
|
HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
|
||||||
|
|
||||||
|
/* Non-Blocking mode: Interrupt */
|
||||||
|
HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
|
||||||
|
HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup TIMEx_Exported_Functions_Group5 Extended Peripheral Control functions
|
||||||
|
* @brief Peripheral Control functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/* Extended Control functions ************************************************/
|
||||||
|
HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent(TIM_HandleTypeDef *htim, uint32_t InputTrigger,
|
||||||
|
uint32_t CommutationSource);
|
||||||
|
HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent_IT(TIM_HandleTypeDef *htim, uint32_t InputTrigger,
|
||||||
|
uint32_t CommutationSource);
|
||||||
|
HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent_DMA(TIM_HandleTypeDef *htim, uint32_t InputTrigger,
|
||||||
|
uint32_t CommutationSource);
|
||||||
|
HAL_StatusTypeDef HAL_TIMEx_MasterConfigSynchronization(TIM_HandleTypeDef *htim,
|
||||||
|
const TIM_MasterConfigTypeDef *sMasterConfig);
|
||||||
|
HAL_StatusTypeDef HAL_TIMEx_ConfigBreakDeadTime(TIM_HandleTypeDef *htim,
|
||||||
|
const TIM_BreakDeadTimeConfigTypeDef *sBreakDeadTimeConfig);
|
||||||
|
HAL_StatusTypeDef HAL_TIMEx_RemapConfig(TIM_HandleTypeDef *htim, uint32_t Remap);
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup TIMEx_Exported_Functions_Group6 Extended Callbacks functions
|
||||||
|
* @brief Extended Callbacks functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/* Extended Callback **********************************************************/
|
||||||
|
void HAL_TIMEx_CommutCallback(TIM_HandleTypeDef *htim);
|
||||||
|
void HAL_TIMEx_CommutHalfCpltCallback(TIM_HandleTypeDef *htim);
|
||||||
|
void HAL_TIMEx_BreakCallback(TIM_HandleTypeDef *htim);
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup TIMEx_Exported_Functions_Group7 Extended Peripheral State functions
|
||||||
|
* @brief Extended Peripheral State functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
/* Extended Peripheral State functions ***************************************/
|
||||||
|
HAL_TIM_StateTypeDef HAL_TIMEx_HallSensor_GetState(const TIM_HandleTypeDef *htim);
|
||||||
|
HAL_TIM_ChannelStateTypeDef HAL_TIMEx_GetChannelNState(const TIM_HandleTypeDef *htim, uint32_t ChannelN);
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
/* End of exported functions -------------------------------------------------*/
|
||||||
|
|
||||||
|
/* Private functions----------------------------------------------------------*/
|
||||||
|
/** @addtogroup TIMEx_Private_Functions TIM Extended Private Functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
void TIMEx_DMACommutationCplt(DMA_HandleTypeDef *hdma);
|
||||||
|
void TIMEx_DMACommutationHalfCplt(DMA_HandleTypeDef *hdma);
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
/* End of private functions --------------------------------------------------*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* STM32F4xx_HAL_TIM_EX_H */
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,182 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file stm32f4xx_hal_i2c_ex.c
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief I2C Extension HAL module driver.
|
||||||
|
* This file provides firmware functions to manage the following
|
||||||
|
* functionalities of I2C extension peripheral:
|
||||||
|
* + Extension features functions
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2016 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
@verbatim
|
||||||
|
==============================================================================
|
||||||
|
##### I2C peripheral extension features #####
|
||||||
|
==============================================================================
|
||||||
|
|
||||||
|
[..] Comparing to other previous devices, the I2C interface for STM32F427xx/437xx/
|
||||||
|
429xx/439xx devices contains the following additional features :
|
||||||
|
|
||||||
|
(+) Possibility to disable or enable Analog Noise Filter
|
||||||
|
(+) Use of a configured Digital Noise Filter
|
||||||
|
|
||||||
|
##### How to use this driver #####
|
||||||
|
==============================================================================
|
||||||
|
[..] This driver provides functions to configure Noise Filter
|
||||||
|
(#) Configure I2C Analog noise filter using the function HAL_I2C_AnalogFilter_Config()
|
||||||
|
(#) Configure I2C Digital noise filter using the function HAL_I2C_DigitalFilter_Config()
|
||||||
|
|
||||||
|
@endverbatim
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "stm32f4xx_hal.h"
|
||||||
|
|
||||||
|
/** @addtogroup STM32F4xx_HAL_Driver
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @defgroup I2CEx I2CEx
|
||||||
|
* @brief I2C HAL module driver
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAL_I2C_MODULE_ENABLED
|
||||||
|
|
||||||
|
#if defined(I2C_FLTR_ANOFF)&&defined(I2C_FLTR_DNF)
|
||||||
|
/* Private typedef -----------------------------------------------------------*/
|
||||||
|
/* Private define ------------------------------------------------------------*/
|
||||||
|
/* Private macro -------------------------------------------------------------*/
|
||||||
|
/* Private variables ---------------------------------------------------------*/
|
||||||
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
|
/* Exported functions --------------------------------------------------------*/
|
||||||
|
/** @defgroup I2CEx_Exported_Functions I2C Exported Functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/** @defgroup I2CEx_Exported_Functions_Group1 Extension features functions
|
||||||
|
* @brief Extension features functions
|
||||||
|
*
|
||||||
|
@verbatim
|
||||||
|
===============================================================================
|
||||||
|
##### Extension features functions #####
|
||||||
|
===============================================================================
|
||||||
|
[..] This section provides functions allowing to:
|
||||||
|
(+) Configure Noise Filters
|
||||||
|
|
||||||
|
@endverbatim
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Configures I2C Analog noise filter.
|
||||||
|
* @param hi2c pointer to a I2C_HandleTypeDef structure that contains
|
||||||
|
* the configuration information for the specified I2Cx peripheral.
|
||||||
|
* @param AnalogFilter new state of the Analog filter.
|
||||||
|
* @retval HAL status
|
||||||
|
*/
|
||||||
|
HAL_StatusTypeDef HAL_I2CEx_ConfigAnalogFilter(I2C_HandleTypeDef *hi2c, uint32_t AnalogFilter)
|
||||||
|
{
|
||||||
|
/* Check the parameters */
|
||||||
|
assert_param(IS_I2C_ALL_INSTANCE(hi2c->Instance));
|
||||||
|
assert_param(IS_I2C_ANALOG_FILTER(AnalogFilter));
|
||||||
|
|
||||||
|
if (hi2c->State == HAL_I2C_STATE_READY)
|
||||||
|
{
|
||||||
|
hi2c->State = HAL_I2C_STATE_BUSY;
|
||||||
|
|
||||||
|
/* Disable the selected I2C peripheral */
|
||||||
|
__HAL_I2C_DISABLE(hi2c);
|
||||||
|
|
||||||
|
/* Reset I2Cx ANOFF bit */
|
||||||
|
hi2c->Instance->FLTR &= ~(I2C_FLTR_ANOFF);
|
||||||
|
|
||||||
|
/* Disable the analog filter */
|
||||||
|
hi2c->Instance->FLTR |= AnalogFilter;
|
||||||
|
|
||||||
|
__HAL_I2C_ENABLE(hi2c);
|
||||||
|
|
||||||
|
hi2c->State = HAL_I2C_STATE_READY;
|
||||||
|
|
||||||
|
return HAL_OK;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return HAL_BUSY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Configures I2C Digital noise filter.
|
||||||
|
* @param hi2c pointer to a I2C_HandleTypeDef structure that contains
|
||||||
|
* the configuration information for the specified I2Cx peripheral.
|
||||||
|
* @param DigitalFilter Coefficient of digital noise filter between 0x00 and 0x0F.
|
||||||
|
* @retval HAL status
|
||||||
|
*/
|
||||||
|
HAL_StatusTypeDef HAL_I2CEx_ConfigDigitalFilter(I2C_HandleTypeDef *hi2c, uint32_t DigitalFilter)
|
||||||
|
{
|
||||||
|
uint16_t tmpreg = 0;
|
||||||
|
|
||||||
|
/* Check the parameters */
|
||||||
|
assert_param(IS_I2C_ALL_INSTANCE(hi2c->Instance));
|
||||||
|
assert_param(IS_I2C_DIGITAL_FILTER(DigitalFilter));
|
||||||
|
|
||||||
|
if (hi2c->State == HAL_I2C_STATE_READY)
|
||||||
|
{
|
||||||
|
hi2c->State = HAL_I2C_STATE_BUSY;
|
||||||
|
|
||||||
|
/* Disable the selected I2C peripheral */
|
||||||
|
__HAL_I2C_DISABLE(hi2c);
|
||||||
|
|
||||||
|
/* Get the old register value */
|
||||||
|
tmpreg = hi2c->Instance->FLTR;
|
||||||
|
|
||||||
|
/* Reset I2Cx DNF bit [3:0] */
|
||||||
|
tmpreg &= ~(I2C_FLTR_DNF);
|
||||||
|
|
||||||
|
/* Set I2Cx DNF coefficient */
|
||||||
|
tmpreg |= DigitalFilter;
|
||||||
|
|
||||||
|
/* Store the new register value */
|
||||||
|
hi2c->Instance->FLTR = tmpreg;
|
||||||
|
|
||||||
|
__HAL_I2C_ENABLE(hi2c);
|
||||||
|
|
||||||
|
hi2c->State = HAL_I2C_STATE_READY;
|
||||||
|
|
||||||
|
return HAL_OK;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return HAL_BUSY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* HAL_I2C_MODULE_ENABLED */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,922 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file stm32f4xx_ll_adc.c
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief ADC LL module driver
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2017 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
#if defined(USE_FULL_LL_DRIVER)
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "stm32f4xx_ll_adc.h"
|
||||||
|
#include "stm32f4xx_ll_bus.h"
|
||||||
|
|
||||||
|
#ifdef USE_FULL_ASSERT
|
||||||
|
#include "stm32_assert.h"
|
||||||
|
#else
|
||||||
|
#define assert_param(expr) ((void)0U)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** @addtogroup STM32F4xx_LL_Driver
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined (ADC1) || defined (ADC2) || defined (ADC3)
|
||||||
|
|
||||||
|
/** @addtogroup ADC_LL ADC
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Private types -------------------------------------------------------------*/
|
||||||
|
/* Private variables ---------------------------------------------------------*/
|
||||||
|
/* Private constants ---------------------------------------------------------*/
|
||||||
|
/* Private macros ------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/** @addtogroup ADC_LL_Private_Macros
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Check of parameters for configuration of ADC hierarchical scope: */
|
||||||
|
/* common to several ADC instances. */
|
||||||
|
#define IS_LL_ADC_COMMON_CLOCK(__CLOCK__) \
|
||||||
|
( ((__CLOCK__) == LL_ADC_CLOCK_SYNC_PCLK_DIV2) \
|
||||||
|
|| ((__CLOCK__) == LL_ADC_CLOCK_SYNC_PCLK_DIV4) \
|
||||||
|
|| ((__CLOCK__) == LL_ADC_CLOCK_SYNC_PCLK_DIV6) \
|
||||||
|
|| ((__CLOCK__) == LL_ADC_CLOCK_SYNC_PCLK_DIV8) \
|
||||||
|
)
|
||||||
|
|
||||||
|
/* Check of parameters for configuration of ADC hierarchical scope: */
|
||||||
|
/* ADC instance. */
|
||||||
|
#define IS_LL_ADC_RESOLUTION(__RESOLUTION__) \
|
||||||
|
( ((__RESOLUTION__) == LL_ADC_RESOLUTION_12B) \
|
||||||
|
|| ((__RESOLUTION__) == LL_ADC_RESOLUTION_10B) \
|
||||||
|
|| ((__RESOLUTION__) == LL_ADC_RESOLUTION_8B) \
|
||||||
|
|| ((__RESOLUTION__) == LL_ADC_RESOLUTION_6B) \
|
||||||
|
)
|
||||||
|
|
||||||
|
#define IS_LL_ADC_DATA_ALIGN(__DATA_ALIGN__) \
|
||||||
|
( ((__DATA_ALIGN__) == LL_ADC_DATA_ALIGN_RIGHT) \
|
||||||
|
|| ((__DATA_ALIGN__) == LL_ADC_DATA_ALIGN_LEFT) \
|
||||||
|
)
|
||||||
|
|
||||||
|
#define IS_LL_ADC_SCAN_SELECTION(__SCAN_SELECTION__) \
|
||||||
|
( ((__SCAN_SELECTION__) == LL_ADC_SEQ_SCAN_DISABLE) \
|
||||||
|
|| ((__SCAN_SELECTION__) == LL_ADC_SEQ_SCAN_ENABLE) \
|
||||||
|
)
|
||||||
|
|
||||||
|
#define IS_LL_ADC_SEQ_SCAN_MODE(__SEQ_SCAN_MODE__) \
|
||||||
|
( ((__SCAN_MODE__) == LL_ADC_SEQ_SCAN_DISABLE) \
|
||||||
|
|| ((__SCAN_MODE__) == LL_ADC_SEQ_SCAN_ENABLE) \
|
||||||
|
)
|
||||||
|
|
||||||
|
/* Check of parameters for configuration of ADC hierarchical scope: */
|
||||||
|
/* ADC group regular */
|
||||||
|
#define IS_LL_ADC_REG_TRIG_SOURCE(__REG_TRIG_SOURCE__) \
|
||||||
|
( ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_SOFTWARE) \
|
||||||
|
|| ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM1_CH1) \
|
||||||
|
|| ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM1_CH2) \
|
||||||
|
|| ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM1_CH3) \
|
||||||
|
|| ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM2_CH2) \
|
||||||
|
|| ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM2_CH3) \
|
||||||
|
|| ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM2_CH4) \
|
||||||
|
|| ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM2_TRGO) \
|
||||||
|
|| ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM3_CH1) \
|
||||||
|
|| ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM3_TRGO) \
|
||||||
|
|| ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM4_CH4) \
|
||||||
|
|| ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM5_CH1) \
|
||||||
|
|| ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM5_CH2) \
|
||||||
|
|| ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM5_CH3) \
|
||||||
|
|| ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM8_CH1) \
|
||||||
|
|| ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM8_TRGO) \
|
||||||
|
|| ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_EXTI_LINE11) \
|
||||||
|
)
|
||||||
|
#define IS_LL_ADC_REG_CONTINUOUS_MODE(__REG_CONTINUOUS_MODE__) \
|
||||||
|
( ((__REG_CONTINUOUS_MODE__) == LL_ADC_REG_CONV_SINGLE) \
|
||||||
|
|| ((__REG_CONTINUOUS_MODE__) == LL_ADC_REG_CONV_CONTINUOUS) \
|
||||||
|
)
|
||||||
|
|
||||||
|
#define IS_LL_ADC_REG_DMA_TRANSFER(__REG_DMA_TRANSFER__) \
|
||||||
|
( ((__REG_DMA_TRANSFER__) == LL_ADC_REG_DMA_TRANSFER_NONE) \
|
||||||
|
|| ((__REG_DMA_TRANSFER__) == LL_ADC_REG_DMA_TRANSFER_LIMITED) \
|
||||||
|
|| ((__REG_DMA_TRANSFER__) == LL_ADC_REG_DMA_TRANSFER_UNLIMITED) \
|
||||||
|
)
|
||||||
|
|
||||||
|
#define IS_LL_ADC_REG_FLAG_EOC_SELECTION(__REG_FLAG_EOC_SELECTION__) \
|
||||||
|
( ((__REG_FLAG_EOC_SELECTION__) == LL_ADC_REG_FLAG_EOC_SEQUENCE_CONV) \
|
||||||
|
|| ((__REG_FLAG_EOC_SELECTION__) == LL_ADC_REG_FLAG_EOC_UNITARY_CONV) \
|
||||||
|
)
|
||||||
|
|
||||||
|
#define IS_LL_ADC_REG_SEQ_SCAN_LENGTH(__REG_SEQ_SCAN_LENGTH__) \
|
||||||
|
( ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_DISABLE) \
|
||||||
|
|| ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS) \
|
||||||
|
|| ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS) \
|
||||||
|
|| ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_4RANKS) \
|
||||||
|
|| ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS) \
|
||||||
|
|| ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_6RANKS) \
|
||||||
|
|| ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_7RANKS) \
|
||||||
|
|| ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_8RANKS) \
|
||||||
|
|| ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_9RANKS) \
|
||||||
|
|| ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_10RANKS) \
|
||||||
|
|| ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_11RANKS) \
|
||||||
|
|| ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_12RANKS) \
|
||||||
|
|| ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_13RANKS) \
|
||||||
|
|| ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_14RANKS) \
|
||||||
|
|| ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_15RANKS) \
|
||||||
|
|| ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_16RANKS) \
|
||||||
|
)
|
||||||
|
|
||||||
|
#define IS_LL_ADC_REG_SEQ_SCAN_DISCONT_MODE(__REG_SEQ_DISCONT_MODE__) \
|
||||||
|
( ((__REG_SEQ_DISCONT_MODE__) == LL_ADC_REG_SEQ_DISCONT_DISABLE) \
|
||||||
|
|| ((__REG_SEQ_DISCONT_MODE__) == LL_ADC_REG_SEQ_DISCONT_1RANK) \
|
||||||
|
|| ((__REG_SEQ_DISCONT_MODE__) == LL_ADC_REG_SEQ_DISCONT_2RANKS) \
|
||||||
|
|| ((__REG_SEQ_DISCONT_MODE__) == LL_ADC_REG_SEQ_DISCONT_3RANKS) \
|
||||||
|
|| ((__REG_SEQ_DISCONT_MODE__) == LL_ADC_REG_SEQ_DISCONT_4RANKS) \
|
||||||
|
|| ((__REG_SEQ_DISCONT_MODE__) == LL_ADC_REG_SEQ_DISCONT_5RANKS) \
|
||||||
|
|| ((__REG_SEQ_DISCONT_MODE__) == LL_ADC_REG_SEQ_DISCONT_6RANKS) \
|
||||||
|
|| ((__REG_SEQ_DISCONT_MODE__) == LL_ADC_REG_SEQ_DISCONT_7RANKS) \
|
||||||
|
|| ((__REG_SEQ_DISCONT_MODE__) == LL_ADC_REG_SEQ_DISCONT_8RANKS) \
|
||||||
|
)
|
||||||
|
|
||||||
|
/* Check of parameters for configuration of ADC hierarchical scope: */
|
||||||
|
/* ADC group injected */
|
||||||
|
#define IS_LL_ADC_INJ_TRIG_SOURCE(__INJ_TRIG_SOURCE__) \
|
||||||
|
( ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_SOFTWARE) \
|
||||||
|
|| ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM1_CH4) \
|
||||||
|
|| ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM1_TRGO) \
|
||||||
|
|| ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM2_CH1) \
|
||||||
|
|| ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM2_TRGO) \
|
||||||
|
|| ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM3_CH2) \
|
||||||
|
|| ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM3_CH4) \
|
||||||
|
|| ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM4_CH1) \
|
||||||
|
|| ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM4_CH2) \
|
||||||
|
|| ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM4_CH3) \
|
||||||
|
|| ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM4_TRGO) \
|
||||||
|
|| ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM5_CH4) \
|
||||||
|
|| ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM5_TRGO) \
|
||||||
|
|| ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM8_CH2) \
|
||||||
|
|| ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM8_CH3) \
|
||||||
|
|| ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM8_CH4) \
|
||||||
|
|| ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_EXTI_LINE15) \
|
||||||
|
)
|
||||||
|
|
||||||
|
#define IS_LL_ADC_INJ_TRIG_EXT_EDGE(__INJ_TRIG_EXT_EDGE__) \
|
||||||
|
( ((__INJ_TRIG_EXT_EDGE__) == LL_ADC_INJ_TRIG_EXT_RISING) \
|
||||||
|
|| ((__INJ_TRIG_EXT_EDGE__) == LL_ADC_INJ_TRIG_EXT_FALLING) \
|
||||||
|
|| ((__INJ_TRIG_EXT_EDGE__) == LL_ADC_INJ_TRIG_EXT_RISINGFALLING) \
|
||||||
|
)
|
||||||
|
|
||||||
|
#define IS_LL_ADC_INJ_TRIG_AUTO(__INJ_TRIG_AUTO__) \
|
||||||
|
( ((__INJ_TRIG_AUTO__) == LL_ADC_INJ_TRIG_INDEPENDENT) \
|
||||||
|
|| ((__INJ_TRIG_AUTO__) == LL_ADC_INJ_TRIG_FROM_GRP_REGULAR) \
|
||||||
|
)
|
||||||
|
|
||||||
|
#define IS_LL_ADC_INJ_SEQ_SCAN_LENGTH(__INJ_SEQ_SCAN_LENGTH__) \
|
||||||
|
( ((__INJ_SEQ_SCAN_LENGTH__) == LL_ADC_INJ_SEQ_SCAN_DISABLE) \
|
||||||
|
|| ((__INJ_SEQ_SCAN_LENGTH__) == LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS) \
|
||||||
|
|| ((__INJ_SEQ_SCAN_LENGTH__) == LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS) \
|
||||||
|
|| ((__INJ_SEQ_SCAN_LENGTH__) == LL_ADC_INJ_SEQ_SCAN_ENABLE_4RANKS) \
|
||||||
|
)
|
||||||
|
|
||||||
|
#define IS_LL_ADC_INJ_SEQ_SCAN_DISCONT_MODE(__INJ_SEQ_DISCONT_MODE__) \
|
||||||
|
( ((__INJ_SEQ_DISCONT_MODE__) == LL_ADC_INJ_SEQ_DISCONT_DISABLE) \
|
||||||
|
|| ((__INJ_SEQ_DISCONT_MODE__) == LL_ADC_INJ_SEQ_DISCONT_1RANK) \
|
||||||
|
)
|
||||||
|
|
||||||
|
#if defined(ADC_MULTIMODE_SUPPORT)
|
||||||
|
/* Check of parameters for configuration of ADC hierarchical scope: */
|
||||||
|
/* multimode. */
|
||||||
|
#if defined(ADC3)
|
||||||
|
#define IS_LL_ADC_MULTI_MODE(__MULTI_MODE__) \
|
||||||
|
( ((__MULTI_MODE__) == LL_ADC_MULTI_INDEPENDENT) \
|
||||||
|
|| ((__MULTI_MODE__) == LL_ADC_MULTI_DUAL_REG_SIMULT) \
|
||||||
|
|| ((__MULTI_MODE__) == LL_ADC_MULTI_DUAL_REG_INTERL) \
|
||||||
|
|| ((__MULTI_MODE__) == LL_ADC_MULTI_DUAL_INJ_SIMULT) \
|
||||||
|
|| ((__MULTI_MODE__) == LL_ADC_MULTI_DUAL_INJ_ALTERN) \
|
||||||
|
|| ((__MULTI_MODE__) == LL_ADC_MULTI_DUAL_REG_SIM_INJ_SIM) \
|
||||||
|
|| ((__MULTI_MODE__) == LL_ADC_MULTI_DUAL_REG_SIM_INJ_ALT) \
|
||||||
|
|| ((__MULTI_MODE__) == LL_ADC_MULTI_DUAL_REG_INT_INJ_SIM) \
|
||||||
|
|| ((__MULTI_MODE__) == LL_ADC_MULTI_TRIPLE_REG_SIM_INJ_SIM) \
|
||||||
|
|| ((__MULTI_MODE__) == LL_ADC_MULTI_TRIPLE_REG_SIM_INJ_ALT) \
|
||||||
|
|| ((__MULTI_MODE__) == LL_ADC_MULTI_TRIPLE_INJ_SIMULT) \
|
||||||
|
|| ((__MULTI_MODE__) == LL_ADC_MULTI_TRIPLE_REG_SIMULT) \
|
||||||
|
|| ((__MULTI_MODE__) == LL_ADC_MULTI_TRIPLE_REG_INTERL) \
|
||||||
|
|| ((__MULTI_MODE__) == LL_ADC_MULTI_TRIPLE_INJ_ALTERN) \
|
||||||
|
)
|
||||||
|
#else
|
||||||
|
#define IS_LL_ADC_MULTI_MODE(__MULTI_MODE__) \
|
||||||
|
( ((__MULTI_MODE__) == LL_ADC_MULTI_INDEPENDENT) \
|
||||||
|
|| ((__MULTI_MODE__) == LL_ADC_MULTI_DUAL_REG_SIMULT) \
|
||||||
|
|| ((__MULTI_MODE__) == LL_ADC_MULTI_DUAL_REG_INTERL) \
|
||||||
|
|| ((__MULTI_MODE__) == LL_ADC_MULTI_DUAL_INJ_SIMULT) \
|
||||||
|
|| ((__MULTI_MODE__) == LL_ADC_MULTI_DUAL_INJ_ALTERN) \
|
||||||
|
|| ((__MULTI_MODE__) == LL_ADC_MULTI_DUAL_REG_SIM_INJ_SIM) \
|
||||||
|
|| ((__MULTI_MODE__) == LL_ADC_MULTI_DUAL_REG_SIM_INJ_ALT) \
|
||||||
|
|| ((__MULTI_MODE__) == LL_ADC_MULTI_DUAL_REG_INT_INJ_SIM) \
|
||||||
|
)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define IS_LL_ADC_MULTI_DMA_TRANSFER(__MULTI_DMA_TRANSFER__) \
|
||||||
|
( ((__MULTI_DMA_TRANSFER__) == LL_ADC_MULTI_REG_DMA_EACH_ADC) \
|
||||||
|
|| ((__MULTI_DMA_TRANSFER__) == LL_ADC_MULTI_REG_DMA_LIMIT_1) \
|
||||||
|
|| ((__MULTI_DMA_TRANSFER__) == LL_ADC_MULTI_REG_DMA_LIMIT_2) \
|
||||||
|
|| ((__MULTI_DMA_TRANSFER__) == LL_ADC_MULTI_REG_DMA_LIMIT_3) \
|
||||||
|
|| ((__MULTI_DMA_TRANSFER__) == LL_ADC_MULTI_REG_DMA_UNLMT_1) \
|
||||||
|
|| ((__MULTI_DMA_TRANSFER__) == LL_ADC_MULTI_REG_DMA_UNLMT_2) \
|
||||||
|
|| ((__MULTI_DMA_TRANSFER__) == LL_ADC_MULTI_REG_DMA_UNLMT_3) \
|
||||||
|
)
|
||||||
|
|
||||||
|
#define IS_LL_ADC_MULTI_TWOSMP_DELAY(__MULTI_TWOSMP_DELAY__) \
|
||||||
|
( ((__MULTI_TWOSMP_DELAY__) == LL_ADC_MULTI_TWOSMP_DELAY_5CYCLES) \
|
||||||
|
|| ((__MULTI_TWOSMP_DELAY__) == LL_ADC_MULTI_TWOSMP_DELAY_6CYCLES) \
|
||||||
|
|| ((__MULTI_TWOSMP_DELAY__) == LL_ADC_MULTI_TWOSMP_DELAY_7CYCLES) \
|
||||||
|
|| ((__MULTI_TWOSMP_DELAY__) == LL_ADC_MULTI_TWOSMP_DELAY_8CYCLES) \
|
||||||
|
|| ((__MULTI_TWOSMP_DELAY__) == LL_ADC_MULTI_TWOSMP_DELAY_9CYCLES) \
|
||||||
|
|| ((__MULTI_TWOSMP_DELAY__) == LL_ADC_MULTI_TWOSMP_DELAY_10CYCLES) \
|
||||||
|
|| ((__MULTI_TWOSMP_DELAY__) == LL_ADC_MULTI_TWOSMP_DELAY_11CYCLES) \
|
||||||
|
|| ((__MULTI_TWOSMP_DELAY__) == LL_ADC_MULTI_TWOSMP_DELAY_12CYCLES) \
|
||||||
|
|| ((__MULTI_TWOSMP_DELAY__) == LL_ADC_MULTI_TWOSMP_DELAY_13CYCLES) \
|
||||||
|
|| ((__MULTI_TWOSMP_DELAY__) == LL_ADC_MULTI_TWOSMP_DELAY_14CYCLES) \
|
||||||
|
|| ((__MULTI_TWOSMP_DELAY__) == LL_ADC_MULTI_TWOSMP_DELAY_15CYCLES) \
|
||||||
|
|| ((__MULTI_TWOSMP_DELAY__) == LL_ADC_MULTI_TWOSMP_DELAY_16CYCLES) \
|
||||||
|
|| ((__MULTI_TWOSMP_DELAY__) == LL_ADC_MULTI_TWOSMP_DELAY_17CYCLES) \
|
||||||
|
|| ((__MULTI_TWOSMP_DELAY__) == LL_ADC_MULTI_TWOSMP_DELAY_18CYCLES) \
|
||||||
|
|| ((__MULTI_TWOSMP_DELAY__) == LL_ADC_MULTI_TWOSMP_DELAY_19CYCLES) \
|
||||||
|
|| ((__MULTI_TWOSMP_DELAY__) == LL_ADC_MULTI_TWOSMP_DELAY_20CYCLES) \
|
||||||
|
)
|
||||||
|
|
||||||
|
#define IS_LL_ADC_MULTI_MASTER_SLAVE(__MULTI_MASTER_SLAVE__) \
|
||||||
|
( ((__MULTI_MASTER_SLAVE__) == LL_ADC_MULTI_MASTER) \
|
||||||
|
|| ((__MULTI_MASTER_SLAVE__) == LL_ADC_MULTI_SLAVE) \
|
||||||
|
|| ((__MULTI_MASTER_SLAVE__) == LL_ADC_MULTI_MASTER_SLAVE) \
|
||||||
|
)
|
||||||
|
|
||||||
|
#endif /* ADC_MULTIMODE_SUPPORT */
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
|
|
||||||
|
/* Exported functions --------------------------------------------------------*/
|
||||||
|
/** @addtogroup ADC_LL_Exported_Functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup ADC_LL_EF_Init
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief De-initialize registers of all ADC instances belonging to
|
||||||
|
* the same ADC common instance to their default reset values.
|
||||||
|
* @param ADCxy_COMMON ADC common instance
|
||||||
|
* (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
|
||||||
|
* @retval An ErrorStatus enumeration value:
|
||||||
|
* - SUCCESS: ADC common registers are de-initialized
|
||||||
|
* - ERROR: not applicable
|
||||||
|
*/
|
||||||
|
ErrorStatus LL_ADC_CommonDeInit(ADC_Common_TypeDef *ADCxy_COMMON)
|
||||||
|
{
|
||||||
|
/* Check the parameters */
|
||||||
|
assert_param(IS_ADC_COMMON_INSTANCE(ADCxy_COMMON));
|
||||||
|
|
||||||
|
|
||||||
|
/* Force reset of ADC clock (core clock) */
|
||||||
|
LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_ADC);
|
||||||
|
|
||||||
|
/* Release reset of ADC clock (core clock) */
|
||||||
|
LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_ADC);
|
||||||
|
|
||||||
|
return SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Initialize some features of ADC common parameters
|
||||||
|
* (all ADC instances belonging to the same ADC common instance)
|
||||||
|
* and multimode (for devices with several ADC instances available).
|
||||||
|
* @note The setting of ADC common parameters is conditioned to
|
||||||
|
* ADC instances state:
|
||||||
|
* All ADC instances belonging to the same ADC common instance
|
||||||
|
* must be disabled.
|
||||||
|
* @param ADCxy_COMMON ADC common instance
|
||||||
|
* (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
|
||||||
|
* @param ADC_CommonInitStruct Pointer to a @ref LL_ADC_CommonInitTypeDef structure
|
||||||
|
* @retval An ErrorStatus enumeration value:
|
||||||
|
* - SUCCESS: ADC common registers are initialized
|
||||||
|
* - ERROR: ADC common registers are not initialized
|
||||||
|
*/
|
||||||
|
ErrorStatus LL_ADC_CommonInit(ADC_Common_TypeDef *ADCxy_COMMON, LL_ADC_CommonInitTypeDef *ADC_CommonInitStruct)
|
||||||
|
{
|
||||||
|
ErrorStatus status = SUCCESS;
|
||||||
|
|
||||||
|
/* Check the parameters */
|
||||||
|
assert_param(IS_ADC_COMMON_INSTANCE(ADCxy_COMMON));
|
||||||
|
assert_param(IS_LL_ADC_COMMON_CLOCK(ADC_CommonInitStruct->CommonClock));
|
||||||
|
|
||||||
|
#if defined(ADC_MULTIMODE_SUPPORT)
|
||||||
|
assert_param(IS_LL_ADC_MULTI_MODE(ADC_CommonInitStruct->Multimode));
|
||||||
|
if (ADC_CommonInitStruct->Multimode != LL_ADC_MULTI_INDEPENDENT)
|
||||||
|
{
|
||||||
|
assert_param(IS_LL_ADC_MULTI_DMA_TRANSFER(ADC_CommonInitStruct->MultiDMATransfer));
|
||||||
|
assert_param(IS_LL_ADC_MULTI_TWOSMP_DELAY(ADC_CommonInitStruct->MultiTwoSamplingDelay));
|
||||||
|
}
|
||||||
|
#endif /* ADC_MULTIMODE_SUPPORT */
|
||||||
|
|
||||||
|
/* Note: Hardware constraint (refer to description of functions */
|
||||||
|
/* "LL_ADC_SetCommonXXX()" and "LL_ADC_SetMultiXXX()"): */
|
||||||
|
/* On this STM32 series, setting of these features is conditioned to */
|
||||||
|
/* ADC state: */
|
||||||
|
/* All ADC instances of the ADC common group must be disabled. */
|
||||||
|
if (__LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE(ADCxy_COMMON) == 0UL)
|
||||||
|
{
|
||||||
|
/* Configuration of ADC hierarchical scope: */
|
||||||
|
/* - common to several ADC */
|
||||||
|
/* (all ADC instances belonging to the same ADC common instance) */
|
||||||
|
/* - Set ADC clock (conversion clock) */
|
||||||
|
/* - multimode (if several ADC instances available on the */
|
||||||
|
/* selected device) */
|
||||||
|
/* - Set ADC multimode configuration */
|
||||||
|
/* - Set ADC multimode DMA transfer */
|
||||||
|
/* - Set ADC multimode: delay between 2 sampling phases */
|
||||||
|
#if defined(ADC_MULTIMODE_SUPPORT)
|
||||||
|
if (ADC_CommonInitStruct->Multimode != LL_ADC_MULTI_INDEPENDENT)
|
||||||
|
{
|
||||||
|
MODIFY_REG(ADCxy_COMMON->CCR,
|
||||||
|
ADC_CCR_ADCPRE
|
||||||
|
| ADC_CCR_MULTI
|
||||||
|
| ADC_CCR_DMA
|
||||||
|
| ADC_CCR_DDS
|
||||||
|
| ADC_CCR_DELAY
|
||||||
|
,
|
||||||
|
ADC_CommonInitStruct->CommonClock
|
||||||
|
| ADC_CommonInitStruct->Multimode
|
||||||
|
| ADC_CommonInitStruct->MultiDMATransfer
|
||||||
|
| ADC_CommonInitStruct->MultiTwoSamplingDelay
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MODIFY_REG(ADCxy_COMMON->CCR,
|
||||||
|
ADC_CCR_ADCPRE
|
||||||
|
| ADC_CCR_MULTI
|
||||||
|
| ADC_CCR_DMA
|
||||||
|
| ADC_CCR_DDS
|
||||||
|
| ADC_CCR_DELAY
|
||||||
|
,
|
||||||
|
ADC_CommonInitStruct->CommonClock
|
||||||
|
| LL_ADC_MULTI_INDEPENDENT
|
||||||
|
);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
LL_ADC_SetCommonClock(ADCxy_COMMON, ADC_CommonInitStruct->CommonClock);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Initialization error: One or several ADC instances belonging to */
|
||||||
|
/* the same ADC common instance are not disabled. */
|
||||||
|
status = ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set each @ref LL_ADC_CommonInitTypeDef field to default value.
|
||||||
|
* @param ADC_CommonInitStruct Pointer to a @ref LL_ADC_CommonInitTypeDef structure
|
||||||
|
* whose fields will be set to default values.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void LL_ADC_CommonStructInit(LL_ADC_CommonInitTypeDef *ADC_CommonInitStruct)
|
||||||
|
{
|
||||||
|
/* Set ADC_CommonInitStruct fields to default values */
|
||||||
|
/* Set fields of ADC common */
|
||||||
|
/* (all ADC instances belonging to the same ADC common instance) */
|
||||||
|
ADC_CommonInitStruct->CommonClock = LL_ADC_CLOCK_SYNC_PCLK_DIV2;
|
||||||
|
|
||||||
|
#if defined(ADC_MULTIMODE_SUPPORT)
|
||||||
|
/* Set fields of ADC multimode */
|
||||||
|
ADC_CommonInitStruct->Multimode = LL_ADC_MULTI_INDEPENDENT;
|
||||||
|
ADC_CommonInitStruct->MultiDMATransfer = LL_ADC_MULTI_REG_DMA_EACH_ADC;
|
||||||
|
ADC_CommonInitStruct->MultiTwoSamplingDelay = LL_ADC_MULTI_TWOSMP_DELAY_5CYCLES;
|
||||||
|
#endif /* ADC_MULTIMODE_SUPPORT */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief De-initialize registers of the selected ADC instance
|
||||||
|
* to their default reset values.
|
||||||
|
* @note To reset all ADC instances quickly (perform a hard reset),
|
||||||
|
* use function @ref LL_ADC_CommonDeInit().
|
||||||
|
* @param ADCx ADC instance
|
||||||
|
* @retval An ErrorStatus enumeration value:
|
||||||
|
* - SUCCESS: ADC registers are de-initialized
|
||||||
|
* - ERROR: ADC registers are not de-initialized
|
||||||
|
*/
|
||||||
|
ErrorStatus LL_ADC_DeInit(ADC_TypeDef *ADCx)
|
||||||
|
{
|
||||||
|
ErrorStatus status = SUCCESS;
|
||||||
|
|
||||||
|
/* Check the parameters */
|
||||||
|
assert_param(IS_ADC_ALL_INSTANCE(ADCx));
|
||||||
|
|
||||||
|
/* Disable ADC instance if not already disabled. */
|
||||||
|
if (LL_ADC_IsEnabled(ADCx) == 1UL)
|
||||||
|
{
|
||||||
|
/* Set ADC group regular trigger source to SW start to ensure to not */
|
||||||
|
/* have an external trigger event occurring during the conversion stop */
|
||||||
|
/* ADC disable process. */
|
||||||
|
LL_ADC_REG_SetTriggerSource(ADCx, LL_ADC_REG_TRIG_SOFTWARE);
|
||||||
|
|
||||||
|
/* Set ADC group injected trigger source to SW start to ensure to not */
|
||||||
|
/* have an external trigger event occurring during the conversion stop */
|
||||||
|
/* ADC disable process. */
|
||||||
|
LL_ADC_INJ_SetTriggerSource(ADCx, LL_ADC_INJ_TRIG_SOFTWARE);
|
||||||
|
|
||||||
|
/* Disable the ADC instance */
|
||||||
|
LL_ADC_Disable(ADCx);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check whether ADC state is compliant with expected state */
|
||||||
|
/* (hardware requirements of bits state to reset registers below) */
|
||||||
|
if (READ_BIT(ADCx->CR2, ADC_CR2_ADON) == 0UL)
|
||||||
|
{
|
||||||
|
/* ========== Reset ADC registers ========== */
|
||||||
|
/* Reset register SR */
|
||||||
|
CLEAR_BIT(ADCx->SR,
|
||||||
|
(LL_ADC_FLAG_STRT
|
||||||
|
| LL_ADC_FLAG_JSTRT
|
||||||
|
| LL_ADC_FLAG_EOCS
|
||||||
|
| LL_ADC_FLAG_OVR
|
||||||
|
| LL_ADC_FLAG_JEOS
|
||||||
|
| LL_ADC_FLAG_AWD1)
|
||||||
|
);
|
||||||
|
|
||||||
|
/* Reset register CR1 */
|
||||||
|
CLEAR_BIT(ADCx->CR1,
|
||||||
|
(ADC_CR1_OVRIE | ADC_CR1_RES | ADC_CR1_AWDEN
|
||||||
|
| ADC_CR1_JAWDEN
|
||||||
|
| ADC_CR1_DISCNUM | ADC_CR1_JDISCEN | ADC_CR1_DISCEN
|
||||||
|
| ADC_CR1_JAUTO | ADC_CR1_AWDSGL | ADC_CR1_SCAN
|
||||||
|
| ADC_CR1_JEOCIE | ADC_CR1_AWDIE | ADC_CR1_EOCIE
|
||||||
|
| ADC_CR1_AWDCH)
|
||||||
|
);
|
||||||
|
|
||||||
|
/* Reset register CR2 */
|
||||||
|
CLEAR_BIT(ADCx->CR2,
|
||||||
|
(ADC_CR2_SWSTART | ADC_CR2_EXTEN | ADC_CR2_EXTSEL
|
||||||
|
| ADC_CR2_JSWSTART | ADC_CR2_JEXTEN | ADC_CR2_JEXTSEL
|
||||||
|
| ADC_CR2_ALIGN | ADC_CR2_EOCS
|
||||||
|
| ADC_CR2_DDS | ADC_CR2_DMA
|
||||||
|
| ADC_CR2_CONT | ADC_CR2_ADON)
|
||||||
|
);
|
||||||
|
|
||||||
|
/* Reset register SMPR1 */
|
||||||
|
CLEAR_BIT(ADCx->SMPR1,
|
||||||
|
(ADC_SMPR1_SMP18 | ADC_SMPR1_SMP17 | ADC_SMPR1_SMP16
|
||||||
|
| ADC_SMPR1_SMP15 | ADC_SMPR1_SMP14 | ADC_SMPR1_SMP13
|
||||||
|
| ADC_SMPR1_SMP12 | ADC_SMPR1_SMP11 | ADC_SMPR1_SMP10)
|
||||||
|
);
|
||||||
|
|
||||||
|
/* Reset register SMPR2 */
|
||||||
|
CLEAR_BIT(ADCx->SMPR2,
|
||||||
|
(ADC_SMPR2_SMP9
|
||||||
|
| ADC_SMPR2_SMP8 | ADC_SMPR2_SMP7 | ADC_SMPR2_SMP6
|
||||||
|
| ADC_SMPR2_SMP5 | ADC_SMPR2_SMP4 | ADC_SMPR2_SMP3
|
||||||
|
| ADC_SMPR2_SMP2 | ADC_SMPR2_SMP1 | ADC_SMPR2_SMP0)
|
||||||
|
);
|
||||||
|
|
||||||
|
/* Reset register JOFR1 */
|
||||||
|
CLEAR_BIT(ADCx->JOFR1, ADC_JOFR1_JOFFSET1);
|
||||||
|
/* Reset register JOFR2 */
|
||||||
|
CLEAR_BIT(ADCx->JOFR2, ADC_JOFR2_JOFFSET2);
|
||||||
|
/* Reset register JOFR3 */
|
||||||
|
CLEAR_BIT(ADCx->JOFR3, ADC_JOFR3_JOFFSET3);
|
||||||
|
/* Reset register JOFR4 */
|
||||||
|
CLEAR_BIT(ADCx->JOFR4, ADC_JOFR4_JOFFSET4);
|
||||||
|
|
||||||
|
/* Reset register HTR */
|
||||||
|
SET_BIT(ADCx->HTR, ADC_HTR_HT);
|
||||||
|
/* Reset register LTR */
|
||||||
|
CLEAR_BIT(ADCx->LTR, ADC_LTR_LT);
|
||||||
|
|
||||||
|
/* Reset register SQR1 */
|
||||||
|
CLEAR_BIT(ADCx->SQR1,
|
||||||
|
(ADC_SQR1_L
|
||||||
|
| ADC_SQR1_SQ16
|
||||||
|
| ADC_SQR1_SQ15 | ADC_SQR1_SQ14 | ADC_SQR1_SQ13)
|
||||||
|
);
|
||||||
|
|
||||||
|
/* Reset register SQR2 */
|
||||||
|
CLEAR_BIT(ADCx->SQR2,
|
||||||
|
(ADC_SQR2_SQ12 | ADC_SQR2_SQ11 | ADC_SQR2_SQ10
|
||||||
|
| ADC_SQR2_SQ9 | ADC_SQR2_SQ8 | ADC_SQR2_SQ7)
|
||||||
|
);
|
||||||
|
|
||||||
|
/* Reset register SQR3 */
|
||||||
|
CLEAR_BIT(ADCx->SQR3,
|
||||||
|
(ADC_SQR3_SQ6 | ADC_SQR3_SQ5 | ADC_SQR3_SQ4
|
||||||
|
| ADC_SQR3_SQ3 | ADC_SQR3_SQ2 | ADC_SQR3_SQ1)
|
||||||
|
);
|
||||||
|
|
||||||
|
/* Reset register JSQR */
|
||||||
|
CLEAR_BIT(ADCx->JSQR,
|
||||||
|
(ADC_JSQR_JL
|
||||||
|
| ADC_JSQR_JSQ4 | ADC_JSQR_JSQ3
|
||||||
|
| ADC_JSQR_JSQ2 | ADC_JSQR_JSQ1)
|
||||||
|
);
|
||||||
|
|
||||||
|
/* Reset register DR */
|
||||||
|
/* bits in access mode read only, no direct reset applicable */
|
||||||
|
|
||||||
|
/* Reset registers JDR1, JDR2, JDR3, JDR4 */
|
||||||
|
/* bits in access mode read only, no direct reset applicable */
|
||||||
|
|
||||||
|
/* Reset register CCR */
|
||||||
|
CLEAR_BIT(ADC->CCR, ADC_CCR_TSVREFE | ADC_CCR_ADCPRE);
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Initialize some features of ADC instance.
|
||||||
|
* @note These parameters have an impact on ADC scope: ADC instance.
|
||||||
|
* Affects both group regular and group injected (availability
|
||||||
|
* of ADC group injected depends on STM32 families).
|
||||||
|
* Refer to corresponding unitary functions into
|
||||||
|
* @ref ADC_LL_EF_Configuration_ADC_Instance .
|
||||||
|
* @note The setting of these parameters by function @ref LL_ADC_Init()
|
||||||
|
* is conditioned to ADC state:
|
||||||
|
* ADC instance must be disabled.
|
||||||
|
* This condition is applied to all ADC features, for efficiency
|
||||||
|
* and compatibility over all STM32 families. However, the different
|
||||||
|
* features can be set under different ADC state conditions
|
||||||
|
* (setting possible with ADC enabled without conversion on going,
|
||||||
|
* ADC enabled with conversion on going, ...)
|
||||||
|
* Each feature can be updated afterwards with a unitary function
|
||||||
|
* and potentially with ADC in a different state than disabled,
|
||||||
|
* refer to description of each function for setting
|
||||||
|
* conditioned to ADC state.
|
||||||
|
* @note After using this function, some other features must be configured
|
||||||
|
* using LL unitary functions.
|
||||||
|
* The minimum configuration remaining to be done is:
|
||||||
|
* - Set ADC group regular or group injected sequencer:
|
||||||
|
* map channel on the selected sequencer rank.
|
||||||
|
* Refer to function @ref LL_ADC_REG_SetSequencerRanks().
|
||||||
|
* - Set ADC channel sampling time
|
||||||
|
* Refer to function LL_ADC_SetChannelSamplingTime();
|
||||||
|
* @param ADCx ADC instance
|
||||||
|
* @param ADC_InitStruct Pointer to a @ref LL_ADC_REG_InitTypeDef structure
|
||||||
|
* @retval An ErrorStatus enumeration value:
|
||||||
|
* - SUCCESS: ADC registers are initialized
|
||||||
|
* - ERROR: ADC registers are not initialized
|
||||||
|
*/
|
||||||
|
ErrorStatus LL_ADC_Init(ADC_TypeDef *ADCx, LL_ADC_InitTypeDef *ADC_InitStruct)
|
||||||
|
{
|
||||||
|
ErrorStatus status = SUCCESS;
|
||||||
|
|
||||||
|
/* Check the parameters */
|
||||||
|
assert_param(IS_ADC_ALL_INSTANCE(ADCx));
|
||||||
|
|
||||||
|
assert_param(IS_LL_ADC_RESOLUTION(ADC_InitStruct->Resolution));
|
||||||
|
assert_param(IS_LL_ADC_DATA_ALIGN(ADC_InitStruct->DataAlignment));
|
||||||
|
assert_param(IS_LL_ADC_SCAN_SELECTION(ADC_InitStruct->SequencersScanMode));
|
||||||
|
|
||||||
|
/* Note: Hardware constraint (refer to description of this function): */
|
||||||
|
/* ADC instance must be disabled. */
|
||||||
|
if (LL_ADC_IsEnabled(ADCx) == 0UL)
|
||||||
|
{
|
||||||
|
/* Configuration of ADC hierarchical scope: */
|
||||||
|
/* - ADC instance */
|
||||||
|
/* - Set ADC data resolution */
|
||||||
|
/* - Set ADC conversion data alignment */
|
||||||
|
MODIFY_REG(ADCx->CR1,
|
||||||
|
ADC_CR1_RES
|
||||||
|
| ADC_CR1_SCAN
|
||||||
|
,
|
||||||
|
ADC_InitStruct->Resolution
|
||||||
|
| ADC_InitStruct->SequencersScanMode
|
||||||
|
);
|
||||||
|
|
||||||
|
MODIFY_REG(ADCx->CR2,
|
||||||
|
ADC_CR2_ALIGN
|
||||||
|
,
|
||||||
|
ADC_InitStruct->DataAlignment
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Initialization error: ADC instance is not disabled. */
|
||||||
|
status = ERROR;
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set each @ref LL_ADC_InitTypeDef field to default value.
|
||||||
|
* @param ADC_InitStruct Pointer to a @ref LL_ADC_InitTypeDef structure
|
||||||
|
* whose fields will be set to default values.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void LL_ADC_StructInit(LL_ADC_InitTypeDef *ADC_InitStruct)
|
||||||
|
{
|
||||||
|
/* Set ADC_InitStruct fields to default values */
|
||||||
|
/* Set fields of ADC instance */
|
||||||
|
ADC_InitStruct->Resolution = LL_ADC_RESOLUTION_12B;
|
||||||
|
ADC_InitStruct->DataAlignment = LL_ADC_DATA_ALIGN_RIGHT;
|
||||||
|
|
||||||
|
/* Enable scan mode to have a generic behavior with ADC of other */
|
||||||
|
/* STM32 families, without this setting available: */
|
||||||
|
/* ADC group regular sequencer and ADC group injected sequencer depend */
|
||||||
|
/* only of their own configuration. */
|
||||||
|
ADC_InitStruct->SequencersScanMode = LL_ADC_SEQ_SCAN_ENABLE;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Initialize some features of ADC group regular.
|
||||||
|
* @note These parameters have an impact on ADC scope: ADC group regular.
|
||||||
|
* Refer to corresponding unitary functions into
|
||||||
|
* @ref ADC_LL_EF_Configuration_ADC_Group_Regular
|
||||||
|
* (functions with prefix "REG").
|
||||||
|
* @note The setting of these parameters by function @ref LL_ADC_Init()
|
||||||
|
* is conditioned to ADC state:
|
||||||
|
* ADC instance must be disabled.
|
||||||
|
* This condition is applied to all ADC features, for efficiency
|
||||||
|
* and compatibility over all STM32 families. However, the different
|
||||||
|
* features can be set under different ADC state conditions
|
||||||
|
* (setting possible with ADC enabled without conversion on going,
|
||||||
|
* ADC enabled with conversion on going, ...)
|
||||||
|
* Each feature can be updated afterwards with a unitary function
|
||||||
|
* and potentially with ADC in a different state than disabled,
|
||||||
|
* refer to description of each function for setting
|
||||||
|
* conditioned to ADC state.
|
||||||
|
* @note After using this function, other features must be configured
|
||||||
|
* using LL unitary functions.
|
||||||
|
* The minimum configuration remaining to be done is:
|
||||||
|
* - Set ADC group regular or group injected sequencer:
|
||||||
|
* map channel on the selected sequencer rank.
|
||||||
|
* Refer to function @ref LL_ADC_REG_SetSequencerRanks().
|
||||||
|
* - Set ADC channel sampling time
|
||||||
|
* Refer to function LL_ADC_SetChannelSamplingTime();
|
||||||
|
* @param ADCx ADC instance
|
||||||
|
* @param ADC_REG_InitStruct Pointer to a @ref LL_ADC_REG_InitTypeDef structure
|
||||||
|
* @retval An ErrorStatus enumeration value:
|
||||||
|
* - SUCCESS: ADC registers are initialized
|
||||||
|
* - ERROR: ADC registers are not initialized
|
||||||
|
*/
|
||||||
|
ErrorStatus LL_ADC_REG_Init(ADC_TypeDef *ADCx, LL_ADC_REG_InitTypeDef *ADC_REG_InitStruct)
|
||||||
|
{
|
||||||
|
ErrorStatus status = SUCCESS;
|
||||||
|
|
||||||
|
/* Check the parameters */
|
||||||
|
assert_param(IS_ADC_ALL_INSTANCE(ADCx));
|
||||||
|
assert_param(IS_LL_ADC_REG_TRIG_SOURCE(ADC_REG_InitStruct->TriggerSource));
|
||||||
|
assert_param(IS_LL_ADC_REG_SEQ_SCAN_LENGTH(ADC_REG_InitStruct->SequencerLength));
|
||||||
|
if (ADC_REG_InitStruct->SequencerLength != LL_ADC_REG_SEQ_SCAN_DISABLE)
|
||||||
|
{
|
||||||
|
assert_param(IS_LL_ADC_REG_SEQ_SCAN_DISCONT_MODE(ADC_REG_InitStruct->SequencerDiscont));
|
||||||
|
}
|
||||||
|
assert_param(IS_LL_ADC_REG_CONTINUOUS_MODE(ADC_REG_InitStruct->ContinuousMode));
|
||||||
|
assert_param(IS_LL_ADC_REG_DMA_TRANSFER(ADC_REG_InitStruct->DMATransfer));
|
||||||
|
|
||||||
|
/* ADC group regular continuous mode and discontinuous mode */
|
||||||
|
/* can not be enabled simultenaeously */
|
||||||
|
assert_param((ADC_REG_InitStruct->ContinuousMode == LL_ADC_REG_CONV_SINGLE)
|
||||||
|
|| (ADC_REG_InitStruct->SequencerDiscont == LL_ADC_REG_SEQ_DISCONT_DISABLE));
|
||||||
|
|
||||||
|
/* Note: Hardware constraint (refer to description of this function): */
|
||||||
|
/* ADC instance must be disabled. */
|
||||||
|
if (LL_ADC_IsEnabled(ADCx) == 0UL)
|
||||||
|
{
|
||||||
|
/* Configuration of ADC hierarchical scope: */
|
||||||
|
/* - ADC group regular */
|
||||||
|
/* - Set ADC group regular trigger source */
|
||||||
|
/* - Set ADC group regular sequencer length */
|
||||||
|
/* - Set ADC group regular sequencer discontinuous mode */
|
||||||
|
/* - Set ADC group regular continuous mode */
|
||||||
|
/* - Set ADC group regular conversion data transfer: no transfer or */
|
||||||
|
/* transfer by DMA, and DMA requests mode */
|
||||||
|
/* Note: On this STM32 series, ADC trigger edge is set when starting */
|
||||||
|
/* ADC conversion. */
|
||||||
|
/* Refer to function @ref LL_ADC_REG_StartConversionExtTrig(). */
|
||||||
|
if (ADC_REG_InitStruct->SequencerLength != LL_ADC_REG_SEQ_SCAN_DISABLE)
|
||||||
|
{
|
||||||
|
MODIFY_REG(ADCx->CR1,
|
||||||
|
ADC_CR1_DISCEN
|
||||||
|
| ADC_CR1_DISCNUM
|
||||||
|
,
|
||||||
|
ADC_REG_InitStruct->SequencerDiscont
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MODIFY_REG(ADCx->CR1,
|
||||||
|
ADC_CR1_DISCEN
|
||||||
|
| ADC_CR1_DISCNUM
|
||||||
|
,
|
||||||
|
LL_ADC_REG_SEQ_DISCONT_DISABLE
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
MODIFY_REG(ADCx->CR2,
|
||||||
|
ADC_CR2_EXTSEL
|
||||||
|
| ADC_CR2_EXTEN
|
||||||
|
| ADC_CR2_CONT
|
||||||
|
| ADC_CR2_DMA
|
||||||
|
| ADC_CR2_DDS
|
||||||
|
,
|
||||||
|
(ADC_REG_InitStruct->TriggerSource & ADC_CR2_EXTSEL)
|
||||||
|
| ADC_REG_InitStruct->ContinuousMode
|
||||||
|
| ADC_REG_InitStruct->DMATransfer
|
||||||
|
);
|
||||||
|
|
||||||
|
/* Set ADC group regular sequencer length and scan direction */
|
||||||
|
/* Note: Hardware constraint (refer to description of this function): */
|
||||||
|
/* Note: If ADC instance feature scan mode is disabled */
|
||||||
|
/* (refer to ADC instance initialization structure */
|
||||||
|
/* parameter @ref SequencersScanMode */
|
||||||
|
/* or function @ref LL_ADC_SetSequencersScanMode() ), */
|
||||||
|
/* this parameter is discarded. */
|
||||||
|
LL_ADC_REG_SetSequencerLength(ADCx, ADC_REG_InitStruct->SequencerLength);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Initialization error: ADC instance is not disabled. */
|
||||||
|
status = ERROR;
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set each @ref LL_ADC_REG_InitTypeDef field to default value.
|
||||||
|
* @param ADC_REG_InitStruct Pointer to a @ref LL_ADC_REG_InitTypeDef structure
|
||||||
|
* whose fields will be set to default values.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void LL_ADC_REG_StructInit(LL_ADC_REG_InitTypeDef *ADC_REG_InitStruct)
|
||||||
|
{
|
||||||
|
/* Set ADC_REG_InitStruct fields to default values */
|
||||||
|
/* Set fields of ADC group regular */
|
||||||
|
/* Note: On this STM32 series, ADC trigger edge is set when starting */
|
||||||
|
/* ADC conversion. */
|
||||||
|
/* Refer to function @ref LL_ADC_REG_StartConversionExtTrig(). */
|
||||||
|
ADC_REG_InitStruct->TriggerSource = LL_ADC_REG_TRIG_SOFTWARE;
|
||||||
|
ADC_REG_InitStruct->SequencerLength = LL_ADC_REG_SEQ_SCAN_DISABLE;
|
||||||
|
ADC_REG_InitStruct->SequencerDiscont = LL_ADC_REG_SEQ_DISCONT_DISABLE;
|
||||||
|
ADC_REG_InitStruct->ContinuousMode = LL_ADC_REG_CONV_SINGLE;
|
||||||
|
ADC_REG_InitStruct->DMATransfer = LL_ADC_REG_DMA_TRANSFER_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Initialize some features of ADC group injected.
|
||||||
|
* @note These parameters have an impact on ADC scope: ADC group injected.
|
||||||
|
* Refer to corresponding unitary functions into
|
||||||
|
* @ref ADC_LL_EF_Configuration_ADC_Group_Regular
|
||||||
|
* (functions with prefix "INJ").
|
||||||
|
* @note The setting of these parameters by function @ref LL_ADC_Init()
|
||||||
|
* is conditioned to ADC state:
|
||||||
|
* ADC instance must be disabled.
|
||||||
|
* This condition is applied to all ADC features, for efficiency
|
||||||
|
* and compatibility over all STM32 families. However, the different
|
||||||
|
* features can be set under different ADC state conditions
|
||||||
|
* (setting possible with ADC enabled without conversion on going,
|
||||||
|
* ADC enabled with conversion on going, ...)
|
||||||
|
* Each feature can be updated afterwards with a unitary function
|
||||||
|
* and potentially with ADC in a different state than disabled,
|
||||||
|
* refer to description of each function for setting
|
||||||
|
* conditioned to ADC state.
|
||||||
|
* @note After using this function, other features must be configured
|
||||||
|
* using LL unitary functions.
|
||||||
|
* The minimum configuration remaining to be done is:
|
||||||
|
* - Set ADC group injected sequencer:
|
||||||
|
* map channel on the selected sequencer rank.
|
||||||
|
* Refer to function @ref LL_ADC_INJ_SetSequencerRanks().
|
||||||
|
* - Set ADC channel sampling time
|
||||||
|
* Refer to function LL_ADC_SetChannelSamplingTime();
|
||||||
|
* @param ADCx ADC instance
|
||||||
|
* @param ADC_INJ_InitStruct Pointer to a @ref LL_ADC_INJ_InitTypeDef structure
|
||||||
|
* @retval An ErrorStatus enumeration value:
|
||||||
|
* - SUCCESS: ADC registers are initialized
|
||||||
|
* - ERROR: ADC registers are not initialized
|
||||||
|
*/
|
||||||
|
ErrorStatus LL_ADC_INJ_Init(ADC_TypeDef *ADCx, LL_ADC_INJ_InitTypeDef *ADC_INJ_InitStruct)
|
||||||
|
{
|
||||||
|
ErrorStatus status = SUCCESS;
|
||||||
|
|
||||||
|
/* Check the parameters */
|
||||||
|
assert_param(IS_ADC_ALL_INSTANCE(ADCx));
|
||||||
|
assert_param(IS_LL_ADC_INJ_TRIG_SOURCE(ADC_INJ_InitStruct->TriggerSource));
|
||||||
|
assert_param(IS_LL_ADC_INJ_SEQ_SCAN_LENGTH(ADC_INJ_InitStruct->SequencerLength));
|
||||||
|
if (ADC_INJ_InitStruct->SequencerLength != LL_ADC_INJ_SEQ_SCAN_DISABLE)
|
||||||
|
{
|
||||||
|
assert_param(IS_LL_ADC_INJ_SEQ_SCAN_DISCONT_MODE(ADC_INJ_InitStruct->SequencerDiscont));
|
||||||
|
}
|
||||||
|
assert_param(IS_LL_ADC_INJ_TRIG_AUTO(ADC_INJ_InitStruct->TrigAuto));
|
||||||
|
|
||||||
|
/* Note: Hardware constraint (refer to description of this function): */
|
||||||
|
/* ADC instance must be disabled. */
|
||||||
|
if (LL_ADC_IsEnabled(ADCx) == 0UL)
|
||||||
|
{
|
||||||
|
/* Configuration of ADC hierarchical scope: */
|
||||||
|
/* - ADC group injected */
|
||||||
|
/* - Set ADC group injected trigger source */
|
||||||
|
/* - Set ADC group injected sequencer length */
|
||||||
|
/* - Set ADC group injected sequencer discontinuous mode */
|
||||||
|
/* - Set ADC group injected conversion trigger: independent or */
|
||||||
|
/* from ADC group regular */
|
||||||
|
/* Note: On this STM32 series, ADC trigger edge is set when starting */
|
||||||
|
/* ADC conversion. */
|
||||||
|
/* Refer to function @ref LL_ADC_INJ_StartConversionExtTrig(). */
|
||||||
|
if (ADC_INJ_InitStruct->SequencerLength != LL_ADC_REG_SEQ_SCAN_DISABLE)
|
||||||
|
{
|
||||||
|
MODIFY_REG(ADCx->CR1,
|
||||||
|
ADC_CR1_JDISCEN
|
||||||
|
| ADC_CR1_JAUTO
|
||||||
|
,
|
||||||
|
ADC_INJ_InitStruct->SequencerDiscont
|
||||||
|
| ADC_INJ_InitStruct->TrigAuto
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MODIFY_REG(ADCx->CR1,
|
||||||
|
ADC_CR1_JDISCEN
|
||||||
|
| ADC_CR1_JAUTO
|
||||||
|
,
|
||||||
|
LL_ADC_REG_SEQ_DISCONT_DISABLE
|
||||||
|
| ADC_INJ_InitStruct->TrigAuto
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
MODIFY_REG(ADCx->CR2,
|
||||||
|
ADC_CR2_JEXTSEL
|
||||||
|
| ADC_CR2_JEXTEN
|
||||||
|
,
|
||||||
|
(ADC_INJ_InitStruct->TriggerSource & ADC_CR2_JEXTSEL)
|
||||||
|
);
|
||||||
|
|
||||||
|
/* Note: Hardware constraint (refer to description of this function): */
|
||||||
|
/* Note: If ADC instance feature scan mode is disabled */
|
||||||
|
/* (refer to ADC instance initialization structure */
|
||||||
|
/* parameter @ref SequencersScanMode */
|
||||||
|
/* or function @ref LL_ADC_SetSequencersScanMode() ), */
|
||||||
|
/* this parameter is discarded. */
|
||||||
|
LL_ADC_INJ_SetSequencerLength(ADCx, ADC_INJ_InitStruct->SequencerLength);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Initialization error: ADC instance is not disabled. */
|
||||||
|
status = ERROR;
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set each @ref LL_ADC_INJ_InitTypeDef field to default value.
|
||||||
|
* @param ADC_INJ_InitStruct Pointer to a @ref LL_ADC_INJ_InitTypeDef structure
|
||||||
|
* whose fields will be set to default values.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void LL_ADC_INJ_StructInit(LL_ADC_INJ_InitTypeDef *ADC_INJ_InitStruct)
|
||||||
|
{
|
||||||
|
/* Set ADC_INJ_InitStruct fields to default values */
|
||||||
|
/* Set fields of ADC group injected */
|
||||||
|
ADC_INJ_InitStruct->TriggerSource = LL_ADC_INJ_TRIG_SOFTWARE;
|
||||||
|
ADC_INJ_InitStruct->SequencerLength = LL_ADC_INJ_SEQ_SCAN_DISABLE;
|
||||||
|
ADC_INJ_InitStruct->SequencerDiscont = LL_ADC_INJ_SEQ_DISCONT_DISABLE;
|
||||||
|
ADC_INJ_InitStruct->TrigAuto = LL_ADC_INJ_TRIG_INDEPENDENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endif /* ADC1 || ADC2 || ADC3 */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endif /* USE_FULL_LL_DRIVER */
|
||||||
|
|
||||||
@@ -1,30 +1,73 @@
|
|||||||
#MicroXplorer Configuration settings - do not modify
|
#MicroXplorer Configuration settings - do not modify
|
||||||
|
ADC1.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_9
|
||||||
|
ADC1.DataAlign=ADC_DATAALIGN_RIGHT
|
||||||
|
ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,NbrOfConversionFlag,master,DataAlign,NbrOfConversion
|
||||||
|
ADC1.NbrOfConversion=1
|
||||||
|
ADC1.NbrOfConversionFlag=1
|
||||||
|
ADC1.Rank-0\#ChannelRegularConversion=1
|
||||||
|
ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_480CYCLES
|
||||||
|
ADC1.master=1
|
||||||
CAD.formats=
|
CAD.formats=
|
||||||
CAD.pinconfig=
|
CAD.pinconfig=
|
||||||
CAD.provider=
|
CAD.provider=
|
||||||
File.Version=6
|
File.Version=6
|
||||||
GPIO.groupedBy=Group By Peripherals
|
GPIO.groupedBy=Group By Peripherals
|
||||||
|
I2S2.AudioFreq=I2S_AUDIOFREQ_48K
|
||||||
|
I2S2.DataFormat=I2S_DATAFORMAT_16B
|
||||||
|
I2S2.ErrorAudioFreq=-0.79 %
|
||||||
|
I2S2.FullDuplexMode=I2S_FULLDUPLEXMODE_DISABLE
|
||||||
|
I2S2.IPParameters=Instance,VirtualMode,FullDuplexMode,RealAudioFreq,ErrorAudioFreq,Mode,DataFormat,AudioFreq
|
||||||
|
I2S2.Instance=SPI$Index
|
||||||
|
I2S2.Mode=I2S_MODE_MASTER_RX
|
||||||
|
I2S2.RealAudioFreq=47.619 KHz
|
||||||
|
I2S2.VirtualMode=I2S_MODE_MASTER
|
||||||
KeepUserPlacement=false
|
KeepUserPlacement=false
|
||||||
Mcu.CPN=STM32F407VGT6
|
Mcu.CPN=STM32F407VGT6
|
||||||
Mcu.Family=STM32F4
|
Mcu.Family=STM32F4
|
||||||
Mcu.IP0=NVIC
|
Mcu.IP0=ADC1
|
||||||
Mcu.IP1=RCC
|
Mcu.IP1=I2C1
|
||||||
Mcu.IPNb=2
|
Mcu.IP2=I2S2
|
||||||
|
Mcu.IP3=NVIC
|
||||||
|
Mcu.IP4=RCC
|
||||||
|
Mcu.IP5=SPI1
|
||||||
|
Mcu.IP6=SYS
|
||||||
|
Mcu.IP7=TIM2
|
||||||
|
Mcu.IPNb=8
|
||||||
Mcu.Name=STM32F407V(E-G)Tx
|
Mcu.Name=STM32F407V(E-G)Tx
|
||||||
Mcu.Package=LQFP100
|
Mcu.Package=LQFP100
|
||||||
Mcu.Pin0=PA0-WKUP
|
Mcu.Pin0=PC3
|
||||||
Mcu.Pin1=PE7
|
Mcu.Pin1=PA0-WKUP
|
||||||
Mcu.Pin10=PD14
|
Mcu.Pin10=PE15
|
||||||
Mcu.Pin11=PD15
|
Mcu.Pin11=PB10
|
||||||
Mcu.Pin2=PE10
|
Mcu.Pin12=PB12
|
||||||
Mcu.Pin3=PE11
|
Mcu.Pin13=PD11
|
||||||
Mcu.Pin4=PE12
|
Mcu.Pin14=PD12
|
||||||
Mcu.Pin5=PE13
|
Mcu.Pin15=PD13
|
||||||
Mcu.Pin6=PE14
|
Mcu.Pin16=PD14
|
||||||
Mcu.Pin7=PE15
|
Mcu.Pin17=PD15
|
||||||
Mcu.Pin8=PD12
|
Mcu.Pin18=PC6
|
||||||
Mcu.Pin9=PD13
|
Mcu.Pin19=PC8
|
||||||
Mcu.PinsNb=12
|
Mcu.Pin2=PA5
|
||||||
|
Mcu.Pin20=PC9
|
||||||
|
Mcu.Pin21=PA15
|
||||||
|
Mcu.Pin22=PC11
|
||||||
|
Mcu.Pin23=PD4
|
||||||
|
Mcu.Pin24=PD7
|
||||||
|
Mcu.Pin25=PB4
|
||||||
|
Mcu.Pin26=PB5
|
||||||
|
Mcu.Pin27=PB6
|
||||||
|
Mcu.Pin28=PB7
|
||||||
|
Mcu.Pin29=PB9
|
||||||
|
Mcu.Pin3=PB1
|
||||||
|
Mcu.Pin30=VP_SYS_VS_Systick
|
||||||
|
Mcu.Pin31=VP_TIM2_VS_ClockSourceINT
|
||||||
|
Mcu.Pin4=PE7
|
||||||
|
Mcu.Pin5=PE10
|
||||||
|
Mcu.Pin6=PE11
|
||||||
|
Mcu.Pin7=PE12
|
||||||
|
Mcu.Pin8=PE13
|
||||||
|
Mcu.Pin9=PE14
|
||||||
|
Mcu.PinsNb=32
|
||||||
Mcu.ThirdPartyNb=0
|
Mcu.ThirdPartyNb=0
|
||||||
Mcu.UserConstants=
|
Mcu.UserConstants=
|
||||||
Mcu.UserName=STM32F407VGTx
|
Mcu.UserName=STM32F407VGTx
|
||||||
@@ -32,7 +75,6 @@ MxCube.Version=6.12.1
|
|||||||
MxDb.Version=DB.6.0.121
|
MxDb.Version=DB.6.0.121
|
||||||
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||||
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||||
NVIC.EXTI0_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
|
||||||
NVIC.ForceEnableDMAVector=true
|
NVIC.ForceEnableDMAVector=true
|
||||||
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||||
NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||||
@@ -43,7 +85,44 @@ NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
|||||||
NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:false
|
NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:false
|
||||||
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||||
PA0-WKUP.Locked=true
|
PA0-WKUP.Locked=true
|
||||||
PA0-WKUP.Signal=GPXTI0
|
PA0-WKUP.Signal=GPIO_Input
|
||||||
|
PA15.Locked=true
|
||||||
|
PA15.Signal=GPIO_Input
|
||||||
|
PA5.Mode=Full_Duplex_Master
|
||||||
|
PA5.Signal=SPI1_SCK
|
||||||
|
PB1.Locked=true
|
||||||
|
PB1.Signal=ADCx_IN9
|
||||||
|
PB10.Locked=true
|
||||||
|
PB10.Mode=Half_Duplex_Master
|
||||||
|
PB10.Signal=I2S2_CK
|
||||||
|
PB12.Mode=Half_Duplex_Master
|
||||||
|
PB12.Signal=I2S2_WS
|
||||||
|
PB4.Locked=true
|
||||||
|
PB4.Mode=Full_Duplex_Master
|
||||||
|
PB4.Signal=SPI1_MISO
|
||||||
|
PB5.Locked=true
|
||||||
|
PB5.Mode=Full_Duplex_Master
|
||||||
|
PB5.Signal=SPI1_MOSI
|
||||||
|
PB6.Mode=I2C
|
||||||
|
PB6.Signal=I2C1_SCL
|
||||||
|
PB7.Locked=true
|
||||||
|
PB7.Signal=GPIO_Output
|
||||||
|
PB9.Locked=true
|
||||||
|
PB9.Mode=I2C
|
||||||
|
PB9.Signal=I2C1_SDA
|
||||||
|
PC11.Locked=true
|
||||||
|
PC11.Signal=GPIO_Input
|
||||||
|
PC3.Locked=true
|
||||||
|
PC3.Mode=Half_Duplex_Master
|
||||||
|
PC3.Signal=I2S2_SD
|
||||||
|
PC6.Locked=true
|
||||||
|
PC6.Signal=GPIO_Input
|
||||||
|
PC8.Locked=true
|
||||||
|
PC8.Signal=GPIO_Input
|
||||||
|
PC9.Locked=true
|
||||||
|
PC9.Signal=GPIO_Input
|
||||||
|
PD11.Locked=true
|
||||||
|
PD11.Signal=GPIO_Output
|
||||||
PD12.Locked=true
|
PD12.Locked=true
|
||||||
PD12.Signal=GPIO_Output
|
PD12.Signal=GPIO_Output
|
||||||
PD13.Locked=true
|
PD13.Locked=true
|
||||||
@@ -52,6 +131,10 @@ PD14.Locked=true
|
|||||||
PD14.Signal=GPIO_Output
|
PD14.Signal=GPIO_Output
|
||||||
PD15.Locked=true
|
PD15.Locked=true
|
||||||
PD15.Signal=GPIO_Output
|
PD15.Signal=GPIO_Output
|
||||||
|
PD4.Locked=true
|
||||||
|
PD4.Signal=GPIO_Output
|
||||||
|
PD7.Locked=true
|
||||||
|
PD7.Signal=GPIO_Output
|
||||||
PE10.Locked=true
|
PE10.Locked=true
|
||||||
PE10.Signal=GPIO_Output
|
PE10.Signal=GPIO_Output
|
||||||
PE11.Locked=true
|
PE11.Locked=true
|
||||||
@@ -97,7 +180,7 @@ ProjectManager.ToolChainLocation=
|
|||||||
ProjectManager.UAScriptAfterPath=
|
ProjectManager.UAScriptAfterPath=
|
||||||
ProjectManager.UAScriptBeforePath=
|
ProjectManager.UAScriptBeforePath=
|
||||||
ProjectManager.UnderRoot=true
|
ProjectManager.UnderRoot=true
|
||||||
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true
|
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_ADC1_Init-ADC1-false-HAL-true,4-MX_I2C1_Init-I2C1-false-HAL-true,5-MX_SPI1_Init-SPI1-false-HAL-true,6-MX_TIM2_Init-TIM2-false-HAL-true,7-MX_I2S2_Init-I2S2-false-HAL-true
|
||||||
RCC.AHBFreq_Value=16000000
|
RCC.AHBFreq_Value=16000000
|
||||||
RCC.APB1Freq_Value=16000000
|
RCC.APB1Freq_Value=16000000
|
||||||
RCC.APB1TimFreq_Value=16000000
|
RCC.APB1TimFreq_Value=16000000
|
||||||
@@ -124,7 +207,19 @@ RCC.VCOI2SOutputFreq_Value=192000000
|
|||||||
RCC.VCOInputFreq_Value=1000000
|
RCC.VCOInputFreq_Value=1000000
|
||||||
RCC.VCOOutputFreq_Value=192000000
|
RCC.VCOOutputFreq_Value=192000000
|
||||||
RCC.VcooutputI2S=96000000
|
RCC.VcooutputI2S=96000000
|
||||||
SH.GPXTI0.0=GPIO_EXTI0
|
SH.ADCx_IN9.0=ADC1_IN9,IN9
|
||||||
SH.GPXTI0.ConfNb=1
|
SH.ADCx_IN9.ConfNb=1
|
||||||
|
SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_16
|
||||||
|
SPI1.CalculateBaudRate=1000.0 KBits/s
|
||||||
|
SPI1.Direction=SPI_DIRECTION_2LINES
|
||||||
|
SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler
|
||||||
|
SPI1.Mode=SPI_MODE_MASTER
|
||||||
|
SPI1.VirtualType=VM_MASTER
|
||||||
|
TIM2.IPParameters=Period
|
||||||
|
TIM2.Period=0xffffffff
|
||||||
|
VP_SYS_VS_Systick.Mode=SysTick
|
||||||
|
VP_SYS_VS_Systick.Signal=SYS_VS_Systick
|
||||||
|
VP_TIM2_VS_ClockSourceINT.Mode=Internal
|
||||||
|
VP_TIM2_VS_ClockSourceINT.Signal=TIM2_VS_ClockSourceINT
|
||||||
board=custom
|
board=custom
|
||||||
isbadioc=false
|
isbadioc=false
|
||||||
|
|||||||
Reference in New Issue
Block a user