mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/CAN-Demo.git
synced 2025-06-10 02:55:59 +00:00
chore: Cleanup for Demo
This commit is contained in:
parent
fd7c123a5e
commit
1f6c939630
14
.cproject
14
.cproject
@ -25,6 +25,7 @@
|
|||||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.1158949736" 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.1158949736" 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.251996276" 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 || STM32F407ZGTx || 0 || 0 || arm-none-eabi- || ${gnu_tools_for_stm32_compiler_path} || ../Drivers/CMSIS/Include | ../Core/Inc | ../Drivers/STM32F4xx_HAL_Driver/Inc | ../Drivers/CMSIS/Device/ST/STM32F4xx/Include | ../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy | ../Middlewares/Third_Party/FreeRTOS/Source/include | ../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 | ../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F || || || USE_HAL_DRIVER | STM32F407xx || || Drivers | Core/Startup | Middlewares | Core || || || ${workspace_loc:/${ProjName}/STM32F407ZGTX_FLASH.ld} || true || NonSecure || || secure_nsclib.o || || None || || || " valueType="string"/>
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.251996276" 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 || STM32F407ZGTx || 0 || 0 || arm-none-eabi- || ${gnu_tools_for_stm32_compiler_path} || ../Drivers/CMSIS/Include | ../Core/Inc | ../Drivers/STM32F4xx_HAL_Driver/Inc | ../Drivers/CMSIS/Device/ST/STM32F4xx/Include | ../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy | ../Middlewares/Third_Party/FreeRTOS/Source/include | ../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 | ../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F || || || USE_HAL_DRIVER | STM32F407xx || || Drivers | Core/Startup | Middlewares | Core || || || ${workspace_loc:/${ProjName}/STM32F407ZGTX_FLASH.ld} || true || NonSecure || || secure_nsclib.o || || None || || || " valueType="string"/>
|
||||||
<option id="com.st.stm32cube.ide.mcu.debug.option.cpuclock.176912155" name="Cpu clock frequence" 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.176912155" name="Cpu clock frequence" superClass="com.st.stm32cube.ide.mcu.debug.option.cpuclock" useByScannerDiscovery="false" value="16" valueType="string"/>
|
||||||
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.nanoprintffloat.1995567269" name="Use float with printf from newlib-nano (-u _printf_float)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.nanoprintffloat" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||||
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform.1003279050" 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.1003279050" isAbstract="false" osList="all" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform"/>
|
||||||
<builder buildPath="${workspace_loc:/CAN-Demo}/Debug" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder.1347089105" 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:/CAN-Demo}/Debug" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder.1347089105" 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.683567819" name="MCU GCC Assembler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler">
|
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.683567819" name="MCU GCC Assembler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler">
|
||||||
@ -32,6 +33,9 @@
|
|||||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.definedsymbols.841867041" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.definedsymbols" valueType="definedSymbols">
|
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.definedsymbols.841867041" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.definedsymbols" valueType="definedSymbols">
|
||||||
<listOptionValue builtIn="false" value="DEBUG"/>
|
<listOptionValue builtIn="false" value="DEBUG"/>
|
||||||
</option>
|
</option>
|
||||||
|
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.includepaths.1573230255" name="Include paths (-I)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.includepaths" valueType="includePath">
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/Libs/rtos2-utils/include}""/>
|
||||||
|
</option>
|
||||||
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input.518850245" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input"/>
|
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input.518850245" 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.1024353098" name="MCU 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.1024353098" name="MCU GCC Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler">
|
||||||
@ -55,8 +59,6 @@
|
|||||||
<listOptionValue builtIn="false" value="../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F"/>
|
<listOptionValue builtIn="false" value="../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F"/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/CAN-Demo/Libs/rtos2-utils/include}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/CAN-Demo/Libs/rtos2-utils/include}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/Libs/TACOS/include}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/Libs/TACOS/include}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/Libs/isotp/include}""/>
|
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/Libs/driver-max31855}""/>
|
|
||||||
</option>
|
</option>
|
||||||
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.1002361924" 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.1002361924" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c"/>
|
||||||
</tool>
|
</tool>
|
||||||
@ -74,11 +76,8 @@
|
|||||||
<listOptionValue builtIn="false" value="../Middlewares/Third_Party/FreeRTOS/Source/include"/>
|
<listOptionValue builtIn="false" value="../Middlewares/Third_Party/FreeRTOS/Source/include"/>
|
||||||
<listOptionValue builtIn="false" value="../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2"/>
|
<listOptionValue builtIn="false" value="../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2"/>
|
||||||
<listOptionValue builtIn="false" value="../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F"/>
|
<listOptionValue builtIn="false" value="../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F"/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/CAN-Demo/App/Inc/sta}""/>
|
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/CAN-Demo/Libs/rtos2-utils/include}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/CAN-Demo/Libs/rtos2-utils/include}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/Libs/TACOS/include}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/Libs/TACOS/include}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/Libs/isotp/include}""/>
|
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/Libs/driver-max31855/include}""/>
|
|
||||||
</option>
|
</option>
|
||||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.definedsymbols.2087867384" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.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.cpp.compiler.option.definedsymbols.2087867384" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.definedsymbols" useByScannerDiscovery="false" valueType="definedSymbols">
|
||||||
<listOptionValue builtIn="false" value="DEBUG"/>
|
<listOptionValue builtIn="false" value="DEBUG"/>
|
||||||
@ -151,6 +150,9 @@
|
|||||||
<builder buildPath="${workspace_loc:/CAN-Demo}/Release" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder.1494703573" 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:/CAN-Demo}/Release" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder.1494703573" 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.1960775626" name="MCU GCC Assembler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler">
|
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.1960775626" name="MCU 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.402807907" 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"/>
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.402807907" 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"/>
|
||||||
|
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.includepaths.1535900856" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.includepaths" valueType="includePath">
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/Libs/rtos2-utils/include}""/>
|
||||||
|
</option>
|
||||||
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input.1699164445" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input"/>
|
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input.1699164445" 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.1012149180" name="MCU 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.1012149180" name="MCU GCC Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler">
|
||||||
@ -169,6 +171,7 @@
|
|||||||
<listOptionValue builtIn="false" value="../Middlewares/Third_Party/FreeRTOS/Source/include"/>
|
<listOptionValue builtIn="false" value="../Middlewares/Third_Party/FreeRTOS/Source/include"/>
|
||||||
<listOptionValue builtIn="false" value="../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2"/>
|
<listOptionValue builtIn="false" value="../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2"/>
|
||||||
<listOptionValue builtIn="false" value="../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F"/>
|
<listOptionValue builtIn="false" value="../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F"/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/Libs/rtos2-utils/include}""/>
|
||||||
</option>
|
</option>
|
||||||
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.1300905399" 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.1300905399" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c"/>
|
||||||
</tool>
|
</tool>
|
||||||
@ -184,6 +187,7 @@
|
|||||||
<listOptionValue builtIn="false" value="../Middlewares/Third_Party/FreeRTOS/Source/include"/>
|
<listOptionValue builtIn="false" value="../Middlewares/Third_Party/FreeRTOS/Source/include"/>
|
||||||
<listOptionValue builtIn="false" value="../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2"/>
|
<listOptionValue builtIn="false" value="../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2"/>
|
||||||
<listOptionValue builtIn="false" value="../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F"/>
|
<listOptionValue builtIn="false" value="../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F"/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/Libs/rtos2-utils/include}""/>
|
||||||
</option>
|
</option>
|
||||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.definedsymbols.353350306" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.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.cpp.compiler.option.definedsymbols.353350306" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.definedsymbols" useByScannerDiscovery="false" valueType="definedSymbols">
|
||||||
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
|
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
|
||||||
|
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -9,6 +9,3 @@
|
|||||||
[submodule "Libs/TACOS"]
|
[submodule "Libs/TACOS"]
|
||||||
path = Libs/TACOS
|
path = Libs/TACOS
|
||||||
url = ssh://git@git.intern.spaceteamaachen.de:22222/ALPAKA/TACOS.git
|
url = ssh://git@git.intern.spaceteamaachen.de:22222/ALPAKA/TACOS.git
|
||||||
[submodule "Libs/driver-max31855"]
|
|
||||||
path = Libs/driver-max31855
|
|
||||||
url = ssh://git@git.intern.spaceteamaachen.de:22222/ALPAKA/driver-max31855.git
|
|
||||||
|
46
.mxproject
46
.mxproject
File diff suppressed because one or more lines are too long
@ -5,7 +5,7 @@
|
|||||||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-614993993494983921" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="933752790054406879" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||||
</provider>
|
</provider>
|
||||||
@ -16,7 +16,7 @@
|
|||||||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-614993993494983921" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="933752790054406879" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||||
</provider>
|
</provider>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
|
2F62501ED4689FB349E356AB974DBE57=84EF3C290D485BA5E95DA5C0811FD966
|
||||||
635E684B79701B039C64EA45C3F84D30=44DBEC1DE4EBA9B0485911FBE58BFC80
|
635E684B79701B039C64EA45C3F84D30=44DBEC1DE4EBA9B0485911FBE58BFC80
|
||||||
66BE74F758C12D739921AEA421D593D3=3
|
66BE74F758C12D739921AEA421D593D3=3
|
||||||
8DF89ED150041C4CBC7CB9A9CAA90856=7B5B92F1162457C6ECACD202698061B0
|
8DF89ED150041C4CBC7CB9A9CAA90856=84EF3C290D485BA5E95DA5C0811FD966
|
||||||
DC22A860405A8BF2F2C095E5B6529F12=7B5B92F1162457C6ECACD202698061B0
|
DC22A860405A8BF2F2C095E5B6529F12=895712FC628DF9D0138664104150017E
|
||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
|
BIN
App/.DS_Store
vendored
BIN
App/.DS_Store
vendored
Binary file not shown.
BIN
App/Inc/.DS_Store
vendored
BIN
App/Inc/.DS_Store
vendored
Binary file not shown.
@ -8,7 +8,7 @@
|
|||||||
#ifndef INC_STA_CONFIG_HPP_
|
#ifndef INC_STA_CONFIG_HPP_
|
||||||
#define INC_STA_CONFIG_HPP_
|
#define INC_STA_CONFIG_HPP_
|
||||||
|
|
||||||
#define STA_STM32_ASEAG
|
#define STA_STM32_ASEAG // This is a define that we are using our own PCB layout called ASEAG
|
||||||
#include <sta/devices/stm32/mcu/STM32F407xx.hpp>
|
#include <sta/devices/stm32/mcu/STM32F407xx.hpp>
|
||||||
|
|
||||||
// Doesn't really do too much right now. Has to be added for successful compilation.
|
// Doesn't really do too much right now. Has to be added for successful compilation.
|
||||||
@ -21,14 +21,12 @@
|
|||||||
#define STA_ASSERT_FORCE
|
#define STA_ASSERT_FORCE
|
||||||
#define STA_DEBUGGING_ENABLED
|
#define STA_DEBUGGING_ENABLED
|
||||||
|
|
||||||
// Activate the timer for microsecond delays.
|
|
||||||
// #define STA_STM32_DELAY_ENABLE
|
|
||||||
// #define STA_STM32_DELAY_US_TIM htim1
|
|
||||||
|
|
||||||
// Settings for the rtos-utils
|
// Settings for the rtos-utils
|
||||||
#define STA_RTOS_SYSTEM_EVENTS_ENABLE
|
#define STA_RTOS_SYSTEM_EVENTS_ENABLE
|
||||||
// #define STA_RTOS_SYSTEM_WATCHDOG_ENABLE
|
#define STA_TACOS_CAN_BUS_ENABLED
|
||||||
// #define STA_RTOS_WATCHDOG_ENABLE
|
|
||||||
|
// Enable CAN for sta core
|
||||||
#define STA_CAN_BUS_ENABLE
|
#define STA_CAN_BUS_ENABLE
|
||||||
|
|
||||||
// Uses the default configuration for TACOS.
|
// Uses the default configuration for TACOS.
|
||||||
|
BIN
App/Inc/tasks/.DS_Store
vendored
Normal file
BIN
App/Inc/tasks/.DS_Store
vendored
Normal file
Binary file not shown.
26
App/Inc/tasks/can_receiver.hpp
Normal file
26
App/Inc/tasks/can_receiver.hpp
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* can_spam.hpp
|
||||||
|
*
|
||||||
|
* Created on: 10 Dec 2023
|
||||||
|
* Author: Carl
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef INC_TASKS_CAN_RECEIVER_TASK_HPP_
|
||||||
|
#define INC_TASKS_CAN_RECEIVER_TASK_HPP_
|
||||||
|
|
||||||
|
#include <sta/tacos.hpp>
|
||||||
|
|
||||||
|
namespace demo
|
||||||
|
{
|
||||||
|
class CanReceiver : public sta::tacos::TacosThread {
|
||||||
|
public:
|
||||||
|
CanReceiver(uint32_t canID);
|
||||||
|
|
||||||
|
void init() override;
|
||||||
|
|
||||||
|
void func() override;
|
||||||
|
private:
|
||||||
|
};
|
||||||
|
} // namespace demo
|
||||||
|
|
||||||
|
#endif /* INC_TASKS_CAN_RECEIVER_TASK_HPP_ */
|
26
App/Inc/tasks/can_spam.hpp
Normal file
26
App/Inc/tasks/can_spam.hpp
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* can_spam.hpp
|
||||||
|
*
|
||||||
|
* Created on: 10 Dec 2023
|
||||||
|
* Author: Carl
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef INC_TASKS_CAN_SPAM_TASK_HPP_
|
||||||
|
#define INC_TASKS_CAN_SPAM_TASK_HPP_
|
||||||
|
|
||||||
|
#include <sta/tacos.hpp>
|
||||||
|
|
||||||
|
namespace demo
|
||||||
|
{
|
||||||
|
class CanSpam : public sta::tacos::TacosThread {
|
||||||
|
public:
|
||||||
|
CanSpam(uint32_t canID);
|
||||||
|
|
||||||
|
void init() override;
|
||||||
|
|
||||||
|
void func() override;
|
||||||
|
private:
|
||||||
|
};
|
||||||
|
} // namespace demo
|
||||||
|
|
||||||
|
#endif /* INC_TASKS_CAN_SPAM_TASK_HPP_ */
|
@ -1,27 +0,0 @@
|
|||||||
/*
|
|
||||||
* can_task.hpp
|
|
||||||
*
|
|
||||||
* Created on: 10 Dec 2023
|
|
||||||
* Author: Carl
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef INC_TASKS_CANTASK_HPP_
|
|
||||||
#define INC_TASKS_CANTASK_HPP_
|
|
||||||
|
|
||||||
#include <sta/tacos/thread.hpp>
|
|
||||||
#include <sta/devices/stm32/can.hpp>
|
|
||||||
|
|
||||||
namespace demo
|
|
||||||
{
|
|
||||||
class CanTask : public sta::tacos::TacosThread {
|
|
||||||
public:
|
|
||||||
CanTask(const char* name, uint32_t canID);
|
|
||||||
|
|
||||||
void init() override;
|
|
||||||
|
|
||||||
void func() override;
|
|
||||||
private:
|
|
||||||
};
|
|
||||||
} // namespace demo
|
|
||||||
|
|
||||||
#endif /* INC_TASKS_CANTASK_HPP_ */
|
|
@ -1,41 +0,0 @@
|
|||||||
/*
|
|
||||||
* can_task.hpp
|
|
||||||
*
|
|
||||||
* Created on: 10 Dec 2023
|
|
||||||
* Author: Carl
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef INC_TASKS_THERMO_HPP_
|
|
||||||
#define INC_TASKS_THERMO_HPP_
|
|
||||||
|
|
||||||
#include <sta/tacos/thread.hpp>
|
|
||||||
#include <sta/devices/stm32/can.hpp>
|
|
||||||
#include <sta/rtos/mutex.hpp>
|
|
||||||
#include <sta/MAX31855.hpp>
|
|
||||||
#include <sta/devices/stm32/bus/spi.hpp>
|
|
||||||
#include <gpio.h>
|
|
||||||
#include <spi.h>
|
|
||||||
|
|
||||||
namespace demo
|
|
||||||
{
|
|
||||||
class ThermoTask : public sta::tacos::TacosThread {
|
|
||||||
public:
|
|
||||||
ThermoTask();
|
|
||||||
|
|
||||||
void init() override;
|
|
||||||
|
|
||||||
void func() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
sta::STM32GpioPin cs_pin = sta::STM32GpioPin(GPIOE, GPIO_PIN_13);
|
|
||||||
sta::RtosMutex* mutex;
|
|
||||||
sta::STM32SPI* spi2;
|
|
||||||
sta::STM32SPIDevice* device_;
|
|
||||||
|
|
||||||
sta::MAX31855* tc;
|
|
||||||
|
|
||||||
};
|
|
||||||
} // namespace demo
|
|
||||||
|
|
||||||
#endif /* INC_TASKS_THERMO_HPP_ */
|
|
@ -1,13 +0,0 @@
|
|||||||
/*
|
|
||||||
* test.hpp
|
|
||||||
*
|
|
||||||
* Created on: Oct 24, 2023
|
|
||||||
* Author: carlw
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef INC_TEST_HPP_
|
|
||||||
#define INC_TEST_HPP_
|
|
||||||
|
|
||||||
//void testCan(CAN_HandleTypeDef * handle);
|
|
||||||
|
|
||||||
#endif /* INC_TEST_HPP_ */
|
|
BIN
App/Src/.DS_Store
vendored
Normal file
BIN
App/Src/.DS_Store
vendored
Normal file
Binary file not shown.
@ -5,19 +5,9 @@
|
|||||||
* Author: Dario
|
* Author: Dario
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sta/debug/debug.hpp>
|
|
||||||
#include <tasks/can_task.hpp>
|
|
||||||
#include <tasks/thermo.hpp>
|
|
||||||
#include <sta/devices/stm32/gpio_pin.hpp>
|
|
||||||
#include <sta/rtos/debug/heap_stats.hpp>
|
|
||||||
|
|
||||||
#include <sta/tacos.hpp>
|
#include <sta/tacos.hpp>
|
||||||
|
#include <tasks/can_spam.hpp>
|
||||||
|
#include <tasks/can_receiver.hpp>
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
extern CAN_HandleTypeDef hcan1;
|
|
||||||
|
|
||||||
namespace sta
|
namespace sta
|
||||||
{
|
{
|
||||||
namespace tacos
|
namespace tacos
|
||||||
@ -31,12 +21,13 @@ namespace sta
|
|||||||
{
|
{
|
||||||
// ###### Register different threads for different states here. ######
|
// ###### Register different threads for different states here. ######
|
||||||
|
|
||||||
// The dummy task runs for state 0.
|
// Register Spam Thread to only run in the first state
|
||||||
Manager::instance()->registerThread(std::make_shared<demo::CanTask>("CAN test", 0x123), {ALL_STATES});
|
addThread<demo::CanSpam>({ALL_STATES}, 0x123);
|
||||||
|
// Register Receive Thread to run in states 0 and 2
|
||||||
|
addThread<demo::CanReceiver>({0,2}, 0x124);
|
||||||
|
|
||||||
|
|
||||||
STA_DEBUG_PRINTF("The answer to everything is %d", 42);
|
STA_DEBUG_PRINTF("The answer to everything is %d", 42);
|
||||||
|
|
||||||
STA_DEBUG_HEAP_STATS();
|
|
||||||
}
|
}
|
||||||
} // namespace tacos
|
} // namespace tacos
|
||||||
} // namespace sta
|
} // namespace sta
|
||||||
|
BIN
App/Src/tasks/.DS_Store
vendored
Normal file
BIN
App/Src/tasks/.DS_Store
vendored
Normal file
Binary file not shown.
45
App/Src/tasks/can_receiver.cpp
Normal file
45
App/Src/tasks/can_receiver.cpp
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* can_task.cpp
|
||||||
|
*
|
||||||
|
* Created on: 10 Dec 2023
|
||||||
|
* Author: Carl
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sta/tacos.hpp>
|
||||||
|
#include <tasks/can_receiver.hpp>
|
||||||
|
|
||||||
|
namespace demo
|
||||||
|
{
|
||||||
|
CanReceiver::CanReceiver(uint32_t canID)
|
||||||
|
: TacosThread("CAN Receiver", osPriorityNormal)
|
||||||
|
{
|
||||||
|
setCanID(canID);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CanReceiver::init()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CanReceiver::func()
|
||||||
|
{
|
||||||
|
CanSysMsg msg;
|
||||||
|
|
||||||
|
if (CAN_queue_.get(&msg, osWaitForever))
|
||||||
|
{
|
||||||
|
STA_DEBUG_PRINTF("Received Message!\n"
|
||||||
|
"Payload Byte 0: %d\n"
|
||||||
|
"Payload Byte 1: %d\n"
|
||||||
|
"Payload Byte 2: %d\n"
|
||||||
|
"Payload Byte 3: %d\n"
|
||||||
|
"Payload Byte 4: %d\n"
|
||||||
|
"Payload Byte 5: %d\n"
|
||||||
|
"Payload Byte 6: %d\n"
|
||||||
|
"Payload Byte 7: %d\n",
|
||||||
|
msg.payload[0], msg.payload[1],
|
||||||
|
msg.payload[2], msg.payload[3],
|
||||||
|
msg.payload[4], msg.payload[5],
|
||||||
|
msg.payload[6], msg.payload[7]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // namespace demo
|
||||||
|
|
41
App/Src/tasks/can_spam.cpp
Normal file
41
App/Src/tasks/can_spam.cpp
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* can_task.cpp
|
||||||
|
*
|
||||||
|
* Created on: 10 Dec 2023
|
||||||
|
* Author: Carl
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sta/tacos.hpp>
|
||||||
|
#include <tasks/can_spam.hpp>
|
||||||
|
|
||||||
|
namespace demo
|
||||||
|
{
|
||||||
|
CanSpam::CanSpam(uint32_t canID)
|
||||||
|
: TacosThread("CAN Spam", osPriorityNormal)
|
||||||
|
{
|
||||||
|
setCanID(canID);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CanSpam::init()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CanSpam::func()
|
||||||
|
{
|
||||||
|
|
||||||
|
CanSysMsg msg;
|
||||||
|
|
||||||
|
// Send some random stuff
|
||||||
|
msg.payload[0] = 1;
|
||||||
|
msg.payload[1] = 2;
|
||||||
|
msg.payload[2] = 3;
|
||||||
|
msg.header.sid = getCanID();
|
||||||
|
msg.header.format = 0;
|
||||||
|
|
||||||
|
sta::tacos::queueCanBusMsg(msg, 0);
|
||||||
|
STA_DEBUG_PRINTLN("Can Task sent message");
|
||||||
|
|
||||||
|
this->periodicDelay(1); // Delay to ensure 1 Hz rate.
|
||||||
|
}
|
||||||
|
} // namespace demo
|
||||||
|
|
@ -1,51 +0,0 @@
|
|||||||
/*
|
|
||||||
* can_task.cpp
|
|
||||||
*
|
|
||||||
* Created on: 10 Dec 2023
|
|
||||||
* Author: Carl
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <tasks/can_task.hpp>
|
|
||||||
#include <sta/debug/debug.hpp>
|
|
||||||
#include <sta/rtos/debug/heap_stats.hpp>
|
|
||||||
#include "can.h"
|
|
||||||
#include <sta/tacos.hpp>
|
|
||||||
|
|
||||||
#include <cmsis_os2.h>
|
|
||||||
|
|
||||||
namespace demo
|
|
||||||
{
|
|
||||||
CanTask::CanTask(const char* name, uint32_t canID)
|
|
||||||
: TacosThread(name, osPriorityNormal)
|
|
||||||
{
|
|
||||||
setCanID(canID);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CanTask::init()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void CanTask::func()
|
|
||||||
{
|
|
||||||
//STA_DEBUG_PRINTLN("Can Task awaiting message");
|
|
||||||
if (CAN_queue_.available() > 0)
|
|
||||||
{
|
|
||||||
// Receiving message
|
|
||||||
CanSysMsg msg;
|
|
||||||
CAN_queue_.get(&msg);
|
|
||||||
STA_DEBUG_PRINTLN("Can Task received message");
|
|
||||||
|
|
||||||
// Sending it back with one changed bit
|
|
||||||
msg.payload[1] = 3;
|
|
||||||
msg.header.sid = getCanID();
|
|
||||||
msg.header.eid = 0;
|
|
||||||
msg.header.format = 0;
|
|
||||||
|
|
||||||
sta::tacos::queueCanBusMsg(msg, 0);
|
|
||||||
STA_DEBUG_PRINTLN("Can Task sent message");
|
|
||||||
|
|
||||||
HAL_Delay(500);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} // namespace demo
|
|
||||||
|
|
@ -1,58 +0,0 @@
|
|||||||
/*
|
|
||||||
* can_task.cpp
|
|
||||||
*
|
|
||||||
* Created on: 10 Dec 2023
|
|
||||||
* Author: Carl
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <tasks/thermo.hpp>
|
|
||||||
#include <sta/debug/debug.hpp>
|
|
||||||
#include <sta/rtos/debug/heap_stats.hpp>
|
|
||||||
#include <gpio.h>
|
|
||||||
#include <spi.h>
|
|
||||||
#include <sta/MAX31855.hpp>
|
|
||||||
#include <sta/devices/stm32/bus/spi.hpp>
|
|
||||||
|
|
||||||
#include <sta/rtos/mutex.hpp>
|
|
||||||
|
|
||||||
#include <cmsis_os2.h>
|
|
||||||
|
|
||||||
namespace demo
|
|
||||||
{
|
|
||||||
ThermoTask::ThermoTask()
|
|
||||||
: TacosThread("Thermo", osPriorityNormal)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void ThermoTask::init()
|
|
||||||
{
|
|
||||||
mutex = new sta::RtosMutex("spi2");
|
|
||||||
spi2 = new sta::STM32SPI(&hspi2, 16000000, mutex);
|
|
||||||
device_ = new sta::STM32SPIDevice(spi2, &cs_pin);
|
|
||||||
|
|
||||||
tc = new sta::MAX31855(device_); //create driver object
|
|
||||||
}
|
|
||||||
|
|
||||||
void ThermoTask::func()
|
|
||||||
{
|
|
||||||
//STA_DEBUG_HEAP_STATS();
|
|
||||||
//canController.sendFrame(txHeader, payload);
|
|
||||||
//STA_DEBUG_HEAP_STATS();
|
|
||||||
|
|
||||||
//fuck off other pins
|
|
||||||
HAL_GPIO_WritePin(GPIOE,GPIO_PIN_12, GPIO_PIN_SET);
|
|
||||||
HAL_GPIO_WritePin(GPIOB,GPIO_PIN_10, GPIO_PIN_SET);
|
|
||||||
HAL_GPIO_WritePin(GPIOE,GPIO_PIN_15, GPIO_PIN_SET);
|
|
||||||
HAL_GPIO_WritePin(GPIOE,GPIO_PIN_14, GPIO_PIN_SET);
|
|
||||||
|
|
||||||
tc->update(); // update internal values
|
|
||||||
float temperature = tc->getTemp(); //read out temperature in degrees Celsius
|
|
||||||
float referenceTemperature = tc->getReferenceTemp(); // read out reference temperature in degrees Celsius
|
|
||||||
uint8_t status = tc->getStatus(); //read out status of the update
|
|
||||||
|
|
||||||
HAL_Delay(1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace demo
|
|
||||||
|
|
@ -1,72 +0,0 @@
|
|||||||
/*
|
|
||||||
* test.cpp
|
|
||||||
*
|
|
||||||
* Created on: Oct 24, 2023
|
|
||||||
* Author: carlw
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
//#include <sta/bus/can/controller.hpp>
|
|
||||||
#include <sta/devices/stm32/can.hpp>
|
|
||||||
|
|
||||||
//extern STM32CanController(CAN_HandleTypeDef * handle);
|
|
||||||
|
|
||||||
|
|
||||||
extern "C" void testCan(CAN_HandleTypeDef * handle){
|
|
||||||
|
|
||||||
sta::STM32CanController canController(handle);
|
|
||||||
|
|
||||||
canController.start();
|
|
||||||
|
|
||||||
// Create a CanTxHeader for your message
|
|
||||||
sta::CanTxHeader txHeader;
|
|
||||||
txHeader.id.format = sta::CanIdFormat::STD; // Set to EXT for extended ID
|
|
||||||
txHeader.id.sid = 0x010; // Set the standard ID or extended ID
|
|
||||||
txHeader.payloadLength = 8; // Set the payload length (max 8 bytes)
|
|
||||||
|
|
||||||
// Create your message payload
|
|
||||||
uint8_t payload[8] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
|
|
||||||
|
|
||||||
// Send the CAN message
|
|
||||||
while (true){
|
|
||||||
canController.sendFrame(txHeader, payload);
|
|
||||||
HAL_Delay(1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" void testCanMsg(CAN_HandleTypeDef * handle, uint8_t payload[8]){
|
|
||||||
|
|
||||||
sta::STM32CanController canController(handle);
|
|
||||||
|
|
||||||
//canController.start();
|
|
||||||
|
|
||||||
// Create a CanTxHeader for your message
|
|
||||||
sta::CanTxHeader txHeader;
|
|
||||||
txHeader.id.format = sta::CanIdFormat::STD; // Set to EXT for extended ID
|
|
||||||
txHeader.id.sid = 0x030; // Set the standard ID or extended ID
|
|
||||||
txHeader.payloadLength = 8; // Set the payload length (max 8 bytes)
|
|
||||||
|
|
||||||
// Send the CAN message
|
|
||||||
canController.sendFrame(txHeader, payload);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" void unpackValues(uint8_t packedByte, uint8_t* type_id, uint8_t* sensor_ID, uint8_t* value, uint8_t* include) {
|
|
||||||
*type_id = (packedByte >> 6) & 0x03; // Extracting two bits for type_id
|
|
||||||
*sensor_ID = (packedByte >> 3) & 0x07; // Extracting three bits for sensorID
|
|
||||||
*include = (packedByte >> 2) & 0x01; // Extracting the flag for included value
|
|
||||||
*value = (packedByte >> 1) & 0x01; // Extracting one bit for value
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" uint8_t packValues(uint8_t type_id, uint8_t sensor_ID, uint8_t value, uint8_t include) {
|
|
||||||
uint8_t packedByte = 0;
|
|
||||||
|
|
||||||
// Shifting and ORing the values
|
|
||||||
packedByte |= (type_id & 0x03) << 6; // Two bits for type_id, left-shifted by 6
|
|
||||||
packedByte |= (sensor_ID & 0x07) << 3; // Three bits for sensorID, left-shifted by 3
|
|
||||||
packedByte |= (include & 0x01) << 2; // Flag for included value
|
|
||||||
packedByte |= (value & 0x01) << 1; // One bit for value
|
|
||||||
|
|
||||||
return packedByte;
|
|
||||||
}*/
|
|
101
CAN-Demo.ioc
101
CAN-Demo.ioc
@ -28,50 +28,37 @@ Mcu.IP0=CAN1
|
|||||||
Mcu.IP1=FREERTOS
|
Mcu.IP1=FREERTOS
|
||||||
Mcu.IP2=NVIC
|
Mcu.IP2=NVIC
|
||||||
Mcu.IP3=RCC
|
Mcu.IP3=RCC
|
||||||
Mcu.IP4=SPI2
|
Mcu.IP4=SYS
|
||||||
Mcu.IP5=SYS
|
Mcu.IP5=USART1
|
||||||
Mcu.IP6=USART1
|
Mcu.IPNb=6
|
||||||
Mcu.IPNb=7
|
|
||||||
Mcu.Name=STM32F407Z(E-G)Tx
|
Mcu.Name=STM32F407Z(E-G)Tx
|
||||||
Mcu.Package=LQFP144
|
Mcu.Package=LQFP144
|
||||||
Mcu.Pin0=PH0-OSC_IN
|
Mcu.Pin0=PH0-OSC_IN
|
||||||
Mcu.Pin1=PH1-OSC_OUT
|
Mcu.Pin1=PH1-OSC_OUT
|
||||||
Mcu.Pin10=PE14
|
Mcu.Pin10=PA15
|
||||||
Mcu.Pin11=PE15
|
Mcu.Pin11=PC10
|
||||||
Mcu.Pin12=PB10
|
Mcu.Pin12=PC11
|
||||||
Mcu.Pin13=PB12
|
Mcu.Pin13=PC12
|
||||||
Mcu.Pin14=PB13
|
Mcu.Pin14=PB3
|
||||||
Mcu.Pin15=PB14
|
Mcu.Pin15=VP_FREERTOS_VS_CMSIS_V2
|
||||||
Mcu.Pin16=PD8
|
Mcu.Pin16=VP_SYS_VS_tim1
|
||||||
Mcu.Pin17=PD9
|
Mcu.Pin2=PB13
|
||||||
Mcu.Pin18=PA9
|
Mcu.Pin3=PB14
|
||||||
Mcu.Pin19=PA10
|
Mcu.Pin4=PA9
|
||||||
Mcu.Pin2=PC3
|
Mcu.Pin5=PA10
|
||||||
Mcu.Pin20=PA11
|
Mcu.Pin6=PA11
|
||||||
Mcu.Pin21=PA12
|
Mcu.Pin7=PA12
|
||||||
Mcu.Pin22=PA13
|
Mcu.Pin8=PA13
|
||||||
Mcu.Pin23=PA14
|
Mcu.Pin9=PA14
|
||||||
Mcu.Pin24=PA15
|
Mcu.PinsNb=17
|
||||||
Mcu.Pin25=PC10
|
|
||||||
Mcu.Pin26=PC11
|
|
||||||
Mcu.Pin27=PC12
|
|
||||||
Mcu.Pin28=PB3
|
|
||||||
Mcu.Pin29=VP_FREERTOS_VS_CMSIS_V2
|
|
||||||
Mcu.Pin3=PA0-WKUP
|
|
||||||
Mcu.Pin30=VP_SYS_VS_tim1
|
|
||||||
Mcu.Pin4=PA1
|
|
||||||
Mcu.Pin5=PA2
|
|
||||||
Mcu.Pin6=PA3
|
|
||||||
Mcu.Pin7=PA6
|
|
||||||
Mcu.Pin8=PE12
|
|
||||||
Mcu.Pin9=PE13
|
|
||||||
Mcu.PinsNb=31
|
|
||||||
Mcu.ThirdPartyNb=0
|
Mcu.ThirdPartyNb=0
|
||||||
Mcu.UserConstants=
|
Mcu.UserConstants=
|
||||||
Mcu.UserName=STM32F407ZGTx
|
Mcu.UserName=STM32F407ZGTx
|
||||||
MxCube.Version=6.10.0
|
MxCube.Version=6.11.1
|
||||||
MxDb.Version=DB.6.0.100
|
MxDb.Version=DB.6.0.111
|
||||||
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
|
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
|
||||||
|
NVIC.CAN1_RX0_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
|
||||||
|
NVIC.CAN1_RX1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
|
||||||
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
|
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
|
||||||
NVIC.ForceEnableDMAVector=true
|
NVIC.ForceEnableDMAVector=true
|
||||||
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
|
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
|
||||||
@ -88,10 +75,6 @@ NVIC.TIM1_UP_TIM10_IRQn=true\:15\:0\:false\:false\:true\:false\:false\:true\:tru
|
|||||||
NVIC.TimeBase=TIM1_UP_TIM10_IRQn
|
NVIC.TimeBase=TIM1_UP_TIM10_IRQn
|
||||||
NVIC.TimeBaseIP=TIM1
|
NVIC.TimeBaseIP=TIM1
|
||||||
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
|
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
|
||||||
PA0-WKUP.Locked=true
|
|
||||||
PA0-WKUP.Signal=GPIO_Output
|
|
||||||
PA1.Locked=true
|
|
||||||
PA1.Signal=GPIO_Output
|
|
||||||
PA10.Mode=Asynchronous
|
PA10.Mode=Asynchronous
|
||||||
PA10.Signal=USART1_RX
|
PA10.Signal=USART1_RX
|
||||||
PA11.Locked=true
|
PA11.Locked=true
|
||||||
@ -106,26 +89,11 @@ PA14.Locked=true
|
|||||||
PA14.Signal=SYS_JTCK-SWCLK
|
PA14.Signal=SYS_JTCK-SWCLK
|
||||||
PA15.Locked=true
|
PA15.Locked=true
|
||||||
PA15.Signal=SYS_JTDI
|
PA15.Signal=SYS_JTDI
|
||||||
PA2.Locked=true
|
|
||||||
PA2.Signal=GPIO_Output
|
|
||||||
PA3.Locked=true
|
|
||||||
PA3.Signal=GPIO_Output
|
|
||||||
PA6.Locked=true
|
|
||||||
PA6.Signal=GPIO_Output
|
|
||||||
PA9.Mode=Asynchronous
|
PA9.Mode=Asynchronous
|
||||||
PA9.Signal=USART1_TX
|
PA9.Signal=USART1_TX
|
||||||
PB10.Locked=true
|
|
||||||
PB10.Signal=GPIO_Output
|
|
||||||
PB12.GPIOParameters=GPIO_Speed,PinState
|
|
||||||
PB12.GPIO_Speed=GPIO_SPEED_FREQ_LOW
|
|
||||||
PB12.Locked=true
|
|
||||||
PB12.PinState=GPIO_PIN_RESET
|
|
||||||
PB12.Signal=GPIO_Output
|
|
||||||
PB13.Locked=true
|
PB13.Locked=true
|
||||||
PB13.Mode=Full_Duplex_Master
|
|
||||||
PB13.Signal=SPI2_SCK
|
PB13.Signal=SPI2_SCK
|
||||||
PB14.Locked=true
|
PB14.Locked=true
|
||||||
PB14.Mode=Full_Duplex_Master
|
|
||||||
PB14.Signal=SPI2_MISO
|
PB14.Signal=SPI2_MISO
|
||||||
PB3.Locked=true
|
PB3.Locked=true
|
||||||
PB3.Signal=SYS_JTDO-SWO
|
PB3.Signal=SYS_JTDO-SWO
|
||||||
@ -135,24 +103,6 @@ PC11.Locked=true
|
|||||||
PC11.Signal=SPI3_MISO
|
PC11.Signal=SPI3_MISO
|
||||||
PC12.Locked=true
|
PC12.Locked=true
|
||||||
PC12.Signal=SPI3_MOSI
|
PC12.Signal=SPI3_MOSI
|
||||||
PC3.Mode=Full_Duplex_Master
|
|
||||||
PC3.Signal=SPI2_MOSI
|
|
||||||
PD8.Locked=true
|
|
||||||
PD8.Signal=GPIO_Output
|
|
||||||
PD9.Locked=true
|
|
||||||
PD9.Signal=GPIO_Output
|
|
||||||
PE12.GPIOParameters=PinState
|
|
||||||
PE12.Locked=true
|
|
||||||
PE12.PinState=GPIO_PIN_SET
|
|
||||||
PE12.Signal=GPIO_Output
|
|
||||||
PE13.GPIOParameters=PinState
|
|
||||||
PE13.Locked=true
|
|
||||||
PE13.PinState=GPIO_PIN_RESET
|
|
||||||
PE13.Signal=GPIO_Output
|
|
||||||
PE14.Locked=true
|
|
||||||
PE14.Signal=GPIO_Output
|
|
||||||
PE15.Locked=true
|
|
||||||
PE15.Signal=GPIO_Output
|
|
||||||
PH0-OSC_IN.Locked=true
|
PH0-OSC_IN.Locked=true
|
||||||
PH0-OSC_IN.Mode=HSE-External-Oscillator
|
PH0-OSC_IN.Mode=HSE-External-Oscillator
|
||||||
PH0-OSC_IN.Signal=RCC_OSC_IN
|
PH0-OSC_IN.Signal=RCC_OSC_IN
|
||||||
@ -223,11 +173,6 @@ RCC.VCOI2SOutputFreq_Value=384000000
|
|||||||
RCC.VCOInputFreq_Value=2000000
|
RCC.VCOInputFreq_Value=2000000
|
||||||
RCC.VCOOutputFreq_Value=128000000
|
RCC.VCOOutputFreq_Value=128000000
|
||||||
RCC.VcooutputI2S=192000000
|
RCC.VcooutputI2S=192000000
|
||||||
SPI2.CalculateBaudRate=8.0 MBits/s
|
|
||||||
SPI2.Direction=SPI_DIRECTION_2LINES
|
|
||||||
SPI2.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate
|
|
||||||
SPI2.Mode=SPI_MODE_MASTER
|
|
||||||
SPI2.VirtualType=VM_MASTER
|
|
||||||
USART1.BaudRate=9600
|
USART1.BaudRate=9600
|
||||||
USART1.IPParameters=VirtualMode,BaudRate
|
USART1.IPParameters=VirtualMode,BaudRate
|
||||||
USART1.VirtualMode=VM_ASYNC
|
USART1.VirtualMode=VM_ASYNC
|
||||||
|
0
Core/Inc/adc.h
Normal file
0
Core/Inc/adc.h
Normal file
52
Core/Inc/dma.h
Normal file
52
Core/Inc/dma.h
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file dma.h
|
||||||
|
* @brief This file contains all the function prototypes for
|
||||||
|
* the dma.c file
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2024 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.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __DMA_H__
|
||||||
|
#define __DMA_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
/* DMA memory to memory transfer handles -------------------------------------*/
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Includes */
|
||||||
|
|
||||||
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Private defines */
|
||||||
|
|
||||||
|
/* USER CODE END Private defines */
|
||||||
|
|
||||||
|
void MX_DMA_Init(void);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Prototypes */
|
||||||
|
|
||||||
|
/* USER CODE END Prototypes */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __DMA_H__ */
|
||||||
|
|
@ -62,7 +62,7 @@
|
|||||||
/* #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 */
|
||||||
@ -214,7 +214,7 @@
|
|||||||
#define MAC_ADDR5 0U
|
#define MAC_ADDR5 0U
|
||||||
|
|
||||||
/* Definition of the Ethernet driver buffers size and count */
|
/* Definition of the Ethernet driver buffers size and count */
|
||||||
#define ETH_RX_BUF_SIZE /* buffer size for receive */
|
#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
|
||||||
#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
|
#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
|
||||||
#define ETH_RXBUFNB 4U /* 4 Rx buffers of size ETH_RX_BUF_SIZE */
|
#define ETH_RXBUFNB 4U /* 4 Rx buffers of size ETH_RX_BUF_SIZE */
|
||||||
#define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */
|
#define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */
|
||||||
|
@ -52,6 +52,8 @@ void MemManage_Handler(void);
|
|||||||
void BusFault_Handler(void);
|
void BusFault_Handler(void);
|
||||||
void UsageFault_Handler(void);
|
void UsageFault_Handler(void);
|
||||||
void DebugMon_Handler(void);
|
void DebugMon_Handler(void);
|
||||||
|
void CAN1_RX0_IRQHandler(void);
|
||||||
|
void CAN1_RX1_IRQHandler(void);
|
||||||
void TIM1_UP_TIM10_IRQHandler(void);
|
void TIM1_UP_TIM10_IRQHandler(void);
|
||||||
/* USER CODE BEGIN EFP */
|
/* USER CODE BEGIN EFP */
|
||||||
|
|
||||||
|
0
Core/Src/adc.c
Normal file
0
Core/Src/adc.c
Normal file
@ -83,6 +83,11 @@ void HAL_CAN_MspInit(CAN_HandleTypeDef* canHandle)
|
|||||||
GPIO_InitStruct.Alternate = GPIO_AF9_CAN1;
|
GPIO_InitStruct.Alternate = GPIO_AF9_CAN1;
|
||||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/* CAN1 interrupt Init */
|
||||||
|
HAL_NVIC_SetPriority(CAN1_RX0_IRQn, 5, 0);
|
||||||
|
HAL_NVIC_EnableIRQ(CAN1_RX0_IRQn);
|
||||||
|
HAL_NVIC_SetPriority(CAN1_RX1_IRQn, 5, 0);
|
||||||
|
HAL_NVIC_EnableIRQ(CAN1_RX1_IRQn);
|
||||||
/* USER CODE BEGIN CAN1_MspInit 1 */
|
/* USER CODE BEGIN CAN1_MspInit 1 */
|
||||||
|
|
||||||
/* USER CODE END CAN1_MspInit 1 */
|
/* USER CODE END CAN1_MspInit 1 */
|
||||||
@ -106,6 +111,9 @@ void HAL_CAN_MspDeInit(CAN_HandleTypeDef* canHandle)
|
|||||||
*/
|
*/
|
||||||
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_11|GPIO_PIN_12);
|
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_11|GPIO_PIN_12);
|
||||||
|
|
||||||
|
/* CAN1 interrupt Deinit */
|
||||||
|
HAL_NVIC_DisableIRQ(CAN1_RX0_IRQn);
|
||||||
|
HAL_NVIC_DisableIRQ(CAN1_RX1_IRQn);
|
||||||
/* USER CODE BEGIN CAN1_MspDeInit 1 */
|
/* USER CODE BEGIN CAN1_MspDeInit 1 */
|
||||||
|
|
||||||
/* USER CODE END CAN1_MspDeInit 1 */
|
/* USER CODE END CAN1_MspDeInit 1 */
|
||||||
|
55
Core/Src/dma.c
Normal file
55
Core/Src/dma.c
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file dma.c
|
||||||
|
* @brief This file provides code for the configuration
|
||||||
|
* of all the requested memory to memory DMA transfers.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2024 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.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "dma.h"
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 0 */
|
||||||
|
|
||||||
|
/* USER CODE END 0 */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------------*/
|
||||||
|
/* Configure DMA */
|
||||||
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 1 */
|
||||||
|
|
||||||
|
/* USER CODE END 1 */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable DMA controller clock
|
||||||
|
*/
|
||||||
|
void MX_DMA_Init(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* DMA controller clock enable */
|
||||||
|
__HAL_RCC_DMA2_CLK_ENABLE();
|
||||||
|
|
||||||
|
/* DMA interrupt init */
|
||||||
|
/* DMA2_Stream0_IRQn interrupt configuration */
|
||||||
|
HAL_NVIC_SetPriority(DMA2_Stream0_IRQn, 5, 0);
|
||||||
|
HAL_NVIC_EnableIRQ(DMA2_Stream0_IRQn);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 2 */
|
||||||
|
|
||||||
|
/* USER CODE END 2 */
|
||||||
|
|
@ -38,6 +38,8 @@
|
|||||||
* Output
|
* Output
|
||||||
* EVENT_OUT
|
* EVENT_OUT
|
||||||
* EXTI
|
* EXTI
|
||||||
|
PB13 ------> SPI2_SCK
|
||||||
|
PB14 ------> SPI2_MISO
|
||||||
PC10 ------> SPI3_SCK
|
PC10 ------> SPI3_SCK
|
||||||
PC11 ------> SPI3_MISO
|
PC11 ------> SPI3_MISO
|
||||||
PC12 ------> SPI3_MOSI
|
PC12 ------> SPI3_MOSI
|
||||||
@ -49,58 +51,18 @@ void MX_GPIO_Init(void)
|
|||||||
|
|
||||||
/* GPIO Ports Clock Enable */
|
/* GPIO Ports Clock Enable */
|
||||||
__HAL_RCC_GPIOH_CLK_ENABLE();
|
__HAL_RCC_GPIOH_CLK_ENABLE();
|
||||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
|
||||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
|
||||||
__HAL_RCC_GPIOE_CLK_ENABLE();
|
|
||||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||||
__HAL_RCC_GPIOD_CLK_ENABLE();
|
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||||
|
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||||
|
|
||||||
/*Configure GPIO pin Output Level */
|
/*Configure GPIO pins : PB13 PB14 */
|
||||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3
|
GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14;
|
||||||
|GPIO_PIN_6, GPIO_PIN_RESET);
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||||
|
|
||||||
/*Configure GPIO pin Output Level */
|
|
||||||
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_12, GPIO_PIN_SET);
|
|
||||||
|
|
||||||
/*Configure GPIO pin Output Level */
|
|
||||||
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15, GPIO_PIN_RESET);
|
|
||||||
|
|
||||||
/*Configure GPIO pin Output Level */
|
|
||||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_10|GPIO_PIN_12, GPIO_PIN_RESET);
|
|
||||||
|
|
||||||
/*Configure GPIO pin Output Level */
|
|
||||||
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_8|GPIO_PIN_9, GPIO_PIN_RESET);
|
|
||||||
|
|
||||||
/*Configure GPIO pins : PA0 PA1 PA2 PA3
|
|
||||||
PA6 */
|
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3
|
|
||||||
|GPIO_PIN_6;
|
|
||||||
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_VERY_HIGH;
|
||||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
|
||||||
|
|
||||||
/*Configure GPIO pins : PE12 PE13 PE14 PE15 */
|
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15;
|
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
||||||
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
|
|
||||||
|
|
||||||
/*Configure GPIO pins : PB10 PB12 */
|
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_12;
|
|
||||||
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);
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||||
|
|
||||||
/*Configure GPIO pins : PD8 PD9 */
|
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9;
|
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
||||||
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
|
||||||
|
|
||||||
/*Configure GPIO pins : PC10 PC11 PC12 */
|
/*Configure GPIO pins : PC10 PC11 PC12 */
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12;
|
GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||||
|
@ -20,16 +20,12 @@
|
|||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "cmsis_os.h"
|
#include "cmsis_os.h"
|
||||||
#include "can.h"
|
#include "can.h"
|
||||||
#include "spi.h"
|
|
||||||
#include "usart.h"
|
#include "usart.h"
|
||||||
#include "gpio.h"
|
#include "gpio.h"
|
||||||
|
|
||||||
/* Private includes ----------------------------------------------------------*/
|
/* Private includes ----------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN Includes */
|
/* USER CODE BEGIN Includes */
|
||||||
//#include <sta/devices/stm32/can.hpp>
|
|
||||||
//extern void testCan(CAN_HandleTypeDef * handle);
|
|
||||||
//extern void testCanMsg(CAN_HandleTypeDef * handle, uint8_t payload[8]);
|
|
||||||
//extern uint8_t packValues(uint8_t type_id, uint8_t sensor_ID, uint8_t value, uint8_t include);
|
|
||||||
/* USER CODE END Includes */
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
/* Private typedef -----------------------------------------------------------*/
|
/* Private typedef -----------------------------------------------------------*/
|
||||||
@ -39,13 +35,7 @@
|
|||||||
|
|
||||||
/* Private define ------------------------------------------------------------*/
|
/* Private define ------------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN PD */
|
/* USER CODE BEGIN PD */
|
||||||
CAN_RxHeaderTypeDef rxHeader; //CAN Bus Transmit Header
|
|
||||||
CAN_TxHeaderTypeDef txHeader; //CAN Bus Receive Header
|
|
||||||
uint8_t canRX[8] = {0,0,0,0,0,0,0,0}; //CAN Bus Receive Buffer
|
|
||||||
CAN_FilterTypeDef canfilterconfig;
|
|
||||||
uint32_t canMailbox; //CAN Bus Mail box variable
|
|
||||||
|
|
||||||
uint8_t received = 0;
|
|
||||||
/* USER CODE END PD */
|
/* USER CODE END PD */
|
||||||
|
|
||||||
/* Private macro -------------------------------------------------------------*/
|
/* Private macro -------------------------------------------------------------*/
|
||||||
@ -77,6 +67,7 @@ void MX_FREERTOS_Init(void);
|
|||||||
*/
|
*/
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* USER CODE BEGIN 1 */
|
/* USER CODE BEGIN 1 */
|
||||||
|
|
||||||
/* USER CODE END 1 */
|
/* USER CODE END 1 */
|
||||||
@ -101,59 +92,25 @@ int main(void)
|
|||||||
MX_GPIO_Init();
|
MX_GPIO_Init();
|
||||||
MX_CAN1_Init();
|
MX_CAN1_Init();
|
||||||
MX_USART1_UART_Init();
|
MX_USART1_UART_Init();
|
||||||
MX_SPI2_Init();
|
|
||||||
/* USER CODE BEGIN 2 */
|
/* USER CODE BEGIN 2 */
|
||||||
|
|
||||||
/*txHeader.DLC = 8;
|
|
||||||
txHeader.IDE = CAN_ID_STD;
|
|
||||||
txHeader.RTR = CAN_RTR_DATA;
|
|
||||||
txHeader.StdId = 0x030;
|
|
||||||
txHeader.ExtId = 0x02;
|
|
||||||
txHeader.TransmitGlobalTime = DISABLE;*/
|
|
||||||
|
|
||||||
canfilterconfig.FilterActivation = CAN_FILTER_ENABLE;
|
|
||||||
canfilterconfig.FilterBank = 18;
|
|
||||||
canfilterconfig.FilterFIFOAssignment = CAN_RX_FIFO0;
|
|
||||||
canfilterconfig.FilterIdHigh = 0;
|
|
||||||
canfilterconfig.FilterIdLow = 0x466<<5;
|
|
||||||
canfilterconfig.FilterMaskIdHigh = 0;
|
|
||||||
canfilterconfig.FilterMaskIdLow = 0x466<<5;
|
|
||||||
canfilterconfig.FilterMode = CAN_FILTERMODE_IDMASK;
|
|
||||||
canfilterconfig.FilterScale = CAN_FILTERSCALE_32BIT;
|
|
||||||
canfilterconfig.SlaveStartFilterBank = 20;
|
|
||||||
|
|
||||||
HAL_CAN_ConfigFilter(&hcan1, &canfilterconfig);
|
|
||||||
HAL_CAN_Start(&hcan1);
|
|
||||||
|
|
||||||
if (HAL_CAN_ActivateNotification(&hcan1, CAN_IT_RX_FIFO0_MSG_PENDING) != HAL_OK)
|
|
||||||
{
|
|
||||||
Error_Handler();
|
|
||||||
}
|
|
||||||
|
|
||||||
//testCan(&hcan1);
|
|
||||||
|
|
||||||
/* USER CODE END 2 */
|
/* USER CODE END 2 */
|
||||||
|
|
||||||
/* Init scheduler */
|
/* Init scheduler */
|
||||||
osKernelInitialize();
|
osKernelInitialize();
|
||||||
|
|
||||||
/* Call init function for freertos objects (in freertos.c) */
|
/* Call init function for freertos objects (in cmsis_os2.c) */
|
||||||
MX_FREERTOS_Init();
|
MX_FREERTOS_Init();
|
||||||
|
|
||||||
/* Start scheduler */
|
/* Start scheduler */
|
||||||
osKernelStart();
|
osKernelStart();
|
||||||
|
|
||||||
/* We should never get here as control is now taken by the scheduler */
|
/* We should never get here as control is now taken by the scheduler */
|
||||||
|
|
||||||
/* Infinite loop */
|
/* Infinite loop */
|
||||||
/* USER CODE BEGIN WHILE */
|
/* USER CODE BEGIN WHILE */
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
if (received == 1){
|
|
||||||
testCanMsg(&hcan1, canRX);
|
|
||||||
received = 0;
|
|
||||||
}
|
|
||||||
HAL_Delay(1000);*/
|
|
||||||
/* USER CODE END WHILE */
|
/* USER CODE END WHILE */
|
||||||
|
|
||||||
/* USER CODE BEGIN 3 */
|
/* USER CODE BEGIN 3 */
|
||||||
@ -209,33 +166,6 @@ void SystemClock_Config(void)
|
|||||||
|
|
||||||
/* USER CODE BEGIN 4 */
|
/* USER CODE BEGIN 4 */
|
||||||
|
|
||||||
void unpackValues(uint8_t packedByte, uint8_t* type_id, uint8_t* sensor_ID, uint8_t* value, uint8_t* include) {
|
|
||||||
*type_id = (packedByte >> 6) & 0x03; // Extracting two bits for type_id
|
|
||||||
*sensor_ID = (packedByte >> 3) & 0x07; // Extracting three bits for sensorID
|
|
||||||
*include = (packedByte >> 2) & 0x01; // Extracting the flag for included value
|
|
||||||
*value = (packedByte >> 1) & 0x01; // Extracting one bit for value
|
|
||||||
}
|
|
||||||
|
|
||||||
void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan1)
|
|
||||||
{
|
|
||||||
|
|
||||||
/*HAL_CAN_GetRxMessage(hcan1, CAN_RX_FIFO0, &rxHeader, canRX);
|
|
||||||
|
|
||||||
uint8_t type_id, sensor_ID, value, include;
|
|
||||||
|
|
||||||
unpackValues(canRX[0], &type_id, &sensor_ID, &value, &include);
|
|
||||||
|
|
||||||
if (type_id == 0 && sensor_ID == 1){
|
|
||||||
if (value == 0){
|
|
||||||
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_8, GPIO_PIN_SET);
|
|
||||||
}else{
|
|
||||||
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_8, GPIO_PIN_SET);
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* USER CODE END 4 */
|
/* USER CODE END 4 */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
129
Core/Src/spi.c
129
Core/Src/spi.c
@ -1,129 +0,0 @@
|
|||||||
/* USER CODE BEGIN Header */
|
|
||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file spi.c
|
|
||||||
* @brief This file provides code for the configuration
|
|
||||||
* of the SPI instances.
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* Copyright (c) 2024 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.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
/* USER CODE END Header */
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "spi.h"
|
|
||||||
|
|
||||||
/* USER CODE BEGIN 0 */
|
|
||||||
|
|
||||||
/* USER CODE END 0 */
|
|
||||||
|
|
||||||
SPI_HandleTypeDef hspi2;
|
|
||||||
|
|
||||||
/* SPI2 init function */
|
|
||||||
void MX_SPI2_Init(void)
|
|
||||||
{
|
|
||||||
|
|
||||||
/* USER CODE BEGIN SPI2_Init 0 */
|
|
||||||
|
|
||||||
/* USER CODE END SPI2_Init 0 */
|
|
||||||
|
|
||||||
/* USER CODE BEGIN SPI2_Init 1 */
|
|
||||||
|
|
||||||
/* USER CODE END SPI2_Init 1 */
|
|
||||||
hspi2.Instance = SPI2;
|
|
||||||
hspi2.Init.Mode = SPI_MODE_MASTER;
|
|
||||||
hspi2.Init.Direction = SPI_DIRECTION_2LINES;
|
|
||||||
hspi2.Init.DataSize = SPI_DATASIZE_8BIT;
|
|
||||||
hspi2.Init.CLKPolarity = SPI_POLARITY_LOW;
|
|
||||||
hspi2.Init.CLKPhase = SPI_PHASE_1EDGE;
|
|
||||||
hspi2.Init.NSS = SPI_NSS_SOFT;
|
|
||||||
hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2;
|
|
||||||
hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB;
|
|
||||||
hspi2.Init.TIMode = SPI_TIMODE_DISABLE;
|
|
||||||
hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
|
|
||||||
hspi2.Init.CRCPolynomial = 10;
|
|
||||||
if (HAL_SPI_Init(&hspi2) != HAL_OK)
|
|
||||||
{
|
|
||||||
Error_Handler();
|
|
||||||
}
|
|
||||||
/* USER CODE BEGIN SPI2_Init 2 */
|
|
||||||
|
|
||||||
/* USER CODE END SPI2_Init 2 */
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void HAL_SPI_MspInit(SPI_HandleTypeDef* spiHandle)
|
|
||||||
{
|
|
||||||
|
|
||||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
|
||||||
if(spiHandle->Instance==SPI2)
|
|
||||||
{
|
|
||||||
/* USER CODE BEGIN SPI2_MspInit 0 */
|
|
||||||
|
|
||||||
/* USER CODE END SPI2_MspInit 0 */
|
|
||||||
/* SPI2 clock enable */
|
|
||||||
__HAL_RCC_SPI2_CLK_ENABLE();
|
|
||||||
|
|
||||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
|
||||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
|
||||||
/**SPI2 GPIO Configuration
|
|
||||||
PC3 ------> SPI2_MOSI
|
|
||||||
PB13 ------> SPI2_SCK
|
|
||||||
PB14 ------> SPI2_MISO
|
|
||||||
*/
|
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_3;
|
|
||||||
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_SPI2;
|
|
||||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
|
||||||
|
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14;
|
|
||||||
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_SPI2;
|
|
||||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
|
||||||
|
|
||||||
/* USER CODE BEGIN SPI2_MspInit 1 */
|
|
||||||
|
|
||||||
/* USER CODE END SPI2_MspInit 1 */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void HAL_SPI_MspDeInit(SPI_HandleTypeDef* spiHandle)
|
|
||||||
{
|
|
||||||
|
|
||||||
if(spiHandle->Instance==SPI2)
|
|
||||||
{
|
|
||||||
/* USER CODE BEGIN SPI2_MspDeInit 0 */
|
|
||||||
|
|
||||||
/* USER CODE END SPI2_MspDeInit 0 */
|
|
||||||
/* Peripheral clock disable */
|
|
||||||
__HAL_RCC_SPI2_CLK_DISABLE();
|
|
||||||
|
|
||||||
/**SPI2 GPIO Configuration
|
|
||||||
PC3 ------> SPI2_MOSI
|
|
||||||
PB13 ------> SPI2_SCK
|
|
||||||
PB14 ------> SPI2_MISO
|
|
||||||
*/
|
|
||||||
HAL_GPIO_DeInit(GPIOC, GPIO_PIN_3);
|
|
||||||
|
|
||||||
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_13|GPIO_PIN_14);
|
|
||||||
|
|
||||||
/* USER CODE BEGIN SPI2_MspDeInit 1 */
|
|
||||||
|
|
||||||
/* USER CODE END SPI2_MspDeInit 1 */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* USER CODE BEGIN 1 */
|
|
||||||
|
|
||||||
/* USER CODE END 1 */
|
|
@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
/* Includes ------------------------------------------------------------------*/
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
/* USER CODE BEGIN Includes */
|
/* USER CODE BEGIN Includes */
|
||||||
|
|
||||||
/* USER CODE END Includes */
|
/* USER CODE END Includes */
|
||||||
@ -63,6 +62,7 @@
|
|||||||
*/
|
*/
|
||||||
void HAL_MspInit(void)
|
void HAL_MspInit(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* USER CODE BEGIN MspInit 0 */
|
/* USER CODE BEGIN MspInit 0 */
|
||||||
|
|
||||||
/* USER CODE END MspInit 0 */
|
/* USER CODE END MspInit 0 */
|
||||||
|
@ -55,6 +55,7 @@
|
|||||||
/* USER CODE END 0 */
|
/* USER CODE END 0 */
|
||||||
|
|
||||||
/* External variables --------------------------------------------------------*/
|
/* External variables --------------------------------------------------------*/
|
||||||
|
extern CAN_HandleTypeDef hcan1;
|
||||||
extern TIM_HandleTypeDef htim1;
|
extern TIM_HandleTypeDef htim1;
|
||||||
|
|
||||||
/* USER CODE BEGIN EV */
|
/* USER CODE BEGIN EV */
|
||||||
@ -159,6 +160,34 @@ void DebugMon_Handler(void)
|
|||||||
/* please refer to the startup file (startup_stm32f4xx.s). */
|
/* please refer to the startup file (startup_stm32f4xx.s). */
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function handles CAN1 RX0 interrupts.
|
||||||
|
*/
|
||||||
|
void CAN1_RX0_IRQHandler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN CAN1_RX0_IRQn 0 */
|
||||||
|
|
||||||
|
/* USER CODE END CAN1_RX0_IRQn 0 */
|
||||||
|
HAL_CAN_IRQHandler(&hcan1);
|
||||||
|
/* USER CODE BEGIN CAN1_RX0_IRQn 1 */
|
||||||
|
|
||||||
|
/* USER CODE END CAN1_RX0_IRQn 1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function handles CAN1 RX1 interrupt.
|
||||||
|
*/
|
||||||
|
void CAN1_RX1_IRQHandler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN CAN1_RX1_IRQn 0 */
|
||||||
|
|
||||||
|
/* USER CODE END CAN1_RX1_IRQn 0 */
|
||||||
|
HAL_CAN_IRQHandler(&hcan1);
|
||||||
|
/* USER CODE BEGIN CAN1_RX1_IRQn 1 */
|
||||||
|
|
||||||
|
/* USER CODE END CAN1_RX1_IRQn 1 */
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles TIM1 update interrupt and TIM10 global interrupt.
|
* @brief This function handles TIM1 update interrupt and TIM10 global interrupt.
|
||||||
*/
|
*/
|
||||||
|
@ -1,729 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @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 */
|
|
||||||
|
|
||||||
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, 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, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size,
|
|
||||||
uint32_t Timeout);
|
|
||||||
HAL_StatusTypeDef HAL_SPI_Transmit_IT(SPI_HandleTypeDef *hspi, 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, uint8_t *pTxData, uint8_t *pRxData,
|
|
||||||
uint16_t Size);
|
|
||||||
HAL_StatusTypeDef HAL_SPI_Transmit_DMA(SPI_HandleTypeDef *hspi, 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, 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(SPI_HandleTypeDef *hspi);
|
|
||||||
uint32_t HAL_SPI_GetError(SPI_HandleTypeDef *hspi);
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* STM32F4xx_HAL_SPI_H */
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1 +1 @@
|
|||||||
Subproject commit 39024e4a8c53ed19f9313a1d52adff763d06ba75
|
Subproject commit 69b5091c766a259e8a98c10576709ff4207762c5
|
@ -1 +0,0 @@
|
|||||||
Subproject commit 841c3b3776dcfea4ff99aa5df07ed54551b78b19
|
|
@ -1 +1 @@
|
|||||||
Subproject commit a6704f4c45a82cf607907854a0005d6450cb0f06
|
Subproject commit ca3e32521cf294cb3779750fd7fa32cf62ef1799
|
@ -1 +1 @@
|
|||||||
Subproject commit 8901abdb9cc393b3e7f2de295e75ba4205d6de39
|
Subproject commit bcdec5de60abef7d5eb562123ffe3485faae1792
|
59
README.md
Normal file
59
README.md
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
# STM32 CAN Demo
|
||||||
|
|
||||||
|
This Project is a simple CAN Demo for STM32F407. It uses sta-core, rtos2-utils and TACOS.
|
||||||
|
|
||||||
|
## Explanation
|
||||||
|
|
||||||
|
In the `startup.cpp` we register threads in the `onManagerInit()` func, by calling the following:
|
||||||
|
```c++
|
||||||
|
// Register Spam Thread to only run in the first state
|
||||||
|
addThread<demo::CanSpam>({ALL_STATES}, 0x123);
|
||||||
|
// Register Receive Thread to run in states 0 and 2
|
||||||
|
addThread<demo::CanReceiver>({0,2}, 0x124);
|
||||||
|
```
|
||||||
|
|
||||||
|
The `CanSpam` thread sends a message every 1 second, while the `CanReceiver` thread receives messages and prints them to the console.
|
||||||
|
Sending is done by calling the following:
|
||||||
|
```c++
|
||||||
|
CanSysMsg msg;
|
||||||
|
|
||||||
|
msg.paylod = ...; // Set the payload
|
||||||
|
msg.header.sid = getCanID(); // Use the ID of the thread
|
||||||
|
msg.header.format = 0; // Set the format to standard id
|
||||||
|
|
||||||
|
sta::tacos::queueCanBusMsg(msg, 0); // Send the message, 0 means no timeout
|
||||||
|
```
|
||||||
|
|
||||||
|
As we can see here every task has a unique ID, which is used to identify the task. Trough this ID (which is set at construction), messages are automagically forwarded to the correct task.
|
||||||
|
|
||||||
|
Receiving is done by calling the following:
|
||||||
|
```c++
|
||||||
|
CanSysMsg msg;
|
||||||
|
if (CAN_queue_.get(&msg, osWaitForever))
|
||||||
|
{
|
||||||
|
// use msg.payload and msg.header to access the data
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
# Setup
|
||||||
|
The only thing one must change outside of the App repository (and ofc the including of the Libs) is starting the ALPAKA stack in Core/freertos.c:
|
||||||
|
|
||||||
|
```c++
|
||||||
|
void StartDefaultTask(void *argument)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN StartDefaultTask */
|
||||||
|
/* Infinite loop */
|
||||||
|
|
||||||
|
extern void startALPAKA(void *);
|
||||||
|
startALPAKA(argument);
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
osDelay(1);
|
||||||
|
}
|
||||||
|
/* USER CODE END StartDefaultTask */
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Notes
|
||||||
|
|
||||||
|
We are using one of our own "ASEAG" modules which have a special define in the `config.hpp` to indicate the CAN bus and UART output. To replicate this for other hardware one must define `STA_STM32_USART_HANDLE` and `STA_STM32_CAN_HANDLE` in the `config.hpp` file.
|
Loading…
x
Reference in New Issue
Block a user