This commit is contained in:
qiyongshuang
2026-08-10 10:47:09 +08:00
parent 804daf39a2
commit dfe5ceea43
150 changed files with 20271 additions and 58 deletions
@@ -0,0 +1,301 @@
<?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="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.2606500741">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.2606500741" moduleId="org.eclipse.cdt.core.settings" name="obj">
<macros/>
<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="${cross_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="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.2606500741" name="obj" parent="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release" postannouncebuildStep="" postbuildStep="" preannouncebuildStep="" prebuildStep="">
<folderInfo id="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.2606500741" name="/" resourcePath="">
<toolChain id="ilg.gnumcueclipse.managedbuild.cross.riscv.toolchain.elf.release.2606500741" name="RISC-V Cross GCC" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.toolchain.elf.release">
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.rvGcc.1171217701" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.rvGcc" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.rvGcc.15" valueType="enumerated"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.base.1900297968" name="Architecture" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.base" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.arch.rv32i" valueType="enumerated"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.multiply.1509705449" name="Multiply extension (RVM)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.multiply" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.atomic.1590833110" name="Atomic extension (RVA)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.atomic" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.fp.1709872289" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.fp" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.isa.fp.none" valueType="enumerated"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.compressed.1038505275" name="Compressed extension (RVC)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.compressed" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.xw.1505432023" name="Extra Compressed extension (RVXW)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.xw" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.b.1896185078" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.b" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.zmmul.724822239" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.zmmul" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.rvv.435767561" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.rvv" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.isa.rvv." valueType="enumerated"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.abi.integer.387605487" name="Integer ABI" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.abi.integer" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.abi.integer.ilp32" valueType="enumerated"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.abi.fp.966196099" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.abi.fp" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.abi.fp.none" valueType="enumerated"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.tune.394563202" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.tune" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.tune.default" valueType="enumerated"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.codemodel.105093140" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.codemodel" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.codemodel.default" valueType="enumerated"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.smalldatalimit.1147643442" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.smalldatalimit" useByScannerDiscovery="false" value="8" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.align.322546450" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.align" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.align.default" valueType="enumerated"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.saverestore.367800619" name="Small prologue/epilogue (-msave-restore)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.saverestore" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.other.1526047739" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.other" useByScannerDiscovery="true" value="" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.level.514997414" name="Optimization Level" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.level" useByScannerDiscovery="true" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.level.size" valueType="enumerated"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.messagelength.1008570639" name="Message length (-fmessage-length=0)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.messagelength" useByScannerDiscovery="true" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.signedchar.467272439" name="'char' is signed (-fsigned-char)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.signedchar" useByScannerDiscovery="true" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.functionsections.2047756949" name="Function sections (-ffunction-sections)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.functionsections" useByScannerDiscovery="true" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.datasections.207613650" name="Data sections (-fdata-sections)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.datasections" useByScannerDiscovery="true" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.nocommon.358586167" name="No common unitialized (-fno-common)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.nocommon" useByScannerDiscovery="true" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.noinlinefunctions.1298414520" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.noinlinefunctions" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.freestanding.213924425" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.freestanding" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.nobuiltin.2007120903" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.nobuiltin" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.spconstant.938841347" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.spconstant" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.PIC.234574726" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.PIC" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.lto.1002322664" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.lto" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.nomoveloopinvariants.1270575343" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.nomoveloopinvariants" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.mrs.highcode.114339272" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.mrs.highcode" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.mrs.asmsoftlib.896763512" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.mrs.asmsoftlib" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.mrs.pipe.1835231981" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.mrs.pipe" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.mrs.caret.2021231049" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.mrs.caret" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.mrs.ccv.2026012911" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.mrs.ccv" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.other.180560481" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.other" useByScannerDiscovery="true" value="" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.syntaxonly.1145714735" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.syntaxonly" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.pedantic.1546854128" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.pedantic" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.pedanticerrors.338820707" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.pedanticerrors" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.nowarn.254465728" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.nowarn" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.unused.1961191588" name="Warn on various unused elements (-Wunused)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.unused" useByScannerDiscovery="true" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.uninitialized.929829166" name="Warn on uninitialized variables (-Wuninitialized)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.uninitialized" useByScannerDiscovery="true" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.allwarn.1168626160" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.allwarn" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.extrawarn.291772487" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.extrawarn" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.missingdeclaration.102344169" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.missingdeclaration" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.conversion.550923640" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.conversion" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.pointerarith.773148082" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.pointerarith" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.padded.1788238782" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.padded" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.shadow.427580978" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.shadow" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.logicalop.1501889551" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.logicalop" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.agreggatereturn.1785504720" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.agreggatereturn" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.floatequal.134298453" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.floatequal" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.toerrors.1117291056" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.toerrors" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.other.1918769559" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.other" useByScannerDiscovery="true" value="" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.level.1204865254" name="Debug level" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.level" useByScannerDiscovery="true" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.level.default" valueType="enumerated"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.format.867779652" name="Debug format" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.format" useByScannerDiscovery="true" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.format.dwarf4" valueType="enumerated"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.prof.2131276390" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.prof" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.gprof.1910159761" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.gprof" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.other.1654431258" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.other" useByScannerDiscovery="true" value="" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.toolchain.name.1218760634" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.toolchain.name" useByScannerDiscovery="false" value="GNU MCU RISC-V GCC" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.prefix.103341323" name="Prefix" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.prefix" useByScannerDiscovery="false" value="riscv32-wch-elf-" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.c.487601824" name="C compiler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.c" useByScannerDiscovery="false" value="gcc" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.cpp.1062130429" name="C++ compiler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.cpp" useByScannerDiscovery="false" value="g++" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.ar.1194282993" name="Archiver" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.ar" useByScannerDiscovery="false" value="ar" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.objcopy.1529355265" name="Hex/Bin converter" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.objcopy" useByScannerDiscovery="false" value="objcopy" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.objdump.1053750745" name="Listing generator" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.objdump" useByScannerDiscovery="false" value="objdump" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.size.1441326233" name="Size command" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.size" useByScannerDiscovery="false" value="size" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.make.550105535" name="Build command" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.make" useByScannerDiscovery="false" value="make" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.rm.719280496" name="Remove command" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.rm" useByScannerDiscovery="false" value="rm" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.toolchain.id.226017994" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.toolchain.id" useByScannerDiscovery="false" value="512258282" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createflash.1311852988" name="Create flash image" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createflash" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createlisting.1983282875" name="Create extended listing" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createlisting" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.printsize.1000761142" name="Print size" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.printsize" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="ilg.gnumcueclipse.managedbuild.cross.riscv.targetPlatform.1944008784" isAbstract="false" osList="all" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.targetPlatform"/>
<builder buildPath="${workspace_loc:/Electric_Hair_Dryer/obj" id="ilg.gnumcueclipse.managedbuild.cross.riscv.builder.1421508906" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" stopOnErr="true" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.builder"/>
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.1244756189" name="GNU RISC-V Cross Assembler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler">
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.usepreprocessor.1692176068" name="Use preprocessor" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.usepreprocessor" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.nostdinc.821897907" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.nostdinc" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.preprocessonly.1205312655" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.preprocessonly" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.defs.181380015" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.defs" useByScannerDiscovery="true" valueType="definedSymbols"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.undefs.1514976831" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.undefs" useByScannerDiscovery="true" valueType="undefDefinedSymbols"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.include.paths.1034038285" name="Include paths (-I)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.include.paths" useByScannerDiscovery="true" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/Startup}&quot;"/>
</option>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.include.systempaths.496720673" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.include.systempaths" useByScannerDiscovery="true" valueType="includePath"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.include.files.1898455566" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.include.files" useByScannerDiscovery="true" valueType="includeFiles"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.otherwarnings.1717778600" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.otherwarnings" useByScannerDiscovery="true" value="" valueType="string"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.flags.1578223870" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.flags" useByScannerDiscovery="false" valueType="stringList"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.asmlisting.1937791148" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.asmlisting" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.savetemps.119863881" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.savetemps" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.verbose.1408057941" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.verbose" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.other.1308239903" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.other" useByScannerDiscovery="false" value="" valueType="string"/>
<inputType id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.input.126366858" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.input"/>
</tool>
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.1731377187" name="GNU RISC-V Cross C Compiler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler">
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.nostdinc.1633344562" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.nostdinc" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.preprocessonly.208069239" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.preprocessonly" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.defs.177116515" name="Defined symbols (-D)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.defs" useByScannerDiscovery="true" valueType="definedSymbols"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.undef.1820512625" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.undef" useByScannerDiscovery="true" valueType="undefDefinedSymbols"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.paths.1567947810" name="Include paths (-I)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.paths" useByScannerDiscovery="true" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/Debug}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/Core}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/User}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/Peripheral/inc}&quot;"/>
</option>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.systempaths.2011720354" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.systempaths" useByScannerDiscovery="true" valueType="includePath"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.files.542153928" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.files" useByScannerDiscovery="true" valueType="includeFiles"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.std.2020844713" name="Language standard" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.std" useByScannerDiscovery="true" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.std.gnu99" valueType="enumerated"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.otheroptimizations.92321033" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.otheroptimizations" useByScannerDiscovery="true" value="" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.warning.missingprototypes.1180998530" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.warning.missingprototypes" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.warning.strictprototypes.684937223" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.warning.strictprototypes" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.warning.badfunctioncast.1090658371" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.warning.badfunctioncast" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.otherwarnings.882361093" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.otherwarnings" useByScannerDiscovery="true" value="" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.asmlisting.1019398219" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.asmlisting" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.savetemps.1858747105" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.savetemps" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.verbose.658438318" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.verbose" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.other.1132663916" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.other" useByScannerDiscovery="true" value="" valueType="string"/>
<inputType id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.input.2036806839" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.input"/>
</tool>
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.compiler.1610882921" name="GNU RISC-V Cross C++ Compiler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.compiler">
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.nostdinc.1306818359" name="Do not search system directories (-nostdinc)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.nostdinc" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.nostdincpp.411115799" name="Do not search system C++ directories (-nostdinc++)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.nostdincpp" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.preprocessonly.704235280" name="Preprocess only (-E)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.preprocessonly" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.defs.256688978" name="Defined symbols (-D)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.defs" useByScannerDiscovery="true" valueType="definedSymbols"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.undef.1769659537" name="Undefined symbols (-U)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.undef" useByScannerDiscovery="true" valueType="undefDefinedSymbols"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.include.paths.1641430352" name="Include paths (-I)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.include.paths" useByScannerDiscovery="true" valueType="includePath"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.include.systempaths.1217742259" name="Include system paths (-isystem)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.include.systempaths" useByScannerDiscovery="true" valueType="includePath"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.include.files.1922780842" name="Include files (-include)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.include.files" useByScannerDiscovery="true" valueType="includeFiles"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.std.426208505" name="Language standard" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.std" useByScannerDiscovery="true" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.std.gnucpp11" valueType="enumerated"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.abiversion.1671052931" name="ABI version" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.abiversion" useByScannerDiscovery="true" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.abiversion.0" valueType="enumerated"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.noexceptions.1891612477" name="Do not use exceptions (-fno-exceptions)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.noexceptions" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.nortti.76308566" name="Do not use RTTI (-fno-rtti)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.nortti" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.nousecxaatexit.390229569" name="Do not use _cxa_atexit() (-fno-use-cxa-atexit)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.nousecxaatexit" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.nothreadsafestatics.1143999424" name="Do not use thread-safe statics (-fno-threadsafe-statics)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.nothreadsafestatics" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.otheroptimizations.1589858535" name="Other optimization flags" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.otheroptimizations" useByScannerDiscovery="true" value="" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.warnabi.1304561076" name="Warn on ABI violations (-Wabi)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.warnabi" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.warning.ctordtorprivacy.534922494" name="Warn on class privacy (-Wctor-dtor-privacy)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.warning.ctordtorprivacy" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.warning.noexcept.1102421587" name="Warn on no-except expressions (-Wnoexcept)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.warning.noexcept" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.warning.nonvirtualdtor.249412631" name="Warn on virtual destructors (-Wnon-virtual-dtor)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.warning.nonvirtualdtor" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.warning.strictnullsentinel.1022346732" name="Warn on uncast NULL (-Wstrict-null-sentinel)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.warning.strictnullsentinel" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.warning.signpromo.1510049602" name="Warn on sign promotion (-Wsign-promo)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.warning.signpromo" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.warneffc.1507924344" name="Warn about Effective C++ violations (-Weffc++)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.warneffc" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.otherwarnings.521572828" name="Other warning flags" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.otherwarnings" useByScannerDiscovery="true" value="" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.asmlisting.842958016" name="Generate assembler listing (-Wa,-adhlns=&quot;$@.lst&quot;)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.asmlisting" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.savetemps.715871177" name="Save temporary files (--save-temps Use with caution!)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.savetemps" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.verbose.974774820" name="Verbose (-v)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.verbose" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.other.1293392631" name="Other compiler flags" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.other" useByScannerDiscovery="true" value="" valueType="string"/>
<inputType id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.compiler.input.1079228323" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.compiler.input"/>
</tool>
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.linker.1620074387" name="GNU RISC-V Cross C Linker" outputPrefix="" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.linker">
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.scriptfile.1390103472" name="Script files (-T)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.scriptfile" useByScannerDiscovery="false" valueType="stringList">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/Ld/Link.ld}&quot;"/>
</option>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.nostart.913830613" name="Do not use standard start files (-nostartfiles)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.nostart" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.nodeflibs.1285997013" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.nodeflibs" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.nostdlibs.179047434" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.nostdlibs" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.gcsections.194760422" name="Remove unused sections (-Xlinker --gc-sections)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.gcsections" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.printgcsections.270824644" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.printgcsections" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.strip.1802601885" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.strip" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.libs.813115939" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.libs" useByScannerDiscovery="false" valueType="libs">
<listOptionValue builtIn="false" value="IQmath_RV32"/>
</option>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.paths.2057340378" name="Library search path (-L)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.paths" useByScannerDiscovery="false" valueType="libPaths">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/User}&quot;"/>
</option>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.flags.1125808200" name="Linker flags (-Xlinker [option])" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.flags" useByScannerDiscovery="false" valueType="stringList"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.otherobjs.16994550" name="Other objects" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.otherobjs" useByScannerDiscovery="false" valueType="userObjs">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/User/libM12023_SV_1.0_COMCoreV1.5_Library.a}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/User/IQmath_RV32.a}&quot;"/>
</option>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.mapfilename.789195953" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.mapfilename" useByScannerDiscovery="false" value="&quot;${BuildArtifactFileBaseName}.map&quot;" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.picolibc.62047318" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.picolibc" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.picolibc.disabled" valueType="enumerated"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.cref.824432654" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.cref" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.printmap.751686263" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.printmap" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.usenewlibnano.239404511" name="Use newlib-nano (--specs=nano.specs)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.usenewlibnano" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.usenewlibnosys.351964161" name="Do not use syscalls (--specs=nosys.specs)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.usenewlibnosys" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.useprintffloat.695795083" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.useprintffloat" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.usescanffloat.1839373535" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.usescanffloat" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.verbose.1444336626" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.verbose" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.printfloat.2044235126" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.printfloat" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.printf.888161142" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.printf" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.iqmath.1390292521" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.iqmath" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.other.1683775650" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.other" useByScannerDiscovery="false" value="" valueType="string"/>
<inputType id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.linker.input.1859223768" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
</tool>
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.linker.1947503520" name="GNU RISC-V Cross C++ Linker" outputPrefix="" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.linker">
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.scriptfile.1751226764" name="Script files (-T)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.scriptfile" useByScannerDiscovery="false" valueType="stringList">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/Ld/Link.ld}&quot;"/>
</option>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.nostart.642896175" name="Do not use standard start files (-nostartfiles)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.nostart" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.nodeflibs.282300763" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.nodeflibs" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.nostdlibs.924960428" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.nostdlibs" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.gcsections.1689063433" name="Remove unused sections (-Xlinker --gc-sections)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.gcsections" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.printgcsections.621524254" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.printgcsections" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.strip.679063538" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.strip" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.libs.579700779" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.libs" useByScannerDiscovery="false" valueType="libs">
<listOptionValue builtIn="false" value="IQmath_RV32"/>
</option>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.paths.1029177148" name="Library search path (-L)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.paths" useByScannerDiscovery="false" valueType="libPaths">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/User}&quot;"/>
</option>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.flags.1251620602" name="Linker flags (-Xlinker [option])" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.flags" useByScannerDiscovery="false" valueType="stringList"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.otherobjs.1493906625" name="Other objects" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.otherobjs" useByScannerDiscovery="false" valueType="userObjs">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/User/libM12023_SV_1.0_COMCoreV1.5_Library.a}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/User/IQmath_RV32.a}&quot;"/>
</option>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.mapfilename.1354773182" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.mapfilename" useByScannerDiscovery="false" value="&quot;${BuildArtifactFileBaseName}.map&quot;" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.picolibc.4345436542" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.picolibc" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.picolibc.disabled" valueType="enumerated"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.cref.1007621036" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.cref" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.printmap.2073713641" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.printmap" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.usenewlibnano.1540675679" name="Use newlib-nano (--specs=nano.specs)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.usenewlibnano" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.usenewlibnosys.561457319" name="Do not use syscalls (--specs=nosys.specs)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.usenewlibnosys" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.useprintffloat.1497004994" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.useprintffloat" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.usescanffloat.881728961" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.usescanffloat" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.verbose.922041698" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.verbose" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.printfloat.476377985" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.printfloat" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.printf.626387227" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.printf" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.iqmath.1441123220" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.iqmath" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.other.1748689212" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.other" useByScannerDiscovery="false" value="" valueType="string"/>
</tool>
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.archiver.1292785366" name="GNU RISC-V Cross Archiver" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.archiver">
<outputType id="cdt.managedbuild.tool.gnu.archiver.output.1527226663" superClass="cdt.managedbuild.tool.gnu.archiver.output" outputPrefix="lib"/>
<option id="gnu.both.lib.option.flags.22122911" superClass="gnu.both.lib.option.flags" useByScannerDiscovery="false" value="-r" valueType="string"/>
</tool>
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.createflash.1801165667" name="GNU RISC-V Cross Create Flash Image" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.createflash">
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.textsection.1097396305" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.textsection" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.datasection.2034511797" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.datasection" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.choice.1726268709" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.choice" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.choice.ihex" valueType="enumerated"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.createalgorithmfile.2643315497" superClass="ilg.gnuarmeclipse.managedbuild.cross.risv.option.createflash.createalgorithmfile" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.othersection.1890795928" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.othersection" useByScannerDiscovery="false" valueType="stringList"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.other.788974495" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.other" useByScannerDiscovery="false" value="" valueType="string"/>
</tool>
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.createlisting.1356766765" name="GNU RISC-V Cross Create Listing" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.createlisting">
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.source.2052761852" name="Display source (--source|-S)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.source" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.allheaders.439659821" name="Display all headers (--all-headers|-x)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.allheaders" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.demangle.67111865" name="Demangle names (--demangle|-C)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.demangle" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.debugging.1623481730" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.debugging" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.disassemble.1859590835" name="Disassemble (--disassemble|-d)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.disassemble" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.fileheaders.160868348" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.fileheaders" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.linenumbers.1549373929" name="Display line numbers (--line-numbers|-l)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.linenumbers" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.reloc.1008747895" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.reloc" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.symbols.577922241" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.symbols" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.wide.1298918921" name="Wide lines (--wide|-w)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.wide" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.other.1560864108" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.other" useByScannerDiscovery="false" value="" valueType="string"/>
</tool>
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.printsize.712424314" name="GNU RISC-V Cross Print Size" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.printsize">
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.printsize.format.1404031980" name="Size format" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.printsize.format" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.printsize.format.berkeley" valueType="enumerated"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.printsize.hex.176087647" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.printsize.hex" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.printsize.totals.380903440" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.printsize.totals" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.printsize.other.1271150877" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.printsize.other" useByScannerDiscovery="false" value="" valueType="string"/>
</tool>
</toolChain>
</folderInfo>
<sourceEntries>
<entry excluding="User/Motor_UsbData.h|User/Motor_UsbData.c|Startup/startup_ch32v20x_D8W.S|Startup/startup_ch32v20x_D8.S" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
</sourceEntries>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
<storageModule moduleId="ilg.gnumcueclipse.managedbuild.packs"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="999.ilg.gnumcueclipse.managedbuild.cross.riscv.target.elf.275846018" name="Executable file" projectType="ilg.gnumcueclipse.managedbuild.cross.riscv.target.elf"/>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<scannerConfigBuildInfo instanceId="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.debug.767917625;ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.debug.767917625.;ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.1375371130;ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.input.1473381709">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.1008047074;ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.1008047074.;ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.1731377187;ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.input.2036806839">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
</cproject>
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<projectDescription>
<name>Electric_Hair_Dryer</name>
<comment/>
<projects/>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments/>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<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>
</natures>
<linkedResources>
<link>
<name>Core</name>
<type>2</type>
<location>PARENT-2-PROJECT_LOC/SRC/Core</location>
</link>
<link>
<name>Debug</name>
<type>2</type>
<location>PARENT-2-PROJECT_LOC/SRC/Debug</location>
</link>
<link>
<name>Ld</name>
<type>2</type>
<location>PARENT-2-PROJECT_LOC/SRC/Ld</location>
</link>
<link>
<name>Peripheral</name>
<type>2</type>
<location>PARENT-2-PROJECT_LOC/SRC/Peripheral</location>
</link>
<link>
<name>Startup</name>
<type>2</type>
<location>PARENT-2-PROJECT_LOC/SRC/Startup</location>
</link>
</linkedResources>
<filteredResources>
<filter>
<name/>
<type>6</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-name-matches-false-false-*.wvproj</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
@@ -0,0 +1,32 @@
Vendor=WCH
Toolchain=RISC-V
Series=CH32V203
RTOS=NoneOS
CalibrateSupport=false
CalibrateCommand=
UIConfigSupport=false
UIConfigCommand=
ExternalFlashSupport=false
MCU=CH32V203RBT6
Link=WCH-Link
PeripheralVersion=1.0
Description=ROM(byte): 64K, SRAM(byte): 20K, CHIP PINS: 32, GPIO PORTS: 27.\nWCH CH32V2 series of mainstream MCUs covers the needs of a large variety of applications in the industrial,medical and consumer markets. High performance with first-class peripherals and low-power,low-voltage operation is paired with a high level of integration at accessible prices with a simple architecture and easy-to-use tools.
TempratureScope=
ArtifactType=executable
Mcu Type=CH32V20x
Address=0x08000000
Target Path=obj/Electric_Hair_Dryer.hex
Exe Path=
Exe Arguments=
CLKSpeed=1
DebugInterfaceMode=0
Erase All=true
Program=true
Verify=true
Reset=true
SDIPrintf=false
Disable Power Output=false
Clear CodeFlash=false
Disable Code-Protect=false
Flash Type=
Algorithm File=
@@ -0,0 +1,458 @@
{
"version": "1.0",
"hasAllParsed": true,
"isNormalMRSProject": true,
"basic": {
"chipInfo": {
"vendor": "WCH",
"toolchain": "RISC-V",
"series": "CH32V203",
"rtos": "NoneOS",
"mcu": "CH32V203RBT6",
"description": "ROM(byte): 64K, SRAM(byte): 20K, CHIP PINS: 32, GPIO PORTS: 27.\\nWCH CH32V2 series of mainstream MCUs covers the needs of a large variety of applications in the industrial,medical and consumer markets. High performance with first-class peripherals and low-power,low-voltage operation is paired with a high level of integration at accessible prices with a simple architecture and easy-to-use tools.",
"tempratureScope": "",
"artifactType": "executable",
"link": "WCH-Link",
"peripheral_version": "1.0",
"calibrateSupport": false,
"calibrateCommand": "",
"UIConfigSupport": false,
"UIConfigCommand": "",
"externalFlashSupport": false
},
"linkedFolders": [
{
"name": "Core",
"location": "../../SRC/Core"
},
{
"name": "Debug",
"location": "../../SRC/Debug"
},
{
"name": "Ld",
"location": "../../SRC/Ld"
},
{
"name": "Peripheral",
"location": "../../SRC/Peripheral"
},
{
"name": "Startup",
"location": "../../SRC/Startup"
}
],
"removedResources": [
{
"parentLogicPath": "",
"type": "file",
"name": "*.wvproj"
}
],
"projectName": "Electric_Hair_Dryer",
"architecture": "RISC-V",
"projectType": "c"
},
"buildConfig": {
"configurations": [
{
"buildArtifact": {
"artifact_name": "${ProjName}",
"artifact_extension": "elf",
"output_prefix": "",
"artifact_type": "Executable"
},
"parallelizationNumber": "optimal",
"stop_on_first_build_error": true,
"pre_script": "",
"pre_script_description": "",
"post_script": "",
"post_script_description": "",
"excludeResources": [
"${project}/User/Motor_UsbData.h",
"${project}/User/Motor_UsbData.c",
"${project}/Startup/startup_ch32v20x_D8W.S",
"${project}/Startup/startup_ch32v20x_D8.S"
],
"optimization": {
"level": "size",
"message_length": true,
"char_is_signed": true,
"function_sections": true,
"data_sections": true,
"no_common_unitialized": true,
"do_not_inline_functions": false,
"assume_freestanding_environment": false,
"disable_builtin": false,
"single_precision_constants": false,
"position_independent_code": false,
"link_time_optimizer": false,
"disable_loop_invariant_move": false,
"optimize_unused_sections_declared_as_high_code": false,
"code_generation_without_hardware_floating": false,
"use_pipelines": false,
"show_caret_indicating_the_column": false,
"calling_convention_variant": false,
"other_optimization_flags": ""
},
"warnings": {
"check_syntax_only": false,
"pedantic": false,
"pedantic_warnings_as_errors": false,
"inhibit_all_warnings": false,
"warn_on_various_unused_elements": true,
"warn_on_uninitialized_variables": true,
"enable_all_common_warnings": false,
"enable_extra_warnings": false,
"warn_on_undeclared_global_function": false,
"warn_on_implicit_conversions": false,
"warn_if_pointer_arthmetic": false,
"warn_if_padding_is_included": false,
"warn_if_shadowed_variable": false,
"warn_if_suspicious_logical_ops": false,
"warn_if_struct_is_returned": false,
"warn_if_floats_are_compared_as_equal": false,
"generate_errors_instead_of_warnings": false,
"other_warning_flags": ""
},
"debugging": {
"debug_level": "default",
"debug_format": "dwarf4",
"generate_prof_information": false,
"generate_gprof_information": false,
"other_debugging_flags": ""
},
"assembler": {
"preprocessor": {
"use_preprocessor": true,
"do_not_search_system_directories": false,
"preprocess_only": false,
"defined_symbols": [],
"undefined_symbols": []
},
"includes": {
"include_paths": [
"${project}/Startup"
],
"include_system_paths": [],
"include_files": []
},
"other_warning_flags": "",
"miscellaneous": {
"assembler_flags": [],
"generate_assembler_listing": false,
"save_temporary_files": false,
"verbose": false,
"other_assembler_flags": ""
}
},
"ccompiler": {
"preprocessor": {
"do_not_search_system_directories": false,
"preprocess_only": false,
"defined_symbols": [],
"undefined_symbols": []
},
"includes": {
"include_paths": [
"${project}/Debug",
"${project}/Core",
"${project}/User",
"${project}/Peripheral/inc"
],
"include_system_paths": [],
"include_files": []
},
"optimization": {
"language_standard": "gnu99",
"other_optimization_flags": ""
},
"warnings": {
"warn_if_a_global_function_has_no_prototype": false,
"warn_if_a_function_has_no_arg_type": false,
"warn_if_wrong_cast": false,
"other_warning_flags": ""
},
"miscellaneous": {
"generate_assembler_listing": false,
"save_temporary_files": false,
"verbose": false,
"other_compiler_flags": ""
}
},
"cppcompiler": {
"preprocessor": {
"do_not_search_system_directories": false,
"do_not_search_system_cpp_directories": false,
"preprocess_only": false,
"defined_symbols": [],
"undefined_symbols": []
},
"includes": {
"include_paths": [],
"include_system_paths": [],
"include_files": []
},
"optimization": {
"cpp_language_standard": "gnucpp11",
"abi_version": "0",
"do_not_use_exceptions": false,
"do_not_use_rtti": false,
"do_not_use__cxa_atexit": false,
"do_not_use_thread_safe_statics": false,
"other_optimization_flags": ""
},
"warnings": {
"warn_on_abi_violations": false,
"warn_on_class_privacy": false,
"warn_on_no_except_expressions": false,
"warn_on_virtual_destructors": false,
"warn_on_uncast_null": false,
"warn_on_sign_promotion": false,
"warn_about_effictive_cpp_violcations": false,
"other_warning_flags": ""
},
"miscellaneous": {
"generate_assembler_listing": false,
"save_temporary_files": false,
"verbose": false,
"other_compiler_flags": ""
}
},
"clinker": {
"general": {
"scriptFiles": [
"${project}/Ld/Link.ld"
],
"do_not_use_standard_start_files": true,
"do_not_use_default_libraries": false,
"no_startup_or_default_libs": false,
"remove_unused_sections": true,
"print_removed_sections": false,
"omit_all_symbol_information": false
},
"libraries": {
"libraries": [
"IQmath_RV32"
],
"library_search_path": [
"${project}/User"
]
},
"miscellaneous": {
"picolibc": "disabled",
"linker_flags": [],
"other_objects": [
"${project}/User/libM12023_SV_1.0_COMCoreV1.5_Library.a",
"${project}/User/IQmath_RV32.a"
],
"generate_map": "\"${BuildArtifactFileBaseName}.map\"",
"cross_reference": false,
"print_link_map": false,
"use_newlib_nano": true,
"use_float_with_nano_printf": false,
"use_float_with_nano_scanf": false,
"do_not_use_syscalls": true,
"verbose": false,
"use_wch_printffloat": false,
"use_wch_printf": false,
"use_iqmath": false,
"other_linker_flags": ""
}
},
"cpplinker": {
"general": {
"scriptFiles": [
"${project}/Ld/Link.ld"
],
"do_not_use_standard_start_files": true,
"do_not_use_default_libraries": false,
"no_startup_or_default_libs": false,
"remove_unused_sections": true,
"print_removed_sections": false,
"omit_all_symbol_information": false
},
"libraries": {
"libraries": [
"IQmath_RV32"
],
"library_search_path": [
"${project}/User"
]
},
"miscellaneous": {
"picolibc": "disabled",
"linker_flags": [],
"other_objects": [
"${project}/User/libM12023_SV_1.0_COMCoreV1.5_Library.a",
"${project}/User/IQmath_RV32.a"
],
"generate_map": "\"${BuildArtifactFileBaseName}.map\"",
"cross_reference": false,
"print_link_map": false,
"use_newlib_nano": true,
"use_float_with_nano_printf": false,
"use_float_with_nano_scanf": false,
"do_not_use_syscalls": true,
"verbose": false,
"use_wch_printffloat": false,
"use_wch_printf": false,
"use_iqmath": false,
"other_linker_flags": ""
}
},
"archiver": {
"archiver_flags": "-r",
"libOutputPrefix": "lib"
},
"createFlash": {
"enabled": true,
"outputFileFormat": "ihex",
"copy_only_section_text": false,
"copy_only_section_data": false,
"copy_only_sections": [],
"create_algorithm_file": false,
"other_flags": ""
},
"createList": {
"enabled": true,
"display_source": false,
"display_all_headers": true,
"demangle_names": true,
"display_debug_info": false,
"disassemble": true,
"display_file_headers": false,
"display_line_numbers": false,
"display_relocation_info": false,
"display_symbols": false,
"wide_lines": false,
"other_flags": ""
},
"printSize": {
"enabled": true,
"size_format": "berkeley",
"hex": false,
"show_totals": false,
"other_flags": ""
},
"configVariables": [],
"riscvTargetProcessor": {
"architecture": "rv32i",
"multiply_extension": true,
"atomic_extension": true,
"floating_point": "none",
"compressed_extension": true,
"extra_compressed_extension": true,
"bit_extension": false,
"multiplication_subset_of_the_M_extension": false,
"vector_cryptography_extensions": "",
"integer_ABI": "ilp32",
"floating_point_ABI": "none",
"tuning": "default",
"code_model": "default",
"small_data_limit": 8,
"align": "default",
"save_restore": true,
"other_target_flags": ""
},
"component_toolchain": "${WCH:Toolchain:GCC15}",
"name": "obj"
}
]
},
"flashConfig": {
"mcutype": "CH32V20x",
"address": "0x08000000",
"target_path": "obj/Electric_Hair_Dryer.hex",
"clkSpeed": "High",
"debug_interface_mode": "",
"erase": true,
"program": true,
"verify": true,
"reset": true,
"sdiPrintf": false,
"disablepowerout": false,
"clearcodeflash": false,
"disablecodeprotect": false,
"flashType": "",
"asmFile_path": "",
"exepath": "",
"exearguments": ""
},
"debugConfigurations": {
"openOCDCfg": {
"useLocalOpenOCD": true,
"executable": "${WCH:OpenOCD:default}",
"gdbport": 3333,
"telnetport": 4444,
"tclport": 6666,
"configOptions": [
"-f \"${WCH:OpenOCD:default}/bin/wch-riscv.cfg\""
],
"host": "127.0.0.1",
"port": 3333,
"skipDownloadBeforeDebug": false,
"enablePageEraser": false,
"enableNoZeroWaitingAreaFlash": false
},
"gdbCfg": {
"executable": "${WCH:Toolchain:GCC15}",
"options": [],
"commands": [
"set mem inaccessible-by-default off",
"set architecture riscv:rv32",
"set remotetimeout unlimited",
"set disassembler-options xw"
]
},
"startup": {
"initCommands": {
"initReset": true,
"initResetType": "init",
"additionalCommands": [],
"armSemihosting": false,
"armSemihosting_old": false
},
"loadedFiles": {
"loadSymbols": true,
"useProjBinaryForSymbols": true,
"useFileForSymbols": false,
"symbolFile": "",
"symbolFileOffset": "",
"loadImage": true,
"useProjBinaryForImage": true,
"useFileForImage": false,
"executableFile": "",
"executableFileOffset": ""
},
"runCommands": {
"runReset": true,
"runResetType": "halt",
"additionalCommands": [],
"setBreakAt": "handle_reset",
"continue": true,
"setBreak": true,
"setProgramCounter": false,
"setProgramCounterAddress": ""
},
"debugInRAM": false
},
"svdpath": "${WCH:SDK:default}/RISC-V/CH32V203/NoneOS/CH32V203xx.svd",
"output": {
"showDebugGDBTrace": true,
"saveDebugOutputToFile": false,
"showDebugOutputTimestamps": true
},
"reserve": {
"PROGRAM_NAME": "obj/Electric_Hair_Dryer.elf",
"PROJECT_ATTR": "Electric_Hair_Dryer",
"PROJECT_BUILD_CONFIG_AUTO_ATTR": true,
"PROJECT_BUILD_CONFIG_ID_ATTR": "",
"ATTR_BUILD_BEFORE_LAUNCH_ATTR": 2,
"GdbServerAllocateConsole": true,
"GdbServerAllocateTelnetConsole": false,
"StartGdbCLient": true,
"UPDATE_THREADLIST_ON_SUSPEND": false
}
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,79 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : M0_Control_Configure.h
* Author : WCH
* Version : V1.0.0
* Date : 2026/04/23
* Description : Function selection and configuration.
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#ifndef __M0_CONTROL_CONFIGURE_H
#define __M0_CONTROL_CONFIGURE_H
#define OBSERVER_ADAPTOR
//#define POSICOM
#define IF_VIBRATION_COM
//#define SIX_SECTOR_POSITION
#define TWELVE_SECTOR_POSITION
#define SPEED_RECOVERKEY
#if defined SPEED_RECOVERKEY
#define POWERON_START
//#define KEY_START
#endif
#define ZEROCROSSOVER_TR
//#define ZEROCROSSOVER_OC
//电压限幅表选择,共8种配置:100,098,096,094,092,090,088,086
//#define MAG100_TABLE_USED
//#define MAG098_TABLE_USED
//#define MAG096_TABLE_USED
//#define MAG094_TABLE_USED
#define MAG092_TABLE_USED
//#define MAG090_TABLE_USED
//#define MAG088_TABLE_USED
//#define MAG086_TABLE_USED
#if ( (!defined(MAG100_TABLE_USED))&&(!defined(MAG098_TABLE_USED))&&\
(!defined(MAG096_TABLE_USED))&&(!defined(MAG094_TABLE_USED))\
&&(!defined(MAG092_TABLE_USED))&&(!defined(MAG090_TABLE_USED))\
&&(!defined(MAG088_TABLE_USED))&&(!defined(MAG086_TABLE_USED)))
#error "Invalid configuration: No voltage limit selected"
#endif
#if ( (!defined(SIX_SECTOR_POSITION))&&(!defined(TWELVE_SECTOR_POSITION)))
#error "Invalid configuration: No HFVQI configure"
#endif
#if ( (defined(SIX_SECTOR_POSITION))&&(defined(TWELVE_SECTOR_POSITION)))
#error "Invalid configuration: Duplicate HFVQI configure"
#endif
#if defined SPEED_RECOVERKEY
#if ((defined(POWERON_START))&&(defined(KEY_START)))
#error "Invalid configuration: Duplicate Startmode configure"
#endif
#if ((!defined(POWERON_START))&&(!defined(KEY_START)))
#error "Invalid configuration: No Startmode configure"
#endif
#endif
#if ((!defined(ZEROCROSSOVER_TR))&&(!defined(ZEROCROSSOVER_OC)))
#error "Invalid configuration: No ZeroCrossmode configure"
#endif
/* Exported variables -------------------------------------------------------*/
/* Exported macro -----------------------------------------------------------*/
/* Exported functions ------------------------------------------------------ */
#endif
@@ -0,0 +1,36 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : M0_Control_Library.h
* Author : WCH
* Version : V1.0.0
* Date : 2026/04/23
* Description : Project header file processing.
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#ifndef __M0_CONTROL_LIBRAYR_H
#define __M0_CONTROL_LIBRAYR_H
#include "ch32v20x.h"
#include "ch32v20x_opa.h"
#include "debug.h"
#include "M0_type_and_Constant.h"
#include "M0_Control_Configure.h"
#include "M1_Motor_Parameter.h"
#include "M2_PID_Parameter.h"
#include "M3_LBG_Observer_Parameter.h"
#include "M4_SVPWM_ADC1R.h"
#include "M5_Operation_and_Display.h"
#include "M5_MotorStart.h"
#include "M6_SpeedLoop.h"
#include "M6_CurrentLoop.h"
#include "M7_Interrupt.h"
#include "M8_Protection.h"
#include "M9_Appication_Blocks.h"
#include "MA_HFVQI_Parameter.h"
#include <MB_Operation_Flash.h>
#include "Motor_SPI_USART_MonitorData.h"
#endif
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,61 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : M1_Motor_Parameter.h
* Author : WCH
* Version : V1.0.0
* Date : 2026/04/23
* Description : Definition of motor parameters file.
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#ifndef __M1_MOTOR_PARAMETER_H
#define __M1_MOTOR_PARAMETER_H
#define RATED_FREQ_M 1833
#define RATED_VOLT_M _IQ18(220)
#define RATED_CURR_M _IQ18(1)
#define POLEPARE_M 1
#define ROTOR_FLUX_M _IQ(0.00930)
#define STATOR_RES_M _IQ(25.24)
#define STATOR_LD_M _IQ(0.0019301)
#define STATOR_LQ_M _IQ(0.0054236)
#define INERTIA_M _IQ(0.00002)
#define FRICTION_M _IQ(0.0001)
#define STATOR_RES_TOTAL_M (STATOR_RES_M + _IQ(2.0))
#define IDQLPF_CF_HIGH_M 600
#define IDQLPF_CF_LOW_M 200
#define IDQLPF_PERIOD_M LBG_CAL_PERIOD_M
#define IDQLPF_WcT_HIGH_M _IQmpyI32(_IQmpy(IDQLPF_PERIOD_M,PI_2_Q24),IDQLPF_CF_HIGH_M)
#define IDQLPF_WcT_LOW_M _IQmpyI32(_IQmpy(IDQLPF_PERIOD_M,PI_2_Q24),IDQLPF_CF_LOW_M)
#define IDQLPF_CF_OBSERVER_M 1200
#define IDQLPF_PERIOD_OBSERVER_M LBG_CAL_PERIOD_M
#define IDQLPF_WcT_OBSERVER_M _IQmpyI32(_IQmpy(IDQLPF_PERIOD_OBSERVER_M,PI_2_Q24),IDQLPF_CF_OBSERVER_M)
#define IDQLPF_CF_INITIAL_M 200
#define IDQLPF_PERIOD_INITIAL_M LBG_CAL_PERIOD_M
#define IDQLPF_WcT_INITIAL_M _IQmpyI32(_IQmpy(IDQLPF_PERIOD_INITIAL_M,PI_2_Q24),IDQLPF_CF_INITIAL_M)
/* Exported variables -------------------------------------------------------*/
extern Motor_Sructure_Type MStruc_M;
extern Motor_Base_Type MBase_M;
extern Runningstatus_Type RunningStatus_M;
extern volatile uint16_t System_Status_Global;
/* Exported macro -----------------------------------------------------------*/
/* Exported functions -------------------------------------------------------*/
void Motor_Prameter_Define(Motor_Base_Type *Basestruc);
void Motor_Status_Initial_M(Motor_Sructure_Type *MStruc);
void Global_Status_Initial(void);
void Motor_FilerPara_Cal_M(Motor_Sructure_Type *MStruc);
void Motor_BaseCal_M(Motor_Base_Type *Basestruc);
#endif
@@ -0,0 +1,149 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : M1_Motor_Parameter_Init.h
* Author : WCH
* Version : V1.0.0
* Date : 2026/04/23
* Description : Motor parameters and state initialization.
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#include "M0_Control_Library.h"
Motor_Sructure_Type MStruc_M;
Motor_Base_Type MBase_M;
Runningstatus_Type RunningStatus_M;
volatile uint16_t System_Status_Global;
/******************************************************************************
* Function Name : Motor_Prameter_Define
* Description : Motor Prameter Define
* Input : Pointer to motor base value parameter structure
* Output : None
* Return : None
******************************************************************************/
void Motor_Prameter_Define(Motor_Base_Type *Basestruc)
{
Basestruc->Fn = RATED_FREQ_M;
Basestruc->Vn = RATED_VOLT_M;
Basestruc->In = RATED_CURR_M;
Basestruc->Flux = ROTOR_FLUX_M;
Basestruc->Pn = POLEPARE_M;
Basestruc->Rs = STATOR_RES_M;
Basestruc->Ld = STATOR_LD_M;
Basestruc->Lq = STATOR_LQ_M;
Basestruc->Rstotal = STATOR_RES_TOTAL_M;
Basestruc->Inertia = INERTIA_M;
Basestruc->Friction = FRICTION_M;
}
/******************************************************************************
* Function Name : Motor_Status_Initial_M
* Description : Motor Status Initialization
* Input : Pointer to the motor overall status structure
* Output : None
* Return : None
******************************************************************************/
void Motor_Status_Initial_M(Motor_Sructure_Type *MStruc)
{
MStruc->VRef2R.cd = _IQ(0.0);
MStruc->VRef2R.cq = _IQ(0.0);
MStruc->VRef2R.peak = _IQ(0.0);
MStruc->VRef2RC.cd = _IQ(0.0);
MStruc->VRef2RC.cq = _IQ(0.0);
MStruc->VRef2RC.peak = _IQ(0.0);
MStruc->VRef2S.Alpha = _IQ(0.0);
MStruc->VRef2S.Beta = _IQ(0.0);
MStruc->VRef2SC.Alpha = _IQ(0.0);
MStruc->VRef2SC.Beta = _IQ(0.0);
MStruc->CRef2R.cd = _IQ(0.0);
MStruc->CRef2R.cq = _IQ(0.0);
MStruc->CRef2R.peak = _IQ(0.0);
MStruc->C3S.PhaseA = _IQ(0.0);
MStruc->C3S.PhaseB = _IQ(0.0);
MStruc->C3S.PhaseC = _IQ(0.0);
MStruc->C2S.Alpha = _IQ(0.0);
MStruc->C2S.Beta = _IQ(0.0);
MStruc->C2R_H.cd = _IQ(0.0);
MStruc->C2R_H.cq = _IQ(0.0);
MStruc->C2R_L.cd = _IQ(0.0);
MStruc->C2R_L.cq = _IQ(0.0);
MStruc->C2R.cd = _IQ(0.0);
MStruc->C2R.cq = _IQ(0.0);
MStruc->C2R_Obs.cd = _IQ(0.0);
MStruc->C2R_Obs.cq = _IQ(0.0);
MStruc->C2S_Obs.Alpha = _IQ(0.0);
MStruc->C2S_Obs.Beta = _IQ(0.0);
MStruc->IdLPF1stH.Out_Pre = _IQ(0.0);
MStruc->IdLPF1stH.Out_New = _IQ(0.0);
MStruc->IdLPF1stL.Out_Pre = _IQ(0.0);
MStruc->IdLPF1stL.Out_New = _IQ(0.0);
MStruc->IqLPF1stH.Out_Pre = _IQ(0.0);
MStruc->IqLPF1stH.Out_New = _IQ(0.0);
MStruc->IqLPF1stL.Out_Pre = _IQ(0.0);
MStruc->IqLPF1stL.Out_New = _IQ(0.0);
MStruc->IdLPF1stObs.Out_Pre = _IQ(0.0);
MStruc->IdLPF1stObs.Out_New = _IQ(0.0);
MStruc->IqLPF1stObs.Out_Pre = _IQ(0.0);
MStruc->IqLPF1stObs.Out_New = _IQ(0.0);
MStruc->IdLPF1stInj.Out_Pre = _IQ(0.0);
MStruc->IdLPF1stInj.Out_New = _IQ(0.0);
MStruc->IqLPF1stInj.Out_Pre = _IQ(0.0);
MStruc->IqLPF1stInj.Out_New = _IQ(0.0);
}
/******************************************************************************
* Function Name : Global_Status_Initial
* Description : Initialization of system status and motor operation status
* Input : None
* Output : None
* Return : None
******************************************************************************/
void Global_Status_Initial(void)
{
System_Status_Global |= SPEED_CONTROL_M;
System_Status_Global |= FIRST_START_M;
RunningStatus_M = IDLE;
}
/******************************************************************************
* Function Name : Motor_FilerPara_Cal_M
* Description : Motor Phase Filter Parameter Initialization
* Input : Pointer to the motor overall status structure
* Output : None
* Return : None
******************************************************************************/
void Motor_FilerPara_Cal_M(Motor_Sructure_Type *MStruc)
{
MStruc->IdLPF1stH.Input_Coef = _IQdiv(IDQLPF_WcT_HIGH_M,(IDQLPF_WcT_HIGH_M + UNIT_Q24));
MStruc->IdLPF1stH.Output_Coef = _IQdiv(UNIT_Q24,(IDQLPF_WcT_HIGH_M + UNIT_Q24));
MStruc->IdLPF1stL.Input_Coef = _IQdiv(IDQLPF_WcT_LOW_M,(IDQLPF_WcT_LOW_M + UNIT_Q24));
MStruc->IdLPF1stL.Output_Coef = _IQdiv(UNIT_Q24,(IDQLPF_WcT_LOW_M + UNIT_Q24));
MStruc->IqLPF1stH.Input_Coef = _IQdiv(IDQLPF_WcT_HIGH_M,(IDQLPF_WcT_HIGH_M + UNIT_Q24));
MStruc->IqLPF1stH.Output_Coef = _IQdiv(UNIT_Q24,(IDQLPF_WcT_HIGH_M + UNIT_Q24));
MStruc->IqLPF1stL.Input_Coef = _IQdiv(IDQLPF_WcT_LOW_M,(IDQLPF_WcT_LOW_M + UNIT_Q24));
MStruc->IqLPF1stL.Output_Coef = _IQdiv(UNIT_Q24,(IDQLPF_WcT_LOW_M + UNIT_Q24));
MStruc->IdLPF1stObs.Input_Coef = _IQdiv(IDQLPF_WcT_OBSERVER_M,(IDQLPF_WcT_OBSERVER_M + UNIT_Q24));
MStruc->IdLPF1stObs.Output_Coef = _IQdiv(UNIT_Q24,(IDQLPF_WcT_OBSERVER_M + UNIT_Q24));
MStruc->IqLPF1stObs.Input_Coef = _IQdiv(IDQLPF_WcT_OBSERVER_M,(IDQLPF_WcT_OBSERVER_M + UNIT_Q24));
MStruc->IqLPF1stObs.Output_Coef = _IQdiv(UNIT_Q24,(IDQLPF_WcT_OBSERVER_M + UNIT_Q24));
MStruc->IdLPF1stInj.Input_Coef = _IQdiv(IDQLPF_WcT_INITIAL_M,(IDQLPF_WcT_INITIAL_M + UNIT_Q24));
MStruc->IdLPF1stInj.Output_Coef = _IQdiv(UNIT_Q24,(IDQLPF_WcT_INITIAL_M + UNIT_Q24));
MStruc->IqLPF1stInj.Input_Coef = _IQdiv(IDQLPF_WcT_INITIAL_M,(IDQLPF_WcT_INITIAL_M + UNIT_Q24));
MStruc->IqLPF1stInj.Output_Coef = _IQdiv(UNIT_Q24,(IDQLPF_WcT_INITIAL_M + UNIT_Q24));
}
@@ -0,0 +1,96 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : M2_PID_Parameter.h
* Author : WCH
* Version : V1.0.0
* Date : 2026/04/23
* Description : Definition of PID control parameters.
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#ifndef __M2_MOTOR_PID_H
#define __M2_MOTOR_PID_H
#define SPEED_REGULATOR_FREQ_M SPEED_LOOP_CAL_FREQ
#define SPEED_REGULATOR_PERIOD_M (_IQ(1.0)/SPEED_REGULATOR_FREQ_M)
#define SPEED_REGULATOR_KP_M _IQ(0.000006)
#define SPEED_REGULATOR_KI_M _IQ(0.000006)
#define SPEED_REGULATOR_KD_M _IQ(0.0)
#define SPEED_REGULATOR_KPADJ_M _IQ(1.0)
#define SPEED_REGULATOR_KIADJ_M _IQ(1.0)
#define SPEED_REGULATOR_KDADJ_M _IQ(1.0)
#define SPEED_REGULATOR_ULIM_M _IQ(0.8)
#define SPEED_REGULATOR_LLIM_M _IQ(-0.1)
#define SPEED_REGULATOR_DLIM_M _IQ(1.0)
#ifdef MAG100_TABLE_USED
#define MAX_MODULATIONSQUARE _IQ(1.0000)
#define MAX_MODULATION _IQ(1.0000)
#elif defined MAG098_TABLE_USED
#define MAX_MODULATIONSQUARE _IQ(0.9604)
#define MAX_MODULATION _IQ(0.9800)
#elif defined MAG096_TABLE_USED
#define MAX_MODULATIONSQUARE _IQ(0.9216)
#define MAX_MODULATION _IQ(0.9600)
#elif defined MAG094_TABLE_USED
#define MAX_MODULATIONSQUARE _IQ(0.8836)
#define MAX_MODULATION _IQ(0.9400)
#elif defined MAG092_TABLE_USED
#define MAX_MODULATIONSQUARE _IQ(0.8464)
#define MAX_MODULATION _IQ(0.9200)
#elif defined MAG090_TABLE_USED
#define MAX_MODULATIONSQUARE _IQ(0.8100)
#define MAX_MODULATION _IQ(0.9000)
#elif defined MAG088_TABLE_USED
#define MAX_MODULATIONSQUARE _IQ(0.7744)
#define MAX_MODULATION _IQ(0.8800)
#elif defined MAG086_TABLE_USED
#define MAX_MODULATIONSQUARE _IQ(0.7396)
#define MAX_MODULATION _IQ(0.8600)
#endif
#define CURR_REGULATOR_FREQ_M FREQ_SVPWM
#define CURR_REGULATOR_BW_M (uint16_t)(PI_2f * 200)
#define DAXIS_CURR_REGULATOR_KD_M _IQ(0.0)
#define DAXIS_CURR_REGULATOR_KPADJ_M _IQ(5.0)
#define DAXIS_CURR_REGULATOR_KIADJ_M _IQ(1.0)
#define DAXIS_CURR_REGULATOR_KDADJ_M _IQ(1.0)
#define DAXIS_CURR_REGULATOR_ULIM_M _IQ(0.25)
#define DAXIS_CURR_REGULATOR_LLIM_M _IQ(-0.25)
#define DAXIS_CURR_REGULATOR_DLIM_M _IQ(1.0)
#define QAXIS_CURR_REGULATOR_KD_M _IQ(0.0)
#define QAXIS_CURR_REGULATOR_KPADJ_M _IQ(5.0)
#define QAXIS_CURR_REGULATOR_KIADJ_M _IQ(1.0)
#define QAXIS_CURR_REGULATOR_KDADJ_M _IQ(1.0)
#define QAXIS_CURR_REGULATOR_ULIM_M MAX_MODULATION
#define QAXIS_CURR_REGULATOR_LLIM_M (-MAX_MODULATION)
#define QAXIS_CURR_REGULATOR_DLIM_M _IQ(1.0)
#define DAXIS_CURR_REF_INIT1_M _IQ(0.3)
#define DAXIS_CURR_REF_INIT2_M _IQ(0.15)
#define DAXIS_CURR_REF_STEP1_M _IQ(0.0002)
#define DAXIS_CURR_REF_STEP2_M _IQ(0.00002)
#define DAXIS_CURR_WEAK_SPEED_M _IQ(1.5)
/* Exported variables -------------------------------------------------------*/
extern Motor_PID_Type Mpid_M;
extern DCurrProcess_Type DCurrProcess_M;
extern _iq24 Magnitude_table[];
/* Exported macro -----------------------------------------------------------*/
/* Exported functions -------------------------------------------------------*/
void PID_Prameter_Define(Motor_PID_Type * Mpid);
void PID_Output_Init(Motor_PID_Type * Mpid);
void PID_ParaBase_Cal_M(Motor_Base_Type *Basestruc,Motor_PID_Type * Mpid);
void DCurrProcess_Parameter_Define(DCurrProcess_Type * DCurrProcess);
#endif
@@ -0,0 +1,137 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : M2_PID_Parameter_Initl.c
* Author : WCH
* Version : V1.0.0
* Date : 2026/04/23
* Description : PID control structure definition and state initialization.
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#include "M0_Control_Library.h"
Motor_PID_Type Mpid_M;
DCurrProcess_Type DCurrProcess_M;
#ifdef MAG100_TABLE_USED
_iq24 Magnitude_table[256] = MAG100_LIMIT_TABLE;
#elif defined MAG098_TABLE_USED
_iq24 Magnitude_table[256] = MAG098_LIMIT_TABLE;
#elif defined MAG096_TABLE_USED
_iq24 Magnitude_table[256] = MAG096_LIMIT_TABLE;
#elif defined MAG094_TABLE_USED
_iq24 Magnitude_table[256] = MAG094_LIMIT_TABLE;
#elif defined MAG092_TABLE_USED
_iq24 Magnitude_table[256] = MAG092_LIMIT_TABLE;
#elif defined MAG090_TABLE_USED
_iq24 Magnitude_table[256] = MAG090_LIMIT_TABLE;
#elif defined MAG088_TABLE_USED
_iq24 Magnitude_table[256] = MAG088_LIMIT_TABLE;
#elif defined MAG086_TABLE_USED
_iq24 Magnitude_table[256] = MAG086_LIMIT_TABLE;
#endif
/******************************************************************************
* Function Name : PID_Prameter_Define
* Description : Speed regulator and current regulator machine parameter definition
* Input : Pointer to motor PID controller structure
* Output : None
* Return : None
******************************************************************************/
void PID_Prameter_Define (Motor_PID_Type * Mpid)
{
Mpid->Speed.CalFreq = SPEED_LOOP_CAL_FREQ;
Mpid->Speed.CalT = SPEED_REGULATOR_PERIOD_M;
Mpid->Speed.Kpreal= SPEED_REGULATOR_KP_M;
Mpid->Speed.Kireal= SPEED_REGULATOR_KI_M;
Mpid->Speed.Kdreal= SPEED_REGULATOR_KD_M;
Mpid->Speed.Kpadj = SPEED_REGULATOR_KPADJ_M;
Mpid->Speed.Kiadj = SPEED_REGULATOR_KIADJ_M;
Mpid->Speed.Kdadj = SPEED_REGULATOR_KDADJ_M;
if(STARTUP_DIRECTION==1)
{
Mpid->Speed.Upper_Lim = SPEED_REGULATOR_ULIM_M;
Mpid->Speed.Lower_Lim = SPEED_REGULATOR_LLIM_M;
}
else
{
Mpid->Speed.Upper_Lim = -SPEED_REGULATOR_LLIM_M;
Mpid->Speed.Lower_Lim = -SPEED_REGULATOR_ULIM_M;
}
Mpid->Speed.Deltalim = SPEED_REGULATOR_DLIM_M;
Mpid->dCurr.CalFreq= CURR_REGULATOR_FREQ_M;
Mpid->dCurr.CalT= _IQ(1.0)/CURR_REGULATOR_FREQ_M;
Mpid->dCurr.Bw= CURR_REGULATOR_BW_M;
Mpid->dCurr.Kdreal= DAXIS_CURR_REGULATOR_KD_M;
Mpid->dCurr.Kpadj = DAXIS_CURR_REGULATOR_KPADJ_M;
Mpid->dCurr.Kiadj = DAXIS_CURR_REGULATOR_KIADJ_M;
Mpid->dCurr.Kdadj = DAXIS_CURR_REGULATOR_KDADJ_M;
Mpid->dCurr.Upper_Lim = DAXIS_CURR_REGULATOR_ULIM_M;
Mpid->dCurr.Lower_Lim = DAXIS_CURR_REGULATOR_LLIM_M;
Mpid->dCurr.Deltalim = QAXIS_CURR_REGULATOR_DLIM_M;
Mpid->qCurr.CalFreq= CURR_REGULATOR_FREQ_M;
Mpid->qCurr.CalT= _IQ(1.0)/CURR_REGULATOR_FREQ_M;
Mpid->qCurr.Bw= CURR_REGULATOR_BW_M;
Mpid->qCurr.Kdreal= QAXIS_CURR_REGULATOR_KD_M;
Mpid->qCurr.Kpadj = QAXIS_CURR_REGULATOR_KPADJ_M;
Mpid->qCurr.Kiadj = QAXIS_CURR_REGULATOR_KIADJ_M;
Mpid->qCurr.Kdadj = QAXIS_CURR_REGULATOR_KDADJ_M;
Mpid->qCurr.Upper_Lim = QAXIS_CURR_REGULATOR_ULIM_M;
Mpid->qCurr.Lower_Lim = QAXIS_CURR_REGULATOR_LLIM_M;
Mpid->qCurr.Deltalim = QAXIS_CURR_REGULATOR_DLIM_M;
}
/******************************************************************************
* Function Name : PID_Output_Init
* Description : Speed regulator, current regulator output state initialization.
* Input : Pointer to motor PID controller structure
* Output : None
* Return : None
******************************************************************************/
void PID_Output_Init(Motor_PID_Type * Mpid)
{
Mpid->Speed.Err_New= 0;
Mpid->Speed.Err_Prev1= 0;
Mpid->Speed.Err_Prev2= 0;
Mpid->Speed.Output_New = 0;
Mpid->Speed.Output_Prev = 0;
Mpid->Speed.Deltaoutput = 0;
Mpid->Speed.Propotion = 0;
Mpid->Speed.Integer = 0;
Mpid->Speed.Differential = 0;
Mpid->dCurr.Err_New= 0;
Mpid->dCurr.Err_Prev1= 0;
Mpid->dCurr.Err_Prev2= 0;
Mpid->dCurr.Output_New= 0;
Mpid->dCurr.Output_Prev= 0;
Mpid->dCurr.Deltaoutput =0;
Mpid->qCurr.Err_New= 0;
Mpid->qCurr.Err_Prev1= 0;
Mpid->qCurr.Err_Prev2= 0;
Mpid->qCurr.Output_New = 0;
Mpid->qCurr.Output_Prev = 0;
Mpid->qCurr.Deltaoutput = 0;
}
/******************************************************************************
* Function Name : DCurrProcess_Parameter_Define
* Description : Definition of parameters related to d-axis current processing
* Input : d-axis current processing structure
* Output : None
* Return : None
******************************************************************************/
void DCurrProcess_Parameter_Define(DCurrProcess_Type * DCurrProcess)
{
DCurrProcess->Target1 = DAXIS_CURR_REF_INIT1_M;
DCurrProcess->Target2 = DAXIS_CURR_REF_INIT2_M;
DCurrProcess->AdjustStep1 = DAXIS_CURR_REF_STEP1_M;
DCurrProcess->AdjustStep2 = DAXIS_CURR_REF_STEP2_M;
DCurrProcess->Weakpoint = DAXIS_CURR_WEAK_SPEED_M;
}
@@ -0,0 +1,164 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : M3_LBG_Observer_Initial.c
* Author : WCH
* Version : V1.0.0
* Date : 2026/04/23
* Description :
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#include "M0_Control_Library.h"
Motor_LBG_Type MLBG_M;
Observer_Status_Type LBG_Status_M;
_iq24 LBG_SpeedBuffer_M[LBG_SPEED_BUFFERSIZE_M];
/******************************************************************************
* Function Name : LBG_Parameter_Define
* Description : LBG Observer Parameter Definition
* Input : LBG observer structure pointer, LBG observer state structure pointer
* Output : None
* Return : None
******************************************************************************/
void LBG_Parameter_Define (Motor_LBG_Type *MLBG,Observer_Status_Type *LBGStatus)
{
MLBG->Para.CalFreq = LBG_CAL_FREQ_M;
MLBG->Para.CalT = LBG_CAL_PERIOD_M;
MLBG->Para.K1CerrC = LBG_K1_CERROR_CURR_M;
MLBG->Para.K2CerrE = LBG_K2_CERROR_EMF_M;
MLBG->Para.kCE_Adj = LBG_K2_CERROR_EMF_ADJ_M;
MLBG->Para.Caltimes = LBG_CAL_TIMES_M;
MLBG->Cal_Struc.EUlim = LBG_MAX_EMF_M;
MLBG->Cal_Struc.ELlim = LBG_MIN_EMF_M;
MLBG->Cal_Struc.CUlim = LBG_MAX_CURR_M;
MLBG->Cal_Struc.CLlim = LBG_MIN_CURR_M;
MLBG->Cal_Struc.SpeedLPF1st_M.Input_Coef = _IQdiv(LBG_SPEEDLPF_WcT_M,(LBG_SPEEDLPF_WcT_M + UNIT_Q24));
MLBG->Cal_Struc.SpeedLPF1st_M.Output_Coef = _IQdiv(UNIT_Q24,(LBG_SPEEDLPF_WcT_M + UNIT_Q24));
MLBG->Cal_Struc.Posicom_Enable = LBG_POSICOM_ENABLE;
MLBG->Speed_PLL.Kpreal = PLL_KP_M;
MLBG->Speed_PLL.Kireal = PLL_KI_M;
MLBG->Speed_PLL.Upper_Lim = LBG_SPEED_MAX_M;
MLBG->Speed_PLL.Lower_Lim = LBG_SPEED_MIN_M;
MLBG->Adaptor.Enable = LBG_ADAPTOR_ENABLE;
MLBG->Adaptor.Gain = LBG_ADAPTOR_COEF_M;
MLBG->Adaptor.EMF_Adj = LBG_ADAPTOR_EMF_ADJ_M;
MLBG->SpeedBuffPara.Length = LBG_SPEED_BUFFERSIZE_M;
LBGStatus->OverspeedThresh = LBG_OVERSPEED_THRESH_M;
LBGStatus->OverspeedcntThresh = LBG_OVERSPEED_CNT_THRESH_M;
LBGStatus->UnderspeedThresh = LBG_UNDERSPEED_THRESH_M;
LBGStatus->UnderspeedcntThresh = LBG_UNDERSPEED_CNT_THRESH_M;
LBGStatus->VarianceThresh = LBG_SPEED_VARIANCE_THRESH_M;
LBGStatus->UnstableCntThresh = LBG_UNSTABLE_CNT_THRESH_M;
LBGStatus->UnstableSpeedThresh = LBG_UNSTABLE_SPEED_THRESH_M;
LBGStatus->ConvergeCntThresh = LBG_CONVERGED_CNT_THRESH_M;
LBGStatus->ConvergeUpper = LBG_CONVERGED_UPPER_THRESH_M;
LBGStatus->ConvergeLower = LBG_CONVERGED_LOWER_THRESH_M;
LBGStatus->ConvergeEmfBandup = LBG_CONVERGED_EMFUP_THRESH_M;
LBGStatus->ConvergeEmfBanddown = LBG_CONVERGED_EMFDOWN_THRESH_M;
LBGStatus->StallSpeedBand = LBG_STALLBAND_M;
LBGStatus->StallSpeed = LBG_STALLSPEED_M;
LBGStatus->StallCurr = LBG_STALLCURR_M;
LBGStatus->StallCntThresh = LBG_STALL_CNT_THRESH_M;
LBGStatus->ReverseCntThresh = LBG_REVERSE_CNT_THRESH_M;
LBGStatus->ReverseSpeedThresh = LBG_REVERSE_SPEED_THRESH_M;
MLBG->Cal_Struc.EMFLPF1st_M.Input_Coef = _IQdiv(LBG_EMFLPF_WcT_M,(LBG_EMFLPF_WcT_M + UNIT_Q24));
MLBG->Cal_Struc.EMFLPF1st_M.Output_Coef = _IQdiv(UNIT_Q24,(LBG_EMFLPF_WcT_M + UNIT_Q24));
}
/******************************************************************************
* Function Name : LBG_Status_Init
* Description : LBG Observer State Initialization
* Input : LBG observer structure pointer, LBG observer state structure pointer
* Output : None
* Return : None
******************************************************************************/
void LBG_Status_Init (Motor_LBG_Type *MLBG,Observer_Status_Type *LBGStatus)
{
MLBG->Cal_Struc.Inimark = FALSE;
MLBG->Cal_Struc.EalphaNew = _IQ(0.0);
MLBG->Cal_Struc.EalphaPrev = _IQ(0.0);
MLBG->Cal_Struc.EbetaNew = _IQ(0.0);
MLBG->Cal_Struc.EbetaPrev = _IQ(0.0);
MLBG->Cal_Struc.CalphaNew = _IQ(0.0);
MLBG->Cal_Struc.CalphaPrev = _IQ(0.0);
MLBG->Cal_Struc.CbetaNew = _IQ(0.0);
MLBG->Cal_Struc.CbetaPrev = _IQ(0.0);
MLBG->Cal_Struc.ThetaErr = _IQ(0.0);
MLBG->Cal_Struc.PosiElecPU = _IQ(0.0);
MLBG->Cal_Struc.PosiElecPU_Pre = _IQ(0.0);
MLBG->Cal_Struc.PosiElecPU_Cali = _IQ(0.0);
MLBG->Cal_Struc.PosiElecPU_Com = _IQ(0.0);
MLBG->Cal_Struc.Angspeed_Inst = _IQ(0.0);
MLBG->Cal_Struc.Angspeed_Aver1 = _IQ(0.0);
MLBG->Cal_Struc.Angspeed_Aver2 = _IQ(0.0);
MLBG->Cal_Struc.Triangle.Cos = _IQ(0.0);
MLBG->Cal_Struc.Triangle.Sin = _IQ(0.0);
MLBG->Cal_Struc.Obs_Calcnt =0;
LBGStatus->Overspeed = FALSE;
LBGStatus->Underspeed = FALSE;
LBGStatus->Reliable = FALSE;
LBGStatus->Convergence = FALSE;
LBGStatus->Timeout = FALSE;
LBGStatus->Stable = TRUE;
LBGStatus->Stall = FALSE;
LBGStatus->Reverse = FALSE;
LBGStatus->Overspeed_CNT =0;
LBGStatus->Underspeed_CNT = 0;
LBGStatus->Converged_CNT = 0;
LBGStatus->Unstable_CNT = 0;
LBGStatus->Stall_CNT = 0;
LBGStatus->Reverse_CNT = 0;
MLBG->Speed_PLL.Error_New = _IQ(0.0);
MLBG->Speed_PLL.Error_Prev = _IQ(0.0);
MLBG->Speed_PLL.Output_New = _IQ(0.0);
MLBG->Speed_PLL.Output_Prev = _IQ(0.0);
#if defined OBSERVER_ADAPTOR
MLBG->Adaptor.Alpha_Err = _IQ(0.0);
MLBG->Adaptor.Alpha_Pre = _IQ(0.0);
MLBG->Adaptor.Alpha_New = _IQ(0.0);
MLBG->Adaptor.Beta_Err = _IQ(0.0);
MLBG->Adaptor.Beta_Pre = _IQ(0.0);
MLBG->Adaptor.Beta_New = _IQ(0.0);
#endif
}
/******************************************************************************
* Function Name : LBG_Cal_Init
* Description : LBG Calculation Initialization
* Input : Pointer to motor start control structure,
* pointer to overall motor status structure, pointer to LBG observer structure
* Output : None
* Return : None
******************************************************************************/
void LBG_Cal_Init (InjStart_Type *InjStart,Motor_Sructure_Type *MStruc,Motor_LBG_Type *MLBG)
{
LBG_EMF_CalInitial(MStruc,InjStart,MLBG);
#if defined OBSERVER_ADAPTOR
LBG_Adaptor_CalInitial(MLBG);
#endif
LBG_Speed_CalInitial(MLBG,&(LBG_SpeedBuffer_M[0]),InjStart->RampInjSpeedRef);
}
@@ -0,0 +1,102 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : M3_LBG_Observer_Parameter.h
* Author : WCH
* Version : V1.0.0
* Date : 2026/04/23
* Description :
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#ifndef __M3_LBG_OBSERVER_H
#define __M3_LBG_OBSERVER_H
#define LBG_CAL_FREQ_M FREQ_SVPWM
#define LBG_CAL_PERIOD_M _IQ(1.0)/LBG_CAL_FREQ_M
#define LBG_K1_CERROR_CURR_M (-30000)
#define LBG_K2_CERROR_EMF_M 40000
#define LBG_K2_CERROR_EMF_ADJ_M 20
#define LBG_CAL_TIMES_M 2
#define LBG_MAX_EMF_M _IQ(2.0)
#define LBG_MIN_EMF_M _IQ(-2.0)
#define LBG_MAX_CURR_M _IQ(2.0)
#define LBG_MIN_CURR_M _IQ(-2.0)
#define PLL_KP_M 140
#define PLL_KI_M 25148
#define LBG_SPEED_MAX_M _IQ(1.5)
#define LBG_SPEED_MIN_M _IQ(0.01)
#if defined OBSERVER_ADAPTOR
#define LBG_ADAPTOR_ENABLE 1;
#else
#define LBG_ADAPTOR_ENABLE 0;
#endif
#define LBG_ADAPTOR_COEF_M 8000
#define LBG_ADAPTOR_EMF_ADJ_M _IQ(0.5)
#define LBG_SPEED_BUFFERSIZE_M 96
#if defined POSICOM
#define LBG_POSICOM_ENABLE 1;
#else
#define LBG_POSICOM_ENABLE 0;
#endif
#define LBG_SPEEDLPF_CF_M 50
#define LBG_SPEEDLPF_PERIOD_M (_IQ(1.0)/SPEED_LOOP_CAL_FREQ)
#define LBG_SPEEDLPF_WcT_M _IQmpyI32(_IQmpy(LBG_SPEEDLPF_PERIOD_M,PI_2_Q24),LBG_SPEEDLPF_CF_M)
#define LBG_OVERSPEED_THRESH_M _IQ(1.5)
#define LBG_UNDERSPEED_THRESH_M _IQ(0.05)
#define LBG_OVERSPEED_CNT_THRESH_M 500
#define LBG_UNDERSPEED_CNT_THRESH_M 500
#define LBG_SPEED_VARIANCE_THRESH_M _IQ(0.2)
#define LBG_UNSTABLE_CNT_THRESH_M 300
#define LBG_UNSTABLE_SPEED_THRESH_M _IQ(0.02)
#define LBG_CONVERGED_CNT_THRESH_M 100
#define LBG_CONVERGED_UPPER_THRESH_M _IQ(1.2)
#define LBG_CONVERGED_LOWER_THRESH_M _IQ(0.8)
#define LBG_CONVERGED_EMFUP_THRESH_M _IQ(0.5)
#define LBG_CONVERGED_EMFDOWN_THRESH_M _IQ(-0.2)
#define LBG_EMFLPF_CF_M 50
#define LBG_EMFLPF_PERIOD_M (_IQ(1.0)/SPEED_LOOP_CAL_FREQ)
#define LBG_EMFLPF_WcT_M _IQmpyI32(_IQmpy(LBG_EMFLPF_PERIOD_M,PI_2_Q24),LBG_EMFLPF_CF_M)
#define LBG_STALLBAND_M _IQ(0.5)
#define LBG_STALLSPEED_M _IQ(0.1)
#define LBG_STALLCURR_M _IQMPY_MACRO(_IQ(0.9),SPEED_REGULATOR_ULIM_M)
#define LBG_STALL_CNT_THRESH_M 100
#define LBG_REVERSE_CNT_THRESH_M 100
#define LBG_REVERSE_SPEED_THRESH_M _IQ(0.02)
/* Exported variables -------------------------------------------------------*/
extern Motor_LBG_Type MLBG_M;
extern Observer_Status_Type LBG_Status_M;
extern _iq24 LBG_SpeedBuffer_M[LBG_SPEED_BUFFERSIZE_M];
void LBG_Parameter_Define (Motor_LBG_Type *MLBG,Observer_Status_Type *LBGStatus);
void LBG_Paramter_Cal (Motor_Base_Type *Basestruc,Motor_LBG_Type *MLBG);
void LBG_Status_Init (Motor_LBG_Type *MLBG,Observer_Status_Type *LBGStatus);
void LBG_EMF_CalInitial(Motor_Sructure_Type *MStruc,InjStart_Type * InjStart,Motor_LBG_Type *MLBG);
void LBG_Adaptor_CalInitial(Motor_LBG_Type *MLBG);
void LBG_Speed_CalInitial(Motor_LBG_Type *MLBG,_iq24 *Buffer,_iq24 SpeedInial);
void LBG_EMF_Cal(Motor_Sructure_Type *MStruc,Motor_LBG_Type *MLBG);
void LBG_Speed_Posi_Cal(Motor_LBG_Type *MLBG);
void LBG_Cal_Init (InjStart_Type *InjStart,Motor_Sructure_Type *MStruc,Motor_LBG_Type *MLBG);
#endif
@@ -0,0 +1,659 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : M4_SVPWM_ADC1R.c
* Author : WCH
* Version : V1.0.0
* Date : 2026/04/23
* Description :
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#include "M0_Control_Library.h"
SVPWM_1R_Type SVPWM_Cal_M;
ADCStruc_Type ADC_M;
PWMCali_Type PWMCali_M;
/******************************************************************************
* Function Name : SVPWM_1R_Paramter_Init
* Description : SVPWM Parameter Initialization
* Input : SVPWM calculation structure, PWM correction structure pointer,
* motor base value parameter structure pointer
* Output : None
* Return : None
******************************************************************************/
void SVPWM_1R_Paramter_Init(SVPWM_1R_Type *SVPWM_Cal,PWMCali_Type *PWMCali,Motor_Base_Type *Mbase)
{
SVPWM_Cal->T = ((uint16_t)(TIMER_CLOCK_FREQ_SVPWM/(uint32_t)(FREQ_SVPWM)));
SVPWM_Cal->T_IQ16 = (_IQ16(SVPWM_Cal->T));
SVPWM_Cal->HALF_T = SVPWM_Cal->T/2;
SVPWM_Cal->Quard_T = SVPWM_Cal->T/4;
SVPWM_Cal->BusVolt = _IQ18div(DCBUS_RATED_VOLT,Mbase->Vbase);
SVPWM_Cal->coef1 = _IQ16mpy(_IQ16div(SVPWM_Cal->T_IQ16/2,SVPWM_Cal->BusVolt>>2),Three_Q16);
SVPWM_Cal->coef2 = _IQ16mpy(_IQ16div(SVPWM_Cal->T_IQ16/2,SVPWM_Cal->BusVolt>>2),SQRT3_Q16);
SVPWM_Cal->Maxmodulesqure = MAX_MODULATIONSQUARE;
SVPWM_Cal->Maxmodule = MAX_MODULATION;
PWMCali->Currconverttime = CURR_CONVERT_CLOCK_ADC;
PWMCali->ADCTimeMin = CURR_MAX_TRTN_CLOCK_ADC + DEADTIME_CLOCK_SVPWM + CURR_CONVERT_CLOCK_ADC ;
PWMCali->ADCTimeMinDouble = PWMCali->ADCTimeMin*2;
PWMCali->ADCTimeMinHalf = PWMCali->ADCTimeMin/2;
}
/******************************************************************************
* Function Name : SVPWM_Status_Initial_M
* Description : SVPWM State Initialization
* Input : SVPWM calculation structure, PWM correction structure pointer
* Output : None
* Return : None
******************************************************************************/
void SVPWM_1R_Status_Init_M(SVPWM_1R_Type *SVPWM_Cal,PWMCali_Type *PWMCali)
{
TIM1->CH1CVR = SVPWM_Cal->Quard_T;
TIM1->CH2CVR = SVPWM_Cal->Quard_T;
TIM1->CH3CVR = SVPWM_Cal->Quard_T;
TIM1->CH4CVR = SVPWM_Cal->Quard_T - PWMCali->Currconverttime;
TIM3->CH4CVR = SVPWM_Cal->HALF_T - PWMCali->Currconverttime;
SVPWM_Cal->cc1 = SVPWM_Cal->Quard_T;
SVPWM_Cal->cc2 = SVPWM_Cal->Quard_T;
SVPWM_Cal->cc3 = SVPWM_Cal->Quard_T;
SVPWM_Cal->cc1Load = SVPWM_Cal->Quard_T;
SVPWM_Cal->cc2Load = SVPWM_Cal->Quard_T;
SVPWM_Cal->cc3Load = SVPWM_Cal->Quard_T;
SVPWM_Cal->cc1Loadup = SVPWM_Cal->Quard_T;
SVPWM_Cal->cc2Loadup = SVPWM_Cal->Quard_T;
SVPWM_Cal->cc3Loadup = SVPWM_Cal->Quard_T;
SVPWM_Cal->sector = 1;
SVPWM_Cal->VoltLimMark = 0;
SVPWM_Cal->PWMUcali1 = SVPWM_Cal->Quard_T;
SVPWM_Cal->PWMUcali2 = SVPWM_Cal->Quard_T;
SVPWM_Cal->PWMVcali1 = SVPWM_Cal->Quard_T;
SVPWM_Cal->PWMVcali2 = SVPWM_Cal->Quard_T;
SVPWM_Cal->PWMWcali1 = SVPWM_Cal->Quard_T;
SVPWM_Cal->PWMWcali2 = SVPWM_Cal->Quard_T;
PWMCali->Cali_Buff.Cali1 = SVPWM_Cal->Quard_T;
PWMCali->Cali_Buff.Cali2 = SVPWM_Cal->Quard_T;
PWMCali->Cali_Buff.Cali3 = SVPWM_Cal->Quard_T;
PWMCali->Cali_Buff.Cali4 = SVPWM_Cal->Quard_T;
PWMCali->Cali_Buff.Cali5 = SVPWM_Cal->Quard_T;
PWMCali->Cali_Buff.Cali6 = SVPWM_Cal->Quard_T;
PWMCali->ADC_Trig.Trig1 = SVPWM_Cal->Quard_T - PWMCali->Currconverttime;
PWMCali->ADC_Trig.Trig2 = SVPWM_Cal->HALF_T - PWMCali->Currconverttime;
PWMCali->ADC_Trig.Trig1_limmark = FALSE;
PWMCali->ADC_Trig.Trig2_limmark = FALSE;
PWMCali->DMA_Trig.Trig1 = 1;
PWMCali->DMA_Trig.Trig2 = SVPWM_Cal->HALF_T +1;
PWMCali->DMA_Trig.Trig3 = 1;
PWMCali->DMA_Trig.Trig4 = SVPWM_Cal->HALF_T +1;
PWMCali->DMA_Trig.Trig5 = 1;
PWMCali->DMA_Trig.Trig6 = SVPWM_Cal->HALF_T +1;
TIM2->CH3CVR = PWMCali->DMA_Trig.Trig1;
TIM3->CH3CVR = PWMCali->DMA_Trig.Trig2;
TIM4->CH2CVR = PWMCali->DMA_Trig.Trig3;
TIM2->CH1CVR = PWMCali->DMA_Trig.Trig4;
TIM3->CH1CVR = PWMCali->DMA_Trig.Trig5;
TIM2->CH2CVR = PWMCali->DMA_Trig.Trig6;
PWMCali->CaliMark = 0;
}
/******************************************************************************
* Function Name : ADC_Parameter_Init
* Description : ADC Parameter Calculation
* Input : ADC calculation structure pointer,
* motor base value parameter structure pointer
* Output : None
* Return : None
******************************************************************************/
void ADC_Parameter_Init (ADCStruc_Type *ADCStruc,Motor_Base_Type *Mbase)
{
ADCStruc->RatedCurr_ConvInv = _IQ16mpyIQX(_IQ16div(_IQ16(128),_IQ16(32767)),\
16,_IQ18div(CURR_SAMPLE_RANGE_ADC,Mbase->Ibase),18);
ADCStruc->AdcChannel1 = ADC1_CURR_CHANNEL_PHASE_M;
ADCStruc->AdcChannel2 = ADC2_CURR_CHANNEL_PHASE_M;
ADCStruc->DCVoltRatedADC = _IQ18div(_IQ18mpy(DCVOLT_CONV_RATIO,DCBUS_RATED_VOLT),_IQ18(3.3))*4096;
ADCStruc->DCVoltRatedADCInv =_IQ18div(_IQ18(1.0),ADCStruc->DCVoltRatedADC);
ADCStruc->DCVoltAverSizeInv1 = _IQ(1.0)/DCVOLT_AVER_SIZE;
ADCStruc->DCVoltAverSizeInv2 = _IQ(1.0) - ADCStruc->DCVoltAverSizeInv1;
ADCStruc->VdcLPF1st.Input_Coef = _IQdiv(DCVOLT_LPF_WcT_M,(DCVOLT_LPF_WcT_M + UNIT_Q24));
ADCStruc->VdcLPF1st.Output_Coef = _IQdiv(UNIT_Q24,(DCVOLT_LPF_WcT_M + UNIT_Q24));
ADCStruc->DCVoltPres=0;
ADCStruc->DCVoltAver=0;
ADCStruc->DCVoltcali=0;
ADCStruc->DCVolt_Filter=0;
ADCStruc->VdcLPF1st.Out_New=0;
ADCStruc->VdcLPF1st.Out_Pre=0;
}
/******************************************************************************
* Function Name : ADC_Status_Init
* Description : ADC Status Init
* Input : ADC calculation structure pointer
* Output : None
* Return : None
******************************************************************************/
void ADC_Status_Init (ADCStruc_Type *ADCStruc)
{
ADCStruc->ADC_Result.Value1 = ADC_M.OffsetValue1;
ADCStruc->ADC_Result.Value2 = ADC_M.OffsetValue2;
// ADCStruc->DCVoltPres = DCVOLT_INIT;
// ADCStruc->DCVoltAver = DCVOLT_INIT;
// ADCStruc->DCVolt_Filter = DCVOLT_INIT;
// ADCStruc->DCVoltcali = _IQ(1.0);
//
// ADCStruc->VdcLPF1st.Out_New =0;
// ADCStruc->VdcLPF1st.Out_Pre =0;
}
/******************************************************************************
* Function Name : SVPWM_1R_Timer_Configure
* Description : SVPWM Port and Timer Initialization
* Input : None
* Output : None
* Return : None
******************************************************************************/
void SVPWM_1R_Timer_Configure()
{
TIM_TimeBaseInitTypeDef TIM1_TimeBaseStructure={0};
TIM_TimeBaseInitTypeDef TIM3_TimeBaseInitStructure= {0};
TIM_OCInitTypeDef TIM1_OCInitStructure={0};
TIM_OCInitTypeDef TIM3_OCInitStructure= {0};
TIM_BDTRInitTypeDef TIM_BDTRInitStructure={0};
GPIO_InitTypeDef GPIO_InitStructure={0};
DMA_InitTypeDef DMA1_InitStructure = {0};
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB\
| RCC_APB2Periph_AFIO | RCC_APB2Periph_TIM1, ENABLE);
RCC_APB1PeriphClockCmd( RCC_APB1Periph_TIM2 |RCC_APB1Periph_TIM3\
| RCC_APB1Periph_TIM4, ENABLE );
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
GPIO_StructInit(&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 ;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12|GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_SetBits(GPIOB,GPIO_Pin_12);
TIM_DeInit(TIM1);
TIM_TimeBaseStructInit(&TIM1_TimeBaseStructure);
TIM1_TimeBaseStructure.TIM_Prescaler = TIMER_PRESCALER_SVPWM;
TIM1_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_CenterAligned1;
TIM1_TimeBaseStructure.TIM_Period = SVPWM_Cal_M.HALF_T-1;
TIM1_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;
TIM1_TimeBaseStructure.TIM_RepetitionCounter = TIMER_UPDATE_RATE_SVPWM;
TIM_TimeBaseInit(TIM1, &TIM1_TimeBaseStructure);
TIM_OCStructInit(&TIM1_OCInitStructure);
TIM1_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
TIM1_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
TIM1_OCInitStructure.TIM_OutputNState = TIM_OutputNState_Enable;
//dummy value
TIM1_OCInitStructure.TIM_Pulse = SVPWM_Cal_M.HALF_T/2;
TIM1_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
TIM1_OCInitStructure.TIM_OCNPolarity = TIM_OCNPolarity_High;
//TIM1_OCInitStructure.TIM_OCNPolarity = TIM_OCNPolarity_Low; //SA2603
TIM1_OCInitStructure.TIM_OCIdleState = TIM_OCIdleState_Reset;
TIM1_OCInitStructure.TIM_OCNIdleState = TIM_OCNIdleState_Reset;
TIM_OC1Init(TIM1, &TIM1_OCInitStructure);
TIM_OC2Init(TIM1, &TIM1_OCInitStructure);
TIM_OC3Init(TIM1, &TIM1_OCInitStructure);
TIM_OCStructInit(&TIM1_OCInitStructure);
TIM1_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM2;
TIM1_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
TIM1_OCInitStructure.TIM_OutputNState = TIM_OutputNState_Disable;
TIM1_OCInitStructure.TIM_Pulse = SVPWM_Cal_M.HALF_T - 1;
TIM1_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
TIM1_OCInitStructure.TIM_OCNPolarity =TIM_OCNPolarity_Low;
TIM1_OCInitStructure.TIM_OCIdleState = TIM_OCIdleState_Reset;
TIM1_OCInitStructure.TIM_OCNIdleState = TIM_OCIdleState_Reset;
TIM_OC4Init(TIM1, &TIM1_OCInitStructure);
TIM_OC1PreloadConfig(TIM1, TIM_OCPreload_Disable);
TIM_OC2PreloadConfig(TIM1, TIM_OCPreload_Disable);
TIM_OC3PreloadConfig(TIM1, TIM_OCPreload_Disable);
TIM_OC4PreloadConfig(TIM1, TIM_OCPreload_Enable);
TIM_BDTRInitStructure.TIM_OSSRState = TIM_OSSRState_Enable;
TIM_BDTRInitStructure.TIM_OSSIState = TIM_OSSIState_Enable;
TIM_BDTRInitStructure.TIM_LOCKLevel = TIM_LOCKLevel_1;
TIM_BDTRInitStructure.TIM_DeadTime = DEADTIME_CONFIGURE;
TIM_BDTRInitStructure.TIM_Break = TIM_Break_Enable;
TIM_BDTRInitStructure.TIM_BreakPolarity = TIM_BreakPolarity_Low;
TIM_BDTRInitStructure.TIM_AutomaticOutput = TIM_AutomaticOutput_Disable;
TIM_BDTRConfig(TIM1, &TIM_BDTRInitStructure);
TIM_SetCounter(TIM1,0);
TIM_ClearFlag(TIM1, TIM_FLAG_Update);
TIM_ITConfig(TIM1, TIM_IT_Update, ENABLE);
DMA_DeInit(DMA1_Channel1);
DMA_DeInit(DMA1_Channel2);
DMA_DeInit(DMA1_Channel4);
DMA_DeInit(DMA1_Channel5);
DMA_DeInit(DMA1_Channel6);
DMA_DeInit(DMA1_Channel7);
DMA1_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST;
DMA1_InitStructure.DMA_BufferSize = 1;
DMA1_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA1_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Disable;
DMA1_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word;
DMA1_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
DMA1_InitStructure.DMA_Mode = DMA_Mode_Circular;
DMA1_InitStructure.DMA_Priority = DMA_Priority_VeryHigh;
DMA1_InitStructure.DMA_M2M = DMA_M2M_Disable;
DMA1_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&(TIM1->CH1CVR);
DMA1_InitStructure.DMA_MemoryBaseAddr = (uint32_t)&(PWMCali_M.Cali_Buff.Cali1);
DMA_Init(DMA1_Channel1, &DMA1_InitStructure);
DMA1_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&(TIM1->CH1CVR);
DMA1_InitStructure.DMA_MemoryBaseAddr = (uint32_t)&(PWMCali_M.Cali_Buff.Cali2);
DMA_Init(DMA1_Channel2, &DMA1_InitStructure);
DMA1_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&(TIM1->CH2CVR);
DMA1_InitStructure.DMA_MemoryBaseAddr = (uint32_t)&(PWMCali_M.Cali_Buff.Cali3);
DMA_Init(DMA1_Channel4, &DMA1_InitStructure);
DMA1_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&(TIM1->CH2CVR);
DMA1_InitStructure.DMA_MemoryBaseAddr = (uint32_t)&(PWMCali_M.Cali_Buff.Cali4);
DMA_Init(DMA1_Channel5, &DMA1_InitStructure);
DMA1_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&(TIM1->CH3CVR);
DMA1_InitStructure.DMA_MemoryBaseAddr = (uint32_t)&(PWMCali_M.Cali_Buff.Cali5);
DMA_Init(DMA1_Channel6, &DMA1_InitStructure);
DMA1_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&(TIM1->CH3CVR);
DMA1_InitStructure.DMA_MemoryBaseAddr = (uint32_t)&(PWMCali_M.Cali_Buff.Cali6);
DMA_Init(DMA1_Channel7, &DMA1_InitStructure);
DMA_Cmd(DMA1_Channel1, ENABLE);
DMA_Cmd(DMA1_Channel2, ENABLE);
DMA_Cmd(DMA1_Channel4, ENABLE);
DMA_Cmd(DMA1_Channel5, ENABLE);
DMA_Cmd(DMA1_Channel6, ENABLE);
DMA_Cmd(DMA1_Channel7, ENABLE);
TIM_DeInit(TIM3);
TIM_DeInit(TIM2);
TIM_DeInit(TIM4);
TIM_TimeBaseStructInit(&TIM3_TimeBaseInitStructure);
TIM3_TimeBaseInitStructure.TIM_Prescaler = TIMER_PRESCALER_SVPWM;
TIM3_TimeBaseInitStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM3_TimeBaseInitStructure.TIM_Period = SVPWM_Cal_M.T-1;
TIM_TimeBaseInit(TIM3, &TIM3_TimeBaseInitStructure);
TIM_TimeBaseInit(TIM2, &TIM3_TimeBaseInitStructure);
TIM_TimeBaseInit(TIM4, &TIM3_TimeBaseInitStructure);
TIM_OCStructInit(&TIM3_OCInitStructure);
TIM3_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM2;
TIM3_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
TIM3_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
TIM_OC3Init(TIM2, &TIM3_OCInitStructure);
TIM_OC3Init(TIM3, &TIM3_OCInitStructure);
TIM_OC2Init(TIM4, &TIM3_OCInitStructure);
TIM_OC1Init(TIM2, &TIM3_OCInitStructure);
TIM_OC1Init(TIM3, &TIM3_OCInitStructure);
TIM_OC2Init(TIM2, &TIM3_OCInitStructure);
TIM_OC4Init(TIM3, &TIM3_OCInitStructure);
TIM_OC1PreloadConfig(TIM3, TIM_OCPreload_Enable);
TIM_OC3PreloadConfig(TIM3, TIM_OCPreload_Enable);
TIM_OC4PreloadConfig(TIM3, TIM_OCPreload_Enable);
TIM_OC3PreloadConfig(TIM2, TIM_OCPreload_Enable);
TIM_OC1PreloadConfig(TIM2, TIM_OCPreload_Enable);
TIM_OC2PreloadConfig(TIM2, TIM_OCPreload_Enable);
TIM_OC2PreloadConfig(TIM4, TIM_OCPreload_Enable);
TIM_SelectOutputTrigger(TIM1, TIM_TRGOSource_Update);
TIM_SelectInputTrigger(TIM3, TIM_TS_ITR0);
TIM_SelectSlaveMode(TIM3, TIM_SlaveMode_Reset);
TIM_SelectOutputTrigger(TIM1, TIM_TRGOSource_Update);
TIM_SelectInputTrigger(TIM2, TIM_TS_ITR0);
TIM_SelectSlaveMode(TIM2, TIM_SlaveMode_Reset);
TIM_SelectOutputTrigger(TIM1, TIM_TRGOSource_Update);
TIM_SelectInputTrigger(TIM4, TIM_TS_ITR0);
TIM_SelectSlaveMode(TIM4, TIM_SlaveMode_Reset);
TIM_SetCounter(TIM3,0);
TIM_SetCounter(TIM2,0);
TIM_SetCounter(TIM4,0);
}
/******************************************************************************
* Function Name : ADC_OPA_Configure
* Description : ADC/OPA Configuration
* Input : ADC calculation structure pointer, ADC register pointer
* Output : None
* Return : None
******************************************************************************/
void ADC_OPA_Configure(ADCStruc_Type *ADCStruc)
{
ADC_InitTypeDef ADC_InitStructure={0};
GPIO_InitTypeDef GPIO_InitStructure={0};
OPA_InitTypeDef OPA1_InitStructure = {0};
OPA_InitTypeDef OPA2_InitStructure = {0};
RCC_ADCCLKConfig(RCC_PCLK2_Div6);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOB\
|RCC_APB2Periph_AFIO | RCC_APB2Periph_ADC1\
| RCC_APB2Periph_ADC2, ENABLE);
GPIO_StructInit(&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 |GPIO_Pin_2 ;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_StructInit(&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4|GPIO_Pin_5;//CH4 CH5
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init( GPIOB, &GPIO_InitStructure );
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init( GPIOA, &GPIO_InitStructure );
OPA2_InitStructure.OPA_NUM = OPA2;
OPA2_InitStructure.PSEL = CHP1;
OPA2_InitStructure.NSEL = CHN0;
OPA2_InitStructure.Mode = OUT_IO_OUT1;
OPA_Init( &OPA2_InitStructure );
OPA_Cmd( OPA2, ENABLE );
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init( GPIOA, &GPIO_InitStructure );
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init( GPIOB, &GPIO_InitStructure );
OPA1_InitStructure.OPA_NUM = OPA1;
OPA1_InitStructure.PSEL = CHP1;
OPA1_InitStructure.NSEL = CHN1;
OPA1_InitStructure.Mode = OUT_IO_OUT1;
OPA_Init( &OPA1_InitStructure );
OPA_Cmd( OPA1, ENABLE );
ADC_DeInit(ADC1);
ADC_DeInit(ADC2);
ADC_StructInit(&ADC_InitStructure);
ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
ADC_InitStructure.ADC_ScanConvMode = ENABLE;
ADC_InitStructure.ADC_ContinuousConvMode = DISABLE;
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Left;
ADC_InitStructure.ADC_NbrOfChannel = 1;
ADC_Init(ADC1, &ADC_InitStructure);
ADC_Init(ADC2, &ADC_InitStructure);
ADC_RegularChannelConfig(ADC2,ADC_Channel_1, 1, SAMPLING_TIMER_CLOCK );
ADC_RegularChannelConfig(ADC1,ADC_Channel_2, 1, SAMPLING_TIMER_CLOCK );
ADC_Cmd(ADC1, ENABLE);
ADC_Cmd(ADC2, ENABLE);
ADC_BufferCmd(ADC1, DISABLE); //disable buffer
ADC_ResetCalibration(ADC1);
while(ADC_GetResetCalibrationStatus(ADC1));
ADC_StartCalibration(ADC1);
while(ADC_GetCalibrationStatus(ADC1));
ADC_BufferCmd(ADC2, DISABLE); //disable buffer
ADC_ResetCalibration(ADC2);
while(ADC_GetResetCalibrationStatus(ADC2));
ADC_StartCalibration(ADC2);
while(ADC_GetCalibrationStatus(ADC2));
}
/******************************************************************************
* Function Name : ADC_1R_Offset_Reading
* Description : ADC current sampling zero reading
* Input : ADC register pointer, ADC calculation structure pointer, ADC number
* Output : None
* Return : None
******************************************************************************/
void ADC_1R_Offset_Reading(ADC_TypeDef *ADCx, ADCStruc_Type *ADCStruc,u_int8_t ADC_num)
{
uint16_t i;
if(ADC_num ==1)
ADCStruc->OffsetValue1 = 0;
else if (ADC_num ==2)
ADCStruc->OffsetValue2 = 0;
ADC_ITConfig(ADCx, ADC_IT_JEOC, DISABLE);
ADC_ExternalTrigInjectedConvConfig(ADCx, ADC_ExternalTrigInjecConv_None);
ADC_ExternalTrigInjectedConvCmd(ADCx,ENABLE);
ADC_InjectedSequencerLengthConfig(ADCx,1);
if(ADC_num ==1)
ADC_InjectedChannelConfig(ADCx, ADCStruc->AdcChannel1,1,SAMPLING_TIMER_CLOCK);
else if (ADC_num ==2)
ADC_InjectedChannelConfig(ADCx, ADCStruc->AdcChannel2,1,SAMPLING_TIMER_CLOCK);
ADC_ClearFlag(ADCx, ADC_FLAG_JEOC);
ADC_SoftwareStartInjectedConvCmd(ADCx,ENABLE);
for(i=0; i <CURR_OFFSET_READ_NUM_ADC; i++)
{
while(!ADC_GetFlagStatus(ADCx,ADC_FLAG_JEOC));
if(ADC_num ==1)
ADCStruc->OffsetValue1 += (ADC_GetInjectedConversionValue(ADCx,ADC_InjectedChannel_1)>>3);
else if (ADC_num ==2)
ADCStruc->OffsetValue2 += (ADC_GetInjectedConversionValue(ADCx,ADC_InjectedChannel_1)>>3);
ADC_ClearFlag(ADCx, ADC_FLAG_JEOC);
ADC_SoftwareStartInjectedConvCmd(ADCx,ENABLE);
}
ADC_ExternalTrigInjectedConvCmd(ADCx,ENABLE);
}
/******************************************************************************
* Function Name : ADC_1R_Start
* Description : ADC Conversion Start
* Input : Enable command
* Output : None
* Return : None
******************************************************************************/
void ADC_1R_Start (FunctionalState cmd)
{
if (cmd == ENABLE)
{
ADC_ExternalTrigInjectedConvConfig(ADC1, ADC_ExternalTrigInjecConv_T1_CC4);
ADC_ExternalTrigInjectedConvConfig(ADC2, ADC_ExternalTrigInjecConv_T3_CC4);
ADC1->STATR = ~(uint32_t)ADC_FLAG_JEOC;
ADC2->STATR = ~(uint32_t)ADC_FLAG_JEOC;
ADC_ITConfig(ADC1, ADC_IT_JEOC, ENABLE);
ADC_ITConfig(ADC2, ADC_IT_JEOC, ENABLE);
TIM_DMACmd(TIM2, TIM_DMA_CC1, ENABLE);
TIM_DMACmd(TIM2, TIM_DMA_CC2, ENABLE);
TIM_DMACmd(TIM2, TIM_DMA_CC3, ENABLE);
TIM_DMACmd(TIM3, TIM_DMA_CC1, ENABLE);
TIM_DMACmd(TIM3, TIM_DMA_CC3, ENABLE);
TIM_DMACmd(TIM4, TIM_DMA_CC2, ENABLE);
}
else
{
ADC_ExternalTrigInjectedConvConfig(ADC1, ADC_ExternalTrigInjecConv_None);
ADC_ExternalTrigInjectedConvConfig(ADC2, ADC_ExternalTrigInjecConv_None);
TIM_DMACmd(TIM2, TIM_DMA_CC1, DISABLE);
TIM_DMACmd(TIM2, TIM_DMA_CC2, DISABLE);
TIM_DMACmd(TIM2, TIM_DMA_CC3, DISABLE);
TIM_DMACmd(TIM3, TIM_DMA_CC1, DISABLE);
TIM_DMACmd(TIM3, TIM_DMA_CC3, DISABLE);
TIM_DMACmd(TIM4, TIM_DMA_CC2, DISABLE);
ADC_ExternalTrigInjectedConvCmd(ADC1,DISABLE);
ADC_ExternalTrigInjectedConvCmd(ADC2,DISABLE);
TIM_CtrlPWMOutputs(TIM1, DISABLE);
}
}
/******************************************************************************
* Function Name : DCBUS_Volt_Cal
* Description : Bus Voltage Calculation
* Input : ADC calculation structure pointer, ADC register pointer
* Output : None
* Return : None
******************************************************************************/
void DCBUS_Volt_Cal(ADCStruc_Type *ADCStruc,ADC_TypeDef *ADCx)
{
if((ADCx->STATR & ADC_FLAG_EOC) == ADC_FLAG_EOC)
{
ADCStruc->DCVoltPres=_IQ18toIQ(_IQ18MPY_MACRO(_IQ18(ADCx->RDATAR>>4),ADCStruc->DCVoltRatedADCInv));
ADCStruc->DCVolt_Filter = LPF_1st_Process(&(ADCStruc->VdcLPF1st), ADCStruc->DCVoltPres);
ADCStruc->DCVoltAver = _IQMPY_MACRO(ADCStruc->DCVoltAver,ADCStruc->DCVoltAverSizeInv2)\
+ _IQMPY_MACRO(ADCStruc->DCVoltPres,ADCStruc->DCVoltAverSizeInv1);
}
}
/******************************************************************************
* Function Name : NTCSample
* Description : NTC Sampling Calculation
* Input : Temperature control structure pointer, ADC register pointer
* Output : None
* Return : None
******************************************************************************/
void NTCSample(Temperature_ctl_Type *TempM, ADC_TypeDef *ADCx)
{
if((ADCx->STATR & ADC_FLAG_EOC) == ADC_FLAG_EOC)
{
TempM->TempPres=(_iq24)((u16)ADCx->RDATAR*TempM->TempRatedADCInv);
//¾ùÖµ¼ÆËã
TempM->TempAver =_IQMPY_MACRO(TempM->TempAver,TempM->TempAverSizeInv2)\
+ _IQMPY_MACRO(TempM->TempPres,TempM->TempAverSizeInv1);
}
}
/******************************************************************************
* Function Name : ADC_Trigger_Update
* Description : Update at ADC trigger moment
* Input : PWM correction calculation structure pointer
* Output : None
* Return : None
******************************************************************************/
void ADC_Trigger_Update(PWMCali_Type *PWMCali)
{
TIM1->CH4CVR = PWMCali->ADC_Trig.Trig1;
TIM3->CH4CVR = PWMCali->ADC_Trig.Trig2;
}
/*******************************************************************************
* Function Name : SVPWM_Zerovolt_Output_Immidiate
* Description : 0 voltage output, takes effect immediately
* Input : SVPWM calculation structure pointer
* Output : None
* Return : None
*******************************************************************************/
void SVPWM_Zerovolt_Output_Immediate(SVPWM_1R_Type *SVPWM_Cal)
{
TIM1->CH1CVR = SVPWM_Cal->Quard_T;
TIM1->CH2CVR = SVPWM_Cal->Quard_T;
TIM1->CH3CVR = SVPWM_Cal->Quard_T;
}
/*******************************************************************************
* Function Name : SVPWM_Lowside_Effective
* Description : All lower tubes are fully conductive and take effect immediately
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void SVPWM_Lowside_Effective_Immediate(void)
{
TIM1->CH1CVR = 0;
TIM1->CH2CVR = 0;
TIM1->CH3CVR = 0;
}
@@ -0,0 +1,112 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : M4_SVPWM_ADC1R.h
* Author : WCH
* Version : V1.0.0
* Date : 2026/04/23
* Description :
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#ifndef __MOTOR_SVPWM_ADC1R_H
#define __MOTOR_SVPWM_ADC1R_H
#define DCBUS_RATED_VOLT _IQ18(311)
#define SYSTEM_CLOCK_FREQ 144000000uL
#define TIMER_PRESCALER_SVPWM 0
#define TIMER_CLOCK_FREQ_SVPWM (SYSTEM_CLOCK_FREQ/(TIMER_PRESCALER_SVPWM+1))
#define TIMER_UPDATE_RATE_SVPWM 1
#define FREQ_SVPWM 30000
#define DEADTIME_SVPWM 1000
#define DEADTIME_CLOCK_SVPWM (uint16_t)((DEADTIME_SVPWM*(SYSTEM_CLOCK_FREQ/1000000))/1000)
#define DEADTIME_CONFIGURE (uint8_t)136
#define BRK_GPIO_M GPIOB
#define BRK_PIN_M GPIO_Pin_12
#define CURR_SAMPLE_RESISTOR_ADC _IQ18(0.1)
#define CURR_AMPLIFIER_ADC _IQ18(3.73333)
#define CURR_SAMPLE_RANGE_ADC _IQ18div(_IQ18(1.65),_IQ18mpy(CURR_SAMPLE_RESISTOR_ADC,CURR_AMPLIFIER_ADC))
#define CURR_OFFSET_READ_NUM_ADC ((uint8_t)16)
#define SAMPLING_TIMER_CLOCK ADC_SampleTime_7Cycles5
#define CONVER_TIME_ADC 750
#define CURR_CONVERT_CLOCK_ADC (uint16_t)((CONVER_TIME_ADC*(SYSTEM_CLOCK_FREQ/1000000))/1000)
#define CURR_RISE_TIME_ADC 900
#define CURR_RISE_CLOCK_ADC (uint16_t)((CURR_RISE_TIME_ADC*(SYSTEM_CLOCK_FREQ/1000000))/1000)
#define CURR_NOISE_TIME_ADC 650
#define CURR_NOISE_CLOCK_ADC (uint16_t)((CURR_NOISE_TIME_ADC*(SYSTEM_CLOCK_FREQ/1000000))/1000)
#if(CURR_RISE_TIME_ADC > CURR_NOISE_TIME_ADC)
#define CURR_MAX_TRTN_CLOCK_ADC CURR_RISE_CLOCK_ADC
#else
#define CURR_MAX_TRTN_CLOCK_ADC CURR_NOISE_CLOCK_ADC
#endif
#define ADC1_CURR_CHANNEL_PHASE_M ADC_Channel_4
#define ADC2_CURR_CHANNEL_PHASE_M ADC_Channel_5
#define DCVOLT_INIT _IQ(1.0)
#define DCVOLT_CONV_RATIO _IQ18(0.006651884)
#define DCVOLT_AVER_SIZE 100
#define DCVOLT_LPF_CF_M 1000
#define DCVOLT_LPF_PERIOD_M LBG_CAL_PERIOD_M
#define DCVOLT_LPF_WcT_M _IQmpyI32(_IQmpy(DCVOLT_LPF_PERIOD_M,PI_2_Q24),DCVOLT_LPF_CF_M)
/* Exported variables -------------------------------------------------------*/
extern SVPWM_1R_Type SVPWM_Cal_M;
extern ADCStruc_Type ADC_M;
extern PWMCali_Type PWMCali_M;
void SVPWM_1R_Paramter_Init(SVPWM_1R_Type *SVPWM_Cal,PWMCali_Type *PWMCali,Motor_Base_Type *Mbase);
void SVPWM_1R_Status_Init_M(SVPWM_1R_Type *SVPWM_Cal,PWMCali_Type *PWMCali);
void ADC_Parameter_Init (ADCStruc_Type *ADCStruc,Motor_Base_Type *Mbase);
void ADC_Status_Init (ADCStruc_Type *ADCStruc);
void SVPWM_1R_Timer_Configure(void);
void ADC_OPA_Configure(ADCStruc_Type *ADCStruc);
void ADC_1R_Offset_Reading(ADC_TypeDef *ADCx, ADCStruc_Type *ADCStruc,u_int8_t ADC_num);
void ADC_1R_Start (FunctionalState cmd);
void SVPWM_Updateup(SVPWM_1R_Type *SVPWM_Cal,PWMCali_Type *PWMCali);
void SVPWM_Updatedown (SVPWM_1R_Type *SVPWM_Cal,PWMCali_Type *PWMCali);
void ADC_Trigger_Update(PWMCali_Type *PWMCali);
void DCBUS_Volt_Cal(ADCStruc_Type *ADCStruc,ADC_TypeDef *ADCx);
void SVPWM_Calculation(SVPWM_1R_Type *SVPWM_Cal, Component_2S_Type *VoltRef);
void SVPWM_Calibration(SVPWM_1R_Type *SVPWM_Cal, PWMCali_Type *PWMCali_Struc);
Component_3S_Type Current_Cal_1R(uint8_t Sector, ADCStruc_Type *ADCStruc);
void SVPWM_Zerovolt_Output(SVPWM_1R_Type *SVPWM_Cal);
void SVPWM_Lowside_Effective(SVPWM_1R_Type *SVPWM_Cal);
void SVPWM_Zerovolt_Output_Immediate(SVPWM_1R_Type *SVPWM_Cal);
void SVPWM_Lowside_Effective_Immediate(void);
void NTCSample(Temperature_ctl_Type *TempM, ADC_TypeDef *ADCx);
#endif
@@ -0,0 +1,252 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : M5_MotorStart.c
* Author : WCH
* Version : V1.0.0
* Date : 2026/04/23
* Description : Initialization of the motor before starting
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#include "M0_Control_Library.h"
InjStart_Type InjStart_M;
/******************************************************************************
* Function Name : Motor_Start_Init
* Description : Motor Start Init
* Input : None
* Output : None
* Return : None
******************************************************************************/
void Motor_Start_Init_M(void)
{
LED_OFF(&LED_M);
KeyandLED_Status_Ini(&Key_M,&LED_M);
Operation_Status_Init(&Operation_M);
Eventmanager_Initial(&Emanager_M);
Speedrampctr_Start_Init_M(&SpeedRamp_M);
Speed_Set(&SpeedRamp_M);
Temp_Set(&Key_M,&SpeedRamp_M,&Triac_ctl);
Protection_and_Emergency_Init();
PID_Output_Init(&Mpid_M);
Motor_Status_Initial_M(&MStruc_M);
Injstart_Status_Init_M(&InjStart_M);
Dcurr_Process_Init(&DCurrProcess_M,1);
SVPWM_1R_Status_Init_M(&SVPWM_Cal_M,&PWMCali_M);
LBG_Status_Init(&MLBG_M,&LBG_Status_M);
Buffer_Clear(&(LBG_SpeedBuffer_M[0]),&(MLBG_M.SpeedBuffPara));
HFVQI_Status_Init_M(&HFVQI_StartStruc_M);
Buffer_Clear(&(HFVQIPosi_CBuff_M[0]),&HFVQIPosi_CBuffPara_M);
Powercom_Status_Init(&Powercom_M);
ADC_1R_Offset_Reading(ADC1,&ADC_M,1);
ADC_1R_Offset_Reading(ADC2,&ADC_M,2);
ADC_Status_Init (&ADC_M);
Triac_Status_Init(&Triac_ctl,&Tempctl_M);
SVPWM_Zerovolt_Output_Immediate(&SVPWM_Cal_M);
TIM_CtrlPWMOutputs(TIM1,ENABLE);
TempLed_Set(&Key_M,&LED_M);
SpeedLed_Set(&SpeedRamp_M,&LED_M);
}
/******************************************************************************
* Function Name : Injstart_Parameter_Define_M
* Description : Definition of Current Injection Start Parameters
* Input : Pointer to motor start control structure
* Output : None
* Return : None
******************************************************************************/
void Injstart_Parameter_Define_M (InjStart_Type *InjStart)
{
InjStart->ForceInjCurrStep = _IQdiv(FORCE_INJ_CURR_M,FORCE_INJ_CURR_RAMP_TIME_M)/FORCE_INJ_FREQ_M;
InjStart->ForceInjCurrTarget = FORCE_INJ_CURR_M;
InjStart->ForceInjCurrAngle = FORCE_INJ_ANGLE_M;
InjStart->ForceInjStage = RAMP_INJ_STAGE_M;
InjStart->RampInjCurrTarget = RAMP_INJ_CURR_FINAL_M;
InjStart->RampInjCurrStep = _IQdiv((RAMP_INJ_CURR_FINAL_M - RAMP_INJ_CURR_INIT_M),\
RAMP_INJ_CURR_RAMP_TIME_M)/RAMP_INJ_FREQ_M;
InjStart->RampInjSpeedTarget = RAMP_INJ_SPEED_M*STARTUP_DIRECTION;
InjStart->RampInjSpeedStep = _IQdiv(RAMP_INJ_SPEED_M,RAMP_INJ_SPEED_RAMP_TIME_M)/RAMP_INJ_FREQ_M;
InjStart->K_WetoPosi = RAMP_INJ_PERIOD_M*RATED_FREQ_M;
InjStart->CurrErrThresh = INJECTION_CURRERR_THRESH_M;
InjStart->RampInjStage1 = RAMP_INJ_STAGE1_M;
InjStart->RampInjStage2 = RAMP_INJ_STAGE2_M;
InjStart->Speedadj = RAMP_INJ_SPEED_ADJ*STARTUP_DIRECTION;
InjStart->Curradj = RAMP_INJ_CURR_ADJ;
InjStart->IF_Vicom.Kcom = IF_VICOM_COEF_M * STARTUP_DIRECTION;
InjStart->IF_Vicom.Wecomupper = IF_VICOM_UPPER_M;
InjStart->IF_Vicom.Wecomlower = IF_VICOM_LOWER_M;
InjStart->IF_Vicom.Power_HPF1st.Input_Coef=_IQdiv(UNIT_Q24,(IF_VICOM_HPF1st_WcT_M + UNIT_Q24));
InjStart->IF_Vicom.Power_HPF1st.Output_Coef=_IQdiv(UNIT_Q24,(IF_VICOM_HPF1st_WcT_M + UNIT_Q24));
}
/******************************************************************************
* Function Name : Injstart_Status_Init_M
* Description : Current injection start-up state initialization
* Input : Pointer to motor start control structure
* Output : None
* Return : None
******************************************************************************/
void Injstart_Status_Init_M(InjStart_Type *InjStart)
{
InjStart->ForceInjCurrRef = _IQ(0);
InjStart->ForceInjCounter = 0;
InjStart->RampInjCurrRef = RAMP_INJ_CURR_INIT_M;
InjStart->RampInjSpeedRef = RAMP_INJ_SPEEDINT_M *STARTUP_DIRECTION;
InjStart->RampInjAngle = _IQ(0);
InjStart->RampInjCounter =0;
InjStart->Curr_2R.cd = _IQ(0);
InjStart->Curr_2R.cq = _IQ(0);
InjStart->VoltRef_2R.cd = _IQ(0);
InjStart->VoltRef_2R.cq = _IQ(0);
InjStart->Status = INITIAL;
InjStart->InjStage=0;
InjStart->IF_Vicom.Powerinst = 0;
InjStart->IF_Vicom.Powerfilter = 0;
InjStart->IF_Vicom.Wecom = 0;
InjStart->IF_Vicom.Power_HPF1st.Out_New = 0;
InjStart->IF_Vicom.Power_HPF1st.Out_Pre = 0;
InjStart->IF_Vicom.Power_HPF1st.In_Pre = 0;
}
/******************************************************************************
* Function Name : Injstart_Process_M
* Description : Injection start, first force positioning, then current closed-loop start
* Input : Pointer to motor start control structure,
* pointer to overall motor status structure,
* pointer to LBG observer structure
* Output : None
* Return : None
******************************************************************************/
void Injstart_Process_M(InjStart_Type *InjStart,Motor_Sructure_Type *MStruc,Motor_LBG_Type *MLBG)
{
switch(InjStart->Status)//Æô¶¯×´Ì¬»ú
{
case INITIAL:
InjStart->Status = INJECTION;
break;
case INJECTION:
if(InjStart->ForceInjCounter < U32_MAX)
InjStart->ForceInjCounter++;
if(InjStart->ForceInjCurrRef < InjStart->ForceInjCurrTarget)
{
InjStart->ForceInjCurrRef += InjStart->ForceInjCurrStep;
if(InjStart->ForceInjCurrRef > InjStart->ForceInjCurrTarget)
InjStart->ForceInjCurrRef = InjStart->ForceInjCurrTarget;
MStruc->CRef2R.cd = InjStart->ForceInjCurrRef;
MStruc->CRef2R.cq = 0;
MStruc->Cossin = TrigonoMetric_Function( InjStart->ForceInjCurrAngle);
}
else
{
if( _IQabs(MStruc->C2R_L.cd)>=_IQMPY_MACRO(InjStart->CurrErrThresh,
_IQabs(MStruc->CRef2R.cd)))
{
if( InjStart->ForceInjCounter >= InjStart->ForceInjStage)
{
InjStart->RampInjCurrRef = InjStart->ForceInjCurrRef;
InjStart->RampInjAngle = InjStart->ForceInjCurrAngle;
InjStart->Status = RAMP;
}
}
else
Protection_SetFault(STARTUP_FAILURE_M);
}
break;
case RAMP:
if(InjStart->RampInjCounter < U32_MAX)
InjStart->RampInjCounter++;
Injstart_Curr_Speed_Ramp(InjStart);
#if defined IF_VIBRATION_COM
IF_Vibration_Com(&(MStruc->VRef2R), &(MStruc->C2R_L), InjStart);
InjStart->RampInjAngle = InjStart->RampInjAngle +\
_IQMPY_MACRO(InjStart->RampInjSpeedRef2,InjStart->K_WetoPosi);
#else
InjStart->RampInjAngle = InjStart->RampInjAngle +\
_IQMPY_MACRO(InjStart->RampInjSpeedRef,InjStart->K_WetoPosi);
#endif
InjStart->RampInjAngle = Round_Circle_Limitation_PU(InjStart->RampInjAngle);
MStruc->Cossin = TrigonoMetric_Function(InjStart->RampInjAngle);
MStruc->CRef2R.cd = InjStart->RampInjCurrRef;
MStruc->CRef2R.cq = 0;
if(InjStart->RampInjCounter >= (InjStart->RampInjStage1))
{
if(_IQabs(MStruc->C2R_L.cd)>=_IQMPY_MACRO(InjStart->CurrErrThresh,\
_IQabs(MStruc->CRef2R.cd)))
{
if(MLBG->Cal_Struc.Inimark == TRUE)
Injstart_Transition_Cal(InjStart,MStruc,MLBG);
else
{
LBG_Cal_Init(InjStart,MStruc,MLBG);
MLBG->Cal_Struc.Inimark = TRUE;
}
}
else
Protection_SetFault(STARTUP_FAILURE_M);
}
else
{
MLBG->Cal_Struc.CalphaPrev = MStruc->C2S.Alpha;
MLBG->Cal_Struc.CbetaPrev = MStruc->C2S.Beta;
}
if (InjStart->RampInjCounter >=InjStart->RampInjStage2)
Protection_SetFault(STARTUP_FAILURE_M);
break;
default:
break;
}
}
@@ -0,0 +1,61 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : M5_MotorStart.h
* Author : WCH
* Version : V1.0.0
* Date : 2026/04/23
* Description : Initialization of the motor before starting
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#ifndef __M5_MOTORSTART_H
#define __M5_MOTORSTART_H
#define FORCE_INJ_FREQ_M FREQ_SVPWM
#define FORCE_INJ_CURR_M _IQ(0.3)
#define FORCE_INJ_ANGLE_M _IQ(0.083333*1)
#define FORCE_INJ_CURR_RAMP_TIME_M _IQ(0.2)
#define RAMP_INJ_STAGE_M (uint32_t)(FREQ_SVPWM*3)
#define RAMP_INJ_FREQ_M FREQ_SVPWM
#define RAMP_INJ_PERIOD_M _IQ(1.0)/FREQ_SVPWM
#define RAMP_INJ_CURR_INIT_M _IQ(0.00)
#define RAMP_INJ_CURR_FINAL_M _IQ(0.4)
#define RAMP_INJ_CURR_RAMP_TIME_M _IQ(0.001)
#define RAMP_INJ_SPEEDINT_M _IQ(0.005)
#define RAMP_INJ_SPEED_M _IQ(0.2)
#define RAMP_INJ_SPEED_RAMP_TIME_M _IQ(0.2)
#define RAMP_INJ_STAGE1_M (uint32_t)(FREQ_SVPWM*0.15)
#define RAMP_INJ_STAGE2_M (uint32_t)(FREQ_SVPWM*0.6)
#define INJECTION_CURRERR_THRESH_M _IQ(0.5)
#define RAMP_INJ_SPEED_ADJ _IQ(0.05)
#define RAMP_INJ_CURR_ADJ _IQ(1.1)
#define IF_VICOM_COEF_M _IQ(-0.15)
#define IF_VICOM_UPPER_M _IQ(0.01)
#define IF_VICOM_LOWER_M _IQ(-0.01)
#define IF_VICOM_PERIOD_M _IQ(1.0)/FREQ_SVPWM
#define IF_VICOM_HPF1st_CF_M 10
#define IF_VICOM_HPF1st_WcT_M _IQmpy(_IQmpyI32(IF_VICOM_PERIOD_M,IF_VICOM_HPF1st_CF_M),PI_2_Q24)
/* Exported variables -------------------------------------------------------*/
extern InjStart_Type InjStart_M;
void Motor_Start_Init_M(void);
void Injstart_Parameter_Define_M (InjStart_Type *InjStart);
void Injstart_Status_Init_M(InjStart_Type *InjStart);
void Injstart_Process_M(InjStart_Type *InjStart,Motor_Sructure_Type *MStruc,Motor_LBG_Type *MLBG);
void Controlloop_Initial(InjStart_Type *InjStart,_iq24 Speedact,Motor_Sructure_Type *MStruc,\
Motor_PID_Type *Mpid,Speedrampctr_Type *Speed_Ramp);
void Injstart_Curr_Speed_Ramp(InjStart_Type *InjStart);
void Injstart_Transition_Cal(InjStart_Type *InjStart,Motor_Sructure_Type *MStruc,Motor_LBG_Type *MLBG);
void Speedrampctr_Start_Init_M(Speedrampctr_Type *Speed_Ramp);
#endif
@@ -0,0 +1,152 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : M5_Operation_Cusevent.c
* Author : WCH
* Version : V1.0.0
* Date : 2026/04/23
* Description :
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#include "M0_Control_Library.h"
Eventmanager_Type Emanager_M;
uint8_t testcounter =0;
/******************************************************************************
* Function Name : Eventmanager_Initial
* Description : Event manage Init
* Input : Event management structure pointer
* Output : None
* Return : None
******************************************************************************/
void Eventmanager_Initial(Eventmanager_Type *EventM)
{
EventM->Event_10ms= FALSE;
EventM->Event_10ms_cntset = (uint16_t)(EVENT_10ms*EVENT_CHECK_FREQ);
EventM->Event_10ms_cnt = 0;
EventM->Event_1ms= FALSE;
EventM->Event_1ms_cntset = (uint16_t)(EVENT_1ms*EVENT_CHECK_FREQ);
EventM->Event_1ms_cnt = 0;
EventM->Event_2s= FALSE;
EventM->Event_2s_cntset = (uint16_t)(EVENT_2s*EVENT_CHECK_FREQ);
EventM->Event_2s_cnt = 0;
}
/******************************************************************************
* Function Name : Zerocross_Process
* Description : AC input zero-crossing event handling
* Input : Temperature control structure pointer, thyristor control structure pointer, key management structure pointer
* Output : None
* Return : None
******************************************************************************/
void ACZerocross_Process(Temperature_ctl_Type *TempM,Key_Manager_Type *KeyM,TRIAC_ctl_Type *TriacM)
{
if((KeyM->Tkeyeffective==TRUE)||(KeyM->Skeyeffective==TRUE))
TriacM->PeriodCtl.DutychangeFlag=TRUE;
if( (TriacM->Zero.ZcrossEvent==1) && (TriacM->Zero.Zcrosseffective == TRUE) )
{
#ifdef ZEROCROSSOVER_OC
if(TriacM->Zero.Zcrosseffectivecnt<2)
TriacM->Zero.Zcrosseffectivecnt++;
if(TriacM->Zero.Zcrosseffectivecnt>=2)
{
if(TriacM->PeriodCtl.DelayProcess_Flag==0)//
{
TriacM->Zero.ZcrossDelayTrigcnt=TriacM->Zero.ZcrossDelayTrigset;
TriacM->PeriodCtl.DelayProcess_Flag=1;
}
if((TriacM->Zero.ZcrossDelayTrigcnt==0)&&(TriacM->PeriodCtl.DelayProcess_Flag==1))
{
TriacZero_50HZControl_Process(TempM,KeyM,TriacM,&SpeedRamp_M);
TriacM->Zero.Zcrosseffectivecnt=0;
TriacM->Zero.ZcrossEvent=0;
TriacM->PeriodCtl.DelayProcess_Flag=0;
}
}
else
{
TriacM->Zero.ZcrossEvent=0;
TriacM->PeriodCtl.DelayProcess_Flag=0;
}
#else
if(TriacM->PeriodCtl.DelayProcess_Flag==0)//
{
TriacM->Zero.ZcrossDelayTrigcnt=TriacM->Zero.ZcrossDelayTrigset;
TriacM->PeriodCtl.DelayProcess_Flag=1;
}
if((TriacM->Zero.ZcrossDelayTrigcnt==0)&&(TriacM->PeriodCtl.DelayProcess_Flag==1))
{
TriacZero_50HZControl_Process(TempM,KeyM,TriacM,&SpeedRamp_M);
TriacM->Zero.ZcrossEvent=0;
TriacM->PeriodCtl.DelayProcess_Flag=0;
}
#endif
}
}
/******************************************************************************
* Function Name : Event_10ms_Process
* Description : 10ms Event process
* Input : Event management structure pointer
* Output : None
* Return : None
******************************************************************************/
void Event_10ms_Process(Eventmanager_Type *EventM)
{
if(EventM->Event_10ms == TRUE)
{
// testcounter++;
//
// if(testcounter ==2)
// LED_Lighton(&LED_M.YLED);
// if(testcounter ==4)
// {
// LED_Lightoff(&LED_M.YLED);
// testcounter = 0;
// }
EventM->Event_10ms_cnt = EventM->Event_10ms_cntset;
EventM->Event_10ms = FALSE;
}
}
/******************************************************************************
* Function Name : Event_1ms_Process
* Description : 1ms Event Handling
* Input : Event management structure pointer
* Output : None
* Return : None
******************************************************************************/
void Event_1ms_Process(Eventmanager_Type *EventM)
{
//static u8 Event_50ms_cnt;
if(EventM->Event_1ms == TRUE)
{
EventM->Event_1ms_cnt = EventM->Event_1ms_cntset;
EventM->Event_1ms = FALSE;
}
}
/******************************************************************************
* Function Name : Event_1ms_Process
* Description : 2s Event Handling
* Input : Event management structure pointer
* Output : None
* Return : None
******************************************************************************/
void Event_2s_Process(Eventmanager_Type *EventM)
{
if(EventM->Event_2s == TRUE)//¶¨Ê±µ½
{
EventM->Event_2s_cnt = EventM->Event_2s_cntset;
EventM->Event_2s = FALSE;
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,351 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : M5_Operation_and_Display.h
* Author : WCH
* Version : V1.0.0
* Date : 2026/04/23
* Description : Definition of relevant operation parameters such as buttons and displays
Definition of acceleration and deceleration parameters
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#ifndef __MOTOR_OPERATION_AND_DISPLAY_H
#define __MOTOR_OPERATION_AND_DISPLAY_H
typedef enum {FAILED = 0, PASSED = !FAILED} TestStatus;
typedef enum {OFF = 0, ON = !OFF} LightStatus;
typedef struct
{
uint8_t FlashExcep;
uint16_t FlashData[2];
volatile uint32_t MemAddress;
volatile FLASH_Status FLASHStatus;
volatile TestStatus MemoryProgramStatus;
} Flash_Operation_Type;
typedef struct
{
GPIO_TypeDef *Group;
uint16_t Pin;
} LEDGPIO_Type;
typedef struct
{
uint16_t FlickInterval;
uint16_t FlickCnt;
uint8_t FlickCtl;
LightStatus LightFlag;
} LED_Type;
typedef struct
{
LED_Type LED4;
LED_Type LED5;
LED_Type LED6;
LED_Type LED7;
LED_Type LED8;
LED_Type LED9;
LEDGPIO_Type Pin1;
LEDGPIO_Type Pin2;
LEDGPIO_Type Pin3;
} Led_Manager_Type;//LED¹ÜÀí
/* Exported constants -------------------------------------------------------*/
/*********************** תËÙ²Ù×÷¶¨Òå ******************************/
#define STARTUP_DIRECTION 1
#define SPEED_ADJUST_STEP _IQ(0.05)
#define MAX_ANGSPEED_POS_M _IQ(1.0)
#define MAX_ANGSPEED_NEG_M _IQ(-1.0)
#define MIN_ANGSPEED_POS_M _IQ(0.025)
#define MIN_ANGSPEED_NEG_M _IQ(-0.025)
#define SPEED_RAMP_FREQ_M SPEED_LOOP_CAL_FREQ
#define ACCE_TIME_M 0.5
#define DECE_TIME_M 0.4
#define POWEROFF_DECE_TIME_M 0.15
#define SPEEDPOINT1 _IQ(0.7965085)
#define SPEEDPOINT2 _IQ(0.8545455)
#define SPEEDPOINT3 _IQ(0.9094380)
//#define SPEEDPOINT3 _IQ(0.92744135)
//#define SPEEDPOINT3 _IQ(0.9383524)
//#define SPEEDPOINT3 _IQ(0.954719)
#define SPEEDPOINT_RANK 3
#define PRECHAGE_TIME 0.05
#define FAST_DECE_SPEED _IQ(0.6)
#define BREAKSPEED _IQ(0.65)
#define BREAKTIME 0.25
#define START_FINISH_SPEED (FAST_DECE_SPEED +_IQ(0.055))
#define LED_PROCESS_FREQ SPEED_LOOP_CAL_FREQ
#define LED_FLICKER_TIME 0.5
#define OPERATION_CAL_FREQ SPEED_LOOP_CAL_FREQ
#define STOP_WAITING_TIME 0.5
#define FAULT_HOLDING_TIME 0.5
#define SYS_RESET_TIME 0.025
#define POWERVERY_FREQ SPEED_LOOP_CAL_FREQ
#define POWERON_VOLT _IQ(0.85)
#define POWERON_TIME 0.1
#define POWEROFF_VOLT1 _IQ(0.7)
#define POWEROFF_VOLT2 _IQ(0.5)
#define POWERVERY_DCVOLTAVERSIZE 4
#define VDCLPF_SPEEDLIM_CF_M 5
#define VDCLPF_SPEEDLIM_PERIOD_M _IQ(1.0)/SPEED_LOOP_CAL_FREQ
#define VDCLPF_SPEEDLIM_WcT_M _IQmpyI32(_IQmpy(VDCLPF_SPEEDLIM_PERIOD_M,PI_2_Q24),VDCLPF_SPEEDLIM_CF_M)
#define VDC_SPEEDLIM_BEGIN _IQ(0.89)
#define VDC_SPEEDLIM_RELEASE _IQ(0.915)
#define VDC_SPEEDLIM_ADJ _IQ(1.1)
#define KEY_CHECK_FREQ SPEED_LOOP_CAL_FREQ
#define EEWRITE_WAITING_TIME 0.005
#define EEWRITE_CYCLE 2
#define SHKEY_CHECK_INTERVAL 0.040
#define SHKEY_EFFECTIVE_TIME 0.010
#define SHKEY_INEFFECTIVE_TIME 0.035
#define TCKEY_EFFECTIVE_TIME 0.010
#define TCKEY_INEFFECTIVE_TIME 0.035
#define SRKEY_EFFECTIVE_TIME 0.1
#define SRKEY_INEFFECTIVE_TIME 0.1
#define TKEY_RANK_SET 3
#define TKEY_SHORT_TIME_UP 0.5
#define TKEY_SHORT_TIME_DOWM 0.1
#define TKEY_LONG_TIME 2
#define ACKEY_CHECK_INTERVAL 0.040
#define ACKEY_EFFECTIVE_TIME 0.005
#define ACKEY_INEFFECTIVE_TIME 0.035
#define ZEROCROSS_FREQ 100
#define ZEROCROSS_VERYFREQ FREQ_SVPWM
#define OC_ZEROCROSS_VERYTIME 5
#define TR_ZEROCROSS_VERYTIME 7
#define ZEROCROSSLOST_VERYTIME 0.05
#define ZEROCROSSLOST_VERYFREQ FREQ_SVPWM
#define EVENT_CHECK_FREQ SPEED_LOOP_CAL_FREQ
#define EVENT_10ms 0.01
#define EVENT_1ms 0.001
#define EVENT_2s 2.00
#define TRIAC_ENABLEWAIT 1.5
#define TRIAC_OFF() (GPIO_SetBits(GPIOB, GPIO_Pin_7))
#define TRIAC_ON() (GPIO_ResetBits(GPIOB, GPIO_Pin_7))
#define TRIAC_TIME 660
#define TRIAC_CONTOROL_PERIOD 20
#ifdef ZEROCROSSOVER_OC
#define TRIAC_TIME_TO_TRIGGER 0.005
#else
#define TRIAC_TIME_TO_TRIGGER 0.003
#endif
#define DUTYMAX_T1S1 13
#define DUTYMIN_T1S1 3
#define DUTYDEFAULT_T1S1 11
#define DUTYMAX_T1S2 17
#define DUTYMIN_T1S2 3
#define DUTYDEFAULT_T1S2 14
#define DUTYMAX_T1S3 19
#define DUTYMIN_T1S3 3
#define DUTYDEFAULT_T1S3 16
#define DUTYMAX_T2S1 20
#define DUTYMIN_T2S1 3
#define DUTYDEFAULT_T2S1 16
#define DUTYMAX_T2S2 20
#define DUTYMIN_T2S2 3
#define DUTYDEFAULT_T2S2 18
#define DUTYMAX_T2S3 23
#define DUTYMIN_T2S3 3
#define DUTYDEFAULT_T2S3 21
#define DUTYMAX_T3S1 22
#define DUTYMIN_T3S1 3
#define DUTYDEFAULT_T3S1 19
#define DUTYMAX_T3S2 24
#define DUTYMIN_T3S2 3
#define DUTYDEFAULT_T3S2 20
#define DUTYMAX_T3S3 27
#define DUTYMIN_T3S3 3
#define DUTYDEFAULT_T3S3 23
#define NUM50HZ_DATA (u8)3
#define NUM100HZ_DATA (u8)6
#define PSC_LED_INTERVAL 0.2
#define PSC_LED_INTERVAL_TOTAL 5.0
#define PSC_LED_INTERVAL_NUM 3
#define PSC_LED_LAST 3.0
#define PSC_FREQ SPEED_LOOP_CAL_FREQ
#define PT_RS _IQ18(10.0)
#define TEMP_AVER_SIZE (u32)8
//34~289
#define DUTY_LIM_TABLE {\
0x00643,0x006D0,0x00766,0x00803,0x008A9,0x00957,0x00A0E,0x00ACE,\
0x00B96,0x00C68,0x00D42,0x00E26,0x00F14,0x0100B,0x0110C,0x01217,\
0x0132B,0x0144A,0x01574,0x016A7,0x017E5,0x0192E,0x01A81,0x01BE0,\
0x01D49,0x01EBD,0x0203C,0x021C6,0x0235C,0x024FD,0x026A9,0x02860,\
0x02A23,0x02BF2,0x02DCC,0x02FB1,0x031A2,0x0339F,0x035A8,0x037BC,\
0x039DB,0x03C07,0x03E3E,0x04081,0x042CF,0x0452A,0x0478F,0x04A01,\
0x04C7E,0x04F06,0x0519B,0x0543A,0x056E5,0x0599C,0x05C5D,0x05F2A,\
0x06202,0x064E5,0x067D4,0x06ACD,0x06DD1,0x070E0,0x073F9,0x0771D,\
0x07A4B,0x07D84,0x080C7,0x08414,0x0876B,0x08ACC,0x08E37,0x091AB,\
0x09529,0x098AF,0x09C3F,0x09FD8,0x0A37A,0x0A725,0x0AAD8,0x0AE93,\
0x0B256,0x0B622,0x0B9F5,0x0BDD0,0x0C1B2,0x0C59B,0x0C98C,0x0CD83,\
0x0D181,0x0D585,0x0D990,0x0DDA0,0x0E1B7,0x0E5D3,0x0E9F4,0x0EE1B,\
0x0F246,0x0F676,0x0FAAB,0x0FEE4,0x10321,0x10762,0x10BA6,0x10FEE,\
0x11439,0x11886,0x11CD7,0x12129,0x1257E,0x129D5,0x12E2D,0x13287,\
0x136E2,0x13B3E,0x13F9B,0x143F8,0x14855,0x14CB3,0x15110,0x1556C,\
0x159C8,0x15E23,0x1627C,0x166D4,0x16B2A,0x16F7E,0x173D0,0x17820,\
0x17C6D,0x180B7,0x184FD,0x18941,0x18D80,0x191BC,0x195F4,0x19A27,\
0x19E56,0x1A280,0x1A6A5,0x1AAC5,0x1AEDF,0x1B2F4,0x1B703,0x1BB0B,\
0x1BF0E,0x1C30A,0x1C6FF,0x1CAED,0x1CED5,0x1D2B5,0x1D68D,0x1DA5E,\
0x1DE27,0x1E1E8,0x1E5A1,0x1E951,0x1ECF9,0x1F098,0x1F42F,0x1F7BC,\
0x1FB40,0x1FEBB,0x2022C,0x20594,0x208F2,0x20C46,0x20F90,0x212D0,\
0x21605,0x21931,0x21C52,0x21F68,0x22273,0x22574,0x2286A,0x22B55,\
0x22E35,0x23109,0x233D3,0x23691,0x23944,0x23BEC,0x23E88,0x24119,\
0x2439E,0x24617,0x24885,0x24AE8,0x24D3E,0x24F89,0x251C9,0x253FC,\
0x25624,0x25841,0x25A51,0x25C56,0x25E4F,0x2603D,0x2621F,0x263F6,\
0x265C1,0x26780,0x26934,0x26ADD,0x26C7A,0x26E0C,0x26F93,0x2710F,\
0x27280,0x273E6,0x27541,0x27691,0x277D6,0x27911,0x27A42,0x27B68,\
0x27C84,0x27D96,0x27E9E,0x27F9C,0x28090,0x2817A,0x2825C,0x28333,\
0x28402,0x284C8,0x28585,0x28639,0x286E5,0x28788,0x28823,0x288B6,\
0x28942,0x289C5,0x28A42,0x28AB7,0x28B25,0x28B8C,0x28BEC,0x28C46,\
0x28C9A,0x28CE7,0x28D2F,0x28D71,0x28DAE,0x28DE6,0x28E18,0x28E46,\
0x28E70,0x28E95,0x28EB6,0x28ED3,0x28EEC,0x28F02,0x28F15,0x28F26};
/* Exported variables -------------------------------------------------------*/
extern Speedrampctr_Type SpeedRamp_M;
extern Powercontrol_Type Powerctr_M;
extern Led_Manager_Type LED_M;
extern Key_Manager_Type Key_M;
extern Eventmanager_Type Emanager_M;
extern Operation_Type Operation_M;
extern Temperature_ctl_Type Tempctl_M;
extern uint8_t Keymembuff[EEWRITE_CYCLE];
extern TRIAC_ctl_Type Triac_ctl;
extern u16 Temp_PhaseDuty[SPEEDPOINT_RANK][TKEY_RANK_SET+1];
/* Exported macro -----------------------------------------------------------*/
/* Exported functions ------------------------------------------------------ */
void Motor_Operation_Process(void);
void Speedrampctr_Parameter_Define(Speedrampctr_Type *Speed_Ramp);
void Speedrampctr_Start_Init_M(Speedrampctr_Type *Speed_Ramp);
void Speed_Set(Speedrampctr_Type *Speed_Ramp);
void Poweroperation_Initial(Powercontrol_Type *PowerOper);
void Poweroperation_Process(Speedrampctr_Type *SpeedRamp,ADCStruc_Type *ADCStruc,Powercontrol_Type *PowerOper,\
Runningstatus_Type *Runningstatus,PID_Structure_Type *Speedpid,_iq24 Speedact);
void KeyandLED_IOInit(void);
void KeyandLED_Parameter_Define(Key_Manager_Type *KeyM,Led_Manager_Type *LEDM);
void KeyandLED_Status_Ini(Key_Manager_Type *KeyM,Led_Manager_Type *LEDM);
void Tempkeycheck(Key_Manager_Type *KeyM);
void Speedkeycheck_Hold(Key_Manager_Type *KeyM,Speedrampctr_Type *Speed_Ramp);
void Speedkeycheck_Recover(Key_Manager_Type *KeyM,Speedrampctr_Type *Speed_Ramp);
void Coldkeycheck(Key_Manager_Type *KeyM);
void Key_Memwrite(Key_Manager_Type *KeyM,Speedrampctr_Type *Speed_Ramp,Flash_Operation_Type *FlashM);
void Key_Memread(Key_Manager_Type *KeyM,Speedrampctr_Type *Speed_Ramp,Flash_Operation_Type *FlashM);
void Fault_LEDflicker(Led_Manager_Type *LED_M);
void Time_Delay_Process(void);
void Time_Wait(uint16_t);
void Time_Delay_Set(uint16_t Delayset, uint16_t *Delaycounter);
Truth_Verify_Type Time_Delay_Elapse(uint16_t Delaycounter);
void Operation_Parameter_Define(Operation_Type *Operastruc);
void Operation_Status_Init(Operation_Type *Operastruc);
void Eventmanager_Initial(Eventmanager_Type *EventM);
void AC_Zerocross_Detect(Key_Manager_Type *KeyM);
void AC_Zerocross_Detect_OC(TRIAC_ctl_Type *TriacM);
void AC_Zerocross_Detect_TR(TRIAC_ctl_Type *TriacM);
void ACZerocross_Process(Temperature_ctl_Type *TempM,Key_Manager_Type *KeyM,TRIAC_ctl_Type *TriacM);
void Event_10ms_Process(Eventmanager_Type *EventM);
void Event_1ms_Process(Eventmanager_Type *EventM);
void Event_2s_Process(Eventmanager_Type *EventM);
void Triac_Parameter_Define(TRIAC_ctl_Type *TriacM,Temperature_ctl_Type *TempM);
void Triac_Status_Init(TRIAC_ctl_Type *TriacM,Temperature_ctl_Type *TempM);
void Temp_Set(Key_Manager_Type *KeyM,Speedrampctr_Type *Speed_Ramp,TRIAC_ctl_Type *TriacM);
void Triac_Control_Process(TRIAC_ctl_Type *TriacM);
void Temp_Ramp_Process(Temperature_ctl_Type *TempM);
void TempInit_Measure(Temperature_ctl_Type *TempM,ADC_TypeDef *ADCx);
void TriacPhAngle_Control_Process(Temperature_ctl_Type *TempM,Key_Manager_Type *KeyM,TRIAC_ctl_Type *TriacM);
void TriacZero_50HZControl_Process(Temperature_ctl_Type *TempM,Key_Manager_Type *KeyM,TRIAC_ctl_Type *TriacM,Speedrampctr_Type *Speed_Ramp);
void Triac_Timeoff(TRIAC_ctl_Type *TriacM);
void ACKEY_CHECK(Key_Manager_Type *KeyM);
void PSC_Process(Operation_Type *Operation);
void Led_Operation(Led_Manager_Type *LEDM);
void SpeedLed_Set(Speedrampctr_Type *Speed_Ramp,Led_Manager_Type *LEDM);
void TempLed_Set(Key_Manager_Type *KeyM,Led_Manager_Type *LEDM);
void LED_OFF(Led_Manager_Type *LEDM);
void LED_Flicker(LED_Type *LedM);
uint16_t Duty_lim(TRIAC_ctl_Type *TriacM,_iq24 value);
#endif
@@ -0,0 +1,425 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : M5_TRIAC_Control.c
* Author : WCH
* Version : V1.0.0
* Date : 2026/04/23
* Description :
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#include "M0_Control_Library.h"
TRIAC_ctl_Type Triac_ctl;
//u16 Temp_PhaseDuty[SPEEDPOINT_RANK][TKEY_RANK_SET+1]={{0,85,110,125},{0,110,125,140},{0,125,145,165}};
_iq24 DutyLim_table[256]=DUTY_LIM_TABLE;
/******************************************************************************
* Function Name : Triac_Parameter_Define
* Description : Silicon Controlled Rectifier Control Parameter Initialization
* Input : Thyristor control pointer Temperature control pointer
* Output : None
* Return : None
******************************************************************************/
void Triac_Parameter_Define(TRIAC_ctl_Type *TriacM,Temperature_ctl_Type *TempM)
{
TriacM->PeriodCtl.NumData=NUM50HZ_DATA;
TriacM->PeriodCtl.Period = (uint16_t)(TRIAC_TIME/TRIAC_CONTOROL_PERIOD);
TriacM->PeriodCtl.HalfPeriod = (TriacM->PeriodCtl.Period -1)/2;
TriacM->PeriodCtl.Serial_Nummax=0;
TriacM->PeriodCtl.Serial_Nummin=0;
TriacM->PeriodCtl.Serial_Num=0;
TriacM->PeriodCtl.Duty_TS=0;
TriacM->PeriodCtl.Dutymax_T1S1=DUTYMAX_T1S1;
TriacM->PeriodCtl.Dutymin_T1S1=DUTYMIN_T1S1;
TriacM->PeriodCtl.Dutydefault_T1S1=DUTYDEFAULT_T1S1;
TriacM->PeriodCtl.Dutymax_T2S1=DUTYMAX_T2S1;
TriacM->PeriodCtl.Dutymin_T2S1=DUTYMIN_T2S1;
TriacM->PeriodCtl.Dutydefault_T2S1=DUTYDEFAULT_T2S1;
TriacM->PeriodCtl.Dutymax_T3S1=DUTYMAX_T3S1;
TriacM->PeriodCtl.Dutymin_T3S1=DUTYMIN_T3S1;
TriacM->PeriodCtl.Dutydefault_T3S1=DUTYDEFAULT_T3S1;
TriacM->PeriodCtl.Dutymax_T1S2=DUTYMAX_T1S2;
TriacM->PeriodCtl.Dutymin_T1S2=DUTYMIN_T1S2;
TriacM->PeriodCtl.Dutydefault_T1S2=DUTYDEFAULT_T1S2;
TriacM->PeriodCtl.Dutymax_T2S2=DUTYMAX_T2S2;
TriacM->PeriodCtl.Dutymin_T2S2=DUTYMIN_T2S2;
TriacM->PeriodCtl.Dutydefault_T2S2=DUTYDEFAULT_T2S2;
TriacM->PeriodCtl.Dutymax_T3S2=DUTYMAX_T3S2;
TriacM->PeriodCtl.Dutymin_T3S2=DUTYMIN_T3S2;
TriacM->PeriodCtl.Dutydefault_T3S2=DUTYDEFAULT_T3S2;
TriacM->PeriodCtl.Dutymax_T1S3=DUTYMAX_T1S3;
TriacM->PeriodCtl.Dutymin_T1S3=DUTYMIN_T1S3;
TriacM->PeriodCtl.Dutydefault_T1S3=DUTYDEFAULT_T1S3;
TriacM->PeriodCtl.Dutymax_T2S3=DUTYMAX_T2S3;
TriacM->PeriodCtl.Dutymin_T2S3=DUTYMIN_T2S3;
TriacM->PeriodCtl.Dutydefault_T2S3=DUTYDEFAULT_T2S3;
TriacM->PeriodCtl.Dutymax_T3S3=DUTYMAX_T3S3;
TriacM->PeriodCtl.Dutymin_T3S3=DUTYMIN_T3S3;
TriacM->PeriodCtl.Dutydefault_T3S3=DUTYDEFAULT_T3S3;
#ifdef ZEROCROSSOVER_OC
TriacM->Zero.Zcrossset=(uint16_t)OC_ZEROCROSS_VERYTIME;//光耦过零
#else
TriacM->Zero.Zcrossset=(uint16_t)TR_ZEROCROSS_VERYTIME;//三极管过零
#endif
TriacM->Zero.Zcrosslostset=(uint16_t)(ZEROCROSSLOST_VERYTIME*ZEROCROSSLOST_VERYFREQ);
TriacM->Zero.SecondZcrossSet=(uint16_t)(ZEROCROSSLOST_VERYFREQ/ZEROCROSS_FREQ);
TriacM->Zero.ZcrossDelayTrigset=(uint16_t)(TRIAC_TIME_TO_TRIGGER*SPEED_LOOP_CAL_FREQ);
TriacM->TonEnable_cntset=(uint16_t)(TRIAC_ENABLEWAIT*TIMER_FREQ_SPEED_LOOP);
TempM->TempRatedADCInv=_IQ(1.0)/65536;
TempM->TempAverSizeInv1 = _IQ(1.0)/TEMP_AVER_SIZE;
TempM->TempAverSizeInv2 = _IQ(1.0) - TempM->TempAverSizeInv1;
}
/******************************************************************************
* Function Name : ZeroCross_Status_Ini
* Description : Silicon-controlled rectifier start-up state initialization
* Input : SCR control structure Temperature control structure
* Output : None
* Return : None
******************************************************************************/
void Triac_Status_Init(TRIAC_ctl_Type *TriacM,Temperature_ctl_Type *TempM)
{
TriacM->Zero.Zcrosscnt = 0;
TriacM->Zero.ZcrossEvent=0;
TriacM->Zero.Zcrosslostcnt=0;
TriacM->Zero.Zcrosslost=FALSE;
TriacM->Zero.Zcrosseffective = FALSE;
TriacM->Zero.ZcrossDelayTrigcnt=0;
TriacM->Zero.Zcrosseffectivecnt=0;
TriacM->Zero.SecondZcrossCnt = 0;
TriacM->Zero.Prestatus = 0;
TriacM->Zero.Aftstatus = 0;
TriacM->Zero.Risingseffective =FALSE;
TriacM->Zero.Inittatus =FALSE;
TriacM->Zero.SecondZsseffective=FALSE;
TriacM->TonEnable_cnt=0;
TriacM->TonEnable=0;
TriacM->ACVoltcaliMin=_IQ(1.0);
TriacM->ACVoltcali=_IQ(1.0);
TriacM->ACVoltcaliPrev=_IQ(1.0);
TriacM->ACVoltcali_Square=_IQ(1.0);
TriacM->PeriodCtl.Cnt=TriacM->PeriodCtl.Period;
TriacM->PeriodCtl.Serial_Num=0;
TriacM->PeriodCtl.DelayProcess_Flag=0;
TriacM->PeriodCtl.DutychangeFlag=FALSE;
}
/******************************************************************************
* Function Name : AC_Zerocross_Detect_OC
* Description : Optocoupler AC Input Zero-Crossing Detection
* Input : SCR control structure pointer
* Output : None
* Return : None
******************************************************************************/
void AC_Zerocross_Detect_OC(TRIAC_ctl_Type *TriacM)
{
if(TriacM->Zero.Zcrosseffective == FALSE)
{
if(GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_3) == 1)
TriacM->Zero.Zcrosscnt++;
else
TriacM->Zero.Zcrosscnt = 0;
if(TriacM->Zero.Zcrosscnt >= TriacM->Zero.Zcrossset)
{
TriacM->Zero.Zcrosseffective = TRUE;
TriacM->Zero.Zcrosscnt=0;
TriacM->Zero.ZcrossEvent=1;
TriacM->Zero.Zcrosslostcnt=0;
TriacM->Zero.Zcrosslost=FALSE;
TriacM->PhaseCtl.Toncnt=0;
TriacM->PhaseCtl.TonStatus=FALSE;
TriacM->PhaseCtl.TonEvent=1;
TriacM->ACVoltcali=TriacM->ACVoltcaliMin;
TriacM->ACVoltcaliMin=ADC_M.DCVoltcali;
}
}
else if((TriacM->Zero.Zcrosseffective == TRUE)&&( TriacM->Zero.ZcrossEvent==0))
{
if(GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_3) == 0)
TriacM->Zero.Zcrosscnt++;
else
TriacM->Zero.Zcrosscnt = 0;
if(TriacM->Zero.Zcrosscnt >= TriacM->Zero.Zcrossset)
{
TriacM->Zero.Zcrosseffective = FALSE;
TriacM->Zero.Zcrosscnt=0;
}
}
TriacM->Zero.Zcrosslostcnt++;
if(TriacM->Zero.Zcrosslostcnt >= TriacM->Zero.Zcrosslostset)
{
TriacM->Zero.Zcrosslost=TRUE;
TriacM->Zero.Zcrosslostcnt=0;
}
}
/******************************************************************************
* Function Name : AC_Zerocross_Detect_TR
* Description : Transistor AC Input Zero-Crossing Detection
* Input : SCR control structure pointer
* Output : None
* Return : None
******************************************************************************/
void AC_Zerocross_Detect_TR(TRIAC_ctl_Type *TriacM)
{
if(TriacM->Zero.Zcrosseffective == FALSE)
{
if(GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_3) == 0)
TriacM->Zero.Zcrosscnt++;
else
TriacM->Zero.Zcrosscnt = 0;
if(TriacM->Zero.Zcrosscnt >= TriacM->Zero.Zcrossset)
{
TriacM->Zero.Zcrosseffective = TRUE;
TriacM->Zero.Zcrosscnt=0;
TriacM->Zero.ZcrossEvent=1;
TriacM->Zero.Zcrosslostcnt=0;
TriacM->Zero.Zcrosslost=FALSE;
TriacM->PhaseCtl.Toncnt=0;
TriacM->PhaseCtl.TonStatus=FALSE;
TriacM->PhaseCtl.TonEvent=1;
TriacM->ACVoltcali=TriacM->ACVoltcaliMin;
TriacM->ACVoltcaliMin=ADC_M.DCVoltcali;
}
}
else if((TriacM->Zero.Zcrosseffective == TRUE)&&( TriacM->Zero.ZcrossEvent==0))
{
if(GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_3) == 1)
TriacM->Zero.Zcrosscnt++;
else
TriacM->Zero.Zcrosscnt = 0;
if(TriacM->Zero.Zcrosscnt >= TriacM->Zero.Zcrossset)
{
TriacM->Zero.Zcrosseffective = FALSE;
TriacM->Zero.Zcrosscnt=0;
}
}
TriacM->Zero.Zcrosslostcnt++;
if(TriacM->Zero.Zcrosslostcnt >= TriacM->Zero.Zcrosslostset)
{
TriacM->Zero.Zcrosslost=TRUE;
TriacM->Zero.Zcrosslostcnt=0;
}
}
/******************************************************************************
* Function Name : TriacZero50HZ_Control_Process
* Description : Thyristor Period Control Processing
* Input : Silicon-controlled rectifier control pointer Temperature gear Temperature control pointer
* Output : None
* Return : None
******************************************************************************/
u_int32_t Triac50hz_Data[30]={0X80100100,0X80804040,0X81020810,0X82084108,0X84422110,0X88888888,0X89122448,0X92249224,\
0XA4924924,0X94949494,0XA4A5294A,0XA92A552A,0XA92B552A,0XAAAAAAAA,0XD5556AAA,0XD5AAD5AA,\
0XB5AD6B5A,0XD6D6D6D6,0XB6DB6DB6,0XDBB6DBB6,0XEDDBB76E,0XEEEEEEEE,0XF77BBDDE,0XF7DEF7DE,\
0XF7DFF7DE,0XFFDFF7DE,0XFFDFFFDE,0XFFFEFFFE,0XFFFFFFFE,0XFFFFFFFF};//占空比9.09%~96.9696%
void TriacZero_50HZControl_Process(Temperature_ctl_Type *TempM,Key_Manager_Type *KeyM,TRIAC_ctl_Type *TriacM,Speedrampctr_Type *Speed_Ramp)
{
_iq24 ACVoltcali;
u32 data=0;
if((TriacM->TonEnable==1)&&(KeyM->Tkey_rank>0)&&( TriacM->Zero.Zcrosslost == FALSE)&&(KeyM->TCkeycold==FALSE)&&\
(TempM->NTCOverStatus==FALSE)&&(TempM->NTCOpenStatus==FALSE)&&\
(RunningStatus_M==RUN)&&(KeyM->Skeystop==FALSE)&&(Operation_M.Faultstop == FALSE))
{
TriacM->PeriodCtl.Cnt++;
if(TriacM->PeriodCtl.Cnt>TriacM->PeriodCtl.Period)
{
TriacM->PeriodCtl.Cnt=1;
if(TriacM->PeriodCtl.DutychangeFlag==TRUE)
{
Temp_Set(KeyM,&SpeedRamp_M,TriacM);
TriacM->PeriodCtl.DutychangeFlag=FALSE;
}
//ACVoltcali= TriacM->ACVoltcali;
ACVoltcali=ADC_M.DCVoltcali;
TriacM->ACVoltcali_Square= _IQmpy(ACVoltcali, ACVoltcali);
TriacM->PeriodCtl.Serial_Num=(u_int8_t)((TriacM->PeriodCtl.Duty_TS*TriacM->ACVoltcali_Square)>>24)-TriacM->PeriodCtl.NumData;
// TriacM->PeriodCtl.Serial_Num=(u_int8_t)(TriacM->PeriodCtl.Duty_TS-TriacM->PeriodCtl.NumData);
if(TriacM->PeriodCtl.Serial_Num>=TriacM->PeriodCtl.Serial_Nummax)
TriacM->PeriodCtl.Serial_Num=TriacM->PeriodCtl.Serial_Nummax;
else if(TriacM->PeriodCtl.Serial_Num<=TriacM->PeriodCtl.Serial_Nummin)
TriacM->PeriodCtl.Serial_Num=TriacM->PeriodCtl.Serial_Nummin;
}
data=Triac50hz_Data[TriacM->PeriodCtl.Serial_Num];
if(TriacM->PeriodCtl.Cnt<TriacM->PeriodCtl.Period)
{
data<<=(TriacM->PeriodCtl.Cnt-1);
if(data&0x80000000)
TRIAC_ON();
else
TRIAC_OFF();
}
else
{
TRIAC_ON();
//TRIAC_OFF();
}
}
else
{
TriacM->PeriodCtl.Cnt=TriacM->PeriodCtl.Period;
TRIAC_OFF();
}
}
u_int32_t Triac100hz_Data1[58]={0X80100100,0X80200802,0X81010100,0X81010402,0X84104080,0X84104104,0X84081041,0X88422081,\
0X21084211,0X22222211,0X11111111,0X22248891,0X88912484,0X92222248,0X89224928,0X92492492,\
0X92492492,0XA9292492,0XA9292492,0XAA924952,0XAA924952,0XA9294AA9,0XAA4954AA,0XAA4AAAAA,\
0XAA4AAAAA,0XAAAAAAAA,0XAAAAAAAA,0X66D55555,0X66D55555,0X66D6D666,0X66D6D666,0X76D6D666,\
0X76D6D666,0X76DB7666,0X76DB7666,0X76DB7766,0X76DB7766,0X776B7767,0X776B7767,0X776B7777,\
0X776B7777,0X77777777,0X77777777,0XF77BDEEE,0XF77BDEEE,0X777F7F77,0X777F7F77,0X777F7F7F,\
0XF77F7F7E,0XF77F7F7F,0XF7FEFEFE,0XF7FFFEFE,0XF7FFFEFE,0XF7FFFEFF,0XFFFEFFFE,0XFFFFFFFE,\
0XFFFFFFFE,0XFFFFFFFF};
/* 6 ~ 13
* 14 ~ 21
* 22 ~ 29
* 30 ~ 37
* 38 ~ 45
* 46 ~ 53
* 54 ~ 61
* 62 ~63
*/
u_int32_t Triac100hz_Data2[58]={0X80100100,0X00804040,0X81010100,0X08041008,0X84104080,0X10404210,0X11041110,0X11041110,\
0X10884442,0X10884442,0X11111111,0X11111111,0X88912444,0X92249224,0X89224928,0X49224928,\
0X92492492,0X92492492,0XA9292492,0XA9292492,0XAA924952,0X29294AAA,0XAA4954AA,0XAA4954AA,\
0XAA4AAAAA,0XAA4AAAAA,0XAAAAAAAA,0X55555555,0X66D55555,0X66D55555,0X66D6D666,0X66D6D666,\
0X76D6D666,0X76D6D666,0X76DB7666,0X76DB7666,0X76DB7766,0X776B5577,0X776B7767,0X776B7767,\
0X776B7777,0X776B7777,0X77777777,0XF777776E,0XF77BDEEE,0X777FDEEE,0X777F7F77,0X777F7F77,\
0XF77F7F7E,0XF77F7F7E,0XF7FEFEFE,0XF7FEFEFE,0XF7FFFEFE,0XF7FFFEFE,0XFFFEFFFE,0XFFFEFFFE,\
0XFFFFFFFE,0XFFFFFFFE};
/******************************************************************************
* Function Name : TriacZero50HZ_Control_Process
* Description : Thyristor Period Control Processing
* Input : Silicon-controlled rectifier control pointer Temperature gear Temperature control pointer
* Output : None
* Return : None
******************************************************************************/
void TriacZero_100HZControl_Process(Temperature_ctl_Type *TempM,Key_Manager_Type *KeyM,TRIAC_ctl_Type *TriacM,Speedrampctr_Type *Speed_Ramp)
{
u32 data=0;
u32 Data1;
u32 Data2;
_iq24 ACVoltcali;
if((TriacM->TonEnable==1)&&(KeyM->Tkey_rank>0)&&( TriacM->Zero.Zcrosslost == FALSE)&&(KeyM->TCkeycold==FALSE)&&\
(TempM->NTCOverStatus==FALSE)&&(TempM->NTCOpenStatus==FALSE)&&\
(RunningStatus_M==RUN)&&(KeyM->Skeystop==FALSE)&&(Operation_M.Faultstop == FALSE))
{
TriacM->PeriodCtl.Cnt++;
if(TriacM->PeriodCtl.Cnt>TriacM->PeriodCtl.Period)//
{
TriacM->PeriodCtl.Cnt=1;
if(TriacM->PeriodCtl.DutychangeFlag==TRUE)
{
Temp_Set(KeyM,&SpeedRamp_M,TriacM);
TriacM->PeriodCtl.DutychangeFlag=FALSE;
}
//根据母线电压峰值矫正占空比
ACVoltcali=ADC_M.DCVoltcali;
TriacM->ACVoltcali_Square= _IQmpy(ACVoltcali, ACVoltcali);
TriacM->PeriodCtl.Serial_Num=(u_int8_t)((TriacM->PeriodCtl.Duty_TS*TriacM->ACVoltcali_Square)>>24)-TriacM->PeriodCtl.NumData;
//TriacM->PeriodCtl.Serial_Num=(u_int8_t)(TriacM->PeriodCtl.Duty_TS-TriacM->PeriodCtl.NumData);
if(TriacM->PeriodCtl.Serial_Num>=TriacM->PeriodCtl.Serial_Nummax)
TriacM->PeriodCtl.Serial_Num=TriacM->PeriodCtl.Serial_Nummax;
else if(TriacM->PeriodCtl.Serial_Num<=TriacM->PeriodCtl.Serial_Nummin)
TriacM->PeriodCtl.Serial_Num=TriacM->PeriodCtl.Serial_Nummin;
}
Data1=Triac100hz_Data1[TriacM->PeriodCtl.Serial_Num];
Data2=Triac100hz_Data2[TriacM->PeriodCtl.Serial_Num];
if(TriacM->PeriodCtl.Cnt<=TriacM->PeriodCtl.HalfPeriod)
{
data=Data1;
data<<=(TriacM->PeriodCtl.Cnt-1);
if(data&0x80000000)
TRIAC_ON();
else
TRIAC_OFF();
}
else if((TriacM->PeriodCtl.Cnt>TriacM->PeriodCtl.HalfPeriod)&&(TriacM->PeriodCtl.Cnt<TriacM->PeriodCtl.Period))//Triac100hz_Data2 1~32 发波
{
data=Data2;
data<<=(TriacM->PeriodCtl.Cnt-1-TriacM->PeriodCtl.HalfPeriod);
if(data&0x80000000)
TRIAC_ON();
else
TRIAC_OFF();
}
else
{
TRIAC_OFF();
}
}
else
{
TriacM->PeriodCtl.Cnt=TriacM->PeriodCtl.Period;
TRIAC_OFF();
}
}
/******************************************************************************
* Function Name : TempInit_Measure
* Description : NTC Temperature Reading
* Input : Temperature Control Body Pointer ADC
* Output : None
* Return : None
******************************************************************************/
void TempInit_Measure(Temperature_ctl_Type *TempM,ADC_TypeDef *ADCx)
{
u8 i;
ADC_ClearFlag(ADCx, ADC_FLAG_JEOC);
ADC_SoftwareStartConvCmd(ADCx, ENABLE);
for(i=0; i <TEMP_AVER_SIZE; i++)
{
while(!ADC_GetFlagStatus(ADCx,ADC_FLAG_EOC));
TempM->TempPres += ((_iq24)((u16)ADCx->RDATAR*(TempM->TempRatedADCInv))>>3);
ADC_ClearFlag(ADCx, ADC_FLAG_JEOC);
ADC_SoftwareStartConvCmd(ADCx,ENABLE);
}
}
@@ -0,0 +1,28 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : M5_Waveform_Configure.c
* Author : WCH
* Version : V1.0.0
* Date : 2026/04/23
* Description :
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#include "M0_Control_Library.h"
/******************************************************************************
* Function Name : Waveform_Display
* Description : Waveform Display Variable Settings
* Input : None
* Return : None
******************************************************************************/
void Waveform_Display (void)
{
sendUsbData.sendDataBuf[sendUsbData.head+0] = (uint16_t)(SVPWM_Cal_M.VoltLimMark*1000);
sendUsbData.sendDataBuf[sendUsbData.head+1] = (uint16_t)(MLBG_M.Cal_Struc.Angspeed_Aver2>>10);
sendUsbData.sendDataBuf[sendUsbData.head+2] = (uint16_t)(ADC_M.DCVoltAver>>10);
sendUsbData.sendDataBuf[sendUsbData.head+3] = (uint16_t)(MStruc_M.CRef2R.cq>>10);
sendUsbData.head += MaxUsbDataLen;
}
@@ -0,0 +1,114 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : M6_CurrentLoop.c
* Author : WCH
* Version : V1.0.0
* Date : 2026/04/23
* Description : ADC sampling result reading, current loop processing, FOC calculation, overcurrent phaseloss protection processing
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#include "M0_Control_Library.h"
void ADC1_2_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
extern void FOC_Cal(Motor_Sructure_Type *MStruc,SVPWM_1R_Type *SVPWM_Cal,Motor_PID_Type *Mpid,\
ADCStruc_Type *ADCStruc,Motor_LBG_Type *MLBG,PWMCali_Type *PWMCali);
uint8_t ADC_1Rsample_Counter_test = 0;
uint8_t Observer_countertest = 0;
/******************************************************************************
* Function Name : ADC1_2_IRQHandler
* Description : ADC1&2 Interrupt response function, read current conversion results
* Input : None
* Output : None
* Return : None
******************************************************************************/
void ADC1_2_IRQHandler(void)
{
// ADC_1Rsample_Counter_test++;
if((ADC1->STATR & ADC_FLAG_JEOC) == ADC_FLAG_JEOC)
{
ADC_M.ADC_Result.Value1= (ADC1->IDATAR1)<<1;
ADC1->STATR = ~(uint32_t)ADC_FLAG_JEOC;
}
if((ADC2->STATR & ADC_FLAG_JEOC) == ADC_FLAG_JEOC)
{
// GPIO_SetBits(GPIOB, GPIO_Pin_8);
ADC_M.ADC_Result.Value2= (ADC2->IDATAR1)<<1;
if(SpeedRamp_M.Break == TRUE)
SVPWM_Lowside_Effective(&SVPWM_Cal_M);
else
{
switch(RunningStatus_M)
{
case POSITION:
HFVQI_PosiSearch_Process(&HFVQI_StartStruc_M,&SVPWM_Cal_M,\
&PWMCali_M,&ADC_M,&InjStart_M,SpeedRamp_M.Direction);
if(HFVQI_StartStruc_M.Finish == TRUE)
{
RunningStatus_M = START;
InjStart_M.Status = RAMP;
}
break;
case START:
Injstart_Process_M(&InjStart_M,&MStruc_M,&MLBG_M);
if (LBG_Status_M.Convergence == TRUE)
{
Controlloop_Initial(&InjStart_M, MLBG_M.Cal_Struc.Angspeed_Aver1,&MStruc_M,&Mpid_M,&SpeedRamp_M);
Time_Delay_Set(Triac_ctl.TonEnable_cntset,&Triac_ctl.TonEnable_cnt);
RunningStatus_M = RUN;
}
FOC_Cal(&MStruc_M,&SVPWM_Cal_M,&Mpid_M,&ADC_M,&MLBG_M,&PWMCali_M);
break;
case RUN:
FOC_Cal(&MStruc_M,&SVPWM_Cal_M,&Mpid_M,&ADC_M,&MLBG_M,&PWMCali_M);
if(Triac_ctl.TonEnable==0)
{
if(Time_Delay_Elapse(Triac_ctl.TonEnable_cnt) == TRUE)
Triac_ctl.TonEnable=1;
}
#ifdef ZEROCROSSOVER_OC
AC_Zerocross_Detect_OC(&Triac_ctl);
#else
AC_Zerocross_Detect_TR(&Triac_ctl);
#endif
break;
default:
break;
}
if ( ((RunningStatus_M==START)||(RunningStatus_M==RUN))&&(Powerctr_M.Poweron == TRUE) )
{
if(Phaseloss_Verify(&(MStruc_M.C3S),&Phaseloss_M ,SVPWM_Cal_M.sector))
Protection_SetFault(PHASELOSS_FALUT);
}
}
ADC_Trigger_Update(&PWMCali_M);
SVPWM_Updateup(&SVPWM_Cal_M, &PWMCali_M);
if ((RunningStatus_M==START)||(RunningStatus_M==RUN))
{
if(Phase_Ins_OverCurrent_Verify(&(MStruc_M.C3S),&InstPhaseOC_M) == TRUE)
Protection_SetFault(MOTOR_OVER_CURR_SOFT_M);
}
Break_Verify(&Powerctr_M,&SpeedRamp_M,&RunningStatus_M,&ADC_M);
ADC_SoftwareStartConvCmd(ADC2, ENABLE);
ADC_SoftwareStartConvCmd(ADC1, ENABLE);
ADC2->STATR = ~(uint32_t)ADC_FLAG_JEOC;
// GPIO_ResetBits(GPIOB, GPIO_Pin_8);
}
}
@@ -0,0 +1,20 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : M6_CurrentLoop.h
* Author : WCH
* Version : V1.0.0
* Date : 2026/04/23
* Description : current loop processing
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#ifndef __M6_CURRENTLOOP_H
#define __M6_CURRENTLOOP_H
extern uint8_t ADC_1Rsample_Counter_test;
extern uint8_t Observer_countertest;
#endif
@@ -0,0 +1,157 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : M6_SpeedLoop.c
* Author : WCH
* Version : V1.0.0
* Date : 2026/04/23
* Description : Speed loop processing, related protection treatment, power up and down control processing
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#include "M0_Control_Library.h"
void SysTick_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
static uint8_t Speed_Sample_PID_CNT = SPEED_SAMPLE_PID_PERIOD;
/******************************************************************************
* Function Name : SysTick_Handler
* Description : Speed loop processing interrupt
* Input : None
* Output : None
* Return : None
******************************************************************************/
void SysTick_Handler(void)
{
Speed_Sample_PID_CNT --;
Time_Delay_Process();
Led_Operation(&LED_M);
Poweroperation_Process(&SpeedRamp_M,&ADC_M,&Powerctr_M,&RunningStatus_M,&(Mpid_M.Speed),\
MLBG_M.Cal_Struc.Angspeed_Aver2);
NTCSample(&Tempctl_M,ADC1);
Coldkeycheck(&Key_M);
Tempkeycheck(&Key_M);
ACKEY_CHECK(&Key_M);
if(RunningStatus_M == IDLE)
PSC_Process(&Operation_M);
if((Operation_M.PSC.Mark == FALSE)&&(Operation_M.PSC.Process ==TRUE))
Speedkeycheck_Recover(&Key_M,&SpeedRamp_M);
Event_1ms_Process(&Emanager_M);
ACZerocross_Process(&Tempctl_M,&Key_M,&Triac_ctl);
if (Speed_Sample_PID_CNT == 0 )
{
Speed_Sample_PID_CNT = SPEED_SAMPLE_PID_PERIOD;
Buffer_Update(&(LBG_SpeedBuffer_M[0]), &(MLBG_M.SpeedBuffPara), MLBG_M.Cal_Struc.Angspeed_Inst);
MLBG_M.Cal_Struc.Angspeed_Aver1 = LPF_1st_Process(&(MLBG_M.Cal_Struc.SpeedLPF1st_M),\
MLBG_M.Cal_Struc.Angspeed_Inst);
LBG_Status_M.Reliable = Speed_Reliable_Verify(&(MLBG_M.SpeedBuffPara),&LBG_SpeedBuffer_M[0],\
MLBG_M.Cal_Struc.Angspeed_Aver1,LBG_Status_M.VarianceThresh);
switch(RunningStatus_M)
{
case START:
if(_IQabs(InjStart_M.RampInjSpeedTarget)<_IQ(0.2))
LBG_Status_M.Reliable = TRUE;
Speed_Converged_Verify1(InjStart_M.RampInjSpeedRef, &MLBG_M, &LBG_Status_M);
break;
case RUN:
if(SpeedRamp_M.Break == FALSE)
{
if((Key_M.Skeystop == FALSE)&&(Operation_M.Faultstop == FALSE)&&(Powerctr_M.Poweron == TRUE))
{
VDC_Limitspeed(&SpeedRamp_M,&ADC_M,&Powerctr_M);
}
if(Powerctr_M.Poweron == TRUE)
Speed_Ramp_Process(&SpeedRamp_M);
else
Poweroff_Speed_Ramp_Process(&SpeedRamp_M);
if(STARTUP_DIRECTION==1)
SpeedRamp_M.Aftrampcom = SpeedRamp_M.Aftramp + Powercom_M.Speedcom;
else if(STARTUP_DIRECTION==-1)
SpeedRamp_M.Aftrampcom = SpeedRamp_M.Aftramp - Powercom_M.Speedcom;
Speed_Stable_Verify(&LBG_Status_M, MLBG_M.Cal_Struc.Angspeed_Aver1);
if(LBG_Status_M.Stable==FALSE)
Protection_SetFault(SPEED_ABNORMAL_M);
Motor_Stall_Verify1(SpeedRamp_M.Aftramp, &MLBG_M, MStruc_M.CRef2R.cq,&LBG_Status_M);
if(LBG_Status_M.Stall==TRUE)
Protection_SetFault(MOTOR_STALL_M);
MStruc_M.CRef2R.cq = PID_Calculaion_Delta (SpeedRamp_M.Aftrampcom, MLBG_M.Cal_Struc.Angspeed_Aver2, &(Mpid_M.Speed));
if((DCurrProcess_M.Stage == 1)&&(_IQabs(MStruc_M.CRef2R.cd) <= DCurrProcess_M.Target1))
Dcurr_Process_Init(&DCurrProcess_M,2);
MStruc_M.CRef2R.cd = Dcurr_Process(&DCurrProcess_M, MLBG_M.Cal_Struc.Angspeed_Aver1, MStruc_M.CRef2R.cd);
}
break;
default:
break;
}
}
DCOvervolt_Protection(ADC_M.DCVoltAver, &DCBusProtecion_M);
DCUndervolt_Protection1(ADC_M.DCVoltAver, &DCBusProtecion_M,&Powerctr_M);
NTC_Protection(&Tempctl_M,Tempctl_M.TempAver);
SysTick->SR &= ~(1 << 0);
}
/************************************************************************************************************
* Function Name : Systick_Init
* Description : Systick Init
* Input : NewState - ENABLE or DISABLE.
* Output : None
* Return : None
*************************************************************************************************************/
void Systick_Init(void)
{
SysTick->CTLR =0;
SysTick->CMP =0;
SysTick->SR &= ~(1 << 0);
SysTick->CNT = 0;
SysTick->CMP = TIMER_PERIDO_SYSTICK;
SysTick->CTLR |=(1 << 1)|(1 << 3)|(1 << 5);
}
/************************************************************************************************************
* Function Name : SYS_TIM_Cmd
* Description : SysTick Enable
* Input : NewState - ENABLE or DISABLE.
* Output : None
* Return : None
*************************************************************************************************************/
void SYS_TIM_Cmd(FunctionalState NewState)
{
if(NewState != DISABLE)
{
SysTick->CTLR |= TIM_CEN;
}
else
{
SysTick->CTLR &= (uint16_t)(~((uint16_t)TIM_CEN));
}
}
@@ -0,0 +1,32 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : M6_SpeedLoop.h
* Author : WCH
* Version : V1.0.0
* Date : 2026/04/23
* Description : The speed loop is defined by timer parameters and control counting parameters.
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#ifndef __M6_SPEEDLOOP_H
#define __M6_SPEEDLOOP_H
#define TIMER_CLOCK_FREQ_SPEED 144000000uL
#define TIMER_FREQ_SPEED_LOOP 2000
#define TIMER_PERIDO_SYSTICK TIMER_CLOCK_FREQ_SPEED / (u32)(TIMER_FREQ_SPEED_LOOP*8)
#define TIMER_PRESCALER_SPEED_LOOP 17
#define SPEED_LOOP_CAL_FREQ 2000
#define SPEED_LOOP_CAL_PERIOD _IQ(1.0)/SPEED_LOOP_CAL_FREQ
#define SPEED_SAMPLE_PID_PERIOD TIMER_FREQ_SPEED_LOOP/SPEED_LOOP_CAL_FREQ
#define LED_PERIOD 4
//void Timer4_Init(void);
void Systick_Init(void);
void SYS_TIM_Cmd(FunctionalState NewState);
#endif
@@ -0,0 +1,159 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : M7_Interrupt.c
* Author : WCH
* Version : V1.0.0
* Date : 2026/04/23
* Description : Interrupt configuration
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#include "M0_Control_Library.h"
void TIM1_UP_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void TIM1_BRK_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void NMI_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void HardFault_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void Observer_Calibration(Motor_Sructure_Type *MStruc,SVPWM_1R_Type *SVPWM_Cal,Motor_PID_Type *Mpid,\
ADCStruc_Type *ADCStruc,Motor_LBG_Type *MLBG,PWMCali_Type *PWMCali);
uint8_t Timer1_Interrupt_Count_test = 0;
/******************************************************************************
* Function Name : Interrupt_Configuration
* Description : Interrupt Priority Configuration
* Input : None
* Output : None
* Return : None
******************************************************************************/
void Interrupt_Configuration(void)
{
NVIC_InitTypeDef NVIC_InitStructure;
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
NVIC_InitStructure.NVIC_IRQChannel = ADC_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
NVIC_InitStructure.NVIC_IRQChannel = TIM1_UP_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
NVIC_InitStructure.NVIC_IRQChannel = TIM1_BRK_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
TIM_ClearITPendingBit(TIM1, TIM_IT_Break);
TIM_ITConfig(TIM1, TIM_IT_Break,ENABLE);
NVIC_InitStructure.NVIC_IRQChannel = SysTicK_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
/******************************************************************************
* Function Name : TIM1_UP_IRQHandler
* Description : Timer 1 overflow interrupt, processing waveform data output
* Input : None
* Output : None
* Return : None
******************************************************************************/
void TIM1_UP_IRQHandler(void)
{
if( RunningStatus_M ==PRESTART)
{
if(Time_Delay_Elapse(SpeedRamp_M.Precharge_cnt) == TRUE)
{
ADC_1R_Start(ENABLE);
RunningStatus_M = POSITION;
}
}
if((RunningStatus_M == POSITION)||(RunningStatus_M == START)||(RunningStatus_M == RUN))
SVPWM_Updatedown(&SVPWM_Cal_M, &PWMCali_M);
else
{
ADC_SoftwareStartConvCmd(ADC2, ENABLE);
ADC_SoftwareStartConvCmd(ADC1, ENABLE);
}
DCBUS_Volt_Cal(&ADC_M,ADC2);
ADC_M.DCVoltcali= (_IQdiv(_IQ(1.0),ADC_M.DCVolt_Filter));
if(RunningStatus_M == RUN)
{
if ((ADC_M.DCVoltcali<Triac_ctl.ACVoltcaliPrev)&&(Triac_ctl.ACVoltcaliMin>ADC_M.DCVoltcali))
Triac_ctl.ACVoltcaliMin=ADC_M.DCVoltcali;
}
else
{
Triac_ctl.ACVoltcaliPrev= ADC_M.DCVoltcali;
Triac_ctl.ACVoltcaliMin=ADC_M.DCVoltcali;
}
#ifdef PHASEANGLE_CONTROL
Triac_Control_Process(&Triac_ctl);
#endif
if(SpeedRamp_M.Break == FALSE)
{
if((RunningStatus_M == START)||(RunningStatus_M == RUN))
{
Observer_Calibration(&MStruc_M,&SVPWM_Cal_M,&Mpid_M,&ADC_M,&MLBG_M,&PWMCali_M);
}
}
// Waveform_Display();
//GPIO_SetBits(GPIOD, GPIO_Pin_0);
Powercom_Process(&Powercom_M,&MStruc_M,&Powerctr_M,&SpeedRamp_M);
if(RunningStatus_M == RUN)
{
Triac_ctl.ACVoltcaliPrev= ADC_M.DCVoltcali;
PeakDCOvervolt_Protection(ADC_M.DCVolt_Filter,&DCBusProtecion_M);
}
TIM_ClearFlag(TIM1, TIM_FLAG_Update);
}
/******************************************************************************
* Function Name : TIM1_BRK_IRQHandler
* Description : Brake interruption, set fault
* Input : None
* Output : None
* Return : None
******************************************************************************/
void TIM1_BRK_IRQHandler(void)
{
Protection_SetFault(DC_OVER_CURR_HARD_M);
TIM_ClearITPendingBit(TIM1, TIM_IT_Break);
}
/*******************************************************************************
* Function Name : NMI_Handler
* Description : This function handles NMI exception.
* Input : None
* Return : None
*******************************************************************************/
void NMI_Handler(void)
{
}
/*******************************************************************************
* Function Name : HardFault_Handler
* Description : This function handles Hard Fault exception.
* Input : None
* Return : None
*******************************************************************************/
void HardFault_Handler(void)
{
while (1)
{
//NVIC_SystemReset();
}
}
@@ -0,0 +1,19 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : M7_Interrupt.h
* Author : WCH
* Version : V1.0.0
* Date : 2026/04/23
* Description : Interrupt configuration, waveform display
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#ifndef __M7_INTERRUPT_H
#define __M7_INTERRUPT_H
extern uint8_t Timer1_Interrupt_Count_test;
void Interrupt_Configuration(void);//ÖжÏÕûÌåÅäÖÃ
#endif
@@ -0,0 +1,330 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : M8_Protection.c
* Author : WCH
* Version : V1.0.0
* Date : 2026/04/23
* Description : Protection parameter initialization, protection state setting
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#include "M0_Control_Library.h"
InstPhaseOC_Type InstPhaseOC_M;
DCbusProtection_Type DCBusProtecion_M;
OverLoad_Type Overload_M;
LPF_First_Order_Type OverloadLPF1st_M;
Phaseloss_Type Phaseloss_M;
/******************************************************************************
* Function Name : Protection_and_Emergency_Parameter_Define
* Description : Fault protection parameter initialization
* Input : None
* Output : None
* Return : None
******************************************************************************/
void Protection_and_Emergency_Parameter_Define (void)
{
InstPhaseOC_M.Cnt = 0;
InstPhaseOC_M.CurrThreshold = INST_PHASEOC_THRE_M;
InstPhaseOC_M.CntThreshold = INST_PHASEOC_CNT_THRE_M;
DCBusProtecion_M.OverThresh = DCBUS_OVER_VOLT_THRE;
DCBusProtecion_M.UnderThresh = DCBUS_UNDER_VOLT_THRE;
DCBusProtecion_M.OverCntThresh = DCBUS_OVER_VOLT_CNT;
DCBusProtecion_M.UnderCntThresh = DCBUS_UNDER_VOLT_CNT;
DCBusProtecion_M.OverCnt = 0;
DCBusProtecion_M.UnderCnt = 0;
DCBusProtecion_M.Overvolt = FALSE;
DCBusProtecion_M.Undervolt = FALSE;
DCBusProtecion_M.PeakOverCnt=0;
DCBusProtecion_M.PeakOverCntThresh=PEAKDCBUS_OVER_VOLT_CNT;
DCBusProtecion_M.PeakOverDetectiontime=(u_int16_t)(PEAKDCBUS_OVER_VOLT_DETECTIONTIME*FREQ_SVPWM);
DCBusProtecion_M.PeakOverDetectiontCnt=0;
Overload_M.CurrThresh = OVERLOAD_CURR_THRE;
Overload_M.CalCoef = OVERLOAD_CAL_COEF;
Overload_M.CntThresh = (uint16_t)(OVERLOAD_TIME_THRE*OVERLOAD_CAL_FREQ);
Overload_M.Cnt = 0;
Overload_M.CurrCal = 0;
OverloadLPF1st_M.Input_Coef = _IQdiv(OVERLOADLPF_WcT_M,(OVERLOADLPF_WcT_M + UNIT_Q24));
OverloadLPF1st_M.Output_Coef = _IQdiv(UNIT_Q24,(OVERLOADLPF_WcT_M + UNIT_Q24));
Phaseloss_M.CurrThresh = PHASELOSS_CURR_THRE;
Phaseloss_M.CntThresh = (uint16_t)(PHASELOSS_TIME_THRE * PHASELOSS_CAL_FREQ);
Phaseloss_M.MultiphaseCnt = 0;
Phaseloss_M.SiglephaseCntA = 0;
Phaseloss_M.SiglephaseCntB = 0;
Phaseloss_M.SiglephaseCntC = 0;
Phaseloss_M.CurrBuffPara.Length = PHASELOSS_CAL_BUFFSIZE;
Phaseloss_M.CurrBuffPara.Inv1 = _IQ(1.0)/PHASELOSS_CAL_BUFFSIZE;
Phaseloss_M.CurrBuffPara.Inv2 = _IQ(1.0) - Phaseloss_M.CurrBuffPara.Inv1;
Tempctl_M.NTCOverThresh = NTC_OVERTEMP_RATEADC;
Tempctl_M.NTCOpenThresh = NTC_OPENTEMP_RATEADC;
Tempctl_M.NTCOverCntThresh = (uint16_t)(TEMP_OVER_TIME*NTC_VERIFY_FREQ);
Tempctl_M.NTCOpenCntThresh = (uint16_t)(NTC_OPEN_TIME*NTC_VERIFY_FREQ);
Tempctl_M.NTCOverCnt = 0;
Tempctl_M.NTCOpenCnt = 0;
Tempctl_M.NTCOpenStatus =FALSE;
Tempctl_M.NTCOverStatus =FALSE;
}
/******************************************************************************
* Function Name : Protection_and_Emergency_Init
* Description : Fault protection parameter initialization
* Input : None
* Output : None
* Return : None
******************************************************************************/
void Protection_and_Emergency_Init ()
{
InstPhaseOC_M.Cnt = 0;
DCBusProtecion_M.OverCnt = 0;
DCBusProtecion_M.UnderCnt = 0;
DCBusProtecion_M.Overvolt = FALSE;
DCBusProtecion_M.Undervolt = FALSE;
DCBusProtecion_M.PeakOverDetectiontCnt=0;
DCBusProtecion_M.PeakOverCnt=0;
Overload_M.Cnt = 0;
Overload_M.CurrCal = 0;
Phaseloss_M.MultiphaseCnt = 0;
Phaseloss_M.SiglephaseCntA = 0;
Phaseloss_M.SiglephaseCntB = 0;
Phaseloss_M.SiglephaseCntC = 0;
// Tempctl_M.NTCOverCnt = 0;
// Tempctl_M.NTCOpenCnt = 0;
// Tempctl_M.NTCOverHysteresisCnt = 0;
// Tempctl_M.NTCOverRecoverCnt = 0;
// Tempctl_M.NTCOpenStatus =FALSE;
// Tempctl_M.NTCOverStatus =FALSE;
// Tempctl_M.NTCOverHysStatus =FALSE;
Tempctl_M.NTCFlickerStatus =FALSE;
}
/******************************************************************************
* Function Name : Protection_SetFault
* Description : Fault Setting
* Input : Fault type
* Output : None
* Return : None
******************************************************************************/
void Protection_SetFault(uint16_t Fault_type)
{
Time_Delay_Set(Operation_M.FaultHoldingSet,&(Operation_M.FaultHoldingCnt));
TIM_CtrlPWMOutputs(TIM1, DISABLE);
TRIAC_OFF();
RunningStatus_M = FAULT;
System_Status_Global |= Fault_type;
}
/******************************************************************************
* Function Name : Protction_Fault_Reset_M
* Description : Fault Reset
* Input : None
* Output : None
* Return : None
******************************************************************************/
void Protction_Fault_Reset_M(void)
{
if (Time_Delay_Elapse(Operation_M.FaultHoldingCnt))
{
System_Status_Global &= ~STARTUP_FAILURE_M;
System_Status_Global &= ~SPEED_ABNORMAL_M;
LBG_Status_M.Unstable_CNT = 0;
System_Status_Global &= ~MOTOR_OVER_CURR_SOFT_M;
InstPhaseOC_M.Cnt = 0;
System_Status_Global &= ~MOTOR_OVERLOAD_M;
Overload_M.Cnt = 0;
if (GPIO_ReadInputDataBit(BRK_GPIO_M, BRK_PIN_M))
System_Status_Global &= ~DC_OVER_CURR_HARD_M;
System_Status_Global &= ~MOTOR_STALL_M;
LBG_Status_M.Stall_CNT = 0;
System_Status_Global &= ~PHASELOSS_FALUT;
LBG_Status_M.Stall_CNT = 0;
System_Status_Global &= ~NTC_OVER_ERR;
Tempctl_M.NTCOverCnt =0;
Tempctl_M.NTCOverStatus =FALSE;
System_Status_Global &= ~NTC_OPEN_ERR;
Tempctl_M.NTCOpenCnt =0;
Tempctl_M.NTCOpenStatus =FALSE;
if((System_Status_Global&DC_OVER_VOLT)==DC_OVER_VOLT)
{
if(ADC_M.DCVolt_Filter < DCBusProtecion_M.OverThresh)
{
System_Status_Global&= ~DC_OVER_VOLT;
DCBusProtecion_M.OverCnt = 0;
}
}
if((System_Status_Global&DC_OVER_VOLT)==DC_UNDER_VOLT)
{
if(ADC_M.DCVolt_Filter > DCBusProtecion_M.UnderThresh)
{
System_Status_Global&= ~DC_UNDER_VOLT;
DCBusProtecion_M.UnderCnt = 0;
}
}
}
if ( (System_Status_Global & (STARTUP_FAILURE_M |SPEED_ABNORMAL_M | MOTOR_OVER_CURR_SOFT_M | MOTOR_OVERLOAD_M\
| DC_OVER_CURR_HARD_M | MOTOR_STALL_M |PHASELOSS_FALUT|NTC_OVER_ERR|NTC_OPEN_ERR| DC_OVER_VOLT | DC_UNDER_VOLT)) == 0 )
{
RunningStatus_M = IDLE;
System_Status_Global |= FIRST_START_M;
}
}
/******************************************************************************
* Function Name : DCOvervolt_Protection
* Description : Bus Overvoltage Protection
* Input : Detect bus voltage, voltage protection structure pointer
* Output : None
* Return : None
******************************************************************************/
void DCOvervolt_Protection(_iq24 DCVolt, DCbusProtection_Type *DCbusProtec)
{
if (DCVolt >= DCbusProtec->OverThresh)
DCbusProtec->OverCnt++;
else
DCbusProtec->OverCnt = 0;
if(DCbusProtec->OverCnt > DCbusProtec->OverCntThresh)
{
DCBusProtecion_M.Overvolt = TRUE;
Protection_SetFault(DC_OVER_VOLT);//ĸÏß¹ýѹ
}
}
/******************************************************************************
* Function Name : PeakDCOvervolt_Protection
* Description : Peak bus overvoltage protection
* Input : Detect bus voltage, voltage protection structure pointer
* Output : None
* Return : None
******************************************************************************/
void PeakDCOvervolt_Protection(_iq24 DCVolt, DCbusProtection_Type *DCbusProtec)
{
DCbusProtec->PeakOverDetectiontCnt++;
if(DCbusProtec->PeakOverDetectiontCnt<DCbusProtec->PeakOverDetectiontime)
{
if (DCVolt >= DCbusProtec->OverThresh)
DCbusProtec->PeakOverCnt++;
if(DCbusProtec->PeakOverCnt > DCbusProtec->PeakOverCntThresh)
{
DCBusProtecion_M.Overvolt = TRUE;
Protection_SetFault(DC_OVER_VOLT);
}
}
else
{
DCbusProtec->PeakOverCnt=0;
DCbusProtec->PeakOverDetectiontCnt=0;
}
}
/******************************************************************************
* Function Name : DCUndervolt_Protection
* Description : Bus Undervoltage Protection
* Input : Detect bus voltage, voltage protection structure pointerv
* Output : None
* Return : None
******************************************************************************/
void DCUndervolt_Protection(_iq24 DCVolt, DCbusProtection_Type *DCbusProtec)
{
if (DCVolt <= DCbusProtec->UnderThresh)
DCbusProtec->UnderCnt++;
else
DCbusProtec->UnderCnt = 0;
if(DCbusProtec->UnderCnt > DCbusProtec->UnderCntThresh)
{
DCBusProtecion_M.Undervolt = TRUE;
Protection_SetFault(DC_UNDER_VOLT);
}
}
/******************************************************************************
* Function Name : DCUndervolt_Protection
* Description : Bus Undervoltage Protection
* Input : Detect bus voltage, voltage protection structure pointer
* Output : None
* Return : None
******************************************************************************/
void DCUndervolt_Protection1(_iq24 DCVolt, DCbusProtection_Type *DCbusProtec,Powercontrol_Type *PowerOper)
{
if (((DCVolt <= DCbusProtec->UnderThresh)||(PowerOper->Poweron==FALSE))&&(Key_M.ACkey_Poweron == TRUE))
{
if(DCbusProtec->UnderCnt<U16_MAX)
DCbusProtec->UnderCnt++;
}
else
DCbusProtec->UnderCnt = 0;
if(DCbusProtec->UnderCnt > DCbusProtec->UnderCntThresh)
{
Protection_SetFault(DC_UNDER_VOLT);
DCBusProtecion_M.Undervolt = TRUE;
}
}
/******************************************************************************
* Function Name : NTC_Protection
* Description : NTC Protection
* Input : Temperature control structure pointer
* Output : None
* Return : None
******************************************************************************/
void NTC_Protection(Temperature_ctl_Type *Temctl,_iq24 Temp)
{
if(Temp < Temctl->NTCOverThresh)
{
if(Temctl->NTCOverCnt<=U16_MAX)
Temctl->NTCOverCnt ++;
}
else
Temctl->NTCOverCnt =0;
if(Temctl->NTCOverCnt >= Temctl-> NTCOverCntThresh)
{
Temctl->NTCOverStatus = TRUE;
Protection_SetFault(NTC_OVER_ERR);
}
if(Temp > Temctl->NTCOpenThresh)
{
if(Temctl->NTCOpenCnt<=U16_MAX)
Temctl->NTCOpenCnt ++;
}
else
Temctl->NTCOpenCnt =0;
if(Temctl->NTCOpenCnt >= Temctl-> NTCOpenCntThresh)
{
Temctl->NTCOpenStatus = TRUE;
Protection_SetFault(NTC_OPEN_ERR);
}
}
@@ -0,0 +1,95 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : M8_Protection.h
* Author : WCH
* Version : V1.0.0
* Date : 2026/04/23
* Description : Protection parameter definition
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#ifndef __M8_PROTECTION_H
#define __M8_PROTECTION_H
#define INST_PHASEOC_THRE_M _IQ(1.3)
#define INST_PHASEOC_CNT_THRE_M (uint16_t)5
#define DCBUS_OVER_VOLT_THRE _IQ(1.175)
#define DCBUS_UNDER_VOLT_THRE _IQ(0.72)
#define DCBUS_OVER_VOLT_CNT (uint16_t)500
#define DCBUS_UNDER_VOLT_CNT (uint16_t)3000
#define PEAKDCBUS_OVER_VOLT_CNT (uint16_t)1500
#define PEAKDCBUS_OVER_VOLT_DETECTIONTIME 0.3
#define NTC_OVERHYSTERESIS_TEMP_TIME 5
#define NTC_OVERTEMP_OHM _IQ18(0.8844)
#define NTC_OVERTEMP_RATEADC _IQ18toIQ(_IQ18div(NTC_OVERTEMP_OHM , NTC_OVERTEMP_OHM + PT_RS))
#define NTC_OPENTEMP_OHM _IQ18(981.5699)
#define NTC_OPENTEMP_RATEADC _IQ18toIQ(_IQ18div(NTC_OPENTEMP_OHM , NTC_OPENTEMP_OHM + PT_RS))
#define NTC_VERIFY_FREQ TIMER_FREQ_SPEED_LOOP
#define TEMP_OVER_TIME 0.1
#define NTC_OPEN_TIME 0.1
#define OVERLOAD_CURR_THRE _IQ(1.1)
#define OVERLOAD_TIME_THRE 0.5
#define OVERLOAD_CAL_FREQ TIMER_FREQ_SPEED_LOOP
#define OVERLOAD_CAL_COEF _IQ(1/1.91)
#define OVERLOADLPF_CF_M 500
#define OVERLOADLPF_WcT_M (PI_2_Q24/OVERLOAD_CAL_FREQ)*OVERLOADLPF_CF_M
#define PHASELOSS_CURR_THRE _IQ(0.1)
#define PHASELOSS_TIME_THRE 0.1
#define PHASELOSS_CAL_FREQ FREQ_SVPWM
#define PHASELOSS_CAL_BUFFSIZE 32
#define PHASELOSS_CNT_THRE 3
/* Exported variables -------------------------------------------------------*/
extern InstPhaseOC_Type InstPhaseOC_M;
extern DCbusProtection_Type DCBusProtecion_M;
extern OverLoad_Type Overload_M;
extern LPF_First_Order_Type OverloadLPF1st_M;
extern Phaseloss_Type Phaseloss_M;
/* Exported macro -----------------------------------------------------------*/
/* Exported functions -------------------------------------------------------*/
void Protection_and_Emergency_Parameter_Define (void);
void Protection_and_Emergency_Init (void);
void Protection_SetFault(uint16_t Fault_type);
void Protction_Fault_Reset_M(void);
Truth_Verify_Type Phase_Ins_OverCurrent_Verify (Component_3S_Type *PhaseABC, InstPhaseOC_Type * InstOC);
void DCOvervolt_Protection(_iq24 DCVolt, DCbusProtection_Type *DCbusProtec);
void DCUndervolt_Protection(_iq24 DCVolt, DCbusProtection_Type *DCbusProtec);
void DCUndervolt_Protection1(_iq24 DCVolt, DCbusProtection_Type *DCbusProtec,Powercontrol_Type *PowerOper);
void Speed_Outrange_Verify(_iq24 Speedref, _iq24 Speedact, Observer_Status_Type *Status);
Truth_Verify_Type Speed_Reliable_Verify(BuffPara_Type *Buffpara,_iq24 *Buffer,_iq24 Averspeed,_iq24 Threshold);
void Speed_Stable_Verify(Observer_Status_Type *Status,_iq24 Speedact);
void Motor_Stall_Verify1(_iq24 Speedref, Motor_LBG_Type *MLBG,_iq24 Iqref, Observer_Status_Type *Status);
void Motor_Stall_Verify2(_iq24 Speedref, _iq24 Speedact , _iq24 Iqref, Observer_Status_Type *Status);
void Motor_Reverse_Verify(_iq24 Speedref, _iq24 Speedact, Observer_Status_Type *Status);
void Speed_Converged_Verify1(_iq24 Speedref,Motor_LBG_Type *MLBG,Observer_Status_Type *Status);
void Speed_Converged_Verify2(_iq24 Speedref,_iq24 Speedact,Observer_Status_Type *Status);
Truth_Verify_Type OverLoad_Verify (Component_3S_Type *PhaseABC, OverLoad_Type * Overload, LPF_First_Order_Type * LPF);
Truth_Verify_Type Phaseloss_Verify (Component_3S_Type *PhaseABC,Phaseloss_Type *Phaseloss, uint8_t PWMsector);
void NTC_Protection(Temperature_ctl_Type *Temctl,_iq24 Temp);
void PeakDCOvervolt_Protection(_iq24 DCVolt, DCbusProtection_Type *DCbusProtec);
#endif
@@ -0,0 +1,110 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : M9_Appication_Blocks.h
* Author : WCH
* Version : V1.0.0
* Date : 2026/04/23
* Description : Standard application module declaration
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __M9_APPLICATION_BLOCKS_H
#define __M9_APPLICATION_BLOCKS_H
#define POWERCOM_FREQ_M FREQ_SVPWM
#define POWERCOM_PERIOD_M _IQ(1.0)/FREQ_SVPWM
#define POWERCOM_HPF1st_CF_M 10
#define POWERCOM_HPF1st_WcT_M _IQmpy(_IQmpyI32(POWERCOM_PERIOD_M,POWERCOM_HPF1st_CF_M),PI_2_Q24)
#define POWERCOM_LPF1st_CF_M 1000
#define POWERCOM_LPF1st_WcT_M _IQmpy(_IQmpyI32(POWERCOM_PERIOD_M,POWERCOM_LPF1st_CF_M),PI_2_Q24)
#define POWERCOM_STARTTIME_M 0.5
#define POWERCOM_SPEEDCLOSETIME_M 0.1
#define POWERCOM_SPEEDERRTHRE_M _IQ(0.01)
#define POWERCOM_VOLT_THRESHOLD_M _IQ(0.75)
#define POWERCOM_KP _IQ(0.5)
#define POWERCOM_KIT _IQ(0.0)//0.000001
#define POWERCOM_KD _IQ(0.0)
#define POWERCOM_KPADJ1_M _IQ(1.0)
#define POWERCOM_KPADJ2_M _IQ(1.0)
#define POWERCOM_KPADJ3_M _IQ(1.0)
#define POWERCOM_ULIM_M _IQ(0.012)
#define POWERCOM_LLIM_M _IQ(-0.012)
#define POWERCOM_DLIM_M _IQ(0.01)
/* Exported variables -------------------------------------------------------*/
extern Powercom_type Powercom_M;
/* Exported macro -----------------------------------------------------------*/
/* Exported functions--------------------------------------------------------*/
//PID¼ÆËã
_iq24 PID_Calculaion_Delta(_iq24 hReference, _iq24 hFeedback, PID_Structure_Type *PID_Struct);
_iq24 PID_Calculaion_Abs(_iq24 hReference, _iq24 hFeedback, PID_Structure_Type *PID_Struct);
Struct_Cossin_Type TrigonoMetric_Function(_iq24 Angle_PU);
Component_2S_Type Clark_TransForm(Component_3S_Type *Input3s);
Component_2R_Type Park_TransForm(Component_2S_Type *Input2s,Struct_Cossin_Type *Struct_Cossin);
Component_2S_Type Rev_Park_TransForm(Component_2R_Type *Input2r,Struct_Cossin_Type *Struct_Cossin);
Component_2R_Type ComponentLimit_2Ror2S(Component_2R_Type *Input,_iq24 Maxsquare,uint8_t *LimMark, _iq24 *Magtable);
_iq24 Round_Circle_Limitation_Rad(_iq24 Input);
_iq24 Round_Circle_Limitation_PU(_iq24 Input);
_iq24 LPF_1st_Process(LPF_First_Order_Type *LPF_1st, _iq24 input);
_iq24 BPF_2nd_Process(BPF_Second_Order_Type *BPF_2nd,_iq24 input);
_iq24 LPF_2nd_Process(LPF_Second_Order_Type *LPF_2nd, _iq24 input);
_iq24 HPF_1st_Process(HPF_First_Order_Type *HPF_1st, _iq24 input);
_iq24 HPF_2nd_Process(HPF_Second_Order_Type *HPF_2nd,_iq24 input);
void Observer_Adaptor_Process(Observer_Adaptor_type *Adaptor,_iq24 Alpha,_iq24 Beta,_iq24 Angspeed);
_iq24 Speedband_Avoid(_iq24 Speedinput,_iq24 Band,_iq24 Bandwidth);
void Dcurr_Process_Init(DCurrProcess_Type * DCurrProcess,uint8_t Stage);
_iq24 Dcurr_Process(DCurrProcess_Type * DCurrProcess, _iq24 Speedact,_iq24 DCurrRefact);
void Speed_Ramp_Process(Speedrampctr_Type *Speed_Ramp);
void Poweroff_Speed_Ramp_Process(Speedrampctr_Type *Speed_Ramp);
_iq24 AverValue_Cal(_iq24 Input,_iq24 Output, BuffPara_Type *Buffpara);
void Buffer_Clear(_iq24 *Buffer, BuffPara_Type *BuffPara);
void Buffer_Update(_iq24 *Buffer, BuffPara_Type *BuffPara,_iq24 Updatevalue);
void Buffer_Set(_iq24 *Buffer, BuffPara_Type *BuffPara,_iq24 Setvalue);
_iq24 Speed_PLL_Cal(Speed_PLL_Type *SpeedPLL, _iq24 Theta_Err);
void IF_Vibration_Com(Component_2R_Type *Volt, Component_2R_Type *Curr, InjStart_Type *InjStart);
_iq24 IQ24divider(_iq24 dividendin, _iq24 divisorin);
void Saturation(_iq24 *input,_iq24 Upper,_iq24 Lower);
void VDC_Limitspeed(Speedrampctr_Type *Speed_Ramp,ADCStruc_Type *ADCStruc,Powercontrol_Type *PowerOper);
void Break_Verify(Powercontrol_Type *PowerOper,Speedrampctr_Type *Speed_Ramp,\
Runningstatus_Type *Runningstatus,ADCStruc_Type *ADCStruc);
void Powercom_Prameter_Define(Powercom_type *Powercom);
void Powercom_Status_Init(Powercom_type *Powercom);
void Powercom_Process(Powercom_type *Powercom,Motor_Sructure_Type *MStruc,Powercontrol_Type *PowerOper,Speedrampctr_Type *Speed_Ramp);
#endif
@@ -0,0 +1,87 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : M9_Appication_Initl.c
* Author : WCH
* Version : V1.0.0
* Date : 2026/04/23
* Description :
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#include "M0_Control_Library.h"
Powercom_type Powercom_M;
/*******************************************************************************
* Function Name : Powercom_Prameter_Define
* Description : Power Compensation Parameter Definition
* Input : Power Fluctuation Suppression Structure
* Output : None
* Return : None
*******************************************************************************/
void Powercom_Prameter_Define(Powercom_type *Powercom)
{
Powercom->Power_HPF1st.Input_Coef = _IQdiv(UNIT_Q24,(POWERCOM_HPF1st_WcT_M+UNIT_Q24));
Powercom->Power_HPF1st.Output_Coef = _IQdiv(UNIT_Q24,(POWERCOM_HPF1st_WcT_M+UNIT_Q24));
Powercom->Power_LPF1st.Input_Coef = _IQdiv(POWERCOM_LPF1st_WcT_M,(POWERCOM_LPF1st_WcT_M+UNIT_Q24));
Powercom->Power_LPF1st.Output_Coef = _IQdiv(UNIT_Q24,(POWERCOM_LPF1st_WcT_M+UNIT_Q24));
Powercom->Kpdefine = POWERCOM_KP;
Powercom->Kidefine = POWERCOM_KIT;
Powercom->Kddefine = POWERCOM_KD;
Powercom->Kpadj1 = POWERCOM_KPADJ1_M;
Powercom->Kpadj2 = POWERCOM_KPADJ2_M;
Powercom->Kpadj3 = POWERCOM_KPADJ3_M;
Powercom->Kpadj = Powercom->Kpadj1;
Powercom->PowerPID.Kp = _IQMPY_MACRO(Powercom->Kpdefine,Powercom->Kpadj);
Powercom->PowerPID.Ki = Powercom->Kidefine;
Powercom->PowerPID.Kd = Powercom->Kddefine;
Powercom->PowerPID.Upper_Lim = POWERCOM_ULIM_M;
Powercom->PowerPID.Lower_Lim = POWERCOM_LLIM_M;
Powercom->PowerPID.Deltalim = POWERCOM_DLIM_M;
Powercom->Startcom_cntset = POWERCOM_FREQ_M*POWERCOM_STARTTIME_M;
Powercom->Speedcolse_cntset = POWERCOM_FREQ_M*POWERCOM_SPEEDCLOSETIME_M;
Powercom->Speederrthre = POWERCOM_SPEEDERRTHRE_M;
Powercom->Voltthre = POWERCOM_VOLT_THRESHOLD_M;
}
/*******************************************************************************
* Function Name : Powercom_Status_Init
* Description : Power Compensation Parameter Initialization
* Input : Power Fluctuation Suppression Structure
* Output : None
* Return : None
*******************************************************************************/
void Powercom_Status_Init(Powercom_type *Powercom)
{
Powercom->Power_HPF1st.In_Pre = 0;
Powercom->Power_HPF1st.Out_Pre = 0;
Powercom->Power_HPF1st.Out_New = 0;
Powercom->Power_LPF1st.Out_Pre = 0;
Powercom->Power_LPF1st.Out_New = 0;
Powercom->PowerPID.Err_New = 0;
Powercom->PowerPID.Err_Prev1 = 0;
Powercom->PowerPID.Err_Prev2 = 0;
Powercom->PowerPID.Differential = 0;
Powercom->PowerPID.Deltaoutput = 0;
Powercom->PowerPID.Output_New = 0;
Powercom->PowerPID.Output_Prev = 0;
Powercom->PowerPID.Difference = 0;
Powercom->Speedcom =0;
Powercom->Power = _IQ(0.0);
Powercom->PowerfilterH = _IQ(0.0);
Powercom->PowerfilterL = _IQ(0.0);
Powercom->Startcom_cnt=0;
Powercom->Speedclose_cnt = 0;
}
@@ -0,0 +1,103 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : MA_HFVQI_Init.c
* Author : WCH
* Version : V1.0.0
* Date : 2026/04/23
* Description :
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#include "M0_Control_Library.h"
HFVQI_Start_Type HFVQI_StartStruc_M;
BuffPara_Type HFVQIPosi_CBuffPara_M;
_iq24 HFVQIPosi_CBuff_M[HFVQI_POSI_SECTOR_M];
uint8_t HFVQI_Sectorbuf_M[HFVQI_SECTORBUFF];
/******************************************************************************/
/* Function Name : HFVQI_Parameter_Define
/* Description : HFVQI Parameter define
/* Input: None
/* Output : None
/* Return : None
/******************************************************************************/
void HFVQI_Parameter_Define (HFVQI_Start_Type *HFVQI_Start,SVPWM_1R_Type *SVPWM_Cal,PWMCali_Type *PWMCali)
{
HFVQI_Start->Vmag = HFVQI_POSI_VMAG_M;
HFVQI_Start->Vmagmax = _IQ16((SVPWM_Cal->HALF_T - PWMCali->ADCTimeMin -2)/2);
HFVQI_Start->Vmagmax = _IQ16div(HFVQI_Start->Vmagmax,SVPWM_Cal->coef2) <<8;
HFVQI_Start->Vmagmin = _IQ16div(_IQ16(PWMCali->ADCTimeMin + 2) , SVPWM_Cal->coef2) <<8;
HFVQI_Start->TimeStep = HFVQI_POSI_STEP_M;
HFVQI_Start->TimeEffect = HFVQI_POSI_PULSE_EFFECTIVE_M;
HFVQI_Start->AngleInit = _IQ(-1.0)/12;
HFVQI_Start->AngleStep = _IQ(1.0)/HFVQI_POSI_SECTOR_M;
HFVQI_Start->SectorSet = HFVQI_POSI_SECTOR_M;
HFVQI_Start->Posi_Cali = _IQ(1.0)/(HFVQI_POSI_SECTOR_M*2);
HFVQIPosi_CBuffPara_M.Length = HFVQI_POSI_SECTOR_M;
HFVQI_Start->Sectorbuff = HFVQI_SECTORBUFF;
HFVQI_Start->Cyclemax = HFVQI_CYCLE_MAX;
HFVQI_Start->Phaseloss_Currthre = PHASELOSS_CURR_THRE;
HFVQI_Start->Phaseloss_Cntthre = PHASELOSS_CNT_THRE;
}
/*******************************************************************************/
/* Function Name : HFVQI_PosiSearch_Status_Init_M
/* Description : HFVQI initial positioning state initialization
/* Input: None
/* Output : None
/* Return : None
/******************************************************************************/
void HFVQI_Status_Init_M (HFVQI_Start_Type *HFVQI_Start)
{
HFVQI_Start->Vpolar = _IQ(0.0);
HFVQI_Start->Counter = 0;
HFVQI_Start->Position = 0;
HFVQI_Start->SectorAct = 0;
HFVQI_Start->CurrMax = 0;
HFVQI_Start->SectorMax = 0;
HFVQI_Start->Finish = FALSE;
HFVQI_Start->AngleInit = _IQ(-1.0)/12;//¹Ì¶¨-30¡ã¿ªÊ¼
HFVQI_Start->Curr3S.PhaseA = 0;
HFVQI_Start->Curr3S.PhaseB = 0;
HFVQI_Start->Curr3S.PhaseC = 0;
HFVQI_Start->Curr2S.Alpha = 0;
HFVQI_Start->Curr2S.Beta = 0;
HFVQI_Start->Curr2R.cd = 0;
HFVQI_Start->Curr2R.cq = 0;
HFVQI_Start->VoltRef2R.cd = 0;
HFVQI_Start->VoltRef2R.cq = 0;
HFVQI_Start->VoltRef2RC.cd = 0;
HFVQI_Start->VoltRef2RC.cq = 0;
HFVQI_Start->VoltRef2SC.Alpha = 0;
HFVQI_Start->VoltRef2SC.Beta = 0;
HFVQI_Start->Verifytime =0;
HFVQI_Start->Cycletime =0;
HFVQI_Buffer_Clear();
HFVQI_Start->Phaseloss_Cnt = 0;
}
/*******************************************************************************/
/* Function Name : HFVQI_Buffer_Clear
/* Description : HFVQI Initial Positioning Sector Array Initialization
/* Input: None
/* Output : None
/* Return : None
/******************************************************************************/
void HFVQI_Buffer_Clear(void)
{
u_int8_t i;
for(i=0; i < HFVQI_SECTORBUFF; i++)
{
HFVQI_Sectorbuf_M[i]=0;
}
}
@@ -0,0 +1,50 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : MA_HFVQI_Parameter.h
* Author : WCH
* Version : V1.0.0
* Date : 2026/04/23
* Description :
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#ifndef _MA_HFVQI_OBSERVER_H
#define _MA_HFVQI_OBSERVER_H
#define HFVQI_POSI_VMAG_M _IQ(0.25)
#if defined TWELVE_SECTOR_POSITION
#define HFVQI_POSI_SECTOR_M 12
#endif
#if defined SIX_SECTOR_POSITION
#define HFVQI_POSI_SECTOR_M 6
#endif
#define HFVQI_POSI_STEP_M 10
#define HFVQI_POSI_PULSE_EFFECTIVE_M 3
#define HFVQI_SECTORBUFF 2
#define HFVQI_CYCLE_MAX 2
/* Exported variables -------------------------------------------------------*/
extern HFVQI_Start_Type HFVQI_StartStruc_M;
extern BuffPara_Type HFVQIPosi_CBuffPara_M;
extern _iq24 HFVQIPosi_CBuff_M[];
extern uint8_t HFVQI_Sectorbuf_M[];
//HFVQI Init
void HFVQI_Parameter_Define (HFVQI_Start_Type *HFVQI_Start,SVPWM_1R_Type *SVPWM_Cal,PWMCali_Type *PWMCali);
//HFVQI Init
void HFVQI_Status_Init_M (HFVQI_Start_Type *HFVQI_Start);
//HFVQI Init
void HFVQI_Buffer_Clear(void);
//HFVQI Init
void HFVQI_PosiSearch_Process(HFVQI_Start_Type *HFVQI_Start,SVPWM_1R_Type *SVPWM_Cal,\
PWMCali_Type *PWMCali,ADCStruc_Type *ADCStruc,InjStart_Type *Injstart, int8_t Direction);
#endif
@@ -0,0 +1,175 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : MB_Operation_Flash.c
* Author : WCH
* Version : V1.0.0
* Date : 2026/04/23
* Description :
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#include "M0_Control_Library.h"
Flash_Operation_Type Flash_M;
/******************************************************************************
* Function Name : SysclkFreq_Change144_48
* Description : Switch system from 144M to 48M
* Input : None
* Output : None
* Return : None
******************************************************************************/
void SysclkFreq_Change144_48(void)
{
RCC->CFGR0&=~(0x3<<0);
RCC->CFGR0&=~(0x3<<2);
RCC->CFGR0|=(RCC_SW_HSI);
RCC->CTLR &=~ RCC_PLLON;
EXTEN->EXTEN_CTR |= EXTEN_PLL_HSI_PRE;
/* HCLK = SYSCLK */
RCC->CFGR0 |= (uint32_t)RCC_HPRE_DIV1;
/* PCLK2 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE2_DIV1;
/* PCLK1 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE1_DIV2;
/* PLL configuration: PLLCLK = HSI * 6 = 48 MHz */
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_PLLSRC | RCC_PLLXTPRE | RCC_PLLMULL));
RCC->CFGR0 |= (uint32_t)(RCC_PLLSRC_HSI_Div2 | RCC_PLLMULL6);
/* Enable PLL */
RCC->CTLR |= RCC_PLLON;
/* Wait till PLL is ready */
while((RCC->CTLR & RCC_PLLRDY) == 0)
{
}
/* Select PLL as system clock source */
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_SW));
RCC->CFGR0 |= (uint32_t)RCC_SW_PLL;
/* Wait till PLL is used as system clock source */
while ((RCC->CFGR0 & (uint32_t)RCC_SWS) != (uint32_t)0x08)
{
}
}
/******************************************************************************
* Function Name : SysclkFreq_Change144_48
* Description : Switch system from 48M to 144M
* Input : None
* Output : None
* Return : None
******************************************************************************/
void SysclkFreq_Change48_144(void)
{
RCC->CFGR0&=~(0x3<<0);
RCC->CFGR0&=~(0x3<<2);
RCC->CFGR0|=(RCC_SW_HSI);
RCC->CTLR &=~ RCC_PLLON;
EXTEN->EXTEN_CTR |= EXTEN_PLL_HSI_PRE;
/* HCLK = SYSCLK */
RCC->CFGR0 |= (uint32_t)RCC_HPRE_DIV1;
/* PCLK2 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE2_DIV1;
/* PCLK1 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE1_DIV2;
/* PLL configuration: PLLCLK = HSI * 18 = 144 MHz */
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_PLLSRC | RCC_PLLXTPRE | RCC_PLLMULL));
RCC->CFGR0 |= (uint32_t)(RCC_PLLSRC_HSI_Div2 | RCC_PLLMULL18);
/* Enable PLL */
RCC->CTLR |= RCC_PLLON;
/* Wait till PLL is ready */
while((RCC->CTLR & RCC_PLLRDY) == 0)
{
}
/* Select PLL as system clock source */
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_SW));
RCC->CFGR0 |= (uint32_t)RCC_SW_PLL;
/* Wait till PLL is used as system clock source */
while ((RCC->CFGR0 & (uint32_t)RCC_SWS) != (uint32_t)0x08)
{
}
}
/******************************************************************************
* Function Name : Flash_Operation_Init
* Description : Flash Init , Read the Flash value of the 4K Flash after erasing 64K
* Input : operate Flash struct point
* Output : None
* Return : None
******************************************************************************/
void Flash_Operation_Init(Flash_Operation_Type *FlashM)
{
uint32_t Address = 0x0;
FlashM->MemAddress=PAGE_WRITE_START_ADDR;
FlashM->FlashExcep=0;
FlashM->FLASHStatus=FLASH_COMPLETE;
FlashM->MemoryProgramStatus=PASSED;
SysclkFreq_Change144_48();
FLASH_Unlock();
Address = PAGE_WRITE_START_ADDR;
while((Address < (PAGE_WRITE_HALF_END_ADDR-2)) && (FlashM->MemoryProgramStatus != FAILED))
{
FlashM->FlashData[0]=(*(__IO uint16_t*) Address);
if( FlashM->FlashData[0]== 0xe339)
{
FlashM->MemoryProgramStatus=FAILED;
if(Address>PAGE_WRITE_START_ADDR)
{
FlashM->FlashData[0]=(*(__IO uint16_t*) (Address-2));
FlashM->FlashData[1]=(*(__IO uint16_t*) (Address-2+2048));
}
}
else
Address += 2;
}
FlashM->FLASHStatus= FLASH_ErasePage(PAGE_WRITE_START_ADDR);
if(FlashM->FLASHStatus != FLASH_COMPLETE)
{
FlashM->FlashExcep=1;
}
SysclkFreq_Change48_144();
FLASH_Lock();//
}
/******************************************************************************
* Function Name : Flash_ProgramHalfWord
* Description : Flash program Half word
* Input : operate Flash struct point/ address/ data
* Output : None
* Return : None
******************************************************************************/
void Flash_ProgramHalfWord(Flash_Operation_Type *FlashM ,uint32_t Address,uint16_t Data )
{
FLASH_Unlock();
FlashM->FLASHStatus = FLASH_ProgramHalfWord(Address, Data);
if(FlashM->FLASHStatus != FLASH_COMPLETE)
{
FlashM->FlashExcep = 1;
}
FLASH_Lock();
}
@@ -0,0 +1,24 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : MB_Operation_Flash.h
* Author : WCH
* Version : V1.0.0
* Date : 2026/04/23
* Description :
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#include "M0_Control_Library.h"
#define PAGE_WRITE_START_ADDR ((uint32_t)0x08010000) /* Start from 64K */
#define PAGE_WRITE_HALF_END_ADDR ((uint32_t)0x08010800) /* End at 66K */
#define PAGE_WRITE_END_ADDR ((uint32_t)0x08011000) /* End at 68K */
#define FLASH_PAGE_SIZE 4096
extern Flash_Operation_Type Flash_M;
void Flash_Operation_Init(Flash_Operation_Type *FlashM);//²Ù×÷Flash³õʼ»¯
void Flash_ProgramHalfWord(Flash_Operation_Type *FlashM ,uint32_t Address,uint16_t Data );
@@ -0,0 +1,220 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : Motor_SPI_USART_MonitorData.c
* Author : WCH
* Version : V1.0.0
* Date : 2026/04/23
* Description :
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#include "Motor_SPI_USART_MonitorData.h"
t_sendUsbData sendUsbData = {0,0,0,0,0,0,0};
const u_int8_t usbFrameByteNum[12] = {0, 32, 32, 28, 28, 24, 28, 32, 20, 22, 24, 26};
const u_int8_t needSendLen[12] = {0, USB_NEEDSEND_LEN1, USB_NEEDSEND_LEN2, USB_NEEDSEND_LEN3, USB_NEEDSEND_LEN4, USB_NEEDSEND_LEN5,
USB_NEEDSEND_LEN6, USB_NEEDSEND_LEN7, USB_NEEDSEND_LEN8, USB_NEEDSEND_LEN9, USB_NEEDSEND_LEN10, USB_NEEDSEND_LEN11};
/******************************************************************************
* Function Name : getUsbBufLen
* Description : get Usb Buf Len
* Input : u_int8_t data
* Output : None
* Return : Return head and tail pointer length
******************************************************************************/
u_int8_t getUsbBufLen(void)
{
u_int8_t reDataLen;
if(sendUsbData.head >= sendUsbData.end)
{
reDataLen = sendUsbData.head - sendUsbData.end;
}
else
{
reDataLen = (u_int16_t)USB_SENDBUF_LEN - sendUsbData.end + sendUsbData.head;
}
return reDataLen;
}
/******************************************************************************
* Function Name : SPI_Deal_sendMonitorData
* Description : SPI send Monitor Data
* Input : None
* Output : None
* Return : None
******************************************************************************/
void SPI_Deal_sendMonitorData(void)
{
u_int16_t data=0;
u_int8_t i=0, frameByteNum=0;
sendUsbData.sendDataLen=7;
// if(sendUsbData.sendDataLen)
// {
if(getUsbBufLen() >= 16)
{
GPIO_ResetBits(GPIOB,GPIO_Pin_6);
__asm volatile ("nop");
while((SPI1->STATR & SPI_I2S_FLAG_TXE) == (uint16_t)RESET);
SPI1->DATAR = 0x55AA;
while((SPI1->STATR & SPI_I2S_FLAG_TXE) == (uint16_t)RESET);
sendUsbData.heartBeat++;
data=sendUsbData.heartBeat<<8;
data|=32;
SPI1->DATAR = data;
while((SPI1->STATR & SPI_I2S_FLAG_TXE) == (uint16_t)RESET);
frameByteNum = 4;
// while(frameByteNum < usbFrameByteNum[sendUsbData.sendDataLen])//{0, 32, 32, 28, 28, 24, 28, 32, 20, 22, 24, 26};
while(frameByteNum < 32)
{
for(i = 0; i < sendUsbData.sendDataLen; i++)
{
SPI1->DATAR=sendUsbData.sendDataBuf[sendUsbData.end+i];
while((SPI1->STATR & SPI_I2S_FLAG_TXE) == (uint16_t)RESET);
frameByteNum+=2;
}
sendUsbData.end += MaxUsbDataLen;
}
while( (SPI1->STATR & SPI_I2S_FLAG_BSY) != (uint16_t)RESET);
__asm volatile ("nop");
GPIO_SetBits(GPIOB,GPIO_Pin_6);
}
// }
}
/******************************************************************************
* Function Name : SPI_FullDuplex_Init
* Description : SPI Init
* Input : None
* Output : None
* Return : None
******************************************************************************/
void SPI_FullDuplex_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure={0};
SPI_InitTypeDef SPI_InitStructure={0};
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB | RCC_APB2Periph_SPI1|RCC_APB2Periph_AFIO, ENABLE );
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;//MOSI
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init( GPIOB, &GPIO_InitStructure );
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init( GPIOB, &GPIO_InitStructure );//SCK
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_PinRemapConfig(GPIO_Remap_SPI1, ENABLE);
GPIO_SetBits(GPIOB,GPIO_Pin_6);
SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
SPI_InitStructure.SPI_DataSize = SPI_DataSize_16b;//16λ
SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;
SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge;
SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_4;//72/4=16M
SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_LSB;
SPI_Init( SPI1, &SPI_InitStructure );
GPIO_ResetBits(GPIOB,GPIO_Pin_6);
SPI_Cmd( SPI1, ENABLE );
}
/******************************************************************************
* Function Name : Usart_Init
* Description : SPI Init
* Input : uint32_t Baud 4000000
* Output : None
* Return : None
******************************************************************************/
void Usart_Init(uint32_t Baud)
{
GPIO_InitTypeDef GPIO_InitStructure={0};
USART_InitTypeDef USART_InitStructure = {0};
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB|RCC_APB2Periph_USART1|RCC_APB2Periph_AFIO, ENABLE );
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_PinRemapConfig(GPIO_Remap_USART1,ENABLE);
USART_InitStructure.USART_BaudRate = Baud;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Tx ;
USART_Init(USART1, &USART_InitStructure);
USART_Cmd(USART1, ENABLE);
}
/******************************************************************************
* Function Name : Usart_Deal_sendMonitorData
* Description : Usart Send
* Input : None
* Output : None
* Return : None
******************************************************************************/
void Usart_Deal_sendMonitorData(void)
{
u_int8_t i=0, frameByteNum=0;
sendUsbData.sendDataLen=4;
if(sendUsbData.sendDataLen)
{
if(getUsbBufLen() >= needSendLen[sendUsbData.sendDataLen])
{
__asm volatile ("nop");
while((USART1->STATR & USART_FLAG_TXE) == (uint16_t)RESET);
USART1->DATAR=0xAA;
while((USART1->STATR & USART_FLAG_TXE) == (uint16_t)RESET);
USART1->DATAR=0x55;
while((USART1->STATR & USART_FLAG_TXE) == (uint16_t)RESET);
USART1->DATAR=usbFrameByteNum[sendUsbData.sendDataLen];
while((USART1->STATR & USART_FLAG_TXE) == (uint16_t)RESET);
sendUsbData.heartBeat++;
USART1->DATAR=sendUsbData.heartBeat;
while((USART1->STATR & USART_FLAG_TXE) == (uint16_t)RESET);
frameByteNum = 4;
while(frameByteNum < usbFrameByteNum[sendUsbData.sendDataLen])//{0, 32, 32, 28, 28, 24, 28, 32, 20, 22, 24, 26};
{
for(i = 0; i < sendUsbData.sendDataLen; i++)
{
USART1->DATAR = (u_int8_t)((sendUsbData.sendDataBuf[sendUsbData.end+i])&0x00FF);
frameByteNum++;
while((USART1->STATR & USART_FLAG_TXE) == (uint16_t)RESET);
USART1->DATAR = (u_int8_t)((sendUsbData.sendDataBuf[sendUsbData.end+i])>>8);
frameByteNum++;
while((USART1->STATR & USART_FLAG_TXE) == (uint16_t)RESET);
}
sendUsbData.end += MaxUsbDataLen;
}
while((USART1->STATR & USART_FLAG_TXE) == (uint16_t)RESET);
__asm volatile ("nop");
}
}
}
@@ -0,0 +1,45 @@
#ifndef __MOTOR_SPI_USART_MONITORDATA_H_
#define __MOTOR_SPI_USART_MONITORDATA_H_
/* Includes -----------------------------------------------------------------*/
#include "debug.h"
/* Exported constants -------------------------------------------------------*/
#define MaxUsbDataLen 8
#define USB_SENDBUF_LEN (MaxUsbDataLen<<5)
#define USB_NEEDSEND_LEN1 (MaxUsbDataLen*14)
#define USB_NEEDSEND_LEN2 (MaxUsbDataLen*7)
#define USB_NEEDSEND_LEN3 (MaxUsbDataLen*4)
#define USB_NEEDSEND_LEN4 (MaxUsbDataLen*3)
#define USB_NEEDSEND_LEN5 (MaxUsbDataLen*2)
#define USB_NEEDSEND_LEN6 (MaxUsbDataLen*2)
#define USB_NEEDSEND_LEN7 (MaxUsbDataLen*2)
#define USB_NEEDSEND_LEN8 (MaxUsbDataLen)
#define USB_NEEDSEND_LEN9 (MaxUsbDataLen)
#define USB_NEEDSEND_LEN10 (MaxUsbDataLen)
#define USB_NEEDSEND_LEN11 (MaxUsbDataLen)
/* Exported types -----------------------------------------------------------*/
typedef struct
{
u_int8_t heartBeat; //---心跳包---
u_int8_t delayNum; //---延迟传输---
u_int8_t volatile sendDataLen; //----数据长度---
//UINT8 frameByteNum; //---发送包字节序列---
u_int8_t curWriteFrame; //----当前写数据帧---
u_int8_t recDataLen; //----接收上位机数据长度---
u_int8_t end;
u_int8_t volatile head;
u_int8_t recDataBuf[16]; //---接收数据缓冲区---
u_int8_t sendDataType[MaxUsbDataLen]; //---发送数据类型---
u_int16_t sendDataBuf[USB_SENDBUF_LEN]; //---发送数据缓冲区---
}t_sendUsbData;
/* Exported variables -------------------------------------------------------*/
extern t_sendUsbData sendUsbData;
/* Exported functions--------------------------------------------------------*/
extern void Deal_sendMonitorData(void);
extern void SPI_FullDuplex_Init(void);
extern void SPI_Deal_sendMonitorData(void);
extern void Usart_Init(uint32_t Baud);
extern void Usart_Deal_sendMonitorData(void);
#endif
@@ -0,0 +1,41 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : ch32v20x_conf.h
* Author : WCH
* Version : V1.0.0
* Date : 2021/06/06
* Description : Library configuration file.
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#ifndef __CH32V20x_CONF_H
#define __CH32V20x_CONF_H
#include "ch32v20x_adc.h"
#include "ch32v20x_bkp.h"
#include "ch32v20x_can.h"
#include "ch32v20x_crc.h"
#include "ch32v20x_dbgmcu.h"
#include "ch32v20x_dma.h"
#include "ch32v20x_exti.h"
#include "ch32v20x_flash.h"
#include "ch32v20x_gpio.h"
#include "ch32v20x_i2c.h"
#include "ch32v20x_iwdg.h"
#include "ch32v20x_pwr.h"
#include "ch32v20x_rcc.h"
#include "ch32v20x_rtc.h"
#include "ch32v20x_spi.h"
#include "ch32v20x_tim.h"
#include "ch32v20x_usart.h"
#include "ch32v20x_wwdg.h"
#include "ch32v20x_misc.h"
#endif /* __CH32V20x_CONF_H */
@@ -0,0 +1,65 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : main.c
* Author : WCH
* Version : V1.0.0
* Date : 2026/04/23
* Description : Main program body.
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#include "M0_Control_Library.h"
#include "ch32v20x_conf.h"
#include "IQmath_RV32.h"
#include "debug.h"
/*********************************************************************
* @fn main
*
* @brief Main program.
*
* @return none
*/
int main(void)
{
Delay_Init();
Delay_Ms(100);
Flash_Operation_Init(&Flash_M); //Post 4K FLASH Erase and Read
KeyandLED_IOInit(); //Button and indicator light IO configuration
KeyandLED_Parameter_Define(&Key_M, &LED_M); //Button and indicator parameters definition
Global_Status_Initial(); //Initialization of global state
Triac_Parameter_Define(&Triac_ctl,&Tempctl_M); //SCR State Initialization
Operation_Parameter_Define(&Operation_M); //Operation Parameter Definition
Motor_Prameter_Define(&MBase_M); //Motor Parameter Definition
Motor_FilerPara_Cal_M(&MStruc_M); //Motor Phase Filter Parameter Initialization
Motor_BaseCal_M(&MBase_M); //Base Value Parameter Calculation
PID_Prameter_Define(&Mpid_M); //PID Parameter Definition
DCurrProcess_Parameter_Define(&DCurrProcess_M);
PID_ParaBase_Cal_M(&MBase_M,&Mpid_M); //PID Base Value Parameter Calculation
Injstart_Parameter_Define_M(&InjStart_M); //Current Injection Start-up Parameter Configuration
Protection_and_Emergency_Parameter_Define(); //Protection Parameter Configuration
Speedrampctr_Parameter_Define(&SpeedRamp_M); //Rotational Speed Operation Parameter Configuration
SVPWM_1R_Paramter_Init(&SVPWM_Cal_M,&PWMCali_M ,&MBase_M); //SVPWM Calculation Parameter Configuration
SVPWM_1R_Timer_Configure(); //SVPWM uses timer and GPIO configuration
ADC_Parameter_Init(&ADC_M,&MBase_M); //ADC Calculation Parameter Configuration
ADC_OPA_Configure(&ADC_M); //ADC and OPA configuration
TempInit_Measure(&Tempctl_M,ADC1); //Initial temperature measurement
LBG_Parameter_Define(&MLBG_M,&LBG_Status_M); //LBG Observer Parameter Definition
LBG_Paramter_Cal (&MBase_M,&MLBG_M); //LBG Observer Parameter Calculation
HFVQI_Parameter_Define(&HFVQI_StartStruc_M,&SVPWM_Cal_M,&PWMCali_M); //Pulse Positioning Parameter Configuration
Poweroperation_Initial(&Powerctr_M); //Power On/Off Control Parameter Configuration
Powercom_Prameter_Define(&Powercom_M);
Systick_Init(); //Speed Loop Configuration
Interrupt_Configuration(); //Configure Interrupt
TIM_Cmd(TIM1, ENABLE);
TIM_Cmd(TIM2, ENABLE);
TIM_Cmd(TIM3, ENABLE);
TIM_Cmd(TIM4, ENABLE);
SYS_TIM_Cmd(ENABLE);
while(1)
{
Motor_Operation_Process(); //Motor Operation
}
}
@@ -0,0 +1,964 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : system_ch32v20x.c
* Author : WCH
* Version : V1.0.0
* Date : 2021/06/06
* Description : CH32V20x Device Peripheral Access Layer System Source File.
* For HSE = 32Mhz (CH32V208x/CH32V203RBT)
* For HSE = 8Mhz (other CH32V203x)
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#include "ch32v20x.h"
/*
* Uncomment the line corresponding to the desired System clock (SYSCLK) frequency (after
* reset the HSI is used as SYSCLK source).
* If none of the define below is enabled, the HSI is used as System clock source.
*/
//#define SYSCLK_FREQ_HSE HSE_VALUE
//#define SYSCLK_FREQ_48MHz_HSE 48000000
//#define SYSCLK_FREQ_56MHz_HSE 56000000
//#define SYSCLK_FREQ_72MHz_HSE 72000000
//#define SYSCLK_FREQ_96MHz_HSE 96000000
//#define SYSCLK_FREQ_120MHz_HSE 120000000
//#define SYSCLK_FREQ_144MHz_HSE 144000000
//#define SYSCLK_FREQ_HSI HSI_VALUE
//#define SYSCLK_FREQ_48MHz_HSI 48000000
//#define SYSCLK_FREQ_56MHz_HSI 56000000
//#define SYSCLK_FREQ_72MHz_HSI 72000000
//#define SYSCLK_FREQ_96MHz_HSI 96000000
//#define SYSCLK_FREQ_120MHz_HSI 120000000
#define SYSCLK_FREQ_144MHz_HSI 144000000
/* Clock Definitions */
#ifdef SYSCLK_FREQ_HSE
uint32_t SystemCoreClock = SYSCLK_FREQ_HSE; /* System Clock Frequency (Core Clock) */
#elif defined SYSCLK_FREQ_48MHz_HSE
uint32_t SystemCoreClock = SYSCLK_FREQ_48MHz_HSE; /* System Clock Frequency (Core Clock) */
#elif defined SYSCLK_FREQ_56MHz_HSE
uint32_t SystemCoreClock = SYSCLK_FREQ_56MHz_HSE; /* System Clock Frequency (Core Clock) */
#elif defined SYSCLK_FREQ_72MHz_HSE
uint32_t SystemCoreClock = SYSCLK_FREQ_72MHz_HSE; /* System Clock Frequency (Core Clock) */
#elif defined SYSCLK_FREQ_96MHz_HSE
uint32_t SystemCoreClock = SYSCLK_FREQ_96MHz_HSE; /* System Clock Frequency (Core Clock) */
#elif defined SYSCLK_FREQ_120MHz_HSE
uint32_t SystemCoreClock = SYSCLK_FREQ_120MHz_HSE; /* System Clock Frequency (Core Clock) */
#elif defined SYSCLK_FREQ_144MHz_HSE
uint32_t SystemCoreClock = SYSCLK_FREQ_144MHz_HSE; /* System Clock Frequency (Core Clock) */
#elif defined SYSCLK_FREQ_48MHz_HSI
uint32_t SystemCoreClock = SYSCLK_FREQ_48MHz_HSI; /* System Clock Frequency (Core Clock) */
#elif defined SYSCLK_FREQ_56MHz_HSI
uint32_t SystemCoreClock = SYSCLK_FREQ_56MHz_HSI; /* System Clock Frequency (Core Clock) */
#elif defined SYSCLK_FREQ_72MHz_HSI
uint32_t SystemCoreClock = SYSCLK_FREQ_72MHz_HSI; /* System Clock Frequency (Core Clock) */
#elif defined SYSCLK_FREQ_96MHz_HSI
uint32_t SystemCoreClock = SYSCLK_FREQ_96MHz_HSI; /* System Clock Frequency (Core Clock) */
#elif defined SYSCLK_FREQ_120MHz_HSI
uint32_t SystemCoreClock = SYSCLK_FREQ_120MHz_HSI; /* System Clock Frequency (Core Clock) */
#elif defined SYSCLK_FREQ_144MHz_HSI
uint32_t SystemCoreClock = SYSCLK_FREQ_144MHz_HSI; /* System Clock Frequency (Core Clock) */
#else
uint32_t SystemCoreClock = HSI_VALUE; /* System Clock Frequency (Core Clock) */
#endif
__I uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
/* system_private_function_proto_types */
static void SetSysClock(void);
#ifdef SYSCLK_FREQ_HSE
static void SetSysClockToHSE( void );
#elif defined SYSCLK_FREQ_48MHz_HSE
static void SetSysClockTo48_HSE( void );
#elif defined SYSCLK_FREQ_56MHz_HSE
static void SetSysClockTo56_HSE( void );
#elif defined SYSCLK_FREQ_72MHz_HSE
static void SetSysClockTo72_HSE( void );
#elif defined SYSCLK_FREQ_96MHz_HSE
static void SetSysClockTo96_HSE( void );
#elif defined SYSCLK_FREQ_120MHz_HSE
static void SetSysClockTo120_HSE( void );
#elif defined SYSCLK_FREQ_144MHz_HSE
static void SetSysClockTo144_HSE( void );
#elif defined SYSCLK_FREQ_48MHz_HSI
static void SetSysClockTo48_HSI( void );
#elif defined SYSCLK_FREQ_56MHz_HSI
static void SetSysClockTo56_HSI( void );
#elif defined SYSCLK_FREQ_72MHz_HSI
static void SetSysClockTo72_HSI( void );
#elif defined SYSCLK_FREQ_96MHz_HSI
static void SetSysClockTo96_HSI( void );
#elif defined SYSCLK_FREQ_120MHz_HSI
static void SetSysClockTo120_HSI( void );
#elif defined SYSCLK_FREQ_144MHz_HSI
static void SetSysClockTo144_HSI( void );
#endif
/*********************************************************************
* @fn SystemInit
*
* @brief Setup the microcontroller system Initialize the Embedded Flash Interface,
* the PLL and update the SystemCoreClock variable.
*
* @return none
*/
void SystemInit (void)
{
RCC->CTLR |= (uint32_t)0x00000001;
RCC->CFGR0 &= (uint32_t)0xF8FF0000;
RCC->CTLR &= (uint32_t)0xFEF6FFFF;
RCC->CTLR &= (uint32_t)0xFFFBFFFF;
RCC->CFGR0 &= (uint32_t)0xFF80FFFF;
RCC->INTR = 0x009F0000;
SetSysClock();
}
/*********************************************************************
* @fn SystemCoreClockUpdate
*
* @brief Update SystemCoreClock variable according to Clock Register Values.
*
* @return none
*/
void SystemCoreClockUpdate (void)
{
uint32_t tmp = 0, pllmull = 0, pllsource = 0, Pll_6_5 = 0;
tmp = RCC->CFGR0 & RCC_SWS;
switch (tmp)
{
case 0x00:
SystemCoreClock = HSI_VALUE;
break;
case 0x04:
SystemCoreClock = HSE_VALUE;
break;
case 0x08:
pllmull = RCC->CFGR0 & RCC_PLLMULL;
pllsource = RCC->CFGR0 & RCC_PLLSRC;
pllmull = ( pllmull >> 18) + 2;
if(pllmull == 17) pllmull = 18;
if (pllsource == 0x00)
{
if(EXTEN->EXTEN_CTR & EXTEN_PLL_HSI_PRE){
SystemCoreClock = HSI_VALUE * pllmull;
}
else{
SystemCoreClock = (HSI_VALUE >> 1) * pllmull;
}
}
else
{
#if defined (CH32V20x_D8W)
if((RCC->CFGR0 & (3<<22)) == (3<<22))
{
SystemCoreClock = ((HSE_VALUE>>1)) * pllmull;
}
else
#endif
if ((RCC->CFGR0 & RCC_PLLXTPRE) != (uint32_t)RESET)
{
#if defined (CH32V20x_D8) || defined (CH32V20x_D8W)
SystemCoreClock = ((HSE_VALUE>>2) >> 1) * pllmull;
#else
SystemCoreClock = (HSE_VALUE >> 1) * pllmull;
#endif
}
else
{
#if defined (CH32V20x_D8) || defined (CH32V20x_D8W)
SystemCoreClock = (HSE_VALUE>>2) * pllmull;
#else
SystemCoreClock = HSE_VALUE * pllmull;
#endif
}
}
if(Pll_6_5 == 1) SystemCoreClock = (SystemCoreClock / 2);
break;
default:
SystemCoreClock = HSI_VALUE;
break;
}
tmp = AHBPrescTable[((RCC->CFGR0 & RCC_HPRE) >> 4)];
SystemCoreClock >>= tmp;
}
/*********************************************************************
* @fn SetSysClock
*
* @brief Configures the System clock frequency, HCLK, PCLK2 and PCLK1 prescalers.
*
* @return none
*/
static void SetSysClock(void)
{
#ifdef SYSCLK_FREQ_HSE
SetSysClockToHSE();
#elif defined SYSCLK_FREQ_48MHz_HSE
SetSysClockTo48_HSE();
#elif defined SYSCLK_FREQ_56MHz_HSE
SetSysClockTo56_HSE();
#elif defined SYSCLK_FREQ_72MHz_HSE
SetSysClockTo72_HSE();
#elif defined SYSCLK_FREQ_96MHz_HSE
SetSysClockTo96_HSE();
#elif defined SYSCLK_FREQ_120MHz_HSE
SetSysClockTo120_HSE();
#elif defined SYSCLK_FREQ_144MHz_HSE
SetSysClockTo144_HSE();
#elif defined SYSCLK_FREQ_48MHz_HSI
SetSysClockTo48_HSI();
#elif defined SYSCLK_FREQ_56MHz_HSI
SetSysClockTo56_HSI();
#elif defined SYSCLK_FREQ_72MHz_HSI
SetSysClockTo72_HSI();
#elif defined SYSCLK_FREQ_96MHz_HSI
SetSysClockTo96_HSI();
#elif defined SYSCLK_FREQ_120MHz_HSI
SetSysClockTo120_HSI();
#elif defined SYSCLK_FREQ_144MHz_HSI
SetSysClockTo144_HSI();
#endif
/* If none of the define above is enabled, the HSI is used as System clock
* source (default after reset)
*/
}
#ifdef SYSCLK_FREQ_HSE
/*********************************************************************
* @fn SetSysClockToHSE
*
* @brief Sets HSE as System clock source and configure HCLK, PCLK2 and PCLK1 prescalers.
*
* @return none
*/
static void SetSysClockToHSE(void)
{
__IO uint32_t StartUpCounter = 0, HSEStatus = 0;
RCC->CTLR |= ((uint32_t)RCC_HSEON);
/* Wait till HSE is ready and if Time out is reached exit */
do
{
HSEStatus = RCC->CTLR & RCC_HSERDY;
StartUpCounter++;
} while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT));
if ((RCC->CTLR & RCC_HSERDY) != RESET)
{
HSEStatus = (uint32_t)0x01;
}
else
{
HSEStatus = (uint32_t)0x00;
}
if (HSEStatus == (uint32_t)0x01)
{
/* HCLK = SYSCLK */
RCC->CFGR0 |= (uint32_t)RCC_HPRE_DIV1;
/* PCLK2 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE2_DIV1;
/* PCLK1 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE1_DIV1;
/* Select HSE as system clock source */
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_SW));
RCC->CFGR0 |= (uint32_t)RCC_SW_HSE;
/* Wait till HSE is used as system clock source */
while ((RCC->CFGR0 & (uint32_t)RCC_SWS) != (uint32_t)0x04)
{
}
}
else
{
/* If HSE fails to start-up, the application will have wrong clock
* configuration. User can add here some code to deal with this error
*/
}
}
#elif defined SYSCLK_FREQ_48MHz_HSE
/*********************************************************************
* @fn SetSysClockTo48_HSE
*
* @brief Sets System clock frequency to 48MHz and configure HCLK, PCLK2 and PCLK1 prescalers.
*
* @return none
*/
static void SetSysClockTo48_HSE(void)
{
__IO uint32_t StartUpCounter = 0, HSEStatus = 0;
RCC->CTLR |= ((uint32_t)RCC_HSEON);
/* Wait till HSE is ready and if Time out is reached exit */
do
{
HSEStatus = RCC->CTLR & RCC_HSERDY;
StartUpCounter++;
} while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT));
if ((RCC->CTLR & RCC_HSERDY) != RESET)
{
HSEStatus = (uint32_t)0x01;
}
else
{
HSEStatus = (uint32_t)0x00;
}
if (HSEStatus == (uint32_t)0x01)
{
/* HCLK = SYSCLK */
RCC->CFGR0 |= (uint32_t)RCC_HPRE_DIV1;
/* PCLK2 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE2_DIV1;
/* PCLK1 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE1_DIV2;
/* PLL configuration: PLLCLK = HSE * 6 = 48 MHz */
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_PLLSRC | RCC_PLLXTPRE | RCC_PLLMULL));
RCC->CFGR0 |= (uint32_t)(RCC_PLLSRC_HSE | RCC_PLLXTPRE_HSE | RCC_PLLMULL6);
/* Enable PLL */
RCC->CTLR |= RCC_PLLON;
/* Wait till PLL is ready */
while((RCC->CTLR & RCC_PLLRDY) == 0)
{
}
/* Select PLL as system clock source */
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_SW));
RCC->CFGR0 |= (uint32_t)RCC_SW_PLL;
/* Wait till PLL is used as system clock source */
while ((RCC->CFGR0 & (uint32_t)RCC_SWS) != (uint32_t)0x08)
{
}
}
else
{
/*
* If HSE fails to start-up, the application will have wrong clock
* configuration. User can add here some code to deal with this error
*/
}
}
#elif defined SYSCLK_FREQ_56MHz_HSE
/*********************************************************************
* @fn SetSysClockTo56_HSE
*
* @brief Sets System clock frequency to 56MHz and configure HCLK, PCLK2 and PCLK1 prescalers.
*
* @return none
*/
static void SetSysClockTo56_HSE(void)
{
__IO uint32_t StartUpCounter = 0, HSEStatus = 0;
RCC->CTLR |= ((uint32_t)RCC_HSEON);
/* Wait till HSE is ready and if Time out is reached exit */
do
{
HSEStatus = RCC->CTLR & RCC_HSERDY;
StartUpCounter++;
} while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT));
if ((RCC->CTLR & RCC_HSERDY) != RESET)
{
HSEStatus = (uint32_t)0x01;
}
else
{
HSEStatus = (uint32_t)0x00;
}
if (HSEStatus == (uint32_t)0x01)
{
/* HCLK = SYSCLK */
RCC->CFGR0 |= (uint32_t)RCC_HPRE_DIV1;
/* PCLK2 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE2_DIV1;
/* PCLK1 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE1_DIV2;
/* PLL configuration: PLLCLK = HSE * 7 = 56 MHz */
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_PLLSRC | RCC_PLLXTPRE | RCC_PLLMULL));
RCC->CFGR0 |= (uint32_t)(RCC_PLLSRC_HSE | RCC_PLLXTPRE_HSE | RCC_PLLMULL7);
/* Enable PLL */
RCC->CTLR |= RCC_PLLON;
/* Wait till PLL is ready */
while((RCC->CTLR & RCC_PLLRDY) == 0)
{
}
/* Select PLL as system clock source */
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_SW));
RCC->CFGR0 |= (uint32_t)RCC_SW_PLL;
/* Wait till PLL is used as system clock source */
while ((RCC->CFGR0 & (uint32_t)RCC_SWS) != (uint32_t)0x08)
{
}
}
else
{
/*
* If HSE fails to start-up, the application will have wrong clock
* configuration. User can add here some code to deal with this error
*/
}
}
#elif defined SYSCLK_FREQ_72MHz_HSE
/*********************************************************************
* @fn SetSysClockTo72_HSE
*
* @brief Sets System clock frequency to 72MHz and configure HCLK, PCLK2 and PCLK1 prescalers.
*
* @return none
*/
static void SetSysClockTo72_HSE(void)
{
__IO uint32_t StartUpCounter = 0, HSEStatus = 0;
RCC->CTLR |= ((uint32_t)RCC_HSEON);
/* Wait till HSE is ready and if Time out is reached exit */
do
{
HSEStatus = RCC->CTLR & RCC_HSERDY;
StartUpCounter++;
} while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT));
if ((RCC->CTLR & RCC_HSERDY) != RESET)
{
HSEStatus = (uint32_t)0x01;
}
else
{
HSEStatus = (uint32_t)0x00;
}
if (HSEStatus == (uint32_t)0x01)
{
/* HCLK = SYSCLK */
RCC->CFGR0 |= (uint32_t)RCC_HPRE_DIV1;
/* PCLK2 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE2_DIV1;
/* PCLK1 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE1_DIV2;
/* PLL configuration: PLLCLK = HSE * 9 = 72 MHz */
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_PLLSRC | RCC_PLLXTPRE |
RCC_PLLMULL));
RCC->CFGR0 |= (uint32_t)(RCC_PLLSRC_HSE | RCC_PLLXTPRE_HSE | RCC_PLLMULL9);
/* Enable PLL */
RCC->CTLR |= RCC_PLLON;
/* Wait till PLL is ready */
while((RCC->CTLR & RCC_PLLRDY) == 0)
{
}
/* Select PLL as system clock source */
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_SW));
RCC->CFGR0 |= (uint32_t)RCC_SW_PLL;
/* Wait till PLL is used as system clock source */
while ((RCC->CFGR0 & (uint32_t)RCC_SWS) != (uint32_t)0x08)
{
}
}
else
{
/*
* If HSE fails to start-up, the application will have wrong clock
* configuration. User can add here some code to deal with this error
*/
}
}
#elif defined SYSCLK_FREQ_96MHz_HSE
/*********************************************************************
* @fn SetSysClockTo96_HSE
*
* @brief Sets System clock frequency to 96MHz and configure HCLK, PCLK2 and PCLK1 prescalers.
*
* @return none
*/
static void SetSysClockTo96_HSE(void)
{
__IO uint32_t StartUpCounter = 0, HSEStatus = 0;
RCC->CTLR |= ((uint32_t)RCC_HSEON);
/* Wait till HSE is ready and if Time out is reached exit */
do
{
HSEStatus = RCC->CTLR & RCC_HSERDY;
StartUpCounter++;
} while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT));
if ((RCC->CTLR & RCC_HSERDY) != RESET)
{
HSEStatus = (uint32_t)0x01;
}
else
{
HSEStatus = (uint32_t)0x00;
}
if (HSEStatus == (uint32_t)0x01)
{
/* HCLK = SYSCLK */
RCC->CFGR0 |= (uint32_t)RCC_HPRE_DIV1;
/* PCLK2 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE2_DIV1;
/* PCLK1 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE1_DIV2;
/* PLL configuration: PLLCLK = HSE * 12 = 96 MHz */
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_PLLSRC | RCC_PLLXTPRE |
RCC_PLLMULL));
RCC->CFGR0 |= (uint32_t)(RCC_PLLSRC_HSE | RCC_PLLXTPRE_HSE | RCC_PLLMULL12);
/* Enable PLL */
RCC->CTLR |= RCC_PLLON;
/* Wait till PLL is ready */
while((RCC->CTLR & RCC_PLLRDY) == 0)
{
}
/* Select PLL as system clock source */
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_SW));
RCC->CFGR0 |= (uint32_t)RCC_SW_PLL;
/* Wait till PLL is used as system clock source */
while ((RCC->CFGR0 & (uint32_t)RCC_SWS) != (uint32_t)0x08)
{
}
}
else
{
/*
* If HSE fails to start-up, the application will have wrong clock
* configuration. User can add here some code to deal with this error
*/
}
}
#elif defined SYSCLK_FREQ_120MHz_HSE
/*********************************************************************
* @fn SetSysClockTo120_HSE
*
* @brief Sets System clock frequency to 120MHz and configure HCLK, PCLK2 and PCLK1 prescalers.
*
* @return none
*/
static void SetSysClockTo120_HSE(void)
{
__IO uint32_t StartUpCounter = 0, HSEStatus = 0;
RCC->CTLR |= ((uint32_t)RCC_HSEON);
/* Wait till HSE is ready and if Time out is reached exit */
do
{
HSEStatus = RCC->CTLR & RCC_HSERDY;
StartUpCounter++;
} while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT));
if((RCC->CTLR & RCC_HSERDY) != RESET)
{
HSEStatus = (uint32_t)0x01;
}
else
{
HSEStatus = (uint32_t)0x00;
}
if(HSEStatus == (uint32_t)0x01)
{
#if defined (CH32V20x_D8W)
RCC->CFGR0 |= (uint32_t)(3<<22);
/* HCLK = SYSCLK/2 */
RCC->CFGR0 |= (uint32_t)RCC_HPRE_DIV2;
#else
/* HCLK = SYSCLK */
RCC->CFGR0 |= (uint32_t)RCC_HPRE_DIV1;
#endif
/* PCLK2 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE2_DIV1;
/* PCLK1 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE1_DIV2;
/* PLL configuration: PLLCLK = HSE * 15 = 120 MHz */
RCC->CFGR0 &= (uint32_t)((uint32_t) ~(RCC_PLLSRC | RCC_PLLXTPRE |
RCC_PLLMULL));
RCC->CFGR0 |= (uint32_t)(RCC_PLLSRC_HSE | RCC_PLLXTPRE_HSE | RCC_PLLMULL15);
/* Enable PLL */
RCC->CTLR |= RCC_PLLON;
/* Wait till PLL is ready */
while((RCC->CTLR & RCC_PLLRDY) == 0)
{
}
/* Select PLL as system clock source */
RCC->CFGR0 &= (uint32_t)((uint32_t) ~(RCC_SW));
RCC->CFGR0 |= (uint32_t)RCC_SW_PLL;
/* Wait till PLL is used as system clock source */
while((RCC->CFGR0 & (uint32_t)RCC_SWS) != (uint32_t)0x08)
{
}
}
else
{
/*
* If HSE fails to start-up, the application will have wrong clock
* configuration. User can add here some code to deal with this error
*/
}
}
#elif defined SYSCLK_FREQ_144MHz_HSE
/*********************************************************************
* @fn SetSysClockTo144_HSE
*
* @brief Sets System clock frequency to 144MHz and configure HCLK, PCLK2 and PCLK1 prescalers.
*
* @return none
*/
static void SetSysClockTo144_HSE(void)
{
__IO uint32_t StartUpCounter = 0, HSEStatus = 0;
RCC->CTLR |= ((uint32_t)RCC_HSEON);
/* Wait till HSE is ready and if Time out is reached exit */
do
{
HSEStatus = RCC->CTLR & RCC_HSERDY;
StartUpCounter++;
} while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT));
if ((RCC->CTLR & RCC_HSERDY) != RESET)
{
HSEStatus = (uint32_t)0x01;
}
else
{
HSEStatus = (uint32_t)0x00;
}
if (HSEStatus == (uint32_t)0x01)
{
/* HCLK = SYSCLK */
RCC->CFGR0 |= (uint32_t)RCC_HPRE_DIV1;
/* PCLK2 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE2_DIV1;
/* PCLK1 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE1_DIV2;
/* PLL configuration: PLLCLK = HSE * 18 = 144 MHz */
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_PLLSRC | RCC_PLLXTPRE |
RCC_PLLMULL));
RCC->CFGR0 |= (uint32_t)(RCC_PLLSRC_HSE | RCC_PLLXTPRE_HSE | RCC_PLLMULL18);
/* Enable PLL */
RCC->CTLR |= RCC_PLLON;
/* Wait till PLL is ready */
while((RCC->CTLR & RCC_PLLRDY) == 0)
{
}
/* Select PLL as system clock source */
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_SW));
RCC->CFGR0 |= (uint32_t)RCC_SW_PLL;
/* Wait till PLL is used as system clock source */
while ((RCC->CFGR0 & (uint32_t)RCC_SWS) != (uint32_t)0x08)
{
}
}
else
{
/*
* If HSE fails to start-up, the application will have wrong clock
* configuration. User can add here some code to deal with this error
*/
}
}
#elif defined SYSCLK_FREQ_48MHz_HSI
/*********************************************************************
* @fn SetSysClockTo48_HSI
*
* @brief Sets System clock frequency to 48MHz and configure HCLK, PCLK2 and PCLK1 prescalers.
*
* @return none
*/
static void SetSysClockTo48_HSI(void)
{
EXTEN->EXTEN_CTR |= EXTEN_PLL_HSI_PRE;
/* HCLK = SYSCLK */
RCC->CFGR0 |= (uint32_t)RCC_HPRE_DIV1;
/* PCLK2 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE2_DIV1;
/* PCLK1 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE1_DIV2;
/* PLL configuration: PLLCLK = HSI * 6 = 48 MHz */
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_PLLSRC | RCC_PLLXTPRE | RCC_PLLMULL));
RCC->CFGR0 |= (uint32_t)(RCC_PLLSRC_HSI_Div2 | RCC_PLLMULL6);
/* Enable PLL */
RCC->CTLR |= RCC_PLLON;
/* Wait till PLL is ready */
while((RCC->CTLR & RCC_PLLRDY) == 0)
{
}
/* Select PLL as system clock source */
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_SW));
RCC->CFGR0 |= (uint32_t)RCC_SW_PLL;
/* Wait till PLL is used as system clock source */
while ((RCC->CFGR0 & (uint32_t)RCC_SWS) != (uint32_t)0x08)
{
}
}
#elif defined SYSCLK_FREQ_56MHz_HSI
/*********************************************************************
* @fn SetSysClockTo56_HSI
*
* @brief Sets System clock frequency to 56MHz and configure HCLK, PCLK2 and PCLK1 prescalers.
*
* @return none
*/
static void SetSysClockTo56_HSI(void)
{
EXTEN->EXTEN_CTR |= EXTEN_PLL_HSI_PRE;
/* HCLK = SYSCLK */
RCC->CFGR0 |= (uint32_t)RCC_HPRE_DIV1;
/* PCLK2 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE2_DIV1;
/* PCLK1 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE1_DIV2;
/* PLL configuration: PLLCLK = HSI * 7 = 48 MHz */
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_PLLSRC | RCC_PLLXTPRE | RCC_PLLMULL));
RCC->CFGR0 |= (uint32_t)(RCC_PLLSRC_HSI_Div2 | RCC_PLLMULL7);
/* Enable PLL */
RCC->CTLR |= RCC_PLLON;
/* Wait till PLL is ready */
while((RCC->CTLR & RCC_PLLRDY) == 0)
{
}
/* Select PLL as system clock source */
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_SW));
RCC->CFGR0 |= (uint32_t)RCC_SW_PLL;
/* Wait till PLL is used as system clock source */
while ((RCC->CFGR0 & (uint32_t)RCC_SWS) != (uint32_t)0x08)
{
}
}
#elif defined SYSCLK_FREQ_72MHz_HSI
/*********************************************************************
* @fn SetSysClockTo72_HSI
*
* @brief Sets System clock frequency to 72MHz and configure HCLK, PCLK2 and PCLK1 prescalers.
*
* @return none
*/
static void SetSysClockTo72_HSI(void)
{
EXTEN->EXTEN_CTR |= EXTEN_PLL_HSI_PRE;
/* HCLK = SYSCLK */
RCC->CFGR0 |= (uint32_t)RCC_HPRE_DIV1;
/* PCLK2 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE2_DIV1;
/* PCLK1 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE1_DIV2;
/* PLL configuration: PLLCLK = HSI * 9 = 72 MHz */
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_PLLSRC | RCC_PLLXTPRE | RCC_PLLMULL));
RCC->CFGR0 |= (uint32_t)(RCC_PLLSRC_HSI_Div2 | RCC_PLLMULL9);
/* Enable PLL */
RCC->CTLR |= RCC_PLLON;
/* Wait till PLL is ready */
while((RCC->CTLR & RCC_PLLRDY) == 0)
{
}
/* Select PLL as system clock source */
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_SW));
RCC->CFGR0 |= (uint32_t)RCC_SW_PLL;
/* Wait till PLL is used as system clock source */
while ((RCC->CFGR0 & (uint32_t)RCC_SWS) != (uint32_t)0x08)
{
}
}
#elif defined SYSCLK_FREQ_96MHz_HSI
/*********************************************************************
* @fn SetSysClockTo96_HSI
*
* @brief Sets System clock frequency to 96MHz and configure HCLK, PCLK2 and PCLK1 prescalers.
*
* @return none
*/
static void SetSysClockTo96_HSI(void)
{
EXTEN->EXTEN_CTR |= EXTEN_PLL_HSI_PRE;
/* HCLK = SYSCLK */
RCC->CFGR0 |= (uint32_t)RCC_HPRE_DIV1;
/* PCLK2 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE2_DIV1;
/* PCLK1 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE1_DIV2;
/* PLL configuration: PLLCLK = HSI * 12 = 96 MHz */
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_PLLSRC | RCC_PLLXTPRE | RCC_PLLMULL));
RCC->CFGR0 |= (uint32_t)(RCC_PLLSRC_HSI_Div2 | RCC_PLLMULL12);
/* Enable PLL */
RCC->CTLR |= RCC_PLLON;
/* Wait till PLL is ready */
while((RCC->CTLR & RCC_PLLRDY) == 0)
{
}
/* Select PLL as system clock source */
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_SW));
RCC->CFGR0 |= (uint32_t)RCC_SW_PLL;
/* Wait till PLL is used as system clock source */
while ((RCC->CFGR0 & (uint32_t)RCC_SWS) != (uint32_t)0x08)
{
}
}
#elif defined SYSCLK_FREQ_120MHz_HSI
/*********************************************************************
* @fn SetSysClockTo120_HSI
*
* @brief Sets System clock frequency to 120MHz and configure HCLK, PCLK2 and PCLK1 prescalers.
*
* @return none
*/
static void SetSysClockTo120_HSI(void)
{
EXTEN->EXTEN_CTR |= EXTEN_PLL_HSI_PRE;
/* HCLK = SYSCLK */
RCC->CFGR0 |= (uint32_t)RCC_HPRE_DIV1;
/* PCLK2 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE2_DIV1;
/* PCLK1 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE1_DIV2;
/* PLL configuration: PLLCLK = HSI * 15 = 120 MHz */
RCC->CFGR0 &= (uint32_t)((uint32_t) ~(RCC_PLLSRC | RCC_PLLXTPRE |
RCC_PLLMULL));
RCC->CFGR0 |= (uint32_t)(RCC_PLLSRC_HSI_Div2 | RCC_PLLMULL15);
/* Enable PLL */
RCC->CTLR |= RCC_PLLON;
/* Wait till PLL is ready */
while((RCC->CTLR & RCC_PLLRDY) == 0)
{
}
/* Select PLL as system clock source */
RCC->CFGR0 &= (uint32_t)((uint32_t) ~(RCC_SW));
RCC->CFGR0 |= (uint32_t)RCC_SW_PLL;
/* Wait till PLL is used as system clock source */
while((RCC->CFGR0 & (uint32_t)RCC_SWS) != (uint32_t)0x08)
{
}
}
#elif defined SYSCLK_FREQ_144MHz_HSI
/*********************************************************************
* @fn SetSysClockTo144_HSI
*
* @brief Sets System clock frequency to 144MHz and configure HCLK, PCLK2 and PCLK1 prescalers.
*
* @return none
*/
static void SetSysClockTo144_HSI(void)
{
EXTEN->EXTEN_CTR |= EXTEN_PLL_HSI_PRE;
/* HCLK = SYSCLK */
RCC->CFGR0 |= (uint32_t)RCC_HPRE_DIV1;
/* PCLK2 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE2_DIV2;
/* PCLK1 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE1_DIV2;
/* PLL configuration: PLLCLK = HSI * 18 = 144 MHz */
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_PLLSRC | RCC_PLLXTPRE | RCC_PLLMULL));
RCC->CFGR0 |= (uint32_t)(RCC_PLLSRC_HSI_Div2 | RCC_PLLMULL18);
/* Enable PLL */
RCC->CTLR |= RCC_PLLON;
/* Wait till PLL is ready */
while((RCC->CTLR & RCC_PLLRDY) == 0)
{
}
/* Select PLL as system clock source */
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_SW));
RCC->CFGR0 |= (uint32_t)RCC_SW_PLL;
/* Wait till PLL is used as system clock source */
while ((RCC->CFGR0 & (uint32_t)RCC_SWS) != (uint32_t)0x08)
{
}
}
#endif
@@ -0,0 +1,32 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : system_ch32v20x.h
* Author : WCH
* Version : V1.0.0
* Date : 2021/06/06
* Description : CH32V20x Device Peripheral Access Layer System Header File.
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#ifndef __SYSTEM_ch32v20x_H
#define __SYSTEM_ch32v20x_H
#ifdef __cplusplus
extern "C" {
#endif
extern uint32_t SystemCoreClock; /* System Clock Frequency (Core Clock) */
/* System_Exported_Functions */
extern void SystemInit(void);
extern void SystemCoreClockUpdate(void);
#ifdef __cplusplus
}
#endif
#endif /*__CH32V20x_SYSTEM_H */
+295
View File
@@ -0,0 +1,295 @@
<?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="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.2606500741">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.2606500741" moduleId="org.eclipse.cdt.core.settings" name="obj">
<macros/>
<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="${cross_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="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.2606500741" name="obj" parent="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release" postannouncebuildStep="" postbuildStep="" preannouncebuildStep="" prebuildStep="">
<folderInfo id="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.2606500741" name="/" resourcePath="">
<toolChain id="ilg.gnumcueclipse.managedbuild.cross.riscv.toolchain.elf.release.2606500741" name="RISC-V Cross GCC" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.toolchain.elf.release">
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.rvGcc.1171217701" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.rvGcc" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.rvGcc.8" valueType="enumerated"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.base.1900297968" name="Architecture" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.base" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.arch.rv32i" valueType="enumerated"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.multiply.1509705449" name="Multiply extension (RVM)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.multiply" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.atomic.1590833110" name="Atomic extension (RVA)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.atomic" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.fp.1709872289" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.fp" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.isa.fp.none" valueType="enumerated"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.compressed.1038505275" name="Compressed extension (RVC)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.compressed" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.xw.1505432023" name="Extra Compressed extension (RVXW)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.xw" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.b.1896185078" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.b" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.zmmul.724822239" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.zmmul" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.rvv.435767561" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.rvv" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.isa.rvv." valueType="enumerated"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.abi.integer.387605487" name="Integer ABI" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.abi.integer" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.abi.integer.ilp32" valueType="enumerated"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.abi.fp.966196099" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.abi.fp" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.abi.fp.none" valueType="enumerated"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.tune.394563202" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.tune" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.tune.default" valueType="enumerated"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.codemodel.105093140" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.codemodel" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.codemodel.default" valueType="enumerated"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.smalldatalimit.1147643442" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.smalldatalimit" useByScannerDiscovery="false" value="8" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.align.322546450" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.align" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.align.default" valueType="enumerated"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.saverestore.367800619" name="Small prologue/epilogue (-msave-restore)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.saverestore" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.other.1526047739" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.other" useByScannerDiscovery="true" value="" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.level.514997414" name="Optimization Level" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.level" useByScannerDiscovery="true" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.level.size" valueType="enumerated"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.messagelength.1008570639" name="Message length (-fmessage-length=0)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.messagelength" useByScannerDiscovery="true" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.signedchar.467272439" name="'char' is signed (-fsigned-char)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.signedchar" useByScannerDiscovery="true" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.functionsections.2047756949" name="Function sections (-ffunction-sections)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.functionsections" useByScannerDiscovery="true" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.datasections.207613650" name="Data sections (-fdata-sections)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.datasections" useByScannerDiscovery="true" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.nocommon.358586167" name="No common unitialized (-fno-common)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.nocommon" useByScannerDiscovery="true" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.noinlinefunctions.1298414520" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.noinlinefunctions" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.freestanding.213924425" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.freestanding" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.nobuiltin.2007120903" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.nobuiltin" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.spconstant.938841347" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.spconstant" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.PIC.234574726" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.PIC" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.lto.1002322664" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.lto" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.nomoveloopinvariants.1270575343" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.nomoveloopinvariants" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.mrs.highcode.114339272" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.mrs.highcode" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.mrs.asmsoftlib.896763512" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.mrs.asmsoftlib" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.mrs.pipe.1835231981" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.mrs.pipe" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.mrs.caret.2021231049" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.mrs.caret" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.mrs.ccv.2026012911" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.mrs.ccv" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.other.180560481" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.other" useByScannerDiscovery="true" value="" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.syntaxonly.1145714735" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.syntaxonly" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.pedantic.1546854128" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.pedantic" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.pedanticerrors.338820707" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.pedanticerrors" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.nowarn.254465728" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.nowarn" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.unused.1961191588" name="Warn on various unused elements (-Wunused)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.unused" useByScannerDiscovery="true" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.uninitialized.929829166" name="Warn on uninitialized variables (-Wuninitialized)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.uninitialized" useByScannerDiscovery="true" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.allwarn.1168626160" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.allwarn" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.extrawarn.291772487" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.extrawarn" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.missingdeclaration.102344169" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.missingdeclaration" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.conversion.550923640" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.conversion" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.pointerarith.773148082" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.pointerarith" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.padded.1788238782" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.padded" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.shadow.427580978" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.shadow" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.logicalop.1501889551" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.logicalop" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.agreggatereturn.1785504720" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.agreggatereturn" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.floatequal.134298453" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.floatequal" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.toerrors.1117291056" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.toerrors" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.other.1918769559" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.other" useByScannerDiscovery="true" value="" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.level.1204865254" name="Debug level" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.level" useByScannerDiscovery="true" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.level.default" valueType="enumerated"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.format.867779652" name="Debug format" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.format" useByScannerDiscovery="true" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.format.default" valueType="enumerated"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.prof.2131276390" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.prof" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.gprof.1910159761" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.gprof" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.other.1654431258" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.other" useByScannerDiscovery="true" value="" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.toolchain.name.1218760634" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.toolchain.name" useByScannerDiscovery="false" value="GNU MCU RISC-V GCC" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.prefix.103341323" name="Prefix" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.prefix" useByScannerDiscovery="false" value="riscv-none-embed-" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.c.487601824" name="C compiler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.c" useByScannerDiscovery="false" value="gcc" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.cpp.1062130429" name="C++ compiler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.cpp" useByScannerDiscovery="false" value="g++" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.ar.1194282993" name="Archiver" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.ar" useByScannerDiscovery="false" value="ar" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.objcopy.1529355265" name="Hex/Bin converter" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.objcopy" useByScannerDiscovery="false" value="objcopy" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.objdump.1053750745" name="Listing generator" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.objdump" useByScannerDiscovery="false" value="objdump" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.size.1441326233" name="Size command" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.size" useByScannerDiscovery="false" value="size" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.make.550105535" name="Build command" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.make" useByScannerDiscovery="false" value="make" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.rm.719280496" name="Remove command" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.rm" useByScannerDiscovery="false" value="rm" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.toolchain.id.226017994" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.toolchain.id" useByScannerDiscovery="false" value="512258282" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createflash.1311852988" name="Create flash image" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createflash" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createlisting.1983282875" name="Create extended listing" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createlisting" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.printsize.1000761142" name="Print size" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.printsize" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="ilg.gnumcueclipse.managedbuild.cross.riscv.targetPlatform.1944008784" isAbstract="false" osList="all" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.targetPlatform"/>
<builder buildPath="${workspace_loc:/wui_demo/obj" id="ilg.gnumcueclipse.managedbuild.cross.riscv.builder.1421508906" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" stopOnErr="true" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.builder"/>
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.1244756189" name="GNU RISC-V Cross Assembler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler">
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.usepreprocessor.1692176068" name="Use preprocessor" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.usepreprocessor" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.nostdinc.821897907" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.nostdinc" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.preprocessonly.1205312655" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.preprocessonly" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.defs.181380015" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.defs" useByScannerDiscovery="true" valueType="definedSymbols"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.undefs.1514976831" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.undefs" useByScannerDiscovery="true" valueType="undefDefinedSymbols"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.include.paths.1034038285" name="Include paths (-I)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.include.paths" useByScannerDiscovery="true" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/Startup}&quot;"/>
</option>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.include.systempaths.496720673" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.include.systempaths" useByScannerDiscovery="true" valueType="includePath"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.include.files.1898455566" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.include.files" useByScannerDiscovery="true" valueType="includeFiles"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.otherwarnings.1717778600" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.otherwarnings" useByScannerDiscovery="true" value="" valueType="string"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.flags.1578223870" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.flags" useByScannerDiscovery="false" valueType="stringList"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.asmlisting.1937791148" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.asmlisting" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.savetemps.119863881" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.savetemps" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.verbose.1408057941" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.verbose" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.other.1308239903" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.other" useByScannerDiscovery="false" value="" valueType="string"/>
<inputType id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.input.126366858" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.input"/>
</tool>
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.1731377187" name="GNU RISC-V Cross C Compiler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler">
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.nostdinc.1633344562" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.nostdinc" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.preprocessonly.208069239" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.preprocessonly" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.defs.177116515" name="Defined symbols (-D)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.defs" useByScannerDiscovery="true" valueType="definedSymbols"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.undef.1820512625" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.undef" useByScannerDiscovery="true" valueType="undefDefinedSymbols"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.paths.1567947810" name="Include paths (-I)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.paths" useByScannerDiscovery="true" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/Debug}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/Core}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/User}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/Peripheral/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/User/Drivers}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/User/wui}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/User/wui_port}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/User/wui_user}&quot;"/>
</option>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.systempaths.2011720354" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.systempaths" useByScannerDiscovery="true" valueType="includePath"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.files.542153928" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.files" useByScannerDiscovery="true" valueType="includeFiles"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.std.2020844713" name="Language standard" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.std" useByScannerDiscovery="true" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.std.gnu99" valueType="enumerated"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.otheroptimizations.92321033" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.otheroptimizations" useByScannerDiscovery="true" value="" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.warning.missingprototypes.1180998530" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.warning.missingprototypes" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.warning.strictprototypes.684937223" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.warning.strictprototypes" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.warning.badfunctioncast.1090658371" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.warning.badfunctioncast" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.otherwarnings.882361093" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.otherwarnings" useByScannerDiscovery="true" value="" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.asmlisting.1019398219" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.asmlisting" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.savetemps.1858747105" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.savetemps" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.verbose.658438318" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.verbose" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.other.1132663916" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.other" useByScannerDiscovery="true" value="" valueType="string"/>
<inputType id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.input.2036806839" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.input"/>
</tool>
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.compiler.1610882921" name="GNU RISC-V Cross C++ Compiler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.compiler">
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.nostdinc.1306818359" name="Do not search system directories (-nostdinc)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.nostdinc" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.nostdincpp.411115799" name="Do not search system C++ directories (-nostdinc++)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.nostdincpp" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.preprocessonly.704235280" name="Preprocess only (-E)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.preprocessonly" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.defs.256688978" name="Defined symbols (-D)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.defs" useByScannerDiscovery="true" valueType="definedSymbols"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.undef.1769659537" name="Undefined symbols (-U)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.undef" useByScannerDiscovery="true" valueType="undefDefinedSymbols"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.include.paths.1641430352" name="Include paths (-I)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.include.paths" useByScannerDiscovery="true" valueType="includePath"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.include.systempaths.1217742259" name="Include system paths (-isystem)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.include.systempaths" useByScannerDiscovery="true" valueType="includePath"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.include.files.1922780842" name="Include files (-include)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.include.files" useByScannerDiscovery="true" valueType="includeFiles"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.std.426208505" name="Language standard" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.std" useByScannerDiscovery="true" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.std.gnucpp11" valueType="enumerated"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.abiversion.1671052931" name="ABI version" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.abiversion" useByScannerDiscovery="true" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.abiversion.0" valueType="enumerated"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.noexceptions.1891612477" name="Do not use exceptions (-fno-exceptions)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.noexceptions" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.nortti.76308566" name="Do not use RTTI (-fno-rtti)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.nortti" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.nousecxaatexit.390229569" name="Do not use _cxa_atexit() (-fno-use-cxa-atexit)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.nousecxaatexit" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.nothreadsafestatics.1143999424" name="Do not use thread-safe statics (-fno-threadsafe-statics)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.nothreadsafestatics" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.otheroptimizations.1589858535" name="Other optimization flags" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.otheroptimizations" useByScannerDiscovery="true" value="" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.warnabi.1304561076" name="Warn on ABI violations (-Wabi)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.warnabi" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.warning.ctordtorprivacy.534922494" name="Warn on class privacy (-Wctor-dtor-privacy)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.warning.ctordtorprivacy" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.warning.noexcept.1102421587" name="Warn on no-except expressions (-Wnoexcept)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.warning.noexcept" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.warning.nonvirtualdtor.249412631" name="Warn on virtual destructors (-Wnon-virtual-dtor)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.warning.nonvirtualdtor" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.warning.strictnullsentinel.1022346732" name="Warn on uncast NULL (-Wstrict-null-sentinel)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.warning.strictnullsentinel" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.warning.signpromo.1510049602" name="Warn on sign promotion (-Wsign-promo)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.warning.signpromo" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.warneffc.1507924344" name="Warn about Effective C++ violations (-Weffc++)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.warneffc" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.otherwarnings.521572828" name="Other warning flags" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.otherwarnings" useByScannerDiscovery="true" value="" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.asmlisting.842958016" name="Generate assembler listing (-Wa,-adhlns=&quot;$@.lst&quot;)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.asmlisting" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.savetemps.715871177" name="Save temporary files (--save-temps Use with caution!)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.savetemps" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.verbose.974774820" name="Verbose (-v)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.verbose" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.other.1293392631" name="Other compiler flags" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.other" useByScannerDiscovery="true" value="" valueType="string"/>
<inputType id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.compiler.input.1079228323" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.compiler.input"/>
</tool>
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.linker.1620074387" name="GNU RISC-V Cross C Linker" outputPrefix="" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.linker">
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.scriptfile.1390103472" name="Script files (-T)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.scriptfile" useByScannerDiscovery="false" valueType="stringList">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/Ld/Link.ld}&quot;"/>
</option>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.nostart.913830613" name="Do not use standard start files (-nostartfiles)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.nostart" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.nodeflibs.1285997013" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.nodeflibs" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.nostdlibs.179047434" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.nostdlibs" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.gcsections.194760422" name="Remove unused sections (-Xlinker --gc-sections)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.gcsections" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.printgcsections.270824644" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.printgcsections" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.strip.1802601885" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.strip" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.libs.813115939" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.libs" useByScannerDiscovery="false" valueType="libs"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.paths.2057340378" name="Library search path (-L)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.paths" useByScannerDiscovery="false" valueType="libPaths"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.flags.1125808200" name="Linker flags (-Xlinker [option])" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.flags" useByScannerDiscovery="false" valueType="stringList"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.otherobjs.16994550" name="Other objects" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.otherobjs" useByScannerDiscovery="false" valueType="userObjs">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/User/wui/libwui_0.2.a}&quot;"/>
</option>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.mapfilename.789195953" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.mapfilename" useByScannerDiscovery="false" value="&quot;${BuildArtifactFileBaseName}.map&quot;" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.picolibc.62047318" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.picolibc" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.picolibc.disabled" valueType="enumerated"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.cref.824432654" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.cref" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.printmap.751686263" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.printmap" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.usenewlibnano.239404511" name="Use newlib-nano (--specs=nano.specs)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.usenewlibnano" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.usenewlibnosys.351964161" name="Do not use syscalls (--specs=nosys.specs)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.usenewlibnosys" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.useprintffloat.695795083" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.useprintffloat" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.usescanffloat.1839373535" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.usescanffloat" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.verbose.1444336626" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.verbose" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.printfloat.2044235126" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.printfloat" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.printf.888161142" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.printf" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.iqmath.1390292521" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.iqmath" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.other.1683775650" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.other" useByScannerDiscovery="false" value="" valueType="string"/>
<inputType id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.linker.input.1859223768" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
</tool>
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.linker.1947503520" name="GNU RISC-V Cross C++ Linker" outputPrefix="" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.linker">
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.scriptfile.1751226764" name="Script files (-T)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.scriptfile" useByScannerDiscovery="false" valueType="stringList">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/Ld/Link.ld}&quot;"/>
</option>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.nostart.642896175" name="Do not use standard start files (-nostartfiles)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.nostart" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.nodeflibs.282300763" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.nodeflibs" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.nostdlibs.924960428" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.nostdlibs" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.gcsections.1689063433" name="Remove unused sections (-Xlinker --gc-sections)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.gcsections" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.printgcsections.621524254" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.printgcsections" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.strip.679063538" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.strip" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.libs.579700779" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.libs" useByScannerDiscovery="false" valueType="libs"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.paths.1029177148" name="Library search path (-L)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.paths" useByScannerDiscovery="false" valueType="libPaths"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.flags.1251620602" name="Linker flags (-Xlinker [option])" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.flags" useByScannerDiscovery="false" valueType="stringList"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.otherobjs.1493906625" name="Other objects" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.otherobjs" useByScannerDiscovery="false" valueType="userObjs">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/User/wui/libwui_0.2.a}&quot;"/>
</option>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.mapfilename.1354773182" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.mapfilename" useByScannerDiscovery="false" value="&quot;${BuildArtifactFileBaseName}.map&quot;" valueType="string"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.picolibc.4345436542" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.picolibc" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.picolibc.disabled" valueType="enumerated"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.cref.1007621036" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.cref" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.printmap.2073713641" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.printmap" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.usenewlibnano.1540675679" name="Use newlib-nano (--specs=nano.specs)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.usenewlibnano" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.usenewlibnosys.561457319" name="Do not use syscalls (--specs=nosys.specs)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.usenewlibnosys" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.useprintffloat.1497004994" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.useprintffloat" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.usescanffloat.881728961" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.usescanffloat" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.verbose.922041698" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.verbose" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.printfloat.476377985" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.printfloat" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.printf.626387227" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.printf" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.iqmath.1441123220" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.iqmath" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.other.1748689212" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.other" useByScannerDiscovery="false" value="" valueType="string"/>
</tool>
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.archiver.1292785366" name="GNU RISC-V Cross Archiver" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.archiver">
<outputType id="cdt.managedbuild.tool.gnu.archiver.output.1527226663" superClass="cdt.managedbuild.tool.gnu.archiver.output" outputPrefix="lib"/>
<option id="gnu.both.lib.option.flags.22122911" superClass="gnu.both.lib.option.flags" useByScannerDiscovery="false" value="-r" valueType="string"/>
</tool>
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.createflash.1801165667" name="GNU RISC-V Cross Create Flash Image" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.createflash">
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.textsection.1097396305" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.textsection" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.datasection.2034511797" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.datasection" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.choice.1726268709" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.choice" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.choice.ihex" valueType="enumerated"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.createalgorithmfile.2643315497" superClass="ilg.gnuarmeclipse.managedbuild.cross.risv.option.createflash.createalgorithmfile" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.othersection.1890795928" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.othersection" useByScannerDiscovery="false" valueType="stringList"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.other.788974495" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.other" useByScannerDiscovery="false" value="" valueType="string"/>
</tool>
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.createlisting.1356766765" name="GNU RISC-V Cross Create Listing" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.createlisting">
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.source.2052761852" name="Display source (--source|-S)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.source" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.allheaders.439659821" name="Display all headers (--all-headers|-x)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.allheaders" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.demangle.67111865" name="Demangle names (--demangle|-C)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.demangle" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.debugging.1623481730" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.debugging" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.disassemble.1859590835" name="Disassemble (--disassemble|-d)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.disassemble" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.fileheaders.160868348" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.fileheaders" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.linenumbers.1549373929" name="Display line numbers (--line-numbers|-l)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.linenumbers" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.reloc.1008747895" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.reloc" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.symbols.577922241" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.symbols" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.wide.1298918921" name="Wide lines (--wide|-w)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.wide" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.other.1560864108" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.other" useByScannerDiscovery="false" value="" valueType="string"/>
</tool>
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.printsize.712424314" name="GNU RISC-V Cross Print Size" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.printsize">
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.printsize.format.1404031980" name="Size format" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.printsize.format" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.printsize.format.berkeley" valueType="enumerated"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.printsize.hex.176087647" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.printsize.hex" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.printsize.totals.380903440" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.printsize.totals" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.printsize.other.1271150877" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.printsize.other" useByScannerDiscovery="false" value="" valueType="string"/>
</tool>
</toolChain>
</folderInfo>
<sourceEntries>
<entry excluding="Startup/startup_ch32v20x_D8W.S|Startup/startup_ch32v20x_D8.S" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
</sourceEntries>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
<storageModule moduleId="ilg.gnumcueclipse.managedbuild.packs"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="999.ilg.gnumcueclipse.managedbuild.cross.riscv.target.elf.275846018" name="Executable file" projectType="ilg.gnumcueclipse.managedbuild.cross.riscv.target.elf"/>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<scannerConfigBuildInfo instanceId="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.debug.767917625;ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.debug.767917625.;ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.1375371130;ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.input.1473381709">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.1008047074;ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.1008047074.;ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.1731377187;ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.input.2036806839">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
</cproject>
+60
View File
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<projectDescription>
<name>wui_demo</name>
<comment/>
<projects/>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments/>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<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>
</natures>
<linkedResources>
<link>
<name>Core</name>
<type>2</type>
<location>PARENT-2-PROJECT_LOC/SRC/Core</location>
</link>
<link>
<name>Debug</name>
<type>2</type>
<location>PARENT-2-PROJECT_LOC/SRC/Debug</location>
</link>
<link>
<name>Ld</name>
<type>2</type>
<location>PARENT-2-PROJECT_LOC/SRC/Ld</location>
</link>
<link>
<name>Peripheral</name>
<type>2</type>
<location>PARENT-2-PROJECT_LOC/SRC/Peripheral</location>
</link>
<link>
<name>Startup</name>
<type>2</type>
<location>PARENT-2-PROJECT_LOC/SRC/Startup</location>
</link>
</linkedResources>
<filteredResources>
<filter>
<name/>
<type>6</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-name-matches-false-false-*.wvproj</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
+32
View File
@@ -0,0 +1,32 @@
Vendor=WCH
Toolchain=RISC-V
Series=CH32V203
RTOS=NoneOS
CalibrateSupport=false
CalibrateCommand=
UIConfigSupport=false
UIConfigCommand=
ExternalFlashSupport=false
MCU=CH32V203RBT
Link=WCH-Link
PeripheralVersion=1.0
Description=ROM(byte): 64K, SRAM(byte): 20K, CHIP PINS: 32, GPIO PORTS: 27.\nWCH CH32V2 series of mainstream MCUs covers the needs of a large variety of applications in the industrial,medical and consumer markets. High performance with first-class peripherals and low-power,low-voltage operation is paired with a high level of integration at accessible prices with a simple architecture and easy-to-use tools.
TempratureScope=
ArtifactType=executable
Mcu Type=CH32V20x
Address=0x08000000
Target Path=obj\wui_demo.hex
Exe Path=
Exe Arguments=
CLKSpeed=1
DebugInterfaceMode=0
Erase All=true
Program=true
Verify=true
Reset=true
SDIPrintf=false
Disable Power Output=false
Clear CodeFlash=false
Disable Code-Protect=false
Flash Type=
Algorithm File=
+383
View File
@@ -0,0 +1,383 @@
/*********************************************************************
* File Name : lcd.c
* Author : WCH
* Version : V1.0.0
* Date : 2023/8/15
* Description : file for lcd screen.
*********************************************************************************
* Copyright (c) 2023 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#include "lcd.h"
#include "debug.h"
#include "LCD_Font.h"
#define LCD_SOFT_RESET (0x01)
#define LCD_READ_ID (0x04)
#define LCD_READ_DISPLAY_STATUS (0x09)
#define LCD_ON (0x28)
#define LCD_OFF (0x29)
#define LCD_SET_X (0x2a)
#define LCD_SET_Y (0x2b)
#define LCD_MEM_WRITE (0x2C)
#define LCD_MEM_READ (0x2e)
static void LCD_WR_REG(uint8_t data)
{
LCD_DC_CLR();
SPI2_Write(data);
}
static void LCD_WR_DATA(uint8_t data)
{
LCD_DC_SET();
SPI2_Write(data);
}
/*********************************************************************
* @fn Lcd_WriteData_16Bit
*
* @brief write two bytes to the lcd screen
*
* @param Data - the data to write
*
* @return none
*/
void Lcd_WriteData_16Bit(uint16_t Data)
{
SPI2_Write(Data >> 8);
SPI2_Write(Data);
}
/*********************************************************************
* @fn LCD_GPIOInit
*
* @brief Configuring the control gpio for the lcd screen
*
* @return none
*/
void LCD_GPIOInit(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(LCD_LED_RCC, ENABLE);
RCC_APB2PeriphClockCmd(LCD_DC_RCC, ENABLE);
RCC_APB2PeriphClockCmd(LCD_RST_RCC, ENABLE);
RCC_APB2PeriphClockCmd(LCD_CS_RCC, ENABLE);
GPIO_InitStructure.GPIO_Pin = LCD_LED_PIN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(LCD_LED_PORT, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = LCD_DC_PIN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(LCD_DC_PORT, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = LCD_RST_PIN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(LCD_RST_PORT, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = LCD_CS_PIN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(LCD_CS_PORT, &GPIO_InitStructure);
LCD_LED_CLR();
LCD_CS_SET();
}
/*********************************************************************
* @fn LCD_RESET
*
* @brief reset the lcd screen by the rst pin
*
* @return none
*/
void LCD_RESET(void)
{
Delay_Ms(50);
LCD_RST_CLR();
Delay_Ms(100);
LCD_RST_SET();
Delay_Ms(50);
}
static const uint8_t lcd_st7789_init_cmds[] = {
1,
0x3A,
0x05,
2,
0xB0,
0x00,
0xF0,
5,
0xB2,
0x0C,
0x0C,
0x00,
0x33,
0x33,
1,
0xB7,
0x35,
1,
0xBB,
0x19,
1,
0xC0,
0x2C,
1,
0xC2,
0x01,
1,
0xC3,
0x12,
1,
0xC4,
0x20,
1,
0xC6,
0x0F,
2,
0xD0,
0xA4,
0xA1,
14,
0xE0,
0xD0,
0x04,
0x0D,
0x11,
0x13,
0x2B,
0x3F,
0x54,
0x4C,
0x18,
0x0D,
0x0B,
0x1F,
0x23,
14,
0xE1,
0xD0,
0x04,
0x0C,
0x11,
0x13,
0x2C,
0x3F,
0x44,
0x51,
0x2F,
0x1F,
0x1F,
0x20,
0x23,
0,
0x21,
1,
0x36,
#if USE_HORIZONTAL == 0
0,
#elif USE_HORIZONTAL == 1
(1 << 7) | (1 << 6) | (0 << 5),
#elif USE_HORIZONTAL == 2
(1 << 6) | (0 << 7) | (1 << 5),
#elif USE_HORIZONTAL == 3
(1 << 7) | (1 << 5),
#endif
0,
0x11,
0,
0x29,
0xff,
0xff,
};
void LCD_exec_init(uint8_t* init_code)
{
uint8_t* p = init_code;
uint8_t data_len;
uint8_t cmd;
LCD_CS_CLR();
while (1)
{
data_len = *p++;
cmd = *p++;
if (cmd == 0xFF)
{
break;
}
LCD_WR_REG(cmd);
for (uint8_t i = 0; i < data_len; i++)
{
LCD_WR_DATA(*p++);
}
}
LCD_CS_SET();
}
void LCD_Init(void)
{
SPI2_Init();
SPI2_DMA_Init();
LCD_GPIOInit();
LCD_RESET();
LCD_CS_CLR();
LCD_WR_REG(0x28);
LCD_exec_init((uint8_t*)lcd_st7789_init_cmds);
Delay_Ms(10);
LCD_Clear(LCD_BLACK);
Delay_Ms(10);
LCD_LED_SET();
}
/*********************************************************************
* @fn LCD_SetWindows
*
* @brief Setting LCD display window
*
* @param xStar - the bebinning x coordinate of the LCD display window
* yStar - the bebinning y coordinate of the LCD display window
* xEnd - the endning x coordinate of the LCD display window
* yEnd - the endning y coordinate of the LCD display window
*
* @return none
*/
void LCD_SetWindows(uint16_t xStar, uint16_t yStar, uint16_t xEnd, uint16_t yEnd)
{
LCD_CS_CLR();
LCD_WR_REG(LCD_SET_X);
LCD_WR_DATA(xStar >> 8);
LCD_WR_DATA(0x00FF & xStar);
LCD_WR_DATA(xEnd >> 8);
LCD_WR_DATA(0x00FF & xEnd);
LCD_WR_REG(LCD_SET_Y);
LCD_WR_DATA(yStar >> 8);
LCD_WR_DATA(0x00FF & yStar);
LCD_WR_DATA(yEnd >> 8);
LCD_WR_DATA(0x00FF & yEnd);
LCD_WR_REG(LCD_MEM_WRITE);
LCD_CS_SET();
}
// 设置引脚为高电平
void LCD_LED_SET(void)
{
LCD_LED_PORT->BSHR = LCD_LED_PIN;
}
void LCD_CS_SET(void)
{
LCD_CS_PORT->BSHR = LCD_CS_PIN;
}
void LCD_DC_SET(void)
{
LCD_DC_PORT->BSHR = LCD_DC_PIN;
}
void LCD_RST_SET(void)
{
LCD_RST_PORT->BSHR = LCD_RST_PIN;
}
// 设置引脚为低电平
void LCD_LED_CLR(void)
{
LCD_LED_PORT->BCR = LCD_LED_PIN;
}
void LCD_CS_CLR(void)
{
LCD_CS_PORT->BCR = LCD_CS_PIN;
}
void LCD_DC_CLR(void)
{
LCD_DC_PORT->BCR = LCD_DC_PIN;
}
void LCD_RST_CLR(void)
{
LCD_RST_PORT->BCR = LCD_RST_PIN;
}
void SPI1_wait_for_bsy()
{
while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_BSY) == SET)
;
}
void SPI2_wait_for_bsy()
{
while (SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_BSY) == SET)
;
}
void SPI2_wait_for_txe()
{
while (SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_TXE) == RESET)
;
}
void SPI1_wait_for_DMA()
{
while (SPI1_DMA_TX_CH->CNTR > 0)
{
}
}
void SPI2_wait_for_DMA()
{
while (SPI2_DMA_TX_CH->CNTR > 0)
{
}
}
void LCD_Clear(uint16_t color)
{
LCD_Fill(0, 0, LCD_W, LCD_H, color);
}
@@ -0,0 +1,84 @@
/*********************************************************************
* File Name : lcd.h
* Author : WCH
* Version : V1.0.0
* Date : 2023/8/15
* Description : file for lcd screen.
*********************************************************************************
* Copyright (c) 2023 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#ifndef __LCD_H
#define __LCD_H
#include "spi.h"
#include "stdio.h"
#include "stdlib.h"
#include "flash.h"
#include "config.h"
#define USE_HORIZONTAL 2
#if USE_HORIZONTAL == 0 || USE_HORIZONTAL == 1
#define LCD_W 240
#define LCD_H 320
#endif
#if USE_HORIZONTAL == 2 || USE_HORIZONTAL == 3
#define LCD_W 320
#define LCD_H 240
#endif
#define LCD_WIDTH LCD_W
#define LCD_HEIGHT LCD_H
#define LCD_SWAP16(x) ((((x) & 0xFF) << 8) | (((x) >> 8) & 0xFF))
#define RGB888_TO_RGB565(r, g, b) LCD_SWAP16((((r) & 0xF8) << 8) | (((g) & 0xFC) << 3) | (((b) & 0xF8) >> 3))
#define RGB24_TO_RGB565(rgb) LCD_SWAP16((((rgb) >> 8) & 0xF800) | (((rgb) >> 5) & 0x07E0) | (((rgb) >> 3) & 0x001F))
#define LCD_red RGB888_TO_RGB565(255, 0, 0)
#define LCD_green RGB888_TO_RGB565(0, 255, 0)
#define LCD_blue RGB888_TO_RGB565(0, 0, 255)
#define LCD_white RGB888_TO_RGB565(255, 255, 255)
#define LCD_gray RGB888_TO_RGB565(128, 128, 128)
#define LCD_black RGB888_TO_RGB565(0, 0, 0)
#define LCD_yellow RGB888_TO_RGB565(255, 255, 0)
#define LCD_WHITE LCD_white
#define LCD_BLACK LCD_black
#define LCD_BLUE LCD_blue
#define LCD_RED LCD_red
#define LCD_MAGENTA RGB888_TO_RGB565(255, 0, 255)
#define LCD_GREEN LCD_green
#define LCD_CYAN RGB888_TO_RGB565(0, 255, 255)
#define LCD_YELLOW LCD_yellow
#define LCD_BROWN RGB888_TO_RGB565(165, 42, 42)
#define LCD_GRAY LCD_gray
void LCD_LED_SET(void);
void LCD_CS_SET(void);
void LCD_DC_SET(void);
void LCD_RST_SET(void);
void LCD_LED_CLR(void);
void LCD_CS_CLR(void);
void LCD_DC_CLR(void);
void LCD_RST_CLR(void);
void SPI1_wait_for_bsy();
void SPI2_wait_for_bsy();
void SPI2_wait_for_txe();
void SPI1_wait_for_DMA();
void SPI2_wait_for_DMA();
void LCD_Init(void);
void LCD_Clear(uint16_t Color);
void Lcd_WriteData_16Bit(uint16_t Data);
void LCD_SetWindows(uint16_t xStar, uint16_t yStar, uint16_t xEnd, uint16_t yEnd);
void LCD_Fill(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t Color);
#endif
@@ -0,0 +1,200 @@
#include "LCD_Font.h"
#include "wui.h"
//12*12
const unsigned char asc2_1206[95][12]={
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*" ",0*/
{0x00,0x00,0x00,0x00,0x3F,0x40,0x00,0x00,0x00,0x00,0x00,0x00},/*"!",1*/
{0x00,0x00,0x30,0x00,0x40,0x00,0x30,0x00,0x40,0x00,0x00,0x00},/*""",2*/
{0x09,0x00,0x0B,0xC0,0x3D,0x00,0x0B,0xC0,0x3D,0x00,0x09,0x00},/*"#",3*/
{0x18,0xC0,0x24,0x40,0x7F,0xE0,0x22,0x40,0x31,0x80,0x00,0x00},/*"$",4*/
{0x18,0x00,0x24,0xC0,0x1B,0x00,0x0D,0x80,0x32,0x40,0x01,0x80},/*"%",5*/
{0x03,0x80,0x1C,0x40,0x27,0x40,0x1C,0x80,0x07,0x40,0x00,0x40},/*"&",6*/
{0x10,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"'",7*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x80,0x20,0x40,0x40,0x20},/*"(",8*/
{0x00,0x00,0x40,0x20,0x20,0x40,0x1F,0x80,0x00,0x00,0x00,0x00},/*")",9*/
{0x09,0x00,0x06,0x00,0x1F,0x80,0x06,0x00,0x09,0x00,0x00,0x00},/*"*",10*/
{0x04,0x00,0x04,0x00,0x3F,0x80,0x04,0x00,0x04,0x00,0x00,0x00},/*"+",11*/
{0x00,0x10,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*",",12*/
{0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x00,0x00},/*"-",13*/
{0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*".",14*/
{0x00,0x20,0x01,0xC0,0x06,0x00,0x38,0x00,0x40,0x00,0x00,0x00},/*"/",15*/
{0x1F,0x80,0x20,0x40,0x20,0x40,0x20,0x40,0x1F,0x80,0x00,0x00},/*"0",16*/
{0x00,0x00,0x10,0x40,0x3F,0xC0,0x00,0x40,0x00,0x00,0x00,0x00},/*"1",17*/
{0x18,0xC0,0x21,0x40,0x22,0x40,0x24,0x40,0x18,0x40,0x00,0x00},/*"2",18*/
{0x10,0x80,0x20,0x40,0x24,0x40,0x24,0x40,0x1B,0x80,0x00,0x00},/*"3",19*/
{0x02,0x00,0x0D,0x00,0x11,0x00,0x3F,0xC0,0x01,0x40,0x00,0x00},/*"4",20*/
{0x3C,0x80,0x24,0x40,0x24,0x40,0x24,0x40,0x23,0x80,0x00,0x00},/*"5",21*/
{0x1F,0x80,0x24,0x40,0x24,0x40,0x34,0x40,0x03,0x80,0x00,0x00},/*"6",22*/
{0x30,0x00,0x20,0x00,0x27,0xC0,0x38,0x00,0x20,0x00,0x00,0x00},/*"7",23*/
{0x1B,0x80,0x24,0x40,0x24,0x40,0x24,0x40,0x1B,0x80,0x00,0x00},/*"8",24*/
{0x1C,0x00,0x22,0xC0,0x22,0x40,0x22,0x40,0x1F,0x80,0x00,0x00},/*"9",25*/
{0x00,0x00,0x00,0x00,0x08,0x40,0x00,0x00,0x00,0x00,0x00,0x00},/*":",26*/
{0x00,0x00,0x00,0x00,0x04,0x60,0x00,0x00,0x00,0x00,0x00,0x00},/*";",27*/
{0x00,0x00,0x04,0x00,0x0A,0x00,0x11,0x00,0x20,0x80,0x40,0x40},/*"<",28*/
{0x09,0x00,0x09,0x00,0x09,0x00,0x09,0x00,0x09,0x00,0x00,0x00},/*"=",29*/
{0x00,0x00,0x40,0x40,0x20,0x80,0x11,0x00,0x0A,0x00,0x04,0x00},/*">",30*/
{0x18,0x00,0x20,0x00,0x23,0x40,0x24,0x00,0x18,0x00,0x00,0x00},/*"?",31*/
{0x1F,0x80,0x20,0x40,0x27,0x40,0x29,0x40,0x1F,0x40,0x00,0x00},/*"@",32*/
{0x00,0x40,0x07,0xC0,0x39,0x00,0x0F,0x00,0x01,0xC0,0x00,0x40},/*"A",33*/
{0x20,0x40,0x3F,0xC0,0x24,0x40,0x24,0x40,0x1B,0x80,0x00,0x00},/*"B",34*/
{0x1F,0x80,0x20,0x40,0x20,0x40,0x20,0x40,0x30,0x80,0x00,0x00},/*"C",35*/
{0x20,0x40,0x3F,0xC0,0x20,0x40,0x20,0x40,0x1F,0x80,0x00,0x00},/*"D",36*/
{0x20,0x40,0x3F,0xC0,0x24,0x40,0x2E,0x40,0x30,0xC0,0x00,0x00},/*"E",37*/
{0x20,0x40,0x3F,0xC0,0x24,0x40,0x2E,0x00,0x30,0x00,0x00,0x00},/*"F",38*/
{0x0F,0x00,0x10,0x80,0x20,0x40,0x22,0x40,0x33,0x80,0x02,0x00},/*"G",39*/
{0x20,0x40,0x3F,0xC0,0x04,0x00,0x04,0x00,0x3F,0xC0,0x20,0x40},/*"H",40*/
{0x20,0x40,0x20,0x40,0x3F,0xC0,0x20,0x40,0x20,0x40,0x00,0x00},/*"I",41*/
{0x00,0x60,0x20,0x20,0x20,0x20,0x3F,0xC0,0x20,0x00,0x20,0x00},/*"J",42*/
{0x20,0x40,0x3F,0xC0,0x24,0x40,0x0B,0x00,0x30,0xC0,0x20,0x40},/*"K",43*/
{0x20,0x40,0x3F,0xC0,0x20,0x40,0x00,0x40,0x00,0x40,0x00,0xC0},/*"L",44*/
{0x3F,0xC0,0x3C,0x00,0x03,0xC0,0x3C,0x00,0x3F,0xC0,0x00,0x00},/*"M",45*/
{0x20,0x40,0x3F,0xC0,0x0C,0x40,0x23,0x00,0x3F,0xC0,0x20,0x00},/*"N",46*/
{0x1F,0x80,0x20,0x40,0x20,0x40,0x20,0x40,0x1F,0x80,0x00,0x00},/*"O",47*/
{0x20,0x40,0x3F,0xC0,0x24,0x40,0x24,0x00,0x18,0x00,0x00,0x00},/*"P",48*/
{0x1F,0x80,0x21,0x40,0x21,0x40,0x20,0xE0,0x1F,0xA0,0x00,0x00},/*"Q",49*/
{0x20,0x40,0x3F,0xC0,0x24,0x40,0x26,0x00,0x19,0xC0,0x00,0x40},/*"R",50*/
{0x18,0xC0,0x24,0x40,0x24,0x40,0x22,0x40,0x31,0x80,0x00,0x00},/*"S",51*/
{0x30,0x00,0x20,0x40,0x3F,0xC0,0x20,0x40,0x30,0x00,0x00,0x00},/*"T",52*/
{0x20,0x00,0x3F,0x80,0x00,0x40,0x00,0x40,0x3F,0x80,0x20,0x00},/*"U",53*/
{0x20,0x00,0x3E,0x00,0x01,0xC0,0x07,0x00,0x38,0x00,0x20,0x00},/*"V",54*/
{0x38,0x00,0x07,0xC0,0x3C,0x00,0x07,0xC0,0x38,0x00,0x00,0x00},/*"W",55*/
{0x20,0x40,0x39,0xC0,0x06,0x00,0x39,0xC0,0x20,0x40,0x00,0x00},/*"X",56*/
{0x20,0x00,0x38,0x40,0x07,0xC0,0x38,0x40,0x20,0x00,0x00,0x00},/*"Y",57*/
{0x30,0x40,0x21,0xC0,0x26,0x40,0x38,0x40,0x20,0xC0,0x00,0x00},/*"Z",58*/
{0x00,0x00,0x00,0x00,0x7F,0xE0,0x40,0x20,0x40,0x20,0x00,0x00},/*"[",59*/
{0x00,0x00,0x70,0x00,0x0C,0x00,0x03,0x80,0x00,0x40,0x00,0x00},/*"\",60*/
{0x00,0x00,0x40,0x20,0x40,0x20,0x7F,0xE0,0x00,0x00,0x00,0x00},/*"]",61*/
{0x00,0x00,0x20,0x00,0x40,0x00,0x20,0x00,0x00,0x00,0x00,0x00},/*"^",62*/
{0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10},/*"_",63*/
{0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"`",64*/
{0x00,0x00,0x02,0x80,0x05,0x40,0x05,0x40,0x03,0xC0,0x00,0x40},/*"a",65*/
{0x20,0x00,0x3F,0xC0,0x04,0x40,0x04,0x40,0x03,0x80,0x00,0x00},/*"b",66*/
{0x00,0x00,0x03,0x80,0x04,0x40,0x04,0x40,0x06,0x40,0x00,0x00},/*"c",67*/
{0x00,0x00,0x03,0x80,0x04,0x40,0x24,0x40,0x3F,0xC0,0x00,0x40},/*"d",68*/
{0x00,0x00,0x03,0x80,0x05,0x40,0x05,0x40,0x03,0x40,0x00,0x00},/*"e",69*/
{0x00,0x00,0x04,0x40,0x1F,0xC0,0x24,0x40,0x24,0x40,0x20,0x00},/*"f",70*/
{0x00,0x00,0x02,0xE0,0x05,0x50,0x05,0x50,0x06,0x50,0x04,0x20},/*"g",71*/
{0x20,0x40,0x3F,0xC0,0x04,0x40,0x04,0x00,0x03,0xC0,0x00,0x40},/*"h",72*/
{0x00,0x00,0x04,0x40,0x27,0xC0,0x00,0x40,0x00,0x00,0x00,0x00},/*"i",73*/
{0x00,0x10,0x00,0x10,0x04,0x10,0x27,0xE0,0x00,0x00,0x00,0x00},/*"j",74*/
{0x20,0x40,0x3F,0xC0,0x01,0x40,0x07,0x00,0x04,0xC0,0x04,0x40},/*"k",75*/
{0x20,0x40,0x20,0x40,0x3F,0xC0,0x00,0x40,0x00,0x40,0x00,0x00},/*"l",76*/
{0x07,0xC0,0x04,0x00,0x07,0xC0,0x04,0x00,0x03,0xC0,0x00,0x00},/*"m",77*/
{0x04,0x40,0x07,0xC0,0x04,0x40,0x04,0x00,0x03,0xC0,0x00,0x40},/*"n",78*/
{0x00,0x00,0x03,0x80,0x04,0x40,0x04,0x40,0x03,0x80,0x00,0x00},/*"o",79*/
{0x04,0x10,0x07,0xF0,0x04,0x50,0x04,0x40,0x03,0x80,0x00,0x00},/*"p",80*/
{0x00,0x00,0x03,0x80,0x04,0x40,0x04,0x50,0x07,0xF0,0x00,0x10},/*"q",81*/
{0x04,0x40,0x07,0xC0,0x02,0x40,0x04,0x00,0x04,0x00,0x00,0x00},/*"r",82*/
{0x00,0x00,0x06,0x40,0x05,0x40,0x05,0x40,0x04,0xC0,0x00,0x00},/*"s",83*/
{0x00,0x00,0x04,0x00,0x1F,0x80,0x04,0x40,0x00,0x40,0x00,0x00},/*"t",84*/
{0x04,0x00,0x07,0x80,0x00,0x40,0x04,0x40,0x07,0xC0,0x00,0x40},/*"u",85*/
{0x04,0x00,0x07,0x00,0x04,0xC0,0x01,0x80,0x06,0x00,0x04,0x00},/*"v",86*/
{0x06,0x00,0x01,0xC0,0x07,0x00,0x01,0xC0,0x06,0x00,0x00,0x00},/*"w",87*/
{0x04,0x40,0x06,0xC0,0x01,0x00,0x06,0xC0,0x04,0x40,0x00,0x00},/*"x",88*/
{0x04,0x10,0x07,0x10,0x04,0xE0,0x01,0x80,0x06,0x00,0x04,0x00},/*"y",89*/
{0x00,0x00,0x04,0x40,0x05,0xC0,0x06,0x40,0x04,0x40,0x00,0x00},/*"z",90*/
{0x00,0x00,0x00,0x00,0x04,0x00,0x7B,0xE0,0x40,0x20,0x00,0x00},/*"{",91*/
{0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xF0,0x00,0x00,0x00,0x00},/*"|",92*/
{0x00,0x00,0x40,0x20,0x7B,0xE0,0x04,0x00,0x00,0x00,0x00,0x00},/*"}",93*/
{0x40,0x00,0x80,0x00,0x40,0x00,0x20,0x00,0x20,0x00,0x40,0x00},/*"~",94*/
};
//16*16
const unsigned char asc2_1608[95][16]={
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*" ",0*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xCC,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00},/*"!",1*/
{0x00,0x00,0x08,0x00,0x30,0x00,0x60,0x00,0x08,0x00,0x30,0x00,0x60,0x00,0x00,0x00},/*""",2*/
{0x02,0x20,0x03,0xFC,0x1E,0x20,0x02,0x20,0x03,0xFC,0x1E,0x20,0x02,0x20,0x00,0x00},/*"#",3*/
{0x00,0x00,0x0E,0x18,0x11,0x04,0x3F,0xFF,0x10,0x84,0x0C,0x78,0x00,0x00,0x00,0x00},/*"$",4*/
{0x0F,0x00,0x10,0x84,0x0F,0x38,0x00,0xC0,0x07,0x78,0x18,0x84,0x00,0x78,0x00,0x00},/*"%",5*/
{0x00,0x78,0x0F,0x84,0x10,0xC4,0x11,0x24,0x0E,0x98,0x00,0xE4,0x00,0x84,0x00,0x08},/*"&",6*/
{0x08,0x00,0x68,0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"'",7*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xE0,0x18,0x18,0x20,0x04,0x40,0x02,0x00,0x00},/*"(",8*/
{0x00,0x00,0x40,0x02,0x20,0x04,0x18,0x18,0x07,0xE0,0x00,0x00,0x00,0x00,0x00,0x00},/*")",9*/
{0x02,0x40,0x02,0x40,0x01,0x80,0x0F,0xF0,0x01,0x80,0x02,0x40,0x02,0x40,0x00,0x00},/*"*",10*/
{0x00,0x80,0x00,0x80,0x00,0x80,0x0F,0xF8,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x00},/*"+",11*/
{0x00,0x01,0x00,0x0D,0x00,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*",",12*/
{0x00,0x00,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80},/*"-",13*/
{0x00,0x00,0x00,0x0C,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*".",14*/
{0x00,0x00,0x00,0x06,0x00,0x18,0x00,0x60,0x01,0x80,0x06,0x00,0x18,0x00,0x20,0x00},/*"/",15*/
{0x00,0x00,0x07,0xF0,0x08,0x08,0x10,0x04,0x10,0x04,0x08,0x08,0x07,0xF0,0x00,0x00},/*"0",16*/
{0x00,0x00,0x08,0x04,0x08,0x04,0x1F,0xFC,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00},/*"1",17*/
{0x00,0x00,0x0E,0x0C,0x10,0x14,0x10,0x24,0x10,0x44,0x11,0x84,0x0E,0x0C,0x00,0x00},/*"2",18*/
{0x00,0x00,0x0C,0x18,0x10,0x04,0x11,0x04,0x11,0x04,0x12,0x88,0x0C,0x70,0x00,0x00},/*"3",19*/
{0x00,0x00,0x00,0xE0,0x03,0x20,0x04,0x24,0x08,0x24,0x1F,0xFC,0x00,0x24,0x00,0x00},/*"4",20*/
{0x00,0x00,0x1F,0x98,0x10,0x84,0x11,0x04,0x11,0x04,0x10,0x88,0x10,0x70,0x00,0x00},/*"5",21*/
{0x00,0x00,0x07,0xF0,0x08,0x88,0x11,0x04,0x11,0x04,0x18,0x88,0x00,0x70,0x00,0x00},/*"6",22*/
{0x00,0x00,0x1C,0x00,0x10,0x00,0x10,0xFC,0x13,0x00,0x1C,0x00,0x10,0x00,0x00,0x00},/*"7",23*/
{0x00,0x00,0x0E,0x38,0x11,0x44,0x10,0x84,0x10,0x84,0x11,0x44,0x0E,0x38,0x00,0x00},/*"8",24*/
{0x00,0x00,0x07,0x00,0x08,0x8C,0x10,0x44,0x10,0x44,0x08,0x88,0x07,0xF0,0x00,0x00},/*"9",25*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x0C,0x03,0x0C,0x00,0x00,0x00,0x00,0x00,0x00},/*":",26*/
{0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*";",27*/
{0x00,0x00,0x00,0x80,0x01,0x40,0x02,0x20,0x04,0x10,0x08,0x08,0x10,0x04,0x00,0x00},/*"<",28*/
{0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x00,0x00},/*"=",29*/
{0x00,0x00,0x10,0x04,0x08,0x08,0x04,0x10,0x02,0x20,0x01,0x40,0x00,0x80,0x00,0x00},/*">",30*/
{0x00,0x00,0x0E,0x00,0x12,0x00,0x10,0x0C,0x10,0x6C,0x10,0x80,0x0F,0x00,0x00,0x00},/*"?",31*/
{0x03,0xE0,0x0C,0x18,0x13,0xE4,0x14,0x24,0x17,0xC4,0x08,0x28,0x07,0xD0,0x00,0x00},/*"@",32*/
{0x00,0x04,0x00,0x3C,0x03,0xC4,0x1C,0x40,0x07,0x40,0x00,0xE4,0x00,0x1C,0x00,0x04},/*"A",33*/
{0x10,0x04,0x1F,0xFC,0x11,0x04,0x11,0x04,0x11,0x04,0x0E,0x88,0x00,0x70,0x00,0x00},/*"B",34*/
{0x03,0xE0,0x0C,0x18,0x10,0x04,0x10,0x04,0x10,0x04,0x10,0x08,0x1C,0x10,0x00,0x00},/*"C",35*/
{0x10,0x04,0x1F,0xFC,0x10,0x04,0x10,0x04,0x10,0x04,0x08,0x08,0x07,0xF0,0x00,0x00},/*"D",36*/
{0x10,0x04,0x1F,0xFC,0x11,0x04,0x11,0x04,0x17,0xC4,0x10,0x04,0x08,0x18,0x00,0x00},/*"E",37*/
{0x10,0x04,0x1F,0xFC,0x11,0x04,0x11,0x00,0x17,0xC0,0x10,0x00,0x08,0x00,0x00,0x00},/*"F",38*/
{0x03,0xE0,0x0C,0x18,0x10,0x04,0x10,0x04,0x10,0x44,0x1C,0x78,0x00,0x40,0x00,0x00},/*"G",39*/
{0x10,0x04,0x1F,0xFC,0x10,0x84,0x00,0x80,0x00,0x80,0x10,0x84,0x1F,0xFC,0x10,0x04},/*"H",40*/
{0x00,0x00,0x10,0x04,0x10,0x04,0x1F,0xFC,0x10,0x04,0x10,0x04,0x00,0x00,0x00,0x00},/*"I",41*/
{0x00,0x03,0x00,0x01,0x10,0x01,0x10,0x01,0x1F,0xFE,0x10,0x00,0x10,0x00,0x00,0x00},/*"J",42*/
{0x10,0x04,0x1F,0xFC,0x11,0x04,0x03,0x80,0x14,0x64,0x18,0x1C,0x10,0x04,0x00,0x00},/*"K",43*/
{0x10,0x04,0x1F,0xFC,0x10,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x0C,0x00,0x00},/*"L",44*/
{0x10,0x04,0x1F,0xFC,0x1F,0x00,0x00,0xFC,0x1F,0x00,0x1F,0xFC,0x10,0x04,0x00,0x00},/*"M",45*/
{0x10,0x04,0x1F,0xFC,0x0C,0x04,0x03,0x00,0x00,0xE0,0x10,0x18,0x1F,0xFC,0x10,0x00},/*"N",46*/
{0x07,0xF0,0x08,0x08,0x10,0x04,0x10,0x04,0x10,0x04,0x08,0x08,0x07,0xF0,0x00,0x00},/*"O",47*/
{0x10,0x04,0x1F,0xFC,0x10,0x84,0x10,0x80,0x10,0x80,0x10,0x80,0x0F,0x00,0x00,0x00},/*"P",48*/
{0x07,0xF0,0x08,0x18,0x10,0x24,0x10,0x24,0x10,0x1C,0x08,0x0A,0x07,0xF2,0x00,0x00},/*"Q",49*/
{0x10,0x04,0x1F,0xFC,0x11,0x04,0x11,0x00,0x11,0xC0,0x11,0x30,0x0E,0x0C,0x00,0x04},/*"R",50*/
{0x00,0x00,0x0E,0x1C,0x11,0x04,0x10,0x84,0x10,0x84,0x10,0x44,0x1C,0x38,0x00,0x00},/*"S",51*/
{0x18,0x00,0x10,0x00,0x10,0x04,0x1F,0xFC,0x10,0x04,0x10,0x00,0x18,0x00,0x00,0x00},/*"T",52*/
{0x10,0x00,0x1F,0xF8,0x10,0x04,0x00,0x04,0x00,0x04,0x10,0x04,0x1F,0xF8,0x10,0x00},/*"U",53*/
{0x10,0x00,0x1E,0x00,0x11,0xE0,0x00,0x1C,0x00,0x70,0x13,0x80,0x1C,0x00,0x10,0x00},/*"V",54*/
{0x1F,0xC0,0x10,0x3C,0x00,0xE0,0x1F,0x00,0x00,0xE0,0x10,0x3C,0x1F,0xC0,0x00,0x00},/*"W",55*/
{0x10,0x04,0x18,0x0C,0x16,0x34,0x01,0xC0,0x01,0xC0,0x16,0x34,0x18,0x0C,0x10,0x04},/*"X",56*/
{0x10,0x00,0x1C,0x00,0x13,0x04,0x00,0xFC,0x13,0x04,0x1C,0x00,0x10,0x00,0x00,0x00},/*"Y",57*/
{0x08,0x04,0x10,0x1C,0x10,0x64,0x10,0x84,0x13,0x04,0x1C,0x04,0x10,0x18,0x00,0x00},/*"Z",58*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFE,0x40,0x02,0x40,0x02,0x40,0x02,0x00,0x00},/*"[",59*/
{0x00,0x00,0x30,0x00,0x0C,0x00,0x03,0x80,0x00,0x60,0x00,0x1C,0x00,0x03,0x00,0x00},/*"\",60*/
{0x00,0x00,0x40,0x02,0x40,0x02,0x40,0x02,0x7F,0xFE,0x00,0x00,0x00,0x00,0x00,0x00},/*"]",61*/
{0x00,0x00,0x00,0x00,0x20,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x20,0x00,0x00,0x00},/*"^",62*/
{0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01},/*"_",63*/
{0x00,0x00,0x40,0x00,0x40,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"`",64*/
{0x00,0x00,0x00,0x98,0x01,0x24,0x01,0x44,0x01,0x44,0x01,0x44,0x00,0xFC,0x00,0x04},/*"a",65*/
{0x10,0x00,0x1F,0xFC,0x00,0x88,0x01,0x04,0x01,0x04,0x00,0x88,0x00,0x70,0x00,0x00},/*"b",66*/
{0x00,0x00,0x00,0x70,0x00,0x88,0x01,0x04,0x01,0x04,0x01,0x04,0x00,0x88,0x00,0x00},/*"c",67*/
{0x00,0x00,0x00,0x70,0x00,0x88,0x01,0x04,0x01,0x04,0x11,0x08,0x1F,0xFC,0x00,0x04},/*"d",68*/
{0x00,0x00,0x00,0xF8,0x01,0x44,0x01,0x44,0x01,0x44,0x01,0x44,0x00,0xC8,0x00,0x00},/*"e",69*/
{0x00,0x00,0x01,0x04,0x01,0x04,0x0F,0xFC,0x11,0x04,0x11,0x04,0x11,0x00,0x18,0x00},/*"f",70*/
{0x00,0x00,0x00,0xD6,0x01,0x29,0x01,0x29,0x01,0x29,0x01,0xC9,0x01,0x06,0x00,0x00},/*"g",71*/
{0x10,0x04,0x1F,0xFC,0x00,0x84,0x01,0x00,0x01,0x00,0x01,0x04,0x00,0xFC,0x00,0x04},/*"h",72*/
{0x00,0x00,0x01,0x04,0x19,0x04,0x19,0xFC,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00},/*"i",73*/
{0x00,0x00,0x00,0x03,0x00,0x01,0x01,0x01,0x19,0x01,0x19,0xFE,0x00,0x00,0x00,0x00},/*"j",74*/
{0x10,0x04,0x1F,0xFC,0x00,0x24,0x00,0x40,0x01,0xB4,0x01,0x0C,0x01,0x04,0x00,0x00},/*"k",75*/
{0x00,0x00,0x10,0x04,0x10,0x04,0x1F,0xFC,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00},/*"l",76*/
{0x01,0x04,0x01,0xFC,0x01,0x04,0x01,0x00,0x01,0xFC,0x01,0x04,0x01,0x00,0x00,0xFC},/*"m",77*/
{0x01,0x04,0x01,0xFC,0x00,0x84,0x01,0x00,0x01,0x00,0x01,0x04,0x00,0xFC,0x00,0x04},/*"n",78*/
{0x00,0x00,0x00,0xF8,0x01,0x04,0x01,0x04,0x01,0x04,0x01,0x04,0x00,0xF8,0x00,0x00},/*"o",79*/
{0x01,0x01,0x01,0xFF,0x00,0x85,0x01,0x04,0x01,0x04,0x00,0x88,0x00,0x70,0x00,0x00},/*"p",80*/
{0x00,0x00,0x00,0x70,0x00,0x88,0x01,0x04,0x01,0x04,0x01,0x05,0x01,0xFF,0x00,0x01},/*"q",81*/
{0x01,0x04,0x01,0x04,0x01,0xFC,0x00,0x84,0x01,0x04,0x01,0x00,0x01,0x80,0x00,0x00},/*"r",82*/
{0x00,0x00,0x00,0xCC,0x01,0x24,0x01,0x24,0x01,0x24,0x01,0x24,0x01,0x98,0x00,0x00},/*"s",83*/
{0x00,0x00,0x01,0x00,0x01,0x00,0x07,0xF8,0x01,0x04,0x01,0x04,0x00,0x00,0x00,0x00},/*"t",84*/
{0x01,0x00,0x01,0xF8,0x00,0x04,0x00,0x04,0x00,0x04,0x01,0x08,0x01,0xFC,0x00,0x04},/*"u",85*/
{0x01,0x00,0x01,0x80,0x01,0x70,0x00,0x0C,0x00,0x10,0x01,0x60,0x01,0x80,0x01,0x00},/*"v",86*/
{0x01,0xF0,0x01,0x0C,0x00,0x30,0x01,0xC0,0x00,0x30,0x01,0x0C,0x01,0xF0,0x01,0x00},/*"w",87*/
{0x00,0x00,0x01,0x04,0x01,0x8C,0x00,0x74,0x01,0x70,0x01,0x8C,0x01,0x04,0x00,0x00},/*"x",88*/
{0x01,0x01,0x01,0x81,0x01,0x71,0x00,0x0E,0x00,0x18,0x01,0x60,0x01,0x80,0x01,0x00},/*"y",89*/
{0x00,0x00,0x01,0x84,0x01,0x0C,0x01,0x34,0x01,0x44,0x01,0x84,0x01,0x0C,0x00,0x00},/*"z",90*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x3E,0xFC,0x40,0x02,0x40,0x02},/*"{",91*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00},/*"|",92*/
{0x00,0x00,0x40,0x02,0x40,0x02,0x3E,0xFC,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"}",93*/
{0x00,0x00,0x60,0x00,0x80,0x00,0x80,0x00,0x40,0x00,0x40,0x00,0x20,0x00,0x20,0x00},/*"~",94*/
};
@@ -0,0 +1,18 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : lcd_font.h
* Author : WCH
* Version : V1.0.1
* Date : 2025/09/15
* Description : ASCII character library.
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#ifndef __LCD_FONT_H
#define __LCD_FONT_H
extern const unsigned char asc2_1206[95][12];
extern const unsigned char asc2_1608[95][16];
#endif
@@ -0,0 +1,36 @@
/*********************************************************************
* File Name : config.h
* Author : WCH
* Version : V1.0.0
* Date : 2023/8/15
* Description : file for Config.
*********************************************************************************
* Copyright (c) 2023 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#ifndef __CONFIG_H__
#define __CONFIG_H__
/* SPI FLASH and LCD_SCREEN GPIO Definition */
#define FLASH_CS_PORT GPIOA
#define FLASH_CS_RCC RCC_APB2Periph_GPIOA
#define FLASH_CS_PIN (GPIO_Pin_4)
#define LCD_LED_RCC RCC_APB2Periph_GPIOB
#define LCD_LED_PORT GPIOB
#define LCD_LED_PIN (GPIO_Pin_9)
#define LCD_DC_RCC RCC_APB2Periph_GPIOB
#define LCD_DC_PORT GPIOB
#define LCD_DC_PIN (GPIO_Pin_10)
#define LCD_RST_RCC RCC_APB2Periph_GPIOB
#define LCD_RST_PORT GPIOB
#define LCD_RST_PIN (GPIO_Pin_11)
#define LCD_CS_RCC RCC_APB2Periph_GPIOB
#define LCD_CS_PORT GPIOB
#define LCD_CS_PIN (GPIO_Pin_12)
#endif
@@ -0,0 +1,465 @@
/*********************************************************************
* File Name : flash.c
* Author : WCH
* Version : V1.0.0
* Date : 2023/8/15
* Description : file for spi flash.
*********************************************************************************
* Copyright (c) 2023 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#include "flash.h"
#include "spi.h"
static uint8_t FLASH_readWrite(uint8_t TxData)
{
while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET)
;
SPI_I2S_SendData(SPI1, TxData);
while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET)
;
return SPI_I2S_ReceiveData(SPI1);
}
/*********************************************************************
* @fn cs_pin_init
*
* @brief gpio cs pin init
*
* @return none
*/
static void cs_pin_init()
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(FLASH_CS_RCC, ENABLE);
GPIO_InitStructure.GPIO_Pin = FLASH_CS_PIN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(FLASH_CS_PORT, &GPIO_InitStructure);
}
/*********************************************************************
* @fn SPI_FLASH_Init
*
* @brief SPI FLASH Init
*
* @return none
*/
void SPI_FLASH_Init(void)
{
SPI1_Init();
SPI1_Read_DMA_Init();
cs_pin_init();
FLASH_CS_SET;
}
/*********************************************************************
* @fn SPI_Flash_ReadSR
*
* @brief Read W25Qxx status register.
* !!BIT7 6 5 4 3 2 1 0
* !!SPR RV TB BP2 BP1 BP0 WEL BUSY
*
* @return byte - status register value.
*/
uint8_t SPI_Flash_ReadSR(void)
{
uint8_t byte = 0;
FLASH_CS_CLR;
FLASH_readWrite(W25X_ReadStatusReg);
byte = FLASH_readWrite(0Xff);
FLASH_CS_SET;
return byte;
}
/*********************************************************************
* @fn SPI_FLASH_Write_SR
*
* @brief Write W25Qxx status register.
*
* @param sr - status register value.
*
* @return none
*/
void SPI_FLASH_Write_SR(uint8_t sr)
{
FLASH_CS_CLR;
FLASH_readWrite(W25X_WriteStatusReg);
FLASH_readWrite(sr);
FLASH_CS_SET;
}
/*********************************************************************
* @fn SPI_Flash_Wait_Busy
*
* @brief Wait flash free.
*
* @return none
*/
void SPI_Flash_Wait_Busy(void)
{
while ((SPI_Flash_ReadSR() & 0x01) == 0x01)
;
}
/*********************************************************************
* @fn SPI_FLASH_Write_Enable
*
* @brief Enable flash write.
*
* @return none
*/
void SPI_FLASH_Write_Enable(void)
{
FLASH_CS_CLR;
FLASH_readWrite(W25X_WriteEnable);
FLASH_CS_SET;
}
/*********************************************************************
* @fn SPI_FLASH_Write_Disable
*
* @brief Disable flash write.
*
* @return none
*/
void SPI_FLASH_Write_Disable(void)
{
FLASH_CS_CLR;
FLASH_readWrite(W25X_WriteDisable);
FLASH_CS_SET;
}
/*********************************************************************
* @fn SPI_Flash_ReadID
*
* @brief Read flash ID.
*
* @return Temp - FLASH ID.
*/
uint16_t SPI_Flash_ReadID(void)
{
uint16_t Temp = 0;
FLASH_CS_CLR;
FLASH_readWrite(W25X_ManufactDeviceID);
FLASH_readWrite(0x00);
FLASH_readWrite(0x00);
FLASH_readWrite(0x00);
Temp |= FLASH_readWrite(0xFF) << 8;
Temp |= FLASH_readWrite(0xFF);
FLASH_CS_SET;
return Temp;
}
/*********************************************************************
* @fn SPI_Flash_ReadJedecDeviceID
*
* @brief Read JedecDevice ID.
*
* @return JedecDevice ID.
*/
uint32_t SPI_Flash_ReadJedecDeviceID(void)
{
uint32_t Temp = 0;
FLASH_CS_CLR;
FLASH_readWrite(W25X_JedecDeviceID);
Temp |= FLASH_readWrite(0xFF) << 16;
Temp |= FLASH_readWrite(0xFF) << 8;
Temp |= FLASH_readWrite(0xFF);
FLASH_CS_SET;
return Temp;
}
/*********************************************************************
* @fn SPI_Flash_Erase_Sector
*
* @brief Erase one sector(4Kbyte).
*
* @param Dst_Addr - 0 !! 2047
*
* @return none
*/
void SPI_Flash_Erase_Sector(uint32_t Dst_Addr)
{
Dst_Addr *= 4096;
SPI_FLASH_Write_Enable();
SPI_Flash_Wait_Busy();
FLASH_CS_CLR;
FLASH_readWrite(W25X_SectorErase);
FLASH_readWrite((uint8_t)((Dst_Addr) >> 16));
FLASH_readWrite((uint8_t)((Dst_Addr) >> 8));
FLASH_readWrite((uint8_t)Dst_Addr);
FLASH_CS_SET;
SPI_Flash_Wait_Busy();
}
/*********************************************************************
* @fn SPI_Flash_Read
*
* @brief Read data from flash.
*
* @param pBuffer -
* ReadAddr -Initial address(24bit).
* size - Data length.
*
* @return none
*/
void SPI_Flash_Read(uint8_t *pBuffer, uint32_t ReadAddr, uint16_t size)
{
uint16_t i;
FLASH_CS_CLR;
FLASH_readWrite(W25X_ReadData);
FLASH_readWrite((uint8_t)((ReadAddr) >> 16));
FLASH_readWrite((uint8_t)((ReadAddr) >> 8));
FLASH_readWrite((uint8_t)ReadAddr);
for (i = 0; i < size; i++)
{
pBuffer[i] = FLASH_readWrite(0XFF);
}
FLASH_CS_SET;
}
/*********************************************************************
* @fn SPI_Flash_Write_Page
*
* @brief Write data by one page.
*
* @param pBuffer -
* WriteAddr - Initial address(24bit).
* size - Data length.
*
* @return none
*/
void SPI_Flash_Write_Page(uint8_t *pBuffer, uint32_t WriteAddr, uint16_t size)
{
uint16_t i;
SPI_FLASH_Write_Enable();
FLASH_CS_CLR;
FLASH_readWrite(W25X_PageProgram);
FLASH_readWrite((uint8_t)((WriteAddr) >> 16));
FLASH_readWrite((uint8_t)((WriteAddr) >> 8));
FLASH_readWrite((uint8_t)WriteAddr);
for (i = 0; i < size; i++)
{
FLASH_readWrite(pBuffer[i]);
}
FLASH_CS_SET;
SPI_Flash_Wait_Busy();
}
/*********************************************************************
* @fn SPI_Flash_Write_NoCheck
*
* @brief Write data to flash.(need Erase)
* All data in address rang is 0xFF.
*
* @param pBuffer -
* WriteAddr - Initial address(24bit).
* size - Data length.
*
* @return none
*/
void SPI_Flash_Write_NoCheck(uint8_t *pBuffer, uint32_t WriteAddr, uint16_t size)
{
uint16_t pageremain;
pageremain = 256 - WriteAddr % 256;
if (size <= pageremain)
pageremain = size;
while (1)
{
SPI_Flash_Write_Page(pBuffer, WriteAddr, pageremain);
if (size == pageremain)
{
break;
}
else
{
pBuffer += pageremain;
WriteAddr += pageremain;
size -= pageremain;
if (size > 256)
pageremain = 256;
else
pageremain = size;
}
}
}
static uint8_t W25QXX_BUFFER[4096];
/*********************************************************************
* @fn SPI_Flash_Write
*
* @brief Write data to flash.(no need Erase)
*
* @param pBuffer -
* WriteAddr - Initial address(24bit).
* size - Data length.
*
* @return none
*/
void SPI_Flash_Write(uint8_t *pBuffer, uint32_t WriteAddr, uint16_t size)
{
uint32_t secpos;
uint16_t secoff;
uint16_t secremain;
uint16_t i;
secpos = WriteAddr / 4096;
secoff = WriteAddr % 4096;
secremain = 4096 - secoff;
if (size <= secremain)
secremain = size;
while (1)
{
SPI_Flash_Read(W25QXX_BUFFER, secpos * 4096, 4096);
for (i = 0; i < secremain; i++)
{
if (W25QXX_BUFFER[secoff + i] != 0XFF)
break;
}
if (i < secremain)
{
SPI_Flash_Erase_Sector(secpos);
for (i = 0; i < secremain; i++)
{
W25QXX_BUFFER[i + secoff] = pBuffer[i];
}
SPI_Flash_Write_NoCheck(W25QXX_BUFFER, secpos * 4096, 4096);
}
else
{
SPI_Flash_Write_NoCheck(pBuffer, WriteAddr, secremain);
}
if (size == secremain)
{
break;
}
else
{
secpos++;
secoff = 0;
pBuffer += secremain;
WriteAddr += secremain;
size -= secremain;
if (size > 4096)
{
secremain = 4096;
}
else
{
secremain = size;
}
}
}
}
/*********************************************************************
* @fn SPI_Flash_Erase_Block
*
* @brief Erase all FLASH pages.
*
*
* @return none
*/
void SPI_Flash_Erase_Block(uint32_t Dst_Addr)
{
SPI_FLASH_Write_Enable();
SPI_Flash_Wait_Busy();
FLASH_CS_CLR;
FLASH_readWrite(W25X_BlockErase);
FLASH_readWrite((uint8_t)((Dst_Addr) >> 16));
FLASH_readWrite((uint8_t)((Dst_Addr) >> 8));
FLASH_readWrite((uint8_t)Dst_Addr);
FLASH_CS_SET;
SPI_Flash_Wait_Busy();
}
/*********************************************************************
* @fn SPI_Flash_PowerDown
*
* @brief Enter power down mode.
*
* @return none
*/
void SPI_Flash_PowerDown(void)
{
FLASH_CS_CLR;
FLASH_readWrite(W25X_PowerDown);
FLASH_CS_SET;
Delay_Us(3);
}
/*********************************************************************
* @fn SPI_Flash_WAKEUP
*
* @brief Power down wake up.
*
* @return none
*/
void SPI_Flash_WAKEUP(void)
{
FLASH_CS_CLR;
FLASH_readWrite(W25X_ReleasePowerDown);
FLASH_CS_SET;
Delay_Us(3);
}
/*********************************************************************
* @fn SPI_Flash_Read_dma_start
*
* @brief enable spi dma and set read address
*
* @param ReadAddr - the address in spi flash
*
* @return none
*/
void SPI_Flash_Read_dma_start(uint32_t ReadAddr)
{
FLASH_CS_CLR;
FLASH_readWrite(W25X_FastReadData);
FLASH_readWrite((uint8_t)((ReadAddr) >> 16));
FLASH_readWrite((uint8_t)((ReadAddr) >> 8));
FLASH_readWrite((uint8_t)ReadAddr);
FLASH_readWrite(0xFF);
SPI_I2S_DMACmd(SPI1, SPI_I2S_DMAReq_Tx | SPI_I2S_DMAReq_Rx, ENABLE);
}
/*********************************************************************
* @fn SPI_Flash_Read_dma_end
*
* @brief disable spi dma
*
* @return none
*/
void SPI_Flash_Read_dma_end(void)
{
FLASH_CS_SET;
SPI_I2S_DMACmd(SPI1, SPI_I2S_DMAReq_Tx | SPI_I2S_DMAReq_Rx, DISABLE);
}
@@ -0,0 +1,57 @@
/*********************************************************************
* File Name : flash.h
* Author : WCH
* Version : V1.0.0
* Date : 2023/8/15
* Description : file for spi flash.
*********************************************************************************
* Copyright (c) 2023 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#ifndef __SPI_FLASH_H
#define __SPI_FLASH_H
#include "debug.h"
#include "spi.h"
#include "config.h"
#define W25X_WriteEnable 0x06
#define W25X_WriteDisable 0x04
#define W25X_ReadStatusReg 0x05
#define W25X_WriteStatusReg 0x01
#define W25X_ReadData 0x03
#define W25X_FastReadData 0x0B
#define W25X_FastReadDual 0x3B
#define W25X_PageProgram 0x02
#define W25X_BlockErase 0xD8
#define W25X_SectorErase 0x20
#define W25X_ChipErase 0xC7
#define W25X_PowerDown 0xB9
#define W25X_ReleasePowerDown 0xAB
#define W25X_DeviceID 0xAB
#define W25X_ManufactDeviceID 0x90
#define W25X_JedecDeviceID 0x9F
#define FLASH_CS_SET (FLASH_CS_PORT->BSHR = FLASH_CS_PIN)
#define FLASH_CS_CLR (FLASH_CS_PORT->BCR = FLASH_CS_PIN)
void SPI_FLASH_Init(void);
uint8_t SPI_Flash_ReadSR(void);
void SPI_FLASH_Write_SR(uint8_t sr);
void SPI_Flash_Wait_Busy(void);
void SPI_FLASH_Write_Enable(void);
void SPI_FLASH_Write_Disable(void);
uint16_t SPI_Flash_ReadID(void);
uint32_t SPI_Flash_ReadJedecDeviceID(void);
void SPI_Flash_Erase_Sector(uint32_t Dst_Addr);
void SPI_Flash_Read(uint8_t *pBuffer, uint32_t ReadAddr, uint16_t size);
void SPI_Flash_Write_Page(uint8_t *pBuffer, uint32_t WriteAddr, uint16_t size);
void SPI_Flash_Write_NoCheck(uint8_t *pBuffer, uint32_t WriteAddr, uint16_t size);
void SPI_Flash_Write(uint8_t *pBuffer, uint32_t WriteAddr, uint16_t size);
void SPI_Flash_Erase_Chip(void);
void SPI_Flash_PowerDown(void);
void SPI_Flash_WAKEUP(void);
void SPI_Flash_Read_dma_start(uint32_t ReadAddr);
void SPI_Flash_Read_dma_end(void);
#endif
+247
View File
@@ -0,0 +1,247 @@
/*********************************************************************
* File Name : spi.c
* Author : WCH
* Version : V1.0.0
* Date : 2023/8/15
* Description : file for spi.
*********************************************************************************
* Copyright (c) 2023 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#include "spi.h"
/*********************************************************************
* @fn SPI1_Init
*
* @brief Initialize SPI1
*
* @return none
*/
void SPI1_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure = {0};
SPI_InitTypeDef SPI_InitStructure = {0};
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_SPI1, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
SPI_InitStructure.SPI_CPOL = SPI_CPOL_High;
SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge;
SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_4;
SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
SPI_InitStructure.SPI_CRCPolynomial = 7;
SPI_Init(SPI1, &SPI_InitStructure);
SPI_Cmd(SPI1, ENABLE);
SPI1->HSCR = 1;
}
/*********************************************************************
* @fn SPI1_Read_DMA_Init
*
* @brief Initialize DMA for SPI1, In this condition every time send 0XFF to read data
*
* @return none
*/
void SPI1_Read_DMA_Init()
{
static uint32_t DummyByte = 0xff;
DMA_InitTypeDef DMA_InitStructure = {0};
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
// Tx
DMA_DeInit(SPI1_DMA_TX_CH);
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&SPI1->DATAR;
DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)&DummyByte;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST;
DMA_InitStructure.DMA_BufferSize = 0;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Disable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
DMA_Init(SPI1_DMA_TX_CH, &DMA_InitStructure);
// Rx
DMA_DeInit(SPI1_DMA_RX_CH);
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&SPI1->DATAR;
DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)NULL;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
DMA_InitStructure.DMA_BufferSize = 0;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
DMA_Init(SPI1_DMA_RX_CH, &DMA_InitStructure);
}
/*********************************************************************
* @fn SPI1_Read_DMA
*
* @brief read data from SPI1 via DMA
*
* @param data - the data to recive
* len - read length
*
* @return none
*/
void SPI1_Read_DMA(uint8_t* data, uint16_t len)
{
while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_BSY) == SET)
;
DMA_Cmd(SPI1_DMA_TX_CH, DISABLE);
DMA_Cmd(SPI1_DMA_RX_CH, DISABLE);
DMA_ClearFlag(DMA1_FLAG_TC3);
DMA_ClearFlag(DMA1_FLAG_TC3);
SPI1_DMA_TX_CH->CNTR = len;
SPI1_DMA_RX_CH->MADDR = (uint32_t)data;
SPI1_DMA_RX_CH->CNTR = len;
DMA_Cmd(SPI1_DMA_TX_CH, ENABLE);
DMA_Cmd(SPI1_DMA_RX_CH, ENABLE);
}
/*********************************************************************
* @fn SPI2_Init
*
* @brief Initialize SPI2
*
* @return none
*/
void SPI2_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure = {0};
SPI_InitTypeDef SPI_InitStructure = {0};
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB, ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_14;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure);
SPI_InitStructure.SPI_Direction = SPI_Direction_1Line_Tx;
SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;
SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge;
SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2;
SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
SPI_InitStructure.SPI_CRCPolynomial = 7;
SPI_Init(SPI2, &SPI_InitStructure);
SPI_Cmd(SPI2, ENABLE);
}
/*********************************************************************
* @fn SPI2_DMA_Init
*
* @brief Initialize DMA for SPI2
*
* @return none
*/
void SPI2_DMA_Init()
{
DMA_InitTypeDef DMA_InitStructure = {0};
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
DMA_DeInit(SPI2_DMA_TX_CH);
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&SPI2->DATAR;
DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)NULL;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST;
DMA_InitStructure.DMA_BufferSize = 0;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
DMA_Init(SPI2_DMA_TX_CH, &DMA_InitStructure);
SPI_I2S_DMACmd(SPI2, SPI_I2S_DMAReq_Tx, ENABLE);
}
/*********************************************************************
* @fn SPI2_Write
*
* @brief send one byte
*
* @param data - the data to send
*
* @return none
*/
void SPI2_Write(uint8_t data)
{
while (SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_TXE) == RESET)
;
SPI_I2S_SendData(SPI2, data);
while (SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_BSY) == SET)
;
}
/*********************************************************************
* @fn SPI2_Write_DMA
*
* @brief send a lot of data
*
* @param data - the data to be send
* len - the length of data
*
* @return none
*/
void SPI2_Write_DMA(uint8_t* data, uint16_t len)
{
while (SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_BSY) == SET)
;
DMA_Cmd(SPI2_DMA_TX_CH, DISABLE);
DMA_ClearFlag(SPI2_DMA_TC_FLAG);
SPI2_DMA_TX_CH->MADDR = (uint32_t)data;
SPI2_DMA_TX_CH->CNTR = len;
SPI2_DMA_TX_CH->CFGR = 0x2090;
DMA_Cmd(SPI2_DMA_TX_CH, ENABLE);
}
@@ -0,0 +1,39 @@
/*********************************************************************
* File Name : spi.h
* Author : WCH
* Version : V1.0.0
* Date : 2023/8/15
* Description : file for spi.
*********************************************************************************
* Copyright (c) 2023 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#ifndef __SPI_H__
#define __SPI_H__
#include "debug.h"
#include "config.h"
#define SPI1_DMA_RX_CH DMA1_Channel2
#define SPI1_DMA_TX_CH DMA1_Channel3
#define SPI1_DMA_TC_FLAG DMA1_FLAG_TC3
#define SPI1_DMA_RC_FLAG DMA1_FLAG_TC2
#define SPI2_DMA_RX_CH DMA1_Channel4
#define SPI2_DMA_TX_CH DMA1_Channel5
#define SPI2_DMA_TC_FLAG DMA1_FLAG_TC5
#define SPI2_DMA_RC_FLAG DMA1_FLAG_TC4
void SPI1_Init(void);
void SPI1_Read_DMA_Init(void);
void SPI1_Read_DMA(uint8_t *data, uint16_t len);
void SPI2_Init(void);
void SPI2_DMA_Init(void);
void SPI2_Write(uint8_t data);
void SPI2_Write_DMA(uint8_t *data, uint16_t len);
#endif
@@ -0,0 +1,42 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : ch32v20x_conf.h
* Author : WCH
* Version : V1.0.0
* Date : 2021/06/06
* Description : Library configuration file.
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#ifndef __CH32V20x_CONF_H
#define __CH32V20x_CONF_H
#include "ch32v20x_adc.h"
#include "ch32v20x_bkp.h"
#include "ch32v20x_can.h"
#include "ch32v20x_crc.h"
#include "ch32v20x_dbgmcu.h"
#include "ch32v20x_dma.h"
#include "ch32v20x_exti.h"
#include "ch32v20x_flash.h"
#include "ch32v20x_gpio.h"
#include "ch32v20x_i2c.h"
#include "ch32v20x_iwdg.h"
#include "ch32v20x_pwr.h"
#include "ch32v20x_rcc.h"
#include "ch32v20x_rtc.h"
#include "ch32v20x_spi.h"
#include "ch32v20x_tim.h"
#include "ch32v20x_usart.h"
#include "ch32v20x_wwdg.h"
#include "ch32v20x_it.h"
#include "ch32v20x_misc.h"
#endif /* __CH32V20x_CONF_H */
@@ -0,0 +1,46 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : ch32v20x_it.c
* Author : WCH
* Version : V1.0.0
* Date : 2023/12/29
* Description : Main Interrupt Service Routines.
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#include "ch32v20x_it.h"
void NMI_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void HardFault_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
/*********************************************************************
* @fn NMI_Handler
*
* @brief This function handles NMI exception.
*
* @return none
*/
void NMI_Handler(void)
{
while (1)
{
}
}
/*********************************************************************
* @fn HardFault_Handler
*
* @brief This function handles Hard Fault exception.
*
* @return none
*/
void HardFault_Handler(void)
{
NVIC_SystemReset();
while (1)
{
}
}
@@ -0,0 +1,20 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : ch32v20x_it.h
* Author : WCH
* Version : V1.0.0
* Date : 2021/06/06
* Description : This file contains the headers of the interrupt handlers.
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#ifndef __CH32V20x_IT_H
#define __CH32V20x_IT_H
#include "debug.h"
#endif /* __CH32V20x_IT_H */
+304
View File
@@ -0,0 +1,304 @@
/*********************************************************************
* File Name : main.c
* Author : WCH
* Version : V1.0.0
* Date : 2026/08/06
* Description : Main program body.
*********************************************************************************
* Copyright (c) 2023 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
/*
*@Note
A demo for wui
pins:
FLASH_CS -- PA4
FLASH_DO -- PA6
FLASH_DI -- PA7
FLASH_CLK -- PA5
LCD_LED -- PB9
LCD_DC -- PB10
LCD_RST -- PB11
LCD_CS -- PB12
LCD_SCK -- PB13
LCD_MOSI -- PB15
*/
#include <math.h>
#include "debug.h"
#include "string.h"
#include "lcd.h"
#include "flash.h"
#include "config.h"
#include "wui.h"
#include "wui_port.h"
#include "wui_user/wui_page.h"
/* Global define */
/* Global Variable */
#define TIM_PCK (8000ul)
/*********************************************************************
* @fn TIM4_init
*
* @brief Initialize TIM2 for WCHGUI
*
* @return none.
*/
void TIM4_init()
{
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4, ENABLE);
TIM_TimeBaseInitTypeDef TIM_TimeBaseInitStructure = {0};
TIM_Cmd(TIM4, DISABLE);
TIM_TimeBaseInitStructure.TIM_Period = 0xffff;
TIM_TimeBaseInitStructure.TIM_Prescaler = ((SystemCoreClock) / TIM_PCK) - 1;
TIM_TimeBaseInitStructure.TIM_ClockDivision = TIM_CKD_DIV1;
TIM_TimeBaseInitStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM4, &TIM_TimeBaseInitStructure);
TIM_ARRPreloadConfig(TIM4, DISABLE);
TIM_ClearFlag(TIM4, TIM_FLAG_Update);
TIM_Cmd(TIM4, ENABLE);
}
/*********************************************************************
* @fn TIM3_Encoder_Init
*
* @brief Initialize TIM1 for encoder
*
* @return none.
*/
void TIM3_Encoder_Init()
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
TIM_ICInitTypeDef TIM_ICInitStructure;
GPIO_InitTypeDef GPIO_InitStructure = {0};
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
{
GPIO_PinRemapConfig(GPIO_PartialRemap_TIM3, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOB, &GPIO_InitStructure);
}
TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
TIM_TimeBaseStructure.TIM_Prescaler = 0x0;
TIM_TimeBaseStructure.TIM_Period = 160;
TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure);
TIM_EncoderInterfaceConfig(TIM3, TIM_EncoderMode_TI12, TIM_ICPolarity_Rising, TIM_ICPolarity_Rising);
TIM_ICStructInit(&TIM_ICInitStructure);
TIM_ICInitStructure.TIM_ICFilter = 10;
TIM_ICInit(TIM3, &TIM_ICInitStructure);
TIM_SetCounter(TIM3, 0);
TIM_Cmd(TIM3, ENABLE);
}
/*********************************************************************
* @fn check_direction
*
* @brief Compute the absolute value of a signed 32-bit integer.
*
* @param a Signed 32-bit integer.
*
* @return Absolute value of a
*/
uint32_t static inline iabs(int32_t a)
{
if (a < 0)
{
return -a;
}
return a;
}
/*********************************************************************
* @fn check_direction
*
* @brief Detect the rotation direction of the encoder
*
* @param current_value The current count value
*
* @return direction The direction of the encoder's rotation
*/
int32_t check_direction(int current_value)
{
static int last_value = 0;
if (current_value == last_value)
{
return 0;
}
int diff = current_value - last_value;
if (iabs(diff) < 4)
{
return 0;
}
int32_t direction;
if (iabs(diff) < 80)
{
if (diff > 0)
{
direction = 1;
}
else
{
direction = -1;
}
}
else
{
if (diff > 0)
{
direction = -1;
}
else
{
direction = 1;
}
}
last_value = current_value;
return direction;
}
#define ENC_KEY_PORT GPIOA
#define ENC_KEY_PIN (GPIO_Pin_15)
#define ENC_KEY() ((ENC_KEY_PORT->INDR & ENC_KEY_PIN) == 0)
uint32_t key3_state = 0;
/*********************************************************************
* @fn Key_GPIOInit
*
* @brief Initialization of the key pins of the encoder
*
* @return none.
*/
void Key_GPIOInit(void)
{
GPIO_InitTypeDef GPIO_InitStructure = {0};
GPIO_InitStructure.GPIO_Pin = ENC_KEY_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_Init(ENC_KEY_PORT, &GPIO_InitStructure);
}
static uint8_t wui_heap_buffer[4 * 1024];
/*********************************************************************
* @fn main
*
* @brief Main program.
*
* @return none
*/
int main(void)
{
SystemCoreClockUpdate();
Delay_Init();
USART_Printf_Init(115200);
printf("SystemClk:%d\r\n", SystemCoreClock);
printf(__TIME__ "\n");
SPI_FLASH_Init();
uint32_t id = SPI_Flash_ReadJedecDeviceID();
printf("flash_id %x\n", id);
LCD_Init();
TIM3_Encoder_Init();
TIM4_init();
Key_GPIOInit();
wui_init_data_t data = {
.page_count = WUI_PAGE_COUNT,
.width = LCD_WIDTH,
.height = LCD_HEIGHT,
.heap_addr = wui_heap_buffer,
.heap_size = sizeof(wui_heap_buffer),
};
wui_init(&data);
wui_register_hal(wui_get_hal());
wui_page_switch(WUI_START_PAGE);
while (1)
{
uint16_t now = TIM4->CNT;
if (now > 16)
{
now = now / 8;
TIM4->CNT = 0;
wui_page_ui_tick(now);
}
wui_page_ui_update();
uint32_t tcnt = TIM3->CNT;
int32_t dir = check_direction(tcnt);
if (dir > 0)
{
HW_Key_event('a');
}
else if (dir < 0)
{
HW_Key_event('d');
}
uint32_t k3 = ENC_KEY();
if (k3)
{
if (key3_state)
{
}
else
{
key3_state = 1;
HW_Key_event('b');
}
}
else
{
key3_state = 0;
}
}
while (1)
{
}
}
+305
View File
@@ -0,0 +1,305 @@
/*********************************************************************
* File Name : main.c
* Author : WCH
* Version : V1.0.0
* Date : 2026/08/06
* Description : Main program body.
*********************************************************************************
* Copyright (c) 2023 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
/*
*@Note
A demo for wui
pins:
pins:
FLASH_CS -- PA4
FLASH_DO -- PA6
FLASH_DI -- PA7
FLASH_CLK -- PA5
LCD_LED -- PB9
LCD_DC -- PB10
LCD_RST -- PB11
LCD_CS -- PB12
LCD_SCK -- PB13
LCD_MOSI -- PB15
*/
#include <math.h>
#include "debug.h"
#include "string.h"
#include "lcd.h"
#include "flash.h"
#include "config.h"
#include "wui.h"
#include "wui_port.h"
#include "wui_user/wui_page.h"
/* Global define */
/* Global Variable */
#define TIM_PCK (8000ul)
/*********************************************************************
* @fn TIM4_init
*
* @brief Initialize TIM2 for WCHGUI
*
* @return none.
*/
void TIM4_init()
{
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4, ENABLE);
TIM_TimeBaseInitTypeDef TIM_TimeBaseInitStructure = {0};
TIM_Cmd(TIM4, DISABLE);
TIM_TimeBaseInitStructure.TIM_Period = 0xffff;
TIM_TimeBaseInitStructure.TIM_Prescaler = ((SystemCoreClock) / TIM_PCK) - 1;
TIM_TimeBaseInitStructure.TIM_ClockDivision = TIM_CKD_DIV1;
TIM_TimeBaseInitStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM4, &TIM_TimeBaseInitStructure);
TIM_ARRPreloadConfig(TIM4, DISABLE);
TIM_ClearFlag(TIM4, TIM_FLAG_Update);
TIM_Cmd(TIM4, ENABLE);
}
/*********************************************************************
* @fn TIM3_Encoder_Init
*
* @brief Initialize TIM1 for encoder
*
* @return none.
*/
void TIM3_Encoder_Init()
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
TIM_ICInitTypeDef TIM_ICInitStructure;
GPIO_InitTypeDef GPIO_InitStructure = {0};
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
{
GPIO_PinRemapConfig(GPIO_PartialRemap_TIM3, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOB, &GPIO_InitStructure);
}
TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
TIM_TimeBaseStructure.TIM_Prescaler = 0x0;
TIM_TimeBaseStructure.TIM_Period = 160;
TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure);
TIM_EncoderInterfaceConfig(TIM3, TIM_EncoderMode_TI12, TIM_ICPolarity_Rising, TIM_ICPolarity_Rising);
TIM_ICStructInit(&TIM_ICInitStructure);
TIM_ICInitStructure.TIM_ICFilter = 10;
TIM_ICInit(TIM3, &TIM_ICInitStructure);
TIM_SetCounter(TIM3, 0);
TIM_Cmd(TIM3, ENABLE);
}
/*********************************************************************
* @fn check_direction
*
* @brief Compute the absolute value of a signed 32-bit integer.
*
* @param a Signed 32-bit integer.
*
* @return Absolute value of a
*/
uint32_t static inline iabs(int32_t a)
{
if (a < 0)
{
return -a;
}
return a;
}
/*********************************************************************
* @fn check_direction
*
* @brief Detect the rotation direction of the encoder
*
* @param current_value The current count value
*
* @return direction The direction of the encoder's rotation
*/
int32_t check_direction(int current_value)
{
static int last_value = 0;
if (current_value == last_value)
{
return 0;
}
int diff = current_value - last_value;
if (iabs(diff) < 4)
{
return 0;
}
int32_t direction;
if (iabs(diff) < 80)
{
if (diff > 0)
{
direction = 1;
}
else
{
direction = -1;
}
}
else
{
if (diff > 0)
{
direction = -1;
}
else
{
direction = 1;
}
}
last_value = current_value;
return direction;
}
#define ENC_KEY_PORT GPIOA
#define ENC_KEY_PIN (GPIO_Pin_15)
#define ENC_KEY() ((ENC_KEY_PORT->INDR & ENC_KEY_PIN) == 0)
uint32_t key3_state = 0;
/*********************************************************************
* @fn Key_GPIOInit
*
* @brief Initialization of the key pins of the encoder
*
* @return none.
*/
void Key_GPIOInit(void)
{
GPIO_InitTypeDef GPIO_InitStructure = {0};
GPIO_InitStructure.GPIO_Pin = ENC_KEY_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_Init(ENC_KEY_PORT, &GPIO_InitStructure);
}
static uint8_t wui_heap_buffer[4 * 1024];
/*********************************************************************
* @fn main
*
* @brief Main program.
*
* @return none
*/
int main(void)
{
SystemCoreClockUpdate();
Delay_Init();
USART_Printf_Init(115200);
printf("SystemClk:%d\r\n", SystemCoreClock);
printf(__TIME__ "\n");
SPI_FLASH_Init();
uint32_t id = SPI_Flash_ReadJedecDeviceID();
printf("flash_id %x\n", id);
LCD_Init();
TIM3_Encoder_Init();
TIM4_init();
Key_GPIOInit();
wui_init_data_t data = {
.page_count = WUI_PAGE_COUNT,
.width = LCD_WIDTH,
.height = LCD_HEIGHT,
.heap_addr = wui_heap_buffer,
.heap_size = sizeof(wui_heap_buffer),
};
wui_init(&data);
wui_register_hal(wui_get_hal());
wui_page_switch(WUI_START_PAGE);
while (1)
{
uint16_t now = TIM4->CNT;
if (now > 16)
{
now = now / 8;
TIM4->CNT = 0;
wui_page_ui_tick(now);
}
wui_page_ui_update();
uint32_t tcnt = TIM3->CNT;
int32_t dir = check_direction(tcnt);
if (dir > 0)
{
HW_Key_event('a');
}
else if (dir < 0)
{
HW_Key_event('d');
}
uint32_t k3 = ENC_KEY();
if (k3)
{
if (key3_state)
{
}
else
{
key3_state = 1;
HW_Key_event('b');
}
}
else
{
key3_state = 0;
}
}
while (1)
{
}
}
@@ -0,0 +1,987 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : system_ch32v20x.c
* Author : WCH
* Version : V1.0.0
* Date : 2021/06/06
* Description : CH32V20x Device Peripheral Access Layer System Source File.
* For HSE = 32Mhz (CH32V208x/CH32V203RBT)
* For HSE = 8Mhz (other CH32V203x)
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#include "ch32v20x.h"
/*
* Uncomment the line corresponding to the desired System clock (SYSCLK) frequency (after
* reset the HSI is used as SYSCLK source).
* If none of the define below is enabled, the HSI is used as System clock source.
*/
//#define SYSCLK_FREQ_HSE HSE_VALUE
//#define SYSCLK_FREQ_48MHz_HSE 48000000
//#define SYSCLK_FREQ_56MHz_HSE 56000000
//#define SYSCLK_FREQ_72MHz_HSE 72000000
#define SYSCLK_FREQ_96MHz_HSE 96000000
//#define SYSCLK_FREQ_120MHz_HSE 120000000
//#define SYSCLK_FREQ_144MHz_HSE 144000000
//#define SYSCLK_FREQ_HSI HSI_VALUE
//#define SYSCLK_FREQ_48MHz_HSI 48000000
//#define SYSCLK_FREQ_56MHz_HSI 56000000
//#define SYSCLK_FREQ_72MHz_HSI 72000000
//#define SYSCLK_FREQ_96MHz_HSI 96000000
//#define SYSCLK_FREQ_120MHz_HSI 120000000
//#define SYSCLK_FREQ_144MHz_HSI 144000000
/* Clock Definitions */
#ifdef SYSCLK_FREQ_HSE
uint32_t SystemCoreClock = SYSCLK_FREQ_HSE; /* System Clock Frequency (Core Clock) */
#elif defined SYSCLK_FREQ_48MHz_HSE
uint32_t SystemCoreClock = SYSCLK_FREQ_48MHz_HSE; /* System Clock Frequency (Core Clock) */
#elif defined SYSCLK_FREQ_56MHz_HSE
uint32_t SystemCoreClock = SYSCLK_FREQ_56MHz_HSE; /* System Clock Frequency (Core Clock) */
#elif defined SYSCLK_FREQ_72MHz_HSE
uint32_t SystemCoreClock = SYSCLK_FREQ_72MHz_HSE; /* System Clock Frequency (Core Clock) */
#elif defined SYSCLK_FREQ_96MHz_HSE
uint32_t SystemCoreClock = SYSCLK_FREQ_96MHz_HSE; /* System Clock Frequency (Core Clock) */
#elif defined SYSCLK_FREQ_120MHz_HSE
uint32_t SystemCoreClock = SYSCLK_FREQ_120MHz_HSE; /* System Clock Frequency (Core Clock) */
#elif defined SYSCLK_FREQ_144MHz_HSE
uint32_t SystemCoreClock = SYSCLK_FREQ_144MHz_HSE; /* System Clock Frequency (Core Clock) */
#elif defined SYSCLK_FREQ_48MHz_HSI
uint32_t SystemCoreClock = SYSCLK_FREQ_48MHz_HSI; /* System Clock Frequency (Core Clock) */
#elif defined SYSCLK_FREQ_56MHz_HSI
uint32_t SystemCoreClock = SYSCLK_FREQ_56MHz_HSI; /* System Clock Frequency (Core Clock) */
#elif defined SYSCLK_FREQ_72MHz_HSI
uint32_t SystemCoreClock = SYSCLK_FREQ_72MHz_HSI; /* System Clock Frequency (Core Clock) */
#elif defined SYSCLK_FREQ_96MHz_HSI
uint32_t SystemCoreClock = SYSCLK_FREQ_96MHz_HSI; /* System Clock Frequency (Core Clock) */
#elif defined SYSCLK_FREQ_120MHz_HSI
uint32_t SystemCoreClock = SYSCLK_FREQ_120MHz_HSI; /* System Clock Frequency (Core Clock) */
#elif defined SYSCLK_FREQ_144MHz_HSI
uint32_t SystemCoreClock = SYSCLK_FREQ_144MHz_HSI; /* System Clock Frequency (Core Clock) */
#else
uint32_t SystemCoreClock = HSI_VALUE; /* System Clock Frequency (Core Clock) */
#endif
__I uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
/* system_private_function_proto_types */
static void SetSysClock(void);
#ifdef SYSCLK_FREQ_HSE
static void SetSysClockToHSE( void );
#elif defined SYSCLK_FREQ_48MHz_HSE
static void SetSysClockTo48_HSE( void );
#elif defined SYSCLK_FREQ_56MHz_HSE
static void SetSysClockTo56_HSE( void );
#elif defined SYSCLK_FREQ_72MHz_HSE
static void SetSysClockTo72_HSE( void );
#elif defined SYSCLK_FREQ_96MHz_HSE
static void SetSysClockTo96_HSE( void );
#elif defined SYSCLK_FREQ_120MHz_HSE
static void SetSysClockTo120_HSE( void );
#elif defined SYSCLK_FREQ_144MHz_HSE
static void SetSysClockTo144_HSE( void );
#elif defined SYSCLK_FREQ_48MHz_HSI
static void SetSysClockTo48_HSI( void );
#elif defined SYSCLK_FREQ_56MHz_HSI
static void SetSysClockTo56_HSI( void );
#elif defined SYSCLK_FREQ_72MHz_HSI
static void SetSysClockTo72_HSI( void );
#elif defined SYSCLK_FREQ_96MHz_HSI
static void SetSysClockTo96_HSI( void );
#elif defined SYSCLK_FREQ_120MHz_HSI
static void SetSysClockTo120_HSI( void );
#elif defined SYSCLK_FREQ_144MHz_HSI
static void SetSysClockTo144_HSI( void );
#endif
/*********************************************************************
* @fn SystemInit
*
* @brief Setup the microcontroller system Initialize the Embedded Flash Interface,
* the PLL and update the SystemCoreClock variable.
*
* @return none
*/
void SystemInit (void)
{
RCC->CTLR |= (uint32_t)0x00000001;
RCC->CFGR0 &= (uint32_t)0xF0FF0000;
RCC->CTLR &= (uint32_t)0xFEF6FFFF;
RCC->CTLR &= (uint32_t)0xFFFBFFFF;
RCC->CFGR0 &= (uint32_t)0xFF00FFFF;
RCC->INTR = 0x009F0000;
SetSysClock();
}
/*********************************************************************
* @fn SystemCoreClockUpdate
*
* @brief Update SystemCoreClock variable according to Clock Register Values.
*
* @return none
*/
void SystemCoreClockUpdate (void)
{
uint32_t tmp = 0, pllmull = 0, pllsource = 0, Pll_6_5 = 0;
tmp = RCC->CFGR0 & RCC_SWS;
switch (tmp)
{
case 0x00:
SystemCoreClock = HSI_VALUE;
break;
case 0x04:
SystemCoreClock = HSE_VALUE;
break;
case 0x08:
pllmull = RCC->CFGR0 & RCC_PLLMULL;
pllsource = RCC->CFGR0 & RCC_PLLSRC;
pllmull = ( pllmull >> 18) + 2;
if(pllmull == 17) pllmull = 18;
if (pllsource == 0x00)
{
if(EXTEN->EXTEN_CTR & EXTEN_PLL_HSI_PRE){
SystemCoreClock = HSI_VALUE * pllmull;
}
else{
SystemCoreClock = (HSI_VALUE >> 1) * pllmull;
}
}
else
{
#if defined (CH32V20x_D8W) || defined (CH32V20x_D8)
if(((RCC->CFGR0 & (3<<22)) == (3<<22)) && (RCC_USB5PRE_JUDGE()== SET))
{
SystemCoreClock = ((HSE_VALUE>>1)) * pllmull;
}
else
#endif
if ((RCC->CFGR0 & RCC_PLLXTPRE) != (uint32_t)RESET)
{
#if defined (CH32V20x_D8) || defined (CH32V20x_D8W)
SystemCoreClock = ((HSE_VALUE>>2) >> 1) * pllmull;
#else
SystemCoreClock = (HSE_VALUE >> 1) * pllmull;
#endif
}
else
{
#if defined (CH32V20x_D8) || defined (CH32V20x_D8W)
SystemCoreClock = (HSE_VALUE>>2) * pllmull;
#else
SystemCoreClock = HSE_VALUE * pllmull;
#endif
}
}
if(Pll_6_5 == 1) SystemCoreClock = (SystemCoreClock / 2);
break;
default:
SystemCoreClock = HSI_VALUE;
break;
}
tmp = AHBPrescTable[((RCC->CFGR0 & RCC_HPRE) >> 4)];
SystemCoreClock >>= tmp;
}
/*********************************************************************
* @fn SetSysClock
*
* @brief Configures the System clock frequency, HCLK, PCLK2 and PCLK1 prescalers.
*
* @return none
*/
static void SetSysClock(void)
{
//GPIO_IPD_Unused();
#ifdef SYSCLK_FREQ_HSE
SetSysClockToHSE();
#elif defined SYSCLK_FREQ_48MHz_HSE
SetSysClockTo48_HSE();
#elif defined SYSCLK_FREQ_56MHz_HSE
SetSysClockTo56_HSE();
#elif defined SYSCLK_FREQ_72MHz_HSE
SetSysClockTo72_HSE();
#elif defined SYSCLK_FREQ_96MHz_HSE
SetSysClockTo96_HSE();
#elif defined SYSCLK_FREQ_120MHz_HSE
SetSysClockTo120_HSE();
#elif defined SYSCLK_FREQ_144MHz_HSE
SetSysClockTo144_HSE();
#elif defined SYSCLK_FREQ_48MHz_HSI
SetSysClockTo48_HSI();
#elif defined SYSCLK_FREQ_56MHz_HSI
SetSysClockTo56_HSI();
#elif defined SYSCLK_FREQ_72MHz_HSI
SetSysClockTo72_HSI();
#elif defined SYSCLK_FREQ_96MHz_HSI
SetSysClockTo96_HSI();
#elif defined SYSCLK_FREQ_120MHz_HSI
SetSysClockTo120_HSI();
#elif defined SYSCLK_FREQ_144MHz_HSI
SetSysClockTo144_HSI();
#endif
/* If none of the define above is enabled, the HSI is used as System clock
* source (default after reset)
*/
}
#ifdef SYSCLK_FREQ_HSE
/*********************************************************************
* @fn SetSysClockToHSE
*
* @brief Sets HSE as System clock source and configure HCLK, PCLK2 and PCLK1 prescalers.
*
* @return none
*/
static void SetSysClockToHSE(void)
{
__IO uint32_t StartUpCounter = 0, HSEStatus = 0;
RCC->CTLR |= ((uint32_t)RCC_HSEON);
/* Wait till HSE is ready and if Time out is reached exit */
do
{
HSEStatus = RCC->CTLR & RCC_HSERDY;
StartUpCounter++;
} while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT));
if ((RCC->CTLR & RCC_HSERDY) != RESET)
{
HSEStatus = (uint32_t)0x01;
}
else
{
HSEStatus = (uint32_t)0x00;
}
if (HSEStatus == (uint32_t)0x01)
{
/* HCLK = SYSCLK */
RCC->CFGR0 |= (uint32_t)RCC_HPRE_DIV1;
/* PCLK2 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE2_DIV1;
/* PCLK1 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE1_DIV1;
/* Select HSE as system clock source
* CH32V20x_D6 (HSE=8MHZ)
* CH32V20x_D8 (HSE=32MHZ)
* CH32V20x_D8W (HSE=32MHZ)
*/
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_SW));
RCC->CFGR0 |= (uint32_t)RCC_SW_HSE;
/* Wait till HSE is used as system clock source */
while ((RCC->CFGR0 & (uint32_t)RCC_SWS) != (uint32_t)0x04)
{
}
}
else
{
/* If HSE fails to start-up, the application will have wrong clock
* configuration. User can add here some code to deal with this error
*/
}
}
#elif defined SYSCLK_FREQ_48MHz_HSE
/*********************************************************************
* @fn SetSysClockTo48_HSE
*
* @brief Sets System clock frequency to 48MHz and configure HCLK, PCLK2 and PCLK1 prescalers.
*
* @return none
*/
static void SetSysClockTo48_HSE(void)
{
__IO uint32_t StartUpCounter = 0, HSEStatus = 0;
RCC->CTLR |= ((uint32_t)RCC_HSEON);
/* Wait till HSE is ready and if Time out is reached exit */
do
{
HSEStatus = RCC->CTLR & RCC_HSERDY;
StartUpCounter++;
} while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT));
if ((RCC->CTLR & RCC_HSERDY) != RESET)
{
HSEStatus = (uint32_t)0x01;
}
else
{
HSEStatus = (uint32_t)0x00;
}
if (HSEStatus == (uint32_t)0x01)
{
/* HCLK = SYSCLK */
RCC->CFGR0 |= (uint32_t)RCC_HPRE_DIV1;
/* PCLK2 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE2_DIV1;
/* PCLK1 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE1_DIV2;
/* CH32V20x_D6-PLL configuration: PLLCLK = HSE * 6 = 48 MHz (HSE=8MHZ)
* CH32V20x_D8-PLL configuration: PLLCLK = HSE/4 * 6 = 48 MHz (HSE=32MHZ)
* CH32V20x_D8W-PLL configuration: PLLCLK = HSE/4 * 6 = 48 MHz (HSE=32MHZ)
*/
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_PLLSRC | RCC_PLLXTPRE | RCC_PLLMULL));
RCC->CFGR0 |= (uint32_t)(RCC_PLLSRC_HSE | RCC_PLLXTPRE_HSE | RCC_PLLMULL6);
/* Enable PLL */
RCC->CTLR |= RCC_PLLON;
/* Wait till PLL is ready */
while((RCC->CTLR & RCC_PLLRDY) == 0)
{
}
/* Select PLL as system clock source */
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_SW));
RCC->CFGR0 |= (uint32_t)RCC_SW_PLL;
/* Wait till PLL is used as system clock source */
while ((RCC->CFGR0 & (uint32_t)RCC_SWS) != (uint32_t)0x08)
{
}
}
else
{
/*
* If HSE fails to start-up, the application will have wrong clock
* configuration. User can add here some code to deal with this error
*/
}
}
#elif defined SYSCLK_FREQ_56MHz_HSE
/*********************************************************************
* @fn SetSysClockTo56_HSE
*
* @brief Sets System clock frequency to 56MHz and configure HCLK, PCLK2 and PCLK1 prescalers.
*
* @return none
*/
static void SetSysClockTo56_HSE(void)
{
__IO uint32_t StartUpCounter = 0, HSEStatus = 0;
RCC->CTLR |= ((uint32_t)RCC_HSEON);
/* Wait till HSE is ready and if Time out is reached exit */
do
{
HSEStatus = RCC->CTLR & RCC_HSERDY;
StartUpCounter++;
} while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT));
if ((RCC->CTLR & RCC_HSERDY) != RESET)
{
HSEStatus = (uint32_t)0x01;
}
else
{
HSEStatus = (uint32_t)0x00;
}
if (HSEStatus == (uint32_t)0x01)
{
/* HCLK = SYSCLK */
RCC->CFGR0 |= (uint32_t)RCC_HPRE_DIV1;
/* PCLK2 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE2_DIV1;
/* PCLK1 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE1_DIV2;
/* CH32V20x_D6-PLL configuration: PLLCLK = HSE * 7 = 56 MHz (HSE=8MHZ)
* CH32V20x_D8-PLL configuration: PLLCLK = HSE/4 * 7 = 56 MHz (HSE=32MHZ)
* CH32V20x_D8W-PLL configuration: PLLCLK = HSE/4 * 7 = 56 MHz (HSE=32MHZ)
*/
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_PLLSRC | RCC_PLLXTPRE | RCC_PLLMULL));
RCC->CFGR0 |= (uint32_t)(RCC_PLLSRC_HSE | RCC_PLLXTPRE_HSE | RCC_PLLMULL7);
/* Enable PLL */
RCC->CTLR |= RCC_PLLON;
/* Wait till PLL is ready */
while((RCC->CTLR & RCC_PLLRDY) == 0)
{
}
/* Select PLL as system clock source */
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_SW));
RCC->CFGR0 |= (uint32_t)RCC_SW_PLL;
/* Wait till PLL is used as system clock source */
while ((RCC->CFGR0 & (uint32_t)RCC_SWS) != (uint32_t)0x08)
{
}
}
else
{
/*
* If HSE fails to start-up, the application will have wrong clock
* configuration. User can add here some code to deal with this error
*/
}
}
#elif defined SYSCLK_FREQ_72MHz_HSE
/*********************************************************************
* @fn SetSysClockTo72_HSE
*
* @brief Sets System clock frequency to 72MHz and configure HCLK, PCLK2 and PCLK1 prescalers.
*
* @return none
*/
static void SetSysClockTo72_HSE(void)
{
__IO uint32_t StartUpCounter = 0, HSEStatus = 0;
RCC->CTLR |= ((uint32_t)RCC_HSEON);
/* Wait till HSE is ready and if Time out is reached exit */
do
{
HSEStatus = RCC->CTLR & RCC_HSERDY;
StartUpCounter++;
} while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT));
if ((RCC->CTLR & RCC_HSERDY) != RESET)
{
HSEStatus = (uint32_t)0x01;
}
else
{
HSEStatus = (uint32_t)0x00;
}
if (HSEStatus == (uint32_t)0x01)
{
/* HCLK = SYSCLK */
RCC->CFGR0 |= (uint32_t)RCC_HPRE_DIV1;
/* PCLK2 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE2_DIV1;
/* PCLK1 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE1_DIV2;
/* CH32V20x_D6-PLL configuration: PLLCLK = HSE * 9 = 72 MHz (HSE=8MHZ)
* CH32V20x_D8-PLL configuration: PLLCLK = HSE/4 * 9 = 72 MHz (HSE=32MHZ)
* CH32V20x_D8W-PLL configuration: PLLCLK = HSE/4 * 9 = 72 MHz (HSE=32MHZ)
*/
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_PLLSRC | RCC_PLLXTPRE |
RCC_PLLMULL));
RCC->CFGR0 |= (uint32_t)(RCC_PLLSRC_HSE | RCC_PLLXTPRE_HSE | RCC_PLLMULL9);
/* Enable PLL */
RCC->CTLR |= RCC_PLLON;
/* Wait till PLL is ready */
while((RCC->CTLR & RCC_PLLRDY) == 0)
{
}
/* Select PLL as system clock source */
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_SW));
RCC->CFGR0 |= (uint32_t)RCC_SW_PLL;
/* Wait till PLL is used as system clock source */
while ((RCC->CFGR0 & (uint32_t)RCC_SWS) != (uint32_t)0x08)
{
}
}
else
{
/*
* If HSE fails to start-up, the application will have wrong clock
* configuration. User can add here some code to deal with this error
*/
}
}
#elif defined SYSCLK_FREQ_96MHz_HSE
/*********************************************************************
* @fn SetSysClockTo96_HSE
*
* @brief Sets System clock frequency to 96MHz and configure HCLK, PCLK2 and PCLK1 prescalers.
*
* @return none
*/
static void SetSysClockTo96_HSE(void)
{
__IO uint32_t StartUpCounter = 0, HSEStatus = 0;
RCC->CTLR |= ((uint32_t)RCC_HSEON);
/* Wait till HSE is ready and if Time out is reached exit */
do
{
HSEStatus = RCC->CTLR & RCC_HSERDY;
StartUpCounter++;
} while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT));
if ((RCC->CTLR & RCC_HSERDY) != RESET)
{
HSEStatus = (uint32_t)0x01;
}
else
{
HSEStatus = (uint32_t)0x00;
}
if (HSEStatus == (uint32_t)0x01)
{
/* HCLK = SYSCLK */
RCC->CFGR0 |= (uint32_t)RCC_HPRE_DIV1;
/* PCLK2 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE2_DIV1;
/* PCLK1 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE1_DIV2;
/* CH32V20x_D6-PLL configuration: PLLCLK = HSE * 12 = 96 MHz (HSE=8MHZ)
* CH32V20x_D8-PLL configuration: PLLCLK = HSE/4 * 12 = 96 MHz (HSE=32MHZ)
* CH32V20x_D8W-PLL configuration: PLLCLK = HSE/4 * 12 = 96 MHz (HSE=32MHZ)
*/
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_PLLSRC | RCC_PLLXTPRE |
RCC_PLLMULL));
RCC->CFGR0 |= (uint32_t)(RCC_PLLSRC_HSE | RCC_PLLXTPRE_HSE | RCC_PLLMULL12);
/* Enable PLL */
RCC->CTLR |= RCC_PLLON;
/* Wait till PLL is ready */
while((RCC->CTLR & RCC_PLLRDY) == 0)
{
}
/* Select PLL as system clock source */
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_SW));
RCC->CFGR0 |= (uint32_t)RCC_SW_PLL;
/* Wait till PLL is used as system clock source */
while ((RCC->CFGR0 & (uint32_t)RCC_SWS) != (uint32_t)0x08)
{
}
}
else
{
/*
* If HSE fails to start-up, the application will have wrong clock
* configuration. User can add here some code to deal with this error
*/
}
}
#elif defined SYSCLK_FREQ_120MHz_HSE
/*********************************************************************
* @fn SetSysClockTo120_HSE
*
* @brief Sets System clock frequency to 120MHz and configure HCLK, PCLK2 and PCLK1 prescalers.
*
* @return none
*/
static void SetSysClockTo120_HSE(void)
{
__IO uint32_t StartUpCounter = 0, HSEStatus = 0;
RCC->CTLR |= ((uint32_t)RCC_HSEON);
/* Wait till HSE is ready and if Time out is reached exit */
do
{
HSEStatus = RCC->CTLR & RCC_HSERDY;
StartUpCounter++;
} while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT));
if((RCC->CTLR & RCC_HSERDY) != RESET)
{
HSEStatus = (uint32_t)0x01;
}
else
{
HSEStatus = (uint32_t)0x00;
}
if(HSEStatus == (uint32_t)0x01)
{
#if defined (CH32V20x_D8W)
RCC->CFGR0 |= (uint32_t)(3<<22);
/* HCLK = SYSCLK/2 */
RCC->CFGR0 |= (uint32_t)RCC_HPRE_DIV2;
#else
/* HCLK = SYSCLK */
RCC->CFGR0 |= (uint32_t)RCC_HPRE_DIV1;
#endif
/* PCLK2 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE2_DIV1;
/* PCLK1 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE1_DIV2;
/* CH32V20x_D6-PLL configuration: PLLCLK = HSE * 15 = 120 MHz (HSE=8MHZ)
* CH32V20x_D8-PLL configuration: PLLCLK = HSE/4 * 15 = 120 MHz (HSE=32MHZ)
* CH32V20x_D8W-PLL configuration: PLLCLK = HSE/2 * 15 = 240 MHz (HSE=32MHZ)
*/
RCC->CFGR0 &= (uint32_t)((uint32_t) ~(RCC_PLLSRC | RCC_PLLXTPRE |
RCC_PLLMULL));
RCC->CFGR0 |= (uint32_t)(RCC_PLLSRC_HSE | RCC_PLLXTPRE_HSE | RCC_PLLMULL15);
/* Enable PLL */
RCC->CTLR |= RCC_PLLON;
/* Wait till PLL is ready */
while((RCC->CTLR & RCC_PLLRDY) == 0)
{
}
/* Select PLL as system clock source */
RCC->CFGR0 &= (uint32_t)((uint32_t) ~(RCC_SW));
RCC->CFGR0 |= (uint32_t)RCC_SW_PLL;
/* Wait till PLL is used as system clock source */
while((RCC->CFGR0 & (uint32_t)RCC_SWS) != (uint32_t)0x08)
{
}
}
else
{
/*
* If HSE fails to start-up, the application will have wrong clock
* configuration. User can add here some code to deal with this error
*/
}
}
#elif defined SYSCLK_FREQ_144MHz_HSE
/*********************************************************************
* @fn SetSysClockTo144_HSE
*
* @brief Sets System clock frequency to 144MHz and configure HCLK, PCLK2 and PCLK1 prescalers.
*
* @return none
*/
static void SetSysClockTo144_HSE(void)
{
__IO uint32_t StartUpCounter = 0, HSEStatus = 0;
RCC->CTLR |= ((uint32_t)RCC_HSEON);
/* Wait till HSE is ready and if Time out is reached exit */
do
{
HSEStatus = RCC->CTLR & RCC_HSERDY;
StartUpCounter++;
} while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT));
if ((RCC->CTLR & RCC_HSERDY) != RESET)
{
HSEStatus = (uint32_t)0x01;
}
else
{
HSEStatus = (uint32_t)0x00;
}
if (HSEStatus == (uint32_t)0x01)
{
/* HCLK = SYSCLK */
RCC->CFGR0 |= (uint32_t)RCC_HPRE_DIV1;
/* PCLK2 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE2_DIV1;
/* PCLK1 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE1_DIV2;
/* CH32V20x_D6-PLL configuration: PLLCLK = HSE * 18 = 144 MHz (HSE=8MHZ)
* CH32V20x_D8-PLL configuration: PLLCLK = HSE/4 * 18 = 144 MHz (HSE=32MHZ)
* CH32V20x_D8W-PLL configuration: PLLCLK = HSE/4 * 18 = 144 MHz (HSE=32MHZ)
*/
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_PLLSRC | RCC_PLLXTPRE |
RCC_PLLMULL));
RCC->CFGR0 |= (uint32_t)(RCC_PLLSRC_HSE | RCC_PLLXTPRE_HSE | RCC_PLLMULL18);
/* Enable PLL */
RCC->CTLR |= RCC_PLLON;
/* Wait till PLL is ready */
while((RCC->CTLR & RCC_PLLRDY) == 0)
{
}
/* Select PLL as system clock source */
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_SW));
RCC->CFGR0 |= (uint32_t)RCC_SW_PLL;
/* Wait till PLL is used as system clock source */
while ((RCC->CFGR0 & (uint32_t)RCC_SWS) != (uint32_t)0x08)
{
}
}
else
{
/*
* If HSE fails to start-up, the application will have wrong clock
* configuration. User can add here some code to deal with this error
*/
}
}
#elif defined SYSCLK_FREQ_48MHz_HSI
/*********************************************************************
* @fn SetSysClockTo48_HSI
*
* @brief Sets System clock frequency to 48MHz and configure HCLK, PCLK2 and PCLK1 prescalers.
*
* @return none
*/
static void SetSysClockTo48_HSI(void)
{
EXTEN->EXTEN_CTR |= EXTEN_PLL_HSI_PRE;
/* HCLK = SYSCLK */
RCC->CFGR0 |= (uint32_t)RCC_HPRE_DIV1;
/* PCLK2 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE2_DIV1;
/* PCLK1 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE1_DIV2;
/* PLL configuration: PLLCLK = HSI * 6 = 48 MHz */
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_PLLSRC | RCC_PLLXTPRE | RCC_PLLMULL));
RCC->CFGR0 |= (uint32_t)(RCC_PLLSRC_HSI_Div2 | RCC_PLLMULL6);
/* Enable PLL */
RCC->CTLR |= RCC_PLLON;
/* Wait till PLL is ready */
while((RCC->CTLR & RCC_PLLRDY) == 0)
{
}
/* Select PLL as system clock source */
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_SW));
RCC->CFGR0 |= (uint32_t)RCC_SW_PLL;
/* Wait till PLL is used as system clock source */
while ((RCC->CFGR0 & (uint32_t)RCC_SWS) != (uint32_t)0x08)
{
}
}
#elif defined SYSCLK_FREQ_56MHz_HSI
/*********************************************************************
* @fn SetSysClockTo56_HSI
*
* @brief Sets System clock frequency to 56MHz and configure HCLK, PCLK2 and PCLK1 prescalers.
*
* @return none
*/
static void SetSysClockTo56_HSI(void)
{
EXTEN->EXTEN_CTR |= EXTEN_PLL_HSI_PRE;
/* HCLK = SYSCLK */
RCC->CFGR0 |= (uint32_t)RCC_HPRE_DIV1;
/* PCLK2 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE2_DIV1;
/* PCLK1 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE1_DIV2;
/* PLL configuration: PLLCLK = HSI * 7 = 48 MHz */
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_PLLSRC | RCC_PLLXTPRE | RCC_PLLMULL));
RCC->CFGR0 |= (uint32_t)(RCC_PLLSRC_HSI_Div2 | RCC_PLLMULL7);
/* Enable PLL */
RCC->CTLR |= RCC_PLLON;
/* Wait till PLL is ready */
while((RCC->CTLR & RCC_PLLRDY) == 0)
{
}
/* Select PLL as system clock source */
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_SW));
RCC->CFGR0 |= (uint32_t)RCC_SW_PLL;
/* Wait till PLL is used as system clock source */
while ((RCC->CFGR0 & (uint32_t)RCC_SWS) != (uint32_t)0x08)
{
}
}
#elif defined SYSCLK_FREQ_72MHz_HSI
/*********************************************************************
* @fn SetSysClockTo72_HSI
*
* @brief Sets System clock frequency to 72MHz and configure HCLK, PCLK2 and PCLK1 prescalers.
*
* @return none
*/
static void SetSysClockTo72_HSI(void)
{
EXTEN->EXTEN_CTR |= EXTEN_PLL_HSI_PRE;
/* HCLK = SYSCLK */
RCC->CFGR0 |= (uint32_t)RCC_HPRE_DIV1;
/* PCLK2 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE2_DIV1;
/* PCLK1 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE1_DIV2;
/* PLL configuration: PLLCLK = HSI * 9 = 72 MHz */
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_PLLSRC | RCC_PLLXTPRE | RCC_PLLMULL));
RCC->CFGR0 |= (uint32_t)(RCC_PLLSRC_HSI_Div2 | RCC_PLLMULL9);
/* Enable PLL */
RCC->CTLR |= RCC_PLLON;
/* Wait till PLL is ready */
while((RCC->CTLR & RCC_PLLRDY) == 0)
{
}
/* Select PLL as system clock source */
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_SW));
RCC->CFGR0 |= (uint32_t)RCC_SW_PLL;
/* Wait till PLL is used as system clock source */
while ((RCC->CFGR0 & (uint32_t)RCC_SWS) != (uint32_t)0x08)
{
}
}
#elif defined SYSCLK_FREQ_96MHz_HSI
/*********************************************************************
* @fn SetSysClockTo96_HSI
*
* @brief Sets System clock frequency to 96MHz and configure HCLK, PCLK2 and PCLK1 prescalers.
*
* @return none
*/
static void SetSysClockTo96_HSI(void)
{
EXTEN->EXTEN_CTR |= EXTEN_PLL_HSI_PRE;
/* HCLK = SYSCLK */
RCC->CFGR0 |= (uint32_t)RCC_HPRE_DIV1;
/* PCLK2 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE2_DIV1;
/* PCLK1 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE1_DIV2;
/* PLL configuration: PLLCLK = HSI * 12 = 96 MHz */
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_PLLSRC | RCC_PLLXTPRE | RCC_PLLMULL));
RCC->CFGR0 |= (uint32_t)(RCC_PLLSRC_HSI_Div2 | RCC_PLLMULL12);
/* Enable PLL */
RCC->CTLR |= RCC_PLLON;
/* Wait till PLL is ready */
while((RCC->CTLR & RCC_PLLRDY) == 0)
{
}
/* Select PLL as system clock source */
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_SW));
RCC->CFGR0 |= (uint32_t)RCC_SW_PLL;
/* Wait till PLL is used as system clock source */
while ((RCC->CFGR0 & (uint32_t)RCC_SWS) != (uint32_t)0x08)
{
}
}
#elif defined SYSCLK_FREQ_120MHz_HSI
/*********************************************************************
* @fn SetSysClockTo120_HSI
*
* @brief Sets System clock frequency to 120MHz and configure HCLK, PCLK2 and PCLK1 prescalers.
*
* @return none
*/
static void SetSysClockTo120_HSI(void)
{
EXTEN->EXTEN_CTR |= EXTEN_PLL_HSI_PRE;
/* HCLK = SYSCLK */
RCC->CFGR0 |= (uint32_t)RCC_HPRE_DIV1;
/* PCLK2 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE2_DIV1;
/* PCLK1 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE1_DIV2;
/* PLL configuration: PLLCLK = HSI * 15 = 120 MHz */
RCC->CFGR0 &= (uint32_t)((uint32_t) ~(RCC_PLLSRC | RCC_PLLXTPRE |
RCC_PLLMULL));
RCC->CFGR0 |= (uint32_t)(RCC_PLLSRC_HSI_Div2 | RCC_PLLMULL15);
/* Enable PLL */
RCC->CTLR |= RCC_PLLON;
/* Wait till PLL is ready */
while((RCC->CTLR & RCC_PLLRDY) == 0)
{
}
/* Select PLL as system clock source */
RCC->CFGR0 &= (uint32_t)((uint32_t) ~(RCC_SW));
RCC->CFGR0 |= (uint32_t)RCC_SW_PLL;
/* Wait till PLL is used as system clock source */
while((RCC->CFGR0 & (uint32_t)RCC_SWS) != (uint32_t)0x08)
{
}
}
#elif defined SYSCLK_FREQ_144MHz_HSI
/*********************************************************************
* @fn SetSysClockTo144_HSI
*
* @brief Sets System clock frequency to 144MHz and configure HCLK, PCLK2 and PCLK1 prescalers.
*
* @return none
*/
static void SetSysClockTo144_HSI(void)
{
EXTEN->EXTEN_CTR |= EXTEN_PLL_HSI_PRE;
/* HCLK = SYSCLK */
RCC->CFGR0 |= (uint32_t)RCC_HPRE_DIV1;
/* PCLK2 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE2_DIV1;
/* PCLK1 = HCLK */
RCC->CFGR0 |= (uint32_t)RCC_PPRE1_DIV2;
/* PLL configuration: PLLCLK = HSI * 18 = 144 MHz */
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_PLLSRC | RCC_PLLXTPRE | RCC_PLLMULL));
RCC->CFGR0 |= (uint32_t)(RCC_PLLSRC_HSI_Div2 | RCC_PLLMULL18);
/* Enable PLL */
RCC->CTLR |= RCC_PLLON;
/* Wait till PLL is ready */
while((RCC->CTLR & RCC_PLLRDY) == 0)
{
}
/* Select PLL as system clock source */
RCC->CFGR0 &= (uint32_t)((uint32_t)~(RCC_SW));
RCC->CFGR0 |= (uint32_t)RCC_SW_PLL;
/* Wait till PLL is used as system clock source */
while ((RCC->CFGR0 & (uint32_t)RCC_SWS) != (uint32_t)0x08)
{
}
}
#endif
@@ -0,0 +1,32 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : system_ch32v20x.h
* Author : WCH
* Version : V1.0.0
* Date : 2021/06/06
* Description : CH32V20x Device Peripheral Access Layer System Header File.
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#ifndef __SYSTEM_ch32v20x_H
#define __SYSTEM_ch32v20x_H
#ifdef __cplusplus
extern "C" {
#endif
extern uint32_t SystemCoreClock; /* System Clock Frequency (Core Clock) */
/* System_Exported_Functions */
extern void SystemInit(void);
extern void SystemCoreClockUpdate(void);
#ifdef __cplusplus
}
#endif
#endif /*__CH32V20x_SYSTEM_H */
Binary file not shown.
+205
View File
@@ -0,0 +1,205 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : wui.h
* Author : WCH
* Version : V1.2.0
* Date : 2026/07/30
* Description : This file contains core type definitions, HAL interface,
* event system, and main API functions.
*********************************************************************************/
#ifndef WUI_H
#define WUI_H
#include <stdint.h>
#include <stddef.h>
#include "LCD.h"
/*******************************************************************************
* TYPE DEFINITIONS
******************************************************************************/
typedef struct {
uint32_t addr;
uint16_t width;
uint16_t height;
uint32_t data_size;
} image_info_t;
//
#define IMAGE_TYPE_RAW 0x0000
#define IMAGE_TYPE_RLE 0x2000
#define IMAGE_TYPE_CLUT 0x4000
#define IMAGE_TYPE_CLUT4 0x6000
#define IMAGE_TYPE_MASK 0xE000
#define IMAGE_INDEX_MASK 0x1FFF
#define MAKE_IMAGE_ID(type, idx) ((type) | ((idx) & IMAGE_INDEX_MASK))
#define IMAGE_GET_TYPE(id) ((id) & IMAGE_TYPE_MASK)
#define IMAGE_GET_INDEX(id) ((id) & IMAGE_INDEX_MASK)
/*******************************************************************************
* HAL CALLBACK TYPES
******************************************************************************/
typedef void (*wui_touch_read_cb_t)(uint16_t* x, uint16_t* y, uint8_t* pressed);
typedef void (*wui_flash_read_cb_t)(uint8_t* buf, uint32_t addr, uint32_t size);
typedef void (*wui_lcd_set_windows_cb_t)(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
typedef void (*wui_lcd_dma_start_cb_t)(void);
typedef void (*wui_lcd_dma_send_cb_t)(const uint8_t* buf, uint32_t len);
typedef void (*wui_lcd_dma_wait_cb_t)(void);
typedef void (*wui_lcd_dma_end_cb_t)(void);
/*******************************************************************************
* HAL INTERFACE
******************************************************************************/
/* Contains all hardware abstraction layer function pointers */
typedef struct
{
wui_touch_read_cb_t touch_read; /* Touch screen read function */
wui_flash_read_cb_t flash_read; /* Flash read function */
wui_lcd_set_windows_cb_t lcd_set_windows; /* LCD window set function */
wui_lcd_dma_start_cb_t lcd_dma_start; /* LCD DMA start function */
wui_lcd_dma_send_cb_t lcd_dma_send; /* LCD DMA send function */
wui_lcd_dma_wait_cb_t lcd_dma_wait; /* LCD DMA wait function */
wui_lcd_dma_end_cb_t lcd_dma_end; /* LCD DMA end function */
} wui_hal_t;
/*******************************************************************************
* PAGE DEFINITIONS
******************************************************************************/
/* Page descriptor structure */
typedef struct
{
uint16_t bg_color; /* Background color */
const char* page_name; /* Page name string */
void (*page_init)(void); /* Page initialization function */
void (*page_loop)(void); /* Page loop function */
void* user_data; /* User data pointer */
} wui_page_desc_t;
/*******************************************************************************
* INITIALIZATION
******************************************************************************/
/* WUI initialization data structure */
typedef struct
{
uint16_t width; /* Display width */
uint16_t height; /* Display height */
uint16_t page_count; /* Number of pages */
uint8_t* heap_addr; /* Heap memory address */
size_t heap_size; /* Heap memory size */
} wui_init_data_t;
/*******************************************************************************
* FONT SYSTEM
******************************************************************************/
/* Font structure */
typedef struct
{
uint16_t height; /* Font height */
uint16_t width; /* Font width */
uint8_t cnt; /* Character count */
uint8_t start_char; /* Start character */
uint16_t first_img_id; /* First image ID */
} wui_font_t;
/* Bitmap font structure */
typedef struct
{
uint8_t width; /* Font width */
uint8_t height; /* Font height */
uint8_t start_char; /* Start character */
uint8_t cnt; /* Character count */
const uint8_t* data; /* Font data pointer */
} wui_bitfont_t;
/*******************************************************************************
* EVENT SYSTEM
******************************************************************************/
/* Event type enumeration */
typedef enum
{
WUI_EVENT_NONE = 0, /* No event */
WUI_EVENT_TOUCH_DOWN = 1, /* Touch down event */
WUI_EVENT_TOUCH_MOVE = 2, /* Touch move event */
WUI_EVENT_TOUCH_LONGPRESS = 3, /* Long press event */
WUI_EVENT_TOUCH_UP = 4, /* Touch up event */
WUI_EVENT_WIDGET_CLICK = 0x10, /* Click event */
WUI_EVENT_WIDGET_LONG_PRESS = 0x11, /* Long press event */
WUI_EVENT_WIDGET_CHANGE = 0x20, /* Value change event */
} _wui_event_t;
typedef uint16_t wui_event_t;
/*******************************************************************************
* TOUCH AREA
******************************************************************************/
typedef struct
{
uint16_t widget_id; /* Widget ID */
uint16_t x, y, w, h; /* Touch area position and size */
} wui_touch_area_t;
/*******************************************************************************
* VERSION API
******************************************************************************/
const char* wui_get_version(void);
/*******************************************************************************
* CORE INITIALIZATION API
******************************************************************************/
void wui_init(wui_init_data_t* data);
void wui_register_hal(const wui_hal_t* hal);
/*******************************************************************************
* PAGE MANAGEMENT API
******************************************************************************/
void wui_page_switch(uint16_t page);
void wui_page_ui_init(void);
void wui_page_ui_loop(void);
const wui_page_desc_t* wui_page_get_desc(uint16_t page);
const char* wui_page_get_name(uint16_t page);
/*******************************************************************************
* UI UPDATE API
******************************************************************************/
uint32_t wui_page_ui_update(void);
void wui_page_ui_tick(uint32_t delta_ms);
/*******************************************************************************
* KEY EVENT API
******************************************************************************/
void wui_register_key_handler(void (*handler)(uint32_t key));
void wui_dispatch_key(void);
void wui_set_key_event(uint32_t key);
/*******************************************************************************
* TOUCH LAYER API
******************************************************************************/
void wui_register_touch_layer(const wui_touch_area_t* areas, uint8_t count, void (*on_event)(uint16_t widget_id, wui_event_t event));
void wui_touch_area_set_enabled(uint16_t widget_id, uint8_t enabled);
#endif /* WUI_H */
@@ -0,0 +1,304 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : wui_widget.h
* Author : WCH
* Version : V1.2.0
* Date : 2026/07/30
* Description : This file contains widget type definitions, properties structures,
* and API functions for widget manipulation.
*********************************************************************************/
#ifndef WUI_WIDGET_H
#define WUI_WIDGET_H
#include <stdint.h>
#include "wui.h"
/*******************************************************************************
* TYPE DEFINITIONS
******************************************************************************/
/* Widget ID types */
typedef uint16_t wui_str_id_t; /* String resource ID */
typedef uint16_t wui_font_id_t; /* Font resource ID */
typedef uint16_t wui_bitmap_font_id_t; /* Bitmap font resource ID */
typedef uint16_t wui_imgtable_id_t; /* Image table resource ID */
typedef uint16_t wui_swgroup_id_t; /* Switch group resource ID */
/*******************************************************************************
* WIDGET TYPES
******************************************************************************/
/**
* @brief Widget type enumeration
*/
typedef enum
{
Wui_w_None, /* Invalid widget type */
Wui_w_Anime, /* Animation widget */
Wui_w_Switch, /* Switch widget */
Wui_w_Res0, /* Reserved 0 */
Wui_w_MultiState, /* Multi-state widget */
Wui_w_StaticImage, /* Static image widget */
Wui_w_QRCode, /* QR code widget */
Wui_w_Rect, /* Rectangle widget */
Wui_w_Res1, /* Reserved 1 */
Wui_w_Res2, /* Reserved 2 */
Wui_w_Res3, /* Reserved 3 */
Wui_w_ProgressBar, /* Progress bar widget */
Wui_w_Button, /* Button widget */
Wui_w_ImgSlider, /* Image slider widget */
Wui_w_SimpleString, /* Simple string widget */
Wui_w_ExString, /* Extended string widget */
Wui_w_COUNT /* Widget type count */
} _wui_widget_type_t;
typedef uint16_t wui_widget_type_t;
/*******************************************************************************
* CONSTANTS & MACROS
******************************************************************************/
/* Progress bar direction */
#define WUI_PB_HORIZONTAL 0 /* Horizontal progress bar */
#define WUI_PB_VERTICAL 1 /* Vertical progress bar */
/* Image slider direction */
#define WUI_IMGSLIDER_HORIZONTAL 0 /* Horizontal image slider */
#define WUI_IMGSLIDER_VERTICAL 1 /* Vertical image slider */
/* Simple string alignment */
#define WUI_SIMPLESTRING_ALIGN_LEFT 0 /* Left alignment */
#define WUI_SIMPLESTRING_ALIGN_RIGHT 1 /* Right alignment */
#define WUI_SIMPLESTRING_ALIGN_CENTER 2 /* Center alignment */
/* Extended string type */
#define WUI_EXSTRING_TYPE_NORMAL 0 /* Normal type */
/* Extended string alignment */
#define WUI_EXSTRING_ALIGN_LEFT 0 /* Left alignment */
#define WUI_EXSTRING_ALIGN_RIGHT 1 /* Right alignment */
#define WUI_EXSTRING_ALIGN_CENTER 2 /* Center alignment */
/*******************************************************************************
* WIDGET PROPERTIES
******************************************************************************/
/* Animation widget properties */
typedef struct
{
uint16_t start_img_id; /* Start image ID */
uint16_t frame_count; /* Total frame count */
uint8_t fps; /* Frames per second */
uint8_t loop; /* Loop mode (0: no loop, 1: loop) */
} wui_widget_anime_props_t;
/* Switch widget properties*/
typedef struct
{
uint16_t on_img_id; /* ON state image ID */
uint16_t off_img_id; /* OFF state image ID */
uint8_t is_on; /* Current state (0: OFF, 1: ON) */
} wui_widget_switch_props_t;
/* Multi-state widget properties */
typedef struct
{
wui_imgtable_id_t imgtable_id; /* Image table ID */
uint8_t state_count; /* Number of states */
uint8_t default_state; /* Default state index */
} wui_widget_multistate_props_t;
/* Static image widget properties */
typedef struct
{
uint16_t img_id; /* Image ID */
} wui_widget_staticimg_props_t;
/* QR code widget properties */
typedef struct
{
uint16_t img_id; /* Image ID */
} wui_widget_qrcode_props_t;
/* Rectangle widget properties */
typedef struct
{
uint16_t color; /* Rectangle color */
} wui_widget_rect_props_t;
/* Button widget properties */
typedef struct
{
uint16_t normal_img_id; /* Normal state image ID */
uint16_t pressed_img_id; /* Pressed state image ID */
uint8_t is_pressed; /* Current state (0: released, 1: pressed) */
} wui_widget_button_props_t;
/* Progress bar widget properties */
typedef struct
{
uint8_t direction; /* Direction (HORIZONTAL/VERTICAL) */
uint8_t min_value; /* Minimum value */
uint8_t max_value; /* Maximum value */
uint8_t current_value; /* Current value */
uint16_t bg_color; /* Background color */
uint16_t fill_color; /* Fill color */
uint16_t thumb_color; /* Thumb color */
uint16_t thumb_w; /* Thumb width */
} wui_widget_pb_props_t;
/* Image slider widget properties */
typedef struct
{
uint16_t full_img_id; /* Full image ID , Must be in raw format */
uint16_t empty_img_id; /* Empty image ID , Must be in raw format*/
uint8_t current_value; /* Initialization percentage (0-100) */
uint8_t direction; /* Direction (HORIZONTAL/VERTICAL) */
} wui_widget_imgslider_props_t;
/* Simple string widget properties */
typedef struct
{
wui_str_id_t str_id; /* String resource ID */
uint16_t fg_color; /* Foreground color */
uint16_t bg_color; /* Background color */
uint8_t align; /* Alignment (LEFT/RIGHT/CENTER) */
wui_bitmap_font_id_t font_id; /* Bitmap font ID */
} wui_widget_simplestring_props_t;
/* Extended string widget properties */
typedef struct
{
uint8_t type; /* String type */
uint8_t align; /* Alignment (LEFT/RIGHT/CENTER) */
union
{
struct
{
uint16_t fg_color; /* Foreground color */
uint16_t bg_color; /* Background color */
};
void* res; /* Reserved pointer */
};
wui_str_id_t str_id; /* String resource ID */
wui_font_id_t font_id; /* Font ID */
} wui_widget_exstring_props_t;
/*******************************************************************************
* WIDGET DESCRIPTOR
******************************************************************************/
/* This is the main structure for defining a widget */
typedef struct
{
uint16_t widget_id; /* Unique widget ID */
uint16_t type; /* Widget type */
uint16_t x, y, w, h; /* Widget position and size */
uint8_t flags; /* Widget flags */
union
{
wui_widget_anime_props_t anime; /* Animation properties */
wui_widget_switch_props_t switch_; /* Switch properties */
// wui_widget_swgroup_props_t swgroup; /* Switch group properties */
wui_widget_multistate_props_t multistate; /* Multi-state properties */
wui_widget_staticimg_props_t staticimg; /* Static image properties */
wui_widget_qrcode_props_t qrcode; /* QR code properties */
wui_widget_rect_props_t rect; /* Rectangle properties */
wui_widget_pb_props_t progress; /* Progress bar properties */
wui_widget_button_props_t button; /* Button properties */
wui_widget_imgslider_props_t imgslider; /* Image slider properties */
wui_widget_simplestring_props_t simplestring; /* Simple string properties */
wui_widget_exstring_props_t exstring; /* Extended string properties */
} props;
} wui_widget_desc_t;
/*******************************************************************************
* API FUNCTIONS
******************************************************************************/
void wui_page_init(const wui_widget_desc_t* widgets, uint8_t widget_count);
/*******************************************************************************
* ANIMATION API
******************************************************************************/
void wui_widget_anime_play(uint16_t widget_id);
void wui_widget_anime_pause(uint16_t widget_id);
void wui_widget_anime_reset(uint16_t widget_id);
uint8_t wui_widget_anime_is_completed(uint16_t widget_id);
/*******************************************************************************
* SWITCH API
******************************************************************************/
void wui_widget_switch_toggle(uint16_t widget_id);
void wui_widget_switch_set_on(uint16_t widget_id, uint8_t on);
uint8_t wui_widget_switch_is_on(uint16_t widget_id);
/*******************************************************************************
* MULTI-STATE API
******************************************************************************/
void wui_widget_multistate_next(uint16_t widget_id);
void wui_widget_multistate_prev(uint16_t widget_id);
void wui_widget_multistate_set_index(uint16_t widget_id, uint8_t index);
uint8_t wui_widget_multistate_get_index(uint16_t widget_id);
/*******************************************************************************
* STATIC IMAGE API
******************************************************************************/
uint16_t wui_widget_staticimg_get_img_id(uint16_t widget_id);
void wui_widget_staticimg_set_img_id(uint16_t widget_id, uint16_t img_id);
/*******************************************************************************
* RECTANGLE API
******************************************************************************/
void wui_widget_rect_set_color(uint16_t widget_id, uint16_t color);
uint16_t wui_widget_rect_get_color(uint16_t widget_id);
/*******************************************************************************
* PROGRESS BAR API
******************************************************************************/
void wui_widget_pb_set_value(uint16_t widget_id, uint8_t value);
uint8_t wui_widget_pb_get_value(uint16_t widget_id);
/*******************************************************************************
* IMAGE SLIDER API
******************************************************************************/
void wui_widget_imgslider_set_value(uint16_t widget_id, uint8_t current_value);
uint8_t wui_widget_imgslider_get_value(uint16_t widget_id);
/*******************************************************************************
* BUTTON API
******************************************************************************/
void wui_widget_button_press(uint16_t widget_id);
void wui_widget_button_release(uint16_t widget_id);
uint8_t wui_widget_button_is_pressed(uint16_t widget_id);
/*******************************************************************************
* SIMPLE STRING API
******************************************************************************/
void wui_widget_simplestring_set_str(uint16_t widget_id, const char* str);
const char* wui_widget_simplestring_get_str(uint16_t widget_id);
void wui_widget_simplestring_set_align(uint16_t widget_id, uint8_t align);
uint8_t wui_widget_simplestring_get_align(uint16_t widget_id);
void wui_widget_simplestring_set_color(uint16_t widget_id, uint16_t fg_color, uint16_t bg_color);
/*******************************************************************************
* EXTENDED STRING API
******************************************************************************/
void wui_widget_exstring_set_str(uint16_t widget_id, const char* str);
const char* wui_widget_exstring_get_str(uint16_t widget_id);
void wui_widget_exstring_set_align(uint16_t widget_id, uint8_t align);
uint8_t wui_widget_exstring_get_align(uint16_t widget_id);
#endif /* WUI_WIDGET_H */
@@ -0,0 +1,150 @@
#include "wui.h"
#include "wui_port.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#include "flash.h"
#include "images.h"
#include "LCD.h"
#include "spi.h"
void HW_Key_event(uint32_t _key_code)
{
printf("[KEY] press %c\n", _key_code);
wui_set_key_event(_key_code);
}
/*********************************************************************
* @fn touch_read
*
* @brief Read touch screen coordinates and pressed state.
* v203 has no touch screen, so touch is disabled.
*
* @param x - Pointer to store X coordinate.
* @param y - Pointer to store Y coordinate.
* @param pressed - Pointer to store pressed state.
*
* @return none
*/
static void touch_read(uint16_t* x, uint16_t* y, uint8_t* pressed)
{
*x = 0;
*y = 0;
*pressed = 0;
}
/*********************************************************************
* @fn spi_flash_read
*
* @brief Read data from SPI Flash.
*
* @param outBuffer - Pointer to data buffer to store read data.
* @param ReadAddr - Start address to read from.
* @param size - Number of bytes to read.
*
* @return none
*/
static void spi_flash_read(uint8_t* outBuffer, uint32_t ReadAddr, uint32_t size)
{
SPI_Flash_Read_dma_start(ReadAddr);
SPI1_Read_DMA(outBuffer, (uint16_t)size);
SPI1_wait_for_bsy();
SPI_Flash_Read_dma_end();
}
/*********************************************************************
* @fn lcd_set_windows
*
* @brief Set LCD display window.
*
* @param x_start - Start X coordinate.
* @param y_start - Start Y coordinate.
* @param x_end - End X coordinate.
* @param y_end - End Y coordinate.
*
* @return none
*/
static void lcd_set_windows(uint16_t x_start, uint16_t y_start, uint16_t x_end, uint16_t y_end)
{
LCD_SetWindows(x_start, y_start, x_end, y_end);
}
/*********************************************************************
* @fn lcd_dma_start
*
* @brief Start LCD data transfer.
*
* @return none
*/
static void lcd_dma_start(void)
{
LCD_DC_SET();
LCD_CS_CLR();
}
/*********************************************************************
* @fn lcd_dma_send
*
* @brief Send data via LCD DMA.
*
* @param buf - Pointer to data buffer to send.
* @param len - Length of data in bytes.
*
* @return none
*/
static void lcd_dma_send(const uint8_t* buf, uint32_t len)
{
SPI2_Write_DMA((uint8_t*)buf, (uint16_t)len);
}
/*********************************************************************
* @fn lcd_dma_wait
*
* @brief Wait for LCD DMA transfer to complete.
*
* @return none
*/
static void lcd_dma_wait(void)
{
while (SPI2_DMA_TX_CH->CNTR > 0)
{
}
while (SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_BSY) == SET)
;
}
/*********************************************************************
* @fn lcd_dma_end
*
* @brief End LCD DMA transfer.
*
* @return none
*/
static void lcd_dma_end(void)
{
LCD_CS_SET();
}
/*********************************************************************
* @fn wui_get_hal
*
* @brief Get WUI HAL interface structure.
*
* @return Pointer to HAL interface structure.
*/
const wui_hal_t* wui_get_hal(void)
{
static const wui_hal_t hal = {
.touch_read = touch_read,
.flash_read = spi_flash_read,
.lcd_set_windows = lcd_set_windows,
.lcd_dma_start = lcd_dma_start,
.lcd_dma_send = lcd_dma_send,
.lcd_dma_wait = lcd_dma_wait,
.lcd_dma_end = lcd_dma_end,
};
return &hal;
}
@@ -0,0 +1,11 @@
#ifndef __WUI_PORT_H
#define __WUI_PORT_H
#include <stdint.h>
#include "wui.h"
void HW_Key_event(uint32_t _key_code);
const wui_hal_t* wui_get_hal(void);
#endif // __WUI_PORT_H
Binary file not shown.
@@ -0,0 +1,377 @@
/**
* @file images.h
* @brief Image resource table generated by WCHGUIDesigner.
* @note Byte order: Big Endian
*/
#ifndef _IMAGES_H_
#define _IMAGES_H_
#include <stdint.h>
#include <stddef.h>
typedef enum {
IMAGE_NONE = 0xFFFF,
// === Raw images (0b000) ===
IMAGE_ART_WUI_PAGE_MAIN_MAIN_TIME_0030 = MAKE_IMAGE_ID(IMAGE_TYPE_RAW, 0),
IMAGE_ART_WUI_PAGE_MAIN_MAIN_TIME_0031 = MAKE_IMAGE_ID(IMAGE_TYPE_RAW, 1),
IMAGE_ART_WUI_PAGE_MAIN_MAIN_TIME_0032 = MAKE_IMAGE_ID(IMAGE_TYPE_RAW, 2),
IMAGE_ART_WUI_PAGE_MAIN_MAIN_TIME_0033 = MAKE_IMAGE_ID(IMAGE_TYPE_RAW, 3),
IMAGE_ART_WUI_PAGE_MAIN_MAIN_TIME_0034 = MAKE_IMAGE_ID(IMAGE_TYPE_RAW, 4),
IMAGE_ART_WUI_PAGE_MAIN_MAIN_TIME_0035 = MAKE_IMAGE_ID(IMAGE_TYPE_RAW, 5),
IMAGE_ART_WUI_PAGE_MAIN_MAIN_TIME_0036 = MAKE_IMAGE_ID(IMAGE_TYPE_RAW, 6),
IMAGE_ART_WUI_PAGE_MAIN_MAIN_TIME_0037 = MAKE_IMAGE_ID(IMAGE_TYPE_RAW, 7),
IMAGE_ART_WUI_PAGE_MAIN_MAIN_TIME_0038 = MAKE_IMAGE_ID(IMAGE_TYPE_RAW, 8),
IMAGE_ART_WUI_PAGE_MAIN_MAIN_TIME_0039 = MAKE_IMAGE_ID(IMAGE_TYPE_RAW, 9),
IMAGE_ART_WUI_PAGE_MAIN_MAIN_TIME_003A = MAKE_IMAGE_ID(IMAGE_TYPE_RAW, 10),
// === CLUT images (0b010) ===
IMAGE_RES_IMG_TPL_MAIN_PAGELIGHTCFG1 = MAKE_IMAGE_ID(IMAGE_TYPE_CLUT, 11),
IMAGE_RES_IMG_TPL_MAIN_PAGELIGHTCFG2 = MAKE_IMAGE_ID(IMAGE_TYPE_CLUT, 12),
IMAGE_RES_IMG_TPL_MAIN_PAGELIGHTCOLOR1 = MAKE_IMAGE_ID(IMAGE_TYPE_CLUT, 13),
IMAGE_RES_IMG_TPL_MAIN_PAGELIGHTCOLOR2 = MAKE_IMAGE_ID(IMAGE_TYPE_CLUT, 14),
IMAGE_RES_IMG_TPL_MAIN_PAGERELDATA1 = MAKE_IMAGE_ID(IMAGE_TYPE_CLUT, 15),
IMAGE_RES_IMG_TPL_MAIN_PAGERELDATA2 = MAKE_IMAGE_ID(IMAGE_TYPE_CLUT, 16),
IMAGE_RES_IMG_TPL_MAIN_PAGEANIMAL1 = MAKE_IMAGE_ID(IMAGE_TYPE_CLUT, 17),
IMAGE_RES_IMG_TPL_MAIN_PAGEANIMAL2 = MAKE_IMAGE_ID(IMAGE_TYPE_CLUT, 18),
IMAGE_RES_IMG_TPL_MAIN_PAGEMODEL1 = MAKE_IMAGE_ID(IMAGE_TYPE_CLUT, 19),
IMAGE_RES_IMG_TPL_MAIN_PAGEMODEL2 = MAKE_IMAGE_ID(IMAGE_TYPE_CLUT, 20),
IMAGE_RES_IMG_TPL_MAIN_PAGESETTING1 = MAKE_IMAGE_ID(IMAGE_TYPE_CLUT, 21),
IMAGE_RES_IMG_TPL_MAIN_PAGESETTING2 = MAKE_IMAGE_ID(IMAGE_TYPE_CLUT, 22),
IMAGE_RES_IMG_TPL_MAIN_BAT00 = MAKE_IMAGE_ID(IMAGE_TYPE_CLUT, 23),
IMAGE_RES_IMG_TPL_MAIN_BAT01 = MAKE_IMAGE_ID(IMAGE_TYPE_CLUT, 24),
IMAGE_RES_IMG_TPL_MAIN_BAT02 = MAKE_IMAGE_ID(IMAGE_TYPE_CLUT, 25),
IMAGE_RES_IMG_TPL_MAIN_BAT03 = MAKE_IMAGE_ID(IMAGE_TYPE_CLUT, 26),
IMAGE_RES_IMG_TPL_MAIN_BAT04 = MAKE_IMAGE_ID(IMAGE_TYPE_CLUT, 27),
IMAGE_RES_IMG_TPL_MAIN_BAT05 = MAKE_IMAGE_ID(IMAGE_TYPE_CLUT, 28),
IMAGE_RES_IMG_TPL_MAIN_BAT06 = MAKE_IMAGE_ID(IMAGE_TYPE_CLUT, 29),
IMAGE_RES_IMG_TPL_MAIN_BAT07 = MAKE_IMAGE_ID(IMAGE_TYPE_CLUT, 30),
IMAGE_RES_IMG_TPL_MAIN_BAT08 = MAKE_IMAGE_ID(IMAGE_TYPE_CLUT, 31),
IMAGE_RES_IMG_TPL_MAIN_BAT09 = MAKE_IMAGE_ID(IMAGE_TYPE_CLUT, 32),
IMAGE_RES_IMG_TPL_MAIN_BAT10 = MAKE_IMAGE_ID(IMAGE_TYPE_CLUT, 33),
IMAGE_RES_IMG_TPL_MAIN_BAT11 = MAKE_IMAGE_ID(IMAGE_TYPE_CLUT, 34),
IMAGE_RES_IMG_TPL_MAIN_BAT12 = MAKE_IMAGE_ID(IMAGE_TYPE_CLUT, 35),
IMAGE_RES_IMG_TPL_MAIN_BAT13 = MAKE_IMAGE_ID(IMAGE_TYPE_CLUT, 36),
IMAGE_RES_IMG_TPL_MAIN_BAT14 = MAKE_IMAGE_ID(IMAGE_TYPE_CLUT, 37),
IMAGE_RES_IMG_TPL_MAIN_BAT15 = MAKE_IMAGE_ID(IMAGE_TYPE_CLUT, 38),
IMAGE_RES_IMG_TPL_MAIN_BAT16 = MAKE_IMAGE_ID(IMAGE_TYPE_CLUT, 39),
IMAGE_RES_IMG_TPL_MAIN_BAT17 = MAKE_IMAGE_ID(IMAGE_TYPE_CLUT, 40),
IMAGE_RES_IMG_TPL_MAIN_BAT18 = MAKE_IMAGE_ID(IMAGE_TYPE_CLUT, 41),
IMAGE_RES_IMG_TPL_MAIN_BAT19 = MAKE_IMAGE_ID(IMAGE_TYPE_CLUT, 42),
IMAGE_RES_IMG_TPL_MAIN_BAT20 = MAKE_IMAGE_ID(IMAGE_TYPE_CLUT, 43),
IMAGE_RES_IMG_TPL_MAIN_BAT21 = MAKE_IMAGE_ID(IMAGE_TYPE_CLUT, 44),
IMAGE_RES_IMG_TPL_MAIN_CON1 = MAKE_IMAGE_ID(IMAGE_TYPE_CLUT, 45),
IMAGE_RES_IMG_TPL_MAIN_CON2 = MAKE_IMAGE_ID(IMAGE_TYPE_CLUT, 46),
IMAGE_RES_IMG_TPL_MAIN_CON3 = MAKE_IMAGE_ID(IMAGE_TYPE_CLUT, 47),
IMAGE_RES_IMG_TPL_MAIN_BG = MAKE_IMAGE_ID(IMAGE_TYPE_CLUT, 48),
} image_index_t;
static const image_info_t image_table[] = {
{ // IMAGE_ART_WUI_PAGE_MAIN_MAIN_TIME_0030
.addr = 0x0001DED4,
.width = 10,
.height = 26,
.data_size = 520,
},
{ // IMAGE_ART_WUI_PAGE_MAIN_MAIN_TIME_0031
.addr = 0x0001E0DC,
.width = 10,
.height = 26,
.data_size = 520,
},
{ // IMAGE_ART_WUI_PAGE_MAIN_MAIN_TIME_0032
.addr = 0x0001E2E4,
.width = 10,
.height = 26,
.data_size = 520,
},
{ // IMAGE_ART_WUI_PAGE_MAIN_MAIN_TIME_0033
.addr = 0x0001E4EC,
.width = 10,
.height = 26,
.data_size = 520,
},
{ // IMAGE_ART_WUI_PAGE_MAIN_MAIN_TIME_0034
.addr = 0x0001E6F4,
.width = 10,
.height = 26,
.data_size = 520,
},
{ // IMAGE_ART_WUI_PAGE_MAIN_MAIN_TIME_0035
.addr = 0x0001E8FC,
.width = 10,
.height = 26,
.data_size = 520,
},
{ // IMAGE_ART_WUI_PAGE_MAIN_MAIN_TIME_0036
.addr = 0x0001EB04,
.width = 10,
.height = 26,
.data_size = 520,
},
{ // IMAGE_ART_WUI_PAGE_MAIN_MAIN_TIME_0037
.addr = 0x0001ED0C,
.width = 10,
.height = 26,
.data_size = 520,
},
{ // IMAGE_ART_WUI_PAGE_MAIN_MAIN_TIME_0038
.addr = 0x0001EF14,
.width = 10,
.height = 26,
.data_size = 520,
},
{ // IMAGE_ART_WUI_PAGE_MAIN_MAIN_TIME_0039
.addr = 0x0001F11C,
.width = 10,
.height = 26,
.data_size = 520,
},
{ // IMAGE_ART_WUI_PAGE_MAIN_MAIN_TIME_003A
.addr = 0x0001F324,
.width = 10,
.height = 26,
.data_size = 520,
},
{ // IMAGE_RES_IMG_TPL_MAIN_PAGELIGHTCFG1
.addr = 0x00000000,
.width = 73,
.height = 99,
.data_size = 7739,
},
{ // IMAGE_RES_IMG_TPL_MAIN_PAGELIGHTCFG2
.addr = 0x00001E3C,
.width = 73,
.height = 99,
.data_size = 7739,
},
{ // IMAGE_RES_IMG_TPL_MAIN_PAGELIGHTCOLOR1
.addr = 0x00003C78,
.width = 73,
.height = 99,
.data_size = 7739,
},
{ // IMAGE_RES_IMG_TPL_MAIN_PAGELIGHTCOLOR2
.addr = 0x00005AB4,
.width = 73,
.height = 99,
.data_size = 7739,
},
{ // IMAGE_RES_IMG_TPL_MAIN_PAGERELDATA1
.addr = 0x000078F0,
.width = 73,
.height = 99,
.data_size = 7739,
},
{ // IMAGE_RES_IMG_TPL_MAIN_PAGERELDATA2
.addr = 0x0000972C,
.width = 73,
.height = 99,
.data_size = 7739,
},
{ // IMAGE_RES_IMG_TPL_MAIN_PAGEANIMAL1
.addr = 0x0000B568,
.width = 73,
.height = 99,
.data_size = 7739,
},
{ // IMAGE_RES_IMG_TPL_MAIN_PAGEANIMAL2
.addr = 0x0000D3A4,
.width = 73,
.height = 99,
.data_size = 7739,
},
{ // IMAGE_RES_IMG_TPL_MAIN_PAGEMODEL1
.addr = 0x0000F1E0,
.width = 73,
.height = 99,
.data_size = 7739,
},
{ // IMAGE_RES_IMG_TPL_MAIN_PAGEMODEL2
.addr = 0x0001101C,
.width = 73,
.height = 99,
.data_size = 7739,
},
{ // IMAGE_RES_IMG_TPL_MAIN_PAGESETTING1
.addr = 0x00012E58,
.width = 73,
.height = 99,
.data_size = 7739,
},
{ // IMAGE_RES_IMG_TPL_MAIN_PAGESETTING2
.addr = 0x00014C94,
.width = 73,
.height = 99,
.data_size = 7739,
},
{ // IMAGE_RES_IMG_TPL_MAIN_BAT00
.addr = 0x00016AD0,
.width = 26,
.height = 26,
.data_size = 1188,
},
{ // IMAGE_RES_IMG_TPL_MAIN_BAT01
.addr = 0x00016F74,
.width = 26,
.height = 26,
.data_size = 1188,
},
{ // IMAGE_RES_IMG_TPL_MAIN_BAT02
.addr = 0x00017418,
.width = 26,
.height = 26,
.data_size = 1188,
},
{ // IMAGE_RES_IMG_TPL_MAIN_BAT03
.addr = 0x000178BC,
.width = 26,
.height = 26,
.data_size = 1188,
},
{ // IMAGE_RES_IMG_TPL_MAIN_BAT04
.addr = 0x00017D60,
.width = 26,
.height = 26,
.data_size = 1188,
},
{ // IMAGE_RES_IMG_TPL_MAIN_BAT05
.addr = 0x00018204,
.width = 26,
.height = 26,
.data_size = 1188,
},
{ // IMAGE_RES_IMG_TPL_MAIN_BAT06
.addr = 0x000186A8,
.width = 26,
.height = 26,
.data_size = 1188,
},
{ // IMAGE_RES_IMG_TPL_MAIN_BAT07
.addr = 0x00018B4C,
.width = 26,
.height = 26,
.data_size = 1188,
},
{ // IMAGE_RES_IMG_TPL_MAIN_BAT08
.addr = 0x00018FF0,
.width = 26,
.height = 26,
.data_size = 1188,
},
{ // IMAGE_RES_IMG_TPL_MAIN_BAT09
.addr = 0x00019494,
.width = 26,
.height = 26,
.data_size = 1188,
},
{ // IMAGE_RES_IMG_TPL_MAIN_BAT10
.addr = 0x00019938,
.width = 26,
.height = 26,
.data_size = 1188,
},
{ // IMAGE_RES_IMG_TPL_MAIN_BAT11
.addr = 0x00019DDC,
.width = 26,
.height = 26,
.data_size = 1188,
},
{ // IMAGE_RES_IMG_TPL_MAIN_BAT12
.addr = 0x0001A280,
.width = 26,
.height = 26,
.data_size = 1188,
},
{ // IMAGE_RES_IMG_TPL_MAIN_BAT13
.addr = 0x0001A724,
.width = 26,
.height = 26,
.data_size = 1188,
},
{ // IMAGE_RES_IMG_TPL_MAIN_BAT14
.addr = 0x0001ABC8,
.width = 26,
.height = 26,
.data_size = 1188,
},
{ // IMAGE_RES_IMG_TPL_MAIN_BAT15
.addr = 0x0001B06C,
.width = 26,
.height = 26,
.data_size = 1188,
},
{ // IMAGE_RES_IMG_TPL_MAIN_BAT16
.addr = 0x0001B510,
.width = 26,
.height = 26,
.data_size = 1188,
},
{ // IMAGE_RES_IMG_TPL_MAIN_BAT17
.addr = 0x0001B9B4,
.width = 26,
.height = 26,
.data_size = 1188,
},
{ // IMAGE_RES_IMG_TPL_MAIN_BAT18
.addr = 0x0001BE58,
.width = 26,
.height = 26,
.data_size = 1188,
},
{ // IMAGE_RES_IMG_TPL_MAIN_BAT19
.addr = 0x0001C2FC,
.width = 26,
.height = 26,
.data_size = 1188,
},
{ // IMAGE_RES_IMG_TPL_MAIN_BAT20
.addr = 0x0001C7A0,
.width = 26,
.height = 26,
.data_size = 1188,
},
{ // IMAGE_RES_IMG_TPL_MAIN_BAT21
.addr = 0x0001CC44,
.width = 26,
.height = 26,
.data_size = 1188,
},
{ // IMAGE_RES_IMG_TPL_MAIN_CON1
.addr = 0x0001D0E8,
.width = 26,
.height = 26,
.data_size = 1188,
},
{ // IMAGE_RES_IMG_TPL_MAIN_CON2
.addr = 0x0001D58C,
.width = 26,
.height = 26,
.data_size = 1188,
},
{ // IMAGE_RES_IMG_TPL_MAIN_CON3
.addr = 0x0001DA30,
.width = 26,
.height = 26,
.data_size = 1188,
},
{ // IMAGE_RES_IMG_TPL_MAIN_BG
.addr = 0x0001F52C,
.width = 320,
.height = 240,
.data_size = 77312,
},
};
#define RAW_IMAGE_COUNT 11
#define RLE_IMAGE_COUNT 0
#define CLUT_IMAGE_COUNT 38
#define CLUT4_IMAGE_COUNT 0
#define IMAGE_COUNT 49
static inline const image_info_t* get_image(image_index_t index) {
uint16_t idx = IMAGE_GET_INDEX(index);
if (idx >= IMAGE_COUNT) return NULL;
return &image_table[idx];
}
#endif /* _IMAGES_H_ */
@@ -0,0 +1,170 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : wui_asset.c
* Author : WCH
* Version : V1.2.0
* Date : 2026/07/30
* Description : This file is auto-generated by WUI Designer Tool.
* : Contains WUI asset resources (strings, images, fonts).
*********************************************************************************
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
* Attention: This software (modified or not) and binary are used for
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
#include "wui_asset.h"
#include <stddef.h>
#include "LCD_Font.h"
const wui_bitfont_t wui_font_6x12 = { 6, 12, 0x20, 95, (const uint8_t*)asc2_1206 };
const wui_bitfont_t wui_font_8x16 = { 8, 16, 0x20, 95, (const uint8_t*)asc2_1608 };
/*******************************************************************************
* STRING RESOURCES
******************************************************************************/
/* Maps string IDs to string pointers */
static const char* wui_string_table[WUI_STR_COUNT] = {
[WUI_STR_NONE] = NULL,
[WUI_STR_MAIN_MAIN_TIME] = "12:34",
};
/**
* @brief Get string by ID
* @param id - String ID
* @return String pointer, or NULL if not found
*/
const char* wui_get_string(wui_str_id_t id)
{
if (id > 0 && id < WUI_STR_COUNT)
{
return wui_string_table[id];
}
return NULL;
}
/*******************************************************************************
* IMAGE TABLE RESOURCES
******************************************************************************/
static const uint16_t wui_imgtable_main_main_battery[] = {
IMAGE_RES_IMG_TPL_MAIN_BAT00,
IMAGE_RES_IMG_TPL_MAIN_BAT01,
IMAGE_RES_IMG_TPL_MAIN_BAT02,
IMAGE_RES_IMG_TPL_MAIN_BAT03,
IMAGE_RES_IMG_TPL_MAIN_BAT04,
IMAGE_RES_IMG_TPL_MAIN_BAT05,
IMAGE_RES_IMG_TPL_MAIN_BAT06,
IMAGE_RES_IMG_TPL_MAIN_BAT07,
IMAGE_RES_IMG_TPL_MAIN_BAT08,
IMAGE_RES_IMG_TPL_MAIN_BAT09,
IMAGE_RES_IMG_TPL_MAIN_BAT10,
IMAGE_RES_IMG_TPL_MAIN_BAT11,
IMAGE_RES_IMG_TPL_MAIN_BAT12,
IMAGE_RES_IMG_TPL_MAIN_BAT13,
IMAGE_RES_IMG_TPL_MAIN_BAT14,
IMAGE_RES_IMG_TPL_MAIN_BAT15,
IMAGE_RES_IMG_TPL_MAIN_BAT16,
IMAGE_RES_IMG_TPL_MAIN_BAT17,
IMAGE_RES_IMG_TPL_MAIN_BAT18,
IMAGE_RES_IMG_TPL_MAIN_BAT19,
IMAGE_RES_IMG_TPL_MAIN_BAT20,
IMAGE_RES_IMG_TPL_MAIN_BAT21,
};
static const uint16_t wui_imgtable_main_main_connection[] = {
IMAGE_RES_IMG_TPL_MAIN_CON1,
IMAGE_RES_IMG_TPL_MAIN_CON2,
IMAGE_RES_IMG_TPL_MAIN_CON3,
};
/* Maps image table IDs to image ID arrays */
static const uint16_t* wui_imgtable_list[WUI_IMGTABLE_COUNT] = {
[WUI_IMGTABLE_NONE] = NULL,
[WUI_IMGTABLE_MAIN_MAIN_BATTERY] = wui_imgtable_main_main_battery,
[WUI_IMGTABLE_MAIN_MAIN_CONNECTION] = wui_imgtable_main_main_connection,
};
/**
* @brief Get image table by ID
* @param id - Image table ID
* @return Image table pointer, or NULL if not found
*/
const uint16_t* wui_get_imgtable(wui_imgtable_id_t id)
{
if (id > 0 && id < WUI_IMGTABLE_COUNT)
{
return wui_imgtable_list[id];
}
return NULL;
}
/*******************************************************************************
* FONT RESOURCES
******************************************************************************/
/**
* @brief Font table for WUI
* @details Maps font IDs to font structures
*/
static const wui_font_t wui_font_table[WUI_FONT_COUNT] = {
[WUI_FONT_NONE] = {0},
[WUI_FONT_WUI_PAGE_MAIN_MAIN_TIME] = {
.cnt = 10,
.start_char = '0',
.width = 10,
.height = 26,
.first_img_id = IMAGE_ART_WUI_PAGE_MAIN_MAIN_TIME_0030,
},
};
const wui_font_t* wui_get_font(wui_font_id_t id)
{
if (id > 0 && id < WUI_FONT_COUNT)
{
return &wui_font_table[id];
}
return NULL;
}
/*******************************************************************************
* BITMAP FONT RESOURCES
******************************************************************************/
/* Maps bitmap font IDs to font structures */
static const wui_bitfont_t* wui_bitmap_font_table[WUI_BITMAP_FONT_COUNT] = {
[WUI_BITMAP_FONT_DEFAULT] = &wui_font_8x16,
[WUI_BITMAP_FONT_6X12] = &wui_font_6x12,
[WUI_BITMAP_FONT_8X16] = &wui_font_8x16,
};
/**
* @brief Get bitmap font by ID
* @param id - Bitmap font ID
* @return Bitmap font structure pointer, or default font if not found
*/
const wui_bitfont_t* wui_get_bitmap_font(wui_bitmap_font_id_t id)
{
if (id > 0 && id < WUI_BITMAP_FONT_COUNT) {
return wui_bitmap_font_table[id];
}
return wui_bitmap_font_table[WUI_BITMAP_FONT_DEFAULT];
}
/*********************************************************************
* @fn wui_get_image
*
* @brief Get image information by index.
*
* @param index - Image index.
*
* @return Pointer to image information structure.
*/
const image_info_t* wui_get_image(uint32_t index)
{
// return get_image(index);
uint16_t idx = IMAGE_GET_INDEX(index);
if (idx >= IMAGE_COUNT) return NULL;
return &image_table[idx];
}
@@ -0,0 +1,58 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : wui_asset.h
* Author : WCH
* Version : V1.2.0
* Date : 2026/07/30
* Description : Asset management functions
*********************************************************************************/
#ifndef WUI_ASSET_H
#define WUI_ASSET_H
#include <stdint.h>
#include "wui.h"
#include "images.h"
#include "wui_widget.h"
enum
{
WUI_STR_NONE = 0,
WUI_STR_MAIN_MAIN_TIME,
WUI_STR_COUNT
};
const char* wui_get_string(wui_str_id_t id);
enum
{
WUI_FONT_NONE = 0,
WUI_FONT_WUI_PAGE_MAIN_MAIN_TIME,
WUI_FONT_COUNT
};
const wui_font_t* wui_get_font(wui_font_id_t id);
enum
{
WUI_IMGTABLE_NONE = 0,
WUI_IMGTABLE_MAIN_MAIN_BATTERY,
WUI_IMGTABLE_MAIN_MAIN_CONNECTION,
WUI_IMGTABLE_COUNT
};
const uint16_t* wui_get_imgtable(wui_imgtable_id_t id);
enum {
WUI_BITMAP_FONT_DEFAULT = 0,
WUI_BITMAP_FONT_6X12,
WUI_BITMAP_FONT_8X16,
WUI_BITMAP_FONT_COUNT
};
const wui_bitfont_t* wui_get_bitmap_font(wui_bitmap_font_id_t id);
const image_info_t* wui_get_image(uint32_t index);
#endif
@@ -0,0 +1,22 @@
#include "wui_page.h"
#include "wui.h"
#include "images.h"
#include <stdio.h>
const wui_page_desc_t wui_pages[WUI_PAGE_COUNT] = {
[WUI_PAGE_NONE] = {
.bg_color = RGB888_TO_RGB565(0, 0, 0),
.page_name = "None",
.page_init = wui_page_none_init,
.page_loop = wui_page_none_loop,
.user_data = NULL,
},
[WUI_PAGE_MAIN] = {
.bg_color = RGB888_TO_RGB565(0, 0, 0),
.page_name = "Menu Page",
.page_init = wui_page_main_init,
.page_loop = wui_page_main_loop,
.user_data = NULL,
},
};
@@ -0,0 +1,25 @@
#ifndef WUI_PAGE_H
#define WUI_PAGE_H
#include <stdint.h>
#include "stddef.h"
#include "wui.h"
typedef enum
{
WUI_PAGE_NONE = 0,
WUI_PAGE_MAIN,
WUI_PAGE_COUNT,
} wui_page_t;
#define WUI_START_PAGE WUI_PAGE_MAIN
void wui_page_none_init(void);
void wui_page_none_loop(void);
void wui_page_main_init(void);
void wui_page_main_loop(void);
extern const wui_page_desc_t wui_pages[WUI_PAGE_COUNT];
#endif
@@ -0,0 +1,80 @@
#include "wui_user/wui_page_main.h"
// ================= Template Page =================
// Template: main menu
// Template interaction logic is generated from known template IDs.
// ================= Template Logic Hooks =================
#define MENU_COUNT 6
static const uint8_t menu_widget_ids[MENU_COUNT] = {
MAIN_MAIN_SETTING,
MAIN_MAIN_MODE,
MAIN_MAIN_ANIM,
MAIN_MAIN_REAL_DATA,
MAIN_MAIN_LIGHT_COLOR,
MAIN_MAIN_COLOR_CFG,
};
static const wui_page_t menu_pages[MENU_COUNT] = {
WUI_PAGE_MAIN,
WUI_PAGE_MAIN,
WUI_PAGE_MAIN,
WUI_PAGE_MAIN,
WUI_PAGE_MAIN,
WUI_PAGE_MAIN,
};
static uint8_t main_saved_selection = 0;
static uint8_t current_menu = 0;
static void menu_set(uint8_t index, uint8_t on)
{
if (index < MENU_COUNT)
{
if (on)
{
wui_widget_button_press(menu_widget_ids[index]);
}
else
{
wui_widget_button_release(menu_widget_ids[index]);
}
}
}
static void main_on_key(uint32_t key)
{
if (key == 'a')
{
menu_set(current_menu, 0);
current_menu = (current_menu == 0) ? MENU_COUNT - 1 : current_menu - 1;
menu_set(current_menu, 1);
}
else if (key == 'd')
{
menu_set(current_menu, 0);
current_menu = (current_menu + 1 >= MENU_COUNT) ? 0 : current_menu + 1;
menu_set(current_menu, 1);
}
else if (key == 'b')
{
main_saved_selection = current_menu;
wui_page_switch(menu_pages[current_menu]);
}
}
// ================= Page Functions =================
void wui_page_main_init(void)
{
wui_page_init(widgets_main, sizeof(widgets_main) / sizeof(widgets_main[0]));
current_menu = main_saved_selection;
menu_set(current_menu, 1);
wui_register_key_handler(main_on_key);
}
void wui_page_main_loop(void)
{
}
@@ -0,0 +1,183 @@
#ifndef WUI_PAGE_MAIN_H
#define WUI_PAGE_MAIN_H
#include "wui.h"
#include "wui_user/wui_page.h"
#include "wui_widget.h"
#include "images.h"
#include "wui_asset.h"
#include <stdio.h>
// ================= Widget ID Enum =================
typedef enum
{
MAIN_MAIN_BG_BLACK,
MAIN_MAIN_BG,
MAIN_MAIN_TIME,
MAIN_MAIN_CONNECTION,
MAIN_MAIN_BATTERY,
MAIN_MAIN_SETTING,
MAIN_MAIN_MODE,
MAIN_MAIN_ANIM,
MAIN_MAIN_REAL_DATA,
MAIN_MAIN_LIGHT_COLOR,
MAIN_MAIN_COLOR_CFG,
} main_widget_id_t;
// ================= Declarative Widgets =================
static const wui_widget_desc_t widgets_main[] = {
[MAIN_MAIN_BG_BLACK] = {
.widget_id = MAIN_MAIN_BG_BLACK,
.type = Wui_w_Rect,
.x = 0,
.y = 0,
.w = 320,
.h = 240,
.props.rect = {
.color = RGB888_TO_RGB565(0, 0, 0),
},
},
[MAIN_MAIN_BG] = {
.widget_id = MAIN_MAIN_BG,
.type = Wui_w_StaticImage,
.x = 0,
.y = 0,
.w = 320,
.h = 240,
.props.staticimg = {
.img_id = IMAGE_RES_IMG_TPL_MAIN_BG,
},
},
[MAIN_MAIN_TIME] = {
.widget_id = MAIN_MAIN_TIME,
.type = Wui_w_ExString,
.x = 12,
.y = 4,
.w = 50,
.h = 26,
.props.exstring = {
.str_id = WUI_STR_MAIN_MAIN_TIME,
.font_id = WUI_FONT_WUI_PAGE_MAIN_MAIN_TIME,
.bg_color = RGB888_TO_RGB565(0, 0, 0),
.align = WUI_EXSTRING_ALIGN_LEFT,
},
},
[MAIN_MAIN_CONNECTION] = {
.widget_id = MAIN_MAIN_CONNECTION,
.type = Wui_w_MultiState,
.x = 119,
.y = 4,
.w = 26,
.h = 26,
.props.multistate = {
.imgtable_id = WUI_IMGTABLE_MAIN_MAIN_CONNECTION,
.state_count = 3,
.default_state = 2,
},
},
[MAIN_MAIN_BATTERY] = {
.widget_id = MAIN_MAIN_BATTERY,
.type = Wui_w_MultiState,
.x = 280,
.y = 4,
.w = 26,
.h = 26,
.props.multistate = {
.imgtable_id = WUI_IMGTABLE_MAIN_MAIN_BATTERY,
.state_count = 22,
.default_state = 0,
},
},
[MAIN_MAIN_SETTING] = {
.widget_id = MAIN_MAIN_SETTING,
.type = Wui_w_Button,
.x = 24,
.y = 42,
.w = 73,
.h = 99,
.props.button = {
.pressed_img_id = IMAGE_RES_IMG_TPL_MAIN_PAGESETTING2,
.normal_img_id = IMAGE_RES_IMG_TPL_MAIN_PAGESETTING1,
.is_pressed = 0,
},
},
[MAIN_MAIN_MODE] = {
.widget_id = MAIN_MAIN_MODE,
.type = Wui_w_Button,
.x = 127,
.y = 42,
.w = 73,
.h = 99,
.props.button = {
.pressed_img_id = IMAGE_RES_IMG_TPL_MAIN_PAGEMODEL2,
.normal_img_id = IMAGE_RES_IMG_TPL_MAIN_PAGEMODEL1,
.is_pressed = 0,
},
},
[MAIN_MAIN_ANIM] = {
.widget_id = MAIN_MAIN_ANIM,
.type = Wui_w_Button,
.x = 226,
.y = 42,
.w = 73,
.h = 99,
.props.button = {
.pressed_img_id = IMAGE_RES_IMG_TPL_MAIN_PAGEANIMAL2,
.normal_img_id = IMAGE_RES_IMG_TPL_MAIN_PAGEANIMAL1,
.is_pressed = 0,
},
},
[MAIN_MAIN_REAL_DATA] = {
.widget_id = MAIN_MAIN_REAL_DATA,
.type = Wui_w_Button,
.x = 24,
.y = 141,
.w = 73,
.h = 99,
.props.button = {
.pressed_img_id = IMAGE_RES_IMG_TPL_MAIN_PAGERELDATA2,
.normal_img_id = IMAGE_RES_IMG_TPL_MAIN_PAGERELDATA1,
.is_pressed = 0,
},
},
[MAIN_MAIN_LIGHT_COLOR] = {
.widget_id = MAIN_MAIN_LIGHT_COLOR,
.type = Wui_w_Button,
.x = 127,
.y = 141,
.w = 73,
.h = 99,
.props.button = {
.pressed_img_id = IMAGE_RES_IMG_TPL_MAIN_PAGELIGHTCOLOR2,
.normal_img_id = IMAGE_RES_IMG_TPL_MAIN_PAGELIGHTCOLOR1,
.is_pressed = 0,
},
},
[MAIN_MAIN_COLOR_CFG] = {
.widget_id = MAIN_MAIN_COLOR_CFG,
.type = Wui_w_Button,
.x = 226,
.y = 141,
.w = 73,
.h = 99,
.props.button = {
.pressed_img_id = IMAGE_RES_IMG_TPL_MAIN_PAGELIGHTCFG2,
.normal_img_id = IMAGE_RES_IMG_TPL_MAIN_PAGELIGHTCFG1,
.is_pressed = 0,
},
},
};
#endif // WUI_PAGE_MAIN_H
@@ -0,0 +1,16 @@
#include "wui_user/wui_page_none.h"
static void none_on_key(uint32_t key)
{
wui_page_switch(WUI_START_PAGE);
}
void wui_page_none_init()
{
wui_page_init(widgets_none, sizeof(widgets_none) / sizeof(widgets_none[0]));
wui_register_key_handler(none_on_key);
}
void wui_page_none_loop()
{
}
@@ -0,0 +1,27 @@
#ifndef WUI_PAGE_NONE_H
#define WUI_PAGE_NONE_H
#include "wui.h"
#include "wui_user/wui_page.h"
#include "wui_widget.h"
typedef enum
{
WIDGET_NONE_BG = 0,
} none_widget_id_t;
static const wui_widget_desc_t widgets_none[] = {
[WIDGET_NONE_BG] = {
.widget_id = WIDGET_NONE_BG,
.type = Wui_w_Rect,
.x = 0,
.y = 0,
.w = LCD_WIDTH,
.h = LCD_HEIGHT,
.props.rect = {
.color = LCD_black,
},
},
};
#endif // WUI_PAGE_NONE_H
+450
View File
@@ -0,0 +1,450 @@
{
"version": "1.0",
"hasAllParsed": true,
"isNormalMRSProject": true,
"basic": {
"chipInfo": {
"vendor": "WCH",
"toolchain": "RISC-V",
"series": "CH32V203",
"rtos": "NoneOS",
"mcu": "CH32V203RBT",
"description": "ROM(byte): 64K, SRAM(byte): 20K, CHIP PINS: 32, GPIO PORTS: 27.\\nWCH CH32V2 series of mainstream MCUs covers the needs of a large variety of applications in the industrial,medical and consumer markets. High performance with first-class peripherals and low-power,low-voltage operation is paired with a high level of integration at accessible prices with a simple architecture and easy-to-use tools.",
"tempratureScope": "",
"artifactType": "executable",
"link": "WCH-Link",
"peripheral_version": "1.0",
"calibrateSupport": false,
"calibrateCommand": "",
"UIConfigSupport": false,
"UIConfigCommand": "",
"externalFlashSupport": false
},
"linkedFolders": [
{
"name": "Core",
"location": "../../SRC/Core"
},
{
"name": "Debug",
"location": "../../SRC/Debug"
},
{
"name": "Ld",
"location": "../../SRC/Ld"
},
{
"name": "Peripheral",
"location": "../../SRC/Peripheral"
},
{
"name": "Startup",
"location": "../../SRC/Startup"
}
],
"removedResources": [
{
"parentLogicPath": "",
"type": "file",
"name": "*.wvproj"
}
],
"projectName": "WS2812_LED",
"architecture": "RISC-V",
"projectType": "c"
},
"buildConfig": {
"configurations": [
{
"buildArtifact": {
"artifact_name": "${ProjName}",
"artifact_extension": "elf",
"output_prefix": "",
"artifact_type": "Executable"
},
"parallelizationNumber": "optimal",
"stop_on_first_build_error": true,
"pre_script": "",
"pre_script_description": "",
"post_script": "",
"post_script_description": "",
"excludeResources": [
"${project}/Startup/startup_ch32v20x_D8W.S",
"${project}/Startup/startup_ch32v20x_D8.S"
],
"optimization": {
"level": "size",
"message_length": true,
"char_is_signed": true,
"function_sections": true,
"data_sections": true,
"no_common_unitialized": true,
"do_not_inline_functions": false,
"assume_freestanding_environment": false,
"disable_builtin": false,
"single_precision_constants": false,
"position_independent_code": false,
"link_time_optimizer": false,
"disable_loop_invariant_move": false,
"optimize_unused_sections_declared_as_high_code": false,
"code_generation_without_hardware_floating": false,
"use_pipelines": false,
"show_caret_indicating_the_column": false,
"calling_convention_variant": false,
"other_optimization_flags": ""
},
"warnings": {
"check_syntax_only": false,
"pedantic": false,
"pedantic_warnings_as_errors": false,
"inhibit_all_warnings": false,
"warn_on_various_unused_elements": true,
"warn_on_uninitialized_variables": true,
"enable_all_common_warnings": false,
"enable_extra_warnings": false,
"warn_on_undeclared_global_function": false,
"warn_on_implicit_conversions": false,
"warn_if_pointer_arthmetic": false,
"warn_if_padding_is_included": false,
"warn_if_shadowed_variable": false,
"warn_if_suspicious_logical_ops": false,
"warn_if_struct_is_returned": false,
"warn_if_floats_are_compared_as_equal": false,
"generate_errors_instead_of_warnings": false,
"other_warning_flags": ""
},
"debugging": {
"debug_level": "default",
"debug_format": "default",
"generate_prof_information": false,
"generate_gprof_information": false,
"other_debugging_flags": ""
},
"assembler": {
"preprocessor": {
"use_preprocessor": true,
"do_not_search_system_directories": false,
"preprocess_only": false,
"defined_symbols": [],
"undefined_symbols": []
},
"includes": {
"include_paths": [
"${project}/Startup"
],
"include_system_paths": [],
"include_files": []
},
"other_warning_flags": "",
"miscellaneous": {
"assembler_flags": [],
"generate_assembler_listing": false,
"save_temporary_files": false,
"verbose": false,
"other_assembler_flags": ""
}
},
"ccompiler": {
"preprocessor": {
"do_not_search_system_directories": false,
"preprocess_only": false,
"defined_symbols": [],
"undefined_symbols": []
},
"includes": {
"include_paths": [
"${project}/Debug",
"${project}/Core",
"${project}/User",
"${project}/Peripheral/inc",
"${project}/User/Drivers",
"${project}/User/wui",
"${project}/User/wui_port",
"${project}/User/wui_user"
],
"include_system_paths": [],
"include_files": []
},
"optimization": {
"language_standard": "gnu99",
"other_optimization_flags": ""
},
"warnings": {
"warn_if_a_global_function_has_no_prototype": false,
"warn_if_a_function_has_no_arg_type": false,
"warn_if_wrong_cast": false,
"other_warning_flags": ""
},
"miscellaneous": {
"generate_assembler_listing": false,
"save_temporary_files": false,
"verbose": false,
"other_compiler_flags": ""
}
},
"cppcompiler": {
"preprocessor": {
"do_not_search_system_directories": false,
"do_not_search_system_cpp_directories": false,
"preprocess_only": false,
"defined_symbols": [],
"undefined_symbols": []
},
"includes": {
"include_paths": [],
"include_system_paths": [],
"include_files": []
},
"optimization": {
"cpp_language_standard": "gnucpp11",
"abi_version": "0",
"do_not_use_exceptions": false,
"do_not_use_rtti": false,
"do_not_use__cxa_atexit": false,
"do_not_use_thread_safe_statics": false,
"other_optimization_flags": ""
},
"warnings": {
"warn_on_abi_violations": false,
"warn_on_class_privacy": false,
"warn_on_no_except_expressions": false,
"warn_on_virtual_destructors": false,
"warn_on_uncast_null": false,
"warn_on_sign_promotion": false,
"warn_about_effictive_cpp_violcations": false,
"other_warning_flags": ""
},
"miscellaneous": {
"generate_assembler_listing": false,
"save_temporary_files": false,
"verbose": false,
"other_compiler_flags": ""
}
},
"clinker": {
"general": {
"scriptFiles": [
"${project}/Ld/Link.ld"
],
"do_not_use_standard_start_files": true,
"do_not_use_default_libraries": false,
"no_startup_or_default_libs": false,
"remove_unused_sections": true,
"print_removed_sections": false,
"omit_all_symbol_information": false
},
"libraries": {
"libraries": [],
"library_search_path": []
},
"miscellaneous": {
"picolibc": "disabled",
"linker_flags": [],
"other_objects": [
"${project}/User/wui/libwui_0.2.a"
],
"generate_map": "\"${BuildArtifactFileBaseName}.map\"",
"cross_reference": false,
"print_link_map": false,
"use_newlib_nano": true,
"use_float_with_nano_printf": false,
"use_float_with_nano_scanf": false,
"do_not_use_syscalls": true,
"verbose": false,
"use_wch_printffloat": false,
"use_wch_printf": false,
"use_iqmath": false,
"other_linker_flags": ""
}
},
"cpplinker": {
"general": {
"scriptFiles": [
"${project}/Ld/Link.ld"
],
"do_not_use_standard_start_files": true,
"do_not_use_default_libraries": false,
"no_startup_or_default_libs": false,
"remove_unused_sections": true,
"print_removed_sections": false,
"omit_all_symbol_information": false
},
"libraries": {
"libraries": [],
"library_search_path": []
},
"miscellaneous": {
"picolibc": "disabled",
"linker_flags": [],
"other_objects": [
"${project}/User/wui/libwui_0.2.a"
],
"generate_map": "\"${BuildArtifactFileBaseName}.map\"",
"cross_reference": false,
"print_link_map": false,
"use_newlib_nano": true,
"use_float_with_nano_printf": false,
"use_float_with_nano_scanf": false,
"do_not_use_syscalls": true,
"verbose": false,
"use_wch_printffloat": false,
"use_wch_printf": false,
"use_iqmath": false,
"other_linker_flags": ""
}
},
"archiver": {
"archiver_flags": "-r",
"libOutputPrefix": "lib"
},
"createFlash": {
"enabled": true,
"outputFileFormat": "ihex",
"copy_only_section_text": false,
"copy_only_section_data": false,
"copy_only_sections": [],
"create_algorithm_file": false,
"other_flags": ""
},
"createList": {
"enabled": true,
"display_source": false,
"display_all_headers": true,
"demangle_names": true,
"display_debug_info": false,
"disassemble": true,
"display_file_headers": false,
"display_line_numbers": false,
"display_relocation_info": false,
"display_symbols": false,
"wide_lines": false,
"other_flags": ""
},
"printSize": {
"enabled": true,
"size_format": "berkeley",
"hex": false,
"show_totals": false,
"other_flags": ""
},
"configVariables": [],
"riscvTargetProcessor": {
"architecture": "rv32i",
"multiply_extension": true,
"atomic_extension": true,
"floating_point": "none",
"compressed_extension": true,
"extra_compressed_extension": true,
"bit_extension": false,
"multiplication_subset_of_the_M_extension": false,
"vector_cryptography_extensions": "",
"integer_ABI": "ilp32",
"floating_point_ABI": "none",
"tuning": "default",
"code_model": "default",
"small_data_limit": 8,
"align": "default",
"save_restore": true,
"other_target_flags": ""
},
"component_toolchain": "${WCH:Toolchain:GCC8}",
"name": "obj"
}
]
},
"flashConfig": {
"mcutype": "CH32V20x",
"address": "0x08000000",
"target_path": "obj\\WS2812_LED.hex",
"clkSpeed": "High",
"debug_interface_mode": "1-wire serial",
"erase": true,
"program": true,
"verify": true,
"reset": true,
"sdiPrintf": false,
"disablepowerout": false,
"clearcodeflash": false,
"disablecodeprotect": false,
"flashType": "",
"asmFile_path": "",
"exepath": "",
"exearguments": ""
},
"debugConfigurations": {
"openOCDCfg": {
"useLocalOpenOCD": true,
"executable": "${WCH:OpenOCD:default}",
"gdbport": 3333,
"telnetport": 4444,
"tclport": 6666,
"configOptions": [
"-f \"${WCH:OpenOCD:default}/bin/wch-riscv.cfg\""
],
"host": "127.0.0.1",
"port": 3333,
"skipDownloadBeforeDebug": false,
"enablePageEraser": false,
"enableNoZeroWaitingAreaFlash": false
},
"gdbCfg": {
"executable": "${WCH:Toolchain:GCC8}",
"options": [],
"commands": [
"set mem inaccessible-by-default off",
"set architecture riscv:rv32",
"set remotetimeout unlimited",
"set disassembler-options xw"
]
},
"startup": {
"initCommands": {
"initReset": true,
"initResetType": "init",
"additionalCommands": [],
"armSemihosting": false,
"armSemihosting_old": false
},
"loadedFiles": {
"loadSymbols": true,
"useProjBinaryForSymbols": true,
"useFileForSymbols": false,
"symbolFile": "",
"symbolFileOffset": "",
"loadImage": true,
"useProjBinaryForImage": true,
"useFileForImage": false,
"executableFile": "",
"executableFileOffset": ""
},
"runCommands": {
"runReset": true,
"runResetType": "halt",
"additionalCommands": [],
"setBreakAt": "handle_reset",
"continue": true,
"setBreak": true,
"setProgramCounter": false,
"setProgramCounterAddress": ""
},
"debugInRAM": false
},
"svdpath": "${WCH:SDK:default}/RISC-V/CH32V203/NoneOS/CH32V203xx.svd",
"output": {
"showDebugGDBTrace": true,
"saveDebugOutputToFile": false,
"showDebugOutputTimestamps": true
},
"reserve": {
"PROGRAM_NAME": "obj/WS2812_LED.elf",
"PROJECT_ATTR": "WS2812_LED",
"PROJECT_BUILD_CONFIG_AUTO_ATTR": true,
"PROJECT_BUILD_CONFIG_ID_ATTR": "",
"ATTR_BUILD_BEFORE_LAUNCH_ATTR": 2,
"GdbServerAllocateConsole": true,
"GdbServerAllocateTelnetConsole": false,
"StartGdbCLient": true,
"UPDATE_THREADLIST_ON_SUSPEND": false
}
}
}