diff --git a/.gitignore b/.gitignore index 8b70d611a..fbae0bc9a 100644 --- a/.gitignore +++ b/.gitignore @@ -81,3 +81,11 @@ local # Makefile GNUmakefile + +# CubeMX Integration +EWARM +.mxproject +*/Core/Src/system_stm32*xx.c +*/*/Core/Src/system_stm32*xx.c +*/Core/Inc/stm32_assert.h +*/*/Core/Inc/stm32_assert.h diff --git a/.vscode/extensions.json b/.vscode/extensions.json index b5c60d558..5e67db949 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -9,6 +9,6 @@ "github.vscode-pull-request-github", "eamodio.gitlens", "davidanson.vscode-markdownlint", - "ms-vscode.vscode-serial-monitor" + "wombat.fancymon" ] } diff --git a/.vscode/launch.json b/.vscode/launch.json index fc890b664..101ae7491 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -32,6 +32,37 @@ ] } }, + { + "cwd": "${workspaceFolder}", + "executable": "${command:cmake.buildDirectory}/CUBEMXTESTING.elf", + "name": "CUBEMXTESTING", + "request": "launch", + "type": "cortex-debug", + "servertype": "openocd", + "configFiles": [ + "interface/stlink.cfg", + "target/stm32g4x.cfg" + ], + "searchDir": [], + "preLaunchTask": "CMake: configure and build CUBEMXTESTING", + "showDevDebugOutput": "raw", + "svdPath": "${workspaceFolder}/Lib/Vendor/CMSIS_5/SVD/STM32G474.svd", + "swoConfig": { + "enabled": true, + "cpuFrequency": 160000000, + "swoFrequency": 2000000, + "source": "probe", + "decoders": [ + { + "type": "console", + "label": "ITM", + "showOnStartup": true, + "port": 0, + "encoding": "ascii" + } + ] + } + }, { "cwd": "${workspaceFolder}", "executable": "${command:cmake.buildDirectory}/CCU.elf", @@ -561,99 +592,6 @@ "showDevDebugOutput": "raw", "svdPath": "${workspaceFolder}/Lib/Vendor/CMSIS_5/SVD/STM32G474.svd" }, - { - "cwd": "${workspaceFolder}", - "executable": "${command:cmake.buildDirectory}/G4PERTESTING.elf", - "name": "G4PERTESTING", - "request": "launch", - "type": "cortex-debug", - "servertype": "openocd", - "configFiles": [ - "interface/stlink.cfg", - "target/stm32g4x.cfg" - ], - "searchDir": [], - "preLaunchTask": "CMake: configure and build G4PERTESTING", - "showDevDebugOutput": "raw", - "svdPath": "${workspaceFolder}/Lib/Vendor/CMSIS_5/SVD/STM32G474.svd", - "swoConfig": { - "enabled": true, - "cpuFrequency": 170000000, - "swoFrequency": 2000000, - "source": "probe", - "decoders": [ - { - "type": "console", - "label": "ITM", - "showOnStartup": true, - "port": 0, - "encoding": "ascii" - } - ] - } - }, - { - "cwd": "${workspaceFolder}", - "executable": "${command:cmake.buildDirectory}/G4SPITESTING.elf", - "name": "G4SPITESTING", - "request": "launch", - "type": "cortex-debug", - "servertype": "openocd", - "configFiles": [ - "interface/stlink.cfg", - "target/stm32g4x.cfg" - ], - "searchDir": [], - "preLaunchTask": "CMake: configure and build G4SPITESTING", - "showDevDebugOutput": "raw", - "svdPath": "${workspaceFolder}/Lib/Vendor/CMSIS_5/SVD/STM32G474.svd", - "swoConfig": { - "enabled": true, - "cpuFrequency": 170000000, - "swoFrequency": 2000000, - "source": "probe", - "decoders": [ - { - "type": "console", - "label": "ITM", - "showOnStartup": true, - "port": 0, - "encoding": "ascii" - } - ] - } - }, - { - "cwd": "${workspaceFolder}", - "executable": "${command:cmake.buildDirectory}/G4ADCTESTING.elf", - "name": "G4ADCTESTING", - "request": "launch", - "type": "cortex-debug", - "servertype": "openocd", - "configFiles": [ - "interface/stlink.cfg", - "target/stm32g4x.cfg" - ], - "searchDir": [], - "preLaunchTask": "CMake: configure and build G4ADCTESTING", - "showDevDebugOutput": "raw", - "svdPath": "${workspaceFolder}/Lib/Vendor/CMSIS_5/SVD/STM32G474.svd", - "swoConfig": { - "enabled": true, - "cpuFrequency": 170000000, - "swoFrequency": 2000000, - "source": "probe", - "decoders": [ - { - "type": "console", - "label": "ITM", - "showOnStartup": true, - "port": 0, - "encoding": "ascii" - } - ] - } - }, { "cwd": "${workspaceFolder}", "executable": "${command:cmake.buildDirectory}/G4NEOTESTING.elf", @@ -684,254 +622,6 @@ } ] } - }, - { - "cwd": "${workspaceFolder}", - "executable": "${command:cmake.buildDirectory}/CAN_BASIC_TEST.elf", - "name": "CAN_BASIC_TEST", - "request": "launch", - "type": "cortex-debug", - "servertype": "openocd", - "configFiles": [ - "interface/stlink.cfg", - "target/stm32g4x.cfg" - ], - "searchDir": [], - "preLaunchTask": "CMake: configure and build CAN_BASIC_TEST", - "showDevDebugOutput": "raw", - "svdPath": "${workspaceFolder}/Lib/Vendor/CMSIS_5/SVD/STM32G474.svd", - "swoConfig": { - "enabled": true, - "cpuFrequency": 170000000, - "swoFrequency": 2000000, - "source": "probe", - "decoders": [ - { - "type": "console", - "label": "ITM", - "showOnStartup": true, - "port": 0, - "encoding": "ascii" - } - ] - } - }, - { - "cwd": "${workspaceFolder}", - "executable": "${command:cmake.buildDirectory}/CAN_FILTER_TEST.elf", - "name": "CAN_FILTER_TEST", - "request": "launch", - "type": "cortex-debug", - "servertype": "openocd", - "configFiles": [ - "interface/stlink.cfg", - "target/stm32g4x.cfg" - ], - "searchDir": [], - "preLaunchTask": "CMake: configure and build CAN_FILTER_TEST", - "showDevDebugOutput": "raw", - "svdPath": "${workspaceFolder}/Lib/Vendor/CMSIS_5/SVD/STM32G474.svd", - "swoConfig": { - "enabled": true, - "cpuFrequency": 170000000, - "swoFrequency": 2000000, - "source": "probe", - "decoders": [ - { - "type": "console", - "label": "ITM", - "showOnStartup": true, - "port": 0, - "encoding": "ascii" - } - ] - } - }, - { - "cwd": "${workspaceFolder}", - "executable": "${command:cmake.buildDirectory}/CAN_STRESS_TEST.elf", - "name": "CAN_STRESS_TEST", - "request": "launch", - "type": "cortex-debug", - "servertype": "openocd", - "configFiles": [ - "interface/stlink.cfg", - "target/stm32g4x.cfg" - ], - "searchDir": [], - "preLaunchTask": "CMake: configure and build CAN_STRESS_TEST", - "showDevDebugOutput": "raw", - "svdPath": "${workspaceFolder}/Lib/Vendor/CMSIS_5/SVD/STM32G474.svd", - "swoConfig": { - "enabled": true, - "cpuFrequency": 170000000, - "swoFrequency": 2000000, - "source": "probe", - "decoders": [ - { - "type": "console", - "label": "ITM", - "showOnStartup": true, - "port": 0, - "encoding": "ascii" - } - ] - } - }, - { - "cwd": "${workspaceFolder}", - "executable": "${command:cmake.buildDirectory}/CAN_LOOPBACK_TEST.elf", - "name": "CAN_LOOPBACK_TEST", - "request": "launch", - "type": "cortex-debug", - "servertype": "openocd", - "configFiles": [ - "interface/stlink.cfg", - "target/stm32g4x.cfg" - ], - "searchDir": [], - "preLaunchTask": "CMake: configure and build CAN_LOOPBACK_TEST", - "showDevDebugOutput": "raw", - "svdPath": "${workspaceFolder}/Lib/Vendor/CMSIS_5/SVD/STM32G474.svd", - "swoConfig": { - "enabled": true, - "cpuFrequency": 170000000, - "swoFrequency": 2000000, - "source": "probe", - "decoders": [ - { - "type": "console", - "label": "ITM", - "showOnStartup": true, - "port": 0, - "encoding": "ascii" - } - ] - } - }, - { - "cwd": "${workspaceFolder}", - "executable": "${command:cmake.buildDirectory}/CAN_LOST_RX_TEST.elf", - "name": "CAN_LOST_RX_TEST", - "request": "launch", - "type": "cortex-debug", - "servertype": "openocd", - "configFiles": [ - "interface/stlink.cfg", - "target/stm32g4x.cfg" - ], - "searchDir": [], - "preLaunchTask": "CMake: configure and build CAN_LOST_RX_TEST", - "showDevDebugOutput": "raw", - "svdPath": "${workspaceFolder}/Lib/Vendor/CMSIS_5/SVD/STM32G474.svd", - "swoConfig": { - "enabled": true, - "cpuFrequency": 170000000, - "swoFrequency": 2000000, - "source": "probe", - "decoders": [ - { - "type": "console", - "label": "ITM", - "showOnStartup": true, - "port": 0, - "encoding": "ascii" - } - ] - } - }, - { - "cwd": "${workspaceFolder}", - "executable": "${command:cmake.buildDirectory}/CAN_RELEASE_TEST.elf", - "name": "CAN_RELEASE_TEST", - "request": "launch", - "type": "cortex-debug", - "servertype": "openocd", - "configFiles": [ - "interface/stlink.cfg", - "target/stm32g4x.cfg" - ], - "searchDir": [], - "preLaunchTask": "CMake: configure and build CAN_RELEASE_TEST", - "showDevDebugOutput": "raw", - "svdPath": "${workspaceFolder}/Lib/Vendor/CMSIS_5/SVD/STM32G474.svd", - "swoConfig": { - "enabled": true, - "cpuFrequency": 170000000, - "swoFrequency": 2000000, - "source": "probe", - "decoders": [ - { - "type": "console", - "label": "ITM", - "showOnStartup": true, - "port": 0, - "encoding": "ascii" - } - ] - } - }, - { - "cwd": "${workspaceFolder}", - "executable": "${command:cmake.buildDirectory}/PROFILER_TEST.elf", - "name": "PROFILER_TEST", - "request": "launch", - "type": "cortex-debug", - "servertype": "openocd", - "configFiles": [ - "interface/stlink.cfg", - "target/stm32g4x.cfg" - ], - "searchDir": [], - "preLaunchTask": "CMake: configure and build PROFILER_TEST", - "showDevDebugOutput": "raw", - "svdPath": "${workspaceFolder}/Lib/Vendor/CMSIS_5/SVD/STM32G474.svd", - "swoConfig": { - "enabled": true, - "cpuFrequency": 170000000, - "swoFrequency": 2000000, - "source": "probe", - "decoders": [ - { - "type": "console", - "label": "ITM", - "showOnStartup": true, - "port": 0, - "encoding": "ascii" - } - ] - } - }, - { - "cwd": "${workspaceFolder}", - "executable": "${command:cmake.buildDirectory}/G431x8_CAN_BASIC_TEST.elf", - "name": "G431x8_CAN_BASIC_TEST", - "request": "launch", - "type": "cortex-debug", - "servertype": "openocd", - "configFiles": [ - "interface/stlink.cfg", - "target/stm32g4x.cfg" - ], - "searchDir": [], - "preLaunchTask": "CMake: configure and build G431x8_CAN_BASIC_TEST", - "showDevDebugOutput": "raw", - "svdPath": "${workspaceFolder}/Lib/Vendor/CMSIS_5/SVD/STM32G431.svd", - "swoConfig": { - "enabled": true, - "cpuFrequency": 170000000, - "swoFrequency": 2000000, - "source": "probe", - "decoders": [ - { - "type": "console", - "label": "ITM", - "showOnStartup": true, - "port": 0, - "encoding": "ascii" - } - ] - } } ] } diff --git a/.vscode/tasks.json b/.vscode/tasks.json index bf2d6e115..d3cb13330 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -38,6 +38,15 @@ ], "command": "cmake --build --preset ${command:cmake.activeBuildPresetName} --target ECU" }, + { + "label": "CMake: configure and build CUBEMXTESTING", + "type": "shell", + "dependsOrder": "sequence", + "dependsOn": [ + "CMake: configure" + ], + "command": "cmake --build --preset ${command:cmake.activeBuildPresetName} --target CUBEMXTESTING" + }, { "label": "CMake: configure and build CCU", "type": "shell", @@ -155,33 +164,6 @@ ], "command": "cmake --build --preset ${command:cmake.activeBuildPresetName} --target G4HELLO" }, - { - "label": "CMake: configure and build G4PERTESTING", - "type": "shell", - "dependsOrder": "sequence", - "dependsOn": [ - "CMake: configure" - ], - "command": "cmake --build --preset ${command:cmake.activeBuildPresetName} --target G4PERTESTING" - }, - { - "label": "CMake: configure and build G4ADCTESTING", - "type": "shell", - "dependsOrder": "sequence", - "dependsOn": [ - "CMake: configure" - ], - "command": "cmake --build --preset ${command:cmake.activeBuildPresetName} --target G4ADCTESTING" - }, - { - "label": "CMake: configure and build G4SPITESTING", - "type": "shell", - "dependsOrder": "sequence", - "dependsOn": [ - "CMake: configure" - ], - "command": "cmake --build --preset ${command:cmake.activeBuildPresetName} --target G4SPITESTING" - }, { "label": "CMake: configure and build G4NEOTESTING", "type": "shell", @@ -244,78 +226,6 @@ "CMake: configure" ], "command": "cmake --build --preset ${command:cmake.activeBuildPresetName} --target W3_G4SPI_Receive" - }, - { - "label": "CMake: configure and build CAN_BASIC_TEST", - "type": "shell", - "dependsOrder": "sequence", - "dependsOn": [ - "CMake: configure" - ], - "command": "cmake --build --preset ${command:cmake.activeBuildPresetName} --target CAN_BASIC_TEST" - }, - { - "label": "CMake: configure and build CAN_STRESS_TEST", - "type": "shell", - "dependsOrder": "sequence", - "dependsOn": [ - "CMake: configure" - ], - "command": "cmake --build --preset ${command:cmake.activeBuildPresetName} --target CAN_STRESS_TEST" - }, - { - "label": "CMake: configure and build CAN_FILTER_TEST", - "type": "shell", - "dependsOrder": "sequence", - "dependsOn": [ - "CMake: configure" - ], - "command": "cmake --build --preset ${command:cmake.activeBuildPresetName} --target CAN_FILTER_TEST" - }, - { - "label": "CMake: configure and build CAN_RELEASE_TEST", - "type": "shell", - "dependsOrder": "sequence", - "dependsOn": [ - "CMake: configure" - ], - "command": "cmake --build --preset ${command:cmake.activeBuildPresetName} --target CAN_RELEASE_TEST" - }, - { - "label": "CMake: configure and build CAN_LOST_RX_TEST", - "type": "shell", - "dependsOrder": "sequence", - "dependsOn": [ - "CMake: configure" - ], - "command": "cmake --build --preset ${command:cmake.activeBuildPresetName} --target CAN_LOST_RX_TEST" - }, - { - "label": "CMake: configure and build CAN_LOOPBACK_TEST", - "type": "shell", - "dependsOrder": "sequence", - "dependsOn": [ - "CMake: configure" - ], - "command": "cmake --build --preset ${command:cmake.activeBuildPresetName} --target CAN_LOOPBACK_TEST" - }, - { - "label": "CMake: configure and build PROFILER_TEST", - "type": "shell", - "dependsOrder": "sequence", - "dependsOn": [ - "CMake: configure" - ], - "command": "cmake --build --preset ${command:cmake.activeBuildPresetName} --target PROFILER_TEST" - }, - { - "label": "CMake: configure and build G431x8_CAN_BASIC_TEST", - "type": "shell", - "dependsOrder": "sequence", - "dependsOn": [ - "CMake: configure" - ], - "command": "cmake --build --preset ${command:cmake.activeBuildPresetName} --target G431x8_CAN_BASIC_TEST" } ] } diff --git a/BLINKY/G4BLINKY/CMakeLists.txt b/BLINKY/G4BLINKY/CMakeLists.txt index 5e27c8df8..544603aba 100644 --- a/BLINKY/G4BLINKY/CMakeLists.txt +++ b/BLINKY/G4BLINKY/CMakeLists.txt @@ -40,7 +40,7 @@ target_sources( Core/Src/stm32g4xx_hal_msp.c ) -target_link_libraries(${GR_PROJECT_NAME}_USER_CODE INTERFACE) +target_link_libraries(${GR_PROJECT_NAME}_USER_CODE INTERFACE LOGOMATIC_OLD_LIB) target_include_directories( ${GR_PROJECT_NAME}_USER_CODE diff --git a/BLINKY/G4ECHO/CMakeLists.txt b/BLINKY/G4ECHO/CMakeLists.txt index 3410dbbb7..e8eb97182 100644 --- a/BLINKY/G4ECHO/CMakeLists.txt +++ b/BLINKY/G4ECHO/CMakeLists.txt @@ -35,6 +35,11 @@ target_sources( Core/Src/stm32g4xx_hal_msp.c ) -target_link_libraries(${GR_PROJECT_NAME}_USER_CODE INTERFACE VCP_LIB) +target_link_libraries( + ${GR_PROJECT_NAME}_USER_CODE + INTERFACE + VCP_LIB + LOGOMATIC_OLD_LIB +) target_include_directories(${GR_PROJECT_NAME}_USER_CODE INTERFACE Core/Inc) diff --git a/BLINKY/G4HELLO/CMakeLists.txt b/BLINKY/G4HELLO/CMakeLists.txt index 954f68470..979a5c93f 100644 --- a/BLINKY/G4HELLO/CMakeLists.txt +++ b/BLINKY/G4HELLO/CMakeLists.txt @@ -35,6 +35,6 @@ target_sources( Core/Src/stm32g4xx_hal_msp.c ) -target_link_libraries(${GR_PROJECT_NAME}_USER_CODE INTERFACE) +target_link_libraries(${GR_PROJECT_NAME}_USER_CODE INTERFACE LOGOMATIC_OLD_LIB) target_include_directories(${GR_PROJECT_NAME}_USER_CODE INTERFACE Core/Inc) diff --git a/BLINKY/L4BLINKY/CMakeLists.txt b/BLINKY/L4BLINKY/CMakeLists.txt index 4a081c49e..48d5d63fa 100644 --- a/BLINKY/L4BLINKY/CMakeLists.txt +++ b/BLINKY/L4BLINKY/CMakeLists.txt @@ -35,7 +35,7 @@ target_sources( Core/Src/usart.c ) -target_link_libraries(${PROJECT_NAME}_USER_CODE INTERFACE) +target_link_libraries(${PROJECT_NAME}_USER_CODE INTERFACE LOGOMATIC_OLD_LIB) target_include_directories( ${PROJECT_NAME}_USER_CODE diff --git a/BLINKY/L4HELLO/CMakeLists.txt b/BLINKY/L4HELLO/CMakeLists.txt index 4a081c49e..48d5d63fa 100644 --- a/BLINKY/L4HELLO/CMakeLists.txt +++ b/BLINKY/L4HELLO/CMakeLists.txt @@ -35,7 +35,7 @@ target_sources( Core/Src/usart.c ) -target_link_libraries(${PROJECT_NAME}_USER_CODE INTERFACE) +target_link_libraries(${PROJECT_NAME}_USER_CODE INTERFACE LOGOMATIC_OLD_LIB) target_include_directories( ${PROJECT_NAME}_USER_CODE diff --git a/BLINKY/U5BLINKY/CMakeLists.txt b/BLINKY/U5BLINKY/CMakeLists.txt index 377f139de..57d43ca09 100644 --- a/BLINKY/U5BLINKY/CMakeLists.txt +++ b/BLINKY/U5BLINKY/CMakeLists.txt @@ -31,7 +31,7 @@ target_sources( Core/Src/stm32u5xx_hal_msp.c ) -target_link_libraries(${GR_PROJECT_NAME}_USER_CODE INTERFACE) +target_link_libraries(${GR_PROJECT_NAME}_USER_CODE INTERFACE LOGOMATIC_OLD_LIB) target_include_directories( ${GR_PROJECT_NAME}_USER_CODE diff --git a/CANine/CMakeLists.txt b/CANine/CMakeLists.txt index 954f68470..979a5c93f 100644 --- a/CANine/CMakeLists.txt +++ b/CANine/CMakeLists.txt @@ -35,6 +35,6 @@ target_sources( Core/Src/stm32g4xx_hal_msp.c ) -target_link_libraries(${GR_PROJECT_NAME}_USER_CODE INTERFACE) +target_link_libraries(${GR_PROJECT_NAME}_USER_CODE INTERFACE LOGOMATIC_OLD_LIB) target_include_directories(${GR_PROJECT_NAME}_USER_CODE INTERFACE Core/Inc) diff --git a/CCU/CMakeLists.txt b/CCU/CMakeLists.txt index 6ecaa5312..700b5923a 100644 --- a/CCU/CMakeLists.txt +++ b/CCU/CMakeLists.txt @@ -35,7 +35,7 @@ if(CMAKE_PRESET_NAME STREQUAL "HOOTLTest") CCUStateTicksTests PRIVATE GLOBALSHARE_LIB - LOGOMATIC_LIB + LOGOMATIC_OLD_LIB BitManipulations_Lib ) add_test(CCUStateTicksTests CCUStateTicksTests) diff --git a/CMakeLists.txt b/CMakeLists.txt index dd6d899d4..40e5a1cb0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -128,7 +128,9 @@ include("${platform_path}/STM32H523xE/chip.cmake") # Utils include("${lib_path}/GlobalShare/common.cmake") -include("${lib_path}/Utils/Logomatic/logomatic.cmake") +include("${lib_path}/Utils/OldLogomatic/logomatic.cmake") +include("${lib_path}/Utils/Logomatic/log.cmake") +include("${lib_path}/Utils/CubeVCP/vcp.cmake") include("${lib_path}/Utils/VirtualComPort/vcp.cmake") include("${lib_path}/Utils/CircularBuffer/circular-buffer-lib.cmake") include("${lib_path}/Utils/MsgBuffer/msg-buffer-lib.cmake") @@ -142,6 +144,7 @@ include("Autogen/CAN/CANfigurator.cmake") include("${lib_path}/Peripherals/USART/common.cmake") include("${lib_path}/Peripherals/TimedCAN/common.cmake") include("${lib_path}/Peripherals/CAN/common.cmake") +include("${lib_path}/Peripherals/CubeCAN/cube_can.cmake") include("${lib_path}/FancyLayers-RENAME/GRCAN/grcan_fancylayer.cmake") include("${lib_path}/FancyLayers-RENAME/ADC/adc.cmake") @@ -157,21 +160,8 @@ add_gr_project(STM32G431x8 OutboardSensors TireTemp) add_gr_project(STM32G431x8 OutboardSensors BrakeTemp) # Development -add_gr_project(STM32G474xE G4PERTESTING) -add_gr_project(STM32G474xE G4SPITESTING) -add_gr_project(STM32G474xE G4ADCTESTING) -add_gr_project(STM32G474xE G4NEOTESTING) - -# CAN Peripheral Testing -add_gr_project(STM32G474xE G474xE_CAN_TESTING CAN_BASIC_TEST) -add_gr_project(STM32G474xE G474xE_CAN_TESTING CAN_RELEASE_TEST) -add_gr_project(STM32G474xE G474xE_CAN_TESTING CAN_STRESS_TEST) -add_gr_project(STM32G474xE G474xE_CAN_TESTING CAN_LOST_RX_TEST) -add_gr_project(STM32G474xE G474xE_CAN_TESTING CAN_FILTER_TEST) -add_gr_project(STM32G474xE G474xE_CAN_TESTING PROFILER_TEST) -add_gr_project(STM32G431x8 G431x8_CAN_TESTING G431x8_CAN_BASIC_TEST) - -add_gr_project(STM32G474xE G4FANCYCANTESTING CAN_LOOPBACK_TEST) +add_gr_project(STM32G474xE Testbench G4NEOTESTING) +add_gr_project(STM32G474xE Testbench CUBEMXTESTING) # BLINKY Demos add_gr_project(STM32G474xE BLINKY G4BLINKY) diff --git a/CUBEMX.md b/CUBEMX.md new file mode 100644 index 000000000..7c8f81390 --- /dev/null +++ b/CUBEMX.md @@ -0,0 +1,64 @@ +> [!IMPORTANT] +> Note that using a peripheral abstraction (eg our version of CAN) means it will no longer be compatible with CubeMX. As a result please **disable** the peripheral within CubeMX and let the peripheral abstraction handle it. + +# STM32CubeMX + +This was last verified on version `6.18.0` + +STM32CubeMX2 is a different product that coexists with STM32CubeMX and (as of now) cannot be used. + +## Instructions + +The process to add a new MCU to the monorepo is complex. Please see `CMAKE.md` or ask the current Firmware Manager for assistance and they can help set it up for you. + +### Modification + +1. Open the appropriate `.ioc` file, corresponding to the project you are interested in, in CubeMX +2. Make changes as relevant, being careful not to violate the [Configuration](#configuration) steps +3. Generate code and then make sure to add/remove from your project `CMakeLists.txt` as relevant + +### Creation + +0. Ensure the MCU you are working on has been added to the monorepo, see the list in [`Lib/Platform`](Lib/Platform). +1. Open and setup a new project through CubeMX, follow the [Configuration](#configuration) steps +2. Generate code and verify that it lives in the correct area, like the other projects +3. Copy [`ProjectTemplate/CMakeLists.txt](ProjectTemplate/CMakeLists.txt) into your folder, edit as instructed by the comments + - Note that folders/files which are git ignored can be safely deleted or ignored. +4. Add a new entry to the root [`CMakeLists.txt`](CMakeLists.txt) containing the appropriate `add_gr_project` call following [`CMAKE.md`](CMAKE.md) +5. Add the appropriate entries to [`launch.json`](.vscode/launch.json) and [`tasks.json`](.vscode/tasks.json) following [`VSCODE.md`](VSCODE.md) + +## Configuration + +> [!IMPORTANT] +> Please ensure you follow these *exactly*, or it will not be guaranteed to work correctly. + +### Project Manager + +| Field | Value | +| :-- | :-- | +| Project Name | (Shortname, ie CCU, ECU) | +| Project Location | (Root of this Git repository) | +| Application Structure | Advanced | +| Do not generate the main() | FALSE / unchecked | +| Toolchain Location | (Root of this Git repository)/(Shortname from above) | +| Toolchain / IDE | `EWARM` | + +### Code Generator + +| Field | Value | +| :-- | :-- | +| STM32Cube MCU packages and embedded software packs | Add necessary library files as reference in the toolchain project configuration file | +| Generate peripheral initialization as a pair of '.c/.h' files per peripheral | TRUE / checked | +| Backup previously generated files when regenerating | FALSE / unchecked | +| Keep User Code when regenerating | TRUE / checked | +| Delete previously generated files when not regenerating | TRUE / checked | + +## Website + +See [STM32CubeMX](https://www.st.com/en/development-tools/stm32cubemx.html) for more from ST. + +To install please visit the ["Get Software"](https://www.st.com/en/development-tools/stm32cubemx.html#section-get-software-table) tab. + +## Purpose + +CubeMX provides a simple way to change clocks, setup peripheral initializations, and much more (including calculating power consumption!). diff --git a/ECU/CMakeLists.txt b/ECU/CMakeLists.txt index 2ea28460a..b63573e3a 100644 --- a/ECU/CMakeLists.txt +++ b/ECU/CMakeLists.txt @@ -38,7 +38,7 @@ if(CMAKE_PRESET_NAME STREQUAL "HOOTLTest") PRIVATE GLOBALSHARE_LIB CANfigurator - LOGOMATIC_LIB + LOGOMATIC_OLD_LIB m # GR_ADC # PERIPHERAL_CAN_LIB diff --git a/G431x8_CAN_TESTING/Core/Inc/adc.h b/G431x8_CAN_TESTING/Core/Inc/adc.h deleted file mode 100644 index 41154538b..000000000 --- a/G431x8_CAN_TESTING/Core/Inc/adc.h +++ /dev/null @@ -1,49 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file adc.h - * @brief This file contains all the function prototypes for - * the adc.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 __ADC_H__ -#define __ADC_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" - -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* USER CODE BEGIN Private defines */ - -/* USER CODE END Private defines */ - -void MX_ADC1_Init(void); - -/* USER CODE BEGIN Prototypes */ - -/* USER CODE END Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif /* __ADC_H__ */ diff --git a/G431x8_CAN_TESTING/Core/Inc/crc.h b/G431x8_CAN_TESTING/Core/Inc/crc.h deleted file mode 100644 index 133957e92..000000000 --- a/G431x8_CAN_TESTING/Core/Inc/crc.h +++ /dev/null @@ -1,51 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file crc.h - * @brief This file contains all the function prototypes for - * the crc.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 __CRC_H__ -#define __CRC_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" - -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -extern CRC_HandleTypeDef hcrc; - -/* USER CODE BEGIN Private defines */ - -/* USER CODE END Private defines */ - -void MX_CRC_Init(void); - -/* USER CODE BEGIN Prototypes */ - -/* USER CODE END Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif /* __CRC_H__ */ diff --git a/G431x8_CAN_TESTING/Core/Inc/dma.h b/G431x8_CAN_TESTING/Core/Inc/dma.h deleted file mode 100644 index ae819cab4..000000000 --- a/G431x8_CAN_TESTING/Core/Inc/dma.h +++ /dev/null @@ -1,51 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file dma.h - * @brief This file contains all the function prototypes for - * the dma.c file - ****************************************************************************** - * @attention - * - * Copyright (c) 2025 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__ */ diff --git a/G431x8_CAN_TESTING/Core/Inc/fdcan.h b/G431x8_CAN_TESTING/Core/Inc/fdcan.h deleted file mode 100644 index 56c4a8adb..000000000 --- a/G431x8_CAN_TESTING/Core/Inc/fdcan.h +++ /dev/null @@ -1,51 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file fdcan.h - * @brief This file contains all the function prototypes for - * the fdcan.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 __FDCAN_H__ -#define __FDCAN_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" - -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -extern FDCAN_HandleTypeDef hfdcan2; - -/* USER CODE BEGIN Private defines */ - -/* USER CODE END Private defines */ - -void MX_FDCAN2_Init(void); - -/* USER CODE BEGIN Prototypes */ - -/* USER CODE END Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif /* __FDCAN_H__ */ diff --git a/G431x8_CAN_TESTING/Core/Inc/gpio.h b/G431x8_CAN_TESTING/Core/Inc/gpio.h deleted file mode 100644 index 843d4e9e7..000000000 --- a/G431x8_CAN_TESTING/Core/Inc/gpio.h +++ /dev/null @@ -1,48 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file gpio.h - * @brief This file contains all the function prototypes for - * the gpio.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 __GPIO_H__ -#define __GPIO_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" - -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* USER CODE BEGIN Private defines */ - -/* USER CODE END Private defines */ - -void MX_GPIO_Init(void); - -/* USER CODE BEGIN Prototypes */ - -/* USER CODE END Prototypes */ - -#ifdef __cplusplus -} -#endif -#endif /*__ GPIO_H__ */ diff --git a/G431x8_CAN_TESTING/Core/Inc/i2c.h b/G431x8_CAN_TESTING/Core/Inc/i2c.h deleted file mode 100644 index 0a0a50803..000000000 --- a/G431x8_CAN_TESTING/Core/Inc/i2c.h +++ /dev/null @@ -1,49 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file i2c.h - * @brief This file contains all the function prototypes for - * the i2c.c file - ****************************************************************************** - * @attention - * - * Copyright (c) 2025 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 __I2C_H__ -#define __I2C_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" - -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* USER CODE BEGIN Private defines */ - -/* USER CODE END Private defines */ - -void MX_I2C2_Init(void); - -/* USER CODE BEGIN Prototypes */ - -/* USER CODE END Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif /* __I2C_H__ */ diff --git a/G431x8_CAN_TESTING/Core/Inc/spi.h b/G431x8_CAN_TESTING/Core/Inc/spi.h deleted file mode 100644 index 74bed003b..000000000 --- a/G431x8_CAN_TESTING/Core/Inc/spi.h +++ /dev/null @@ -1,49 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file spi.h - * @brief This file contains all the function prototypes for - * the spi.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 __SPI_H__ -#define __SPI_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" - -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* USER CODE BEGIN Private defines */ - -/* USER CODE END Private defines */ - -void MX_SPI3_Init(void); - -/* USER CODE BEGIN Prototypes */ - -/* USER CODE END Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif /* __SPI_H__ */ diff --git a/G431x8_CAN_TESTING/Core/Src/adc.c b/G431x8_CAN_TESTING/Core/Src/adc.c deleted file mode 100644 index f3dbff8ed..000000000 --- a/G431x8_CAN_TESTING/Core/Src/adc.c +++ /dev/null @@ -1,186 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file adc.c - * @brief This file provides code for the configuration - * of the ADC 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 "adc.h" - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/* ADC1 init function */ -void MX_ADC1_Init(void) -{ - - /* USER CODE BEGIN ADC1_Init 0 */ - - /* USER CODE END ADC1_Init 0 */ - - LL_ADC_InitTypeDef ADC_InitStruct = {0}; - LL_ADC_REG_InitTypeDef ADC_REG_InitStruct = {0}; - LL_ADC_CommonInitTypeDef ADC_CommonInitStruct = {0}; - - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - - LL_RCC_SetADCClockSource(LL_RCC_ADC12_CLKSOURCE_SYSCLK); - - /* Peripheral clock enable */ - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_ADC12); - - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOB); - /**ADC1 GPIO Configuration - PC1 ------> ADC1_IN7 - PC2 ------> ADC1_IN8 - PC3 ------> ADC1_IN9 - PB0 ------> ADC1_IN15 - PB1 ------> ADC1_IN12 - PB14 ------> ADC1_IN5 - */ - GPIO_InitStruct.Pin = BSPD_SIGNAL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(BSPD_SIGNAL_GPIO_Port, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = APPS1_SIGNAL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(APPS1_SIGNAL_GPIO_Port, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = APPS2_SIGNAL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(APPS2_SIGNAL_GPIO_Port, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = BRAKE_F_SIGNAL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(BRAKE_F_SIGNAL_GPIO_Port, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = BRAKE_R_SIGNAL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(BRAKE_R_SIGNAL_GPIO_Port, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = AUX_SIGNAL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(AUX_SIGNAL_GPIO_Port, &GPIO_InitStruct); - - /* ADC1 DMA Init */ - - /* ADC1 Init */ - LL_DMA_SetPeriphRequest(DMA1, LL_DMA_CHANNEL_1, LL_DMAMUX_REQ_ADC1); - - LL_DMA_SetDataTransferDirection(DMA1, LL_DMA_CHANNEL_1, LL_DMA_DIRECTION_PERIPH_TO_MEMORY); - - LL_DMA_SetChannelPriorityLevel(DMA1, LL_DMA_CHANNEL_1, LL_DMA_PRIORITY_LOW); - - LL_DMA_SetMode(DMA1, LL_DMA_CHANNEL_1, LL_DMA_MODE_CIRCULAR); - - LL_DMA_SetPeriphIncMode(DMA1, LL_DMA_CHANNEL_1, LL_DMA_PERIPH_NOINCREMENT); - - LL_DMA_SetMemoryIncMode(DMA1, LL_DMA_CHANNEL_1, LL_DMA_MEMORY_INCREMENT); - - LL_DMA_SetPeriphSize(DMA1, LL_DMA_CHANNEL_1, LL_DMA_PDATAALIGN_HALFWORD); - - LL_DMA_SetMemorySize(DMA1, LL_DMA_CHANNEL_1, LL_DMA_MDATAALIGN_HALFWORD); - - /* USER CODE BEGIN ADC1_Init 1 */ - - /* USER CODE END ADC1_Init 1 */ - - /** Common config - */ - ADC_InitStruct.Resolution = LL_ADC_RESOLUTION_12B; - ADC_InitStruct.DataAlignment = LL_ADC_DATA_ALIGN_RIGHT; - ADC_InitStruct.LowPowerMode = LL_ADC_LP_MODE_NONE; - LL_ADC_Init(ADC1, &ADC_InitStruct); - ADC_REG_InitStruct.TriggerSource = LL_ADC_REG_TRIG_SOFTWARE; - ADC_REG_InitStruct.SequencerLength = LL_ADC_REG_SEQ_SCAN_ENABLE_6RANKS; - ADC_REG_InitStruct.SequencerDiscont = LL_ADC_REG_SEQ_DISCONT_DISABLE; - ADC_REG_InitStruct.ContinuousMode = LL_ADC_REG_CONV_CONTINUOUS; - ADC_REG_InitStruct.DMATransfer = LL_ADC_REG_DMA_TRANSFER_UNLIMITED; - ADC_REG_InitStruct.Overrun = LL_ADC_REG_OVR_DATA_PRESERVED; - LL_ADC_REG_Init(ADC1, &ADC_REG_InitStruct); - LL_ADC_SetGainCompensation(ADC1, 0); - LL_ADC_SetOverSamplingScope(ADC1, LL_ADC_OVS_DISABLE); - ADC_CommonInitStruct.CommonClock = LL_ADC_CLOCK_ASYNC_DIV256; - ADC_CommonInitStruct.Multimode = LL_ADC_MULTI_INDEPENDENT; - LL_ADC_CommonInit(__LL_ADC_COMMON_INSTANCE(ADC1), &ADC_CommonInitStruct); - - /* Disable ADC deep power down (enabled by default after reset state) */ - LL_ADC_DisableDeepPowerDown(ADC1); - /* Enable ADC internal voltage regulator */ - LL_ADC_EnableInternalRegulator(ADC1); - /* Delay for ADC internal voltage regulator stabilization. */ - /* Compute number of CPU cycles to wait for, from delay in us. */ - /* Note: Variable divided by 2 to compensate partially */ - /* CPU processing cycles (depends on compilation optimization). */ - /* Note: If system core clock frequency is below 200kHz, wait time */ - /* is only a few CPU processing cycles. */ - uint32_t wait_loop_index; - wait_loop_index = ((LL_ADC_DELAY_INTERNAL_REGUL_STAB_US * (SystemCoreClock / (100000 * 2))) / 10); - while (wait_loop_index != 0) { - wait_loop_index--; - } - - /** Configure Regular Channel - */ - LL_ADC_REG_SetSequencerRanks(ADC1, LL_ADC_REG_RANK_1, LL_ADC_CHANNEL_5); - LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_5, LL_ADC_SAMPLINGTIME_92CYCLES_5); - LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_5, LL_ADC_SINGLE_ENDED); - - /** Configure Regular Channel - */ - LL_ADC_REG_SetSequencerRanks(ADC1, LL_ADC_REG_RANK_2, LL_ADC_CHANNEL_7); - LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_7, LL_ADC_SAMPLINGTIME_92CYCLES_5); - LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_7, LL_ADC_SINGLE_ENDED); - - /** Configure Regular Channel - */ - LL_ADC_REG_SetSequencerRanks(ADC1, LL_ADC_REG_RANK_3, LL_ADC_CHANNEL_8); - LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_8, LL_ADC_SAMPLINGTIME_92CYCLES_5); - LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_8, LL_ADC_SINGLE_ENDED); - - /** Configure Regular Channel - */ - LL_ADC_REG_SetSequencerRanks(ADC1, LL_ADC_REG_RANK_4, LL_ADC_CHANNEL_9); - LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_9, LL_ADC_SAMPLINGTIME_92CYCLES_5); - LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_9, LL_ADC_SINGLE_ENDED); - - /** Configure Regular Channel - */ - LL_ADC_REG_SetSequencerRanks(ADC1, LL_ADC_REG_RANK_5, LL_ADC_CHANNEL_12); - LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_12, LL_ADC_SAMPLINGTIME_92CYCLES_5); - LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_12, LL_ADC_SINGLE_ENDED); - - /** Configure Regular Channel - */ - LL_ADC_REG_SetSequencerRanks(ADC1, LL_ADC_REG_RANK_6, LL_ADC_CHANNEL_15); - LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_15, LL_ADC_SAMPLINGTIME_92CYCLES_5); - LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_15, LL_ADC_SINGLE_ENDED); - /* USER CODE BEGIN ADC1_Init 2 */ - - /* USER CODE END ADC1_Init 2 */ -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ diff --git a/G431x8_CAN_TESTING/Core/Src/crc.c b/G431x8_CAN_TESTING/Core/Src/crc.c deleted file mode 100644 index 213510a5d..000000000 --- a/G431x8_CAN_TESTING/Core/Src/crc.c +++ /dev/null @@ -1,86 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file crc.c - * @brief This file provides code for the configuration - * of the CRC 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 "crc.h" - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -CRC_HandleTypeDef hcrc; - -/* CRC init function */ -void MX_CRC_Init(void) -{ - - /* USER CODE BEGIN CRC_Init 0 */ - - /* USER CODE END CRC_Init 0 */ - - /* USER CODE BEGIN CRC_Init 1 */ - - /* USER CODE END CRC_Init 1 */ - hcrc.Instance = CRC; - hcrc.Init.DefaultPolynomialUse = DEFAULT_POLYNOMIAL_ENABLE; - hcrc.Init.DefaultInitValueUse = DEFAULT_INIT_VALUE_ENABLE; - hcrc.Init.InputDataInversionMode = CRC_INPUTDATA_INVERSION_NONE; - hcrc.Init.OutputDataInversionMode = CRC_OUTPUTDATA_INVERSION_DISABLE; - hcrc.InputDataFormat = CRC_INPUTDATA_FORMAT_BYTES; - if (HAL_CRC_Init(&hcrc) != HAL_OK) { - Error_Handler(); - } - /* USER CODE BEGIN CRC_Init 2 */ - - /* USER CODE END CRC_Init 2 */ -} - -void HAL_CRC_MspInit(CRC_HandleTypeDef *crcHandle) -{ - - if (crcHandle->Instance == CRC) { - /* USER CODE BEGIN CRC_MspInit 0 */ - - /* USER CODE END CRC_MspInit 0 */ - /* CRC clock enable */ - __HAL_RCC_CRC_CLK_ENABLE(); - /* USER CODE BEGIN CRC_MspInit 1 */ - - /* USER CODE END CRC_MspInit 1 */ - } -} - -void HAL_CRC_MspDeInit(CRC_HandleTypeDef *crcHandle) -{ - - if (crcHandle->Instance == CRC) { - /* USER CODE BEGIN CRC_MspDeInit 0 */ - - /* USER CODE END CRC_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_CRC_CLK_DISABLE(); - /* USER CODE BEGIN CRC_MspDeInit 1 */ - - /* USER CODE END CRC_MspDeInit 1 */ - } -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ diff --git a/G431x8_CAN_TESTING/Core/Src/dma.c b/G431x8_CAN_TESTING/Core/Src/dma.c deleted file mode 100644 index 491e3889d..000000000 --- a/G431x8_CAN_TESTING/Core/Src/dma.c +++ /dev/null @@ -1,50 +0,0 @@ -/* 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) 2025 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) -{ - - /* Init with LL driver */ - /* DMA controller clock enable */ - LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_DMAMUX1); - LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_DMA1); -} - -/* USER CODE BEGIN 2 */ - -/* USER CODE END 2 */ diff --git a/G431x8_CAN_TESTING/Core/Src/fdcan.c b/G431x8_CAN_TESTING/Core/Src/fdcan.c deleted file mode 100644 index ebc13ea73..000000000 --- a/G431x8_CAN_TESTING/Core/Src/fdcan.c +++ /dev/null @@ -1,135 +0,0 @@ -// #include "unused.h" -// /* USER CODE BEGIN Header */ -// /** -// ****************************************************************************** -// * @file fdcan.c -// * @brief This file provides code for the configuration -// * of the FDCAN 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 "fdcan.h" - -// /* USER CODE BEGIN 0 */ - -// /* USER CODE END 0 */ - -// FDCAN_HandleTypeDef hfdcan2; - -// /* FDCAN2 init function */ -// void MX_FDCAN2_Init(void) -// { - -// /* USER CODE BEGIN FDCAN2_Init 0 */ - -// /* USER CODE END FDCAN2_Init 0 */ - -// /* USER CODE BEGIN FDCAN2_Init 1 */ - -// /* USER CODE END FDCAN2_Init 1 */ -// hfdcan2.Instance = FDCAN2; -// hfdcan2.Init.ClockDivider = FDCAN_CLOCK_DIV1; -// hfdcan2.Init.FrameFormat = FDCAN_FRAME_CLASSIC; -// hfdcan2.Init.Mode = FDCAN_MODE_NORMAL; -// hfdcan2.Init.AutoRetransmission = ENABLE; -// hfdcan2.Init.TransmitPause = DISABLE; -// hfdcan2.Init.ProtocolException = ENABLE; -// hfdcan2.Init.NominalPrescaler = 1; -// hfdcan2.Init.NominalSyncJumpWidth = 16; -// hfdcan2.Init.NominalTimeSeg1 = 119; -// hfdcan2.Init.NominalTimeSeg2 = 40; -// hfdcan2.Init.DataPrescaler = 8; -// hfdcan2.Init.DataSyncJumpWidth = 16; -// hfdcan2.Init.DataTimeSeg1 = 14; -// hfdcan2.Init.DataTimeSeg2 = 5; -// hfdcan2.Init.StdFiltersNbr = 0; -// hfdcan2.Init.ExtFiltersNbr = 2; -// hfdcan2.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION; -// if (HAL_FDCAN_Init(&hfdcan2) != HAL_OK) { -// Error_Handler(); -// } -// /* USER CODE BEGIN FDCAN2_Init 2 */ - -// /* USER CODE END FDCAN2_Init 2 */ -// } - -// void HAL_FDCAN_MspInit(FDCAN_HandleTypeDef *fdcanHandle) -// { - -// GPIO_InitTypeDef GPIO_InitStruct = {0}; -// if (fdcanHandle->Instance == FDCAN2) { -// /* USER CODE BEGIN FDCAN2_MspInit 0 */ - -// /* USER CODE END FDCAN2_MspInit 0 */ -// LL_RCC_SetFDCANClockSource(LL_RCC_FDCAN_CLKSOURCE_PCLK1); - -// /* FDCAN2 clock enable */ -// __HAL_RCC_FDCAN_CLK_ENABLE(); - -// __HAL_RCC_GPIOB_CLK_ENABLE(); -// /**FDCAN2 GPIO Configuration -// PB12 ------> FDCAN2_RX -// PB13 ------> FDCAN2_TX -// */ -// GPIO_InitStruct.Pin = GPIO_PIN_12; -// GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; -// GPIO_InitStruct.Pull = GPIO_PULLUP; -// GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; -// GPIO_InitStruct.Alternate = GPIO_AF9_FDCAN2; -// HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - -// GPIO_InitStruct.Pin = GPIO_PIN_13; -// GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; -// GPIO_InitStruct.Pull = GPIO_NOPULL; -// GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; -// GPIO_InitStruct.Alternate = GPIO_AF9_FDCAN2; -// HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - -// /* FDCAN2 interrupt Init */ -// HAL_NVIC_SetPriority(FDCAN2_IT0_IRQn, 0, 0); -// HAL_NVIC_EnableIRQ(FDCAN2_IT0_IRQn); -// /* USER CODE BEGIN FDCAN2_MspInit 1 */ - -// /* USER CODE END FDCAN2_MspInit 1 */ -// } -// } - -// /*void HAL_FDCAN_MspDeInit(FDCAN_HandleTypeDef *fdcanHandle) -// { - -// if (fdcanHandle->Instance == FDCAN2) { -// /* USER CODE BEGIN FDCAN2_MspDeInit 0 */ - -// /* USER CODE END FDCAN2_MspDeInit 0 */ -// /* Peripheral clock disable */ -// __HAL_RCC_FDCAN_CLK_DISABLE(); - -// /**FDCAN2 GPIO Configuration -// PB12 ------> FDCAN2_RX -// PB13 ------> FDCAN2_TX -// */ -// HAL_GPIO_DeInit(GPIOB, GPIO_PIN_12 | GPIO_PIN_13); - -// /* FDCAN2 interrupt Deinit */ -// HAL_NVIC_DisableIRQ(FDCAN2_IT0_IRQn); -// /* USER CODE BEGIN FDCAN2_MspDeInit 1 */ - -// /* USER CODE END FDCAN2_MspDeInit 1 */ -// } -// } - -// /* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ -// UNUSED(5); diff --git a/G431x8_CAN_TESTING/Core/Src/gpio.c b/G431x8_CAN_TESTING/Core/Src/gpio.c deleted file mode 100644 index d36e6eca6..000000000 --- a/G431x8_CAN_TESTING/Core/Src/gpio.c +++ /dev/null @@ -1,260 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file gpio.c - * @brief This file provides code for the configuration - * of all used GPIO pins. - ****************************************************************************** - * @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 "gpio.h" - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/*----------------------------------------------------------------------------*/ -/* Configure GPIO */ -/*----------------------------------------------------------------------------*/ -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ - -/** Configure pins as - * Analog - * Input - * Output - * EVENT_OUT - * EXTI - * Free pins are configured automatically as Analog (this feature is - enabled through - * the Code Generation settings) - PA6 ------> ADC2_IN3 - PA7 ------> ADC2_IN4 - PB15 ------> ADC2_IN15 - PB7 ------> UART4_CTS -*/ -void MX_GPIO_Init(void) -{ - - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - - /* GPIO Ports Clock Enable */ - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOF); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOG); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOB); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOD); - - /**/ - LL_GPIO_ResetOutputPin(BLINKY_GPIO_Port, BLINKY_Pin); - - /**/ - LL_GPIO_ResetOutputPin(LED_TEST_GPIO_Port, LED_TEST_Pin); - - /**/ - LL_GPIO_ResetOutputPin(BRAKE_LIGHT_GPIO_Port, BRAKE_LIGHT_Pin); - - /**/ - LL_GPIO_ResetOutputPin(TSSI_G_CONTROL_GPIO_Port, TSSI_G_CONTROL_Pin); - - /**/ - LL_GPIO_ResetOutputPin(AUX_CONTROL_GPIO_Port, AUX_CONTROL_Pin); - - /**/ - LL_GPIO_ResetOutputPin(SOFTWARE_OK_CONTROL_GPIO_Port, SOFTWARE_OK_CONTROL_Pin); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_13; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_14; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_15; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_10; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOG, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_0; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_1; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_4; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = BLINKY_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(BLINKY_GPIO_Port, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = IMD_SENSE_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(IMD_SENSE_GPIO_Port, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = AMS_SENSE_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(AMS_SENSE_GPIO_Port, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_2; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_10; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LED_TEST_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(LED_TEST_GPIO_Port, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = STEERING_ANGLE_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(STEERING_ANGLE_GPIO_Port, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_6; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_7; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_8; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_9; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_9; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_10; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_15; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_2; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOD, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = BRAKE_LIGHT_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(BRAKE_LIGHT_GPIO_Port, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = TSSI_G_CONTROL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(TSSI_G_CONTROL_GPIO_Port, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_7; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_14; - LL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = AUX_CONTROL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(AUX_CONTROL_GPIO_Port, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = SOFTWARE_OK_CONTROL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(SOFTWARE_OK_CONTROL_GPIO_Port, &GPIO_InitStruct); -} - -/* USER CODE BEGIN 2 */ - -/* USER CODE END 2 */ diff --git a/G431x8_CAN_TESTING/Core/Src/i2c.c b/G431x8_CAN_TESTING/Core/Src/i2c.c deleted file mode 100644 index bfb4e0153..000000000 --- a/G431x8_CAN_TESTING/Core/Src/i2c.c +++ /dev/null @@ -1,92 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file i2c.c - * @brief This file provides code for the configuration - * of the I2C instances. - ****************************************************************************** - * @attention - * - * Copyright (c) 2025 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 "i2c.h" - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/* I2C2 init function */ -void MX_I2C2_Init(void) -{ - - /* USER CODE BEGIN I2C2_Init 0 */ - - /* USER CODE END I2C2_Init 0 */ - - LL_I2C_InitTypeDef I2C_InitStruct = {0}; - - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - - LL_RCC_SetI2CClockSource(LL_RCC_I2C2_CLKSOURCE_PCLK1); - - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA); - /**I2C2 GPIO Configuration - PC4 ------> I2C2_SCL - PA8 ------> I2C2_SDA - */ - GPIO_InitStruct.Pin = LL_GPIO_PIN_4; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_OPENDRAIN; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_4; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = LL_GPIO_PIN_8; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_OPENDRAIN; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_4; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /* Peripheral clock enable */ - LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_I2C2); - - /* USER CODE BEGIN I2C2_Init 1 */ - - /* USER CODE END I2C2_Init 1 */ - - /** I2C Initialization - */ - I2C_InitStruct.PeripheralMode = LL_I2C_MODE_I2C; - I2C_InitStruct.Timing = 0x30D29DE4; - I2C_InitStruct.AnalogFilter = LL_I2C_ANALOGFILTER_ENABLE; - I2C_InitStruct.DigitalFilter = 0; - I2C_InitStruct.OwnAddress1 = 0; - I2C_InitStruct.TypeAcknowledge = LL_I2C_ACK; - I2C_InitStruct.OwnAddrSize = LL_I2C_OWNADDRESS1_7BIT; - LL_I2C_Init(I2C2, &I2C_InitStruct); - LL_I2C_EnableAutoEndMode(I2C2); - LL_I2C_SetOwnAddress2(I2C2, 0, LL_I2C_OWNADDRESS2_NOMASK); - LL_I2C_DisableOwnAddress2(I2C2); - LL_I2C_DisableGeneralCall(I2C2); - LL_I2C_EnableClockStretching(I2C2); - /* USER CODE BEGIN I2C2_Init 2 */ - - /* USER CODE END I2C2_Init 2 */ -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ diff --git a/G431x8_CAN_TESTING/Core/Src/spi.c b/G431x8_CAN_TESTING/Core/Src/spi.c deleted file mode 100644 index 66459f2ec..000000000 --- a/G431x8_CAN_TESTING/Core/Src/spi.c +++ /dev/null @@ -1,95 +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 */ - -/* SPI3 init function */ -void MX_SPI3_Init(void) -{ - - /* USER CODE BEGIN SPI3_Init 0 */ - - /* USER CODE END SPI3_Init 0 */ - - LL_SPI_InitTypeDef SPI_InitStruct = {0}; - - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - - /* Peripheral clock enable */ - LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_SPI3); - - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC); - /**SPI3 GPIO Configuration - PC10 ------> SPI3_SCK - PC11 ------> SPI3_MISO - PC12 ------> SPI3_MOSI - */ - GPIO_InitStruct.Pin = LL_GPIO_PIN_10; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_6; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = LL_GPIO_PIN_11; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_6; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = LL_GPIO_PIN_12; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_6; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /* USER CODE BEGIN SPI3_Init 1 */ - - /* USER CODE END SPI3_Init 1 */ - SPI_InitStruct.TransferDirection = LL_SPI_FULL_DUPLEX; - SPI_InitStruct.Mode = LL_SPI_MODE_MASTER; - SPI_InitStruct.DataWidth = LL_SPI_DATAWIDTH_4BIT; - SPI_InitStruct.ClockPolarity = LL_SPI_POLARITY_LOW; - SPI_InitStruct.ClockPhase = LL_SPI_PHASE_1EDGE; - SPI_InitStruct.NSS = LL_SPI_NSS_SOFT; - SPI_InitStruct.BaudRate = LL_SPI_BAUDRATEPRESCALER_DIV32; - SPI_InitStruct.BitOrder = LL_SPI_MSB_FIRST; - SPI_InitStruct.CRCCalculation = LL_SPI_CRCCALCULATION_DISABLE; - SPI_InitStruct.CRCPoly = 7; - LL_SPI_Init(SPI3, &SPI_InitStruct); - LL_SPI_SetStandard(SPI3, LL_SPI_PROTOCOL_MOTOROLA); - LL_SPI_EnableNSSPulseMgt(SPI3); - /* USER CODE BEGIN SPI3_Init 2 */ - - /* USER CODE END SPI3_Init 2 */ -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ diff --git a/G431x8_CAN_TESTING/Core/Src/stm32g4xx_it.c b/G431x8_CAN_TESTING/Core/Src/stm32g4xx_it.c deleted file mode 100644 index dd322200e..000000000 --- a/G431x8_CAN_TESTING/Core/Src/stm32g4xx_it.c +++ /dev/null @@ -1,194 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file stm32g4xx_it.c - * @brief Interrupt Service Routines. - ****************************************************************************** - * @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 "stm32g4xx_it.h" - -#include "main.h" -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ -/* USER CODE END Includes */ - -/* Private typedef -----------------------------------------------------------*/ -/* USER CODE BEGIN TD */ - -/* USER CODE END TD */ - -/* Private define ------------------------------------------------------------*/ -/* USER CODE BEGIN PD */ - -/* USER CODE END PD */ - -/* Private macro -------------------------------------------------------------*/ -/* USER CODE BEGIN PM */ - -/* USER CODE END PM */ - -/* Private variables ---------------------------------------------------------*/ -/* USER CODE BEGIN PV */ - -/* USER CODE END PV */ - -/* Private function prototypes -----------------------------------------------*/ -/* USER CODE BEGIN PFP */ - -/* USER CODE END PFP */ - -/* Private user code ---------------------------------------------------------*/ -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/* External variables --------------------------------------------------------*/ -// extern FDCAN_HandleTypeDef hfdcan2; -/* USER CODE BEGIN EV */ - -/* USER CODE END EV */ - -/******************************************************************************/ -/* Cortex-M4 Processor Interruption and Exception Handlers */ -/******************************************************************************/ -/** - * @brief This function handles Non maskable interrupt. - */ -void NMI_Handler(void) -{ - /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ - - /* USER CODE END NonMaskableInt_IRQn 0 */ - /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ - while (1) {} - /* USER CODE END NonMaskableInt_IRQn 1 */ -} - -/** - * @brief This function handles Hard fault interrupt. - */ -void HardFault_Handler(void) -{ - /* USER CODE BEGIN HardFault_IRQn 0 */ - - /* USER CODE END HardFault_IRQn 0 */ - while (1) { - /* USER CODE BEGIN W1_HardFault_IRQn 0 */ - /* USER CODE END W1_HardFault_IRQn 0 */ - } -} - -/** - * @brief This function handles Memory management fault. - */ -void MemManage_Handler(void) -{ - /* USER CODE BEGIN MemoryManagement_IRQn 0 */ - - /* USER CODE END MemoryManagement_IRQn 0 */ - while (1) { - /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ - /* USER CODE END W1_MemoryManagement_IRQn 0 */ - } -} - -/** - * @brief This function handles Prefetch fault, memory access fault. - */ -void BusFault_Handler(void) -{ - /* USER CODE BEGIN BusFault_IRQn 0 */ - - /* USER CODE END BusFault_IRQn 0 */ - while (1) { - /* USER CODE BEGIN W1_BusFault_IRQn 0 */ - /* USER CODE END W1_BusFault_IRQn 0 */ - } -} - -/** - * @brief This function handles Undefined instruction or illegal state. - */ -void UsageFault_Handler(void) -{ - /* USER CODE BEGIN UsageFault_IRQn 0 */ - - /* USER CODE END UsageFault_IRQn 0 */ - while (1) { - /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ - /* USER CODE END W1_UsageFault_IRQn 0 */ - } -} - -/** - * @brief This function handles System service call via SWI instruction. - */ -void SVC_Handler(void) -{ - /* USER CODE BEGIN SVCall_IRQn 0 */ - - /* USER CODE END SVCall_IRQn 0 */ - /* USER CODE BEGIN SVCall_IRQn 1 */ - - /* USER CODE END SVCall_IRQn 1 */ -} - -/** - * @brief This function handles Debug monitor. - */ -void DebugMon_Handler(void) -{ - /* USER CODE BEGIN DebugMonitor_IRQn 0 */ - - /* USER CODE END DebugMonitor_IRQn 0 */ - /* USER CODE BEGIN DebugMonitor_IRQn 1 */ - - /* USER CODE END DebugMonitor_IRQn 1 */ -} - -/** - * @brief This function handles Pendable request for system service. - */ -void PendSV_Handler(void) -{ - /* USER CODE BEGIN PendSV_IRQn 0 */ - - /* USER CODE END PendSV_IRQn 0 */ - /* USER CODE BEGIN PendSV_IRQn 1 */ - - /* USER CODE END PendSV_IRQn 1 */ -} - -/** - * @brief This function handles System tick timer. - */ -void SysTick_Handler(void) -{ - /* USER CODE BEGIN SysTick_IRQn 0 */ - - /* USER CODE END SysTick_IRQn 0 */ - HAL_IncTick(); - /* USER CODE BEGIN SysTick_IRQn 1 */ - - /* USER CODE END SysTick_IRQn 1 */ -} - -/******************************************************************************/ -/* STM32G4xx Peripheral Interrupt Handlers */ -/* Add here the Interrupt Handlers for the used peripherals. */ -/* For the available peripheral interrupt handler names, */ -/* please refer to the startup file (startup_stm32g4xx.s). */ -/******************************************************************************/ diff --git a/G431x8_CAN_TESTING/Core/Src/tim.c b/G431x8_CAN_TESTING/Core/Src/tim.c deleted file mode 100644 index 7f521c3bf..000000000 --- a/G431x8_CAN_TESTING/Core/Src/tim.c +++ /dev/null @@ -1,79 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file tim.c - * @brief This file provides code for the configuration - * of the TIM instances. - ****************************************************************************** - * @attention - * - * Copyright (c) 2025 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 "tim.h" - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/* TIM2 init function */ -void MX_TIM2_Init(void) -{ - - /* USER CODE BEGIN TIM2_Init 0 */ - - /* USER CODE END TIM2_Init 0 */ - - LL_TIM_InitTypeDef TIM_InitStruct = {0}; - LL_TIM_OC_InitTypeDef TIM_OC_InitStruct = {0}; - - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - /* Peripheral clock enable */ - LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM2); - - /* USER CODE BEGIN TIM2_Init 1 */ - - /* USER CODE END TIM2_Init 1 */ - TIM_InitStruct.Prescaler = 0; - TIM_InitStruct.CounterMode = LL_TIM_COUNTERMODE_UP; - TIM_InitStruct.Autoreload = 4294967295; - TIM_InitStruct.ClockDivision = LL_TIM_CLOCKDIVISION_DIV1; - LL_TIM_Init(TIM2, &TIM_InitStruct); - LL_TIM_DisableARRPreload(TIM2); - LL_TIM_SetClockSource(TIM2, LL_TIM_CLOCKSOURCE_INTERNAL); - TIM_OC_InitStruct.OCMode = LL_TIM_OCMODE_FORCED_ACTIVE; - TIM_OC_InitStruct.OCState = LL_TIM_OCSTATE_DISABLE; - TIM_OC_InitStruct.OCNState = LL_TIM_OCSTATE_DISABLE; - TIM_OC_InitStruct.CompareValue = 0; - TIM_OC_InitStruct.OCPolarity = LL_TIM_OCPOLARITY_HIGH; - LL_TIM_OC_Init(TIM2, LL_TIM_CHANNEL_CH1, &TIM_OC_InitStruct); - LL_TIM_OC_DisableFast(TIM2, LL_TIM_CHANNEL_CH1); - LL_TIM_SetTriggerOutput(TIM2, LL_TIM_TRGO_RESET); - LL_TIM_DisableMasterSlaveMode(TIM2); - /* USER CODE BEGIN TIM2_Init 2 */ - - /* USER CODE END TIM2_Init 2 */ - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA); - /**TIM2 GPIO Configuration - PA0 ------> TIM2_CH1 - */ - GPIO_InitStruct.Pin = LL_GPIO_PIN_0; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_1; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ diff --git a/G431x8_CAN_TESTING/Core/Src/usart.c b/G431x8_CAN_TESTING/Core/Src/usart.c deleted file mode 100644 index 41561862c..000000000 --- a/G431x8_CAN_TESTING/Core/Src/usart.c +++ /dev/null @@ -1,184 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file usart.c - * @brief This file provides code for the configuration - * of the USART instances. - ****************************************************************************** - * @attention - * - * Copyright (c) 2025 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 "usart.h" - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/* LPUART1 init function */ - -void MX_LPUART1_UART_Init(void) -{ - - /* USER CODE BEGIN LPUART1_Init 0 */ - - /* USER CODE END LPUART1_Init 0 */ - - LL_LPUART_InitTypeDef LPUART_InitStruct = {0}; - - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - - LL_RCC_SetLPUARTClockSource(LL_RCC_LPUART1_CLKSOURCE_HSI); - - /* Peripheral clock enable */ - LL_APB1_GRP2_EnableClock(LL_APB1_GRP2_PERIPH_LPUART1); - - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA); - /**LPUART1 GPIO Configuration - PA2 ------> LPUART1_TX - PA3 ------> LPUART1_RX - */ - GPIO_InitStruct.Pin = LL_GPIO_PIN_2; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_12; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = LL_GPIO_PIN_3; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_12; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /* USER CODE BEGIN LPUART1_Init 1 */ - - /* USER CODE END LPUART1_Init 1 */ - LPUART_InitStruct.PrescalerValue = LL_LPUART_PRESCALER_DIV1; - LPUART_InitStruct.BaudRate = 115200; - LPUART_InitStruct.DataWidth = LL_LPUART_DATAWIDTH_8B; - LPUART_InitStruct.StopBits = LL_LPUART_STOPBITS_1; - LPUART_InitStruct.Parity = LL_LPUART_PARITY_NONE; - LPUART_InitStruct.TransferDirection = LL_LPUART_DIRECTION_TX_RX; - LPUART_InitStruct.HardwareFlowControl = LL_LPUART_HWCONTROL_NONE; - LL_LPUART_Init(LPUART1, &LPUART_InitStruct); - LL_LPUART_SetTXFIFOThreshold(LPUART1, LL_LPUART_FIFOTHRESHOLD_1_8); - LL_LPUART_SetRXFIFOThreshold(LPUART1, LL_LPUART_FIFOTHRESHOLD_1_8); - LL_LPUART_DisableFIFO(LPUART1); - - /* USER CODE BEGIN WKUPType LPUART1 */ - - /* USER CODE END WKUPType LPUART1 */ - - LL_LPUART_Enable(LPUART1); - - /* Polling LPUART1 initialisation */ - while ((!(LL_LPUART_IsActiveFlag_TEACK(LPUART1))) || (!(LL_LPUART_IsActiveFlag_REACK(LPUART1)))) {} - /* USER CODE BEGIN LPUART1_Init 2 */ - - /* USER CODE END LPUART1_Init 2 */ -} -/* USART1 init function */ - -void MX_USART1_UART_Init(void) -{ - - /* USER CODE BEGIN USART1_Init 0 */ - - /* USER CODE END USART1_Init 0 */ - - LL_USART_InitTypeDef USART_InitStruct = {0}; - - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - - LL_RCC_SetUSARTClockSource(LL_RCC_USART1_CLKSOURCE_PCLK2); - - /* Peripheral clock enable */ - LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_USART1); - - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOB); - /**USART1 GPIO Configuration - PC5 ------> USART1_RX - PA11 ------> USART1_CTS - PA12 ------> USART1_RTS - PB6 ------> USART1_TX - */ - GPIO_InitStruct.Pin = LL_GPIO_PIN_5; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_7; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = LL_GPIO_PIN_11; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_7; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = LL_GPIO_PIN_12; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_7; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = LL_GPIO_PIN_6; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_7; - LL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - /* USER CODE BEGIN USART1_Init 1 */ - - /* USER CODE END USART1_Init 1 */ - USART_InitStruct.PrescalerValue = LL_USART_PRESCALER_DIV1; - USART_InitStruct.BaudRate = 115200; - USART_InitStruct.DataWidth = LL_USART_DATAWIDTH_8B; - USART_InitStruct.StopBits = LL_USART_STOPBITS_1; - USART_InitStruct.Parity = LL_USART_PARITY_NONE; - USART_InitStruct.TransferDirection = LL_USART_DIRECTION_TX_RX; - USART_InitStruct.HardwareFlowControl = LL_USART_HWCONTROL_RTS_CTS; - USART_InitStruct.OverSampling = LL_USART_OVERSAMPLING_16; - LL_USART_Init(USART1, &USART_InitStruct); - LL_USART_SetTXFIFOThreshold(USART1, LL_USART_FIFOTHRESHOLD_1_8); - LL_USART_SetRXFIFOThreshold(USART1, LL_USART_FIFOTHRESHOLD_1_8); - LL_USART_DisableFIFO(USART1); - LL_USART_ConfigAsyncMode(USART1); - - /* USER CODE BEGIN WKUPType USART1 */ - - /* USER CODE END WKUPType USART1 */ - - LL_USART_Enable(USART1); - - /* Polling USART1 initialisation */ - while ((!(LL_USART_IsActiveFlag_TEACK(USART1))) || (!(LL_USART_IsActiveFlag_REACK(USART1)))) {} - /* USER CODE BEGIN USART1_Init 2 */ - - /* USER CODE END USART1_Init 2 */ -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ diff --git a/G431x8_CAN_TESTING/G431x8_CAN_BASIC_TEST/CMakeLists.txt b/G431x8_CAN_TESTING/G431x8_CAN_BASIC_TEST/CMakeLists.txt deleted file mode 100644 index ccedc8c6d..000000000 --- a/G431x8_CAN_TESTING/G431x8_CAN_BASIC_TEST/CMakeLists.txt +++ /dev/null @@ -1,60 +0,0 @@ -cmake_minimum_required(VERSION 3.25) - -# Setup compiler settings -set(CMAKE_C_STANDARD 11) -set(CMAKE_C_STANDARD_REQUIRED ON) -set(CMAKE_C_EXTENSIONS ON) - -# Define the build type -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Debug") -endif() - -# Enable compile command to ease indexing with e.g. clangd -set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE) - -# Enable CMake support for ASM and C languages -enable_language( - C - ASM -) - -# Core project settings -project(${CMAKE_PROJECT_NAME}) - -# what, does in fact not get the filename of somthing but rather the name of the project from the path -get_filename_component(PROJECT_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME) - -add_library(${PROJECT_NAME}_USER_CODE INTERFACE) - -target_sources( - ${PROJECT_NAME}_USER_CODE - INTERFACE - ../Core/Src/adc.c - ../Core/Src/crc.c - ../Core/Src/dma.c - ../Core/Src/gpio.c - ../Core/Src/i2c.c - main.c - ../Core/Src/spi.c - ../Core/Src/stm32g4xx_hal_msp.c - ../Core/Src/stm32g4xx_it.c - ../Core/Src/tim.c - ../Core/Src/usart.c -) - -set_target_properties( - ${NAME} - PROPERTIES - OUTPUT_NAME - "CAN_${NAME}" -) - -target_link_libraries(${PROJECT_NAME}_USER_CODE INTERFACE PERIPHERAL_CAN_LIB) - -target_include_directories( - ${PROJECT_NAME}_USER_CODE - INTERFACE - ../Core/Inc - . -) diff --git a/G431x8_CAN_TESTING/G431x8_CAN_BASIC_TEST/can_cfg.h b/G431x8_CAN_TESTING/G431x8_CAN_BASIC_TEST/can_cfg.h deleted file mode 100644 index 0e987b82d..000000000 --- a/G431x8_CAN_TESTING/G431x8_CAN_BASIC_TEST/can_cfg.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef CAN_CFG_H -#define CAN_CFG_H - -#define USECAN1 -#define TX_BUFFER_1_SIZE 10 - -#endif diff --git a/G431x8_CAN_TESTING/G431x8_CAN_BASIC_TEST/can_external_test_cfg.h b/G431x8_CAN_TESTING/G431x8_CAN_BASIC_TEST/can_external_test_cfg.h deleted file mode 100644 index 0b7e7a815..000000000 --- a/G431x8_CAN_TESTING/G431x8_CAN_BASIC_TEST/can_external_test_cfg.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef CAN_BASIC_TEST_CFG_H -#define CAN_BASIC_TEST_CFG_H - -#define NODE_ID 1 - -#endif diff --git a/G431x8_CAN_TESTING/G431x8_CAN_BASIC_TEST/main.c b/G431x8_CAN_TESTING/G431x8_CAN_BASIC_TEST/main.c deleted file mode 100644 index f10f81707..000000000 --- a/G431x8_CAN_TESTING/G431x8_CAN_BASIC_TEST/main.c +++ /dev/null @@ -1,274 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file : main.c - * @brief : Main program body - ****************************************************************************** - * @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 "main.h" - -#include "adc.h" -#include "can.h" // Assume this works -#include "can_tests.h" -#include "dma.h" -#include "fdcan.h" -#include "gpio.h" -#include "i2c.h" -#include "spi.h" -#include "tim.h" -#include "usart.h" - -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ -#include "Logomatic.h" -/* USER CODE END Includes */ - -/* Private typedef -----------------------------------------------------------*/ -/* USER CODE BEGIN PTD */ - -/* USER CODE END PTD */ - -/* Private define ------------------------------------------------------------*/ -/* USER CODE BEGIN PD */ - -/* USER CODE END PD */ - -/* Private macro -------------------------------------------------------------*/ -/* USER CODE BEGIN PM */ - -/* USER CODE END PM */ - -/* Private variables ---------------------------------------------------------*/ - -/* USER CODE BEGIN PV */ -/* USER CODE END PV */ - -/* Private function prototypes -----------------------------------------------*/ -void SystemClock_Config(void); -/* USER CODE BEGIN PFP */ - -/* USER CODE END PFP */ - -/* Private user code ---------------------------------------------------------*/ -/* USER CODE BEGIN 0 */ -/* Enable ITM for SWO output */ -static void ITM_Enable(void) -{ - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOB); - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - GPIO_InitStruct.Pin = LL_GPIO_PIN_3; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_0; - LL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - DBGMCU->CR |= DBGMCU_CR_TRACE_IOEN; - - /* Enable TRC (Trace) */ - CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; - - /* Configure TPI for SWO output (set prescaler for 2MHz SWO clock) */ - TPI->SPPR = 2U; /* 2 = Manchester/async UART mode */ - TPI->ACPR = 84U; /* Prescaler: (170 MHz / (84+1) / 2) ≈ 1MHz SWO */ - - ITM->TER |= (1UL << 0); - ITM->TCR |= (ITM_TCR_ITMENA_Msk | ITM_TCR_SWOENA_Msk); -} -// static int toggleze = 0; -/* USER CODE END 0 */ - -/** - * @brief The application entry point. - * @retval int - */ -int main(void) -{ - /* USER CODE BEGIN 1 */ - - /* USER CODE END 1 */ - - /* MCU - * Configuration--------------------------------------------------------*/ - - /* Reset of all peripherals, Initializes the Flash interface and the - * Systick. */ - HAL_Init(); - /* USER CODE BEGIN Init */ - ITM_Enable(); - /* USER CODE END Init */ - - /* Configure the system clock */ - SystemClock_Config(); - - /* USER CODE BEGIN SysInit */ - - /* USER CODE END SysInit */ - - /* Initialize all configured peripherals */ - MX_GPIO_Init(); - MX_DMA_Init(); - // MX_FDCAN2_Init(); - MX_ADC1_Init(); - MX_LPUART1_UART_Init(); - MX_I2C2_Init(); - MX_USART1_UART_Init(); - MX_SPI3_Init(); - MX_TIM2_Init(); - - /* USER CODE BEGIN 2 */ - - LOGOMATIC("Booted!\n"); - - // LOGOMATIC("running can_basic_test:\n"); - can_basic_test(); - - /* Infinite loop */ - /* USER CODE BEGIN WHILE */ - while (1) { - /* USER CODE END WHILE */ - LOGOMATIC("Main Loop\n"); - LL_mDelay(10000); - - // Receive on GPIOs - // HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, toggleze ? GPIO_PIN_SET - // : GPIO_PIN_RESET); HAL_Delay(1000); msg.data[0] = toggleze ? - // 0x00 : 0x80; can_send(data_can, &msg); - - // RCC->CFGR |= RCC_CFGR_SW; - /* USER CODE BEGIN 3 */ - } -} - -/** - * @brief System Clock Configuration - * @retval None - */ - -// void SystemClock_Config(void) -// { -// LL_FLASH_SetLatency(LL_FLASH_LATENCY_4); -// while (LL_FLASH_GetLatency() != LL_FLASH_LATENCY_4) { -// } -// LL_PWR_EnableRange1BoostMode(); -// LL_RCC_HSE_Enable(); - -// /* Wait till HSE is ready */ -// while (LL_RCC_HSE_IsReady() != 1) { -// } - -// LL_RCC_HSE_EnableCSS(); -// LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSE, LL_RCC_PLLM_DIV_1, 20, -// LL_RCC_PLLR_DIV_2); -// //LL_RCC_PLL_ConfigDomain_48M(LL_RCC_PLLSOURCE_HSE, ); -// LL_RCC_PLL_EnableDomain_SYS(); -// LL_RCC_PLL_Enable(); -// /* Wait till PLL is ready */ -// while (LL_RCC_PLL_IsReady() != 1) { -// } - -// LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL); -// LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_2); -// /* Wait till System clock is ready */ -// while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL) { -// } - -// /* Insure 1us transition state at intermediate medium speed clock*/ -// for (__IO uint32_t i = (170 >> 1); i != 0; i--) -// ; - -// /* Set AHB prescaler*/ -// LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1); -// LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1); -// LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_1); -// LL_SetSystemCoreClock(160000000); - -// /* Update the time base */ -// if (HAL_InitTick(TICK_INT_PRIORITY) != HAL_OK) { -// Error_Handler(); -// } -// }*/ -void SystemClock_Config(void) -{ - LL_FLASH_SetLatency(LL_FLASH_LATENCY_4); - while (LL_FLASH_GetLatency() != LL_FLASH_LATENCY_4) {} - LL_PWR_EnableRange1BoostMode(); - LL_RCC_HSI_Enable(); - /* Wait till HSI is ready */ - while (LL_RCC_HSI_IsReady() != 1) {} - - LL_RCC_HSI_SetCalibTrimming(64); - LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSI, LL_RCC_PLLM_DIV_4, 85, LL_RCC_PLLR_DIV_2); - LL_RCC_PLL_EnableDomain_SYS(); - LL_RCC_PLL_Enable(); - /* Wait till PLL is ready */ - while (LL_RCC_PLL_IsReady() != 1) {} - - LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL); - // LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1); - /* Wait till System clock is ready */ - while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL) {} - - /* Insure 1us transition state at intermediate medium speed clock*/ - for (__IO uint32_t i = (170 >> 1); i != 0; i--) - ; - - /* Set AHB prescaler*/ - LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1); - LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1); - LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_1); - LL_SetSystemCoreClock(170000000); - - /* Update the time base */ - if (HAL_InitTick(TICK_INT_PRIORITY) != HAL_OK) { - Error_Handler(); - } -} - -/* USER CODE BEGIN 4 */ - -/* USER CODE END 4 */ - -/** - * @brief This function is executed in case of error occurrence. - * @retval None - */ -void Error_Handler(void) -{ - /* USER CODE BEGIN Error_Handler_Debug */ - /* User can add his own implementation to report the HAL error return - * state */ - __disable_irq(); - while (1) {} - /* USER CODE END Error_Handler_Debug */ -} -#ifdef USE_FULL_ASSERT -/** - * @brief Reports the name of the source file and the source line number - * where the assert_param error has occurred. - * @param file: pointer to the source file name - * @param line: assert_param error line source number - * @retval None - */ -void assert_failed(uint8_t *file, uint32_t line) -{ - /* USER CODE BEGIN 6 */ - /* User can add his own implementation to report the file name and line - number, ex: printf("Wrong parameters value: file %s on line %d\r\n", - file, line) */ - /* USER CODE END 6 */ -} -#endif /* USE_FULL_ASSERT */ diff --git a/G431x8_CAN_TESTING/G4PERTESTING.ioc b/G431x8_CAN_TESTING/G4PERTESTING.ioc deleted file mode 100644 index 8cf1860b1..000000000 --- a/G431x8_CAN_TESTING/G4PERTESTING.ioc +++ /dev/null @@ -1,382 +0,0 @@ -#MicroXplorer Configuration settings - do not modify -ADC1.Channel-2\#ChannelRegularConversion=ADC_CHANNEL_5 -ADC1.Channel-3\#ChannelRegularConversion=ADC_CHANNEL_7 -ADC1.Channel-4\#ChannelRegularConversion=ADC_CHANNEL_8 -ADC1.Channel-5\#ChannelRegularConversion=ADC_CHANNEL_9 -ADC1.Channel-6\#ChannelRegularConversion=ADC_CHANNEL_12 -ADC1.Channel-7\#ChannelRegularConversion=ADC_CHANNEL_15 -ADC1.ClockPrescaler=ADC_CLOCK_ASYNC_DIV256 -ADC1.CommonPathInternal=null|null|null|null -ADC1.ContinuousConvMode=ENABLE -ADC1.DMAContinuousRequests=ENABLE -ADC1.EOCSelection=ADC_EOC_SEQ_CONV -ADC1.ExternalTrigConv=ADC_SOFTWARE_START -ADC1.IPParameters=Rank-2\#ChannelRegularConversion,Channel-2\#ChannelRegularConversion,SamplingTime-2\#ChannelRegularConversion,OffsetNumber-2\#ChannelRegularConversion,NbrOfConversionFlag,master,Rank-3\#ChannelRegularConversion,Channel-3\#ChannelRegularConversion,SamplingTime-3\#ChannelRegularConversion,OffsetNumber-3\#ChannelRegularConversion,Rank-4\#ChannelRegularConversion,Channel-4\#ChannelRegularConversion,SamplingTime-4\#ChannelRegularConversion,OffsetNumber-4\#ChannelRegularConversion,Rank-5\#ChannelRegularConversion,Channel-5\#ChannelRegularConversion,SamplingTime-5\#ChannelRegularConversion,OffsetNumber-5\#ChannelRegularConversion,Rank-6\#ChannelRegularConversion,Channel-6\#ChannelRegularConversion,SamplingTime-6\#ChannelRegularConversion,OffsetNumber-6\#ChannelRegularConversion,Rank-7\#ChannelRegularConversion,Channel-7\#ChannelRegularConversion,SamplingTime-7\#ChannelRegularConversion,OffsetNumber-7\#ChannelRegularConversion,NbrOfConversion,ContinuousConvMode,DMAContinuousRequests,ClockPrescaler,EOCSelection,ExternalTrigConv,CommonPathInternal -ADC1.NbrOfConversion=6 -ADC1.NbrOfConversionFlag=1 -ADC1.OffsetNumber-2\#ChannelRegularConversion=ADC_OFFSET_NONE -ADC1.OffsetNumber-3\#ChannelRegularConversion=ADC_OFFSET_NONE -ADC1.OffsetNumber-4\#ChannelRegularConversion=ADC_OFFSET_NONE -ADC1.OffsetNumber-5\#ChannelRegularConversion=ADC_OFFSET_NONE -ADC1.OffsetNumber-6\#ChannelRegularConversion=ADC_OFFSET_NONE -ADC1.OffsetNumber-7\#ChannelRegularConversion=ADC_OFFSET_NONE -ADC1.Rank-2\#ChannelRegularConversion=1 -ADC1.Rank-3\#ChannelRegularConversion=2 -ADC1.Rank-4\#ChannelRegularConversion=3 -ADC1.Rank-5\#ChannelRegularConversion=4 -ADC1.Rank-6\#ChannelRegularConversion=5 -ADC1.Rank-7\#ChannelRegularConversion=6 -ADC1.SamplingTime-2\#ChannelRegularConversion=ADC_SAMPLETIME_92CYCLES_5 -ADC1.SamplingTime-3\#ChannelRegularConversion=ADC_SAMPLETIME_92CYCLES_5 -ADC1.SamplingTime-4\#ChannelRegularConversion=ADC_SAMPLETIME_92CYCLES_5 -ADC1.SamplingTime-5\#ChannelRegularConversion=ADC_SAMPLETIME_92CYCLES_5 -ADC1.SamplingTime-6\#ChannelRegularConversion=ADC_SAMPLETIME_92CYCLES_5 -ADC1.SamplingTime-7\#ChannelRegularConversion=ADC_SAMPLETIME_92CYCLES_5 -ADC1.master=1 -CAD.formats=[] -CAD.pinconfig=Dual -CAD.provider= -Dma.ADC1.0.Direction=DMA_PERIPH_TO_MEMORY -Dma.ADC1.0.EventEnable=DISABLE -Dma.ADC1.0.Instance=DMA1_Channel1 -Dma.ADC1.0.MemDataAlignment=DMA_MDATAALIGN_HALFWORD -Dma.ADC1.0.MemInc=DMA_MINC_ENABLE -Dma.ADC1.0.Mode=DMA_CIRCULAR -Dma.ADC1.0.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD -Dma.ADC1.0.PeriphInc=DMA_PINC_DISABLE -Dma.ADC1.0.Polarity=HAL_DMAMUX_REQ_GEN_RISING -Dma.ADC1.0.Priority=DMA_PRIORITY_LOW -Dma.ADC1.0.RequestNumber=1 -Dma.ADC1.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -Dma.ADC1.0.SignalID=NONE -Dma.ADC1.0.SyncEnable=DISABLE -Dma.ADC1.0.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT -Dma.ADC1.0.SyncRequestNumber=1 -Dma.ADC1.0.SyncSignalID=NONE -Dma.Request0=ADC1 -Dma.RequestsNb=1 -FDCAN2.AutoRetransmission=ENABLE -FDCAN2.CalculateBaudRateNominal=1000000 -FDCAN2.CalculateTimeBitNominal=1000 -FDCAN2.CalculateTimeQuantumNominal=6.25 -FDCAN2.DataPrescaler=8 -FDCAN2.DataSyncJumpWidth=16 -FDCAN2.DataTimeSeg1=14 -FDCAN2.DataTimeSeg2=5 -FDCAN2.ExtFiltersNbr=2 -FDCAN2.FrameFormat=FDCAN_FRAME_CLASSIC -FDCAN2.IPParameters=CalculateTimeQuantumNominal,CalculateTimeBitNominal,CalculateBaudRateNominal,FrameFormat,NominalTimeSeg1,NominalTimeSeg2,NominalPrescaler,AutoRetransmission,StdFiltersNbr,TransmitPause,NominalSyncJumpWidth,DataTimeSeg1,DataTimeSeg2,DataPrescaler,DataSyncJumpWidth,ExtFiltersNbr,ProtocolException -FDCAN2.NominalPrescaler=1 -FDCAN2.NominalSyncJumpWidth=16 -FDCAN2.NominalTimeSeg1=119 -FDCAN2.NominalTimeSeg2=40 -FDCAN2.ProtocolException=ENABLE -FDCAN2.StdFiltersNbr=0 -FDCAN2.TransmitPause=DISABLE -File.Version=6 -GPIO.groupedBy=Group By Peripherals -I2C2.IPParameters=Timing -I2C2.Timing=0x30D29DE4 -KeepUserPlacement=false -LPUART1.BaudRate=115200 -LPUART1.IPParameters=BaudRate -Mcu.CPN=STM32G474RET6 -Mcu.Family=STM32G4 -Mcu.IP0=ADC1 -Mcu.IP1=DMA -Mcu.IP10=USART1 -Mcu.IP2=FDCAN2 -Mcu.IP3=I2C2 -Mcu.IP4=LPUART1 -Mcu.IP5=NVIC -Mcu.IP6=RCC -Mcu.IP7=SPI3 -Mcu.IP8=SYS -Mcu.IP9=TIM2 -Mcu.IPNb=11 -Mcu.Name=STM32G474R(B-C-E)Tx -Mcu.Package=LQFP64 -Mcu.Pin0=PF0-OSC_IN -Mcu.Pin1=PF1-OSC_OUT -Mcu.Pin10=PA7 -Mcu.Pin11=PC4 -Mcu.Pin12=PC5 -Mcu.Pin13=PB0 -Mcu.Pin14=PB1 -Mcu.Pin15=PB11 -Mcu.Pin16=PB12 -Mcu.Pin17=PB13 -Mcu.Pin18=PB14 -Mcu.Pin19=PB15 -Mcu.Pin2=PC1 -Mcu.Pin20=PA8 -Mcu.Pin21=PA11 -Mcu.Pin22=PA12 -Mcu.Pin23=PA13 -Mcu.Pin24=PA14 -Mcu.Pin25=PC10 -Mcu.Pin26=PC11 -Mcu.Pin27=PC12 -Mcu.Pin28=PB3 -Mcu.Pin29=PB4 -Mcu.Pin3=PC2 -Mcu.Pin30=PB5 -Mcu.Pin31=PB6 -Mcu.Pin32=PB7 -Mcu.Pin33=PB8-BOOT0 -Mcu.Pin34=PB9 -Mcu.Pin35=VP_SYS_VS_Systick -Mcu.Pin36=VP_SYS_VS_DBSignals -Mcu.Pin37=VP_TIM2_VS_ClockSourceINT -Mcu.Pin4=PC3 -Mcu.Pin5=PA0 -Mcu.Pin6=PA2 -Mcu.Pin7=PA3 -Mcu.Pin8=PA5 -Mcu.Pin9=PA6 -Mcu.PinsNb=38 -Mcu.ThirdPartyNb=0 -Mcu.UserConstants= -Mcu.UserName=STM32G474RETx -MxCube.Version=6.15.0 -MxDb.Version=DB.6.0.150 -NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.FDCAN2_IT0_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true -NVIC.ForceEnableDMAVector=false -NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:false -NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 -NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:false -NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -PA0.Signal=S_TIM2_CH1 -PA11.Locked=true -PA11.Mode=CTS_RTS -PA11.Signal=USART1_CTS -PA12.Locked=true -PA12.Mode=CTS_RTS -PA12.Signal=USART1_RTS -PA13.Locked=true -PA13.Mode=Trace_Asynchronous_SW -PA13.Signal=SYS_JTMS-SWDIO -PA14.Locked=true -PA14.Mode=Trace_Asynchronous_SW -PA14.Signal=SYS_JTCK-SWCLK -PA2.GPIOParameters=GPIO_Speed -PA2.GPIO_Speed=GPIO_SPEED_FREQ_HIGH -PA2.Locked=true -PA2.Mode=Asynchronous -PA2.Signal=LPUART1_TX -PA3.GPIOParameters=GPIO_Speed -PA3.GPIO_Speed=GPIO_SPEED_FREQ_HIGH -PA3.Locked=true -PA3.Mode=Asynchronous -PA3.Signal=LPUART1_RX -PA5.GPIOParameters=GPIO_Label -PA5.GPIO_Label=BLINKY -PA5.Locked=true -PA5.Signal=GPIO_Output -PA6.GPIOParameters=GPIO_Label -PA6.GPIO_Label=IMD_SENSE -PA6.Locked=true -PA6.Signal=ADC2_IN3 -PA7.GPIOParameters=GPIO_Label -PA7.GPIO_Label=AMS_SENSE -PA7.Locked=true -PA7.Signal=ADC2_IN4 -PA8.Mode=I2C -PA8.Signal=I2C2_SDA -PB0.GPIOParameters=GPIO_Label -PB0.GPIO_Label=BRAKE_F_SIGNAL -PB0.Locked=true -PB0.Mode=IN15-Single-Ended -PB0.Signal=ADC1_IN15 -PB1.GPIOParameters=GPIO_Label -PB1.GPIO_Label=BRAKE_R_SIGNAL -PB1.Locked=true -PB1.Mode=IN12-Single-Ended -PB1.Signal=ADC1_IN12 -PB11.GPIOParameters=GPIO_Label -PB11.GPIO_Label=LED_TEST -PB11.Locked=true -PB11.Signal=GPIO_Output -PB12.GPIOParameters=GPIO_Speed,GPIO_PuPd -PB12.GPIO_PuPd=GPIO_PULLUP -PB12.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH -PB12.Locked=true -PB12.Mode=FDCAN_Activate -PB12.Signal=FDCAN2_RX -PB13.GPIOParameters=GPIO_Speed -PB13.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH -PB13.Locked=true -PB13.Mode=FDCAN_Activate -PB13.Signal=FDCAN2_TX -PB14.GPIOParameters=GPIO_Label -PB14.GPIO_Label=AUX_SIGNAL -PB14.Locked=true -PB14.Mode=IN5-Single-Ended -PB14.Signal=ADC1_IN5 -PB15.GPIOParameters=GPIO_Label -PB15.GPIO_Label=STEERING_ANGLE -PB15.Locked=true -PB15.Signal=ADC2_IN15 -PB3.Locked=true -PB3.Mode=Trace_Asynchronous_SW -PB3.Signal=SYS_JTDO-SWO -PB4.GPIOParameters=GPIO_Label -PB4.GPIO_Label=BRAKE_LIGHT -PB4.Locked=true -PB4.Signal=GPIO_Output -PB5.GPIOParameters=GPIO_Label -PB5.GPIO_Label=TSSI_G_CONTROL -PB5.Locked=true -PB5.Signal=GPIO_Output -PB6.Locked=true -PB6.Mode=Asynchronous -PB6.Signal=USART1_TX -PB7.Locked=true -PB7.Signal=UART4_CTS -PB8-BOOT0.GPIOParameters=GPIO_Label -PB8-BOOT0.GPIO_Label=AUX_CONTROL -PB8-BOOT0.Locked=true -PB8-BOOT0.Signal=GPIO_Output -PB9.GPIOParameters=GPIO_Label -PB9.GPIO_Label=SOFTWARE_OK_CONTROL -PB9.Locked=true -PB9.Signal=GPIO_Output -PC1.GPIOParameters=GPIO_Label -PC1.GPIO_Label=BSPD_SIGNAL -PC1.Locked=true -PC1.Mode=IN7-Single-Ended -PC1.Signal=ADC1_IN7 -PC10.Mode=Full_Duplex_Master -PC10.Signal=SPI3_SCK -PC11.Mode=Full_Duplex_Master -PC11.Signal=SPI3_MISO -PC12.Mode=Full_Duplex_Master -PC12.Signal=SPI3_MOSI -PC2.GPIOParameters=GPIO_Label -PC2.GPIO_Label=APPS1_SIGNAL -PC2.Locked=true -PC2.Mode=IN8-Single-Ended -PC2.Signal=ADC1_IN8 -PC3.GPIOParameters=GPIO_Label -PC3.GPIO_Label=APPS2_SIGNAL -PC3.Locked=true -PC3.Mode=IN9-Single-Ended -PC3.Signal=ADC1_IN9 -PC4.Mode=I2C -PC4.Signal=I2C2_SCL -PC5.Mode=Asynchronous -PC5.Signal=USART1_RX -PF0-OSC_IN.Locked=true -PF0-OSC_IN.Mode=HSE-External-Oscillator -PF0-OSC_IN.Signal=RCC_OSC_IN -PF1-OSC_OUT.Locked=true -PF1-OSC_OUT.Mode=HSE-External-Oscillator -PF1-OSC_OUT.Signal=RCC_OSC_OUT -PinOutPanel.RotationAngle=180 -ProjectManager.AskForMigrate=true -ProjectManager.BackupPrevious=false -ProjectManager.CompilerLinker=GCC -ProjectManager.CompilerOptimize=6 -ProjectManager.ComputerToolchain=false -ProjectManager.CoupleFile=true -ProjectManager.CustomerFirmwarePackage= -ProjectManager.DefaultFWLocation=true -ProjectManager.DeletePrevious=true -ProjectManager.DeviceId=STM32G474RETx -ProjectManager.FirmwarePackage=STM32Cube FW_G4 V1.6.1 -ProjectManager.FreePins=true -ProjectManager.HalAssertFull=false -ProjectManager.HeapSize=0x200 -ProjectManager.KeepUserCode=true -ProjectManager.LastFirmware=true -ProjectManager.LibraryCopy=0 -ProjectManager.MainLocation=Core/Src -ProjectManager.NoMain=false -ProjectManager.PreviousToolchain= -ProjectManager.ProjectBuild=false -ProjectManager.ProjectFileName=G4PERTESTING.ioc -ProjectManager.ProjectName=G4PERTESTING -ProjectManager.ProjectStructure= -ProjectManager.RegisterCallBack= -ProjectManager.StackSize=0x400 -ProjectManager.TargetToolchain=CMake -ProjectManager.ToolChainLocation= -ProjectManager.UAScriptAfterPath= -ProjectManager.UAScriptBeforePath= -ProjectManager.UnderRoot=false -ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-LL-false,2-MX_GPIO_Init-GPIO-false-LL-true,3-MX_DMA_Init-DMA-false-LL-true,4-MX_FDCAN2_Init-FDCAN2-false-HAL-true,5-MX_ADC1_Init-ADC1-false-LL-true,6-MX_LPUART1_UART_Init-LPUART1-false-LL-true,7-MX_I2C2_Init-I2C2-false-LL-true,8-MX_USART1_UART_Init-USART1-false-LL-true,9-MX_SPI3_Init-SPI3-false-LL-true,10-MX_TIM2_Init-TIM2-false-LL-true -RCC.ADC12Freq_Value=160000000 -RCC.ADC345Freq_Value=160000000 -RCC.AHBFreq_Value=160000000 -RCC.APB1Freq_Value=160000000 -RCC.APB1TimFreq_Value=160000000 -RCC.APB2Freq_Value=160000000 -RCC.APB2TimFreq_Value=160000000 -RCC.CRSFreq_Value=48000000 -RCC.CortexFreq_Value=160000000 -RCC.EXTERNAL_CLOCK_VALUE=12288000 -RCC.EnbaleCSS=true -RCC.FCLKCortexFreq_Value=160000000 -RCC.FDCANFreq_Value=160000000 -RCC.FamilyName=M -RCC.HCLKFreq_Value=160000000 -RCC.HRTIM1Freq_Value=160000000 -RCC.HSE_VALUE=16000000 -RCC.HSI48_VALUE=48000000 -RCC.HSI_VALUE=16000000 -RCC.I2C1Freq_Value=160000000 -RCC.I2C2Freq_Value=160000000 -RCC.I2C3Freq_Value=160000000 -RCC.I2C4Freq_Value=160000000 -RCC.I2SFreq_Value=160000000 -RCC.IPParameters=ADC12Freq_Value,ADC345Freq_Value,AHBFreq_Value,APB1Freq_Value,APB1TimFreq_Value,APB2Freq_Value,APB2TimFreq_Value,CRSFreq_Value,CortexFreq_Value,EXTERNAL_CLOCK_VALUE,EnbaleCSS,FCLKCortexFreq_Value,FDCANFreq_Value,FamilyName,HCLKFreq_Value,HRTIM1Freq_Value,HSE_VALUE,HSI48_VALUE,HSI_VALUE,I2C1Freq_Value,I2C2Freq_Value,I2C3Freq_Value,I2C4Freq_Value,I2SFreq_Value,LPTIM1Freq_Value,LPUART1Freq_Value,LSCOPinFreq_Value,LSE_VALUE,LSI_VALUE,MCO1PinFreq_Value,PLLN,PLLPoutputFreq_Value,PLLQoutputFreq_Value,PLLRCLKFreq_Value,PLLSourceVirtual,PWRFreq_Value,QSPIFreq_Value,RNGFreq_Value,SAI1Freq_Value,SYSCLKFreq_VALUE,SYSCLKSource,UART4Freq_Value,UART5Freq_Value,USART1Freq_Value,USART2Freq_Value,USART3Freq_Value,USBFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value -RCC.LPTIM1Freq_Value=160000000 -RCC.LPUART1Freq_Value=160000000 -RCC.LSCOPinFreq_Value=32000 -RCC.LSE_VALUE=32768 -RCC.LSI_VALUE=32000 -RCC.MCO1PinFreq_Value=16000000 -RCC.PLLN=20 -RCC.PLLPoutputFreq_Value=160000000 -RCC.PLLQoutputFreq_Value=160000000 -RCC.PLLRCLKFreq_Value=160000000 -RCC.PLLSourceVirtual=RCC_PLLSOURCE_HSE -RCC.PWRFreq_Value=160000000 -RCC.QSPIFreq_Value=160000000 -RCC.RNGFreq_Value=160000000 -RCC.SAI1Freq_Value=160000000 -RCC.SYSCLKFreq_VALUE=160000000 -RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK -RCC.UART4Freq_Value=160000000 -RCC.UART5Freq_Value=160000000 -RCC.USART1Freq_Value=160000000 -RCC.USART2Freq_Value=160000000 -RCC.USART3Freq_Value=160000000 -RCC.USBFreq_Value=160000000 -RCC.VCOInputFreq_Value=16000000 -RCC.VCOOutputFreq_Value=320000000 -SH.S_TIM2_CH1.0=TIM2_CH1,Forced Output1 CH1 -SH.S_TIM2_CH1.ConfNb=1 -SPI3.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_32 -SPI3.CalculateBaudRate=5.0 MBits/s -SPI3.Direction=SPI_DIRECTION_2LINES -SPI3.IPParameters=VirtualType,Mode,Direction,BaudRatePrescaler,CalculateBaudRate -SPI3.Mode=SPI_MODE_MASTER -SPI3.VirtualType=VM_MASTER -TIM2.Channel-Forced\ Output1\ CH1=TIM_CHANNEL_1 -TIM2.IPParameters=Channel-Forced Output1 CH1 -USART1.IPParameters=VirtualMode-Asynchronous -USART1.VirtualMode-Asynchronous=VM_ASYNC -VP_SYS_VS_DBSignals.Mode=DisableDeadBatterySignals -VP_SYS_VS_DBSignals.Signal=SYS_VS_DBSignals -VP_SYS_VS_Systick.Mode=SysTick -VP_SYS_VS_Systick.Signal=SYS_VS_Systick -VP_TIM2_VS_ClockSourceINT.Mode=Internal -VP_TIM2_VS_ClockSourceINT.Signal=TIM2_VS_ClockSourceINT -board=custom diff --git a/G431x8_CAN_TESTING/README.md b/G431x8_CAN_TESTING/README.md deleted file mode 100644 index 558f1c125..000000000 --- a/G431x8_CAN_TESTING/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# STM32G474 CAN -Nucleo-G474RE-C04 - -Plug in the board following ST-LINK pinout -Compile and flash G4CANTESTING.elf diff --git a/G474xE_CAN_TESTING/CAN_BASIC_TEST/CMakeLists.txt b/G474xE_CAN_TESTING/CAN_BASIC_TEST/CMakeLists.txt deleted file mode 100644 index ccedc8c6d..000000000 --- a/G474xE_CAN_TESTING/CAN_BASIC_TEST/CMakeLists.txt +++ /dev/null @@ -1,60 +0,0 @@ -cmake_minimum_required(VERSION 3.25) - -# Setup compiler settings -set(CMAKE_C_STANDARD 11) -set(CMAKE_C_STANDARD_REQUIRED ON) -set(CMAKE_C_EXTENSIONS ON) - -# Define the build type -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Debug") -endif() - -# Enable compile command to ease indexing with e.g. clangd -set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE) - -# Enable CMake support for ASM and C languages -enable_language( - C - ASM -) - -# Core project settings -project(${CMAKE_PROJECT_NAME}) - -# what, does in fact not get the filename of somthing but rather the name of the project from the path -get_filename_component(PROJECT_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME) - -add_library(${PROJECT_NAME}_USER_CODE INTERFACE) - -target_sources( - ${PROJECT_NAME}_USER_CODE - INTERFACE - ../Core/Src/adc.c - ../Core/Src/crc.c - ../Core/Src/dma.c - ../Core/Src/gpio.c - ../Core/Src/i2c.c - main.c - ../Core/Src/spi.c - ../Core/Src/stm32g4xx_hal_msp.c - ../Core/Src/stm32g4xx_it.c - ../Core/Src/tim.c - ../Core/Src/usart.c -) - -set_target_properties( - ${NAME} - PROPERTIES - OUTPUT_NAME - "CAN_${NAME}" -) - -target_link_libraries(${PROJECT_NAME}_USER_CODE INTERFACE PERIPHERAL_CAN_LIB) - -target_include_directories( - ${PROJECT_NAME}_USER_CODE - INTERFACE - ../Core/Inc - . -) diff --git a/G474xE_CAN_TESTING/CAN_BASIC_TEST/can_cfg.h b/G474xE_CAN_TESTING/CAN_BASIC_TEST/can_cfg.h deleted file mode 100644 index 8a18e8882..000000000 --- a/G474xE_CAN_TESTING/CAN_BASIC_TEST/can_cfg.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef CAN_CFG_H -#define CAN_CFG_H - -#define USECAN1 -#define TX_BUFFER_1_SIZE 10 - -#define USECAN2 -#define TX_BUFFER_2_SIZE 10 - -#endif diff --git a/G474xE_CAN_TESTING/CAN_BASIC_TEST/can_external_test_cfg.h b/G474xE_CAN_TESTING/CAN_BASIC_TEST/can_external_test_cfg.h deleted file mode 100644 index 0b7e7a815..000000000 --- a/G474xE_CAN_TESTING/CAN_BASIC_TEST/can_external_test_cfg.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef CAN_BASIC_TEST_CFG_H -#define CAN_BASIC_TEST_CFG_H - -#define NODE_ID 1 - -#endif diff --git a/G474xE_CAN_TESTING/CAN_BASIC_TEST/main.c b/G474xE_CAN_TESTING/CAN_BASIC_TEST/main.c deleted file mode 100644 index f10f81707..000000000 --- a/G474xE_CAN_TESTING/CAN_BASIC_TEST/main.c +++ /dev/null @@ -1,274 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file : main.c - * @brief : Main program body - ****************************************************************************** - * @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 "main.h" - -#include "adc.h" -#include "can.h" // Assume this works -#include "can_tests.h" -#include "dma.h" -#include "fdcan.h" -#include "gpio.h" -#include "i2c.h" -#include "spi.h" -#include "tim.h" -#include "usart.h" - -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ -#include "Logomatic.h" -/* USER CODE END Includes */ - -/* Private typedef -----------------------------------------------------------*/ -/* USER CODE BEGIN PTD */ - -/* USER CODE END PTD */ - -/* Private define ------------------------------------------------------------*/ -/* USER CODE BEGIN PD */ - -/* USER CODE END PD */ - -/* Private macro -------------------------------------------------------------*/ -/* USER CODE BEGIN PM */ - -/* USER CODE END PM */ - -/* Private variables ---------------------------------------------------------*/ - -/* USER CODE BEGIN PV */ -/* USER CODE END PV */ - -/* Private function prototypes -----------------------------------------------*/ -void SystemClock_Config(void); -/* USER CODE BEGIN PFP */ - -/* USER CODE END PFP */ - -/* Private user code ---------------------------------------------------------*/ -/* USER CODE BEGIN 0 */ -/* Enable ITM for SWO output */ -static void ITM_Enable(void) -{ - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOB); - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - GPIO_InitStruct.Pin = LL_GPIO_PIN_3; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_0; - LL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - DBGMCU->CR |= DBGMCU_CR_TRACE_IOEN; - - /* Enable TRC (Trace) */ - CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; - - /* Configure TPI for SWO output (set prescaler for 2MHz SWO clock) */ - TPI->SPPR = 2U; /* 2 = Manchester/async UART mode */ - TPI->ACPR = 84U; /* Prescaler: (170 MHz / (84+1) / 2) ≈ 1MHz SWO */ - - ITM->TER |= (1UL << 0); - ITM->TCR |= (ITM_TCR_ITMENA_Msk | ITM_TCR_SWOENA_Msk); -} -// static int toggleze = 0; -/* USER CODE END 0 */ - -/** - * @brief The application entry point. - * @retval int - */ -int main(void) -{ - /* USER CODE BEGIN 1 */ - - /* USER CODE END 1 */ - - /* MCU - * Configuration--------------------------------------------------------*/ - - /* Reset of all peripherals, Initializes the Flash interface and the - * Systick. */ - HAL_Init(); - /* USER CODE BEGIN Init */ - ITM_Enable(); - /* USER CODE END Init */ - - /* Configure the system clock */ - SystemClock_Config(); - - /* USER CODE BEGIN SysInit */ - - /* USER CODE END SysInit */ - - /* Initialize all configured peripherals */ - MX_GPIO_Init(); - MX_DMA_Init(); - // MX_FDCAN2_Init(); - MX_ADC1_Init(); - MX_LPUART1_UART_Init(); - MX_I2C2_Init(); - MX_USART1_UART_Init(); - MX_SPI3_Init(); - MX_TIM2_Init(); - - /* USER CODE BEGIN 2 */ - - LOGOMATIC("Booted!\n"); - - // LOGOMATIC("running can_basic_test:\n"); - can_basic_test(); - - /* Infinite loop */ - /* USER CODE BEGIN WHILE */ - while (1) { - /* USER CODE END WHILE */ - LOGOMATIC("Main Loop\n"); - LL_mDelay(10000); - - // Receive on GPIOs - // HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, toggleze ? GPIO_PIN_SET - // : GPIO_PIN_RESET); HAL_Delay(1000); msg.data[0] = toggleze ? - // 0x00 : 0x80; can_send(data_can, &msg); - - // RCC->CFGR |= RCC_CFGR_SW; - /* USER CODE BEGIN 3 */ - } -} - -/** - * @brief System Clock Configuration - * @retval None - */ - -// void SystemClock_Config(void) -// { -// LL_FLASH_SetLatency(LL_FLASH_LATENCY_4); -// while (LL_FLASH_GetLatency() != LL_FLASH_LATENCY_4) { -// } -// LL_PWR_EnableRange1BoostMode(); -// LL_RCC_HSE_Enable(); - -// /* Wait till HSE is ready */ -// while (LL_RCC_HSE_IsReady() != 1) { -// } - -// LL_RCC_HSE_EnableCSS(); -// LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSE, LL_RCC_PLLM_DIV_1, 20, -// LL_RCC_PLLR_DIV_2); -// //LL_RCC_PLL_ConfigDomain_48M(LL_RCC_PLLSOURCE_HSE, ); -// LL_RCC_PLL_EnableDomain_SYS(); -// LL_RCC_PLL_Enable(); -// /* Wait till PLL is ready */ -// while (LL_RCC_PLL_IsReady() != 1) { -// } - -// LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL); -// LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_2); -// /* Wait till System clock is ready */ -// while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL) { -// } - -// /* Insure 1us transition state at intermediate medium speed clock*/ -// for (__IO uint32_t i = (170 >> 1); i != 0; i--) -// ; - -// /* Set AHB prescaler*/ -// LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1); -// LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1); -// LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_1); -// LL_SetSystemCoreClock(160000000); - -// /* Update the time base */ -// if (HAL_InitTick(TICK_INT_PRIORITY) != HAL_OK) { -// Error_Handler(); -// } -// }*/ -void SystemClock_Config(void) -{ - LL_FLASH_SetLatency(LL_FLASH_LATENCY_4); - while (LL_FLASH_GetLatency() != LL_FLASH_LATENCY_4) {} - LL_PWR_EnableRange1BoostMode(); - LL_RCC_HSI_Enable(); - /* Wait till HSI is ready */ - while (LL_RCC_HSI_IsReady() != 1) {} - - LL_RCC_HSI_SetCalibTrimming(64); - LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSI, LL_RCC_PLLM_DIV_4, 85, LL_RCC_PLLR_DIV_2); - LL_RCC_PLL_EnableDomain_SYS(); - LL_RCC_PLL_Enable(); - /* Wait till PLL is ready */ - while (LL_RCC_PLL_IsReady() != 1) {} - - LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL); - // LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1); - /* Wait till System clock is ready */ - while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL) {} - - /* Insure 1us transition state at intermediate medium speed clock*/ - for (__IO uint32_t i = (170 >> 1); i != 0; i--) - ; - - /* Set AHB prescaler*/ - LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1); - LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1); - LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_1); - LL_SetSystemCoreClock(170000000); - - /* Update the time base */ - if (HAL_InitTick(TICK_INT_PRIORITY) != HAL_OK) { - Error_Handler(); - } -} - -/* USER CODE BEGIN 4 */ - -/* USER CODE END 4 */ - -/** - * @brief This function is executed in case of error occurrence. - * @retval None - */ -void Error_Handler(void) -{ - /* USER CODE BEGIN Error_Handler_Debug */ - /* User can add his own implementation to report the HAL error return - * state */ - __disable_irq(); - while (1) {} - /* USER CODE END Error_Handler_Debug */ -} -#ifdef USE_FULL_ASSERT -/** - * @brief Reports the name of the source file and the source line number - * where the assert_param error has occurred. - * @param file: pointer to the source file name - * @param line: assert_param error line source number - * @retval None - */ -void assert_failed(uint8_t *file, uint32_t line) -{ - /* USER CODE BEGIN 6 */ - /* User can add his own implementation to report the file name and line - number, ex: printf("Wrong parameters value: file %s on line %d\r\n", - file, line) */ - /* USER CODE END 6 */ -} -#endif /* USE_FULL_ASSERT */ diff --git a/G474xE_CAN_TESTING/CAN_FILTER_TEST/CMakeLists.txt b/G474xE_CAN_TESTING/CAN_FILTER_TEST/CMakeLists.txt deleted file mode 100644 index 3be5c86bd..000000000 --- a/G474xE_CAN_TESTING/CAN_FILTER_TEST/CMakeLists.txt +++ /dev/null @@ -1,53 +0,0 @@ -cmake_minimum_required(VERSION 3.25) - -# Setup compiler settings -set(CMAKE_C_STANDARD 11) -set(CMAKE_C_STANDARD_REQUIRED ON) -set(CMAKE_C_EXTENSIONS ON) - -# Define the build type -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Debug") -endif() - -# Enable compile command to ease indexing with e.g. clangd -set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE) - -# Enable CMake support for ASM and C languages -enable_language( - C - ASM -) - -# Core project settings -project(${CMAKE_PROJECT_NAME}) - -# what, does in fact not get the filename of somthing but rather the name of the project from the path -get_filename_component(PROJECT_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME) - -add_library(${PROJECT_NAME}_USER_CODE INTERFACE) - -target_sources( - ${PROJECT_NAME}_USER_CODE - INTERFACE - ../Core/Src/adc.c - ../Core/Src/crc.c - ../Core/Src/dma.c - ../Core/Src/gpio.c - ../Core/Src/i2c.c - main.c - ../Core/Src/spi.c - ../Core/Src/stm32g4xx_hal_msp.c - ../Core/Src/stm32g4xx_it.c - ../Core/Src/tim.c - ../Core/Src/usart.c -) - -target_link_libraries(${PROJECT_NAME}_USER_CODE INTERFACE PERIPHERAL_CAN_LIB) - -target_include_directories( - ${PROJECT_NAME}_USER_CODE - INTERFACE - ../Core/Inc - . -) diff --git a/G474xE_CAN_TESTING/CAN_FILTER_TEST/can_cfg.h b/G474xE_CAN_TESTING/CAN_FILTER_TEST/can_cfg.h deleted file mode 100644 index fc11e3e23..000000000 --- a/G474xE_CAN_TESTING/CAN_FILTER_TEST/can_cfg.h +++ /dev/null @@ -1,11 +0,0 @@ - -#ifndef CAN_CFG_H -#define CAN_CFG_H - -#define USECAN1 -#define TX_BUFFER_1_SIZE 10 - -#define USECAN2 -#define TX_BUFFER_2_SIZE 10 - -#endif diff --git a/G474xE_CAN_TESTING/CAN_FILTER_TEST/main.c b/G474xE_CAN_TESTING/CAN_FILTER_TEST/main.c deleted file mode 100644 index 8fe024424..000000000 --- a/G474xE_CAN_TESTING/CAN_FILTER_TEST/main.c +++ /dev/null @@ -1,274 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file : main.c - * @brief : Main program body - ****************************************************************************** - * @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 "main.h" - -#include "adc.h" -#include "can.h" // Assume this works -#include "can_tests.h" -#include "dma.h" -#include "fdcan.h" -#include "gpio.h" -#include "i2c.h" -#include "spi.h" -#include "tim.h" -#include "usart.h" - -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ -#include "Logomatic.h" -/* USER CODE END Includes */ - -/* Private typedef -----------------------------------------------------------*/ -/* USER CODE BEGIN PTD */ - -/* USER CODE END PTD */ - -/* Private define ------------------------------------------------------------*/ -/* USER CODE BEGIN PD */ - -/* USER CODE END PD */ - -/* Private macro -------------------------------------------------------------*/ -/* USER CODE BEGIN PM */ - -/* USER CODE END PM */ - -/* Private variables ---------------------------------------------------------*/ - -/* USER CODE BEGIN PV */ -/* USER CODE END PV */ - -/* Private function prototypes -----------------------------------------------*/ -void SystemClock_Config(void); -/* USER CODE BEGIN PFP */ - -/* USER CODE END PFP */ - -/* Private user code ---------------------------------------------------------*/ -/* USER CODE BEGIN 0 */ -/* Enable ITM for SWO output */ -static void ITM_Enable(void) -{ - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOB); - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - GPIO_InitStruct.Pin = LL_GPIO_PIN_3; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_0; - LL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - DBGMCU->CR |= DBGMCU_CR_TRACE_IOEN; - - /* Enable TRC (Trace) */ - CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; - - /* Configure TPI for SWO output (set prescaler for 2MHz SWO clock) */ - TPI->SPPR = 2U; /* 2 = Manchester/async UART mode */ - TPI->ACPR = 84U; /* Prescaler: (170 MHz / (84+1) / 2) ≈ 1MHz SWO */ - - ITM->TER |= (1UL << 0); - ITM->TCR |= (ITM_TCR_ITMENA_Msk | ITM_TCR_SWOENA_Msk); -} -// static int toggleze = 0; -/* USER CODE END 0 */ - -/** - * @brief The application entry point. - * @retval int - */ -int main(void) -{ - /* USER CODE BEGIN 1 */ - - /* USER CODE END 1 */ - - /* MCU - * Configuration--------------------------------------------------------*/ - - /* Reset of all peripherals, Initializes the Flash interface and the - * Systick. */ - HAL_Init(); - /* USER CODE BEGIN Init */ - ITM_Enable(); - /* USER CODE END Init */ - - /* Configure the system clock */ - SystemClock_Config(); - - /* USER CODE BEGIN SysInit */ - - /* USER CODE END SysInit */ - - /* Initialize all configured peripherals */ - MX_GPIO_Init(); - MX_DMA_Init(); - // MX_FDCAN2_Init(); - MX_ADC1_Init(); - MX_LPUART1_UART_Init(); - MX_I2C2_Init(); - MX_USART1_UART_Init(); - MX_SPI3_Init(); - MX_TIM2_Init(); - - /* USER CODE BEGIN 2 */ - - LOGOMATIC("Booted!\n"); - - // LOGOMATIC("running can_stress_test:\n"); - can_filter_test(); - - /* Infinite loop */ - /* USER CODE BEGIN WHILE */ - while (1) { - /* USER CODE END WHILE */ - LOGOMATIC("Main Loop\n"); - LL_mDelay(1000); - - // Receive on GPIOs - // HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, toggleze ? GPIO_PIN_SET - // : GPIO_PIN_RESET); HAL_Delay(1000); msg.data[0] = toggleze ? - // 0x00 : 0x80; can_send(data_can, &msg); - - // RCC->CFGR |= RCC_CFGR_SW; - /* USER CODE BEGIN 3 */ - } -} - -/** - * @brief System Clock Configuration - * @retval None - */ - -// void SystemClock_Config(void) -// { -// LL_FLASH_SetLatency(LL_FLASH_LATENCY_4); -// while (LL_FLASH_GetLatency() != LL_FLASH_LATENCY_4) { -// } -// LL_PWR_EnableRange1BoostMode(); -// LL_RCC_HSE_Enable(); - -// /* Wait till HSE is ready */ -// while (LL_RCC_HSE_IsReady() != 1) { -// } - -// LL_RCC_HSE_EnableCSS(); -// LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSE, LL_RCC_PLLM_DIV_1, 20, -// LL_RCC_PLLR_DIV_2); -// //LL_RCC_PLL_ConfigDomain_48M(LL_RCC_PLLSOURCE_HSE, ); -// LL_RCC_PLL_EnableDomain_SYS(); -// LL_RCC_PLL_Enable(); -// /* Wait till PLL is ready */ -// while (LL_RCC_PLL_IsReady() != 1) { -// } - -// LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL); -// LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_2); -// /* Wait till System clock is ready */ -// while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL) { -// } - -// /* Insure 1us transition state at intermediate medium speed clock*/ -// for (__IO uint32_t i = (170 >> 1); i != 0; i--) -// ; - -// /* Set AHB prescaler*/ -// LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1); -// LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1); -// LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_1); -// LL_SetSystemCoreClock(160000000); - -// /* Update the time base */ -// if (HAL_InitTick(TICK_INT_PRIORITY) != HAL_OK) { -// Error_Handler(); -// } -// }*/ -void SystemClock_Config(void) -{ - LL_FLASH_SetLatency(LL_FLASH_LATENCY_4); - while (LL_FLASH_GetLatency() != LL_FLASH_LATENCY_4) {} - LL_PWR_EnableRange1BoostMode(); - LL_RCC_HSI_Enable(); - /* Wait till HSI is ready */ - while (LL_RCC_HSI_IsReady() != 1) {} - - LL_RCC_HSI_SetCalibTrimming(64); - LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSI, LL_RCC_PLLM_DIV_4, 85, LL_RCC_PLLR_DIV_2); - LL_RCC_PLL_EnableDomain_SYS(); - LL_RCC_PLL_Enable(); - /* Wait till PLL is ready */ - while (LL_RCC_PLL_IsReady() != 1) {} - - LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL); - // LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1); - /* Wait till System clock is ready */ - while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL) {} - - /* Insure 1us transition state at intermediate medium speed clock*/ - for (__IO uint32_t i = (170 >> 1); i != 0; i--) - ; - - /* Set AHB prescaler*/ - LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1); - LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1); - LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_1); - LL_SetSystemCoreClock(170000000); - - /* Update the time base */ - if (HAL_InitTick(TICK_INT_PRIORITY) != HAL_OK) { - Error_Handler(); - } -} - -/* USER CODE BEGIN 4 */ - -/* USER CODE END 4 */ - -/** - * @brief This function is executed in case of error occurrence. - * @retval None - */ -void Error_Handler(void) -{ - /* USER CODE BEGIN Error_Handler_Debug */ - /* User can add his own implementation to report the HAL error return - * state */ - __disable_irq(); - while (1) {} - /* USER CODE END Error_Handler_Debug */ -} -#ifdef USE_FULL_ASSERT -/** - * @brief Reports the name of the source file and the source line number - * where the assert_param error has occurred. - * @param file: pointer to the source file name - * @param line: assert_param error line source number - * @retval None - */ -void assert_failed(uint8_t *file, uint32_t line) -{ - /* USER CODE BEGIN 6 */ - /* User can add his own implementation to report the file name and line - number, ex: printf("Wrong parameters value: file %s on line %d\r\n", - file, line) */ - /* USER CODE END 6 */ -} -#endif /* USE_FULL_ASSERT */ diff --git a/G474xE_CAN_TESTING/CAN_INTERNAL_TEST/CMakeLists.txt b/G474xE_CAN_TESTING/CAN_INTERNAL_TEST/CMakeLists.txt deleted file mode 100644 index ccedc8c6d..000000000 --- a/G474xE_CAN_TESTING/CAN_INTERNAL_TEST/CMakeLists.txt +++ /dev/null @@ -1,60 +0,0 @@ -cmake_minimum_required(VERSION 3.25) - -# Setup compiler settings -set(CMAKE_C_STANDARD 11) -set(CMAKE_C_STANDARD_REQUIRED ON) -set(CMAKE_C_EXTENSIONS ON) - -# Define the build type -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Debug") -endif() - -# Enable compile command to ease indexing with e.g. clangd -set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE) - -# Enable CMake support for ASM and C languages -enable_language( - C - ASM -) - -# Core project settings -project(${CMAKE_PROJECT_NAME}) - -# what, does in fact not get the filename of somthing but rather the name of the project from the path -get_filename_component(PROJECT_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME) - -add_library(${PROJECT_NAME}_USER_CODE INTERFACE) - -target_sources( - ${PROJECT_NAME}_USER_CODE - INTERFACE - ../Core/Src/adc.c - ../Core/Src/crc.c - ../Core/Src/dma.c - ../Core/Src/gpio.c - ../Core/Src/i2c.c - main.c - ../Core/Src/spi.c - ../Core/Src/stm32g4xx_hal_msp.c - ../Core/Src/stm32g4xx_it.c - ../Core/Src/tim.c - ../Core/Src/usart.c -) - -set_target_properties( - ${NAME} - PROPERTIES - OUTPUT_NAME - "CAN_${NAME}" -) - -target_link_libraries(${PROJECT_NAME}_USER_CODE INTERFACE PERIPHERAL_CAN_LIB) - -target_include_directories( - ${PROJECT_NAME}_USER_CODE - INTERFACE - ../Core/Inc - . -) diff --git a/G474xE_CAN_TESTING/CAN_INTERNAL_TEST/can_cfg.h b/G474xE_CAN_TESTING/CAN_INTERNAL_TEST/can_cfg.h deleted file mode 100644 index 8a18e8882..000000000 --- a/G474xE_CAN_TESTING/CAN_INTERNAL_TEST/can_cfg.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef CAN_CFG_H -#define CAN_CFG_H - -#define USECAN1 -#define TX_BUFFER_1_SIZE 10 - -#define USECAN2 -#define TX_BUFFER_2_SIZE 10 - -#endif diff --git a/G474xE_CAN_TESTING/CAN_INTERNAL_TEST/main.c b/G474xE_CAN_TESTING/CAN_INTERNAL_TEST/main.c deleted file mode 100644 index 9c2f2b7a4..000000000 --- a/G474xE_CAN_TESTING/CAN_INTERNAL_TEST/main.c +++ /dev/null @@ -1,274 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file : main.c - * @brief : Main program body - ****************************************************************************** - * @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 "main.h" - -#include "adc.h" -#include "can.h" // Assume this works -#include "can_tests.h" -#include "dma.h" -#include "fdcan.h" -#include "gpio.h" -#include "i2c.h" -#include "spi.h" -#include "tim.h" -#include "usart.h" - -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ -#include "Logomatic.h" -/* USER CODE END Includes */ - -/* Private typedef -----------------------------------------------------------*/ -/* USER CODE BEGIN PTD */ - -/* USER CODE END PTD */ - -/* Private define ------------------------------------------------------------*/ -/* USER CODE BEGIN PD */ - -/* USER CODE END PD */ - -/* Private macro -------------------------------------------------------------*/ -/* USER CODE BEGIN PM */ - -/* USER CODE END PM */ - -/* Private variables ---------------------------------------------------------*/ - -/* USER CODE BEGIN PV */ -/* USER CODE END PV */ - -/* Private function prototypes -----------------------------------------------*/ -void SystemClock_Config(void); -/* USER CODE BEGIN PFP */ - -/* USER CODE END PFP */ - -/* Private user code ---------------------------------------------------------*/ -/* USER CODE BEGIN 0 */ -/* Enable ITM for SWO output */ -static void ITM_Enable(void) -{ - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOB); - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - GPIO_InitStruct.Pin = LL_GPIO_PIN_3; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_0; - LL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - DBGMCU->CR |= DBGMCU_CR_TRACE_IOEN; - - /* Enable TRC (Trace) */ - CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; - - /* Configure TPI for SWO output (set prescaler for 2MHz SWO clock) */ - TPI->SPPR = 2U; /* 2 = Manchester/async UART mode */ - TPI->ACPR = 84U; /* Prescaler: (170 MHz / (84+1) / 2) ≈ 1MHz SWO */ - - ITM->TER |= (1UL << 0); - ITM->TCR |= (ITM_TCR_ITMENA_Msk | ITM_TCR_SWOENA_Msk); -} -// static int toggleze = 0; -/* USER CODE END 0 */ - -/** - * @brief The application entry point. - * @retval int - */ -int main(void) -{ - /* USER CODE BEGIN 1 */ - - /* USER CODE END 1 */ - - /* MCU - * Configuration--------------------------------------------------------*/ - - /* Reset of all peripherals, Initializes the Flash interface and the - * Systick. */ - HAL_Init(); - /* USER CODE BEGIN Init */ - ITM_Enable(); - /* USER CODE END Init */ - - /* Configure the system clock */ - SystemClock_Config(); - - /* USER CODE BEGIN SysInit */ - - /* USER CODE END SysInit */ - - /* Initialize all configured peripherals */ - MX_GPIO_Init(); - MX_DMA_Init(); - // MX_FDCAN2_Init(); - MX_ADC1_Init(); - MX_LPUART1_UART_Init(); - MX_I2C2_Init(); - MX_USART1_UART_Init(); - MX_SPI3_Init(); - MX_TIM2_Init(); - - /* USER CODE BEGIN 2 */ - - LOGOMATIC("Booted!\n"); - - // LOGOMATIC("running can_internal_test:\n"); - can_internal_test(); - - /* Infinite loop */ - /* USER CODE BEGIN WHILE */ - while (1) { - /* USER CODE END WHILE */ - LOGOMATIC("Main Loop\n"); - LL_mDelay(10000); - - // Receive on GPIOs - // HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, toggleze ? GPIO_PIN_SET - // : GPIO_PIN_RESET); HAL_Delay(1000); msg.data[0] = toggleze ? - // 0x00 : 0x80; can_send(data_can, &msg); - - // RCC->CFGR |= RCC_CFGR_SW; - /* USER CODE BEGIN 3 */ - } -} - -/** - * @brief System Clock Configuration - * @retval None - */ - -// void SystemClock_Config(void) -// { -// LL_FLASH_SetLatency(LL_FLASH_LATENCY_4); -// while (LL_FLASH_GetLatency() != LL_FLASH_LATENCY_4) { -// } -// LL_PWR_EnableRange1BoostMode(); -// LL_RCC_HSE_Enable(); - -// /* Wait till HSE is ready */ -// while (LL_RCC_HSE_IsReady() != 1) { -// } - -// LL_RCC_HSE_EnableCSS(); -// LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSE, LL_RCC_PLLM_DIV_1, 20, -// LL_RCC_PLLR_DIV_2); -// //LL_RCC_PLL_ConfigDomain_48M(LL_RCC_PLLSOURCE_HSE, ); -// LL_RCC_PLL_EnableDomain_SYS(); -// LL_RCC_PLL_Enable(); -// /* Wait till PLL is ready */ -// while (LL_RCC_PLL_IsReady() != 1) { -// } - -// LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL); -// LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_2); -// /* Wait till System clock is ready */ -// while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL) { -// } - -// /* Insure 1us transition state at intermediate medium speed clock*/ -// for (__IO uint32_t i = (170 >> 1); i != 0; i--) -// ; - -// /* Set AHB prescaler*/ -// LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1); -// LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1); -// LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_1); -// LL_SetSystemCoreClock(160000000); - -// /* Update the time base */ -// if (HAL_InitTick(TICK_INT_PRIORITY) != HAL_OK) { -// Error_Handler(); -// } -// }*/ -void SystemClock_Config(void) -{ - LL_FLASH_SetLatency(LL_FLASH_LATENCY_4); - while (LL_FLASH_GetLatency() != LL_FLASH_LATENCY_4) {} - LL_PWR_EnableRange1BoostMode(); - LL_RCC_HSI_Enable(); - /* Wait till HSI is ready */ - while (LL_RCC_HSI_IsReady() != 1) {} - - LL_RCC_HSI_SetCalibTrimming(64); - LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSI, LL_RCC_PLLM_DIV_4, 85, LL_RCC_PLLR_DIV_2); - LL_RCC_PLL_EnableDomain_SYS(); - LL_RCC_PLL_Enable(); - /* Wait till PLL is ready */ - while (LL_RCC_PLL_IsReady() != 1) {} - - LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL); - // LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1); - /* Wait till System clock is ready */ - while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL) {} - - /* Insure 1us transition state at intermediate medium speed clock*/ - for (__IO uint32_t i = (170 >> 1); i != 0; i--) - ; - - /* Set AHB prescaler*/ - LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1); - LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1); - LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_1); - LL_SetSystemCoreClock(170000000); - - /* Update the time base */ - if (HAL_InitTick(TICK_INT_PRIORITY) != HAL_OK) { - Error_Handler(); - } -} - -/* USER CODE BEGIN 4 */ - -/* USER CODE END 4 */ - -/** - * @brief This function is executed in case of error occurrence. - * @retval None - */ -void Error_Handler(void) -{ - /* USER CODE BEGIN Error_Handler_Debug */ - /* User can add his own implementation to report the HAL error return - * state */ - __disable_irq(); - while (1) {} - /* USER CODE END Error_Handler_Debug */ -} -#ifdef USE_FULL_ASSERT -/** - * @brief Reports the name of the source file and the source line number - * where the assert_param error has occurred. - * @param file: pointer to the source file name - * @param line: assert_param error line source number - * @retval None - */ -void assert_failed(uint8_t *file, uint32_t line) -{ - /* USER CODE BEGIN 6 */ - /* User can add his own implementation to report the file name and line - number, ex: printf("Wrong parameters value: file %s on line %d\r\n", - file, line) */ - /* USER CODE END 6 */ -} -#endif /* USE_FULL_ASSERT */ diff --git a/G474xE_CAN_TESTING/CAN_LOST_RX_TEST/CMakeLists.txt b/G474xE_CAN_TESTING/CAN_LOST_RX_TEST/CMakeLists.txt deleted file mode 100644 index 3be5c86bd..000000000 --- a/G474xE_CAN_TESTING/CAN_LOST_RX_TEST/CMakeLists.txt +++ /dev/null @@ -1,53 +0,0 @@ -cmake_minimum_required(VERSION 3.25) - -# Setup compiler settings -set(CMAKE_C_STANDARD 11) -set(CMAKE_C_STANDARD_REQUIRED ON) -set(CMAKE_C_EXTENSIONS ON) - -# Define the build type -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Debug") -endif() - -# Enable compile command to ease indexing with e.g. clangd -set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE) - -# Enable CMake support for ASM and C languages -enable_language( - C - ASM -) - -# Core project settings -project(${CMAKE_PROJECT_NAME}) - -# what, does in fact not get the filename of somthing but rather the name of the project from the path -get_filename_component(PROJECT_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME) - -add_library(${PROJECT_NAME}_USER_CODE INTERFACE) - -target_sources( - ${PROJECT_NAME}_USER_CODE - INTERFACE - ../Core/Src/adc.c - ../Core/Src/crc.c - ../Core/Src/dma.c - ../Core/Src/gpio.c - ../Core/Src/i2c.c - main.c - ../Core/Src/spi.c - ../Core/Src/stm32g4xx_hal_msp.c - ../Core/Src/stm32g4xx_it.c - ../Core/Src/tim.c - ../Core/Src/usart.c -) - -target_link_libraries(${PROJECT_NAME}_USER_CODE INTERFACE PERIPHERAL_CAN_LIB) - -target_include_directories( - ${PROJECT_NAME}_USER_CODE - INTERFACE - ../Core/Inc - . -) diff --git a/G474xE_CAN_TESTING/CAN_LOST_RX_TEST/can_cfg.h b/G474xE_CAN_TESTING/CAN_LOST_RX_TEST/can_cfg.h deleted file mode 100644 index 4d370d3eb..000000000 --- a/G474xE_CAN_TESTING/CAN_LOST_RX_TEST/can_cfg.h +++ /dev/null @@ -1,23 +0,0 @@ - -#ifndef CAN_CFG_H -#define CAN_CFG_H - -#define USECAN1 -#define TX_BUFFER_1_SIZE 10 - -/*#define CAN1_RX_GPIO -#define CAN1_RX_PIN -#define CAN1_TX_GPIO -#define CAN1_TX_PIN -*/ - -#define USECAN2 -#define TX_BUFFER_2_SIZE 10 - -/*#define CAN1_RX_GPIO -#define CAN1_RX_PIN -#define CAN1_TX_GPIO -#define CAN1_TX_PIN -*/ - -#endif diff --git a/G474xE_CAN_TESTING/CAN_LOST_RX_TEST/main.c b/G474xE_CAN_TESTING/CAN_LOST_RX_TEST/main.c deleted file mode 100644 index c9efe8499..000000000 --- a/G474xE_CAN_TESTING/CAN_LOST_RX_TEST/main.c +++ /dev/null @@ -1,274 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file : main.c - * @brief : Main program body - ****************************************************************************** - * @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 "main.h" - -#include "adc.h" -#include "can.h" // Assume this works -#include "can_tests.h" -#include "dma.h" -#include "fdcan.h" -#include "gpio.h" -#include "i2c.h" -#include "spi.h" -#include "tim.h" -#include "usart.h" - -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ -#include "Logomatic.h" -/* USER CODE END Includes */ - -/* Private typedef -----------------------------------------------------------*/ -/* USER CODE BEGIN PTD */ - -/* USER CODE END PTD */ - -/* Private define ------------------------------------------------------------*/ -/* USER CODE BEGIN PD */ - -/* USER CODE END PD */ - -/* Private macro -------------------------------------------------------------*/ -/* USER CODE BEGIN PM */ - -/* USER CODE END PM */ - -/* Private variables ---------------------------------------------------------*/ - -/* USER CODE BEGIN PV */ -/* USER CODE END PV */ - -/* Private function prototypes -----------------------------------------------*/ -void SystemClock_Config(void); -/* USER CODE BEGIN PFP */ - -/* USER CODE END PFP */ - -/* Private user code ---------------------------------------------------------*/ -/* USER CODE BEGIN 0 */ -/* Enable ITM for SWO output */ -static void ITM_Enable(void) -{ - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOB); - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - GPIO_InitStruct.Pin = LL_GPIO_PIN_3; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_0; - LL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - DBGMCU->CR |= DBGMCU_CR_TRACE_IOEN; - - /* Enable TRC (Trace) */ - CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; - - /* Configure TPI for SWO output (set prescaler for 2MHz SWO clock) */ - TPI->SPPR = 2U; /* 2 = Manchester/async UART mode */ - TPI->ACPR = 84U; /* Prescaler: (170 MHz / (84+1) / 2) ≈ 1MHz SWO */ - - ITM->TER |= (1UL << 0); - ITM->TCR |= (ITM_TCR_ITMENA_Msk | ITM_TCR_SWOENA_Msk); -} -// static int toggleze = 0; -/* USER CODE END 0 */ - -/** - * @brief The application entry point. - * @retval int - */ -int main(void) -{ - /* USER CODE BEGIN 1 */ - - /* USER CODE END 1 */ - - /* MCU - * Configuration--------------------------------------------------------*/ - - /* Reset of all peripherals, Initializes the Flash interface and the - * Systick. */ - HAL_Init(); - /* USER CODE BEGIN Init */ - ITM_Enable(); - /* USER CODE END Init */ - - /* Configure the system clock */ - SystemClock_Config(); - - /* USER CODE BEGIN SysInit */ - - /* USER CODE END SysInit */ - - /* Initialize all configured peripherals */ - MX_GPIO_Init(); - MX_DMA_Init(); - // MX_FDCAN2_Init(); - MX_ADC1_Init(); - MX_LPUART1_UART_Init(); - MX_I2C2_Init(); - MX_USART1_UART_Init(); - MX_SPI3_Init(); - MX_TIM2_Init(); - - /* USER CODE BEGIN 2 */ - - LOGOMATIC("Booted!\n"); - - // LOGOMATIC("running can_stress_test:\n"); - can_lost_rx_test(); - - /* Infinite loop */ - /* USER CODE BEGIN WHILE */ - while (1) { - /* USER CODE END WHILE */ - LOGOMATIC("Main Loop\n"); - LL_mDelay(1000); - - // Receive on GPIOs - // HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, toggleze ? GPIO_PIN_SET - // : GPIO_PIN_RESET); HAL_Delay(1000); msg.data[0] = toggleze ? - // 0x00 : 0x80; can_send(data_can, &msg); - - // RCC->CFGR |= RCC_CFGR_SW; - /* USER CODE BEGIN 3 */ - } -} - -/** - * @brief System Clock Configuration - * @retval None - */ - -// void SystemClock_Config(void) -// { -// LL_FLASH_SetLatency(LL_FLASH_LATENCY_4); -// while (LL_FLASH_GetLatency() != LL_FLASH_LATENCY_4) { -// } -// LL_PWR_EnableRange1BoostMode(); -// LL_RCC_HSE_Enable(); - -// /* Wait till HSE is ready */ -// while (LL_RCC_HSE_IsReady() != 1) { -// } - -// LL_RCC_HSE_EnableCSS(); -// LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSE, LL_RCC_PLLM_DIV_1, 20, -// LL_RCC_PLLR_DIV_2); -// //LL_RCC_PLL_ConfigDomain_48M(LL_RCC_PLLSOURCE_HSE, ); -// LL_RCC_PLL_EnableDomain_SYS(); -// LL_RCC_PLL_Enable(); -// /* Wait till PLL is ready */ -// while (LL_RCC_PLL_IsReady() != 1) { -// } - -// LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL); -// LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_2); -// /* Wait till System clock is ready */ -// while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL) { -// } - -// /* Insure 1us transition state at intermediate medium speed clock*/ -// for (__IO uint32_t i = (170 >> 1); i != 0; i--) -// ; - -// /* Set AHB prescaler*/ -// LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1); -// LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1); -// LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_1); -// LL_SetSystemCoreClock(160000000); - -// /* Update the time base */ -// if (HAL_InitTick(TICK_INT_PRIORITY) != HAL_OK) { -// Error_Handler(); -// } -// }*/ -void SystemClock_Config(void) -{ - LL_FLASH_SetLatency(LL_FLASH_LATENCY_4); - while (LL_FLASH_GetLatency() != LL_FLASH_LATENCY_4) {} - LL_PWR_EnableRange1BoostMode(); - LL_RCC_HSI_Enable(); - /* Wait till HSI is ready */ - while (LL_RCC_HSI_IsReady() != 1) {} - - LL_RCC_HSI_SetCalibTrimming(64); - LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSI, LL_RCC_PLLM_DIV_4, 85, LL_RCC_PLLR_DIV_2); - LL_RCC_PLL_EnableDomain_SYS(); - LL_RCC_PLL_Enable(); - /* Wait till PLL is ready */ - while (LL_RCC_PLL_IsReady() != 1) {} - - LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL); - // LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1); - /* Wait till System clock is ready */ - while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL) {} - - /* Insure 1us transition state at intermediate medium speed clock*/ - for (__IO uint32_t i = (170 >> 1); i != 0; i--) - ; - - /* Set AHB prescaler*/ - LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1); - LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1); - LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_1); - LL_SetSystemCoreClock(170000000); - - /* Update the time base */ - if (HAL_InitTick(TICK_INT_PRIORITY) != HAL_OK) { - Error_Handler(); - } -} - -/* USER CODE BEGIN 4 */ - -/* USER CODE END 4 */ - -/** - * @brief This function is executed in case of error occurrence. - * @retval None - */ -void Error_Handler(void) -{ - /* USER CODE BEGIN Error_Handler_Debug */ - /* User can add his own implementation to report the HAL error return - * state */ - __disable_irq(); - while (1) {} - /* USER CODE END Error_Handler_Debug */ -} -#ifdef USE_FULL_ASSERT -/** - * @brief Reports the name of the source file and the source line number - * where the assert_param error has occurred. - * @param file: pointer to the source file name - * @param line: assert_param error line source number - * @retval None - */ -void assert_failed(uint8_t *file, uint32_t line) -{ - /* USER CODE BEGIN 6 */ - /* User can add his own implementation to report the file name and line - number, ex: printf("Wrong parameters value: file %s on line %d\r\n", - file, line) */ - /* USER CODE END 6 */ -} -#endif /* USE_FULL_ASSERT */ diff --git a/G474xE_CAN_TESTING/CAN_RELEASE_TEST/CMakeLists.txt b/G474xE_CAN_TESTING/CAN_RELEASE_TEST/CMakeLists.txt deleted file mode 100644 index ccedc8c6d..000000000 --- a/G474xE_CAN_TESTING/CAN_RELEASE_TEST/CMakeLists.txt +++ /dev/null @@ -1,60 +0,0 @@ -cmake_minimum_required(VERSION 3.25) - -# Setup compiler settings -set(CMAKE_C_STANDARD 11) -set(CMAKE_C_STANDARD_REQUIRED ON) -set(CMAKE_C_EXTENSIONS ON) - -# Define the build type -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Debug") -endif() - -# Enable compile command to ease indexing with e.g. clangd -set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE) - -# Enable CMake support for ASM and C languages -enable_language( - C - ASM -) - -# Core project settings -project(${CMAKE_PROJECT_NAME}) - -# what, does in fact not get the filename of somthing but rather the name of the project from the path -get_filename_component(PROJECT_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME) - -add_library(${PROJECT_NAME}_USER_CODE INTERFACE) - -target_sources( - ${PROJECT_NAME}_USER_CODE - INTERFACE - ../Core/Src/adc.c - ../Core/Src/crc.c - ../Core/Src/dma.c - ../Core/Src/gpio.c - ../Core/Src/i2c.c - main.c - ../Core/Src/spi.c - ../Core/Src/stm32g4xx_hal_msp.c - ../Core/Src/stm32g4xx_it.c - ../Core/Src/tim.c - ../Core/Src/usart.c -) - -set_target_properties( - ${NAME} - PROPERTIES - OUTPUT_NAME - "CAN_${NAME}" -) - -target_link_libraries(${PROJECT_NAME}_USER_CODE INTERFACE PERIPHERAL_CAN_LIB) - -target_include_directories( - ${PROJECT_NAME}_USER_CODE - INTERFACE - ../Core/Inc - . -) diff --git a/G474xE_CAN_TESTING/CAN_RELEASE_TEST/can_cfg.h b/G474xE_CAN_TESTING/CAN_RELEASE_TEST/can_cfg.h deleted file mode 100644 index fc11e3e23..000000000 --- a/G474xE_CAN_TESTING/CAN_RELEASE_TEST/can_cfg.h +++ /dev/null @@ -1,11 +0,0 @@ - -#ifndef CAN_CFG_H -#define CAN_CFG_H - -#define USECAN1 -#define TX_BUFFER_1_SIZE 10 - -#define USECAN2 -#define TX_BUFFER_2_SIZE 10 - -#endif diff --git a/G474xE_CAN_TESTING/CAN_RELEASE_TEST/main.c b/G474xE_CAN_TESTING/CAN_RELEASE_TEST/main.c deleted file mode 100644 index a3197bb29..000000000 --- a/G474xE_CAN_TESTING/CAN_RELEASE_TEST/main.c +++ /dev/null @@ -1,274 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file : main.c - * @brief : Main program body - ****************************************************************************** - * @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 "main.h" - -#include "adc.h" -#include "can.h" // Assume this works -#include "can_tests.h" -#include "dma.h" -#include "fdcan.h" -#include "gpio.h" -#include "i2c.h" -#include "spi.h" -#include "tim.h" -#include "usart.h" - -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ -#include "Logomatic.h" -/* USER CODE END Includes */ - -/* Private typedef -----------------------------------------------------------*/ -/* USER CODE BEGIN PTD */ - -/* USER CODE END PTD */ - -/* Private define ------------------------------------------------------------*/ -/* USER CODE BEGIN PD */ - -/* USER CODE END PD */ - -/* Private macro -------------------------------------------------------------*/ -/* USER CODE BEGIN PM */ - -/* USER CODE END PM */ - -/* Private variables ---------------------------------------------------------*/ - -/* USER CODE BEGIN PV */ -/* USER CODE END PV */ - -/* Private function prototypes -----------------------------------------------*/ -void SystemClock_Config(void); -/* USER CODE BEGIN PFP */ - -/* USER CODE END PFP */ - -/* Private user code ---------------------------------------------------------*/ -/* USER CODE BEGIN 0 */ -/* Enable ITM for SWO output */ -static void ITM_Enable(void) -{ - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOB); - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - GPIO_InitStruct.Pin = LL_GPIO_PIN_3; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_0; - LL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - DBGMCU->CR |= DBGMCU_CR_TRACE_IOEN; - - /* Enable TRC (Trace) */ - CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; - - /* Configure TPI for SWO output (set prescaler for 2MHz SWO clock) */ - TPI->SPPR = 2U; /* 2 = Manchester/async UART mode */ - TPI->ACPR = 84U; /* Prescaler: (170 MHz / (84+1) / 2) ≈ 1MHz SWO */ - - ITM->TER |= (1UL << 0); - ITM->TCR |= (ITM_TCR_ITMENA_Msk | ITM_TCR_SWOENA_Msk); -} -// static int toggleze = 0; -/* USER CODE END 0 */ - -/** - * @brief The application entry point. - * @retval int - */ -int main(void) -{ - /* USER CODE BEGIN 1 */ - - /* USER CODE END 1 */ - - /* MCU - * Configuration--------------------------------------------------------*/ - - /* Reset of all peripherals, Initializes the Flash interface and the - * Systick. */ - HAL_Init(); - /* USER CODE BEGIN Init */ - ITM_Enable(); - /* USER CODE END Init */ - - /* Configure the system clock */ - SystemClock_Config(); - - /* USER CODE BEGIN SysInit */ - - /* USER CODE END SysInit */ - - /* Initialize all configured peripherals */ - MX_GPIO_Init(); - MX_DMA_Init(); - // MX_FDCAN2_Init(); - MX_ADC1_Init(); - MX_LPUART1_UART_Init(); - MX_I2C2_Init(); - MX_USART1_UART_Init(); - MX_SPI3_Init(); - MX_TIM2_Init(); - - /* USER CODE BEGIN 2 */ - - LOGOMATIC("Booted!\n"); - - // LOGOMATIC("running can_release_test:\n"); - can_release_test(); - - /* Infinite loop */ - /* USER CODE BEGIN WHILE */ - while (1) { - /* USER CODE END WHILE */ - LOGOMATIC("Main Loop\n"); - LL_mDelay(1000); - - // Receive on GPIOs - // HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, toggleze ? GPIO_PIN_SET - // : GPIO_PIN_RESET); HAL_Delay(1000); msg.data[0] = toggleze ? - // 0x00 : 0x80; can_send(data_can, &msg); - - // RCC->CFGR |= RCC_CFGR_SW; - /* USER CODE BEGIN 3 */ - } -} - -/** - * @brief System Clock Configuration - * @retval None - */ - -// void SystemClock_Config(void) -// { -// LL_FLASH_SetLatency(LL_FLASH_LATENCY_4); -// while (LL_FLASH_GetLatency() != LL_FLASH_LATENCY_4) { -// } -// LL_PWR_EnableRange1BoostMode(); -// LL_RCC_HSE_Enable(); - -// /* Wait till HSE is ready */ -// while (LL_RCC_HSE_IsReady() != 1) { -// } - -// LL_RCC_HSE_EnableCSS(); -// LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSE, LL_RCC_PLLM_DIV_1, 20, -// LL_RCC_PLLR_DIV_2); -// //LL_RCC_PLL_ConfigDomain_48M(LL_RCC_PLLSOURCE_HSE, ); -// LL_RCC_PLL_EnableDomain_SYS(); -// LL_RCC_PLL_Enable(); -// /* Wait till PLL is ready */ -// while (LL_RCC_PLL_IsReady() != 1) { -// } - -// LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL); -// LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_2); -// /* Wait till System clock is ready */ -// while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL) { -// } - -// /* Insure 1us transition state at intermediate medium speed clock*/ -// for (__IO uint32_t i = (170 >> 1); i != 0; i--) -// ; - -// /* Set AHB prescaler*/ -// LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1); -// LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1); -// LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_1); -// LL_SetSystemCoreClock(160000000); - -// /* Update the time base */ -// if (HAL_InitTick(TICK_INT_PRIORITY) != HAL_OK) { -// Error_Handler(); -// } -// }*/ -void SystemClock_Config(void) -{ - LL_FLASH_SetLatency(LL_FLASH_LATENCY_4); - while (LL_FLASH_GetLatency() != LL_FLASH_LATENCY_4) {} - LL_PWR_EnableRange1BoostMode(); - LL_RCC_HSI_Enable(); - /* Wait till HSI is ready */ - while (LL_RCC_HSI_IsReady() != 1) {} - - LL_RCC_HSI_SetCalibTrimming(64); - LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSI, LL_RCC_PLLM_DIV_4, 85, LL_RCC_PLLR_DIV_2); - LL_RCC_PLL_EnableDomain_SYS(); - LL_RCC_PLL_Enable(); - /* Wait till PLL is ready */ - while (LL_RCC_PLL_IsReady() != 1) {} - - LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL); - // LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1); - /* Wait till System clock is ready */ - while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL) {} - - /* Insure 1us transition state at intermediate medium speed clock*/ - for (__IO uint32_t i = (170 >> 1); i != 0; i--) - ; - - /* Set AHB prescaler*/ - LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1); - LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1); - LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_1); - LL_SetSystemCoreClock(170000000); - - /* Update the time base */ - if (HAL_InitTick(TICK_INT_PRIORITY) != HAL_OK) { - Error_Handler(); - } -} - -/* USER CODE BEGIN 4 */ - -/* USER CODE END 4 */ - -/** - * @brief This function is executed in case of error occurrence. - * @retval None - */ -void Error_Handler(void) -{ - /* USER CODE BEGIN Error_Handler_Debug */ - /* User can add his own implementation to report the HAL error return - * state */ - __disable_irq(); - while (1) {} - /* USER CODE END Error_Handler_Debug */ -} -#ifdef USE_FULL_ASSERT -/** - * @brief Reports the name of the source file and the source line number - * where the assert_param error has occurred. - * @param file: pointer to the source file name - * @param line: assert_param error line source number - * @retval None - */ -void assert_failed(uint8_t *file, uint32_t line) -{ - /* USER CODE BEGIN 6 */ - /* User can add his own implementation to report the file name and line - number, ex: printf("Wrong parameters value: file %s on line %d\r\n", - file, line) */ - /* USER CODE END 6 */ -} -#endif /* USE_FULL_ASSERT */ diff --git a/G474xE_CAN_TESTING/CAN_STRESS_TEST/CMakeLists.txt b/G474xE_CAN_TESTING/CAN_STRESS_TEST/CMakeLists.txt deleted file mode 100644 index 3be5c86bd..000000000 --- a/G474xE_CAN_TESTING/CAN_STRESS_TEST/CMakeLists.txt +++ /dev/null @@ -1,53 +0,0 @@ -cmake_minimum_required(VERSION 3.25) - -# Setup compiler settings -set(CMAKE_C_STANDARD 11) -set(CMAKE_C_STANDARD_REQUIRED ON) -set(CMAKE_C_EXTENSIONS ON) - -# Define the build type -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Debug") -endif() - -# Enable compile command to ease indexing with e.g. clangd -set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE) - -# Enable CMake support for ASM and C languages -enable_language( - C - ASM -) - -# Core project settings -project(${CMAKE_PROJECT_NAME}) - -# what, does in fact not get the filename of somthing but rather the name of the project from the path -get_filename_component(PROJECT_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME) - -add_library(${PROJECT_NAME}_USER_CODE INTERFACE) - -target_sources( - ${PROJECT_NAME}_USER_CODE - INTERFACE - ../Core/Src/adc.c - ../Core/Src/crc.c - ../Core/Src/dma.c - ../Core/Src/gpio.c - ../Core/Src/i2c.c - main.c - ../Core/Src/spi.c - ../Core/Src/stm32g4xx_hal_msp.c - ../Core/Src/stm32g4xx_it.c - ../Core/Src/tim.c - ../Core/Src/usart.c -) - -target_link_libraries(${PROJECT_NAME}_USER_CODE INTERFACE PERIPHERAL_CAN_LIB) - -target_include_directories( - ${PROJECT_NAME}_USER_CODE - INTERFACE - ../Core/Inc - . -) diff --git a/G474xE_CAN_TESTING/CAN_STRESS_TEST/can_cfg.h b/G474xE_CAN_TESTING/CAN_STRESS_TEST/can_cfg.h deleted file mode 100644 index fc11e3e23..000000000 --- a/G474xE_CAN_TESTING/CAN_STRESS_TEST/can_cfg.h +++ /dev/null @@ -1,11 +0,0 @@ - -#ifndef CAN_CFG_H -#define CAN_CFG_H - -#define USECAN1 -#define TX_BUFFER_1_SIZE 10 - -#define USECAN2 -#define TX_BUFFER_2_SIZE 10 - -#endif diff --git a/G474xE_CAN_TESTING/CAN_STRESS_TEST/main.c b/G474xE_CAN_TESTING/CAN_STRESS_TEST/main.c deleted file mode 100644 index 591f49aa6..000000000 --- a/G474xE_CAN_TESTING/CAN_STRESS_TEST/main.c +++ /dev/null @@ -1,275 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file : main.c - * @brief : Main program body - ****************************************************************************** - * @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 "main.h" - -#include "adc.h" -#include "can.h" // Assume this works -#include "can_tests.h" -#include "dma.h" -#include "fdcan.h" -#include "gpio.h" -#include "i2c.h" -#include "spi.h" -#include "tim.h" -#include "usart.h" - -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ -#include "Logomatic.h" -// #include "profile.h" -/* USER CODE END Includes */ - -/* Private typedef -----------------------------------------------------------*/ -/* USER CODE BEGIN PTD */ - -/* USER CODE END PTD */ - -/* Private define ------------------------------------------------------------*/ -/* USER CODE BEGIN PD */ - -/* USER CODE END PD */ - -/* Private macro -------------------------------------------------------------*/ -/* USER CODE BEGIN PM */ - -/* USER CODE END PM */ - -/* Private variables ---------------------------------------------------------*/ - -/* USER CODE BEGIN PV */ -/* USER CODE END PV */ - -/* Private function prototypes -----------------------------------------------*/ -void SystemClock_Config(void); -/* USER CODE BEGIN PFP */ - -/* USER CODE END PFP */ - -/* Private user code ---------------------------------------------------------*/ -/* USER CODE BEGIN 0 */ -/* Enable ITM for SWO output */ -static void ITM_Enable(void) -{ - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOB); - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - GPIO_InitStruct.Pin = LL_GPIO_PIN_3; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_0; - LL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - DBGMCU->CR |= DBGMCU_CR_TRACE_IOEN; - - /* Enable TRC (Trace) */ - CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; - - /* Configure TPI for SWO output (set prescaler for 2MHz SWO clock) */ - TPI->SPPR = 2U; /* 2 = Manchester/async UART mode */ - TPI->ACPR = 84U; /* Prescaler: (170 MHz / (84+1) / 2) ≈ 1MHz SWO */ - - ITM->TER |= (1UL << 0); - ITM->TCR |= (ITM_TCR_ITMENA_Msk | ITM_TCR_SWOENA_Msk); -} -// static int toggleze = 0; -/* USER CODE END 0 */ - -/** - * @brief The application entry point. - * @retval int - */ -int main(void) -{ - /* USER CODE BEGIN 1 */ - - /* USER CODE END 1 */ - - /* MCU - * Configuration--------------------------------------------------------*/ - - /* Reset of all peripherals, Initializes the Flash interface and the - * Systick. */ - HAL_Init(); - /* USER CODE BEGIN Init */ - ITM_Enable(); - /* USER CODE END Init */ - - /* Configure the system clock */ - SystemClock_Config(); - - /* USER CODE BEGIN SysInit */ - - /* USER CODE END SysInit */ - - /* Initialize all configured peripherals */ - MX_GPIO_Init(); - MX_DMA_Init(); - // MX_FDCAN2_Init(); - MX_ADC1_Init(); - MX_LPUART1_UART_Init(); - MX_I2C2_Init(); - MX_USART1_UART_Init(); - MX_SPI3_Init(); - MX_TIM2_Init(); - - /* USER CODE BEGIN 2 */ - - LOGOMATIC("Booted!\n"); - - // LOGOMATIC("running can_stress_test:\n"); - can_stress_test(); - - /* Infinite loop */ - /* USER CODE BEGIN WHILE */ - while (1) { - /* USER CODE END WHILE */ - LOGOMATIC("Main Loop\n"); - LL_mDelay(10000); - - // Receive on GPIOs - // HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, toggleze ? GPIO_PIN_SET - // : GPIO_PIN_RESET); HAL_Delay(1000); msg.data[0] = toggleze ? - // 0x00 : 0x80; can_send(data_can, &msg); - - // RCC->CFGR |= RCC_CFGR_SW; - /* USER CODE BEGIN 3 */ - } -} - -/** - * @brief System Clock Configuration - * @retval None - */ - -// void SystemClock_Config(void) -// { -// LL_FLASH_SetLatency(LL_FLASH_LATENCY_4); -// while (LL_FLASH_GetLatency() != LL_FLASH_LATENCY_4) { -// } -// LL_PWR_EnableRange1BoostMode(); -// LL_RCC_HSE_Enable(); - -// /* Wait till HSE is ready */ -// while (LL_RCC_HSE_IsReady() != 1) { -// } - -// LL_RCC_HSE_EnableCSS(); -// LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSE, LL_RCC_PLLM_DIV_1, 20, -// LL_RCC_PLLR_DIV_2); -// //LL_RCC_PLL_ConfigDomain_48M(LL_RCC_PLLSOURCE_HSE, ); -// LL_RCC_PLL_EnableDomain_SYS(); -// LL_RCC_PLL_Enable(); -// /* Wait till PLL is ready */ -// while (LL_RCC_PLL_IsReady() != 1) { -// } - -// LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL); -// LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_2); -// /* Wait till System clock is ready */ -// while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL) { -// } - -// /* Insure 1us transition state at intermediate medium speed clock*/ -// for (__IO uint32_t i = (170 >> 1); i != 0; i--) -// ; - -// /* Set AHB prescaler*/ -// LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1); -// LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1); -// LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_1); -// LL_SetSystemCoreClock(160000000); - -// /* Update the time base */ -// if (HAL_InitTick(TICK_INT_PRIORITY) != HAL_OK) { -// Error_Handler(); -// } -// }*/ -void SystemClock_Config(void) -{ - LL_FLASH_SetLatency(LL_FLASH_LATENCY_4); - while (LL_FLASH_GetLatency() != LL_FLASH_LATENCY_4) {} - LL_PWR_EnableRange1BoostMode(); - LL_RCC_HSI_Enable(); - /* Wait till HSI is ready */ - while (LL_RCC_HSI_IsReady() != 1) {} - - LL_RCC_HSI_SetCalibTrimming(64); - LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSI, LL_RCC_PLLM_DIV_4, 85, LL_RCC_PLLR_DIV_2); - LL_RCC_PLL_EnableDomain_SYS(); - LL_RCC_PLL_Enable(); - /* Wait till PLL is ready */ - while (LL_RCC_PLL_IsReady() != 1) {} - - LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL); - // LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1); - /* Wait till System clock is ready */ - while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL) {} - - /* Insure 1us transition state at intermediate medium speed clock*/ - for (__IO uint32_t i = (170 >> 1); i != 0; i--) - ; - - /* Set AHB prescaler*/ - LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1); - LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1); - LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_1); - LL_SetSystemCoreClock(170000000); - - /* Update the time base */ - if (HAL_InitTick(TICK_INT_PRIORITY) != HAL_OK) { - Error_Handler(); - } -} - -/* USER CODE BEGIN 4 */ - -/* USER CODE END 4 */ - -/** - * @brief This function is executed in case of error occurrence. - * @retval None - */ -void Error_Handler(void) -{ - /* USER CODE BEGIN Error_Handler_Debug */ - /* User can add his own implementation to report the HAL error return - * state */ - __disable_irq(); - while (1) {} - /* USER CODE END Error_Handler_Debug */ -} -#ifdef USE_FULL_ASSERT -/** - * @brief Reports the name of the source file and the source line number - * where the assert_param error has occurred. - * @param file: pointer to the source file name - * @param line: assert_param error line source number - * @retval None - */ -void assert_failed(uint8_t *file, uint32_t line) -{ - /* USER CODE BEGIN 6 */ - /* User can add his own implementation to report the file name and line - number, ex: printf("Wrong parameters value: file %s on line %d\r\n", - file, line) */ - /* USER CODE END 6 */ -} -#endif /* USE_FULL_ASSERT */ diff --git a/G474xE_CAN_TESTING/Core/Inc/adc.h b/G474xE_CAN_TESTING/Core/Inc/adc.h deleted file mode 100644 index 41154538b..000000000 --- a/G474xE_CAN_TESTING/Core/Inc/adc.h +++ /dev/null @@ -1,49 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file adc.h - * @brief This file contains all the function prototypes for - * the adc.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 __ADC_H__ -#define __ADC_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" - -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* USER CODE BEGIN Private defines */ - -/* USER CODE END Private defines */ - -void MX_ADC1_Init(void); - -/* USER CODE BEGIN Prototypes */ - -/* USER CODE END Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif /* __ADC_H__ */ diff --git a/G474xE_CAN_TESTING/Core/Inc/crc.h b/G474xE_CAN_TESTING/Core/Inc/crc.h deleted file mode 100644 index 133957e92..000000000 --- a/G474xE_CAN_TESTING/Core/Inc/crc.h +++ /dev/null @@ -1,51 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file crc.h - * @brief This file contains all the function prototypes for - * the crc.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 __CRC_H__ -#define __CRC_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" - -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -extern CRC_HandleTypeDef hcrc; - -/* USER CODE BEGIN Private defines */ - -/* USER CODE END Private defines */ - -void MX_CRC_Init(void); - -/* USER CODE BEGIN Prototypes */ - -/* USER CODE END Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif /* __CRC_H__ */ diff --git a/G474xE_CAN_TESTING/Core/Inc/dma.h b/G474xE_CAN_TESTING/Core/Inc/dma.h deleted file mode 100644 index ae819cab4..000000000 --- a/G474xE_CAN_TESTING/Core/Inc/dma.h +++ /dev/null @@ -1,51 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file dma.h - * @brief This file contains all the function prototypes for - * the dma.c file - ****************************************************************************** - * @attention - * - * Copyright (c) 2025 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__ */ diff --git a/G474xE_CAN_TESTING/Core/Inc/i2c.h b/G474xE_CAN_TESTING/Core/Inc/i2c.h deleted file mode 100644 index 0a0a50803..000000000 --- a/G474xE_CAN_TESTING/Core/Inc/i2c.h +++ /dev/null @@ -1,49 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file i2c.h - * @brief This file contains all the function prototypes for - * the i2c.c file - ****************************************************************************** - * @attention - * - * Copyright (c) 2025 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 __I2C_H__ -#define __I2C_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" - -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* USER CODE BEGIN Private defines */ - -/* USER CODE END Private defines */ - -void MX_I2C2_Init(void); - -/* USER CODE BEGIN Prototypes */ - -/* USER CODE END Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif /* __I2C_H__ */ diff --git a/G474xE_CAN_TESTING/Core/Inc/main.h b/G474xE_CAN_TESTING/Core/Inc/main.h deleted file mode 100644 index 23d7ffce4..000000000 --- a/G474xE_CAN_TESTING/Core/Inc/main.h +++ /dev/null @@ -1,115 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file : main.h - * @brief : Header for main.c file. - * This file contains the common defines of the application. - ****************************************************************************** - * @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 __MAIN_H -#define __MAIN_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32g4xx_hal.h" -#include "stm32g4xx_ll_adc.h" -#include "stm32g4xx_ll_bus.h" -#include "stm32g4xx_ll_cortex.h" -#include "stm32g4xx_ll_crs.h" -#include "stm32g4xx_ll_dma.h" -#include "stm32g4xx_ll_exti.h" -#include "stm32g4xx_ll_gpio.h" -#include "stm32g4xx_ll_i2c.h" -#include "stm32g4xx_ll_lpuart.h" -#include "stm32g4xx_ll_pwr.h" -#include "stm32g4xx_ll_rcc.h" -#include "stm32g4xx_ll_spi.h" -#include "stm32g4xx_ll_system.h" -#include "stm32g4xx_ll_tim.h" -#include "stm32g4xx_ll_usart.h" -#include "stm32g4xx_ll_utils.h" - -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* Exported types ------------------------------------------------------------*/ -/* USER CODE BEGIN ET */ - -/* USER CODE END ET */ - -/* Exported constants --------------------------------------------------------*/ -/* USER CODE BEGIN EC */ - -/* USER CODE END EC */ - -/* Exported macro ------------------------------------------------------------*/ -/* USER CODE BEGIN EM */ - -/* USER CODE END EM */ - -/* Exported functions prototypes ---------------------------------------------*/ -void Error_Handler(void); - -/* USER CODE BEGIN EFP */ - -/* USER CODE END EFP */ - -/* Private defines -----------------------------------------------------------*/ -#define BSPD_SIGNAL_Pin LL_GPIO_PIN_1 -#define BSPD_SIGNAL_GPIO_Port GPIOC -#define APPS1_SIGNAL_Pin LL_GPIO_PIN_2 -#define APPS1_SIGNAL_GPIO_Port GPIOC -#define APPS2_SIGNAL_Pin LL_GPIO_PIN_3 -#define APPS2_SIGNAL_GPIO_Port GPIOC -#define BLINKY_Pin LL_GPIO_PIN_5 -#define BLINKY_GPIO_Port GPIOA -#define IMD_SENSE_Pin LL_GPIO_PIN_6 -#define IMD_SENSE_GPIO_Port GPIOA -#define AMS_SENSE_Pin LL_GPIO_PIN_7 -#define AMS_SENSE_GPIO_Port GPIOA -#define BRAKE_F_SIGNAL_Pin LL_GPIO_PIN_0 -#define BRAKE_F_SIGNAL_GPIO_Port GPIOB -#define BRAKE_R_SIGNAL_Pin LL_GPIO_PIN_1 -#define BRAKE_R_SIGNAL_GPIO_Port GPIOB -#define LED_TEST_Pin LL_GPIO_PIN_11 -#define LED_TEST_GPIO_Port GPIOB -#define AUX_SIGNAL_Pin LL_GPIO_PIN_14 -#define AUX_SIGNAL_GPIO_Port GPIOB -#define STEERING_ANGLE_Pin LL_GPIO_PIN_15 -#define STEERING_ANGLE_GPIO_Port GPIOB -#define BRAKE_LIGHT_Pin LL_GPIO_PIN_4 -#define BRAKE_LIGHT_GPIO_Port GPIOB -#define TSSI_G_CONTROL_Pin LL_GPIO_PIN_5 -#define TSSI_G_CONTROL_GPIO_Port GPIOB -#define AUX_CONTROL_Pin LL_GPIO_PIN_8 -#define AUX_CONTROL_GPIO_Port GPIOB -#define SOFTWARE_OK_CONTROL_Pin LL_GPIO_PIN_9 -#define SOFTWARE_OK_CONTROL_GPIO_Port GPIOB - -/* USER CODE BEGIN Private defines */ - -/* USER CODE END Private defines */ - -#ifdef __cplusplus -} -#endif - -#endif /* __MAIN_H */ diff --git a/G474xE_CAN_TESTING/Core/Inc/spi.h b/G474xE_CAN_TESTING/Core/Inc/spi.h deleted file mode 100644 index 74bed003b..000000000 --- a/G474xE_CAN_TESTING/Core/Inc/spi.h +++ /dev/null @@ -1,49 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file spi.h - * @brief This file contains all the function prototypes for - * the spi.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 __SPI_H__ -#define __SPI_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" - -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* USER CODE BEGIN Private defines */ - -/* USER CODE END Private defines */ - -void MX_SPI3_Init(void); - -/* USER CODE BEGIN Prototypes */ - -/* USER CODE END Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif /* __SPI_H__ */ diff --git a/G474xE_CAN_TESTING/Core/Inc/stm32g4xx_it.h b/G474xE_CAN_TESTING/Core/Inc/stm32g4xx_it.h deleted file mode 100644 index b6c3b2f72..000000000 --- a/G474xE_CAN_TESTING/Core/Inc/stm32g4xx_it.h +++ /dev/null @@ -1,67 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file stm32g4xx_it.h - * @brief This file contains the headers of the interrupt handlers. - ****************************************************************************** - * @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 __STM32G4xx_IT_H -#define __STM32G4xx_IT_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* Exported types ------------------------------------------------------------*/ -/* USER CODE BEGIN ET */ - -/* USER CODE END ET */ - -/* Exported constants --------------------------------------------------------*/ -/* USER CODE BEGIN EC */ - -/* USER CODE END EC */ - -/* Exported macro ------------------------------------------------------------*/ -/* USER CODE BEGIN EM */ - -/* USER CODE END EM */ - -/* Exported functions prototypes ---------------------------------------------*/ -void NMI_Handler(void); -void HardFault_Handler(void); -void MemManage_Handler(void); -void BusFault_Handler(void); -void UsageFault_Handler(void); -void SVC_Handler(void); -void DebugMon_Handler(void); -void PendSV_Handler(void); -void SysTick_Handler(void); -void FDCAN2_IT0_IRQHandler(void); -/* USER CODE BEGIN EFP */ - -/* USER CODE END EFP */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32G4xx_IT_H */ diff --git a/G474xE_CAN_TESTING/Core/Inc/tim.h b/G474xE_CAN_TESTING/Core/Inc/tim.h deleted file mode 100644 index c19e6cc71..000000000 --- a/G474xE_CAN_TESTING/Core/Inc/tim.h +++ /dev/null @@ -1,49 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file tim.h - * @brief This file contains all the function prototypes for - * the tim.c file - ****************************************************************************** - * @attention - * - * Copyright (c) 2025 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 __TIM_H__ -#define __TIM_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" - -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* USER CODE BEGIN Private defines */ - -/* USER CODE END Private defines */ - -void MX_TIM2_Init(void); - -/* USER CODE BEGIN Prototypes */ - -/* USER CODE END Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif /* __TIM_H__ */ diff --git a/G474xE_CAN_TESTING/Core/Inc/usart.h b/G474xE_CAN_TESTING/Core/Inc/usart.h deleted file mode 100644 index daefd73e6..000000000 --- a/G474xE_CAN_TESTING/Core/Inc/usart.h +++ /dev/null @@ -1,50 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file usart.h - * @brief This file contains all the function prototypes for - * the usart.c file - ****************************************************************************** - * @attention - * - * Copyright (c) 2025 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 __USART_H__ -#define __USART_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" - -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* USER CODE BEGIN Private defines */ - -/* USER CODE END Private defines */ - -void MX_LPUART1_UART_Init(void); -void MX_USART1_UART_Init(void); - -/* USER CODE BEGIN Prototypes */ - -/* USER CODE END Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif /* __USART_H__ */ diff --git a/G474xE_CAN_TESTING/Core/Src/adc.c b/G474xE_CAN_TESTING/Core/Src/adc.c deleted file mode 100644 index f3dbff8ed..000000000 --- a/G474xE_CAN_TESTING/Core/Src/adc.c +++ /dev/null @@ -1,186 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file adc.c - * @brief This file provides code for the configuration - * of the ADC 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 "adc.h" - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/* ADC1 init function */ -void MX_ADC1_Init(void) -{ - - /* USER CODE BEGIN ADC1_Init 0 */ - - /* USER CODE END ADC1_Init 0 */ - - LL_ADC_InitTypeDef ADC_InitStruct = {0}; - LL_ADC_REG_InitTypeDef ADC_REG_InitStruct = {0}; - LL_ADC_CommonInitTypeDef ADC_CommonInitStruct = {0}; - - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - - LL_RCC_SetADCClockSource(LL_RCC_ADC12_CLKSOURCE_SYSCLK); - - /* Peripheral clock enable */ - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_ADC12); - - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOB); - /**ADC1 GPIO Configuration - PC1 ------> ADC1_IN7 - PC2 ------> ADC1_IN8 - PC3 ------> ADC1_IN9 - PB0 ------> ADC1_IN15 - PB1 ------> ADC1_IN12 - PB14 ------> ADC1_IN5 - */ - GPIO_InitStruct.Pin = BSPD_SIGNAL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(BSPD_SIGNAL_GPIO_Port, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = APPS1_SIGNAL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(APPS1_SIGNAL_GPIO_Port, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = APPS2_SIGNAL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(APPS2_SIGNAL_GPIO_Port, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = BRAKE_F_SIGNAL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(BRAKE_F_SIGNAL_GPIO_Port, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = BRAKE_R_SIGNAL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(BRAKE_R_SIGNAL_GPIO_Port, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = AUX_SIGNAL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(AUX_SIGNAL_GPIO_Port, &GPIO_InitStruct); - - /* ADC1 DMA Init */ - - /* ADC1 Init */ - LL_DMA_SetPeriphRequest(DMA1, LL_DMA_CHANNEL_1, LL_DMAMUX_REQ_ADC1); - - LL_DMA_SetDataTransferDirection(DMA1, LL_DMA_CHANNEL_1, LL_DMA_DIRECTION_PERIPH_TO_MEMORY); - - LL_DMA_SetChannelPriorityLevel(DMA1, LL_DMA_CHANNEL_1, LL_DMA_PRIORITY_LOW); - - LL_DMA_SetMode(DMA1, LL_DMA_CHANNEL_1, LL_DMA_MODE_CIRCULAR); - - LL_DMA_SetPeriphIncMode(DMA1, LL_DMA_CHANNEL_1, LL_DMA_PERIPH_NOINCREMENT); - - LL_DMA_SetMemoryIncMode(DMA1, LL_DMA_CHANNEL_1, LL_DMA_MEMORY_INCREMENT); - - LL_DMA_SetPeriphSize(DMA1, LL_DMA_CHANNEL_1, LL_DMA_PDATAALIGN_HALFWORD); - - LL_DMA_SetMemorySize(DMA1, LL_DMA_CHANNEL_1, LL_DMA_MDATAALIGN_HALFWORD); - - /* USER CODE BEGIN ADC1_Init 1 */ - - /* USER CODE END ADC1_Init 1 */ - - /** Common config - */ - ADC_InitStruct.Resolution = LL_ADC_RESOLUTION_12B; - ADC_InitStruct.DataAlignment = LL_ADC_DATA_ALIGN_RIGHT; - ADC_InitStruct.LowPowerMode = LL_ADC_LP_MODE_NONE; - LL_ADC_Init(ADC1, &ADC_InitStruct); - ADC_REG_InitStruct.TriggerSource = LL_ADC_REG_TRIG_SOFTWARE; - ADC_REG_InitStruct.SequencerLength = LL_ADC_REG_SEQ_SCAN_ENABLE_6RANKS; - ADC_REG_InitStruct.SequencerDiscont = LL_ADC_REG_SEQ_DISCONT_DISABLE; - ADC_REG_InitStruct.ContinuousMode = LL_ADC_REG_CONV_CONTINUOUS; - ADC_REG_InitStruct.DMATransfer = LL_ADC_REG_DMA_TRANSFER_UNLIMITED; - ADC_REG_InitStruct.Overrun = LL_ADC_REG_OVR_DATA_PRESERVED; - LL_ADC_REG_Init(ADC1, &ADC_REG_InitStruct); - LL_ADC_SetGainCompensation(ADC1, 0); - LL_ADC_SetOverSamplingScope(ADC1, LL_ADC_OVS_DISABLE); - ADC_CommonInitStruct.CommonClock = LL_ADC_CLOCK_ASYNC_DIV256; - ADC_CommonInitStruct.Multimode = LL_ADC_MULTI_INDEPENDENT; - LL_ADC_CommonInit(__LL_ADC_COMMON_INSTANCE(ADC1), &ADC_CommonInitStruct); - - /* Disable ADC deep power down (enabled by default after reset state) */ - LL_ADC_DisableDeepPowerDown(ADC1); - /* Enable ADC internal voltage regulator */ - LL_ADC_EnableInternalRegulator(ADC1); - /* Delay for ADC internal voltage regulator stabilization. */ - /* Compute number of CPU cycles to wait for, from delay in us. */ - /* Note: Variable divided by 2 to compensate partially */ - /* CPU processing cycles (depends on compilation optimization). */ - /* Note: If system core clock frequency is below 200kHz, wait time */ - /* is only a few CPU processing cycles. */ - uint32_t wait_loop_index; - wait_loop_index = ((LL_ADC_DELAY_INTERNAL_REGUL_STAB_US * (SystemCoreClock / (100000 * 2))) / 10); - while (wait_loop_index != 0) { - wait_loop_index--; - } - - /** Configure Regular Channel - */ - LL_ADC_REG_SetSequencerRanks(ADC1, LL_ADC_REG_RANK_1, LL_ADC_CHANNEL_5); - LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_5, LL_ADC_SAMPLINGTIME_92CYCLES_5); - LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_5, LL_ADC_SINGLE_ENDED); - - /** Configure Regular Channel - */ - LL_ADC_REG_SetSequencerRanks(ADC1, LL_ADC_REG_RANK_2, LL_ADC_CHANNEL_7); - LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_7, LL_ADC_SAMPLINGTIME_92CYCLES_5); - LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_7, LL_ADC_SINGLE_ENDED); - - /** Configure Regular Channel - */ - LL_ADC_REG_SetSequencerRanks(ADC1, LL_ADC_REG_RANK_3, LL_ADC_CHANNEL_8); - LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_8, LL_ADC_SAMPLINGTIME_92CYCLES_5); - LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_8, LL_ADC_SINGLE_ENDED); - - /** Configure Regular Channel - */ - LL_ADC_REG_SetSequencerRanks(ADC1, LL_ADC_REG_RANK_4, LL_ADC_CHANNEL_9); - LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_9, LL_ADC_SAMPLINGTIME_92CYCLES_5); - LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_9, LL_ADC_SINGLE_ENDED); - - /** Configure Regular Channel - */ - LL_ADC_REG_SetSequencerRanks(ADC1, LL_ADC_REG_RANK_5, LL_ADC_CHANNEL_12); - LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_12, LL_ADC_SAMPLINGTIME_92CYCLES_5); - LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_12, LL_ADC_SINGLE_ENDED); - - /** Configure Regular Channel - */ - LL_ADC_REG_SetSequencerRanks(ADC1, LL_ADC_REG_RANK_6, LL_ADC_CHANNEL_15); - LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_15, LL_ADC_SAMPLINGTIME_92CYCLES_5); - LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_15, LL_ADC_SINGLE_ENDED); - /* USER CODE BEGIN ADC1_Init 2 */ - - /* USER CODE END ADC1_Init 2 */ -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ diff --git a/G474xE_CAN_TESTING/Core/Src/crc.c b/G474xE_CAN_TESTING/Core/Src/crc.c deleted file mode 100644 index 213510a5d..000000000 --- a/G474xE_CAN_TESTING/Core/Src/crc.c +++ /dev/null @@ -1,86 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file crc.c - * @brief This file provides code for the configuration - * of the CRC 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 "crc.h" - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -CRC_HandleTypeDef hcrc; - -/* CRC init function */ -void MX_CRC_Init(void) -{ - - /* USER CODE BEGIN CRC_Init 0 */ - - /* USER CODE END CRC_Init 0 */ - - /* USER CODE BEGIN CRC_Init 1 */ - - /* USER CODE END CRC_Init 1 */ - hcrc.Instance = CRC; - hcrc.Init.DefaultPolynomialUse = DEFAULT_POLYNOMIAL_ENABLE; - hcrc.Init.DefaultInitValueUse = DEFAULT_INIT_VALUE_ENABLE; - hcrc.Init.InputDataInversionMode = CRC_INPUTDATA_INVERSION_NONE; - hcrc.Init.OutputDataInversionMode = CRC_OUTPUTDATA_INVERSION_DISABLE; - hcrc.InputDataFormat = CRC_INPUTDATA_FORMAT_BYTES; - if (HAL_CRC_Init(&hcrc) != HAL_OK) { - Error_Handler(); - } - /* USER CODE BEGIN CRC_Init 2 */ - - /* USER CODE END CRC_Init 2 */ -} - -void HAL_CRC_MspInit(CRC_HandleTypeDef *crcHandle) -{ - - if (crcHandle->Instance == CRC) { - /* USER CODE BEGIN CRC_MspInit 0 */ - - /* USER CODE END CRC_MspInit 0 */ - /* CRC clock enable */ - __HAL_RCC_CRC_CLK_ENABLE(); - /* USER CODE BEGIN CRC_MspInit 1 */ - - /* USER CODE END CRC_MspInit 1 */ - } -} - -void HAL_CRC_MspDeInit(CRC_HandleTypeDef *crcHandle) -{ - - if (crcHandle->Instance == CRC) { - /* USER CODE BEGIN CRC_MspDeInit 0 */ - - /* USER CODE END CRC_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_CRC_CLK_DISABLE(); - /* USER CODE BEGIN CRC_MspDeInit 1 */ - - /* USER CODE END CRC_MspDeInit 1 */ - } -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ diff --git a/G474xE_CAN_TESTING/Core/Src/dma.c b/G474xE_CAN_TESTING/Core/Src/dma.c deleted file mode 100644 index 491e3889d..000000000 --- a/G474xE_CAN_TESTING/Core/Src/dma.c +++ /dev/null @@ -1,50 +0,0 @@ -/* 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) 2025 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) -{ - - /* Init with LL driver */ - /* DMA controller clock enable */ - LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_DMAMUX1); - LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_DMA1); -} - -/* USER CODE BEGIN 2 */ - -/* USER CODE END 2 */ diff --git a/G474xE_CAN_TESTING/Core/Src/fdcan.c b/G474xE_CAN_TESTING/Core/Src/fdcan.c deleted file mode 100644 index ebc13ea73..000000000 --- a/G474xE_CAN_TESTING/Core/Src/fdcan.c +++ /dev/null @@ -1,135 +0,0 @@ -// #include "unused.h" -// /* USER CODE BEGIN Header */ -// /** -// ****************************************************************************** -// * @file fdcan.c -// * @brief This file provides code for the configuration -// * of the FDCAN 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 "fdcan.h" - -// /* USER CODE BEGIN 0 */ - -// /* USER CODE END 0 */ - -// FDCAN_HandleTypeDef hfdcan2; - -// /* FDCAN2 init function */ -// void MX_FDCAN2_Init(void) -// { - -// /* USER CODE BEGIN FDCAN2_Init 0 */ - -// /* USER CODE END FDCAN2_Init 0 */ - -// /* USER CODE BEGIN FDCAN2_Init 1 */ - -// /* USER CODE END FDCAN2_Init 1 */ -// hfdcan2.Instance = FDCAN2; -// hfdcan2.Init.ClockDivider = FDCAN_CLOCK_DIV1; -// hfdcan2.Init.FrameFormat = FDCAN_FRAME_CLASSIC; -// hfdcan2.Init.Mode = FDCAN_MODE_NORMAL; -// hfdcan2.Init.AutoRetransmission = ENABLE; -// hfdcan2.Init.TransmitPause = DISABLE; -// hfdcan2.Init.ProtocolException = ENABLE; -// hfdcan2.Init.NominalPrescaler = 1; -// hfdcan2.Init.NominalSyncJumpWidth = 16; -// hfdcan2.Init.NominalTimeSeg1 = 119; -// hfdcan2.Init.NominalTimeSeg2 = 40; -// hfdcan2.Init.DataPrescaler = 8; -// hfdcan2.Init.DataSyncJumpWidth = 16; -// hfdcan2.Init.DataTimeSeg1 = 14; -// hfdcan2.Init.DataTimeSeg2 = 5; -// hfdcan2.Init.StdFiltersNbr = 0; -// hfdcan2.Init.ExtFiltersNbr = 2; -// hfdcan2.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION; -// if (HAL_FDCAN_Init(&hfdcan2) != HAL_OK) { -// Error_Handler(); -// } -// /* USER CODE BEGIN FDCAN2_Init 2 */ - -// /* USER CODE END FDCAN2_Init 2 */ -// } - -// void HAL_FDCAN_MspInit(FDCAN_HandleTypeDef *fdcanHandle) -// { - -// GPIO_InitTypeDef GPIO_InitStruct = {0}; -// if (fdcanHandle->Instance == FDCAN2) { -// /* USER CODE BEGIN FDCAN2_MspInit 0 */ - -// /* USER CODE END FDCAN2_MspInit 0 */ -// LL_RCC_SetFDCANClockSource(LL_RCC_FDCAN_CLKSOURCE_PCLK1); - -// /* FDCAN2 clock enable */ -// __HAL_RCC_FDCAN_CLK_ENABLE(); - -// __HAL_RCC_GPIOB_CLK_ENABLE(); -// /**FDCAN2 GPIO Configuration -// PB12 ------> FDCAN2_RX -// PB13 ------> FDCAN2_TX -// */ -// GPIO_InitStruct.Pin = GPIO_PIN_12; -// GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; -// GPIO_InitStruct.Pull = GPIO_PULLUP; -// GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; -// GPIO_InitStruct.Alternate = GPIO_AF9_FDCAN2; -// HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - -// GPIO_InitStruct.Pin = GPIO_PIN_13; -// GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; -// GPIO_InitStruct.Pull = GPIO_NOPULL; -// GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; -// GPIO_InitStruct.Alternate = GPIO_AF9_FDCAN2; -// HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - -// /* FDCAN2 interrupt Init */ -// HAL_NVIC_SetPriority(FDCAN2_IT0_IRQn, 0, 0); -// HAL_NVIC_EnableIRQ(FDCAN2_IT0_IRQn); -// /* USER CODE BEGIN FDCAN2_MspInit 1 */ - -// /* USER CODE END FDCAN2_MspInit 1 */ -// } -// } - -// /*void HAL_FDCAN_MspDeInit(FDCAN_HandleTypeDef *fdcanHandle) -// { - -// if (fdcanHandle->Instance == FDCAN2) { -// /* USER CODE BEGIN FDCAN2_MspDeInit 0 */ - -// /* USER CODE END FDCAN2_MspDeInit 0 */ -// /* Peripheral clock disable */ -// __HAL_RCC_FDCAN_CLK_DISABLE(); - -// /**FDCAN2 GPIO Configuration -// PB12 ------> FDCAN2_RX -// PB13 ------> FDCAN2_TX -// */ -// HAL_GPIO_DeInit(GPIOB, GPIO_PIN_12 | GPIO_PIN_13); - -// /* FDCAN2 interrupt Deinit */ -// HAL_NVIC_DisableIRQ(FDCAN2_IT0_IRQn); -// /* USER CODE BEGIN FDCAN2_MspDeInit 1 */ - -// /* USER CODE END FDCAN2_MspDeInit 1 */ -// } -// } - -// /* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ -// UNUSED(5); diff --git a/G474xE_CAN_TESTING/Core/Src/i2c.c b/G474xE_CAN_TESTING/Core/Src/i2c.c deleted file mode 100644 index bfb4e0153..000000000 --- a/G474xE_CAN_TESTING/Core/Src/i2c.c +++ /dev/null @@ -1,92 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file i2c.c - * @brief This file provides code for the configuration - * of the I2C instances. - ****************************************************************************** - * @attention - * - * Copyright (c) 2025 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 "i2c.h" - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/* I2C2 init function */ -void MX_I2C2_Init(void) -{ - - /* USER CODE BEGIN I2C2_Init 0 */ - - /* USER CODE END I2C2_Init 0 */ - - LL_I2C_InitTypeDef I2C_InitStruct = {0}; - - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - - LL_RCC_SetI2CClockSource(LL_RCC_I2C2_CLKSOURCE_PCLK1); - - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA); - /**I2C2 GPIO Configuration - PC4 ------> I2C2_SCL - PA8 ------> I2C2_SDA - */ - GPIO_InitStruct.Pin = LL_GPIO_PIN_4; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_OPENDRAIN; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_4; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = LL_GPIO_PIN_8; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_OPENDRAIN; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_4; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /* Peripheral clock enable */ - LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_I2C2); - - /* USER CODE BEGIN I2C2_Init 1 */ - - /* USER CODE END I2C2_Init 1 */ - - /** I2C Initialization - */ - I2C_InitStruct.PeripheralMode = LL_I2C_MODE_I2C; - I2C_InitStruct.Timing = 0x30D29DE4; - I2C_InitStruct.AnalogFilter = LL_I2C_ANALOGFILTER_ENABLE; - I2C_InitStruct.DigitalFilter = 0; - I2C_InitStruct.OwnAddress1 = 0; - I2C_InitStruct.TypeAcknowledge = LL_I2C_ACK; - I2C_InitStruct.OwnAddrSize = LL_I2C_OWNADDRESS1_7BIT; - LL_I2C_Init(I2C2, &I2C_InitStruct); - LL_I2C_EnableAutoEndMode(I2C2); - LL_I2C_SetOwnAddress2(I2C2, 0, LL_I2C_OWNADDRESS2_NOMASK); - LL_I2C_DisableOwnAddress2(I2C2); - LL_I2C_DisableGeneralCall(I2C2); - LL_I2C_EnableClockStretching(I2C2); - /* USER CODE BEGIN I2C2_Init 2 */ - - /* USER CODE END I2C2_Init 2 */ -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ diff --git a/G474xE_CAN_TESTING/Core/Src/spi.c b/G474xE_CAN_TESTING/Core/Src/spi.c deleted file mode 100644 index 66459f2ec..000000000 --- a/G474xE_CAN_TESTING/Core/Src/spi.c +++ /dev/null @@ -1,95 +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 */ - -/* SPI3 init function */ -void MX_SPI3_Init(void) -{ - - /* USER CODE BEGIN SPI3_Init 0 */ - - /* USER CODE END SPI3_Init 0 */ - - LL_SPI_InitTypeDef SPI_InitStruct = {0}; - - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - - /* Peripheral clock enable */ - LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_SPI3); - - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC); - /**SPI3 GPIO Configuration - PC10 ------> SPI3_SCK - PC11 ------> SPI3_MISO - PC12 ------> SPI3_MOSI - */ - GPIO_InitStruct.Pin = LL_GPIO_PIN_10; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_6; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = LL_GPIO_PIN_11; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_6; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = LL_GPIO_PIN_12; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_6; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /* USER CODE BEGIN SPI3_Init 1 */ - - /* USER CODE END SPI3_Init 1 */ - SPI_InitStruct.TransferDirection = LL_SPI_FULL_DUPLEX; - SPI_InitStruct.Mode = LL_SPI_MODE_MASTER; - SPI_InitStruct.DataWidth = LL_SPI_DATAWIDTH_4BIT; - SPI_InitStruct.ClockPolarity = LL_SPI_POLARITY_LOW; - SPI_InitStruct.ClockPhase = LL_SPI_PHASE_1EDGE; - SPI_InitStruct.NSS = LL_SPI_NSS_SOFT; - SPI_InitStruct.BaudRate = LL_SPI_BAUDRATEPRESCALER_DIV32; - SPI_InitStruct.BitOrder = LL_SPI_MSB_FIRST; - SPI_InitStruct.CRCCalculation = LL_SPI_CRCCALCULATION_DISABLE; - SPI_InitStruct.CRCPoly = 7; - LL_SPI_Init(SPI3, &SPI_InitStruct); - LL_SPI_SetStandard(SPI3, LL_SPI_PROTOCOL_MOTOROLA); - LL_SPI_EnableNSSPulseMgt(SPI3); - /* USER CODE BEGIN SPI3_Init 2 */ - - /* USER CODE END SPI3_Init 2 */ -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ diff --git a/G474xE_CAN_TESTING/Core/Src/stm32g4xx_hal_msp.c b/G474xE_CAN_TESTING/Core/Src/stm32g4xx_hal_msp.c deleted file mode 100644 index 69189ef4e..000000000 --- a/G474xE_CAN_TESTING/Core/Src/stm32g4xx_hal_msp.c +++ /dev/null @@ -1,86 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file stm32g4xx_hal_msp.c - * @brief This file provides code for the MSP Initialization - * and de-Initialization codes. - ****************************************************************************** - * @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 "main.h" -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* Private typedef -----------------------------------------------------------*/ -/* USER CODE BEGIN TD */ - -/* USER CODE END TD */ - -/* Private define ------------------------------------------------------------*/ -/* USER CODE BEGIN Define */ - -/* USER CODE END Define */ - -/* Private macro -------------------------------------------------------------*/ -/* USER CODE BEGIN Macro */ - -/* USER CODE END Macro */ - -/* Private variables ---------------------------------------------------------*/ -/* USER CODE BEGIN PV */ - -/* USER CODE END PV */ - -/* Private function prototypes -----------------------------------------------*/ -/* USER CODE BEGIN PFP */ - -/* USER CODE END PFP */ - -/* External functions --------------------------------------------------------*/ -/* USER CODE BEGIN ExternalFunctions */ - -/* USER CODE END ExternalFunctions */ - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ -/** - * Initializes the Global MSP. - */ -void HAL_MspInit(void) -{ - - /* USER CODE BEGIN MspInit 0 */ - - /* USER CODE END MspInit 0 */ - - __HAL_RCC_SYSCFG_CLK_ENABLE(); - __HAL_RCC_PWR_CLK_ENABLE(); - - /* System interrupt init*/ - - /** Disable the internal Pull-Up in Dead Battery pins of UCPD peripheral - */ - HAL_PWREx_DisableUCPDDeadBattery(); - - /* USER CODE BEGIN MspInit 1 */ - - /* USER CODE END MspInit 1 */ -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ diff --git a/G474xE_CAN_TESTING/Core/Src/stm32g4xx_it.c b/G474xE_CAN_TESTING/Core/Src/stm32g4xx_it.c deleted file mode 100644 index dd322200e..000000000 --- a/G474xE_CAN_TESTING/Core/Src/stm32g4xx_it.c +++ /dev/null @@ -1,194 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file stm32g4xx_it.c - * @brief Interrupt Service Routines. - ****************************************************************************** - * @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 "stm32g4xx_it.h" - -#include "main.h" -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ -/* USER CODE END Includes */ - -/* Private typedef -----------------------------------------------------------*/ -/* USER CODE BEGIN TD */ - -/* USER CODE END TD */ - -/* Private define ------------------------------------------------------------*/ -/* USER CODE BEGIN PD */ - -/* USER CODE END PD */ - -/* Private macro -------------------------------------------------------------*/ -/* USER CODE BEGIN PM */ - -/* USER CODE END PM */ - -/* Private variables ---------------------------------------------------------*/ -/* USER CODE BEGIN PV */ - -/* USER CODE END PV */ - -/* Private function prototypes -----------------------------------------------*/ -/* USER CODE BEGIN PFP */ - -/* USER CODE END PFP */ - -/* Private user code ---------------------------------------------------------*/ -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/* External variables --------------------------------------------------------*/ -// extern FDCAN_HandleTypeDef hfdcan2; -/* USER CODE BEGIN EV */ - -/* USER CODE END EV */ - -/******************************************************************************/ -/* Cortex-M4 Processor Interruption and Exception Handlers */ -/******************************************************************************/ -/** - * @brief This function handles Non maskable interrupt. - */ -void NMI_Handler(void) -{ - /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ - - /* USER CODE END NonMaskableInt_IRQn 0 */ - /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ - while (1) {} - /* USER CODE END NonMaskableInt_IRQn 1 */ -} - -/** - * @brief This function handles Hard fault interrupt. - */ -void HardFault_Handler(void) -{ - /* USER CODE BEGIN HardFault_IRQn 0 */ - - /* USER CODE END HardFault_IRQn 0 */ - while (1) { - /* USER CODE BEGIN W1_HardFault_IRQn 0 */ - /* USER CODE END W1_HardFault_IRQn 0 */ - } -} - -/** - * @brief This function handles Memory management fault. - */ -void MemManage_Handler(void) -{ - /* USER CODE BEGIN MemoryManagement_IRQn 0 */ - - /* USER CODE END MemoryManagement_IRQn 0 */ - while (1) { - /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ - /* USER CODE END W1_MemoryManagement_IRQn 0 */ - } -} - -/** - * @brief This function handles Prefetch fault, memory access fault. - */ -void BusFault_Handler(void) -{ - /* USER CODE BEGIN BusFault_IRQn 0 */ - - /* USER CODE END BusFault_IRQn 0 */ - while (1) { - /* USER CODE BEGIN W1_BusFault_IRQn 0 */ - /* USER CODE END W1_BusFault_IRQn 0 */ - } -} - -/** - * @brief This function handles Undefined instruction or illegal state. - */ -void UsageFault_Handler(void) -{ - /* USER CODE BEGIN UsageFault_IRQn 0 */ - - /* USER CODE END UsageFault_IRQn 0 */ - while (1) { - /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ - /* USER CODE END W1_UsageFault_IRQn 0 */ - } -} - -/** - * @brief This function handles System service call via SWI instruction. - */ -void SVC_Handler(void) -{ - /* USER CODE BEGIN SVCall_IRQn 0 */ - - /* USER CODE END SVCall_IRQn 0 */ - /* USER CODE BEGIN SVCall_IRQn 1 */ - - /* USER CODE END SVCall_IRQn 1 */ -} - -/** - * @brief This function handles Debug monitor. - */ -void DebugMon_Handler(void) -{ - /* USER CODE BEGIN DebugMonitor_IRQn 0 */ - - /* USER CODE END DebugMonitor_IRQn 0 */ - /* USER CODE BEGIN DebugMonitor_IRQn 1 */ - - /* USER CODE END DebugMonitor_IRQn 1 */ -} - -/** - * @brief This function handles Pendable request for system service. - */ -void PendSV_Handler(void) -{ - /* USER CODE BEGIN PendSV_IRQn 0 */ - - /* USER CODE END PendSV_IRQn 0 */ - /* USER CODE BEGIN PendSV_IRQn 1 */ - - /* USER CODE END PendSV_IRQn 1 */ -} - -/** - * @brief This function handles System tick timer. - */ -void SysTick_Handler(void) -{ - /* USER CODE BEGIN SysTick_IRQn 0 */ - - /* USER CODE END SysTick_IRQn 0 */ - HAL_IncTick(); - /* USER CODE BEGIN SysTick_IRQn 1 */ - - /* USER CODE END SysTick_IRQn 1 */ -} - -/******************************************************************************/ -/* STM32G4xx Peripheral Interrupt Handlers */ -/* Add here the Interrupt Handlers for the used peripherals. */ -/* For the available peripheral interrupt handler names, */ -/* please refer to the startup file (startup_stm32g4xx.s). */ -/******************************************************************************/ diff --git a/G474xE_CAN_TESTING/Core/Src/tim.c b/G474xE_CAN_TESTING/Core/Src/tim.c deleted file mode 100644 index 7f521c3bf..000000000 --- a/G474xE_CAN_TESTING/Core/Src/tim.c +++ /dev/null @@ -1,79 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file tim.c - * @brief This file provides code for the configuration - * of the TIM instances. - ****************************************************************************** - * @attention - * - * Copyright (c) 2025 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 "tim.h" - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/* TIM2 init function */ -void MX_TIM2_Init(void) -{ - - /* USER CODE BEGIN TIM2_Init 0 */ - - /* USER CODE END TIM2_Init 0 */ - - LL_TIM_InitTypeDef TIM_InitStruct = {0}; - LL_TIM_OC_InitTypeDef TIM_OC_InitStruct = {0}; - - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - /* Peripheral clock enable */ - LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM2); - - /* USER CODE BEGIN TIM2_Init 1 */ - - /* USER CODE END TIM2_Init 1 */ - TIM_InitStruct.Prescaler = 0; - TIM_InitStruct.CounterMode = LL_TIM_COUNTERMODE_UP; - TIM_InitStruct.Autoreload = 4294967295; - TIM_InitStruct.ClockDivision = LL_TIM_CLOCKDIVISION_DIV1; - LL_TIM_Init(TIM2, &TIM_InitStruct); - LL_TIM_DisableARRPreload(TIM2); - LL_TIM_SetClockSource(TIM2, LL_TIM_CLOCKSOURCE_INTERNAL); - TIM_OC_InitStruct.OCMode = LL_TIM_OCMODE_FORCED_ACTIVE; - TIM_OC_InitStruct.OCState = LL_TIM_OCSTATE_DISABLE; - TIM_OC_InitStruct.OCNState = LL_TIM_OCSTATE_DISABLE; - TIM_OC_InitStruct.CompareValue = 0; - TIM_OC_InitStruct.OCPolarity = LL_TIM_OCPOLARITY_HIGH; - LL_TIM_OC_Init(TIM2, LL_TIM_CHANNEL_CH1, &TIM_OC_InitStruct); - LL_TIM_OC_DisableFast(TIM2, LL_TIM_CHANNEL_CH1); - LL_TIM_SetTriggerOutput(TIM2, LL_TIM_TRGO_RESET); - LL_TIM_DisableMasterSlaveMode(TIM2); - /* USER CODE BEGIN TIM2_Init 2 */ - - /* USER CODE END TIM2_Init 2 */ - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA); - /**TIM2 GPIO Configuration - PA0 ------> TIM2_CH1 - */ - GPIO_InitStruct.Pin = LL_GPIO_PIN_0; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_1; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ diff --git a/G474xE_CAN_TESTING/Core/Src/usart.c b/G474xE_CAN_TESTING/Core/Src/usart.c deleted file mode 100644 index 41561862c..000000000 --- a/G474xE_CAN_TESTING/Core/Src/usart.c +++ /dev/null @@ -1,184 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file usart.c - * @brief This file provides code for the configuration - * of the USART instances. - ****************************************************************************** - * @attention - * - * Copyright (c) 2025 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 "usart.h" - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/* LPUART1 init function */ - -void MX_LPUART1_UART_Init(void) -{ - - /* USER CODE BEGIN LPUART1_Init 0 */ - - /* USER CODE END LPUART1_Init 0 */ - - LL_LPUART_InitTypeDef LPUART_InitStruct = {0}; - - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - - LL_RCC_SetLPUARTClockSource(LL_RCC_LPUART1_CLKSOURCE_HSI); - - /* Peripheral clock enable */ - LL_APB1_GRP2_EnableClock(LL_APB1_GRP2_PERIPH_LPUART1); - - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA); - /**LPUART1 GPIO Configuration - PA2 ------> LPUART1_TX - PA3 ------> LPUART1_RX - */ - GPIO_InitStruct.Pin = LL_GPIO_PIN_2; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_12; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = LL_GPIO_PIN_3; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_12; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /* USER CODE BEGIN LPUART1_Init 1 */ - - /* USER CODE END LPUART1_Init 1 */ - LPUART_InitStruct.PrescalerValue = LL_LPUART_PRESCALER_DIV1; - LPUART_InitStruct.BaudRate = 115200; - LPUART_InitStruct.DataWidth = LL_LPUART_DATAWIDTH_8B; - LPUART_InitStruct.StopBits = LL_LPUART_STOPBITS_1; - LPUART_InitStruct.Parity = LL_LPUART_PARITY_NONE; - LPUART_InitStruct.TransferDirection = LL_LPUART_DIRECTION_TX_RX; - LPUART_InitStruct.HardwareFlowControl = LL_LPUART_HWCONTROL_NONE; - LL_LPUART_Init(LPUART1, &LPUART_InitStruct); - LL_LPUART_SetTXFIFOThreshold(LPUART1, LL_LPUART_FIFOTHRESHOLD_1_8); - LL_LPUART_SetRXFIFOThreshold(LPUART1, LL_LPUART_FIFOTHRESHOLD_1_8); - LL_LPUART_DisableFIFO(LPUART1); - - /* USER CODE BEGIN WKUPType LPUART1 */ - - /* USER CODE END WKUPType LPUART1 */ - - LL_LPUART_Enable(LPUART1); - - /* Polling LPUART1 initialisation */ - while ((!(LL_LPUART_IsActiveFlag_TEACK(LPUART1))) || (!(LL_LPUART_IsActiveFlag_REACK(LPUART1)))) {} - /* USER CODE BEGIN LPUART1_Init 2 */ - - /* USER CODE END LPUART1_Init 2 */ -} -/* USART1 init function */ - -void MX_USART1_UART_Init(void) -{ - - /* USER CODE BEGIN USART1_Init 0 */ - - /* USER CODE END USART1_Init 0 */ - - LL_USART_InitTypeDef USART_InitStruct = {0}; - - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - - LL_RCC_SetUSARTClockSource(LL_RCC_USART1_CLKSOURCE_PCLK2); - - /* Peripheral clock enable */ - LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_USART1); - - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOB); - /**USART1 GPIO Configuration - PC5 ------> USART1_RX - PA11 ------> USART1_CTS - PA12 ------> USART1_RTS - PB6 ------> USART1_TX - */ - GPIO_InitStruct.Pin = LL_GPIO_PIN_5; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_7; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = LL_GPIO_PIN_11; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_7; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = LL_GPIO_PIN_12; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_7; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = LL_GPIO_PIN_6; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_7; - LL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - /* USER CODE BEGIN USART1_Init 1 */ - - /* USER CODE END USART1_Init 1 */ - USART_InitStruct.PrescalerValue = LL_USART_PRESCALER_DIV1; - USART_InitStruct.BaudRate = 115200; - USART_InitStruct.DataWidth = LL_USART_DATAWIDTH_8B; - USART_InitStruct.StopBits = LL_USART_STOPBITS_1; - USART_InitStruct.Parity = LL_USART_PARITY_NONE; - USART_InitStruct.TransferDirection = LL_USART_DIRECTION_TX_RX; - USART_InitStruct.HardwareFlowControl = LL_USART_HWCONTROL_RTS_CTS; - USART_InitStruct.OverSampling = LL_USART_OVERSAMPLING_16; - LL_USART_Init(USART1, &USART_InitStruct); - LL_USART_SetTXFIFOThreshold(USART1, LL_USART_FIFOTHRESHOLD_1_8); - LL_USART_SetRXFIFOThreshold(USART1, LL_USART_FIFOTHRESHOLD_1_8); - LL_USART_DisableFIFO(USART1); - LL_USART_ConfigAsyncMode(USART1); - - /* USER CODE BEGIN WKUPType USART1 */ - - /* USER CODE END WKUPType USART1 */ - - LL_USART_Enable(USART1); - - /* Polling USART1 initialisation */ - while ((!(LL_USART_IsActiveFlag_TEACK(USART1))) || (!(LL_USART_IsActiveFlag_REACK(USART1)))) {} - /* USER CODE BEGIN USART1_Init 2 */ - - /* USER CODE END USART1_Init 2 */ -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ diff --git a/G474xE_CAN_TESTING/G4PERTESTING.ioc b/G474xE_CAN_TESTING/G4PERTESTING.ioc deleted file mode 100644 index 8cf1860b1..000000000 --- a/G474xE_CAN_TESTING/G4PERTESTING.ioc +++ /dev/null @@ -1,382 +0,0 @@ -#MicroXplorer Configuration settings - do not modify -ADC1.Channel-2\#ChannelRegularConversion=ADC_CHANNEL_5 -ADC1.Channel-3\#ChannelRegularConversion=ADC_CHANNEL_7 -ADC1.Channel-4\#ChannelRegularConversion=ADC_CHANNEL_8 -ADC1.Channel-5\#ChannelRegularConversion=ADC_CHANNEL_9 -ADC1.Channel-6\#ChannelRegularConversion=ADC_CHANNEL_12 -ADC1.Channel-7\#ChannelRegularConversion=ADC_CHANNEL_15 -ADC1.ClockPrescaler=ADC_CLOCK_ASYNC_DIV256 -ADC1.CommonPathInternal=null|null|null|null -ADC1.ContinuousConvMode=ENABLE -ADC1.DMAContinuousRequests=ENABLE -ADC1.EOCSelection=ADC_EOC_SEQ_CONV -ADC1.ExternalTrigConv=ADC_SOFTWARE_START -ADC1.IPParameters=Rank-2\#ChannelRegularConversion,Channel-2\#ChannelRegularConversion,SamplingTime-2\#ChannelRegularConversion,OffsetNumber-2\#ChannelRegularConversion,NbrOfConversionFlag,master,Rank-3\#ChannelRegularConversion,Channel-3\#ChannelRegularConversion,SamplingTime-3\#ChannelRegularConversion,OffsetNumber-3\#ChannelRegularConversion,Rank-4\#ChannelRegularConversion,Channel-4\#ChannelRegularConversion,SamplingTime-4\#ChannelRegularConversion,OffsetNumber-4\#ChannelRegularConversion,Rank-5\#ChannelRegularConversion,Channel-5\#ChannelRegularConversion,SamplingTime-5\#ChannelRegularConversion,OffsetNumber-5\#ChannelRegularConversion,Rank-6\#ChannelRegularConversion,Channel-6\#ChannelRegularConversion,SamplingTime-6\#ChannelRegularConversion,OffsetNumber-6\#ChannelRegularConversion,Rank-7\#ChannelRegularConversion,Channel-7\#ChannelRegularConversion,SamplingTime-7\#ChannelRegularConversion,OffsetNumber-7\#ChannelRegularConversion,NbrOfConversion,ContinuousConvMode,DMAContinuousRequests,ClockPrescaler,EOCSelection,ExternalTrigConv,CommonPathInternal -ADC1.NbrOfConversion=6 -ADC1.NbrOfConversionFlag=1 -ADC1.OffsetNumber-2\#ChannelRegularConversion=ADC_OFFSET_NONE -ADC1.OffsetNumber-3\#ChannelRegularConversion=ADC_OFFSET_NONE -ADC1.OffsetNumber-4\#ChannelRegularConversion=ADC_OFFSET_NONE -ADC1.OffsetNumber-5\#ChannelRegularConversion=ADC_OFFSET_NONE -ADC1.OffsetNumber-6\#ChannelRegularConversion=ADC_OFFSET_NONE -ADC1.OffsetNumber-7\#ChannelRegularConversion=ADC_OFFSET_NONE -ADC1.Rank-2\#ChannelRegularConversion=1 -ADC1.Rank-3\#ChannelRegularConversion=2 -ADC1.Rank-4\#ChannelRegularConversion=3 -ADC1.Rank-5\#ChannelRegularConversion=4 -ADC1.Rank-6\#ChannelRegularConversion=5 -ADC1.Rank-7\#ChannelRegularConversion=6 -ADC1.SamplingTime-2\#ChannelRegularConversion=ADC_SAMPLETIME_92CYCLES_5 -ADC1.SamplingTime-3\#ChannelRegularConversion=ADC_SAMPLETIME_92CYCLES_5 -ADC1.SamplingTime-4\#ChannelRegularConversion=ADC_SAMPLETIME_92CYCLES_5 -ADC1.SamplingTime-5\#ChannelRegularConversion=ADC_SAMPLETIME_92CYCLES_5 -ADC1.SamplingTime-6\#ChannelRegularConversion=ADC_SAMPLETIME_92CYCLES_5 -ADC1.SamplingTime-7\#ChannelRegularConversion=ADC_SAMPLETIME_92CYCLES_5 -ADC1.master=1 -CAD.formats=[] -CAD.pinconfig=Dual -CAD.provider= -Dma.ADC1.0.Direction=DMA_PERIPH_TO_MEMORY -Dma.ADC1.0.EventEnable=DISABLE -Dma.ADC1.0.Instance=DMA1_Channel1 -Dma.ADC1.0.MemDataAlignment=DMA_MDATAALIGN_HALFWORD -Dma.ADC1.0.MemInc=DMA_MINC_ENABLE -Dma.ADC1.0.Mode=DMA_CIRCULAR -Dma.ADC1.0.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD -Dma.ADC1.0.PeriphInc=DMA_PINC_DISABLE -Dma.ADC1.0.Polarity=HAL_DMAMUX_REQ_GEN_RISING -Dma.ADC1.0.Priority=DMA_PRIORITY_LOW -Dma.ADC1.0.RequestNumber=1 -Dma.ADC1.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -Dma.ADC1.0.SignalID=NONE -Dma.ADC1.0.SyncEnable=DISABLE -Dma.ADC1.0.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT -Dma.ADC1.0.SyncRequestNumber=1 -Dma.ADC1.0.SyncSignalID=NONE -Dma.Request0=ADC1 -Dma.RequestsNb=1 -FDCAN2.AutoRetransmission=ENABLE -FDCAN2.CalculateBaudRateNominal=1000000 -FDCAN2.CalculateTimeBitNominal=1000 -FDCAN2.CalculateTimeQuantumNominal=6.25 -FDCAN2.DataPrescaler=8 -FDCAN2.DataSyncJumpWidth=16 -FDCAN2.DataTimeSeg1=14 -FDCAN2.DataTimeSeg2=5 -FDCAN2.ExtFiltersNbr=2 -FDCAN2.FrameFormat=FDCAN_FRAME_CLASSIC -FDCAN2.IPParameters=CalculateTimeQuantumNominal,CalculateTimeBitNominal,CalculateBaudRateNominal,FrameFormat,NominalTimeSeg1,NominalTimeSeg2,NominalPrescaler,AutoRetransmission,StdFiltersNbr,TransmitPause,NominalSyncJumpWidth,DataTimeSeg1,DataTimeSeg2,DataPrescaler,DataSyncJumpWidth,ExtFiltersNbr,ProtocolException -FDCAN2.NominalPrescaler=1 -FDCAN2.NominalSyncJumpWidth=16 -FDCAN2.NominalTimeSeg1=119 -FDCAN2.NominalTimeSeg2=40 -FDCAN2.ProtocolException=ENABLE -FDCAN2.StdFiltersNbr=0 -FDCAN2.TransmitPause=DISABLE -File.Version=6 -GPIO.groupedBy=Group By Peripherals -I2C2.IPParameters=Timing -I2C2.Timing=0x30D29DE4 -KeepUserPlacement=false -LPUART1.BaudRate=115200 -LPUART1.IPParameters=BaudRate -Mcu.CPN=STM32G474RET6 -Mcu.Family=STM32G4 -Mcu.IP0=ADC1 -Mcu.IP1=DMA -Mcu.IP10=USART1 -Mcu.IP2=FDCAN2 -Mcu.IP3=I2C2 -Mcu.IP4=LPUART1 -Mcu.IP5=NVIC -Mcu.IP6=RCC -Mcu.IP7=SPI3 -Mcu.IP8=SYS -Mcu.IP9=TIM2 -Mcu.IPNb=11 -Mcu.Name=STM32G474R(B-C-E)Tx -Mcu.Package=LQFP64 -Mcu.Pin0=PF0-OSC_IN -Mcu.Pin1=PF1-OSC_OUT -Mcu.Pin10=PA7 -Mcu.Pin11=PC4 -Mcu.Pin12=PC5 -Mcu.Pin13=PB0 -Mcu.Pin14=PB1 -Mcu.Pin15=PB11 -Mcu.Pin16=PB12 -Mcu.Pin17=PB13 -Mcu.Pin18=PB14 -Mcu.Pin19=PB15 -Mcu.Pin2=PC1 -Mcu.Pin20=PA8 -Mcu.Pin21=PA11 -Mcu.Pin22=PA12 -Mcu.Pin23=PA13 -Mcu.Pin24=PA14 -Mcu.Pin25=PC10 -Mcu.Pin26=PC11 -Mcu.Pin27=PC12 -Mcu.Pin28=PB3 -Mcu.Pin29=PB4 -Mcu.Pin3=PC2 -Mcu.Pin30=PB5 -Mcu.Pin31=PB6 -Mcu.Pin32=PB7 -Mcu.Pin33=PB8-BOOT0 -Mcu.Pin34=PB9 -Mcu.Pin35=VP_SYS_VS_Systick -Mcu.Pin36=VP_SYS_VS_DBSignals -Mcu.Pin37=VP_TIM2_VS_ClockSourceINT -Mcu.Pin4=PC3 -Mcu.Pin5=PA0 -Mcu.Pin6=PA2 -Mcu.Pin7=PA3 -Mcu.Pin8=PA5 -Mcu.Pin9=PA6 -Mcu.PinsNb=38 -Mcu.ThirdPartyNb=0 -Mcu.UserConstants= -Mcu.UserName=STM32G474RETx -MxCube.Version=6.15.0 -MxDb.Version=DB.6.0.150 -NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.FDCAN2_IT0_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true -NVIC.ForceEnableDMAVector=false -NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:false -NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 -NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:false -NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -PA0.Signal=S_TIM2_CH1 -PA11.Locked=true -PA11.Mode=CTS_RTS -PA11.Signal=USART1_CTS -PA12.Locked=true -PA12.Mode=CTS_RTS -PA12.Signal=USART1_RTS -PA13.Locked=true -PA13.Mode=Trace_Asynchronous_SW -PA13.Signal=SYS_JTMS-SWDIO -PA14.Locked=true -PA14.Mode=Trace_Asynchronous_SW -PA14.Signal=SYS_JTCK-SWCLK -PA2.GPIOParameters=GPIO_Speed -PA2.GPIO_Speed=GPIO_SPEED_FREQ_HIGH -PA2.Locked=true -PA2.Mode=Asynchronous -PA2.Signal=LPUART1_TX -PA3.GPIOParameters=GPIO_Speed -PA3.GPIO_Speed=GPIO_SPEED_FREQ_HIGH -PA3.Locked=true -PA3.Mode=Asynchronous -PA3.Signal=LPUART1_RX -PA5.GPIOParameters=GPIO_Label -PA5.GPIO_Label=BLINKY -PA5.Locked=true -PA5.Signal=GPIO_Output -PA6.GPIOParameters=GPIO_Label -PA6.GPIO_Label=IMD_SENSE -PA6.Locked=true -PA6.Signal=ADC2_IN3 -PA7.GPIOParameters=GPIO_Label -PA7.GPIO_Label=AMS_SENSE -PA7.Locked=true -PA7.Signal=ADC2_IN4 -PA8.Mode=I2C -PA8.Signal=I2C2_SDA -PB0.GPIOParameters=GPIO_Label -PB0.GPIO_Label=BRAKE_F_SIGNAL -PB0.Locked=true -PB0.Mode=IN15-Single-Ended -PB0.Signal=ADC1_IN15 -PB1.GPIOParameters=GPIO_Label -PB1.GPIO_Label=BRAKE_R_SIGNAL -PB1.Locked=true -PB1.Mode=IN12-Single-Ended -PB1.Signal=ADC1_IN12 -PB11.GPIOParameters=GPIO_Label -PB11.GPIO_Label=LED_TEST -PB11.Locked=true -PB11.Signal=GPIO_Output -PB12.GPIOParameters=GPIO_Speed,GPIO_PuPd -PB12.GPIO_PuPd=GPIO_PULLUP -PB12.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH -PB12.Locked=true -PB12.Mode=FDCAN_Activate -PB12.Signal=FDCAN2_RX -PB13.GPIOParameters=GPIO_Speed -PB13.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH -PB13.Locked=true -PB13.Mode=FDCAN_Activate -PB13.Signal=FDCAN2_TX -PB14.GPIOParameters=GPIO_Label -PB14.GPIO_Label=AUX_SIGNAL -PB14.Locked=true -PB14.Mode=IN5-Single-Ended -PB14.Signal=ADC1_IN5 -PB15.GPIOParameters=GPIO_Label -PB15.GPIO_Label=STEERING_ANGLE -PB15.Locked=true -PB15.Signal=ADC2_IN15 -PB3.Locked=true -PB3.Mode=Trace_Asynchronous_SW -PB3.Signal=SYS_JTDO-SWO -PB4.GPIOParameters=GPIO_Label -PB4.GPIO_Label=BRAKE_LIGHT -PB4.Locked=true -PB4.Signal=GPIO_Output -PB5.GPIOParameters=GPIO_Label -PB5.GPIO_Label=TSSI_G_CONTROL -PB5.Locked=true -PB5.Signal=GPIO_Output -PB6.Locked=true -PB6.Mode=Asynchronous -PB6.Signal=USART1_TX -PB7.Locked=true -PB7.Signal=UART4_CTS -PB8-BOOT0.GPIOParameters=GPIO_Label -PB8-BOOT0.GPIO_Label=AUX_CONTROL -PB8-BOOT0.Locked=true -PB8-BOOT0.Signal=GPIO_Output -PB9.GPIOParameters=GPIO_Label -PB9.GPIO_Label=SOFTWARE_OK_CONTROL -PB9.Locked=true -PB9.Signal=GPIO_Output -PC1.GPIOParameters=GPIO_Label -PC1.GPIO_Label=BSPD_SIGNAL -PC1.Locked=true -PC1.Mode=IN7-Single-Ended -PC1.Signal=ADC1_IN7 -PC10.Mode=Full_Duplex_Master -PC10.Signal=SPI3_SCK -PC11.Mode=Full_Duplex_Master -PC11.Signal=SPI3_MISO -PC12.Mode=Full_Duplex_Master -PC12.Signal=SPI3_MOSI -PC2.GPIOParameters=GPIO_Label -PC2.GPIO_Label=APPS1_SIGNAL -PC2.Locked=true -PC2.Mode=IN8-Single-Ended -PC2.Signal=ADC1_IN8 -PC3.GPIOParameters=GPIO_Label -PC3.GPIO_Label=APPS2_SIGNAL -PC3.Locked=true -PC3.Mode=IN9-Single-Ended -PC3.Signal=ADC1_IN9 -PC4.Mode=I2C -PC4.Signal=I2C2_SCL -PC5.Mode=Asynchronous -PC5.Signal=USART1_RX -PF0-OSC_IN.Locked=true -PF0-OSC_IN.Mode=HSE-External-Oscillator -PF0-OSC_IN.Signal=RCC_OSC_IN -PF1-OSC_OUT.Locked=true -PF1-OSC_OUT.Mode=HSE-External-Oscillator -PF1-OSC_OUT.Signal=RCC_OSC_OUT -PinOutPanel.RotationAngle=180 -ProjectManager.AskForMigrate=true -ProjectManager.BackupPrevious=false -ProjectManager.CompilerLinker=GCC -ProjectManager.CompilerOptimize=6 -ProjectManager.ComputerToolchain=false -ProjectManager.CoupleFile=true -ProjectManager.CustomerFirmwarePackage= -ProjectManager.DefaultFWLocation=true -ProjectManager.DeletePrevious=true -ProjectManager.DeviceId=STM32G474RETx -ProjectManager.FirmwarePackage=STM32Cube FW_G4 V1.6.1 -ProjectManager.FreePins=true -ProjectManager.HalAssertFull=false -ProjectManager.HeapSize=0x200 -ProjectManager.KeepUserCode=true -ProjectManager.LastFirmware=true -ProjectManager.LibraryCopy=0 -ProjectManager.MainLocation=Core/Src -ProjectManager.NoMain=false -ProjectManager.PreviousToolchain= -ProjectManager.ProjectBuild=false -ProjectManager.ProjectFileName=G4PERTESTING.ioc -ProjectManager.ProjectName=G4PERTESTING -ProjectManager.ProjectStructure= -ProjectManager.RegisterCallBack= -ProjectManager.StackSize=0x400 -ProjectManager.TargetToolchain=CMake -ProjectManager.ToolChainLocation= -ProjectManager.UAScriptAfterPath= -ProjectManager.UAScriptBeforePath= -ProjectManager.UnderRoot=false -ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-LL-false,2-MX_GPIO_Init-GPIO-false-LL-true,3-MX_DMA_Init-DMA-false-LL-true,4-MX_FDCAN2_Init-FDCAN2-false-HAL-true,5-MX_ADC1_Init-ADC1-false-LL-true,6-MX_LPUART1_UART_Init-LPUART1-false-LL-true,7-MX_I2C2_Init-I2C2-false-LL-true,8-MX_USART1_UART_Init-USART1-false-LL-true,9-MX_SPI3_Init-SPI3-false-LL-true,10-MX_TIM2_Init-TIM2-false-LL-true -RCC.ADC12Freq_Value=160000000 -RCC.ADC345Freq_Value=160000000 -RCC.AHBFreq_Value=160000000 -RCC.APB1Freq_Value=160000000 -RCC.APB1TimFreq_Value=160000000 -RCC.APB2Freq_Value=160000000 -RCC.APB2TimFreq_Value=160000000 -RCC.CRSFreq_Value=48000000 -RCC.CortexFreq_Value=160000000 -RCC.EXTERNAL_CLOCK_VALUE=12288000 -RCC.EnbaleCSS=true -RCC.FCLKCortexFreq_Value=160000000 -RCC.FDCANFreq_Value=160000000 -RCC.FamilyName=M -RCC.HCLKFreq_Value=160000000 -RCC.HRTIM1Freq_Value=160000000 -RCC.HSE_VALUE=16000000 -RCC.HSI48_VALUE=48000000 -RCC.HSI_VALUE=16000000 -RCC.I2C1Freq_Value=160000000 -RCC.I2C2Freq_Value=160000000 -RCC.I2C3Freq_Value=160000000 -RCC.I2C4Freq_Value=160000000 -RCC.I2SFreq_Value=160000000 -RCC.IPParameters=ADC12Freq_Value,ADC345Freq_Value,AHBFreq_Value,APB1Freq_Value,APB1TimFreq_Value,APB2Freq_Value,APB2TimFreq_Value,CRSFreq_Value,CortexFreq_Value,EXTERNAL_CLOCK_VALUE,EnbaleCSS,FCLKCortexFreq_Value,FDCANFreq_Value,FamilyName,HCLKFreq_Value,HRTIM1Freq_Value,HSE_VALUE,HSI48_VALUE,HSI_VALUE,I2C1Freq_Value,I2C2Freq_Value,I2C3Freq_Value,I2C4Freq_Value,I2SFreq_Value,LPTIM1Freq_Value,LPUART1Freq_Value,LSCOPinFreq_Value,LSE_VALUE,LSI_VALUE,MCO1PinFreq_Value,PLLN,PLLPoutputFreq_Value,PLLQoutputFreq_Value,PLLRCLKFreq_Value,PLLSourceVirtual,PWRFreq_Value,QSPIFreq_Value,RNGFreq_Value,SAI1Freq_Value,SYSCLKFreq_VALUE,SYSCLKSource,UART4Freq_Value,UART5Freq_Value,USART1Freq_Value,USART2Freq_Value,USART3Freq_Value,USBFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value -RCC.LPTIM1Freq_Value=160000000 -RCC.LPUART1Freq_Value=160000000 -RCC.LSCOPinFreq_Value=32000 -RCC.LSE_VALUE=32768 -RCC.LSI_VALUE=32000 -RCC.MCO1PinFreq_Value=16000000 -RCC.PLLN=20 -RCC.PLLPoutputFreq_Value=160000000 -RCC.PLLQoutputFreq_Value=160000000 -RCC.PLLRCLKFreq_Value=160000000 -RCC.PLLSourceVirtual=RCC_PLLSOURCE_HSE -RCC.PWRFreq_Value=160000000 -RCC.QSPIFreq_Value=160000000 -RCC.RNGFreq_Value=160000000 -RCC.SAI1Freq_Value=160000000 -RCC.SYSCLKFreq_VALUE=160000000 -RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK -RCC.UART4Freq_Value=160000000 -RCC.UART5Freq_Value=160000000 -RCC.USART1Freq_Value=160000000 -RCC.USART2Freq_Value=160000000 -RCC.USART3Freq_Value=160000000 -RCC.USBFreq_Value=160000000 -RCC.VCOInputFreq_Value=16000000 -RCC.VCOOutputFreq_Value=320000000 -SH.S_TIM2_CH1.0=TIM2_CH1,Forced Output1 CH1 -SH.S_TIM2_CH1.ConfNb=1 -SPI3.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_32 -SPI3.CalculateBaudRate=5.0 MBits/s -SPI3.Direction=SPI_DIRECTION_2LINES -SPI3.IPParameters=VirtualType,Mode,Direction,BaudRatePrescaler,CalculateBaudRate -SPI3.Mode=SPI_MODE_MASTER -SPI3.VirtualType=VM_MASTER -TIM2.Channel-Forced\ Output1\ CH1=TIM_CHANNEL_1 -TIM2.IPParameters=Channel-Forced Output1 CH1 -USART1.IPParameters=VirtualMode-Asynchronous -USART1.VirtualMode-Asynchronous=VM_ASYNC -VP_SYS_VS_DBSignals.Mode=DisableDeadBatterySignals -VP_SYS_VS_DBSignals.Signal=SYS_VS_DBSignals -VP_SYS_VS_Systick.Mode=SysTick -VP_SYS_VS_Systick.Signal=SYS_VS_Systick -VP_TIM2_VS_ClockSourceINT.Mode=Internal -VP_TIM2_VS_ClockSourceINT.Signal=TIM2_VS_ClockSourceINT -board=custom diff --git a/G474xE_CAN_TESTING/PROFILER_TEST/CMakeLists.txt b/G474xE_CAN_TESTING/PROFILER_TEST/CMakeLists.txt deleted file mode 100644 index 3be5c86bd..000000000 --- a/G474xE_CAN_TESTING/PROFILER_TEST/CMakeLists.txt +++ /dev/null @@ -1,53 +0,0 @@ -cmake_minimum_required(VERSION 3.25) - -# Setup compiler settings -set(CMAKE_C_STANDARD 11) -set(CMAKE_C_STANDARD_REQUIRED ON) -set(CMAKE_C_EXTENSIONS ON) - -# Define the build type -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Debug") -endif() - -# Enable compile command to ease indexing with e.g. clangd -set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE) - -# Enable CMake support for ASM and C languages -enable_language( - C - ASM -) - -# Core project settings -project(${CMAKE_PROJECT_NAME}) - -# what, does in fact not get the filename of somthing but rather the name of the project from the path -get_filename_component(PROJECT_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME) - -add_library(${PROJECT_NAME}_USER_CODE INTERFACE) - -target_sources( - ${PROJECT_NAME}_USER_CODE - INTERFACE - ../Core/Src/adc.c - ../Core/Src/crc.c - ../Core/Src/dma.c - ../Core/Src/gpio.c - ../Core/Src/i2c.c - main.c - ../Core/Src/spi.c - ../Core/Src/stm32g4xx_hal_msp.c - ../Core/Src/stm32g4xx_it.c - ../Core/Src/tim.c - ../Core/Src/usart.c -) - -target_link_libraries(${PROJECT_NAME}_USER_CODE INTERFACE PERIPHERAL_CAN_LIB) - -target_include_directories( - ${PROJECT_NAME}_USER_CODE - INTERFACE - ../Core/Inc - . -) diff --git a/G474xE_CAN_TESTING/PROFILER_TEST/can_cfg.h b/G474xE_CAN_TESTING/PROFILER_TEST/can_cfg.h deleted file mode 100644 index a9e30c564..000000000 --- a/G474xE_CAN_TESTING/PROFILER_TEST/can_cfg.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef CAN_CFG_H -#define CAN_CFG_H - -// #define USEDMA - -#define USECAN1 -#define TX_BUFFER_1_SIZE 10 - -// not using -// #define CAN1_RX_GPIO_PORT -// #define CAN1_RX_GPIO_PIN -// #define CAN1_TX_GPIO_PORT -// #define CAN1_TX_GPIO_PIN - -// #define CAN - -#define USECAN2 -#define TX_BUFFER_2_SIZE 10 - -#endif diff --git a/G474xE_CAN_TESTING/PROFILER_TEST/main.c b/G474xE_CAN_TESTING/PROFILER_TEST/main.c deleted file mode 100644 index c916470eb..000000000 --- a/G474xE_CAN_TESTING/PROFILER_TEST/main.c +++ /dev/null @@ -1,275 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file : main.c - * @brief : Main program body - ****************************************************************************** - * @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 "main.h" - -#include "adc.h" -#include "can.h" // Assume this works -#include "can_tests.h" -#include "dma.h" -#include "fdcan.h" -#include "gpio.h" -#include "i2c.h" -#include "spi.h" -#include "tim.h" -#include "usart.h" - -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ -#include "Logomatic.h" -// #include "profile.h" -/* USER CODE END Includes */ - -/* Private typedef -----------------------------------------------------------*/ -/* USER CODE BEGIN PTD */ - -/* USER CODE END PTD */ - -/* Private define ------------------------------------------------------------*/ -/* USER CODE BEGIN PD */ - -/* USER CODE END PD */ - -/* Private macro -------------------------------------------------------------*/ -/* USER CODE BEGIN PM */ - -/* USER CODE END PM */ - -/* Private variables ---------------------------------------------------------*/ - -/* USER CODE BEGIN PV */ -/* USER CODE END PV */ - -/* Private function prototypes -----------------------------------------------*/ -void SystemClock_Config(void); -/* USER CODE BEGIN PFP */ - -/* USER CODE END PFP */ - -/* Private user code ---------------------------------------------------------*/ -/* USER CODE BEGIN 0 */ -/* Enable ITM for SWO output */ -static void ITM_Enable(void) -{ - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOB); - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - GPIO_InitStruct.Pin = LL_GPIO_PIN_3; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_0; - LL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - DBGMCU->CR |= DBGMCU_CR_TRACE_IOEN; - - /* Enable TRC (Trace) */ - CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; - - /* Configure TPI for SWO output (set prescaler for 2MHz SWO clock) */ - TPI->SPPR = 2U; /* 2 = Manchester/async UART mode */ - TPI->ACPR = 84U; /* Prescaler: (170 MHz / (84+1) / 2) ≈ 1MHz SWO */ - - ITM->TER |= (1UL << 0); - ITM->TCR |= (ITM_TCR_ITMENA_Msk | ITM_TCR_SWOENA_Msk); -} -// static int toggleze = 0; -/* USER CODE END 0 */ - -/** - * @brief The application entry point. - * @retval int - */ -int main(void) -{ - /* USER CODE BEGIN 1 */ - - /* USER CODE END 1 */ - - /* MCU - * Configuration--------------------------------------------------------*/ - - /* Reset of all peripherals, Initializes the Flash interface and the - * Systick. */ - HAL_Init(); - /* USER CODE BEGIN Init */ - ITM_Enable(); - /* USER CODE END Init */ - - /* Configure the system clock */ - SystemClock_Config(); - - /* USER CODE BEGIN SysInit */ - - /* USER CODE END SysInit */ - - /* Initialize all configured peripherals */ - MX_GPIO_Init(); - MX_DMA_Init(); - // MX_FDCAN2_Init(); - MX_ADC1_Init(); - MX_LPUART1_UART_Init(); - MX_I2C2_Init(); - MX_USART1_UART_Init(); - MX_SPI3_Init(); - MX_TIM2_Init(); - - /* USER CODE BEGIN 2 */ - - LOGOMATIC("Booted!\n"); - - // LOGOMATIC("running can_stress_test:\n"); - profiler_test(); - - /* Infinite loop */ - /* USER CODE BEGIN WHILE */ - while (1) { - /* USER CODE END WHILE */ - LOGOMATIC("Main Loop\n"); - LL_mDelay(1000); - - // Receive on GPIOs - // HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, toggleze ? GPIO_PIN_SET - // : GPIO_PIN_RESET); HAL_Delay(1000); msg.data[0] = toggleze ? - // 0x00 : 0x80; can_send(data_can, &msg); - - // RCC->CFGR |= RCC_CFGR_SW; - /* USER CODE BEGIN 3 */ - } -} - -/** - * @brief System Clock Configuration - * @retval None - */ - -// void SystemClock_Config(void) -// { -// LL_FLASH_SetLatency(LL_FLASH_LATENCY_4); -// while (LL_FLASH_GetLatency() != LL_FLASH_LATENCY_4) { -// } -// LL_PWR_EnableRange1BoostMode(); -// LL_RCC_HSE_Enable(); - -// /* Wait till HSE is ready */ -// while (LL_RCC_HSE_IsReady() != 1) { -// } - -// LL_RCC_HSE_EnableCSS(); -// LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSE, LL_RCC_PLLM_DIV_1, 20, -// LL_RCC_PLLR_DIV_2); -// //LL_RCC_PLL_ConfigDomain_48M(LL_RCC_PLLSOURCE_HSE, ); -// LL_RCC_PLL_EnableDomain_SYS(); -// LL_RCC_PLL_Enable(); -// /* Wait till PLL is ready */ -// while (LL_RCC_PLL_IsReady() != 1) { -// } - -// LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL); -// LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_2); -// /* Wait till System clock is ready */ -// while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL) { -// } - -// /* Insure 1us transition state at intermediate medium speed clock*/ -// for (__IO uint32_t i = (170 >> 1); i != 0; i--) -// ; - -// /* Set AHB prescaler*/ -// LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1); -// LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1); -// LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_1); -// LL_SetSystemCoreClock(160000000); - -// /* Update the time base */ -// if (HAL_InitTick(TICK_INT_PRIORITY) != HAL_OK) { -// Error_Handler(); -// } -// }*/ -void SystemClock_Config(void) -{ - LL_FLASH_SetLatency(LL_FLASH_LATENCY_4); - while (LL_FLASH_GetLatency() != LL_FLASH_LATENCY_4) {} - LL_PWR_EnableRange1BoostMode(); - LL_RCC_HSI_Enable(); - /* Wait till HSI is ready */ - while (LL_RCC_HSI_IsReady() != 1) {} - - LL_RCC_HSI_SetCalibTrimming(64); - LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSI, LL_RCC_PLLM_DIV_4, 85, LL_RCC_PLLR_DIV_2); - LL_RCC_PLL_EnableDomain_SYS(); - LL_RCC_PLL_Enable(); - /* Wait till PLL is ready */ - while (LL_RCC_PLL_IsReady() != 1) {} - - LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL); - // LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1); - /* Wait till System clock is ready */ - while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL) {} - - /* Insure 1us transition state at intermediate medium speed clock*/ - for (__IO uint32_t i = (170 >> 1); i != 0; i--) - ; - - /* Set AHB prescaler*/ - LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1); - LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1); - LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_1); - LL_SetSystemCoreClock(170000000); - - /* Update the time base */ - if (HAL_InitTick(TICK_INT_PRIORITY) != HAL_OK) { - Error_Handler(); - } -} - -/* USER CODE BEGIN 4 */ - -/* USER CODE END 4 */ - -/** - * @brief This function is executed in case of error occurrence. - * @retval None - */ -void Error_Handler(void) -{ - /* USER CODE BEGIN Error_Handler_Debug */ - /* User can add his own implementation to report the HAL error return - * state */ - __disable_irq(); - while (1) {} - /* USER CODE END Error_Handler_Debug */ -} -#ifdef USE_FULL_ASSERT -/** - * @brief Reports the name of the source file and the source line number - * where the assert_param error has occurred. - * @param file: pointer to the source file name - * @param line: assert_param error line source number - * @retval None - */ -void assert_failed(uint8_t *file, uint32_t line) -{ - /* USER CODE BEGIN 6 */ - /* User can add his own implementation to report the file name and line - number, ex: printf("Wrong parameters value: file %s on line %d\r\n", - file, line) */ - /* USER CODE END 6 */ -} -#endif /* USE_FULL_ASSERT */ diff --git a/G474xE_CAN_TESTING/README.md b/G474xE_CAN_TESTING/README.md deleted file mode 100644 index 558f1c125..000000000 --- a/G474xE_CAN_TESTING/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# STM32G474 CAN -Nucleo-G474RE-C04 - -Plug in the board following ST-LINK pinout -Compile and flash G4CANTESTING.elf diff --git a/G4ADCTESTING/CMakeLists.txt b/G4ADCTESTING/CMakeLists.txt deleted file mode 100644 index 103c4e3d9..000000000 --- a/G4ADCTESTING/CMakeLists.txt +++ /dev/null @@ -1,48 +0,0 @@ -cmake_minimum_required(VERSION 3.25) - -# Setup compiler settings -set(CMAKE_C_STANDARD 11) -set(CMAKE_C_STANDARD_REQUIRED ON) -set(CMAKE_C_EXTENSIONS ON) - -# Define the build type -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Debug") -endif() - -# Enable compile command to ease indexing with e.g. clangd -set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE) - -# Enable CMake support for ASM and C languages -enable_language( - C - ASM -) - -# Core project settings -project(${CMAKE_PROJECT_NAME}) - -# what, does in fact not get the filename of somthing but rather the name of the project from the path -get_filename_component(PROJECT_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME) - -add_library(${PROJECT_NAME}_USER_CODE INTERFACE) -target_sources( - ${PROJECT_NAME}_USER_CODE - INTERFACE - Core/Src/adc.c - Core/Src/crc.c - Core/Src/dma.c - Core/Src/fdcan.c - Core/Src/gpio.c - Core/Src/i2c.c - Core/Src/main.c - Core/Src/spi.c - Core/Src/stm32g4xx_hal_msp.c - Core/Src/stm32g4xx_it.c - Core/Src/tim.c - Core/Src/usart.c -) - -target_link_libraries(${PROJECT_NAME}_USER_CODE INTERFACE GR_ADC) - -target_include_directories(${PROJECT_NAME}_USER_CODE INTERFACE Core/Inc) diff --git a/G4ADCTESTING/Core/Inc/adc.h b/G4ADCTESTING/Core/Inc/adc.h deleted file mode 100644 index 41154538b..000000000 --- a/G4ADCTESTING/Core/Inc/adc.h +++ /dev/null @@ -1,49 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file adc.h - * @brief This file contains all the function prototypes for - * the adc.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 __ADC_H__ -#define __ADC_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" - -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* USER CODE BEGIN Private defines */ - -/* USER CODE END Private defines */ - -void MX_ADC1_Init(void); - -/* USER CODE BEGIN Prototypes */ - -/* USER CODE END Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif /* __ADC_H__ */ diff --git a/G4ADCTESTING/Core/Inc/crc.h b/G4ADCTESTING/Core/Inc/crc.h deleted file mode 100644 index 133957e92..000000000 --- a/G4ADCTESTING/Core/Inc/crc.h +++ /dev/null @@ -1,51 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file crc.h - * @brief This file contains all the function prototypes for - * the crc.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 __CRC_H__ -#define __CRC_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" - -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -extern CRC_HandleTypeDef hcrc; - -/* USER CODE BEGIN Private defines */ - -/* USER CODE END Private defines */ - -void MX_CRC_Init(void); - -/* USER CODE BEGIN Prototypes */ - -/* USER CODE END Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif /* __CRC_H__ */ diff --git a/G4ADCTESTING/Core/Inc/dma.h b/G4ADCTESTING/Core/Inc/dma.h deleted file mode 100644 index ae819cab4..000000000 --- a/G4ADCTESTING/Core/Inc/dma.h +++ /dev/null @@ -1,51 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file dma.h - * @brief This file contains all the function prototypes for - * the dma.c file - ****************************************************************************** - * @attention - * - * Copyright (c) 2025 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__ */ diff --git a/G4ADCTESTING/Core/Inc/fdcan.h b/G4ADCTESTING/Core/Inc/fdcan.h deleted file mode 100644 index 56c4a8adb..000000000 --- a/G4ADCTESTING/Core/Inc/fdcan.h +++ /dev/null @@ -1,51 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file fdcan.h - * @brief This file contains all the function prototypes for - * the fdcan.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 __FDCAN_H__ -#define __FDCAN_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" - -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -extern FDCAN_HandleTypeDef hfdcan2; - -/* USER CODE BEGIN Private defines */ - -/* USER CODE END Private defines */ - -void MX_FDCAN2_Init(void); - -/* USER CODE BEGIN Prototypes */ - -/* USER CODE END Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif /* __FDCAN_H__ */ diff --git a/G4ADCTESTING/Core/Inc/gpio.h b/G4ADCTESTING/Core/Inc/gpio.h deleted file mode 100644 index 843d4e9e7..000000000 --- a/G4ADCTESTING/Core/Inc/gpio.h +++ /dev/null @@ -1,48 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file gpio.h - * @brief This file contains all the function prototypes for - * the gpio.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 __GPIO_H__ -#define __GPIO_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" - -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* USER CODE BEGIN Private defines */ - -/* USER CODE END Private defines */ - -void MX_GPIO_Init(void); - -/* USER CODE BEGIN Prototypes */ - -/* USER CODE END Prototypes */ - -#ifdef __cplusplus -} -#endif -#endif /*__ GPIO_H__ */ diff --git a/G4ADCTESTING/Core/Inc/i2c.h b/G4ADCTESTING/Core/Inc/i2c.h deleted file mode 100644 index 0a0a50803..000000000 --- a/G4ADCTESTING/Core/Inc/i2c.h +++ /dev/null @@ -1,49 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file i2c.h - * @brief This file contains all the function prototypes for - * the i2c.c file - ****************************************************************************** - * @attention - * - * Copyright (c) 2025 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 __I2C_H__ -#define __I2C_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" - -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* USER CODE BEGIN Private defines */ - -/* USER CODE END Private defines */ - -void MX_I2C2_Init(void); - -/* USER CODE BEGIN Prototypes */ - -/* USER CODE END Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif /* __I2C_H__ */ diff --git a/G4ADCTESTING/Core/Inc/main.h b/G4ADCTESTING/Core/Inc/main.h deleted file mode 100644 index 23d7ffce4..000000000 --- a/G4ADCTESTING/Core/Inc/main.h +++ /dev/null @@ -1,115 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file : main.h - * @brief : Header for main.c file. - * This file contains the common defines of the application. - ****************************************************************************** - * @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 __MAIN_H -#define __MAIN_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32g4xx_hal.h" -#include "stm32g4xx_ll_adc.h" -#include "stm32g4xx_ll_bus.h" -#include "stm32g4xx_ll_cortex.h" -#include "stm32g4xx_ll_crs.h" -#include "stm32g4xx_ll_dma.h" -#include "stm32g4xx_ll_exti.h" -#include "stm32g4xx_ll_gpio.h" -#include "stm32g4xx_ll_i2c.h" -#include "stm32g4xx_ll_lpuart.h" -#include "stm32g4xx_ll_pwr.h" -#include "stm32g4xx_ll_rcc.h" -#include "stm32g4xx_ll_spi.h" -#include "stm32g4xx_ll_system.h" -#include "stm32g4xx_ll_tim.h" -#include "stm32g4xx_ll_usart.h" -#include "stm32g4xx_ll_utils.h" - -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* Exported types ------------------------------------------------------------*/ -/* USER CODE BEGIN ET */ - -/* USER CODE END ET */ - -/* Exported constants --------------------------------------------------------*/ -/* USER CODE BEGIN EC */ - -/* USER CODE END EC */ - -/* Exported macro ------------------------------------------------------------*/ -/* USER CODE BEGIN EM */ - -/* USER CODE END EM */ - -/* Exported functions prototypes ---------------------------------------------*/ -void Error_Handler(void); - -/* USER CODE BEGIN EFP */ - -/* USER CODE END EFP */ - -/* Private defines -----------------------------------------------------------*/ -#define BSPD_SIGNAL_Pin LL_GPIO_PIN_1 -#define BSPD_SIGNAL_GPIO_Port GPIOC -#define APPS1_SIGNAL_Pin LL_GPIO_PIN_2 -#define APPS1_SIGNAL_GPIO_Port GPIOC -#define APPS2_SIGNAL_Pin LL_GPIO_PIN_3 -#define APPS2_SIGNAL_GPIO_Port GPIOC -#define BLINKY_Pin LL_GPIO_PIN_5 -#define BLINKY_GPIO_Port GPIOA -#define IMD_SENSE_Pin LL_GPIO_PIN_6 -#define IMD_SENSE_GPIO_Port GPIOA -#define AMS_SENSE_Pin LL_GPIO_PIN_7 -#define AMS_SENSE_GPIO_Port GPIOA -#define BRAKE_F_SIGNAL_Pin LL_GPIO_PIN_0 -#define BRAKE_F_SIGNAL_GPIO_Port GPIOB -#define BRAKE_R_SIGNAL_Pin LL_GPIO_PIN_1 -#define BRAKE_R_SIGNAL_GPIO_Port GPIOB -#define LED_TEST_Pin LL_GPIO_PIN_11 -#define LED_TEST_GPIO_Port GPIOB -#define AUX_SIGNAL_Pin LL_GPIO_PIN_14 -#define AUX_SIGNAL_GPIO_Port GPIOB -#define STEERING_ANGLE_Pin LL_GPIO_PIN_15 -#define STEERING_ANGLE_GPIO_Port GPIOB -#define BRAKE_LIGHT_Pin LL_GPIO_PIN_4 -#define BRAKE_LIGHT_GPIO_Port GPIOB -#define TSSI_G_CONTROL_Pin LL_GPIO_PIN_5 -#define TSSI_G_CONTROL_GPIO_Port GPIOB -#define AUX_CONTROL_Pin LL_GPIO_PIN_8 -#define AUX_CONTROL_GPIO_Port GPIOB -#define SOFTWARE_OK_CONTROL_Pin LL_GPIO_PIN_9 -#define SOFTWARE_OK_CONTROL_GPIO_Port GPIOB - -/* USER CODE BEGIN Private defines */ - -/* USER CODE END Private defines */ - -#ifdef __cplusplus -} -#endif - -#endif /* __MAIN_H */ diff --git a/G4ADCTESTING/Core/Inc/spi.h b/G4ADCTESTING/Core/Inc/spi.h deleted file mode 100644 index 74bed003b..000000000 --- a/G4ADCTESTING/Core/Inc/spi.h +++ /dev/null @@ -1,49 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file spi.h - * @brief This file contains all the function prototypes for - * the spi.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 __SPI_H__ -#define __SPI_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" - -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* USER CODE BEGIN Private defines */ - -/* USER CODE END Private defines */ - -void MX_SPI3_Init(void); - -/* USER CODE BEGIN Prototypes */ - -/* USER CODE END Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif /* __SPI_H__ */ diff --git a/G4ADCTESTING/Core/Inc/stm32g4xx_hal_conf.h b/G4ADCTESTING/Core/Inc/stm32g4xx_hal_conf.h deleted file mode 100644 index 3e1fcb018..000000000 --- a/G4ADCTESTING/Core/Inc/stm32g4xx_hal_conf.h +++ /dev/null @@ -1,390 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file stm32g4xx_hal_conf.h - * @author MCD Application Team - * @brief HAL configuration file - ****************************************************************************** - * @attention - * - * Copyright (c) 2019 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 STM32G4xx_HAL_CONF_H -#define STM32G4xx_HAL_CONF_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Exported types ------------------------------------------------------------*/ -/* Exported constants --------------------------------------------------------*/ - -/* ########################## Module Selection ############################## */ -/** - * @brief This is the list of modules to be used in the HAL driver - */ - -#define HAL_MODULE_ENABLED - -/*#define HAL_ADC_MODULE_ENABLED */ -/*#define HAL_COMP_MODULE_ENABLED */ -/*#define HAL_CORDIC_MODULE_ENABLED */ -#define HAL_CRC_MODULE_ENABLED -/*#define HAL_CRYP_MODULE_ENABLED */ -/*#define HAL_DAC_MODULE_ENABLED */ -#define HAL_FDCAN_MODULE_ENABLED -/*#define HAL_FMAC_MODULE_ENABLED */ -/*#define HAL_HRTIM_MODULE_ENABLED */ -/*#define HAL_IRDA_MODULE_ENABLED */ -/*#define HAL_IWDG_MODULE_ENABLED */ -/*#define HAL_I2C_MODULE_ENABLED */ -/*#define HAL_I2S_MODULE_ENABLED */ -/*#define HAL_LPTIM_MODULE_ENABLED */ -/*#define HAL_NAND_MODULE_ENABLED */ -/*#define HAL_NOR_MODULE_ENABLED */ -/*#define HAL_OPAMP_MODULE_ENABLED */ -/*#define HAL_PCD_MODULE_ENABLED */ -/*#define HAL_QSPI_MODULE_ENABLED */ -/*#define HAL_RNG_MODULE_ENABLED */ -/*#define HAL_RTC_MODULE_ENABLED */ -/*#define HAL_SAI_MODULE_ENABLED */ -/*#define HAL_SMARTCARD_MODULE_ENABLED */ -/*#define HAL_SMBUS_MODULE_ENABLED */ -/*#define HAL_SPI_MODULE_ENABLED */ -/*#define HAL_SRAM_MODULE_ENABLED */ -/*#define HAL_TIM_MODULE_ENABLED */ -/*#define HAL_UART_MODULE_ENABLED */ -/*#define HAL_USART_MODULE_ENABLED */ -/*#define HAL_WWDG_MODULE_ENABLED */ -#define HAL_GPIO_MODULE_ENABLED -#define HAL_EXTI_MODULE_ENABLED -#define HAL_DMA_MODULE_ENABLED -#define HAL_RCC_MODULE_ENABLED -#define HAL_FLASH_MODULE_ENABLED -#define HAL_PWR_MODULE_ENABLED -#define HAL_CORTEX_MODULE_ENABLED - -/* ########################## Register Callbacks selection - * ############################## */ -/** - * @brief This is the list of modules where register callback can be used - */ -#define USE_HAL_ADC_REGISTER_CALLBACKS 0U -#define USE_HAL_COMP_REGISTER_CALLBACKS 0U -#define USE_HAL_CORDIC_REGISTER_CALLBACKS 0U -#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U -#define USE_HAL_DAC_REGISTER_CALLBACKS 0U -#define USE_HAL_EXTI_REGISTER_CALLBACKS 0U -#define USE_HAL_FDCAN_REGISTER_CALLBACKS 0U -#define USE_HAL_FMAC_REGISTER_CALLBACKS 0U -#define USE_HAL_HRTIM_REGISTER_CALLBACKS 0U -#define USE_HAL_I2C_REGISTER_CALLBACKS 0U -#define USE_HAL_I2S_REGISTER_CALLBACKS 0U -#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U -#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U -#define USE_HAL_NAND_REGISTER_CALLBACKS 0U -#define USE_HAL_NOR_REGISTER_CALLBACKS 0U -#define USE_HAL_OPAMP_REGISTER_CALLBACKS 0U -#define USE_HAL_PCD_REGISTER_CALLBACKS 0U -#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U -#define USE_HAL_RNG_REGISTER_CALLBACKS 0U -#define USE_HAL_RTC_REGISTER_CALLBACKS 0U -#define USE_HAL_SAI_REGISTER_CALLBACKS 0U -#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U -#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U -#define USE_HAL_SPI_REGISTER_CALLBACKS 0U -#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U -#define USE_HAL_TIM_REGISTER_CALLBACKS 0U -#define USE_HAL_UART_REGISTER_CALLBACKS 0U -#define USE_HAL_USART_REGISTER_CALLBACKS 0U -#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U - -/* ########################## Oscillator Values adaptation - * ####################*/ -/** - * @brief Adjust the value of External High Speed oscillator (HSE) used in your - * application. This value is used by the RCC HAL module to compute the system - * frequency (when HSE is used as system clock source, directly or through the - * PLL). - */ -#if !defined(HSE_VALUE) -#define HSE_VALUE (16000000UL) /*!< Value of the External oscillator in Hz */ -#endif /* HSE_VALUE */ - -#if !defined(HSE_STARTUP_TIMEOUT) -#define HSE_STARTUP_TIMEOUT (100UL) /*!< Time out for HSE start up, in ms */ -#endif /* HSE_STARTUP_TIMEOUT */ - -/** - * @brief Internal High Speed oscillator (HSI) value. - * This value is used by the RCC HAL module to compute the system - * frequency (when HSI is used as system clock source, directly or through the - * PLL). - */ -#if !defined(HSI_VALUE) -#define HSI_VALUE (16000000UL) /*!< Value of the Internal oscillator in Hz*/ -#endif /* HSI_VALUE */ - -/** - * @brief Internal High Speed oscillator (HSI48) value for USB FS and RNG. - * This internal oscillator is mainly dedicated to provide a high - * precision clock to the USB peripheral by means of a special Clock Recovery - * System (CRS) circuitry. When the CRS is not used, the HSI48 RC oscillator - * runs on it default frequency which is subject to manufacturing process - * variations. - */ -#if !defined(HSI48_VALUE) -#define HSI48_VALUE \ - (48000000UL) /*!< Value of the Internal High Speed oscillator for USB \ - FS/RNG in Hz. The real value my vary depending on \ - manufacturing process variations.*/ -#endif /* HSI48_VALUE */ - -/** - * @brief Internal Low Speed oscillator (LSI) value. - */ -#if !defined(LSI_VALUE) -/*!< Value of the Internal Low Speed oscillator in Hz -The real value may vary depending on the variations in voltage and -temperature.*/ -#define LSI_VALUE (32000UL) /*!< LSI Typical Value in Hz*/ -#endif /* LSI_VALUE */ -/** - * @brief External Low Speed oscillator (LSE) value. - * This value is used by the UART, RTC HAL module to compute the system - * frequency - */ -#if !defined(LSE_VALUE) -#define LSE_VALUE (32768UL) /*!< Value of the External Low Speed oscillator in Hz */ -#endif /* LSE_VALUE */ - -#if !defined(LSE_STARTUP_TIMEOUT) -#define LSE_STARTUP_TIMEOUT (5000UL) /*!< Time out for LSE start up, in ms */ -#endif /* LSE_STARTUP_TIMEOUT */ - -/** - * @brief External clock source for I2S and SAI peripherals - * This value is used by the I2S and SAI HAL modules to compute the I2S - * and SAI clock source frequency, this source is inserted directly through - * I2S_CKIN pad. - */ -#if !defined(EXTERNAL_CLOCK_VALUE) -#define EXTERNAL_CLOCK_VALUE (12288000UL) /*!< Value of the External oscillator in Hz*/ -#endif /* EXTERNAL_CLOCK_VALUE */ - -/* Tip: To avoid modifying this file each time you need to use different HSE, - === you can define the HSE value in your toolchain compiler preprocessor. */ - -/* ########################### System Configuration ######################### */ -/** - * @brief This is the HAL system configuration section - */ - -#define VDD_VALUE (3300UL) /*!< Value of VDD in mv */ -#define TICK_INT_PRIORITY (15UL) /*!< tick interrupt priority (lowest by default) */ -#define USE_RTOS 0U -#define PREFETCH_ENABLE 0U -#define INSTRUCTION_CACHE_ENABLE 1U -#define DATA_CACHE_ENABLE 1U - -/* ########################## Assert Selection ############################## */ -/** - * @brief Uncomment the line below to expanse the "assert_param" macro in the - * HAL drivers code - */ -/* #define USE_FULL_ASSERT 1U */ - -/* ################## SPI peripheral configuration ########################## */ - -/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver - * Activated: CRC code is present inside driver - * Deactivated: CRC code cleaned from driver - */ - -#define USE_SPI_CRC 0U - -/* Includes ------------------------------------------------------------------*/ -/** - * @brief Include module's header file - */ - -#ifdef HAL_RCC_MODULE_ENABLED -#include "stm32g4xx_hal_rcc.h" -#endif /* HAL_RCC_MODULE_ENABLED */ - -#ifdef HAL_GPIO_MODULE_ENABLED -#include "stm32g4xx_hal_gpio.h" -#endif /* HAL_GPIO_MODULE_ENABLED */ - -#ifdef HAL_DMA_MODULE_ENABLED -#include "stm32g4xx_hal_dma.h" -#endif /* HAL_DMA_MODULE_ENABLED */ - -#ifdef HAL_CORTEX_MODULE_ENABLED -#include "stm32g4xx_hal_cortex.h" -#endif /* HAL_CORTEX_MODULE_ENABLED */ - -#ifdef HAL_ADC_MODULE_ENABLED -#include "stm32g4xx_hal_adc.h" -#endif /* HAL_ADC_MODULE_ENABLED */ - -#ifdef HAL_COMP_MODULE_ENABLED -#include "stm32g4xx_hal_comp.h" -#endif /* HAL_COMP_MODULE_ENABLED */ - -#ifdef HAL_CORDIC_MODULE_ENABLED -#include "stm32g4xx_hal_cordic.h" -#endif /* HAL_CORDIC_MODULE_ENABLED */ - -#ifdef HAL_CRC_MODULE_ENABLED -#include "stm32g4xx_hal_crc.h" -#endif /* HAL_CRC_MODULE_ENABLED */ - -#ifdef HAL_CRYP_MODULE_ENABLED -#include "stm32g4xx_hal_cryp.h" -#endif /* HAL_CRYP_MODULE_ENABLED */ - -#ifdef HAL_DAC_MODULE_ENABLED -#include "stm32g4xx_hal_dac.h" -#endif /* HAL_DAC_MODULE_ENABLED */ - -#ifdef HAL_EXTI_MODULE_ENABLED -#include "stm32g4xx_hal_exti.h" -#endif /* HAL_EXTI_MODULE_ENABLED */ - -#ifdef HAL_FDCAN_MODULE_ENABLED -#include "stm32g4xx_hal_fdcan.h" -#endif /* HAL_FDCAN_MODULE_ENABLED */ - -#ifdef HAL_FLASH_MODULE_ENABLED -#include "stm32g4xx_hal_flash.h" -#endif /* HAL_FLASH_MODULE_ENABLED */ - -#ifdef HAL_FMAC_MODULE_ENABLED -#include "stm32g4xx_hal_fmac.h" -#endif /* HAL_FMAC_MODULE_ENABLED */ - -#ifdef HAL_HRTIM_MODULE_ENABLED -#include "stm32g4xx_hal_hrtim.h" -#endif /* HAL_HRTIM_MODULE_ENABLED */ - -#ifdef HAL_IRDA_MODULE_ENABLED -#include "stm32g4xx_hal_irda.h" -#endif /* HAL_IRDA_MODULE_ENABLED */ - -#ifdef HAL_IWDG_MODULE_ENABLED -#include "stm32g4xx_hal_iwdg.h" -#endif /* HAL_IWDG_MODULE_ENABLED */ - -#ifdef HAL_I2C_MODULE_ENABLED -#include "stm32g4xx_hal_i2c.h" -#endif /* HAL_I2C_MODULE_ENABLED */ - -#ifdef HAL_I2S_MODULE_ENABLED -#include "stm32g4xx_hal_i2s.h" -#endif /* HAL_I2S_MODULE_ENABLED */ - -#ifdef HAL_LPTIM_MODULE_ENABLED -#include "stm32g4xx_hal_lptim.h" -#endif /* HAL_LPTIM_MODULE_ENABLED */ - -#ifdef HAL_NAND_MODULE_ENABLED -#include "stm32g4xx_hal_nand.h" -#endif /* HAL_NAND_MODULE_ENABLED */ - -#ifdef HAL_NOR_MODULE_ENABLED -#include "stm32g4xx_hal_nor.h" -#endif /* HAL_NOR_MODULE_ENABLED */ - -#ifdef HAL_OPAMP_MODULE_ENABLED -#include "stm32g4xx_hal_opamp.h" -#endif /* HAL_OPAMP_MODULE_ENABLED */ - -#ifdef HAL_PCD_MODULE_ENABLED -#include "stm32g4xx_hal_pcd.h" -#endif /* HAL_PCD_MODULE_ENABLED */ - -#ifdef HAL_PWR_MODULE_ENABLED -#include "stm32g4xx_hal_pwr.h" -#endif /* HAL_PWR_MODULE_ENABLED */ - -#ifdef HAL_QSPI_MODULE_ENABLED -#include "stm32g4xx_hal_qspi.h" -#endif /* HAL_QSPI_MODULE_ENABLED */ - -#ifdef HAL_RNG_MODULE_ENABLED -#include "stm32g4xx_hal_rng.h" -#endif /* HAL_RNG_MODULE_ENABLED */ - -#ifdef HAL_RTC_MODULE_ENABLED -#include "stm32g4xx_hal_rtc.h" -#endif /* HAL_RTC_MODULE_ENABLED */ - -#ifdef HAL_SAI_MODULE_ENABLED -#include "stm32g4xx_hal_sai.h" -#endif /* HAL_SAI_MODULE_ENABLED */ - -#ifdef HAL_SMARTCARD_MODULE_ENABLED -#include "stm32g4xx_hal_smartcard.h" -#endif /* HAL_SMARTCARD_MODULE_ENABLED */ - -#ifdef HAL_SMBUS_MODULE_ENABLED -#include "stm32g4xx_hal_smbus.h" -#endif /* HAL_SMBUS_MODULE_ENABLED */ - -#ifdef HAL_SPI_MODULE_ENABLED -#include "stm32g4xx_hal_spi.h" -#endif /* HAL_SPI_MODULE_ENABLED */ - -#ifdef HAL_SRAM_MODULE_ENABLED -#include "stm32g4xx_hal_sram.h" -#endif /* HAL_SRAM_MODULE_ENABLED */ - -#ifdef HAL_TIM_MODULE_ENABLED -#include "stm32g4xx_hal_tim.h" -#endif /* HAL_TIM_MODULE_ENABLED */ - -#ifdef HAL_UART_MODULE_ENABLED -#include "stm32g4xx_hal_uart.h" -#endif /* HAL_UART_MODULE_ENABLED */ - -#ifdef HAL_USART_MODULE_ENABLED -#include "stm32g4xx_hal_usart.h" -#endif /* HAL_USART_MODULE_ENABLED */ - -#ifdef HAL_WWDG_MODULE_ENABLED -#include "stm32g4xx_hal_wwdg.h" -#endif /* HAL_WWDG_MODULE_ENABLED */ - -/* Exported macro ------------------------------------------------------------*/ -#ifdef USE_FULL_ASSERT -/** - * @brief The assert_param macro is used for function's parameters check. - * @param expr: If expr is false, it calls assert_failed function - * which reports the name of the source file and the source - * line number of the call that failed. - * If expr is true, it returns no value. - * @retval None - */ -#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) -/* Exported functions ------------------------------------------------------- */ -void assert_failed(uint8_t *file, uint32_t line); -#else -#define assert_param(expr) ((void)0U) -#endif /* USE_FULL_ASSERT */ - -#ifdef __cplusplus -} -#endif - -#endif /* STM32G4xx_HAL_CONF_H */ diff --git a/G4ADCTESTING/Core/Inc/tim.h b/G4ADCTESTING/Core/Inc/tim.h deleted file mode 100644 index c19e6cc71..000000000 --- a/G4ADCTESTING/Core/Inc/tim.h +++ /dev/null @@ -1,49 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file tim.h - * @brief This file contains all the function prototypes for - * the tim.c file - ****************************************************************************** - * @attention - * - * Copyright (c) 2025 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 __TIM_H__ -#define __TIM_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" - -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* USER CODE BEGIN Private defines */ - -/* USER CODE END Private defines */ - -void MX_TIM2_Init(void); - -/* USER CODE BEGIN Prototypes */ - -/* USER CODE END Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif /* __TIM_H__ */ diff --git a/G4ADCTESTING/Core/Inc/usart.h b/G4ADCTESTING/Core/Inc/usart.h deleted file mode 100644 index daefd73e6..000000000 --- a/G4ADCTESTING/Core/Inc/usart.h +++ /dev/null @@ -1,50 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file usart.h - * @brief This file contains all the function prototypes for - * the usart.c file - ****************************************************************************** - * @attention - * - * Copyright (c) 2025 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 __USART_H__ -#define __USART_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" - -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* USER CODE BEGIN Private defines */ - -/* USER CODE END Private defines */ - -void MX_LPUART1_UART_Init(void); -void MX_USART1_UART_Init(void); - -/* USER CODE BEGIN Prototypes */ - -/* USER CODE END Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif /* __USART_H__ */ diff --git a/G4ADCTESTING/Core/Src/adc.c b/G4ADCTESTING/Core/Src/adc.c deleted file mode 100644 index f3dbff8ed..000000000 --- a/G4ADCTESTING/Core/Src/adc.c +++ /dev/null @@ -1,186 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file adc.c - * @brief This file provides code for the configuration - * of the ADC 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 "adc.h" - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/* ADC1 init function */ -void MX_ADC1_Init(void) -{ - - /* USER CODE BEGIN ADC1_Init 0 */ - - /* USER CODE END ADC1_Init 0 */ - - LL_ADC_InitTypeDef ADC_InitStruct = {0}; - LL_ADC_REG_InitTypeDef ADC_REG_InitStruct = {0}; - LL_ADC_CommonInitTypeDef ADC_CommonInitStruct = {0}; - - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - - LL_RCC_SetADCClockSource(LL_RCC_ADC12_CLKSOURCE_SYSCLK); - - /* Peripheral clock enable */ - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_ADC12); - - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOB); - /**ADC1 GPIO Configuration - PC1 ------> ADC1_IN7 - PC2 ------> ADC1_IN8 - PC3 ------> ADC1_IN9 - PB0 ------> ADC1_IN15 - PB1 ------> ADC1_IN12 - PB14 ------> ADC1_IN5 - */ - GPIO_InitStruct.Pin = BSPD_SIGNAL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(BSPD_SIGNAL_GPIO_Port, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = APPS1_SIGNAL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(APPS1_SIGNAL_GPIO_Port, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = APPS2_SIGNAL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(APPS2_SIGNAL_GPIO_Port, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = BRAKE_F_SIGNAL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(BRAKE_F_SIGNAL_GPIO_Port, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = BRAKE_R_SIGNAL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(BRAKE_R_SIGNAL_GPIO_Port, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = AUX_SIGNAL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(AUX_SIGNAL_GPIO_Port, &GPIO_InitStruct); - - /* ADC1 DMA Init */ - - /* ADC1 Init */ - LL_DMA_SetPeriphRequest(DMA1, LL_DMA_CHANNEL_1, LL_DMAMUX_REQ_ADC1); - - LL_DMA_SetDataTransferDirection(DMA1, LL_DMA_CHANNEL_1, LL_DMA_DIRECTION_PERIPH_TO_MEMORY); - - LL_DMA_SetChannelPriorityLevel(DMA1, LL_DMA_CHANNEL_1, LL_DMA_PRIORITY_LOW); - - LL_DMA_SetMode(DMA1, LL_DMA_CHANNEL_1, LL_DMA_MODE_CIRCULAR); - - LL_DMA_SetPeriphIncMode(DMA1, LL_DMA_CHANNEL_1, LL_DMA_PERIPH_NOINCREMENT); - - LL_DMA_SetMemoryIncMode(DMA1, LL_DMA_CHANNEL_1, LL_DMA_MEMORY_INCREMENT); - - LL_DMA_SetPeriphSize(DMA1, LL_DMA_CHANNEL_1, LL_DMA_PDATAALIGN_HALFWORD); - - LL_DMA_SetMemorySize(DMA1, LL_DMA_CHANNEL_1, LL_DMA_MDATAALIGN_HALFWORD); - - /* USER CODE BEGIN ADC1_Init 1 */ - - /* USER CODE END ADC1_Init 1 */ - - /** Common config - */ - ADC_InitStruct.Resolution = LL_ADC_RESOLUTION_12B; - ADC_InitStruct.DataAlignment = LL_ADC_DATA_ALIGN_RIGHT; - ADC_InitStruct.LowPowerMode = LL_ADC_LP_MODE_NONE; - LL_ADC_Init(ADC1, &ADC_InitStruct); - ADC_REG_InitStruct.TriggerSource = LL_ADC_REG_TRIG_SOFTWARE; - ADC_REG_InitStruct.SequencerLength = LL_ADC_REG_SEQ_SCAN_ENABLE_6RANKS; - ADC_REG_InitStruct.SequencerDiscont = LL_ADC_REG_SEQ_DISCONT_DISABLE; - ADC_REG_InitStruct.ContinuousMode = LL_ADC_REG_CONV_CONTINUOUS; - ADC_REG_InitStruct.DMATransfer = LL_ADC_REG_DMA_TRANSFER_UNLIMITED; - ADC_REG_InitStruct.Overrun = LL_ADC_REG_OVR_DATA_PRESERVED; - LL_ADC_REG_Init(ADC1, &ADC_REG_InitStruct); - LL_ADC_SetGainCompensation(ADC1, 0); - LL_ADC_SetOverSamplingScope(ADC1, LL_ADC_OVS_DISABLE); - ADC_CommonInitStruct.CommonClock = LL_ADC_CLOCK_ASYNC_DIV256; - ADC_CommonInitStruct.Multimode = LL_ADC_MULTI_INDEPENDENT; - LL_ADC_CommonInit(__LL_ADC_COMMON_INSTANCE(ADC1), &ADC_CommonInitStruct); - - /* Disable ADC deep power down (enabled by default after reset state) */ - LL_ADC_DisableDeepPowerDown(ADC1); - /* Enable ADC internal voltage regulator */ - LL_ADC_EnableInternalRegulator(ADC1); - /* Delay for ADC internal voltage regulator stabilization. */ - /* Compute number of CPU cycles to wait for, from delay in us. */ - /* Note: Variable divided by 2 to compensate partially */ - /* CPU processing cycles (depends on compilation optimization). */ - /* Note: If system core clock frequency is below 200kHz, wait time */ - /* is only a few CPU processing cycles. */ - uint32_t wait_loop_index; - wait_loop_index = ((LL_ADC_DELAY_INTERNAL_REGUL_STAB_US * (SystemCoreClock / (100000 * 2))) / 10); - while (wait_loop_index != 0) { - wait_loop_index--; - } - - /** Configure Regular Channel - */ - LL_ADC_REG_SetSequencerRanks(ADC1, LL_ADC_REG_RANK_1, LL_ADC_CHANNEL_5); - LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_5, LL_ADC_SAMPLINGTIME_92CYCLES_5); - LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_5, LL_ADC_SINGLE_ENDED); - - /** Configure Regular Channel - */ - LL_ADC_REG_SetSequencerRanks(ADC1, LL_ADC_REG_RANK_2, LL_ADC_CHANNEL_7); - LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_7, LL_ADC_SAMPLINGTIME_92CYCLES_5); - LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_7, LL_ADC_SINGLE_ENDED); - - /** Configure Regular Channel - */ - LL_ADC_REG_SetSequencerRanks(ADC1, LL_ADC_REG_RANK_3, LL_ADC_CHANNEL_8); - LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_8, LL_ADC_SAMPLINGTIME_92CYCLES_5); - LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_8, LL_ADC_SINGLE_ENDED); - - /** Configure Regular Channel - */ - LL_ADC_REG_SetSequencerRanks(ADC1, LL_ADC_REG_RANK_4, LL_ADC_CHANNEL_9); - LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_9, LL_ADC_SAMPLINGTIME_92CYCLES_5); - LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_9, LL_ADC_SINGLE_ENDED); - - /** Configure Regular Channel - */ - LL_ADC_REG_SetSequencerRanks(ADC1, LL_ADC_REG_RANK_5, LL_ADC_CHANNEL_12); - LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_12, LL_ADC_SAMPLINGTIME_92CYCLES_5); - LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_12, LL_ADC_SINGLE_ENDED); - - /** Configure Regular Channel - */ - LL_ADC_REG_SetSequencerRanks(ADC1, LL_ADC_REG_RANK_6, LL_ADC_CHANNEL_15); - LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_15, LL_ADC_SAMPLINGTIME_92CYCLES_5); - LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_15, LL_ADC_SINGLE_ENDED); - /* USER CODE BEGIN ADC1_Init 2 */ - - /* USER CODE END ADC1_Init 2 */ -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ diff --git a/G4ADCTESTING/Core/Src/crc.c b/G4ADCTESTING/Core/Src/crc.c deleted file mode 100644 index 213510a5d..000000000 --- a/G4ADCTESTING/Core/Src/crc.c +++ /dev/null @@ -1,86 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file crc.c - * @brief This file provides code for the configuration - * of the CRC 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 "crc.h" - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -CRC_HandleTypeDef hcrc; - -/* CRC init function */ -void MX_CRC_Init(void) -{ - - /* USER CODE BEGIN CRC_Init 0 */ - - /* USER CODE END CRC_Init 0 */ - - /* USER CODE BEGIN CRC_Init 1 */ - - /* USER CODE END CRC_Init 1 */ - hcrc.Instance = CRC; - hcrc.Init.DefaultPolynomialUse = DEFAULT_POLYNOMIAL_ENABLE; - hcrc.Init.DefaultInitValueUse = DEFAULT_INIT_VALUE_ENABLE; - hcrc.Init.InputDataInversionMode = CRC_INPUTDATA_INVERSION_NONE; - hcrc.Init.OutputDataInversionMode = CRC_OUTPUTDATA_INVERSION_DISABLE; - hcrc.InputDataFormat = CRC_INPUTDATA_FORMAT_BYTES; - if (HAL_CRC_Init(&hcrc) != HAL_OK) { - Error_Handler(); - } - /* USER CODE BEGIN CRC_Init 2 */ - - /* USER CODE END CRC_Init 2 */ -} - -void HAL_CRC_MspInit(CRC_HandleTypeDef *crcHandle) -{ - - if (crcHandle->Instance == CRC) { - /* USER CODE BEGIN CRC_MspInit 0 */ - - /* USER CODE END CRC_MspInit 0 */ - /* CRC clock enable */ - __HAL_RCC_CRC_CLK_ENABLE(); - /* USER CODE BEGIN CRC_MspInit 1 */ - - /* USER CODE END CRC_MspInit 1 */ - } -} - -void HAL_CRC_MspDeInit(CRC_HandleTypeDef *crcHandle) -{ - - if (crcHandle->Instance == CRC) { - /* USER CODE BEGIN CRC_MspDeInit 0 */ - - /* USER CODE END CRC_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_CRC_CLK_DISABLE(); - /* USER CODE BEGIN CRC_MspDeInit 1 */ - - /* USER CODE END CRC_MspDeInit 1 */ - } -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ diff --git a/G4ADCTESTING/Core/Src/dma.c b/G4ADCTESTING/Core/Src/dma.c deleted file mode 100644 index 491e3889d..000000000 --- a/G4ADCTESTING/Core/Src/dma.c +++ /dev/null @@ -1,50 +0,0 @@ -/* 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) 2025 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) -{ - - /* Init with LL driver */ - /* DMA controller clock enable */ - LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_DMAMUX1); - LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_DMA1); -} - -/* USER CODE BEGIN 2 */ - -/* USER CODE END 2 */ diff --git a/G4ADCTESTING/Core/Src/fdcan.c b/G4ADCTESTING/Core/Src/fdcan.c deleted file mode 100644 index f39dbfa2b..000000000 --- a/G4ADCTESTING/Core/Src/fdcan.c +++ /dev/null @@ -1,133 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file fdcan.c - * @brief This file provides code for the configuration - * of the FDCAN 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 "fdcan.h" - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -FDCAN_HandleTypeDef hfdcan2; - -/* FDCAN2 init function */ -void MX_FDCAN2_Init(void) -{ - - /* USER CODE BEGIN FDCAN2_Init 0 */ - - /* USER CODE END FDCAN2_Init 0 */ - - /* USER CODE BEGIN FDCAN2_Init 1 */ - - /* USER CODE END FDCAN2_Init 1 */ - hfdcan2.Instance = FDCAN2; - hfdcan2.Init.ClockDivider = FDCAN_CLOCK_DIV1; - hfdcan2.Init.FrameFormat = FDCAN_FRAME_CLASSIC; - hfdcan2.Init.Mode = FDCAN_MODE_NORMAL; - hfdcan2.Init.AutoRetransmission = ENABLE; - hfdcan2.Init.TransmitPause = DISABLE; - hfdcan2.Init.ProtocolException = ENABLE; - hfdcan2.Init.NominalPrescaler = 1; - hfdcan2.Init.NominalSyncJumpWidth = 16; - hfdcan2.Init.NominalTimeSeg1 = 119; - hfdcan2.Init.NominalTimeSeg2 = 40; - hfdcan2.Init.DataPrescaler = 8; - hfdcan2.Init.DataSyncJumpWidth = 16; - hfdcan2.Init.DataTimeSeg1 = 14; - hfdcan2.Init.DataTimeSeg2 = 5; - hfdcan2.Init.StdFiltersNbr = 0; - hfdcan2.Init.ExtFiltersNbr = 2; - hfdcan2.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION; - if (HAL_FDCAN_Init(&hfdcan2) != HAL_OK) { - Error_Handler(); - } - /* USER CODE BEGIN FDCAN2_Init 2 */ - - /* USER CODE END FDCAN2_Init 2 */ -} - -void HAL_FDCAN_MspInit(FDCAN_HandleTypeDef *fdcanHandle) -{ - - GPIO_InitTypeDef GPIO_InitStruct = {0}; - if (fdcanHandle->Instance == FDCAN2) { - /* USER CODE BEGIN FDCAN2_MspInit 0 */ - - /* USER CODE END FDCAN2_MspInit 0 */ - LL_RCC_SetFDCANClockSource(LL_RCC_FDCAN_CLKSOURCE_PCLK1); - - /* FDCAN2 clock enable */ - __HAL_RCC_FDCAN_CLK_ENABLE(); - - __HAL_RCC_GPIOB_CLK_ENABLE(); - /**FDCAN2 GPIO Configuration - PB12 ------> FDCAN2_RX - PB13 ------> FDCAN2_TX - */ - GPIO_InitStruct.Pin = GPIO_PIN_12; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_PULLUP; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF9_FDCAN2; - HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = GPIO_PIN_13; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF9_FDCAN2; - HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - /* FDCAN2 interrupt Init */ - HAL_NVIC_SetPriority(FDCAN2_IT0_IRQn, 0, 0); - HAL_NVIC_EnableIRQ(FDCAN2_IT0_IRQn); - /* USER CODE BEGIN FDCAN2_MspInit 1 */ - - /* USER CODE END FDCAN2_MspInit 1 */ - } -} - -void HAL_FDCAN_MspDeInit(FDCAN_HandleTypeDef *fdcanHandle) -{ - - if (fdcanHandle->Instance == FDCAN2) { - /* USER CODE BEGIN FDCAN2_MspDeInit 0 */ - - /* USER CODE END FDCAN2_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_FDCAN_CLK_DISABLE(); - - /**FDCAN2 GPIO Configuration - PB12 ------> FDCAN2_RX - PB13 ------> FDCAN2_TX - */ - HAL_GPIO_DeInit(GPIOB, GPIO_PIN_12 | GPIO_PIN_13); - - /* FDCAN2 interrupt Deinit */ - HAL_NVIC_DisableIRQ(FDCAN2_IT0_IRQn); - /* USER CODE BEGIN FDCAN2_MspDeInit 1 */ - - /* USER CODE END FDCAN2_MspDeInit 1 */ - } -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ diff --git a/G4ADCTESTING/Core/Src/gpio.c b/G4ADCTESTING/Core/Src/gpio.c deleted file mode 100644 index d36e6eca6..000000000 --- a/G4ADCTESTING/Core/Src/gpio.c +++ /dev/null @@ -1,260 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file gpio.c - * @brief This file provides code for the configuration - * of all used GPIO pins. - ****************************************************************************** - * @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 "gpio.h" - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/*----------------------------------------------------------------------------*/ -/* Configure GPIO */ -/*----------------------------------------------------------------------------*/ -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ - -/** Configure pins as - * Analog - * Input - * Output - * EVENT_OUT - * EXTI - * Free pins are configured automatically as Analog (this feature is - enabled through - * the Code Generation settings) - PA6 ------> ADC2_IN3 - PA7 ------> ADC2_IN4 - PB15 ------> ADC2_IN15 - PB7 ------> UART4_CTS -*/ -void MX_GPIO_Init(void) -{ - - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - - /* GPIO Ports Clock Enable */ - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOF); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOG); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOB); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOD); - - /**/ - LL_GPIO_ResetOutputPin(BLINKY_GPIO_Port, BLINKY_Pin); - - /**/ - LL_GPIO_ResetOutputPin(LED_TEST_GPIO_Port, LED_TEST_Pin); - - /**/ - LL_GPIO_ResetOutputPin(BRAKE_LIGHT_GPIO_Port, BRAKE_LIGHT_Pin); - - /**/ - LL_GPIO_ResetOutputPin(TSSI_G_CONTROL_GPIO_Port, TSSI_G_CONTROL_Pin); - - /**/ - LL_GPIO_ResetOutputPin(AUX_CONTROL_GPIO_Port, AUX_CONTROL_Pin); - - /**/ - LL_GPIO_ResetOutputPin(SOFTWARE_OK_CONTROL_GPIO_Port, SOFTWARE_OK_CONTROL_Pin); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_13; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_14; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_15; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_10; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOG, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_0; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_1; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_4; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = BLINKY_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(BLINKY_GPIO_Port, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = IMD_SENSE_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(IMD_SENSE_GPIO_Port, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = AMS_SENSE_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(AMS_SENSE_GPIO_Port, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_2; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_10; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LED_TEST_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(LED_TEST_GPIO_Port, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = STEERING_ANGLE_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(STEERING_ANGLE_GPIO_Port, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_6; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_7; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_8; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_9; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_9; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_10; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_15; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_2; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOD, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = BRAKE_LIGHT_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(BRAKE_LIGHT_GPIO_Port, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = TSSI_G_CONTROL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(TSSI_G_CONTROL_GPIO_Port, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_7; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_14; - LL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = AUX_CONTROL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(AUX_CONTROL_GPIO_Port, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = SOFTWARE_OK_CONTROL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(SOFTWARE_OK_CONTROL_GPIO_Port, &GPIO_InitStruct); -} - -/* USER CODE BEGIN 2 */ - -/* USER CODE END 2 */ diff --git a/G4ADCTESTING/Core/Src/i2c.c b/G4ADCTESTING/Core/Src/i2c.c deleted file mode 100644 index bfb4e0153..000000000 --- a/G4ADCTESTING/Core/Src/i2c.c +++ /dev/null @@ -1,92 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file i2c.c - * @brief This file provides code for the configuration - * of the I2C instances. - ****************************************************************************** - * @attention - * - * Copyright (c) 2025 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 "i2c.h" - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/* I2C2 init function */ -void MX_I2C2_Init(void) -{ - - /* USER CODE BEGIN I2C2_Init 0 */ - - /* USER CODE END I2C2_Init 0 */ - - LL_I2C_InitTypeDef I2C_InitStruct = {0}; - - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - - LL_RCC_SetI2CClockSource(LL_RCC_I2C2_CLKSOURCE_PCLK1); - - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA); - /**I2C2 GPIO Configuration - PC4 ------> I2C2_SCL - PA8 ------> I2C2_SDA - */ - GPIO_InitStruct.Pin = LL_GPIO_PIN_4; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_OPENDRAIN; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_4; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = LL_GPIO_PIN_8; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_OPENDRAIN; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_4; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /* Peripheral clock enable */ - LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_I2C2); - - /* USER CODE BEGIN I2C2_Init 1 */ - - /* USER CODE END I2C2_Init 1 */ - - /** I2C Initialization - */ - I2C_InitStruct.PeripheralMode = LL_I2C_MODE_I2C; - I2C_InitStruct.Timing = 0x30D29DE4; - I2C_InitStruct.AnalogFilter = LL_I2C_ANALOGFILTER_ENABLE; - I2C_InitStruct.DigitalFilter = 0; - I2C_InitStruct.OwnAddress1 = 0; - I2C_InitStruct.TypeAcknowledge = LL_I2C_ACK; - I2C_InitStruct.OwnAddrSize = LL_I2C_OWNADDRESS1_7BIT; - LL_I2C_Init(I2C2, &I2C_InitStruct); - LL_I2C_EnableAutoEndMode(I2C2); - LL_I2C_SetOwnAddress2(I2C2, 0, LL_I2C_OWNADDRESS2_NOMASK); - LL_I2C_DisableOwnAddress2(I2C2); - LL_I2C_DisableGeneralCall(I2C2); - LL_I2C_EnableClockStretching(I2C2); - /* USER CODE BEGIN I2C2_Init 2 */ - - /* USER CODE END I2C2_Init 2 */ -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ diff --git a/G4ADCTESTING/Core/Src/main.c b/G4ADCTESTING/Core/Src/main.c deleted file mode 100644 index 5b3a492dc..000000000 --- a/G4ADCTESTING/Core/Src/main.c +++ /dev/null @@ -1,276 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file : main.c - * @brief : Main program body - ****************************************************************************** - * @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 "main.h" - -#include "Logomatic.h" -#include "adc.h" -#include "dma.h" -#include "fdcan.h" -#include "gpio.h" -#include "gr_adc.h" -#include "i2c.h" -#include "malloc.h" -#include "spi.h" -#include "tim.h" -#include "usart.h" -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* Private typedef -----------------------------------------------------------*/ -/* USER CODE BEGIN PTD */ - -/* USER CODE END PTD */ - -/* Private define ------------------------------------------------------------*/ -/* USER CODE BEGIN PD */ - -/* USER CODE END PD */ - -/* Private macro -------------------------------------------------------------*/ -/* USER CODE BEGIN PM */ - -/* USER CODE END PM */ - -/* Private variables ---------------------------------------------------------*/ - -/* USER CODE BEGIN PV */ -/* USER CODE END PV */ - -/* Private function prototypes -----------------------------------------------*/ -void SystemClock_Config(void); -/* USER CODE BEGIN PFP */ - -/* USER CODE END PFP */ - -/* Private user code ---------------------------------------------------------*/ -/* USER CODE BEGIN 0 */ -#define WINDOW_SIZE 10 // weighted average for now can extend to other window functions -#define NUM_SIGNALS 1 -volatile uint16_t buffers[NUM_SIGNALS] = {0}; // Contains new values -uint16_t outputs[NUM_SIGNALS] = {0}; // Updated averages -uint16_t *adcDataValues[NUM_SIGNALS] = {0}; -// Flag raised with DMA finishes transfer -volatile uint8_t DMA_Transfer_Complete = 0; - -/* Enable ITM for SWO output */ -static void ITM_Enable(void) -{ - /* Enable TRC (Trace) */ - CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; - - /* Enable stimulus port 0 */ - ITM->TER |= (1UL << 0); - - /* Set trace control register */ - ITM->TCR |= ITM_TCR_ITMENA_Msk; -} - -/* USER CODE BEGIN 0 */ -void ADC_Configure(void) -{ - // Initialize which clock source to use - LL_RCC_SetADCClockSource(LL_RCC_ADC12_CLKSOURCE_SYSCLK); - /* Peripheral clock enable */ - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_ADC12); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA); - - ADC_Init_Values init_vals = {0}; - init_vals.ADC = ADC1; - init_vals.PS_Value = PS_8; - init_vals.Res = RESOLUTION_12; - init_vals.Num_Pin_Port_Objs = 1; - Pin_Ports p = {LL_GPIO_PIN_0, GPIOA}; - init_vals.Pins = &p; - init_vals.Num_Channels = 1; - Channel c = ADC_CHANNEL_1; - init_vals.Channels = &c; - SamplingTime s = SAMPLINGTIME_247CYCLES_5; - init_vals.SamplingTimes = &s; - ADC_Init(&init_vals); - - // Initialize DMA - DMA_Init_Values DMA_Init_Vals = {0}; - DMA_Init_Vals.DMA = DMA1; - DMA_Init_Vals.ADC = ADC1; - DMA_Init_Vals.Channel = DMA_CHANNEL_1; - DMA_Init_Vals.Src_Address = LL_ADC_DMA_GetRegAddr(ADC1, LL_ADC_DMA_REG_REGULAR_DATA); - DMA_Init_Vals.Dest_Address = &buffers; - DMA_Init_Vals.Data_Size = Word; - DMA_Init_Vals.Priority = LOW; - DMA_Init(&DMA_Init_Vals); - LL_DMA_EnableChannel(DMA1, LL_DMA_CHANNEL_1); - - ADC_Enable_And_Calibrate(ADC1); -} -/* USER CODE END 0 */ - -/** - * @brief The application entry point. - * @retval int - */ -int main(void) -{ - - /* USER CODE BEGIN 1 */ - - /* USER CODE END 1 */ - - /* MCU - * Configuration--------------------------------------------------------*/ - - /* Reset of all peripherals, Initializes the Flash interface and the - * Systick. */ - HAL_Init(); - - /* USER CODE BEGIN Init */ - ITM_Enable(); - /* USER CODE END Init */ - - /* Configure the system clock */ - SystemClock_Config(); - - /* USER CODE BEGIN SysInit */ - - /* USER CODE END SysInit */ - - /* Initialize all configured peripherals */ - MX_GPIO_Init(); - MX_DMA_Init(); - MX_FDCAN2_Init(); - MX_ADC1_Init(); - MX_LPUART1_UART_Init(); - MX_I2C2_Init(); - MX_USART1_UART_Init(); - MX_SPI3_Init(); - MX_TIM2_Init(); - /* USER CODE BEGIN 2 */ - ADC_Configure(); - /* USER CODE END 2 */ - adcDataValues[0] = malloc(sizeof(uint16_t) * WINDOW_SIZE); - - /* Infinite loop */ - /* USER CODE BEGIN WHILE */ - while (1) { - /* USER CODE END WHILE */ - - // BLINKY - HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_SET); - HAL_Delay(50); - HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_RESET); - HAL_Delay(50); - - /* USER CODE BEGIN 3 */ - LOGOMATIC("Buffer Value: %u\n", buffers[0]); - // ADC_UpdateAnalogValues(adcDataValues, buffers, NUM_SIGNALS, WINDOW_SIZE, outputs); - ADC_UpdateAnalogValues_EMA(buffers, NUM_SIGNALS, 0.3, outputs); - LOGOMATIC("Moving Average: %u\n", outputs[0]); - DMA_Transfer_Complete = 0; - // just test 1 pin for now - if (DMA_Transfer_Complete) {} - } - - free(adcDataValues[0]); -} - -void DMA1_Channel1_IRQHandler(void) -{ - if (LL_DMA_IsActiveFlag_TC1(DMA1)) { - LL_DMA_ClearFlag_TC1(DMA1); - DMA_Transfer_Complete = 1; // notify main loop - } -} - -/** - * @brief System Clock Configuration - * @retval None - */ -void SystemClock_Config(void) -{ - LL_FLASH_SetLatency(LL_FLASH_LATENCY_4); - while (LL_FLASH_GetLatency() != LL_FLASH_LATENCY_4) {} - LL_PWR_EnableRange1BoostMode(); - LL_RCC_HSI_Enable(); - /* Wait till HSI is ready */ - while (LL_RCC_HSI_IsReady() != 1) {} - - LL_RCC_HSI_SetCalibTrimming(64); - LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSI, LL_RCC_PLLM_DIV_4, 85, LL_RCC_PLLR_DIV_2); - LL_RCC_PLL_EnableDomain_SYS(); - LL_RCC_PLL_Enable(); - /* Wait till PLL is ready */ - while (LL_RCC_PLL_IsReady() != 1) {} - - LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL); - LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_2); - /* Wait till System clock is ready */ - while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL) {} - - /* Insure 1us transition state at intermediate medium speed clock*/ - for (__IO uint32_t i = (170 >> 1); i != 0; i--) - ; - - /* Set AHB prescaler*/ - LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1); - LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1); - LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_1); - LL_SetSystemCoreClock(170000000); - - /* Update the time base */ - if (HAL_InitTick(TICK_INT_PRIORITY) != HAL_OK) { - Error_Handler(); - } -} - -/* USER CODE BEGIN 4 */ - -/* USER CODE END 4 */ - -/** - * @brief This function is executed in case of error occurrence. - * @retval None - */ -void Error_Handler(void) -{ - /* USER CODE BEGIN Error_Handler_Debug */ - /* User can add his own implementation to report the HAL error return - * state */ - __disable_irq(); - while (1) {} - /* USER CODE END Error_Handler_Debug */ -} -#ifdef USE_FULL_ASSERT -/** - * @brief Reports the name of the source file and the source line number - * where the assert_param error has occurred. - * @param file: pointer to the source file name - * @param line: assert_param error line source number - * @retval None - */ -void assert_failed(uint8_t *file, uint32_t line) -{ - /* USER CODE BEGIN 6 */ - /* User can add his own implementation to report the file name and line - number, ex: printf("Wrong parameters value: file %s on line %d\r\n", - file, line) */ - /* USER CODE END 6 */ -} -#endif /* USE_FULL_ASSERT */ diff --git a/G4ADCTESTING/Core/Src/spi.c b/G4ADCTESTING/Core/Src/spi.c deleted file mode 100644 index 66459f2ec..000000000 --- a/G4ADCTESTING/Core/Src/spi.c +++ /dev/null @@ -1,95 +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 */ - -/* SPI3 init function */ -void MX_SPI3_Init(void) -{ - - /* USER CODE BEGIN SPI3_Init 0 */ - - /* USER CODE END SPI3_Init 0 */ - - LL_SPI_InitTypeDef SPI_InitStruct = {0}; - - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - - /* Peripheral clock enable */ - LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_SPI3); - - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC); - /**SPI3 GPIO Configuration - PC10 ------> SPI3_SCK - PC11 ------> SPI3_MISO - PC12 ------> SPI3_MOSI - */ - GPIO_InitStruct.Pin = LL_GPIO_PIN_10; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_6; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = LL_GPIO_PIN_11; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_6; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = LL_GPIO_PIN_12; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_6; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /* USER CODE BEGIN SPI3_Init 1 */ - - /* USER CODE END SPI3_Init 1 */ - SPI_InitStruct.TransferDirection = LL_SPI_FULL_DUPLEX; - SPI_InitStruct.Mode = LL_SPI_MODE_MASTER; - SPI_InitStruct.DataWidth = LL_SPI_DATAWIDTH_4BIT; - SPI_InitStruct.ClockPolarity = LL_SPI_POLARITY_LOW; - SPI_InitStruct.ClockPhase = LL_SPI_PHASE_1EDGE; - SPI_InitStruct.NSS = LL_SPI_NSS_SOFT; - SPI_InitStruct.BaudRate = LL_SPI_BAUDRATEPRESCALER_DIV32; - SPI_InitStruct.BitOrder = LL_SPI_MSB_FIRST; - SPI_InitStruct.CRCCalculation = LL_SPI_CRCCALCULATION_DISABLE; - SPI_InitStruct.CRCPoly = 7; - LL_SPI_Init(SPI3, &SPI_InitStruct); - LL_SPI_SetStandard(SPI3, LL_SPI_PROTOCOL_MOTOROLA); - LL_SPI_EnableNSSPulseMgt(SPI3); - /* USER CODE BEGIN SPI3_Init 2 */ - - /* USER CODE END SPI3_Init 2 */ -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ diff --git a/G4ADCTESTING/Core/Src/stm32g4xx_it.c b/G4ADCTESTING/Core/Src/stm32g4xx_it.c deleted file mode 100644 index 2f0cf90a7..000000000 --- a/G4ADCTESTING/Core/Src/stm32g4xx_it.c +++ /dev/null @@ -1,212 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file stm32g4xx_it.c - * @brief Interrupt Service Routines. - ****************************************************************************** - * @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 "stm32g4xx_it.h" - -#include "main.h" -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ -/* USER CODE END Includes */ - -/* Private typedef -----------------------------------------------------------*/ -/* USER CODE BEGIN TD */ - -/* USER CODE END TD */ - -/* Private define ------------------------------------------------------------*/ -/* USER CODE BEGIN PD */ - -/* USER CODE END PD */ - -/* Private macro -------------------------------------------------------------*/ -/* USER CODE BEGIN PM */ - -/* USER CODE END PM */ - -/* Private variables ---------------------------------------------------------*/ -/* USER CODE BEGIN PV */ - -/* USER CODE END PV */ - -/* Private function prototypes -----------------------------------------------*/ -/* USER CODE BEGIN PFP */ - -/* USER CODE END PFP */ - -/* Private user code ---------------------------------------------------------*/ -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/* External variables --------------------------------------------------------*/ -extern FDCAN_HandleTypeDef hfdcan2; -/* USER CODE BEGIN EV */ - -/* USER CODE END EV */ - -/******************************************************************************/ -/* Cortex-M4 Processor Interruption and Exception Handlers */ -/******************************************************************************/ -/** - * @brief This function handles Non maskable interrupt. - */ -void NMI_Handler(void) -{ - /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ - - /* USER CODE END NonMaskableInt_IRQn 0 */ - /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ - while (1) {} - /* USER CODE END NonMaskableInt_IRQn 1 */ -} - -/** - * @brief This function handles Hard fault interrupt. - */ -void HardFault_Handler(void) -{ - /* USER CODE BEGIN HardFault_IRQn 0 */ - - /* USER CODE END HardFault_IRQn 0 */ - while (1) { - /* USER CODE BEGIN W1_HardFault_IRQn 0 */ - /* USER CODE END W1_HardFault_IRQn 0 */ - } -} - -/** - * @brief This function handles Memory management fault. - */ -void MemManage_Handler(void) -{ - /* USER CODE BEGIN MemoryManagement_IRQn 0 */ - - /* USER CODE END MemoryManagement_IRQn 0 */ - while (1) { - /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ - /* USER CODE END W1_MemoryManagement_IRQn 0 */ - } -} - -/** - * @brief This function handles Prefetch fault, memory access fault. - */ -void BusFault_Handler(void) -{ - /* USER CODE BEGIN BusFault_IRQn 0 */ - - /* USER CODE END BusFault_IRQn 0 */ - while (1) { - /* USER CODE BEGIN W1_BusFault_IRQn 0 */ - /* USER CODE END W1_BusFault_IRQn 0 */ - } -} - -/** - * @brief This function handles Undefined instruction or illegal state. - */ -void UsageFault_Handler(void) -{ - /* USER CODE BEGIN UsageFault_IRQn 0 */ - - /* USER CODE END UsageFault_IRQn 0 */ - while (1) { - /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ - /* USER CODE END W1_UsageFault_IRQn 0 */ - } -} - -/** - * @brief This function handles System service call via SWI instruction. - */ -void SVC_Handler(void) -{ - /* USER CODE BEGIN SVCall_IRQn 0 */ - - /* USER CODE END SVCall_IRQn 0 */ - /* USER CODE BEGIN SVCall_IRQn 1 */ - - /* USER CODE END SVCall_IRQn 1 */ -} - -/** - * @brief This function handles Debug monitor. - */ -void DebugMon_Handler(void) -{ - /* USER CODE BEGIN DebugMonitor_IRQn 0 */ - - /* USER CODE END DebugMonitor_IRQn 0 */ - /* USER CODE BEGIN DebugMonitor_IRQn 1 */ - - /* USER CODE END DebugMonitor_IRQn 1 */ -} - -/** - * @brief This function handles Pendable request for system service. - */ -void PendSV_Handler(void) -{ - /* USER CODE BEGIN PendSV_IRQn 0 */ - - /* USER CODE END PendSV_IRQn 0 */ - /* USER CODE BEGIN PendSV_IRQn 1 */ - - /* USER CODE END PendSV_IRQn 1 */ -} - -/** - * @brief This function handles System tick timer. - */ -void SysTick_Handler(void) -{ - /* USER CODE BEGIN SysTick_IRQn 0 */ - - /* USER CODE END SysTick_IRQn 0 */ - HAL_IncTick(); - /* USER CODE BEGIN SysTick_IRQn 1 */ - - /* USER CODE END SysTick_IRQn 1 */ -} - -/******************************************************************************/ -/* STM32G4xx Peripheral Interrupt Handlers */ -/* Add here the Interrupt Handlers for the used peripherals. */ -/* For the available peripheral interrupt handler names, */ -/* please refer to the startup file (startup_stm32g4xx.s). */ -/******************************************************************************/ - -/** - * @brief This function handles FDCAN2 interrupt 0. - */ -void FDCAN2_IT0_IRQHandler(void) -{ - /* USER CODE BEGIN FDCAN2_IT0_IRQn 0 */ - - /* USER CODE END FDCAN2_IT0_IRQn 0 */ - HAL_FDCAN_IRQHandler(&hfdcan2); - /* USER CODE BEGIN FDCAN2_IT0_IRQn 1 */ - - /* USER CODE END FDCAN2_IT0_IRQn 1 */ -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ diff --git a/G4ADCTESTING/Core/Src/tim.c b/G4ADCTESTING/Core/Src/tim.c deleted file mode 100644 index 7f521c3bf..000000000 --- a/G4ADCTESTING/Core/Src/tim.c +++ /dev/null @@ -1,79 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file tim.c - * @brief This file provides code for the configuration - * of the TIM instances. - ****************************************************************************** - * @attention - * - * Copyright (c) 2025 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 "tim.h" - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/* TIM2 init function */ -void MX_TIM2_Init(void) -{ - - /* USER CODE BEGIN TIM2_Init 0 */ - - /* USER CODE END TIM2_Init 0 */ - - LL_TIM_InitTypeDef TIM_InitStruct = {0}; - LL_TIM_OC_InitTypeDef TIM_OC_InitStruct = {0}; - - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - /* Peripheral clock enable */ - LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM2); - - /* USER CODE BEGIN TIM2_Init 1 */ - - /* USER CODE END TIM2_Init 1 */ - TIM_InitStruct.Prescaler = 0; - TIM_InitStruct.CounterMode = LL_TIM_COUNTERMODE_UP; - TIM_InitStruct.Autoreload = 4294967295; - TIM_InitStruct.ClockDivision = LL_TIM_CLOCKDIVISION_DIV1; - LL_TIM_Init(TIM2, &TIM_InitStruct); - LL_TIM_DisableARRPreload(TIM2); - LL_TIM_SetClockSource(TIM2, LL_TIM_CLOCKSOURCE_INTERNAL); - TIM_OC_InitStruct.OCMode = LL_TIM_OCMODE_FORCED_ACTIVE; - TIM_OC_InitStruct.OCState = LL_TIM_OCSTATE_DISABLE; - TIM_OC_InitStruct.OCNState = LL_TIM_OCSTATE_DISABLE; - TIM_OC_InitStruct.CompareValue = 0; - TIM_OC_InitStruct.OCPolarity = LL_TIM_OCPOLARITY_HIGH; - LL_TIM_OC_Init(TIM2, LL_TIM_CHANNEL_CH1, &TIM_OC_InitStruct); - LL_TIM_OC_DisableFast(TIM2, LL_TIM_CHANNEL_CH1); - LL_TIM_SetTriggerOutput(TIM2, LL_TIM_TRGO_RESET); - LL_TIM_DisableMasterSlaveMode(TIM2); - /* USER CODE BEGIN TIM2_Init 2 */ - - /* USER CODE END TIM2_Init 2 */ - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA); - /**TIM2 GPIO Configuration - PA0 ------> TIM2_CH1 - */ - GPIO_InitStruct.Pin = LL_GPIO_PIN_0; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_1; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ diff --git a/G4ADCTESTING/Core/Src/usart.c b/G4ADCTESTING/Core/Src/usart.c deleted file mode 100644 index 56a3fa98f..000000000 --- a/G4ADCTESTING/Core/Src/usart.c +++ /dev/null @@ -1,184 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file usart.c - * @brief This file provides code for the configuration - * of the USART instances. - ****************************************************************************** - * @attention - * - * Copyright (c) 2025 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 "usart.h" - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/* LPUART1 init function */ - -void MX_LPUART1_UART_Init(void) -{ - - /* USER CODE BEGIN LPUART1_Init 0 */ - - /* USER CODE END LPUART1_Init 0 */ - - LL_LPUART_InitTypeDef LPUART_InitStruct = {0}; - - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - - LL_RCC_SetLPUARTClockSource(LL_RCC_LPUART1_CLKSOURCE_PCLK1); - - /* Peripheral clock enable */ - LL_APB1_GRP2_EnableClock(LL_APB1_GRP2_PERIPH_LPUART1); - - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA); - /**LPUART1 GPIO Configuration - PA2 ------> LPUART1_TX - PA3 ------> LPUART1_RX - */ - GPIO_InitStruct.Pin = LL_GPIO_PIN_2; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_12; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = LL_GPIO_PIN_3; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_12; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /* USER CODE BEGIN LPUART1_Init 1 */ - - /* USER CODE END LPUART1_Init 1 */ - LPUART_InitStruct.PrescalerValue = LL_LPUART_PRESCALER_DIV1; - LPUART_InitStruct.BaudRate = 115200; - LPUART_InitStruct.DataWidth = LL_LPUART_DATAWIDTH_8B; - LPUART_InitStruct.StopBits = LL_LPUART_STOPBITS_1; - LPUART_InitStruct.Parity = LL_LPUART_PARITY_NONE; - LPUART_InitStruct.TransferDirection = LL_LPUART_DIRECTION_TX_RX; - LPUART_InitStruct.HardwareFlowControl = LL_LPUART_HWCONTROL_NONE; - LL_LPUART_Init(LPUART1, &LPUART_InitStruct); - LL_LPUART_SetTXFIFOThreshold(LPUART1, LL_LPUART_FIFOTHRESHOLD_1_8); - LL_LPUART_SetRXFIFOThreshold(LPUART1, LL_LPUART_FIFOTHRESHOLD_1_8); - LL_LPUART_DisableFIFO(LPUART1); - - /* USER CODE BEGIN WKUPType LPUART1 */ - - /* USER CODE END WKUPType LPUART1 */ - - LL_LPUART_Enable(LPUART1); - - /* Polling LPUART1 initialisation */ - while ((!(LL_LPUART_IsActiveFlag_TEACK(LPUART1))) || (!(LL_LPUART_IsActiveFlag_REACK(LPUART1)))) {} - /* USER CODE BEGIN LPUART1_Init 2 */ - - /* USER CODE END LPUART1_Init 2 */ -} -/* USART1 init function */ - -void MX_USART1_UART_Init(void) -{ - - /* USER CODE BEGIN USART1_Init 0 */ - - /* USER CODE END USART1_Init 0 */ - - LL_USART_InitTypeDef USART_InitStruct = {0}; - - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - - LL_RCC_SetUSARTClockSource(LL_RCC_USART1_CLKSOURCE_PCLK2); - - /* Peripheral clock enable */ - LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_USART1); - - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOB); - /**USART1 GPIO Configuration - PC5 ------> USART1_RX - PA11 ------> USART1_CTS - PA12 ------> USART1_RTS - PB6 ------> USART1_TX - */ - GPIO_InitStruct.Pin = LL_GPIO_PIN_5; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_7; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = LL_GPIO_PIN_11; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_7; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = LL_GPIO_PIN_12; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_7; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = LL_GPIO_PIN_6; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_7; - LL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - /* USER CODE BEGIN USART1_Init 1 */ - - /* USER CODE END USART1_Init 1 */ - USART_InitStruct.PrescalerValue = LL_USART_PRESCALER_DIV1; - USART_InitStruct.BaudRate = 115200; - USART_InitStruct.DataWidth = LL_USART_DATAWIDTH_8B; - USART_InitStruct.StopBits = LL_USART_STOPBITS_1; - USART_InitStruct.Parity = LL_USART_PARITY_NONE; - USART_InitStruct.TransferDirection = LL_USART_DIRECTION_TX_RX; - USART_InitStruct.HardwareFlowControl = LL_USART_HWCONTROL_RTS_CTS; - USART_InitStruct.OverSampling = LL_USART_OVERSAMPLING_16; - LL_USART_Init(USART1, &USART_InitStruct); - LL_USART_SetTXFIFOThreshold(USART1, LL_USART_FIFOTHRESHOLD_1_8); - LL_USART_SetRXFIFOThreshold(USART1, LL_USART_FIFOTHRESHOLD_1_8); - LL_USART_DisableFIFO(USART1); - LL_USART_ConfigAsyncMode(USART1); - - /* USER CODE BEGIN WKUPType USART1 */ - - /* USER CODE END WKUPType USART1 */ - - LL_USART_Enable(USART1); - - /* Polling USART1 initialisation */ - while ((!(LL_USART_IsActiveFlag_TEACK(USART1))) || (!(LL_USART_IsActiveFlag_REACK(USART1)))) {} - /* USER CODE BEGIN USART1_Init 2 */ - - /* USER CODE END USART1_Init 2 */ -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ diff --git a/G4ADCTESTING/G4PERTESTING.ioc b/G4ADCTESTING/G4PERTESTING.ioc deleted file mode 100644 index 8cf1860b1..000000000 --- a/G4ADCTESTING/G4PERTESTING.ioc +++ /dev/null @@ -1,382 +0,0 @@ -#MicroXplorer Configuration settings - do not modify -ADC1.Channel-2\#ChannelRegularConversion=ADC_CHANNEL_5 -ADC1.Channel-3\#ChannelRegularConversion=ADC_CHANNEL_7 -ADC1.Channel-4\#ChannelRegularConversion=ADC_CHANNEL_8 -ADC1.Channel-5\#ChannelRegularConversion=ADC_CHANNEL_9 -ADC1.Channel-6\#ChannelRegularConversion=ADC_CHANNEL_12 -ADC1.Channel-7\#ChannelRegularConversion=ADC_CHANNEL_15 -ADC1.ClockPrescaler=ADC_CLOCK_ASYNC_DIV256 -ADC1.CommonPathInternal=null|null|null|null -ADC1.ContinuousConvMode=ENABLE -ADC1.DMAContinuousRequests=ENABLE -ADC1.EOCSelection=ADC_EOC_SEQ_CONV -ADC1.ExternalTrigConv=ADC_SOFTWARE_START -ADC1.IPParameters=Rank-2\#ChannelRegularConversion,Channel-2\#ChannelRegularConversion,SamplingTime-2\#ChannelRegularConversion,OffsetNumber-2\#ChannelRegularConversion,NbrOfConversionFlag,master,Rank-3\#ChannelRegularConversion,Channel-3\#ChannelRegularConversion,SamplingTime-3\#ChannelRegularConversion,OffsetNumber-3\#ChannelRegularConversion,Rank-4\#ChannelRegularConversion,Channel-4\#ChannelRegularConversion,SamplingTime-4\#ChannelRegularConversion,OffsetNumber-4\#ChannelRegularConversion,Rank-5\#ChannelRegularConversion,Channel-5\#ChannelRegularConversion,SamplingTime-5\#ChannelRegularConversion,OffsetNumber-5\#ChannelRegularConversion,Rank-6\#ChannelRegularConversion,Channel-6\#ChannelRegularConversion,SamplingTime-6\#ChannelRegularConversion,OffsetNumber-6\#ChannelRegularConversion,Rank-7\#ChannelRegularConversion,Channel-7\#ChannelRegularConversion,SamplingTime-7\#ChannelRegularConversion,OffsetNumber-7\#ChannelRegularConversion,NbrOfConversion,ContinuousConvMode,DMAContinuousRequests,ClockPrescaler,EOCSelection,ExternalTrigConv,CommonPathInternal -ADC1.NbrOfConversion=6 -ADC1.NbrOfConversionFlag=1 -ADC1.OffsetNumber-2\#ChannelRegularConversion=ADC_OFFSET_NONE -ADC1.OffsetNumber-3\#ChannelRegularConversion=ADC_OFFSET_NONE -ADC1.OffsetNumber-4\#ChannelRegularConversion=ADC_OFFSET_NONE -ADC1.OffsetNumber-5\#ChannelRegularConversion=ADC_OFFSET_NONE -ADC1.OffsetNumber-6\#ChannelRegularConversion=ADC_OFFSET_NONE -ADC1.OffsetNumber-7\#ChannelRegularConversion=ADC_OFFSET_NONE -ADC1.Rank-2\#ChannelRegularConversion=1 -ADC1.Rank-3\#ChannelRegularConversion=2 -ADC1.Rank-4\#ChannelRegularConversion=3 -ADC1.Rank-5\#ChannelRegularConversion=4 -ADC1.Rank-6\#ChannelRegularConversion=5 -ADC1.Rank-7\#ChannelRegularConversion=6 -ADC1.SamplingTime-2\#ChannelRegularConversion=ADC_SAMPLETIME_92CYCLES_5 -ADC1.SamplingTime-3\#ChannelRegularConversion=ADC_SAMPLETIME_92CYCLES_5 -ADC1.SamplingTime-4\#ChannelRegularConversion=ADC_SAMPLETIME_92CYCLES_5 -ADC1.SamplingTime-5\#ChannelRegularConversion=ADC_SAMPLETIME_92CYCLES_5 -ADC1.SamplingTime-6\#ChannelRegularConversion=ADC_SAMPLETIME_92CYCLES_5 -ADC1.SamplingTime-7\#ChannelRegularConversion=ADC_SAMPLETIME_92CYCLES_5 -ADC1.master=1 -CAD.formats=[] -CAD.pinconfig=Dual -CAD.provider= -Dma.ADC1.0.Direction=DMA_PERIPH_TO_MEMORY -Dma.ADC1.0.EventEnable=DISABLE -Dma.ADC1.0.Instance=DMA1_Channel1 -Dma.ADC1.0.MemDataAlignment=DMA_MDATAALIGN_HALFWORD -Dma.ADC1.0.MemInc=DMA_MINC_ENABLE -Dma.ADC1.0.Mode=DMA_CIRCULAR -Dma.ADC1.0.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD -Dma.ADC1.0.PeriphInc=DMA_PINC_DISABLE -Dma.ADC1.0.Polarity=HAL_DMAMUX_REQ_GEN_RISING -Dma.ADC1.0.Priority=DMA_PRIORITY_LOW -Dma.ADC1.0.RequestNumber=1 -Dma.ADC1.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -Dma.ADC1.0.SignalID=NONE -Dma.ADC1.0.SyncEnable=DISABLE -Dma.ADC1.0.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT -Dma.ADC1.0.SyncRequestNumber=1 -Dma.ADC1.0.SyncSignalID=NONE -Dma.Request0=ADC1 -Dma.RequestsNb=1 -FDCAN2.AutoRetransmission=ENABLE -FDCAN2.CalculateBaudRateNominal=1000000 -FDCAN2.CalculateTimeBitNominal=1000 -FDCAN2.CalculateTimeQuantumNominal=6.25 -FDCAN2.DataPrescaler=8 -FDCAN2.DataSyncJumpWidth=16 -FDCAN2.DataTimeSeg1=14 -FDCAN2.DataTimeSeg2=5 -FDCAN2.ExtFiltersNbr=2 -FDCAN2.FrameFormat=FDCAN_FRAME_CLASSIC -FDCAN2.IPParameters=CalculateTimeQuantumNominal,CalculateTimeBitNominal,CalculateBaudRateNominal,FrameFormat,NominalTimeSeg1,NominalTimeSeg2,NominalPrescaler,AutoRetransmission,StdFiltersNbr,TransmitPause,NominalSyncJumpWidth,DataTimeSeg1,DataTimeSeg2,DataPrescaler,DataSyncJumpWidth,ExtFiltersNbr,ProtocolException -FDCAN2.NominalPrescaler=1 -FDCAN2.NominalSyncJumpWidth=16 -FDCAN2.NominalTimeSeg1=119 -FDCAN2.NominalTimeSeg2=40 -FDCAN2.ProtocolException=ENABLE -FDCAN2.StdFiltersNbr=0 -FDCAN2.TransmitPause=DISABLE -File.Version=6 -GPIO.groupedBy=Group By Peripherals -I2C2.IPParameters=Timing -I2C2.Timing=0x30D29DE4 -KeepUserPlacement=false -LPUART1.BaudRate=115200 -LPUART1.IPParameters=BaudRate -Mcu.CPN=STM32G474RET6 -Mcu.Family=STM32G4 -Mcu.IP0=ADC1 -Mcu.IP1=DMA -Mcu.IP10=USART1 -Mcu.IP2=FDCAN2 -Mcu.IP3=I2C2 -Mcu.IP4=LPUART1 -Mcu.IP5=NVIC -Mcu.IP6=RCC -Mcu.IP7=SPI3 -Mcu.IP8=SYS -Mcu.IP9=TIM2 -Mcu.IPNb=11 -Mcu.Name=STM32G474R(B-C-E)Tx -Mcu.Package=LQFP64 -Mcu.Pin0=PF0-OSC_IN -Mcu.Pin1=PF1-OSC_OUT -Mcu.Pin10=PA7 -Mcu.Pin11=PC4 -Mcu.Pin12=PC5 -Mcu.Pin13=PB0 -Mcu.Pin14=PB1 -Mcu.Pin15=PB11 -Mcu.Pin16=PB12 -Mcu.Pin17=PB13 -Mcu.Pin18=PB14 -Mcu.Pin19=PB15 -Mcu.Pin2=PC1 -Mcu.Pin20=PA8 -Mcu.Pin21=PA11 -Mcu.Pin22=PA12 -Mcu.Pin23=PA13 -Mcu.Pin24=PA14 -Mcu.Pin25=PC10 -Mcu.Pin26=PC11 -Mcu.Pin27=PC12 -Mcu.Pin28=PB3 -Mcu.Pin29=PB4 -Mcu.Pin3=PC2 -Mcu.Pin30=PB5 -Mcu.Pin31=PB6 -Mcu.Pin32=PB7 -Mcu.Pin33=PB8-BOOT0 -Mcu.Pin34=PB9 -Mcu.Pin35=VP_SYS_VS_Systick -Mcu.Pin36=VP_SYS_VS_DBSignals -Mcu.Pin37=VP_TIM2_VS_ClockSourceINT -Mcu.Pin4=PC3 -Mcu.Pin5=PA0 -Mcu.Pin6=PA2 -Mcu.Pin7=PA3 -Mcu.Pin8=PA5 -Mcu.Pin9=PA6 -Mcu.PinsNb=38 -Mcu.ThirdPartyNb=0 -Mcu.UserConstants= -Mcu.UserName=STM32G474RETx -MxCube.Version=6.15.0 -MxDb.Version=DB.6.0.150 -NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.FDCAN2_IT0_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true -NVIC.ForceEnableDMAVector=false -NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:false -NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 -NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:false -NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -PA0.Signal=S_TIM2_CH1 -PA11.Locked=true -PA11.Mode=CTS_RTS -PA11.Signal=USART1_CTS -PA12.Locked=true -PA12.Mode=CTS_RTS -PA12.Signal=USART1_RTS -PA13.Locked=true -PA13.Mode=Trace_Asynchronous_SW -PA13.Signal=SYS_JTMS-SWDIO -PA14.Locked=true -PA14.Mode=Trace_Asynchronous_SW -PA14.Signal=SYS_JTCK-SWCLK -PA2.GPIOParameters=GPIO_Speed -PA2.GPIO_Speed=GPIO_SPEED_FREQ_HIGH -PA2.Locked=true -PA2.Mode=Asynchronous -PA2.Signal=LPUART1_TX -PA3.GPIOParameters=GPIO_Speed -PA3.GPIO_Speed=GPIO_SPEED_FREQ_HIGH -PA3.Locked=true -PA3.Mode=Asynchronous -PA3.Signal=LPUART1_RX -PA5.GPIOParameters=GPIO_Label -PA5.GPIO_Label=BLINKY -PA5.Locked=true -PA5.Signal=GPIO_Output -PA6.GPIOParameters=GPIO_Label -PA6.GPIO_Label=IMD_SENSE -PA6.Locked=true -PA6.Signal=ADC2_IN3 -PA7.GPIOParameters=GPIO_Label -PA7.GPIO_Label=AMS_SENSE -PA7.Locked=true -PA7.Signal=ADC2_IN4 -PA8.Mode=I2C -PA8.Signal=I2C2_SDA -PB0.GPIOParameters=GPIO_Label -PB0.GPIO_Label=BRAKE_F_SIGNAL -PB0.Locked=true -PB0.Mode=IN15-Single-Ended -PB0.Signal=ADC1_IN15 -PB1.GPIOParameters=GPIO_Label -PB1.GPIO_Label=BRAKE_R_SIGNAL -PB1.Locked=true -PB1.Mode=IN12-Single-Ended -PB1.Signal=ADC1_IN12 -PB11.GPIOParameters=GPIO_Label -PB11.GPIO_Label=LED_TEST -PB11.Locked=true -PB11.Signal=GPIO_Output -PB12.GPIOParameters=GPIO_Speed,GPIO_PuPd -PB12.GPIO_PuPd=GPIO_PULLUP -PB12.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH -PB12.Locked=true -PB12.Mode=FDCAN_Activate -PB12.Signal=FDCAN2_RX -PB13.GPIOParameters=GPIO_Speed -PB13.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH -PB13.Locked=true -PB13.Mode=FDCAN_Activate -PB13.Signal=FDCAN2_TX -PB14.GPIOParameters=GPIO_Label -PB14.GPIO_Label=AUX_SIGNAL -PB14.Locked=true -PB14.Mode=IN5-Single-Ended -PB14.Signal=ADC1_IN5 -PB15.GPIOParameters=GPIO_Label -PB15.GPIO_Label=STEERING_ANGLE -PB15.Locked=true -PB15.Signal=ADC2_IN15 -PB3.Locked=true -PB3.Mode=Trace_Asynchronous_SW -PB3.Signal=SYS_JTDO-SWO -PB4.GPIOParameters=GPIO_Label -PB4.GPIO_Label=BRAKE_LIGHT -PB4.Locked=true -PB4.Signal=GPIO_Output -PB5.GPIOParameters=GPIO_Label -PB5.GPIO_Label=TSSI_G_CONTROL -PB5.Locked=true -PB5.Signal=GPIO_Output -PB6.Locked=true -PB6.Mode=Asynchronous -PB6.Signal=USART1_TX -PB7.Locked=true -PB7.Signal=UART4_CTS -PB8-BOOT0.GPIOParameters=GPIO_Label -PB8-BOOT0.GPIO_Label=AUX_CONTROL -PB8-BOOT0.Locked=true -PB8-BOOT0.Signal=GPIO_Output -PB9.GPIOParameters=GPIO_Label -PB9.GPIO_Label=SOFTWARE_OK_CONTROL -PB9.Locked=true -PB9.Signal=GPIO_Output -PC1.GPIOParameters=GPIO_Label -PC1.GPIO_Label=BSPD_SIGNAL -PC1.Locked=true -PC1.Mode=IN7-Single-Ended -PC1.Signal=ADC1_IN7 -PC10.Mode=Full_Duplex_Master -PC10.Signal=SPI3_SCK -PC11.Mode=Full_Duplex_Master -PC11.Signal=SPI3_MISO -PC12.Mode=Full_Duplex_Master -PC12.Signal=SPI3_MOSI -PC2.GPIOParameters=GPIO_Label -PC2.GPIO_Label=APPS1_SIGNAL -PC2.Locked=true -PC2.Mode=IN8-Single-Ended -PC2.Signal=ADC1_IN8 -PC3.GPIOParameters=GPIO_Label -PC3.GPIO_Label=APPS2_SIGNAL -PC3.Locked=true -PC3.Mode=IN9-Single-Ended -PC3.Signal=ADC1_IN9 -PC4.Mode=I2C -PC4.Signal=I2C2_SCL -PC5.Mode=Asynchronous -PC5.Signal=USART1_RX -PF0-OSC_IN.Locked=true -PF0-OSC_IN.Mode=HSE-External-Oscillator -PF0-OSC_IN.Signal=RCC_OSC_IN -PF1-OSC_OUT.Locked=true -PF1-OSC_OUT.Mode=HSE-External-Oscillator -PF1-OSC_OUT.Signal=RCC_OSC_OUT -PinOutPanel.RotationAngle=180 -ProjectManager.AskForMigrate=true -ProjectManager.BackupPrevious=false -ProjectManager.CompilerLinker=GCC -ProjectManager.CompilerOptimize=6 -ProjectManager.ComputerToolchain=false -ProjectManager.CoupleFile=true -ProjectManager.CustomerFirmwarePackage= -ProjectManager.DefaultFWLocation=true -ProjectManager.DeletePrevious=true -ProjectManager.DeviceId=STM32G474RETx -ProjectManager.FirmwarePackage=STM32Cube FW_G4 V1.6.1 -ProjectManager.FreePins=true -ProjectManager.HalAssertFull=false -ProjectManager.HeapSize=0x200 -ProjectManager.KeepUserCode=true -ProjectManager.LastFirmware=true -ProjectManager.LibraryCopy=0 -ProjectManager.MainLocation=Core/Src -ProjectManager.NoMain=false -ProjectManager.PreviousToolchain= -ProjectManager.ProjectBuild=false -ProjectManager.ProjectFileName=G4PERTESTING.ioc -ProjectManager.ProjectName=G4PERTESTING -ProjectManager.ProjectStructure= -ProjectManager.RegisterCallBack= -ProjectManager.StackSize=0x400 -ProjectManager.TargetToolchain=CMake -ProjectManager.ToolChainLocation= -ProjectManager.UAScriptAfterPath= -ProjectManager.UAScriptBeforePath= -ProjectManager.UnderRoot=false -ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-LL-false,2-MX_GPIO_Init-GPIO-false-LL-true,3-MX_DMA_Init-DMA-false-LL-true,4-MX_FDCAN2_Init-FDCAN2-false-HAL-true,5-MX_ADC1_Init-ADC1-false-LL-true,6-MX_LPUART1_UART_Init-LPUART1-false-LL-true,7-MX_I2C2_Init-I2C2-false-LL-true,8-MX_USART1_UART_Init-USART1-false-LL-true,9-MX_SPI3_Init-SPI3-false-LL-true,10-MX_TIM2_Init-TIM2-false-LL-true -RCC.ADC12Freq_Value=160000000 -RCC.ADC345Freq_Value=160000000 -RCC.AHBFreq_Value=160000000 -RCC.APB1Freq_Value=160000000 -RCC.APB1TimFreq_Value=160000000 -RCC.APB2Freq_Value=160000000 -RCC.APB2TimFreq_Value=160000000 -RCC.CRSFreq_Value=48000000 -RCC.CortexFreq_Value=160000000 -RCC.EXTERNAL_CLOCK_VALUE=12288000 -RCC.EnbaleCSS=true -RCC.FCLKCortexFreq_Value=160000000 -RCC.FDCANFreq_Value=160000000 -RCC.FamilyName=M -RCC.HCLKFreq_Value=160000000 -RCC.HRTIM1Freq_Value=160000000 -RCC.HSE_VALUE=16000000 -RCC.HSI48_VALUE=48000000 -RCC.HSI_VALUE=16000000 -RCC.I2C1Freq_Value=160000000 -RCC.I2C2Freq_Value=160000000 -RCC.I2C3Freq_Value=160000000 -RCC.I2C4Freq_Value=160000000 -RCC.I2SFreq_Value=160000000 -RCC.IPParameters=ADC12Freq_Value,ADC345Freq_Value,AHBFreq_Value,APB1Freq_Value,APB1TimFreq_Value,APB2Freq_Value,APB2TimFreq_Value,CRSFreq_Value,CortexFreq_Value,EXTERNAL_CLOCK_VALUE,EnbaleCSS,FCLKCortexFreq_Value,FDCANFreq_Value,FamilyName,HCLKFreq_Value,HRTIM1Freq_Value,HSE_VALUE,HSI48_VALUE,HSI_VALUE,I2C1Freq_Value,I2C2Freq_Value,I2C3Freq_Value,I2C4Freq_Value,I2SFreq_Value,LPTIM1Freq_Value,LPUART1Freq_Value,LSCOPinFreq_Value,LSE_VALUE,LSI_VALUE,MCO1PinFreq_Value,PLLN,PLLPoutputFreq_Value,PLLQoutputFreq_Value,PLLRCLKFreq_Value,PLLSourceVirtual,PWRFreq_Value,QSPIFreq_Value,RNGFreq_Value,SAI1Freq_Value,SYSCLKFreq_VALUE,SYSCLKSource,UART4Freq_Value,UART5Freq_Value,USART1Freq_Value,USART2Freq_Value,USART3Freq_Value,USBFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value -RCC.LPTIM1Freq_Value=160000000 -RCC.LPUART1Freq_Value=160000000 -RCC.LSCOPinFreq_Value=32000 -RCC.LSE_VALUE=32768 -RCC.LSI_VALUE=32000 -RCC.MCO1PinFreq_Value=16000000 -RCC.PLLN=20 -RCC.PLLPoutputFreq_Value=160000000 -RCC.PLLQoutputFreq_Value=160000000 -RCC.PLLRCLKFreq_Value=160000000 -RCC.PLLSourceVirtual=RCC_PLLSOURCE_HSE -RCC.PWRFreq_Value=160000000 -RCC.QSPIFreq_Value=160000000 -RCC.RNGFreq_Value=160000000 -RCC.SAI1Freq_Value=160000000 -RCC.SYSCLKFreq_VALUE=160000000 -RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK -RCC.UART4Freq_Value=160000000 -RCC.UART5Freq_Value=160000000 -RCC.USART1Freq_Value=160000000 -RCC.USART2Freq_Value=160000000 -RCC.USART3Freq_Value=160000000 -RCC.USBFreq_Value=160000000 -RCC.VCOInputFreq_Value=16000000 -RCC.VCOOutputFreq_Value=320000000 -SH.S_TIM2_CH1.0=TIM2_CH1,Forced Output1 CH1 -SH.S_TIM2_CH1.ConfNb=1 -SPI3.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_32 -SPI3.CalculateBaudRate=5.0 MBits/s -SPI3.Direction=SPI_DIRECTION_2LINES -SPI3.IPParameters=VirtualType,Mode,Direction,BaudRatePrescaler,CalculateBaudRate -SPI3.Mode=SPI_MODE_MASTER -SPI3.VirtualType=VM_MASTER -TIM2.Channel-Forced\ Output1\ CH1=TIM_CHANNEL_1 -TIM2.IPParameters=Channel-Forced Output1 CH1 -USART1.IPParameters=VirtualMode-Asynchronous -USART1.VirtualMode-Asynchronous=VM_ASYNC -VP_SYS_VS_DBSignals.Mode=DisableDeadBatterySignals -VP_SYS_VS_DBSignals.Signal=SYS_VS_DBSignals -VP_SYS_VS_Systick.Mode=SysTick -VP_SYS_VS_Systick.Signal=SYS_VS_Systick -VP_TIM2_VS_ClockSourceINT.Mode=Internal -VP_TIM2_VS_ClockSourceINT.Signal=TIM2_VS_ClockSourceINT -board=custom diff --git a/G4ADCTESTING/README.md b/G4ADCTESTING/README.md deleted file mode 100644 index 79c0032d8..000000000 --- a/G4ADCTESTING/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# STM32G474 Blinky -Nucleo-G474RE-C04 - -Plug in the board following ST-LINK pinout -Compile and flash G4PERTESTING.elf diff --git a/G4FANCYCANTESTING/CAN_LOOPBACK_TEST/CMakeLists.txt b/G4FANCYCANTESTING/CAN_LOOPBACK_TEST/CMakeLists.txt deleted file mode 100644 index fdf940e7b..000000000 --- a/G4FANCYCANTESTING/CAN_LOOPBACK_TEST/CMakeLists.txt +++ /dev/null @@ -1,56 +0,0 @@ -cmake_minimum_required(VERSION 3.25) - -# Setup compiler settings -set(CMAKE_C_STANDARD 11) -set(CMAKE_C_STANDARD_REQUIRED ON) -set(CMAKE_C_EXTENSIONS ON) - -# Define the build type -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Debug") -endif() - -# Enable compile command to ease indexing with e.g. clangd -set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE) - -# Enable CMake support for ASM and C languages -enable_language( - C - ASM -) - -# Core project settings -project(${CMAKE_PROJECT_NAME}) - -# what, does in fact not get the filename of somthing but rather the name of the project from the path -get_filename_component(PROJECT_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME) - -add_library(${PROJECT_NAME}_USER_CODE INTERFACE) - -target_sources( - ${PROJECT_NAME}_USER_CODE - INTERFACE - ../Core/Src/adc.c - ../Core/Src/crc.c - ../Core/Src/dma.c - ../Core/Src/gpio.c - ../Core/Src/i2c.c - main.c - ../Core/Src/spi.c - ../Core/Src/stm32g4xx_hal_msp.c - ../Core/Src/stm32g4xx_it.c - ../Core/Src/tim.c - ../Core/Src/usart.c - ../Core/Src/FancyCAN_LoopbackTest.c -) - -set_target_properties( - ${NAME} - PROPERTIES - OUTPUT_NAME - "CAN_${NAME}" -) - -target_link_libraries(${PROJECT_NAME}_USER_CODE INTERFACE GRCAN_FANCYLAYER) - -target_include_directories(${PROJECT_NAME}_USER_CODE INTERFACE ../Core/Inc) diff --git a/G4FANCYCANTESTING/CAN_LOOPBACK_TEST/main.c b/G4FANCYCANTESTING/CAN_LOOPBACK_TEST/main.c deleted file mode 100644 index 739003d67..000000000 --- a/G4FANCYCANTESTING/CAN_LOOPBACK_TEST/main.c +++ /dev/null @@ -1,305 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file : main.c - * @brief : Main program body - ****************************************************************************** - * @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 "main.h" - -#include "adc.h" -#include "can.h" // Assume this works -#include "can_tests.h" -#include "dma.h" -#include "gpio.h" -#include "i2c.h" -#include "spi.h" -#include "tim.h" -#include "usart.h" - -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ -#include "FancyCAN_LoopbackTest.h" -#include "GRCAN_FancyLayer.h" -#include "Logomatic.h" -/* USER CODE END Includes */ - -/* Private typedef -----------------------------------------------------------*/ -/* USER CODE BEGIN PTD */ - -/* USER CODE END PTD */ - -/* Private define ------------------------------------------------------------*/ -/* USER CODE BEGIN PD */ - -/* USER CODE END PD */ - -/* Private macro -------------------------------------------------------------*/ -/* USER CODE BEGIN PM */ - -/* USER CODE END PM */ - -/* Private variables ---------------------------------------------------------*/ - -/* USER CODE BEGIN PV */ -/* USER CODE END PV */ - -/* Private function prototypes -----------------------------------------------*/ -void SystemClock_Config(void); -/* USER CODE BEGIN PFP */ - -/* USER CODE END PFP */ - -/* Private user code ---------------------------------------------------------*/ -/* USER CODE BEGIN 0 */ -/* Enable ITM for SWO output */ -static void ITM_Enable(void) -{ - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOB); - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - GPIO_InitStruct.Pin = LL_GPIO_PIN_3; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_0; - LL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - DBGMCU->CR |= DBGMCU_CR_TRACE_IOEN; - - /* Enable TRC (Trace) */ - CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; - - /* Configure TPI for SWO output (set prescaler for 2MHz SWO clock) */ - TPI->SPPR = 2U; /* 2 = Manchester/async UART mode */ - TPI->ACPR = 84U; /* Prescaler: (170 MHz / (84+1) / 2) ≈ 1MHz SWO */ - - ITM->TER |= (1UL << 0); - ITM->TCR |= (ITM_TCR_ITMENA_Msk | ITM_TCR_SWOENA_Msk); -} - -LogomaticConfig logomaticConfig = {.clock_source = LOGOMATIC_PCLK1, - .bus = LOGOMATIC_BUS, - .gpio_port = LOGOMATIC_GPIOA, - .gpio_pin_rx_tx_mask = LL_GPIO_PIN_2 | LL_GPIO_PIN_3, - .baud_rate = 115200, - .data_width = LOGOMATIC_DATAWIDTH_8B, - .stop_bits = LOGOMATIC_STOPBITS_1, - .parity = LOGOMATIC_PARITY_NONE, - .transfer_direction = LOGOMATIC_DIRECTION_TX, - .hardware_flow_control = LOGOMATIC_HWCONTROL_NONE, - .prescaler = LOGOMATIC_PRESCALER_DIV1, - .tx_fifo_threshold = LOGOMATIC_FIFOTHRESHOLD_1_8, - .rx_fifo_threshold = LOGOMATIC_FIFOTHRESHOLD_1_8}; - -// static int toggleze = 0; -/* USER CODE END 0 */ - -/** - * @brief The application entry point. - * @retval int - */ -int main(void) -{ - /* USER CODE BEGIN 1 */ - - /* USER CODE END 1 */ - - /* MCU - * Configuration--------------------------------------------------------*/ - - /* Reset of all peripherals, Initializes the Flash interface and the - * Systick. */ - HAL_Init(); - /* USER CODE BEGIN Init */ - ITM_Enable(); - /* USER CODE END Init */ - - /* Configure the system clock */ - SystemClock_Config(); - - /* USER CODE BEGIN SysInit */ - - /* USER CODE END SysInit */ - - /* Initialize all configured peripherals */ - MX_GPIO_Init(); - MX_DMA_Init(); - // MX_FDCAN2_Init(); //might make own init for hfdcan for use for multiple hfdcan busses - MX_ADC1_Init(); - MX_LPUART1_UART_Init(); - MX_I2C2_Init(); - MX_USART1_UART_Init(); - MX_SPI3_Init(); - MX_TIM2_Init(); - - /* USER CODE BEGIN 2 */ - - Setup_Logomatic(&logomaticConfig); - - LOGOMATIC("Booted!\n"); - - HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5); - HAL_Delay(200); - - // LOGOMATIC("running can_basic_test:\n"); - // can_basic_test(); - - int result = FancyCAN_LoopbackTest(); - LOGOMATIC("\n"); - if (result) { - LOGOMATIC("CAN Loopback Test PASSED!\n"); - } else { - LOGOMATIC("CAN Loopback Test FAILED!\n"); - } - - /* Infinite loop */ - /* USER CODE BEGIN WHILE */ - while (1) { - /* USER CODE END WHILE */ - // LOGOMATIC("Main Loop\n"); - LL_mDelay(1000); - HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5); - - // Receive on GPIOs - // HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, toggleze ? GPIO_PIN_SET - // : GPIO_PIN_RESET); HAL_Delay(1000); msg.data[0] = toggleze ? - // 0x00 : 0x80; can_send(data_can, &msg); - - // RCC->CFGR |= RCC_CFGR_SW; - /* USER CODE BEGIN 3 */ - } -} - -/** - * @brief System Clock Configuration - * @retval None - */ - -// void SystemClock_Config(void) -// { -// LL_FLASH_SetLatency(LL_FLASH_LATENCY_4); -// while (LL_FLASH_GetLatency() != LL_FLASH_LATENCY_4) { -// } -// LL_PWR_EnableRange1BoostMode(); -// LL_RCC_HSE_Enable(); - -// /* Wait till HSE is ready */ -// while (LL_RCC_HSE_IsReady() != 1) { -// } - -// LL_RCC_HSE_EnableCSS(); -// LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSE, LL_RCC_PLLM_DIV_1, 20, -// LL_RCC_PLLR_DIV_2); -// //LL_RCC_PLL_ConfigDomain_48M(LL_RCC_PLLSOURCE_HSE, ); -// LL_RCC_PLL_EnableDomain_SYS(); -// LL_RCC_PLL_Enable(); -// /* Wait till PLL is ready */ -// while (LL_RCC_PLL_IsReady() != 1) { -// } - -// LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL); -// LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_2); -// /* Wait till System clock is ready */ -// while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL) { -// } - -// /* Insure 1us transition state at intermediate medium speed clock*/ -// for (__IO uint32_t i = (170 >> 1); i != 0; i--) -// ; - -// /* Set AHB prescaler*/ -// LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1); -// LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1); -// LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_1); -// LL_SetSystemCoreClock(160000000); - -// /* Update the time base */ -// if (HAL_InitTick(TICK_INT_PRIORITY) != HAL_OK) { -// Error_Handler(); -// } -// }*/ -void SystemClock_Config(void) -{ - LL_FLASH_SetLatency(LL_FLASH_LATENCY_4); - while (LL_FLASH_GetLatency() != LL_FLASH_LATENCY_4) {} - LL_PWR_EnableRange1BoostMode(); - LL_RCC_HSI_Enable(); - /* Wait till HSI is ready */ - while (LL_RCC_HSI_IsReady() != 1) {} - - LL_RCC_HSI_SetCalibTrimming(64); - LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSI, LL_RCC_PLLM_DIV_4, 85, LL_RCC_PLLR_DIV_2); - LL_RCC_PLL_EnableDomain_SYS(); - LL_RCC_PLL_Enable(); - /* Wait till PLL is ready */ - while (LL_RCC_PLL_IsReady() != 1) {} - - LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL); - // LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1); - /* Wait till System clock is ready */ - while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL) {} - - /* Insure 1us transition state at intermediate medium speed clock*/ - for (__IO uint32_t i = (170 >> 1); i != 0; i--) - ; - - /* Set AHB prescaler*/ - LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1); - LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1); - LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_1); - LL_SetSystemCoreClock(170000000); - - /* Update the time base */ - if (HAL_InitTick(TICK_INT_PRIORITY) != HAL_OK) { - Error_Handler(); - } -} - -/* USER CODE BEGIN 4 */ - -/* USER CODE END 4 */ - -/** - * @brief This function is executed in case of error occurrence. - * @retval None - */ -void Error_Handler(void) -{ - /* USER CODE BEGIN Error_Handler_Debug */ - /* User can add his own implementation to report the HAL error return - * state */ - __disable_irq(); - while (1) {} - /* USER CODE END Error_Handler_Debug */ -} -#ifdef USE_FULL_ASSERT -/** - * @brief Reports the name of the source file and the source line number - * where the assert_param error has occurred. - * @param file: pointer to the source file name - * @param line: assert_param error line source number - * @retval None - */ -void assert_failed(uint8_t *file, uint32_t line) -{ - /* USER CODE BEGIN 6 */ - /* User can add his own implementation to report the file name and line - number, ex: printf("Wrong parameters value: file %s on line %d\r\n", - file, line) */ - /* USER CODE END 6 */ -} -#endif /* USE_FULL_ASSERT */ diff --git a/G4FANCYCANTESTING/Core/Inc/FancyCAN_LoopbackTest.h b/G4FANCYCANTESTING/Core/Inc/FancyCAN_LoopbackTest.h deleted file mode 100644 index 9a2ba9a26..000000000 --- a/G4FANCYCANTESTING/Core/Inc/FancyCAN_LoopbackTest.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef FANCYCAN_LOOPBACKTEST_H -#define FANCYCAN_LOOPBACKTEST_H - -int FancyCAN_LoopbackTest(void); - -#endif // FANCYCAN_LOOPBACKTEST_H diff --git a/G4FANCYCANTESTING/Core/Inc/adc.h b/G4FANCYCANTESTING/Core/Inc/adc.h deleted file mode 100644 index 41154538b..000000000 --- a/G4FANCYCANTESTING/Core/Inc/adc.h +++ /dev/null @@ -1,49 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file adc.h - * @brief This file contains all the function prototypes for - * the adc.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 __ADC_H__ -#define __ADC_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" - -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* USER CODE BEGIN Private defines */ - -/* USER CODE END Private defines */ - -void MX_ADC1_Init(void); - -/* USER CODE BEGIN Prototypes */ - -/* USER CODE END Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif /* __ADC_H__ */ diff --git a/G4FANCYCANTESTING/Core/Inc/can_cfg.h b/G4FANCYCANTESTING/Core/Inc/can_cfg.h deleted file mode 100644 index 5e7e78550..000000000 --- a/G4FANCYCANTESTING/Core/Inc/can_cfg.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef CAN_CFG_H -#define CAN_CFG_H - -#define USECAN2 -#define TX_BUFFER_1_SIZE 10 - -#define TX_BUFFER_2_SIZE 10 - -#endif diff --git a/G4FANCYCANTESTING/Core/Inc/crc.h b/G4FANCYCANTESTING/Core/Inc/crc.h deleted file mode 100644 index 133957e92..000000000 --- a/G4FANCYCANTESTING/Core/Inc/crc.h +++ /dev/null @@ -1,51 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file crc.h - * @brief This file contains all the function prototypes for - * the crc.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 __CRC_H__ -#define __CRC_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" - -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -extern CRC_HandleTypeDef hcrc; - -/* USER CODE BEGIN Private defines */ - -/* USER CODE END Private defines */ - -void MX_CRC_Init(void); - -/* USER CODE BEGIN Prototypes */ - -/* USER CODE END Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif /* __CRC_H__ */ diff --git a/G4FANCYCANTESTING/Core/Inc/dma.h b/G4FANCYCANTESTING/Core/Inc/dma.h deleted file mode 100644 index ae819cab4..000000000 --- a/G4FANCYCANTESTING/Core/Inc/dma.h +++ /dev/null @@ -1,51 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file dma.h - * @brief This file contains all the function prototypes for - * the dma.c file - ****************************************************************************** - * @attention - * - * Copyright (c) 2025 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__ */ diff --git a/G4FANCYCANTESTING/Core/Inc/gpio.h b/G4FANCYCANTESTING/Core/Inc/gpio.h deleted file mode 100644 index 843d4e9e7..000000000 --- a/G4FANCYCANTESTING/Core/Inc/gpio.h +++ /dev/null @@ -1,48 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file gpio.h - * @brief This file contains all the function prototypes for - * the gpio.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 __GPIO_H__ -#define __GPIO_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" - -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* USER CODE BEGIN Private defines */ - -/* USER CODE END Private defines */ - -void MX_GPIO_Init(void); - -/* USER CODE BEGIN Prototypes */ - -/* USER CODE END Prototypes */ - -#ifdef __cplusplus -} -#endif -#endif /*__ GPIO_H__ */ diff --git a/G4FANCYCANTESTING/Core/Inc/i2c.h b/G4FANCYCANTESTING/Core/Inc/i2c.h deleted file mode 100644 index 0a0a50803..000000000 --- a/G4FANCYCANTESTING/Core/Inc/i2c.h +++ /dev/null @@ -1,49 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file i2c.h - * @brief This file contains all the function prototypes for - * the i2c.c file - ****************************************************************************** - * @attention - * - * Copyright (c) 2025 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 __I2C_H__ -#define __I2C_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" - -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* USER CODE BEGIN Private defines */ - -/* USER CODE END Private defines */ - -void MX_I2C2_Init(void); - -/* USER CODE BEGIN Prototypes */ - -/* USER CODE END Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif /* __I2C_H__ */ diff --git a/G4FANCYCANTESTING/Core/Inc/main.h b/G4FANCYCANTESTING/Core/Inc/main.h deleted file mode 100644 index 23d7ffce4..000000000 --- a/G4FANCYCANTESTING/Core/Inc/main.h +++ /dev/null @@ -1,115 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file : main.h - * @brief : Header for main.c file. - * This file contains the common defines of the application. - ****************************************************************************** - * @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 __MAIN_H -#define __MAIN_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32g4xx_hal.h" -#include "stm32g4xx_ll_adc.h" -#include "stm32g4xx_ll_bus.h" -#include "stm32g4xx_ll_cortex.h" -#include "stm32g4xx_ll_crs.h" -#include "stm32g4xx_ll_dma.h" -#include "stm32g4xx_ll_exti.h" -#include "stm32g4xx_ll_gpio.h" -#include "stm32g4xx_ll_i2c.h" -#include "stm32g4xx_ll_lpuart.h" -#include "stm32g4xx_ll_pwr.h" -#include "stm32g4xx_ll_rcc.h" -#include "stm32g4xx_ll_spi.h" -#include "stm32g4xx_ll_system.h" -#include "stm32g4xx_ll_tim.h" -#include "stm32g4xx_ll_usart.h" -#include "stm32g4xx_ll_utils.h" - -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* Exported types ------------------------------------------------------------*/ -/* USER CODE BEGIN ET */ - -/* USER CODE END ET */ - -/* Exported constants --------------------------------------------------------*/ -/* USER CODE BEGIN EC */ - -/* USER CODE END EC */ - -/* Exported macro ------------------------------------------------------------*/ -/* USER CODE BEGIN EM */ - -/* USER CODE END EM */ - -/* Exported functions prototypes ---------------------------------------------*/ -void Error_Handler(void); - -/* USER CODE BEGIN EFP */ - -/* USER CODE END EFP */ - -/* Private defines -----------------------------------------------------------*/ -#define BSPD_SIGNAL_Pin LL_GPIO_PIN_1 -#define BSPD_SIGNAL_GPIO_Port GPIOC -#define APPS1_SIGNAL_Pin LL_GPIO_PIN_2 -#define APPS1_SIGNAL_GPIO_Port GPIOC -#define APPS2_SIGNAL_Pin LL_GPIO_PIN_3 -#define APPS2_SIGNAL_GPIO_Port GPIOC -#define BLINKY_Pin LL_GPIO_PIN_5 -#define BLINKY_GPIO_Port GPIOA -#define IMD_SENSE_Pin LL_GPIO_PIN_6 -#define IMD_SENSE_GPIO_Port GPIOA -#define AMS_SENSE_Pin LL_GPIO_PIN_7 -#define AMS_SENSE_GPIO_Port GPIOA -#define BRAKE_F_SIGNAL_Pin LL_GPIO_PIN_0 -#define BRAKE_F_SIGNAL_GPIO_Port GPIOB -#define BRAKE_R_SIGNAL_Pin LL_GPIO_PIN_1 -#define BRAKE_R_SIGNAL_GPIO_Port GPIOB -#define LED_TEST_Pin LL_GPIO_PIN_11 -#define LED_TEST_GPIO_Port GPIOB -#define AUX_SIGNAL_Pin LL_GPIO_PIN_14 -#define AUX_SIGNAL_GPIO_Port GPIOB -#define STEERING_ANGLE_Pin LL_GPIO_PIN_15 -#define STEERING_ANGLE_GPIO_Port GPIOB -#define BRAKE_LIGHT_Pin LL_GPIO_PIN_4 -#define BRAKE_LIGHT_GPIO_Port GPIOB -#define TSSI_G_CONTROL_Pin LL_GPIO_PIN_5 -#define TSSI_G_CONTROL_GPIO_Port GPIOB -#define AUX_CONTROL_Pin LL_GPIO_PIN_8 -#define AUX_CONTROL_GPIO_Port GPIOB -#define SOFTWARE_OK_CONTROL_Pin LL_GPIO_PIN_9 -#define SOFTWARE_OK_CONTROL_GPIO_Port GPIOB - -/* USER CODE BEGIN Private defines */ - -/* USER CODE END Private defines */ - -#ifdef __cplusplus -} -#endif - -#endif /* __MAIN_H */ diff --git a/G4FANCYCANTESTING/Core/Inc/spi.h b/G4FANCYCANTESTING/Core/Inc/spi.h deleted file mode 100644 index 74bed003b..000000000 --- a/G4FANCYCANTESTING/Core/Inc/spi.h +++ /dev/null @@ -1,49 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file spi.h - * @brief This file contains all the function prototypes for - * the spi.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 __SPI_H__ -#define __SPI_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" - -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* USER CODE BEGIN Private defines */ - -/* USER CODE END Private defines */ - -void MX_SPI3_Init(void); - -/* USER CODE BEGIN Prototypes */ - -/* USER CODE END Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif /* __SPI_H__ */ diff --git a/G4FANCYCANTESTING/Core/Inc/stm32g4xx_hal_conf.h b/G4FANCYCANTESTING/Core/Inc/stm32g4xx_hal_conf.h deleted file mode 100644 index 3e1fcb018..000000000 --- a/G4FANCYCANTESTING/Core/Inc/stm32g4xx_hal_conf.h +++ /dev/null @@ -1,390 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file stm32g4xx_hal_conf.h - * @author MCD Application Team - * @brief HAL configuration file - ****************************************************************************** - * @attention - * - * Copyright (c) 2019 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 STM32G4xx_HAL_CONF_H -#define STM32G4xx_HAL_CONF_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Exported types ------------------------------------------------------------*/ -/* Exported constants --------------------------------------------------------*/ - -/* ########################## Module Selection ############################## */ -/** - * @brief This is the list of modules to be used in the HAL driver - */ - -#define HAL_MODULE_ENABLED - -/*#define HAL_ADC_MODULE_ENABLED */ -/*#define HAL_COMP_MODULE_ENABLED */ -/*#define HAL_CORDIC_MODULE_ENABLED */ -#define HAL_CRC_MODULE_ENABLED -/*#define HAL_CRYP_MODULE_ENABLED */ -/*#define HAL_DAC_MODULE_ENABLED */ -#define HAL_FDCAN_MODULE_ENABLED -/*#define HAL_FMAC_MODULE_ENABLED */ -/*#define HAL_HRTIM_MODULE_ENABLED */ -/*#define HAL_IRDA_MODULE_ENABLED */ -/*#define HAL_IWDG_MODULE_ENABLED */ -/*#define HAL_I2C_MODULE_ENABLED */ -/*#define HAL_I2S_MODULE_ENABLED */ -/*#define HAL_LPTIM_MODULE_ENABLED */ -/*#define HAL_NAND_MODULE_ENABLED */ -/*#define HAL_NOR_MODULE_ENABLED */ -/*#define HAL_OPAMP_MODULE_ENABLED */ -/*#define HAL_PCD_MODULE_ENABLED */ -/*#define HAL_QSPI_MODULE_ENABLED */ -/*#define HAL_RNG_MODULE_ENABLED */ -/*#define HAL_RTC_MODULE_ENABLED */ -/*#define HAL_SAI_MODULE_ENABLED */ -/*#define HAL_SMARTCARD_MODULE_ENABLED */ -/*#define HAL_SMBUS_MODULE_ENABLED */ -/*#define HAL_SPI_MODULE_ENABLED */ -/*#define HAL_SRAM_MODULE_ENABLED */ -/*#define HAL_TIM_MODULE_ENABLED */ -/*#define HAL_UART_MODULE_ENABLED */ -/*#define HAL_USART_MODULE_ENABLED */ -/*#define HAL_WWDG_MODULE_ENABLED */ -#define HAL_GPIO_MODULE_ENABLED -#define HAL_EXTI_MODULE_ENABLED -#define HAL_DMA_MODULE_ENABLED -#define HAL_RCC_MODULE_ENABLED -#define HAL_FLASH_MODULE_ENABLED -#define HAL_PWR_MODULE_ENABLED -#define HAL_CORTEX_MODULE_ENABLED - -/* ########################## Register Callbacks selection - * ############################## */ -/** - * @brief This is the list of modules where register callback can be used - */ -#define USE_HAL_ADC_REGISTER_CALLBACKS 0U -#define USE_HAL_COMP_REGISTER_CALLBACKS 0U -#define USE_HAL_CORDIC_REGISTER_CALLBACKS 0U -#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U -#define USE_HAL_DAC_REGISTER_CALLBACKS 0U -#define USE_HAL_EXTI_REGISTER_CALLBACKS 0U -#define USE_HAL_FDCAN_REGISTER_CALLBACKS 0U -#define USE_HAL_FMAC_REGISTER_CALLBACKS 0U -#define USE_HAL_HRTIM_REGISTER_CALLBACKS 0U -#define USE_HAL_I2C_REGISTER_CALLBACKS 0U -#define USE_HAL_I2S_REGISTER_CALLBACKS 0U -#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U -#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U -#define USE_HAL_NAND_REGISTER_CALLBACKS 0U -#define USE_HAL_NOR_REGISTER_CALLBACKS 0U -#define USE_HAL_OPAMP_REGISTER_CALLBACKS 0U -#define USE_HAL_PCD_REGISTER_CALLBACKS 0U -#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U -#define USE_HAL_RNG_REGISTER_CALLBACKS 0U -#define USE_HAL_RTC_REGISTER_CALLBACKS 0U -#define USE_HAL_SAI_REGISTER_CALLBACKS 0U -#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U -#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U -#define USE_HAL_SPI_REGISTER_CALLBACKS 0U -#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U -#define USE_HAL_TIM_REGISTER_CALLBACKS 0U -#define USE_HAL_UART_REGISTER_CALLBACKS 0U -#define USE_HAL_USART_REGISTER_CALLBACKS 0U -#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U - -/* ########################## Oscillator Values adaptation - * ####################*/ -/** - * @brief Adjust the value of External High Speed oscillator (HSE) used in your - * application. This value is used by the RCC HAL module to compute the system - * frequency (when HSE is used as system clock source, directly or through the - * PLL). - */ -#if !defined(HSE_VALUE) -#define HSE_VALUE (16000000UL) /*!< Value of the External oscillator in Hz */ -#endif /* HSE_VALUE */ - -#if !defined(HSE_STARTUP_TIMEOUT) -#define HSE_STARTUP_TIMEOUT (100UL) /*!< Time out for HSE start up, in ms */ -#endif /* HSE_STARTUP_TIMEOUT */ - -/** - * @brief Internal High Speed oscillator (HSI) value. - * This value is used by the RCC HAL module to compute the system - * frequency (when HSI is used as system clock source, directly or through the - * PLL). - */ -#if !defined(HSI_VALUE) -#define HSI_VALUE (16000000UL) /*!< Value of the Internal oscillator in Hz*/ -#endif /* HSI_VALUE */ - -/** - * @brief Internal High Speed oscillator (HSI48) value for USB FS and RNG. - * This internal oscillator is mainly dedicated to provide a high - * precision clock to the USB peripheral by means of a special Clock Recovery - * System (CRS) circuitry. When the CRS is not used, the HSI48 RC oscillator - * runs on it default frequency which is subject to manufacturing process - * variations. - */ -#if !defined(HSI48_VALUE) -#define HSI48_VALUE \ - (48000000UL) /*!< Value of the Internal High Speed oscillator for USB \ - FS/RNG in Hz. The real value my vary depending on \ - manufacturing process variations.*/ -#endif /* HSI48_VALUE */ - -/** - * @brief Internal Low Speed oscillator (LSI) value. - */ -#if !defined(LSI_VALUE) -/*!< Value of the Internal Low Speed oscillator in Hz -The real value may vary depending on the variations in voltage and -temperature.*/ -#define LSI_VALUE (32000UL) /*!< LSI Typical Value in Hz*/ -#endif /* LSI_VALUE */ -/** - * @brief External Low Speed oscillator (LSE) value. - * This value is used by the UART, RTC HAL module to compute the system - * frequency - */ -#if !defined(LSE_VALUE) -#define LSE_VALUE (32768UL) /*!< Value of the External Low Speed oscillator in Hz */ -#endif /* LSE_VALUE */ - -#if !defined(LSE_STARTUP_TIMEOUT) -#define LSE_STARTUP_TIMEOUT (5000UL) /*!< Time out for LSE start up, in ms */ -#endif /* LSE_STARTUP_TIMEOUT */ - -/** - * @brief External clock source for I2S and SAI peripherals - * This value is used by the I2S and SAI HAL modules to compute the I2S - * and SAI clock source frequency, this source is inserted directly through - * I2S_CKIN pad. - */ -#if !defined(EXTERNAL_CLOCK_VALUE) -#define EXTERNAL_CLOCK_VALUE (12288000UL) /*!< Value of the External oscillator in Hz*/ -#endif /* EXTERNAL_CLOCK_VALUE */ - -/* Tip: To avoid modifying this file each time you need to use different HSE, - === you can define the HSE value in your toolchain compiler preprocessor. */ - -/* ########################### System Configuration ######################### */ -/** - * @brief This is the HAL system configuration section - */ - -#define VDD_VALUE (3300UL) /*!< Value of VDD in mv */ -#define TICK_INT_PRIORITY (15UL) /*!< tick interrupt priority (lowest by default) */ -#define USE_RTOS 0U -#define PREFETCH_ENABLE 0U -#define INSTRUCTION_CACHE_ENABLE 1U -#define DATA_CACHE_ENABLE 1U - -/* ########################## Assert Selection ############################## */ -/** - * @brief Uncomment the line below to expanse the "assert_param" macro in the - * HAL drivers code - */ -/* #define USE_FULL_ASSERT 1U */ - -/* ################## SPI peripheral configuration ########################## */ - -/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver - * Activated: CRC code is present inside driver - * Deactivated: CRC code cleaned from driver - */ - -#define USE_SPI_CRC 0U - -/* Includes ------------------------------------------------------------------*/ -/** - * @brief Include module's header file - */ - -#ifdef HAL_RCC_MODULE_ENABLED -#include "stm32g4xx_hal_rcc.h" -#endif /* HAL_RCC_MODULE_ENABLED */ - -#ifdef HAL_GPIO_MODULE_ENABLED -#include "stm32g4xx_hal_gpio.h" -#endif /* HAL_GPIO_MODULE_ENABLED */ - -#ifdef HAL_DMA_MODULE_ENABLED -#include "stm32g4xx_hal_dma.h" -#endif /* HAL_DMA_MODULE_ENABLED */ - -#ifdef HAL_CORTEX_MODULE_ENABLED -#include "stm32g4xx_hal_cortex.h" -#endif /* HAL_CORTEX_MODULE_ENABLED */ - -#ifdef HAL_ADC_MODULE_ENABLED -#include "stm32g4xx_hal_adc.h" -#endif /* HAL_ADC_MODULE_ENABLED */ - -#ifdef HAL_COMP_MODULE_ENABLED -#include "stm32g4xx_hal_comp.h" -#endif /* HAL_COMP_MODULE_ENABLED */ - -#ifdef HAL_CORDIC_MODULE_ENABLED -#include "stm32g4xx_hal_cordic.h" -#endif /* HAL_CORDIC_MODULE_ENABLED */ - -#ifdef HAL_CRC_MODULE_ENABLED -#include "stm32g4xx_hal_crc.h" -#endif /* HAL_CRC_MODULE_ENABLED */ - -#ifdef HAL_CRYP_MODULE_ENABLED -#include "stm32g4xx_hal_cryp.h" -#endif /* HAL_CRYP_MODULE_ENABLED */ - -#ifdef HAL_DAC_MODULE_ENABLED -#include "stm32g4xx_hal_dac.h" -#endif /* HAL_DAC_MODULE_ENABLED */ - -#ifdef HAL_EXTI_MODULE_ENABLED -#include "stm32g4xx_hal_exti.h" -#endif /* HAL_EXTI_MODULE_ENABLED */ - -#ifdef HAL_FDCAN_MODULE_ENABLED -#include "stm32g4xx_hal_fdcan.h" -#endif /* HAL_FDCAN_MODULE_ENABLED */ - -#ifdef HAL_FLASH_MODULE_ENABLED -#include "stm32g4xx_hal_flash.h" -#endif /* HAL_FLASH_MODULE_ENABLED */ - -#ifdef HAL_FMAC_MODULE_ENABLED -#include "stm32g4xx_hal_fmac.h" -#endif /* HAL_FMAC_MODULE_ENABLED */ - -#ifdef HAL_HRTIM_MODULE_ENABLED -#include "stm32g4xx_hal_hrtim.h" -#endif /* HAL_HRTIM_MODULE_ENABLED */ - -#ifdef HAL_IRDA_MODULE_ENABLED -#include "stm32g4xx_hal_irda.h" -#endif /* HAL_IRDA_MODULE_ENABLED */ - -#ifdef HAL_IWDG_MODULE_ENABLED -#include "stm32g4xx_hal_iwdg.h" -#endif /* HAL_IWDG_MODULE_ENABLED */ - -#ifdef HAL_I2C_MODULE_ENABLED -#include "stm32g4xx_hal_i2c.h" -#endif /* HAL_I2C_MODULE_ENABLED */ - -#ifdef HAL_I2S_MODULE_ENABLED -#include "stm32g4xx_hal_i2s.h" -#endif /* HAL_I2S_MODULE_ENABLED */ - -#ifdef HAL_LPTIM_MODULE_ENABLED -#include "stm32g4xx_hal_lptim.h" -#endif /* HAL_LPTIM_MODULE_ENABLED */ - -#ifdef HAL_NAND_MODULE_ENABLED -#include "stm32g4xx_hal_nand.h" -#endif /* HAL_NAND_MODULE_ENABLED */ - -#ifdef HAL_NOR_MODULE_ENABLED -#include "stm32g4xx_hal_nor.h" -#endif /* HAL_NOR_MODULE_ENABLED */ - -#ifdef HAL_OPAMP_MODULE_ENABLED -#include "stm32g4xx_hal_opamp.h" -#endif /* HAL_OPAMP_MODULE_ENABLED */ - -#ifdef HAL_PCD_MODULE_ENABLED -#include "stm32g4xx_hal_pcd.h" -#endif /* HAL_PCD_MODULE_ENABLED */ - -#ifdef HAL_PWR_MODULE_ENABLED -#include "stm32g4xx_hal_pwr.h" -#endif /* HAL_PWR_MODULE_ENABLED */ - -#ifdef HAL_QSPI_MODULE_ENABLED -#include "stm32g4xx_hal_qspi.h" -#endif /* HAL_QSPI_MODULE_ENABLED */ - -#ifdef HAL_RNG_MODULE_ENABLED -#include "stm32g4xx_hal_rng.h" -#endif /* HAL_RNG_MODULE_ENABLED */ - -#ifdef HAL_RTC_MODULE_ENABLED -#include "stm32g4xx_hal_rtc.h" -#endif /* HAL_RTC_MODULE_ENABLED */ - -#ifdef HAL_SAI_MODULE_ENABLED -#include "stm32g4xx_hal_sai.h" -#endif /* HAL_SAI_MODULE_ENABLED */ - -#ifdef HAL_SMARTCARD_MODULE_ENABLED -#include "stm32g4xx_hal_smartcard.h" -#endif /* HAL_SMARTCARD_MODULE_ENABLED */ - -#ifdef HAL_SMBUS_MODULE_ENABLED -#include "stm32g4xx_hal_smbus.h" -#endif /* HAL_SMBUS_MODULE_ENABLED */ - -#ifdef HAL_SPI_MODULE_ENABLED -#include "stm32g4xx_hal_spi.h" -#endif /* HAL_SPI_MODULE_ENABLED */ - -#ifdef HAL_SRAM_MODULE_ENABLED -#include "stm32g4xx_hal_sram.h" -#endif /* HAL_SRAM_MODULE_ENABLED */ - -#ifdef HAL_TIM_MODULE_ENABLED -#include "stm32g4xx_hal_tim.h" -#endif /* HAL_TIM_MODULE_ENABLED */ - -#ifdef HAL_UART_MODULE_ENABLED -#include "stm32g4xx_hal_uart.h" -#endif /* HAL_UART_MODULE_ENABLED */ - -#ifdef HAL_USART_MODULE_ENABLED -#include "stm32g4xx_hal_usart.h" -#endif /* HAL_USART_MODULE_ENABLED */ - -#ifdef HAL_WWDG_MODULE_ENABLED -#include "stm32g4xx_hal_wwdg.h" -#endif /* HAL_WWDG_MODULE_ENABLED */ - -/* Exported macro ------------------------------------------------------------*/ -#ifdef USE_FULL_ASSERT -/** - * @brief The assert_param macro is used for function's parameters check. - * @param expr: If expr is false, it calls assert_failed function - * which reports the name of the source file and the source - * line number of the call that failed. - * If expr is true, it returns no value. - * @retval None - */ -#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) -/* Exported functions ------------------------------------------------------- */ -void assert_failed(uint8_t *file, uint32_t line); -#else -#define assert_param(expr) ((void)0U) -#endif /* USE_FULL_ASSERT */ - -#ifdef __cplusplus -} -#endif - -#endif /* STM32G4xx_HAL_CONF_H */ diff --git a/G4FANCYCANTESTING/Core/Inc/stm32g4xx_it.h b/G4FANCYCANTESTING/Core/Inc/stm32g4xx_it.h deleted file mode 100644 index b6c3b2f72..000000000 --- a/G4FANCYCANTESTING/Core/Inc/stm32g4xx_it.h +++ /dev/null @@ -1,67 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file stm32g4xx_it.h - * @brief This file contains the headers of the interrupt handlers. - ****************************************************************************** - * @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 __STM32G4xx_IT_H -#define __STM32G4xx_IT_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* Exported types ------------------------------------------------------------*/ -/* USER CODE BEGIN ET */ - -/* USER CODE END ET */ - -/* Exported constants --------------------------------------------------------*/ -/* USER CODE BEGIN EC */ - -/* USER CODE END EC */ - -/* Exported macro ------------------------------------------------------------*/ -/* USER CODE BEGIN EM */ - -/* USER CODE END EM */ - -/* Exported functions prototypes ---------------------------------------------*/ -void NMI_Handler(void); -void HardFault_Handler(void); -void MemManage_Handler(void); -void BusFault_Handler(void); -void UsageFault_Handler(void); -void SVC_Handler(void); -void DebugMon_Handler(void); -void PendSV_Handler(void); -void SysTick_Handler(void); -void FDCAN2_IT0_IRQHandler(void); -/* USER CODE BEGIN EFP */ - -/* USER CODE END EFP */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32G4xx_IT_H */ diff --git a/G4FANCYCANTESTING/Core/Inc/tim.h b/G4FANCYCANTESTING/Core/Inc/tim.h deleted file mode 100644 index c19e6cc71..000000000 --- a/G4FANCYCANTESTING/Core/Inc/tim.h +++ /dev/null @@ -1,49 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file tim.h - * @brief This file contains all the function prototypes for - * the tim.c file - ****************************************************************************** - * @attention - * - * Copyright (c) 2025 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 __TIM_H__ -#define __TIM_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" - -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* USER CODE BEGIN Private defines */ - -/* USER CODE END Private defines */ - -void MX_TIM2_Init(void); - -/* USER CODE BEGIN Prototypes */ - -/* USER CODE END Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif /* __TIM_H__ */ diff --git a/G4FANCYCANTESTING/Core/Inc/usart.h b/G4FANCYCANTESTING/Core/Inc/usart.h deleted file mode 100644 index daefd73e6..000000000 --- a/G4FANCYCANTESTING/Core/Inc/usart.h +++ /dev/null @@ -1,50 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file usart.h - * @brief This file contains all the function prototypes for - * the usart.c file - ****************************************************************************** - * @attention - * - * Copyright (c) 2025 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 __USART_H__ -#define __USART_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" - -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* USER CODE BEGIN Private defines */ - -/* USER CODE END Private defines */ - -void MX_LPUART1_UART_Init(void); -void MX_USART1_UART_Init(void); - -/* USER CODE BEGIN Prototypes */ - -/* USER CODE END Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif /* __USART_H__ */ diff --git a/G4FANCYCANTESTING/Core/Src/FancyCAN_LoopbackTest.c b/G4FANCYCANTESTING/Core/Src/FancyCAN_LoopbackTest.c deleted file mode 100644 index 07f9ca72a..000000000 --- a/G4FANCYCANTESTING/Core/Src/FancyCAN_LoopbackTest.c +++ /dev/null @@ -1,419 +0,0 @@ -#include -#include -#include - -#include "GRCAN_FancyLayer.h" -#include "Logomatic.h" -#include "stdlib.h" - -static volatile uint32_t rx_received = 0; -static volatile bool data_valid = false; -static uint8_t expected_data[TX_BUFFER_2_SIZE]; -static volatile uint32_t expected_size = 0; -static volatile uint32_t expected_id = 0; -static volatile bool id_valid = false; - -static void can_test_rx_callback(uint32_t id, void *data, uint32_t size) -{ - rx_received++; - if (size > sizeof(expected_data)) { - data_valid = false; - return; - } - data_valid = (size == expected_size) && (memcmp(data, expected_data, size) == 0); - id_valid = (id == expected_id); - - LOGOMATIC("\nCallback triggered: ID=%" PRIu32 ", Size=%lu, Data[0]=0x%x\n", id, (unsigned long)size, *(uint8_t *)data); -} - -// TODO - allow user to send data without needing to construct a header for the buffer -// TODO: G4 tests are dependent on the System clock configuration?? - -int GRCAN_Validate_InitBus(GRCAN_BUS_ID bus, GRCAN_OperatingMode mode, FDCAN_GlobalTypeDef *fdcan_instance) -{ - GRCAN_BusConfig bus_config; - GRCAN_SetDefaultBusConfig(&bus_config, bus); - bus_config.operating_mode = mode; // GRCAN_OPMODE_INTERNAL_LOOPBACK is only one tested so far - bus_config.fdcan_instance = fdcan_instance; - bus_config.rx_callback = can_test_rx_callback; // test loopback - - LOGOMATIC("Testing GRCAN_InitBus...\n"); - bool result = GRCAN_InitBus(&bus_config); - - if (result == true) { - LOGOMATIC("GRCAN_InitBus PASSED.\n"); - return 1; - } else { - LOGOMATIC("GRCAN_InitBus FAILED.\n"); - return 0; - } -} - -// GRCAN_ALL = 0xFF, -// GRCAN_ACU = 0x03, -// GRCAN_ECU = 0x02, -// GRCAN_CCU = 0x02, -// GRCAN_Charger = 0x00, -// GRCAN_Charging_SDC = 0x0C, -// GRCAN_DGPS = 0x30, -// GRCAN_Dash_Panel = 0x05, -// GRCAN_Debugger = 0x01, -// GRCAN_Fan_Ctrl_1 = 0x0D, -// GRCAN_Fan_Ctrl_2 = 0x0E, -// GRCAN_Fan_Ctrl_3 = 0x0F, -// GRCAN_GR_Inv = 0x08, -// GRCAN_TCM = 0x04, - -GRCAN_NODE_ID get_nodeID(GRCAN_BUS_ID bus) -{ - switch (bus) { - case GRCAN_BUS_PRIMARY: - return GRCAN_ACU; - case GRCAN_BUS_DATA: - return GRCAN_ECU; - case GRCAN_BUS_TESTING: - return GRCAN_Debugger; - case GRCAN_BUS_CHARGER: - return GRCAN_Charger; - default: - return GRCAN_ALL; // All causes error - } -} - -// typedef enum { -// GRCAN_DEBUG_2_0 = 0x000, -// GRCAN_DEBUG_FD = 0x001, -// GRCAN_PING = 0x002, -// GRCAN_ECU_STATUS_1 = 0x003, -// GRCAN_ECU_STATUS_2 = 0x004, -// GRCAN_ECU_STATUS_3 = 0x005, -// GRCAN_ECU_CONFIG = 0x006, -// GRCAN_ACU_STATUS_1 = 0x007, -// GRCAN_ACU_STATUS_2 = 0x008, -// GRCAN_ACU_STATUS_3 = 0x009, -// GRCAN_ACU_PRECHARGE = 0x00A, -// GRCAN_ACU_CONFIG_CHARGE_PARAMETERS = 0x00B, -// GRCAN_ACU_CONFIG_OPERATIONAL_PARAMETERS = 0x00C, -// GRCAN_ACU_CELL_DATA_1 = 0x00D, -// GRCAN_ACU_CELL_DATA_2 = 0x00E, -// GRCAN_ACU_CELL_DATA_3 = 0x00F, -// GRCAN_ACU_CELL_DATA_4 = 0x010, -// GRCAN_ACU_CELL_DATA_5 = 0x011, -// GRCAN_INV_STATUS_1 = 0x013, -// GRCAN_INV_STATUS_2 = 0x014, -// GRCAN_INV_STATUS_3 = 0x015, -// GRCAN_INV_CONFIG = 0x016, -// GRCAN_INV_CMD = 0x017, -// GRCAN_FAN_STATUS = 0x018, -// GRCAN_FAN_COMMAND = 0x019, -// GRCAN_DASH_STATUS = 0x01A, -// GRCAN_DASH_CONFIG = 0x01B, -// GRCAN_TCM_STATUS = 0x029, -// GRCAN_TCM_RESOURCE_UTILIZATION = 0x02A, -// GRCAN_DASH_WARNING_FLAGS = 0x02B, -// GRCAN_ECU_ANALOG_DATA = 0x02E, -// GRCAN_GPS_LAT = 0x031, -// GRCAN_GPS_LON = 0x032, -// GRCAN_GPS_ALT = 0x033, -// GRCAN_GPS_PX = 0x034, -// GRCAN_GPS_QY = 0x035, -// GRCAN_GPS_RZ = 0x036, -// GRCAN_UVW_DGPS = 0x030, -// GRCAN_ECU_PERFORMANCE = 0x123, -// } GRCAN_MSG_ID; - -GRCAN_MSG_ID get_messageID(GRCAN_BUS_ID bus) -{ - switch (bus) { - case GRCAN_BUS_PRIMARY: - return GRCAN_ACU_STATUS_1; - case GRCAN_BUS_DATA: - return GRCAN_ECU_STATUS_1; - case GRCAN_BUS_TESTING: - return GRCAN_DEBUG_2_0; - case GRCAN_BUS_CHARGER: - return GRCAN_ACU_CONFIG_CHG_PARAMS; - default: - return (GRCAN_MSG_ID)0xFF; // Invalid message ID - } -} - -int GRCAN_SendReceive(GRCAN_BUS_ID bus, GRCAN_NODE_ID nodeID, GRCAN_NODE_ID dest_nodeID, GRCAN_MSG_ID messageID, void *data, uint32_t size) -{ - if (data == NULL) { - data = "Hello"; - size = sizeof("Hello"); - } - - if (size > sizeof(expected_data)) { - LOGOMATIC("Data size exceeds expected_data buffer size. Test cannot proceed.\n"); - return 0; - } - - // typedef struct { - // GRCAN_NODE_ID srcID; - // GRCAN_NODE_ID destNode; - // GRCAN_MSG_ID messageID; - // } GRCAN_Fancy_ID; - - expected_size = size; - GRCAN_Fancy_ID GRCAN_Fancy_ID; - GRCAN_Fancy_ID.srcID = nodeID; - GRCAN_Fancy_ID.destNode = dest_nodeID; - GRCAN_Fancy_ID.messageID = messageID; - expected_id = GRCAN_Fancy_EncodeID(&GRCAN_Fancy_ID); - - rx_received = 0; - data_valid = false; - id_valid = false; - - GRCAN_SetLocalNodeID(nodeID); - - memcpy(expected_data, data, size); - bool send_result = GRCAN_Fancy_Send(bus, dest_nodeID, messageID, data, size); - - if (!send_result) { - LOGOMATIC("GRCAN_Fancy_Send failed to send message on bus %d\n", bus); - return 0; - } - - HAL_Delay(1); - - if (rx_received > 0 && data_valid && id_valid) { - LOGOMATIC("GRCAN_Fancy_Send PASSED. Callback verified and data is valid.\n"); - return 1; - } else { - LOGOMATIC("GRCAN_Fancy_Send FAILED. Callback not triggered or data is invalid.\n"); - return 0; - } -} - -int GRCAN_ErrorHandling() -{ - GRCAN_BusConfig invalid_config = {0}; - - LOGOMATIC("\nTesting GRCAN_InitBus with invalid config...\n"); - bool result = GRCAN_InitBus(&invalid_config); - if (result == false) { - LOGOMATIC("GRCAN_InitBus error handling PASSED.\n"); - return 1; - } else { - LOGOMATIC("GRCAN_InitBus error handling FAILED.\n"); - return 0; - } -} - -void get_test_payload(int idx, void **data, uint32_t *size) -{ - static uint8_t msg1[] = "Hello"; - static uint8_t msg2[] = "World"; - static uint8_t msg3[] = {12}; - static uint8_t msg4[] = {23}; - static uint8_t msg5[] = {0x00, 0x00, 0x00, 0x00}; - static uint8_t msg6[] = {0xFF, 0xFF, 0xFF, 0xFF}; - static uint8_t msg7[] = {0xAA, 0x55, 0xAA, 0x55}; - static uint8_t msg8[] = {0, 1, 2, 3, 4, 5, 6, 7}; - - switch (idx) { - case 0: - *data = msg1; - *size = sizeof(msg1); - break; - case 1: - *data = msg2; - *size = sizeof(msg2); - break; - case 2: - *data = msg3; - *size = sizeof(msg3); - break; - case 3: - *data = msg4; - *size = sizeof(msg4); - break; - case 4: - *data = msg5; - *size = sizeof(msg5); - break; - case 5: - *data = msg6; - *size = sizeof(msg6); - break; - case 6: - *data = msg7; - *size = sizeof(msg7); - break; - case 7: - *data = msg8; - *size = sizeof(msg8); - break; - default: - *data = NULL; - *size = 0; - break; - } -} - -int GRCAN_BurstSendTest(GRCAN_BUS_ID bus, GRCAN_NODE_ID nodeID, GRCAN_NODE_ID dest_nodeID, GRCAN_MSG_ID messageID, uint32_t count) -{ - uint8_t burst_msg[] = {0x10, 0x20, 0x30, 0x40}; - - LOGOMATIC("Starting burst send test on bus %d with %lu messages...\n", bus, (unsigned long)count); - - for (uint32_t i = 0; i < count; i++) { - if (!GRCAN_SendReceive(bus, nodeID, dest_nodeID, messageID, burst_msg, sizeof(burst_msg))) { - LOGOMATIC("Burst send test FAILED on iteration %lu.\n", (unsigned long)i); - return 0; - } - } - - LOGOMATIC("Burst send test PASSED on bus %d.\n", bus); - return 1; -} - -int GRCAN_InitDeactivateStressTest(GRCAN_BUS_ID bus, GRCAN_NODE_ID nodeID, GRCAN_NODE_ID dest_nodeID, GRCAN_MSG_ID messageID, FDCAN_GlobalTypeDef *fdcan_instance, uint32_t iterations) -{ - uint8_t stress_msg[] = "Stress"; - - LOGOMATIC("Starting init/deactivate stress test on bus %d for %lu iterations...\n", bus, (unsigned long)iterations); - - for (uint32_t i = 0; i < iterations; i++) { - if (!GRCAN_Validate_InitBus(bus, GRCAN_OPMODE_INTERNAL_LOOPBACK, fdcan_instance)) { - LOGOMATIC("Stress test FAILED during init on iteration %lu.\n", (unsigned long)i); - return 0; - } - - if (!GRCAN_SendReceive(bus, nodeID, dest_nodeID, messageID, stress_msg, sizeof(stress_msg))) { - LOGOMATIC("Stress test FAILED during send/receive on iteration %lu.\n", (unsigned long)i); - GRCAN_DeactivateBus(bus); - return 0; - } - - if (!GRCAN_DeactivateBus(bus)) { - LOGOMATIC("Stress test FAILED during deactivate on iteration %lu.\n", (unsigned long)i); - return 0; - } - } - - LOGOMATIC("Init/deactivate stress test PASSED on bus %d.\n", bus); - return 1; -} - -int FancyCAN_LoopbackTest(void) -{ - GRCAN_BUS_ID bus; - - for (bus = GRCAN_BUS_TESTING; bus <= GRCAN_BUS_CHARGER; bus++) { - LOGOMATIC("\n--- Testing bus %d ---\n", bus); - int res1 = GRCAN_Validate_InitBus(bus, GRCAN_OPMODE_INTERNAL_LOOPBACK, FDCAN2); - // GRCAN_OPMODE_EXTERNAL_LOOPBACK needs to be tested, can change FDCAN: make sure to #define USECANx - GRCAN_NODE_ID nodeID = get_nodeID(bus); - GRCAN_MSG_ID messageID = get_messageID(bus); - GRCAN_NODE_ID dest_nodeID = nodeID; // Loopback to self for internal - int res2 = 1; - for (int i = 0; i < 8; i++) { - void *data; - uint32_t size; - get_test_payload(i, &data, &size); - - LOGOMATIC("\nTesting GRCAN_SendReceive on bus %d...\n", bus); - res2 = GRCAN_SendReceive(bus, nodeID, dest_nodeID, messageID, data, size); // - if (res2 == 0) { - uint8_t data_value = *(uint8_t *)data; - switch (bus) { - case GRCAN_BUS_PRIMARY: - LOGOMATIC("Testing Bus:PRIMARY Loopback Test FAILED for message with first byte: %d.\n", data_value); - break; - case GRCAN_BUS_DATA: - LOGOMATIC("Testing Bus:DATA Loopback Test FAILED for message with first byte: %d.\n", data_value); - break; - case GRCAN_BUS_CHARGER: - LOGOMATIC("Testing Bus:CHARGER Loopback Test FAILED for message with first byte: %d.\n", data_value); - break; - case GRCAN_BUS_TESTING: - LOGOMATIC("Testing Bus:TESTING Loopback Test FAILED for message with first byte: %d.\n", data_value); - break; - default: - LOGOMATIC("Testing Bus:UNKNOWN Loopback Test FAILED for message with first byte: %d.\n", data_value); - break; - } - break; - } - } - - bool res4 = GRCAN_DeactivateBus(bus); - - if (!res1 || !res2) { - switch (bus) { - case GRCAN_BUS_PRIMARY: - LOGOMATIC("Testing Bus:PRIMARY Loopback Test FAILED during initialization or send/receive test.\n"); - break; - case GRCAN_BUS_DATA: - LOGOMATIC("Testing Bus:DATA Loopback Test FAILED during initialization or send/receive test.\n"); - break; - case GRCAN_BUS_TESTING: - LOGOMATIC("Testing Bus:TESTING Loopback Test FAILED during initialization or send/receive test.\n"); - break; - case GRCAN_BUS_CHARGER: - LOGOMATIC("Testing Bus:CHARGER Loopback Test FAILED during initialization or send/receive test.\n"); - break; - default: - LOGOMATIC("Testing Bus:UNKNOWN Loopback Test FAILED during initialization or send/receive test.\n"); - break; - } - } - if (!res4) { - switch (bus) { - case GRCAN_BUS_PRIMARY: - LOGOMATIC("Testing Bus:PRIMARY Loopback Test FAILED during bus deactivation.\n"); - break; - case GRCAN_BUS_DATA: - LOGOMATIC("Testing Bus:DATA Loopback Test FAILED during bus deactivation.\n"); - break; - case GRCAN_BUS_TESTING: - LOGOMATIC("Testing Bus:TESTING Loopback Test FAILED during bus deactivation.\n"); - break; - case GRCAN_BUS_CHARGER: - LOGOMATIC("Testing Bus:CHARGER Loopback Test FAILED during bus deactivation.\n"); - break; - default: - LOGOMATIC("Testing Bus:UNKNOWN Loopback Test FAILED during bus deactivation.\n"); - break; - } - } - } - - if (bus < 4) { - LOGOMATIC("\nLoopback Test FAILED. Not all buses were tested.\n"); - return 0; - } - - // The next tests takes a while, completely fine to remove - for (bus = GRCAN_BUS_TESTING; bus <= GRCAN_BUS_CHARGER; bus++) { - LOGOMATIC("\n--- Testing burst send on bus %d ---\n", bus); - GRCAN_Validate_InitBus(bus, GRCAN_OPMODE_INTERNAL_LOOPBACK, FDCAN2); - int burst_result = GRCAN_BurstSendTest(bus, get_nodeID(bus), get_nodeID(bus), get_messageID(bus), 100); - if (!burst_result) { - LOGOMATIC("\nLoopback Test FAILED during burst send test on bus %d.\n", bus); - return 0; - } - GRCAN_DeactivateBus(bus); - } - - for (bus = GRCAN_BUS_TESTING; bus <= GRCAN_BUS_CHARGER; bus++) { - LOGOMATIC("\n--- Testing init/deactivate stress test on bus %d ---\n", bus); - int stress_result = GRCAN_InitDeactivateStressTest(bus, get_nodeID(bus), get_nodeID(bus), get_messageID(bus), FDCAN2, 50); - if (!stress_result) { - LOGOMATIC("\nLoopback Test FAILED during init/deactivate stress test on bus %d.\n", bus); - return 0; - } - } - - int res3 = GRCAN_ErrorHandling(); - if (!res3) { - LOGOMATIC("\nLoopback Test FAILED during error handling test.\n"); - return 0; - } - - return 1; -} diff --git a/G4FANCYCANTESTING/Core/Src/adc.c b/G4FANCYCANTESTING/Core/Src/adc.c deleted file mode 100644 index f3dbff8ed..000000000 --- a/G4FANCYCANTESTING/Core/Src/adc.c +++ /dev/null @@ -1,186 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file adc.c - * @brief This file provides code for the configuration - * of the ADC 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 "adc.h" - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/* ADC1 init function */ -void MX_ADC1_Init(void) -{ - - /* USER CODE BEGIN ADC1_Init 0 */ - - /* USER CODE END ADC1_Init 0 */ - - LL_ADC_InitTypeDef ADC_InitStruct = {0}; - LL_ADC_REG_InitTypeDef ADC_REG_InitStruct = {0}; - LL_ADC_CommonInitTypeDef ADC_CommonInitStruct = {0}; - - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - - LL_RCC_SetADCClockSource(LL_RCC_ADC12_CLKSOURCE_SYSCLK); - - /* Peripheral clock enable */ - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_ADC12); - - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOB); - /**ADC1 GPIO Configuration - PC1 ------> ADC1_IN7 - PC2 ------> ADC1_IN8 - PC3 ------> ADC1_IN9 - PB0 ------> ADC1_IN15 - PB1 ------> ADC1_IN12 - PB14 ------> ADC1_IN5 - */ - GPIO_InitStruct.Pin = BSPD_SIGNAL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(BSPD_SIGNAL_GPIO_Port, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = APPS1_SIGNAL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(APPS1_SIGNAL_GPIO_Port, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = APPS2_SIGNAL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(APPS2_SIGNAL_GPIO_Port, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = BRAKE_F_SIGNAL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(BRAKE_F_SIGNAL_GPIO_Port, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = BRAKE_R_SIGNAL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(BRAKE_R_SIGNAL_GPIO_Port, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = AUX_SIGNAL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(AUX_SIGNAL_GPIO_Port, &GPIO_InitStruct); - - /* ADC1 DMA Init */ - - /* ADC1 Init */ - LL_DMA_SetPeriphRequest(DMA1, LL_DMA_CHANNEL_1, LL_DMAMUX_REQ_ADC1); - - LL_DMA_SetDataTransferDirection(DMA1, LL_DMA_CHANNEL_1, LL_DMA_DIRECTION_PERIPH_TO_MEMORY); - - LL_DMA_SetChannelPriorityLevel(DMA1, LL_DMA_CHANNEL_1, LL_DMA_PRIORITY_LOW); - - LL_DMA_SetMode(DMA1, LL_DMA_CHANNEL_1, LL_DMA_MODE_CIRCULAR); - - LL_DMA_SetPeriphIncMode(DMA1, LL_DMA_CHANNEL_1, LL_DMA_PERIPH_NOINCREMENT); - - LL_DMA_SetMemoryIncMode(DMA1, LL_DMA_CHANNEL_1, LL_DMA_MEMORY_INCREMENT); - - LL_DMA_SetPeriphSize(DMA1, LL_DMA_CHANNEL_1, LL_DMA_PDATAALIGN_HALFWORD); - - LL_DMA_SetMemorySize(DMA1, LL_DMA_CHANNEL_1, LL_DMA_MDATAALIGN_HALFWORD); - - /* USER CODE BEGIN ADC1_Init 1 */ - - /* USER CODE END ADC1_Init 1 */ - - /** Common config - */ - ADC_InitStruct.Resolution = LL_ADC_RESOLUTION_12B; - ADC_InitStruct.DataAlignment = LL_ADC_DATA_ALIGN_RIGHT; - ADC_InitStruct.LowPowerMode = LL_ADC_LP_MODE_NONE; - LL_ADC_Init(ADC1, &ADC_InitStruct); - ADC_REG_InitStruct.TriggerSource = LL_ADC_REG_TRIG_SOFTWARE; - ADC_REG_InitStruct.SequencerLength = LL_ADC_REG_SEQ_SCAN_ENABLE_6RANKS; - ADC_REG_InitStruct.SequencerDiscont = LL_ADC_REG_SEQ_DISCONT_DISABLE; - ADC_REG_InitStruct.ContinuousMode = LL_ADC_REG_CONV_CONTINUOUS; - ADC_REG_InitStruct.DMATransfer = LL_ADC_REG_DMA_TRANSFER_UNLIMITED; - ADC_REG_InitStruct.Overrun = LL_ADC_REG_OVR_DATA_PRESERVED; - LL_ADC_REG_Init(ADC1, &ADC_REG_InitStruct); - LL_ADC_SetGainCompensation(ADC1, 0); - LL_ADC_SetOverSamplingScope(ADC1, LL_ADC_OVS_DISABLE); - ADC_CommonInitStruct.CommonClock = LL_ADC_CLOCK_ASYNC_DIV256; - ADC_CommonInitStruct.Multimode = LL_ADC_MULTI_INDEPENDENT; - LL_ADC_CommonInit(__LL_ADC_COMMON_INSTANCE(ADC1), &ADC_CommonInitStruct); - - /* Disable ADC deep power down (enabled by default after reset state) */ - LL_ADC_DisableDeepPowerDown(ADC1); - /* Enable ADC internal voltage regulator */ - LL_ADC_EnableInternalRegulator(ADC1); - /* Delay for ADC internal voltage regulator stabilization. */ - /* Compute number of CPU cycles to wait for, from delay in us. */ - /* Note: Variable divided by 2 to compensate partially */ - /* CPU processing cycles (depends on compilation optimization). */ - /* Note: If system core clock frequency is below 200kHz, wait time */ - /* is only a few CPU processing cycles. */ - uint32_t wait_loop_index; - wait_loop_index = ((LL_ADC_DELAY_INTERNAL_REGUL_STAB_US * (SystemCoreClock / (100000 * 2))) / 10); - while (wait_loop_index != 0) { - wait_loop_index--; - } - - /** Configure Regular Channel - */ - LL_ADC_REG_SetSequencerRanks(ADC1, LL_ADC_REG_RANK_1, LL_ADC_CHANNEL_5); - LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_5, LL_ADC_SAMPLINGTIME_92CYCLES_5); - LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_5, LL_ADC_SINGLE_ENDED); - - /** Configure Regular Channel - */ - LL_ADC_REG_SetSequencerRanks(ADC1, LL_ADC_REG_RANK_2, LL_ADC_CHANNEL_7); - LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_7, LL_ADC_SAMPLINGTIME_92CYCLES_5); - LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_7, LL_ADC_SINGLE_ENDED); - - /** Configure Regular Channel - */ - LL_ADC_REG_SetSequencerRanks(ADC1, LL_ADC_REG_RANK_3, LL_ADC_CHANNEL_8); - LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_8, LL_ADC_SAMPLINGTIME_92CYCLES_5); - LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_8, LL_ADC_SINGLE_ENDED); - - /** Configure Regular Channel - */ - LL_ADC_REG_SetSequencerRanks(ADC1, LL_ADC_REG_RANK_4, LL_ADC_CHANNEL_9); - LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_9, LL_ADC_SAMPLINGTIME_92CYCLES_5); - LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_9, LL_ADC_SINGLE_ENDED); - - /** Configure Regular Channel - */ - LL_ADC_REG_SetSequencerRanks(ADC1, LL_ADC_REG_RANK_5, LL_ADC_CHANNEL_12); - LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_12, LL_ADC_SAMPLINGTIME_92CYCLES_5); - LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_12, LL_ADC_SINGLE_ENDED); - - /** Configure Regular Channel - */ - LL_ADC_REG_SetSequencerRanks(ADC1, LL_ADC_REG_RANK_6, LL_ADC_CHANNEL_15); - LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_15, LL_ADC_SAMPLINGTIME_92CYCLES_5); - LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_15, LL_ADC_SINGLE_ENDED); - /* USER CODE BEGIN ADC1_Init 2 */ - - /* USER CODE END ADC1_Init 2 */ -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ diff --git a/G4FANCYCANTESTING/Core/Src/crc.c b/G4FANCYCANTESTING/Core/Src/crc.c deleted file mode 100644 index 213510a5d..000000000 --- a/G4FANCYCANTESTING/Core/Src/crc.c +++ /dev/null @@ -1,86 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file crc.c - * @brief This file provides code for the configuration - * of the CRC 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 "crc.h" - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -CRC_HandleTypeDef hcrc; - -/* CRC init function */ -void MX_CRC_Init(void) -{ - - /* USER CODE BEGIN CRC_Init 0 */ - - /* USER CODE END CRC_Init 0 */ - - /* USER CODE BEGIN CRC_Init 1 */ - - /* USER CODE END CRC_Init 1 */ - hcrc.Instance = CRC; - hcrc.Init.DefaultPolynomialUse = DEFAULT_POLYNOMIAL_ENABLE; - hcrc.Init.DefaultInitValueUse = DEFAULT_INIT_VALUE_ENABLE; - hcrc.Init.InputDataInversionMode = CRC_INPUTDATA_INVERSION_NONE; - hcrc.Init.OutputDataInversionMode = CRC_OUTPUTDATA_INVERSION_DISABLE; - hcrc.InputDataFormat = CRC_INPUTDATA_FORMAT_BYTES; - if (HAL_CRC_Init(&hcrc) != HAL_OK) { - Error_Handler(); - } - /* USER CODE BEGIN CRC_Init 2 */ - - /* USER CODE END CRC_Init 2 */ -} - -void HAL_CRC_MspInit(CRC_HandleTypeDef *crcHandle) -{ - - if (crcHandle->Instance == CRC) { - /* USER CODE BEGIN CRC_MspInit 0 */ - - /* USER CODE END CRC_MspInit 0 */ - /* CRC clock enable */ - __HAL_RCC_CRC_CLK_ENABLE(); - /* USER CODE BEGIN CRC_MspInit 1 */ - - /* USER CODE END CRC_MspInit 1 */ - } -} - -void HAL_CRC_MspDeInit(CRC_HandleTypeDef *crcHandle) -{ - - if (crcHandle->Instance == CRC) { - /* USER CODE BEGIN CRC_MspDeInit 0 */ - - /* USER CODE END CRC_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_CRC_CLK_DISABLE(); - /* USER CODE BEGIN CRC_MspDeInit 1 */ - - /* USER CODE END CRC_MspDeInit 1 */ - } -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ diff --git a/G4FANCYCANTESTING/Core/Src/dma.c b/G4FANCYCANTESTING/Core/Src/dma.c deleted file mode 100644 index 491e3889d..000000000 --- a/G4FANCYCANTESTING/Core/Src/dma.c +++ /dev/null @@ -1,50 +0,0 @@ -/* 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) 2025 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) -{ - - /* Init with LL driver */ - /* DMA controller clock enable */ - LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_DMAMUX1); - LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_DMA1); -} - -/* USER CODE BEGIN 2 */ - -/* USER CODE END 2 */ diff --git a/G4FANCYCANTESTING/Core/Src/gpio.c b/G4FANCYCANTESTING/Core/Src/gpio.c deleted file mode 100644 index d36e6eca6..000000000 --- a/G4FANCYCANTESTING/Core/Src/gpio.c +++ /dev/null @@ -1,260 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file gpio.c - * @brief This file provides code for the configuration - * of all used GPIO pins. - ****************************************************************************** - * @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 "gpio.h" - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/*----------------------------------------------------------------------------*/ -/* Configure GPIO */ -/*----------------------------------------------------------------------------*/ -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ - -/** Configure pins as - * Analog - * Input - * Output - * EVENT_OUT - * EXTI - * Free pins are configured automatically as Analog (this feature is - enabled through - * the Code Generation settings) - PA6 ------> ADC2_IN3 - PA7 ------> ADC2_IN4 - PB15 ------> ADC2_IN15 - PB7 ------> UART4_CTS -*/ -void MX_GPIO_Init(void) -{ - - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - - /* GPIO Ports Clock Enable */ - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOF); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOG); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOB); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOD); - - /**/ - LL_GPIO_ResetOutputPin(BLINKY_GPIO_Port, BLINKY_Pin); - - /**/ - LL_GPIO_ResetOutputPin(LED_TEST_GPIO_Port, LED_TEST_Pin); - - /**/ - LL_GPIO_ResetOutputPin(BRAKE_LIGHT_GPIO_Port, BRAKE_LIGHT_Pin); - - /**/ - LL_GPIO_ResetOutputPin(TSSI_G_CONTROL_GPIO_Port, TSSI_G_CONTROL_Pin); - - /**/ - LL_GPIO_ResetOutputPin(AUX_CONTROL_GPIO_Port, AUX_CONTROL_Pin); - - /**/ - LL_GPIO_ResetOutputPin(SOFTWARE_OK_CONTROL_GPIO_Port, SOFTWARE_OK_CONTROL_Pin); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_13; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_14; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_15; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_10; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOG, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_0; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_1; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_4; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = BLINKY_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(BLINKY_GPIO_Port, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = IMD_SENSE_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(IMD_SENSE_GPIO_Port, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = AMS_SENSE_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(AMS_SENSE_GPIO_Port, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_2; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_10; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LED_TEST_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(LED_TEST_GPIO_Port, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = STEERING_ANGLE_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(STEERING_ANGLE_GPIO_Port, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_6; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_7; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_8; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_9; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_9; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_10; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_15; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_2; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOD, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = BRAKE_LIGHT_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(BRAKE_LIGHT_GPIO_Port, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = TSSI_G_CONTROL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(TSSI_G_CONTROL_GPIO_Port, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_7; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_14; - LL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = AUX_CONTROL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(AUX_CONTROL_GPIO_Port, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = SOFTWARE_OK_CONTROL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(SOFTWARE_OK_CONTROL_GPIO_Port, &GPIO_InitStruct); -} - -/* USER CODE BEGIN 2 */ - -/* USER CODE END 2 */ diff --git a/G4FANCYCANTESTING/Core/Src/i2c.c b/G4FANCYCANTESTING/Core/Src/i2c.c deleted file mode 100644 index bfb4e0153..000000000 --- a/G4FANCYCANTESTING/Core/Src/i2c.c +++ /dev/null @@ -1,92 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file i2c.c - * @brief This file provides code for the configuration - * of the I2C instances. - ****************************************************************************** - * @attention - * - * Copyright (c) 2025 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 "i2c.h" - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/* I2C2 init function */ -void MX_I2C2_Init(void) -{ - - /* USER CODE BEGIN I2C2_Init 0 */ - - /* USER CODE END I2C2_Init 0 */ - - LL_I2C_InitTypeDef I2C_InitStruct = {0}; - - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - - LL_RCC_SetI2CClockSource(LL_RCC_I2C2_CLKSOURCE_PCLK1); - - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA); - /**I2C2 GPIO Configuration - PC4 ------> I2C2_SCL - PA8 ------> I2C2_SDA - */ - GPIO_InitStruct.Pin = LL_GPIO_PIN_4; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_OPENDRAIN; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_4; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = LL_GPIO_PIN_8; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_OPENDRAIN; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_4; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /* Peripheral clock enable */ - LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_I2C2); - - /* USER CODE BEGIN I2C2_Init 1 */ - - /* USER CODE END I2C2_Init 1 */ - - /** I2C Initialization - */ - I2C_InitStruct.PeripheralMode = LL_I2C_MODE_I2C; - I2C_InitStruct.Timing = 0x30D29DE4; - I2C_InitStruct.AnalogFilter = LL_I2C_ANALOGFILTER_ENABLE; - I2C_InitStruct.DigitalFilter = 0; - I2C_InitStruct.OwnAddress1 = 0; - I2C_InitStruct.TypeAcknowledge = LL_I2C_ACK; - I2C_InitStruct.OwnAddrSize = LL_I2C_OWNADDRESS1_7BIT; - LL_I2C_Init(I2C2, &I2C_InitStruct); - LL_I2C_EnableAutoEndMode(I2C2); - LL_I2C_SetOwnAddress2(I2C2, 0, LL_I2C_OWNADDRESS2_NOMASK); - LL_I2C_DisableOwnAddress2(I2C2); - LL_I2C_DisableGeneralCall(I2C2); - LL_I2C_EnableClockStretching(I2C2); - /* USER CODE BEGIN I2C2_Init 2 */ - - /* USER CODE END I2C2_Init 2 */ -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ diff --git a/G4FANCYCANTESTING/Core/Src/spi.c b/G4FANCYCANTESTING/Core/Src/spi.c deleted file mode 100644 index 66459f2ec..000000000 --- a/G4FANCYCANTESTING/Core/Src/spi.c +++ /dev/null @@ -1,95 +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 */ - -/* SPI3 init function */ -void MX_SPI3_Init(void) -{ - - /* USER CODE BEGIN SPI3_Init 0 */ - - /* USER CODE END SPI3_Init 0 */ - - LL_SPI_InitTypeDef SPI_InitStruct = {0}; - - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - - /* Peripheral clock enable */ - LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_SPI3); - - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC); - /**SPI3 GPIO Configuration - PC10 ------> SPI3_SCK - PC11 ------> SPI3_MISO - PC12 ------> SPI3_MOSI - */ - GPIO_InitStruct.Pin = LL_GPIO_PIN_10; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_6; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = LL_GPIO_PIN_11; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_6; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = LL_GPIO_PIN_12; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_6; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /* USER CODE BEGIN SPI3_Init 1 */ - - /* USER CODE END SPI3_Init 1 */ - SPI_InitStruct.TransferDirection = LL_SPI_FULL_DUPLEX; - SPI_InitStruct.Mode = LL_SPI_MODE_MASTER; - SPI_InitStruct.DataWidth = LL_SPI_DATAWIDTH_4BIT; - SPI_InitStruct.ClockPolarity = LL_SPI_POLARITY_LOW; - SPI_InitStruct.ClockPhase = LL_SPI_PHASE_1EDGE; - SPI_InitStruct.NSS = LL_SPI_NSS_SOFT; - SPI_InitStruct.BaudRate = LL_SPI_BAUDRATEPRESCALER_DIV32; - SPI_InitStruct.BitOrder = LL_SPI_MSB_FIRST; - SPI_InitStruct.CRCCalculation = LL_SPI_CRCCALCULATION_DISABLE; - SPI_InitStruct.CRCPoly = 7; - LL_SPI_Init(SPI3, &SPI_InitStruct); - LL_SPI_SetStandard(SPI3, LL_SPI_PROTOCOL_MOTOROLA); - LL_SPI_EnableNSSPulseMgt(SPI3); - /* USER CODE BEGIN SPI3_Init 2 */ - - /* USER CODE END SPI3_Init 2 */ -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ diff --git a/G4FANCYCANTESTING/Core/Src/stm32g4xx_hal_msp.c b/G4FANCYCANTESTING/Core/Src/stm32g4xx_hal_msp.c deleted file mode 100644 index 69189ef4e..000000000 --- a/G4FANCYCANTESTING/Core/Src/stm32g4xx_hal_msp.c +++ /dev/null @@ -1,86 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file stm32g4xx_hal_msp.c - * @brief This file provides code for the MSP Initialization - * and de-Initialization codes. - ****************************************************************************** - * @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 "main.h" -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* Private typedef -----------------------------------------------------------*/ -/* USER CODE BEGIN TD */ - -/* USER CODE END TD */ - -/* Private define ------------------------------------------------------------*/ -/* USER CODE BEGIN Define */ - -/* USER CODE END Define */ - -/* Private macro -------------------------------------------------------------*/ -/* USER CODE BEGIN Macro */ - -/* USER CODE END Macro */ - -/* Private variables ---------------------------------------------------------*/ -/* USER CODE BEGIN PV */ - -/* USER CODE END PV */ - -/* Private function prototypes -----------------------------------------------*/ -/* USER CODE BEGIN PFP */ - -/* USER CODE END PFP */ - -/* External functions --------------------------------------------------------*/ -/* USER CODE BEGIN ExternalFunctions */ - -/* USER CODE END ExternalFunctions */ - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ -/** - * Initializes the Global MSP. - */ -void HAL_MspInit(void) -{ - - /* USER CODE BEGIN MspInit 0 */ - - /* USER CODE END MspInit 0 */ - - __HAL_RCC_SYSCFG_CLK_ENABLE(); - __HAL_RCC_PWR_CLK_ENABLE(); - - /* System interrupt init*/ - - /** Disable the internal Pull-Up in Dead Battery pins of UCPD peripheral - */ - HAL_PWREx_DisableUCPDDeadBattery(); - - /* USER CODE BEGIN MspInit 1 */ - - /* USER CODE END MspInit 1 */ -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ diff --git a/G4FANCYCANTESTING/Core/Src/stm32g4xx_it.c b/G4FANCYCANTESTING/Core/Src/stm32g4xx_it.c deleted file mode 100644 index dd322200e..000000000 --- a/G4FANCYCANTESTING/Core/Src/stm32g4xx_it.c +++ /dev/null @@ -1,194 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file stm32g4xx_it.c - * @brief Interrupt Service Routines. - ****************************************************************************** - * @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 "stm32g4xx_it.h" - -#include "main.h" -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ -/* USER CODE END Includes */ - -/* Private typedef -----------------------------------------------------------*/ -/* USER CODE BEGIN TD */ - -/* USER CODE END TD */ - -/* Private define ------------------------------------------------------------*/ -/* USER CODE BEGIN PD */ - -/* USER CODE END PD */ - -/* Private macro -------------------------------------------------------------*/ -/* USER CODE BEGIN PM */ - -/* USER CODE END PM */ - -/* Private variables ---------------------------------------------------------*/ -/* USER CODE BEGIN PV */ - -/* USER CODE END PV */ - -/* Private function prototypes -----------------------------------------------*/ -/* USER CODE BEGIN PFP */ - -/* USER CODE END PFP */ - -/* Private user code ---------------------------------------------------------*/ -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/* External variables --------------------------------------------------------*/ -// extern FDCAN_HandleTypeDef hfdcan2; -/* USER CODE BEGIN EV */ - -/* USER CODE END EV */ - -/******************************************************************************/ -/* Cortex-M4 Processor Interruption and Exception Handlers */ -/******************************************************************************/ -/** - * @brief This function handles Non maskable interrupt. - */ -void NMI_Handler(void) -{ - /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ - - /* USER CODE END NonMaskableInt_IRQn 0 */ - /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ - while (1) {} - /* USER CODE END NonMaskableInt_IRQn 1 */ -} - -/** - * @brief This function handles Hard fault interrupt. - */ -void HardFault_Handler(void) -{ - /* USER CODE BEGIN HardFault_IRQn 0 */ - - /* USER CODE END HardFault_IRQn 0 */ - while (1) { - /* USER CODE BEGIN W1_HardFault_IRQn 0 */ - /* USER CODE END W1_HardFault_IRQn 0 */ - } -} - -/** - * @brief This function handles Memory management fault. - */ -void MemManage_Handler(void) -{ - /* USER CODE BEGIN MemoryManagement_IRQn 0 */ - - /* USER CODE END MemoryManagement_IRQn 0 */ - while (1) { - /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ - /* USER CODE END W1_MemoryManagement_IRQn 0 */ - } -} - -/** - * @brief This function handles Prefetch fault, memory access fault. - */ -void BusFault_Handler(void) -{ - /* USER CODE BEGIN BusFault_IRQn 0 */ - - /* USER CODE END BusFault_IRQn 0 */ - while (1) { - /* USER CODE BEGIN W1_BusFault_IRQn 0 */ - /* USER CODE END W1_BusFault_IRQn 0 */ - } -} - -/** - * @brief This function handles Undefined instruction or illegal state. - */ -void UsageFault_Handler(void) -{ - /* USER CODE BEGIN UsageFault_IRQn 0 */ - - /* USER CODE END UsageFault_IRQn 0 */ - while (1) { - /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ - /* USER CODE END W1_UsageFault_IRQn 0 */ - } -} - -/** - * @brief This function handles System service call via SWI instruction. - */ -void SVC_Handler(void) -{ - /* USER CODE BEGIN SVCall_IRQn 0 */ - - /* USER CODE END SVCall_IRQn 0 */ - /* USER CODE BEGIN SVCall_IRQn 1 */ - - /* USER CODE END SVCall_IRQn 1 */ -} - -/** - * @brief This function handles Debug monitor. - */ -void DebugMon_Handler(void) -{ - /* USER CODE BEGIN DebugMonitor_IRQn 0 */ - - /* USER CODE END DebugMonitor_IRQn 0 */ - /* USER CODE BEGIN DebugMonitor_IRQn 1 */ - - /* USER CODE END DebugMonitor_IRQn 1 */ -} - -/** - * @brief This function handles Pendable request for system service. - */ -void PendSV_Handler(void) -{ - /* USER CODE BEGIN PendSV_IRQn 0 */ - - /* USER CODE END PendSV_IRQn 0 */ - /* USER CODE BEGIN PendSV_IRQn 1 */ - - /* USER CODE END PendSV_IRQn 1 */ -} - -/** - * @brief This function handles System tick timer. - */ -void SysTick_Handler(void) -{ - /* USER CODE BEGIN SysTick_IRQn 0 */ - - /* USER CODE END SysTick_IRQn 0 */ - HAL_IncTick(); - /* USER CODE BEGIN SysTick_IRQn 1 */ - - /* USER CODE END SysTick_IRQn 1 */ -} - -/******************************************************************************/ -/* STM32G4xx Peripheral Interrupt Handlers */ -/* Add here the Interrupt Handlers for the used peripherals. */ -/* For the available peripheral interrupt handler names, */ -/* please refer to the startup file (startup_stm32g4xx.s). */ -/******************************************************************************/ diff --git a/G4FANCYCANTESTING/Core/Src/tim.c b/G4FANCYCANTESTING/Core/Src/tim.c deleted file mode 100644 index 7f521c3bf..000000000 --- a/G4FANCYCANTESTING/Core/Src/tim.c +++ /dev/null @@ -1,79 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file tim.c - * @brief This file provides code for the configuration - * of the TIM instances. - ****************************************************************************** - * @attention - * - * Copyright (c) 2025 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 "tim.h" - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/* TIM2 init function */ -void MX_TIM2_Init(void) -{ - - /* USER CODE BEGIN TIM2_Init 0 */ - - /* USER CODE END TIM2_Init 0 */ - - LL_TIM_InitTypeDef TIM_InitStruct = {0}; - LL_TIM_OC_InitTypeDef TIM_OC_InitStruct = {0}; - - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - /* Peripheral clock enable */ - LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM2); - - /* USER CODE BEGIN TIM2_Init 1 */ - - /* USER CODE END TIM2_Init 1 */ - TIM_InitStruct.Prescaler = 0; - TIM_InitStruct.CounterMode = LL_TIM_COUNTERMODE_UP; - TIM_InitStruct.Autoreload = 4294967295; - TIM_InitStruct.ClockDivision = LL_TIM_CLOCKDIVISION_DIV1; - LL_TIM_Init(TIM2, &TIM_InitStruct); - LL_TIM_DisableARRPreload(TIM2); - LL_TIM_SetClockSource(TIM2, LL_TIM_CLOCKSOURCE_INTERNAL); - TIM_OC_InitStruct.OCMode = LL_TIM_OCMODE_FORCED_ACTIVE; - TIM_OC_InitStruct.OCState = LL_TIM_OCSTATE_DISABLE; - TIM_OC_InitStruct.OCNState = LL_TIM_OCSTATE_DISABLE; - TIM_OC_InitStruct.CompareValue = 0; - TIM_OC_InitStruct.OCPolarity = LL_TIM_OCPOLARITY_HIGH; - LL_TIM_OC_Init(TIM2, LL_TIM_CHANNEL_CH1, &TIM_OC_InitStruct); - LL_TIM_OC_DisableFast(TIM2, LL_TIM_CHANNEL_CH1); - LL_TIM_SetTriggerOutput(TIM2, LL_TIM_TRGO_RESET); - LL_TIM_DisableMasterSlaveMode(TIM2); - /* USER CODE BEGIN TIM2_Init 2 */ - - /* USER CODE END TIM2_Init 2 */ - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA); - /**TIM2 GPIO Configuration - PA0 ------> TIM2_CH1 - */ - GPIO_InitStruct.Pin = LL_GPIO_PIN_0; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_1; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ diff --git a/G4FANCYCANTESTING/Core/Src/usart.c b/G4FANCYCANTESTING/Core/Src/usart.c deleted file mode 100644 index 41561862c..000000000 --- a/G4FANCYCANTESTING/Core/Src/usart.c +++ /dev/null @@ -1,184 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file usart.c - * @brief This file provides code for the configuration - * of the USART instances. - ****************************************************************************** - * @attention - * - * Copyright (c) 2025 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 "usart.h" - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/* LPUART1 init function */ - -void MX_LPUART1_UART_Init(void) -{ - - /* USER CODE BEGIN LPUART1_Init 0 */ - - /* USER CODE END LPUART1_Init 0 */ - - LL_LPUART_InitTypeDef LPUART_InitStruct = {0}; - - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - - LL_RCC_SetLPUARTClockSource(LL_RCC_LPUART1_CLKSOURCE_HSI); - - /* Peripheral clock enable */ - LL_APB1_GRP2_EnableClock(LL_APB1_GRP2_PERIPH_LPUART1); - - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA); - /**LPUART1 GPIO Configuration - PA2 ------> LPUART1_TX - PA3 ------> LPUART1_RX - */ - GPIO_InitStruct.Pin = LL_GPIO_PIN_2; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_12; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = LL_GPIO_PIN_3; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_12; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /* USER CODE BEGIN LPUART1_Init 1 */ - - /* USER CODE END LPUART1_Init 1 */ - LPUART_InitStruct.PrescalerValue = LL_LPUART_PRESCALER_DIV1; - LPUART_InitStruct.BaudRate = 115200; - LPUART_InitStruct.DataWidth = LL_LPUART_DATAWIDTH_8B; - LPUART_InitStruct.StopBits = LL_LPUART_STOPBITS_1; - LPUART_InitStruct.Parity = LL_LPUART_PARITY_NONE; - LPUART_InitStruct.TransferDirection = LL_LPUART_DIRECTION_TX_RX; - LPUART_InitStruct.HardwareFlowControl = LL_LPUART_HWCONTROL_NONE; - LL_LPUART_Init(LPUART1, &LPUART_InitStruct); - LL_LPUART_SetTXFIFOThreshold(LPUART1, LL_LPUART_FIFOTHRESHOLD_1_8); - LL_LPUART_SetRXFIFOThreshold(LPUART1, LL_LPUART_FIFOTHRESHOLD_1_8); - LL_LPUART_DisableFIFO(LPUART1); - - /* USER CODE BEGIN WKUPType LPUART1 */ - - /* USER CODE END WKUPType LPUART1 */ - - LL_LPUART_Enable(LPUART1); - - /* Polling LPUART1 initialisation */ - while ((!(LL_LPUART_IsActiveFlag_TEACK(LPUART1))) || (!(LL_LPUART_IsActiveFlag_REACK(LPUART1)))) {} - /* USER CODE BEGIN LPUART1_Init 2 */ - - /* USER CODE END LPUART1_Init 2 */ -} -/* USART1 init function */ - -void MX_USART1_UART_Init(void) -{ - - /* USER CODE BEGIN USART1_Init 0 */ - - /* USER CODE END USART1_Init 0 */ - - LL_USART_InitTypeDef USART_InitStruct = {0}; - - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - - LL_RCC_SetUSARTClockSource(LL_RCC_USART1_CLKSOURCE_PCLK2); - - /* Peripheral clock enable */ - LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_USART1); - - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOB); - /**USART1 GPIO Configuration - PC5 ------> USART1_RX - PA11 ------> USART1_CTS - PA12 ------> USART1_RTS - PB6 ------> USART1_TX - */ - GPIO_InitStruct.Pin = LL_GPIO_PIN_5; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_7; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = LL_GPIO_PIN_11; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_7; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = LL_GPIO_PIN_12; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_7; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = LL_GPIO_PIN_6; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_7; - LL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - /* USER CODE BEGIN USART1_Init 1 */ - - /* USER CODE END USART1_Init 1 */ - USART_InitStruct.PrescalerValue = LL_USART_PRESCALER_DIV1; - USART_InitStruct.BaudRate = 115200; - USART_InitStruct.DataWidth = LL_USART_DATAWIDTH_8B; - USART_InitStruct.StopBits = LL_USART_STOPBITS_1; - USART_InitStruct.Parity = LL_USART_PARITY_NONE; - USART_InitStruct.TransferDirection = LL_USART_DIRECTION_TX_RX; - USART_InitStruct.HardwareFlowControl = LL_USART_HWCONTROL_RTS_CTS; - USART_InitStruct.OverSampling = LL_USART_OVERSAMPLING_16; - LL_USART_Init(USART1, &USART_InitStruct); - LL_USART_SetTXFIFOThreshold(USART1, LL_USART_FIFOTHRESHOLD_1_8); - LL_USART_SetRXFIFOThreshold(USART1, LL_USART_FIFOTHRESHOLD_1_8); - LL_USART_DisableFIFO(USART1); - LL_USART_ConfigAsyncMode(USART1); - - /* USER CODE BEGIN WKUPType USART1 */ - - /* USER CODE END WKUPType USART1 */ - - LL_USART_Enable(USART1); - - /* Polling USART1 initialisation */ - while ((!(LL_USART_IsActiveFlag_TEACK(USART1))) || (!(LL_USART_IsActiveFlag_REACK(USART1)))) {} - /* USER CODE BEGIN USART1_Init 2 */ - - /* USER CODE END USART1_Init 2 */ -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ diff --git a/G4NEOTESTING/Core/Inc/stm32g4xx_hal_conf.h b/G4NEOTESTING/Core/Inc/stm32g4xx_hal_conf.h deleted file mode 100644 index 3e1fcb018..000000000 --- a/G4NEOTESTING/Core/Inc/stm32g4xx_hal_conf.h +++ /dev/null @@ -1,390 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file stm32g4xx_hal_conf.h - * @author MCD Application Team - * @brief HAL configuration file - ****************************************************************************** - * @attention - * - * Copyright (c) 2019 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 STM32G4xx_HAL_CONF_H -#define STM32G4xx_HAL_CONF_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Exported types ------------------------------------------------------------*/ -/* Exported constants --------------------------------------------------------*/ - -/* ########################## Module Selection ############################## */ -/** - * @brief This is the list of modules to be used in the HAL driver - */ - -#define HAL_MODULE_ENABLED - -/*#define HAL_ADC_MODULE_ENABLED */ -/*#define HAL_COMP_MODULE_ENABLED */ -/*#define HAL_CORDIC_MODULE_ENABLED */ -#define HAL_CRC_MODULE_ENABLED -/*#define HAL_CRYP_MODULE_ENABLED */ -/*#define HAL_DAC_MODULE_ENABLED */ -#define HAL_FDCAN_MODULE_ENABLED -/*#define HAL_FMAC_MODULE_ENABLED */ -/*#define HAL_HRTIM_MODULE_ENABLED */ -/*#define HAL_IRDA_MODULE_ENABLED */ -/*#define HAL_IWDG_MODULE_ENABLED */ -/*#define HAL_I2C_MODULE_ENABLED */ -/*#define HAL_I2S_MODULE_ENABLED */ -/*#define HAL_LPTIM_MODULE_ENABLED */ -/*#define HAL_NAND_MODULE_ENABLED */ -/*#define HAL_NOR_MODULE_ENABLED */ -/*#define HAL_OPAMP_MODULE_ENABLED */ -/*#define HAL_PCD_MODULE_ENABLED */ -/*#define HAL_QSPI_MODULE_ENABLED */ -/*#define HAL_RNG_MODULE_ENABLED */ -/*#define HAL_RTC_MODULE_ENABLED */ -/*#define HAL_SAI_MODULE_ENABLED */ -/*#define HAL_SMARTCARD_MODULE_ENABLED */ -/*#define HAL_SMBUS_MODULE_ENABLED */ -/*#define HAL_SPI_MODULE_ENABLED */ -/*#define HAL_SRAM_MODULE_ENABLED */ -/*#define HAL_TIM_MODULE_ENABLED */ -/*#define HAL_UART_MODULE_ENABLED */ -/*#define HAL_USART_MODULE_ENABLED */ -/*#define HAL_WWDG_MODULE_ENABLED */ -#define HAL_GPIO_MODULE_ENABLED -#define HAL_EXTI_MODULE_ENABLED -#define HAL_DMA_MODULE_ENABLED -#define HAL_RCC_MODULE_ENABLED -#define HAL_FLASH_MODULE_ENABLED -#define HAL_PWR_MODULE_ENABLED -#define HAL_CORTEX_MODULE_ENABLED - -/* ########################## Register Callbacks selection - * ############################## */ -/** - * @brief This is the list of modules where register callback can be used - */ -#define USE_HAL_ADC_REGISTER_CALLBACKS 0U -#define USE_HAL_COMP_REGISTER_CALLBACKS 0U -#define USE_HAL_CORDIC_REGISTER_CALLBACKS 0U -#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U -#define USE_HAL_DAC_REGISTER_CALLBACKS 0U -#define USE_HAL_EXTI_REGISTER_CALLBACKS 0U -#define USE_HAL_FDCAN_REGISTER_CALLBACKS 0U -#define USE_HAL_FMAC_REGISTER_CALLBACKS 0U -#define USE_HAL_HRTIM_REGISTER_CALLBACKS 0U -#define USE_HAL_I2C_REGISTER_CALLBACKS 0U -#define USE_HAL_I2S_REGISTER_CALLBACKS 0U -#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U -#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U -#define USE_HAL_NAND_REGISTER_CALLBACKS 0U -#define USE_HAL_NOR_REGISTER_CALLBACKS 0U -#define USE_HAL_OPAMP_REGISTER_CALLBACKS 0U -#define USE_HAL_PCD_REGISTER_CALLBACKS 0U -#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U -#define USE_HAL_RNG_REGISTER_CALLBACKS 0U -#define USE_HAL_RTC_REGISTER_CALLBACKS 0U -#define USE_HAL_SAI_REGISTER_CALLBACKS 0U -#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U -#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U -#define USE_HAL_SPI_REGISTER_CALLBACKS 0U -#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U -#define USE_HAL_TIM_REGISTER_CALLBACKS 0U -#define USE_HAL_UART_REGISTER_CALLBACKS 0U -#define USE_HAL_USART_REGISTER_CALLBACKS 0U -#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U - -/* ########################## Oscillator Values adaptation - * ####################*/ -/** - * @brief Adjust the value of External High Speed oscillator (HSE) used in your - * application. This value is used by the RCC HAL module to compute the system - * frequency (when HSE is used as system clock source, directly or through the - * PLL). - */ -#if !defined(HSE_VALUE) -#define HSE_VALUE (16000000UL) /*!< Value of the External oscillator in Hz */ -#endif /* HSE_VALUE */ - -#if !defined(HSE_STARTUP_TIMEOUT) -#define HSE_STARTUP_TIMEOUT (100UL) /*!< Time out for HSE start up, in ms */ -#endif /* HSE_STARTUP_TIMEOUT */ - -/** - * @brief Internal High Speed oscillator (HSI) value. - * This value is used by the RCC HAL module to compute the system - * frequency (when HSI is used as system clock source, directly or through the - * PLL). - */ -#if !defined(HSI_VALUE) -#define HSI_VALUE (16000000UL) /*!< Value of the Internal oscillator in Hz*/ -#endif /* HSI_VALUE */ - -/** - * @brief Internal High Speed oscillator (HSI48) value for USB FS and RNG. - * This internal oscillator is mainly dedicated to provide a high - * precision clock to the USB peripheral by means of a special Clock Recovery - * System (CRS) circuitry. When the CRS is not used, the HSI48 RC oscillator - * runs on it default frequency which is subject to manufacturing process - * variations. - */ -#if !defined(HSI48_VALUE) -#define HSI48_VALUE \ - (48000000UL) /*!< Value of the Internal High Speed oscillator for USB \ - FS/RNG in Hz. The real value my vary depending on \ - manufacturing process variations.*/ -#endif /* HSI48_VALUE */ - -/** - * @brief Internal Low Speed oscillator (LSI) value. - */ -#if !defined(LSI_VALUE) -/*!< Value of the Internal Low Speed oscillator in Hz -The real value may vary depending on the variations in voltage and -temperature.*/ -#define LSI_VALUE (32000UL) /*!< LSI Typical Value in Hz*/ -#endif /* LSI_VALUE */ -/** - * @brief External Low Speed oscillator (LSE) value. - * This value is used by the UART, RTC HAL module to compute the system - * frequency - */ -#if !defined(LSE_VALUE) -#define LSE_VALUE (32768UL) /*!< Value of the External Low Speed oscillator in Hz */ -#endif /* LSE_VALUE */ - -#if !defined(LSE_STARTUP_TIMEOUT) -#define LSE_STARTUP_TIMEOUT (5000UL) /*!< Time out for LSE start up, in ms */ -#endif /* LSE_STARTUP_TIMEOUT */ - -/** - * @brief External clock source for I2S and SAI peripherals - * This value is used by the I2S and SAI HAL modules to compute the I2S - * and SAI clock source frequency, this source is inserted directly through - * I2S_CKIN pad. - */ -#if !defined(EXTERNAL_CLOCK_VALUE) -#define EXTERNAL_CLOCK_VALUE (12288000UL) /*!< Value of the External oscillator in Hz*/ -#endif /* EXTERNAL_CLOCK_VALUE */ - -/* Tip: To avoid modifying this file each time you need to use different HSE, - === you can define the HSE value in your toolchain compiler preprocessor. */ - -/* ########################### System Configuration ######################### */ -/** - * @brief This is the HAL system configuration section - */ - -#define VDD_VALUE (3300UL) /*!< Value of VDD in mv */ -#define TICK_INT_PRIORITY (15UL) /*!< tick interrupt priority (lowest by default) */ -#define USE_RTOS 0U -#define PREFETCH_ENABLE 0U -#define INSTRUCTION_CACHE_ENABLE 1U -#define DATA_CACHE_ENABLE 1U - -/* ########################## Assert Selection ############################## */ -/** - * @brief Uncomment the line below to expanse the "assert_param" macro in the - * HAL drivers code - */ -/* #define USE_FULL_ASSERT 1U */ - -/* ################## SPI peripheral configuration ########################## */ - -/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver - * Activated: CRC code is present inside driver - * Deactivated: CRC code cleaned from driver - */ - -#define USE_SPI_CRC 0U - -/* Includes ------------------------------------------------------------------*/ -/** - * @brief Include module's header file - */ - -#ifdef HAL_RCC_MODULE_ENABLED -#include "stm32g4xx_hal_rcc.h" -#endif /* HAL_RCC_MODULE_ENABLED */ - -#ifdef HAL_GPIO_MODULE_ENABLED -#include "stm32g4xx_hal_gpio.h" -#endif /* HAL_GPIO_MODULE_ENABLED */ - -#ifdef HAL_DMA_MODULE_ENABLED -#include "stm32g4xx_hal_dma.h" -#endif /* HAL_DMA_MODULE_ENABLED */ - -#ifdef HAL_CORTEX_MODULE_ENABLED -#include "stm32g4xx_hal_cortex.h" -#endif /* HAL_CORTEX_MODULE_ENABLED */ - -#ifdef HAL_ADC_MODULE_ENABLED -#include "stm32g4xx_hal_adc.h" -#endif /* HAL_ADC_MODULE_ENABLED */ - -#ifdef HAL_COMP_MODULE_ENABLED -#include "stm32g4xx_hal_comp.h" -#endif /* HAL_COMP_MODULE_ENABLED */ - -#ifdef HAL_CORDIC_MODULE_ENABLED -#include "stm32g4xx_hal_cordic.h" -#endif /* HAL_CORDIC_MODULE_ENABLED */ - -#ifdef HAL_CRC_MODULE_ENABLED -#include "stm32g4xx_hal_crc.h" -#endif /* HAL_CRC_MODULE_ENABLED */ - -#ifdef HAL_CRYP_MODULE_ENABLED -#include "stm32g4xx_hal_cryp.h" -#endif /* HAL_CRYP_MODULE_ENABLED */ - -#ifdef HAL_DAC_MODULE_ENABLED -#include "stm32g4xx_hal_dac.h" -#endif /* HAL_DAC_MODULE_ENABLED */ - -#ifdef HAL_EXTI_MODULE_ENABLED -#include "stm32g4xx_hal_exti.h" -#endif /* HAL_EXTI_MODULE_ENABLED */ - -#ifdef HAL_FDCAN_MODULE_ENABLED -#include "stm32g4xx_hal_fdcan.h" -#endif /* HAL_FDCAN_MODULE_ENABLED */ - -#ifdef HAL_FLASH_MODULE_ENABLED -#include "stm32g4xx_hal_flash.h" -#endif /* HAL_FLASH_MODULE_ENABLED */ - -#ifdef HAL_FMAC_MODULE_ENABLED -#include "stm32g4xx_hal_fmac.h" -#endif /* HAL_FMAC_MODULE_ENABLED */ - -#ifdef HAL_HRTIM_MODULE_ENABLED -#include "stm32g4xx_hal_hrtim.h" -#endif /* HAL_HRTIM_MODULE_ENABLED */ - -#ifdef HAL_IRDA_MODULE_ENABLED -#include "stm32g4xx_hal_irda.h" -#endif /* HAL_IRDA_MODULE_ENABLED */ - -#ifdef HAL_IWDG_MODULE_ENABLED -#include "stm32g4xx_hal_iwdg.h" -#endif /* HAL_IWDG_MODULE_ENABLED */ - -#ifdef HAL_I2C_MODULE_ENABLED -#include "stm32g4xx_hal_i2c.h" -#endif /* HAL_I2C_MODULE_ENABLED */ - -#ifdef HAL_I2S_MODULE_ENABLED -#include "stm32g4xx_hal_i2s.h" -#endif /* HAL_I2S_MODULE_ENABLED */ - -#ifdef HAL_LPTIM_MODULE_ENABLED -#include "stm32g4xx_hal_lptim.h" -#endif /* HAL_LPTIM_MODULE_ENABLED */ - -#ifdef HAL_NAND_MODULE_ENABLED -#include "stm32g4xx_hal_nand.h" -#endif /* HAL_NAND_MODULE_ENABLED */ - -#ifdef HAL_NOR_MODULE_ENABLED -#include "stm32g4xx_hal_nor.h" -#endif /* HAL_NOR_MODULE_ENABLED */ - -#ifdef HAL_OPAMP_MODULE_ENABLED -#include "stm32g4xx_hal_opamp.h" -#endif /* HAL_OPAMP_MODULE_ENABLED */ - -#ifdef HAL_PCD_MODULE_ENABLED -#include "stm32g4xx_hal_pcd.h" -#endif /* HAL_PCD_MODULE_ENABLED */ - -#ifdef HAL_PWR_MODULE_ENABLED -#include "stm32g4xx_hal_pwr.h" -#endif /* HAL_PWR_MODULE_ENABLED */ - -#ifdef HAL_QSPI_MODULE_ENABLED -#include "stm32g4xx_hal_qspi.h" -#endif /* HAL_QSPI_MODULE_ENABLED */ - -#ifdef HAL_RNG_MODULE_ENABLED -#include "stm32g4xx_hal_rng.h" -#endif /* HAL_RNG_MODULE_ENABLED */ - -#ifdef HAL_RTC_MODULE_ENABLED -#include "stm32g4xx_hal_rtc.h" -#endif /* HAL_RTC_MODULE_ENABLED */ - -#ifdef HAL_SAI_MODULE_ENABLED -#include "stm32g4xx_hal_sai.h" -#endif /* HAL_SAI_MODULE_ENABLED */ - -#ifdef HAL_SMARTCARD_MODULE_ENABLED -#include "stm32g4xx_hal_smartcard.h" -#endif /* HAL_SMARTCARD_MODULE_ENABLED */ - -#ifdef HAL_SMBUS_MODULE_ENABLED -#include "stm32g4xx_hal_smbus.h" -#endif /* HAL_SMBUS_MODULE_ENABLED */ - -#ifdef HAL_SPI_MODULE_ENABLED -#include "stm32g4xx_hal_spi.h" -#endif /* HAL_SPI_MODULE_ENABLED */ - -#ifdef HAL_SRAM_MODULE_ENABLED -#include "stm32g4xx_hal_sram.h" -#endif /* HAL_SRAM_MODULE_ENABLED */ - -#ifdef HAL_TIM_MODULE_ENABLED -#include "stm32g4xx_hal_tim.h" -#endif /* HAL_TIM_MODULE_ENABLED */ - -#ifdef HAL_UART_MODULE_ENABLED -#include "stm32g4xx_hal_uart.h" -#endif /* HAL_UART_MODULE_ENABLED */ - -#ifdef HAL_USART_MODULE_ENABLED -#include "stm32g4xx_hal_usart.h" -#endif /* HAL_USART_MODULE_ENABLED */ - -#ifdef HAL_WWDG_MODULE_ENABLED -#include "stm32g4xx_hal_wwdg.h" -#endif /* HAL_WWDG_MODULE_ENABLED */ - -/* Exported macro ------------------------------------------------------------*/ -#ifdef USE_FULL_ASSERT -/** - * @brief The assert_param macro is used for function's parameters check. - * @param expr: If expr is false, it calls assert_failed function - * which reports the name of the source file and the source - * line number of the call that failed. - * If expr is true, it returns no value. - * @retval None - */ -#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) -/* Exported functions ------------------------------------------------------- */ -void assert_failed(uint8_t *file, uint32_t line); -#else -#define assert_param(expr) ((void)0U) -#endif /* USE_FULL_ASSERT */ - -#ifdef __cplusplus -} -#endif - -#endif /* STM32G4xx_HAL_CONF_H */ diff --git a/G4NEOTESTING/Core/Inc/stm32g4xx_it.h b/G4NEOTESTING/Core/Inc/stm32g4xx_it.h deleted file mode 100644 index b6c3b2f72..000000000 --- a/G4NEOTESTING/Core/Inc/stm32g4xx_it.h +++ /dev/null @@ -1,67 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file stm32g4xx_it.h - * @brief This file contains the headers of the interrupt handlers. - ****************************************************************************** - * @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 __STM32G4xx_IT_H -#define __STM32G4xx_IT_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* Exported types ------------------------------------------------------------*/ -/* USER CODE BEGIN ET */ - -/* USER CODE END ET */ - -/* Exported constants --------------------------------------------------------*/ -/* USER CODE BEGIN EC */ - -/* USER CODE END EC */ - -/* Exported macro ------------------------------------------------------------*/ -/* USER CODE BEGIN EM */ - -/* USER CODE END EM */ - -/* Exported functions prototypes ---------------------------------------------*/ -void NMI_Handler(void); -void HardFault_Handler(void); -void MemManage_Handler(void); -void BusFault_Handler(void); -void UsageFault_Handler(void); -void SVC_Handler(void); -void DebugMon_Handler(void); -void PendSV_Handler(void); -void SysTick_Handler(void); -void FDCAN2_IT0_IRQHandler(void); -/* USER CODE BEGIN EFP */ - -/* USER CODE END EFP */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32G4xx_IT_H */ diff --git a/G4NEOTESTING/Core/Src/stm32g4xx_hal_msp.c b/G4NEOTESTING/Core/Src/stm32g4xx_hal_msp.c deleted file mode 100644 index 69189ef4e..000000000 --- a/G4NEOTESTING/Core/Src/stm32g4xx_hal_msp.c +++ /dev/null @@ -1,86 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file stm32g4xx_hal_msp.c - * @brief This file provides code for the MSP Initialization - * and de-Initialization codes. - ****************************************************************************** - * @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 "main.h" -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* Private typedef -----------------------------------------------------------*/ -/* USER CODE BEGIN TD */ - -/* USER CODE END TD */ - -/* Private define ------------------------------------------------------------*/ -/* USER CODE BEGIN Define */ - -/* USER CODE END Define */ - -/* Private macro -------------------------------------------------------------*/ -/* USER CODE BEGIN Macro */ - -/* USER CODE END Macro */ - -/* Private variables ---------------------------------------------------------*/ -/* USER CODE BEGIN PV */ - -/* USER CODE END PV */ - -/* Private function prototypes -----------------------------------------------*/ -/* USER CODE BEGIN PFP */ - -/* USER CODE END PFP */ - -/* External functions --------------------------------------------------------*/ -/* USER CODE BEGIN ExternalFunctions */ - -/* USER CODE END ExternalFunctions */ - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ -/** - * Initializes the Global MSP. - */ -void HAL_MspInit(void) -{ - - /* USER CODE BEGIN MspInit 0 */ - - /* USER CODE END MspInit 0 */ - - __HAL_RCC_SYSCFG_CLK_ENABLE(); - __HAL_RCC_PWR_CLK_ENABLE(); - - /* System interrupt init*/ - - /** Disable the internal Pull-Up in Dead Battery pins of UCPD peripheral - */ - HAL_PWREx_DisableUCPDDeadBattery(); - - /* USER CODE BEGIN MspInit 1 */ - - /* USER CODE END MspInit 1 */ -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ diff --git a/G4PERTESTING/Core/Inc/adc.h b/G4PERTESTING/Core/Inc/adc.h deleted file mode 100644 index 41154538b..000000000 --- a/G4PERTESTING/Core/Inc/adc.h +++ /dev/null @@ -1,49 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file adc.h - * @brief This file contains all the function prototypes for - * the adc.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 __ADC_H__ -#define __ADC_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" - -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* USER CODE BEGIN Private defines */ - -/* USER CODE END Private defines */ - -void MX_ADC1_Init(void); - -/* USER CODE BEGIN Prototypes */ - -/* USER CODE END Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif /* __ADC_H__ */ diff --git a/G4PERTESTING/Core/Inc/crc.h b/G4PERTESTING/Core/Inc/crc.h deleted file mode 100644 index 133957e92..000000000 --- a/G4PERTESTING/Core/Inc/crc.h +++ /dev/null @@ -1,51 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file crc.h - * @brief This file contains all the function prototypes for - * the crc.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 __CRC_H__ -#define __CRC_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" - -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -extern CRC_HandleTypeDef hcrc; - -/* USER CODE BEGIN Private defines */ - -/* USER CODE END Private defines */ - -void MX_CRC_Init(void); - -/* USER CODE BEGIN Prototypes */ - -/* USER CODE END Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif /* __CRC_H__ */ diff --git a/G4PERTESTING/Core/Inc/dma.h b/G4PERTESTING/Core/Inc/dma.h deleted file mode 100644 index ae819cab4..000000000 --- a/G4PERTESTING/Core/Inc/dma.h +++ /dev/null @@ -1,51 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file dma.h - * @brief This file contains all the function prototypes for - * the dma.c file - ****************************************************************************** - * @attention - * - * Copyright (c) 2025 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__ */ diff --git a/G4PERTESTING/Core/Inc/fdcan.h b/G4PERTESTING/Core/Inc/fdcan.h deleted file mode 100644 index 56c4a8adb..000000000 --- a/G4PERTESTING/Core/Inc/fdcan.h +++ /dev/null @@ -1,51 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file fdcan.h - * @brief This file contains all the function prototypes for - * the fdcan.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 __FDCAN_H__ -#define __FDCAN_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" - -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -extern FDCAN_HandleTypeDef hfdcan2; - -/* USER CODE BEGIN Private defines */ - -/* USER CODE END Private defines */ - -void MX_FDCAN2_Init(void); - -/* USER CODE BEGIN Prototypes */ - -/* USER CODE END Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif /* __FDCAN_H__ */ diff --git a/G4PERTESTING/Core/Inc/gpio.h b/G4PERTESTING/Core/Inc/gpio.h deleted file mode 100644 index 843d4e9e7..000000000 --- a/G4PERTESTING/Core/Inc/gpio.h +++ /dev/null @@ -1,48 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file gpio.h - * @brief This file contains all the function prototypes for - * the gpio.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 __GPIO_H__ -#define __GPIO_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" - -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* USER CODE BEGIN Private defines */ - -/* USER CODE END Private defines */ - -void MX_GPIO_Init(void); - -/* USER CODE BEGIN Prototypes */ - -/* USER CODE END Prototypes */ - -#ifdef __cplusplus -} -#endif -#endif /*__ GPIO_H__ */ diff --git a/G4PERTESTING/Core/Inc/i2c.h b/G4PERTESTING/Core/Inc/i2c.h deleted file mode 100644 index 0a0a50803..000000000 --- a/G4PERTESTING/Core/Inc/i2c.h +++ /dev/null @@ -1,49 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file i2c.h - * @brief This file contains all the function prototypes for - * the i2c.c file - ****************************************************************************** - * @attention - * - * Copyright (c) 2025 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 __I2C_H__ -#define __I2C_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" - -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* USER CODE BEGIN Private defines */ - -/* USER CODE END Private defines */ - -void MX_I2C2_Init(void); - -/* USER CODE BEGIN Prototypes */ - -/* USER CODE END Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif /* __I2C_H__ */ diff --git a/G4PERTESTING/Core/Inc/main.h b/G4PERTESTING/Core/Inc/main.h deleted file mode 100644 index 23d7ffce4..000000000 --- a/G4PERTESTING/Core/Inc/main.h +++ /dev/null @@ -1,115 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file : main.h - * @brief : Header for main.c file. - * This file contains the common defines of the application. - ****************************************************************************** - * @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 __MAIN_H -#define __MAIN_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32g4xx_hal.h" -#include "stm32g4xx_ll_adc.h" -#include "stm32g4xx_ll_bus.h" -#include "stm32g4xx_ll_cortex.h" -#include "stm32g4xx_ll_crs.h" -#include "stm32g4xx_ll_dma.h" -#include "stm32g4xx_ll_exti.h" -#include "stm32g4xx_ll_gpio.h" -#include "stm32g4xx_ll_i2c.h" -#include "stm32g4xx_ll_lpuart.h" -#include "stm32g4xx_ll_pwr.h" -#include "stm32g4xx_ll_rcc.h" -#include "stm32g4xx_ll_spi.h" -#include "stm32g4xx_ll_system.h" -#include "stm32g4xx_ll_tim.h" -#include "stm32g4xx_ll_usart.h" -#include "stm32g4xx_ll_utils.h" - -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* Exported types ------------------------------------------------------------*/ -/* USER CODE BEGIN ET */ - -/* USER CODE END ET */ - -/* Exported constants --------------------------------------------------------*/ -/* USER CODE BEGIN EC */ - -/* USER CODE END EC */ - -/* Exported macro ------------------------------------------------------------*/ -/* USER CODE BEGIN EM */ - -/* USER CODE END EM */ - -/* Exported functions prototypes ---------------------------------------------*/ -void Error_Handler(void); - -/* USER CODE BEGIN EFP */ - -/* USER CODE END EFP */ - -/* Private defines -----------------------------------------------------------*/ -#define BSPD_SIGNAL_Pin LL_GPIO_PIN_1 -#define BSPD_SIGNAL_GPIO_Port GPIOC -#define APPS1_SIGNAL_Pin LL_GPIO_PIN_2 -#define APPS1_SIGNAL_GPIO_Port GPIOC -#define APPS2_SIGNAL_Pin LL_GPIO_PIN_3 -#define APPS2_SIGNAL_GPIO_Port GPIOC -#define BLINKY_Pin LL_GPIO_PIN_5 -#define BLINKY_GPIO_Port GPIOA -#define IMD_SENSE_Pin LL_GPIO_PIN_6 -#define IMD_SENSE_GPIO_Port GPIOA -#define AMS_SENSE_Pin LL_GPIO_PIN_7 -#define AMS_SENSE_GPIO_Port GPIOA -#define BRAKE_F_SIGNAL_Pin LL_GPIO_PIN_0 -#define BRAKE_F_SIGNAL_GPIO_Port GPIOB -#define BRAKE_R_SIGNAL_Pin LL_GPIO_PIN_1 -#define BRAKE_R_SIGNAL_GPIO_Port GPIOB -#define LED_TEST_Pin LL_GPIO_PIN_11 -#define LED_TEST_GPIO_Port GPIOB -#define AUX_SIGNAL_Pin LL_GPIO_PIN_14 -#define AUX_SIGNAL_GPIO_Port GPIOB -#define STEERING_ANGLE_Pin LL_GPIO_PIN_15 -#define STEERING_ANGLE_GPIO_Port GPIOB -#define BRAKE_LIGHT_Pin LL_GPIO_PIN_4 -#define BRAKE_LIGHT_GPIO_Port GPIOB -#define TSSI_G_CONTROL_Pin LL_GPIO_PIN_5 -#define TSSI_G_CONTROL_GPIO_Port GPIOB -#define AUX_CONTROL_Pin LL_GPIO_PIN_8 -#define AUX_CONTROL_GPIO_Port GPIOB -#define SOFTWARE_OK_CONTROL_Pin LL_GPIO_PIN_9 -#define SOFTWARE_OK_CONTROL_GPIO_Port GPIOB - -/* USER CODE BEGIN Private defines */ - -/* USER CODE END Private defines */ - -#ifdef __cplusplus -} -#endif - -#endif /* __MAIN_H */ diff --git a/G4PERTESTING/Core/Inc/spi.h b/G4PERTESTING/Core/Inc/spi.h deleted file mode 100644 index 74bed003b..000000000 --- a/G4PERTESTING/Core/Inc/spi.h +++ /dev/null @@ -1,49 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file spi.h - * @brief This file contains all the function prototypes for - * the spi.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 __SPI_H__ -#define __SPI_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" - -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* USER CODE BEGIN Private defines */ - -/* USER CODE END Private defines */ - -void MX_SPI3_Init(void); - -/* USER CODE BEGIN Prototypes */ - -/* USER CODE END Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif /* __SPI_H__ */ diff --git a/G4PERTESTING/Core/Inc/stm32g4xx_hal_conf.h b/G4PERTESTING/Core/Inc/stm32g4xx_hal_conf.h deleted file mode 100644 index 3e1fcb018..000000000 --- a/G4PERTESTING/Core/Inc/stm32g4xx_hal_conf.h +++ /dev/null @@ -1,390 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file stm32g4xx_hal_conf.h - * @author MCD Application Team - * @brief HAL configuration file - ****************************************************************************** - * @attention - * - * Copyright (c) 2019 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 STM32G4xx_HAL_CONF_H -#define STM32G4xx_HAL_CONF_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Exported types ------------------------------------------------------------*/ -/* Exported constants --------------------------------------------------------*/ - -/* ########################## Module Selection ############################## */ -/** - * @brief This is the list of modules to be used in the HAL driver - */ - -#define HAL_MODULE_ENABLED - -/*#define HAL_ADC_MODULE_ENABLED */ -/*#define HAL_COMP_MODULE_ENABLED */ -/*#define HAL_CORDIC_MODULE_ENABLED */ -#define HAL_CRC_MODULE_ENABLED -/*#define HAL_CRYP_MODULE_ENABLED */ -/*#define HAL_DAC_MODULE_ENABLED */ -#define HAL_FDCAN_MODULE_ENABLED -/*#define HAL_FMAC_MODULE_ENABLED */ -/*#define HAL_HRTIM_MODULE_ENABLED */ -/*#define HAL_IRDA_MODULE_ENABLED */ -/*#define HAL_IWDG_MODULE_ENABLED */ -/*#define HAL_I2C_MODULE_ENABLED */ -/*#define HAL_I2S_MODULE_ENABLED */ -/*#define HAL_LPTIM_MODULE_ENABLED */ -/*#define HAL_NAND_MODULE_ENABLED */ -/*#define HAL_NOR_MODULE_ENABLED */ -/*#define HAL_OPAMP_MODULE_ENABLED */ -/*#define HAL_PCD_MODULE_ENABLED */ -/*#define HAL_QSPI_MODULE_ENABLED */ -/*#define HAL_RNG_MODULE_ENABLED */ -/*#define HAL_RTC_MODULE_ENABLED */ -/*#define HAL_SAI_MODULE_ENABLED */ -/*#define HAL_SMARTCARD_MODULE_ENABLED */ -/*#define HAL_SMBUS_MODULE_ENABLED */ -/*#define HAL_SPI_MODULE_ENABLED */ -/*#define HAL_SRAM_MODULE_ENABLED */ -/*#define HAL_TIM_MODULE_ENABLED */ -/*#define HAL_UART_MODULE_ENABLED */ -/*#define HAL_USART_MODULE_ENABLED */ -/*#define HAL_WWDG_MODULE_ENABLED */ -#define HAL_GPIO_MODULE_ENABLED -#define HAL_EXTI_MODULE_ENABLED -#define HAL_DMA_MODULE_ENABLED -#define HAL_RCC_MODULE_ENABLED -#define HAL_FLASH_MODULE_ENABLED -#define HAL_PWR_MODULE_ENABLED -#define HAL_CORTEX_MODULE_ENABLED - -/* ########################## Register Callbacks selection - * ############################## */ -/** - * @brief This is the list of modules where register callback can be used - */ -#define USE_HAL_ADC_REGISTER_CALLBACKS 0U -#define USE_HAL_COMP_REGISTER_CALLBACKS 0U -#define USE_HAL_CORDIC_REGISTER_CALLBACKS 0U -#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U -#define USE_HAL_DAC_REGISTER_CALLBACKS 0U -#define USE_HAL_EXTI_REGISTER_CALLBACKS 0U -#define USE_HAL_FDCAN_REGISTER_CALLBACKS 0U -#define USE_HAL_FMAC_REGISTER_CALLBACKS 0U -#define USE_HAL_HRTIM_REGISTER_CALLBACKS 0U -#define USE_HAL_I2C_REGISTER_CALLBACKS 0U -#define USE_HAL_I2S_REGISTER_CALLBACKS 0U -#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U -#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U -#define USE_HAL_NAND_REGISTER_CALLBACKS 0U -#define USE_HAL_NOR_REGISTER_CALLBACKS 0U -#define USE_HAL_OPAMP_REGISTER_CALLBACKS 0U -#define USE_HAL_PCD_REGISTER_CALLBACKS 0U -#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U -#define USE_HAL_RNG_REGISTER_CALLBACKS 0U -#define USE_HAL_RTC_REGISTER_CALLBACKS 0U -#define USE_HAL_SAI_REGISTER_CALLBACKS 0U -#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U -#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U -#define USE_HAL_SPI_REGISTER_CALLBACKS 0U -#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U -#define USE_HAL_TIM_REGISTER_CALLBACKS 0U -#define USE_HAL_UART_REGISTER_CALLBACKS 0U -#define USE_HAL_USART_REGISTER_CALLBACKS 0U -#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U - -/* ########################## Oscillator Values adaptation - * ####################*/ -/** - * @brief Adjust the value of External High Speed oscillator (HSE) used in your - * application. This value is used by the RCC HAL module to compute the system - * frequency (when HSE is used as system clock source, directly or through the - * PLL). - */ -#if !defined(HSE_VALUE) -#define HSE_VALUE (16000000UL) /*!< Value of the External oscillator in Hz */ -#endif /* HSE_VALUE */ - -#if !defined(HSE_STARTUP_TIMEOUT) -#define HSE_STARTUP_TIMEOUT (100UL) /*!< Time out for HSE start up, in ms */ -#endif /* HSE_STARTUP_TIMEOUT */ - -/** - * @brief Internal High Speed oscillator (HSI) value. - * This value is used by the RCC HAL module to compute the system - * frequency (when HSI is used as system clock source, directly or through the - * PLL). - */ -#if !defined(HSI_VALUE) -#define HSI_VALUE (16000000UL) /*!< Value of the Internal oscillator in Hz*/ -#endif /* HSI_VALUE */ - -/** - * @brief Internal High Speed oscillator (HSI48) value for USB FS and RNG. - * This internal oscillator is mainly dedicated to provide a high - * precision clock to the USB peripheral by means of a special Clock Recovery - * System (CRS) circuitry. When the CRS is not used, the HSI48 RC oscillator - * runs on it default frequency which is subject to manufacturing process - * variations. - */ -#if !defined(HSI48_VALUE) -#define HSI48_VALUE \ - (48000000UL) /*!< Value of the Internal High Speed oscillator for USB \ - FS/RNG in Hz. The real value my vary depending on \ - manufacturing process variations.*/ -#endif /* HSI48_VALUE */ - -/** - * @brief Internal Low Speed oscillator (LSI) value. - */ -#if !defined(LSI_VALUE) -/*!< Value of the Internal Low Speed oscillator in Hz -The real value may vary depending on the variations in voltage and -temperature.*/ -#define LSI_VALUE (32000UL) /*!< LSI Typical Value in Hz*/ -#endif /* LSI_VALUE */ -/** - * @brief External Low Speed oscillator (LSE) value. - * This value is used by the UART, RTC HAL module to compute the system - * frequency - */ -#if !defined(LSE_VALUE) -#define LSE_VALUE (32768UL) /*!< Value of the External Low Speed oscillator in Hz */ -#endif /* LSE_VALUE */ - -#if !defined(LSE_STARTUP_TIMEOUT) -#define LSE_STARTUP_TIMEOUT (5000UL) /*!< Time out for LSE start up, in ms */ -#endif /* LSE_STARTUP_TIMEOUT */ - -/** - * @brief External clock source for I2S and SAI peripherals - * This value is used by the I2S and SAI HAL modules to compute the I2S - * and SAI clock source frequency, this source is inserted directly through - * I2S_CKIN pad. - */ -#if !defined(EXTERNAL_CLOCK_VALUE) -#define EXTERNAL_CLOCK_VALUE (12288000UL) /*!< Value of the External oscillator in Hz*/ -#endif /* EXTERNAL_CLOCK_VALUE */ - -/* Tip: To avoid modifying this file each time you need to use different HSE, - === you can define the HSE value in your toolchain compiler preprocessor. */ - -/* ########################### System Configuration ######################### */ -/** - * @brief This is the HAL system configuration section - */ - -#define VDD_VALUE (3300UL) /*!< Value of VDD in mv */ -#define TICK_INT_PRIORITY (15UL) /*!< tick interrupt priority (lowest by default) */ -#define USE_RTOS 0U -#define PREFETCH_ENABLE 0U -#define INSTRUCTION_CACHE_ENABLE 1U -#define DATA_CACHE_ENABLE 1U - -/* ########################## Assert Selection ############################## */ -/** - * @brief Uncomment the line below to expanse the "assert_param" macro in the - * HAL drivers code - */ -/* #define USE_FULL_ASSERT 1U */ - -/* ################## SPI peripheral configuration ########################## */ - -/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver - * Activated: CRC code is present inside driver - * Deactivated: CRC code cleaned from driver - */ - -#define USE_SPI_CRC 0U - -/* Includes ------------------------------------------------------------------*/ -/** - * @brief Include module's header file - */ - -#ifdef HAL_RCC_MODULE_ENABLED -#include "stm32g4xx_hal_rcc.h" -#endif /* HAL_RCC_MODULE_ENABLED */ - -#ifdef HAL_GPIO_MODULE_ENABLED -#include "stm32g4xx_hal_gpio.h" -#endif /* HAL_GPIO_MODULE_ENABLED */ - -#ifdef HAL_DMA_MODULE_ENABLED -#include "stm32g4xx_hal_dma.h" -#endif /* HAL_DMA_MODULE_ENABLED */ - -#ifdef HAL_CORTEX_MODULE_ENABLED -#include "stm32g4xx_hal_cortex.h" -#endif /* HAL_CORTEX_MODULE_ENABLED */ - -#ifdef HAL_ADC_MODULE_ENABLED -#include "stm32g4xx_hal_adc.h" -#endif /* HAL_ADC_MODULE_ENABLED */ - -#ifdef HAL_COMP_MODULE_ENABLED -#include "stm32g4xx_hal_comp.h" -#endif /* HAL_COMP_MODULE_ENABLED */ - -#ifdef HAL_CORDIC_MODULE_ENABLED -#include "stm32g4xx_hal_cordic.h" -#endif /* HAL_CORDIC_MODULE_ENABLED */ - -#ifdef HAL_CRC_MODULE_ENABLED -#include "stm32g4xx_hal_crc.h" -#endif /* HAL_CRC_MODULE_ENABLED */ - -#ifdef HAL_CRYP_MODULE_ENABLED -#include "stm32g4xx_hal_cryp.h" -#endif /* HAL_CRYP_MODULE_ENABLED */ - -#ifdef HAL_DAC_MODULE_ENABLED -#include "stm32g4xx_hal_dac.h" -#endif /* HAL_DAC_MODULE_ENABLED */ - -#ifdef HAL_EXTI_MODULE_ENABLED -#include "stm32g4xx_hal_exti.h" -#endif /* HAL_EXTI_MODULE_ENABLED */ - -#ifdef HAL_FDCAN_MODULE_ENABLED -#include "stm32g4xx_hal_fdcan.h" -#endif /* HAL_FDCAN_MODULE_ENABLED */ - -#ifdef HAL_FLASH_MODULE_ENABLED -#include "stm32g4xx_hal_flash.h" -#endif /* HAL_FLASH_MODULE_ENABLED */ - -#ifdef HAL_FMAC_MODULE_ENABLED -#include "stm32g4xx_hal_fmac.h" -#endif /* HAL_FMAC_MODULE_ENABLED */ - -#ifdef HAL_HRTIM_MODULE_ENABLED -#include "stm32g4xx_hal_hrtim.h" -#endif /* HAL_HRTIM_MODULE_ENABLED */ - -#ifdef HAL_IRDA_MODULE_ENABLED -#include "stm32g4xx_hal_irda.h" -#endif /* HAL_IRDA_MODULE_ENABLED */ - -#ifdef HAL_IWDG_MODULE_ENABLED -#include "stm32g4xx_hal_iwdg.h" -#endif /* HAL_IWDG_MODULE_ENABLED */ - -#ifdef HAL_I2C_MODULE_ENABLED -#include "stm32g4xx_hal_i2c.h" -#endif /* HAL_I2C_MODULE_ENABLED */ - -#ifdef HAL_I2S_MODULE_ENABLED -#include "stm32g4xx_hal_i2s.h" -#endif /* HAL_I2S_MODULE_ENABLED */ - -#ifdef HAL_LPTIM_MODULE_ENABLED -#include "stm32g4xx_hal_lptim.h" -#endif /* HAL_LPTIM_MODULE_ENABLED */ - -#ifdef HAL_NAND_MODULE_ENABLED -#include "stm32g4xx_hal_nand.h" -#endif /* HAL_NAND_MODULE_ENABLED */ - -#ifdef HAL_NOR_MODULE_ENABLED -#include "stm32g4xx_hal_nor.h" -#endif /* HAL_NOR_MODULE_ENABLED */ - -#ifdef HAL_OPAMP_MODULE_ENABLED -#include "stm32g4xx_hal_opamp.h" -#endif /* HAL_OPAMP_MODULE_ENABLED */ - -#ifdef HAL_PCD_MODULE_ENABLED -#include "stm32g4xx_hal_pcd.h" -#endif /* HAL_PCD_MODULE_ENABLED */ - -#ifdef HAL_PWR_MODULE_ENABLED -#include "stm32g4xx_hal_pwr.h" -#endif /* HAL_PWR_MODULE_ENABLED */ - -#ifdef HAL_QSPI_MODULE_ENABLED -#include "stm32g4xx_hal_qspi.h" -#endif /* HAL_QSPI_MODULE_ENABLED */ - -#ifdef HAL_RNG_MODULE_ENABLED -#include "stm32g4xx_hal_rng.h" -#endif /* HAL_RNG_MODULE_ENABLED */ - -#ifdef HAL_RTC_MODULE_ENABLED -#include "stm32g4xx_hal_rtc.h" -#endif /* HAL_RTC_MODULE_ENABLED */ - -#ifdef HAL_SAI_MODULE_ENABLED -#include "stm32g4xx_hal_sai.h" -#endif /* HAL_SAI_MODULE_ENABLED */ - -#ifdef HAL_SMARTCARD_MODULE_ENABLED -#include "stm32g4xx_hal_smartcard.h" -#endif /* HAL_SMARTCARD_MODULE_ENABLED */ - -#ifdef HAL_SMBUS_MODULE_ENABLED -#include "stm32g4xx_hal_smbus.h" -#endif /* HAL_SMBUS_MODULE_ENABLED */ - -#ifdef HAL_SPI_MODULE_ENABLED -#include "stm32g4xx_hal_spi.h" -#endif /* HAL_SPI_MODULE_ENABLED */ - -#ifdef HAL_SRAM_MODULE_ENABLED -#include "stm32g4xx_hal_sram.h" -#endif /* HAL_SRAM_MODULE_ENABLED */ - -#ifdef HAL_TIM_MODULE_ENABLED -#include "stm32g4xx_hal_tim.h" -#endif /* HAL_TIM_MODULE_ENABLED */ - -#ifdef HAL_UART_MODULE_ENABLED -#include "stm32g4xx_hal_uart.h" -#endif /* HAL_UART_MODULE_ENABLED */ - -#ifdef HAL_USART_MODULE_ENABLED -#include "stm32g4xx_hal_usart.h" -#endif /* HAL_USART_MODULE_ENABLED */ - -#ifdef HAL_WWDG_MODULE_ENABLED -#include "stm32g4xx_hal_wwdg.h" -#endif /* HAL_WWDG_MODULE_ENABLED */ - -/* Exported macro ------------------------------------------------------------*/ -#ifdef USE_FULL_ASSERT -/** - * @brief The assert_param macro is used for function's parameters check. - * @param expr: If expr is false, it calls assert_failed function - * which reports the name of the source file and the source - * line number of the call that failed. - * If expr is true, it returns no value. - * @retval None - */ -#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) -/* Exported functions ------------------------------------------------------- */ -void assert_failed(uint8_t *file, uint32_t line); -#else -#define assert_param(expr) ((void)0U) -#endif /* USE_FULL_ASSERT */ - -#ifdef __cplusplus -} -#endif - -#endif /* STM32G4xx_HAL_CONF_H */ diff --git a/G4PERTESTING/Core/Inc/stm32g4xx_it.h b/G4PERTESTING/Core/Inc/stm32g4xx_it.h deleted file mode 100644 index b6c3b2f72..000000000 --- a/G4PERTESTING/Core/Inc/stm32g4xx_it.h +++ /dev/null @@ -1,67 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file stm32g4xx_it.h - * @brief This file contains the headers of the interrupt handlers. - ****************************************************************************** - * @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 __STM32G4xx_IT_H -#define __STM32G4xx_IT_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* Exported types ------------------------------------------------------------*/ -/* USER CODE BEGIN ET */ - -/* USER CODE END ET */ - -/* Exported constants --------------------------------------------------------*/ -/* USER CODE BEGIN EC */ - -/* USER CODE END EC */ - -/* Exported macro ------------------------------------------------------------*/ -/* USER CODE BEGIN EM */ - -/* USER CODE END EM */ - -/* Exported functions prototypes ---------------------------------------------*/ -void NMI_Handler(void); -void HardFault_Handler(void); -void MemManage_Handler(void); -void BusFault_Handler(void); -void UsageFault_Handler(void); -void SVC_Handler(void); -void DebugMon_Handler(void); -void PendSV_Handler(void); -void SysTick_Handler(void); -void FDCAN2_IT0_IRQHandler(void); -/* USER CODE BEGIN EFP */ - -/* USER CODE END EFP */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32G4xx_IT_H */ diff --git a/G4PERTESTING/Core/Inc/tim.h b/G4PERTESTING/Core/Inc/tim.h deleted file mode 100644 index c19e6cc71..000000000 --- a/G4PERTESTING/Core/Inc/tim.h +++ /dev/null @@ -1,49 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file tim.h - * @brief This file contains all the function prototypes for - * the tim.c file - ****************************************************************************** - * @attention - * - * Copyright (c) 2025 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 __TIM_H__ -#define __TIM_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" - -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* USER CODE BEGIN Private defines */ - -/* USER CODE END Private defines */ - -void MX_TIM2_Init(void); - -/* USER CODE BEGIN Prototypes */ - -/* USER CODE END Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif /* __TIM_H__ */ diff --git a/G4PERTESTING/Core/Inc/usart.h b/G4PERTESTING/Core/Inc/usart.h deleted file mode 100644 index daefd73e6..000000000 --- a/G4PERTESTING/Core/Inc/usart.h +++ /dev/null @@ -1,50 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file usart.h - * @brief This file contains all the function prototypes for - * the usart.c file - ****************************************************************************** - * @attention - * - * Copyright (c) 2025 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 __USART_H__ -#define __USART_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" - -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* USER CODE BEGIN Private defines */ - -/* USER CODE END Private defines */ - -void MX_LPUART1_UART_Init(void); -void MX_USART1_UART_Init(void); - -/* USER CODE BEGIN Prototypes */ - -/* USER CODE END Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif /* __USART_H__ */ diff --git a/G4PERTESTING/Core/Src/adc.c b/G4PERTESTING/Core/Src/adc.c deleted file mode 100644 index f3dbff8ed..000000000 --- a/G4PERTESTING/Core/Src/adc.c +++ /dev/null @@ -1,186 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file adc.c - * @brief This file provides code for the configuration - * of the ADC 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 "adc.h" - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/* ADC1 init function */ -void MX_ADC1_Init(void) -{ - - /* USER CODE BEGIN ADC1_Init 0 */ - - /* USER CODE END ADC1_Init 0 */ - - LL_ADC_InitTypeDef ADC_InitStruct = {0}; - LL_ADC_REG_InitTypeDef ADC_REG_InitStruct = {0}; - LL_ADC_CommonInitTypeDef ADC_CommonInitStruct = {0}; - - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - - LL_RCC_SetADCClockSource(LL_RCC_ADC12_CLKSOURCE_SYSCLK); - - /* Peripheral clock enable */ - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_ADC12); - - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOB); - /**ADC1 GPIO Configuration - PC1 ------> ADC1_IN7 - PC2 ------> ADC1_IN8 - PC3 ------> ADC1_IN9 - PB0 ------> ADC1_IN15 - PB1 ------> ADC1_IN12 - PB14 ------> ADC1_IN5 - */ - GPIO_InitStruct.Pin = BSPD_SIGNAL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(BSPD_SIGNAL_GPIO_Port, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = APPS1_SIGNAL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(APPS1_SIGNAL_GPIO_Port, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = APPS2_SIGNAL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(APPS2_SIGNAL_GPIO_Port, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = BRAKE_F_SIGNAL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(BRAKE_F_SIGNAL_GPIO_Port, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = BRAKE_R_SIGNAL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(BRAKE_R_SIGNAL_GPIO_Port, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = AUX_SIGNAL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(AUX_SIGNAL_GPIO_Port, &GPIO_InitStruct); - - /* ADC1 DMA Init */ - - /* ADC1 Init */ - LL_DMA_SetPeriphRequest(DMA1, LL_DMA_CHANNEL_1, LL_DMAMUX_REQ_ADC1); - - LL_DMA_SetDataTransferDirection(DMA1, LL_DMA_CHANNEL_1, LL_DMA_DIRECTION_PERIPH_TO_MEMORY); - - LL_DMA_SetChannelPriorityLevel(DMA1, LL_DMA_CHANNEL_1, LL_DMA_PRIORITY_LOW); - - LL_DMA_SetMode(DMA1, LL_DMA_CHANNEL_1, LL_DMA_MODE_CIRCULAR); - - LL_DMA_SetPeriphIncMode(DMA1, LL_DMA_CHANNEL_1, LL_DMA_PERIPH_NOINCREMENT); - - LL_DMA_SetMemoryIncMode(DMA1, LL_DMA_CHANNEL_1, LL_DMA_MEMORY_INCREMENT); - - LL_DMA_SetPeriphSize(DMA1, LL_DMA_CHANNEL_1, LL_DMA_PDATAALIGN_HALFWORD); - - LL_DMA_SetMemorySize(DMA1, LL_DMA_CHANNEL_1, LL_DMA_MDATAALIGN_HALFWORD); - - /* USER CODE BEGIN ADC1_Init 1 */ - - /* USER CODE END ADC1_Init 1 */ - - /** Common config - */ - ADC_InitStruct.Resolution = LL_ADC_RESOLUTION_12B; - ADC_InitStruct.DataAlignment = LL_ADC_DATA_ALIGN_RIGHT; - ADC_InitStruct.LowPowerMode = LL_ADC_LP_MODE_NONE; - LL_ADC_Init(ADC1, &ADC_InitStruct); - ADC_REG_InitStruct.TriggerSource = LL_ADC_REG_TRIG_SOFTWARE; - ADC_REG_InitStruct.SequencerLength = LL_ADC_REG_SEQ_SCAN_ENABLE_6RANKS; - ADC_REG_InitStruct.SequencerDiscont = LL_ADC_REG_SEQ_DISCONT_DISABLE; - ADC_REG_InitStruct.ContinuousMode = LL_ADC_REG_CONV_CONTINUOUS; - ADC_REG_InitStruct.DMATransfer = LL_ADC_REG_DMA_TRANSFER_UNLIMITED; - ADC_REG_InitStruct.Overrun = LL_ADC_REG_OVR_DATA_PRESERVED; - LL_ADC_REG_Init(ADC1, &ADC_REG_InitStruct); - LL_ADC_SetGainCompensation(ADC1, 0); - LL_ADC_SetOverSamplingScope(ADC1, LL_ADC_OVS_DISABLE); - ADC_CommonInitStruct.CommonClock = LL_ADC_CLOCK_ASYNC_DIV256; - ADC_CommonInitStruct.Multimode = LL_ADC_MULTI_INDEPENDENT; - LL_ADC_CommonInit(__LL_ADC_COMMON_INSTANCE(ADC1), &ADC_CommonInitStruct); - - /* Disable ADC deep power down (enabled by default after reset state) */ - LL_ADC_DisableDeepPowerDown(ADC1); - /* Enable ADC internal voltage regulator */ - LL_ADC_EnableInternalRegulator(ADC1); - /* Delay for ADC internal voltage regulator stabilization. */ - /* Compute number of CPU cycles to wait for, from delay in us. */ - /* Note: Variable divided by 2 to compensate partially */ - /* CPU processing cycles (depends on compilation optimization). */ - /* Note: If system core clock frequency is below 200kHz, wait time */ - /* is only a few CPU processing cycles. */ - uint32_t wait_loop_index; - wait_loop_index = ((LL_ADC_DELAY_INTERNAL_REGUL_STAB_US * (SystemCoreClock / (100000 * 2))) / 10); - while (wait_loop_index != 0) { - wait_loop_index--; - } - - /** Configure Regular Channel - */ - LL_ADC_REG_SetSequencerRanks(ADC1, LL_ADC_REG_RANK_1, LL_ADC_CHANNEL_5); - LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_5, LL_ADC_SAMPLINGTIME_92CYCLES_5); - LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_5, LL_ADC_SINGLE_ENDED); - - /** Configure Regular Channel - */ - LL_ADC_REG_SetSequencerRanks(ADC1, LL_ADC_REG_RANK_2, LL_ADC_CHANNEL_7); - LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_7, LL_ADC_SAMPLINGTIME_92CYCLES_5); - LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_7, LL_ADC_SINGLE_ENDED); - - /** Configure Regular Channel - */ - LL_ADC_REG_SetSequencerRanks(ADC1, LL_ADC_REG_RANK_3, LL_ADC_CHANNEL_8); - LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_8, LL_ADC_SAMPLINGTIME_92CYCLES_5); - LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_8, LL_ADC_SINGLE_ENDED); - - /** Configure Regular Channel - */ - LL_ADC_REG_SetSequencerRanks(ADC1, LL_ADC_REG_RANK_4, LL_ADC_CHANNEL_9); - LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_9, LL_ADC_SAMPLINGTIME_92CYCLES_5); - LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_9, LL_ADC_SINGLE_ENDED); - - /** Configure Regular Channel - */ - LL_ADC_REG_SetSequencerRanks(ADC1, LL_ADC_REG_RANK_5, LL_ADC_CHANNEL_12); - LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_12, LL_ADC_SAMPLINGTIME_92CYCLES_5); - LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_12, LL_ADC_SINGLE_ENDED); - - /** Configure Regular Channel - */ - LL_ADC_REG_SetSequencerRanks(ADC1, LL_ADC_REG_RANK_6, LL_ADC_CHANNEL_15); - LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_15, LL_ADC_SAMPLINGTIME_92CYCLES_5); - LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_15, LL_ADC_SINGLE_ENDED); - /* USER CODE BEGIN ADC1_Init 2 */ - - /* USER CODE END ADC1_Init 2 */ -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ diff --git a/G4PERTESTING/Core/Src/crc.c b/G4PERTESTING/Core/Src/crc.c deleted file mode 100644 index 213510a5d..000000000 --- a/G4PERTESTING/Core/Src/crc.c +++ /dev/null @@ -1,86 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file crc.c - * @brief This file provides code for the configuration - * of the CRC 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 "crc.h" - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -CRC_HandleTypeDef hcrc; - -/* CRC init function */ -void MX_CRC_Init(void) -{ - - /* USER CODE BEGIN CRC_Init 0 */ - - /* USER CODE END CRC_Init 0 */ - - /* USER CODE BEGIN CRC_Init 1 */ - - /* USER CODE END CRC_Init 1 */ - hcrc.Instance = CRC; - hcrc.Init.DefaultPolynomialUse = DEFAULT_POLYNOMIAL_ENABLE; - hcrc.Init.DefaultInitValueUse = DEFAULT_INIT_VALUE_ENABLE; - hcrc.Init.InputDataInversionMode = CRC_INPUTDATA_INVERSION_NONE; - hcrc.Init.OutputDataInversionMode = CRC_OUTPUTDATA_INVERSION_DISABLE; - hcrc.InputDataFormat = CRC_INPUTDATA_FORMAT_BYTES; - if (HAL_CRC_Init(&hcrc) != HAL_OK) { - Error_Handler(); - } - /* USER CODE BEGIN CRC_Init 2 */ - - /* USER CODE END CRC_Init 2 */ -} - -void HAL_CRC_MspInit(CRC_HandleTypeDef *crcHandle) -{ - - if (crcHandle->Instance == CRC) { - /* USER CODE BEGIN CRC_MspInit 0 */ - - /* USER CODE END CRC_MspInit 0 */ - /* CRC clock enable */ - __HAL_RCC_CRC_CLK_ENABLE(); - /* USER CODE BEGIN CRC_MspInit 1 */ - - /* USER CODE END CRC_MspInit 1 */ - } -} - -void HAL_CRC_MspDeInit(CRC_HandleTypeDef *crcHandle) -{ - - if (crcHandle->Instance == CRC) { - /* USER CODE BEGIN CRC_MspDeInit 0 */ - - /* USER CODE END CRC_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_CRC_CLK_DISABLE(); - /* USER CODE BEGIN CRC_MspDeInit 1 */ - - /* USER CODE END CRC_MspDeInit 1 */ - } -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ diff --git a/G4PERTESTING/Core/Src/dma.c b/G4PERTESTING/Core/Src/dma.c deleted file mode 100644 index 491e3889d..000000000 --- a/G4PERTESTING/Core/Src/dma.c +++ /dev/null @@ -1,50 +0,0 @@ -/* 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) 2025 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) -{ - - /* Init with LL driver */ - /* DMA controller clock enable */ - LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_DMAMUX1); - LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_DMA1); -} - -/* USER CODE BEGIN 2 */ - -/* USER CODE END 2 */ diff --git a/G4PERTESTING/Core/Src/fdcan.c b/G4PERTESTING/Core/Src/fdcan.c deleted file mode 100644 index f39dbfa2b..000000000 --- a/G4PERTESTING/Core/Src/fdcan.c +++ /dev/null @@ -1,133 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file fdcan.c - * @brief This file provides code for the configuration - * of the FDCAN 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 "fdcan.h" - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -FDCAN_HandleTypeDef hfdcan2; - -/* FDCAN2 init function */ -void MX_FDCAN2_Init(void) -{ - - /* USER CODE BEGIN FDCAN2_Init 0 */ - - /* USER CODE END FDCAN2_Init 0 */ - - /* USER CODE BEGIN FDCAN2_Init 1 */ - - /* USER CODE END FDCAN2_Init 1 */ - hfdcan2.Instance = FDCAN2; - hfdcan2.Init.ClockDivider = FDCAN_CLOCK_DIV1; - hfdcan2.Init.FrameFormat = FDCAN_FRAME_CLASSIC; - hfdcan2.Init.Mode = FDCAN_MODE_NORMAL; - hfdcan2.Init.AutoRetransmission = ENABLE; - hfdcan2.Init.TransmitPause = DISABLE; - hfdcan2.Init.ProtocolException = ENABLE; - hfdcan2.Init.NominalPrescaler = 1; - hfdcan2.Init.NominalSyncJumpWidth = 16; - hfdcan2.Init.NominalTimeSeg1 = 119; - hfdcan2.Init.NominalTimeSeg2 = 40; - hfdcan2.Init.DataPrescaler = 8; - hfdcan2.Init.DataSyncJumpWidth = 16; - hfdcan2.Init.DataTimeSeg1 = 14; - hfdcan2.Init.DataTimeSeg2 = 5; - hfdcan2.Init.StdFiltersNbr = 0; - hfdcan2.Init.ExtFiltersNbr = 2; - hfdcan2.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION; - if (HAL_FDCAN_Init(&hfdcan2) != HAL_OK) { - Error_Handler(); - } - /* USER CODE BEGIN FDCAN2_Init 2 */ - - /* USER CODE END FDCAN2_Init 2 */ -} - -void HAL_FDCAN_MspInit(FDCAN_HandleTypeDef *fdcanHandle) -{ - - GPIO_InitTypeDef GPIO_InitStruct = {0}; - if (fdcanHandle->Instance == FDCAN2) { - /* USER CODE BEGIN FDCAN2_MspInit 0 */ - - /* USER CODE END FDCAN2_MspInit 0 */ - LL_RCC_SetFDCANClockSource(LL_RCC_FDCAN_CLKSOURCE_PCLK1); - - /* FDCAN2 clock enable */ - __HAL_RCC_FDCAN_CLK_ENABLE(); - - __HAL_RCC_GPIOB_CLK_ENABLE(); - /**FDCAN2 GPIO Configuration - PB12 ------> FDCAN2_RX - PB13 ------> FDCAN2_TX - */ - GPIO_InitStruct.Pin = GPIO_PIN_12; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_PULLUP; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF9_FDCAN2; - HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = GPIO_PIN_13; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF9_FDCAN2; - HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - /* FDCAN2 interrupt Init */ - HAL_NVIC_SetPriority(FDCAN2_IT0_IRQn, 0, 0); - HAL_NVIC_EnableIRQ(FDCAN2_IT0_IRQn); - /* USER CODE BEGIN FDCAN2_MspInit 1 */ - - /* USER CODE END FDCAN2_MspInit 1 */ - } -} - -void HAL_FDCAN_MspDeInit(FDCAN_HandleTypeDef *fdcanHandle) -{ - - if (fdcanHandle->Instance == FDCAN2) { - /* USER CODE BEGIN FDCAN2_MspDeInit 0 */ - - /* USER CODE END FDCAN2_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_FDCAN_CLK_DISABLE(); - - /**FDCAN2 GPIO Configuration - PB12 ------> FDCAN2_RX - PB13 ------> FDCAN2_TX - */ - HAL_GPIO_DeInit(GPIOB, GPIO_PIN_12 | GPIO_PIN_13); - - /* FDCAN2 interrupt Deinit */ - HAL_NVIC_DisableIRQ(FDCAN2_IT0_IRQn); - /* USER CODE BEGIN FDCAN2_MspDeInit 1 */ - - /* USER CODE END FDCAN2_MspDeInit 1 */ - } -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ diff --git a/G4PERTESTING/Core/Src/gpio.c b/G4PERTESTING/Core/Src/gpio.c deleted file mode 100644 index d36e6eca6..000000000 --- a/G4PERTESTING/Core/Src/gpio.c +++ /dev/null @@ -1,260 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file gpio.c - * @brief This file provides code for the configuration - * of all used GPIO pins. - ****************************************************************************** - * @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 "gpio.h" - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/*----------------------------------------------------------------------------*/ -/* Configure GPIO */ -/*----------------------------------------------------------------------------*/ -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ - -/** Configure pins as - * Analog - * Input - * Output - * EVENT_OUT - * EXTI - * Free pins are configured automatically as Analog (this feature is - enabled through - * the Code Generation settings) - PA6 ------> ADC2_IN3 - PA7 ------> ADC2_IN4 - PB15 ------> ADC2_IN15 - PB7 ------> UART4_CTS -*/ -void MX_GPIO_Init(void) -{ - - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - - /* GPIO Ports Clock Enable */ - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOF); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOG); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOB); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOD); - - /**/ - LL_GPIO_ResetOutputPin(BLINKY_GPIO_Port, BLINKY_Pin); - - /**/ - LL_GPIO_ResetOutputPin(LED_TEST_GPIO_Port, LED_TEST_Pin); - - /**/ - LL_GPIO_ResetOutputPin(BRAKE_LIGHT_GPIO_Port, BRAKE_LIGHT_Pin); - - /**/ - LL_GPIO_ResetOutputPin(TSSI_G_CONTROL_GPIO_Port, TSSI_G_CONTROL_Pin); - - /**/ - LL_GPIO_ResetOutputPin(AUX_CONTROL_GPIO_Port, AUX_CONTROL_Pin); - - /**/ - LL_GPIO_ResetOutputPin(SOFTWARE_OK_CONTROL_GPIO_Port, SOFTWARE_OK_CONTROL_Pin); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_13; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_14; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_15; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_10; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOG, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_0; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_1; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_4; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = BLINKY_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(BLINKY_GPIO_Port, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = IMD_SENSE_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(IMD_SENSE_GPIO_Port, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = AMS_SENSE_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(AMS_SENSE_GPIO_Port, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_2; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_10; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LED_TEST_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(LED_TEST_GPIO_Port, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = STEERING_ANGLE_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(STEERING_ANGLE_GPIO_Port, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_6; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_7; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_8; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_9; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_9; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_10; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_15; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_2; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOD, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = BRAKE_LIGHT_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(BRAKE_LIGHT_GPIO_Port, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = TSSI_G_CONTROL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(TSSI_G_CONTROL_GPIO_Port, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_7; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_14; - LL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = AUX_CONTROL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(AUX_CONTROL_GPIO_Port, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = SOFTWARE_OK_CONTROL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(SOFTWARE_OK_CONTROL_GPIO_Port, &GPIO_InitStruct); -} - -/* USER CODE BEGIN 2 */ - -/* USER CODE END 2 */ diff --git a/G4PERTESTING/Core/Src/i2c.c b/G4PERTESTING/Core/Src/i2c.c deleted file mode 100644 index bfb4e0153..000000000 --- a/G4PERTESTING/Core/Src/i2c.c +++ /dev/null @@ -1,92 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file i2c.c - * @brief This file provides code for the configuration - * of the I2C instances. - ****************************************************************************** - * @attention - * - * Copyright (c) 2025 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 "i2c.h" - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/* I2C2 init function */ -void MX_I2C2_Init(void) -{ - - /* USER CODE BEGIN I2C2_Init 0 */ - - /* USER CODE END I2C2_Init 0 */ - - LL_I2C_InitTypeDef I2C_InitStruct = {0}; - - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - - LL_RCC_SetI2CClockSource(LL_RCC_I2C2_CLKSOURCE_PCLK1); - - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA); - /**I2C2 GPIO Configuration - PC4 ------> I2C2_SCL - PA8 ------> I2C2_SDA - */ - GPIO_InitStruct.Pin = LL_GPIO_PIN_4; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_OPENDRAIN; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_4; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = LL_GPIO_PIN_8; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_OPENDRAIN; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_4; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /* Peripheral clock enable */ - LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_I2C2); - - /* USER CODE BEGIN I2C2_Init 1 */ - - /* USER CODE END I2C2_Init 1 */ - - /** I2C Initialization - */ - I2C_InitStruct.PeripheralMode = LL_I2C_MODE_I2C; - I2C_InitStruct.Timing = 0x30D29DE4; - I2C_InitStruct.AnalogFilter = LL_I2C_ANALOGFILTER_ENABLE; - I2C_InitStruct.DigitalFilter = 0; - I2C_InitStruct.OwnAddress1 = 0; - I2C_InitStruct.TypeAcknowledge = LL_I2C_ACK; - I2C_InitStruct.OwnAddrSize = LL_I2C_OWNADDRESS1_7BIT; - LL_I2C_Init(I2C2, &I2C_InitStruct); - LL_I2C_EnableAutoEndMode(I2C2); - LL_I2C_SetOwnAddress2(I2C2, 0, LL_I2C_OWNADDRESS2_NOMASK); - LL_I2C_DisableOwnAddress2(I2C2); - LL_I2C_DisableGeneralCall(I2C2); - LL_I2C_EnableClockStretching(I2C2); - /* USER CODE BEGIN I2C2_Init 2 */ - - /* USER CODE END I2C2_Init 2 */ -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ diff --git a/G4PERTESTING/Core/Src/spi.c b/G4PERTESTING/Core/Src/spi.c deleted file mode 100644 index 66459f2ec..000000000 --- a/G4PERTESTING/Core/Src/spi.c +++ /dev/null @@ -1,95 +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 */ - -/* SPI3 init function */ -void MX_SPI3_Init(void) -{ - - /* USER CODE BEGIN SPI3_Init 0 */ - - /* USER CODE END SPI3_Init 0 */ - - LL_SPI_InitTypeDef SPI_InitStruct = {0}; - - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - - /* Peripheral clock enable */ - LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_SPI3); - - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC); - /**SPI3 GPIO Configuration - PC10 ------> SPI3_SCK - PC11 ------> SPI3_MISO - PC12 ------> SPI3_MOSI - */ - GPIO_InitStruct.Pin = LL_GPIO_PIN_10; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_6; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = LL_GPIO_PIN_11; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_6; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = LL_GPIO_PIN_12; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_6; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /* USER CODE BEGIN SPI3_Init 1 */ - - /* USER CODE END SPI3_Init 1 */ - SPI_InitStruct.TransferDirection = LL_SPI_FULL_DUPLEX; - SPI_InitStruct.Mode = LL_SPI_MODE_MASTER; - SPI_InitStruct.DataWidth = LL_SPI_DATAWIDTH_4BIT; - SPI_InitStruct.ClockPolarity = LL_SPI_POLARITY_LOW; - SPI_InitStruct.ClockPhase = LL_SPI_PHASE_1EDGE; - SPI_InitStruct.NSS = LL_SPI_NSS_SOFT; - SPI_InitStruct.BaudRate = LL_SPI_BAUDRATEPRESCALER_DIV32; - SPI_InitStruct.BitOrder = LL_SPI_MSB_FIRST; - SPI_InitStruct.CRCCalculation = LL_SPI_CRCCALCULATION_DISABLE; - SPI_InitStruct.CRCPoly = 7; - LL_SPI_Init(SPI3, &SPI_InitStruct); - LL_SPI_SetStandard(SPI3, LL_SPI_PROTOCOL_MOTOROLA); - LL_SPI_EnableNSSPulseMgt(SPI3); - /* USER CODE BEGIN SPI3_Init 2 */ - - /* USER CODE END SPI3_Init 2 */ -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ diff --git a/G4PERTESTING/Core/Src/stm32g4xx_hal_msp.c b/G4PERTESTING/Core/Src/stm32g4xx_hal_msp.c deleted file mode 100644 index 69189ef4e..000000000 --- a/G4PERTESTING/Core/Src/stm32g4xx_hal_msp.c +++ /dev/null @@ -1,86 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file stm32g4xx_hal_msp.c - * @brief This file provides code for the MSP Initialization - * and de-Initialization codes. - ****************************************************************************** - * @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 "main.h" -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* Private typedef -----------------------------------------------------------*/ -/* USER CODE BEGIN TD */ - -/* USER CODE END TD */ - -/* Private define ------------------------------------------------------------*/ -/* USER CODE BEGIN Define */ - -/* USER CODE END Define */ - -/* Private macro -------------------------------------------------------------*/ -/* USER CODE BEGIN Macro */ - -/* USER CODE END Macro */ - -/* Private variables ---------------------------------------------------------*/ -/* USER CODE BEGIN PV */ - -/* USER CODE END PV */ - -/* Private function prototypes -----------------------------------------------*/ -/* USER CODE BEGIN PFP */ - -/* USER CODE END PFP */ - -/* External functions --------------------------------------------------------*/ -/* USER CODE BEGIN ExternalFunctions */ - -/* USER CODE END ExternalFunctions */ - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ -/** - * Initializes the Global MSP. - */ -void HAL_MspInit(void) -{ - - /* USER CODE BEGIN MspInit 0 */ - - /* USER CODE END MspInit 0 */ - - __HAL_RCC_SYSCFG_CLK_ENABLE(); - __HAL_RCC_PWR_CLK_ENABLE(); - - /* System interrupt init*/ - - /** Disable the internal Pull-Up in Dead Battery pins of UCPD peripheral - */ - HAL_PWREx_DisableUCPDDeadBattery(); - - /* USER CODE BEGIN MspInit 1 */ - - /* USER CODE END MspInit 1 */ -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ diff --git a/G4PERTESTING/Core/Src/tim.c b/G4PERTESTING/Core/Src/tim.c deleted file mode 100644 index 7f521c3bf..000000000 --- a/G4PERTESTING/Core/Src/tim.c +++ /dev/null @@ -1,79 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file tim.c - * @brief This file provides code for the configuration - * of the TIM instances. - ****************************************************************************** - * @attention - * - * Copyright (c) 2025 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 "tim.h" - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/* TIM2 init function */ -void MX_TIM2_Init(void) -{ - - /* USER CODE BEGIN TIM2_Init 0 */ - - /* USER CODE END TIM2_Init 0 */ - - LL_TIM_InitTypeDef TIM_InitStruct = {0}; - LL_TIM_OC_InitTypeDef TIM_OC_InitStruct = {0}; - - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - /* Peripheral clock enable */ - LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM2); - - /* USER CODE BEGIN TIM2_Init 1 */ - - /* USER CODE END TIM2_Init 1 */ - TIM_InitStruct.Prescaler = 0; - TIM_InitStruct.CounterMode = LL_TIM_COUNTERMODE_UP; - TIM_InitStruct.Autoreload = 4294967295; - TIM_InitStruct.ClockDivision = LL_TIM_CLOCKDIVISION_DIV1; - LL_TIM_Init(TIM2, &TIM_InitStruct); - LL_TIM_DisableARRPreload(TIM2); - LL_TIM_SetClockSource(TIM2, LL_TIM_CLOCKSOURCE_INTERNAL); - TIM_OC_InitStruct.OCMode = LL_TIM_OCMODE_FORCED_ACTIVE; - TIM_OC_InitStruct.OCState = LL_TIM_OCSTATE_DISABLE; - TIM_OC_InitStruct.OCNState = LL_TIM_OCSTATE_DISABLE; - TIM_OC_InitStruct.CompareValue = 0; - TIM_OC_InitStruct.OCPolarity = LL_TIM_OCPOLARITY_HIGH; - LL_TIM_OC_Init(TIM2, LL_TIM_CHANNEL_CH1, &TIM_OC_InitStruct); - LL_TIM_OC_DisableFast(TIM2, LL_TIM_CHANNEL_CH1); - LL_TIM_SetTriggerOutput(TIM2, LL_TIM_TRGO_RESET); - LL_TIM_DisableMasterSlaveMode(TIM2); - /* USER CODE BEGIN TIM2_Init 2 */ - - /* USER CODE END TIM2_Init 2 */ - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA); - /**TIM2 GPIO Configuration - PA0 ------> TIM2_CH1 - */ - GPIO_InitStruct.Pin = LL_GPIO_PIN_0; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_1; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ diff --git a/G4PERTESTING/Core/Src/usart.c b/G4PERTESTING/Core/Src/usart.c deleted file mode 100644 index 56a3fa98f..000000000 --- a/G4PERTESTING/Core/Src/usart.c +++ /dev/null @@ -1,184 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file usart.c - * @brief This file provides code for the configuration - * of the USART instances. - ****************************************************************************** - * @attention - * - * Copyright (c) 2025 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 "usart.h" - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/* LPUART1 init function */ - -void MX_LPUART1_UART_Init(void) -{ - - /* USER CODE BEGIN LPUART1_Init 0 */ - - /* USER CODE END LPUART1_Init 0 */ - - LL_LPUART_InitTypeDef LPUART_InitStruct = {0}; - - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - - LL_RCC_SetLPUARTClockSource(LL_RCC_LPUART1_CLKSOURCE_PCLK1); - - /* Peripheral clock enable */ - LL_APB1_GRP2_EnableClock(LL_APB1_GRP2_PERIPH_LPUART1); - - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA); - /**LPUART1 GPIO Configuration - PA2 ------> LPUART1_TX - PA3 ------> LPUART1_RX - */ - GPIO_InitStruct.Pin = LL_GPIO_PIN_2; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_12; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = LL_GPIO_PIN_3; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_12; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /* USER CODE BEGIN LPUART1_Init 1 */ - - /* USER CODE END LPUART1_Init 1 */ - LPUART_InitStruct.PrescalerValue = LL_LPUART_PRESCALER_DIV1; - LPUART_InitStruct.BaudRate = 115200; - LPUART_InitStruct.DataWidth = LL_LPUART_DATAWIDTH_8B; - LPUART_InitStruct.StopBits = LL_LPUART_STOPBITS_1; - LPUART_InitStruct.Parity = LL_LPUART_PARITY_NONE; - LPUART_InitStruct.TransferDirection = LL_LPUART_DIRECTION_TX_RX; - LPUART_InitStruct.HardwareFlowControl = LL_LPUART_HWCONTROL_NONE; - LL_LPUART_Init(LPUART1, &LPUART_InitStruct); - LL_LPUART_SetTXFIFOThreshold(LPUART1, LL_LPUART_FIFOTHRESHOLD_1_8); - LL_LPUART_SetRXFIFOThreshold(LPUART1, LL_LPUART_FIFOTHRESHOLD_1_8); - LL_LPUART_DisableFIFO(LPUART1); - - /* USER CODE BEGIN WKUPType LPUART1 */ - - /* USER CODE END WKUPType LPUART1 */ - - LL_LPUART_Enable(LPUART1); - - /* Polling LPUART1 initialisation */ - while ((!(LL_LPUART_IsActiveFlag_TEACK(LPUART1))) || (!(LL_LPUART_IsActiveFlag_REACK(LPUART1)))) {} - /* USER CODE BEGIN LPUART1_Init 2 */ - - /* USER CODE END LPUART1_Init 2 */ -} -/* USART1 init function */ - -void MX_USART1_UART_Init(void) -{ - - /* USER CODE BEGIN USART1_Init 0 */ - - /* USER CODE END USART1_Init 0 */ - - LL_USART_InitTypeDef USART_InitStruct = {0}; - - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - - LL_RCC_SetUSARTClockSource(LL_RCC_USART1_CLKSOURCE_PCLK2); - - /* Peripheral clock enable */ - LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_USART1); - - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOB); - /**USART1 GPIO Configuration - PC5 ------> USART1_RX - PA11 ------> USART1_CTS - PA12 ------> USART1_RTS - PB6 ------> USART1_TX - */ - GPIO_InitStruct.Pin = LL_GPIO_PIN_5; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_7; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = LL_GPIO_PIN_11; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_7; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = LL_GPIO_PIN_12; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_7; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = LL_GPIO_PIN_6; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_7; - LL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - /* USER CODE BEGIN USART1_Init 1 */ - - /* USER CODE END USART1_Init 1 */ - USART_InitStruct.PrescalerValue = LL_USART_PRESCALER_DIV1; - USART_InitStruct.BaudRate = 115200; - USART_InitStruct.DataWidth = LL_USART_DATAWIDTH_8B; - USART_InitStruct.StopBits = LL_USART_STOPBITS_1; - USART_InitStruct.Parity = LL_USART_PARITY_NONE; - USART_InitStruct.TransferDirection = LL_USART_DIRECTION_TX_RX; - USART_InitStruct.HardwareFlowControl = LL_USART_HWCONTROL_RTS_CTS; - USART_InitStruct.OverSampling = LL_USART_OVERSAMPLING_16; - LL_USART_Init(USART1, &USART_InitStruct); - LL_USART_SetTXFIFOThreshold(USART1, LL_USART_FIFOTHRESHOLD_1_8); - LL_USART_SetRXFIFOThreshold(USART1, LL_USART_FIFOTHRESHOLD_1_8); - LL_USART_DisableFIFO(USART1); - LL_USART_ConfigAsyncMode(USART1); - - /* USER CODE BEGIN WKUPType USART1 */ - - /* USER CODE END WKUPType USART1 */ - - LL_USART_Enable(USART1); - - /* Polling USART1 initialisation */ - while ((!(LL_USART_IsActiveFlag_TEACK(USART1))) || (!(LL_USART_IsActiveFlag_REACK(USART1)))) {} - /* USER CODE BEGIN USART1_Init 2 */ - - /* USER CODE END USART1_Init 2 */ -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ diff --git a/G4PERTESTING/G4PERTESTING.ioc b/G4PERTESTING/G4PERTESTING.ioc deleted file mode 100644 index 8cf1860b1..000000000 --- a/G4PERTESTING/G4PERTESTING.ioc +++ /dev/null @@ -1,382 +0,0 @@ -#MicroXplorer Configuration settings - do not modify -ADC1.Channel-2\#ChannelRegularConversion=ADC_CHANNEL_5 -ADC1.Channel-3\#ChannelRegularConversion=ADC_CHANNEL_7 -ADC1.Channel-4\#ChannelRegularConversion=ADC_CHANNEL_8 -ADC1.Channel-5\#ChannelRegularConversion=ADC_CHANNEL_9 -ADC1.Channel-6\#ChannelRegularConversion=ADC_CHANNEL_12 -ADC1.Channel-7\#ChannelRegularConversion=ADC_CHANNEL_15 -ADC1.ClockPrescaler=ADC_CLOCK_ASYNC_DIV256 -ADC1.CommonPathInternal=null|null|null|null -ADC1.ContinuousConvMode=ENABLE -ADC1.DMAContinuousRequests=ENABLE -ADC1.EOCSelection=ADC_EOC_SEQ_CONV -ADC1.ExternalTrigConv=ADC_SOFTWARE_START -ADC1.IPParameters=Rank-2\#ChannelRegularConversion,Channel-2\#ChannelRegularConversion,SamplingTime-2\#ChannelRegularConversion,OffsetNumber-2\#ChannelRegularConversion,NbrOfConversionFlag,master,Rank-3\#ChannelRegularConversion,Channel-3\#ChannelRegularConversion,SamplingTime-3\#ChannelRegularConversion,OffsetNumber-3\#ChannelRegularConversion,Rank-4\#ChannelRegularConversion,Channel-4\#ChannelRegularConversion,SamplingTime-4\#ChannelRegularConversion,OffsetNumber-4\#ChannelRegularConversion,Rank-5\#ChannelRegularConversion,Channel-5\#ChannelRegularConversion,SamplingTime-5\#ChannelRegularConversion,OffsetNumber-5\#ChannelRegularConversion,Rank-6\#ChannelRegularConversion,Channel-6\#ChannelRegularConversion,SamplingTime-6\#ChannelRegularConversion,OffsetNumber-6\#ChannelRegularConversion,Rank-7\#ChannelRegularConversion,Channel-7\#ChannelRegularConversion,SamplingTime-7\#ChannelRegularConversion,OffsetNumber-7\#ChannelRegularConversion,NbrOfConversion,ContinuousConvMode,DMAContinuousRequests,ClockPrescaler,EOCSelection,ExternalTrigConv,CommonPathInternal -ADC1.NbrOfConversion=6 -ADC1.NbrOfConversionFlag=1 -ADC1.OffsetNumber-2\#ChannelRegularConversion=ADC_OFFSET_NONE -ADC1.OffsetNumber-3\#ChannelRegularConversion=ADC_OFFSET_NONE -ADC1.OffsetNumber-4\#ChannelRegularConversion=ADC_OFFSET_NONE -ADC1.OffsetNumber-5\#ChannelRegularConversion=ADC_OFFSET_NONE -ADC1.OffsetNumber-6\#ChannelRegularConversion=ADC_OFFSET_NONE -ADC1.OffsetNumber-7\#ChannelRegularConversion=ADC_OFFSET_NONE -ADC1.Rank-2\#ChannelRegularConversion=1 -ADC1.Rank-3\#ChannelRegularConversion=2 -ADC1.Rank-4\#ChannelRegularConversion=3 -ADC1.Rank-5\#ChannelRegularConversion=4 -ADC1.Rank-6\#ChannelRegularConversion=5 -ADC1.Rank-7\#ChannelRegularConversion=6 -ADC1.SamplingTime-2\#ChannelRegularConversion=ADC_SAMPLETIME_92CYCLES_5 -ADC1.SamplingTime-3\#ChannelRegularConversion=ADC_SAMPLETIME_92CYCLES_5 -ADC1.SamplingTime-4\#ChannelRegularConversion=ADC_SAMPLETIME_92CYCLES_5 -ADC1.SamplingTime-5\#ChannelRegularConversion=ADC_SAMPLETIME_92CYCLES_5 -ADC1.SamplingTime-6\#ChannelRegularConversion=ADC_SAMPLETIME_92CYCLES_5 -ADC1.SamplingTime-7\#ChannelRegularConversion=ADC_SAMPLETIME_92CYCLES_5 -ADC1.master=1 -CAD.formats=[] -CAD.pinconfig=Dual -CAD.provider= -Dma.ADC1.0.Direction=DMA_PERIPH_TO_MEMORY -Dma.ADC1.0.EventEnable=DISABLE -Dma.ADC1.0.Instance=DMA1_Channel1 -Dma.ADC1.0.MemDataAlignment=DMA_MDATAALIGN_HALFWORD -Dma.ADC1.0.MemInc=DMA_MINC_ENABLE -Dma.ADC1.0.Mode=DMA_CIRCULAR -Dma.ADC1.0.PeriphDataAlignment=DMA_PDATAALIGN_HALFWORD -Dma.ADC1.0.PeriphInc=DMA_PINC_DISABLE -Dma.ADC1.0.Polarity=HAL_DMAMUX_REQ_GEN_RISING -Dma.ADC1.0.Priority=DMA_PRIORITY_LOW -Dma.ADC1.0.RequestNumber=1 -Dma.ADC1.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,SignalID,Polarity,RequestNumber,SyncSignalID,SyncPolarity,SyncEnable,EventEnable,SyncRequestNumber -Dma.ADC1.0.SignalID=NONE -Dma.ADC1.0.SyncEnable=DISABLE -Dma.ADC1.0.SyncPolarity=HAL_DMAMUX_SYNC_NO_EVENT -Dma.ADC1.0.SyncRequestNumber=1 -Dma.ADC1.0.SyncSignalID=NONE -Dma.Request0=ADC1 -Dma.RequestsNb=1 -FDCAN2.AutoRetransmission=ENABLE -FDCAN2.CalculateBaudRateNominal=1000000 -FDCAN2.CalculateTimeBitNominal=1000 -FDCAN2.CalculateTimeQuantumNominal=6.25 -FDCAN2.DataPrescaler=8 -FDCAN2.DataSyncJumpWidth=16 -FDCAN2.DataTimeSeg1=14 -FDCAN2.DataTimeSeg2=5 -FDCAN2.ExtFiltersNbr=2 -FDCAN2.FrameFormat=FDCAN_FRAME_CLASSIC -FDCAN2.IPParameters=CalculateTimeQuantumNominal,CalculateTimeBitNominal,CalculateBaudRateNominal,FrameFormat,NominalTimeSeg1,NominalTimeSeg2,NominalPrescaler,AutoRetransmission,StdFiltersNbr,TransmitPause,NominalSyncJumpWidth,DataTimeSeg1,DataTimeSeg2,DataPrescaler,DataSyncJumpWidth,ExtFiltersNbr,ProtocolException -FDCAN2.NominalPrescaler=1 -FDCAN2.NominalSyncJumpWidth=16 -FDCAN2.NominalTimeSeg1=119 -FDCAN2.NominalTimeSeg2=40 -FDCAN2.ProtocolException=ENABLE -FDCAN2.StdFiltersNbr=0 -FDCAN2.TransmitPause=DISABLE -File.Version=6 -GPIO.groupedBy=Group By Peripherals -I2C2.IPParameters=Timing -I2C2.Timing=0x30D29DE4 -KeepUserPlacement=false -LPUART1.BaudRate=115200 -LPUART1.IPParameters=BaudRate -Mcu.CPN=STM32G474RET6 -Mcu.Family=STM32G4 -Mcu.IP0=ADC1 -Mcu.IP1=DMA -Mcu.IP10=USART1 -Mcu.IP2=FDCAN2 -Mcu.IP3=I2C2 -Mcu.IP4=LPUART1 -Mcu.IP5=NVIC -Mcu.IP6=RCC -Mcu.IP7=SPI3 -Mcu.IP8=SYS -Mcu.IP9=TIM2 -Mcu.IPNb=11 -Mcu.Name=STM32G474R(B-C-E)Tx -Mcu.Package=LQFP64 -Mcu.Pin0=PF0-OSC_IN -Mcu.Pin1=PF1-OSC_OUT -Mcu.Pin10=PA7 -Mcu.Pin11=PC4 -Mcu.Pin12=PC5 -Mcu.Pin13=PB0 -Mcu.Pin14=PB1 -Mcu.Pin15=PB11 -Mcu.Pin16=PB12 -Mcu.Pin17=PB13 -Mcu.Pin18=PB14 -Mcu.Pin19=PB15 -Mcu.Pin2=PC1 -Mcu.Pin20=PA8 -Mcu.Pin21=PA11 -Mcu.Pin22=PA12 -Mcu.Pin23=PA13 -Mcu.Pin24=PA14 -Mcu.Pin25=PC10 -Mcu.Pin26=PC11 -Mcu.Pin27=PC12 -Mcu.Pin28=PB3 -Mcu.Pin29=PB4 -Mcu.Pin3=PC2 -Mcu.Pin30=PB5 -Mcu.Pin31=PB6 -Mcu.Pin32=PB7 -Mcu.Pin33=PB8-BOOT0 -Mcu.Pin34=PB9 -Mcu.Pin35=VP_SYS_VS_Systick -Mcu.Pin36=VP_SYS_VS_DBSignals -Mcu.Pin37=VP_TIM2_VS_ClockSourceINT -Mcu.Pin4=PC3 -Mcu.Pin5=PA0 -Mcu.Pin6=PA2 -Mcu.Pin7=PA3 -Mcu.Pin8=PA5 -Mcu.Pin9=PA6 -Mcu.PinsNb=38 -Mcu.ThirdPartyNb=0 -Mcu.UserConstants= -Mcu.UserName=STM32G474RETx -MxCube.Version=6.15.0 -MxDb.Version=DB.6.0.150 -NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.FDCAN2_IT0_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true -NVIC.ForceEnableDMAVector=false -NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:false -NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 -NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:false -NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -PA0.Signal=S_TIM2_CH1 -PA11.Locked=true -PA11.Mode=CTS_RTS -PA11.Signal=USART1_CTS -PA12.Locked=true -PA12.Mode=CTS_RTS -PA12.Signal=USART1_RTS -PA13.Locked=true -PA13.Mode=Trace_Asynchronous_SW -PA13.Signal=SYS_JTMS-SWDIO -PA14.Locked=true -PA14.Mode=Trace_Asynchronous_SW -PA14.Signal=SYS_JTCK-SWCLK -PA2.GPIOParameters=GPIO_Speed -PA2.GPIO_Speed=GPIO_SPEED_FREQ_HIGH -PA2.Locked=true -PA2.Mode=Asynchronous -PA2.Signal=LPUART1_TX -PA3.GPIOParameters=GPIO_Speed -PA3.GPIO_Speed=GPIO_SPEED_FREQ_HIGH -PA3.Locked=true -PA3.Mode=Asynchronous -PA3.Signal=LPUART1_RX -PA5.GPIOParameters=GPIO_Label -PA5.GPIO_Label=BLINKY -PA5.Locked=true -PA5.Signal=GPIO_Output -PA6.GPIOParameters=GPIO_Label -PA6.GPIO_Label=IMD_SENSE -PA6.Locked=true -PA6.Signal=ADC2_IN3 -PA7.GPIOParameters=GPIO_Label -PA7.GPIO_Label=AMS_SENSE -PA7.Locked=true -PA7.Signal=ADC2_IN4 -PA8.Mode=I2C -PA8.Signal=I2C2_SDA -PB0.GPIOParameters=GPIO_Label -PB0.GPIO_Label=BRAKE_F_SIGNAL -PB0.Locked=true -PB0.Mode=IN15-Single-Ended -PB0.Signal=ADC1_IN15 -PB1.GPIOParameters=GPIO_Label -PB1.GPIO_Label=BRAKE_R_SIGNAL -PB1.Locked=true -PB1.Mode=IN12-Single-Ended -PB1.Signal=ADC1_IN12 -PB11.GPIOParameters=GPIO_Label -PB11.GPIO_Label=LED_TEST -PB11.Locked=true -PB11.Signal=GPIO_Output -PB12.GPIOParameters=GPIO_Speed,GPIO_PuPd -PB12.GPIO_PuPd=GPIO_PULLUP -PB12.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH -PB12.Locked=true -PB12.Mode=FDCAN_Activate -PB12.Signal=FDCAN2_RX -PB13.GPIOParameters=GPIO_Speed -PB13.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH -PB13.Locked=true -PB13.Mode=FDCAN_Activate -PB13.Signal=FDCAN2_TX -PB14.GPIOParameters=GPIO_Label -PB14.GPIO_Label=AUX_SIGNAL -PB14.Locked=true -PB14.Mode=IN5-Single-Ended -PB14.Signal=ADC1_IN5 -PB15.GPIOParameters=GPIO_Label -PB15.GPIO_Label=STEERING_ANGLE -PB15.Locked=true -PB15.Signal=ADC2_IN15 -PB3.Locked=true -PB3.Mode=Trace_Asynchronous_SW -PB3.Signal=SYS_JTDO-SWO -PB4.GPIOParameters=GPIO_Label -PB4.GPIO_Label=BRAKE_LIGHT -PB4.Locked=true -PB4.Signal=GPIO_Output -PB5.GPIOParameters=GPIO_Label -PB5.GPIO_Label=TSSI_G_CONTROL -PB5.Locked=true -PB5.Signal=GPIO_Output -PB6.Locked=true -PB6.Mode=Asynchronous -PB6.Signal=USART1_TX -PB7.Locked=true -PB7.Signal=UART4_CTS -PB8-BOOT0.GPIOParameters=GPIO_Label -PB8-BOOT0.GPIO_Label=AUX_CONTROL -PB8-BOOT0.Locked=true -PB8-BOOT0.Signal=GPIO_Output -PB9.GPIOParameters=GPIO_Label -PB9.GPIO_Label=SOFTWARE_OK_CONTROL -PB9.Locked=true -PB9.Signal=GPIO_Output -PC1.GPIOParameters=GPIO_Label -PC1.GPIO_Label=BSPD_SIGNAL -PC1.Locked=true -PC1.Mode=IN7-Single-Ended -PC1.Signal=ADC1_IN7 -PC10.Mode=Full_Duplex_Master -PC10.Signal=SPI3_SCK -PC11.Mode=Full_Duplex_Master -PC11.Signal=SPI3_MISO -PC12.Mode=Full_Duplex_Master -PC12.Signal=SPI3_MOSI -PC2.GPIOParameters=GPIO_Label -PC2.GPIO_Label=APPS1_SIGNAL -PC2.Locked=true -PC2.Mode=IN8-Single-Ended -PC2.Signal=ADC1_IN8 -PC3.GPIOParameters=GPIO_Label -PC3.GPIO_Label=APPS2_SIGNAL -PC3.Locked=true -PC3.Mode=IN9-Single-Ended -PC3.Signal=ADC1_IN9 -PC4.Mode=I2C -PC4.Signal=I2C2_SCL -PC5.Mode=Asynchronous -PC5.Signal=USART1_RX -PF0-OSC_IN.Locked=true -PF0-OSC_IN.Mode=HSE-External-Oscillator -PF0-OSC_IN.Signal=RCC_OSC_IN -PF1-OSC_OUT.Locked=true -PF1-OSC_OUT.Mode=HSE-External-Oscillator -PF1-OSC_OUT.Signal=RCC_OSC_OUT -PinOutPanel.RotationAngle=180 -ProjectManager.AskForMigrate=true -ProjectManager.BackupPrevious=false -ProjectManager.CompilerLinker=GCC -ProjectManager.CompilerOptimize=6 -ProjectManager.ComputerToolchain=false -ProjectManager.CoupleFile=true -ProjectManager.CustomerFirmwarePackage= -ProjectManager.DefaultFWLocation=true -ProjectManager.DeletePrevious=true -ProjectManager.DeviceId=STM32G474RETx -ProjectManager.FirmwarePackage=STM32Cube FW_G4 V1.6.1 -ProjectManager.FreePins=true -ProjectManager.HalAssertFull=false -ProjectManager.HeapSize=0x200 -ProjectManager.KeepUserCode=true -ProjectManager.LastFirmware=true -ProjectManager.LibraryCopy=0 -ProjectManager.MainLocation=Core/Src -ProjectManager.NoMain=false -ProjectManager.PreviousToolchain= -ProjectManager.ProjectBuild=false -ProjectManager.ProjectFileName=G4PERTESTING.ioc -ProjectManager.ProjectName=G4PERTESTING -ProjectManager.ProjectStructure= -ProjectManager.RegisterCallBack= -ProjectManager.StackSize=0x400 -ProjectManager.TargetToolchain=CMake -ProjectManager.ToolChainLocation= -ProjectManager.UAScriptAfterPath= -ProjectManager.UAScriptBeforePath= -ProjectManager.UnderRoot=false -ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-LL-false,2-MX_GPIO_Init-GPIO-false-LL-true,3-MX_DMA_Init-DMA-false-LL-true,4-MX_FDCAN2_Init-FDCAN2-false-HAL-true,5-MX_ADC1_Init-ADC1-false-LL-true,6-MX_LPUART1_UART_Init-LPUART1-false-LL-true,7-MX_I2C2_Init-I2C2-false-LL-true,8-MX_USART1_UART_Init-USART1-false-LL-true,9-MX_SPI3_Init-SPI3-false-LL-true,10-MX_TIM2_Init-TIM2-false-LL-true -RCC.ADC12Freq_Value=160000000 -RCC.ADC345Freq_Value=160000000 -RCC.AHBFreq_Value=160000000 -RCC.APB1Freq_Value=160000000 -RCC.APB1TimFreq_Value=160000000 -RCC.APB2Freq_Value=160000000 -RCC.APB2TimFreq_Value=160000000 -RCC.CRSFreq_Value=48000000 -RCC.CortexFreq_Value=160000000 -RCC.EXTERNAL_CLOCK_VALUE=12288000 -RCC.EnbaleCSS=true -RCC.FCLKCortexFreq_Value=160000000 -RCC.FDCANFreq_Value=160000000 -RCC.FamilyName=M -RCC.HCLKFreq_Value=160000000 -RCC.HRTIM1Freq_Value=160000000 -RCC.HSE_VALUE=16000000 -RCC.HSI48_VALUE=48000000 -RCC.HSI_VALUE=16000000 -RCC.I2C1Freq_Value=160000000 -RCC.I2C2Freq_Value=160000000 -RCC.I2C3Freq_Value=160000000 -RCC.I2C4Freq_Value=160000000 -RCC.I2SFreq_Value=160000000 -RCC.IPParameters=ADC12Freq_Value,ADC345Freq_Value,AHBFreq_Value,APB1Freq_Value,APB1TimFreq_Value,APB2Freq_Value,APB2TimFreq_Value,CRSFreq_Value,CortexFreq_Value,EXTERNAL_CLOCK_VALUE,EnbaleCSS,FCLKCortexFreq_Value,FDCANFreq_Value,FamilyName,HCLKFreq_Value,HRTIM1Freq_Value,HSE_VALUE,HSI48_VALUE,HSI_VALUE,I2C1Freq_Value,I2C2Freq_Value,I2C3Freq_Value,I2C4Freq_Value,I2SFreq_Value,LPTIM1Freq_Value,LPUART1Freq_Value,LSCOPinFreq_Value,LSE_VALUE,LSI_VALUE,MCO1PinFreq_Value,PLLN,PLLPoutputFreq_Value,PLLQoutputFreq_Value,PLLRCLKFreq_Value,PLLSourceVirtual,PWRFreq_Value,QSPIFreq_Value,RNGFreq_Value,SAI1Freq_Value,SYSCLKFreq_VALUE,SYSCLKSource,UART4Freq_Value,UART5Freq_Value,USART1Freq_Value,USART2Freq_Value,USART3Freq_Value,USBFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value -RCC.LPTIM1Freq_Value=160000000 -RCC.LPUART1Freq_Value=160000000 -RCC.LSCOPinFreq_Value=32000 -RCC.LSE_VALUE=32768 -RCC.LSI_VALUE=32000 -RCC.MCO1PinFreq_Value=16000000 -RCC.PLLN=20 -RCC.PLLPoutputFreq_Value=160000000 -RCC.PLLQoutputFreq_Value=160000000 -RCC.PLLRCLKFreq_Value=160000000 -RCC.PLLSourceVirtual=RCC_PLLSOURCE_HSE -RCC.PWRFreq_Value=160000000 -RCC.QSPIFreq_Value=160000000 -RCC.RNGFreq_Value=160000000 -RCC.SAI1Freq_Value=160000000 -RCC.SYSCLKFreq_VALUE=160000000 -RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK -RCC.UART4Freq_Value=160000000 -RCC.UART5Freq_Value=160000000 -RCC.USART1Freq_Value=160000000 -RCC.USART2Freq_Value=160000000 -RCC.USART3Freq_Value=160000000 -RCC.USBFreq_Value=160000000 -RCC.VCOInputFreq_Value=16000000 -RCC.VCOOutputFreq_Value=320000000 -SH.S_TIM2_CH1.0=TIM2_CH1,Forced Output1 CH1 -SH.S_TIM2_CH1.ConfNb=1 -SPI3.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_32 -SPI3.CalculateBaudRate=5.0 MBits/s -SPI3.Direction=SPI_DIRECTION_2LINES -SPI3.IPParameters=VirtualType,Mode,Direction,BaudRatePrescaler,CalculateBaudRate -SPI3.Mode=SPI_MODE_MASTER -SPI3.VirtualType=VM_MASTER -TIM2.Channel-Forced\ Output1\ CH1=TIM_CHANNEL_1 -TIM2.IPParameters=Channel-Forced Output1 CH1 -USART1.IPParameters=VirtualMode-Asynchronous -USART1.VirtualMode-Asynchronous=VM_ASYNC -VP_SYS_VS_DBSignals.Mode=DisableDeadBatterySignals -VP_SYS_VS_DBSignals.Signal=SYS_VS_DBSignals -VP_SYS_VS_Systick.Mode=SysTick -VP_SYS_VS_Systick.Signal=SYS_VS_Systick -VP_TIM2_VS_ClockSourceINT.Mode=Internal -VP_TIM2_VS_ClockSourceINT.Signal=TIM2_VS_ClockSourceINT -board=custom diff --git a/G4PERTESTING/README.md b/G4PERTESTING/README.md deleted file mode 100644 index 099ac620f..000000000 --- a/G4PERTESTING/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# STM32G474 ADC -Nucleo-G474RE-C04 - -Plug in the board following ST-LINK pinout -Compile and flash G4ADCTESTING.elf diff --git a/G4SPITESTING/CMakeLists.txt b/G4SPITESTING/CMakeLists.txt deleted file mode 100644 index d965f1c66..000000000 --- a/G4SPITESTING/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ -cmake_minimum_required(VERSION 3.25) - -# Setup compiler settings -set(CMAKE_C_STANDARD 11) -set(CMAKE_C_STANDARD_REQUIRED ON) -set(CMAKE_C_EXTENSIONS ON) - -# Define the build type -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Debug") -endif() - -# Enable compile command to ease indexing with e.g. clangd -set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE) - -# Enable CMake support for ASM and C languages -enable_language( - C - ASM -) - -# Core project settings -project(${CMAKE_PROJECT_NAME}) - -# what, does in fact not get the filename of somthing but rather the name of the project from the path -get_filename_component(PROJECT_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME) - -add_library(${PROJECT_NAME}_USER_CODE INTERFACE) -target_sources( - ${PROJECT_NAME}_USER_CODE - INTERFACE - Core/Src/main.c - Core/Src/stm32g4xx_hal_msp.c - Core/Src/stm32g4xx_it.c -) - -target_link_libraries(${PROJECT_NAME}_USER_CODE INTERFACE SPI_Lib) - -target_include_directories(${PROJECT_NAME}_USER_CODE INTERFACE Core/Inc) diff --git a/G4SPITESTING/Core/Inc/main.h b/G4SPITESTING/Core/Inc/main.h deleted file mode 100644 index 9ff00d051..000000000 --- a/G4SPITESTING/Core/Inc/main.h +++ /dev/null @@ -1,116 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file : main.h - * @brief : Header for main.c file. - * This file contains the common defines of the application. - ****************************************************************************** - * @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 __MAIN_H -#define __MAIN_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32g4xx_hal.h" -#include "stm32g4xx_ll_adc.h" -#include "stm32g4xx_ll_bus.h" -#include "stm32g4xx_ll_cortex.h" -#include "stm32g4xx_ll_crs.h" -#include "stm32g4xx_ll_dma.h" -#include "stm32g4xx_ll_exti.h" -#include "stm32g4xx_ll_gpio.h" -#include "stm32g4xx_ll_i2c.h" -#include "stm32g4xx_ll_lpuart.h" -#include "stm32g4xx_ll_pwr.h" -#include "stm32g4xx_ll_rcc.h" -#include "stm32g4xx_ll_spi.h" -#include "stm32g4xx_ll_system.h" -#include "stm32g4xx_ll_tim.h" -#include "stm32g4xx_ll_usart.h" -#include "stm32g4xx_ll_utils.h" - -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ -#include -#include -/* USER CODE END Includes */ - -/* Exported types ------------------------------------------------------------*/ -/* USER CODE BEGIN ET */ - -/* USER CODE END ET */ - -/* Exported constants --------------------------------------------------------*/ -/* USER CODE BEGIN EC */ - -/* USER CODE END EC */ - -/* Exported macro ------------------------------------------------------------*/ -/* USER CODE BEGIN EM */ - -/* USER CODE END EM */ - -/* Exported functions prototypes ---------------------------------------------*/ -void Error_Handler(void); - -/* USER CODE BEGIN EFP */ - -/* USER CODE END EFP */ - -/* Private defines -----------------------------------------------------------*/ -#define BSPD_SIGNAL_Pin LL_GPIO_PIN_1 -#define BSPD_SIGNAL_GPIO_Port GPIOC -#define APPS1_SIGNAL_Pin LL_GPIO_PIN_2 -#define APPS1_SIGNAL_GPIO_Port GPIOC -#define APPS2_SIGNAL_Pin LL_GPIO_PIN_3 -#define APPS2_SIGNAL_GPIO_Port GPIOC -#define BLINKY_Pin LL_GPIO_PIN_5 -#define BLINKY_GPIO_Port GPIOA -#define IMD_SENSE_Pin LL_GPIO_PIN_6 -#define IMD_SENSE_GPIO_Port GPIOA -#define AMS_SENSE_Pin LL_GPIO_PIN_7 -#define AMS_SENSE_GPIO_Port GPIOA -#define BRAKE_F_SIGNAL_Pin LL_GPIO_PIN_0 -#define BRAKE_F_SIGNAL_GPIO_Port GPIOB -#define BRAKE_R_SIGNAL_Pin LL_GPIO_PIN_1 -#define BRAKE_R_SIGNAL_GPIO_Port GPIOB -#define LED_TEST_Pin LL_GPIO_PIN_11 -#define LED_TEST_GPIO_Port GPIOB -#define AUX_SIGNAL_Pin LL_GPIO_PIN_14 -#define AUX_SIGNAL_GPIO_Port GPIOB -#define STEERING_ANGLE_Pin LL_GPIO_PIN_15 -#define STEERING_ANGLE_GPIO_Port GPIOB -#define BRAKE_LIGHT_Pin LL_GPIO_PIN_4 -#define BRAKE_LIGHT_GPIO_Port GPIOB -#define TSSI_G_CONTROL_Pin LL_GPIO_PIN_5 -#define TSSI_G_CONTROL_GPIO_Port GPIOB -#define AUX_CONTROL_Pin LL_GPIO_PIN_8 -#define AUX_CONTROL_GPIO_Port GPIOB -#define SOFTWARE_OK_CONTROL_Pin LL_GPIO_PIN_9 -#define SOFTWARE_OK_CONTROL_GPIO_Port GPIOB - -/* USER CODE BEGIN Private defines */ - -/* USER CODE END Private defines */ - -#ifdef __cplusplus -} -#endif - -#endif /* __MAIN_H */ diff --git a/G4SPITESTING/Core/Inc/stm32_assert.h b/G4SPITESTING/Core/Inc/stm32_assert.h deleted file mode 100644 index 92460620f..000000000 --- a/G4SPITESTING/Core/Inc/stm32_assert.h +++ /dev/null @@ -1,52 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file stm32_assert.h - * @author MCD Application Team - * @brief STM32 assert file. - ****************************************************************************** - * @attention - * - * Copyright (c) 2019 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 __STM32_ASSERT_H -#define __STM32_ASSERT_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Exported types ------------------------------------------------------------*/ -/* Exported constants --------------------------------------------------------*/ -/* Includes ------------------------------------------------------------------*/ -/* Exported macro ------------------------------------------------------------*/ -#ifdef USE_FULL_ASSERT -/** - * @brief The assert_param macro is used for function's parameters check. - * @param expr: If expr is false, it calls assert_failed function - * which reports the name of the source file and the source - * line number of the call that failed. - * If expr is true, it returns no value. - * @retval None - */ -#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) -/* Exported functions ------------------------------------------------------- */ -void assert_failed(uint8_t *file, uint32_t line); -#else -#define assert_param(expr) ((void)0U) -#endif /* USE_FULL_ASSERT */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32_ASSERT_H */ diff --git a/G4SPITESTING/Core/Inc/stm32g4xx_hal_conf.h b/G4SPITESTING/Core/Inc/stm32g4xx_hal_conf.h deleted file mode 100644 index 3e1fcb018..000000000 --- a/G4SPITESTING/Core/Inc/stm32g4xx_hal_conf.h +++ /dev/null @@ -1,390 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file stm32g4xx_hal_conf.h - * @author MCD Application Team - * @brief HAL configuration file - ****************************************************************************** - * @attention - * - * Copyright (c) 2019 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 STM32G4xx_HAL_CONF_H -#define STM32G4xx_HAL_CONF_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Exported types ------------------------------------------------------------*/ -/* Exported constants --------------------------------------------------------*/ - -/* ########################## Module Selection ############################## */ -/** - * @brief This is the list of modules to be used in the HAL driver - */ - -#define HAL_MODULE_ENABLED - -/*#define HAL_ADC_MODULE_ENABLED */ -/*#define HAL_COMP_MODULE_ENABLED */ -/*#define HAL_CORDIC_MODULE_ENABLED */ -#define HAL_CRC_MODULE_ENABLED -/*#define HAL_CRYP_MODULE_ENABLED */ -/*#define HAL_DAC_MODULE_ENABLED */ -#define HAL_FDCAN_MODULE_ENABLED -/*#define HAL_FMAC_MODULE_ENABLED */ -/*#define HAL_HRTIM_MODULE_ENABLED */ -/*#define HAL_IRDA_MODULE_ENABLED */ -/*#define HAL_IWDG_MODULE_ENABLED */ -/*#define HAL_I2C_MODULE_ENABLED */ -/*#define HAL_I2S_MODULE_ENABLED */ -/*#define HAL_LPTIM_MODULE_ENABLED */ -/*#define HAL_NAND_MODULE_ENABLED */ -/*#define HAL_NOR_MODULE_ENABLED */ -/*#define HAL_OPAMP_MODULE_ENABLED */ -/*#define HAL_PCD_MODULE_ENABLED */ -/*#define HAL_QSPI_MODULE_ENABLED */ -/*#define HAL_RNG_MODULE_ENABLED */ -/*#define HAL_RTC_MODULE_ENABLED */ -/*#define HAL_SAI_MODULE_ENABLED */ -/*#define HAL_SMARTCARD_MODULE_ENABLED */ -/*#define HAL_SMBUS_MODULE_ENABLED */ -/*#define HAL_SPI_MODULE_ENABLED */ -/*#define HAL_SRAM_MODULE_ENABLED */ -/*#define HAL_TIM_MODULE_ENABLED */ -/*#define HAL_UART_MODULE_ENABLED */ -/*#define HAL_USART_MODULE_ENABLED */ -/*#define HAL_WWDG_MODULE_ENABLED */ -#define HAL_GPIO_MODULE_ENABLED -#define HAL_EXTI_MODULE_ENABLED -#define HAL_DMA_MODULE_ENABLED -#define HAL_RCC_MODULE_ENABLED -#define HAL_FLASH_MODULE_ENABLED -#define HAL_PWR_MODULE_ENABLED -#define HAL_CORTEX_MODULE_ENABLED - -/* ########################## Register Callbacks selection - * ############################## */ -/** - * @brief This is the list of modules where register callback can be used - */ -#define USE_HAL_ADC_REGISTER_CALLBACKS 0U -#define USE_HAL_COMP_REGISTER_CALLBACKS 0U -#define USE_HAL_CORDIC_REGISTER_CALLBACKS 0U -#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U -#define USE_HAL_DAC_REGISTER_CALLBACKS 0U -#define USE_HAL_EXTI_REGISTER_CALLBACKS 0U -#define USE_HAL_FDCAN_REGISTER_CALLBACKS 0U -#define USE_HAL_FMAC_REGISTER_CALLBACKS 0U -#define USE_HAL_HRTIM_REGISTER_CALLBACKS 0U -#define USE_HAL_I2C_REGISTER_CALLBACKS 0U -#define USE_HAL_I2S_REGISTER_CALLBACKS 0U -#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U -#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U -#define USE_HAL_NAND_REGISTER_CALLBACKS 0U -#define USE_HAL_NOR_REGISTER_CALLBACKS 0U -#define USE_HAL_OPAMP_REGISTER_CALLBACKS 0U -#define USE_HAL_PCD_REGISTER_CALLBACKS 0U -#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U -#define USE_HAL_RNG_REGISTER_CALLBACKS 0U -#define USE_HAL_RTC_REGISTER_CALLBACKS 0U -#define USE_HAL_SAI_REGISTER_CALLBACKS 0U -#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U -#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U -#define USE_HAL_SPI_REGISTER_CALLBACKS 0U -#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U -#define USE_HAL_TIM_REGISTER_CALLBACKS 0U -#define USE_HAL_UART_REGISTER_CALLBACKS 0U -#define USE_HAL_USART_REGISTER_CALLBACKS 0U -#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U - -/* ########################## Oscillator Values adaptation - * ####################*/ -/** - * @brief Adjust the value of External High Speed oscillator (HSE) used in your - * application. This value is used by the RCC HAL module to compute the system - * frequency (when HSE is used as system clock source, directly or through the - * PLL). - */ -#if !defined(HSE_VALUE) -#define HSE_VALUE (16000000UL) /*!< Value of the External oscillator in Hz */ -#endif /* HSE_VALUE */ - -#if !defined(HSE_STARTUP_TIMEOUT) -#define HSE_STARTUP_TIMEOUT (100UL) /*!< Time out for HSE start up, in ms */ -#endif /* HSE_STARTUP_TIMEOUT */ - -/** - * @brief Internal High Speed oscillator (HSI) value. - * This value is used by the RCC HAL module to compute the system - * frequency (when HSI is used as system clock source, directly or through the - * PLL). - */ -#if !defined(HSI_VALUE) -#define HSI_VALUE (16000000UL) /*!< Value of the Internal oscillator in Hz*/ -#endif /* HSI_VALUE */ - -/** - * @brief Internal High Speed oscillator (HSI48) value for USB FS and RNG. - * This internal oscillator is mainly dedicated to provide a high - * precision clock to the USB peripheral by means of a special Clock Recovery - * System (CRS) circuitry. When the CRS is not used, the HSI48 RC oscillator - * runs on it default frequency which is subject to manufacturing process - * variations. - */ -#if !defined(HSI48_VALUE) -#define HSI48_VALUE \ - (48000000UL) /*!< Value of the Internal High Speed oscillator for USB \ - FS/RNG in Hz. The real value my vary depending on \ - manufacturing process variations.*/ -#endif /* HSI48_VALUE */ - -/** - * @brief Internal Low Speed oscillator (LSI) value. - */ -#if !defined(LSI_VALUE) -/*!< Value of the Internal Low Speed oscillator in Hz -The real value may vary depending on the variations in voltage and -temperature.*/ -#define LSI_VALUE (32000UL) /*!< LSI Typical Value in Hz*/ -#endif /* LSI_VALUE */ -/** - * @brief External Low Speed oscillator (LSE) value. - * This value is used by the UART, RTC HAL module to compute the system - * frequency - */ -#if !defined(LSE_VALUE) -#define LSE_VALUE (32768UL) /*!< Value of the External Low Speed oscillator in Hz */ -#endif /* LSE_VALUE */ - -#if !defined(LSE_STARTUP_TIMEOUT) -#define LSE_STARTUP_TIMEOUT (5000UL) /*!< Time out for LSE start up, in ms */ -#endif /* LSE_STARTUP_TIMEOUT */ - -/** - * @brief External clock source for I2S and SAI peripherals - * This value is used by the I2S and SAI HAL modules to compute the I2S - * and SAI clock source frequency, this source is inserted directly through - * I2S_CKIN pad. - */ -#if !defined(EXTERNAL_CLOCK_VALUE) -#define EXTERNAL_CLOCK_VALUE (12288000UL) /*!< Value of the External oscillator in Hz*/ -#endif /* EXTERNAL_CLOCK_VALUE */ - -/* Tip: To avoid modifying this file each time you need to use different HSE, - === you can define the HSE value in your toolchain compiler preprocessor. */ - -/* ########################### System Configuration ######################### */ -/** - * @brief This is the HAL system configuration section - */ - -#define VDD_VALUE (3300UL) /*!< Value of VDD in mv */ -#define TICK_INT_PRIORITY (15UL) /*!< tick interrupt priority (lowest by default) */ -#define USE_RTOS 0U -#define PREFETCH_ENABLE 0U -#define INSTRUCTION_CACHE_ENABLE 1U -#define DATA_CACHE_ENABLE 1U - -/* ########################## Assert Selection ############################## */ -/** - * @brief Uncomment the line below to expanse the "assert_param" macro in the - * HAL drivers code - */ -/* #define USE_FULL_ASSERT 1U */ - -/* ################## SPI peripheral configuration ########################## */ - -/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver - * Activated: CRC code is present inside driver - * Deactivated: CRC code cleaned from driver - */ - -#define USE_SPI_CRC 0U - -/* Includes ------------------------------------------------------------------*/ -/** - * @brief Include module's header file - */ - -#ifdef HAL_RCC_MODULE_ENABLED -#include "stm32g4xx_hal_rcc.h" -#endif /* HAL_RCC_MODULE_ENABLED */ - -#ifdef HAL_GPIO_MODULE_ENABLED -#include "stm32g4xx_hal_gpio.h" -#endif /* HAL_GPIO_MODULE_ENABLED */ - -#ifdef HAL_DMA_MODULE_ENABLED -#include "stm32g4xx_hal_dma.h" -#endif /* HAL_DMA_MODULE_ENABLED */ - -#ifdef HAL_CORTEX_MODULE_ENABLED -#include "stm32g4xx_hal_cortex.h" -#endif /* HAL_CORTEX_MODULE_ENABLED */ - -#ifdef HAL_ADC_MODULE_ENABLED -#include "stm32g4xx_hal_adc.h" -#endif /* HAL_ADC_MODULE_ENABLED */ - -#ifdef HAL_COMP_MODULE_ENABLED -#include "stm32g4xx_hal_comp.h" -#endif /* HAL_COMP_MODULE_ENABLED */ - -#ifdef HAL_CORDIC_MODULE_ENABLED -#include "stm32g4xx_hal_cordic.h" -#endif /* HAL_CORDIC_MODULE_ENABLED */ - -#ifdef HAL_CRC_MODULE_ENABLED -#include "stm32g4xx_hal_crc.h" -#endif /* HAL_CRC_MODULE_ENABLED */ - -#ifdef HAL_CRYP_MODULE_ENABLED -#include "stm32g4xx_hal_cryp.h" -#endif /* HAL_CRYP_MODULE_ENABLED */ - -#ifdef HAL_DAC_MODULE_ENABLED -#include "stm32g4xx_hal_dac.h" -#endif /* HAL_DAC_MODULE_ENABLED */ - -#ifdef HAL_EXTI_MODULE_ENABLED -#include "stm32g4xx_hal_exti.h" -#endif /* HAL_EXTI_MODULE_ENABLED */ - -#ifdef HAL_FDCAN_MODULE_ENABLED -#include "stm32g4xx_hal_fdcan.h" -#endif /* HAL_FDCAN_MODULE_ENABLED */ - -#ifdef HAL_FLASH_MODULE_ENABLED -#include "stm32g4xx_hal_flash.h" -#endif /* HAL_FLASH_MODULE_ENABLED */ - -#ifdef HAL_FMAC_MODULE_ENABLED -#include "stm32g4xx_hal_fmac.h" -#endif /* HAL_FMAC_MODULE_ENABLED */ - -#ifdef HAL_HRTIM_MODULE_ENABLED -#include "stm32g4xx_hal_hrtim.h" -#endif /* HAL_HRTIM_MODULE_ENABLED */ - -#ifdef HAL_IRDA_MODULE_ENABLED -#include "stm32g4xx_hal_irda.h" -#endif /* HAL_IRDA_MODULE_ENABLED */ - -#ifdef HAL_IWDG_MODULE_ENABLED -#include "stm32g4xx_hal_iwdg.h" -#endif /* HAL_IWDG_MODULE_ENABLED */ - -#ifdef HAL_I2C_MODULE_ENABLED -#include "stm32g4xx_hal_i2c.h" -#endif /* HAL_I2C_MODULE_ENABLED */ - -#ifdef HAL_I2S_MODULE_ENABLED -#include "stm32g4xx_hal_i2s.h" -#endif /* HAL_I2S_MODULE_ENABLED */ - -#ifdef HAL_LPTIM_MODULE_ENABLED -#include "stm32g4xx_hal_lptim.h" -#endif /* HAL_LPTIM_MODULE_ENABLED */ - -#ifdef HAL_NAND_MODULE_ENABLED -#include "stm32g4xx_hal_nand.h" -#endif /* HAL_NAND_MODULE_ENABLED */ - -#ifdef HAL_NOR_MODULE_ENABLED -#include "stm32g4xx_hal_nor.h" -#endif /* HAL_NOR_MODULE_ENABLED */ - -#ifdef HAL_OPAMP_MODULE_ENABLED -#include "stm32g4xx_hal_opamp.h" -#endif /* HAL_OPAMP_MODULE_ENABLED */ - -#ifdef HAL_PCD_MODULE_ENABLED -#include "stm32g4xx_hal_pcd.h" -#endif /* HAL_PCD_MODULE_ENABLED */ - -#ifdef HAL_PWR_MODULE_ENABLED -#include "stm32g4xx_hal_pwr.h" -#endif /* HAL_PWR_MODULE_ENABLED */ - -#ifdef HAL_QSPI_MODULE_ENABLED -#include "stm32g4xx_hal_qspi.h" -#endif /* HAL_QSPI_MODULE_ENABLED */ - -#ifdef HAL_RNG_MODULE_ENABLED -#include "stm32g4xx_hal_rng.h" -#endif /* HAL_RNG_MODULE_ENABLED */ - -#ifdef HAL_RTC_MODULE_ENABLED -#include "stm32g4xx_hal_rtc.h" -#endif /* HAL_RTC_MODULE_ENABLED */ - -#ifdef HAL_SAI_MODULE_ENABLED -#include "stm32g4xx_hal_sai.h" -#endif /* HAL_SAI_MODULE_ENABLED */ - -#ifdef HAL_SMARTCARD_MODULE_ENABLED -#include "stm32g4xx_hal_smartcard.h" -#endif /* HAL_SMARTCARD_MODULE_ENABLED */ - -#ifdef HAL_SMBUS_MODULE_ENABLED -#include "stm32g4xx_hal_smbus.h" -#endif /* HAL_SMBUS_MODULE_ENABLED */ - -#ifdef HAL_SPI_MODULE_ENABLED -#include "stm32g4xx_hal_spi.h" -#endif /* HAL_SPI_MODULE_ENABLED */ - -#ifdef HAL_SRAM_MODULE_ENABLED -#include "stm32g4xx_hal_sram.h" -#endif /* HAL_SRAM_MODULE_ENABLED */ - -#ifdef HAL_TIM_MODULE_ENABLED -#include "stm32g4xx_hal_tim.h" -#endif /* HAL_TIM_MODULE_ENABLED */ - -#ifdef HAL_UART_MODULE_ENABLED -#include "stm32g4xx_hal_uart.h" -#endif /* HAL_UART_MODULE_ENABLED */ - -#ifdef HAL_USART_MODULE_ENABLED -#include "stm32g4xx_hal_usart.h" -#endif /* HAL_USART_MODULE_ENABLED */ - -#ifdef HAL_WWDG_MODULE_ENABLED -#include "stm32g4xx_hal_wwdg.h" -#endif /* HAL_WWDG_MODULE_ENABLED */ - -/* Exported macro ------------------------------------------------------------*/ -#ifdef USE_FULL_ASSERT -/** - * @brief The assert_param macro is used for function's parameters check. - * @param expr: If expr is false, it calls assert_failed function - * which reports the name of the source file and the source - * line number of the call that failed. - * If expr is true, it returns no value. - * @retval None - */ -#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) -/* Exported functions ------------------------------------------------------- */ -void assert_failed(uint8_t *file, uint32_t line); -#else -#define assert_param(expr) ((void)0U) -#endif /* USE_FULL_ASSERT */ - -#ifdef __cplusplus -} -#endif - -#endif /* STM32G4xx_HAL_CONF_H */ diff --git a/G4SPITESTING/Core/Inc/stm32g4xx_it.h b/G4SPITESTING/Core/Inc/stm32g4xx_it.h deleted file mode 100644 index b6c3b2f72..000000000 --- a/G4SPITESTING/Core/Inc/stm32g4xx_it.h +++ /dev/null @@ -1,67 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file stm32g4xx_it.h - * @brief This file contains the headers of the interrupt handlers. - ****************************************************************************** - * @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 __STM32G4xx_IT_H -#define __STM32G4xx_IT_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* Exported types ------------------------------------------------------------*/ -/* USER CODE BEGIN ET */ - -/* USER CODE END ET */ - -/* Exported constants --------------------------------------------------------*/ -/* USER CODE BEGIN EC */ - -/* USER CODE END EC */ - -/* Exported macro ------------------------------------------------------------*/ -/* USER CODE BEGIN EM */ - -/* USER CODE END EM */ - -/* Exported functions prototypes ---------------------------------------------*/ -void NMI_Handler(void); -void HardFault_Handler(void); -void MemManage_Handler(void); -void BusFault_Handler(void); -void UsageFault_Handler(void); -void SVC_Handler(void); -void DebugMon_Handler(void); -void PendSV_Handler(void); -void SysTick_Handler(void); -void FDCAN2_IT0_IRQHandler(void); -/* USER CODE BEGIN EFP */ - -/* USER CODE END EFP */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32G4xx_IT_H */ diff --git a/G4SPITESTING/Core/Src/main.c b/G4SPITESTING/Core/Src/main.c deleted file mode 100644 index 539e27d8f..000000000 --- a/G4SPITESTING/Core/Src/main.c +++ /dev/null @@ -1,298 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file : main.c - * @brief : Main program body - ****************************************************************************** - * @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 "main.h" - -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ -#include - -#include "Logomatic.h" -#include "spi.h" -/* USER CODE END Includes */ - -/* Private typedef -----------------------------------------------------------*/ -/* USER CODE BEGIN PTD */ - -/* USER CODE END PTD */ - -/* Private define ------------------------------------------------------------*/ -/* USER CODE BEGIN PD */ - -/* USER CODE END PD */ - -/* Private macro -------------------------------------------------------------*/ -/* USER CODE BEGIN PM */ - -/* USER CODE END PM */ - -/* Private variables ---------------------------------------------------------*/ - -/* USER CODE BEGIN PV */ -LogomaticConfig logomaticConfig = {.clock_source = LOGOMATIC_PCLK1, - .bus = LOGOMATIC_BUS, - .gpio_port = LOGOMATIC_GPIOA, - .gpio_pin_rx_tx_mask = LL_GPIO_PIN_2 | LL_GPIO_PIN_3, - .baud_rate = 115200, - .data_width = LOGOMATIC_DATAWIDTH_8B, - .stop_bits = LOGOMATIC_STOPBITS_1, - .parity = LOGOMATIC_PARITY_NONE, - .transfer_direction = LOGOMATIC_DIRECTION_TX, - .hardware_flow_control = LOGOMATIC_HWCONTROL_NONE, - .prescaler = LOGOMATIC_PRESCALER_DIV1, - .tx_fifo_threshold = LOGOMATIC_FIFOTHRESHOLD_1_8, - .rx_fifo_threshold = LOGOMATIC_FIFOTHRESHOLD_1_8}; -/* USER CODE END PV */ - -/* Private function prototypes -----------------------------------------------*/ -void SystemClock_Config(void); -/* USER CODE BEGIN PFP */ - -/* USER CODE END PFP */ - -/* Private user code ---------------------------------------------------------*/ -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/** - * @brief The application entry point. - * @retval int - */ -int main(void) -{ - - /* USER CODE BEGIN 1 */ - static GR_SPI_Handler handle_spi2, handle_spi3; - static LL_SPI_InitTypeDef config_spi2, config_spi3; - static GR_SPI_Pins pins_spi2, pins_spi3; - /*HAL_OSPI_HandleTypeDef hospi; - HAL_StatusTypeDef status;*/ - - /* USER CODE END 1 */ - - /* MCU - * Configuration--------------------------------------------------------*/ - - /* Reset of all peripherals, Initializes the Flash interface and the - * Systick. */ - HAL_Init(); - - /* USER CODE BEGIN Init */ - Setup_Logomatic(&logomaticConfig); - /* USER CODE END Init */ - - /* Configure the system clock */ - SystemClock_Config(); - - /* USER CODE BEGIN SysInit */ - LOGOMATIC("Booted!\n"); - /* USER CODE END SysInit */ - - /* Initialize all configured peripherals */ - /* USER CODE BEGIN 2 */ - LL_mDelay(1000); // Wait for peripherals to stabilize - LOGOMATIC("Booted!\n"); - - // ========== RECEIVER CONFIGURATION ========== - config_spi2.Mode = LL_SPI_MODE_SLAVE; - config_spi2.NSS = LL_SPI_NSS_HARD_INPUT; - config_spi2.TransferDirection = LL_SPI_FULL_DUPLEX; - config_spi2.DataWidth = LL_SPI_DATAWIDTH_8BIT; - config_spi2.ClockPolarity = LL_SPI_POLARITY_LOW; - config_spi2.ClockPhase = LL_SPI_PHASE_1EDGE; - config_spi2.BaudRate = LL_SPI_BAUDRATEPRESCALER_DIV32; - config_spi2.BitOrder = LL_SPI_LSB_FIRST; - config_spi2.CRCCalculation = LL_SPI_CRCCALCULATION_ENABLE; - config_spi2.CRCPoly = 0x1D; - - pins_spi2.SPIx = SPI2; - pins_spi2.COPI_port = GPIOB; - pins_spi2.CIPO_port = GPIOB; - pins_spi2.SCLK_port = GPIOB; - pins_spi2.NCS_port = GPIOB; - pins_spi2.COPI_pin = LL_GPIO_PIN_15; // COPI - pins_spi2.CIPO_pin = LL_GPIO_PIN_14; // CIPO - pins_spi2.SCLK_pin = LL_GPIO_PIN_13; // SCK - pins_spi2.NCS_pin = LL_GPIO_PIN_12; // NSS - pins_spi2.AFN = 5; - - GR_SPI_Initialize(&handle_spi2, &config_spi2, &pins_spi2); - - // ========== SENDER CONFIGURATION ========== - config_spi3.Mode = LL_SPI_MODE_MASTER; - config_spi3.NSS = LL_SPI_NSS_SOFT; - config_spi3.TransferDirection = LL_SPI_FULL_DUPLEX; - config_spi3.DataWidth = LL_SPI_DATAWIDTH_8BIT; - config_spi3.ClockPolarity = LL_SPI_POLARITY_LOW; - config_spi3.ClockPhase = LL_SPI_PHASE_1EDGE; - config_spi3.BaudRate = LL_SPI_BAUDRATEPRESCALER_DIV32; - config_spi3.BitOrder = LL_SPI_LSB_FIRST; - config_spi3.CRCCalculation = LL_SPI_CRCCALCULATION_ENABLE; - config_spi3.CRCPoly = 0x1D; - - // Configure GR_SPI_Pins struct - pins_spi3.SPIx = SPI3; - pins_spi3.COPI_port = GPIOC; - pins_spi3.CIPO_port = GPIOC; - pins_spi3.SCLK_port = GPIOC; - pins_spi3.NCS_port = GPIOA; - pins_spi3.COPI_pin = LL_GPIO_PIN_12; // COPI - pins_spi3.CIPO_pin = LL_GPIO_PIN_11; // CIPO - pins_spi3.SCLK_pin = LL_GPIO_PIN_10; // SCK - pins_spi3.NCS_pin = LL_GPIO_PIN_4; // NSS - pins_spi3.AFN = 6; - - GR_SPI_Initialize(&handle_spi3, &config_spi3, &pins_spi3); - - LOGOMATIC("Starting message transaction...\n"); - - GR_SPI_Message msg; - msg.data = (uint8_t *)malloc(32 * sizeof(uint8_t)); - msg.size = 32; // Must be <= 32 for this example code - - for (int i = 0; i < msg.size; i++) { - msg.data[i] = 'A' + i; - } - - GR_SPI_Send(&handle_spi3, &msg); - - LOGOMATIC("Sent message, now receiving...\n"); - - for (int i = 0; i < msg.size; i++) { - msg.data[i] = '#'; - } - - for (int i = 0; i < msg.size; i++) { - while (GR_SPI_IsRxEmpty(&handle_spi2)) - ; - uint8_t temp_byte; - GR_SPI_Message temp_msg = {0}; - temp_msg.data = &temp_byte; - temp_msg.size = 1; - GR_SPI_Receive(&handle_spi2, &temp_msg); - msg.data[i] = temp_byte; - } - - char str[33]; - memcpy(str, msg.data, msg.size * sizeof(uint8_t)); - str[msg.size] = '\0'; - - LOGOMATIC("Received: %s\n", str); - - free(msg.data); - GR_SPI_Close(&handle_spi2); - GR_SPI_Close(&handle_spi3); - - /* USER CODE END 2 */ - - /* Infinite loop */ - /* USER CODE BEGIN WHILE */ - while (1) { - /* USER CODE END WHILE */ - - // BLINKY - HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_SET); - HAL_Delay(1000); - HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_RESET); - HAL_Delay(1000); - LOGOMATIC("Blinking!\n"); - - /* USER CODE BEGIN 3 */ - } -} - -/* void test_spi_initialize(GR_SPI_Handler* handle, LL_SPI_InitTypeDef* config, -GR_SPI_Pins* pin_config){ if(GR_SPI_Initialize(&handle, &config, &pin_config) -} */ - -/** - * @brief System Clock Configuration - * @retval None - */ -void SystemClock_Config(void) -{ - LL_FLASH_SetLatency(LL_FLASH_LATENCY_4); - while (LL_FLASH_GetLatency() != LL_FLASH_LATENCY_4) {} - LL_PWR_EnableRange1BoostMode(); - LL_RCC_HSI_Enable(); - /* Wait till HSI is ready */ - while (LL_RCC_HSI_IsReady() != 1) {} - - LL_RCC_HSI_SetCalibTrimming(64); - LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSI, LL_RCC_PLLM_DIV_4, 85, LL_RCC_PLLR_DIV_2); - LL_RCC_PLL_EnableDomain_SYS(); - LL_RCC_PLL_Enable(); - /* Wait till PLL is ready */ - while (LL_RCC_PLL_IsReady() != 1) {} - - LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL); - LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_2); - /* Wait till System clock is ready */ - while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL) {} - - /* Insure 1us transition state at intermediate medium speed clock*/ - for (__IO uint32_t i = (170 >> 1); i != 0; i--) - ; - - /* Set AHB prescaler*/ - LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1); - LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1); - LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_1); - LL_SetSystemCoreClock(170000000); - - /* Update the time base */ - if (HAL_InitTick(TICK_INT_PRIORITY) != HAL_OK) { - // status = ERROR; - Error_Handler(); - } -} -/* USER CODE BEGIN 4 */ - -/* USER CODE END 4 */ - -/** - * @brief This function is executed in case of error occurrence. - * @retval None - */ -void Error_Handler(void) -{ - /* USER CODE BEGIN Error_Handler_Debug */ - /* User can add his own implementation to report the HAL error return - * state */ - __disable_irq(); - while (1) {} -} -#ifdef USE_FULL_ASSERT -/** - * @brief Reports the name of the source file and the source line number - * where the assert_param error has occurred. - * @param file: pointer to the source file name - * @param line: assert_param error line source number - * @retval None - */ -void assert_failed(uint8_t *file, uint32_t line) -{ - /* USER CODE BEGIN 6 */ - /* User can add his own implementation to report the file name and line - number, ex: printf("Wrong parameters value: file %s on line %d\r\n", - file, line) */ - /* USER CODE END 6 */ -} -#endif /* USE_FULL_ASSERT */ diff --git a/G4SPITESTING/Core/Src/stm32g4xx_hal_msp.c b/G4SPITESTING/Core/Src/stm32g4xx_hal_msp.c deleted file mode 100644 index 69189ef4e..000000000 --- a/G4SPITESTING/Core/Src/stm32g4xx_hal_msp.c +++ /dev/null @@ -1,86 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file stm32g4xx_hal_msp.c - * @brief This file provides code for the MSP Initialization - * and de-Initialization codes. - ****************************************************************************** - * @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 "main.h" -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* Private typedef -----------------------------------------------------------*/ -/* USER CODE BEGIN TD */ - -/* USER CODE END TD */ - -/* Private define ------------------------------------------------------------*/ -/* USER CODE BEGIN Define */ - -/* USER CODE END Define */ - -/* Private macro -------------------------------------------------------------*/ -/* USER CODE BEGIN Macro */ - -/* USER CODE END Macro */ - -/* Private variables ---------------------------------------------------------*/ -/* USER CODE BEGIN PV */ - -/* USER CODE END PV */ - -/* Private function prototypes -----------------------------------------------*/ -/* USER CODE BEGIN PFP */ - -/* USER CODE END PFP */ - -/* External functions --------------------------------------------------------*/ -/* USER CODE BEGIN ExternalFunctions */ - -/* USER CODE END ExternalFunctions */ - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ -/** - * Initializes the Global MSP. - */ -void HAL_MspInit(void) -{ - - /* USER CODE BEGIN MspInit 0 */ - - /* USER CODE END MspInit 0 */ - - __HAL_RCC_SYSCFG_CLK_ENABLE(); - __HAL_RCC_PWR_CLK_ENABLE(); - - /* System interrupt init*/ - - /** Disable the internal Pull-Up in Dead Battery pins of UCPD peripheral - */ - HAL_PWREx_DisableUCPDDeadBattery(); - - /* USER CODE BEGIN MspInit 1 */ - - /* USER CODE END MspInit 1 */ -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ diff --git a/G4SPITESTING/Core/Src/stm32g4xx_it.c b/G4SPITESTING/Core/Src/stm32g4xx_it.c deleted file mode 100644 index 9549141b0..000000000 --- a/G4SPITESTING/Core/Src/stm32g4xx_it.c +++ /dev/null @@ -1,198 +0,0 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file stm32g4xx_it.c - * @brief Interrupt Service Routines. - ****************************************************************************** - * @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 "stm32g4xx_it.h" - -#include "main.h" -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ -/* USER CODE END Includes */ - -/* Private typedef -----------------------------------------------------------*/ -/* USER CODE BEGIN TD */ - -/* USER CODE END TD */ - -/* Private define ------------------------------------------------------------*/ -/* USER CODE BEGIN PD */ - -/* USER CODE END PD */ - -/* Private macro -------------------------------------------------------------*/ -/* USER CODE BEGIN PM */ - -/* USER CODE END PM */ - -/* Private variables ---------------------------------------------------------*/ -/* USER CODE BEGIN PV */ - -/* USER CODE END PV */ - -/* Private function prototypes -----------------------------------------------*/ -/* USER CODE BEGIN PFP */ - -/* USER CODE END PFP */ - -/* Private user code ---------------------------------------------------------*/ -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/* External variables --------------------------------------------------------*/ - -/* USER CODE BEGIN EV */ - -/* USER CODE END EV */ - -/******************************************************************************/ -/* Cortex-M4 Processor Interruption and Exception Handlers */ -/******************************************************************************/ -/** - * @brief This function handles Non maskable interrupt. - */ -void NMI_Handler(void) -{ - /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ - - /* USER CODE END NonMaskableInt_IRQn 0 */ - /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ - while (1) {} - /* USER CODE END NonMaskableInt_IRQn 1 */ -} - -/** - * @brief This function handles Hard fault interrupt. - */ -void HardFault_Handler(void) -{ - /* USER CODE BEGIN HardFault_IRQn 0 */ - - /* USER CODE END HardFault_IRQn 0 */ - while (1) { - /* USER CODE BEGIN W1_HardFault_IRQn 0 */ - /* USER CODE END W1_HardFault_IRQn 0 */ - } -} - -/** - * @brief This function handles Memory management fault. - */ -void MemManage_Handler(void) -{ - /* USER CODE BEGIN MemoryManagement_IRQn 0 */ - - /* USER CODE END MemoryManagement_IRQn 0 */ - while (1) { - /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ - /* USER CODE END W1_MemoryManagement_IRQn 0 */ - } -} - -/** - * @brief This function handles Prefetch fault, memory access fault. - */ -void BusFault_Handler(void) -{ - /* USER CODE BEGIN BusFault_IRQn 0 */ - - /* USER CODE END BusFault_IRQn 0 */ - while (1) { - /* USER CODE BEGIN W1_BusFault_IRQn 0 */ - /* USER CODE END W1_BusFault_IRQn 0 */ - } -} - -/** - * @brief This function handles Undefined instruction or illegal state. - */ -void UsageFault_Handler(void) -{ - /* USER CODE BEGIN UsageFault_IRQn 0 */ - - /* USER CODE END UsageFault_IRQn 0 */ - while (1) { - /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ - /* USER CODE END W1_UsageFault_IRQn 0 */ - } -} - -/** - * @brief This function handles System service call via SWI instruction. - */ -void SVC_Handler(void) -{ - /* USER CODE BEGIN SVCall_IRQn 0 */ - - /* USER CODE END SVCall_IRQn 0 */ - /* USER CODE BEGIN SVCall_IRQn 1 */ - - /* USER CODE END SVCall_IRQn 1 */ -} - -/** - * @brief This function handles Debug monitor. - */ -void DebugMon_Handler(void) -{ - /* USER CODE BEGIN DebugMonitor_IRQn 0 */ - - /* USER CODE END DebugMonitor_IRQn 0 */ - /* USER CODE BEGIN DebugMonitor_IRQn 1 */ - - /* USER CODE END DebugMonitor_IRQn 1 */ -} - -/** - * @brief This function handles Pendable request for system service. - */ -void PendSV_Handler(void) -{ - /* USER CODE BEGIN PendSV_IRQn 0 */ - - /* USER CODE END PendSV_IRQn 0 */ - /* USER CODE BEGIN PendSV_IRQn 1 */ - - /* USER CODE END PendSV_IRQn 1 */ -} - -/** - * @brief This function handles System tick timer. - */ -void SysTick_Handler(void) -{ - /* USER CODE BEGIN SysTick_IRQn 0 */ - - /* USER CODE END SysTick_IRQn 0 */ - HAL_IncTick(); - /* USER CODE BEGIN SysTick_IRQn 1 */ - - /* USER CODE END SysTick_IRQn 1 */ -} - -/******************************************************************************/ -/* STM32G4xx Peripheral Interrupt Handlers */ -/* Add here the Interrupt Handlers for the used peripherals. */ -/* For the available peripheral interrupt handler names, */ -/* please refer to the startup file (startup_stm32g4xx.s). */ -/******************************************************************************/ - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ diff --git a/G4SPITESTING/README.md b/G4SPITESTING/README.md deleted file mode 100644 index c35301534..000000000 --- a/G4SPITESTING/README.md +++ /dev/null @@ -1,10 +0,0 @@ -# STM32G474 SPI -Nucleo-G474RE-C04 - -Compile and flash G4SPITESTING.elf - -## Testing - -Connect pins C11 and C12 together - -Run the program and watch the SWO console diff --git a/Lib/FancyLayers-RENAME/ADC/adc.cmake b/Lib/FancyLayers-RENAME/ADC/adc.cmake index 941fca30d..ea5f29bf6 100644 --- a/Lib/FancyLayers-RENAME/ADC/adc.cmake +++ b/Lib/FancyLayers-RENAME/ADC/adc.cmake @@ -5,3 +5,10 @@ target_sources(GR_ADC INTERFACE ${CMAKE_CURRENT_LIST_DIR}/Src/gr_adc.c) target_include_directories(GR_ADC INTERFACE ${CMAKE_CURRENT_LIST_DIR}/Inc) target_link_libraries(GR_ADC INTERFACE GLOBALSHARE_LIB) + +set_target_properties( + GR_ADC + PROPERTIES + DEPRECATION + "GR_ADC is deprecated and should be removed in favor of STM32CubeMX functionality." +) diff --git a/Lib/FancyLayers-RENAME/GRCAN/grcan_fancylayer.cmake b/Lib/FancyLayers-RENAME/GRCAN/grcan_fancylayer.cmake index eb82067ff..c972fdf3b 100644 --- a/Lib/FancyLayers-RENAME/GRCAN/grcan_fancylayer.cmake +++ b/Lib/FancyLayers-RENAME/GRCAN/grcan_fancylayer.cmake @@ -30,7 +30,7 @@ target_link_libraries( ) if(CMAKE_PRESET_NAME STREQUAL "HOOTLTest") - # target_compile_definitions(LOGOMATIC_LIB INTERFACE LOGOMATIC_ENABLED) + # target_compile_definitions(LOGOMATIC_OLD_LIB INTERFACE LOGOMATIC_ENABLED) # add_executable(logomatic_simple) # target_sources( @@ -43,7 +43,7 @@ if(CMAKE_PRESET_NAME STREQUAL "HOOTLTest") # PRIVATE # ${CMAKE_CURRENT_LIST_DIR}/Test/Inc # ) - # target_link_libraries(logomatic_simple PRIVATE LOGOMATIC_LIB) + # target_link_libraries(logomatic_simple PRIVATE LOGOMATIC_OLD_LIB) # add_test(logomatic_simple_test logomatic_simple) # add_executable(logomatic_float) @@ -57,6 +57,13 @@ if(CMAKE_PRESET_NAME STREQUAL "HOOTLTest") # PRIVATE # ${CMAKE_CURRENT_LIST_DIR}/Test/Inc # ) - # target_link_libraries(logomatic_float PRIVATE LOGOMATIC_LIB) + # target_link_libraries(logomatic_float PRIVATE LOGOMATIC_OLD_LIB) # add_test(logomatic_float_test logomatic_float) endif() + +set_target_properties( + GRCAN_FANCYLAYER + PROPERTIES + DEPRECATION + "GRCAN_FANCYLAYER is deprecated and should be replaced by CUBE_CAN_LIB." +) diff --git a/Lib/FancyLayers-RENAME/SPI/spi.cmake b/Lib/FancyLayers-RENAME/SPI/spi.cmake index d2f773772..856b2566f 100644 --- a/Lib/FancyLayers-RENAME/SPI/spi.cmake +++ b/Lib/FancyLayers-RENAME/SPI/spi.cmake @@ -9,3 +9,10 @@ target_link_libraries( MsgBuffer_Lib GLOBALSHARE_LIB ) + +set_target_properties( + SPI_Lib + PROPERTIES + DEPRECATION + "SPI_Lib is deprecated and should be removed in favor of STM32CubeMX functionality." +) diff --git a/Lib/GlobalShare/Inc/CriticalSection.h b/Lib/GlobalShare/Inc/CriticalSection.h new file mode 100644 index 000000000..7e53dd0b5 --- /dev/null +++ b/Lib/GlobalShare/Inc/CriticalSection.h @@ -0,0 +1,73 @@ +#include + +#include "Stringification.h" + +#ifndef CRITICAL_SECTION_H +#define CRITICAL_SECTION_H + +#ifdef HOOTL_TEST +#include + +extern pthread_mutex_t __mock_global_irq_mutex; +extern _Thread_local uint32_t __mock_primask_state; +extern _Thread_local uint32_t __mock_irq_nesting_depth; + +static inline uint32_t __get_PRIMASK(void) +{ + return __mock_primask_state; +} + +static inline void __disable_irq(void) +{ + pthread_mutex_lock(&__mock_global_irq_mutex); + if (__mock_irq_nesting_depth == 0) { + __mock_primask_state = 1; + } + __mock_irq_nesting_depth++; +} + +static inline void __set_PRIMASK(uint32_t state) +{ + if (__mock_irq_nesting_depth > 0) { + __mock_irq_nesting_depth--; + if (__mock_irq_nesting_depth == 0 || state == 0) { + __mock_primask_state = 0; + __mock_irq_nesting_depth = 0; + } + } + pthread_mutex_unlock(&__mock_global_irq_mutex); +} +#else +#include "main.h" +#endif + +/** + * @brief Internal function to automatically restore the interrupt state when exiting a critical section. + * + * This function is intended to be used with the GCC cleanup attribute to automatically restore the interrupt state when a critical section is exited. It takes a pointer to a state variable that holds + * the previous interrupt state and restores it using the __set_PRIMASK function. + * + * @warning This function is intended for internal use only and should not be called directly by user code. Use the CRITICAL_SECTION macro instead. + */ +static inline void _magic_auto_critical_exit(uint32_t *state_var) +{ + if (state_var) { + __set_PRIMASK(*state_var); + } +} + +/** + * @brief Macro to create a critical section that disables interrupts for the duration of the block. + * + * This macro uses the GCC cleanup attribute to automatically restore the interrupt state when the block is exited, regardless of how the block is exited (e.g., return, break, continue). + * + * @warning This macro should be used with caution, as it can lead to deadlocks or other issues if not used correctly. It is recommended to use this macro only in situations where it is necessary to + * disable interrupts for a short period of time. + * @warning If you use goto statements it will not automatically cleanup. However, you should not use goto at all. + */ +#define CRITICAL_SECTION \ + for (__attribute__((cleanup(_magic_auto_critical_exit))) uint32_t CONCAT(_magic_auto_critical_state_, __LINE__) = __get_PRIMASK(), \ + CONCAT(_magic_auto_critical_run_, __LINE__) = (__disable_irq(), 1); \ + CONCAT(_magic_auto_critical_run_, __LINE__); CONCAT(_magic_auto_critical_run_, __LINE__) = 0) + +#endif diff --git a/Lib/GlobalShare/README.md b/Lib/GlobalShare/README.md index 9d3505f87..6750bbc43 100644 --- a/Lib/GlobalShare/README.md +++ b/Lib/GlobalShare/README.md @@ -6,7 +6,7 @@ This directory contains shared definitions and interfaces used across multiple p Please do not add source files to this directory, this is intended for only header files. -**Important**: All files in this directory are **manually maintained and hand-written**. Nothing here is auto-generated. For auto-generated files please see [Autogen](../../Autogen/). +**Important**: All files in this directory are **manually maintained and hand-written**. Nothing here is auto-generated. For auto-generated files please see [Autogen](/Autogen). Please ensure everything is clearly doc-commented and a markdown section is present for each file as relevant. @@ -21,7 +21,7 @@ When adding new shared types or constants: ## State Machine -This is an enum corresponding to [`STATE_MACHINE.md`](../../STATE_MACHINE.md) exactly, no change should be made to this enum without modifying the state machine diagram and vice versa. +This is an enum corresponding to [`STATE_MACHINE.md`](/STATE_MACHINE.md) exactly, no change should be made to this enum without modifying the state machine diagram and vice versa. It is critical that every board runs the same version of this enum so as to have correct state machine numerical definitions. @@ -40,15 +40,16 @@ No warnings: ```c { - int thing = 42; - UNUSED(thing); + int thing = 42; + UNUSED(thing); } ``` Will have a warning that will become promoted to an error for release builds: + ```c { - int thing = 42; + int thing = 42; } ``` @@ -58,7 +59,7 @@ This macro converts the name of any type or variable into the corresponding quot This is helpful for cases where you need the explicit name of a variable -### Example +### String Example ```c int input = 42; diff --git a/Lib/GlobalShare/Test/criticalsection.c b/Lib/GlobalShare/Test/criticalsection.c new file mode 100644 index 000000000..68ebae386 --- /dev/null +++ b/Lib/GlobalShare/Test/criticalsection.c @@ -0,0 +1,110 @@ +#include "CriticalSection.h" + +#include +#include +#include + +#include "Unused.h" + +#define NUM_THREADS 40 +#define INCREMENTS_PER_THREAD 100000 + +pthread_mutex_t __mock_global_irq_mutex; +_Thread_local uint32_t __mock_primask_state = 0; +_Thread_local uint32_t __mock_irq_nesting_depth = 0; + +__attribute__((constructor)) static void init_recursive_mock_mutex(void) +{ + pthread_mutexattr_t attr; + pthread_mutexattr_init(&attr); + pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); + pthread_mutex_init(&__mock_global_irq_mutex, &attr); + pthread_mutexattr_destroy(&attr); +} + +volatile long long global_counter = 0; + +void *thread_worker_good(void *arg) +{ + UNUSED(arg); + + for (int i = 0; i < INCREMENTS_PER_THREAD; i++) { + CRITICAL_SECTION + { + CRITICAL_SECTION + { + global_counter++; + } + } + } + + return NULL; +} + +void *thread_worker_bad(void *arg) +{ + UNUSED(arg); + + for (int i = 0; i < INCREMENTS_PER_THREAD; i++) { + global_counter++; + } + + return NULL; +} + +int main(void) +{ + pthread_t threads[NUM_THREADS]; + int thread_ids[NUM_THREADS]; + + printf("Starting %d 'good' threads, each incrementing %d times...\n", NUM_THREADS, INCREMENTS_PER_THREAD); + global_counter = 0; + + for (int i = 0; i < NUM_THREADS; i++) { + thread_ids[i] = i; + if (pthread_create(&threads[i], NULL, thread_worker_good, &thread_ids[i]) != 0) { + printf("Failed to create thread"); + return 1; + } + } + + for (int i = 0; i < NUM_THREADS; i++) { + pthread_join(threads[i], NULL); + } + + long long expected_value = (long long)NUM_THREADS * INCREMENTS_PER_THREAD; + printf("\tExpected final counter value: %lld\n", expected_value); + printf("\tActual global_counter value: %lld\n", global_counter); + + if (global_counter == expected_value) { + printf("\tMocks and nested critical sections passed!\n"); + } else { + printf("\tData race detected! Your critical section failed.\n"); + return 2; + } + + printf("\nStarting %d 'bad' threads, each incrementing %d times...\n", NUM_THREADS, INCREMENTS_PER_THREAD); + global_counter = 0; + + for (int i = 0; i < NUM_THREADS; i++) { + thread_ids[i] = i; + if (pthread_create(&threads[i], NULL, thread_worker_bad, &thread_ids[i]) != 0) { + printf("Failed to create thread"); + return 3; + } + } + + for (int i = 0; i < NUM_THREADS; i++) { + pthread_join(threads[i], NULL); + } + + printf("\tExpected final counter value: %lld\n", expected_value); + printf("\tActual global_counter value: %lld\n", global_counter); + if (global_counter == expected_value) { + printf("\tUnexpectedly, the counter is correct without critical sections. This is highly unlikely and may indicate a problem with the test setup.\n"); + return 4; + } + + printf("\tAs expected, the counter is incorrect without critical sections. Data race detected!\n"); + return 0; +} diff --git a/Lib/GlobalShare/common.cmake b/Lib/GlobalShare/common.cmake index c47123510..f2fd1b082 100644 --- a/Lib/GlobalShare/common.cmake +++ b/Lib/GlobalShare/common.cmake @@ -51,4 +51,19 @@ if(CMAKE_PRESET_NAME STREQUAL "HOOTLTest") ) target_link_libraries(verify_min_max PRIVATE GLOBALSHARE_LIB) add_test(verify_min_max_test verify_min_max) + + find_package(Threads REQUIRED) + add_executable(criticalsection) + target_sources( + criticalsection + PRIVATE + ${CMAKE_CURRENT_LIST_DIR}/Test/criticalsection.c + ) + target_link_libraries( + criticalsection + PRIVATE + GLOBALSHARE_LIB + Threads::Threads + ) + add_test(criticalsection_test criticalsection) endif() diff --git a/Lib/Peripherals/CAN/common.cmake b/Lib/Peripherals/CAN/common.cmake index ad9709a07..61aacaf39 100644 --- a/Lib/Peripherals/CAN/common.cmake +++ b/Lib/Peripherals/CAN/common.cmake @@ -58,3 +58,10 @@ target_include_directories( # PERIPHERAL_CAN_LIB_init_test # ) #endif() + +set_target_properties( + PERIPHERAL_CAN_LIB + PROPERTIES + DEPRECATION + "PERIPHERAL_CAN_LIB is deprecated and should be replaced by CUBE_CAN_LIB." +) diff --git a/Lib/Peripherals/CubeCAN/Inc/CubeCAN.h b/Lib/Peripherals/CubeCAN/Inc/CubeCAN.h new file mode 100644 index 000000000..df16b5a82 --- /dev/null +++ b/Lib/Peripherals/CubeCAN/Inc/CubeCAN.h @@ -0,0 +1,140 @@ +#include +#include +#include + +#include "CubeCAN_Config.h" +#include "GRCAN_BUS_ID.h" +#include "GRCAN_CUSTOM_ID.h" +#include "GRCAN_MSG_ID.h" +#include "GRCAN_NODE_ID.h" +#include "main.h" + +#ifndef CUBEMX_CAN_H +#define CUBEMX_CAN_H + +/** + * @brief CAN handle for CubeCAN CAN. + * @warning Do not access directly, use the provided API functions. + */ +typedef struct CubeCAN_Private_Handle CubeCAN_Handle; + +/** + * @brief CAN Identifier structure + * + * This structure is used to represent a CAN message identifier, which consists of a transmitting node ID, a receiving node ID, and a message ID. The structure is used in conjunction with the + * Construct_Message_ID and Deconstruct_Message_ID functions to convert between the structure representation and the 32-bit integer representation of the CAN message identifier. + * + * @warning The structure does not represent custom IDs. + * @warning The structure does not represent actual bit depth + */ +typedef struct { + GRCAN_NODE_ID tx_node_id; + GRCAN_NODE_ID rx_node_id; + GRCAN_MSG_ID msg_id; +} CAN_Identifier; + +/** + * @brief Union for user-defined context data in CubeCAN configuration. + * + * This union allows for flexible user-defined context data to be passed to the receive callback function. It can hold either a pointer to any user-defined data or a specific GRCAN_BUS_ID value. + * + * @warning The union should be used carefully to ensure that the correct type of data is accessed in the callback function. + * + * @note Compile time checks verify that GRCAN_BUS_ID is the same size or smaller than the pointer, ensuring safe usage of the union. + */ +typedef union { + /// @brief Pointer to user-defined context data. This can be used to pass additional data or state information to the receive callback function. + void *full_user_context; + /// @brief GRCAN_BUS_ID value for user-defined context data. This can be used to pass the bus ID to the receive callback function. + GRCAN_BUS_ID busid_user_context; +} CubeCAN_Config_Context; + +/** + * @brief Callback function type for receiving CAN messages. + * + * @warning The callback function should not perform blocking operations or take too long to execute. + * @warning The callback function should not call any CubeCAN functions, as it may lead to undefined behavior. + * @warning It is the responsibility of the callback function to verify the integrity of the received data and handle any errors or null inputs. + */ +typedef void (*CubeCAN_RxCallback)(const CubeCAN_Config_Context *const context, const CAN_Identifier *const identifier, const uint8_t *const data, const uint8_t size); + +/** + * @brief Configuration structure for CubeCAN CAN. + * + * This structure is used to configure the CubeCAN CAN handle, including the receive callback function and user context. The receive callback function is called when a CAN message is received, and the + * user context is a pointer to user-defined data that can be passed to the callback function. + * + * @warning Do not edit after initialization, as it may lead to undefined behavior. + */ +typedef struct { + /// @brief Union for user-defined context data. This can be used to pass additional data or state information to the receive callback function. + CubeCAN_Config_Context context; + /// @brief Callback function for receiving CAN messages. This function is called when a CAN message is received. + CubeCAN_RxCallback rx_callback; + /// @brief Node ID of the sending device. This is used to identify the source of the CAN messages and must be unique on the CAN bus. + GRCAN_NODE_ID sending_node_id; +} CubeCAN_Config; + +/** + * @brief Initializes a CubeCAN CAN handle with the given FDCAN handle and configuration, and starts the CAN peripheral. + * @param hfdcan Pointer to the FDCAN handle. + * @param config Pointer to the CubeCAN configuration structure. + * @return Pointer to the initialized CubeCAN CAN handle, or NULL if initialization fails. + * @note This functions wraps CubeCAN_Private_Init and CubeCAN_Private_Start into a single call. If either of those functions fails, this function will return NULL and the handle will be + * released. + */ +CubeCAN_Handle *CubeCAN_Entrance(FDCAN_HandleTypeDef *hfdcan, CubeCAN_Config *config); + +/** + * @brief Stops the CubeCAN CAN peripheral and releases the associated handle. + * @param handle Pointer to the CubeCAN CAN handle. + * @return HAL_StatusTypeDef indicating the success or failure of the operation. + * @note This function can be used regardless of if CubeCAN_Entrance was used to initialize the handle. + */ +HAL_StatusTypeDef CubeCAN_Exit(CubeCAN_Handle *handle); + +/** + * @brief Processes periodic tasks for the CubeCAN CAN handle, such as handling timeouts and managing the transmission queue. + * + * For each configured bus, this function will send one CAN message per call. It is recommended to call this function at a regular interval to ensure timely processing of CAN messages. + * + * @note This function sends one can message per configured bus per call. Not calling it will simply not send any messages. + * @warning It is recommended to call this function no more than and no less than once every 625 us. + * @warning This function checks during early boot that it is not called more than ABSOLUTE_MAX_INVOCATIONS_PER_TICK times per millisecond, failing if so + */ +void CubeCAN_Tick(void); + +/** + * @brief Sends a CAN message using the CubeCAN CAN handle, with the specified receive node, message ID, data payload, and size. + * @param handle Pointer to the CubeCAN CAN handle. + * @param rx_node The receive node identifier for the message. + * @param msg_id The message ID for the message. + * @param data Pointer to the data payload of the message. + * @param size The size of the data payload in bytes. + * @return HAL_StatusTypeDef indicating the success or failure of the operation. + * @note The size of the data payload must not exceed FDCAN_MAX_DATA_BYTES (64 bytes). If the size exceeds this limit, the function will return HAL_ERROR. + */ +HAL_StatusTypeDef CubeCAN_Send(CubeCAN_Handle *const handle, const GRCAN_NODE_ID rx_node, const GRCAN_MSG_ID msg_id, const void *const data, const uint8_t size); + +/** + * @brief Constructs a CAN message identifier from the given transmitting node ID, receiving node ID, and message ID. + * + * @param identifier Pointer to the CAN_Identifier structure containing the node and message IDs. + * + * @return The constructed 29-bit CAN message extended identifier. + */ +uint32_t CubeCAN_Construct_Identifier(const CAN_Identifier *const identifier); + +/** + * @brief Deconstructs a 29-bit CAN message extended identifier into its constituent transmitting node ID, receiving node ID, and message ID. + * + * @param message_id The 29-bit CAN message extended identifier to be deconstructed. + * + * @return A CAN_Identifier structure containing the deconstructed node and message IDs. + * + * @warning The function does not guarantee that the returned structure will represent a valid CAN message identifier. + * @warning The function does not support custom IDs. + */ +CAN_Identifier CubeCAN_Deconstruct_Identifier(const uint32_t message_id); + +#endif diff --git a/Lib/Peripherals/CubeCAN/README.md b/Lib/Peripherals/CubeCAN/README.md new file mode 100644 index 000000000..814265ee8 --- /dev/null +++ b/Lib/Peripherals/CubeCAN/README.md @@ -0,0 +1,212 @@ +# Cube CAN + +Support for STM32CubeMX and CAN. See [`CUBEMX.md`](/CUBEMX.md) for background. + +## Summary + +Use STM32CubeMX to setup the CAN peripheral, then call `CubeCAN_Entrance()` on it after HAL initializes the peripheral. + +Save the handle that function returns and use that to send messages. Receive messages on your function callback. + +> [!IMPORTANT] +> We recommend that your received message callback function is a switch-case off of the message ID that does nothing more than writing to memory. +> +> Your `CubeCAN_RxCallback()` function must run quickly, it is inside of a low level ISR. +> Read the library code yourself if you wish to call a CubeCAN function from within an ISR, but you really should not. + +## Setup + +### 1. CMake + +Add `CUBE_CAN_LIB` as an interface target link library within your project. + +### 2. Configuration + +Add a file named `CubeCAN_Config.h` to your project, generally `Application/Inc/CubeCAN_Config.h`, that looks something like: + +```c +#ifndef CUBE_CAN_CONFIG_H +#define CUBE_CAN_CONFIG_H + +#define CUBEMX_CAN_TX_QUEUE_SIZE 16U +#define CUBEMX_CAN_MAX_INSTANCES 1U + +#endif +``` + +**Configuration Requirements:** + +- `CUBEMX_CAN_TX_QUEUE_SIZE`: Must be a power of two. Defines the transmission queue depth; when the queue fills, the oldest message is dropped and `CubeCAN_Send()` returns `HAL_BUSY`. +- `CUBEMX_CAN_MAX_INSTANCES`: Must be 1-3 depending on your chip's available FDCAN peripherals. Omit this definition to automatically select the maximum supported by your MCU. + +From there just ensure that you have configured CAN through STM32CubeMX and setup a global variable for each `CubeCAN_Handle` you wish to use. + +### 3. Entrance + +Make sure to `#include "CubeCAN.h"` where needed. Do not include `PrivateInc/internal.h` outside of the peripheral source files. + +At the end of your STM32CubeMX-generated `MX_FDCAN#_Init()` function, configure your filters as needed with `HAL_FDCAN_ConfigFilter()`. It is recommended to setup a filter to ignore messages not intended for your board. + +Within `main` after `MX_FDCAN#_Init()` and Logomatic are setup (see [Logomatic](/Lib/Utils/Logomatic/README.md)), call `CubeCAN_Entrance()` saving the handle for global use later (one entrance and handle per peripheral). + +Ensure you have setup some mechanism to call `CubeCAN_Tick()` frequently (a STM32CubeMX timer interrupt is recommended). This function: + +- Sends one CAN message per bus per call (limiting to one prevents overwhelming the ISR) +- Must be called regularly for messages to be transmitted +- Can start running at any point in execution + +### 4. Operation + +#### Transmission + +Call `CubeCAN_Send()` to queue a message for transmission. Messages are queued in a lock-free ring buffer and processed in FIFO order. + +- **Returns `HAL_OK`**: Message successfully queued +- **Returns `HAL_BUSY`**: Transmission queue is full; the oldest queued message was dropped to make room for the new one +- **Returns `HAL_ERROR`**: Invalid parameters (null handle/data, size > 64 bytes, invalid frame format) + +Each call to `CubeCAN_Tick()` transmits one message from the queue per peripheral. If you need higher throughput, call `CubeCAN_Tick()` more frequently or increase `CUBEMX_CAN_TX_QUEUE_SIZE`. + +#### Reception + +Your provided callback `CubeCAN_RxCallback()` is triggered for messages that pass your configured filters. + +- Keep execution time minimal, you are in a hardware ISR +- Avoid calling CubeCAN functions or performing blocking operations +- Typical pattern is to decode the message and write results to shared memory (protected with atomic operations or critical sections as needed) + +## Architecture + +```mermaid +flowchart TD + classDef lib fill:#1e40af,stroke:#bfdbfe,color:#ffffff; + classDef cubemx fill:#5b21b6,stroke:#ddd6fe,color:#ffffff; + classDef internal fill:#F0E442,stroke:#333,color:#333; + classDef other fill:#c2410c,stroke:#fed7aa,color:#ffffff; + + MXInit(["MX_FDCAN#_Init()"]) -->Entrance("CubeCAN_Entrance()") + MXInit --> Filter("HAL_FDCAN_\nConfigFilter()") + Filter --> Filter + Filter --> Entrance + Entrance --> Choice{"Functions"} + Choice --> Exit(["CubeCAN_Exit()"]) + Exit -.-> |"AVOID"| Entrance + Choice --> Send(["CubeCAN_Send()"]) + Choice --> |"Call Often\n(User Setup)"| Tick(["CubeCAN_Tick()"]) + Send -.-> Queue("CubeCAN_Private_QueueTx()") + Data -.-> Tick + Queue -.-> Data{"Internal Queue"} + Tick -.-> Tx(["CubeCAN_Private\n_SendQueuedMessage()"]) + Data -.-> Tx + Tx -.->|"HAL_FDCAN_\nAddMessageToTxFifoQ()"| Sent(["Transmitted over bus!"]) + Choice -.->|"HAL Interrupt"| Recieved + Recieved(["Recieved over bus!"]) -.->|"HAL_FDCAN_\nRxFifo0Callback()\n\nHAL_FDCAN_\nGetRxMessage()"| Get(["CubeCAN_RxCallback()"]) + + class MXInit cubemx; + class Filter cubemx; + class Entrance lib; + class Exit lib; + class Send lib; + class Queue internal; + class Tick lib; + class Tx internal; + class Choice other; + class Data other; + class Sent other; + class Recieved other; + class Get lib; +``` + +## Advanced + +### Interrupt Safety + +CubeCAN is designed to handle concurrent access from multiple execution contexts (main loop and ISR). + +#### Overview + +- `tx_head` and `tx_tail` are atomic `uint32_t` variables that implement a lock-free ring buffer +- `CubeCAN_Send()` and `CubeCAN_Tick()` use critical sections (interrupt blocking) when necessary +- Atomic operations use `memory_order_relaxed` within ISRs and `memory_order_release`/`memory_order_acquire` for inter-context synchronization +- The queue size must be a power of two, allowing fast wraparound via bitwise AND instead of expensive modulo operations + +#### Critical Sections + +Interrupt protection is used only in: + +- `CubeCAN_Private_QueueTx()` while updating the queue +- `HAL_FDCAN_RxFifo0Callback` while reading handle state + +#### ISR Interaction + +- Safe to call `CubeCAN_Send()` from `main()` or any ISR +- Safe to call `CubeCAN_Tick()` from `main()` or any ISR +- Do not call any CubeCAN function from `CubeCAN_RxCallback()`, use it only to write data to shared memory (with concurrency safety as needed) + +### Filters + +You are responsible for configuring CAN filters. + +Use `HAL_FDCAN_ConfigFilter()` in `MX_FDCAN#_Init()` to setup any filters you need. Configure the number and type of filters in STM32CubeMX. + +#### Best Practices + +Create a filter to accept only messages intended for your board + +The library uses only `HAL_FDCAN_RxFifo0Callback()` for message reception, you can define your own `HAL_FDCAN_RxFifo1Callback()` for additional needs + +#### Message Overflow + +If your received message FIFO overflows (messages arrive faster than they're processed), the library logs a warning and drops the oldest messages. + +Improve this by increasing callback efficiency or adding more CAN filters to reduce unwanted messages. + +### Rx Callback Context + +You may consolidate multiple receive callbacks into a single function by passing different context data to each handle. + +Use the context union for this, it can point to arbitrary data or to a bus ID. It is your responsibility to be consistent the peripheral will just return input. + +### Tx Message Marker + +Currently we do not do anything cool with this, but we could! + +If you would like to see this do something please open an Issue (and if you want to code it, a Pull Request as well) + +### Assertions + +We currently provide compile time static assertions to validate: + +- Memory alignment of 32 bits for `tx_head` and `tx_tail` +- Struct alignment of >=4 bytes for `GRCAN_Private_TxMessage` and `CubeCAN_Private_Handle` +- Union compatibility for types `GRCAN_BUS_ID` and `void*` +- Lock free atomic operations for integers and booleans guaranteed by the compiler +- `CUBEMX_CAN_TX_QUEUE_SIZE` is a power of two and non-zero (allows faster ring-buffer wrapping) +- `CUBEMX_CAN_MAX_INSTANCES` requires management of 1 to 3 interfaces (optional parameter, otherwise automatically chooses the maximum possible) + +### Globals + +CubeCAN maintains a global private array of handles (sized to `CUBEMX_CAN_MAX_INSTANCES`). + +- Each handle is 28 bytes (overhead) +- Plus transmission queue: `CUBEMX_CAN_TX_QUEUE_SIZE` times `sizeof(GRCAN_Private_TxMessage)` (4 byte header and 64 bytes of data, at print time) + +If your chip supports multiple FDCAN peripherals but you need fewer, set `CUBEMX_CAN_MAX_INSTANCES` lower to avoid wasting memory on unused handles. Similarly, reduce `CUBEMX_CAN_TX_QUEUE_SIZE` if you send infrequently and have frequent ticks. + +### Timer Rate Checker + +In the interest of preventing improper bus actions, during a period after early boot and ending a few seconds later we monitor how often `CubeCAN_Tick()` is callled to verify the sender is not going to bring down the bus. + +Ideally, you should call `CubeCAN_Tick()` about every `625 us` and you will not run into any issues with it. + +If for some reason you wish to go past that, such as some extreme debugging case, then you may define `RELAXED_TIMER_GATE` inside of your `CubeCAN_Config.h` file and this will turn the error handler call into a logged violation. + +If for some reason you wish to go even farther pas that, such as some extreme debugging case where you do not want to even check for violations, then you may define `DISABLED_TIMER_GATE` inside of your `CubeCAN_Config.h` file and this will skip running the violation check at all. + +However, you really should fix your timers so that it is not possible to spam the bus, needing to use either of these flags means you should reevaluate other settings, try sending larger messages instead of many smaller ones and increasing `CUBEMX_CAN_TX_QUEUE_SIZE`. + +## Troubleshooting + +TODO + +As issues are found we will extend this section. For now, please contact the Firmware Manager if you are unable to get this working. diff --git a/Lib/Peripherals/CubeCAN/Src/PrivateInc/internal.h b/Lib/Peripherals/CubeCAN/Src/PrivateInc/internal.h new file mode 100644 index 000000000..7abb7899d --- /dev/null +++ b/Lib/Peripherals/CubeCAN/Src/PrivateInc/internal.h @@ -0,0 +1,188 @@ +#include +#include +#include + +#include "CubeCAN_Config.h" +#include "Logomatic.h" +#include "Stringification.h" +#include "fdcan.h" +#include "main.h" + +#ifndef PRIVATE_CUBE_MX_CAN_H +#define PRIVATE_CUBE_MX_CAN_H + +/** + * @brief Maximum number of CubeCAN CAN instances supported by the library. + * + * This value is determined based on the available FDCAN peripherals in the STM32 microcontroller. + * + * @warning You can override it, but you should only reduce it to a lower value, there is no point to increase it beyond what their is hardware for. + */ +#ifndef CUBEMX_CAN_MAX_INSTANCES +#if (defined(FDCAN3) || defined(CAN3)) && (defined(FDCAN2) || defined(CAN2)) && (defined(FDCAN1) || defined(CAN1)) +#define CUBEMX_CAN_MAX_INSTANCES (3U) +#elif (defined(FDCAN2) || defined(CAN2)) && (defined(FDCAN1) || defined(CAN1)) +#define CUBEMX_CAN_MAX_INSTANCES (2U) +#elif (defined(FDCAN1) || defined(CAN1)) +#define CUBEMX_CAN_MAX_INSTANCES (1U) +#else +#error "No CAN or FDCAN instances defined. Please check your CubeCAN configuration." +#endif +#endif + +/** + * @brief Mask for the transmission queue index, used to wrap around the queue when it reaches its maximum size. + * + * Application code should not use this macro directly. It is intended for internal use only + * + * @warning The transmission queue size must be a power of two for this mask to work correctly + * @warning The transmission queue size must be defined as CUBEMX_CAN_TX_QUEUE_SIZE in the CubeCAN CAN configuration header file + */ +#define TX_QUEUE_MASK (CUBEMX_CAN_TX_QUEUE_SIZE - 1U) + +/** + * @brief Rx events mask for FDCAN notifications. + * + * This mask is used to enable notifications for new messages, full FIFO, and message lost events in the FDCAN peripheral. + */ +#define FDCAN_IT_RX_EVENTS (FDCAN_IT_RX_FIFO0_NEW_MESSAGE | FDCAN_IT_RX_FIFO0_FULL | FDCAN_IT_RX_FIFO0_MESSAGE_LOST) + +/** + * @brief Maximum number of data bytes in an FDCAN message. + * + * This macro defines the maximum number of data bytes that can be included in an FDCAN message. + */ +#define FDCAN_MAX_DATA_BYTES (64U) + +/** + * @brief Absolute maximum number of CubeCAN_Tick invocations per millisecond. + * + * This value is used to detect if the CubeCAN_Tick function is being called too frequently, which could indicate a problem with the invocation method. + * + * @note If you need to think about increasing this, you need to evaluate + * @warning If this value is exceeded, the system will trigger an error handler to prevent potential issues but this is checked only during a short duration starting after early boot and ending after + * a few seconds + */ +#define ABSOLUTE_MAX_INVOCATIONS_PER_TICK 3U + +/** + * @brief Transmission CAN message structure + * + * This structure is used to represent a transmission CAN message, which consists of a header and data payload. The header contains information about the message, such as its identifier, data length, + * and other relevant parameters. The data payload contains the actual data bytes of the message. + * + * @warning The length of the data array may be longer than the actual CAN message. + */ +typedef struct { + FDCAN_TxHeaderTypeDef tx_header; + uint8_t data[FDCAN_MAX_DATA_BYTES]; +} GRCAN_Private_TxMessage; + +/** + * @brief CubeCAN CAN handle structure + * + * This structure is used to represent a CubeCAN CAN handle, which consists of a pointer to the FDCAN handle, a configuration structure, a transmission queue, and other relevant parameters. + * + * @warning Use the provided API functions to interact with the CubeCAN CAN handle. + * @warning The structure is intended for internal use only and should not be accessed directly by user code. + */ +struct CubeCAN_Private_Handle { + /// @brief Pointer to the FDCAN handle associated with this CubeCAN CAN handle. + FDCAN_HandleTypeDef *hfdcan; + /// @brief Configuration structure for the CubeCAN CAN handle, containing the receive callback and user context. + CubeCAN_Config config; + /// @brief Transmission queue for the CubeCAN CAN handle, containing the messages to be transmitted. + GRCAN_Private_TxMessage tx_queue[CUBEMX_CAN_TX_QUEUE_SIZE]; + /// @brief Atomic head index for the transmission queue, indicating the next message to be transmitted. + _Atomic uint32_t tx_head; + /// @brief Atomic tail index for the transmission queue, indicating the next available slot for a new message. + _Atomic uint32_t tx_tail; + /// @brief Flag indicating whether the CubeCAN CAN handle has been started. + bool started; +}; + +/** + * @brief Array of CubeCAN CAN handles, one for each supported instance. + * @note The number of instances is defined by CUBEMX_CAN_MAX_INSTANCES. + */ +extern struct CubeCAN_Private_Handle handles[CUBEMX_CAN_MAX_INSTANCES]; + +/** + * @brief Sends a queued message from the CubeCAN CAN handle. + * @param handle Pointer to the CubeCAN CAN handle. + * @return HAL_StatusTypeDef indicating the success or failure of the operation. + */ +HAL_StatusTypeDef CubeCAN_Private_SendQueuedMessage(const CubeCAN_Handle *const handle); + +/** + * @brief Attempts to recover the FDCAN peripheral associated with the given CubeCAN CAN handle. + * + * Handles recovery from bus off or restricted operation mode by reinitializing the FDCAN peripheral and restoring its configuration. + * + * @param handle Pointer to the CubeCAN CAN handle associated with the FDCAN peripheral to be recovered. + * @return HAL_StatusTypeDef indicating the success or failure of the recovery operation. + */ +HAL_StatusTypeDef CubeCAN_Private_RecoverPeripheral(const CubeCAN_Handle *const handle); + +/** + * @brief Converts a Data Length Code (DLC) to the corresponding number of data bytes. + * @param dlc The Data Length Code to be converted. + * @return The number of data bytes corresponding to the given DLC. + * @warning The DLC value must be between 0 and 15, inclusive. Values outside this range will result in undefined behavior. + */ +bool CubeCAN_Private_IsDisabled(const CubeCAN_Handle *const handle); + +/** + * @brief Queues a transmission message for the CubeCAN CAN handle, allowing for asynchronous message transmission. + * @param handle Pointer to the CubeCAN CAN handle. + * @param message Pointer to the GRCAN transmission message structure. + * @return HAL_StatusTypeDef if the parameters are non-null or the queue is full. + */ +HAL_StatusTypeDef CubeCAN_Private_QueueTx(CubeCAN_Handle *const handle, const GRCAN_Private_TxMessage *const message); + +/** + * @brief Converts a Data Length Code (DLC) to the corresponding number of bytes. + * @param dlc The Data Length Code to be converted. + * @return The number of bytes corresponding to the given DLC. + * @warning The DLC value must be between 0 and 15, inclusive. Values outside this range will result in undefined behavior. + */ +uint8_t CubeCAN_Private_DlcToBytes(const uint32_t dlc); + +/** + * @brief Converts a number of bytes to the corresponding Data Length Code (DLC). + * @param bytes The number of bytes to be converted. + * @return The Data Length Code corresponding to the given number of bytes. + * @warning The number of bytes must be between 0 and 8, inclusive. Values outside this range will result in undefined behavior. + */ +uint8_t CubeCAN_Private_BytesToDlc(const uint8_t bytes); + +/** + * @brief Initializes a CubeCAN CAN handle with the given FDCAN handle and configuration. + * @param hfdcan Pointer to the FDCAN handle. + * @param config Pointer to the CubeCAN configuration structure. + * @return Pointer to the initialized CubeCAN CAN handle, or NULL if initialization fails. + */ +CubeCAN_Handle *CubeCAN_Private_Init(FDCAN_HandleTypeDef *hfdcan, CubeCAN_Config *config); + +/** + * @brief Starts the CubeCAN CAN handle, enabling message transmission and reception. + * @param handle Pointer to the CubeCAN CAN handle. + * @return HAL_StatusTypeDef indicating the success or failure of the operation. + */ +HAL_StatusTypeDef CubeCAN_Private_Start(CubeCAN_Handle *const handle); + +/** + * @brief Stops the CubeCAN CAN handle, disabling message transmission and reception. + * @param handle Pointer to the CubeCAN CAN handle. + * @return HAL_StatusTypeDef indicating the success or failure of the operation. + */ +HAL_StatusTypeDef CubeCAN_Private_Stop(CubeCAN_Handle *const handle); + +/** + * @brief Releases the resources associated with the CubeCAN CAN handle. + * @param handle Pointer to the CubeCAN CAN handle. + * @return HAL_StatusTypeDef indicating the success or failure of the operation. + */ +HAL_StatusTypeDef CubeCAN_Private_Release(CubeCAN_Handle *const handle); + +#endif diff --git a/Lib/Peripherals/CubeCAN/Src/can_assert.c b/Lib/Peripherals/CubeCAN/Src/can_assert.c new file mode 100644 index 000000000..107db57b6 --- /dev/null +++ b/Lib/Peripherals/CubeCAN/Src/can_assert.c @@ -0,0 +1,28 @@ +#include +#include +#include +#include + +#include "CriticalSection.h" +#include "CubeCAN.h" +#include "CubeCAN_Config.h" +#include "GRCAN_BUS_ID.h" +#include "PrivateInc/internal.h" +#include "main.h" + +static_assert(sizeof(((struct CubeCAN_Private_Handle *)0)->tx_head) == sizeof(uint32_t), "CubeCAN internal tx_head must be 32 bits"); +static_assert(sizeof(((struct CubeCAN_Private_Handle *)0)->tx_tail) == sizeof(uint32_t), "CubeCAN internal tx_tail must be 32 bits"); + +static_assert(alignof(GRCAN_Private_TxMessage) >= 4, "CubeCAN internal GRCAN_Private_TxMessage must have at least 4-byte alignment"); +static_assert(alignof(struct CubeCAN_Private_Handle) >= 4, "CubeCAN internal CubeCAN_Private_Handle must have at least 4-byte alignment"); + +static_assert((offsetof(struct CubeCAN_Private_Handle, tx_head) % 4U) == 0U, "CubeCAN internal atomic tx_head is unaligned"); +static_assert((offsetof(struct CubeCAN_Private_Handle, tx_tail) % 4U) == 0U, "CubeCAN internal atomic tx_tail is unaligned"); + +static_assert(ATOMIC_INT_LOCK_FREE == 2, "CubeCAN internal ATOMIC_INT_LOCK_FREE must be enabled for atomic operations"); +static_assert(ATOMIC_BOOL_LOCK_FREE == 2, "CubeCAN internal ATOMIC_BOOL_LOCK_FREE must be enabled for atomic operations"); + +static_assert((CUBEMX_CAN_TX_QUEUE_SIZE > 0) && !(CUBEMX_CAN_TX_QUEUE_SIZE & (CUBEMX_CAN_TX_QUEUE_SIZE - 1U)), "CUBEMX_CAN_TX_QUEUE_SIZE must be a power of two and greater than zero"); +static_assert(CUBEMX_CAN_MAX_INSTANCES >= 1 && CUBEMX_CAN_MAX_INSTANCES <= 3, "CUBEMX_CAN_MAX_INSTANCES must be configured between 1 and 3 inclusive"); + +static_assert(sizeof(GRCAN_BUS_ID) <= sizeof(void *), "GRCAN_BUS_ID must fit within a pointer-sized type to support being unioned with a pointer in CubeCAN_Config"); diff --git a/Lib/Peripherals/CubeCAN/Src/can_global.c b/Lib/Peripherals/CubeCAN/Src/can_global.c new file mode 100644 index 000000000..254508f25 --- /dev/null +++ b/Lib/Peripherals/CubeCAN/Src/can_global.c @@ -0,0 +1,9 @@ +#include +#include +#include + +#include "CriticalSection.h" +#include "CubeCAN.h" +#include "PrivateInc/internal.h" + +struct CubeCAN_Private_Handle handles[CUBEMX_CAN_MAX_INSTANCES] = {0}; diff --git a/Lib/Peripherals/CubeCAN/Src/can_init.c b/Lib/Peripherals/CubeCAN/Src/can_init.c new file mode 100644 index 000000000..ec86c7bef --- /dev/null +++ b/Lib/Peripherals/CubeCAN/Src/can_init.c @@ -0,0 +1,209 @@ +#include +#include +#include +#include + +#include "CriticalSection.h" +#include "CubeCAN.h" +#include "Logomatic.h" +#include "PrivateInc/internal.h" +#include "main.h" + +CubeCAN_Handle *CubeCAN_Entrance(FDCAN_HandleTypeDef *hfdcan, CubeCAN_Config *config) +{ + CubeCAN_Handle *handle = CubeCAN_Private_Init(hfdcan, config); + + if (handle == NULL) { + LOGOMATIC_ERROR("CubeCAN_Entrance: failed to initialize handle\n"); + return NULL; + } + + if (CubeCAN_Private_Start(handle) != HAL_OK) { + LOGOMATIC_ERROR("CubeCAN_Entrance: failed to start handle\n"); + CubeCAN_Private_Release(handle); + return NULL; + } + + return handle; +} + +HAL_StatusTypeDef CubeCAN_Exit(CubeCAN_Handle *handle) +{ + if (handle == NULL) { + LOGOMATIC_ERROR("CubeCAN_Exit: invalid null parameter\n"); + return HAL_ERROR; + } + + HAL_StatusTypeDef status = CubeCAN_Private_Stop(handle); + + if (status != HAL_OK) { + LOGOMATIC_ERROR("CubeCAN_Exit: failed to stop FDCAN instance\n"); + return status; + } + + return CubeCAN_Private_Release(handle); +} + +CubeCAN_Handle *CubeCAN_Private_Init(FDCAN_HandleTypeDef *hfdcan, CubeCAN_Config *config) +{ + if (hfdcan == NULL || config == NULL) { + LOGOMATIC_ERROR("CubeCAN_Private_Init: invalid null parameters\n"); + return NULL; + } + + CubeCAN_Handle *handle = NULL; + uint8_t free_handle_index = (uint8_t)-1; + + CRITICAL_SECTION + { + for (uint8_t i = 0U; i < CUBEMX_CAN_MAX_INSTANCES; ++i) { + if (handles[i].hfdcan == hfdcan) { + handle = &handles[i]; + break; + } else if (handles[i].hfdcan == NULL && free_handle_index == (uint8_t)-1) { + free_handle_index = i; + } + } + + if (handle != NULL) { + LOGOMATIC_WARNING("CubeCAN_Private_Init: handle already initialized for this FDCAN instance\n"); + return NULL; + } else if (free_handle_index != (uint8_t)-1) { + handle = &handles[free_handle_index]; + memset(handle, 0, sizeof(*handle)); + handle->hfdcan = hfdcan; + handle->config = *config; + atomic_init(&handle->tx_head, 0U); + atomic_init(&handle->tx_tail, 0U); + handle->started = false; + } + } + + if (handle == NULL) { + LOGOMATIC_ERROR("CubeCAN_Private_Init: no free handle slots\n"); + return NULL; + } + + if (HAL_FDCAN_ActivateNotification(hfdcan, FDCAN_IT_RX_EVENTS, 0U) != HAL_OK) { + LOGOMATIC_ERROR("CubeCAN_Private_Init: failed to activate RX notifications\n"); + CRITICAL_SECTION + { + memset(handle, 0, sizeof(*handle)); + } + return NULL; + } + + return handle; +} + +HAL_StatusTypeDef CubeCAN_Private_Release(CubeCAN_Handle *handle) +{ + if (handle == NULL) { + return HAL_ERROR; + } + + FDCAN_HandleTypeDef *hfdcan_to_stop = NULL; + + CRITICAL_SECTION + { + if (handle->hfdcan != NULL) { + hfdcan_to_stop = handle->hfdcan; + handle->hfdcan = NULL; + handle->started = false; + } + } + + if (hfdcan_to_stop == NULL) { + return HAL_ERROR; + } + + HAL_StatusTypeDef status = HAL_FDCAN_Stop(hfdcan_to_stop); + + if (status == HAL_OK) { + status = HAL_FDCAN_DeactivateNotification(hfdcan_to_stop, FDCAN_IT_RX_EVENTS); + } + + if (status != HAL_OK) { + LOGOMATIC_ERROR("CubeCAN_Release: peripheral deactivation failed\n"); + + CRITICAL_SECTION + { + handle->hfdcan = hfdcan_to_stop; + } + + return status; + } + + CRITICAL_SECTION + { + memset(handle, 0, sizeof(*handle)); + } + + return HAL_OK; +} + +HAL_StatusTypeDef CubeCAN_Private_Start(CubeCAN_Handle *const handle) +{ + if (handle == NULL) { + return HAL_ERROR; + } + + bool dynamic_start = false; + FDCAN_HandleTypeDef *hfdcan = NULL; + + CRITICAL_SECTION + { + if (handle->hfdcan != NULL && !handle->started) { + hfdcan = handle->hfdcan; + dynamic_start = true; + } + } + + if (!dynamic_start) { + return HAL_ERROR; + } + + HAL_StatusTypeDef status = HAL_FDCAN_Start(hfdcan); + + if (status == HAL_OK) { + CRITICAL_SECTION + { + handle->started = true; + } + } + + return status; +} + +HAL_StatusTypeDef CubeCAN_Private_Stop(CubeCAN_Handle *const handle) +{ + if (handle == NULL) { + return HAL_ERROR; + } + + bool dynamic_stop = false; + FDCAN_HandleTypeDef *hfdcan = NULL; + + CRITICAL_SECTION + { + if (handle->hfdcan != NULL && handle->started) { + hfdcan = handle->hfdcan; + dynamic_stop = true; + } + } + + if (!dynamic_stop) { + return HAL_ERROR; + } + + HAL_StatusTypeDef status = HAL_FDCAN_Stop(hfdcan); + + if (status == HAL_OK) { + CRITICAL_SECTION + { + handle->started = false; + } + } + + return status; +} diff --git a/Lib/Peripherals/CubeCAN/Src/can_rx.c b/Lib/Peripherals/CubeCAN/Src/can_rx.c new file mode 100644 index 000000000..c330e26a4 --- /dev/null +++ b/Lib/Peripherals/CubeCAN/Src/can_rx.c @@ -0,0 +1,62 @@ +#include +#include + +#include "CriticalSection.h" +#include "CubeCAN.h" +#include "Logomatic.h" +#include "PrivateInc/internal.h" +#include "Unused.h" +#include "main.h" + +void HAL_FDCAN_RxFifo0Callback(FDCAN_HandleTypeDef *hfdcan, uint32_t RxFifo0ITs) +{ + if (RxFifo0ITs & FDCAN_IT_RX_FIFO0_MESSAGE_LOST) { + LOGOMATIC_ERROR("CAN Rx FIFO is overflowing, messages are being lost!\n"); + } + + if (hfdcan == NULL) { + return; + } + + CubeCAN_Config_Context context; + CubeCAN_RxCallback rx_callback = NULL; + bool is_started = false; + + CRITICAL_SECTION + { + for (uint8_t i = 0U; i < CUBEMX_CAN_MAX_INSTANCES; ++i) { + if (handles[i].hfdcan == hfdcan) { + context = handles[i].config.context; + rx_callback = handles[i].config.rx_callback; + is_started = handles[i].started; + break; + } + } + } + + if (!is_started || rx_callback == NULL) { + FDCAN_RxHeaderTypeDef dump_header; + uint8_t dump_data[FDCAN_MAX_DATA_BYTES]; + + while (HAL_FDCAN_GetRxFifoFillLevel(hfdcan, FDCAN_RX_FIFO0) > 0U) { + (void)HAL_FDCAN_GetRxMessage(hfdcan, FDCAN_RX_FIFO0, &dump_header, dump_data); + } + + LOGOMATIC_WARNING("HAL_FDCAN_RxFifo0Callback: Message dropped, unmapped handle or instance stopped\n"); + return; + } + + FDCAN_RxHeaderTypeDef rx_header; + uint8_t rx_data[FDCAN_MAX_DATA_BYTES]; + + while (HAL_FDCAN_GetRxFifoFillLevel(hfdcan, FDCAN_RX_FIFO0) > 0U) { + if (HAL_FDCAN_GetRxMessage(hfdcan, FDCAN_RX_FIFO0, &rx_header, rx_data) == HAL_OK) { + CAN_Identifier id = CubeCAN_Deconstruct_Identifier(rx_header.Identifier); + uint8_t size = CubeCAN_Private_DlcToBytes(rx_header.DataLength); + rx_callback(&context, &id, rx_data, size); + } else { + LOGOMATIC_ERROR("HAL_FDCAN_RxFifo0Callback: Failed to get Rx message from FIFO\n"); + break; + } + } +} diff --git a/Lib/Peripherals/CubeCAN/Src/can_tx.c b/Lib/Peripherals/CubeCAN/Src/can_tx.c new file mode 100644 index 000000000..c14b5311c --- /dev/null +++ b/Lib/Peripherals/CubeCAN/Src/can_tx.c @@ -0,0 +1,177 @@ +#include +#include +#include +#include + +#include "CriticalSection.h" +#include "CubeCAN.h" +#include "CubeCAN_Config.h" +#include "Logomatic.h" +#include "PrivateInc/internal.h" +#include "main.h" + +void CubeCAN_Private_RateChecker(void) +{ + static uint32_t last_tick = 0; + static uint32_t call_count_in_tick = 0; + static uint32_t violations = 0; + + const uint32_t current_tick = HAL_GetTick(); + + if (current_tick == last_tick) { + call_count_in_tick++; + } else { + last_tick = current_tick; + call_count_in_tick = 1; + } + + if (current_tick > 10U && call_count_in_tick > ABSOLUTE_MAX_INVOCATIONS_PER_TICK) { + LOGOMATIC_ERROR("CubeCAN_Tick: called too frequently (%" PRIu32 " times in 1 ms), you NEED to fix your timers!\tViolation %" PRIu32 "\n", call_count_in_tick, ++violations); +#ifdef RELAXED_TIMER_GATE // Hidden feature flag if you REALLY know what you are doing but you should fix your timers instead +#warning "CubeCAN_Tick: Compiled with RELAXED_TIMER_GATE, this is a hidden feature flag that allows you to ignore the timer violation but you really should fix your timers" +#else + Error_Handler(); +#endif + } +} + +void CubeCAN_Tick(void) +{ +#ifdef DISABLED_TIMER_GATE +#warning "CubeCAN_Tick: Compiled with DISABLED_TIMER_GATE, this is a hidden feature flag that disables the timer violation check but you really should fix your timers" + static bool rate_checker_gate = true; +#else + static bool rate_checker_gate = false; +#endif + + if (__builtin_expect(!rate_checker_gate, 0)) { + CubeCAN_Private_RateChecker(); + + if (HAL_GetTick() > 5000U) { // Disable check after 5 seconds + rate_checker_gate = true; + } + } + + for (uint8_t i = 0U; i < CUBEMX_CAN_MAX_INSTANCES; ++i) { + CubeCAN_Handle *handle = &handles[i]; + + if (handle->hfdcan == NULL || !handle->started) { + continue; + } + + if (CubeCAN_Private_IsDisabled(handle)) { + LOGOMATIC_WARNING("CubeCAN_Tick: currently in restricted operation mode\n"); + if (CubeCAN_Private_RecoverPeripheral(handle) != HAL_OK) { + LOGOMATIC_ERROR("CubeCAN_Tick %d: failed to recover peripheral\n", (int)i); + continue; + } + } + + (void)CubeCAN_Private_SendQueuedMessage(handle); + } +} + +HAL_StatusTypeDef CubeCAN_Send(CubeCAN_Handle *const handle, const GRCAN_NODE_ID rx_node, const GRCAN_MSG_ID msg_id, const void *const data, const uint8_t size) +{ + if (handle == NULL || data == NULL || size > FDCAN_MAX_DATA_BYTES) { + return HAL_ERROR; + } + + const uint32_t dlc = CubeCAN_Private_BytesToDlc(size); + if (dlc == FDCAN_DLC_BYTES_0 && size != 0) { + LOGOMATIC_ERROR("CubeCAN_Send: invalid data length code\n"); + return HAL_ERROR; + } + + uint32_t fdformat = 0; + uint32_t brs = 0; + switch (handle->hfdcan->Init.FrameFormat) { + case FDCAN_FRAME_CLASSIC: + fdformat = FDCAN_CLASSIC_CAN; + brs = FDCAN_BRS_OFF; + break; + case FDCAN_FRAME_FD_NO_BRS: + fdformat = FDCAN_FD_CAN; + brs = FDCAN_BRS_OFF; + break; + case FDCAN_FRAME_FD_BRS: + fdformat = FDCAN_FD_CAN; + brs = FDCAN_BRS_ON; + break; + default: + LOGOMATIC_ERROR("CubeCAN_Send: unsupported frame format\n"); + return HAL_ERROR; + } + + const CAN_Identifier identifier_struct = {.tx_node_id = handle->config.sending_node_id, .rx_node_id = rx_node, .msg_id = msg_id}; + + const FDCAN_TxHeaderTypeDef header = {.BitRateSwitch = brs, + .DataLength = CubeCAN_Private_BytesToDlc(size), + .ErrorStateIndicator = FDCAN_ESI_ACTIVE, + .FDFormat = fdformat, + .Identifier = CubeCAN_Construct_Identifier(&identifier_struct), + .IdType = FDCAN_EXTENDED_ID, + .MessageMarker = 0U, // TODO We can do cool things with this to track transmission queue statistics + .TxEventFifoControl = FDCAN_NO_TX_EVENTS, + .TxFrameType = FDCAN_DATA_FRAME}; + + GRCAN_Private_TxMessage message = {.tx_header = header}; + memcpy(message.data, data, size); + + return CubeCAN_Private_QueueTx(handle, &message); +} + +HAL_StatusTypeDef CubeCAN_Private_QueueTx(CubeCAN_Handle *handle, const GRCAN_Private_TxMessage *message) +{ + if (handle == NULL || message == NULL) { + return HAL_ERROR; + } + + HAL_StatusTypeDef status = HAL_OK; + + CRITICAL_SECTION + { + const uint32_t tail = atomic_load_explicit(&handle->tx_tail, memory_order_relaxed); + uint32_t head = atomic_load_explicit(&handle->tx_head, memory_order_relaxed); + + if ((tail - head) >= CUBEMX_CAN_TX_QUEUE_SIZE) { + head++; // Drop oldest message to make room for the new one + atomic_store_explicit(&handle->tx_head, head, memory_order_relaxed); + status = HAL_BUSY; + } + handle->tx_queue[tail & TX_QUEUE_MASK] = *message; + + atomic_store_explicit(&handle->tx_tail, tail + 1U, memory_order_release); + } + + return status; +} + +HAL_StatusTypeDef CubeCAN_Private_SendQueuedMessage(const CubeCAN_Handle *const handle) +{ + if (handle == NULL || handle->hfdcan == NULL) { + LOGOMATIC_ERROR("CubeCAN_Private_SendQueuedMessage: invalid null parameter\n"); + return HAL_ERROR; + } + + if (HAL_FDCAN_GetTxFifoFreeLevel(handle->hfdcan) == 0U) { + LOGOMATIC_ERROR("CubeCAN_Private_SendQueuedMessage: Tx FIFO full, cannot send message\n"); + return HAL_BUSY; + } + + const uint32_t current_head = atomic_load_explicit(&handle->tx_head, memory_order_relaxed); + const uint32_t current_tail = atomic_load_explicit(&handle->tx_tail, memory_order_acquire); + + if (current_head == current_tail) { + return HAL_OK; + } + + const GRCAN_Private_TxMessage *const message_ptr = &handle->tx_queue[current_head & TX_QUEUE_MASK]; + + if (HAL_FDCAN_AddMessageToTxFifoQ(handle->hfdcan, &message_ptr->tx_header, message_ptr->data) != HAL_OK) { + return HAL_ERROR; + } + + atomic_store_explicit(&handle->tx_head, (current_head + 1U), memory_order_release); + return HAL_OK; +} diff --git a/Lib/Peripherals/CubeCAN/Src/can_utils.c b/Lib/Peripherals/CubeCAN/Src/can_utils.c new file mode 100644 index 000000000..4a3e79567 --- /dev/null +++ b/Lib/Peripherals/CubeCAN/Src/can_utils.c @@ -0,0 +1,193 @@ +#include +#include + +#include "CriticalSection.h" +#include "CubeCAN.h" +#include "GRCAN_MSG_ID.h" +#include "GRCAN_NODE_ID.h" +#include "Logomatic.h" +#include "PrivateInc/internal.h" + +#define CAN_TX_NODE_SHIFT 20U +#define CAN_MSG_SHIFT 8U +#define CAN_RX_NODE_SHIFT 0U +#define CAN_NODE_MASK 0xFFU +#define CAN_MSG_MASK 0xFFFU + +uint32_t CubeCAN_Construct_Identifier(const CAN_Identifier *identifier) +{ + if (identifier == NULL) { + return 0U; + } + + const uint32_t tx_node_id = identifier->tx_node_id & CAN_NODE_MASK; + const uint32_t msg_id = identifier->msg_id & CAN_MSG_MASK; + const uint32_t rx_node_id = identifier->rx_node_id & CAN_NODE_MASK; + + return (tx_node_id << CAN_TX_NODE_SHIFT) | (msg_id << CAN_MSG_SHIFT) | (rx_node_id << CAN_RX_NODE_SHIFT); +} + +CAN_Identifier CubeCAN_Deconstruct_Identifier(const uint32_t message_id) +{ + const GRCAN_NODE_ID tx_node_id = (message_id >> CAN_TX_NODE_SHIFT) & CAN_NODE_MASK; + const GRCAN_MSG_ID msg_id = (message_id >> CAN_MSG_SHIFT) & CAN_MSG_MASK; + const GRCAN_NODE_ID rx_node_id = (message_id >> CAN_RX_NODE_SHIFT) & CAN_NODE_MASK; + + return (CAN_Identifier){.tx_node_id = tx_node_id, .msg_id = msg_id, .rx_node_id = rx_node_id}; +} + +uint8_t CubeCAN_Private_BytesToDlc(const uint8_t bytes) +{ + switch (bytes) { + case 0U: + return FDCAN_DLC_BYTES_0; + case 1U: + return FDCAN_DLC_BYTES_1; + case 2U: + return FDCAN_DLC_BYTES_2; + case 3U: + return FDCAN_DLC_BYTES_3; + case 4U: + return FDCAN_DLC_BYTES_4; + case 5U: + return FDCAN_DLC_BYTES_5; + case 6U: + return FDCAN_DLC_BYTES_6; + case 7U: + return FDCAN_DLC_BYTES_7; + case 8U: + return FDCAN_DLC_BYTES_8; + case 12U: + return FDCAN_DLC_BYTES_12; + case 16U: + return FDCAN_DLC_BYTES_16; + case 20U: + return FDCAN_DLC_BYTES_20; + case 24U: + return FDCAN_DLC_BYTES_24; + case 32U: + return FDCAN_DLC_BYTES_32; + case 48U: + return FDCAN_DLC_BYTES_48; + case 64U: + return FDCAN_DLC_BYTES_64; + default: + LOGOMATIC_ERROR("CubeCAN_Private_BytesToDlc: Invalid byte count\n"); + return FDCAN_DLC_BYTES_0; + } +} + +uint8_t CubeCAN_Private_DlcToBytes(const uint32_t dlc) +{ + switch (dlc) { + case FDCAN_DLC_BYTES_0: + return 0U; + case FDCAN_DLC_BYTES_1: + return 1U; + case FDCAN_DLC_BYTES_2: + return 2U; + case FDCAN_DLC_BYTES_3: + return 3U; + case FDCAN_DLC_BYTES_4: + return 4U; + case FDCAN_DLC_BYTES_5: + return 5U; + case FDCAN_DLC_BYTES_6: + return 6U; + case FDCAN_DLC_BYTES_7: + return 7U; + case FDCAN_DLC_BYTES_8: + return 8U; + case FDCAN_DLC_BYTES_12: + return 12U; + case FDCAN_DLC_BYTES_16: + return 16U; + case FDCAN_DLC_BYTES_20: + return 20U; + case FDCAN_DLC_BYTES_24: + return 24U; + case FDCAN_DLC_BYTES_32: + return 32U; + case FDCAN_DLC_BYTES_48: + return 48U; + case FDCAN_DLC_BYTES_64: + return 64U; + default: + LOGOMATIC_ERROR("CubeCAN_Private_DlcToBytes: Invalid DLC value\n"); + return 0U; + } +} + +bool CubeCAN_Private_IsDisabled(const CubeCAN_Handle *const handle) +{ + if (handle == NULL) { + return true; + } + + bool disabled = true; + + CRITICAL_SECTION + { + if (handle->hfdcan != NULL) { + const HAL_FDCAN_StateTypeDef state = HAL_FDCAN_GetState(handle->hfdcan); + FDCAN_ProtocolStatusTypeDef protocol_status = {0}; + + bool is_bus_off = false; + + if (HAL_FDCAN_GetProtocolStatus(handle->hfdcan, &protocol_status) == HAL_OK) { + is_bus_off = protocol_status.BusOff; + } + + disabled = (state == HAL_FDCAN_STATE_ERROR || state == HAL_FDCAN_STATE_READY || is_bus_off); + } + } + + return disabled; +} + +HAL_StatusTypeDef CubeCAN_Private_RecoverPeripheral(const CubeCAN_Handle *const handle) +{ + if (handle == NULL) { + return HAL_ERROR; + } + + HAL_StatusTypeDef status = HAL_OK; + + CRITICAL_SECTION + { + if (handle->hfdcan != NULL && handle->started) { + FDCAN_ProtocolStatusTypeDef protocol_status = {0}; + + if (HAL_FDCAN_GetProtocolStatus(handle->hfdcan, &protocol_status) == HAL_OK && protocol_status.BusOff) { + LOGOMATIC_ERROR("CubeCAN_Private_RecoverPeripheral: CRITICAL BUS-OFF DETECTED. Forcing hardware reset...\n"); + + HAL_FDCAN_Stop(handle->hfdcan); + + status = HAL_FDCAN_Init(handle->hfdcan); + + if (status == HAL_OK) { + status = HAL_FDCAN_ActivateNotification(handle->hfdcan, FDCAN_IT_RX_EVENTS, 0U); + } + + if (status == HAL_OK) { + status = HAL_FDCAN_Start(handle->hfdcan); + } + + if (status != HAL_OK) { + LOGOMATIC_ERROR("CubeCAN_Private_RecoverPeripheral: Aggressive hardware start failed!\n"); + } + } + + if (HAL_FDCAN_IsRestrictedOperationMode(handle->hfdcan)) { + LOGOMATIC_WARNING("CubeCAN_Private_RecoverPeripheral: Forcing exit from restricted operation mode\n"); + status = HAL_FDCAN_ExitRestrictedOperationMode(handle->hfdcan); + + if (status != HAL_OK) { + LOGOMATIC_ERROR("CubeCAN_Private_RecoverPeripheral: Failed to recover peripheral\n"); + } + } + } + } + + return status; +} diff --git a/Lib/Peripherals/CubeCAN/cube_can.cmake b/Lib/Peripherals/CubeCAN/cube_can.cmake new file mode 100644 index 000000000..0168d0d8c --- /dev/null +++ b/Lib/Peripherals/CubeCAN/cube_can.cmake @@ -0,0 +1,21 @@ +add_library(CUBE_CAN_LIB INTERFACE) + +target_include_directories(CUBE_CAN_LIB INTERFACE ${CMAKE_CURRENT_LIST_DIR}/Inc) + +target_sources( + CUBE_CAN_LIB + INTERFACE + ${CMAKE_CURRENT_LIST_DIR}/Src/can_assert.c + ${CMAKE_CURRENT_LIST_DIR}/Src/can_global.c + ${CMAKE_CURRENT_LIST_DIR}/Src/can_init.c + ${CMAKE_CURRENT_LIST_DIR}/Src/can_rx.c + ${CMAKE_CURRENT_LIST_DIR}/Src/can_tx.c + ${CMAKE_CURRENT_LIST_DIR}/Src/can_utils.c +) + +target_link_libraries( + CUBE_CAN_LIB + INTERFACE + CANfigurator + LOGOMATIC_LIB +) diff --git a/Lib/Peripherals/TimedCAN/common.cmake b/Lib/Peripherals/TimedCAN/common.cmake index f2b227054..12a7334dd 100644 --- a/Lib/Peripherals/TimedCAN/common.cmake +++ b/Lib/Peripherals/TimedCAN/common.cmake @@ -11,3 +11,10 @@ target_sources( INTERFACE ${CMAKE_CURRENT_LIST_DIR}/Src/can.c ) + +set_target_properties( + PERIPHERAL_TIMEDCAN_LIB + PROPERTIES + DEPRECATION + "PERIPHERAL_TIMEDCAN_LIB is deprecated and should be replaced by CUBE_CAN_LIB." +) diff --git a/Lib/Peripherals/USART/common.cmake b/Lib/Peripherals/USART/common.cmake index 5c0d4577b..2f8aaac01 100644 --- a/Lib/Peripherals/USART/common.cmake +++ b/Lib/Peripherals/USART/common.cmake @@ -8,3 +8,10 @@ target_include_directories( INTERFACE ${CMAKE_CURRENT_LIST_DIR}/../.. ) + +set_target_properties( + PERIPHERAL_USART_LIB + PROPERTIES + DEPRECATION + "PERIPHERAL_USART_LIB is deprecated and should be removed in favor of STM32CubeMX functionality or VCP_LIB." +) diff --git a/Lib/Utils/CubeVCP/Inc/CubeVCP.h b/Lib/Utils/CubeVCP/Inc/CubeVCP.h new file mode 100644 index 000000000..052485587 --- /dev/null +++ b/Lib/Utils/CubeVCP/Inc/CubeVCP.h @@ -0,0 +1,80 @@ +#include + +#include "main.h" + +#ifndef CUBE_VCP_H +#define CUBE_VCP_H + +/** + * @brief Callback function type for UART transmission complete events in CubeVCP. + * @param huart Pointer to the UART handle. + */ +typedef void (*CubeVCP_UART_TxCpltCallback)(UART_HandleTypeDef *huart); + +/** + * @brief Callback function type for UART reception complete events in CubeVCP. + * @param huart Pointer to the UART handle. + */ +typedef void (*CubeVCP_UART_RxCpltCallback)(UART_HandleTypeDef *huart); + +/** + * @brief Callback function type for handling received data in CubeVCP. + * @param buffer Pointer to the received data buffer. + * @param length Length of the received data in bytes. + */ +typedef void (*CubeVCP_Rx_Callback)(const uint8_t *const buffer, const uint16_t length); + +/** + * @brief Callback function pointer for handling UART transmission complete events in CubeVCP that are not related to the VCP transmission + * + * This function pointer allows users to define their own callback function to handle UART transmission complete events that are not related to the VCP transmission. + * It is called when a UART transmission complete event occurs for a UART instance that is not the one used for VCP transmission. + * + * @note This variable should not be modified once setup by the user. + * @warning The callback function should be thread-safe and should not block for long periods of time + */ +extern __weak CubeVCP_UART_TxCpltCallback const vcp_uart_tx_cplt_callback_other; + +/** + * @brief Callback function pointer for handling UART reception complete events in CubeVCP that are not related to the VCP transmission + * + * This function pointer allows users to define their own callback function to handle UART reception complete events that are not related to the VCP transmission. + * It is called when a UART reception complete event occurs for a UART instance that is not the one used for VCP transmission. + * + * @note This variable should not be modified once setup by the user. + * @warning The callback function should be thread-safe and should not block for long periods of time + */ +extern __weak CubeVCP_UART_RxCpltCallback const vcp_uart_rx_cplt_callback_other; + +/** + * @brief Initialize CubeVCP with the UART handle to be used for VCP communication. + * @param huart Pointer to the UART handle that will be used for VCP transmission and reception. + * @retval HAL_StatusTypeDef HAL_OK if initialization was successful, HAL_ERROR if huart is NULL, or HAL_BUSY if already initialized. + * @note This function MUST be called first before any other CubeVCP functions. + * @note The UART handle must be properly initialized and configured by STM32CubeMX before calling this function. + */ +HAL_StatusTypeDef CubeVCP_Setup(UART_HandleTypeDef *huart); + +/** + * @brief Enable reception of data over the VCP interface and set the callback function to handle received data. + * @param callback Pointer to the callback function that will be called when data is received over the VCP interface. + * @retval HAL_StatusTypeDef HAL_OK if the reception was successfully enabled, HAL_ERROR if there was an error, or HAL_BUSY if the reception is already enabled. + * @note This function should be called after CubeVCP_Setup() and after the UART handle has been properly initialized and configured by STM32CubeMX. + * @note RX uses double buffering, so data reception continues uninterrupted while the callback processes data. + * @warning The callback function should be thread-safe and should not block for long periods of time, you easily can lose data on long messages if not properly configured. + */ +HAL_StatusTypeDef CubeVCP_EnableRx(CubeVCP_Rx_Callback callback); + +/** + * @brief Send a string over the VCP interface + * @param data Pointer to the string data to be sent + * @param length Length of the string data to be sent + * @retval HAL_StatusTypeDef HAL_OK if the string was successfully queued for transmission, HAL_ERROR if there was an error, or HAL_BUSY if the internal buffer is full + * @note This function is non-blocking and will return immediately. The data will be sent in the background using interrupts. + * @note The data buffer does not have to remain valid after the function returns, as the data will be copied into an internal buffer for transmission. + * @note The maximum length of the data that can be sent is defined by CUBE_VCP_TX_BUFFER_SIZE. If the length of the data exceeds this value, only the first CUBE_VCP_TX_BUFFER_SIZE bytes will be + * sent. + */ +HAL_StatusTypeDef CubeVCP_SendString(const char *const data, uint16_t length); + +#endif diff --git a/Lib/Utils/CubeVCP/README.md b/Lib/Utils/CubeVCP/README.md new file mode 100644 index 000000000..d8f73f935 --- /dev/null +++ b/Lib/Utils/CubeVCP/README.md @@ -0,0 +1,3 @@ +# Virtual COM Port + +TODO diff --git a/Lib/Utils/CubeVCP/Src/PrivateInc/internal.h b/Lib/Utils/CubeVCP/Src/PrivateInc/internal.h new file mode 100644 index 000000000..71e88bb52 --- /dev/null +++ b/Lib/Utils/CubeVCP/Src/PrivateInc/internal.h @@ -0,0 +1,130 @@ +#include +#include +#include + +#include "CubeVCP_Config.h" + +#ifndef CUBE_VCP_INTERNAL_H +#define CUBE_VCP_INTERNAL_H + +/** + * @brief Mask for the ring buffer used in VCP transmission. + * + * This mask is used to wrap the head and tail indices of the ring buffer to ensure they stay within the bounds of the buffer size. + * + * @note The size of the ring buffer must be a power of two for this mask to work correctly + */ +#define VCP_TX_BUFFER_MASK (CUBE_VCP_TX_BUFFER_SIZE - 1) + +/** + * @brief Callback function pointer for handling received data in CubeVCP. + * + * This function pointer allows users to define their own callback function to handle received data in CubeVCP. + * The callback function will be invoked either off of buffers or off of individual bytes, depending on the configuration of CubeVCP. + * + * @warning The callback function should be thread-safe and should not block for long periods of time + */ +extern CubeVCP_Rx_Callback vcp_rx_callback; + +/** + * @brief Pointer to the UART handle used for VCP transmission. + * + * This pointer should be set to the UART handle that is used for VCP transmission. + * It is used internally by CubeVCP to manage the transmission of data over the VCP interface. + * This can be LPUART, USART, or any other UART peripheral that is configured for VCP transmission. + * + * @note This variable should not be modified once setup by the user. + * @warning The UART handle should be properly initialized and configured before using CubeVCP functions by STM32CubeMX. + */ +extern UART_HandleTypeDef *vcp_uart_handle; + +/** + * @brief Head of the ring buffer for VCP transmission. + * + * This atomic variable keeps track of the current head index in the ring buffer + * It is used to determine where new data should be written in the buffer + * + * @warning Requires atomic operations to ensure thread safety when accessed from multiple contexts + */ +extern _Atomic uint16_t vcp_ring_head; + +/** + * @brief Tail of the ring buffer for VCP transmission. + * + * This atomic variable keeps track of the current tail index in the ring buffer + * It is used to determine where data should be read from the buffer for transmission + * + * @warning Requires atomic operations to ensure thread safety when accessed from multiple contexts + */ +extern _Atomic uint16_t vcp_ring_tail; + +/** + * @brief Flag indicating whether a VCP transmission is currently active + * + * This atomic boolean variable is set to true when a transmission is in progress and false when the transmission is complete + * + * @warning Requires atomic operations to ensure thread safety when accessed from multiple contexts + */ +extern _Atomic bool vcp_tx_active; + +/** + * @brief Ring buffer for VCP transmission. + * + * This buffer is used to store data that is to be transmitted over the VCP interface + * + * @note Access only through atomic operations to ensure thread safety when accessed from multiple contexts + * @warning The size of this buffer is defined by CUBE_VCP_TX_BUFFER_SIZE and must be a power of two for proper operation + */ +extern uint8_t vcp_tx_buffer[]; + +/** + * @brief The next byte to be received in the VCP reception buffer. + * + * This variable is used to store the byte that has just been received from the UART interface before it is placed into the reception buffer. + * + * @warning Only the UART interrupt handler should modify this variable to ensure correct operation. + */ +extern uint8_t vcp_rx_byte; + +/** + * @brief Staging buffer for VCP reception. + * + * This buffer is used to temporarily store received data before it is processed by the application. + * + * @note The size of this buffer is defined by CUBE_VCP_RX_BUFFER_SIZE + */ +extern uint8_t vcp_callback_staging[]; + +/** + * @brief Double reception buffers for VCP (2 buffers for seamless RX without pauses). + * + * These buffers are used for double-buffering: one buffer fills while the ISR processes and swaps to the other. + * This allows continuous RX reception without data loss or pauses. + * + * @note The size of each buffer is defined by CUBE_VCP_RX_BUFFER_SIZE + * @remark Access only from ISR context to ensure thread safety + */ +extern uint8_t vcp_rx_buffer[]; + +/** + * @brief Index of the next byte to be written in the current VCP reception buffer. + * + * This atomic variable is used to keep track of the index where the next byte should be written in the current VCP reception buffer. + * When the buffer fills or a newline is received, the callback is invoked and this index is reset to 0. + * + * @warning Requires atomic operations to ensure thread safety when accessed from multiple contexts + */ +extern uint16_t vcp_rx_index; + +/** + * @brief Index of the current RX buffer (0 or 1) being written to by the ISR. + * + * This atomic variable tracks which of the two receive buffers is currently being filled. + * When a buffer fills or a newline is received, the callback is invoked with that buffer's contents, + * and the index automatically switches to the other buffer. This allows continuous RX without data loss. + * + * @warning Requires atomic operations to ensure thread safety when accessed from multiple contexts + */ +extern uint8_t vcp_rx_current_buffer; + +#endif diff --git a/Lib/Utils/CubeVCP/Src/vcp_assert.c b/Lib/Utils/CubeVCP/Src/vcp_assert.c new file mode 100644 index 000000000..927f04be6 --- /dev/null +++ b/Lib/Utils/CubeVCP/Src/vcp_assert.c @@ -0,0 +1,12 @@ +#include + +#include "CubeVCP.h" +#include "CubeVCP_Config.h" +#include "main.h" + +static_assert(ATOMIC_BOOL_LOCK_FREE == 2, "CubeVCP internal ATOMIC_BOOL_LOCK_FREE must be enabled for atomic operations"); +static_assert(ATOMIC_SHORT_LOCK_FREE == 2, "CubeVCP internal ATOMIC_SHORT_LOCK_FREE must be enabled for atomic operations"); + +static_assert((CUBE_VCP_TX_BUFFER_SIZE > 0) && !(CUBE_VCP_TX_BUFFER_SIZE & (CUBE_VCP_TX_BUFFER_SIZE - 1U)), "CUBE_VCP_TX_BUFFER_SIZE must be a power of two and greater than zero"); +static_assert(CUBE_VCP_RX_BUFFER_SIZE > 8, + "CUBE_VCP_RX_BUFFER_SIZE must be greater than 8 bytes to ensure useful command input is possible. It is recommended to set this to at least 32 bytes for practical use cases."); diff --git a/Lib/Utils/CubeVCP/Src/vcp_global.c b/Lib/Utils/CubeVCP/Src/vcp_global.c new file mode 100644 index 000000000..cc1f0755e --- /dev/null +++ b/Lib/Utils/CubeVCP/Src/vcp_global.c @@ -0,0 +1,20 @@ +#include "CubeVCP.h" +#include "PrivateInc/internal.h" + +UART_HandleTypeDef *vcp_uart_handle = NULL; + +__weak CubeVCP_UART_TxCpltCallback const vcp_uart_tx_cplt_callback_other = NULL; +__weak CubeVCP_UART_RxCpltCallback const vcp_uart_rx_cplt_callback_other = NULL; + +CubeVCP_Rx_Callback vcp_rx_callback = NULL; + +uint8_t vcp_tx_buffer[CUBE_VCP_TX_BUFFER_SIZE]; + +_Atomic uint16_t vcp_ring_head; +_Atomic uint16_t vcp_ring_tail; +_Atomic bool vcp_tx_active; + +uint16_t vcp_rx_index; +uint8_t vcp_rx_byte; +uint8_t vcp_rx_buffer[CUBE_VCP_RX_BUFFER_SIZE]; +uint8_t vcp_callback_staging[CUBE_VCP_RX_BUFFER_SIZE]; diff --git a/Lib/Utils/CubeVCP/Src/vcp_init.c b/Lib/Utils/CubeVCP/Src/vcp_init.c new file mode 100644 index 000000000..548aa7541 --- /dev/null +++ b/Lib/Utils/CubeVCP/Src/vcp_init.c @@ -0,0 +1,30 @@ +#include "CubeVCP.h" +#include "CubeVCP_Config.h" +#include "Logomatic.h" +#include "PrivateInc/internal.h" +#include "main.h" +#include "usart.h" + +HAL_StatusTypeDef CubeVCP_Setup(UART_HandleTypeDef *huart) +{ + static bool initialized = false; + if (initialized) { + LOGOMATIC_ERROR("CubeVCP_Setup: already initialized"); + return HAL_BUSY; + } else { + initialized = true; + } + + if (huart == NULL) { + LOGOMATIC_ERROR("CubeVCP_Setup: huart is NULL"); + return HAL_ERROR; + } + + vcp_uart_handle = huart; + + atomic_store_explicit(&vcp_ring_head, 0, memory_order_relaxed); + atomic_store_explicit(&vcp_ring_tail, 0, memory_order_relaxed); + atomic_store_explicit(&vcp_tx_active, false, memory_order_relaxed); + + return HAL_OK; +} diff --git a/Lib/Utils/CubeVCP/Src/vcp_rx.c b/Lib/Utils/CubeVCP/Src/vcp_rx.c new file mode 100644 index 000000000..9255db438 --- /dev/null +++ b/Lib/Utils/CubeVCP/Src/vcp_rx.c @@ -0,0 +1,95 @@ +#include +#include + +#include "CriticalSection.h" +#include "CubeVCP.h" +#include "CubeVCP_Config.h" +#include "Logomatic.h" +#include "PrivateInc/internal.h" +#include "main.h" + +HAL_StatusTypeDef CubeVCP_EnableRx(CubeVCP_Rx_Callback callback) +{ + static bool enabled = false; + if (enabled) { + LOGOMATIC_ERROR("CubeVCP_EnableRx: already enabled"); + return HAL_BUSY; + } else { + enabled = true; + } + + if (vcp_uart_handle == NULL) { + LOGOMATIC_ERROR("CubeVCP_EnableRx: vcp_uart_handle is NULL"); + return HAL_ERROR; + } + + if (callback == NULL) { + LOGOMATIC_ERROR("CubeVCP_EnableRx: callback is NULL"); + return HAL_ERROR; + } + + vcp_rx_callback = callback; + + atomic_store_explicit(&vcp_rx_index, 0, memory_order_relaxed); + + HAL_StatusTypeDef status = HAL_UART_Receive_IT(vcp_uart_handle, &vcp_rx_byte, 1); + + if (status != HAL_OK) { + LOGOMATIC_ERROR("CubeVCP_EnableRx: HAL_UART_Receive_IT failed"); + return status; + } + + return HAL_OK; +} + +void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) +{ + if (huart->Instance != vcp_uart_handle->Instance) { + if (vcp_uart_rx_cplt_callback_other != NULL) { + vcp_uart_rx_cplt_callback_other(huart); + } + return; + } + + uint8_t received_byte = vcp_rx_byte; + uint16_t index = vcp_rx_index; + + vcp_rx_buffer[index++] = received_byte; + + if (received_byte == '\n' || index >= CUBE_VCP_RX_BUFFER_SIZE) { + uint16_t filled_len = index; + + CRITICAL_SECTION + { + for (uint16_t i = 0; i < filled_len; i++) { + vcp_callback_staging[i] = vcp_rx_buffer[i]; + } + vcp_rx_index = 0; + } + + __HAL_UART_CLEAR_OREFLAG(huart); + __HAL_UART_CLEAR_NEFLAG(huart); + __HAL_UART_CLEAR_FEFLAG(huart); + + if (HAL_UART_Receive_IT(vcp_uart_handle, &vcp_rx_byte, 1) != HAL_OK) { + huart->RxState = HAL_UART_STATE_READY; + HAL_UART_Receive_IT(vcp_uart_handle, &vcp_rx_byte, 1); + } + + if (vcp_rx_callback != NULL) { + vcp_rx_callback(vcp_callback_staging, filled_len); + } + + } else { + CRITICAL_SECTION + { + vcp_rx_index = index; + } + + __HAL_UART_CLEAR_OREFLAG(huart); + if (HAL_UART_Receive_IT(vcp_uart_handle, &vcp_rx_byte, 1) != HAL_OK) { + huart->RxState = HAL_UART_STATE_READY; + HAL_UART_Receive_IT(vcp_uart_handle, &vcp_rx_byte, 1); + } + } +} diff --git a/Lib/Utils/CubeVCP/Src/vcp_tx.c b/Lib/Utils/CubeVCP/Src/vcp_tx.c new file mode 100644 index 000000000..d0261cf7f --- /dev/null +++ b/Lib/Utils/CubeVCP/Src/vcp_tx.c @@ -0,0 +1,104 @@ +#include +#include +#include + +#include "CubeVCP.h" +#include "PrivateInc/internal.h" +#include "main.h" +#include "usart.h" + +HAL_StatusTypeDef CubeVCP_SendString(const char *const str, uint16_t length) +{ + if (vcp_uart_handle == NULL || str == NULL || length == 0) { + return HAL_ERROR; + } + + uint16_t current_head = atomic_load_explicit(&vcp_ring_head, memory_order_relaxed); + uint16_t current_tail = atomic_load_explicit(&vcp_ring_tail, memory_order_acquire); + uint16_t used_space = current_head - current_tail; + uint16_t free_space = CUBE_VCP_TX_BUFFER_SIZE - used_space; + + if (length > free_space) { + length = free_space; + } + + if (length == 0) { + return HAL_BUSY; + } + + uint16_t local_head = current_head; + for (uint16_t i = 0; i < length; i++) { + vcp_tx_buffer[local_head & VCP_TX_BUFFER_MASK] = (uint8_t)str[i]; + local_head++; + } + + atomic_store_explicit(&vcp_ring_head, local_head, memory_order_release); + + if (!atomic_load_explicit(&vcp_tx_active, memory_order_relaxed)) { + if (!atomic_exchange_explicit(&vcp_tx_active, true, memory_order_acquire)) { + /* We successfully set tx_active to true */ + uint16_t current_tail = atomic_load_explicit(&vcp_ring_tail, memory_order_acquire); + uint16_t current_head = atomic_load_explicit(&vcp_ring_head, memory_order_acquire); + + if (current_tail != current_head) { + uint16_t tail_idx = current_tail & VCP_TX_BUFFER_MASK; + uint16_t head_idx = current_head & VCP_TX_BUFFER_MASK; + uint16_t send_size = (head_idx > tail_idx) ? (head_idx - tail_idx) : (CUBE_VCP_TX_BUFFER_SIZE - tail_idx); + + HAL_StatusTypeDef status = HAL_UART_Transmit_IT(vcp_uart_handle, &vcp_tx_buffer[tail_idx], send_size); + if (status != HAL_OK) { + atomic_store_explicit(&vcp_tx_active, false, memory_order_release); + return status; + } + } else { + /* No data to send, clear the active flag */ + atomic_store_explicit(&vcp_tx_active, false, memory_order_release); + } + } + } + + return HAL_OK; +} + +void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart) +{ + if (vcp_uart_handle == NULL || huart->Instance != vcp_uart_handle->Instance) { + if (vcp_uart_tx_cplt_callback_other != NULL) { + vcp_uart_tx_cplt_callback_other(huart); + } + return; + } + + uint16_t current_tail = atomic_load_explicit(&vcp_ring_tail, memory_order_relaxed) + huart->TxXferSize; + atomic_store_explicit(&vcp_ring_tail, current_tail, memory_order_release); + + uint16_t current_head = atomic_load_explicit(&vcp_ring_head, memory_order_acquire); + + if (current_tail != current_head) { + uint16_t tail_idx = current_tail & VCP_TX_BUFFER_MASK; + uint16_t head_idx = current_head & VCP_TX_BUFFER_MASK; + + uint16_t send_size = (head_idx > tail_idx) ? (head_idx - tail_idx) : (CUBE_VCP_TX_BUFFER_SIZE - tail_idx); + + if (HAL_UART_Transmit_IT(vcp_uart_handle, &vcp_tx_buffer[tail_idx], send_size) != HAL_OK) { + atomic_store_explicit(&vcp_tx_active, false, memory_order_release); + } + } else { + atomic_store_explicit(&vcp_tx_active, false, memory_order_release); + + current_head = atomic_load_explicit(&vcp_ring_head, memory_order_acquire); + if (current_tail != current_head) { + if (!atomic_load_explicit(&vcp_tx_active, memory_order_relaxed)) { + atomic_store_explicit(&vcp_tx_active, true, memory_order_relaxed); + + uint16_t tail_idx = current_tail & VCP_TX_BUFFER_MASK; + uint16_t head_idx = current_head & VCP_TX_BUFFER_MASK; + uint16_t send_size = (head_idx > tail_idx) ? (head_idx - tail_idx) : (CUBE_VCP_TX_BUFFER_SIZE - tail_idx); + + if (HAL_UART_Transmit_IT(vcp_uart_handle, &vcp_tx_buffer[tail_idx], send_size) != HAL_OK) { + atomic_store_explicit(&vcp_tx_active, false, memory_order_release); + } + } + } + } +} diff --git a/Lib/Utils/CubeVCP/vcp.cmake b/Lib/Utils/CubeVCP/vcp.cmake new file mode 100644 index 000000000..e79b445b0 --- /dev/null +++ b/Lib/Utils/CubeVCP/vcp.cmake @@ -0,0 +1,15 @@ +add_library(CUBE_VCP_LIB INTERFACE) + +target_include_directories(CUBE_VCP_LIB INTERFACE ${CMAKE_CURRENT_LIST_DIR}/Inc) + +target_sources( + CUBE_VCP_LIB + INTERFACE + ${CMAKE_CURRENT_LIST_DIR}/Src/vcp_assert.c + ${CMAKE_CURRENT_LIST_DIR}/Src/vcp_global.c + ${CMAKE_CURRENT_LIST_DIR}/Src/vcp_init.c + ${CMAKE_CURRENT_LIST_DIR}/Src/vcp_rx.c + ${CMAKE_CURRENT_LIST_DIR}/Src/vcp_tx.c +) + +target_link_libraries(CUBE_VCP_LIB INTERFACE LOGOMATIC_LIB) diff --git a/Lib/Utils/Logomatic/Inc/Logomatic.h b/Lib/Utils/Logomatic/Inc/Logomatic.h index d291f296a..061fd76d1 100644 --- a/Lib/Utils/Logomatic/Inc/Logomatic.h +++ b/Lib/Utils/Logomatic/Inc/Logomatic.h @@ -1,140 +1,224 @@ -#include +#include #include #include "main.h" -#ifndef _LOGOMATIC_H_ -#define _LOGOMATIC_H_ +#ifndef LOGOMATIC_H +#define LOGOMATIC_H -#if defined(ITM) && defined(LL_GPIO_MODE_ALTERNATE) -typedef enum { - LOGOMATIC_PCLK1 = LL_RCC_LPUART1_CLKSOURCE_PCLK1, - LOGOMATIC_SYSCLK = LL_RCC_LPUART1_CLKSOURCE_SYSCLK, - LOGOMATIC_HSI = LL_RCC_LPUART1_CLKSOURCE_HSI, - LOGOMATIC_LSE = LL_RCC_LPUART1_CLKSOURCE_LSE -} LPUART_Clock_Source; - -typedef enum { - LOGOMATIC_BUS = LL_APB1_GRP2_PERIPH_LPUART1, -} LPUART_Bus; - -typedef enum { - LOGOMATIC_GPIOA = LL_AHB2_GRP1_PERIPH_GPIOA, - LOGOMATIC_GPIOB = LL_AHB2_GRP1_PERIPH_GPIOB, - LOGOMATIC_GPIOC = LL_AHB2_GRP1_PERIPH_GPIOC, - LOGOMATIC_GPIOD = LL_AHB2_GRP1_PERIPH_GPIOD, - LOGOMATIC_GPIOE = LL_AHB2_GRP1_PERIPH_GPIOE, - LOGOMATIC_GPIOF = LL_AHB2_GRP1_PERIPH_GPIOF, - LOGOMATIC_GPIOG = LL_AHB2_GRP1_PERIPH_GPIOG, -} LPUART_GPIO_Port; - -typedef enum { - LOGOMATIC_DATAWIDTH_7B = LL_LPUART_DATAWIDTH_7B, - LOGOMATIC_DATAWIDTH_8B = LL_LPUART_DATAWIDTH_8B, - LOGOMATIC_DATAWIDTH_9B = LL_LPUART_DATAWIDTH_9B -} LPUART_DataWidth; +/// @brief Logomatic log level type, used to define the severity of log messages +#define _LOGOMATIC_LOGLEVEL_PRIVATE_LIST \ + X(LogLevel_Off, 0, "OFF") \ + X(LogLevel_Critical, 1, "CRITICAL") \ + X(LogLevel_Error, 2, "ERROR") \ + X(LogLevel_Warning, 3, "WARNING") \ + X(LogLevel_Info, 4, "INFO") \ + X(LogLevel_Debug, 5, "DEBUG") \ + X(LogLevel_Verbose, 6, "VERBOSE") typedef enum { - LOGOMATIC_STOPBITS_1 = LL_LPUART_STOPBITS_1, - LOGOMATIC_STOPBITS_2 = LL_LPUART_STOPBITS_2 -} LPUART_StopBits; +#define X(name, val, str) name = val, + _LOGOMATIC_LOGLEVEL_PRIVATE_LIST +#undef X +} Logomatic_LogLevel; -typedef enum { - LOGOMATIC_PARITY_NONE = LL_LPUART_PARITY_NONE, - LOGOMATIC_PARITY_EVEN = LL_LPUART_PARITY_EVEN, - LOGOMATIC_PARITY_ODD = LL_LPUART_PARITY_ODD -} LPUART_Parity; +/** + * @brief Set the global log level + * + * Only logs with a higher or equal severity than the global log level will be printed. + * + * @param level The log level to set as the global log level. This should be one of the values from the Logomatic_LogLevel enum. + * @return true if the log level was successfully set, false if the provided log level is invalid. + */ +bool Logomatic_SetLogLevel(Logomatic_LogLevel level); -typedef enum { - LOGOMATIC_DIRECTION_NONE = LL_LPUART_DIRECTION_NONE, - LOGOMATIC_DIRECTION_RX = LL_LPUART_DIRECTION_RX, - LOGOMATIC_DIRECTION_TX = LL_LPUART_DIRECTION_TX, - LOGOMATIC_DIRECTION_TX_RX = LL_LPUART_DIRECTION_TX_RX -} LPUART_TransferDirection; +/** + * @brief Logomatic log level strings + * + * This array is used to map the log level enum values to their corresponding string representations for printing log messages. + * + * @note The order of the strings in this array must match the order of the enum values in Logomatic_LogLevel. + */ +extern const char *Logomatic_Private_LogLevelStrings[]; -typedef enum { - LOGOMATIC_HWCONTROL_NONE = LL_LPUART_HWCONTROL_NONE, - LOGOMATIC_HWCONTROL_RTS = LL_LPUART_HWCONTROL_RTS, - LOGOMATIC_HWCONTROL_CTS = LL_LPUART_HWCONTROL_CTS, - LOGOMATIC_HWCONTROL_RTS_CTS = LL_LPUART_HWCONTROL_RTS_CTS -} LPUART_HardwareFlowControl; +/** + * @brief Logomatic driver function pointer type + * + * This is used to define the log driver function that will be used to output log messages + * + * @note Default log drivers are provided for you but you can implement your own log driver by defining a function that matches this signature and assigning it to the global_logomatic_driver variable + */ +typedef int (*Logomatic_Driver)(int); -typedef enum { - LOGOMATIC_PRESCALER_DIV1 = LL_LPUART_PRESCALER_DIV1, - LOGOMATIC_PRESCALER_DIV2 = LL_LPUART_PRESCALER_DIV2, - LOGOMATIC_PRESCALER_DIV4 = LL_LPUART_PRESCALER_DIV4, - LOGOMATIC_PRESCALER_DIV6 = LL_LPUART_PRESCALER_DIV6, - LOGOMATIC_PRESCALER_DIV8 = LL_LPUART_PRESCALER_DIV8, - LOGOMATIC_PRESCALER_DIV10 = LL_LPUART_PRESCALER_DIV10, - LOGOMATIC_PRESCALER_DIV12 = LL_LPUART_PRESCALER_DIV12, - LOGOMATIC_PRESCALER_DIV16 = LL_LPUART_PRESCALER_DIV16, - LOGOMATIC_PRESCALER_DIV32 = LL_LPUART_PRESCALER_DIV32, - LOGOMATIC_PRESCALER_DIV64 = LL_LPUART_PRESCALER_DIV64, - LOGOMATIC_PRESCALER_DIV128 = LL_LPUART_PRESCALER_DIV128, - LOGOMATIC_PRESCALER_DIV256 = LL_LPUART_PRESCALER_DIV256 -} LPUART_Prescaler; +/** + * @brief Global log level variable + * + * Store the global log level in this variable. It is used to determine which log messages should be printed based on their severity. + * + * @warning This variable should not be modified once setup by the user. + */ +extern Logomatic_LogLevel _logomatic_loglevel; -typedef enum { - LOGOMATIC_FIFOTHRESHOLD_1_8 = LL_LPUART_FIFOTHRESHOLD_1_8, - LOGOMATIC_FIFOTHRESHOLD_1_4 = LL_LPUART_FIFOTHRESHOLD_1_4, - LOGOMATIC_FIFOTHRESHOLD_1_2 = LL_LPUART_FIFOTHRESHOLD_1_2, - LOGOMATIC_FIFOTHRESHOLD_3_4 = LL_LPUART_FIFOTHRESHOLD_3_4, - LOGOMATIC_FIFOTHRESHOLD_7_8 = LL_LPUART_FIFOTHRESHOLD_7_8, - LOGOMATIC_FIFOTHRESHOLD_8_8 = LL_LPUART_FIFOTHRESHOLD_8_8 -} LPUART_FifoThreshold; - -typedef struct { - LPUART_Clock_Source clock_source; - LPUART_Bus bus; - LPUART_GPIO_Port gpio_port; - uint32_t gpio_pin_rx_tx_mask; - uint32_t baud_rate; - LPUART_DataWidth data_width; - LPUART_StopBits stop_bits; - LPUART_Parity parity; - LPUART_TransferDirection transfer_direction; - LPUART_HardwareFlowControl hardware_flow_control; - LPUART_Prescaler prescaler; - LPUART_FifoThreshold tx_fifo_threshold; - LPUART_FifoThreshold rx_fifo_threshold; -} LogomaticConfig; -#else -typedef uint8_t LogomaticConfig; +/** + * @brief Logomatic driver function pointer + * + * This function pointer is used to point to the appropriate log driver function based on the selected log output method (e.g., ITM, UART, etc.) + * + * @note This variable should not be modified once setup by the user. + */ +#ifndef LOGOMATIC_HOOTLTEST +extern __weak Logomatic_Driver const global_logomatic_driver; #endif -void Setup_Logomatic(LogomaticConfig *config); +#ifdef LOGOMATIC_HOOTLTEST -#ifdef LOGOMATIC_ENABLED -/** - * @brief ENABLED - Logs a message to the ITM console. - * @param ... The format string and arguments to log. - * @note This function is only enabled when LOGOMATIC_ENABLED is defined. Otherwise, it will be compiled out. - * @note This function is designed to be used with the ITM console, as a result printing floats is an intensive operation. - */ -#define LOGOMATIC(...) \ +#define LOGOMATIC_CRITICAL(...) \ + do { \ + printf("[CRITICAL] "); \ + printf(__VA_ARGS__); \ + } while (0) +#define LOGOMATIC_ERROR(...) \ + do { \ + printf("[ERROR] "); \ + printf(__VA_ARGS__); \ + } while (0) +#define LOGOMATIC_WARNING(...) \ + do { \ + printf("[WARNING] "); \ + printf(__VA_ARGS__); \ + } while (0) +#define LOGOMATIC_INFO(...) \ do { \ - _Pragma("GCC diagnostic push"); \ - _Pragma("GCC diagnostic ignored \"-Wdouble-promotion\""); \ + printf("[INFO] "); \ + printf(__VA_ARGS__); \ + } while (0) +#define LOGOMATIC_DEBUG(...) \ + do { \ + printf("[DEBUG] "); \ + printf(__VA_ARGS__); \ + } while (0) +#define LOGOMATIC_VERBOSE(...) \ + do { \ + printf("[VERBOSE - %s:%d] ", __FILE_NAME__, __LINE__); \ printf(__VA_ARGS__); \ - _Pragma("GCC diagnostic pop"); \ } while (0) #else -/** - * @brief DISABLED - Logs a message to the ITM console. - * @param ... The format string and arguments to log. - * @note This function is only enabled when LOGOMATIC_ENABLED is defined. Otherwise, it will be compiled out - * @note This function is designed to be used with the ITM console, as a result printing floats is an intensive operation. - */ -#define LOGOMATIC(...) \ + +#if defined(LOGOMATIC_ENABLED) +#define _LOGOMATIC_PRIVATE_LOG(level, ...) \ + do { \ + if (_logomatic_loglevel >= (level) && (level) != LogLevel_Off && _logomatic_loglevel != LogLevel_Off) { \ + if (level == LogLevel_Verbose) { \ + printf("[%s - %s:%d] ", Logomatic_Private_LogLevelStrings[(level)], __FILE_NAME__, __LINE__); \ + } else { \ + printf("[%s] ", Logomatic_Private_LogLevelStrings[(level)]); \ + } \ + _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wdouble-promotion\"") printf(__VA_ARGS__); \ + _Pragma("GCC diagnostic pop") \ + } \ + } while (0) +#define LOGOMATIC_CRITICAL(...) _LOGOMATIC_PRIVATE_LOG(LogLevel_Critical, __VA_ARGS__) +#define LOGOMATIC_ERROR(...) _LOGOMATIC_PRIVATE_LOG(LogLevel_Error, __VA_ARGS__) +#define LOGOMATIC_WARNING(...) _LOGOMATIC_PRIVATE_LOG(LogLevel_Warning, __VA_ARGS__) +#define LOGOMATIC_INFO(...) _LOGOMATIC_PRIVATE_LOG(LogLevel_Info, __VA_ARGS__) +#define LOGOMATIC_DEBUG(...) _LOGOMATIC_PRIVATE_LOG(LogLevel_Debug, __VA_ARGS__) +#define LOGOMATIC_VERBOSE(...) _LOGOMATIC_PRIVATE_LOG(LogLevel_Verbose, __VA_ARGS__) +#else +#define _LOGOMATIC_PRIVATE_LOG(...) \ do { \ if (0) { \ - _Pragma("GCC diagnostic push"); \ - _Pragma("GCC diagnostic ignored \"-Wdouble-promotion\""); \ printf(__VA_ARGS__); \ - _Pragma("GCC diagnostic pop"); \ } \ } while (0) +#define LOGOMATIC_CRITICAL(...) _LOGOMATIC_PRIVATE_LOG(__VA_ARGS__) +#define LOGOMATIC_ERROR(...) _LOGOMATIC_PRIVATE_LOG(__VA_ARGS__) +#define LOGOMATIC_WARNING(...) _LOGOMATIC_PRIVATE_LOG(__VA_ARGS__) +#define LOGOMATIC_INFO(...) _LOGOMATIC_PRIVATE_LOG(__VA_ARGS__) +#define LOGOMATIC_DEBUG(...) _LOGOMATIC_PRIVATE_LOG(__VA_ARGS__) +#define LOGOMATIC_VERBOSE(...) _LOGOMATIC_PRIVATE_LOG(__VA_ARGS__) +#endif + +#endif + +#if defined(ITM) +int Logomatic_Driver_ITM(int ch); +#endif + +#if defined(LPUART1) +int Logomatic_Driver_LPUART1(int ch); +#endif + +#if defined(LPUART2) +int Logomatic_Driver_LPUART2(int ch); +#endif + +#if defined(LPUART3) +int Logomatic_Driver_LPUART3(int ch); +#endif + +#if defined(USART1) +int Logomatic_Driver_USART1(int ch); +#endif + +#if defined(USART2) +int Logomatic_Driver_USART2(int ch); +#endif + +#if defined(USART3) +int Logomatic_Driver_USART3(int ch); +#endif + +#if defined(USART4) +int Logomatic_Driver_USART4(int ch); +#endif + +#if defined(USART5) +int Logomatic_Driver_USART5(int ch); +#endif + +#if defined(USART6) +int Logomatic_Driver_USART6(int ch); +#endif + +#if defined(USART7) +int Logomatic_Driver_USART7(int ch); +#endif + +#if defined(USART8) +int Logomatic_Driver_USART8(int ch); +#endif + +#if defined(UART1) +int Logomatic_Driver_UART1(int ch); +#endif + +#if defined(UART2) +int Logomatic_Driver_UART2(int ch); +#endif + +#if defined(UART3) +int Logomatic_Driver_UART3(int ch); +#endif + +#if defined(UART4) +int Logomatic_Driver_UART4(int ch); +#endif + +#if defined(UART5) +int Logomatic_Driver_UART5(int ch); +#endif + +#if defined(UART6) +int Logomatic_Driver_UART6(int ch); +#endif + +#if defined(UART7) +int Logomatic_Driver_UART7(int ch); +#endif + +#if defined(UART8) +int Logomatic_Driver_UART8(int ch); #endif #endif diff --git a/Lib/Utils/Logomatic/README.md b/Lib/Utils/Logomatic/README.md index 932ee8222..9f2e89322 100644 --- a/Lib/Utils/Logomatic/README.md +++ b/Lib/Utils/Logomatic/README.md @@ -1,81 +1,119 @@ # Logomatic -A smart drop-in replacement for `printf` that dynamically works in HOOTL and embedded environments. It is also backwards compatible and can coexist with older manual implementations. - -## What it does - -- **HOOTL builds**: Writes to stdout (tests/CI can capture output) -- **Embedded targets**: Uses ITM over SWO when CMSIS ITM and the LL drivers are available -- **Release builds**: Compiles out entirely (no runtime cost) - -## Quick use - -```c -#include "Logomatic.h" - -void example_function(int count, float value) -{ - LOGOMATIC("Sensor reading: count=%d, value=%.2f\n", count, value); -} -``` - -## Logomatic Initialization - -When ITM and LL GPIO are available, `Setup_Logomatic()` expects a `LogomaticConfig`, on a STM32G474xE for LPUART1 this could look like: - -```c -LogomaticConfig logomaticConfig = { - .clock_source = LOGOMATIC_SYSCLK, - .bus = LOGOMATIC_BUS, - .gpio_port = LOGOMATIC_GPIOA, - .gpio_pin_rx_tx_mask = LL_GPIO_PIN_2 | LL_GPIO_PIN_3, - .baud_rate = 115200, - .data_width = LOGOMATIC_DATAWIDTH_8B, - .stop_bits = LOGOMATIC_STOPBITS_1, - .parity = LOGOMATIC_PARITY_NONE, - .transfer_direction = LOGOMATIC_DIRECTION_TX_RX, - .hardware_flow_control = LOGOMATIC_HWCONTROL_NONE, - .prescaler = LOGOMATIC_PRESCALER_DIV1, - .tx_fifo_threshold = LOGOMATIC_FIFOTHRESHOLD_1_8, - .rx_fifo_threshold = LOGOMATIC_FIFOTHRESHOLD_1_8, -}; - -int main(void) -{ - // ... - Setup_Logomatic(&logomaticConfig); - // ... - SystemClock_Config(); - // ... - LOGOMATIC("System initialized\n"); - // ... -} -``` - -## What ITM is - -ITM (Instrumentation Trace Macrocell) is an on-chip debug trace block on ARM Cortex-M. It can stream characters over the SWO pin to your debugger. Logomatic uses CMSIS `ITM_SendChar()` and enables ITM port 0 in `Setup_Logomatic()`. - -## VS Code Cortex-Debug SWO setup - -Use Cortex-Debug with SWO enabled so the debugger can show ITM output, remember to set the clock speed according to your chip! - -```json -{ - "swoConfig": { - "enabled": true, - "cpuFrequency": 170000000, - "swoFrequency": 2000000, - "source": "probe", - "decoders": [ - { "port": 0, "type": "console", "label": "SWO:ITM" } - ] - } -} -``` - -## How output is routed - -- With `LOGOMATIC_ENABLED` and `ITM` defined, Logomatic provides a weak `__io_putchar()` that writes to ITM. -- Without `ITM`, `printf()` uses the normal C library path (stdout in HOOTL or your platform retarget). -- The weak symbol can be overridden for a custom backend. +## Quick Start + +In STM32CubeMX configure `SYS` Debug to be "Trace Asynchronous Sw". Other settings will require you to set `TPI` settings as needed. + +By default logomatic will use ITM with your clock-configured baud rate on port 0. You can configure this trivially if you want. + +1. Link against `LOGOMATIC_LIB` as another library in your CMake project +2. Add `#include "Logomatic.h"` to your files and add calls to `LOGOMATIC_()` as appopriate +3. Call `Logomatic_SetLogLevel()` to configure your global verbosity logging level +4. Add the `swoConfig` key to your [`launch.json](/.vscode/launch.json) entry for your project, see the default below + +> ```json +> "swoConfig": { +> "enabled": true, +> "cpuFrequency": 160000000, +> "swoFrequency": 115, +> "source": "probe", +> "decoders": [ +> { +> "type": "console", +> "label": "ITM", +> "showOnStartup": true, +> "port": 0, +> "encoding": "ascii" +> } +> ] +> } +> ``` + +## Drivers + +You may configure any LPUART, UART, or USART to serve as your dedicated channel as well (almost) out of the box. + +To do that, you must define a strong symbol for `global_logomatic_driver` setting it to your own function, defaults are provided in the form `Logomatic_Driver_`. + +You can setup your own as well. Any you setup should have the same function signature and should + +- On success return the written character +- On failure return `EOF` +- Be very quick, as logomatic is often used inside ISRs for debugging + +## Log Levels + +Logs are defined in a X-Macro list `_LOGOMATIC_LOGLEVEL_X_LIST` where a higher number means more output + +| Status | Level | Description | +| --- | --- | --- | +| :zipper_mouth_face: | Off | Nothing will be printed, less performant than using `CMAKE_LOGOMATIC_ENABLED` | +| :rotating_light: | Critical | An important operation is failing and the car will not behave correctly | +| :x: | Error | An operation is failing but the car as a whole may be able to recover on its own | +| :warning: | Warning | An operation is not proceeding as expected but may recover on its own | +| :bell: | Info | An operation updates the status of the car, but nothing bad has happened | +| :bug: | Debug | An operation would like to report diagnostics that may be helpful | +| :loudspeaker: | Verbose | An operation has generated information and later inspection of the logs could be helpful, spammy | + +## Advanced + +It is strongly suggested to use ITM and the default settings, it will compile out fully on release builds with no overhead. + +### CMake + +Logomatic is exposed to others as an interface library called `LOGOMATIC_LIB`. From here you can include `Logomatic.h` which will automagically try and find a working peripheral to attach to. + +The CMake file for the library is [`log.cmake`](log.cmake) and uses the symbol `CMAKE_LOGOMATIC_ENABLED` to allow [`CMakePresets.json`](/CMakePresets.json) to enable or disable logging based on if the build is a debug or release build. If it is enabled then we add the compiler definition `LOGOMATIC_ENABLED`. + +By default, we also enable printing floats which adds significant memory and CPU overhead. It is strongly recommend to never print raw floating point values. + +If we are building for testing then [`CMakePresets.json`](/CMakePresets.json) ensures that logomatic is enabled and we attempt to signal the library to default to a verbose log level, see [log levels](#log-levels) + +### CAN Messages + +Currently we do not do anything cool with CAN specifically, but we could! + +It can also be configured as a driver (queuing to fill a packet) within this library or by providing a strong `_write()` definition (dividing a buffer into messages). + +If you would like to see this do something please open an Issue (and if you want to code it, a Pull Request as well) + +### Macros + +#### Log Levels X-Macro + +See [log levels](#log-levels) for more. + +We define `_LOGOMATIC_LOGLEVEL_PRIVATE_LIST` which consists of [X-Macros](https://wikipedia.org/wiki/X_macro) for the enum name, value, and text label. It is recommended to understand the nuances of the X-Macro pattern before continuing reading. + +We define `X` operations to translate that list into different forms, namely an enum, an array for value to text lookups, and type checking on the enum. + +It is required that more verbose log levels have a higher value than less verbose log levels. + +#### Logging Macros + +We provide macros, manually made, for each log level to simplify calling. These are in the form `LOGOMATIC_` and they take a single format string to print (exactly `printf`). + +These macros are variants of `_LOGOMATIC_PRIVATE_LOG()` which does runtime checks of the configured global log level against the requested log level, only printing if it is equal or higher. +This function also prints the log level in front of them, verbose logs also get the file and line number it was invoked on for easier debugging. + +As we have warnings for double promotion, since STM32 chips support FPU-accelerated operations only for 32-bit floats, we also have to push and pop a diagnostic to ignore that warning for that specific line. + +If logomatic is not enabled then each of the user-callable macros compiles to nothing, while not changing the used/unused status of the variables and not affecting the vardic variable. + +### Color Codes + +If you really want to, you can print colors using ANSI color codes. Be aware that this will tank performance with lots of unneeded data and is not supported. + +We also ask that you do not use color codes because different setups on different computers may behave differently. + +### HOOTL Testing + +Calls to logomatic functions inside of HOOTLTest configurations will work as you expect, except there is no more logging level filter. + +Note that by default the logging level for embedded is informational. You cannot set a logging level for HOOTL. + +## Troubleshooting + +TODO + +As issues are found we will extend this section. For now, please contact the Firmware Manager if you are unable to get this working. Be aware that specific hardware is required to use Logomatic diff --git a/Lib/Utils/Logomatic/Src/log_config.c b/Lib/Utils/Logomatic/Src/log_config.c new file mode 100644 index 000000000..f74f98006 --- /dev/null +++ b/Lib/Utils/Logomatic/Src/log_config.c @@ -0,0 +1,35 @@ +#include "Logomatic.h" +#include "main.h" + +Logomatic_LogLevel _logomatic_loglevel = LogLevel_Debug; + +#if defined(ITM) +__weak const Logomatic_Driver global_logomatic_driver = Logomatic_Driver_ITM; +#elif defined(LPUART1) +__weak const Logomatic_Driver global_logomatic_driver = Logomatic_Driver_LPUART1; +#else +__weak const Logomatic_Driver global_logomatic_driver = NULL; +#endif + +const char *Logomatic_Private_LogLevelStrings[] = { +#define X(name, val, str) [val] = str, + _LOGOMATIC_LOGLEVEL_PRIVATE_LIST +#undef X +}; + +bool Logomatic_SetLogLevel(Logomatic_LogLevel level) +{ +#if defined(LOGOMATIC_HOOTLTEST) + _logomatic_loglevel = LogLevel_Verbose; + return true; +#endif + +#define X(name, val, string) \ + if (level == val) { \ + _logomatic_loglevel = level; \ + return true; \ + } + _LOGOMATIC_LOGLEVEL_PRIVATE_LIST +#undef X + return false; +} diff --git a/Lib/Utils/Logomatic/Src/log_driver.c b/Lib/Utils/Logomatic/Src/log_driver.c new file mode 100644 index 000000000..60406ac84 --- /dev/null +++ b/Lib/Utils/Logomatic/Src/log_driver.c @@ -0,0 +1,176 @@ +#include "Logomatic.h" +#include "main.h" + +int __io_putchar(int ch) +{ +#ifdef LOGOMATIC_HOOTLTEST + return putchar(ch); +#else + if (global_logomatic_driver != NULL) { + return global_logomatic_driver(ch); + } + return ch; +#endif +} + +#if defined(ITM) +int Logomatic_Driver_ITM(int ch) +{ + ITM_SendChar(ch); + return ch; +} +#endif + +#if defined(LPUART1) || defined(LPUART2) || defined(LPUART3) || defined(USART1) || defined(USART2) || defined(USART3) || defined(USART4) || defined(USART5) || defined(USART6) || defined(USART7) || \ + defined(USART8) || defined(UART1) || defined(UART2) || defined(UART3) || defined(UART4) || defined(UART5) || defined(UART6) || defined(UART7) || defined(UART8) +int Logomatic_Private_UART(USART_TypeDef *handle, int ch) +{ +#if defined(USART_ISR_TXE_TXFNF) + while (!(handle->ISR & USART_ISR_TXE_TXFNF)) { /* Wait */ + } + handle->TDR = (uint8_t)ch; +#elif defined(USART_ISR_TXE) + while (!(handle->ISR & USART_ISR_TXE)) { /* Wait */ + } + handle->TDR = (uint8_t)ch; +#else + while (!(handle->SR & USART_SR_TXE)) { /* Wait */ + } + handle->DR = (uint8_t)ch; +#endif + return ch; +} +#endif + +#if defined(LPUART1) +int Logomatic_Driver_LPUART1(int ch) +{ + return Logomatic_Private_UART(LPUART1, ch); +} +#endif + +#if defined(LPUART2) +int Logomatic_Driver_LPUART2(int ch) +{ + return Logomatic_Private_UART(LPUART2, ch); +} +#endif + +#if defined(LPUART3) +int Logomatic_Driver_LPUART3(int ch) +{ + return Logomatic_Private_UART(LPUART3, ch); +} +#endif + +#if defined(USART1) +int Logomatic_Driver_USART1(int ch) +{ + return Logomatic_Private_UART(USART1, ch); +} +#endif + +#if defined(USART2) +int Logomatic_Driver_USART2(int ch) +{ + return Logomatic_Private_UART(USART2, ch); +} +#endif + +#if defined(USART3) +int Logomatic_Driver_USART3(int ch) +{ + return Logomatic_Private_UART(USART3, ch); +} +#endif + +#if defined(USART4) +int Logomatic_Driver_USART4(int ch) +{ + return Logomatic_Private_UART(USART4, ch); +} +#endif + +#if defined(USART5) +int Logomatic_Driver_USART5(int ch) +{ + return Logomatic_Private_UART(USART5, ch); +} +#endif + +#if defined(USART6) +int Logomatic_Driver_USART6(int ch) +{ + return Logomatic_Private_UART(USART6, ch); +} +#endif + +#if defined(USART7) +int Logomatic_Driver_USART7(int ch) +{ + return Logomatic_Private_UART(USART7, ch); +} +#endif + +#if defined(USART8) +int Logomatic_Driver_USART8(int ch) +{ + return Logomatic_Private_UART(USART8, ch); +} +#endif + +#if defined(UART1) +int Logomatic_Driver_UART1(int ch) +{ + return Logomatic_Private_UART(UART1, ch); +} +#endif + +#if defined(UART2) +int Logomatic_Driver_UART2(int ch) +{ + return Logomatic_Private_UART(UART2, ch); +} +#endif + +#if defined(UART3) +int Logomatic_Driver_UART3(int ch) +{ + return Logomatic_Private_UART(UART3, ch); +} +#endif + +#if defined(UART4) +int Logomatic_Driver_UART4(int ch) +{ + return Logomatic_Private_UART(UART4, ch); +} +#endif + +#if defined(UART5) +int Logomatic_Driver_UART5(int ch) +{ + return Logomatic_Private_UART(UART5, ch); +} +#endif + +#if defined(UART6) +int Logomatic_Driver_UART6(int ch) +{ + return Logomatic_Private_UART(UART6, ch); +} +#endif + +#if defined(UART7) +int Logomatic_Driver_UART7(int ch) +{ + return Logomatic_Private_UART(UART7, ch); +} +#endif + +#if defined(UART8) +int Logomatic_Driver_UART8(int ch) +{ + return Logomatic_Private_UART(UART8, ch); +} +#endif diff --git a/Lib/Utils/Logomatic/Test/main.h b/Lib/Utils/Logomatic/Test/main.h new file mode 100644 index 000000000..76d64ed3d --- /dev/null +++ b/Lib/Utils/Logomatic/Test/main.h @@ -0,0 +1,8 @@ +#ifndef MAIN_H +#define MAIN_H + +#ifndef __weak +#define __weak __attribute__((weak)) +#endif + +#endif diff --git a/Lib/Utils/Logomatic/Test/print.c b/Lib/Utils/Logomatic/Test/print.c new file mode 100644 index 000000000..d38e9af1f --- /dev/null +++ b/Lib/Utils/Logomatic/Test/print.c @@ -0,0 +1,98 @@ +#include +#include +#include +#include + +#ifdef _WIN32 +#include +#include + +#define sys_pipe(fd) _pipe(fd, 4096, _O_BINARY) +#define sys_dup _dup +#define sys_dup2 _dup2 +#define sys_read _read +#define sys_close _close + +#ifndef STDOUT_FILENO +#define STDOUT_FILENO _fileno(stdout) +#endif + +typedef ptrdiff_t ssize_t; +#else +#include + +#define sys_pipe(fd) pipe(fd) +#define sys_dup dup +#define sys_dup2 dup2 +#define sys_read read +#define sys_close close +#endif + +#include "Logomatic.h" + +int main(void) +{ + const char expected[] = "[CRITICAL] Critical log message\n" + "[ERROR] Error log message\n" + "[WARNING] Warning log message\n" + "[INFO] Informational log message\n" + "[DEBUG] Debug log message\n" + "[VERBOSE - print.c:63] Verbose log message\n"; + + int pipefd[2]; + char buffer[sizeof(expected) + 50] = {0}; + + if (sys_pipe(pipefd) == -1) { + perror("Pipe failed"); + return 1; + } + + int saved_stdout = sys_dup(STDOUT_FILENO); + +#ifdef _WIN32 + _setmode(STDOUT_FILENO, _O_BINARY); +#endif + + sys_dup2(pipefd[1], STDOUT_FILENO); + + LOGOMATIC_CRITICAL("Critical log message\n"); + LOGOMATIC_ERROR("Error log message\n"); + LOGOMATIC_WARNING("Warning log message\n"); + LOGOMATIC_INFO("Informational log message\n"); + LOGOMATIC_DEBUG("Debug log message\n"); + LOGOMATIC_VERBOSE("Verbose log message\n"); + + fflush(stdout); + sys_close(pipefd[1]); + + sys_dup2(saved_stdout, STDOUT_FILENO); + sys_close(saved_stdout); + +#ifdef _WIN32 + _setmode(STDOUT_FILENO, _O_TEXT); +#endif + + ssize_t bytes_read = sys_read(pipefd[0], buffer, sizeof(buffer) - 1); + if (bytes_read >= 0) { + buffer[bytes_read] = '\0'; + } + sys_close(pipefd[0]); + + if (strcmp(buffer, expected) == 0) { + printf("Test passed: Log output matches expected output.\n"); + } else { + printf("Test failed: Log output does not match expected output.\n"); + printf("\nExpected:\n%s", expected); + printf("\nGot:\n%s", buffer); + return 1; + } + + LOGOMATIC_CRITICAL("Critical log message again\n"); + LOGOMATIC_ERROR("Error log message again\n"); + LOGOMATIC_WARNING("Warning log message again\n"); + LOGOMATIC_INFO("Informational log message again\n"); + LOGOMATIC_DEBUG("Debug log message again\n"); + LOGOMATIC_VERBOSE("Verbose log message again\n"); + + return 0; +} diff --git a/Lib/Utils/Logomatic/log.cmake b/Lib/Utils/Logomatic/log.cmake new file mode 100644 index 000000000..dfb6d99e6 --- /dev/null +++ b/Lib/Utils/Logomatic/log.cmake @@ -0,0 +1,53 @@ +add_library(LOGOMATIC_LIB INTERFACE) + +target_include_directories( + LOGOMATIC_LIB + INTERFACE + ${CMAKE_CURRENT_LIST_DIR}/Inc +) + +target_sources( + LOGOMATIC_LIB + INTERFACE + ${CMAKE_CURRENT_LIST_DIR}/Src/log_config.c + ${CMAKE_CURRENT_LIST_DIR}/Src/log_driver.c +) + +target_link_libraries(LOGOMATIC_LIB INTERFACE GLOBALSHARE_LIB) + +if(NOT DEFINED CMAKE_LOGOMATIC_ENABLED) + set(CMAKE_LOGOMATIC_ENABLED OFF) +endif() + +if(CMAKE_LOGOMATIC_ENABLED) + message(STATUS "Logomatic enabled") + target_compile_definitions(LOGOMATIC_LIB INTERFACE LOGOMATIC_ENABLED) +endif() + +if(CMAKE_PRESET_NAME STREQUAL "HOOTLTest") + target_compile_definitions(LOGOMATIC_LIB INTERFACE LOGOMATIC_HOOTLTEST) + + add_executable(logomatic) + target_sources(logomatic PRIVATE ${CMAKE_CURRENT_LIST_DIR}/Test/print.c) + target_include_directories(logomatic PRIVATE ${CMAKE_CURRENT_LIST_DIR}/Test) + target_link_libraries( + logomatic + PRIVATE + LOGOMATIC_LIB + GLOBALSHARE_LIB + ) + add_test(logomatic_test logomatic) +else() + target_compile_options( + LOGOMATIC_LIB + INTERFACE + -u + _printf_float + ) + target_link_options( + LOGOMATIC_LIB + INTERFACE + -u + _printf_float + ) +endif() diff --git a/Lib/Utils/OldLogomatic/Inc/Logomatic.h b/Lib/Utils/OldLogomatic/Inc/Logomatic.h new file mode 100644 index 000000000..21734ba64 --- /dev/null +++ b/Lib/Utils/OldLogomatic/Inc/Logomatic.h @@ -0,0 +1,136 @@ +#include +#include + +#include "main.h" + +#ifndef LOGOMATIC_H +#define LOGOMATIC_H + +#if defined(ITM) && defined(LL_GPIO_MODE_ALTERNATE) +typedef enum { + LOGOMATIC_PCLK1 = LL_RCC_LPUART1_CLKSOURCE_PCLK1, + LOGOMATIC_SYSCLK = LL_RCC_LPUART1_CLKSOURCE_SYSCLK, + LOGOMATIC_HSI = LL_RCC_LPUART1_CLKSOURCE_HSI, + LOGOMATIC_LSE = LL_RCC_LPUART1_CLKSOURCE_LSE +} LPUART_Clock_Source; + +typedef enum { + LOGOMATIC_BUS = LL_APB1_GRP2_PERIPH_LPUART1, +} LPUART_Bus; + +typedef enum { + LOGOMATIC_GPIOA = LL_AHB2_GRP1_PERIPH_GPIOA, + LOGOMATIC_GPIOB = LL_AHB2_GRP1_PERIPH_GPIOB, + LOGOMATIC_GPIOC = LL_AHB2_GRP1_PERIPH_GPIOC, + LOGOMATIC_GPIOD = LL_AHB2_GRP1_PERIPH_GPIOD, + LOGOMATIC_GPIOE = LL_AHB2_GRP1_PERIPH_GPIOE, + LOGOMATIC_GPIOF = LL_AHB2_GRP1_PERIPH_GPIOF, + LOGOMATIC_GPIOG = LL_AHB2_GRP1_PERIPH_GPIOG, +} LPUART_GPIO_Port; + +typedef enum { + LOGOMATIC_DATAWIDTH_7B = LL_LPUART_DATAWIDTH_7B, + LOGOMATIC_DATAWIDTH_8B = LL_LPUART_DATAWIDTH_8B, + LOGOMATIC_DATAWIDTH_9B = LL_LPUART_DATAWIDTH_9B +} LPUART_DataWidth; + +typedef enum { + LOGOMATIC_STOPBITS_1 = LL_LPUART_STOPBITS_1, + LOGOMATIC_STOPBITS_2 = LL_LPUART_STOPBITS_2 +} LPUART_StopBits; + +typedef enum { + LOGOMATIC_PARITY_NONE = LL_LPUART_PARITY_NONE, + LOGOMATIC_PARITY_EVEN = LL_LPUART_PARITY_EVEN, + LOGOMATIC_PARITY_ODD = LL_LPUART_PARITY_ODD +} LPUART_Parity; + +typedef enum { + LOGOMATIC_DIRECTION_NONE = LL_LPUART_DIRECTION_NONE, + LOGOMATIC_DIRECTION_RX = LL_LPUART_DIRECTION_RX, + LOGOMATIC_DIRECTION_TX = LL_LPUART_DIRECTION_TX, + LOGOMATIC_DIRECTION_TX_RX = LL_LPUART_DIRECTION_TX_RX +} LPUART_TransferDirection; + +typedef enum { + LOGOMATIC_HWCONTROL_NONE = LL_LPUART_HWCONTROL_NONE, + LOGOMATIC_HWCONTROL_RTS = LL_LPUART_HWCONTROL_RTS, + LOGOMATIC_HWCONTROL_CTS = LL_LPUART_HWCONTROL_CTS, + LOGOMATIC_HWCONTROL_RTS_CTS = LL_LPUART_HWCONTROL_RTS_CTS +} LPUART_HardwareFlowControl; + +typedef enum { + LOGOMATIC_PRESCALER_DIV1 = LL_LPUART_PRESCALER_DIV1, + LOGOMATIC_PRESCALER_DIV2 = LL_LPUART_PRESCALER_DIV2, + LOGOMATIC_PRESCALER_DIV4 = LL_LPUART_PRESCALER_DIV4, + LOGOMATIC_PRESCALER_DIV6 = LL_LPUART_PRESCALER_DIV6, + LOGOMATIC_PRESCALER_DIV8 = LL_LPUART_PRESCALER_DIV8, + LOGOMATIC_PRESCALER_DIV10 = LL_LPUART_PRESCALER_DIV10, + LOGOMATIC_PRESCALER_DIV12 = LL_LPUART_PRESCALER_DIV12, + LOGOMATIC_PRESCALER_DIV16 = LL_LPUART_PRESCALER_DIV16, + LOGOMATIC_PRESCALER_DIV32 = LL_LPUART_PRESCALER_DIV32, + LOGOMATIC_PRESCALER_DIV64 = LL_LPUART_PRESCALER_DIV64, + LOGOMATIC_PRESCALER_DIV128 = LL_LPUART_PRESCALER_DIV128, + LOGOMATIC_PRESCALER_DIV256 = LL_LPUART_PRESCALER_DIV256 +} LPUART_Prescaler; + +typedef enum { + LOGOMATIC_FIFOTHRESHOLD_1_8 = LL_LPUART_FIFOTHRESHOLD_1_8, + LOGOMATIC_FIFOTHRESHOLD_1_4 = LL_LPUART_FIFOTHRESHOLD_1_4, + LOGOMATIC_FIFOTHRESHOLD_1_2 = LL_LPUART_FIFOTHRESHOLD_1_2, + LOGOMATIC_FIFOTHRESHOLD_3_4 = LL_LPUART_FIFOTHRESHOLD_3_4, + LOGOMATIC_FIFOTHRESHOLD_7_8 = LL_LPUART_FIFOTHRESHOLD_7_8, + LOGOMATIC_FIFOTHRESHOLD_8_8 = LL_LPUART_FIFOTHRESHOLD_8_8 +} LPUART_FifoThreshold; + +typedef struct { + LPUART_Clock_Source clock_source; + LPUART_Bus bus; + LPUART_GPIO_Port gpio_port; + uint32_t gpio_pin_rx_tx_mask; + uint32_t baud_rate; + LPUART_DataWidth data_width; + LPUART_StopBits stop_bits; + LPUART_Parity parity; + LPUART_TransferDirection transfer_direction; + LPUART_HardwareFlowControl hardware_flow_control; + LPUART_Prescaler prescaler; + LPUART_FifoThreshold tx_fifo_threshold; + LPUART_FifoThreshold rx_fifo_threshold; +} LogomaticConfig; +#else +typedef uint8_t LogomaticConfig; +#endif + +void Setup_Logomatic(LogomaticConfig *config); + +#ifdef LOGOMATIC_ENABLED +/** + * @brief ENABLED - Logs a message to the ITM console. + * @param ... The format string and arguments to log. + * @note This function is only enabled when LOGOMATIC_ENABLED is defined. Otherwise, it will be compiled out. + * @note This function is designed to be used with the ITM console, as a result printing floats is an intensive operation. + */ +#define LOGOMATIC(...) \ + do { \ + _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wdouble-promotion\"") printf(__VA_ARGS__); \ + _Pragma("GCC diagnostic pop") \ + } while (0) + +#else +/** + * @brief DISABLED - Logs a message to the ITM console. + * @param ... The format string and arguments to log. + * @note This function is only enabled when LOGOMATIC_ENABLED is defined. Otherwise, it will be compiled out + * @note This function is designed to be used with the ITM console, as a result printing floats is an intensive operation. + */ +#define LOGOMATIC(...) \ + do { \ + if (0) { \ + _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wdouble-promotion\"") printf(__VA_ARGS__); \ + _Pragma("GCC diagnostic pop") \ + } \ + } while (0) +#endif + +#endif diff --git a/Lib/Utils/OldLogomatic/README.md b/Lib/Utils/OldLogomatic/README.md new file mode 100644 index 000000000..932ee8222 --- /dev/null +++ b/Lib/Utils/OldLogomatic/README.md @@ -0,0 +1,81 @@ +# Logomatic + +A smart drop-in replacement for `printf` that dynamically works in HOOTL and embedded environments. It is also backwards compatible and can coexist with older manual implementations. + +## What it does + +- **HOOTL builds**: Writes to stdout (tests/CI can capture output) +- **Embedded targets**: Uses ITM over SWO when CMSIS ITM and the LL drivers are available +- **Release builds**: Compiles out entirely (no runtime cost) + +## Quick use + +```c +#include "Logomatic.h" + +void example_function(int count, float value) +{ + LOGOMATIC("Sensor reading: count=%d, value=%.2f\n", count, value); +} +``` + +## Logomatic Initialization + +When ITM and LL GPIO are available, `Setup_Logomatic()` expects a `LogomaticConfig`, on a STM32G474xE for LPUART1 this could look like: + +```c +LogomaticConfig logomaticConfig = { + .clock_source = LOGOMATIC_SYSCLK, + .bus = LOGOMATIC_BUS, + .gpio_port = LOGOMATIC_GPIOA, + .gpio_pin_rx_tx_mask = LL_GPIO_PIN_2 | LL_GPIO_PIN_3, + .baud_rate = 115200, + .data_width = LOGOMATIC_DATAWIDTH_8B, + .stop_bits = LOGOMATIC_STOPBITS_1, + .parity = LOGOMATIC_PARITY_NONE, + .transfer_direction = LOGOMATIC_DIRECTION_TX_RX, + .hardware_flow_control = LOGOMATIC_HWCONTROL_NONE, + .prescaler = LOGOMATIC_PRESCALER_DIV1, + .tx_fifo_threshold = LOGOMATIC_FIFOTHRESHOLD_1_8, + .rx_fifo_threshold = LOGOMATIC_FIFOTHRESHOLD_1_8, +}; + +int main(void) +{ + // ... + Setup_Logomatic(&logomaticConfig); + // ... + SystemClock_Config(); + // ... + LOGOMATIC("System initialized\n"); + // ... +} +``` + +## What ITM is + +ITM (Instrumentation Trace Macrocell) is an on-chip debug trace block on ARM Cortex-M. It can stream characters over the SWO pin to your debugger. Logomatic uses CMSIS `ITM_SendChar()` and enables ITM port 0 in `Setup_Logomatic()`. + +## VS Code Cortex-Debug SWO setup + +Use Cortex-Debug with SWO enabled so the debugger can show ITM output, remember to set the clock speed according to your chip! + +```json +{ + "swoConfig": { + "enabled": true, + "cpuFrequency": 170000000, + "swoFrequency": 2000000, + "source": "probe", + "decoders": [ + { "port": 0, "type": "console", "label": "SWO:ITM" } + ] + } +} +``` + +## How output is routed + +- With `LOGOMATIC_ENABLED` and `ITM` defined, Logomatic provides a weak `__io_putchar()` that writes to ITM. +- Without `ITM`, `printf()` uses the normal C library path (stdout in HOOTL or your platform retarget). +- The weak symbol can be overridden for a custom backend. diff --git a/Lib/Utils/Logomatic/Src/Logomatic.c b/Lib/Utils/OldLogomatic/Src/Logomatic.c similarity index 100% rename from Lib/Utils/Logomatic/Src/Logomatic.c rename to Lib/Utils/OldLogomatic/Src/Logomatic.c diff --git a/Lib/Utils/Logomatic/Test/Inc/main.h b/Lib/Utils/OldLogomatic/Test/Inc/main.h similarity index 100% rename from Lib/Utils/Logomatic/Test/Inc/main.h rename to Lib/Utils/OldLogomatic/Test/Inc/main.h diff --git a/Lib/Utils/Logomatic/Test/Src/logomatic_float_print.c b/Lib/Utils/OldLogomatic/Test/Src/logomatic_float_print.c similarity index 100% rename from Lib/Utils/Logomatic/Test/Src/logomatic_float_print.c rename to Lib/Utils/OldLogomatic/Test/Src/logomatic_float_print.c diff --git a/Lib/Utils/Logomatic/Test/Src/logomatic_simple_print.c b/Lib/Utils/OldLogomatic/Test/Src/logomatic_simple_print.c similarity index 100% rename from Lib/Utils/Logomatic/Test/Src/logomatic_simple_print.c rename to Lib/Utils/OldLogomatic/Test/Src/logomatic_simple_print.c diff --git a/Lib/Utils/Logomatic/logomatic.cmake b/Lib/Utils/OldLogomatic/logomatic.cmake similarity index 70% rename from Lib/Utils/Logomatic/logomatic.cmake rename to Lib/Utils/OldLogomatic/logomatic.cmake index 0b8144e06..b5afa0e0b 100644 --- a/Lib/Utils/Logomatic/logomatic.cmake +++ b/Lib/Utils/OldLogomatic/logomatic.cmake @@ -1,17 +1,17 @@ -add_library(LOGOMATIC_LIB INTERFACE) +add_library(LOGOMATIC_OLD_LIB INTERFACE) # Include directories and source files for the logomatic library target_include_directories( - LOGOMATIC_LIB + LOGOMATIC_OLD_LIB INTERFACE ${CMAKE_CURRENT_LIST_DIR}/Inc ) target_sources( - LOGOMATIC_LIB + LOGOMATIC_OLD_LIB INTERFACE ${CMAKE_CURRENT_LIST_DIR}/Src/Logomatic.c ) -target_link_libraries(LOGOMATIC_LIB INTERFACE GLOBALSHARE_LIB) +target_link_libraries(LOGOMATIC_OLD_LIB INTERFACE GLOBALSHARE_LIB) # Default logomatic to be disabled if(NOT DEFINED CMAKE_LOGOMATIC_ENABLED) @@ -21,7 +21,7 @@ endif() # Main compilation flag to enable logomatic if(CMAKE_LOGOMATIC_ENABLED) message(STATUS "Logomatic enabled") - target_compile_definitions(LOGOMATIC_LIB INTERFACE LOGOMATIC_ENABLED) + target_compile_definitions(LOGOMATIC_OLD_LIB INTERFACE LOGOMATIC_ENABLED) endif() if(CMAKE_PRESET_NAME STREQUAL "HOOTLTest") @@ -36,7 +36,7 @@ if(CMAKE_PRESET_NAME STREQUAL "HOOTLTest") PRIVATE ${CMAKE_CURRENT_LIST_DIR}/Test/Inc ) - target_link_libraries(logomatic_simple PRIVATE LOGOMATIC_LIB) + target_link_libraries(logomatic_simple PRIVATE LOGOMATIC_OLD_LIB) add_test(logomatic_simple_test logomatic_simple) add_executable(logomatic_float) @@ -50,20 +50,27 @@ if(CMAKE_PRESET_NAME STREQUAL "HOOTLTest") PRIVATE ${CMAKE_CURRENT_LIST_DIR}/Test/Inc ) - target_link_libraries(logomatic_float PRIVATE LOGOMATIC_LIB) + target_link_libraries(logomatic_float PRIVATE LOGOMATIC_OLD_LIB) add_test(logomatic_float_test logomatic_float) else() # Add floating point support for printf, which goes unused on MacOS hootl builds and throws a warning target_compile_options( - LOGOMATIC_LIB + LOGOMATIC_OLD_LIB INTERFACE -u _printf_float ) target_link_options( - LOGOMATIC_LIB + LOGOMATIC_OLD_LIB INTERFACE -u _printf_float ) endif() + +set_target_properties( + LOGOMATIC_OLD_LIB + PROPERTIES + DEPRECATION + "LOGOMATIC_OLD_LIB is deprecated and should be replaced by LOGOMATIC_LIB." +) diff --git a/Lib/Utils/VirtualComPort/vcp.cmake b/Lib/Utils/VirtualComPort/vcp.cmake index 71c25df4e..9eda7ead3 100644 --- a/Lib/Utils/VirtualComPort/vcp.cmake +++ b/Lib/Utils/VirtualComPort/vcp.cmake @@ -16,5 +16,12 @@ target_link_libraries( VCP_LIB INTERFACE GLOBALSHARE_LIB - LOGOMATIC_LIB + LOGOMATIC_OLD_LIB +) + +set_target_properties( + VCP_LIB + PROPERTIES + DEPRECATION + "VCP_LIB is deprecated and should be removed in favor of CUBE_VCP_LIB." ) diff --git a/Lib/cmake/HOOTL.cmake b/Lib/cmake/HOOTL.cmake index e9fc8b613..bd3858b2a 100644 --- a/Lib/cmake/HOOTL.cmake +++ b/Lib/cmake/HOOTL.cmake @@ -27,8 +27,8 @@ add_compile_options( -Werror -Wpedantic -Wvla - -Wdouble-promotion -g + -DHOOTL_TEST ) if(APPLE) # MacOS has a different syntax for linker fatal warnings @@ -58,11 +58,13 @@ if(ADDRESS_SANITIZER) -fsanitize=address -fsanitize=undefined -fsanitize=leak + # -fsanitize=thread ) add_link_options( -fsanitize=address -fsanitize=undefined -fsanitize=leak + # -fsanitize=thread ) endif() endif() diff --git a/Lib/cmake/gr-lib.cmake b/Lib/cmake/gr-lib.cmake index cc1c29762..619031bd6 100644 --- a/Lib/cmake/gr-lib.cmake +++ b/Lib/cmake/gr-lib.cmake @@ -34,7 +34,6 @@ function(add_gr_project) ${TARGET_NAME} PRIVATE ${TARGET_NAME}_USER_CODE # Blame Owen - LOGOMATIC_LIB GLOBALSHARE_LIB m ) diff --git a/OutboardSensors/BrakeTemp/CMakeLists.txt b/OutboardSensors/BrakeTemp/CMakeLists.txt index 88485311c..4b63816c1 100644 --- a/OutboardSensors/BrakeTemp/CMakeLists.txt +++ b/OutboardSensors/BrakeTemp/CMakeLists.txt @@ -50,6 +50,7 @@ target_link_libraries( BitManipulations_Lib MLX90614_LIB PERIPHERAL_TIMEDCAN_LIB + LOGOMATIC_OLD_LIB ) target_include_directories( diff --git a/OutboardSensors/TireTemp/CMakeLists.txt b/OutboardSensors/TireTemp/CMakeLists.txt index 4d7126fea..933e1d4a5 100644 --- a/OutboardSensors/TireTemp/CMakeLists.txt +++ b/OutboardSensors/TireTemp/CMakeLists.txt @@ -49,6 +49,7 @@ target_link_libraries( BitManipulations_Lib MLX90640_LIB PERIPHERAL_TIMEDCAN_LIB + LOGOMATIC_OLD_LIB ) target_include_directories( diff --git a/README.md b/README.md index 2006a43f0..c0dcd5f2a 100644 --- a/README.md +++ b/README.md @@ -43,17 +43,20 @@ When able, please add VS Code comptatible doc comments! These will help debuggin ## Install Tools/Dependencies *For Windows:* -1. `winget install Ninja-build.Ninja Kitware.CMake Arm.GnuArmEmbeddedToolchain` + +1. `winget install Ninja-build.Ninja Kitware.CMake Arm.GnuArmEmbeddedToolchain Microsoft.VisualStudioCode` 2. [OpenOCD](https://github.com/openocd-org/openocd/releases/latest) -> Download the `.tar.gz` file, extract to directory, add the bin directory to your `PATH` 3. Relaunch your terminal *For MacOS:* 1. `/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"` -2. `brew install cmake ninja open-ocd` -3. `brew install --cask gcc-arm-embedded` +2. `brew install cmake ninja open-ocd gcc-arm-embedded visual-studio-code` 4. Relaunch your terminal *For Linux / BSD:* + +Install the Visual Studio Code IDE (prefer using the `deb` or `rpm` from [Microsoft](https://code.visualstudio.com/download)). + * `sudo apt install cmake ninja gcc-arm-none-eabi openocd` * `sudo dnf install cmake ninja openocd` (Normally also `arm-none-eabi-gcc-cs arm-none-eabi-newlib` which worked on Fedora 42 but is broken on Fedora 43, use [Arm's version](https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads) instead for the moment) * `sudo pacman -S cmake ninja openocd arm-none-eabi-gcc` @@ -61,6 +64,7 @@ When able, please add VS Code comptatible doc comments! These will help debuggin * If you run into issues verify that binutils and newlib are installed for `arm-none-eabi` ### Verify that you have all these dependencies installed: + - CMake - `cmake --version` - Ninja - `ninja --version` - Arm - `arm-none-eabi-gcc --version` diff --git a/Testbench/CUBEMXTESTING/Application/Inc/CANdler.h b/Testbench/CUBEMXTESTING/Application/Inc/CANdler.h new file mode 100644 index 000000000..4950e32d2 --- /dev/null +++ b/Testbench/CUBEMXTESTING/Application/Inc/CANdler.h @@ -0,0 +1,9 @@ +#include "CubeCAN.h" + +#ifndef CANDLER_H +#define CANDLER_H + +void CANdler_Callback(const CubeCAN_Config_Context *const context, const CAN_Identifier *const identifier, const uint8_t *const data, const uint8_t size); +void CANdler_VCP_Callback(const uint8_t *const data, const uint16_t size); + +#endif diff --git a/Testbench/CUBEMXTESTING/Application/Inc/CubeCAN_Config.h b/Testbench/CUBEMXTESTING/Application/Inc/CubeCAN_Config.h new file mode 100644 index 000000000..e8345d49a --- /dev/null +++ b/Testbench/CUBEMXTESTING/Application/Inc/CubeCAN_Config.h @@ -0,0 +1,7 @@ +#ifndef CUBE_CAN_CONFIG_H +#define CUBE_CAN_CONFIG_H + +#define CUBEMX_CAN_TX_QUEUE_SIZE 16U +#define CUBEMX_CAN_MAX_INSTANCES 3U + +#endif diff --git a/Testbench/CUBEMXTESTING/Application/Inc/CubeVCP_Config.h b/Testbench/CUBEMXTESTING/Application/Inc/CubeVCP_Config.h new file mode 100644 index 000000000..0dcf9fd11 --- /dev/null +++ b/Testbench/CUBEMXTESTING/Application/Inc/CubeVCP_Config.h @@ -0,0 +1,10 @@ +#ifndef CUBE_VCP_CONFIG_H +#define CUBE_VCP_CONFIG_H + +// Maximum size of a message you can send over VCP +#define CUBE_VCP_TX_BUFFER_SIZE 16 + +// Maximum size of a message you can receive over VCP +#define CUBE_VCP_RX_BUFFER_SIZE 64 + +#endif diff --git a/Testbench/CUBEMXTESTING/Application/Inc/Loop.h b/Testbench/CUBEMXTESTING/Application/Inc/Loop.h new file mode 100644 index 000000000..4b447f829 --- /dev/null +++ b/Testbench/CUBEMXTESTING/Application/Inc/Loop.h @@ -0,0 +1,6 @@ +#ifndef LOOP_H +#define LOOP_H + +void MainLoop(void); + +#endif diff --git a/Testbench/CUBEMXTESTING/Application/Src/CANdler.c b/Testbench/CUBEMXTESTING/Application/Src/CANdler.c new file mode 100644 index 000000000..5e573cdb7 --- /dev/null +++ b/Testbench/CUBEMXTESTING/Application/Src/CANdler.c @@ -0,0 +1,37 @@ +#include "CANdler.h" + +#include "CubeCAN.h" +#include "GRCAN_BUS_ID.h" +#include "GRCAN_MSG_ID.h" +#include "GRCAN_NODE_ID.h" +#include "Logomatic.h" + +int value; + +void CANdler_Callback(const CubeCAN_Config_Context *const context, const CAN_Identifier *const identifier, const uint8_t *const data, const uint8_t size) +{ + value++; + + if (context == NULL || identifier == NULL || data == NULL || size == 0) { + LOGOMATIC_ERROR("CANdler_Callback: Invalid parameters received. context: %u, identifier: %p, data: %p, size: %u\n", context->busid_user_context, (void *const)identifier, + (void *const)data, size); + return; + } + + const GRCAN_BUS_ID busid = context->busid_user_context; + const GRCAN_NODE_ID tx_node = identifier->tx_node_id; + const GRCAN_NODE_ID rx_node = identifier->rx_node_id; + const GRCAN_MSG_ID msg_id = identifier->msg_id; + + LOGOMATIC_VERBOSE("Received on bus %d with node %d -> %d with message %d and size %u\t%.*s\n", busid, tx_node, rx_node, msg_id, size, size, (const char *const)data); +} + +void CANdler_VCP_Callback(const uint8_t *const data, const uint16_t size) +{ + if (data == NULL || size == 0) { + LOGOMATIC_ERROR("CANdler_VCP_Callback: Invalid parameters received. data: %p, size: %u\n", (void *const)data, size); + return; + } + + LOGOMATIC_DEBUG("VCP Rx with size %u\t%.*s\n", size, size, (const char *const)data); +} diff --git a/Testbench/CUBEMXTESTING/Application/Src/Loop.c b/Testbench/CUBEMXTESTING/Application/Src/Loop.c new file mode 100644 index 000000000..0f805c9d3 --- /dev/null +++ b/Testbench/CUBEMXTESTING/Application/Src/Loop.c @@ -0,0 +1,25 @@ +#include "Loop.h" + +#include + +#include "CubeCAN.h" +#include "CubeVCP.h" +#include "GRCAN_MSG_ID.h" +#include "GRCAN_NODE_ID.h" +#include "Logomatic.h" +#include "main.h" + +extern int value; + +void MainLoop(void) +{ + LL_GPIO_TogglePin(USER_LED_GPIO_Port, USER_LED_Pin); + + (void)CubeCAN_Send(primaryHandle, GRCAN_Debugger, GRCAN_DEBUG_2_0, "Hello0", 6); + (void)CubeCAN_Send(dataHandle, GRCAN_Debugger, GRCAN_DEBUG_2_0, "Hello1", 6); + (void)CubeCAN_Send(chargerHandle, GRCAN_Debugger, GRCAN_DEBUG_2_0, "Hello2", 6); + + LOGOMATIC_VERBOSE("Main Loop %d %" PRIu32 "\n", value, HAL_GetTick()); + + CubeVCP_SendString("Hello from VCP\n", sizeof("Hello from VCP\n") - 1); +} diff --git a/G4PERTESTING/CMakeLists.txt b/Testbench/CUBEMXTESTING/CMakeLists.txt similarity index 68% rename from G4PERTESTING/CMakeLists.txt rename to Testbench/CUBEMXTESTING/CMakeLists.txt index 6a3e34d42..a5341ae8f 100644 --- a/G4PERTESTING/CMakeLists.txt +++ b/Testbench/CUBEMXTESTING/CMakeLists.txt @@ -10,9 +10,6 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Debug") endif() -# Enable compile command to ease indexing with e.g. clangd -set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE) - # Enable CMake support for ASM and C languages enable_language( C @@ -29,20 +26,27 @@ add_library(${PROJECT_NAME}_USER_CODE INTERFACE) target_sources( ${PROJECT_NAME}_USER_CODE INTERFACE - Core/Src/adc.c - Core/Src/crc.c - Core/Src/dma.c + Application/Src/CANdler.c + Application/Src/Loop.c Core/Src/fdcan.c Core/Src/gpio.c - Core/Src/i2c.c Core/Src/main.c - Core/Src/spi.c - Core/Src/stm32g4xx_hal_msp.c Core/Src/stm32g4xx_it.c Core/Src/tim.c Core/Src/usart.c ) -target_link_libraries(${PROJECT_NAME}_USER_CODE INTERFACE) +target_link_libraries( + ${PROJECT_NAME}_USER_CODE + INTERFACE + CUBE_CAN_LIB + CUBE_VCP_LIB + LOGOMATIC_LIB +) -target_include_directories(${PROJECT_NAME}_USER_CODE INTERFACE Core/Inc) +target_include_directories( + ${PROJECT_NAME}_USER_CODE + INTERFACE + Core/Inc + Application/Inc +) diff --git a/Testbench/CUBEMXTESTING/CUBEMXTESTING.ioc b/Testbench/CUBEMXTESTING/CUBEMXTESTING.ioc new file mode 100644 index 000000000..eb06b6e12 --- /dev/null +++ b/Testbench/CUBEMXTESTING/CUBEMXTESTING.ioc @@ -0,0 +1,228 @@ +#MicroXplorer Configuration settings - do not modify +CAD.formats=[] +CAD.pinconfig=Dual +CAD.provider= +FDCAN1.AutoRetransmission=ENABLE +FDCAN1.CalculateBaudRateNominal=1000000 +FDCAN1.CalculateTimeBitNominal=1000 +FDCAN1.CalculateTimeQuantumNominal=6.25 +FDCAN1.DataPrescaler=8 +FDCAN1.DataSyncJumpWidth=16 +FDCAN1.DataTimeSeg1=14 +FDCAN1.DataTimeSeg2=5 +FDCAN1.ExtFiltersNbr=2 +FDCAN1.IPParameters=CalculateTimeQuantumNominal,CalculateTimeBitNominal,CalculateBaudRateNominal,NominalSyncJumpWidth,AutoRetransmission,ProtocolException,DataPrescaler,DataSyncJumpWidth,DataTimeSeg1,DataTimeSeg2,ExtFiltersNbr,NominalPrescaler,NominalTimeSeg1,NominalTimeSeg2,Mode +FDCAN1.Mode=FDCAN_MODE_INTERNAL_LOOPBACK +FDCAN1.NominalPrescaler=1 +FDCAN1.NominalSyncJumpWidth=16 +FDCAN1.NominalTimeSeg1=119 +FDCAN1.NominalTimeSeg2=40 +FDCAN1.ProtocolException=ENABLE +FDCAN2.AutoRetransmission=ENABLE +FDCAN2.CalculateBaudRateNominal=1000000 +FDCAN2.CalculateTimeBitNominal=1000 +FDCAN2.CalculateTimeQuantumNominal=6.25 +FDCAN2.DataPrescaler=8 +FDCAN2.DataSyncJumpWidth=16 +FDCAN2.DataTimeSeg1=14 +FDCAN2.DataTimeSeg2=5 +FDCAN2.ExtFiltersNbr=2 +FDCAN2.IPParameters=CalculateTimeQuantumNominal,CalculateTimeBitNominal,CalculateBaudRateNominal,AutoRetransmission,ProtocolException,NominalSyncJumpWidth,DataPrescaler,DataSyncJumpWidth,DataTimeSeg1,DataTimeSeg2,ExtFiltersNbr,NominalPrescaler,NominalTimeSeg1,NominalTimeSeg2,Mode +FDCAN2.Mode=FDCAN_MODE_INTERNAL_LOOPBACK +FDCAN2.NominalPrescaler=1 +FDCAN2.NominalSyncJumpWidth=16 +FDCAN2.NominalTimeSeg1=119 +FDCAN2.NominalTimeSeg2=40 +FDCAN2.ProtocolException=ENABLE +FDCAN3.CalculateBaudRateNominal=3333333 +FDCAN3.CalculateTimeBitNominal=300 +FDCAN3.CalculateTimeQuantumNominal=100.0 +FDCAN3.IPParameters=CalculateTimeQuantumNominal,CalculateTimeBitNominal,CalculateBaudRateNominal,Mode +FDCAN3.Mode=FDCAN_MODE_INTERNAL_LOOPBACK +File.Version=6 +GPIO.groupedBy=Group By Peripherals +KeepUserPlacement=false +LPUART1.BaudRate=115200 +LPUART1.IPParameters=BaudRate +Mcu.CPN=STM32G474RET6 +Mcu.Family=STM32G4 +Mcu.IP0=FDCAN1 +Mcu.IP1=FDCAN2 +Mcu.IP2=FDCAN3 +Mcu.IP3=LPUART1 +Mcu.IP4=NVIC +Mcu.IP5=RCC +Mcu.IP6=SYS +Mcu.IP7=TIM5 +Mcu.IPNb=8 +Mcu.Name=STM32G474R(B-C-E)Tx +Mcu.Package=LQFP64 +Mcu.Pin0=PC13 +Mcu.Pin1=PA2 +Mcu.Pin10=PB3 +Mcu.Pin11=PB8-BOOT0 +Mcu.Pin12=PB9 +Mcu.Pin13=VP_SYS_VS_Systick +Mcu.Pin14=VP_SYS_VS_DBSignals +Mcu.Pin15=VP_TIM5_VS_ClockSourceINT +Mcu.Pin2=PA3 +Mcu.Pin3=PA5 +Mcu.Pin4=PB12 +Mcu.Pin5=PB13 +Mcu.Pin6=PA8 +Mcu.Pin7=PA13 +Mcu.Pin8=PA14 +Mcu.Pin9=PA15 +Mcu.PinsNb=16 +Mcu.ThirdPartyNb=0 +Mcu.UserConstants= +Mcu.UserName=STM32G474RETx +MxCube.Version=6.18.1 +MxDb.Version=DB.6.0.181 +NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false +NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false +NVIC.FDCAN1_IT0_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true +NVIC.FDCAN2_IT0_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true +NVIC.FDCAN3_IT0_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true +NVIC.ForceEnableDMAVector=false +NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false +NVIC.LPUART1_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true +NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false +NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false +NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false +NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 +NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false +NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:false +NVIC.TIM5_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true +NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false +PA13.Mode=Trace_Asynchronous_SW +PA13.Signal=SYS_JTMS-SWDIO +PA14.Mode=Trace_Asynchronous_SW +PA14.Signal=SYS_JTCK-SWCLK +PA15.Mode=FDCAN_Activate +PA15.Signal=FDCAN3_TX +PA2.Locked=true +PA2.Mode=Asynchronous +PA2.Signal=LPUART1_TX +PA3.Locked=true +PA3.Mode=Asynchronous +PA3.Signal=LPUART1_RX +PA5.GPIOParameters=GPIO_Label +PA5.GPIO_Label=USER_LED +PA5.Locked=true +PA5.Signal=GPIO_Output +PA8.Mode=FDCAN_Activate +PA8.Signal=FDCAN3_RX +PB12.Mode=FDCAN_Activate +PB12.Signal=FDCAN2_RX +PB13.Mode=FDCAN_Activate +PB13.Signal=FDCAN2_TX +PB3.Mode=Trace_Asynchronous_SW +PB3.Signal=SYS_JTDO-SWO +PB8-BOOT0.Mode=FDCAN_Activate +PB8-BOOT0.Signal=FDCAN1_RX +PB9.Mode=FDCAN_Activate +PB9.Signal=FDCAN1_TX +PC13.GPIOParameters=GPIO_Label +PC13.GPIO_Label=USER_BUTTON +PC13.Locked=true +PC13.Signal=GPIO_Input +PinOutPanel.RotationAngle=0 +ProjectManager.AskForMigrate=true +ProjectManager.BackupPrevious=false +ProjectManager.CompilerLinker=GCC +ProjectManager.CompilerOptimize=6 +ProjectManager.ComputerToolchain=false +ProjectManager.CoupleFile=true +ProjectManager.CustomerFirmwarePackage= +ProjectManager.DefaultFWLocation=true +ProjectManager.DeletePrevious=true +ProjectManager.DeviceId=STM32G474RETx +ProjectManager.FirmwarePackage=STM32Cube FW_G4 V1.6.3 +ProjectManager.FreePins=true +ProjectManager.FreePinsContext= +ProjectManager.HalAssertFull=true +ProjectManager.HeapSize=0x200 +ProjectManager.KeepUserCode=true +ProjectManager.LastFirmware=true +ProjectManager.LibraryCopy=2 +ProjectManager.MainLocation=Core/Src +ProjectManager.NoMain=false +ProjectManager.PreviousToolchain= +ProjectManager.ProjectBuild=false +ProjectManager.ProjectFileName=CUBEMXTESTING.ioc +ProjectManager.ProjectName=CUBEMXTESTING +ProjectManager.ProjectStructure= +ProjectManager.RegisterCallBack= +ProjectManager.StackSize=0x400 +ProjectManager.TargetToolchain=EWARM V8.50 +ProjectManager.TemplateDestinationPath=C\:\\Users\\maxnm\\Firmware\\CUBEMXTESTING +ProjectManager.TemplateSourcePath=C\:\\Users\\maxnm\\Firmware\\Lib\\CubeMXTemplates +ProjectManager.TemplatesList=\\Autogen\\Inc\\can_cfg_h.ftl, +ProjectManager.ToolChainLocation= +ProjectManager.UAScriptAfterPath= +ProjectManager.UAScriptBeforePath= +ProjectManager.UnderRoot=false +ProjectManager.UseDefaultDestinationPath=true +ProjectManager.UseDefaultSourcePath=true +ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-LL-false,2-MX_GPIO_Init-GPIO-false-LL-true,3-MX_FDCAN1_Init-FDCAN1-false-HAL-true,4-MX_FDCAN2_Init-FDCAN2-false-HAL-true,5-MX_TIM5_Init-TIM5-false-HAL-true,6-MX_FDCAN3_Init-FDCAN3-false-HAL-true,7-MX_LPUART1_UART_Init-LPUART1-false-HAL-true +RCC.ADC12Freq_Value=160000000 +RCC.ADC345Freq_Value=160000000 +RCC.AHBFreq_Value=160000000 +RCC.APB1Freq_Value=160000000 +RCC.APB1TimFreq_Value=160000000 +RCC.APB2Freq_Value=160000000 +RCC.APB2TimFreq_Value=160000000 +RCC.CRSFreq_Value=48000000 +RCC.CortexFreq_Value=160000000 +RCC.EXTERNAL_CLOCK_VALUE=12288000 +RCC.FCLKCortexFreq_Value=160000000 +RCC.FDCANFreq_Value=160000000 +RCC.FamilyName=M +RCC.HCLKFreq_Value=160000000 +RCC.HRTIM1Freq_Value=160000000 +RCC.HSE_VALUE=16000000 +RCC.HSI48_VALUE=48000000 +RCC.HSI_VALUE=16000000 +RCC.I2C1Freq_Value=160000000 +RCC.I2C2Freq_Value=160000000 +RCC.I2C3Freq_Value=160000000 +RCC.I2C4Freq_Value=160000000 +RCC.I2SFreq_Value=160000000 +RCC.IPParameters=ADC12Freq_Value,ADC345Freq_Value,AHBFreq_Value,APB1Freq_Value,APB1TimFreq_Value,APB2Freq_Value,APB2TimFreq_Value,CRSFreq_Value,CortexFreq_Value,EXTERNAL_CLOCK_VALUE,FCLKCortexFreq_Value,FDCANFreq_Value,FamilyName,HCLKFreq_Value,HRTIM1Freq_Value,HSE_VALUE,HSI48_VALUE,HSI_VALUE,I2C1Freq_Value,I2C2Freq_Value,I2C3Freq_Value,I2C4Freq_Value,I2SFreq_Value,LPTIM1Freq_Value,LPUART1Freq_Value,LSCOPinFreq_Value,LSE_VALUE,LSI_VALUE,MCO1PinFreq_Value,PLLN,PLLPoutputFreq_Value,PLLQ,PLLQoutputFreq_Value,PLLRCLKFreq_Value,PWRFreq_Value,QSPIFreq_Value,RNGFreq_Value,SAI1Freq_Value,SYSCLKFreq_VALUE,SYSCLKSource,UART4Freq_Value,UART5Freq_Value,USART1Freq_Value,USART2Freq_Value,USART3Freq_Value,USBFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value +RCC.LPTIM1Freq_Value=160000000 +RCC.LPUART1Freq_Value=160000000 +RCC.LSCOPinFreq_Value=32000 +RCC.LSE_VALUE=32768 +RCC.LSI_VALUE=32000 +RCC.MCO1PinFreq_Value=16000000 +RCC.PLLN=20 +RCC.PLLPoutputFreq_Value=160000000 +RCC.PLLQ=RCC_PLLQ_DIV4 +RCC.PLLQoutputFreq_Value=80000000 +RCC.PLLRCLKFreq_Value=160000000 +RCC.PWRFreq_Value=160000000 +RCC.QSPIFreq_Value=160000000 +RCC.RNGFreq_Value=80000000 +RCC.SAI1Freq_Value=160000000 +RCC.SYSCLKFreq_VALUE=160000000 +RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK +RCC.UART4Freq_Value=160000000 +RCC.UART5Freq_Value=160000000 +RCC.USART1Freq_Value=160000000 +RCC.USART2Freq_Value=160000000 +RCC.USART3Freq_Value=160000000 +RCC.USBFreq_Value=80000000 +RCC.VCOInputFreq_Value=16000000 +RCC.VCOOutputFreq_Value=320000000 +TIM5.Dithering=Disable +TIM5.IPParameters=Prescaler,PeriodNoDither,Dithering +TIM5.PeriodNoDither=499 +TIM5.Prescaler=159 +VP_SYS_VS_DBSignals.Mode=DisableDeadBatterySignals +VP_SYS_VS_DBSignals.Signal=SYS_VS_DBSignals +VP_SYS_VS_Systick.Mode=SysTick +VP_SYS_VS_Systick.Signal=SYS_VS_Systick +VP_TIM5_VS_ClockSourceINT.Mode=Internal +VP_TIM5_VS_ClockSourceINT.Signal=TIM5_VS_ClockSourceINT +board=custom diff --git a/G474xE_CAN_TESTING/Core/Inc/fdcan.h b/Testbench/CUBEMXTESTING/Core/Inc/fdcan.h similarity index 88% rename from G474xE_CAN_TESTING/Core/Inc/fdcan.h rename to Testbench/CUBEMXTESTING/Core/Inc/fdcan.h index 56c4a8adb..3597c6476 100644 --- a/G474xE_CAN_TESTING/Core/Inc/fdcan.h +++ b/Testbench/CUBEMXTESTING/Core/Inc/fdcan.h @@ -7,7 +7,7 @@ ****************************************************************************** * @attention * - * Copyright (c) 2024 STMicroelectronics. + * Copyright (c) 2026 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file @@ -32,13 +32,19 @@ extern "C" { /* USER CODE END Includes */ +extern FDCAN_HandleTypeDef hfdcan1; + extern FDCAN_HandleTypeDef hfdcan2; +extern FDCAN_HandleTypeDef hfdcan3; + /* USER CODE BEGIN Private defines */ /* USER CODE END Private defines */ +void MX_FDCAN1_Init(void); void MX_FDCAN2_Init(void); +void MX_FDCAN3_Init(void); /* USER CODE BEGIN Prototypes */ diff --git a/G474xE_CAN_TESTING/Core/Inc/gpio.h b/Testbench/CUBEMXTESTING/Core/Inc/gpio.h similarity index 96% rename from G474xE_CAN_TESTING/Core/Inc/gpio.h rename to Testbench/CUBEMXTESTING/Core/Inc/gpio.h index 843d4e9e7..37dcc0a5c 100644 --- a/G474xE_CAN_TESTING/Core/Inc/gpio.h +++ b/Testbench/CUBEMXTESTING/Core/Inc/gpio.h @@ -7,7 +7,7 @@ ****************************************************************************** * @attention * - * Copyright (c) 2024 STMicroelectronics. + * Copyright (c) 2026 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file diff --git a/G431x8_CAN_TESTING/Core/Inc/main.h b/Testbench/CUBEMXTESTING/Core/Inc/main.h similarity index 63% rename from G431x8_CAN_TESTING/Core/Inc/main.h rename to Testbench/CUBEMXTESTING/Core/Inc/main.h index 23d7ffce4..cbeced83f 100644 --- a/G431x8_CAN_TESTING/Core/Inc/main.h +++ b/Testbench/CUBEMXTESTING/Core/Inc/main.h @@ -7,7 +7,7 @@ ****************************************************************************** * @attention * - * Copyright (c) 2024 STMicroelectronics. + * Copyright (c) 2026 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file @@ -28,31 +28,30 @@ extern "C" { /* Includes ------------------------------------------------------------------*/ #include "stm32g4xx_hal.h" -#include "stm32g4xx_ll_adc.h" #include "stm32g4xx_ll_bus.h" #include "stm32g4xx_ll_cortex.h" #include "stm32g4xx_ll_crs.h" #include "stm32g4xx_ll_dma.h" #include "stm32g4xx_ll_exti.h" #include "stm32g4xx_ll_gpio.h" -#include "stm32g4xx_ll_i2c.h" -#include "stm32g4xx_ll_lpuart.h" #include "stm32g4xx_ll_pwr.h" #include "stm32g4xx_ll_rcc.h" -#include "stm32g4xx_ll_spi.h" #include "stm32g4xx_ll_system.h" -#include "stm32g4xx_ll_tim.h" -#include "stm32g4xx_ll_usart.h" #include "stm32g4xx_ll_utils.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ - +#include "CubeCAN.h" +#include "stm32g4xx_ll_lpuart.h" +#include "stm32g4xx_ll_rcc.h" +#include "stm32g4xx_ll_usart.h" /* USER CODE END Includes */ /* Exported types ------------------------------------------------------------*/ /* USER CODE BEGIN ET */ - +extern CubeCAN_Handle *primaryHandle; +extern CubeCAN_Handle *dataHandle; +extern CubeCAN_Handle *chargerHandle; /* USER CODE END ET */ /* Exported constants --------------------------------------------------------*/ @@ -73,36 +72,10 @@ void Error_Handler(void); /* USER CODE END EFP */ /* Private defines -----------------------------------------------------------*/ -#define BSPD_SIGNAL_Pin LL_GPIO_PIN_1 -#define BSPD_SIGNAL_GPIO_Port GPIOC -#define APPS1_SIGNAL_Pin LL_GPIO_PIN_2 -#define APPS1_SIGNAL_GPIO_Port GPIOC -#define APPS2_SIGNAL_Pin LL_GPIO_PIN_3 -#define APPS2_SIGNAL_GPIO_Port GPIOC -#define BLINKY_Pin LL_GPIO_PIN_5 -#define BLINKY_GPIO_Port GPIOA -#define IMD_SENSE_Pin LL_GPIO_PIN_6 -#define IMD_SENSE_GPIO_Port GPIOA -#define AMS_SENSE_Pin LL_GPIO_PIN_7 -#define AMS_SENSE_GPIO_Port GPIOA -#define BRAKE_F_SIGNAL_Pin LL_GPIO_PIN_0 -#define BRAKE_F_SIGNAL_GPIO_Port GPIOB -#define BRAKE_R_SIGNAL_Pin LL_GPIO_PIN_1 -#define BRAKE_R_SIGNAL_GPIO_Port GPIOB -#define LED_TEST_Pin LL_GPIO_PIN_11 -#define LED_TEST_GPIO_Port GPIOB -#define AUX_SIGNAL_Pin LL_GPIO_PIN_14 -#define AUX_SIGNAL_GPIO_Port GPIOB -#define STEERING_ANGLE_Pin LL_GPIO_PIN_15 -#define STEERING_ANGLE_GPIO_Port GPIOB -#define BRAKE_LIGHT_Pin LL_GPIO_PIN_4 -#define BRAKE_LIGHT_GPIO_Port GPIOB -#define TSSI_G_CONTROL_Pin LL_GPIO_PIN_5 -#define TSSI_G_CONTROL_GPIO_Port GPIOB -#define AUX_CONTROL_Pin LL_GPIO_PIN_8 -#define AUX_CONTROL_GPIO_Port GPIOB -#define SOFTWARE_OK_CONTROL_Pin LL_GPIO_PIN_9 -#define SOFTWARE_OK_CONTROL_GPIO_Port GPIOB +#define USER_BUTTON_Pin LL_GPIO_PIN_13 +#define USER_BUTTON_GPIO_Port GPIOC +#define USER_LED_Pin LL_GPIO_PIN_5 +#define USER_LED_GPIO_Port GPIOA /* USER CODE BEGIN Private defines */ diff --git a/G474xE_CAN_TESTING/Core/Inc/stm32g4xx_hal_conf.h b/Testbench/CUBEMXTESTING/Core/Inc/stm32g4xx_hal_conf.h similarity index 90% rename from G474xE_CAN_TESTING/Core/Inc/stm32g4xx_hal_conf.h rename to Testbench/CUBEMXTESTING/Core/Inc/stm32g4xx_hal_conf.h index 3e1fcb018..d12d585bd 100644 --- a/G474xE_CAN_TESTING/Core/Inc/stm32g4xx_hal_conf.h +++ b/Testbench/CUBEMXTESTING/Core/Inc/stm32g4xx_hal_conf.h @@ -39,7 +39,7 @@ extern "C" { /*#define HAL_ADC_MODULE_ENABLED */ /*#define HAL_COMP_MODULE_ENABLED */ /*#define HAL_CORDIC_MODULE_ENABLED */ -#define HAL_CRC_MODULE_ENABLED +/*#define HAL_CRC_MODULE_ENABLED */ /*#define HAL_CRYP_MODULE_ENABLED */ /*#define HAL_DAC_MODULE_ENABLED */ #define HAL_FDCAN_MODULE_ENABLED @@ -62,8 +62,8 @@ extern "C" { /*#define HAL_SMBUS_MODULE_ENABLED */ /*#define HAL_SPI_MODULE_ENABLED */ /*#define HAL_SRAM_MODULE_ENABLED */ -/*#define HAL_TIM_MODULE_ENABLED */ -/*#define HAL_UART_MODULE_ENABLED */ +#define HAL_TIM_MODULE_ENABLED +#define HAL_UART_MODULE_ENABLED /*#define HAL_USART_MODULE_ENABLED */ /*#define HAL_WWDG_MODULE_ENABLED */ #define HAL_GPIO_MODULE_ENABLED @@ -74,8 +74,7 @@ extern "C" { #define HAL_PWR_MODULE_ENABLED #define HAL_CORTEX_MODULE_ENABLED -/* ########################## Register Callbacks selection - * ############################## */ +/* ########################## Register Callbacks selection ############################## */ /** * @brief This is the list of modules where register callback can be used */ @@ -109,13 +108,11 @@ extern "C" { #define USE_HAL_USART_REGISTER_CALLBACKS 0U #define USE_HAL_WWDG_REGISTER_CALLBACKS 0U -/* ########################## Oscillator Values adaptation - * ####################*/ +/* ########################## Oscillator Values adaptation ####################*/ /** - * @brief Adjust the value of External High Speed oscillator (HSE) used in your - * application. This value is used by the RCC HAL module to compute the system - * frequency (when HSE is used as system clock source, directly or through the - * PLL). + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). */ #if !defined(HSE_VALUE) #define HSE_VALUE (16000000UL) /*!< Value of the External oscillator in Hz */ @@ -127,9 +124,8 @@ extern "C" { /** * @brief Internal High Speed oscillator (HSI) value. - * This value is used by the RCC HAL module to compute the system - * frequency (when HSI is used as system clock source, directly or through the - * PLL). + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). */ #if !defined(HSI_VALUE) #define HSI_VALUE (16000000UL) /*!< Value of the Internal oscillator in Hz*/ @@ -137,17 +133,15 @@ extern "C" { /** * @brief Internal High Speed oscillator (HSI48) value for USB FS and RNG. - * This internal oscillator is mainly dedicated to provide a high - * precision clock to the USB peripheral by means of a special Clock Recovery - * System (CRS) circuitry. When the CRS is not used, the HSI48 RC oscillator - * runs on it default frequency which is subject to manufacturing process - * variations. + * This internal oscillator is mainly dedicated to provide a high precision clock to + * the USB peripheral by means of a special Clock Recovery System (CRS) circuitry. + * When the CRS is not used, the HSI48 RC oscillator runs on it default frequency + * which is subject to manufacturing process variations. */ #if !defined(HSI48_VALUE) #define HSI48_VALUE \ - (48000000UL) /*!< Value of the Internal High Speed oscillator for USB \ - FS/RNG in Hz. The real value my vary depending on \ - manufacturing process variations.*/ + (48000000UL) /*!< Value of the Internal High Speed oscillator for USB FS/RNG in Hz. \ + The real value my vary depending on manufacturing process variations.*/ #endif /* HSI48_VALUE */ /** @@ -155,14 +149,12 @@ extern "C" { */ #if !defined(LSI_VALUE) /*!< Value of the Internal Low Speed oscillator in Hz -The real value may vary depending on the variations in voltage and -temperature.*/ +The real value may vary depending on the variations in voltage and temperature.*/ #define LSI_VALUE (32000UL) /*!< LSI Typical Value in Hz*/ #endif /* LSI_VALUE */ /** * @brief External Low Speed oscillator (LSE) value. - * This value is used by the UART, RTC HAL module to compute the system - * frequency + * This value is used by the UART, RTC HAL module to compute the system frequency */ #if !defined(LSE_VALUE) #define LSE_VALUE (32768UL) /*!< Value of the External Low Speed oscillator in Hz */ @@ -174,9 +166,8 @@ temperature.*/ /** * @brief External clock source for I2S and SAI peripherals - * This value is used by the I2S and SAI HAL modules to compute the I2S - * and SAI clock source frequency, this source is inserted directly through - * I2S_CKIN pad. + * This value is used by the I2S and SAI HAL modules to compute the I2S and SAI clock source + * frequency, this source is inserted directly through I2S_CKIN pad. */ #if !defined(EXTERNAL_CLOCK_VALUE) #define EXTERNAL_CLOCK_VALUE (12288000UL) /*!< Value of the External oscillator in Hz*/ @@ -202,7 +193,7 @@ temperature.*/ * @brief Uncomment the line below to expanse the "assert_param" macro in the * HAL drivers code */ -/* #define USE_FULL_ASSERT 1U */ +#define USE_FULL_ASSERT 1U /* ################## SPI peripheral configuration ########################## */ diff --git a/G4ADCTESTING/Core/Inc/stm32g4xx_it.h b/Testbench/CUBEMXTESTING/Core/Inc/stm32g4xx_it.h similarity index 91% rename from G4ADCTESTING/Core/Inc/stm32g4xx_it.h rename to Testbench/CUBEMXTESTING/Core/Inc/stm32g4xx_it.h index b6c3b2f72..b2d3d042e 100644 --- a/G4ADCTESTING/Core/Inc/stm32g4xx_it.h +++ b/Testbench/CUBEMXTESTING/Core/Inc/stm32g4xx_it.h @@ -6,7 +6,7 @@ ****************************************************************************** * @attention * - * Copyright (c) 2024 STMicroelectronics. + * Copyright (c) 2026 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file @@ -55,7 +55,11 @@ void SVC_Handler(void); void DebugMon_Handler(void); void PendSV_Handler(void); void SysTick_Handler(void); +void FDCAN1_IT0_IRQHandler(void); +void TIM5_IRQHandler(void); void FDCAN2_IT0_IRQHandler(void); +void FDCAN3_IT0_IRQHandler(void); +void LPUART1_IRQHandler(void); /* USER CODE BEGIN EFP */ /* USER CODE END EFP */ diff --git a/G431x8_CAN_TESTING/Core/Inc/tim.h b/Testbench/CUBEMXTESTING/Core/Inc/tim.h similarity index 90% rename from G431x8_CAN_TESTING/Core/Inc/tim.h rename to Testbench/CUBEMXTESTING/Core/Inc/tim.h index c19e6cc71..2d20bd560 100644 --- a/G431x8_CAN_TESTING/Core/Inc/tim.h +++ b/Testbench/CUBEMXTESTING/Core/Inc/tim.h @@ -7,7 +7,7 @@ ****************************************************************************** * @attention * - * Copyright (c) 2025 STMicroelectronics. + * Copyright (c) 2026 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file @@ -32,11 +32,13 @@ extern "C" { /* USER CODE END Includes */ -/* USER CODE BEGIN Private defines */ +extern TIM_HandleTypeDef htim5; +/* USER CODE BEGIN Private defines */ +#define CAN_TIMER_HANDLE htim5 /* USER CODE END Private defines */ -void MX_TIM2_Init(void); +void MX_TIM5_Init(void); /* USER CODE BEGIN Prototypes */ diff --git a/G431x8_CAN_TESTING/Core/Inc/usart.h b/Testbench/CUBEMXTESTING/Core/Inc/usart.h similarity index 93% rename from G431x8_CAN_TESTING/Core/Inc/usart.h rename to Testbench/CUBEMXTESTING/Core/Inc/usart.h index daefd73e6..bdec0c9cb 100644 --- a/G431x8_CAN_TESTING/Core/Inc/usart.h +++ b/Testbench/CUBEMXTESTING/Core/Inc/usart.h @@ -7,7 +7,7 @@ ****************************************************************************** * @attention * - * Copyright (c) 2025 STMicroelectronics. + * Copyright (c) 2026 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file @@ -32,12 +32,13 @@ extern "C" { /* USER CODE END Includes */ +extern UART_HandleTypeDef hlpuart1; + /* USER CODE BEGIN Private defines */ /* USER CODE END Private defines */ void MX_LPUART1_UART_Init(void); -void MX_USART1_UART_Init(void); /* USER CODE BEGIN Prototypes */ diff --git a/Testbench/CUBEMXTESTING/Core/Src/fdcan.c b/Testbench/CUBEMXTESTING/Core/Src/fdcan.c new file mode 100644 index 000000000..30b3c9dc1 --- /dev/null +++ b/Testbench/CUBEMXTESTING/Core/Src/fdcan.c @@ -0,0 +1,312 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file fdcan.c + * @brief This file provides code for the configuration + * of the FDCAN instances. + ****************************************************************************** + * @attention + * + * Copyright (c) 2026 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 "fdcan.h" + +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +FDCAN_HandleTypeDef hfdcan1; +FDCAN_HandleTypeDef hfdcan2; +FDCAN_HandleTypeDef hfdcan3; + +/* FDCAN1 init function */ +void MX_FDCAN1_Init(void) +{ + + /* USER CODE BEGIN FDCAN1_Init 0 */ + + /* USER CODE END FDCAN1_Init 0 */ + + /* USER CODE BEGIN FDCAN1_Init 1 */ + + /* USER CODE END FDCAN1_Init 1 */ + hfdcan1.Instance = FDCAN1; + hfdcan1.Init.ClockDivider = FDCAN_CLOCK_DIV1; + hfdcan1.Init.FrameFormat = FDCAN_FRAME_CLASSIC; + hfdcan1.Init.Mode = FDCAN_MODE_INTERNAL_LOOPBACK; + hfdcan1.Init.AutoRetransmission = ENABLE; + hfdcan1.Init.TransmitPause = DISABLE; + hfdcan1.Init.ProtocolException = ENABLE; + hfdcan1.Init.NominalPrescaler = 1; + hfdcan1.Init.NominalSyncJumpWidth = 16; + hfdcan1.Init.NominalTimeSeg1 = 119; + hfdcan1.Init.NominalTimeSeg2 = 40; + hfdcan1.Init.DataPrescaler = 8; + hfdcan1.Init.DataSyncJumpWidth = 16; + hfdcan1.Init.DataTimeSeg1 = 14; + hfdcan1.Init.DataTimeSeg2 = 5; + hfdcan1.Init.StdFiltersNbr = 0; + hfdcan1.Init.ExtFiltersNbr = 2; + hfdcan1.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION; + if (HAL_FDCAN_Init(&hfdcan1) != HAL_OK) { + Error_Handler(); + } + /* USER CODE BEGIN FDCAN1_Init 2 */ + + /* USER CODE END FDCAN1_Init 2 */ +} +/* FDCAN2 init function */ +void MX_FDCAN2_Init(void) +{ + + /* USER CODE BEGIN FDCAN2_Init 0 */ + + /* USER CODE END FDCAN2_Init 0 */ + + /* USER CODE BEGIN FDCAN2_Init 1 */ + + /* USER CODE END FDCAN2_Init 1 */ + hfdcan2.Instance = FDCAN2; + hfdcan2.Init.ClockDivider = FDCAN_CLOCK_DIV1; + hfdcan2.Init.FrameFormat = FDCAN_FRAME_CLASSIC; + hfdcan2.Init.Mode = FDCAN_MODE_INTERNAL_LOOPBACK; + hfdcan2.Init.AutoRetransmission = ENABLE; + hfdcan2.Init.TransmitPause = DISABLE; + hfdcan2.Init.ProtocolException = ENABLE; + hfdcan2.Init.NominalPrescaler = 1; + hfdcan2.Init.NominalSyncJumpWidth = 16; + hfdcan2.Init.NominalTimeSeg1 = 119; + hfdcan2.Init.NominalTimeSeg2 = 40; + hfdcan2.Init.DataPrescaler = 8; + hfdcan2.Init.DataSyncJumpWidth = 16; + hfdcan2.Init.DataTimeSeg1 = 14; + hfdcan2.Init.DataTimeSeg2 = 5; + hfdcan2.Init.StdFiltersNbr = 0; + hfdcan2.Init.ExtFiltersNbr = 2; + hfdcan2.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION; + if (HAL_FDCAN_Init(&hfdcan2) != HAL_OK) { + Error_Handler(); + } + /* USER CODE BEGIN FDCAN2_Init 2 */ + + /* USER CODE END FDCAN2_Init 2 */ +} +/* FDCAN3 init function */ +void MX_FDCAN3_Init(void) +{ + + /* USER CODE BEGIN FDCAN3_Init 0 */ + + /* USER CODE END FDCAN3_Init 0 */ + + /* USER CODE BEGIN FDCAN3_Init 1 */ + + /* USER CODE END FDCAN3_Init 1 */ + hfdcan3.Instance = FDCAN3; + hfdcan3.Init.ClockDivider = FDCAN_CLOCK_DIV1; + hfdcan3.Init.FrameFormat = FDCAN_FRAME_CLASSIC; + hfdcan3.Init.Mode = FDCAN_MODE_INTERNAL_LOOPBACK; + hfdcan3.Init.AutoRetransmission = DISABLE; + hfdcan3.Init.TransmitPause = DISABLE; + hfdcan3.Init.ProtocolException = DISABLE; + hfdcan3.Init.NominalPrescaler = 16; + hfdcan3.Init.NominalSyncJumpWidth = 1; + hfdcan3.Init.NominalTimeSeg1 = 1; + hfdcan3.Init.NominalTimeSeg2 = 1; + hfdcan3.Init.DataPrescaler = 1; + hfdcan3.Init.DataSyncJumpWidth = 1; + hfdcan3.Init.DataTimeSeg1 = 1; + hfdcan3.Init.DataTimeSeg2 = 1; + hfdcan3.Init.StdFiltersNbr = 0; + hfdcan3.Init.ExtFiltersNbr = 0; + hfdcan3.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION; + if (HAL_FDCAN_Init(&hfdcan3) != HAL_OK) { + Error_Handler(); + } + /* USER CODE BEGIN FDCAN3_Init 2 */ + + /* USER CODE END FDCAN3_Init 2 */ +} + +static uint32_t HAL_RCC_FDCAN_CLK_ENABLED = 0; + +void HAL_FDCAN_MspInit(FDCAN_HandleTypeDef *fdcanHandle) +{ + + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if (fdcanHandle->Instance == FDCAN1) { + /* USER CODE BEGIN FDCAN1_MspInit 0 */ + + /* USER CODE END FDCAN1_MspInit 0 */ + LL_RCC_SetFDCANClockSource(LL_RCC_FDCAN_CLKSOURCE_PCLK1); + + /* FDCAN1 clock enable */ + HAL_RCC_FDCAN_CLK_ENABLED++; + if (HAL_RCC_FDCAN_CLK_ENABLED == 1) { + __HAL_RCC_FDCAN_CLK_ENABLE(); + } + + __HAL_RCC_GPIOB_CLK_ENABLE(); + /**FDCAN1 GPIO Configuration + PB8-BOOT0 ------> FDCAN1_RX + PB9 ------> FDCAN1_TX + */ + GPIO_InitStruct.Pin = GPIO_PIN_8 | GPIO_PIN_9; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF9_FDCAN1; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /* FDCAN1 interrupt Init */ + HAL_NVIC_SetPriority(FDCAN1_IT0_IRQn, 0, 0); + HAL_NVIC_EnableIRQ(FDCAN1_IT0_IRQn); + /* USER CODE BEGIN FDCAN1_MspInit 1 */ + + /* USER CODE END FDCAN1_MspInit 1 */ + } else if (fdcanHandle->Instance == FDCAN2) { + /* USER CODE BEGIN FDCAN2_MspInit 0 */ + + /* USER CODE END FDCAN2_MspInit 0 */ + + LL_RCC_SetFDCANClockSource(LL_RCC_FDCAN_CLKSOURCE_PCLK1); + + /* FDCAN2 clock enable */ + HAL_RCC_FDCAN_CLK_ENABLED++; + if (HAL_RCC_FDCAN_CLK_ENABLED == 1) { + __HAL_RCC_FDCAN_CLK_ENABLE(); + } + + __HAL_RCC_GPIOB_CLK_ENABLE(); + /**FDCAN2 GPIO Configuration + PB12 ------> FDCAN2_RX + PB13 ------> FDCAN2_TX + */ + GPIO_InitStruct.Pin = GPIO_PIN_12 | GPIO_PIN_13; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF9_FDCAN2; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /* FDCAN2 interrupt Init */ + HAL_NVIC_SetPriority(FDCAN2_IT0_IRQn, 0, 0); + HAL_NVIC_EnableIRQ(FDCAN2_IT0_IRQn); + /* USER CODE BEGIN FDCAN2_MspInit 1 */ + + /* USER CODE END FDCAN2_MspInit 1 */ + } else if (fdcanHandle->Instance == FDCAN3) { + /* USER CODE BEGIN FDCAN3_MspInit 0 */ + + /* USER CODE END FDCAN3_MspInit 0 */ + + LL_RCC_SetFDCANClockSource(LL_RCC_FDCAN_CLKSOURCE_PCLK1); + + /* FDCAN3 clock enable */ + HAL_RCC_FDCAN_CLK_ENABLED++; + if (HAL_RCC_FDCAN_CLK_ENABLED == 1) { + __HAL_RCC_FDCAN_CLK_ENABLE(); + } + + __HAL_RCC_GPIOA_CLK_ENABLE(); + /**FDCAN3 GPIO Configuration + PA8 ------> FDCAN3_RX + PA15 ------> FDCAN3_TX + */ + GPIO_InitStruct.Pin = GPIO_PIN_8 | GPIO_PIN_15; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF11_FDCAN3; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /* FDCAN3 interrupt Init */ + HAL_NVIC_SetPriority(FDCAN3_IT0_IRQn, 0, 0); + HAL_NVIC_EnableIRQ(FDCAN3_IT0_IRQn); + /* USER CODE BEGIN FDCAN3_MspInit 1 */ + + /* USER CODE END FDCAN3_MspInit 1 */ + } +} + +void HAL_FDCAN_MspDeInit(FDCAN_HandleTypeDef *fdcanHandle) +{ + + if (fdcanHandle->Instance == FDCAN1) { + /* USER CODE BEGIN FDCAN1_MspDeInit 0 */ + + /* USER CODE END FDCAN1_MspDeInit 0 */ + /* Peripheral clock disable */ + HAL_RCC_FDCAN_CLK_ENABLED--; + if (HAL_RCC_FDCAN_CLK_ENABLED == 0) { + __HAL_RCC_FDCAN_CLK_DISABLE(); + } + + /**FDCAN1 GPIO Configuration + PB8-BOOT0 ------> FDCAN1_RX + PB9 ------> FDCAN1_TX + */ + HAL_GPIO_DeInit(GPIOB, GPIO_PIN_8 | GPIO_PIN_9); + + /* FDCAN1 interrupt Deinit */ + HAL_NVIC_DisableIRQ(FDCAN1_IT0_IRQn); + /* USER CODE BEGIN FDCAN1_MspDeInit 1 */ + + /* USER CODE END FDCAN1_MspDeInit 1 */ + } else if (fdcanHandle->Instance == FDCAN2) { + /* USER CODE BEGIN FDCAN2_MspDeInit 0 */ + + /* USER CODE END FDCAN2_MspDeInit 0 */ + /* Peripheral clock disable */ + HAL_RCC_FDCAN_CLK_ENABLED--; + if (HAL_RCC_FDCAN_CLK_ENABLED == 0) { + __HAL_RCC_FDCAN_CLK_DISABLE(); + } + + /**FDCAN2 GPIO Configuration + PB12 ------> FDCAN2_RX + PB13 ------> FDCAN2_TX + */ + HAL_GPIO_DeInit(GPIOB, GPIO_PIN_12 | GPIO_PIN_13); + + /* FDCAN2 interrupt Deinit */ + HAL_NVIC_DisableIRQ(FDCAN2_IT0_IRQn); + /* USER CODE BEGIN FDCAN2_MspDeInit 1 */ + + /* USER CODE END FDCAN2_MspDeInit 1 */ + } else if (fdcanHandle->Instance == FDCAN3) { + /* USER CODE BEGIN FDCAN3_MspDeInit 0 */ + + /* USER CODE END FDCAN3_MspDeInit 0 */ + /* Peripheral clock disable */ + HAL_RCC_FDCAN_CLK_ENABLED--; + if (HAL_RCC_FDCAN_CLK_ENABLED == 0) { + __HAL_RCC_FDCAN_CLK_DISABLE(); + } + + /**FDCAN3 GPIO Configuration + PA8 ------> FDCAN3_RX + PA15 ------> FDCAN3_TX + */ + HAL_GPIO_DeInit(GPIOA, GPIO_PIN_8 | GPIO_PIN_15); + + /* FDCAN3 interrupt Deinit */ + HAL_NVIC_DisableIRQ(FDCAN3_IT0_IRQn); + /* USER CODE BEGIN FDCAN3_MspDeInit 1 */ + + /* USER CODE END FDCAN3_MspDeInit 1 */ + } +} + +/* USER CODE BEGIN 1 */ + +/* USER CODE END 1 */ diff --git a/G474xE_CAN_TESTING/Core/Src/gpio.c b/Testbench/CUBEMXTESTING/Core/Src/gpio.c similarity index 59% rename from G474xE_CAN_TESTING/Core/Src/gpio.c rename to Testbench/CUBEMXTESTING/Core/Src/gpio.c index d36e6eca6..4d07c7993 100644 --- a/G474xE_CAN_TESTING/Core/Src/gpio.c +++ b/Testbench/CUBEMXTESTING/Core/Src/gpio.c @@ -7,7 +7,7 @@ ****************************************************************************** * @attention * - * Copyright (c) 2024 STMicroelectronics. + * Copyright (c) 2026 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file @@ -33,19 +33,14 @@ /* USER CODE END 1 */ /** Configure pins as - * Analog - * Input - * Output - * EVENT_OUT - * EXTI - * Free pins are configured automatically as Analog (this feature is - enabled through - * the Code Generation settings) - PA6 ------> ADC2_IN3 - PA7 ------> ADC2_IN4 - PB15 ------> ADC2_IN15 - PB7 ------> UART4_CTS -*/ + * Analog + * Input + * Output + * EVENT_OUT + * EXTI + * Free pins are configured automatically as Analog (this feature is enabled through + * the Code Generation settings) + */ void MX_GPIO_Init(void) { @@ -60,52 +55,73 @@ void MX_GPIO_Init(void) LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOD); /**/ - LL_GPIO_ResetOutputPin(BLINKY_GPIO_Port, BLINKY_Pin); + LL_GPIO_ResetOutputPin(USER_LED_GPIO_Port, USER_LED_Pin); /**/ - LL_GPIO_ResetOutputPin(LED_TEST_GPIO_Port, LED_TEST_Pin); + GPIO_InitStruct.Pin = USER_BUTTON_Pin; + GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + LL_GPIO_Init(USER_BUTTON_GPIO_Port, &GPIO_InitStruct); /**/ - LL_GPIO_ResetOutputPin(BRAKE_LIGHT_GPIO_Port, BRAKE_LIGHT_Pin); + GPIO_InitStruct.Pin = LL_GPIO_PIN_14; + GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + LL_GPIO_Init(GPIOC, &GPIO_InitStruct); /**/ - LL_GPIO_ResetOutputPin(TSSI_G_CONTROL_GPIO_Port, TSSI_G_CONTROL_Pin); + GPIO_InitStruct.Pin = LL_GPIO_PIN_15; + GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + LL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /**/ + GPIO_InitStruct.Pin = LL_GPIO_PIN_0; + GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + LL_GPIO_Init(GPIOF, &GPIO_InitStruct); /**/ - LL_GPIO_ResetOutputPin(AUX_CONTROL_GPIO_Port, AUX_CONTROL_Pin); + GPIO_InitStruct.Pin = LL_GPIO_PIN_1; + GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + LL_GPIO_Init(GPIOF, &GPIO_InitStruct); /**/ - LL_GPIO_ResetOutputPin(SOFTWARE_OK_CONTROL_GPIO_Port, SOFTWARE_OK_CONTROL_Pin); + GPIO_InitStruct.Pin = LL_GPIO_PIN_10; + GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + LL_GPIO_Init(GPIOG, &GPIO_InitStruct); /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_13; + GPIO_InitStruct.Pin = LL_GPIO_PIN_0; GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; LL_GPIO_Init(GPIOC, &GPIO_InitStruct); /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_14; + GPIO_InitStruct.Pin = LL_GPIO_PIN_1; GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; LL_GPIO_Init(GPIOC, &GPIO_InitStruct); /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_15; + GPIO_InitStruct.Pin = LL_GPIO_PIN_2; GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; LL_GPIO_Init(GPIOC, &GPIO_InitStruct); /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_10; + GPIO_InitStruct.Pin = LL_GPIO_PIN_3; GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOG, &GPIO_InitStruct); + LL_GPIO_Init(GPIOC, &GPIO_InitStruct); /**/ GPIO_InitStruct.Pin = LL_GPIO_PIN_0; GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); + LL_GPIO_Init(GPIOA, &GPIO_InitStruct); /**/ GPIO_InitStruct.Pin = LL_GPIO_PIN_1; @@ -120,24 +136,48 @@ void MX_GPIO_Init(void) LL_GPIO_Init(GPIOA, &GPIO_InitStruct); /**/ - GPIO_InitStruct.Pin = BLINKY_Pin; + GPIO_InitStruct.Pin = USER_LED_Pin; GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(BLINKY_GPIO_Port, &GPIO_InitStruct); + LL_GPIO_Init(USER_LED_GPIO_Port, &GPIO_InitStruct); + + /**/ + GPIO_InitStruct.Pin = LL_GPIO_PIN_6; + GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + LL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /**/ + GPIO_InitStruct.Pin = LL_GPIO_PIN_7; + GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + LL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /**/ + GPIO_InitStruct.Pin = LL_GPIO_PIN_4; + GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + LL_GPIO_Init(GPIOC, &GPIO_InitStruct); /**/ - GPIO_InitStruct.Pin = IMD_SENSE_Pin; + GPIO_InitStruct.Pin = LL_GPIO_PIN_5; GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(IMD_SENSE_GPIO_Port, &GPIO_InitStruct); + LL_GPIO_Init(GPIOC, &GPIO_InitStruct); /**/ - GPIO_InitStruct.Pin = AMS_SENSE_Pin; + GPIO_InitStruct.Pin = LL_GPIO_PIN_0; GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(AMS_SENSE_GPIO_Port, &GPIO_InitStruct); + LL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /**/ + GPIO_InitStruct.Pin = LL_GPIO_PIN_1; + GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + LL_GPIO_Init(GPIOB, &GPIO_InitStruct); /**/ GPIO_InitStruct.Pin = LL_GPIO_PIN_2; @@ -152,18 +192,22 @@ void MX_GPIO_Init(void) LL_GPIO_Init(GPIOB, &GPIO_InitStruct); /**/ - GPIO_InitStruct.Pin = LED_TEST_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + GPIO_InitStruct.Pin = LL_GPIO_PIN_11; + GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(LED_TEST_GPIO_Port, &GPIO_InitStruct); + LL_GPIO_Init(GPIOB, &GPIO_InitStruct); /**/ - GPIO_InitStruct.Pin = STEERING_ANGLE_Pin; + GPIO_InitStruct.Pin = LL_GPIO_PIN_14; GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(STEERING_ANGLE_GPIO_Port, &GPIO_InitStruct); + LL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /**/ + GPIO_InitStruct.Pin = LL_GPIO_PIN_15; + GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + LL_GPIO_Init(GPIOB, &GPIO_InitStruct); /**/ GPIO_InitStruct.Pin = LL_GPIO_PIN_6; @@ -202,57 +246,64 @@ void MX_GPIO_Init(void) LL_GPIO_Init(GPIOA, &GPIO_InitStruct); /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_15; + GPIO_InitStruct.Pin = LL_GPIO_PIN_11; GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; LL_GPIO_Init(GPIOA, &GPIO_InitStruct); /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_2; + GPIO_InitStruct.Pin = LL_GPIO_PIN_12; GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOD, &GPIO_InitStruct); + LL_GPIO_Init(GPIOA, &GPIO_InitStruct); /**/ - GPIO_InitStruct.Pin = BRAKE_LIGHT_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + GPIO_InitStruct.Pin = LL_GPIO_PIN_10; + GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(BRAKE_LIGHT_GPIO_Port, &GPIO_InitStruct); + LL_GPIO_Init(GPIOC, &GPIO_InitStruct); /**/ - GPIO_InitStruct.Pin = TSSI_G_CONTROL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + GPIO_InitStruct.Pin = LL_GPIO_PIN_11; + GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(TSSI_G_CONTROL_GPIO_Port, &GPIO_InitStruct); + LL_GPIO_Init(GPIOC, &GPIO_InitStruct); /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_7; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + GPIO_InitStruct.Pin = LL_GPIO_PIN_12; + GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + LL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /**/ + GPIO_InitStruct.Pin = LL_GPIO_PIN_2; + GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + LL_GPIO_Init(GPIOD, &GPIO_InitStruct); + + /**/ + GPIO_InitStruct.Pin = LL_GPIO_PIN_4; + GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_14; LL_GPIO_Init(GPIOB, &GPIO_InitStruct); /**/ - GPIO_InitStruct.Pin = AUX_CONTROL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + GPIO_InitStruct.Pin = LL_GPIO_PIN_5; + GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(AUX_CONTROL_GPIO_Port, &GPIO_InitStruct); + LL_GPIO_Init(GPIOB, &GPIO_InitStruct); /**/ - GPIO_InitStruct.Pin = SOFTWARE_OK_CONTROL_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + GPIO_InitStruct.Pin = LL_GPIO_PIN_6; + GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(SOFTWARE_OK_CONTROL_GPIO_Port, &GPIO_InitStruct); + LL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /**/ + GPIO_InitStruct.Pin = LL_GPIO_PIN_7; + GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + LL_GPIO_Init(GPIOB, &GPIO_InitStruct); } /* USER CODE BEGIN 2 */ diff --git a/G4PERTESTING/Core/Src/main.c b/Testbench/CUBEMXTESTING/Core/Src/main.c similarity index 64% rename from G4PERTESTING/Core/Src/main.c rename to Testbench/CUBEMXTESTING/Core/Src/main.c index ba6196726..7344dd05d 100644 --- a/G4PERTESTING/Core/Src/main.c +++ b/Testbench/CUBEMXTESTING/Core/Src/main.c @@ -6,7 +6,7 @@ ****************************************************************************** * @attention * - * Copyright (c) 2024 STMicroelectronics. + * Copyright (c) 2026 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file @@ -19,18 +19,23 @@ /* Includes ------------------------------------------------------------------*/ #include "main.h" -#include "adc.h" -#include "dma.h" #include "fdcan.h" #include "gpio.h" -#include "i2c.h" -#include "spi.h" #include "tim.h" #include "usart.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ - +#include + +#include "CANdler.h" +#include "CubeCAN.h" +#include "CubeVCP.h" +#include "GRCAN_BUS_ID.h" +#include "GRCAN_NODE_ID.h" +#include "Logomatic.h" +#include "Loop.h" +#include "tim.h" /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ @@ -51,6 +56,9 @@ /* Private variables ---------------------------------------------------------*/ /* USER CODE BEGIN PV */ +CubeCAN_Handle *primaryHandle = NULL; +CubeCAN_Handle *dataHandle = NULL; +CubeCAN_Handle *chargerHandle = NULL; /* USER CODE END PV */ /* Private function prototypes -----------------------------------------------*/ @@ -75,11 +83,9 @@ int main(void) /* USER CODE END 1 */ - /* MCU - * Configuration--------------------------------------------------------*/ + /* MCU Configuration--------------------------------------------------------*/ - /* Reset of all peripherals, Initializes the Flash interface and the - * Systick. */ + /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* USER CODE BEGIN Init */ @@ -90,21 +96,43 @@ int main(void) SystemClock_Config(); /* USER CODE BEGIN SysInit */ - + Logomatic_SetLogLevel(LogLevel_Debug); /* USER CODE END SysInit */ /* Initialize all configured peripherals */ MX_GPIO_Init(); - MX_DMA_Init(); + MX_FDCAN1_Init(); MX_FDCAN2_Init(); - MX_ADC1_Init(); + MX_TIM5_Init(); + MX_FDCAN3_Init(); MX_LPUART1_UART_Init(); - MX_I2C2_Init(); - MX_USART1_UART_Init(); - MX_SPI3_Init(); - MX_TIM2_Init(); /* USER CODE BEGIN 2 */ + CubeCAN_Config primaryCanConfig = {.rx_callback = CANdler_Callback, .context.busid_user_context = GRCAN_BUS_PRIMARY, .sending_node_id = GRCAN_Debugger}; + CubeCAN_Config dataCanConfig = {.rx_callback = CANdler_Callback, .context.busid_user_context = GRCAN_BUS_DATA, .sending_node_id = GRCAN_Debugger}; + CubeCAN_Config chargerCanConfig = {.rx_callback = CANdler_Callback, .context.busid_user_context = GRCAN_BUS_CHARGER, .sending_node_id = GRCAN_Debugger}; + + primaryHandle = CubeCAN_Entrance(&hfdcan1, &primaryCanConfig); + if (primaryHandle == NULL) { + LOGOMATIC_CRITICAL("Failed to initialize primary CAN handle\n"); + Error_Handler(); + } + dataHandle = CubeCAN_Entrance(&hfdcan2, &dataCanConfig); + if (dataHandle == NULL) { + LOGOMATIC_CRITICAL("Failed to initialize data CAN handle\n"); + Error_Handler(); + } + + chargerHandle = CubeCAN_Entrance(&hfdcan3, &chargerCanConfig); + if (chargerHandle == NULL) { + LOGOMATIC_CRITICAL("Failed to initialize charger CAN handle\n"); + Error_Handler(); + } + + LOGOMATIC_INFO("Hello World!\n"); + CubeVCP_Setup(&hlpuart1); + CubeVCP_EnableRx(CANdler_VCP_Callback); + CubeVCP_SendString("Hello World!\n", sizeof("Hello World!\n") - 1); /* USER CODE END 2 */ /* Infinite loop */ @@ -112,14 +140,11 @@ int main(void) while (1) { /* USER CODE END WHILE */ - // BLINKY - HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_SET); - HAL_Delay(1000); - HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_RESET); - HAL_Delay(1000); - /* USER CODE BEGIN 3 */ + MainLoop(); + HAL_Delay(100); } + /* USER CODE END 3 */ } /** @@ -131,12 +156,12 @@ void SystemClock_Config(void) LL_FLASH_SetLatency(LL_FLASH_LATENCY_4); while (LL_FLASH_GetLatency() != LL_FLASH_LATENCY_4) {} LL_PWR_EnableRange1BoostMode(); - LL_RCC_HSE_Enable(); - /* Wait till HSE is ready */ - while (LL_RCC_HSE_IsReady() != 1) {} + LL_RCC_HSI_Enable(); + /* Wait till HSI is ready */ + while (LL_RCC_HSI_IsReady() != 1) {} - LL_RCC_HSE_EnableCSS(); - LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSE, LL_RCC_PLLM_DIV_1, 20, LL_RCC_PLLR_DIV_2); + LL_RCC_HSI_SetCalibTrimming(64); + LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSI, LL_RCC_PLLM_DIV_1, 20, LL_RCC_PLLR_DIV_2); LL_RCC_PLL_EnableDomain_SYS(); LL_RCC_PLL_Enable(); /* Wait till PLL is ready */ @@ -165,6 +190,17 @@ void SystemClock_Config(void) /* USER CODE BEGIN 4 */ +/** + * @brief Route the CubeMX-generated CAN service timer callback to the CAN runtime. + * + * CAN_TIMER_HANDLE is generated by can_cfg.h from CAN_TIMER_INDEX. + */ +void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) +{ + UNUSED(htim); + CubeCAN_Tick(); +} + /* USER CODE END 4 */ /** @@ -174,8 +210,7 @@ void SystemClock_Config(void) void Error_Handler(void) { /* USER CODE BEGIN Error_Handler_Debug */ - /* User can add his own implementation to report the HAL error return - * state */ + /* User can add his own implementation to report the HAL error return state */ __disable_irq(); while (1) {} /* USER CODE END Error_Handler_Debug */ @@ -191,9 +226,7 @@ void Error_Handler(void) void assert_failed(uint8_t *file, uint32_t line) { /* USER CODE BEGIN 6 */ - /* User can add his own implementation to report the file name and line - number, ex: printf("Wrong parameters value: file %s on line %d\r\n", - file, line) */ + LOGOMATIC_CRITICAL("Assert failed! File %s on line %" PRIu32 "\n", file, line); /* USER CODE END 6 */ } #endif /* USE_FULL_ASSERT */ diff --git a/G4ADCTESTING/Core/Src/stm32g4xx_hal_msp.c b/Testbench/CUBEMXTESTING/Core/Src/stm32g4xx_hal_msp.c similarity index 98% rename from G4ADCTESTING/Core/Src/stm32g4xx_hal_msp.c rename to Testbench/CUBEMXTESTING/Core/Src/stm32g4xx_hal_msp.c index 69189ef4e..4668755ab 100644 --- a/G4ADCTESTING/Core/Src/stm32g4xx_hal_msp.c +++ b/Testbench/CUBEMXTESTING/Core/Src/stm32g4xx_hal_msp.c @@ -7,7 +7,7 @@ ****************************************************************************** * @attention * - * Copyright (c) 2024 STMicroelectronics. + * Copyright (c) 2026 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file @@ -17,7 +17,6 @@ ****************************************************************************** */ /* USER CODE END Header */ - /* Includes ------------------------------------------------------------------*/ #include "main.h" /* USER CODE BEGIN Includes */ diff --git a/G4PERTESTING/Core/Src/stm32g4xx_it.c b/Testbench/CUBEMXTESTING/Core/Src/stm32g4xx_it.c similarity index 80% rename from G4PERTESTING/Core/Src/stm32g4xx_it.c rename to Testbench/CUBEMXTESTING/Core/Src/stm32g4xx_it.c index 2f0cf90a7..77f85d385 100644 --- a/G4PERTESTING/Core/Src/stm32g4xx_it.c +++ b/Testbench/CUBEMXTESTING/Core/Src/stm32g4xx_it.c @@ -6,7 +6,7 @@ ****************************************************************************** * @attention * - * Copyright (c) 2024 STMicroelectronics. + * Copyright (c) 2026 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file @@ -56,7 +56,11 @@ /* USER CODE END 0 */ /* External variables --------------------------------------------------------*/ +extern FDCAN_HandleTypeDef hfdcan1; extern FDCAN_HandleTypeDef hfdcan2; +extern FDCAN_HandleTypeDef hfdcan3; +extern UART_HandleTypeDef hlpuart1; +extern TIM_HandleTypeDef htim5; /* USER CODE BEGIN EV */ /* USER CODE END EV */ @@ -193,6 +197,34 @@ void SysTick_Handler(void) /* please refer to the startup file (startup_stm32g4xx.s). */ /******************************************************************************/ +/** + * @brief This function handles FDCAN1 interrupt 0. + */ +void FDCAN1_IT0_IRQHandler(void) +{ + /* USER CODE BEGIN FDCAN1_IT0_IRQn 0 */ + + /* USER CODE END FDCAN1_IT0_IRQn 0 */ + HAL_FDCAN_IRQHandler(&hfdcan1); + /* USER CODE BEGIN FDCAN1_IT0_IRQn 1 */ + + /* USER CODE END FDCAN1_IT0_IRQn 1 */ +} + +/** + * @brief This function handles TIM5 global interrupt. + */ +void TIM5_IRQHandler(void) +{ + /* USER CODE BEGIN TIM5_IRQn 0 */ + + /* USER CODE END TIM5_IRQn 0 */ + HAL_TIM_IRQHandler(&htim5); + /* USER CODE BEGIN TIM5_IRQn 1 */ + + /* USER CODE END TIM5_IRQn 1 */ +} + /** * @brief This function handles FDCAN2 interrupt 0. */ @@ -207,6 +239,34 @@ void FDCAN2_IT0_IRQHandler(void) /* USER CODE END FDCAN2_IT0_IRQn 1 */ } +/** + * @brief This function handles FDCAN3 interrupt 0. + */ +void FDCAN3_IT0_IRQHandler(void) +{ + /* USER CODE BEGIN FDCAN3_IT0_IRQn 0 */ + + /* USER CODE END FDCAN3_IT0_IRQn 0 */ + HAL_FDCAN_IRQHandler(&hfdcan3); + /* USER CODE BEGIN FDCAN3_IT0_IRQn 1 */ + + /* USER CODE END FDCAN3_IT0_IRQn 1 */ +} + +/** + * @brief This function handles LPUART1 global interrupt. + */ +void LPUART1_IRQHandler(void) +{ + /* USER CODE BEGIN LPUART1_IRQn 0 */ + + /* USER CODE END LPUART1_IRQn 0 */ + HAL_UART_IRQHandler(&hlpuart1); + /* USER CODE BEGIN LPUART1_IRQn 1 */ + + /* USER CODE END LPUART1_IRQn 1 */ +} + /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ diff --git a/Testbench/CUBEMXTESTING/Core/Src/tim.c b/Testbench/CUBEMXTESTING/Core/Src/tim.c new file mode 100644 index 000000000..1f6110e86 --- /dev/null +++ b/Testbench/CUBEMXTESTING/Core/Src/tim.c @@ -0,0 +1,105 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file tim.c + * @brief This file provides code for the configuration + * of the TIM instances. + ****************************************************************************** + * @attention + * + * Copyright (c) 2026 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 "tim.h" + +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +TIM_HandleTypeDef htim5; + +/* TIM5 init function */ +void MX_TIM5_Init(void) +{ + + /* USER CODE BEGIN TIM5_Init 0 */ + + /* USER CODE END TIM5_Init 0 */ + + TIM_ClockConfigTypeDef sClockSourceConfig = {0}; + TIM_MasterConfigTypeDef sMasterConfig = {0}; + + /* USER CODE BEGIN TIM5_Init 1 */ + + /* USER CODE END TIM5_Init 1 */ + htim5.Instance = TIM5; + htim5.Init.Prescaler = 159; + htim5.Init.CounterMode = TIM_COUNTERMODE_UP; + htim5.Init.Period = 499; + htim5.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; + htim5.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; + if (HAL_TIM_Base_Init(&htim5) != HAL_OK) { + Error_Handler(); + } + sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL; + if (HAL_TIM_ConfigClockSource(&htim5, &sClockSourceConfig) != HAL_OK) { + Error_Handler(); + } + sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; + sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; + if (HAL_TIMEx_MasterConfigSynchronization(&htim5, &sMasterConfig) != HAL_OK) { + Error_Handler(); + } + /* USER CODE BEGIN TIM5_Init 2 */ + HAL_TIM_Base_Start_IT(&htim5); + /* USER CODE END TIM5_Init 2 */ +} + +void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *tim_baseHandle) +{ + + if (tim_baseHandle->Instance == TIM5) { + /* USER CODE BEGIN TIM5_MspInit 0 */ + + /* USER CODE END TIM5_MspInit 0 */ + /* TIM5 clock enable */ + __HAL_RCC_TIM5_CLK_ENABLE(); + + /* TIM5 interrupt Init */ + HAL_NVIC_SetPriority(TIM5_IRQn, 0, 0); + HAL_NVIC_EnableIRQ(TIM5_IRQn); + /* USER CODE BEGIN TIM5_MspInit 1 */ + + /* USER CODE END TIM5_MspInit 1 */ + } +} + +void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *tim_baseHandle) +{ + + if (tim_baseHandle->Instance == TIM5) { + /* USER CODE BEGIN TIM5_MspDeInit 0 */ + + /* USER CODE END TIM5_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_TIM5_CLK_DISABLE(); + + /* TIM5 interrupt Deinit */ + HAL_NVIC_DisableIRQ(TIM5_IRQn); + /* USER CODE BEGIN TIM5_MspDeInit 1 */ + + /* USER CODE END TIM5_MspDeInit 1 */ + } +} + +/* USER CODE BEGIN 1 */ + +/* USER CODE END 1 */ diff --git a/Testbench/CUBEMXTESTING/Core/Src/usart.c b/Testbench/CUBEMXTESTING/Core/Src/usart.c new file mode 100644 index 000000000..a14deb76c --- /dev/null +++ b/Testbench/CUBEMXTESTING/Core/Src/usart.c @@ -0,0 +1,128 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file usart.c + * @brief This file provides code for the configuration + * of the USART instances. + ****************************************************************************** + * @attention + * + * Copyright (c) 2026 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 "usart.h" + +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +UART_HandleTypeDef hlpuart1; + +/* LPUART1 init function */ + +void MX_LPUART1_UART_Init(void) +{ + + /* USER CODE BEGIN LPUART1_Init 0 */ + + /* USER CODE END LPUART1_Init 0 */ + + /* USER CODE BEGIN LPUART1_Init 1 */ + + /* USER CODE END LPUART1_Init 1 */ + hlpuart1.Instance = LPUART1; + hlpuart1.Init.BaudRate = 115200; + hlpuart1.Init.WordLength = UART_WORDLENGTH_8B; + hlpuart1.Init.StopBits = UART_STOPBITS_1; + hlpuart1.Init.Parity = UART_PARITY_NONE; + hlpuart1.Init.Mode = UART_MODE_TX_RX; + hlpuart1.Init.HwFlowCtl = UART_HWCONTROL_NONE; + hlpuart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE; + hlpuart1.Init.ClockPrescaler = UART_PRESCALER_DIV1; + hlpuart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT; + if (HAL_UART_Init(&hlpuart1) != HAL_OK) { + Error_Handler(); + } + if (HAL_UARTEx_SetTxFifoThreshold(&hlpuart1, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK) { + Error_Handler(); + } + if (HAL_UARTEx_SetRxFifoThreshold(&hlpuart1, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK) { + Error_Handler(); + } + if (HAL_UARTEx_DisableFifoMode(&hlpuart1) != HAL_OK) { + Error_Handler(); + } + /* USER CODE BEGIN LPUART1_Init 2 */ + + /* USER CODE END LPUART1_Init 2 */ +} + +void HAL_UART_MspInit(UART_HandleTypeDef *uartHandle) +{ + + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if (uartHandle->Instance == LPUART1) { + /* USER CODE BEGIN LPUART1_MspInit 0 */ + + /* USER CODE END LPUART1_MspInit 0 */ + LL_RCC_SetLPUARTClockSource(LL_RCC_LPUART1_CLKSOURCE_PCLK1); + + /* LPUART1 clock enable */ + __HAL_RCC_LPUART1_CLK_ENABLE(); + + __HAL_RCC_GPIOA_CLK_ENABLE(); + /**LPUART1 GPIO Configuration + PA2 ------> LPUART1_TX + PA3 ------> LPUART1_RX + */ + GPIO_InitStruct.Pin = GPIO_PIN_2 | GPIO_PIN_3; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF12_LPUART1; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /* LPUART1 interrupt Init */ + HAL_NVIC_SetPriority(LPUART1_IRQn, 0, 0); + HAL_NVIC_EnableIRQ(LPUART1_IRQn); + /* USER CODE BEGIN LPUART1_MspInit 1 */ + + /* USER CODE END LPUART1_MspInit 1 */ + } +} + +void HAL_UART_MspDeInit(UART_HandleTypeDef *uartHandle) +{ + + if (uartHandle->Instance == LPUART1) { + /* USER CODE BEGIN LPUART1_MspDeInit 0 */ + + /* USER CODE END LPUART1_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_LPUART1_CLK_DISABLE(); + + /**LPUART1 GPIO Configuration + PA2 ------> LPUART1_TX + PA3 ------> LPUART1_RX + */ + HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2 | GPIO_PIN_3); + + /* LPUART1 interrupt Deinit */ + HAL_NVIC_DisableIRQ(LPUART1_IRQn); + /* USER CODE BEGIN LPUART1_MspDeInit 1 */ + + /* USER CODE END LPUART1_MspDeInit 1 */ + } +} + +/* USER CODE BEGIN 1 */ + +/* USER CODE END 1 */ diff --git a/G4NEOTESTING/CMakeLists.txt b/Testbench/G4NEOTESTING/CMakeLists.txt similarity index 90% rename from G4NEOTESTING/CMakeLists.txt rename to Testbench/G4NEOTESTING/CMakeLists.txt index 21af9929e..e01d41704 100644 --- a/G4NEOTESTING/CMakeLists.txt +++ b/Testbench/G4NEOTESTING/CMakeLists.txt @@ -34,6 +34,11 @@ target_sources( Core/Src/stm32g4xx_it.c ) -target_link_libraries(${PROJECT_NAME}_USER_CODE INTERFACE GR_NEOPIXEL) +target_link_libraries( + ${PROJECT_NAME}_USER_CODE + INTERFACE + GR_NEOPIXEL + LOGOMATIC_OLD_LIB +) target_include_directories(${PROJECT_NAME}_USER_CODE INTERFACE Core/Inc) diff --git a/G4NEOTESTING/Core/Inc/main.h b/Testbench/G4NEOTESTING/Core/Inc/main.h similarity index 100% rename from G4NEOTESTING/Core/Inc/main.h rename to Testbench/G4NEOTESTING/Core/Inc/main.h diff --git a/G431x8_CAN_TESTING/Core/Inc/stm32g4xx_hal_conf.h b/Testbench/G4NEOTESTING/Core/Inc/stm32g4xx_hal_conf.h similarity index 100% rename from G431x8_CAN_TESTING/Core/Inc/stm32g4xx_hal_conf.h rename to Testbench/G4NEOTESTING/Core/Inc/stm32g4xx_hal_conf.h diff --git a/G431x8_CAN_TESTING/Core/Inc/stm32g4xx_it.h b/Testbench/G4NEOTESTING/Core/Inc/stm32g4xx_it.h similarity index 100% rename from G431x8_CAN_TESTING/Core/Inc/stm32g4xx_it.h rename to Testbench/G4NEOTESTING/Core/Inc/stm32g4xx_it.h diff --git a/G4NEOTESTING/Core/Src/main.c b/Testbench/G4NEOTESTING/Core/Src/main.c similarity index 100% rename from G4NEOTESTING/Core/Src/main.c rename to Testbench/G4NEOTESTING/Core/Src/main.c diff --git a/G431x8_CAN_TESTING/Core/Src/stm32g4xx_hal_msp.c b/Testbench/G4NEOTESTING/Core/Src/stm32g4xx_hal_msp.c similarity index 100% rename from G431x8_CAN_TESTING/Core/Src/stm32g4xx_hal_msp.c rename to Testbench/G4NEOTESTING/Core/Src/stm32g4xx_hal_msp.c diff --git a/G4NEOTESTING/Core/Src/stm32g4xx_it.c b/Testbench/G4NEOTESTING/Core/Src/stm32g4xx_it.c similarity index 100% rename from G4NEOTESTING/Core/Src/stm32g4xx_it.c rename to Testbench/G4NEOTESTING/Core/Src/stm32g4xx_it.c diff --git a/G4NEOTESTING/README.md b/Testbench/G4NEOTESTING/README.md similarity index 100% rename from G4NEOTESTING/README.md rename to Testbench/G4NEOTESTING/README.md