first submission

This commit is contained in:
qiyongshuang
2023-02-01 14:19:13 +08:00
parent d534aad004
commit b79c6ac80d
3711 changed files with 745432 additions and 2 deletions
+247
View File
@@ -0,0 +1,247 @@
<?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.1008047074">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.1008047074" moduleId="org.eclipse.cdt.core.settings" name="obj">
<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 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.1008047074" name="obj" parent="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release">
<folderInfo id="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.1008047074." name="/" resourcePath="">
<toolChain id="ilg.gnumcueclipse.managedbuild.cross.riscv.toolchain.elf.release.231146001" name="RISC-V Cross GCC" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.toolchain.elf.release">
<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"/>
<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.debugging.level.1204865254" name="Debug level" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.level" useByScannerDiscovery="true"/>
<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"/>
<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.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.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.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.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.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.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="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.xw.1607187870" 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.saverestore.2008269042" 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.optimization.nocommon.243344651" name="No common unitialized (-fno-common)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.nocommon" useByScannerDiscovery="true" 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:/GPIO_Toggle}/obj" id="ilg.gnumcueclipse.managedbuild.cross.riscv.builder.1421508906" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" 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 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>
<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 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}/Mail/inc}&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}/NetLib}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/Ld}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/Debug}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/Core}&quot;"/>
</option>
<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 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">
<listOptionValue builtIn="false" value="CH32V20x_D8W"/>
</option>
<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"/>
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.linker.1620074387" name="GNU RISC-V Cross C Linker" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.linker">
<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 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}/NetLib}&quot;"/>
</option>
<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.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 IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="true" 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"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="true" 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.libs.950322766" name="Libraries (-l)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.libs" useByScannerDiscovery="false" valueType="libs">
<listOptionValue builtIn="false" value="wchnet"/>
</option>
<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" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.linker">
<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" value="true" valueType="boolean"/>
<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" valueType="libPaths">
<listOptionValue builtIn="false" value="&quot;../LD&quot;"/>
</option>
<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" valueType="stringList">
<listOptionValue builtIn="false" value="Link.ld"/>
</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" value="true" 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" value="true" valueType="boolean"/>
</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"/>
<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"/>
<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.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.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.disassemble.1859590835" name="Disassemble (--disassemble|-d)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.disassemble" useByScannerDiscovery="false" value="true" valueType="boolean"/>
</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"/>
</tool>
</toolChain>
</folderInfo>
<fileInfo id="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.1008047074.529083857" name="ch32v20x_usb_host.h" rcbsApplicability="disable" resourcePath="Peripheral/inc/ch32v20x_usb_host.h" toolsToInvoke=""/>
<fileInfo id="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.1008047074.1630706625" name="ch32v20x_usb.h" rcbsApplicability="disable" resourcePath="Peripheral/inc/ch32v20x_usb.h" toolsToInvoke=""/>
<folderInfo id="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.1008047074.334436054" name="/" resourcePath="LiteOS/components/exchook">
<toolChain id="ilg.gnumcueclipse.managedbuild.cross.riscv.toolchain.elf.release.2062228612" name="RISC-V Cross GCC" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.toolchain.elf.release" unusedChildren="">
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createflash.1311852988.1812227985" name="Create flash image" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createflash.1311852988"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createlisting.1983282875.794002289" name="Create extended listing" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createlisting.1983282875"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.printsize.1000761142.1161644685" name="Print size" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.printsize.1000761142"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.level.514997414.1791600899" name="Optimization Level" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.level.514997414"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.messagelength.1008570639.177015924" name="Message length (-fmessage-length=0)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.messagelength.1008570639"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.signedchar.467272439.1926983693" name="'char' is signed (-fsigned-char)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.signedchar.467272439"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.functionsections.2047756949.529750294" name="Function sections (-ffunction-sections)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.functionsections.2047756949"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.datasections.207613650.1387199788" name="Data sections (-fdata-sections)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.datasections.207613650"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.level.1204865254.984447253" name="Debug level" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.level.1204865254"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.format.867779652.27813518" name="Debug format" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.format.867779652"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.base.1900297968.1000577842" name="Architecture" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.base.1900297968"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.abi.integer.387605487.347710818" name="Integer ABI" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.abi.integer.387605487"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.multiply.1509705449.1311033037" name="Multiply extension (RVM)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.multiply.1509705449"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.compressed.1038505275.1602374020" name="Compressed extension (RVC)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.compressed.1038505275"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.toolchain.name.1218760634.876429077" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.toolchain.name.1218760634"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.prefix.103341323.517962339" name="Prefix" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.prefix.103341323"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.c.487601824.398117832" name="C compiler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.c.487601824"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.cpp.1062130429.825649012" name="C++ compiler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.cpp.1062130429"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.ar.1194282993.2043525793" name="Archiver" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.ar.1194282993"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.objcopy.1529355265.1924824097" name="Hex/Bin converter" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.objcopy.1529355265"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.objdump.1053750745.994326153" name="Listing generator" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.objdump.1053750745"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.size.1441326233.1524712786" name="Size command" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.size.1441326233"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.make.550105535.1877290161" name="Build command" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.make.550105535"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.rm.719280496.768716183" name="Remove command" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.rm.719280496"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.toolchain.id.226017994.1606796257" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.toolchain.id.226017994"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.atomic.1590833110.1143920462" name="Atomic extension (RVA)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.atomic.1590833110"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.unused.1961191588.1603069542" name="Warn on various unused elements (-Wunused)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.unused.1961191588"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.uninitialized.929829166.361141595" name="Warn on uninitialized variables (-Wuninitialised)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.uninitialized.929829166"/>
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="ilg.gnumcueclipse.managedbuild.cross.riscv.targetPlatform" isAbstract="false" osList="all" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.targetPlatform"/>
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.8171434" name="GNU RISC-V Cross Assembler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.1244756189">
<inputType id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.input.1310499878" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.input"/>
</tool>
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.1791728488" name="GNU RISC-V Cross C Compiler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.1731377187">
<inputType id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.input.1173456351" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.input"/>
</tool>
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.compiler.108442955" name="GNU RISC-V Cross C++ Compiler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.compiler.1610882921"/>
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.linker.976972193" name="GNU RISC-V Cross C Linker" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.linker.1620074387"/>
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.linker.1510729979" name="GNU RISC-V Cross C++ Linker" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.linker.1947503520"/>
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.archiver.312242404" name="GNU RISC-V Cross Archiver" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.archiver.1292785366"/>
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.createflash.1021522021" name="GNU RISC-V Cross Create Flash Image" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.createflash.1801165667"/>
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.createlisting.1317783986" name="GNU RISC-V Cross Create Listing" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.createlisting.1356766765"/>
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.printsize.1634774322" name="GNU RISC-V Cross Print Size" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.printsize.712424314"/>
</toolChain>
</folderInfo>
<folderInfo id="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.1008047074.1333323521" name="/" resourcePath="LiteOS/third_party/cmsis">
<toolChain id="ilg.gnumcueclipse.managedbuild.cross.riscv.toolchain.elf.release.100688438" name="RISC-V Cross GCC" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.toolchain.elf.release" unusedChildren="">
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createflash.1311852988.204242395" name="Create flash image" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createflash.1311852988"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createlisting.1983282875.1613118878" name="Create extended listing" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createlisting.1983282875"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.printsize.1000761142.2015860899" name="Print size" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.printsize.1000761142"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.level.514997414.1636977454" name="Optimization Level" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.level.514997414"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.messagelength.1008570639.784696137" name="Message length (-fmessage-length=0)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.messagelength.1008570639"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.signedchar.467272439.914301612" name="'char' is signed (-fsigned-char)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.signedchar.467272439"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.functionsections.2047756949.1939113075" name="Function sections (-ffunction-sections)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.functionsections.2047756949"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.datasections.207613650.2068430746" name="Data sections (-fdata-sections)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.datasections.207613650"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.level.1204865254.1627966088" name="Debug level" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.level.1204865254"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.format.867779652.891307898" name="Debug format" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.format.867779652"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.base.1900297968.1492675969" name="Architecture" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.base.1900297968"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.abi.integer.387605487.460427754" name="Integer ABI" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.abi.integer.387605487"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.multiply.1509705449.101332093" name="Multiply extension (RVM)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.multiply.1509705449"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.compressed.1038505275.97006159" name="Compressed extension (RVC)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.compressed.1038505275"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.toolchain.name.1218760634.1684566918" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.toolchain.name.1218760634"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.prefix.103341323.1342041958" name="Prefix" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.prefix.103341323"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.c.487601824.1841552693" name="C compiler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.c.487601824"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.cpp.1062130429.1801436350" name="C++ compiler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.cpp.1062130429"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.ar.1194282993.643893858" name="Archiver" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.ar.1194282993"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.objcopy.1529355265.1997967325" name="Hex/Bin converter" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.objcopy.1529355265"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.objdump.1053750745.1939554715" name="Listing generator" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.objdump.1053750745"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.size.1441326233.1342857864" name="Size command" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.size.1441326233"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.make.550105535.288958149" name="Build command" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.make.550105535"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.rm.719280496.359746984" name="Remove command" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.rm.719280496"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.toolchain.id.226017994.1870097564" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.toolchain.id.226017994"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.atomic.1590833110.705902982" name="Atomic extension (RVA)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.atomic.1590833110"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.unused.1961191588.827934939" name="Warn on various unused elements (-Wunused)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.unused.1961191588"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.uninitialized.929829166.1837883347" name="Warn on uninitialized variables (-Wuninitialised)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.uninitialized.929829166"/>
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="ilg.gnumcueclipse.managedbuild.cross.riscv.targetPlatform" isAbstract="false" osList="all" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.targetPlatform"/>
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.440232423" name="GNU RISC-V Cross Assembler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.1244756189">
<inputType id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.input.1113434951" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.input"/>
</tool>
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.615957970" name="GNU RISC-V Cross C Compiler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.1731377187">
<inputType id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.input.784424371" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.input"/>
</tool>
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.compiler.1796908532" name="GNU RISC-V Cross C++ Compiler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.compiler.1610882921"/>
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.linker.2119140349" name="GNU RISC-V Cross C Linker" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.linker.1620074387"/>
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.linker.957422234" name="GNU RISC-V Cross C++ Linker" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.linker.1947503520"/>
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.archiver.940539115" name="GNU RISC-V Cross Archiver" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.archiver.1292785366"/>
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.createflash.1092495852" name="GNU RISC-V Cross Create Flash Image" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.createflash.1801165667"/>
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.createlisting.1656640092" name="GNU RISC-V Cross Create Listing" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.createlisting.1356766765"/>
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.printsize.110026313" name="GNU RISC-V Cross Print Size" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.printsize.712424314"/>
</toolChain>
</folderInfo>
<sourceEntries>
<entry excluding="NetLib|Startup|Core|Startup/startup_ch32v20x.S|LiteOS/components/cppsupport|User/task_sample.c|LiteOS/kal|Peripheral|LiteOS/third_party/cmsis/CMSIS/Core|LiteOS/components/exchook|LiteOS/third_party/cmsis|User/task_sample.h|LiteOS/components/net|Debug|LiteOS/testsuits|LiteOS/components/fs" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Core"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Debug"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="NetLib"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Peripheral"/>
<entry excluding="startup_ch32v20x_D8.S|startup_ch32v20x_D6.S" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Startup"/>
</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"/>
<storageModule moduleId="refreshScope"/>
</cproject>
+61
View File
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<projectDescription>
<name>Mail</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>
<filteredResources>
<filter>
<id>1595986042669</id>
<name/>
<type>22</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-name-matches-false-false-*.wvproj</arguments>
</matcher>
</filter>
</filteredResources>
<linkedResources>
<link>
<name>Startup</name>
<type>2</type>
<location>PARENT-2-PROJECT_LOC/SRC/Startup</location>
</link>
<link>
<name>Peripheral</name>
<type>2</type>
<location>PARENT-2-PROJECT_LOC/SRC/Peripheral</location>
</link>
<link>
<name>Debug</name>
<type>2</type>
<location>PARENT-2-PROJECT_LOC/SRC/Debug</location>
</link>
<link>
<name>Core</name>
<type>2</type>
<location>PARENT-2-PROJECT_LOC/SRC/Core</location>
</link>
<link>
<name>NetLib</name>
<type>2</type>
<location>PARENT-1-PROJECT_LOC/NetLib</location>
</link>
</linkedResources>
</projectDescription>
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project>
<configuration id="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.1008047074" name="obj">
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1890730752159159725" id="ilg.gnumcueclipse.managedbuild.cross.riscv.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT RISC-V Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
</extension>
</configuration>
</project>
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding//User/main.c=UTF-8
+16
View File
@@ -0,0 +1,16 @@
Mcu Type=CH32V20x
Address=0x08000000
Erase All=true
Program=true
Verify=true
Reset=true
Vendor=WCH
Link=WCH-Link
Toolchain=RISC-V
Series=CH32V203
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.
PeripheralVersion=1.0
MCU=CH32V203RBT6
Target Path=obj/Mail.hex
+1
View File
@@ -0,0 +1 @@
ENTRY( _start )␍␍__stack_size = 2048;␍␍PROVIDE( _stack_size = __stack_size );␍␍␍MEMORY␍{␍/* CH32V20x_D6 - CH32V203F6-CH32V203G6-CH32V203K6-CH32V203C6 */␍/*␍ FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 32K␍ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 10K␍*/ ␍␍/* CH32V20x_D6 - CH32V203K8-CH32V203C8-CH32V203G8-CH32V203F8 */␍␍/* FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 64K␍ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K␍*/ ␍ ␍/* CH32V20x_D8 - CH32V203RB␍ CH32V20x_D8W - CH32V208x␍ FLASH + RAM supports the following configuration␍ FLASH-128K + RAM-64K␍ FLASH-144K + RAM-48K␍ FLASH-160K + RAM-32K␍*/␍ FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 128K␍ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K␍␍}␍␍␍SECTIONS␍{␍␍ .init :␍ {␍ _sinit = .;␍ . = ALIGN(4);␍ KEEP(*(SORT_NONE(.init)))␍ . = ALIGN(4);␍ _einit = .;␍ } >FLASH AT>FLASH␍␍ .vector :␍ {␍ *(.vector);␍ . = ALIGN(64);␍ } >FLASH AT>FLASH␍␍ .text :␍ {␍ . = ALIGN(4);␍ *(.text)␍ *(.text.*)␍ *(.rodata)␍ *(.rodata*)␍ *(.gnu.linkonce.t.*)␍ . = ALIGN(4);␍ } >FLASH AT>FLASH ␍␍ .fini :␍ {␍ KEEP(*(SORT_NONE(.fini)))␍ . = ALIGN(4);␍ } >FLASH AT>FLASH␍␍ PROVIDE( _etext = . );␍ PROVIDE( _eitcm = . ); ␍␍ .preinit_array :␍ {␍ PROVIDE_HIDDEN (__preinit_array_start = .);␍ KEEP (*(.preinit_array))␍ PROVIDE_HIDDEN (__preinit_array_end = .);␍ } >FLASH AT>FLASH ␍ ␍ .init_array :␍ {␍ PROVIDE_HIDDEN (__init_array_start = .);␍ KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))␍ KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))␍ PROVIDE_HIDDEN (__init_array_end = .);␍ } >FLASH AT>FLASH ␍ ␍ .fini_array :␍ {␍ PROVIDE_HIDDEN (__fini_array_start = .);␍ KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))␍ KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))␍ PROVIDE_HIDDEN (__fini_array_end = .);␍ } >FLASH AT>FLASH ␍ ␍ .ctors :␍ {␍ /* gcc uses crtbegin.o to find the start of␍ the constructors, so we make sure it is␍ first. Because this is a wildcard, it␍ doesn't matter if the user does not␍ actually link against crtbegin.o; the␍ linker won't look for a file to match a␍ wildcard. The wildcard also means that it␍ doesn't matter which directory crtbegin.o␍ is in. */␍ KEEP (*crtbegin.o(.ctors))␍ KEEP (*crtbegin?.o(.ctors))␍ /* We don't want to include the .ctor section from␍ the crtend.o file until after the sorted ctors.␍ The .ctor section from the crtend file contains the␍ end of ctors marker and it must be last */␍ KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))␍ KEEP (*(SORT(.ctors.*)))␍ KEEP (*(.ctors))␍ } >FLASH AT>FLASH ␍ ␍ .dtors :␍ {␍ KEEP (*crtbegin.o(.dtors))␍ KEEP (*crtbegin?.o(.dtors))␍ KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))␍ KEEP (*(SORT(.dtors.*)))␍ KEEP (*(.dtors))␍ } >FLASH AT>FLASH ␍␍ .dalign :␍ {␍ . = ALIGN(4);␍ PROVIDE(_data_vma = .);␍ } >RAM AT>FLASH ␍␍ .dlalign :␍ {␍ . = ALIGN(4); ␍ PROVIDE(_data_lma = .);␍ } >FLASH AT>FLASH␍␍ .data :␍ {␍ *(.gnu.linkonce.r.*)␍ *(.data .data.*)␍ *(.gnu.linkonce.d.*)␍ . = ALIGN(8);␍ PROVIDE( __global_pointer$ = . + 0x800 );␍ *(.sdata .sdata.*)␍ *(.sdata2.*)␍ *(.gnu.linkonce.s.*)␍ . = ALIGN(8);␍ *(.srodata.cst16)␍ *(.srodata.cst8)␍ *(.srodata.cst4)␍ *(.srodata.cst2)␍ *(.srodata .srodata.*)␍ . = ALIGN(4);␍ PROVIDE( _edata = .);␍ } >RAM AT>FLASH␍␍ .bss :␍ {␍ . = ALIGN(4);␍ PROVIDE( _sbss = .);␍ *(.sbss*)␍ *(.gnu.linkonce.sb.*)␍ *(.bss*)␍ *(.gnu.linkonce.b.*) ␍ *(COMMON*)␍ . = ALIGN(4);␍ PROVIDE( _ebss = .);␍ } >RAM AT>FLASH␍␍ PROVIDE( _end = _ebss);␍ PROVIDE( end = . );␍␍ .stack ORIGIN(RAM) + LENGTH(RAM) - __stack_size :␍ {␍ PROVIDE( _heap_end = . );␍ . = ALIGN(4);␍ PROVIDE(_susrstack = . );␍ . = . + __stack_size;␍ PROVIDE( _eusrstack = .);␍ } >RAM ␍␍}␍␍␍␍
+2
View File
@@ -0,0 +1,2 @@
�i“CZ ?"Ç�¸rŸ�F<Fy8E9Y‡½„%Pa³D¶La† %Ã'y€¡]Ç;’¶ŸS)1†1+R4><‚.„ÇÅ¿º°?/£XO©Ä¿ChQN$*¢”»EÅBk‹!2tŒ+buh†nUb]xl‹l|
+"Ÿ<“¯AH42}z8p;m€u1Ž-¦eh»Od¼Âwµª7x{5�CqEx©=;¦¢e¢º»2£Š ‚«*BP Mš"
+278
View File
@@ -0,0 +1,278 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : mail.h
* Author : WCH
* Version : V1.0.0
* Date : 2022/01/18
* Description : Definition for mail.c.
*********************************************************************************
* 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 __MAIL_H__
#define __MAIL_H__
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "debug.h"
#include "wchnet.h"
#include "eth_driver.h"
#include "mailcmd.h"
/* ********************************************************************************************************************
* work mode:
*
* 1 Only send mail, log out after sending and close the socket connection;
* 2 Only receive mail, log out and close the socket connection after receiving
* [Get mail list];
* 3 Only receive email, log out after receiving [delete after reading emails]
* and close the socket connection;
* 4 Send email and receive email, start receiving email after sending, and
* log out after receiving them;
* 5 Send email and receive email, reply email after receiving them, exit
* SMTP after sending them, and exit POP after deleting email.
* Description: This code receives and sends two independent socket connections;
***********************************************************************************************************************/
#ifndef mail_work_mode
#define mail_work_mode 1
#endif
#if (mail_work_mode == 1)
#define send_mail 1 // send email
#define send_over_quit 1 // send completed and sign out
#elif (mail_work_mode == 2)
#define receive_mail 1 // receive email
#define receive_over_quit 1 // Exit after reading mail
#elif (mail_work_mode == 3)
#define receive_mail 1 // receive email
#define receive_dele_quit 1 // Delete and log out after reading the message
#elif (mail_work_mode == 4)
#define send_mail 1 // send email
#define send_over_receive 1 // send completed and reading mail
#define receive_mail 0 // receive email,according to the program flow, here should be set to 0
#define receive_over_quit 1 // Exit after reading mail
#elif (mail_work_mode == 5)
#define receive_mail 1 // receive email
#define receive_over_reply 1 // Reply to mails after reading them
#define send_mail 0 // send email,according to the program flow, here should be set to 0
#define send_over_quit 1 // send completed and sign out
#endif
//================================================================================
extern u8 OrderType; //Command type
extern u8 CheckType;
extern u8 ReceDatFlag; //received data flag
extern u16 ReceLen;
//=================================================================================
#define attach_max_len 512 //The maximum length of the attachment to send, the default is 512
#define POP3_SERVER_PORT 110 //The destination port for receiving mails
#define SMTP_SERVER_PORT 25 //SMTP port
#define DIALOG 0 //1 print debug information 0 close debug information
#define POP3_LOG_EN 1 //Output the obtained file on the serial port
typedef struct
{
u8 Socket;
u8 g_MIME; //Attachment flag
char m_strFile[48]; //attachment name
char m_strSendFrom[48]; //sender address
char m_strSendTo[48]; //receiver's address
char m_strSMTPServer[32]; //server name
char m_strUSERID[32]; //user name
char m_strPASSWD[32]; //password
char m_strSubject[32]; //subject
char m_strSenderName[32]; //sender name
}SMTP;
typedef struct
{
u8 Socket;
u8 EncodeType; //The encoding used by the mail
u8 AnalyMailDat; //Analyze the end-of-mail flag
u8 identitycheck; //Verify Attachment Content Flags
u8 RefreshTime; //No mail found, continue search flag
u8 DiscnntFlag;
u8 ReceFlag;
char sBufTime[40]; //Save the time of receiving emails
char Ccname[48]; //CC name
char DecodeRName[32]; //Save the sender's name after the received email is decoded
char pPop3Server[32]; //POP server
char pPop3UserName[32]; //POP login user name
char pPop3PassWd[32]; //POP login password
}POP;
/* SMTP send email related parameters */
extern const char *m_Server;
extern const char *m_UserName;
extern const char *m_PassWord;
extern const char *m_SendFrom;
extern const char *m_SendName;
extern const char *m_SendTo;
extern const char *m_Subject;
extern const char *m_FileName;
/* pop receive mail related*/
extern const char *p_Server;
extern const char *p_UserName;
extern const char *p_PassWord;
extern u8 MACAddr[6];
extern char AttachmentData[attach_max_len];
extern POP *p_pop3;
extern SMTP *p_smtp;
extern char MailBodyData[128];
extern const u8 SocketSMTPIP[4];
extern const u16 SmtpSourPrt;
extern const u8 SocketPOP3IP[4];
extern const u16 Pop3SourPrt;
/************************************************************************************************************************
* POP optional command
************************************************************************************************************************/
#ifdef receive_mail
#define POP_RTER 1 // 1 Process the full text of the server's mail
#define POP_DELE 1 // 2 Mark for deletion
// #define POP_RSET 1 // 3 Cancel all DELE commands
// #define POP_TOP 1 // 4 Returns the first m lines of mail number n
// #define POP_UIDL 1 // 5 Returns the specified mail, if not specified, returns all.
#define POP_REFRESH 1 // Email not received continue query sign
#endif
#define g_strBoundary "18ac0781-9ae4-4a2a-b5f7-5479635efb6b" //boundary
#define g_strEncode "base64" //Encoding
#define g_strcharset "gb2312" //windows format (linux format "utf-8")
#define g_xMailer "X-Mailer: X-WCH-Mail Client Sender\r\n" //X-Mailer Content
#define g_Encoding "Content-Transfer-Encoding: quoted-printable\r\nReply-To: " //Encoding content
#define g_Custom "X-Program: CSMTPMessageTester" //X-Program Content
#define g_FormatMail "This is a multi-part message in MIME format."
#define g_AttachHead "\r\nContent-Transfer-Encoding: quoted-printable\r\n"
#define g_AttachHedType "text/plain"
#define g_MailHedType "multipart/mixed"
#ifdef receive_over_reply
extern const char *g_mailbody;
extern const char *g_autograph1;
extern const char *g_autograph2;
extern char MacAddr[6];
extern char MacAddrC[18];
#endif
/************************************************************************************************************************
* command code
* 0x01-0x0f Command code for receiving mail
****************** 0x01-0x07 Common commands
****************** 0x09-0x0e optional command
****************** 0x01-0x02-0x03-0x06 confirm status
****************** 0x04-0x05 0x09-0x0e operating state
* 0x10-0x1f send mail command code
****************** 0x10-0x17 need to be executed in order
****************** The latter is optional
* 0x00 do nothing
************************************************************************************************************************/
#define COMMAND_UNUSEFULL 0x00
//POP RECEIVE CODE
#define POP_RECEIVE_USER 0x01 //Authenticated user
#define POP_RECEIVE_PASS 0x02 //Authenticated password
#define POP_RECEIVE_STAT 0x03 //Mailbox Statistics
#define POP_RECEIVE_LIST 0x04 //Returns the size of the specified message
#define POP_RECEIVE_RTER 0x05 //Read the entire text of an email
#define POP_RECEIVE_QUIT 0x06 //sign out
#define POP_CLOSE_SOCKET 0x07 //close pop socket
#define POP_RECEIVE_START 0x08 //Start receiving mail
#define POP_RECEIVE_DELE 0x09 //Mark for deletion
#define POP_RECEIVE_RSET 0x0a //Cancel all DELE commands
#define POP_RECEIVE_TOP 0x0b //Returns the content of the first m lines of mail number n
#define POP_RECEIVE_UIDL 0x0e //Returns the unique identifier for the specified message
#define POP_ERR_CHECK 0x0F //POP handshake error, log out and close socket
//SMTP SEND CODE
#define SMTP_SEND_HELO 0x10 //send hello command
#define SMTP_SEND_AUTH 0x11 //Send login command
#define SMTP_SEND_USER 0x12 //send user name
#define SMTP_SEND_PASS 0x13 //send password
#define SMTP_SEND_MAIL 0x14 //Send sender address
#define SMTP_SEND_RCPT 0x15 //Send receiver address
#define SMTP_SEND_DATA 0x16 //send DATA command
#define SMTP_DATA_OVER 0x17 //Send email content
#define SMTP_SEND_QUIT 0x18 //sign out
#define SMTP_CLOSE_SOCKET 0x19 //close SMTP socket
#define SMTP_SEND_START 0x1E //Start sending mail
#define SMTP_ERR_CHECK 0x1F //SMTP handshake error, log out and close socket
/* *********************************************************************************************************************
* �����źź˶Դ������
************************************************************************************************************************/
//POP ERR CHECK CODE
#define POP_ERR_CNNT 0x20 //pop connection error
#define POP_ERR_USER 0x21 //Authentication user name error
#define POP_ERR_PASS 0x22 //Login failed error
#define POP_ERR_STAT 0x23 //Getting email information error
#define POP_ERR_LIST 0x24 //Getting email list information error
#define POP_ERR_RETR 0x25 //Read the specified mail number information error
#define POP_ERR_DELE 0x26 //Deleting a message failed error
#define POP_ERR_QUIT 0x59 //Logout failed
#define POP_ERR_RSET 0x28 //recover deleted messages error
#define POP_ERR_TOP 0x2B //Failed to read the first m lines of an email
#define POP_ERR_UIDL 0x2C //Failed to get an email ID
#define POP_ERR_UNKW 0x2F //pop error unknown
//SMTP ERR CHECK CODE
#define SMTP_ERR_CNNT 0x31 //SMTP connection error
#define SMTP_ERR_HELO 0x32 //Failed to send HELO command
#define SMTP_ERR_AUTH 0x33 //Failed to request login command
#define SMTP_ERR_USER 0x34 //Sending user name not recognized
#define SMTP_ERR_PASS 0x35 //failed to login
#define SMTP_ERR_MAIL 0x36 //Sender address sending failed
#define SMTP_ERR_RCPT 0x37 //receiving address sending failed
#define SMTP_ERR_DATA 0x38 //request to send data
#define SMTP_ERR_DATA_END 0x39 //sending data error
#define SMTP_ERR_QUIT 0x3A //Logout failed
#define SMTP_ERR_UNKNOW 0x3F //SMTP unknown error
//
#define send_data_timeout 0x10 //send data timeout
#define send_data_success 0x14 //Send data successfully
#define CHECK_SUCCESS 0x00
#define UNCHECK 0x00
//POP CHECK CODE
// Check the response information, return "+OK" correctly, return "-ERR" if wrong.
#define POP_CHECK_CNNT 0x50
#define POP_CHECK_USER 0x51
#define POP_CHECK_PASS 0x52
#define POP_CHECK_STAT 0x53
#define POP_CHECK_LIST 0x54
#define POP_CHECK_RETR 0x55
#define POP_CHECK_DELE 0x56
#define POP_CHECK_SEAR 0x57
#define POP_CHECK_QUIT 0x58
#define POP_CHECK_RSET 0x59
#define POP_CHECK_APOP 0x5A
#define POP_CHECK_TOP 0x5B
#define POP_CHECK_UIDL 0x5C
//SMTP CHECK CODE
#define SMTP_CHECK_CNNT 0x60
#define SMTP_CHECK_HELO 0x61
#define SMTP_CHECK_AUTH 0x62
#define SMTP_CHECK_USER 0x63
#define SMTP_CHECK_PASS 0x64
#define SMTP_CHECK_MAIL 0x65
#define SMTP_CHECK_RCPT 0x66
#define SMTP_CHECK_DATA 0x67
#define SMTP_CHECK_DATA_END 0x68
#define SMTP_CHECK_QUIT 0x69
/******************************************************************************/
void WCHNET_SendData( char *PSend, u32 Len,u8 type,u8 index );
u8 WCHNET_CheckResponse( char *recv_buff,u8 check_type );
void WCHNET_CreateTcpPop3( void );
void WCHNET_CreateTcpSmtp( void );
void WCHNET_ReplyMailBody( void );
void WCHNET_MailQuery( void );
void mStopIfError(u8 iError);
void WCHNET_HandleGlobalInt( void );
//================================================================================
#endif
+90
View File
@@ -0,0 +1,90 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : mailcmd.h
* Author : WCH
* Version : V1.0.0
* Date : 2022/01/18
* Description : Definition for mailcmd.c.
*********************************************************************************
* 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 __MAILCMD__
#define __MAILCMD__
#include "mail.h"
extern char send_buff[];
extern char EncodeHostName[];
extern const char *g_autograph2;
extern char R_argv[3][32];
extern const char *g_autograph1;
void Base64Encode(char *src, u16 src_len, char *dst);
void Base64Decode(char *src, u16 src_len, char *dst);
void QuotedPrintableEncode( char *pSrc, char *pDst, u16 nSrcLen, u16 MaxLine );
void QuotedPrintableDecode( char *pSrc, char *pDst, u16 nSrcLen );
void WCHNET_XToChar( char *dat,char *p,char len);
void WCHNET_SMTPInit(void);
void WCHNET_SMTPIsMIME(void);
void WCHNET_SMTPAttachHeader( char *pFileName, char *pAttachHeader );
void WCHNET_SMTPAttachEnd( u16 *EndSize, char *pAttachEnd );
void WCHNET_SMTPMailHeader( void );
void WCHNET_SMTPSendAttachData( void );
void WCHNET_SMTPSendAttachHeader( void );
void WCHNET_SMTPEhlo( void );
void WCHNET_SMTPAuth( void );
void WCHNET_SMTPUser( void );
void WCHNET_SMTPPass( void );
void WCHNET_SMTPMail( void );
void WCHNET_SMTPRcpt( void );
void WCHNET_SMTPData( void );
void WCHNET_SMTPSendMail( void );
void WCHNET_POP3Init( void );
void WCHNET_POP3User( void );
void WCHNET_POP3Pass( void );
void WCHNET_POP3Stat( void );
void WCHNET_POP3List( void );
void WCHNET_POP3Retr( u8 num );
void WCHNET_POP3Dele( u8 num );
void WCHNET_POP3Rset( void );
void WCHNET_POP3Top( char num ,char m );
void WCHNET_POP3Uidl( char num );
void WCHNET_Quit( u8 index );
void WCHNET_MailCmd( u8 choiceorder );
#endif
+666
View File
@@ -0,0 +1,666 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : mail.c
* Author : WCH
* Version : V1.0
* Date : 2022/05/06
* Description : for sending and receiving mail.
*********************************************************************************
* 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 "mail.h"
POP *p_pop3;
SMTP *p_smtp;
/*********************************************************************
* @fn WCHNET_ReplyMailBody
*
* @brief Reply email body content.
*
* @return none
*/
#ifdef receive_over_reply
void WCHNET_ReplyMailBody( void )
{
u8 i;
memset( MailBodyData,'\0',sizeof(MailBodyData));
QuotedPrintableEncode( "hello" ,MailBodyData, strlen("hello"),76 );
strcat( send_buff, MailBodyData );
strcat( send_buff, "\r\n " );
strcat( send_buff, p_pop3->DecodeRName );
strcat( send_buff, "!" );
memset( MailBodyData,'\0',sizeof(MailBodyData));
QuotedPrintableEncode( (char *)g_mailbody ,MailBodyData, strlen(g_mailbody),76 );
strcat( send_buff, MailBodyData );
if(p_pop3->identitycheck == 1){
for(i=0;i<6;i++) MacAddr[i] = MACAddr[i];
WCHNET_XToChar(MacAddr,&MacAddrC[0],strlen(MacAddr));
#if DIALOG
printf("B len= %02X\n",(u16)strlen(MacAddrC));
#endif
if(strlen(MacAddrC)>17) MacAddrC[17] = '\0';
strcat( send_buff, "\r\n" );
memset( MailBodyData,'\0',sizeof(MailBodyData));
QuotedPrintableEncode( "I am ", MailBodyData, strlen("I am "),76 );
strcat( send_buff, MailBodyData );
memset( MailBodyData,'\0',sizeof(MailBodyData));
QuotedPrintableEncode( (char *)MacAddrC, MailBodyData, strlen(MacAddrC),76 );
strcat( send_buff, MailBodyData );
strcat( send_buff, "\r\n" );
}
strcat( send_buff, g_autograph1 );
strcat( send_buff, "From: \"" );
strcat( send_buff, p_pop3->DecodeRName );
strcat( send_buff, "\" <" );
strcat( send_buff, R_argv[0] );
strcat( send_buff, ">\r\n" );
strcat( send_buff, "To: ");
strcat( send_buff, p_smtp->m_strSendFrom );
strcat( send_buff, "\r\n" );
if(strlen(p_pop3->Ccname)){
strcat( send_buff, "Cc: ");
strcat( send_buff, p_pop3->Ccname);
strcat( send_buff, "\r\n" );
}
strcat( send_buff, "Sent: ");
strcat( send_buff, p_pop3->sBufTime );
strcat( send_buff, "\r\nSubject: ");
strcat( send_buff, p_smtp->m_strSubject );
strcat( send_buff, g_autograph2 );
}
#endif // receive_over_reply
/*********************************************************************
* @fn WCHNET_AnalyseMailData
*
* @brief Analyze incoming mails.
*
* @param recv_buff - data buff.
*
* @return none
*/
void WCHNET_AnalyseMailData( char *recv_buff )
{
u16 i=0,j=0;
if(p_pop3->ReceFlag){
i = 0;
if(p_pop3->EncodeType == 2) goto type2; //Jump to attachment receiving, encoding -- quoted-printable
if(p_pop3->EncodeType == 1) goto type1; //Jump to attachment receiving, encoding --- base64/
if(p_pop3->EncodeType == 0) goto type0; //Jump to attachment receiving, encoding -- others
}
for(i=0;i<ReceLen;i++){
/* sender name/address */
if( strncmp("\nFrom: ", &recv_buff[i], 7) == 0 ){
i += 7;
#if DIALOG
printf("1#From \n");
#endif
if(recv_buff[i] == '"') i++;
if(recv_buff[i] == '='){
while(strncmp("?B?", &recv_buff[i], 3)&&(i < ReceLen)) i++;
i += 3;
j = 0;
memset( send_buff, '\0', strlen(send_buff) );
/* sender name */
while((recv_buff[i] != '=')&&(recv_buff[i] != '?')&&(i < ReceLen)){
send_buff[j] = recv_buff[i];
j++;
i++;
}
memset( p_pop3->DecodeRName, '\0', sizeof(p_pop3->DecodeRName) );
Base64Decode(send_buff, strlen(send_buff),p_pop3->DecodeRName);
#if DIALOG
printf("DecName:%s\n", p_pop3->DecodeRName);
#endif
}
else{ //not encoded
j = 0;
while((recv_buff[i] != '"')&&(i < ReceLen)){ //sender name
p_pop3->DecodeRName[j] = recv_buff[i];
j++;
i++;
}
}
while((recv_buff[i] != '<')&&(i < ReceLen)) i++;
i++;
j = 0;
while((recv_buff[i] != '>')&&(i < ReceLen)){ //sender address
R_argv[0][j] = recv_buff[i];
j++;
i++;
}
}
if( strncmp("\nCc: ", &recv_buff[i], 5) == 0 ){
i += 5;
#if DIALOG
printf("2#Cc \n");
#endif
while(recv_buff[i] != '<') i++;
i++;
j = 0;
while(recv_buff[i] != '>'&&(i < ReceLen)){ //CC address
p_pop3->Ccname[j] = recv_buff[i];
j++;
i++;
}
}
if( strncmp("\nDate: ", &recv_buff[i], 7) == 0 ){
i += 7;
#if DIALOG
printf("3#date \n");
#endif
j = 0;
while((recv_buff[i] != '\r')&&(i < ReceLen)){ //date sent
p_pop3->sBufTime[j] = recv_buff[i];
j++;
i++;
}
}
if( strncmp("\nSubject: ", &recv_buff[i], 10) == 0 ){
i += 10;
#if DIALOG
printf("4#Subject \n");
#endif
if(recv_buff[i] == '[') {
while(recv_buff[i] == ']'&&(i < ReceLen)) i++;
i += 2;
}
if(recv_buff[i] == '='){
while(strncmp("?B?", &recv_buff[i], 3)&&(i < ReceLen)) i++;
i += 3;
j = 0;
memset( send_buff, '\0', strlen(send_buff) );
while((recv_buff[i] != '=')&&(recv_buff[i] != '?')&&(i < ReceLen)){
send_buff[j] = recv_buff[i];
j++;
i++;
}
Base64Decode(send_buff,strlen(send_buff),R_argv[1]);
#if DIALOG
printf("Decode subject:%s\n", R_argv[1]);
#endif
}
else{
j = 0;
while(recv_buff[i] != '\r'&&(i < ReceLen)){
R_argv[1][j] = recv_buff[i];
j++;
i++;
}
}
}
if( strncmp("name=", &recv_buff[i], 5) == 0 ){
#if DIALOG
printf("5#\n");
#endif
i += 5;
while(strncmp("Content-Transfer-Encoding: ", &recv_buff[i], 27)&&strncmp("filename=", &recv_buff[i], 9)&&(i < ReceLen)) i++;
if(strncmp("Content-Transfer-Encoding: ", &recv_buff[i], 27) == 0){
i += 27;
if(strncmp("base64", &recv_buff[i], 6) == 0 ){
#if DIALOG
printf("5#base64 \n");
#endif
i += 6;
p_pop3->EncodeType = 1;
}
else if(strncmp("quoted-printable", &recv_buff[i], 16) == 0 ) {
#if DIALOG
printf("5#quoted-printable \n");
#endif
i += 16;
p_pop3->EncodeType = 2;
}
else p_pop3->EncodeType = 0;
while(strncmp("filename=", &recv_buff[i], 9)) i++;
i += 9;
while(recv_buff[i] != '"'&&i<ReceLen) i++;
i++;
#if DIALOG
printf("6#filename \n");
#endif
if(recv_buff[i] == '='){
while(strncmp("?B?", &recv_buff[i], 3)&&(i < ReceLen)) i++;
i += 3;
j = 0;
memset(send_buff,'\0', strlen(send_buff) );
while((recv_buff[i] != '=')&&(recv_buff[i] != '?')&&(i < ReceLen)){
send_buff[j] = recv_buff[i];
j++;
i++;
}
Base64Decode(send_buff, strlen(send_buff),R_argv[2]);
}
else{
j = 0;
while(recv_buff[i] != '"'&&(i < ReceLen)){
R_argv[2][j] = recv_buff[i];
j++;
i++;
}
}
}
else if( strncmp("filename=", &recv_buff[i], 9) == 0 ){
#if DIALOG
printf("6#filename \n");
#endif
i += 9;
while(recv_buff[i] != '"'&&i<ReceLen) i++;
i++;
if(recv_buff[i] == '='){
while(strncmp("?B?", &recv_buff[i], 3)&&(i < ReceLen)) i++;
i += 3;
j = 0;
memset(send_buff,'\0', strlen(send_buff) );
while((recv_buff[i] != '=')&&(recv_buff[i] != '?')&&(i < ReceLen)){
send_buff[j] = recv_buff[i];
j++;
i++;
}
Base64Decode(send_buff, strlen(send_buff),R_argv[2]);
}
else{
j = 0;
while(recv_buff[i] != '"'&&(i < ReceLen)){
R_argv[2][j] = recv_buff[i];
j++;
i++;
}
}
while(strncmp("Content-Transfer-Encoding: ", &recv_buff[i], 27)) i++;
i += 27;
if(strncmp("base64", &recv_buff[i], 6) == 0 ){
#if DIALOG
printf("5#base64 \n");
#endif
i += 6;
p_pop3->EncodeType = 1;
}
else if(strncmp("quoted-printable", &recv_buff[i], 16) == 0 ) {
#if DIALOG
printf("5#quoted-printable \n");
#endif
i += 16;
p_pop3->EncodeType = 2;
}
else p_pop3->EncodeType = 0;
}
while( strncmp("\n\r\n", &recv_buff[i], 3) != 0 &&(i < ReceLen)) i++;
i += 3;
if(p_pop3->EncodeType==1){ /* base64 */
j = 0;
memset(send_buff,'\0', strlen(send_buff) );
type1: while((recv_buff[i] != '=')&&strncmp("\r\n--", &recv_buff[i], 4)&&strncmp("\r\n\r\n", &recv_buff[i], 4)&&(i < ReceLen)&&\
(j<attach_max_len)){
send_buff[j] = recv_buff[i];
j++;
i++;
}
if(i>=ReceLen-1) p_pop3->ReceFlag = 1;
else {
p_pop3->ReceFlag = 0;
Base64Decode(send_buff, strlen(send_buff),AttachmentData);
}
}
else if(p_pop3->EncodeType==2){ /* quoted-printable */
j = 0;
memset(send_buff,'\0', strlen(send_buff));
type2: while(strncmp("\r\n.\r\n", &recv_buff[i], 5)&&strncmp("\r\n--", &recv_buff[i], 4)&&(i < ReceLen)&&(j<attach_max_len)){
send_buff[j] = recv_buff[i];
j++;
i++;
}
if(i>=ReceLen-1) p_pop3->ReceFlag = 1;
else {
p_pop3->ReceFlag = 0;
QuotedPrintableDecode(send_buff,(char *)AttachmentData, strlen(send_buff));
}
}
else{ /* 7bit or others */
j = 0;
type0: while(recv_buff[i] != '\r'&&(i < ReceLen)&&(j<attach_max_len)){
AttachmentData[j] = recv_buff[i];
j++;
i++;
}
if(i>=ReceLen-1) p_pop3->ReceFlag = 1;
else p_pop3->ReceFlag = 0;
}
}
}
if(p_pop3->AnalyMailDat){
#if DIALOG
printf("addr:\n %s\n",R_argv[0]);
printf("send name:\n %s\n",p_pop3->DecodeRName);
printf("subject:\n %s\n",R_argv[1]);
printf("attach name:\n%s\n",R_argv[2]);
printf("send time:\n %s\n",p_pop3->sBufTime);
printf("attach text:\n%s\n",AttachmentData);
#endif
if(strncmp("wch", AttachmentData, 3) == 0) p_pop3->identitycheck = 1;
else p_pop3->identitycheck = 0;
#ifdef receive_over_reply
WCHNET_SMTPInit( );
#endif
}
}
/*********************************************************************
* @fn strFind
*
* @brief query for a specific string.
*
* @param str - source string.
* substr - String to be queried.
*
* @return The number of data segments contained in the received data
*/
int strFind( char str[], char substr[] )
{
int i, j, check ,count = 0;
int len = strlen( str );
int sublen = strlen( substr );
for( i = 0; i < len; i++ )
{
check = 1;
for( j = 0; j + i < len && j < sublen; j++ )
{
if( str[i + j] != substr[j] )
{
check = 0;
break;
}
}
if( check == 1 )
{
count++;
i = i + sublen;
}
}
return count;
}
/*********************************************************************
* @fn WCHNET_CheckResponse
*
* @brief Verify handshake signals.
*
* @param recv_buff - data buff.
* check_type - check type.
*
* @return state
*/
u8 WCHNET_CheckResponse( char *recv_buff,u8 checktype )
{
#ifdef receive_mail
int segCnt;
#endif
switch(checktype){
#ifdef send_mail
case SMTP_CHECK_CNNT: //
if( strncmp("220", recv_buff, 3) == 0 ){
OrderType = SMTP_SEND_HELO;
return (CHECK_SUCCESS);
}
return SMTP_ERR_CNNT;
case SMTP_CHECK_HELO: //
if( strncmp("250", recv_buff, 3) == 0 ){
OrderType = SMTP_SEND_AUTH;
return (CHECK_SUCCESS);
}
return SMTP_ERR_HELO;
case SMTP_CHECK_AUTH:
if(strncmp("250", recv_buff, 3) == 0){
OrderType = COMMAND_UNUSEFULL;
return (CHECK_SUCCESS);
}
if(strncmp("334", recv_buff, 3) == 0){
OrderType = SMTP_SEND_USER;
return (CHECK_SUCCESS);
}
return SMTP_ERR_AUTH;
case SMTP_CHECK_USER:
if(strncmp("334", recv_buff, 3) == 0){
OrderType = SMTP_SEND_PASS;
return (CHECK_SUCCESS);
}
return SMTP_ERR_USER;
case SMTP_CHECK_PASS:
if(strncmp("235", recv_buff, 3) == 0){
OrderType = SMTP_SEND_MAIL;
return (CHECK_SUCCESS);
}
return SMTP_ERR_PASS;
case SMTP_CHECK_MAIL:
if(strncmp("250", recv_buff, 3) == 0){
OrderType = SMTP_SEND_RCPT;
return (CHECK_SUCCESS);
}
return SMTP_ERR_MAIL;
case SMTP_CHECK_RCPT:
if(strncmp("250", recv_buff, 3) == 0){
OrderType = SMTP_SEND_DATA;
return (CHECK_SUCCESS);
}
return SMTP_ERR_RCPT;
case SMTP_CHECK_DATA:
if(strncmp("354", recv_buff, 3) == 0){
OrderType = SMTP_DATA_OVER;
return (CHECK_SUCCESS);
}
return SMTP_ERR_DATA;
case SMTP_CHECK_DATA_END:
if(strncmp("250", recv_buff, 3) == 0){
#ifdef send_over_receive
OrderType = POP_RECEIVE_START;
#endif
#ifdef send_over_quit
OrderType = SMTP_SEND_QUIT;
#endif
return (CHECK_SUCCESS);
}
return SMTP_ERR_DATA_END;
case SMTP_CHECK_QUIT:
if(strncmp("220", recv_buff, 3) == 0||strncmp("221", recv_buff, 3) == 0){
OrderType = SMTP_CLOSE_SOCKET;
return (CHECK_SUCCESS);
}
return SMTP_ERR_QUIT;
#endif // send_mail
#ifdef receive_mail
case POP_CHECK_CNNT:
if(strncmp("+OK", recv_buff, 3) == 0) {
OrderType = POP_RECEIVE_USER;
return (CHECK_SUCCESS);
}
return POP_ERR_CNNT;
case POP_CHECK_USER:
if(strncmp("+OK", recv_buff, 3) == 0) {
OrderType = POP_RECEIVE_PASS;
return (CHECK_SUCCESS);
}
return POP_ERR_USER;
case POP_CHECK_PASS:
if(strncmp("+OK", recv_buff, 3) == 0){
OrderType = POP_RECEIVE_STAT;
return (CHECK_SUCCESS);
}
return POP_ERR_PASS;
case POP_CHECK_STAT:
if(strncmp("+OK", recv_buff, 3) == 0){
OrderType = POP_RECEIVE_LIST;
return (CHECK_SUCCESS);
}
return POP_ERR_STAT;
case POP_CHECK_LIST:
segCnt = strFind(recv_buff,"\r\n");
if(segCnt != 1){
if((strncmp("+OK", recv_buff, 3) == 0)){
p_pop3->RefreshTime = 0;
OrderType = POP_RECEIVE_RTER;
return (CHECK_SUCCESS);
}
}
else{
if((strncmp("+OK", recv_buff, 3) == 0)){
OrderType = COMMAND_UNUSEFULL;
return (CHECK_SUCCESS);
}
if((strncmp(".", recv_buff, 1) == 0)){
p_pop3->RefreshTime = 1;
OrderType = POP_RECEIVE_QUIT;
return (CHECK_SUCCESS);
}
if((strncmp("1", recv_buff, 1) == 0)){
p_pop3->RefreshTime = 0;
OrderType = POP_RECEIVE_RTER;
return (CHECK_SUCCESS);
}
}
return POP_ERR_LIST;
case POP_CHECK_QUIT:
if(strncmp("+OK", recv_buff, 3) == 0){
OrderType = POP_CLOSE_SOCKET;
return (CHECK_SUCCESS);
}
return POP_ERR_QUIT;
case POP_CHECK_RETR:
if(strncmp("+OK", recv_buff, 3) == 0){
OrderType = COMMAND_UNUSEFULL;
#ifdef receive_over_reply
memset(AttachmentData,'\0',sizeof(AttachmentData));
memset(R_argv,'\0',sizeof(R_argv));
memset( p_pop3, '\0', sizeof(POP) );
#endif
#if POP3_LOG_EN
printf("%s\r\n",recv_buff);
#endif
p_pop3->AnalyMailDat = 0;
WCHNET_AnalyseMailData( recv_buff );
return (CHECK_SUCCESS);
}
else if(strncmp("-ERROR", recv_buff, 6) != 0){
if( strncmp("\r\n.\r\n", &recv_buff[ReceLen-5], 5) == 0 ){
#if POP3_LOG_EN
printf("%s\r\n",recv_buff);
#endif
p_pop3->AnalyMailDat = 1;
WCHNET_AnalyseMailData( recv_buff );
#ifdef receive_dele_quit
OrderType = POP_RECEIVE_DELE;
#endif
#ifdef receive_over_quit
OrderType = POP_RECEIVE_QUIT;
#endif
#ifdef receive_over_reply
OrderType = SMTP_SEND_START;
#endif // receive_over_reply
}
else{
#if POP3_LOG_EN
printf("%s\r\n",recv_buff);
#endif
p_pop3->AnalyMailDat = 0;
WCHNET_AnalyseMailData( recv_buff );
}
return (CHECK_SUCCESS);
}
return POP_ERR_RETR;
case POP_CHECK_DELE:
if(strncmp("+OK", recv_buff, 3) == 0){
OrderType = POP_RECEIVE_QUIT;
return (CHECK_SUCCESS);
}
return POP_ERR_DELE;
case POP_CHECK_RSET:
if(strncmp("+OK", recv_buff, 3) == 0){
OrderType = POP_RECEIVE_QUIT;
return (CHECK_SUCCESS);
}
return POP_ERR_RSET;
case POP_CHECK_TOP: //
if(strncmp("+OK", recv_buff, 3) == 0){
OrderType = POP_RECEIVE_QUIT;
return (CHECK_SUCCESS);
}
if(strncmp("Return", recv_buff, 6) == 0){
OrderType = POP_RECEIVE_QUIT;
return (CHECK_SUCCESS);
}
return POP_ERR_TOP;
case POP_CHECK_UIDL: //
if(strncmp("+OK", recv_buff, 3) == 0){
OrderType = POP_RECEIVE_QUIT;
return (CHECK_SUCCESS);
}
return POP_ERR_UIDL;
#endif // receive_mail
default:
return SMTP_ERR_UNKNOW;
}
}
/*********************************************************************
* @fn WCHNET_MailQuery
*
* @brief Status query.
*
* @return None
*/
void WCHNET_MailQuery( void )
{
if( p_pop3->DiscnntFlag == 1){
p_pop3->DiscnntFlag = 0;
#ifdef POP_REFRESH
if(p_pop3->RefreshTime){
p_pop3->RefreshTime = 0;
Delay_Ms(200);
WCHNET_CreateTcpPop3( );
}
#endif
}
if(ReceDatFlag){
#ifdef POP_RTER
if(OrderType == POP_RECEIVE_RTER ){
ReceDatFlag = 0;
WCHNET_POP3Retr( '1' );
}
#endif
#ifdef POP_DELE
if(OrderType == POP_RECEIVE_DELE ){
ReceDatFlag = 0;
WCHNET_POP3Dele( '1' );
}
#endif
#ifdef POP_RSET
if(OrderType == POP_RECEIVE_RSET ){
ReceDatFlag = 0;
WCHNET_POP3Rset( );
}
#endif
#ifdef POP_TOP
if(OrderType == POP_RECEIVE_TOP ){
ReceDatFlag = 0;
WCHNET_POP3Top( '1','3' );
}
#endif
#ifdef POP_UIDL
if(OrderType == POP_RECEIVE_UIDL ){
ReceDatFlag = 0;
WCHNET_POP3Uidl( '1' );
}
#endif
}
}
/*********************************** endfile **********************************/
+933
View File
@@ -0,0 +1,933 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : mailcmd.c
* Author : WCH
* Version : V1.0.0
* Date : 2020/05/06
* Description : Send and receive mail function.
*********************************************************************************
* 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 "mailcmd.h"
char send_buff[512];
char EncodeHostName[32];
#ifdef receive_mail
const char base64_decode_map[256] =
{
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 62, 255, 255, 255, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 255, 255,
255, 0, 255, 255, 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 255, 255, 255, 255, 255, 255, 26, 27, 28,
29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
49, 50, 51, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
};
#endif
/******************************************************************************/
const char base64_map[64] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
/* SMTP CMD Codes */
const char SMTP_CLIENT_CMD[5][11] =
{
"EHLO",
"AUTH LOGIN",
"MAIL FROM:",
"RCPT TO:",
"DATA",
};
/* POP3 CMD Codes */
const char POP3_CLIENT_CMD[12][5] =
{
/* basic POP3 commands */
"QUIT",
"USER",
"PASS",
"STAT",
"LIST",
"RETR",
"DELE",
"RSET",
"NOOP",
/* alternative POP3 commands */
"APOP",
"TOP" ,
"UIDL"
};
/******************************************************************************/
char R_argv[3][32];
POP m_pop3;
SMTP m_smtp;
/*********************************************************************
* @fn Base64Encode
*
* @brief base64 encoding.
*
* @param src - String to be encoded.
* src_len - the length of the encoded string required
* dst - encoded string
*
* @return none
*/
#ifdef send_mail
void Base64Encode(char *src, u16 src_len, char *dst)
{
u16 i = 0,j = 0;
for (; i < src_len - src_len % 3; i += 3) {
dst[j++] = base64_map[(src[i] >> 2) & 0x3f];
dst[j++] = base64_map[((src[i] << 4) | (src[i + 1] >> 4)) & 0x3f];
dst[j++] = base64_map[((src[i + 1] << 2) | (src[i + 2] >> 6 )) & 0x3f];
dst[j++] = base64_map[src[i + 2] & 0x3f];
}
if (src_len % 3 == 1) {
dst[j++] = base64_map[(src[i] >> 2) & 0x3f];
dst[j++] = base64_map[(src[i] << 4) & 0x3f];
dst[j++] = '=';
dst[j++] = '=';
}
else if (src_len % 3 == 2) {
dst[j++] = base64_map[(src[i] >> 2) & 0x3f];
dst[j++] = base64_map[((src[i] << 4) | (src[i + 1] >> 4)) & 0x3f];
dst[j++] = base64_map[(src[i + 1] << 2) & 0x3f];
dst[j++] = '=';
}
dst[j] = '\0';
}
#endif
/*********************************************************************
* @fn Base64Decode
*
* @brief base64 decoding.
*
* @param pSrc - String to decode.
* src_len - the length of the string that needs to be decoded
* dst - decoded string
*
* @return none
*/
#ifdef receive_mail
void Base64Decode(char *src, u16 src_len, char *dst)
{
u32 i = 0, j = 0;
for (; i < src_len; i += 4) {
if(strncmp( &src[i], "\r\n", 2 ) == 0) i += 2;
dst[j++] = base64_decode_map[src[i]] << 2 |
base64_decode_map[src[i + 1]] >> 4;
dst[j++] = base64_decode_map[src[i + 1]] << 4 |
base64_decode_map[src[i + 2]] >> 2;
dst[j++] = base64_decode_map[src[i + 2]] << 6 |
base64_decode_map[src[i + 3]];
}
if(src_len%4 == 3) {
dst[strlen(dst)-1] = '\0';
}
else if(src_len%4 == 2) {
dst[strlen((char *)dst)-1] = '\0';
dst[strlen((char *)dst)-1] = '\0';
}
else dst[j] = '\0';
}
#endif
/*********************************************************************
* @fn QuotedPrintableEncode
*
* @brief quoted printable encoding.
*
* @param pSrc - String to be encoded.
* pDst - encoded string
* nSrcLen - data length
* MaxLine - maximum number of lines
*
* @return none
*/
#ifdef send_mail
void QuotedPrintableEncode( char *pSrc, char *pDst, u16 nSrcLen, u16 MaxLine )
{
u16 nDstLen = 0;
u16 nLineLen = 0;
u16 i = 0;
for(i = 0; i < nSrcLen; i++, pSrc++ ){
if( (*pSrc >= '!') && (*pSrc <= '~') && (*pSrc != '=') ){
*pDst++ = *pSrc;
nDstLen++;
nLineLen++;
}
else{
sprintf(pDst, "=%02x", *pSrc);
pDst += 3;
nDstLen += 3;
nLineLen += 3;
}
if( nLineLen >= MaxLine - 3 ){
sprintf(pDst,"=\r\n");
pDst += 3;
nDstLen += 3;
nLineLen = 0;
}
}
*pDst = '\0';
}
#endif
/*********************************************************************
* @fn QuotedPrintableDecode
*
* @brief quoted printable decoding.
*
* @param pSrc - String to decode.
* pDst - decoded string
* nSrcLen - data length
*
* @return none
*/
#ifdef receive_mail
void QuotedPrintableDecode( char *pSrc, char *pDst, u16 nSrcLen )
{
u16 i = 0;
u16 nDstLen = 0;
while( i < nSrcLen ){
if( strncmp( pSrc, "=\r\n", 3 ) == 0 ){
pSrc += 3;
i += 3;
}
else{
if( *pSrc == '=' ){
sscanf( pSrc, "=%02x",*pDst);
pDst++;
pSrc += 3;
i += 3;
}
else{
*pDst++ = *pSrc++;
i++;
}
nDstLen++;
}
}
*pDst = '\0';
}
#endif
/*******************************************************************************/
#ifdef send_mail
/*********************************************************************
* @fn WCHNET_XToChar
*
* @brief hex to string.
*
* @param dat - hex data to convert.
* p - The corresponding string after conversion
* len - length to convert
*
* @return none
*/
#ifdef receive_over_reply
void WCHNET_XToChar( char *dat,char *p,char len)
{
char k;
for(k=0;k<len;k++){
*p = (((dat[k]&0xf0)>>4)/10)?(((dat[k]&0xf0)>>4)+'A'-10):(((dat[k]&0xf0)>>4)+'0');
p++;
*p = ((dat[k]&0x0f)/10)?((dat[k]&0x0f)+'A'-10):((dat[k]&0x0f)+'0');
p++;
if(k<len-1){
*p = '.';
p++;
}
}
}
#endif //receive_over_reply
/*********************************************************************
* @fn WCHNET_SMTPInit
*
* @brief Email sending initialization.
*
* @return none
*/
void WCHNET_SMTPInit(void)
{
p_smtp = &m_smtp;
p_smtp->g_MIME = 0;
memset( p_smtp, '\0', sizeof(SMTP) );
strcpy( p_smtp->m_strSMTPServer, m_Server );
strcpy( p_smtp->m_strUSERID,m_UserName );
strcpy( p_smtp->m_strPASSWD,m_PassWord );
strcpy( p_smtp->m_strSendFrom,m_SendFrom );
strcpy( p_smtp->m_strSenderName, m_SendName );
#ifdef receive_over_reply
strcpy( p_smtp->m_strSendTo,R_argv[0] );
strcpy( p_smtp->m_strSubject,R_argv[1] );
strcpy( p_smtp->m_strFile,R_argv[2] );
#else
strcpy( p_smtp->m_strSendTo,m_SendTo );
strcpy( p_smtp->m_strSubject,m_Subject );
strcpy( p_smtp->m_strFile,m_FileName );
#endif // receive_over_reply
}
/*********************************************************************
* @fn WCHNET_SMTPIsMIME
*
* @brief Check for attachments.
*
* @return none
*/
void WCHNET_SMTPIsMIME( void )
{
if( strlen(p_smtp->m_strFile) <= 0 ) p_smtp->g_MIME = 0;
else p_smtp->g_MIME = 1;
}
/*********************************************************************
* @fn WCHNET_SMTPAttachHeader
*
* @brief Attachment envelope.
*
* @param pFileName - Attachment name.
* pAttachHeader - Envelope Contents
*
* @return none
*/
void WCHNET_SMTPAttachHeader( char *pFileName, char *pAttachHeader )
{
const char *strContentType = "application/octet-stream";
sprintf(pAttachHeader, "\r\n\r\n--%s\r\nContent-Type: %s;\r\n name=\"%s\"%sContent-Disposition: \
attachment;\r\n filename=\"%s\"\r\n\r\n", g_strBoundary, strContentType, pFileName,g_AttachHead, pFileName );
}
/*********************************************************************
* @fn WCHNET_SMTPAttachEnd
*
* @brief Form attachment end content.
*
* @param EndSize - data length.
* pAttachEnd - data buff
*
* @return none
*/
void WCHNET_SMTPAttachEnd( u16 *EndSize, char *pAttachEnd )
{
strcat( pAttachEnd, "\r\n--" );
strcat( pAttachEnd, g_strBoundary );
strcat( pAttachEnd, "--" );
*EndSize = strlen(pAttachEnd);
}
/*********************************************************************
* @fn WCHNET_SMTPMailHeader
*
* @brief mail envelope.
*
* @return none
*/
void WCHNET_SMTPMailHeader( void )
{
// "FROM: "
memset( send_buff, '\0', sizeof(send_buff) );
strcat( send_buff, "From: \"" );
strcat( send_buff, p_smtp->m_strSenderName );
strcat( send_buff, "\" <" );
strcat( send_buff, p_smtp->m_strSendFrom );
strcat( send_buff, ">\r\n" );
// "TO: "
strcat( send_buff, "To: <" );
strcat( send_buff, p_smtp->m_strSendTo );
strcat( send_buff, ">\r\n" );
// "Subject: "
strcat( send_buff, "Subject: ");
#ifdef receive_over_reply
strcat( send_buff, "Re: ");
#endif
strcat( send_buff, p_smtp->m_strSubject );
strcat( send_buff, "\r\n" );
//"Date: "
strcat( send_buff, "Date: ");
// strcat( send_buff, "" ); /* 时间 */
strcat( send_buff, "\r\n" );
/* "X-Mailer: " */
strcat( send_buff, g_xMailer );
/* 有附件 */
if( p_smtp->g_MIME == 1 ){
strcat( send_buff, "MIME-Version: 1.0\r\nContent-Type: " );
strcat( send_buff, g_MailHedType );
strcat( send_buff, ";\r\n\tboundary=\"" );
strcat( send_buff, g_strBoundary );
strcat( send_buff, "\"\r\n" );
}
/* Encoding information */
strcat( send_buff, g_Encoding );
strcat( send_buff, p_smtp->m_strSenderName );
strcat( send_buff, " <" );
strcat( send_buff, p_smtp->m_strSendFrom );
strcat( send_buff, ">\r\n" );
/* add custom-tailor */
strcat( send_buff, g_Custom );
/* end of mail header */
strcat( send_buff, "\r\n\r\n" );
#if DIALOG
printf("Mail Header:\n%s\n", send_buff);
#endif
WCHNET_SendData( send_buff, strlen(send_buff),UNCHECK ,p_smtp->Socket);
}
/*********************************************************************
* @fn WCHNET_SMTPSendAttachData
*
* @brief Send attachment content.
*
* @return none
*/
void WCHNET_SMTPSendAttachData( void )
{
u16 EndSize;
memset( send_buff, '\0', sizeof(send_buff) );
WCHNET_SMTPAttachHeader( p_smtp->m_strFile, send_buff);
#if DIALOG
printf("Attach Header:\n%s\n", send_buff);
#endif
WCHNET_SendData( send_buff, strlen(send_buff),UNCHECK ,p_smtp->Socket); /* Send attached file header */
/*****************************************************************************
*Attachment content
*****************************************************************************/
// GetAttachedFileBody( &FileSize, m_smtp->m_strFile, pAttachedFileBody );
memset( send_buff, '\0', sizeof(send_buff) );
QuotedPrintableEncode( AttachmentData, send_buff, strlen(AttachmentData),200 );
#if DIALOG
printf("Attach Data send_buff:\n%s\n", send_buff);
#endif
WCHNET_SendData( send_buff, strlen(send_buff),UNCHECK ,p_smtp->Socket);
memset( send_buff, '\0', sizeof(send_buff) );
WCHNET_SMTPAttachEnd( &EndSize, send_buff );
#if DIALOG
printf("Attach End :\n%s\n", send_buff);
#endif
WCHNET_SendData( send_buff, strlen(send_buff),UNCHECK ,p_smtp->Socket); /* Send attached file end */
}
/*********************************************************************
* @fn WCHNET_SMTPSendAttachHeader
*
* @brief Send attachment envelope.
*
* @return none
*/
void WCHNET_SMTPSendAttachHeader( void )
{
memset( send_buff, '\0', sizeof(send_buff) );
sprintf( send_buff, g_FormatMail );
WCHNET_SendData( send_buff, strlen(send_buff),UNCHECK,p_smtp->Socket );
memset( send_buff, '\0', sizeof(send_buff) );
sprintf( send_buff, "\r\n--%s\r\nContent-Type: %s;\r\n\tcharset=\"%s\"%s\r\n",
g_strBoundary, g_AttachHedType, g_strcharset,g_AttachHead );
#if DIALOG
printf("MIME Header:\n%s\n", send_buff);
#endif
WCHNET_SendData( send_buff, strlen(send_buff),UNCHECK,p_smtp->Socket);
}
/*********************************************************************
* @fn WCHNET_SMTPEhlo
*
* @brief Send HELLO command.
*
* @return none
*/
void WCHNET_SMTPEhlo( void )
{
memset( EncodeHostName, '\0', sizeof(EncodeHostName) );
QuotedPrintableEncode( (char *)p_smtp->m_strSenderName, EncodeHostName, strlen(p_smtp->m_strSenderName),76 );
memset( send_buff, '\0', sizeof(send_buff) );
sprintf( send_buff, "%s %s\r\n", SMTP_CLIENT_CMD[0],EncodeHostName );
#if DIALOG
printf("EHLO :%s\n", send_buff);
#endif
WCHNET_SendData( send_buff, strlen(send_buff),SMTP_CHECK_HELO ,p_smtp->Socket);
}
/*********************************************************************
* @fn WCHNET_SMTPAuth
*
* @brief send login command.
*
* @return none
*/
void WCHNET_SMTPAuth( void )
{
memset( send_buff, '\0', sizeof(send_buff) );
sprintf( send_buff, "%s\r\n",SMTP_CLIENT_CMD[1]);
#if DIALOG
printf("AUTH :%s\n", send_buff);
#endif
/* send "AUTH LOGIN" command */
WCHNET_SendData( send_buff, strlen(send_buff),SMTP_CHECK_AUTH ,p_smtp->Socket);
}
/*********************************************************************
* @fn WCHNET_SMTPUser
*
* @brief Authentication user name.
*
* @return none
*/
void WCHNET_SMTPUser( void )
{
memset( send_buff, '\0', sizeof(send_buff) );
Base64Encode( (char *)p_smtp->m_strUSERID, strlen(p_smtp->m_strUSERID), send_buff );
sprintf( send_buff, "%s\r\n", send_buff);
#if DIALOG
printf("USER :%s\n", send_buff);
#endif
WCHNET_SendData( send_buff, strlen(send_buff),SMTP_CHECK_USER,p_smtp->Socket );
}
/*********************************************************************
* @fn WCHNET_SMTPPass
*
* @brief Authentication login password.
*
* @return none
*/
void WCHNET_SMTPPass( void )
{
memset( send_buff, '\0', sizeof(send_buff) );
Base64Encode( (char *)p_smtp->m_strPASSWD, strlen(p_smtp->m_strPASSWD), send_buff);
sprintf( send_buff, "%s\r\n", send_buff);
#if DIALOG
printf("PASS :%s\n", send_buff);
#endif
WCHNET_SendData( send_buff, strlen(send_buff),SMTP_CHECK_PASS,p_smtp->Socket );
}
/*********************************************************************
* @fn WCHNET_SMTPMail
*
* @brief Send sender name.
*
* @return none
*/
void WCHNET_SMTPMail( void )
{
memset( send_buff, '\0', sizeof(send_buff) );
sprintf( send_buff, "%s <%s>\r\n", SMTP_CLIENT_CMD[2],p_smtp->m_strSendFrom );
#if DIALOG
printf("MAIL :%s\n", send_buff);
#endif
WCHNET_SendData( send_buff, strlen(send_buff),SMTP_CHECK_MAIL,p_smtp->Socket );
}
/*********************************************************************
* @fn WCHNET_SMTPRcpt
*
* @brief receiver's address.
*
* @return none
*/
void WCHNET_SMTPRcpt( void )
{
memset( send_buff, '\0', sizeof(send_buff) );
sprintf( send_buff, "%s <%s>\r\n", SMTP_CLIENT_CMD[3],p_smtp->m_strSendTo );
#if DIALOG
printf("RCPT :%s\n", send_buff);
#endif
WCHNET_SendData( send_buff, strlen(send_buff),SMTP_CHECK_RCPT,p_smtp->Socket );
}
/*********************************************************************
* @fn WCHNET_SMTPData
*
* @brief send DATA command.
*
* @return none
*/
void WCHNET_SMTPData( void )
{
memset( send_buff, '\0', sizeof(send_buff) );
sprintf( send_buff, "%s\r\n",SMTP_CLIENT_CMD[4] );
#if DIALOG
printf("DATA :%s\n", send_buff);
#endif
WCHNET_SendData( send_buff, strlen(send_buff),SMTP_CHECK_DATA,p_smtp->Socket );
}
/*********************************************************************
* @fn WCHNET_SMTPSendMail
*
* @brief Send email content.
*
* @return none
*/
void WCHNET_SMTPSendMail( void )
{
WCHNET_SMTPIsMIME( );
WCHNET_SMTPMailHeader( ); /* Send Mail Header */
if( p_smtp->g_MIME == 1 ){
WCHNET_SMTPSendAttachHeader( ); /* Send MIME Header */
}
else {
WCHNET_SendData("\r\n", strlen("\r\n"),UNCHECK,p_smtp->Socket);
}
memset( send_buff, '\0', sizeof(send_buff) );
#ifdef receive_over_reply
WCHNET_ReplyMailBody( );
#else // receive_over_reply
QuotedPrintableEncode( (char *)MailBodyData, send_buff, strlen(MailBodyData),76 );
#endif // receive_over_reply
#if DIALOG
printf("text data:\n%s\n",send_buff);
#endif
WCHNET_SendData( send_buff, strlen(send_buff),UNCHECK ,p_smtp->Socket);
if( 1 == p_smtp->g_MIME ) WCHNET_SMTPSendAttachData( ); /* Send Attached file */
memset( send_buff, '\0', sizeof(send_buff) );
sprintf( send_buff, "\r\n.\r\n" );
#if DIALOG
printf("OVER :%s\n", send_buff);
#endif
/* Send end flag of Mail */
WCHNET_SendData( send_buff, strlen(send_buff),SMTP_CHECK_DATA_END ,p_smtp->Socket);
}
/******************************************************************************/
#endif // send_mail
/******************************************************************************/
#ifdef receive_mail
/*********************************************************************
* @fn WCHNET_POP3Init
*
* @brief Receive mail initialization.
*
* @return none
*/
void WCHNET_POP3Init( void )
{
p_pop3 = &m_pop3;
memset( p_pop3, '\0', sizeof(POP) );
strcpy( p_pop3->pPop3Server, p_Server );
strcpy( p_pop3->pPop3UserName, p_UserName );
strcpy( p_pop3->pPop3PassWd, p_PassWord );
}
/*********************************************************************
* @fn WCHNET_POP3User
*
* @brief Authentication user name.
*
* @return none
*/
void WCHNET_POP3User( void )
{
memset( send_buff, '\0', sizeof(send_buff) );
sprintf(send_buff, "%s %s\r\n",POP3_CLIENT_CMD[1], p_pop3->pPop3UserName);
#if DIALOG
printf("USER :%s\n", send_buff);
#endif
WCHNET_SendData( send_buff, strlen(send_buff), POP_CHECK_USER ,p_pop3->Socket);
}
/*********************************************************************
* @fn WCHNET_POP3Pass
*
* @brief Authentication password.
*
* @return none
*/
void WCHNET_POP3Pass( void )
{
memset( send_buff, '\0', sizeof(send_buff) );
sprintf( send_buff, "%s %s\r\n", POP3_CLIENT_CMD[2], p_pop3->pPop3PassWd );
#if DIALOG
printf("PASS :%s\n", send_buff);
#endif
WCHNET_SendData( send_buff, strlen(send_buff), POP_CHECK_PASS,p_pop3->Socket );
}
/*********************************************************************
* @fn WCHNET_POP3Stat
*
* @brief Get mailbox statistics.
*
* @return none
*/
void WCHNET_POP3Stat( void )
{
memset( send_buff, '\0', sizeof(send_buff) );
sprintf( send_buff,"%s\r\n", POP3_CLIENT_CMD[3] );
#if DIALOG
printf("STAT :%s\n", send_buff);
#endif
WCHNET_SendData( send_buff, strlen(send_buff), POP_CHECK_STAT,p_pop3->Socket );
}
/*********************************************************************
* @fn WCHNET_POP3List
*
* @brief Get email list information.
*
* @return none
*/
void WCHNET_POP3List( void )
{
#if 0 /* 如果需指定某封邮件则置1 */
char num;
num = '1'; /* 根据需要修改邮件号 */
memset( send_buff, '\0', sizeof(send_buff) );
sprintf( send_buff, "%s %c\r\n", POP3_CLIENT_CMD[4],num );
#else
memset( send_buff, '\0', sizeof(send_buff) );
sprintf( send_buff, "%s\r\n", POP3_CLIENT_CMD[4] );
#endif
#if DIALOG
printf("LIST :%s\n", send_buff);
#endif
WCHNET_SendData( send_buff, strlen(send_buff), POP_CHECK_LIST,p_pop3->Socket);
}
/*********************************************************************
* @fn WCHNET_POP3Retr
*
* @brief deal the full text of an email
*
* @param num - mail number.
*
* @return none
*/
#ifdef POP_RTER
void WCHNET_POP3Retr( u8 num )
{
memset( send_buff, '\0', sizeof(send_buff) );
sprintf( send_buff, "%s %c\r\n", POP3_CLIENT_CMD[5], num );
#if DIALOG
printf("RTER :%s\n", send_buff);
#endif
WCHNET_SendData( send_buff, strlen(send_buff), POP_CHECK_RETR,p_pop3->Socket );
}
#endif
/*********************************************************************
* @fn WCHNET_POP3Dele
*
* @brief Mark to delete, only when the QUIT
* command is executed is actually deleted.
*
* @param num - mail number.
*
* @return none
*/
#ifdef POP_DELE
void WCHNET_POP3Dele( u8 num )
{
memset( send_buff, '\0', sizeof(send_buff) );
sprintf( send_buff, "%s %c\r\n", POP3_CLIENT_CMD[6], num );
#if DIALOG
printf("DELE :%s\n", send_buff);
#endif
WCHNET_SendData( send_buff, strlen(send_buff), POP_CHECK_DELE,p_pop3->Socket );
}
#endif
/*********************************************************************
* @fn WCHNET_POP3Rset
*
* @brief Undo delete.
*
* @return none
*/
#ifdef POP_RSET
void WCHNET_POP3Rset( void )
{
memset( send_buff, '\0', sizeof(send_buff) );
sprintf( send_buff, "%s \r\n", POP3_CLIENT_CMD[7]);
#if DIALOG
printf("RSET :%s\n", send_buff);
#endif
WCHNET_SendData( send_buff, strlen(send_buff), POP_CHECK_RSET,p_pop3->Socket );
}
#endif
/*********************************************************************
* @fn WCHNET_POP3Top
*
* @brief Returns the first 'm' lines of mail number 'num'.
*
* @param num - mail number.
* m - rows.
*
* @return none
*/
#ifdef POP_TOP
void WCHNET_POP3Top( char num ,char m )
{
memset( send_buff, '\0', sizeof(send_buff) );
sprintf( send_buff, "%s %c %c\r\n", POP3_CLIENT_CMD[10], num, m);
#if DIALOG
printf("TOP :%s\n", send_buff);
#endif
WCHNET_SendData( send_buff, strlen(send_buff), POP_CHECK_TOP, p_pop3->Socket );
}
#endif
/*********************************************************************
* @fn WCHNET_POP3Uidl
*
* @brief Returns the unique identifier for the specified message.
*
* @param num - mail number.
*
* @return none
*/
#ifdef POP_UIDL
void WCHNET_POP3Uidl( char num )
{
memset( send_buff, '\0', sizeof(send_buff) );
sprintf( send_buff, "%s %c\r\n", POP3_CLIENT_CMD[11], num);
#if DIALOG
printf("UIDL :%s\n", send_buff);
#endif
WCHNET_SendData( send_buff, sizeof(send_buff), POP_CHECK_UIDL, p_pop3->Socket );
}
#endif
/******************************************************************************/
#endif // receive_mail
/*********************************************************************
* @fn WCHNET_Quit
*
* @brief sign out.
*
* @param id - socket id.
*
* @return none
*/
void WCHNET_Quit( u8 id )
{
#if DIALOG
printf("QUIT(socket=%2d)\n", id);
#endif
memset( send_buff, '\0', sizeof(send_buff) );
sprintf( send_buff, "%s\r\n", POP3_CLIENT_CMD[0]);
if(id == p_smtp->Socket) WCHNET_SendData( send_buff, strlen(send_buff), SMTP_CHECK_QUIT, id );
if(id == p_pop3->Socket) WCHNET_SendData( send_buff, strlen(send_buff), POP_CHECK_QUIT, id );
}
/*********************************************************************
* @fn WCHNET_MailCmd
*
* @brief Analytical data.
*
* @param choiceorder - Command type.
*
* @return none
*/
void WCHNET_MailCmd( u8 choiceorder )
{
u8 i;
switch( choiceorder ){
#ifdef send_mail
case SMTP_SEND_HELO:
WCHNET_SMTPEhlo( );
break;
case SMTP_SEND_AUTH:
WCHNET_SMTPAuth( );
break;
case SMTP_SEND_USER:
WCHNET_SMTPUser( );
break;
case SMTP_SEND_PASS:
WCHNET_SMTPPass( );
break;
case SMTP_SEND_MAIL:
WCHNET_SMTPMail( );
break;
case SMTP_SEND_RCPT:
WCHNET_SMTPRcpt( );
break;
case SMTP_SEND_DATA:
WCHNET_SMTPData( );
break;
case SMTP_DATA_OVER:
WCHNET_SMTPSendMail( );
break;
case SMTP_ERR_CHECK:
WCHNET_Quit( p_smtp->Socket );
CheckType = UNCHECK;
i = WCHNET_SocketClose( p_smtp->Socket,TCP_CLOSE_NORMAL );
mStopIfError(i);
break;
case SMTP_SEND_QUIT:
WCHNET_Quit( p_smtp->Socket );
break;
case SMTP_CLOSE_SOCKET:
CheckType = UNCHECK;
i = WCHNET_SocketClose( p_smtp->Socket,TCP_CLOSE_NORMAL );
mStopIfError(i);
#ifdef receive_over_reply
OrderType = POP_RECEIVE_DELE;
#endif
break;
case SMTP_SEND_START:
WCHNET_CreateTcpSmtp( );
break;
#endif // send_mail
#ifdef receive_mail
case POP_RECEIVE_USER:
WCHNET_POP3User( );
break;
case POP_RECEIVE_PASS:
WCHNET_POP3Pass( );
break;
case POP_RECEIVE_STAT:
WCHNET_POP3Stat( );
break;
case POP_RECEIVE_LIST:
WCHNET_POP3List( );
break;
case POP_ERR_CHECK:
WCHNET_Quit( p_pop3->Socket );
CheckType = UNCHECK;
i = WCHNET_SocketClose( p_pop3->Socket,TCP_CLOSE_NORMAL );
mStopIfError(i);
break;
case POP_RECEIVE_QUIT:
WCHNET_Quit( p_pop3->Socket );
break;
case POP_CLOSE_SOCKET:
CheckType = UNCHECK;
i = WCHNET_SocketClose( p_pop3->Socket,TCP_CLOSE_NORMAL );
mStopIfError(i);
#ifdef send_over_receive
OrderType = SMTP_SEND_QUIT;
#endif
break;
case POP_RECEIVE_START:
WCHNET_CreateTcpPop3( );
break;
#endif // receive_mail
default:
break;
}
}
/*********************************** endfile **********************************/
+41
View File
@@ -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_it.h"
#include "ch32v20x_misc.h"
#endif /* __CH32V20x_CONF_H */
+73
View File
@@ -0,0 +1,73 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : ch32v20x_it.c
* Author : WCH
* Version : V1.0.0
* Date : 2021/06/06
* 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"
#include <wchnet.h>
#include "eth_driver.h"
void NMI_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void HardFault_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void ETH_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void TIM2_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
/*********************************************************************
* @fn NMI_Handler
*
* @brief This function handles NMI exception.
*
* @return none
*/
void NMI_Handler(void)
{
/**/
}
/*********************************************************************
* @fn HardFault_Handler
*
* @brief This function handles Hard Fault exception.
*
* @return none
*/
void HardFault_Handler(void)
{
printf("HardFault_Handler\r\n");
printf("mcause:%08x\r\n",__get_MCAUSE());
printf("mtval:%08x\r\n",__get_MTVAL());
printf("mepc:%08x\r\n",__get_MEPC());
while (1);
}
/*********************************************************************
* @fn ETH_IRQHandler
*
* @brief This function handles ETH exception.
*
* @return none
*/
void ETH_IRQHandler(void)
{
WCHNET_ETHIsr();
}
/*********************************************************************
* @fn TIM2_IRQHandler
*
* @brief This function handles TIM2 exception.
*
* @return none
*/
void TIM2_IRQHandler(void)
{
WCHNET_TimeIsr(WCHNETTIMERPERIOD);
TIM_ClearITPendingBit(TIM2, TIM_IT_Update);
}
+19
View File
@@ -0,0 +1,19 @@
/********************************** (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 */
+363
View File
@@ -0,0 +1,363 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : main.c
* Author : WCH
* Version : V1.0.0
* Date : 2022/05/07
* 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.
*******************************************************************************/
/*
*@Note
Mail example, demo SMTP and POP3 mail sending and receiving.
For details on the selection of engineering chips,
please refer to the "CH32V20x Evaluation Board Manual" under the CH32V20xEVT\EVT\PUB folder.
*/
#include "string.h"
#include "debug.h"
#include "eth_driver.h"
#include "mail.h"
u8 MACAddr[6]; //MAC address
u8 IPAddr[4] = {192,168,1,10}; //IP address
u8 GWIPAddr[4] = {192,168,1,1}; //Gateway IP address
u8 IPMask[4] = {255,255,255,0}; //subnet mask
u8 DESIP[4] = {192,168,1,100}; //destination IP address
u8 SocketId; //socket id
u8 SocketRecvBuf[WCHNET_MAX_SOCKET_NUM][RECE_BUF_LEN]; //socket data buff
u8 ReceDatFlag = 0;
u8 CheckType;
u8 OrderType;
u16 ReceLen;
/*SMTP related definitions, SMTP sending mail*/
const u16 SmtpSourPrt = 5300;
const u8 SocketSMTPIP[4] = {183,47,101,192}; //SMTP destination IP address
/*It is recommended to manually PING to
* obtain the latest IP before using*/
/*
* {220,181,15,73} "smtp.126.com"
* {220,181,15,161} "smtp.163.com"
* {183,47,101,192} "smtp.qq.com"
* {64,233,189,108} "smtp.gmail.com"
*/
/*POP3 related definitions, POP receiving mail*/
const u16 Pop3SourPrt = 4567;
const u8 SocketPOP3IP[4] = {183,47,101,192}; //POP3 destination IP address
/*It is recommended to manually PING to
* obtain the latest IP before using*/
/*
* {220,181,15,128} "pop.126.com",
* {220,181,12,110} "pop.163.com",
* {183,47,101,192} "pop.qq.com",
* {108,177,125,108} "pop.gmail.com"
*/
/* SMTP send email related parameters */
const char *m_Server = "smtp.qq.com"; //server name
const char *m_UserName = "XXX"; //user name
const char *m_PassWord = "******"; //password
const char *m_SendFrom = "XXX@qq.com"; //sender address
const char *m_SendName = "one"; //sender name
const char *m_SendTo = "XXX@qq.com"; //receiver's address
const char *m_Subject = "text"; //subject
const char *m_FileName = "m_file.txt"; //Attachment name (set to "\0" if no attachment is sent)
/* POP receive mail related parameters */
const char *p_Server = "pop.qq.com"; //POP server
const char *p_UserName = "XXX"; //POP login user name
const char *p_PassWord = "******"; //POP login password
/*Email related content*/
char AttachmentData[attach_max_len] = "0123456789abcdefghijklmnopqrstuvwxyz"; //Attachment content
char MailBodyData[128] = "Demonstration test WCHNET mail function wch.cn"; //Email body content
#ifdef receive_over_reply
const char *g_mailbody = "welcome."; //Email body content for reply
const char *g_autograph1 = "\r\n\r\nBest Regards!\r\n----- Original Message \
----\r\n"; //Email autograph field content for reply
const char *g_autograph2 = "\r\nweb:http://www.wch.cn\r\n"; //Email autograph field content for reply
char MacAddr[6];
char MacAddrC[18];
#endif
/*********************************************************************
* @fn mStopIfError
*
* @brief check if error.
*
* @param iError - error constants.
*
* @return none
*/
void mStopIfError(u8 iError)
{
if (iError == WCHNET_ERR_SUCCESS) return;
printf("Error: %02X\r\n", (u16)iError);
}
/*********************************************************************
* @fn TIM2_Init
*
* @brief Initializes TIM2.
*
* @return none
*/
void TIM2_Init( void )
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure={0};
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);
TIM_TimeBaseStructure.TIM_Period = SystemCoreClock / 1000000 - 1;
TIM_TimeBaseStructure.TIM_Prescaler = WCHNETTIMERPERIOD * 1000 - 1;
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
TIM_ITConfig(TIM2, TIM_IT_Update ,ENABLE);
TIM_Cmd(TIM2, ENABLE);
TIM_ClearITPendingBit(TIM2, TIM_IT_Update );
NVIC_EnableIRQ(TIM2_IRQn);
}
/*********************************************************************
* @fn WCHNET_CreateTcpSmtp
*
* @brief create TCP Client socket for SMTP
*
* @return none
*/
void WCHNET_CreateTcpSmtp( void )
{
u8 i;
SOCK_INF TmpSocketInf;
memset((void *)SocketRecvBuf[0],'\0',sizeof(SocketRecvBuf[0]));
memset((void *)&TmpSocketInf,0,sizeof(SOCK_INF));
memcpy((void *)TmpSocketInf.IPAddr,SocketSMTPIP,4);
TmpSocketInf.DesPort = SMTP_SERVER_PORT;
TmpSocketInf.SourPort = SmtpSourPrt;
TmpSocketInf.ProtoType = PROTO_TYPE_TCP;
TmpSocketInf.RecvBufLen = RECE_BUF_LEN ;
i = WCHNET_SocketCreat(&SocketId,&TmpSocketInf);
printf("SocketId TCP SMTP = %02x\n",(u16)SocketId);
mStopIfError(i);
p_smtp->Socket = SocketId;
CheckType = SMTP_CHECK_CNNT;
i = WCHNET_SocketConnect(SocketId);
mStopIfError(i);
}
/*********************************************************************
* @fn WCHNET_CreateTcpPop3
*
* @brief create TCP Client socket for POP3
*
* @return none
*/
void WCHNET_CreateTcpPop3( void )
{
u8 i;
SOCK_INF TmpSocketInf;
memset((void *)SocketRecvBuf[1],'\0',sizeof(SocketRecvBuf[1]));
memset((void *)&TmpSocketInf,0,sizeof(SOCK_INF));
memcpy((void *)TmpSocketInf.IPAddr,SocketPOP3IP,4);
TmpSocketInf.DesPort = POP3_SERVER_PORT;
TmpSocketInf.SourPort = Pop3SourPrt;
TmpSocketInf.ProtoType = PROTO_TYPE_TCP;
TmpSocketInf.RecvBufLen = RECE_BUF_LEN ;
i = WCHNET_SocketCreat(&SocketId,&TmpSocketInf);
printf("SocketId TCP pop3 = %02x\n",(u16)SocketId);
mStopIfError(i);
p_pop3->Socket = SocketId;
CheckType = POP_CHECK_CNNT;
i = WCHNET_SocketConnect(SocketId);
mStopIfError(i);
memset((void *)SocketRecvBuf[SocketId],'\0',sizeof(SocketRecvBuf[SocketId]));
}
/*********************************************************************
* @fn WCHNET_SendData
*
* @brief send data.
*
* @param PSend data buff
* Len data length
* type control command code
* id socket id
* @return none
*/
void WCHNET_SendData( char *PSend, u32 Len,u8 type,u8 id )
{
u32 length;
u8 i;
u8 *p;
p = (u8 *)PSend;
length = Len;
CheckType = type;
while(1)
{
Len = length;
i = WCHNET_SocketSend(id,p,&Len);
mStopIfError(i);
length -= Len;
p += Len;
if(length)continue;
break;
}
}
/*********************************************************************
* @fn WCHNET_HandleSockInt
*
* @brief Socket Interrupt Handle
*
* @param socketid - socket id.
* intstat - interrupt status
*
* @return none
*/
void WCHNET_HandleSockInt(u8 socketid,u8 intstat)
{
u32 len;
u8 i;
if(intstat & SINT_STAT_RECV) //receive data
{
ReceDatFlag = 1;
len = WCHNET_SocketRecvLen(socketid,NULL);
ReceLen = len;
WCHNET_SocketRecv(socketid,SocketRecvBuf[socketid],&len);
if( CheckType != UNCHECK ){
i = WCHNET_CheckResponse((char *)SocketRecvBuf[socketid],CheckType);
if(i != CHECK_SUCCESS){
if(socketid == p_smtp->Socket) OrderType = SMTP_ERR_CHECK;
if(socketid == p_pop3->Socket) OrderType = POP_ERR_CHECK;
printf("ERROR: %02x\n",(u16)i);
}
}
memset((void *)SocketRecvBuf[socketid],'\0',sizeof(SocketRecvBuf[socketid]));
}
if(intstat & SINT_STAT_CONNECT) //connect successfully
{
WCHNET_ModifyRecvBuf(socketid, (u32)SocketRecvBuf[socketid], RECE_BUF_LEN);
printf("TCP Connect Success\r\n");
}
if(intstat & SINT_STAT_DISCONNECT) //disconnect
{
printf("TCP Disconnect\r\n");
if(socketid == p_pop3->Socket) p_pop3->DiscnntFlag = 1;
}
if(intstat & SINT_STAT_TIM_OUT) //timeout disconnect
{
printf("TCP Timeout\r\n");
if(socketid == p_pop3->Socket) p_pop3->DiscnntFlag = 1;
}
}
/*********************************************************************
* @fn WCHNET_HandleGlobalInt
*
* @brief Global Interrupt Handle
*
* @return none
*/
void WCHNET_HandleGlobalInt(void)
{
u8 intstat;
u8 socketint;
u16 i;
intstat = WCHNET_GetGlobalInt(); //get global interrupt flag
if(intstat & GINT_STAT_UNREACH) //Unreachable interrupt
{
printf("GINT_STAT_UNREACH\r\n");
}
if(intstat & GINT_STAT_IP_CONFLI) //IP conflict
{
printf("GINT_STAT_IP_CONFLI\r\n");
}
if(intstat & GINT_STAT_PHY_CHANGE) //PHY status change
{
i = WCHNET_GetPHYStatus(); //socket related interrupt
if(i&PHY_Linked_Status)
printf("PHY Link Success\r\n");
}
if(intstat & GINT_STAT_SOCKET)
{
for(i = 0; i < WCHNET_MAX_SOCKET_NUM; i ++)
{
socketint = WCHNET_GetSocketInt(i);
if(socketint)WCHNET_HandleSockInt(i,socketint);
}
}
}
/*********************************************************************
* @fn main
*
* @brief Main program
*
* @return none
*/
int main(void)
{
u8 i;
Delay_Init();
USART_Printf_Init(115200); //USART initialize
printf("Mail\r\n");
printf("SystemClk:%d\r\n",SystemCoreClock);
printf("net version:%x\n",WCHNET_GetVer());
if( WCHNET_LIB_VER != WCHNET_GetVer() ){
printf("version error.\n");
}
WCHNET_GetMacAddr(MACAddr); //get the chip MAC address
printf("mac addr:");
for(i = 0; i < 6; i++)
printf("%x ",MACAddr[i]);
printf("\n");
TIM2_Init();
i = ETH_LibInit(IPAddr,GWIPAddr,IPMask,MACAddr); //Ethernet library initialize
mStopIfError(i);
if(i == WCHNET_ERR_SUCCESS) printf("WCHNET_LibInit Success\r\n");
#ifdef send_mail
if(send_mail) WCHNET_CreateTcpSmtp( );
WCHNET_SMTPInit( );
#endif
#ifdef receive_mail
if(receive_mail) WCHNET_CreateTcpPop3( );
WCHNET_POP3Init( );
#endif
while(1)
{
/*Ethernet library main task function,
* which needs to be called cyclically*/
WCHNET_MainTask();
/*Query the Ethernet global interrupt,
* if there is an interrupt, call the global interrupt handler*/
if(WCHNET_QueryGlobalInt())
{
WCHNET_HandleGlobalInt();
}
WCHNET_MailQuery( );
/*Process the received data*/
if(ReceDatFlag){
ReceDatFlag = 0;
WCHNET_MailCmd( OrderType );
}
}
}
+144
View File
@@ -0,0 +1,144 @@
/********************************** (C) COPYRIGHT *******************************
* File Name : net_config.h
* Author : WCH
* Version : V1.30
* Date : 2022/06/02
* Description : This file contains the configurations of
* Ethernet protocol stack 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 __NET_CONFIG_H__
#define __NET_CONFIG_H__
#ifdef __cplusplus
extern "C" {
#endif
/*********************************************************************
* socket configuration, IPRAW + UDP + TCP + TCP_LISTEN = number of sockets
*/
#define WCHNET_NUM_IPRAW 0 /* Number of IPRAW connections */
#define WCHNET_NUM_UDP 0 /* The number of UDP connections */
#define WCHNET_NUM_TCP 2 /* Number of TCP connections */
#define WCHNET_NUM_TCP_LISTEN 0 /* Number of TCP listening */
/* The number of sockets, the maximum is 31 */
#define WCHNET_MAX_SOCKET_NUM (WCHNET_NUM_IPRAW+WCHNET_NUM_UDP+WCHNET_NUM_TCP+WCHNET_NUM_TCP_LISTEN)
#define WCHNET_TCP_MSS 1460 /* Size of TCP MSS*/
/*********************************************************************
* MAC queue configuration
*/
#define ETH_TXBUFNB 1 /* The number of descriptors sent by the MAC */
#define ETH_RXBUFNB 4 /* Number of MAC received descriptors */
#ifndef ETH_MAX_PACKET_SIZE
#define ETH_RX_BUF_SZE 1520 /* MAC receive buffer length, an integer multiple of 4 */
#define ETH_TX_BUF_SZE 1520 /* MAC send buffer length, an integer multiple of 4 */
#else
#define ETH_RX_BUF_SZE ETH_MAX_PACKET_SIZE
#define ETH_TX_BUF_SZE ETH_MAX_PACKET_SIZE
#endif
/*********************************************************************
* Functional configuration
*/
#define WCHNET_PING_ENABLE 1 /* PING is enabled, PING is enabled by default */
#define TCP_RETRY_COUNT 20 /* The number of TCP retransmissions, the default value is 20 */
#define TCP_RETRY_PERIOD 10 /* TCP retransmission period, the default value is 10, the unit is 50ms */
#define SOCKET_SEND_RETRY 1 /* Send failed retry configuration, 1: enable, 0: disable */
#define CFG0_TCP_SEND_COPY 1 /* TCP send buffer copy, 1: copy, 0: not copy */
#define CFG0_TCP_RECV_COPY 1 /* TCP receive replication optimization, internal debugging use */
#define CFG0_TCP_OLD_DELETE 0 /* Delete oldest TCP connection, 1: enable, 0: disable */
/*********************************************************************
* Memory related configuration
*/
/*If a single socket cannot reach full speed,
* try to increase RECE_BUF_LEN to (WCHNET_TCP_MSS*4)
* and increase WCHNET_NUM_TCP_SEG to (WCHNET_NUM_TCP*4)*/
#define RECE_BUF_LEN (WCHNET_TCP_MSS*2) /* socket receive buffer size */
#define WCHNET_NUM_PBUF (WCHNET_MAX_SOCKET_NUM+WCHNET_NUM_TCP) /* Number of PBUF structures */
#define WCHNET_NUM_TCP_SEG (WCHNET_NUM_TCP*2) /* The number of TCP segments used to send */
#define WCHNET_MEM_HEAP_SIZE (((WCHNET_TCP_MSS+0x10+54)*WCHNET_NUM_TCP_SEG)+ETH_TX_BUF_SZE+64) /* memory heap size */
#define WCHNET_NUM_ARP_TABLE 50 /* Number of ARP lists */
#define WCHNET_NUM_IP_REASSDATA 4 /* Number of IP segments */
#define CFG0_IP_REASS_PBUFS 4 /* Number of reassembled IP PBUFs */
#define WCHNET_MEM_ALIGNMENT 4 /* 4 byte alignment */
#define WCHNET_NUM_POOL_BUF (WCHNET_NUM_TCP*2+2) /* The number of POOL BUFs, the number of receive queues */
/* Check the configuration of the SOCKET quantity */
#if( WCHNET_NUM_TCP_LISTEN && !WCHNET_NUM_TCP )
#error "WCHNET_NUM_TCP Error)"
#endif
/* Check byte alignment must be a multiple of 4 */
#if((WCHNET_MEM_ALIGNMENT % 4) || (WCHNET_MEM_ALIGNMENT == 0))
#error "WCHNET_MEM_ALIGNMENT Error,Please Config WCHNET_MEM_ALIGNMENT = 4 * N, N >=1"
#endif
/* TCP maximum segment length */
#if((WCHNET_TCP_MSS > 1460) || (WCHNET_TCP_MSS < 60))
#error "WCHNET_TCP_MSS Error,Please Config WCHNET_TCP_MSS >= 60 && WCHNET_TCP_MSS <= 1460"
#endif
/* Number of ARP cache tables */
#if((WCHNET_NUM_ARP_TABLE > 0X7F) || (WCHNET_NUM_ARP_TABLE < 1))
#error "WCHNET_NUM_ARP_TABLE Error,Please Config WCHNET_NUM_ARP_TABLE >= 1 && WCHNET_NUM_ARP_TABLE <= 0X7F"
#endif
/* Check POOL BUF configuration */
#if(WCHNET_NUM_POOL_BUF < 1)
#error "WCHNET_NUM_POOL_BUF Error,Please Config WCHNET_NUM_POOL_BUF >= 1"
#endif
/* Check PBUF structure configuration */
#if(WCHNET_NUM_PBUF < 1)
#error "WCHNET_NUM_PBUF Error,Please Config WCHNET_NUM_PBUF >= 1"
#endif
/* Check IP Assignment Configuration */
#if((WCHNET_NUM_IP_REASSDATA > 10) || (WCHNET_NUM_IP_REASSDATA < 1))
#error "WCHNET_NUM_IP_REASSDATA Error,Please Config WCHNET_NUM_IP_REASSDATA < 10 && WCHNET_NUM_IP_REASSDATA >= 1 "
#endif
/* Check the number of reassembled IP PBUFs */
#if(WCHNET_IP_REASS_PBUFS > WCHNET_NUM_POOL_BUF)
#error "WCHNET_IP_REASS_PBUFS Error,Please Config WCHNET_IP_REASS_PBUFS < WCHNET_NUM_POOL_BUF"
#endif
#if(WCHNETTIMERPERIOD > 50)
#error "WCHNETTIMERPERIOD Error,Please Config WCHNETTIMERPERIOD < 50"
#endif
/* Configuration value 0 */
#define WCHNET_MISC_CONFIG0 (((CFG0_TCP_SEND_COPY) << 0) |\
((CFG0_TCP_RECV_COPY) << 1) |\
((CFG0_TCP_OLD_DELETE) << 2) |\
((CFG0_IP_REASS_PBUFS) << 3) )
/* Configuration value 1 */
#define WCHNET_MISC_CONFIG1 (((WCHNET_MAX_SOCKET_NUM)<<0)|\
((WCHNET_PING_ENABLE) << 13) |\
((TCP_RETRY_COUNT) << 14) |\
((TCP_RETRY_PERIOD) << 19) |\
((SOCKET_SEND_RETRY) << 25) )
#ifdef __cplusplus
}
#endif
#endif
+990
View File
@@ -0,0 +1,990 @@
/********************************** (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/CH32V203RBT6)
* 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
* 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
+32
View File
@@ -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 */