18 Commits
Author SHA1 Message Date
raduetandCursor b98207da4c Add SET_LIGHTING (0xB1) and AC22-style init LED shimmer.
Mutable status palette over serial; Unknown uses HSV saturation pulse instead of dim-red/fade-to-black.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-30 17:12:09 +02:00
raduetandCursor 940e3f4a3d Add charging-phase PSU sudden-off diagnostics (v1.0.28).
Observability only: log can_lost/output_lost and status flags during Charging, without changing PSU recovery behavior.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-12 01:03:13 +02:00
raduetandCursor fdc83c5b9f Clean repo hygiene: drop junk, normalize docs layout.
Remove chat/testplan/zip/scratch docs; move PDFs/scripts/board-rev ioc; standardize README + docs/.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-11 23:53:49 +02:00
raduetandCursor 52d4685673 Standardize .gitignore and untrack build/IDE artifacts; keep firmware images only.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-11 23:40:12 +02:00
raduetandCursor af8bbd5275 Expose charging session elapsed time in monitoring packet (v1.0.27).
CONN.ChargingTime ticks at 1 Hz during Charging; serial GET_STATUS reports elapsed min/sec instead of zero stubs.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-08 11:29:01 +02:00
raduetandCursor 96826da0e0 Add PSU diagnostic logging for setpoints and state transitions (v1.0.26).
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-06 09:19:36 +02:00
raduetandCursor 49a4fd8ee1 Replace hv_mode gate with CS60 hv_limit logic for unrestricted HV setpoints (v1.0.25).
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-30 19:27:47 +02:00
raduet 86b0bfc0fc Remove FAKE_500V Everest workaround; use real setpoints on the bus (v1.0.24). 2026-06-30 18:30:07 +02:00
raduetandCursor a583e12132 Add PSU fast discharge API for DC precharge step-down (v1.0.23).
Policy/executor hooks, event-driven OFF/ON state machine, and release binaries.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-30 16:28:25 +02:00
raduetandCursor ecf8e3d2f0 Build artifacts updated.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 12:43:15 +02:00
achamaikin 622644a6a1 added WS2812 support 2026-06-12 12:17:57 +03:00
achamaikin ac1ce30121 Add fire alarm support and update firmware version to 1.0.19
- Introduced CONN_ERR_FIRE_ALARM to handle fire alarm conditions in charger control.
- Added CMD_FIRE_ALARM command for external trigger handling in serial control.
- Updated firmware version from 1.0.17 to 1.0.19.
- Integrated fire alarm functionality into the charging loop and command handler.
2026-06-11 15:33:22 +03:00
achamaikin 3037ae2368 board rev2 support, added heater support 2026-06-04 10:35:01 +03:00
achamaikin 414d2cba60 clean project 2026-05-09 14:02:54 +03:00
achamaikinandCursor c8f91af7da cleanup project
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-09 13:20:17 +03:00
achamaikinandCursor e8b3ed90cd Overwrite repository contents with fork state.
Replace outdated files with the latest working tree from fork/CCSModuleSW30Web to align source and generated artifacts.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-09 13:16:13 +03:00
achamaikin 28d63c7270 latest version before merge 2026-05-05 12:25:11 +03:00
achamaikin c59d150b23 Update firmware version to 1.0.10, add hv_tick parameter to PSU control, enhance serial control with response handling, and improve stop button control logic. 2026-04-13 20:01:44 +03:00
137 changed files with 11257 additions and 71487 deletions
Vendored
BIN
View File
Binary file not shown.
Executable
+187
View File
@@ -0,0 +1,187 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.1370229639">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.1370229639" moduleId="org.eclipse.cdt.core.settings" name="Debug">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="elf" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="rm -rf" description="" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.1370229639" name="Debug" parent="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug">
<folderInfo id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.1370229639." name="/" resourcePath="">
<toolChain id="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.debug.1017099221" name="MCU ARM GCC" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.debug">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu.1244048691" name="MCU" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu" useByScannerDiscovery="true" value="STM32F107VCTx" valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_cpuid.1379215735" name="CPU" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_cpuid" useByScannerDiscovery="false" value="0" valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid.960532971" name="Core" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid" useByScannerDiscovery="false" value="0" valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.1990552137" name="Board" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board" useByScannerDiscovery="false" value="genericBoard" valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.1586976077" name="Defaults" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults" useByScannerDiscovery="false" value="com.st.stm32cube.ide.common.services.build.inputs.revA.1.0.6 || Debug || true || Executable || com.st.stm32cube.ide.mcu.gnu.managedbuild.option.toolchain.value.workspace || STM32F107VCTx || 0 || 0 || arm-none-eabi- || ${gnu_tools_for_stm32_compiler_path} || ../Core/Inc | ../Drivers/STM32F1xx_HAL_Driver/Inc | ../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy | ../Drivers/CMSIS/Device/ST/STM32F1xx/Include | ../Drivers/CMSIS/Include || || || USE_HAL_DRIVER | STM32F107xC || || Drivers | Core/Startup | Core || || || ${workspace_loc:/${ProjName}/STM32F107VCTX_FLASH.ld} || true || NonSecure || || secure_nsclib.o || || None || || || " valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.debug.option.cpuclock.82282192" name="Cpu clock frequence" superClass="com.st.stm32cube.ide.mcu.debug.option.cpuclock" useByScannerDiscovery="false" value="72" valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.nanoprintffloat.808472221" name="Use float with printf from newlib-nano (-u _printf_float)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.nanoprintffloat" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.converthex.400501462" name="Convert to Intel Hex file (-O ihex)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.converthex" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.convertsrec.519949918" name="Convert to Motorola S-record file (-O srec)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.convertsrec" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.convertbinary.1730912092" name="Convert to binary file (-O binary)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.convertbinary" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform.1026339783" isAbstract="false" osList="all" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform"/>
<builder buildPath="${workspace_loc:/GbTModuleSW}/Debug" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder.653659782" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.1272315080" name="MCU GCC Assembler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.370357426" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.value.g3" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.definedsymbols.1924718806" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.definedsymbols" valueType="definedSymbols">
<listOptionValue builtIn="false" value="DEBUG"/>
</option>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.includepaths.340226531" name="Include paths (-I)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.includepaths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="/Users/colorbass/STM32CubeIDE/workspace_1.12.0/lib_EDCAN"/>
</option>
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input.602034741" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input"/>
</tool>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.129443933" name="MCU GCC Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.150601486" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.value.g3" valueType="enumerated"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.2041244846" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.value.o0" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols.504560065" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols" useByScannerDiscovery="false" valueType="definedSymbols">
<listOptionValue builtIn="false" value="DEBUG"/>
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
<listOptionValue builtIn="false" value="STM32F107xC"/>
</option>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths.452593111" name="Include paths (-I)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="../Core/Inc"/>
<listOptionValue builtIn="false" value="../Drivers/STM32F1xx_HAL_Driver/Inc"/>
<listOptionValue builtIn="false" value="../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy"/>
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Device/ST/STM32F1xx/Include"/>
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Include"/>
</option>
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.1408123272" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c"/>
</tool>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.2070441151" name="MCU G++ Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.debuglevel.1543951018" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.debuglevel" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.debuglevel.value.g3" valueType="enumerated"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.optimization.level.2049580629" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.optimization.level" useByScannerDiscovery="false"/>
</tool>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.2102490823" name="MCU GCC Linker" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.script.272103658" name="Linker Script (-T)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.script" value="${workspace_loc:/${ProjName}/STM32F107VCTX_FLASH.ld}" valueType="string"/>
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.input.266162782" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
</tool>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.502005820" name="MCU G++ Linker" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.archiver.1392625179" name="MCU GCC Archiver" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.archiver"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.size.771001125" name="MCU Size" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.size"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objdump.listfile.1682381984" name="MCU Output Converter list file" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objdump.listfile"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.hex.467663480" name="MCU Output Converter Hex" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.hex"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.binary.1608796910" name="MCU Output Converter Binary" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.binary"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.verilog.1767624081" name="MCU Output Converter Verilog" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.verilog"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.srec.139156618" name="MCU Output Converter Motorola S-rec" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.srec"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.symbolsrec.1422585447" name="MCU Output Converter Motorola S-rec with symbols" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.symbolsrec"/>
</toolChain>
</folderInfo>
<sourceEntries>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Core"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Drivers"/>
</sourceEntries>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
<cconfiguration id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.1286135127">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.1286135127" moduleId="org.eclipse.cdt.core.settings" name="Release">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="elf" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" cleanCommand="rm -rf" description="" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.1286135127" name="Release" parent="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release">
<folderInfo id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.1286135127." name="/" resourcePath="">
<toolChain id="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.release.368317543" name="MCU ARM GCC" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.release">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu.1083778044" name="MCU" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu" useByScannerDiscovery="true" value="STM32F107VCTx" valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_cpuid.1672048738" name="CPU" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_cpuid" useByScannerDiscovery="false" value="0" valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid.716214807" name="Core" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid" useByScannerDiscovery="false" value="0" valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.1611406059" name="Board" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board" useByScannerDiscovery="false" value="genericBoard" valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.2026840843" name="Defaults" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults" useByScannerDiscovery="false" value="com.st.stm32cube.ide.common.services.build.inputs.revA.1.0.6 || Release || false || Executable || com.st.stm32cube.ide.mcu.gnu.managedbuild.option.toolchain.value.workspace || STM32F107VCTx || 0 || 0 || arm-none-eabi- || ${gnu_tools_for_stm32_compiler_path} || ../Core/Inc | ../Drivers/STM32F1xx_HAL_Driver/Inc | ../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy | ../Drivers/CMSIS/Device/ST/STM32F1xx/Include | ../Drivers/CMSIS/Include || || || USE_HAL_DRIVER | STM32F107xC || || Drivers | Core/Startup | Core || || || ${workspace_loc:/${ProjName}/STM32F107VCTX_FLASH.ld} || true || NonSecure || || secure_nsclib.o || || None || || || " valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.debug.option.cpuclock.1744697906" name="Cpu clock frequence" superClass="com.st.stm32cube.ide.mcu.debug.option.cpuclock" useByScannerDiscovery="false" value="72" valueType="string"/>
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform.1433680358" isAbstract="false" osList="all" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform"/>
<builder buildPath="${workspace_loc:/GbTModuleSW}/Release" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder.1316679712" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.1810954687" name="MCU GCC Assembler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.1184417617" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.value.g0" valueType="enumerated"/>
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input.679037772" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input"/>
</tool>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.2023937975" name="MCU GCC Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.2061465690" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.value.g0" valueType="enumerated"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.463973701" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.value.os" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols.1124370999" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols" useByScannerDiscovery="false" valueType="definedSymbols">
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
<listOptionValue builtIn="false" value="STM32F107xC"/>
</option>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths.2130633236" name="Include paths (-I)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="../Core/Inc"/>
<listOptionValue builtIn="false" value="../Drivers/STM32F1xx_HAL_Driver/Inc"/>
<listOptionValue builtIn="false" value="../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy"/>
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Device/ST/STM32F1xx/Include"/>
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Include"/>
</option>
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.139233432" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c"/>
</tool>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.77997183" name="MCU G++ Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.debuglevel.954735929" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.debuglevel" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.debuglevel.value.g0" valueType="enumerated"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.optimization.level.1509118949" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.optimization.level" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.optimization.level.value.os" valueType="enumerated"/>
</tool>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.455795129" name="MCU GCC Linker" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.script.135018481" name="Linker Script (-T)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.script" value="${workspace_loc:/${ProjName}/STM32F107VCTX_FLASH.ld}" valueType="string"/>
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.input.850565080" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
</tool>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.1304115760" name="MCU G++ Linker" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.archiver.2125898682" name="MCU GCC Archiver" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.archiver"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.size.862607409" name="MCU Size" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.size"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objdump.listfile.268643843" name="MCU Output Converter list file" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objdump.listfile"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.hex.2012318786" name="MCU Output Converter Hex" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.hex"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.binary.25627582" name="MCU Output Converter Binary" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.binary"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.verilog.1856490045" name="MCU Output Converter Verilog" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.verilog"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.srec.573281510" name="MCU Output Converter Motorola S-rec" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.srec"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.symbolsrec.336799426" name="MCU Output Converter Motorola S-rec with symbols" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.symbolsrec"/>
</toolChain>
</folderInfo>
<sourceEntries>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Core"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Drivers"/>
</sourceEntries>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.pathentry"/>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="GbTModuleSW.null.359723610" name="GbTModuleSW"/>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<scannerConfigBuildInfo instanceId="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.1286135127;com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.1286135127.;com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.2023937975;com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.139233432">
<autodiscovery enabled="false" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.1370229639;com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.1370229639.;com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.129443933;com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.1408123272">
<autodiscovery enabled="false" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="refreshScope" versionNumber="2">
<configuration configurationName="Debug">
<resource resourceType="PROJECT" workspacePath="/GbTModuleSW"/>
</configuration>
<configuration configurationName="Release">
<resource resourceType="PROJECT" workspacePath="/GbTModuleSW"/>
</configuration>
</storageModule>
</cproject>
+83 -112
View File
@@ -1,129 +1,100 @@
# ---> C
# Prerequisites
*.d
# =============================================================================
# STM32 / ARM GCC / STM32CubeIDE — standardized firmware .gitignore
# Track: sources + final firmware images (*.elf *.bin *.hex *.srec)
# Ignore: build intermediates, IDE noise, logs, captures, backups
#
# NOTE: Only root /Debug /Release /Build are build dirs.
# Do NOT use **/Debug — on Windows (core.ignorecase) that also matches
# source folders like Libs/**/DEBUG/.
# =============================================================================
# Object files
# -----------------------------------------------------------------------------
# Build dirs (project root only): ignore all, then re-include firmware images
# -----------------------------------------------------------------------------
/Debug/*
!/Debug/
/Release/*
!/Release/
/Build/*
!/Build/
# -----------------------------------------------------------------------------
# Object / dependency / analysis outputs (any path)
# -----------------------------------------------------------------------------
*.o
*.ko
*.obj
*.elf
# Linker output
*.ilk
*.map
*.exp
# Precompiled Headers
*.gch
*.pch
# Libraries
*.lib
*.a
*.la
*.lo
# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib
# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex
# Debug files
*.dSYM/
*.d
*.su
*.idb
*.pdb
*.cyclo
# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf
# ---> CMake
CMakeLists.txt.user
CMakeCache.txt
CMakeFiles
CMakeScripts
Testing
# -----------------------------------------------------------------------------
# Generated make fragments (CubeIDE)
# -----------------------------------------------------------------------------
*.mk
makefile
Makefile
cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
_deps
objects.list
objects.mk
sources.mk
subdir.mk
# ---> Eclipse
.metadata
bin/
tmp/
*.tmp
# -----------------------------------------------------------------------------
# Linker listings (not needed in repo)
# -----------------------------------------------------------------------------
*.map
*.list
# -----------------------------------------------------------------------------
# Backups / temp
# -----------------------------------------------------------------------------
**/Backup/
*.bak
*.tmp
*.swp
*~.nib
local.properties
*.swo
*~
# -----------------------------------------------------------------------------
# IDE / tooling (local machine)
# -----------------------------------------------------------------------------
.settings/
.loadpath
.recommenders
# External tool builders
.mxproject
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
.metadata/
.idea/
*.launch
*.code-workspace
# PyDev specific (Python IDE for Eclipse)
*.pydevproject
# -----------------------------------------------------------------------------
# Logs / analyzer captures
# -----------------------------------------------------------------------------
log.txt
log*.txt
*.log
*.asc
# CDT-specific (C/C++ Development Tooling)
.cproject
# -----------------------------------------------------------------------------
# OS junk
# -----------------------------------------------------------------------------
.DS_Store
Thumbs.db
# CDT- autotools
.autotools
# =============================================================================
# Keep final firmware images under root build dirs
# =============================================================================
!/Debug/*.elf
!/Debug/*.bin
!/Debug/*.hex
!/Debug/*.srec
!/Release/*.elf
!/Release/*.bin
!/Release/*.hex
!/Release/*.srec
!/Build/*.elf
!/Build/*.bin
!/Build/*.hex
!/Build/*.srec
# Java annotation processor (APT)
.factorypath
# PDT-specific (PHP Development Tools)
.buildpath
# sbteclipse plugin
.target
# Tern plugin
.tern-project
# TeXlipse plugin
.texlipse
# STS (Spring Tool Suite)
.springBeans
# Code Recommenders
.recommenders/
# Annotation Processing
.apt_generated/
.apt_generated_test/
# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet
# Uncomment this line if you wish to ignore the project description file.
# Typically, this file would be tracked if it contains build/dependency configurations:
#.project
# IDE local
.vscode/
-41
View File
File diff suppressed because one or more lines are too long
-6
View File
@@ -1,6 +0,0 @@
{
"files.associations": {
"charger_config.h": "c",
"charger_gbt.h": "c"
}
}
+42 -34
View File
@@ -6,7 +6,7 @@ ADC1.Channel-3\#ChannelRegularConversion=ADC_CHANNEL_9
ADC1.Channel-4\#ChannelRegularConversion=ADC_CHANNEL_TEMPSENSOR
ADC1.Channel-5\#ChannelRegularConversion=ADC_CHANNEL_VREFINT
ADC1.ExternalTrigConv=ADC_EXTERNALTRIGCONV_T3_TRGO
ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,NbrOfConversionFlag,master,Rank-1\#ChannelRegularConversion,Channel-1\#ChannelRegularConversion,SamplingTime-1\#ChannelRegularConversion,Rank-2\#ChannelRegularConversion,Channel-2\#ChannelRegularConversion,SamplingTime-2\#ChannelRegularConversion,Rank-3\#ChannelRegularConversion,Channel-3\#ChannelRegularConversion,SamplingTime-3\#ChannelRegularConversion,Rank-4\#ChannelRegularConversion,Channel-4\#ChannelRegularConversion,SamplingTime-4\#ChannelRegularConversion,Rank-5\#ChannelRegularConversion,Channel-5\#ChannelRegularConversion,SamplingTime-5\#ChannelRegularConversion,NbrOfConversion,ExternalTrigConv
ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,NbrOfConversionFlag,Rank-1\#ChannelRegularConversion,Channel-1\#ChannelRegularConversion,SamplingTime-1\#ChannelRegularConversion,Rank-2\#ChannelRegularConversion,Channel-2\#ChannelRegularConversion,SamplingTime-2\#ChannelRegularConversion,Rank-3\#ChannelRegularConversion,Channel-3\#ChannelRegularConversion,SamplingTime-3\#ChannelRegularConversion,Rank-4\#ChannelRegularConversion,Channel-4\#ChannelRegularConversion,SamplingTime-4\#ChannelRegularConversion,Rank-5\#ChannelRegularConversion,Channel-5\#ChannelRegularConversion,SamplingTime-5\#ChannelRegularConversion,NbrOfConversion,ExternalTrigConv,master
ADC1.NbrOfConversion=6
ADC1.NbrOfConversionFlag=1
ADC1.Rank-0\#ChannelRegularConversion=1
@@ -143,46 +143,47 @@ Mcu.Pin25=PB11
Mcu.Pin26=PD13
Mcu.Pin27=PD14
Mcu.Pin28=PD15
Mcu.Pin29=PA9
Mcu.Pin29=PC9
Mcu.Pin3=OSC_OUT
Mcu.Pin30=PA10
Mcu.Pin31=PA13
Mcu.Pin32=PA14
Mcu.Pin33=PA15
Mcu.Pin34=PC10
Mcu.Pin35=PC11
Mcu.Pin36=PC12
Mcu.Pin37=PD0
Mcu.Pin38=PD1
Mcu.Pin39=PD2
Mcu.Pin30=PA9
Mcu.Pin31=PA10
Mcu.Pin32=PA13
Mcu.Pin33=PA14
Mcu.Pin34=PA15
Mcu.Pin35=PC10
Mcu.Pin36=PC11
Mcu.Pin37=PC12
Mcu.Pin38=PD0
Mcu.Pin39=PD1
Mcu.Pin4=PC2
Mcu.Pin40=PD3
Mcu.Pin41=PD4
Mcu.Pin42=PD5
Mcu.Pin43=PD6
Mcu.Pin44=PD7
Mcu.Pin45=PB3
Mcu.Pin46=PB4
Mcu.Pin47=PB5
Mcu.Pin48=PB6
Mcu.Pin49=PB7
Mcu.Pin40=PD2
Mcu.Pin41=PD3
Mcu.Pin42=PD4
Mcu.Pin43=PD5
Mcu.Pin44=PD6
Mcu.Pin45=PD7
Mcu.Pin46=PB3
Mcu.Pin47=PB4
Mcu.Pin48=PB5
Mcu.Pin49=PB6
Mcu.Pin5=PC3
Mcu.Pin50=PB8
Mcu.Pin51=PB9
Mcu.Pin52=PE1
Mcu.Pin53=VP_ADC1_TempSens_Input
Mcu.Pin54=VP_ADC1_Vref_Input
Mcu.Pin55=VP_CRC_VS_CRC
Mcu.Pin56=VP_RTC_VS_RTC_Activate
Mcu.Pin57=VP_SYS_VS_Systick
Mcu.Pin58=VP_TIM3_VS_ClockSourceINT
Mcu.Pin59=VP_TIM3_VS_no_output1
Mcu.Pin50=PB7
Mcu.Pin51=PB8
Mcu.Pin52=PB9
Mcu.Pin53=PE1
Mcu.Pin54=VP_ADC1_TempSens_Input
Mcu.Pin55=VP_ADC1_Vref_Input
Mcu.Pin56=VP_CRC_VS_CRC
Mcu.Pin57=VP_RTC_VS_RTC_Activate
Mcu.Pin58=VP_SYS_VS_Systick
Mcu.Pin59=VP_TIM3_VS_ClockSourceINT
Mcu.Pin6=PA1
Mcu.Pin60=VP_TIM4_VS_ClockSourceINT
Mcu.Pin60=VP_TIM3_VS_no_output1
Mcu.Pin61=VP_TIM4_VS_ClockSourceINT
Mcu.Pin7=PA2
Mcu.Pin8=PA3
Mcu.Pin9=PA4
Mcu.PinsNb=61
Mcu.PinsNb=62
Mcu.ThirdPartyNb=0
Mcu.UserConstants=
Mcu.UserName=STM32F107VCTx
@@ -306,6 +307,8 @@ PC10.Signal=USART3_TX
PC11.Locked=true
PC11.Mode=Asynchronous
PC11.Signal=USART3_RX
PC12.GPIOParameters=GPIO_Label
PC12.GPIO_Label=HEATER
PC12.Mode=Asynchronous
PC12.Signal=UART5_TX
PC14-OSC32_IN.Mode=LSE-External-Oscillator
@@ -329,6 +332,11 @@ PC5.GPIOParameters=GPIO_Label
PC5.GPIO_Label=LOCK_B
PC5.Locked=true
PC5.Signal=GPIO_Output
PC9.GPIOParameters=GPIO_Speed,GPIO_Label
PC9.GPIO_Label=LED_DATA
PC9.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
PC9.Locked=true
PC9.Signal=GPIO_Output
PD0.Locked=true
PD0.Mode=CAN_Activate
PD0.Signal=CAN1_RX
-133
View File
@@ -1,133 +0,0 @@
# Журнал изменений (сессия чата): `fork/CCSModuleSW30Web`
Документ фиксирует доработки проекта **CCSModuleSW30Web** в ветке/каталоге форка
`/Users/colorbass/STM32CubeIDE/workspace_1.12.0/fork/CCSModuleSW30Web`, обсуждавшиеся и вносившиеся в рамках описанной сессии (UART, ADC/DMA, CP, отладка IRQ, оптимизация `-Ofast` для кода из прерываний).
---
## 1. UART и протокол
### 1.1. UART3 (Everest / `serial.c`)
- Таймаут «нет связи с хостом»:** `EVEREST_TIMEOUT_MS` = **5000** мс.
- Жёсткий реинициал при отсутствии RX:** `UART3_REINIT_TIMEOUT_MS` = **1500** мс (с защитой от слишком частых реинициалов через `uart3_last_reinit_tick`).
- Расширено логирование путей сброса/ошибок приёма и ошибок HAL для диагностики «таймаут без остановки UART3».
- Колбэки и вспомогательные функции, вызываемые из контекста прерывания, помечены **`ISR_FAST`** (см. раздел 6):
`CCS_RxEventCallback`, `HAL_UART_ErrorCallback`, `uart3_log_hal_error`, `uart3_arm_rx_or_log`, цепочка разбора пакета (`process_received_packet`, `crc16_ibm`, `expected_payload_len`, `apply_command`).
### 1.2. UART2 / `serial_control.c`
- Отдельная логика **`SC_UART2_Watchdog()`**, вызывается из **`SC_Task()`** (не из IRQ).
- Константы:
- **`SC_UART2_REINIT_TIMEOUT_MS`** = **500** мс — порог для жёсткого реинициала при отсутствии пакетов;
- **`SC_UART2_PACKET_TIMEOUT_MS`** = **5000** мс — таймаут коммуникации.
- Сценарий **новый пакет при `BUSY_TX`**: при необходимости **`Abort_IT`**, сброс направления RS-485, затем повторная инициализация UART и приём `ReceiveToIdle_IT` (защита от обрыва TX из-за агрессивного watchdog).
- Отдельная ветка **жёсткого реинициала при `BUSY_TX`** с логом `USART2 BUSY_TX: hard reinit` (отслеживание `sc_uart2_last_busy_tx_reinit_packet_tick`).
- HAL-колбэки **`HAL_UARTEx_RxEventCallback`**, **`HAL_UART_TxCpltCallback`** помечены **`ISR_FAST`**.
### 1.3. `SC_SendPacket` и стек CRC/кодирования
- Для единообразной оптимизации пути «IRQ → ответ» на функции **`calculate_crc32`**, **`encode_packet`**, **`parse_packet`**, **`process_received_packet`** и публичную **`SC_SendPacket`** добавлен **`ISR_FAST`**.
- В **`Core/Inc/serial_control.h`**: подключение **`isr_opt.h`**, прототип **`ISR_FAST void SC_SendPacket(...)`** (согласованность с определением в `.c`).
**Замечание:** `SC_SendPacket` вызывается и из основного потока; для GCC вся функция компилируется с `-Ofast`. При необходимости строгого разделения можно вынести отдельную версию «только из IRQ».
---
## 2. Отладочные линии DBG в `stm32f1xx_it.c`
На время входа/выхода из выбранных обработчиков прерываний поднимается/опускается соответствующий GPIO — удобно для осциллографа (длительность IRQ).
| Линия | Обработчик |
|--------|------------|
| **DBG1** | `UART5_IRQHandler` |
| **DBG2** | `USART2_IRQHandler` |
| **DBG3** | `USART3_IRQHandler` |
| **DBG4** | `DMA1_Channel1_IRQHandler`, `ADC1_2_IRQHandler`, `TIM3_IRQHandler` |
| **DBG5** | `CAN1_RX0_IRQHandler`, `CAN2_TX_IRQHandler`, `CAN2_RX1_IRQHandler` |
| — | `USART1_IRQHandler` — без обёртки DBG (по согласованию) |
В **`DMA1_Channel1_IRQHandler`** вызывается **`HAL_DMA_IRQHandler(&hdma_adc1)`** для цепочки ADC+DMA.
Для всего файла **`stm32f1xx_it.c`** под GCC добавлено:
```c
#pragma GCC optimize("Ofast")
```
(в блоке `USER CODE BEGIN Includes`).
---
## 3. ADC: DMA, глобальные данные, колбэк
- Файлы **`adc.c` / `adc.h`**: структура **`ADC_ScanData_t`**, глобально **`volatile ADC_ScanData_t adc_data`** с полями сырых каналов (`in3_raw`, `cp_raw`, `ntc1_raw`, `ntc2_raw`, `temp_sensor_raw`, `vrefint_raw` и т.д. по фактическому объявлению в заголовке).
- **`HAL_ADC_ConvCpltCallback`**: копирование из буфера DMA в **`adc_data`**, помечен **`ISR_FAST`**.
- Публичная **`ADC_ScanStart()`** — запуск сканирования (после калибровки вызывается из инициализации платы).
- **`board.c`**: после **`HAL_ADCEx_Calibration_Start`** вызывается **`ADC_ScanStart()`**; **`CONN_ReadTemp`** читает **`adc_data.ntc1_raw` / `ntc2_raw`** вместо блокирующего опроса ADC.
**Диагностика (из обсуждения):** если не вызываются **`HAL_ADC_ConvCpltCallback`** / **`HAL_DMA_IRQHandler`**, проверять: срабатывание триггера ADC (например, **TIM3 TRGO**), работу TIM3, порядок инициализации DMA/NVIC, срабатывание **`DMA1_Channel1_IRQHandler`**.
---
## 4. CP (`cp.c` / `cp.h`)
- Измерение опоры на **`adc_data.cp_raw`** (и при необходимости **`vrefint_raw`** по текущей реализации в коде).
- Логика классификации/порогов приведена к варианту, согласованному с основным **CCSModuleSW30Web** (не форк).
- Сэмпл по таймеру: уход от тяжёлой работы в IRQ OC — использование **`HAL_TIM_OC_Start`** без прерывания по сравнению, обновление напряжения в **`CP_GetVoltage()`** / основном цикле (**`CP_Loop`** опирается на **`CP_GetState()`** и т.п. по фактическому коду).
---
## 5. Отладочный UART (`debug.c`)
При **`#ifndef USE_WEB_INTERFACE`** (или эквивалентной ветке сборки в файле): колбэк **`HAL_UARTEx_RxEventCallback`** и **`debug_rx_interrupt`** помечены **`ISR_FAST`**.
---
## 6. Оптимизация `-Ofast` для кода из прерываний
### 6.1. Макрос `ISR_FAST`
Файл **`Core/Inc/isr_opt.h`**:
- **GCC:** `#define ISR_FAST __attribute__((optimize("Ofast")))`
- **Иное:** пустой макрос.
### 6.2. Где используется (по состоянию репозитория)
| Файл | Элементы с `ISR_FAST` / pragma |
|------|--------------------------------|
| `stm32f1xx_it.c` | `#pragma GCC optimize("Ofast")` на весь файл (GCC) |
| `adc.c` | `HAL_ADC_ConvCpltCallback` |
| `serial.c` | `CCS_RxEventCallback`, `HAL_UART_ErrorCallback`, `uart3_log_hal_error`, `uart3_arm_rx_or_log`, `process_received_packet`, `crc16_ibm`, `expected_payload_len`, `apply_command` |
| `serial_control.c` | `HAL_UARTEx_RxEventCallback`, `HAL_UART_TxCpltCallback`, `calculate_crc32`, `encode_packet`, `parse_packet`, `process_received_packet`, `SC_SendPacket` |
| `serial_control.h` | прототип `SC_SendPacket` + `#include "isr_opt.h"` |
| `psu_control.c` | `HAL_CAN_RxFifo1MsgPendingCallback` |
| `debug.c` | см. раздел 5 |
---
## 7. Ограничения и переносимость
- **`ISR_FAST`** и pragma в **`stm32f1xx_it.c`** рассчитаны на **GCC** (STM32CubeIDE по умолчанию). Для **IAR / ARM Compiler 6** потребуется отдельная стратегия (прагмы/ключи проекта).
- **`-Ofast`** допускает агрессивные преобразования с плавающей точкой и перестановки, влияющие на строго воспроизводимую арифметику; для критичных вычислений вне IRQ при необходимости ограничивайте область оптимизации.
---
## 8. Затронутые пути (краткий список)
- `Core/Inc/isr_opt.h` — новый/центральный заголовок оптимизации IRQ.
- `Core/Inc/serial_control.h``isr_opt.h`, `ISR_FAST` у `SC_SendPacket`.
- `Core/Src/stm32f1xx_it.c` — DBG, DMA ADC, pragma `Ofast`.
- `Core/Src/adc.c`, `Core/Inc/adc.h` — DMA, `adc_data`, `ADC_ScanStart`, колбэк.
- `Core/Src/board.c` — калибровка, старт скана, температура из `adc_data`.
- `Core/Src/cp.c`, `Core/Inc/cp.h` — CP и ADC.
- `Core/Src/serial.c` — UART3, таймауты, логи, `ISR_FAST`.
- `Core/Src/serial_control.c` — UART2, watchdog, `ISR_FAST`.
- `Core/Src/psu_control.c` — CAN RX callback.
- `Core/Src/debug.c` — отладочный UART под условием сборки.
- `Core/Src/dma.c`, `gpio.c`, `main.h` — по необходимости для DMA1 Ch1 и DBG-пинов.
---
*Документ сгенерирован для фиксации контекста сессии; при дальнейших правках кода имеет смысл обновлять соответствующие разделы вручную.*
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+1 -17
View File
@@ -1,21 +1,5 @@
/* 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__
+3 -13
View File
@@ -1,14 +1,6 @@
/*
* board.h
*
* Created on: Apr 15, 2024
* Author: colorbass
*/
#pragma once
#ifndef SRC_BOARD_H_
#define SRC_BOARD_H_
void GBT_Lock(uint8_t state);
#include <stdint.h>
typedef enum{
RELAY_AUX0 = 0,
@@ -24,6 +16,7 @@ typedef enum{
} relay_t;
void RELAY_Write(relay_t num, uint8_t state);
uint8_t RELAY_Read(relay_t num);
void Init_Peripheral();
uint8_t GBT_LockGetState();
void GBT_Lock(uint8_t state);
@@ -60,6 +53,3 @@ typedef struct __attribute__((packed)) {
} InfoBlock_t;
extern InfoBlock_t *InfoBlock;
#endif /* SRC_BOARD_H_ */
Executable → Regular
+1 -17
View File
@@ -1,21 +1,5 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file can.h
* @brief This file contains all the function prototypes for
* the can.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 __CAN_H__
+22 -3
View File
@@ -5,9 +5,28 @@
#define PSU_MIN_VOLTAGE 150 //1V/bit
#define PSU_MAX_CURRENT 133 //1A/bit
#define PSU_MIN_CURRENT 1 //1A/bit
#define PSU_MAX_POWER 30000 //1W/bit
#define PSU_MAX_POWER 40000 //1W/bit
#define PSU_NUM 1
#define GBT_CH_VER_MAJOR 1
#define GBT_CH_VER_MINOR 0
/* Dynamic LV clamp (CS60 hv_limit): active only on overload at low bus voltage. */
#define PSU_LV_CLAMP_V 499u
#define PSU_HV_LIMIT_ON_THRESHOLD 480u
#define PSU_HV_LIMIT_OFF_THRESHOLD 495u
#define PSU_HV_SWITCH_DELAY_MS 1000u
#define PSU_HV_LOAD_CURRENT 300u /* 30.0 A, MeasuredCurrent is 0.1 A/bit */
#define PSU_HV_LIMIT_MAX_COUNT 3u
/* Fast discharge: PSU off/on cycle on step-down setpoint (unloaded bus). */
#define PSD_ENABLE 1u
#define PSD_MAX_CMD_CURRENT_0P1A 20u /* 2.0 A */
#define PSD_MAX_MEASURED_CURRENT_0P1A 30u /* 3.0 A */
#define PSD_MEASURED_LATCH_MS 500u
#define PSD_MIN_VOLTAGE_STEP_V 50u
#define PSD_DISCHARGE_MARGIN_V 15u
#define PSD_DEBOUNCE_MS 2000u
#define PSD_MAX_PER_SESSION 4u
#define PSD_OFF_TIMEOUT_MS 10000u /* как PSU_WAIT_ACK_OFF */
#define PSD_ON_TIMEOUT_MS 10000u
#define PSD_ON_RETRY_MS 500u /* повтор SET+ON в ON_WAIT */
#define PSD_PRECHARGE_TOLERANCE_V 40u /* ~±10% for 350 V precharge window */
+6 -19
View File
@@ -1,12 +1,4 @@
/*
* charger_control.h
*
* Created on: Jul 29, 2024
* Author: colorbass
*/
#ifndef INC_CHARGER_CONTROL_H_
#define INC_CHARGER_CONTROL_H_
#pragma once
#include "main.h"
@@ -76,6 +68,10 @@ typedef struct{
uint16_t WantedCurrent; //0.1A/bit
CONN_Error_t chargingError; // 0 if okay
uint8_t EvConnected;
uint32_t ChargingTime; // seconds of active charging in current session
uint8_t hv_limit; // Limits PSU voltage to LV range when set
uint32_t hv_tick; // Timer for delayed HV limit switching
uint8_t hv_limit_count; // Anti-chatter counter for LV limit switching
} ChargingConnector_t;
@@ -84,16 +80,7 @@ typedef struct{
extern ChargingConnector_t CONN;
//информация о зарядке
//база данных с хранением инфы
//главный блок хранит в себе инфу о конфиге возможно во флеше
//либо в charger_config.h
//OCPP - универсальный блок типа
void CONN_Init();
void CONN_Loop();
void CONN_PrintChargingTotal();
#endif /* INC_CHARGER_CONTROL_H_ */
void CONN_GetElapsedForMonitoring(uint16_t *min, uint8_t *sec);
+1 -12
View File
@@ -1,12 +1,4 @@
/*
* connector.h
*
* Created on: Jul 31, 2024
* Author: colorbass
*/
#ifndef INC_CONNECTOR_H_
#define INC_CONNECTOR_H_
#pragma once
#include "main.h"
#include "charger_control.h"
@@ -15,7 +7,4 @@
extern CONN_State_t connectorState;
void CONN_Init();
void CONN_Task();
void CONN_SetState(CONN_State_t state);
#endif /* INC_CONNECTOR_H_ */
+1 -4
View File
@@ -1,5 +1,4 @@
#ifndef __CP_H
#define __CP_H
#pragma once
#include "main.h"
#include <stdint.h>
@@ -27,5 +26,3 @@ CP_State_t CP_GetFilteredState(void);
void CP_FilterState(void);
void CP_Loop(void);
#endif
+1 -17
View File
@@ -1,21 +1,5 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file crc.h
* @brief This file contains all the function prototypes for
* the crc.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 __CRC_H__
+1 -11
View File
@@ -1,12 +1,4 @@
/*
* debug.h
*
* Created on: Apr 16, 2024
* Author: colorbass
*/
#ifndef SRC_DEBUG_H_
#define SRC_DEBUG_H_
#pragma once
#include <stdint.h>
#include <stdarg.h>
@@ -30,5 +22,3 @@ void debug_buffer_send(void);
// Кастомный printf с приоритетом лога
int log_printf(LogLevel_t level, const char *format, ...);
#endif /* SRC_DEBUG_H_ */
+1 -17
View File
@@ -1,21 +1,5 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file dma.h
* @brief This file contains all the function prototypes for
* the dma.c file
******************************************************************************
* @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 */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __DMA_H__
-2
View File
@@ -4,8 +4,6 @@
#include <stdint.h>
uint8_t FireAlarm_IsLatched(void);
uint8_t FireAlarm_IsBlockingCommand(uint8_t command_code);
void FireAlarm_Activate(void);
void FireAlarm_Maintain(void);
#endif /* INC_FIRE_ALARM_H_ */
Executable → Regular
+1 -17
View File
@@ -1,21 +1,5 @@
/* 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__
+1 -4
View File
@@ -1,5 +1,4 @@
#ifndef ISR_OPT_H
#define ISR_OPT_H
#pragma once
/* GCC: быстрые функции, вызываемые из IRQ / из HAL из IRQ-контекста */
#if defined(__GNUC__)
@@ -7,5 +6,3 @@
#else
#define ISR_FAST
#endif
#endif /* ISR_OPT_H */
+8 -18
View File
@@ -1,21 +1,5 @@
/* 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 -------------------------------------*/
@@ -43,7 +27,7 @@ extern "C" {
/* USER CODE BEGIN EC */
#define FW_VERSION_MAJOR 1
#define FW_VERSION_MINOR 0
#define FW_VERSION_PATCH 18
#define FW_VERSION_PATCH 31
/* USER CODE END EC */
/* Exported macro ------------------------------------------------------------*/
@@ -55,6 +39,8 @@ extern "C" {
void Error_Handler(void);
/* USER CODE BEGIN EFP */
uint8_t ED_TraceWarning(uint8_t flag, uint8_t id);
void ED_Delay(uint32_t Delay);
/* USER CODE END EFP */
@@ -101,8 +87,12 @@ void Error_Handler(void);
#define DBG5_GPIO_Port GPIOB
#define DBG4_Pin GPIO_PIN_11
#define DBG4_GPIO_Port GPIOB
#define LED_DATA_Pin GPIO_PIN_9
#define LED_DATA_GPIO_Port GPIOC
#define RELAY_CC_Pin GPIO_PIN_15
#define RELAY_CC_GPIO_Port GPIOA
#define HEATER_Pin GPIO_PIN_12
#define HEATER_GPIO_Port GPIOC
#define RELAY_DC_Pin GPIO_PIN_3
#define RELAY_DC_GPIO_Port GPIOD
#define USART2_DIR_Pin GPIO_PIN_4
+1 -13
View File
@@ -1,25 +1,15 @@
/*
* psu_struct.h
*
* Created on: Jul 24, 2024
* Author: colorbass
*/
#ifndef INC_METER_H_
#define INC_METER_H_
#pragma once
#include "main.h"
#include "charger_config.h"
typedef struct {
uint32_t meterLastTick; // Время последнего пакета Alive
uint8_t online;
uint32_t lastTick; // Время последнего вызова для каждого коннектора
uint64_t EnergyPSU_Ws; // Энергия для каждого коннектора (расчет по силовым модулям)
uint32_t AbsoluteEnergy; // Абсолютная энергия каждого счетчика (ватт*час)
uint32_t EnergyOffset; // смещение энергии по счетчикам (если 0, значит не успели захватить Offset) (ватт*час)
uint32_t EnergyOffset1; // смещение энергии по счетчикам относительно PSU
uint8_t enable; //если 0, то счетчик обнуляется
}METER_t;
@@ -27,5 +17,3 @@ typedef struct {
extern METER_t METER;
void METER_CalculateEnergy();
#endif /* INC_METER_H_ */
+21
View File
@@ -0,0 +1,21 @@
#pragma once
#include <stdint.h>
#include "power_setpoint_policy.h"
typedef enum {
PSD_TRY_IDLE = 0,
PSD_TRY_APPLIED_NORMAL,
PSD_TRY_START_FAST_DISCHARGE,
} PowerSetpointTryResult_t;
void PowerSetpoint_Init(void);
void PowerSetpoint_OnCommand(uint16_t voltage_V, uint16_t current_0p1A);
void PowerSetpoint_UpdateDeliveryLatch(void);
uint8_t PowerSetpoint_HasPending(void);
uint8_t PowerSetpoint_IsBusy(void);
PowerSetpointTryResult_t PowerSetpoint_TryApply(void);
void PowerSetpoint_GetFastDischargeTarget(PowerSetpoint_t *target);
void PowerSetpoint_OnFastDischargeComplete(void);
void PowerSetpoint_OnFastDischargeAbort(void);
+35
View File
@@ -0,0 +1,35 @@
#pragma once
#include <stdint.h>
#include "charger_config.h"
typedef struct {
uint16_t voltage_V;
uint16_t current_0p1A;
} PowerSetpoint_t;
typedef enum {
POWER_SETPOINT_NORMAL,
POWER_SETPOINT_FAST_DISCHARGE,
} PowerSetpointAction_t;
typedef struct {
uint8_t dc_contactor_closed;
uint8_t psu_hv_enabled;
uint16_t measured_voltage_V;
uint16_t measured_current_0p1A;
uint8_t power_delivery_active;
uint8_t enable_output;
uint8_t psu_state_connected;
uint8_t psu_cont_fault;
uint8_t psu_fault;
uint8_t fast_discharge_count;
uint32_t last_fast_discharge_ms;
uint32_t now_ms;
} PowerPathContext_t;
PowerSetpointAction_t PowerSetpoint_Decide(
const PowerSetpoint_t *applied,
const PowerSetpoint_t *next,
const PowerPathContext_t *ctx);
+8 -17
View File
@@ -1,20 +1,12 @@
/*
* ccs_control.h
*
* Created on: 19 авг. 2024 г.
* Author: colorbass
*/
#ifndef INC_PSU_CONTROL_H_
#define INC_PSU_CONTROL_H_
#pragma once
#include "main.h"
#include "charger_config.h"
void PSU_Init();
void PSU_Enable(uint8_t addr, uint8_t enable);
void PSU_Loop();
void CONT_Loop();
void PSU_SetVoltageCurrent(uint8_t addr, uint16_t voltage, uint16_t current);
void PSU_ReadWrite(void);
// --- Состояние силового модуля (DC30, один PSU) ---
@@ -25,6 +17,11 @@ typedef enum{
PSU_WAIT_ACK_ON, // ждём подтверждение включения модуля (напряжение выше порога)
PSU_CONT_WAIT_ACK_ON, // включаем DC-контактор и ждём подтверждение
PSU_CONNECTED, // модуль включён, DC-контактор замкнут
PSU_FAST_DISCHARGE_OFF,
PSU_FAST_DISCHARGE_WAIT, /* ждём подтверждение выключения (как PSU_WAIT_ACK_OFF) */
PSU_FAST_DISCHARGE_SET, /* задать целевое U/I при выключенном модуле */
PSU_FAST_DISCHARGE_ON, /* команда включения после set */
PSU_FAST_DISCHARGE_ON_WAIT, /* ждём подтверждение включения (как PSU_WAIT_ACK_ON) */
PSU_CURRENT_DROP, // снижение тока перед отключением
PSU_WAIT_ACK_OFF, // ждём подтверждение выключения модуля (напряжение ниже порога)
PSU_CONT_WAIT_ACK_OFF, // выключаем DC-контактор и ждём подтверждение
@@ -87,8 +84,6 @@ typedef struct {
// Дополнительные параметры для одного модуля DC30
uint32_t power_limit; // лимит мощности [кВт]
uint8_t hv_mode; // HV-режим (ограничение напряжения)
uint32_t hv_tick; // таймер для задержки входа в HV-режим
uint32_t tempAmbient; // температура окружающего воздуха (из PSU_04)
union { uint8_t raw; PSU_Status0_t bits; } status0; // modularForm0
@@ -191,7 +186,3 @@ extern PSU_1B_t PSU_1B;
extern PSU_1C_t PSU_1C;
#pragma pack(pop)
#endif /* INC_PSU_CONTROL_H_ */
+6 -12
View File
@@ -1,14 +1,7 @@
/*
* rgb_handler.h
*
* Created on: Jul 25, 2024
* Author: colorbass
*/
#ifndef INC_RGB_CONTROLLER_H_
#define INC_RGB_CONTROLLER_H_
#pragma once
#include "main.h"
#include "serial_control.h"
#pragma pack(push, 1)
@@ -48,6 +41,7 @@ typedef struct{
void LED_Task();
void LED_Write();
void LED_Init();
#endif /* INC_RGB_CONTROLLER_H_ */
void LED_SetColor(const RGB_Cycle_t *color);
void RGB_SetColor(RGB_t *color);
void WS2812_SetColor(RGB_t *color);
uint8_t LED_ApplyLightingConfig(const LightingConfigPacket_t *config);
Executable → Regular
+1 -17
View File
@@ -1,21 +1,5 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file rtc.h
* @brief This file contains all the function prototypes for
* the rtc.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 __RTC_H__
+1 -5
View File
@@ -1,5 +1,4 @@
#ifndef __SERIAL_H
#define __SERIAL_H
#pragma once
#include "main.h"
#include "charger_control.h"
@@ -125,6 +124,3 @@ extern CCS_MaxLoad_t CCS_MaxLoad;
extern CCS_EvInfo_t CCS_EvInfo;
extern CONN_State_t CCS_EvseState;
extern uint8_t REPLUG;
#endif
+23 -6
View File
@@ -1,13 +1,10 @@
#ifndef SERIALCONTROL_H
#define SERIALCONTROL_H
#pragma once
#include "main.h"
#include <string.h>
#include "charger_control.h"
#include "isr_opt.h"
#define USE_WEB_INTERFACE
// Команды от ПК к устройству
// Пакет статуса изоляции от отдельного блока по одностороннему UART
#define CMD_ISOLATION_STATUS 0x01
@@ -25,6 +22,7 @@
// Сервисные команды
#define CMD_SET_CONFIG 0xB0
#define CMD_SET_LIGHTING 0xB1
// Перезагрузка для входа в бутлоадер
#define CMD_DEVICE_RESET 0xB5
@@ -150,6 +148,27 @@ typedef struct __attribute__((packed)) {
} ConfigBlock_t;
typedef struct __attribute__((packed)) {
uint8_t r;
uint8_t g;
uint8_t b;
uint8_t brightness;
uint8_t effect;
uint8_t speed;
uint8_t fadeTo;
} LightingRolePacket_t;
typedef struct __attribute__((packed)) {
uint8_t mode;
uint8_t flags;
uint8_t previewSec;
uint8_t reserved;
LightingRolePacket_t roles[5];
} LightingConfigPacket_t;
_Static_assert(sizeof(LightingRolePacket_t) == 7, "Lighting role packet must be 7 bytes");
_Static_assert(sizeof(LightingConfigPacket_t) == 39, "Lighting config packet must be 39 bytes");
// Предварительное объявление структуры протокола
typedef struct SerialControl_t SerialControl_t;
@@ -182,5 +201,3 @@ extern StatusPacket_t statusPacket;
extern InfoPacket_t infoPacket;
extern IsolationStatusPacket_t ISO;
extern volatile SC_Source_t g_sc_command_source;
#endif // SERIALCONTROL_H
+1 -5
View File
@@ -1,5 +1,4 @@
#ifndef SMA_FILTER_H
#define SMA_FILTER_H
#pragma once
#include <stdint.h>
@@ -18,6 +17,3 @@ typedef struct {
void SMAFilter_Init(SMAFilter_t* f);
int32_t SMAFilter_Update(SMAFilter_t* f, int32_t x);
#endif // SMA_FILTER_H
+1 -11
View File
@@ -1,12 +1,4 @@
/*
* soft_rtc.h
*
* Created on: Jul 22, 2024
* Author: colorbass
*/
#ifndef INC_SOFT_RTC_H_
#define INC_SOFT_RTC_H_
#pragma once
#include "main.h"
@@ -15,5 +7,3 @@ void set_Time(uint32_t unix_time);
void unix_to_bcd(uint32_t unix_time, uint8_t *time);
void writeTimeReg(uint8_t reg_number, uint8_t value);
uint8_t getTimeReg(uint8_t reg_number);
#endif /* INC_SOFT_RTC_H_ */
+1 -16
View File
@@ -1,20 +1,5 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file stm32f1xx_hal_conf.h
* @brief HAL configuration file.
******************************************************************************
* @attention
*
* Copyright (c) 2017 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
+1 -16
View File
@@ -1,20 +1,5 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file stm32f1xx_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 -------------------------------------*/
+1 -17
View File
@@ -1,21 +1,5 @@
/* 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__
+1 -17
View File
@@ -1,21 +1,5 @@
/* 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__
BIN
View File
Binary file not shown.
+1 -17
View File
@@ -1,21 +1,5 @@
/* 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"
+25 -18
View File
@@ -1,13 +1,9 @@
#include "main.h"
#include "board.h"
#include "adc.h"
#include "tim.h"
#include "sma_filter.h"
//TODO:
//TEMP READ
// Connector temperature sensors
#include "adc.h"
#include "main.h"
#include "sma_filter.h"
#include "tim.h"
InfoBlock_t *InfoBlock = (InfoBlock_t *)(VERSION_OFFSET);
@@ -74,19 +70,31 @@ uint8_t IN_ReadInput(inputNum_t input_n){
}
}
uint8_t GetBoardTemp(){
//TODO
// HAL_ADC_Start(&hadc1); // start the adc
//
// HAL_ADC_PollForConversion(&hadc1, 100); // poll for conversion
//
// adc_val = HAL_ADC_GetValue(&hadc1); // get the adc value
//
// HAL_ADC_Stop(&hadc1); // stop adc
/* Заглушка: температура платы не измеряется (нет реализации АЦП для канала). */
uint8_t GetBoardTemp(void){
return 0;
}
/**
* @brief Force PC12 (HEATER) as GPIO output via CRH/ODR, overriding UART5 MspInit.
* CubeMX assigns PC12 to UART5_TX; on the board it drives the heater relay.
*/
static void Heater_PinForceOutput(void)
{
const uint32_t pin_cfg = GPIO_SPEED_FREQ_LOW; /* MODE=10, CNF=00: GP output PP, 2 MHz */
__HAL_RCC_GPIOC_CLK_ENABLE();
MODIFY_REG(HEATER_GPIO_Port->CRH,
(GPIO_CRH_MODE12 | GPIO_CRH_CNF12),
(pin_cfg << GPIO_CRH_MODE12_Pos));
HEATER_GPIO_Port->BSRR = (uint32_t)HEATER_Pin << 16U;
}
void Init_Peripheral(){
Heater_PinForceOutput();
HAL_GPIO_WritePin(HEATER_GPIO_Port, HEATER_Pin, GPIO_PIN_RESET);
HAL_ADCEx_Calibration_Start(&hadc1);
ADC_ScanStart();
@@ -138,7 +146,6 @@ int16_t CONN_ReadTemp(uint8_t ch){
return 20; //Термодатчик не подключен
}
// int adc_value = 2048; // Пример значения АЦП
float Vref = 3.3; // Напряжение опорное
float Vin = 5.0; // Входное напряжение
float R = 1000; // Сопротивление резистора в Омах
+1 -17
View File
@@ -1,21 +1,5 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file can.c
* @brief This file provides code for the configuration
* of the CAN 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 "can.h"
+31 -29
View File
@@ -1,57 +1,66 @@
#include "charger_control.h"
#include "charger_config.h"
#include "psu_control.h"
#include "connector.h"
#include "debug.h"
#include "fire_alarm.h"
#include "psu_control.h"
ChargingConnector_t CONN;
CONN_State_t connectorState;
extern uint8_t config_initialized;
void CONN_Init(){
CONN.connControl = CMD_NONE;
CONN.connState = Unknown;
CONN.RequestedVoltage = PSU_MIN_VOLTAGE;
CONN.ChargingTime = 0;
CONN.hv_limit = 0u;
CONN.hv_tick = 0u;
CONN.hv_limit_count = 0u;
}
void CONN_Loop(){
static uint32_t charging_time_tick = 0;
static CONN_State_t last_connState = Unknown;
if (FireAlarm_IsLatched()) {
CONN.chargingError = CONN_ERR_FIRE_ALARM;
CONN.EnableOutput = 0;
return;
}
if(last_connState != CONN.connState){
last_connState = CONN.connState;
CONN.connControl = CMD_NONE;
}
if(PSU0.cont_fault){
if (FireAlarm_IsLatched()) {
CONN.chargingError = CONN_ERR_FIRE_ALARM;
} else if(PSU0.cont_fault){
CONN.chargingError = CONN_ERR_CONTACTOR;
} else if(PSU0.psu_fault){
CONN.chargingError = CONN_ERR_PSU_FAULT;
// } else if(!CTRL.ac_ok) {
// CONN.chargingError = CONN_ERR_AC_FAULT;
// } else
}else if (CONN.EvConnected == 0){
CONN.chargingError = CONN_NO_ERROR;
}
if(ED_TraceWarning(CONN.chargingError, 0)) printf("CONN%d Error: %d\n", 0, CONN.chargingError);
if(ED_TraceWarning(CONN.chargingError, 0)) {
log_printf(LOG_WARN, "CONN0 Error: %d\n", (int)CONN.chargingError);
}
void CONN_Task(){
/* CCS state machine is handled in serial.c.
* Keep this task lightweight for scheduler compatibility.
*/
return;
if (HAL_GetTick() - charging_time_tick >= 1000U) {
charging_time_tick += 1000U;
if (CONN.connState == Charging) {
CONN.ChargingTime++;
}
if (CONN.connState == Unplugged) {
CONN.ChargingTime = 0;
}
}
}
void CONN_GetElapsedForMonitoring(uint16_t *min, uint8_t *sec) {
uint32_t elapsed_sec = CONN.ChargingTime;
if (min != NULL) {
*min = (uint16_t)(elapsed_sec / 60U);
}
if (sec != NULL) {
*sec = (uint8_t)(elapsed_sec % 60U);
}
}
void CONN_SetState(CONN_State_t state){
@@ -79,10 +88,3 @@ void CONN_SetState(CONN_State_t state){
CONN.connState = state;
}
void CONN_PrintChargingTotal(){
printf("CONN%d Charging Finished:\n", 0);
// printf("Charging Time: %d\n", CONN.chargingTime);
printf("Charging Energy: %d\n", CONN.Energy);
// printf("Charging Power: %d\n", CONN.chargingPower);
}
+1
View File
@@ -1,4 +1,5 @@
#include "cp.h"
#include "adc.h"
#include "board.h"
#include "debug.h"
+1 -17
View File
@@ -1,21 +1,5 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file crc.c
* @brief This file provides code for the configuration
* of the CRC 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 "crc.h"
+8 -15
View File
@@ -1,21 +1,14 @@
/*
* debug.c
*
* Created on: Apr 16, 2024
* Author: colorbass
*/
#include "main.h"
#include "board.h"
#include "connector.h"
#include "debug.h"
#include "serial_control.h"
#include "usart.h"
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <stdarg.h>
#include "debug.h"
#include "board.h"
#include "usart.h"
#include <time.h>
#include <connector.h>
#include "serial_control.h"
// Кольцевой буфер для отладочных сообщений
#define DEBUG_BUFFER_SIZE 1024
@@ -112,7 +105,7 @@ void debug_buffer_send(void)
__enable_irq();
}
#define LOG_BUFFER_SIZE 128
#define LOG_BUFFER_SIZE 256
uint8_t log_buffer[LOG_BUFFER_SIZE];
// Кастомный printf с приоритетом лога
+1 -17
View File
@@ -1,21 +1,5 @@
/* 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) 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 ------------------------------------------------------------------*/
+2 -56
View File
@@ -1,74 +1,20 @@
#include "fire_alarm.h"
#include "serial_control.h"
#include "charger_control.h"
#include "connector.h"
#include "serial.h"
#include "cp.h"
#include "debug.h"
#include "serial.h"
static uint8_t fire_alarm_latched = 0;
static uint32_t fire_alarm_last_estop_tick = 0;
extern CCS_ConnectorState_t CCS_ConnectorState;
uint8_t FireAlarm_IsLatched(void) {
return fire_alarm_latched;
}
uint8_t FireAlarm_IsBlockingCommand(uint8_t command_code) {
if (!fire_alarm_latched) {
return 0;
}
switch (command_code) {
case CMD_GET_STATUS:
case CMD_GET_INFO:
case CMD_GET_LOG:
case CMD_DEVICE_RESET:
return 0;
default:
return 1;
}
}
void FireAlarm_Activate(void) {
if (fire_alarm_latched) {
return;
}
fire_alarm_latched = 1;
CONN.chargingError = CONN_ERR_FIRE_ALARM;
CONN.connControl = CMD_STOP;
CONN.EnableOutput = 0;
log_printf(LOG_ERR, "FIRE ALARM activated\n");
CCS_SendEmergencyStop();
fire_alarm_last_estop_tick = HAL_GetTick();
CP_SetDuty(100);
CCS_ConnectorState = CCS_DISABLED;
CONN_SetState(Disabled);
}
void FireAlarm_Maintain(void) {
if (!fire_alarm_latched) {
return;
}
CONN.chargingError = CONN_ERR_FIRE_ALARM;
CONN.EnableOutput = 0;
CP_SetDuty(100);
if ((int32_t)(HAL_GetTick() - fire_alarm_last_estop_tick) >= 1000) {
CCS_SendEmergencyStop();
fire_alarm_last_estop_tick = HAL_GetTick();
}
if (CCS_ConnectorState != CCS_DISABLED && CCS_ConnectorState != CCS_UNKNOWN) {
CCS_ConnectorState = CCS_DISABLED;
}
if (CONN.connState != Disabled) {
CONN_SetState(Disabled);
}
}
+6 -21
View File
@@ -1,21 +1,5 @@
/* 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 ------------------------------------------------------------------*/
@@ -54,7 +38,8 @@ void MX_GPIO_Init(void)
__HAL_RCC_GPIOD_CLK_ENABLE();
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOC, DBG1_Pin|RELAY_CP_Pin|LOCK_A_Pin|LOCK_B_Pin, GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOC, DBG1_Pin|RELAY_CP_Pin|LOCK_A_Pin|LOCK_B_Pin
|LED_DATA_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOA, DBG2_Pin|DBG3_Pin|RELAY_CC_Pin, GPIO_PIN_RESET);
@@ -69,12 +54,12 @@ void MX_GPIO_Init(void)
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOD, RELAY_DC_Pin|USART2_DIR_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin : DBG1_Pin */
GPIO_InitStruct.Pin = DBG1_Pin;
/*Configure GPIO pins : DBG1_Pin LED_DATA_Pin */
GPIO_InitStruct.Pin = DBG1_Pin|LED_DATA_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(DBG1_GPIO_Port, &GPIO_InitStruct);
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
/*Configure GPIO pins : RELAY_CP_Pin LOCK_A_Pin LOCK_B_Pin */
GPIO_InitStruct.Pin = RELAY_CP_Pin|LOCK_A_Pin|LOCK_B_Pin;
+11 -10
View File
@@ -1,4 +1,5 @@
/* USER CODE BEGIN Header */
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
@@ -13,15 +14,17 @@
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "can.h"
#include "board.h"
#include <stdio.h>
#include "debug.h"
#include "soft_rtc.h"
#include "connector.h"
#include "serial_control.h"
#include "charger_config.h"
#include "connector.h"
#include "debug.h"
#include "meter.h"
#include "psu_control.h"
#include "rgb_controller.h"
#include "serial.h"
#include "serial_control.h"
#include "soft_rtc.h"
#include <stdio.h>
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
@@ -53,6 +56,7 @@ void SystemClock_Config(void);
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
static void StopButtonControl(void);
/**
* @brief Vector base address configuration. It should no longer be at the start of
@@ -99,13 +103,12 @@ void ED_Delay(uint32_t Delay)
CCS_SerialLoop();
StopButtonControl();
CP_Loop();
CONN_Task();
LED_Task();
SC_Task();
}
}
void StopButtonControl(){
static void StopButtonControl(void){
static uint32_t tick;
static uint32_t hold_time;
static uint8_t stop_btn_fault = 1;
@@ -146,8 +149,6 @@ void StopButtonControl(){
}
}
uint8_t temp0, temp1;
static void CAN1_MinimalReInit(void)
{
HAL_CAN_Stop(&hcan1);
+1 -9
View File
@@ -1,13 +1,5 @@
/*
* meter.c
*
* Created on: 27 сент. 2024 г.
* Author: root
*/
#include "meter.h"
#include "charger_config.h"
#include "charger_control.h"
+196
View File
@@ -0,0 +1,196 @@
#include "power_setpoint_executor.h"
#include "charger_config.h"
#include "charger_control.h"
#include "debug.h"
#include "psu_control.h"
#include "serial.h"
static PowerSetpoint_t applied;
static PowerSetpoint_t pending;
static PowerSetpoint_t fd_target;
static uint8_t setpoint_dirty;
static uint8_t fd_active;
static uint8_t power_delivery_latched;
static uint8_t fast_discharge_count;
static uint32_t last_fast_discharge_ms;
static uint32_t measured_high_current_since_ms;
static uint8_t session_ended_state(CONN_State_t state)
{
return (state == Unknown) || (state == Unplugged) || (state == Finished) ||
(state == FinishedEV) || (state == FinishedEVSE);
}
void PowerSetpoint_Init(void)
{
applied.voltage_V = PSU_MIN_VOLTAGE;
applied.current_0p1A = 0u;
pending = applied;
fd_target = applied;
setpoint_dirty = 0u;
fd_active = 0u;
power_delivery_latched = 0u;
fast_discharge_count = 0u;
last_fast_discharge_ms = 0u;
measured_high_current_since_ms = 0u;
}
void PowerSetpoint_OnCommand(uint16_t voltage_V, uint16_t current_0p1A)
{
#if PSD_ENABLE
pending.voltage_V = voltage_V;
pending.current_0p1A = current_0p1A;
setpoint_dirty = 1u;
#else
(void)voltage_V;
(void)current_0p1A;
#endif
}
void PowerSetpoint_UpdateDeliveryLatch(void)
{
#if PSD_ENABLE
uint32_t now = HAL_GetTick();
if (!CONN.EnableOutput || !CONN.EvConnected || session_ended_state(CCS_EvseState)) {
power_delivery_latched = 0u;
fast_discharge_count = 0u;
last_fast_discharge_ms = 0u;
measured_high_current_since_ms = 0u;
return;
}
if (CONN.WantedCurrent > PSD_MAX_CMD_CURRENT_0P1A) {
power_delivery_latched = 1u;
}
if (CCS_EvseState == Charging) {
power_delivery_latched = 1u;
}
if (CONN.MeasuredCurrent >= PSD_MAX_MEASURED_CURRENT_0P1A) {
if (measured_high_current_since_ms == 0u) {
measured_high_current_since_ms = now;
} else if ((now - measured_high_current_since_ms) >= PSD_MEASURED_LATCH_MS) {
power_delivery_latched = 1u;
}
} else {
measured_high_current_since_ms = 0u;
}
#endif
}
uint8_t PowerSetpoint_HasPending(void)
{
#if PSD_ENABLE
return setpoint_dirty;
#else
return 0u;
#endif
}
uint8_t PowerSetpoint_IsBusy(void)
{
#if PSD_ENABLE
if (!fd_active) {
return 0u;
}
switch (PSU0.state) {
case PSU_FAST_DISCHARGE_OFF:
case PSU_FAST_DISCHARGE_WAIT:
case PSU_FAST_DISCHARGE_SET:
case PSU_FAST_DISCHARGE_ON:
case PSU_FAST_DISCHARGE_ON_WAIT:
return 1u;
default:
return 0u;
}
#else
return 0u;
#endif
}
static PowerPathContext_t build_context(void)
{
PowerPathContext_t ctx;
ctx.dc_contactor_closed = PSU0.CONT_enabled;
ctx.psu_hv_enabled = PSU0.PSU_enabled;
ctx.measured_voltage_V = CONN.MeasuredVoltage;
ctx.measured_current_0p1A = (uint16_t)CONN.MeasuredCurrent;
ctx.power_delivery_active = power_delivery_latched;
ctx.enable_output = CONN.EnableOutput;
ctx.psu_state_connected = (PSU0.state == PSU_CONNECTED) ? 1u : 0u;
ctx.psu_cont_fault = PSU0.cont_fault;
ctx.psu_fault = PSU0.psu_fault;
ctx.fast_discharge_count = fast_discharge_count;
ctx.last_fast_discharge_ms = last_fast_discharge_ms;
ctx.now_ms = HAL_GetTick();
return ctx;
}
PowerSetpointTryResult_t PowerSetpoint_TryApply(void)
{
#if PSD_ENABLE
PowerPathContext_t ctx;
PowerSetpointAction_t action;
if (!setpoint_dirty || fd_active) {
return PSD_TRY_IDLE;
}
ctx = build_context();
action = PowerSetpoint_Decide(&applied, &pending, &ctx);
if (action == POWER_SETPOINT_FAST_DISCHARGE) {
fd_target = pending;
fd_active = 1u;
setpoint_dirty = 0u;
log_printf(LOG_INFO, "Fast discharge trigger %u->%u I=%u\n",
(unsigned)applied.voltage_V,
(unsigned)fd_target.voltage_V,
(unsigned)fd_target.current_0p1A);
return PSD_TRY_START_FAST_DISCHARGE;
}
if (!PSU0.ready) {
return PSD_TRY_IDLE;
}
PSU_SetVoltageCurrent(0, pending.voltage_V, pending.current_0p1A);
applied = pending;
setpoint_dirty = 0u;
return PSD_TRY_APPLIED_NORMAL;
#else
return PSD_TRY_IDLE;
#endif
}
void PowerSetpoint_GetFastDischargeTarget(PowerSetpoint_t *target)
{
if (target != 0) {
*target = fd_target;
}
}
void PowerSetpoint_OnFastDischargeComplete(void)
{
#if PSD_ENABLE
applied = fd_target;
fd_active = 0u;
fast_discharge_count++;
last_fast_discharge_ms = HAL_GetTick();
log_printf(LOG_INFO, "Fast discharge complete, V=%u\n", (unsigned)CONN.MeasuredVoltage);
#endif
}
void PowerSetpoint_OnFastDischargeAbort(void)
{
#if PSD_ENABLE
fd_active = 0u;
pending = fd_target;
setpoint_dirty = 1u;
log_printf(LOG_WARN, "Fast discharge aborted, V=%u\n", (unsigned)CONN.MeasuredVoltage);
#endif
}
+77
View File
@@ -0,0 +1,77 @@
#include "power_setpoint_policy.h"
PowerSetpointAction_t PowerSetpoint_Decide(
const PowerSetpoint_t *applied,
const PowerSetpoint_t *next,
const PowerPathContext_t *ctx)
{
#if !PSD_ENABLE
(void)applied;
(void)next;
(void)ctx;
return POWER_SETPOINT_NORMAL;
#else
uint16_t delta_v;
if (applied == 0 || next == 0 || ctx == 0) {
return POWER_SETPOINT_NORMAL;
}
if (next->voltage_V >= applied->voltage_V) {
return POWER_SETPOINT_NORMAL;
}
delta_v = (uint16_t)(applied->voltage_V - next->voltage_V);
if (delta_v < PSD_MIN_VOLTAGE_STEP_V) {
return POWER_SETPOINT_NORMAL;
}
if (applied->current_0p1A > PSD_MAX_CMD_CURRENT_0P1A ||
next->current_0p1A > PSD_MAX_CMD_CURRENT_0P1A) {
return POWER_SETPOINT_NORMAL;
}
if (ctx->measured_current_0p1A >= PSD_MAX_MEASURED_CURRENT_0P1A) {
return POWER_SETPOINT_NORMAL;
}
if (ctx->measured_voltage_V <= (uint16_t)(next->voltage_V + PSD_DISCHARGE_MARGIN_V)) {
return POWER_SETPOINT_NORMAL;
}
if (ctx->power_delivery_active) {
return POWER_SETPOINT_NORMAL;
}
if (!ctx->enable_output) {
return POWER_SETPOINT_NORMAL;
}
if (!ctx->psu_state_connected) {
return POWER_SETPOINT_NORMAL;
}
if (!ctx->dc_contactor_closed) {
return POWER_SETPOINT_NORMAL;
}
if (!ctx->psu_hv_enabled) {
return POWER_SETPOINT_NORMAL;
}
if (ctx->psu_cont_fault || ctx->psu_fault) {
return POWER_SETPOINT_NORMAL;
}
if (ctx->fast_discharge_count >= PSD_MAX_PER_SESSION) {
return POWER_SETPOINT_NORMAL;
}
if (ctx->last_fast_discharge_ms != 0u &&
(ctx->now_ms - ctx->last_fast_discharge_ms) < PSD_DEBOUNCE_MS) {
return POWER_SETPOINT_NORMAL;
}
return POWER_SETPOINT_FAST_DISCHARGE;
#endif
}
+499 -37
View File
@@ -1,14 +1,14 @@
#include "psu_control.h"
#include <psu_control.h>
#include "board.h"
#include "can.h"
#include "string.h"
#include "stdio.h"
#include "charger_config.h"
#include "charger_control.h"
#include "board.h"
#include "debug.h"
#include "isr_opt.h"
#include "power_setpoint_executor.h"
#include <stdio.h>
#include <string.h>
PSU_02_t PSU_02;
PSU_04_t PSU_04;
@@ -26,12 +26,344 @@ PSU_t PSU0;
#define PSU_VOLTAGE_THRESHOLD 20 // Порог напряжения для определения состояния (В)
#define PSU_ONLINE_TIMEOUT 500 // Таймаут для определения состояния (мс)
#define PSU_STARTUP_DELAY 4000 // Задержка 2 секунды перед включением
#define PSU_DIAG_LOG_MS 2000u
#define PSU_SUDDEN_OFF_DEBOUNCE_MS 200u
uint32_t can_lastpacket;
extern CAN_HandleTypeDef hcan2;
static uint16_t psu_last_can_v;
static uint16_t psu_last_can_i_0p1A;
static uint8_t psu_last_good_s0;
static uint8_t psu_last_good_s1;
static uint8_t psu_last_good_s2;
static void PSU_SendCmd(uint8_t source, uint8_t destination, uint8_t cmd, void *data);
static void PSU_LogActiveStatusFlags(LogLevel_t level);
static void PSU_MonitorStatusAndUnexpectedOff(void);
static const char *PSU_StateName(PSU_State_t state)
{
switch (state) {
case PSU_UNREADY: return "UNREADY";
case PSU_INITIALIZING: return "INIT";
case PSU_READY: return "READY";
case PSU_WAIT_ACK_ON: return "WAIT_ON";
case PSU_CONT_WAIT_ACK_ON: return "CONT_ON";
case PSU_CONNECTED: return "CONNECTED";
case PSU_FAST_DISCHARGE_OFF: return "FD_OFF";
case PSU_FAST_DISCHARGE_WAIT: return "FD_WAIT";
case PSU_FAST_DISCHARGE_SET: return "FD_SET";
case PSU_FAST_DISCHARGE_ON: return "FD_ON";
case PSU_FAST_DISCHARGE_ON_WAIT: return "FD_ON_WAIT";
case PSU_CURRENT_DROP: return "CUR_DROP";
case PSU_CONT_WAIT_ACK_OFF: return "CONT_OFF";
case PSU_WAIT_ACK_OFF: return "WAIT_OFF";
case PSU_OFF_PAUSE: return "OFF_PAUSE";
default: return "?";
}
}
static void PSU_LogPeriodicDiag(void)
{
static uint32_t last_log_ms;
uint32_t now = HAL_GetTick();
uint8_t block_setpoint;
/* Periodic PSU telemetry only while session is in Charging. */
if (CONN.connState != Charging) {
return;
}
if ((now - last_log_ms) < PSU_DIAG_LOG_MS) {
return;
}
last_log_ms = now;
#if PSD_ENABLE
block_setpoint = PowerSetpoint_HasPending() || PowerSetpoint_IsBusy();
#else
block_setpoint = 0u;
#endif
log_printf(LOG_INFO,
"PSU diag st=%s req=%uV/%u.%uA want=%uV/%u.%uA "
"can=%uV/%u.%uA meas=%uV/%d.%uA "
"enOut=%u out=%u rdy=%u on=%u cont=%u ac=%u hv=%u psd_blk=%u "
"err=%u s0=0x%02x s1=0x%02x s2=0x%02x can_age=%lums\n",
PSU_StateName(PSU0.state),
(unsigned)CONN.RequestedVoltage,
(unsigned)(CONN.RequestedCurrent / 10u),
(unsigned)(CONN.RequestedCurrent % 10u),
(unsigned)CONN.RequestedVoltage,
(unsigned)(CONN.WantedCurrent / 10u),
(unsigned)(CONN.WantedCurrent % 10u),
(unsigned)psu_last_can_v,
(unsigned)(psu_last_can_i_0p1A / 10u),
(unsigned)(psu_last_can_i_0p1A % 10u),
(unsigned)CONN.MeasuredVoltage,
(int)(CONN.MeasuredCurrent / 10),
(unsigned)(((CONN.MeasuredCurrent < 0) ?
-CONN.MeasuredCurrent : CONN.MeasuredCurrent) % 10),
(unsigned)CONN.EnableOutput,
(unsigned)CONN.outputEnabled,
(unsigned)PSU0.ready,
(unsigned)PSU0.PSU_enabled,
(unsigned)PSU0.CONT_enabled,
(unsigned)PSU0.enableAC,
(unsigned)CONN.hv_limit,
(unsigned)block_setpoint,
(unsigned)CONN.chargingError,
(unsigned)PSU0.status0.raw,
(unsigned)PSU0.status1.raw,
(unsigned)PSU0.status2.raw,
(unsigned long)(can_lastpacket ? (now - can_lastpacket) : 9999u));
}
static void PSU_LogActiveStatusFlags(LogLevel_t level)
{
PSU_Status0_t s0 = PSU0.status0.bits;
PSU_Status1_t s1 = PSU0.status1.bits;
PSU_Status2_t s2 = PSU0.status2.bits;
log_printf(level,
"PSU flags%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
s0.shortCircuitFault ? " sc" : "",
s0.unevenFlowAlarm ? " uneven" : "",
s0.internalCommunicationFault ? " int_comm" : "",
s0.inputBusLineFault ? " in_bus" : "",
s0.lockProtection ? " lock" : "",
s0.dischargeFault ? " disch" : "",
s0.eepromFault ? " eeprom" : "",
s1.dcSideOffStatus ? " dc_off" : "",
s1.moduleFaultAlarm ? " fault" : "",
s1.moduleProtectionAlarm ? " prot" : "",
s1.fanFaultAlarm ? " fan" : "",
s1.overTempAlarm ? " ot" : "",
s1.outputOverVoltageAlarm ? " oov" : "",
s1.outputOverCurrentAlarm ? " ooc" : "",
s1.canCommunicationInterruptAlarm ? " can_int" : "",
s2.powerLimitStatus ? " plim" : "",
s2.moduleAddressDuplicate ? " addr_dup" : "",
s2.severeUnevenFlowFault ? " uneven_hi" : "",
s2.threePhaseInputPhaseLossAlarm ? " ph_loss" : "",
s2.threePhaseInputUnbalanceAlarm ? " unbal" : "",
s2.inputUnderVoltageAlarm ? " uv" : "",
s2.inputOverVoltageAlarm ? " ov" : "",
s2.pfcSideOffStatus ? " pfc_off" : "");
}
/*
* Observability only: does not change PSU/contactor state machine.
* Armed only in CONN Charging phase:
* - status bit edges while output is requested
* - PSU_enabled 1->0 while CONNECTED + EnableOutput (sudden disable)
*
* Note: PSU_enabled is derived from V >= PSU_VOLTAGE_THRESHOLD, not from
* the module enable command bit.
*/
static void PSU_MonitorStatusAndUnexpectedOff(void)
{
static uint8_t prev_s0;
static uint8_t prev_s1;
static uint8_t prev_s2;
static uint8_t prev_enabled;
static uint8_t inited;
static uint8_t sudden_latched;
static uint32_t sudden_cand_ms;
uint32_t now = HAL_GetTick();
uint8_t in_charging;
uint8_t watch_status;
uint8_t expect_on;
in_charging = (CONN.connState == Charging);
watch_status = in_charging && (CONN.EnableOutput != 0) && (PSU0.online != 0) &&
((PSU0.state == PSU_CONNECTED) ||
(PSU0.state == PSU_WAIT_ACK_ON) ||
(PSU0.state == PSU_CONT_WAIT_ACK_ON));
expect_on = in_charging && (CONN.EnableOutput != 0) && (PSU0.state == PSU_CONNECTED);
if (!inited) {
prev_s0 = PSU0.status0.raw;
prev_s1 = PSU0.status1.raw;
prev_s2 = PSU0.status2.raw;
prev_enabled = PSU0.PSU_enabled;
inited = 1u;
return;
}
if (watch_status) {
if ((PSU0.status0.raw != prev_s0) ||
(PSU0.status1.raw != prev_s1) ||
(PSU0.status2.raw != prev_s2)) {
log_printf(LOG_WARN,
"PSU status change s0=0x%02x->0x%02x s1=0x%02x->0x%02x s2=0x%02x->0x%02x\n",
(unsigned)prev_s0, (unsigned)PSU0.status0.raw,
(unsigned)prev_s1, (unsigned)PSU0.status1.raw,
(unsigned)prev_s2, (unsigned)PSU0.status2.raw);
PSU_LogActiveStatusFlags(LOG_WARN);
}
}
prev_s0 = PSU0.status0.raw;
prev_s1 = PSU0.status1.raw;
prev_s2 = PSU0.status2.raw;
if (!expect_on) {
sudden_cand_ms = 0u;
if ((CONN.EnableOutput == 0) ||
(CONN.connState != Charging) ||
(PSU0.state == PSU_READY) ||
(PSU0.state == PSU_UNREADY) ||
(PSU0.state == PSU_OFF_PAUSE) ||
(PSU0.state == PSU_WAIT_ACK_OFF) ||
(PSU0.state == PSU_CONT_WAIT_ACK_OFF) ||
(PSU0.state == PSU_CURRENT_DROP)) {
sudden_latched = 0u;
}
prev_enabled = PSU0.PSU_enabled;
return;
}
if (PSU0.PSU_enabled) {
sudden_cand_ms = 0u;
sudden_latched = 0u;
prev_enabled = 1u;
return;
}
if (sudden_latched) {
prev_enabled = 0u;
return;
}
if (!prev_enabled) {
sudden_cand_ms = 0u;
return;
}
/* Falling edge of PSU_enabled while still CONNECTED + EnableOutput + Charging */
if (!PSU0.online) {
log_printf(LOG_ERR,
"PSU suddenly disabled while charging reason=can_lost "
"V=%u I=%d cont=%u s0=0x%02x s1=0x%02x s2=0x%02x can_age=%lums\n",
(unsigned)PSU0.outputVoltage,
(int)PSU0.outputCurrent,
(unsigned)PSU0.CONT_enabled,
(unsigned)psu_last_good_s0,
(unsigned)psu_last_good_s1,
(unsigned)psu_last_good_s2,
(unsigned long)(can_lastpacket ? (now - can_lastpacket) : 9999u));
PSU_LogActiveStatusFlags(LOG_ERR);
sudden_latched = 1u;
sudden_cand_ms = 0u;
prev_enabled = 0u;
return;
}
if (sudden_cand_ms == 0u) {
sudden_cand_ms = now;
return;
}
if ((now - sudden_cand_ms) < PSU_SUDDEN_OFF_DEBOUNCE_MS) {
return;
}
log_printf(LOG_ERR,
"PSU suddenly disabled while charging reason=output_lost "
"V=%u I=%d cont=%u s0=0x%02x s1=0x%02x s2=0x%02x can_age=%lums\n",
(unsigned)PSU0.outputVoltage,
(int)PSU0.outputCurrent,
(unsigned)PSU0.CONT_enabled,
(unsigned)PSU0.status0.raw,
(unsigned)PSU0.status1.raw,
(unsigned)PSU0.status2.raw,
(unsigned long)(can_lastpacket ? (now - can_lastpacket) : 9999u));
PSU_LogActiveStatusFlags(LOG_ERR);
sudden_latched = 1u;
sudden_cand_ms = 0u;
prev_enabled = 0u;
}
static void PSU_HvControl(void)
{
if (CONN.EnableOutput == 0u) {
if ((CONN.hv_limit != 0u) || (CONN.hv_limit_count != 0u)) {
log_printf(LOG_INFO, "HV limit reset output off\n");
}
CONN.hv_limit = 0u;
CONN.hv_tick = 0u;
CONN.hv_limit_count = 0u;
return;
}
if (!PSU0.online) {
if ((CONN.hv_limit != 0u) || (CONN.hv_limit_count != 0u)) {
log_printf(LOG_INFO, "HV limit reset no PSU\n");
}
CONN.hv_limit = 0u;
CONN.hv_tick = 0u;
CONN.hv_limit_count = 0u;
return;
}
if (CONN.hv_limit == 0u) {
if ((CONN.hv_limit_count < PSU_HV_LIMIT_MAX_COUNT) &&
(CONN.MeasuredVoltage < PSU_HV_LIMIT_ON_THRESHOLD) &&
(CONN.MeasuredCurrent > PSU_HV_LOAD_CURRENT)) {
if (CONN.hv_tick == 0u) {
CONN.hv_tick = HAL_GetTick();
} else if ((HAL_GetTick() - CONN.hv_tick) >= PSU_HV_SWITCH_DELAY_MS) {
CONN.hv_limit = 1u;
CONN.hv_limit_count++;
CONN.hv_tick = 0u;
log_printf(LOG_WARN, "HV limit ON V=%d I=%d cnt=%d\n",
(int)CONN.MeasuredVoltage,
(int)CONN.MeasuredCurrent,
(int)CONN.hv_limit_count);
if (CONN.hv_limit_count >= PSU_HV_LIMIT_MAX_COUNT) {
log_printf(LOG_WARN, "HV limit locked cnt=%d\n",
(int)CONN.hv_limit_count);
}
}
} else {
CONN.hv_tick = 0u;
}
} else {
if ((CONN.MeasuredVoltage > PSU_HV_LIMIT_OFF_THRESHOLD) ||
(CONN.MeasuredCurrent <= PSU_HV_LOAD_CURRENT)) {
if (CONN.hv_tick == 0u) {
CONN.hv_tick = HAL_GetTick();
} else if ((HAL_GetTick() - CONN.hv_tick) >= PSU_HV_SWITCH_DELAY_MS) {
CONN.hv_limit = 0u;
CONN.hv_tick = 0u;
log_printf(LOG_INFO, "HV limit OFF V=%d I=%d cnt=%d\n",
(int)CONN.MeasuredVoltage,
(int)CONN.MeasuredCurrent,
(int)CONN.hv_limit_count);
}
} else {
CONN.hv_tick = 0u;
}
}
}
static void PSU_SwitchState(PSU_State_t state){
if (PSU0.state != state) {
log_printf(LOG_INFO,
"PSU st %s->%s enOut=%u rdy=%u on=%u cont=%u err=%u\n",
PSU_StateName(PSU0.state),
PSU_StateName(state),
(unsigned)CONN.EnableOutput,
(unsigned)PSU0.ready,
(unsigned)PSU0.PSU_enabled,
(unsigned)PSU0.CONT_enabled,
(unsigned)CONN.chargingError);
}
PSU0.state = state;
PSU0.statetick = HAL_GetTick();
}
@@ -40,6 +372,24 @@ static uint32_t PSU_StateTime(void){
return HAL_GetTick() - PSU0.statetick;
}
static void PSU_FastDischarge_PushTarget(void)
{
PowerSetpoint_t fd_sp;
PowerSetpoint_GetFastDischargeTarget(&fd_sp);
PSU_SetVoltageCurrent(0, fd_sp.voltage_V, fd_sp.current_0p1A);
PSU_Enable(0, 1);
}
static void PSU_FastDischarge_AbortToConnected(void)
{
PowerSetpoint_OnFastDischargeAbort();
if (!PSU0.PSU_enabled) {
PSU_FastDischarge_PushTarget();
}
PSU_SwitchState(PSU_CONNECTED);
}
ISR_FAST void HAL_CAN_RxFifo1MsgPendingCallback(CAN_HandleTypeDef *hcan){
static CAN_RxHeaderTypeDef RxHeader;
@@ -64,6 +414,9 @@ ISR_FAST void HAL_CAN_RxFifo1MsgPendingCallback(CAN_HandleTypeDef *hcan){
PSU0.status0.raw = PSU_04.modularForm0;
PSU0.status1.raw = PSU_04.modularForm1;
PSU0.status2.raw = PSU_04.modularForm2;
psu_last_good_s0 = PSU0.status0.raw;
psu_last_good_s1 = PSU0.status1.raw;
psu_last_good_s2 = PSU0.status2.raw;
}
if(CanId.command==0x06){
memcpy(&PSU_06, RxData, 8);
@@ -149,10 +502,9 @@ void PSU_Init(){
PSU0.statetick = HAL_GetTick();
PSU0.power_limit = PSU_MAX_POWER; // kW
PSU0.hv_mode = 0;
PSU0.hv_tick = 0;
PSU_Enable(0, 0);
PowerSetpoint_Init();
}
void PSU_Enable(uint8_t addr, uint8_t enable){
@@ -182,7 +534,9 @@ void PSU_SetVoltageCurrent(uint8_t addr, uint16_t voltage, uint16_t current){
if(voltage<PSU_MIN_VOLTAGE) voltage = PSU_MIN_VOLTAGE;
if((PSU0.hv_mode==0) && voltage>499) voltage = 499;
if((CONN.hv_limit != 0u) && (voltage > PSU_LV_CLAMP_V)){
voltage = PSU_LV_CLAMP_V;
}
uint32_t current_ma = current * 100;
uint32_t voltage_mv = voltage * 1000;
@@ -197,6 +551,8 @@ void PSU_SetVoltageCurrent(uint8_t addr, uint16_t voltage, uint16_t current){
data.moduleVoltage[2] = (voltage_mv >> 8) & 0xFF;
data.moduleVoltage[3] = (voltage_mv >> 0) & 0xFF;
psu_last_can_v = voltage;
psu_last_can_i_0p1A = current;
PSU_SendCmd(0xF0, addr, 0x1C, &data);
}
@@ -227,7 +583,6 @@ void PSU_SendCmd(uint8_t source, uint8_t destination, uint8_t cmd, void *data){
/* если отправка удалась, выход */
if(CAN_result == HAL_OK) {
return;
retry_counter = 0;
}
}
ED_Delay(1);
@@ -237,11 +592,6 @@ void PSU_SendCmd(uint8_t source, uint8_t destination, uint8_t cmd, void *data){
}
uint32_t max(uint32_t a, uint32_t b){
if(a>b) return a;
else return b;
}
void PSU_ReadWrite(){
uint8_t zero_data[8] = {0,0,0,0,0,0,0,0};
@@ -263,36 +613,50 @@ void PSU_ReadWrite(){
}
CONN.RequestedPower = CONN.RequestedCurrent * CONN.RequestedVoltage / 10;
if(PSU0.ready){
if (CONN.RequestedVoltage == 500) { // fake
PSU_SetVoltageCurrent(0, 300, 10); // Normal mode
}else{
PSU_SetVoltageCurrent(0, CONN.RequestedVoltage, CONN.RequestedCurrent); // Normal mode
}
ED_Delay(CAN_DELAY);
if(CONN.MeasuredVoltage > 490){
if(PSU0.hv_tick == 0){
PSU0.hv_tick = HAL_GetTick();
}else if((HAL_GetTick() - PSU0.hv_tick) >= 10000){
PSU0.hv_mode = 1;
}
}else{
PSU0.hv_tick = 0;
}
}
#if PSD_ENABLE
{
uint8_t block_setpoint = PowerSetpoint_HasPending() || PowerSetpoint_IsBusy();
// PSU_SetHVMode(0, PSU0.hv_mode); // auto set, no need
// ED_Delay(CAN_DELAY);
if (PSU0.ready && !block_setpoint) {
PSU_SetVoltageCurrent(0, CONN.RequestedVoltage, CONN.RequestedCurrent);
ED_Delay(CAN_DELAY);
}
}
#else
if (PSU0.ready) {
PSU_SetVoltageCurrent(0, CONN.RequestedVoltage, CONN.RequestedCurrent); // Normal mode
ED_Delay(CAN_DELAY);
}
#endif
if (PSU0.ready) {
PSU_HvControl();
}
}
void PSU_Task(void){
static uint32_t psu_on_tick = 0;
static uint32_t dc_on_tick = 0;
static uint32_t cont_ok_tick = 0;
static uint32_t fd_on_last_cmd_ms = 0;
PowerSetpointTryResult_t psd_result;
#if PSD_ENABLE
PowerSetpoint_UpdateDeliveryLatch();
if (PowerSetpoint_HasPending()) {
psd_result = PowerSetpoint_TryApply();
if (psd_result == PSD_TRY_START_FAST_DISCHARGE) {
PSU_SwitchState(PSU_FAST_DISCHARGE_OFF);
}
}
#endif
// Обновляем ONLINE/READY по таймауту
if((HAL_GetTick() - can_lastpacket) > PSU_ONLINE_TIMEOUT){
if (PSU0.online) {
log_printf(LOG_WARN, "PSU CAN timeout age=%lums -> offline\n",
(unsigned long)(HAL_GetTick() - can_lastpacket));
}
PSU0.online = 0;
PSU0.PSU_enabled = 0;
PSU_04.moduleTemperature = 0;
@@ -333,6 +697,9 @@ void PSU_Task(void){
PSU0.ready = 0;
}
/* Before state transitions so CONNECTED+can_lost is still visible */
PSU_MonitorStatusAndUnexpectedOff();
switch(PSU0.state){
case PSU_UNREADY:
PSU0.enableOutput = 0;
@@ -351,8 +718,9 @@ void PSU_Task(void){
case PSU_READY:
// модуль готов, но выключен
PSU0.hv_mode = 0;
PSU0.hv_tick = 0;
CONN.hv_limit = 0u;
CONN.hv_tick = 0u;
CONN.hv_limit_count = 0u;
RELAY_Write(RELAY_DC, 0);
if(!PSU0.ready){
@@ -368,7 +736,6 @@ void PSU_Task(void){
case PSU_WAIT_ACK_ON:
if(PSU0.PSU_enabled && PSU0.ready){
dc_on_tick = HAL_GetTick();
PSU_SwitchState(PSU_CONT_WAIT_ACK_ON);
}else if(PSU_StateTime() > 10000){
PSU0.psu_fault = 1;
@@ -410,6 +777,99 @@ void PSU_Task(void){
}
break;
case PSU_FAST_DISCHARGE_OFF:
if (!CONN.EnableOutput || !PSU0.ready || PSU0.cont_fault || PSU0.psu_fault) {
log_printf(LOG_WARN, "Fast discharge abort -> stop\n");
PowerSetpoint_OnFastDischargeAbort();
PSU_SwitchState(PSU_CURRENT_DROP);
break;
}
PSU_Enable(0, 0);
PSU_SwitchState(PSU_FAST_DISCHARGE_WAIT);
break;
case PSU_FAST_DISCHARGE_WAIT: {
PowerSetpoint_t fd_sp;
if (!CONN.EnableOutput || !PSU0.ready || PSU0.cont_fault || PSU0.psu_fault) {
log_printf(LOG_WARN, "Fast discharge abort -> stop\n");
PowerSetpoint_OnFastDischargeAbort();
PSU_SwitchState(PSU_CURRENT_DROP);
break;
}
/* Как PSU_WAIT_ACK_OFF: 020 V на телеметрии = модуль выключен */
if (!PSU0.PSU_enabled) {
PowerSetpoint_GetFastDischargeTarget(&fd_sp);
log_printf(LOG_INFO, "Fast discharge off ack, V=%u -> set %u\n",
(unsigned)CONN.MeasuredVoltage, (unsigned)fd_sp.voltage_V);
PSU_SwitchState(PSU_FAST_DISCHARGE_SET);
} else if (PSU_StateTime() > PSD_OFF_TIMEOUT_MS) {
log_printf(LOG_WARN, "Fast discharge off timeout, V=%u\n",
(unsigned)CONN.MeasuredVoltage);
PSU_FastDischarge_AbortToConnected();
}
break;
}
case PSU_FAST_DISCHARGE_SET: {
PowerSetpoint_t fd_sp;
if (!CONN.EnableOutput || !PSU0.ready || PSU0.cont_fault || PSU0.psu_fault) {
log_printf(LOG_WARN, "Fast discharge abort -> stop\n");
PowerSetpoint_OnFastDischargeAbort();
PSU_SwitchState(PSU_CURRENT_DROP);
break;
}
PowerSetpoint_GetFastDischargeTarget(&fd_sp);
PSU_SetVoltageCurrent(0, fd_sp.voltage_V, fd_sp.current_0p1A);
PSU_SwitchState(PSU_FAST_DISCHARGE_ON);
break;
}
case PSU_FAST_DISCHARGE_ON:
if (!CONN.EnableOutput || !PSU0.ready || PSU0.cont_fault || PSU0.psu_fault) {
log_printf(LOG_WARN, "Fast discharge abort -> stop\n");
PowerSetpoint_OnFastDischargeAbort();
PSU_SwitchState(PSU_CURRENT_DROP);
break;
}
PSU_Enable(0, 1);
fd_on_last_cmd_ms = HAL_GetTick();
PSU_SwitchState(PSU_FAST_DISCHARGE_ON_WAIT);
break;
case PSU_FAST_DISCHARGE_ON_WAIT: {
PowerSetpoint_t fd_sp;
uint16_t v_low;
if (!CONN.EnableOutput || !PSU0.ready || PSU0.cont_fault || PSU0.psu_fault) {
log_printf(LOG_WARN, "Fast discharge abort -> stop\n");
PowerSetpoint_OnFastDischargeAbort();
PSU_SwitchState(PSU_CURRENT_DROP);
break;
}
PowerSetpoint_GetFastDischargeTarget(&fd_sp);
v_low = (fd_sp.voltage_V > PSD_PRECHARGE_TOLERANCE_V) ?
(uint16_t)(fd_sp.voltage_V - PSD_PRECHARGE_TOLERANCE_V) : 0u;
if (PSU0.PSU_enabled && CONN.MeasuredVoltage >= v_low) {
PowerSetpoint_OnFastDischargeComplete();
PSU_SwitchState(PSU_CONNECTED);
} else {
if ((HAL_GetTick() - fd_on_last_cmd_ms) >= PSD_ON_RETRY_MS) {
PSU_FastDischarge_PushTarget();
fd_on_last_cmd_ms = HAL_GetTick();
}
if (PSU_StateTime() > PSD_ON_TIMEOUT_MS) {
log_printf(LOG_WARN, "Fast discharge on timeout, V=%u (target %u)\n",
(unsigned)CONN.MeasuredVoltage, (unsigned)fd_sp.voltage_V);
PSU_FastDischarge_AbortToConnected();
}
}
break;
}
case PSU_CURRENT_DROP:
// снижаем ток до нуля перед отключением DC
CONN.RequestedCurrent = 0;
@@ -456,6 +916,8 @@ void PSU_Task(void){
PSU_SwitchState(PSU_UNREADY);
break;
}
PSU_LogPeriodicDiag();
}
+351 -143
View File
@@ -1,25 +1,33 @@
#include "rgb_controller.h"
#include "fire_alarm.h"
#include "main.h"
#include "string.h"
#include "charger_control.h"
#include "board.h"
#include "board.h"
#include "charger_control.h"
#include "main.h"
#include "tim.h"
#include <string.h>
/* Второй светодиод в цепочке WS2812 */
static RGB_t ws2812_led1 = { .R = 0, .G = 0, .B = 0 };
#define WS2812_ERROR_BLINK_MS 100
#define WS2812_ERROR_BLINK_PAUSE 30
/* Яркость обоих WS2812 на плате, 0..255 */
#define WS2812_BRIGHTNESS 60
RGB_State_t LED_State;
RGB_Cycle_t LED_Cycle;
RGB_Cycle_t color_estop = {
static const RGB_Cycle_t color_estop = {
.Color1 = { .R = 250, .G = 0, .B = 0 },
.Color2 = { .R = 0, .G = 0, .B = 0 },
.Tr = 10,
.Th = 5,
.Tf = 10,
.Tl = 5,
.Tr = 40,
.Th = 10,
.Tf = 40,
.Tl = 10,
};
RGB_Cycle_t color_unlock = {
static const RGB_Cycle_t color_unlock = {
.Color1 = { .R = 255, .G = 0, .B = 0 },
.Color2 = { .R = 0, .G = 0, .B = 0 },
.Tr = 10,
@@ -28,142 +36,219 @@ RGB_Cycle_t color_unlock = {
.Tl = 10,
};
RGB_Cycle_t color_unknown = {
.Color1 = { .R = 64, .G = 0, .B = 0 },
.Color2 = { .R = 64, .G = 0, .B = 0 },
.Tr = 50,
.Th = 10,
.Tf = 50,
.Tl = 0,
};
/* Same init shimmer as AC22/tkzu22: hue=85, sat breathes 30↔250 (not fade-to-black). */
static uint8_t lighting_init_active;
RGB_Cycle_t color_light = {
.Color1 = { .R = 0, .G = 255, .B = 0 },
.Color2 = { .R = 0, .G = 255, .B = 0 },
.Tr = 50,
.Th = 10,
.Tf = 50,
.Tl = 0,
};
static void LED_HsvToRgb(uint8_t hue, uint8_t sat, uint8_t val, RGB_t *out)
{
uint8_t region;
uint8_t remainder;
uint8_t p;
uint8_t q;
uint8_t t;
RGB_Cycle_t color_disabled = {
.Color1 = { .R = 250, .G = 0, .B = 0 },
.Color2 = { .R = 32, .G = 0, .B = 0 },
.Tr = 50,
.Th = 10,
.Tf = 50,
.Tl = 0,
};
RGB_Cycle_t color_unplugged = {
.Color1 = { .R = 0, .G = 128, .B = 0 },
.Color2 = { .R = 0, .G = 128, .B = 0 },
.Tr = 50,
.Th = 10,
.Tf = 50,
.Tl = 0,
};
RGB_Cycle_t color_preparing = {
.Color1 = { .R = 0, .G = 0, .B = 255 },
.Color2 = { .R = 0, .G = 0, .B = 0 },
.Tr = 10,
.Th = 10,
.Tf = 10,
.Tl = 10,
};
RGB_Cycle_t color_charging = {
.Color1 = { .R = 0, .G = 255, .B = 0 },
.Color2 = { .R = 0, .G = 32, .B = 0 },
.Tr = 50,
.Th = 10,
.Tf = 50,
.Tl = 0,
};
RGB_Cycle_t color_finished = {
.Color1 = { .R = 255, .G = 255, .B = 255 },
.Color2 = { .R = 255, .G = 255, .B = 255 },
.Tr = 50,
.Th = 10,
.Tf = 50,
.Tl = 0,
};
RGB_Cycle_t color_error = {
.Color1 = { .R = 255, .G = 0, .B = 0 },
.Color2 = { .R = 32, .G = 0, .B = 0 },
.Tr = 50,
.Th = 10,
.Tf = 50,
.Tl = 0,
};
void LED_Write(){
if(FireAlarm_IsLatched() || CONN.chargingError == CONN_ERR_FIRE_ALARM){
LED_SetColor(&color_error);
if (sat == 0U) {
out->R = out->G = out->B = val;
return;
}
if(CONN.chargingError != CONN_NO_ERROR){
LED_SetColor(&color_error);
region = (uint8_t)(hue / 43U);
remainder = (uint8_t)((hue - (uint8_t)(region * 43U)) * 6U);
p = (uint8_t)((val * (255U - sat)) >> 8);
q = (uint8_t)((val * (255U - ((sat * remainder) >> 8))) >> 8);
t = (uint8_t)((val * (255U - ((sat * (255U - remainder)) >> 8))) >> 8);
switch (region) {
case 0:
out->R = val;
out->G = t;
out->B = p;
break;
case 1:
out->R = q;
out->G = val;
out->B = p;
break;
case 2:
out->R = p;
out->G = val;
out->B = t;
break;
case 3:
out->R = p;
out->G = q;
out->B = val;
break;
case 4:
out->R = t;
out->G = p;
out->B = val;
break;
default:
out->R = val;
out->G = p;
out->B = q;
break;
}
}
/** AC22-compatible init «перелив»: fixed green hue, saturation pulse. */
static void LED_RenderInitShimmer(void)
{
static uint8_t sat = 250U;
static uint8_t rising = 0U;
const uint8_t hue = 85U;
const uint8_t val = 245U;
if (sat >= 250U) {
rising = 0U;
}
if (sat <= 30U) {
rising = 1U;
}
if (rising) {
sat = (sat <= 246U) ? (uint8_t)(sat + 4U) : 250U;
} else {
sat = (sat >= 34U) ? (uint8_t)(sat - 4U) : 30U;
}
LED_HsvToRgb(hue, sat, val, &LED_State.color);
}
static LightingConfigPacket_t committed_lighting = {
.mode = 0,
.roles = {
{ 0, 128, 0, 100, 0, 40, 0 },
{ 0, 0, 255, 100, 1, 55, 100 },
{ 0, 255, 0, 100, 1, 40, 87 },
{ 255, 255, 255, 100, 0, 40, 0 },
{ 255, 0, 0, 100, 1, 50, 87 },
},
};
static LightingConfigPacket_t preview_lighting;
static uint32_t preview_expires_at;
static uint8_t preview_active;
static RGB_Cycle_t LED_CycleFromRole(const LightingRolePacket_t *role)
{
const uint8_t fade_to_black = role->fadeTo >= 95;
RGB_Cycle_t cycle = {
.Color1 = {
.R = (uint8_t)((uint16_t)role->r * role->brightness / 100),
.G = (uint8_t)((uint16_t)role->g * role->brightness / 100),
.B = (uint8_t)((uint16_t)role->b * role->brightness / 100),
},
.Tr = (uint8_t)((100 - role->speed) < 5 ? 5 : (100 - role->speed)),
.Th = 10,
.Tf = (uint8_t)((100 - role->speed) < 5 ? 5 : (100 - role->speed)),
.Tl = fade_to_black ? 10 : 0,
};
if (role->effect == 0) {
cycle.Color2 = cycle.Color1;
} else {
cycle.Color2.R = (uint8_t)((uint16_t)cycle.Color1.R * (100 - role->fadeTo) / 100);
cycle.Color2.G = (uint8_t)((uint16_t)cycle.Color1.G * (100 - role->fadeTo) / 100);
cycle.Color2.B = (uint8_t)((uint16_t)cycle.Color1.B * (100 - role->fadeTo) / 100);
}
return cycle;
}
static uint8_t LED_IsLightingConfigValid(const LightingConfigPacket_t *config)
{
if (config == NULL || config->mode > 1 || (config->flags & 0xFE) != 0 ||
config->reserved != 0 || ((config->flags & 0x01) && config->previewSec == 0) ||
(!(config->flags & 0x01) && config->previewSec != 0)) {
return 0;
}
for (uint8_t i = 0; i < 5; i++) {
const LightingRolePacket_t *role = &config->roles[i];
if (role->brightness > 100 || role->effect > 1 || role->speed > 100 || role->fadeTo > 100) {
return 0;
}
}
return 1;
}
uint8_t LED_ApplyLightingConfig(const LightingConfigPacket_t *config)
{
if (!LED_IsLightingConfigValid(config)) {
return 0;
}
if (config->flags & 0x01) {
memcpy(&preview_lighting, config, sizeof(preview_lighting));
preview_active = 1;
preview_expires_at = HAL_GetTick() + ((uint32_t)config->previewSec * 1000U);
} else {
memcpy(&committed_lighting, config, sizeof(committed_lighting));
preview_active = 0;
}
return 1;
}
void LED_Write(void)
{
const LightingConfigPacket_t *lighting = &committed_lighting;
RGB_Cycle_t cycle;
lighting_init_active = 0;
if (CONN.connControl == CMD_STOP) {
LED_SetColor(&color_estop);
return;
}
if (CONN.chargingError != CONN_NO_ERROR || CONN.connState == Disabled) {
cycle = LED_CycleFromRole(&lighting->roles[4]);
LED_SetColor(&cycle);
return;
}
if (preview_active && (int32_t)(HAL_GetTick() - preview_expires_at) >= 0) {
preview_active = 0;
}
if (preview_active) {
lighting = &preview_lighting;
}
if (lighting->mode == 1) {
RGB_Cycle_t off = { 0 };
LED_SetColor(&off);
return;
}
if (CONN.connControl == CMD_FORCE_UNLOCK) {
LED_SetColor(&color_unlock);
return;
}
if(CONN.connControl == CMD_STOP){
LED_SetColor(&color_estop);
if (CONN.connState == Unknown) {
lighting_init_active = 1;
return;
}
switch (CONN.connState) {
case Unknown:
LED_SetColor(&color_unknown);
break;
case Unplugged:
LED_SetColor(&color_unplugged);
break;
case Disabled:
LED_SetColor(&color_error);
cycle = LED_CycleFromRole(&lighting->roles[0]);
break;
case Preparing:
LED_SetColor(&color_preparing);
break;
case AuthRequired:
LED_SetColor(&color_preparing);
case Replugging:
cycle = LED_CycleFromRole(&lighting->roles[1]);
break;
case WaitingForEnergy:
LED_SetColor(&color_charging);
break;
case ChargingPausedEV:
LED_SetColor(&color_charging);
break;
case ChargingPausedEVSE:
LED_SetColor(&color_charging);
break;
case Charging:
LED_SetColor(&color_charging);
cycle = LED_CycleFromRole(&lighting->roles[2]);
break;
case AuthTimeout:
LED_SetColor(&color_finished);
break;
case Finished:
LED_SetColor(&color_finished);
break;
case FinishedEVSE:
LED_SetColor(&color_finished);
break;
case FinishedEV:
LED_SetColor(&color_finished);
break;
case Replugging:
LED_SetColor(&color_preparing);
cycle = LED_CycleFromRole(&lighting->roles[3]);
break;
default:
LED_SetColor(&color_unknown);
break;
lighting_init_active = 1;
return;
}
LED_SetColor(&cycle);
}
void interpolateColors(RGB_t* color1, RGB_t* color2, uint16_t a, uint16_t b, RGB_t *result) {
@@ -184,13 +269,150 @@ void interpolateColors(RGB_t* color1, RGB_t* color2, uint16_t a, uint16_t b, RGB
}
#pragma GCC push_options
#pragma GCC optimize("O2")
#define WS2812_T0H_NOP 25
#define WS2812_T0L_NOP 52
#define WS2812_T1H_NOP 52
#define WS2812_T1L_NOP 25
#define _WS2812_DELAY_NOPS(n) __asm volatile(".rept " #n "\nnop\n.endr" ::: "memory")
#define WS2812_DELAY_NOPS(n) _WS2812_DELAY_NOPS(n)
static void ws2812_send_pixel(uint8_t r, uint8_t g, uint8_t b)
{
uint32_t tmp = ~(((uint32_t)g << 16) | ((uint32_t)r << 8) | (uint32_t)b);
for (int i = 0; i < 24; i++) {
LED_DATA_GPIO_Port->BSRR = LED_DATA_Pin;
if (tmp & (1U << 23)) {
WS2812_DELAY_NOPS(WS2812_T0H_NOP);
LED_DATA_GPIO_Port->BRR = LED_DATA_Pin;
WS2812_DELAY_NOPS(WS2812_T0L_NOP);
} else {
WS2812_DELAY_NOPS(WS2812_T1H_NOP);
LED_DATA_GPIO_Port->BRR = LED_DATA_Pin;
WS2812_DELAY_NOPS(WS2812_T1L_NOP);
}
tmp <<= 1;
}
}
static void ws2812_update(RGB_t *led0, RGB_t *led1)
{
uint32_t primask = __get_PRIMASK();
__disable_irq();
ws2812_send_pixel(led0->R, led0->G, led0->B);
ws2812_send_pixel(led1->R, led1->G, led1->B);
__set_PRIMASK(primask);
}
#pragma GCC pop_options
static RGB_t RGB_ScaleBrightness(const RGB_t *color)
{
RGB_t out = {
.R = (uint8_t)((uint16_t)color->R * WS2812_BRIGHTNESS / 255),
.G = (uint8_t)((uint16_t)color->G * WS2812_BRIGHTNESS / 255),
.B = (uint8_t)((uint16_t)color->B * WS2812_BRIGHTNESS / 255),
};
return out;
}
/*
* Моргание красным на втором WS2812 при chargingError > 0.
* Логика как Slave-LB24 LED_Task: N вспышек = код ошибки, пауза 30×100 ms.
* Вызывается из LED_Task каждые 20 ms; шаг FSM — 100 ms.
*/
static void LED_Ws2812ErrorBlinkUpdate(void)
{
static uint8_t err_counter;
static uint8_t led_state;
static uint8_t led_pause;
static uint32_t blink_tick;
static uint32_t flash_until;
static CONN_Error_t last_error = CONN_NO_ERROR;
const CONN_Error_t err = CONN.chargingError;
const uint32_t now = HAL_GetTick();
if (err == CONN_NO_ERROR) {
err_counter = 0;
led_state = 0;
led_pause = 0;
flash_until = 0;
last_error = CONN_NO_ERROR;
ws2812_led1.R = 0;
ws2812_led1.G = 0;
ws2812_led1.B = 0;
return;
}
if (err != last_error) {
err_counter = 0;
led_state = 0;
led_pause = 0;
flash_until = 0;
last_error = err;
}
if (now < flash_until) {
ws2812_led1.R = 255;
ws2812_led1.G = 0;
ws2812_led1.B = 0;
return;
}
ws2812_led1.R = 0;
ws2812_led1.G = 0;
ws2812_led1.B = 0;
if ((now - blink_tick) < WS2812_ERROR_BLINK_MS) {
return;
}
blink_tick = now;
uint8_t led_flash = 0;
if (led_pause > 0) {
led_pause--;
} else if (err_counter < (uint8_t)err) {
if (led_state == 0) {
led_state = 1;
} else {
led_flash = 1;
led_state = 0;
err_counter++;
}
} else {
err_counter = 0;
led_pause = WS2812_ERROR_BLINK_PAUSE;
}
if (led_flash) {
flash_until = now + WS2812_ERROR_BLINK_MS;
ws2812_led1.R = 255;
ws2812_led1.G = 0;
ws2812_led1.B = 0;
}
}
void RGB_SetColor(RGB_t *color){
htim4.Instance->CCR2 = color->R * 100 / 255;
htim4.Instance->CCR3 = color->G * 100 / 255;
htim4.Instance->CCR4 = color->B * 100 / 255;
}
void LED_SetColor(RGB_Cycle_t *color){
void WS2812_SetColor(RGB_t *color){
RGB_t led0 = RGB_ScaleBrightness(color);
RGB_t led1 = RGB_ScaleBrightness(&ws2812_led1);
ws2812_update(&led0, &led1);
}
void LED_SetColor(const RGB_Cycle_t *color){
memcpy(&LED_Cycle, color, sizeof(RGB_Cycle_t));
}
@@ -201,38 +423,23 @@ void LED_Init(){
HAL_TIM_PWM_Start(&htim4, TIM_CHANNEL_3);
HAL_TIM_PWM_Start(&htim4, TIM_CHANNEL_4);
RGB_SetColor(&color);
WS2812_SetColor(&color);
}
// void LED_PhaseSync(uint8_t led_n){
// if(LED_State[led_n].phasesync){
// LED_State[led_n].phasesync = 0;
// //default settings
// LED_State[led_n].state = LED_HIGH;
// LED_State[led_n].tick = 0;
// //ищем среди всех светодиодов такую же последовательность
// for (uint8_t led_n1 = 0; led_n1 < 5; led_n1++){
// if ((LED_Cycle[led_n].Tf == LED_Cycle[led_n1].Tf) &&
// (LED_Cycle[led_n].Tr == LED_Cycle[led_n1].Tr) &&
// (LED_Cycle[led_n].Th == LED_Cycle[led_n1].Th) &&
// (LED_Cycle[led_n].Tl == LED_Cycle[led_n1].Tl) &&
// (led_n != led_n1)){
// //если нашли, то копируем фазу оттуда
// LED_State[led_n].state = LED_State[led_n1].state;
// LED_State[led_n].tick = LED_State[led_n1].tick;
// return;
// }
// }
// }
// }
void LED_Task(){
static uint32_t led_tick;
if((HAL_GetTick() - led_tick) > 20){
led_tick = HAL_GetTick();
LED_Ws2812ErrorBlinkUpdate();
if (lighting_init_active) {
LED_RenderInitShimmer();
RGB_SetColor(&LED_State.color);
WS2812_SetColor(&LED_State.color);
return;
}
LED_State.tick++;
// LED_PhaseSync(led_n);
switch(LED_State.state){
case LED_RISING:
interpolateColors(&LED_Cycle.Color2, &LED_Cycle.Color1, LED_State.tick, LED_Cycle.Tr, &LED_State.color);
@@ -270,5 +477,6 @@ void LED_Task(){
LED_State.state = LED_RISING;
}
RGB_SetColor(&LED_State.color);
WS2812_SetColor(&LED_State.color);
}
}
+30 -54
View File
@@ -1,15 +1,16 @@
#include "serial.h"
#include "cp.h"
#include "connector.h"
#include "board.h"
#include "charger_config.h"
#include "connector.h"
#include "cp.h"
#include "debug.h"
#include "isr_opt.h"
#include "psu_control.h"
#include "power_setpoint_executor.h"
#include "serial_control.h"
#include <stdint.h>
#include <string.h>
#include "charger_config.h"
#include "psu_control.h"
#include "serial_control.h"
#include "fire_alarm.h"
extern UART_HandleTypeDef huart3;
extern uint8_t config_initialized;
@@ -29,15 +30,9 @@ CONN_Control_t last_cmd = CMD_NONE;
uint8_t ev_enable_output = 0;
#define CMD_INTERVAL 10
#define MAX_TX_BUFFER_SIZE 256
#define MAX_RX_BUFFER_SIZE 256
#define EVEREST_TIMEOUT_WARN_MS 5000u
#define EVEREST_TIMEOUT_STOP_MS 10000u
#define UART3_REINIT_TIMEOUT_MS 1500u
/* Everest requests 500 V -> PSU really gets 300 V / 1 A, state still reports 500 V. */
#define FAKE_EVREQ_VOLTAGE_V 500u
#define FAKE_PSU_VOLTAGE_V 300u
#define FAKE_PSU_CURRENT_0P1A 10u
static uint8_t rx_buffer[MAX_RX_BUFFER_SIZE];
static uint8_t tx_buffer[MAX_TX_BUFFER_SIZE];
@@ -52,7 +47,6 @@ static uint8_t enabled = 0;
static uint8_t pwm_duty_percent = 100;
uint8_t isolation_enable = 0;
static uint32_t last_host_seen = 0;
static uint8_t fake_500_voltage_mode = 0;
static uint8_t everest_timed_out = 0;
static uint8_t everest_timeout_warn_latched = 0;
static uint8_t everest_timeout_stop_latched = 0;
@@ -176,7 +170,6 @@ void CCS_SerialLoop(void) {
static uint32_t stop_tick = 0;
CCS_UART3_Watchdog();
FireAlarm_Maintain();
if (CONN.connControl != CMD_NONE) {
last_cmd = CONN.connControl;
@@ -218,8 +211,7 @@ void CCS_SerialLoop(void) {
if (((CONN.connControl == CMD_STOP) ||
(CONN.connControl == CMD_FORCE_UNLOCK) ||
(CONN.chargingError != CONN_NO_ERROR) ||
FireAlarm_IsLatched()) &&
(CONN.chargingError != CONN_NO_ERROR)) &&
((int32_t)(HAL_GetTick() - last_stop_sent) > 1000)) {
last_stop_sent = HAL_GetTick();
log_printf(LOG_WARN, "Stopping charging...\n");
@@ -262,10 +254,6 @@ void CCS_SerialLoop(void) {
everest_timed_out = host_timeout_stop;
switch(CCS_ConnectorState){
case CCS_UNKNOWN:
if (FireAlarm_IsLatched()) {
CCS_ConnectorState = CCS_DISABLED;
break;
}
RELAY_Write(RELAY_CP, 0);
CONN_SetState(Unknown);
if (config_initialized && !host_timed_out) {
@@ -275,15 +263,11 @@ void CCS_SerialLoop(void) {
case CCS_DISABLED:
RELAY_Write(RELAY_CP, 0);
CONN_SetState(Disabled);
if (!FireAlarm_IsLatched() && (CONN.chargingError == CONN_NO_ERROR) && !host_timed_out){
if ((CONN.chargingError == CONN_NO_ERROR) && !host_timed_out){
CCS_ConnectorState = CCS_UNPLUGGED;
}
break;
case CCS_UNPLUGGED:
if (FireAlarm_IsLatched()) {
CCS_ConnectorState = CCS_DISABLED;
break;
}
RELAY_Write(RELAY_CP, 1);
CONN_SetState(Unplugged);
if ((cp_state_buffer == EV_STATE_B_CONN_PREP) || (cp_state_buffer == EV_STATE_C_CONN_ACTIVE)){
@@ -296,10 +280,6 @@ void CCS_SerialLoop(void) {
break;
case CCS_AUTH_REQUIRED:
if (FireAlarm_IsLatched()) {
CCS_ConnectorState = CCS_DISABLED;
break;
}
RELAY_Write(RELAY_CP, 1);
CONN_SetState(AuthRequired);
if(CONN.connControl == CMD_START){
@@ -312,10 +292,6 @@ void CCS_SerialLoop(void) {
}
break;
case CCS_CONNECTED:
if (FireAlarm_IsLatched()) {
CCS_ConnectorState = CCS_DISABLED;
break;
}
RELAY_Write(RELAY_CP, 1);
if((CCS_EvseState < Preparing) || (CCS_EvseState == AuthRequired)) {
CONN_SetState(Preparing);
@@ -332,10 +308,6 @@ void CCS_SerialLoop(void) {
}
break;
case CCS_REPLUGGING:
if (FireAlarm_IsLatched()) {
CCS_ConnectorState = CCS_DISABLED;
break;
}
RELAY_Write(RELAY_CP, 0);
CONN_SetState(Replugging);
if((int32_t)(HAL_GetTick() - replug_tick) > 1000){
@@ -358,19 +330,18 @@ void CCS_SerialLoop(void) {
}
// 10s timeout: enforce safe-state until host communication recovers.
if (FireAlarm_IsLatched()) {
CONN.EnableOutput = 0;
CP_SetDuty(100);
if (CCS_ConnectorState != CCS_DISABLED && CCS_ConnectorState != CCS_UNKNOWN) {
CCS_ConnectorState = CCS_DISABLED;
}
} else if (host_timeout_stop) {
{
static uint8_t prev_enable_output = 0xFFu;
uint8_t new_enable_output;
if (host_timeout_stop) {
CONN.EnableOutput = 0;
CCS_EvseState = Unknown;
CP_SetDuty(100);
if (CCS_ConnectorState != CCS_DISABLED && CCS_ConnectorState != CCS_UNKNOWN) {
CCS_ConnectorState = CCS_DISABLED;
}
new_enable_output = 0u;
} else {
if (last_cmd == CMD_STOP) {
CONN.EnableOutput = 0;
@@ -380,6 +351,20 @@ void CCS_SerialLoop(void) {
CONN.EnableOutput = 0;
}
}
new_enable_output = CONN.EnableOutput;
}
if (prev_enable_output != 0xFFu && prev_enable_output != new_enable_output) {
log_printf(LOG_INFO,
"EnableOutput %u->%u ev=%u stop=%u host_to=%u err=%u\n",
(unsigned)prev_enable_output,
(unsigned)new_enable_output,
(unsigned)ev_enable_output,
(unsigned)(last_cmd == CMD_STOP),
(unsigned)host_timeout_stop,
(unsigned)CONN.chargingError);
}
prev_enable_output = new_enable_output;
}
if ((cp_state_buffer == EV_STATE_B_CONN_PREP) ||
@@ -487,9 +472,6 @@ static void send_state(void) {
CCS_State.DutyCycle = CP_GetDuty();
CCS_State.OutputEnabled = PSU0.CONT_enabled;
CCS_State.MeasuredVoltage = (uint16_t)CONN.MeasuredVoltage;
if (fake_500_voltage_mode) {
CCS_State.MeasuredVoltage = FAKE_EVREQ_VOLTAGE_V;
}
CCS_State.MeasuredCurrent = (uint16_t)CONN.MeasuredCurrent;
CCS_State.Power = CCS_Power;
CCS_State.Energy = CCS_Energy;
@@ -567,15 +549,9 @@ ISR_FAST static void apply_command(uint8_t cmd, const uint8_t* payload, uint16_t
}
case CMD_E2M_SET_OUTPUT_VOLTAGE: {
const e2m_set_output_t* p = (const e2m_set_output_t*)payload;
if (p->voltage_V == FAKE_EVREQ_VOLTAGE_V) {
fake_500_voltage_mode = 1u;
CONN.RequestedVoltage = FAKE_PSU_VOLTAGE_V;
CONN.WantedCurrent = FAKE_PSU_CURRENT_0P1A;
} else {
fake_500_voltage_mode = 0u;
CONN.RequestedVoltage = p->voltage_V;
CONN.WantedCurrent = p->current_0p1A;
}
PowerSetpoint_OnCommand(p->voltage_V, p->current_0p1A);
break;
}
case CMD_E2M_ISOLATION_CONTROL: {
+3 -2
View File
@@ -1,9 +1,10 @@
#include "serial_control.h"
#include "usart.h"
#include "board.h"
#include "serial.h"
#include "debug.h"
#include "isr_opt.h"
#include "serial.h"
#include "usart.h"
// Приватные функции
ISR_FAST static uint32_t calculate_crc32(const uint8_t* data, uint16_t length);
+18 -15
View File
@@ -1,15 +1,16 @@
#include "serial_control.h"
#include "usart.h"
#include "charger_control.h"
#include "board.h"
#include "psu_control.h"
#include "charger_control.h"
#include "debug.h"
#include "fire_alarm.h"
#include "psu_control.h"
#include "rgb_controller.h"
#include "usart.h"
#include <string.h>
#ifdef USE_WEB_INTERFACE
extern volatile SC_Source_t g_sc_command_source;
static void monitoring_data_callback(void);
IsolationStatusPacket_t ISO = {
.isolationResistance = 0xFFFF
@@ -28,11 +29,6 @@ void SC_CommandHandler(ReceivedCommand_t* cmd) {
uint8_t response_code = RESP_FAILED;
if (FireAlarm_IsBlockingCommand(cmd->command)) {
SC_SendPacket(NULL, 0, RESP_FAILED);
return;
}
switch (cmd->command) {
// Команды БЕЗ аргументов
case CMD_GET_STATUS:
@@ -63,6 +59,14 @@ void SC_CommandHandler(ReceivedCommand_t* cmd) {
}
response_code = RESP_FAILED;
break;
case CMD_SET_LIGHTING:
if (cmd->argument_length == sizeof(LightingConfigPacket_t) &&
LED_ApplyLightingConfig((const LightingConfigPacket_t *)cmd->argument)) {
response_code = RESP_SUCCESS;
break;
}
response_code = RESP_FAILED;
break;
case CMD_SET_POWER_LIMIT:
if (cmd->argument_length == 1) {
PSU0.power_limit = ((uint8_t*)cmd->argument)[0] * 1000;
@@ -96,7 +100,6 @@ void SC_CommandHandler(ReceivedCommand_t* cmd) {
FireAlarm_Activate();
response_code = RESP_SUCCESS;
break;
case CMD_DEVICE_RESET:
// 2. Отправляем SUCCESS (хост может успеть получить его перед ребутом)
SC_SendPacket(NULL, 0, RESP_SUCCESS);
@@ -133,7 +136,7 @@ void SC_CommandHandler(ReceivedCommand_t* cmd) {
// Колбэк для заполнения данных мониторинга
void monitoring_data_callback() {
static void monitoring_data_callback(void) {
// Информация о зарядной сессии
statusPacket.SOC = CONN.SOC;
@@ -145,8 +148,9 @@ void monitoring_data_callback() {
statusPacket.outputEnabled = CONN.outputEnabled;
statusPacket.chargingError = CONN.chargingError;
statusPacket.connState = CONN.connState;
statusPacket.chargingElapsedTimeMin = 0;
statusPacket.chargingElapsedTimeSec = 0;
CONN_GetElapsedForMonitoring(
&statusPacket.chargingElapsedTimeMin,
&statusPacket.chargingElapsedTimeSec);
statusPacket.estimatedRemainingChargingTime = 0;
// состояние зарядной станции
@@ -213,4 +217,3 @@ void monitoring_data_callback() {
}
#endif
+2 -22
View File
@@ -1,11 +1,4 @@
/*
* rtc.c
*
* Created on: Jul 22, 2024
* Author: colorbass
*/
#include <soft_rtc.h>
#include "soft_rtc.h"
#include <stdint.h>
#include <time.h>
@@ -63,20 +56,7 @@ uint8_t getTimeReg(uint8_t reg_number){
}else{
return 0x00;
}
};
//int main() {
// uint32_t unix_time = 1672531199; // Example Unix timestamp
// uint8_t time[8];
//
// unix_to_bcd(unix_time, time);
//
// // Print the BCD values for verification
// for (int i = 0; i < 8; i++) {
// log_printf(LOG_INFO, "time[%d]: %02X\n", i, time[i]);
// }
//
// return 0;
//}
}
/**
* @brief Read the time counter available in RTC_CNT registers.
+1 -17
View File
@@ -1,21 +1,5 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file stm32f1xx_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 ------------------------------------------------------------------*/
+1 -16
View File
@@ -1,20 +1,5 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file stm32f1xx_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 ------------------------------------------------------------------*/
+1 -17
View File
@@ -1,21 +1,5 @@
/* 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"
+4 -20
View File
@@ -1,21 +1,5 @@
/* 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"
@@ -167,10 +151,10 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
PC12 ------> UART5_TX
PD2 ------> UART5_RX
*/
GPIO_InitStruct.Pin = GPIO_PIN_12;
GPIO_InitStruct.Pin = HEATER_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
HAL_GPIO_Init(HEATER_GPIO_Port, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_2;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
@@ -361,7 +345,7 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle)
PC12 ------> UART5_TX
PD2 ------> UART5_RX
*/
HAL_GPIO_DeInit(GPIOC, GPIO_PIN_12);
HAL_GPIO_DeInit(HEATER_GPIO_Port, HEATER_Pin);
HAL_GPIO_DeInit(GPIOD, GPIO_PIN_2);
BIN
View File
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+4660 -3581
View File
File diff suppressed because it is too large Load Diff
Binary file not shown.
BIN
View File
Binary file not shown.
-5
View File
@@ -1,5 +0,0 @@
../Core/Src/adc.c:29:6:ADC_ScanStart 2
../Core/Src/adc.c:37:15:HAL_ADC_ConvCpltCallback 2
../Core/Src/adc.c:59:6:MX_ADC1_Init 8
../Core/Src/adc.c:146:6:HAL_ADC_MspInit 3
../Core/Src/adc.c:200:6:HAL_ADC_MspDeInit 2
-13
View File
@@ -1,13 +0,0 @@
../Core/Src/board.c:18:6:RELAY_Write 9
../Core/Src/board.c:51:9:RELAY_Read 1
../Core/Src/board.c:56:9:IN_ReadInput 8
../Core/Src/board.c:77:9:GetBoardTemp 1
../Core/Src/board.c:89:6:Init_Peripheral 1
../Core/Src/board.c:106:7:pt1000_to_temperature 1
../Core/Src/board.c:117:7:calculate_NTC_resistance 2
../Core/Src/board.c:132:9:CONN_ReadTemp 4
../Core/Src/board.c:152:9:GBT_ReadTemp 1
../Core/Src/board.c:156:6:ADC_Select_Channel 2
../Core/Src/board.c:167:9:ADC_TryLock 4
../Core/Src/board.c:183:6:ADC_LockBlocking 2
../Core/Src/board.c:189:6:ADC_Unlock 2
-4
View File
@@ -1,4 +0,0 @@
../Core/Src/can.c:31:6:MX_CAN1_Init 2
../Core/Src/can.c:63:6:MX_CAN2_Init 2
../Core/Src/can.c:97:6:HAL_CAN_MspInit 5
../Core/Src/can.c:176:6:HAL_CAN_MspDeInit 5
-5
View File
@@ -1,5 +0,0 @@
../Core/Src/charger_control.c:13:6:CONN_Init 1
../Core/Src/charger_control.c:21:6:CONN_Loop 7
../Core/Src/charger_control.c:50:6:CONN_Task 1
../Core/Src/charger_control.c:57:6:CONN_SetState 16
../Core/Src/charger_control.c:83:6:CONN_PrintChargingTotal 1
-2
View File
@@ -1,2 +0,0 @@
../Core/Src/connector.c:12:6:CONN_Task 5
../Core/Src/connector.c:28:6:CONN_SetState 16
-9
View File
@@ -1,9 +0,0 @@
../Core/Src/cp.c:19:16:CP_ReadVoltageMv 1
../Core/Src/cp.c:36:6:CP_Init 1
../Core/Src/cp.c:53:6:CP_SetDuty 1
../Core/Src/cp.c:66:9:CP_GetDuty 1
../Core/Src/cp.c:70:9:CP_GetVoltage 1
../Core/Src/cp.c:75:12:CP_GetState 12
../Core/Src/cp.c:99:12:CP_GetFilteredState 1
../Core/Src/cp.c:103:6:CP_FilterState 5
../Core/Src/cp.c:131:6:CP_Loop 5
-3
View File
@@ -1,3 +0,0 @@
../Core/Src/crc.c:30:6:MX_CRC_Init 2
../Core/Src/crc.c:51:6:HAL_CRC_MspInit 2
../Core/Src/crc.c:67:6:HAL_CRC_MspDeInit 2
-5
View File
@@ -1,5 +0,0 @@
../Core/Src/debug.c:42:5:_write 1
../Core/Src/debug.c:50:6:debug_buffer_add 3
../Core/Src/debug.c:70:10:debug_buffer_available 1
../Core/Src/debug.c:79:6:debug_buffer_send 5
../Core/Src/debug.c:119:5:log_printf 3
-1
View File
@@ -1 +0,0 @@
../Core/Src/dma.c:39:6:MX_DMA_Init 1
-4
View File
@@ -1,4 +0,0 @@
../Core/Src/fire_alarm.c:14:9:FireAlarm_IsLatched 1
../Core/Src/fire_alarm.c:18:9:FireAlarm_IsBlockingCommand 8
../Core/Src/fire_alarm.c:34:6:FireAlarm_Activate 2
../Core/Src/fire_alarm.c:53:6:FireAlarm_Maintain 6
-3
View File
@@ -1,3 +0,0 @@
../Core/Src/gbt_control.c:10:6:GBT_SetConfig 1
../Core/Src/gbt_control.c:24:6:GBT_ControlRead 1
../Core/Src/gbt_control.c:33:6:GBT_ControlWrite 2
-1
View File
@@ -1 +0,0 @@
../Core/Src/gpio.c:44:6:MX_GPIO_Init 1
-9
View File
@@ -1,9 +0,0 @@
../Drivers/CMSIS/Include/core_cm3.h:1762:34:__NVIC_SystemReset 1
../Core/Src/main.c:65:13:VectorBase_Config 1
../Core/Src/main.c:76:9:ED_TraceWarning 3
../Core/Src/main.c:88:6:ED_Delay 3
../Core/Src/main.c:108:6:StopButtonControl 8
../Core/Src/main.c:151:13:CAN1_MinimalReInit 3
../Core/Src/main.c:169:5:main 1
../Core/Src/main.c:250:6:SystemClock_Config 4
../Core/Src/main.c:310:6:Error_Handler 1
-1
View File
@@ -1 +0,0 @@
../Core/Src/meter.c:17:6:METER_CalculateEnergy 3
-12
View File
@@ -1,12 +0,0 @@
../Core/Src/psu_control.c:34:13:PSU_SwitchState 1
../Core/Src/psu_control.c:39:17:PSU_StateTime 1
../Core/Src/psu_control.c:43:15:HAL_CAN_RxFifo1MsgPendingCallback 9
../Core/Src/psu_control.c:117:6:PSU_CAN_FilterInit 2
../Core/Src/psu_control.c:140:6:PSU_Init 1
../Core/Src/psu_control.c:158:6:PSU_Enable 3
../Core/Src/psu_control.c:170:6:PSU_SetHVMode 2
../Core/Src/psu_control.c:177:6:PSU_SetVoltageCurrent 5
../Core/Src/psu_control.c:204:6:PSU_SendCmd 4
../Core/Src/psu_control.c:240:10:max 2
../Core/Src/psu_control.c:245:6:PSU_ReadWrite 8
../Core/Src/psu_control.c:289:6:PSU_Task 41
-6
View File
@@ -1,6 +0,0 @@
../Core/Src/rgb_controller.c:103:6:LED_Write 20
../Core/Src/rgb_controller.c:169:6:interpolateColors 3
../Core/Src/rgb_controller.c:187:6:RGB_SetColor 1
../Core/Src/rgb_controller.c:193:6:LED_SetColor 1
../Core/Src/rgb_controller.c:198:6:LED_Init 1
../Core/Src/rgb_controller.c:230:6:LED_Task 10
-3
View File
@@ -1,3 +0,0 @@
../Core/Src/rtc.c:14:6:MX_RTC_Init 2
../Core/Src/rtc.c:40:6:HAL_RTC_MspInit 2
../Core/Src/rtc.c:59:6:HAL_RTC_MspDeInit 2
-20
View File
@@ -1,20 +0,0 @@
../Core/Src/serial.c:71:22:uart3_log_hal_error 3
../Core/Src/serial.c:91:22:uart3_arm_rx_or_log 3
../Core/Src/serial.c:107:15:CCS_RxEventCallback 4
../Core/Src/serial.c:130:15:HAL_UART_ErrorCallback 5
../Core/Src/serial.c:150:6:CCS_TxCpltCallback 4
../Core/Src/serial.c:166:6:CCS_SerialLoop 72
../Core/Src/serial.c:394:6:CCS_Init 1
../Core/Src/serial.c:409:26:crc16_ibm 3
../Core/Src/serial.c:424:17:CCS_BuildPacket 4
../Core/Src/serial.c:440:13:CCS_SendPacket 4
../Core/Src/serial.c:457:13:CCS_SendResetReason 1
../Core/Src/serial.c:461:6:CCS_SendEmergencyStop 1
../Core/Src/serial.c:465:6:CCS_SendStart 1
../Core/Src/serial.c:469:13:CCS_CalculateEnergy 2
../Core/Src/serial.c:484:13:send_state 3
../Core/Src/serial.c:514:26:expected_payload_len 2
../Core/Src/serial.c:530:22:apply_command 15
../Core/Src/serial.c:612:25:process_received_packet 8
../Core/Src/serial.c:665:13:CCS_UART3_Watchdog 4
../Core/Src/serial.c:678:13:CCS_LogUart3Error 1
-15
View File
@@ -1,15 +0,0 @@
../Core/Src/serial_control.c:71:6:ReadVersion 1
../Core/Src/serial_control.c:83:6:SC_Init 1
../Core/Src/serial_control.c:94:6:SC_Task 7
../Core/Src/serial_control.c:122:15:HAL_UARTEx_RxEventCallback 8
../Core/Src/serial_control.c:152:15:HAL_UART_TxCpltCallback 3
../Core/Src/serial_control.c:163:26:calculate_crc32 3
../Core/Src/serial_control.c:180:26:encode_packet 5
../Core/Src/serial_control.c:213:15:SC_SendPacket 4
../Core/Src/serial_control.c:230:25:parse_packet 3
../Core/Src/serial_control.c:263:25:process_received_packet 2
../Core/Src/serial_control.c:272:13:SC_UART2_Watchdog 5
../Core/Src/serial_control.c:293:13:SC_ArmUart2RxDma 4
../Core/Src/serial_control.c:301:13:SC_ArmUart5RxDma 3
../Core/Src/serial_control.c:310:6:SC_RecoverUartDma 3
../Core/Src/serial_control.c:325:13:SC_LogUartError 3
-3
View File
@@ -1,3 +0,0 @@
../Drivers/CMSIS/Include/core_cm3.h:1762:34:__NVIC_SystemReset 1
../Core/Src/serial_handler.c:27:6:SC_CommandHandler 21
../Core/Src/serial_handler.c:136:6:monitoring_data_callback 1
-2
View File
@@ -1,2 +0,0 @@
../Core/Src/sma_filter.c:3:6:SMAFilter_Init 3
../Core/Src/sma_filter.c:16:9:SMAFilter_Update 6
-10
View File
@@ -1,10 +0,0 @@
../Core/Src/soft_rtc.c:22:10:get_Current_Time 1
../Core/Src/soft_rtc.c:26:6:set_Time 1
../Core/Src/soft_rtc.c:30:9:to_bcd 1
../Core/Src/soft_rtc.c:34:6:unix_to_bcd 1
../Core/Src/soft_rtc.c:48:6:writeTimeReg 2
../Core/Src/soft_rtc.c:53:9:getTimeReg 5
../Core/Src/soft_rtc.c:87:17:RTC1_ReadTimeCounter 2
../Core/Src/soft_rtc.c:119:26:RTC1_WriteTimeCounter 3
../Core/Src/soft_rtc.c:151:26:RTC1_EnterInitMode 3
../Core/Src/soft_rtc.c:178:26:RTC1_ExitInitMode 3
-1
View File
@@ -1 +0,0 @@
../Core/Src/stm32f1xx_hal_msp.c:63:6:HAL_MspInit 1
-23
View File
@@ -1,23 +0,0 @@
../Core/Src/stm32f1xx_it.c:84:6:NMI_Handler 1
../Core/Src/stm32f1xx_it.c:99:6:HardFault_Handler 1
../Core/Src/stm32f1xx_it.c:114:6:MemManage_Handler 1
../Core/Src/stm32f1xx_it.c:129:6:BusFault_Handler 1
../Core/Src/stm32f1xx_it.c:144:6:UsageFault_Handler 1
../Core/Src/stm32f1xx_it.c:159:6:SVC_Handler 1
../Core/Src/stm32f1xx_it.c:172:6:DebugMon_Handler 1
../Core/Src/stm32f1xx_it.c:185:6:PendSV_Handler 1
../Core/Src/stm32f1xx_it.c:198:6:SysTick_Handler 1
../Core/Src/stm32f1xx_it.c:219:6:DMA1_Channel1_IRQHandler 1
../Core/Src/stm32f1xx_it.c:233:6:DMA1_Channel2_IRQHandler 1
../Core/Src/stm32f1xx_it.c:247:6:DMA1_Channel3_IRQHandler 1
../Core/Src/stm32f1xx_it.c:261:6:DMA1_Channel6_IRQHandler 1
../Core/Src/stm32f1xx_it.c:275:6:DMA1_Channel7_IRQHandler 1
../Core/Src/stm32f1xx_it.c:289:6:ADC1_2_IRQHandler 1
../Core/Src/stm32f1xx_it.c:303:6:CAN1_RX0_IRQHandler 1
../Core/Src/stm32f1xx_it.c:317:6:TIM3_IRQHandler 1
../Core/Src/stm32f1xx_it.c:331:6:USART1_IRQHandler 1
../Core/Src/stm32f1xx_it.c:345:6:USART2_IRQHandler 1
../Core/Src/stm32f1xx_it.c:359:6:USART3_IRQHandler 1
../Core/Src/stm32f1xx_it.c:373:6:UART5_IRQHandler 1
../Core/Src/stm32f1xx_it.c:387:6:CAN2_TX_IRQHandler 1
../Core/Src/stm32f1xx_it.c:401:6:CAN2_RX1_IRQHandler 1
-105
View File
@@ -1,105 +0,0 @@
################################################################################
# Automatically-generated file. Do not edit!
# Toolchain: GNU Tools for STM32 (13.3.rel1)
################################################################################
# Add inputs and outputs from these tool invocations to the build variables
C_SRCS += \
../Core/Src/adc.c \
../Core/Src/board.c \
../Core/Src/can.c \
../Core/Src/charger_control.c \
../Core/Src/cp.c \
../Core/Src/crc.c \
../Core/Src/debug.c \
../Core/Src/dma.c \
../Core/Src/fire_alarm.c \
../Core/Src/gpio.c \
../Core/Src/main.c \
../Core/Src/meter.c \
../Core/Src/psu_control.c \
../Core/Src/rgb_controller.c \
../Core/Src/rtc.c \
../Core/Src/serial.c \
../Core/Src/serial_control.c \
../Core/Src/serial_handler.c \
../Core/Src/sma_filter.c \
../Core/Src/soft_rtc.c \
../Core/Src/stm32f1xx_hal_msp.c \
../Core/Src/stm32f1xx_it.c \
../Core/Src/syscalls.c \
../Core/Src/sysmem.c \
../Core/Src/system_stm32f1xx.c \
../Core/Src/tim.c \
../Core/Src/usart.c
C_DEPS += \
./Core/Src/adc.d \
./Core/Src/board.d \
./Core/Src/can.d \
./Core/Src/charger_control.d \
./Core/Src/cp.d \
./Core/Src/crc.d \
./Core/Src/debug.d \
./Core/Src/dma.d \
./Core/Src/fire_alarm.d \
./Core/Src/gpio.d \
./Core/Src/main.d \
./Core/Src/meter.d \
./Core/Src/psu_control.d \
./Core/Src/rgb_controller.d \
./Core/Src/rtc.d \
./Core/Src/serial.d \
./Core/Src/serial_control.d \
./Core/Src/serial_handler.d \
./Core/Src/sma_filter.d \
./Core/Src/soft_rtc.d \
./Core/Src/stm32f1xx_hal_msp.d \
./Core/Src/stm32f1xx_it.d \
./Core/Src/syscalls.d \
./Core/Src/sysmem.d \
./Core/Src/system_stm32f1xx.d \
./Core/Src/tim.d \
./Core/Src/usart.d
OBJS += \
./Core/Src/adc.o \
./Core/Src/board.o \
./Core/Src/can.o \
./Core/Src/charger_control.o \
./Core/Src/cp.o \
./Core/Src/crc.o \
./Core/Src/debug.o \
./Core/Src/dma.o \
./Core/Src/fire_alarm.o \
./Core/Src/gpio.o \
./Core/Src/main.o \
./Core/Src/meter.o \
./Core/Src/psu_control.o \
./Core/Src/rgb_controller.o \
./Core/Src/rtc.o \
./Core/Src/serial.o \
./Core/Src/serial_control.o \
./Core/Src/serial_handler.o \
./Core/Src/sma_filter.o \
./Core/Src/soft_rtc.o \
./Core/Src/stm32f1xx_hal_msp.o \
./Core/Src/stm32f1xx_it.o \
./Core/Src/syscalls.o \
./Core/Src/sysmem.o \
./Core/Src/system_stm32f1xx.o \
./Core/Src/tim.o \
./Core/Src/usart.o
# Each subdirectory must supply rules for building sources it contributes
Core/Src/%.o Core/Src/%.su Core/Src/%.cyclo: ../Core/Src/%.c Core/Src/subdir.mk
arm-none-eabi-gcc "$<" -mcpu=cortex-m3 -std=gnu11 -g3 -DDEBUG -DUSE_HAL_DRIVER -DSTM32F107xC -c -I../Core/Inc -I../Drivers/STM32F1xx_HAL_Driver/Inc -I../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy -I../Drivers/CMSIS/Device/ST/STM32F1xx/Include -I../Drivers/CMSIS/Include -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" --specs=nano.specs -mfloat-abi=soft -mthumb -o "$@"
clean: clean-Core-2f-Src
clean-Core-2f-Src:
-$(RM) ./Core/Src/adc.cyclo ./Core/Src/adc.d ./Core/Src/adc.o ./Core/Src/adc.su ./Core/Src/board.cyclo ./Core/Src/board.d ./Core/Src/board.o ./Core/Src/board.su ./Core/Src/can.cyclo ./Core/Src/can.d ./Core/Src/can.o ./Core/Src/can.su ./Core/Src/charger_control.cyclo ./Core/Src/charger_control.d ./Core/Src/charger_control.o ./Core/Src/charger_control.su ./Core/Src/cp.cyclo ./Core/Src/cp.d ./Core/Src/cp.o ./Core/Src/cp.su ./Core/Src/crc.cyclo ./Core/Src/crc.d ./Core/Src/crc.o ./Core/Src/crc.su ./Core/Src/debug.cyclo ./Core/Src/debug.d ./Core/Src/debug.o ./Core/Src/debug.su ./Core/Src/dma.cyclo ./Core/Src/dma.d ./Core/Src/dma.o ./Core/Src/dma.su ./Core/Src/fire_alarm.cyclo ./Core/Src/fire_alarm.d ./Core/Src/fire_alarm.o ./Core/Src/fire_alarm.su ./Core/Src/gpio.cyclo ./Core/Src/gpio.d ./Core/Src/gpio.o ./Core/Src/gpio.su ./Core/Src/main.cyclo ./Core/Src/main.d ./Core/Src/main.o ./Core/Src/main.su ./Core/Src/meter.cyclo ./Core/Src/meter.d ./Core/Src/meter.o ./Core/Src/meter.su ./Core/Src/psu_control.cyclo ./Core/Src/psu_control.d ./Core/Src/psu_control.o ./Core/Src/psu_control.su ./Core/Src/rgb_controller.cyclo ./Core/Src/rgb_controller.d ./Core/Src/rgb_controller.o ./Core/Src/rgb_controller.su ./Core/Src/rtc.cyclo ./Core/Src/rtc.d ./Core/Src/rtc.o ./Core/Src/rtc.su ./Core/Src/serial.cyclo ./Core/Src/serial.d ./Core/Src/serial.o ./Core/Src/serial.su ./Core/Src/serial_control.cyclo ./Core/Src/serial_control.d ./Core/Src/serial_control.o ./Core/Src/serial_control.su ./Core/Src/serial_handler.cyclo ./Core/Src/serial_handler.d ./Core/Src/serial_handler.o ./Core/Src/serial_handler.su ./Core/Src/sma_filter.cyclo ./Core/Src/sma_filter.d ./Core/Src/sma_filter.o ./Core/Src/sma_filter.su ./Core/Src/soft_rtc.cyclo ./Core/Src/soft_rtc.d ./Core/Src/soft_rtc.o ./Core/Src/soft_rtc.su ./Core/Src/stm32f1xx_hal_msp.cyclo ./Core/Src/stm32f1xx_hal_msp.d ./Core/Src/stm32f1xx_hal_msp.o ./Core/Src/stm32f1xx_hal_msp.su ./Core/Src/stm32f1xx_it.cyclo ./Core/Src/stm32f1xx_it.d ./Core/Src/stm32f1xx_it.o ./Core/Src/stm32f1xx_it.su ./Core/Src/syscalls.cyclo ./Core/Src/syscalls.d ./Core/Src/syscalls.o ./Core/Src/syscalls.su ./Core/Src/sysmem.cyclo ./Core/Src/sysmem.d ./Core/Src/sysmem.o ./Core/Src/sysmem.su ./Core/Src/system_stm32f1xx.cyclo ./Core/Src/system_stm32f1xx.d ./Core/Src/system_stm32f1xx.o ./Core/Src/system_stm32f1xx.su ./Core/Src/tim.cyclo ./Core/Src/tim.d ./Core/Src/tim.o ./Core/Src/tim.su ./Core/Src/usart.cyclo ./Core/Src/usart.d ./Core/Src/usart.o ./Core/Src/usart.su
.PHONY: clean-Core-2f-Src
-18
View File
@@ -1,18 +0,0 @@
../Core/Src/syscalls.c:44:6:initialise_monitor_handles 1
../Core/Src/syscalls.c:48:5:_getpid 1
../Core/Src/syscalls.c:53:5:_kill 1
../Core/Src/syscalls.c:61:6:_exit 1
../Core/Src/syscalls.c:67:27:_read 2
../Core/Src/syscalls.c:80:27:_write 2
../Core/Src/syscalls.c:92:5:_close 1
../Core/Src/syscalls.c:99:5:_fstat 1
../Core/Src/syscalls.c:106:5:_isatty 1
../Core/Src/syscalls.c:112:5:_lseek 1
../Core/Src/syscalls.c:120:5:_open 1
../Core/Src/syscalls.c:128:5:_wait 1
../Core/Src/syscalls.c:135:5:_unlink 1
../Core/Src/syscalls.c:142:5:_times 1
../Core/Src/syscalls.c:148:5:_stat 1
../Core/Src/syscalls.c:155:5:_link 1
../Core/Src/syscalls.c:163:5:_fork 1
../Core/Src/syscalls.c:169:5:_execve 1
-1
View File
@@ -1 +0,0 @@
../Core/Src/sysmem.c:53:7:_sbrk 3
-2
View File
@@ -1,2 +0,0 @@
../Core/Src/system_stm32f1xx.c:175:6:SystemInit 1
../Core/Src/system_stm32f1xx.c:224:6:SystemCoreClockUpdate 8
-5
View File
@@ -1,5 +0,0 @@
../Core/Src/tim.c:31:6:MX_TIM3_Init 8
../Core/Src/tim.c:95:6:MX_TIM4_Init 8
../Core/Src/tim.c:157:6:HAL_TIM_Base_MspInit 3
../Core/Src/tim.c:187:6:HAL_TIM_MspPostInit 3
../Core/Src/tim.c:235:6:HAL_TIM_Base_MspDeInit 3

Some files were not shown because too many files have changed in this diff Show More