diff --git a/.vscode/launch.json b/.vscode/launch.json index d27bedbdb5..1d27421504 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -11,22 +11,7 @@ ], "console": "integratedTerminal" }, - { - "name": "Debug JSON CAN (module)", - "type": "python", - "request": "launch", - "module": "scripts.code_generation.jsoncan.generate_can_from_json", - "args": [ - "--board", - "VC", - "--can_data_dir", - "${workspaceFolder}/can_bus/quintuna", - "--output_dir", - "temp", - "--dbc_output", - ], - "console": "integratedTerminal" - }, + // ========== HEXRAY CHIMERA ========== { "name": "Debug Chimera: VC (Hexray)", "cwd": "${workspaceRoot}", @@ -273,6 +258,7 @@ ] } }, + // ========== HEXRAY BOARDS ========== { "name": "Debug Embedded: CRIT (Hexray)", "cwd": "${workspaceRoot}", @@ -316,15 +302,10 @@ } }, { - "name": "Debug Embedded: VC (Hexray)", + "name": "Debug Embedded: PCM (Hexray)", "cwd": "${workspaceRoot}", - "executable": "build_fw_dev/firmware/hexray/VC/hexray_VC.hex", - "symbolFiles": [ - // This order matters, or RTT won't work! (app has to be last) - "build_fw_dev/firmware/hexray/VC/hexray_VC_boot.elf", - "build_fw_dev/firmware/hexray/VC/hexray_VC_app.elf" - ], - "preLaunchTask": "Build Embedded: VC (Hexray)", + "executable": "build_fw_dev/firmware/hexray/PCM/hexray_PCM_app.elf", + "preLaunchTask": "Build Embedded: PCM (Hexray)", // cortex configurations "request": "launch", "type": "cortex-debug", @@ -342,7 +323,7 @@ "-speed", "4000" ], - "device": "STM32H733VG", + "device": "STM32F412RG", "interface": "swd", "showDevDebugOutput": "none", "rttConfig": { @@ -350,7 +331,7 @@ "address": "auto", "decoders": [ { - "label": "Debug logs: VC", + "label": "Debug logs: PCM", "port": 0, "type": "console" } @@ -358,16 +339,15 @@ } }, { - - "name": "Debug Embedded: BMS (Hexray)", + "name": "Debug Embedded: VC (Hexray)", "cwd": "${workspaceRoot}", - "executable": "build_fw_dev/firmware/hexray/BMS/hexray_BMS.hex", + "executable": "build_fw_dev/firmware/hexray/VC/hexray_VC.hex", "symbolFiles": [ // This order matters, or RTT won't work! (app has to be last) - "build_fw_dev/firmware/hexray/BMS/hexray_BMS_boot.elf", - "build_fw_dev/firmware/hexray/BMS/hexray_BMS_app.elf" + "build_fw_dev/firmware/hexray/VC/hexray_VC_boot.elf", + "build_fw_dev/firmware/hexray/VC/hexray_VC_app.elf" ], - "preLaunchTask": "Build Embedded: BMS (Hexray)", + "preLaunchTask": "Build Embedded: VC (Hexray)", // cortex configurations "request": "launch", "type": "cortex-debug", @@ -393,7 +373,7 @@ "address": "auto", "decoders": [ { - "label": "Debug logs: BMS", + "label": "Debug logs: VC", "port": 0, "type": "console" } @@ -401,15 +381,16 @@ } }, { - "name": "Debug Embedded: FSM (Hexray)", + + "name": "Debug Embedded: BMS (Hexray)", "cwd": "${workspaceRoot}", - "executable": "build_fw_dev/firmware/hexray/FSM/hexray_FSM.hex", + "executable": "build_fw_dev/firmware/hexray/BMS/hexray_BMS.hex", "symbolFiles": [ // This order matters, or RTT won't work! (app has to be last) - "build_fw_dev/firmware/hexray/FSM/hexray_FSM_boot.elf", - "build_fw_dev/firmware/hexray/FSM/hexray_FSM_app.elf" + "build_fw_dev/firmware/hexray/BMS/hexray_BMS_boot.elf", + "build_fw_dev/firmware/hexray/BMS/hexray_BMS_app.elf" ], - "preLaunchTask": "Build Embedded: FSM (Hexray)", + "preLaunchTask": "Build Embedded: BMS (Hexray)", // cortex configurations "request": "launch", "type": "cortex-debug", @@ -427,7 +408,7 @@ "-speed", "4000" ], - "device": "STM32H562RI", + "device": "STM32H733VG", "interface": "swd", "showDevDebugOutput": "none", "rttConfig": { @@ -435,7 +416,7 @@ "address": "auto", "decoders": [ { - "label": "Debug logs: FSM", + "label": "Debug logs: BMS", "port": 0, "type": "console" } @@ -443,15 +424,15 @@ } }, { - "name": "Debug Embedded: DAM (Hexray)", + "name": "Debug Embedded: FSM (Hexray)", "cwd": "${workspaceRoot}", - "executable": "build_fw_dev/firmware/hexray/DAM/hexray_DAM.hex", + "executable": "build_fw_dev/firmware/hexray/FSM/hexray_FSM.hex", "symbolFiles": [ // This order matters, or RTT won't work! (app has to be last) - "build_fw_dev/firmware/hexray/DAM/hexray_DAM_boot.elf", - "build_fw_dev/firmware/hexray/DAM/hexray_DAM_app.elf" + "build_fw_dev/firmware/hexray/FSM/hexray_FSM_boot.elf", + "build_fw_dev/firmware/hexray/FSM/hexray_FSM_app.elf" ], - "preLaunchTask": "Build Embedded: DAM (Hexray)", + "preLaunchTask": "Build Embedded: FSM (Hexray)", // cortex configurations "request": "launch", "type": "cortex-debug", @@ -477,7 +458,7 @@ "address": "auto", "decoders": [ { - "label": "Debug logs: DAM", + "label": "Debug logs: FSM", "port": 0, "type": "console" } @@ -485,15 +466,15 @@ } }, { - "name": "Debug Embedded: RSM (Hexray)", + "name": "Debug Embedded: DAM (Hexray)", "cwd": "${workspaceRoot}", - "executable": "build_fw_dev/firmware/hexray/RSM/hexray_RSM.hex", + "executable": "build_fw_dev/firmware/hexray/DAM/hexray_DAM.hex", "symbolFiles": [ // This order matters, or RTT won't work! (app has to be last) - "build_fw_dev/firmware/hexray/RSM/hexray_RSM_boot.elf", - "build_fw_dev/firmware/hexray/RSM/hexray_RSM_app.elf" + "build_fw_dev/firmware/hexray/DAM/hexray_DAM_boot.elf", + "build_fw_dev/firmware/hexray/DAM/hexray_DAM_app.elf" ], - "preLaunchTask": "Build Embedded: RSM (Hexray)", + "preLaunchTask": "Build Embedded: DAM (Hexray)", // cortex configurations "request": "launch", "type": "cortex-debug", @@ -514,90 +495,6 @@ "device": "STM32H562RI", "interface": "swd", "showDevDebugOutput": "none", - "rttConfig": { - "enabled": true, - "address": "auto", - "decoders": [ - { - "label": "Debug logs: RSM", - "port": 0, - "type": "console" - } - ] - } - }, - { - "name": "Debug Embedded: VC (Quintuna)", - "cwd": "${workspaceRoot}", - "executable": "build_fw_dev/firmware/quintuna/VC/quintuna_VC.hex", - "symbolFiles": [ - // This order matters, or RTT won't work! (app has to be last) - "build_fw_dev/firmware/quintuna/VC/quintuna_VC_boot.elf", - "build_fw_dev/firmware/quintuna/VC/quintuna_VC_app.elf" - ], - "preLaunchTask": "Build Embedded: VC (Quintuna)", - // cortex configurations - "request": "launch", - "type": "cortex-debug", - "servertype": "jlink", - "linux": { - "serverpath": "JLinkGDBServerCLExe" - }, - "osx": { - "serverpath": "JLinkGDBServer" - }, - "windows": { - "serverpath": "JLinkGDBServerCL" - }, - "serverArgs": [ - "-speed", - "4000" - ], - "device": "STM32H733VG", - "interface": "swd", - "showDevDebugOutput": "none", - "rttConfig": { - "enabled": true, - "address": "auto", - "decoders": [ - { - "label": "Debug logs: VC", - "port": 0, - "type": "console" - } - ] - } - }, - { - "name": "Debug Embedded: DAM (Quintuna)", - "cwd": "${workspaceRoot}", - "executable": "build_fw_dev/firmware/quintuna/DAM/quintuna_DAM.hex", - "symbolFiles": [ - // This order matters, or RTT won't work! (app has to be last) - "build_fw_dev/firmware/quintuna/DAM/quintuna_DAM_boot.elf", - "build_fw_dev/firmware/quintuna/DAM/quintuna_DAM_app.elf", - ], - "preLaunchTask": "Build Embedded: DAM (Quintuna)", - // cortex configurations - "request": "launch", - "type": "cortex-debug", - "servertype": "jlink", - "linux": { - "serverpath": "JLinkGDBServerCLExe" - }, - "osx": { - "serverpath": "JLinkGDBServer" - }, - "windows": { - "serverpath": "JLinkGDBServerCL" - }, - "serverArgs": [ - "-speed", - "4000" - ], - "device": "STM32H733VG", - "interface": "swd", - "showDevDebugOutput": "none", "rttConfig": { "enabled": true, "address": "auto", @@ -611,57 +508,15 @@ } }, { - "name": "Debug Embedded: FSM (Quintuna)", - "cwd": "${workspaceRoot}", - "executable": "build_fw_dev/firmware/quintuna/FSM/quintuna_FSM.hex", - "symbolFiles": [ - // This order matters, or RTT won't work! (app has to be last) - "build_fw_dev/firmware/quintuna/FSM/quintuna_FSM_boot.elf", - "build_fw_dev/firmware/quintuna/FSM/quintuna_FSM_app.elf" - ], - "preLaunchTask": "Build Embedded: FSM (Quintuna)", - // cortex configurations - "request": "launch", - "type": "cortex-debug", - "servertype": "jlink", - "linux": { - "serverpath": "JLinkGDBServerCLExe" - }, - "osx": { - "serverpath": "JLinkGDBServer" - }, - "windows": { - "serverpath": "JLinkGDBServerCL" - }, - "serverArgs": [ - "-speed", - "4000" - ], - "device": "STM32F412RG", - "interface": "swd", - "showDevDebugOutput": "none", - "rttConfig": { - "enabled": true, - "address": "auto", - "decoders": [ - { - "label": "Debug logs: FSM", - "port": 0, - "type": "console" - } - ] - } - }, - { - "name": "Debug Embedded: RSM (Quintuna)", + "name": "Debug Embedded: RSM (Hexray)", "cwd": "${workspaceRoot}", - "executable": "build_fw_dev/firmware/quintuna/RSM/quintuna_RSM.hex", + "executable": "build_fw_dev/firmware/hexray/RSM/hexray_RSM.hex", "symbolFiles": [ // This order matters, or RTT won't work! (app has to be last) - "build_fw_dev/firmware/quintuna/RSM/quintuna_RSM_boot.elf", - "build_fw_dev/firmware/quintuna/RSM/quintuna_RSM_app.elf" + "build_fw_dev/firmware/hexray/RSM/hexray_RSM_boot.elf", + "build_fw_dev/firmware/hexray/RSM/hexray_RSM_app.elf" ], - "preLaunchTask": "Build Embedded: RSM (Quintuna)", + "preLaunchTask": "Build Embedded: RSM (Hexray)", // cortex configurations "request": "launch", "type": "cortex-debug", @@ -679,7 +534,7 @@ "-speed", "4000" ], - "device": "STM32F412RG", + "device": "STM32H562RI", "interface": "swd", "showDevDebugOutput": "none", "rttConfig": { @@ -694,210 +549,7 @@ ] } }, - { - "name": "Debug Embedded: CRIT (Quintuna)", - "cwd": "${workspaceRoot}", - // binary config - "executable": "build_fw_dev/firmware/quintuna/CRIT/quintuna_CRIT.hex", - "symbolFiles": [ - // This order matters, or RTT won't work! (app has to be last) - "build_fw_dev/firmware/quintuna/CRIT/quintuna_CRIT_boot.elf", - "build_fw_dev/firmware/quintuna/CRIT/quintuna_CRIT_app.elf" - ], - "preLaunchTask": "Build Embedded: CRIT (Quintuna)", - // cortex configurations - "request": "launch", - "type": "cortex-debug", - "servertype": "jlink", - "linux": { - "serverpath": "JLinkGDBServerCLExe" - }, - "osx": { - "serverpath": "JLinkGDBServer" - }, - "windows": { - "serverpath": "JLinkGDBServerCL" - }, - "serverArgs": [ - "-speed", - "4000" - ], - "device": "STM32F412RG", - "interface": "swd", - "showDevDebugOutput": "none", - "rttConfig": { - "enabled": true, - "address": "auto", - "decoders": [ - { - "label": "Debug logs: CRIT", - "port": 0, - "type": "console" - } - ] - } - }, - { - "name": "Debug Embedded: BMS (Quintuna)", - "cwd": "${workspaceRoot}", - "executable": "build_fw_dev/firmware/quintuna/BMS/quintuna_BMS.hex", - "symbolFiles": [ - // This order matters, or RTT won't work! (app has to be last) - "build_fw_dev/firmware/quintuna/BMS/quintuna_BMS_boot.elf", - "build_fw_dev/firmware/quintuna/BMS/quintuna_BMS_app.elf" - ], - "preLaunchTask": "Build Embedded: BMS (Quintuna)", - // cortex configurations - "request": "launch", - "type": "cortex-debug", - "servertype": "jlink", - "linux": { - "serverpath": "JLinkGDBServerCLExe" - }, - "osx": { - "serverpath": "JLinkGDBServer" - }, - "windows": { - "serverpath": "JLinkGDBServerCL" - }, - "serverArgs": [ - "-speed", - "4000" - ], - "device": "STM32H733VG", - "interface": "swd", - "showDevDebugOutput": "none", - "rttConfig": { - "enabled": true, - "address": "auto", - "decoders": [ - { - "label": "Debug logs: BMS", - "port": 0, - "type": "console" - } - ] - } - }, - { - "name": "Debug Embedded: VCR (Quintuna)", - "cwd": "${workspaceRoot}", - "executable": "build_fw_dev/firmware/quintuna/VCR/quintuna_VCR_app.elf", - "symbolFiles": [ - // This order matters, or RTT won't work! (app has to be last) - "build_fw_dev/firmware/quintuna/VCR/quintuna_VCR_app.elf" - ], - "preLaunchTask": "Build Embedded: VCR (Quintuna)", - // cortex configurations - "request": "launch", - "type": "cortex-debug", - "servertype": "jlink", - "linux": { - "serverpath": "JLinkGDBServerCLExe" - }, - "osx": { - "serverpath": "JLinkGDBServer" - }, - "windows": { - "serverpath": "JLinkGDBServerCL" - }, - "serverArgs": [ - "-speed", - "4000" - ], - "device": "STM32H733VG", - "interface": "swd", - "showDevDebugOutput": "none", - "rttConfig": { - "enabled": true, - "address": "auto", - "decoders": [ - { - "label": "Debug logs: VCR", - "port": 0, - "type": "console" - } - ] - } - }, - { - "name": "Debug Embedded: PCM (Quintuna)", - "cwd": "${workspaceRoot}", - "executable": "build_fw_dev/firmware/quintuna/PCM/quintuna_PCM_app.elf", - "preLaunchTask": "Build Embedded: PCM (Quintuna)", - // cortex configurations - "request": "launch", - "type": "cortex-debug", - "servertype": "jlink", - "linux": { - "serverpath": "JLinkGDBServerCLExe" - }, - "osx": { - "serverpath": "JLinkGDBServer" - }, - "windows": { - "serverpath": "JLinkGDBServerCL" - }, - "serverArgs": [ - "-speed", - "4000" - ], - "device": "STM32F412RG", - "interface": "swd", - "showDevDebugOutput": "none", - "rttConfig": { - "enabled": true, - "address": "auto", - "decoders": [ - { - "label": "Debug logs: VCR", - "port": 0, - "type": "console" - } - ] - } - }, - { - "name": "Debug Embedded: SSM", - "cwd": "${workspaceRoot}", - // binary config - "executable": "build_fw_dev/firmware/dev/SSM/ssm.elf", - "symbolFiles": [ - "build_fw_dev/firmware/dev/SSM/ssm.elf" - ], - "preLaunchTask": "Build Embedded: SSM", - // cortex configurations - "request": "launch", - "type": "cortex-debug", - "servertype": "jlink", - "linux": { - "serverpath": "JLinkGDBServerCLExe" - }, - "osx": { - "serverpath": "JLinkGDBServer" - }, - "windows": { - "serverpath": "JLinkGDBServerCL" - }, - "serverArgs": [ - "-speed", - "4000" - ], - "device": "STM32F412RG", - "interface": "swd", - "showDevDebugOutput": "none", - "rttConfig": { - "enabled": true, - "address": "auto", - "decoders": [ - { - "label": "Debug logs: SSM", - "port": 0, - "type": "console" - } - ] - } - }, + // ========== DEV BOARDS ========== { "name": "Debug Embedded: h7dev", "cwd": "${workspaceRoot}", @@ -981,48 +633,6 @@ } }, // ========== TESTS ========== - { - "name": "Debug Tests: VC (Quintuna)", - "type": "cppdbg", - "request": "launch", - "program": "${workspaceRoot}/build_fw_test/firmware/quintuna/VC/quintuna_VC_test", - "cwd": "${workspaceRoot}", - "preLaunchTask": "Build Tests: VC (Quintuna)", - "linux": { - "MIMode": "gdb" - }, - "osx": { - "MIMode": "lldb" - } - }, - { - "name": "Debug Tests: CRIT (Quintuna)", - "type": "cppdbg", - "request": "launch", - "program": "${workspaceRoot}/build_fw_test/firmware/quintuna/CRIT/quintuna_CRIT_test", - "cwd": "${workspaceRoot}", - "preLaunchTask": "Build Tests: CRIT (Quintuna)", - "linux": { - "MIMode": "gdb" - }, - "osx": { - "MIMode": "lldb" - } - }, - { - "name": "Debug Tests: BMS (Quintuna)", - "type": "cppdbg", - "request": "launch", - "program": "${workspaceRoot}/build_fw_test/firmware/quintuna/BMS/quintuna_BMS_test", - "cwd": "${workspaceRoot}", - // "preLaunchTask": "Build Tests: BMS (Quintuna)", - "linux": { - "MIMode": "gdb" - }, - "osx": { - "MIMode": "lldb" - } - }, { "name": "Debug Tests: BMS (Hexray)", "type": "cppdbg", @@ -1065,20 +675,6 @@ "MIMode": "lldb" } }, - { - "name": "Debug Tests: BMS (Quintuna)", - "type": "cppdbg", - "request": "launch", - "program": "${workspaceRoot}/build_fw_test/firmware/quintuna/BMS/quintuna_BMS_test", - "cwd": "${workspaceRoot}", - "preLaunchTask": "Build Tests: BMS (Quintuna)", - "linux": { - "MIMode": "gdb" - }, - "osx": { - "MIMode": "lldb" - } - }, { "name": "Debug Tests: FSM (Hexray)", "type": "cppdbg", diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 7ba5b7d383..4aa1a77144 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -32,22 +32,6 @@ "command": "configure", "preset": "${command:cmake.activeConfigurePresetName}" }, - { - "label": "Build Embedded Quintuna", - "detail": "CMake Generate step", - "group": "build", - "type": "cmake", - "command": "build", - "targets": [ - "quintuna_BMS.hex", - "quintuna_VC.hex", - "quintuna_CRIT.hex", - "quintuna_RSM.hex", - "quintuna_FSM.hex", - "quintuna_DAM.hex", - "can_bus_load_quintuna" - ] - }, { "label": "Build Embedded Hexray", "detail": "CMake Generate step", @@ -69,88 +53,6 @@ "command": "clean", "preset": "${command:cmake.activeBuildPresetName}" }, - { - "label": "Build Embedded: VCR (Quintuna)", - "group": "build", - "type": "cmake", - "command": "build", - "targets": [ - "quintuna_VCR_app.elf", - ] - }, - { - "label": "Build Embedded: BMS (Quintuna)", - "group": "build", - "type": "cmake", - "command": "build", - "targets": [ - "quintuna_BMS.hex", - ] - }, - { - "label": "Run Tests: BMS (Quintuna)", - "type": "shell", - "command": "${workspaceFolder}/build_fw_test/firmware/quintuna/BMS/quintuna_BMS_test", - "group": "test", - "presentation": { - "reveal": "always" - }, - "problemMatcher": [] - }, - { - "label": "Build Embedded: VC (Quintuna)", - "group": "build", - "type": "cmake", - "command": "build", - "targets": [ - "quintuna_VC.hex", - ] - }, - { - "label": "Build Embedded: CRIT (Quintuna)", - "group": "build", - "type": "cmake", - "command": "build", - "targets": [ - "quintuna_CRIT.hex", - ] - }, - { - "label": "Build Embedded: DAM (Quintuna)", - "group": "build", - "type": "cmake", - "command": "build", - "targets": [ - "quintuna_DAM.hex", - ] - }, - { - "label": "Build Embedded: RSM (Quintuna)", - "group": "build", - "type": "cmake", - "command": "build", - "targets": [ - "quintuna_RSM.hex", - ] - }, - { - "label": "Build Embedded: FSM (Quintuna)", - "group": "build", - "type": "cmake", - "command": "build", - "targets": [ - "quintuna_FSM.hex", - ] - }, - { - "label": "Build Embedded: PCM (Quintuna)", - "group": "build", - "type": "cmake", - "command": "build", - "targets": [ - "quintuna_PCM_app.elf", - ] - }, { "label": "Build Embedded: h7dev", "group": "build", @@ -178,33 +80,6 @@ "ssm.hex" ] }, - { - "label": "Build Tests: CRIT (Quintuna)", - "group": "build", - "type": "cmake", - "command": "build", - "targets": [ - "quintuna_CRIT_test" - ] - }, - { - "label": "Build Tests: VC (Quintuna)", - "group": "build", - "type": "cmake", - "command": "build", - "targets": [ - "quintuna_VC_test" - ] - }, - { - "label": "Build Tests: BMS (Quintuna)", - "group": "build", - "type": "cmake", - "command": "build", - "targets": [ - "quintuna_BMS_test" - ] - }, { "label": "Build Embedded: BMS (Hexray)", "group": "build", @@ -313,6 +188,15 @@ "hexray_FSM_chimera.elf" ] }, + { + "label": "Build Embedded: PCM (Hexray)", + "group": "build", + "type": "cmake", + "command": "build", + "targets": [ + "hexray_PCM_app.elf", + ] + }, { "label": "Build Embedded: RSM (Hexray)", "group": "build", @@ -386,15 +270,6 @@ "jsoncan_test" ] }, - { - "label": "CAN Bus Load: Quintuna", - "group": "build", - "type": "cmake", - "command": "build", - "targets": [ - "can_bus_load_quintuna" - ] - }, { "label": "Run Telem Backend", "type": "shell", diff --git a/firmware/hexray/PCM/src/cubemx/Inc/main.h b/firmware/hexray/PCM/src/cubemx/Inc/main.h index eb80b05572..dee46475fd 100644 --- a/firmware/hexray/PCM/src/cubemx/Inc/main.h +++ b/firmware/hexray/PCM/src/cubemx/Inc/main.h @@ -70,6 +70,7 @@ extern "C" #define SWO_GPIO_Port GPIOB #define PCM_EN_Pin GPIO_PIN_5 #define PCM_EN_GPIO_Port GPIOB +#define PCM_EN_EXTI_IRQn EXTI9_5_IRQn #define VICOR_SMBUS_SCL_Pin GPIO_PIN_6 #define VICOR_SMBUS_SCL_GPIO_Port GPIOB #define VICOR_SMBUS_SDA_Pin GPIO_PIN_7 diff --git a/firmware/hexray/PCM/src/cubemx/Inc/stm32f4xx_it.h b/firmware/hexray/PCM/src/cubemx/Inc/stm32f4xx_it.h index a53790154b..b1474f0e1f 100644 --- a/firmware/hexray/PCM/src/cubemx/Inc/stm32f4xx_it.h +++ b/firmware/hexray/PCM/src/cubemx/Inc/stm32f4xx_it.h @@ -54,6 +54,7 @@ extern "C" void UsageFault_Handler(void); void DebugMon_Handler(void); void SysTick_Handler(void); + void EXTI9_5_IRQHandler(void); void I2C1_EV_IRQHandler(void); void I2C1_ER_IRQHandler(void); /* USER CODE BEGIN EFP */ diff --git a/firmware/hexray/PCM/src/cubemx/PCM.ioc b/firmware/hexray/PCM/src/cubemx/PCM.ioc index 2fa5e7f038..1bad0fe90b 100644 --- a/firmware/hexray/PCM/src/cubemx/PCM.ioc +++ b/firmware/hexray/PCM/src/cubemx/PCM.ioc @@ -24,14 +24,14 @@ Mcu.Pin6=PB6 Mcu.Pin7=PB7 Mcu.Pin8=VP_SYS_VS_Systick Mcu.PinsNb=9 -Mcu.ThirdParty0=STMicroelectronics.X-CUBE-SMBUS.2.1.0 -Mcu.ThirdPartyNb=1 +Mcu.ThirdPartyNb=0 Mcu.UserConstants= Mcu.UserName=STM32F412RGTx 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.EXTI9_5_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true NVIC.ForceEnableDMAVector=true NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false NVIC.I2C1_ER_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true @@ -62,10 +62,12 @@ PB3.GPIO_Label=SWO PB3.Locked=true PB3.Mode=Trace_Asynchronous_SW PB3.Signal=SYS_JTDO-SWO -PB5.GPIOParameters=GPIO_Label +PB5.GPIOParameters=GPIO_Label,GPIO_ITMode,GPIO_ModeDefaultEXTI +PB5.GPIO_ITMode=Interrupt_Rising_Falling_Edge PB5.GPIO_Label=PCM_EN +PB5.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING PB5.Locked=true -PB5.Signal=GPIO_Input +PB5.Signal=GPXTI5 PB6.GPIOParameters=GPIO_Label PB6.GPIO_Label=VICOR_SMBUS_SCL PB6.Locked=true @@ -144,11 +146,8 @@ RCC.VCOI2SInputFreq_Value=1000000 RCC.VCOI2SOutputFreq_Value=192000000 RCC.VCOInputFreq_Value=1000000 RCC.VCOOutputFreq_Value=192000000 -STMicroelectronics.X-CUBE-SMBUS.2.1.0.ApplicationJjApplication_Checked=false -STMicroelectronics.X-CUBE-SMBUS.2.1.0.IPParameters=SMB_master -STMicroelectronics.X-CUBE-SMBUS.2.1.0.SMB_master=1 -STMicroelectronics.X-CUBE-SMBUS.2.1.0.SMbusJjSMBusIiPMBusIiStack_Checked=false -STMicroelectronics.X-CUBE-SMBUS.2.1.0_SwParameter=ApplicationCcApplicationJjApplication\:true;SMBusIiPMBusIiStackCcSMbusJjSMBus\:true; +SH.GPXTI5.0=GPIO_EXTI5 +SH.GPXTI5.ConfNb=1 VP_SYS_VS_Systick.Mode=SysTick VP_SYS_VS_Systick.Signal=SYS_VS_Systick board=custom diff --git a/firmware/hexray/PCM/src/cubemx/PCM.ioc.md5 b/firmware/hexray/PCM/src/cubemx/PCM.ioc.md5 index 5beeee5469..941f77b567 100644 --- a/firmware/hexray/PCM/src/cubemx/PCM.ioc.md5 +++ b/firmware/hexray/PCM/src/cubemx/PCM.ioc.md5 @@ -1 +1 @@ -9075300837875b8e54de77a35ad094c7 \ No newline at end of file +6c152407cb5a0d57cb1ccdd44010ea4c \ No newline at end of file diff --git a/firmware/hexray/PCM/src/cubemx/Src/main.c b/firmware/hexray/PCM/src/cubemx/Src/main.c index c5dde76221..ff3086cd96 100644 --- a/firmware/hexray/PCM/src/cubemx/Src/main.c +++ b/firmware/hexray/PCM/src/cubemx/Src/main.c @@ -220,10 +220,14 @@ static void MX_GPIO_Init(void) /*Configure GPIO pin : PCM_EN_Pin */ GPIO_InitStruct.Pin = PCM_EN_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(PCM_EN_GPIO_Port, &GPIO_InitStruct); + /* EXTI interrupt init*/ + HAL_NVIC_SetPriority(EXTI9_5_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(EXTI9_5_IRQn); + /* USER CODE BEGIN MX_GPIO_Init_2 */ /* USER CODE END MX_GPIO_Init_2 */ diff --git a/firmware/hexray/PCM/src/cubemx/Src/stm32f4xx_it.c b/firmware/hexray/PCM/src/cubemx/Src/stm32f4xx_it.c index ba0962d09f..c4667989b8 100644 --- a/firmware/hexray/PCM/src/cubemx/Src/stm32f4xx_it.c +++ b/firmware/hexray/PCM/src/cubemx/Src/stm32f4xx_it.c @@ -173,6 +173,20 @@ void SysTick_Handler(void) /* please refer to the startup file (startup_stm32f4xx.s). */ /******************************************************************************/ +/** + * @brief This function handles EXTI line[9:5] interrupts. + */ +void EXTI9_5_IRQHandler(void) +{ + /* USER CODE BEGIN EXTI9_5_IRQn 0 */ + + /* USER CODE END EXTI9_5_IRQn 0 */ + HAL_GPIO_EXTI_IRQHandler(PCM_EN_Pin); + /* USER CODE BEGIN EXTI9_5_IRQn 1 */ + + /* USER CODE END EXTI9_5_IRQn 1 */ +} + /** * @brief This function handles I2C1 event interrupt. */ diff --git a/firmware/hexray/PCM/src/tasks.cpp b/firmware/hexray/PCM/src/tasks.cpp index 0812155fc0..40559d9579 100644 --- a/firmware/hexray/PCM/src/tasks.cpp +++ b/firmware/hexray/PCM/src/tasks.cpp @@ -33,12 +33,21 @@ static const hw::gpio pcm_en_in{ PCM_EN_GPIO_Port, PCM_EN_Pin }; static const hw::gpio lv_buck_en_out{ LV_BUCK_EN_GPIO_Port, LV_BUCK_EN_Pin }; static const hw::gpio led_out{ LED_GPIO_Port, LED_Pin }; -static auto state = PcmState::OFF; +static auto state = PcmState::OFF; +static volatile bool pcm_en_state = false; #ifdef PCM_DEBUG static char debug_buf[1024]; #endif +void HAL_GPIO_EXTI_Callback(const uint16_t GPIO_Pin) +{ + if (GPIO_Pin == pcm_en_in.getPin()) + { + pcm_en_state = pcm_en_in.readPin(); + } +} + [[noreturn]] static void tasks_tick(void *arg) { forever @@ -143,7 +152,7 @@ static char debug_buf[1024]; { case PcmState::OFF: { - if (pcm_en_in.readPin()) + if (pcm_en_state) { LOG_INFO("trying to clear faults and turn on"); if (vicor::clearFaults().has_value() and vicor::operation(true).has_value()) @@ -161,7 +170,7 @@ static char debug_buf[1024]; } case PcmState::VICOR_ONLY: { - if (not pcm_en_in.readPin() and vicor::operation(false).has_value()) + if (not pcm_en_state and vicor::operation(false).has_value()) { LOG_INFO("Going to OFF state"); state = PcmState::OFF; @@ -181,7 +190,7 @@ static char debug_buf[1024]; } case PcmState::ON: // everything on { - if (not pcm_en_in.readPin()) + if (not pcm_en_state) { lv_buck_en_out.writePin(false);