Initial commit
This commit is contained in:
273
.cproject
Normal file
273
.cproject
Normal file
@@ -0,0 +1,273 @@
|
||||
<?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.889467840">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.889467840" 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="" errorParsers="org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.CWDLocator;org.eclipse.cdt.core.GCCErrorParser" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.889467840" 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.889467840." name="/" resourcePath="">
|
||||
<toolChain id="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.debug.790718464" 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.convertverilog.487490376" name="Convert to Verilog file (-O verilog)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.convertverilog" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.showsize.1267376833" name="Show size information about built artifact" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.showsize" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.converthex.1939906552" 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.convertsymbolsrec.200974614" name="Convert to Motorola S-record (symbols) file (-O symbolsrec)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.convertsymbolsrec" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.convertbinary.305347085" name="Convert to binary file (-O binary)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.convertbinary" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.convertsrec.126267895" name="Convert to Motorola S-record file (-O srec)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.convertsrec" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu.2006653348" 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_board.1735449080" 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.instructionset.1587280773" name="Instruction set" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.instructionset" useByScannerDiscovery="true" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.instructionset.value.thumb2" valueType="enumerated"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.181464863" name="Floating-point ABI" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi" useByScannerDiscovery="true" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.value.soft" valueType="enumerated"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu.385755946" name="Floating-point unit" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu" useByScannerDiscovery="true" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu.value.none" valueType="enumerated"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_cpuid.1513035601" 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.169473098" 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.runtimelibrary_c.560534009" name="Runtime library" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.runtimelibrary_c" useByScannerDiscovery="true" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.runtimelibrary_c.value.nano_c" valueType="enumerated"/>
|
||||
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform.1658501236" isAbstract="false" osList="all" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform"/>
|
||||
<builder buildPath="${workspace_loc:/BMS_v2}/Debug" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder.245082461" keepEnvironmentInBuildfile="false" name="Gnu Make Builder" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder"/>
|
||||
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.2138221794" 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.1515574608" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.value.g3" valueType="enumerated"/>
|
||||
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input.2133497953" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input"/>
|
||||
</tool>
|
||||
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.713526699" 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.1470303212" 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.g" valueType="enumerated"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.2023232157" 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 id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.ffunction.1429929661" name="Place functions in their own sections (-ffunction-sections)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.ffunction" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.fdata.450593484" name="Place data in their own sections (-fdata-sections)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.fdata" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths.1428886539" 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="../USB_DEVICE/App"/>
|
||||
<listOptionValue builtIn="false" value="../USB_DEVICE/Target"/>
|
||||
<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="../Middlewares/ST/STM32_USB_Device_Library/Core/Inc"/>
|
||||
<listOptionValue builtIn="false" value="../Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc"/>
|
||||
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Device/ST/STM32F1xx/Include"/>
|
||||
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Include"/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/BMS_v3/FATFS/Target}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/BMS_v3/Middlewares/Third_Party/FatFs/src}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/BMS_v3/FATFS/App}""/>
|
||||
</option>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols.1889788482" 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.otherflags.257112675" name="Other flags" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.otherflags" useByScannerDiscovery="true" valueType="stringList">
|
||||
<listOptionValue builtIn="false" value="-fcommon"/>
|
||||
</option>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.languagestandard.1278783455" name="Language standard" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.languagestandard" useByScannerDiscovery="true" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.languagestandard.value.gnu11" valueType="enumerated"/>
|
||||
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.1900817136" 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.208518287" 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.1662196597" 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.2439824" 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.og" valueType="enumerated"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.ffunction.1288185583" name="Place functions in their own sections (-ffunction-sections)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.ffunction" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.fdata.934245785" name="Place data in their own sections (-fdata-sections)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.fdata" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.noexceptions.1462336223" name="Disable handling exceptions (-fno-exceptions)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.noexceptions" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.nortti.834328789" name="Disable generation of information about every class with virtual functions (-fno-rtti)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.nortti" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.includepaths.1043193887" name="Include paths (-I)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.includepaths" useByScannerDiscovery="false" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="../USB_DEVICE/App"/>
|
||||
<listOptionValue builtIn="false" value="../USB_DEVICE/Target"/>
|
||||
<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="../Middlewares/ST/STM32_USB_Device_Library/Core/Inc"/>
|
||||
<listOptionValue builtIn="false" value="../Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc"/>
|
||||
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Device/ST/STM32F1xx/Include"/>
|
||||
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Include"/>
|
||||
</option>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.definedsymbols.739392240" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.definedsymbols" useByScannerDiscovery="false" valueType="definedSymbols">
|
||||
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
|
||||
<listOptionValue builtIn="false" value="STM32F107xC"/>
|
||||
</option>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="true" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.otherflags.334944548" name="Other flags" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.otherflags" useByScannerDiscovery="true" valueType="stringList"/>
|
||||
</tool>
|
||||
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.2136376380" 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.1111452979" name="Linker Script (-T)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.script" useByScannerDiscovery="false" value="../STM32F107VCTx_FLASH.ld" valueType="string"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.gcsections.1165034409" name="Discard unused sections (-Wl,--gc-sections)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.gcsections" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.systemcalls.1499763252" name="System calls" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.systemcalls" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.systemcalls.value.minimalimplementation" valueType="enumerated"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.otherflags.842497115" name="Other flags" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.otherflags" useByScannerDiscovery="false" valueType="stringList">
|
||||
<listOptionValue builtIn="false" value="-u_printf_float"/>
|
||||
</option>
|
||||
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.input.921493411" 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.1393674634" name="MCU G++ Linker" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker">
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.option.script.489108637" name="Linker Script (-T)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.option.script" value="../STM32F107VCTx_FLASH.ld" valueType="string"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.option.gcsections.852868084" name="Discard unused sections (-Wl,--gc-sections)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.option.gcsections" value="true" valueType="boolean"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.option.otherflags.1060173923" name="Other flags" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.option.otherflags"/>
|
||||
</tool>
|
||||
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.archiver.1000985315" 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.474986712" 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.1584526714" 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.483770605" 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.1962709763" 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.1626614708" 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.1827426583" 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.145456910" 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" kind="sourcePath" name="startup"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="USB_DEVICE"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="Middlewares"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="Drivers"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="Core"/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
<cconfiguration id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.701804892">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.701804892" 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.701804892" 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.701804892." name="/" resourcePath="">
|
||||
<toolChain id="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.release.1118959152" 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.convertverilog.1005802254" name="Convert to Verilog file (-O verilog)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.convertverilog" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.showsize.607758994" name="Show size information about built artifact" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.showsize" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.converthex.1403728396" 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.convertsymbolsrec.1791142605" name="Convert to Motorola S-record (symbols) file (-O symbolsrec)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.convertsymbolsrec" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.convertbinary.1870449599" name="Convert to binary file (-O binary)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.convertbinary" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.convertsrec.483446177" name="Convert to Motorola S-record file (-O srec)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.convertsrec" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu.978188544" 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_board.541010248" 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.instructionset.364395835" name="Instruction set" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.instructionset" useByScannerDiscovery="true" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.instructionset.value.thumb2" valueType="enumerated"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.72668292" name="Floating-point ABI" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi" useByScannerDiscovery="true" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.value.soft" valueType="enumerated"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu.451755257" name="Floating-point unit" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu" useByScannerDiscovery="true" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu.value.none" valueType="enumerated"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_cpuid.285269395" 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.132246512" 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.runtimelibrary_c.544478664" name="Runtime library" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.runtimelibrary_c" useByScannerDiscovery="true" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.runtimelibrary_c.value.nano_c" valueType="enumerated"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.runtimelibrary_cpp.140664137" name="Runtime library" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.runtimelibrary_cpp" useByScannerDiscovery="true" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.runtimelibrary_cpp.value.nano_c_nano_cpp" valueType="enumerated"/>
|
||||
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform.441704572" isAbstract="false" osList="all" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform"/>
|
||||
<builder buildPath="${workspace_loc:/BMS_v2}/Release" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder.375594320" keepEnvironmentInBuildfile="false" name="Gnu Make Builder" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder"/>
|
||||
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.1054588656" 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.2125530472" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel" useByScannerDiscovery="false" 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.2079852435" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input"/>
|
||||
</tool>
|
||||
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1266801965" 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.1427795036" 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.619693745" 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.og" valueType="enumerated"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.ffunction.123590378" name="Place functions in their own sections (-ffunction-sections)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.ffunction" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.fdata.1393562981" name="Place data in their own sections (-fdata-sections)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.fdata" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths.1019588072" 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="../USB_DEVICE/App"/>
|
||||
<listOptionValue builtIn="false" value="../USB_DEVICE/Target"/>
|
||||
<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="../Middlewares/ST/STM32_USB_Device_Library/Core/Inc"/>
|
||||
<listOptionValue builtIn="false" value="../Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc"/>
|
||||
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Device/ST/STM32F1xx/Include"/>
|
||||
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Include"/>
|
||||
</option>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols.390483859" 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="true" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.otherflags.2024131576" name="Other flags" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.otherflags" useByScannerDiscovery="true" valueType="stringList"/>
|
||||
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.111418448" 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.269961560" 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.843370608" 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.1732073733" 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.og" valueType="enumerated"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.ffunction.127706151" name="Place functions in their own sections (-ffunction-sections)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.ffunction" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.fdata.1220352459" name="Place data in their own sections (-fdata-sections)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.fdata" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.noexceptions.1569649006" name="Disable handling exceptions (-fno-exceptions)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.noexceptions" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.nortti.1302080300" name="Disable generation of information about every class with virtual functions (-fno-rtti)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.nortti" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.includepaths.930252425" name="Include paths (-I)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.includepaths" useByScannerDiscovery="false" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="../USB_DEVICE/App"/>
|
||||
<listOptionValue builtIn="false" value="../USB_DEVICE/Target"/>
|
||||
<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="../Middlewares/ST/STM32_USB_Device_Library/Core/Inc"/>
|
||||
<listOptionValue builtIn="false" value="../Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc"/>
|
||||
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Device/ST/STM32F1xx/Include"/>
|
||||
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Include"/>
|
||||
</option>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="true" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.otherflags.1890454030" name="Other flags" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.otherflags" useByScannerDiscovery="true" valueType="stringList"/>
|
||||
</tool>
|
||||
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.1921589734" 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.2003806800" name="Linker Script (-T)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.script" value="../STM32F107VCTx_FLASH.ld" valueType="string"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.gcsections.770300945" name="Discard unused sections (-Wl,--gc-sections)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.gcsections" value="true" valueType="boolean"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.systemcalls.683834985" name="System calls" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.systemcalls" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.systemcalls.value.minimalimplementation" valueType="enumerated"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.otherflags.1563034163" name="Other flags" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.otherflags" valueType="stringList">
|
||||
<listOptionValue builtIn="false" value=""/>
|
||||
</option>
|
||||
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.input.2116323897" 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.432540644" name="MCU G++ Linker" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker">
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.option.script.852462870" name="Linker Script (-T)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.option.script" value="../STM32F107VCTx_FLASH.ld" valueType="string"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.option.gcsections.1508250858" name="Discard unused sections (-Wl,--gc-sections)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.option.gcsections" value="true" valueType="boolean"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.option.systemcalls.16663388" name="System calls" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.option.systemcalls" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.option.systemcalls.value.minimalimplementation" valueType="enumerated"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.option.otherflags.1427994056" name="Other flags" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.option.otherflags" valueType="stringList">
|
||||
<listOptionValue builtIn="false" value=""/>
|
||||
</option>
|
||||
</tool>
|
||||
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.archiver.1208532752" 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.1167143474" 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.961738795" 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.346638481" 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.2129475810" 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.1235005080" 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.1279993133" 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.369369009" 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" kind="sourcePath" name="startup"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="USB_DEVICE"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="Middlewares"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="Drivers"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="Core"/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<project id="bms_s_cube.fr.ac6.managedbuild.target.gnu.cross.exe.1717897125" name="Executable"/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||
<storageModule moduleId="refreshScope" versionNumber="2">
|
||||
<configuration configurationName="Debug">
|
||||
<resource resourceType="PROJECT" workspacePath="/bms_s_cube"/>
|
||||
</configuration>
|
||||
<configuration configurationName="Release"/>
|
||||
</storageModule>
|
||||
<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.debug.889467840;com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.889467840.;com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.713526699;com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.1900817136">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="fr.ac6.managedbuild.config.gnu.cross.exe.debug.390580388;fr.ac6.managedbuild.config.gnu.cross.exe.debug.390580388.;fr.ac6.managedbuild.tool.gnu.cross.c.compiler.1881810371;fr.ac6.managedbuild.tool.gnu.cross.c.compiler.input.c.965869334">
|
||||
<autodiscovery enabled="false" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</scannerConfigBuildInfo>
|
||||
</storageModule>
|
||||
</cproject>
|
||||
257
.cproject_org
Normal file
257
.cproject_org
Normal file
@@ -0,0 +1,257 @@
|
||||
<?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="fr.ac6.managedbuild.config.gnu.cross.exe.debug.390580388">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="fr.ac6.managedbuild.config.gnu.cross.exe.debug.390580388" 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="fr.ac6.managedbuild.config.gnu.cross.exe.debug.390580388" name="Debug" parent="fr.ac6.managedbuild.config.gnu.cross.exe.debug" postannouncebuildStep="Generating hex and Printing size information:" postbuildStep="arm-none-eabi-objcopy -O ihex "${BuildArtifactFileBaseName}.elf" "${BuildArtifactFileBaseName}.hex" && arm-none-eabi-size "${BuildArtifactFileName}"">
|
||||
<folderInfo id="fr.ac6.managedbuild.config.gnu.cross.exe.debug.390580388." name="/" resourcePath="">
|
||||
<toolChain id="fr.ac6.managedbuild.toolchain.gnu.cross.exe.debug.1014208713" name="Ac6 STM32 MCU GCC" superClass="fr.ac6.managedbuild.toolchain.gnu.cross.exe.debug">
|
||||
<option id="fr.ac6.managedbuild.option.gnu.cross.prefix.139675596" name="Prefix" superClass="fr.ac6.managedbuild.option.gnu.cross.prefix" useByScannerDiscovery="false" value="arm-none-eabi-" valueType="string"/>
|
||||
<option id="fr.ac6.managedbuild.option.gnu.cross.mcu.544253679" name="Mcu" superClass="fr.ac6.managedbuild.option.gnu.cross.mcu" useByScannerDiscovery="false" value="STM32F107VCTx" valueType="string"/>
|
||||
<option id="fr.ac6.managedbuild.option.gnu.cross.board.503768300" name="Board" superClass="fr.ac6.managedbuild.option.gnu.cross.board" useByScannerDiscovery="false" value="bms_s_cube" valueType="string"/>
|
||||
<option id="fr.ac6.managedbuild.option.gnu.cross.core.1083960614" name="Core" superClass="fr.ac6.managedbuild.option.gnu.cross.core" useByScannerDiscovery="false" valueType="stringList">
|
||||
<listOptionValue builtIn="false" value="ARM Cortex-M3"/>
|
||||
<listOptionValue builtIn="false" value="CM3"/>
|
||||
</option>
|
||||
<option id="fr.ac6.managedbuild.option.gnu.cross.instructionSet.1562226012" name="Instruction Set" superClass="fr.ac6.managedbuild.option.gnu.cross.instructionSet" useByScannerDiscovery="false" value="fr.ac6.managedbuild.option.gnu.cross.instructionSet.thumbII" valueType="enumerated"/>
|
||||
<option id="fr.ac6.managedbuild.option.gnu.cross.fpu.1331187893" name="Floating point hardware" superClass="fr.ac6.managedbuild.option.gnu.cross.fpu" useByScannerDiscovery="false" value="fr.ac6.managedbuild.option.gnu.cross.fpu.no" valueType="enumerated"/>
|
||||
<option id="fr.ac6.managedbuild.option.gnu.cross.floatabi.110348793" name="Floating-point ABI" superClass="fr.ac6.managedbuild.option.gnu.cross.floatabi" useByScannerDiscovery="false" value="fr.ac6.managedbuild.option.gnu.cross.floatabi.soft" valueType="enumerated"/>
|
||||
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="fr.ac6.managedbuild.targetPlatform.gnu.cross.245080103" isAbstract="false" osList="all" superClass="fr.ac6.managedbuild.targetPlatform.gnu.cross"/>
|
||||
<builder buildPath="${workspace_loc:/bms_s_cube}/Debug" id="fr.ac6.managedbuild.builder.gnu.cross.1415409813" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="fr.ac6.managedbuild.builder.gnu.cross">
|
||||
<outputEntries>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="outputPath" name="Debug"/>
|
||||
</outputEntries>
|
||||
</builder>
|
||||
<tool id="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.1881810371" name="MCU GCC Compiler" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.compiler">
|
||||
<option defaultValue="gnu.c.optimization.level.none" id="fr.ac6.managedbuild.gnu.c.compiler.option.optimization.level.986412169" name="Optimization Level" superClass="fr.ac6.managedbuild.gnu.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="fr.ac6.managedbuild.gnu.c.optimization.level.none" valueType="enumerated"/>
|
||||
<option id="gnu.c.compiler.option.debugging.level.630446846" name="Debug Level" superClass="gnu.c.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.c.debugging.level.max" valueType="enumerated"/>
|
||||
<option id="gnu.c.compiler.option.include.paths.579804173" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="../USB_DEVICE/App"/>
|
||||
<listOptionValue builtIn="false" value="../USB_DEVICE/Target"/>
|
||||
<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="../Middlewares/ST/STM32_USB_Device_Library/Core/Inc"/>
|
||||
<listOptionValue builtIn="false" value="../Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc"/>
|
||||
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Device/ST/STM32F1xx/Include"/>
|
||||
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Include"/>
|
||||
</option>
|
||||
<option id="gnu.c.compiler.option.preprocessor.def.symbols.903935306" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" useByScannerDiscovery="false" valueType="definedSymbols">
|
||||
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
|
||||
<listOptionValue builtIn="false" value="STM32F107xC"/>
|
||||
</option>
|
||||
<option id="fr.ac6.managedbuild.gnu.c.compiler.option.misc.other.1449937591" superClass="fr.ac6.managedbuild.gnu.c.compiler.option.misc.other" useByScannerDiscovery="false" value="-fmessage-length=0" valueType="string"/>
|
||||
<option id="gnu.c.compiler.option.dialect.std.1949579639" name="Language standard" superClass="gnu.c.compiler.option.dialect.std" useByScannerDiscovery="true" value="gnu.c.compiler.dialect.default" valueType="enumerated"/>
|
||||
<inputType id="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.input.c.965869334" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.input.c"/>
|
||||
<inputType id="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.input.s.1047310569" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.input.s"/>
|
||||
</tool>
|
||||
<tool id="fr.ac6.managedbuild.tool.gnu.cross.cpp.compiler.1559336118" name="MCU G++ Compiler" superClass="fr.ac6.managedbuild.tool.gnu.cross.cpp.compiler">
|
||||
<option defaultValue="gnu.cpp.optimization.level.none" id="fr.ac6.managedbuild.gnu.cpp.compiler.option.optimization.level.529495401" name="Optimization Level" superClass="fr.ac6.managedbuild.gnu.cpp.compiler.option.optimization.level" useByScannerDiscovery="false" value="fr.ac6.managedbuild.gnu.cpp.optimization.level.debug" valueType="enumerated"/>
|
||||
<option id="gnu.cpp.compiler.option.debugging.level.1750074118" name="Debug Level" superClass="gnu.cpp.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
|
||||
<option id="gnu.cpp.compiler.option.include.paths.565826390" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="../USB_DEVICE/App"/>
|
||||
<listOptionValue builtIn="false" value="../USB_DEVICE/Target"/>
|
||||
<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="../Middlewares/ST/STM32_USB_Device_Library/Core/Inc"/>
|
||||
<listOptionValue builtIn="false" value="../Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc"/>
|
||||
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Device/ST/STM32F1xx/Include"/>
|
||||
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Include"/>
|
||||
</option>
|
||||
<option id="gnu.cpp.compiler.option.preprocessor.def.593685131" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" useByScannerDiscovery="false" valueType="definedSymbols">
|
||||
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
|
||||
<listOptionValue builtIn="false" value="STM32F107xC"/>
|
||||
</option>
|
||||
<option id="fr.ac6.managedbuild.gnu.cpp.compiler.option.misc.other.604712611" name="Other flags" superClass="fr.ac6.managedbuild.gnu.cpp.compiler.option.misc.other" useByScannerDiscovery="false" value="-fmessage-length=0" valueType="string"/>
|
||||
<inputType id="fr.ac6.managedbuild.tool.gnu.cross.cpp.compiler.input.cpp.317863634" superClass="fr.ac6.managedbuild.tool.gnu.cross.cpp.compiler.input.cpp"/>
|
||||
<inputType id="fr.ac6.managedbuild.tool.gnu.cross.cpp.compiler.input.s.1003573747" superClass="fr.ac6.managedbuild.tool.gnu.cross.cpp.compiler.input.s"/>
|
||||
</tool>
|
||||
<tool id="fr.ac6.managedbuild.tool.gnu.cross.c.linker.169053044" name="MCU GCC Linker" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.linker">
|
||||
<option id="fr.ac6.managedbuild.tool.gnu.cross.c.linker.script.1553165415" name="Linker Script (-T)" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.linker.script" useByScannerDiscovery="false" value="../STM32F107VCTx_FLASH.ld" valueType="string"/>
|
||||
<option id="gnu.c.link.option.libs.2110858250" name="Libraries (-l)" superClass="gnu.c.link.option.libs" useByScannerDiscovery="false"/>
|
||||
<option id="gnu.c.link.option.paths.154932018" name="Library search path (-L)" superClass="gnu.c.link.option.paths" useByScannerDiscovery="false"/>
|
||||
<option id="gnu.c.link.option.ldflags.1460713607" name="Linker flags" superClass="gnu.c.link.option.ldflags" useByScannerDiscovery="false" value="-specs=nosys.specs -specs=nano.specs -u_printf_float" valueType="string"/>
|
||||
<option id="gnu.c.link.option.other.181616672" name="Other options (-Xlinker [option])" superClass="gnu.c.link.option.other" useByScannerDiscovery="false"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.1910896968" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
</inputType>
|
||||
</tool>
|
||||
<tool id="fr.ac6.managedbuild.tool.gnu.cross.cpp.linker.929601528" name="MCU G++ Linker" superClass="fr.ac6.managedbuild.tool.gnu.cross.cpp.linker">
|
||||
<option id="fr.ac6.managedbuild.tool.gnu.cross.cpp.linker.script.1159861204" name="Linker Script (-T)" superClass="fr.ac6.managedbuild.tool.gnu.cross.cpp.linker.script" value="../STM32F107VCTx_FLASH.ld" valueType="string"/>
|
||||
<option id="gnu.cpp.link.option.libs.1787484740" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs"/>
|
||||
<option id="gnu.cpp.link.option.paths.1772824783" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths"/>
|
||||
<option id="gnu.cpp.link.option.flags.1936979836" name="Linker flags" superClass="gnu.cpp.link.option.flags" value="-specs=nosys.specs -specs=nano.specs" valueType="string"/>
|
||||
<option id="gnu.cpp.link.option.other.942640585" name="Other options (-Xlinker [option])" superClass="gnu.cpp.link.option.other" useByScannerDiscovery="false"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.51480467" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
</inputType>
|
||||
</tool>
|
||||
<tool id="fr.ac6.managedbuild.tool.gnu.archiver.1162225735" name="MCU GCC Archiver" superClass="fr.ac6.managedbuild.tool.gnu.archiver"/>
|
||||
<tool id="fr.ac6.managedbuild.tool.gnu.cross.assembler.1902356751" name="MCU GCC Assembler" superClass="fr.ac6.managedbuild.tool.gnu.cross.assembler">
|
||||
<option id="gnu.both.asm.option.include.paths.1414415575" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" useByScannerDiscovery="false"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.188877911" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||
<inputType id="fr.ac6.managedbuild.tool.gnu.cross.assembler.input.578381987" superClass="fr.ac6.managedbuild.tool.gnu.cross.assembler.input"/>
|
||||
</tool>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="startup"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="USB_DEVICE"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Middlewares"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Drivers"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Core"/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
<cconfiguration id="fr.ac6.managedbuild.config.gnu.cross.exe.release.1302766797">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="fr.ac6.managedbuild.config.gnu.cross.exe.release.1302766797" 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="fr.ac6.managedbuild.config.gnu.cross.exe.release.1302766797" name="Release" parent="fr.ac6.managedbuild.config.gnu.cross.exe.release" postannouncebuildStep="Generating hex and Printing size information:" postbuildStep="arm-none-eabi-objcopy -O ihex "${BuildArtifactFileBaseName}.elf" "${BuildArtifactFileBaseName}.hex" && arm-none-eabi-size "${BuildArtifactFileName}"">
|
||||
<folderInfo id="fr.ac6.managedbuild.config.gnu.cross.exe.release.1302766797." name="/" resourcePath="">
|
||||
<toolChain id="fr.ac6.managedbuild.toolchain.gnu.cross.exe.release.121029803" name="Ac6 STM32 MCU GCC" superClass="fr.ac6.managedbuild.toolchain.gnu.cross.exe.release">
|
||||
<option id="fr.ac6.managedbuild.option.gnu.cross.prefix.139675596" name="Prefix" superClass="fr.ac6.managedbuild.option.gnu.cross.prefix" value="arm-none-eabi-" valueType="string"/>
|
||||
<option id="fr.ac6.managedbuild.option.gnu.cross.mcu.544253679" name="Mcu" superClass="fr.ac6.managedbuild.option.gnu.cross.mcu" value="STM32F107VCTx" valueType="string"/>
|
||||
<option id="fr.ac6.managedbuild.option.gnu.cross.board.503768300" name="Board" superClass="fr.ac6.managedbuild.option.gnu.cross.board" value="bms_s_cube" valueType="string"/>
|
||||
<option id="fr.ac6.managedbuild.option.gnu.cross.core.1083960614" name="Core" superClass="fr.ac6.managedbuild.option.gnu.cross.core" valueType="stringList">
|
||||
<listOptionValue builtIn="false" value="ARM Cortex-M3"/>
|
||||
<listOptionValue builtIn="false" value="CM3"/>
|
||||
</option>
|
||||
<option id="fr.ac6.managedbuild.option.gnu.cross.instructionSet.1562226012" name="Instruction Set" superClass="fr.ac6.managedbuild.option.gnu.cross.instructionSet" value="fr.ac6.managedbuild.option.gnu.cross.instructionSet.thumbII" valueType="enumerated"/>
|
||||
<option id="fr.ac6.managedbuild.option.gnu.cross.fpu.1331187893" name="Floating point hardware" superClass="fr.ac6.managedbuild.option.gnu.cross.fpu" value="fr.ac6.managedbuild.option.gnu.cross.fpu.no" valueType="enumerated"/>
|
||||
<option id="fr.ac6.managedbuild.option.gnu.cross.floatabi.110348793" name="Floating-point ABI" superClass="fr.ac6.managedbuild.option.gnu.cross.floatabi" value="fr.ac6.managedbuild.option.gnu.cross.floatabi.soft" valueType="enumerated"/>
|
||||
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="fr.ac6.managedbuild.targetPlatform.gnu.cross.245080103" isAbstract="false" osList="all" superClass="fr.ac6.managedbuild.targetPlatform.gnu.cross"/>
|
||||
<builder buildPath="${workspace_loc:/bms_s_cube}/Release" id="fr.ac6.managedbuild.builder.gnu.cross.1415409813" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="fr.ac6.managedbuild.builder.gnu.cross">
|
||||
<outputEntries>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="outputPath" name="Release"/>
|
||||
</outputEntries>
|
||||
</builder>
|
||||
<tool id="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.1881810371" name="MCU GCC Compiler" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.compiler">
|
||||
<option defaultValue="gnu.c.optimization.level.none" id="fr.ac6.managedbuild.gnu.c.compiler.option.optimization.level.986412169" name="Optimization Level" superClass="fr.ac6.managedbuild.gnu.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="fr.ac6.managedbuild.gnu.c.optimization.level.debug" valueType="enumerated"/>
|
||||
<option id="gnu.c.compiler.option.debugging.level.630446846" name="Debug Level" superClass="gnu.c.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.c.debugging.level.max" valueType="enumerated"/>
|
||||
<option id="gnu.c.compiler.option.include.paths.579804173" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="../USB_DEVICE/App"/>
|
||||
<listOptionValue builtIn="false" value="../USB_DEVICE/Target"/>
|
||||
<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="../Middlewares/ST/STM32_USB_Device_Library/Core/Inc"/>
|
||||
<listOptionValue builtIn="false" value="../Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc"/>
|
||||
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Device/ST/STM32F1xx/Include"/>
|
||||
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Include"/>
|
||||
</option>
|
||||
<option id="gnu.c.compiler.option.preprocessor.def.symbols.903935306" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" useByScannerDiscovery="false" valueType="definedSymbols">
|
||||
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
|
||||
<listOptionValue builtIn="false" value="STM32F107xC"/>
|
||||
</option>
|
||||
<option id="fr.ac6.managedbuild.gnu.c.compiler.option.misc.other.1449937591" superClass="fr.ac6.managedbuild.gnu.c.compiler.option.misc.other" useByScannerDiscovery="false" value="-fmessage-length=0" valueType="string"/>
|
||||
<inputType id="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.input.c.965869334" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.input.c"/>
|
||||
<inputType id="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.input.s.1047310569" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.input.s"/>
|
||||
</tool>
|
||||
<tool id="fr.ac6.managedbuild.tool.gnu.cross.cpp.compiler.1559336118" name="MCU G++ Compiler" superClass="fr.ac6.managedbuild.tool.gnu.cross.cpp.compiler">
|
||||
<option defaultValue="gnu.cpp.optimization.level.none" id="fr.ac6.managedbuild.gnu.cpp.compiler.option.optimization.level.529495401" name="Optimization Level" superClass="fr.ac6.managedbuild.gnu.cpp.compiler.option.optimization.level" useByScannerDiscovery="false" value="fr.ac6.managedbuild.gnu.cpp.optimization.level.debug" valueType="enumerated"/>
|
||||
<option id="gnu.cpp.compiler.option.debugging.level.1750074118" name="Debug Level" superClass="gnu.cpp.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.cpp.debugging.level.max" valueType="enumerated"/>
|
||||
<option id="gnu.cpp.compiler.option.include.paths.565826390" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="../USB_DEVICE/App"/>
|
||||
<listOptionValue builtIn="false" value="../USB_DEVICE/Target"/>
|
||||
<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="../Middlewares/ST/STM32_USB_Device_Library/Core/Inc"/>
|
||||
<listOptionValue builtIn="false" value="../Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc"/>
|
||||
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Device/ST/STM32F1xx/Include"/>
|
||||
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Include"/>
|
||||
</option>
|
||||
<option id="gnu.cpp.compiler.option.preprocessor.def.symbols.1054182349" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def.symbols" useByScannerDiscovery="false" valueType="definedSymbols">
|
||||
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
|
||||
<listOptionValue builtIn="false" value="STM32F107xC"/>
|
||||
</option>
|
||||
<option id="fr.ac6.managedbuild.gnu.cpp.compiler.option.misc.other.604712611" name="Other flags" superClass="fr.ac6.managedbuild.gnu.cpp.compiler.option.misc.other" useByScannerDiscovery="false" value="-fmessage-length=0" valueType="string"/>
|
||||
<inputType id="fr.ac6.managedbuild.tool.gnu.cross.cpp.compiler.input.cpp.317863634" superClass="fr.ac6.managedbuild.tool.gnu.cross.cpp.compiler.input.cpp"/>
|
||||
<inputType id="fr.ac6.managedbuild.tool.gnu.cross.cpp.compiler.input.s.1003573747" superClass="fr.ac6.managedbuild.tool.gnu.cross.cpp.compiler.input.s"/>
|
||||
</tool>
|
||||
<tool id="fr.ac6.managedbuild.tool.gnu.cross.c.linker.169053044" name="MCU GCC Linker" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.linker">
|
||||
<option id="fr.ac6.managedbuild.tool.gnu.cross.c.linker.script.1553165415" name="Linker Script (-T)" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.linker.script" value="../STM32F107VCTx_FLASH.ld" valueType="string"/>
|
||||
<option id="gnu.c.link.option.libs.2110858250" name="Libraries (-l)" superClass="gnu.c.link.option.libs"/>
|
||||
<option id="gnu.c.link.option.paths.154932018" name="Library search path (-L)" superClass="gnu.c.link.option.paths"/>
|
||||
<option id="gnu.c.link.option.ldflags.1460713607" name="Linker flags" superClass="gnu.c.link.option.ldflags" value="-specs=nosys.specs -specs=nano.specs" valueType="string"/>
|
||||
<option id="gnu.c.link.option.other.181616672" name="Other options (-Xlinker [option])" superClass="gnu.c.link.option.other" useByScannerDiscovery="false"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.1910896968" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
</inputType>
|
||||
</tool>
|
||||
<tool id="fr.ac6.managedbuild.tool.gnu.cross.cpp.linker.929601528" name="MCU G++ Linker" superClass="fr.ac6.managedbuild.tool.gnu.cross.cpp.linker">
|
||||
<option id="fr.ac6.managedbuild.tool.gnu.cross.cpp.linker.script.1159861204" name="Linker Script (-T)" superClass="fr.ac6.managedbuild.tool.gnu.cross.cpp.linker.script" value="../STM32F107VCTx_FLASH.ld" valueType="string"/>
|
||||
<option id="gnu.cpp.link.option.libs.1787484740" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs"/>
|
||||
<option id="gnu.cpp.link.option.paths.1772824783" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths"/>
|
||||
<option id="gnu.cpp.link.option.ldflags.497726998" superClass="gnu.cpp.link.option.ldflags" value="-specs=nosys.specs -specs=nano.specs" valueType="string"/>
|
||||
<option id="gnu.cpp.link.option.other.942640585" name="Other options (-Xlinker [option])" superClass="gnu.cpp.link.option.other" useByScannerDiscovery="false"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.51480467" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
</inputType>
|
||||
</tool>
|
||||
<tool id="fr.ac6.managedbuild.tool.gnu.archiver.1162225735" name="MCU GCC Archiver" superClass="fr.ac6.managedbuild.tool.gnu.archiver"/>
|
||||
<tool id="fr.ac6.managedbuild.tool.gnu.cross.assembler.exe.release.1931406915" name="MCU GCC Assembler" superClass="fr.ac6.managedbuild.tool.gnu.cross.assembler.exe.release">
|
||||
<option id="gnu.both.asm.option.include.paths.1414415575" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.188877911" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||
<inputType id="fr.ac6.managedbuild.tool.gnu.cross.assembler.input.578381987" superClass="fr.ac6.managedbuild.tool.gnu.cross.assembler.input"/>
|
||||
</tool>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="startup"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="USB_DEVICE"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Middlewares"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Drivers"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Core"/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<project id="bms_s_cube.fr.ac6.managedbuild.target.gnu.cross.exe.1717897125" name="Executable" projectType="fr.ac6.managedbuild.target.gnu.cross.exe"/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
<scannerConfigBuildInfo instanceId="fr.ac6.managedbuild.config.gnu.cross.exe.debug.390580388;fr.ac6.managedbuild.config.gnu.cross.exe.debug.390580388.;fr.ac6.managedbuild.tool.gnu.cross.c.compiler.1881810371;fr.ac6.managedbuild.tool.gnu.cross.c.compiler.input.c.965869334">
|
||||
<autodiscovery enabled="false" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</scannerConfigBuildInfo>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||
<storageModule moduleId="refreshScope" versionNumber="2">
|
||||
<configuration configurationName="Debug">
|
||||
<resource resourceType="PROJECT" workspacePath="/bms_s_cube"/>
|
||||
</configuration>
|
||||
<configuration configurationName="Release"/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
|
||||
</cproject>
|
||||
8
.gitignore
vendored
Normal file
8
.gitignore
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
*.log
|
||||
*.elf
|
||||
*.o
|
||||
*.d
|
||||
*.tmp
|
||||
*.list
|
||||
*.map
|
||||
/Debug/
|
||||
37
.mxproject
Normal file
37
.mxproject
Normal file
File diff suppressed because one or more lines are too long
49
.project
Normal file
49
.project
Normal file
@@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>BMS_v3</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||
<triggers>clean,full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
|
||||
<triggers>full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.cdt.core.cnature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
||||
<nature>com.st.stm32cube.ide.mcu.MCUSW4STM32ConvertedProjectNature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
||||
</natures>
|
||||
<linkedResources>
|
||||
<link>
|
||||
<name>USB_Device_Library/usbd_cdc.c</name>
|
||||
<type>1</type>
|
||||
<locationURI>PARENT-2-PROJECT_LOC/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>USB_Device_Library/usbd_core.c</name>
|
||||
<type>1</type>
|
||||
<locationURI>PARENT-2-PROJECT_LOC/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>USB_Device_Library/usbd_ctlreq.c</name>
|
||||
<type>1</type>
|
||||
<locationURI>PARENT-2-PROJECT_LOC/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>USB_Device_Library/usbd_ioreq.c</name>
|
||||
<type>1</type>
|
||||
<locationURI>PARENT-2-PROJECT_LOC/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c</locationURI>
|
||||
</link>
|
||||
</linkedResources>
|
||||
</projectDescription>
|
||||
49
.project_org
Normal file
49
.project_org
Normal file
@@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>BMS_v2</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||
<triggers>clean,full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
|
||||
<triggers>full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.cdt.core.cnature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
||||
<nature>fr.ac6.mcu.ide.core.MCUProjectNature</nature>
|
||||
</natures>
|
||||
<linkedResources>
|
||||
<link>
|
||||
<name>USB_Device_Library/usbd_cdc.c</name>
|
||||
<type>1</type>
|
||||
<locationURI>PARENT-2-PROJECT_LOC/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>USB_Device_Library/usbd_core.c</name>
|
||||
<type>1</type>
|
||||
<locationURI>PARENT-2-PROJECT_LOC/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>USB_Device_Library/usbd_ctlreq.c</name>
|
||||
<type>1</type>
|
||||
<locationURI>PARENT-2-PROJECT_LOC/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>USB_Device_Library/usbd_ioreq.c</name>
|
||||
<type>1</type>
|
||||
<locationURI>PARENT-2-PROJECT_LOC/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c</locationURI>
|
||||
</link>
|
||||
</linkedResources>
|
||||
</projectDescription>
|
||||
2
.settings/desktop.ini
Normal file
2
.settings/desktop.ini
Normal file
@@ -0,0 +1,2 @@
|
||||
[.ShellClassInfo]
|
||||
IconResource=C:\Program Files\Google\Drive File Stream\54.0.3.0\GoogleDriveFS.exe,23
|
||||
26
.settings/language.settings.xml
Normal file
26
.settings/language.settings.xml
Normal file
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<project>
|
||||
<configuration id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.889467840" name="Debug">
|
||||
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
|
||||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-674487765729842554" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||
</provider>
|
||||
</extension>
|
||||
</configuration>
|
||||
<configuration id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.701804892" name="Release">
|
||||
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
|
||||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
|
||||
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-625935826514445666" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||
</provider>
|
||||
</extension>
|
||||
</configuration>
|
||||
</project>
|
||||
74
.settings/org.eclipse.cdt.codan.core.prefs
Normal file
74
.settings/org.eclipse.cdt.codan.core.prefs
Normal file
@@ -0,0 +1,74 @@
|
||||
com.st.stm32cube.ide.mcu.ide.oss.source.checker.libnano.problem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Float formatting support\\")"}
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.cdt.codan.checkers.errnoreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"No return\\")",implicit\=>false}
|
||||
org.eclipse.cdt.codan.checkers.errreturnvalue.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused return value\\")"}
|
||||
org.eclipse.cdt.codan.checkers.localvarreturn=-Warning
|
||||
org.eclipse.cdt.codan.checkers.localvarreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Returning the address of a local variable\\")"}
|
||||
org.eclipse.cdt.codan.checkers.nocommentinside.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Nesting comments\\")"}
|
||||
org.eclipse.cdt.codan.checkers.nolinecomment.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Line comments\\")"}
|
||||
org.eclipse.cdt.codan.checkers.noreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"No return value\\")",implicit\=>false}
|
||||
org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Abstract class cannot be instantiated\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Ambiguous problem\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Assignment in condition\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Assignment to itself\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.BlacklistProblem=-Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.BlacklistProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Function or method is blacklisted\\")",blacklist\=>()}
|
||||
org.eclipse.cdt.codan.internal.checkers.CStyleCastProblem=-Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.CStyleCastProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"C-Style cast instead of C++ cast\\")",checkMacro\=>true}
|
||||
org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"No break at end of case\\")",no_break_comment\=>"no break",last_case_param\=>false,empty_case_param\=>false,enable_fallthrough_quickfix_param\=>false}
|
||||
org.eclipse.cdt.codan.internal.checkers.CatchByReference.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Catching by reference is recommended\\")",unknown\=>false,exceptions\=>()}
|
||||
org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Circular inheritance\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Class members should be properly initialized\\")",skip\=>true}
|
||||
org.eclipse.cdt.codan.internal.checkers.CopyrightProblem=-Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.CopyrightProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Lack of copyright information\\")",regex\=>".*Copyright.*"}
|
||||
org.eclipse.cdt.codan.internal.checkers.DecltypeAutoProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid 'decltype(auto)' specifier\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Field cannot be resolved\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.FloatCompareProblem=-Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.FloatCompareProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Direct float comparison\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Function cannot be resolved\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.GotoStatementProblem=-Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.GotoStatementProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Goto statement used\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.InvalidArguments.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid arguments\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid template argument\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Label statement not found\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.MagicNumberProblem=-Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.MagicNumberProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Avoid magic numbers\\")",checkArray\=>true,checkOperatorParen\=>true,exceptions\=>(1,0,-1,2,1.0,0.0,-1.0)}
|
||||
org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Member declaration not found\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Method cannot be resolved\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.MissCaseProblem=-Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.MissCaseProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Missing cases in switch\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.MissDefaultProblem=-Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.MissDefaultProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Missing default in switch\\")",defaultWithAllEnums\=>false}
|
||||
org.eclipse.cdt.codan.internal.checkers.MissReferenceProblem=-Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.MissReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Missing reference return value in assignment operator\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.MissSelfCheckProblem=-Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.MissSelfCheckProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Missing self check in assignment operator\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.MultipleDeclarationsProblem=-Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.MultipleDeclarationsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Multiple variable declaration\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Name convention for function\\")",pattern\=>"^[a-z]",macro\=>true,exceptions\=>()}
|
||||
org.eclipse.cdt.codan.internal.checkers.NoDiscardProblem=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.NoDiscardProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Return value not evaluated\\")",macro\=>true}
|
||||
org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Class has a virtual method and non-virtual destructor\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.OverloadProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid overload\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid redeclaration\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid redefinition\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Return with parenthesis\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Format String Vulnerability\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.ShallowCopyProblem=-Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.ShallowCopyProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Miss copy constructor or assignment operator\\")",onlynew\=>false}
|
||||
org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Statement has no effect\\")",macro\=>true,exceptions\=>()}
|
||||
org.eclipse.cdt.codan.internal.checkers.StaticVariableInHeaderProblem=-Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.StaticVariableInHeaderProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Static variable in header file\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Suggested parenthesis around expression\\")",paramNot\=>false}
|
||||
org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Suspicious semicolon\\")",else\=>false,afterelse\=>false}
|
||||
org.eclipse.cdt.codan.internal.checkers.SymbolShadowingProblem=-Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.SymbolShadowingProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Symbol shadowing\\")",paramFuncParameters\=>true}
|
||||
org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Type cannot be resolved\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused function declaration\\")",macro\=>true}
|
||||
org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused static function\\")",macro\=>true}
|
||||
org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused variable declaration in file scope\\")",macro\=>true,exceptions\=>("@(\#)","$Id")}
|
||||
org.eclipse.cdt.codan.internal.checkers.UsingInHeaderProblem=-Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.UsingInHeaderProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Using directive in header\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Symbol is not resolved\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.VirtualMethodCallProblem=-Error
|
||||
org.eclipse.cdt.codan.internal.checkers.VirtualMethodCallProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Virtual method call in constructor/destructor\\")"}
|
||||
6
.settings/org.eclipse.cdt.core.prefs
Normal file
6
.settings/org.eclipse.cdt.core.prefs
Normal file
@@ -0,0 +1,6 @@
|
||||
doxygen/doxygen_new_line_after_brief=true
|
||||
doxygen/doxygen_use_brief_tag=false
|
||||
doxygen/doxygen_use_javadoc_tags=true
|
||||
doxygen/doxygen_use_pre_tag=false
|
||||
doxygen/doxygen_use_structural_commands=false
|
||||
eclipse.preferences.version=1
|
||||
28
BMS_v2 Run.cfg
Normal file
28
BMS_v2 Run.cfg
Normal file
@@ -0,0 +1,28 @@
|
||||
# This is an bms_s_cube board with a single STM32F107VCTx chip
|
||||
#
|
||||
# Generated by System Workbench for STM32
|
||||
# Take care that such file, as generated, may be overridden without any early notice. Please have a look to debug launch configuration setup(s)
|
||||
|
||||
source [find interface/stlink.cfg]
|
||||
|
||||
set WORKAREASIZE 0x8000
|
||||
|
||||
transport select "hla_swd"
|
||||
|
||||
set CHIPNAME STM32F107VCTx
|
||||
set BOARDNAME bms_s_cube
|
||||
|
||||
# Enable debug when in low power modes
|
||||
set ENABLE_LOW_POWER 1
|
||||
|
||||
# Stop Watchdog counters when halt
|
||||
set STOP_WATCHDOG 1
|
||||
|
||||
# STlink Debug clock frequency
|
||||
set CLOCK_FREQ 4000
|
||||
|
||||
# use software system reset
|
||||
reset_config none
|
||||
set CONNECT_UNDER_RESET 0
|
||||
|
||||
source [find target/stm32f1x.cfg]
|
||||
80
BMS_v3 Debug.launch
Normal file
80
BMS_v3 Debug.launch
Normal file
@@ -0,0 +1,80 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="com.st.stm32cube.ide.mcu.debug.launch.launchConfigurationType">
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.access_port_id" value="0"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.enable_live_expr" value="true"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.enable_swv" value="false"/>
|
||||
<intAttribute key="com.st.stm32cube.ide.mcu.debug.launch.formatVersion" value="2"/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.ip_address_local" value="localhost"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.limit_swo_clock.enabled" value="false"/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.limit_swo_clock.value" value=""/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.loadList" value="{"fItems":[{"fIsFromMainTab":true,"fPath":"Debug/BMS_v3.elf","fProjectName":"BMS_v3","fPerformBuild":true,"fDownload":true,"fLoadSymbols":true}]}"/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.override_start_address_mode" value="default"/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.remoteCommand" value="target remote"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.startServer" value="true"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.startuptab.exception.divby0" value="true"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.startuptab.exception.unaligned" value="false"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.startuptab.haltonexception" value="true"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.swd_mode" value="true"/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.swv_port" value="61235"/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.swv_trace_hclk" value="16000000"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.useRemoteTarget" value="true"/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.vector_table" value=""/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.verify_flash_download" value="true"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.cti_allow_halt" value="false"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.cti_signal_halt" value="false"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.enable_external_loader" value="false"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.enable_logging" value="false"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.enable_max_halt_delay" value="false"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.enable_shared_stlink" value="false"/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.external_loader" value=""/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.external_loader_init" value="false"/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.frequency" value="0"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.halt_all_on_reset" value="false"/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.log_file" value="E:\GIT\BMS\Debug\st-link_gdbserver_log.txt"/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.low_power_debug" value="enable"/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.max_halt_delay" value="2"/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.reset_strategy" value="connect_under_reset"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.stlink_check_serial_number" value="false"/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.stlink_txt_serial_number" value=""/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.watchdog_config" value="none"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlinkenable_rtos" value="false"/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlinkrestart_configurations" value="{"fItems":[{"fDisplayName":"Reset","fIsSuppressible":false,"fResetAttribute":"Software system reset","fResetStrategies":[{"fDisplayName":"Software system reset","fLaunchAttribute":"system_reset","fGdbCommands":["monitor reset\r\n"],"fCmdOptions":["-g"]},{"fDisplayName":"Hardware reset","fLaunchAttribute":"hardware_reset","fGdbCommands":["monitor reset hardware\r\n"],"fCmdOptions":["-g"]},{"fDisplayName":"Core reset","fLaunchAttribute":"core_reset","fGdbCommands":["monitor reset core\r\n"],"fCmdOptions":["-g"]},{"fDisplayName":"None","fLaunchAttribute":"no_reset","fGdbCommands":[],"fCmdOptions":["-g"]}],"fGdbCommandGroup":{"name":"Additional commands","commands":[]}}]}"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.enableRtosProxy" value="false"/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyCustomProperties" value=""/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriver" value="threadx"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriverAuto" value="false"/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriverPort" value="cortex_m0"/>
|
||||
<intAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyPort" value="60000"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doHalt" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doReset" value="false"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.initCommands" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.ipAddress" value="localhost"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDeviceId" value="com.st.stm32cube.ide.mcu.debug.stlink"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value=""/>
|
||||
<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.portNumber" value="61234"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.runCommands" value=""/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setResume" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setStopAt" value="true"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.stopAt" value="main"/>
|
||||
<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="arm-none-eabi-gdb"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.NON_STOP" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.UPDATE_THREADLIST_ON_SUSPEND" value="false"/>
|
||||
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_START_MODE" value="remote"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN" value="true"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN_SYMBOL" value="main"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="Debug/BMS_v3.elf"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="BMS_v3"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="true"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.889467840"/>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/BMS_v3"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="4"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?><memoryBlockExpressionList context="reserved-for-future-use"/>"/>
|
||||
<stringAttribute key="process_factory_id" value="org.eclipse.cdt.dsf.gdb.GdbProcessFactory"/>
|
||||
</launchConfiguration>
|
||||
88
Core/Inc/DPC_Timeout.h
Normal file
88
Core/Inc/DPC_Timeout.h
Normal file
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
* @file Timeout.h
|
||||
* @author Smart Power - SRA CL
|
||||
* @version V1.0.0
|
||||
* @date 18-Dec-2019
|
||||
* @brief .
|
||||
* @details
|
||||
*
|
||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
|
||||
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
|
||||
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
|
||||
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
||||
*
|
||||
* THIS SOURCE CODE IS PROTECTED BY A LICENSE.
|
||||
* FOR MORE INFORMATION PLEASE CAREFULLY READ THE LICENSE AGREEMENT FILE LOCATED
|
||||
* IN THE ROOT DIRECTORY OF THIS FIRMWARE PACKAGE.
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2019 STMicroelectronics</center></h2>
|
||||
*/
|
||||
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __TIMEOUT_H
|
||||
#define __TIMEOUT_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stdint.h"
|
||||
#include "stddef.h"
|
||||
|
||||
|
||||
/** @defgroup Exported_Tyoedef Exported Typedef
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
typedef enum{
|
||||
TO_OFF = 0,
|
||||
TO_RUN,
|
||||
TO_TOOK
|
||||
} TO_STATE;
|
||||
|
||||
typedef struct{
|
||||
uint32_t Count;
|
||||
TO_STATE State;
|
||||
} TimeoutDataStr_T;
|
||||
|
||||
|
||||
|
||||
typedef enum{
|
||||
TO_OUT_ERR = 0,
|
||||
TO_OUT_OK,
|
||||
TO_OUT_TOOK
|
||||
} TO_RET_STATE;
|
||||
|
||||
#define TO_MAX_NUMBER 10
|
||||
|
||||
#define TO_LED 0
|
||||
#define TO_COM 1
|
||||
#define TO_UART 2
|
||||
#define TO_AT_TIMEOUT 3
|
||||
#define TO_SIM_TIMEOUT 4
|
||||
#define TO_HTTP_PARAM 5
|
||||
#define TO_SD_Card 6
|
||||
#define TO_SD_Filename 7
|
||||
|
||||
#define TEL_TIMEOUT_VAL 200
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup Exported_Functions Exported Functions
|
||||
* @{
|
||||
*/
|
||||
void DPC_TO_Init(void);
|
||||
TO_RET_STATE DPC_TO_Set(uint8_t TO_Num, uint32_t Val);
|
||||
TO_RET_STATE DPC_TO_Check(uint8_t TO_Num);
|
||||
void TimeoutMng(void);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#endif //TELEMETRY
|
||||
|
||||
/******************* (C) COPYRIGHT 2019 STMicroelectronics *****END OF FILE****/
|
||||
385
Core/Inc/GSM.h
Normal file
385
Core/Inc/GSM.h
Normal file
@@ -0,0 +1,385 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file GSM.h
|
||||
* @brief This file contains all the function prototypes for
|
||||
* the GSM.c file
|
||||
******************************************************************************
|
||||
*1. define SIM800_Global_Struct
|
||||
*2. start init functions
|
||||
SIM800_Var_Init(&SIM800_Struct);
|
||||
HTTP_Data_Init(&SIM800_Struct);
|
||||
*3. DPC_TO_Init();
|
||||
*4.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef __GSMMODULE_H
|
||||
#define __GSMMODULE_H
|
||||
|
||||
#include "main.h"
|
||||
#include "modconfig.h"
|
||||
|
||||
//#include "string.h"
|
||||
//#include "stdlib.h"
|
||||
|
||||
#define SIM_RESET_TIMEOUT 120000 //ms
|
||||
#define SIM_NETWORK_CHECK_TIMEOUT 120000
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t SIM_RX_Flag;
|
||||
char SIM_answer[1024];
|
||||
char* SIM_command;
|
||||
uint8_t Size;
|
||||
}SIM_Answer_Struct;
|
||||
|
||||
typedef struct {
|
||||
uint8_t year;
|
||||
uint8_t month;
|
||||
uint8_t day;
|
||||
uint8_t hour;
|
||||
uint8_t minute;
|
||||
uint8_t second;
|
||||
uint8_t timezone;
|
||||
}Time_Struct;
|
||||
|
||||
typedef struct{
|
||||
char* Serial_Number;
|
||||
char* Battery_Condition_ID;
|
||||
char* Event_time;
|
||||
char* Started_At_Time;
|
||||
char* Ended_At_Time;
|
||||
char* Status_Indication;
|
||||
char* Energy_Sum;
|
||||
char* Battery_Level_At_Start;
|
||||
char* Battery_Level_At_End;
|
||||
char* Battery_Voltage_At_Start;
|
||||
char* Battery_Voltage_At_End;
|
||||
char* Battery_Temperature_At_End;
|
||||
char* Latitude;
|
||||
char* Longitude;
|
||||
char* Maximum_Load_Current;
|
||||
char* Maximum_Charge_Current;
|
||||
char* Internal_Resistance;
|
||||
char* Moderated;
|
||||
char* Current_time;
|
||||
|
||||
char Serial_Number_var[10];
|
||||
char Battery_Condition_ID_var[10];
|
||||
char Event_time_var[30];
|
||||
char Started_At_Time_var[30];
|
||||
char Ended_At_Time_var[30];
|
||||
char Status_Indication_var[10];
|
||||
char Energy_Sum_var[10];
|
||||
char Battery_Level_At_Start_var[10];
|
||||
char Battery_Level_At_End_var[10];
|
||||
char Battery_Voltage_At_Start_var[10];
|
||||
char Battery_Voltage_At_End_var[10];
|
||||
char Battery_Temperature_At_End_var[10];
|
||||
char Latitude_var[10];
|
||||
char Longitude_var[10];
|
||||
char Maximum_Load_Current_var[10];
|
||||
char Maximum_Charge_Current_var[10];
|
||||
char Internal_Resistance_var[15];
|
||||
char Moderated_var[15];
|
||||
char Current_time_var[30];
|
||||
|
||||
}HTTP_DATA_Struct;
|
||||
|
||||
typedef enum{
|
||||
AT,
|
||||
ATE,
|
||||
ATV,
|
||||
ATW,
|
||||
ATCCLK,
|
||||
ATCMEE2,
|
||||
ATCLTS,
|
||||
ATCNMI,
|
||||
ATCREG,
|
||||
ATCCID,
|
||||
ATCSQ,
|
||||
ATCOPS,
|
||||
ATCOPS_Manual,
|
||||
ATHTTPSTATUS,
|
||||
|
||||
ATCGATT_check,
|
||||
ATCGATT_disconnect,
|
||||
ATCGATT_connect,
|
||||
ATSAPBR0,
|
||||
ATSAPBR1,
|
||||
ATSAPBR2,
|
||||
ATSAPBR3_1_CONTYPE,
|
||||
ATSAPBR3_1_APN,
|
||||
ATSAPBR3_1_USER,
|
||||
ATSAPBR3_1_PWD,
|
||||
ATSAPBR4_1,
|
||||
|
||||
|
||||
ATHTTP,
|
||||
ATHTTPPARA_CID,
|
||||
ATHTTPPARA_URL,
|
||||
ATHTTPPARA_URL_EVENT,
|
||||
ATHTTPPARA_CONTENT,
|
||||
ATHTTPPARA_USERDATA,
|
||||
ATHTTPPARA_PARAM,
|
||||
ATHTTPDATA,
|
||||
ATHTTPP_ACTION_POST,
|
||||
ATHTTPP_ACTION_GET,
|
||||
DATA0,
|
||||
DATA1,
|
||||
DATA2,
|
||||
ATHTTPREAD,
|
||||
ATHTTPREAD_REQ,
|
||||
ATHTTPHEAD,
|
||||
ATHTTPTERM,
|
||||
ATHTTPSSL,
|
||||
ATHTTPSSLREQUEST,
|
||||
ATCGMR,
|
||||
ATCDNSCFG,
|
||||
ATCDNSCFG_REQ,
|
||||
ATCIFSR,
|
||||
ATCIPSTATUS,
|
||||
ATCSTT,
|
||||
ATCIICR,
|
||||
ATCIPSHUT,
|
||||
ATCIPMUX,
|
||||
ATCIPGSMLOC,
|
||||
|
||||
REQUEST_START,
|
||||
REQUEST_FINISHED,
|
||||
READY_TO_OPERATE,
|
||||
NETWORK_CHECK,
|
||||
|
||||
GPS_Req,
|
||||
GET_ACTUAL_TIME,
|
||||
GPS_LBS_Change
|
||||
} Sim_Stages;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t Init_Complete;
|
||||
uint8_t GPRS_Established;
|
||||
uint8_t Permission_to_Send;
|
||||
}SIM800_States;
|
||||
|
||||
//PUT DATA STRUCT
|
||||
typedef struct{
|
||||
uint64_t Serial;
|
||||
uint8_t Battery_cond_ID;
|
||||
Time_Struct Event_time;
|
||||
Time_Struct Started_At_Time;
|
||||
Time_Struct Ended_At_Time;
|
||||
uint8_t Status_Indication;
|
||||
uint16_t Energy_Sum;
|
||||
uint16_t Battery_Level_At_Start;
|
||||
uint16_t Battery_Level_At_End;
|
||||
float Battery_Voltage_At_Start;
|
||||
float Battery_Voltage_At_End;
|
||||
uint16_t Battery_Temperature_At_End;
|
||||
uint16_t Maximum_Load_Current;
|
||||
uint16_t Maximum_Charge_Current;
|
||||
float Internal_Resistance;
|
||||
uint8_t Moderated;
|
||||
}Battery_Data_Struct;
|
||||
|
||||
typedef enum{
|
||||
INITIALISATION,
|
||||
READY,
|
||||
BUSY,
|
||||
SIM_ERROR,
|
||||
COMMAND_SET,
|
||||
COMMAND_NOT_SET
|
||||
}SIM800_Op_States;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char* AT ; // "AT\r\n";
|
||||
char* ATV ;// "ATV1\r\n"; //echo turn off
|
||||
char* ATE ;// "ATE0\r\n"; //answer without echo
|
||||
char* ATW ;// "AT&W\r\n"; //save presets to mem
|
||||
char* ATCFUN0;//"AT+CFUN;//0\r\n"; //reboot
|
||||
char* ATCFUN1;//"AT+CFUN;//1\r\n"; //reboot
|
||||
char* ATCMEE2;//"AT+CMEE;//2\r\n"; //return error code
|
||||
char* ATCGREG;//"AT+CGREG?\r\n"; //gprs availability
|
||||
char* ATCOPS;//"AT+COPS?\r\n";
|
||||
char* ATCPAS;//"AT+CPAS\r\n";
|
||||
char* ATCSQ;//"AT+CSQ\r\n";
|
||||
|
||||
//sms
|
||||
char* ATCMGF1;//"AT+CMGF;//1\r\n";
|
||||
char* ATCSMP;//"AT+CSMP;//17,167,0,0\r\n";
|
||||
char* ATCMGFnum;//"AT+CMGS;//\"+79253801217\"\r\n";
|
||||
char* ATCMGFtext;//"Hello\32\r\n";
|
||||
char* ATD;//"ATD+79253801217\r\n";
|
||||
char* ATCSCSUCS2;//"AT+CSCS;//\"UCS2\"\r\n";
|
||||
|
||||
//TIME
|
||||
char* ATCLTS ;// "AT+CLTS;//1\r\n";
|
||||
char* ATCCLK ;// "AT+CCLK?\r\n";
|
||||
//GPS
|
||||
char* ATCLBS;
|
||||
char* ATCLBSCFG;
|
||||
|
||||
//GPRS
|
||||
char* ATCGATT_check;//"AT+CGATT?\r\n";
|
||||
char* ATCGATT_disconnect;
|
||||
char* ATCGATT_connect;//"AT+CGATT;//1\r\n";
|
||||
char* ATSAPBR1;//"AT+SAPBR;//1,1\r\n"; //Set connection
|
||||
char* ATSAPBR2;//"AT+SAPBR;//2,1\r\n"; //get info and IP
|
||||
char* ATSAPBR3_1_CONTYPE;//"AT+SAPBR;//3,1,\"CONTYPE\",\"GPRS\"\r\n"; //CONTYPE gprs connection types
|
||||
char* ATSAPBR3_1_APN;//"AT+SAPBR;//3,1,\"APN\",\"internet.beeline.ru\"\r\n"; //APN connection¤
|
||||
char* ATSAPBR3_1_USER;//"AT+SAPBR;//3,1,\"USER\",\"Beeline\"\r\n"; //
|
||||
char* ATSAPBR3_1_PWD;//"AT+SAPBR;//3,1,\"PWD\",\"Beeline\"\r\n"; //
|
||||
char* ATSAPBR4_1;//"AT+SAPBR;//4,1\r\n"; //current settings
|
||||
char* ATCSTT;
|
||||
char* ATCIICR;
|
||||
char* ATCIPSHUT;
|
||||
char* ATCIPGSMLOC;
|
||||
|
||||
|
||||
//HTTP
|
||||
char* ATHTTP;//"AT+HTTPINIT\r\n"; //init http
|
||||
char* ATHTTPPARA_CID;
|
||||
char* ATHTTPSTATUS;
|
||||
char* ATHTTPPARA_PARAM;
|
||||
char* ATHTTPPARA_URL;
|
||||
char* ATHTTPP_ACTION_POST;
|
||||
char* ATHTTPP_ACTION_GET;
|
||||
|
||||
char* ATHTTPPARA_USERDATA;
|
||||
|
||||
char* ATHTTPPARA_CONTENT; //set the Content-Type field in HTTP header
|
||||
char* ATHTTPPARA_KEY;
|
||||
//after this should return DOWNLOAD - we ready to transmit
|
||||
|
||||
char* DATA2;
|
||||
|
||||
char* ATHTTPACTION; //0-GET 1-POST 2-HEAD
|
||||
char* ATHTTPREAD; //should return 200
|
||||
char* ATHTTPTERM; //close
|
||||
char* ATSAPBR0; //close
|
||||
char* AT_CSCS_GSM;
|
||||
char* ATCUSD102;
|
||||
char* ATCNMI;
|
||||
char* ATCMGL;
|
||||
char* ATCCID;
|
||||
char* ATCREG;
|
||||
char* ATHTTPSSLREQUEST;
|
||||
char* ATHTTPSSL;
|
||||
char* ATCGMR;
|
||||
char* ATCOPS_Manual;
|
||||
char* ATCDNSCFG_REQ;
|
||||
char* ATCDNSCFG;
|
||||
char* ATCIFSR;
|
||||
char* ATCIPSTATUS;
|
||||
char* ATCIPMUX;
|
||||
char* ATHTTPREAD_REQ;
|
||||
char* ATHTTPHEAD;
|
||||
char* ATHTTPPARA_URL_EVENT;
|
||||
char* ATHTTPPARA_URL_EVENT_TEST;
|
||||
char* ATHTTPPARA_URL_TEST;
|
||||
|
||||
char* SE_HTTPDATA;
|
||||
|
||||
char* SE_ENDOFSTRING;
|
||||
char* SE_DATATO;
|
||||
|
||||
|
||||
char* DATA0;
|
||||
char* DATA1; //data to transmit
|
||||
char* ATHTTPDATA0;
|
||||
char* ATHTTPDATA1;
|
||||
char* SE_Length1;
|
||||
char* SE_Length2;
|
||||
|
||||
char DATA0_ch[500];
|
||||
char DATA1_ch[300];
|
||||
char ATHTTPDATA0_ch[100];
|
||||
char ATHTTPDATA1_ch[100];
|
||||
char SE_Length1_ch[100];
|
||||
char SE_Length2_ch[100];
|
||||
char Domain_URL[250];
|
||||
char Domain_URL_Event[250];
|
||||
char GSM_APN[50];
|
||||
char GSM_USER[50];
|
||||
char GSM_PWD[50];
|
||||
|
||||
} AT_Commands_Struct;
|
||||
|
||||
typedef enum{
|
||||
DONOTHING,
|
||||
HTTP_EVENT_POST,
|
||||
HTTP_PARAMETERS_POST,
|
||||
GET_GPS_COORDINATES,
|
||||
GET_TIME,
|
||||
HTTP_PARAMETERS_POST_TEST,
|
||||
HTTP_EVENT_POST_TEST,
|
||||
CHECK_NETWORK_AWAILABILITY
|
||||
}SIM800_Op_Commands;
|
||||
|
||||
typedef struct{
|
||||
Battery_Data_Struct BATTERY_DATA;
|
||||
SIM_Answer_Struct Sim_Answer;
|
||||
Time_Struct Sim_Time;
|
||||
HTTP_DATA_Struct Sim_HTTP_Data;
|
||||
Sim_Stages Sim_Stages_List;
|
||||
SIM800_Op_States Sim_States_to_return;
|
||||
SIM800_States Sim_Main_States;
|
||||
AT_Commands_Struct Sim_At_Commands;
|
||||
uint8_t SIM_RESET_Switch;
|
||||
uint8_t SIM_RESET_Set;
|
||||
uint32_t REQUEST_Timeout;
|
||||
uint8_t REQUEST_Timeout_Active;
|
||||
uint32_t INIT_Timeout;
|
||||
uint8_t INIT_Timeout_Active;
|
||||
uint32_t NORMAL_Timeout;
|
||||
uint8_t NORMAL_Timeout_Active;
|
||||
SIM800_Op_Commands Sim_Active_Command;
|
||||
char* Default_Longitude;
|
||||
char* Default_Latitude;
|
||||
char Raw_var[100];
|
||||
uint8_t Network_Check_Flag;
|
||||
}SIM800_Global_Struct;
|
||||
|
||||
|
||||
|
||||
|
||||
void SIM800_Var_Init(SIM800_Global_Struct* Sim_Struct);
|
||||
void SIM800_Send_Command(char* command);
|
||||
void SIM800_Send_Command_Long(char* command);
|
||||
void SIM800_RESET(SIM800_Global_Struct* Sim_Struct);
|
||||
uint8_t SIM800_Received_LOOKFOR(SIM_Answer_Struct* answ, char* LOOKFOR );
|
||||
void SIM800_get_time(SIM_Answer_Struct* answ, Time_Struct* time);
|
||||
void SIM800_Time_To_String(Time_Struct* Time, char* DST);
|
||||
void SIM800_import_time_to_struct(SIM800_Global_Struct* Sim_Struct, Time_Struct* DST);
|
||||
void Battery_Data_Event_Processing(SIM800_Global_Struct* Sim_Struct);
|
||||
void Battery_Data_Parameters_Processing(SIM800_Global_Struct* Sim_Struct);
|
||||
void Battery_Data_Length_Calculating(SIM800_Global_Struct* Sim_Struct);
|
||||
void Battery_Data_Time_Processing(SIM800_Global_Struct* Sim_Struct/*HTTP_DATA_Struct* HTTP_DATA,Time_Struct* time*/);
|
||||
void HTTP_Data_Init(SIM800_Global_Struct* Sim_Struct);
|
||||
void SIM800_Get_Coordinates(SIM800_Global_Struct* Sim_Struct);
|
||||
void SIM800_Interrupt_Handler(SIM800_Global_Struct* Sim_Struct, uint8_t* UART_Buffer, uint16_t Size);
|
||||
void SIM800_Processing(SIM800_Global_Struct* Sim_Struct, uint8_t* UART_Buf);
|
||||
SIM800_Op_States SIM800_Init(SIM800_Global_Struct* Sim_Struct/*SIM800_States* State, Sim_Stages* CMD_Type, AT_Commands_Struct* AT_CMD ,SIM_Answer_Struct* Answer_Struct, Time_Struct* Time*/);
|
||||
SIM800_Op_States SIM800_Active_Mode(SIM800_Global_Struct* Sim_Struct);
|
||||
SIM800_Op_States SIM800_Set_Command(SIM800_Global_Struct* Sim_Struct, SIM800_Op_Commands CMD, uint32_t Timeout);
|
||||
void Battery_Data_to_String_Converter(SIM800_Global_Struct* Sim_Struct);
|
||||
|
||||
void SetParametersFromConfig(SIM800_Global_Struct* Sim_Struct, modConfigGeneralConfigStructTypedef *Config);
|
||||
|
||||
|
||||
#endif
|
||||
119
Core/Inc/SD_Card.h
Normal file
119
Core/Inc/SD_Card.h
Normal file
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* SD_Card.h
|
||||
*
|
||||
* Created on: 24 дек. 2021 г.
|
||||
* Author: Николай
|
||||
*/
|
||||
|
||||
#ifndef INC_SD_CARD_H_
|
||||
#define INC_SD_CARD_H_
|
||||
|
||||
#include "GSM.h"
|
||||
#include "fatfs.h"
|
||||
//FATFS
|
||||
|
||||
#define __MIN_FREE_SPACE_REQUIRED 500*1000*1000 //bytes
|
||||
|
||||
FATFS FatFs; //Fatfs handle
|
||||
FIL fil; //File handle
|
||||
FRESULT fres; //Result after operations
|
||||
DIR dir;
|
||||
|
||||
FILINFO flinf;
|
||||
DWORD free_clusters, free_sectors, total_sectors;
|
||||
uint32_t free_space;
|
||||
FATFS* getFreeFs;
|
||||
UINT nRead;
|
||||
char readbuff[1024];
|
||||
uint32_t sizeWritten;
|
||||
unsigned int BytesWr;
|
||||
|
||||
typedef enum{
|
||||
SD_OP_DONOTHING,
|
||||
SD_OP_WRITE_STATUS,
|
||||
SD_OP_WRITE_PARAM,
|
||||
SD_OP_WRITE_HEADER,
|
||||
SD_OP_DELETEOLD,
|
||||
SD_OP_MOUNT,
|
||||
SD_OP_UMOUNT
|
||||
}SD_Op_Commands;
|
||||
|
||||
typedef enum{
|
||||
SD_READY,
|
||||
SD_BUSY,
|
||||
SD_ERROR,
|
||||
SD_COMMAND_SET,
|
||||
SD_COMMAND_NOT_SET
|
||||
}SD_Card_states;
|
||||
|
||||
typedef enum{
|
||||
SD_IDLE,
|
||||
SD_MOUNT,
|
||||
SD_OPEN_DIR,
|
||||
SD_OPEN_FILE,
|
||||
SD_WRITE,
|
||||
SD_WRITE_HEADER,
|
||||
SD_READ,
|
||||
SD_CLOSE,
|
||||
SD_UMOUNT,
|
||||
SD_DELETE_OLD_FILES,
|
||||
SD_CHECK_FREE_SPACE
|
||||
|
||||
} SD_Stages;
|
||||
|
||||
typedef struct{
|
||||
uint64_t Battery_Serial;
|
||||
HTTP_DATA_Struct CSV_DATA;
|
||||
Battery_Data_Struct BATTERY_DATA;
|
||||
char Raw_var[100];
|
||||
SD_Op_Commands SD_Active_Command;
|
||||
SD_Card_states SD_State_to_return;
|
||||
SD_Stages SD_Stages_list;
|
||||
|
||||
uint8_t SD_CARD_ChipDetect;
|
||||
char* DATA0;
|
||||
char DATA0_ch[1000];
|
||||
|
||||
char* Header;
|
||||
char* FileName;
|
||||
char* Path;
|
||||
char Path_ch[100];
|
||||
char Filename_ch[20];
|
||||
uint8_t Mount_Flag;
|
||||
uint8_t Mount_CMD_SET;
|
||||
|
||||
uint8_t Filename_Check_Done;
|
||||
|
||||
FRESULT Fat_result;
|
||||
}SD_CARD_Global_Struct;
|
||||
|
||||
typedef struct{
|
||||
char isDir;
|
||||
|
||||
char fullpath_ch[100];
|
||||
char* fullpath;
|
||||
char filename_ch[13];
|
||||
char* filename;
|
||||
uint32_t value;
|
||||
|
||||
uint32_t FN_Value;
|
||||
uint8_t Lastfound_FN_Month;
|
||||
uint8_t Lastfound_FN_Year;
|
||||
uint8_t Oldest_FN_Month;
|
||||
uint8_t Oldest_FN_Year;
|
||||
uint32_t Oldest_FN_Value;
|
||||
|
||||
}ff_search_struct;
|
||||
|
||||
|
||||
void Battery_Data_to_CSV_Converter(SD_CARD_Global_Struct* Sd_Struct, HTTP_DATA_Struct* DST);
|
||||
void CSV_Status_Data_Compilation(SD_CARD_Global_Struct* Sd_Struct);
|
||||
void CSV_Param_Data_Compilation(SD_CARD_Global_Struct* Sd_Struct);
|
||||
SD_Card_states SD_Set_Command(SD_CARD_Global_Struct* SD_Struct, SD_Op_Commands CMD, uint32_t Timeout);
|
||||
void SD_Card_Processing(SD_CARD_Global_Struct* SD_Struct);
|
||||
uint64_t Filename_to_Value(char* FN);
|
||||
uint8_t Configure_Path_to_delete(char* path, uint32_t Value);
|
||||
void Search_for_Oldest(volatile ff_search_struct* sourceStruct,char* Path, uint64_t ActualSerial);
|
||||
void SD_Update_Path(SD_CARD_Global_Struct* source);
|
||||
|
||||
#endif /* INC_SD_CARD_H_ */
|
||||
56
Core/Inc/dataHelper.h
Normal file
56
Core/Inc/dataHelper.h
Normal file
@@ -0,0 +1,56 @@
|
||||
#include <stdint.h>
|
||||
|
||||
typedef union
|
||||
{
|
||||
uint16_t Val;
|
||||
uint8_t v[2];
|
||||
struct
|
||||
{
|
||||
uint8_t LB;
|
||||
uint8_t HB;
|
||||
} byte;
|
||||
} UINT16_VAL;
|
||||
|
||||
typedef union
|
||||
{
|
||||
uint32_t Val;
|
||||
uint16_t w[2];
|
||||
uint8_t v[4];
|
||||
struct
|
||||
{
|
||||
uint16_t LW;
|
||||
uint16_t HW;
|
||||
} word;
|
||||
struct
|
||||
{
|
||||
uint8_t LB;
|
||||
uint8_t HB;
|
||||
uint8_t UB;
|
||||
uint8_t MB;
|
||||
} byte;
|
||||
struct
|
||||
{
|
||||
UINT16_VAL low;
|
||||
UINT16_VAL high;
|
||||
}wordUnion;
|
||||
} UINT32_VAL;
|
||||
|
||||
typedef union
|
||||
{
|
||||
uint64_t Val;
|
||||
uint32_t d[2];
|
||||
uint16_t w[4];
|
||||
uint8_t v[8];
|
||||
struct
|
||||
{
|
||||
uint32_t LD;
|
||||
uint32_t HD;
|
||||
} dword;
|
||||
struct
|
||||
{
|
||||
uint16_t LW;
|
||||
uint16_t HW;
|
||||
uint16_t UW;
|
||||
uint16_t MW;
|
||||
} word;
|
||||
} UINT64_VAL;
|
||||
2
Core/Inc/desktop.ini
Normal file
2
Core/Inc/desktop.ini
Normal file
@@ -0,0 +1,2 @@
|
||||
[.ShellClassInfo]
|
||||
IconResource=C:\Program Files\Google\Drive File Stream\54.0.3.0\GoogleDriveFS.exe,23
|
||||
334
Core/Inc/driverHWEEPROM.h
Normal file
334
Core/Inc/driverHWEEPROM.h
Normal file
@@ -0,0 +1,334 @@
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __DRIVERHWEEPROM_H
|
||||
#define __DRIVERHWEEPROM_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32f1xx_hal.h"
|
||||
#include "stdlib.h"
|
||||
#include "modFlash.h"
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* EEPROM emulation firmware error codes */
|
||||
#define EE_OK (uint32_t)HAL_OK
|
||||
#define EE_ERROR (uint32_t)HAL_ERROR
|
||||
#define EE_BUSY (uint32_t)HAL_BUSY
|
||||
#define EE_TIMEOUT (uint32_t)HAL_TIMEOUT
|
||||
|
||||
/* Base address of the Flash sectors */
|
||||
|
||||
//#define ADDR_FLASH_PAGE_0 ((uint32_t)0x0807D000) /* Base @ of Page 250, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_1 ((uint32_t)0x0807D800) /* Base @ of Page 251, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_2 ((uint32_t)0x0807E000) /* Base @ of Page 252, 2 Kbytes */
|
||||
|
||||
|
||||
#define ADDR_EEPROM_PAGE_0 ((uint32_t)0x0803E800) /* Base @ of Page 125, 2 Kbytes */
|
||||
#define ADDR_EEPROM_PAGE_1 ((uint32_t)0x0803F000) /* Base @ of Page 126, 2 Kbytes */
|
||||
//#define ADDR_EEPROM_PAGE_2 ((uint32_t)0x0802B000) /* Base @ of Page 86, 2 Kbytes */
|
||||
|
||||
|
||||
//#define ADDR_FLASH_PAGE_253 ((uint32_t)0x0807E800) /* Base @ of Page 253, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_254 ((uint32_t)0x0807F000) /* Base @ of Page 254, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_255 ((uint32_t)0x0807F800) /* Base @ of Page 255, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_0 ((uint32_t)0x08000000) /* Base @ of Page 0, 2 Kbytes */ // Startup Code
|
||||
//#define ADDR_FLASH_PAGE_1 ((uint32_t)0x08000800) /* Base @ of Page 1, 2 Kbytes */ // Page0
|
||||
//#define ADDR_FLASH_PAGE_2 ((uint32_t)0x08001000) /* Base @ of Page 2, 2 Kbytes */ // Page1
|
||||
//#define ADDR_FLASH_PAGE_3 ((uint32_t)0x08001800) /* Base @ of Page 3, 2 Kbytes */ // Remainder of code from here
|
||||
//#define ADDR_FLASH_PAGE_4 ((uint32_t)0x08002000) /* Base @ of Page 4, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_5 ((uint32_t)0x08002800) /* Base @ of Page 5, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_6 ((uint32_t)0x08003000) /* Base @ of Page 6, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_7 ((uint32_t)0x08003800) /* Base @ of Page 7, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_8 ((uint32_t)0x08004000) /* Base @ of Page 8, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_9 ((uint32_t)0x08004800) /* Base @ of Page 9, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_10 ((uint32_t)0x08005000) /* Base @ of Page 10, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_11 ((uint32_t)0x08005800) /* Base @ of Page 11, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_12 ((uint32_t)0x08006000) /* Base @ of Page 12, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_13 ((uint32_t)0x08006800) /* Base @ of Page 13, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_14 ((uint32_t)0x08007000) /* Base @ of Page 14, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_15 ((uint32_t)0x08007800) /* Base @ of Page 15, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_16 ((uint32_t)0x08008000) /* Base @ of Page 16, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_17 ((uint32_t)0x08008800) /* Base @ of Page 17, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_18 ((uint32_t)0x08009000) /* Base @ of Page 18, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_19 ((uint32_t)0x08009800) /* Base @ of Page 19, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_20 ((uint32_t)0x0800A000) /* Base @ of Page 20, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_21 ((uint32_t)0x0800A800) /* Base @ of Page 21, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_22 ((uint32_t)0x0800B000) /* Base @ of Page 22, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_23 ((uint32_t)0x0800B800) /* Base @ of Page 23, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_24 ((uint32_t)0x0800C000) /* Base @ of Page 24, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_25 ((uint32_t)0x0800C800) /* Base @ of Page 25, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_26 ((uint32_t)0x0800D000) /* Base @ of Page 26, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_27 ((uint32_t)0x0800D800) /* Base @ of Page 27, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_28 ((uint32_t)0x0800E000) /* Base @ of Page 28, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_29 ((uint32_t)0x0800E800) /* Base @ of Page 29, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_30 ((uint32_t)0x0800F000) /* Base @ of Page 30, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_31 ((uint32_t)0x0800F800) /* Base @ of Page 31, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_32 ((uint32_t)0x08010000) /* Base @ of Page 32, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_33 ((uint32_t)0x08010800) /* Base @ of Page 33, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_34 ((uint32_t)0x08011000) /* Base @ of Page 34, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_35 ((uint32_t)0x08011800) /* Base @ of Page 35, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_36 ((uint32_t)0x08012000) /* Base @ of Page 36, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_37 ((uint32_t)0x08012800) /* Base @ of Page 37, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_38 ((uint32_t)0x08013000) /* Base @ of Page 38, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_39 ((uint32_t)0x08013800) /* Base @ of Page 39, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_40 ((uint32_t)0x08014000) /* Base @ of Page 40, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_41 ((uint32_t)0x08014800) /* Base @ of Page 41, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_42 ((uint32_t)0x08015000) /* Base @ of Page 42, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_43 ((uint32_t)0x08015800) /* Base @ of Page 43, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_44 ((uint32_t)0x08016000) /* Base @ of Page 44, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_45 ((uint32_t)0x08016800) /* Base @ of Page 45, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_46 ((uint32_t)0x08017000) /* Base @ of Page 46, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_47 ((uint32_t)0x08017800) /* Base @ of Page 47, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_48 ((uint32_t)0x08018000) /* Base @ of Page 48, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_49 ((uint32_t)0x08018800) /* Base @ of Page 49, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_50 ((uint32_t)0x08019000) /* Base @ of Page 50, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_51 ((uint32_t)0x08019800) /* Base @ of Page 51, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_52 ((uint32_t)0x0801A000) /* Base @ of Page 52, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_53 ((uint32_t)0x0801A800) /* Base @ of Page 53, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_54 ((uint32_t)0x0801B000) /* Base @ of Page 54, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_55 ((uint32_t)0x0801B800) /* Base @ of Page 55, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_56 ((uint32_t)0x0801C000) /* Base @ of Page 56, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_57 ((uint32_t)0x0801C800) /* Base @ of Page 57, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_58 ((uint32_t)0x0801D000) /* Base @ of Page 58, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_59 ((uint32_t)0x0801D800) /* Base @ of Page 59, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_60 ((uint32_t)0x0801E000) /* Base @ of Page 60, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_61 ((uint32_t)0x0801E800) /* Base @ of Page 61, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_62 ((uint32_t)0x0801F000) /* Base @ of Page 62, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_63 ((uint32_t)0x0801F800) /* Base @ of Page 63, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_64 ((uint32_t)0x08020000) /* Base @ of Page 64, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_65 ((uint32_t)0x08020800) /* Base @ of Page 65, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_66 ((uint32_t)0x08021000) /* Base @ of Page 66, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_67 ((uint32_t)0x08021800) /* Base @ of Page 67, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_68 ((uint32_t)0x08022000) /* Base @ of Page 68, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_69 ((uint32_t)0x08022800) /* Base @ of Page 69, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_70 ((uint32_t)0x08023000) /* Base @ of Page 70, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_71 ((uint32_t)0x08023800) /* Base @ of Page 71, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_72 ((uint32_t)0x08024000) /* Base @ of Page 72, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_73 ((uint32_t)0x08024800) /* Base @ of Page 73, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_74 ((uint32_t)0x08025000) /* Base @ of Page 74, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_75 ((uint32_t)0x08025800) /* Base @ of Page 75, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_76 ((uint32_t)0x08026000) /* Base @ of Page 76, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_77 ((uint32_t)0x08026800) /* Base @ of Page 77, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_78 ((uint32_t)0x08027000) /* Base @ of Page 78, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_79 ((uint32_t)0x08027800) /* Base @ of Page 79, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_80 ((uint32_t)0x08028000) /* Base @ of Page 80, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_81 ((uint32_t)0x08028800) /* Base @ of Page 81, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_82 ((uint32_t)0x08029000) /* Base @ of Page 82, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_83 ((uint32_t)0x08029800) /* Base @ of Page 83, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_84 ((uint32_t)0x0802A000) /* Base @ of Page 84, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_85 ((uint32_t)0x0802A800) /* Base @ of Page 85, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_86 ((uint32_t)0x0802B000) /* Base @ of Page 86, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_87 ((uint32_t)0x0802B800) /* Base @ of Page 87, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_88 ((uint32_t)0x0802C000) /* Base @ of Page 88, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_89 ((uint32_t)0x0802C800) /* Base @ of Page 89, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_90 ((uint32_t)0x0802D000) /* Base @ of Page 90, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_91 ((uint32_t)0x0802D800) /* Base @ of Page 91, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_92 ((uint32_t)0x0802E000) /* Base @ of Page 92, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_93 ((uint32_t)0x0802E800) /* Base @ of Page 93, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_94 ((uint32_t)0x0802F000) /* Base @ of Page 94, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_95 ((uint32_t)0x0802F800) /* Base @ of Page 95, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_96 ((uint32_t)0x08030000) /* Base @ of Page 96, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_97 ((uint32_t)0x08030800) /* Base @ of Page 97, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_98 ((uint32_t)0x08031000) /* Base @ of Page 98, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_99 ((uint32_t)0x08031800) /* Base @ of Page 99, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_100 ((uint32_t)0x08032000) /* Base @ of Page 100, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_101 ((uint32_t)0x08032800) /* Base @ of Page 101, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_102 ((uint32_t)0x08033000) /* Base @ of Page 102, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_103 ((uint32_t)0x08033800) /* Base @ of Page 103, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_104 ((uint32_t)0x08034000) /* Base @ of Page 104, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_105 ((uint32_t)0x08034800) /* Base @ of Page 105, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_106 ((uint32_t)0x08035000) /* Base @ of Page 106, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_107 ((uint32_t)0x08035800) /* Base @ of Page 107, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_108 ((uint32_t)0x08036000) /* Base @ of Page 108, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_109 ((uint32_t)0x08036800) /* Base @ of Page 109, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_110 ((uint32_t)0x08037000) /* Base @ of Page 110, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_111 ((uint32_t)0x08037800) /* Base @ of Page 111, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_112 ((uint32_t)0x08038000) /* Base @ of Page 112, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_113 ((uint32_t)0x08038800) /* Base @ of Page 113, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_114 ((uint32_t)0x08039000) /* Base @ of Page 114, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_115 ((uint32_t)0x08039800) /* Base @ of Page 115, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_116 ((uint32_t)0x0803A000) /* Base @ of Page 116, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_117 ((uint32_t)0x0803A800) /* Base @ of Page 117, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_118 ((uint32_t)0x0803B000) /* Base @ of Page 118, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_119 ((uint32_t)0x0803B800) /* Base @ of Page 119, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_120 ((uint32_t)0x0803C000) /* Base @ of Page 120, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_121 ((uint32_t)0x0803C800) /* Base @ of Page 121, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_122 ((uint32_t)0x0803D000) /* Base @ of Page 122, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_123 ((uint32_t)0x0803D800) /* Base @ of Page 123, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_124 ((uint32_t)0x0803E000) /* Base @ of Page 124, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_125 ((uint32_t)0x0803E800) /* Base @ of Page 125, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_126 ((uint32_t)0x0803F000) /* Base @ of Page 126, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_127 ((uint32_t)0x0803F800) /* Base @ of Page 127, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_128 ((uint32_t)0x08040000) /* Base @ of Page 128, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_129 ((uint32_t)0x08040800) /* Base @ of Page 129, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_130 ((uint32_t)0x08041000) /* Base @ of Page 130, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_131 ((uint32_t)0x08041800) /* Base @ of Page 131, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_132 ((uint32_t)0x08042000) /* Base @ of Page 132, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_133 ((uint32_t)0x08042800) /* Base @ of Page 133, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_134 ((uint32_t)0x08043000) /* Base @ of Page 134, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_135 ((uint32_t)0x08043800) /* Base @ of Page 135, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_136 ((uint32_t)0x08044000) /* Base @ of Page 136, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_137 ((uint32_t)0x08044800) /* Base @ of Page 137, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_138 ((uint32_t)0x08045000) /* Base @ of Page 138, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_139 ((uint32_t)0x08045800) /* Base @ of Page 139, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_140 ((uint32_t)0x08046000) /* Base @ of Page 140, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_141 ((uint32_t)0x08046800) /* Base @ of Page 141, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_142 ((uint32_t)0x08047000) /* Base @ of Page 142, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_143 ((uint32_t)0x08047800) /* Base @ of Page 143, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_144 ((uint32_t)0x08048000) /* Base @ of Page 144, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_145 ((uint32_t)0x08048800) /* Base @ of Page 145, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_146 ((uint32_t)0x08049000) /* Base @ of Page 146, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_147 ((uint32_t)0x08049800) /* Base @ of Page 147, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_148 ((uint32_t)0x0804A000) /* Base @ of Page 148, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_149 ((uint32_t)0x0804A800) /* Base @ of Page 149, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_150 ((uint32_t)0x0804B000) /* Base @ of Page 150, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_151 ((uint32_t)0x0804B800) /* Base @ of Page 151, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_152 ((uint32_t)0x0804C000) /* Base @ of Page 152, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_153 ((uint32_t)0x0804C800) /* Base @ of Page 153, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_154 ((uint32_t)0x0804D000) /* Base @ of Page 154, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_155 ((uint32_t)0x0804D800) /* Base @ of Page 155, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_156 ((uint32_t)0x0804E000) /* Base @ of Page 156, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_157 ((uint32_t)0x0804E800) /* Base @ of Page 157, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_158 ((uint32_t)0x0804F000) /* Base @ of Page 158, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_159 ((uint32_t)0x0804F800) /* Base @ of Page 159, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_160 ((uint32_t)0x08050000) /* Base @ of Page 160, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_161 ((uint32_t)0x08050800) /* Base @ of Page 161, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_162 ((uint32_t)0x08051000) /* Base @ of Page 162, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_163 ((uint32_t)0x08051800) /* Base @ of Page 163, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_164 ((uint32_t)0x08052000) /* Base @ of Page 164, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_165 ((uint32_t)0x08052800) /* Base @ of Page 165, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_166 ((uint32_t)0x08053000) /* Base @ of Page 166, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_167 ((uint32_t)0x08053800) /* Base @ of Page 167, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_168 ((uint32_t)0x08054000) /* Base @ of Page 168, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_169 ((uint32_t)0x08054800) /* Base @ of Page 169, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_170 ((uint32_t)0x08055000) /* Base @ of Page 170, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_171 ((uint32_t)0x08055800) /* Base @ of Page 171, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_172 ((uint32_t)0x08056000) /* Base @ of Page 172, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_173 ((uint32_t)0x08056800) /* Base @ of Page 173, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_174 ((uint32_t)0x08057000) /* Base @ of Page 174, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_175 ((uint32_t)0x08057800) /* Base @ of Page 175, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_176 ((uint32_t)0x08058000) /* Base @ of Page 176, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_177 ((uint32_t)0x08058800) /* Base @ of Page 177, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_178 ((uint32_t)0x08059000) /* Base @ of Page 178, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_179 ((uint32_t)0x08059800) /* Base @ of Page 179, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_180 ((uint32_t)0x0805A000) /* Base @ of Page 180, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_181 ((uint32_t)0x0805A800) /* Base @ of Page 181, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_182 ((uint32_t)0x0805B000) /* Base @ of Page 182, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_183 ((uint32_t)0x0805B800) /* Base @ of Page 183, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_184 ((uint32_t)0x0805C000) /* Base @ of Page 184, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_185 ((uint32_t)0x0805C800) /* Base @ of Page 185, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_186 ((uint32_t)0x0805D000) /* Base @ of Page 186, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_187 ((uint32_t)0x0805D800) /* Base @ of Page 187, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_188 ((uint32_t)0x0805E000) /* Base @ of Page 188, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_189 ((uint32_t)0x0805E800) /* Base @ of Page 189, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_190 ((uint32_t)0x0805F000) /* Base @ of Page 190, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_191 ((uint32_t)0x0805F800) /* Base @ of Page 191, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_192 ((uint32_t)0x08060000) /* Base @ of Page 192, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_193 ((uint32_t)0x08060800) /* Base @ of Page 193, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_194 ((uint32_t)0x08061000) /* Base @ of Page 194, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_195 ((uint32_t)0x08061800) /* Base @ of Page 195, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_196 ((uint32_t)0x08062000) /* Base @ of Page 196, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_197 ((uint32_t)0x08062800) /* Base @ of Page 197, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_198 ((uint32_t)0x08063000) /* Base @ of Page 198, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_199 ((uint32_t)0x08063800) /* Base @ of Page 199, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_200 ((uint32_t)0x08064000) /* Base @ of Page 200, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_201 ((uint32_t)0x08064800) /* Base @ of Page 201, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_202 ((uint32_t)0x08065000) /* Base @ of Page 202, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_203 ((uint32_t)0x08065800) /* Base @ of Page 203, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_204 ((uint32_t)0x08066000) /* Base @ of Page 204, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_205 ((uint32_t)0x08066800) /* Base @ of Page 205, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_206 ((uint32_t)0x08067000) /* Base @ of Page 206, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_207 ((uint32_t)0x08067800) /* Base @ of Page 207, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_208 ((uint32_t)0x08068000) /* Base @ of Page 208, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_209 ((uint32_t)0x08068800) /* Base @ of Page 209, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_210 ((uint32_t)0x08069000) /* Base @ of Page 210, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_211 ((uint32_t)0x08069800) /* Base @ of Page 211, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_212 ((uint32_t)0x0806A000) /* Base @ of Page 212, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_213 ((uint32_t)0x0806A800) /* Base @ of Page 213, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_214 ((uint32_t)0x0806B000) /* Base @ of Page 214, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_215 ((uint32_t)0x0806B800) /* Base @ of Page 215, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_216 ((uint32_t)0x0806C000) /* Base @ of Page 216, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_217 ((uint32_t)0x0806C800) /* Base @ of Page 217, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_218 ((uint32_t)0x0806D000) /* Base @ of Page 218, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_219 ((uint32_t)0x0806D800) /* Base @ of Page 219, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_220 ((uint32_t)0x0806E000) /* Base @ of Page 220, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_221 ((uint32_t)0x0806E800) /* Base @ of Page 221, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_222 ((uint32_t)0x0806F000) /* Base @ of Page 222, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_223 ((uint32_t)0x0806F800) /* Base @ of Page 223, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_224 ((uint32_t)0x08070000) /* Base @ of Page 224, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_225 ((uint32_t)0x08070800) /* Base @ of Page 225, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_226 ((uint32_t)0x08071000) /* Base @ of Page 226, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_227 ((uint32_t)0x08071800) /* Base @ of Page 227, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_228 ((uint32_t)0x08072000) /* Base @ of Page 228, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_229 ((uint32_t)0x08072800) /* Base @ of Page 229, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_230 ((uint32_t)0x08073000) /* Base @ of Page 230, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_231 ((uint32_t)0x08073800) /* Base @ of Page 231, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_232 ((uint32_t)0x08074000) /* Base @ of Page 232, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_233 ((uint32_t)0x08074800) /* Base @ of Page 233, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_234 ((uint32_t)0x08075000) /* Base @ of Page 234, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_235 ((uint32_t)0x08075800) /* Base @ of Page 235, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_236 ((uint32_t)0x08076000) /* Base @ of Page 236, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_237 ((uint32_t)0x08076800) /* Base @ of Page 237, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_238 ((uint32_t)0x08077000) /* Base @ of Page 238, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_239 ((uint32_t)0x08077800) /* Base @ of Page 239, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_240 ((uint32_t)0x08078000) /* Base @ of Page 240, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_241 ((uint32_t)0x08078800) /* Base @ of Page 241, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_242 ((uint32_t)0x08079000) /* Base @ of Page 242, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_243 ((uint32_t)0x08079800) /* Base @ of Page 243, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_244 ((uint32_t)0x0807A000) /* Base @ of Page 244, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_245 ((uint32_t)0x0807A800) /* Base @ of Page 245, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_246 ((uint32_t)0x0807B000) /* Base @ of Page 246, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_247 ((uint32_t)0x0807B800) /* Base @ of Page 247, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_248 ((uint32_t)0x0807C000) /* Base @ of Page 248, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_249 ((uint32_t)0x0807C800) /* Base @ of Page 249, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_250 ((uint32_t)0x0807D000) /* Base @ of Page 250, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_251 ((uint32_t)0x0807D800) /* Base @ of Page 251, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_252 ((uint32_t)0x0807E000) /* Base @ of Page 252, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_253 ((uint32_t)0x0807E800) /* Base @ of Page 253, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_254 ((uint32_t)0x0807F000) /* Base @ of Page 254, 2 Kbytes */
|
||||
//#define ADDR_FLASH_PAGE_255 ((uint32_t)0x0807F800) /* Base @ of Page 255, 2 Kbytes */
|
||||
|
||||
/* Define the size of the sectors to be used */
|
||||
#define PAGE_SIZE (uint32_t)FLASH_PAGE_SIZE /* Page size */
|
||||
|
||||
/* EEPROM start address in Flash */
|
||||
#define EEPROM_START_ADDRESS ((uint32_t)ADDR_EEPROM_PAGE_0) /* EEPROM emulation start address */
|
||||
|
||||
/* Pages 0 and 1 base and end addresses */
|
||||
#define PAGE0_BASE_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + 0x0000))
|
||||
#define PAGE0_END_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + (PAGE_SIZE - 1)))
|
||||
|
||||
#define PAGE1_BASE_ADDRESS ((uint32_t)(ADDR_EEPROM_PAGE_1))
|
||||
#define PAGE1_END_ADDRESS ((uint32_t)(ADDR_EEPROM_PAGE_1 + PAGE_SIZE - 1))
|
||||
|
||||
/* Used Flash pages for EEPROM emulation */
|
||||
#define PAGE0 ((uint16_t)0x0000)
|
||||
#define PAGE1 ((uint16_t)1) /* Page numbers between PAGE0_BASE_ADDRESS & PAGE1_BASE_ADDRESS*/
|
||||
|
||||
/* No valid page define */
|
||||
#define NO_VALID_PAGE ((uint16_t)0x00AB)
|
||||
|
||||
/* Page status definitions */
|
||||
#define ERASED ((uint16_t)0xFFFF) /* Page is empty */
|
||||
#define RECEIVE_DATA ((uint16_t)0xEEEE) /* Page is marked to receive data */
|
||||
#define VALID_PAGE ((uint16_t)0x0000) /* Page containing valid data */
|
||||
|
||||
/* Valid pages in read and write defines */
|
||||
#define READ_FROM_VALID_PAGE ((uint8_t)0x00)
|
||||
#define WRITE_IN_VALID_PAGE ((uint8_t)0x01)
|
||||
|
||||
/* Page full define */
|
||||
#define PAGE_FULL ((uint8_t)0x80)
|
||||
|
||||
/* Variables' number */
|
||||
//#define NB_OF_VAR ((uint8_t)0x03)
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
uint16_t driverHWEEPROMInit(uint16_t numberOfVars);
|
||||
uint16_t driverHWEEPROMEraseFlash(void);
|
||||
uint16_t driverHWEEPROMReadVariable(uint16_t VirtAddress, uint16_t* Data);
|
||||
uint16_t driverHWEEPROMWriteVariable(uint16_t VirtAddress, uint16_t Data);
|
||||
|
||||
#endif /* __EEPROM_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
35
Core/Inc/driverHWPowerState.h
Normal file
35
Core/Inc/driverHWPowerState.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#ifndef __DRIVERHWPOWERSTATE_H
|
||||
#define __DRIVERHWPOWERSTATE_H
|
||||
|
||||
#include "generalDefines.h"
|
||||
#include "stm32f1xx_hal.h"
|
||||
#include "stdbool.h"
|
||||
|
||||
#define NoOfPowersSTATs 3
|
||||
|
||||
typedef struct {
|
||||
GPIO_TypeDef* Port;
|
||||
uint32_t ClkRegister;
|
||||
uint32_t Pin;
|
||||
uint32_t Mode;
|
||||
uint32_t Pull;
|
||||
} PowerStatePortStruct;
|
||||
|
||||
extern const PowerStatePortStruct driverHWPorts[NoOfPowersSTATs];
|
||||
|
||||
typedef enum {
|
||||
P_STAT_POWER_ENABLE = 0,
|
||||
P_STAT_BUTTON_INPUT,
|
||||
P_STAT_CHARGE_DETECT
|
||||
} PowerStateIDTypedef;
|
||||
|
||||
typedef enum {
|
||||
P_STAT_RESET = 0,
|
||||
P_STAT_SET
|
||||
} PowerStateStateTypedef;
|
||||
|
||||
void driverHWPowerStateInit(void);
|
||||
void driverHWPowerStateSetOutput(PowerStateIDTypedef inputPort, PowerStateStateTypedef newState);
|
||||
bool driverHWPowerStateReadInput(PowerStateIDTypedef inputPort);
|
||||
|
||||
#endif
|
||||
10
Core/Inc/driverHWSPI1.h
Normal file
10
Core/Inc/driverHWSPI1.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#include "stm32f1xx_hal.h"
|
||||
#include "stdbool.h"
|
||||
#include "stdlib.h"
|
||||
#include "string.h"
|
||||
|
||||
#define driverHWSPI1DefaultTimeout 100
|
||||
|
||||
void driverHWSPI1Init(GPIO_TypeDef* GPIOCSPort, uint16_t GPIO_CSPin);
|
||||
bool driverHWSPI1Write(uint8_t *writeBuffer, uint8_t noOfBytesToWrite,GPIO_TypeDef* GPIOCSPort, uint16_t GPIO_CSPin);
|
||||
bool driverHWSPI1WriteRead(uint8_t *writeBuffer, uint8_t noOfBytesToWrite, uint8_t *readBuffer, uint8_t noOfBytesToRead,GPIO_TypeDef* GPIOCSPort, uint16_t GPIO_CSPin);
|
||||
71
Core/Inc/driverHWSwitches.h
Normal file
71
Core/Inc/driverHWSwitches.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
Copyright 2017 - 2018 Danny Bokma danny@diebie.nl
|
||||
Copyright 2019 - 2020 Kevin Dionne kevin.dionne@ennoid.me
|
||||
|
||||
This file is part of the DieBieMS/ENNOID-BMS firmware.
|
||||
|
||||
The DieBieMS/ENNOID-BMS firmware is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The DieBieMS/ENNOID-BMS firmware is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "stm32f1xx_hal.h"
|
||||
#include "stdbool.h"
|
||||
#include "generalDefines.h"
|
||||
|
||||
#define NoOfSwitches 6 //7
|
||||
|
||||
typedef struct {
|
||||
GPIO_TypeDef* Port;
|
||||
uint32_t ClkRegister;
|
||||
uint32_t Pin;
|
||||
uint32_t Mode;
|
||||
uint32_t Pull;
|
||||
} driverHWSwitchesPortStruct;
|
||||
|
||||
extern const driverHWSwitchesPortStruct driverHWSwitchesPorts[NoOfSwitches];
|
||||
|
||||
typedef enum {
|
||||
#if ENNOID_SS
|
||||
SWITCH_CHARGE_BYPASS = 0,
|
||||
SWITCH_CHARGE,
|
||||
SWITCH_PRECHARGE,
|
||||
SWITCH_DISCHARGE,
|
||||
SWITCH_DISCHARGEHV,
|
||||
SWITCH_SAFETY_OUTPUT,
|
||||
#elif ENNOID_SS_LITE
|
||||
SWITCH_DISCHARGE = 0,
|
||||
SWITCH_CHARGE,
|
||||
SWITCH_PRECHARGE,
|
||||
SWITCH_CHARGE_BYPASS,
|
||||
SWITCH_DISCHARGEHV,
|
||||
SWITCH_SAFETY_OUTPUT,
|
||||
#else
|
||||
SWITCH_COOLING = 0,
|
||||
SWITCH_CHARGE,
|
||||
SWITCH_PRECHARGE,
|
||||
SWITCH_DISCHARGE,
|
||||
SWITCH_DISCHARGEHV,
|
||||
SWITCH_SAFETY_OUTPUT,
|
||||
#endif
|
||||
|
||||
} driverHWSwitchesIDTypedef;
|
||||
|
||||
typedef enum {
|
||||
SWITCH_RESET = 0,
|
||||
SWITCH_SET,
|
||||
} driverHWSwitchesStateTypedef;
|
||||
|
||||
void driverHWSwitchesInit(void);
|
||||
void driverHWSwitchesSetSwitchState(driverHWSwitchesIDTypedef switchID, driverHWSwitchesStateTypedef newState);
|
||||
void driverHWSwitchesDisableAll(void);
|
||||
bool driverHWSwitchesGetSwitchState(driverHWSwitchesIDTypedef switchID);
|
||||
14
Core/Inc/driverHWUART2.h
Normal file
14
Core/Inc/driverHWUART2.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#include "stm32f1xx_hal.h"
|
||||
#include "stdbool.h"
|
||||
#include "string.h"
|
||||
|
||||
#define RX_UART_BUFFER_SIZE 1024//2048 //1024
|
||||
|
||||
void driverHWUART2Init(uint32_t baudRate);
|
||||
void driverHWUART2SendChar(uint8_t character);
|
||||
bool driverHWUART2GetChar(char *character);
|
||||
|
||||
extern uint8_t driverHWUART2ReceiveBuffer[RX_UART_BUFFER_SIZE];
|
||||
extern uint8_t driverHWUART2ReceiveBuffer_usb[RX_UART_BUFFER_SIZE];
|
||||
extern uint32_t driverHWUART2Receive_CNDTR;
|
||||
extern uint8_t driverHWUART2Receive_CNDTR_resetFlag;
|
||||
258
Core/Inc/driverSWLTC6804.h
Normal file
258
Core/Inc/driverSWLTC6804.h
Normal file
@@ -0,0 +1,258 @@
|
||||
/*
|
||||
Copyright 2017 - 2018 Danny Bokma danny@diebie.nl
|
||||
Copyright 2019 - 2020 Kevin Dionne kevin.dionne@ennoid.me
|
||||
|
||||
This file is part of the DieBieMS/ENNOID-BMS firmware.
|
||||
|
||||
The DieBieMS/ENNOID-BMS firmware is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The DieBieMS/ENNOID-BMS firmware is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "driverHWSPI1.h"
|
||||
#include "stdlib.h"
|
||||
#include "math.h"
|
||||
#include "mainDataTypes.h"
|
||||
#include "modDelay.h"
|
||||
//#include "driverSWLTC6804.h"
|
||||
|
||||
|
||||
/*
|
||||
Pre computed crc15 table used for the LTC6804 PEC calculation
|
||||
|
||||
The code used to generate the crc15 table is:
|
||||
|
||||
void generate_crc15_table()
|
||||
{
|
||||
int remainder;
|
||||
for(int i = 0; i<256;i++)
|
||||
{
|
||||
remainder = i<< 7;
|
||||
for (int bit = 8; bit > 0; --bit)
|
||||
{
|
||||
|
||||
if ((remainder & 0x4000) > 0)//equivalent to remainder & 2^14 simply check for MSB
|
||||
{
|
||||
remainder = ((remainder << 1)) ;
|
||||
remainder = (remainder ^ 0x4599);
|
||||
}
|
||||
else
|
||||
{
|
||||
remainder = ((remainder << 1));
|
||||
}
|
||||
}
|
||||
|
||||
crc15Table[i] = remainder&0xFFFF;
|
||||
}
|
||||
}
|
||||
*/
|
||||
static const unsigned int crc15Table[256] = {
|
||||
0x0000, 0xc599, 0xceab, 0x0b32, 0xd8cf, 0x1d56, 0x1664, 0xd3fd, 0xf407, 0x319e, 0x3aac, //!<precomputed CRC15 Table
|
||||
0xff35, 0x2cc8, 0xe951, 0xe263, 0x27fa, 0xad97, 0x680e, 0x633c, 0xa6a5, 0x7558, 0xb0c1,
|
||||
0xbbf3, 0x7e6a, 0x5990, 0x9c09, 0x973b, 0x52a2, 0x815f, 0x44c6, 0x4ff4, 0x8a6d, 0x5b2e,
|
||||
0x9eb7, 0x9585, 0x501c, 0x83e1, 0x4678, 0x4d4a, 0x88d3, 0xaf29, 0x6ab0, 0x6182, 0xa41b,
|
||||
0x77e6, 0xb27f, 0xb94d, 0x7cd4, 0xf6b9, 0x3320, 0x3812, 0xfd8b, 0x2e76, 0xebef, 0xe0dd,
|
||||
0x2544, 0x02be, 0xc727, 0xcc15, 0x098c, 0xda71, 0x1fe8, 0x14da, 0xd143, 0xf3c5, 0x365c,
|
||||
0x3d6e, 0xf8f7, 0x2b0a, 0xee93, 0xe5a1, 0x2038, 0x07c2, 0xc25b, 0xc969, 0x0cf0, 0xdf0d,
|
||||
0x1a94, 0x11a6, 0xd43f, 0x5e52, 0x9bcb, 0x90f9, 0x5560, 0x869d, 0x4304, 0x4836, 0x8daf,
|
||||
0xaa55, 0x6fcc, 0x64fe, 0xa167, 0x729a, 0xb703, 0xbc31, 0x79a8, 0xa8eb, 0x6d72, 0x6640,
|
||||
0xa3d9, 0x7024, 0xb5bd, 0xbe8f, 0x7b16, 0x5cec, 0x9975, 0x9247, 0x57de, 0x8423, 0x41ba,
|
||||
0x4a88, 0x8f11, 0x057c, 0xc0e5, 0xcbd7, 0x0e4e, 0xddb3, 0x182a, 0x1318, 0xd681, 0xf17b,
|
||||
0x34e2, 0x3fd0, 0xfa49, 0x29b4, 0xec2d, 0xe71f, 0x2286, 0xa213, 0x678a, 0x6cb8, 0xa921,
|
||||
0x7adc, 0xbf45, 0xb477, 0x71ee, 0x5614, 0x938d, 0x98bf, 0x5d26, 0x8edb, 0x4b42, 0x4070,
|
||||
0x85e9, 0x0f84, 0xca1d, 0xc12f, 0x04b6, 0xd74b, 0x12d2, 0x19e0, 0xdc79, 0xfb83, 0x3e1a,
|
||||
0x3528, 0xf0b1, 0x234c, 0xe6d5, 0xede7, 0x287e, 0xf93d, 0x3ca4, 0x3796, 0xf20f, 0x21f2,
|
||||
0xe46b, 0xef59, 0x2ac0, 0x0d3a, 0xc8a3, 0xc391, 0x0608, 0xd5f5, 0x106c, 0x1b5e, 0xdec7,
|
||||
0x54aa, 0x9133, 0x9a01, 0x5f98, 0x8c65, 0x49fc, 0x42ce, 0x8757, 0xa0ad, 0x6534, 0x6e06,
|
||||
0xab9f, 0x7862, 0xbdfb, 0xb6c9, 0x7350, 0x51d6, 0x944f, 0x9f7d, 0x5ae4, 0x8919, 0x4c80,
|
||||
0x47b2, 0x822b, 0xa5d1, 0x6048, 0x6b7a, 0xaee3, 0x7d1e, 0xb887, 0xb3b5, 0x762c, 0xfc41,
|
||||
0x39d8, 0x32ea, 0xf773, 0x248e, 0xe117, 0xea25, 0x2fbc, 0x0846, 0xcddf, 0xc6ed, 0x0374,
|
||||
0xd089, 0x1510, 0x1e22, 0xdbbb, 0x0af8, 0xcf61, 0xc453, 0x01ca, 0xd237, 0x17ae, 0x1c9c,
|
||||
0xd905, 0xfeff, 0x3b66, 0x3054, 0xf5cd, 0x2630, 0xe3a9, 0xe89b, 0x2d02, 0xa76f, 0x62f6,
|
||||
0x69c4, 0xac5d, 0x7fa0, 0xba39, 0xb10b, 0x7492, 0x5368, 0x96f1, 0x9dc3, 0x585a, 0x8ba7,
|
||||
0x4e3e, 0x450c, 0x8095
|
||||
};
|
||||
|
||||
/*!
|
||||
|
||||
|MD| Dec | ADC Conversion Model|
|
||||
|--|------|---------------------|
|
||||
|01| 1 | Fast |
|
||||
|10| 2 | Normal |
|
||||
|11| 3 | Filtered |
|
||||
*/
|
||||
#define MD_FAST 1
|
||||
#define MD_NORMAL 2
|
||||
#define MD_FILTERED 3
|
||||
|
||||
|
||||
/*!
|
||||
|CH | Dec | Channels to convert |
|
||||
|---|------|---------------------|
|
||||
|000| 0 | All Cells |
|
||||
|001| 1 | Cell 1 and Cell 7 |
|
||||
|010| 2 | Cell 2 and Cell 8 |
|
||||
|011| 3 | Cell 3 and Cell 9 |
|
||||
|100| 4 | Cell 4 and Cell 10 |
|
||||
|101| 5 | Cell 5 and Cell 11 |
|
||||
|110| 6 | Cell 6 and Cell 12 |
|
||||
*/
|
||||
|
||||
#define CELL_CH_ALL 0
|
||||
#define CELL_CH_1and7 1
|
||||
#define CELL_CH_2and8 2
|
||||
#define CELL_CH_3and9 3
|
||||
#define CELL_CH_4and10 4
|
||||
#define CELL_CH_5and11 5
|
||||
#define CELL_CH_6and12 6
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
|
||||
|CHG | Dec |Channels to convert |
|
||||
|----|------|----------------------|
|
||||
|000 | 0 | All GPIOS and 2nd Ref|
|
||||
|001 | 1 | GPIO 1 |
|
||||
|010 | 2 | GPIO 2 |
|
||||
|011 | 3 | GPIO 3 |
|
||||
|100 | 4 | GPIO 4 |
|
||||
|101 | 5 | GPIO 5 |
|
||||
|110 | 6 | Vref2 |
|
||||
*/
|
||||
|
||||
#define AUX_CH_ALL 0
|
||||
#define AUX_CH_GPIO1 1
|
||||
#define AUX_CH_GPIO2 2
|
||||
#define AUX_CH_GPIO3 3
|
||||
#define AUX_CH_GPIO4 4
|
||||
#define AUX_CH_GPIO5 5
|
||||
#define AUX_CH_VREF2 6
|
||||
|
||||
//uint8_t CHG = 0; //!< aux channels to be converted
|
||||
/*!****************************************************
|
||||
\brief Controls if Discharging transitors are enabled
|
||||
or disabled during Cell conversions.
|
||||
|
||||
|DCP | Discharge Permitted During conversion |
|
||||
|----|----------------------------------------|
|
||||
|0 | No - discharge is not permitted |
|
||||
|1 | Yes - discharge is permitted |
|
||||
|
||||
********************************************************/
|
||||
#define DCP_DISABLED 0
|
||||
#define DCP_ENABLED 1
|
||||
|
||||
typedef enum {
|
||||
LTC6804WriteConfigRegA = 0x0001, // WRCFG
|
||||
LTC6804WriteConfigRegB = 0x0024, // WRCFG
|
||||
LTC6804ReadConfigRegA = 0x0002, // RDCFG
|
||||
LTC6804ReadConfigRegB = 0x0026, // RDCFG
|
||||
LTC6804ReadCellVoltageGroupA = 0x0004, // RDVCA
|
||||
LTC6804ReadCellVoltageGroupB = 0x0006, // RDVCB
|
||||
LTC6804ReadCellVoltageGroupC = 0x0008, // RDVCC
|
||||
LTC6804ReadCellVoltageGroupD = 0x000A, // RDVCD
|
||||
LTC6804ReadAuxGroupA = 0x000C, // RDAUXA
|
||||
LTC6804ReadAuxGroupB = 0x000E, // RDAUXB
|
||||
LTC6804ReadStatusRegisterGroupA = 0x0010, // RDSTATA
|
||||
LTC6804ReadStatusRegisterGroupB = 0x0012, // RDSTATB
|
||||
LTC6804StartCellVoltageADConversion = 0x0260, // ADCV
|
||||
LTC6804StartCellOpenWireVoltageADConversion = 0x0228, // ADOW
|
||||
LTC6804StartCellSelfTestVoltageConversion = 0x0207, // CVST
|
||||
LTC6804StartGPIOADConversion = 0x0460, // ADAX
|
||||
LTC6804SelfTestGPIOConversion = 0x0407, // AXST
|
||||
LTC6804StartStatusGroupConversion = 0x0468, // ADSTAT
|
||||
LTC6804StartSelfTestStatusGroup = 0x040F, // STATST
|
||||
LTC6804StartCombinedADConversion = 0x046F, // ADCVAX
|
||||
LTC6804ClearCellVoltageGroup = 0x0711, // CLRCELL
|
||||
LTC6804ClearAuxVoltageGroup = 0x0712, // CLRAUX
|
||||
LTC6804ClearStatusRegisterGroup = 0x0713, // CLRSTAT
|
||||
LTC6804PollADConversion = 0x0714, // PLADC
|
||||
LTC6804DiagnoseMUX = 0x0715, // DIAGN
|
||||
LTC6804CommunicationWriteRegisterGroup = 0x0721, // WRCOMM
|
||||
LTC6804CommunucationReadRegisterGroup = 0x0722, // RDCOMM
|
||||
LTC6804CommuncationStart = 0x0723 // STCOMM
|
||||
} driverSWLTC6804RegistersBase;
|
||||
|
||||
typedef struct {
|
||||
bool GPIO1; // Read/Write opendrain GPIO1
|
||||
bool GPIO2; // Read/Write opendrain GPIO2
|
||||
bool GPIO3; // Read/Write opendrain GPIO3
|
||||
bool GPIO4; // Read/Write opendrain GPIO4
|
||||
bool GPIO5; // Read/Write opendrain GPIO5
|
||||
bool GPIO6; // Read/Write opendrain GPIO6
|
||||
bool GPIO7; // Read/Write opendrain GPIO7
|
||||
bool GPIO8; // Read/Write opendrain GPIO8
|
||||
bool GPIO9; // Read/Write opendrain GPIO9
|
||||
bool ReferenceON; // Reference ON
|
||||
bool SoftwareTimerFlag; // Read software timer pin
|
||||
bool ADCOption; // ADC Option register for configuration of over sampling ratio
|
||||
uint8_t noOfCells; // Number of cells to monitor (that can cause interrupt)
|
||||
uint32_t DisChargeEnableMask; // Set enable state of discharge, 1=EnableDischarge, 0=DisableDischarge
|
||||
uint8_t DischargeTimout; // Discharge timout value / limit
|
||||
double CellUnderVoltageLimit; // Undervoltage level, cell voltages under this limit will cause interrupt
|
||||
double CellOverVoltageLimit; // Over voltage limit, cell voltages over this limit will cause interrupt
|
||||
} driverLTC6804ConfigStructTypedef;
|
||||
|
||||
typedef struct {
|
||||
float sumOfCells;
|
||||
float dieTemperature;
|
||||
float voltageAnalogSupply;
|
||||
float voltageDigitalSupply;
|
||||
uint16_t overVoltage;
|
||||
uint16_t underVoltage;
|
||||
bool muxFail;
|
||||
} driverSWLTC6804StatusStructTypedef;
|
||||
|
||||
//Init
|
||||
void driverSWLTC6804Init(driverLTC6804ConfigStructTypedef configStruct, uint8_t totalNumberOfLTCs, uint8_t maxNoOfCellPerModule, uint8_t maxNoOfTempSensorPerModule, uint8_t cellMonitorType);
|
||||
|
||||
//Write/read config registers
|
||||
void driverSWLTC6804WriteConfigRegister(uint8_t totalNumberOfLTCs, uint32_t *balanceEnableMaskArray, bool useArray);
|
||||
void driverSWLTC6804WriteConfigRegisterB(uint8_t totalNumberOfLTCs, uint32_t *balanceEnableMaskArray, bool useArray);
|
||||
int8_t driverSWLTC6804ReadConfigRegister(uint8_t nIC, uint8_t r_config[][8]);
|
||||
|
||||
//Balance resistor
|
||||
void driverSWLTC6804EnableBalanceResistors(uint32_t enableMask, uint8_t cellMonitorType); // Used only for single slave test with "testbms" command
|
||||
void driverSWLTC6804EnableBalanceResistorsArray(uint32_t *enableMask, uint8_t cellMonitorType);
|
||||
|
||||
//Cell voltage
|
||||
void driverSWLTC6804StartCellAndAuxVoltageConversion(uint8_t MD,uint8_t DCP);
|
||||
void driverSWLTC6804StartCellVoltageConversion(uint8_t MD,uint8_t DCP, uint8_t CH);
|
||||
void driverSWLTC6804StartLoadedCellVoltageConversion(uint8_t MD,uint8_t DCP, uint8_t CH,uint8_t PUP);
|
||||
|
||||
bool driverSWLTC6804ReadCellVoltagesArray(float cellVoltagesArray[][18]);
|
||||
uint8_t driverSWLTC6804ReadCellVoltageRegisters(uint8_t reg, uint8_t total_ic, uint16_t cell_codes[][18]);
|
||||
void driverSWLTC6804ReadCellVoltageGroups(uint8_t reg, uint8_t total_ic, uint8_t *data);
|
||||
|
||||
// Aux sensors
|
||||
void driverSWLTC6804StartAuxVoltageConversion(uint8_t MD, uint8_t CHG);
|
||||
float driverSWLTC6804ConvertTemperatureExt(uint16_t inputValue,uint32_t ntcNominal,uint32_t ntcSeriesResistance,uint16_t ntcBetaFactor, float ntcNominalTemp);
|
||||
|
||||
bool driverSWLTC6804ReadAuxVoltagesArray(float auxVoltagesArray[][12],uint32_t ntcNominal,uint32_t ntcSeriesResistance, uint16_t ntcBetaFactor,float ntcNominalTemp);
|
||||
int8_t driverSWLTC6804ReadAuxVoltageRegisters(uint8_t reg, uint8_t total_ic, uint16_t aux_codes[][12]);
|
||||
void driverSWLTC6804ReadAuxGroups(uint8_t reg, uint8_t total_ic,uint8_t *data);
|
||||
|
||||
//Status & flags
|
||||
bool driverSWLTC6804ReadVoltageFlags(uint32_t *underVoltageFlags, uint32_t *overVoltageFlags, uint32_t lastICMask, uint8_t noOfParallelModules, uint32_t dieTemperature[]);
|
||||
uint8_t driverSWLTC6804ReadStatusValues(uint8_t total_ic, driverSWLTC6804StatusStructTypedef statusArray[]);
|
||||
void driverSWLTC6804ReadStatusGroups(uint8_t reg, uint8_t total_ic, uint8_t *data );
|
||||
|
||||
//Utilities
|
||||
void driverSWLTC6804ResetCellVoltageRegisters(void);
|
||||
void driverSWLTC6804ResetAuxRegisters(void);
|
||||
void driverSWLTC6804ResetStatusRegisters(void);
|
||||
void driverSWLTC6804DelayMS(uint32_t delayMS);
|
||||
void driverSWLTC6804Write(uint8_t *writeBytes, uint8_t writeLength);
|
||||
void driverSWLTC6804WriteRead(uint8_t *writeBytes, uint8_t writeLength, uint8_t *readBytes, uint8_t readLength);
|
||||
void driverSWLTC6804WakeIC(void);
|
||||
uint16_t driverSWLTC6804CalcPEC15(uint8_t len, uint8_t *data);
|
||||
25
Core/Inc/driverSWStorageManager.h
Normal file
25
Core/Inc/driverSWStorageManager.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef __DRIVERSWSTORAGEMANAGER_H
|
||||
#define __DRIVERSWSTORAGEMANAGER_H
|
||||
|
||||
#include "stdint.h"
|
||||
#include "stdbool.h"
|
||||
#include "driverHWEEPROM.h"
|
||||
|
||||
extern bool driverSWStorageManagerConfigEmpty;
|
||||
extern bool driverSWStorageManagerStateOfChargeEmpty;
|
||||
extern uint16_t driverSWStorageManagerConfigStructSize;
|
||||
extern uint16_t driverSWStorageManagerStateOfChargeStructSize;
|
||||
|
||||
typedef enum {
|
||||
STORAGE_CONFIG = 0,
|
||||
STORAGE_STATEOFCHARGE,
|
||||
} StorageLocationTypedef;
|
||||
|
||||
void driverSWStorageManagerInit(void);
|
||||
bool driverSWStorageManagerEraseData(void);
|
||||
bool driverSWStorageManagerStoreStruct(void *configStruct, StorageLocationTypedef storageLocation);
|
||||
bool driverSWStorageManagerGetStruct(void *configStruct, StorageLocationTypedef storageLocation);
|
||||
uint16_t driverSWStorageManagerGetOffsetFromLocation(StorageLocationTypedef storageLocation);
|
||||
uint16_t driverSWStorageManagerGetStructSize(StorageLocationTypedef storageLocation);
|
||||
|
||||
#endif
|
||||
12
Core/Inc/driverSWUART2.h
Normal file
12
Core/Inc/driverSWUART2.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#include "stm32f1xx_hal.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include "driverHWUART2.h"
|
||||
#include "libRingBuffer.h"
|
||||
|
||||
#define RINGBUFFERSIZE 1024
|
||||
|
||||
void driverSWUART2Init(uint32_t baudRate);
|
||||
char driverSWUART2PutCharInOutputBuffer(char character, FILE *stream);
|
||||
bool driverSWUART2Task(void);
|
||||
49
Core/Inc/fatfs.h
Normal file
49
Core/Inc/fatfs.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file fatfs.h
|
||||
* @brief Header for fatfs applications
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2021 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __fatfs_H
|
||||
#define __fatfs_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "ff.h"
|
||||
#include "ff_gen_drv.h"
|
||||
#include "user_diskio.h" /* defines USER_Driver as external */
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
extern uint8_t retUSER; /* Return value for USER */
|
||||
extern char USERPath[4]; /* USER logical drive path */
|
||||
extern FATFS USERFatFS; /* File system object for USER logical drive */
|
||||
extern FIL USERFile; /* File object for USER */
|
||||
|
||||
void MX_FATFS_Init(void);
|
||||
|
||||
/* USER CODE BEGIN Prototypes */
|
||||
void MX_FATFS_DeInit(void);
|
||||
/* USER CODE END Prototypes */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /*__fatfs_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
275
Core/Inc/ffconf.h
Normal file
275
Core/Inc/ffconf.h
Normal file
@@ -0,0 +1,275 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* FatFs - FAT file system module configuration file R0.11 (C)ChaN, 2015
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2021 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
#ifndef _FFCONF
|
||||
#define _FFCONF 32020 /* Revision ID */
|
||||
|
||||
/*-----------------------------------------------------------------------------/
|
||||
/ Additional user header to be used
|
||||
/-----------------------------------------------------------------------------*/
|
||||
#include "main.h"
|
||||
#include "stm32f1xx_hal.h"
|
||||
|
||||
/*-----------------------------------------------------------------------------/
|
||||
/ Functions and Buffer Configurations
|
||||
/-----------------------------------------------------------------------------*/
|
||||
|
||||
#define _FS_TINY 0 /* 0:Normal or 1:Tiny */
|
||||
/* This option switches tiny buffer configuration. (0:Normal or 1:Tiny)
|
||||
/ At the tiny configuration, size of the file object (FIL) is reduced _MAX_SS
|
||||
/ bytes. Instead of private sector buffer eliminated from the file object,
|
||||
/ common sector buffer in the file system object (FATFS) is used for the file
|
||||
/ data transfer. */
|
||||
|
||||
#define _FS_READONLY 0 /* 0:Read/Write or 1:Read only */
|
||||
/* This option switches read-only configuration. (0:Read/Write or 1:Read-only)
|
||||
/ Read-only configuration removes writing API functions, f_write(), f_sync(),
|
||||
/ f_unlink(), f_mkdir(), f_chmod(), f_rename(), f_truncate(), f_getfree()
|
||||
/ and optional writing functions as well. */
|
||||
|
||||
#define _FS_MINIMIZE 0 /* 0 to 3 */
|
||||
/* This option defines minimization level to remove some basic API functions.
|
||||
/
|
||||
/ 0: All basic functions are enabled.
|
||||
/ 1: f_stat(), f_getfree(), f_unlink(), f_mkdir(), f_chmod(), f_utime(),
|
||||
/ f_truncate() and f_rename() function are removed.
|
||||
/ 2: f_opendir(), f_readdir() and f_closedir() are removed in addition to 1.
|
||||
/ 3: f_lseek() function is removed in addition to 2. */
|
||||
|
||||
#define _USE_STRFUNC 2 /* 0:Disable or 1-2:Enable */
|
||||
/* This option switches string functions, f_gets(), f_putc(), f_puts() and
|
||||
/ f_printf().
|
||||
/
|
||||
/ 0: Disable string functions.
|
||||
/ 1: Enable without LF-CRLF conversion.
|
||||
/ 2: Enable with LF-CRLF conversion. */
|
||||
|
||||
#define _USE_FIND 0
|
||||
/* This option switches filtered directory read feature and related functions,
|
||||
/ f_findfirst() and f_findnext(). (0:Disable or 1:Enable) */
|
||||
|
||||
#define _USE_MKFS 1
|
||||
/* This option switches f_mkfs() function. (0:Disable or 1:Enable) */
|
||||
|
||||
#define _USE_FASTSEEK 1
|
||||
/* This option switches fast seek feature. (0:Disable or 1:Enable) */
|
||||
|
||||
#define _USE_LABEL 0
|
||||
/* This option switches volume label functions, f_getlabel() and f_setlabel().
|
||||
/ (0:Disable or 1:Enable) */
|
||||
|
||||
#define _USE_FORWARD 0
|
||||
/* This option switches f_forward() function. (0:Disable or 1:Enable)
|
||||
/ To enable it, also _FS_TINY need to be set to 1. */
|
||||
|
||||
/*-----------------------------------------------------------------------------/
|
||||
/ Locale and Namespace Configurations
|
||||
/-----------------------------------------------------------------------------*/
|
||||
|
||||
#define _CODE_PAGE 850
|
||||
/* This option specifies the OEM code page to be used on the target system.
|
||||
/ Incorrect setting of the code page can cause a file open failure.
|
||||
/
|
||||
/ 932 - Japanese Shift_JIS (DBCS, OEM, Windows)
|
||||
/ 936 - Simplified Chinese GBK (DBCS, OEM, Windows)
|
||||
/ 949 - Korean (DBCS, OEM, Windows)
|
||||
/ 950 - Traditional Chinese Big5 (DBCS, OEM, Windows)
|
||||
/ 1250 - Central Europe (Windows)
|
||||
/ 1251 - Cyrillic (Windows)
|
||||
/ 1252 - Latin 1 (Windows)
|
||||
/ 1253 - Greek (Windows)
|
||||
/ 1254 - Turkish (Windows)
|
||||
/ 1255 - Hebrew (Windows)
|
||||
/ 1256 - Arabic (Windows)
|
||||
/ 1257 - Baltic (Windows)
|
||||
/ 1258 - Vietnam (OEM, Windows)
|
||||
/ 437 - U.S. (OEM)
|
||||
/ 720 - Arabic (OEM)
|
||||
/ 737 - Greek (OEM)
|
||||
/ 775 - Baltic (OEM)
|
||||
/ 850 - Multilingual Latin 1 (OEM)
|
||||
/ 858 - Multilingual Latin 1 + Euro (OEM)
|
||||
/ 852 - Latin 2 (OEM)
|
||||
/ 855 - Cyrillic (OEM)
|
||||
/ 866 - Russian (OEM)
|
||||
/ 857 - Turkish (OEM)
|
||||
/ 862 - Hebrew (OEM)
|
||||
/ 874 - Thai (OEM, Windows)
|
||||
/ 1 - ASCII (No extended character. Valid for only non-LFN configuration.) */
|
||||
|
||||
#define _USE_LFN 0 /* 0 to 3 */
|
||||
#define _MAX_LFN 255 /* Maximum LFN length to handle (12 to 255) */
|
||||
/* The _USE_LFN option switches the LFN feature.
|
||||
/
|
||||
/ 0: Disable LFN feature. _MAX_LFN has no effect.
|
||||
/ 1: Enable LFN with static working buffer on the BSS. Always NOT thread-safe.
|
||||
/ 2: Enable LFN with dynamic working buffer on the STACK.
|
||||
/ 3: Enable LFN with dynamic working buffer on the HEAP.
|
||||
/
|
||||
/ When enable the LFN feature, Unicode handling functions (option/unicode.c) must
|
||||
/ be added to the project. The LFN working buffer occupies (_MAX_LFN + 1) * 2 bytes.
|
||||
/ When use stack for the working buffer, take care on stack overflow. When use heap
|
||||
/ memory for the working buffer, memory management functions, ff_memalloc() and
|
||||
/ ff_memfree(), must be added to the project. */
|
||||
|
||||
#define _LFN_UNICODE 0 /* 0:ANSI/OEM or 1:Unicode */
|
||||
/* This option switches character encoding on the API. (0:ANSI/OEM or 1:Unicode)
|
||||
/ To use Unicode string for the path name, enable LFN feature and set _LFN_UNICODE
|
||||
/ to 1. This option also affects behavior of string I/O functions. */
|
||||
|
||||
#define _STRF_ENCODE 3
|
||||
/* When _LFN_UNICODE is 1, this option selects the character encoding on the file to
|
||||
/ be read/written via string I/O functions, f_gets(), f_putc(), f_puts and f_printf().
|
||||
/
|
||||
/ 0: ANSI/OEM
|
||||
/ 1: UTF-16LE
|
||||
/ 2: UTF-16BE
|
||||
/ 3: UTF-8
|
||||
/
|
||||
/ When _LFN_UNICODE is 0, this option has no effect. */
|
||||
|
||||
#define _FS_RPATH 0 /* 0 to 2 */
|
||||
/* This option configures relative path feature.
|
||||
/
|
||||
/ 0: Disable relative path feature and remove related functions.
|
||||
/ 1: Enable relative path feature. f_chdir() and f_chdrive() are available.
|
||||
/ 2: f_getcwd() function is available in addition to 1.
|
||||
/
|
||||
/ Note that directory items read via f_readdir() are affected by this option. */
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ Drive/Volume Configurations
|
||||
/----------------------------------------------------------------------------*/
|
||||
|
||||
#define _VOLUMES 1
|
||||
/* Number of volumes (logical drives) to be used. */
|
||||
|
||||
/* USER CODE BEGIN Volumes */
|
||||
#define _STR_VOLUME_ID 0 /* 0:Use only 0-9 for drive ID, 1:Use strings for drive ID */
|
||||
#define _VOLUME_STRS "RAM","NAND","CF","SD1","SD2","USB1","USB2","USB3"
|
||||
/* _STR_VOLUME_ID option switches string volume ID feature.
|
||||
/ When _STR_VOLUME_ID is set to 1, also pre-defined strings can be used as drive
|
||||
/ number in the path name. _VOLUME_STRS defines the drive ID strings for each
|
||||
/ logical drives. Number of items must be equal to _VOLUMES. Valid characters for
|
||||
/ the drive ID strings are: A-Z and 0-9. */
|
||||
/* USER CODE END Volumes */
|
||||
|
||||
#define _MULTI_PARTITION 0 /* 0:Single partition, 1:Multiple partition */
|
||||
/* This option switches multi-partition feature. By default (0), each logical drive
|
||||
/ number is bound to the same physical drive number and only an FAT volume found on
|
||||
/ the physical drive will be mounted. When multi-partition feature is enabled (1),
|
||||
/ each logical drive number is bound to arbitrary physical drive and partition
|
||||
/ listed in the VolToPart[]. Also f_fdisk() funciton will be available. */
|
||||
|
||||
#define _MIN_SS 512 /* 512, 1024, 2048 or 4096 */
|
||||
#define _MAX_SS 512 /* 512, 1024, 2048 or 4096 */
|
||||
/* These options configure the range of sector size to be supported. (512, 1024,
|
||||
/ 2048 or 4096) Always set both 512 for most systems, all type of memory cards and
|
||||
/ harddisk. But a larger value may be required for on-board flash memory and some
|
||||
/ type of optical media. When _MAX_SS is larger than _MIN_SS, FatFs is configured
|
||||
/ to variable sector size and GET_SECTOR_SIZE command must be implemented to the
|
||||
/ disk_ioctl() function. */
|
||||
|
||||
#define _USE_TRIM 0
|
||||
/* This option switches ATA-TRIM feature. (0:Disable or 1:Enable)
|
||||
/ To enable Trim feature, also CTRL_TRIM command should be implemented to the
|
||||
/ disk_ioctl() function. */
|
||||
|
||||
#define _FS_NOFSINFO 0 /* 0,1,2 or 3 */
|
||||
/* If you need to know correct free space on the FAT32 volume, set bit 0 of this
|
||||
/ option, and f_getfree() function at first time after volume mount will force
|
||||
/ a full FAT scan. Bit 1 controls the use of last allocated cluster number.
|
||||
/
|
||||
/ bit0=0: Use free cluster count in the FSINFO if available.
|
||||
/ bit0=1: Do not trust free cluster count in the FSINFO.
|
||||
/ bit1=0: Use last allocated cluster number in the FSINFO if available.
|
||||
/ bit1=1: Do not trust last allocated cluster number in the FSINFO.
|
||||
*/
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ System Configurations
|
||||
/----------------------------------------------------------------------------*/
|
||||
|
||||
#define _FS_NORTC 0
|
||||
#define _NORTC_MON 6
|
||||
#define _NORTC_MDAY 4
|
||||
#define _NORTC_YEAR 2015
|
||||
/* The _FS_NORTC option switches timestamp feature. If the system does not have
|
||||
/ an RTC function or valid timestamp is not needed, set _FS_NORTC to 1 to disable
|
||||
/ the timestamp feature. All objects modified by FatFs will have a fixed timestamp
|
||||
/ defined by _NORTC_MON, _NORTC_MDAY and _NORTC_YEAR.
|
||||
/ When timestamp feature is enabled (_FS_NORTC == 0), get_fattime() function need
|
||||
/ to be added to the project to read current time form RTC. _NORTC_MON,
|
||||
/ _NORTC_MDAY and _NORTC_YEAR have no effect.
|
||||
/ These options have no effect at read-only configuration (_FS_READONLY == 1). */
|
||||
|
||||
#define _FS_LOCK 2 /* 0:Disable or >=1:Enable */
|
||||
/* The _FS_LOCK option switches file lock feature to control duplicated file open
|
||||
/ and illegal operation to open objects. This option must be 0 when _FS_READONLY
|
||||
/ is 1.
|
||||
/
|
||||
/ 0: Disable file lock feature. To avoid volume corruption, application program
|
||||
/ should avoid illegal open, remove and rename to the open objects.
|
||||
/ >0: Enable file lock feature. The value defines how many files/sub-directories
|
||||
/ can be opened simultaneously under file lock control. Note that the file
|
||||
/ lock feature is independent of re-entrancy. */
|
||||
|
||||
#define _FS_REENTRANT 0 /* 0:Disable or 1:Enable */
|
||||
#define _FS_TIMEOUT 1000 /* Timeout period in unit of time ticks */
|
||||
#define _SYNC_t NULL
|
||||
/* The _FS_REENTRANT option switches the re-entrancy (thread safe) of the FatFs
|
||||
/ module itself. Note that regardless of this option, file access to different
|
||||
/ volume is always re-entrant and volume control functions, f_mount(), f_mkfs()
|
||||
/ and f_fdisk() function, are always not re-entrant. Only file/directory access
|
||||
/ to the same volume is under control of this feature.
|
||||
/
|
||||
/ 0: Disable re-entrancy. _FS_TIMEOUT and _SYNC_t have no effect.
|
||||
/ 1: Enable re-entrancy. Also user provided synchronization handlers,
|
||||
/ ff_req_grant(), ff_rel_grant(), ff_del_syncobj() and ff_cre_syncobj()
|
||||
/ function, must be added to the project. Samples are available in
|
||||
/ option/syscall.c.
|
||||
/
|
||||
/ The _FS_TIMEOUT defines timeout period in unit of time tick.
|
||||
/ The _SYNC_t defines O/S dependent sync object type. e.g. HANDLE, ID, OS_EVENT*,
|
||||
/ SemaphoreHandle_t and etc.. */
|
||||
|
||||
#define _WORD_ACCESS 0 /* 0 or 1 */
|
||||
/* The _WORD_ACCESS option is an only platform dependent option. It defines
|
||||
/ which access method is used to the word data on the FAT volume.
|
||||
/
|
||||
/ 0: Byte-by-byte access. Always compatible with all platforms.
|
||||
/ 1: Word access. Do not choose this unless under both the following conditions.
|
||||
/
|
||||
/ * Address misaligned memory access is always allowed to ALL instructions.
|
||||
/ * Byte order on the memory is little-endian.
|
||||
/
|
||||
/ If it is the case, _WORD_ACCESS can also be set to 1 to reduce code size.
|
||||
/ Following table shows allowable settings of some processor types.
|
||||
/
|
||||
/ ARM7TDMI 0 ColdFire 0 V850E 0
|
||||
/ Cortex-M3 0 Z80 0/1 V850ES 0/1
|
||||
/ Cortex-M0 0 x86 0/1 TLCS-870 0/1
|
||||
/ AVR 0/1 RX600(LE) 0/1 TLCS-900 0/1
|
||||
/ AVR32 0 RL78 0 R32C 0
|
||||
/ PIC18 0/1 SH-2 0 M16C 0/1
|
||||
/ PIC24 0 H8S 0 MSP430 0
|
||||
/ PIC32 0 H8/300H 0 8051 0/1
|
||||
*/
|
||||
|
||||
#endif /* _FFCONF */
|
||||
61
Core/Inc/generalDefines.h
Normal file
61
Core/Inc/generalDefines.h
Normal file
@@ -0,0 +1,61 @@
|
||||
// Define the hardware version here:
|
||||
#ifndef ENNOID_SS_LITE
|
||||
#define ENNOID_SS_LITE 0
|
||||
#endif
|
||||
|
||||
#ifndef ENNOID_SS
|
||||
#define ENNOID_SS 0
|
||||
#endif
|
||||
|
||||
#ifndef ENNOID_LV
|
||||
#define ENNOID_LV 1
|
||||
#endif
|
||||
|
||||
#ifndef ENNOID_HV
|
||||
#define ENNOID_HV 0
|
||||
#endif
|
||||
|
||||
// Firmware version
|
||||
//#define FW_VERSION_MAJOR 1
|
||||
//#define FW_VERSION_MINOR 3
|
||||
//#define FW_REAL_VERSION "V1.3"
|
||||
|
||||
#define FW_VERSION_MAJOR 1
|
||||
#define FW_VERSION_MINOR 3
|
||||
#define FW_REAL_VERSION "V1.3"
|
||||
|
||||
// UUID
|
||||
#define STM32_UUID ((uint32_t*)0x1FFFF7E8)
|
||||
#define STM32_UUID_8 ((uint8_t*)0x1FFFF7E8)
|
||||
|
||||
// Hardware names and limits
|
||||
#if ENNOID_LV
|
||||
#define HW_NAME "ENNOID-LV"
|
||||
#define HW_LIM_CELL_BALANCE_MAX_SIMULTANEOUS_DISCHARGE 18
|
||||
#define HW_LIM_CELL_MONITOR_IC_COUNT 18
|
||||
#define HW_LIM_MIN_NOT_USED_DELAY 5000
|
||||
#endif
|
||||
|
||||
#if ENNOID_HV
|
||||
#define HW_NAME "ENNOID-HV"
|
||||
#define HW_LIM_CELL_BALANCE_MAX_SIMULTANEOUS_DISCHARGE 18
|
||||
#define HW_LIM_CELL_MONITOR_IC_COUNT 18
|
||||
#define HW_LIM_MIN_NOT_USED_DELAY 5000
|
||||
#endif
|
||||
|
||||
#if ENNOID_SS
|
||||
#define HW_NAME "ENNOID-SS"
|
||||
#define HW_LIM_CELL_BALANCE_MAX_SIMULTANEOUS_DISCHARGE 18
|
||||
#define HW_LIM_CELL_MONITOR_IC_COUNT 1
|
||||
#define HW_LIM_MIN_NOT_USED_DELAY 5000
|
||||
#endif
|
||||
|
||||
#if ENNOID_SS_LITE
|
||||
#define HW_NAME "ENNOID-SS-LITE"
|
||||
#define HW_LIM_CELL_BALANCE_MAX_SIMULTANEOUS_DISCHARGE 18
|
||||
#define HW_LIM_CELL_MONITOR_IC_COUNT 1
|
||||
#define HW_LIM_MIN_NOT_USED_DELAY 5000
|
||||
#endif
|
||||
|
||||
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
|
||||
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
|
||||
51
Core/Inc/libBuffer.h
Normal file
51
Core/Inc/libBuffer.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
Copyright 2016 Benjamin Vedder benjamin@vedder.se
|
||||
|
||||
This file is part of the VESC firmware.
|
||||
|
||||
The VESC firmware is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The VESC firmware is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef BUFFER_H_
|
||||
#define BUFFER_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
void libBufferAppend_int8(uint8_t* buffer, int8_t number, int32_t *index);
|
||||
void libBufferAppend_uint8(uint8_t* buffer, uint8_t number, int32_t *index);
|
||||
void libBufferAppend_int16(uint8_t* buffer, int16_t number, int32_t *index);
|
||||
void libBufferAppend_uint16(uint8_t* buffer, uint16_t number, int32_t *index);
|
||||
void libBufferAppend_int32(uint8_t* buffer, int32_t number, int32_t *index);
|
||||
void libBufferAppend_uint32(uint8_t* buffer, uint32_t number, int32_t *index);
|
||||
void libBufferAppend_uint64(uint8_t* buffer, uint64_t number, int32_t *index);
|
||||
|
||||
void libBufferAppend_int16_LSBFirst(uint8_t* buffer, int16_t number, int32_t *index);
|
||||
void libBufferAppend_uint16_LSBFirst(uint8_t* buffer, uint16_t number, int32_t *index);
|
||||
void libBufferAppend_int32_LSBFirst(uint8_t* buffer, int32_t number, int32_t *index);
|
||||
void libBufferAppend_uint32_LSBFirst(uint8_t* buffer, uint32_t number, int32_t *index);
|
||||
|
||||
void libBufferAppend_float16(uint8_t* buffer, float number, float scale, int32_t *index);
|
||||
void libBufferAppend_float32(uint8_t* buffer, float number, float scale, int32_t *index);
|
||||
void libBufferAppend_float32_auto(uint8_t* buffer, float number, int32_t *index);
|
||||
int8_t libBufferGet_int8(const uint8_t *buffer, int32_t *index);
|
||||
uint8_t libBufferGet_uint8(const uint8_t *buffer, int32_t *index);
|
||||
int16_t libBufferGet_int16(const uint8_t *buffer, int32_t *index);
|
||||
uint16_t libBufferGet_uint16(const uint8_t *buffer, int32_t *index);
|
||||
int32_t libBufferGet_int32(const uint8_t *buffer, int32_t *index);
|
||||
uint32_t libBufferGet_uint32(const uint8_t *buffer, int32_t *index);
|
||||
float libBufferGet_float16(const uint8_t *buffer, float scale, int32_t *index);
|
||||
float libBufferGet_float32(const uint8_t *buffer, float scale, int32_t *index);
|
||||
float libBufferGet_float32_auto(const uint8_t *buffer, int32_t *index);
|
||||
|
||||
#endif /* BUFFER_H_ */
|
||||
28
Core/Inc/libCRC.h
Normal file
28
Core/Inc/libCRC.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
Copyright 2016 Benjamin Vedder benjamin@vedder.se
|
||||
|
||||
This file is part of the VESC firmware.
|
||||
|
||||
The VESC firmware is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The VESC firmware is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef CRC_H_
|
||||
#define CRC_H_
|
||||
|
||||
/*
|
||||
* Functions
|
||||
*/
|
||||
unsigned short libCRCCalcCRC16(unsigned char *buf, unsigned int len);
|
||||
|
||||
#endif /* CRC_H_ */
|
||||
36
Core/Inc/libPacket.h
Normal file
36
Core/Inc/libPacket.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
Copyright 2016 Benjamin Vedder benjamin@vedder.se
|
||||
|
||||
This file is part of the VESC firmware.
|
||||
|
||||
The VESC firmware is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The VESC firmware is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PACKET_H_
|
||||
#define PACKET_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// Settings
|
||||
#define PACKET_RX_TIMEOUT 10
|
||||
#define PACKET_HANDLERS 2
|
||||
#define PACKET_MAX_PL_LEN 1024
|
||||
|
||||
// Functions
|
||||
void libPacketInit(void (*s_func)(unsigned char *data, unsigned int len), void (*p_func)(unsigned char *data, unsigned int len), int handler_num);
|
||||
void libPacketProcessByte(uint8_t rx_data, int handler_num);
|
||||
void libPacketTimerFunc(void);
|
||||
void libPacketSendPacket(unsigned char *data, unsigned int len, int handler_num);
|
||||
|
||||
#endif /* PACKET_H_ */
|
||||
55
Core/Inc/libRingbuffer.h
Normal file
55
Core/Inc/libRingbuffer.h
Normal file
@@ -0,0 +1,55 @@
|
||||
#ifndef RingBuf_h
|
||||
#define RingBuf_h
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
//https://github.com/wizard97/ArduinoRingBuffer
|
||||
|
||||
typedef struct libRingBufferTypedef libRingBufferTypedef;
|
||||
|
||||
typedef struct libRingBufferTypedef {
|
||||
// Invariant: end and start is always in bounds
|
||||
unsigned char *buf;
|
||||
unsigned int len, size, start, end, elements;
|
||||
|
||||
// Private:
|
||||
int (*next_end_index) (libRingBufferTypedef*);
|
||||
int (*incr_end_index) (libRingBufferTypedef*);
|
||||
|
||||
int (*incr_start_index) (libRingBufferTypedef*);
|
||||
|
||||
//public:
|
||||
// Returns true if full
|
||||
bool (*isFull) (libRingBufferTypedef*);
|
||||
// Returns true if empty
|
||||
bool (*isEmpty) (libRingBufferTypedef*);
|
||||
// Returns number of elemnts in buffer
|
||||
unsigned int (*numElements)(libRingBufferTypedef*);
|
||||
// Add Event, Returns index where added in buffer, -1 on full buffer
|
||||
int (*add) (libRingBufferTypedef*, const void*);
|
||||
// Returns pointer to nth element, NULL when nth element is empty
|
||||
void *(*peek) (libRingBufferTypedef*, unsigned int);
|
||||
// Removes element and copies it to location pointed to by void *
|
||||
// Returns pointer passed in, NULL on empty buffer
|
||||
void *(*pull) (libRingBufferTypedef*, void *);
|
||||
|
||||
} libRingBufferTypedef;
|
||||
|
||||
libRingBufferTypedef *libRingBufferNew(int size, int len);
|
||||
int libRingBufferInit(libRingBufferTypedef *self, int size, int len);
|
||||
int libRingBufferDelete(libRingBufferTypedef *self);
|
||||
int libRingBufferNextEndIndex(libRingBufferTypedef *self);
|
||||
int libRingBufferIncrEnd(libRingBufferTypedef *self);
|
||||
int libRingBufferIncrStart(libRingBufferTypedef *self);
|
||||
int libRingBufferAdd(libRingBufferTypedef *self, const void *object);
|
||||
void *libRingBufferPeek(libRingBufferTypedef *self, unsigned int num);
|
||||
void *libRingBufferPull(libRingBufferTypedef *self, void *object);
|
||||
bool libRingBufferIsFull(libRingBufferTypedef *self);
|
||||
bool libRingBufferIsEmpty(libRingBufferTypedef *self);
|
||||
unsigned int libRingBufferNumElements(libRingBufferTypedef *self);
|
||||
|
||||
#endif
|
||||
143
Core/Inc/main.h
Normal file
143
Core/Inc/main.h
Normal file
@@ -0,0 +1,143 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file : main.h
|
||||
* @brief : Header for main.c file.
|
||||
* This file contains the common defines of the application.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2021 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __MAIN_H
|
||||
#define __MAIN_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32f1xx_hal.h"
|
||||
|
||||
extern void usbTIM(uint8_t OnOff);
|
||||
|
||||
extern uint16_t load_current;
|
||||
extern uint16_t charge_current;
|
||||
extern float float_current;
|
||||
extern uint8_t load_switch_state;
|
||||
extern uint8_t charge_switch_state;
|
||||
|
||||
extern uint16_t export_adc_average_res;
|
||||
|
||||
extern float export_real_capacity;
|
||||
|
||||
extern float cellVoltageHigh_Maximum;
|
||||
extern float cellVoltageHigh_Maximum_Hyst;
|
||||
extern float maxChargeCurrent;
|
||||
extern float maxLoadCurrent;
|
||||
extern float cellVoltageLow_Minimum;
|
||||
extern float cellVoltageLow_Minimum_Hyst;
|
||||
extern float currentZero_config;
|
||||
|
||||
extern float Brush_Minimum_SoC;
|
||||
extern uint8_t Brush_Default_State;
|
||||
|
||||
extern float maxTemperature;
|
||||
extern float maxTemperature_Hyst;
|
||||
|
||||
|
||||
extern uint8_t Pilot_Status;
|
||||
extern uint8_t Maximum_Charge_Current_Status;
|
||||
extern uint8_t Maximum_Voltage_Status;
|
||||
extern uint8_t Maximum_Temp_Status;
|
||||
extern uint8_t Maximum_Load_Current_Status;
|
||||
extern uint8_t Minimum_Voltage_Status;
|
||||
extern uint8_t Deep_Discharge_Status;
|
||||
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN ET */
|
||||
|
||||
/* USER CODE END ET */
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EC */
|
||||
|
||||
/* USER CODE END EC */
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EM */
|
||||
|
||||
/* USER CODE END EM */
|
||||
|
||||
/* Exported functions prototypes ---------------------------------------------*/
|
||||
void Error_Handler(void);
|
||||
|
||||
void UpdateGSMParamsFromConfig();
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
/* USER CODE END EFP */
|
||||
|
||||
/* Private defines -----------------------------------------------------------*/
|
||||
#define Output_2_Pin GPIO_PIN_2
|
||||
#define Output_2_GPIO_Port GPIOE
|
||||
#define Output_3_Pin GPIO_PIN_3
|
||||
#define Output_3_GPIO_Port GPIOE
|
||||
#define Output_4_Pin GPIO_PIN_4
|
||||
#define Output_4_GPIO_Port GPIOE
|
||||
#define Output_5_Pin GPIO_PIN_5
|
||||
#define Output_5_GPIO_Port GPIOE
|
||||
#define SD_CD_Pin GPIO_PIN_10
|
||||
#define SD_CD_GPIO_Port GPIOA
|
||||
#define SPI3_CS_Pin GPIO_PIN_3
|
||||
#define SPI3_CS_GPIO_Port GPIOC
|
||||
#define Input_1_Pin GPIO_PIN_7
|
||||
#define Input_1_GPIO_Port GPIOE
|
||||
#define Input_2_Pin GPIO_PIN_8
|
||||
#define Input_2_GPIO_Port GPIOE
|
||||
#define Input_3_Pin GPIO_PIN_9
|
||||
#define Input_3_GPIO_Port GPIOE
|
||||
#define GSM_RST_Pin GPIO_PIN_10
|
||||
#define GSM_RST_GPIO_Port GPIOE
|
||||
#define HL5_Pin GPIO_PIN_12
|
||||
#define HL5_GPIO_Port GPIOE
|
||||
#define HL4_Pin GPIO_PIN_13
|
||||
#define HL4_GPIO_Port GPIOE
|
||||
#define HL3_Pin GPIO_PIN_14
|
||||
#define HL3_GPIO_Port GPIOE
|
||||
#define HL2_Pin GPIO_PIN_15
|
||||
#define HL2_GPIO_Port GPIOE
|
||||
#define SD_CS_Pin GPIO_PIN_8
|
||||
#define SD_CS_GPIO_Port GPIOA
|
||||
#define Charging_Pin GPIO_PIN_2
|
||||
#define Charging_GPIO_Port GPIOD
|
||||
#define Output_0_Pin GPIO_PIN_0
|
||||
#define Output_0_GPIO_Port GPIOE
|
||||
#define Output_1_Pin GPIO_PIN_1
|
||||
#define Output_1_GPIO_Port GPIOE
|
||||
/* USER CODE BEGIN Private defines */
|
||||
#define SD_SPI_HANDLE hspi1
|
||||
/* USER CODE END Private defines */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __MAIN_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
784
Core/Inc/mainDataTypes.h
Normal file
784
Core/Inc/mainDataTypes.h
Normal file
@@ -0,0 +1,784 @@
|
||||
/*
|
||||
Copyright 2016 Benjamin Vedder benjamin@vedder.se
|
||||
Copyright 2017 - 2018 Danny Bokma danny@diebie.nl
|
||||
Copyright 2019 - 2020 Kevin Dionne kevin.dionne@ennoid.me
|
||||
|
||||
This file is part of the DieBieMS/ENNOID-BMS firmware.
|
||||
|
||||
The DieBieMS/ENNOID-BMS firmware is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The DieBieMS/ENNOID-BMS firmware is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef DATATYPES_H_
|
||||
#define DATATYPES_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "dataHelper.h"
|
||||
|
||||
#define systime_t uint32_t // was not here
|
||||
|
||||
typedef enum {
|
||||
BALANCE_MODE_DISABLED = 0,
|
||||
BALANCE_MODE_CHARGING_ONLY,
|
||||
BALANCE_MODE_DURING_AND_AFTER_CHARGING,
|
||||
BALANCE_MODE_ALWAYS
|
||||
} BMS_BALANCE_MODE;
|
||||
|
||||
typedef enum {
|
||||
HW_TYPE_VESC = 0,
|
||||
HW_TYPE_VESC_BMS,
|
||||
HW_TYPE_CUSTOM_MODULE,
|
||||
HW_TYPE_EBMS
|
||||
} HW_TYPE;
|
||||
|
||||
typedef enum {
|
||||
I_MEASURE_MODE_BMS = 0,
|
||||
I_MEASURE_MODE_VESC
|
||||
} I_MEASURE_MODE;
|
||||
|
||||
// Data types
|
||||
typedef enum {
|
||||
MC_STATE_OFF = 0,
|
||||
MC_STATE_DETECTING,
|
||||
MC_STATE_RUNNING,
|
||||
MC_STATE_FULL_BRAKE,
|
||||
} mc_state;
|
||||
|
||||
typedef enum {
|
||||
PWM_MODE_NONSYNCHRONOUS_HISW = 0, // This mode is not recommended
|
||||
PWM_MODE_SYNCHRONOUS, // The recommended and most tested mode
|
||||
PWM_MODE_BIPOLAR // Some glitches occasionally, can kill MOSFETs
|
||||
} mc_pwm_mode;
|
||||
|
||||
typedef enum {
|
||||
COMM_MODE_INTEGRATE = 0,
|
||||
COMM_MODE_DELAY
|
||||
} mc_comm_mode;
|
||||
|
||||
typedef enum {
|
||||
SENSOR_MODE_SENSORLESS = 0,
|
||||
SENSOR_MODE_SENSORED,
|
||||
SENSOR_MODE_HYBRID
|
||||
} mc_sensor_mode;
|
||||
|
||||
typedef enum {
|
||||
FOC_SENSOR_MODE_SENSORLESS = 0,
|
||||
FOC_SENSOR_MODE_ENCODER,
|
||||
FOC_SENSOR_MODE_HALL
|
||||
} mc_foc_sensor_mode;
|
||||
|
||||
typedef enum {
|
||||
MOTOR_TYPE_BLDC = 0,
|
||||
MOTOR_TYPE_DC,
|
||||
MOTOR_TYPE_FOC
|
||||
} mc_motor_type;
|
||||
|
||||
typedef enum {
|
||||
FAULT_CODE_NONE = 0,
|
||||
FAULT_CODE_PACK_OVER_VOLTAGE,
|
||||
FAULT_CODE_PACK_UNDER_VOLTAGE,
|
||||
FAULT_CODE_LOAD_OVER_VOLTAGE,
|
||||
FAULT_CODE_LOAD_UNDER_VOLTAGE,
|
||||
FAULT_CODE_CHARGER_OVER_VOLTAGE,
|
||||
FAULT_CODE_CHARGER_UNDER_VOLTAGE,
|
||||
FAULT_CODE_CELL_HARD_OVER_VOLTAGE,
|
||||
FAULT_CODE_CELL_HARD_UNDER_VOLTAGE,
|
||||
FAULT_CODE_CELL_SOFT_OVER_VOLTAGE,
|
||||
FAULT_CODE_CELL_SOFT_UNDER_VOLTAGE,
|
||||
FAULT_CODE_MAX_UVP_OVP_ERRORS,
|
||||
FAULT_CODE_MAX_UVT_OVT_ERRORS,
|
||||
FAULT_CODE_OVER_CURRENT,
|
||||
FAULT_CODE_OVER_TEMP_BMS,
|
||||
FAULT_CODE_UNDER_TEMP_BMS,
|
||||
FAULT_CODE_DISCHARGE_OVER_TEMP_CELLS,
|
||||
FAULT_CODE_DISCHARGE_UNDER_TEMP_CELLS,
|
||||
FAULT_CODE_CHARGE_OVER_TEMP_CELLS,
|
||||
FAULT_CODE_CHARGE_UNDER_TEMP_CELLS,
|
||||
FAULT_CODE_PRECHARGE_TIMEOUT,
|
||||
FAULT_CODE_DISCHARGE_RETRY,
|
||||
FAULT_CODE_CHARGE_RETRY,
|
||||
FAULT_CODE_CAN_DELAYED_POWER_DOWN,
|
||||
FAULT_CODE_NOT_USED_TIMEOUT,
|
||||
FAULT_CODE_CHARGER_DISCONNECT
|
||||
} bms_fault_state;
|
||||
|
||||
typedef enum {
|
||||
CONTROL_MODE_DUTY = 0,
|
||||
CONTROL_MODE_SPEED,
|
||||
CONTROL_MODE_CURRENT,
|
||||
CONTROL_MODE_CURRENT_BRAKE,
|
||||
CONTROL_MODE_POS,
|
||||
CONTROL_MODE_HANDBRAKE,
|
||||
CONTROL_MODE_OPENLOOP,
|
||||
CONTROL_MODE_NONE
|
||||
} mc_control_mode;
|
||||
|
||||
typedef enum {
|
||||
DISP_POS_MODE_NONE = 0,
|
||||
DISP_POS_MODE_INDUCTANCE,
|
||||
DISP_POS_MODE_OBSERVER,
|
||||
DISP_POS_MODE_ENCODER,
|
||||
DISP_POS_MODE_PID_POS,
|
||||
DISP_POS_MODE_PID_POS_ERROR,
|
||||
DISP_POS_MODE_ENCODER_OBSERVER_ERROR
|
||||
} disp_pos_mode;
|
||||
|
||||
typedef enum {
|
||||
SENSOR_PORT_MODE_HALL = 0,
|
||||
SENSOR_PORT_MODE_ABI,
|
||||
SENSOR_PORT_MODE_AS5047_SPI
|
||||
} sensor_port_mode;
|
||||
|
||||
typedef struct {
|
||||
float cycle_int_limit;
|
||||
float cycle_int_limit_running;
|
||||
float cycle_int_limit_max;
|
||||
float comm_time_sum;
|
||||
float comm_time_sum_min_rpm;
|
||||
int32_t comms;
|
||||
uint32_t time_at_comm;
|
||||
} mc_rpm_dep_struct;
|
||||
|
||||
typedef enum {
|
||||
DRV8301_OC_LIMIT = 0,
|
||||
DRV8301_OC_LATCH_SHUTDOWN,
|
||||
DRV8301_OC_REPORT_ONLY,
|
||||
DRV8301_OC_DISABLED
|
||||
} drv8301_oc_mode;
|
||||
|
||||
typedef enum {
|
||||
DEBUG_SAMPLING_OFF = 0,
|
||||
DEBUG_SAMPLING_NOW,
|
||||
DEBUG_SAMPLING_START,
|
||||
DEBUG_SAMPLING_TRIGGER_START,
|
||||
DEBUG_SAMPLING_TRIGGER_FAULT,
|
||||
DEBUG_SAMPLING_TRIGGER_START_NOSEND,
|
||||
DEBUG_SAMPLING_TRIGGER_FAULT_NOSEND,
|
||||
DEBUG_SAMPLING_SEND_LAST_SAMPLES
|
||||
} debug_sampling_mode;
|
||||
|
||||
typedef struct {
|
||||
// Switching and drive
|
||||
mc_pwm_mode pwm_mode;
|
||||
mc_comm_mode comm_mode;
|
||||
mc_motor_type motor_type;
|
||||
mc_sensor_mode sensor_mode;
|
||||
// Limits
|
||||
float l_current_max;
|
||||
float l_current_min;
|
||||
float l_in_current_max;
|
||||
float l_in_current_min;
|
||||
float l_abs_current_max;
|
||||
float l_min_erpm;
|
||||
float l_max_erpm;
|
||||
float l_erpm_start;
|
||||
float l_max_erpm_fbrake;
|
||||
float l_max_erpm_fbrake_cc;
|
||||
float l_min_vin;
|
||||
float l_max_vin;
|
||||
float l_battery_cut_start;
|
||||
float l_battery_cut_end;
|
||||
bool l_slow_abs_current;
|
||||
float l_temp_fet_start;
|
||||
float l_temp_fet_end;
|
||||
float l_temp_motor_start;
|
||||
float l_temp_motor_end;
|
||||
float l_min_duty;
|
||||
float l_max_duty;
|
||||
float l_watt_max;
|
||||
float l_watt_min;
|
||||
// Overridden limits (Computed during runtime)
|
||||
float lo_current_max;
|
||||
float lo_current_min;
|
||||
float lo_in_current_max;
|
||||
float lo_in_current_min;
|
||||
float lo_current_motor_max_now;
|
||||
float lo_current_motor_min_now;
|
||||
// Sensorless (bldc)
|
||||
float sl_min_erpm;
|
||||
float sl_min_erpm_cycle_int_limit;
|
||||
float sl_max_fullbreak_current_dir_change;
|
||||
float sl_cycle_int_limit;
|
||||
float sl_phase_advance_at_br;
|
||||
float sl_cycle_int_rpm_br;
|
||||
float sl_bemf_coupling_k;
|
||||
// Hall sensor
|
||||
int8_t hall_table[8];
|
||||
float hall_sl_erpm;
|
||||
// FOC
|
||||
float foc_current_kp;
|
||||
float foc_current_ki;
|
||||
float foc_f_sw;
|
||||
float foc_dt_us;
|
||||
float foc_encoder_offset;
|
||||
bool foc_encoder_inverted;
|
||||
float foc_encoder_ratio;
|
||||
float foc_motor_l;
|
||||
float foc_motor_r;
|
||||
float foc_motor_flux_linkage;
|
||||
float foc_observer_gain;
|
||||
float foc_observer_gain_slow;
|
||||
float foc_pll_kp;
|
||||
float foc_pll_ki;
|
||||
float foc_duty_dowmramp_kp;
|
||||
float foc_duty_dowmramp_ki;
|
||||
float foc_openloop_rpm;
|
||||
float foc_sl_openloop_hyst;
|
||||
float foc_sl_openloop_time;
|
||||
float foc_sl_d_current_duty;
|
||||
float foc_sl_d_current_factor;
|
||||
mc_foc_sensor_mode foc_sensor_mode;
|
||||
uint8_t foc_hall_table[8];
|
||||
float foc_sl_erpm;
|
||||
bool foc_sample_v0_v7;
|
||||
bool foc_sample_high_current;
|
||||
float foc_sat_comp;
|
||||
bool foc_temp_comp;
|
||||
float foc_temp_comp_base_temp;
|
||||
// Speed PID
|
||||
float s_pid_kp;
|
||||
float s_pid_ki;
|
||||
float s_pid_kd;
|
||||
float s_pid_min_erpm;
|
||||
bool s_pid_allow_braking;
|
||||
// Pos PID
|
||||
float p_pid_kp;
|
||||
float p_pid_ki;
|
||||
float p_pid_kd;
|
||||
float p_pid_ang_div;
|
||||
// Current controller
|
||||
float cc_startup_boost_duty;
|
||||
float cc_min_current;
|
||||
float cc_gain;
|
||||
float cc_ramp_step_max;
|
||||
// Misc
|
||||
int32_t m_fault_stop_time_ms;
|
||||
float m_duty_ramp_step;
|
||||
float m_current_backoff_gain;
|
||||
uint32_t m_encoder_counts;
|
||||
sensor_port_mode m_sensor_port_mode;
|
||||
bool m_invert_direction;
|
||||
drv8301_oc_mode m_drv8301_oc_mode;
|
||||
int m_drv8301_oc_adj;
|
||||
float m_bldc_f_sw_min;
|
||||
float m_bldc_f_sw_max;
|
||||
float m_dc_f_sw;
|
||||
} mc_configuration;
|
||||
|
||||
// Applications to use
|
||||
typedef enum {
|
||||
APP_NONE = 0,
|
||||
APP_PPM,
|
||||
APP_ADC,
|
||||
APP_UART,
|
||||
APP_PPM_UART,
|
||||
APP_ADC_UART,
|
||||
APP_NUNCHUK,
|
||||
APP_NRF,
|
||||
APP_CUSTOM
|
||||
} app_use;
|
||||
|
||||
// Throttle curve mode
|
||||
typedef enum {
|
||||
THR_EXP_EXPO = 0,
|
||||
THR_EXP_NATURAL,
|
||||
THR_EXP_POLY
|
||||
} thr_exp_mode;
|
||||
|
||||
// PPM control types
|
||||
typedef enum {
|
||||
PPM_CTRL_TYPE_NONE = 0,
|
||||
PPM_CTRL_TYPE_CURRENT,
|
||||
PPM_CTRL_TYPE_CURRENT_NOREV,
|
||||
PPM_CTRL_TYPE_CURRENT_NOREV_BRAKE,
|
||||
PPM_CTRL_TYPE_DUTY,
|
||||
PPM_CTRL_TYPE_DUTY_NOREV,
|
||||
PPM_CTRL_TYPE_PID,
|
||||
PPM_CTRL_TYPE_PID_NOREV
|
||||
} ppm_control_type;
|
||||
|
||||
typedef struct {
|
||||
ppm_control_type ctrl_type;
|
||||
float pid_max_erpm;
|
||||
float hyst;
|
||||
float pulse_start;
|
||||
float pulse_end;
|
||||
float pulse_center;
|
||||
bool median_filter;
|
||||
bool safe_start;
|
||||
float throttle_exp;
|
||||
thr_exp_mode throttle_exp_mode;
|
||||
float ramp_time_pos;
|
||||
float ramp_time_neg;
|
||||
bool multi_esc;
|
||||
bool tc;
|
||||
float tc_max_diff;
|
||||
} ppm_config;
|
||||
|
||||
// ADC control types
|
||||
typedef enum {
|
||||
ADC_CTRL_TYPE_NONE = 0,
|
||||
ADC_CTRL_TYPE_CURRENT,
|
||||
ADC_CTRL_TYPE_CURRENT_REV_CENTER,
|
||||
ADC_CTRL_TYPE_CURRENT_REV_BUTTON,
|
||||
ADC_CTRL_TYPE_CURRENT_REV_BUTTON_BRAKE_ADC,
|
||||
ADC_CTRL_TYPE_CURRENT_NOREV_BRAKE_CENTER,
|
||||
ADC_CTRL_TYPE_CURRENT_NOREV_BRAKE_BUTTON,
|
||||
ADC_CTRL_TYPE_CURRENT_NOREV_BRAKE_ADC,
|
||||
ADC_CTRL_TYPE_DUTY,
|
||||
ADC_CTRL_TYPE_DUTY_REV_CENTER,
|
||||
ADC_CTRL_TYPE_DUTY_REV_BUTTON
|
||||
} adc_control_type;
|
||||
|
||||
typedef struct {
|
||||
adc_control_type ctrl_type;
|
||||
float hyst;
|
||||
float voltage_start;
|
||||
float voltage_end;
|
||||
float voltage_center;
|
||||
float voltage2_start;
|
||||
float voltage2_end;
|
||||
bool use_filter;
|
||||
bool safe_start;
|
||||
bool cc_button_inverted;
|
||||
bool rev_button_inverted;
|
||||
bool voltage_inverted;
|
||||
bool voltage2_inverted;
|
||||
float throttle_exp;
|
||||
thr_exp_mode throttle_exp_mode;
|
||||
float ramp_time_pos;
|
||||
float ramp_time_neg;
|
||||
bool multi_esc;
|
||||
bool tc;
|
||||
float tc_max_diff;
|
||||
uint32_t update_rate_hz;
|
||||
} adc_config;
|
||||
|
||||
// Nunchuk control types
|
||||
typedef enum {
|
||||
CHUK_CTRL_TYPE_NONE = 0,
|
||||
CHUK_CTRL_TYPE_CURRENT,
|
||||
CHUK_CTRL_TYPE_CURRENT_NOREV
|
||||
} chuk_control_type;
|
||||
|
||||
typedef struct {
|
||||
chuk_control_type ctrl_type;
|
||||
float hyst;
|
||||
float ramp_time_pos;
|
||||
float ramp_time_neg;
|
||||
float stick_erpm_per_s_in_cc;
|
||||
float throttle_exp;
|
||||
thr_exp_mode throttle_exp_mode;
|
||||
bool multi_esc;
|
||||
bool tc;
|
||||
float tc_max_diff;
|
||||
} chuk_config;
|
||||
|
||||
// NRF Datatypes
|
||||
typedef enum {
|
||||
NRF_SPEED_250K = 0,
|
||||
NRF_SPEED_1M,
|
||||
NRF_SPEED_2M
|
||||
} NRF_SPEED;
|
||||
|
||||
typedef enum {
|
||||
NRF_POWER_M18DBM = 0,
|
||||
NRF_POWER_M12DBM,
|
||||
NRF_POWER_M6DBM,
|
||||
NRF_POWER_0DBM
|
||||
} NRF_POWER;
|
||||
|
||||
typedef enum {
|
||||
NRF_AW_3 = 0,
|
||||
NRF_AW_4,
|
||||
NRF_AW_5
|
||||
} NRF_AW;
|
||||
|
||||
typedef enum {
|
||||
NRF_CRC_DISABLED = 0,
|
||||
NRF_CRC_1B,
|
||||
NRF_CRC_2B
|
||||
} NRF_CRC;
|
||||
|
||||
typedef enum {
|
||||
NRF_RETR_DELAY_250US = 0,
|
||||
NRF_RETR_DELAY_500US,
|
||||
NRF_RETR_DELAY_750US,
|
||||
NRF_RETR_DELAY_1000US,
|
||||
NRF_RETR_DELAY_1250US,
|
||||
NRF_RETR_DELAY_1500US,
|
||||
NRF_RETR_DELAY_1750US,
|
||||
NRF_RETR_DELAY_2000US,
|
||||
NRF_RETR_DELAY_2250US,
|
||||
NRF_RETR_DELAY_2500US,
|
||||
NRF_RETR_DELAY_2750US,
|
||||
NRF_RETR_DELAY_3000US,
|
||||
NRF_RETR_DELAY_3250US,
|
||||
NRF_RETR_DELAY_3500US,
|
||||
NRF_RETR_DELAY_3750US,
|
||||
NRF_RETR_DELAY_4000US
|
||||
} NRF_RETR_DELAY;
|
||||
|
||||
typedef struct {
|
||||
NRF_SPEED speed;
|
||||
NRF_POWER power;
|
||||
NRF_CRC crc_type;
|
||||
NRF_RETR_DELAY retry_delay;
|
||||
unsigned char retries;
|
||||
unsigned char channel;
|
||||
unsigned char address[3];
|
||||
bool send_crc_ack;
|
||||
} nrf_config;
|
||||
|
||||
typedef struct {
|
||||
// Settings
|
||||
uint8_t controller_id;
|
||||
uint32_t timeout_msec;
|
||||
float timeout_brake_current;
|
||||
bool send_can_status;
|
||||
uint32_t send_can_status_rate_hz;
|
||||
|
||||
// Application to use
|
||||
app_use app_to_use;
|
||||
|
||||
// PPM application settings
|
||||
ppm_config app_ppm_conf;
|
||||
|
||||
// ADC application settings
|
||||
adc_config app_adc_conf;
|
||||
|
||||
// UART application settings
|
||||
uint32_t app_uart_baudrate;
|
||||
|
||||
// Nunchuk application settings
|
||||
chuk_config app_chuk_conf;
|
||||
|
||||
// NRF application settings
|
||||
nrf_config app_nrf_conf;
|
||||
} app_configuration;
|
||||
|
||||
// Communication commands
|
||||
typedef enum {
|
||||
COMM_FW_VERSION = 0,
|
||||
COMM_JUMP_TO_BOOTLOADER,
|
||||
COMM_ERASE_NEW_APP,
|
||||
COMM_WRITE_NEW_APP_DATA,
|
||||
COMM_GET_VALUES,
|
||||
COMM_SET_DUTY,
|
||||
COMM_SET_CURRENT,
|
||||
COMM_SET_CURRENT_BRAKE,
|
||||
COMM_SET_RPM,
|
||||
COMM_SET_POS,
|
||||
COMM_SET_HANDBRAKE,
|
||||
COMM_SET_DETECT,
|
||||
COMM_SET_SERVO_POS,
|
||||
COMM_SET_MCCONF,
|
||||
COMM_GET_MCCONF,
|
||||
COMM_GET_MCCONF_DEFAULT,
|
||||
|
||||
|
||||
|
||||
COMM_SET_APPCONF,
|
||||
COMM_GET_APPCONF,
|
||||
COMM_GET_APPCONF_DEFAULT,
|
||||
COMM_SAMPLE_PRINT,
|
||||
COMM_TERMINAL_CMD,
|
||||
COMM_PRINT,
|
||||
COMM_ROTOR_POSITION,
|
||||
COMM_EXPERIMENT_SAMPLE,
|
||||
COMM_DETECT_MOTOR_PARAM,
|
||||
COMM_DETECT_MOTOR_R_L,
|
||||
COMM_DETECT_MOTOR_FLUX_LINKAGE,
|
||||
COMM_DETECT_ENCODER,
|
||||
COMM_DETECT_HALL_FOC,
|
||||
COMM_REBOOT,
|
||||
COMM_ALIVE,
|
||||
COMM_GET_DECODED_PPM,
|
||||
COMM_GET_DECODED_ADC,
|
||||
COMM_GET_DECODED_CHUK,
|
||||
COMM_FORWARD_CAN,
|
||||
COMM_SET_CHUCK_DATA,
|
||||
COMM_CUSTOM_APP_DATA,
|
||||
COMM_NRF_START_PAIRING,
|
||||
COMM_GPD_SET_FSW,
|
||||
COMM_GPD_BUFFER_NOTIFY,
|
||||
COMM_GPD_BUFFER_SIZE_LEFT,
|
||||
COMM_GPD_FILL_BUFFER,
|
||||
COMM_GPD_OUTPUT_SAMPLE,
|
||||
COMM_GPD_SET_MODE,
|
||||
COMM_GPD_FILL_BUFFER_INT8,
|
||||
COMM_GPD_FILL_BUFFER_INT16,
|
||||
COMM_GPD_SET_BUFFER_INT_SCALE,
|
||||
COMM_GET_VALUES_SETUP,
|
||||
COMM_SET_MCCONF_TEMP,
|
||||
COMM_SET_MCCONF_TEMP_SETUP,
|
||||
COMM_GET_VALUES_SELECTIVE,
|
||||
COMM_GET_VALUES_SETUP_SELECTIVE,
|
||||
COMM_EXT_NRF_PRESENT,
|
||||
COMM_EXT_NRF_ESB_SET_CH_ADDR,
|
||||
COMM_EXT_NRF_ESB_SEND_DATA,
|
||||
COMM_EXT_NRF_ESB_RX_DATA,
|
||||
COMM_EXT_NRF_SET_ENABLED,
|
||||
COMM_DETECT_MOTOR_FLUX_LINKAGE_OPENLOOP,
|
||||
COMM_DETECT_APPLY_ALL_FOC,
|
||||
COMM_JUMP_TO_BOOTLOADER_ALL_CAN,
|
||||
COMM_ERASE_NEW_APP_ALL_CAN,
|
||||
COMM_WRITE_NEW_APP_DATA_ALL_CAN,
|
||||
COMM_PING_CAN,
|
||||
COMM_APP_DISABLE_OUTPUT,
|
||||
COMM_TERMINAL_CMD_SYNC,
|
||||
COMM_GET_IMU_DATA,
|
||||
COMM_BM_CONNECT,
|
||||
COMM_BM_ERASE_FLASH_ALL,
|
||||
COMM_BM_WRITE_FLASH,
|
||||
COMM_BM_REBOOT,
|
||||
COMM_BM_DISCONNECT,
|
||||
COMM_BM_MAP_PINS_DEFAULT,
|
||||
COMM_BM_MAP_PINS_NRF5X,
|
||||
COMM_ERASE_BOOTLOADER,
|
||||
COMM_ERASE_BOOTLOADER_ALL_CAN,
|
||||
COMM_PLOT_INIT,
|
||||
COMM_PLOT_DATA,
|
||||
COMM_PLOT_ADD_GRAPH,
|
||||
COMM_PLOT_SET_GRAPH,
|
||||
COMM_GET_DECODED_BALANCE,
|
||||
COMM_BM_MEM_READ,
|
||||
COMM_WRITE_NEW_APP_DATA_LZO,
|
||||
COMM_WRITE_NEW_APP_DATA_ALL_CAN_LZO,
|
||||
COMM_BM_WRITE_FLASH_LZO,
|
||||
COMM_SET_CURRENT_REL,
|
||||
COMM_CAN_FWD_FRAME,
|
||||
COMM_SET_BATTERY_CUT,
|
||||
COMM_SET_BLE_NAME,
|
||||
COMM_SET_BLE_PIN,
|
||||
COMM_SET_CAN_MODE,
|
||||
COMM_GET_IMU_CALIBRATION,
|
||||
COMM_GET_MCCONF_TEMP,
|
||||
|
||||
// Custom configuration for hardware
|
||||
COMM_GET_CUSTOM_CONFIG_XML,
|
||||
COMM_GET_CUSTOM_CONFIG,
|
||||
COMM_GET_CUSTOM_CONFIG_DEFAULT,
|
||||
COMM_SET_CUSTOM_CONFIG,
|
||||
|
||||
// BMS commands
|
||||
COMM_BMS_GET_VALUES,
|
||||
COMM_BMS_SET_CHARGE_ALLOWED,
|
||||
COMM_BMS_SET_BALANCE_OVERRIDE,
|
||||
COMM_BMS_RESET_COUNTERS,
|
||||
COMM_BMS_FORCE_BALANCE,
|
||||
COMM_BMS_ZERO_CURRENT_OFFSET,
|
||||
|
||||
// FW updates commands for different HW types
|
||||
COMM_JUMP_TO_BOOTLOADER_HW,
|
||||
COMM_ERASE_NEW_APP_HW,
|
||||
COMM_WRITE_NEW_APP_DATA_HW,
|
||||
COMM_ERASE_BOOTLOADER_HW,
|
||||
COMM_JUMP_TO_BOOTLOADER_ALL_CAN_HW,
|
||||
COMM_ERASE_NEW_APP_ALL_CAN_HW,
|
||||
COMM_WRITE_NEW_APP_DATA_ALL_CAN_HW,
|
||||
COMM_ERASE_BOOTLOADER_ALL_CAN_HW,
|
||||
|
||||
COMM_SET_ODOMETER,
|
||||
|
||||
// ENNOID-BMS specific
|
||||
COMM_STORE_BMS_CONF = 150,
|
||||
COMM_GET_BMS_CELLS,
|
||||
COMM_GET_BMS_AUX,
|
||||
COMM_GET_BMS_EXP_TEMP,
|
||||
COMM_GET_GSM_DATA,
|
||||
COMM_GET_GSM_DEFAULT_DATA,
|
||||
COMM_SET_GSM_DATA,
|
||||
} COMM_PACKET_ID;
|
||||
|
||||
typedef enum {
|
||||
CANIDStyleVESC = 0,
|
||||
CANIDStyleFoiler
|
||||
} CAN_ID_STYLE;
|
||||
|
||||
typedef enum {
|
||||
OP_STATE_INIT = 0, // 0
|
||||
OP_STATE_CHARGING, // 1
|
||||
OP_STATE_PRE_CHARGE, // 2
|
||||
OP_STATE_LOAD_ENABLED, // 3
|
||||
OP_STATE_BATTERY_DEAD, // 4
|
||||
OP_STATE_POWER_DOWN, // 5
|
||||
OP_STATE_EXTERNAL, // 6
|
||||
OP_STATE_ERROR, // 7
|
||||
OP_STATE_ERROR_PRECHARGE, // 8
|
||||
OP_STATE_BALANCING, // 9
|
||||
OP_STATE_CHARGED, // 10
|
||||
OP_STATE_FORCEON, // 11
|
||||
} OperationalStateTypedef;
|
||||
|
||||
typedef enum {
|
||||
opInit = 0,
|
||||
opChargerReset,
|
||||
opChargerSet,
|
||||
opCharging
|
||||
} ChargerStateTypedef;
|
||||
|
||||
// CAN commands
|
||||
typedef enum {
|
||||
CAN_PACKET_ESC_SET_DUTY = 0,
|
||||
CAN_PACKET_ESC_SET_CURRENT,
|
||||
CAN_PACKET_ESC_SET_CURRENT_BRAKE,
|
||||
CAN_PACKET_ESC_SET_RPM,
|
||||
CAN_PACKET_ESC_SET_POS,
|
||||
CAN_PACKET_FILL_RX_BUFFER,
|
||||
CAN_PACKET_FILL_RX_BUFFER_LONG,
|
||||
CAN_PACKET_PROCESS_RX_BUFFER,
|
||||
CAN_PACKET_PROCESS_SHORT_BUFFER,
|
||||
CAN_PACKET_ESC_STATUS,
|
||||
CAN_PACKET_ESC_SET_CURRENT_REL,
|
||||
CAN_PACKET_ESC_SET_CURRENT_BRAKE_REL,
|
||||
CAN_PACKET_BMS_STATUS_MAIN_IV = 30,
|
||||
CAN_PACKET_BMS_STATUS_CELLVOLTAGE,
|
||||
CAN_PACKET_BMS_STATUS_THROTTLE_CH_DISCH_BOOL,
|
||||
CAN_PACKET_BMS_STATUS_TEMPERATURES,
|
||||
CAN_PACKET_BMS_STATUS_AUX_IV_SAFETY_WATCHDOG,
|
||||
CAN_PACKET_BMS_KEEP_ALIVE_SAFETY,
|
||||
CAN_PACKET_BMS_STATUS_TEMP_INDIVIDUAL,
|
||||
CAN_PACKET_SLS_STATUS_CURRENT_RPM = 40,
|
||||
CAN_PACKET_SLS_STATUS_TEMPERATURE,
|
||||
CAN_PACKET_SSR_STATUS_MAIN_V_TEMP = 60,
|
||||
CAN_PACKET_SSR_STATUS_MAIN_LOAD0,
|
||||
CAN_PACKET_SSR_STATUS_MAIN_LOAD1
|
||||
} CAN_PACKET_ID;
|
||||
|
||||
typedef struct {
|
||||
int id;
|
||||
systime_t rx_time;
|
||||
float rpm;
|
||||
float current;
|
||||
float duty;
|
||||
} can_status_msg;
|
||||
|
||||
typedef enum {
|
||||
MOTE_PACKET_BATT_LEVEL = 0,
|
||||
MOTE_PACKET_BUTTONS,
|
||||
MOTE_PACKET_ALIVE,
|
||||
MOTE_PACKET_FILL_RX_BUFFER,
|
||||
MOTE_PACKET_FILL_RX_BUFFER_LONG,
|
||||
MOTE_PACKET_PROCESS_RX_BUFFER,
|
||||
MOTE_PACKET_PROCESS_SHORT_BUFFER,
|
||||
MOTE_PACKET_PAIRING_INFO
|
||||
} MOTE_PACKET;
|
||||
|
||||
typedef enum {
|
||||
NRF_PAIR_STARTED = 0,
|
||||
NRF_PAIR_OK,
|
||||
NRF_PAIR_FAIL
|
||||
} NRF_PAIR_RES;
|
||||
|
||||
typedef enum {
|
||||
CELL_MON_NONE = 0,
|
||||
CELL_MON_LTC6811_1,
|
||||
CELL_MON_LTC6812_1,
|
||||
CELL_MON_LTC6813_1
|
||||
} configCellMonitorICTypeEnum;
|
||||
|
||||
typedef enum {
|
||||
opStateExternal = 0,
|
||||
opStateExtNormal
|
||||
} configExtEnableStateTypeEnum;
|
||||
|
||||
typedef enum {
|
||||
opStateChargingModeCharging = 0,
|
||||
opStateChargingModeNormal
|
||||
} configChargerEnableStateTypeEnum;
|
||||
|
||||
typedef enum {
|
||||
canSpeedBaud125k = 0,
|
||||
canSpeedBaud250k,
|
||||
canSpeedBaud500k
|
||||
} configCANSpeedTypeEnum;
|
||||
|
||||
typedef enum {
|
||||
sourcePackVoltageNone = 0,
|
||||
sourcePackVoltageISL28022_2_BatteryIn,
|
||||
sourcePackVoltageSumOfIndividualCellVoltages,
|
||||
sourcePackVoltageCANDieBieShunt,
|
||||
sourcePackVoltageCANIsabellenhutte
|
||||
} configPackVoltageDataSourceEnum;
|
||||
|
||||
typedef enum {
|
||||
sourcePackCurrentNone = 0,
|
||||
sourcePackCurrentLowCurrentShunt,
|
||||
sourcePackCurrentCANDieBieShunt,
|
||||
sourcePackCurrentCANIsaBellenHuette
|
||||
} configPackCurrentDataSourceEnum;
|
||||
|
||||
typedef enum {
|
||||
socNone = 0,
|
||||
socCoulomb,
|
||||
socCoulombAndCellVoltage
|
||||
} configStateOfChargeMethodEnum;
|
||||
|
||||
typedef enum {
|
||||
basic = 0,
|
||||
advanced
|
||||
} displayStyle;
|
||||
|
||||
typedef enum {
|
||||
buzzerSourceOff = 0,
|
||||
buzzerSourceOn,
|
||||
buzzerSourceAll,
|
||||
buzzerSourceLC,
|
||||
buzzerSourceSOA
|
||||
} buzzerSignalSourceEnum;
|
||||
|
||||
typedef enum {
|
||||
canEmitProtocolNone = 0,
|
||||
canEmitProtocolDieBieEngineering,
|
||||
canEmitProtocolMGElectronics
|
||||
} canEmitProtocol;
|
||||
|
||||
typedef struct {
|
||||
float cellVoltage;
|
||||
uint8_t cellNumber;
|
||||
bool cellBleedActive;
|
||||
} cellMonitorCellsTypeDef;
|
||||
|
||||
typedef struct {
|
||||
float auxVoltage;
|
||||
uint8_t auxNumber;
|
||||
} auxMonitorTypeDef;
|
||||
|
||||
typedef struct {
|
||||
float expVoltage;
|
||||
uint8_t expNumber;
|
||||
} expMonitorTypeDef;
|
||||
|
||||
typedef struct {
|
||||
float voltages[12];
|
||||
uint16_t balanceMask;
|
||||
float temperatures[8];
|
||||
float humidity;
|
||||
} cellMonitorModuleTypeDef;
|
||||
|
||||
typedef enum {
|
||||
disabled = 0,
|
||||
enabled,
|
||||
forced // For specific hardware with negative main contactor as precharge circuit
|
||||
} switchState;
|
||||
|
||||
typedef enum {
|
||||
none = 0,
|
||||
si7020,
|
||||
htc1080
|
||||
} humidityICTypeEnum;
|
||||
|
||||
#endif /* DATATYPES_H_ */
|
||||
45
Core/Inc/modCommands.h
Normal file
45
Core/Inc/modCommands.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
Copyright 2016 Benjamin Vedder benjamin@vedder.se
|
||||
|
||||
This file is part of the VESC firmware.
|
||||
|
||||
The VESC firmware is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The VESC firmware is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef COMMANDS_H_
|
||||
#define COMMANDS_H_
|
||||
|
||||
#include "mainDataTypes.h"
|
||||
#include "libPacket.h"
|
||||
#include "generalDefines.h"
|
||||
#include "libBuffer.h"
|
||||
#include "modTerminal.h"
|
||||
//#include "modCAN.h"
|
||||
#include "modFlash.h"
|
||||
#include "modConfig.h"
|
||||
#include "modPowerElectronics.h"
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
// Functions
|
||||
void modCommandsInit(modPowerElectronicsPackStateTypedef *generalState,modConfigGeneralConfigStructTypedef *configPointer);
|
||||
void modCommandsSetSendFunction(void(*func)(unsigned char *data, unsigned int len));
|
||||
void modCommandsSendPacket(unsigned char *data, unsigned int len);
|
||||
void modCommandsProcessPacket(unsigned char *data, unsigned int len);
|
||||
void modCommandsPrintf(const char* format, ...);
|
||||
void modCommandsJumpToMainApplication(void);
|
||||
|
||||
#endif /* COMMANDS_H_ */
|
||||
156
Core/Inc/modConfig.h
Normal file
156
Core/Inc/modConfig.h
Normal file
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
Copyright 2017 - 2018 Danny Bokma danny@diebie.nl
|
||||
Copyright 2019 - 2020 Kevin Dionne kevin.dionne@ennoid.me
|
||||
|
||||
This file is part of the DieBieMS/ENNOID-BMS firmware.
|
||||
|
||||
The DieBieMS/ENNOID-BMS firmware is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The DieBieMS/ENNOID-BMS firmware is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __MODCONFIG_H
|
||||
#define __MODCONFIG_H
|
||||
|
||||
#include "stdint.h"
|
||||
#include "string.h"
|
||||
#include "stdbool.h"
|
||||
#include "mainDataTypes.h"
|
||||
#include "driverSWStorageManager.h"
|
||||
#include "generalDefines.h"
|
||||
|
||||
#define modConfigNoOfNTCTypes 5
|
||||
#define modConfigNTCGroupLTCExt 2
|
||||
#define modConfigNTCGroupMasterPCB 3
|
||||
#define modConfigNTCGroupExp 4
|
||||
|
||||
#define __DEFAULT_BATTERY_SERIAL 20000007
|
||||
|
||||
|
||||
typedef struct {
|
||||
// Master BMS
|
||||
//uint32_t serialNumber;
|
||||
uint8_t noOfCellsSeries; // Total number of cells in series in the battery pack
|
||||
uint8_t noOfCellsParallel; // Number of cells in parallel group
|
||||
uint8_t noOfCellsPerModule; // Number of cell levels monitored per LTC68XX
|
||||
uint8_t noOfParallelModules; // Number of parallel modules
|
||||
float batteryCapacity; // Battery capacity in Ah
|
||||
float cellHardUnderVoltage; // If the lowest cell is under this voltage -> Error situation, turn all off and power down
|
||||
float cellHardOverVoltage; // If the upper cell is above this voltage -> Error situation, turn all off and power down
|
||||
float cellLCSoftUnderVoltage; // If the lowest cell is under this voltage -> disable low current load
|
||||
float cellSoftOverVoltage; // If the upper cell is above this voltage -> disable charging, but keep bms enabled
|
||||
float cellBalanceDifferenceThreshold; // If the upper cell is more than this voltage away from the average -> start discharging this cell
|
||||
float cellBalanceStart; // If an upper cell is above this voltage and higher than the cellBalanceDifferenceThreshold voltage then average, start discharging
|
||||
bool cellBalanceAllTime; // Enable balancing under all opstate
|
||||
float cellThrottleUpperStart; // Charge throttle range
|
||||
float cellThrottleLowerStart; // Discharge throttle rande
|
||||
float cellThrottleUpperMargin; // Margin from the upper cell voltage extremes
|
||||
float cellThrottleLowerMargin; // Margin from the lower cell voltage extremes
|
||||
uint8_t packVoltageDataSource; // Enum value of pack voltage data source (what source to derive the voltage information from different ADC options)
|
||||
uint8_t packCurrentDataSource; // Enum value of pack current data source (what source to derive the current information from LC/HC/LC+HC/CAN)
|
||||
uint8_t buzzerSignalSource; // - Stores what source shoud be taken to trigger
|
||||
uint8_t buzzerSignalPersistant; // - Stores whether the buzzer should stay on after triggering
|
||||
float shuntLCFactor; // Shunt multiplication factor Low current
|
||||
float voltageLCFactor; // Battery Voltage multiplication factor Low current
|
||||
int16_t voltageLCOffset; // Battery Voltage low current offset
|
||||
float loadVoltageFactor; // Load Voltage multiplication factor
|
||||
float loadVoltageOffset; // Load Voltage offset
|
||||
float chargerVoltageFactor; // Charger Voltage multiplication factor
|
||||
float chargerVoltageOffset; // Charger Voltage offset
|
||||
uint8_t throttleChargeIncreaseRate; // The rate of charge throttle percentage increase per 100ms
|
||||
uint8_t throttleDisChargeIncreaseRate; // The rate of discharge throttle percentage instrease per 100ms
|
||||
uint32_t cellBalanceUpdateInterval; // Amount of time that the balance resistor enable mask is kept
|
||||
uint8_t maxSimultaneousDischargingCells; // Set the maximum amount of discharging cells. This is to limit dissepated power (and thus board temperature)
|
||||
uint32_t timeoutDischargeRetry; // If soft lower threshold limit was tripped wait this amount of time to re-enable load if cell is within threshold
|
||||
float hysteresisDischarge; // If the lowest cell voltage rises this amount of mV re enable output
|
||||
uint32_t timeoutChargeRetry; // If soft higher threshold limit was tripped and cell is within acceptable limits wait this amount of time before re-enabling charge input
|
||||
float hysteresisCharge; // If the highest cell voltage loweres this amount of mW re enable charge input
|
||||
uint32_t timeoutChargeCompleted; // If tricklecharging > this threshold timer declare the pack charged but keep balancing if nessesary
|
||||
uint32_t timeoutChargingCompletedMinimalMismatch; // If charger is disabled and cellvoltagemismatch is under threshold determin charged after this timeout time
|
||||
float maxMismatchThreshold; // If the mismatch is below this threshold the battery SoC is set to 100%
|
||||
float chargerEnabledThreshold; // Minimal current to stay in charge mode
|
||||
uint32_t timeoutChargerDisconnected; // Timeout for charger disconnect detection
|
||||
float minimalPrechargePercentage; // Output voltage threshold for precharging
|
||||
uint32_t timeoutLCPreCharge; // If threshold is not reached within this time in ms goto error state
|
||||
float maxAllowedCurrent; // Max allowed current passing trough BMS, if limit is exceded disable output
|
||||
float allowedTempBattDischargingMax; // Max battery temperature where discharging is still allowed
|
||||
float allowedTempBattDischargingMin; // Min battery temperature where discharging is still allowed
|
||||
float allowedTempBattChargingMax; // Max battery temperature where charging is still allowed
|
||||
float allowedTempBattChargingMin; // Min battery temperature where heating is activated
|
||||
float allowedTempBattCoolingMax; // Max battery temperature where cooling is activated
|
||||
float allowedTempBattCoolingMin; // Min battery temperature where charging is still allowed
|
||||
float allowedTempBMSMax; // Max BMS operational temperature
|
||||
float allowedTempBMSMin; // Min BMS operational temperature
|
||||
uint32_t displayTimeoutBatteryDead; // Duration of displaying battery dead symbol
|
||||
uint32_t displayTimeoutBatteryError; // Duration of displaying error symbol
|
||||
uint32_t displayTimeoutBatteryErrorPreCharge; // Duration of displaying error symbol
|
||||
uint32_t displayTimeoutSplashScreen; // Duration of displaying splash screen + First few samples of ADC's
|
||||
uint8_t displayStyle; // Enum value for the SSD1306 display style option used
|
||||
uint8_t maxUnderAndOverVoltageErrorCount; // Threshold that defines max amount of hard over / under voltage errors
|
||||
uint8_t maxUnderAndOverTemperatureErrorCount; // Threshold that defines max amount of hard over / under temperature errors
|
||||
float notUsedCurrentThreshold; // Threshold that defines whether or not pack is in use.
|
||||
uint32_t notUsedTimeout; // Delay time that defines max amount of no operation on-time. When absolute battery curren < notUsedCurrentThreshold for longer than this amount of time -> the system is disabled
|
||||
uint32_t stateOfChargeStoreInterval; // Interval to store state of charge information.
|
||||
uint8_t stateOfChargeMethod; // Stores the desired type of state of charge algorithm
|
||||
uint8_t CANID; // Stores the CAN ID of the device.
|
||||
uint8_t CANIDStyle; // Store the ID style used to communicate over CAN
|
||||
uint8_t emitStatusOverCAN; // Enable or disable sending of status over CAN
|
||||
uint8_t emitStatusProtocol; // The protocol type / format to send the status data
|
||||
uint32_t tempEnableMaskBMS; // Stores the mask to select what temperature sensor is enabled for the BMS.
|
||||
uint32_t tempEnableMaskBattery; // Stores the mask to select what temperature sensor is enabled for the battery.
|
||||
uint32_t tempEnableMaskExpansion; // Stores the mask to select what temperature sensor is enabled for the battery.
|
||||
uint8_t noOfTempSensorPerModule; // Number of temperature sensor monitored per LTC68XX
|
||||
uint8_t noOfExpansionBoard; // Number of expansion board
|
||||
uint8_t noOfTempSensorPerExpansionBoard; // Number of temperature sensor monitored per expansion board
|
||||
uint8_t LCUseDischarge; // Enable or disable switch output.
|
||||
uint8_t LCUsePrecharge; // choice whether to precharge or not.
|
||||
uint8_t allowChargingDuringDischarge; // Allow charging during discharge.
|
||||
uint8_t allowForceOn; // Enable or disable the option to be forced on.
|
||||
uint8_t pulseToggleButton; // Pulse or Toggle power button.
|
||||
uint8_t togglePowerModeDirectHCDelay; // Toggle switch controls onstate directly or controls HC output with delayed turn off.
|
||||
uint8_t useCANSafetyInput; // Use the safe input state received from the CAN bus.
|
||||
uint8_t useCANDelayedPowerDown; // Config that holds the preference whethet to used delayes power down
|
||||
uint8_t cellMonitorType; // The cell monitor IC type
|
||||
uint8_t cellMonitorICCount; // The amount of cell monitor IC's connected
|
||||
uint8_t lastICNoOfCells; // Store number of cells in the last module (Used for odd number of cells in series only)
|
||||
uint32_t lastICMask; // Stores the mask to select what cell should be monitored when last IC is not equal to other ones (Used for odd number of cells in series only)
|
||||
uint8_t externalEnableOperationalState; // The state to enter when externally enabled
|
||||
uint32_t powerDownDelay; // The delay time between going to power down and turning off
|
||||
uint8_t canBusSpeed; // CAN bus baudrate
|
||||
uint8_t chargeEnableOperationalState; // State to enter when BMS is turned on due to charger
|
||||
uint32_t NTCTopResistor[modConfigNoOfNTCTypes]; // NTC Pullup resistor value
|
||||
uint32_t NTC25DegResistance[modConfigNoOfNTCTypes]; // NTC resistance at 25 degree
|
||||
uint16_t NTCBetaFactor[modConfigNoOfNTCTypes]; // NTC Beta factor
|
||||
uint8_t humidityICType; // Humidity sensor IC type
|
||||
|
||||
char Domain_URL[250];
|
||||
char Domain_URL_Event[250];
|
||||
char GSM_APN[50];
|
||||
char GSM_USER[50];
|
||||
char GSM_PWD[50];
|
||||
|
||||
uint64_t serialNumber;
|
||||
|
||||
uint64_t PC_Time;
|
||||
|
||||
|
||||
} modConfigGeneralConfigStructTypedef;
|
||||
|
||||
modConfigGeneralConfigStructTypedef* modConfigInit(void);
|
||||
bool modConfigStoreAndLoadDefaultConfig(void);
|
||||
bool modConfigStoreConfig(void);
|
||||
bool modConfigLoadConfig(void);
|
||||
bool modConfigStoreDefaultConfig(void);
|
||||
void modConfigLoadDefaultConfig(modConfigGeneralConfigStructTypedef *configLocation);
|
||||
void modconfigHardwareLimitsApply(modConfigGeneralConfigStructTypedef *configLocation);
|
||||
|
||||
#endif
|
||||
28
Core/Inc/modDelay.h
Normal file
28
Core/Inc/modDelay.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
Copyright 2017 - 2018 Danny Bokma danny@diebie.nl
|
||||
Copyright 2019 - 2020 Kevin Dionne kevin.dionne@ennoid.me
|
||||
|
||||
This file is part of the DieBieMS/ENNOID-BMS firmware.
|
||||
|
||||
The DieBieMS/ENNOID-BMS firmware is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The DieBieMS/ENNOID-BMS firmware is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "stm32f1xx_hal.h"
|
||||
#include "stdbool.h"
|
||||
|
||||
void modDelayInit(void);
|
||||
uint8_t modDelayTick1ms(uint32_t *last, uint32_t ticks);
|
||||
uint8_t modDelayTick100ms(uint32_t *last, uint32_t ticks);
|
||||
uint8_t modDelayTick1msNoRST(uint32_t *last, uint32_t ticks);
|
||||
uint8_t modDelayTick100msNoRST(uint32_t *last, uint32_t ticks);
|
||||
161
Core/Inc/modFlash.h
Normal file
161
Core/Inc/modFlash.h
Normal file
@@ -0,0 +1,161 @@
|
||||
#include "stm32f1xx_hal.h"
|
||||
#include "stdbool.h"
|
||||
|
||||
#ifndef MODFLASH_H__
|
||||
#define MODFLASH_H__
|
||||
|
||||
#define FLASH_PAGES 128
|
||||
#define BOOTLOADER_BASE 104
|
||||
#define MAIN_APP_BASE 0
|
||||
#define NEW_APP_BASE 52
|
||||
#define NEW_APP_SECTORS 52
|
||||
#define NEW_APP_MAX_SIZE (NEW_APP_SECTORS * (1 << 11))
|
||||
|
||||
/* Base address of the Flash sectors */
|
||||
#define ADDR_FLASH_PAGE_0 ((uint32_t)0x08000000) /* Base @ of Page 0, 2 Kbytes */ // Startup Code - Main application
|
||||
#define ADDR_FLASH_PAGE_1 ((uint32_t)0x08000800) /* Base @ of Page 1, 2 Kbytes */ //
|
||||
#define ADDR_FLASH_PAGE_2 ((uint32_t)0x08001000) /* Base @ of Page 2, 2 Kbytes */ //
|
||||
#define ADDR_FLASH_PAGE_3 ((uint32_t)0x08001800) /* Base @ of Page 3, 2 Kbytes */ //
|
||||
#define ADDR_FLASH_PAGE_4 ((uint32_t)0x08002000) /* Base @ of Page 4, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_5 ((uint32_t)0x08002800) /* Base @ of Page 5, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_6 ((uint32_t)0x08003000) /* Base @ of Page 6, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_7 ((uint32_t)0x08003800) /* Base @ of Page 7, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_8 ((uint32_t)0x08004000) /* Base @ of Page 8, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_9 ((uint32_t)0x08004800) /* Base @ of Page 9, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_10 ((uint32_t)0x08005000) /* Base @ of Page 10, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_11 ((uint32_t)0x08005800) /* Base @ of Page 11, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_12 ((uint32_t)0x08006000) /* Base @ of Page 12, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_13 ((uint32_t)0x08006800) /* Base @ of Page 13, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_14 ((uint32_t)0x08007000) /* Base @ of Page 14, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_15 ((uint32_t)0x08007800) /* Base @ of Page 15, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_16 ((uint32_t)0x08008000) /* Base @ of Page 16, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_17 ((uint32_t)0x08008800) /* Base @ of Page 17, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_18 ((uint32_t)0x08009000) /* Base @ of Page 18, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_19 ((uint32_t)0x08009800) /* Base @ of Page 19, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_20 ((uint32_t)0x0800A000) /* Base @ of Page 20, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_21 ((uint32_t)0x0800A800) /* Base @ of Page 21, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_22 ((uint32_t)0x0800B000) /* Base @ of Page 22, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_23 ((uint32_t)0x0800B800) /* Base @ of Page 23, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_24 ((uint32_t)0x0800C000) /* Base @ of Page 24, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_25 ((uint32_t)0x0800C800) /* Base @ of Page 25, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_26 ((uint32_t)0x0800D000) /* Base @ of Page 26, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_27 ((uint32_t)0x0800D800) /* Base @ of Page 27, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_28 ((uint32_t)0x0800E000) /* Base @ of Page 28, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_29 ((uint32_t)0x0800E800) /* Base @ of Page 29, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_30 ((uint32_t)0x0800F000) /* Base @ of Page 30, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_31 ((uint32_t)0x0800F800) /* Base @ of Page 31, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_32 ((uint32_t)0x08010000) /* Base @ of Page 32, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_33 ((uint32_t)0x08010800) /* Base @ of Page 33, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_34 ((uint32_t)0x08011000) /* Base @ of Page 34, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_35 ((uint32_t)0x08011800) /* Base @ of Page 35, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_36 ((uint32_t)0x08012000) /* Base @ of Page 36, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_37 ((uint32_t)0x08012800) /* Base @ of Page 37, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_38 ((uint32_t)0x08013000) /* Base @ of Page 38, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_39 ((uint32_t)0x08013800) /* Base @ of Page 39, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_40 ((uint32_t)0x08014000) /* Base @ of Page 40, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_41 ((uint32_t)0x08014800) /* Base @ of Page 41, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_42 ((uint32_t)0x08015000) /* Base @ of Page 42, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_43 ((uint32_t)0x08015800) /* Base @ of Page 43, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_44 ((uint32_t)0x08016000) /* Base @ of Page 44, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_45 ((uint32_t)0x08016800) /* Base @ of Page 45, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_46 ((uint32_t)0x08017000) /* Base @ of Page 46, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_47 ((uint32_t)0x08017800) /* Base @ of Page 47, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_48 ((uint32_t)0x08018000) /* Base @ of Page 48, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_49 ((uint32_t)0x08018800) /* Base @ of Page 49, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_50 ((uint32_t)0x08019000) /* Base @ of Page 50, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_51 ((uint32_t)0x08019800) /* Base @ of Page 51, 2 Kbytes *///Main ends here
|
||||
#define ADDR_FLASH_PAGE_52 ((uint32_t)0x0801A000) /* Base @ of Page 52, 2 Kbytes *///NEW app start
|
||||
#define ADDR_FLASH_PAGE_53 ((uint32_t)0x0801A800) /* Base @ of Page 53, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_54 ((uint32_t)0x0801B000) /* Base @ of Page 54, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_55 ((uint32_t)0x0801B800) /* Base @ of Page 55, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_56 ((uint32_t)0x0801C000) /* Base @ of Page 56, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_57 ((uint32_t)0x0801C800) /* Base @ of Page 57, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_58 ((uint32_t)0x0801D000) /* Base @ of Page 58, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_59 ((uint32_t)0x0801D800) /* Base @ of Page 59, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_60 ((uint32_t)0x0801E000) /* Base @ of Page 60, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_61 ((uint32_t)0x0801E800) /* Base @ of Page 61, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_62 ((uint32_t)0x0801F000) /* Base @ of Page 62, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_63 ((uint32_t)0x0801F800) /* Base @ of Page 63, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_64 ((uint32_t)0x08020000) /* Base @ of Page 64, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_65 ((uint32_t)0x08020800) /* Base @ of Page 65, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_66 ((uint32_t)0x08021000) /* Base @ of Page 66, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_67 ((uint32_t)0x08021800) /* Base @ of Page 67, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_68 ((uint32_t)0x08022000) /* Base @ of Page 68, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_69 ((uint32_t)0x08022800) /* Base @ of Page 69, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_70 ((uint32_t)0x08023000) /* Base @ of Page 70, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_71 ((uint32_t)0x08023800) /* Base @ of Page 71, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_72 ((uint32_t)0x08024000) /* Base @ of Page 72, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_73 ((uint32_t)0x08024800) /* Base @ of Page 73, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_74 ((uint32_t)0x08025000) /* Base @ of Page 74, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_75 ((uint32_t)0x08025800) /* Base @ of Page 75, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_76 ((uint32_t)0x08026000) /* Base @ of Page 76, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_77 ((uint32_t)0x08026800) /* Base @ of Page 77, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_78 ((uint32_t)0x08027000) /* Base @ of Page 78, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_79 ((uint32_t)0x08027800) /* Base @ of Page 79, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_80 ((uint32_t)0x08028000) /* Base @ of Page 80, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_81 ((uint32_t)0x08028800) /* Base @ of Page 81, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_82 ((uint32_t)0x08029000) /* Base @ of Page 82, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_83 ((uint32_t)0x08029800) /* Base @ of Page 83, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_84 ((uint32_t)0x0802A000) /* Base @ of Page 84, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_85 ((uint32_t)0x0802A800) /* Base @ of Page 85, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_86 ((uint32_t)0x0802B000) /* Base @ of Page 86, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_87 ((uint32_t)0x0802B800) /* Base @ of Page 87, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_88 ((uint32_t)0x0802C000) /* Base @ of Page 88, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_89 ((uint32_t)0x0802C800) /* Base @ of Page 89, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_90 ((uint32_t)0x0802D000) /* Base @ of Page 90, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_91 ((uint32_t)0x0802D800) /* Base @ of Page 91, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_92 ((uint32_t)0x0802E000) /* Base @ of Page 92, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_93 ((uint32_t)0x0802E800) /* Base @ of Page 93, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_94 ((uint32_t)0x0802F000) /* Base @ of Page 94, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_95 ((uint32_t)0x0802F800) /* Base @ of Page 95, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_96 ((uint32_t)0x08030000) /* Base @ of Page 96, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_97 ((uint32_t)0x08030800) /* Base @ of Page 97, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_98 ((uint32_t)0x08031000) /* Base @ of Page 98, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_99 ((uint32_t)0x08031800) /* Base @ of Page 99, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_100 ((uint32_t)0x08032000) /* Base @ of Page 100, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_101 ((uint32_t)0x08032800) /* Base @ of Page 101, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_102 ((uint32_t)0x08033000) /* Base @ of Page 102, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_103 ((uint32_t)0x08033800) /* Base @ of Page 103, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_104 ((uint32_t)0x08034000) /* Base @ of Page 104, 2 Kbytes *///bootloader
|
||||
#define ADDR_FLASH_PAGE_105 ((uint32_t)0x08034800) /* Base @ of Page 105, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_106 ((uint32_t)0x08035000) /* Base @ of Page 106, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_107 ((uint32_t)0x08035800) /* Base @ of Page 107, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_108 ((uint32_t)0x08036000) /* Base @ of Page 108, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_109 ((uint32_t)0x08036800) /* Base @ of Page 109, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_110 ((uint32_t)0x08037000) /* Base @ of Page 110, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_111 ((uint32_t)0x08037800) /* Base @ of Page 111, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_112 ((uint32_t)0x08038000) /* Base @ of Page 112, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_113 ((uint32_t)0x08038800) /* Base @ of Page 113, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_114 ((uint32_t)0x08039000) /* Base @ of Page 114, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_115 ((uint32_t)0x08039800) /* Base @ of Page 115, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_116 ((uint32_t)0x0803A000) /* Base @ of Page 116, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_117 ((uint32_t)0x0803A800) /* Base @ of Page 117, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_118 ((uint32_t)0x0803B000) /* Base @ of Page 118, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_119 ((uint32_t)0x0803B800) /* Base @ of Page 119, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_120 ((uint32_t)0x0803C000) /* Base @ of Page 120, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_121 ((uint32_t)0x0803C800) /* Base @ of Page 121, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_122 ((uint32_t)0x0803D000) /* Base @ of Page 122, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_123 ((uint32_t)0x0803D800) /* Base @ of Page 123, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_124 ((uint32_t)0x0803E000) /* Base @ of Page 124, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_125 ((uint32_t)0x0803E800) /* Base @ of Page 125, 2 Kbytes */
|
||||
#define ADDR_FLASH_PAGE_126 ((uint32_t)0x0803F000) /* Base @ of Page 126, 2 Kbytes */ //EEprom page1
|
||||
#define ADDR_FLASH_PAGE_127 ((uint32_t)0x0803F800) /* Base @ of Page 127, 2 Kbytes */ //EEprom page2
|
||||
// flash ends here
|
||||
|
||||
|
||||
typedef void (application_t)(void);
|
||||
|
||||
typedef struct{
|
||||
uint32_t stack_addr;
|
||||
application_t* func_p;
|
||||
} JumpStruct;
|
||||
|
||||
uint16_t modFlashEraseNewAppData(uint32_t new_app_size);
|
||||
uint16_t modFlashEraseMainAppData(uint32_t new_app_size);
|
||||
uint16_t modFlashWriteNewAppData(uint32_t offset, uint8_t *data, uint32_t len);
|
||||
uint16_t modFlashCopyNewAppToMainApp(uint32_t offset, uint8_t *data, uint32_t len);
|
||||
void modFlashJumpToBootloader(void);
|
||||
void modFlashJumpToMainApplication(void);
|
||||
void jumpToBootLoader(void);
|
||||
|
||||
#endif
|
||||
50
Core/Inc/modOperationalState.h
Normal file
50
Core/Inc/modOperationalState.h
Normal file
@@ -0,0 +1,50 @@
|
||||
///*
|
||||
// Copyright 2017 - 2018 Danny Bokma danny@diebie.nl
|
||||
// Copyright 2019 - 2020 Kevin Dionne kevin.dionne@ennoid.me
|
||||
//
|
||||
// This file is part of the DieBieMS/ENNOID-BMS firmware.
|
||||
//
|
||||
// The DieBieMS/ENNOID-BMS firmware is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// The DieBieMS/ENNOID-BMS firmware is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
// */
|
||||
//
|
||||
//#include "stdbool.h"
|
||||
//#include "mainDataTypes.h"
|
||||
//#include "modDelay.h"
|
||||
//#include "modPowerState.h"
|
||||
////#include "modEffect.h"
|
||||
//#include "modPowerElectronics.h"
|
||||
////#include "modDisplay.h"
|
||||
//#include "modConfig.h"
|
||||
//#include "modStateOfCharge.h"
|
||||
//#include "math.h"
|
||||
//
|
||||
//#ifndef MODOPERATIONALSTATE_H_
|
||||
//#define MODOPERATIONALSTATE_H_
|
||||
//
|
||||
//void modOperationalStateInit(modPowerElectronicsPackStateTypedef *packState, modConfigGeneralConfigStructTypedef *generalConfigPointer,modStateOfChargeStructTypeDef *generalStateOfCharge);
|
||||
//void modOperationalStateTask(void);
|
||||
//void modOperationalStateUpdateStates(void);
|
||||
//void modOperationalStateSetAllStates(OperationalStateTypedef newState);
|
||||
//void modOperationalStateSetNewState(OperationalStateTypedef newState);
|
||||
//
|
||||
//void modOperationalStateUpdateFaultStates(void);
|
||||
//void modOperationalStateSetAllFaultStates(bms_fault_state newFaultState);
|
||||
//void modOperationalStateSetNewFaultState(bms_fault_state newFaultState);
|
||||
//
|
||||
//void modOperationalStateHandleChargerDisconnect(OperationalStateTypedef newState);
|
||||
//void modOperationalStateTerminateOperation(void);
|
||||
//bool modOperationalStateDelayedDisable(bool delayedPowerDownDesired);
|
||||
//bool modOperationalStatePowerDownDelayCheck(void);
|
||||
//
|
||||
//#endif
|
||||
189
Core/Inc/modPowerElectronics.h
Normal file
189
Core/Inc/modPowerElectronics.h
Normal file
@@ -0,0 +1,189 @@
|
||||
/*
|
||||
Copyright 2017 - 2018 Danny Bokma danny@diebie.nl
|
||||
Copyright 2019 - 2020 Kevin Dionne kevin.dionne@ennoid.me
|
||||
|
||||
This file is part of the DieBieMS/ENNOID-BMS firmware.
|
||||
|
||||
The DieBieMS/ENNOID-BMS firmware is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The DieBieMS/ENNOID-BMS firmware is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __MODPOWERELECTRONICS_H
|
||||
#define __MODPOWERELECTRONICS_H
|
||||
|
||||
//#include "driverSWISL28022.h"
|
||||
//#include "driverHWADC.h"
|
||||
#include "driverSWLTC6804.h"
|
||||
//#include "driverSWADC128D818.h"
|
||||
//#include "driverHWSwitches.h"
|
||||
//#include "driverSWEMC2305.h"
|
||||
#include "modDelay.h"
|
||||
#include "modConfig.h"
|
||||
#//include "modPowerState.h"
|
||||
#include "stdbool.h"
|
||||
#include "math.h"
|
||||
//#include "driverSWSHT21.h"
|
||||
//#include "driverSWHTC1080.h"
|
||||
|
||||
|
||||
#define NoOfCellsPossibleOnBMS 180
|
||||
#define NoOfCellMonitorsPossibleOnBMS 19
|
||||
|
||||
#define NoOfAuxPossibleOnBMS 120
|
||||
|
||||
#define NoOfExpPossibleOnBMS 72
|
||||
#define NoOfExpMonitorPossibleOnBMS 9
|
||||
|
||||
#define NoOfTempSensors 14
|
||||
#define VinErrorThreshold 10
|
||||
|
||||
typedef enum {
|
||||
TEMP_EXT_LTC_NTC0 = 0, // EXT on master BMS on LTC
|
||||
TEMP_EXT_LTC_NTC1, // EXT on master BMS on LTC
|
||||
TEMP_INT_LTC_CHIP, // Int on master BMS inside LTC Chip
|
||||
TEMP_INT_STM_NTC, // Int on master BMS outside STM Chip
|
||||
TEMP_EXT_ADC_NTC0, // Ext on slave BMS OR water detect
|
||||
TEMP_EXT_ADC_NTC1, // Ext on slave BMS OR water detect
|
||||
TEMP_EXT_ADC_NTC2, // Ext on slave BMS OR water detect
|
||||
TEMP_EXT_ADC_NTC3, // Ext on slave BMS OR water detect
|
||||
TEMP_EXT_ADC_NTC4, // Ext on slave BMS OR water detect
|
||||
TEMP_EXT_ADC_NTC5, // Ext on slave BMS OR water detect
|
||||
TEMP_INT_ADC_NTC6, // Int on slave BMS
|
||||
TEMP_INT_ADC_NTC7, // Int on slave BMS
|
||||
TEMP_INT_SHT, // Int on slave BMS
|
||||
TEMP_INT_ADC_NTCAUX // Ext on the CAN connector
|
||||
} modPowerElectronicsTemperatureSensorMapping;
|
||||
|
||||
typedef enum {
|
||||
PACK_STATE_ERROR_HARD_CELLVOLTAGE = 0,
|
||||
PACK_STATE_ERROR_SOFT_CELLVOLTAGE,
|
||||
PACK_STATE_ERROR_OVER_CURRENT,
|
||||
PACK_STATE_NORMAL,
|
||||
PACK_STATE_ERROR_TEMPERATURE,
|
||||
} modPowerElectronicsPackOperationalCellStatesTypedef;
|
||||
|
||||
typedef struct {
|
||||
// Master BMS
|
||||
|
||||
uint64_t serial_number;
|
||||
|
||||
uint16_t throttleDutyGeneralTemperatureBMS;
|
||||
uint16_t throttleDutyChargeVoltage;
|
||||
uint16_t throttleDutyChargeTemperatureBattery;
|
||||
uint16_t throttleDutyCharge;
|
||||
uint16_t throttleDutyDischargeVoltage;
|
||||
uint16_t throttleDutyDischargeTemperatureBattery;
|
||||
uint16_t throttleDutyDischarge;
|
||||
float SoC;
|
||||
float SoCCapacityAh;
|
||||
OperationalStateTypedef operationalState;
|
||||
bms_fault_state faultState;
|
||||
float packVoltage;
|
||||
float packCurrent;
|
||||
float packPower;
|
||||
float loCurrentLoadCurrent;
|
||||
float loCurrentLoadVoltage;
|
||||
float chargerVoltage;
|
||||
float cellVoltageHigh;
|
||||
float cellVoltageLow;
|
||||
float cellVoltageAverage;
|
||||
float cellVoltageMisMatch;
|
||||
uint16_t cellBalanceResistorEnableMask;
|
||||
float temperatures[NoOfTempSensors];
|
||||
float tempBatteryHigh;
|
||||
float tempBatteryLow;
|
||||
float tempBatteryAverage;
|
||||
float tempBMSHigh;
|
||||
float tempBMSLow;
|
||||
float tempBMSAverage;
|
||||
float humidity;
|
||||
uint8_t preChargeDesired;
|
||||
uint8_t disChargeDesired;
|
||||
uint8_t disChargeLCAllowed;
|
||||
uint8_t chargeDesired;
|
||||
uint8_t chargePFETDesired;
|
||||
uint8_t chargeAllowed;
|
||||
uint8_t coolingDesired;
|
||||
uint8_t coolingAllowed;
|
||||
uint8_t safetyOverCANHCSafeNSafe;
|
||||
uint8_t chargeCurrentDetected;
|
||||
uint8_t chargeBalanceActive;
|
||||
uint8_t balanceActive;
|
||||
uint8_t powerButtonActuated;
|
||||
uint8_t packInSOADischarge;
|
||||
uint8_t packInSOACharge;
|
||||
uint8_t powerDownDesired;
|
||||
uint8_t powerOnLongButtonPress;
|
||||
uint8_t buzzerOn;
|
||||
uint8_t watchDogTime;
|
||||
cellMonitorCellsTypeDef cellVoltagesIndividual[NoOfCellsPossibleOnBMS];
|
||||
auxMonitorTypeDef auxVoltagesIndividual[NoOfAuxPossibleOnBMS];
|
||||
expMonitorTypeDef expVoltagesIndividual[NoOfExpPossibleOnBMS];
|
||||
|
||||
modPowerElectronicsPackOperationalCellStatesTypedef packOperationalCellState;
|
||||
|
||||
// Slave modules -> TODO move into struct.
|
||||
float cellModuleVoltages[NoOfCellMonitorsPossibleOnBMS][18];
|
||||
float auxModuleVoltages[NoOfCellMonitorsPossibleOnBMS][12];
|
||||
float expModuleVoltages[NoOfExpMonitorPossibleOnBMS][8];
|
||||
uint32_t cellModuleBalanceResistorEnableMask[NoOfCellMonitorsPossibleOnBMS];
|
||||
uint32_t dieTemperature[NoOfCellMonitorsPossibleOnBMS];
|
||||
|
||||
} modPowerElectronicsPackStateTypedef;
|
||||
|
||||
void modPowerElectronicsInit(modPowerElectronicsPackStateTypedef *packState, modConfigGeneralConfigStructTypedef *generalConfig);
|
||||
bool modPowerElectronicsTask(void);
|
||||
void modPowerElectronicsAllowForcedOn(bool allowedState);
|
||||
void modPowerElectronicsSetPreCharge(bool newState);
|
||||
bool modPowerElectronicsSetDisCharge(bool newState);
|
||||
void modPowerElectronicsSetCharge(bool newState);
|
||||
void modPowerElectronicsSetChargePFET(bool newState);
|
||||
void modPowerElectronicsSetCooling(bool newState);
|
||||
void modPowerElectronicsDisableAll(void);
|
||||
void modPowerElectronicsCalculateCellStats(void);
|
||||
void modPowerElectronicsSubTaskBalancing(void);
|
||||
void modPowerElectronicsCallMonitorsCalcBalanceResistorArray(void);
|
||||
void modPowerElectronicsSubTaskVoltageWatch(void);
|
||||
void modPowerElectronicsSubTaskCurrentWatch(void);
|
||||
void modPowerElectronicsUpdateSwitches(void);
|
||||
void modPowerElectronicsSortCells(cellMonitorCellsTypeDef *cells, uint8_t cellCount);
|
||||
void modPowerElectronicsCalcTempStats(void);
|
||||
void modPowerElectronicsCalcThrottle(void);
|
||||
int32_t modPowerElectronicsMapVariableInt(int32_t inputVariable, int32_t inputLowerLimit, int32_t inputUpperLimit, int32_t outputLowerLimit, int32_t outputUpperLimit);
|
||||
float modPowerElectronicsMapVariableFloat(float inputVariable, float inputLowerLimit, float inputUpperLimit, float outputLowerLimit, float outputUpperLimit);
|
||||
void modPowerElectronicsInitISL(void);
|
||||
void modPowerElectronicsSubTaskBuzzer(void);
|
||||
bool modPowerElectronicsHCSafetyCANAndPowerButtonCheck(void);
|
||||
void modPowerElectronicsResetBalanceModeActiveTimeout(void);
|
||||
void modPowerElectronicsCellMonitorsInit(void);
|
||||
void modPowerElectronicsCellMonitorsCheckConfigAndReadAnalogData(void);
|
||||
void modPowerElectronicsCellMonitorsStartCellConversion(void);
|
||||
void modPowerElectronicsCellMonitorsStartLoadedCellConversion(bool PUP);
|
||||
void modPowerElectronicsCellMonitorsStartTemperatureConversion(void);
|
||||
void modPowerElectronicsCellMonitorsEnableBalanceResistors(uint32_t);
|
||||
void modPowerElectronicsCellMonitorsEnableBalanceResistorsArray(void);
|
||||
void modPowerElectronicsCellMonitorsReadVoltageFlags(uint32_t *underVoltageFlags, uint32_t *overVoltageFlags);
|
||||
void modPowerElectronicsCellMonitorsCheckAndSolveInitState(void);
|
||||
void modPowerElectronicsCellMonitorsArrayTranslate(void);
|
||||
void modPowerElectronicsAuxMonitorsArrayTranslate(void);
|
||||
void modPowerElectronicsExpMonitorsArrayTranslate(void);
|
||||
float modPowerElectronicsCalcPackCurrent(void);
|
||||
void modPowerElectronicsTerminalCellConnectionTest(int argc, const char **argv);
|
||||
void modPowerElectronicsCheckPackSOA(void);
|
||||
void modPowerElectronicsSamplePackAndLCData(void);
|
||||
void modPowerElectronicsSamplePackVoltage(float *voltagePointer);
|
||||
void modPowerElectronicsLCSenseSample(void);
|
||||
void modPowerElectronicsLCSenseInit(void);
|
||||
uint16_t modPowerElectronicsLowestInThree(uint16_t num1,uint16_t num2,uint16_t num3);
|
||||
|
||||
#endif
|
||||
38
Core/Inc/modPowerState.h
Normal file
38
Core/Inc/modPowerState.h
Normal file
@@ -0,0 +1,38 @@
|
||||
///*
|
||||
// Copyright 2017 - 2018 Danny Bokma danny@diebie.nl
|
||||
// Copyright 2019 - 2020 Kevin Dionne kevin.dionne@ennoid.me
|
||||
//
|
||||
// This file is part of the DieBieMS/ENNOID-BMS firmware.
|
||||
//
|
||||
// The DieBieMS/ENNOID-BMS firmware is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// The DieBieMS/ENNOID-BMS firmware is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
// */
|
||||
//
|
||||
//#include "modDelay.h"
|
||||
//#include "driverHWPowerState.h"
|
||||
//#include "modconfig.h"
|
||||
//
|
||||
//#define POWERBUTTON_POWERDOWN_THRESHOLD_TIME 1000
|
||||
//#define POWERBUTTON_FORCEON_THRESHOLD_TIME 5000
|
||||
//#define POWERBUTTON_DEBOUNCE_TIME 600
|
||||
//
|
||||
//void modPowerStateInit(PowerStateStateTypedef desiredPowerState);
|
||||
//void modPowerStateSetConfigHandle(modConfigGeneralConfigStructTypedef *generalConfigPointer);
|
||||
//void modPowerStateTask(void);
|
||||
//bool modPowerStateGetButtonPressedState(void);
|
||||
//bool modPowerStateChargerDetected(void);
|
||||
//bool modPowerStatePowerdownRequest(void);
|
||||
//bool modPowerStateForceOnRequest(void);
|
||||
//void modPowerStateSetState(PowerStateStateTypedef newState);
|
||||
//bool modPowerStateButtonPressedOnTurnon(void);
|
||||
//bool modPowerStateGetLongButtonPressState(void);
|
||||
38
Core/Inc/modStateOfCharge.h
Normal file
38
Core/Inc/modStateOfCharge.h
Normal file
@@ -0,0 +1,38 @@
|
||||
#ifndef __MODSTATEOFCHARGE_H
|
||||
#define __MODSTATEOFCHARGE_H
|
||||
|
||||
#include "stdint.h"
|
||||
#include "stdbool.h"
|
||||
#include "modPowerElectronics.h"
|
||||
#include "modConfig.h"
|
||||
|
||||
typedef struct {
|
||||
float generalStateOfCharge;
|
||||
float generalStateOfHealth;
|
||||
float remainingCapacityAh;
|
||||
float remainingCapacityWh;
|
||||
} modStateOfChargeStructTypeDef;
|
||||
|
||||
|
||||
extern float real_capacity;
|
||||
extern float previous_capacity;
|
||||
extern float previous_SoC;
|
||||
//static float current_SoC = 0;
|
||||
extern float soc_diff;
|
||||
extern float capacity_diff;
|
||||
extern uint8_t SoC_Save_Flag;
|
||||
|
||||
typedef enum {
|
||||
EVENT_FULL = 0,
|
||||
EVENT_EMPTY,
|
||||
} modStateOfChargeVoltageEventTypeDef;
|
||||
|
||||
modStateOfChargeStructTypeDef* modStateOfChargeInit(modPowerElectronicsPackStateTypedef *packState, modConfigGeneralConfigStructTypedef *generalConfigPointer);
|
||||
void modStateOfChargeProcess(void);
|
||||
bool modStateOfChargeStoreAndLoadDefaultStateOfCharge(void);
|
||||
bool modStateOfChargeStoreStateOfCharge(void);
|
||||
bool modStateOfChargeLoadStateOfCharge(void);
|
||||
bool modStateOfChargePowerDownSave(void);
|
||||
void modStateOfChargeVoltageEvent(modStateOfChargeVoltageEventTypeDef eventType);
|
||||
|
||||
#endif
|
||||
50
Core/Inc/modTerminal.h
Normal file
50
Core/Inc/modTerminal.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
Copyright 2016 Benjamin Vedder benjamin@vedder.se
|
||||
Copyright 2017 - 2018 Danny Bokma danny@diebie.nl
|
||||
Copyright 2019 - 2020 Kevin Dionne kevin.dionne@ennoid.me
|
||||
|
||||
This file is part of the VESC/DieBieMS/ENNOID-BMS firmware.
|
||||
|
||||
The VESC/DieBieMS/ENNOID-BMS firmware is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The VESC/DieBieMS/ENNOID-BMS firmware is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TERMINAL_H_
|
||||
#define TERMINAL_H_
|
||||
|
||||
#include "mainDataTypes.h"
|
||||
#include "modCommands.h"
|
||||
#include "generalDefines.h"
|
||||
#include "modStateOfCharge.h"
|
||||
#include "modPowerElectronics.h"
|
||||
#include "modOperationalState.h"
|
||||
#include "modConfig.h"
|
||||
#include "GSM.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
// Settings
|
||||
#define FAULT_VEC_LEN 25
|
||||
#define CALLBACK_LEN 25
|
||||
|
||||
// Functions
|
||||
void modTerminalProcessString(char *str);
|
||||
void modTerminalRegisterCommandCallBack(
|
||||
const char* command,
|
||||
const char *help,
|
||||
const char *arg_names,
|
||||
void(*cbf)(int argc, const char **argv));
|
||||
|
||||
#endif /* TERMINAL_H_ */
|
||||
28
Core/Inc/modUART.h
Normal file
28
Core/Inc/modUART.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#ifndef __MODMESSAGE_H
|
||||
#define __MODMESSAGE_H
|
||||
|
||||
#include "stdint.h"
|
||||
#include "stdbool.h"
|
||||
#include "driverSWUART2.h"
|
||||
#include "modDelay.h"
|
||||
#include "modConfig.h"
|
||||
#include "modPowerElectronics.h"
|
||||
|
||||
#include "libPacket.h"
|
||||
#include "modCommands.h"
|
||||
|
||||
#define PACKET_HANDLER_UART 1
|
||||
|
||||
typedef enum {
|
||||
MESSAGE_DEBUG = 0,
|
||||
MESSAGE_ERROR,
|
||||
MESSAGE_NORMAL,
|
||||
} modMessageMessageTypeDef;
|
||||
|
||||
void modUARTInit(void);
|
||||
void modUARTTask(void);
|
||||
void modUARTSendPacketWrapper(unsigned char *data, unsigned int len);
|
||||
void modUARTProcessPacket(unsigned char *data, unsigned int len);
|
||||
void modUARTSendPacket(unsigned char *data, unsigned int len);
|
||||
|
||||
#endif
|
||||
58
Core/Inc/rtc.h
Normal file
58
Core/Inc/rtc.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file rtc.h
|
||||
* @brief This file contains all the function prototypes for
|
||||
* the rtc.c file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2021 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __RTC_H__
|
||||
#define __RTC_H__
|
||||
|
||||
#ifndef __GSMMODULE_H
|
||||
#include "GSM.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "main.h"
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
extern RTC_HandleTypeDef hrtc;
|
||||
|
||||
/* USER CODE BEGIN Private defines */
|
||||
|
||||
/* USER CODE END Private defines */
|
||||
|
||||
void MX_RTC_Init(void);
|
||||
|
||||
/* USER CODE BEGIN Prototypes */
|
||||
void RTC_Get_Values(Time_Struct* Time_to_Get);
|
||||
void RTC_Set_Values(Time_Struct* Time_to_Get);
|
||||
/* USER CODE END Prototypes */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __RTC_H__ */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
391
Core/Inc/stm32f1xx_hal_conf.h
Normal file
391
Core/Inc/stm32f1xx_hal_conf.h
Normal file
@@ -0,0 +1,391 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32f1xx_hal_conf.h
|
||||
* @brief HAL configuration file.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2017 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __STM32F1xx_HAL_CONF_H
|
||||
#define __STM32F1xx_HAL_CONF_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
/* ########################## Module Selection ############################## */
|
||||
/**
|
||||
* @brief This is the list of modules to be used in the HAL driver
|
||||
*/
|
||||
|
||||
#define HAL_MODULE_ENABLED
|
||||
#define HAL_ADC_MODULE_ENABLED
|
||||
/*#define HAL_CRYP_MODULE_ENABLED */
|
||||
#define HAL_CAN_MODULE_ENABLED
|
||||
/*#define HAL_CAN_LEGACY_MODULE_ENABLED */
|
||||
/*#define HAL_CEC_MODULE_ENABLED */
|
||||
/*#define HAL_CORTEX_MODULE_ENABLED */
|
||||
/*#define HAL_CRC_MODULE_ENABLED */
|
||||
#define HAL_DAC_MODULE_ENABLED
|
||||
/*#define HAL_DMA_MODULE_ENABLED */
|
||||
/*#define HAL_ETH_MODULE_ENABLED */
|
||||
/*#define HAL_FLASH_MODULE_ENABLED */
|
||||
#define HAL_GPIO_MODULE_ENABLED
|
||||
/*#define HAL_I2C_MODULE_ENABLED */
|
||||
/*#define HAL_I2S_MODULE_ENABLED */
|
||||
/*#define HAL_IRDA_MODULE_ENABLED */
|
||||
#define HAL_IWDG_MODULE_ENABLED
|
||||
/*#define HAL_NOR_MODULE_ENABLED */
|
||||
/*#define HAL_NAND_MODULE_ENABLED */
|
||||
/*#define HAL_PCCARD_MODULE_ENABLED */
|
||||
#define HAL_PCD_MODULE_ENABLED
|
||||
/*#define HAL_HCD_MODULE_ENABLED */
|
||||
/*#define HAL_PWR_MODULE_ENABLED */
|
||||
/*#define HAL_RCC_MODULE_ENABLED */
|
||||
#define HAL_RTC_MODULE_ENABLED
|
||||
/*#define HAL_SD_MODULE_ENABLED */
|
||||
/*#define HAL_MMC_MODULE_ENABLED */
|
||||
/*#define HAL_SDRAM_MODULE_ENABLED */
|
||||
/*#define HAL_SMARTCARD_MODULE_ENABLED */
|
||||
#define HAL_SPI_MODULE_ENABLED
|
||||
/*#define HAL_SRAM_MODULE_ENABLED */
|
||||
#define HAL_TIM_MODULE_ENABLED
|
||||
#define HAL_UART_MODULE_ENABLED
|
||||
/*#define HAL_USART_MODULE_ENABLED */
|
||||
/*#define HAL_WWDG_MODULE_ENABLED */
|
||||
|
||||
#define HAL_CORTEX_MODULE_ENABLED
|
||||
#define HAL_DMA_MODULE_ENABLED
|
||||
#define HAL_FLASH_MODULE_ENABLED
|
||||
#define HAL_EXTI_MODULE_ENABLED
|
||||
#define HAL_GPIO_MODULE_ENABLED
|
||||
#define HAL_PWR_MODULE_ENABLED
|
||||
#define HAL_RCC_MODULE_ENABLED
|
||||
|
||||
/* ########################## Oscillator Values adaptation ####################*/
|
||||
/**
|
||||
* @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
|
||||
* This value is used by the RCC HAL module to compute the system frequency
|
||||
* (when HSE is used as system clock source, directly or through the PLL).
|
||||
*/
|
||||
#if !defined (HSE_VALUE)
|
||||
#define HSE_VALUE 25000000U /*!< Value of the External oscillator in Hz */
|
||||
#endif /* HSE_VALUE */
|
||||
|
||||
#if !defined (HSE_STARTUP_TIMEOUT)
|
||||
#define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */
|
||||
#endif /* HSE_STARTUP_TIMEOUT */
|
||||
|
||||
/**
|
||||
* @brief Internal High Speed oscillator (HSI) value.
|
||||
* This value is used by the RCC HAL module to compute the system frequency
|
||||
* (when HSI is used as system clock source, directly or through the PLL).
|
||||
*/
|
||||
#if !defined (HSI_VALUE)
|
||||
#define HSI_VALUE 8000000U /*!< Value of the Internal oscillator in Hz*/
|
||||
#endif /* HSI_VALUE */
|
||||
|
||||
/**
|
||||
* @brief Internal Low Speed oscillator (LSI) value.
|
||||
*/
|
||||
#if !defined (LSI_VALUE)
|
||||
#define LSI_VALUE 40000U /*!< LSI Typical Value in Hz */
|
||||
#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
|
||||
The real value may vary depending on the variations
|
||||
in voltage and temperature. */
|
||||
|
||||
/**
|
||||
* @brief External Low Speed oscillator (LSE) value.
|
||||
* This value is used by the UART, RTC HAL module to compute the system frequency
|
||||
*/
|
||||
#if !defined (LSE_VALUE)
|
||||
#define LSE_VALUE 32768U /*!< Value of the External oscillator in Hz*/
|
||||
#endif /* LSE_VALUE */
|
||||
|
||||
#if !defined (LSE_STARTUP_TIMEOUT)
|
||||
#define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */
|
||||
#endif /* LSE_STARTUP_TIMEOUT */
|
||||
|
||||
/* Tip: To avoid modifying this file each time you need to use different HSE,
|
||||
=== you can define the HSE value in your toolchain compiler preprocessor. */
|
||||
|
||||
/* ########################### System Configuration ######################### */
|
||||
/**
|
||||
* @brief This is the HAL system configuration section
|
||||
*/
|
||||
#define VDD_VALUE 3300U /*!< Value of VDD in mv */
|
||||
#define TICK_INT_PRIORITY 0U /*!< tick interrupt priority (lowest by default) */
|
||||
#define USE_RTOS 0U
|
||||
#define PREFETCH_ENABLE 1U
|
||||
|
||||
#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */
|
||||
#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */
|
||||
#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */
|
||||
#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */
|
||||
#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */
|
||||
#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */
|
||||
#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */
|
||||
#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */
|
||||
#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */
|
||||
#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */
|
||||
#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */
|
||||
#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */
|
||||
#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */
|
||||
#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */
|
||||
#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */
|
||||
#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */
|
||||
#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */
|
||||
#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */
|
||||
#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */
|
||||
#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */
|
||||
#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */
|
||||
#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */
|
||||
#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */
|
||||
|
||||
/* ########################## Assert Selection ############################## */
|
||||
/**
|
||||
* @brief Uncomment the line below to expanse the "assert_param" macro in the
|
||||
* HAL drivers code
|
||||
*/
|
||||
/* #define USE_FULL_ASSERT 1U */
|
||||
|
||||
/* ################## Ethernet peripheral configuration ##################### */
|
||||
|
||||
/* Section 1 : Ethernet peripheral configuration */
|
||||
|
||||
/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */
|
||||
#define MAC_ADDR0 2U
|
||||
#define MAC_ADDR1 0U
|
||||
#define MAC_ADDR2 0U
|
||||
#define MAC_ADDR3 0U
|
||||
#define MAC_ADDR4 0U
|
||||
#define MAC_ADDR5 0U
|
||||
|
||||
/* Definition of the Ethernet driver buffers size and count */
|
||||
#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
|
||||
#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
|
||||
#define ETH_RXBUFNB 8U /* 4 Rx buffers of size ETH_RX_BUF_SIZE */
|
||||
#define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */
|
||||
|
||||
/* Section 2: PHY configuration section */
|
||||
|
||||
/* DP83848_PHY_ADDRESS Address*/
|
||||
#define DP83848_PHY_ADDRESS 0x01U
|
||||
/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
|
||||
#define PHY_RESET_DELAY 0x000000FFU
|
||||
/* PHY Configuration delay */
|
||||
#define PHY_CONFIG_DELAY 0x00000FFFU
|
||||
|
||||
#define PHY_READ_TO 0x0000FFFFU
|
||||
#define PHY_WRITE_TO 0x0000FFFFU
|
||||
|
||||
/* Section 3: Common PHY Registers */
|
||||
|
||||
#define PHY_BCR ((uint16_t)0x00) /*!< Transceiver Basic Control Register */
|
||||
#define PHY_BSR ((uint16_t)0x01) /*!< Transceiver Basic Status Register */
|
||||
|
||||
#define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */
|
||||
#define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */
|
||||
#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */
|
||||
#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */
|
||||
#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */
|
||||
#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */
|
||||
#define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */
|
||||
#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */
|
||||
#define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */
|
||||
#define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */
|
||||
|
||||
#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */
|
||||
#define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */
|
||||
#define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */
|
||||
|
||||
/* Section 4: Extended PHY Registers */
|
||||
#define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */
|
||||
|
||||
#define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */
|
||||
#define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */
|
||||
|
||||
/* ################## SPI peripheral configuration ########################## */
|
||||
|
||||
/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver
|
||||
* Activated: CRC code is present inside driver
|
||||
* Deactivated: CRC code cleaned from driver
|
||||
*/
|
||||
|
||||
#define USE_SPI_CRC 0U
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Include module's header file
|
||||
*/
|
||||
|
||||
#ifdef HAL_RCC_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_rcc.h"
|
||||
#endif /* HAL_RCC_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_GPIO_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_gpio.h"
|
||||
#endif /* HAL_GPIO_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_EXTI_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_exti.h"
|
||||
#endif /* HAL_EXTI_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_DMA_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_dma.h"
|
||||
#endif /* HAL_DMA_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_ETH_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_eth.h"
|
||||
#endif /* HAL_ETH_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_CAN_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_can.h"
|
||||
#endif /* HAL_CAN_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_CAN_LEGACY_MODULE_ENABLED
|
||||
#include "Legacy/stm32f1xx_hal_can_legacy.h"
|
||||
#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_CEC_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_cec.h"
|
||||
#endif /* HAL_CEC_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_CORTEX_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_cortex.h"
|
||||
#endif /* HAL_CORTEX_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_ADC_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_adc.h"
|
||||
#endif /* HAL_ADC_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_CRC_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_crc.h"
|
||||
#endif /* HAL_CRC_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_DAC_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_dac.h"
|
||||
#endif /* HAL_DAC_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_FLASH_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_flash.h"
|
||||
#endif /* HAL_FLASH_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_SRAM_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_sram.h"
|
||||
#endif /* HAL_SRAM_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_NOR_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_nor.h"
|
||||
#endif /* HAL_NOR_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_I2C_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_i2c.h"
|
||||
#endif /* HAL_I2C_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_I2S_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_i2s.h"
|
||||
#endif /* HAL_I2S_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_IWDG_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_iwdg.h"
|
||||
#endif /* HAL_IWDG_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_PWR_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_pwr.h"
|
||||
#endif /* HAL_PWR_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_RTC_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_rtc.h"
|
||||
#endif /* HAL_RTC_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_PCCARD_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_pccard.h"
|
||||
#endif /* HAL_PCCARD_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_SD_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_sd.h"
|
||||
#endif /* HAL_SD_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_NAND_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_nand.h"
|
||||
#endif /* HAL_NAND_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_SPI_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_spi.h"
|
||||
#endif /* HAL_SPI_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_TIM_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_tim.h"
|
||||
#endif /* HAL_TIM_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_UART_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_uart.h"
|
||||
#endif /* HAL_UART_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_USART_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_usart.h"
|
||||
#endif /* HAL_USART_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_IRDA_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_irda.h"
|
||||
#endif /* HAL_IRDA_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_SMARTCARD_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_smartcard.h"
|
||||
#endif /* HAL_SMARTCARD_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_WWDG_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_wwdg.h"
|
||||
#endif /* HAL_WWDG_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_PCD_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_pcd.h"
|
||||
#endif /* HAL_PCD_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_HCD_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_hcd.h"
|
||||
#endif /* HAL_HCD_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_MMC_MODULE_ENABLED
|
||||
#include "stm32f1xx_hal_mmc.h"
|
||||
#endif /* HAL_MMC_MODULE_ENABLED */
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
#ifdef USE_FULL_ASSERT
|
||||
/**
|
||||
* @brief The assert_param macro is used for function's parameters check.
|
||||
* @param expr If expr is false, it calls assert_failed function
|
||||
* which reports the name of the source file and the source
|
||||
* line number of the call that failed.
|
||||
* If expr is true, it returns no value.
|
||||
* @retval None
|
||||
*/
|
||||
#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
void assert_failed(uint8_t* file, uint32_t line);
|
||||
#else
|
||||
#define assert_param(expr) ((void)0U)
|
||||
#endif /* USE_FULL_ASSERT */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __STM32F1xx_HAL_CONF_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
70
Core/Inc/stm32f1xx_it.h
Normal file
70
Core/Inc/stm32f1xx_it.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32f1xx_it.h
|
||||
* @brief This file contains the headers of the interrupt handlers.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2021 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __STM32F1xx_IT_H
|
||||
#define __STM32F1xx_IT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN ET */
|
||||
|
||||
/* USER CODE END ET */
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EC */
|
||||
|
||||
/* USER CODE END EC */
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EM */
|
||||
|
||||
/* USER CODE END EM */
|
||||
|
||||
/* Exported functions prototypes ---------------------------------------------*/
|
||||
void NMI_Handler(void);
|
||||
void HardFault_Handler(void);
|
||||
void MemManage_Handler(void);
|
||||
void BusFault_Handler(void);
|
||||
void UsageFault_Handler(void);
|
||||
void SVC_Handler(void);
|
||||
void DebugMon_Handler(void);
|
||||
void PendSV_Handler(void);
|
||||
void SysTick_Handler(void);
|
||||
void OTG_FS_IRQHandler(void);
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
/* USER CODE END EFP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __STM32F1xx_IT_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
143
Core/Src/DPC_Timeout.c
Normal file
143
Core/Src/DPC_Timeout.c
Normal file
@@ -0,0 +1,143 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file : DPC_Timeout.c
|
||||
* @brief : Timeout Module
|
||||
******************************************************************************
|
||||
*
|
||||
* COPYRIGHT(c) 2020 STMicroelectronics
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "DPC_Timeout.h"
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup Private_Variables Private Variables
|
||||
* @{
|
||||
*/
|
||||
TimeoutDataStr_T Timeout_List[TO_MAX_NUMBER];
|
||||
/**
|
||||
*@}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup Private_function Private Variables
|
||||
* @{
|
||||
*/
|
||||
void DPC_TO_Init(void)
|
||||
{
|
||||
for ( uint8_t Temp = 0; Temp < TO_MAX_NUMBER; Temp++){
|
||||
Timeout_List[Temp].State = TO_OFF;
|
||||
Timeout_List[Temp].Count = 0;
|
||||
}
|
||||
}
|
||||
/**
|
||||
*@}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup Private_function Private Variables
|
||||
* @{
|
||||
*/
|
||||
TO_RET_STATE DPC_TO_Set(uint8_t TO_Num, uint32_t Val)
|
||||
{
|
||||
TO_RET_STATE RetState = TO_OUT_ERR;
|
||||
|
||||
if(Timeout_List[TO_Num].State == TO_OFF || Timeout_List[TO_Num].State == TO_RUN){
|
||||
Timeout_List[TO_Num].State = TO_RUN;
|
||||
Timeout_List[TO_Num].Count = Val;
|
||||
RetState = TO_OUT_OK;
|
||||
}
|
||||
return RetState;
|
||||
}
|
||||
/**
|
||||
*@}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup Private_function Private Variables
|
||||
* @{
|
||||
*/
|
||||
TO_RET_STATE DPC_TO_Check(uint8_t TO_Num)
|
||||
{
|
||||
TO_RET_STATE RetState = TO_OUT_ERR;
|
||||
if(Timeout_List[TO_Num].State == TO_RUN){
|
||||
RetState = TO_OUT_OK;
|
||||
}
|
||||
else if(Timeout_List[TO_Num].State == TO_TOOK){
|
||||
RetState = TO_OUT_TOOK;
|
||||
Timeout_List[TO_Num].State = TO_OFF;
|
||||
}
|
||||
return RetState;
|
||||
}
|
||||
/**
|
||||
*@}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup Private_function Private Variables
|
||||
* @{
|
||||
*/
|
||||
void TimeoutMng(void)
|
||||
{
|
||||
for ( uint8_t Temp = 0; Temp < TO_MAX_NUMBER; Temp++){
|
||||
|
||||
if(Timeout_List[Temp].State == TO_RUN){
|
||||
if(Timeout_List[Temp].Count == 0){
|
||||
Timeout_List[Temp].State = TO_TOOK;
|
||||
}
|
||||
else{
|
||||
Timeout_List[Temp].Count--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
*@}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief manage the command Load
|
||||
*/
|
||||
|
||||
/**
|
||||
*@}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Declare the Rx done flag
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Init the Telemetry package
|
||||
*/
|
||||
|
||||
/**
|
||||
*@}
|
||||
*/
|
||||
|
||||
/******************* (C) COPYRIGHT 2019 STMicroelectronics *****END OF FILE****/
|
||||
1646
Core/Src/GSM.c
Normal file
1646
Core/Src/GSM.c
Normal file
File diff suppressed because it is too large
Load Diff
572
Core/Src/SD_Card.c
Normal file
572
Core/Src/SD_Card.c
Normal file
@@ -0,0 +1,572 @@
|
||||
|
||||
#include "SD_Card.h"
|
||||
#include "DPC_Timeout.h"
|
||||
#include "string.h"
|
||||
#include "stdlib.h"
|
||||
#include "stdio.h"
|
||||
#include "rtc.h"
|
||||
|
||||
volatile ff_search_struct FileSearchStruct;
|
||||
|
||||
void SD_Card_Var_Init(SD_CARD_Global_Struct* SD_Struct){
|
||||
|
||||
HTTP_DATA_Struct* HTTP_DATA;
|
||||
HTTP_DATA=&SD_Struct->CSV_DATA;
|
||||
|
||||
SD_Struct->DATA0 = &SD_Struct->DATA0_ch[0];
|
||||
|
||||
SD_Struct->Header = "serial_number;"
|
||||
"started_at;"
|
||||
"ended_at;"
|
||||
"status_indication;"
|
||||
"energy_sum;"
|
||||
"battery_level_at_start;"
|
||||
"battery_level_at_end;"
|
||||
"battery_voltage_at_start;"
|
||||
"battery_voltage_at_end;"
|
||||
"battery_temperature_at_end;"
|
||||
"latitude;"
|
||||
"longitude;"
|
||||
"maximum_load_current;"
|
||||
"maximum_charge_current;"
|
||||
"internal_resistance;"
|
||||
"is_moderated;"
|
||||
"event_time;"
|
||||
"battery_condition_id\r";
|
||||
|
||||
|
||||
SD_Struct->FileName = &SD_Struct->Filename_ch[0];
|
||||
SD_Struct->Path = &SD_Struct->Path_ch[0];
|
||||
|
||||
|
||||
|
||||
HTTP_DATA->Serial_Number = &HTTP_DATA->Serial_Number_var[0];
|
||||
HTTP_DATA->Battery_Condition_ID = &HTTP_DATA->Battery_Condition_ID_var[0];
|
||||
HTTP_DATA->Event_time = &HTTP_DATA->Event_time_var[0];
|
||||
HTTP_DATA->Started_At_Time = &HTTP_DATA->Started_At_Time_var[0];
|
||||
HTTP_DATA->Ended_At_Time = &HTTP_DATA->Ended_At_Time_var[0];
|
||||
HTTP_DATA->Status_Indication = &HTTP_DATA->Status_Indication_var[0];
|
||||
HTTP_DATA->Energy_Sum = &HTTP_DATA->Energy_Sum_var[0];
|
||||
HTTP_DATA->Battery_Level_At_Start = &HTTP_DATA->Battery_Level_At_Start_var[0];
|
||||
HTTP_DATA->Battery_Level_At_End = &HTTP_DATA->Battery_Level_At_End_var[0];
|
||||
HTTP_DATA->Battery_Voltage_At_Start = &HTTP_DATA->Battery_Voltage_At_Start_var[0];
|
||||
HTTP_DATA->Battery_Voltage_At_End = &HTTP_DATA->Battery_Voltage_At_End_var[0];
|
||||
HTTP_DATA->Battery_Temperature_At_End = &HTTP_DATA->Battery_Temperature_At_End_var[0];
|
||||
HTTP_DATA->Latitude = &HTTP_DATA->Latitude_var[0];
|
||||
HTTP_DATA->Longitude = &HTTP_DATA->Longitude_var[0];
|
||||
HTTP_DATA->Maximum_Load_Current = &HTTP_DATA->Maximum_Load_Current_var[0];
|
||||
HTTP_DATA->Maximum_Charge_Current = &HTTP_DATA->Maximum_Charge_Current_var[0];
|
||||
HTTP_DATA->Internal_Resistance = &HTTP_DATA->Internal_Resistance_var[0];
|
||||
HTTP_DATA->Moderated = &HTTP_DATA->Moderated_var[0];
|
||||
HTTP_DATA->Current_time = &HTTP_DATA->Current_time_var[0];
|
||||
|
||||
}
|
||||
|
||||
uint8_t SD_Received_LOOKFOR(char* answ, char* LOOKFOR){
|
||||
uint8_t result=0;
|
||||
char *istr='\0';
|
||||
istr=strstr(answ, LOOKFOR);
|
||||
if (istr=='\0')
|
||||
{
|
||||
result=0; //nothing found
|
||||
}
|
||||
else
|
||||
{
|
||||
result=1; //found
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
SD_Card_states SD_Set_Command(SD_CARD_Global_Struct* SD_Struct, SD_Op_Commands CMD, uint32_t Timeout){
|
||||
|
||||
if (SD_Struct->SD_State_to_return == SD_READY){
|
||||
//Battery_Data_to_String_Converter(Sim_Struct);
|
||||
SD_Struct->SD_Active_Command = CMD;
|
||||
SD_Struct->SD_State_to_return = SD_BUSY;
|
||||
DPC_TO_Set(TO_SD_Card,Timeout);
|
||||
//CSV_Data_Compilation(SD_Struct);
|
||||
return SD_COMMAND_SET;
|
||||
}
|
||||
else return SD_COMMAND_NOT_SET;
|
||||
}
|
||||
|
||||
|
||||
void SD_Card_Processing(SD_CARD_Global_Struct* SD_Struct){
|
||||
|
||||
SD_Stages* Active_Stage;
|
||||
SD_Op_Commands* CMD;
|
||||
Time_Struct rtc_time;
|
||||
char Filename_ch[20];
|
||||
char* Filename = &Filename_ch[0];
|
||||
char Path_ch[100];
|
||||
char* Path=&Path_ch[0];
|
||||
|
||||
FileSearchStruct.filename=&FileSearchStruct.filename_ch[0];
|
||||
FileSearchStruct.fullpath=&FileSearchStruct.fullpath_ch[0];
|
||||
|
||||
strcpy(Path,"");
|
||||
strcpy(Filename,"");
|
||||
|
||||
|
||||
CMD = &SD_Struct->SD_Active_Command;
|
||||
Active_Stage = &SD_Struct->SD_Stages_list;
|
||||
|
||||
SD_Struct->SD_CARD_ChipDetect = HAL_GPIO_ReadPin(SD_CD_GPIO_Port, SD_CD_Pin);
|
||||
|
||||
if (DPC_TO_Check(TO_SD_Card)==TO_OUT_TOOK){
|
||||
if (*Active_Stage != SD_IDLE) {
|
||||
SD_Struct->SD_Stages_list = SD_UMOUNT;
|
||||
}
|
||||
}
|
||||
|
||||
switch (*Active_Stage){
|
||||
|
||||
case SD_IDLE:
|
||||
|
||||
if (SD_Struct->Mount_Flag){
|
||||
if (*CMD == SD_OP_WRITE_STATUS){
|
||||
CSV_Status_Data_Compilation(SD_Struct);
|
||||
*Active_Stage = SD_OPEN_DIR;
|
||||
}
|
||||
else if (*CMD == SD_OP_WRITE_PARAM){
|
||||
CSV_Param_Data_Compilation(SD_Struct);
|
||||
*Active_Stage = SD_OPEN_DIR;
|
||||
}
|
||||
else if(*CMD == SD_OP_WRITE_HEADER){
|
||||
*Active_Stage = SD_OPEN_DIR;
|
||||
}
|
||||
else if (*CMD == SD_OP_DELETEOLD){
|
||||
RTC_Get_Values(&rtc_time);
|
||||
if (rtc_time.year>20){
|
||||
*Active_Stage = SD_DELETE_OLD_FILES;
|
||||
}
|
||||
else *Active_Stage = SD_IDLE;
|
||||
}
|
||||
}
|
||||
|
||||
if (*CMD == SD_OP_MOUNT){
|
||||
*Active_Stage = SD_MOUNT;
|
||||
}
|
||||
else if (*CMD == SD_OP_UMOUNT){
|
||||
*Active_Stage = SD_UMOUNT;
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
case SD_MOUNT:
|
||||
|
||||
fres = f_mount(&FatFs, "", 1); //1=mount now
|
||||
if (fres != FR_OK) {
|
||||
SD_Struct->Fat_result=fres;
|
||||
}
|
||||
else if(fres==FR_OK){
|
||||
SD_Struct->Mount_Flag = 1;
|
||||
*Active_Stage = SD_CHECK_FREE_SPACE;
|
||||
}
|
||||
break;
|
||||
case SD_CHECK_FREE_SPACE:
|
||||
fres = f_getfree("", &free_clusters, &getFreeFs);
|
||||
if (fres == FR_OK) {
|
||||
total_sectors = (getFreeFs->n_fatent - 2) * getFreeFs->csize;
|
||||
free_sectors = free_clusters * getFreeFs->csize;
|
||||
|
||||
#if _MAX_SS != _MIN_SS
|
||||
free_space=free_sectors*getFreeFs->ssize;
|
||||
#else
|
||||
free_space = free_sectors * 512;
|
||||
#endif
|
||||
|
||||
if (free_space < __MIN_FREE_SPACE_REQUIRED){
|
||||
*Active_Stage = SD_DELETE_OLD_FILES;
|
||||
}
|
||||
else {
|
||||
SD_Struct->Mount_Flag = 1;
|
||||
*Active_Stage = SD_IDLE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SD_DELETE_OLD_FILES:
|
||||
FileSearchStruct.Oldest_FN_Month=99;
|
||||
FileSearchStruct.Oldest_FN_Year=99;
|
||||
FileSearchStruct.Oldest_FN_Value=0;
|
||||
Search_for_Oldest(&FileSearchStruct, Path, SD_Struct->Battery_Serial);
|
||||
|
||||
strcat(FileSearchStruct.fullpath,"/");
|
||||
strcat(FileSearchStruct.fullpath,FileSearchStruct.filename);
|
||||
if (FileSearchStruct.isDir==1){
|
||||
fres = delete_node(FileSearchStruct.fullpath, sizeof(FileSearchStruct.fullpath_ch), &flinf);
|
||||
}
|
||||
else{
|
||||
fres=f_unlink(FileSearchStruct.fullpath);
|
||||
}
|
||||
if (fres==FR_OK){
|
||||
*Active_Stage = SD_CHECK_FREE_SPACE;
|
||||
}
|
||||
else *Active_Stage = SD_CHECK_FREE_SPACE;
|
||||
break;
|
||||
case SD_OPEN_DIR:
|
||||
|
||||
//strcpy(Path,"/");
|
||||
//itoa(SD_Struct->Battery_Serial,Path+1,sizeof(SD_Struct->Battery_Serial)+6);
|
||||
SD_Update_Path(SD_Struct);
|
||||
|
||||
fres = f_opendir(&dir, SD_Struct->Path);
|
||||
if (fres == FR_OK) {
|
||||
*Active_Stage = SD_OPEN_FILE;
|
||||
}
|
||||
else if (fres == FR_NO_PATH){
|
||||
fres = f_mkdir(SD_Struct->Path);
|
||||
*Active_Stage = SD_OPEN_DIR;
|
||||
}
|
||||
else *Active_Stage = SD_OPEN_DIR;
|
||||
|
||||
break;
|
||||
case SD_OPEN_FILE:
|
||||
strcat(SD_Struct->Path,"/");
|
||||
strcat(SD_Struct->Path,SD_Struct->FileName);
|
||||
if (f_open(&fil, SD_Struct->Path, FA_READ | FA_WRITE | FA_OPEN_ALWAYS )==FR_OK){
|
||||
if (fil.fsize==0){
|
||||
*Active_Stage = SD_WRITE_HEADER;
|
||||
}
|
||||
else {
|
||||
*Active_Stage = SD_READ;
|
||||
}
|
||||
|
||||
}
|
||||
//fres = f_open(&fil, "1221.csv" /* SD_Struct->FileName*/, FA_READ | FA_WRITE | FA_OPEN_ALWAYS | FA_CREATE_ALWAYS);
|
||||
|
||||
break;
|
||||
case SD_READ:
|
||||
fres = f_read(&fil, &readbuff[0], strlen(SD_Struct->Header), &nRead);
|
||||
//f_gets(&readbuff[0], sizeof(SD_Struct->Header),&fil);
|
||||
//if (fres == FR_OK){
|
||||
if(SD_Received_LOOKFOR(&readbuff[0], SD_Struct->Header)){
|
||||
*Active_Stage = SD_WRITE;
|
||||
}
|
||||
else *Active_Stage = SD_WRITE_HEADER;
|
||||
//}
|
||||
break;
|
||||
case SD_WRITE_HEADER:
|
||||
f_puts(SD_Struct->Header, &fil);
|
||||
*Active_Stage = SD_WRITE;
|
||||
break;
|
||||
case SD_WRITE:
|
||||
fres = f_lseek(&fil, f_size(&fil));
|
||||
fres = f_write(&fil, SD_Struct->DATA0, strlen(SD_Struct->DATA0), &BytesWr);
|
||||
//f_puts(SD_Struct->DATA0, &fil);
|
||||
*Active_Stage = SD_CLOSE;
|
||||
break;
|
||||
|
||||
case SD_CLOSE:
|
||||
if(f_close(&fil) == FR_OK){
|
||||
if (f_closedir(&dir)==FR_OK){
|
||||
*Active_Stage = SD_IDLE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case SD_UMOUNT:
|
||||
if(f_mount(NULL, "", 1) == FR_OK){
|
||||
*Active_Stage = SD_IDLE;
|
||||
SD_Struct->Mount_Flag = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (*Active_Stage == SD_IDLE) {
|
||||
SD_Struct->SD_Active_Command = SD_OP_DONOTHING;
|
||||
SD_Struct->SD_State_to_return = SD_READY;
|
||||
|
||||
}
|
||||
else SD_Struct->SD_State_to_return = SD_BUSY;
|
||||
}
|
||||
|
||||
void SD_Update_Path(SD_CARD_Global_Struct* source){
|
||||
uint64_t Raw;
|
||||
char* part1="/";
|
||||
char* stringptr=&source->Raw_var[0];
|
||||
|
||||
Raw=source->Battery_Serial;
|
||||
|
||||
itoa(Raw,stringptr,sizeof(Raw)+2);
|
||||
strcpy(source->Path,part1);
|
||||
strcat(source->Path,stringptr);
|
||||
//strcat(source->Path,part1);
|
||||
|
||||
}
|
||||
|
||||
void Search_for_Oldest(volatile ff_search_struct* sourceStruct,char* Path, uint64_t ActualSerial){
|
||||
|
||||
uint32_t Raw;
|
||||
uint64_t Raw64;
|
||||
|
||||
char Path2_ch[100];
|
||||
char* Path2=&Path2_ch[0];
|
||||
|
||||
char Filename_ch[20];
|
||||
char* Filename = &Filename_ch[0];
|
||||
|
||||
|
||||
// Oldest_FN_Year = 99;
|
||||
// Oldest_FN_Month = 99;
|
||||
// Oldest_FN_Value = 0;
|
||||
|
||||
fres = f_opendir(&dir,Path);
|
||||
if (fres == FR_OK) {
|
||||
|
||||
//i = strlen(Path);
|
||||
for (;;) {
|
||||
fres = f_readdir(&dir, &flinf); /* Read a directory item */
|
||||
if (fres != FR_OK || flinf.fname[0] == 0) break; /* Break on error or end of dir */
|
||||
if (flinf.fname[0] == '.') continue; /* Ignore dot entry */
|
||||
|
||||
#if _USE_LFN
|
||||
Filename = *flinf.lfname ? fno.lfname : fno.fname;
|
||||
#else
|
||||
Filename = flinf.fname;
|
||||
#endif
|
||||
|
||||
if ((flinf.fattrib & AM_DIR) && !(flinf.fattrib & AM_SYS) && !(flinf.fattrib & AM_HID) ){
|
||||
Raw64=atol(Filename);
|
||||
if (Raw64 != ActualSerial){
|
||||
strcpy(sourceStruct->fullpath,Path);
|
||||
strcpy(sourceStruct->filename,Filename);
|
||||
sourceStruct->isDir=1;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
strcpy(Path2,Path);
|
||||
strcat(Path2,"/");
|
||||
strcat(Path2,Filename);
|
||||
Search_for_Oldest(sourceStruct,Path2,ActualSerial);
|
||||
}
|
||||
// if (sourceStruct->value!=0){
|
||||
// sourceStruct->Lastfound_FN_Month=(uint8_t)(sourceStruct->value/100);
|
||||
// Raw=sourceStruct->Lastfound_FN_Month*100;
|
||||
// sourceStruct->Lastfound_FN_Year=(uint8_t)(sourceStruct->value-Raw);
|
||||
// }
|
||||
}
|
||||
else if ( !(flinf.fattrib & AM_DIR) && !(flinf.fattrib & AM_SYS) && !(flinf.fattrib & AM_HID) ) {
|
||||
sourceStruct->isDir=0;
|
||||
sourceStruct->value = Filename_to_Value(Filename);
|
||||
if (sourceStruct->value!=0){
|
||||
sourceStruct->Lastfound_FN_Month=(uint8_t)(sourceStruct->value/100);
|
||||
Raw=sourceStruct->Lastfound_FN_Month*100;
|
||||
sourceStruct->Lastfound_FN_Year=(uint8_t)(sourceStruct->value-Raw);
|
||||
|
||||
|
||||
// if (Lastfound_FN_Month<=Oldest_FN_Month && Lastfound_FN_Year<=Oldest_FN_Year){
|
||||
// Oldest_FN_Year = Lastfound_FN_Year;
|
||||
// Oldest_FN_Month = Lastfound_FN_Month;
|
||||
// Oldest_FN_Value = FN_Value;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
if (sourceStruct->Lastfound_FN_Month!=0 || sourceStruct->Lastfound_FN_Year!=0){
|
||||
if (sourceStruct->Lastfound_FN_Month<=sourceStruct->Oldest_FN_Month && sourceStruct->Lastfound_FN_Year<=sourceStruct->Oldest_FN_Year){
|
||||
sourceStruct->Oldest_FN_Year = sourceStruct->Lastfound_FN_Year;
|
||||
sourceStruct->Oldest_FN_Month = sourceStruct->Lastfound_FN_Month;
|
||||
//sourceStruct->Oldest_FN_Value = sourceStruct->value;
|
||||
strcpy(sourceStruct->fullpath,Path);
|
||||
strcpy(sourceStruct->filename,Filename);
|
||||
}
|
||||
}
|
||||
|
||||
// if (flinf.fattrib & AM_DIR) { /* It is a directory */
|
||||
// //res = scan_files(path);
|
||||
// //if (res != FR_OK) break;
|
||||
// //path[i] = 0;
|
||||
// } else { /* It is a file. */
|
||||
//
|
||||
// //printf("%s/%s\n", path, fn);
|
||||
// }
|
||||
}
|
||||
|
||||
// if (Oldest_FN_Value!=0){
|
||||
// Configure_Path_to_delete(Path, Oldest_FN_Value);
|
||||
// }
|
||||
//fres = f_unlink()
|
||||
}
|
||||
}
|
||||
|
||||
void Battery_Data_to_CSV_Converter(SD_CARD_Global_Struct* Sd_Struct, HTTP_DATA_Struct* DST){
|
||||
Battery_Data_Struct* Bat_data;
|
||||
HTTP_DATA_Struct CSV_Data_DST;
|
||||
CSV_Data_DST = *DST;
|
||||
|
||||
char* Raw = &Sd_Struct->Raw_var[0];
|
||||
int Size;
|
||||
Bat_data = &Sd_Struct->BATTERY_DATA;
|
||||
|
||||
|
||||
itoa(Bat_data->Serial,Raw,sizeof(Bat_data->Serial)+2);
|
||||
strcpy(Sd_Struct->CSV_DATA.Serial_Number, Raw);
|
||||
|
||||
itoa(Bat_data->Battery_cond_ID,Raw,10);
|
||||
strcpy(Sd_Struct->CSV_DATA.Battery_Condition_ID, Raw);
|
||||
|
||||
SIM800_Time_To_String(&Bat_data->Event_time,CSV_Data_DST.Event_time);
|
||||
SIM800_Time_To_String(&Bat_data->Started_At_Time,CSV_Data_DST.Started_At_Time);
|
||||
SIM800_Time_To_String(&Bat_data->Ended_At_Time,CSV_Data_DST.Ended_At_Time);
|
||||
|
||||
itoa(Bat_data->Status_Indication,Raw,10);
|
||||
strcpy(CSV_Data_DST.Status_Indication, Raw);
|
||||
|
||||
itoa(Bat_data->Energy_Sum,Raw,10);
|
||||
strcpy(CSV_Data_DST.Energy_Sum, Raw);
|
||||
|
||||
itoa(Bat_data->Battery_Level_At_Start,Raw,10);
|
||||
strcpy(CSV_Data_DST.Battery_Level_At_Start, Raw);
|
||||
|
||||
itoa(Bat_data->Battery_Level_At_End,Raw,10);
|
||||
strcpy(CSV_Data_DST.Battery_Level_At_End, Raw);
|
||||
|
||||
sprintf(Raw, "%f", Bat_data->Battery_Voltage_At_Start);
|
||||
//ftoa(Bat_data->Battery_Voltage_At_Start,Raw,sizeof(Bat_data->Battery_Voltage_At_Start));
|
||||
strcpy(CSV_Data_DST.Battery_Voltage_At_Start, Raw);
|
||||
|
||||
sprintf(Raw, "%f", Bat_data->Battery_Voltage_At_End);
|
||||
//ftoa(Bat_data->Battery_Voltage_At_End,Raw,sizeof(Bat_data->Battery_Voltage_At_End));
|
||||
strcpy(CSV_Data_DST.Battery_Voltage_At_End, Raw);
|
||||
|
||||
itoa(Bat_data->Battery_Temperature_At_End,Raw,10);
|
||||
strcpy(CSV_Data_DST.Battery_Temperature_At_End, Raw);
|
||||
|
||||
itoa(Bat_data->Maximum_Load_Current,Raw,10);
|
||||
strcpy(CSV_Data_DST.Maximum_Load_Current, Raw);
|
||||
|
||||
itoa(Bat_data->Maximum_Charge_Current,Raw,10);
|
||||
strcpy(CSV_Data_DST.Maximum_Charge_Current, Raw);
|
||||
|
||||
sprintf(Raw, "%f", Bat_data->Internal_Resistance);
|
||||
//ftoa(Bat_data->Internal_Resistance,Raw,sizeof(Bat_data->Internal_Resistance));
|
||||
strcpy(CSV_Data_DST.Internal_Resistance, Raw);
|
||||
|
||||
if (Bat_data->Moderated){
|
||||
strcpy(CSV_Data_DST.Moderated,"true");
|
||||
}
|
||||
else strcpy(CSV_Data_DST.Moderated,"false");
|
||||
|
||||
//memcpy(DST,&CSV_Data_DST, sizeof(CSV_Data_DST));
|
||||
|
||||
memset(Raw,0,100);
|
||||
}
|
||||
|
||||
uint64_t Filename_to_Value(char* FN){
|
||||
Time_Struct rtc_time;
|
||||
uint32_t Raw;
|
||||
uint32_t FN_month;
|
||||
char* istr="/0";
|
||||
//char* test1_ptr=&test1[0];
|
||||
|
||||
|
||||
istr=strstr(FN,".CSV");
|
||||
if (istr=='\0')
|
||||
{
|
||||
Raw=0; //nothing found
|
||||
}
|
||||
else
|
||||
{
|
||||
Raw=atoi(istr-4); //found
|
||||
}
|
||||
return Raw;
|
||||
}
|
||||
|
||||
uint8_t Configure_Path_to_delete(char* path, uint32_t Value){
|
||||
char service[10];
|
||||
char* csv=".CSV";
|
||||
char* service_ptr=&service[0];
|
||||
|
||||
itoa(Value,service_ptr,sizeof(Value)+6);
|
||||
strcat(path,service_ptr);
|
||||
strcat(path,csv);
|
||||
}
|
||||
|
||||
void CSV_Status_Data_Compilation(SD_CARD_Global_Struct* Sd_Struct){
|
||||
|
||||
char* Delimeter=";";
|
||||
char* EndOfString = "\r";
|
||||
|
||||
strcpy(Sd_Struct->DATA0,Sd_Struct->CSV_DATA.Serial_Number);
|
||||
strcat(Sd_Struct->DATA0,Delimeter);
|
||||
strcat(Sd_Struct->DATA0,"");
|
||||
strcat(Sd_Struct->DATA0,Delimeter);
|
||||
strcat(Sd_Struct->DATA0,"");
|
||||
strcat(Sd_Struct->DATA0,Delimeter);
|
||||
strcat(Sd_Struct->DATA0,"");
|
||||
strcat(Sd_Struct->DATA0,Delimeter);
|
||||
strcat(Sd_Struct->DATA0,"");
|
||||
strcat(Sd_Struct->DATA0,Delimeter);
|
||||
strcat(Sd_Struct->DATA0,"");
|
||||
strcat(Sd_Struct->DATA0,Delimeter);
|
||||
strcat(Sd_Struct->DATA0,"");
|
||||
strcat(Sd_Struct->DATA0,Delimeter);
|
||||
strcat(Sd_Struct->DATA0,"");
|
||||
strcat(Sd_Struct->DATA0,Delimeter);
|
||||
strcat(Sd_Struct->DATA0,"");
|
||||
strcat(Sd_Struct->DATA0,Delimeter);
|
||||
strcat(Sd_Struct->DATA0,"");
|
||||
strcat(Sd_Struct->DATA0,Delimeter);
|
||||
strcat(Sd_Struct->DATA0,"");
|
||||
strcat(Sd_Struct->DATA0,Delimeter);
|
||||
strcat(Sd_Struct->DATA0,"");
|
||||
strcat(Sd_Struct->DATA0,Delimeter);
|
||||
strcat(Sd_Struct->DATA0,"");
|
||||
strcat(Sd_Struct->DATA0,Delimeter);
|
||||
strcat(Sd_Struct->DATA0,"");
|
||||
strcat(Sd_Struct->DATA0,Delimeter);
|
||||
strcat(Sd_Struct->DATA0,"");
|
||||
strcat(Sd_Struct->DATA0,Delimeter);
|
||||
strcat(Sd_Struct->DATA0,"");
|
||||
strcat(Sd_Struct->DATA0,Delimeter);
|
||||
strcat(Sd_Struct->DATA0,Sd_Struct->CSV_DATA.Event_time);
|
||||
strcat(Sd_Struct->DATA0,Delimeter);
|
||||
strcat(Sd_Struct->DATA0,Sd_Struct->CSV_DATA.Battery_Condition_ID);
|
||||
//strcat(Sd_Struct->DATA0,Delimeter);
|
||||
strcat(Sd_Struct->DATA0,EndOfString);
|
||||
}
|
||||
|
||||
void CSV_Param_Data_Compilation(SD_CARD_Global_Struct* Sd_Struct){
|
||||
|
||||
char* Delimeter=";";
|
||||
char* EndOfString = "\n";
|
||||
|
||||
strcpy(Sd_Struct->DATA0,Sd_Struct->CSV_DATA.Serial_Number);
|
||||
strcat(Sd_Struct->DATA0,Delimeter);
|
||||
strcat(Sd_Struct->DATA0,Sd_Struct->CSV_DATA.Started_At_Time);
|
||||
strcat(Sd_Struct->DATA0,Delimeter);
|
||||
strcat(Sd_Struct->DATA0,Sd_Struct->CSV_DATA.Ended_At_Time);
|
||||
strcat(Sd_Struct->DATA0,Delimeter);
|
||||
strcat(Sd_Struct->DATA0,Sd_Struct->CSV_DATA.Status_Indication);
|
||||
strcat(Sd_Struct->DATA0,Delimeter);
|
||||
strcat(Sd_Struct->DATA0,Sd_Struct->CSV_DATA.Energy_Sum);
|
||||
strcat(Sd_Struct->DATA0,Delimeter);
|
||||
strcat(Sd_Struct->DATA0,Sd_Struct->CSV_DATA.Battery_Level_At_Start);
|
||||
strcat(Sd_Struct->DATA0,Delimeter);
|
||||
strcat(Sd_Struct->DATA0,Sd_Struct->CSV_DATA.Battery_Level_At_End);
|
||||
strcat(Sd_Struct->DATA0,Delimeter);
|
||||
strcat(Sd_Struct->DATA0,Sd_Struct->CSV_DATA.Battery_Voltage_At_Start);
|
||||
strcat(Sd_Struct->DATA0,Delimeter);
|
||||
strcat(Sd_Struct->DATA0,Sd_Struct->CSV_DATA.Battery_Voltage_At_End);
|
||||
strcat(Sd_Struct->DATA0,Delimeter);
|
||||
strcat(Sd_Struct->DATA0,Sd_Struct->CSV_DATA.Battery_Temperature_At_End);
|
||||
strcat(Sd_Struct->DATA0,Delimeter);
|
||||
strcat(Sd_Struct->DATA0,Sd_Struct->CSV_DATA.Latitude);
|
||||
strcat(Sd_Struct->DATA0,Delimeter);
|
||||
strcat(Sd_Struct->DATA0,Sd_Struct->CSV_DATA.Longitude);
|
||||
strcat(Sd_Struct->DATA0,Delimeter);
|
||||
strcat(Sd_Struct->DATA0,Sd_Struct->CSV_DATA.Maximum_Load_Current);
|
||||
strcat(Sd_Struct->DATA0,Delimeter);
|
||||
strcat(Sd_Struct->DATA0,Sd_Struct->CSV_DATA.Maximum_Charge_Current);
|
||||
strcat(Sd_Struct->DATA0,Delimeter);
|
||||
strcat(Sd_Struct->DATA0,Sd_Struct->CSV_DATA.Internal_Resistance);
|
||||
strcat(Sd_Struct->DATA0,Delimeter);
|
||||
strcat(Sd_Struct->DATA0,Sd_Struct->CSV_DATA.Moderated);
|
||||
strcat(Sd_Struct->DATA0,Delimeter);
|
||||
strcat(Sd_Struct->DATA0,"");
|
||||
strcat(Sd_Struct->DATA0,Delimeter);
|
||||
strcat(Sd_Struct->DATA0,"");
|
||||
//strcat(Sd_Struct->DATA0,Delimeter);
|
||||
strcat(Sd_Struct->DATA0,EndOfString);
|
||||
}
|
||||
2
Core/Src/desktop.ini
Normal file
2
Core/Src/desktop.ini
Normal file
@@ -0,0 +1,2 @@
|
||||
[.ShellClassInfo]
|
||||
IconResource=C:\Program Files\Google\Drive File Stream\54.0.3.0\GoogleDriveFS.exe,23
|
||||
700
Core/Src/driverHWEEPROM.c
Normal file
700
Core/Src/driverHWEEPROM.c
Normal file
@@ -0,0 +1,700 @@
|
||||
#include "driverHWEEPROM.h"
|
||||
|
||||
/* Global variable used to store variable value in read sequence */
|
||||
uint16_t DataVar = 0;
|
||||
|
||||
uint16_t driverHWEEPROMNumberOfVars = 0;
|
||||
|
||||
/* Virtual address defined by the user: 0xFFFF value is prohibited */
|
||||
extern uint16_t *driverHWEEPROMVirtAddVarTab;
|
||||
|
||||
static HAL_StatusTypeDef driverHWEEPROMFormat(void);
|
||||
static uint16_t driverHWEEPROMFindValidPage(uint8_t Operation);
|
||||
static uint16_t driverHWEEPROMVerifyPageFullWriteVariable(uint16_t VirtAddress, uint16_t Data);
|
||||
static uint16_t driverHWEEPROMPageTransfer(uint16_t VirtAddress, uint16_t Data);
|
||||
static uint16_t driverHWEEPROMVerifyPageFullyErased(uint32_t Address);
|
||||
|
||||
/**
|
||||
* @brief Restore the pages to a known good state in case of page's status
|
||||
* corruption after a power loss.
|
||||
* @param None.
|
||||
* @retval - Flash error code: on write Flash error
|
||||
* - FLASH_COMPLETE: on success
|
||||
*/
|
||||
uint16_t driverHWEEPROMInit(uint16_t numberOfVars) {
|
||||
driverHWEEPROMNumberOfVars = numberOfVars;
|
||||
|
||||
uint16_t pagestatus0 = 6, pagestatus1 = 6;
|
||||
uint16_t varidx = 0;
|
||||
uint16_t eepromstatus = 0, readstatus = 0;
|
||||
int16_t x = -1;
|
||||
HAL_StatusTypeDef flashstatus;
|
||||
uint32_t page_error = 0;
|
||||
FLASH_EraseInitTypeDef s_eraseinit;
|
||||
|
||||
/* Get Page0 status */
|
||||
pagestatus0 = (*(__IO uint16_t*)PAGE0_BASE_ADDRESS);
|
||||
/* Get Page1 status */
|
||||
pagestatus1 = (*(__IO uint16_t*)PAGE1_BASE_ADDRESS);
|
||||
|
||||
/* Fill EraseInit structure*/
|
||||
s_eraseinit.TypeErase = FLASH_TYPEERASE_PAGES;
|
||||
s_eraseinit.PageAddress = PAGE0_BASE_ADDRESS;
|
||||
s_eraseinit.NbPages = 1;
|
||||
|
||||
/* Check for invalid header states and repair if necessary */
|
||||
switch (pagestatus0)
|
||||
{
|
||||
case ERASED:
|
||||
if (pagestatus1 == VALID_PAGE) /* Page0 erased, Page1 valid */
|
||||
{
|
||||
/* Erase Page0 */
|
||||
if(!driverHWEEPROMVerifyPageFullyErased(PAGE0_BASE_ADDRESS))
|
||||
{
|
||||
flashstatus = HAL_FLASHEx_Erase(&s_eraseinit, &page_error);
|
||||
/* If erase operation was failed, a Flash error code is returned */
|
||||
if (flashstatus != HAL_OK)
|
||||
{
|
||||
return flashstatus;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (pagestatus1 == RECEIVE_DATA) /* Page0 erased, Page1 receive */
|
||||
{
|
||||
/* Erase Page0 */
|
||||
if(!driverHWEEPROMVerifyPageFullyErased(PAGE0_BASE_ADDRESS))
|
||||
{
|
||||
flashstatus = HAL_FLASHEx_Erase(&s_eraseinit, &page_error);
|
||||
/* If erase operation was failed, a Flash error code is returned */
|
||||
if (flashstatus != HAL_OK)
|
||||
{
|
||||
return flashstatus;
|
||||
}
|
||||
}
|
||||
/* Mark Page1 as valid */
|
||||
flashstatus = HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, PAGE1_BASE_ADDRESS, VALID_PAGE);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (flashstatus != HAL_OK)
|
||||
{
|
||||
return flashstatus;
|
||||
}
|
||||
}
|
||||
else /* First EEPROM access (Page0&1 are erased) or invalid state -> format EEPROM */
|
||||
{
|
||||
/* Erase both Page0 and Page1 and set Page0 as valid page */
|
||||
flashstatus = driverHWEEPROMFormat();
|
||||
/* If erase/program operation was failed, a Flash error code is returned */
|
||||
if (flashstatus != HAL_OK)
|
||||
{
|
||||
return flashstatus;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case RECEIVE_DATA:
|
||||
if (pagestatus1 == VALID_PAGE) /* Page0 receive, Page1 valid */
|
||||
{
|
||||
/* Transfer data from Page1 to Page0 */
|
||||
for (varidx = 0; varidx < driverHWEEPROMNumberOfVars; varidx++)
|
||||
{
|
||||
if (( *(__IO uint16_t*)(PAGE0_BASE_ADDRESS + 6)) == driverHWEEPROMVirtAddVarTab[varidx])
|
||||
{
|
||||
x = varidx;
|
||||
}
|
||||
if (varidx != x)
|
||||
{
|
||||
/* Read the last variables' updates */
|
||||
readstatus = driverHWEEPROMReadVariable(driverHWEEPROMVirtAddVarTab[varidx], &DataVar);
|
||||
/* In case variable corresponding to the virtual address was found */
|
||||
if (readstatus != 0x1)
|
||||
{
|
||||
/* Transfer the variable to the Page0 */
|
||||
eepromstatus = driverHWEEPROMVerifyPageFullWriteVariable(driverHWEEPROMVirtAddVarTab[varidx], DataVar);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (eepromstatus != HAL_OK)
|
||||
{
|
||||
return eepromstatus;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Mark Page0 as valid */
|
||||
flashstatus = HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, PAGE0_BASE_ADDRESS, VALID_PAGE);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (flashstatus != HAL_OK)
|
||||
{
|
||||
return flashstatus;
|
||||
}
|
||||
s_eraseinit.TypeErase = FLASH_TYPEERASE_PAGES;
|
||||
s_eraseinit.PageAddress = PAGE1_BASE_ADDRESS;
|
||||
s_eraseinit.NbPages = 1;
|
||||
/* Erase Page1 */
|
||||
if(!driverHWEEPROMVerifyPageFullyErased(PAGE1_BASE_ADDRESS))
|
||||
{
|
||||
flashstatus = HAL_FLASHEx_Erase(&s_eraseinit, &page_error);
|
||||
/* If erase operation was failed, a Flash error code is returned */
|
||||
if (flashstatus != HAL_OK)
|
||||
{
|
||||
return flashstatus;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (pagestatus1 == ERASED) /* Page0 receive, Page1 erased */
|
||||
{
|
||||
s_eraseinit.TypeErase = FLASH_TYPEERASE_PAGES;
|
||||
s_eraseinit.PageAddress = PAGE1_BASE_ADDRESS;
|
||||
s_eraseinit.NbPages = 1;
|
||||
/* Erase Page1 */
|
||||
if(!driverHWEEPROMVerifyPageFullyErased(PAGE1_BASE_ADDRESS))
|
||||
{
|
||||
flashstatus = HAL_FLASHEx_Erase(&s_eraseinit, &page_error);
|
||||
/* If erase operation was failed, a Flash error code is returned */
|
||||
if (flashstatus != HAL_OK)
|
||||
{
|
||||
return flashstatus;
|
||||
}
|
||||
}
|
||||
/* Mark Page0 as valid */
|
||||
flashstatus = HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, PAGE0_BASE_ADDRESS, VALID_PAGE);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (flashstatus != HAL_OK)
|
||||
{
|
||||
return flashstatus;
|
||||
}
|
||||
}
|
||||
else /* Invalid state -> format eeprom */
|
||||
{
|
||||
/* Erase both Page0 and Page1 and set Page0 as valid page */
|
||||
flashstatus = driverHWEEPROMFormat();
|
||||
/* If erase/program operation was failed, a Flash error code is returned */
|
||||
if (flashstatus != HAL_OK)
|
||||
{
|
||||
return flashstatus;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case VALID_PAGE:
|
||||
if (pagestatus1 == VALID_PAGE) /* Invalid state -> format eeprom */
|
||||
{
|
||||
/* Erase both Page0 and Page1 and set Page0 as valid page */
|
||||
flashstatus = driverHWEEPROMFormat();
|
||||
/* If erase/program operation was failed, a Flash error code is returned */
|
||||
if (flashstatus != HAL_OK)
|
||||
{
|
||||
return flashstatus;
|
||||
}
|
||||
}
|
||||
else if (pagestatus1 == ERASED) /* Page0 valid, Page1 erased */
|
||||
{
|
||||
s_eraseinit.TypeErase = FLASH_TYPEERASE_PAGES;
|
||||
s_eraseinit.PageAddress = PAGE1_BASE_ADDRESS;
|
||||
s_eraseinit.NbPages = 1;
|
||||
/* Erase Page1 */
|
||||
if(!driverHWEEPROMVerifyPageFullyErased(PAGE1_BASE_ADDRESS))
|
||||
{
|
||||
flashstatus = HAL_FLASHEx_Erase(&s_eraseinit, &page_error);
|
||||
/* If erase operation was failed, a Flash error code is returned */
|
||||
if (flashstatus != HAL_OK)
|
||||
{
|
||||
return flashstatus;
|
||||
}
|
||||
}
|
||||
}
|
||||
else /* Page0 valid, Page1 receive */
|
||||
{
|
||||
/* Transfer data from Page0 to Page1 */
|
||||
for (varidx = 0; varidx < driverHWEEPROMNumberOfVars; varidx++)
|
||||
{
|
||||
if ((*(__IO uint16_t*)(PAGE1_BASE_ADDRESS + 6)) == driverHWEEPROMVirtAddVarTab[varidx])
|
||||
{
|
||||
x = varidx;
|
||||
}
|
||||
if (varidx != x)
|
||||
{
|
||||
/* Read the last variables' updates */
|
||||
readstatus = driverHWEEPROMReadVariable(driverHWEEPROMVirtAddVarTab[varidx], &DataVar);
|
||||
/* In case variable corresponding to the virtual address was found */
|
||||
if (readstatus != 0x1)
|
||||
{
|
||||
/* Transfer the variable to the Page1 */
|
||||
eepromstatus = driverHWEEPROMVerifyPageFullWriteVariable(driverHWEEPROMVirtAddVarTab[varidx], DataVar);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (eepromstatus != HAL_OK)
|
||||
{
|
||||
return eepromstatus;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Mark Page1 as valid */
|
||||
flashstatus = HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, PAGE1_BASE_ADDRESS, VALID_PAGE);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (flashstatus != HAL_OK)
|
||||
{
|
||||
return flashstatus;
|
||||
}
|
||||
s_eraseinit.TypeErase = FLASH_TYPEERASE_PAGES;
|
||||
s_eraseinit.PageAddress = PAGE0_BASE_ADDRESS;
|
||||
s_eraseinit.NbPages = 1;
|
||||
/* Erase Page0 */
|
||||
if(!driverHWEEPROMVerifyPageFullyErased(PAGE0_BASE_ADDRESS))
|
||||
{
|
||||
flashstatus = HAL_FLASHEx_Erase(&s_eraseinit, &page_error);
|
||||
/* If erase operation was failed, a Flash error code is returned */
|
||||
if (flashstatus != HAL_OK)
|
||||
{
|
||||
return flashstatus;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default: /* Any other state -> format eeprom */
|
||||
/* Erase both Page0 and Page1 and set Page0 as valid page */
|
||||
flashstatus = driverHWEEPROMFormat();
|
||||
/* If erase/program operation was failed, a Flash error code is returned */
|
||||
if (flashstatus != HAL_OK)
|
||||
{
|
||||
return flashstatus;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return HAL_OK;
|
||||
}
|
||||
|
||||
uint16_t driverHWEEPROMEraseFlash(void) {
|
||||
FLASH_EraseInitTypeDef s_eraseinit;
|
||||
HAL_StatusTypeDef flashstatus;
|
||||
uint32_t page_error = 0;
|
||||
|
||||
/* Fill EraseInit structure*/
|
||||
s_eraseinit.TypeErase = FLASH_TYPEERASE_PAGES;
|
||||
s_eraseinit.PageAddress = PAGE0_BASE_ADDRESS;
|
||||
s_eraseinit.NbPages = 2;
|
||||
|
||||
flashstatus = HAL_FLASHEx_Erase(&s_eraseinit, &page_error);
|
||||
/* If erase operation was failed, a Flash error code is returned */
|
||||
|
||||
return flashstatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Verify if specified page is fully erased.
|
||||
* @param Address: page address
|
||||
* This parameter can be one of the following values:
|
||||
* @arg PAGE0_BASE_ADDRESS: Page0 base address
|
||||
* @arg PAGE1_BASE_ADDRESS: Page1 base address
|
||||
* @retval page fully erased status:
|
||||
* - 0: if Page not erased
|
||||
* - 1: if Page erased
|
||||
*/
|
||||
uint16_t driverHWEEPROMVerifyPageFullyErased(uint32_t Address)
|
||||
{
|
||||
uint32_t readstatus = 1;
|
||||
uint16_t addressvalue = 0x5555;
|
||||
|
||||
/* Check each active page address starting from end */
|
||||
while (Address <= PAGE0_END_ADDRESS)
|
||||
{
|
||||
/* Get the current location content to be compared with virtual address */
|
||||
addressvalue = (*(__IO uint16_t*)Address);
|
||||
|
||||
/* Compare the read address with the virtual address */
|
||||
if (addressvalue != ERASED)
|
||||
{
|
||||
|
||||
/* In case variable value is read, reset readstatus flag */
|
||||
readstatus = 0;
|
||||
|
||||
break;
|
||||
}
|
||||
/* Next address location */
|
||||
Address = Address + 4;
|
||||
}
|
||||
|
||||
/* Return readstatus value: (0: Page not erased, 1: Page erased) */
|
||||
return readstatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the last stored variable data, if found, which correspond to
|
||||
* the passed virtual address
|
||||
* @param VirtAddress: Variable virtual address
|
||||
* @param Data: Global variable contains the read variable value
|
||||
* @retval Success or error status:
|
||||
* - 0: if variable was found
|
||||
* - 1: if the variable was not found
|
||||
* - NO_VALID_PAGE: if no valid page was found.
|
||||
*/
|
||||
uint16_t driverHWEEPROMReadVariable(uint16_t VirtAddress, uint16_t* Data)
|
||||
{
|
||||
uint16_t validpage = PAGE0;
|
||||
uint16_t addressvalue = 0x5555, readstatus = 1;
|
||||
uint32_t address = EEPROM_START_ADDRESS, PageStartAddress = EEPROM_START_ADDRESS;
|
||||
|
||||
/* Get active Page for read operation */
|
||||
validpage = driverHWEEPROMFindValidPage(READ_FROM_VALID_PAGE);
|
||||
|
||||
/* Check if there is no valid page */
|
||||
if (validpage == NO_VALID_PAGE)
|
||||
{
|
||||
return NO_VALID_PAGE;
|
||||
}
|
||||
|
||||
/* Get the valid Page start Address */
|
||||
PageStartAddress = (uint32_t)(EEPROM_START_ADDRESS + (uint32_t)(validpage * PAGE_SIZE));
|
||||
|
||||
/* Get the valid Page end Address */
|
||||
address = (uint32_t)((EEPROM_START_ADDRESS - 2) + (uint32_t)((1 + validpage) * PAGE_SIZE));
|
||||
|
||||
/* Check each active page address starting from end */
|
||||
while (address > (PageStartAddress + 2))
|
||||
{
|
||||
/* Get the current location content to be compared with virtual address */
|
||||
addressvalue = (*(__IO uint16_t*)address);
|
||||
|
||||
/* Compare the read address with the virtual address */
|
||||
if (addressvalue == VirtAddress)
|
||||
{
|
||||
/* Get content of Address-2 which is variable value */
|
||||
*Data = (*(__IO uint16_t*)(address - 2));
|
||||
|
||||
/* In case variable value is read, reset readstatus flag */
|
||||
readstatus = 0;
|
||||
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Next address location */
|
||||
address = address - 4;
|
||||
}
|
||||
}
|
||||
|
||||
/* Return readstatus value: (0: variable exist, 1: variable doesn't exist) */
|
||||
return readstatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Writes/upadtes variable data in EEPROM.
|
||||
* @param VirtAddress: Variable virtual address
|
||||
* @param Data: 16 bit data to be written
|
||||
* @retval Success or error status:
|
||||
* - FLASH_COMPLETE: on success
|
||||
* - PAGE_FULL: if valid page is full
|
||||
* - NO_VALID_PAGE: if no valid page was found
|
||||
* - Flash error code: on write Flash error
|
||||
*/
|
||||
uint16_t driverHWEEPROMWriteVariable(uint16_t VirtAddress, uint16_t Data)
|
||||
{
|
||||
uint16_t Status = 0;
|
||||
|
||||
/* Write the variable virtual address and value in the EEPROM */
|
||||
Status = driverHWEEPROMVerifyPageFullWriteVariable(VirtAddress, Data);
|
||||
|
||||
/* In case the EEPROM active page is full */
|
||||
if (Status == PAGE_FULL)
|
||||
{
|
||||
/* Perform Page transfer */
|
||||
Status = driverHWEEPROMPageTransfer(VirtAddress, Data);
|
||||
}
|
||||
|
||||
/* Return last operation status */
|
||||
return Status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Erases PAGE and PAGE1 and writes VALID_PAGE header to PAGE
|
||||
* @param None
|
||||
* @retval Status of the last operation (Flash write or erase) done during
|
||||
* EEPROM formating
|
||||
*/
|
||||
static HAL_StatusTypeDef driverHWEEPROMFormat(void)
|
||||
{
|
||||
HAL_StatusTypeDef flashstatus = HAL_OK;
|
||||
uint32_t page_error = 0;
|
||||
FLASH_EraseInitTypeDef s_eraseinit;
|
||||
|
||||
s_eraseinit.TypeErase = FLASH_TYPEERASE_PAGES;
|
||||
s_eraseinit.PageAddress = PAGE0_BASE_ADDRESS;
|
||||
s_eraseinit.NbPages = 1;
|
||||
/* Erase Page0 */
|
||||
if(!driverHWEEPROMVerifyPageFullyErased(PAGE0_BASE_ADDRESS))
|
||||
{
|
||||
flashstatus = HAL_FLASHEx_Erase(&s_eraseinit, &page_error);
|
||||
/* If erase operation was failed, a Flash error code is returned */
|
||||
if (flashstatus != HAL_OK)
|
||||
{
|
||||
return flashstatus;
|
||||
}
|
||||
}
|
||||
/* Set Page0 as valid page: Write VALID_PAGE at Page0 base address */
|
||||
flashstatus = HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, PAGE0_BASE_ADDRESS, VALID_PAGE);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (flashstatus != HAL_OK)
|
||||
{
|
||||
return flashstatus;
|
||||
}
|
||||
|
||||
s_eraseinit.PageAddress = PAGE1_BASE_ADDRESS;
|
||||
/* Erase Page1 */
|
||||
if(!driverHWEEPROMVerifyPageFullyErased(PAGE1_BASE_ADDRESS))
|
||||
{
|
||||
flashstatus = HAL_FLASHEx_Erase(&s_eraseinit, &page_error);
|
||||
/* If erase operation was failed, a Flash error code is returned */
|
||||
if (flashstatus != HAL_OK)
|
||||
{
|
||||
return flashstatus;
|
||||
}
|
||||
}
|
||||
|
||||
return HAL_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Find valid Page for write or read operation
|
||||
* @param Operation: operation to achieve on the valid page.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg READ_FROM_VALID_PAGE: read operation from valid page
|
||||
* @arg WRITE_IN_VALID_PAGE: write operation from valid page
|
||||
* @retval Valid page number (PAGE or PAGE1) or NO_VALID_PAGE in case
|
||||
* of no valid page was found
|
||||
*/
|
||||
static uint16_t driverHWEEPROMFindValidPage(uint8_t Operation)
|
||||
{
|
||||
uint16_t pagestatus0 = 6, pagestatus1 = 6;
|
||||
|
||||
/* Get Page0 actual status */
|
||||
pagestatus0 = (*(__IO uint16_t*)PAGE0_BASE_ADDRESS);
|
||||
|
||||
/* Get Page1 actual status */
|
||||
pagestatus1 = (*(__IO uint16_t*)PAGE1_BASE_ADDRESS);
|
||||
|
||||
/* Write or read operation */
|
||||
switch (Operation)
|
||||
{
|
||||
case WRITE_IN_VALID_PAGE: /* ---- Write operation ---- */
|
||||
if (pagestatus1 == VALID_PAGE)
|
||||
{
|
||||
/* Page0 receiving data */
|
||||
if (pagestatus0 == RECEIVE_DATA)
|
||||
{
|
||||
return PAGE0; /* Page0 valid */
|
||||
}
|
||||
else
|
||||
{
|
||||
return PAGE1; /* Page1 valid */
|
||||
}
|
||||
}
|
||||
else if (pagestatus0 == VALID_PAGE)
|
||||
{
|
||||
/* Page1 receiving data */
|
||||
if (pagestatus1 == RECEIVE_DATA)
|
||||
{
|
||||
return PAGE1; /* Page1 valid */
|
||||
}
|
||||
else
|
||||
{
|
||||
return PAGE0; /* Page0 valid */
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return NO_VALID_PAGE; /* No valid Page */
|
||||
}
|
||||
|
||||
case READ_FROM_VALID_PAGE: /* ---- Read operation ---- */
|
||||
if (pagestatus0 == VALID_PAGE)
|
||||
{
|
||||
return PAGE0; /* Page0 valid */
|
||||
}
|
||||
else if (pagestatus1 == VALID_PAGE)
|
||||
{
|
||||
return PAGE1; /* Page1 valid */
|
||||
}
|
||||
else
|
||||
{
|
||||
return NO_VALID_PAGE ; /* No valid Page */
|
||||
}
|
||||
|
||||
default:
|
||||
return PAGE0; /* Page0 valid */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Verify if active page is full and Writes variable in EEPROM.
|
||||
* @param VirtAddress: 16 bit virtual address of the variable
|
||||
* @param Data: 16 bit data to be written as variable value
|
||||
* @retval Success or error status:
|
||||
* - FLASH_COMPLETE: on success
|
||||
* - PAGE_FULL: if valid page is full
|
||||
* - NO_VALID_PAGE: if no valid page was found
|
||||
* - Flash error code: on write Flash error
|
||||
*/
|
||||
|
||||
static uint16_t driverHWEEPROMVerifyPageFullWriteVariable(uint16_t VirtAddress, uint16_t Data)
|
||||
{
|
||||
HAL_StatusTypeDef flashstatus = HAL_OK;
|
||||
uint16_t validpage = PAGE0;
|
||||
uint32_t address = EEPROM_START_ADDRESS, pageendaddress = EEPROM_START_ADDRESS+PAGE_SIZE;
|
||||
|
||||
/* Get valid Page for write operation */
|
||||
validpage = driverHWEEPROMFindValidPage(WRITE_IN_VALID_PAGE);
|
||||
|
||||
/* Check if there is no valid page */
|
||||
if (validpage == NO_VALID_PAGE)
|
||||
{
|
||||
return NO_VALID_PAGE;
|
||||
}
|
||||
|
||||
/* Get the valid Page start address */
|
||||
address = (uint32_t)(EEPROM_START_ADDRESS + (uint32_t)(validpage * PAGE_SIZE));
|
||||
|
||||
/* Get the valid Page end address */
|
||||
pageendaddress = (uint32_t)((EEPROM_START_ADDRESS - 1) + (uint32_t)((validpage + 1) * PAGE_SIZE));
|
||||
|
||||
/* Check each active page address starting from begining */
|
||||
while (address < pageendaddress)
|
||||
{
|
||||
/* Verify if address and address+2 contents are 0xFFFFFFFF */
|
||||
if ((*(__IO uint32_t*)address) == 0xFFFFFFFF)
|
||||
{
|
||||
/* Set variable data */
|
||||
flashstatus = HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, address, Data);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (flashstatus != HAL_OK)
|
||||
{
|
||||
return flashstatus;
|
||||
}
|
||||
/* Set variable virtual address */
|
||||
flashstatus = HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, address + 2, VirtAddress);
|
||||
/* Return program operation status */
|
||||
return flashstatus;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Next address location */
|
||||
address = address + 4;
|
||||
}
|
||||
}
|
||||
|
||||
/* Return PAGE_FULL in case the valid page is full */
|
||||
return PAGE_FULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Transfers last updated variables data from the full Page to
|
||||
* an empty one.
|
||||
* @param VirtAddress: 16 bit virtual address of the variable
|
||||
* @param Data: 16 bit data to be written as variable value
|
||||
* @retval Success or error status:
|
||||
* - FLASH_COMPLETE: on success
|
||||
* - PAGE_FULL: if valid page is full
|
||||
* - NO_VALID_PAGE: if no valid page was found
|
||||
* - Flash error code: on write Flash error
|
||||
*/
|
||||
static uint16_t driverHWEEPROMPageTransfer(uint16_t VirtAddress, uint16_t Data)
|
||||
{
|
||||
HAL_StatusTypeDef flashstatus = HAL_OK;
|
||||
uint32_t newpageaddress = EEPROM_START_ADDRESS;
|
||||
uint32_t oldpageid = 0;
|
||||
uint16_t validpage = PAGE0, varidx = 0;
|
||||
uint16_t eepromstatus = 0, readstatus = 0;
|
||||
uint32_t page_error = 0;
|
||||
FLASH_EraseInitTypeDef s_eraseinit;
|
||||
|
||||
/* Get active Page for read operation */
|
||||
validpage = driverHWEEPROMFindValidPage(READ_FROM_VALID_PAGE);
|
||||
|
||||
if (validpage == PAGE1) /* Page1 valid */
|
||||
{
|
||||
/* New page address where variable will be moved to */
|
||||
newpageaddress = PAGE0_BASE_ADDRESS;
|
||||
|
||||
/* Old page ID where variable will be taken from */
|
||||
oldpageid = PAGE1_BASE_ADDRESS;
|
||||
}
|
||||
else if (validpage == PAGE0) /* Page0 valid */
|
||||
{
|
||||
/* New page address where variable will be moved to */
|
||||
newpageaddress = PAGE1_BASE_ADDRESS;
|
||||
|
||||
/* Old page ID where variable will be taken from */
|
||||
oldpageid = PAGE0_BASE_ADDRESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NO_VALID_PAGE; /* No valid Page */
|
||||
}
|
||||
|
||||
/* Set the new Page status to RECEIVE_DATA status */
|
||||
flashstatus = HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, newpageaddress, RECEIVE_DATA);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (flashstatus != HAL_OK)
|
||||
{
|
||||
return flashstatus;
|
||||
}
|
||||
|
||||
/* Write the variable passed as parameter in the new active page */
|
||||
eepromstatus = driverHWEEPROMVerifyPageFullWriteVariable(VirtAddress, Data);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (eepromstatus != HAL_OK)
|
||||
{
|
||||
return eepromstatus;
|
||||
}
|
||||
|
||||
/* Transfer process: transfer variables from old to the new active page */
|
||||
for (varidx = 0; varidx < driverHWEEPROMNumberOfVars; varidx++)
|
||||
{
|
||||
if (driverHWEEPROMVirtAddVarTab[varidx] != VirtAddress) /* Check each variable except the one passed as parameter */
|
||||
{
|
||||
/* Read the other last variable updates */
|
||||
readstatus = driverHWEEPROMReadVariable(driverHWEEPROMVirtAddVarTab[varidx], &DataVar);
|
||||
/* In case variable corresponding to the virtual address was found */
|
||||
if (readstatus != 0x1)
|
||||
{
|
||||
/* Transfer the variable to the new active page */
|
||||
eepromstatus = driverHWEEPROMVerifyPageFullWriteVariable(driverHWEEPROMVirtAddVarTab[varidx], DataVar);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (eepromstatus != HAL_OK)
|
||||
{
|
||||
return eepromstatus;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
s_eraseinit.TypeErase = FLASH_TYPEERASE_PAGES;
|
||||
s_eraseinit.PageAddress = oldpageid;
|
||||
s_eraseinit.NbPages = 1;
|
||||
|
||||
/* Erase the old Page: Set old Page status to ERASED status */
|
||||
flashstatus = HAL_FLASHEx_Erase(&s_eraseinit, &page_error);
|
||||
/* If erase operation was failed, a Flash error code is returned */
|
||||
if (flashstatus != HAL_OK)
|
||||
{
|
||||
return flashstatus;
|
||||
}
|
||||
|
||||
/* Set new Page status to VALID_PAGE status */
|
||||
flashstatus = HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, newpageaddress, VALID_PAGE);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (flashstatus != HAL_OK)
|
||||
{
|
||||
return flashstatus;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Return last operation flash status */
|
||||
return flashstatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
34
Core/Src/driverHWPowerState.c
Normal file
34
Core/Src/driverHWPowerState.c
Normal file
@@ -0,0 +1,34 @@
|
||||
#include "driverHWPowerState.h"
|
||||
|
||||
const PowerStatePortStruct driverHWPorts[NoOfPowersSTATs] = // Holds all status configuration data
|
||||
{
|
||||
{GPIOB,0,GPIO_PIN_5,GPIO_MODE_OUTPUT_PP,GPIO_NOPULL}, // P_STAT_POWER_ENABLE
|
||||
{GPIOB,0,GPIO_PIN_4,GPIO_MODE_INPUT,GPIO_PULLUP}, // P_STAT_BUTTON_INPUT
|
||||
{GPIOE,0,GPIO_PIN_9,GPIO_MODE_INPUT,GPIO_PULLDOWN} // P_STAT_CHARGE_DETECT
|
||||
};
|
||||
|
||||
void driverHWPowerStateInit(void) {
|
||||
GPIO_InitTypeDef PowerStatePortHolder;
|
||||
uint8_t STATPointer;
|
||||
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||
|
||||
for(STATPointer = 0; STATPointer < NoOfPowersSTATs; STATPointer++) {
|
||||
//RCC->AHBENR |= driverHWPorts[STATPointer].ClkRegister; // Enable clock de desired port
|
||||
PowerStatePortHolder.Mode = driverHWPorts[STATPointer].Mode; // Push pull output
|
||||
PowerStatePortHolder.Pin = driverHWPorts[STATPointer].Pin; // Points to status pin
|
||||
PowerStatePortHolder.Pull = driverHWPorts[STATPointer].Pull; // No pullup
|
||||
PowerStatePortHolder.Speed = GPIO_SPEED_HIGH; // GPIO clock speed
|
||||
HAL_GPIO_Init(driverHWPorts[STATPointer].Port,&PowerStatePortHolder); // Perform the IO init
|
||||
};
|
||||
};
|
||||
|
||||
void driverHWPowerStateSetOutput(PowerStateIDTypedef outputPort, PowerStateStateTypedef newState) {
|
||||
HAL_GPIO_WritePin(driverHWPorts[outputPort].Port,driverHWPorts[outputPort].Pin,(GPIO_PinState)newState); // Set desired pin to desired state
|
||||
};
|
||||
|
||||
bool driverHWPowerStateReadInput(PowerStateIDTypedef inputPort) {
|
||||
return (bool) !HAL_GPIO_ReadPin(driverHWPorts[inputPort].Port,driverHWPorts[inputPort].Pin);
|
||||
};
|
||||
74
Core/Src/driverHWSPI1.c
Normal file
74
Core/Src/driverHWSPI1.c
Normal file
@@ -0,0 +1,74 @@
|
||||
#include "driverHWSPI1.h"
|
||||
|
||||
SPI_HandleTypeDef driverHWSPI1Handle;
|
||||
|
||||
void driverHWSPI1Init(GPIO_TypeDef* GPIOCSPort, uint16_t GPIO_CSPin) {
|
||||
driverHWSPI1Handle.Instance = SPI3;
|
||||
driverHWSPI1Handle.Init.Mode = SPI_MODE_MASTER;
|
||||
driverHWSPI1Handle.Init.Direction = SPI_DIRECTION_2LINES;
|
||||
driverHWSPI1Handle.Init.DataSize = SPI_DATASIZE_8BIT;
|
||||
driverHWSPI1Handle.Init.CLKPolarity = SPI_POLARITY_HIGH;
|
||||
//driverHWSPI1Handle.Init.CLKPhase = SPI_PHASE_1EDGE;
|
||||
driverHWSPI1Handle.Init.CLKPhase = SPI_PHASE_2EDGE;
|
||||
driverHWSPI1Handle.Init.NSS = SPI_NSS_HARD_OUTPUT;
|
||||
driverHWSPI1Handle.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_256;
|
||||
// driverHWSPI1Handle.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2;
|
||||
driverHWSPI1Handle.Init.FirstBit = SPI_FIRSTBIT_MSB;
|
||||
driverHWSPI1Handle.Init.TIMode = SPI_TIMODE_DISABLE;
|
||||
driverHWSPI1Handle.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
|
||||
driverHWSPI1Handle.Init.CRCPolynomial = 7;
|
||||
|
||||
|
||||
|
||||
|
||||
// driverHWSPI1Handle.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE;
|
||||
// driverHWSPI1Handle.Init.NSSPMode = SPI_NSS_PULSE_DISABLE;
|
||||
if (HAL_SPI_Init(&driverHWSPI1Handle) != HAL_OK)
|
||||
{
|
||||
while(true);
|
||||
}
|
||||
|
||||
HAL_GPIO_WritePin(GPIOCSPort,GPIO_CSPin,GPIO_PIN_SET);
|
||||
};
|
||||
|
||||
bool driverHWSPI1Write(uint8_t *writeBuffer, uint8_t noOfBytesToWrite, GPIO_TypeDef* GPIOCSPort, uint16_t GPIO_CSPin) {
|
||||
uint8_t *readBuffer; // Make fake buffer holder
|
||||
HAL_StatusTypeDef halReturnStatus; // Make holder for HAL state
|
||||
readBuffer = malloc(noOfBytesToWrite); // Make fake buffer for
|
||||
|
||||
HAL_GPIO_WritePin(GPIOCSPort,GPIO_CSPin,GPIO_PIN_RESET); // Make CS low
|
||||
halReturnStatus = HAL_SPI_TransmitReceive(&driverHWSPI1Handle,writeBuffer,readBuffer,noOfBytesToWrite,driverHWSPI1DefaultTimeout); // Write desired data to slave and store the received data in readBuffer
|
||||
while( driverHWSPI1Handle.State == HAL_SPI_STATE_BUSY ); // Wait until transmission is complete
|
||||
HAL_GPIO_WritePin(GPIOCSPort,GPIO_CSPin,GPIO_PIN_SET); // Make CS High
|
||||
|
||||
free(readBuffer); // Dump de fake buffer
|
||||
|
||||
return (halReturnStatus == HAL_OK); // Return true if all went OK
|
||||
};
|
||||
|
||||
bool driverHWSPI1WriteRead(uint8_t *writeBuffer, uint8_t noOfBytesToWrite, uint8_t *readBuffer, uint8_t noOfBytesToRead, GPIO_TypeDef* GPIOCSPort, uint16_t GPIO_CSPin) {
|
||||
uint8_t *writeArray, *readArray;
|
||||
HAL_StatusTypeDef halReturnStatus; // Make holder for HAL state
|
||||
|
||||
writeArray = malloc(sizeof(uint8_t)*(noOfBytesToWrite+noOfBytesToRead));
|
||||
readArray = malloc(sizeof(uint8_t)*(noOfBytesToWrite+noOfBytesToRead));
|
||||
|
||||
memset(writeArray,0xFF,noOfBytesToWrite+noOfBytesToRead);
|
||||
memcpy(writeArray,writeBuffer,noOfBytesToWrite);
|
||||
|
||||
HAL_GPIO_WritePin(GPIOCSPort,GPIO_CSPin,GPIO_PIN_RESET);
|
||||
halReturnStatus = HAL_SPI_TransmitReceive(&driverHWSPI1Handle,writeArray,readArray,noOfBytesToWrite+noOfBytesToRead,driverHWSPI1DefaultTimeout);
|
||||
while( driverHWSPI1Handle.State == HAL_SPI_STATE_BUSY ); // wait xmission complete
|
||||
HAL_GPIO_WritePin(GPIOCSPort,GPIO_CSPin,GPIO_PIN_SET);
|
||||
|
||||
memcpy(readBuffer,readArray+noOfBytesToWrite,noOfBytesToRead);
|
||||
|
||||
free(writeArray);
|
||||
free(readArray);
|
||||
|
||||
return (halReturnStatus == HAL_OK); // Return true if all went OK
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
65
Core/Src/driverHWSwitches.c
Normal file
65
Core/Src/driverHWSwitches.c
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
Copyright 2017 - 2018 Danny Bokma danny@diebie.nl
|
||||
Copyright 2019 - 2020 Kevin Dionne kevin.dionne@ennoid.me
|
||||
|
||||
This file is part of the DieBieMS/ENNOID-BMS firmware.
|
||||
|
||||
The DieBieMS/ENNOID-BMS firmware is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The DieBieMS/ENNOID-BMS firmware is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "driverHWSwitches.h"
|
||||
|
||||
const driverHWSwitchesPortStruct driverHWSwitchesPorts[NoOfSwitches] = // Hold all status configuration data
|
||||
{
|
||||
// {GPIOB,0,GPIO_PIN_2,GPIO_MODE_OUTPUT_PP,GPIO_NOPULL}, // SWITCH_COOLING or SWITCH_CHARGE_BYPASS
|
||||
// {GPIOB,0,GPIO_PIN_0,GPIO_MODE_OUTPUT_PP,GPIO_NOPULL}, // SWITCH_CHARGE
|
||||
// {GPIOB,0,GPIO_PIN_11,GPIO_MODE_OUTPUT_PP,GPIO_NOPULL}, // SWITCH_PRECHARGE
|
||||
// {GPIOB,0,GPIO_PIN_10,GPIO_MODE_OUTPUT_PP,GPIO_NOPULL}, // SWITCH_DISCHARGE
|
||||
// {GPIOC,0,GPIO_PIN_15,GPIO_MODE_OUTPUT_PP,GPIO_NOPULL}, // SWITCH_DISCHARGEHV
|
||||
// {GPIOC,0,GPIO_PIN_13,GPIO_MODE_OUTPUT_OD,GPIO_NOPULL}//, // SWITCH_SAFETY_OUTPUT
|
||||
};
|
||||
|
||||
void driverHWSwitchesInit(void) {
|
||||
GPIO_InitTypeDef switchPortHolder;
|
||||
uint8_t SwitchPointer;
|
||||
|
||||
// for(SwitchPointer = 0; SwitchPointer < NoOfSwitches; SwitchPointer++) {
|
||||
// // RCC->AHBENR |= driverHWSwitchesPorts[SwitchPointer].ClkRegister; // Enable clock de desired port
|
||||
// switchPortHolder.Mode = driverHWSwitchesPorts[SwitchPointer].Mode; // Push pull output
|
||||
// switchPortHolder.Pin = driverHWSwitchesPorts[SwitchPointer].Pin; // Points to status pin
|
||||
// switchPortHolder.Pull = driverHWSwitchesPorts[SwitchPointer].Pull; // Pullup
|
||||
// //switchPortHolder.Speed = GPIO_SPEED_HIGH; // GPIO clock speed
|
||||
// HAL_GPIO_Init(driverHWSwitchesPorts[SwitchPointer].Port,&switchPortHolder);// Perform the IO init
|
||||
// };
|
||||
//
|
||||
driverHWSwitchesSetSwitchState(SWITCH_SAFETY_OUTPUT,SWITCH_SET);
|
||||
};
|
||||
|
||||
void driverHWSwitchesSetSwitchState(driverHWSwitchesIDTypedef switchID, driverHWSwitchesStateTypedef newState) {
|
||||
// HAL_GPIO_WritePin(driverHWSwitchesPorts[switchID].Port,driverHWSwitchesPorts[switchID].Pin,(GPIO_PinState)newState); // Set desired pin to desired state
|
||||
};
|
||||
|
||||
void driverHWSwitchesDisableAll(void) {
|
||||
uint8_t SwitchPointer;
|
||||
// for(SwitchPointer = 0; SwitchPointer < NoOfSwitches; SwitchPointer++) {
|
||||
// HAL_GPIO_WritePin(driverHWSwitchesPorts[SwitchPointer].Port,driverHWSwitchesPorts[SwitchPointer].Pin,(GPIO_PinState)SWITCH_RESET); // Set desired pin to desired state
|
||||
// };
|
||||
};
|
||||
|
||||
|
||||
bool driverHWSwitchesGetSwitchState(driverHWSwitchesIDTypedef switchID) {
|
||||
return (bool) HAL_GPIO_ReadPin(driverHWSwitchesPorts[switchID].Port,driverHWSwitchesPorts[switchID].Pin); // Set desired pin to desired state
|
||||
};
|
||||
|
||||
|
||||
173
Core/Src/driverHWUART2.c
Normal file
173
Core/Src/driverHWUART2.c
Normal file
@@ -0,0 +1,173 @@
|
||||
#include "driverHWUART2.h"
|
||||
|
||||
UART_HandleTypeDef driverHWUART2Handle;
|
||||
DMA_HandleTypeDef driverHWUART2HDMAHandleRX;
|
||||
uint8_t driverHWUART2ReceivedChar;
|
||||
|
||||
uint8_t driverHWUART2ReceiveBuffer[RX_UART_BUFFER_SIZE]; // Buffer that stores received chars
|
||||
uint8_t driverHWUART2ReceiveBuffer_usb[RX_UART_BUFFER_SIZE];
|
||||
uint32_t driverHWUART2Receive_CNDTR = RX_UART_BUFFER_SIZE;
|
||||
uint8_t driverHWUART2Receive_CNDTR_resetFlag = 0;
|
||||
|
||||
void driverHWUART2Init(uint32_t baudRate) {
|
||||
// memset(driverHWUART2ReceiveBuffer,0,sizeof(driverHWUART2ReceiveBuffer)/sizeof(uint8_t));
|
||||
//
|
||||
// /* DMA controller clock enable */
|
||||
// __HAL_RCC_DMA1_CLK_ENABLE();
|
||||
//
|
||||
// driverHWUART2HDMAHandleRX.Instance = DMA1_Channel6; // Will handle transfer of received char to buffer
|
||||
// driverHWUART2HDMAHandleRX.Init.Direction = DMA_PERIPH_TO_MEMORY;
|
||||
// driverHWUART2HDMAHandleRX.Init.PeriphInc = DMA_PINC_DISABLE;
|
||||
// driverHWUART2HDMAHandleRX.Init.MemInc = DMA_MINC_ENABLE;
|
||||
// driverHWUART2HDMAHandleRX.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
|
||||
// driverHWUART2HDMAHandleRX.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
|
||||
// driverHWUART2HDMAHandleRX.Init.Mode = DMA_CIRCULAR;
|
||||
// driverHWUART2HDMAHandleRX.Init.Priority = DMA_PRIORITY_MEDIUM;
|
||||
//
|
||||
// if (HAL_DMA_Init(&driverHWUART2HDMAHandleRX) != HAL_OK)
|
||||
// {
|
||||
// while(true);
|
||||
// }
|
||||
//
|
||||
// __HAL_LINKDMA(&driverHWUART2Handle,hdmarx,driverHWUART2HDMAHandleRX);
|
||||
//
|
||||
// driverHWUART2Handle.Instance = USART2;
|
||||
// driverHWUART2Handle.Init.BaudRate = baudRate;
|
||||
// driverHWUART2Handle.Init.WordLength = UART_WORDLENGTH_8B;
|
||||
// driverHWUART2Handle.Init.StopBits = UART_STOPBITS_1;
|
||||
// driverHWUART2Handle.Init.Parity = UART_PARITY_NONE;
|
||||
// driverHWUART2Handle.Init.Mode = UART_MODE_TX_RX;
|
||||
// driverHWUART2Handle.Init.HwFlowCtl = UART_HWCONTROL_NONE;
|
||||
// driverHWUART2Handle.Init.OverSampling = UART_OVERSAMPLING_16;
|
||||
// // driverHWUART2Handle.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
|
||||
// // driverHWUART2Handle.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
|
||||
//
|
||||
// if (HAL_UART_Init(&driverHWUART2Handle) != HAL_OK) {
|
||||
// while(true);
|
||||
// }
|
||||
//
|
||||
// volatile HAL_StatusTypeDef temp = HAL_UART_Receive_DMA(&driverHWUART2Handle,driverHWUART2ReceiveBuffer,sizeof(driverHWUART2ReceiveBuffer)/sizeof(uint8_t)); // Start receive to DMA transfer
|
||||
//
|
||||
// HAL_NVIC_SetPriority(DMA1_Channel6_IRQn, 0, 0); // Will realise interrupt on half and full DMA transfer
|
||||
// HAL_NVIC_EnableIRQ(DMA1_Channel6_IRQn);
|
||||
};
|
||||
|
||||
void driverHWUART2SendChar(uint8_t character) {
|
||||
uint8_t usb_out_buffer[1];
|
||||
uint8_t usb_result = 1;
|
||||
uint32_t usb_start_time;
|
||||
usb_start_time = HAL_GetTick();
|
||||
|
||||
usb_out_buffer[0] = character;
|
||||
while(usb_result == 1){
|
||||
//) || ((HAL_GetTick() - usb_start_time < 10))
|
||||
usb_result = CDC_Transmit_FS(usb_out_buffer, 1);
|
||||
}
|
||||
//HAL_UART_Transmit(&driverHWUART2Handle,&character,sizeof(character)/sizeof(uint8_t),10); // Send single char over serial port
|
||||
};
|
||||
|
||||
bool driverHWUART2GetChar(char *character) {
|
||||
static uint32_t bufferTail = 0; // Initiate tail to 0
|
||||
uint32_t bufferHead = sizeof(driverHWUART2ReceiveBuffer_usb)/sizeof(uint8_t) - driverHWUART2Receive_CNDTR; // Tranform to be transferred bytes to bytes transferred.
|
||||
|
||||
// if(driverHWUART2Receive_CNDTR_resetFlag){
|
||||
// bufferTail = 0;
|
||||
// driverHWUART2Receive_CNDTR_resetFlag = 0;
|
||||
// //bufferHead = 0;
|
||||
// }
|
||||
|
||||
if(bufferTail != bufferHead){ // If head and tail differs there is something in the buffer
|
||||
*character = driverHWUART2ReceiveBuffer_usb[bufferTail]; // Get char from tail of buffer
|
||||
bufferTail++; // Move the tail forward
|
||||
bufferTail %= (sizeof(driverHWUART2ReceiveBuffer_usb)/sizeof(uint8_t)); // Wrap it around the end
|
||||
return true; // Indicate there is a char in buffer
|
||||
}else
|
||||
return false; // Indicate there is no char in buffer
|
||||
};
|
||||
|
||||
//bool driverHWUART2GetChar(char *character) {
|
||||
// static uint32_t bufferTail = 0;
|
||||
// __IO uint32_t a = 0;
|
||||
// __IO uint32_t b = 0;
|
||||
// uint32_t usb_start_time;
|
||||
// __IO uint32_t bufferHead = 0;
|
||||
// usb_start_time = HAL_GetTick();// Initiate tail to 0
|
||||
// uint32_t cndtr_buf = driverHWUART2HDMAHandleRX.Instance->CNDTR;
|
||||
//
|
||||
// if(driverHWUART2Receive_CNDTR_resetFlag){
|
||||
// bufferTail = 0;
|
||||
// driverHWUART2Receive_CNDTR_resetFlag = 0;
|
||||
// //bufferHead = 0;
|
||||
//
|
||||
// }
|
||||
//
|
||||
// //uint32_t bufferHead = sizeof(driverHWUART2ReceiveBuffer)/sizeof(uint8_t) - driverHWUART2HDMAHandleRX.Instance->CNDTR; // Tranform to be transferred bytes to bytes transferred.
|
||||
// bufferHead = sizeof(driverHWUART2ReceiveBuffer)/sizeof(uint8_t) - driverHWUART2Receive_CNDTR; // Tranform to be transferred bytes to bytes transferred.
|
||||
// // 1024 - 1016 = 8
|
||||
// a = bufferHead - bufferTail;
|
||||
// if(a != 0) {
|
||||
// *character = driverHWUART2ReceiveBuffer_usb[bufferTail];
|
||||
// bufferTail++;
|
||||
//
|
||||
// bufferTail %= (sizeof(driverHWUART2ReceiveBuffer)/sizeof(uint8_t));
|
||||
// return true;
|
||||
// } else{
|
||||
// if(driverHWUART2Receive_CNDTR < 1000) {
|
||||
// return false;
|
||||
// }
|
||||
// return false; // Indicate there is no char in buffer
|
||||
// }
|
||||
// //if(bufferTail != bufferHead) { // If head and tail differs there is something in the buffer
|
||||
// //while (bufferTail != bufferHead) {
|
||||
//// //if(bufferTail < 20) {
|
||||
//// //*character = driverHWUART2ReceiveBuffer[bufferTail]; // Get char from tail of buffer
|
||||
//// *character = driverHWUART2ReceiveBuffer_usb[bufferTail];
|
||||
//// bufferTail++;
|
||||
//// // Move the tail forward
|
||||
//// bufferTail %= (sizeof(driverHWUART2ReceiveBuffer)/sizeof(uint8_t)); // Wrap it around the end
|
||||
//// // bufferTail = bufferTail % 1024
|
||||
//// // bufferTail = 1024 % 1024 = 0
|
||||
//// return true; // Indicate there is a char in buffer
|
||||
//// }else{
|
||||
//// if(driverHWUART2Receive_CNDTR < 1000) {
|
||||
//// return false;
|
||||
//// }
|
||||
//// return false; // Indicate there is no char in buffer
|
||||
//// }
|
||||
//};
|
||||
|
||||
//void driverHWUART2SendChar(uint8_t character) {
|
||||
// //HAL_UART_Transmit(&driverHWUART2Handle,&character,sizeof(character)/sizeof(uint8_t),10); // Send single char over serial port
|
||||
//// CDC_Transmit_FS(character, 1);
|
||||
// uint8_t testDataToSend[8];
|
||||
// // for (uint8_t i = 0; i < 8; i++)
|
||||
// // {
|
||||
// // testDataToSend[i] = i;
|
||||
// // }
|
||||
//
|
||||
// testDataToSend[0] = character;
|
||||
// CDC_Transmit_FS(testDataToSend, 1);
|
||||
//
|
||||
// //uint8_t buf[1];
|
||||
// //buf[0] = character;
|
||||
// //CDC_Transmit_FS(buf[0], 1);
|
||||
//};
|
||||
//
|
||||
//bool driverHWUART2GetChar(char *character) {
|
||||
// static uint32_t bufferTail = 0; // Initiate tail to 0
|
||||
// uint32_t bufferHead = sizeof(driverHWUART2ReceiveBuffer)/sizeof(uint8_t) - driverHWUART2Receive_CNDTR; // Tranform to be transferred bytes to bytes transferred.
|
||||
// if(bufferHead == 12) {
|
||||
//// bufferTail = 1;
|
||||
// }
|
||||
// if(bufferTail != bufferHead){ // If head and tail differs there is something in the buffer
|
||||
// *character = driverHWUART2ReceiveBuffer[bufferTail]; // Get char from tail of buffer
|
||||
// bufferTail++; // Move the tail forward
|
||||
// bufferTail %= (sizeof(driverHWUART2ReceiveBuffer)/sizeof(uint8_t)); // Wrap it around the end
|
||||
// return true; // Indicate there is a char in buffer
|
||||
// }else
|
||||
// return false; // Indicate there is no char in buffer
|
||||
//};
|
||||
|
||||
void DMA1_Channel6_IRQHandler(void) { // Will trigger on halve and full
|
||||
// HAL_DMA_IRQHandler(&driverHWUART2HDMAHandleRX);
|
||||
}
|
||||
789
Core/Src/driverSWLTC6804.c
Normal file
789
Core/Src/driverSWLTC6804.c
Normal file
@@ -0,0 +1,789 @@
|
||||
/*
|
||||
Copyright 2017 - 2018 Danny Bokma danny@diebie.nl
|
||||
Copyright 2019 - 2020 Kevin Dionne kevin.dionne@ennoid.me
|
||||
|
||||
This file is part of the DieBieMS/ENNOID-BMS firmware.
|
||||
|
||||
The DieBieMS/ENNOID-BMS firmware is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The DieBieMS/ENNOID-BMS firmware is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "driverSWLTC6804.h"
|
||||
#define LTC6804_CS_Pin GPIO_PIN_3
|
||||
#define LTC6804_CS_GPIO_Port GPIOC
|
||||
uint8_t driverSWLTC6804TotalNumberOfICs = 0;
|
||||
|
||||
uint8_t driverSWLTC6804MaxNoOfCellPerModule = 0;
|
||||
uint8_t driverSWLTC6804MaxNoOfTempSensorPerModule = 0;
|
||||
|
||||
driverLTC6804ConfigStructTypedef driverSWLTC6804ConfigStruct;
|
||||
|
||||
void driverSWLTC6804DelayMS(uint32_t delayMS) {
|
||||
uint32_t currentTick = HAL_GetTick();
|
||||
while(!modDelayTick1ms(¤tTick,delayMS)){};
|
||||
}
|
||||
|
||||
void driverSWLTC6804Init(driverLTC6804ConfigStructTypedef configStruct, uint8_t totalNumberOfLTCs, uint8_t noOfCellPerModule, uint8_t noOfTempSensorPerModule, uint8_t cellMonitorType) {
|
||||
driverSWLTC6804ConfigStruct = configStruct;
|
||||
driverSWLTC6804TotalNumberOfICs = totalNumberOfLTCs;
|
||||
driverSWLTC6804MaxNoOfCellPerModule = noOfCellPerModule;
|
||||
driverSWLTC6804MaxNoOfTempSensorPerModule = noOfTempSensorPerModule;
|
||||
|
||||
uint8_t rxConfig [driverSWLTC6804TotalNumberOfICs][8];
|
||||
uint8_t LTCScanCount = 0;
|
||||
int8_t returnPEC = -1;
|
||||
|
||||
driverHWSPI1Init(LTC6804_CS_GPIO_Port,LTC6804_CS_Pin);
|
||||
driverSWLTC6804WakeIC();
|
||||
|
||||
while((LTCScanCount < 5) && (returnPEC == -1)){
|
||||
returnPEC = driverSWLTC6804ReadConfigRegister(driverSWLTC6804TotalNumberOfICs,rxConfig);
|
||||
driverSWLTC6804WakeIC();
|
||||
driverSWLTC6804WriteConfigRegister(driverSWLTC6804TotalNumberOfICs,0,false);
|
||||
if(cellMonitorType==CELL_MON_LTC6812_1 || cellMonitorType == CELL_MON_LTC6813_1){
|
||||
driverSWLTC6804WriteConfigRegisterB(driverSWLTC6804TotalNumberOfICs,0,false);
|
||||
}
|
||||
driverSWLTC6804WakeIC();
|
||||
LTCScanCount++;
|
||||
}
|
||||
}
|
||||
|
||||
void driverSWLTC6804ResetCellVoltageRegisters(void) {
|
||||
uint8_t cmd[4];
|
||||
uint16_t cmd_pec;
|
||||
|
||||
cmd[0] = 0x07;
|
||||
cmd[1] = 0x11;
|
||||
cmd_pec = driverSWLTC6804CalcPEC15(2, cmd);
|
||||
cmd[2] = (uint8_t)(cmd_pec >> 8);
|
||||
cmd[3] = (uint8_t)(cmd_pec );
|
||||
|
||||
driverSWLTC6804WakeIC();
|
||||
driverSWLTC6804Write(cmd,4);
|
||||
}
|
||||
|
||||
void driverSWLTC6804ResetAuxRegisters(void) {
|
||||
uint8_t cmd[4];
|
||||
uint16_t cmd_pec;
|
||||
|
||||
cmd[0] = 0x07;
|
||||
cmd[1] = 0x12;
|
||||
cmd_pec = driverSWLTC6804CalcPEC15(2, cmd);
|
||||
cmd[2] = (uint8_t)(cmd_pec >> 8);
|
||||
cmd[3] = (uint8_t)(cmd_pec );
|
||||
|
||||
driverSWLTC6804WakeIC();
|
||||
driverSWLTC6804Write(cmd,4);
|
||||
}
|
||||
|
||||
void driverSWLTC6804ResetStatusRegisters(void) {
|
||||
uint8_t cmd[4];
|
||||
uint16_t cmd_pec;
|
||||
|
||||
cmd[0] = 0x07;
|
||||
cmd[1] = 0x13;
|
||||
cmd_pec = driverSWLTC6804CalcPEC15(2, cmd);
|
||||
cmd[2] = (uint8_t)(cmd_pec >> 8);
|
||||
cmd[3] = (uint8_t)(cmd_pec );
|
||||
|
||||
driverSWLTC6804WakeIC();
|
||||
driverSWLTC6804Write(cmd,4);
|
||||
}
|
||||
|
||||
void driverSWLTC6804StartCellAndAuxVoltageConversion(uint8_t MD,uint8_t DCP) {
|
||||
uint8_t cmd[4];
|
||||
uint16_t cmd_pec;
|
||||
uint8_t ADCVAX[2]; //!< Cell Voltage conversion command.
|
||||
|
||||
ADCVAX[0] = ((MD & 0x02) >> 1) + 0x04;
|
||||
ADCVAX[1] = ((MD & 0x01) << 7) + 0x6F + (DCP<<4);
|
||||
|
||||
cmd[0] = ADCVAX[0];
|
||||
cmd[1] = ADCVAX[1];
|
||||
cmd_pec = driverSWLTC6804CalcPEC15(2, ADCVAX);
|
||||
cmd[2] = (uint8_t)(cmd_pec >> 8);
|
||||
cmd[3] = (uint8_t)(cmd_pec);
|
||||
|
||||
driverSWLTC6804WakeIC();
|
||||
driverSWLTC6804Write(cmd,4);
|
||||
}
|
||||
|
||||
void driverSWLTC6804StartCellVoltageConversion(uint8_t MD,uint8_t DCP, uint8_t CH) {
|
||||
uint8_t cmd[4];
|
||||
uint16_t cmd_pec;
|
||||
uint8_t ADCV[2]; //!< Cell Voltage conversion command.
|
||||
|
||||
ADCV[0] = ((MD & 0x02) >> 1) + 0x02;
|
||||
ADCV[1] = ((MD & 0x01) << 7) + 0x60 + (DCP<<4) + CH;
|
||||
|
||||
cmd[0] = ADCV[0];
|
||||
cmd[1] = ADCV[1];
|
||||
cmd_pec = driverSWLTC6804CalcPEC15(2, ADCV);
|
||||
cmd[2] = (uint8_t)(cmd_pec >> 8);
|
||||
cmd[3] = (uint8_t)(cmd_pec);
|
||||
|
||||
driverSWLTC6804WakeIC();
|
||||
driverSWLTC6804Write(cmd,4);
|
||||
}
|
||||
|
||||
void driverSWLTC6804StartLoadedCellVoltageConversion(uint8_t MD,uint8_t DCP, uint8_t CH,uint8_t PUP) {
|
||||
uint8_t cmd[4];
|
||||
uint16_t cmd_pec;
|
||||
uint8_t ADOW[2]; //!< Cell Voltage conversion command.
|
||||
|
||||
ADOW[0] = ((MD & 0x02) >> 1) + 0x02;
|
||||
ADOW[1] = ((MD & 0x01) << 7) + 0x28 + (DCP<<4) + CH + (PUP<<6);
|
||||
|
||||
cmd[0] = ADOW[0];
|
||||
cmd[1] = ADOW[1];
|
||||
cmd_pec = driverSWLTC6804CalcPEC15(2, ADOW);
|
||||
cmd[2] = (uint8_t)(cmd_pec >> 8);
|
||||
cmd[3] = (uint8_t)(cmd_pec);
|
||||
|
||||
driverSWLTC6804WakeIC();
|
||||
driverSWLTC6804Write(cmd,4);
|
||||
}
|
||||
|
||||
void driverSWLTC6804StartAuxVoltageConversion(uint8_t MD, uint8_t CHG) {
|
||||
uint8_t cmd[4];
|
||||
uint16_t cmd_pec;
|
||||
uint8_t ADAX[2]; //!< GPIO conversion command.
|
||||
|
||||
ADAX[0] = ((MD & 0x02) >> 1) + 0x04;
|
||||
ADAX[1] = ((MD & 0x01) << 7) + 0x60 + CHG ;
|
||||
|
||||
cmd[0] = ADAX[0];
|
||||
cmd[1] = ADAX[1];
|
||||
cmd_pec = driverSWLTC6804CalcPEC15(2, ADAX);
|
||||
cmd[2] = (uint8_t)(cmd_pec >> 8);
|
||||
cmd[3] = (uint8_t)(cmd_pec);
|
||||
|
||||
driverSWLTC6804WakeIC();
|
||||
driverSWLTC6804Write(cmd,4);
|
||||
}
|
||||
|
||||
|
||||
//bool driverSWLTC6804ReadCellVoltagesArray(float cellVoltagesArray[][driverSWLTC6804MaxNoOfCellPerModule]) {
|
||||
bool driverSWLTC6804ReadCellVoltagesArray(float cellVoltagesArray[][18]) {
|
||||
bool dataValid = true;
|
||||
// uint8_t driverSWLTC6804MaxNoOfCellPerModule1 = 12;
|
||||
//uint8_t i = 0;
|
||||
uint16_t cellVoltageArrayCodes[driverSWLTC6804TotalNumberOfICs][driverSWLTC6804MaxNoOfCellPerModule];
|
||||
|
||||
|
||||
driverSWLTC6804ReadCellVoltageRegisters(CELL_CH_ALL,driverSWLTC6804TotalNumberOfICs,cellVoltageArrayCodes);
|
||||
for(uint8_t modulePointer = 0; modulePointer < driverSWLTC6804TotalNumberOfICs; modulePointer++) {
|
||||
for(uint8_t cellPointer = 0; cellPointer < driverSWLTC6804MaxNoOfCellPerModule; cellPointer++){
|
||||
|
||||
if (cellVoltageArrayCodes[modulePointer][cellPointer]*0.0001f < 10.0f) {
|
||||
cellVoltagesArray[modulePointer][cellPointer] = cellVoltageArrayCodes[modulePointer][cellPointer]*0.0001f;
|
||||
// cellVoltagesArray[modulePointer][cellPointer] = i++;
|
||||
} else {
|
||||
dataValid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// cellVoltagesArray[0][0] = 1;
|
||||
// cellVoltagesArray[0][1] = 2;
|
||||
// cellVoltagesArray[0][2] = 3;
|
||||
// cellVoltagesArray[0][3] = 4;
|
||||
// cellVoltagesArray[0][4] = 5;
|
||||
// cellVoltagesArray[0][5] = 6;
|
||||
// cellVoltagesArray[0][6] = 7;
|
||||
// cellVoltagesArray[0][7] = 8;
|
||||
// cellVoltagesArray[0][8] = 9;
|
||||
// cellVoltagesArray[0][9] = 10;
|
||||
// cellVoltagesArray[0][10] = 11;
|
||||
// cellVoltagesArray[0][11] = 12;
|
||||
//
|
||||
// cellVoltagesArray[1][0] = 13;
|
||||
// cellVoltagesArray[1][1] = 14;
|
||||
// cellVoltagesArray[1][2] = 15;
|
||||
// cellVoltagesArray[1][3] = 16;
|
||||
// cellVoltagesArray[1][4] = 17;
|
||||
// cellVoltagesArray[1][5] = 18;
|
||||
// cellVoltagesArray[1][6] = 13;
|
||||
// cellVoltagesArray[1][7] = 14;
|
||||
// cellVoltagesArray[1][8] = 15;
|
||||
// cellVoltagesArray[1][9] = 16;
|
||||
// cellVoltagesArray[1][10] = 17;
|
||||
// cellVoltagesArray[1][11] = 18;
|
||||
|
||||
// cellVoltagesArray[0][4] = cellVoltagesArray[0][6]; // 5=7
|
||||
// cellVoltagesArray[0][5] = cellVoltagesArray[0][7]; // 6=8
|
||||
// cellVoltagesArray[0][6] = cellVoltagesArray[0][8]; // 7=9
|
||||
// cellVoltagesArray[0][7] = cellVoltagesArray[0][9]; // 8=10
|
||||
// cellVoltagesArray[0][8] = 0;
|
||||
// cellVoltagesArray[0][9] = 0;
|
||||
// cellVoltagesArray[0][10] = 0;
|
||||
// cellVoltagesArray[0][11] = 0;
|
||||
|
||||
|
||||
return dataValid;
|
||||
}
|
||||
|
||||
uint8_t driverSWLTC6804ReadCellVoltageRegisters(uint8_t reg, uint8_t total_ic, uint16_t cell_codes[][driverSWLTC6804MaxNoOfCellPerModule]) {
|
||||
const uint8_t NUM_RX_BYT = 8;
|
||||
const uint8_t BYT_IN_REG = 6;
|
||||
const uint8_t CELL_IN_REG = 3;
|
||||
|
||||
uint8_t *cell_data;
|
||||
int8_t pec_error = 0;
|
||||
uint16_t parsed_cell;
|
||||
uint16_t received_pec;
|
||||
uint16_t data_pec;
|
||||
uint8_t data_counter=0; //data counter
|
||||
cell_data = (uint8_t *) malloc((NUM_RX_BYT*total_ic)*sizeof(uint8_t));
|
||||
|
||||
if (reg == 0) {
|
||||
for(uint8_t cell_reg = 1; cell_reg<((driverSWLTC6804MaxNoOfCellPerModule/3)+1); cell_reg++) { //executes once for each of the LTC6804 cell voltage registers
|
||||
data_counter = 0;
|
||||
driverSWLTC6804ReadCellVoltageGroups(cell_reg, total_ic,cell_data ); //Reads a single Cell voltage register
|
||||
for (uint8_t current_ic = 0 ; current_ic < total_ic; current_ic++) { // executes for every LTC6804 in the daisy chain current_ic is used as the IC counter
|
||||
for(uint8_t current_cell = 0; current_cell<CELL_IN_REG; current_cell++) { // This loop parses the read back data into cell voltages, it loops once for each of the 3 cell voltage codes in the register
|
||||
parsed_cell = cell_data[data_counter] + (cell_data[data_counter + 1] << 8); //Each cell code is received as two bytes and is combined to create the parsed cell voltage code
|
||||
cell_codes[current_ic][current_cell + ((cell_reg - 1) * CELL_IN_REG)] = parsed_cell;
|
||||
data_counter = data_counter + 2; //Because cell voltage codes are two bytes the data counter must increment by two for each parsed cell code
|
||||
}
|
||||
received_pec = (cell_data[data_counter] << 8) + cell_data[data_counter+1]; //The received PEC for the current_ic is transmitted as the 7th and 8th after the 6 cell voltage data bytes
|
||||
data_pec = driverSWLTC6804CalcPEC15(BYT_IN_REG, &cell_data[current_ic * NUM_RX_BYT]);
|
||||
if(received_pec != data_pec) {
|
||||
pec_error = -1; //The pec_error variable is simply set negative if any PEC errors are detected in the serial data
|
||||
}
|
||||
data_counter=data_counter+2; //Because the transmitted PEC code is 2 bytes long the data_counter must be incremented by 2 bytes to point to the next ICs cell voltage data
|
||||
}
|
||||
}
|
||||
}else{
|
||||
driverSWLTC6804ReadCellVoltageGroups(reg, total_ic,cell_data);
|
||||
for (uint8_t current_ic = 0 ; current_ic < total_ic; current_ic++) { // executes for every LTC6804 in the daisy chain current_ic is used as the IC counter
|
||||
for(uint8_t current_cell = 0; current_cell < CELL_IN_REG; current_cell++) { // This loop parses the read back data into cell voltages, it loops once for each of the 3 cell voltage codes in the register
|
||||
parsed_cell = cell_data[data_counter] + (cell_data[data_counter+1]<<8); //Each cell code is received as two bytes and is combined to create the parsed cell voltage code
|
||||
cell_codes[current_ic][current_cell + ((reg - 1) * CELL_IN_REG)] = 0x0000FFFF & parsed_cell;
|
||||
data_counter= data_counter + 2; //Because cell voltage codes are two bytes the data counter must increment by two for each parsed cell code
|
||||
}
|
||||
received_pec = (cell_data[data_counter] << 8 )+ cell_data[data_counter + 1]; //The received PEC for the current_ic is transmitted as the 7th and 8th after the 6 cell voltage data bytes
|
||||
data_pec = driverSWLTC6804CalcPEC15(BYT_IN_REG, &cell_data[current_ic * NUM_RX_BYT]);
|
||||
|
||||
if(received_pec != data_pec) {
|
||||
pec_error = -1; //The pec_error variable is simply set negative if any PEC errors are detected in the serial data
|
||||
}
|
||||
data_counter= data_counter + 2; //Because the transmitted PEC code is 2 bytes long the data_counter must be incremented by 2 bytes to point to the next ICs cell voltage data
|
||||
}
|
||||
}
|
||||
|
||||
free(cell_data);
|
||||
return(pec_error);
|
||||
}
|
||||
|
||||
void driverSWLTC6804ReadCellVoltageGroups(uint8_t reg, uint8_t total_ic, uint8_t *data ) {
|
||||
const uint8_t REG_LEN = 8; //number of bytes in each ICs register + 2 bytes for the PEC
|
||||
uint8_t cmd[4];
|
||||
uint16_t cmd_pec;
|
||||
//static uint8_t clean_flag = 0;
|
||||
// uint8_t unlimbuf[1024];
|
||||
//if(clean_flag==0){
|
||||
// memset(unlimbuf,0,1023);
|
||||
//clean_flag=1;
|
||||
// }
|
||||
|
||||
if (reg == 1) { //1: RDCVA
|
||||
cmd[1] = 0x04;
|
||||
cmd[0] = 0x00;
|
||||
}else if(reg == 2) { //2: RDCVB
|
||||
cmd[1] = 0x06;
|
||||
cmd[0] = 0x00;
|
||||
}else if(reg == 3) { //3: RDCVC
|
||||
cmd[1] = 0x08;
|
||||
cmd[0] = 0x00;
|
||||
}else if(reg == 4) { //4: RDCVD
|
||||
cmd[1] = 0x0A;
|
||||
cmd[0] = 0x00;
|
||||
}else if(reg == 5) { //5: RDCVE - LTC6812 & LTC6813 only
|
||||
cmd[1] = 0x09;
|
||||
cmd[0] = 0x00;
|
||||
}else if(reg == 6) { //6: RDCVF - LTC6813 only
|
||||
cmd[1] = 0x0B;
|
||||
cmd[0] = 0x00;
|
||||
}
|
||||
|
||||
cmd_pec = driverSWLTC6804CalcPEC15(2, cmd);
|
||||
cmd[2] = (uint8_t)(cmd_pec >> 8);
|
||||
cmd[3] = (uint8_t)(cmd_pec);
|
||||
|
||||
driverSWLTC6804WakeIC(); //This will guarantee that the LTC6804 isoSPI port is awake. This command can be removed.
|
||||
driverSWLTC6804WriteRead(cmd,4,data,(REG_LEN*total_ic));
|
||||
// driverSWLTC6804WriteRead(cmd,4,unlimbuf,(REG_LEN*total_ic));
|
||||
}
|
||||
|
||||
bool driverSWLTC6804ReadVoltageFlags(uint32_t *underVoltageFlags, uint32_t *overVoltageFlags, uint32_t lastICMask, uint8_t noOfParallelModules, uint32_t dieTemperature[]) {
|
||||
// Variables
|
||||
uint32_t newVoltageUnder = 0;
|
||||
uint32_t newVoltageOver = 0;
|
||||
driverSWLTC6804StatusStructTypedef driverSWLTC6804StatusStruct[driverSWLTC6804TotalNumberOfICs];
|
||||
|
||||
// Get the data from the modules
|
||||
driverSWLTC6804ReadStatusValues(driverSWLTC6804TotalNumberOfICs,driverSWLTC6804StatusStruct);
|
||||
|
||||
// Combine it
|
||||
for(uint8_t modulePointer = 0; modulePointer < driverSWLTC6804TotalNumberOfICs; modulePointer++) {
|
||||
dieTemperature[modulePointer] = driverSWLTC6804StatusStruct[modulePointer].dieTemperature;
|
||||
//if we have a different number of cells monitored in the last IC, disable error bits with mask
|
||||
if((modulePointer+1) % (driverSWLTC6804TotalNumberOfICs/noOfParallelModules) == 0 && modulePointer != 0){
|
||||
driverSWLTC6804StatusStruct[modulePointer].underVoltage &= lastICMask;
|
||||
driverSWLTC6804StatusStruct[modulePointer].overVoltage &= lastICMask;
|
||||
|
||||
newVoltageUnder |= driverSWLTC6804StatusStruct[modulePointer].underVoltage;
|
||||
newVoltageOver |= driverSWLTC6804StatusStruct[modulePointer].overVoltage;
|
||||
}else{
|
||||
newVoltageUnder |= driverSWLTC6804StatusStruct[modulePointer].underVoltage;
|
||||
newVoltageOver |= driverSWLTC6804StatusStruct[modulePointer].overVoltage;
|
||||
}
|
||||
}
|
||||
|
||||
// Transfer the data to the output
|
||||
*underVoltageFlags = newVoltageUnder;
|
||||
*overVoltageFlags = newVoltageOver;
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8_t driverSWLTC6804ReadStatusValues(uint8_t total_ic, driverSWLTC6804StatusStructTypedef statusArray[]) {
|
||||
const uint8_t NUM_RX_BYT = 8;
|
||||
const uint8_t BYT_IN_REG = 6;
|
||||
|
||||
uint32_t registersCombined;
|
||||
uint32_t registersCombinedTemp;
|
||||
int8_t pec_error = 0;
|
||||
uint16_t received_pec;
|
||||
uint16_t data_pec;
|
||||
uint8_t data_counter = 0; //data counter
|
||||
uint8_t *status_data = (uint8_t *) malloc((NUM_RX_BYT*total_ic)*sizeof(uint8_t));
|
||||
|
||||
driverSWLTC6804ReadStatusGroups(1,total_ic,status_data);
|
||||
data_counter = 0;
|
||||
|
||||
for (uint8_t current_ic = 0 ; current_ic < total_ic; current_ic++) {
|
||||
// Extract DATA
|
||||
statusArray[current_ic].sumOfCells = ((status_data[data_counter+1] << 8) | status_data[data_counter]) * 0.0001f;
|
||||
statusArray[current_ic].dieTemperature = (((status_data[data_counter+3] << 8) | status_data[data_counter+2]) * 0.0001f)/0.0075f - 273.0f;
|
||||
statusArray[current_ic].voltageAnalogSupply = ((status_data[data_counter+5] << 8) | status_data[data_counter+4]) * 0.0001f;
|
||||
data_counter += 6;
|
||||
// Calculate PEC
|
||||
received_pec = (status_data[data_counter] << 8) + status_data[data_counter+1]; //The received PEC for the current_ic is transmitted as the 7th and 8th after the 6 cell voltage data bytes
|
||||
data_counter += 2;
|
||||
data_pec = driverSWLTC6804CalcPEC15(BYT_IN_REG, &status_data[current_ic * NUM_RX_BYT]);
|
||||
if(received_pec != data_pec) {
|
||||
pec_error = -1; //The pec_error variable is simply set negative if any PEC errors are detected in the serial data
|
||||
}
|
||||
}
|
||||
|
||||
driverSWLTC6804ReadStatusGroups(2,total_ic,status_data);
|
||||
data_counter = 0;
|
||||
|
||||
for (uint8_t current_ic = 0 ; current_ic < total_ic; current_ic++) {
|
||||
// Reset vlag registers
|
||||
statusArray[current_ic].underVoltage = 0;
|
||||
statusArray[current_ic].overVoltage = 0;
|
||||
|
||||
// Extract DATA
|
||||
statusArray[current_ic].voltageDigitalSupply = ((status_data[data_counter+1] << 8) | status_data[data_counter]) * 0.0001f;
|
||||
|
||||
registersCombined = (status_data[data_counter+4] << 16) | (status_data[data_counter+3] << 8) | status_data[data_counter+2]; // Combine all registers in one variable
|
||||
registersCombinedTemp = registersCombined & 0x00555555; // Filter out only the undervoltage bits
|
||||
|
||||
for(int bitPointer = 0; bitPointer < driverSWLTC6804ConfigStruct.noOfCells; bitPointer++)
|
||||
statusArray[current_ic].underVoltage |= (registersCombinedTemp & (1 << bitPointer*2)) ? (1 << bitPointer) : 0; // Shift undervoltage bits closer together and store them in *underVoltageFlags
|
||||
|
||||
registersCombinedTemp = registersCombined & 0x00AAAAAA; // Filter out only the overvoltage bits
|
||||
registersCombinedTemp = registersCombinedTemp >> 1; // Move everything one bit to the right
|
||||
|
||||
for(int bitPointer = 0; bitPointer < driverSWLTC6804ConfigStruct.noOfCells; bitPointer++)
|
||||
statusArray[current_ic].overVoltage |= (registersCombinedTemp & (1 << bitPointer*2)) ? (1 << bitPointer) : 0; // And do the same for the overvoltage bits
|
||||
|
||||
statusArray[current_ic].muxFail = 0;
|
||||
data_counter += 6;
|
||||
// Calculate PEC
|
||||
received_pec = (status_data[data_counter] << 8) + status_data[data_counter+1]; //The received PEC for the current_ic is transmitted as the 7th and 8th after the 6 cell voltage data bytes
|
||||
data_counter += 2;
|
||||
data_pec = driverSWLTC6804CalcPEC15(BYT_IN_REG, &status_data[current_ic * NUM_RX_BYT]);
|
||||
if(received_pec != data_pec) {
|
||||
pec_error = -1; //The pec_error variable is simply set negative if any PEC errors are detected in the serial data
|
||||
}
|
||||
}
|
||||
|
||||
// Execute for higher cell count with auxiliary group D OV & UV flags
|
||||
if(driverSWLTC6804MaxNoOfCellPerModule > 12){
|
||||
|
||||
driverSWLTC6804ReadStatusGroups(3,total_ic,status_data);
|
||||
data_counter = 0;
|
||||
|
||||
for (uint8_t current_ic = 0 ; current_ic < total_ic; current_ic++) {
|
||||
|
||||
//Extract DATA for under & over voltage flags STBR4, STBR3, & STBR2
|
||||
registersCombined = (status_data[data_counter+5] << 8) | (status_data[data_counter+4]); // Combine all registers in one variable
|
||||
registersCombinedTemp = registersCombined & 0x00000555; // Filter out only the undervoltage bits
|
||||
|
||||
for(int bitPointer = 0; bitPointer < (driverSWLTC6804ConfigStruct.noOfCells-12); bitPointer++){
|
||||
statusArray[current_ic].underVoltage |= (((registersCombinedTemp & (1 << bitPointer*2)) ? (1 << bitPointer) : 0) << 12) ; // Shift undervoltage bits closer together and store them in *underVoltageFlags + shift 12 bits
|
||||
|
||||
registersCombinedTemp = registersCombined & 0x00000AAA; // Filter out only the overvoltage bits
|
||||
registersCombinedTemp = registersCombinedTemp >> 1; // Move everything one bit to the right
|
||||
|
||||
for(int bitPointer = 0; bitPointer < driverSWLTC6804ConfigStruct.noOfCells-12; bitPointer++)
|
||||
statusArray[current_ic].overVoltage |= (((registersCombinedTemp & (1 << bitPointer*2)) ? (1 << bitPointer) : 0) << 12); // And do the same for the overvoltage bits
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free(status_data);
|
||||
return pec_error;
|
||||
}
|
||||
|
||||
void driverSWLTC6804ReadStatusGroups(uint8_t reg, uint8_t total_ic, uint8_t *data ) {
|
||||
const uint8_t REG_LEN = 8; //number of bytes in each ICs register + 2 bytes for the PEC
|
||||
uint8_t cmd[4];
|
||||
uint16_t cmd_pec;
|
||||
|
||||
if (reg == 1) { //1: RDSTATA
|
||||
cmd[1] = 0x10;
|
||||
cmd[0] = 0x00;
|
||||
}else if(reg == 2) { //2: RDSTATB
|
||||
cmd[1] = 0x12;
|
||||
cmd[0] = 0x00;
|
||||
}else if(reg == 3) { //Read auxiliary group D LTC6812 & LTC6813 only for AVDR4 & AVDR5 OV & UV flags
|
||||
cmd[1] = 0x0F;
|
||||
cmd[0] = 0x00;
|
||||
}
|
||||
|
||||
cmd_pec = driverSWLTC6804CalcPEC15(2, cmd);
|
||||
cmd[2] = (uint8_t)(cmd_pec >> 8);
|
||||
cmd[3] = (uint8_t)(cmd_pec);
|
||||
|
||||
driverSWLTC6804WriteRead(cmd,4,data,(REG_LEN*total_ic));
|
||||
}
|
||||
|
||||
bool driverSWLTC6804ReadAuxVoltagesArray(float auxVoltagesArray[][12],uint32_t ntcNominal,uint32_t ntcSeriesResistance, uint16_t ntcBetaFactor,float ntcNominalTemp) {
|
||||
bool dataValid = true;
|
||||
uint16_t auxVoltageArrayCodes[driverSWLTC6804TotalNumberOfICs][driverSWLTC6804MaxNoOfTempSensorPerModule];
|
||||
|
||||
driverSWLTC6804ReadAuxVoltageRegisters(AUX_CH_ALL,driverSWLTC6804TotalNumberOfICs,auxVoltageArrayCodes);
|
||||
|
||||
for(uint8_t modulePointer = 0; modulePointer < driverSWLTC6804TotalNumberOfICs; modulePointer++) {
|
||||
for(uint8_t auxPointer = 0; auxPointer < driverSWLTC6804MaxNoOfTempSensorPerModule; auxPointer++){
|
||||
if(auxVoltageArrayCodes[modulePointer][auxPointer]*0.0001f < 10.0f)
|
||||
auxVoltagesArray[modulePointer][auxPointer] = driverSWLTC6804ConvertTemperatureExt(auxVoltageArrayCodes[modulePointer][auxPointer], ntcNominal, ntcSeriesResistance, ntcBetaFactor, ntcNominalTemp);
|
||||
else
|
||||
dataValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
return dataValid;
|
||||
}
|
||||
|
||||
int8_t driverSWLTC6804ReadAuxVoltageRegisters(uint8_t reg, uint8_t total_ic, uint16_t aux_codes[][driverSWLTC6804MaxNoOfTempSensorPerModule]) {
|
||||
const uint8_t NUM_RX_BYT = 8;
|
||||
const uint8_t BYT_IN_REG = 6;
|
||||
const uint8_t GPIO_IN_REG = 3;
|
||||
|
||||
uint8_t *data;
|
||||
uint8_t data_counter = 0;
|
||||
int8_t pec_error = 0;
|
||||
uint16_t parsed_aux;
|
||||
uint16_t received_pec;
|
||||
uint16_t data_pec;
|
||||
data = (uint8_t *) malloc((NUM_RX_BYT*total_ic)*sizeof(uint8_t));
|
||||
//1.a
|
||||
if (reg == 0) {
|
||||
for(uint8_t gpio_reg = 1; gpio_reg<((driverSWLTC6804MaxNoOfTempSensorPerModule/3)+1); gpio_reg++) { //executes once for each of the LTC6804 aux voltage registers
|
||||
data_counter = 0;
|
||||
driverSWLTC6804ReadAuxGroups(gpio_reg, total_ic,data); //Reads the raw auxiliary register data into the data[] array
|
||||
for (uint8_t current_ic = 0 ; current_ic < total_ic; current_ic++) { // executes for every LTC6804 in the daisy chain current_ic is used as the IC counter
|
||||
for(uint8_t current_gpio = 0; current_gpio< GPIO_IN_REG; current_gpio++) { // This loop parses the read back data into GPIO voltages, it loops once for each of the 3 gpio voltage codes in the register
|
||||
parsed_aux = data[data_counter] + (data[data_counter+1]<<8); //Each gpio codes is received as two bytes and is combined to create the parsed gpio voltage code
|
||||
aux_codes[current_ic][current_gpio +((gpio_reg-1)*GPIO_IN_REG)] = parsed_aux;
|
||||
data_counter=data_counter+2; //Because gpio voltage codes are two bytes the data counter must increment by two for each parsed gpio voltage code
|
||||
}
|
||||
|
||||
received_pec = (data[data_counter]<<8)+ data[data_counter+1]; //The received PEC for the current_ic is transmitted as the 7th and 8th after the 6 gpio voltage data bytes
|
||||
data_pec = driverSWLTC6804CalcPEC15(BYT_IN_REG, &data[current_ic*NUM_RX_BYT]);
|
||||
if(received_pec != data_pec) {
|
||||
pec_error = -1; //The pec_error variable is simply set negative if any PEC errors are detected in the received serial data
|
||||
}
|
||||
data_counter=data_counter+2; //Because the transmitted PEC code is 2 bytes long the data_counter must be incremented by 2 bytes to point to the next ICs gpio voltage data
|
||||
}
|
||||
}
|
||||
}else{
|
||||
driverSWLTC6804ReadAuxGroups(reg, total_ic, data);
|
||||
for (int current_ic = 0 ; current_ic < total_ic; current_ic++) { // executes for every LTC6804 in the daisy chain current_ic is used as an IC counter
|
||||
|
||||
for(int current_gpio = 0; current_gpio<GPIO_IN_REG; current_gpio++) { // This loop parses the read back data. Loops once for each aux voltage in the register
|
||||
parsed_aux = (data[data_counter] + (data[data_counter+1]<<8)); //Each gpio codes is received as two bytes and is combined to create the parsed gpio voltage code
|
||||
aux_codes[current_ic][current_gpio +((reg-1)*GPIO_IN_REG)] = parsed_aux;
|
||||
data_counter=data_counter+2; //Because gpio voltage codes are two bytes the data counter must increment by two for each parsed gpio voltage code
|
||||
}
|
||||
received_pec = (data[data_counter]<<8) + data[data_counter+1]; //The received PEC for the current_ic is transmitted as the 7th and 8th after the 6 gpio voltage data bytes
|
||||
data_pec = driverSWLTC6804CalcPEC15(BYT_IN_REG, &data[current_ic*NUM_RX_BYT]);
|
||||
|
||||
if(received_pec != data_pec) {
|
||||
pec_error = -1; //The pec_error variable is simply set negative if any PEC errors are detected in the received serial data
|
||||
}
|
||||
|
||||
data_counter=data_counter+2; //Because the transmitted PEC code is 2 bytes long the data_counter must be incremented by 2 bytes to point to the next ICs gpio voltage data
|
||||
}
|
||||
}
|
||||
free(data);
|
||||
return (pec_error);
|
||||
}
|
||||
|
||||
void driverSWLTC6804ReadAuxGroups(uint8_t reg, uint8_t total_ic, uint8_t *data) {
|
||||
const uint8_t REG_LEN = 8; // number of bytes in the register + 2 bytes for the PEC
|
||||
uint8_t cmd[4];
|
||||
uint16_t cmd_pec;
|
||||
|
||||
//1
|
||||
if (reg == 1) { //Read back auxiliary group A
|
||||
cmd[1] = 0x0C;
|
||||
cmd[0] = 0x00;
|
||||
}else if(reg == 2) { //Read back auxiliary group B
|
||||
cmd[1] = 0x0E;
|
||||
cmd[0] = 0x00;
|
||||
}else if(reg == 3) { //Read auxiliary group C LTC6812 & LTC6813 only
|
||||
cmd[1] = 0x0D;
|
||||
cmd[0] = 0x00;
|
||||
}else if(reg == 4) { //Read auxiliary group D LTC6812 & LTC6813 only
|
||||
cmd[1] = 0x0F;
|
||||
cmd[0] = 0x00;
|
||||
}else{ //Read back auxiliary group A
|
||||
cmd[1] = 0x0C;
|
||||
cmd[0] = 0x00;
|
||||
}
|
||||
|
||||
cmd_pec = driverSWLTC6804CalcPEC15(2, cmd);
|
||||
cmd[2] = (uint8_t)(cmd_pec >> 8);
|
||||
cmd[3] = (uint8_t)(cmd_pec);
|
||||
|
||||
driverSWLTC6804WakeIC(); //This will guarantee that the LTC6804 isoSPI port is awake, this command can be removed.
|
||||
driverSWLTC6804WriteRead(cmd,4,data,(REG_LEN*total_ic));
|
||||
}
|
||||
|
||||
__IO double VuV_dbl;
|
||||
|
||||
void driverSWLTC6804WriteConfigRegister(uint8_t totalNumberOfLTCs, uint32_t *balanceEnableMaskArray, bool useArray) {
|
||||
const uint8_t BYTES_IN_REG = 6;
|
||||
const uint8_t CMD_LEN = 4+(8*totalNumberOfLTCs);
|
||||
uint8_t *cmd;
|
||||
uint16_t cfg_pec;
|
||||
uint8_t cmd_index; //command counter
|
||||
uint8_t tx_cfg[totalNumberOfLTCs][6];
|
||||
|
||||
|
||||
//VuV_buf = driverSWLTC6804ConfigStruct.CellUnderVoltageLimit;
|
||||
//VuV_buf = 2.29999995 * 625;
|
||||
//VuV_buf = ggg * VuV_buf_del;
|
||||
//driverSWLTC6804ConfigStruct.CellUnderVoltageLimit
|
||||
|
||||
VuV_dbl = driverSWLTC6804ConfigStruct.CellUnderVoltageLimit/(16*0.0001);
|
||||
//uint16_t VuV = driverSWLTC6804ConfigStruct.CellUnderVoltageLimit/(16*0.0001);
|
||||
uint16_t VuV = VuV_dbl;
|
||||
//VuV = 2;
|
||||
uint16_t VoV = driverSWLTC6804ConfigStruct.CellOverVoltageLimit/(16*0.0001);
|
||||
//uint16_t VoV = 4.19 * 625;
|
||||
uint32_t activeBalanceMask=0;
|
||||
|
||||
for(int i = 0; i<totalNumberOfLTCs;i++) {
|
||||
if(useArray)
|
||||
activeBalanceMask = balanceEnableMaskArray[i];
|
||||
else
|
||||
activeBalanceMask = driverSWLTC6804ConfigStruct.DisChargeEnableMask;
|
||||
|
||||
tx_cfg[i][0] = (driverSWLTC6804ConfigStruct.GPIO5 << 7) | (driverSWLTC6804ConfigStruct.GPIO4 << 6) | (driverSWLTC6804ConfigStruct.GPIO3 << 5) | (driverSWLTC6804ConfigStruct.GPIO2 << 4) | (driverSWLTC6804ConfigStruct.GPIO1 << 3) | (driverSWLTC6804ConfigStruct.ReferenceON << 2) | (driverSWLTC6804ConfigStruct.ADCOption);
|
||||
tx_cfg[i][1] = (VuV & 0xFF) ;
|
||||
tx_cfg[i][2] = ((VoV & 0x0F) << 4) | (VuV >> 8) ;
|
||||
tx_cfg[i][3] = (VoV >> 4) ;
|
||||
tx_cfg[i][4] = (activeBalanceMask & 0xFF) ;
|
||||
tx_cfg[i][5] = ((driverSWLTC6804ConfigStruct.DischargeTimout & 0x0F) << 4) | (activeBalanceMask >> 8) ;
|
||||
}
|
||||
|
||||
cmd = (uint8_t *)malloc(CMD_LEN*sizeof(uint8_t));
|
||||
cmd[0] = 0x00; // config register command
|
||||
cmd[1] = 0x01; // config register command
|
||||
cmd[2] = 0x3d; // PEC
|
||||
cmd[3] = 0x6e; // PEC
|
||||
cmd_index = 4;
|
||||
|
||||
for (uint8_t current_ic = totalNumberOfLTCs; current_ic > 0; current_ic--) { // executes for each LTC6804 in daisy chain, this loops starts with the last IC on the stack. The first configuration written is received by the last IC in the daisy chain
|
||||
for (uint8_t current_byte = 0; current_byte < BYTES_IN_REG; current_byte++) { // executes for each of the 6 bytes in the CFGR register current_byte is the byte counter
|
||||
cmd[cmd_index] = tx_cfg[current_ic-1][current_byte]; //adding the config data to the array to be sent
|
||||
cmd_index = cmd_index + 1;
|
||||
}
|
||||
cfg_pec = (uint16_t)driverSWLTC6804CalcPEC15(BYTES_IN_REG, &tx_cfg[current_ic-1][0]); // calculating the PEC for each ICs configuration register data
|
||||
cmd[cmd_index] = (uint8_t)(cfg_pec >> 8);
|
||||
cmd[cmd_index + 1] = (uint8_t)cfg_pec;
|
||||
cmd_index = cmd_index + 2;
|
||||
}
|
||||
|
||||
driverSWLTC6804WakeIC();
|
||||
driverSWLTC6804Write(cmd,CMD_LEN);
|
||||
free(cmd);
|
||||
}
|
||||
|
||||
void driverSWLTC6804WriteConfigRegisterB(uint8_t totalNumberOfLTCs, uint32_t *balanceEnableMaskArray, bool useArray) {
|
||||
const uint8_t BYTES_IN_REG = 6;
|
||||
const uint8_t CMD_LEN = 4+(8*totalNumberOfLTCs);
|
||||
uint8_t *cmd;
|
||||
uint16_t cfg_pec;
|
||||
uint8_t cmd_index; //command counter
|
||||
uint8_t tx_cfg[totalNumberOfLTCs][6];
|
||||
uint32_t activeBalanceMask=0;
|
||||
uint16_t cmd_pec;
|
||||
|
||||
for(int i = 0; i<totalNumberOfLTCs;i++) {
|
||||
if(useArray)
|
||||
activeBalanceMask = balanceEnableMaskArray[i];
|
||||
else
|
||||
activeBalanceMask = driverSWLTC6804ConfigStruct.DisChargeEnableMask;
|
||||
|
||||
|
||||
tx_cfg[i][0] = ((activeBalanceMask >> 8 ) & 0x000000F0) | (driverSWLTC6804ConfigStruct.GPIO9 << 3) | (driverSWLTC6804ConfigStruct.GPIO8 << 2) | (driverSWLTC6804ConfigStruct.GPIO7 << 1) | (driverSWLTC6804ConfigStruct.GPIO6) ;
|
||||
tx_cfg[i][1] = ((activeBalanceMask >> 16 ) & 0x00000003) ;
|
||||
tx_cfg[i][2] = 0;
|
||||
tx_cfg[i][3] = 0;
|
||||
tx_cfg[i][4] = 0;
|
||||
tx_cfg[i][5] = 0;
|
||||
}
|
||||
|
||||
cmd = (uint8_t *)malloc(CMD_LEN*sizeof(uint8_t));
|
||||
cmd[0] = 0x00; // config register B command
|
||||
cmd[1] = 0x24; // config register B command
|
||||
cmd_pec = driverSWLTC6804CalcPEC15(2, cmd);
|
||||
cmd[2] = (uint8_t)(cmd_pec >> 8);
|
||||
cmd[3] = (uint8_t)(cmd_pec);
|
||||
cmd_index = 4;
|
||||
|
||||
for (uint8_t current_ic = totalNumberOfLTCs; current_ic > 0; current_ic--) { // executes for each LTC6804 in daisy chain, this loops starts with the last IC on the stack. The first configuration written is received by the last IC in the daisy chain
|
||||
for (uint8_t current_byte = 0; current_byte < BYTES_IN_REG; current_byte++) { // executes for each of the 6 bytes in the CFGR register current_byte is the byte counter
|
||||
cmd[cmd_index] = tx_cfg[current_ic-1][current_byte]; //adding the config data to the array to be sent
|
||||
cmd_index = cmd_index + 1;
|
||||
}
|
||||
cfg_pec = (uint16_t)driverSWLTC6804CalcPEC15(BYTES_IN_REG, &tx_cfg[current_ic-1][0]); // calculating the PEC for each ICs configuration register data
|
||||
cmd[cmd_index] = (uint8_t)(cfg_pec >> 8);
|
||||
cmd[cmd_index + 1] = (uint8_t)cfg_pec;
|
||||
cmd_index = cmd_index + 2;
|
||||
}
|
||||
|
||||
driverSWLTC6804WakeIC();
|
||||
driverSWLTC6804Write(cmd,CMD_LEN);
|
||||
free(cmd);
|
||||
}
|
||||
|
||||
void driverSWLTC6804EnableBalanceResistors(uint32_t enableMask,uint8_t cellMonitorType) {
|
||||
driverSWLTC6804ConfigStruct.DisChargeEnableMask = enableMask;
|
||||
driverSWLTC6804WriteConfigRegister(driverSWLTC6804TotalNumberOfICs,0,false);
|
||||
if(cellMonitorType==CELL_MON_LTC6812_1 || cellMonitorType == CELL_MON_LTC6813_1){
|
||||
driverSWLTC6804WriteConfigRegisterB(driverSWLTC6804TotalNumberOfICs,0,false);
|
||||
}
|
||||
}
|
||||
|
||||
void driverSWLTC6804EnableBalanceResistorsArray(uint32_t *enableMask, uint8_t cellMonitorType) {
|
||||
driverSWLTC6804WriteConfigRegister(driverSWLTC6804TotalNumberOfICs,enableMask,true);
|
||||
if(cellMonitorType==CELL_MON_LTC6812_1 || cellMonitorType == CELL_MON_LTC6813_1){
|
||||
driverSWLTC6804WriteConfigRegisterB(driverSWLTC6804TotalNumberOfICs,enableMask,true);
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t driverSWLTC6804CalcPEC15(uint8_t len, uint8_t *data) {
|
||||
uint16_t remainder,addr;
|
||||
|
||||
remainder = 16;//initialize the PEC
|
||||
for(uint8_t i = 0; i<len;i++) // loops for each byte in data array
|
||||
{
|
||||
addr = ((remainder>>7)^data[i])&0xff;//calculate PEC table address
|
||||
remainder = (remainder<<8)^crc15Table[addr];
|
||||
}
|
||||
return(remainder*2);//The CRC15 has a 0 in the LSB so the remainder must be multiplied by 2
|
||||
}
|
||||
|
||||
int8_t driverSWLTC6804ReadConfigRegister(uint8_t total_ic, uint8_t r_config[][8]) {
|
||||
const uint8_t BYTES_IN_REG = 8;
|
||||
|
||||
uint8_t cmd[4];
|
||||
uint8_t *rx_data;
|
||||
int8_t pec_error = 0;
|
||||
uint16_t data_pec;
|
||||
uint16_t received_pec;
|
||||
|
||||
rx_data = (uint8_t *) malloc((8*total_ic)*sizeof(uint8_t));
|
||||
|
||||
cmd[0] = 0x00;
|
||||
cmd[1] = 0x02;
|
||||
cmd[2] = 0x2b;
|
||||
cmd[3] = 0x0A;
|
||||
|
||||
driverSWLTC6804WriteRead(cmd, 4, rx_data, (BYTES_IN_REG*total_ic));
|
||||
|
||||
for (uint8_t current_ic = 0; current_ic < total_ic; current_ic++) { //executes for each LTC6804 in the daisy chain and packs the data into the r_config array as well as check the received Config data for any bit errors
|
||||
for (uint8_t current_byte = 0; current_byte < BYTES_IN_REG; current_byte++) {
|
||||
r_config[current_ic][current_byte] = rx_data[current_byte + (current_ic*BYTES_IN_REG)];
|
||||
}
|
||||
received_pec = (r_config[current_ic][6]<<8) + r_config[current_ic][7];
|
||||
data_pec = driverSWLTC6804CalcPEC15(6, &r_config[current_ic][0]);
|
||||
if(received_pec != data_pec) {
|
||||
pec_error = -1;
|
||||
}
|
||||
}
|
||||
free(rx_data);
|
||||
return(pec_error);
|
||||
}
|
||||
|
||||
// Coupling of drivers
|
||||
void driverSWLTC6804Write(uint8_t *writeBytes, uint8_t writeLength) {
|
||||
driverHWSPI1Write(writeBytes,writeLength,LTC6804_CS_GPIO_Port,LTC6804_CS_Pin);
|
||||
};
|
||||
|
||||
// Coupling of drivers
|
||||
void driverSWLTC6804WriteRead(uint8_t *writeBytes, uint8_t writeLength, uint8_t *readBytes, uint8_t readLength) {
|
||||
uint8_t buf[100];
|
||||
uint8_t buf_out[100];
|
||||
memset(buf_out,0x00,99);
|
||||
memcpy(buf_out, writeBytes, writeLength);
|
||||
memset(buf,0x00,99);
|
||||
driverHWSPI1WriteRead(writeBytes,writeLength,readBytes,readLength,LTC6804_CS_GPIO_Port,LTC6804_CS_Pin);
|
||||
// driverHWSPI1WriteRead(writeBytes,writeLength,buf,readLength,LTC6804_CS_GPIO_Port,LTC6804_CS_Pin);
|
||||
};
|
||||
|
||||
void driverSWLTC6804WakeIC(void){
|
||||
driverSWLTC6804DelayMS(1);
|
||||
HAL_GPIO_WritePin(LTC6804_CS_GPIO_Port,LTC6804_CS_Pin,GPIO_PIN_RESET);
|
||||
driverSWLTC6804DelayMS(1);
|
||||
HAL_GPIO_WritePin(LTC6804_CS_GPIO_Port,LTC6804_CS_Pin,GPIO_PIN_SET);
|
||||
driverSWLTC6804DelayMS(1);
|
||||
}
|
||||
|
||||
float driverSWLTC6804ConvertTemperatureExt(uint16_t inputValue,uint32_t ntcNominal,uint32_t ntcSeriesResistance,uint16_t ntcBetaFactor, float ntcNominalTemp) {
|
||||
static float scalar;
|
||||
static float steinhart;
|
||||
|
||||
scalar = 30000.0f / (float)inputValue - 1.0f;
|
||||
scalar = (float)ntcSeriesResistance / scalar;
|
||||
steinhart = scalar / (float)ntcNominal; // (R/Ro)
|
||||
steinhart = log(steinhart); // ln(R/Ro)
|
||||
steinhart /= (float)ntcBetaFactor; // 1/B * ln(R/Ro)
|
||||
steinhart += 1.0f / ((float)ntcNominalTemp + 273.15f); // + (1/To)
|
||||
steinhart = 1.0f / steinhart; // Invert
|
||||
steinhart -= 273.15f; // convert to degree
|
||||
|
||||
if(steinhart < -50.0f || (float)inputValue >= 30000.0f)
|
||||
steinhart = 100.0f;
|
||||
|
||||
return steinhart;
|
||||
}
|
||||
93
Core/Src/driverSWStorageManager.c
Normal file
93
Core/Src/driverSWStorageManager.c
Normal file
@@ -0,0 +1,93 @@
|
||||
#include "driverSWStorageManager.h"
|
||||
|
||||
uint16_t *driverHWEEPROMVirtAddVarTab;
|
||||
|
||||
bool driverSWStorageManagerConfigEmpty = false;
|
||||
bool driverSWStorageManagerStateOfChargeEmpty = false;
|
||||
uint16_t driverSWStorageManagerDataSize = 0;
|
||||
uint16_t driverSWStorageManagerConfigStructSize = 0;
|
||||
uint16_t driverSWStorageManagerStateOfChargeStructSize = 0;
|
||||
|
||||
void driverSWStorageManagerInit(void) {
|
||||
driverSWStorageManagerDataSize = driverSWStorageManagerConfigStructSize + driverSWStorageManagerStateOfChargeStructSize;// Calculate the total desired space
|
||||
|
||||
// Generate EEPROM enviroment
|
||||
driverHWEEPROMVirtAddVarTab = malloc(driverSWStorageManagerDataSize*sizeof(uint16_t)); // Make room for the addres array
|
||||
HAL_FLASH_Unlock(); // Unlock FLASH to allow EEPROM lib to write
|
||||
|
||||
if(driverHWEEPROMInit(driverSWStorageManagerDataSize) != HAL_OK) // Init EEPROM and tell EEPROM manager the disered size
|
||||
while(true); // Something went wrong in the init
|
||||
|
||||
for(uint16_t addresPointer=0 ; addresPointer<driverSWStorageManagerDataSize ; addresPointer++)
|
||||
driverHWEEPROMVirtAddVarTab[addresPointer] = addresPointer; // Generate addres array
|
||||
|
||||
// Check EEPROM Contents
|
||||
uint16_t readVariable; // Define variable to write EEPROM contents to if any
|
||||
if(driverHWEEPROMReadVariable(driverHWEEPROMVirtAddVarTab[0], &readVariable) == 1) { // Try to read from first memory location
|
||||
driverSWStorageManagerConfigEmpty = true;
|
||||
driverSWStorageManagerStateOfChargeEmpty = true;
|
||||
}
|
||||
};
|
||||
|
||||
bool driverSWStorageManagerEraseData(void) {
|
||||
return (driverHWEEPROMEraseFlash() == HAL_OK);
|
||||
}
|
||||
|
||||
bool driverSWStorageManagerStoreStruct(void *configStruct, StorageLocationTypedef storageLocation) {
|
||||
uint8_t returnStatus = 0;
|
||||
uint16_t *dataPointer = (uint16_t*)configStruct; // Trick to convert struct to a 16 bit pointer.
|
||||
uint16_t dataOffset = driverSWStorageManagerGetOffsetFromLocation(storageLocation); // Get addres offset
|
||||
uint16_t dataSize = driverSWStorageManagerGetStructSize(storageLocation); // Get data size
|
||||
|
||||
for(uint16_t addresPointer=0 ; addresPointer<dataSize ; addresPointer++) { // Scan trough all adresses
|
||||
returnStatus |= driverHWEEPROMWriteVariable(driverHWEEPROMVirtAddVarTab[addresPointer+dataOffset],dataPointer[addresPointer]);// Store data in EEPROM
|
||||
}
|
||||
|
||||
return (returnStatus == HAL_OK);
|
||||
};
|
||||
|
||||
bool driverSWStorageManagerGetStruct(void *configStruct, StorageLocationTypedef storageLocation) {
|
||||
uint8_t returnStatus = 0;
|
||||
uint16_t *dataPointer = (uint16_t*)configStruct; // Trick to convert struct to a 16 bit pointer.
|
||||
uint16_t dataOffset = driverSWStorageManagerGetOffsetFromLocation(storageLocation); // Get addres offset
|
||||
uint16_t dataSize = driverSWStorageManagerGetStructSize(storageLocation); // Get data size
|
||||
|
||||
for(uint16_t addresPointer=0 ; addresPointer<dataSize ; addresPointer++) // Scan trough all adresses
|
||||
returnStatus |= driverHWEEPROMReadVariable(driverHWEEPROMVirtAddVarTab[addresPointer+dataOffset],&dataPointer[addresPointer]);// Get data from EEPROM
|
||||
|
||||
return (returnStatus == HAL_OK);
|
||||
};
|
||||
|
||||
uint16_t driverSWStorageManagerGetOffsetFromLocation(StorageLocationTypedef storageLocation) {
|
||||
int16_t locationPointer = -1;
|
||||
switch(storageLocation) {
|
||||
case STORAGE_CONFIG:
|
||||
locationPointer = 0; // StorageStruct starts at addres 0
|
||||
break;
|
||||
case STORAGE_STATEOFCHARGE:
|
||||
locationPointer = driverSWStorageManagerConfigStructSize; // StateOfCharge starts after configStruct
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
};
|
||||
|
||||
return locationPointer;
|
||||
};
|
||||
|
||||
uint16_t driverSWStorageManagerGetStructSize(StorageLocationTypedef storageLocation) {
|
||||
int16_t sizeIndicator = -1;
|
||||
switch(storageLocation) {
|
||||
case STORAGE_CONFIG:
|
||||
sizeIndicator = driverSWStorageManagerConfigStructSize; // Config struct size
|
||||
break;
|
||||
case STORAGE_STATEOFCHARGE:
|
||||
sizeIndicator = driverSWStorageManagerStateOfChargeStructSize; // StateOfCharge struct size
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
};
|
||||
|
||||
return sizeIndicator;
|
||||
};
|
||||
|
||||
|
||||
34
Core/Src/driverSWUART2.c
Normal file
34
Core/Src/driverSWUART2.c
Normal file
@@ -0,0 +1,34 @@
|
||||
#include "driverSWUART2.h"
|
||||
|
||||
libRingBufferTypedef *driverSWUART2OutputBuffer;
|
||||
|
||||
void driverSWUART2Init(uint32_t baudRate) {
|
||||
driverSWUART2OutputBuffer = libRingBufferNew(sizeof(uint8_t),RINGBUFFERSIZE); // Make new output buffer
|
||||
|
||||
if(!driverSWUART2OutputBuffer) // Check if buffer pointer is generated
|
||||
while(true); // Out of memory error
|
||||
|
||||
driverHWUART2Init(baudRate); // Initialize serial port and pass function that should be called when a byte is received
|
||||
};
|
||||
|
||||
char driverSWUART2PutCharInOutputBuffer(char character, FILE *stream) {
|
||||
// TODO: If buffer is full, first send a character out, then place new char. This should however never happen
|
||||
if(!driverSWUART2OutputBuffer->isFull(driverSWUART2OutputBuffer)) {
|
||||
driverSWUART2OutputBuffer->add(driverSWUART2OutputBuffer,&character);
|
||||
}else{
|
||||
driverSWUART2Task();
|
||||
driverSWUART2OutputBuffer->add(driverSWUART2OutputBuffer,&character);
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
bool driverSWUART2Task(void) {
|
||||
char outputChar;
|
||||
|
||||
if(!driverSWUART2OutputBuffer->isEmpty(driverSWUART2OutputBuffer)){ // Check if there is data in the ouput buffer
|
||||
driverSWUART2OutputBuffer->pull(driverSWUART2OutputBuffer,&outputChar); // Pull the data from ouput buffer
|
||||
driverHWUART2SendChar(outputChar); // And send it to the uart
|
||||
}
|
||||
|
||||
return !driverSWUART2OutputBuffer->isEmpty(driverSWUART2OutputBuffer);
|
||||
};
|
||||
66
Core/Src/fatfs.c
Normal file
66
Core/Src/fatfs.c
Normal file
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file fatfs.c
|
||||
* @brief Code for fatfs applications
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "fatfs.h"
|
||||
|
||||
uint8_t retUSER; /* Return value for USER */
|
||||
char USERPath[4]; /* USER logical drive path */
|
||||
FATFS USERFatFS; /* File system object for USER logical drive */
|
||||
FIL USERFile; /* File object for USER */
|
||||
|
||||
/* USER CODE BEGIN Variables */
|
||||
|
||||
/* USER CODE END Variables */
|
||||
|
||||
void MX_FATFS_Init(void)
|
||||
{
|
||||
/*## FatFS: Link the USER driver ###########################*/
|
||||
retUSER = FATFS_LinkDriver(&USER_Driver, USERPath);
|
||||
|
||||
/* USER CODE BEGIN Init */
|
||||
/* additional user code for init */
|
||||
/* USER CODE END Init */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets Time from RTC
|
||||
* @param None
|
||||
* @retval Time in DWORD
|
||||
*/
|
||||
DWORD get_fattime(void)
|
||||
{
|
||||
/* USER CODE BEGIN get_fattime */
|
||||
return 0;
|
||||
/* USER CODE END get_fattime */
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN Application */
|
||||
|
||||
void MX_FATFS_DeInit(void)
|
||||
{
|
||||
/*## FatFS: Link the USER driver ###########################*/
|
||||
retUSER = FATFS_UnLinkDriver(USERPath);
|
||||
|
||||
/* USER CODE BEGIN Init */
|
||||
/* additional user code for init */
|
||||
/* USER CODE END Init */
|
||||
}
|
||||
|
||||
/* USER CODE END Application */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
231
Core/Src/libBuffer.c
Normal file
231
Core/Src/libBuffer.c
Normal file
@@ -0,0 +1,231 @@
|
||||
/*
|
||||
Copyright 2016 Benjamin Vedder benjamin@vedder.se
|
||||
|
||||
This file is part of the VESC firmware.
|
||||
|
||||
The VESC firmware is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The VESC firmware is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "libBuffer.h"
|
||||
#include <math.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
void libBufferAppend_int8(uint8_t* buffer, int8_t number, int32_t *index) {
|
||||
buffer[(*index)++] = number;
|
||||
}
|
||||
|
||||
void libBufferAppend_uint8(uint8_t* buffer, uint8_t number, int32_t *index) {
|
||||
buffer[(*index)++] = number;
|
||||
}
|
||||
|
||||
void libBufferAppend_int16(uint8_t* buffer, int16_t number, int32_t *index) {
|
||||
buffer[(*index)++] = number >> 8;
|
||||
buffer[(*index)++] = number;
|
||||
}
|
||||
|
||||
void libBufferAppend_uint16(uint8_t* buffer, uint16_t number, int32_t *index) {
|
||||
buffer[(*index)++] = number >> 8;
|
||||
buffer[(*index)++] = number;
|
||||
}
|
||||
|
||||
void libBufferAppend_int32(uint8_t* buffer, int32_t number, int32_t *index) {
|
||||
buffer[(*index)++] = number >> 24;
|
||||
buffer[(*index)++] = number >> 16;
|
||||
buffer[(*index)++] = number >> 8;
|
||||
buffer[(*index)++] = number;
|
||||
}
|
||||
|
||||
void libBufferAppend_uint32(uint8_t* buffer, uint32_t number, int32_t *index) {
|
||||
buffer[(*index)++] = number >> 24;
|
||||
buffer[(*index)++] = number >> 16;
|
||||
buffer[(*index)++] = number >> 8;
|
||||
buffer[(*index)++] = number;
|
||||
}
|
||||
|
||||
void libBufferAppend_uint64(uint8_t* buffer, uint64_t number, int32_t *index) {
|
||||
buffer[(*index)++] = number >> 56;
|
||||
buffer[(*index)++] = number >> 48;
|
||||
buffer[(*index)++] = number >> 40;
|
||||
buffer[(*index)++] = number >> 32;
|
||||
buffer[(*index)++] = number >> 24;
|
||||
buffer[(*index)++] = number >> 16;
|
||||
buffer[(*index)++] = number >> 8;
|
||||
buffer[(*index)++] = number;
|
||||
}
|
||||
|
||||
void libBufferAppend_int16_LSBFirst(uint8_t* buffer, int16_t number, int32_t *index) {
|
||||
buffer[(*index)++] = number;
|
||||
buffer[(*index)++] = number >> 8;
|
||||
}
|
||||
|
||||
void libBufferAppend_uint16_LSBFirst(uint8_t* buffer, uint16_t number, int32_t *index) {
|
||||
buffer[(*index)++] = number;
|
||||
buffer[(*index)++] = number >> 8;
|
||||
}
|
||||
|
||||
void libBufferAppend_int32_LSBFirst(uint8_t* buffer, int32_t number, int32_t *index) {
|
||||
buffer[(*index)++] = number;
|
||||
buffer[(*index)++] = number >> 8;
|
||||
buffer[(*index)++] = number >> 16;
|
||||
buffer[(*index)++] = number >> 24;
|
||||
}
|
||||
|
||||
void libBufferAppend_uint32_LSBFirst(uint8_t* buffer, uint32_t number, int32_t *index) {
|
||||
buffer[(*index)++] = number;
|
||||
buffer[(*index)++] = number >> 8;
|
||||
buffer[(*index)++] = number >> 16;
|
||||
buffer[(*index)++] = number >> 24;
|
||||
}
|
||||
|
||||
void libBufferAppend_float16(uint8_t* buffer, float number, float scale, int32_t *index) {
|
||||
libBufferAppend_int16(buffer, (int16_t)(number * scale), index);
|
||||
}
|
||||
|
||||
void libBufferAppend_float32(uint8_t* buffer, float number, float scale, int32_t *index) {
|
||||
libBufferAppend_int32(buffer, (int32_t)(number * scale), index);
|
||||
}
|
||||
|
||||
/*
|
||||
* See my question:
|
||||
* http://stackoverflow.com/questions/40416682/portable-way-to-serialize-float-as-32-bit-integer
|
||||
*
|
||||
* Regarding the float32_auto functions:
|
||||
*
|
||||
* Noticed that frexp and ldexp fit the format of the IEEE float representation, so
|
||||
* they should be quite fast. They are (more or less) equivalent with the following:
|
||||
*
|
||||
* float frexp_slow(float f, int *e) {
|
||||
* if (f == 0.0) {
|
||||
* *e = 0;
|
||||
* return 0.0;
|
||||
* }
|
||||
*
|
||||
* *e = ceilf(log2f(fabsf(f)));
|
||||
* float res = f / powf(2.0, (float)*e);
|
||||
*
|
||||
* if (res >= 1.0) {
|
||||
* res -= 0.5;
|
||||
* *e += 1;
|
||||
* }
|
||||
*
|
||||
* if (res <= -1.0) {
|
||||
* res += 0.5;
|
||||
* *e += 1;
|
||||
* }
|
||||
*
|
||||
* return res;
|
||||
* }
|
||||
*
|
||||
* float ldexp_slow(float f, int e) {
|
||||
* return f * powf(2.0, (float)e);
|
||||
* }
|
||||
*
|
||||
* 8388608.0 is 2^23, which scales the result to fit within 23 bits if sig_abs < 1.0.
|
||||
*
|
||||
* This should be a relatively fast and efficient way to serialize
|
||||
* floating point numbers in a fully defined manner.
|
||||
*/
|
||||
void libBufferAppend_float32_auto(uint8_t* buffer, float number, int32_t *index) {
|
||||
int e = 0;
|
||||
float sig = frexpf(number, &e);
|
||||
float sig_abs = fabsf(sig);
|
||||
uint32_t sig_i = 0;
|
||||
|
||||
if (sig_abs >= 0.5f) {
|
||||
sig_i = (uint32_t)((sig_abs - 0.5f) * 2.0f * 8388608.0f);
|
||||
e += 126;
|
||||
}
|
||||
|
||||
uint32_t res = ((e & 0xFF) << 23) | (sig_i & 0x7FFFFF);
|
||||
if (sig < 0) {
|
||||
//res |= 1 << 31;
|
||||
res |= 0x80000000;
|
||||
}
|
||||
|
||||
libBufferAppend_uint32(buffer, res, index);
|
||||
}
|
||||
|
||||
int8_t libBufferGet_int8(const uint8_t *buffer, int32_t *index) {
|
||||
int8_t res = ((uint8_t) buffer[*index]);
|
||||
*index += 1;
|
||||
return res;
|
||||
}
|
||||
|
||||
uint8_t libBufferGet_uint8(const uint8_t *buffer, int32_t *index) {
|
||||
uint8_t res = ((uint8_t) buffer[*index]);
|
||||
*index += 1;
|
||||
return res;
|
||||
}
|
||||
|
||||
int16_t libBufferGet_int16(const uint8_t *buffer, int32_t *index) {
|
||||
int16_t res = ((uint16_t) buffer[*index]) << 8 |
|
||||
((uint16_t) buffer[*index + 1]);
|
||||
*index += 2;
|
||||
return res;
|
||||
}
|
||||
|
||||
uint16_t libBufferGet_uint16(const uint8_t *buffer, int32_t *index) {
|
||||
uint16_t res = ((uint16_t) buffer[*index]) << 8 |
|
||||
((uint16_t) buffer[*index + 1]);
|
||||
*index += 2;
|
||||
return res;
|
||||
}
|
||||
|
||||
int32_t libBufferGet_int32(const uint8_t *buffer, int32_t *index) {
|
||||
int32_t res = ((uint32_t) buffer[*index]) << 24 |
|
||||
((uint32_t) buffer[*index + 1]) << 16 |
|
||||
((uint32_t) buffer[*index + 2]) << 8 |
|
||||
((uint32_t) buffer[*index + 3]);
|
||||
*index += 4;
|
||||
return res;
|
||||
}
|
||||
|
||||
uint32_t libBufferGet_uint32(const uint8_t *buffer, int32_t *index) {
|
||||
uint32_t res = ((uint32_t) buffer[*index]) << 24 |
|
||||
((uint32_t) buffer[*index + 1]) << 16 |
|
||||
((uint32_t) buffer[*index + 2]) << 8 |
|
||||
((uint32_t) buffer[*index + 3]);
|
||||
*index += 4;
|
||||
return res;
|
||||
}
|
||||
|
||||
float libBufferGet_float16(const uint8_t *buffer, float scale, int32_t *index) {
|
||||
return (float)libBufferGet_int16(buffer, index) / scale;
|
||||
}
|
||||
|
||||
float libBufferGet_float32(const uint8_t *buffer, float scale, int32_t *index) {
|
||||
return (float)libBufferGet_int32(buffer, index) / scale;
|
||||
}
|
||||
|
||||
float libBufferGet_float32_auto(const uint8_t *buffer, int32_t *index) {
|
||||
uint32_t res = libBufferGet_uint32(buffer, index);
|
||||
|
||||
int e = (res >> 23) & 0xFF;
|
||||
uint32_t sig_i = res & 0x7FFFFF;
|
||||
//bool neg = res & (1 << 31);
|
||||
bool neg = res & (0x80000000);
|
||||
|
||||
|
||||
float sig = 0.0;
|
||||
if (e != 0 || sig_i != 0) {
|
||||
sig = (float)sig_i / (8388608.0 * 2.0) + 0.5;
|
||||
e -= 126;
|
||||
}
|
||||
|
||||
if (neg) {
|
||||
sig = -sig;
|
||||
}
|
||||
|
||||
return ldexpf(sig, e);
|
||||
}
|
||||
60
Core/Src/libCRC.c
Normal file
60
Core/Src/libCRC.c
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
Copyright 2016 Benjamin Vedder benjamin@vedder.se
|
||||
|
||||
This file is part of the VESC firmware.
|
||||
|
||||
The VESC firmware is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The VESC firmware is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "libCRC.h"
|
||||
|
||||
// CRC Table
|
||||
const unsigned short libCRCLookupTable[] = { 0x0000, 0x1021, 0x2042, 0x3063, 0x4084,
|
||||
0x50a5, 0x60c6, 0x70e7, 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad,
|
||||
0xe1ce, 0xf1ef, 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7,
|
||||
0x62d6, 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,
|
||||
0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485, 0xa56a,
|
||||
0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d, 0x3653, 0x2672,
|
||||
0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4, 0xb75b, 0xa77a, 0x9719,
|
||||
0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc, 0x48c4, 0x58e5, 0x6886, 0x78a7,
|
||||
0x0840, 0x1861, 0x2802, 0x3823, 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948,
|
||||
0x9969, 0xa90a, 0xb92b, 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50,
|
||||
0x3a33, 0x2a12, 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b,
|
||||
0xab1a, 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41,
|
||||
0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49, 0x7e97,
|
||||
0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70, 0xff9f, 0xefbe,
|
||||
0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78, 0x9188, 0x81a9, 0xb1ca,
|
||||
0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f, 0x1080, 0x00a1, 0x30c2, 0x20e3,
|
||||
0x5004, 0x4025, 0x7046, 0x6067, 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d,
|
||||
0xd31c, 0xe37f, 0xf35e, 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214,
|
||||
0x6277, 0x7256, 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c,
|
||||
0xc50d, 0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
|
||||
0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c, 0x26d3,
|
||||
0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634, 0xd94c, 0xc96d,
|
||||
0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab, 0x5844, 0x4865, 0x7806,
|
||||
0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3, 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e,
|
||||
0x8bf9, 0x9bd8, 0xabbb, 0xbb9a, 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1,
|
||||
0x1ad0, 0x2ab3, 0x3a92, 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b,
|
||||
0x9de8, 0x8dc9, 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0,
|
||||
0x0cc1, 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,
|
||||
0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0 };
|
||||
|
||||
unsigned short libCRCCalcCRC16(unsigned char *buf, unsigned int len) {
|
||||
unsigned int i;
|
||||
unsigned short cksum = 0;
|
||||
for (i = 0; i < len; i++) {
|
||||
cksum = libCRCLookupTable[(((cksum >> 8) ^ *buf++) & 0xFF)] ^ (cksum << 8);
|
||||
}
|
||||
return cksum;
|
||||
}
|
||||
170
Core/Src/libPacket.c
Normal file
170
Core/Src/libPacket.c
Normal file
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
Copyright 2016 Benjamin Vedder benjamin@vedder.se
|
||||
|
||||
This file is part of the VESC firmware.
|
||||
|
||||
The VESC firmware is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The VESC firmware is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "libPacket.h"
|
||||
#include "libCRC.h"
|
||||
|
||||
typedef struct {
|
||||
volatile unsigned char rx_state;
|
||||
volatile unsigned char rx_timeout;
|
||||
void(*send_func)(unsigned char *data, unsigned int len);
|
||||
void(*process_func)(unsigned char *data, unsigned int len);
|
||||
unsigned int payload_length;
|
||||
unsigned char rx_buffer[PACKET_MAX_PL_LEN];
|
||||
unsigned char tx_buffer[PACKET_MAX_PL_LEN + 6];
|
||||
unsigned int rx_data_ptr;
|
||||
unsigned char crc_low;
|
||||
unsigned char crc_high;
|
||||
} PACKET_STATE_t;
|
||||
|
||||
static PACKET_STATE_t libPacketHandlerStates[PACKET_HANDLERS];
|
||||
|
||||
void libPacketInit(void (*s_func)(unsigned char *data, unsigned int len),
|
||||
void (*p_func)(unsigned char *data, unsigned int len), int handler_num) {
|
||||
libPacketHandlerStates[handler_num].send_func = s_func;
|
||||
libPacketHandlerStates[handler_num].process_func = p_func;
|
||||
}
|
||||
|
||||
void libPacketSendPacket(unsigned char *data, unsigned int len, int handler_num) {
|
||||
if (len > PACKET_MAX_PL_LEN) {
|
||||
return;
|
||||
}
|
||||
|
||||
int b_ind = 0;
|
||||
|
||||
if (len <= 256) {
|
||||
libPacketHandlerStates[handler_num].tx_buffer[b_ind++] = 2;
|
||||
libPacketHandlerStates[handler_num].tx_buffer[b_ind++] = len;
|
||||
} else {
|
||||
libPacketHandlerStates[handler_num].tx_buffer[b_ind++] = 3;
|
||||
libPacketHandlerStates[handler_num].tx_buffer[b_ind++] = len >> 8;
|
||||
libPacketHandlerStates[handler_num].tx_buffer[b_ind++] = len & 0xFF;
|
||||
}
|
||||
|
||||
memcpy(libPacketHandlerStates[handler_num].tx_buffer + b_ind, data, len);
|
||||
b_ind += len;
|
||||
|
||||
unsigned short crc = libCRCCalcCRC16(data, len);
|
||||
libPacketHandlerStates[handler_num].tx_buffer[b_ind++] = (uint8_t)(crc >> 8);
|
||||
libPacketHandlerStates[handler_num].tx_buffer[b_ind++] = (uint8_t)(crc & 0xFF);
|
||||
libPacketHandlerStates[handler_num].tx_buffer[b_ind++] = 3;
|
||||
|
||||
if (libPacketHandlerStates[handler_num].send_func) {
|
||||
libPacketHandlerStates[handler_num].send_func(libPacketHandlerStates[handler_num].tx_buffer, b_ind);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this function every millisecond.
|
||||
*/
|
||||
void libPacketTimerFunc(void) {
|
||||
uint8_t a;
|
||||
for (int i = 0;i < PACKET_HANDLERS;i++) {
|
||||
if (libPacketHandlerStates[i].rx_timeout!=0) {
|
||||
libPacketHandlerStates[i].rx_timeout--;
|
||||
}
|
||||
else {
|
||||
// if(libPacketHandlerStates[i].rx_state==6){
|
||||
// libPacketHandlerStates[i].rx_state = 0;
|
||||
// }
|
||||
// libPacketHandlerStates[i].rx_timeout=0;
|
||||
// a=0;
|
||||
libPacketHandlerStates[i].rx_state = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void libPacketProcessByte(uint8_t rx_data, int handler_num) {
|
||||
switch (libPacketHandlerStates[handler_num].rx_state) {
|
||||
case 0:
|
||||
if (rx_data == 2) {
|
||||
// 1 byte PL len
|
||||
libPacketHandlerStates[handler_num].rx_state += 2;
|
||||
libPacketHandlerStates[handler_num].rx_timeout = PACKET_RX_TIMEOUT;
|
||||
libPacketHandlerStates[handler_num].rx_data_ptr = 0;
|
||||
libPacketHandlerStates[handler_num].payload_length = 0;
|
||||
} else if (rx_data == 3) {
|
||||
// 2 byte PL len
|
||||
libPacketHandlerStates[handler_num].rx_state++;
|
||||
libPacketHandlerStates[handler_num].rx_timeout = PACKET_RX_TIMEOUT;
|
||||
libPacketHandlerStates[handler_num].rx_data_ptr = 0;
|
||||
libPacketHandlerStates[handler_num].payload_length = 0;
|
||||
} else {
|
||||
libPacketHandlerStates[handler_num].rx_state = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
libPacketHandlerStates[handler_num].payload_length = (unsigned int)rx_data << 8;
|
||||
libPacketHandlerStates[handler_num].rx_state++;
|
||||
libPacketHandlerStates[handler_num].rx_timeout = PACKET_RX_TIMEOUT;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
libPacketHandlerStates[handler_num].payload_length |= (unsigned int)rx_data;
|
||||
if (libPacketHandlerStates[handler_num].payload_length > 0 &&
|
||||
libPacketHandlerStates[handler_num].payload_length <= PACKET_MAX_PL_LEN) {
|
||||
libPacketHandlerStates[handler_num].rx_state++;
|
||||
libPacketHandlerStates[handler_num].rx_timeout = PACKET_RX_TIMEOUT;
|
||||
} else {
|
||||
libPacketHandlerStates[handler_num].rx_state = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
libPacketHandlerStates[handler_num].rx_buffer[libPacketHandlerStates[handler_num].rx_data_ptr++] = rx_data;
|
||||
if (libPacketHandlerStates[handler_num].rx_data_ptr == libPacketHandlerStates[handler_num].payload_length) {
|
||||
libPacketHandlerStates[handler_num].rx_state++;
|
||||
}
|
||||
libPacketHandlerStates[handler_num].rx_timeout = PACKET_RX_TIMEOUT;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
libPacketHandlerStates[handler_num].crc_high = rx_data;
|
||||
libPacketHandlerStates[handler_num].rx_state++;
|
||||
libPacketHandlerStates[handler_num].rx_timeout = PACKET_RX_TIMEOUT;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
libPacketHandlerStates[handler_num].crc_low = rx_data;
|
||||
libPacketHandlerStates[handler_num].rx_state++;
|
||||
libPacketHandlerStates[handler_num].rx_timeout = PACKET_RX_TIMEOUT;
|
||||
break;
|
||||
|
||||
case 6:
|
||||
if (rx_data == 3) {
|
||||
if (libCRCCalcCRC16(libPacketHandlerStates[handler_num].rx_buffer, libPacketHandlerStates[handler_num].payload_length)
|
||||
== ((unsigned short)libPacketHandlerStates[handler_num].crc_high << 8
|
||||
| (unsigned short)libPacketHandlerStates[handler_num].crc_low)) {
|
||||
// Packet received!
|
||||
if (libPacketHandlerStates[handler_num].process_func) {
|
||||
libPacketHandlerStates[handler_num].process_func(libPacketHandlerStates[handler_num].rx_buffer,
|
||||
libPacketHandlerStates[handler_num].payload_length);
|
||||
}
|
||||
}
|
||||
}
|
||||
libPacketHandlerStates[handler_num].rx_state = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
libPacketHandlerStates[handler_num].rx_state = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
140
Core/Src/libRingbuffer.c
Normal file
140
Core/Src/libRingbuffer.c
Normal file
@@ -0,0 +1,140 @@
|
||||
#include "libRingbuffer.h"
|
||||
|
||||
libRingBufferTypedef *libRingBufferNew(int size, int len) {
|
||||
libRingBufferTypedef *self = (libRingBufferTypedef *)malloc(sizeof(libRingBufferTypedef));
|
||||
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
||||
memset(self, 0, sizeof(libRingBufferTypedef));
|
||||
|
||||
if (libRingBufferInit(self, size, len) < 0) {
|
||||
free(self);
|
||||
return NULL;
|
||||
}
|
||||
return self;
|
||||
};
|
||||
|
||||
int libRingBufferInit(libRingBufferTypedef *self, int size, int len) {
|
||||
self->buf = (unsigned char *)malloc(size*len);
|
||||
if (!self->buf) return -1;
|
||||
memset(self->buf, 0, size*len);
|
||||
|
||||
self->size = size;
|
||||
self->len = len;
|
||||
self->start = 0;
|
||||
self->end = 0;
|
||||
self->elements = 0;
|
||||
|
||||
self->next_end_index = &libRingBufferNextEndIndex;
|
||||
self->incr_end_index = &libRingBufferIncrEnd;
|
||||
self->incr_start_index = &libRingBufferIncrStart;
|
||||
self->isFull = &libRingBufferIsFull;
|
||||
self->isEmpty = &libRingBufferIsEmpty;
|
||||
self->add = &libRingBufferAdd;
|
||||
self->numElements = &libRingBufferNumElements;
|
||||
self->peek = &libRingBufferPeek;
|
||||
self->pull = &libRingBufferPull;
|
||||
return 0;
|
||||
};
|
||||
|
||||
int libRingBufferDelete(libRingBufferTypedef *self) {
|
||||
free(self->buf);
|
||||
free(self);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/////// PRIVATE METHODS //////////
|
||||
// get next empty index
|
||||
int libRingBufferNextEndIndex(libRingBufferTypedef *self) {
|
||||
//buffer is full
|
||||
if (self->isFull(self)) return -1;
|
||||
//if empty dont incriment
|
||||
return (self->end+(unsigned int)!self->isEmpty(self))%self->len;
|
||||
};
|
||||
|
||||
// incriment index of RingBuf struct, only call if safe to do so
|
||||
int libRingBufferIncrEnd(libRingBufferTypedef *self) {
|
||||
self->end = (self->end+1)%self->len;
|
||||
return self->end;
|
||||
};
|
||||
|
||||
|
||||
// incriment index of RingBuf struct, only call if safe to do so
|
||||
int libRingBufferIncrStart(libRingBufferTypedef *self) {
|
||||
self->start = (self->start+1)%self->len;
|
||||
return self->start;
|
||||
};
|
||||
|
||||
/////// PUBLIC METHODS //////////
|
||||
// Add an object struct to RingBuf
|
||||
int libRingBufferAdd(libRingBufferTypedef *self, const void *object) {
|
||||
int index;
|
||||
// Perform all atomic opertaions
|
||||
index = self->next_end_index(self);
|
||||
//if not full
|
||||
if (index >= 0) {
|
||||
memcpy(self->buf + index*self->size, object, self->size);
|
||||
if (!self->isEmpty(self)) self->incr_end_index(self);
|
||||
self->elements++;
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
// Return pointer to num element, return null on empty or num out of bounds
|
||||
void *libRingBufferPeek(libRingBufferTypedef *self, unsigned int num) {
|
||||
void *ret = NULL;
|
||||
|
||||
//empty or out of bounds
|
||||
if (self->isEmpty(self) || num > self->elements - 1)
|
||||
ret = NULL;
|
||||
else
|
||||
ret = &self->buf[((self->start + num)%self->len)*self->size];
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Returns and removes first buffer element
|
||||
void *libRingBufferPull(libRingBufferTypedef *self, void *object) {
|
||||
void *ret = NULL;
|
||||
|
||||
if (self->isEmpty(self))
|
||||
ret = NULL;
|
||||
else{
|
||||
memcpy(object, self->buf+self->start*self->size, self->size);
|
||||
self->elements--;
|
||||
// don't incriment start if removing last element
|
||||
if (!self->isEmpty(self)) self->incr_start_index(self);
|
||||
ret = object;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Returns number of elemnts in buffer
|
||||
unsigned int libRingBufferNumElements(libRingBufferTypedef *self) {
|
||||
unsigned int elements;
|
||||
|
||||
elements = self->elements;
|
||||
|
||||
return elements;
|
||||
}
|
||||
|
||||
// Returns true if buffer is full
|
||||
bool libRingBufferIsFull(libRingBufferTypedef *self) {
|
||||
bool ret;
|
||||
|
||||
ret = self->elements == self->len;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Returns true if buffer is empty
|
||||
bool libRingBufferIsEmpty(libRingBufferTypedef *self) {
|
||||
bool ret;
|
||||
|
||||
ret = !self->elements;
|
||||
|
||||
return ret;
|
||||
}
|
||||
2646
Core/Src/main.c
Normal file
2646
Core/Src/main.c
Normal file
File diff suppressed because it is too large
Load Diff
535
Core/Src/modCommands.c
Normal file
535
Core/Src/modCommands.c
Normal file
@@ -0,0 +1,535 @@
|
||||
/*
|
||||
Copyright 2017 - 2018 Danny Bokma danny@diebie.nl
|
||||
Copyright 2019 - 2020 Kevin Dionne kevin.dionne@ennoid.me
|
||||
|
||||
This file is part of the DieBieMS/ENNOID-BMS firmware.
|
||||
|
||||
The DieBieMS/ENNOID-BMS firmware is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The DieBieMS/ENNOID-BMS firmware is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "modCommands.h"
|
||||
|
||||
// Private variables
|
||||
static uint8_t modCommandsSendBuffer[PACKET_MAX_PL_LEN];
|
||||
static void(*modCommandsSendFunction)(unsigned char *data, unsigned int len) = 0;
|
||||
bool jumpBootloaderTrue;
|
||||
modConfigGeneralConfigStructTypedef *modCommandsGeneralConfig;
|
||||
modConfigGeneralConfigStructTypedef *modCommandsToBeSendConfig;
|
||||
modConfigGeneralConfigStructTypedef modCommandsConfigStorage;
|
||||
modPowerElectronicsPackStateTypedef *modCommandsGeneralState;
|
||||
|
||||
void modCommandsInit(modPowerElectronicsPackStateTypedef *generalState,modConfigGeneralConfigStructTypedef *configPointer) {
|
||||
modCommandsGeneralConfig = configPointer;
|
||||
modCommandsGeneralState = generalState;
|
||||
jumpBootloaderTrue = false;
|
||||
}
|
||||
|
||||
void modCommandsSetSendFunction(void(*func)(unsigned char *data, unsigned int len)) {
|
||||
modCommandsSendFunction = func;
|
||||
}
|
||||
|
||||
void modCommandsSendPacket(unsigned char *data, unsigned int len) {
|
||||
if (modCommandsSendFunction) {
|
||||
modCommandsSendFunction(data, len);
|
||||
}
|
||||
}
|
||||
|
||||
void modCommandsProcessPacket(unsigned char *data, unsigned int len) {
|
||||
if (!len) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint64_t RawSerial;
|
||||
uint32_t* RawSerialPtr;
|
||||
float RawSerialPtrfl;
|
||||
|
||||
|
||||
COMM_PACKET_ID packet_id;
|
||||
int32_t ind = 0;
|
||||
uint16_t flash_res;
|
||||
uint32_t new_app_offset;
|
||||
uint32_t delayTick;
|
||||
uint8_t cellPointer;
|
||||
uint8_t auxPointer;
|
||||
uint8_t expPointer;
|
||||
uint8_t i;
|
||||
|
||||
packet_id = (COMM_PACKET_ID) data[0];
|
||||
data++;
|
||||
len--;
|
||||
|
||||
|
||||
switch (packet_id) {
|
||||
case COMM_FW_VERSION:
|
||||
ind = 0;
|
||||
modCommandsSendBuffer[ind++] = COMM_FW_VERSION;
|
||||
modCommandsSendBuffer[ind++] = FW_VERSION_MAJOR;
|
||||
modCommandsSendBuffer[ind++] = FW_VERSION_MINOR;
|
||||
strcpy((char*)(modCommandsSendBuffer + ind), HW_NAME);
|
||||
ind += strlen(HW_NAME) + 1;
|
||||
memcpy(modCommandsSendBuffer + ind, STM32_UUID, 12);
|
||||
ind += 12;
|
||||
|
||||
modCommandsSendPacket(modCommandsSendBuffer, ind);
|
||||
break;
|
||||
case COMM_JUMP_TO_BOOTLOADER:
|
||||
jumpBootloaderTrue = true;
|
||||
delayTick = HAL_GetTick();
|
||||
break;
|
||||
case COMM_ERASE_NEW_APP:
|
||||
ind = 0;
|
||||
flash_res = modFlashEraseNewAppData(libBufferGet_uint32(data, &ind));
|
||||
ind = 0;
|
||||
modCommandsSendBuffer[ind++] = COMM_ERASE_NEW_APP;
|
||||
modCommandsSendBuffer[ind++] = flash_res == HAL_OK ? true : false;
|
||||
modCommandsSendPacket(modCommandsSendBuffer, ind);
|
||||
break;
|
||||
case COMM_WRITE_NEW_APP_DATA:
|
||||
ind = 0;
|
||||
new_app_offset = libBufferGet_uint32(data, &ind);
|
||||
flash_res = modFlashWriteNewAppData(new_app_offset, data + ind, len - ind);
|
||||
//flash_res = 0;
|
||||
ind = 0;
|
||||
modCommandsSendBuffer[ind++] = COMM_WRITE_NEW_APP_DATA;
|
||||
modCommandsSendBuffer[ind++] = flash_res == HAL_OK ? 1 : 0;
|
||||
modCommandsSendPacket(modCommandsSendBuffer, ind);
|
||||
break;
|
||||
case COMM_GET_VALUES:
|
||||
ind = 0;
|
||||
modCommandsSendBuffer[ind++] = COMM_GET_VALUES;
|
||||
|
||||
libBufferAppend_float32(modCommandsSendBuffer, modCommandsGeneralState->packVoltage, 1e3, &ind);
|
||||
libBufferAppend_float32(modCommandsSendBuffer, modCommandsGeneralState->packCurrent, 1e3, &ind);
|
||||
|
||||
libBufferAppend_uint8(modCommandsSendBuffer, (uint8_t)round(modCommandsGeneralState->SoC), &ind);
|
||||
|
||||
libBufferAppend_float32(modCommandsSendBuffer, modCommandsGeneralState->cellVoltageHigh, 1e3, &ind);
|
||||
libBufferAppend_float32(modCommandsSendBuffer, modCommandsGeneralState->cellVoltageAverage, 1e3, &ind);
|
||||
libBufferAppend_float32(modCommandsSendBuffer, modCommandsGeneralState->cellVoltageLow, 1e3, &ind);
|
||||
libBufferAppend_float32(modCommandsSendBuffer, modCommandsGeneralState->cellVoltageMisMatch, 1e3, &ind);
|
||||
|
||||
libBufferAppend_float16(modCommandsSendBuffer, modCommandsGeneralState->loCurrentLoadVoltage, 1e1, &ind);
|
||||
libBufferAppend_float16(modCommandsSendBuffer, modCommandsGeneralState->loCurrentLoadCurrent, 1e1, &ind);
|
||||
|
||||
libBufferAppend_float16(modCommandsSendBuffer, modCommandsGeneralState->chargerVoltage, 1e1, &ind);
|
||||
|
||||
libBufferAppend_float16(modCommandsSendBuffer, modCommandsGeneralState->tempBatteryHigh, 1e1, &ind);
|
||||
libBufferAppend_float16(modCommandsSendBuffer, modCommandsGeneralState->tempBatteryAverage, 1e1, &ind);
|
||||
libBufferAppend_float16(modCommandsSendBuffer, modCommandsGeneralState->tempBatteryLow, 1e1, &ind);
|
||||
libBufferAppend_float16(modCommandsSendBuffer, modCommandsGeneralState->tempBMSHigh, 1e1, &ind);
|
||||
libBufferAppend_float16(modCommandsSendBuffer, modCommandsGeneralState->tempBMSAverage, 1e1, &ind);
|
||||
libBufferAppend_float16(modCommandsSendBuffer, modCommandsGeneralState->tempBMSLow, 1e1, &ind);
|
||||
libBufferAppend_float16(modCommandsSendBuffer, modCommandsGeneralState->humidity, 1e1, &ind);
|
||||
|
||||
libBufferAppend_uint8(modCommandsSendBuffer, (uint8_t)modCommandsGeneralState->operationalState, &ind);
|
||||
libBufferAppend_uint8(modCommandsSendBuffer, (uint8_t)modCommandsGeneralState->chargeBalanceActive, &ind); // Indicator for charging
|
||||
|
||||
libBufferAppend_uint8(modCommandsSendBuffer, (uint8_t)modCommandsGeneralState->faultState, &ind);
|
||||
|
||||
modCommandsSendBuffer[ind++] = modCommandsGeneralConfig->CANID;
|
||||
modCommandsSendPacket(modCommandsSendBuffer, ind);
|
||||
|
||||
break;
|
||||
case COMM_GET_BMS_CELLS:
|
||||
ind = 0;
|
||||
modCommandsSendBuffer[ind++] = COMM_GET_BMS_CELLS;
|
||||
|
||||
libBufferAppend_uint8(modCommandsSendBuffer, modCommandsGeneralConfig->noOfCellsSeries*modCommandsGeneralConfig->noOfParallelModules, &ind); // Cell count
|
||||
for(cellPointer = 0; cellPointer < modCommandsGeneralConfig->noOfCellsSeries*modCommandsGeneralConfig->noOfParallelModules; cellPointer++){
|
||||
if(modCommandsGeneralState->cellVoltagesIndividual[cellPointer].cellBleedActive)
|
||||
libBufferAppend_float16(modCommandsSendBuffer, modCommandsGeneralState->cellVoltagesIndividual[cellPointer].cellVoltage*-1.0f, 1e3, &ind); // Individual cells
|
||||
else
|
||||
libBufferAppend_float16(modCommandsSendBuffer, modCommandsGeneralState->cellVoltagesIndividual[cellPointer].cellVoltage, 1e3, &ind); // Individual cells
|
||||
}
|
||||
|
||||
modCommandsSendBuffer[ind++] = modCommandsGeneralConfig->CANID;
|
||||
modCommandsSendPacket(modCommandsSendBuffer, ind);
|
||||
break;
|
||||
case COMM_GET_BMS_AUX:
|
||||
ind = 0;
|
||||
modCommandsSendBuffer[ind++] = COMM_GET_BMS_AUX;
|
||||
|
||||
libBufferAppend_uint8(modCommandsSendBuffer, modCommandsGeneralConfig->cellMonitorICCount*modCommandsGeneralConfig->noOfTempSensorPerModule, &ind); // Total aux count
|
||||
for(auxPointer = 0; auxPointer < modCommandsGeneralConfig->cellMonitorICCount*modCommandsGeneralConfig->noOfTempSensorPerModule; auxPointer++){
|
||||
libBufferAppend_float16(modCommandsSendBuffer, modCommandsGeneralState->auxVoltagesIndividual[auxPointer].auxVoltage, 1e1, &ind); // Individual aux
|
||||
}
|
||||
|
||||
modCommandsSendBuffer[ind++] = modCommandsGeneralConfig->CANID;
|
||||
modCommandsSendPacket(modCommandsSendBuffer, ind);
|
||||
break;
|
||||
case COMM_GET_BMS_EXP_TEMP:
|
||||
ind = 0;
|
||||
modCommandsSendBuffer[ind++] = COMM_GET_BMS_EXP_TEMP;
|
||||
|
||||
libBufferAppend_uint8(modCommandsSendBuffer, modCommandsGeneralConfig->noOfExpansionBoard*modCommandsGeneralConfig->noOfTempSensorPerExpansionBoard, &ind); // Total aux count
|
||||
for(expPointer = 0; expPointer < modCommandsGeneralConfig->noOfExpansionBoard*modCommandsGeneralConfig->noOfTempSensorPerExpansionBoard; expPointer++){
|
||||
libBufferAppend_float16(modCommandsSendBuffer, modCommandsGeneralState->expVoltagesIndividual[expPointer].expVoltage, 1e1, &ind); // Individual aux
|
||||
}
|
||||
|
||||
modCommandsSendBuffer[ind++] = modCommandsGeneralConfig->CANID;
|
||||
modCommandsSendPacket(modCommandsSendBuffer, ind);
|
||||
break;
|
||||
case COMM_SET_MCCONF:
|
||||
ind = 0;
|
||||
modCommandsGeneralConfig->noOfCellsSeries = libBufferGet_uint8(data,&ind); // 1
|
||||
modCommandsGeneralConfig->noOfCellsParallel = libBufferGet_uint8(data,&ind); // 1
|
||||
modCommandsGeneralConfig->noOfParallelModules = libBufferGet_uint8(data,&ind); // 1
|
||||
modCommandsGeneralConfig->batteryCapacity = libBufferGet_float32_auto(data,&ind); // 4
|
||||
modCommandsGeneralConfig->cellHardUnderVoltage = libBufferGet_float32_auto(data,&ind); // 4
|
||||
modCommandsGeneralConfig->cellHardOverVoltage = libBufferGet_float32_auto(data,&ind); // 4
|
||||
modCommandsGeneralConfig->cellLCSoftUnderVoltage = libBufferGet_float32_auto(data,&ind); // 4
|
||||
modCommandsGeneralConfig->cellSoftOverVoltage = libBufferGet_float32_auto(data,&ind); // 4
|
||||
modCommandsGeneralConfig->cellBalanceDifferenceThreshold = libBufferGet_float32_auto(data,&ind); // 4
|
||||
modCommandsGeneralConfig->cellBalanceStart = libBufferGet_float32_auto(data,&ind); // 4
|
||||
modCommandsGeneralConfig->cellBalanceAllTime = libBufferGet_uint8(data,&ind); // 1
|
||||
modCommandsGeneralConfig->cellThrottleUpperStart = libBufferGet_float32_auto(data,&ind); // 4
|
||||
modCommandsGeneralConfig->cellThrottleLowerStart = libBufferGet_float32_auto(data,&ind); // 4
|
||||
modCommandsGeneralConfig->cellThrottleUpperMargin = libBufferGet_float32_auto(data,&ind); // 4
|
||||
modCommandsGeneralConfig->cellThrottleLowerMargin = libBufferGet_float32_auto(data,&ind); // 4
|
||||
modCommandsGeneralConfig->packVoltageDataSource = libBufferGet_uint8(data,&ind); // 1
|
||||
modCommandsGeneralConfig->packCurrentDataSource = libBufferGet_uint8(data,&ind); // 1
|
||||
modCommandsGeneralConfig->buzzerSignalSource = libBufferGet_uint8(data,&ind); // 1
|
||||
modCommandsGeneralConfig->buzzerSignalPersistant = libBufferGet_uint8(data,&ind); // 1
|
||||
modCommandsGeneralConfig->shuntLCFactor = libBufferGet_float32_auto(data,&ind); // 4
|
||||
modCommandsGeneralConfig->voltageLCFactor = libBufferGet_float32_auto(data,&ind); // 4
|
||||
modCommandsGeneralConfig->voltageLCOffset = libBufferGet_int16(data,&ind); // 2
|
||||
modCommandsGeneralConfig->loadVoltageFactor = libBufferGet_float32_auto(data,&ind); // 4
|
||||
modCommandsGeneralConfig->loadVoltageOffset = libBufferGet_float32_auto(data,&ind); // 4
|
||||
modCommandsGeneralConfig->chargerVoltageFactor = libBufferGet_float32_auto(data,&ind); // 4
|
||||
modCommandsGeneralConfig->chargerVoltageOffset = libBufferGet_float32_auto(data,&ind); // 4
|
||||
modCommandsGeneralConfig->throttleChargeIncreaseRate = libBufferGet_uint8(data,&ind); // 1
|
||||
modCommandsGeneralConfig->throttleDisChargeIncreaseRate = libBufferGet_uint8(data,&ind); // 1
|
||||
modCommandsGeneralConfig->cellBalanceUpdateInterval = libBufferGet_uint32(data,&ind); // 4
|
||||
modCommandsGeneralConfig->maxSimultaneousDischargingCells = libBufferGet_uint8(data,&ind); // 1
|
||||
modCommandsGeneralConfig->timeoutDischargeRetry = libBufferGet_uint32(data,&ind); // 4
|
||||
modCommandsGeneralConfig->hysteresisDischarge = libBufferGet_float32_auto(data,&ind); // 4
|
||||
modCommandsGeneralConfig->timeoutChargeRetry = libBufferGet_uint32(data,&ind); // 4
|
||||
modCommandsGeneralConfig->hysteresisCharge = libBufferGet_float32_auto(data,&ind); // 4
|
||||
modCommandsGeneralConfig->timeoutChargeCompleted = libBufferGet_uint32(data,&ind); // 4
|
||||
modCommandsGeneralConfig->timeoutChargingCompletedMinimalMismatch = libBufferGet_uint32(data,&ind); // 4
|
||||
modCommandsGeneralConfig->maxMismatchThreshold = libBufferGet_float32_auto(data,&ind); // 4
|
||||
modCommandsGeneralConfig->chargerEnabledThreshold = libBufferGet_float32_auto(data,&ind); // 4
|
||||
modCommandsGeneralConfig->timeoutChargerDisconnected = libBufferGet_uint32(data,&ind); // 4
|
||||
modCommandsGeneralConfig->minimalPrechargePercentage = libBufferGet_float32_auto(data,&ind); // 4
|
||||
modCommandsGeneralConfig->timeoutLCPreCharge = libBufferGet_uint32(data,&ind); // 4
|
||||
modCommandsGeneralConfig->maxAllowedCurrent = libBufferGet_float32_auto(data,&ind); // 4
|
||||
modCommandsGeneralConfig->allowedTempBattDischargingMax = libBufferGet_float32_auto(data,&ind); // 4
|
||||
modCommandsGeneralConfig->allowedTempBattDischargingMin = libBufferGet_float32_auto(data,&ind); // 4
|
||||
modCommandsGeneralConfig->allowedTempBattChargingMax = libBufferGet_float32_auto(data,&ind); // 4
|
||||
modCommandsGeneralConfig->allowedTempBattChargingMin = libBufferGet_float32_auto(data,&ind); // 4
|
||||
modCommandsGeneralConfig->allowedTempBattCoolingMax = libBufferGet_float32_auto(data,&ind); // 4
|
||||
modCommandsGeneralConfig->allowedTempBattCoolingMin = libBufferGet_float32_auto(data,&ind); // 4
|
||||
modCommandsGeneralConfig->allowedTempBMSMax = libBufferGet_float32_auto(data,&ind); // 4
|
||||
modCommandsGeneralConfig->allowedTempBMSMin = libBufferGet_float32_auto(data,&ind); // 4
|
||||
modCommandsGeneralConfig->displayTimeoutBatteryDead = libBufferGet_uint32(data,&ind); // 4
|
||||
modCommandsGeneralConfig->displayTimeoutBatteryError = libBufferGet_uint32(data,&ind); // 4
|
||||
modCommandsGeneralConfig->displayTimeoutBatteryErrorPreCharge = libBufferGet_uint32(data,&ind); // 4
|
||||
modCommandsGeneralConfig->displayTimeoutSplashScreen = libBufferGet_uint32(data,&ind); // 4
|
||||
modCommandsGeneralConfig->displayStyle = libBufferGet_uint8(data,&ind); // 1
|
||||
modCommandsGeneralConfig->maxUnderAndOverVoltageErrorCount = libBufferGet_uint8(data,&ind); // 1
|
||||
modCommandsGeneralConfig->maxUnderAndOverTemperatureErrorCount = libBufferGet_uint8(data,&ind); // 1
|
||||
modCommandsGeneralConfig->notUsedCurrentThreshold = libBufferGet_float32_auto(data,&ind); // 4
|
||||
modCommandsGeneralConfig->notUsedTimeout = libBufferGet_uint32(data,&ind); // 4
|
||||
modCommandsGeneralConfig->stateOfChargeStoreInterval = libBufferGet_uint32(data,&ind); // 4
|
||||
modCommandsGeneralConfig->stateOfChargeMethod = libBufferGet_uint8(data,&ind); // 1
|
||||
modCommandsGeneralConfig->CANID = libBufferGet_uint8(data,&ind); // 1
|
||||
modCommandsGeneralConfig->CANIDStyle = libBufferGet_uint8(data,&ind); // 1
|
||||
modCommandsGeneralConfig->canBusSpeed = libBufferGet_uint8(data,&ind); // 1
|
||||
modCommandsGeneralConfig->emitStatusOverCAN = libBufferGet_uint8(data,&ind); // 1
|
||||
modCommandsGeneralConfig->emitStatusProtocol = libBufferGet_uint8(data,&ind); // 1
|
||||
modCommandsGeneralConfig->tempEnableMaskBMS = libBufferGet_uint32(data,&ind); // 4
|
||||
modCommandsGeneralConfig->tempEnableMaskBattery = libBufferGet_uint32(data,&ind); // 4
|
||||
modCommandsGeneralConfig->tempEnableMaskExpansion = libBufferGet_uint32(data,&ind); // 4
|
||||
modCommandsGeneralConfig->noOfTempSensorPerModule = libBufferGet_uint8(data,&ind); // 1
|
||||
modCommandsGeneralConfig->noOfExpansionBoard = libBufferGet_uint8(data,&ind); // 1
|
||||
modCommandsGeneralConfig->noOfTempSensorPerExpansionBoard= libBufferGet_uint8(data,&ind); // 1
|
||||
modCommandsGeneralConfig->LCUseDischarge = libBufferGet_uint8(data,&ind); // 1
|
||||
modCommandsGeneralConfig->LCUsePrecharge = libBufferGet_uint8(data,&ind); // 1
|
||||
modCommandsGeneralConfig->allowChargingDuringDischarge = libBufferGet_uint8(data,&ind); // 1
|
||||
modCommandsGeneralConfig->allowForceOn = libBufferGet_uint8(data,&ind); // 1
|
||||
modCommandsGeneralConfig->pulseToggleButton = libBufferGet_uint8(data,&ind); // 1
|
||||
modCommandsGeneralConfig->useCANSafetyInput = libBufferGet_uint8(data,&ind); // 1
|
||||
modCommandsGeneralConfig->useCANDelayedPowerDown = libBufferGet_uint8(data,&ind); // 1
|
||||
modCommandsGeneralConfig->NTCTopResistor[modConfigNTCGroupLTCExt] = libBufferGet_uint32(data,&ind);// 4
|
||||
modCommandsGeneralConfig->NTC25DegResistance[modConfigNTCGroupLTCExt] = libBufferGet_uint32(data,&ind);// 4
|
||||
modCommandsGeneralConfig->NTCBetaFactor[modConfigNTCGroupLTCExt] = libBufferGet_uint16(data,&ind);// 2
|
||||
modCommandsGeneralConfig->NTCTopResistor[modConfigNTCGroupMasterPCB] = libBufferGet_uint32(data,&ind);// 4
|
||||
modCommandsGeneralConfig->NTC25DegResistance[modConfigNTCGroupMasterPCB] = libBufferGet_uint32(data,&ind);// 4
|
||||
modCommandsGeneralConfig->NTCBetaFactor[modConfigNTCGroupMasterPCB] = libBufferGet_uint16(data,&ind);// 2
|
||||
modCommandsGeneralConfig->NTCTopResistor[modConfigNTCGroupExp] = libBufferGet_uint32(data,&ind);// 4
|
||||
modCommandsGeneralConfig->NTC25DegResistance[modConfigNTCGroupExp] = libBufferGet_uint32(data,&ind);// 4
|
||||
modCommandsGeneralConfig->NTCBetaFactor[modConfigNTCGroupExp] = libBufferGet_uint16(data,&ind);// 2
|
||||
modCommandsGeneralConfig->cellMonitorType = libBufferGet_uint8(data,&ind); // 1
|
||||
modCommandsGeneralConfig->cellMonitorICCount = libBufferGet_uint8(data,&ind); // 1
|
||||
modCommandsGeneralConfig->externalEnableOperationalState = libBufferGet_uint8(data,&ind); // 1
|
||||
modCommandsGeneralConfig->chargeEnableOperationalState = libBufferGet_uint8(data,&ind); // 1
|
||||
modCommandsGeneralConfig->powerDownDelay = libBufferGet_uint32(data,&ind);// 4
|
||||
modCommandsGeneralConfig->humidityICType = libBufferGet_uint8(data,&ind); // 1
|
||||
|
||||
// RawSerialPtr = modCommandsGeneralConfig->displayTimeoutBatteryDead;
|
||||
// RawSerial = *RawSerialPtr;
|
||||
// RawSerial = RawSerial<<32;
|
||||
// RawSerialPtr = modCommandsGeneralConfig->displayTimeoutBatteryError;
|
||||
// RawSerial+=*RawSerialPtr;
|
||||
|
||||
RawSerialPtrfl = modCommandsGeneralConfig->notUsedCurrentThreshold;
|
||||
RawSerial = ceil(RawSerialPtrfl);
|
||||
modCommandsGeneralConfig->serialNumber = RawSerial;
|
||||
|
||||
ind = 0;
|
||||
modCommandsSendBuffer[ind++] = packet_id;
|
||||
modCommandsSendPacket(modCommandsSendBuffer, ind);
|
||||
|
||||
modconfigHardwareLimitsApply(modCommandsGeneralConfig);
|
||||
|
||||
break;
|
||||
case COMM_GET_MCCONF:
|
||||
case COMM_GET_MCCONF_DEFAULT:
|
||||
if(packet_id == COMM_GET_MCCONF_DEFAULT){
|
||||
modConfigLoadDefaultConfig(&modCommandsConfigStorage);
|
||||
modCommandsToBeSendConfig = &modCommandsConfigStorage;
|
||||
}else{
|
||||
modCommandsToBeSendConfig = modCommandsGeneralConfig;
|
||||
}
|
||||
|
||||
ind = 0;
|
||||
modCommandsSendBuffer[ind++] = packet_id;
|
||||
|
||||
libBufferAppend_uint8( modCommandsSendBuffer,modCommandsToBeSendConfig->noOfCellsSeries ,&ind); // 1
|
||||
libBufferAppend_uint8( modCommandsSendBuffer,modCommandsToBeSendConfig->noOfCellsParallel ,&ind); // 1
|
||||
libBufferAppend_uint8( modCommandsSendBuffer,modCommandsToBeSendConfig->noOfParallelModules ,&ind); // 1
|
||||
libBufferAppend_float32_auto( modCommandsSendBuffer,modCommandsToBeSendConfig->batteryCapacity ,&ind); // 4
|
||||
libBufferAppend_float32_auto( modCommandsSendBuffer,modCommandsToBeSendConfig->cellHardUnderVoltage ,&ind); // 4
|
||||
libBufferAppend_float32_auto( modCommandsSendBuffer,modCommandsToBeSendConfig->cellHardOverVoltage ,&ind); // 4
|
||||
libBufferAppend_float32_auto( modCommandsSendBuffer,modCommandsToBeSendConfig->cellLCSoftUnderVoltage ,&ind); // 4
|
||||
libBufferAppend_float32_auto( modCommandsSendBuffer,modCommandsToBeSendConfig->cellSoftOverVoltage ,&ind); // 4
|
||||
libBufferAppend_float32_auto( modCommandsSendBuffer,modCommandsToBeSendConfig->cellBalanceDifferenceThreshold ,&ind); // 4
|
||||
libBufferAppend_float32_auto( modCommandsSendBuffer,modCommandsToBeSendConfig->cellBalanceStart ,&ind); // 4
|
||||
libBufferAppend_uint8( modCommandsSendBuffer,modCommandsToBeSendConfig->cellBalanceAllTime ,&ind); // 1
|
||||
libBufferAppend_float32_auto( modCommandsSendBuffer,modCommandsToBeSendConfig->cellThrottleUpperStart ,&ind); // 4
|
||||
libBufferAppend_float32_auto( modCommandsSendBuffer,modCommandsToBeSendConfig->cellThrottleLowerStart ,&ind); // 4
|
||||
libBufferAppend_float32_auto( modCommandsSendBuffer,modCommandsToBeSendConfig->cellThrottleUpperMargin ,&ind); // 4
|
||||
libBufferAppend_float32_auto( modCommandsSendBuffer,modCommandsToBeSendConfig->cellThrottleLowerMargin ,&ind); // 4
|
||||
libBufferAppend_uint8( modCommandsSendBuffer,modCommandsToBeSendConfig->packVoltageDataSource ,&ind); // 1
|
||||
libBufferAppend_uint8( modCommandsSendBuffer,modCommandsToBeSendConfig->packCurrentDataSource ,&ind); // 1
|
||||
libBufferAppend_uint8( modCommandsSendBuffer,modCommandsToBeSendConfig->buzzerSignalSource ,&ind); // 1
|
||||
libBufferAppend_uint8( modCommandsSendBuffer,modCommandsToBeSendConfig->buzzerSignalPersistant ,&ind); // 1
|
||||
libBufferAppend_float32_auto( modCommandsSendBuffer,modCommandsToBeSendConfig->shuntLCFactor ,&ind); // 4
|
||||
libBufferAppend_float32_auto( modCommandsSendBuffer,modCommandsToBeSendConfig->voltageLCFactor ,&ind); // 4
|
||||
libBufferAppend_int16( modCommandsSendBuffer,modCommandsToBeSendConfig->voltageLCOffset ,&ind); // 2
|
||||
libBufferAppend_float32_auto( modCommandsSendBuffer,modCommandsToBeSendConfig->loadVoltageFactor ,&ind); // 4
|
||||
libBufferAppend_float32_auto( modCommandsSendBuffer,modCommandsToBeSendConfig->loadVoltageOffset ,&ind); // 4
|
||||
libBufferAppend_float32_auto( modCommandsSendBuffer,modCommandsToBeSendConfig->chargerVoltageFactor ,&ind); // 4
|
||||
libBufferAppend_float32_auto( modCommandsSendBuffer,modCommandsToBeSendConfig->chargerVoltageOffset ,&ind); // 4
|
||||
libBufferAppend_uint8( modCommandsSendBuffer,modCommandsToBeSendConfig->throttleChargeIncreaseRate ,&ind); // 1
|
||||
libBufferAppend_uint8( modCommandsSendBuffer,modCommandsToBeSendConfig->throttleDisChargeIncreaseRate ,&ind); // 1
|
||||
libBufferAppend_uint32( modCommandsSendBuffer,modCommandsToBeSendConfig->cellBalanceUpdateInterval ,&ind); // 4
|
||||
libBufferAppend_uint8( modCommandsSendBuffer,modCommandsToBeSendConfig->maxSimultaneousDischargingCells ,&ind); // 1
|
||||
libBufferAppend_uint32( modCommandsSendBuffer,modCommandsToBeSendConfig->timeoutDischargeRetry ,&ind); // 4
|
||||
libBufferAppend_float32_auto( modCommandsSendBuffer,modCommandsToBeSendConfig->hysteresisDischarge ,&ind); // 4
|
||||
libBufferAppend_uint32( modCommandsSendBuffer,modCommandsToBeSendConfig->timeoutChargeRetry ,&ind); // 4
|
||||
libBufferAppend_float32_auto( modCommandsSendBuffer,modCommandsToBeSendConfig->hysteresisCharge ,&ind); // 4
|
||||
libBufferAppend_uint32( modCommandsSendBuffer,modCommandsToBeSendConfig->timeoutChargeCompleted ,&ind); // 4
|
||||
libBufferAppend_uint32( modCommandsSendBuffer,modCommandsToBeSendConfig->timeoutChargingCompletedMinimalMismatch,&ind); // 4
|
||||
libBufferAppend_float32_auto( modCommandsSendBuffer,modCommandsToBeSendConfig->maxMismatchThreshold ,&ind); // 4
|
||||
libBufferAppend_float32_auto( modCommandsSendBuffer,modCommandsToBeSendConfig->chargerEnabledThreshold ,&ind); // 4
|
||||
libBufferAppend_uint32( modCommandsSendBuffer,modCommandsToBeSendConfig->timeoutChargerDisconnected ,&ind); // 4
|
||||
libBufferAppend_float32_auto( modCommandsSendBuffer,modCommandsToBeSendConfig->minimalPrechargePercentage ,&ind); // 4
|
||||
libBufferAppend_uint32( modCommandsSendBuffer,modCommandsToBeSendConfig->timeoutLCPreCharge ,&ind); // 4
|
||||
libBufferAppend_float32_auto( modCommandsSendBuffer,modCommandsToBeSendConfig->maxAllowedCurrent ,&ind); // 4
|
||||
libBufferAppend_float32_auto( modCommandsSendBuffer,modCommandsToBeSendConfig->allowedTempBattDischargingMax ,&ind); // 4
|
||||
libBufferAppend_float32_auto( modCommandsSendBuffer,modCommandsToBeSendConfig->allowedTempBattDischargingMin ,&ind); // 4
|
||||
libBufferAppend_float32_auto( modCommandsSendBuffer,modCommandsToBeSendConfig->allowedTempBattChargingMax ,&ind); // 4
|
||||
libBufferAppend_float32_auto( modCommandsSendBuffer,modCommandsToBeSendConfig->allowedTempBattChargingMin ,&ind); // 4
|
||||
libBufferAppend_float32_auto( modCommandsSendBuffer,modCommandsToBeSendConfig->allowedTempBattCoolingMax ,&ind); // 4
|
||||
libBufferAppend_float32_auto( modCommandsSendBuffer,modCommandsToBeSendConfig->allowedTempBattCoolingMin ,&ind); // 4
|
||||
libBufferAppend_float32_auto( modCommandsSendBuffer,modCommandsToBeSendConfig->allowedTempBMSMax ,&ind); // 4
|
||||
libBufferAppend_float32_auto( modCommandsSendBuffer,modCommandsToBeSendConfig->allowedTempBMSMin ,&ind); // 4
|
||||
|
||||
//libBufferAppend_uint64( modCommandsSendBuffer,modCommandsToBeSendConfig->serialNumber , &ind); // 8
|
||||
RawSerial=modCommandsToBeSendConfig->serialNumber;
|
||||
// modCommandsToBeSendConfig->displayTimeoutBatteryDead = RawSerial;
|
||||
// modCommandsToBeSendConfig->displayTimeoutBatteryError = RawSerial<<32;
|
||||
|
||||
modCommandsToBeSendConfig->notUsedCurrentThreshold = (float) RawSerial;
|
||||
|
||||
libBufferAppend_uint32( modCommandsSendBuffer,modCommandsToBeSendConfig->displayTimeoutBatteryDead ,&ind); // 4
|
||||
libBufferAppend_uint32( modCommandsSendBuffer,modCommandsToBeSendConfig->displayTimeoutBatteryError ,&ind); // 4
|
||||
|
||||
libBufferAppend_uint32( modCommandsSendBuffer,modCommandsToBeSendConfig->displayTimeoutBatteryErrorPreCharge,&ind);//4
|
||||
libBufferAppend_uint32( modCommandsSendBuffer,modCommandsToBeSendConfig->displayTimeoutSplashScreen ,&ind); // 4
|
||||
libBufferAppend_uint8( modCommandsSendBuffer,modCommandsToBeSendConfig->displayStyle ,&ind); // 1
|
||||
libBufferAppend_uint8( modCommandsSendBuffer,modCommandsToBeSendConfig->maxUnderAndOverVoltageErrorCount,&ind); // 1
|
||||
libBufferAppend_uint8( modCommandsSendBuffer,modCommandsToBeSendConfig->maxUnderAndOverTemperatureErrorCount,&ind); // 1
|
||||
libBufferAppend_float32_auto( modCommandsSendBuffer,modCommandsToBeSendConfig->notUsedCurrentThreshold ,&ind); // 4
|
||||
libBufferAppend_uint32( modCommandsSendBuffer,modCommandsToBeSendConfig->notUsedTimeout ,&ind); // 4
|
||||
libBufferAppend_uint32( modCommandsSendBuffer,modCommandsToBeSendConfig->stateOfChargeStoreInterval ,&ind); // 4
|
||||
libBufferAppend_uint8( modCommandsSendBuffer,modCommandsToBeSendConfig->stateOfChargeMethod ,&ind); // 1
|
||||
libBufferAppend_uint8( modCommandsSendBuffer,modCommandsToBeSendConfig->CANID ,&ind); // 1
|
||||
libBufferAppend_uint8( modCommandsSendBuffer,modCommandsToBeSendConfig->CANIDStyle ,&ind); // 1
|
||||
libBufferAppend_uint8( modCommandsSendBuffer,modCommandsToBeSendConfig->canBusSpeed ,&ind); // 1
|
||||
libBufferAppend_uint8( modCommandsSendBuffer,modCommandsToBeSendConfig->emitStatusOverCAN ,&ind); // 1
|
||||
libBufferAppend_uint8( modCommandsSendBuffer,modCommandsToBeSendConfig->emitStatusProtocol ,&ind); // 1
|
||||
libBufferAppend_uint32( modCommandsSendBuffer,modCommandsToBeSendConfig->tempEnableMaskBMS ,&ind); // 4
|
||||
libBufferAppend_uint32( modCommandsSendBuffer,modCommandsToBeSendConfig->tempEnableMaskBattery ,&ind); // 4
|
||||
libBufferAppend_uint32( modCommandsSendBuffer,modCommandsToBeSendConfig->tempEnableMaskExpansion ,&ind); // 4
|
||||
libBufferAppend_uint8( modCommandsSendBuffer,modCommandsToBeSendConfig->noOfTempSensorPerModule ,&ind); // 1
|
||||
libBufferAppend_uint8( modCommandsSendBuffer,modCommandsToBeSendConfig->noOfExpansionBoard ,&ind); // 1
|
||||
libBufferAppend_uint8( modCommandsSendBuffer,modCommandsToBeSendConfig->noOfTempSensorPerExpansionBoard ,&ind); // 1
|
||||
libBufferAppend_uint8( modCommandsSendBuffer,modCommandsToBeSendConfig->LCUseDischarge ,&ind); // 1
|
||||
libBufferAppend_uint8( modCommandsSendBuffer,modCommandsToBeSendConfig->LCUsePrecharge ,&ind); // 1
|
||||
libBufferAppend_uint8( modCommandsSendBuffer,modCommandsToBeSendConfig->allowChargingDuringDischarge ,&ind); // 1
|
||||
libBufferAppend_uint8( modCommandsSendBuffer,modCommandsToBeSendConfig->allowForceOn ,&ind); // 1
|
||||
libBufferAppend_uint8( modCommandsSendBuffer,modCommandsToBeSendConfig->pulseToggleButton ,&ind); // 1
|
||||
libBufferAppend_uint8( modCommandsSendBuffer,modCommandsToBeSendConfig->useCANSafetyInput ,&ind); // 1
|
||||
libBufferAppend_uint8( modCommandsSendBuffer,modCommandsToBeSendConfig->useCANDelayedPowerDown ,&ind); // 1
|
||||
libBufferAppend_uint32( modCommandsSendBuffer,modCommandsToBeSendConfig->NTCTopResistor[modConfigNTCGroupLTCExt],&ind); // 4
|
||||
libBufferAppend_uint32( modCommandsSendBuffer,modCommandsToBeSendConfig->NTC25DegResistance[modConfigNTCGroupLTCExt],&ind); // 4
|
||||
libBufferAppend_uint16( modCommandsSendBuffer,modCommandsToBeSendConfig->NTCBetaFactor[modConfigNTCGroupLTCExt],&ind); // 2
|
||||
libBufferAppend_uint32( modCommandsSendBuffer,modCommandsToBeSendConfig->NTCTopResistor[modConfigNTCGroupMasterPCB],&ind); // 4
|
||||
libBufferAppend_uint32( modCommandsSendBuffer,modCommandsToBeSendConfig->NTC25DegResistance[modConfigNTCGroupMasterPCB],&ind); // 4
|
||||
libBufferAppend_uint16( modCommandsSendBuffer,modCommandsToBeSendConfig->NTCBetaFactor[modConfigNTCGroupMasterPCB],&ind); // 2
|
||||
libBufferAppend_uint32( modCommandsSendBuffer,modCommandsToBeSendConfig->NTCTopResistor[modConfigNTCGroupExp],&ind); // 4
|
||||
libBufferAppend_uint32( modCommandsSendBuffer,modCommandsToBeSendConfig->NTC25DegResistance[modConfigNTCGroupExp],&ind); // 4
|
||||
libBufferAppend_uint16( modCommandsSendBuffer,modCommandsToBeSendConfig->NTCBetaFactor[modConfigNTCGroupExp],&ind); // 2
|
||||
libBufferAppend_uint8( modCommandsSendBuffer,modCommandsToBeSendConfig->cellMonitorType ,&ind); // 1
|
||||
libBufferAppend_uint8( modCommandsSendBuffer,modCommandsToBeSendConfig->cellMonitorICCount ,&ind); // 1
|
||||
libBufferAppend_uint8( modCommandsSendBuffer,modCommandsToBeSendConfig->externalEnableOperationalState ,&ind); // 1
|
||||
libBufferAppend_uint8( modCommandsSendBuffer,modCommandsToBeSendConfig->chargeEnableOperationalState ,&ind); // 1
|
||||
libBufferAppend_uint32( modCommandsSendBuffer,modCommandsToBeSendConfig->powerDownDelay ,&ind); // 4
|
||||
libBufferAppend_uint8( modCommandsSendBuffer,modCommandsToBeSendConfig->humidityICType ,&ind); // 1
|
||||
//libBufferAppend_uint64( modCommandsSendBuffer,modCommandsToBeSendConfig->serialNumber , &ind); // 8
|
||||
modCommandsSendPacket(modCommandsSendBuffer, ind);
|
||||
break;
|
||||
|
||||
case COMM_GET_GSM_DATA:
|
||||
case COMM_GET_GSM_DEFAULT_DATA:
|
||||
if(packet_id == COMM_GET_GSM_DEFAULT_DATA){
|
||||
modConfigLoadDefaultConfig(&modCommandsConfigStorage);
|
||||
modCommandsToBeSendConfig = &modCommandsConfigStorage;
|
||||
}else{
|
||||
modCommandsToBeSendConfig = modCommandsGeneralConfig;
|
||||
}
|
||||
|
||||
ind = 0;
|
||||
modCommandsSendBuffer[ind++] = packet_id;
|
||||
|
||||
i=250;
|
||||
while (i>0){
|
||||
libBufferAppend_uint8(modCommandsSendBuffer,modCommandsToBeSendConfig->Domain_URL[i],&ind);
|
||||
i--;
|
||||
}
|
||||
i=250;
|
||||
while (i>0){
|
||||
libBufferAppend_uint8(modCommandsSendBuffer,modCommandsToBeSendConfig->Domain_URL_Event[i],&ind);
|
||||
i--;
|
||||
}
|
||||
i=50;
|
||||
while (i>0){
|
||||
libBufferAppend_uint8(modCommandsSendBuffer,modCommandsToBeSendConfig->GSM_APN[i],&ind);
|
||||
i--;
|
||||
}
|
||||
i=50;
|
||||
while (i>0){
|
||||
libBufferAppend_uint8(modCommandsSendBuffer,modCommandsToBeSendConfig->GSM_USER[i],&ind);
|
||||
i--;
|
||||
}
|
||||
i=50;
|
||||
while (i>0){
|
||||
libBufferAppend_uint8(modCommandsSendBuffer,modCommandsToBeSendConfig->GSM_PWD[i],&ind);
|
||||
i--;
|
||||
}
|
||||
modCommandsSendPacket(modCommandsSendBuffer, ind);
|
||||
|
||||
break;
|
||||
case COMM_SET_GSM_DATA:
|
||||
ind = 0;
|
||||
for (i=0;i<250;i++){
|
||||
modCommandsGeneralConfig->Domain_URL[i] = libBufferGet_uint8(data,&ind); // 250
|
||||
}
|
||||
for (i=0;i<250;i++){
|
||||
modCommandsGeneralConfig->Domain_URL_Event[i] = libBufferGet_uint8(data,&ind); // 250
|
||||
}
|
||||
for (i=0;i<50;i++){
|
||||
modCommandsGeneralConfig->GSM_APN[i] = libBufferGet_uint8(data,&ind); // 50
|
||||
}
|
||||
for (i=0;i<50;i++){
|
||||
modCommandsGeneralConfig->GSM_USER[i] = libBufferGet_uint8(data,&ind); // 50
|
||||
}
|
||||
for (i=0;i<50;i++){
|
||||
modCommandsGeneralConfig->GSM_PWD[i] = libBufferGet_uint8(data,&ind); // 50
|
||||
}
|
||||
|
||||
ind = 0;
|
||||
modCommandsSendBuffer[ind++] = packet_id;
|
||||
modCommandsSendPacket(modCommandsSendBuffer, ind);
|
||||
UpdateGSMParamsFromConfig();
|
||||
//SetParametersFromConfig
|
||||
|
||||
break;
|
||||
case COMM_TERMINAL_CMD:
|
||||
data[len] = '\0';
|
||||
modTerminalProcessString((char*)data);
|
||||
break;
|
||||
case COMM_REBOOT:
|
||||
modCommandsJumpToMainApplication();
|
||||
break;
|
||||
case COMM_ALIVE:
|
||||
break;
|
||||
case COMM_FORWARD_CAN:
|
||||
//ni modCANSendBuffer(data[0], data + 1, len - 1, false);
|
||||
break;
|
||||
case COMM_STORE_BMS_CONF:
|
||||
modConfigStoreConfig();
|
||||
|
||||
ind = 0;
|
||||
modCommandsSendBuffer[ind++] = packet_id;
|
||||
modCommandsSendPacket(modCommandsSendBuffer, ind);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if(modDelayTick1ms(&delayTick,1000) && jumpBootloaderTrue) jumpToBootLoader();
|
||||
}
|
||||
|
||||
void modCommandsPrintf(const char* format, ...) {
|
||||
va_list arg;
|
||||
va_start (arg, format);
|
||||
int len;
|
||||
static char print_buffer[255];
|
||||
|
||||
print_buffer[0] = COMM_PRINT;
|
||||
len = vsnprintf(print_buffer+1, 254, format, arg);
|
||||
va_end (arg);
|
||||
|
||||
if(len > 0) {
|
||||
modCommandsSendPacket((unsigned char*)print_buffer, (len<254)? len+1: 255);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void modCommandsJumpToMainApplication(void) {
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
//void BufferCharStringSend(char *modCommandsSource, uint8_t NumberOfBytes){
|
||||
// char SourceBuf[NumberOfBytes];
|
||||
//
|
||||
// *SourceBuf = modCommandsSource;
|
||||
//
|
||||
// while (Number0fBytes>0){
|
||||
// libBufferAppend_uint8(modCommandsSendBuffer,SourceBuf[Number0fBytes],&ind);
|
||||
// }
|
||||
//}
|
||||
529
Core/Src/modConfig.c
Normal file
529
Core/Src/modConfig.c
Normal file
@@ -0,0 +1,529 @@
|
||||
/*
|
||||
Copyright 2017 - 2018 Danny Bokma danny@diebie.nl
|
||||
Copyright 2019 - 2020 Kevin Dionne kevin.dionne@ennoid.me
|
||||
|
||||
This file is part of the DieBieMS/ENNOID-BMS firmware.
|
||||
|
||||
The DieBieMS/ENNOID-BMS firmware is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The DieBieMS/ENNOID-BMS firmware is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "modConfig.h"
|
||||
|
||||
modConfigGeneralConfigStructTypedef modConfigGeneralConfig;
|
||||
|
||||
modConfigGeneralConfigStructTypedef* modConfigInit(void) {
|
||||
driverSWStorageManagerConfigStructSize = (sizeof(modConfigGeneralConfigStructTypedef)/sizeof(uint16_t)); // Calculate the space needed for the config struct in EEPROM
|
||||
return &modConfigGeneralConfig;
|
||||
};
|
||||
|
||||
bool modConfigStoreAndLoadDefaultConfig(void) {
|
||||
bool returnVal = false;
|
||||
if(driverSWStorageManagerConfigEmpty) {
|
||||
returnVal = modConfigStoreDefaultConfig();
|
||||
}
|
||||
|
||||
modConfigLoadConfig();
|
||||
return returnVal;
|
||||
};
|
||||
|
||||
bool modConfigStoreConfig(void) {
|
||||
return driverSWStorageManagerStoreStruct(&modConfigGeneralConfig,STORAGE_CONFIG);
|
||||
// TODO_EEPROM
|
||||
};
|
||||
|
||||
bool modConfigLoadConfig(void) {
|
||||
return driverSWStorageManagerGetStruct(&modConfigGeneralConfig,STORAGE_CONFIG);
|
||||
};
|
||||
|
||||
bool modConfigStoreDefaultConfig(void) {
|
||||
// VALUES WILL ONLY AUTIMATICALLY UPDATE AFTER FLASH ERASE!
|
||||
modConfigGeneralConfigStructTypedef defaultConfig;
|
||||
modConfigLoadDefaultConfig(&defaultConfig);
|
||||
|
||||
driverSWStorageManagerConfigEmpty = false;
|
||||
return driverSWStorageManagerStoreStruct(&defaultConfig,STORAGE_CONFIG);
|
||||
}
|
||||
|
||||
void modconfigHardwareLimitsApply(modConfigGeneralConfigStructTypedef *configLocation) {
|
||||
configLocation->maxSimultaneousDischargingCells = MIN(configLocation->maxSimultaneousDischargingCells,HW_LIM_CELL_BALANCE_MAX_SIMULTANEOUS_DISCHARGE);
|
||||
configLocation->cellMonitorICCount = MIN(configLocation->cellMonitorICCount ,HW_LIM_CELL_MONITOR_IC_COUNT);
|
||||
configLocation->lastICMask = 0;
|
||||
|
||||
if(configLocation->notUsedTimeout)
|
||||
configLocation->notUsedTimeout = MAX(configLocation->notUsedTimeout ,HW_LIM_MIN_NOT_USED_DELAY);
|
||||
|
||||
// Check for feasable parameters
|
||||
if((configLocation->cellMonitorICCount % configLocation->noOfParallelModules) == 0){ // Check if feasable configuration
|
||||
if(configLocation->noOfCellsSeries % (configLocation->cellMonitorICCount / configLocation->noOfParallelModules) == 0){
|
||||
configLocation->noOfCellsPerModule = configLocation->noOfCellsSeries/(configLocation->cellMonitorICCount / configLocation->noOfParallelModules);
|
||||
configLocation->lastICNoOfCells = configLocation->noOfCellsPerModule;
|
||||
|
||||
for(int bitPointer = 0; bitPointer < configLocation->lastICNoOfCells ; bitPointer++){
|
||||
configLocation->lastICMask = (configLocation->lastICMask << 1)| 1 ; // This contains the last cells mask used for enabling UV & OV flag in the last serie IC
|
||||
}
|
||||
}else{ //Odd number of cells in series
|
||||
configLocation->noOfCellsPerModule = (configLocation->noOfCellsSeries / (configLocation->cellMonitorICCount / configLocation->noOfParallelModules))+1;
|
||||
|
||||
configLocation->lastICNoOfCells = configLocation->noOfCellsSeries % configLocation->noOfCellsPerModule; // This contains the last cells number monitored by the last serie IC
|
||||
|
||||
for(int bitPointer = 0; bitPointer < configLocation->lastICNoOfCells ; bitPointer++){
|
||||
configLocation->lastICMask = (configLocation->lastICMask << 1)| 1 ; // This contains the last cells mask used for enabling UV & OV flag in the last serie IC
|
||||
}
|
||||
};
|
||||
}else{
|
||||
configLocation->noOfCellsSeries = 8;
|
||||
configLocation->cellMonitorICCount = 1;
|
||||
configLocation->noOfCellsPerModule = 1;
|
||||
configLocation->lastICNoOfCells = 0;
|
||||
configLocation->lastICMask = 0;
|
||||
};
|
||||
|
||||
if (configLocation->noOfCellsPerModule <= 4){
|
||||
configLocation->noOfCellsSeries = 8;
|
||||
configLocation->cellMonitorICCount = 1;
|
||||
configLocation->noOfCellsPerModule = 1;
|
||||
configLocation->lastICNoOfCells = 0;
|
||||
configLocation->lastICMask = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void modConfigLoadDefaultConfig(modConfigGeneralConfigStructTypedef *configLocation) {
|
||||
char* ptr;
|
||||
|
||||
#if ENNOID_LV
|
||||
//configLocation->serialNumber = 20000054;
|
||||
configLocation->noOfCellsSeries = 8; // Total number of cells in series in the battery pack
|
||||
configLocation->noOfCellsParallel = 2; // Number of cells in parallel
|
||||
configLocation->noOfParallelModules = 1; // Number of parallel modules
|
||||
configLocation->batteryCapacity = 144.00f; // XXAh battery
|
||||
configLocation->cellHardUnderVoltage = 2.50f; // Worst case X.XXV as lowest cell voltage
|
||||
configLocation->cellHardOverVoltage = 3.65f; // Worst case X.XXV as highest cell voltage
|
||||
configLocation->cellLCSoftUnderVoltage = 2.70f; // Lowest cell voltage X.XXV.
|
||||
configLocation->cellSoftOverVoltage = 4.10f; // Normal highest cell voltage X.XXV.
|
||||
configLocation->cellBalanceDifferenceThreshold = 0.005f; // Start balancing @ XmV difference, stop if below.
|
||||
configLocation->cellBalanceStart = 3.4f; // Start balancing above X.XXV.
|
||||
configLocation->cellBalanceAllTime = false; // Enable balancing under all opstate
|
||||
configLocation->cellThrottleUpperStart = 0.03f; // Upper range of cell voltage for charge throttling.
|
||||
configLocation->cellThrottleLowerStart = 0.20f; // Lower range of cell voltage for discharge throttling.
|
||||
configLocation->cellThrottleUpperMargin = 0.01f; // Margin of throttle from upper soft limits.
|
||||
configLocation->cellThrottleLowerMargin = 0.50f; // Margin of throttle from lower soft limits.
|
||||
configLocation->packVoltageDataSource = sourcePackVoltageSumOfIndividualCellVoltages; // Packvoltage source.
|
||||
configLocation->packCurrentDataSource = sourcePackCurrentLowCurrentShunt; // The pack current is the same as the current through the low current shunt
|
||||
configLocation->buzzerSignalSource = buzzerSourceOn; // Stores what source shoud be taken to trigger
|
||||
configLocation->buzzerSignalPersistant = false; // Stores whether the buzzer should stay on after triggering
|
||||
configLocation->shuntLCFactor = -0.051f; // Shunt factor low current
|
||||
configLocation->voltageLCFactor = 3.50f; // Pack voltage factor
|
||||
configLocation->voltageLCOffset = 0; // Pack voltage offset
|
||||
configLocation->loadVoltageFactor = 49.2f; // Load voltage factor
|
||||
configLocation->loadVoltageOffset = 0.0f; // Load voltage offset
|
||||
configLocation->chargerVoltageFactor = 49.2f; // Charger voltage factor
|
||||
configLocation->chargerVoltageOffset = 0.0f; // Charger voltage offset
|
||||
configLocation->throttleChargeIncreaseRate = 1; // Percentage charge throttle increase rate per 100ms (cell voltage loop time)
|
||||
configLocation->throttleDisChargeIncreaseRate = 2; // Percentage discharge throttle increase rate per 100ms (cell voltage loop time)
|
||||
configLocation->cellBalanceUpdateInterval = 4*1000; // Keep calculated resistors enabled for this amount of time in miliseconds.
|
||||
configLocation->maxSimultaneousDischargingCells = 5; // Allow a maximum of X cells simultinous discharging trough bleeding resistors.
|
||||
configLocation->timeoutDischargeRetry = 10*1000; // Wait for X seconds before retrying to enable load.
|
||||
configLocation->hysteresisDischarge = 0.02f; // Lowest cell should rise XXmV before output is re enabled.
|
||||
configLocation->timeoutChargeRetry = 100*1000; // Wait for XX seconds before retrying to enable charger.
|
||||
configLocation->hysteresisCharge = 0.01f; // Highest cell should lower XXmV before charger is re enabled.
|
||||
configLocation->timeoutChargeCompleted = 30*60*1000; // Wait for XX minutes before setting charge state to charged.
|
||||
configLocation->timeoutChargingCompletedMinimalMismatch = 6*1000; // If cell mismatch is under threshold and (charging is not allowed) wait this delay time to set "charged" state.
|
||||
configLocation->maxMismatchThreshold = 0.010f; // If mismatch is under this threshold for timeoutChargingCompletedMinimalMismatch determin fully charged.
|
||||
configLocation->chargerEnabledThreshold = 0.5f; // If charge current > X.XA stay in charging mode and dont power off.
|
||||
configLocation->timeoutChargerDisconnected = 2000; // Wait for X seconds to respond to charger disconnect.
|
||||
configLocation->minimalPrechargePercentage = 0.90f; // output should be at a minimal of 80% of input voltage.
|
||||
configLocation->timeoutLCPreCharge = 1.5*1000; // Precharge error timeout, allow 1.5 seconds pre-charge time before declaring load error.
|
||||
configLocation->maxAllowedCurrent = 1000.0f; // Allow max XXXA trough BMS.
|
||||
configLocation->allowedTempBattDischargingMax = 75.0f; // Max battery temperature where discharging is still allowed
|
||||
configLocation->allowedTempBattDischargingMin = 0.0f; // Min battery temperature where discharging is still allowed
|
||||
configLocation->allowedTempBattChargingMax = 50.0f; // Max battery temperature where charging is still allowed
|
||||
configLocation->allowedTempBattChargingMin = 0.0f; // Min battery temperature where charging is still allowed
|
||||
configLocation->allowedTempBattCoolingMax = 5.0f; // Max battery temperature where cooling is activated
|
||||
configLocation->allowedTempBattCoolingMin = 50.0f; // Min battery temperature where heating is activated
|
||||
configLocation->allowedTempBMSMax = 80.0f; // Max BMS operational temperature
|
||||
configLocation->allowedTempBMSMin = 0.0f; // Min BMS operational temperature
|
||||
configLocation->displayTimeoutBatteryDead = 5000; // Show battery dead symbol X seconds before going to powerdown in cell voltage error state.
|
||||
configLocation->displayTimeoutBatteryError = 5000; // Show error symbol for X seconds before going to powerdown in general error state.
|
||||
configLocation->displayTimeoutBatteryErrorPreCharge = 10000; // Show pre charge error for XX seconds.
|
||||
configLocation->displayTimeoutSplashScreen = 3000; // Display / INIT splash screen time.
|
||||
configLocation->displayStyle = advanced; // Display style used for showing the SSD1306 data
|
||||
configLocation->maxUnderAndOverVoltageErrorCount = 5; // Max count of hard cell voltage errors.
|
||||
configLocation->maxUnderAndOverTemperatureErrorCount = 5; // Max count of hard cell voltage errors.
|
||||
configLocation->notUsedCurrentThreshold = 1.0f; // If abs(packcurrent) < X.XA consider pack as not used.
|
||||
configLocation->notUsedTimeout = 20*60*1000; // If pack is not used for longer than XX minutes disable bms.
|
||||
configLocation->stateOfChargeStoreInterval = 60*1000; // Interval in ms to store state of charge information.
|
||||
configLocation->stateOfChargeMethod = socCoulomb; // Use coulomb counting for SoC calculation
|
||||
configLocation->CANID = 10; // CAN ID for CAN communication.
|
||||
configLocation->CANIDStyle = CANIDStyleVESC; // CAN ID default Style.
|
||||
configLocation->emitStatusOverCAN = false; // Send status over can.
|
||||
configLocation->canBusSpeed = canSpeedBaud500k; // 500k CAN baud
|
||||
configLocation->emitStatusProtocol = canEmitProtocolDieBieEngineering; // Can emit protocol set to MG style for backwards compatibility
|
||||
configLocation->tempEnableMaskBMS = 0x0001; // Bitwise select what sensor to enable for the BMS (internal sensors).
|
||||
configLocation->tempEnableMaskBattery = 0xFFFF; // Bitwise select what sensor to enable for the battery (external sensors).
|
||||
configLocation->tempEnableMaskExpansion = 0xFFFF; // Bitwise select what sensor to enable for the expansion boards(external sensors).
|
||||
configLocation->noOfTempSensorPerModule = 2; // Number of temperature sensors monitored per LTC68XX
|
||||
configLocation->noOfExpansionBoard = 0; // Number of expansion board
|
||||
configLocation->noOfTempSensorPerExpansionBoard = 0; // Number of temperature sensors monitored per expansion board
|
||||
configLocation->LCUseDischarge = enabled; // Enable or disable the solid state output
|
||||
configLocation->LCUsePrecharge = enabled; // Use precharge before enabling main output
|
||||
configLocation->allowChargingDuringDischarge = true; // Allow the battery to be charged in normal mode
|
||||
configLocation->allowForceOn = false; // Allow the BMS to be forced ON by long actuation of the power button
|
||||
configLocation->pulseToggleButton = true; // Select either pulse or toggle power button
|
||||
configLocation->useCANSafetyInput = false; // Use the safety input status from CAN
|
||||
configLocation->useCANDelayedPowerDown = false; // Use delayed power down
|
||||
configLocation->NTCTopResistor[modConfigNTCGroupLTCExt] = 100000; // NTC Pullup resistor value
|
||||
configLocation->NTCTopResistor[modConfigNTCGroupMasterPCB] = 100000; // NTC Pullup resistor value
|
||||
configLocation->NTCTopResistor[modConfigNTCGroupExp] = 100000; // NTC Pullup resistor value
|
||||
configLocation->NTC25DegResistance[modConfigNTCGroupLTCExt] = 100000; // NTC resistance at 25 degree
|
||||
configLocation->NTC25DegResistance[modConfigNTCGroupMasterPCB] = 100000; // NTC resistance at 25 degree
|
||||
configLocation->NTC25DegResistance[modConfigNTCGroupExp] = 100000; // NTC resistance at 25 degree
|
||||
configLocation->NTCBetaFactor[modConfigNTCGroupLTCExt] = 4250; // NTC Beta factor
|
||||
configLocation->NTCBetaFactor[modConfigNTCGroupMasterPCB] = 4250; // NTC Beta factor
|
||||
configLocation->NTCBetaFactor[modConfigNTCGroupExp] = 4250; // NTC Beta factor
|
||||
configLocation->cellMonitorType = CELL_MON_LTC6811_1; // Use the new cell voltage monitor
|
||||
configLocation->cellMonitorICCount = 1; // Only one slave IC
|
||||
configLocation->externalEnableOperationalState = opStateExtNormal; // Go to normal enable mode
|
||||
configLocation->chargeEnableOperationalState = opStateChargingModeCharging;// Go to charging mode when a charger is connected
|
||||
configLocation->powerDownDelay = 3000; // Wait only minimal to turn off
|
||||
|
||||
configLocation->noOfCellsPerModule = 8; // Number of cell levels monitored per LTC68XX
|
||||
configLocation->lastICNoOfCells = 0;
|
||||
configLocation->lastICMask = 0;
|
||||
configLocation->humidityICType = 0;
|
||||
|
||||
configLocation->serialNumber=__DEFAULT_BATTERY_SERIAL;
|
||||
|
||||
ptr = &configLocation->Domain_URL[0];
|
||||
strcpy(ptr,"http://battery.cscw.ru/api/v1/battery");
|
||||
|
||||
ptr = &configLocation->Domain_URL_Event[0];
|
||||
strcpy(ptr,"http://battery.cscw.ru/api/v1/events");
|
||||
|
||||
ptr = &configLocation->GSM_APN[0];
|
||||
strcpy(ptr,"internet.beeline.ru");
|
||||
|
||||
ptr = &configLocation->GSM_USER[0];
|
||||
strcpy(ptr,"Beeline");
|
||||
|
||||
ptr = &configLocation->GSM_PWD[0];
|
||||
strcpy(ptr,"Beeline");
|
||||
|
||||
configLocation->PC_Time=0;
|
||||
|
||||
|
||||
#elif ENNOID_HV
|
||||
configLocation->noOfCellsSeries = 8; // Total number of cells in series in the battery pack
|
||||
configLocation->noOfCellsParallel = 10; // Number of cells in parallel
|
||||
configLocation->noOfParallelModules = 1; // Number of parallel modules
|
||||
configLocation->batteryCapacity = 22.00f; // XXAh battery
|
||||
configLocation->cellHardUnderVoltage = 2.30f; // Worst case X.XXV as lowest cell voltage
|
||||
configLocation->cellHardOverVoltage = 4.20f; // Worst case X.XXV as highest cell voltage
|
||||
configLocation->cellLCSoftUnderVoltage = 2.70f; // Lowest cell voltage X.XXV.
|
||||
configLocation->cellSoftOverVoltage = 4.15f; // Normal highest cell voltage X.XXV.
|
||||
configLocation->cellBalanceDifferenceThreshold = 0.01f; // Start balancing @ XmV difference, stop if below.
|
||||
configLocation->cellBalanceStart = 4.1f; // Start balancing above X.XXV.
|
||||
configLocation->cellBalanceAllTime = false; // Enable balancing under all opstate
|
||||
configLocation->cellThrottleUpperStart = 0.03f; // Upper range of cell voltage for charge throttling.
|
||||
configLocation->cellThrottleLowerStart = 0.20f; // Lower range of cell voltage for discharge throttling.
|
||||
configLocation->cellThrottleUpperMargin = 0.01f; // Margin of throttle from upper soft limits.
|
||||
configLocation->cellThrottleLowerMargin = 0.50f; // Margin of throttle from lower soft limits.
|
||||
configLocation->packVoltageDataSource = sourcePackVoltageISL28022_2_BatteryIn; // Packvoltage source.
|
||||
configLocation->packCurrentDataSource = sourcePackCurrentLowCurrentShunt; // The pack current is the same as the current through the low current shunt
|
||||
configLocation->buzzerSignalSource = buzzerSourceOn; // Stores what source shoud be taken to trigger
|
||||
configLocation->buzzerSignalPersistant = false; // Stores whether the buzzer should stay on after triggering
|
||||
configLocation->shuntLCFactor = -0.07f; // Shunt factor low current
|
||||
configLocation->voltageLCFactor = 47.5f; // Pack voltage factor
|
||||
configLocation->voltageLCOffset = 0; // Pack voltage offset
|
||||
configLocation->loadVoltageFactor = 190.0f; // Load voltage factor
|
||||
configLocation->loadVoltageOffset = 9.0f; // Load voltage offset
|
||||
configLocation->chargerVoltageFactor = 49.2f; // Charger voltage factor
|
||||
configLocation->chargerVoltageOffset = 0.0f; // Charger voltage offset
|
||||
configLocation->throttleChargeIncreaseRate = 1; // Percentage charge throttle increase rate per 100ms (cell voltage loop time)
|
||||
configLocation->throttleDisChargeIncreaseRate = 2; // Percentage discharge throttle increase rate per 100ms (cell voltage loop time)
|
||||
configLocation->cellBalanceUpdateInterval = 4*1000; // Keep calculated resistors enabled for this amount of time in miliseconds.
|
||||
configLocation->maxSimultaneousDischargingCells = 5; // Allow a maximum of X cells simultinous discharging trough bleeding resistors.
|
||||
configLocation->timeoutDischargeRetry = 10*1000; // Wait for X seconds before retrying to enable load.
|
||||
configLocation->hysteresisDischarge = 0.02f; // Lowest cell should rise XXmV before output is re enabled.
|
||||
configLocation->timeoutChargeRetry = 30*1000; // Wait for XX seconds before retrying to enable charger.
|
||||
configLocation->hysteresisCharge = 0.01f; // Highest cell should lower XXmV before charger is re enabled.
|
||||
configLocation->timeoutChargeCompleted = 30*60*1000; // Wait for XX minutes before setting charge state to charged.
|
||||
configLocation->timeoutChargingCompletedMinimalMismatch = 6*1000; // If cell mismatch is under threshold and (charging is not allowed) wait this delay time to set "charged" state.
|
||||
configLocation->maxMismatchThreshold = 0.010f; // If mismatch is under this threshold for timeoutChargingCompletedMinimalMismatch determin fully charged.
|
||||
configLocation->chargerEnabledThreshold = 0.5f; // If charge current > X.XA stay in charging mode and dont power off.
|
||||
configLocation->timeoutChargerDisconnected = 2000; // Wait for X seconds to respond to charger disconnect.
|
||||
configLocation->minimalPrechargePercentage = 0.90f; // output should be at a minimal of 80% of input voltage.
|
||||
configLocation->timeoutLCPreCharge = 1.5*1000; // Precharge error timeout, allow 1.5 seconds pre-charge time before declaring load error.
|
||||
configLocation->maxAllowedCurrent = 1000.0f; // Allow max XXXA trough BMS.
|
||||
configLocation->allowedTempBattDischargingMax = 75.0f; // Max battery temperature where discharging is still allowed
|
||||
configLocation->allowedTempBattDischargingMin = 0.0f; // Min battery temperature where discharging is still allowed
|
||||
configLocation->allowedTempBattChargingMax = 50.0f; // Max battery temperature where charging is still allowed
|
||||
configLocation->allowedTempBattChargingMin = 0.0f; // Min battery temperature where charging is still allowed
|
||||
configLocation->allowedTempBattCoolingMax = 5.0f; // Max battery temperature where cooling is activated
|
||||
configLocation->allowedTempBattCoolingMin = 50.0f; // Min battery temperature where heating is activated
|
||||
configLocation->allowedTempBMSMax = 80.0f; // Max BMS operational temperature
|
||||
configLocation->allowedTempBMSMin = 0.0f; // Min BMS operational temperature
|
||||
configLocation->displayTimeoutBatteryDead = 5000; // Show battery dead symbol X seconds before going to powerdown in cell voltage error state.
|
||||
configLocation->displayTimeoutBatteryError = 5000; // Show error symbol for X seconds before going to powerdown in general error state.
|
||||
configLocation->displayTimeoutBatteryErrorPreCharge = 10000; // Show pre charge error for XX seconds.
|
||||
configLocation->displayTimeoutSplashScreen = 3000; // Display / INIT splash screen time.
|
||||
configLocation->displayStyle = advanced; // Display style used for showing the SSD1306 data
|
||||
configLocation->maxUnderAndOverVoltageErrorCount = 5; // Max count of hard cell voltage errors.
|
||||
configLocation->maxUnderAndOverTemperatureErrorCount = 5; // Max count of hard cell voltage errors.
|
||||
configLocation->notUsedCurrentThreshold = 1.0f; // If abs(packcurrent) < X.XA consider pack as not used.
|
||||
configLocation->notUsedTimeout = 20*60*1000; // If pack is not used for longer than XX minutes disable bms.
|
||||
configLocation->stateOfChargeStoreInterval = 60*1000; // Interval in ms to store state of charge information.
|
||||
configLocation->stateOfChargeMethod = socCoulomb; // Use coulomb counting for SoC calculation
|
||||
configLocation->CANID = 10; // CAN ID for CAN communication.
|
||||
configLocation->CANIDStyle = CANIDStyleVESC; // CAN ID default Style.
|
||||
configLocation->canBusSpeed = canSpeedBaud500k; // 500k CAN baud
|
||||
configLocation->emitStatusOverCAN = false; // Send status over can.
|
||||
configLocation->emitStatusProtocol = canEmitProtocolDieBieEngineering; // Can emit protocol set to MG style for backwards compatibility
|
||||
configLocation->tempEnableMaskBMS = 0x0001; // Bitwise select what sensor to enable for the BMS (internal sensors).
|
||||
configLocation->tempEnableMaskBattery = 0xFFFF; // Bitwise select what sensor to enable for the battery (external sensors).
|
||||
configLocation->tempEnableMaskExpansion = 0xFFFF; // Bitwise select what sensor to enable for the battery (external sensors).
|
||||
configLocation->noOfTempSensorPerModule = 1; // Number of temperature sensors monitored per LTC68XX
|
||||
configLocation->noOfExpansionBoard = 0; // Number of expansion board
|
||||
configLocation->noOfTempSensorPerExpansionBoard = 0; // Number of temperature sensors monitored per expansion board
|
||||
configLocation->LCUseDischarge = enabled; // Enable or disable the solid state output
|
||||
configLocation->LCUsePrecharge = enabled; // Use precharge before enabling main output
|
||||
configLocation->allowChargingDuringDischarge = true; // Allow the battery to be charged in normal mode
|
||||
configLocation->allowForceOn = false; // Allow the BMS to be forced ON by long actuation of the power button
|
||||
configLocation->pulseToggleButton = true; // Select either pulse or toggle power button
|
||||
configLocation->useCANSafetyInput = false; // Use the safety input status from CAN
|
||||
configLocation->useCANDelayedPowerDown = false; // Use delayed power down
|
||||
configLocation->NTCTopResistor[modConfigNTCGroupLTCExt] = 100000; // NTC Pullup resistor value
|
||||
configLocation->NTCTopResistor[modConfigNTCGroupMasterPCB] = 100000; // NTC Pullup resistor value
|
||||
configLocation->NTCTopResistor[modConfigNTCGroupExp] = 100000; // NTC Pullup resistor value
|
||||
configLocation->NTC25DegResistance[modConfigNTCGroupLTCExt] = 100000; // NTC resistance at 25 degree
|
||||
configLocation->NTC25DegResistance[modConfigNTCGroupMasterPCB] = 100000; // NTC resistance at 25 degree
|
||||
configLocation->NTC25DegResistance[modConfigNTCGroupExp] = 100000; // NTC resistance at 25 degree
|
||||
configLocation->NTCBetaFactor[modConfigNTCGroupLTCExt] = 4250; // NTC Beta factor
|
||||
configLocation->NTCBetaFactor[modConfigNTCGroupMasterPCB] = 4250; // NTC Beta factor
|
||||
configLocation->NTCBetaFactor[modConfigNTCGroupExp] = 4250; // NTC Beta factor
|
||||
configLocation->cellMonitorType = CELL_MON_LTC6811_1; // Use the new cell voltage monitor
|
||||
configLocation->cellMonitorICCount = 1; // Only one slave IC
|
||||
configLocation->externalEnableOperationalState = opStateExtNormal; // Go to normal enable mode
|
||||
configLocation->chargeEnableOperationalState = opStateChargingModeCharging;// Go to charging mode when a charger is connected
|
||||
configLocation->powerDownDelay = 3000; // Wait only minimal to turn off
|
||||
|
||||
configLocation->noOfCellsPerModule = 8; // Number of cell levels monitored per LTC68XX
|
||||
configLocation->lastICNoOfCells = 0;
|
||||
configLocation->lastICMask = 0;
|
||||
configLocation->humidityICType = 0;
|
||||
|
||||
|
||||
#elif ENNOID_SS
|
||||
configLocation->noOfCellsSeries = 8; // Total number of cells in series in the battery pack
|
||||
configLocation->noOfCellsParallel = 10; // Number of cells in parallel
|
||||
configLocation->noOfParallelModules = 1; // Number of parallel modules
|
||||
configLocation->batteryCapacity = 22.00f; // XXAh battery
|
||||
configLocation->cellHardUnderVoltage = 2.30f; // Worst case X.XXV as lowest cell voltage
|
||||
configLocation->cellHardOverVoltage = 4.20f; // Worst case X.XXV as highest cell voltage
|
||||
configLocation->cellLCSoftUnderVoltage = 2.70f; // Lowest cell voltage X.XXV.
|
||||
configLocation->cellSoftOverVoltage = 4.15f; // Normal highest cell voltage X.XXV.
|
||||
configLocation->cellBalanceDifferenceThreshold = 0.01f; // Start balancing @ XmV difference, stop if below.
|
||||
configLocation->cellBalanceStart = 4.1f; // Start balancing above X.XXV.
|
||||
configLocation->cellBalanceAllTime = false; // Enable balancing under all opstate
|
||||
configLocation->cellThrottleUpperStart = 0.03f; // Upper range of cell voltage for charge throttling.
|
||||
configLocation->cellThrottleLowerStart = 0.20f; // Lower range of cell voltage for discharge throttling.
|
||||
configLocation->cellThrottleUpperMargin = 0.01f; // Margin of throttle from upper soft limits.
|
||||
configLocation->cellThrottleLowerMargin = 0.50f; // Margin of throttle from lower soft limits.
|
||||
configLocation->packVoltageDataSource = sourcePackVoltageISL28022_2_BatteryIn; // Packvoltage source.
|
||||
configLocation->packCurrentDataSource = sourcePackCurrentLowCurrentShunt; // The pack current is the same as the current through the low current shunt
|
||||
configLocation->buzzerSignalSource = buzzerSourceOn; // Stores what source shoud be taken to trigger
|
||||
configLocation->buzzerSignalPersistant = false; // Stores whether the buzzer should stay on after triggering
|
||||
configLocation->shuntLCFactor = -0.0052f; // Shunt factor low current
|
||||
configLocation->voltageLCFactor = 1.35f; // Pack voltage factor
|
||||
configLocation->voltageLCOffset = 0; // Pack voltage offset
|
||||
configLocation->loadVoltageFactor = 29.8f; // Load voltage factor
|
||||
configLocation->loadVoltageOffset = 0.0f; // Load voltage offset
|
||||
configLocation->chargerVoltageFactor = 29.8f; // Charger voltage factor
|
||||
configLocation->chargerVoltageOffset = 0.0f; // Charger voltage offset
|
||||
configLocation->throttleChargeIncreaseRate = 1; // Percentage charge throttle increase rate per 100ms (cell voltage loop time)
|
||||
configLocation->throttleDisChargeIncreaseRate = 2; // Percentage discharge throttle increase rate per 100ms (cell voltage loop time)
|
||||
configLocation->cellBalanceUpdateInterval = 4*1000; // Keep calculated resistors enabled for this amount of time in miliseconds.
|
||||
configLocation->maxSimultaneousDischargingCells = 5; // Allow a maximum of X cells simultinous discharging trough bleeding resistors.
|
||||
configLocation->timeoutDischargeRetry = 10*1000; // Wait for X seconds before retrying to enable load.
|
||||
configLocation->hysteresisDischarge = 0.02f; // Lowest cell should rise XXmV before output is re enabled.
|
||||
configLocation->timeoutChargeRetry = 30*1000; // Wait for XX seconds before retrying to enable charger.
|
||||
configLocation->hysteresisCharge = 0.01f; // Highest cell should lower XXmV before charger is re enabled.
|
||||
configLocation->timeoutChargeCompleted = 30*60*1000; // Wait for XX minutes before setting charge state to charged.
|
||||
configLocation->timeoutChargingCompletedMinimalMismatch = 6*1000; // If cell mismatch is under threshold and (charging is not allowed) wait this delay time to set "charged" state.
|
||||
configLocation->maxMismatchThreshold = 0.010f; // If mismatch is under this threshold for timeoutChargingCompletedMinimalMismatch determin fully charged.
|
||||
configLocation->chargerEnabledThreshold = 0.5f; // If charge current > X.XA stay in charging mode and dont power off.
|
||||
configLocation->timeoutChargerDisconnected = 2000; // Wait for X seconds to respond to charger disconnect.
|
||||
configLocation->minimalPrechargePercentage = 0.90f; // output should be at a minimal of 80% of input voltage.
|
||||
configLocation->timeoutLCPreCharge = 1.5*1000; // Precharge error timeout, allow 1.5 seconds pre-charge time before declaring load error.
|
||||
configLocation->maxAllowedCurrent = 1000.0f; // Allow max XXXA trough BMS.
|
||||
configLocation->allowedTempBattDischargingMax = 105.0f; // Max battery temperature where discharging is still allowed
|
||||
configLocation->allowedTempBattDischargingMin = 0.0f; // Min battery temperature where discharging is still allowed
|
||||
configLocation->allowedTempBattChargingMax = 105.0f; // Max battery temperature where charging is still allowed
|
||||
configLocation->allowedTempBattChargingMin = 0.0f; // Min battery temperature where charging is still allowed
|
||||
configLocation->allowedTempBattCoolingMax = 5.0f; // Max battery temperature where cooling is activated
|
||||
configLocation->allowedTempBattCoolingMin = 50.0f; // Min battery temperature where heating is activated
|
||||
configLocation->allowedTempBMSMax = 80.0f; // Max BMS operational temperature
|
||||
configLocation->allowedTempBMSMin = 0.0f; // Min BMS operational temperature
|
||||
configLocation->displayTimeoutBatteryDead = 5000; // Show battery dead symbol X seconds before going to powerdown in cell voltage error state.
|
||||
configLocation->displayTimeoutBatteryError = 5000; // Show error symbol for X seconds before going to powerdown in general error state.
|
||||
configLocation->displayTimeoutBatteryErrorPreCharge = 10000; // Show pre charge error for XX seconds.
|
||||
configLocation->displayTimeoutSplashScreen = 3000; // Display / INIT splash screen time.
|
||||
configLocation->displayStyle = advanced; // Display style used for showing the SSD1306 data
|
||||
configLocation->maxUnderAndOverVoltageErrorCount = 5; // Max count of hard cell voltage errors.
|
||||
configLocation->maxUnderAndOverTemperatureErrorCount = 5; // Max count of hard cell voltage errors.
|
||||
configLocation->notUsedCurrentThreshold = 1.0f; // If abs(packcurrent) < X.XA consider pack as not used.
|
||||
configLocation->notUsedTimeout = 20*60*1000; // If pack is not used for longer than XX minutes disable bms.
|
||||
configLocation->stateOfChargeStoreInterval = 60*1000; // Interval in ms to store state of charge information.
|
||||
configLocation->stateOfChargeMethod = socCoulomb; // Use coulomb counting for SoC calculation
|
||||
configLocation->CANID = 10; // CAN ID for CAN communication.
|
||||
configLocation->CANIDStyle = CANIDStyleVESC; // CAN ID default Style.
|
||||
configLocation->canBusSpeed = canSpeedBaud500k; // 500k CAN baud
|
||||
configLocation->emitStatusOverCAN = false; // Send status over can.
|
||||
configLocation->emitStatusProtocol = canEmitProtocolDieBieEngineering; // Can emit protocol set to MG style for backwards compatibility
|
||||
configLocation->tempEnableMaskBMS = 0x0001; // Bitwise select what sensor to enable for the BMS (internal sensors).
|
||||
configLocation->tempEnableMaskBattery = 0xFFFF; // Bitwise select what sensor to enable for the battery (external sensors).
|
||||
configLocation->tempEnableMaskExpansion = 0xFFFF; // Bitwise select what sensor to enable for the battery (external sensors).
|
||||
configLocation->noOfTempSensorPerModule = 0; // Number of temperature sensors monitored per LTC68XX
|
||||
configLocation->noOfExpansionBoard = 0; // Number of expansion board
|
||||
configLocation->noOfTempSensorPerExpansionBoard = 0; // Number of temperature sensors monitored per expansion board
|
||||
configLocation->LCUseDischarge = enabled; // Enable or disable the solid state output
|
||||
configLocation->LCUsePrecharge = enabled; // Use precharge before enabling main output
|
||||
configLocation->allowChargingDuringDischarge = false; // Allow the battery to be charged in normal mode
|
||||
configLocation->allowForceOn = false; // Allow the BMS to be forced ON by long actuation of the power button
|
||||
configLocation->pulseToggleButton = true; // Select either pulse or toggle power button
|
||||
configLocation->useCANSafetyInput = false; // Use the safety input status from CAN
|
||||
configLocation->useCANDelayedPowerDown = false; // Use delayed power down
|
||||
configLocation->NTCTopResistor[modConfigNTCGroupLTCExt] = 100000; // NTC Pullup resistor value
|
||||
configLocation->NTCTopResistor[modConfigNTCGroupMasterPCB] = 100000; // NTC Pullup resistor value
|
||||
configLocation->NTCTopResistor[modConfigNTCGroupExp] = 100000; // NTC Pullup resistor value
|
||||
configLocation->NTC25DegResistance[modConfigNTCGroupLTCExt] = 100000; // NTC resistance at 25 degree
|
||||
configLocation->NTC25DegResistance[modConfigNTCGroupMasterPCB] = 100000; // NTC resistance at 25 degree
|
||||
configLocation->NTC25DegResistance[modConfigNTCGroupExp] = 100000; // NTC resistance at 25 degree
|
||||
configLocation->NTCBetaFactor[modConfigNTCGroupLTCExt] = 4250; // NTC Beta factor
|
||||
configLocation->NTCBetaFactor[modConfigNTCGroupMasterPCB] = 4250; // NTC Beta factor
|
||||
configLocation->NTCBetaFactor[modConfigNTCGroupExp] = 4250; // NTC Beta factor
|
||||
configLocation->cellMonitorType = CELL_MON_LTC6813_1; // Use the new cell voltage monitor
|
||||
configLocation->cellMonitorICCount = 1; // Only one slave IC
|
||||
configLocation->externalEnableOperationalState = opStateExtNormal; // Go to normal enable mode
|
||||
configLocation->chargeEnableOperationalState = opStateChargingModeCharging;// Go to charging mode when a charger is connected
|
||||
configLocation->powerDownDelay = 3000; // Wait only minimal to turn off
|
||||
|
||||
configLocation->noOfCellsPerModule = 18; // Number of cell levels monitored per LTC68XX
|
||||
configLocation->lastICNoOfCells = 0;
|
||||
configLocation->lastICMask = 0;
|
||||
configLocation->humidityICType = 2;
|
||||
|
||||
#elif ENNOID_SS_LITE
|
||||
configLocation->noOfCellsSeries = 18; // Total number of cells in series in the battery pack
|
||||
configLocation->noOfCellsParallel = 10; // Number of cells in parallel
|
||||
configLocation->noOfParallelModules = 1; // Number of parallel modules
|
||||
configLocation->batteryCapacity = 22.00f; // XXAh battery
|
||||
configLocation->cellHardUnderVoltage = 2.30f; // Worst case X.XXV as lowest cell voltage
|
||||
configLocation->cellHardOverVoltage = 4.20f; // Worst case X.XXV as highest cell voltage
|
||||
configLocation->cellLCSoftUnderVoltage = 2.70f; // Lowest cell voltage X.XXV.
|
||||
configLocation->cellSoftOverVoltage = 4.15f; // Normal highest cell voltage X.XXV.
|
||||
configLocation->cellBalanceDifferenceThreshold = 0.01f; // Start balancing @ XmV difference, stop if below.
|
||||
configLocation->cellBalanceStart = 4.1f; // Start balancing above X.XXV.
|
||||
configLocation->cellBalanceAllTime = false; // Enable balancing under all opstate
|
||||
configLocation->cellThrottleUpperStart = 0.03f; // Upper range of cell voltage for charge throttling.
|
||||
configLocation->cellThrottleLowerStart = 0.20f; // Lower range of cell voltage for discharge throttling.
|
||||
configLocation->cellThrottleUpperMargin = 0.01f; // Margin of throttle from upper soft limits.
|
||||
configLocation->cellThrottleLowerMargin = 0.50f; // Margin of throttle from lower soft limits.
|
||||
configLocation->packVoltageDataSource = sourcePackVoltageISL28022_2_BatteryIn; // Packvoltage source.
|
||||
configLocation->packCurrentDataSource = sourcePackCurrentLowCurrentShunt; // The pack current is the same as the current through the low current shunt
|
||||
configLocation->buzzerSignalSource = buzzerSourceOn; // Stores what source shoud be taken to trigger
|
||||
configLocation->buzzerSignalPersistant = false; // Stores whether the buzzer should stay on after triggering
|
||||
configLocation->shuntLCFactor = -0.0052f; // Shunt factor low current
|
||||
configLocation->voltageLCFactor = 1.35f; // Pack voltage factor
|
||||
configLocation->voltageLCOffset = 0; // Pack voltage offset
|
||||
configLocation->loadVoltageFactor = 29.8f; // Load voltage factor
|
||||
configLocation->loadVoltageOffset = 0.0f; // Load voltage offset
|
||||
configLocation->chargerVoltageFactor = 29.8f; // Charger voltage factor
|
||||
configLocation->chargerVoltageOffset = 0.0f; // Charger voltage offset
|
||||
configLocation->throttleChargeIncreaseRate = 1; // Percentage charge throttle increase rate per 100ms (cell voltage loop time)
|
||||
configLocation->throttleDisChargeIncreaseRate = 2; // Percentage discharge throttle increase rate per 100ms (cell voltage loop time)
|
||||
configLocation->cellBalanceUpdateInterval = 4*1000; // Keep calculated resistors enabled for this amount of time in miliseconds.
|
||||
configLocation->maxSimultaneousDischargingCells = 5; // Allow a maximum of X cells simultinous discharging trough bleeding resistors.
|
||||
configLocation->timeoutDischargeRetry = 10*1000; // Wait for X seconds before retrying to enable load.
|
||||
configLocation->hysteresisDischarge = 0.02f; // Lowest cell should rise XXmV before output is re enabled.
|
||||
configLocation->timeoutChargeRetry = 30*1000; // Wait for XX seconds before retrying to enable charger.
|
||||
configLocation->hysteresisCharge = 0.01f; // Highest cell should lower XXmV before charger is re enabled.
|
||||
configLocation->timeoutChargeCompleted = 30*60*1000; // Wait for XX minutes before setting charge state to charged.
|
||||
configLocation->timeoutChargingCompletedMinimalMismatch = 6*1000; // If cell mismatch is under threshold and (charging is not allowed) wait this delay time to set "charged" state.
|
||||
configLocation->maxMismatchThreshold = 0.010f; // If mismatch is under this threshold for timeoutChargingCompletedMinimalMismatch determin fully charged.
|
||||
configLocation->chargerEnabledThreshold = 0.5f; // If charge current > X.XA stay in charging mode and dont power off.
|
||||
configLocation->timeoutChargerDisconnected = 2000; // Wait for X seconds to respond to charger disconnect.
|
||||
configLocation->minimalPrechargePercentage = 0.90f; // output should be at a minimal of 80% of input voltage.
|
||||
configLocation->timeoutLCPreCharge = 1.5*1000; // Precharge error timeout, allow 1.5 seconds pre-charge time before declaring load error.
|
||||
configLocation->maxAllowedCurrent = 1000.0f; // Allow max XXXA trough BMS.
|
||||
configLocation->allowedTempBattDischargingMax = 105.0f; // Max battery temperature where discharging is still allowed
|
||||
configLocation->allowedTempBattDischargingMin = 0.0f; // Min battery temperature where discharging is still allowed
|
||||
configLocation->allowedTempBattChargingMax = 105.0f; // Max battery temperature where charging is still allowed
|
||||
configLocation->allowedTempBattChargingMin = 0.0f; // Min battery temperature where charging is still allowed
|
||||
configLocation->allowedTempBattCoolingMax = 5.0f; // Max battery temperature where cooling is activated
|
||||
configLocation->allowedTempBattCoolingMin = 50.0f; // Min battery temperature where heating is activated
|
||||
configLocation->allowedTempBMSMax = 80.0f; // Max BMS operational temperature
|
||||
configLocation->allowedTempBMSMin = 0.0f; // Min BMS operational temperature
|
||||
configLocation->displayTimeoutBatteryDead = 5000; // Show battery dead symbol X seconds before going to powerdown in cell voltage error state.
|
||||
configLocation->displayTimeoutBatteryError = 5000; // Show error symbol for X seconds before going to powerdown in general error state.
|
||||
configLocation->displayTimeoutBatteryErrorPreCharge = 10000; // Show pre charge error for XX seconds.
|
||||
configLocation->displayTimeoutSplashScreen = 3000; // Display / INIT splash screen time.
|
||||
configLocation->displayStyle = advanced; // Display style used for showing the SSD1306 data
|
||||
configLocation->maxUnderAndOverVoltageErrorCount = 5; // Max count of hard cell voltage errors.
|
||||
configLocation->maxUnderAndOverTemperatureErrorCount = 5; // Max count of hard cell voltage errors.
|
||||
configLocation->notUsedCurrentThreshold = 1.0f; // If abs(packcurrent) < X.XA consider pack as not used.
|
||||
configLocation->notUsedTimeout = 20*60*1000; // If pack is not used for longer than XX minutes disable bms.
|
||||
configLocation->stateOfChargeStoreInterval = 60*1000; // Interval in ms to store state of charge information.
|
||||
configLocation->stateOfChargeMethod = socCoulomb; // Use coulomb counting for SoC calculation
|
||||
configLocation->CANID = 10; // CAN ID for CAN communication.
|
||||
configLocation->CANIDStyle = CANIDStyleVESC; // CAN ID default Style.
|
||||
configLocation->canBusSpeed = canSpeedBaud500k; // 500k CAN baud
|
||||
configLocation->emitStatusOverCAN = false; // Send status over can.
|
||||
configLocation->emitStatusProtocol = canEmitProtocolDieBieEngineering; // Can emit protocol set to MG style for backwards compatibility
|
||||
configLocation->tempEnableMaskBMS = 0x0001; // Bitwise select what sensor to enable for the BMS (internal sensors).
|
||||
configLocation->tempEnableMaskBattery = 0xFFFF; // Bitwise select what sensor to enable for the battery (external sensors).
|
||||
configLocation->tempEnableMaskExpansion = 0xFFFF; // Bitwise select what sensor to enable for the battery (external sensors).
|
||||
configLocation->noOfTempSensorPerModule = 0; // Number of temperature sensors monitored per LTC68XX
|
||||
configLocation->noOfExpansionBoard = 0; // Number of expansion board
|
||||
configLocation->noOfTempSensorPerExpansionBoard = 0; // Number of temperature sensors monitored per expansion board
|
||||
configLocation->LCUseDischarge = disabled; // Enable or disable the solid state output
|
||||
configLocation->LCUsePrecharge = disabled; // Use precharge before enabling main output
|
||||
configLocation->allowChargingDuringDischarge = false; // Allow the battery to be charged in normal mode
|
||||
configLocation->allowForceOn = false; // Allow the BMS to be forced ON by long actuation of the power button
|
||||
configLocation->pulseToggleButton = true; // Select either pulse or toggle power button
|
||||
configLocation->useCANSafetyInput = false; // Use the safety input status from CAN
|
||||
configLocation->useCANDelayedPowerDown = false; // Use delayed power down
|
||||
configLocation->NTCTopResistor[modConfigNTCGroupLTCExt] = 100000; // NTC Pullup resistor value
|
||||
configLocation->NTCTopResistor[modConfigNTCGroupMasterPCB] = 100000; // NTC Pullup resistor value
|
||||
configLocation->NTCTopResistor[modConfigNTCGroupExp] = 100000; // NTC Pullup resistor value
|
||||
configLocation->NTC25DegResistance[modConfigNTCGroupLTCExt] = 100000; // NTC resistance at 25 degree
|
||||
configLocation->NTC25DegResistance[modConfigNTCGroupMasterPCB] = 100000; // NTC resistance at 25 degree
|
||||
configLocation->NTC25DegResistance[modConfigNTCGroupExp] = 100000; // NTC resistance at 25 degree
|
||||
configLocation->NTCBetaFactor[modConfigNTCGroupLTCExt] = 4250; // NTC Beta factor
|
||||
configLocation->NTCBetaFactor[modConfigNTCGroupMasterPCB] = 4250; // NTC Beta factor
|
||||
configLocation->NTCBetaFactor[modConfigNTCGroupExp] = 4250; // NTC Beta factor
|
||||
configLocation->cellMonitorType = CELL_MON_LTC6813_1; // Use the new cell voltage monitor
|
||||
configLocation->cellMonitorICCount = 1; // Only one slave IC
|
||||
configLocation->externalEnableOperationalState = opStateExtNormal; // Go to normal enable mode
|
||||
configLocation->chargeEnableOperationalState = opStateChargingModeCharging;// Go to charging mode when a charger is connected
|
||||
configLocation->powerDownDelay = 3000; // Wait only minimal to turn off
|
||||
|
||||
configLocation->noOfCellsPerModule = 18; // Number of cell levels monitored per LTC68XX
|
||||
configLocation->lastICNoOfCells = 0;
|
||||
configLocation->lastICMask = 0;
|
||||
configLocation->humidityICType = 2;
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
61
Core/Src/modDelay.c
Normal file
61
Core/Src/modDelay.c
Normal file
@@ -0,0 +1,61 @@
|
||||
#include "modDelay.h"
|
||||
|
||||
static uint32_t hmsCnt = 0;
|
||||
|
||||
void modDelayInit(void) {
|
||||
SystemCoreClockUpdate();
|
||||
|
||||
//SystemCoreClock / 1000
|
||||
if(SysTick_Config(72000)){
|
||||
while(1); //Error setting SysTick.
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t modDelayTick1ms(uint32_t *last, uint32_t ticks) {
|
||||
if((uint32_t)(HAL_GetTick() - *last) >= ticks)
|
||||
{
|
||||
*last = HAL_GetTick();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8_t modDelayTick100ms(uint32_t *last, uint32_t ticks) {
|
||||
static uint32_t msTicks = 0;
|
||||
|
||||
if(modDelayTick1ms(&msTicks,99))
|
||||
hmsCnt++;
|
||||
|
||||
if((uint32_t)(hmsCnt - *last) >= ticks)
|
||||
{
|
||||
*last = hmsCnt;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8_t modDelayTick1msNoRST(uint32_t *last, uint32_t ticks) {
|
||||
if((uint32_t)(HAL_GetTick() - *last) >= ticks)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8_t modDelayTick100msNoRST(uint32_t *last, uint32_t ticks) {
|
||||
static uint32_t msTicks = 0;
|
||||
|
||||
if(modDelayTick1msNoRST(&msTicks,99))
|
||||
hmsCnt++;
|
||||
|
||||
if((uint32_t)(hmsCnt - *last) >= ticks)
|
||||
{
|
||||
*last = hmsCnt;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
383
Core/Src/modFlash.c
Normal file
383
Core/Src/modFlash.c
Normal file
@@ -0,0 +1,383 @@
|
||||
#include "modFlash.h"
|
||||
|
||||
static const uint32_t flash_addr[FLASH_PAGES] = {
|
||||
ADDR_FLASH_PAGE_0,
|
||||
ADDR_FLASH_PAGE_1,
|
||||
ADDR_FLASH_PAGE_2,
|
||||
ADDR_FLASH_PAGE_3,
|
||||
ADDR_FLASH_PAGE_4,
|
||||
ADDR_FLASH_PAGE_5,
|
||||
ADDR_FLASH_PAGE_6,
|
||||
ADDR_FLASH_PAGE_7,
|
||||
ADDR_FLASH_PAGE_8,
|
||||
ADDR_FLASH_PAGE_9,
|
||||
ADDR_FLASH_PAGE_10,
|
||||
ADDR_FLASH_PAGE_11,
|
||||
ADDR_FLASH_PAGE_12,
|
||||
ADDR_FLASH_PAGE_13,
|
||||
ADDR_FLASH_PAGE_14,
|
||||
ADDR_FLASH_PAGE_15,
|
||||
ADDR_FLASH_PAGE_16,
|
||||
ADDR_FLASH_PAGE_17,
|
||||
ADDR_FLASH_PAGE_18,
|
||||
ADDR_FLASH_PAGE_19,
|
||||
ADDR_FLASH_PAGE_20,
|
||||
ADDR_FLASH_PAGE_21,
|
||||
ADDR_FLASH_PAGE_22,
|
||||
ADDR_FLASH_PAGE_23,
|
||||
ADDR_FLASH_PAGE_24,
|
||||
ADDR_FLASH_PAGE_25,
|
||||
ADDR_FLASH_PAGE_26,
|
||||
ADDR_FLASH_PAGE_27,
|
||||
ADDR_FLASH_PAGE_28,
|
||||
ADDR_FLASH_PAGE_29,
|
||||
ADDR_FLASH_PAGE_30,
|
||||
ADDR_FLASH_PAGE_31,
|
||||
ADDR_FLASH_PAGE_32,
|
||||
ADDR_FLASH_PAGE_33,
|
||||
ADDR_FLASH_PAGE_34,
|
||||
ADDR_FLASH_PAGE_35,
|
||||
ADDR_FLASH_PAGE_36,
|
||||
ADDR_FLASH_PAGE_37,
|
||||
ADDR_FLASH_PAGE_38,
|
||||
ADDR_FLASH_PAGE_39,
|
||||
ADDR_FLASH_PAGE_40,
|
||||
ADDR_FLASH_PAGE_41,
|
||||
ADDR_FLASH_PAGE_42,
|
||||
ADDR_FLASH_PAGE_43,
|
||||
ADDR_FLASH_PAGE_44,
|
||||
ADDR_FLASH_PAGE_45,
|
||||
ADDR_FLASH_PAGE_46,
|
||||
ADDR_FLASH_PAGE_47,
|
||||
ADDR_FLASH_PAGE_48,
|
||||
ADDR_FLASH_PAGE_49,
|
||||
ADDR_FLASH_PAGE_50,
|
||||
ADDR_FLASH_PAGE_51,
|
||||
ADDR_FLASH_PAGE_52,
|
||||
ADDR_FLASH_PAGE_53,
|
||||
ADDR_FLASH_PAGE_54,
|
||||
ADDR_FLASH_PAGE_55,
|
||||
ADDR_FLASH_PAGE_56,
|
||||
ADDR_FLASH_PAGE_57,
|
||||
ADDR_FLASH_PAGE_58,
|
||||
ADDR_FLASH_PAGE_59,
|
||||
ADDR_FLASH_PAGE_60,
|
||||
ADDR_FLASH_PAGE_61,
|
||||
ADDR_FLASH_PAGE_62,
|
||||
ADDR_FLASH_PAGE_63,
|
||||
ADDR_FLASH_PAGE_64,
|
||||
ADDR_FLASH_PAGE_65,
|
||||
ADDR_FLASH_PAGE_66,
|
||||
ADDR_FLASH_PAGE_67,
|
||||
ADDR_FLASH_PAGE_68,
|
||||
ADDR_FLASH_PAGE_69,
|
||||
ADDR_FLASH_PAGE_70,
|
||||
ADDR_FLASH_PAGE_71,
|
||||
ADDR_FLASH_PAGE_72,
|
||||
ADDR_FLASH_PAGE_73,
|
||||
ADDR_FLASH_PAGE_74,
|
||||
ADDR_FLASH_PAGE_75,
|
||||
ADDR_FLASH_PAGE_76,
|
||||
ADDR_FLASH_PAGE_77,
|
||||
ADDR_FLASH_PAGE_78,
|
||||
ADDR_FLASH_PAGE_79,
|
||||
ADDR_FLASH_PAGE_80,
|
||||
ADDR_FLASH_PAGE_81,
|
||||
ADDR_FLASH_PAGE_82,
|
||||
ADDR_FLASH_PAGE_83,
|
||||
ADDR_FLASH_PAGE_84,
|
||||
ADDR_FLASH_PAGE_85,
|
||||
ADDR_FLASH_PAGE_86,
|
||||
ADDR_FLASH_PAGE_87,
|
||||
ADDR_FLASH_PAGE_88,
|
||||
ADDR_FLASH_PAGE_89,
|
||||
ADDR_FLASH_PAGE_90,
|
||||
ADDR_FLASH_PAGE_91,
|
||||
ADDR_FLASH_PAGE_92,
|
||||
ADDR_FLASH_PAGE_93,
|
||||
ADDR_FLASH_PAGE_94,
|
||||
ADDR_FLASH_PAGE_95,
|
||||
ADDR_FLASH_PAGE_96,
|
||||
ADDR_FLASH_PAGE_97,
|
||||
ADDR_FLASH_PAGE_98,
|
||||
ADDR_FLASH_PAGE_99,
|
||||
ADDR_FLASH_PAGE_100,
|
||||
ADDR_FLASH_PAGE_101,
|
||||
ADDR_FLASH_PAGE_102,
|
||||
ADDR_FLASH_PAGE_103,
|
||||
ADDR_FLASH_PAGE_104,
|
||||
ADDR_FLASH_PAGE_105,
|
||||
ADDR_FLASH_PAGE_106,
|
||||
ADDR_FLASH_PAGE_107,
|
||||
ADDR_FLASH_PAGE_108,
|
||||
ADDR_FLASH_PAGE_109,
|
||||
ADDR_FLASH_PAGE_110,
|
||||
ADDR_FLASH_PAGE_111,
|
||||
ADDR_FLASH_PAGE_112,
|
||||
ADDR_FLASH_PAGE_113,
|
||||
ADDR_FLASH_PAGE_114,
|
||||
ADDR_FLASH_PAGE_115,
|
||||
ADDR_FLASH_PAGE_116,
|
||||
ADDR_FLASH_PAGE_117,
|
||||
ADDR_FLASH_PAGE_118,
|
||||
ADDR_FLASH_PAGE_119,
|
||||
ADDR_FLASH_PAGE_120,
|
||||
ADDR_FLASH_PAGE_121,
|
||||
ADDR_FLASH_PAGE_122,
|
||||
ADDR_FLASH_PAGE_123,
|
||||
ADDR_FLASH_PAGE_124,
|
||||
ADDR_FLASH_PAGE_125,
|
||||
ADDR_FLASH_PAGE_126,
|
||||
ADDR_FLASH_PAGE_127
|
||||
};
|
||||
|
||||
TIM_HandleTypeDef htim2;
|
||||
TIM_HandleTypeDef htim6;
|
||||
UART_HandleTypeDef huart2;
|
||||
|
||||
uint16_t modFlashEraseNewAppData(uint32_t new_app_size) {
|
||||
uint32_t page_error = 0;
|
||||
|
||||
new_app_size += flash_addr[NEW_APP_BASE];
|
||||
|
||||
HAL_FLASH_Unlock();
|
||||
|
||||
FLASH_EraseInitTypeDef flashEraseInit;
|
||||
//flashEraseInit.NbPages = 1;
|
||||
flashEraseInit.NbPages = NEW_APP_SECTORS;
|
||||
|
||||
flashEraseInit.PageAddress = flash_addr[NEW_APP_BASE];
|
||||
flashEraseInit.TypeErase = FLASH_TYPEERASE_PAGES;
|
||||
|
||||
flashEraseInit.PageAddress = flash_addr[NEW_APP_BASE];
|
||||
|
||||
uint16_t res = HAL_FLASHEx_Erase(&flashEraseInit,&page_error);
|
||||
if (res != HAL_OK) {
|
||||
return res;
|
||||
}
|
||||
HAL_FLASH_Lock();
|
||||
return HAL_OK;
|
||||
|
||||
|
||||
|
||||
// for (int i = 0;i < NEW_APP_SECTORS;i++) {
|
||||
// if (new_app_size > flash_addr[NEW_APP_BASE + i]) {
|
||||
// flashEraseInit.PageAddress = flash_addr[NEW_APP_BASE + i];
|
||||
// uint16_t res = HAL_FLASHEx_Erase(&flashEraseInit,&page_error);
|
||||
// if (res != HAL_OK) {
|
||||
// return res;
|
||||
// }
|
||||
// } else {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return HAL_OK;
|
||||
}
|
||||
|
||||
uint16_t modFlashEraseMainAppData(uint32_t new_app_size) {
|
||||
uint32_t page_error = 0;
|
||||
HAL_FLASH_Unlock();
|
||||
new_app_size += flash_addr[MAIN_APP_BASE];
|
||||
|
||||
FLASH_EraseInitTypeDef flashEraseInit;
|
||||
flashEraseInit.NbPages = 1;
|
||||
flashEraseInit.PageAddress = flash_addr[MAIN_APP_BASE];
|
||||
flashEraseInit.TypeErase = FLASH_TYPEERASE_PAGES;
|
||||
|
||||
for (int i = 0;i < NEW_APP_SECTORS;i++) {
|
||||
if (new_app_size > flash_addr[MAIN_APP_BASE + i]) {
|
||||
flashEraseInit.PageAddress = flash_addr[NEW_APP_BASE + i];
|
||||
uint16_t res = HAL_FLASHEx_Erase(&flashEraseInit,&page_error);
|
||||
|
||||
if (res != HAL_OK) {
|
||||
return res;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
HAL_FLASH_Lock();
|
||||
return HAL_OK;
|
||||
}
|
||||
|
||||
uint16_t modFlashWriteByte(uint32_t offset, uint8_t data, bool lastByte) {
|
||||
static bool highLowByte;
|
||||
static bool newStoredData;
|
||||
static uint32_t newAddressOffset;
|
||||
static uint32_t newData;
|
||||
uint16_t returnValue = HAL_OK;
|
||||
|
||||
|
||||
|
||||
if(offset != 0){
|
||||
highLowByte = (offset & 0x01) ? true : false;
|
||||
newAddressOffset = (offset & 0xFFFFFFFE);
|
||||
|
||||
if(!highLowByte)
|
||||
newData = data;
|
||||
else
|
||||
newData |= (data << 8);
|
||||
newStoredData = true;
|
||||
}
|
||||
|
||||
if((highLowByte || lastByte) && newStoredData) {
|
||||
returnValue = HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD,newAddressOffset,newData);
|
||||
newStoredData = false;
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
uint16_t modFlashWriteNewAppData(uint32_t offset, uint8_t *data, uint32_t len) {
|
||||
uint16_t returnVal = HAL_OK;
|
||||
HAL_FLASH_Unlock();
|
||||
for (uint32_t i = 0;i < len;i++) {
|
||||
uint16_t res = modFlashWriteByte(flash_addr[NEW_APP_BASE] + offset + i, data[i],false);
|
||||
if (res != HAL_OK) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
HAL_FLASH_Lock();
|
||||
return returnVal;
|
||||
}
|
||||
|
||||
uint16_t modFlashCopyNewAppToMainApp(uint32_t offset, uint8_t *data, uint32_t len) {
|
||||
HAL_FLASH_Unlock();
|
||||
for (uint32_t i = 0;i < len;i++) {
|
||||
uint16_t res = modFlashWriteByte(flash_addr[NEW_APP_BASE] + offset + i, data[1],false);
|
||||
if (res != HAL_OK) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
modFlashWriteByte(0,0,true);
|
||||
HAL_FLASH_Lock();
|
||||
return HAL_OK;
|
||||
}
|
||||
|
||||
//void modFlashJumpToBootloader(void) {
|
||||
//
|
||||
// typedef void (*pFunction)(void);
|
||||
//
|
||||
// modFlashWriteByte(0,0,true);
|
||||
//
|
||||
// __HAL_RCC_CAN1_FORCE_RESET();
|
||||
// HAL_Delay(5);
|
||||
// __HAL_RCC_CAN1_RELEASE_RESET();
|
||||
// HAL_Delay(5);
|
||||
//
|
||||
// __HAL_RCC_USART2_FORCE_RESET();
|
||||
// HAL_Delay(5);
|
||||
// __HAL_RCC_USART2_RELEASE_RESET();
|
||||
// HAL_Delay(5);
|
||||
//
|
||||
// HAL_RCC_DeInit();
|
||||
//
|
||||
// pFunction jump_to_bootloader;
|
||||
//
|
||||
// // Variable that will be loaded with the start address of the application
|
||||
//// volatile uint32_t* jump_address;
|
||||
//// const volatile uint32_t* bootloader_address = (volatile uint32_t*)ADDR_FLASH_PAGE_110;//ADDR_FLASH_PAGE_100;
|
||||
////
|
||||
//// // Get jump address from application vector table
|
||||
//// jump_address = (volatile uint32_t*) bootloader_address[1];
|
||||
//
|
||||
// uint32_t JumpAddress;
|
||||
// JumpAddress = (uint32_t) *((__IO uint32_t*)ADDR_FLASH_PAGE_110);
|
||||
// jump_to_bootloader = (pFunction)(*(volatile uint32_t*) (ADDR_FLASH_PAGE_110+4u));
|
||||
//
|
||||
//
|
||||
//// // Load this address into function pointer
|
||||
//// jump_to_bootloader = (pFunction) jump_address;
|
||||
//
|
||||
// // Clear pending interrupts
|
||||
// SCB->ICSR = SCB_ICSR_PENDSVCLR_Msk;
|
||||
//
|
||||
// // Disable all interrupts
|
||||
// for(int i = 0;i < 8;i++) {
|
||||
// NVIC->ICER[i] = NVIC->IABR[i];
|
||||
// }
|
||||
//
|
||||
// SCB->VTOR = JumpAddress;
|
||||
// // Set stack pointer
|
||||
// //__set_MSP((uint32_t) (bootloader_address[0]));
|
||||
// __set_MSP(JumpAddress);
|
||||
//
|
||||
// // Jump to the bootloader
|
||||
// jump_to_bootloader();
|
||||
//}
|
||||
|
||||
//
|
||||
//typedef void (*pFunction)(void);
|
||||
//pFunction Jump_To_Application;
|
||||
|
||||
|
||||
//void modFlashJumpToBootloader(void)
|
||||
//{
|
||||
// uint32_t JumpAddress;
|
||||
//
|
||||
// HAL_DeInit();
|
||||
// HAL_RCC_DeInit();
|
||||
//
|
||||
// __disable_irq();
|
||||
//
|
||||
// JumpAddress = *( uint32_t*) (ADDR_FLASH_PAGE_110 + 4);
|
||||
// JumpAddress = 0x08037004;
|
||||
// Jump_To_Application = (pFunction)JumpAddress;
|
||||
// /* Initialize user application's Stack Pointer */
|
||||
// __set_MSP(*(__IO uint32_t*) ADDR_FLASH_PAGE_110);
|
||||
//
|
||||
// Jump_To_Application();
|
||||
|
||||
// uint32_t JumpAddress;
|
||||
// JumpAddress = (uint32_t) *((__IO uint32_t*)ADDR_FLASH_PAGE_110);
|
||||
// Jump_To_Application = (pFunction)(*(volatile uint32_t*) (0x08037000+4u));
|
||||
// __HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH();
|
||||
//
|
||||
// for(int i = 0;i < 8;i++) {
|
||||
// NVIC->ICER[i] = NVIC->IABR[i];
|
||||
// }
|
||||
//
|
||||
// SCB->ICSR = SCB_ICSR_PENDSVCLR_Msk;
|
||||
// SCB->VTOR = 0x08037000;
|
||||
// __set_MSP(0x08037000);
|
||||
//
|
||||
// Jump_To_Application();
|
||||
//}
|
||||
|
||||
void deinitEverything()
|
||||
{
|
||||
//-- reset peripherals to guarantee flawless start of user application
|
||||
HAL_TIM_Base_Stop_IT(&htim2);
|
||||
HAL_TIM_Base_Stop_IT(&htim6);
|
||||
MX_USB_DEVICE_DeInit();
|
||||
MX_FATFS_DeInit();
|
||||
HAL_UART_DeInit(&huart2);
|
||||
|
||||
HAL_RCC_DeInit();
|
||||
HAL_DeInit();
|
||||
SysTick->CTRL = 0;
|
||||
SysTick->LOAD = 0;
|
||||
SysTick->VAL = 0;
|
||||
}
|
||||
|
||||
void jumpToBootLoader(void)
|
||||
{
|
||||
uint32_t adr=ADDR_FLASH_PAGE_104;
|
||||
const JumpStruct* vector_p = (JumpStruct*)adr;
|
||||
|
||||
//Total_DeInit();
|
||||
deinitEverything();
|
||||
|
||||
/* let's do The Jump! */
|
||||
/* Jump, used asm to avoid stack optimization */
|
||||
asm("msr msp, %0; bx %1;" : : "r"(vector_p->stack_addr), "r"(vector_p->func_p));
|
||||
}
|
||||
|
||||
void modFlashJumpToMainApplication(void) {
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
|
||||
|
||||
537
Core/Src/modOperationalState.c
Normal file
537
Core/Src/modOperationalState.c
Normal file
@@ -0,0 +1,537 @@
|
||||
///*
|
||||
// Copyright 2017 - 2018 Danny Bokma danny@diebie.nl
|
||||
// Copyright 2019 - 2020 Kevin Dionne kevin.dionne@ennoid.me
|
||||
//
|
||||
// This file is part of the DieBieMS/ENNOID-BMS firmware.
|
||||
//
|
||||
// The DieBieMS/ENNOID-BMS firmware is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// The DieBieMS/ENNOID-BMS firmware is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
// */
|
||||
//
|
||||
//#include "modOperationalState.h"
|
||||
//
|
||||
//OperationalStateTypedef modOperationalStateLastState;
|
||||
//OperationalStateTypedef modOperationalStateCurrentState;
|
||||
//OperationalStateTypedef modOperationalStateNewState;
|
||||
//bms_fault_state modOperationalStateLastFaultState;
|
||||
//bms_fault_state modOperationalStateCurrentFaultState;
|
||||
//bms_fault_state modOperationalStateNewFaultState;
|
||||
//modPowerElectronicsPackOperationalCellStatesTypedef packOperationalCellStateLastErrorState;
|
||||
//modPowerElectronicsPackStateTypedef *modOperationalStatePackStatehandle;
|
||||
//modConfigGeneralConfigStructTypedef *modOperationalStateGeneralConfigHandle;
|
||||
//modStateOfChargeStructTypeDef *modOperationalStateGeneralStateOfCharge;
|
||||
////nc modDisplayDataTypedef modOperationalStateDisplayData;
|
||||
//uint32_t modOperationalStateChargerTimeout;
|
||||
//uint32_t modOperationalStateChargedTimeout;
|
||||
//uint32_t modOperationalStatePreChargeTimeout;
|
||||
//uint32_t modOperationalStateStartupDelay;
|
||||
//uint32_t modOperationalStateChargerDisconnectDetectDelay;
|
||||
//uint32_t modOperationalStateBatteryDeadDisplayTime;
|
||||
//uint32_t modOperationalStateErrorDisplayTime;
|
||||
//uint32_t modOperationalStateNotUsedResetDelay;
|
||||
//uint32_t modOperationalStateNotUsedTime;
|
||||
//uint32_t modOperationalStatePSPDisableDelay;
|
||||
//uint32_t modOperationalStateWatchDogCountdownLastTick;
|
||||
//bool modOperationalStateForceOn;
|
||||
//
|
||||
//void modOperationalStateInit(modPowerElectronicsPackStateTypedef *packState, modConfigGeneralConfigStructTypedef *generalConfigPointer, modStateOfChargeStructTypeDef *generalStateOfCharge) {
|
||||
// modOperationalStatePackStatehandle = packState;
|
||||
// modOperationalStateGeneralConfigHandle = generalConfigPointer;
|
||||
// modOperationalStateGeneralStateOfCharge = generalStateOfCharge;
|
||||
// modOperationalStateSetAllStates(OP_STATE_INIT);
|
||||
// modOperationalStateStartupDelay = HAL_GetTick();
|
||||
// modOperationalStateChargerDisconnectDetectDelay = HAL_GetTick();
|
||||
// packOperationalCellStateLastErrorState = PACK_STATE_NORMAL;
|
||||
// modOperationalStateForceOn = false;
|
||||
// //nc modDisplayInit();
|
||||
//
|
||||
// //Init Expansion temperature modules
|
||||
// //nc driverSWADC128D818Init(modOperationalStateGeneralConfigHandle->noOfExpansionBoard, 8);
|
||||
//
|
||||
// modOperationalStateNotUsedTime = HAL_GetTick();
|
||||
// modOperationalStateNotUsedResetDelay = HAL_GetTick();
|
||||
//};
|
||||
//
|
||||
//void modOperationalStateTask(void) {
|
||||
// switch(modOperationalStateCurrentState) {
|
||||
// case OP_STATE_INIT:
|
||||
// if(modPowerStateChargerDetected()) { // Check to detect charger
|
||||
// switch(modOperationalStateGeneralConfigHandle->chargeEnableOperationalState){
|
||||
// case opStateChargingModeCharging:
|
||||
// modOperationalStateSetNewState(OP_STATE_CHARGING); // Go to charge state
|
||||
// //nc modEffectChangeState(STAT_LED_POWER,STAT_FLASH); // Flash power LED when charging
|
||||
// modOperationalStateChargerDisconnectDetectDelay = HAL_GetTick();
|
||||
// break;
|
||||
// case opStateChargingModeNormal:
|
||||
// default:
|
||||
// modOperationalStateSetNewState(OP_STATE_PRE_CHARGE); // Prepare to goto operational state
|
||||
// //nc modEffectChangeState(STAT_LED_POWER,STAT_SET); // Turn LED on in normal operation
|
||||
// break;
|
||||
// }
|
||||
// }else if(modPowerStateButtonPressedOnTurnon()) { // Check if button was pressen on turn-on
|
||||
// modOperationalStateSetNewState(OP_STATE_PRE_CHARGE); // Prepare to goto operational state
|
||||
// //nc modEffectChangeState(STAT_LED_POWER,STAT_SET); // Turn LED on in normal operation
|
||||
// }else if(modOperationalStateNewState == OP_STATE_INIT){ // USB or CAN origin of turn-on
|
||||
// switch(modOperationalStateGeneralConfigHandle->externalEnableOperationalState){
|
||||
// case opStateExtNormal:
|
||||
// modOperationalStateSetNewState(OP_STATE_PRE_CHARGE); // Prepare to goto normal operational state
|
||||
// break;
|
||||
// case opStateExternal:
|
||||
// default:
|
||||
// modOperationalStateSetNewState(OP_STATE_EXTERNAL); // Serve external control
|
||||
// break;
|
||||
// }
|
||||
// //nc modEffectChangeState(STAT_LED_POWER,STAT_SET); // Turn LED on in normal operation
|
||||
// }
|
||||
//
|
||||
// if(modDelayTick1ms(&modOperationalStateStartupDelay,modOperationalStateGeneralConfigHandle->displayTimeoutSplashScreen)) {// Wait for a bit than update state. Also check voltage after main fuse? followed by going to error state if blown?
|
||||
// if(!modOperationalStatePackStatehandle->disChargeLCAllowed && !modPowerStateChargerDetected()) { // If discharge is not allowed
|
||||
// modOperationalStateSetNewState(OP_STATE_ERROR); // Then the battery is dead
|
||||
// modOperationalStateBatteryDeadDisplayTime = HAL_GetTick();
|
||||
// }
|
||||
// modOperationalStateUpdateStates(); // Sync states
|
||||
// };
|
||||
//
|
||||
// //nc modDisplayShowInfo(DISP_MODE_SPLASH,modOperationalStateDisplayData);
|
||||
// break;
|
||||
// case OP_STATE_CHARGING:
|
||||
// // If chargeAllowed = false -> operational state balancing
|
||||
// if(modOperationalStatePackStatehandle->balanceActive){
|
||||
// modOperationalStateSetNewState(OP_STATE_BALANCING);
|
||||
// }
|
||||
// modOperationalStateHandleChargerDisconnect(OP_STATE_POWER_DOWN);
|
||||
// modPowerElectronicsSetCharge(true);
|
||||
// if(modOperationalStatePackStatehandle->packCurrent >= 0.5f || modOperationalStatePackStatehandle->packCurrent >= modOperationalStateGeneralConfigHandle->chargerEnabledThreshold){
|
||||
// modPowerElectronicsSetChargePFET(true);
|
||||
// }else{
|
||||
// modPowerElectronicsSetChargePFET(false);
|
||||
// };
|
||||
// #if (ENNOID_HV || ENNOID_LV)
|
||||
// //Allow main contactors to close if load voltage is above pack voltage & below max allowed voltage, that means that the charger is connected to the load
|
||||
// if(modOperationalStatePackStatehandle->packVoltage-modOperationalStatePackStatehandle->loCurrentLoadVoltage < (modOperationalStatePackStatehandle->packVoltage*0.1f) && modOperationalStatePackStatehandle->loCurrentLoadVoltage < (modOperationalStateGeneralConfigHandle->noOfCellsSeries*modOperationalStateGeneralConfigHandle->cellHardOverVoltage+10)){
|
||||
// modPowerElectronicsSetDisCharge(true);
|
||||
// if(modOperationalStateGeneralConfigHandle->LCUsePrecharge==forced){
|
||||
// modPowerElectronicsSetPreCharge(true);
|
||||
// }
|
||||
// }
|
||||
// #endif
|
||||
// //Cooling/Heating
|
||||
// if(modOperationalStatePackStatehandle->coolingAllowed )
|
||||
// modPowerElectronicsSetCooling(true);
|
||||
// else{
|
||||
// modPowerElectronicsSetCooling(false);
|
||||
// }
|
||||
//
|
||||
// modOperationalStateUpdateStates();
|
||||
// //nc modOperationalStateDisplayData.StateOfCharge = modOperationalStateGeneralStateOfCharge->generalStateOfCharge;
|
||||
// //nc modOperationalStateDisplayData.Current = fabs(modOperationalStatePackStatehandle->packCurrent);
|
||||
// //nc modOperationalStateDisplayData.ChargerVoltage = fabs(modOperationalStatePackStatehandle->chargerVoltage);
|
||||
// //nc modDisplayShowInfo(DISP_MODE_CHARGE,modOperationalStateDisplayData);
|
||||
// break;
|
||||
// case OP_STATE_PRE_CHARGE:
|
||||
// // in case of timeout: disable pre charge & go to error state
|
||||
// if(modOperationalStateLastState != modOperationalStateCurrentState) { // If discharge is not allowed pre-charge will not be enabled, therefore reset timeout every task call. Also reset on first entry
|
||||
// modOperationalStatePreChargeTimeout = HAL_GetTick(); // Reset timeout
|
||||
// modPowerElectronicsSetDisCharge(false);
|
||||
// modPowerElectronicsSetCharge(false);
|
||||
// }
|
||||
//
|
||||
// if(modOperationalStatePackStatehandle->disChargeLCAllowed || modOperationalStateForceOn)
|
||||
// modPowerElectronicsSetPreCharge(true);
|
||||
// else{
|
||||
// modPowerElectronicsSetPreCharge(false);
|
||||
// modOperationalStatePreChargeTimeout = HAL_GetTick();
|
||||
// // if(modOperationalStateGeneralConfigHandle->buzzerSignalSource)
|
||||
// //nc modEffectChangeStateError(STAT_BUZZER,STAT_ERROR,modOperationalStatePackStatehandle->faultState);
|
||||
// // }
|
||||
//
|
||||
// if((modOperationalStatePackStatehandle->loCurrentLoadVoltage > modOperationalStatePackStatehandle->packVoltage*modOperationalStateGeneralConfigHandle->minimalPrechargePercentage) && (modOperationalStatePackStatehandle->disChargeLCAllowed || modOperationalStateForceOn)) {
|
||||
// if(modOperationalStateForceOn) {
|
||||
// modOperationalStateSetNewState(OP_STATE_FORCEON); // Goto force on
|
||||
// }else{
|
||||
// modOperationalStateSetNewState(OP_STATE_LOAD_ENABLED); // Goto normal load enabled operation
|
||||
// }
|
||||
// }else if(modDelayTick1ms(&modOperationalStatePreChargeTimeout,modOperationalStateGeneralConfigHandle->timeoutLCPreCharge)){
|
||||
// if(modOperationalStateGeneralConfigHandle->LCUsePrecharge>=1){
|
||||
// modOperationalStateSetNewState(OP_STATE_ERROR_PRECHARGE); // An error occured during pre charge
|
||||
// modOperationalStatePackStatehandle->faultState = FAULT_CODE_PRECHARGE_TIMEOUT;
|
||||
// }else
|
||||
// modOperationalStateSetNewState(OP_STATE_LOAD_ENABLED); // Goto normal load enabled operation
|
||||
// }
|
||||
//
|
||||
// modOperationalStateUpdateStates();
|
||||
// break;
|
||||
// case OP_STATE_LOAD_ENABLED:
|
||||
// if(modPowerElectronicsSetDisCharge(true)) {
|
||||
//
|
||||
// if(modOperationalStateGeneralConfigHandle->LCUsePrecharge==forced){
|
||||
// #if ENNOID_HV
|
||||
// modPowerElectronicsSetPreCharge(true);
|
||||
// #endif
|
||||
// }else{
|
||||
// modPowerElectronicsSetPreCharge(false);
|
||||
// }
|
||||
// if(modPowerStateChargerDetected()){
|
||||
// modPowerElectronicsSetCharge(modOperationalStateGeneralConfigHandle->allowChargingDuringDischarge);
|
||||
// if(modOperationalStatePackStatehandle->packCurrent >= 0.5f || modOperationalStatePackStatehandle->packCurrent >= modOperationalStateGeneralConfigHandle->chargerEnabledThreshold){
|
||||
// modPowerElectronicsSetChargePFET(true);
|
||||
// }
|
||||
// }else{
|
||||
// modPowerElectronicsSetCharge(false);
|
||||
// modPowerElectronicsSetChargePFET(false);
|
||||
// }
|
||||
// }else{
|
||||
// modOperationalStateSetNewState(OP_STATE_PRE_CHARGE);
|
||||
// modPowerElectronicsSetDisCharge(false);
|
||||
// modPowerElectronicsSetCharge(false);
|
||||
// modPowerElectronicsSetChargePFET(false);
|
||||
// }
|
||||
//
|
||||
// //nc modEffectChangeState(STAT_BUZZER,STAT_RESET);
|
||||
//
|
||||
// //Cooling/Heating
|
||||
// if(modOperationalStatePackStatehandle->coolingAllowed )
|
||||
// modPowerElectronicsSetCooling(true);
|
||||
// else{
|
||||
// modPowerElectronicsSetCooling(false);
|
||||
// }
|
||||
// //Charger detect
|
||||
// if(modPowerStateChargerDetected() && !modOperationalStateGeneralConfigHandle->allowChargingDuringDischarge) {
|
||||
// modOperationalStateSetNewState(OP_STATE_INIT);
|
||||
// modPowerElectronicsSetDisCharge(false);
|
||||
// modPowerElectronicsSetCharge(false);
|
||||
// };
|
||||
//
|
||||
//
|
||||
// // Battery is empty or battery temp is out of range?
|
||||
// if(!modOperationalStatePackStatehandle->disChargeLCAllowed) {
|
||||
// //modOperationalStateSetNewState(OP_STATE_ERROR);
|
||||
// modPowerElectronicsSetDisCharge(false);
|
||||
// modPowerElectronicsSetCharge(false);
|
||||
// modOperationalStatePackStatehandle->faultState = FAULT_CODE_DISCHARGE_RETRY;
|
||||
// //nc if(modOperationalStateGeneralConfigHandle->buzzerSignalSource)
|
||||
// //nc modEffectChangeStateError(STAT_BUZZER,STAT_ERROR,modOperationalStatePackStatehandle->faultState);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// if(fabs(modOperationalStatePackStatehandle->packCurrent) >= modOperationalStateGeneralConfigHandle->notUsedCurrentThreshold) {
|
||||
// if(modDelayTick1ms(&modOperationalStateNotUsedResetDelay,1000))
|
||||
// modOperationalStateNotUsedTime = HAL_GetTick();
|
||||
// }else{
|
||||
// modOperationalStateNotUsedResetDelay = HAL_GetTick();
|
||||
// }
|
||||
//
|
||||
// if(modOperationalStatePowerDownDelayCheck()) {
|
||||
// modOperationalStateSetNewState(OP_STATE_POWER_DOWN);
|
||||
// modOperationalStatePackStatehandle->powerDownDesired = true;
|
||||
// }
|
||||
//
|
||||
// if(modOperationalStatePackStatehandle->balanceActive) {
|
||||
// if(!modOperationalStatePackStatehandle->chargeAllowed && (modOperationalStatePackStatehandle->cellVoltageMisMatch < modOperationalStateGeneralConfigHandle->maxMismatchThreshold)){
|
||||
// if(modDelayTick1ms(&modOperationalStateChargedTimeout,modOperationalStateGeneralConfigHandle->timeoutChargingCompletedMinimalMismatch)) {
|
||||
// modStateOfChargeVoltageEvent(EVENT_FULL);
|
||||
// modOperationalStateChargedTimeout = HAL_GetTick();
|
||||
// }
|
||||
// }else{
|
||||
// modOperationalStateChargedTimeout = HAL_GetTick();
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// modOperationalStateUpdateStates();
|
||||
//
|
||||
// //nc modOperationalStateDisplayData.StateOfCharge = modOperationalStateGeneralStateOfCharge->generalStateOfCharge;
|
||||
// //nc modOperationalStateDisplayData.Current = fabs(modOperationalStatePackStatehandle->packCurrent);
|
||||
// //nc modOperationalStateDisplayData.PackVoltage = fabs(modOperationalStatePackStatehandle->packVoltage);
|
||||
// //nc modOperationalStateDisplayData.HighestTemp = fabs(modOperationalStatePackStatehandle->tempBatteryHigh);
|
||||
// //nc modOperationalStateDisplayData.AverageTemp = fabs(modOperationalStatePackStatehandle->tempBatteryAverage);
|
||||
// //nc modOperationalStateDisplayData.LowestTemp = fabs(modOperationalStatePackStatehandle->tempBatteryLow);
|
||||
// //nc modOperationalStateDisplayData.Humidity = fabs(modOperationalStatePackStatehandle->humidity);
|
||||
// //nc modOperationalStateDisplayData.LowestCellVoltage = fabs(modOperationalStatePackStatehandle->cellVoltageLow);
|
||||
// //nc modOperationalStateDisplayData.HighestCellVoltage = fabs(modOperationalStatePackStatehandle->cellVoltageHigh);
|
||||
// //nc modOperationalStateDisplayData.DisplayStyle = modOperationalStateGeneralConfigHandle->displayStyle;
|
||||
//
|
||||
// //nc modDisplayShowInfo(DISP_MODE_LOAD,modOperationalStateDisplayData);
|
||||
// break;
|
||||
// case OP_STATE_BATTERY_DEAD:
|
||||
// //nc modDisplayShowInfo(DISP_MODE_BATTERY_DEAD,modOperationalStateDisplayData);
|
||||
//// if(modDelayTick1ms(&modOperationalStateBatteryDeadDisplayTime,modOperationalStateGeneralConfigHandle->displayTimeoutBatteryDead)){
|
||||
//// modOperationalStateSetNewState(OP_STATE_POWER_DOWN);
|
||||
//// modOperationalStatePackStatehandle->powerDownDesired = true;
|
||||
//// modOperationalStatePackStatehandle->faultState = FAULT_CODE_PACK_UNDER_VOLTAGE;
|
||||
//// }
|
||||
// modOperationalStateUpdateStates();
|
||||
// break;
|
||||
// case OP_STATE_POWER_DOWN:
|
||||
// if(modOperationalStateLastState != modOperationalStateCurrentState) {
|
||||
// modOperationalStatePSPDisableDelay = HAL_GetTick();
|
||||
// }
|
||||
// modPowerElectronicsDisableAll(); // Disable all power paths
|
||||
// //nc modEffectChangeState(STAT_LED_POWER,STAT_RESET); // Turn off power LED
|
||||
// //nc modEffectChangeState(STAT_LED_DEBUG,STAT_RESET);
|
||||
// //nc if(!modOperationalStateGeneralConfigHandle->buzzerSignalPersistant)
|
||||
// //nc modEffectChangeState(STAT_BUZZER,STAT_RESET);
|
||||
// modOperationalStateUpdateStates();
|
||||
// //nc modDisplayShowInfo(DISP_MODE_POWEROFF,modOperationalStateDisplayData);
|
||||
// if(modDelayTick1ms(&modOperationalStatePSPDisableDelay,modOperationalStateGeneralConfigHandle->powerDownDelay)) { // Wait for the power down delay time to pass
|
||||
// modOperationalStateTerminateOperation(); // Disable powersupply and store SoC
|
||||
// }
|
||||
// break;
|
||||
// case OP_STATE_EXTERNAL: // BMS is turned on by external force IE CAN or USB
|
||||
// if(modOperationalStateLastState != modOperationalStateCurrentState) {
|
||||
// modPowerElectronicsSetPreCharge(false);
|
||||
// modPowerElectronicsSetDisCharge(false);
|
||||
// modPowerElectronicsSetCharge(false);
|
||||
// }
|
||||
//
|
||||
// modOperationalStateTerminateOperation(); // Disable power and store SoC
|
||||
// //nc modDisplayShowInfo(DISP_MODE_EXTERNAL,modOperationalStateDisplayData);
|
||||
//
|
||||
// break;
|
||||
// case OP_STATE_ERROR:
|
||||
// // Go to save state and in the future -> try to handle error situation
|
||||
// if(modOperationalStateLastState != modOperationalStateCurrentState)
|
||||
// modOperationalStateErrorDisplayTime = HAL_GetTick();
|
||||
//
|
||||
// if(modDelayTick1ms(&modOperationalStateErrorDisplayTime,modOperationalStateGeneralConfigHandle->displayTimeoutBatteryError)) {
|
||||
// modOperationalStateSetNewState(OP_STATE_POWER_DOWN);
|
||||
// modOperationalStatePackStatehandle->powerDownDesired = true;
|
||||
// }
|
||||
//
|
||||
// //nc modEffectChangeStateError(STAT_LED_DEBUG,STAT_ERROR,modOperationalStatePackStatehandle->faultState); // Turn flash fast on debug and power LED
|
||||
// //nc modEffectChangeStateError(STAT_LED_POWER,STAT_ERROR,modOperationalStatePackStatehandle->faultState);
|
||||
// if(modOperationalStateGeneralConfigHandle->buzzerSignalSource)
|
||||
// //nc modEffectChangeStateError(STAT_BUZZER,STAT_ERROR,modOperationalStatePackStatehandle->faultState); // Turn flash fast on debug and power LED
|
||||
// modPowerElectronicsDisableAll();
|
||||
// modOperationalStateUpdateStates();
|
||||
// //nc modOperationalStateDisplayData.FaultCode = modOperationalStatePackStatehandle->faultState;
|
||||
// //nc modDisplayShowInfo(DISP_MODE_ERROR,modOperationalStateDisplayData);
|
||||
//
|
||||
// break;
|
||||
// case OP_STATE_ERROR_PRECHARGE:
|
||||
// // Go to save state and in the future -> try to handle error situation
|
||||
// if(modOperationalStateLastState != modOperationalStateCurrentState)
|
||||
// modOperationalStateErrorDisplayTime = HAL_GetTick();
|
||||
//
|
||||
// if(modDelayTick1ms(&modOperationalStateErrorDisplayTime,modOperationalStateGeneralConfigHandle->displayTimeoutBatteryErrorPreCharge)) {
|
||||
// modOperationalStateSetNewState(OP_STATE_POWER_DOWN);
|
||||
// modOperationalStatePackStatehandle->powerDownDesired = true;
|
||||
// }
|
||||
//
|
||||
// //nc modEffectChangeState(STAT_LED_DEBUG,STAT_FLASH_FAST); // Turn flash fast on debug and power LED
|
||||
// //nc modEffectChangeState(STAT_LED_POWER,STAT_FLASH_FAST); // Turn flash fast on debug and power LED
|
||||
// //nc if(modOperationalStateGeneralConfigHandle->buzzerSignalSource)
|
||||
// //nc modEffectChangeStateError(STAT_BUZZER,STAT_ERROR,modOperationalStatePackStatehandle->faultState);
|
||||
// modPowerElectronicsDisableAll();
|
||||
// modOperationalStateUpdateStates();
|
||||
// //nc modDisplayShowInfo(DISP_MODE_ERROR_PRECHARGE,modOperationalStateDisplayData);
|
||||
// break;
|
||||
// case OP_STATE_BALANCING:
|
||||
// // update timeout time for balancing and use charging manager for enable state charge input
|
||||
// if(modOperationalStatePackStatehandle->packCurrent < modOperationalStateGeneralConfigHandle->chargerEnabledThreshold && modOperationalStatePackStatehandle->chargeAllowed){
|
||||
// if(modDelayTick1ms(&modOperationalStateChargerTimeout,modOperationalStateGeneralConfigHandle->timeoutChargeCompleted)) {
|
||||
// modOperationalStateSetAllStates(OP_STATE_CHARGED);
|
||||
// modStateOfChargeVoltageEvent(EVENT_FULL);
|
||||
// }
|
||||
// }else{
|
||||
// modOperationalStateChargerTimeout = HAL_GetTick();
|
||||
// };
|
||||
//
|
||||
// if(!modOperationalStatePackStatehandle->chargeAllowed && (modOperationalStatePackStatehandle->cellVoltageMisMatch < modOperationalStateGeneralConfigHandle->maxMismatchThreshold)){
|
||||
// if(modDelayTick1ms(&modOperationalStateChargedTimeout,modOperationalStateGeneralConfigHandle->timeoutChargingCompletedMinimalMismatch)) {
|
||||
// modOperationalStateSetAllStates(OP_STATE_CHARGED);
|
||||
// modStateOfChargeVoltageEvent(EVENT_FULL);
|
||||
// }
|
||||
// }else{
|
||||
// modOperationalStateChargedTimeout = HAL_GetTick();
|
||||
// };
|
||||
//
|
||||
// modOperationalStateHandleChargerDisconnect(OP_STATE_POWER_DOWN);
|
||||
// if(modOperationalStatePackStatehandle->chargeAllowed){
|
||||
// modPowerElectronicsSetCharge(true);
|
||||
// if(modOperationalStatePackStatehandle->packCurrent >= 0.5f || modOperationalStatePackStatehandle->packCurrent >= modOperationalStateGeneralConfigHandle->chargerEnabledThreshold){
|
||||
// modPowerElectronicsSetChargePFET(true);
|
||||
// }
|
||||
//
|
||||
// #if (ENNOID_HV || ENNOID_LV)
|
||||
// if(modOperationalStatePackStatehandle->packVoltage-modOperationalStatePackStatehandle->loCurrentLoadVoltage < (modOperationalStatePackStatehandle->packVoltage*0.1f) && modOperationalStatePackStatehandle->loCurrentLoadVoltage < (modOperationalStateGeneralConfigHandle->noOfCellsSeries*modOperationalStateGeneralConfigHandle->cellHardOverVoltage+10.0f)){
|
||||
// modPowerElectronicsSetDisCharge(true);
|
||||
// if(modOperationalStateGeneralConfigHandle->LCUsePrecharge==forced){
|
||||
// modPowerElectronicsSetPreCharge(true);
|
||||
// }
|
||||
// }
|
||||
// #endif
|
||||
// }else{
|
||||
// modPowerElectronicsSetChargePFET(false);
|
||||
// modPowerElectronicsSetCharge(false);
|
||||
// modPowerElectronicsSetDisCharge(false);
|
||||
// modPowerElectronicsSetPreCharge(false);
|
||||
// modOperationalStatePackStatehandle->faultState = FAULT_CODE_CHARGE_RETRY;
|
||||
// };
|
||||
//
|
||||
// //Cooling/Heating
|
||||
// if(modOperationalStatePackStatehandle->coolingAllowed )
|
||||
// modPowerElectronicsSetCooling(true);
|
||||
// else{
|
||||
// modPowerElectronicsSetCooling(false);
|
||||
// }
|
||||
//
|
||||
// modOperationalStateUpdateStates();
|
||||
// //nc modOperationalStateDisplayData.StateOfCharge = modOperationalStateGeneralStateOfCharge->generalStateOfCharge;
|
||||
// //nc modOperationalStateDisplayData.CellMismatch = fabs(modOperationalStatePackStatehandle->cellVoltageMisMatch);
|
||||
// //nc modOperationalStateDisplayData.AverageCellVoltage = fabs(modOperationalStatePackStatehandle->cellVoltageAverage);
|
||||
// //nc modDisplayShowInfo(DISP_MODE_BALANCING,modOperationalStateDisplayData);
|
||||
// //nc modEffectChangeState(STAT_LED_POWER,STAT_BLINKSHORTLONG_100_20); // Indicate balancing
|
||||
// break;
|
||||
// case OP_STATE_CHARGED:
|
||||
// modOperationalStateHandleChargerDisconnect(OP_STATE_POWER_DOWN);
|
||||
// //nc modEffectChangeState(STAT_LED_POWER,STAT_BLINKSHORTLONG_1000_4); // Indicate Charged
|
||||
// modOperationalStateUpdateStates();
|
||||
// //nc modDisplayShowInfo(DISP_MODE_CHARGED,modOperationalStateDisplayData);
|
||||
// break;
|
||||
// case OP_STATE_FORCEON:
|
||||
// if(modPowerElectronicsSetDisCharge(true))
|
||||
// modPowerElectronicsSetPreCharge(false);
|
||||
// else {
|
||||
// modOperationalStateSetNewState(OP_STATE_PRE_CHARGE);
|
||||
// modPowerElectronicsSetDisCharge(false);
|
||||
// }
|
||||
//
|
||||
// if(fabs(modOperationalStatePackStatehandle->packCurrent) >= modOperationalStateGeneralConfigHandle->notUsedCurrentThreshold) {
|
||||
// if(modDelayTick1ms(&modOperationalStateNotUsedResetDelay,1000))
|
||||
// modOperationalStateNotUsedTime = HAL_GetTick();
|
||||
// }else{
|
||||
// modOperationalStateNotUsedResetDelay = HAL_GetTick();
|
||||
// }
|
||||
//
|
||||
// if(modOperationalStatePowerDownDelayCheck()) {
|
||||
// modOperationalStateSetNewFaultState(FAULT_CODE_NOT_USED_TIMEOUT);
|
||||
// modOperationalStateSetNewState(OP_STATE_POWER_DOWN);
|
||||
// modOperationalStatePackStatehandle->powerDownDesired = true;
|
||||
// }
|
||||
//
|
||||
// //nc modDisplayShowInfo(DISP_MODE_FORCED_ON,modOperationalStateDisplayData);
|
||||
// //nc modEffectChangeState(STAT_LED_POWER,STAT_BLINKSHORTLONG_1000_4); // Turn flash fast on debug and power LED
|
||||
// modOperationalStateUpdateStates();
|
||||
// break;
|
||||
// default:
|
||||
// modOperationalStateSetAllStates(OP_STATE_ERROR);
|
||||
// break;
|
||||
// };
|
||||
//
|
||||
// if(modPowerStateForceOnRequest()){
|
||||
// modOperationalStateForceOn = true;
|
||||
// modPowerElectronicsAllowForcedOn(true);
|
||||
// modOperationalStateSetNewState(OP_STATE_PRE_CHARGE);
|
||||
// driverSWStorageManagerEraseData();
|
||||
// };
|
||||
//
|
||||
// // Check for power button longpress -> if so power down BMS
|
||||
// if(modPowerStatePowerdownRequest()) {
|
||||
// modOperationalStatePackStatehandle->powerDownDesired = true;
|
||||
//
|
||||
// if(modOperationalStateDelayedDisable(modOperationalStateGeneralConfigHandle->useCANDelayedPowerDown)) {
|
||||
// modOperationalStateSetNewFaultState(FAULT_CODE_CAN_DELAYED_POWER_DOWN);
|
||||
// modOperationalStateSetNewState(OP_STATE_POWER_DOWN);
|
||||
// //nc modDisplayShowInfo(DISP_MODE_POWEROFF,modOperationalStateDisplayData);
|
||||
// modOperationalStateUpdateFaultStates();
|
||||
//
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// // In case of extreme cellvoltages or temperatures goto error state
|
||||
// if((modOperationalStatePackStatehandle->packOperationalCellState == PACK_STATE_ERROR_HARD_CELLVOLTAGE || modOperationalStatePackStatehandle->packOperationalCellState == PACK_STATE_ERROR_TEMPERATURE) && (modOperationalStatePackStatehandle->packOperationalCellState != packOperationalCellStateLastErrorState) && !modOperationalStateForceOn){
|
||||
// packOperationalCellStateLastErrorState = modOperationalStatePackStatehandle->packOperationalCellState; // Meganism to make error situation only trigger once
|
||||
// modOperationalStateSetNewState(OP_STATE_ERROR);
|
||||
// modOperationalStateUpdateStates();
|
||||
// }
|
||||
//
|
||||
// // In case of extreme currents goto error state
|
||||
// if((modOperationalStatePackStatehandle->packOperationalCellState == PACK_STATE_ERROR_OVER_CURRENT) && (modOperationalStatePackStatehandle->packOperationalCellState != packOperationalCellStateLastErrorState)){
|
||||
// packOperationalCellStateLastErrorState = modOperationalStatePackStatehandle->packOperationalCellState; // Meganism to make error situation only trigger once
|
||||
// modOperationalStatePackStatehandle->faultState = FAULT_CODE_OVER_CURRENT;
|
||||
// modOperationalStateSetNewState(OP_STATE_ERROR);
|
||||
// modOperationalStateUpdateStates();
|
||||
// }
|
||||
//
|
||||
//
|
||||
// // Move the button pressed state to the status struct
|
||||
// modOperationalStatePackStatehandle->powerOnLongButtonPress = modPowerStateGetLongButtonPressState();
|
||||
//
|
||||
// // Handle subtask-display to update display content
|
||||
// //nc modDisplayTask();
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//void modOperationalStateUpdateStates(void) {
|
||||
// modOperationalStateLastState = modOperationalStateCurrentState;
|
||||
// modOperationalStatePackStatehandle->operationalState = modOperationalStateCurrentState = modOperationalStateNewState;
|
||||
//};
|
||||
//
|
||||
//void modOperationalStateSetAllStates(OperationalStateTypedef newState) {
|
||||
// modOperationalStatePackStatehandle->operationalState = modOperationalStateLastState = modOperationalStateCurrentState = modOperationalStateNewState = newState;
|
||||
//};
|
||||
//
|
||||
//void modOperationalStateSetNewState(OperationalStateTypedef newState) {
|
||||
// modOperationalStateNewState = newState;
|
||||
//};
|
||||
//
|
||||
//void modOperationalStateHandleChargerDisconnect(OperationalStateTypedef newState) {
|
||||
// if(modPowerStateChargerDetected() && !((modOperationalStatePackStatehandle->packCurrent < modOperationalStateGeneralConfigHandle->chargerEnabledThreshold ) && modOperationalStatePackStatehandle->chargeDesired && modOperationalStatePackStatehandle->chargeAllowed)) {
|
||||
// modOperationalStateChargerDisconnectDetectDelay = HAL_GetTick();
|
||||
// }else{
|
||||
// if(modDelayTick1ms(&modOperationalStateChargerDisconnectDetectDelay,modOperationalStateGeneralConfigHandle->timeoutChargerDisconnected)){
|
||||
// modOperationalStateSetAllStates(newState);
|
||||
// modOperationalStatePackStatehandle->powerDownDesired = true;
|
||||
// }
|
||||
// }
|
||||
//};
|
||||
//
|
||||
//void modOperationalStateTerminateOperation(void) {
|
||||
// // Store the state of charge data
|
||||
// modStateOfChargePowerDownSave(); // Store the SoC data
|
||||
//
|
||||
// // Disable the power supply
|
||||
// modPowerStateSetState(P_STAT_RESET); // Turn off the power
|
||||
//}
|
||||
//
|
||||
//bool modOperationalStateDelayedDisable(bool delayedPowerDownDesired) {
|
||||
// if(delayedPowerDownDesired){
|
||||
// if(modOperationalStatePackStatehandle->watchDogTime){
|
||||
// if(modDelayTick1ms(&modOperationalStateWatchDogCountdownLastTick,1000))
|
||||
// modOperationalStatePackStatehandle->watchDogTime--;
|
||||
//
|
||||
// return false;
|
||||
// }else{
|
||||
// return true;
|
||||
// }
|
||||
// }else{
|
||||
// return true;
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//bool modOperationalStatePowerDownDelayCheck(void){
|
||||
// return modDelayTick1ms(&modOperationalStateNotUsedTime,modOperationalStateGeneralConfigHandle->notUsedTimeout) && modOperationalStateGeneralConfigHandle->notUsedTimeout;
|
||||
//}
|
||||
//
|
||||
//void modOperationalStateUpdateFaultStates(void) {
|
||||
// modOperationalStateLastFaultState = modOperationalStateCurrentFaultState;
|
||||
// modOperationalStatePackStatehandle->faultState = modOperationalStateCurrentFaultState = modOperationalStateNewFaultState;
|
||||
//};
|
||||
//
|
||||
//void modOperationalStateSetAllFaultStates(bms_fault_state newFaultState) {
|
||||
// modOperationalStatePackStatehandle->faultState = modOperationalStateLastFaultState = modOperationalStateCurrentFaultState = modOperationalStateNewFaultState = newFaultState;
|
||||
//};
|
||||
//
|
||||
//void modOperationalStateSetNewFaultState(bms_fault_state newFaultState) {
|
||||
// modOperationalStateNewFaultState = newFaultState;
|
||||
//};
|
||||
1288
Core/Src/modPowerElectronics.c
Normal file
1288
Core/Src/modPowerElectronics.c
Normal file
File diff suppressed because it is too large
Load Diff
160
Core/Src/modPowerState.c
Normal file
160
Core/Src/modPowerState.c
Normal file
@@ -0,0 +1,160 @@
|
||||
///*
|
||||
// Copyright 2017 - 2018 Danny Bokma danny@diebie.nl
|
||||
// Copyright 2019 - 2020 Kevin Dionne kevin.dionne@ennoid.me
|
||||
//
|
||||
// This file is part of the DieBieMS/ENNOID-BMS firmware.
|
||||
//
|
||||
// The DieBieMS/ENNOID-BMS firmware is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// The DieBieMS/ENNOID-BMS firmware is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
// */
|
||||
//
|
||||
//#include "modPowerState.h"
|
||||
//
|
||||
//modConfigGeneralConfigStructTypedef *modPowerStateGeneralConfigHandle;
|
||||
//
|
||||
//bool modPowerStatePulsePowerDownDesired;
|
||||
//bool modPowerStateForceOnDesired;
|
||||
//bool modPowerStateButtonPressedVar;
|
||||
//bool modPowerStateLastButtonPressedVar;
|
||||
//bool modPowerStateLastButtonFirstPress;
|
||||
//bool modPowerStateButtonActuated;
|
||||
//bool modPowerStateButtonPulsToggleMode;
|
||||
//bool modPowerStatePowerModeDirectHCDelay;
|
||||
//bool modPowerStateLongStartupButtonPress;
|
||||
//uint32_t modPowerStateButtonPressedDuration;
|
||||
//uint32_t modPowerStateButtonPressedTimeStamp;
|
||||
//uint32_t modPowerStateStartupDelay;
|
||||
//uint32_t modPowerStatePowerDownTimeout;
|
||||
//
|
||||
//bool tempButtonPressed;
|
||||
//
|
||||
//void modPowerStateInit(PowerStateStateTypedef desiredPowerState) {
|
||||
// uint32_t startupDelay = HAL_GetTick();
|
||||
// modPowerStateStartupDelay = HAL_GetTick();
|
||||
// modPowerStatePowerDownTimeout = HAL_GetTick();
|
||||
// modPowerStatePulsePowerDownDesired = false;
|
||||
// modPowerStateForceOnDesired = false;
|
||||
// modPowerStateButtonPressedVar = true;
|
||||
// modPowerStateLongStartupButtonPress = false;
|
||||
// modPowerStateButtonPulsToggleMode = true;
|
||||
// modPowerStateButtonPressedDuration = 0;
|
||||
// modPowerStateButtonPressedTimeStamp = 0;
|
||||
// modPowerStateButtonActuated = false;
|
||||
//
|
||||
// driverHWPowerStateInit();
|
||||
//
|
||||
// while(!modDelayTick1ms(&modPowerStateStartupDelay,20)); // Needed for power button signal to reach uC
|
||||
// modPowerStateLastButtonFirstPress = modPowerStateLastButtonPressedVar = driverHWPowerStateReadInput(P_STAT_BUTTON_INPUT);
|
||||
//
|
||||
// if(!modPowerStateLastButtonFirstPress) {
|
||||
// while(!modDelayTick1ms(&modPowerStateStartupDelay,100));
|
||||
// }
|
||||
//
|
||||
// modPowerStateSetState(desiredPowerState);
|
||||
//};
|
||||
//
|
||||
//
|
||||
//
|
||||
//void modPowerStateSetConfigHandle(modConfigGeneralConfigStructTypedef *generalConfigPointer) {
|
||||
// modPowerStateGeneralConfigHandle = generalConfigPointer;
|
||||
//
|
||||
// modPowerStateButtonPulsToggleMode = modPowerStateGeneralConfigHandle->pulseToggleButton;
|
||||
// modPowerStatePowerModeDirectHCDelay = modPowerStateGeneralConfigHandle->togglePowerModeDirectHCDelay;
|
||||
//}
|
||||
//
|
||||
//void modPowerStateTask(void) {
|
||||
// //bool tempButtonPressed = driverHWPowerStateReadInput(P_STAT_BUTTON_INPUT);
|
||||
// tempButtonPressed = driverHWPowerStateReadInput(P_STAT_BUTTON_INPUT);
|
||||
//
|
||||
// if(modPowerStateLastButtonPressedVar != tempButtonPressed) {
|
||||
// if(modPowerStateLastButtonPressedVar){ // If is was high and now low (actuated)
|
||||
// modPowerStateLastButtonFirstPress = false;
|
||||
// modPowerStateButtonActuated = true;
|
||||
// }else{ // If is was low and now high (non actuated)
|
||||
// modPowerStateButtonPressedTimeStamp = HAL_GetTick();
|
||||
// modPowerStateButtonActuated = false;
|
||||
// }
|
||||
// modPowerStateLastButtonPressedVar = tempButtonPressed;
|
||||
// }
|
||||
//
|
||||
// if(tempButtonPressed) {
|
||||
// modPowerStateButtonPressedDuration = HAL_GetTick() - modPowerStateButtonPressedTimeStamp;
|
||||
//
|
||||
// if((modPowerStateButtonPressedDuration > POWERBUTTON_DEBOUNCE_TIME) && (modPowerStateLastButtonFirstPress == false))
|
||||
// modPowerStateButtonPressedVar = true;
|
||||
//
|
||||
// if((modPowerStateButtonPressedDuration >= POWERBUTTON_POWERDOWN_THRESHOLD_TIME) && (modPowerStateLastButtonFirstPress == false) && modPowerStateGeneralConfigHandle->pulseToggleButton) {
|
||||
// modPowerStatePulsePowerDownDesired = true;
|
||||
// modPowerStateButtonPressedDuration = 0;
|
||||
// }
|
||||
//
|
||||
// if((modPowerStateButtonPressedDuration >= POWERBUTTON_FORCEON_THRESHOLD_TIME) && (modPowerStateLastButtonFirstPress == true) && modPowerStateGeneralConfigHandle->pulseToggleButton) {
|
||||
// if(modPowerStateGeneralConfigHandle->allowForceOn) {
|
||||
// modPowerStateForceOnDesired = true;
|
||||
// }
|
||||
//
|
||||
// modPowerStateLongStartupButtonPress = true;
|
||||
// modPowerStateButtonPressedDuration = 0;
|
||||
// }
|
||||
//
|
||||
// modPowerStatePowerDownTimeout = HAL_GetTick();
|
||||
// }else{
|
||||
// if(modDelayTick1ms(&modPowerStatePowerDownTimeout,500) && modPowerStateButtonActuated)
|
||||
// modPowerStateButtonPressedVar = false;
|
||||
// }
|
||||
//};
|
||||
//
|
||||
//bool modPowerStateGetButtonPressedState(void) {
|
||||
// return modPowerStateButtonPressedVar;
|
||||
//};
|
||||
//
|
||||
//bool modPowerStateChargerDetected(void) {
|
||||
// static bool chargeDetect = false;
|
||||
// chargeDetect = driverHWPowerStateReadInput(P_STAT_CHARGE_DETECT);
|
||||
// return chargeDetect;
|
||||
//};
|
||||
//
|
||||
//bool modPowerStatePowerdownRequest(void) {
|
||||
// bool returnValue = false;
|
||||
//
|
||||
// if(modPowerStateGeneralConfigHandle->pulseToggleButton){
|
||||
// returnValue = modPowerStatePulsePowerDownDesired;
|
||||
// }else{
|
||||
// returnValue = !modPowerStateButtonPressedVar;
|
||||
// }
|
||||
// return returnValue;
|
||||
//};
|
||||
//
|
||||
//bool modPowerStateForceOnRequest(void) {
|
||||
// static bool firstTrigger = true;
|
||||
//
|
||||
// if(modPowerStateForceOnDesired && firstTrigger){
|
||||
// modPowerStateForceOnDesired = false;
|
||||
// firstTrigger = false;
|
||||
// return true;
|
||||
// }else{
|
||||
// return false;
|
||||
// }
|
||||
//};
|
||||
//
|
||||
//void modPowerStateSetState(PowerStateStateTypedef newState) {
|
||||
// driverHWPowerStateSetOutput(P_STAT_POWER_ENABLE,newState);
|
||||
//};
|
||||
//
|
||||
//bool modPowerStateButtonPressedOnTurnon(void) {
|
||||
// return modPowerStateLastButtonFirstPress;
|
||||
//};
|
||||
//
|
||||
//bool modPowerStateGetLongButtonPressState(void) {
|
||||
// return modPowerStateLongStartupButtonPress;
|
||||
//}
|
||||
226
Core/Src/modStateOfCharge.c
Normal file
226
Core/Src/modStateOfCharge.c
Normal file
@@ -0,0 +1,226 @@
|
||||
/*
|
||||
Copyright 2017 - 2018 Danny Bokma danny@diebie.nl
|
||||
Copyright 2019 - 2020 Kevin Dionne kevin.dionne@ennoid.me
|
||||
|
||||
This file is part of the DieBieMS/ENNOID-BMS firmware.
|
||||
|
||||
The DieBieMS/ENNOID-BMS firmware is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The DieBieMS/ENNOID-BMS firmware is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "modStateOfCharge.h"
|
||||
#include "main.h"
|
||||
|
||||
modStateOfChargeStructTypeDef modStateOfChargeGeneralStateOfCharge;
|
||||
modPowerElectronicsPackStateTypedef *modStateOfChargePackStatehandle;
|
||||
modConfigGeneralConfigStructTypedef *modStateOfChargeGeneralConfigHandle;
|
||||
uint32_t modStateOfChargeLargeCoulombTick;
|
||||
uint32_t modStateOfChargeStoreSoCTick;
|
||||
|
||||
bool modStateOfChargePowerDownSavedFlag = false;
|
||||
|
||||
modStateOfChargeStructTypeDef* modStateOfChargeInit(modPowerElectronicsPackStateTypedef *packState, modConfigGeneralConfigStructTypedef *generalConfigPointer){
|
||||
modStateOfChargePackStatehandle = packState;
|
||||
modStateOfChargeGeneralConfigHandle = generalConfigPointer;
|
||||
driverSWStorageManagerStateOfChargeStructSize = (sizeof(modStateOfChargeStructTypeDef)/sizeof(uint16_t)); // Calculate the space needed for the config struct in EEPROM
|
||||
|
||||
modStateOfChargeLargeCoulombTick = HAL_GetTick();
|
||||
modStateOfChargeStoreSoCTick = HAL_GetTick();
|
||||
|
||||
return &modStateOfChargeGeneralStateOfCharge;
|
||||
};
|
||||
|
||||
float real_capacity = 0;
|
||||
float previous_capacity = 0;
|
||||
float previous_SoC = 0;
|
||||
//static float current_SoC = 0;
|
||||
float soc_diff = 0;
|
||||
float capacity_diff = 0;
|
||||
uint8_t SoC_Save_Flag = 0;
|
||||
|
||||
void modStateOfChargeProcess(void){
|
||||
// Calculate accumulated energy
|
||||
uint32_t dt = HAL_GetTick() - modStateOfChargeLargeCoulombTick;
|
||||
|
||||
static float lastsaved_remainingCapacityAh = 0;
|
||||
modStateOfChargeStructTypeDef lastGeneralStateOfCharge;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* soc = <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> / <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> * 100
|
||||
*
|
||||
* <20> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> 1% (<28><>)
|
||||
* b - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> 5% (<28><>) ( x amp - 5%
|
||||
* y amp - 100%; y = 100x/5
|
||||
*
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = ( 100 * <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> ) / <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* 100 * 2 /1 = 200
|
||||
*
|
||||
* *
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1%, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1,4<><34><EFBFBD>
|
||||
* <20><> = (100 * 1.4) / 1 = 140 <20><><EFBFBD>
|
||||
*
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1%, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 2,8<><38><EFBFBD>
|
||||
* (100 * 2,8) /1 = 280 <20><><EFBFBD>
|
||||
*
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 2%, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1,4
|
||||
* (100 * 1.4) /2 70 <20><><EFBFBD>
|
||||
*
|
||||
*
|
||||
*
|
||||
* soh
|
||||
*
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 150, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1,5, <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 99%
|
||||
*
|
||||
*
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> (<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>) <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* soh = <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* soc =
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
lastGeneralStateOfCharge = modStateOfChargeGeneralStateOfCharge;
|
||||
|
||||
modStateOfChargeLargeCoulombTick = HAL_GetTick();
|
||||
// calc in Ahmps how much we put or take
|
||||
modStateOfChargeGeneralStateOfCharge.remainingCapacityAh += dt*modStateOfChargePackStatehandle->packCurrent/(3600*1000);// (miliseconds * amps)/(3600*1000) accumulatedCharge in AmpHour.
|
||||
|
||||
// Cap the max stored energy to the configured battery capacity.
|
||||
// if we put more than battery is, set maximum
|
||||
if(modStateOfChargeGeneralStateOfCharge.remainingCapacityAh > modStateOfChargeGeneralConfigHandle->batteryCapacity)
|
||||
modStateOfChargeGeneralStateOfCharge.remainingCapacityAh = modStateOfChargeGeneralConfigHandle->batteryCapacity;
|
||||
|
||||
// if we take more than battery, set zero
|
||||
if(modStateOfChargeGeneralStateOfCharge.remainingCapacityAh < 0.0f)
|
||||
modStateOfChargeGeneralStateOfCharge.remainingCapacityAh = 0.0f;
|
||||
|
||||
// Calculate state of charge
|
||||
// calc percent of we put/take to battery capacity
|
||||
modStateOfChargeGeneralStateOfCharge.generalStateOfCharge = modStateOfChargeGeneralStateOfCharge.remainingCapacityAh / modStateOfChargeGeneralConfigHandle->batteryCapacity * 100.0f;
|
||||
|
||||
if(SoC_Save_Flag == 0) {
|
||||
previous_SoC = modStateOfChargeGeneralStateOfCharge.generalStateOfCharge;
|
||||
previous_capacity = modStateOfChargeGeneralStateOfCharge.remainingCapacityAh;
|
||||
|
||||
SoC_Save_Flag = 1;
|
||||
}
|
||||
|
||||
if(previous_SoC - modStateOfChargeGeneralStateOfCharge.generalStateOfCharge > 1) {
|
||||
soc_diff = previous_SoC - modStateOfChargeGeneralStateOfCharge.generalStateOfCharge;
|
||||
//
|
||||
if(soc_diff == 0) soc_diff = 1;
|
||||
capacity_diff = previous_capacity - modStateOfChargeGeneralStateOfCharge.remainingCapacityAh;
|
||||
real_capacity = (100 * capacity_diff) / soc_diff;
|
||||
|
||||
export_real_capacity = real_capacity;
|
||||
|
||||
previous_SoC = modStateOfChargeGeneralStateOfCharge.generalStateOfCharge;
|
||||
previous_capacity = modStateOfChargeGeneralStateOfCharge.remainingCapacityAh;
|
||||
|
||||
//SoC_Save_Flag = 0;
|
||||
|
||||
} //else if (previous_SoC - modStateOfChargeGeneralStateOfCharge.generalStateOfCharge < -1) {
|
||||
// SoC_Save_Flag = 0;
|
||||
//}
|
||||
|
||||
|
||||
|
||||
// if we have more than 100% it is 100%
|
||||
if(modStateOfChargeGeneralStateOfCharge.generalStateOfCharge >= 100.0f)
|
||||
modStateOfChargeGeneralStateOfCharge.generalStateOfCharge = 100.0f;
|
||||
|
||||
// save soc and amps
|
||||
modStateOfChargePackStatehandle->SoC = modStateOfChargeGeneralStateOfCharge.generalStateOfCharge;
|
||||
modStateOfChargePackStatehandle->SoCCapacityAh = modStateOfChargeGeneralStateOfCharge.remainingCapacityAh;
|
||||
|
||||
// Store SoC every 'stateOfChargeStoreInterval'
|
||||
|
||||
modStateOfChargeGeneralConfigHandle->stateOfChargeStoreInterval = 10000;
|
||||
|
||||
|
||||
|
||||
if(modDelayTick1ms(&modStateOfChargeStoreSoCTick,modStateOfChargeGeneralConfigHandle->stateOfChargeStoreInterval) &&
|
||||
(lastsaved_remainingCapacityAh != modStateOfChargeGeneralStateOfCharge.remainingCapacityAh)) {
|
||||
lastsaved_remainingCapacityAh = modStateOfChargeGeneralStateOfCharge.remainingCapacityAh;
|
||||
modStateOfChargeStoreStateOfCharge();
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
bool modStateOfChargeStoreAndLoadDefaultStateOfCharge(void){
|
||||
bool returnVal = false;
|
||||
if(driverSWStorageManagerStateOfChargeEmpty){
|
||||
// TODO: SoC manager is empy -> Determin SoC from voltage when voltages are available.
|
||||
modStateOfChargeStructTypeDef defaultStateOfCharge;
|
||||
defaultStateOfCharge.generalStateOfCharge = 100.0f;
|
||||
defaultStateOfCharge.generalStateOfHealth = 100.0f;
|
||||
defaultStateOfCharge.remainingCapacityAh = modStateOfChargeGeneralConfigHandle->batteryCapacity;
|
||||
defaultStateOfCharge.remainingCapacityWh = 0.0f;
|
||||
|
||||
driverSWStorageManagerStateOfChargeEmpty = false;
|
||||
driverSWStorageManagerStoreStruct(&defaultStateOfCharge,STORAGE_STATEOFCHARGE);
|
||||
// TODO_EEPROM
|
||||
}
|
||||
|
||||
modStateOfChargeStructTypeDef tempStateOfCharge;
|
||||
driverSWStorageManagerGetStruct(&tempStateOfCharge,STORAGE_STATEOFCHARGE);
|
||||
|
||||
modStateOfChargeLoadStateOfCharge();
|
||||
return returnVal;
|
||||
};
|
||||
|
||||
bool modStateOfChargeStoreStateOfCharge(void){
|
||||
HAL_GPIO_TogglePin(HL2_GPIO_Port, HL2_Pin);
|
||||
return driverSWStorageManagerStoreStruct(&modStateOfChargeGeneralStateOfCharge,STORAGE_STATEOFCHARGE);
|
||||
};
|
||||
|
||||
bool modStateOfChargeLoadStateOfCharge(void){
|
||||
return driverSWStorageManagerGetStruct(&modStateOfChargeGeneralStateOfCharge,STORAGE_STATEOFCHARGE);
|
||||
};
|
||||
|
||||
bool modStateOfChargePowerDownSave(void) {
|
||||
// if(!modStateOfChargePowerDownSavedFlag) {
|
||||
// modStateOfChargePowerDownSavedFlag = true;
|
||||
// modStateOfChargeStoreStateOfCharge();
|
||||
// // TODO_EEPROM
|
||||
// return true;
|
||||
// }else
|
||||
// return false;
|
||||
};
|
||||
|
||||
void modStateOfChargeVoltageEvent(modStateOfChargeVoltageEventTypeDef eventType) {
|
||||
switch(eventType) {
|
||||
case EVENT_EMPTY:
|
||||
break;
|
||||
case EVENT_FULL:
|
||||
modStateOfChargeGeneralStateOfCharge.remainingCapacityAh = modStateOfChargeGeneralConfigHandle->batteryCapacity;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
};
|
||||
587
Core/Src/modTerminal.c
Normal file
587
Core/Src/modTerminal.c
Normal file
@@ -0,0 +1,587 @@
|
||||
/*
|
||||
Copyright 2016 Benjamin Vedder benjamin@vedder.se
|
||||
Copyright 2017 - 2018 Danny Bokma danny@diebie.nl
|
||||
Copyright 2019 - 2020 Kevin Dionne kevin.dionne@ennoid.me
|
||||
|
||||
This file is part of the VESC/DieBieMS/ENNOID-BMS firmware.
|
||||
|
||||
The VESC/DieBieMS/ENNOID-BMS firmware is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The VESC/DieBieMS/ENNOID-BMS firmware is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "modTerminal.h"
|
||||
#include "main.h"
|
||||
#include "time.h"
|
||||
#include "rtc.h"
|
||||
|
||||
#include "modStateOfCharge.h"
|
||||
|
||||
|
||||
|
||||
|
||||
// Private types
|
||||
typedef struct _terminal_callback_struct {
|
||||
const char *command;
|
||||
const char *help;
|
||||
const char *arg_names;
|
||||
void(*cbf)(int argc, const char **argv);
|
||||
} terminal_callback_struct;
|
||||
|
||||
// Private variables
|
||||
static terminal_callback_struct callbacks[CALLBACK_LEN];
|
||||
static int callback_write = 0;
|
||||
|
||||
extern modConfigGeneralConfigStructTypedef *generalConfig;
|
||||
extern modStateOfChargeStructTypeDef *generalStateOfCharge;
|
||||
extern modPowerElectronicsPackStateTypedef packState;
|
||||
extern OperationalStateTypedef modOperationalStateCurrentState;
|
||||
|
||||
extern SIM800_Global_Struct SIM800_Struct;
|
||||
|
||||
extern bool jumpBootloaderTrue;
|
||||
|
||||
void modTerminalProcessString(char *str) {
|
||||
|
||||
struct tm tm_PC_Time = {0};
|
||||
Time_Struct PC_time;
|
||||
uint64_t NewSerial;
|
||||
|
||||
enum { kMaxArgs = 64 };
|
||||
int argc = 0;
|
||||
char *argv[kMaxArgs];
|
||||
|
||||
char* ptr;
|
||||
|
||||
char *p2 = strtok(str, " ");
|
||||
while (p2 && argc < kMaxArgs) {
|
||||
argv[argc++] = p2;
|
||||
p2 = strtok(0, " ");
|
||||
}
|
||||
|
||||
if (argc == 0) {
|
||||
modCommandsPrintf("No command received\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp(argv[0], "ping") == 0) {
|
||||
modCommandsPrintf("pong\n");
|
||||
} else if (strcmp(argv[0], "status") == 0) {
|
||||
bool disChargeEnabled = packState.disChargeDesired && packState.disChargeLCAllowed;
|
||||
bool chargeEnabled = packState.chargeDesired && packState.chargeAllowed;
|
||||
|
||||
|
||||
/*
|
||||
static float real_capacity = 0;
|
||||
static float previous_capacity = 0;
|
||||
static float previous_SoC = 0;
|
||||
//static float current_SoC = 0;
|
||||
static float soc_diff = 0;
|
||||
static float capacity_diff = 0;
|
||||
static uint8_t SoC_Save_Flag = 0;
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
uint8_t Pilot_Status = 0;
|
||||
uint8_t Maximum_Charge_Current_Status = 0;
|
||||
uint8_t Maximum_Voltage_Status = 0;
|
||||
uint8_t Maximum_Temp_Status = 0;
|
||||
uint8_t Maximum_Load_Current_Status = 0;
|
||||
uint8_t Minimum_Voltage_Status = 0;
|
||||
*/
|
||||
modCommandsPrintf(" ");
|
||||
modCommandsPrintf("-----Battery Pack Status-----");
|
||||
|
||||
//modPowerElectronicsPackStateHandle->cellModuleBalanceResistorEnableMask
|
||||
|
||||
|
||||
modCommandsPrintf("Balance mask : 0x%x ",packState.cellModuleBalanceResistorEnableMask[0]);
|
||||
modCommandsPrintf("Pack voltage Direct : %.2fV",packState.packVoltage);
|
||||
modCommandsPrintf("Pack voltage CVAverage: %.2fV",packState.cellVoltageAverage*generalConfig->noOfCellsSeries);
|
||||
modCommandsPrintf("Pack current : %.2fA",packState.packCurrent);
|
||||
//modCommandsPrintf("LC Load voltage : %.2fV",packState.loCurrentLoadVoltage);
|
||||
//modCommandsPrintf("Low current : %.2fA",packState.loCurrentLoadCurrent);
|
||||
modCommandsPrintf("State of charge : %.1f%%",generalStateOfCharge->generalStateOfCharge);
|
||||
modCommandsPrintf("Remaining capacity : %.2fAh",generalStateOfCharge->remainingCapacityAh);
|
||||
modCommandsPrintf("Real calculated capacity : %fAh",export_real_capacity);
|
||||
|
||||
//modCommandsPrintf("previous_capacity : %.2fAh",previous_capacity);
|
||||
// modCommandsPrintf("previous_SoC : %.2fAh",previous_SoC);
|
||||
// modCommandsPrintf("soc_diff : %.2fAh",soc_diff);
|
||||
// modCommandsPrintf("capacity_diff : %.2fAh",capacity_diff);
|
||||
// modCommandsPrintf("SoC_Save_Flag : %.2fAh",SoC_Save_Flag);
|
||||
modCommandsPrintf(" ");
|
||||
modCommandsPrintf("Pilot_Status: %s",Pilot_Status ? "Charging" : "No charging");
|
||||
modCommandsPrintf("Maximum_Charge_Current_Status: %s",Maximum_Charge_Current_Status ? "Good" : "Too high charge current!");
|
||||
modCommandsPrintf("Maximum_Voltage_Status: %s",Maximum_Voltage_Status ? "Good" : "Too high voltage!");
|
||||
modCommandsPrintf("Maximum_Temp_Status: %s",Maximum_Temp_Status ? "Good" : "Too high temperature!");
|
||||
modCommandsPrintf("Maximum_Load_Current_Status: %s",Maximum_Load_Current_Status ? "Good" : "Too high load current!");
|
||||
modCommandsPrintf("Minimum_Voltage_Status: %s",Minimum_Voltage_Status ? "Good" : "Too low voltage!");
|
||||
modCommandsPrintf("Deep_Discharge_Status: %s",Deep_Discharge_Status ? "Good" : "Deep discharge!");
|
||||
modCommandsPrintf("ADC_Current: %d",export_adc_average_res);
|
||||
modCommandsPrintf("Current Zero Value: %f",generalConfig->shuntLCFactor);
|
||||
modCommandsPrintf(" ");
|
||||
modCommandsPrintf("Charge Switch State: %s",charge_switch_state ? "ON" : "OFF");
|
||||
modCommandsPrintf("Load Switch State: %s",load_switch_state ? "ON" : "OFF");
|
||||
//generalConfig->shuntLCFactor
|
||||
//export_adc_average_res
|
||||
|
||||
//export_real_capacity
|
||||
|
||||
// switch(modOperationalStateCurrentState) {
|
||||
// case OP_STATE_CHARGING:
|
||||
// modCommandsPrintf("Operational state : %s","Charging");
|
||||
// break;
|
||||
// case OP_STATE_LOAD_ENABLED:
|
||||
// modCommandsPrintf("Operational state : %s","Load enabled");
|
||||
// break;
|
||||
// case OP_STATE_CHARGED:
|
||||
// modCommandsPrintf("Operational state : %s","Charged");
|
||||
// break;
|
||||
// case OP_STATE_BALANCING:
|
||||
// modCommandsPrintf("Operational state : %s","Balancing");
|
||||
// break;
|
||||
// case OP_STATE_ERROR_PRECHARGE:
|
||||
// modCommandsPrintf("Operational state : %s","Pre charge error");
|
||||
// break;
|
||||
// case OP_STATE_ERROR:
|
||||
// modCommandsPrintf("Operational state : %s","Error");
|
||||
// break;
|
||||
// case OP_STATE_FORCEON:
|
||||
// modCommandsPrintf("Operational state : %s","Forced on");
|
||||
// break;
|
||||
// case OP_STATE_POWER_DOWN:
|
||||
// modCommandsPrintf("Operational state : %s","Power down");
|
||||
// break;
|
||||
// case OP_STATE_EXTERNAL:
|
||||
// modCommandsPrintf("Operational state : %s","External (USB or CAN)");
|
||||
// break;
|
||||
// default:
|
||||
// modCommandsPrintf("Operational state : %s","Unknown");
|
||||
// break;
|
||||
// }
|
||||
// modCommandsPrintf("Cell voltage high : %.3fV",packState.cellVoltageHigh);
|
||||
// modCommandsPrintf("Cell voltage low : %.3fV",packState.cellVoltageLow);
|
||||
// modCommandsPrintf("Cell voltage average : %.3fV",packState.cellVoltageAverage);
|
||||
// modCommandsPrintf("Cell voltage mismatch : %.3fV",packState.cellVoltageMisMatch);
|
||||
// modCommandsPrintf("Discharge enabled : %s",disChargeEnabled ? "True" : "False");
|
||||
// modCommandsPrintf("Charge enabled : %s",chargeEnabled ? "True" : "False");
|
||||
//ni modCommandsPrintf("Power button pressed : %s",packState.powerButtonActuated ? "True" : "False");
|
||||
//ni modCommandsPrintf("CAN safety state : %s",packState.safetyOverCANHCSafeNSafe ? "True" : "False");
|
||||
|
||||
|
||||
//ni modCommandsPrintf("---End Battery Pack Status---");
|
||||
//ni modCommandsPrintf(" ");
|
||||
/*
|
||||
uint8_t cellVoltageLow_Minimum = 0;
|
||||
uint8_t cellVoltageLow_Minimum_Hyst = 0;
|
||||
uint8_t cellVoltageHigh_Maximum = 0;
|
||||
uint8_t cellVoltageHigh_Maximum_Hyst = 0;
|
||||
uint8_t maxChargeCurrent = 0;
|
||||
uint8_t maxLoadCurrent = 0;
|
||||
|
||||
*/
|
||||
} else if (strcmp(argv[0], "setZeroCurrent") == 0) {
|
||||
modCommandsPrintf(" ");
|
||||
modCommandsPrintf("----- setZeroCurrent -----");
|
||||
|
||||
// print temperatures
|
||||
modCommandsPrintf("ADC Value: %.3f V",export_adc_average_res);
|
||||
generalConfig->shuntLCFactor = export_adc_average_res;
|
||||
modCommandsPrintf("Config Zero Value in EEPROM: %.3f V",generalConfig->shuntLCFactor);
|
||||
modCommandsPrintf("Config Zero Value in RAM: %.3f V",currentZero_config);
|
||||
|
||||
modCommandsPrintf("Current Zero Value Updated! Remember to save EEPROM!");
|
||||
modCommandsPrintf(" ");
|
||||
|
||||
/*
|
||||
*
|
||||
Brush_Minimum_SoC = generalConfig->minimalPrechargePercentage;
|
||||
Brush_Default_State = generalConfig->timeoutLCPreCharge;
|
||||
*/
|
||||
|
||||
} else if (strcmp(argv[0], "Outputs") == 0) {
|
||||
modCommandsPrintf(" ");
|
||||
modCommandsPrintf("----- Outputs -----");
|
||||
|
||||
// print temperatures
|
||||
modCommandsPrintf("Output 2 minimum SoC: %.3f",Brush_Minimum_SoC);
|
||||
modCommandsPrintf("Output 2 default state: %d",Brush_Default_State);
|
||||
|
||||
modCommandsPrintf(" ");
|
||||
|
||||
}else if (strcmp(argv[0], "limits") == 0) {
|
||||
modCommandsPrintf(" ");
|
||||
modCommandsPrintf("----- Limits -----");
|
||||
|
||||
// print temperatures
|
||||
modCommandsPrintf("Minimum Cell Voltage: %.3f V",cellVoltageLow_Minimum);
|
||||
modCommandsPrintf("Minimum Cell Voltage Hyst: %.3f V",cellVoltageLow_Minimum_Hyst);
|
||||
modCommandsPrintf("Maximum Cell Voltage: %.3f V",cellVoltageHigh_Maximum);
|
||||
modCommandsPrintf("Maximum Cell Voltage Hyst: %.3f V",cellVoltageHigh_Maximum_Hyst);
|
||||
modCommandsPrintf(" ");
|
||||
modCommandsPrintf("Maximum Charge Current: %.3f A",maxChargeCurrent);
|
||||
modCommandsPrintf("Maximum Load Current: %.3f A",maxLoadCurrent);
|
||||
modCommandsPrintf(" ");
|
||||
modCommandsPrintf("Maximum Temperature: %.3f C",maxTemperature);
|
||||
modCommandsPrintf("Maximum Temperature Hyst: %.3f C",maxTemperature_Hyst);
|
||||
modCommandsPrintf(" ");
|
||||
|
||||
} else if (strcmp(argv[0], "sens") == 0) {
|
||||
modCommandsPrintf("----- Sensors -----");
|
||||
|
||||
// print temperatures
|
||||
modCommandsPrintf("Sensor[0] : % 3.1f C - I - 'LTC Internal'",packState.temperatures[0]);
|
||||
modCommandsPrintf("Sensor[1] : % 3.1f C - I - 'LTC Internal'",packState.temperatures[1]);
|
||||
modCommandsPrintf("Sensor[2] : % 3.1f C - I - 'LTC Internal'",packState.temperatures[2]);
|
||||
modCommandsPrintf("Sensor[3] : % 3.1f C - I - 'LTC Internal'",packState.temperatures[3]);
|
||||
modCommandsPrintf("Sensor[4] : % 3.1f C - I - 'LTC Internal'",packState.temperatures[4]);
|
||||
modCommandsPrintf("Sensor[5] : % 3.1f C - I - 'LTC Internal'",packState.temperatures[5]);
|
||||
modCommandsPrintf("Sensor[6] : % 3.1f C - I - 'LTC Internal'",packState.temperatures[6]);
|
||||
modCommandsPrintf("Sensor[7] : % 3.1f C - I - 'LTC Internal'",packState.temperatures[7]);
|
||||
modCommandsPrintf("Sensor[8] : % 3.1f C - I - 'LTC Internal'",packState.temperatures[8]);
|
||||
modCommandsPrintf("Sensor[9] : % 3.1f C - I - 'LTC Internal'",packState.temperatures[9]);
|
||||
modCommandsPrintf("Sensor[10] : % 3.1f C - I - 'LTC Internal'",packState.temperatures[10]);
|
||||
modCommandsPrintf("Sensor[11] : % 3.1f C - I - 'LTC Internal'",packState.temperatures[11]);
|
||||
modCommandsPrintf("Sensor[12] : % 3.1f C - I - 'LTC Internal'",packState.temperatures[12]);
|
||||
|
||||
modCommandsPrintf("Sensor[2] : % 3.1f C - I - 'LTC Internal'",packState.temperatures[2]);
|
||||
modCommandsPrintf("Sensor[3] : % 3.1f C - I - 'STM NTC'",packState.temperatures[3]);
|
||||
modCommandsPrintf("----- End sensors -----");
|
||||
modCommandsPrintf("----- E=External I=Internal -----");
|
||||
modCommandsPrintf(" ");
|
||||
|
||||
} else if (strcmp(argv[0], "cells") == 0) {
|
||||
uint8_t cellPointer = 0;
|
||||
|
||||
modCommandsPrintf("----- Cell voltages -----");
|
||||
modCommandsPrintf("Cell in series : %d ",generalConfig->noOfCellsSeries);
|
||||
modCommandsPrintf("Number of ICs : %d ",generalConfig->cellMonitorICCount);
|
||||
modCommandsPrintf("Cells per IC : %d ",generalConfig->noOfCellsPerModule);
|
||||
|
||||
for(cellPointer = 0 ; cellPointer < generalConfig->noOfCellsSeries ; cellPointer++) {
|
||||
// test 01.11.2021 //
|
||||
//for(cellPointer = 0 ; cellPointer < 20 ; cellPointer++) {
|
||||
modCommandsPrintf("Cell voltage%3d : %.3f V",cellPointer,packState.cellVoltagesIndividual[cellPointer].cellVoltage);
|
||||
}
|
||||
modCommandsPrintf("Cell voltage high : %.3f V",packState.cellVoltageHigh);
|
||||
modCommandsPrintf("Cell voltage low : %.3f V",packState.cellVoltageLow);
|
||||
modCommandsPrintf("Cell voltage average : %.3f V",packState.cellVoltageAverage);
|
||||
modCommandsPrintf("Cell voltage mismatch : %.3f V",packState.cellVoltageMisMatch);
|
||||
modCommandsPrintf("----- End Cell voltages -----");
|
||||
modCommandsPrintf(" ");
|
||||
|
||||
} else if (strcmp(argv[0], "config") == 0) {
|
||||
modCommandsPrintf("--- BMS Configuration ---");
|
||||
//modCommandsPrintf("serialNumber : %u",generalConfig->serialNumber);
|
||||
modCommandsPrintf("NoOfCells : %u",generalConfig->noOfCellsSeries);
|
||||
modCommandsPrintf("batteryCapacity : %.2fAh",generalConfig->batteryCapacity);
|
||||
modCommandsPrintf("cellHardUnderVoltage : %.3fV",generalConfig->cellHardUnderVoltage);
|
||||
modCommandsPrintf("cellHardOverVoltage : %.3fV",generalConfig->cellHardOverVoltage);
|
||||
modCommandsPrintf("cellLCSoftUnderVoltage : %.3fV",generalConfig->cellLCSoftUnderVoltage);
|
||||
modCommandsPrintf("cellSoftOverVoltage : %.3fV",generalConfig->cellSoftOverVoltage);
|
||||
modCommandsPrintf("cellBalanceStart : %.3fV",generalConfig->cellBalanceStart);
|
||||
//modCommandsPrintf("cellBalanceDiffThreshold : %.3fV",generalConfig->cellBalanceDifferenceThreshold);
|
||||
modCommandsPrintf("CAN ID : %u",generalConfig->CANID);
|
||||
modCommandsPrintf("--- End BMS Configuration ---");
|
||||
modCommandsPrintf(" ");
|
||||
|
||||
} else if (strcmp(argv[0], "config_default") == 0) {
|
||||
modCommandsPrintf("--Restoring default config--");
|
||||
if(modConfigStoreDefaultConfig())
|
||||
modCommandsPrintf("Succesfully restored config, new config wil be used on powercycle (or use config_read to apply it now).");
|
||||
else
|
||||
modCommandsPrintf("Error restored config.");
|
||||
modCommandsPrintf(" ");
|
||||
|
||||
} else if (strcmp(argv[0], "config_write") == 0) {
|
||||
modCommandsPrintf("--- Writing config ---");
|
||||
if(modConfigStoreConfig())
|
||||
modCommandsPrintf("Succesfully written config.");
|
||||
else
|
||||
modCommandsPrintf("Error writing config.");
|
||||
modCommandsPrintf(" ");
|
||||
|
||||
} else if (strcmp(argv[0], "config_read") == 0) {
|
||||
modCommandsPrintf("--- Reading config ---");
|
||||
if(modConfigLoadConfig())
|
||||
modCommandsPrintf("Succesfully read config.");
|
||||
else
|
||||
modCommandsPrintf("Error reading config.");
|
||||
modCommandsPrintf(" ");
|
||||
|
||||
} else if (strcmp(argv[0], "config_set_cells") == 0) {
|
||||
modCommandsPrintf("---Setting new cell count---");
|
||||
if (argc == 2) {
|
||||
uint32_t newNumberOfCells = 0;
|
||||
sscanf(argv[1], "%u", &newNumberOfCells);
|
||||
if(newNumberOfCells < 13 && newNumberOfCells > 2) {
|
||||
modCommandsPrintf("Number of cells is set to: %u.",newNumberOfCells);
|
||||
generalConfig->noOfCellsSeries = newNumberOfCells;
|
||||
} else {
|
||||
modCommandsPrintf("Invalid number of cells (should be anything from 3 to 12).");
|
||||
}
|
||||
} else {
|
||||
modCommandsPrintf("This command requires one argument.");
|
||||
}
|
||||
modCommandsPrintf(" ");
|
||||
|
||||
} else if (strcmp(argv[0], "hwinfo") == 0) {
|
||||
modCommandsPrintf("------- BMS Info -------");
|
||||
modCommandsPrintf("Firmware: %s", FW_REAL_VERSION);
|
||||
modCommandsPrintf("Name : %s", HW_NAME);
|
||||
modCommandsPrintf("UUID: %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X",
|
||||
STM32_UUID_8[0], STM32_UUID_8[1], STM32_UUID_8[2], STM32_UUID_8[3],
|
||||
STM32_UUID_8[4], STM32_UUID_8[5], STM32_UUID_8[6], STM32_UUID_8[7],
|
||||
STM32_UUID_8[8], STM32_UUID_8[9], STM32_UUID_8[10], STM32_UUID_8[11]);
|
||||
modCommandsPrintf("------- End BMS Info -------");
|
||||
modCommandsPrintf(" ");
|
||||
|
||||
} else if (strcmp(argv[0], "reboot") == 0) {
|
||||
modCommandsPrintf("------ Rebooting BMS ------");
|
||||
NVIC_SystemReset();
|
||||
|
||||
} else if (strcmp(argv[0], "bootloader_erase") == 0) {
|
||||
modCommandsPrintf("------ erasing new app space ------");
|
||||
//ni if(modFlashEraseNewAppData(0x00002000) == HAL_OK)
|
||||
if(1)
|
||||
modCommandsPrintf("--Erase done.");
|
||||
else
|
||||
modCommandsPrintf("--Erase error.");
|
||||
|
||||
} else if (strcmp(argv[0], "bootloader_jump") == 0) {
|
||||
//ni modFlashJumpToBootloader();
|
||||
|
||||
} else if (strcmp(argv[0], "help") == 0) {
|
||||
modCommandsPrintf("------- Start of help -------");
|
||||
modCommandsPrintf("Valid commands for ENNOID-BMS are:");
|
||||
modCommandsPrintf("help");
|
||||
modCommandsPrintf(" Show this help.");
|
||||
modCommandsPrintf("setZeroCurrent");
|
||||
modCommandsPrintf(" Set Zero for current sensor");
|
||||
modCommandsPrintf("ping");
|
||||
modCommandsPrintf(" Print pong here to see if the reply works.");
|
||||
modCommandsPrintf("slave_scan");
|
||||
modCommandsPrintf(" Scan the I2C devices on the slave.");
|
||||
modCommandsPrintf("status");
|
||||
modCommandsPrintf(" Print battery measurements summary.");
|
||||
modCommandsPrintf("sens");
|
||||
modCommandsPrintf(" Print all sensor values.");
|
||||
modCommandsPrintf("cells");
|
||||
modCommandsPrintf(" Print cell voltage measurements.");
|
||||
modCommandsPrintf("config");
|
||||
modCommandsPrintf(" Print BMS configuration.");
|
||||
modCommandsPrintf("config_default");
|
||||
modCommandsPrintf(" Load default BMS configuration.");
|
||||
modCommandsPrintf("config_write");
|
||||
modCommandsPrintf(" Store current BMS configuration to EEPROM.");
|
||||
modCommandsPrintf("config_read");
|
||||
modCommandsPrintf(" Read BMS configuration from EEPROM.");
|
||||
modCommandsPrintf("hwinfo");
|
||||
modCommandsPrintf(" Print some hardware information.");
|
||||
modCommandsPrintf("GSM");
|
||||
modCommandsPrintf(" Print some GSM information.");
|
||||
modCommandsPrintf("setUnixTime [Value]");
|
||||
modCommandsPrintf(" Set RTC Time from TimeStamp. [Value] - uint64 unixtime value ");
|
||||
modCommandsPrintf("checkUnixTime");
|
||||
modCommandsPrintf(" Check actual RTC time ");
|
||||
|
||||
modCommandsPrintf("setSerialNumber [Value]");
|
||||
modCommandsPrintf(" Set Serial [Value] - uint64 value ");
|
||||
modCommandsPrintf("checkSerialNumber");
|
||||
modCommandsPrintf(" Check actual Serial ");
|
||||
|
||||
modCommandsPrintf("SDcard");
|
||||
modCommandsPrintf(" Switch to SD storage");
|
||||
|
||||
|
||||
|
||||
for (int i = 0;i < callback_write;i++) {
|
||||
if (callbacks[i].arg_names) {
|
||||
modCommandsPrintf("%s %s", callbacks[i].command, callbacks[i].arg_names);
|
||||
} else {
|
||||
modCommandsPrintf(callbacks[i].command);
|
||||
}
|
||||
|
||||
if (callbacks[i].help) {
|
||||
modCommandsPrintf(" %s", callbacks[i].help);
|
||||
} else {
|
||||
modCommandsPrintf(" There is no help available for this command.");
|
||||
}
|
||||
}
|
||||
|
||||
modCommandsPrintf(" ");
|
||||
} else if (strcmp(argv[0], "GSM") == 0) {
|
||||
uint8_t cellPointer = 0;
|
||||
|
||||
modCommandsPrintf("----- GSM STATE -----");
|
||||
modCommandsPrintf("GPRS Connected : %d ", SIM800_Struct.Sim_Main_States.GPRS_Established);
|
||||
ptr = &SIM800_Struct.Sim_Answer.SIM_answer[0];
|
||||
modCommandsPrintf("Last received msg : %s ", ptr);
|
||||
modCommandsPrintf("----- End GSM STATE -----");
|
||||
modCommandsPrintf(" ");
|
||||
|
||||
}else if (strcmp(argv[0], "setUnixTime") == 0) {
|
||||
modCommandsPrintf(" ");
|
||||
modCommandsPrintf("----- set Unix Time -----");
|
||||
|
||||
time_t Time_rcvd;
|
||||
Time_rcvd = strtol(argv[1], NULL, 16);
|
||||
tm_PC_Time = *(localtime(&Time_rcvd));
|
||||
|
||||
if(Time_rcvd < 0x386D4380){
|
||||
PC_time.year = 0;
|
||||
PC_time.month = 1;
|
||||
PC_time.day = 1;
|
||||
PC_time.hour = 0;
|
||||
PC_time.minute = 0;
|
||||
PC_time.second = 0;
|
||||
|
||||
} else {
|
||||
|
||||
PC_time.year = tm_PC_Time.tm_year+1900-2000;
|
||||
PC_time.month = tm_PC_Time.tm_mon+1;
|
||||
PC_time.day = tm_PC_Time.tm_mday;
|
||||
PC_time.hour = tm_PC_Time.tm_hour;
|
||||
PC_time.minute = tm_PC_Time.tm_min;
|
||||
PC_time.second = tm_PC_Time.tm_sec;
|
||||
}
|
||||
|
||||
RTC_Set_Values(&PC_time);
|
||||
// print temperatures
|
||||
|
||||
modCommandsPrintf("RTC Updated!");
|
||||
modCommandsPrintf("Actual RTC:");
|
||||
modCommandsPrintf("Year : %d", PC_time.year);
|
||||
modCommandsPrintf("Month : %d", PC_time.month);
|
||||
modCommandsPrintf("Day : %d", PC_time.day);
|
||||
modCommandsPrintf("Hours : %d", PC_time.hour);
|
||||
modCommandsPrintf("Minutes : %d", PC_time.minute);
|
||||
modCommandsPrintf("Seconds : %d", PC_time.second);
|
||||
|
||||
|
||||
modCommandsPrintf(" ");
|
||||
}else if (strcmp(argv[0], "checkUnixTime") == 0) {
|
||||
modCommandsPrintf(" ");
|
||||
modCommandsPrintf("----- check Unix Time -----");
|
||||
|
||||
RTC_Get_Values(&PC_time);
|
||||
|
||||
modCommandsPrintf("Actual RTC:");
|
||||
modCommandsPrintf("Year : %d", PC_time.year);
|
||||
modCommandsPrintf("Month : %d", PC_time.month);
|
||||
modCommandsPrintf("Day : %d", PC_time.day);
|
||||
modCommandsPrintf("Hours : %d", PC_time.hour);
|
||||
modCommandsPrintf("Minutes : %d", PC_time.minute);
|
||||
modCommandsPrintf("Seconds : %d", PC_time.second);
|
||||
|
||||
modCommandsPrintf("----- end Unix Time -----");
|
||||
modCommandsPrintf(" ");
|
||||
}
|
||||
else if (strcmp(argv[0], "checkSerialNumber") == 0) {
|
||||
modCommandsPrintf(" ");
|
||||
modCommandsPrintf("----- check Serial -----");
|
||||
|
||||
modCommandsPrintf("Actual Serial:");
|
||||
modCommandsPrintf("Serial : %lu %lu", generalConfig->serialNumber);
|
||||
modCommandsPrintf("Serial : %.8f", generalConfig->notUsedCurrentThreshold);
|
||||
modCommandsPrintf("----- end Serial -----");
|
||||
modCommandsPrintf(" ");
|
||||
}
|
||||
else if (strcmp(argv[0], "setSerialNumber") == 0) {
|
||||
modCommandsPrintf(" ");
|
||||
modCommandsPrintf("----- Set Serial -----");
|
||||
|
||||
NewSerial = strtol(argv[1], NULL, 10);
|
||||
generalConfig->serialNumber = NewSerial;
|
||||
modCommandsPrintf("New Serial : %lu %lu", NewSerial);
|
||||
modCommandsPrintf("----- end Serial -----");
|
||||
modCommandsPrintf(" ");
|
||||
}
|
||||
else if (strcmp(argv[0], "SDcard") == 0) {
|
||||
HAL_RTCEx_BKUPWrite(&hrtc, RTC_BKP_DR11, 1);
|
||||
jumpBootloaderTrue = 1;
|
||||
}
|
||||
else {
|
||||
bool found = false;
|
||||
for (int i = 0;i < callback_write;i++) {
|
||||
if (strcmp(argv[0], callbacks[i].command) == 0) {
|
||||
callbacks[i].cbf(argc, (const char**)argv);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
modCommandsPrintf("Invalid command: %s\n type help to list all available commands\n", argv[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a custom command callback to the terminal. If the command
|
||||
* is already registered the old command callback will be replaced.
|
||||
*
|
||||
* @param command
|
||||
* The command name.
|
||||
*
|
||||
* @param help
|
||||
* A help text for the command. Can be NULL.
|
||||
*
|
||||
* @param arg_names
|
||||
* The argument names for the command, e.g. [arg_a] [arg_b]
|
||||
* Can be NULL.
|
||||
*
|
||||
* @param cbf
|
||||
* The callback function for the command.
|
||||
*/
|
||||
void modTerminalRegisterCommandCallBack(
|
||||
const char* command,
|
||||
const char *help,
|
||||
const char *arg_names,
|
||||
void(*cbf)(int argc, const char **argv)) {
|
||||
|
||||
int callback_num = callback_write;
|
||||
|
||||
for (int i = 0;i < callback_write;i++) {
|
||||
// First check the address in case the same callback is registered more than once.
|
||||
if (callbacks[i].command == command) {
|
||||
callback_num = i;
|
||||
break;
|
||||
}
|
||||
|
||||
// Check by string comparison.
|
||||
if (strcmp(callbacks[i].command, command) == 0) {
|
||||
callback_num = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
callbacks[callback_num].command = command;
|
||||
callbacks[callback_num].help = help;
|
||||
callbacks[callback_num].arg_names = arg_names;
|
||||
callbacks[callback_num].cbf = cbf;
|
||||
|
||||
if (callback_num == callback_write) {
|
||||
callback_write++;
|
||||
if (callback_write >= CALLBACK_LEN) {
|
||||
callback_write = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
defaultConfig.cellBalanceDifferenceThreshold = 0.01f; // Start balancing @ 5mV difference, stop if below
|
||||
*/
|
||||
55
Core/Src/modUART.c
Normal file
55
Core/Src/modUART.c
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
Copyright 2017 - 2018 Danny Bokma danny@diebie.nl
|
||||
Copyright 2019 - 2020 Kevin Dionne kevin.dionne@ennoid.me
|
||||
|
||||
This file is part of the DieBieMS/ENNOID-BMS firmware.
|
||||
|
||||
The DieBieMS/ENNOID-BMS firmware is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The DieBieMS/ENNOID-BMS firmware is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "modUART.h"
|
||||
|
||||
uint32_t consoleStatusLastTick;
|
||||
|
||||
void modUARTInit(void) {
|
||||
libPacketInit(modUARTSendPacket, modUARTProcessPacket, PACKET_HANDLER_UART);
|
||||
|
||||
driverSWUART2Init(115200); // Configure the UART driver
|
||||
};
|
||||
|
||||
void modUARTTask(void) {
|
||||
char inputChar;
|
||||
|
||||
while(driverSWUART2Task()){};
|
||||
|
||||
if(driverHWUART2GetChar(&inputChar))
|
||||
libPacketProcessByte(inputChar,PACKET_HANDLER_UART);
|
||||
};
|
||||
|
||||
void modUARTSendPacketWrapper(unsigned char *data, unsigned int len) {
|
||||
libPacketSendPacket(data, len, PACKET_HANDLER_UART);
|
||||
}
|
||||
|
||||
void modUARTProcessPacket(unsigned char *data, unsigned int len) {
|
||||
modCommandsSetSendFunction(modUARTSendPacketWrapper);
|
||||
modCommandsProcessPacket(data, len);
|
||||
}
|
||||
|
||||
void modUARTSendPacket(unsigned char *data, unsigned int len) {
|
||||
uint32_t outputCharPointer;
|
||||
|
||||
for(outputCharPointer = 0; outputCharPointer < len; outputCharPointer++) {
|
||||
driverHWUART2SendChar(data[outputCharPointer]);
|
||||
}
|
||||
}
|
||||
167
Core/Src/rtc.c
Normal file
167
Core/Src/rtc.c
Normal file
@@ -0,0 +1,167 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file rtc.c
|
||||
* @brief This file provides code for the configuration
|
||||
* of the RTC instances.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2021 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "rtc.h"
|
||||
|
||||
/* USER CODE BEGIN 0 */
|
||||
//extern Time_Struct Global_RTC_Time;
|
||||
/* USER CODE END 0 */
|
||||
|
||||
RTC_HandleTypeDef hrtc;
|
||||
|
||||
/* RTC init function */
|
||||
void MX_RTC_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN RTC_Init 0 */
|
||||
|
||||
/* USER CODE END RTC_Init 0 */
|
||||
|
||||
RTC_TimeTypeDef sTime = {0};
|
||||
RTC_DateTypeDef DateToUpdate = {0};
|
||||
|
||||
/* USER CODE BEGIN RTC_Init 1 */
|
||||
|
||||
/* USER CODE END RTC_Init 1 */
|
||||
/** Initialize RTC Only
|
||||
*/
|
||||
hrtc.Instance = RTC;
|
||||
hrtc.Init.AsynchPrediv = RTC_AUTO_1_SECOND;
|
||||
hrtc.Init.OutPut = RTC_OUTPUTSOURCE_ALARM;
|
||||
if (HAL_RTC_Init(&hrtc) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN Check_RTC_BKUP */
|
||||
|
||||
/* USER CODE END Check_RTC_BKUP */
|
||||
|
||||
/** Initialize RTC and set the Time and Date
|
||||
*/
|
||||
// sTime.Hours = 18;
|
||||
// sTime.Minutes = 25;
|
||||
// sTime.Seconds = 58;
|
||||
//
|
||||
// if (HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BCD) != HAL_OK)
|
||||
// {
|
||||
// Error_Handler();
|
||||
// }
|
||||
// DateToUpdate.WeekDay = RTC_WEEKDAY_MONDAY;
|
||||
// DateToUpdate.Month = 11;
|
||||
// DateToUpdate.Date = 24;
|
||||
// DateToUpdate.Year = 21;
|
||||
//
|
||||
// if (HAL_RTC_SetDate(&hrtc, &DateToUpdate, RTC_FORMAT_BCD) != HAL_OK)
|
||||
// {
|
||||
// Error_Handler();
|
||||
// }
|
||||
/* USER CODE BEGIN RTC_Init 2 */
|
||||
|
||||
/* USER CODE END RTC_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
void HAL_RTC_MspInit(RTC_HandleTypeDef* rtcHandle)
|
||||
{
|
||||
|
||||
if(rtcHandle->Instance==RTC)
|
||||
{
|
||||
/* USER CODE BEGIN RTC_MspInit 0 */
|
||||
|
||||
/* USER CODE END RTC_MspInit 0 */
|
||||
HAL_PWR_EnableBkUpAccess();
|
||||
/* Enable BKP CLK enable for backup registers */
|
||||
__HAL_RCC_BKP_CLK_ENABLE();
|
||||
/* RTC clock enable */
|
||||
__HAL_RCC_RTC_ENABLE();
|
||||
/* USER CODE BEGIN RTC_MspInit 1 */
|
||||
|
||||
/* USER CODE END RTC_MspInit 1 */
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_RTC_MspDeInit(RTC_HandleTypeDef* rtcHandle)
|
||||
{
|
||||
|
||||
if(rtcHandle->Instance==RTC)
|
||||
{
|
||||
/* USER CODE BEGIN RTC_MspDeInit 0 */
|
||||
|
||||
/* USER CODE END RTC_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_RTC_DISABLE();
|
||||
/* USER CODE BEGIN RTC_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END RTC_MspDeInit 1 */
|
||||
}
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
void RTC_Set_Values(Time_Struct* Time_to_Set){
|
||||
|
||||
RTC_TimeTypeDef sTime = {0};
|
||||
RTC_DateTypeDef DateToUpdate = {0};
|
||||
|
||||
sTime.Hours = Time_to_Set->hour;
|
||||
sTime.Minutes = Time_to_Set->minute;
|
||||
sTime.Seconds = Time_to_Set->second;
|
||||
|
||||
DateToUpdate.WeekDay = RTC_WEEKDAY_MONDAY;
|
||||
DateToUpdate.Month = Time_to_Set->month;
|
||||
DateToUpdate.Date = Time_to_Set->day;
|
||||
DateToUpdate.Year = Time_to_Set->year;
|
||||
|
||||
if (HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BIN) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
if (HAL_RTC_SetDate(&hrtc, &DateToUpdate, RTC_FORMAT_BIN) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
}
|
||||
|
||||
void RTC_Get_Values(Time_Struct* Time_to_Get){
|
||||
|
||||
RTC_TimeTypeDef sTime = {0};
|
||||
RTC_DateTypeDef DateToUpdate = {0};
|
||||
|
||||
if (HAL_RTC_GetTime(&hrtc, &sTime, RTC_FORMAT_BIN) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
if (HAL_RTC_GetDate(&hrtc, &DateToUpdate, RTC_FORMAT_BIN) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
Time_to_Get->hour = sTime.Hours ;
|
||||
Time_to_Get->minute = sTime.Minutes ;
|
||||
Time_to_Get->second = sTime.Seconds ;
|
||||
|
||||
Time_to_Get->month = DateToUpdate.Month ;
|
||||
Time_to_Get->day = DateToUpdate.Date ;
|
||||
Time_to_Get->year = DateToUpdate.Year ;
|
||||
}
|
||||
/* USER CODE END 1 */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
623
Core/Src/stm32f1xx_hal_msp.c
Normal file
623
Core/Src/stm32f1xx_hal_msp.c
Normal file
@@ -0,0 +1,623 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32f1xx_hal_msp.c
|
||||
* @brief This file provides code for the MSP Initialization
|
||||
* and de-Initialization codes.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2021 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "main.h"
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN TD */
|
||||
|
||||
/* USER CODE END TD */
|
||||
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Define */
|
||||
|
||||
/* USER CODE END Define */
|
||||
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Macro */
|
||||
|
||||
/* USER CODE END Macro */
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PV */
|
||||
|
||||
/* USER CODE END PV */
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/* USER CODE BEGIN PFP */
|
||||
|
||||
/* USER CODE END PFP */
|
||||
|
||||
/* External functions --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN ExternalFunctions */
|
||||
|
||||
/* USER CODE END ExternalFunctions */
|
||||
|
||||
/* USER CODE BEGIN 0 */
|
||||
|
||||
/* USER CODE END 0 */
|
||||
/**
|
||||
* Initializes the Global MSP.
|
||||
*/
|
||||
void HAL_MspInit(void)
|
||||
{
|
||||
/* USER CODE BEGIN MspInit 0 */
|
||||
|
||||
/* USER CODE END MspInit 0 */
|
||||
|
||||
__HAL_RCC_AFIO_CLK_ENABLE();
|
||||
__HAL_RCC_PWR_CLK_ENABLE();
|
||||
|
||||
/* System interrupt init*/
|
||||
|
||||
/** ENABLE: Full SWJ (JTAG-DP + SW-DP): Reset State
|
||||
*/
|
||||
__HAL_AFIO_REMAP_SWJ_ENABLE();
|
||||
|
||||
/* USER CODE BEGIN MspInit 1 */
|
||||
|
||||
/* USER CODE END MspInit 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ADC MSP Initialization
|
||||
* This function configures the hardware resources used in this example
|
||||
* @param hadc: ADC handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
if(hadc->Instance==ADC2)
|
||||
{
|
||||
/* USER CODE BEGIN ADC2_MspInit 0 */
|
||||
|
||||
/* USER CODE END ADC2_MspInit 0 */
|
||||
/* Peripheral clock enable */
|
||||
__HAL_RCC_ADC2_CLK_ENABLE();
|
||||
|
||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||
/**ADC2 GPIO Configuration
|
||||
PC0 ------> ADC2_IN10
|
||||
*/
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_0;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||
|
||||
/* USER CODE BEGIN ADC2_MspInit 1 */
|
||||
|
||||
/* USER CODE END ADC2_MspInit 1 */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ADC MSP De-Initialization
|
||||
* This function freeze the hardware resources used in this example
|
||||
* @param hadc: ADC handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc)
|
||||
{
|
||||
if(hadc->Instance==ADC2)
|
||||
{
|
||||
/* USER CODE BEGIN ADC2_MspDeInit 0 */
|
||||
|
||||
/* USER CODE END ADC2_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_ADC2_CLK_DISABLE();
|
||||
|
||||
/**ADC2 GPIO Configuration
|
||||
PC0 ------> ADC2_IN10
|
||||
*/
|
||||
HAL_GPIO_DeInit(GPIOC, GPIO_PIN_0);
|
||||
|
||||
/* USER CODE BEGIN ADC2_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END ADC2_MspDeInit 1 */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static uint32_t HAL_RCC_CAN1_CLK_ENABLED=0;
|
||||
|
||||
/**
|
||||
* @brief CAN MSP Initialization
|
||||
* This function configures the hardware resources used in this example
|
||||
* @param hcan: CAN handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_CAN_MspInit(CAN_HandleTypeDef* hcan)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
if(hcan->Instance==CAN1)
|
||||
{
|
||||
/* USER CODE BEGIN CAN1_MspInit 0 */
|
||||
|
||||
/* USER CODE END CAN1_MspInit 0 */
|
||||
/* Peripheral clock enable */
|
||||
HAL_RCC_CAN1_CLK_ENABLED++;
|
||||
if(HAL_RCC_CAN1_CLK_ENABLED==1){
|
||||
__HAL_RCC_CAN1_CLK_ENABLE();
|
||||
}
|
||||
|
||||
__HAL_RCC_GPIOD_CLK_ENABLE();
|
||||
/**CAN1 GPIO Configuration
|
||||
PD0 ------> CAN1_RX
|
||||
PD1 ------> CAN1_TX
|
||||
*/
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_0;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
||||
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_1;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
||||
|
||||
__HAL_AFIO_REMAP_CAN1_3();
|
||||
|
||||
/* USER CODE BEGIN CAN1_MspInit 1 */
|
||||
|
||||
/* USER CODE END CAN1_MspInit 1 */
|
||||
}
|
||||
else if(hcan->Instance==CAN2)
|
||||
{
|
||||
/* USER CODE BEGIN CAN2_MspInit 0 */
|
||||
|
||||
/* USER CODE END CAN2_MspInit 0 */
|
||||
/* Peripheral clock enable */
|
||||
__HAL_RCC_CAN2_CLK_ENABLE();
|
||||
HAL_RCC_CAN1_CLK_ENABLED++;
|
||||
if(HAL_RCC_CAN1_CLK_ENABLED==1){
|
||||
__HAL_RCC_CAN1_CLK_ENABLE();
|
||||
}
|
||||
|
||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||
/**CAN2 GPIO Configuration
|
||||
PB12 ------> CAN2_RX
|
||||
PB13 ------> CAN2_TX
|
||||
*/
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_12;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_13;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
|
||||
/* USER CODE BEGIN CAN2_MspInit 1 */
|
||||
|
||||
/* USER CODE END CAN2_MspInit 1 */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CAN MSP De-Initialization
|
||||
* This function freeze the hardware resources used in this example
|
||||
* @param hcan: CAN handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_CAN_MspDeInit(CAN_HandleTypeDef* hcan)
|
||||
{
|
||||
if(hcan->Instance==CAN1)
|
||||
{
|
||||
/* USER CODE BEGIN CAN1_MspDeInit 0 */
|
||||
|
||||
/* USER CODE END CAN1_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
HAL_RCC_CAN1_CLK_ENABLED--;
|
||||
if(HAL_RCC_CAN1_CLK_ENABLED==0){
|
||||
__HAL_RCC_CAN1_CLK_DISABLE();
|
||||
}
|
||||
|
||||
/**CAN1 GPIO Configuration
|
||||
PD0 ------> CAN1_RX
|
||||
PD1 ------> CAN1_TX
|
||||
*/
|
||||
HAL_GPIO_DeInit(GPIOD, GPIO_PIN_0|GPIO_PIN_1);
|
||||
|
||||
/* USER CODE BEGIN CAN1_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END CAN1_MspDeInit 1 */
|
||||
}
|
||||
else if(hcan->Instance==CAN2)
|
||||
{
|
||||
/* USER CODE BEGIN CAN2_MspDeInit 0 */
|
||||
|
||||
/* USER CODE END CAN2_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_CAN2_CLK_DISABLE();
|
||||
HAL_RCC_CAN1_CLK_ENABLED--;
|
||||
if(HAL_RCC_CAN1_CLK_ENABLED==0){
|
||||
__HAL_RCC_CAN1_CLK_DISABLE();
|
||||
}
|
||||
|
||||
/**CAN2 GPIO Configuration
|
||||
PB12 ------> CAN2_RX
|
||||
PB13 ------> CAN2_TX
|
||||
*/
|
||||
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_12|GPIO_PIN_13);
|
||||
|
||||
/* USER CODE BEGIN CAN2_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END CAN2_MspDeInit 1 */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DAC MSP Initialization
|
||||
* This function configures the hardware resources used in this example
|
||||
* @param hdac: DAC handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_DAC_MspInit(DAC_HandleTypeDef* hdac)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
if(hdac->Instance==DAC)
|
||||
{
|
||||
/* USER CODE BEGIN DAC_MspInit 0 */
|
||||
|
||||
/* USER CODE END DAC_MspInit 0 */
|
||||
/* Peripheral clock enable */
|
||||
__HAL_RCC_DAC_CLK_ENABLE();
|
||||
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
/**DAC GPIO Configuration
|
||||
PA4 ------> DAC_OUT1
|
||||
*/
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_4;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
/* USER CODE BEGIN DAC_MspInit 1 */
|
||||
|
||||
/* USER CODE END DAC_MspInit 1 */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DAC MSP De-Initialization
|
||||
* This function freeze the hardware resources used in this example
|
||||
* @param hdac: DAC handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_DAC_MspDeInit(DAC_HandleTypeDef* hdac)
|
||||
{
|
||||
if(hdac->Instance==DAC)
|
||||
{
|
||||
/* USER CODE BEGIN DAC_MspDeInit 0 */
|
||||
|
||||
/* USER CODE END DAC_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_DAC_CLK_DISABLE();
|
||||
|
||||
/**DAC GPIO Configuration
|
||||
PA4 ------> DAC_OUT1
|
||||
*/
|
||||
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_4);
|
||||
|
||||
/* USER CODE BEGIN DAC_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END DAC_MspDeInit 1 */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SPI MSP Initialization
|
||||
* This function configures the hardware resources used in this example
|
||||
* @param hspi: SPI handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
if(hspi->Instance==SPI1)
|
||||
{
|
||||
/* USER CODE BEGIN SPI1_MspInit 0 */
|
||||
|
||||
/* USER CODE END SPI1_MspInit 0 */
|
||||
/* Peripheral clock enable */
|
||||
__HAL_RCC_SPI1_CLK_ENABLE();
|
||||
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
/**SPI1 GPIO Configuration
|
||||
PA5 ------> SPI1_SCK
|
||||
PA6 ------> SPI1_MISO
|
||||
PA7 ------> SPI1_MOSI
|
||||
*/
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_7;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_6;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
/* USER CODE BEGIN SPI1_MspInit 1 */
|
||||
|
||||
/* USER CODE END SPI1_MspInit 1 */
|
||||
}
|
||||
else if(hspi->Instance==SPI3)
|
||||
{
|
||||
/* USER CODE BEGIN SPI3_MspInit 0 */
|
||||
|
||||
/* USER CODE END SPI3_MspInit 0 */
|
||||
/* Peripheral clock enable */
|
||||
__HAL_RCC_SPI3_CLK_ENABLE();
|
||||
|
||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||
/**SPI3 GPIO Configuration
|
||||
PC10 ------> SPI3_SCK
|
||||
PC11 ------> SPI3_MISO
|
||||
PC12 ------> SPI3_MOSI
|
||||
*/
|
||||
|
||||
//
|
||||
// GPIO_InitStruct.Pin = LTC_SCK_Pin|LTC_MOSI_Pin;
|
||||
// GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
// GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
// GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
// GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;
|
||||
// HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
//
|
||||
// GPIO_InitStruct.Pin = LTC_MISO_Pin;
|
||||
// GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
|
||||
// GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||
// GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
// GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;
|
||||
// HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
//
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_12;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_11;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; // before input
|
||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||
|
||||
__HAL_AFIO_REMAP_SPI3_ENABLE();
|
||||
|
||||
/* USER CODE BEGIN SPI3_MspInit 1 */
|
||||
|
||||
/* USER CODE END SPI3_MspInit 1 */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SPI MSP De-Initialization
|
||||
* This function freeze the hardware resources used in this example
|
||||
* @param hspi: SPI handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)
|
||||
{
|
||||
if(hspi->Instance==SPI1)
|
||||
{
|
||||
/* USER CODE BEGIN SPI1_MspDeInit 0 */
|
||||
|
||||
/* USER CODE END SPI1_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_SPI1_CLK_DISABLE();
|
||||
|
||||
/**SPI1 GPIO Configuration
|
||||
PA5 ------> SPI1_SCK
|
||||
PA6 ------> SPI1_MISO
|
||||
PA7 ------> SPI1_MOSI
|
||||
*/
|
||||
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7);
|
||||
|
||||
/* USER CODE BEGIN SPI1_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END SPI1_MspDeInit 1 */
|
||||
}
|
||||
else if(hspi->Instance==SPI3)
|
||||
{
|
||||
/* USER CODE BEGIN SPI3_MspDeInit 0 */
|
||||
|
||||
/* USER CODE END SPI3_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_SPI3_CLK_DISABLE();
|
||||
|
||||
/**SPI3 GPIO Configuration
|
||||
PC10 ------> SPI3_SCK
|
||||
PC11 ------> SPI3_MISO
|
||||
PC12 ------> SPI3_MOSI
|
||||
*/
|
||||
HAL_GPIO_DeInit(GPIOC, GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12);
|
||||
|
||||
/* USER CODE BEGIN SPI3_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END SPI3_MspDeInit 1 */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
|
||||
{
|
||||
if(htim_base->Instance==TIM6)
|
||||
{
|
||||
/* USER CODE BEGIN TIM6_MspInit 0 */
|
||||
|
||||
/* USER CODE END TIM6_MspInit 0 */
|
||||
/* Peripheral clock enable */
|
||||
__HAL_RCC_TIM6_CLK_ENABLE();
|
||||
/* TIM6 interrupt Init */
|
||||
HAL_NVIC_SetPriority(TIM6_IRQn, 1, 0);
|
||||
HAL_NVIC_EnableIRQ(TIM6_IRQn);
|
||||
/* USER CODE BEGIN TIM6_MspInit 1 */
|
||||
|
||||
/* USER CODE END TIM6_MspInit 1 */
|
||||
}
|
||||
if(htim_base->Instance==TIM2)
|
||||
{
|
||||
/* USER CODE BEGIN TIM6_MspInit 0 */
|
||||
|
||||
/* USER CODE END TIM6_MspInit 0 */
|
||||
/* Peripheral clock enable */
|
||||
__HAL_RCC_TIM2_CLK_ENABLE();
|
||||
|
||||
HAL_NVIC_SetPriority(TIM2_IRQn, 0, 0);
|
||||
HAL_NVIC_EnableIRQ(TIM2_IRQn);
|
||||
/* USER CODE BEGIN TIM6_MspInit 1 */
|
||||
|
||||
/* USER CODE END TIM6_MspInit 1 */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TIM_Base MSP De-Initialization
|
||||
* This function freeze the hardware resources used in this example
|
||||
* @param htim_base: TIM_Base handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base)
|
||||
{
|
||||
if(htim_base->Instance==TIM6)
|
||||
{
|
||||
/* USER CODE BEGIN TIM6_MspDeInit 0 */
|
||||
|
||||
/* USER CODE END TIM6_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_TIM6_CLK_DISABLE();
|
||||
|
||||
/* TIM6 interrupt DeInit */
|
||||
HAL_NVIC_DisableIRQ(TIM6_IRQn);
|
||||
/* USER CODE BEGIN TIM6_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END TIM6_MspDeInit 1 */
|
||||
}
|
||||
|
||||
if(htim_base->Instance==TIM2)
|
||||
{
|
||||
/* USER CODE BEGIN TIM6_MspDeInit 0 */
|
||||
|
||||
/* USER CODE END TIM6_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_TIM2_CLK_DISABLE();
|
||||
|
||||
/* TIM6 interrupt DeInit */
|
||||
HAL_NVIC_DisableIRQ(TIM2_IRQn);
|
||||
/* USER CODE BEGIN TIM6_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END TIM6_MspDeInit 1 */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief UART MSP Initialization
|
||||
* This function configures the hardware resources used in this example
|
||||
* @param huart: UART handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_UART_MspInit(UART_HandleTypeDef* huart)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
if(huart->Instance==USART2)
|
||||
{
|
||||
/* USER CODE BEGIN USART2_MspInit 0 */
|
||||
|
||||
/* USER CODE END USART2_MspInit 0 */
|
||||
/* Peripheral clock enable */
|
||||
__HAL_RCC_USART2_CLK_ENABLE();
|
||||
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
/**USART2 GPIO Configuration
|
||||
PA2 ------> USART2_TX
|
||||
PA3 ------> USART2_RX
|
||||
*/
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_2;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_3;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
/* USER CODE BEGIN USART2_MspInit 1 */
|
||||
HAL_NVIC_SetPriority(USART2_IRQn, 0, 0);
|
||||
HAL_NVIC_EnableIRQ(USART2_IRQn);
|
||||
/* USER CODE END USART2_MspInit 1 */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief UART MSP De-Initialization
|
||||
* This function freeze the hardware resources used in this example
|
||||
* @param huart: UART handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
|
||||
{
|
||||
if(huart->Instance==USART2)
|
||||
{
|
||||
/* USER CODE BEGIN USART2_MspDeInit 0 */
|
||||
|
||||
/* USER CODE END USART2_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_USART2_CLK_DISABLE();
|
||||
|
||||
/**USART2 GPIO Configuration
|
||||
PA2 ------> USART2_TX
|
||||
PA3 ------> USART2_RX
|
||||
*/
|
||||
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2|GPIO_PIN_3);
|
||||
|
||||
/* USER CODE BEGIN USART2_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END USART2_MspDeInit 1 */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
279
Core/Src/stm32f1xx_it.c
Normal file
279
Core/Src/stm32f1xx_it.c
Normal file
@@ -0,0 +1,279 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32f1xx_it.c
|
||||
* @brief Interrupt Service Routines.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2021 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "main.h"
|
||||
#include "stm32f1xx_it.h"
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN TD */
|
||||
extern UART_HandleTypeDef huart2;
|
||||
|
||||
/* USER CODE END TD */
|
||||
void USART2_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN USART2_IRQn 0 */
|
||||
|
||||
/* USER CODE END USART2_IRQn 0 */
|
||||
HAL_UART_IRQHandler(&huart2);
|
||||
/* USER CODE BEGIN USART2_IRQn 1 */
|
||||
|
||||
/* USER CODE END USART2_IRQn 1 */
|
||||
}
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PD */
|
||||
|
||||
/* USER CODE END PD */
|
||||
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PM */
|
||||
|
||||
/* USER CODE END PM */
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PV */
|
||||
|
||||
/* USER CODE END PV */
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/* USER CODE BEGIN PFP */
|
||||
|
||||
/* USER CODE END PFP */
|
||||
|
||||
/* Private user code ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN 0 */
|
||||
|
||||
/* USER CODE END 0 */
|
||||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
extern PCD_HandleTypeDef hpcd_USB_OTG_FS;
|
||||
extern TIM_HandleTypeDef htim2;
|
||||
extern TIM_HandleTypeDef htim6;
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
||||
/******************************************************************************/
|
||||
/* Cortex-M3 Processor Interruption and Exception Handlers */
|
||||
/******************************************************************************/
|
||||
/**
|
||||
* @brief This function handles Non maskable interrupt.
|
||||
*/
|
||||
void NMI_Handler(void)
|
||||
{
|
||||
/* USER CODE BEGIN NonMaskableInt_IRQn 0 */
|
||||
|
||||
/* USER CODE END NonMaskableInt_IRQn 0 */
|
||||
/* USER CODE BEGIN NonMaskableInt_IRQn 1 */
|
||||
while (1)
|
||||
{
|
||||
}
|
||||
/* USER CODE END NonMaskableInt_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles Hard fault interrupt.
|
||||
*/
|
||||
void HardFault_Handler(void)
|
||||
{
|
||||
/* USER CODE BEGIN HardFault_IRQn 0 */
|
||||
struct
|
||||
{
|
||||
uint32_t r0;
|
||||
uint32_t r1;
|
||||
uint32_t r2;
|
||||
uint32_t r3;
|
||||
uint32_t r12;
|
||||
uint32_t lr;
|
||||
uint32_t pc;
|
||||
uint32_t psr;
|
||||
}*stack_ptr; //Указатель на текущее значение стека(SP)
|
||||
|
||||
|
||||
asm(
|
||||
"TST lr, #4 \n" //Тестируем 3ий бит указателя стека(побитовое И)
|
||||
"ITE EQ \n" //Значение указателя стека имеет бит 3?
|
||||
"MRSEQ %[ptr], MSP \n" //Да, сохраняем основной указатель стека
|
||||
"MRSNE %[ptr], PSP \n" //Нет, сохраняем указатель стека процесса
|
||||
: [ptr] "=r" (stack_ptr)
|
||||
);
|
||||
|
||||
/* USER CODE END HardFault_IRQn 0 */
|
||||
while (1)
|
||||
{
|
||||
/* USER CODE BEGIN W1_HardFault_IRQn 0 */
|
||||
|
||||
HAL_GPIO_WritePin(HL2_GPIO_Port, HL2_Pin, GPIO_PIN_SET);
|
||||
HAL_GPIO_WritePin(HL3_GPIO_Port, HL3_Pin, GPIO_PIN_SET);
|
||||
HAL_GPIO_WritePin(HL4_GPIO_Port, HL4_Pin, GPIO_PIN_SET);
|
||||
HAL_GPIO_WritePin(HL5_GPIO_Port, HL5_Pin, GPIO_PIN_SET);
|
||||
|
||||
/* USER CODE END W1_HardFault_IRQn 0 */
|
||||
}
|
||||
}
|
||||
|
||||
void TIM2_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN TIM6_IRQn 0 */
|
||||
|
||||
/* USER CODE END TIM6_IRQn 0 */
|
||||
HAL_TIM_IRQHandler(&htim2);
|
||||
/* USER CODE BEGIN TIM6_IRQn 1 */
|
||||
|
||||
/* USER CODE END TIM6_IRQn 1 */
|
||||
}
|
||||
|
||||
|
||||
void TIM6_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN TIM6_IRQn 0 */
|
||||
|
||||
/* USER CODE END TIM6_IRQn 0 */
|
||||
HAL_TIM_IRQHandler(&htim6);
|
||||
/* USER CODE BEGIN TIM6_IRQn 1 */
|
||||
|
||||
/* USER CODE END TIM6_IRQn 1 */
|
||||
}
|
||||
/**
|
||||
* @brief This function handles Memory management fault.
|
||||
*/
|
||||
void MemManage_Handler(void)
|
||||
{
|
||||
/* USER CODE BEGIN MemoryManagement_IRQn 0 */
|
||||
|
||||
/* USER CODE END MemoryManagement_IRQn 0 */
|
||||
while (1)
|
||||
{
|
||||
/* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */
|
||||
/* USER CODE END W1_MemoryManagement_IRQn 0 */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles Prefetch fault, memory access fault.
|
||||
*/
|
||||
void BusFault_Handler(void)
|
||||
{
|
||||
/* USER CODE BEGIN BusFault_IRQn 0 */
|
||||
|
||||
/* USER CODE END BusFault_IRQn 0 */
|
||||
while (1)
|
||||
{
|
||||
/* USER CODE BEGIN W1_BusFault_IRQn 0 */
|
||||
/* USER CODE END W1_BusFault_IRQn 0 */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles Undefined instruction or illegal state.
|
||||
*/
|
||||
void UsageFault_Handler(void)
|
||||
{
|
||||
/* USER CODE BEGIN UsageFault_IRQn 0 */
|
||||
|
||||
/* USER CODE END UsageFault_IRQn 0 */
|
||||
while (1)
|
||||
{
|
||||
/* USER CODE BEGIN W1_UsageFault_IRQn 0 */
|
||||
/* USER CODE END W1_UsageFault_IRQn 0 */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles System service call via SWI instruction.
|
||||
*/
|
||||
void SVC_Handler(void)
|
||||
{
|
||||
/* USER CODE BEGIN SVCall_IRQn 0 */
|
||||
|
||||
/* USER CODE END SVCall_IRQn 0 */
|
||||
/* USER CODE BEGIN SVCall_IRQn 1 */
|
||||
|
||||
/* USER CODE END SVCall_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles Debug monitor.
|
||||
*/
|
||||
void DebugMon_Handler(void)
|
||||
{
|
||||
/* USER CODE BEGIN DebugMonitor_IRQn 0 */
|
||||
|
||||
/* USER CODE END DebugMonitor_IRQn 0 */
|
||||
/* USER CODE BEGIN DebugMonitor_IRQn 1 */
|
||||
|
||||
/* USER CODE END DebugMonitor_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles Pendable request for system service.
|
||||
*/
|
||||
void PendSV_Handler(void)
|
||||
{
|
||||
/* USER CODE BEGIN PendSV_IRQn 0 */
|
||||
|
||||
/* USER CODE END PendSV_IRQn 0 */
|
||||
/* USER CODE BEGIN PendSV_IRQn 1 */
|
||||
|
||||
/* USER CODE END PendSV_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles System tick timer.
|
||||
*/
|
||||
void SysTick_Handler(void)
|
||||
{
|
||||
/* USER CODE BEGIN SysTick_IRQn 0 */
|
||||
|
||||
/* USER CODE END SysTick_IRQn 0 */
|
||||
HAL_IncTick();
|
||||
/* USER CODE BEGIN SysTick_IRQn 1 */
|
||||
|
||||
/* USER CODE END SysTick_IRQn 1 */
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* STM32F1xx Peripheral Interrupt Handlers */
|
||||
/* Add here the Interrupt Handlers for the used peripherals. */
|
||||
/* For the available peripheral interrupt handler names, */
|
||||
/* please refer to the startup file (startup_stm32f1xx.s). */
|
||||
/******************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief This function handles USB OTG FS global interrupt.
|
||||
*/
|
||||
void OTG_FS_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN OTG_FS_IRQn 0 */
|
||||
|
||||
/* USER CODE END OTG_FS_IRQn 0 */
|
||||
HAL_PCD_IRQHandler(&hpcd_USB_OTG_FS);
|
||||
/* USER CODE BEGIN OTG_FS_IRQn 1 */
|
||||
|
||||
/* USER CODE END OTG_FS_IRQn 1 */
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
207
Core/Src/syscalls.c
Normal file
207
Core/Src/syscalls.c
Normal file
@@ -0,0 +1,207 @@
|
||||
/**
|
||||
*****************************************************************************
|
||||
**
|
||||
** File : syscalls.c
|
||||
**
|
||||
** Author : Auto-generated by System workbench for STM32
|
||||
**
|
||||
** Abstract : System Workbench Minimal System calls file
|
||||
**
|
||||
** For more information about which c-functions
|
||||
** need which of these lowlevel functions
|
||||
** please consult the Newlib libc-manual
|
||||
**
|
||||
** Target : STMicroelectronics STM32
|
||||
**
|
||||
** Distribution: The file is distributed “as is,” without any warranty
|
||||
** of any kind.
|
||||
**
|
||||
*****************************************************************************
|
||||
** @attention
|
||||
**
|
||||
** <h2><center>© COPYRIGHT(c) 2019 STMicroelectronics</center></h2>
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without modification,
|
||||
** are permitted provided that the following conditions are met:
|
||||
** 1. Redistributions of source code must retain the above copyright notice,
|
||||
** this list of conditions and the following disclaimer.
|
||||
** 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
** this list of conditions and the following disclaimer in the documentation
|
||||
** and/or other materials provided with the distribution.
|
||||
** 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
** may be used to endorse or promote products derived from this software
|
||||
** without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes */
|
||||
#include <sys/stat.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/times.h>
|
||||
|
||||
|
||||
/* Variables */
|
||||
//#undef errno
|
||||
extern int errno;
|
||||
extern int __io_putchar(int ch) __attribute__((weak));
|
||||
extern int __io_getchar(void) __attribute__((weak));
|
||||
|
||||
register char * stack_ptr asm("sp");
|
||||
|
||||
char *__env[1] = { 0 };
|
||||
char **environ = __env;
|
||||
|
||||
|
||||
/* Functions */
|
||||
void initialise_monitor_handles()
|
||||
{
|
||||
}
|
||||
|
||||
int _getpid(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _kill(int pid, int sig)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
void _exit (int status)
|
||||
{
|
||||
_kill(status, -1);
|
||||
while (1) {} /* Make sure we hang here */
|
||||
}
|
||||
|
||||
__attribute__((weak)) int _read(int file, char *ptr, int len)
|
||||
{
|
||||
int DataIdx;
|
||||
|
||||
for (DataIdx = 0; DataIdx < len; DataIdx++)
|
||||
{
|
||||
*ptr++ = __io_getchar();
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
__attribute__((weak)) int _write(int file, char *ptr, int len)
|
||||
{
|
||||
int DataIdx;
|
||||
|
||||
for (DataIdx = 0; DataIdx < len; DataIdx++)
|
||||
{
|
||||
__io_putchar(*ptr++);
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
caddr_t _sbrk(int incr)
|
||||
{
|
||||
extern char end asm("end");
|
||||
static char *heap_end;
|
||||
char *prev_heap_end;
|
||||
|
||||
if (heap_end == 0)
|
||||
heap_end = &end;
|
||||
|
||||
prev_heap_end = heap_end;
|
||||
if (heap_end + incr > stack_ptr)
|
||||
{
|
||||
// write(1, "Heap and stack collision\n", 25);
|
||||
// abort();
|
||||
errno = ENOMEM;
|
||||
return (caddr_t) -1;
|
||||
}
|
||||
|
||||
heap_end += incr;
|
||||
|
||||
return (caddr_t) prev_heap_end;
|
||||
}
|
||||
|
||||
int _close(int file)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int _fstat(int file, struct stat *st)
|
||||
{
|
||||
st->st_mode = S_IFCHR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _isatty(int file)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _lseek(int file, int ptr, int dir)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _open(char *path, int flags, ...)
|
||||
{
|
||||
/* Pretend like we always fail */
|
||||
return -1;
|
||||
}
|
||||
|
||||
int _wait(int *status)
|
||||
{
|
||||
errno = ECHILD;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int _unlink(char *name)
|
||||
{
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int _times(struct tms *buf)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int _stat(char *file, struct stat *st)
|
||||
{
|
||||
st->st_mode = S_IFCHR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _link(char *old, char *new)
|
||||
{
|
||||
errno = EMLINK;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int _fork(void)
|
||||
{
|
||||
errno = EAGAIN;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int _execve(char *name, char **argv, char **env)
|
||||
{
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
408
Core/Src/system_stm32f1xx.c
Normal file
408
Core/Src/system_stm32f1xx.c
Normal file
@@ -0,0 +1,408 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file system_stm32f1xx.c
|
||||
* @author MCD Application Team
|
||||
* @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Source File.
|
||||
*
|
||||
* 1. This file provides two functions and one global variable to be called from
|
||||
* user application:
|
||||
* - SystemInit(): Setups the system clock (System clock source, PLL Multiplier
|
||||
* factors, AHB/APBx prescalers and Flash settings).
|
||||
* This function is called at startup just after reset and
|
||||
* before branch to main program. This call is made inside
|
||||
* the "startup_stm32f1xx_xx.s" file.
|
||||
*
|
||||
* - SystemCoreClock variable: Contains the core clock (HCLK), it can be used
|
||||
* by the user application to setup the SysTick
|
||||
* timer or configure other parameters.
|
||||
*
|
||||
* - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must
|
||||
* be called whenever the core clock is changed
|
||||
* during program execution.
|
||||
*
|
||||
* 2. After each device reset the HSI (8 MHz) is used as system clock source.
|
||||
* Then SystemInit() function is called, in "startup_stm32f1xx_xx.s" file, to
|
||||
* configure the system clock before to branch to main program.
|
||||
*
|
||||
* 4. The default value of HSE crystal is set to 8 MHz (or 25 MHz, depending on
|
||||
* the product used), refer to "HSE_VALUE".
|
||||
* When HSE is used as system clock source, directly or through PLL, and you
|
||||
* are using different crystal you have to adapt the HSE value to your own
|
||||
* configuration.
|
||||
*
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2017 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/** @addtogroup CMSIS
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup stm32f1xx_system
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32F1xx_System_Private_Includes
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include "stm32f1xx.h"
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32F1xx_System_Private_TypesDefinitions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32F1xx_System_Private_Defines
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if !defined (HSE_VALUE)
|
||||
#define HSE_VALUE 8000000U /*!< Default value of the External oscillator in Hz.
|
||||
This value can be provided and adapted by the user application. */
|
||||
#endif /* HSE_VALUE */
|
||||
|
||||
#if !defined (HSI_VALUE)
|
||||
#define HSI_VALUE 8000000U /*!< Default value of the Internal oscillator in Hz.
|
||||
This value can be provided and adapted by the user application. */
|
||||
#endif /* HSI_VALUE */
|
||||
|
||||
/*!< Uncomment the following line if you need to use external SRAM */
|
||||
#if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG)
|
||||
/* #define DATA_IN_ExtSRAM */
|
||||
#endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */
|
||||
|
||||
/* Note: Following vector table addresses must be defined in line with linker
|
||||
configuration. */
|
||||
/*!< Uncomment the following line if you need to relocate the vector table
|
||||
anywhere in Flash or Sram, else the vector table is kept at the automatic
|
||||
remap of boot address selected */
|
||||
#define USER_VECT_TAB_ADDRESS
|
||||
|
||||
#if defined(USER_VECT_TAB_ADDRESS)
|
||||
/*!< Uncomment the following line if you need to relocate your vector Table
|
||||
in Sram else user remap will be done in Flash. */
|
||||
/* #define VECT_TAB_SRAM */
|
||||
#if defined(VECT_TAB_SRAM)
|
||||
#define VECT_TAB_BASE_ADDRESS SRAM_BASE /*!< Vector Table base address field.
|
||||
This value must be a multiple of 0x200. */
|
||||
#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
|
||||
This value must be a multiple of 0x200. */
|
||||
#else
|
||||
#define VECT_TAB_BASE_ADDRESS FLASH_BASE /*!< Vector Table base address field.
|
||||
This value must be a multiple of 0x200. */
|
||||
#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
|
||||
This value must be a multiple of 0x200. */
|
||||
#endif /* VECT_TAB_SRAM */
|
||||
#endif /* USER_VECT_TAB_ADDRESS */
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32F1xx_System_Private_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32F1xx_System_Private_Variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* This variable is updated in three ways:
|
||||
1) by calling CMSIS function SystemCoreClockUpdate()
|
||||
2) by calling HAL API function HAL_RCC_GetHCLKFreq()
|
||||
3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency
|
||||
Note: If you use this function to configure the system clock; then there
|
||||
is no need to call the 2 first functions listed above, since SystemCoreClock
|
||||
variable is updated automatically.
|
||||
*/
|
||||
uint32_t SystemCoreClock = 16000000;
|
||||
const uint8_t AHBPrescTable[16U] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
|
||||
const uint8_t APBPrescTable[8U] = {0, 0, 0, 0, 1, 2, 3, 4};
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32F1xx_System_Private_FunctionPrototypes
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG)
|
||||
#ifdef DATA_IN_ExtSRAM
|
||||
static void SystemInit_ExtMemCtl(void);
|
||||
#endif /* DATA_IN_ExtSRAM */
|
||||
#endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32F1xx_System_Private_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Setup the microcontroller system
|
||||
* Initialize the Embedded Flash Interface, the PLL and update the
|
||||
* SystemCoreClock variable.
|
||||
* @note This function should be used only after reset.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void SystemInit (void)
|
||||
{
|
||||
#if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG)
|
||||
#ifdef DATA_IN_ExtSRAM
|
||||
SystemInit_ExtMemCtl();
|
||||
#endif /* DATA_IN_ExtSRAM */
|
||||
#endif
|
||||
|
||||
/* Configure the Vector Table location -------------------------------------*/
|
||||
#if defined(USER_VECT_TAB_ADDRESS)
|
||||
SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM. */
|
||||
#endif /* USER_VECT_TAB_ADDRESS */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Update SystemCoreClock variable according to Clock Register Values.
|
||||
* The SystemCoreClock variable contains the core clock (HCLK), it can
|
||||
* be used by the user application to setup the SysTick timer or configure
|
||||
* other parameters.
|
||||
*
|
||||
* @note Each time the core clock (HCLK) changes, this function must be called
|
||||
* to update SystemCoreClock variable value. Otherwise, any configuration
|
||||
* based on this variable will be incorrect.
|
||||
*
|
||||
* @note - The system frequency computed by this function is not the real
|
||||
* frequency in the chip. It is calculated based on the predefined
|
||||
* constant and the selected clock source:
|
||||
*
|
||||
* - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*)
|
||||
*
|
||||
* - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**)
|
||||
*
|
||||
* - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**)
|
||||
* or HSI_VALUE(*) multiplied by the PLL factors.
|
||||
*
|
||||
* (*) HSI_VALUE is a constant defined in stm32f1xx.h file (default value
|
||||
* 8 MHz) but the real value may vary depending on the variations
|
||||
* in voltage and temperature.
|
||||
*
|
||||
* (**) HSE_VALUE is a constant defined in stm32f1xx.h file (default value
|
||||
* 8 MHz or 25 MHz, depending on the product used), user has to ensure
|
||||
* that HSE_VALUE is same as the real frequency of the crystal used.
|
||||
* Otherwise, this function may have wrong result.
|
||||
*
|
||||
* - The result of this function could be not correct when using fractional
|
||||
* value for HSE crystal.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void SystemCoreClockUpdate (void)
|
||||
{
|
||||
uint32_t tmp = 0U, pllmull = 0U, pllsource = 0U;
|
||||
|
||||
#if defined(STM32F105xC) || defined(STM32F107xC)
|
||||
uint32_t prediv1source = 0U, prediv1factor = 0U, prediv2factor = 0U, pll2mull = 0U;
|
||||
#endif /* STM32F105xC */
|
||||
|
||||
#if defined(STM32F100xB) || defined(STM32F100xE)
|
||||
uint32_t prediv1factor = 0U;
|
||||
#endif /* STM32F100xB or STM32F100xE */
|
||||
|
||||
/* Get SYSCLK source -------------------------------------------------------*/
|
||||
tmp = RCC->CFGR & RCC_CFGR_SWS;
|
||||
|
||||
switch (tmp)
|
||||
{
|
||||
case 0x00U: /* HSI used as system clock */
|
||||
SystemCoreClock = HSI_VALUE;
|
||||
break;
|
||||
case 0x04U: /* HSE used as system clock */
|
||||
SystemCoreClock = HSE_VALUE;
|
||||
break;
|
||||
case 0x08U: /* PLL used as system clock */
|
||||
|
||||
/* Get PLL clock source and multiplication factor ----------------------*/
|
||||
pllmull = RCC->CFGR & RCC_CFGR_PLLMULL;
|
||||
pllsource = RCC->CFGR & RCC_CFGR_PLLSRC;
|
||||
|
||||
#if !defined(STM32F105xC) && !defined(STM32F107xC)
|
||||
pllmull = ( pllmull >> 18U) + 2U;
|
||||
|
||||
if (pllsource == 0x00U)
|
||||
{
|
||||
/* HSI oscillator clock divided by 2 selected as PLL clock entry */
|
||||
SystemCoreClock = (HSI_VALUE >> 1U) * pllmull;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(STM32F100xB) || defined(STM32F100xE)
|
||||
prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1U;
|
||||
/* HSE oscillator clock selected as PREDIV1 clock entry */
|
||||
SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull;
|
||||
#else
|
||||
/* HSE selected as PLL clock entry */
|
||||
if ((RCC->CFGR & RCC_CFGR_PLLXTPRE) != (uint32_t)RESET)
|
||||
{/* HSE oscillator clock divided by 2 */
|
||||
SystemCoreClock = (HSE_VALUE >> 1U) * pllmull;
|
||||
}
|
||||
else
|
||||
{
|
||||
SystemCoreClock = HSE_VALUE * pllmull;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
pllmull = pllmull >> 18U;
|
||||
|
||||
if (pllmull != 0x0DU)
|
||||
{
|
||||
pllmull += 2U;
|
||||
}
|
||||
else
|
||||
{ /* PLL multiplication factor = PLL input clock * 6.5 */
|
||||
pllmull = 13U / 2U;
|
||||
}
|
||||
|
||||
if (pllsource == 0x00U)
|
||||
{
|
||||
/* HSI oscillator clock divided by 2 selected as PLL clock entry */
|
||||
SystemCoreClock = (HSI_VALUE >> 1U) * pllmull;
|
||||
}
|
||||
else
|
||||
{/* PREDIV1 selected as PLL clock entry */
|
||||
|
||||
/* Get PREDIV1 clock source and division factor */
|
||||
prediv1source = RCC->CFGR2 & RCC_CFGR2_PREDIV1SRC;
|
||||
prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1U;
|
||||
|
||||
if (prediv1source == 0U)
|
||||
{
|
||||
/* HSE oscillator clock selected as PREDIV1 clock entry */
|
||||
SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull;
|
||||
}
|
||||
else
|
||||
{/* PLL2 clock selected as PREDIV1 clock entry */
|
||||
|
||||
/* Get PREDIV2 division factor and PLL2 multiplication factor */
|
||||
prediv2factor = ((RCC->CFGR2 & RCC_CFGR2_PREDIV2) >> 4U) + 1U;
|
||||
pll2mull = ((RCC->CFGR2 & RCC_CFGR2_PLL2MUL) >> 8U) + 2U;
|
||||
SystemCoreClock = (((HSE_VALUE / prediv2factor) * pll2mull) / prediv1factor) * pllmull;
|
||||
}
|
||||
}
|
||||
#endif /* STM32F105xC */
|
||||
break;
|
||||
|
||||
default:
|
||||
SystemCoreClock = HSI_VALUE;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Compute HCLK clock frequency ----------------*/
|
||||
/* Get HCLK prescaler */
|
||||
tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4U)];
|
||||
/* HCLK clock frequency */
|
||||
SystemCoreClock >>= tmp;
|
||||
}
|
||||
|
||||
#if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG)
|
||||
/**
|
||||
* @brief Setup the external memory controller. Called in startup_stm32f1xx.s
|
||||
* before jump to __main
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
#ifdef DATA_IN_ExtSRAM
|
||||
/**
|
||||
* @brief Setup the external memory controller.
|
||||
* Called in startup_stm32f1xx_xx.s/.c before jump to main.
|
||||
* This function configures the external SRAM mounted on STM3210E-EVAL
|
||||
* board (STM32 High density devices). This SRAM will be used as program
|
||||
* data memory (including heap and stack).
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void SystemInit_ExtMemCtl(void)
|
||||
{
|
||||
__IO uint32_t tmpreg;
|
||||
/*!< FSMC Bank1 NOR/SRAM3 is used for the STM3210E-EVAL, if another Bank is
|
||||
required, then adjust the Register Addresses */
|
||||
|
||||
/* Enable FSMC clock */
|
||||
RCC->AHBENR = 0x00000114U;
|
||||
|
||||
/* Delay after an RCC peripheral clock enabling */
|
||||
tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_FSMCEN);
|
||||
|
||||
/* Enable GPIOD, GPIOE, GPIOF and GPIOG clocks */
|
||||
RCC->APB2ENR = 0x000001E0U;
|
||||
|
||||
/* Delay after an RCC peripheral clock enabling */
|
||||
tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_IOPDEN);
|
||||
|
||||
(void)(tmpreg);
|
||||
|
||||
/* --------------- SRAM Data lines, NOE and NWE configuration ---------------*/
|
||||
/*---------------- SRAM Address lines configuration -------------------------*/
|
||||
/*---------------- NOE and NWE configuration --------------------------------*/
|
||||
/*---------------- NE3 configuration ----------------------------------------*/
|
||||
/*---------------- NBL0, NBL1 configuration ---------------------------------*/
|
||||
|
||||
GPIOD->CRL = 0x44BB44BBU;
|
||||
GPIOD->CRH = 0xBBBBBBBBU;
|
||||
|
||||
GPIOE->CRL = 0xB44444BBU;
|
||||
GPIOE->CRH = 0xBBBBBBBBU;
|
||||
|
||||
GPIOF->CRL = 0x44BBBBBBU;
|
||||
GPIOF->CRH = 0xBBBB4444U;
|
||||
|
||||
GPIOG->CRL = 0x44BBBBBBU;
|
||||
GPIOG->CRH = 0x444B4B44U;
|
||||
|
||||
/*---------------- FSMC Configuration ---------------------------------------*/
|
||||
/*---------------- Enable FSMC Bank1_SRAM Bank ------------------------------*/
|
||||
|
||||
FSMC_Bank1->BTCR[4U] = 0x00001091U;
|
||||
FSMC_Bank1->BTCR[5U] = 0x00110212U;
|
||||
}
|
||||
#endif /* DATA_IN_ExtSRAM */
|
||||
#endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
2
Core/desktop.ini
Normal file
2
Core/desktop.ini
Normal file
@@ -0,0 +1,2 @@
|
||||
[.ShellClassInfo]
|
||||
IconResource=C:\Program Files\Google\Drive File Stream\54.0.3.0\GoogleDriveFS.exe,23
|
||||
2
Drivers/CMSIS/Device/ST/STM32F1xx/Include/desktop.ini
Normal file
2
Drivers/CMSIS/Device/ST/STM32F1xx/Include/desktop.ini
Normal file
@@ -0,0 +1,2 @@
|
||||
[.ShellClassInfo]
|
||||
IconResource=C:\Program Files\Google\Drive File Stream\54.0.3.0\GoogleDriveFS.exe,23
|
||||
15247
Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f107xc.h
Normal file
15247
Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f107xc.h
Normal file
File diff suppressed because it is too large
Load Diff
220
Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h
Normal file
220
Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h
Normal file
@@ -0,0 +1,220 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32f1xx.h
|
||||
* @author MCD Application Team
|
||||
* @brief CMSIS STM32F1xx Device Peripheral Access Layer Header File.
|
||||
*
|
||||
* The file is the unique include file that the application programmer
|
||||
* is using in the C source code, usually in main.c. This file contains:
|
||||
* - Configuration section that allows to select:
|
||||
* - The STM32F1xx device used in the target application
|
||||
* - To use or not the peripheral’s drivers in application code(i.e.
|
||||
* code will be based on direct access to peripheral’s registers
|
||||
* rather than drivers API), this option is controlled by
|
||||
* "#define USE_HAL_DRIVER"
|
||||
*
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2017 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/** @addtogroup CMSIS
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup stm32f1xx
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __STM32F1XX_H
|
||||
#define __STM32F1XX_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/** @addtogroup Library_configuration_section
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief STM32 Family
|
||||
*/
|
||||
#if !defined (STM32F1)
|
||||
#define STM32F1
|
||||
#endif /* STM32F1 */
|
||||
|
||||
/* Uncomment the line below according to the target STM32L device used in your
|
||||
application
|
||||
*/
|
||||
|
||||
#if !defined (STM32F100xB) && !defined (STM32F100xE) && !defined (STM32F101x6) && \
|
||||
!defined (STM32F101xB) && !defined (STM32F101xE) && !defined (STM32F101xG) && !defined (STM32F102x6) && !defined (STM32F102xB) && !defined (STM32F103x6) && \
|
||||
!defined (STM32F103xB) && !defined (STM32F103xE) && !defined (STM32F103xG) && !defined (STM32F105xC) && !defined (STM32F107xC)
|
||||
/* #define STM32F100xB */ /*!< STM32F100C4, STM32F100R4, STM32F100C6, STM32F100R6, STM32F100C8, STM32F100R8, STM32F100V8, STM32F100CB, STM32F100RB and STM32F100VB */
|
||||
/* #define STM32F100xE */ /*!< STM32F100RC, STM32F100VC, STM32F100ZC, STM32F100RD, STM32F100VD, STM32F100ZD, STM32F100RE, STM32F100VE and STM32F100ZE */
|
||||
/* #define STM32F101x6 */ /*!< STM32F101C4, STM32F101R4, STM32F101T4, STM32F101C6, STM32F101R6 and STM32F101T6 Devices */
|
||||
/* #define STM32F101xB */ /*!< STM32F101C8, STM32F101R8, STM32F101T8, STM32F101V8, STM32F101CB, STM32F101RB, STM32F101TB and STM32F101VB */
|
||||
/* #define STM32F101xE */ /*!< STM32F101RC, STM32F101VC, STM32F101ZC, STM32F101RD, STM32F101VD, STM32F101ZD, STM32F101RE, STM32F101VE and STM32F101ZE */
|
||||
/* #define STM32F101xG */ /*!< STM32F101RF, STM32F101VF, STM32F101ZF, STM32F101RG, STM32F101VG and STM32F101ZG */
|
||||
/* #define STM32F102x6 */ /*!< STM32F102C4, STM32F102R4, STM32F102C6 and STM32F102R6 */
|
||||
/* #define STM32F102xB */ /*!< STM32F102C8, STM32F102R8, STM32F102CB and STM32F102RB */
|
||||
/* #define STM32F103x6 */ /*!< STM32F103C4, STM32F103R4, STM32F103T4, STM32F103C6, STM32F103R6 and STM32F103T6 */
|
||||
/* #define STM32F103xB */ /*!< STM32F103C8, STM32F103R8, STM32F103T8, STM32F103V8, STM32F103CB, STM32F103RB, STM32F103TB and STM32F103VB */
|
||||
/* #define STM32F103xE */ /*!< STM32F103RC, STM32F103VC, STM32F103ZC, STM32F103RD, STM32F103VD, STM32F103ZD, STM32F103RE, STM32F103VE and STM32F103ZE */
|
||||
/* #define STM32F103xG */ /*!< STM32F103RF, STM32F103VF, STM32F103ZF, STM32F103RG, STM32F103VG and STM32F103ZG */
|
||||
/* #define STM32F105xC */ /*!< STM32F105R8, STM32F105V8, STM32F105RB, STM32F105VB, STM32F105RC and STM32F105VC */
|
||||
/* #define STM32F107xC */ /*!< STM32F107RB, STM32F107VB, STM32F107RC and STM32F107VC */
|
||||
#endif
|
||||
|
||||
/* Tip: To avoid modifying this file each time you need to switch between these
|
||||
devices, you can define the device in your toolchain compiler preprocessor.
|
||||
*/
|
||||
|
||||
#if !defined (USE_HAL_DRIVER)
|
||||
/**
|
||||
* @brief Comment the line below if you will not use the peripherals drivers.
|
||||
In this case, these drivers will not be included and the application code will
|
||||
be based on direct access to peripherals registers
|
||||
*/
|
||||
/*#define USE_HAL_DRIVER */
|
||||
#endif /* USE_HAL_DRIVER */
|
||||
|
||||
/**
|
||||
* @brief CMSIS Device version number V4.3.2
|
||||
*/
|
||||
#define __STM32F1_CMSIS_VERSION_MAIN (0x04) /*!< [31:24] main version */
|
||||
#define __STM32F1_CMSIS_VERSION_SUB1 (0x03) /*!< [23:16] sub1 version */
|
||||
#define __STM32F1_CMSIS_VERSION_SUB2 (0x02) /*!< [15:8] sub2 version */
|
||||
#define __STM32F1_CMSIS_VERSION_RC (0x00) /*!< [7:0] release candidate */
|
||||
#define __STM32F1_CMSIS_VERSION ((__STM32F1_CMSIS_VERSION_MAIN << 24)\
|
||||
|(__STM32F1_CMSIS_VERSION_SUB1 << 16)\
|
||||
|(__STM32F1_CMSIS_VERSION_SUB2 << 8 )\
|
||||
|(__STM32F1_CMSIS_VERSION_RC))
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup Device_Included
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if defined(STM32F100xB)
|
||||
#include "stm32f100xb.h"
|
||||
#elif defined(STM32F100xE)
|
||||
#include "stm32f100xe.h"
|
||||
#elif defined(STM32F101x6)
|
||||
#include "stm32f101x6.h"
|
||||
#elif defined(STM32F101xB)
|
||||
#include "stm32f101xb.h"
|
||||
#elif defined(STM32F101xE)
|
||||
#include "stm32f101xe.h"
|
||||
#elif defined(STM32F101xG)
|
||||
#include "stm32f101xg.h"
|
||||
#elif defined(STM32F102x6)
|
||||
#include "stm32f102x6.h"
|
||||
#elif defined(STM32F102xB)
|
||||
#include "stm32f102xb.h"
|
||||
#elif defined(STM32F103x6)
|
||||
#include "stm32f103x6.h"
|
||||
#elif defined(STM32F103xB)
|
||||
#include "stm32f103xb.h"
|
||||
#elif defined(STM32F103xE)
|
||||
#include "stm32f103xe.h"
|
||||
#elif defined(STM32F103xG)
|
||||
#include "stm32f103xg.h"
|
||||
#elif defined(STM32F105xC)
|
||||
#include "stm32f105xc.h"
|
||||
#elif defined(STM32F107xC)
|
||||
#include "stm32f107xc.h"
|
||||
#else
|
||||
#error "Please select first the target STM32F1xx device used in your application (in stm32f1xx.h file)"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup Exported_types
|
||||
* @{
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
RESET = 0,
|
||||
SET = !RESET
|
||||
} FlagStatus, ITStatus;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DISABLE = 0,
|
||||
ENABLE = !DISABLE
|
||||
} FunctionalState;
|
||||
#define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE))
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SUCCESS = 0U,
|
||||
ERROR = !SUCCESS
|
||||
} ErrorStatus;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @addtogroup Exported_macros
|
||||
* @{
|
||||
*/
|
||||
#define SET_BIT(REG, BIT) ((REG) |= (BIT))
|
||||
|
||||
#define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT))
|
||||
|
||||
#define READ_BIT(REG, BIT) ((REG) & (BIT))
|
||||
|
||||
#define CLEAR_REG(REG) ((REG) = (0x0))
|
||||
|
||||
#define WRITE_REG(REG, VAL) ((REG) = (VAL))
|
||||
|
||||
#define READ_REG(REG) ((REG))
|
||||
|
||||
#define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK)))
|
||||
|
||||
#define POSITION_VAL(VAL) (__CLZ(__RBIT(VAL)))
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#if defined (USE_HAL_DRIVER)
|
||||
#include "stm32f1xx_hal.h"
|
||||
#endif /* USE_HAL_DRIVER */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __STM32F1xx_H */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
98
Drivers/CMSIS/Device/ST/STM32F1xx/Include/system_stm32f1xx.h
Normal file
98
Drivers/CMSIS/Device/ST/STM32F1xx/Include/system_stm32f1xx.h
Normal file
@@ -0,0 +1,98 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file system_stm32f10x.h
|
||||
* @author MCD Application Team
|
||||
* @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Header File.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2017 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/** @addtogroup CMSIS
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup stm32f10x_system
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Define to prevent recursive inclusion
|
||||
*/
|
||||
#ifndef __SYSTEM_STM32F10X_H
|
||||
#define __SYSTEM_STM32F10X_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @addtogroup STM32F10x_System_Includes
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @addtogroup STM32F10x_System_Exported_types
|
||||
* @{
|
||||
*/
|
||||
|
||||
extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */
|
||||
extern const uint8_t AHBPrescTable[16U]; /*!< AHB prescalers table values */
|
||||
extern const uint8_t APBPrescTable[8U]; /*!< APB prescalers table values */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32F10x_System_Exported_Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32F10x_System_Exported_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32F10x_System_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
extern void SystemInit(void);
|
||||
extern void SystemCoreClockUpdate(void);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__SYSTEM_STM32F10X_H */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
@@ -0,0 +1,2 @@
|
||||
[.ShellClassInfo]
|
||||
IconResource=C:\Program Files\Google\Drive File Stream\54.0.3.0\GoogleDriveFS.exe,23
|
||||
2
Drivers/CMSIS/Device/ST/STM32F1xx/Source/desktop.ini
Normal file
2
Drivers/CMSIS/Device/ST/STM32F1xx/Source/desktop.ini
Normal file
@@ -0,0 +1,2 @@
|
||||
[.ShellClassInfo]
|
||||
IconResource=C:\Program Files\Google\Drive File Stream\54.0.3.0\GoogleDriveFS.exe,23
|
||||
2
Drivers/CMSIS/Device/ST/STM32F1xx/desktop.ini
Normal file
2
Drivers/CMSIS/Device/ST/STM32F1xx/desktop.ini
Normal file
@@ -0,0 +1,2 @@
|
||||
[.ShellClassInfo]
|
||||
IconResource=C:\Program Files\Google\Drive File Stream\54.0.3.0\GoogleDriveFS.exe,23
|
||||
2
Drivers/CMSIS/Device/ST/desktop.ini
Normal file
2
Drivers/CMSIS/Device/ST/desktop.ini
Normal file
@@ -0,0 +1,2 @@
|
||||
[.ShellClassInfo]
|
||||
IconResource=C:\Program Files\Google\Drive File Stream\54.0.3.0\GoogleDriveFS.exe,23
|
||||
2
Drivers/CMSIS/Device/desktop.ini
Normal file
2
Drivers/CMSIS/Device/desktop.ini
Normal file
@@ -0,0 +1,2 @@
|
||||
[.ShellClassInfo]
|
||||
IconResource=C:\Program Files\Google\Drive File Stream\54.0.3.0\GoogleDriveFS.exe,23
|
||||
865
Drivers/CMSIS/Include/cmsis_armcc.h
Normal file
865
Drivers/CMSIS/Include/cmsis_armcc.h
Normal file
@@ -0,0 +1,865 @@
|
||||
/**************************************************************************//**
|
||||
* @file cmsis_armcc.h
|
||||
* @brief CMSIS compiler ARMCC (Arm Compiler 5) header file
|
||||
* @version V5.0.4
|
||||
* @date 10. January 2018
|
||||
******************************************************************************/
|
||||
/*
|
||||
* Copyright (c) 2009-2018 Arm Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __CMSIS_ARMCC_H
|
||||
#define __CMSIS_ARMCC_H
|
||||
|
||||
|
||||
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 400677)
|
||||
#error "Please use Arm Compiler Toolchain V4.0.677 or later!"
|
||||
#endif
|
||||
|
||||
/* CMSIS compiler control architecture macros */
|
||||
#if ((defined (__TARGET_ARCH_6_M ) && (__TARGET_ARCH_6_M == 1)) || \
|
||||
(defined (__TARGET_ARCH_6S_M ) && (__TARGET_ARCH_6S_M == 1)) )
|
||||
#define __ARM_ARCH_6M__ 1
|
||||
#endif
|
||||
|
||||
#if (defined (__TARGET_ARCH_7_M ) && (__TARGET_ARCH_7_M == 1))
|
||||
#define __ARM_ARCH_7M__ 1
|
||||
#endif
|
||||
|
||||
#if (defined (__TARGET_ARCH_7E_M) && (__TARGET_ARCH_7E_M == 1))
|
||||
#define __ARM_ARCH_7EM__ 1
|
||||
#endif
|
||||
|
||||
/* __ARM_ARCH_8M_BASE__ not applicable */
|
||||
/* __ARM_ARCH_8M_MAIN__ not applicable */
|
||||
|
||||
|
||||
/* CMSIS compiler specific defines */
|
||||
#ifndef __ASM
|
||||
#define __ASM __asm
|
||||
#endif
|
||||
#ifndef __INLINE
|
||||
#define __INLINE __inline
|
||||
#endif
|
||||
#ifndef __STATIC_INLINE
|
||||
#define __STATIC_INLINE static __inline
|
||||
#endif
|
||||
#ifndef __STATIC_FORCEINLINE
|
||||
#define __STATIC_FORCEINLINE static __forceinline
|
||||
#endif
|
||||
#ifndef __NO_RETURN
|
||||
#define __NO_RETURN __declspec(noreturn)
|
||||
#endif
|
||||
#ifndef __USED
|
||||
#define __USED __attribute__((used))
|
||||
#endif
|
||||
#ifndef __WEAK
|
||||
#define __WEAK __attribute__((weak))
|
||||
#endif
|
||||
#ifndef __PACKED
|
||||
#define __PACKED __attribute__((packed))
|
||||
#endif
|
||||
#ifndef __PACKED_STRUCT
|
||||
#define __PACKED_STRUCT __packed struct
|
||||
#endif
|
||||
#ifndef __PACKED_UNION
|
||||
#define __PACKED_UNION __packed union
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32 /* deprecated */
|
||||
#define __UNALIGNED_UINT32(x) (*((__packed uint32_t *)(x)))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT16_WRITE
|
||||
#define __UNALIGNED_UINT16_WRITE(addr, val) ((*((__packed uint16_t *)(addr))) = (val))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT16_READ
|
||||
#define __UNALIGNED_UINT16_READ(addr) (*((const __packed uint16_t *)(addr)))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32_WRITE
|
||||
#define __UNALIGNED_UINT32_WRITE(addr, val) ((*((__packed uint32_t *)(addr))) = (val))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32_READ
|
||||
#define __UNALIGNED_UINT32_READ(addr) (*((const __packed uint32_t *)(addr)))
|
||||
#endif
|
||||
#ifndef __ALIGNED
|
||||
#define __ALIGNED(x) __attribute__((aligned(x)))
|
||||
#endif
|
||||
#ifndef __RESTRICT
|
||||
#define __RESTRICT __restrict
|
||||
#endif
|
||||
|
||||
/* ########################### Core Function Access ########################### */
|
||||
/** \ingroup CMSIS_Core_FunctionInterface
|
||||
\defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
|
||||
@{
|
||||
*/
|
||||
|
||||
/**
|
||||
\brief Enable IRQ Interrupts
|
||||
\details Enables IRQ interrupts by clearing the I-bit in the CPSR.
|
||||
Can only be executed in Privileged modes.
|
||||
*/
|
||||
/* intrinsic void __enable_irq(); */
|
||||
|
||||
|
||||
/**
|
||||
\brief Disable IRQ Interrupts
|
||||
\details Disables IRQ interrupts by setting the I-bit in the CPSR.
|
||||
Can only be executed in Privileged modes.
|
||||
*/
|
||||
/* intrinsic void __disable_irq(); */
|
||||
|
||||
/**
|
||||
\brief Get Control Register
|
||||
\details Returns the content of the Control Register.
|
||||
\return Control Register value
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __get_CONTROL(void)
|
||||
{
|
||||
register uint32_t __regControl __ASM("control");
|
||||
return(__regControl);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Set Control Register
|
||||
\details Writes the given value to the Control Register.
|
||||
\param [in] control Control Register value to set
|
||||
*/
|
||||
__STATIC_INLINE void __set_CONTROL(uint32_t control)
|
||||
{
|
||||
register uint32_t __regControl __ASM("control");
|
||||
__regControl = control;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Get IPSR Register
|
||||
\details Returns the content of the IPSR Register.
|
||||
\return IPSR Register value
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __get_IPSR(void)
|
||||
{
|
||||
register uint32_t __regIPSR __ASM("ipsr");
|
||||
return(__regIPSR);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Get APSR Register
|
||||
\details Returns the content of the APSR Register.
|
||||
\return APSR Register value
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __get_APSR(void)
|
||||
{
|
||||
register uint32_t __regAPSR __ASM("apsr");
|
||||
return(__regAPSR);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Get xPSR Register
|
||||
\details Returns the content of the xPSR Register.
|
||||
\return xPSR Register value
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __get_xPSR(void)
|
||||
{
|
||||
register uint32_t __regXPSR __ASM("xpsr");
|
||||
return(__regXPSR);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Get Process Stack Pointer
|
||||
\details Returns the current value of the Process Stack Pointer (PSP).
|
||||
\return PSP Register value
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __get_PSP(void)
|
||||
{
|
||||
register uint32_t __regProcessStackPointer __ASM("psp");
|
||||
return(__regProcessStackPointer);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Set Process Stack Pointer
|
||||
\details Assigns the given value to the Process Stack Pointer (PSP).
|
||||
\param [in] topOfProcStack Process Stack Pointer value to set
|
||||
*/
|
||||
__STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
|
||||
{
|
||||
register uint32_t __regProcessStackPointer __ASM("psp");
|
||||
__regProcessStackPointer = topOfProcStack;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Get Main Stack Pointer
|
||||
\details Returns the current value of the Main Stack Pointer (MSP).
|
||||
\return MSP Register value
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __get_MSP(void)
|
||||
{
|
||||
register uint32_t __regMainStackPointer __ASM("msp");
|
||||
return(__regMainStackPointer);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Set Main Stack Pointer
|
||||
\details Assigns the given value to the Main Stack Pointer (MSP).
|
||||
\param [in] topOfMainStack Main Stack Pointer value to set
|
||||
*/
|
||||
__STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
|
||||
{
|
||||
register uint32_t __regMainStackPointer __ASM("msp");
|
||||
__regMainStackPointer = topOfMainStack;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Get Priority Mask
|
||||
\details Returns the current state of the priority mask bit from the Priority Mask Register.
|
||||
\return Priority Mask value
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __get_PRIMASK(void)
|
||||
{
|
||||
register uint32_t __regPriMask __ASM("primask");
|
||||
return(__regPriMask);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Set Priority Mask
|
||||
\details Assigns the given value to the Priority Mask Register.
|
||||
\param [in] priMask Priority Mask
|
||||
*/
|
||||
__STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
|
||||
{
|
||||
register uint32_t __regPriMask __ASM("primask");
|
||||
__regPriMask = (priMask);
|
||||
}
|
||||
|
||||
|
||||
#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
|
||||
(defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
|
||||
|
||||
/**
|
||||
\brief Enable FIQ
|
||||
\details Enables FIQ interrupts by clearing the F-bit in the CPSR.
|
||||
Can only be executed in Privileged modes.
|
||||
*/
|
||||
#define __enable_fault_irq __enable_fiq
|
||||
|
||||
|
||||
/**
|
||||
\brief Disable FIQ
|
||||
\details Disables FIQ interrupts by setting the F-bit in the CPSR.
|
||||
Can only be executed in Privileged modes.
|
||||
*/
|
||||
#define __disable_fault_irq __disable_fiq
|
||||
|
||||
|
||||
/**
|
||||
\brief Get Base Priority
|
||||
\details Returns the current value of the Base Priority register.
|
||||
\return Base Priority register value
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __get_BASEPRI(void)
|
||||
{
|
||||
register uint32_t __regBasePri __ASM("basepri");
|
||||
return(__regBasePri);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Set Base Priority
|
||||
\details Assigns the given value to the Base Priority register.
|
||||
\param [in] basePri Base Priority value to set
|
||||
*/
|
||||
__STATIC_INLINE void __set_BASEPRI(uint32_t basePri)
|
||||
{
|
||||
register uint32_t __regBasePri __ASM("basepri");
|
||||
__regBasePri = (basePri & 0xFFU);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Set Base Priority with condition
|
||||
\details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled,
|
||||
or the new value increases the BASEPRI priority level.
|
||||
\param [in] basePri Base Priority value to set
|
||||
*/
|
||||
__STATIC_INLINE void __set_BASEPRI_MAX(uint32_t basePri)
|
||||
{
|
||||
register uint32_t __regBasePriMax __ASM("basepri_max");
|
||||
__regBasePriMax = (basePri & 0xFFU);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Get Fault Mask
|
||||
\details Returns the current value of the Fault Mask register.
|
||||
\return Fault Mask register value
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __get_FAULTMASK(void)
|
||||
{
|
||||
register uint32_t __regFaultMask __ASM("faultmask");
|
||||
return(__regFaultMask);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Set Fault Mask
|
||||
\details Assigns the given value to the Fault Mask register.
|
||||
\param [in] faultMask Fault Mask value to set
|
||||
*/
|
||||
__STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
|
||||
{
|
||||
register uint32_t __regFaultMask __ASM("faultmask");
|
||||
__regFaultMask = (faultMask & (uint32_t)1U);
|
||||
}
|
||||
|
||||
#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
|
||||
(defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */
|
||||
|
||||
|
||||
/**
|
||||
\brief Get FPSCR
|
||||
\details Returns the current value of the Floating Point Status/Control register.
|
||||
\return Floating Point Status/Control register value
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __get_FPSCR(void)
|
||||
{
|
||||
#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||
(defined (__FPU_USED ) && (__FPU_USED == 1U)) )
|
||||
register uint32_t __regfpscr __ASM("fpscr");
|
||||
return(__regfpscr);
|
||||
#else
|
||||
return(0U);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Set FPSCR
|
||||
\details Assigns the given value to the Floating Point Status/Control register.
|
||||
\param [in] fpscr Floating Point Status/Control value to set
|
||||
*/
|
||||
__STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
|
||||
{
|
||||
#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||
(defined (__FPU_USED ) && (__FPU_USED == 1U)) )
|
||||
register uint32_t __regfpscr __ASM("fpscr");
|
||||
__regfpscr = (fpscr);
|
||||
#else
|
||||
(void)fpscr;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*@} end of CMSIS_Core_RegAccFunctions */
|
||||
|
||||
|
||||
/* ########################## Core Instruction Access ######################### */
|
||||
/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
|
||||
Access to dedicated instructions
|
||||
@{
|
||||
*/
|
||||
|
||||
/**
|
||||
\brief No Operation
|
||||
\details No Operation does nothing. This instruction can be used for code alignment purposes.
|
||||
*/
|
||||
#define __NOP __nop
|
||||
|
||||
|
||||
/**
|
||||
\brief Wait For Interrupt
|
||||
\details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs.
|
||||
*/
|
||||
#define __WFI __wfi
|
||||
|
||||
|
||||
/**
|
||||
\brief Wait For Event
|
||||
\details Wait For Event is a hint instruction that permits the processor to enter
|
||||
a low-power state until one of a number of events occurs.
|
||||
*/
|
||||
#define __WFE __wfe
|
||||
|
||||
|
||||
/**
|
||||
\brief Send Event
|
||||
\details Send Event is a hint instruction. It causes an event to be signaled to the CPU.
|
||||
*/
|
||||
#define __SEV __sev
|
||||
|
||||
|
||||
/**
|
||||
\brief Instruction Synchronization Barrier
|
||||
\details Instruction Synchronization Barrier flushes the pipeline in the processor,
|
||||
so that all instructions following the ISB are fetched from cache or memory,
|
||||
after the instruction has been completed.
|
||||
*/
|
||||
#define __ISB() do {\
|
||||
__schedule_barrier();\
|
||||
__isb(0xF);\
|
||||
__schedule_barrier();\
|
||||
} while (0U)
|
||||
|
||||
/**
|
||||
\brief Data Synchronization Barrier
|
||||
\details Acts as a special kind of Data Memory Barrier.
|
||||
It completes when all explicit memory accesses before this instruction complete.
|
||||
*/
|
||||
#define __DSB() do {\
|
||||
__schedule_barrier();\
|
||||
__dsb(0xF);\
|
||||
__schedule_barrier();\
|
||||
} while (0U)
|
||||
|
||||
/**
|
||||
\brief Data Memory Barrier
|
||||
\details Ensures the apparent order of the explicit memory operations before
|
||||
and after the instruction, without ensuring their completion.
|
||||
*/
|
||||
#define __DMB() do {\
|
||||
__schedule_barrier();\
|
||||
__dmb(0xF);\
|
||||
__schedule_barrier();\
|
||||
} while (0U)
|
||||
|
||||
|
||||
/**
|
||||
\brief Reverse byte order (32 bit)
|
||||
\details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412.
|
||||
\param [in] value Value to reverse
|
||||
\return Reversed value
|
||||
*/
|
||||
#define __REV __rev
|
||||
|
||||
|
||||
/**
|
||||
\brief Reverse byte order (16 bit)
|
||||
\details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856.
|
||||
\param [in] value Value to reverse
|
||||
\return Reversed value
|
||||
*/
|
||||
#ifndef __NO_EMBEDDED_ASM
|
||||
__attribute__((section(".rev16_text"))) __STATIC_INLINE __ASM uint32_t __REV16(uint32_t value)
|
||||
{
|
||||
rev16 r0, r0
|
||||
bx lr
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
\brief Reverse byte order (16 bit)
|
||||
\details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000.
|
||||
\param [in] value Value to reverse
|
||||
\return Reversed value
|
||||
*/
|
||||
#ifndef __NO_EMBEDDED_ASM
|
||||
__attribute__((section(".revsh_text"))) __STATIC_INLINE __ASM int16_t __REVSH(int16_t value)
|
||||
{
|
||||
revsh r0, r0
|
||||
bx lr
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
\brief Rotate Right in unsigned value (32 bit)
|
||||
\details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
|
||||
\param [in] op1 Value to rotate
|
||||
\param [in] op2 Number of Bits to rotate
|
||||
\return Rotated value
|
||||
*/
|
||||
#define __ROR __ror
|
||||
|
||||
|
||||
/**
|
||||
\brief Breakpoint
|
||||
\details Causes the processor to enter Debug state.
|
||||
Debug tools can use this to investigate system state when the instruction at a particular address is reached.
|
||||
\param [in] value is ignored by the processor.
|
||||
If required, a debugger can use it to store additional information about the breakpoint.
|
||||
*/
|
||||
#define __BKPT(value) __breakpoint(value)
|
||||
|
||||
|
||||
/**
|
||||
\brief Reverse bit order of value
|
||||
\details Reverses the bit order of the given value.
|
||||
\param [in] value Value to reverse
|
||||
\return Reversed value
|
||||
*/
|
||||
#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
|
||||
(defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
|
||||
#define __RBIT __rbit
|
||||
#else
|
||||
__attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
|
||||
{
|
||||
uint32_t result;
|
||||
uint32_t s = (4U /*sizeof(v)*/ * 8U) - 1U; /* extra shift needed at end */
|
||||
|
||||
result = value; /* r will be reversed bits of v; first get LSB of v */
|
||||
for (value >>= 1U; value != 0U; value >>= 1U)
|
||||
{
|
||||
result <<= 1U;
|
||||
result |= value & 1U;
|
||||
s--;
|
||||
}
|
||||
result <<= s; /* shift when v's highest bits are zero */
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
\brief Count leading zeros
|
||||
\details Counts the number of leading zeros of a data value.
|
||||
\param [in] value Value to count the leading zeros
|
||||
\return number of leading zeros in value
|
||||
*/
|
||||
#define __CLZ __clz
|
||||
|
||||
|
||||
#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
|
||||
(defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
|
||||
|
||||
/**
|
||||
\brief LDR Exclusive (8 bit)
|
||||
\details Executes a exclusive LDR instruction for 8 bit value.
|
||||
\param [in] ptr Pointer to data
|
||||
\return value of type uint8_t at (*ptr)
|
||||
*/
|
||||
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
|
||||
#define __LDREXB(ptr) ((uint8_t ) __ldrex(ptr))
|
||||
#else
|
||||
#define __LDREXB(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint8_t ) __ldrex(ptr)) _Pragma("pop")
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
\brief LDR Exclusive (16 bit)
|
||||
\details Executes a exclusive LDR instruction for 16 bit values.
|
||||
\param [in] ptr Pointer to data
|
||||
\return value of type uint16_t at (*ptr)
|
||||
*/
|
||||
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
|
||||
#define __LDREXH(ptr) ((uint16_t) __ldrex(ptr))
|
||||
#else
|
||||
#define __LDREXH(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint16_t) __ldrex(ptr)) _Pragma("pop")
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
\brief LDR Exclusive (32 bit)
|
||||
\details Executes a exclusive LDR instruction for 32 bit values.
|
||||
\param [in] ptr Pointer to data
|
||||
\return value of type uint32_t at (*ptr)
|
||||
*/
|
||||
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
|
||||
#define __LDREXW(ptr) ((uint32_t ) __ldrex(ptr))
|
||||
#else
|
||||
#define __LDREXW(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint32_t ) __ldrex(ptr)) _Pragma("pop")
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
\brief STR Exclusive (8 bit)
|
||||
\details Executes a exclusive STR instruction for 8 bit values.
|
||||
\param [in] value Value to store
|
||||
\param [in] ptr Pointer to location
|
||||
\return 0 Function succeeded
|
||||
\return 1 Function failed
|
||||
*/
|
||||
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
|
||||
#define __STREXB(value, ptr) __strex(value, ptr)
|
||||
#else
|
||||
#define __STREXB(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop")
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
\brief STR Exclusive (16 bit)
|
||||
\details Executes a exclusive STR instruction for 16 bit values.
|
||||
\param [in] value Value to store
|
||||
\param [in] ptr Pointer to location
|
||||
\return 0 Function succeeded
|
||||
\return 1 Function failed
|
||||
*/
|
||||
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
|
||||
#define __STREXH(value, ptr) __strex(value, ptr)
|
||||
#else
|
||||
#define __STREXH(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop")
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
\brief STR Exclusive (32 bit)
|
||||
\details Executes a exclusive STR instruction for 32 bit values.
|
||||
\param [in] value Value to store
|
||||
\param [in] ptr Pointer to location
|
||||
\return 0 Function succeeded
|
||||
\return 1 Function failed
|
||||
*/
|
||||
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
|
||||
#define __STREXW(value, ptr) __strex(value, ptr)
|
||||
#else
|
||||
#define __STREXW(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop")
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
\brief Remove the exclusive lock
|
||||
\details Removes the exclusive lock which is created by LDREX.
|
||||
*/
|
||||
#define __CLREX __clrex
|
||||
|
||||
|
||||
/**
|
||||
\brief Signed Saturate
|
||||
\details Saturates a signed value.
|
||||
\param [in] value Value to be saturated
|
||||
\param [in] sat Bit position to saturate to (1..32)
|
||||
\return Saturated value
|
||||
*/
|
||||
#define __SSAT __ssat
|
||||
|
||||
|
||||
/**
|
||||
\brief Unsigned Saturate
|
||||
\details Saturates an unsigned value.
|
||||
\param [in] value Value to be saturated
|
||||
\param [in] sat Bit position to saturate to (0..31)
|
||||
\return Saturated value
|
||||
*/
|
||||
#define __USAT __usat
|
||||
|
||||
|
||||
/**
|
||||
\brief Rotate Right with Extend (32 bit)
|
||||
\details Moves each bit of a bitstring right by one bit.
|
||||
The carry input is shifted in at the left end of the bitstring.
|
||||
\param [in] value Value to rotate
|
||||
\return Rotated value
|
||||
*/
|
||||
#ifndef __NO_EMBEDDED_ASM
|
||||
__attribute__((section(".rrx_text"))) __STATIC_INLINE __ASM uint32_t __RRX(uint32_t value)
|
||||
{
|
||||
rrx r0, r0
|
||||
bx lr
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
\brief LDRT Unprivileged (8 bit)
|
||||
\details Executes a Unprivileged LDRT instruction for 8 bit value.
|
||||
\param [in] ptr Pointer to data
|
||||
\return value of type uint8_t at (*ptr)
|
||||
*/
|
||||
#define __LDRBT(ptr) ((uint8_t ) __ldrt(ptr))
|
||||
|
||||
|
||||
/**
|
||||
\brief LDRT Unprivileged (16 bit)
|
||||
\details Executes a Unprivileged LDRT instruction for 16 bit values.
|
||||
\param [in] ptr Pointer to data
|
||||
\return value of type uint16_t at (*ptr)
|
||||
*/
|
||||
#define __LDRHT(ptr) ((uint16_t) __ldrt(ptr))
|
||||
|
||||
|
||||
/**
|
||||
\brief LDRT Unprivileged (32 bit)
|
||||
\details Executes a Unprivileged LDRT instruction for 32 bit values.
|
||||
\param [in] ptr Pointer to data
|
||||
\return value of type uint32_t at (*ptr)
|
||||
*/
|
||||
#define __LDRT(ptr) ((uint32_t ) __ldrt(ptr))
|
||||
|
||||
|
||||
/**
|
||||
\brief STRT Unprivileged (8 bit)
|
||||
\details Executes a Unprivileged STRT instruction for 8 bit values.
|
||||
\param [in] value Value to store
|
||||
\param [in] ptr Pointer to location
|
||||
*/
|
||||
#define __STRBT(value, ptr) __strt(value, ptr)
|
||||
|
||||
|
||||
/**
|
||||
\brief STRT Unprivileged (16 bit)
|
||||
\details Executes a Unprivileged STRT instruction for 16 bit values.
|
||||
\param [in] value Value to store
|
||||
\param [in] ptr Pointer to location
|
||||
*/
|
||||
#define __STRHT(value, ptr) __strt(value, ptr)
|
||||
|
||||
|
||||
/**
|
||||
\brief STRT Unprivileged (32 bit)
|
||||
\details Executes a Unprivileged STRT instruction for 32 bit values.
|
||||
\param [in] value Value to store
|
||||
\param [in] ptr Pointer to location
|
||||
*/
|
||||
#define __STRT(value, ptr) __strt(value, ptr)
|
||||
|
||||
#else /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
|
||||
(defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */
|
||||
|
||||
/**
|
||||
\brief Signed Saturate
|
||||
\details Saturates a signed value.
|
||||
\param [in] value Value to be saturated
|
||||
\param [in] sat Bit position to saturate to (1..32)
|
||||
\return Saturated value
|
||||
*/
|
||||
__attribute__((always_inline)) __STATIC_INLINE int32_t __SSAT(int32_t val, uint32_t sat)
|
||||
{
|
||||
if ((sat >= 1U) && (sat <= 32U))
|
||||
{
|
||||
const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U);
|
||||
const int32_t min = -1 - max ;
|
||||
if (val > max)
|
||||
{
|
||||
return max;
|
||||
}
|
||||
else if (val < min)
|
||||
{
|
||||
return min;
|
||||
}
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Unsigned Saturate
|
||||
\details Saturates an unsigned value.
|
||||
\param [in] value Value to be saturated
|
||||
\param [in] sat Bit position to saturate to (0..31)
|
||||
\return Saturated value
|
||||
*/
|
||||
__attribute__((always_inline)) __STATIC_INLINE uint32_t __USAT(int32_t val, uint32_t sat)
|
||||
{
|
||||
if (sat <= 31U)
|
||||
{
|
||||
const uint32_t max = ((1U << sat) - 1U);
|
||||
if (val > (int32_t)max)
|
||||
{
|
||||
return max;
|
||||
}
|
||||
else if (val < 0)
|
||||
{
|
||||
return 0U;
|
||||
}
|
||||
}
|
||||
return (uint32_t)val;
|
||||
}
|
||||
|
||||
#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
|
||||
(defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */
|
||||
|
||||
/*@}*/ /* end of group CMSIS_Core_InstructionInterface */
|
||||
|
||||
|
||||
/* ################### Compiler specific Intrinsics ########################### */
|
||||
/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
|
||||
Access to dedicated SIMD instructions
|
||||
@{
|
||||
*/
|
||||
|
||||
#if ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
|
||||
|
||||
#define __SADD8 __sadd8
|
||||
#define __QADD8 __qadd8
|
||||
#define __SHADD8 __shadd8
|
||||
#define __UADD8 __uadd8
|
||||
#define __UQADD8 __uqadd8
|
||||
#define __UHADD8 __uhadd8
|
||||
#define __SSUB8 __ssub8
|
||||
#define __QSUB8 __qsub8
|
||||
#define __SHSUB8 __shsub8
|
||||
#define __USUB8 __usub8
|
||||
#define __UQSUB8 __uqsub8
|
||||
#define __UHSUB8 __uhsub8
|
||||
#define __SADD16 __sadd16
|
||||
#define __QADD16 __qadd16
|
||||
#define __SHADD16 __shadd16
|
||||
#define __UADD16 __uadd16
|
||||
#define __UQADD16 __uqadd16
|
||||
#define __UHADD16 __uhadd16
|
||||
#define __SSUB16 __ssub16
|
||||
#define __QSUB16 __qsub16
|
||||
#define __SHSUB16 __shsub16
|
||||
#define __USUB16 __usub16
|
||||
#define __UQSUB16 __uqsub16
|
||||
#define __UHSUB16 __uhsub16
|
||||
#define __SASX __sasx
|
||||
#define __QASX __qasx
|
||||
#define __SHASX __shasx
|
||||
#define __UASX __uasx
|
||||
#define __UQASX __uqasx
|
||||
#define __UHASX __uhasx
|
||||
#define __SSAX __ssax
|
||||
#define __QSAX __qsax
|
||||
#define __SHSAX __shsax
|
||||
#define __USAX __usax
|
||||
#define __UQSAX __uqsax
|
||||
#define __UHSAX __uhsax
|
||||
#define __USAD8 __usad8
|
||||
#define __USADA8 __usada8
|
||||
#define __SSAT16 __ssat16
|
||||
#define __USAT16 __usat16
|
||||
#define __UXTB16 __uxtb16
|
||||
#define __UXTAB16 __uxtab16
|
||||
#define __SXTB16 __sxtb16
|
||||
#define __SXTAB16 __sxtab16
|
||||
#define __SMUAD __smuad
|
||||
#define __SMUADX __smuadx
|
||||
#define __SMLAD __smlad
|
||||
#define __SMLADX __smladx
|
||||
#define __SMLALD __smlald
|
||||
#define __SMLALDX __smlaldx
|
||||
#define __SMUSD __smusd
|
||||
#define __SMUSDX __smusdx
|
||||
#define __SMLSD __smlsd
|
||||
#define __SMLSDX __smlsdx
|
||||
#define __SMLSLD __smlsld
|
||||
#define __SMLSLDX __smlsldx
|
||||
#define __SEL __sel
|
||||
#define __QADD __qadd
|
||||
#define __QSUB __qsub
|
||||
|
||||
#define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \
|
||||
((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) )
|
||||
|
||||
#define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \
|
||||
((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) )
|
||||
|
||||
#define __SMMLA(ARG1,ARG2,ARG3) ( (int32_t)((((int64_t)(ARG1) * (ARG2)) + \
|
||||
((int64_t)(ARG3) << 32U) ) >> 32U))
|
||||
|
||||
#endif /* ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */
|
||||
/*@} end of group CMSIS_SIMD_intrinsics */
|
||||
|
||||
|
||||
#endif /* __CMSIS_ARMCC_H */
|
||||
1869
Drivers/CMSIS/Include/cmsis_armclang.h
Normal file
1869
Drivers/CMSIS/Include/cmsis_armclang.h
Normal file
File diff suppressed because it is too large
Load Diff
266
Drivers/CMSIS/Include/cmsis_compiler.h
Normal file
266
Drivers/CMSIS/Include/cmsis_compiler.h
Normal file
@@ -0,0 +1,266 @@
|
||||
/**************************************************************************//**
|
||||
* @file cmsis_compiler.h
|
||||
* @brief CMSIS compiler generic header file
|
||||
* @version V5.0.4
|
||||
* @date 10. January 2018
|
||||
******************************************************************************/
|
||||
/*
|
||||
* Copyright (c) 2009-2018 Arm Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __CMSIS_COMPILER_H
|
||||
#define __CMSIS_COMPILER_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*
|
||||
* Arm Compiler 4/5
|
||||
*/
|
||||
#if defined ( __CC_ARM )
|
||||
#include "cmsis_armcc.h"
|
||||
|
||||
|
||||
/*
|
||||
* Arm Compiler 6 (armclang)
|
||||
*/
|
||||
#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||
#include "cmsis_armclang.h"
|
||||
|
||||
|
||||
/*
|
||||
* GNU Compiler
|
||||
*/
|
||||
#elif defined ( __GNUC__ )
|
||||
#include "cmsis_gcc.h"
|
||||
|
||||
|
||||
/*
|
||||
* IAR Compiler
|
||||
*/
|
||||
#elif defined ( __ICCARM__ )
|
||||
#include <cmsis_iccarm.h>
|
||||
|
||||
|
||||
/*
|
||||
* TI Arm Compiler
|
||||
*/
|
||||
#elif defined ( __TI_ARM__ )
|
||||
#include <cmsis_ccs.h>
|
||||
|
||||
#ifndef __ASM
|
||||
#define __ASM __asm
|
||||
#endif
|
||||
#ifndef __INLINE
|
||||
#define __INLINE inline
|
||||
#endif
|
||||
#ifndef __STATIC_INLINE
|
||||
#define __STATIC_INLINE static inline
|
||||
#endif
|
||||
#ifndef __STATIC_FORCEINLINE
|
||||
#define __STATIC_FORCEINLINE __STATIC_INLINE
|
||||
#endif
|
||||
#ifndef __NO_RETURN
|
||||
#define __NO_RETURN __attribute__((noreturn))
|
||||
#endif
|
||||
#ifndef __USED
|
||||
#define __USED __attribute__((used))
|
||||
#endif
|
||||
#ifndef __WEAK
|
||||
#define __WEAK __attribute__((weak))
|
||||
#endif
|
||||
#ifndef __PACKED
|
||||
#define __PACKED __attribute__((packed))
|
||||
#endif
|
||||
#ifndef __PACKED_STRUCT
|
||||
#define __PACKED_STRUCT struct __attribute__((packed))
|
||||
#endif
|
||||
#ifndef __PACKED_UNION
|
||||
#define __PACKED_UNION union __attribute__((packed))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32 /* deprecated */
|
||||
struct __attribute__((packed)) T_UINT32 { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT16_WRITE
|
||||
__PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
|
||||
#define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void*)(addr))->v) = (val))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT16_READ
|
||||
__PACKED_STRUCT T_UINT16_READ { uint16_t v; };
|
||||
#define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32_WRITE
|
||||
__PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32_READ
|
||||
__PACKED_STRUCT T_UINT32_READ { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
|
||||
#endif
|
||||
#ifndef __ALIGNED
|
||||
#define __ALIGNED(x) __attribute__((aligned(x)))
|
||||
#endif
|
||||
#ifndef __RESTRICT
|
||||
#warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
|
||||
#define __RESTRICT
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* TASKING Compiler
|
||||
*/
|
||||
#elif defined ( __TASKING__ )
|
||||
/*
|
||||
* The CMSIS functions have been implemented as intrinsics in the compiler.
|
||||
* Please use "carm -?i" to get an up to date list of all intrinsics,
|
||||
* Including the CMSIS ones.
|
||||
*/
|
||||
|
||||
#ifndef __ASM
|
||||
#define __ASM __asm
|
||||
#endif
|
||||
#ifndef __INLINE
|
||||
#define __INLINE inline
|
||||
#endif
|
||||
#ifndef __STATIC_INLINE
|
||||
#define __STATIC_INLINE static inline
|
||||
#endif
|
||||
#ifndef __STATIC_FORCEINLINE
|
||||
#define __STATIC_FORCEINLINE __STATIC_INLINE
|
||||
#endif
|
||||
#ifndef __NO_RETURN
|
||||
#define __NO_RETURN __attribute__((noreturn))
|
||||
#endif
|
||||
#ifndef __USED
|
||||
#define __USED __attribute__((used))
|
||||
#endif
|
||||
#ifndef __WEAK
|
||||
#define __WEAK __attribute__((weak))
|
||||
#endif
|
||||
#ifndef __PACKED
|
||||
#define __PACKED __packed__
|
||||
#endif
|
||||
#ifndef __PACKED_STRUCT
|
||||
#define __PACKED_STRUCT struct __packed__
|
||||
#endif
|
||||
#ifndef __PACKED_UNION
|
||||
#define __PACKED_UNION union __packed__
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32 /* deprecated */
|
||||
struct __packed__ T_UINT32 { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT16_WRITE
|
||||
__PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
|
||||
#define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT16_READ
|
||||
__PACKED_STRUCT T_UINT16_READ { uint16_t v; };
|
||||
#define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32_WRITE
|
||||
__PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32_READ
|
||||
__PACKED_STRUCT T_UINT32_READ { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
|
||||
#endif
|
||||
#ifndef __ALIGNED
|
||||
#define __ALIGNED(x) __align(x)
|
||||
#endif
|
||||
#ifndef __RESTRICT
|
||||
#warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
|
||||
#define __RESTRICT
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* COSMIC Compiler
|
||||
*/
|
||||
#elif defined ( __CSMC__ )
|
||||
#include <cmsis_csm.h>
|
||||
|
||||
#ifndef __ASM
|
||||
#define __ASM _asm
|
||||
#endif
|
||||
#ifndef __INLINE
|
||||
#define __INLINE inline
|
||||
#endif
|
||||
#ifndef __STATIC_INLINE
|
||||
#define __STATIC_INLINE static inline
|
||||
#endif
|
||||
#ifndef __STATIC_FORCEINLINE
|
||||
#define __STATIC_FORCEINLINE __STATIC_INLINE
|
||||
#endif
|
||||
#ifndef __NO_RETURN
|
||||
// NO RETURN is automatically detected hence no warning here
|
||||
#define __NO_RETURN
|
||||
#endif
|
||||
#ifndef __USED
|
||||
#warning No compiler specific solution for __USED. __USED is ignored.
|
||||
#define __USED
|
||||
#endif
|
||||
#ifndef __WEAK
|
||||
#define __WEAK __weak
|
||||
#endif
|
||||
#ifndef __PACKED
|
||||
#define __PACKED @packed
|
||||
#endif
|
||||
#ifndef __PACKED_STRUCT
|
||||
#define __PACKED_STRUCT @packed struct
|
||||
#endif
|
||||
#ifndef __PACKED_UNION
|
||||
#define __PACKED_UNION @packed union
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32 /* deprecated */
|
||||
@packed struct T_UINT32 { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT16_WRITE
|
||||
__PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
|
||||
#define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT16_READ
|
||||
__PACKED_STRUCT T_UINT16_READ { uint16_t v; };
|
||||
#define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32_WRITE
|
||||
__PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32_READ
|
||||
__PACKED_STRUCT T_UINT32_READ { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
|
||||
#endif
|
||||
#ifndef __ALIGNED
|
||||
#warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
|
||||
#define __ALIGNED(x)
|
||||
#endif
|
||||
#ifndef __RESTRICT
|
||||
#warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
|
||||
#define __RESTRICT
|
||||
#endif
|
||||
|
||||
|
||||
#else
|
||||
#error Unknown compiler.
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* __CMSIS_COMPILER_H */
|
||||
|
||||
2085
Drivers/CMSIS/Include/cmsis_gcc.h
Normal file
2085
Drivers/CMSIS/Include/cmsis_gcc.h
Normal file
File diff suppressed because it is too large
Load Diff
935
Drivers/CMSIS/Include/cmsis_iccarm.h
Normal file
935
Drivers/CMSIS/Include/cmsis_iccarm.h
Normal file
@@ -0,0 +1,935 @@
|
||||
/**************************************************************************//**
|
||||
* @file cmsis_iccarm.h
|
||||
* @brief CMSIS compiler ICCARM (IAR Compiler for Arm) header file
|
||||
* @version V5.0.7
|
||||
* @date 19. June 2018
|
||||
******************************************************************************/
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2017-2018 IAR Systems
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License")
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
#ifndef __CMSIS_ICCARM_H__
|
||||
#define __CMSIS_ICCARM_H__
|
||||
|
||||
#ifndef __ICCARM__
|
||||
#error This file should only be compiled by ICCARM
|
||||
#endif
|
||||
|
||||
#pragma system_include
|
||||
|
||||
#define __IAR_FT _Pragma("inline=forced") __intrinsic
|
||||
|
||||
#if (__VER__ >= 8000000)
|
||||
#define __ICCARM_V8 1
|
||||
#else
|
||||
#define __ICCARM_V8 0
|
||||
#endif
|
||||
|
||||
#ifndef __ALIGNED
|
||||
#if __ICCARM_V8
|
||||
#define __ALIGNED(x) __attribute__((aligned(x)))
|
||||
#elif (__VER__ >= 7080000)
|
||||
/* Needs IAR language extensions */
|
||||
#define __ALIGNED(x) __attribute__((aligned(x)))
|
||||
#else
|
||||
#warning No compiler specific solution for __ALIGNED.__ALIGNED is ignored.
|
||||
#define __ALIGNED(x)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* Define compiler macros for CPU architecture, used in CMSIS 5.
|
||||
*/
|
||||
#if __ARM_ARCH_6M__ || __ARM_ARCH_7M__ || __ARM_ARCH_7EM__ || __ARM_ARCH_8M_BASE__ || __ARM_ARCH_8M_MAIN__
|
||||
/* Macros already defined */
|
||||
#else
|
||||
#if defined(__ARM8M_MAINLINE__) || defined(__ARM8EM_MAINLINE__)
|
||||
#define __ARM_ARCH_8M_MAIN__ 1
|
||||
#elif defined(__ARM8M_BASELINE__)
|
||||
#define __ARM_ARCH_8M_BASE__ 1
|
||||
#elif defined(__ARM_ARCH_PROFILE) && __ARM_ARCH_PROFILE == 'M'
|
||||
#if __ARM_ARCH == 6
|
||||
#define __ARM_ARCH_6M__ 1
|
||||
#elif __ARM_ARCH == 7
|
||||
#if __ARM_FEATURE_DSP
|
||||
#define __ARM_ARCH_7EM__ 1
|
||||
#else
|
||||
#define __ARM_ARCH_7M__ 1
|
||||
#endif
|
||||
#endif /* __ARM_ARCH */
|
||||
#endif /* __ARM_ARCH_PROFILE == 'M' */
|
||||
#endif
|
||||
|
||||
/* Alternativ core deduction for older ICCARM's */
|
||||
#if !defined(__ARM_ARCH_6M__) && !defined(__ARM_ARCH_7M__) && !defined(__ARM_ARCH_7EM__) && \
|
||||
!defined(__ARM_ARCH_8M_BASE__) && !defined(__ARM_ARCH_8M_MAIN__)
|
||||
#if defined(__ARM6M__) && (__CORE__ == __ARM6M__)
|
||||
#define __ARM_ARCH_6M__ 1
|
||||
#elif defined(__ARM7M__) && (__CORE__ == __ARM7M__)
|
||||
#define __ARM_ARCH_7M__ 1
|
||||
#elif defined(__ARM7EM__) && (__CORE__ == __ARM7EM__)
|
||||
#define __ARM_ARCH_7EM__ 1
|
||||
#elif defined(__ARM8M_BASELINE__) && (__CORE == __ARM8M_BASELINE__)
|
||||
#define __ARM_ARCH_8M_BASE__ 1
|
||||
#elif defined(__ARM8M_MAINLINE__) && (__CORE == __ARM8M_MAINLINE__)
|
||||
#define __ARM_ARCH_8M_MAIN__ 1
|
||||
#elif defined(__ARM8EM_MAINLINE__) && (__CORE == __ARM8EM_MAINLINE__)
|
||||
#define __ARM_ARCH_8M_MAIN__ 1
|
||||
#else
|
||||
#error "Unknown target."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if defined(__ARM_ARCH_6M__) && __ARM_ARCH_6M__==1
|
||||
#define __IAR_M0_FAMILY 1
|
||||
#elif defined(__ARM_ARCH_8M_BASE__) && __ARM_ARCH_8M_BASE__==1
|
||||
#define __IAR_M0_FAMILY 1
|
||||
#else
|
||||
#define __IAR_M0_FAMILY 0
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef __ASM
|
||||
#define __ASM __asm
|
||||
#endif
|
||||
|
||||
#ifndef __INLINE
|
||||
#define __INLINE inline
|
||||
#endif
|
||||
|
||||
#ifndef __NO_RETURN
|
||||
#if __ICCARM_V8
|
||||
#define __NO_RETURN __attribute__((__noreturn__))
|
||||
#else
|
||||
#define __NO_RETURN _Pragma("object_attribute=__noreturn")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef __PACKED
|
||||
#if __ICCARM_V8
|
||||
#define __PACKED __attribute__((packed, aligned(1)))
|
||||
#else
|
||||
/* Needs IAR language extensions */
|
||||
#define __PACKED __packed
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef __PACKED_STRUCT
|
||||
#if __ICCARM_V8
|
||||
#define __PACKED_STRUCT struct __attribute__((packed, aligned(1)))
|
||||
#else
|
||||
/* Needs IAR language extensions */
|
||||
#define __PACKED_STRUCT __packed struct
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef __PACKED_UNION
|
||||
#if __ICCARM_V8
|
||||
#define __PACKED_UNION union __attribute__((packed, aligned(1)))
|
||||
#else
|
||||
/* Needs IAR language extensions */
|
||||
#define __PACKED_UNION __packed union
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef __RESTRICT
|
||||
#define __RESTRICT __restrict
|
||||
#endif
|
||||
|
||||
#ifndef __STATIC_INLINE
|
||||
#define __STATIC_INLINE static inline
|
||||
#endif
|
||||
|
||||
#ifndef __FORCEINLINE
|
||||
#define __FORCEINLINE _Pragma("inline=forced")
|
||||
#endif
|
||||
|
||||
#ifndef __STATIC_FORCEINLINE
|
||||
#define __STATIC_FORCEINLINE __FORCEINLINE __STATIC_INLINE
|
||||
#endif
|
||||
|
||||
#ifndef __UNALIGNED_UINT16_READ
|
||||
#pragma language=save
|
||||
#pragma language=extended
|
||||
__IAR_FT uint16_t __iar_uint16_read(void const *ptr)
|
||||
{
|
||||
return *(__packed uint16_t*)(ptr);
|
||||
}
|
||||
#pragma language=restore
|
||||
#define __UNALIGNED_UINT16_READ(PTR) __iar_uint16_read(PTR)
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef __UNALIGNED_UINT16_WRITE
|
||||
#pragma language=save
|
||||
#pragma language=extended
|
||||
__IAR_FT void __iar_uint16_write(void const *ptr, uint16_t val)
|
||||
{
|
||||
*(__packed uint16_t*)(ptr) = val;;
|
||||
}
|
||||
#pragma language=restore
|
||||
#define __UNALIGNED_UINT16_WRITE(PTR,VAL) __iar_uint16_write(PTR,VAL)
|
||||
#endif
|
||||
|
||||
#ifndef __UNALIGNED_UINT32_READ
|
||||
#pragma language=save
|
||||
#pragma language=extended
|
||||
__IAR_FT uint32_t __iar_uint32_read(void const *ptr)
|
||||
{
|
||||
return *(__packed uint32_t*)(ptr);
|
||||
}
|
||||
#pragma language=restore
|
||||
#define __UNALIGNED_UINT32_READ(PTR) __iar_uint32_read(PTR)
|
||||
#endif
|
||||
|
||||
#ifndef __UNALIGNED_UINT32_WRITE
|
||||
#pragma language=save
|
||||
#pragma language=extended
|
||||
__IAR_FT void __iar_uint32_write(void const *ptr, uint32_t val)
|
||||
{
|
||||
*(__packed uint32_t*)(ptr) = val;;
|
||||
}
|
||||
#pragma language=restore
|
||||
#define __UNALIGNED_UINT32_WRITE(PTR,VAL) __iar_uint32_write(PTR,VAL)
|
||||
#endif
|
||||
|
||||
#ifndef __UNALIGNED_UINT32 /* deprecated */
|
||||
#pragma language=save
|
||||
#pragma language=extended
|
||||
__packed struct __iar_u32 { uint32_t v; };
|
||||
#pragma language=restore
|
||||
#define __UNALIGNED_UINT32(PTR) (((struct __iar_u32 *)(PTR))->v)
|
||||
#endif
|
||||
|
||||
#ifndef __USED
|
||||
#if __ICCARM_V8
|
||||
#define __USED __attribute__((used))
|
||||
#else
|
||||
#define __USED _Pragma("__root")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef __WEAK
|
||||
#if __ICCARM_V8
|
||||
#define __WEAK __attribute__((weak))
|
||||
#else
|
||||
#define __WEAK _Pragma("__weak")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef __ICCARM_INTRINSICS_VERSION__
|
||||
#define __ICCARM_INTRINSICS_VERSION__ 0
|
||||
#endif
|
||||
|
||||
#if __ICCARM_INTRINSICS_VERSION__ == 2
|
||||
|
||||
#if defined(__CLZ)
|
||||
#undef __CLZ
|
||||
#endif
|
||||
#if defined(__REVSH)
|
||||
#undef __REVSH
|
||||
#endif
|
||||
#if defined(__RBIT)
|
||||
#undef __RBIT
|
||||
#endif
|
||||
#if defined(__SSAT)
|
||||
#undef __SSAT
|
||||
#endif
|
||||
#if defined(__USAT)
|
||||
#undef __USAT
|
||||
#endif
|
||||
|
||||
#include "iccarm_builtin.h"
|
||||
|
||||
#define __disable_fault_irq __iar_builtin_disable_fiq
|
||||
#define __disable_irq __iar_builtin_disable_interrupt
|
||||
#define __enable_fault_irq __iar_builtin_enable_fiq
|
||||
#define __enable_irq __iar_builtin_enable_interrupt
|
||||
#define __arm_rsr __iar_builtin_rsr
|
||||
#define __arm_wsr __iar_builtin_wsr
|
||||
|
||||
|
||||
#define __get_APSR() (__arm_rsr("APSR"))
|
||||
#define __get_BASEPRI() (__arm_rsr("BASEPRI"))
|
||||
#define __get_CONTROL() (__arm_rsr("CONTROL"))
|
||||
#define __get_FAULTMASK() (__arm_rsr("FAULTMASK"))
|
||||
|
||||
#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||
(defined (__FPU_USED ) && (__FPU_USED == 1U)) )
|
||||
#define __get_FPSCR() (__arm_rsr("FPSCR"))
|
||||
#define __set_FPSCR(VALUE) (__arm_wsr("FPSCR", (VALUE)))
|
||||
#else
|
||||
#define __get_FPSCR() ( 0 )
|
||||
#define __set_FPSCR(VALUE) ((void)VALUE)
|
||||
#endif
|
||||
|
||||
#define __get_IPSR() (__arm_rsr("IPSR"))
|
||||
#define __get_MSP() (__arm_rsr("MSP"))
|
||||
#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
|
||||
(!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
|
||||
// without main extensions, the non-secure MSPLIM is RAZ/WI
|
||||
#define __get_MSPLIM() (0U)
|
||||
#else
|
||||
#define __get_MSPLIM() (__arm_rsr("MSPLIM"))
|
||||
#endif
|
||||
#define __get_PRIMASK() (__arm_rsr("PRIMASK"))
|
||||
#define __get_PSP() (__arm_rsr("PSP"))
|
||||
|
||||
#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
|
||||
(!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
|
||||
// without main extensions, the non-secure PSPLIM is RAZ/WI
|
||||
#define __get_PSPLIM() (0U)
|
||||
#else
|
||||
#define __get_PSPLIM() (__arm_rsr("PSPLIM"))
|
||||
#endif
|
||||
|
||||
#define __get_xPSR() (__arm_rsr("xPSR"))
|
||||
|
||||
#define __set_BASEPRI(VALUE) (__arm_wsr("BASEPRI", (VALUE)))
|
||||
#define __set_BASEPRI_MAX(VALUE) (__arm_wsr("BASEPRI_MAX", (VALUE)))
|
||||
#define __set_CONTROL(VALUE) (__arm_wsr("CONTROL", (VALUE)))
|
||||
#define __set_FAULTMASK(VALUE) (__arm_wsr("FAULTMASK", (VALUE)))
|
||||
#define __set_MSP(VALUE) (__arm_wsr("MSP", (VALUE)))
|
||||
|
||||
#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
|
||||
(!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
|
||||
// without main extensions, the non-secure MSPLIM is RAZ/WI
|
||||
#define __set_MSPLIM(VALUE) ((void)(VALUE))
|
||||
#else
|
||||
#define __set_MSPLIM(VALUE) (__arm_wsr("MSPLIM", (VALUE)))
|
||||
#endif
|
||||
#define __set_PRIMASK(VALUE) (__arm_wsr("PRIMASK", (VALUE)))
|
||||
#define __set_PSP(VALUE) (__arm_wsr("PSP", (VALUE)))
|
||||
#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
|
||||
(!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
|
||||
// without main extensions, the non-secure PSPLIM is RAZ/WI
|
||||
#define __set_PSPLIM(VALUE) ((void)(VALUE))
|
||||
#else
|
||||
#define __set_PSPLIM(VALUE) (__arm_wsr("PSPLIM", (VALUE)))
|
||||
#endif
|
||||
|
||||
#define __TZ_get_CONTROL_NS() (__arm_rsr("CONTROL_NS"))
|
||||
#define __TZ_set_CONTROL_NS(VALUE) (__arm_wsr("CONTROL_NS", (VALUE)))
|
||||
#define __TZ_get_PSP_NS() (__arm_rsr("PSP_NS"))
|
||||
#define __TZ_set_PSP_NS(VALUE) (__arm_wsr("PSP_NS", (VALUE)))
|
||||
#define __TZ_get_MSP_NS() (__arm_rsr("MSP_NS"))
|
||||
#define __TZ_set_MSP_NS(VALUE) (__arm_wsr("MSP_NS", (VALUE)))
|
||||
#define __TZ_get_SP_NS() (__arm_rsr("SP_NS"))
|
||||
#define __TZ_set_SP_NS(VALUE) (__arm_wsr("SP_NS", (VALUE)))
|
||||
#define __TZ_get_PRIMASK_NS() (__arm_rsr("PRIMASK_NS"))
|
||||
#define __TZ_set_PRIMASK_NS(VALUE) (__arm_wsr("PRIMASK_NS", (VALUE)))
|
||||
#define __TZ_get_BASEPRI_NS() (__arm_rsr("BASEPRI_NS"))
|
||||
#define __TZ_set_BASEPRI_NS(VALUE) (__arm_wsr("BASEPRI_NS", (VALUE)))
|
||||
#define __TZ_get_FAULTMASK_NS() (__arm_rsr("FAULTMASK_NS"))
|
||||
#define __TZ_set_FAULTMASK_NS(VALUE)(__arm_wsr("FAULTMASK_NS", (VALUE)))
|
||||
|
||||
#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
|
||||
(!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
|
||||
// without main extensions, the non-secure PSPLIM is RAZ/WI
|
||||
#define __TZ_get_PSPLIM_NS() (0U)
|
||||
#define __TZ_set_PSPLIM_NS(VALUE) ((void)(VALUE))
|
||||
#else
|
||||
#define __TZ_get_PSPLIM_NS() (__arm_rsr("PSPLIM_NS"))
|
||||
#define __TZ_set_PSPLIM_NS(VALUE) (__arm_wsr("PSPLIM_NS", (VALUE)))
|
||||
#endif
|
||||
|
||||
#define __TZ_get_MSPLIM_NS() (__arm_rsr("MSPLIM_NS"))
|
||||
#define __TZ_set_MSPLIM_NS(VALUE) (__arm_wsr("MSPLIM_NS", (VALUE)))
|
||||
|
||||
#define __NOP __iar_builtin_no_operation
|
||||
|
||||
#define __CLZ __iar_builtin_CLZ
|
||||
#define __CLREX __iar_builtin_CLREX
|
||||
|
||||
#define __DMB __iar_builtin_DMB
|
||||
#define __DSB __iar_builtin_DSB
|
||||
#define __ISB __iar_builtin_ISB
|
||||
|
||||
#define __LDREXB __iar_builtin_LDREXB
|
||||
#define __LDREXH __iar_builtin_LDREXH
|
||||
#define __LDREXW __iar_builtin_LDREX
|
||||
|
||||
#define __RBIT __iar_builtin_RBIT
|
||||
#define __REV __iar_builtin_REV
|
||||
#define __REV16 __iar_builtin_REV16
|
||||
|
||||
__IAR_FT int16_t __REVSH(int16_t val)
|
||||
{
|
||||
return (int16_t) __iar_builtin_REVSH(val);
|
||||
}
|
||||
|
||||
#define __ROR __iar_builtin_ROR
|
||||
#define __RRX __iar_builtin_RRX
|
||||
|
||||
#define __SEV __iar_builtin_SEV
|
||||
|
||||
#if !__IAR_M0_FAMILY
|
||||
#define __SSAT __iar_builtin_SSAT
|
||||
#endif
|
||||
|
||||
#define __STREXB __iar_builtin_STREXB
|
||||
#define __STREXH __iar_builtin_STREXH
|
||||
#define __STREXW __iar_builtin_STREX
|
||||
|
||||
#if !__IAR_M0_FAMILY
|
||||
#define __USAT __iar_builtin_USAT
|
||||
#endif
|
||||
|
||||
#define __WFE __iar_builtin_WFE
|
||||
#define __WFI __iar_builtin_WFI
|
||||
|
||||
#if __ARM_MEDIA__
|
||||
#define __SADD8 __iar_builtin_SADD8
|
||||
#define __QADD8 __iar_builtin_QADD8
|
||||
#define __SHADD8 __iar_builtin_SHADD8
|
||||
#define __UADD8 __iar_builtin_UADD8
|
||||
#define __UQADD8 __iar_builtin_UQADD8
|
||||
#define __UHADD8 __iar_builtin_UHADD8
|
||||
#define __SSUB8 __iar_builtin_SSUB8
|
||||
#define __QSUB8 __iar_builtin_QSUB8
|
||||
#define __SHSUB8 __iar_builtin_SHSUB8
|
||||
#define __USUB8 __iar_builtin_USUB8
|
||||
#define __UQSUB8 __iar_builtin_UQSUB8
|
||||
#define __UHSUB8 __iar_builtin_UHSUB8
|
||||
#define __SADD16 __iar_builtin_SADD16
|
||||
#define __QADD16 __iar_builtin_QADD16
|
||||
#define __SHADD16 __iar_builtin_SHADD16
|
||||
#define __UADD16 __iar_builtin_UADD16
|
||||
#define __UQADD16 __iar_builtin_UQADD16
|
||||
#define __UHADD16 __iar_builtin_UHADD16
|
||||
#define __SSUB16 __iar_builtin_SSUB16
|
||||
#define __QSUB16 __iar_builtin_QSUB16
|
||||
#define __SHSUB16 __iar_builtin_SHSUB16
|
||||
#define __USUB16 __iar_builtin_USUB16
|
||||
#define __UQSUB16 __iar_builtin_UQSUB16
|
||||
#define __UHSUB16 __iar_builtin_UHSUB16
|
||||
#define __SASX __iar_builtin_SASX
|
||||
#define __QASX __iar_builtin_QASX
|
||||
#define __SHASX __iar_builtin_SHASX
|
||||
#define __UASX __iar_builtin_UASX
|
||||
#define __UQASX __iar_builtin_UQASX
|
||||
#define __UHASX __iar_builtin_UHASX
|
||||
#define __SSAX __iar_builtin_SSAX
|
||||
#define __QSAX __iar_builtin_QSAX
|
||||
#define __SHSAX __iar_builtin_SHSAX
|
||||
#define __USAX __iar_builtin_USAX
|
||||
#define __UQSAX __iar_builtin_UQSAX
|
||||
#define __UHSAX __iar_builtin_UHSAX
|
||||
#define __USAD8 __iar_builtin_USAD8
|
||||
#define __USADA8 __iar_builtin_USADA8
|
||||
#define __SSAT16 __iar_builtin_SSAT16
|
||||
#define __USAT16 __iar_builtin_USAT16
|
||||
#define __UXTB16 __iar_builtin_UXTB16
|
||||
#define __UXTAB16 __iar_builtin_UXTAB16
|
||||
#define __SXTB16 __iar_builtin_SXTB16
|
||||
#define __SXTAB16 __iar_builtin_SXTAB16
|
||||
#define __SMUAD __iar_builtin_SMUAD
|
||||
#define __SMUADX __iar_builtin_SMUADX
|
||||
#define __SMMLA __iar_builtin_SMMLA
|
||||
#define __SMLAD __iar_builtin_SMLAD
|
||||
#define __SMLADX __iar_builtin_SMLADX
|
||||
#define __SMLALD __iar_builtin_SMLALD
|
||||
#define __SMLALDX __iar_builtin_SMLALDX
|
||||
#define __SMUSD __iar_builtin_SMUSD
|
||||
#define __SMUSDX __iar_builtin_SMUSDX
|
||||
#define __SMLSD __iar_builtin_SMLSD
|
||||
#define __SMLSDX __iar_builtin_SMLSDX
|
||||
#define __SMLSLD __iar_builtin_SMLSLD
|
||||
#define __SMLSLDX __iar_builtin_SMLSLDX
|
||||
#define __SEL __iar_builtin_SEL
|
||||
#define __QADD __iar_builtin_QADD
|
||||
#define __QSUB __iar_builtin_QSUB
|
||||
#define __PKHBT __iar_builtin_PKHBT
|
||||
#define __PKHTB __iar_builtin_PKHTB
|
||||
#endif
|
||||
|
||||
#else /* __ICCARM_INTRINSICS_VERSION__ == 2 */
|
||||
|
||||
#if __IAR_M0_FAMILY
|
||||
/* Avoid clash between intrinsics.h and arm_math.h when compiling for Cortex-M0. */
|
||||
#define __CLZ __cmsis_iar_clz_not_active
|
||||
#define __SSAT __cmsis_iar_ssat_not_active
|
||||
#define __USAT __cmsis_iar_usat_not_active
|
||||
#define __RBIT __cmsis_iar_rbit_not_active
|
||||
#define __get_APSR __cmsis_iar_get_APSR_not_active
|
||||
#endif
|
||||
|
||||
|
||||
#if (!((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||
(defined (__FPU_USED ) && (__FPU_USED == 1U)) ))
|
||||
#define __get_FPSCR __cmsis_iar_get_FPSR_not_active
|
||||
#define __set_FPSCR __cmsis_iar_set_FPSR_not_active
|
||||
#endif
|
||||
|
||||
#ifdef __INTRINSICS_INCLUDED
|
||||
#error intrinsics.h is already included previously!
|
||||
#endif
|
||||
|
||||
#include <intrinsics.h>
|
||||
|
||||
#if __IAR_M0_FAMILY
|
||||
/* Avoid clash between intrinsics.h and arm_math.h when compiling for Cortex-M0. */
|
||||
#undef __CLZ
|
||||
#undef __SSAT
|
||||
#undef __USAT
|
||||
#undef __RBIT
|
||||
#undef __get_APSR
|
||||
|
||||
__STATIC_INLINE uint8_t __CLZ(uint32_t data)
|
||||
{
|
||||
if (data == 0U) { return 32U; }
|
||||
|
||||
uint32_t count = 0U;
|
||||
uint32_t mask = 0x80000000U;
|
||||
|
||||
while ((data & mask) == 0U)
|
||||
{
|
||||
count += 1U;
|
||||
mask = mask >> 1U;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t __RBIT(uint32_t v)
|
||||
{
|
||||
uint8_t sc = 31U;
|
||||
uint32_t r = v;
|
||||
for (v >>= 1U; v; v >>= 1U)
|
||||
{
|
||||
r <<= 1U;
|
||||
r |= v & 1U;
|
||||
sc--;
|
||||
}
|
||||
return (r << sc);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t __get_APSR(void)
|
||||
{
|
||||
uint32_t res;
|
||||
__asm("MRS %0,APSR" : "=r" (res));
|
||||
return res;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if (!((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||
(defined (__FPU_USED ) && (__FPU_USED == 1U)) ))
|
||||
#undef __get_FPSCR
|
||||
#undef __set_FPSCR
|
||||
#define __get_FPSCR() (0)
|
||||
#define __set_FPSCR(VALUE) ((void)VALUE)
|
||||
#endif
|
||||
|
||||
#pragma diag_suppress=Pe940
|
||||
#pragma diag_suppress=Pe177
|
||||
|
||||
#define __enable_irq __enable_interrupt
|
||||
#define __disable_irq __disable_interrupt
|
||||
#define __NOP __no_operation
|
||||
|
||||
#define __get_xPSR __get_PSR
|
||||
|
||||
#if (!defined(__ARM_ARCH_6M__) || __ARM_ARCH_6M__==0)
|
||||
|
||||
__IAR_FT uint32_t __LDREXW(uint32_t volatile *ptr)
|
||||
{
|
||||
return __LDREX((unsigned long *)ptr);
|
||||
}
|
||||
|
||||
__IAR_FT uint32_t __STREXW(uint32_t value, uint32_t volatile *ptr)
|
||||
{
|
||||
return __STREX(value, (unsigned long *)ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* __CORTEX_M is defined in core_cm0.h, core_cm3.h and core_cm4.h. */
|
||||
#if (__CORTEX_M >= 0x03)
|
||||
|
||||
__IAR_FT uint32_t __RRX(uint32_t value)
|
||||
{
|
||||
uint32_t result;
|
||||
__ASM("RRX %0, %1" : "=r"(result) : "r" (value) : "cc");
|
||||
return(result);
|
||||
}
|
||||
|
||||
__IAR_FT void __set_BASEPRI_MAX(uint32_t value)
|
||||
{
|
||||
__asm volatile("MSR BASEPRI_MAX,%0"::"r" (value));
|
||||
}
|
||||
|
||||
|
||||
#define __enable_fault_irq __enable_fiq
|
||||
#define __disable_fault_irq __disable_fiq
|
||||
|
||||
|
||||
#endif /* (__CORTEX_M >= 0x03) */
|
||||
|
||||
__IAR_FT uint32_t __ROR(uint32_t op1, uint32_t op2)
|
||||
{
|
||||
return (op1 >> op2) | (op1 << ((sizeof(op1)*8)-op2));
|
||||
}
|
||||
|
||||
#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
|
||||
(defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
|
||||
|
||||
__IAR_FT uint32_t __get_MSPLIM(void)
|
||||
{
|
||||
uint32_t res;
|
||||
#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
|
||||
(!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3)))
|
||||
// without main extensions, the non-secure MSPLIM is RAZ/WI
|
||||
res = 0U;
|
||||
#else
|
||||
__asm volatile("MRS %0,MSPLIM" : "=r" (res));
|
||||
#endif
|
||||
return res;
|
||||
}
|
||||
|
||||
__IAR_FT void __set_MSPLIM(uint32_t value)
|
||||
{
|
||||
#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
|
||||
(!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3)))
|
||||
// without main extensions, the non-secure MSPLIM is RAZ/WI
|
||||
(void)value;
|
||||
#else
|
||||
__asm volatile("MSR MSPLIM,%0" :: "r" (value));
|
||||
#endif
|
||||
}
|
||||
|
||||
__IAR_FT uint32_t __get_PSPLIM(void)
|
||||
{
|
||||
uint32_t res;
|
||||
#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
|
||||
(!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3)))
|
||||
// without main extensions, the non-secure PSPLIM is RAZ/WI
|
||||
res = 0U;
|
||||
#else
|
||||
__asm volatile("MRS %0,PSPLIM" : "=r" (res));
|
||||
#endif
|
||||
return res;
|
||||
}
|
||||
|
||||
__IAR_FT void __set_PSPLIM(uint32_t value)
|
||||
{
|
||||
#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
|
||||
(!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3)))
|
||||
// without main extensions, the non-secure PSPLIM is RAZ/WI
|
||||
(void)value;
|
||||
#else
|
||||
__asm volatile("MSR PSPLIM,%0" :: "r" (value));
|
||||
#endif
|
||||
}
|
||||
|
||||
__IAR_FT uint32_t __TZ_get_CONTROL_NS(void)
|
||||
{
|
||||
uint32_t res;
|
||||
__asm volatile("MRS %0,CONTROL_NS" : "=r" (res));
|
||||
return res;
|
||||
}
|
||||
|
||||
__IAR_FT void __TZ_set_CONTROL_NS(uint32_t value)
|
||||
{
|
||||
__asm volatile("MSR CONTROL_NS,%0" :: "r" (value));
|
||||
}
|
||||
|
||||
__IAR_FT uint32_t __TZ_get_PSP_NS(void)
|
||||
{
|
||||
uint32_t res;
|
||||
__asm volatile("MRS %0,PSP_NS" : "=r" (res));
|
||||
return res;
|
||||
}
|
||||
|
||||
__IAR_FT void __TZ_set_PSP_NS(uint32_t value)
|
||||
{
|
||||
__asm volatile("MSR PSP_NS,%0" :: "r" (value));
|
||||
}
|
||||
|
||||
__IAR_FT uint32_t __TZ_get_MSP_NS(void)
|
||||
{
|
||||
uint32_t res;
|
||||
__asm volatile("MRS %0,MSP_NS" : "=r" (res));
|
||||
return res;
|
||||
}
|
||||
|
||||
__IAR_FT void __TZ_set_MSP_NS(uint32_t value)
|
||||
{
|
||||
__asm volatile("MSR MSP_NS,%0" :: "r" (value));
|
||||
}
|
||||
|
||||
__IAR_FT uint32_t __TZ_get_SP_NS(void)
|
||||
{
|
||||
uint32_t res;
|
||||
__asm volatile("MRS %0,SP_NS" : "=r" (res));
|
||||
return res;
|
||||
}
|
||||
__IAR_FT void __TZ_set_SP_NS(uint32_t value)
|
||||
{
|
||||
__asm volatile("MSR SP_NS,%0" :: "r" (value));
|
||||
}
|
||||
|
||||
__IAR_FT uint32_t __TZ_get_PRIMASK_NS(void)
|
||||
{
|
||||
uint32_t res;
|
||||
__asm volatile("MRS %0,PRIMASK_NS" : "=r" (res));
|
||||
return res;
|
||||
}
|
||||
|
||||
__IAR_FT void __TZ_set_PRIMASK_NS(uint32_t value)
|
||||
{
|
||||
__asm volatile("MSR PRIMASK_NS,%0" :: "r" (value));
|
||||
}
|
||||
|
||||
__IAR_FT uint32_t __TZ_get_BASEPRI_NS(void)
|
||||
{
|
||||
uint32_t res;
|
||||
__asm volatile("MRS %0,BASEPRI_NS" : "=r" (res));
|
||||
return res;
|
||||
}
|
||||
|
||||
__IAR_FT void __TZ_set_BASEPRI_NS(uint32_t value)
|
||||
{
|
||||
__asm volatile("MSR BASEPRI_NS,%0" :: "r" (value));
|
||||
}
|
||||
|
||||
__IAR_FT uint32_t __TZ_get_FAULTMASK_NS(void)
|
||||
{
|
||||
uint32_t res;
|
||||
__asm volatile("MRS %0,FAULTMASK_NS" : "=r" (res));
|
||||
return res;
|
||||
}
|
||||
|
||||
__IAR_FT void __TZ_set_FAULTMASK_NS(uint32_t value)
|
||||
{
|
||||
__asm volatile("MSR FAULTMASK_NS,%0" :: "r" (value));
|
||||
}
|
||||
|
||||
__IAR_FT uint32_t __TZ_get_PSPLIM_NS(void)
|
||||
{
|
||||
uint32_t res;
|
||||
#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
|
||||
(!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3)))
|
||||
// without main extensions, the non-secure PSPLIM is RAZ/WI
|
||||
res = 0U;
|
||||
#else
|
||||
__asm volatile("MRS %0,PSPLIM_NS" : "=r" (res));
|
||||
#endif
|
||||
return res;
|
||||
}
|
||||
|
||||
__IAR_FT void __TZ_set_PSPLIM_NS(uint32_t value)
|
||||
{
|
||||
#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
|
||||
(!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3)))
|
||||
// without main extensions, the non-secure PSPLIM is RAZ/WI
|
||||
(void)value;
|
||||
#else
|
||||
__asm volatile("MSR PSPLIM_NS,%0" :: "r" (value));
|
||||
#endif
|
||||
}
|
||||
|
||||
__IAR_FT uint32_t __TZ_get_MSPLIM_NS(void)
|
||||
{
|
||||
uint32_t res;
|
||||
__asm volatile("MRS %0,MSPLIM_NS" : "=r" (res));
|
||||
return res;
|
||||
}
|
||||
|
||||
__IAR_FT void __TZ_set_MSPLIM_NS(uint32_t value)
|
||||
{
|
||||
__asm volatile("MSR MSPLIM_NS,%0" :: "r" (value));
|
||||
}
|
||||
|
||||
#endif /* __ARM_ARCH_8M_MAIN__ or __ARM_ARCH_8M_BASE__ */
|
||||
|
||||
#endif /* __ICCARM_INTRINSICS_VERSION__ == 2 */
|
||||
|
||||
#define __BKPT(value) __asm volatile ("BKPT %0" : : "i"(value))
|
||||
|
||||
#if __IAR_M0_FAMILY
|
||||
__STATIC_INLINE int32_t __SSAT(int32_t val, uint32_t sat)
|
||||
{
|
||||
if ((sat >= 1U) && (sat <= 32U))
|
||||
{
|
||||
const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U);
|
||||
const int32_t min = -1 - max ;
|
||||
if (val > max)
|
||||
{
|
||||
return max;
|
||||
}
|
||||
else if (val < min)
|
||||
{
|
||||
return min;
|
||||
}
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t __USAT(int32_t val, uint32_t sat)
|
||||
{
|
||||
if (sat <= 31U)
|
||||
{
|
||||
const uint32_t max = ((1U << sat) - 1U);
|
||||
if (val > (int32_t)max)
|
||||
{
|
||||
return max;
|
||||
}
|
||||
else if (val < 0)
|
||||
{
|
||||
return 0U;
|
||||
}
|
||||
}
|
||||
return (uint32_t)val;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (__CORTEX_M >= 0x03) /* __CORTEX_M is defined in core_cm0.h, core_cm3.h and core_cm4.h. */
|
||||
|
||||
__IAR_FT uint8_t __LDRBT(volatile uint8_t *addr)
|
||||
{
|
||||
uint32_t res;
|
||||
__ASM("LDRBT %0, [%1]" : "=r" (res) : "r" (addr) : "memory");
|
||||
return ((uint8_t)res);
|
||||
}
|
||||
|
||||
__IAR_FT uint16_t __LDRHT(volatile uint16_t *addr)
|
||||
{
|
||||
uint32_t res;
|
||||
__ASM("LDRHT %0, [%1]" : "=r" (res) : "r" (addr) : "memory");
|
||||
return ((uint16_t)res);
|
||||
}
|
||||
|
||||
__IAR_FT uint32_t __LDRT(volatile uint32_t *addr)
|
||||
{
|
||||
uint32_t res;
|
||||
__ASM("LDRT %0, [%1]" : "=r" (res) : "r" (addr) : "memory");
|
||||
return res;
|
||||
}
|
||||
|
||||
__IAR_FT void __STRBT(uint8_t value, volatile uint8_t *addr)
|
||||
{
|
||||
__ASM("STRBT %1, [%0]" : : "r" (addr), "r" ((uint32_t)value) : "memory");
|
||||
}
|
||||
|
||||
__IAR_FT void __STRHT(uint16_t value, volatile uint16_t *addr)
|
||||
{
|
||||
__ASM("STRHT %1, [%0]" : : "r" (addr), "r" ((uint32_t)value) : "memory");
|
||||
}
|
||||
|
||||
__IAR_FT void __STRT(uint32_t value, volatile uint32_t *addr)
|
||||
{
|
||||
__ASM("STRT %1, [%0]" : : "r" (addr), "r" (value) : "memory");
|
||||
}
|
||||
|
||||
#endif /* (__CORTEX_M >= 0x03) */
|
||||
|
||||
#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
|
||||
(defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
|
||||
|
||||
|
||||
__IAR_FT uint8_t __LDAB(volatile uint8_t *ptr)
|
||||
{
|
||||
uint32_t res;
|
||||
__ASM volatile ("LDAB %0, [%1]" : "=r" (res) : "r" (ptr) : "memory");
|
||||
return ((uint8_t)res);
|
||||
}
|
||||
|
||||
__IAR_FT uint16_t __LDAH(volatile uint16_t *ptr)
|
||||
{
|
||||
uint32_t res;
|
||||
__ASM volatile ("LDAH %0, [%1]" : "=r" (res) : "r" (ptr) : "memory");
|
||||
return ((uint16_t)res);
|
||||
}
|
||||
|
||||
__IAR_FT uint32_t __LDA(volatile uint32_t *ptr)
|
||||
{
|
||||
uint32_t res;
|
||||
__ASM volatile ("LDA %0, [%1]" : "=r" (res) : "r" (ptr) : "memory");
|
||||
return res;
|
||||
}
|
||||
|
||||
__IAR_FT void __STLB(uint8_t value, volatile uint8_t *ptr)
|
||||
{
|
||||
__ASM volatile ("STLB %1, [%0]" :: "r" (ptr), "r" (value) : "memory");
|
||||
}
|
||||
|
||||
__IAR_FT void __STLH(uint16_t value, volatile uint16_t *ptr)
|
||||
{
|
||||
__ASM volatile ("STLH %1, [%0]" :: "r" (ptr), "r" (value) : "memory");
|
||||
}
|
||||
|
||||
__IAR_FT void __STL(uint32_t value, volatile uint32_t *ptr)
|
||||
{
|
||||
__ASM volatile ("STL %1, [%0]" :: "r" (ptr), "r" (value) : "memory");
|
||||
}
|
||||
|
||||
__IAR_FT uint8_t __LDAEXB(volatile uint8_t *ptr)
|
||||
{
|
||||
uint32_t res;
|
||||
__ASM volatile ("LDAEXB %0, [%1]" : "=r" (res) : "r" (ptr) : "memory");
|
||||
return ((uint8_t)res);
|
||||
}
|
||||
|
||||
__IAR_FT uint16_t __LDAEXH(volatile uint16_t *ptr)
|
||||
{
|
||||
uint32_t res;
|
||||
__ASM volatile ("LDAEXH %0, [%1]" : "=r" (res) : "r" (ptr) : "memory");
|
||||
return ((uint16_t)res);
|
||||
}
|
||||
|
||||
__IAR_FT uint32_t __LDAEX(volatile uint32_t *ptr)
|
||||
{
|
||||
uint32_t res;
|
||||
__ASM volatile ("LDAEX %0, [%1]" : "=r" (res) : "r" (ptr) : "memory");
|
||||
return res;
|
||||
}
|
||||
|
||||
__IAR_FT uint32_t __STLEXB(uint8_t value, volatile uint8_t *ptr)
|
||||
{
|
||||
uint32_t res;
|
||||
__ASM volatile ("STLEXB %0, %2, [%1]" : "=r" (res) : "r" (ptr), "r" (value) : "memory");
|
||||
return res;
|
||||
}
|
||||
|
||||
__IAR_FT uint32_t __STLEXH(uint16_t value, volatile uint16_t *ptr)
|
||||
{
|
||||
uint32_t res;
|
||||
__ASM volatile ("STLEXH %0, %2, [%1]" : "=r" (res) : "r" (ptr), "r" (value) : "memory");
|
||||
return res;
|
||||
}
|
||||
|
||||
__IAR_FT uint32_t __STLEX(uint32_t value, volatile uint32_t *ptr)
|
||||
{
|
||||
uint32_t res;
|
||||
__ASM volatile ("STLEX %0, %2, [%1]" : "=r" (res) : "r" (ptr), "r" (value) : "memory");
|
||||
return res;
|
||||
}
|
||||
|
||||
#endif /* __ARM_ARCH_8M_MAIN__ or __ARM_ARCH_8M_BASE__ */
|
||||
|
||||
#undef __IAR_FT
|
||||
#undef __IAR_M0_FAMILY
|
||||
#undef __ICCARM_V8
|
||||
|
||||
#pragma diag_default=Pe940
|
||||
#pragma diag_default=Pe177
|
||||
|
||||
#endif /* __CMSIS_ICCARM_H__ */
|
||||
39
Drivers/CMSIS/Include/cmsis_version.h
Normal file
39
Drivers/CMSIS/Include/cmsis_version.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/**************************************************************************//**
|
||||
* @file cmsis_version.h
|
||||
* @brief CMSIS Core(M) Version definitions
|
||||
* @version V5.0.2
|
||||
* @date 19. April 2017
|
||||
******************************************************************************/
|
||||
/*
|
||||
* Copyright (c) 2009-2017 ARM Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if defined ( __ICCARM__ )
|
||||
#pragma system_include /* treat file as system include file for MISRA check */
|
||||
#elif defined (__clang__)
|
||||
#pragma clang system_header /* treat file as system include file */
|
||||
#endif
|
||||
|
||||
#ifndef __CMSIS_VERSION_H
|
||||
#define __CMSIS_VERSION_H
|
||||
|
||||
/* CMSIS Version definitions */
|
||||
#define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */
|
||||
#define __CM_CMSIS_VERSION_SUB ( 1U) /*!< [15:0] CMSIS Core(M) sub version */
|
||||
#define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \
|
||||
__CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */
|
||||
#endif
|
||||
1918
Drivers/CMSIS/Include/core_armv8mbl.h
Normal file
1918
Drivers/CMSIS/Include/core_armv8mbl.h
Normal file
File diff suppressed because it is too large
Load Diff
2927
Drivers/CMSIS/Include/core_armv8mml.h
Normal file
2927
Drivers/CMSIS/Include/core_armv8mml.h
Normal file
File diff suppressed because it is too large
Load Diff
949
Drivers/CMSIS/Include/core_cm0.h
Normal file
949
Drivers/CMSIS/Include/core_cm0.h
Normal file
@@ -0,0 +1,949 @@
|
||||
/**************************************************************************//**
|
||||
* @file core_cm0.h
|
||||
* @brief CMSIS Cortex-M0 Core Peripheral Access Layer Header File
|
||||
* @version V5.0.5
|
||||
* @date 28. May 2018
|
||||
******************************************************************************/
|
||||
/*
|
||||
* Copyright (c) 2009-2018 Arm Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if defined ( __ICCARM__ )
|
||||
#pragma system_include /* treat file as system include file for MISRA check */
|
||||
#elif defined (__clang__)
|
||||
#pragma clang system_header /* treat file as system include file */
|
||||
#endif
|
||||
|
||||
#ifndef __CORE_CM0_H_GENERIC
|
||||
#define __CORE_CM0_H_GENERIC
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
\page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions
|
||||
CMSIS violates the following MISRA-C:2004 rules:
|
||||
|
||||
\li Required Rule 8.5, object/function definition in header file.<br>
|
||||
Function definitions in header files are used to allow 'inlining'.
|
||||
|
||||
\li Required Rule 18.4, declaration of union type or object of union type: '{...}'.<br>
|
||||
Unions are used for effective representation of core registers.
|
||||
|
||||
\li Advisory Rule 19.7, Function-like macro defined.<br>
|
||||
Function-like macros are used to allow more efficient code.
|
||||
*/
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* CMSIS definitions
|
||||
******************************************************************************/
|
||||
/**
|
||||
\ingroup Cortex_M0
|
||||
@{
|
||||
*/
|
||||
|
||||
#include "cmsis_version.h"
|
||||
|
||||
/* CMSIS CM0 definitions */
|
||||
#define __CM0_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */
|
||||
#define __CM0_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */
|
||||
#define __CM0_CMSIS_VERSION ((__CM0_CMSIS_VERSION_MAIN << 16U) | \
|
||||
__CM0_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */
|
||||
|
||||
#define __CORTEX_M (0U) /*!< Cortex-M Core */
|
||||
|
||||
/** __FPU_USED indicates whether an FPU is used or not.
|
||||
This core does not support an FPU at all
|
||||
*/
|
||||
#define __FPU_USED 0U
|
||||
|
||||
#if defined ( __CC_ARM )
|
||||
#if defined __TARGET_FPU_VFP
|
||||
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||
#endif
|
||||
|
||||
#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||
#if defined __ARM_PCS_VFP
|
||||
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||
#endif
|
||||
|
||||
#elif defined ( __GNUC__ )
|
||||
#if defined (__VFP_FP__) && !defined(__SOFTFP__)
|
||||
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||
#endif
|
||||
|
||||
#elif defined ( __ICCARM__ )
|
||||
#if defined __ARMVFP__
|
||||
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||
#endif
|
||||
|
||||
#elif defined ( __TI_ARM__ )
|
||||
#if defined __TI_VFP_SUPPORT__
|
||||
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||
#endif
|
||||
|
||||
#elif defined ( __TASKING__ )
|
||||
#if defined __FPU_VFP__
|
||||
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||
#endif
|
||||
|
||||
#elif defined ( __CSMC__ )
|
||||
#if ( __CSMC__ & 0x400U)
|
||||
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#include "cmsis_compiler.h" /* CMSIS compiler specific defines */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __CORE_CM0_H_GENERIC */
|
||||
|
||||
#ifndef __CMSIS_GENERIC
|
||||
|
||||
#ifndef __CORE_CM0_H_DEPENDANT
|
||||
#define __CORE_CM0_H_DEPENDANT
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* check device defines and use defaults */
|
||||
#if defined __CHECK_DEVICE_DEFINES
|
||||
#ifndef __CM0_REV
|
||||
#define __CM0_REV 0x0000U
|
||||
#warning "__CM0_REV not defined in device header file; using default!"
|
||||
#endif
|
||||
|
||||
#ifndef __NVIC_PRIO_BITS
|
||||
#define __NVIC_PRIO_BITS 2U
|
||||
#warning "__NVIC_PRIO_BITS not defined in device header file; using default!"
|
||||
#endif
|
||||
|
||||
#ifndef __Vendor_SysTickConfig
|
||||
#define __Vendor_SysTickConfig 0U
|
||||
#warning "__Vendor_SysTickConfig not defined in device header file; using default!"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* IO definitions (access restrictions to peripheral registers) */
|
||||
/**
|
||||
\defgroup CMSIS_glob_defs CMSIS Global Defines
|
||||
|
||||
<strong>IO Type Qualifiers</strong> are used
|
||||
\li to specify the access to peripheral variables.
|
||||
\li for automatic generation of peripheral register debug information.
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
#define __I volatile /*!< Defines 'read only' permissions */
|
||||
#else
|
||||
#define __I volatile const /*!< Defines 'read only' permissions */
|
||||
#endif
|
||||
#define __O volatile /*!< Defines 'write only' permissions */
|
||||
#define __IO volatile /*!< Defines 'read / write' permissions */
|
||||
|
||||
/* following defines should be used for structure members */
|
||||
#define __IM volatile const /*! Defines 'read only' structure member permissions */
|
||||
#define __OM volatile /*! Defines 'write only' structure member permissions */
|
||||
#define __IOM volatile /*! Defines 'read / write' structure member permissions */
|
||||
|
||||
/*@} end of group Cortex_M0 */
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Register Abstraction
|
||||
Core Register contain:
|
||||
- Core Register
|
||||
- Core NVIC Register
|
||||
- Core SCB Register
|
||||
- Core SysTick Register
|
||||
******************************************************************************/
|
||||
/**
|
||||
\defgroup CMSIS_core_register Defines and Type Definitions
|
||||
\brief Type definitions and defines for Cortex-M processor based devices.
|
||||
*/
|
||||
|
||||
/**
|
||||
\ingroup CMSIS_core_register
|
||||
\defgroup CMSIS_CORE Status and Control Registers
|
||||
\brief Core Register type definitions.
|
||||
@{
|
||||
*/
|
||||
|
||||
/**
|
||||
\brief Union type to access the Application Program Status Register (APSR).
|
||||
*/
|
||||
typedef union
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint32_t _reserved0:28; /*!< bit: 0..27 Reserved */
|
||||
uint32_t V:1; /*!< bit: 28 Overflow condition code flag */
|
||||
uint32_t C:1; /*!< bit: 29 Carry condition code flag */
|
||||
uint32_t Z:1; /*!< bit: 30 Zero condition code flag */
|
||||
uint32_t N:1; /*!< bit: 31 Negative condition code flag */
|
||||
} b; /*!< Structure used for bit access */
|
||||
uint32_t w; /*!< Type used for word access */
|
||||
} APSR_Type;
|
||||
|
||||
/* APSR Register Definitions */
|
||||
#define APSR_N_Pos 31U /*!< APSR: N Position */
|
||||
#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */
|
||||
|
||||
#define APSR_Z_Pos 30U /*!< APSR: Z Position */
|
||||
#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */
|
||||
|
||||
#define APSR_C_Pos 29U /*!< APSR: C Position */
|
||||
#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */
|
||||
|
||||
#define APSR_V_Pos 28U /*!< APSR: V Position */
|
||||
#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */
|
||||
|
||||
|
||||
/**
|
||||
\brief Union type to access the Interrupt Program Status Register (IPSR).
|
||||
*/
|
||||
typedef union
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */
|
||||
uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */
|
||||
} b; /*!< Structure used for bit access */
|
||||
uint32_t w; /*!< Type used for word access */
|
||||
} IPSR_Type;
|
||||
|
||||
/* IPSR Register Definitions */
|
||||
#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */
|
||||
#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */
|
||||
|
||||
|
||||
/**
|
||||
\brief Union type to access the Special-Purpose Program Status Registers (xPSR).
|
||||
*/
|
||||
typedef union
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */
|
||||
uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */
|
||||
uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */
|
||||
uint32_t _reserved1:3; /*!< bit: 25..27 Reserved */
|
||||
uint32_t V:1; /*!< bit: 28 Overflow condition code flag */
|
||||
uint32_t C:1; /*!< bit: 29 Carry condition code flag */
|
||||
uint32_t Z:1; /*!< bit: 30 Zero condition code flag */
|
||||
uint32_t N:1; /*!< bit: 31 Negative condition code flag */
|
||||
} b; /*!< Structure used for bit access */
|
||||
uint32_t w; /*!< Type used for word access */
|
||||
} xPSR_Type;
|
||||
|
||||
/* xPSR Register Definitions */
|
||||
#define xPSR_N_Pos 31U /*!< xPSR: N Position */
|
||||
#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */
|
||||
|
||||
#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */
|
||||
#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */
|
||||
|
||||
#define xPSR_C_Pos 29U /*!< xPSR: C Position */
|
||||
#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */
|
||||
|
||||
#define xPSR_V_Pos 28U /*!< xPSR: V Position */
|
||||
#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */
|
||||
|
||||
#define xPSR_T_Pos 24U /*!< xPSR: T Position */
|
||||
#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */
|
||||
|
||||
#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */
|
||||
#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */
|
||||
|
||||
|
||||
/**
|
||||
\brief Union type to access the Control Registers (CONTROL).
|
||||
*/
|
||||
typedef union
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint32_t _reserved0:1; /*!< bit: 0 Reserved */
|
||||
uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */
|
||||
uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */
|
||||
} b; /*!< Structure used for bit access */
|
||||
uint32_t w; /*!< Type used for word access */
|
||||
} CONTROL_Type;
|
||||
|
||||
/* CONTROL Register Definitions */
|
||||
#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */
|
||||
#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */
|
||||
|
||||
/*@} end of group CMSIS_CORE */
|
||||
|
||||
|
||||
/**
|
||||
\ingroup CMSIS_core_register
|
||||
\defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC)
|
||||
\brief Type definitions for the NVIC Registers
|
||||
@{
|
||||
*/
|
||||
|
||||
/**
|
||||
\brief Structure type to access the Nested Vectored Interrupt Controller (NVIC).
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
__IOM uint32_t ISER[1U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */
|
||||
uint32_t RESERVED0[31U];
|
||||
__IOM uint32_t ICER[1U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */
|
||||
uint32_t RSERVED1[31U];
|
||||
__IOM uint32_t ISPR[1U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */
|
||||
uint32_t RESERVED2[31U];
|
||||
__IOM uint32_t ICPR[1U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */
|
||||
uint32_t RESERVED3[31U];
|
||||
uint32_t RESERVED4[64U];
|
||||
__IOM uint32_t IP[8U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register */
|
||||
} NVIC_Type;
|
||||
|
||||
/*@} end of group CMSIS_NVIC */
|
||||
|
||||
|
||||
/**
|
||||
\ingroup CMSIS_core_register
|
||||
\defgroup CMSIS_SCB System Control Block (SCB)
|
||||
\brief Type definitions for the System Control Block Registers
|
||||
@{
|
||||
*/
|
||||
|
||||
/**
|
||||
\brief Structure type to access the System Control Block (SCB).
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
__IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */
|
||||
__IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */
|
||||
uint32_t RESERVED0;
|
||||
__IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */
|
||||
__IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */
|
||||
__IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */
|
||||
uint32_t RESERVED1;
|
||||
__IOM uint32_t SHP[2U]; /*!< Offset: 0x01C (R/W) System Handlers Priority Registers. [0] is RESERVED */
|
||||
__IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */
|
||||
} SCB_Type;
|
||||
|
||||
/* SCB CPUID Register Definitions */
|
||||
#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */
|
||||
#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */
|
||||
|
||||
#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */
|
||||
#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */
|
||||
|
||||
#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */
|
||||
#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */
|
||||
|
||||
#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */
|
||||
#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */
|
||||
|
||||
#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */
|
||||
#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */
|
||||
|
||||
/* SCB Interrupt Control State Register Definitions */
|
||||
#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */
|
||||
#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */
|
||||
|
||||
#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */
|
||||
#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */
|
||||
|
||||
#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */
|
||||
#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */
|
||||
|
||||
#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */
|
||||
#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */
|
||||
|
||||
#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */
|
||||
#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */
|
||||
|
||||
#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */
|
||||
#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */
|
||||
|
||||
#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */
|
||||
#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */
|
||||
|
||||
#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */
|
||||
#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */
|
||||
|
||||
#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */
|
||||
#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */
|
||||
|
||||
/* SCB Application Interrupt and Reset Control Register Definitions */
|
||||
#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */
|
||||
#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */
|
||||
|
||||
#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */
|
||||
#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */
|
||||
|
||||
#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */
|
||||
#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */
|
||||
|
||||
#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */
|
||||
#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */
|
||||
|
||||
#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */
|
||||
#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */
|
||||
|
||||
/* SCB System Control Register Definitions */
|
||||
#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */
|
||||
#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */
|
||||
|
||||
#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */
|
||||
#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */
|
||||
|
||||
#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */
|
||||
#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */
|
||||
|
||||
/* SCB Configuration Control Register Definitions */
|
||||
#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */
|
||||
#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */
|
||||
|
||||
#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */
|
||||
#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */
|
||||
|
||||
/* SCB System Handler Control and State Register Definitions */
|
||||
#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */
|
||||
#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */
|
||||
|
||||
/*@} end of group CMSIS_SCB */
|
||||
|
||||
|
||||
/**
|
||||
\ingroup CMSIS_core_register
|
||||
\defgroup CMSIS_SysTick System Tick Timer (SysTick)
|
||||
\brief Type definitions for the System Timer Registers.
|
||||
@{
|
||||
*/
|
||||
|
||||
/**
|
||||
\brief Structure type to access the System Timer (SysTick).
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
__IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */
|
||||
__IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */
|
||||
__IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */
|
||||
__IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */
|
||||
} SysTick_Type;
|
||||
|
||||
/* SysTick Control / Status Register Definitions */
|
||||
#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */
|
||||
#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */
|
||||
|
||||
#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */
|
||||
#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */
|
||||
|
||||
#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */
|
||||
#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */
|
||||
|
||||
#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */
|
||||
#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */
|
||||
|
||||
/* SysTick Reload Register Definitions */
|
||||
#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */
|
||||
#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */
|
||||
|
||||
/* SysTick Current Register Definitions */
|
||||
#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */
|
||||
#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */
|
||||
|
||||
/* SysTick Calibration Register Definitions */
|
||||
#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */
|
||||
#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */
|
||||
|
||||
#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */
|
||||
#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */
|
||||
|
||||
#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */
|
||||
#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */
|
||||
|
||||
/*@} end of group CMSIS_SysTick */
|
||||
|
||||
|
||||
/**
|
||||
\ingroup CMSIS_core_register
|
||||
\defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug)
|
||||
\brief Cortex-M0 Core Debug Registers (DCB registers, SHCSR, and DFSR) are only accessible over DAP and not via processor.
|
||||
Therefore they are not covered by the Cortex-M0 header file.
|
||||
@{
|
||||
*/
|
||||
/*@} end of group CMSIS_CoreDebug */
|
||||
|
||||
|
||||
/**
|
||||
\ingroup CMSIS_core_register
|
||||
\defgroup CMSIS_core_bitfield Core register bit field macros
|
||||
\brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk).
|
||||
@{
|
||||
*/
|
||||
|
||||
/**
|
||||
\brief Mask and shift a bit field value for use in a register bit range.
|
||||
\param[in] field Name of the register bit field.
|
||||
\param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type.
|
||||
\return Masked and shifted value.
|
||||
*/
|
||||
#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk)
|
||||
|
||||
/**
|
||||
\brief Mask and shift a register value to extract a bit filed value.
|
||||
\param[in] field Name of the register bit field.
|
||||
\param[in] value Value of register. This parameter is interpreted as an uint32_t type.
|
||||
\return Masked and shifted bit field value.
|
||||
*/
|
||||
#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos)
|
||||
|
||||
/*@} end of group CMSIS_core_bitfield */
|
||||
|
||||
|
||||
/**
|
||||
\ingroup CMSIS_core_register
|
||||
\defgroup CMSIS_core_base Core Definitions
|
||||
\brief Definitions for base addresses, unions, and structures.
|
||||
@{
|
||||
*/
|
||||
|
||||
/* Memory mapping of Core Hardware */
|
||||
#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */
|
||||
#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */
|
||||
#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */
|
||||
#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */
|
||||
|
||||
#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */
|
||||
#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */
|
||||
#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */
|
||||
|
||||
|
||||
/*@} */
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Hardware Abstraction Layer
|
||||
Core Function Interface contains:
|
||||
- Core NVIC Functions
|
||||
- Core SysTick Functions
|
||||
- Core Register Access Functions
|
||||
******************************************************************************/
|
||||
/**
|
||||
\defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* ########################## NVIC functions #################################### */
|
||||
/**
|
||||
\ingroup CMSIS_Core_FunctionInterface
|
||||
\defgroup CMSIS_Core_NVICFunctions NVIC Functions
|
||||
\brief Functions that manage interrupts and exceptions via the NVIC.
|
||||
@{
|
||||
*/
|
||||
|
||||
#ifdef CMSIS_NVIC_VIRTUAL
|
||||
#ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE
|
||||
#define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h"
|
||||
#endif
|
||||
#include CMSIS_NVIC_VIRTUAL_HEADER_FILE
|
||||
#else
|
||||
#define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping
|
||||
#define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping
|
||||
#define NVIC_EnableIRQ __NVIC_EnableIRQ
|
||||
#define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ
|
||||
#define NVIC_DisableIRQ __NVIC_DisableIRQ
|
||||
#define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ
|
||||
#define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ
|
||||
#define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ
|
||||
/*#define NVIC_GetActive __NVIC_GetActive not available for Cortex-M0 */
|
||||
#define NVIC_SetPriority __NVIC_SetPriority
|
||||
#define NVIC_GetPriority __NVIC_GetPriority
|
||||
#define NVIC_SystemReset __NVIC_SystemReset
|
||||
#endif /* CMSIS_NVIC_VIRTUAL */
|
||||
|
||||
#ifdef CMSIS_VECTAB_VIRTUAL
|
||||
#ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE
|
||||
#define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h"
|
||||
#endif
|
||||
#include CMSIS_VECTAB_VIRTUAL_HEADER_FILE
|
||||
#else
|
||||
#define NVIC_SetVector __NVIC_SetVector
|
||||
#define NVIC_GetVector __NVIC_GetVector
|
||||
#endif /* (CMSIS_VECTAB_VIRTUAL) */
|
||||
|
||||
#define NVIC_USER_IRQ_OFFSET 16
|
||||
|
||||
|
||||
/* The following EXC_RETURN values are saved the LR on exception entry */
|
||||
#define EXC_RETURN_HANDLER (0xFFFFFFF1UL) /* return to Handler mode, uses MSP after return */
|
||||
#define EXC_RETURN_THREAD_MSP (0xFFFFFFF9UL) /* return to Thread mode, uses MSP after return */
|
||||
#define EXC_RETURN_THREAD_PSP (0xFFFFFFFDUL) /* return to Thread mode, uses PSP after return */
|
||||
|
||||
|
||||
/* Interrupt Priorities are WORD accessible only under Armv6-M */
|
||||
/* The following MACROS handle generation of the register offset and byte masks */
|
||||
#define _BIT_SHIFT(IRQn) ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL)
|
||||
#define _SHP_IDX(IRQn) ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >> 2UL) )
|
||||
#define _IP_IDX(IRQn) ( (((uint32_t)(int32_t)(IRQn)) >> 2UL) )
|
||||
|
||||
#define __NVIC_SetPriorityGrouping(X) (void)(X)
|
||||
#define __NVIC_GetPriorityGrouping() (0U)
|
||||
|
||||
/**
|
||||
\brief Enable Interrupt
|
||||
\details Enables a device specific interrupt in the NVIC interrupt controller.
|
||||
\param [in] IRQn Device specific interrupt number.
|
||||
\note IRQn must not be negative.
|
||||
*/
|
||||
__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn)
|
||||
{
|
||||
if ((int32_t)(IRQn) >= 0)
|
||||
{
|
||||
NVIC->ISER[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Get Interrupt Enable status
|
||||
\details Returns a device specific interrupt enable status from the NVIC interrupt controller.
|
||||
\param [in] IRQn Device specific interrupt number.
|
||||
\return 0 Interrupt is not enabled.
|
||||
\return 1 Interrupt is enabled.
|
||||
\note IRQn must not be negative.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn)
|
||||
{
|
||||
if ((int32_t)(IRQn) >= 0)
|
||||
{
|
||||
return((uint32_t)(((NVIC->ISER[0U] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
|
||||
}
|
||||
else
|
||||
{
|
||||
return(0U);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Disable Interrupt
|
||||
\details Disables a device specific interrupt in the NVIC interrupt controller.
|
||||
\param [in] IRQn Device specific interrupt number.
|
||||
\note IRQn must not be negative.
|
||||
*/
|
||||
__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn)
|
||||
{
|
||||
if ((int32_t)(IRQn) >= 0)
|
||||
{
|
||||
NVIC->ICER[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL));
|
||||
__DSB();
|
||||
__ISB();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Get Pending Interrupt
|
||||
\details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt.
|
||||
\param [in] IRQn Device specific interrupt number.
|
||||
\return 0 Interrupt status is not pending.
|
||||
\return 1 Interrupt status is pending.
|
||||
\note IRQn must not be negative.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn)
|
||||
{
|
||||
if ((int32_t)(IRQn) >= 0)
|
||||
{
|
||||
return((uint32_t)(((NVIC->ISPR[0U] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
|
||||
}
|
||||
else
|
||||
{
|
||||
return(0U);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Set Pending Interrupt
|
||||
\details Sets the pending bit of a device specific interrupt in the NVIC pending register.
|
||||
\param [in] IRQn Device specific interrupt number.
|
||||
\note IRQn must not be negative.
|
||||
*/
|
||||
__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn)
|
||||
{
|
||||
if ((int32_t)(IRQn) >= 0)
|
||||
{
|
||||
NVIC->ISPR[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Clear Pending Interrupt
|
||||
\details Clears the pending bit of a device specific interrupt in the NVIC pending register.
|
||||
\param [in] IRQn Device specific interrupt number.
|
||||
\note IRQn must not be negative.
|
||||
*/
|
||||
__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn)
|
||||
{
|
||||
if ((int32_t)(IRQn) >= 0)
|
||||
{
|
||||
NVIC->ICPR[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Set Interrupt Priority
|
||||
\details Sets the priority of a device specific interrupt or a processor exception.
|
||||
The interrupt number can be positive to specify a device specific interrupt,
|
||||
or negative to specify a processor exception.
|
||||
\param [in] IRQn Interrupt number.
|
||||
\param [in] priority Priority to set.
|
||||
\note The priority cannot be set for every processor exception.
|
||||
*/
|
||||
__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
|
||||
{
|
||||
if ((int32_t)(IRQn) >= 0)
|
||||
{
|
||||
NVIC->IP[_IP_IDX(IRQn)] = ((uint32_t)(NVIC->IP[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) |
|
||||
(((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn)));
|
||||
}
|
||||
else
|
||||
{
|
||||
SCB->SHP[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) |
|
||||
(((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Get Interrupt Priority
|
||||
\details Reads the priority of a device specific interrupt or a processor exception.
|
||||
The interrupt number can be positive to specify a device specific interrupt,
|
||||
or negative to specify a processor exception.
|
||||
\param [in] IRQn Interrupt number.
|
||||
\return Interrupt Priority.
|
||||
Value is aligned automatically to the implemented priority bits of the microcontroller.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn)
|
||||
{
|
||||
|
||||
if ((int32_t)(IRQn) >= 0)
|
||||
{
|
||||
return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS)));
|
||||
}
|
||||
else
|
||||
{
|
||||
return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Encode Priority
|
||||
\details Encodes the priority for an interrupt with the given priority group,
|
||||
preemptive priority value, and subpriority value.
|
||||
In case of a conflict between priority grouping and available
|
||||
priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set.
|
||||
\param [in] PriorityGroup Used priority group.
|
||||
\param [in] PreemptPriority Preemptive priority value (starting from 0).
|
||||
\param [in] SubPriority Subpriority value (starting from 0).
|
||||
\return Encoded priority. Value can be used in the function \ref NVIC_SetPriority().
|
||||
*/
|
||||
__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority)
|
||||
{
|
||||
uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */
|
||||
uint32_t PreemptPriorityBits;
|
||||
uint32_t SubPriorityBits;
|
||||
|
||||
PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp);
|
||||
SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS));
|
||||
|
||||
return (
|
||||
((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) |
|
||||
((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL)))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Decode Priority
|
||||
\details Decodes an interrupt priority value with a given priority group to
|
||||
preemptive priority value and subpriority value.
|
||||
In case of a conflict between priority grouping and available
|
||||
priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set.
|
||||
\param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority().
|
||||
\param [in] PriorityGroup Used priority group.
|
||||
\param [out] pPreemptPriority Preemptive priority value (starting from 0).
|
||||
\param [out] pSubPriority Subpriority value (starting from 0).
|
||||
*/
|
||||
__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority)
|
||||
{
|
||||
uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */
|
||||
uint32_t PreemptPriorityBits;
|
||||
uint32_t SubPriorityBits;
|
||||
|
||||
PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp);
|
||||
SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS));
|
||||
|
||||
*pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL);
|
||||
*pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\brief Set Interrupt Vector
|
||||
\details Sets an interrupt vector in SRAM based interrupt vector table.
|
||||
The interrupt number can be positive to specify a device specific interrupt,
|
||||
or negative to specify a processor exception.
|
||||
Address 0 must be mapped to SRAM.
|
||||
\param [in] IRQn Interrupt number
|
||||
\param [in] vector Address of interrupt handler function
|
||||
*/
|
||||
__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector)
|
||||
{
|
||||
uint32_t *vectors = (uint32_t *)0x0U;
|
||||
vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Get Interrupt Vector
|
||||
\details Reads an interrupt vector from interrupt vector table.
|
||||
The interrupt number can be positive to specify a device specific interrupt,
|
||||
or negative to specify a processor exception.
|
||||
\param [in] IRQn Interrupt number.
|
||||
\return Address of interrupt handler function
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn)
|
||||
{
|
||||
uint32_t *vectors = (uint32_t *)0x0U;
|
||||
return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief System Reset
|
||||
\details Initiates a system reset request to reset the MCU.
|
||||
*/
|
||||
__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void)
|
||||
{
|
||||
__DSB(); /* Ensure all outstanding memory accesses included
|
||||
buffered write are completed before reset */
|
||||
SCB->AIRCR = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) |
|
||||
SCB_AIRCR_SYSRESETREQ_Msk);
|
||||
__DSB(); /* Ensure completion of memory access */
|
||||
|
||||
for(;;) /* wait until reset */
|
||||
{
|
||||
__NOP();
|
||||
}
|
||||
}
|
||||
|
||||
/*@} end of CMSIS_Core_NVICFunctions */
|
||||
|
||||
|
||||
/* ########################## FPU functions #################################### */
|
||||
/**
|
||||
\ingroup CMSIS_Core_FunctionInterface
|
||||
\defgroup CMSIS_Core_FpuFunctions FPU Functions
|
||||
\brief Function that provides FPU type.
|
||||
@{
|
||||
*/
|
||||
|
||||
/**
|
||||
\brief get FPU type
|
||||
\details returns the FPU type
|
||||
\returns
|
||||
- \b 0: No FPU
|
||||
- \b 1: Single precision FPU
|
||||
- \b 2: Double + Single precision FPU
|
||||
*/
|
||||
__STATIC_INLINE uint32_t SCB_GetFPUType(void)
|
||||
{
|
||||
return 0U; /* No FPU */
|
||||
}
|
||||
|
||||
|
||||
/*@} end of CMSIS_Core_FpuFunctions */
|
||||
|
||||
|
||||
|
||||
/* ################################## SysTick function ############################################ */
|
||||
/**
|
||||
\ingroup CMSIS_Core_FunctionInterface
|
||||
\defgroup CMSIS_Core_SysTickFunctions SysTick Functions
|
||||
\brief Functions that configure the System.
|
||||
@{
|
||||
*/
|
||||
|
||||
#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U)
|
||||
|
||||
/**
|
||||
\brief System Tick Configuration
|
||||
\details Initializes the System Timer and its interrupt, and starts the System Tick Timer.
|
||||
Counter is in free running mode to generate periodic interrupts.
|
||||
\param [in] ticks Number of ticks between two interrupts.
|
||||
\return 0 Function succeeded.
|
||||
\return 1 Function failed.
|
||||
\note When the variable <b>__Vendor_SysTickConfig</b> is set to 1, then the
|
||||
function <b>SysTick_Config</b> is not included. In this case, the file <b><i>device</i>.h</b>
|
||||
must contain a vendor-specific implementation of this function.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks)
|
||||
{
|
||||
if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk)
|
||||
{
|
||||
return (1UL); /* Reload value impossible */
|
||||
}
|
||||
|
||||
SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */
|
||||
NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */
|
||||
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
||||
SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk |
|
||||
SysTick_CTRL_TICKINT_Msk |
|
||||
SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */
|
||||
return (0UL); /* Function successful */
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*@} end of CMSIS_Core_SysTickFunctions */
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __CORE_CM0_H_DEPENDANT */
|
||||
|
||||
#endif /* __CMSIS_GENERIC */
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user