RF_W13无卡设备
上传云端
This commit is contained in:
177
BLV_RF_W13_V04_20260114/.cproject
Normal file
177
BLV_RF_W13_V04_20260114/.cproject
Normal file
@@ -0,0 +1,177 @@
|
||||
<?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.abi.fp.962468442" name="Floating point ABI" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.abi.fp" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.abi.fp.none" valueType="enumerated"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.codemodel.1234945999" name="Code model" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.codemodel" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.codemodel.any" valueType="enumerated"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.atomic.985553432" name="Atomic extension (RVA)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.atomic" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.nocommon.1193890948" name="No common unitialized (-fno-common)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.nocommon" useByScannerDiscovery="true" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.rvGcc.1559804128" name="RISC-V Compiler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.rvGcc" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.rvGcc.12" valueType="enumerated"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.xw.2063668652" name="Extra Compressed extension (RVXW)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.xw" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.b.394692427" name="Bit extension (RVB)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.b" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.mrs.highcode.1573669418" name="Optimize unused sections declared as high code (--param=highcode-gen-section-name=1)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.mrs.highcode" 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:/Peripheral}/obj" id="ilg.gnumcueclipse.managedbuild.cross.riscv.builder.1421508906" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="GNU Make 构建器" 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="true" 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"/>
|
||||
<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=""${workspace_loc:/${ProjName}/Startup}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/StdPeriphDriver/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/HAL/include}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/Ld}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/LIB}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/RVMSIS}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/User_Drivers/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/User_Drivers}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/User/include}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/User}""/>
|
||||
</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="DEBUG=0"/>
|
||||
<listOptionValue builtIn="false" value="BLE_BUFF_MAX_LEN=128"/>
|
||||
</option>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="true" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.files.288896968" name="Include files (-include)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.files" useByScannerDiscovery="true" valueType="includeFiles"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.preprocessonly.1594987158" name="Preprocess only (-E)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.preprocessonly" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.nostdinc.698774408" name="Do not search system directories (-nostdinc)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.nostdinc" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<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=""../""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/LIB}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/StdPeriphDriver}""/>
|
||||
</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=""${workspace_loc:/${ProjName}/Ld/Link.ld}""/>
|
||||
</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 id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.strip.1780837525" name="Omit all symbol information (-s)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.strip" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.cref.1847421489" name="Cross reference (-Xlinker --cref)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.cref" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.printmap.548776282" name="Print link map (-Xlinker --print-map)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.printmap" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.libs.1350862782" name="Libraries (-l)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.libs" useByScannerDiscovery="false" valueType="libs">
|
||||
<listOptionValue builtIn="false" value="ISP572"/>
|
||||
<listOptionValue builtIn="false" value="m"/>
|
||||
<listOptionValue builtIn="false" value="CH572BLE_PERI"/>
|
||||
</option>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.flags.1577723329" name="Linker flags (-Xlinker [option])" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.flags" useByScannerDiscovery="false" valueType="stringList">
|
||||
<listOptionValue builtIn="false" value="--print-memory-usage"/>
|
||||
</option>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.useprintffloat.434730229" name="Use float with nano printf (-u _printf_float)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.useprintffloat" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.usescanffloat.1159645229" name="Use float with nano scanf (-u _scanf_float)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.usescanffloat" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.printfloat.738404448" name="Use wchprintfloat(-lprintfloat)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.printfloat" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.printf.2140849723" name="Use wchprintf(-lprintf)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.printf" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<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=""../LD""/>
|
||||
</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="true" 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="true" 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="true" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.other.108640181" name="Other flags" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.other" useByScannerDiscovery="false" value="" valueType="string"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.debugging.1148933762" name="Display debugging info (--debugging|-g)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.debugging" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.symbols.1099699088" name="Display symbols (--syms|-t)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.symbols" useByScannerDiscovery="false" value="false" 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>
|
||||
<sourceEntries>
|
||||
<entry excluding="Profile|LED.c|KEY.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="HAL"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="LIB"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="Ld"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="RVMSIS"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="Startup"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="StdPeriphDriver"/>
|
||||
<entry excluding="simpleBLEPeripheral.c|simpleBLEPeripheral_main.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="User"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="User_Drivers"/>
|
||||
</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" projectType="ilg.gnumcueclipse.managedbuild.cross.riscv.target.elf"/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
<scannerConfigBuildInfo instanceId="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.debug.767917625;ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.debug.767917625.;ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.1375371130;ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.input.1473381709">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.1008047074;ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.1008047074.;ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.1731377187;ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.input.2036806839">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</scannerConfigBuildInfo>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
|
||||
|
||||
</cproject>
|
||||
37
BLV_RF_W13_V04_20260114/.project
Normal file
37
BLV_RF_W13_V04_20260114/.project
Normal file
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<projectDescription>
|
||||
<name>BLV_RF_W13_V04</name>
|
||||
<comment/>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||
<triggers>clean,full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
|
||||
<triggers>full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.cdt.core.cnature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
||||
</natures>
|
||||
<filteredResources>
|
||||
<filter>
|
||||
<id>1760412127804</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>
|
||||
</projectDescription>
|
||||
14
BLV_RF_W13_V04_20260114/.settings/language.settings.xml
Normal file
14
BLV_RF_W13_V04_20260114/.settings/language.settings.xml
Normal file
@@ -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="1700981201444522483" 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 "${INPUTS}"" prefer-non-shared="true">
|
||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||
</provider>
|
||||
</extension>
|
||||
</configuration>
|
||||
</project>
|
||||
@@ -0,0 +1,73 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.cdt.codan.checkers.errnoreturn=Warning
|
||||
org.eclipse.cdt.codan.checkers.errnoreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"No return\\")",implicit\=>false}
|
||||
org.eclipse.cdt.codan.checkers.errreturnvalue=Error
|
||||
org.eclipse.cdt.codan.checkers.errreturnvalue.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused return value\\")"}
|
||||
org.eclipse.cdt.codan.checkers.nocommentinside=-Error
|
||||
org.eclipse.cdt.codan.checkers.nocommentinside.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Nesting comments\\")"}
|
||||
org.eclipse.cdt.codan.checkers.nolinecomment=-Error
|
||||
org.eclipse.cdt.codan.checkers.nolinecomment.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Line comments\\")"}
|
||||
org.eclipse.cdt.codan.checkers.noreturn=Error
|
||||
org.eclipse.cdt.codan.checkers.noreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"No return value\\")",implicit\=>false}
|
||||
org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Abstract class cannot be instantiated\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Ambiguous problem\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Assignment in condition\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Assignment to itself\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"No break at end of case\\")",no_break_comment\=>"no break",last_case_param\=>false,empty_case_param\=>false,enable_fallthrough_quickfix_param\=>false}
|
||||
org.eclipse.cdt.codan.internal.checkers.CatchByReference=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.CatchByReference.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Catching by reference is recommended\\")",unknown\=>false,exceptions\=>()}
|
||||
org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Circular inheritance\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Class members should be properly initialized\\")",skip\=>true}
|
||||
org.eclipse.cdt.codan.internal.checkers.DecltypeAutoProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.DecltypeAutoProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid 'decltype(auto)' specifier\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Field cannot be resolved\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Function cannot be resolved\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.InvalidArguments=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.InvalidArguments.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid arguments\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid template argument\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Label statement not found\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Member declaration not found\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Method cannot be resolved\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker=-Info
|
||||
org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Name convention for function\\")",pattern\=>"^[a-z]",macro\=>true,exceptions\=>()}
|
||||
org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Class has a virtual method and non-virtual destructor\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.OverloadProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.OverloadProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid overload\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid redeclaration\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid redefinition\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem=-Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Return with parenthesis\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem=-Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Format String Vulnerability\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Statement has no effect\\")",macro\=>true,exceptions\=>()}
|
||||
org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Suggested parenthesis around expression\\")",paramNot\=>false}
|
||||
org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Suspicious semicolon\\")",else\=>false,afterelse\=>false}
|
||||
org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Type cannot be resolved\\")"}
|
||||
org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused function declaration\\")",macro\=>true}
|
||||
org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused static function\\")",macro\=>true}
|
||||
org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused variable declaration in file scope\\")",macro\=>true,exceptions\=>("@(\#)","$Id")}
|
||||
org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Symbol is not resolved\\")"}
|
||||
@@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
formatter_settings_version=1
|
||||
@@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false
|
||||
18
BLV_RF_W13_V04_20260114/.template
Normal file
18
BLV_RF_W13_V04_20260114/.template
Normal file
@@ -0,0 +1,18 @@
|
||||
Vendor=WCH
|
||||
Toolchain=RISC-V
|
||||
Series=CH32L103
|
||||
RTOS=NoneOS
|
||||
MCU=CH572D
|
||||
Link=WCH-Link
|
||||
PeripheralVersion======1.0
|
||||
Description======
|
||||
Mcu Type=CH570/2
|
||||
Address=0x00000000
|
||||
Target Path=obj\Peripheral_2.hex
|
||||
CLKSpeed=1
|
||||
DebugInterfaceMode=1
|
||||
Erase All=true
|
||||
Program=true
|
||||
Verify=true
|
||||
Reset=true
|
||||
SDIPrintf=false
|
||||
129
BLV_RF_W13_V04_20260114/.trae/documents/CH572D BLE项目优化建议.md
Normal file
129
BLV_RF_W13_V04_20260114/.trae/documents/CH572D BLE项目优化建议.md
Normal file
@@ -0,0 +1,129 @@
|
||||
## 代码结构与可读性优化
|
||||
|
||||
1. **函数拆分**
|
||||
- 将过长的函数(如`Blv_CardlessPower_Tack`超过800行)拆分为多个子函数,提高可读性和维护性
|
||||
- 按功能模块划分函数,如状态检测、条件判断、事件处理等
|
||||
|
||||
2. **注释规范**
|
||||
- 采用Doxygen格式注释,便于生成文档
|
||||
- 为关键算法和复杂逻辑添加详细注释
|
||||
- 为宏定义和常量添加说明,避免魔法数字
|
||||
|
||||
3. **命名规范**
|
||||
- 统一变量和函数命名风格,使用驼峰命名法或下划线命名法
|
||||
- 为常量和宏定义使用有意义的名称,避免缩写过度
|
||||
|
||||
## 性能优化
|
||||
|
||||
1. **主循环优化**
|
||||
- 减少主循环中的不必要计算,将耗时操作移至定时器或事件中
|
||||
- 优化函数调用顺序,将频繁调用的函数优先处理
|
||||
|
||||
2. **传感器检测优化**
|
||||
- 动态调整传感器采样频率,根据系统状态(有人/无人)调整
|
||||
- 优化长时间检测算法,减少循环计算量
|
||||
- 考虑使用位操作替代字节操作,提高处理速度
|
||||
|
||||
3. **BLE通信优化**
|
||||
- 优化BLE通知频率,避免频繁发送数据
|
||||
- 合理设置MTU大小,减少数据包数量
|
||||
- 优化连接参数,平衡功耗和响应速度
|
||||
|
||||
## 内存管理优化
|
||||
|
||||
1. **静态内存优化**
|
||||
- 根据实际需求调整数组大小,如`portBuff`、`print_BLE`等
|
||||
- 避免定义过大的全局数组,减少静态内存占用
|
||||
|
||||
2. **动态内存管理**
|
||||
- 为频繁分配的内存(如BLE通知数据)实现内存池
|
||||
- 确保动态分配的内存及时释放,避免内存泄漏
|
||||
- 考虑使用静态分配替代部分动态分配,提高可靠性
|
||||
|
||||
3. **缓冲区优化**
|
||||
- 优化环形缓冲区算法,提高读写效率
|
||||
- 为不同功能使用独立的缓冲区,避免数据冲突
|
||||
|
||||
## BLE通信优化
|
||||
|
||||
1. **连接管理优化**
|
||||
- 优化BLE广播间隔,平衡 discoverability 和功耗
|
||||
- 实现快速重连机制,提高用户体验
|
||||
- 优化连接参数更新策略,减少连接中断
|
||||
|
||||
2. **GATT服务优化**
|
||||
- 精简GATT服务和特征值,只保留必要的功能
|
||||
- 优化特征值的读写权限,提高安全性
|
||||
- 考虑使用BLE 5.0的长包特性,提高数据传输效率
|
||||
|
||||
3. **MTU协商优化**
|
||||
- 提前进行MTU协商,在连接建立后立即执行
|
||||
- 根据实际数据传输需求设置合理的MTU大小
|
||||
|
||||
## 传感器检测算法优化
|
||||
|
||||
1. **滤波算法**
|
||||
- 为传感器数据添加滤波算法(如滑动平均、中值滤波),减少噪声干扰
|
||||
- 实现自适应阈值调整,提高检测准确性
|
||||
|
||||
2. **长时间检测优化**
|
||||
- 优化环形缓冲区的读写逻辑,减少计算量
|
||||
- 考虑使用更高效的统计方法,如加权平均等
|
||||
- 为不同传感器设置不同的检测阈值,提高灵活性
|
||||
|
||||
3. **状态转换优化**
|
||||
- 优化有人/无人状态转换的条件判断,提高响应速度
|
||||
- 实现更平滑的状态转换,避免频繁切换
|
||||
|
||||
## 鲁棒性与可靠性优化
|
||||
|
||||
1. **错误处理**
|
||||
- 为BLE通信添加错误处理机制,如连接失败、数据传输错误等
|
||||
- 为传感器检测添加异常处理,如端口状态异常等
|
||||
- 实现系统状态监控,及时发现和恢复异常
|
||||
|
||||
2. **看门狗优化**
|
||||
- 合理设置看门狗超时时间,平衡可靠性和系统响应
|
||||
- 为不同任务模块设置独立的看门狗喂狗点
|
||||
|
||||
3. **数据完整性**
|
||||
- 为重要数据添加校验机制,如CRC校验
|
||||
- 实现数据备份和恢复机制,提高数据可靠性
|
||||
|
||||
## 电源管理优化
|
||||
|
||||
1. **低功耗模式**
|
||||
- 实现空闲时自动进入低功耗模式,降低功耗
|
||||
- 优化BLE通信的功耗,如减少广播时间、优化连接间隔等
|
||||
- 为传感器检测添加唤醒机制,只在需要时唤醒系统
|
||||
|
||||
2. **动态功耗调整**
|
||||
- 根据系统状态动态调整功耗模式,如有人时提高性能,无人时降低功耗
|
||||
- 优化时钟频率,根据实际需求调整
|
||||
|
||||
3. **电源监控**
|
||||
- 添加电源电压监控,及时发现电源异常
|
||||
- 实现电源故障处理机制,提高系统可靠性
|
||||
|
||||
## 测试与调试优化
|
||||
|
||||
1. **调试信息分级**
|
||||
- 实现分级调试信息,根据需求开启不同级别的调试
|
||||
- 为BLE通信、传感器检测、事件处理等添加独立的调试开关
|
||||
|
||||
2. **测试用例**
|
||||
- 为关键功能编写测试用例,提高测试覆盖率
|
||||
- 实现自动化测试,提高测试效率
|
||||
|
||||
3. **性能分析**
|
||||
- 添加性能分析工具,如代码覆盖率、执行时间统计等
|
||||
- 定期进行性能测试,发现和优化瓶颈
|
||||
|
||||
## 实施建议
|
||||
|
||||
1. **分阶段实施**:按照优先级分阶段实施优化,先解决关键问题
|
||||
2. **测试验证**:每阶段优化后进行充分测试,确保功能正常
|
||||
3. **文档更新**:及时更新文档,记录优化内容和效果
|
||||
4. **持续优化**:建立持续优化机制,定期 review 代码和性能
|
||||
|
||||
这些优化建议将有助于提高系统的性能、可靠性和可维护性,同时降低功耗,提升用户体验。
|
||||
BIN
BLV_RF_W13_V04_20260114/BLV_RF_W13_V04.wvproj
Normal file
BIN
BLV_RF_W13_V04_20260114/BLV_RF_W13_V04.wvproj
Normal file
Binary file not shown.
228
BLV_RF_W13_V04_20260114/HAL/MCU.c
Normal file
228
BLV_RF_W13_V04_20260114/HAL/MCU.c
Normal file
@@ -0,0 +1,228 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : MCU.c
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2022/01/18
|
||||
* Description : Ӳ<><D3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>BLE<4C><45>Ӳ<EFBFBD><D3B2><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
|
||||
*********************************************************************************
|
||||
* 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.
|
||||
*******************************************************************************/
|
||||
|
||||
/******************************************************************************/
|
||||
/* ͷ<>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD> */
|
||||
#include "HAL.h"
|
||||
|
||||
tmosTaskID halTaskID;
|
||||
uint32_t g_LLE_IRQLibHandlerLocation;
|
||||
|
||||
#if(defined(BLE_SNV)) && (BLE_SNV == TRUE)
|
||||
/*******************************************************************************
|
||||
* @fn Lib_Read_Flash
|
||||
*
|
||||
* @brief Callback function used for BLE lib.
|
||||
*
|
||||
* @param addr - Read start address
|
||||
* @param num - Number of units to read (unit: 4 bytes)
|
||||
* @param pBuf - Buffer to store read data
|
||||
*
|
||||
* @return None.
|
||||
*/
|
||||
uint32_t Lib_Read_Flash(uint32_t addr, uint32_t num, uint32_t *pBuf)
|
||||
{
|
||||
FLASH_ROM_READ(addr, pBuf, num * 4);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* @fn Lib_Write_Flash
|
||||
*
|
||||
* @brief Callback function used for BLE lib.
|
||||
*
|
||||
* @param addr - Write start address
|
||||
* @param num - Number of units to write (unit: 4 bytes)
|
||||
* @param pBuf - Buffer with data to be written
|
||||
*
|
||||
* @return None.
|
||||
*/
|
||||
uint32_t Lib_Write_Flash(uint32_t addr, uint32_t num, uint32_t *pBuf)
|
||||
{
|
||||
FLASH_ROM_ERASE(addr, num * 4);
|
||||
FLASH_ROM_WRITE(addr, pBuf, num * 4);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* @fn CH57x_BLEInit
|
||||
*
|
||||
* @brief BLE <20><><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @return None.
|
||||
*/
|
||||
void CH57x_BLEInit(void)
|
||||
{
|
||||
uint8_t i;
|
||||
bleConfig_t cfg;
|
||||
if(tmos_memcmp(VER_LIB, VER_FILE, strlen(VER_FILE)) == FALSE)
|
||||
{
|
||||
PRINT("head file error...\n");
|
||||
while(1);
|
||||
}
|
||||
|
||||
//__SysTick_Config(SysTick_LOAD_RELOAD_Msk);// <20><><EFBFBD><EFBFBD>SysTick
|
||||
SysTick_Config(FREQ_SYS/10000);
|
||||
|
||||
sys_safe_access_enable( );
|
||||
R32_MISC_CTRL = (R32_MISC_CTRL&(~(0x3f<<24)))|(0xe<<24);
|
||||
sys_safe_access_disable( );
|
||||
g_LLE_IRQLibHandlerLocation = (uint32_t)LLE_IRQLibHandler;
|
||||
PFIC_SetPriority(BLEL_IRQn, 0xF0);
|
||||
tmos_memset(&cfg, 0, sizeof(bleConfig_t));
|
||||
cfg.MEMAddr = (uint32_t)MEM_BUF;
|
||||
cfg.MEMLen = (uint32_t)BLE_MEMHEAP_SIZE;
|
||||
cfg.BufMaxLen = (uint32_t)BLE_BUFF_MAX_LEN;
|
||||
cfg.BufNumber = (uint32_t)BLE_BUFF_NUM;
|
||||
cfg.TxNumEvent = (uint32_t)BLE_TX_NUM_EVENT;
|
||||
cfg.TxPower = (uint32_t)BLE_TX_POWER;
|
||||
cfg.WindowWidening = 120;
|
||||
#if(defined(BLE_SNV)) && (BLE_SNV == TRUE)
|
||||
if((BLE_SNV_ADDR + BLE_SNV_BLOCK * BLE_SNV_NUM) > (0x40000))
|
||||
{
|
||||
PRINT("SNV config error...\n");
|
||||
while(1);
|
||||
}
|
||||
cfg.SNVAddr = (uint32_t)BLE_SNV_ADDR;
|
||||
cfg.SNVBlock = (uint32_t)BLE_SNV_BLOCK;
|
||||
cfg.SNVNum = (uint32_t)BLE_SNV_NUM;
|
||||
cfg.readFlashCB = Lib_Read_Flash;
|
||||
cfg.writeFlashCB = Lib_Write_Flash;
|
||||
#endif
|
||||
cfg.srandCB = SYS_GetSysTickCnt;
|
||||
#if(defined(HAL_SLEEP)) && (HAL_SLEEP == TRUE)
|
||||
cfg.idleCB = CH57x_LowPower; // <20><><EFBFBD><EFBFBD>˯<EFBFBD><CBAF>
|
||||
#endif
|
||||
#if(defined(BLE_MAC)) && (BLE_MAC == TRUE)
|
||||
for(i = 0; i < 6; i++)
|
||||
{
|
||||
cfg.MacAddr[i] = MacAddr[5 - i];
|
||||
}
|
||||
#else
|
||||
{
|
||||
uint8_t MacAddr[6];
|
||||
GetMACAddress(MacAddr);
|
||||
for(i = 0; i < 6; i++)
|
||||
{
|
||||
cfg.MacAddr[i] = MacAddr[i]; // ʹ<><CAB9>оƬmac<61><63>ַ
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if(!cfg.MEMAddr || cfg.MEMLen < 3 * 1024)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
// BLE_Lib ռ<><D5BC><EFBFBD><EFBFBD>VTF Interrupt 2<>ź<EFBFBD>3<EFBFBD><33>
|
||||
i = BLE_LibInit(&cfg);
|
||||
if(i)
|
||||
{
|
||||
PRINT("LIB init error code: %x ...\n", i);
|
||||
while(1);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* @fn HAL_ProcessEvent
|
||||
*
|
||||
* @brief Ӳ<><D3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param task_id - The TMOS assigned task ID.
|
||||
* @param events - events to process. This is a bit map and can
|
||||
* contain more than one event.
|
||||
*
|
||||
* @return events.
|
||||
*/
|
||||
tmosEvents HAL_ProcessEvent(tmosTaskID task_id, tmosEvents events)
|
||||
{
|
||||
uint8_t *msgPtr;
|
||||
|
||||
if(events & SYS_EVENT_MSG)
|
||||
{ // <20><><EFBFBD><EFBFBD>HAL<41><4C><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>tmos_msg_receive<76><65>ȡ<EFBFBD><C8A1>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɺ<EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>
|
||||
msgPtr = tmos_msg_receive(task_id);
|
||||
if(msgPtr)
|
||||
{
|
||||
/* De-allocate */
|
||||
tmos_msg_deallocate(msgPtr);
|
||||
}
|
||||
return events ^ SYS_EVENT_MSG;
|
||||
}
|
||||
if(events & LED_BLINK_EVENT)
|
||||
{
|
||||
#if(defined HAL_LED) && (HAL_LED == TRUE)
|
||||
HalLedUpdate();
|
||||
#endif // HAL_LED
|
||||
return events ^ LED_BLINK_EVENT;
|
||||
}
|
||||
if(events & HAL_KEY_EVENT)
|
||||
{
|
||||
#if(defined HAL_KEY) && (HAL_KEY == TRUE)
|
||||
HAL_KeyPoll(); /* Check for keys */
|
||||
tmos_start_task(halTaskID, HAL_KEY_EVENT, MS1_TO_SYSTEM_TIME(100));
|
||||
return events ^ HAL_KEY_EVENT;
|
||||
#endif
|
||||
}
|
||||
if(events & HAL_REG_INIT_EVENT)
|
||||
{
|
||||
#if(defined BLE_CALIBRATION_ENABLE) && (BLE_CALIBRATION_ENABLE == TRUE) // У<D0A3><D7BC><EFBFBD><EFBFBD><F1A3ACB5><EFBFBD>У<D0A3><D7BC>ʱС<CAB1><D0A1>10ms
|
||||
uint8_t state;
|
||||
bleClockConfig_t conf;
|
||||
|
||||
BLE_RegInit(); // УRF<52><46><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD>RF<52><46><EFBFBD>ı<EFBFBD>RF<52><46><EFBFBD>ؼĴ<D8BC><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD>RF<52>շ<EFBFBD><D5B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>У<D0A3><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
lsiFrq = RTC_InitClock( Count_1024 );
|
||||
conf = BLE_ClockConfig(lsiFrq);
|
||||
state = TMOS_TimerSet(&conf);
|
||||
LSIWakeup_MaxTime = GET_WakeUpLSIMaxTime();
|
||||
tmos_start_task(halTaskID, HAL_REG_INIT_EVENT, MS1_TO_SYSTEM_TIME(BLE_CALIBRATION_PERIOD));
|
||||
return events ^ HAL_REG_INIT_EVENT;
|
||||
#endif
|
||||
}
|
||||
if(events & HAL_TEST_EVENT)
|
||||
{
|
||||
PRINT("* \n");
|
||||
tmos_start_task(halTaskID, HAL_TEST_EVENT, MS1_TO_SYSTEM_TIME(1000));
|
||||
return events ^ HAL_TEST_EVENT;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* @fn HAL_Init
|
||||
*
|
||||
* @brief Ӳ<><D3B2><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @return None.
|
||||
*/
|
||||
void HAL_Init()
|
||||
{
|
||||
halTaskID = TMOS_ProcessEventRegister(HAL_ProcessEvent);
|
||||
HAL_TimeInit();
|
||||
#if(defined HAL_SLEEP) && (HAL_SLEEP == TRUE)
|
||||
HAL_SleepInit();
|
||||
#endif
|
||||
#if(defined HAL_LED) && (HAL_LED == TRUE)
|
||||
HAL_LedInit();
|
||||
#endif
|
||||
#if(defined HAL_KEY) && (HAL_KEY == TRUE)
|
||||
HAL_KeyInit();
|
||||
#endif
|
||||
#if(defined BLE_CALIBRATION_ENABLE) && (BLE_CALIBRATION_ENABLE == TRUE)
|
||||
tmos_start_task(halTaskID, HAL_REG_INIT_EVENT, 800); // <20><><EFBFBD><EFBFBD>У<D0A3><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>500ms<6D><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<D0A3><D7BC>ʱС<CAB1><D0A1>10ms
|
||||
#endif
|
||||
// tmos_start_task( halTaskID, HAL_TEST_EVENT, 1600 ); // <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
|
||||
/******************************** endfile @ mcu ******************************/
|
||||
132
BLV_RF_W13_V04_20260114/HAL/RTC.c
Normal file
132
BLV_RF_W13_V04_20260114/HAL/RTC.c
Normal file
@@ -0,0 +1,132 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : RTC.c
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2022/01/18
|
||||
* Description : RTC<54><43><EFBFBD>ü<EFBFBD><C3BC><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
|
||||
*********************************************************************************
|
||||
* 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.
|
||||
*******************************************************************************/
|
||||
|
||||
/******************************************************************************/
|
||||
/* ͷ<>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD> */
|
||||
#include "HAL.h"
|
||||
|
||||
/*********************************************************************
|
||||
* CONSTANTS
|
||||
*/
|
||||
|
||||
/***************************************************
|
||||
* Global variables
|
||||
*/
|
||||
volatile uint32_t RTCTigFlag;
|
||||
|
||||
#define US_TO_TICK(us) (uint32_t)((us)/(1000000/(CAB_LSIFQ)))
|
||||
#define SLEEP_WAIT_HSE_TIME US_TO_TICK(2400)
|
||||
#define RTC_MAX_COUNT 0xA8C00000
|
||||
uint32_t lsiFrq;
|
||||
|
||||
/*******************************************************************************
|
||||
* @fn RTC_SetTignTime
|
||||
*
|
||||
* @brief <20><><EFBFBD><EFBFBD>RTC<54><43><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
*
|
||||
* @param time - <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>.
|
||||
*
|
||||
* @return None.
|
||||
*/
|
||||
void RTC_SetTignTime(uint32_t time)
|
||||
{
|
||||
sys_safe_access_enable();
|
||||
R32_RTC_TRIG = time;
|
||||
sys_safe_access_disable();
|
||||
RTCTigFlag = 0;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* @fn RTC_IRQHandler
|
||||
*
|
||||
* @brief RTC<54>жϴ<D0B6><CFB4><EFBFBD>
|
||||
*
|
||||
* @param None.
|
||||
*/
|
||||
__INTERRUPT
|
||||
__HIGH_CODE
|
||||
void RTC_IRQHandler( void )
|
||||
{
|
||||
R8_RTC_FLAG_CTRL =(RB_RTC_TMR_CLR|RB_RTC_TRIG_CLR);
|
||||
RTCTigFlag = 1;
|
||||
}
|
||||
|
||||
__HIGH_CODE
|
||||
static uint32_t SYS_GetClockValue(void)
|
||||
{
|
||||
uint32_t volatile rtc_count;
|
||||
do{
|
||||
rtc_count = R32_RTC_CNT_LSI;
|
||||
}while( rtc_count != R32_RTC_CNT_LSI);
|
||||
return rtc_count;
|
||||
}
|
||||
|
||||
__HIGH_CODE
|
||||
static void SYS_SetPendingIRQ(void)
|
||||
{
|
||||
PFIC_SetPendingIRQ( RTC_IRQn );
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* @fn BLE_ClockConfig
|
||||
*
|
||||
* @brief BLE_ClockConfig
|
||||
*
|
||||
* @param conf.
|
||||
*/
|
||||
bleClockConfig_t BLE_ClockConfig(uint32_t lsifreq)
|
||||
{
|
||||
bleClockConfig_t conf;
|
||||
|
||||
conf.ClockAccuracy = 2500;
|
||||
conf.ClockFrequency = lsifreq;
|
||||
conf.ClockMaxCount = RTC_MAX_COUNT;
|
||||
conf.getClockValue = SYS_GetClockValue;
|
||||
conf.SetPendingIRQ = SYS_SetPendingIRQ;
|
||||
|
||||
return conf;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* @fn HAL_Time0Init
|
||||
*
|
||||
* @brief ϵͳ<CFB5><CDB3>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @return None.
|
||||
*/
|
||||
void HAL_TimeInit(void)
|
||||
{
|
||||
bleClockConfig_t conf;
|
||||
|
||||
sys_safe_access_enable();
|
||||
R8_LSI_CONFIG |= RB_CLK_LSI_PON;
|
||||
sys_safe_access_disable();
|
||||
|
||||
lsiFrq = RTC_InitClock( Count_1024 );
|
||||
|
||||
PRINT("lsiFrq = %d\n",lsiFrq);
|
||||
|
||||
RTC_InitTime( 2021,1,28,0,0,0 );
|
||||
|
||||
conf = BLE_ClockConfig(lsiFrq);
|
||||
TMOS_TimerInit( &conf );
|
||||
|
||||
sys_safe_access_enable();
|
||||
__nop();__nop();
|
||||
R8_RTC_MODE_CTRL |= RB_RTC_TRIG_EN; // <20><><EFBFBD><EFBFBD>ģʽ
|
||||
sys_safe_access_disable();
|
||||
PFIC_EnableIRQ(RTC_IRQn);
|
||||
}
|
||||
|
||||
/******************************** endfile @ time ******************************/
|
||||
117
BLV_RF_W13_V04_20260114/HAL/SLEEP.c
Normal file
117
BLV_RF_W13_V04_20260114/HAL/SLEEP.c
Normal file
@@ -0,0 +1,117 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : SLEEP.c
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2022/01/18
|
||||
* Description : ˯<><CBAF><EFBFBD><EFBFBD><EFBFBD>ü<EFBFBD><C3BC><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
|
||||
*********************************************************************************
|
||||
* 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.
|
||||
*******************************************************************************/
|
||||
|
||||
/******************************************************************************/
|
||||
/* ͷ<>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD> */
|
||||
#include "HAL.h"
|
||||
|
||||
uint16_t LSIWakeup_MaxTime;
|
||||
|
||||
/*******************************************************************************
|
||||
* @fn CH57x_LowPower
|
||||
*
|
||||
* @brief <20><><EFBFBD><EFBFBD>˯<EFBFBD><CBAF>
|
||||
*
|
||||
* @param time - <20><><EFBFBD>ѵ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>㣨RTC<54><43><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>
|
||||
*
|
||||
* @return state.
|
||||
*/
|
||||
uint32_t CH57x_LowPower(uint32_t time)
|
||||
{
|
||||
#if(defined(HAL_SLEEP)) && (HAL_SLEEP == TRUE)
|
||||
volatile uint32_t i;
|
||||
uint32_t time_tign, time_sleep, time_curr;
|
||||
unsigned long irq_status;
|
||||
|
||||
// <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>
|
||||
if (time <= LSIWakeup_MaxTime) {
|
||||
time_tign = time + (RTC_MAX_COUNT - LSIWakeup_MaxTime);
|
||||
} else {
|
||||
time_tign = time - LSIWakeup_MaxTime;
|
||||
}
|
||||
|
||||
SYS_DisableAllIrq(&irq_status);
|
||||
time_curr = RTC_GetCycleLSI();
|
||||
// <20><><EFBFBD><EFBFBD>˯<EFBFBD><CBAF>ʱ<EFBFBD><CAB1>
|
||||
if (time_tign < time_curr) {
|
||||
time_sleep = time_tign + (RTC_MAX_COUNT - time_curr);
|
||||
} else {
|
||||
time_sleep = time_tign - time_curr;
|
||||
}
|
||||
|
||||
// <20><>˯<EFBFBD><CBAF>ʱ<EFBFBD><CAB1>С<EFBFBD><D0A1><EFBFBD><EFBFBD>С˯<D0A1><CBAF>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˯<EFBFBD><CBAF>ʱ<EFBFBD>䣬<EFBFBD><E4A3AC><EFBFBD><EFBFBD>˯<EFBFBD><CBAF>
|
||||
if ((time_sleep < SLEEP_RTC_MIN_TIME) ||
|
||||
(time_sleep > SLEEP_RTC_MAX_TIME)) {
|
||||
SYS_RecoverIrq(irq_status);
|
||||
return 2;
|
||||
}
|
||||
|
||||
RTC_SetTignTime(time_tign);
|
||||
SYS_RecoverIrq(irq_status);
|
||||
#if(DEBUG == Debug_UART0) // ʹ<><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӡ<EFBFBD><D3A1>Ϣ<EFBFBD><CFA2>Ҫ<EFBFBD><EFBFBD><DEB8><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD>
|
||||
while((R8_UART_LSR & RB_LSR_TX_ALL_EMP) == 0)
|
||||
{
|
||||
__nop();
|
||||
}
|
||||
#endif
|
||||
// LOW POWER-sleepģʽ
|
||||
if(!RTCTigFlag)
|
||||
{
|
||||
LowPower_Sleep(RB_PWR_RAM12K | RB_PWR_EXTEND | RB_XT_PRE_EN );
|
||||
HSECFG_Current(HSE_RCur_100); // <20><>Ϊ<EFBFBD><EFBFBD><EEB6A8><EFBFBD><EFBFBD>(<28><EFBFBD><CDB9>ĺ<EFBFBD><C4BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>HSEƫ<45>õ<EFBFBD><C3B5><EFBFBD>)
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
return 3;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* @fn GET_WakeUpLSIMaxTime
|
||||
*
|
||||
* @brief <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
*
|
||||
* @param none
|
||||
*/
|
||||
uint16_t GET_WakeUpLSIMaxTime(void)
|
||||
{
|
||||
uint16_t pre_time;
|
||||
|
||||
pre_time = RTC_TO_US(45)+200;
|
||||
pre_time = pre_time > 1600 ? pre_time:1600;
|
||||
pre_time = US_TO_RTC(pre_time);
|
||||
|
||||
return pre_time;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* @fn HAL_SleepInit
|
||||
*
|
||||
* @brief <20><><EFBFBD><EFBFBD>˯<EFBFBD><EFBFBD><DFBB>ѵķ<D1B5>ʽ - RTC<54><43><EFBFBD>ѣ<EFBFBD><D1A3><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @return None.
|
||||
*/
|
||||
void HAL_SleepInit(void)
|
||||
{
|
||||
#if(defined(HAL_SLEEP)) && (HAL_SLEEP == TRUE)
|
||||
sys_safe_access_enable();
|
||||
R8_SLP_WAKE_CTRL |= RB_SLP_RTC_WAKE; // RTC<54><43><EFBFBD><EFBFBD>
|
||||
sys_safe_access_disable();
|
||||
sys_safe_access_enable();
|
||||
R8_RTC_MODE_CTRL |= RB_RTC_TRIG_EN; // <20><><EFBFBD><EFBFBD>ģʽ
|
||||
sys_safe_access_disable();
|
||||
PFIC_EnableIRQ(RTC_IRQn);
|
||||
LSIWakeup_MaxTime = GET_WakeUpLSIMaxTime();
|
||||
// PRINT("Pre_time %d\n",LSIWakeup_MaxTime);
|
||||
#endif
|
||||
}
|
||||
142
BLV_RF_W13_V04_20260114/HAL/include/CONFIG.h
Normal file
142
BLV_RF_W13_V04_20260114/HAL/include/CONFIG.h
Normal file
@@ -0,0 +1,142 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CONFIG.h
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2022/01/18
|
||||
* Description : <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD>Ĭ<EFBFBD><C4AC>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڹ<EFBFBD><DAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<DEB8>ǰֵ
|
||||
*********************************************************************************
|
||||
* 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 __CONFIG_H
|
||||
#define __CONFIG_H
|
||||
|
||||
|
||||
#define CHIP_ID ID_CH572
|
||||
|
||||
#ifdef CH57xBLE_ROM
|
||||
#include "CH57xBLE_ROM.h"
|
||||
#else
|
||||
#include "CH572BLEPeri_LIB.h"
|
||||
#endif
|
||||
|
||||
#include "CH57x_common.h"
|
||||
|
||||
/*********************************************************************
|
||||
<20><>MAC<41><43>
|
||||
BLE_MAC - <20>Ƿ<EFBFBD><C7B7>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Mac<61><63>ַ ( Ĭ<><C4AC>:FALSE - ʹ<><CAB9>оƬMac<61><63>ַ )<29><><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>main.c<><EFBFBD>Mac<61><63>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>
|
||||
|
||||
<20><>SLEEP<45><50>
|
||||
HAL_SLEEP - <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>˯<EFBFBD>߹<EFBFBD><DFB9><EFBFBD> ( Ĭ<><C4AC>:FALSE )
|
||||
SLEEP_RTC_MIN_TIME - <20>ǿ<EFBFBD><C7BF><EFBFBD>ģʽ<C4A3><CABD>˯<EFBFBD>ߵ<EFBFBD><DFB5><EFBFBD>Сʱ<D0A1>䣨<EFBFBD><E4A3A8>λ<EFBFBD><CEBB>һ<EFBFBD><D2BB>RTC<54><43><EFBFBD>ڣ<EFBFBD>
|
||||
SLEEP_RTC_MAX_TIME - <20>ǿ<EFBFBD><C7BF><EFBFBD>ģʽ<C4A3><CABD>˯<EFBFBD>ߵ<EFBFBD><DFB5><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>䣨<EFBFBD><E4A3A8>λ<EFBFBD><CEBB>һ<EFBFBD><D2BB>RTC<54><43><EFBFBD>ڣ<EFBFBD>
|
||||
WAKE_UP_RTC_MAX_TIME - <20>ȴ<EFBFBD>32M<32><4D><EFBFBD><EFBFBD><EFBFBD>ȶ<EFBFBD>ʱ<EFBFBD>䣨<EFBFBD><E4A3A8>λ<EFBFBD><CEBB>һ<EFBFBD><D2BB>RTC<54><43><EFBFBD>ڣ<EFBFBD>
|
||||
<20><><EFBFBD>ݲ<EFBFBD>ͬ˯<CDAC><CBAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡֵ<C8A1>ɷ<EFBFBD>Ϊ<EFBFBD><CEAA> ˯<><CBAF>ģʽ/<2F>µ<EFBFBD>ģʽ - 45 (Ĭ<><C4AC>)
|
||||
<20><>ͣģʽ - 45
|
||||
<20><><EFBFBD><EFBFBD>ģʽ - 5
|
||||
<20><>TEMPERATION<4F><4E>
|
||||
TEM_SAMPLE - <20>Ƿ<EFBFBD><C7B7><EFBFBD><F2BFAAB8><EFBFBD><EFBFBD>¶ȱ仯У<D0A3>Ĺ<EFBFBD><C4B9>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD><EFBFBD>У<D0A3><D7BC>ʱС<CAB1><D0A1>10ms( Ĭ<><C4AC>:TRUE )
|
||||
|
||||
<20><>CALIBRATION<4F><4E>
|
||||
BLE_CALIBRATION_ENABLE - <20>Ƿ<EFBFBD><C7B7><EFBFBD>ʱУ<D0A3>Ĺ<EFBFBD><C4B9>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD><EFBFBD>У<D0A3><D7BC>ʱС<CAB1><D0A1>10ms( Ĭ<><C4AC>:TRUE )
|
||||
BLE_CALIBRATION_PERIOD - <20><>ʱУ<D0A3><D7BC><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD>λms( Ĭ<><C4AC>:120000 )
|
||||
|
||||
<20><>SNV<4E><56>
|
||||
BLE_SNV - <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>SNV<4E><56><EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ( Ĭ<><C4AC>:TRUE )
|
||||
BLE_SNV_ADDR - SNV<4E><56>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7>ʹ<EFBFBD><CAB9>data flash<73><68><EFBFBD><EFBFBD>512<31>ֽ<EFBFBD>( Ĭ<><C4AC>:0x77E00 )
|
||||
BLE_SNV_BLOCK - SNV<4E><56>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С( Ĭ<><C4AC>:256 )
|
||||
BLE_SNV_NUM - SNV<4E><56>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>( Ĭ<><C4AC>:1 )
|
||||
|
||||
<20><>RTC<54><43>
|
||||
CLK_OSC32K - RTCʱ<43><CAB1>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD>ⲿ32K( 0 <20>ⲿ(32768Hz)<29><>Ĭ<EFBFBD><C4AC>:1<><31><EFBFBD>ڲ<EFBFBD>(32000Hz)<29><>2<EFBFBD><32><EFBFBD>ڲ<EFBFBD>(32768Hz) )
|
||||
|
||||
<20><>MEMORY<52><59>
|
||||
BLE_MEMHEAP_SIZE - <20><><EFBFBD><EFBFBD>Э<EFBFBD><D0AD>ջʹ<D5BB>õ<EFBFBD>RAM<41><4D>С<EFBFBD><D0A1><EFBFBD><EFBFBD>С<EFBFBD><D0A1>6K ( Ĭ<><C4AC>:(1024*6) )
|
||||
|
||||
<20><>DATA<54><41>
|
||||
BLE_BUFF_MAX_LEN - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>( Ĭ<><C4AC>:27 (ATT_MTU=23)<29><>ȡֵ<C8A1><D6B5>Χ[27~516] )
|
||||
BLE_BUFF_NUM - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD><C4B0><EFBFBD><EFBFBD><EFBFBD>( Ĭ<><C4AC>:5 )
|
||||
BLE_TX_NUM_EVENT - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Է<EFBFBD><D4B7><EFBFBD><EFBFBD>ٸ<EFBFBD><D9B8><EFBFBD><EFBFBD>ݰ<EFBFBD>( Ĭ<><C4AC>:1 )
|
||||
BLE_TX_POWER - <20><><EFBFBD>书<EFBFBD><E4B9A6>( Ĭ<><C4AC>:LL_TX_POWEER_0_DBM (0dBm) )
|
||||
|
||||
<20><>MULTICONN<4E><4E>
|
||||
PERIPHERAL_MAX_CONNECTION - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬʱ<CDAC><CAB1><EFBFBD><EFBFBD><EFBFBD>ٴӻ<D9B4><D3BB><EFBFBD>ɫ( Ĭ<><C4AC>:1 )
|
||||
CENTRAL_MAX_CONNECTION - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬʱ<CDAC><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ( Ĭ<><C4AC>:3 )
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
/*********************************************************************
|
||||
* Ĭ<><C4AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
||||
*/
|
||||
#ifndef BLE_MAC
|
||||
#define BLE_MAC FALSE
|
||||
#endif
|
||||
#ifndef HAL_SLEEP
|
||||
#define HAL_SLEEP FALSE
|
||||
#endif
|
||||
#ifndef SLEEP_RTC_MIN_TIME
|
||||
#define SLEEP_RTC_MIN_TIME US_TO_RTC(1000)
|
||||
#endif
|
||||
#ifndef SLEEP_RTC_MAX_TIME
|
||||
#define SLEEP_RTC_MAX_TIME (RTC_MAX_COUNT - 1000 * 1000 * 30)
|
||||
#endif
|
||||
#ifndef WAKE_UP_RTC_MAX_TIME
|
||||
#define WAKE_UP_RTC_MAX_TIME US_TO_RTC(1600)
|
||||
#endif
|
||||
#ifndef HAL_KEY
|
||||
#define HAL_KEY FALSE
|
||||
#endif
|
||||
#ifndef HAL_LED
|
||||
#define HAL_LED FALSE
|
||||
#endif
|
||||
#ifndef TEM_SAMPLE
|
||||
#define TEM_SAMPLE TRUE
|
||||
#endif
|
||||
#ifndef BLE_CALIBRATION_ENABLE
|
||||
#define BLE_CALIBRATION_ENABLE TRUE
|
||||
#endif
|
||||
#ifndef BLE_CALIBRATION_PERIOD
|
||||
#define BLE_CALIBRATION_PERIOD 120000
|
||||
#endif
|
||||
#ifndef BLE_SNV
|
||||
#define BLE_SNV TRUE
|
||||
#endif
|
||||
#ifndef BLE_SNV_ADDR
|
||||
#define BLE_SNV_ADDR 0x3B000
|
||||
#endif
|
||||
#ifndef BLE_SNV_BLOCK
|
||||
#define BLE_SNV_BLOCK 256
|
||||
#endif
|
||||
#ifndef BLE_SNV_NUM
|
||||
#define BLE_SNV_NUM 1
|
||||
#endif
|
||||
#ifndef BLE_MEMHEAP_SIZE
|
||||
#define BLE_MEMHEAP_SIZE (512*7)
|
||||
#endif
|
||||
#ifndef BLE_BUFF_MAX_LEN
|
||||
#define BLE_BUFF_MAX_LEN 128
|
||||
#endif
|
||||
#ifndef BLE_BUFF_NUM
|
||||
#define BLE_BUFF_NUM 3
|
||||
#endif
|
||||
#ifndef BLE_TX_NUM_EVENT
|
||||
#define BLE_TX_NUM_EVENT 1
|
||||
#endif
|
||||
#ifndef BLE_TX_POWER
|
||||
#define BLE_TX_POWER LL_TX_POWEER_0_DBM
|
||||
#endif
|
||||
#ifndef PERIPHERAL_MAX_CONNECTION
|
||||
#define PERIPHERAL_MAX_CONNECTION 1
|
||||
#endif
|
||||
#ifndef CENTRAL_MAX_CONNECTION
|
||||
#define CENTRAL_MAX_CONNECTION 3
|
||||
#endif
|
||||
|
||||
extern uint32_t MEM_BUF[BLE_MEMHEAP_SIZE / 4];
|
||||
extern const uint8_t MacAddr[6];
|
||||
|
||||
#endif
|
||||
|
||||
69
BLV_RF_W13_V04_20260114/HAL/include/HAL.h
Normal file
69
BLV_RF_W13_V04_20260114/HAL/include/HAL.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : HAL.h
|
||||
* Author : WCH
|
||||
* Version : V1.0
|
||||
* Date : 2016/05/05
|
||||
* Description :
|
||||
*********************************************************************************
|
||||
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
|
||||
/******************************************************************************/
|
||||
#ifndef __HAL_H
|
||||
#define __HAL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "CONFIG.h"
|
||||
#include "RTC.h"
|
||||
#include "SLEEP.h"
|
||||
//#include "LED.h"
|
||||
//#include "KEY.h"
|
||||
|
||||
/* hal task Event */
|
||||
#define LED_BLINK_EVENT 0x0001
|
||||
#define HAL_KEY_EVENT 0x0002
|
||||
#define HAL_REG_INIT_EVENT 0x2000
|
||||
#define HAL_TEST_EVENT 0x4000
|
||||
|
||||
/*********************************************************************
|
||||
* GLOBAL VARIABLES
|
||||
*/
|
||||
extern tmosTaskID halTaskID;
|
||||
|
||||
/*********************************************************************
|
||||
* GLOBAL FUNCTIONS
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Ӳ<><D3B2><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
|
||||
*/
|
||||
extern void HAL_Init(void);
|
||||
|
||||
/**
|
||||
* @brief Ӳ<><D3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param task_id - The TMOS assigned task ID.
|
||||
* @param events - events to process. This is a bit map and can
|
||||
* contain more than one event.
|
||||
*/
|
||||
extern tmosEvents HAL_ProcessEvent(tmosTaskID task_id, tmosEvents events);
|
||||
|
||||
/**
|
||||
* @brief BLE <20><><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
|
||||
*/
|
||||
extern void CH57x_BLEInit(void);
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
*********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
68
BLV_RF_W13_V04_20260114/HAL/include/RTC.h
Normal file
68
BLV_RF_W13_V04_20260114/HAL/include/RTC.h
Normal file
@@ -0,0 +1,68 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : RTC.h
|
||||
* Author : WCH
|
||||
* Version : V1.0
|
||||
* Date : 2016/04/12
|
||||
* Description :
|
||||
*********************************************************************************
|
||||
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
|
||||
/******************************************************************************/
|
||||
#ifndef __RTC_H
|
||||
#define __RTC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef CLK_OSC32K
|
||||
#if (CLK_OSC32K==1)
|
||||
#define FREQ_RTC 32000
|
||||
#else
|
||||
#define FREQ_RTC 32768
|
||||
#endif
|
||||
#endif /* CLK_OSC32K */
|
||||
|
||||
|
||||
#define CLK_PER_US (1.0 / ((1.0 / Freq_LSI) * 1000 * 1000))
|
||||
#define CLK_PER_MS (CLK_PER_US * 1000)
|
||||
|
||||
#define US_PER_CLK (1.0 / CLK_PER_US)
|
||||
#define MS_PER_CLK (US_PER_CLK / 1000.0)
|
||||
|
||||
#define RTC_TO_US(clk) ((uint32_t)((clk) * US_PER_CLK + 0.5))
|
||||
#define RTC_TO_MS(clk) ((uint32_t)((clk) * MS_PER_CLK + 0.5))
|
||||
|
||||
#define US_TO_RTC(us) ((uint32_t)((us) * CLK_PER_US + 0.5))
|
||||
#define MS_TO_RTC(ms) ((uint32_t)((ms) * CLK_PER_MS + 0.5))
|
||||
|
||||
extern volatile uint32_t RTCTigFlag;
|
||||
extern uint32_t lsiFrq;
|
||||
|
||||
/**
|
||||
* @brief Initialize time Service.
|
||||
*/
|
||||
void HAL_TimeInit(void);
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD>RTC<54><43><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
*
|
||||
* @param time - <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>.
|
||||
*/
|
||||
extern void RTC_SetTignTime(uint32_t time);
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD>BLE<4C><45><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
*
|
||||
* @param lsifreq - LSIƵ<49><C6B5>.
|
||||
*/
|
||||
extern bleClockConfig_t BLE_ClockConfig(uint32_t lsifreq);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
60
BLV_RF_W13_V04_20260114/HAL/include/SLEEP.h
Normal file
60
BLV_RF_W13_V04_20260114/HAL/include/SLEEP.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : SLEEP.h
|
||||
* Author : WCH
|
||||
* Version : V1.0
|
||||
* Date : 2018/11/12
|
||||
* Description :
|
||||
*********************************************************************************
|
||||
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
|
||||
/******************************************************************************/
|
||||
#ifndef __SLEEP_H
|
||||
#define __SLEEP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
* GLOBAL VARIABLES
|
||||
*/
|
||||
typedef void (*pfnLowPowerGapProcessCB_t)( void );
|
||||
|
||||
extern uint16_t LSIWakeup_MaxTime;
|
||||
/*********************************************************************
|
||||
* FUNCTIONS
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD>˯<EFBFBD><EFBFBD><DFBB>ѵķ<D1B5>ʽ - RTC<54><43><EFBFBD>ѣ<EFBFBD><D1A3><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
||||
*/
|
||||
extern void HAL_SleepInit(void);
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD>˯<EFBFBD><CBAF>
|
||||
*
|
||||
* @param time - <20><><EFBFBD>ѵ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>㣨RTC<54><43><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>
|
||||
*
|
||||
* @return state.
|
||||
*/
|
||||
extern uint32_t CH57x_LowPower(uint32_t time);
|
||||
|
||||
/**
|
||||
* @brief <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
*
|
||||
* @param none.
|
||||
*/
|
||||
extern uint16_t GET_WakeUpLSIMaxTime(void);
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
*********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
3868
BLV_RF_W13_V04_20260114/LIB/CH572BLEPeri_LIB.h
Normal file
3868
BLV_RF_W13_V04_20260114/LIB/CH572BLEPeri_LIB.h
Normal file
File diff suppressed because it is too large
Load Diff
BIN
BLV_RF_W13_V04_20260114/LIB/libCH572BLE_PERI.a
Normal file
BIN
BLV_RF_W13_V04_20260114/LIB/libCH572BLE_PERI.a
Normal file
Binary file not shown.
174
BLV_RF_W13_V04_20260114/Ld/Link.ld
Normal file
174
BLV_RF_W13_V04_20260114/Ld/Link.ld
Normal file
@@ -0,0 +1,174 @@
|
||||
ENTRY( _start )
|
||||
|
||||
MEMORY
|
||||
{
|
||||
|
||||
FLASH (rx) : ORIGIN = 0x00001000, LENGTH = 116K
|
||||
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 12K
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.init :
|
||||
{
|
||||
_sinit = .;
|
||||
. = ALIGN(4);
|
||||
KEEP(*(SORT_NONE(.init)))
|
||||
. = ALIGN(4);
|
||||
_einit = .;
|
||||
} >FLASH AT>FLASH
|
||||
|
||||
.highcode_initlalign :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
PROVIDE(_highcode_init_lma = .);
|
||||
} >FLASH AT>FLASH
|
||||
|
||||
.highcodelalign :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
PROVIDE(_highcode_lma = .);
|
||||
} >FLASH AT>FLASH
|
||||
|
||||
.highcode :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
PROVIDE(_highcode_vma_start = .);
|
||||
. = ALIGN(1024);
|
||||
*(.vector);
|
||||
*(.highcode);
|
||||
*(.highcode.*);
|
||||
. = ALIGN(4);
|
||||
PROVIDE(_highcode_vma_end = .);
|
||||
} >RAM AT>FLASH
|
||||
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
KEEP(*(SORT_NONE(.handle_reset)))
|
||||
*(.text)
|
||||
*(.text.*)
|
||||
*(.rodata)
|
||||
*(.rodata*)
|
||||
*(.sdata2.*)
|
||||
*(.glue_7)
|
||||
*(.glue_7t)
|
||||
*(.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
|
||||
|
||||
.dlalign :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
PROVIDE(_data_lma = .);
|
||||
} >FLASH AT>FLASH
|
||||
|
||||
.data :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
PROVIDE(_data_vma = .);
|
||||
*(.gnu.linkonce.r.*)
|
||||
*(.data .data.*)
|
||||
*(.gnu.linkonce.d.*)
|
||||
. = ALIGN(8);
|
||||
PROVIDE( __global_pointer$ = . + 0x800 );
|
||||
*(.sdata .sdata.*)
|
||||
*(.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) :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
PROVIDE(_eusrstack = . );
|
||||
} >RAM
|
||||
}
|
||||
|
||||
|
||||
|
||||
226
BLV_RF_W13_V04_20260114/README.md
Normal file
226
BLV_RF_W13_V04_20260114/README.md
Normal file
@@ -0,0 +1,226 @@
|
||||
# 版本记录:
|
||||
|
||||
## 2026-01-19
|
||||
|
||||
添加蓝牙连接终止时,停止所有定时任务的代码
|
||||
|
||||
|
||||
|
||||
## 2026-01-14 叶阳文
|
||||
|
||||
1、只有取电后才有卫生间雷达开卫生间灯功能
|
||||
2、门磁在开启的时候记录时间戳,执行门磁开事件,在延时时间到达时执行门磁关事件,如果中途再次有门磁开事件则刷新延时时间戳。
|
||||
|
||||
连接最小间隔设置为:8 (=1ms)
|
||||
连接最大间隔设置为:40 (=50ms)
|
||||
连接超时时间设置为:1000 (=10s)
|
||||
|
||||
|
||||
|
||||
## 2026-01-12 15: 00 叶阳文
|
||||
|
||||
```
|
||||
软件版本:V04
|
||||
支持硬件版本:RF-C13-V04a
|
||||
更名项目为BLV_RF_W13
|
||||
1、串口接收:串口的接收缓冲在接收12包数据后会溢出导致设备主控芯片CH572D复位,已解决。
|
||||
|
||||
当前:
|
||||
传感器输入(引脚与外壳丝印对应):
|
||||
s1(PA2):洗手间
|
||||
S2(PA3):卧室
|
||||
S3(PA4):门口区
|
||||
S4(PA5):门磁
|
||||
配置软件设置:
|
||||
插卡状态(未使用)、门磁、洗手间、卧室、门口
|
||||
按键输出事件:
|
||||
按键1:无人到有人
|
||||
按键2:有人到无人
|
||||
按键3:门磁开
|
||||
按键4:门磁关
|
||||
按键5:洗手间雷达开
|
||||
按键6:洗手间雷达关
|
||||
```
|
||||
|
||||
|
||||
|
||||
## 2025-11-26 17: 00 叶阳文
|
||||
|
||||
```
|
||||
发布文件:1、BLV_C13_JumpIAP.hex
|
||||
2、BackupUpgrade_IAPOTA.hex
|
||||
3、BLV_RF_C13_V02.hex
|
||||
合成文件:BLV_RF_C13_V02_202511261530.hex
|
||||
合成烧录固件:BLV_RF_C13_V02_202511261530.datakey 校验码:0xD745
|
||||
软件版本:V02
|
||||
支持硬件版本:RF-C13-V04
|
||||
1、泛智联按键事件触发间隔500ms
|
||||
2、主机无卡逻辑,默认条件组数量不可修改。
|
||||
```
|
||||
|
||||
|
||||
|
||||
## 2025-10-29 叶阳文
|
||||
|
||||
```
|
||||
长时间离开事件修改为门磁开事件
|
||||
当前:
|
||||
传感器输入(引脚与外壳丝印对应):
|
||||
s1(PA2):洗手间
|
||||
S2(PA3):卧室
|
||||
S3(PA4):门口
|
||||
S4(PA5):预留:门磁
|
||||
|
||||
按键输出事件(泛至联六键开关模块):
|
||||
按键1-(PA6)无人到有人
|
||||
按键2-(PA7)短暂离开
|
||||
按键3-(PA8)门磁开事件
|
||||
按键4-(PA9)有人到无人
|
||||
按键5-(PA10)长时间检测有人
|
||||
按键6-(PA11)长时间检测无人
|
||||
```
|
||||
|
||||
|
||||
|
||||
## 2025-10-28
|
||||
|
||||
```
|
||||
修改条件端口默认信息后一直复位的版本
|
||||
-- 长时间检测判断中,原来一个bit存储1s改为存储15s后没有处理好,导致溢出,已解决
|
||||
```
|
||||
|
||||
## 2025-10-17 叶阳文
|
||||
|
||||
```
|
||||
传感器输入(引脚与外壳丝印对应):
|
||||
s1(PA2):洗手间
|
||||
S2(PA3):卧室
|
||||
S3(PA4):门口
|
||||
S4(PA5):预留:门磁
|
||||
|
||||
按键输出事件(泛至联六键开关模块):
|
||||
按键1-(PA6)无人到有人
|
||||
按键2-(PA7)短暂离开
|
||||
按键3-(PA8)长时间离开
|
||||
按键4-(PA9)有人到无人
|
||||
按键5-(PA10)长时间检测有人
|
||||
按键6-(PA11)长时间检测无人
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
## 2025-10-08 叶阳文
|
||||
|
||||
```
|
||||
1、本地逻辑基本确认成功
|
||||
2、蓝牙调试打印通道打通
|
||||
3、串口设置、蓝牙设置打通
|
||||
4、OTA升级功能暂未实现。
|
||||
|
||||
#define VC_Event_DoorSensor_Flag 0x01 //开门进入事件:条件逻辑判断无人->有人
|
||||
#define VC_Event_BrieflyLeaving_Flag 0x02 //短暂人离事件:条件逻辑判断有人->无人中,短暂判定人离
|
||||
#define VC_Event_LongTermLeaving_Flag 0x04 //短暂人离事件:条件逻辑判断有人->无人中,长时间判定人离
|
||||
#define VC_Event_UncardedPersonLeft_Flag 0x08 //无卡人离事件:条件逻辑判断有人->无人,且无卡
|
||||
#define VC_Event_RadarPersonDetected_Flag 0x10 //雷达有人事件:长时间检测逻辑判断人员存在
|
||||
#define VC_Event_RadarPersonLeft_Flag 0x20 //雷达无人事件:长时间检测逻辑判断室内无人
|
||||
#define VC_Event_CardedPersonLeft_Flag 0x40//---- 未使用 //卡在人离事件:条件逻辑判断有人->无人,同时卡还在
|
||||
#define VC_Event_RS485ButtonPress_Flag 0x80//---- 未使用 //按键触发事件:室内检测到RS485 按键有触发
|
||||
|
||||
|
||||
/*调试信息初始状态*/
|
||||
|
||||
#define DBG_OPT_Debug_STATUS 0 //临时调试信息打印开关
|
||||
#define DBG_OPT_PC_COMM 0 //PC通讯打印开关
|
||||
#define DBG_OPT_BLE_STATUS 1 //蓝牙信息打印开关
|
||||
#define DBG_OPT_DEVICE_STATUS 1 //设备驱动层打印调试信息打印开关
|
||||
#define DBG_OPT_SYS_STATUS 0 //系统调试信息打印开关
|
||||
|
||||
/*调试信息输出控制位*/
|
||||
#define DBG_BIT_Debug_STATUS 4
|
||||
#define DBG_BIT_PC_COMM 3
|
||||
#define DBG_BIT_BLE_STATUS 2
|
||||
#define DBG_BIT_DEVICE_STATUS 1
|
||||
#define DBG_BIT_SYS_STATUS 0
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# 通讯示例:
|
||||
|
||||
```
|
||||
设置端口5参数: CC C0 16 00 43 CF 01 00 02 00 09 01 02 03 00 50 05 01 03 00 02 1E
|
||||
解析:
|
||||
CC C0 //固定帧头
|
||||
16 00 //长度
|
||||
43 CF //整包CRC,校验时此处补零
|
||||
01 00 //帧号 ,不管
|
||||
02 00 //帧总数
|
||||
09 //命令字
|
||||
01 02 03 00 50 05 01 03 00 02 1E //内容,端口信息
|
||||
|
||||
设置条件组: cc c0 19 00 f1 05 01 00 01 00 08 01 01 01 00 00 01 00 04 00 00 00 02 00 01
|
||||
解析:
|
||||
cc c0 //P0-P1, 固定帧头
|
||||
19 00 //P2-P3, 长度
|
||||
f1 05 //P4-P5, 整包CRC, 计算校验值时此处要补零计算
|
||||
01 00 //P6-P7, 帧号, 不管
|
||||
01 00 //P8-P9, 帧总数,
|
||||
08 //P10, 命令字
|
||||
01 01 01 00 00 01 00 04 00 00 00 02 00 01 //设置的条件组内容
|
||||
|
||||
读取版版本号:
|
||||
CC C0 0B 00 1E 7B 01 00 01 00 01
|
||||
|
||||
升级命令
|
||||
CC C0 0C 00 8D F6 01 00 02 00 0B 01
|
||||
|
||||
打印设置
|
||||
关闭全部打印: CC C0 0C 00 4E 06 01 00 02 00 0C 00
|
||||
只打开蓝牙打印: CC C0 0C 00 4F C5 01 00 02 00 0C 04
|
||||
只打开串口打印: CC C0 0C 00 4F C0 01 00 02 00 0C 08
|
||||
蓝牙|串口打印: CC C0 0C 00 4E 03 01 00 02 00 0C 0C
|
||||
|
||||
雷达状态控制:
|
||||
打开雷达状态发送: CC C0 0C 00 86 96 01 00 02 00 11 01
|
||||
关闭雷达状态发送: CC C0 0C 00 C6 97 01 00 02 00 11 02
|
||||
|
||||
测试按键功能:
|
||||
控制所有按键按下: CC C0 0D 00 B6 8E 01 00 01 00 13 01 3F
|
||||
控制按键1按下: CC C0 0D 00 37 5E 01 00 01 00 13 01 01
|
||||
控制按键2按下: CC C0 0D 00 77 5F 01 00 01 00 13 01 02
|
||||
控制按键3按下: CC C0 0D 00 F7 5D 01 00 01 00 13 01 04
|
||||
控制按键4按下: CC C0 0D 00 F7 58 01 00 01 00 13 01 08
|
||||
控制按键5按下: CC C0 0D 00 F7 52 01 00 01 00 13 01 10
|
||||
控制按键6按下: CC C0 0D 00 F7 46 01 00 01 00 13 01 20
|
||||
|
||||
设置门磁开廊灯事件,卫浴雷达开卫浴灯事件触发、释放参数:
|
||||
全 10S:
|
||||
CC C0 14 00 6C F7 01 00 01 00 16 03 0A 01 0A 01 0A 01 0A 01
|
||||
设置 40min, 最大时间设置为30min, 此时间设置只能是30min:
|
||||
CC C0 14 00 3C 6D 01 00 01 00 16 03 28 02 28 02 28 02 28 02
|
||||
|
||||
CC C0 14 00 69 3B 01 00 01 00 16 03 1A 01 0A 01 1A 01 0A 01
|
||||
CC C0 14 00 EF 50 01 00 01 00 16 03 00 01 0A 01 00 01 0A 01
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# BLE连接状态表, 查询版本号返回:
|
||||
|
||||
| 状态名称 | 值 | 状态类型 | 描述 |
|
||||
| --------------------- | ---- | ----------- | ---------------------------------------------------------- |
|
||||
| GAPROLE_INIT | 0 | 初始状态 | 等待被启动,系统刚初始化时的状态 |
|
||||
| GAPROLE_STARTED | 1 | 已启动 | 设备已启动但未处于广播状态 |
|
||||
| GAPROLE_ADVERTISING | 2 | 广播中 | 设备正在进行蓝牙广播,寻找连接设备 |
|
||||
| GAPROLE_WAITING | 3 | 等待中 | 设备已启动但未广播,处于等待再次广播的期间(如连接断开后) |
|
||||
| GAPROLE_CONNECTED | 4 | 已连接 | 设备已与其他蓝牙设备建立连接 |
|
||||
| GAPROLE_CONNECTED_ADV | 5 | 已连接+广播 | 设备已建立连接,同时仍在进行广播 |
|
||||
| GAPROLE_ERROR | 6 | 错误状态 | 发生错误,进入无效状态 |
|
||||
|
||||
695
BLV_RF_W13_V04_20260114/RVMSIS/core_riscv.h
Normal file
695
BLV_RF_W13_V04_20260114/RVMSIS/core_riscv.h
Normal file
@@ -0,0 +1,695 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : core_riscv.h
|
||||
* Author : WCH
|
||||
* Version : V1.0.0
|
||||
* Date : 2024/07/25
|
||||
* Description : CH585 Series RISC-V Core Peripheral Access Layer Header File
|
||||
*********************************************************************************
|
||||
* Copyright (c) 2024 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
#ifndef __CORE_RISCV_H__
|
||||
#define __CORE_RISCV_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* define compiler specific symbols */
|
||||
#if defined ( __CC_ARM )
|
||||
#define __ASM __asm /*!< asm keyword for ARM Compiler */
|
||||
#define __INLINE __inline /*!< inline keyword for ARM Compiler */
|
||||
|
||||
#elif defined ( __ICCARM__ )
|
||||
#define __ASM __asm /*!< asm keyword for IAR Compiler */
|
||||
#define __INLINE inline /*!< inline keyword for IAR Compiler. Only avaiable in High optimization mode! */
|
||||
|
||||
#elif defined ( __GNUC__ )
|
||||
#define __ASM __asm /*!< asm keyword for GNU Compiler */
|
||||
#define __INLINE inline /*!< inline keyword for GNU Compiler */
|
||||
|
||||
#elif defined ( __TASKING__ )
|
||||
#define __ASM __asm /*!< asm keyword for TASKING Compiler */
|
||||
#define __INLINE inline /*!< inline keyword for TASKING Compiler */
|
||||
|
||||
#endif
|
||||
|
||||
/* IO definitions */
|
||||
#ifdef __cplusplus
|
||||
#define __I volatile /*!< defines 'read only' permissions */
|
||||
#else
|
||||
#define __I volatile const /*!< defines 'read only' permissions */
|
||||
#endif
|
||||
#define __O volatile /*!< defines 'write only' permissions */
|
||||
#define __IO volatile /*!< defines 'read / write' permissions */
|
||||
#define RV_STATIC_INLINE static inline
|
||||
|
||||
//typedef enum {SUCCESS = 0, ERROR = !SUCCESS} ErrorStatus;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DISABLE = 0,
|
||||
ENABLE = !DISABLE
|
||||
} FunctionalState;
|
||||
typedef enum
|
||||
{
|
||||
RESET = 0,
|
||||
SET = !RESET
|
||||
} FlagStatus, ITStatus;
|
||||
|
||||
/* memory mapped structure for Program Fast Interrupt Controller (PFIC) */
|
||||
typedef struct
|
||||
{
|
||||
__I uint32_t ISR[8]; // 0
|
||||
__I uint32_t IPR[8]; // 20H
|
||||
__IO uint32_t ITHRESDR; // 40H
|
||||
uint8_t RESERVED[8]; // 44H
|
||||
__I uint32_t GISR; // 4CH
|
||||
__IO uint8_t VTFIDR[4]; // 50H
|
||||
uint8_t RESERVED0[0x0C]; // 54H
|
||||
__IO uint32_t VTFADDR[4]; // 60H
|
||||
uint8_t RESERVED1[0x90]; // 70H
|
||||
__O uint32_t IENR[8]; // 100H
|
||||
uint8_t RESERVED2[0x60]; // 120H
|
||||
__O uint32_t IRER[8]; // 180H
|
||||
uint8_t RESERVED3[0x60]; // 1A0H
|
||||
__O uint32_t IPSR[8]; // 200H
|
||||
uint8_t RESERVED4[0x60]; // 220H
|
||||
__O uint32_t IPRR[8]; // 280H
|
||||
uint8_t RESERVED5[0x60]; // 2A0H
|
||||
__IO uint32_t IACTR[8]; // 300H
|
||||
uint8_t RESERVED6[0xE0]; // 320H
|
||||
__IO uint8_t IPRIOR[256]; // 400H
|
||||
uint8_t RESERVED7[0x810]; // 500H
|
||||
__IO uint32_t SCTLR; // D10H
|
||||
} PFIC_Type;
|
||||
|
||||
/* memory mapped structure for SysTick */
|
||||
typedef struct
|
||||
{
|
||||
__IO uint32_t CTLR;
|
||||
__IO uint32_t SR;
|
||||
union
|
||||
{
|
||||
__IO uint32_t CNT;
|
||||
__IO uint32_t CNTL;
|
||||
};
|
||||
uint8_t RESERVED[4];
|
||||
union
|
||||
{
|
||||
__IO uint32_t CMP;
|
||||
__IO uint32_t CMPL;
|
||||
};
|
||||
uint8_t RESERVED0[4];
|
||||
} SysTick_Type;
|
||||
|
||||
#define PFIC ((PFIC_Type *)0xE000E000)
|
||||
#define SysTick ((SysTick_Type *)0xE000F000)
|
||||
|
||||
#define PFIC_KEY1 ((uint32_t)0xFA050000)
|
||||
#define PFIC_KEY2 ((uint32_t)0xBCAF0000)
|
||||
#define PFIC_KEY3 ((uint32_t)0xBEEF0000)
|
||||
|
||||
/* ########################## define #################################### */
|
||||
#define __nop() __asm__ volatile("nop")
|
||||
|
||||
#define read_csr(reg) ({unsigned long __tmp; \
|
||||
__asm__ volatile ("csrr %0, " #reg : "=r"(__tmp)); \
|
||||
__tmp; })
|
||||
|
||||
#define write_csr(reg, val) ({ \
|
||||
if (__builtin_constant_p(val) && (unsigned long)(val) < 32) \
|
||||
__asm__ volatile ("csrw " #reg ", %0" :: "i"(val)); \
|
||||
else \
|
||||
__asm__ volatile ("csrw " #reg ", %0" :: "r"(val)); })
|
||||
|
||||
/*********************************************************************
|
||||
* @fn __risc_v_enable_irq
|
||||
*
|
||||
* @brief recover Global Interrupt
|
||||
*
|
||||
* @return mpie and mie bit in mstatus.
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE uint32_t __risc_v_enable_irq(uint32_t mpie_mie)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
__asm volatile("csrrs %0, 0x800, %1" : \
|
||||
"=r"(result): "r"(mpie_mie) : "memory");
|
||||
return result;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn __disable_irq
|
||||
*
|
||||
* @brief Disable Global Interrupt
|
||||
*
|
||||
* @return mpie and mie bit in mstatus.
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE uint32_t __risc_v_disable_irq(void)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
__asm volatile("csrrc %0, 0x800, %1" : \
|
||||
"=r"(result): "r"(0x88) : "memory");
|
||||
return result & 0x88;
|
||||
}
|
||||
|
||||
/* ########################## PFIC functions #################################### */
|
||||
|
||||
#define PFIC_EnableAllIRQ() {write_csr(0x800, 0x88);}
|
||||
#define PFIC_DisableAllIRQ() {write_csr(0x800, 0x80);asm volatile("fence.i");}
|
||||
|
||||
/*******************************************************************************
|
||||
* @fn PFIC_EnableIRQ
|
||||
*
|
||||
* @brief Enable Interrupt
|
||||
*
|
||||
* @param IRQn - Interrupt Numbers
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE void PFIC_EnableIRQ(IRQn_Type IRQn)
|
||||
{
|
||||
PFIC->IENR[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F));
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* @fn PFIC_DisableIRQ
|
||||
*
|
||||
* @brief Disable Interrupt
|
||||
*
|
||||
* @param IRQn - Interrupt Numbers
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE void PFIC_DisableIRQ(IRQn_Type IRQn)
|
||||
{
|
||||
PFIC->IRER[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F));
|
||||
asm volatile("fence.i");
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* @fn PFIC_GetStatusIRQ
|
||||
*
|
||||
* @brief Get Interrupt Enable State
|
||||
*
|
||||
* @param IRQn - Interrupt Numbers
|
||||
*
|
||||
* @return 1: Interrupt Enable
|
||||
* 0: Interrupt Disable
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE uint32_t PFIC_GetStatusIRQ(IRQn_Type IRQn)
|
||||
{
|
||||
return ((uint32_t)((PFIC->ISR[(uint32_t)(IRQn) >> 5] & (1 << ((uint32_t)(IRQn) & 0x1F))) ? 1 : 0));
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* @fn PFIC_GetPendingIRQ
|
||||
*
|
||||
* @brief Get Interrupt Pending State
|
||||
*
|
||||
* @param IRQn - Interrupt Numbers
|
||||
*
|
||||
* @return 1: Interrupt Pending Enable
|
||||
* 0: Interrupt Pending Disable
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE uint32_t PFIC_GetPendingIRQ(IRQn_Type IRQn)
|
||||
{
|
||||
return ((uint32_t)((PFIC->IPR[(uint32_t)(IRQn) >> 5] & (1 << ((uint32_t)(IRQn) & 0x1F))) ? 1 : 0));
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* @fn PFIC_SetPendingIRQ
|
||||
*
|
||||
* @brief Set Interrupt Pending
|
||||
*
|
||||
* @param IRQn - Interrupt Numbers
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE void PFIC_SetPendingIRQ(IRQn_Type IRQn)
|
||||
{
|
||||
PFIC->IPSR[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F));
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* @fn PFIC_ClearPendingIRQ
|
||||
*
|
||||
* @brief Clear Interrupt Pending
|
||||
*
|
||||
* @param IRQn - Interrupt Numbers
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE void PFIC_ClearPendingIRQ(IRQn_Type IRQn)
|
||||
{
|
||||
PFIC->IPRR[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F));
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* @fn PFIC_GetActive
|
||||
*
|
||||
* @brief Get Interrupt Active State
|
||||
*
|
||||
* @param IRQn - Interrupt Numbers
|
||||
*
|
||||
* @return 1: Interrupt Active
|
||||
* 0: Interrupt No Active.
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE uint32_t PFIC_GetActive(IRQn_Type IRQn)
|
||||
{
|
||||
return ((uint32_t)((PFIC->IACTR[(uint32_t)(IRQn) >> 5] & (1 << ((uint32_t)(IRQn) & 0x1F))) ? 1 : 0));
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* @fn PFIC_SetPriority
|
||||
*
|
||||
* @brief Set Interrupt Priority
|
||||
*
|
||||
* @param IRQn - Interrupt Numbers
|
||||
* @param priority - bit7: pre-emption priority
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE void PFIC_SetPriority(IRQn_Type IRQn, uint8_t priority)
|
||||
{
|
||||
PFIC->IPRIOR[(uint32_t)(IRQn)] = priority ? 0x80 : 0;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SetVTFIRQ
|
||||
*
|
||||
* @brief Set VTF Interrupt
|
||||
*
|
||||
* @param addr - VTF interrupt service function base address.
|
||||
* IRQn - Interrupt Numbers
|
||||
* num - VTF Interrupt Numbers
|
||||
* NewState - DISABLE or ENABLE
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE void SetVTFIRQ(uint32_t addr, IRQn_Type IRQn, uint8_t num, FunctionalState NewState)
|
||||
{
|
||||
if (num > 3) return ;
|
||||
|
||||
if (NewState != DISABLE)
|
||||
{
|
||||
PFIC->VTFIDR[num] = IRQn;
|
||||
PFIC->VTFADDR[num] = ((addr & 0xFFFFFFFE) | 0x1);
|
||||
}
|
||||
else
|
||||
{
|
||||
PFIC->VTFIDR[num] = IRQn;
|
||||
PFIC->VTFADDR[num] = ((addr & 0xFFFFFFFE) & (~0x1));
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn _SEV
|
||||
*
|
||||
* @brief Set Event
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE void _SEV(void)
|
||||
{
|
||||
|
||||
PFIC->SCTLR |= (1 << 3) | (1 << 5);
|
||||
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn _WFE
|
||||
*
|
||||
* @brief Wait for Events
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE void _WFE(void)
|
||||
{
|
||||
PFIC->SCTLR |= (1 << 3);
|
||||
asm volatile("wfi");
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
* @fn __WFE
|
||||
*
|
||||
* @brief Wait for Events
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE void __WFE(void)
|
||||
{
|
||||
_SEV();
|
||||
_WFE();
|
||||
_WFE();
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn __WFI
|
||||
*
|
||||
* @brief Wait for Interrupt
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE void __WFI(void)
|
||||
{
|
||||
PFIC->SCTLR &= ~(1 << 3); // wfi
|
||||
__asm__ volatile("wfi");
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn PFIC_SystemReset
|
||||
*
|
||||
* @brief Initiate a system reset request
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE void PFIC_SystemReset(void)
|
||||
{
|
||||
PFIC->SCTLR = 0x80000000;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn __get_MSTATUS
|
||||
*
|
||||
* @brief Return the Machine Status Register
|
||||
*
|
||||
* @return mstatus value
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE uint32_t __get_MSTATUS(void)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
__ASM volatile("csrr %0," "mstatus" : "=r"(result));
|
||||
return (result);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn __set_MSTATUS
|
||||
*
|
||||
* @brief Set the Machine Status Register
|
||||
*
|
||||
* @param value - set mstatus value
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE void __set_MSTATUS(uint32_t value)
|
||||
{
|
||||
__ASM volatile("csrw mstatus, %0" : : "r"(value));
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn __get_MISA
|
||||
*
|
||||
* @brief Return the Machine ISA Register
|
||||
*
|
||||
* @return misa value
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE uint32_t __get_MISA(void)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
__ASM volatile("csrr %0," "misa" : "=r"(result));
|
||||
return (result);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn __set_MISA
|
||||
*
|
||||
* @brief Set the Machine ISA Register
|
||||
*
|
||||
* @param value - set misa value
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE void __set_MISA(uint32_t value)
|
||||
{
|
||||
__ASM volatile("csrw misa, %0" : : "r"(value));
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn __get_MTVEC
|
||||
*
|
||||
* @brief Return the Machine Trap-Vector Base-Address Register
|
||||
*
|
||||
* @return mtvec value
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE uint32_t __get_MTVEC(void)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
__ASM volatile("csrr %0," "mtvec" : "=r"(result));
|
||||
return (result);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn __set_MTVEC
|
||||
*
|
||||
* @brief Set the Machine Trap-Vector Base-Address Register
|
||||
*
|
||||
* @param value - set mtvec value
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE void __set_MTVEC(uint32_t value)
|
||||
{
|
||||
__ASM volatile("csrw mtvec, %0" : : "r"(value));
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn __get_MSCRATCH
|
||||
*
|
||||
* @brief Return the Machine Seratch Register
|
||||
*
|
||||
* @return mscratch value
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE uint32_t __get_MSCRATCH(void)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
__ASM volatile("csrr %0," "mscratch" : "=r"(result));
|
||||
return (result);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn __set_MSCRATCH
|
||||
*
|
||||
* @brief Set the Machine Seratch Register
|
||||
*
|
||||
* @param value - set mscratch value
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE void __set_MSCRATCH(uint32_t value)
|
||||
{
|
||||
__ASM volatile("csrw mscratch, %0" : : "r"(value));
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn __get_MEPC
|
||||
*
|
||||
* @brief Return the Machine Exception Program Register
|
||||
*
|
||||
* @return mepc value
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE uint32_t __get_MEPC(void)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
__ASM volatile("csrr %0," "mepc" : "=r"(result));
|
||||
return (result);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn __set_MEPC
|
||||
*
|
||||
* @brief Set the Machine Exception Program Register
|
||||
*
|
||||
* @return mepc value
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE void __set_MEPC(uint32_t value)
|
||||
{
|
||||
__ASM volatile("csrw mepc, %0" : : "r"(value));
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn __get_MCAUSE
|
||||
*
|
||||
* @brief Return the Machine Cause Register
|
||||
*
|
||||
* @return mcause value
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE uint32_t __get_MCAUSE(void)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
__ASM volatile("csrr %0," "mcause" : "=r"(result));
|
||||
return (result);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn __set_MEPC
|
||||
*
|
||||
* @brief Set the Machine Cause Register
|
||||
*
|
||||
* @return mcause value
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE void __set_MCAUSE(uint32_t value)
|
||||
{
|
||||
__ASM volatile("csrw mcause, %0" : : "r"(value));
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn __get_MTVAL
|
||||
*
|
||||
* @brief Return the Machine Trap Value Register
|
||||
*
|
||||
* @return mtval value
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE uint32_t __get_MTVAL(void)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
__ASM volatile("csrr %0," "mtval" : "=r"(result));
|
||||
return (result);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn __set_MTVAL
|
||||
*
|
||||
* @brief Set the Machine Trap Value Register
|
||||
*
|
||||
* @return mtval value
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE void __set_MTVAL(uint32_t value)
|
||||
{
|
||||
__ASM volatile("csrw mtval, %0" : : "r"(value));
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn __get_MVENDORID
|
||||
*
|
||||
* @brief Return Vendor ID Register
|
||||
*
|
||||
* @return mvendorid value
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE uint32_t __get_MVENDORID(void)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
__ASM volatile("csrr %0," "mvendorid" : "=r"(result));
|
||||
return (result);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn __get_MARCHID
|
||||
*
|
||||
* @brief Return Machine Architecture ID Register
|
||||
*
|
||||
* @return marchid value
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE uint32_t __get_MARCHID(void)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
__ASM volatile("csrr %0," "marchid" : "=r"(result));
|
||||
return (result);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn __get_MIMPID
|
||||
*
|
||||
* @brief Return Machine Implementation ID Register
|
||||
*
|
||||
* @return mimpid value
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE uint32_t __get_MIMPID(void)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
__ASM volatile("csrr %0," "mimpid" : "=r"(result));
|
||||
return (result);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn __get_MHARTID
|
||||
*
|
||||
* @brief Return Hart ID Register
|
||||
*
|
||||
* @return mhartid value
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE uint32_t __get_MHARTID(void)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
__ASM volatile("csrr %0," "mhartid" : "=r"(result));
|
||||
return (result);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn __get_SP
|
||||
*
|
||||
* @brief Return SP Register
|
||||
*
|
||||
* @return SP value
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE uint32_t __get_SP(void)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
__ASM volatile("mv %0," "sp" : "=r"(result) :);
|
||||
return (result);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn __MCPY
|
||||
*
|
||||
* @brief fast memory copy asm instruction.
|
||||
* @details copy memory from start to dst, copy length is (end - start).
|
||||
*
|
||||
*
|
||||
* @return None.
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE void __MCPY(void *dst, void *start, void *end)
|
||||
{
|
||||
__asm volatile("mcpy %2, %0, %1" : \
|
||||
"+r"(start), "+r"(dst) : "r"(end) : "memory");
|
||||
}
|
||||
|
||||
#define SysTick_SR_SWIE (1 << 31)
|
||||
#define SysTick_SR_CNTIF (1 << 0)
|
||||
|
||||
#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFFF)
|
||||
#define SysTick_CTLR_INIT (1 << 5)
|
||||
#define SysTick_CTLR_MODE (1 << 4)
|
||||
#define SysTick_CTLR_STRE (1 << 3)
|
||||
#define SysTick_CTLR_STCLK (1 << 2)
|
||||
#define SysTick_CTLR_STIE (1 << 1)
|
||||
#define SysTick_CTLR_STE (1 << 0)
|
||||
|
||||
|
||||
RV_STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks)
|
||||
{
|
||||
if ((ticks - 1) > SysTick_LOAD_RELOAD_Msk)
|
||||
return (1); /* Reload value impossible */
|
||||
|
||||
// SysTick->CNTL = 0;
|
||||
SysTick->CMP = ticks - 1; /* set reload register */
|
||||
PFIC_EnableIRQ(SysTick_IRQn);
|
||||
SysTick->CTLR = SysTick_CTLR_INIT | //<2F><><EFBFBD><EFBFBD>
|
||||
SysTick_CTLR_STRE |
|
||||
SysTick_CTLR_STCLK |
|
||||
SysTick_CTLR_STIE |
|
||||
SysTick_CTLR_STE; /* Enable SysTick IRQ and SysTick Timer */
|
||||
return (0); /* Function successful */
|
||||
}
|
||||
|
||||
RV_STATIC_INLINE uint32_t __SysTick_Config(uint32_t ticks)
|
||||
{
|
||||
if ((ticks - 1) > SysTick_LOAD_RELOAD_Msk)
|
||||
return (1); /* Reload value impossible */
|
||||
|
||||
SysTick->CNTL = 0;
|
||||
SysTick->CMP = ticks - 1; /* set reload register */
|
||||
SysTick->CTLR = SysTick_CTLR_STRE |
|
||||
SysTick_CTLR_STCLK |
|
||||
SysTick_CTLR_STIE |
|
||||
SysTick_CTLR_STE; /* Enable SysTick IRQ and SysTick Timer */
|
||||
return (0); /* Function successful */
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __CORE_RV3A_H__ */
|
||||
180
BLV_RF_W13_V04_20260114/Startup/startup_CH572.S
Normal file
180
BLV_RF_W13_V04_20260114/Startup/startup_CH572.S
Normal file
@@ -0,0 +1,180 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : startup_CH57x.s
|
||||
* Author : WCH
|
||||
* Version : V1.0.0
|
||||
* Date : 2024/12/20
|
||||
* Description :
|
||||
*********************************************************************************
|
||||
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
|
||||
.section .init,"ax",@progbits
|
||||
.global _start
|
||||
.global _vector_base
|
||||
.align 1
|
||||
_start:
|
||||
j handle_reset
|
||||
|
||||
.section .vector,"ax",@progbits
|
||||
.align 1
|
||||
_vector_base:
|
||||
.option norvc;
|
||||
|
||||
.word 0
|
||||
.word 0
|
||||
.word NMI_Handler /* NMI Handler */
|
||||
.word HardFault_Handler /* Hard Fault Handler */
|
||||
.word 0xF3F9BDA9
|
||||
.word Ecall_M_Mode_Handler /* 5 */
|
||||
.word 0
|
||||
.word 0
|
||||
.word Ecall_U_Mode_Handler /* 8 */
|
||||
.word Break_Point_Handler /* 9 */
|
||||
.word 0
|
||||
.word 0
|
||||
.word SysTick_Handler /* SysTick Handler */
|
||||
.word 0
|
||||
.word SWI_Handler /* SWI Handler */
|
||||
.word 0
|
||||
/* External Interrupts */
|
||||
.word 0 /* 16 */
|
||||
.word GPIOA_IRQHandler /* GPIOA */
|
||||
.word 0
|
||||
.word SPI_IRQHandler /* SPI */
|
||||
.word BB_IRQHandler /* BLEB */
|
||||
.word LLE_IRQHandler /* BLEL */
|
||||
.word USB_IRQHandler /* USB */
|
||||
.word 0
|
||||
.word TMR_IRQHandler /* TMR */
|
||||
.word 0
|
||||
.word 0
|
||||
.word UART_IRQHandler /* UART */
|
||||
.word RTC_IRQHandler /* RTC */
|
||||
.word CMP_IRQHandler /* CMP */
|
||||
.word I2C_IRQHandler /* I2C */
|
||||
.word PWMX_IRQHandler /* PWMX */
|
||||
.word 0
|
||||
.word KEYSCAN_IRQHandler /* KEYSCAN */
|
||||
.word ENCODER_IRQHandler /* ENCODER */
|
||||
.word WDOG_BAT_IRQHandler /* WDOG_BAT */
|
||||
|
||||
|
||||
.option rvc;
|
||||
|
||||
.section .vector_handler, "ax", @progbits
|
||||
.weak NMI_Handler
|
||||
.weak HardFault_Handler
|
||||
.weak Ecall_M_Mode_Handler
|
||||
.weak Ecall_U_Mode_Handler
|
||||
.weak Break_Point_Handler
|
||||
.weak SysTick_Handler
|
||||
.weak SWI_Handler
|
||||
.weak GPIOA_IRQHandler
|
||||
.weak SPI_IRQHandler
|
||||
.weak BB_IRQHandler
|
||||
.weak LLE_IRQHandler
|
||||
.weak USB_IRQHandler
|
||||
.weak TMR_IRQHandler
|
||||
.weak UART_IRQHandler
|
||||
.weak RTC_IRQHandler
|
||||
.weak CMP_IRQHandler
|
||||
.weak I2C_IRQHandler
|
||||
.weak PWMX_IRQHandler
|
||||
.weak KEYSCAN_IRQHandler
|
||||
.weak ENCODER_IRQHandler
|
||||
.weak WDOG_BAT_IRQHandler
|
||||
|
||||
NMI_Handler:
|
||||
HardFault_Handler:
|
||||
Ecall_M_Mode_Handler:
|
||||
Ecall_U_Mode_Handler:
|
||||
Break_Point_Handler:
|
||||
SysTick_Handler:
|
||||
SWI_Handler:
|
||||
GPIOA_IRQHandler:
|
||||
SPI_IRQHandler:
|
||||
BB_IRQHandler:
|
||||
LLE_IRQHandler:
|
||||
USB_IRQHandler:
|
||||
TMR_IRQHandler:
|
||||
UART_IRQHandler:
|
||||
RTC_IRQHandler:
|
||||
CMP_IRQHandler:
|
||||
I2C_IRQHandler:
|
||||
PWMX_IRQHandler:
|
||||
KEYSCAN_IRQHandler:
|
||||
ENDOCE_IRQHandler:
|
||||
WDOG_BAT_IRQHandler:
|
||||
1:
|
||||
j 1b
|
||||
|
||||
.section .handle_reset,"ax",@progbits
|
||||
.weak handle_reset
|
||||
.align 1
|
||||
handle_reset:
|
||||
.option push
|
||||
.option norelax
|
||||
la gp, __global_pointer$
|
||||
1:
|
||||
la sp, _eusrstack
|
||||
.option pop
|
||||
|
||||
/* Load highcode code section from flash to RAM */
|
||||
2:
|
||||
la a0, _highcode_lma
|
||||
la a1, _highcode_vma_start
|
||||
la a2, _highcode_vma_end
|
||||
bgeu a1, a2, 2f
|
||||
1:
|
||||
lw t0, (a0)
|
||||
sw t0, (a1)
|
||||
addi a0, a0, 4
|
||||
addi a1, a1, 4
|
||||
bltu a1, a2, 1b
|
||||
|
||||
/* Load data section from flash to RAM */
|
||||
2:
|
||||
la a0, _data_lma
|
||||
la a1, _data_vma
|
||||
la a2, _edata
|
||||
bgeu a1, a2, 2f
|
||||
1:
|
||||
lw t0, (a0)
|
||||
sw t0, (a1)
|
||||
addi a0, a0, 4
|
||||
addi a1, a1, 4
|
||||
bltu a1, a2, 1b
|
||||
2:
|
||||
/* clear bss section */
|
||||
la a0, _sbss
|
||||
la a1, _ebss
|
||||
bgeu a0, a1, 2f
|
||||
1:
|
||||
sw zero, (a0)
|
||||
addi a0, a0, 4
|
||||
bltu a0, a1, 1b
|
||||
2:
|
||||
/* <20>û<EFBFBD>ģʽ<C4A3>ж<EFBFBD>ʹ<EFBFBD><CAB9> */
|
||||
/*Ԥȡʹ<C8A1><CAB9>*/
|
||||
li t0, 0x25
|
||||
csrw 0xbc0, t0
|
||||
/* <20><><EFBFBD><EFBFBD>Ƕ<EFBFBD><C7B6><EFBFBD>жϡ<D0B6>Ӳ<EFBFBD><D3B2>ѹջ<D1B9><D5BB><EFBFBD><EFBFBD> */
|
||||
li t0, 0x3
|
||||
csrw 0x804, t0
|
||||
li t0, 0x1
|
||||
csrw 0xbc1, t0
|
||||
|
||||
li t0, 0x88
|
||||
csrw mstatus, t0
|
||||
la t0, _vector_base
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽΪ<CABD><CEAA><EFBFBD>Ե<EFBFBD>ַģʽ */
|
||||
ori t0, t0, 3
|
||||
csrw mtvec, t0
|
||||
|
||||
la t0, main
|
||||
csrw mepc, t0
|
||||
|
||||
mret
|
||||
473
BLV_RF_W13_V04_20260114/StdPeriphDriver/CH57x_clk.c
Normal file
473
BLV_RF_W13_V04_20260114/StdPeriphDriver/CH57x_clk.c
Normal file
@@ -0,0 +1,473 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH57x_clk.c
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2021/11/17
|
||||
* Description : source file(ch572/ch570)
|
||||
*********************************************************************************
|
||||
* 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 "CH57x_common.h"
|
||||
|
||||
/**
|
||||
* @brief LSIʱ<49>ӣ<EFBFBD>Hz<48><7A>
|
||||
*/
|
||||
uint32_t Freq_LSI = 0;
|
||||
|
||||
/*********************************************************************
|
||||
* @fn LClk_Cfg
|
||||
*
|
||||
* @brief <20><>Ƶʱ<C6B5>ӵ<EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param s - <20>Ƿ<EFBFBD><C7B7><EFBFBD>Դ
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void LClk_Cfg(FunctionalState s)
|
||||
{
|
||||
uint8_t cfg = R8_LSI_CONFIG;
|
||||
|
||||
if(s == DISABLE)
|
||||
{
|
||||
cfg &= ~RB_CLK_LSI_PON;
|
||||
}
|
||||
else
|
||||
{
|
||||
cfg |= RB_CLK_LSI_PON;
|
||||
}
|
||||
|
||||
sys_safe_access_enable();
|
||||
R8_LSI_CONFIG = cfg;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn HSECFG_Current
|
||||
*
|
||||
* @brief HSE<53><45><EFBFBD><EFBFBD> ƫ<>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param c - 75%,100%,125%,150%
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void HSECFG_Current(HSECurrentTypeDef c)
|
||||
{
|
||||
uint8_t x32M_c;
|
||||
|
||||
x32M_c = R8_XT32M_TUNE;
|
||||
x32M_c = (x32M_c & 0xfc) | (c & 0x03);
|
||||
|
||||
sys_safe_access_enable();
|
||||
R8_XT32M_TUNE = x32M_c;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn HSECFG_Capacitance
|
||||
*
|
||||
* @brief HSE<53><45><EFBFBD><EFBFBD> <20><><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param c - refer to HSECapTypeDef
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void HSECFG_Capacitance(HSECapTypeDef c)
|
||||
{
|
||||
uint8_t x32M_c;
|
||||
|
||||
x32M_c = R8_XT32M_TUNE;
|
||||
x32M_c = (x32M_c & 0x0f) | (c << 4);
|
||||
|
||||
sys_safe_access_enable();
|
||||
R8_XT32M_TUNE = x32M_c;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn RTC_InitClock
|
||||
*
|
||||
* @brief <20><>ʼ<EFBFBD><CABC> RTCʱ<43><CAB1>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Խ<EFBFBD><D4BD>,<2C><>ʼ<EFBFBD><CABC>ʱ<EFBFBD><CAB1>Խ<EFBFBD><D4BD>,ʱ<>Ӿ<EFBFBD><D3BE><EFBFBD>Խ<EFBFBD><D4BD>
|
||||
*
|
||||
* @param cnt - the total number of cycles captured by the oscillator
|
||||
*
|
||||
* @return RTCʱ<43><CAB1>, 24~42KHz
|
||||
*/
|
||||
uint32_t RTC_InitClock(RTC_OSCCntTypeDef cnt)
|
||||
{
|
||||
uint32_t count;
|
||||
uint32_t cyc;
|
||||
uint32_t last_ov_cnt = 0;
|
||||
uint32_t new_ov_cnt = 0;
|
||||
uint32_t ov_cnt_ov_cnt = 0;
|
||||
|
||||
if(cnt<Count_32)
|
||||
{
|
||||
cyc = 1<<cnt;
|
||||
}
|
||||
else if(cnt<Count_1024)
|
||||
{
|
||||
cyc = 1<<(cnt+2);
|
||||
}
|
||||
else if(cnt<Count_2047)
|
||||
{
|
||||
cyc = 1024;
|
||||
}
|
||||
else
|
||||
{
|
||||
cyc = 2047;
|
||||
}
|
||||
R16_OSC_CAL_CNT |= RB_OSC_CAL_OV_CLR | RB_OSC_CAL_IF;
|
||||
sys_safe_access_enable();
|
||||
R8_OSC_CAL_CTRL |= RB_CNT_CLR;
|
||||
R8_OSC_CAL_CTRL = cnt;
|
||||
R8_OSC_CAL_CTRL |= RB_OSC_CNT_EN;
|
||||
sys_safe_access_disable();
|
||||
while(!(R16_OSC_CAL_CNT&RB_OSC_CAL_IF))
|
||||
{
|
||||
new_ov_cnt = R8_OSC_CAL_OV_CNT;
|
||||
if(new_ov_cnt<last_ov_cnt)
|
||||
{
|
||||
ov_cnt_ov_cnt++;
|
||||
}
|
||||
last_ov_cnt = new_ov_cnt;
|
||||
}
|
||||
count = ((uint32_t)R16_OSC_CAL_CNT&RB_OSC_CAL_CNT) + ((uint32_t)R8_OSC_CAL_OV_CNT+ov_cnt_ov_cnt*256)*16384;
|
||||
Freq_LSI = GetSysClock()/(count/cyc);
|
||||
return Freq_LSI;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn RTCInitTime
|
||||
*
|
||||
* @brief RTCʱ<43>ӳ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ǰʱ<C7B0>䣬ע<E4A3AC>⣺<EFBFBD><E2A3BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵʱLSIƵ<49>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>LSIƵ<49><C6B5><EFBFBD>нϴ<CFB4>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ʱ<EFBFBD>ӻ<EFBFBD><D3BB><EFBFBD>ƫ<EFBFBD>
|
||||
*
|
||||
* @param y - <20><><EFBFBD><EFBFBD><EFBFBD>꣬MAX_Y = BEGYEAR + 44
|
||||
* @param mon - <20><><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>MAX_MON = 12
|
||||
* @param d - <20><><EFBFBD><EFBFBD><EFBFBD>գ<EFBFBD>MAX_D = 31
|
||||
* @param h - <20><><EFBFBD><EFBFBD>Сʱ<D0A1><CAB1>MAX_H = 23
|
||||
* @param m - <20><><EFBFBD>÷<EFBFBD><C3B7>ӣ<EFBFBD>MAX_M = 59
|
||||
* @param s - <20><><EFBFBD><EFBFBD><EFBFBD>룬MAX_S = 59
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void RTC_InitTime(uint16_t y, uint16_t mon, uint16_t d, uint16_t h, uint16_t m, uint16_t s)
|
||||
{
|
||||
uint32_t t;
|
||||
uint32_t year, month, day, sec2;
|
||||
uint32_t t32k;
|
||||
volatile uint8_t clk_pin;
|
||||
uint32_t temp,temp1,temp2,temp3;
|
||||
uint32_t tmp,tmp1,tmp2;
|
||||
|
||||
year = y;
|
||||
month = mon;
|
||||
day = 0;
|
||||
while(year > BEGYEAR)
|
||||
{
|
||||
day += YearLength(year - 1);
|
||||
year--;
|
||||
}
|
||||
while(month > 1)
|
||||
{
|
||||
day += monthLength(IsLeapYear(y), month - 2);
|
||||
month--;
|
||||
}
|
||||
|
||||
day += d - 1;
|
||||
sec2 = (h % 24) * 1800 + m * 30 + s / 2;
|
||||
t32k = (s & 1) ? (Freq_LSI) : (0);
|
||||
t = sec2;
|
||||
t = t << 16 | t32k;
|
||||
|
||||
temp = day * Freq_LSI;
|
||||
temp1 = temp % 32768; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
temp = temp / 32768; // <20><><EFBFBD><EFBFBD>
|
||||
|
||||
temp2 = temp1 * 675; // temp1 / 32768 * 2831155200 / 65536
|
||||
temp3 = temp2 % 512; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ת<><D7AA><EFBFBD><EFBFBD>2sΪ<73><CEAA>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
temp2 = temp2 / 512; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ת<><D7AA><EFBFBD><EFBFBD>2sΪ<73><CEAA>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
|
||||
|
||||
temp1 = temp3 * 128; // 2sΪ<73><CEAA>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ת<><D7AA><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> temp3 / 512 * 65536
|
||||
|
||||
tmp = sec2 * Freq_LSI;
|
||||
tmp1 = tmp % 32768; // 2s<32><73><EFBFBD><EFBFBD>
|
||||
tmp = tmp / 32768; // 2s<32><73>
|
||||
|
||||
tmp2 = tmp1 * 2 ; // 2sΪ<73><CEAA>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ת<><D7AA><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> // tmp1 / 32768 * 65536
|
||||
|
||||
t32k = (t32k * Freq_LSI + 16384) / 32768; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
t32k += tmp2 + temp1; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
tmp += (t32k/65536) + temp2; // <20><>2s<32><73>
|
||||
temp += (tmp/43200); // <20><><EFBFBD><EFBFBD>
|
||||
|
||||
t32k %= 65536; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
tmp %= 43200; // 2s<32><73>
|
||||
|
||||
t = tmp; // 64000
|
||||
t = t << 16 | t32k; // 1
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
clk_pin = (R8_LSI_CONFIG & RB_LSI_CLK_PIN);
|
||||
} while(clk_pin != (R8_LSI_CONFIG & RB_LSI_CLK_PIN));
|
||||
if(!clk_pin)
|
||||
{
|
||||
while(!clk_pin)
|
||||
{
|
||||
do
|
||||
{
|
||||
clk_pin = (R8_LSI_CONFIG & RB_LSI_CLK_PIN);
|
||||
} while(clk_pin != (R8_LSI_CONFIG & RB_LSI_CLK_PIN));
|
||||
}
|
||||
}
|
||||
|
||||
sys_safe_access_enable();
|
||||
R32_RTC_TRIG = temp;
|
||||
R8_RTC_MODE_CTRL |= RB_RTC_LOAD_HI;
|
||||
sys_safe_access_disable();
|
||||
while((R32_RTC_TRIG & 0x3FFF) != (R32_RTC_CNT_DIV2 & 0x3FFF));
|
||||
sys_safe_access_enable();
|
||||
R32_RTC_TRIG = t;
|
||||
R8_RTC_MODE_CTRL |= RB_RTC_LOAD_LO;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn RTC_GetTime
|
||||
*
|
||||
* @brief <20><>ȡ<EFBFBD><C8A1>ǰʱ<C7B0><CAB1>
|
||||
*
|
||||
* @param py - <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>꣬MAX_Y = BEGYEAR + 44
|
||||
* @param pmon - <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>MAX_MON = 12
|
||||
* @param pd - <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>գ<EFBFBD>MAX_D = 31
|
||||
* @param ph - <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>Сʱ<D0A1><CAB1>MAX_H = 23
|
||||
* @param pm - <20><>ȡ<EFBFBD><C8A1><EFBFBD>ķ<EFBFBD><C4B7>ӣ<EFBFBD>MAX_M = 59
|
||||
* @param ps - <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>룬MAX_S = 59
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void RTC_GetTime(uint16_t *py, uint16_t *pmon, uint16_t *pd, uint16_t *ph, uint16_t *pm, uint16_t *ps)
|
||||
{
|
||||
uint32_t t;
|
||||
uint32_t day, sec2, t32k;
|
||||
uint32_t temp,temp1,temp2,temp3;
|
||||
uint32_t tmp,tmp1,tmp2;
|
||||
|
||||
day = R32_RTC_CNT_DIV2 & 0x3FFF;
|
||||
sec2 = R16_RTC_CNT_DIV1;
|
||||
t32k = R16_RTC_CNT_LSI;
|
||||
|
||||
temp = day * 32768;
|
||||
temp1 = temp % Freq_LSI; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
temp = temp / Freq_LSI; // <20><><EFBFBD><EFBFBD>
|
||||
|
||||
temp2 = temp1 * 43200; // temp1 / Freq_LSI * 43200
|
||||
temp3 = temp2 % Freq_LSI; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ת<><D7AA><EFBFBD><EFBFBD>2sΪ<73><CEAA>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
temp2 = temp2 / Freq_LSI; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ת<><D7AA><EFBFBD><EFBFBD>2sΪ<73><CEAA>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
|
||||
|
||||
temp1 = (temp3 * 65536 + Freq_LSI/2 ) / Freq_LSI; // 2sΪ<73><CEAA>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ת<><D7AA><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> temp3 / Freq_LSI * 65536
|
||||
|
||||
tmp = sec2 * 32768;
|
||||
tmp1 = tmp % Freq_LSI; // 2s<32><73><EFBFBD><EFBFBD> 5376
|
||||
tmp = tmp / Freq_LSI; // 2s<32><73> 1799
|
||||
|
||||
tmp2 = (tmp1 * 65536 + Freq_LSI/2 ) / Freq_LSI; // 2sΪ<73><CEAA>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ת<><D7AA><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> // tmp1 / Freq_LSI * 65536 11010
|
||||
|
||||
t32k = (t32k * 32768 + Freq_LSI/2 ) / Freq_LSI; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 54525
|
||||
|
||||
|
||||
t32k += tmp2 + temp1; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
tmp += (t32k/65536) + temp2; // <20><>2s<32><73>
|
||||
temp += (tmp/43200); // <20><><EFBFBD><EFBFBD>
|
||||
|
||||
t32k %= 65536; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
tmp %= 43200; // 2s<32><73>
|
||||
|
||||
|
||||
t = tmp * 2 + ((t32k < 0x8000) ? 0 : 1);
|
||||
|
||||
*py = BEGYEAR;
|
||||
while(temp >= YearLength(*py))
|
||||
{
|
||||
temp -= YearLength(*py);
|
||||
(*py)++;
|
||||
}
|
||||
|
||||
*pmon = 0;
|
||||
while(temp >= monthLength(IsLeapYear(*py), *pmon))
|
||||
{
|
||||
temp -= monthLength(IsLeapYear(*py), *pmon);
|
||||
(*pmon)++;
|
||||
}
|
||||
(*pmon)++;
|
||||
*pd = temp + 1;
|
||||
*ph = t / 3600;
|
||||
*pm = t % 3600 / 60;
|
||||
*ps = t % 60;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn RTC_SetCycleLSI
|
||||
*
|
||||
* @brief <20><><EFBFBD><EFBFBD>LSIʱ<49>ӣ<EFBFBD><D3A3><EFBFBD><EFBFBD>õ<EFBFBD>ǰRTC <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param cyc - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD><DABC><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>MAX_CYC = 0xA8BFFFFF = 2831155199
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void RTC_SetCycleLSI(uint32_t cyc)
|
||||
{
|
||||
volatile uint8_t clk_pin;
|
||||
|
||||
do
|
||||
{
|
||||
clk_pin = (R8_LSI_CONFIG & RB_LSI_CLK_PIN);
|
||||
} while((clk_pin != (R8_LSI_CONFIG & RB_LSI_CLK_PIN)) || (!clk_pin));
|
||||
|
||||
sys_safe_access_enable();
|
||||
R32_RTC_TRIG = cyc;
|
||||
R8_RTC_MODE_CTRL |= RB_RTC_LOAD_LO;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn RTC_GetCycleLSI
|
||||
*
|
||||
* @brief <20><><EFBFBD><EFBFBD>LSIʱ<49>ӣ<EFBFBD><D3A3><EFBFBD>ȡ<EFBFBD><C8A1>ǰRTC <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>MAX_CYC = 0xA8BFFFFF = 2831155199
|
||||
*/
|
||||
uint32_t RTC_GetCycleLSI(void)
|
||||
{
|
||||
volatile uint32_t i;
|
||||
|
||||
do
|
||||
{
|
||||
i = R32_RTC_CNT_LSI;
|
||||
} while(i != R32_RTC_CNT_LSI);
|
||||
|
||||
return (i);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn RTC_TMRFunCfg
|
||||
*
|
||||
* @brief RTC<54><43>ʱģʽ<C4A3><CABD><EFBFBD>ã<EFBFBD>ע<EFBFBD>ⶨʱ<E2B6A8><CAB1><EFBFBD>̶<EFBFBD>Ϊ32768Hz<48><7A>
|
||||
*
|
||||
* @param t - refer to RTC_TMRCycTypeDef
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void RTC_TMRFunCfg(RTC_TMRCycTypeDef t)
|
||||
{
|
||||
sys_safe_access_enable();
|
||||
R8_RTC_MODE_CTRL &= ~(RB_RTC_TMR_EN | RB_RTC_TMR_MODE);
|
||||
sys_safe_access_disable();
|
||||
sys_safe_access_enable();
|
||||
R8_RTC_MODE_CTRL |= RB_RTC_TMR_EN | (t);
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn RTC_TRIGFunCfg
|
||||
*
|
||||
* @brief RTCʱ<43>䴥<EFBFBD><E4B4A5>ģʽ<C4A3><CABD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param cyc - <20><><EFBFBD>Ե<EFBFBD>ǰʱ<C7B0><CAB1><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>䣬<EFBFBD><E4A3AC><EFBFBD><EFBFBD>LSIʱ<49><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void RTC_TRIGFunCfg(uint32_t cyc)
|
||||
{
|
||||
uint32_t t;
|
||||
|
||||
t = RTC_GetCycleLSI() + cyc;
|
||||
if(t > RTC_MAX_COUNT)
|
||||
{
|
||||
t -= RTC_MAX_COUNT;
|
||||
}
|
||||
|
||||
sys_safe_access_enable();
|
||||
R32_RTC_TRIG = t;
|
||||
R8_RTC_MODE_CTRL |= RB_RTC_TRIG_EN;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn RTC_ModeFunDisable
|
||||
*
|
||||
* @brief RTC ģʽ<C4A3><CABD><EFBFBD>ܹر<DCB9>
|
||||
*
|
||||
* @param m - <20><>Ҫ<EFBFBD>رյĵ<D5B5>ǰģʽ
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void RTC_ModeFunDisable(RTC_MODETypeDef m)
|
||||
{
|
||||
uint8_t i = 0;
|
||||
|
||||
if(m == RTC_TRIG_MODE)
|
||||
{
|
||||
i |= RB_RTC_TRIG_EN;
|
||||
}
|
||||
else if(m == RTC_TMR_MODE)
|
||||
{
|
||||
i |= RB_RTC_TMR_EN;
|
||||
}
|
||||
|
||||
sys_safe_access_enable();
|
||||
R8_RTC_MODE_CTRL &= ~(i);
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn RTC_GetITFlag
|
||||
*
|
||||
* @brief <20><>ȡRTC<54>жϱ<D0B6>־
|
||||
*
|
||||
* @param f - refer to RTC_EVENTTypeDef
|
||||
*
|
||||
* @return <20>жϱ<D0B6>־״̬
|
||||
*/
|
||||
uint8_t RTC_GetITFlag(RTC_EVENTTypeDef f)
|
||||
{
|
||||
if(f == RTC_TRIG_EVENT)
|
||||
{
|
||||
return (R8_RTC_FLAG_CTRL & RB_RTC_TRIG_FLAG);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (R8_RTC_FLAG_CTRL & RB_RTC_TMR_FLAG);
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn RTC_ClearITFlag
|
||||
*
|
||||
* @brief <20><><EFBFBD><EFBFBD>RTC<54>жϱ<D0B6>־
|
||||
*
|
||||
* @param f - refer to RTC_EVENTTypeDef
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void RTC_ClearITFlag(RTC_EVENTTypeDef f)
|
||||
{
|
||||
switch(f)
|
||||
{
|
||||
case RTC_TRIG_EVENT:
|
||||
R8_RTC_FLAG_CTRL = RB_RTC_TRIG_CLR;
|
||||
break;
|
||||
case RTC_TMR_EVENT:
|
||||
R8_RTC_FLAG_CTRL = RB_RTC_TMR_CLR;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
44
BLV_RF_W13_V04_20260114/StdPeriphDriver/CH57x_cmp.c
Normal file
44
BLV_RF_W13_V04_20260114/StdPeriphDriver/CH57x_cmp.c
Normal file
@@ -0,0 +1,44 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH57x_cmp.c
|
||||
* Author : WCH
|
||||
* Version : V1.0
|
||||
* Date : 2024/12/17
|
||||
* Description : source file(ch572/ch570)
|
||||
*********************************************************************************
|
||||
* 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 "CH57x_common.h"
|
||||
|
||||
void CMP_Init (CMPSwTypeDef s, CMPNrefLevelTypeDef v)
|
||||
{
|
||||
R8_CMP_CTRL_0 = (s << 2)|(v << 4);
|
||||
}
|
||||
|
||||
void CMP_OutToTIMCAPCfg(FunctionalState s)
|
||||
{
|
||||
if (s)
|
||||
{
|
||||
R8_CMP_CTRL_0 |= RB_CMP_CAP;
|
||||
}
|
||||
else
|
||||
{
|
||||
R8_CMP_CTRL_0 &= ~RB_CMP_CAP;
|
||||
}
|
||||
}
|
||||
|
||||
void CMP_INTCfg (CMPOutSelTypeDef sel, FunctionalState s)
|
||||
{
|
||||
R8_CMP_CTRL_1 = (sel << 2);
|
||||
if (s)
|
||||
{
|
||||
R8_CMP_CTRL_1 |= RB_CMP_IE;
|
||||
}
|
||||
else
|
||||
{
|
||||
R8_CMP_CTRL_1 &= ~RB_CMP_IE;
|
||||
}
|
||||
}
|
||||
|
||||
157
BLV_RF_W13_V04_20260114/StdPeriphDriver/CH57x_flash.c
Normal file
157
BLV_RF_W13_V04_20260114/StdPeriphDriver/CH57x_flash.c
Normal file
@@ -0,0 +1,157 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH57x_flash.c
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2021/11/17
|
||||
* Description : source file(ch572/ch570)
|
||||
*********************************************************************************
|
||||
* 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 "CH57x_common.h"
|
||||
|
||||
/* RESET_EN */
|
||||
#define RESET_Enable 0x00000008
|
||||
#define RESET_Disable 0xFFFFFFF7
|
||||
|
||||
/* LOCKUP_RST_EN */
|
||||
#define UART_NO_KEY_Enable 0x00000100
|
||||
#define UART_NO_KEY_Disable 0xFFFFFEFF
|
||||
|
||||
/* BOOT_PIN */
|
||||
#define BOOT_PIN_PB22 0x00000200
|
||||
#define BOOT_PIN_PB11 0xFFFFFDFF
|
||||
|
||||
/* FLASH_WRProt */
|
||||
#define FLASH_WRProt 0xFFF003FF
|
||||
|
||||
/*********************************************************************
|
||||
* @fn FLASH_ROM_READ
|
||||
*
|
||||
* @brief Read Flash
|
||||
*
|
||||
* @param StartAddr - read address
|
||||
* @param Buffer - read buffer
|
||||
* @param len - read len
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void FLASH_ROM_READ(uint32_t StartAddr, void *Buffer, uint32_t len)
|
||||
{
|
||||
uint32_t i, Length = (len + 3) >> 2;
|
||||
uint32_t *pCode = (uint32_t *)StartAddr;
|
||||
uint32_t *pBuf = (uint32_t *)Buffer;
|
||||
|
||||
for(i = 0; i < Length; i++)
|
||||
{
|
||||
*pBuf++ = *pCode++;
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn UserOptionByteConfig
|
||||
*
|
||||
* @brief Configure User Option Byte.<2E><><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч,<2C><>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
||||
* (ʹ<>øú<C3B8><C3BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>ùٷ<C3B9><D9B7>ṩ<EFBFBD><E1B9A9>.S<>ļ<EFBFBD><C4BC><EFBFBD>ͬʱ<CDAC><CAB1><EFBFBD>øú<C3B8><C3BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD><DFB5>Խӿ<D4BD>Ĭ<EFBFBD>Ϲر<CFB9>)
|
||||
*
|
||||
* @param RESET_EN - <20>ⲿ<EFBFBD><E2B2BF>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>
|
||||
* @param UART_NO_KEY_EN - <20><><EFBFBD><EFBFBD><EFBFBD>ⰴ<EFBFBD><E2B0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>
|
||||
* @param FLASHProt_Size - д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С(<28><>λ4K)
|
||||
*
|
||||
* @return 0-Success, 1-Err
|
||||
*/
|
||||
uint8_t UserOptionByteConfig(FunctionalState RESET_EN, FunctionalState UART_NO_KEY_EN,
|
||||
uint32_t FLASHProt_Size)
|
||||
{
|
||||
uint32_t s, t;
|
||||
|
||||
FLASH_ROM_READ(0x14, &s, 4);
|
||||
|
||||
if(s == 0xF5F9BDA9)
|
||||
{
|
||||
s = 0;
|
||||
FLASH_EEPROM_CMD(CMD_GET_ROM_INFO, 0x3EFFC, &s, 4);
|
||||
s &= 0xFF;
|
||||
|
||||
if(RESET_EN == ENABLE)
|
||||
s |= RESET_Enable;
|
||||
else
|
||||
s &= RESET_Disable;
|
||||
|
||||
/* bit[7:0]-bit[31-24] */
|
||||
s |= ((~(s << 24)) & 0xFF000000); //<2F><>8λ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣȡ<CFA2><C8A1><EFBFBD><EFBFBD>
|
||||
|
||||
if(UART_NO_KEY_EN == ENABLE)
|
||||
s |= UART_NO_KEY_Enable;
|
||||
|
||||
/* bit[23-10] */
|
||||
s &= 0xFF0003FF;
|
||||
s |= ((FLASHProt_Size << 10) | (5 << 20)) & 0x00FFFC00;
|
||||
|
||||
/*Write user option byte*/
|
||||
FLASH_ROM_WRITE(0x14, &s, 4);
|
||||
|
||||
/* Verify user option byte */
|
||||
FLASH_ROM_READ(0x14, &t, 4);
|
||||
|
||||
if(s == t)
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn UserOptionByteClose_SWD
|
||||
*
|
||||
* @brief <20><><EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD><DFB5>Խӿ<D4BD>
|
||||
*
|
||||
* @return 0-Success, 1-Err
|
||||
*/
|
||||
uint8_t UserOptionByteClose_SWD(void)
|
||||
{
|
||||
uint32_t s, t;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn UserOptionByte_Active
|
||||
*
|
||||
* @brief <20>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD>к<EFBFBD><D0BA>Զ<EFBFBD><D4B6><EFBFBD>λ
|
||||
*
|
||||
* @return 0-Success, 1-Err
|
||||
*/
|
||||
void UserOptionByte_Active(void)
|
||||
{
|
||||
FLASH_ROM_SW_RESET();
|
||||
sys_safe_access_enable();
|
||||
R16_INT_LSI_TUNE = 0xFFFF;
|
||||
sys_safe_access_disable();
|
||||
sys_safe_access_enable();
|
||||
R8_RST_WDOG_CTRL |= RB_SOFTWARE_RESET;
|
||||
sys_safe_access_disable();
|
||||
while(1);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn GET_UNIQUE_ID
|
||||
*
|
||||
* @brief get 64 bit unique ID
|
||||
*
|
||||
* @param Buffer - Pointer to the buffer where data should be stored, Must be aligned to 4 bytes.
|
||||
*
|
||||
* @return 0-SUCCESS (!0)-FAILURE
|
||||
*/
|
||||
void GET_UNIQUE_ID(uint8_t *Buffer)
|
||||
{
|
||||
uint16_t temp;
|
||||
FLASH_EEPROM_CMD( CMD_GET_ROM_INFO, ROM_CFG_MAC_ADDR, Buffer, 0 );
|
||||
temp = (Buffer[0]|(Buffer[1]<<8)) + (Buffer[2]|(Buffer[3]<<8)) + (Buffer[4]|(Buffer[5]<<8));
|
||||
Buffer[6] = temp&0xFF;
|
||||
Buffer[7] = (temp>>8)&0xFF;
|
||||
}
|
||||
145
BLV_RF_W13_V04_20260114/StdPeriphDriver/CH57x_gpio.c
Normal file
145
BLV_RF_W13_V04_20260114/StdPeriphDriver/CH57x_gpio.c
Normal file
@@ -0,0 +1,145 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH57x_gpio.c
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2021/11/17
|
||||
* Description : source file(ch572/ch570)
|
||||
*********************************************************************************
|
||||
* 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 "CH57x_common.h"
|
||||
|
||||
/*********************************************************************
|
||||
* @fn GPIOA_ModeCfg
|
||||
*
|
||||
* @brief GPIOA<4F>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param pin - PA0-PA15
|
||||
* @param mode - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void GPIOA_ModeCfg(uint32_t pin, GPIOModeTypeDef mode)
|
||||
{
|
||||
switch(mode)
|
||||
{
|
||||
case GPIO_ModeIN_Floating:
|
||||
R32_PA_PD_DRV &= ~pin;
|
||||
R32_PA_PU &= ~pin;
|
||||
R32_PA_DIR &= ~pin;
|
||||
break;
|
||||
|
||||
case GPIO_ModeIN_PU:
|
||||
R32_PA_PD_DRV &= ~pin;
|
||||
R32_PA_PU |= pin;
|
||||
R32_PA_DIR &= ~pin;
|
||||
break;
|
||||
|
||||
case GPIO_ModeIN_PD:
|
||||
R32_PA_PD_DRV |= pin;
|
||||
R32_PA_PU &= ~pin;
|
||||
R32_PA_DIR &= ~pin;
|
||||
break;
|
||||
|
||||
case GPIO_ModeOut_PP_5mA:
|
||||
R32_PA_PD_DRV &= ~pin;
|
||||
R32_PA_DIR |= pin;
|
||||
break;
|
||||
|
||||
case GPIO_ModeOut_PP_20mA:
|
||||
R32_PA_PD_DRV |= pin;
|
||||
R32_PA_DIR |= pin;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn GPIOA_ITModeCfg
|
||||
*
|
||||
* @brief GPIOA<4F><41><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param pin - PA0-PA15
|
||||
* @param mode - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void GPIOA_ITModeCfg(uint32_t pin, GPIOITModeTpDef mode)
|
||||
{
|
||||
switch(mode)
|
||||
{
|
||||
case GPIO_ITMode_LowLevel: // <20>͵<EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD>
|
||||
R16_PA_INT_MODE &= ~pin;
|
||||
R32_PA_CLR |= pin;
|
||||
break;
|
||||
|
||||
case GPIO_ITMode_HighLevel: // <20>ߵ<EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD>
|
||||
R16_PA_INT_MODE &= ~pin;
|
||||
R32_PA_OUT |= pin;
|
||||
break;
|
||||
|
||||
case GPIO_ITMode_FallEdge: // <20>½<EFBFBD><C2BD>ش<EFBFBD><D8B4><EFBFBD>
|
||||
R16_PA_INT_MODE |= pin;
|
||||
R32_PA_CLR |= pin;
|
||||
break;
|
||||
|
||||
case GPIO_ITMode_RiseEdge: // <20><><EFBFBD><EFBFBD><EFBFBD>ش<EFBFBD><D8B4><EFBFBD>
|
||||
R16_PA_INT_MODE |= pin;
|
||||
R32_PA_OUT |= pin;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
R16_PA_INT_IF = pin;
|
||||
R16_PA_INT_EN |= pin;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn GPIOPinRemap
|
||||
*
|
||||
* @brief <20><><EFBFBD>蹦<EFBFBD><E8B9A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD><D3B3>
|
||||
*
|
||||
* @param s - <20>Ƿ<EFBFBD>ʹ<EFBFBD><CAB9>ӳ<EFBFBD><D3B3>
|
||||
* @param perph - д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD><D3B3><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>GPIO_pins_remap_define
|
||||
*
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void GPIOPinRemap(FunctionalState s, uint16_t perph)
|
||||
{
|
||||
if(s)
|
||||
{
|
||||
R16_PIN_ALTERNATE_H |= perph;
|
||||
}
|
||||
else
|
||||
{
|
||||
R16_PIN_ALTERNATE_H &= ~perph;
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn GPIOADigitalCfg
|
||||
*
|
||||
* @brief I/O pin<69><6E><EFBFBD>ֹ<EFBFBD><D6B9>ܿ<EFBFBD><DCBF><EFBFBD>
|
||||
*
|
||||
* @param s - <20>Ƿ<EFBFBD><C7B7><EFBFBD>ӦI/O pin<69><6E><EFBFBD>ֹ<EFBFBD><D6B9><EFBFBD>
|
||||
* @param pin - PA0-PA11
|
||||
*/
|
||||
void GPIOADigitalCfg(FunctionalState s, uint16_t pin)
|
||||
{
|
||||
if(s)
|
||||
{
|
||||
R16_PIN_ALTERNATE &= ~pin;
|
||||
}
|
||||
else
|
||||
{
|
||||
R16_PIN_ALTERNATE |= pin;
|
||||
}
|
||||
}
|
||||
|
||||
672
BLV_RF_W13_V04_20260114/StdPeriphDriver/CH57x_i2c.c
Normal file
672
BLV_RF_W13_V04_20260114/StdPeriphDriver/CH57x_i2c.c
Normal file
@@ -0,0 +1,672 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH57x_i2c.c
|
||||
* Author : WCH
|
||||
* Version : V1.0
|
||||
* Date : 2021/03/15
|
||||
* Description : source file(ch572/ch570)
|
||||
*********************************************************************************
|
||||
* 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 "CH57x_common.h"
|
||||
|
||||
/*********************************************************************
|
||||
* @fn I2C_Init
|
||||
*
|
||||
* @brief Initializes the I2Cx peripheral according to the specified
|
||||
* parameters in the I2C_InitStruct.
|
||||
*
|
||||
* @param I2C_Mode - refer to I2C_ModeTypeDef
|
||||
* @param I2C_ClockSpeed - Specifies the clock frequency(Hz).
|
||||
* This parameter must be set to a value lower than 400kHz
|
||||
* @param I2C_DutyCycle - Specifies the I2C fast mode duty cycle.refer to I2C_DutyTypeDef
|
||||
* @param I2C_Ack - Enables or disables the acknowledgement.refer to I2C_AckTypeDef
|
||||
* @param I2C_AckAddr - Specifies if 7-bit or 10-bit address is acknowledged.refer to I2C_AckAddrTypeDef
|
||||
* @param I2C_OwnAddress1 - Specifies the first device own address.
|
||||
* This parameter can be a 7-bit or 10-bit address.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void I2C_Init(I2C_ModeTypeDef I2C_Mode, uint32_t I2C_ClockSpeed, I2C_DutyTypeDef I2C_DutyCycle,
|
||||
I2C_AckTypeDef I2C_Ack, I2C_AckAddrTypeDef I2C_AckAddr, uint16_t I2C_OwnAddress1)
|
||||
{
|
||||
uint32_t sysClock;
|
||||
uint16_t tmpreg;
|
||||
|
||||
I2C_SoftwareResetCmd(ENABLE);
|
||||
I2C_SoftwareResetCmd(DISABLE);
|
||||
|
||||
sysClock = GetSysClock();
|
||||
|
||||
R16_I2C_CTRL2 &= ~RB_I2C_FREQ;
|
||||
R16_I2C_CTRL2 |= (sysClock / 1000000);
|
||||
|
||||
R16_I2C_CTRL1 &= ~RB_I2C_PE;
|
||||
|
||||
if(I2C_ClockSpeed <= 100000)
|
||||
{
|
||||
tmpreg = (sysClock / (I2C_ClockSpeed << 1)) & RB_I2C_CCR;
|
||||
|
||||
if(tmpreg < 0x04)
|
||||
tmpreg = 0x04;
|
||||
|
||||
R16_I2C_RTR = (((sysClock / 1000000) + 1) > 0x3F) ? 0x3F : ((sysClock / 1000000) + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(I2C_DutyCycle == I2C_DutyCycle_2)
|
||||
{
|
||||
tmpreg = (sysClock / (I2C_ClockSpeed * 3)) & RB_I2C_CCR;
|
||||
}
|
||||
else
|
||||
{
|
||||
tmpreg = (sysClock / (I2C_ClockSpeed * 25)) & RB_I2C_CCR;
|
||||
tmpreg |= I2C_DutyCycle_16_9;
|
||||
}
|
||||
|
||||
if(tmpreg == 0)
|
||||
{
|
||||
tmpreg |= (uint16_t)0x0001;
|
||||
}
|
||||
|
||||
tmpreg |= RB_I2C_F_S;
|
||||
R16_I2C_RTR = (uint16_t)((((sysClock / 1000000) * (uint16_t)300) / (uint16_t)1000) + (uint16_t)1);
|
||||
}
|
||||
R16_I2C_CKCFGR = tmpreg;
|
||||
|
||||
R16_I2C_CTRL1 |= RB_I2C_PE;
|
||||
|
||||
R16_I2C_CTRL1 &= ~(RB_I2C_SMBUS | RB_I2C_SMBTYPE | RB_I2C_ACK);
|
||||
R16_I2C_CTRL1 |= I2C_Mode | I2C_Ack;
|
||||
|
||||
R16_I2C_OADDR1 &= 0;
|
||||
R16_I2C_OADDR1 |= I2C_AckAddr | I2C_OwnAddress1;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn I2C_Cmd
|
||||
*
|
||||
* @brief Enables or disables the specified I2C peripheral.
|
||||
*
|
||||
* @param NewState - ENABLE or DISABLE.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void I2C_Cmd(FunctionalState NewState)
|
||||
{
|
||||
if(NewState != DISABLE)
|
||||
R16_I2C_CTRL1 |= RB_I2C_PE;
|
||||
else
|
||||
R16_I2C_CTRL1 &= ~RB_I2C_PE;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn I2C_GenerateSTART
|
||||
*
|
||||
* @brief Generates I2Cx communication START condition.
|
||||
*
|
||||
* @param NewState - ENABLE or DISABLE.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void I2C_GenerateSTART(FunctionalState NewState)
|
||||
{
|
||||
if(NewState != DISABLE)
|
||||
R16_I2C_CTRL1 |= RB_I2C_START;
|
||||
else
|
||||
R16_I2C_CTRL1 &= ~RB_I2C_START;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn I2C_GenerateSTOP
|
||||
*
|
||||
* @brief Generates I2Cx communication STOP condition.
|
||||
*
|
||||
* @param NewState - ENABLE or DISABLE.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void I2C_GenerateSTOP(FunctionalState NewState)
|
||||
{
|
||||
if(NewState != DISABLE)
|
||||
R16_I2C_CTRL1 |= RB_I2C_STOP;
|
||||
else
|
||||
R16_I2C_CTRL1 &= ~RB_I2C_STOP;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn I2C_AcknowledgeConfig
|
||||
*
|
||||
* @brief Enables or disables the specified I2C acknowledge feature.
|
||||
*
|
||||
* @param NewState - ENABLE or DISABLE.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void I2C_AcknowledgeConfig(FunctionalState NewState)
|
||||
{
|
||||
if(NewState != DISABLE)
|
||||
R16_I2C_CTRL1 |= RB_I2C_ACK;
|
||||
else
|
||||
R16_I2C_CTRL1 &= ~RB_I2C_ACK;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn I2C_OwnAddress2Config
|
||||
*
|
||||
* @brief Configures the specified I2C own address2.
|
||||
*
|
||||
* @param Address - specifies the 7bit I2C own address2.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void I2C_OwnAddress2Config(uint8_t Address)
|
||||
{
|
||||
R16_I2C_OADDR2 &= ~RB_I2C_ADD2;
|
||||
R16_I2C_OADDR2 |= (uint16_t)(Address & RB_I2C_ADD2);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn I2C_DualAddressCmd
|
||||
*
|
||||
* @brief Enables or disables the specified I2C dual addressing mode.
|
||||
*
|
||||
* @param NewState - ENABLE or DISABLE.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void I2C_DualAddressCmd(FunctionalState NewState)
|
||||
{
|
||||
if(NewState != DISABLE)
|
||||
R16_I2C_OADDR2 |= RB_I2C_ENDUAL;
|
||||
else
|
||||
R16_I2C_OADDR2 &= ~RB_I2C_ENDUAL;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn I2C_GeneralCallCmd
|
||||
*
|
||||
* @brief Enables or disables the specified I2C general call feature.
|
||||
*
|
||||
* @param NewState - ENABLE or DISABLE.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void I2C_GeneralCallCmd(FunctionalState NewState)
|
||||
{
|
||||
if(NewState != DISABLE)
|
||||
R16_I2C_CTRL1 |= RB_I2C_ENGC;
|
||||
else
|
||||
R16_I2C_CTRL1 &= ~RB_I2C_ENGC;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn I2C_ITConfig
|
||||
*
|
||||
* @brief Enables or disables the specified I2C interrupts.
|
||||
*
|
||||
* @param I2C_IT - specifies the I2C interrupts sources to be enabled or disabled.
|
||||
* I2C_IT_BUF - Buffer interrupt mask.
|
||||
* I2C_IT_EVT - Event interrupt mask.
|
||||
* I2C_IT_ERR - Error interrupt mask.
|
||||
* @param NewState - ENABLE or DISABLE.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void I2C_ITConfig(I2C_ITTypeDef I2C_IT, FunctionalState NewState)
|
||||
{
|
||||
if(NewState != DISABLE)
|
||||
R16_I2C_CTRL2 |= I2C_IT;
|
||||
else
|
||||
R16_I2C_CTRL2 &= (uint16_t)~I2C_IT;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn I2C_SendData
|
||||
*
|
||||
* @brief Sends a data byte through the I2Cx peripheral.
|
||||
*
|
||||
* @param Data - Byte to be transmitted.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void I2C_SendData(uint8_t Data)
|
||||
{
|
||||
R16_I2C_DATAR = Data;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn I2C_ReceiveData
|
||||
*
|
||||
* @brief Returns the most recent received data by the I2Cx peripheral.
|
||||
*
|
||||
* @return The value of the received data.
|
||||
*/
|
||||
uint8_t I2C_ReceiveData(void)
|
||||
{
|
||||
return (uint8_t)R16_I2C_DATAR;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn I2C_Send7bitAddress
|
||||
*
|
||||
* @brief Transmits the address byte to select the slave device.
|
||||
*
|
||||
* @param Address - specifies the slave address which will be transmitted.
|
||||
* @param I2C_Direction - specifies whether the I2C device will be a Transmitter or a Receiver.
|
||||
* I2C_Direction_Transmitter - Transmitter mode.
|
||||
* I2C_Direction_Receiver - Receiver mode.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void I2C_Send7bitAddress(uint8_t Address, uint8_t I2C_Direction)
|
||||
{
|
||||
if(I2C_Direction != I2C_Direction_Transmitter)
|
||||
Address |= OADDR1_ADD0_Set;
|
||||
else
|
||||
Address &= OADDR1_ADD0_Reset;
|
||||
|
||||
R16_I2C_DATAR = Address;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn I2C_SoftwareResetCmd
|
||||
*
|
||||
* @brief Enables or disables the specified I2C software reset.
|
||||
*
|
||||
* @param NewState - ENABLE or DISABLE.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void I2C_SoftwareResetCmd(FunctionalState NewState)
|
||||
{
|
||||
if(NewState != DISABLE)
|
||||
R16_I2C_CTRL1 |= RB_I2C_SWRST;
|
||||
else
|
||||
R16_I2C_CTRL1 &= ~RB_I2C_SWRST;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn I2C_NACKPositionConfig
|
||||
*
|
||||
* @brief Selects the specified I2C NACK position in master receiver mode.
|
||||
*
|
||||
* @param I2C_NACKPosition - specifies the NACK position.
|
||||
* I2C_NACKPosition_Next - indicates that the next byte will be the last received byte.
|
||||
* I2C_NACKPosition_Current - indicates that current byte is the last received byte.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void I2C_NACKPositionConfig(uint16_t I2C_NACKPosition)
|
||||
{
|
||||
if(I2C_NACKPosition == I2C_NACKPosition_Next)
|
||||
R16_I2C_CTRL1 |= I2C_NACKPosition_Next;
|
||||
else
|
||||
R16_I2C_CTRL1 &= I2C_NACKPosition_Current;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn I2C_SMBusAlertConfig
|
||||
*
|
||||
* @brief Drives the SMBusAlert pin high or low for the specified I2C.
|
||||
*
|
||||
* @param I2C_SMBusAlert - specifies SMBAlert pin level.
|
||||
* I2C_SMBusAlert_Low - SMBAlert pin driven low.
|
||||
* I2C_SMBusAlert_High - SMBAlert pin driven high.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void I2C_SMBusAlertConfig(uint16_t I2C_SMBusAlert)
|
||||
{
|
||||
if(I2C_SMBusAlert == I2C_SMBusAlert_Low)
|
||||
R16_I2C_CTRL1 |= I2C_SMBusAlert_Low;
|
||||
else
|
||||
R16_I2C_CTRL1 &= I2C_SMBusAlert_High;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn I2C_TransmitPEC
|
||||
*
|
||||
* @brief Enables or disables the specified I2C PEC transfer.
|
||||
*
|
||||
* @param NewState - ENABLE or DISABLE.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void I2C_TransmitPEC(FunctionalState NewState)
|
||||
{
|
||||
if(NewState != DISABLE)
|
||||
R16_I2C_CTRL1 |= RB_I2C_PEC;
|
||||
else
|
||||
R16_I2C_CTRL1 &= ~RB_I2C_PEC;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn I2C_PECPositionConfig
|
||||
*
|
||||
* @brief Selects the specified I2C PEC position.
|
||||
*
|
||||
* @param I2C_PECPosition - specifies the PEC position.
|
||||
* I2C_PECPosition_Next - indicates that the next byte is PEC.
|
||||
* I2C_PECPosition_Current - indicates that current byte is PEC.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void I2C_PECPositionConfig(uint16_t I2C_PECPosition)
|
||||
{
|
||||
if(I2C_PECPosition == I2C_PECPosition_Next)
|
||||
R16_I2C_CTRL1 |= I2C_PECPosition_Next;
|
||||
else
|
||||
R16_I2C_CTRL1 &= I2C_PECPosition_Current;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn I2C_CalculatePEC
|
||||
*
|
||||
* @brief Enables or disables the PEC value calculation of the transferred bytes.
|
||||
*
|
||||
* @param NewState - ENABLE or DISABLE.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void I2C_CalculatePEC(FunctionalState NewState)
|
||||
{
|
||||
if(NewState != DISABLE)
|
||||
R16_I2C_CTRL1 |= RB_I2C_ENPEC;
|
||||
else
|
||||
R16_I2C_CTRL1 &= ~RB_I2C_ENPEC;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn I2C_GetPEC
|
||||
*
|
||||
* @brief Returns the PEC value for the specified I2C.
|
||||
*
|
||||
* @return The PEC value.
|
||||
*/
|
||||
uint8_t I2C_GetPEC(void)
|
||||
{
|
||||
return (R16_I2C_STAR2 >> 8);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn I2C_ARPCmd
|
||||
*
|
||||
* @brief Enables or disables the specified I2C ARP.
|
||||
*
|
||||
* @param NewState - ENABLE or DISABLE.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void I2C_ARPCmd(FunctionalState NewState)
|
||||
{
|
||||
if(NewState != DISABLE)
|
||||
R16_I2C_CTRL1 |= RB_I2C_EBARP;
|
||||
else
|
||||
R16_I2C_CTRL1 &= ~RB_I2C_EBARP;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn I2C_StretchClockCmd
|
||||
*
|
||||
* @brief Enables or disables the specified I2C Clock stretching.
|
||||
*
|
||||
* @param NewState - ENABLE or DISABLE.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void I2C_StretchClockCmd(FunctionalState NewState)
|
||||
{
|
||||
if(NewState == DISABLE)
|
||||
R16_I2C_CTRL1 |= RB_I2C_NOSTRETCH;
|
||||
else
|
||||
R16_I2C_CTRL1 &= ~RB_I2C_NOSTRETCH;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn I2C_FastModeDutyCycleConfig
|
||||
*
|
||||
* @brief Selects the specified I2C fast mode duty cycle.
|
||||
*
|
||||
* @param I2C_DutyCycle - specifies the fast mode duty cycle.
|
||||
* I2C_DutyCycle_2 - I2C fast mode Tlow/Thigh = 2.
|
||||
* I2C_DutyCycle_16_9 - I2C fast mode Tlow/Thigh = 16/9.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void I2C_FastModeDutyCycleConfig(uint16_t I2C_DutyCycle)
|
||||
{
|
||||
if(I2C_DutyCycle != I2C_DutyCycle_16_9)
|
||||
R16_I2C_CKCFGR &= ~I2C_DutyCycle_16_9;
|
||||
else
|
||||
R16_I2C_CKCFGR |= I2C_DutyCycle_16_9;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn I2C_CheckEvent
|
||||
*
|
||||
* @brief Checks whether the last I2Cx Event is equal to the one passed as parameter.
|
||||
*
|
||||
* @param I2C_EVENT - specifies the event to be checked.
|
||||
* I2C_EVENT_SLAVE_TRANSMITTER_ADDRESS_MATCHED : EV1.
|
||||
* I2C_EVENT_SLAVE_RECEIVER_ADDRESS_MATCHED : EV1.
|
||||
* I2C_EVENT_SLAVE_TRANSMITTER_SECONDADDRESS_MATCHED : EV1.
|
||||
* I2C_EVENT_SLAVE_RECEIVER_SECONDADDRESS_MATCHED : EV1.
|
||||
* I2C_EVENT_SLAVE_GENERALCALLADDRESS_MATCHED : EV1.
|
||||
* I2C_EVENT_SLAVE_BYTE_RECEIVED : EV2.
|
||||
* (I2C_EVENT_SLAVE_BYTE_RECEIVED | I2C_FLAG_DUALF) : EV2.
|
||||
* (I2C_EVENT_SLAVE_BYTE_RECEIVED | I2C_FLAG_GENCALL) : EV2.
|
||||
* I2C_EVENT_SLAVE_BYTE_TRANSMITTED : EV3.
|
||||
* (I2C_EVENT_SLAVE_BYTE_TRANSMITTED | I2C_FLAG_DUALF) : EV3.
|
||||
* (I2C_EVENT_SLAVE_BYTE_TRANSMITTED | I2C_FLAG_GENCALL) : EV3.
|
||||
* I2C_EVENT_SLAVE_ACK_FAILURE : EV3_2.
|
||||
* I2C_EVENT_SLAVE_STOP_DETECTED : EV4.
|
||||
* I2C_EVENT_MASTER_MODE_SELECT : EV5.
|
||||
* I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED : EV6.
|
||||
* I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED : EV6.
|
||||
* I2C_EVENT_MASTER_BYTE_RECEIVED : EV7.
|
||||
* I2C_EVENT_MASTER_BYTE_TRANSMITTING : EV8.
|
||||
* I2C_EVENT_MASTER_BYTE_TRANSMITTED : EV8_2.
|
||||
* I2C_EVENT_MASTER_MODE_ADDRESS10 : EV9.
|
||||
*
|
||||
* @return 1 - SUCCESS or 0 - ERROR.
|
||||
*/
|
||||
uint8_t I2C_CheckEvent(uint32_t I2C_EVENT)
|
||||
{
|
||||
uint32_t lastevent = 0;
|
||||
uint32_t flag1 = 0, flag2 = 0;
|
||||
uint8_t status = 0;
|
||||
|
||||
flag1 = R16_I2C_STAR1;
|
||||
flag2 = R16_I2C_STAR2;
|
||||
flag2 = flag2 << 16;
|
||||
|
||||
lastevent = (flag1 | flag2) & FLAG_Mask;
|
||||
|
||||
if((lastevent & I2C_EVENT) == I2C_EVENT)
|
||||
{
|
||||
status = !0;
|
||||
}
|
||||
else
|
||||
{
|
||||
status = 0;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn I2C_GetLastEvent
|
||||
*
|
||||
* @brief Returns the last I2Cx Event.
|
||||
*
|
||||
* @return The last event.
|
||||
*/
|
||||
uint32_t I2C_GetLastEvent(void)
|
||||
{
|
||||
uint32_t lastevent = 0;
|
||||
uint32_t flag1 = 0, flag2 = 0;
|
||||
|
||||
flag1 = R16_I2C_STAR1;
|
||||
flag2 = R16_I2C_STAR2;
|
||||
flag2 = flag2 << 16;
|
||||
lastevent = (flag1 | flag2) & FLAG_Mask;
|
||||
|
||||
return lastevent;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn I2C_GetFlagStatus
|
||||
*
|
||||
* @brief Checks whether the last I2Cx Event is equal to the one passed as parameter.
|
||||
*
|
||||
* @param I2C_FLAG - specifies the flag to check.
|
||||
* I2C_FLAG_DUALF - Dual flag (Slave mode).
|
||||
* I2C_FLAG_SMBHOST - SMBus host header (Slave mode).
|
||||
* I2C_FLAG_SMBDEFAULT - SMBus default header (Slave mode).
|
||||
* I2C_FLAG_GENCALL - General call header flag (Slave mode).
|
||||
* I2C_FLAG_TRA - Transmitter/Receiver flag.
|
||||
* I2C_FLAG_BUSY - Bus busy flag.
|
||||
* I2C_FLAG_MSL - Master/Slave flag.
|
||||
* I2C_FLAG_SMBALERT - SMBus Alert flag.
|
||||
* I2C_FLAG_TIMEOUT - Timeout or Tlow error flag.
|
||||
* I2C_FLAG_PECERR - PEC error in reception flag.
|
||||
* I2C_FLAG_OVR - Overrun/Underrun flag (Slave mode).
|
||||
* I2C_FLAG_AF - Acknowledge failure flag.
|
||||
* I2C_FLAG_ARLO - Arbitration lost flag (Master mode).
|
||||
* I2C_FLAG_BERR - Bus error flag.
|
||||
* I2C_FLAG_TXE - Data register empty flag (Transmitter).
|
||||
* I2C_FLAG_RXNE - Data register not empty (Receiver) flag.
|
||||
* I2C_FLAG_STOPF - Stop detection flag (Slave mode).
|
||||
* I2C_FLAG_ADD10 - 10-bit header sent flag (Master mode).
|
||||
* I2C_FLAG_BTF - Byte transfer finished flag.
|
||||
* I2C_FLAG_ADDR - Address sent flag (Master mode) "ADSL"
|
||||
* Address matched flag (Slave mode)"ENDA".
|
||||
* I2C_FLAG_SB - Start bit flag (Master mode).
|
||||
*
|
||||
* @return FlagStatus - SET or RESET.
|
||||
*/
|
||||
FlagStatus I2C_GetFlagStatus(uint32_t I2C_FLAG)
|
||||
{
|
||||
FlagStatus bitstatus = RESET;
|
||||
__IO uint32_t i2creg = 0, i2cxbase = 0;
|
||||
|
||||
i2cxbase = (uint32_t)BA_I2C;
|
||||
i2creg = I2C_FLAG >> 28;
|
||||
I2C_FLAG &= FLAG_Mask;
|
||||
|
||||
if(i2creg != 0)
|
||||
{
|
||||
i2cxbase += 0x14;
|
||||
}
|
||||
else
|
||||
{
|
||||
I2C_FLAG = (uint32_t)(I2C_FLAG >> 16);
|
||||
i2cxbase += 0x18;
|
||||
}
|
||||
|
||||
if(((*(__IO uint32_t *)i2cxbase) & I2C_FLAG) != (uint32_t)RESET)
|
||||
{
|
||||
bitstatus = SET;
|
||||
}
|
||||
else
|
||||
{
|
||||
bitstatus = RESET;
|
||||
}
|
||||
|
||||
return bitstatus;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn I2C_ClearFlag
|
||||
*
|
||||
* @brief Clears the I2Cx's pending flags.
|
||||
*
|
||||
* @param I2C_FLAG - specifies the flag to clear.
|
||||
* I2C_FLAG_SMBALERT - SMBus Alert flag.
|
||||
* I2C_FLAG_TIMEOUT - Timeout or Tlow error flag.
|
||||
* I2C_FLAG_PECERR - PEC error in reception flag.
|
||||
* I2C_FLAG_OVR - Overrun/Underrun flag (Slave mode).
|
||||
* I2C_FLAG_AF - Acknowledge failure flag.
|
||||
* I2C_FLAG_ARLO - Arbitration lost flag (Master mode).
|
||||
* I2C_FLAG_BERR - Bus error flag.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void I2C_ClearFlag(uint32_t I2C_FLAG)
|
||||
{
|
||||
uint32_t flagpos = 0;
|
||||
|
||||
flagpos = I2C_FLAG & FLAG_Mask;
|
||||
R16_I2C_STAR1 = (uint16_t)~flagpos;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn I2C_GetITStatus
|
||||
*
|
||||
* @brief Checks whether the specified I2C interrupt has occurred or not.
|
||||
*
|
||||
* @param II2C_IT - specifies the interrupt source to check.
|
||||
* I2C_FLAG_SMBALERT - SMBus Alert flag.
|
||||
* I2C_FLAG_TIMEOUT - Timeout or Tlow error flag.
|
||||
* I2C_FLAG_PECERR - PEC error in reception flag.
|
||||
* I2C_FLAG_OVR - Overrun/Underrun flag (Slave mode).
|
||||
* I2C_FLAG_AF - Acknowledge failure flag.
|
||||
* I2C_FLAG_ARLO - Arbitration lost flag (Master mode).
|
||||
* I2C_FLAG_BERR - Bus error flag.
|
||||
* I2C_FLAG_TXE - Data register empty flag (Transmitter).
|
||||
* I2C_FLAG_RXNE - Data register not empty (Receiver) flag.
|
||||
* I2C_FLAG_STOPF - Stop detection flag (Slave mode).
|
||||
* I2C_FLAG_ADD10 - 10-bit header sent flag (Master mode).
|
||||
* I2C_FLAG_BTF - Byte transfer finished flag.
|
||||
* I2C_FLAG_ADDR - Address sent flag (Master mode) "ADSL"
|
||||
* Address matched flag (Slave mode)"ENDA".
|
||||
* I2C_FLAG_SB - Start bit flag (Master mode).
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
ITStatus I2C_GetITStatus(uint32_t I2C_IT)
|
||||
{
|
||||
ITStatus bitstatus = RESET;
|
||||
uint32_t enablestatus = 0;
|
||||
|
||||
enablestatus = (uint32_t)(((I2C_IT & ITEN_Mask) >> 16) & (R16_I2C_CTRL2));
|
||||
I2C_IT &= FLAG_Mask;
|
||||
|
||||
if(((R16_I2C_STAR1 & I2C_IT) != (uint32_t)RESET) && enablestatus)
|
||||
{
|
||||
bitstatus = SET;
|
||||
}
|
||||
else
|
||||
{
|
||||
bitstatus = RESET;
|
||||
}
|
||||
|
||||
return bitstatus;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn I2C_ClearITPendingBit
|
||||
*
|
||||
* @brief Clears the I2Cx interrupt pending bits.
|
||||
*
|
||||
* @param I2C_IT - specifies the interrupt pending bit to clear.
|
||||
* I2C_IT_SMBALERT - SMBus Alert interrupt.
|
||||
* I2C_IT_TIMEOUT - Timeout or Tlow error interrupt.
|
||||
* I2C_IT_PECERR - PEC error in reception interrupt.
|
||||
* I2C_IT_OVR - Overrun/Underrun interrupt (Slave mode).
|
||||
* I2C_IT_AF - Acknowledge failure interrupt.
|
||||
* I2C_IT_ARLO - Arbitration lost interrupt (Master mode).
|
||||
* I2C_IT_BERR - Bus error interrupt.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void I2C_ClearITPendingBit(uint32_t I2C_IT)
|
||||
{
|
||||
uint32_t flagpos = 0;
|
||||
|
||||
flagpos = I2C_IT & FLAG_Mask;
|
||||
R16_I2C_STAR1 = (uint16_t)~flagpos;
|
||||
}
|
||||
63
BLV_RF_W13_V04_20260114/StdPeriphDriver/CH57x_keyscan.c
Normal file
63
BLV_RF_W13_V04_20260114/StdPeriphDriver/CH57x_keyscan.c
Normal file
@@ -0,0 +1,63 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH57x_keyscan.c
|
||||
* Author : WCH
|
||||
* Version : V1.0
|
||||
* Date : 2024/12/17
|
||||
* Description : source file(ch572/ch570)
|
||||
*********************************************************************************
|
||||
* 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 "CH57x_common.h"
|
||||
|
||||
/*********************************************************************
|
||||
* @fn KeyScan_Cfg
|
||||
*
|
||||
* @brief <20><><EFBFBD>ð<EFBFBD><C3B0><EFBFBD>ɨ<EFBFBD>蹦<EFBFBD><E8B9A6>
|
||||
*
|
||||
* @param s - <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɨ<EFBFBD>蹦<EFBFBD><E8B9A6>
|
||||
* @param keyScanPin - <20><><EFBFBD>ò<EFBFBD><C3B2>밴<EFBFBD><EBB0B4>ɨ<EFBFBD><C9A8><EFBFBD><EFBFBD>IOʹ<4F><CAB9>
|
||||
* @param ClkDiv - <20><><EFBFBD><EFBFBD>ɨ<EFBFBD><C9A8>ʱ<EFBFBD>ӷ<EFBFBD>Ƶ<EFBFBD><C6B5>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ԴLSI
|
||||
* @param Rep - <20><><EFBFBD><EFBFBD>ɨ<EFBFBD>赽<EFBFBD><E8B5BD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void KeyScan_Cfg(uint8_t s, uint16_t keyScanPin, uint16_t ClkDiv, uint16_t Rep)
|
||||
{
|
||||
if(s == DISABLE)
|
||||
{
|
||||
R16_KEY_SCAN_CTRL &= ~(RB_SCAN_START_EN);
|
||||
}
|
||||
else
|
||||
{
|
||||
R16_KEY_SCAN_CTRL |= keyScanPin | ClkDiv | Rep;
|
||||
R16_KEY_SCAN_CTRL |= RB_SCAN_START_EN;
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn KeyPress_Wake
|
||||
*
|
||||
* @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>»<EFBFBD><C2BB><EFBFBD>˯<EFBFBD><CBAF>ʹ<EFBFBD><CAB9>
|
||||
*
|
||||
* @param s - <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD>
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void KeyPress_Wake(uint8_t s)
|
||||
{
|
||||
if(s == DISABLE)
|
||||
{
|
||||
sys_safe_access_enable();
|
||||
R8_SLP_CLK_OFF0 &= ~(RB_SLP_KEYSCAN_WAKE);
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
else
|
||||
{
|
||||
sys_safe_access_enable();
|
||||
R8_SLP_CLK_OFF0 |= RB_SLP_KEYSCAN_WAKE;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
}
|
||||
246
BLV_RF_W13_V04_20260114/StdPeriphDriver/CH57x_pwm.c
Normal file
246
BLV_RF_W13_V04_20260114/StdPeriphDriver/CH57x_pwm.c
Normal file
@@ -0,0 +1,246 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH57x_pwm.c
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2021/11/17
|
||||
* Description : source file(ch572/ch570)
|
||||
*********************************************************************************
|
||||
* 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 "CH57x_common.h"
|
||||
|
||||
/*********************************************************************
|
||||
* @fn PWMX_CycleCfg
|
||||
*
|
||||
* @brief PWM 8λ<38><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param cyc - refer to PWMX_CycleTypeDef
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void PWMX_CycleCfg(PWMX_CycleTypeDef cyc)
|
||||
{
|
||||
switch(cyc)
|
||||
{
|
||||
case PWMX_Cycle_256:
|
||||
R8_PWM_CONFIG &= ~(0x07);
|
||||
break;
|
||||
|
||||
case PWMX_Cycle_255:
|
||||
R8_PWM_CONFIG |= 0x01;
|
||||
break;
|
||||
|
||||
case PWMX_Cycle_128:
|
||||
R8_PWM_CONFIG |= (1 << 1);
|
||||
break;
|
||||
|
||||
case PWMX_Cycle_127:
|
||||
R8_PWM_CONFIG |= (1 << 1) | 0x01;
|
||||
break;
|
||||
|
||||
case PWMX_Cycle_64:
|
||||
R8_PWM_CONFIG |= (2 << 1);
|
||||
break;
|
||||
|
||||
case PWMX_Cycle_63:
|
||||
R8_PWM_CONFIG |= (2 << 1) | 0x01;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn PWMX_16bit_CycleCfg
|
||||
*
|
||||
* @brief PWM 16λ<36><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param cyc - 16λ<36><CEBB><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void PWMX_16bit_CycleCfg(uint8_t ch, uint16_t cyc)
|
||||
{
|
||||
if(ch & (CH_PWM1|CH_PWM2|CH_PWM3))
|
||||
{
|
||||
R16_PWM_CYC_VALUE = cyc;
|
||||
}
|
||||
if(ch & (CH_PWM4|CH_PWM5))
|
||||
{
|
||||
R16_PWM_CYC1_VALUE = cyc;
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn PWMX_16bit_ACTOUT
|
||||
*
|
||||
* @brief PWM 16λ<36><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param ch - select channel of pwm, refer to channel of PWM define
|
||||
* @param da - effective pulse width
|
||||
* @param pr - select wave polar, refer to PWMX_PolarTypeDef
|
||||
* @param s - control pwmx function, ENABLE or DISABLE
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void PWMX_16bit_ACTOUT(uint8_t ch, uint16_t da, PWMX_PolarTypeDef pr, FunctionalState s)
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
if(s == DISABLE)
|
||||
{
|
||||
R8_PWM_OUT_EN &= ~(ch);
|
||||
}
|
||||
else
|
||||
{
|
||||
(pr) ? (R8_PWM_POLAR |= (ch)) : (R8_PWM_POLAR &= ~(ch));
|
||||
for(i = 0; i < 5; i++)
|
||||
{
|
||||
if((ch >> i) & 1)
|
||||
{
|
||||
if(i<3)
|
||||
{
|
||||
*((volatile uint16_t *)((&R16_PWM1_DATA) + i)) = da;
|
||||
}
|
||||
else
|
||||
{
|
||||
*((volatile uint16_t *)((&R16_PWM4_DATA) + (i-3))) = da;
|
||||
}
|
||||
}
|
||||
}
|
||||
R8_PWM_OUT_EN |= (ch);
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn PWMX_ACTOUT
|
||||
*
|
||||
* @brief PWM 8λ<38><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param ch - select channel of pwm, refer to channel of PWM define
|
||||
* @param da - effective pulse width
|
||||
* @param pr - select wave polar, refer to PWMX_PolarTypeDef
|
||||
* @param s - control pwmx function, ENABLE or DISABLE
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void PWMX_ACTOUT(uint8_t ch, uint8_t da, PWMX_PolarTypeDef pr, FunctionalState s)
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
if(s == DISABLE)
|
||||
{
|
||||
R8_PWM_OUT_EN &= ~(ch);
|
||||
}
|
||||
else
|
||||
{
|
||||
(pr) ? (R8_PWM_POLAR |= (ch)) : (R8_PWM_POLAR &= ~(ch));
|
||||
switch(ch)
|
||||
{
|
||||
case CH_PWM1:
|
||||
*((volatile uint16_t *)((&R8_PWM1_DATA))) = da;
|
||||
break;
|
||||
case CH_PWM2:
|
||||
*((volatile uint16_t *)((&R8_PWM2_DATA))) = da;
|
||||
break;
|
||||
case CH_PWM3:
|
||||
*((volatile uint16_t *)((&R8_PWM3_DATA))) = da;
|
||||
break;
|
||||
case CH_PWM4:
|
||||
*((volatile uint16_t *)((&R8_PWM4_DATA))) = da;
|
||||
break;
|
||||
case CH_PWM5:
|
||||
*((volatile uint16_t *)((&R8_PWM5_DATA))) = da;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
R8_PWM_OUT_EN |= (ch);
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn PWMX_AlterOutCfg
|
||||
*
|
||||
* @brief PWM <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param ch - select group of PWM alternate output
|
||||
* RB_PWM4_5_STAG_EN - PWM4 <20><> PWM5 ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @param s - control pwmx function, ENABLE or DISABLE
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void PWMX_AlterOutCfg(uint8_t ch, FunctionalState s)
|
||||
{
|
||||
if(s == DISABLE)
|
||||
{
|
||||
R8_PWM_CONFIG &= ~(ch);
|
||||
}
|
||||
else
|
||||
{
|
||||
R8_PWM_CONFIG |= (ch);
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn PWMX_SyncOutCfg
|
||||
*
|
||||
* @brief PWM ͬ<><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param s - control pwmx function, ENABLE or DISABLE
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void PWMX_SyncOutCfg(FunctionalState s)
|
||||
{
|
||||
if(s == DISABLE)
|
||||
{
|
||||
R8_PWM_CONFIG &= ~(RB_PWM_SYNC_EN);
|
||||
}
|
||||
else
|
||||
{
|
||||
R8_PWM_CONFIG |= RB_PWM_SYNC_EN;
|
||||
R8_PWM_CONFIG |= RB_PWM_SYNC_START;
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn PWM_DMACfg
|
||||
*
|
||||
* @brief <20><><EFBFBD><EFBFBD>PWM DMA<4D><41><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param s - <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>DMA<4D><41><EFBFBD><EFBFBD>
|
||||
* @param startAddr - DMA <20><>ʼ<EFBFBD><CABC>ַ
|
||||
* @param endAddr - DMA <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
||||
* @param m - <20><><EFBFBD><EFBFBD>DMAģʽ
|
||||
* @param ch - <20><><EFBFBD><EFBFBD>DMA<4D><41><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void PWM_DMACfg(uint8_t s, uint32_t startAddr, uint32_t endAddr, PWM_DMAModeTypeDef m, PWM_DMAChannel ch)
|
||||
{
|
||||
if(s == DISABLE)
|
||||
{
|
||||
R8_PWM_DMA_CTRL = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
R32_PWM_DMA_BEG = startAddr & 0xFFFF;
|
||||
R32_PWM_DMA_END = endAddr & 0xFFFF;
|
||||
|
||||
if(m)
|
||||
R8_PWM_DMA_CTRL = RB_DMA_ADDR_LOOP | RB_DMA_ENABLE;
|
||||
else
|
||||
R8_PWM_DMA_CTRL = RB_DMA_ENABLE;
|
||||
|
||||
if(ch != Mode_DMACH4_5)
|
||||
{
|
||||
if(ch == Mode_DMACH1_3) R8_PWM_DMA_CTRL |= RB_DMA_SEL;
|
||||
else R8_PWM_CONFIG |= RB_PWM_SYNC_EN | RB_PWM_SYNC_START;
|
||||
}
|
||||
}
|
||||
}
|
||||
300
BLV_RF_W13_V04_20260114/StdPeriphDriver/CH57x_pwr.c
Normal file
300
BLV_RF_W13_V04_20260114/StdPeriphDriver/CH57x_pwr.c
Normal file
@@ -0,0 +1,300 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH57x_pwr.c
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2021/11/17
|
||||
* Description : source file(ch572/ch570)
|
||||
*********************************************************************************
|
||||
* 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 "CH57x_common.h"
|
||||
|
||||
/*********************************************************************
|
||||
* @fn PWR_PeriphClkCfg
|
||||
*
|
||||
* @brief <20><><EFBFBD><EFBFBD>ʱ<EFBFBD>ӿ<EFBFBD><D3BF><EFBFBD>λ
|
||||
*
|
||||
* @param s - <20>Ƿ<EFBFBD><C7B7><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
* @param perph - please refer to Peripher CLK control bit define
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void PWR_PeriphClkCfg(FunctionalState s, uint16_t perph)
|
||||
{
|
||||
uint32_t sleep_ctrl = R32_SLEEP_CONTROL;
|
||||
|
||||
if(s == DISABLE)
|
||||
{
|
||||
sleep_ctrl |= perph;
|
||||
}
|
||||
else
|
||||
{
|
||||
sleep_ctrl &= ~perph;
|
||||
}
|
||||
|
||||
sys_safe_access_enable();
|
||||
R32_SLEEP_CONTROL = sleep_ctrl;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn PWR_PeriphWakeUpCfg
|
||||
*
|
||||
* @brief ˯<><EFBFBD><DFBB><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param s - <20>Ƿ<EFBFBD><C7B7><EFBFBD><F2BFAAB4><EFBFBD><EFBFBD><EFBFBD>˯<EFBFBD><EFBFBD><DFBB>ѹ<EFBFBD><D1B9><EFBFBD>
|
||||
* @param perph - <20><>Ҫ<EFBFBD><D2AA><EFBFBD>õĻ<C3B5><C4BB><EFBFBD>Դ
|
||||
* RB_GPIO_WAKE_MODE - GPIO<49><4F><EFBFBD>ػ<EFBFBD><D8BB><EFBFBD>ģʽʹ<CABD><CAB9> 1:<3A><><EFBFBD>ػ<EFBFBD><D8BB><EFBFBD>,RB_SLP_GPIO_EDGE_MODE=1,˫<><CBAB><EFBFBD>ػ<EFBFBD><D8BB><EFBFBD>
|
||||
* RB_SLP_GPIO_EDGE_MODE=0,<2C><><EFBFBD><EFBFBD><EFBFBD>ػ<EFBFBD><D8BB><EFBFBD>;0:<3A><>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD>
|
||||
* RB_SLP_USB_WAKE - USBFS Ϊ<><CEAA><EFBFBD><EFBFBD>Դ
|
||||
* RB_SLP_USB2_WAKE - USBHS Ϊ<><CEAA><EFBFBD><EFBFBD>Դ
|
||||
* RB_SLP_RTC_WAKE - RTC Ϊ<><CEAA><EFBFBD><EFBFBD>Դ
|
||||
* RB_SLP_GPIO_WAKE - GPIO Ϊ<><CEAA><EFBFBD><EFBFBD>Դ
|
||||
* RB_SLP_BAT_WAKE - BAT Ϊ<><CEAA><EFBFBD><EFBFBD>Դ
|
||||
* RB_SLP_GPIO_EDGE_MODE - GPIO<49><4F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ػ<EFBFBD><D8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><D8B6>ܻ<EFBFBD><DCBB><EFBFBD>
|
||||
* @param mode - refer to WakeUP_ModeypeDef
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void PWR_PeriphWakeUpCfg(FunctionalState s, uint8_t perph, WakeUP_ModeypeDef mode)
|
||||
{
|
||||
if(s == DISABLE)
|
||||
{
|
||||
sys_safe_access_enable();
|
||||
R8_SLP_WAKE_CTRL &= ~perph;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
else
|
||||
{
|
||||
sys_safe_access_enable();
|
||||
R8_SLP_WAKE_CTRL |= RB_WAKE_EV_MODE | perph;
|
||||
sys_safe_access_disable();
|
||||
sys_safe_access_enable();
|
||||
R8_SLP_POWER_CTRL &= ~(RB_WAKE_DLY_MOD);
|
||||
sys_safe_access_disable();
|
||||
sys_safe_access_enable();
|
||||
R8_SLP_POWER_CTRL |= mode;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn PowerMonitor
|
||||
*
|
||||
* @brief <20><>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param s - <20>Ƿ<EFBFBD><C7B7>˹<F2BFAAB4><CBB9><EFBFBD>
|
||||
* @param vl - refer to VolM_LevelypeDef
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void PowerMonitor(FunctionalState s, VolM_LevelypeDef vl)
|
||||
{
|
||||
uint8_t ctrl = R8_BAT_DET_CTRL;
|
||||
uint8_t cfg = R8_BAT_DET_CFG;
|
||||
|
||||
if(s == DISABLE)
|
||||
{
|
||||
sys_safe_access_enable();
|
||||
R8_BAT_DET_CTRL = 0;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
else
|
||||
{
|
||||
cfg = vl & 0x03;
|
||||
ctrl = RB_BAT_MON_EN;
|
||||
sys_safe_access_enable();
|
||||
R8_BAT_DET_CTRL = ctrl;
|
||||
R8_BAT_DET_CFG = cfg;
|
||||
sys_safe_access_disable();
|
||||
|
||||
mDelayuS(1);
|
||||
sys_safe_access_enable();
|
||||
R8_BAT_DET_CTRL |= RB_BAT_LOW_IE;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn LowPower_Idle
|
||||
*
|
||||
* @brief <20><EFBFBD><CDB9><EFBFBD>-Idleģʽ
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
__HIGH_CODE
|
||||
void LowPower_Idle(void)
|
||||
{
|
||||
FLASH_ROM_SW_RESET();
|
||||
R8_FLASH_CTRL = 0x04; //flash<73>ر<EFBFBD>
|
||||
|
||||
PFIC->SCTLR &= ~(1 << 2); // sleep
|
||||
__WFI();
|
||||
__nop();
|
||||
__nop();
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn LowPower_Halt
|
||||
*
|
||||
* @brief <20><EFBFBD><CDB9><EFBFBD>-Haltģʽ<C4A3><CABD><EFBFBD>˵<CBB5><CDB9><EFBFBD><EFBFBD>е<EFBFBD>HSI/5ʱ<35><CAB1><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD>Ѻ<EFBFBD><D1BA><EFBFBD>Ҫ<EFBFBD>û<EFBFBD><C3BB>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>ϵͳʱ<CDB3><CAB1>Դ
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
__HIGH_CODE
|
||||
void LowPower_Halt(void)
|
||||
{
|
||||
uint8_t x32Mpw;
|
||||
|
||||
FLASH_ROM_SW_RESET();
|
||||
R8_FLASH_CTRL = 0x04; //flash<73>ر<EFBFBD>
|
||||
x32Mpw = R8_XT32M_TUNE;
|
||||
if(!(R8_HFCK_PWR_CTRL&RB_CLK_XT32M_KEEP))
|
||||
{
|
||||
x32Mpw = (x32Mpw & 0xfc) | 0x03; // 150%<25><EFBFBD><EEB6A8><EFBFBD><EFBFBD>
|
||||
}
|
||||
|
||||
sys_safe_access_enable();
|
||||
R8_BAT_DET_CTRL = 0; // <20>رյ<D8B1>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD>
|
||||
sys_safe_access_disable();
|
||||
sys_safe_access_enable();
|
||||
R8_XT32M_TUNE = x32Mpw;
|
||||
sys_safe_access_disable();
|
||||
sys_safe_access_enable();
|
||||
R8_PLL_CONFIG |= (1 << 5);
|
||||
sys_safe_access_disable();
|
||||
|
||||
PFIC->SCTLR |= (1 << 2); //deep sleep
|
||||
__WFI();
|
||||
__nop();
|
||||
__nop();
|
||||
sys_safe_access_enable();
|
||||
R8_PLL_CONFIG &= ~(1 << 5);
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : LowPower_Sleep
|
||||
* Description : <20><EFBFBD><CDB9><EFBFBD>-Sleepģʽ<C4A3><CABD>
|
||||
* Input : rm:
|
||||
RB_PWR_RAM12K - 12K retention SRAM <20><><EFBFBD><EFBFBD>
|
||||
RB_PWR_EXTEND - USB <20><> BLE <20><>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
RB_PWR_XROM - FlashROM <20><><EFBFBD><EFBFBD>
|
||||
NULL - <09><><EFBFBD>ϵ<EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD>ϵ<EFBFBD>
|
||||
* Return : None
|
||||
*******************************************************************************/
|
||||
__HIGH_CODE
|
||||
void LowPower_Sleep(uint16_t rm)
|
||||
{
|
||||
uint8_t x32Mpw;
|
||||
uint16_t power_plan;
|
||||
uint8_t clk_sys_cfg;
|
||||
uint16_t hfck_pwr_ctrl;
|
||||
|
||||
clk_sys_cfg = R8_CLK_SYS_CFG;
|
||||
hfck_pwr_ctrl = R8_HFCK_PWR_CTRL;
|
||||
x32Mpw = R8_XT32M_TUNE;
|
||||
x32Mpw = (x32Mpw & 0xfc) | 0x03; // 150%<25><EFBFBD><EEB6A8><EFBFBD><EFBFBD>
|
||||
|
||||
sys_safe_access_enable();
|
||||
R8_BAT_DET_CTRL = 0; // <20>رյ<D8B1>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD>
|
||||
sys_safe_access_disable();
|
||||
sys_safe_access_enable();
|
||||
R8_XT32M_TUNE = x32Mpw;
|
||||
sys_safe_access_disable();
|
||||
|
||||
PFIC->SCTLR |= (1 << 2); //deep sleep
|
||||
|
||||
power_plan = RB_PWR_PLAN_EN | RB_PWR_CORE | rm | (2<<11);
|
||||
|
||||
sys_safe_access_enable();
|
||||
|
||||
// <20><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Ŀǰ<C4BF>õ<EFBFBD>3584
|
||||
R8_SLP_POWER_CTRL |= 0x40;
|
||||
|
||||
R16_POWER_PLAN = power_plan;
|
||||
sys_safe_access_disable();
|
||||
sys_safe_access_enable();
|
||||
R8_CLK_SYS_CFG = CLK_SOURCE_HSE_PLL_24MHz;
|
||||
sys_safe_access_disable();
|
||||
// if((R16_CLK_SYS_CFG & RB_CLK_SYS_MOD) == 0x40)
|
||||
// {
|
||||
// sys_safe_access_enable();
|
||||
// R16_CLK_SYS_CFG = (R16_CLK_SYS_CFG&(~RB_CLK_PLL_DIV))|24;
|
||||
// sys_safe_access_disable();
|
||||
// }
|
||||
// sys_safe_access_enable();
|
||||
// R8_PLL_CONFIG |= (1 << 5);
|
||||
// sys_safe_access_disable();
|
||||
|
||||
__WFI();
|
||||
__nop();
|
||||
__nop();
|
||||
|
||||
sys_safe_access_enable();
|
||||
R8_CLK_SYS_CFG = clk_sys_cfg;
|
||||
// R8_HFCK_PWR_CTRL = hfck_pwr_ctrl;
|
||||
sys_safe_access_disable();
|
||||
sys_safe_access_enable();
|
||||
R16_POWER_PLAN &= ~RB_PWR_PLAN_EN;
|
||||
R16_POWER_PLAN &= ~RB_XT_PRE_EN;
|
||||
sys_safe_access_disable();
|
||||
// sys_safe_access_enable();
|
||||
// R8_PLL_CONFIG &= ~(1 << 5);
|
||||
// sys_safe_access_disable();
|
||||
DelayUs(40);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn LowPower_Shutdown
|
||||
*
|
||||
* @brief <20><EFBFBD><CDB9><EFBFBD>-Shutdownģʽ<C4A3><CABD><EFBFBD>˵<CBB5><CDB9><EFBFBD><EFBFBD>е<EFBFBD>HSI/5ʱ<35><CAB1><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD>Ѻ<EFBFBD><D1BA><EFBFBD>Ҫ<EFBFBD>û<EFBFBD><C3BB>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>ϵͳʱ<CDB3><CAB1>Դ
|
||||
* @note ע<><D7A2><EFBFBD><EFBFBD><EFBFBD>ô˺<C3B4><CBBA><EFBFBD><EFBFBD><EFBFBD>DCDC<44><43><EFBFBD><EFBFBD>ǿ<EFBFBD>ƹرգ<D8B1><D5A3><EFBFBD><EFBFBD>Ѻ<EFBFBD><D1BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><D6B6>ٴδ<D9B4><CEB4><EFBFBD>
|
||||
*
|
||||
* @param rm - <20><><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>ѡ<EFBFBD><D1A1>
|
||||
* RB_PWR_RAM12K - 12K retention SRAM <20><><EFBFBD><EFBFBD>
|
||||
* RB_PWR_EXTEND - USB <20><> BLE <20><>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* NULL - <20><><EFBFBD>ϵ<EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD>ϵ<EFBFBD>
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
__HIGH_CODE
|
||||
void LowPower_Shutdown(uint16_t rm)
|
||||
{
|
||||
uint8_t x32Mpw;
|
||||
|
||||
FLASH_ROM_SW_RESET();
|
||||
x32Mpw = R8_XT32M_TUNE;
|
||||
x32Mpw = (x32Mpw & 0xfc) | 0x03; // 150%<25><EFBFBD><EEB6A8><EFBFBD><EFBFBD>
|
||||
|
||||
sys_safe_access_enable();
|
||||
R8_BAT_DET_CTRL = 0; // <20>رյ<D8B1>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD>
|
||||
sys_safe_access_disable();
|
||||
sys_safe_access_enable();
|
||||
R8_XT32M_TUNE = x32Mpw;
|
||||
sys_safe_access_disable();
|
||||
|
||||
PFIC->SCTLR |= (1 << 2); //deep sleep
|
||||
|
||||
SetSysClock(CLK_SOURCE_HSE_PLL_24MHz);
|
||||
sys_safe_access_enable();
|
||||
R8_SLP_POWER_CTRL |= 0x40;
|
||||
sys_safe_access_disable();
|
||||
sys_safe_access_enable();
|
||||
R16_POWER_PLAN = RB_PWR_PLAN_EN | rm;
|
||||
sys_safe_access_disable();
|
||||
__WFI();
|
||||
__nop();
|
||||
__nop();
|
||||
FLASH_ROM_SW_RESET();
|
||||
sys_safe_access_enable();
|
||||
R8_RST_WDOG_CTRL |= RB_SOFTWARE_RESET;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
454
BLV_RF_W13_V04_20260114/StdPeriphDriver/CH57x_spi.c
Normal file
454
BLV_RF_W13_V04_20260114/StdPeriphDriver/CH57x_spi.c
Normal file
@@ -0,0 +1,454 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH57x_SPI.c
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2021/11/17
|
||||
* Description : source file(ch572/ch570)
|
||||
*********************************************************************************
|
||||
* 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 "CH57x_common.h"
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SPI_MasterDefInit
|
||||
*
|
||||
* @brief <20><><EFBFBD><EFBFBD>ģʽĬ<CABD>ϳ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ģʽ0+3<><33>ȫ˫<C8AB><CBAB>+8MHz
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void SPI_MasterDefInit(void)
|
||||
{
|
||||
R8_SPI_CLOCK_DIV = 4; // <20><>Ƶʱ<C6B5><CAB1>4<EFBFBD><34>Ƶ
|
||||
R8_SPI_CTRL_MOD = RB_SPI_ALL_CLEAR;
|
||||
R8_SPI_CTRL_MOD = RB_SPI_MOSI_OE | RB_SPI_SCK_OE;
|
||||
R8_SPI_CTRL_CFG |= RB_SPI_AUTO_IF; // <20><><EFBFBD><EFBFBD>BUFFER/FIFO<46>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>IF_BYTE_END<4E><44>־
|
||||
R8_SPI_CTRL_CFG &= ~RB_SPI_DMA_ENABLE; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DMA<4D><41>ʽ
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SPI_2WIRE_MasterOutputInit
|
||||
*
|
||||
* @brief <20><><EFBFBD><EFBFBD>2<EFBFBD>߷<EFBFBD><DFB7><EFBFBD>ģʽ<C4A3><CABD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ģʽ1+2<>߰<EFBFBD>˫<EFBFBD><CBAB>+8MHz
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void SPI_2WIRE_MasterOutputInit(void)
|
||||
{
|
||||
R8_SPI_CLOCK_DIV = 4; // <20><>Ƶʱ<C6B5><CAB1>4<EFBFBD><34>Ƶ
|
||||
R8_SPI_CTRL_MOD = RB_SPI_ALL_CLEAR;
|
||||
R8_SPI_CTRL_MOD = RB_SPI_MOSI_OE | RB_SPI_SCK_OE | RB_SPI_2WIRE_MOD; // ʹ<><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
||||
R8_SPI_CTRL_CFG |= RB_SPI_AUTO_IF; // <20><><EFBFBD><EFBFBD>BUFFER/FIFO<46>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>IF_BYTE_END<4E><44>־
|
||||
R8_SPI_CTRL_CFG &= ~RB_SPI_DMA_ENABLE; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DMA<4D><41>ʽ
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SPI_2WIRE_MasterReceiveInit
|
||||
*
|
||||
* @brief <20><><EFBFBD><EFBFBD>2<EFBFBD>߽<EFBFBD><DFBD><EFBFBD>ģʽ<C4A3><CABD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ģʽ1+2<>߰<EFBFBD>˫<EFBFBD><CBAB>+8MHz
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void SPI_2WIRE_MasterReceiveInit(void)
|
||||
{
|
||||
R8_SPI_CLOCK_DIV = 4; // <20><>Ƶʱ<C6B5><CAB1>4<EFBFBD><34>Ƶ
|
||||
R8_SPI_CTRL_MOD = RB_SPI_ALL_CLEAR;
|
||||
R8_SPI_CTRL_MOD = RB_SPI_SCK_OE | RB_SPI_2WIRE_MOD; // ʹ<><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
||||
R8_SPI_CTRL_CFG |= RB_SPI_AUTO_IF; // <20><><EFBFBD><EFBFBD>BUFFER/FIFO<46>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>IF_BYTE_END<4E><44>־
|
||||
R8_SPI_CTRL_CFG &= ~RB_SPI_DMA_ENABLE; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DMA<4D><41>ʽ
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SPI_2WIRE_SlaveInputInit
|
||||
*
|
||||
* @brief <20>ӻ<EFBFBD>2<EFBFBD>߽<EFBFBD><DFBD><EFBFBD>ģʽ<C4A3><CABD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ģʽ1+2<>߰<EFBFBD>˫<EFBFBD><CBAB>+8MHz
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void SPI_2WIRE_SlaveInputInit(void)
|
||||
{
|
||||
R8_SPI_CTRL_MOD = RB_SPI_ALL_CLEAR;
|
||||
R8_SPI_CTRL_MOD = RB_SPI_2WIRE_MOD | RB_SPI_MODE_SLAVE;
|
||||
R8_SPI_CTRL_CFG |= RB_SPI_AUTO_IF | RB_MST_CLK_SEL;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SPI_2WIRE_SlaveOutputInit
|
||||
*
|
||||
* @brief <20>ӻ<EFBFBD>2<EFBFBD>߷<EFBFBD><DFB7><EFBFBD>ģʽ<C4A3><CABD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ģʽ1+2<>߰<EFBFBD>˫<EFBFBD><CBAB>+8MHz
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void SPI_2WIRE_SlaveOutputInit(void)
|
||||
{
|
||||
R8_SPI_CTRL_MOD = RB_SPI_ALL_CLEAR;
|
||||
R8_SPI_CTRL_MOD = RB_SPI_MISO_OE | RB_SPI_2WIRE_MOD | RB_SPI_MODE_SLAVE;
|
||||
R8_SPI_CTRL_CFG |= RB_SPI_AUTO_IF;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SPI_CLKCfg
|
||||
*
|
||||
* @brief SPI <20><>ʱ<D7BC><CAB1><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD>= d*Tsys
|
||||
*
|
||||
* @param c - ʱ<>ӷ<EFBFBD>Ƶϵ<C6B5><CFB5>
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void SPI_CLKCfg(uint8_t c)
|
||||
{
|
||||
if(c == 2)
|
||||
{
|
||||
R8_SPI_CTRL_CFG |= RB_SPI_MST_DLY_EN;
|
||||
}
|
||||
else
|
||||
{
|
||||
R8_SPI_CTRL_CFG &= ~RB_SPI_MST_DLY_EN;
|
||||
}
|
||||
R8_SPI_CLOCK_DIV = c;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SPI_DataMode
|
||||
*
|
||||
* @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
||||
*
|
||||
* @param m - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ refer to ModeBitOrderTypeDef
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void SPI_DataMode(ModeBitOrderTypeDef m)
|
||||
{
|
||||
switch(m)
|
||||
{
|
||||
case Mode0_LowBitINFront:
|
||||
R8_SPI_CTRL_MOD &= ~RB_SPI_MST_SCK_MOD;
|
||||
R8_SPI_CTRL_CFG |= RB_SPI_BIT_ORDER;
|
||||
break;
|
||||
case Mode0_HighBitINFront:
|
||||
R8_SPI_CTRL_MOD &= ~RB_SPI_MST_SCK_MOD;
|
||||
R8_SPI_CTRL_CFG &= ~RB_SPI_BIT_ORDER;
|
||||
break;
|
||||
case Mode3_LowBitINFront:
|
||||
R8_SPI_CTRL_MOD |= RB_SPI_MST_SCK_MOD;
|
||||
R8_SPI_CTRL_CFG |= RB_SPI_BIT_ORDER;
|
||||
break;
|
||||
case Mode3_HighBitINFront:
|
||||
R8_SPI_CTRL_MOD |= RB_SPI_MST_SCK_MOD;
|
||||
R8_SPI_CTRL_CFG &= ~RB_SPI_BIT_ORDER;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SPI_MasterSendByte
|
||||
*
|
||||
* @brief <20><><EFBFBD>͵<EFBFBD><CDB5>ֽ<EFBFBD> (buffer)
|
||||
*
|
||||
* @param d - <20><><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void SPI_MasterSendByte(uint8_t d)
|
||||
{
|
||||
R8_SPI_CTRL_MOD &= ~RB_SPI_FIFO_DIR;
|
||||
R16_SPI_TOTAL_CNT = 1;
|
||||
R8_SPI_FIFO = d;
|
||||
while(!(R8_SPI_INT_FLAG & RB_SPI_FREE));
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SPI_MasterRecvByte
|
||||
*
|
||||
* @brief <20><><EFBFBD>յ<EFBFBD><D5B5>ֽ<EFBFBD> (buffer)
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return <20><><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD>ֽ<EFBFBD>
|
||||
*/
|
||||
uint8_t SPI_MasterRecvByte(void)
|
||||
{
|
||||
R8_SPI_CTRL_MOD &= ~RB_SPI_FIFO_DIR;
|
||||
R8_SPI_BUFFER = 0xFF; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
while(!(R8_SPI_INT_FLAG & RB_SPI_FREE));
|
||||
return (R8_SPI_BUFFER);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SPI_MasterTrans
|
||||
*
|
||||
* @brief ʹ<><CAB9>FIFO<46><4F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͷ<EFBFBD><CDB6>ֽ<EFBFBD>
|
||||
*
|
||||
* @param pbuf - <20><><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
||||
* @param len - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3>ȣ<EFBFBD><C8A3><EFBFBD><EFBFBD><EFBFBD>4095
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void SPI_MasterTrans(uint8_t *pbuf, uint16_t len)
|
||||
{
|
||||
uint16_t sendlen;
|
||||
|
||||
sendlen = len;
|
||||
R8_SPI_CTRL_MOD &= ~RB_SPI_FIFO_DIR; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݷ<EFBFBD><DDB7><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>
|
||||
R16_SPI_TOTAL_CNT = sendlen; // <20><><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||
R8_SPI_INT_FLAG = RB_SPI_IF_CNT_END;
|
||||
while(sendlen)
|
||||
{
|
||||
if(R8_SPI_FIFO_COUNT < SPI_FIFO_SIZE)
|
||||
{
|
||||
R8_SPI_FIFO = *pbuf;
|
||||
pbuf++;
|
||||
sendlen--;
|
||||
}
|
||||
}
|
||||
while(R8_SPI_FIFO_COUNT != 0); // <20>ȴ<EFBFBD>FIFO<46>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SPI_MasterRecv
|
||||
*
|
||||
* @brief ʹ<><CAB9>FIFO<46><4F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ն<EFBFBD><D5B6>ֽ<EFBFBD>
|
||||
*
|
||||
* @param pbuf - <20><><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
||||
* @param len - <20><><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3>ȣ<EFBFBD><C8A3><EFBFBD><EFBFBD><EFBFBD>4095
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void SPI_MasterRecv(uint8_t *pbuf, uint16_t len)
|
||||
{
|
||||
uint16_t readlen;
|
||||
|
||||
readlen = len;
|
||||
R8_SPI_CTRL_MOD |= RB_SPI_FIFO_DIR; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݷ<EFBFBD><DDB7><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>
|
||||
R16_SPI_TOTAL_CNT = len; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3>ȣ<EFBFBD>FIFO<46><4F><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>볤<EFBFBD>Ȳ<EFBFBD>Ϊ0<CEAA><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
R8_SPI_INT_FLAG = RB_SPI_IF_CNT_END;
|
||||
while(readlen)
|
||||
{
|
||||
if(R8_SPI_FIFO_COUNT)
|
||||
{
|
||||
*pbuf = R8_SPI_FIFO;
|
||||
pbuf++;
|
||||
readlen--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SPI_MasterDMATrans
|
||||
*
|
||||
* @brief DMA<4D><41>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param pbuf - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ,<2C><>Ҫ<EFBFBD><D2AA><EFBFBD>ֽڶ<D6BD><DAB6><EFBFBD>
|
||||
* @param len - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void SPI_MasterDMATrans(uint8_t *pbuf, uint16_t len)
|
||||
{
|
||||
R8_SPI_CTRL_MOD &= ~RB_SPI_FIFO_DIR;
|
||||
R16_SPI_DMA_BEG = (uint32_t)pbuf;
|
||||
R16_SPI_DMA_END = (uint32_t)(pbuf + len);
|
||||
R16_SPI_TOTAL_CNT = len;
|
||||
R8_SPI_INT_FLAG = RB_SPI_IF_CNT_END | RB_SPI_IF_DMA_END;
|
||||
R8_SPI_CTRL_CFG |= RB_SPI_DMA_ENABLE;
|
||||
while(!(R8_SPI_INT_FLAG & RB_SPI_IF_CNT_END));
|
||||
R8_SPI_CTRL_CFG &= ~RB_SPI_DMA_ENABLE;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SPI_MasterDMARecv
|
||||
*
|
||||
* @brief DMA<4D><41>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param pbuf - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ,<2C><>Ҫ<EFBFBD><D2AA><EFBFBD>ֽڶ<D6BD><DAB6><EFBFBD>
|
||||
* @param len - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void SPI_MasterDMARecv(uint8_t *pbuf, uint16_t len)
|
||||
{
|
||||
R8_SPI_CTRL_MOD |= RB_SPI_FIFO_DIR;
|
||||
R16_SPI_DMA_BEG = (uint32_t)pbuf;
|
||||
R16_SPI_DMA_END = (uint32_t)(pbuf + len);
|
||||
R16_SPI_TOTAL_CNT = len;
|
||||
R8_SPI_INT_FLAG = RB_SPI_IF_CNT_END | RB_SPI_IF_DMA_END;
|
||||
R8_SPI_CTRL_CFG |= RB_SPI_DMA_ENABLE;
|
||||
while(!(R8_SPI_INT_FLAG & RB_SPI_IF_CNT_END));
|
||||
R8_SPI_CTRL_CFG &= ~RB_SPI_DMA_ENABLE;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SPI_SlaveInit
|
||||
*
|
||||
* @brief <20>豸ģʽĬ<CABD>ϳ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>MISO<53><4F>GPIO<49><4F>ӦΪ<D3A6><CEAA><EFBFBD><EFBFBD>ģʽ
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void SPI_SlaveInit(void)
|
||||
{
|
||||
R8_SPI_CTRL_MOD = RB_SPI_ALL_CLEAR;
|
||||
R8_SPI_CTRL_MOD = RB_SPI_MISO_OE | RB_SPI_MODE_SLAVE;
|
||||
R8_SPI_CTRL_CFG |= RB_SPI_AUTO_IF;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SPI_2WIRE_SlaveInit
|
||||
*
|
||||
* @brief <20>豸2<E8B1B8><32>ģʽ<C4A3><CABD>ʼ<EFBFBD><CABC>
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void SPI_2WIRE_SlaveInit(void)
|
||||
{
|
||||
R8_SPI_CTRL_MOD = RB_SPI_ALL_CLEAR;
|
||||
R8_SPI_CTRL_MOD = RB_SPI_MISO_OE | RB_SPI_2WIRE_MOD | RB_SPI_MODE_SLAVE;
|
||||
R8_SPI_CTRL_CFG |= RB_SPI_AUTO_IF;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SPI_SlaveRecvByte
|
||||
*
|
||||
* @brief <20>ӻ<EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @return <20><><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
uint8_t SPI_SlaveRecvByte(void)
|
||||
{
|
||||
R8_SPI_CTRL_MOD |= RB_SPI_FIFO_DIR;
|
||||
while(R8_SPI_FIFO_COUNT == 0);
|
||||
return R8_SPI_FIFO;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SPI_SlaveSendByte
|
||||
*
|
||||
* @brief <20>ӻ<EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param d - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void SPI_SlaveSendByte(uint8_t d)
|
||||
{
|
||||
R8_SPI_CTRL_MOD &= ~RB_SPI_FIFO_DIR;
|
||||
R16_SPI_TOTAL_CNT = 1;
|
||||
R8_SPI_FIFO = d;
|
||||
while(R8_SPI_FIFO_COUNT != 0); // <20>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SPI_SlaveRecv
|
||||
*
|
||||
* @brief <20>ӻ<EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD><EFBFBD>ն<EFBFBD><D5B6>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param pbuf - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ
|
||||
* @param len - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
__HIGH_CODE
|
||||
void SPI_SlaveRecv(uint8_t *pbuf, uint16_t len)
|
||||
{
|
||||
uint16_t revlen;
|
||||
|
||||
revlen = len;
|
||||
R8_SPI_CTRL_MOD |= RB_SPI_FIFO_DIR;
|
||||
R8_SPI_INT_FLAG = RB_SPI_IF_CNT_END;
|
||||
while(revlen)
|
||||
{
|
||||
if(R8_SPI_FIFO_COUNT)
|
||||
{
|
||||
*pbuf = R8_SPI_FIFO;
|
||||
pbuf++;
|
||||
revlen--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SPI_SlaveTrans
|
||||
*
|
||||
* @brief <20>ӻ<EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD><EFBFBD>Ͷ<EFBFBD><CDB6>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param pbuf - <20><><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
||||
* @param len - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3>ȣ<EFBFBD><C8A3><EFBFBD><EFBFBD><EFBFBD>4095
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
__HIGH_CODE
|
||||
void SPI_SlaveTrans(uint8_t *pbuf, uint16_t len)
|
||||
{
|
||||
uint16_t sendlen;
|
||||
|
||||
sendlen = len;
|
||||
R8_SPI_CTRL_MOD &= ~RB_SPI_FIFO_DIR; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݷ<EFBFBD><DDB7><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>
|
||||
R8_SPI_INT_FLAG = RB_SPI_IF_CNT_END;
|
||||
while(sendlen)
|
||||
{
|
||||
if(R8_SPI_FIFO_COUNT < SPI_FIFO_SIZE)
|
||||
{
|
||||
R8_SPI_FIFO = *pbuf;
|
||||
pbuf++;
|
||||
sendlen--;
|
||||
}
|
||||
}
|
||||
while(R8_SPI_FIFO_COUNT != 0); // <20>ȴ<EFBFBD>FIFO<46>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SPI_SlaveDMARecv
|
||||
*
|
||||
* @brief DMA<4D><41>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param pbuf - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ,<2C><>Ҫ<EFBFBD><D2AA><EFBFBD>ֽڶ<D6BD><DAB6><EFBFBD>
|
||||
* @param len - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void SPI_SlaveDMARecv(uint8_t *pbuf, uint16_t len)
|
||||
{
|
||||
R8_SPI_CTRL_MOD |= RB_SPI_FIFO_DIR;
|
||||
R16_SPI_DMA_BEG = (uint32_t)pbuf;
|
||||
R16_SPI_DMA_END = (uint32_t)(pbuf + len);
|
||||
R16_SPI_TOTAL_CNT = len;
|
||||
R8_SPI_INT_FLAG = RB_SPI_IF_CNT_END | RB_SPI_IF_DMA_END;
|
||||
R8_SPI_CTRL_CFG |= RB_SPI_DMA_ENABLE;
|
||||
while(!(R8_SPI_INT_FLAG & RB_SPI_IF_CNT_END));
|
||||
R8_SPI_CTRL_CFG &= ~RB_SPI_DMA_ENABLE;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SPI_SlaveDMATrans
|
||||
*
|
||||
* @brief DMA<4D><41>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param pbuf - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ,<2C><>Ҫ<EFBFBD><D2AA><EFBFBD>ֽڶ<D6BD><DAB6><EFBFBD>
|
||||
* @param len - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void SPI_SlaveDMATrans(uint8_t *pbuf, uint16_t len)
|
||||
{
|
||||
R8_SPI_CTRL_MOD &= ~RB_SPI_FIFO_DIR;
|
||||
R16_SPI_DMA_BEG = (uint32_t)pbuf;
|
||||
R16_SPI_DMA_END = (uint32_t)(pbuf + len);
|
||||
R16_SPI_TOTAL_CNT = len;
|
||||
R8_SPI_INT_FLAG = RB_SPI_IF_CNT_END | RB_SPI_IF_DMA_END;
|
||||
R8_SPI_CTRL_CFG |= RB_SPI_DMA_ENABLE;
|
||||
while(!(R8_SPI_INT_FLAG & RB_SPI_IF_CNT_END));
|
||||
R8_SPI_CTRL_CFG &= ~RB_SPI_DMA_ENABLE;
|
||||
}
|
||||
421
BLV_RF_W13_V04_20260114/StdPeriphDriver/CH57x_sys.c
Normal file
421
BLV_RF_W13_V04_20260114/StdPeriphDriver/CH57x_sys.c
Normal file
@@ -0,0 +1,421 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH57x_SYS.c
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2021/11/17
|
||||
* Description : source file(ch572/ch570)
|
||||
*********************************************************************************
|
||||
* 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 "CH57x_common.h"
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SetSysClock
|
||||
*
|
||||
* @brief <20><><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
*
|
||||
* @param sc - ϵͳʱ<CDB3><CAB1>Դѡ<D4B4><D1A1> refer to SYS_CLKTypeDef
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
__HIGH_CODE
|
||||
void SetSysClock(SYS_CLKTypeDef sc)
|
||||
{
|
||||
uint16_t clk_sys_cfg;
|
||||
uint8_t i;
|
||||
uint8_t x32M_c;
|
||||
|
||||
if(sc == RB_CLK_SYS_MOD) // LSI
|
||||
{
|
||||
sys_safe_access_enable();
|
||||
R8_CLK_SYS_CFG |= RB_CLK_SYS_MOD;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!(R8_HFCK_PWR_CTRL & RB_CLK_XT32M_PON))
|
||||
{
|
||||
x32M_c = R8_XT32M_TUNE;
|
||||
sys_safe_access_enable();
|
||||
R8_XT32M_TUNE |= 0x03;
|
||||
R8_HFCK_PWR_CTRL |= RB_CLK_XT32M_PON;
|
||||
sys_safe_access_disable();
|
||||
clk_sys_cfg = R8_CLK_SYS_CFG;
|
||||
sys_safe_access_enable();
|
||||
R8_CLK_SYS_CFG |= 0xC0;
|
||||
sys_safe_access_disable();
|
||||
for(i=0; i<9; i++)
|
||||
{
|
||||
__nop();
|
||||
}
|
||||
sys_safe_access_enable();
|
||||
R8_CLK_SYS_CFG = clk_sys_cfg;
|
||||
R8_XT32M_TUNE = x32M_c;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
|
||||
if((sc & RB_CLK_SYS_MOD) == 0x40) // PLL div
|
||||
{
|
||||
sys_safe_access_enable();
|
||||
R8_HFCK_PWR_CTRL |= RB_CLK_PLL_PON;
|
||||
R8_FLASH_CFG = 0X01;
|
||||
R8_FLASH_SCK |= 1<<4; //50M
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
else // 32M div
|
||||
{
|
||||
if((sc&0x1F) )
|
||||
{
|
||||
sys_safe_access_enable();
|
||||
R8_FLASH_CFG = 0X02;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
else
|
||||
{
|
||||
sys_safe_access_enable();
|
||||
R8_FLASH_CFG = 0X07;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
}
|
||||
|
||||
sys_safe_access_enable();
|
||||
R8_CLK_SYS_CFG = sc;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn GetSysClock
|
||||
*
|
||||
* @brief <20><>ȡ<EFBFBD><C8A1>ǰϵͳʱ<CDB3><CAB1>
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return Hz
|
||||
*/
|
||||
uint32_t GetSysClock(void)
|
||||
{
|
||||
if((R8_CLK_SYS_CFG & RB_CLK_SYS_MOD) == RB_CLK_SYS_MOD)
|
||||
{ // 32K<32><4B><EFBFBD><EFBFBD>Ƶ
|
||||
return (Freq_LSI);
|
||||
}
|
||||
else if((R8_CLK_SYS_CFG & RB_CLK_SYS_MOD) == 0x40)
|
||||
{
|
||||
return (600000000 / ((R8_CLK_SYS_CFG & 0x1f)?(R8_CLK_SYS_CFG & 0x1f):32));
|
||||
}
|
||||
else
|
||||
{ // 32M<32><4D><EFBFBD>з<EFBFBD>Ƶ
|
||||
return (32000000 / ((R8_CLK_SYS_CFG & 0x1f)?(R8_CLK_SYS_CFG & 0x1f):32));
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SYS_GetInfoSta
|
||||
*
|
||||
* @brief <20><>ȡ<EFBFBD><C8A1>ǰϵͳ<CFB5><CDB3>Ϣ״̬
|
||||
*
|
||||
* @param i - refer to SYS_InfoStaTypeDef
|
||||
*
|
||||
* @return <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
uint8_t SYS_GetInfoSta(SYS_InfoStaTypeDef i)
|
||||
{
|
||||
if(i == STA_SAFEACC_ACT)
|
||||
{
|
||||
return (R8_SAFE_ACCESS_SIG & RB_SAFE_ACC_ACT);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (R8_GLOB_CFG_INFO & (1 << i));
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SYS_ResetExecute
|
||||
*
|
||||
* @brief ִ<><D6B4>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
__HIGH_CODE
|
||||
void SYS_ResetExecute(void)
|
||||
{
|
||||
FLASH_ROM_SW_RESET();
|
||||
sys_safe_access_enable();
|
||||
R8_RST_WDOG_CTRL |= RB_SOFTWARE_RESET;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SYS_DisableAllIrq
|
||||
*
|
||||
* @brief <20>ر<EFBFBD><D8B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>жϣ<D0B6><CFA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD>ж<EFBFBD>ֵ
|
||||
*
|
||||
* @param pirqv - <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>ֵ
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void SYS_DisableAllIrq(uint32_t *pirqv)
|
||||
{
|
||||
*pirqv = (PFIC->ISR[0] >> 8) | (PFIC->ISR[1] << 24);
|
||||
PFIC->IRER[0] = 0xffffffff;
|
||||
PFIC->IRER[1] = 0xffffffff;
|
||||
asm volatile("fence.i");
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SYS_RecoverIrq
|
||||
*
|
||||
* @brief <20>ָ<EFBFBD>֮ǰ<D6AE>رյ<D8B1><D5B5>ж<EFBFBD>ֵ
|
||||
*
|
||||
* @param irq_status - <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>ֵ
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void SYS_RecoverIrq(uint32_t irq_status)
|
||||
{
|
||||
PFIC->IENR[0] = (irq_status << 8);
|
||||
PFIC->IENR[1] = (irq_status >> 24);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SYS_GetSysTickCnt
|
||||
*
|
||||
* @brief <20><>ȡ<EFBFBD><C8A1>ǰϵͳ(SYSTICK)<29><><EFBFBD><EFBFBD>ֵ
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ֵ
|
||||
*/
|
||||
uint32_t SYS_GetSysTickCnt(void)
|
||||
{
|
||||
return SysTick->CNTL;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn WWDG_ITCfg
|
||||
*
|
||||
* @brief <20><><EFBFBD>Ź<EFBFBD><C5B9><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>ʹ<EFBFBD><CAB9>
|
||||
*
|
||||
* @param s - <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ж<EFBFBD>
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void WWDG_ITCfg(FunctionalState s)
|
||||
{
|
||||
uint8_t ctrl = R8_RST_WDOG_CTRL;
|
||||
|
||||
if(s == DISABLE)
|
||||
{
|
||||
ctrl &= ~RB_WDOG_INT_EN;
|
||||
}
|
||||
else
|
||||
{
|
||||
ctrl |= RB_WDOG_INT_EN;
|
||||
}
|
||||
|
||||
sys_safe_access_enable();
|
||||
R8_RST_WDOG_CTRL = ctrl;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn WWDG_ResetCfg
|
||||
*
|
||||
* @brief <20><><EFBFBD>Ź<EFBFBD><C5B9><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param s - <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>λ
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void WWDG_ResetCfg(FunctionalState s)
|
||||
{
|
||||
uint8_t ctrl = R8_RST_WDOG_CTRL;
|
||||
|
||||
if(s == DISABLE)
|
||||
{
|
||||
ctrl &= ~RB_WDOG_RST_EN;
|
||||
}
|
||||
else
|
||||
{
|
||||
ctrl |= RB_WDOG_RST_EN;
|
||||
}
|
||||
|
||||
sys_safe_access_enable();
|
||||
R8_RST_WDOG_CTRL = ctrl;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn WWDG_ClearFlag
|
||||
*
|
||||
* @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ź<EFBFBD><C5B9>жϱ<D0B6>־<EFBFBD><D6BE><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>ؼ<EFBFBD><D8BC><EFBFBD>ֵҲ<D6B5><D2B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void WWDG_ClearFlag(void)
|
||||
{
|
||||
sys_safe_access_enable();
|
||||
R8_RST_WDOG_CTRL |= RB_WDOG_INT_FLAG;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn HardFault_Handler
|
||||
*
|
||||
* @brief Ӳ<><D3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>жϣ<D0B6><CFA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD>и<EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϊ<EFBFBD>ϵ縴λ
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
__INTERRUPT
|
||||
__HIGH_CODE
|
||||
__attribute__((weak))
|
||||
void HardFault_Handler(void)
|
||||
{
|
||||
FLASH_ROM_SW_RESET();
|
||||
sys_safe_access_enable();
|
||||
R16_INT_LSI_TUNE = 0xFFFF;
|
||||
sys_safe_access_disable();
|
||||
sys_safe_access_enable();
|
||||
R8_RST_WDOG_CTRL |= RB_SOFTWARE_RESET;
|
||||
sys_safe_access_disable();
|
||||
while(1);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn mDelayuS
|
||||
*
|
||||
* @brief uS <20><>ʱ
|
||||
*
|
||||
* @param t - ʱ<><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
__HIGH_CODE
|
||||
void mDelayuS(uint16_t t)
|
||||
{
|
||||
uint32_t i;
|
||||
#if(FREQ_SYS == 100000000)
|
||||
i = t * 25;
|
||||
#elif(FREQ_SYS == 75000000)
|
||||
i = (t * 25)>>1;
|
||||
#elif(FREQ_SYS == 60000000)
|
||||
i = t * 10;
|
||||
#elif(FREQ_SYS == 50000000)
|
||||
i = (t * 25)>>1;
|
||||
#elif(FREQ_SYS == 40000000)
|
||||
i = t * 10;
|
||||
#elif(FREQ_SYS == 30000000)
|
||||
i = t * 5;
|
||||
#elif(FREQ_SYS == 25000000)
|
||||
i = (t * 25)>>2;
|
||||
#elif(FREQ_SYS == 24000000)
|
||||
i = t * 6;
|
||||
#elif(FREQ_SYS == 20000000)
|
||||
i = t * 5;
|
||||
#elif(FREQ_SYS == 16000000)
|
||||
i = t << 2;
|
||||
#elif(FREQ_SYS == 8000000)
|
||||
i = t << 1;
|
||||
#elif(FREQ_SYS == 6400000)
|
||||
i = t * 8 / 5;
|
||||
#elif(FREQ_SYS == 4000000)
|
||||
i = t;
|
||||
#elif(FREQ_SYS == 2000000)
|
||||
i = t >> 1;
|
||||
#elif(FREQ_SYS == 1000000)
|
||||
i = t >> 2;
|
||||
#else
|
||||
i = t;
|
||||
#endif
|
||||
|
||||
#if((FREQ_SYS == 75000000)||\
|
||||
(FREQ_SYS == 60000000)||\
|
||||
(FREQ_SYS == 30000000))
|
||||
while(--i)
|
||||
{
|
||||
__nop();
|
||||
};
|
||||
#else
|
||||
do
|
||||
{
|
||||
__nop();
|
||||
}while(--i);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn mDelaymS
|
||||
*
|
||||
* @brief mS <20><>ʱ
|
||||
*
|
||||
* @param t - ʱ<><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
__HIGH_CODE
|
||||
void mDelaymS(uint16_t t)
|
||||
{
|
||||
do
|
||||
{
|
||||
mDelayuS(1000);
|
||||
}while(--t);
|
||||
}
|
||||
|
||||
//YYW,20250918
|
||||
//#ifdef DEBUG
|
||||
//int _write(int fd, char *buf, int size)
|
||||
//{
|
||||
// int i;
|
||||
// for(i = 0; i < size; i++)
|
||||
// {
|
||||
// while(R8_UART_TFC == UART_FIFO_SIZE); /* <20>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD>ݷ<EFBFBD><DDB7><EFBFBD> */
|
||||
// R8_UART_THR = *buf++; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
// }
|
||||
// return size;
|
||||
//}
|
||||
//
|
||||
//#endif
|
||||
|
||||
/*********************************************************************
|
||||
* @fn _sbrk
|
||||
*
|
||||
* @brief Change the spatial position of data segment.
|
||||
*
|
||||
* @return size: Data length
|
||||
*/
|
||||
__attribute__((used))
|
||||
void *_sbrk(ptrdiff_t incr)
|
||||
{
|
||||
extern char _end[];
|
||||
static char *curbrk = _end;
|
||||
|
||||
if ((curbrk + incr < _end) || ((uint32_t)curbrk + incr > (__get_SP() - 64)))
|
||||
return NULL - 1;
|
||||
|
||||
curbrk += incr;
|
||||
return curbrk - incr;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn __wrap_memcpy
|
||||
*
|
||||
* @brief wrap memcpy
|
||||
*
|
||||
* @return dst
|
||||
*/
|
||||
__HIGH_CODE
|
||||
void *__wrap_memcpy(void *dst, void *src, size_t size)
|
||||
{
|
||||
__MCPY(dst, src, (void *)((uint32_t)src+size));
|
||||
return dst;
|
||||
}
|
||||
132
BLV_RF_W13_V04_20260114/StdPeriphDriver/CH57x_timer.c
Normal file
132
BLV_RF_W13_V04_20260114/StdPeriphDriver/CH57x_timer.c
Normal file
@@ -0,0 +1,132 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH57x_timer0.c
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2021/11/17
|
||||
* Description : source file(ch572/ch570)
|
||||
*********************************************************************************
|
||||
* 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 "CH57x_common.h"
|
||||
|
||||
/*********************************************************************
|
||||
* @fn TMR_TimerInit
|
||||
*
|
||||
* @brief <20><>ʱ<EFBFBD><CAB1><EFBFBD>ܳ<EFBFBD>ʼ<EFBFBD><CABC>
|
||||
*
|
||||
* @param t - <20><>ʱʱ<CAB1>䣬<EFBFBD><E4A3AC><EFBFBD>ڵ<EFBFBD>ǰϵͳʱ<CDB3><CAB1>Tsys, <20><EFBFBD><EEB3A4>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD> 67108864
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void TMR_TimerInit(uint32_t t)
|
||||
{
|
||||
R32_TMR_CNT_END = t;
|
||||
R8_TMR_CTRL_MOD = RB_TMR_ALL_CLEAR;
|
||||
R8_TMR_CTRL_MOD = RB_TMR_COUNT_EN;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn TMR_EXTSingleCounterInit
|
||||
*
|
||||
* @brief <20><><EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD>ʼ<EFBFBD><CABC>
|
||||
*
|
||||
* @param cap - <20>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void TMR_EXTSingleCounterInit(CapModeTypeDef cap)
|
||||
{
|
||||
R8_TMR_CTRL_MOD = RB_TMR_ALL_CLEAR;
|
||||
R8_TMR_CTRL_MOD = RB_TMR_COUNT_EN | RB_TMR_CAP_COUNT | RB_TMR_MODE_IN | (cap << 6);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn TMR_PWMInit
|
||||
*
|
||||
* @brief PWM <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
|
||||
*
|
||||
* @param pr - select wave polar, refer to PWMX_PolarTypeDef
|
||||
* @param ts - set pwm repeat times, refer to PWM_RepeatTsTypeDef
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void TMR_PWMInit(PWMX_PolarTypeDef pr, PWM_RepeatTsTypeDef ts)
|
||||
{
|
||||
R8_TMR_CTRL_MOD = RB_TMR_ALL_CLEAR;
|
||||
R8_TMR_CTRL_MOD = (pr << 4) | (ts << 6);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn TMR_CapInit
|
||||
*
|
||||
* @brief <20>ⲿ<EFBFBD>źŲ<C5BA><EFBFBD><D7BD><EFBFBD>ܳ<EFBFBD>ʼ<EFBFBD><CABC>
|
||||
*
|
||||
* @param cap - select capture mode, refer to CapModeTypeDef
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void TMR_CapInit(CapModeTypeDef cap)
|
||||
{
|
||||
R8_TMR_CTRL_MOD = RB_TMR_ALL_CLEAR;
|
||||
R8_TMR_CTRL_MOD = RB_TMR_COUNT_EN | RB_TMR_MODE_IN | (cap << 6);
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
* @fn TMR_DMACfg
|
||||
*
|
||||
* @brief <20><><EFBFBD><EFBFBD>DMA<4D><41><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param s - <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>DMA<4D><41><EFBFBD><EFBFBD>
|
||||
* @param startAddr - DMA <20><>ʼ<EFBFBD><CABC>ַ
|
||||
* @param endAddr - DMA <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
||||
* @param m - <20><><EFBFBD><EFBFBD>DMAģʽ
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void TMR_DMACfg(uint8_t s, uint32_t startAddr, uint32_t endAddr, DMAModeTypeDef m)
|
||||
{
|
||||
if(s == DISABLE)
|
||||
{
|
||||
R8_TMR_CTRL_DMA = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
R16_TMR_DMA_BEG = startAddr & 0xFFFF;
|
||||
R16_TMR_DMA_END = endAddr & 0xFFFF;
|
||||
if(m)
|
||||
R8_TMR_CTRL_DMA = RB_TMR_DMA_LOOP | RB_TMR_DMA_ENABLE;
|
||||
else
|
||||
R8_TMR_CTRL_DMA = RB_TMR_DMA_ENABLE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
* @fn ENC_Config
|
||||
*
|
||||
* @brief <20><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param s - <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @param encReg - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<C4A3><CABD>ֵ(<28><><EFBFBD><EFBFBD>ֵ0xFFFF)
|
||||
* @param m - <20><><EFBFBD><EFBFBD>ENCģʽ
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void ENC_Config(uint8_t s, uint32_t encReg, ENCModeTypeDef m)
|
||||
{
|
||||
if(s == DISABLE)
|
||||
{
|
||||
R8_ENC_REG_CTRL &= ~(RB_START_ENC_EN);
|
||||
}
|
||||
else
|
||||
{
|
||||
R8_ENC_REG_CTRL |= (m << 1) | RB_START_ENC_EN;
|
||||
R32_ENC_REG_CEND |= encReg;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
160
BLV_RF_W13_V04_20260114/StdPeriphDriver/CH57x_uart.c
Normal file
160
BLV_RF_W13_V04_20260114/StdPeriphDriver/CH57x_uart.c
Normal file
@@ -0,0 +1,160 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH57x_UART.c
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2021/11/17
|
||||
* Description : source file(ch572/ch570)
|
||||
*********************************************************************************
|
||||
* 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 "CH57x_common.h"
|
||||
|
||||
/*********************************************************************
|
||||
* @fn UART_DefInit
|
||||
*
|
||||
* @brief <20><><EFBFBD><EFBFBD>Ĭ<EFBFBD>ϳ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void UART_DefInit(void)
|
||||
{
|
||||
UART_BaudRateCfg(115200);
|
||||
R8_UART_FCR = (2 << 6) | RB_FCR_FIFO_EN; // FIFO<46><EFBFBD><F2BFAAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>4<EFBFBD>ֽ<EFBFBD>
|
||||
R8_UART_LCR = RB_LCR_WORD_SZ;
|
||||
R8_UART_IER = RB_IER_TXD_EN;
|
||||
R8_UART_DIV = 1;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn UART_BaudRateCfg
|
||||
*
|
||||
* @brief <20><><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param baudrate - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void UART_BaudRateCfg(uint32_t baudrate)
|
||||
{
|
||||
uint32_t x;
|
||||
|
||||
x = 10 * GetSysClock() / 8 / baudrate;
|
||||
x = (x + 5) / 10;
|
||||
R16_UART_DL = (uint16_t)x;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn UART_ByteTrigCfg
|
||||
*
|
||||
* @brief <20><><EFBFBD><EFBFBD><EFBFBD>ֽڴ<D6BD><DAB4><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param b - <20><><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD> refer to UARTByteTRIGTypeDef
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void UART_ByteTrigCfg(UARTByteTRIGTypeDef b)
|
||||
{
|
||||
R8_UART_FCR = (R8_UART_FCR & ~RB_FCR_FIFO_TRIG) | (b << 6);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn UART_INTCfg
|
||||
*
|
||||
* @brief <20><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param s - <20>жϿ<D0B6><CFBF><EFBFBD>״̬<D7B4><CCAC><EFBFBD>Ƿ<EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD>Ӧ<EFBFBD>ж<EFBFBD>
|
||||
* @param i - <20>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>
|
||||
* RB_IER_MODEM_CHG - <20><><EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4>仯<EFBFBD>ж<EFBFBD>ʹ<EFBFBD><CAB9>λ<EFBFBD><CEBB><EFBFBD><EFBFBD> UART ֧<>֣<EFBFBD>
|
||||
* RB_IER_LINE_STAT - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·״̬<D7B4>ж<EFBFBD>
|
||||
* RB_IER_THR_EMPTY - <20><><EFBFBD>ͱ<EFBFBD><CDB1>ּĴ<D6BC><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
||||
* RB_IER_RECV_RDY - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void UART_INTCfg(FunctionalState s, uint8_t i)
|
||||
{
|
||||
if(s)
|
||||
{
|
||||
R8_UART_IER |= i;
|
||||
R8_UART_MCR |= RB_MCR_INT_OE;
|
||||
}
|
||||
else
|
||||
{
|
||||
R8_UART_IER &= ~i;
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn UART_SendString
|
||||
*
|
||||
* @brief <20><><EFBFBD>ڶ<EFBFBD><DAB6>ֽڷ<D6BD><DAB7><EFBFBD>
|
||||
*
|
||||
* @param buf - <20><><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
||||
* @param l - <20><><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void UART_SendString(uint8_t *buf, uint16_t l)
|
||||
{
|
||||
uint16_t len = l;
|
||||
|
||||
while(len)
|
||||
{
|
||||
if(R8_UART_TFC != UART_FIFO_SIZE)
|
||||
{
|
||||
R8_UART_THR = *buf++;
|
||||
len--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn UART_RecvString
|
||||
*
|
||||
* @brief <20><><EFBFBD>ڶ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>ֽ<EFBFBD>
|
||||
*
|
||||
* @param buf - <20><>ȡ<EFBFBD><C8A1><EFBFBD>ݴ<EFBFBD><DDB4>Ż<EFBFBD><C5BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
||||
*
|
||||
* @return <20><>ȡ<EFBFBD><C8A1><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||
*/
|
||||
uint16_t UART_RecvString(uint8_t *buf)
|
||||
{
|
||||
uint16_t len = 0;
|
||||
|
||||
while(R8_UART_RFC)
|
||||
{
|
||||
*buf++ = R8_UART_RBR;
|
||||
len++;
|
||||
}
|
||||
|
||||
return (len);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn UART_Remap
|
||||
*
|
||||
* @brief <20><><EFBFBD><EFBFBD>ӳ<EFBFBD><D3B3>
|
||||
*
|
||||
* @param s - <20>Ƿ<EFBFBD>ʹ<EFBFBD><CAB9>ӳ<EFBFBD><D3B3>
|
||||
* @param perph - дTx<54><78>Rx<52><78>ӳ<EFBFBD><D3B3><EFBFBD><EFBFBD>ϵ
|
||||
*
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void UART_Remap(FunctionalState s, UARTTxPinRemapDef u_tx, UARTRxPinRemapDef u_rx)
|
||||
{
|
||||
if(s)
|
||||
{
|
||||
R16_PIN_ALTERNATE_H &= ~(RB_UART_TXD | RB_UART_RXD); // <20>üĴ<C3BC><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ縴λ<E7B8B4><CEBB>ShutDown˯<6E><CBAF>ʱ<EFBFBD><CAB1>0
|
||||
R16_PIN_ALTERNATE_H |= (u_tx << 3) | u_rx;
|
||||
}
|
||||
else
|
||||
{
|
||||
R16_PIN_ALTERNATE_H &= ~(RB_UART_TXD | RB_UART_RXD);
|
||||
}
|
||||
}
|
||||
113
BLV_RF_W13_V04_20260114/StdPeriphDriver/CH57x_usbdev.c
Normal file
113
BLV_RF_W13_V04_20260114/StdPeriphDriver/CH57x_usbdev.c
Normal file
@@ -0,0 +1,113 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH57x_usbdev.c
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2021/11/17
|
||||
* Description : source file(ch572/ch570)
|
||||
*********************************************************************************
|
||||
* 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 "CH57x_common.h"
|
||||
|
||||
uint8_t *pEP0_RAM_Addr;
|
||||
uint8_t *pEP1_RAM_Addr;
|
||||
uint8_t *pEP2_RAM_Addr;
|
||||
uint8_t *pEP3_RAM_Addr;
|
||||
|
||||
/*********************************************************************
|
||||
* @fn USB_DeviceInit
|
||||
*
|
||||
* @brief USB<53>豸<EFBFBD><E8B1B8><EFBFBD>ܳ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>4<EFBFBD><34><EFBFBD>˵㣬8<E3A3AC><38>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void USB_DeviceInit(void)
|
||||
{
|
||||
R8_USB_CTRL = 0x00; // <20><><EFBFBD>趨ģʽ,ȡ<><C8A1> RB_UC_CLR_ALL
|
||||
|
||||
R8_UEP4_1_MOD = RB_UEP4_RX_EN | RB_UEP4_TX_EN | RB_UEP1_RX_EN | RB_UEP1_TX_EN; // <20>˵<EFBFBD>4 OUT+IN,<2C>˵<EFBFBD>1 OUT+IN
|
||||
R8_UEP2_3_MOD = RB_UEP2_RX_EN | RB_UEP2_TX_EN | RB_UEP3_RX_EN | RB_UEP3_TX_EN; // <20>˵<EFBFBD>2 OUT+IN,<2C>˵<EFBFBD>3 OUT+IN
|
||||
|
||||
R16_UEP0_DMA = (uint16_t)(uint32_t)pEP0_RAM_Addr;
|
||||
R16_UEP1_DMA = (uint16_t)(uint32_t)pEP1_RAM_Addr;
|
||||
R16_UEP2_DMA = (uint16_t)(uint32_t)pEP2_RAM_Addr;
|
||||
R16_UEP3_DMA = (uint16_t)(uint32_t)pEP3_RAM_Addr;
|
||||
|
||||
R8_UEP0_CTRL = UEP_R_RES_ACK | UEP_T_RES_NAK;
|
||||
R8_UEP1_CTRL = UEP_R_RES_ACK | UEP_T_RES_NAK | RB_UEP_AUTO_TOG;
|
||||
R8_UEP2_CTRL = UEP_R_RES_ACK | UEP_T_RES_NAK | RB_UEP_AUTO_TOG;
|
||||
R8_UEP3_CTRL = UEP_R_RES_ACK | UEP_T_RES_NAK | RB_UEP_AUTO_TOG;
|
||||
R8_UEP4_CTRL = UEP_R_RES_ACK | UEP_T_RES_NAK;
|
||||
|
||||
R8_USB_DEV_AD = 0x00;
|
||||
R8_USB_CTRL = RB_UC_DEV_PU_EN | RB_UC_INT_BUSY | RB_UC_DMA_EN; // <20><><EFBFBD><EFBFBD>USB<53>豸<EFBFBD><E8B1B8>DMA<4D><41><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6>ڼ<EFBFBD><DABC>жϱ<D0B6>־δ<D6BE><CEB4><EFBFBD><EFBFBD>ǰ<EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>NAK
|
||||
R16_PIN_ALTERNATE |= RB_PIN_USB_EN | RB_UDP_PU_EN; // <20><>ֹUSB<53>˿ڸ<CBBF><DAB8>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
R8_USB_INT_FG = 0xFF; // <20><><EFBFBD>жϱ<D0B6>־
|
||||
R8_UDEV_CTRL = RB_UD_PD_DIS | RB_UD_PORT_EN; // <20><><EFBFBD><EFBFBD>USB<53>˿<EFBFBD>
|
||||
R8_USB_INT_EN = RB_UIE_SUSPEND | RB_UIE_BUS_RST | RB_UIE_TRANSFER;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn DevEP1_IN_Deal
|
||||
*
|
||||
* @brief <20>˵<EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>
|
||||
*
|
||||
* @param l - <20>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>(<64B)
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void DevEP1_IN_Deal(uint8_t l)
|
||||
{
|
||||
R8_UEP1_T_LEN = l;
|
||||
R8_UEP1_CTRL = (R8_UEP1_CTRL & ~MASK_UEP_T_RES) | UEP_T_RES_ACK;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn DevEP2_IN_Deal
|
||||
*
|
||||
* @brief <20>˵<EFBFBD>2<EFBFBD><32><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>
|
||||
*
|
||||
* @param l - <20>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>(<64B)
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void DevEP2_IN_Deal(uint8_t l)
|
||||
{
|
||||
R8_UEP2_T_LEN = l;
|
||||
R8_UEP2_CTRL = (R8_UEP2_CTRL & ~MASK_UEP_T_RES) | UEP_T_RES_ACK;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn DevEP3_IN_Deal
|
||||
*
|
||||
* @brief <20>˵<EFBFBD>3<EFBFBD><33><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>
|
||||
*
|
||||
* @param l - <20>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>(<64B)
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void DevEP3_IN_Deal(uint8_t l)
|
||||
{
|
||||
R8_UEP3_T_LEN = l;
|
||||
R8_UEP3_CTRL = (R8_UEP3_CTRL & ~MASK_UEP_T_RES) | UEP_T_RES_ACK;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn DevEP4_IN_Deal
|
||||
*
|
||||
* @brief <20>˵<EFBFBD>4<EFBFBD><34><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>
|
||||
*
|
||||
* @param l - <20>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>(<64B)
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void DevEP4_IN_Deal(uint8_t l)
|
||||
{
|
||||
R8_UEP4_T_LEN = l;
|
||||
R8_UEP4_CTRL = (R8_UEP4_CTRL & ~MASK_UEP_T_RES) | UEP_T_RES_ACK;
|
||||
}
|
||||
695
BLV_RF_W13_V04_20260114/StdPeriphDriver/CH57x_usbhostBase.c
Normal file
695
BLV_RF_W13_V04_20260114/StdPeriphDriver/CH57x_usbhostBase.c
Normal file
@@ -0,0 +1,695 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH57x_usbhost.c
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2021/11/17
|
||||
* Description : source file(ch572/ch570)
|
||||
*********************************************************************************
|
||||
* 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 "CH57x_common.h"
|
||||
#if DISK_LIB_ENABLE
|
||||
#include "CHRV3UFI.H"
|
||||
#endif
|
||||
|
||||
uint8_t UsbDevEndp0Size; // USB<53>豸<EFBFBD>Ķ˵<C4B6>0<EFBFBD><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߴ<EFBFBD>
|
||||
uint8_t FoundNewDev;
|
||||
_RootHubDev ThisUsbDev; //ROOT<4F><54>
|
||||
_DevOnHubPort DevOnHubPort[HUB_MAX_PORTS]; // <20>ٶ<EFBFBD>:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><31><EFBFBD>ⲿHUB,ÿ<><C3BF><EFBFBD>ⲿHUB<55><42><EFBFBD><EFBFBD><EFBFBD><EFBFBD>HUB_MAX_PORTS<54><53><EFBFBD>˿<EFBFBD>(<28><><EFBFBD>˲<EFBFBD><CBB2><EFBFBD>)
|
||||
|
||||
uint8_t *pHOST_RX_RAM_Addr;
|
||||
uint8_t *pHOST_TX_RAM_Addr;
|
||||
|
||||
/*<2A><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
__attribute__((aligned(4))) const uint8_t SetupGetDevDescr[] = {USB_REQ_TYP_IN, USB_GET_DESCRIPTOR, 0x00,
|
||||
USB_DESCR_TYP_DEVICE, 0x00, 0x00, sizeof(USB_DEV_DESCR), 0x00};
|
||||
/*<2A><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
__attribute__((aligned(4))) const uint8_t SetupGetCfgDescr[] = {USB_REQ_TYP_IN, USB_GET_DESCRIPTOR, 0x00,
|
||||
USB_DESCR_TYP_CONFIG, 0x00, 0x00, 0x04, 0x00};
|
||||
/*<2A><><EFBFBD><EFBFBD>USB<53><42>ַ*/
|
||||
__attribute__((aligned(4))) const uint8_t SetupSetUsbAddr[] = {USB_REQ_TYP_OUT, USB_SET_ADDRESS, USB_DEVICE_ADDR, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00};
|
||||
/*<2A><><EFBFBD><EFBFBD>USB<53><42><EFBFBD><EFBFBD>*/
|
||||
__attribute__((aligned(4))) const uint8_t SetupSetUsbConfig[] = {USB_REQ_TYP_OUT, USB_SET_CONFIGURATION, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00};
|
||||
/*<2A><><EFBFBD><EFBFBD>USB<53>ӿ<EFBFBD><D3BF><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
__attribute__((aligned(4))) const uint8_t SetupSetUsbInterface[] = {USB_REQ_RECIP_INTERF, USB_SET_INTERFACE, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00};
|
||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD>STALL*/
|
||||
__attribute__((aligned(4))) const uint8_t SetupClrEndpStall[] = {USB_REQ_TYP_OUT | USB_REQ_RECIP_ENDP, USB_CLEAR_FEATURE,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
/*********************************************************************
|
||||
* @fn DisableRootHubPort
|
||||
*
|
||||
* @brief <20>ر<EFBFBD>ROOT-HUB<55>˿<EFBFBD>,ʵ<><CAB5><EFBFBD><EFBFBD>Ӳ<EFBFBD><D3B2><EFBFBD>Ѿ<EFBFBD><D1BE>Զ<EFBFBD><D4B6>ر<EFBFBD>,<2C>˴<EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һЩ<D2BB>ṹ״̬
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void DisableRootHubPort(void)
|
||||
{
|
||||
#ifdef FOR_ROOT_UDISK_ONLY
|
||||
CHRV3DiskStatus = DISK_DISCONNECT;
|
||||
#endif
|
||||
#ifndef DISK_BASE_BUF_LEN
|
||||
ThisUsbDev.DeviceStatus = ROOT_DEV_DISCONNECT;
|
||||
ThisUsbDev.DeviceAddress = 0x00;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn AnalyzeRootHub
|
||||
*
|
||||
* @brief <20><><EFBFBD><EFBFBD>ROOT-HUB״̬,<2C><><EFBFBD><EFBFBD>ROOT-HUB<55>˿ڵ<CBBF><DAB5>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD>γ<EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD>DisableRootHubPort()<29><><EFBFBD><EFBFBD>,<2C><><EFBFBD>˿ڹر<DAB9>,<2C><><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>,<2C><><EFBFBD><EFBFBD>Ӧ<EFBFBD>˿ڵ<CBBF>״̬λ
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return <20><><EFBFBD><EFBFBD>ERR_SUCCESSΪû<CEAA><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>ERR_USB_CONNECTΪ<54><CEAA><EFBFBD><EFBFBD><E2B5BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>ERR_USB_DISCONΪ<4E><CEAA><EFBFBD><EFBFBD>Ͽ<EFBFBD>
|
||||
*/
|
||||
uint8_t AnalyzeRootHub(void)
|
||||
{
|
||||
uint8_t s;
|
||||
|
||||
s = ERR_SUCCESS;
|
||||
|
||||
if(R8_USB_MIS_ST & RB_UMS_DEV_ATTACH)
|
||||
{ // <20>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||||
#ifdef DISK_BASE_BUF_LEN
|
||||
if(CHRV3DiskStatus == DISK_DISCONNECT
|
||||
#else
|
||||
if(ThisUsbDev.DeviceStatus == ROOT_DEV_DISCONNECT // <20><><EFBFBD><EFBFBD><E2B5BD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||||
#endif
|
||||
|| (R8_UHOST_CTRL & RB_UH_PORT_EN) == 0x00)
|
||||
{ // <20><><EFBFBD><EFBFBD><E2B5BD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>,˵<><CBB5><EFBFBD>Ǹղ<C7B8><D5B2><EFBFBD>
|
||||
DisableRootHubPort(); // <20>رն˿<D5B6>
|
||||
#ifdef DISK_BASE_BUF_LEN
|
||||
CHRV3DiskStatus = DISK_CONNECT;
|
||||
#else
|
||||
ThisUsbDev.DeviceSpeed = R8_USB_MIS_ST & RB_UMS_DM_LEVEL ? 0 : 1;
|
||||
ThisUsbDev.DeviceStatus = ROOT_DEV_CONNECTED; //<2F><><EFBFBD><EFBFBD><EFBFBD>ӱ<EFBFBD>־
|
||||
#endif
|
||||
PRINT("USB dev in\n");
|
||||
s = ERR_USB_CONNECT;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DISK_BASE_BUF_LEN
|
||||
else if(CHRV3DiskStatus >= DISK_CONNECT)
|
||||
{
|
||||
#else
|
||||
else if(ThisUsbDev.DeviceStatus >= ROOT_DEV_CONNECTED)
|
||||
{ //<2F><><EFBFBD><EFBFBD>豸<EFBFBD>γ<EFBFBD>
|
||||
#endif
|
||||
DisableRootHubPort(); // <20>رն˿<D5B6>
|
||||
PRINT("USB dev out\n");
|
||||
if(s == ERR_SUCCESS)
|
||||
{
|
||||
s = ERR_USB_DISCON;
|
||||
}
|
||||
}
|
||||
// R8_USB_INT_FG = RB_UIF_DETECT; // <20><><EFBFBD>жϱ<D0B6>־
|
||||
return (s);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SetHostUsbAddr
|
||||
*
|
||||
* @brief <20><><EFBFBD><EFBFBD>USB<53><42><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>USB<53>豸<EFBFBD><E8B1B8>ַ
|
||||
*
|
||||
* @param addr - USB<53>豸<EFBFBD><E8B1B8>ַ
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void SetHostUsbAddr(uint8_t addr)
|
||||
{
|
||||
R8_USB_DEV_AD = (R8_USB_DEV_AD & RB_UDA_GP_BIT) | (addr & MASK_USB_ADDR);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SetUsbSpeed
|
||||
*
|
||||
* @brief <20><><EFBFBD>õ<EFBFBD>ǰUSB<53>ٶ<EFBFBD>
|
||||
*
|
||||
* @param FullSpeed - USB<53>ٶ<EFBFBD>
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void SetUsbSpeed(uint8_t FullSpeed)
|
||||
{
|
||||
#ifndef DISK_BASE_BUF_LEN
|
||||
if(FullSpeed) // ȫ<><C8AB>
|
||||
{
|
||||
R8_USB_CTRL &= ~RB_UC_LOW_SPEED; // ȫ<><C8AB>
|
||||
R8_UH_SETUP &= ~RB_UH_PRE_PID_EN; // <20><>ֹPRE PID
|
||||
}
|
||||
else
|
||||
{
|
||||
R8_USB_CTRL |= RB_UC_LOW_SPEED; // <20><><EFBFBD><EFBFBD>
|
||||
}
|
||||
#endif
|
||||
(void)FullSpeed;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn ResetRootHubPort
|
||||
*
|
||||
* @brief <20><><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8>,<2C><>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>,Ϊö<CEAA><C3B6><EFBFBD>豸<E8B1B8><D7BC>,<2C><><EFBFBD><EFBFBD>ΪĬ<CEAA><C4AC>Ϊȫ<CEAA><C8AB>
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void ResetRootHubPort(void)
|
||||
{
|
||||
UsbDevEndp0Size = DEFAULT_ENDP0_SIZE; //USB<53>豸<EFBFBD>Ķ˵<C4B6>0<EFBFBD><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߴ<EFBFBD>
|
||||
SetHostUsbAddr(0x00);
|
||||
R8_UHOST_CTRL &= ~RB_UH_PORT_EN; // <20>ص<EFBFBD><D8B5>˿<EFBFBD>
|
||||
SetUsbSpeed(1); // Ĭ<><C4AC>Ϊȫ<CEAA><C8AB>
|
||||
R8_UHOST_CTRL = (R8_UHOST_CTRL & ~RB_UH_LOW_SPEED) | RB_UH_BUS_RESET; // Ĭ<><C4AC>Ϊȫ<CEAA><C8AB>,<2C><>ʼ<EFBFBD><CABC>λ
|
||||
mDelaymS(15); // <20><>λʱ<CEBB><CAB1>10mS<6D><53>20mS
|
||||
R8_UHOST_CTRL = R8_UHOST_CTRL & ~RB_UH_BUS_RESET; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
|
||||
mDelayuS(250);
|
||||
R8_USB_INT_FG = RB_UIF_DETECT; // <20><><EFBFBD>жϱ<D0B6>־
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn EnableRootHubPort
|
||||
*
|
||||
* @brief ʹ<><CAB9>ROOT-HUB<55>˿<EFBFBD>,<2C><>Ӧ<EFBFBD><D3A6>bUH_PORT_EN<45><4E>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>,<2C>豸<EFBFBD>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD>ܵ<EFBFBD><DCB5>·<EFBFBD><C2B7><EFBFBD>ʧ<EFBFBD><CAA7>
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return <20><><EFBFBD><EFBFBD>ERR_SUCCESSΪ<53><CEAA><EFBFBD><EFBFBD><E2B5BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>ERR_USB_DISCONΪ<4E><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
uint8_t EnableRootHubPort(void)
|
||||
{
|
||||
#ifdef DISK_BASE_BUF_LEN
|
||||
if(CHRV3DiskStatus < DISK_CONNECT)
|
||||
CHRV3DiskStatus = DISK_CONNECT;
|
||||
#else
|
||||
if(ThisUsbDev.DeviceStatus < ROOT_DEV_CONNECTED)
|
||||
ThisUsbDev.DeviceStatus = ROOT_DEV_CONNECTED;
|
||||
#endif
|
||||
if(R8_USB_MIS_ST & RB_UMS_DEV_ATTACH)
|
||||
{ // <20><><EFBFBD>豸
|
||||
#ifndef DISK_BASE_BUF_LEN
|
||||
if((R8_UHOST_CTRL & RB_UH_PORT_EN) == 0x00)
|
||||
{ // <20><>δʹ<CEB4><CAB9>
|
||||
ThisUsbDev.DeviceSpeed = (R8_USB_MIS_ST & RB_UMS_DM_LEVEL) ? 0 : 1;
|
||||
if(ThisUsbDev.DeviceSpeed == 0)
|
||||
{
|
||||
R8_UHOST_CTRL |= RB_UH_LOW_SPEED; // <20><><EFBFBD><EFBFBD>
|
||||
}
|
||||
}
|
||||
#endif
|
||||
R8_UHOST_CTRL |= RB_UH_PORT_EN; //ʹ<><CAB9>HUB<55>˿<EFBFBD>
|
||||
return (ERR_SUCCESS);
|
||||
}
|
||||
return (ERR_USB_DISCON);
|
||||
}
|
||||
|
||||
#ifndef DISK_BASE_BUF_LEN
|
||||
/*********************************************************************
|
||||
* @fn SelectHubPort
|
||||
*
|
||||
* @brief ѡ<><D1A1><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>HUB<55><42>
|
||||
*
|
||||
* @param HubPortIndex - ѡ<><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>ROOT-HUB<55>˿ڵ<CBBF><DAB5>ⲿHUB<55><42>ָ<EFBFBD><D6B8><EFBFBD>˿<EFBFBD>
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void SelectHubPort(uint8_t HubPortIndex)
|
||||
{
|
||||
if(HubPortIndex) // ѡ<><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>ROOT-HUB<55>˿ڵ<CBBF><DAB5>ⲿHUB<55><42>ָ<EFBFBD><D6B8><EFBFBD>˿<EFBFBD>
|
||||
{
|
||||
SetHostUsbAddr(DevOnHubPort[HubPortIndex - 1].DeviceAddress); // <20><><EFBFBD><EFBFBD>USB<53><42><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>USB<53>豸<EFBFBD><E8B1B8>ַ
|
||||
SetUsbSpeed(DevOnHubPort[HubPortIndex - 1].DeviceSpeed); // <20><><EFBFBD>õ<EFBFBD>ǰUSB<53>ٶ<EFBFBD>
|
||||
if(DevOnHubPort[HubPortIndex - 1].DeviceSpeed == 0) // ͨ<><CDA8><EFBFBD>ⲿHUB<55><42><EFBFBD><EFBFBD><EFBFBD><EFBFBD>USB<53>豸ͨѶ<CDA8><D1B6>Ҫǰ<D2AA><C7B0>ID
|
||||
{
|
||||
R8_UEP1_CTRL |= RB_UH_PRE_PID_EN; // <20><><EFBFBD><EFBFBD>PRE PID
|
||||
mDelayuS(100);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SetHostUsbAddr(ThisUsbDev.DeviceAddress); // <20><><EFBFBD><EFBFBD>USB<53><42><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>USB<53>豸<EFBFBD><E8B1B8>ַ
|
||||
SetUsbSpeed(ThisUsbDev.DeviceSpeed); // <20><><EFBFBD><EFBFBD>USB<53>豸<EFBFBD><E8B1B8><EFBFBD>ٶ<EFBFBD>
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
* @fn WaitUSB_Interrupt
|
||||
*
|
||||
* @brief <20>ȴ<EFBFBD>USB<53>ж<EFBFBD>
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return <20><><EFBFBD><EFBFBD>ERR_SUCCESS <20><><EFBFBD>ݽ<EFBFBD><DDBD>ջ<EFBFBD><D5BB>߷<EFBFBD><DFB7>ͳɹ<CDB3>,<2C><><EFBFBD><EFBFBD>ERR_USB_UNKNOWN <20><><EFBFBD>ݽ<EFBFBD><DDBD>ջ<EFBFBD><D5BB>߷<EFBFBD><DFB7><EFBFBD>ʧ<EFBFBD><CAA7>
|
||||
*/
|
||||
uint8_t WaitUSB_Interrupt(void)
|
||||
{
|
||||
uint16_t i;
|
||||
for(i = WAIT_USB_TOUT_200US; i != 0 && (R8_USB_INT_FG & RB_UIF_TRANSFER) == 0; i--)
|
||||
{
|
||||
;
|
||||
}
|
||||
return ((R8_USB_INT_FG & RB_UIF_TRANSFER) ? ERR_SUCCESS : ERR_USB_UNKNOWN);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn USBHostTransact
|
||||
*
|
||||
* @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>Ŀ<EFBFBD>Ķ˵<C4B6><CBB5><EFBFBD>ַ/PID<49><44><EFBFBD><EFBFBD>,ͬ<><CDAC><EFBFBD><EFBFBD>־,<2C><>20uSΪ<53><CEAA>λ<EFBFBD><CEBB>NAK<41><4B><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>(0<><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0xFFFF<46><46><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>),<2C><><EFBFBD><EFBFBD>0<EFBFBD>ɹ<EFBFBD>,<2C><>ʱ/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <20><><EFBFBD>ӳ<EFBFBD><D3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>,Ϊ<><CEAA><EFBFBD>ṩ<EFBFBD><E1B9A9><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>,Ӧ<>öԱ<C3B6><D4B1>ӳ<EFBFBD><D3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ż<EFBFBD>
|
||||
*
|
||||
* @param endp_pid - <20><><EFBFBD>ƺ͵<C6BA>ַ, <20><>4λ<34><CEBB>token_pid<69><64><EFBFBD><EFBFBD>, <20><>4λ<34>Ƕ˵<C7B6><CBB5><EFBFBD>ַ
|
||||
* @param tog - ͬ<><CDAC><EFBFBD><EFBFBD>־
|
||||
* @param timeout - <20><>ʱʱ<CAB1><CAB1>
|
||||
*
|
||||
* @return ERR_USB_UNKNOWN <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӳ<EFBFBD><D3B2><EFBFBD>쳣
|
||||
* ERR_USB_DISCON <20>豸<EFBFBD>Ͽ<EFBFBD>
|
||||
* ERR_USB_CONNECT <20>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||||
* ERR_SUCCESS <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
uint8_t USBHostTransact(uint8_t endp_pid, uint8_t tog, uint32_t timeout)
|
||||
{
|
||||
uint8_t TransRetry;
|
||||
|
||||
uint8_t s, r;
|
||||
uint16_t i;
|
||||
|
||||
R8_UH_RX_CTRL = R8_UH_TX_CTRL = tog;
|
||||
TransRetry = 0;
|
||||
|
||||
do
|
||||
{
|
||||
R8_UH_EP_PID = endp_pid; // ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>PID<49><44>Ŀ<EFBFBD>Ķ˵<C4B6><CBB5><EFBFBD>
|
||||
R8_USB_INT_FG = RB_UIF_TRANSFER;
|
||||
for(i = WAIT_USB_TOUT_200US; i != 0 && (R8_USB_INT_FG & RB_UIF_TRANSFER) == 0; i--)
|
||||
{
|
||||
;
|
||||
}
|
||||
R8_UH_EP_PID = 0x00; // ֹͣUSB<53><42><EFBFBD><EFBFBD>
|
||||
if((R8_USB_INT_FG & RB_UIF_TRANSFER) == 0)
|
||||
{
|
||||
return (ERR_USB_UNKNOWN);
|
||||
}
|
||||
|
||||
if(R8_USB_INT_FG & RB_UIF_DETECT)
|
||||
{ // USB<53>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
||||
// mDelayuS( 200 ); // <20>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
R8_USB_INT_FG = RB_UIF_DETECT;
|
||||
s = AnalyzeRootHub(); // <20><><EFBFBD><EFBFBD>ROOT-HUB״̬
|
||||
|
||||
if(s == ERR_USB_CONNECT)
|
||||
FoundNewDev = 1;
|
||||
#ifdef DISK_BASE_BUF_LEN
|
||||
if(CHRV3DiskStatus == DISK_DISCONNECT)
|
||||
{
|
||||
return (ERR_USB_DISCON);
|
||||
} // USB<53>豸<EFBFBD>Ͽ<EFBFBD><CFBF>¼<EFBFBD>
|
||||
if(CHRV3DiskStatus == DISK_CONNECT)
|
||||
{
|
||||
return (ERR_USB_CONNECT);
|
||||
} // USB<53>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
||||
#else
|
||||
if(ThisUsbDev.DeviceStatus == ROOT_DEV_DISCONNECT)
|
||||
{
|
||||
return (ERR_USB_DISCON);
|
||||
} // USB<53>豸<EFBFBD>Ͽ<EFBFBD><CFBF>¼<EFBFBD>
|
||||
if(ThisUsbDev.DeviceStatus == ROOT_DEV_CONNECTED)
|
||||
{
|
||||
return (ERR_USB_CONNECT);
|
||||
} // USB<53>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
||||
#endif
|
||||
mDelayuS(200); // <20>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
|
||||
if(R8_USB_INT_FG & RB_UIF_TRANSFER) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
||||
{
|
||||
if(R8_USB_INT_ST & RB_UIS_TOG_OK)
|
||||
{
|
||||
return (ERR_SUCCESS);
|
||||
}
|
||||
r = R8_USB_INT_ST & MASK_UIS_H_RES; // USB<53>豸Ӧ<E8B1B8><D3A6>״̬
|
||||
if(r == USB_PID_STALL)
|
||||
{
|
||||
return (r | ERR_USB_TRANSFER);
|
||||
}
|
||||
if(r == USB_PID_NAK)
|
||||
{
|
||||
if(timeout == 0)
|
||||
{
|
||||
return (r | ERR_USB_TRANSFER);
|
||||
}
|
||||
if(timeout < 0xFFFFFFFF)
|
||||
{
|
||||
timeout--;
|
||||
}
|
||||
--TransRetry;
|
||||
}
|
||||
else
|
||||
switch(endp_pid >> 4)
|
||||
{
|
||||
case USB_PID_SETUP:
|
||||
case USB_PID_OUT:
|
||||
if(r)
|
||||
{
|
||||
return (r | ERR_USB_TRANSFER);
|
||||
} // <20><><EFBFBD>dz<EFBFBD>ʱ/<2F><><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6>
|
||||
break; // <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
|
||||
case USB_PID_IN:
|
||||
if(r == USB_PID_DATA0 || r == USB_PID_DATA1)
|
||||
{ // <20><>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD>趪<EFBFBD><E8B6AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
} // <20><>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
else if(r)
|
||||
{
|
||||
return (r | ERR_USB_TRANSFER);
|
||||
} // <20><><EFBFBD>dz<EFBFBD>ʱ/<2F><><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6>
|
||||
break; // <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
|
||||
default:
|
||||
return (ERR_USB_UNKNOWN); // <20><><EFBFBD><EFBFBD><EFBFBD>ܵ<EFBFBD><DCB5><EFBFBD><EFBFBD><EFBFBD>
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // <20><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>,<2C><>Ӧ<EFBFBD>÷<EFBFBD><C3B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
R8_USB_INT_FG = 0xFF; /* <20><><EFBFBD>жϱ<D0B6>־ */
|
||||
}
|
||||
mDelayuS(15);
|
||||
} while(++TransRetry < 3);
|
||||
return (ERR_USB_TRANSFER); // Ӧ<><D3A6><EFBFBD><EFBFBD>ʱ
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn HostCtrlTransfer
|
||||
*
|
||||
* @brief ִ<>п<EFBFBD><D0BF>ƴ<EFBFBD><C6B4><EFBFBD>,8<>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>pSetupReq<65><71>,DataBufΪ<66><CEAA>ѡ<EFBFBD><D1A1><EFBFBD>շ<EFBFBD><D5B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param DataBuf - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>պͷ<D5BA><CDB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><>ôDataBuf<75><66>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><DAB4>ź<EFBFBD><C5BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @param RetLen - ʵ<>ʳɹ<CAB3><C9B9>շ<EFBFBD><D5B7><EFBFBD><EFBFBD>ܳ<EFBFBD><DCB3>ȱ<EFBFBD><C8B1><EFBFBD><EFBFBD><EFBFBD>RetLenָ<6E><D6B8><EFBFBD><EFBFBD><EFBFBD>ֽڱ<D6BD><DAB1><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @return ERR_USB_BUF_OVER IN״̬<D7B4>γ<D7B6><CEB3><EFBFBD>
|
||||
* ERR_SUCCESS <20><><EFBFBD>ݽ<EFBFBD><DDBD><EFBFBD><EFBFBD>ɹ<EFBFBD>
|
||||
*/
|
||||
uint8_t HostCtrlTransfer(uint8_t *DataBuf, uint8_t *RetLen)
|
||||
{
|
||||
uint16_t RemLen = 0;
|
||||
uint8_t s, RxLen, RxCnt, TxCnt;
|
||||
uint8_t *pBuf;
|
||||
uint8_t *pLen;
|
||||
|
||||
pBuf = DataBuf;
|
||||
pLen = RetLen;
|
||||
mDelayuS(200);
|
||||
if(pLen)
|
||||
{
|
||||
*pLen = 0; // ʵ<>ʳɹ<CAB3><C9B9>շ<EFBFBD><D5B7><EFBFBD><EFBFBD>ܳ<EFBFBD><DCB3><EFBFBD>
|
||||
}
|
||||
|
||||
R8_UH_TX_LEN = sizeof(USB_SETUP_REQ);
|
||||
s = USBHostTransact(USB_PID_SETUP << 4 | 0x00, 0x00, 200000 / 20); // SETUP<55><EFBFBD>,200mS<6D><53>ʱ
|
||||
if(s != ERR_SUCCESS)
|
||||
{
|
||||
return (s);
|
||||
}
|
||||
R8_UH_RX_CTRL = R8_UH_TX_CTRL = RB_UH_R_TOG | RB_UH_R_AUTO_TOG | RB_UH_T_TOG | RB_UH_T_AUTO_TOG; // Ĭ<><C4AC>DATA1
|
||||
R8_UH_TX_LEN = 0x01; // Ĭ<><C4AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݹ<EFBFBD>״̬<D7B4><EFBFBD>ΪIN
|
||||
RemLen = pSetupReq->wLength;
|
||||
PRINT("wLength: %x\n", RemLen);
|
||||
if(RemLen && pBuf) // <20><>Ҫ<EFBFBD>շ<EFBFBD><D5B7><EFBFBD><EFBFBD><EFBFBD>
|
||||
{
|
||||
PRINT("bRequestType: %x\n", pSetupReq->bRequestType);
|
||||
if(pSetupReq->bRequestType & USB_REQ_TYP_IN) // <20><>
|
||||
{
|
||||
while(RemLen)
|
||||
{
|
||||
mDelayuS(200);
|
||||
s = USBHostTransact(USB_PID_IN << 4 | 0x00, R8_UH_RX_CTRL, 200000 / 20); // IN<49><4E><EFBFBD><EFBFBD>
|
||||
if(s != ERR_SUCCESS)
|
||||
{
|
||||
return (s);
|
||||
}
|
||||
RxLen = R8_USB_RX_LEN < RemLen ? R8_USB_RX_LEN : RemLen;
|
||||
RemLen -= RxLen;
|
||||
if(pLen)
|
||||
{
|
||||
*pLen += RxLen; // ʵ<>ʳɹ<CAB3><C9B9>շ<EFBFBD><D5B7><EFBFBD><EFBFBD>ܳ<EFBFBD><DCB3><EFBFBD>
|
||||
}
|
||||
for(RxCnt = 0; RxCnt != RxLen; RxCnt++)
|
||||
{
|
||||
*pBuf = pHOST_RX_RAM_Addr[RxCnt];
|
||||
pBuf++;
|
||||
}
|
||||
if(R8_USB_RX_LEN == 0 || (R8_USB_RX_LEN & (UsbDevEndp0Size - 1)))
|
||||
{
|
||||
break; // <20>̰<EFBFBD>
|
||||
}
|
||||
}
|
||||
R8_UH_TX_LEN = 0x00; // ״̬<D7B4><EFBFBD>ΪOUT
|
||||
}
|
||||
else // <20><>
|
||||
{
|
||||
while(RemLen)
|
||||
{
|
||||
mDelayuS(200);
|
||||
R8_UH_TX_LEN = RemLen >= UsbDevEndp0Size ? UsbDevEndp0Size : RemLen;
|
||||
for(TxCnt = 0; TxCnt != R8_UH_TX_LEN; TxCnt++)
|
||||
{
|
||||
pHOST_TX_RAM_Addr[TxCnt] = *pBuf;
|
||||
pBuf++;
|
||||
}
|
||||
s = USBHostTransact(USB_PID_OUT << 4 | 0x00, R8_UH_TX_CTRL, 200000 / 20); // OUT<55><54><EFBFBD><EFBFBD>
|
||||
if(s != ERR_SUCCESS)
|
||||
{
|
||||
return (s);
|
||||
}
|
||||
RemLen -= R8_UH_TX_LEN;
|
||||
if(pLen)
|
||||
{
|
||||
*pLen += R8_UH_TX_LEN; // ʵ<>ʳɹ<CAB3><C9B9>շ<EFBFBD><D5B7><EFBFBD><EFBFBD>ܳ<EFBFBD><DCB3><EFBFBD>
|
||||
}
|
||||
}
|
||||
PRINT("Send: %d\n", *pLen);
|
||||
// R8_UH_TX_LEN = 0x01; // ״̬<D7B4><EFBFBD>ΪIN
|
||||
}
|
||||
}
|
||||
mDelayuS(200);
|
||||
s = USBHostTransact((R8_UH_TX_LEN ? USB_PID_IN << 4 | 0x00 : USB_PID_OUT << 4 | 0x00), RB_UH_R_TOG | RB_UH_T_TOG, 200000 / 20); // STATUS<55><EFBFBD>
|
||||
if(s != ERR_SUCCESS)
|
||||
{
|
||||
return (s);
|
||||
}
|
||||
if(R8_UH_TX_LEN == 0)
|
||||
{
|
||||
return (ERR_SUCCESS); // ״̬OUT
|
||||
}
|
||||
if(R8_USB_RX_LEN == 0)
|
||||
{
|
||||
return (ERR_SUCCESS); // ״̬IN,<2C><><EFBFBD><EFBFBD>IN״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||
}
|
||||
return (ERR_USB_BUF_OVER); // IN״̬<D7B4>δ<D7B6><CEB4><EFBFBD>
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn CopySetupReqPkg
|
||||
*
|
||||
* @brief <20><><EFBFBD>ƿ<EFBFBD><C6BF>ƴ<EFBFBD><C6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param pReqPkt - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void CopySetupReqPkg(const uint8_t *pReqPkt) // <20><><EFBFBD>ƿ<EFBFBD><C6BF>ƴ<EFBFBD><C6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
{
|
||||
uint8_t i;
|
||||
for(i = 0; i != sizeof(USB_SETUP_REQ); i++)
|
||||
{
|
||||
((uint8_t *)pSetupReq)[i] = *pReqPkt;
|
||||
pReqPkt++;
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn CtrlGetDeviceDescr
|
||||
*
|
||||
* @brief <20><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> pHOST_TX_RAM_Addr <20><>
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return ERR_USB_BUF_OVER <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD><C8B4><EFBFBD>
|
||||
* ERR_SUCCESS <20>ɹ<EFBFBD>
|
||||
*/
|
||||
uint8_t CtrlGetDeviceDescr(void)
|
||||
{
|
||||
uint8_t s;
|
||||
uint8_t len;
|
||||
|
||||
UsbDevEndp0Size = DEFAULT_ENDP0_SIZE;
|
||||
CopySetupReqPkg(SetupGetDevDescr);
|
||||
s = HostCtrlTransfer(Com_Buffer, &len); // ִ<>п<EFBFBD><D0BF>ƴ<EFBFBD><C6B4><EFBFBD>
|
||||
if(s != ERR_SUCCESS)
|
||||
{
|
||||
return (s);
|
||||
}
|
||||
UsbDevEndp0Size = ((PUSB_DEV_DESCR)Com_Buffer)->bMaxPacketSize0; // <20>˵<EFBFBD>0<EFBFBD><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD>Ǽ<C7BC><F2BBAFB4><EFBFBD>,<2C><><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD>Ȼ<EFBFBD>ȡǰ8<C7B0>ֽں<D6BD><DABA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>UsbDevEndp0Size<7A>ټ<EFBFBD><D9BC><EFBFBD>
|
||||
if(len < ((PUSB_SETUP_REQ)SetupGetDevDescr)->wLength)
|
||||
{
|
||||
return (ERR_USB_BUF_OVER); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD><C8B4><EFBFBD>
|
||||
}
|
||||
return (ERR_SUCCESS);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn CtrlGetConfigDescr
|
||||
*
|
||||
* @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> pHOST_TX_RAM_Addr <20><>
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return ERR_USB_BUF_OVER <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD><C8B4><EFBFBD>
|
||||
* ERR_SUCCESS <20>ɹ<EFBFBD>
|
||||
*/
|
||||
uint8_t CtrlGetConfigDescr(void)
|
||||
{
|
||||
uint8_t s;
|
||||
uint8_t len;
|
||||
|
||||
CopySetupReqPkg(SetupGetCfgDescr);
|
||||
s = HostCtrlTransfer(Com_Buffer, &len); // ִ<>п<EFBFBD><D0BF>ƴ<EFBFBD><C6B4><EFBFBD>
|
||||
if(s != ERR_SUCCESS)
|
||||
{
|
||||
return (s);
|
||||
}
|
||||
if(len < ((PUSB_SETUP_REQ)SetupGetCfgDescr)->wLength)
|
||||
{
|
||||
return (ERR_USB_BUF_OVER); // <20><><EFBFBD>س<EFBFBD><D8B3>ȴ<EFBFBD><C8B4><EFBFBD>
|
||||
}
|
||||
|
||||
len = ((PUSB_CFG_DESCR)Com_Buffer)->wTotalLength;
|
||||
CopySetupReqPkg(SetupGetCfgDescr);
|
||||
pSetupReq->wLength = len; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD><DCB3><EFBFBD>
|
||||
s = HostCtrlTransfer(Com_Buffer, &len); // ִ<>п<EFBFBD><D0BF>ƴ<EFBFBD><C6B4><EFBFBD>
|
||||
if(s != ERR_SUCCESS)
|
||||
{
|
||||
return (s);
|
||||
}
|
||||
|
||||
#ifdef DISK_BASE_BUF_LEN
|
||||
if(len > 64)
|
||||
len = 64;
|
||||
memcpy(TxBuffer, Com_Buffer, len); //U<>̲<EFBFBD><CCB2><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>TxBuffer
|
||||
#endif
|
||||
|
||||
return (ERR_SUCCESS);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn CtrlSetUsbAddress
|
||||
*
|
||||
* @brief <20><><EFBFBD><EFBFBD>USB<53>豸<EFBFBD><E8B1B8>ַ
|
||||
*
|
||||
* @param addr - <20>豸<EFBFBD><E8B1B8>ַ
|
||||
*
|
||||
* @return ERR_SUCCESS <20>ɹ<EFBFBD>
|
||||
*/
|
||||
uint8_t CtrlSetUsbAddress(uint8_t addr)
|
||||
{
|
||||
uint8_t s;
|
||||
|
||||
CopySetupReqPkg(SetupSetUsbAddr);
|
||||
pSetupReq->wValue = addr; // USB<53>豸<EFBFBD><E8B1B8>ַ
|
||||
s = HostCtrlTransfer(NULL, NULL); // ִ<>п<EFBFBD><D0BF>ƴ<EFBFBD><C6B4><EFBFBD>
|
||||
if(s != ERR_SUCCESS)
|
||||
{
|
||||
return (s);
|
||||
}
|
||||
SetHostUsbAddr(addr); // <20><><EFBFBD><EFBFBD>USB<53><42><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>USB<53>豸<EFBFBD><E8B1B8>ַ
|
||||
mDelaymS(10); // <20>ȴ<EFBFBD>USB<53>豸<EFBFBD><E8B1B8><EFBFBD>ɲ<EFBFBD><C9B2><EFBFBD>
|
||||
return (ERR_SUCCESS);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn CtrlSetUsbConfig
|
||||
*
|
||||
* @brief <20><><EFBFBD><EFBFBD>USB<53>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param cfg - <20><><EFBFBD><EFBFBD>ֵ
|
||||
*
|
||||
* @return ERR_SUCCESS <20>ɹ<EFBFBD>
|
||||
*/
|
||||
uint8_t CtrlSetUsbConfig(uint8_t cfg)
|
||||
{
|
||||
CopySetupReqPkg(SetupSetUsbConfig);
|
||||
pSetupReq->wValue = cfg; // USB<53>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||||
return (HostCtrlTransfer(NULL, NULL)); // ִ<>п<EFBFBD><D0BF>ƴ<EFBFBD><C6B4><EFBFBD>
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn CtrlClearEndpStall
|
||||
*
|
||||
* @brief <20><><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD>STALL
|
||||
*
|
||||
* @param endp - <20>˵<EFBFBD><CBB5><EFBFBD>ַ
|
||||
*
|
||||
* @return ERR_SUCCESS <20>ɹ<EFBFBD>
|
||||
*/
|
||||
uint8_t CtrlClearEndpStall(uint8_t endp)
|
||||
{
|
||||
CopySetupReqPkg(SetupClrEndpStall); // <20><><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>Ĵ<EFBFBD><C4B4><EFBFBD>
|
||||
pSetupReq->wIndex = endp; // <20>˵<EFBFBD><CBB5><EFBFBD>ַ
|
||||
return (HostCtrlTransfer(NULL, NULL)); // ִ<>п<EFBFBD><D0BF>ƴ<EFBFBD><C6B4><EFBFBD>
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn CtrlSetUsbIntercace
|
||||
*
|
||||
* @brief <20><><EFBFBD><EFBFBD>USB<53>豸<EFBFBD>ӿ<EFBFBD>
|
||||
*
|
||||
* @param cfg - <20><><EFBFBD><EFBFBD>ֵ
|
||||
*
|
||||
* @return ERR_SUCCESS <20>ɹ<EFBFBD>
|
||||
*/
|
||||
uint8_t CtrlSetUsbIntercace(uint8_t cfg)
|
||||
{
|
||||
CopySetupReqPkg(SetupSetUsbInterface);
|
||||
pSetupReq->wValue = cfg; // USB<53>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||||
return (HostCtrlTransfer(NULL, NULL)); // ִ<>п<EFBFBD><D0BF>ƴ<EFBFBD><C6B4><EFBFBD>
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn USB_HostInit
|
||||
*
|
||||
* @brief USB<53><42><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD>ʼ<EFBFBD><CABC>
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void USB_HostInit(void)
|
||||
{
|
||||
R8_USB_CTRL = RB_UC_HOST_MODE;
|
||||
R8_UHOST_CTRL = 0;
|
||||
R8_USB_DEV_AD = 0x00;
|
||||
|
||||
R8_UH_EP_MOD = RB_UH_EP_TX_EN | RB_UH_EP_RX_EN;
|
||||
R16_UH_RX_DMA = (uint32_t)pHOST_RX_RAM_Addr;
|
||||
R16_UH_TX_DMA = (uint32_t)pHOST_TX_RAM_Addr;
|
||||
|
||||
R8_UH_RX_CTRL = 0x00;
|
||||
R8_UH_TX_CTRL = 0x00;
|
||||
R8_USB_CTRL = RB_UC_HOST_MODE | RB_UC_INT_BUSY | RB_UC_DMA_EN;
|
||||
R8_UH_SETUP = RB_UH_SOF_EN;
|
||||
R8_USB_INT_FG = 0xFF;
|
||||
DisableRootHubPort();
|
||||
R8_USB_INT_EN = RB_UIE_TRANSFER | RB_UIE_DETECT;
|
||||
|
||||
FoundNewDev = 0;
|
||||
}
|
||||
840
BLV_RF_W13_V04_20260114/StdPeriphDriver/CH57x_usbhostClass.c
Normal file
840
BLV_RF_W13_V04_20260114/StdPeriphDriver/CH57x_usbhostClass.c
Normal file
@@ -0,0 +1,840 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH57x_usbhost.c
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2021/11/17
|
||||
* Description : source file(ch572/ch570)
|
||||
*********************************************************************************
|
||||
* 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 "CH57x_common.h"
|
||||
#if DISK_LIB_ENABLE
|
||||
#include "CHRV3UFI.H"
|
||||
#endif
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD>HID<49>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD><EFBFBD> */
|
||||
__attribute__((aligned(4))) const uint8_t SetupSetHIDIdle[] = {0x21, HID_SET_IDLE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
/* <20><>ȡHID<49>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
__attribute__((aligned(4))) const uint8_t SetupGetHIDDevReport[] = {0x81, USB_GET_DESCRIPTOR, 0x00, USB_DESCR_TYP_REPORT,
|
||||
0x00, 0x00, 0x41, 0x00};
|
||||
/* <20><>ȡHUB<55><42><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
__attribute__((aligned(4))) const uint8_t SetupGetHubDescr[] = {HUB_GET_HUB_DESCRIPTOR, HUB_GET_DESCRIPTOR, 0x00,
|
||||
USB_DESCR_TYP_HUB, 0x00, 0x00, sizeof(USB_HUB_DESCR), 0x00};
|
||||
|
||||
__attribute__((aligned(4))) uint8_t Com_Buffer[128]; // <20><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,ö<><C3B6>ʱ<EFBFBD><CAB1><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,ö<>ٽ<EFBFBD><D9BD><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
/*********************************************************************
|
||||
* @fn AnalyzeHidIntEndp
|
||||
*
|
||||
* @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>з<EFBFBD><D0B7><EFBFBD><EFBFBD><EFBFBD>HID<49>ж϶˵<CFB6><CBB5>ĵ<EFBFBD>ַ,<2C><><EFBFBD><EFBFBD>HubPortIndex<65><78>0<EFBFBD><30><EFBFBD>浽ROOTHUB<55><42><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>ֵ<EFBFBD>浽HUB<55>½ṹ<C2BD><E1B9B9>
|
||||
*
|
||||
* @param buf - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݻ<EFBFBD><DDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ HubPortIndex<65><78>0<EFBFBD><30>ʾ<EFBFBD><CABE>HUB<55><42><EFBFBD><EFBFBD>0<EFBFBD><30>ʾ<EFBFBD>ⲿHUB<55>µĶ˿ں<CBBF>
|
||||
*
|
||||
* @return <20>˵<EFBFBD><CBB5><EFBFBD>
|
||||
*/
|
||||
uint8_t AnalyzeHidIntEndp(uint8_t *buf, uint8_t HubPortIndex)
|
||||
{
|
||||
uint8_t i, s, l;
|
||||
s = 0;
|
||||
|
||||
if(HubPortIndex)
|
||||
{
|
||||
memset(DevOnHubPort[HubPortIndex - 1].GpVar, 0, sizeof(DevOnHubPort[HubPortIndex - 1].GpVar)); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(ThisUsbDev.GpVar, 0, sizeof(ThisUsbDev.GpVar)); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
|
||||
for(i = 0; i < ((PUSB_CFG_DESCR)buf)->wTotalLength; i += l) // <20><><EFBFBD><EFBFBD><EFBFBD>ж϶˵<CFB6><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͽӿ<CDBD><D3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
{
|
||||
if(((PUSB_ENDP_DESCR)(buf + i))->bDescriptorType == USB_DESCR_TYP_ENDP // <20>Ƕ˵<C7B6><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
&& (((PUSB_ENDP_DESCR)(buf + i))->bmAttributes & USB_ENDP_TYPE_MASK) == USB_ENDP_TYPE_INTER // <20><><EFBFBD>ж϶˵<CFB6>
|
||||
&& (((PUSB_ENDP_DESCR)(buf + i))->bEndpointAddress & USB_ENDP_DIR_MASK)) // <20><>IN<49>˵<EFBFBD>
|
||||
{ // <20><><EFBFBD><EFBFBD><EFBFBD>ж϶˵<CFB6><CBB5>ĵ<EFBFBD>ַ,λ7<CEBB><37><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD>־λ,<2C><>0
|
||||
if(HubPortIndex)
|
||||
{
|
||||
DevOnHubPort[HubPortIndex - 1].GpVar[s] = ((PUSB_ENDP_DESCR)(buf + i))->bEndpointAddress & USB_ENDP_ADDR_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
ThisUsbDev.GpVar[s] = ((PUSB_ENDP_DESCR)(buf + i))->bEndpointAddress & USB_ENDP_ADDR_MASK; // <20>ж϶˵<CFB6><CBB5>ĵ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>Ը<EFBFBD><D4B8><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>wMaxPacketSize<7A><65>bInterval
|
||||
}
|
||||
PRINT("%02x ", (uint16_t)ThisUsbDev.GpVar[s]);
|
||||
s++;
|
||||
if(s >= 4)
|
||||
{
|
||||
break; //ֻ<><D6BB><EFBFBD><EFBFBD>4<EFBFBD><34><EFBFBD>˵<EFBFBD>
|
||||
}
|
||||
}
|
||||
l = ((PUSB_ENDP_DESCR)(buf + i))->bLength; // <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>
|
||||
if(l > 16)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
PRINT("\n");
|
||||
return (s);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn AnalyzeBulkEndp
|
||||
*
|
||||
* @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD>,GpVar[0]<5D><>GpVar[1]<5D><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD><CFB4>˵㡣GpVar[2]<5D><>GpVar[3]<5D><><EFBFBD><EFBFBD><EFBFBD>´<EFBFBD><C2B4>˵<EFBFBD>
|
||||
*
|
||||
* @param buf - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݻ<EFBFBD><DDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ HubPortIndex<65><78>0<EFBFBD><30>ʾ<EFBFBD><CABE>HUB<55><42><EFBFBD><EFBFBD>0<EFBFBD><30>ʾ<EFBFBD>ⲿHUB<55>µĶ˿ں<CBBF>
|
||||
*
|
||||
* @return 0
|
||||
*/
|
||||
uint8_t AnalyzeBulkEndp(uint8_t *buf, uint8_t HubPortIndex)
|
||||
{
|
||||
uint8_t i, s1, s2, l;
|
||||
s1 = 0;
|
||||
s2 = 2;
|
||||
|
||||
if(HubPortIndex)
|
||||
{
|
||||
memset(DevOnHubPort[HubPortIndex - 1].GpVar, 0, sizeof(DevOnHubPort[HubPortIndex - 1].GpVar)); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(ThisUsbDev.GpVar, 0, sizeof(ThisUsbDev.GpVar)); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
|
||||
for(i = 0; i < ((PUSB_CFG_DESCR)buf)->wTotalLength; i += l) // <20><><EFBFBD><EFBFBD><EFBFBD>ж϶˵<CFB6><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͽӿ<CDBD><D3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
{
|
||||
if((((PUSB_ENDP_DESCR)(buf + i))->bDescriptorType == USB_DESCR_TYP_ENDP) // <20>Ƕ˵<C7B6><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
&& ((((PUSB_ENDP_DESCR)(buf + i))->bmAttributes & USB_ENDP_TYPE_MASK) == USB_ENDP_TYPE_BULK)) // <20><><EFBFBD>ж϶˵<CFB6>
|
||||
|
||||
{
|
||||
if(HubPortIndex)
|
||||
{
|
||||
if(((PUSB_ENDP_DESCR)(buf + i))->bEndpointAddress & USB_ENDP_DIR_MASK)
|
||||
{
|
||||
DevOnHubPort[HubPortIndex - 1].GpVar[s1++] = ((PUSB_ENDP_DESCR)(buf + i))->bEndpointAddress & USB_ENDP_ADDR_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
DevOnHubPort[HubPortIndex - 1].GpVar[s2++] = ((PUSB_ENDP_DESCR)(buf + i))->bEndpointAddress & USB_ENDP_ADDR_MASK;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(((PUSB_ENDP_DESCR)(buf + i))->bEndpointAddress & USB_ENDP_DIR_MASK)
|
||||
{
|
||||
ThisUsbDev.GpVar[s1++] = ((PUSB_ENDP_DESCR)(buf + i))->bEndpointAddress & USB_ENDP_ADDR_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
ThisUsbDev.GpVar[s2++] = ((PUSB_ENDP_DESCR)(buf + i))->bEndpointAddress & USB_ENDP_ADDR_MASK;
|
||||
}
|
||||
}
|
||||
|
||||
if(s1 == 2)
|
||||
{
|
||||
s1 = 1;
|
||||
}
|
||||
if(s2 == 4)
|
||||
{
|
||||
s2 = 3;
|
||||
}
|
||||
}
|
||||
l = ((PUSB_ENDP_DESCR)(buf + i))->bLength; // <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>
|
||||
if(l > 16)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn InitRootDevice
|
||||
*
|
||||
* @brief <20><>ʼ<EFBFBD><CABC>ָ<EFBFBD><D6B8>ROOT-HUB<55>˿ڵ<CBBF>USB<53>豸
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
uint8_t InitRootDevice(void)
|
||||
{
|
||||
uint8_t i, s;
|
||||
uint8_t cfg, dv_cls, if_cls;
|
||||
|
||||
PRINT("Reset host port\n");
|
||||
ResetRootHubPort(); // <20><><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8>,<2C><>λ<EFBFBD><CEBB>Ӧ<EFBFBD>˿ڵ<CBBF>USB<53><42><EFBFBD><EFBFBD>
|
||||
for(i = 0, s = 0; i < 100; i++)
|
||||
{ // <20>ȴ<EFBFBD>USB<53>豸<EFBFBD><E8B1B8>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,100mS<6D><53>ʱ
|
||||
mDelaymS(1);
|
||||
if(EnableRootHubPort() == ERR_SUCCESS)
|
||||
{ // ʹ<>ܶ˿<DCB6>
|
||||
i = 0;
|
||||
s++;
|
||||
if(s > 100)
|
||||
{
|
||||
break; // <20>Ѿ<EFBFBD><D1BE>ȶ<EFBFBD><C8B6><EFBFBD><EFBFBD><EFBFBD>100mS
|
||||
}
|
||||
}
|
||||
}
|
||||
if(i)
|
||||
{ // <20><>λ<EFBFBD><CEBB><EFBFBD>豸û<E8B1B8><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
DisableRootHubPort();
|
||||
PRINT("Disable host port because of disconnect\n");
|
||||
return (ERR_USB_DISCON);
|
||||
}
|
||||
SetUsbSpeed(ThisUsbDev.DeviceSpeed); // <20><><EFBFBD>õ<EFBFBD>ǰUSB<53>ٶ<EFBFBD>
|
||||
|
||||
PRINT("GetDevDescr: ");
|
||||
s = CtrlGetDeviceDescr(); // <20><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if(s == ERR_SUCCESS)
|
||||
{
|
||||
for(i = 0; i < ((PUSB_SETUP_REQ)SetupGetDevDescr)->wLength; i++)
|
||||
{
|
||||
PRINT("x%02X ", (uint16_t)(Com_Buffer[i]));
|
||||
}
|
||||
PRINT("\n");
|
||||
|
||||
ThisUsbDev.DeviceVID = ((PUSB_DEV_DESCR)Com_Buffer)->idVendor; //<2F><><EFBFBD><EFBFBD>VID PID<49><44>Ϣ
|
||||
ThisUsbDev.DevicePID = ((PUSB_DEV_DESCR)Com_Buffer)->idProduct;
|
||||
dv_cls = ((PUSB_DEV_DESCR)Com_Buffer)->bDeviceClass;
|
||||
|
||||
s = CtrlSetUsbAddress(((PUSB_SETUP_REQ)SetupSetUsbAddr)->wValue);
|
||||
if(s == ERR_SUCCESS)
|
||||
{
|
||||
ThisUsbDev.DeviceAddress = ((PUSB_SETUP_REQ)SetupSetUsbAddr)->wValue; // <20><><EFBFBD><EFBFBD>USB<53><42>ַ
|
||||
|
||||
PRINT("GetCfgDescr: ");
|
||||
s = CtrlGetConfigDescr();
|
||||
if(s == ERR_SUCCESS)
|
||||
{
|
||||
for(i = 0; i < ((PUSB_CFG_DESCR)Com_Buffer)->wTotalLength; i++)
|
||||
{
|
||||
PRINT("x%02X ", (uint16_t)(Com_Buffer[i]));
|
||||
}
|
||||
PRINT("\n");
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><>ȡ<EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>ַ/<2F><><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>С<EFBFBD><D0A1>,<2C><><EFBFBD>±<EFBFBD><C2B1><EFBFBD>endp_addr<64><72>endp_size<7A><65> */
|
||||
cfg = ((PUSB_CFG_DESCR)Com_Buffer)->bConfigurationValue;
|
||||
if_cls = ((PUSB_CFG_DESCR_LONG)Com_Buffer)->itf_descr.bInterfaceClass; // <20>ӿ<EFBFBD><D3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
if((dv_cls == 0x00) && (if_cls == USB_DEV_CLASS_STORAGE))
|
||||
{ // <20><>USB<53>洢<EFBFBD><E6B4A2><EFBFBD>豸,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD>U<EFBFBD><55>
|
||||
#ifdef FOR_ROOT_UDISK_ONLY
|
||||
CHRV3DiskStatus = DISK_USB_ADDR;
|
||||
return (ERR_SUCCESS);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (ERR_USB_UNSUPPORT);
|
||||
}
|
||||
#else
|
||||
s = CtrlSetUsbConfig(cfg); // <20><><EFBFBD><EFBFBD>USB<53>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||||
if(s == ERR_SUCCESS)
|
||||
{
|
||||
ThisUsbDev.DeviceStatus = ROOT_DEV_SUCCESS;
|
||||
ThisUsbDev.DeviceType = USB_DEV_CLASS_STORAGE;
|
||||
PRINT("USB-Disk Ready\n");
|
||||
SetUsbSpeed(1); // Ĭ<><C4AC>Ϊȫ<CEAA><C8AB>
|
||||
return (ERR_SUCCESS);
|
||||
}
|
||||
}
|
||||
else if((dv_cls == 0x00) && (if_cls == USB_DEV_CLASS_PRINTER) && ((PUSB_CFG_DESCR_LONG)Com_Buffer)->itf_descr.bInterfaceSubClass == 0x01)
|
||||
{ // <20>Ǵ<EFBFBD>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><EFBFBD>豸
|
||||
s = CtrlSetUsbConfig(cfg); // <20><><EFBFBD><EFBFBD>USB<53>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||||
if(s == ERR_SUCCESS)
|
||||
{
|
||||
// <09>豣<EFBFBD><E8B1A3><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>Ϣ<EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>USB<53><42><EFBFBD><EFBFBD>
|
||||
ThisUsbDev.DeviceStatus = ROOT_DEV_SUCCESS;
|
||||
ThisUsbDev.DeviceType = USB_DEV_CLASS_PRINTER;
|
||||
PRINT("USB-Print Ready\n");
|
||||
SetUsbSpeed(1); // Ĭ<><C4AC>Ϊȫ<CEAA><C8AB>
|
||||
return (ERR_SUCCESS);
|
||||
}
|
||||
}
|
||||
else if((dv_cls == 0x00) && (if_cls == USB_DEV_CLASS_HID) && ((PUSB_CFG_DESCR_LONG)Com_Buffer)->itf_descr.bInterfaceSubClass <= 0x01)
|
||||
{ // <20><>HID<49><44><EFBFBD>豸,<2C><><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>з<EFBFBD><D0B7><EFBFBD><EFBFBD><EFBFBD>HID<49>ж϶˵<CFB6><CBB5>ĵ<EFBFBD>ַ
|
||||
s = AnalyzeHidIntEndp(Com_Buffer, 0); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>з<EFBFBD><D0B7><EFBFBD><EFBFBD><EFBFBD>HID<49>ж϶˵<CFB6><CBB5>ĵ<EFBFBD>ַ
|
||||
PRINT("AnalyzeHidIntEndp %02x\n", (uint16_t)s);
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>ж϶˵<CFB6><CBB5>ĵ<EFBFBD>ַ,λ7<CEBB><37><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD>־λ,<2C><>0
|
||||
if_cls = ((PUSB_CFG_DESCR_LONG)Com_Buffer)->itf_descr.bInterfaceProtocol;
|
||||
s = CtrlSetUsbConfig(cfg); // <20><><EFBFBD><EFBFBD>USB<53>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||||
if(s == ERR_SUCCESS)
|
||||
{
|
||||
s = CtrlGetHIDDeviceReport(dv_cls); //<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if(s == ERR_SUCCESS)
|
||||
{
|
||||
for(i = 0; i < 64; i++)
|
||||
{
|
||||
PRINT("x%02X ", (uint16_t)(Com_Buffer[i]));
|
||||
}
|
||||
PRINT("\n");
|
||||
}
|
||||
// <09>豣<EFBFBD><E8B1A3><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>Ϣ<EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>USB<53><42><EFBFBD><EFBFBD>
|
||||
ThisUsbDev.DeviceStatus = ROOT_DEV_SUCCESS;
|
||||
if(if_cls == 1)
|
||||
{
|
||||
ThisUsbDev.DeviceType = DEV_TYPE_KEYBOARD;
|
||||
// <09><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>,<2C><><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>ָʾ<D6B8><CABE>LED<45><44>
|
||||
PRINT("USB-Keyboard Ready\n");
|
||||
SetUsbSpeed(1); // Ĭ<><C4AC>Ϊȫ<CEAA><C8AB>
|
||||
return (ERR_SUCCESS);
|
||||
}
|
||||
else if(if_cls == 2)
|
||||
{
|
||||
ThisUsbDev.DeviceType = DEV_TYPE_MOUSE;
|
||||
// Ϊ<><CEAA><EFBFBD>Ժ<EFBFBD><D4BA><EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>״̬,Ӧ<>÷<EFBFBD><C3B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,ȡ<><C8A1><EFBFBD>ж϶˿ڵĵ<DAB5>ַ,<2C><><EFBFBD>ȵ<EFBFBD><C8B5><EFBFBD>Ϣ
|
||||
PRINT("USB-Mouse Ready\n");
|
||||
SetUsbSpeed(1); // Ĭ<><C4AC>Ϊȫ<CEAA><C8AB>
|
||||
return (ERR_SUCCESS);
|
||||
}
|
||||
s = ERR_USB_UNSUPPORT;
|
||||
}
|
||||
}
|
||||
else if(dv_cls == USB_DEV_CLASS_HUB)
|
||||
{ // <20><>HUB<55><42><EFBFBD>豸,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
s = CtrlGetHubDescr();
|
||||
if(s == ERR_SUCCESS)
|
||||
{
|
||||
PRINT("Max Port:%02X ", (((PXUSB_HUB_DESCR)Com_Buffer)->bNbrPorts));
|
||||
ThisUsbDev.GpHUBPortNum = ((PXUSB_HUB_DESCR)Com_Buffer)->bNbrPorts; // <20><><EFBFBD><EFBFBD>HUB<55>Ķ˿<C4B6><CBBF><EFBFBD><EFBFBD><EFBFBD>
|
||||
if(ThisUsbDev.GpHUBPortNum > HUB_MAX_PORTS)
|
||||
{
|
||||
ThisUsbDev.GpHUBPortNum = HUB_MAX_PORTS; // <20><>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD>ṹDevOnHubPortʱ<74><CAB1>Ϊ<EFBFBD>ٶ<EFBFBD>ÿ<EFBFBD><C3BF>HUB<55><42><EFBFBD><EFBFBD><EFBFBD><EFBFBD>HUB_MAX_PORTS<54><53><EFBFBD>˿<EFBFBD>
|
||||
}
|
||||
s = CtrlSetUsbConfig(cfg); // <20><><EFBFBD><EFBFBD>USB<53>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||||
if(s == ERR_SUCCESS)
|
||||
{
|
||||
ThisUsbDev.DeviceStatus = ROOT_DEV_SUCCESS;
|
||||
ThisUsbDev.DeviceType = USB_DEV_CLASS_HUB;
|
||||
//<2F>豣<EFBFBD><E8B1A3><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>Ϣ<EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>USB<53><42><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD>ж϶˵<CFB6><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>HUB<55>¼<EFBFBD>֪ͨ,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>ò<EFBFBD>ѯ״̬<D7B4><CCAC><EFBFBD>ƴ<EFBFBD><C6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//<2F><>HUB<55><42><EFBFBD>˿<EFBFBD><CBBF>ϵ<EFBFBD>,<2C><>ѯ<EFBFBD><D1AF><EFBFBD>˿<EFBFBD>״̬,<2C><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD>ӵ<EFBFBD>HUB<55>˿<EFBFBD>,<2C><>ʼ<EFBFBD><CABC><EFBFBD>豸
|
||||
for(i = 1; i <= ThisUsbDev.GpHUBPortNum; i++) // <20><>HUB<55><42><EFBFBD>˿ڶ<CBBF><DAB6>ϵ<EFBFBD>
|
||||
{
|
||||
DevOnHubPort[i - 1].DeviceStatus = ROOT_DEV_DISCONNECT; // <20><><EFBFBD>ⲿHUB<55>˿<EFBFBD><CBBF><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8>״̬
|
||||
s = HubSetPortFeature(i, HUB_PORT_POWER);
|
||||
if(s != ERR_SUCCESS)
|
||||
{
|
||||
PRINT("Ext-HUB Port_%1d# power on error\n", (uint16_t)i); // <20>˿<EFBFBD><CBBF>ϵ<EFBFBD>ʧ<EFBFBD><CAA7>
|
||||
}
|
||||
}
|
||||
PRINT("USB-HUB Ready\n");
|
||||
SetUsbSpeed(1); // Ĭ<><C4AC>Ϊȫ<CEAA><C8AB>
|
||||
return (ERR_SUCCESS);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // <20><><EFBFBD>Խ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
s = CtrlSetUsbConfig(cfg); // <20><><EFBFBD><EFBFBD>USB<53>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||||
if(s == ERR_SUCCESS)
|
||||
{
|
||||
// <09>豣<EFBFBD><E8B1A3><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>Ϣ<EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>USB<53><42><EFBFBD><EFBFBD>
|
||||
ThisUsbDev.DeviceStatus = ROOT_DEV_SUCCESS;
|
||||
ThisUsbDev.DeviceType = DEV_TYPE_UNKNOW;
|
||||
SetUsbSpeed(1); // Ĭ<><C4AC>Ϊȫ<CEAA><C8AB>
|
||||
return (ERR_SUCCESS); /* δ֪<CEB4>豸<EFBFBD><E8B1B8>ʼ<EFBFBD><CABC><EFBFBD>ɹ<EFBFBD> */
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PRINT("InitRootDev Err = %02X\n", (uint16_t)s);
|
||||
#ifdef FOR_ROOT_UDISK_ONLY
|
||||
CHRV3DiskStatus = DISK_CONNECT;
|
||||
#else
|
||||
ThisUsbDev.DeviceStatus = ROOT_DEV_FAILED;
|
||||
#endif
|
||||
SetUsbSpeed(1); // Ĭ<><C4AC>Ϊȫ<CEAA><C8AB>
|
||||
return (s);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn InitDevOnHub
|
||||
*
|
||||
* @brief <20><>ʼ<EFBFBD><CABC>ö<EFBFBD><C3B6><EFBFBD>ⲿHUB<55><42><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>USB<53>豸
|
||||
*
|
||||
* @param HubPortIndex - ָ<><D6B8><EFBFBD>ⲿHUB
|
||||
*
|
||||
* @return <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
uint8_t InitDevOnHub(uint8_t HubPortIndex)
|
||||
{
|
||||
uint8_t i, s, cfg, dv_cls, if_cls;
|
||||
uint8_t ifc;
|
||||
PRINT("Init dev @ExtHub-port_%1d ", (uint16_t)HubPortIndex);
|
||||
if(HubPortIndex == 0)
|
||||
{
|
||||
return (ERR_USB_UNKNOWN);
|
||||
}
|
||||
SelectHubPort(HubPortIndex); // ѡ<><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>ROOT-HUB<55>˿ڵ<CBBF><DAB5>ⲿHUB<55><42>ָ<EFBFBD><D6B8><EFBFBD>˿<EFBFBD>,ѡ<><D1A1><EFBFBD>ٶ<EFBFBD>
|
||||
PRINT("GetDevDescr: ");
|
||||
s = CtrlGetDeviceDescr(); // <20><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if(s != ERR_SUCCESS)
|
||||
{
|
||||
return (s);
|
||||
}
|
||||
DevOnHubPort[HubPortIndex - 1].DeviceVID = ((uint16_t)((PUSB_DEV_DESCR)Com_Buffer)->idVendor); //<2F><><EFBFBD><EFBFBD>VID PID<49><44>Ϣ
|
||||
DevOnHubPort[HubPortIndex - 1].DevicePID = ((uint16_t)((PUSB_DEV_DESCR)Com_Buffer)->idProduct);
|
||||
|
||||
dv_cls = ((PUSB_DEV_DESCR)Com_Buffer)->bDeviceClass; // <20>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
cfg = (1 << 4) + HubPortIndex; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>USB<53><42>ַ,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD>ص<EFBFBD>
|
||||
s = CtrlSetUsbAddress(cfg); // <20><><EFBFBD><EFBFBD>USB<53>豸<EFBFBD><E8B1B8>ַ
|
||||
if(s != ERR_SUCCESS)
|
||||
{
|
||||
return (s);
|
||||
}
|
||||
DevOnHubPort[HubPortIndex - 1].DeviceAddress = cfg; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>USB<53><42>ַ
|
||||
PRINT("GetCfgDescr: ");
|
||||
s = CtrlGetConfigDescr(); // <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if(s != ERR_SUCCESS)
|
||||
{
|
||||
return (s);
|
||||
}
|
||||
cfg = ((PUSB_CFG_DESCR)Com_Buffer)->bConfigurationValue;
|
||||
for(i = 0; i < ((PUSB_CFG_DESCR)Com_Buffer)->wTotalLength; i++)
|
||||
{
|
||||
PRINT("x%02X ", (uint16_t)(Com_Buffer[i]));
|
||||
}
|
||||
PRINT("\n");
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><>ȡ<EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>ַ/<2F><><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>С<EFBFBD><D0A1>,<2C><><EFBFBD>±<EFBFBD><C2B1><EFBFBD>endp_addr<64><72>endp_size<7A><65> */
|
||||
if_cls = ((PXUSB_CFG_DESCR_LONG)Com_Buffer)->itf_descr.bInterfaceClass; // <20>ӿ<EFBFBD><D3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if(dv_cls == 0x00 && if_cls == USB_DEV_CLASS_STORAGE) // <20><>USB<53>洢<EFBFBD><E6B4A2><EFBFBD>豸,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD>U<EFBFBD><55>
|
||||
{
|
||||
AnalyzeBulkEndp(Com_Buffer, HubPortIndex);
|
||||
for(i = 0; i != 4; i++)
|
||||
{
|
||||
PRINT("%02x ", (uint16_t)DevOnHubPort[HubPortIndex - 1].GpVar[i]);
|
||||
}
|
||||
PRINT("\n");
|
||||
s = CtrlSetUsbConfig(cfg); // <20><><EFBFBD><EFBFBD>USB<53>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||||
if(s == ERR_SUCCESS)
|
||||
{
|
||||
DevOnHubPort[HubPortIndex - 1].DeviceStatus = ROOT_DEV_SUCCESS;
|
||||
DevOnHubPort[HubPortIndex - 1].DeviceType = USB_DEV_CLASS_STORAGE;
|
||||
PRINT("USB-Disk Ready\n");
|
||||
SetUsbSpeed(1); // Ĭ<><C4AC>Ϊȫ<CEAA><C8AB>
|
||||
return (ERR_SUCCESS);
|
||||
}
|
||||
}
|
||||
else if((dv_cls == 0x00) && (if_cls == USB_DEV_CLASS_HID) && (((PXUSB_CFG_DESCR_LONG)Com_Buffer)->itf_descr.bInterfaceSubClass <= 0x01)) // <20><>HID<49><44><EFBFBD>豸,<2C><><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
{
|
||||
ifc = ((PXUSB_CFG_DESCR_LONG)Com_Buffer)->cfg_descr.bNumInterfaces;
|
||||
s = AnalyzeHidIntEndp(Com_Buffer, HubPortIndex); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>з<EFBFBD><D0B7><EFBFBD><EFBFBD><EFBFBD>HID<49>ж϶˵<CFB6><CBB5>ĵ<EFBFBD>ַ
|
||||
PRINT("AnalyzeHidIntEndp %02x\n", (uint16_t)s);
|
||||
if_cls = ((PXUSB_CFG_DESCR_LONG)Com_Buffer)->itf_descr.bInterfaceProtocol;
|
||||
s = CtrlSetUsbConfig(cfg); // <20><><EFBFBD><EFBFBD>USB<53>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||||
if(s == ERR_SUCCESS)
|
||||
{
|
||||
for(dv_cls = 0; dv_cls < ifc; dv_cls++)
|
||||
{
|
||||
s = CtrlGetHIDDeviceReport(dv_cls); //<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if(s == ERR_SUCCESS)
|
||||
{
|
||||
for(i = 0; i < 64; i++)
|
||||
{
|
||||
PRINT("x%02X ", (uint16_t)(Com_Buffer[i]));
|
||||
}
|
||||
PRINT("\n");
|
||||
}
|
||||
}
|
||||
//<2F>豣<EFBFBD><E8B1A3><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>Ϣ<EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>USB<53><42><EFBFBD><EFBFBD>
|
||||
DevOnHubPort[HubPortIndex - 1].DeviceStatus = ROOT_DEV_SUCCESS;
|
||||
if(if_cls == 1)
|
||||
{
|
||||
DevOnHubPort[HubPortIndex - 1].DeviceType = DEV_TYPE_KEYBOARD;
|
||||
//<2F><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>,<2C><><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>ָʾ<D6B8><CABE>LED<45><44>
|
||||
if(ifc > 1)
|
||||
{
|
||||
PRINT("USB_DEV_CLASS_HID Ready\n");
|
||||
DevOnHubPort[HubPortIndex - 1].DeviceType = USB_DEV_CLASS_HID; //<2F><><EFBFBD><EFBFBD>HID<49>豸
|
||||
}
|
||||
PRINT("USB-Keyboard Ready\n");
|
||||
SetUsbSpeed(1); // Ĭ<><C4AC>Ϊȫ<CEAA><C8AB>
|
||||
|
||||
return (ERR_SUCCESS);
|
||||
}
|
||||
else if(if_cls == 2)
|
||||
{
|
||||
DevOnHubPort[HubPortIndex - 1].DeviceType = DEV_TYPE_MOUSE;
|
||||
//Ϊ<><CEAA><EFBFBD>Ժ<EFBFBD><D4BA><EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>״̬,Ӧ<>÷<EFBFBD><C3B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,ȡ<><C8A1><EFBFBD>ж϶˿ڵĵ<DAB5>ַ,<2C><><EFBFBD>ȵ<EFBFBD><C8B5><EFBFBD>Ϣ
|
||||
if(ifc > 1)
|
||||
{
|
||||
PRINT("USB_DEV_CLASS_HID Ready\n");
|
||||
DevOnHubPort[HubPortIndex - 1].DeviceType = USB_DEV_CLASS_HID; //<2F><><EFBFBD><EFBFBD>HID<49>豸
|
||||
}
|
||||
PRINT("USB-Mouse Ready\n");
|
||||
SetUsbSpeed(1); // Ĭ<><C4AC>Ϊȫ<CEAA><C8AB>
|
||||
|
||||
return (ERR_SUCCESS);
|
||||
}
|
||||
s = ERR_USB_UNSUPPORT;
|
||||
}
|
||||
}
|
||||
else if(dv_cls == USB_DEV_CLASS_HUB) // <20><>HUB<55><42><EFBFBD>豸,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
{
|
||||
DevOnHubPort[HubPortIndex - 1].DeviceType = USB_DEV_CLASS_HUB;
|
||||
PRINT("This program don't support Level 2 HUB\n"); // <20><>Ҫ֧<D2AA>ֶ༶HUB<55><42><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ο<EFBFBD><CEBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>չ
|
||||
s = HubClearPortFeature(i, HUB_PORT_ENABLE); // <20><>ֹHUB<55>˿<EFBFBD>
|
||||
if(s != ERR_SUCCESS)
|
||||
{
|
||||
return (s);
|
||||
}
|
||||
s = ERR_USB_UNSUPPORT;
|
||||
}
|
||||
else //<2F><><EFBFBD><EFBFBD><EFBFBD>豸
|
||||
{
|
||||
AnalyzeBulkEndp(Com_Buffer, HubPortIndex); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD>
|
||||
for(i = 0; i != 4; i++)
|
||||
{
|
||||
PRINT("%02x ", (uint16_t)DevOnHubPort[HubPortIndex - 1].GpVar[i]);
|
||||
}
|
||||
PRINT("\n");
|
||||
s = CtrlSetUsbConfig(cfg); // <20><><EFBFBD><EFBFBD>USB<53>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||||
if(s == ERR_SUCCESS)
|
||||
{
|
||||
//<2F>豣<EFBFBD><E8B1A3><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>Ϣ<EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>USB<53><42><EFBFBD><EFBFBD>
|
||||
DevOnHubPort[HubPortIndex - 1].DeviceStatus = ROOT_DEV_SUCCESS;
|
||||
DevOnHubPort[HubPortIndex - 1].DeviceType = dv_cls ? dv_cls : if_cls;
|
||||
SetUsbSpeed(1); // Ĭ<><C4AC>Ϊȫ<CEAA><C8AB>
|
||||
return (ERR_SUCCESS); //δ֪<CEB4>豸<EFBFBD><E8B1B8>ʼ<EFBFBD><CABC><EFBFBD>ɹ<EFBFBD>
|
||||
}
|
||||
}
|
||||
PRINT("InitDevOnHub Err = %02X\n", (uint16_t)s);
|
||||
DevOnHubPort[HubPortIndex - 1].DeviceStatus = ROOT_DEV_FAILED;
|
||||
SetUsbSpeed(1); // Ĭ<><C4AC>Ϊȫ<CEAA><C8AB>
|
||||
return (s);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn EnumHubPort
|
||||
*
|
||||
* @brief ö<><C3B6>ָ<EFBFBD><D6B8>ROOT-HUB<55>˿<EFBFBD><CBBF>ϵ<EFBFBD><CFB5>ⲿHUB<55><42><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD><EFBFBD>˿<EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӻ<EFBFBD><D3BB>Ƴ<EFBFBD><C6B3>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>USB<53>豸
|
||||
*
|
||||
* @param RootHubIndex - ROOT_HUB0<42><30>ROOT_HUB1
|
||||
*
|
||||
* @return <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
uint8_t EnumHubPort()
|
||||
{
|
||||
uint8_t i, s;
|
||||
|
||||
for(i = 1; i <= ThisUsbDev.GpHUBPortNum; i++) // <20><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ˿<C4B6><CBBF>Ƿ<EFBFBD><C7B7>б仯
|
||||
{
|
||||
SelectHubPort(0); // ѡ<><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>ROOT-HUB<55>˿<EFBFBD>,<2C><><EFBFBD>õ<EFBFBD>ǰUSB<53>ٶ<EFBFBD><D9B6>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8>USB<53><42>ַ
|
||||
s = HubGetPortStatus(i); // <20><>ȡ<EFBFBD>˿<EFBFBD>״̬
|
||||
if(s != ERR_SUCCESS)
|
||||
{
|
||||
return (s); // <20><><EFBFBD><EFBFBD><EFBFBD>Ǹ<EFBFBD>HUB<55>Ͽ<EFBFBD><CFBF><EFBFBD>
|
||||
}
|
||||
if(((Com_Buffer[0] & (1 << (HUB_PORT_CONNECTION & 0x07))) && (Com_Buffer[2] & (1 << (HUB_C_PORT_CONNECTION & 0x07)))) || (Com_Buffer[2] == 0x10))
|
||||
{ // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||||
DevOnHubPort[i - 1].DeviceStatus = ROOT_DEV_CONNECTED; // <20><><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||||
DevOnHubPort[i - 1].DeviceAddress = 0x00;
|
||||
s = HubGetPortStatus(i); // <20><>ȡ<EFBFBD>˿<EFBFBD>״̬
|
||||
if(s != ERR_SUCCESS)
|
||||
{
|
||||
return (s); // <20><><EFBFBD><EFBFBD><EFBFBD>Ǹ<EFBFBD>HUB<55>Ͽ<EFBFBD><CFBF><EFBFBD>
|
||||
}
|
||||
DevOnHubPort[i - 1].DeviceSpeed = Com_Buffer[1] & (1 << (HUB_PORT_LOW_SPEED & 0x07)) ? 0 : 1; // <20><><EFBFBD>ٻ<EFBFBD><D9BB><EFBFBD>ȫ<EFBFBD><C8AB>
|
||||
if(DevOnHubPort[i - 1].DeviceSpeed)
|
||||
{
|
||||
PRINT("Found full speed device on port %1d\n", (uint16_t)i);
|
||||
}
|
||||
else
|
||||
{
|
||||
PRINT("Found low speed device on port %1d\n", (uint16_t)i);
|
||||
}
|
||||
mDelaymS(200); // <20>ȴ<EFBFBD><C8B4>豸<EFBFBD>ϵ<EFBFBD><CFB5>ȶ<EFBFBD>
|
||||
s = HubSetPortFeature(i, HUB_PORT_RESET); // <20><><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD>ӵĶ˿ڸ<CBBF>λ
|
||||
if(s != ERR_SUCCESS)
|
||||
{
|
||||
return (s); // <20><><EFBFBD><EFBFBD><EFBFBD>Ǹ<EFBFBD>HUB<55>Ͽ<EFBFBD><CFBF><EFBFBD>
|
||||
}
|
||||
PRINT("Reset port and then wait in\n");
|
||||
do // <20><>ѯ<EFBFBD><D1AF>λ<EFBFBD>˿<EFBFBD>,ֱ<><D6B1><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD>ɺ<EFBFBD><C9BA><EFBFBD>״̬<D7B4><CCAC>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
||||
{
|
||||
mDelaymS(1);
|
||||
s = HubGetPortStatus(i);
|
||||
if(s != ERR_SUCCESS)
|
||||
{
|
||||
return (s); // <20><><EFBFBD><EFBFBD><EFBFBD>Ǹ<EFBFBD>HUB<55>Ͽ<EFBFBD><CFBF><EFBFBD>
|
||||
}
|
||||
} while(Com_Buffer[0] & (1 << (HUB_PORT_RESET & 0x07))); // <20>˿<EFBFBD><CBBF><EFBFBD><EFBFBD>ڸ<EFBFBD>λ<EFBFBD><CEBB><EFBFBD>ȴ<EFBFBD>
|
||||
mDelaymS(100);
|
||||
s = HubClearPortFeature(i, HUB_C_PORT_RESET); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD>ɱ<EFBFBD>־
|
||||
// s = HubSetPortFeature( i, HUB_PORT_ENABLE ); // <20><><EFBFBD><EFBFBD>HUB<55>˿<EFBFBD>
|
||||
s = HubClearPortFeature(i, HUB_C_PORT_CONNECTION); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӻ<EFBFBD><D3BB>Ƴ<EFBFBD><C6B3>仯<EFBFBD><E4BBAF>־
|
||||
if(s != ERR_SUCCESS)
|
||||
{
|
||||
return (s);
|
||||
}
|
||||
s = HubGetPortStatus(i); // <20>ٶ<EFBFBD>ȡ״̬,<2C><><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
||||
if(s != ERR_SUCCESS)
|
||||
{
|
||||
return (s);
|
||||
}
|
||||
if((Com_Buffer[0] & (1 << (HUB_PORT_CONNECTION & 0x07))) == 0)
|
||||
{
|
||||
DevOnHubPort[i - 1].DeviceStatus = ROOT_DEV_DISCONNECT; // <20>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
s = InitDevOnHub(i); // <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>USB<53>豸
|
||||
if(s != ERR_SUCCESS)
|
||||
{
|
||||
return (s);
|
||||
}
|
||||
SetUsbSpeed(1); // Ĭ<><C4AC>Ϊȫ<CEAA><C8AB>
|
||||
}
|
||||
else if(Com_Buffer[2] & (1 << (HUB_C_PORT_ENABLE & 0x07))) // <20>豸<EFBFBD><E8B1B8><EFBFBD>ӳ<EFBFBD><D3B3><EFBFBD>
|
||||
{
|
||||
HubClearPortFeature(i, HUB_C_PORT_ENABLE); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӵ<EFBFBD><D3B4><EFBFBD><EFBFBD><EFBFBD>־
|
||||
PRINT("Device on port error\n");
|
||||
s = HubSetPortFeature(i, HUB_PORT_RESET); // <20><><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD>ӵĶ˿ڸ<CBBF>λ
|
||||
if(s != ERR_SUCCESS)
|
||||
return (s); // <20><><EFBFBD><EFBFBD><EFBFBD>Ǹ<EFBFBD>HUB<55>Ͽ<EFBFBD><CFBF><EFBFBD>
|
||||
do // <20><>ѯ<EFBFBD><D1AF>λ<EFBFBD>˿<EFBFBD>,ֱ<><D6B1><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD>ɺ<EFBFBD><C9BA><EFBFBD>״̬<D7B4><CCAC>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
||||
{
|
||||
mDelaymS(1);
|
||||
s = HubGetPortStatus(i);
|
||||
if(s != ERR_SUCCESS)
|
||||
return (s); // <20><><EFBFBD><EFBFBD><EFBFBD>Ǹ<EFBFBD>HUB<55>Ͽ<EFBFBD><CFBF><EFBFBD>
|
||||
} while(Com_Buffer[0] & (1 << (HUB_PORT_RESET & 0x07))); // <20>˿<EFBFBD><CBBF><EFBFBD><EFBFBD>ڸ<EFBFBD>λ<EFBFBD><CEBB><EFBFBD>ȴ<EFBFBD>
|
||||
}
|
||||
else if((Com_Buffer[0] & (1 << (HUB_PORT_CONNECTION & 0x07))) == 0) // <20>豸<EFBFBD>Ѿ<EFBFBD><D1BE>Ͽ<EFBFBD>
|
||||
{
|
||||
if(DevOnHubPort[i - 1].DeviceStatus >= ROOT_DEV_CONNECTED)
|
||||
{
|
||||
PRINT("Device on port %1d removed\n", (uint16_t)i);
|
||||
}
|
||||
DevOnHubPort[i - 1].DeviceStatus = ROOT_DEV_DISCONNECT; // <20><><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||||
if(Com_Buffer[2] & (1 << (HUB_C_PORT_CONNECTION & 0x07)))
|
||||
{
|
||||
HubClearPortFeature(i, HUB_C_PORT_CONNECTION); // <20><><EFBFBD><EFBFBD><EFBFBD>Ƴ<EFBFBD><C6B3>仯<EFBFBD><E4BBAF>־
|
||||
}
|
||||
}
|
||||
}
|
||||
return (ERR_SUCCESS); // <20><><EFBFBD>ز<EFBFBD><D8B2><EFBFBD><EFBFBD>ɹ<EFBFBD>
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn EnumAllHubPort
|
||||
*
|
||||
* @brief ö<><C3B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ROOT-HUB<55>˿<EFBFBD><CBBF><EFBFBD><EFBFBD>ⲿHUB<55><42><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>USB<53>豸
|
||||
*
|
||||
* @return <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
uint8_t EnumAllHubPort(void)
|
||||
{
|
||||
uint8_t s;
|
||||
|
||||
if((ThisUsbDev.DeviceStatus >= ROOT_DEV_SUCCESS) && (ThisUsbDev.DeviceType == USB_DEV_CLASS_HUB)) // HUBö<42>ٳɹ<D9B3>
|
||||
{
|
||||
SelectHubPort(0); // ѡ<><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>ROOT-HUB<55>˿<EFBFBD>,<2C><><EFBFBD>õ<EFBFBD>ǰUSB<53>ٶ<EFBFBD><D9B6>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8>USB<53><42>ַ
|
||||
s = EnumHubPort(); // ö<><C3B6>ָ<EFBFBD><D6B8>ROOT-HUB<55>˿<EFBFBD><CBBF>ϵ<EFBFBD><CFB5>ⲿHUB<55><42><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD><EFBFBD>˿<EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӻ<EFBFBD><D3BB>Ƴ<EFBFBD><C6B3>¼<EFBFBD>
|
||||
if(s != ERR_SUCCESS) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>HUB<55>Ͽ<EFBFBD><CFBF><EFBFBD>
|
||||
{
|
||||
PRINT("EnumAllHubPort err = %02X\n", (uint16_t)s);
|
||||
}
|
||||
SetUsbSpeed(1); // Ĭ<><C4AC>Ϊȫ<CEAA><C8AB>
|
||||
}
|
||||
return (ERR_SUCCESS);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SearchTypeDevice
|
||||
*
|
||||
* @brief <20><>ROOT-HUB<55>Լ<EFBFBD><D4BC>ⲿHUB<55><42><EFBFBD>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><CDB5>豸<EFBFBD><E8B1B8><EFBFBD>ڵĶ˿ں<CBBF>,<2C><><EFBFBD><EFBFBD><EFBFBD>˿ں<CBBF>Ϊ0xFFFF<46><46>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||
* <20><>ȻҲ<C8BB><D2B2><EFBFBD>Ը<EFBFBD><D4B8><EFBFBD>USB<53>ij<EFBFBD><C4B3><EFBFBD>VID<49><44>ƷPID<49><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>¼<EFBFBD><C2BC><EFBFBD>豸<EFBFBD><E8B1B8>VID<49><44>PID),<2C>Լ<EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param type - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @return <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>8λΪROOT-HUB<55>˿ں<CBBF>,<2C><>8λΪ<CEBB>ⲿHUB<55>Ķ˿ں<CBBF>,<2C><>8λΪ0<CEAA><30><EFBFBD>豸ֱ<E8B1B8><D6B1><EFBFBD><EFBFBD>ROOT-HUB<55>˿<EFBFBD><CBBF><EFBFBD>
|
||||
*/
|
||||
uint16_t SearchTypeDevice(uint8_t type)
|
||||
{
|
||||
uint8_t RootHubIndex; //CH554ֻ<34><D6BB>һ<EFBFBD><D2BB>USB<53><42>,RootHubIndex = 0,ֻ<>迴<EFBFBD><E8BFB4><EFBFBD><EFBFBD>ֵ<EFBFBD>ĵͰ<C4B5>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
|
||||
uint8_t HubPortIndex;
|
||||
|
||||
RootHubIndex = 0;
|
||||
if((ThisUsbDev.DeviceType == USB_DEV_CLASS_HUB) && (ThisUsbDev.DeviceStatus >= ROOT_DEV_SUCCESS)) // <20>ⲿ<EFBFBD><E2B2BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>HUB<55><42>ö<EFBFBD>ٳɹ<D9B3>
|
||||
{
|
||||
for(HubPortIndex = 1; HubPortIndex <= ThisUsbDev.GpHUBPortNum; HubPortIndex++) // <20><><EFBFBD><EFBFBD><EFBFBD>ⲿHUB<55>ĸ<EFBFBD><C4B8><EFBFBD><EFBFBD>˿<EFBFBD>
|
||||
{
|
||||
if(DevOnHubPort[HubPortIndex - 1].DeviceType == type && DevOnHubPort[HubPortIndex - 1].DeviceStatus >= ROOT_DEV_SUCCESS)
|
||||
{
|
||||
return (((uint16_t)RootHubIndex << 8) | HubPortIndex); // <20><><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD>ö<EFBFBD>ٳɹ<D9B3>
|
||||
}
|
||||
}
|
||||
}
|
||||
if((ThisUsbDev.DeviceType == type) && (ThisUsbDev.DeviceStatus >= ROOT_DEV_SUCCESS))
|
||||
{
|
||||
return ((uint16_t)RootHubIndex << 8); // <20><><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD>ö<EFBFBD>ٳɹ<D9B3>,<2C><>ROOT-HUB<55>˿<EFBFBD><CBBF><EFBFBD>
|
||||
}
|
||||
|
||||
return (0xFFFF);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SETorOFFNumLock
|
||||
*
|
||||
* @brief NumLock<63>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD>ж<EFBFBD>
|
||||
*
|
||||
* @param buf - <20><><EFBFBD>Ƽ<EFBFBD>ֵ
|
||||
*
|
||||
* @return <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
uint8_t SETorOFFNumLock(uint8_t *buf)
|
||||
{
|
||||
uint8_t tmp[] = {0x21, 0x09, 0x00, 0x02, 0x00, 0x00, 0x01, 0x00};
|
||||
uint8_t len, s;
|
||||
if((buf[2] == 0x53) & ((buf[0] | buf[1] | buf[3] | buf[4] | buf[5] | buf[6] | buf[7]) == 0))
|
||||
{
|
||||
for(s = 0; s != sizeof(tmp); s++)
|
||||
{
|
||||
((uint8_t *)pSetupReq)[s] = tmp[s];
|
||||
}
|
||||
s = HostCtrlTransfer(Com_Buffer, &len); // ִ<>п<EFBFBD><D0BF>ƴ<EFBFBD><C6B4><EFBFBD>
|
||||
if(s != ERR_SUCCESS)
|
||||
{
|
||||
return (s);
|
||||
}
|
||||
}
|
||||
return (ERR_SUCCESS);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn CtrlGetHIDDeviceReport
|
||||
*
|
||||
* @brief <20><>ȡHID<49>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>TxBuffer<65><72>
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
uint8_t CtrlGetHIDDeviceReport(uint8_t infc)
|
||||
{
|
||||
uint8_t s;
|
||||
uint8_t len;
|
||||
|
||||
CopySetupReqPkg(SetupSetHIDIdle);
|
||||
pSetupReq->wIndex = infc;
|
||||
s = HostCtrlTransfer(Com_Buffer, &len); // ִ<>п<EFBFBD><D0BF>ƴ<EFBFBD><C6B4><EFBFBD>
|
||||
if(s != ERR_SUCCESS)
|
||||
{
|
||||
return (s);
|
||||
}
|
||||
|
||||
CopySetupReqPkg(SetupGetHIDDevReport);
|
||||
pSetupReq->wIndex = infc;
|
||||
s = HostCtrlTransfer(Com_Buffer, &len); // ִ<>п<EFBFBD><D0BF>ƴ<EFBFBD><C6B4><EFBFBD>
|
||||
if(s != ERR_SUCCESS)
|
||||
{
|
||||
return (s);
|
||||
}
|
||||
|
||||
return (ERR_SUCCESS);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn CtrlGetHubDescr
|
||||
*
|
||||
* @brief <20><>ȡHUB<55><42><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Com_Buffer<65><72>
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
uint8_t CtrlGetHubDescr(void)
|
||||
{
|
||||
uint8_t s;
|
||||
uint8_t len;
|
||||
|
||||
CopySetupReqPkg(SetupGetHubDescr);
|
||||
s = HostCtrlTransfer(Com_Buffer, &len); // ִ<>п<EFBFBD><D0BF>ƴ<EFBFBD><C6B4><EFBFBD>
|
||||
if(s != ERR_SUCCESS)
|
||||
{
|
||||
return (s);
|
||||
}
|
||||
if(len < ((PUSB_SETUP_REQ)SetupGetHubDescr)->wLength)
|
||||
{
|
||||
return (ERR_USB_BUF_OVER); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD><C8B4><EFBFBD>
|
||||
}
|
||||
// if ( len < 4 ) return( ERR_USB_BUF_OVER ); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD><C8B4><EFBFBD>
|
||||
return (ERR_SUCCESS);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn HubGetPortStatus
|
||||
*
|
||||
* @brief <20><>ѯHUB<55>˿<EFBFBD>״̬,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Com_Buffer<65><72>
|
||||
*
|
||||
* @param HubPortIndex - <20>˿ں<CBBF>
|
||||
*
|
||||
* @return <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
uint8_t HubGetPortStatus(uint8_t HubPortIndex)
|
||||
{
|
||||
uint8_t s;
|
||||
uint8_t len;
|
||||
|
||||
pSetupReq->bRequestType = HUB_GET_PORT_STATUS;
|
||||
pSetupReq->bRequest = HUB_GET_STATUS;
|
||||
pSetupReq->wValue = 0x0000;
|
||||
pSetupReq->wIndex = 0x0000 | HubPortIndex;
|
||||
pSetupReq->wLength = 0x0004;
|
||||
s = HostCtrlTransfer(Com_Buffer, &len); // ִ<>п<EFBFBD><D0BF>ƴ<EFBFBD><C6B4><EFBFBD>
|
||||
if(s != ERR_SUCCESS)
|
||||
{
|
||||
return (s);
|
||||
}
|
||||
if(len < 4)
|
||||
{
|
||||
return (ERR_USB_BUF_OVER); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD><C8B4><EFBFBD>
|
||||
}
|
||||
return (ERR_SUCCESS);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn HubSetPortFeature
|
||||
*
|
||||
* @brief <20><><EFBFBD><EFBFBD>HUB<55>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param HubPortIndex - <20>˿ں<CBBF>
|
||||
* @param FeatureSelt - <20>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @return <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
uint8_t HubSetPortFeature(uint8_t HubPortIndex, uint8_t FeatureSelt)
|
||||
{
|
||||
pSetupReq->bRequestType = HUB_SET_PORT_FEATURE;
|
||||
pSetupReq->bRequest = HUB_SET_FEATURE;
|
||||
pSetupReq->wValue = 0x0000 | FeatureSelt;
|
||||
pSetupReq->wIndex = 0x0000 | HubPortIndex;
|
||||
pSetupReq->wLength = 0x0000;
|
||||
return (HostCtrlTransfer(NULL, NULL)); // ִ<>п<EFBFBD><D0BF>ƴ<EFBFBD><C6B4><EFBFBD>
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn HubClearPortFeature
|
||||
*
|
||||
* @brief <20><><EFBFBD><EFBFBD>HUB<55>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param HubPortIndex - <20>˿ں<CBBF>
|
||||
* @param FeatureSelt - <20>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @return <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
uint8_t HubClearPortFeature(uint8_t HubPortIndex, uint8_t FeatureSelt)
|
||||
{
|
||||
pSetupReq->bRequestType = HUB_CLEAR_PORT_FEATURE;
|
||||
pSetupReq->bRequest = HUB_CLEAR_FEATURE;
|
||||
pSetupReq->wValue = 0x0000 | FeatureSelt;
|
||||
pSetupReq->wIndex = 0x0000 | HubPortIndex;
|
||||
pSetupReq->wLength = 0x0000;
|
||||
return (HostCtrlTransfer(NULL, NULL)); // ִ<>п<EFBFBD><D0BF>ƴ<EFBFBD><C6B4><EFBFBD>
|
||||
}
|
||||
1600
BLV_RF_W13_V04_20260114/StdPeriphDriver/inc/CH572SFR.h
Normal file
1600
BLV_RF_W13_V04_20260114/StdPeriphDriver/inc/CH572SFR.h
Normal file
File diff suppressed because it is too large
Load Diff
243
BLV_RF_W13_V04_20260114/StdPeriphDriver/inc/CH57x_clk.h
Normal file
243
BLV_RF_W13_V04_20260114/StdPeriphDriver/inc/CH57x_clk.h
Normal file
@@ -0,0 +1,243 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH57x_clk.h
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2021/11/17
|
||||
* Description : head file(ch572/ch570)
|
||||
*********************************************************************************
|
||||
* 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 __CH57x_CLK_H__
|
||||
#define __CH57x_CLK_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief ϵͳ<CFB5><CDB3>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD>
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
CLK_SOURCE_LSI = 0xC0,
|
||||
|
||||
CLK_SOURCE_HSE_16MHz = (0x02),
|
||||
CLK_SOURCE_HSE_8MHz = (0x04),
|
||||
CLK_SOURCE_HSE_6_4MHz = (0x05),
|
||||
CLK_SOURCE_HSE_4MHz = (0x08),
|
||||
CLK_SOURCE_HSE_2MHz = (0x10),
|
||||
CLK_SOURCE_HSE_1MHz = (0x0),
|
||||
|
||||
CLK_SOURCE_HSE_PLL_100MHz = (0x40 | 6),
|
||||
CLK_SOURCE_HSE_PLL_75MHz = (0x40 | 8),
|
||||
CLK_SOURCE_HSE_PLL_60MHz = (0x40 | 10),
|
||||
CLK_SOURCE_HSE_PLL_50MHz = (0x40 | 12),
|
||||
CLK_SOURCE_HSE_PLL_40MHz = (0x40 | 15),
|
||||
CLK_SOURCE_HSE_PLL_30MHz = (0x40 | 20),
|
||||
CLK_SOURCE_HSE_PLL_25MHz = (0x40 | 24),
|
||||
CLK_SOURCE_HSE_PLL_24MHz = (0x40 | 25),
|
||||
CLK_SOURCE_HSE_PLL_20MHz = (0x40 | 30),
|
||||
|
||||
} SYS_CLKTypeDef;
|
||||
|
||||
/**
|
||||
* @brief 32M<32><4D><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HSE_RCur_75 = 0,
|
||||
HSE_RCur_100,
|
||||
HSE_RCur_125,
|
||||
HSE_RCur_150
|
||||
|
||||
} HSECurrentTypeDef;
|
||||
|
||||
/**
|
||||
* @brief 32M<32><4D><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD>ݵ<EFBFBD>λ
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HSECap_6p = 0,
|
||||
HSECap_8p,
|
||||
HSECap_10p,
|
||||
HSECap_12p,
|
||||
HSECap_14p,
|
||||
HSECap_16p,
|
||||
HSECap_18p,
|
||||
HSECap_20p
|
||||
|
||||
} HSECapTypeDef;
|
||||
|
||||
#define RTC_MAX_COUNT 0xA8C00000
|
||||
|
||||
#define MAX_DAY 0x00004000
|
||||
#define MAX_2_SEC 0x0000A8C0
|
||||
//#define MAX_SEC 0x545FFFFF
|
||||
|
||||
#define BEGYEAR 2020
|
||||
#define IsLeapYear(yr) (!((yr) % 400) || (((yr) % 100) && !((yr) % 4)))
|
||||
#define YearLength(yr) (IsLeapYear(yr) ? 366 : 365)
|
||||
#define monthLength(lpyr, mon) (((mon) == 1) ? (28 + (lpyr)) : (((mon) > 6) ? (((mon) & 1) ? 31 : 30) : (((mon) & 1) ? 30 : 31)))
|
||||
|
||||
/**
|
||||
* @brief the total number of cycles captured by the oscillator define
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
Count_1 = 0,
|
||||
Count_2,
|
||||
Count_4,
|
||||
Count_32,
|
||||
Count_64,
|
||||
Count_128,
|
||||
Count_1024,
|
||||
Count_2047,
|
||||
} RTC_OSCCntTypeDef;
|
||||
|
||||
/**
|
||||
* @brief rtc timer mode period define
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
Period_4096 = 0,
|
||||
Period_8192,
|
||||
Period_16384,
|
||||
Period_32768,
|
||||
Period_65536,
|
||||
Period_131072,
|
||||
Period_262144,
|
||||
Period_524288,
|
||||
} RTC_TMRCycTypeDef;
|
||||
|
||||
/**
|
||||
* @brief rtc interrupt event define
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
RTC_TRIG_EVENT = 0, // RTC <20><><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
||||
RTC_TMR_EVENT, // RTC <20><><EFBFBD>ڶ<EFBFBD>ʱ<EFBFBD>¼<EFBFBD>
|
||||
|
||||
} RTC_EVENTTypeDef;
|
||||
|
||||
/**
|
||||
* @brief rtc interrupt mode define
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
RTC_TRIG_MODE = 0, // RTC <20><><EFBFBD><EFBFBD>ģʽ
|
||||
RTC_TMR_MODE, // RTC <20><><EFBFBD>ڶ<EFBFBD>ʱģʽ
|
||||
|
||||
} RTC_MODETypeDef;
|
||||
|
||||
/**
|
||||
* @brief HSE<53><45><EFBFBD><EFBFBD> ƫ<>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param c - 75%,100%,125%,150%
|
||||
*/
|
||||
void HSECFG_Current(HSECurrentTypeDef c);
|
||||
|
||||
/**
|
||||
* @brief HSE<53><45><EFBFBD><EFBFBD> <20><><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param c - refer to HSECapTypeDef
|
||||
*/
|
||||
void HSECFG_Capacitance(HSECapTypeDef c);
|
||||
|
||||
/**
|
||||
* @brief <20><>ʼ<EFBFBD><CABC> RTCʱ<43><CAB1>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Խ<EFBFBD><D4BD>,<2C><>ʼ<EFBFBD><CABC>ʱ<EFBFBD><CAB1>Խ<EFBFBD><D4BD>,ʱ<>Ӿ<EFBFBD><D3BE><EFBFBD>Խ<EFBFBD><D4BD>
|
||||
*
|
||||
* @param cnt - the total number of cycles captured by the oscillator
|
||||
*
|
||||
* @return RTCʱ<43><CAB1>, 24~42KHz
|
||||
*/
|
||||
uint32_t RTC_InitClock(RTC_OSCCntTypeDef cnt);
|
||||
|
||||
/**
|
||||
* @brief RTCʱ<43>ӳ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ǰʱ<C7B0><CAB1>
|
||||
*
|
||||
* @param y - <20><><EFBFBD><EFBFBD><EFBFBD>꣬MAX_Y = BEGYEAR + 44
|
||||
* @param mon - <20><><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>MAX_MON = 12
|
||||
* @param d - <20><><EFBFBD><EFBFBD><EFBFBD>գ<EFBFBD>MAX_D = 31
|
||||
* @param h - <20><><EFBFBD><EFBFBD>Сʱ<D0A1><CAB1>MAX_H = 23
|
||||
* @param m - <20><><EFBFBD>÷<EFBFBD><C3B7>ӣ<EFBFBD>MAX_M = 59
|
||||
* @param s - <20><><EFBFBD><EFBFBD><EFBFBD>룬MAX_S = 59
|
||||
*/
|
||||
void RTC_InitTime(uint16_t y, uint16_t mon, uint16_t d, uint16_t h, uint16_t m, uint16_t s);
|
||||
|
||||
/**
|
||||
* @brief <20><>ȡ<EFBFBD><C8A1>ǰʱ<C7B0><CAB1>
|
||||
*
|
||||
* @param py - <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>꣬MAX_Y = BEGYEAR + 44
|
||||
* @param pmon - <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>MAX_MON = 12
|
||||
* @param pd - <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>գ<EFBFBD>MAX_D = 31
|
||||
* @param ph - <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>Сʱ<D0A1><CAB1>MAX_H = 23
|
||||
* @param pm - <20><>ȡ<EFBFBD><C8A1><EFBFBD>ķ<EFBFBD><C4B7>ӣ<EFBFBD>MAX_M = 59
|
||||
* @param ps - <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>룬MAX_S = 59
|
||||
*/
|
||||
void RTC_GetTime(uint16_t *py, uint16_t *pmon, uint16_t *pd, uint16_t *ph, uint16_t *pm, uint16_t *ps);
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD>LSIʱ<49>ӣ<EFBFBD><D3A3><EFBFBD><EFBFBD>õ<EFBFBD>ǰRTC <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param cyc - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD><DABC><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>MAX_CYC = 0xA8BFFFFF = 2831155199
|
||||
*/
|
||||
void RTC_SetCycleLSI(uint32_t cyc);
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD>LSIʱ<49>ӣ<EFBFBD><D3A3><EFBFBD>ȡ<EFBFBD><C8A1>ǰRTC <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @return <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>MAX_CYC = 0xA8BFFFFF = 2831155199
|
||||
*/
|
||||
uint32_t RTC_GetCycleLSI(void);
|
||||
|
||||
/**
|
||||
* @brief RTC<54><43>ʱģʽ<C4A3><CABD><EFBFBD>ã<EFBFBD>ע<EFBFBD>ⶨʱ<E2B6A8><CAB1><EFBFBD>̶<EFBFBD>Ϊ32768Hz<48><7A>
|
||||
*
|
||||
* @param t - refer to RTC_TMRCycTypeDef
|
||||
*/
|
||||
void RTC_TRIGFunCfg(uint32_t cyc);
|
||||
|
||||
/**
|
||||
* @brief RTC<54><43>ʱģʽ<C4A3><CABD><EFBFBD>ã<EFBFBD>ע<EFBFBD>ⶨʱ<E2B6A8><CAB1><EFBFBD>̶<EFBFBD>Ϊ32768Hz<48><7A>
|
||||
*
|
||||
* @param t - refer to RTC_TMRCycTypeDef
|
||||
*/
|
||||
void RTC_TMRFunCfg(RTC_TMRCycTypeDef t);
|
||||
|
||||
/**
|
||||
* @brief RTC ģʽ<C4A3><CABD><EFBFBD>ܹر<DCB9>
|
||||
*
|
||||
* @param m - <20><>Ҫ<EFBFBD>رյĵ<D5B5>ǰģʽ
|
||||
*/
|
||||
void RTC_ModeFunDisable(RTC_MODETypeDef m);
|
||||
|
||||
/**
|
||||
* @brief <20><>ȡRTC<54>жϱ<D0B6>־
|
||||
*
|
||||
* @param f - refer to RTC_EVENTTypeDef
|
||||
*
|
||||
* @return <20>жϱ<D0B6>־״̬
|
||||
*/
|
||||
uint8_t RTC_GetITFlag(RTC_EVENTTypeDef f);
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD>RTC<54>жϱ<D0B6>־
|
||||
*
|
||||
* @param f - refer to RTC_EVENTTypeDef
|
||||
*/
|
||||
void RTC_ClearITFlag(RTC_EVENTTypeDef f);
|
||||
|
||||
/**
|
||||
* @brief <20><>Ƶʱ<C6B5>ӵ<EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD>
|
||||
*/
|
||||
void LClk_Cfg(FunctionalState s);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __CH57x_CLK_H__
|
||||
79
BLV_RF_W13_V04_20260114/StdPeriphDriver/inc/CH57x_cmp.h
Normal file
79
BLV_RF_W13_V04_20260114/StdPeriphDriver/inc/CH57x_cmp.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH57x_cmp.h
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2021/11/17
|
||||
* Description : head file(ch572/ch570)
|
||||
*********************************************************************************
|
||||
* 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 __CH57x_CMP_H__
|
||||
#define __CH57x_CMP_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/* comparator -channel input sel */
|
||||
typedef enum
|
||||
{
|
||||
cmp_sw_0 = 0, // CMP_P0(PA3),CMP_N(PA2)
|
||||
cmp_sw_1, // CMP_P0(PA3),CMP_N(CMP_VERF)
|
||||
cmp_sw_2, // CMP_P0(PA7),CMP_N(PA2)
|
||||
cmp_sw_3 // CMP_P0(PA7),CMP_N(CMP_VERF)
|
||||
} CMPSwTypeDef;
|
||||
|
||||
//GPIOModeTypeDef
|
||||
/* comparator negative end point Vref sel */
|
||||
typedef enum
|
||||
{
|
||||
cmp_nref_level_50 = 0, // 50mv
|
||||
cmp_nref_level_100, // 100mv
|
||||
cmp_nref_level_150, // 150mv
|
||||
cmp_nref_level_200, // 200mv
|
||||
cmp_nref_level_250, // 250mv
|
||||
cmp_nref_level_300, // 300mv
|
||||
cmp_nref_level_350, // 350mv
|
||||
cmp_nref_level_400, // 400mv
|
||||
cmp_nref_level_450, // 450mv
|
||||
cmp_nref_level_500, // 500mv
|
||||
cmp_nref_level_550, // 550mv
|
||||
cmp_nref_level_600, // 600mv
|
||||
cmp_nref_level_650, // 650mv
|
||||
cmp_nref_level_700, // 700mv
|
||||
cmp_nref_level_750, // 750mv
|
||||
cmp_nref_level_800, // 800mv
|
||||
} CMPNrefLevelTypeDef;
|
||||
|
||||
/* comparator output sel */
|
||||
typedef enum
|
||||
{
|
||||
cmp_out_sel_high = 0, // high
|
||||
cmp_out_sel_low, // low
|
||||
cmp_out_sel_fall, // fall edge
|
||||
cmp_out_sel_rise // rise edge
|
||||
} CMPOutSelTypeDef;
|
||||
|
||||
#define CMP_GetITStatus() (R8_CMP_CTRL_2 & RB_CMP_IF)
|
||||
|
||||
#define CMP_ClearITStatus() (R8_CMP_CTRL_2 |= RB_CMP_IF)
|
||||
|
||||
#define CMP_ReadAPROut() (R8_CMP_CTRL_3 & RB_APR_OUT_CMP)
|
||||
|
||||
#define CMP_Enable() (R8_CMP_CTRL_0 |= RB_CMP_EN)
|
||||
|
||||
#define CMP_Disable() (R8_CMP_CTRL_0 &= ~RB_CMP_EN)
|
||||
|
||||
void CMP_Init (CMPSwTypeDef s, CMPNrefLevelTypeDef v);
|
||||
|
||||
void CMP_OutToTIMCAPCfg(FunctionalState s);
|
||||
|
||||
void CMP_INTCfg (CMPOutSelTypeDef sel, FunctionalState s);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __CH57x_CMP_H__
|
||||
95
BLV_RF_W13_V04_20260114/StdPeriphDriver/inc/CH57x_common.h
Normal file
95
BLV_RF_W13_V04_20260114/StdPeriphDriver/inc/CH57x_common.h
Normal file
@@ -0,0 +1,95 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH57x_common.h
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2021/11/17
|
||||
* Description : head file(ch572/ch570)
|
||||
*********************************************************************************
|
||||
* 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 __CH57x_COMM_H__
|
||||
#define __CH57x_COMM_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
#define ALL 0xFFFF
|
||||
|
||||
#ifndef __HIGH_CODE
|
||||
#define __HIGH_CODE __attribute__((section(".highcode")))
|
||||
#endif
|
||||
|
||||
#ifndef __INTERRUPT
|
||||
#ifdef INT_SOFT
|
||||
#define __INTERRUPT __attribute__((interrupt()))
|
||||
#else
|
||||
#define __INTERRUPT __attribute__((interrupt("WCH-Interrupt-fast")))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
#define PRINT(X...) printf(X)
|
||||
#else
|
||||
#define PRINT(X...)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief ϵͳ<CFB5><CDB3>Ƶʱ<C6B5>ӣ<EFBFBD>Hz<48><7A>
|
||||
*/
|
||||
#ifndef FREQ_SYS
|
||||
#define FREQ_SYS 100000000
|
||||
#endif
|
||||
|
||||
#ifndef SAFEOPERATE
|
||||
#define SAFEOPERATE asm volatile("fence.i")
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <CH572SFR.h>
|
||||
#include "core_riscv.h"
|
||||
#include "CH57x_clk.h"
|
||||
#include "CH57x_cmp.h"
|
||||
#include "CH57x_keyscan.h"
|
||||
#include "CH57x_uart.h"
|
||||
#include "CH57x_gpio.h"
|
||||
#include "CH57x_i2c.h"
|
||||
#include "CH57x_flash.h"
|
||||
#include "CH57x_pwr.h"
|
||||
#include "CH57x_pwm.h"
|
||||
#include "CH57x_sys.h"
|
||||
#include "CH57x_timer.h"
|
||||
#include "CH57x_spi.h"
|
||||
#include "CH57x_usbdev.h"
|
||||
#include "CH57x_usbhost.h"
|
||||
#include "ISP572.h"
|
||||
|
||||
/**
|
||||
* @brief LSIʱ<49>ӣ<EFBFBD>Hz<48><7A>
|
||||
*/
|
||||
extern uint32_t Freq_LSI;
|
||||
|
||||
#define DelayMs(x) mDelaymS(x)
|
||||
#define DelayUs(x) mDelayuS(x)
|
||||
|
||||
#define ROM_CFG_VERISON 0x7F010
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __CH57x_COMM_H__
|
||||
|
||||
41
BLV_RF_W13_V04_20260114/StdPeriphDriver/inc/CH57x_flash.h
Normal file
41
BLV_RF_W13_V04_20260114/StdPeriphDriver/inc/CH57x_flash.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH57x_flash.h
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2021/11/17
|
||||
* Description : head file(ch572/ch570)
|
||||
*********************************************************************************
|
||||
* 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 __CH57x_FLASH_H__
|
||||
#define __CH57x_FLASH_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief <20><>ȡFlash-ROM
|
||||
*
|
||||
* @param StartAddr - read address
|
||||
* @param Buffer - read buffer
|
||||
* @param len - read len
|
||||
*/
|
||||
void FLASH_ROM_READ(uint32_t StartAddr, void *Buffer, uint32_t len);
|
||||
|
||||
uint8_t UserOptionByteConfig(FunctionalState RESET_EN, FunctionalState UART_NO_KEY_EN,
|
||||
uint32_t FLASHProt_Size);
|
||||
|
||||
uint8_t UserOptionByteClose_SWD(void);
|
||||
|
||||
void UserOptionByte_Active(void);
|
||||
|
||||
void GET_UNIQUE_ID(uint8_t *Buffer);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __CH57x_FLASH_H__
|
||||
202
BLV_RF_W13_V04_20260114/StdPeriphDriver/inc/CH57x_gpio.h
Normal file
202
BLV_RF_W13_V04_20260114/StdPeriphDriver/inc/CH57x_gpio.h
Normal file
@@ -0,0 +1,202 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH57x_gpio.h
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2021/11/17
|
||||
* Description : head file(ch572/ch570)
|
||||
*********************************************************************************
|
||||
* 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 __CH57x_GPIO_H__
|
||||
#define __CH57x_GPIO_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief GPIO_pins_define
|
||||
*/
|
||||
#define GPIO_Pin_0 (0x00000001) /*!< Pin 0 selected */
|
||||
#define GPIO_Pin_1 (0x00000002) /*!< Pin 1 selected */
|
||||
#define GPIO_Pin_2 (0x00000004) /*!< Pin 2 selected */
|
||||
#define GPIO_Pin_3 (0x00000008) /*!< Pin 3 selected */
|
||||
#define GPIO_Pin_4 (0x00000010) /*!< Pin 4 selected */
|
||||
#define GPIO_Pin_5 (0x00000020) /*!< Pin 5 selected */
|
||||
#define GPIO_Pin_6 (0x00000040) /*!< Pin 6 selected */
|
||||
#define GPIO_Pin_7 (0x00000080) /*!< Pin 7 selected */
|
||||
#define GPIO_Pin_8 (0x00000100) /*!< Pin 8 selected */
|
||||
#define GPIO_Pin_9 (0x00000200) /*!< Pin 9 selected */
|
||||
#define GPIO_Pin_10 (0x00000400) /*!< Pin 10 selected */
|
||||
#define GPIO_Pin_11 (0x00000800) /*!< Pin 11 selected */
|
||||
#define GPIO_Pin_12 (0x00001000) /*!< Pin 12 selected */
|
||||
#define GPIO_Pin_13 (0x00002000) /*!< Pin 13 selected */
|
||||
#define GPIO_Pin_14 (0x00004000) /*!< Pin 14 selected */
|
||||
#define GPIO_Pin_15 (0x00008000) /*!< Pin 15 selected */
|
||||
#define GPIO_Pin_16 (0x00010000) /*!< Pin 16 selected */
|
||||
#define GPIO_Pin_17 (0x00020000) /*!< Pin 17 selected */
|
||||
#define GPIO_Pin_18 (0x00040000) /*!< Pin 18 selected */
|
||||
#define GPIO_Pin_19 (0x00080000) /*!< Pin 19 selected */
|
||||
#define GPIO_Pin_20 (0x00100000) /*!< Pin 20 selected */
|
||||
#define GPIO_Pin_21 (0x00200000) /*!< Pin 21 selected */
|
||||
#define GPIO_Pin_22 (0x00400000) /*!< Pin 22 selected */
|
||||
#define GPIO_Pin_23 (0x00800000) /*!< Pin 23 selected */
|
||||
#define GPIO_Pin_All (0xFFFFFFFF) /*!< All pins selected */
|
||||
|
||||
/**
|
||||
* @brief GPIO_pins_remap_define
|
||||
*/
|
||||
#define REMAP_RXD_PA2 0x00 /*!<Ĭ<><C4AC>ӳ<EFBFBD>䣨RXD/PA2<41><32> */
|
||||
#define REMAP_RXD_PA3 0x01 /*!<<3C><>ӳ<EFBFBD>䣨RXD/PA3<41><33> */
|
||||
#define REMAP_RXD_PA0 0x02 /*!<<3C><>ӳ<EFBFBD>䣨RXD/PA0<41><30> */
|
||||
#define REMAP_RXD_PA1 0x03 /*!<<3C><>ӳ<EFBFBD>䣨RXD/PA1<41><31> */
|
||||
#define REMAP_RXD_PA4 0x04 /*!<<3C><>ӳ<EFBFBD>䣨RXD/PA4<41><34> */
|
||||
#define REMAP_RXD_PA9 0x05 /*!<<3C><>ӳ<EFBFBD>䣨RXD/PA9<41><39> */
|
||||
#define REMAP_RXD_PA10 0x06 /*!<<3C><>ӳ<EFBFBD>䣨RXD/PA10<31><30> */
|
||||
#define REMAP_RXD_PA11 0x07 /*!<<3C><>ӳ<EFBFBD>䣨RXD/PA11<31><31> */
|
||||
|
||||
#define REMAP_TXD_PA3 0x00 /*!<Ĭ<><C4AC>ӳ<EFBFBD>䣨TXD/PA3<41><33> */
|
||||
#define REMAP_TXD_PA2 0x08 /*!<<3C><>ӳ<EFBFBD>䣨TXD/PA2<41><32> */
|
||||
#define REMAP_TXD_PA1 0x10 /*!<<3C><>ӳ<EFBFBD>䣨TXD/PA1<41><31> */
|
||||
#define REMAP_TXD_PA0 0x18 /*!<<3C><>ӳ<EFBFBD>䣨TXD/PA0<41><30> */
|
||||
#define REMAP_TXD_PA7 0x20 /*!<<3C><>ӳ<EFBFBD>䣨TXD/PA7<41><37> */
|
||||
#define REMAP_TXD_PA8 0x28 /*!<<3C><>ӳ<EFBFBD>䣨TXD/PA8<41><38> */
|
||||
#define REMAP_TXD_PA11 0x30 /*!<<3C><>ӳ<EFBFBD>䣨TXD/PA11<31><31> */
|
||||
#define REMAP_TXD_PA10 0x38 /*!<<3C><>ӳ<EFBFBD>䣨TXD/PA10<31><30> */
|
||||
|
||||
#define REMAP_TMR_DEFAULT 0x00 /*!<Ĭ<><C4AC>ӳ<EFBFBD>䣨PWM0/PA7<41><37>CAP_IN1/PA7<41><37>CAP_IN2/PA2<41><32> */
|
||||
#define REMAP_TMR_MODE1 0x40 /*!<<3C><>ӳ<EFBFBD><D3B3>1 <20><>PWM0/PA2<41><32>CAP_IN1/PA2<41><32>CAP_IN2/PA7<41><37> */
|
||||
#define REMAP_TMR_MODE2 0x80 /*!<<3C><>ӳ<EFBFBD><D3B3>2<EFBFBD><32>PWM0/PA4<41><34>CAP_IN1/PA4<41><34>CAP_IN2/PA9<41><39> */
|
||||
#define REMAP_TMR_MODE3 0xC0 /*!<<3C><>ӳ<EFBFBD><D3B3>3<EFBFBD><33>PWM0/PA9<41><39>CAP_IN1/PA9<41><39>CAP_IN2/PA4<41><34> */
|
||||
|
||||
#define REMAP_I2C_DEFAULT 0x00 /*!<Ĭ<><C4AC>ӳ<EFBFBD>䣨SCL/PA8<41><38>SDA/PA9<41><39> */
|
||||
#define REMAP_I2C_MODE1 0x200 /*!<<3C><>ӳ<EFBFBD><D3B3>1 <20><>SCL/PA0<41><30>SDA/PA1<41><31> */
|
||||
#define REMAP_I2C_MODE2 0x400 /*!<<3C><>ӳ<EFBFBD><D3B3>2 <20><>SCL/PA3<41><33>SDA/PA2<41><32> */
|
||||
#define REMAP_I2C_MODE3 0x600 /*!<<3C><>ӳ<EFBFBD><D3B3>3 <20><>SCL/PA5<41><35>SDA/PA6<41><36> */
|
||||
|
||||
/**
|
||||
* @brief Configuration GPIO Mode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GPIO_ModeIN_Floating, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
GPIO_ModeIN_PU, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
GPIO_ModeIN_PD, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
GPIO_ModeOut_PP_5mA, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>5mA
|
||||
GPIO_ModeOut_PP_20mA, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>20mA
|
||||
|
||||
} GPIOModeTypeDef;
|
||||
|
||||
/**
|
||||
* @brief Configuration GPIO IT Mode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GPIO_ITMode_LowLevel, //<2F>͵<EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD>
|
||||
GPIO_ITMode_HighLevel, //<2F>ߵ<EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD>
|
||||
GPIO_ITMode_FallEdge, //<2F>½<EFBFBD><C2BD>ش<EFBFBD><D8B4><EFBFBD>
|
||||
GPIO_ITMode_RiseEdge, //<2F><><EFBFBD><EFBFBD><EFBFBD>ش<EFBFBD><D8B4><EFBFBD>
|
||||
|
||||
} GPIOITModeTpDef;
|
||||
|
||||
/**
|
||||
* @brief GPIOA<4F>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param pin - PA0-PA15
|
||||
* @param mode - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
void GPIOA_ModeCfg(uint32_t pin, GPIOModeTypeDef mode);
|
||||
|
||||
/**
|
||||
* @brief GPIOA<4F>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>
|
||||
*
|
||||
* @param pin - PA0-PA15
|
||||
*/
|
||||
#define GPIOA_ResetBits(pin) (R32_PA_CLR = pin)
|
||||
|
||||
/**
|
||||
* @brief GPIOA<4F>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ø<EFBFBD>
|
||||
*
|
||||
* @param pin - PA0-PA15
|
||||
*/
|
||||
#define GPIOA_SetBits(pin) (R32_PA_SET = pin)
|
||||
|
||||
/**
|
||||
* @brief GPIOA<4F>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽ<EFBFBD><C6BD>ת
|
||||
*
|
||||
* @param pin - PA0-PA15
|
||||
*/
|
||||
#define GPIOA_InverseBits(pin) (R32_PA_OUT ^= pin)
|
||||
|
||||
/**
|
||||
* @brief GPIOA<4F>˿<EFBFBD>32λ<32><CEBB><EFBFBD>ݷ<EFBFBD><DDB7>أ<EFBFBD><D8A3><EFBFBD>16λ<36><CEBB>Ч
|
||||
*
|
||||
* @return GPIOA<4F>˿<EFBFBD>32λ<32><CEBB><EFBFBD><EFBFBD>
|
||||
*/
|
||||
#define GPIOA_ReadPort() (R32_PA_PIN)
|
||||
|
||||
/**
|
||||
* @brief GPIOA<4F>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4><CCAC>0-<2D><><EFBFBD>ŵ͵<C5B5>ƽ<EFBFBD><C6BD>(!0)-<2D><><EFBFBD>Ÿߵ<C5B8>ƽ
|
||||
*
|
||||
* @param pin - PA0-PA15
|
||||
*
|
||||
* @return GPIOA<4F>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD>״̬
|
||||
*/
|
||||
#define GPIOA_ReadPortPin(pin) (R32_PA_PIN & (pin))
|
||||
|
||||
/**
|
||||
* @brief GPIOA<4F><41><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param pin - PA0-PA15
|
||||
* @param mode - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
void GPIOA_ITModeCfg(uint32_t pin, GPIOITModeTpDef mode);
|
||||
|
||||
/**
|
||||
* @brief <20><>ȡGPIOA<4F>˿<EFBFBD><CBBF>жϱ<D0B6>־״̬
|
||||
*
|
||||
* @return GPIOA<4F>˿<EFBFBD><CBBF>жϱ<D0B6>־״̬
|
||||
*/
|
||||
#define GPIOA_ReadITFlagPort() (R16_PA_INT_IF)
|
||||
|
||||
/**
|
||||
* @brief <20><>ȡGPIOA<4F>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>жϱ<D0B6>־״̬
|
||||
*
|
||||
* @param pin - PA0-PA15
|
||||
*
|
||||
* @return GPIOA<4F>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>жϱ<D0B6>־״̬
|
||||
*/
|
||||
#define GPIOA_ReadITFlagBit(pin) (R16_PA_INT_IF & (pin))
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD>GPIOA<4F>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>жϱ<D0B6>־״̬
|
||||
*
|
||||
* @param pin - PA0-PA15
|
||||
*/
|
||||
#define GPIOA_ClearITFlagBit(pin) (R16_PA_INT_IF = pin)
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD>蹦<EFBFBD><E8B9A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD><D3B3>
|
||||
*
|
||||
* @param s - <20>Ƿ<EFBFBD>ʹ<EFBFBD><CAB9>ӳ<EFBFBD><D3B3>
|
||||
* @param perph - д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD><D3B3><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>GPIO_pins_remap_define
|
||||
*/
|
||||
void GPIOPinRemap(FunctionalState s, uint16_t perph);
|
||||
|
||||
/**
|
||||
* @brief I/O pin<69><6E><EFBFBD>ֹ<EFBFBD><D6B9>ܿ<EFBFBD><DCBF><EFBFBD>
|
||||
*
|
||||
* @param s - <20>Ƿ<EFBFBD><C7B7><EFBFBD>ӦI/O pin<69><6E><EFBFBD>ֹ<EFBFBD><D6B9><EFBFBD>
|
||||
* @param pin - PA0-PA15
|
||||
*/
|
||||
void GPIOADigitalCfg(FunctionalState s, uint16_t pin);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __CH57x_GPIO_H__
|
||||
191
BLV_RF_W13_V04_20260114/StdPeriphDriver/inc/CH57x_i2c.h
Normal file
191
BLV_RF_W13_V04_20260114/StdPeriphDriver/inc/CH57x_i2c.h
Normal file
@@ -0,0 +1,191 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH57x_i2c.h
|
||||
* Author : WCH
|
||||
* Version : V1.0
|
||||
* Date : 2024/8/22
|
||||
* Description : head file(ch572/ch570)
|
||||
*********************************************************************************
|
||||
* 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 __CH57x_I2C_H__
|
||||
#define __CH57x_I2C_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* I2C_transfer_direction */
|
||||
#define I2C_Direction_Transmitter ((uint8_t)0x00)
|
||||
#define I2C_Direction_Receiver ((uint8_t)0x01)
|
||||
|
||||
/* I2C ADD0 mask */
|
||||
#define OADDR1_ADD0_Set ((uint16_t)0x0001)
|
||||
#define OADDR1_ADD0_Reset ((uint16_t)0xFFFE)
|
||||
|
||||
/* I2C_NACK_position */
|
||||
#define I2C_NACKPosition_Next ((uint16_t)RB_I2C_POS)
|
||||
#define I2C_NACKPosition_Current ((uint16_t)~RB_I2C_POS)
|
||||
|
||||
/* I2C_PEC_position */
|
||||
#define I2C_PECPosition_Next ((uint16_t)RB_I2C_POS)
|
||||
#define I2C_PECPosition_Current ((uint16_t)~RB_I2C_POS)
|
||||
|
||||
/* I2C_SMBus_alert_pin_level */
|
||||
#define I2C_SMBusAlert_Low ((uint16_t)RB_I2C_ALERT)
|
||||
#define I2C_SMBusAlert_High ((uint16_t)~RB_I2C_ALERT)
|
||||
|
||||
/* I2C FLAG mask */
|
||||
#define FLAG_Mask ((uint32_t)0x00FFFFFF)
|
||||
|
||||
/* I2C Interrupt Enable mask */
|
||||
#define ITEN_Mask ((uint32_t)0x07000000)
|
||||
|
||||
/* I2C_mode */
|
||||
typedef enum
|
||||
{
|
||||
I2C_Mode_I2C = 0x0000,
|
||||
I2C_Mode_SMBusDevice = 0x0002,
|
||||
I2C_Mode_SMBusHost = 0x000A,
|
||||
} I2C_ModeTypeDef;
|
||||
|
||||
/* I2C_duty_cycle_in_fast_mode */
|
||||
typedef enum
|
||||
{
|
||||
I2C_DutyCycle_16_9 = RB_I2C_DUTY, /* I2C fast mode Tlow/Thigh = 16/9 */
|
||||
I2C_DutyCycle_2 = 0x0000, /* I2C fast mode Tlow/Thigh = 2 */
|
||||
} I2C_DutyTypeDef;
|
||||
|
||||
/* I2C_acknowledgement - Enables or disables the acknowledgement.*/
|
||||
typedef enum
|
||||
{
|
||||
I2C_Ack_Enable = RB_I2C_ACK,
|
||||
I2C_Ack_Disable = 0x0000,
|
||||
} I2C_AckTypeDef;
|
||||
|
||||
/* I2C_acknowledged_address - Specifies if 7-bit or 10-bit address is acknowledged. */
|
||||
typedef enum
|
||||
{
|
||||
I2C_AckAddr_7bit = 0x4000,
|
||||
I2C_AckAddr_10bit = 0xC000,
|
||||
} I2C_AckAddrTypeDef;
|
||||
|
||||
/* I2C_interrupts_definition */
|
||||
typedef enum
|
||||
{
|
||||
I2C_IT_BUF = 0x0400, /* Buffer interrupt mask. */
|
||||
I2C_IT_EVT = 0x0200, /* Event interrupt mask. */
|
||||
I2C_IT_ERR = 0x0100, /* Error interrupt mask. */
|
||||
} I2C_ITTypeDef;
|
||||
|
||||
/* I2C_interrupts_definition */
|
||||
#define I2C_IT_SMBALERT ((uint32_t)0x01008000)
|
||||
#define I2C_IT_TIMEOUT ((uint32_t)0x01004000)
|
||||
#define I2C_IT_PECERR ((uint32_t)0x01001000)
|
||||
#define I2C_IT_OVR ((uint32_t)0x01000800)
|
||||
#define I2C_IT_AF ((uint32_t)0x01000400)
|
||||
#define I2C_IT_ARLO ((uint32_t)0x01000200)
|
||||
#define I2C_IT_BERR ((uint32_t)0x01000100)
|
||||
#define I2C_IT_TXE ((uint32_t)0x06000080)
|
||||
#define I2C_IT_RXNE ((uint32_t)0x06000040)
|
||||
#define I2C_IT_STOPF ((uint32_t)0x02000010)
|
||||
#define I2C_IT_ADD10 ((uint32_t)0x02000008)
|
||||
#define I2C_IT_BTF ((uint32_t)0x02000004)
|
||||
#define I2C_IT_ADDR ((uint32_t)0x02000002)
|
||||
#define I2C_IT_SB ((uint32_t)0x02000001)
|
||||
|
||||
/* SR2 register flags */
|
||||
#define I2C_FLAG_DUALF ((uint32_t)0x00800000)
|
||||
#define I2C_FLAG_SMBHOST ((uint32_t)0x00400000)
|
||||
#define I2C_FLAG_SMBDEFAULT ((uint32_t)0x00200000)
|
||||
#define I2C_FLAG_GENCALL ((uint32_t)0x00100000)
|
||||
#define I2C_FLAG_TRA ((uint32_t)0x00040000)
|
||||
#define I2C_FLAG_BUSY ((uint32_t)0x00020000)
|
||||
#define I2C_FLAG_MSL ((uint32_t)0x00010000)
|
||||
|
||||
/* SR1 register flags */
|
||||
#define I2C_FLAG_SMBALERT ((uint32_t)0x10008000)
|
||||
#define I2C_FLAG_TIMEOUT ((uint32_t)0x10004000)
|
||||
#define I2C_FLAG_PECERR ((uint32_t)0x10001000)
|
||||
#define I2C_FLAG_OVR ((uint32_t)0x10000800)
|
||||
#define I2C_FLAG_AF ((uint32_t)0x10000400)
|
||||
#define I2C_FLAG_ARLO ((uint32_t)0x10000200)
|
||||
#define I2C_FLAG_BERR ((uint32_t)0x10000100)
|
||||
#define I2C_FLAG_TXE ((uint32_t)0x10000080)
|
||||
#define I2C_FLAG_RXNE ((uint32_t)0x10000040)
|
||||
#define I2C_FLAG_STOPF ((uint32_t)0x10000010)
|
||||
#define I2C_FLAG_ADD10 ((uint32_t)0x10000008)
|
||||
#define I2C_FLAG_BTF ((uint32_t)0x10000004)
|
||||
#define I2C_FLAG_ADDR ((uint32_t)0x10000002)
|
||||
#define I2C_FLAG_SB ((uint32_t)0x10000001)
|
||||
|
||||
/****************I2C Master Events (Events grouped in order of communication)********************/
|
||||
|
||||
#define I2C_EVENT_MASTER_MODE_SELECT ((uint32_t)0x00030001) /* BUSY, MSL and SB flag */
|
||||
#define I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED ((uint32_t)0x00070082) /* BUSY, MSL, ADDR, TXE and TRA flags */
|
||||
#define I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED ((uint32_t)0x00030002) /* BUSY, MSL and ADDR flags */
|
||||
#define I2C_EVENT_MASTER_MODE_ADDRESS10 ((uint32_t)0x00030008) /* BUSY, MSL and ADD10 flags */
|
||||
#define I2C_EVENT_MASTER_BYTE_RECEIVED ((uint32_t)0x00030040) /* BUSY, MSL and RXNE flags */
|
||||
#define I2C_EVENT_MASTER_BYTE_TRANSMITTING ((uint32_t)0x00070080) /* TRA, BUSY, MSL, TXE flags */
|
||||
#define I2C_EVENT_MASTER_BYTE_TRANSMITTED ((uint32_t)0x00070084) /* TRA, BUSY, MSL, TXE and BTF flags */
|
||||
|
||||
/******************I2C Slave Events (Events grouped in order of communication)******************/
|
||||
|
||||
#define I2C_EVENT_SLAVE_RECEIVER_ADDRESS_MATCHED ((uint32_t)0x00020002) /* BUSY and ADDR flags */
|
||||
#define I2C_EVENT_SLAVE_TRANSMITTER_ADDRESS_MATCHED ((uint32_t)0x00060082) /* TRA, BUSY, TXE and ADDR flags */
|
||||
#define I2C_EVENT_SLAVE_RECEIVER_SECONDADDRESS_MATCHED ((uint32_t)0x00820000) /* DUALF and BUSY flags */
|
||||
#define I2C_EVENT_SLAVE_TRANSMITTER_SECONDADDRESS_MATCHED ((uint32_t)0x00860080) /* DUALF, TRA, BUSY and TXE flags */
|
||||
#define I2C_EVENT_SLAVE_GENERALCALLADDRESS_MATCHED ((uint32_t)0x00120000) /* GENCALL and BUSY flags */
|
||||
#define I2C_EVENT_SLAVE_BYTE_RECEIVED ((uint32_t)0x00020040) /* BUSY and RXNE flags */
|
||||
#define I2C_EVENT_SLAVE_STOP_DETECTED ((uint32_t)0x00000010) /* STOPF flag */
|
||||
#define I2C_EVENT_SLAVE_BYTE_TRANSMITTED ((uint32_t)0x00060084) /* TRA, BUSY, TXE and BTF flags */
|
||||
#define I2C_EVENT_SLAVE_BYTE_TRANSMITTING ((uint32_t)0x00060080) /* TRA, BUSY and TXE flags */
|
||||
#define I2C_EVENT_SLAVE_ACK_FAILURE ((uint32_t)0x00000400) /* AF flag */
|
||||
|
||||
void I2C_Init(I2C_ModeTypeDef I2C_Mode, uint32_t I2C_ClockSpeed, I2C_DutyTypeDef I2C_DutyCycle,
|
||||
I2C_AckTypeDef I2C_Ack, I2C_AckAddrTypeDef I2C_AckAddr, uint16_t I2C_OwnAddress1);
|
||||
void I2C_Cmd(FunctionalState NewState);
|
||||
void I2C_GenerateSTART(FunctionalState NewState);
|
||||
void I2C_GenerateSTOP(FunctionalState NewState);
|
||||
void I2C_AcknowledgeConfig(FunctionalState NewState);
|
||||
void I2C_OwnAddress2Config(uint8_t Address);
|
||||
void I2C_DualAddressCmd(FunctionalState NewState);
|
||||
void I2C_GeneralCallCmd(FunctionalState NewState);
|
||||
void I2C_ITConfig(I2C_ITTypeDef I2C_IT, FunctionalState NewState);
|
||||
void I2C_SendData(uint8_t Data);
|
||||
|
||||
uint8_t I2C_ReceiveData(void);
|
||||
|
||||
void I2C_Send7bitAddress(uint8_t Address, uint8_t I2C_Direction);
|
||||
void I2C_SoftwareResetCmd(FunctionalState NewState);
|
||||
void I2C_NACKPositionConfig(uint16_t I2C_NACKPosition);
|
||||
void I2C_SMBusAlertConfig(uint16_t I2C_SMBusAlert);
|
||||
void I2C_TransmitPEC(FunctionalState NewState);
|
||||
void I2C_PECPositionConfig(uint16_t I2C_PECPosition);
|
||||
void I2C_CalculatePEC(FunctionalState NewState);
|
||||
|
||||
uint8_t I2C_GetPEC(void);
|
||||
|
||||
void I2C_ARPCmd(FunctionalState NewState);
|
||||
void I2C_StretchClockCmd(FunctionalState NewState);
|
||||
void I2C_FastModeDutyCycleConfig(uint16_t I2C_DutyCycle);
|
||||
|
||||
/****************************************************************************************
|
||||
* I2C State Monitoring Functions
|
||||
****************************************************************************************/
|
||||
uint8_t I2C_CheckEvent(uint32_t I2C_EVENT);
|
||||
uint32_t I2C_GetLastEvent(void);
|
||||
FlagStatus I2C_GetFlagStatus(uint32_t I2C_FLAG);
|
||||
|
||||
void I2C_ClearFlag(uint32_t I2C_FLAG);
|
||||
ITStatus I2C_GetITStatus(uint32_t I2C_IT);
|
||||
void I2C_ClearITPendingBit(uint32_t I2C_IT);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __CH57x_I2C_H__
|
||||
96
BLV_RF_W13_V04_20260114/StdPeriphDriver/inc/CH57x_keyscan.h
Normal file
96
BLV_RF_W13_V04_20260114/StdPeriphDriver/inc/CH57x_keyscan.h
Normal file
@@ -0,0 +1,96 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH57x_keyscan.h
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2021/11/17
|
||||
* Description : head file(ch572/ch570)
|
||||
*********************************************************************************
|
||||
* 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 __CH57x_KEYSCAN_H__
|
||||
#define __CH57x_KEYSCAN_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* @brief Keyscan Pin Configuration
|
||||
*/
|
||||
#define KEYSCAN_PA2 0x100
|
||||
#define KEYSCAN_PA3 0x200
|
||||
#define KEYSCAN_PA8 0x400
|
||||
#define KEYSCAN_PA10 0x800
|
||||
#define KEYSCAN_PA11 0x1000
|
||||
#define KEYSCAN_ALL 0x1F00
|
||||
|
||||
/*
|
||||
* @brief Keyscan Clock Division
|
||||
*/
|
||||
#define KEYSCAN_DIV1 0x00
|
||||
#define KEYSCAN_DIV2 0x10
|
||||
#define KEYSCAN_DIV4 0x30
|
||||
#define KEYSCAN_DIV8 0x70
|
||||
#define KEYSCAN_DIV16 0xF0
|
||||
|
||||
/*
|
||||
* @brief Keyscan repetition times
|
||||
*/
|
||||
#define KEYSCAN_REP1 0x02
|
||||
#define KEYSCAN_REP2 0x04
|
||||
#define KEYSCAN_REP3 0x06
|
||||
#define KEYSCAN_REP4 0x08
|
||||
#define KEYSCAN_REP5 0x0A
|
||||
#define KEYSCAN_REP6 0x0C
|
||||
#define KEYSCAN_REP7 0x0E
|
||||
|
||||
/*
|
||||
* @brief Keyscan Configuration
|
||||
*/
|
||||
void KeyScan_Cfg(uint8_t s, uint16_t keyScanPin, uint16_t ClkDiv, uint16_t Rep);
|
||||
|
||||
/*
|
||||
* @brief Keypress Wakeup Enable
|
||||
*/
|
||||
void KeyPress_Wake(uint8_t s);
|
||||
|
||||
/*
|
||||
* @brief Key Values Return
|
||||
*/
|
||||
#define KeyValue (R32_KEY_SCAN_NUMB & RB_KEY_SCAN_NUMB)
|
||||
|
||||
/*
|
||||
* @brief Keyscan Count
|
||||
*/
|
||||
#define KeyScan_Cnt (R32_KEY_SCAN_NUMB >> 20)
|
||||
|
||||
/**
|
||||
* @brief KeyScan<61>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param s - ʹ<><CAB9>/<2F>ر<EFBFBD>
|
||||
* @param f - refer to ENC interrupt bit define
|
||||
*/
|
||||
#define KeyScan_ITCfg(s, f) ((s) ? (R8_KEY_SCAN_INT_EN |= f) : (R8_KEY_SCAN_INT_EN &= ~f))
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD>ENC<4E>жϱ<D0B6>־
|
||||
*
|
||||
* @param f - refer to ENC interrupt bit define
|
||||
*/
|
||||
#define KeyScan_ClearITFlag(f) (R8_KEY_SCAN_INT_FLAG = f)
|
||||
|
||||
/**
|
||||
* @brief <20><>ѯ<EFBFBD>жϱ<D0B6>־״̬
|
||||
*
|
||||
* @param f - refer to ENC interrupt bit define
|
||||
*/
|
||||
#define KeyScan_GetITFlag(f) (R8_KEY_SCAN_INT_FLAG & f)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __CH57x_KEYSCAN_H__
|
||||
223
BLV_RF_W13_V04_20260114/StdPeriphDriver/inc/CH57x_pwm.h
Normal file
223
BLV_RF_W13_V04_20260114/StdPeriphDriver/inc/CH57x_pwm.h
Normal file
@@ -0,0 +1,223 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH57x_pwm.h
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2021/11/17
|
||||
* Description : head file(ch572/ch570)
|
||||
*********************************************************************************
|
||||
* 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 __CH57x_PWM_H__
|
||||
#define __CH57x_PWM_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief channel of PWM define
|
||||
*/
|
||||
#define CH_PWM1 0x01 // PWM1 ͨ<><CDA8>
|
||||
#define CH_PWM2 0x02 // PWM2 ͨ<><CDA8>
|
||||
#define CH_PWM3 0x04 // PWM3 ͨ<><CDA8>
|
||||
#define CH_PWM4 0x08 // PWM4 ͨ<><CDA8>
|
||||
#define CH_PWM5 0x10 // PWM5 ͨ<><CDA8>
|
||||
#define CH_PWM_ALL 0x1F // PWM1-5 ͨ<><CDA8>
|
||||
|
||||
/**
|
||||
* @brief DMA channel of PWM
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
Mode_DMACH1_3 = 0, // DMAѡ<41><D1A1>1<EFBFBD><31>2<EFBFBD><32>3ͨ<33><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
Mode_DMACH4_5, // DMAѡ<41><D1A1>4<EFBFBD><34>5ͨ<35><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
Mode_DMACH1_5, // DMAѡ<41><D1A1>1<EFBFBD><31>2<EFBFBD><32>3<EFBFBD><33>4<EFBFBD><34>5ͨ<35><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
} PWM_DMAChannel;
|
||||
|
||||
/**
|
||||
* @brief channel of PWM define
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
High_Level = 0, // Ĭ<>ϵ͵<CFB5>ƽ<EFBFBD><C6BD><EFBFBD>ߵ<EFBFBD>ƽ<EFBFBD><C6BD>Ч
|
||||
Low_Level, // Ĭ<>ϸߵ<CFB8>ƽ<EFBFBD><C6BD><EFBFBD>͵<EFBFBD>ƽ<EFBFBD><C6BD>Ч
|
||||
} PWMX_PolarTypeDef;
|
||||
|
||||
/**
|
||||
* @brief Configuration PWM4_11 Cycle size
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PWMX_Cycle_256 = 0, // 256 <20><>PWMX<4D><58><EFBFBD><EFBFBD>
|
||||
PWMX_Cycle_255, // 255 <20><>PWMX<4D><58><EFBFBD><EFBFBD>
|
||||
PWMX_Cycle_128, // 128 <20><>PWMX<4D><58><EFBFBD><EFBFBD>
|
||||
PWMX_Cycle_127, // 127 <20><>PWMX<4D><58><EFBFBD><EFBFBD>
|
||||
PWMX_Cycle_64, // 64 <20><>PWMX<4D><58><EFBFBD><EFBFBD>
|
||||
PWMX_Cycle_63, // 63 <20><>PWMX<4D><58><EFBFBD><EFBFBD>
|
||||
} PWMX_CycleTypeDef;
|
||||
|
||||
/**
|
||||
* @brief Configuration DMA mode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PWM_ModeSINGLE = 0, // <20><><EFBFBD><EFBFBD>ģʽ
|
||||
PWM_ModeLOOP, // ѭ<><D1AD>ģʽ
|
||||
} PWM_DMAModeTypeDef;
|
||||
|
||||
/**
|
||||
* @brief PWM ͨ<><CDA8><EFBFBD><EFBFBD>ʱ<D7BC><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param d - ͨ<><CDA8><EFBFBD><EFBFBD>ʱ<D7BC><CAB1> = d*Tsys
|
||||
*/
|
||||
#define PWMX_CLKCfg(d) (R16_PWM_CLOCK_DIV = d)
|
||||
|
||||
/**
|
||||
* @brief PWM 8λ<38><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param cyc - refer to PWMX_CycleTypeDef
|
||||
*/
|
||||
void PWMX_CycleCfg(PWMX_CycleTypeDef cyc);
|
||||
|
||||
/**
|
||||
* @brief PWM 16λ<36><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param ch - select channel of pwm, refer to channel of PWM define
|
||||
* cyc - 16λ<36><CEBB><EFBFBD><EFBFBD>
|
||||
*/
|
||||
void PWMX_16bit_CycleCfg(uint8_t ch, uint16_t cyc);
|
||||
|
||||
/**
|
||||
* @brief PWM 16λ<36><CEBB><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>ʹ<EFBFBD><CAB9>
|
||||
*/
|
||||
#define PWM_16bit_CycleEnable() (R8_PWM_CONFIG |= (3 << 1))
|
||||
|
||||
/**
|
||||
* @brief PWM 16λ<36><CEBB><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>ʧ<EFBFBD><CAA7>
|
||||
*/
|
||||
#define PWM_16bit_CycleDisable() (R8_PWM_CONFIG &= ~(3 << 1))
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD> PWM1 8λ<38><CEBB>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param d - <20><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
#define PWM1_ActDataWidth(d) (R8_PWM1_DATA = d)
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD> PWM2 8λ<38><CEBB>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param d - <20><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
#define PWM2_ActDataWidth(d) (R8_PWM2_DATA = d)
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD> PWM3 8λ<38><CEBB>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param d - <20><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
#define PWM3_ActDataWidth(d) (R8_PWM3_DATA = d)
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD> PWM4 8λ<38><CEBB>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param d - <20><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
#define PWM4_ActDataWidth(d) (R8_PWM4_DATA = d)
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD> PWM5 8λ<38><CEBB>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param d - <20><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
#define PWM5_ActDataWidth(d) (R8_PWM5_DATA = d)
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD> PWM1 16λ<36><CEBB>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param d - <20><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
#define PWM1_16bit_ActDataWidth(d) (R16_PWM1_DATA = d)
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD> PWM2 16λ<36><CEBB>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param d - <20><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
#define PWM2_16bit_ActDataWidth(d) (R16_PWM2_DATA = d)
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD> PWM3 16λ<36><CEBB>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param d - <20><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
#define PWM3_16bit_ActDataWidth(d) (R16_PWM3_DATA = d)
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD> PWM4 16λ<36><CEBB>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param d - <20><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
#define PWM4_16bit_ActDataWidth(d) (R16_PWM4_DATA = d)
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD> PWM5 16λ<36><CEBB>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param d - <20><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
#define PWM5_16bit_ActDataWidth(d) (R16_PWM5_DATA = d)
|
||||
|
||||
/**
|
||||
* @brief PWM 8λ<38><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param ch - select channel of pwm, refer to channel of PWM define
|
||||
* @param da - effective pulse width
|
||||
* @param pr - select wave polar, refer to PWMX_PolarTypeDef
|
||||
* @param s - control pwmx function, ENABLE or DISABLE
|
||||
*/
|
||||
void PWMX_ACTOUT(uint8_t ch, uint8_t da, PWMX_PolarTypeDef pr, FunctionalState s);
|
||||
|
||||
/**
|
||||
* @brief PWM 16λ<36><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param ch - select channel of pwm, refer to channel of PWM define
|
||||
* @param da - effective pulse width
|
||||
* @param pr - select wave polar, refer to PWMX_PolarTypeDef
|
||||
* @param s - control pwmx function, ENABLE or DISABLE
|
||||
*/
|
||||
void PWMX_16bit_ACTOUT(uint8_t ch, uint16_t da, PWMX_PolarTypeDef pr, FunctionalState s);
|
||||
|
||||
/**
|
||||
* @brief PWM <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param ch - select group of PWM alternate output
|
||||
* RB_PWM4_5_STAG_EN - PWM4 <20><> PWM5 ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @param s - control pwmx function, ENABLE or DISABLE
|
||||
*/
|
||||
void PWMX_AlterOutCfg(uint8_t ch, FunctionalState s);
|
||||
|
||||
/**
|
||||
* @brief PWM ͬ<><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param s - control pwmx function, ENABLE or DISABLE
|
||||
*/
|
||||
void PWMX_SyncOutCfg(FunctionalState s);
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD>PWM DMA<4D><41><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param s - <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>DMA<4D><41><EFBFBD><EFBFBD>
|
||||
* @param startAddr - DMA <20><>ʼ<EFBFBD><CABC>ַ
|
||||
* @param endAddr - DMA <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
||||
* @param m - <20><><EFBFBD><EFBFBD>DMAģʽ
|
||||
*/
|
||||
void PWM_DMACfg(uint8_t s, uint32_t startAddr, uint32_t endAddr, PWM_DMAModeTypeDef m, PWM_DMAChannel ch);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __CH57x_PWM_H__
|
||||
118
BLV_RF_W13_V04_20260114/StdPeriphDriver/inc/CH57x_pwr.h
Normal file
118
BLV_RF_W13_V04_20260114/StdPeriphDriver/inc/CH57x_pwr.h
Normal file
@@ -0,0 +1,118 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH57x_pwr.h
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2021/11/17
|
||||
* Description : head file(ch572/ch570)
|
||||
*********************************************************************************
|
||||
* 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 __CH57x_PWR_H__
|
||||
#define __CH57x_PWR_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ROM_CFG_ADR_HW 0x7F00C // config address for hardware config for LDO&OSC and etc
|
||||
|
||||
/**
|
||||
* @brief wakeup mode define, select wakeup delay
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
Fsys_Delay_3584 = 0,
|
||||
Fsys_Delay_512,
|
||||
Fsys_Delay_64,
|
||||
Fsys_Delay_1,
|
||||
Fsys_Delay_8191,
|
||||
Fsys_Delay_7168,
|
||||
Fsys_Delay_6144,
|
||||
Fsys_Delay_4096,
|
||||
|
||||
} WakeUP_ModeypeDef;
|
||||
|
||||
/**
|
||||
* @brief wakeup mode define
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD>ʹ<EFBFBD>õ<C3B5><CDB9>ļ<EFBFBD><C4BC>أ<EFBFBD>1uA<75><41><EFBFBD><EFBFBD> */
|
||||
LPLevel_1V8 = 0,
|
||||
LPLevel_2V0,
|
||||
LPLevel_2V2,
|
||||
LPLevel_2V4,
|
||||
|
||||
} VolM_LevelypeDef;
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD>ʱ<EFBFBD>ӿ<EFBFBD><D3BF><EFBFBD>λ
|
||||
*
|
||||
* @param s - <20>Ƿ<EFBFBD><C7B7><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
* @param perph - please refer to Peripher CLK control bit define
|
||||
*/
|
||||
void PWR_PeriphClkCfg(FunctionalState s, uint16_t perph);
|
||||
|
||||
/**
|
||||
* @brief ˯<><EFBFBD><DFBB><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param s - <20>Ƿ<EFBFBD><C7B7><EFBFBD><F2BFAAB4><EFBFBD><EFBFBD><EFBFBD>˯<EFBFBD><EFBFBD><DFBB>ѹ<EFBFBD><D1B9><EFBFBD>
|
||||
* @param perph - <20><>Ҫ<EFBFBD><D2AA><EFBFBD>õĻ<C3B5><C4BB><EFBFBD>Դ
|
||||
* RB_SLP_USB_WAKE - USB Ϊ<><CEAA><EFBFBD><EFBFBD>Դ
|
||||
* RB_SLP_RTC_WAKE - RTC Ϊ<><CEAA><EFBFBD><EFBFBD>Դ
|
||||
* RB_SLP_GPIO_WAKE - GPIO Ϊ<><CEAA><EFBFBD><EFBFBD>Դ
|
||||
* RB_SLP_BAT_WAKE - BAT Ϊ<><CEAA><EFBFBD><EFBFBD>Դ
|
||||
* @param mode - refer to WakeUP_ModeypeDef
|
||||
*/
|
||||
void PWR_PeriphWakeUpCfg(FunctionalState s, uint8_t perph, WakeUP_ModeypeDef mode);
|
||||
|
||||
/**
|
||||
* @brief <20><>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param s - <20>Ƿ<EFBFBD><C7B7>˹<F2BFAAB4><CBB9><EFBFBD>
|
||||
* @param vl - refer to VolM_LevelypeDef
|
||||
*/
|
||||
void PowerMonitor(FunctionalState s, VolM_LevelypeDef vl);
|
||||
|
||||
/**
|
||||
* @brief <20><EFBFBD><CDB9><EFBFBD>-Idleģʽ
|
||||
*/
|
||||
void LowPower_Idle(void);
|
||||
|
||||
/**
|
||||
* @brief <20><EFBFBD><CDB9><EFBFBD>-Haltģʽ<C4A3><CABD><EFBFBD>˵<CBB5><CDB9><EFBFBD><EFBFBD>е<EFBFBD>HSI/5ʱ<35><CAB1><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD>Ѻ<EFBFBD><D1BA><EFBFBD>Ҫ<EFBFBD>û<EFBFBD><C3BB>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>ϵͳʱ<CDB3><CAB1>Դ
|
||||
*/
|
||||
void LowPower_Halt(void);
|
||||
|
||||
/**
|
||||
* @brief <20><EFBFBD><CDB9><EFBFBD>-Sleepģʽ<C4A3><CABD><EFBFBD>˵<CBB5><CDB9><EFBFBD><EFBFBD>е<EFBFBD>HSI/5ʱ<35><CAB1><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD>Ѻ<EFBFBD><D1BA><EFBFBD>Ҫ<EFBFBD>û<EFBFBD><C3BB>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>ϵͳʱ<CDB3><CAB1>Դ
|
||||
* @note ע<><D7A2><EFBFBD><EFBFBD><EFBFBD>ô˺<C3B4><CBBA><EFBFBD><EFBFBD><EFBFBD>DCDC<44><43><EFBFBD><EFBFBD>ǿ<EFBFBD>ƹرգ<D8B1><D5A3><EFBFBD><EFBFBD>Ѻ<EFBFBD><D1BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><D6B6>ٴδ<D9B4><CEB4><EFBFBD>
|
||||
*
|
||||
* @param rm - <20><><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>ѡ<EFBFBD><D1A1>
|
||||
* RB_PWR_RAM2K - 2K retention SRAM <20><><EFBFBD><EFBFBD>
|
||||
* RB_PWR_RAM16K - 16K main SRAM <20><><EFBFBD><EFBFBD>
|
||||
* RB_PWR_EXTEND - USB <20><> BLE <20><>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* RB_PWR_XROM - FlashROM <20><><EFBFBD><EFBFBD>
|
||||
* NULL - <20><><EFBFBD>ϵ<EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD>ϵ<EFBFBD>
|
||||
*/
|
||||
void LowPower_Sleep(uint16_t rm);
|
||||
|
||||
/**
|
||||
* @brief <20><EFBFBD><CDB9><EFBFBD>-Shutdownģʽ<C4A3><CABD><EFBFBD>˵<CBB5><CDB9><EFBFBD><EFBFBD>е<EFBFBD>HSI/5ʱ<35><CAB1><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD>Ѻ<EFBFBD><D1BA><EFBFBD>Ҫ<EFBFBD>û<EFBFBD><C3BB>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>ϵͳʱ<CDB3><CAB1>Դ
|
||||
* @note ע<><D7A2><EFBFBD><EFBFBD><EFBFBD>ô˺<C3B4><CBBA><EFBFBD><EFBFBD><EFBFBD>DCDC<44><43><EFBFBD><EFBFBD>ǿ<EFBFBD>ƹرգ<D8B1><D5A3><EFBFBD><EFBFBD>Ѻ<EFBFBD><D1BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><D6B6>ٴδ<D9B4><CEB4><EFBFBD>
|
||||
*
|
||||
* @param rm - <20><><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>ѡ<EFBFBD><D1A1>
|
||||
* RB_PWR_RAM2K - 2K retention SRAM <20><><EFBFBD><EFBFBD>
|
||||
* RB_PWR_RAM16K - 16K main SRAM <20><><EFBFBD><EFBFBD>
|
||||
* NULL - <20><><EFBFBD>ϵ<EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD>ϵ<EFBFBD>
|
||||
*/
|
||||
void LowPower_Shutdown(uint16_t rm);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __CH57x_PWR_H__
|
||||
229
BLV_RF_W13_V04_20260114/StdPeriphDriver/inc/CH57x_spi.h
Normal file
229
BLV_RF_W13_V04_20260114/StdPeriphDriver/inc/CH57x_spi.h
Normal file
@@ -0,0 +1,229 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH57x_SPI.h
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2021/11/17
|
||||
* Description : head file(ch572/ch570)
|
||||
*********************************************************************************
|
||||
* 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 __CH57x_SPI_H__
|
||||
#define __CH57x_SPI_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief SPI interrupt bit define
|
||||
*/
|
||||
#define SPI_IT_FST_BYTE RB_SPI_IE_FST_BYTE // <20>ӻ<EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>ģʽ<C4A3>£<EFBFBD><C2A3><EFBFBD><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD>ж<EFBFBD>
|
||||
#define SPI_IT_FIFO_OV RB_SPI_IE_FIFO_OV // FIFO <20><><EFBFBD><EFBFBD>
|
||||
#define SPI_IT_DMA_END RB_SPI_IE_DMA_END // DMA <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#define SPI_IT_FIFO_HF RB_SPI_IE_FIFO_HF // FIFO ʹ<>ù<EFBFBD><C3B9><EFBFBD>
|
||||
#define SPI_IT_BYTE_END RB_SPI_IE_BYTE_END // <20><><EFBFBD>ֽڴ<D6BD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#define SPI_IT_CNT_END RB_SPI_IE_CNT_END // ȫ<><C8AB><EFBFBD>ֽڴ<D6BD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
/**
|
||||
* @brief Configuration data mode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
Mode0_LowBitINFront = 0, // ģʽ0<CABD><30><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>ǰ
|
||||
Mode0_HighBitINFront, // ģʽ0<CABD><30><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>ǰ
|
||||
Mode3_LowBitINFront, // ģʽ3<CABD><33><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>ǰ
|
||||
Mode3_HighBitINFront, // ģʽ3<CABD><33><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>ǰ
|
||||
} ModeBitOrderTypeDef;
|
||||
|
||||
/**
|
||||
* @brief Configuration SPI slave mode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
Mode_DataStream = 0, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
||||
Mose_FirstCmd, // <20><><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
||||
} Slave_ModeTypeDef;
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD>ģʽĬ<CABD>ϳ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ģʽ0+3<><33>ȫ˫<C8AB><CBAB>+8MHz
|
||||
*/
|
||||
void SPI_MasterDefInit(void);
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD>2<EFBFBD>߷<EFBFBD><DFB7><EFBFBD>ģʽ<C4A3><CABD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ģʽ1+2<>߰<EFBFBD>˫<EFBFBD><CBAB>+8MHz
|
||||
*/
|
||||
void SPI_2WIRE_MasterOutputInit(void);
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD>2<EFBFBD>߽<EFBFBD><DFBD><EFBFBD>ģʽ<C4A3><CABD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ģʽ1+2<>߰<EFBFBD>˫<EFBFBD><CBAB>+8MHz
|
||||
*/
|
||||
void SPI_2WIRE_MasterReceiveInit(void);
|
||||
|
||||
/**
|
||||
* @brief <20>ӻ<EFBFBD>2<EFBFBD>߽<EFBFBD><DFBD><EFBFBD>ģʽ<C4A3><CABD>ʼ<EFBFBD><CABC>
|
||||
*/
|
||||
void SPI_2WIRE_SlaveInputInit(void);
|
||||
|
||||
/**
|
||||
* @brief <20>ӻ<EFBFBD>2<EFBFBD>߷<EFBFBD><DFB7><EFBFBD>ģʽ<C4A3><CABD>ʼ<EFBFBD><CABC>
|
||||
*/
|
||||
void SPI_2WIRE_SlaveOutputInit(void);
|
||||
|
||||
/**
|
||||
* @brief SPI <20><>ʱ<D7BC><CAB1><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD>= d*Tsys
|
||||
*
|
||||
* @param c - ʱ<>ӷ<EFBFBD>Ƶϵ<C6B5><CFB5>
|
||||
*/
|
||||
void SPI_CLKCfg(uint8_t c);
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
||||
*
|
||||
* @param m - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ refer to ModeBitOrderTypeDef
|
||||
*/
|
||||
void SPI_DataMode(ModeBitOrderTypeDef m);
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD>͵<EFBFBD><CDB5>ֽ<EFBFBD> (buffer)
|
||||
*
|
||||
* @param d - <20><><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>
|
||||
*/
|
||||
void SPI_MasterSendByte(uint8_t d);
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD>յ<EFBFBD><D5B5>ֽ<EFBFBD> (buffer)
|
||||
*
|
||||
* @param none
|
||||
*/
|
||||
uint8_t SPI_MasterRecvByte(void);
|
||||
|
||||
/**
|
||||
* @brief ʹ<><CAB9>FIFO<46><4F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͷ<EFBFBD><CDB6>ֽ<EFBFBD>
|
||||
*
|
||||
* @param pbuf - <20><><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
||||
* @param len - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3>ȣ<EFBFBD><C8A3><EFBFBD><EFBFBD><EFBFBD>4095
|
||||
*/
|
||||
void SPI_MasterTrans(uint8_t *pbuf, uint16_t len);
|
||||
|
||||
/**
|
||||
* @brief ʹ<><CAB9>FIFO<46><4F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ն<EFBFBD><D5B6>ֽ<EFBFBD>
|
||||
*
|
||||
* @param pbuf - <20><><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
||||
* @param len - <20><><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3>ȣ<EFBFBD><C8A3><EFBFBD><EFBFBD><EFBFBD>4095
|
||||
*/
|
||||
void SPI_MasterRecv(uint8_t *pbuf, uint16_t len);
|
||||
|
||||
/**
|
||||
* @brief DMA<4D><41>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param pbuf - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ,<2C><>Ҫ<EFBFBD><D2AA><EFBFBD>ֽڶ<D6BD><DAB6><EFBFBD>
|
||||
* @param len - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||
*/
|
||||
void SPI_MasterDMATrans(uint8_t *pbuf, uint16_t len);
|
||||
|
||||
/**
|
||||
* @brief DMA<4D><41>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param pbuf - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ,<2C><>Ҫ<EFBFBD><D2AA><EFBFBD>ֽڶ<D6BD><DAB6><EFBFBD>
|
||||
* @param len - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||
*/
|
||||
void SPI_MasterDMARecv(uint8_t *pbuf, uint16_t len);
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param d - <20><><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
#define SetFirstData(d) (R8_SPI_SLAVE_PRE = d)
|
||||
|
||||
/**
|
||||
* @brief <20>ӻ<EFBFBD>ģʽ<C4A3><CABD>ʼ<EFBFBD><CABC>
|
||||
*/
|
||||
void SPI_SlaveInit(void);
|
||||
|
||||
/**
|
||||
* @brief <20>ӻ<EFBFBD>2<EFBFBD><32>ģʽ<C4A3><CABD>ʼ<EFBFBD><CABC>
|
||||
*/
|
||||
void SPI_2WIRE_SlaveInit(void);
|
||||
|
||||
/**
|
||||
* @brief <20>ӻ<EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param d - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
void SPI_SlaveSendByte(uint8_t d);
|
||||
|
||||
/**
|
||||
* @brief <20>ӻ<EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @return <20><><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
uint8_t SPI_SlaveRecvByte(void);
|
||||
|
||||
/**
|
||||
* @brief <20>ӻ<EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD><EFBFBD>Ͷ<EFBFBD><CDB6>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param pbuf - <20><><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
||||
* @param len - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3>ȣ<EFBFBD><C8A3><EFBFBD><EFBFBD><EFBFBD>4095
|
||||
*/
|
||||
void SPI_SlaveTrans(uint8_t *pbuf, uint16_t len);
|
||||
|
||||
/**
|
||||
* @brief <20>ӻ<EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD><EFBFBD>ն<EFBFBD><D5B6>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param pbuf - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ
|
||||
* @param len - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||
*/
|
||||
void SPI_SlaveRecv(uint8_t *pbuf, uint16_t len);
|
||||
|
||||
/**
|
||||
* @brief DMA<4D><41>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param pbuf - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ,<2C><>Ҫ<EFBFBD><D2AA><EFBFBD>ֽڶ<D6BD><DAB6><EFBFBD>
|
||||
* @param len - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||
*/
|
||||
void SPI_SlaveDMATrans(uint8_t *pbuf, uint16_t len);
|
||||
|
||||
/**
|
||||
* @brief DMA<4D><41>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param pbuf - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ,<2C><>Ҫ<EFBFBD><D2AA><EFBFBD>ֽڶ<D6BD><DAB6><EFBFBD>
|
||||
* @param len - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||
*/
|
||||
void SPI_SlaveDMARecv(uint8_t *pbuf, uint16_t len);
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD>SPI<50>ж<EFBFBD>
|
||||
*
|
||||
* @param s - ʹ<><CAB9>/<2F>ر<EFBFBD>
|
||||
* @param f - refer to SPI interrupt bit define
|
||||
*/
|
||||
#define SPI_ITCfg(s, f) ((s) ? (R8_SPI_INTER_EN |= f) : (R8_SPI_INTER_EN &= ~f))
|
||||
|
||||
/**
|
||||
* @brief <20><>ȡ<EFBFBD>жϱ<D0B6>־״̬<D7B4><CCAC>0-δ<><CEB4>λ<EFBFBD><CEBB>(!0)-<2D><><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param f - refer to SPI interrupt bit define
|
||||
*/
|
||||
#define SPI_GetITFlag(f) (R8_SPI_INT_FLAG & f)
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD>жϱ<D0B6>־
|
||||
*
|
||||
* @param f - refer to SPI interrupt bit define
|
||||
*/
|
||||
#define SPI_ClearITFlag(f) (R8_SPI_INT_FLAG = f)
|
||||
|
||||
/**
|
||||
* @brief <20>ر<EFBFBD>SPI
|
||||
*/
|
||||
#define SPI_Disable() (R8_SPI_CTRL_MOD &= ~(RB_SPI_MOSI_OE | RB_SPI_SCK_OE | RB_SPI_MISO_OE))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __CH57x_SPI_H__
|
||||
188
BLV_RF_W13_V04_20260114/StdPeriphDriver/inc/CH57x_sys.h
Normal file
188
BLV_RF_W13_V04_20260114/StdPeriphDriver/inc/CH57x_sys.h
Normal file
@@ -0,0 +1,188 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH57x_SYS.h
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2021/11/17
|
||||
* Description : head file(ch572/ch570)
|
||||
*********************************************************************************
|
||||
* 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 __CH57x_SYS_H__
|
||||
#define __CH57x_SYS_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief rtc interrupt event define
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
RST_STATUS_SW = 0, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
|
||||
RST_STATUS_RPOR, // <20>ϵ縴λ
|
||||
RST_STATUS_WTR, // <20><><EFBFBD>Ź<EFBFBD><C5B9><EFBFBD>ʱ<EFBFBD><CAB1>λ
|
||||
RST_STATUS_MR, // <20>ⲿ<EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD>λ
|
||||
RST_STATUS_LRM0, // <20><><EFBFBD>Ѹ<EFBFBD>λ-<2D><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
|
||||
RST_STATUS_GPWSM, // <20>µ<EFBFBD>ģʽ<C4A3><CABD><EFBFBD>Ѹ<EFBFBD>λ
|
||||
RST_STATUS_LRM1, // <09><><EFBFBD>Ѹ<EFBFBD>λ-<2D><><EFBFBD>Ź<EFBFBD><C5B9><EFBFBD><EFBFBD><EFBFBD>
|
||||
RST_STATUS_LRM2, // <09><><EFBFBD>Ѹ<EFBFBD>λ-<2D>ֶ<EFBFBD><D6B6><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
|
||||
|
||||
} SYS_ResetStaTypeDef;
|
||||
|
||||
/**
|
||||
* @brief rtc interrupt event define
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
INFO_RESET_EN = 0x4, // RST#<23>ⲿ<EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD>λ<EFBFBD><CEBB><EFBFBD>빦<EFBFBD><EBB9A6><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
||||
INFO_BOOT_EN = 0x8, // ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> BootLoader <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
||||
INFO_RST_PIN = 0x10, // <20><>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>1<EFBFBD><31>PA7<41><37>0<EFBFBD><30>PA8
|
||||
INFO_LOADER = 0x20, // <20><>ǰϵͳ<CFB5>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>Bootloader <20><>
|
||||
STA_SAFEACC_ACT = 0x30,// <20><>ǰϵͳ<CFB5>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ڰ<EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>RWA<57><41><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɷ<F2B2BBBF><C9B7><EFBFBD>
|
||||
|
||||
} SYS_InfoStaTypeDef;
|
||||
|
||||
/**
|
||||
* @brief <20><>ȡоƬID<49>࣬һ<E0A3AC><D2BB>Ϊ<EFBFBD>̶<EFBFBD>ֵ
|
||||
*/
|
||||
#define SYS_GetChipID() R8_CHIP_ID
|
||||
|
||||
/**
|
||||
* @brief <20><>ȡ<EFBFBD><C8A1>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD>ID<49><44>һ<EFBFBD><D2BB>Ϊ<EFBFBD>̶<EFBFBD>ֵ
|
||||
*/
|
||||
#define SYS_GetAccessID() R8_SAFE_ACCESS_ID
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
*
|
||||
* @param sc - ϵͳʱ<CDB3><CAB1>Դѡ<D4B4><D1A1> refer to SYS_CLKTypeDef
|
||||
*/
|
||||
void SetSysClock(SYS_CLKTypeDef sc);
|
||||
|
||||
/**
|
||||
* @brief <20><>ȡ<EFBFBD><C8A1>ǰϵͳʱ<CDB3><CAB1>
|
||||
*
|
||||
* @return Hz
|
||||
*/
|
||||
uint32_t GetSysClock(void);
|
||||
|
||||
/**
|
||||
* @brief <20><>ȡ<EFBFBD><C8A1>ǰϵͳ<CFB5><CDB3>Ϣ״̬
|
||||
*
|
||||
* @param i - refer to SYS_InfoStaTypeDef
|
||||
*
|
||||
* @return <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
uint8_t SYS_GetInfoSta(SYS_InfoStaTypeDef i);
|
||||
|
||||
/**
|
||||
* @brief <20><>ȡϵͳ<CFB5>ϴθ<CFB4>λ״̬
|
||||
*
|
||||
* @return refer to SYS_ResetStaTypeDef
|
||||
*/
|
||||
#define SYS_GetLastResetSta() (R8_RESET_STATUS & RB_RESET_FLAG)
|
||||
|
||||
/**
|
||||
* @brief ִ<><D6B4>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
|
||||
*/
|
||||
void SYS_ResetExecute(void);
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD>ø<EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD>λ<EFBFBD><CEBB> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB> <20><><EFBFBD>Ź<EFBFBD><C5B9><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD>Ѹ<EFBFBD>λ<EFBFBD><CEBB>Ӱ<EFBFBD><D3B0>
|
||||
*
|
||||
* @param i - refer to SYS_InfoStaTypeDef
|
||||
*/
|
||||
#define SYS_ResetKeepBuf(d) (R8_GLOB_RESET_KEEP = d)
|
||||
|
||||
/**
|
||||
* @brief <20>ر<EFBFBD><D8B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>жϣ<D0B6><CFA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD>ж<EFBFBD>ֵ
|
||||
*
|
||||
* @param pirqv - <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>ֵ
|
||||
*/
|
||||
void SYS_DisableAllIrq(uint32_t *pirqv);
|
||||
|
||||
/**
|
||||
* @brief <20>ָ<EFBFBD>֮ǰ<D6AE>رյ<D8B1><D5B5>ж<EFBFBD>ֵ
|
||||
*
|
||||
* @param irq_status - <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>ֵ
|
||||
*/
|
||||
void SYS_RecoverIrq(uint32_t irq_status);
|
||||
|
||||
/**
|
||||
* @brief <20><>ȡ<EFBFBD><C8A1>ǰϵͳ(SYSTICK)<29><><EFBFBD><EFBFBD>ֵ
|
||||
*
|
||||
* @return <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ֵ
|
||||
*/
|
||||
uint32_t SYS_GetSysTickCnt(void);
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD>ؿ<EFBFBD><D8BF>Ź<EFBFBD><C5B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param c - <20><><EFBFBD>Ź<EFBFBD><C5B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
||||
*/
|
||||
#define WWDG_SetCounter(c) (R8_WDOG_COUNT = c)
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD>Ź<EFBFBD><C5B9><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>ʹ<EFBFBD><CAB9>
|
||||
*
|
||||
* @param s - <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ж<EFBFBD>
|
||||
*/
|
||||
void WWDG_ITCfg(FunctionalState s);
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD>Ź<EFBFBD><C5B9><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param s - <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>λ
|
||||
*/
|
||||
void WWDG_ResetCfg(FunctionalState s);
|
||||
|
||||
/**
|
||||
* @brief <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD>Ź<EFBFBD><C5B9><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־
|
||||
*
|
||||
* @return <20><><EFBFBD>Ź<EFBFBD><C5B9><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־
|
||||
*/
|
||||
#define WWDG_GetFlowFlag() (R8_RST_WDOG_CTRL & RB_WDOG_INT_FLAG)
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ź<EFBFBD><C5B9>жϱ<D0B6>־<EFBFBD><D6BE><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>ؼ<EFBFBD><D8BC><EFBFBD>ֵҲ<D6B5><D2B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
void WWDG_ClearFlag(void);
|
||||
|
||||
/**
|
||||
* @brief uS <20><>ʱ
|
||||
*
|
||||
* @param t - ʱ<><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
void mDelayuS(uint16_t t);
|
||||
|
||||
/**
|
||||
* @brief mS <20><>ʱ
|
||||
*
|
||||
* @param t - ʱ<><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
void mDelaymS(uint16_t t);
|
||||
|
||||
/**
|
||||
* @brief Enter safe access mode.
|
||||
*
|
||||
* @NOTE: After enter safe access mode, about 16 system frequency cycles
|
||||
* are in safe mode, and one or more secure registers can be rewritten
|
||||
* within the valid period. The safe mode will be automatically
|
||||
* terminated after the above validity period is exceeded.
|
||||
* if sys_safe_access_enable() is called,
|
||||
* you must call sys_safe_access_disable() before call sys_safe_access_enable() again.
|
||||
*/
|
||||
#define sys_safe_access_enable() do{volatile uint32_t mpie_mie;mpie_mie=__risc_v_disable_irq();SAFEOPERATE;\
|
||||
R8_SAFE_ACCESS_SIG = SAFE_ACCESS_SIG1;R8_SAFE_ACCESS_SIG = SAFE_ACCESS_SIG2;SAFEOPERATE;
|
||||
|
||||
#define sys_safe_access_disable() R8_SAFE_ACCESS_SIG = 0;__risc_v_enable_irq(mpie_mie);SAFEOPERATE;}while(0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __CH57x_SYS_H__
|
||||
263
BLV_RF_W13_V04_20260114/StdPeriphDriver/inc/CH57x_timer.h
Normal file
263
BLV_RF_W13_V04_20260114/StdPeriphDriver/inc/CH57x_timer.h
Normal file
@@ -0,0 +1,263 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH57x_timer.h
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2021/11/17
|
||||
* Description : head file(ch572/ch570)
|
||||
*********************************************************************************
|
||||
* 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 __CH57x_TIMER_H__
|
||||
#define __CH57x_TIMER_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define DataBit_25 (1 << 25)
|
||||
|
||||
/**
|
||||
* @brief TMR interrupt bit define
|
||||
*/
|
||||
#define TMR_IT_CYC_END 0x01 // <20><><EFBFBD>ڽ<EFBFBD><DABD><EFBFBD><EFBFBD><EFBFBD>־<EFBFBD><D6BE><EFBFBD><EFBFBD>-<2D><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ʱ-<2D><><EFBFBD>ڽ<EFBFBD><DABD><EFBFBD><EFBFBD><EFBFBD>PWM-<2D><><EFBFBD>ڽ<EFBFBD><DABD><EFBFBD>
|
||||
#define TMR_IT_DATA_ACT 0x02 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7>־<EFBFBD><D6BE><EFBFBD><EFBFBD>-<2D><><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>PWM-<2D><>Ч<EFBFBD><D0A7>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD>
|
||||
#define TMR_IT_FIFO_HF 0x04 // FIFO ʹ<>ù<EFBFBD><C3B9>룺<EFBFBD><EBA3BA>- FIFO>=4<><34> PWM- FIFO<4
|
||||
#define TMR_IT_DMA_END 0x08 // DMA <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֧<EFBFBD><D6A7>TMR-TMR3
|
||||
#define TMR_IT_FIFO_OV 0x10 // FIFO <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>- FIFO<46><4F><EFBFBD><EFBFBD> PWM- FIFO<46><4F>
|
||||
|
||||
/**
|
||||
* @brief ENC interrupt bit define
|
||||
*/
|
||||
#define RB_IE_DIR_INC 0x01 // ǰ<><C7B0><EFBFBD>ж<EFBFBD>ʹ<EFBFBD><CAB9>
|
||||
#define RB_IE_DIR_DEC 0x02 // <20><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>ʹ<EFBFBD><CAB9>
|
||||
|
||||
/**
|
||||
* @brief Configuration PWM effective level repeat times
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PWM_Times_1 = 0, // PWM <20><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD>
|
||||
PWM_Times_4, // PWM <20><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD>4<EFBFBD><34><EFBFBD><EFBFBD>
|
||||
PWM_Times_8, // PWM <20><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD>8<EFBFBD><38><EFBFBD><EFBFBD>
|
||||
PWM_Times_16, // PWM <20><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD>16<31><36><EFBFBD><EFBFBD>
|
||||
} PWM_RepeatTsTypeDef;
|
||||
|
||||
/**
|
||||
* @brief Configuration Cap mode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
CAP_NULL = 0, // <20><><EFBFBD><EFBFBD> & <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
Edge_To_Edge, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮<EFBFBD><D6AE> & <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
FallEdge_To_FallEdge, // <20>½<EFBFBD><C2BD>ص<EFBFBD><D8B5>½<EFBFBD><C2BD><EFBFBD> & <20><><EFBFBD><EFBFBD><EFBFBD>½<EFBFBD><C2BD><EFBFBD>
|
||||
RiseEdge_To_RiseEdge, // <20><><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> & <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
} CapModeTypeDef;
|
||||
|
||||
/**
|
||||
* @brief Configuration DMA mode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
Mode_Single = 0, // <20><><EFBFBD><EFBFBD>ģʽ
|
||||
Mode_LOOP, // ѭ<><D1AD>ģʽ
|
||||
} DMAModeTypeDef;
|
||||
|
||||
/**
|
||||
* @brief Configuration ENC mode
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
Mode_IDLE = 0, // IDLEģʽ
|
||||
Mode_T2 , // T2<54><32><EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD>ģʽ
|
||||
Mode_T1 , // T1<54><31><EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD>ģʽ
|
||||
Mode_T1T2 , // T1<54><31>T2<54><32><EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD>ģʽ
|
||||
} ENCModeTypeDef;
|
||||
|
||||
/**
|
||||
* @brief <20><>ʱ<EFBFBD><CAB1><EFBFBD>ܳ<EFBFBD>ʼ<EFBFBD><CABC>
|
||||
*
|
||||
* @param t - <20><>ʱʱ<CAB1>䣬<EFBFBD><E4A3AC><EFBFBD>ڵ<EFBFBD>ǰϵͳʱ<CDB3><CAB1>Tsys, <20><EFBFBD><EEB3A4>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD> 67108864
|
||||
*/
|
||||
void TMR_TimerInit(uint32_t t);
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD>ʼ<EFBFBD><CABC>
|
||||
*
|
||||
* @param cap - <20>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
void TMR_EXTSingleCounterInit(CapModeTypeDef cap);
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD>ü<EFBFBD><C3BC><EFBFBD>ͳ<EFBFBD><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>67108863
|
||||
*
|
||||
* @param cyc - <20><><EFBFBD><EFBFBD>ͳ<EFBFBD><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
|
||||
*/
|
||||
#define TMR_CountOverflowCfg(cyc) (R32_TMR_CNT_END = (cyc + 2))
|
||||
|
||||
/**
|
||||
* @brief <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>67108863
|
||||
*
|
||||
* @return <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ֵ
|
||||
*/
|
||||
#define TMR_GetCurrentCount() R32_TMR_COUNT
|
||||
|
||||
/**
|
||||
* @brief PWM0 ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD>67108863
|
||||
*
|
||||
* @param cyc - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
#define TMR_PWMCycleCfg(cyc) (R32_TMR_CNT_END = cyc)
|
||||
|
||||
/**
|
||||
* @brief PWM <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
|
||||
*
|
||||
* @param pr - select wave polar, refer to PWMX_PolarTypeDef
|
||||
* @param ts - set pwm repeat times, refer to PWM_RepeatTsTypeDef
|
||||
*/
|
||||
void TMR_PWMInit(PWMX_PolarTypeDef pr, PWM_RepeatTsTypeDef ts);
|
||||
|
||||
/**
|
||||
* @brief PWM0 <20><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD>67108864
|
||||
*
|
||||
* @param d - <20><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
#define TMR_PWMActDataWidth(d) (R32_TMR_FIFO = d)
|
||||
|
||||
/**
|
||||
* @brief CAP0 <20><><EFBFBD><D7BD>ƽ<EFBFBD><C6BD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD>33554432
|
||||
*
|
||||
* @param cyc - <20><><EFBFBD><D7BD>ƽ<EFBFBD><C6BD>ʱ
|
||||
*/
|
||||
#define TMR_CAPTimeoutCfg(cyc) (R32_TMR_CNT_END = cyc)
|
||||
|
||||
/**
|
||||
* @brief <20>ⲿ<EFBFBD>źŲ<C5BA><EFBFBD><D7BD><EFBFBD>ܳ<EFBFBD>ʼ<EFBFBD><CABC>
|
||||
*
|
||||
* @param cap - select capture mode, refer to CapModeTypeDef
|
||||
*/
|
||||
void TMR_CapInit(CapModeTypeDef cap);
|
||||
|
||||
/**
|
||||
* @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @return <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
#define TMR_CAPGetData() R32_TMR_FIFO
|
||||
|
||||
/**
|
||||
* @brief <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD>Ѳ<EFBFBD><D1B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><DDB8><EFBFBD>
|
||||
*
|
||||
* @return <20><>ǰ<EFBFBD>Ѳ<EFBFBD><D1B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><DDB8><EFBFBD>
|
||||
*/
|
||||
#define TMR_CAPDataCounter() R8_TMR_FIFO_COUNT
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD>DMA<4D><41><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param s - <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>DMA<4D><41><EFBFBD><EFBFBD>
|
||||
* @param startAddr - DMA <20><>ʼ<EFBFBD><CABC>ַ
|
||||
* @param endAddr - DMA <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
||||
* @param m - <20><><EFBFBD><EFBFBD>DMAģʽ
|
||||
*/
|
||||
void TMR_DMACfg(uint8_t s, uint32_t startAddr, uint32_t endAddr, DMAModeTypeDef m);
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD>ENC<4E><43><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param s - <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @param encReg - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<C4A3><CABD>ֵ(<28><><EFBFBD><EFBFBD>ֵ0xFFFF)
|
||||
* @param m - <20><><EFBFBD><EFBFBD>ENCģʽ
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void ENC_Config(uint8_t s, uint32_t encReg, ENCModeTypeDef m);
|
||||
|
||||
/**
|
||||
* @brief <20>ر<EFBFBD> TMR PWM<57><4D><EFBFBD><EFBFBD>
|
||||
*/
|
||||
#define TMR_PWMDisable() (R8_TMR_CTRL_MOD &= ~RB_TMR_OUT_EN)
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD> TMR PWM<57><4D><EFBFBD><EFBFBD>
|
||||
*/
|
||||
#define TMR_PWMEnable() (R8_TMR_CTRL_MOD |= RB_TMR_OUT_EN)
|
||||
|
||||
/**
|
||||
* @brief <20>ر<EFBFBD> TMR
|
||||
*/
|
||||
#define TMR_Disable() (R8_TMR_CTRL_MOD &= ~RB_TMR_COUNT_EN)
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD> TMR
|
||||
*/
|
||||
#define TMR_Enable() (R8_TMR_CTRL_MOD |= RB_TMR_COUNT_EN)
|
||||
|
||||
/**
|
||||
* @brief TMR<4D>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param s - ʹ<><CAB9>/<2F>ر<EFBFBD>
|
||||
* @param f - refer to TMR interrupt bit define
|
||||
*/
|
||||
#define TMR_ITCfg(s, f) ((s) ? (R8_TMR_INTER_EN |= f) : (R8_TMR_INTER_EN &= ~f))
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD>TMR<4D>жϱ<D0B6>־
|
||||
*
|
||||
* @param f - refer to TMR interrupt bit define
|
||||
*/
|
||||
#define TMR_ClearITFlag(f) (R8_TMR_INT_FLAG = f)
|
||||
|
||||
/**
|
||||
* @brief <20><>ѯ<EFBFBD>жϱ<D0B6>־״̬
|
||||
*
|
||||
* @param f - refer to TMR interrupt bit define
|
||||
*/
|
||||
#define TMR_GetITFlag(f) (R8_TMR_INT_FLAG & f)
|
||||
|
||||
/**
|
||||
* @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @return <20><><EFBFBD><EFBFBD>ֵ 0:ǰ<><C7B0> 1:<3A><><EFBFBD><EFBFBD>
|
||||
*/
|
||||
#define ENC_GetCurrentDir (R8_ENC_REG_CTRL>>5 & 0x01)
|
||||
|
||||
/**
|
||||
* @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ֵ
|
||||
*/
|
||||
#define ENC_GetCurrentCount R32_ENC_REG_CCNT
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0
|
||||
*/
|
||||
#define ENC_GetCountandReset() R8_ENC_REG_CTRL |= RB_RD_CLR_EN
|
||||
|
||||
/**
|
||||
* @brief ENC<4E>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param s - ʹ<><CAB9>/<2F>ر<EFBFBD>
|
||||
* @param f - refer to ENC interrupt bit define
|
||||
*/
|
||||
#define ENC_ITCfg(s, f) ((s) ? (R8_ENC_INTER_EN |= f) : (R8_ENC_INTER_EN &= ~f))
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD>ENC<4E>жϱ<D0B6>־
|
||||
*
|
||||
* @param f - refer to ENC interrupt bit define
|
||||
*/
|
||||
#define ENC_ClearITFlag(f) (R8_ENC_INT_FLAG = f)
|
||||
|
||||
/**
|
||||
* @brief <20><>ѯ<EFBFBD>жϱ<D0B6>־״̬
|
||||
*
|
||||
* @param f - refer to ENC interrupt bit define
|
||||
*/
|
||||
#define ENC_GetITFlag(f) (R8_ENC_INT_FLAG & f)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __CH57x_TIMER_H__
|
||||
172
BLV_RF_W13_V04_20260114/StdPeriphDriver/inc/CH57x_uart.h
Normal file
172
BLV_RF_W13_V04_20260114/StdPeriphDriver/inc/CH57x_uart.h
Normal file
@@ -0,0 +1,172 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH57x_uart.h
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2021/11/17
|
||||
* Description : head file(ch572/ch570)
|
||||
*********************************************************************************
|
||||
* 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 __CH57x_UART_H__
|
||||
#define __CH57x_UART_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief LINE error and status define
|
||||
*/
|
||||
#define STA_ERR_BREAK RB_LSR_BREAK_ERR // <20><><EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#define STA_ERR_FRAME RB_LSR_FRAME_ERR // <20><><EFBFBD><EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD>
|
||||
#define STA_ERR_PAR RB_LSR_PAR_ERR // <20><>żУ<C5BC><D0A3>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
|
||||
#define STA_ERR_FIFOOV RB_LSR_OVER_ERR // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
#define STA_TXFIFO_EMP RB_LSR_TX_FIFO_EMP // <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>FIFO<46>գ<EFBFBD><D5A3><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>䷢<EFBFBD><E4B7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#define STA_TXALL_EMP RB_LSR_TX_ALL_EMP // <20><>ǰ<EFBFBD><C7B0><EFBFBD>з<EFBFBD><D0B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݶ<EFBFBD><DDB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#define STA_RECV_DATA RB_LSR_DATA_RDY // <20><>ǰ<EFBFBD>н<EFBFBD><D0BD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
/**
|
||||
* @brief Configuration UART TrigByte num
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
UART_1BYTE_TRIG = 0, // 1<>ֽڴ<D6BD><DAB4><EFBFBD>
|
||||
UART_2BYTE_TRIG, // 2<>ֽڴ<D6BD><DAB4><EFBFBD>
|
||||
UART_4BYTE_TRIG, // 4<>ֽڴ<D6BD><DAB4><EFBFBD>
|
||||
UART_7BYTE_TRIG, // 7<>ֽڴ<D6BD><DAB4><EFBFBD>
|
||||
|
||||
} UARTByteTRIGTypeDef;
|
||||
|
||||
/**
|
||||
* @brief UART Tx Pin Remap Def
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
UART_TX_REMAP_PA3 = 0, /*!<Ĭ<><C4AC>ӳ<EFBFBD>䣨TXD/PA3<41><33> */
|
||||
UART_TX_REMAP_PA2, /*!<<3C><>ӳ<EFBFBD>䣨TXD/PA2<41><32> */
|
||||
UART_TX_REMAP_PA1, /*!<<3C><>ӳ<EFBFBD>䣨TXD/PA1<41><31> */
|
||||
UART_TX_REMAP_PA0, /*!<<3C><>ӳ<EFBFBD>䣨TXD/PA0<41><30> */
|
||||
UART_TX_REMAP_PA7, /*!<<3C><>ӳ<EFBFBD>䣨TXD/PA7<41><37> */
|
||||
UART_TX_REMAP_PA8, /*!<<3C><>ӳ<EFBFBD>䣨TXD/PA8<41><38> */
|
||||
UART_TX_REMAP_PA11, /*!<<3C><>ӳ<EFBFBD>䣨TXD/PA11<31><31> */
|
||||
UART_TX_REMAP_PA10, /*!<<3C><>ӳ<EFBFBD>䣨TXD/PA10<31><30> */
|
||||
} UARTTxPinRemapDef;
|
||||
|
||||
/**
|
||||
* @brief UART Rx Pin Remap Def
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
UART_RX_REMAP_PA2 = 0, /*!<Ĭ<><C4AC>ӳ<EFBFBD>䣨RXD/PA2<41><32> */
|
||||
UART_RX_REMAP_PA3, /*!<<3C><>ӳ<EFBFBD>䣨RXD/PA3<41><33> */
|
||||
UART_RX_REMAP_PA0, /*!<<3C><>ӳ<EFBFBD>䣨RXD/PA0<41><30> */
|
||||
UART_RX_REMAP_PA1, /*!<<3C><>ӳ<EFBFBD>䣨RXD/PA1<41><31> */
|
||||
UART_RX_REMAP_PA6, /*!<<3C><>ӳ<EFBFBD>䣨RXD/PA6<41><36> */
|
||||
UART_RX_REMAP_PA9, /*!<<3C><>ӳ<EFBFBD>䣨RXD/PA9<41><39> */
|
||||
UART_RX_REMAP_PA10, /*!<<3C><>ӳ<EFBFBD>䣨RXD/PA10<31><30> */
|
||||
UART_RX_REMAP_PA11, /*!<<3C><>ӳ<EFBFBD>䣨RXD/PA11<31><31> */
|
||||
} UARTRxPinRemapDef;
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD>Ĭ<EFBFBD>ϳ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
void UART_DefInit(void);
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param baudrate - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
void UART_BaudRateCfg(uint32_t baudrate);
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD><EFBFBD>ֽڴ<D6BD><DAB4><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param b - <20><><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD> refer to UARTByteTRIGTypeDef
|
||||
*/
|
||||
void UART_ByteTrigCfg(UARTByteTRIGTypeDef b);
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param s - <20>жϿ<D0B6><CFBF><EFBFBD>״̬<D7B4><CCAC><EFBFBD>Ƿ<EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD>Ӧ<EFBFBD>ж<EFBFBD>
|
||||
* @param i - <20>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>
|
||||
* RB_IER_MODEM_CHG - <20><><EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4>仯<EFBFBD>ж<EFBFBD>ʹ<EFBFBD><CAB9>λ<EFBFBD><CEBB><EFBFBD><EFBFBD> UART0 ֧<>֣<EFBFBD>
|
||||
* RB_IER_LINE_STAT - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·״̬<D7B4>ж<EFBFBD>
|
||||
* RB_IER_THR_EMPTY - <20><><EFBFBD>ͱ<EFBFBD><CDB1>ּĴ<D6BC><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
||||
* RB_IER_RECV_RDY - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
||||
*/
|
||||
void UART_INTCfg(FunctionalState s, uint8_t i);
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>FIFO
|
||||
*/
|
||||
#define UART_CLR_RXFIFO() (R8_UART_FCR |= RB_FCR_RX_FIFO_CLR)
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>FIFO
|
||||
*/
|
||||
#define UART_CLR_TXFIFO() (R8_UART_FCR |= RB_FCR_TX_FIFO_CLR)
|
||||
|
||||
/**
|
||||
* @brief <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD>жϱ<D0B6>־
|
||||
*
|
||||
* @return <20><>ǰ<EFBFBD>жϱ<D0B6>־
|
||||
*/
|
||||
#define UART_GetITFlag() (R8_UART_IIR & RB_IIR_INT_MASK)
|
||||
|
||||
/**
|
||||
* @brief <20><>ȡ<EFBFBD><C8A1>ǰͨѶ״̬
|
||||
*
|
||||
* @return refer to LINE error and status define
|
||||
*/
|
||||
#define UART_GetLinSTA() (R8_UART_LSR)
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD>ڵ<EFBFBD><DAB5>ֽڷ<D6BD><DAB7><EFBFBD>
|
||||
*
|
||||
* @param b <20><><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><CDB5>ֽ<EFBFBD>
|
||||
*/
|
||||
#define UART_SendByte(b) (R8_UART_THR = b)
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD>ڶ<EFBFBD><DAB6>ֽڷ<D6BD><DAB7><EFBFBD>
|
||||
*
|
||||
* @param buf - <20><><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
||||
* @param l - <20><><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||
*/
|
||||
void UART_SendString(uint8_t *buf, uint16_t l);
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD>ڶ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>ֽ<EFBFBD>
|
||||
*
|
||||
* @return <20><>ȡ<EFBFBD><C8A1><EFBFBD>ĵ<EFBFBD><C4B5>ֽ<EFBFBD>
|
||||
*/
|
||||
#define UART_RecvByte() (R8_UART_RBR)
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD>ڶ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>ֽ<EFBFBD>
|
||||
*
|
||||
* @param buf - <20><>ȡ<EFBFBD><C8A1><EFBFBD>ݴ<EFBFBD><DDB4>Ż<EFBFBD><C5BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
||||
*
|
||||
* @return <20><>ȡ<EFBFBD><C8A1><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||
*/
|
||||
uint16_t UART_RecvString(uint8_t *buf);
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD><D3B3>
|
||||
*
|
||||
* @param s - <20>Ƿ<EFBFBD>ʹ<EFBFBD><CAB9>ӳ<EFBFBD><D3B3>
|
||||
* @param perph - дTx<54><78>Rx<52><78>ӳ<EFBFBD><D3B3><EFBFBD><EFBFBD>ϵ
|
||||
*/
|
||||
void UART_Remap(FunctionalState s, UARTTxPinRemapDef u_tx, UARTRxPinRemapDef u_rx);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __CH57x_UART_H__
|
||||
152
BLV_RF_W13_V04_20260114/StdPeriphDriver/inc/CH57x_usbdev.h
Normal file
152
BLV_RF_W13_V04_20260114/StdPeriphDriver/inc/CH57x_usbdev.h
Normal file
@@ -0,0 +1,152 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH57x_usbdev.h
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2021/11/17
|
||||
* Description : head file(ch572/ch570)
|
||||
*********************************************************************************
|
||||
* 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 __CH57x_USBDEV_H__
|
||||
#define __CH57x_USBDEV_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* HID<49><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
#define DEF_USB_GET_IDLE 0x02 /* get idle for key or mouse */
|
||||
#define DEF_USB_GET_PROTOCOL 0x03 /* get protocol for bios type */
|
||||
#define DEF_USB_SET_REPORT 0x09 /* set report for key */
|
||||
#define DEF_USB_SET_IDLE 0x0A /* set idle for key or mouse */
|
||||
#define DEF_USB_SET_PROTOCOL 0x0B /* set protocol for bios type */
|
||||
|
||||
/* <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>USBģ<42><C4A3><EFBFBD>շ<EFBFBD>ʹ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>ݻ<EFBFBD><DDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܹ<EFBFBD>9<EFBFBD><39>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD>9<EFBFBD>黺<EFBFBD>棩<EFBFBD><E6A3A9><EFBFBD>û<EFBFBD><C3BB>ɸ<EFBFBD><C9B8><EFBFBD>ʵ<EFBFBD><CAB5>ʹ<EFBFBD>õ<EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
extern uint8_t *pEP0_RAM_Addr; //ep0(64)+ep4_out(64)+ep4_in(64)
|
||||
extern uint8_t *pEP1_RAM_Addr; //ep1_out(64)+ep1_in(64)
|
||||
extern uint8_t *pEP2_RAM_Addr; //ep2_out(64)+ep2_in(64)
|
||||
extern uint8_t *pEP3_RAM_Addr; //ep3_out(64)+ep3_in(64)
|
||||
|
||||
#define pSetupReqPak ((PUSB_SETUP_REQ)pEP0_RAM_Addr)
|
||||
#define pEP0_DataBuf (pEP0_RAM_Addr)
|
||||
#define pEP1_OUT_DataBuf (pEP1_RAM_Addr)
|
||||
#define pEP1_IN_DataBuf (pEP1_RAM_Addr + 64)
|
||||
#define pEP2_OUT_DataBuf (pEP2_RAM_Addr)
|
||||
#define pEP2_IN_DataBuf (pEP2_RAM_Addr + 64)
|
||||
#define pEP3_OUT_DataBuf (pEP3_RAM_Addr)
|
||||
#define pEP3_IN_DataBuf (pEP3_RAM_Addr + 64)
|
||||
#define pEP4_OUT_DataBuf (pEP0_RAM_Addr + 64)
|
||||
#define pEP4_IN_DataBuf (pEP0_RAM_Addr + 128)
|
||||
|
||||
/**
|
||||
* @brief USB<53>豸<EFBFBD><E8B1B8><EFBFBD>ܳ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>4<EFBFBD><34><EFBFBD>˵㣬8<E3A3AC><38>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD>
|
||||
*/
|
||||
void USB_DeviceInit(void);
|
||||
|
||||
/**
|
||||
* @brief USB<53>豸Ӧ<E8B1B8><D3A6><EFBFBD><EFBFBD><EFBFBD>䴦<EFBFBD><E4B4A6>
|
||||
*/
|
||||
void USB_DevTransProcess(void);
|
||||
|
||||
/**
|
||||
* @brief <20>˵<EFBFBD>1<EFBFBD>´<EFBFBD><C2B4><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD>
|
||||
*
|
||||
* @param l - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>(<64B)
|
||||
*/
|
||||
void DevEP1_OUT_Deal(uint8_t l);
|
||||
|
||||
/**
|
||||
* @brief <20>˵<EFBFBD>2<EFBFBD>´<EFBFBD><C2B4><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD>
|
||||
*
|
||||
* @param l - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>(<64B)
|
||||
*/
|
||||
void DevEP2_OUT_Deal(uint8_t l);
|
||||
|
||||
/**
|
||||
* @brief <20>˵<EFBFBD>3<EFBFBD>´<EFBFBD><C2B4><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD>
|
||||
*
|
||||
* @param l - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>(<64B)
|
||||
*/
|
||||
void DevEP3_OUT_Deal(uint8_t l);
|
||||
|
||||
/**
|
||||
* @brief <20>˵<EFBFBD>4<EFBFBD>´<EFBFBD><C2B4><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD>
|
||||
*
|
||||
* @param l - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>(<64B)
|
||||
*/
|
||||
void DevEP4_OUT_Deal(uint8_t l);
|
||||
|
||||
/**
|
||||
* @brief <20>˵<EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>
|
||||
*
|
||||
* @param l - <20>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>(<64B)
|
||||
*/
|
||||
void DevEP1_IN_Deal(uint8_t l);
|
||||
|
||||
/**
|
||||
* @brief <20>˵<EFBFBD>2<EFBFBD><32><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>
|
||||
*
|
||||
* @param l - <20>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>(<64B)
|
||||
*/
|
||||
void DevEP2_IN_Deal(uint8_t l);
|
||||
|
||||
/**
|
||||
* @brief <20>˵<EFBFBD>3<EFBFBD><33><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>
|
||||
*
|
||||
* @param l - <20>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>(<64B)
|
||||
*/
|
||||
void DevEP3_IN_Deal(uint8_t l);
|
||||
|
||||
/**
|
||||
* @brief <20>˵<EFBFBD>4<EFBFBD><34><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>
|
||||
*
|
||||
* @param l - <20>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>(<64B)
|
||||
*/
|
||||
void DevEP4_IN_Deal(uint8_t l);
|
||||
|
||||
/**
|
||||
* @brief <20><>ѯ<EFBFBD>˵<EFBFBD>1<EFBFBD>Ƿ<EFBFBD><C7B7>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @return 0-δ<><CEB4><EFBFBD><EFBFBD> (!0)-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
#define EP1_GetINSta() (R8_UEP1_CTRL & UEP_T_RES_NAK)
|
||||
|
||||
/**
|
||||
* @brief <20><>ѯ<EFBFBD>˵<EFBFBD>2<EFBFBD>Ƿ<EFBFBD><C7B7>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @return 0-δ<><CEB4><EFBFBD><EFBFBD> (!0)-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
#define EP2_GetINSta() (R8_UEP2_CTRL & UEP_T_RES_NAK)
|
||||
|
||||
/**
|
||||
* @brief <20><>ѯ<EFBFBD>˵<EFBFBD>3<EFBFBD>Ƿ<EFBFBD><C7B7>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @return 0-δ<><CEB4><EFBFBD><EFBFBD> (!0)-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
#define EP3_GetINSta() (R8_UEP3_CTRL & UEP_T_RES_NAK)
|
||||
|
||||
/**
|
||||
* @brief <20><>ѯ<EFBFBD>˵<EFBFBD>4<EFBFBD>Ƿ<EFBFBD><C7B7>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @return 0-δ<><CEB4><EFBFBD><EFBFBD> (!0)-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
#define EP4_GetINSta() (R8_UEP4_CTRL & UEP_T_RES_NAK)
|
||||
|
||||
/**
|
||||
* @brief <20>ر<EFBFBD>USB<53><42><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
#define USB_DisablePin() (R16_PIN_ANALOG_IE &= ~(RB_PIN_USB_IE | RB_PIN_USB_DP_PU))
|
||||
|
||||
/**
|
||||
* @brief <20>ر<EFBFBD>USB
|
||||
*/
|
||||
#define USB_Disable() (R32_USB_CONTROL = 0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __CH57x_USBDEV_H__
|
||||
314
BLV_RF_W13_V04_20260114/StdPeriphDriver/inc/CH57x_usbhost.h
Normal file
314
BLV_RF_W13_V04_20260114/StdPeriphDriver/inc/CH57x_usbhost.h
Normal file
@@ -0,0 +1,314 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH57x_usbhost.h
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2021/11/17
|
||||
* Description : head file(ch572/ch570)
|
||||
*********************************************************************************
|
||||
* 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 __CH57x_USBHOST_H__
|
||||
#define __CH57x_USBHOST_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if DISK_LIB_ENABLE
|
||||
#if DISK_WITHOUT_USB_HUB
|
||||
/* <20><>ʹ<EFBFBD><CAB9>U<EFBFBD><55><EFBFBD>ļ<EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>U<EFBFBD>̹<EFBFBD><CCB9><EFBFBD>USBhub<75><62><EFBFBD>棬<EFBFBD><E6A3AC>Ҫ<EFBFBD>ر<EFBFBD><D8B1><EFBFBD><EFBFBD>涨<EFBFBD><E6B6A8> */
|
||||
#define FOR_ROOT_UDISK_ONLY
|
||||
#endif
|
||||
/* ʹ<><CAB9>U<EFBFBD><55><EFBFBD>ļ<EFBFBD>ϵͳ<CFB5>⣬<EFBFBD><E2A3AC>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>涨<EFBFBD><E6B6A8>, <20><>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD> */
|
||||
#define DISK_BASE_BUF_LEN 512 /* Ĭ<>ϵĴ<CFB5><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݻ<EFBFBD><DDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>СΪ512<31>ֽ<EFBFBD>,<2C><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>Ϊ2048<34><38><EFBFBD><EFBFBD>4096<39><36>֧<EFBFBD><D6A7>ijЩ<C4B3><D0A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>U<EFBFBD><55>,Ϊ0<CEAA><30><EFBFBD><EFBFBD>ֹ<EFBFBD><D6B9>.H<>ļ<EFBFBD><C4BC>ж<EFBFBD><D0B6>建<EFBFBD><E5BBBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD>pDISK_BASE_BUF<55><46>ָ<EFBFBD><D6B8> */
|
||||
#endif
|
||||
|
||||
// <20><><EFBFBD>ӳ<EFBFBD><D3B3><EFBFBD>״̬<D7B4><CCAC>
|
||||
#define ERR_SUCCESS 0x00 // <20><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>
|
||||
#define ERR_USB_CONNECT 0x15 /* <20><><EFBFBD>USB<53>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>,<2C>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD> */
|
||||
#define ERR_USB_DISCON 0x16 /* <20><><EFBFBD>USB<53>豸<EFBFBD>Ͽ<EFBFBD><CFBF>¼<EFBFBD>,<2C>Ѿ<EFBFBD><D1BE>Ͽ<EFBFBD> */
|
||||
#define ERR_USB_BUF_OVER 0x17 /* USB<53><42><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̫<EFBFBD><EFBFBD><E0BBBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
#define ERR_USB_DISK_ERR 0x1F /* USB<53>洢<EFBFBD><E6B4A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>,<2C>ڳ<EFBFBD>ʼ<EFBFBD><CABC>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>USB<53>洢<EFBFBD><E6B4A2><EFBFBD><EFBFBD>֧<EFBFBD><D6A7>,<2C>ڶ<EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>п<EFBFBD><D0BF><EFBFBD><EFBFBD>Ǵ<EFBFBD><C7B4><EFBFBD><EFBFBD><EFBFBD><F0BBB5BB><EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE>Ͽ<EFBFBD> */
|
||||
#define ERR_USB_TRANSFER 0x20 /* NAK/STALL<4C>ȸ<EFBFBD><C8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0x20~0x2F */
|
||||
#define ERR_USB_UNSUPPORT 0xFB /* <20><>֧<EFBFBD>ֵ<EFBFBD>USB<53>豸*/
|
||||
#define ERR_USB_UNKNOWN 0xFE /* <20>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
#define ERR_AOA_PROTOCOL 0x41 /* Э<><D0AD><EFBFBD>汾<EFBFBD><E6B1BE><EFBFBD><EFBFBD> */
|
||||
|
||||
/*USB<53>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>,<2C><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7>1<EFBFBD><31><EFBFBD>豸*/
|
||||
#define ROOT_DEV_DISCONNECT 0
|
||||
#define ROOT_DEV_CONNECTED 1
|
||||
#define ROOT_DEV_FAILED 2
|
||||
#define ROOT_DEV_SUCCESS 3
|
||||
#define DEV_TYPE_KEYBOARD (USB_DEV_CLASS_HID | 0x20)
|
||||
#define DEV_TYPE_MOUSE (USB_DEV_CLASS_HID | 0x30)
|
||||
#define DEF_AOA_DEVICE 0xF0
|
||||
#define DEV_TYPE_UNKNOW 0xFF
|
||||
|
||||
/*
|
||||
Լ<EFBFBD><EFBFBD>: USB<53>豸<EFBFBD><E8B1B8>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28>ο<EFBFBD>USB_DEVICE_ADDR)
|
||||
<EFBFBD><EFBFBD>ֵַ <20>豸λ<E8B1B8><CEBB>
|
||||
0x02 <20><><EFBFBD><EFBFBD>Root-HUB<55>µ<EFBFBD>USB<53>豸<EFBFBD><E8B1B8><EFBFBD>ⲿHUB
|
||||
0x1x <20><><EFBFBD><EFBFBD>Root-HUB<55>µ<EFBFBD><C2B5>ⲿHUB<55>Ķ˿<C4B6>x<EFBFBD>µ<EFBFBD>USB<53>豸,xΪ1~n
|
||||
*/
|
||||
#define HUB_MAX_PORTS 4
|
||||
#define WAIT_USB_TOUT_200US 800 // <20>ȴ<EFBFBD>USB<53>жϳ<D0B6>ʱʱ<CAB1><CAB1>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t DeviceStatus; // <20>豸״̬,0-<2D><><EFBFBD>豸,1-<2D><><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>δ<EFBFBD><CEB4>ʼ<EFBFBD><CABC>,2-<2D><><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ö<EFBFBD><C3B6>ʧ<EFBFBD><CAA7>,3-<2D><><EFBFBD>豸<EFBFBD>ҳ<EFBFBD>ʼ<EFBFBD><CABC>ö<EFBFBD>ٳɹ<D9B3>
|
||||
uint8_t DeviceAddress; // <20>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>USB<53><42>ַ
|
||||
uint8_t DeviceSpeed; // 0Ϊ<30><CEAA><EFBFBD><EFBFBD>,<2C><>0Ϊȫ<CEAA><C8AB>
|
||||
uint8_t DeviceType; // <20>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||||
uint16_t DeviceVID;
|
||||
uint16_t DevicePID;
|
||||
uint8_t GpVar[4]; // ͨ<>ñ<EFBFBD><C3B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŷ˵<C5B6>
|
||||
uint8_t GpHUBPortNum; // ͨ<>ñ<EFBFBD><C3B1><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>HUB<55><42><EFBFBD><EFBFBD>ʾHUB<55>˿<EFBFBD><CBBF><EFBFBD>
|
||||
} _RootHubDev;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t DeviceStatus; // <20>豸״̬,0-<2D><><EFBFBD>豸,1-<2D><><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>δ<EFBFBD><CEB4>ʼ<EFBFBD><CABC>,2-<2D><><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ö<EFBFBD><C3B6>ʧ<EFBFBD><CAA7>,3-<2D><><EFBFBD>豸<EFBFBD>ҳ<EFBFBD>ʼ<EFBFBD><CABC>ö<EFBFBD>ٳɹ<D9B3>
|
||||
uint8_t DeviceAddress; // <20>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>USB<53><42>ַ
|
||||
uint8_t DeviceSpeed; // 0Ϊ<30><CEAA><EFBFBD><EFBFBD>,<2C><>0Ϊȫ<CEAA><C8AB>
|
||||
uint8_t DeviceType; // <20>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||||
uint16_t DeviceVID;
|
||||
uint16_t DevicePID;
|
||||
uint8_t GpVar[4]; // ͨ<>ñ<EFBFBD><C3B1><EFBFBD>
|
||||
} _DevOnHubPort; // <20>ٶ<EFBFBD>:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><31><EFBFBD>ⲿHUB,ÿ<><C3BF><EFBFBD>ⲿHUB<55><42><EFBFBD><EFBFBD><EFBFBD><EFBFBD>HUB_MAX_PORTS<54><53><EFBFBD>˿<EFBFBD>(<28><><EFBFBD>˲<EFBFBD><CBB2><EFBFBD>)
|
||||
|
||||
extern _RootHubDev ThisUsbDev;
|
||||
extern _DevOnHubPort DevOnHubPort[HUB_MAX_PORTS]; // <20>ٶ<EFBFBD>:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><31><EFBFBD>ⲿHUB,ÿ<><C3BF><EFBFBD>ⲿHUB<55><42><EFBFBD><EFBFBD><EFBFBD><EFBFBD>HUB_MAX_PORTS<54><53><EFBFBD>˿<EFBFBD>(<28><><EFBFBD>˲<EFBFBD><CBB2><EFBFBD>)
|
||||
extern uint8_t UsbDevEndp0Size; // USB<53>豸<EFBFBD>Ķ˵<C4B6>0<EFBFBD><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߴ<EFBFBD> */
|
||||
extern uint8_t FoundNewDev;
|
||||
|
||||
extern uint8_t *pHOST_RX_RAM_Addr;
|
||||
extern uint8_t *pHOST_TX_RAM_Addr;
|
||||
|
||||
extern _RootHubDev ThisUsb2Dev;
|
||||
extern _DevOnHubPort DevOnU2HubPort[HUB_MAX_PORTS]; // <20>ٶ<EFBFBD>:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><31><EFBFBD>ⲿHUB,ÿ<><C3BF><EFBFBD>ⲿHUB<55><42><EFBFBD><EFBFBD><EFBFBD><EFBFBD>HUB_MAX_PORTS<54><53><EFBFBD>˿<EFBFBD>(<28><><EFBFBD>˲<EFBFBD><CBB2><EFBFBD>)
|
||||
extern uint8_t Usb2DevEndp0Size; // USB<53>豸<EFBFBD>Ķ˵<C4B6>0<EFBFBD><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߴ<EFBFBD> */
|
||||
extern uint8_t FoundNewU2Dev;
|
||||
|
||||
extern uint8_t *pU2HOST_RX_RAM_Addr;
|
||||
extern uint8_t *pU2HOST_TX_RAM_Addr;
|
||||
|
||||
#define pSetupReq ((PUSB_SETUP_REQ)pHOST_TX_RAM_Addr)
|
||||
#define pU2SetupReq ((PUSB_SETUP_REQ)pU2HOST_TX_RAM_Addr)
|
||||
extern uint8_t Com_Buffer[];
|
||||
extern uint8_t U2Com_Buffer[];
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD>ΪUSB<53><42><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
extern const uint8_t SetupGetDevDescr[]; // <20><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
extern const uint8_t SetupGetCfgDescr[]; // <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
extern const uint8_t SetupSetUsbAddr[]; // <20><><EFBFBD><EFBFBD>USB<53><42>ַ*/
|
||||
extern const uint8_t SetupSetUsbConfig[]; // <20><><EFBFBD><EFBFBD>USB<53><42><EFBFBD><EFBFBD>*/
|
||||
extern const uint8_t SetupSetUsbInterface[]; // <20><><EFBFBD><EFBFBD>USB<53>ӿ<EFBFBD><D3BF><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
extern const uint8_t SetupClrEndpStall[]; // <20><><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD>STALL*/
|
||||
|
||||
extern const uint8_t SetupGetU2DevDescr[]; // <20><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
extern const uint8_t SetupGetU2CfgDescr[]; // <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
extern const uint8_t SetupSetUsb2Addr[]; // <20><><EFBFBD><EFBFBD>USB<53><42>ַ*/
|
||||
extern const uint8_t SetupSetUsb2Config[]; // <20><><EFBFBD><EFBFBD>USB<53><42><EFBFBD><EFBFBD>*/
|
||||
extern const uint8_t SetupSetUsb2Interface[]; // <20><><EFBFBD><EFBFBD>USB<53>ӿ<EFBFBD><D3BF><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
extern const uint8_t SetupClrU2EndpStall[]; // <20><><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD>STALL*/
|
||||
|
||||
/**
|
||||
* @brief <20>ر<EFBFBD>ROOT-HUB<55>˿<EFBFBD>,ʵ<><CAB5><EFBFBD><EFBFBD>Ӳ<EFBFBD><D3B2><EFBFBD>Ѿ<EFBFBD><D1BE>Զ<EFBFBD><D4B6>ر<EFBFBD>,<2C>˴<EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һЩ<D2BB>ṹ״̬
|
||||
*/
|
||||
void DisableRootHubPort(void);
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD>ROOT-HUB״̬,<2C><><EFBFBD><EFBFBD>ROOT-HUB<55>˿ڵ<CBBF><DAB5>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD>γ<EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD>DisableRootHubPort()<29><><EFBFBD><EFBFBD>,<2C><><EFBFBD>˿ڹر<DAB9>,<2C><><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>,<2C><><EFBFBD><EFBFBD>Ӧ<EFBFBD>˿ڵ<CBBF>״̬λ
|
||||
*
|
||||
* @return <20><><EFBFBD><EFBFBD>ERR_SUCCESSΪû<CEAA><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>ERR_USB_CONNECTΪ<54><CEAA><EFBFBD><EFBFBD><E2B5BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>ERR_USB_DISCONΪ<4E><CEAA><EFBFBD><EFBFBD>Ͽ<EFBFBD>
|
||||
*/
|
||||
uint8_t AnalyzeRootHub(void);
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD>USB<53><42><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>USB<53>豸<EFBFBD><E8B1B8>ַ
|
||||
*
|
||||
* @param addr - USB<53>豸<EFBFBD><E8B1B8>ַ
|
||||
*/
|
||||
void SetHostUsbAddr(uint8_t addr);
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD>õ<EFBFBD>ǰUSB<53>ٶ<EFBFBD>
|
||||
*
|
||||
* @param FullSpeed - USB<53>ٶ<EFBFBD>
|
||||
*/
|
||||
void SetUsbSpeed(uint8_t FullSpeed);
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8>,<2C><>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>,Ϊö<CEAA><C3B6><EFBFBD>豸<E8B1B8><D7BC>,<2C><><EFBFBD><EFBFBD>ΪĬ<CEAA><C4AC>Ϊȫ<CEAA><C8AB>
|
||||
*/
|
||||
void ResetRootHubPort(void);
|
||||
|
||||
/**
|
||||
* @brief ʹ<><CAB9>ROOT-HUB<55>˿<EFBFBD>,<2C><>Ӧ<EFBFBD><D3A6>bUH_PORT_EN<45><4E>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>,<2C>豸<EFBFBD>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD>ܵ<EFBFBD><DCB5>·<EFBFBD><C2B7><EFBFBD>ʧ<EFBFBD><CAA7>
|
||||
*
|
||||
* @return <20><><EFBFBD><EFBFBD>ERR_SUCCESSΪ<53><CEAA><EFBFBD><EFBFBD><E2B5BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>ERR_USB_DISCONΪ<4E><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
uint8_t EnableRootHubPort(void);
|
||||
|
||||
/**
|
||||
* @brief <20>ȴ<EFBFBD>USB<53>ж<EFBFBD>
|
||||
*
|
||||
* @return <20><><EFBFBD><EFBFBD>ERR_SUCCESS <20><><EFBFBD>ݽ<EFBFBD><DDBD>ջ<EFBFBD><D5BB>߷<EFBFBD><DFB7>ͳɹ<CDB3>,<2C><><EFBFBD><EFBFBD>ERR_USB_UNKNOWN <20><><EFBFBD>ݽ<EFBFBD><DDBD>ջ<EFBFBD><D5BB>߷<EFBFBD><DFB7><EFBFBD>ʧ<EFBFBD><CAA7>
|
||||
*/
|
||||
uint8_t WaitUSB_Interrupt(void);
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>Ŀ<EFBFBD>Ķ˵<C4B6><CBB5><EFBFBD>ַ/PID<49><44><EFBFBD><EFBFBD>,ͬ<><CDAC><EFBFBD><EFBFBD>־,<2C><>20uSΪ<53><CEAA>λ<EFBFBD><CEBB>NAK<41><4B><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>(0<><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0xFFFF<46><46><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>),<2C><><EFBFBD><EFBFBD>0<EFBFBD>ɹ<EFBFBD>,<2C><>ʱ/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <20><><EFBFBD>ӳ<EFBFBD><D3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>,Ϊ<><CEAA><EFBFBD>ṩ<EFBFBD><E1B9A9><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>,Ӧ<>öԱ<C3B6><D4B1>ӳ<EFBFBD><D3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ż<EFBFBD>
|
||||
*
|
||||
* @param endp_pid - <20><><EFBFBD>ƺ͵<C6BA>ַ, <20><>4λ<34><CEBB>token_pid<69><64><EFBFBD><EFBFBD>, <20><>4λ<34>Ƕ˵<C7B6><CBB5><EFBFBD>ַ
|
||||
* @param tog - ͬ<><CDAC><EFBFBD><EFBFBD>־
|
||||
* @param timeout - <20><>ʱʱ<CAB1><CAB1>
|
||||
*
|
||||
* @return ERR_USB_UNKNOWN <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӳ<EFBFBD><D3B2><EFBFBD>쳣
|
||||
* ERR_USB_DISCON <20>豸<EFBFBD>Ͽ<EFBFBD>
|
||||
* ERR_USB_CONNECT <20>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||||
* ERR_SUCCESS <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
uint8_t USBHostTransact(uint8_t endp_pid, uint8_t tog, uint32_t timeout);
|
||||
|
||||
/**
|
||||
* @brief ִ<>п<EFBFBD><D0BF>ƴ<EFBFBD><C6B4><EFBFBD>,8<>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>pSetupReq<65><71>,DataBufΪ<66><CEAA>ѡ<EFBFBD><D1A1><EFBFBD>շ<EFBFBD><D5B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param DataBuf - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>պͷ<D5BA><CDB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><>ôDataBuf<75><66>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><DAB4>ź<EFBFBD><C5BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @param RetLen - ʵ<>ʳɹ<CAB3><C9B9>շ<EFBFBD><D5B7><EFBFBD><EFBFBD>ܳ<EFBFBD><DCB3>ȱ<EFBFBD><C8B1><EFBFBD><EFBFBD><EFBFBD>RetLenָ<6E><D6B8><EFBFBD><EFBFBD><EFBFBD>ֽڱ<D6BD><DAB1><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @return ERR_USB_BUF_OVER IN״̬<D7B4>γ<D7B6><CEB3><EFBFBD>
|
||||
* ERR_SUCCESS <20><><EFBFBD>ݽ<EFBFBD><DDBD><EFBFBD><EFBFBD>ɹ<EFBFBD>
|
||||
*/
|
||||
uint8_t HostCtrlTransfer(uint8_t *DataBuf, uint8_t *RetLen);
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD>ƿ<EFBFBD><C6BF>ƴ<EFBFBD><C6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param pReqPkt - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
||||
*/
|
||||
void CopySetupReqPkg(const uint8_t *pReqPkt);
|
||||
|
||||
/**
|
||||
* @brief <20><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> pHOST_TX_RAM_Addr <20><>
|
||||
*
|
||||
* @return ERR_USB_BUF_OVER <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD><C8B4><EFBFBD>
|
||||
* ERR_SUCCESS <20>ɹ<EFBFBD>
|
||||
*/
|
||||
uint8_t CtrlGetDeviceDescr(void);
|
||||
|
||||
/**
|
||||
* @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> pHOST_TX_RAM_Addr <20><>
|
||||
*
|
||||
* @return ERR_USB_BUF_OVER <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD><C8B4><EFBFBD>
|
||||
* ERR_SUCCESS <20>ɹ<EFBFBD>
|
||||
*/
|
||||
uint8_t CtrlGetConfigDescr(void);
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD>USB<53>豸<EFBFBD><E8B1B8>ַ
|
||||
*
|
||||
* @param addr - <20>豸<EFBFBD><E8B1B8>ַ
|
||||
*
|
||||
* @return ERR_SUCCESS <20>ɹ<EFBFBD>
|
||||
*/
|
||||
uint8_t CtrlSetUsbAddress(uint8_t addr);
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD>USB<53>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param cfg - <20><><EFBFBD><EFBFBD>ֵ
|
||||
*
|
||||
* @return ERR_SUCCESS <20>ɹ<EFBFBD>
|
||||
*/
|
||||
uint8_t CtrlSetUsbConfig(uint8_t cfg);
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD>STALL
|
||||
*
|
||||
* @param endp - <20>˵<EFBFBD><CBB5><EFBFBD>ַ
|
||||
*
|
||||
* @return ERR_SUCCESS <20>ɹ<EFBFBD>
|
||||
*/
|
||||
uint8_t CtrlClearEndpStall(uint8_t endp);
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD>USB<53>豸<EFBFBD>ӿ<EFBFBD>
|
||||
*
|
||||
* @param cfg - <20><><EFBFBD><EFBFBD>ֵ
|
||||
*
|
||||
* @return ERR_SUCCESS <20>ɹ<EFBFBD>
|
||||
*/
|
||||
uint8_t CtrlSetUsbIntercace(uint8_t cfg);
|
||||
|
||||
/**
|
||||
* @brief USB<53><42><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD>ʼ<EFBFBD><CABC>
|
||||
*/
|
||||
void USB_HostInit(void);
|
||||
uint8_t EnumAllHubPort(void);// ö<><C3B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ROOT-HUB<55>˿<EFBFBD><CBBF><EFBFBD><EFBFBD>ⲿHUB<55><42><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>USB<53>豸
|
||||
void SelectHubPort(uint8_t HubPortIndex); // HubPortIndex=0ѡ<30><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>ROOT-HUB<55>˿<EFBFBD>,<2C><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>ROOT-HUB<55>˿ڵ<CBBF><DAB5>ⲿHUB<55><42>ָ<EFBFBD><D6B8><EFBFBD>˿<EFBFBD>
|
||||
uint16_t SearchTypeDevice(uint8_t type); // <20><>ROOT-HUB<55>Լ<EFBFBD><D4BC>ⲿHUB<55><42><EFBFBD>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><CDB5>豸<EFBFBD><E8B1B8><EFBFBD>ڵĶ˿ں<CBBF>,<2C><><EFBFBD><EFBFBD><EFBFBD>˿ں<CBBF>Ϊ0xFFFF<46><46>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||
uint8_t SETorOFFNumLock(uint8_t *buf); // NumLock<63>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD>ж<EFBFBD>
|
||||
|
||||
/*************************************************************/
|
||||
|
||||
/**
|
||||
* @brief <20><>ʼ<EFBFBD><CABC>ָ<EFBFBD><D6B8>ROOT-HUB<55>˿ڵ<CBBF>USB<53>豸
|
||||
*
|
||||
* @return <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
uint8_t InitRootDevice(void);
|
||||
|
||||
/**
|
||||
* @brief <20><>ȡHID<49>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>TxBuffer<65><72>
|
||||
*
|
||||
* @return <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
uint8_t CtrlGetHIDDeviceReport(uint8_t infc);
|
||||
|
||||
/**
|
||||
* @brief <20><>ȡHUB<55><42><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Com_Buffer<65><72>
|
||||
*
|
||||
* @return <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
uint8_t CtrlGetHubDescr(void);
|
||||
|
||||
/**
|
||||
* @brief <20><>ѯHUB<55>˿<EFBFBD>״̬,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Com_Buffer<65><72>
|
||||
*
|
||||
* @param HubPortIndex - <20>˿ں<CBBF>
|
||||
*
|
||||
* @return <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
uint8_t HubGetPortStatus(uint8_t HubPortIndex);
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD>HUB<55>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param HubPortIndex - <20>˿ں<CBBF>
|
||||
* @param FeatureSelt - <20>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @return <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
uint8_t HubSetPortFeature(uint8_t HubPortIndex, uint8_t FeatureSelt);
|
||||
|
||||
/**
|
||||
* @brief <20><><EFBFBD><EFBFBD>HUB<55>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param HubPortIndex - <20>˿ں<CBBF>
|
||||
* @param FeatureSelt - <20>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @return <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
uint8_t HubClearPortFeature(uint8_t HubPortIndex, uint8_t FeatureSelt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __CH57x_USBHOST_H__
|
||||
130
BLV_RF_W13_V04_20260114/StdPeriphDriver/inc/ISP572.h
Normal file
130
BLV_RF_W13_V04_20260114/StdPeriphDriver/inc/ISP572.h
Normal file
@@ -0,0 +1,130 @@
|
||||
/* CH572 Flash-ROM & Data-Flash */
|
||||
/* Website: http://wch.cn */
|
||||
/* Email: tech@wch.cn */
|
||||
/* Author: W.ch 2024.12 */
|
||||
/* V1.0 FlashROM library for USER/BOOT */
|
||||
/* for the target in USER code area on the chip divided into USER code area and BOOT area */
|
||||
/* <20><><EFBFBD>ھ<EFBFBD><DABE><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>оƬ<D0BE><C6AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>Ϊ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD>ã<EFBFBD>IAP<41><50><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>룩 */
|
||||
|
||||
/* Flash-ROM feature:
|
||||
for store program code, support block erasing, dword and page writing, dword verifying, unit for Length is byte,
|
||||
minimal quantity for write or verify is one dword (4-bytes),
|
||||
256 bytes/page for writing, FLASH_ROM_WRITE support one dword or more dword writing, but multiple of 256 is the best,
|
||||
4KB (4096 bytes) bytes/block for erasing, so multiple of 4096 is the best */
|
||||
|
||||
#ifndef FLASH_MIN_WR_SIZE
|
||||
#define FLASH_MIN_WR_SIZE 4 // Flash-ROM minimal size for writing
|
||||
#endif
|
||||
#ifndef FLASH_ROM_MAX_SIZE
|
||||
#define FLASH_ROM_MAX_SIZE 0x03C000 // Flash-ROM maximum program size, 240KB
|
||||
#endif
|
||||
#ifndef FLASH_BLOCK_SIZE
|
||||
#define FLASH_BLOCK_SIZE 4096
|
||||
#endif
|
||||
// CMD_* for caller from FlashROM or RAM, auto execute CMD_FLASH_ROM_SW_RESET before command
|
||||
#ifndef CMD_FLASH_ROM_SW_RESET
|
||||
#define CMD_FLASH_ROM_START_IO 0x00 // start FlashROM I/O, without parameter
|
||||
#define CMD_FLASH_ROM_SW_RESET 0x04 // software reset FlashROM, without parameter
|
||||
#define CMD_GET_ROM_INFO 0x06 // get information from FlashROM, parameter @Address,Buffer
|
||||
#define CMD_GET_UNIQUE_ID 0x07 // get 64 bit unique ID, parameter @Buffer
|
||||
#define CMD_FLASH_ROM_PWR_DOWN 0x0D // power-down FlashROM, without parameter
|
||||
#define CMD_FLASH_ROM_PWR_UP 0x0C // power-up FlashROM, without parameter
|
||||
#define CMD_FLASH_ROM_ERASE 0x01 // erase FlashROM block, return 0 if success, parameter @StartAddr,Length
|
||||
#define CMD_FLASH_ROM_WRITE 0x02 // write FlashROM data block, minimal block is dword, return 0 if success, parameter @StartAddr,Buffer,Length
|
||||
#define CMD_FLASH_ROM_VERIFY 0x03 // read FlashROM data block, minimal block is dword, return 0 if success, parameter @StartAddr,Buffer,Length
|
||||
#endif
|
||||
|
||||
#define ROM_CFG_MAC_ADDR 0x3F018 // address for MAC address information
|
||||
#define ROM_CFG_BOOT_INFO 0x3DFF8 // address for BOOT information
|
||||
|
||||
/**
|
||||
* @brief execute Flash/EEPROM command, caller from FlashROM or RAM
|
||||
*
|
||||
* @param cmd - CMD_* for caller from FlashROM or RAM.
|
||||
* @param StartAddr - Address of the data to be process.
|
||||
* @param Buffer - Pointer to the buffer where data should be process, Must in RAM and be aligned to 4 bytes.
|
||||
* @param Length - Size of data to be process, in bytes.
|
||||
*
|
||||
* @return 0-SUCCESS (!0)-FAILURE
|
||||
*/
|
||||
extern uint32_t FLASH_EEPROM_CMD( uint8_t cmd, uint32_t StartAddr, void *Buffer, uint32_t Length );
|
||||
|
||||
/**
|
||||
* @brief start FlashROM I/O
|
||||
*
|
||||
* @return 0-SUCCESS (!0)-FAILURE
|
||||
*/
|
||||
#define FLASH_ROM_START_IO( ) FLASH_EEPROM_CMD( CMD_FLASH_ROM_START_IO, 0, NULL, 0 )
|
||||
|
||||
/**
|
||||
* @brief software reset FlashROM
|
||||
*
|
||||
* @return 0-SUCCESS (!0)-FAILURE
|
||||
*/
|
||||
#define FLASH_ROM_SW_RESET( ) FLASH_EEPROM_CMD( CMD_FLASH_ROM_SW_RESET, 0, NULL, 0 )
|
||||
|
||||
/**
|
||||
* @brief get 6 bytes MAC address
|
||||
*
|
||||
* @param Buffer - Pointer to the buffer where data should be stored, Must in RAM and be aligned to 4 bytes.
|
||||
*
|
||||
* @return 0-SUCCESS (!0)-FAILURE
|
||||
*/
|
||||
#define GetMACAddress(Buffer) FLASH_EEPROM_CMD( CMD_GET_ROM_INFO, ROM_CFG_MAC_ADDR, Buffer, 0 )
|
||||
|
||||
/**
|
||||
* @brief get 8 bytes BOOT information
|
||||
*
|
||||
* @param Buffer - Pointer to the buffer where data should be stored, Must in RAM and be aligned to 4 bytes.
|
||||
*
|
||||
* @return 0-SUCCESS (!0)-FAILURE
|
||||
*/
|
||||
#define GET_BOOT_INFO(Buffer) FLASH_EEPROM_CMD( CMD_GET_ROM_INFO, ROM_CFG_BOOT_INFO, Buffer, 0 )
|
||||
|
||||
/**
|
||||
* @brief power-down FlashROM
|
||||
*
|
||||
* @return 0-SUCCESS (!0)-FAILURE
|
||||
*/
|
||||
#define FLASH_ROM_PWR_DOWN( ) FLASH_EEPROM_CMD( CMD_FLASH_ROM_PWR_DOWN, 0, NULL, 0 )
|
||||
|
||||
/**
|
||||
* @brief power-up FlashROM
|
||||
*
|
||||
* @return 0-SUCCESS (!0)-FAILURE
|
||||
*/
|
||||
#define FLASH_ROM_PWR_UP( ) FLASH_EEPROM_CMD( CMD_FLASH_ROM_PWR_UP, 0, NULL, 0 )
|
||||
|
||||
/**
|
||||
* @brief erase FlashROM block
|
||||
*
|
||||
* @param StartAddr - Address of the data to be erased.
|
||||
* @param Length - Size of data to be erased, in bytes.
|
||||
*
|
||||
* @return 0-SUCCESS (!0)-FAILURE
|
||||
*/
|
||||
#define FLASH_ROM_ERASE(StartAddr,Length) FLASH_EEPROM_CMD( CMD_FLASH_ROM_ERASE, StartAddr, NULL, Length )
|
||||
|
||||
/**
|
||||
* @brief write FlashROM data block, minimal block is dword.
|
||||
*
|
||||
* @param StartAddr - Address of the data to be written.
|
||||
* @param Buffer - Pointer to the source buffer, Must in RAM and be aligned to 4 bytes.
|
||||
* @param Length - Size of data to be written, in bytes.
|
||||
*
|
||||
* @return 0-SUCCESS (!0)-FAILURE
|
||||
*/
|
||||
#define FLASH_ROM_WRITE(StartAddr,Buffer,Length) FLASH_EEPROM_CMD( CMD_FLASH_ROM_WRITE, StartAddr, Buffer, Length )
|
||||
|
||||
/**
|
||||
* @brief verify FlashROM data block, minimal block is dword.
|
||||
*
|
||||
* @param StartAddr - Address of the data to verify.
|
||||
* @param Buffer - Pointer to the source buffer, Must in RAM and be aligned to 4 bytes.
|
||||
* @param Length - Size of data to verify, in bytes.
|
||||
*
|
||||
* @return 0-SUCCESS (!0)-FAILURE
|
||||
*/
|
||||
#define FLASH_ROM_VERIFY(StartAddr,Buffer,Length) FLASH_EEPROM_CMD( CMD_FLASH_ROM_VERIFY, StartAddr, Buffer, Length )
|
||||
|
||||
BIN
BLV_RF_W13_V04_20260114/StdPeriphDriver/libISP572.a
Normal file
BIN
BLV_RF_W13_V04_20260114/StdPeriphDriver/libISP572.a
Normal file
Binary file not shown.
30
BLV_RF_W13_V04_20260114/User/include/includes.h
Normal file
30
BLV_RF_W13_V04_20260114/User/include/includes.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef _INCLUDES_H_
|
||||
#define _INCLUDES_H_
|
||||
|
||||
#include "CH57x_common.h"
|
||||
#include "CONFIG.h"
|
||||
#include "HAL.h"
|
||||
#include "gattprofile.h"
|
||||
#include "peripheral.h"
|
||||
#include "debug.h"
|
||||
#include "uart.h"
|
||||
#include "sensor_scan.h"
|
||||
#include "flash.h"
|
||||
|
||||
#define FW_Version 0x04
|
||||
#define EE_Version 0x04
|
||||
|
||||
/********************
|
||||
* <20><>periphera.c<>ļ<EFBFBD><C4BC>е<EFBFBD> static uint8_t scanRspData[] <20><><EFBFBD><EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*
|
||||
*
|
||||
* */
|
||||
|
||||
|
||||
|
||||
|
||||
extern volatile uint32_t SysTick_100us;
|
||||
extern volatile uint32_t SysTick_1ms;
|
||||
extern volatile uint32_t SysTick_1s;
|
||||
|
||||
#endif
|
||||
71
BLV_RF_W13_V04_20260114/User/main.c
Normal file
71
BLV_RF_W13_V04_20260114/User/main.c
Normal file
@@ -0,0 +1,71 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : main.c
|
||||
* Author : WCH
|
||||
* Version : V1.1
|
||||
* Date : 2026/01/14
|
||||
* Description : <20><><EFBFBD><EFBFBD><EFBFBD>ӻ<EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3>ʼ<EFBFBD><CABC>
|
||||
*******************************************************************************/
|
||||
|
||||
/******************************************************************************/
|
||||
/* ͷ<>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD> */
|
||||
#include "../User/include/includes.h"
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
* GLOBAL TYPEDEFS
|
||||
*/
|
||||
__attribute__((aligned(4))) uint32_t MEM_BUF[BLE_MEMHEAP_SIZE / 4];
|
||||
|
||||
#if(defined(BLE_MAC)) && (BLE_MAC == TRUE)
|
||||
const uint8_t MacAddr[6] = {0x84, 0xC2, 0xE4, 0x03, 0x02, 0x02};
|
||||
#endif
|
||||
|
||||
|
||||
#define ceshi 0x00
|
||||
|
||||
/*********************************************************************
|
||||
* @fn main
|
||||
* @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @return none
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
HSECFG_Capacitance(HSECap_18p);
|
||||
SetSysClock(CLK_SOURCE_HSE_PLL_100MHz);
|
||||
#if(defined(HAL_SLEEP)) && (HAL_SLEEP == TRUE)
|
||||
GPIOA_ModeCfg(GPIO_Pin_All, GPIO_ModeIN_PU);
|
||||
#endif
|
||||
WDT_Init();
|
||||
|
||||
UARTx_Init(UART_0,115200,BLV_DETInfo_Recv_Processing); //RS485ͨѶ<CDA8><D1B6><EFBFBD><EFBFBD>
|
||||
|
||||
CH57x_BLEInit(); //<2F><>ʼ<EFBFBD><CABC> BLE Э<><D0AD>ջ<EFBFBD>ײ<EFBFBD>
|
||||
HAL_Init(); //<2F><>ʼ<EFBFBD><CABC>Ӳ<EFBFBD><D3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㣨HAL<41><4C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>оƬ<D0BE><C6AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>衣
|
||||
GAPRole_PeripheralInit(); //<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>裨Peripheral<61><6C><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB> GAP <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
EEPROM_Init();
|
||||
Peripheral_Init(); //Ӧ<>ò<EFBFBD><C3B2>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
|
||||
Sensor_Init(); //IOɨ<4F><C9A8><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
|
||||
|
||||
Dbg_Println(DBG_BIT_DEVICE_STATUS,"MCU Start:%s",VER_LIB);
|
||||
PRINT("MCU_Rst:%04x\n", R8_RESET_STATUS);
|
||||
|
||||
while(1)
|
||||
{
|
||||
WDT_Feed();
|
||||
|
||||
UART_RECEIVE();
|
||||
|
||||
DIP_ScanTask();
|
||||
|
||||
TMOS_SystemProcess();
|
||||
|
||||
Blv_CardlessPower_Tack();
|
||||
|
||||
print_RDRsta_Tack();
|
||||
|
||||
Action_Task();
|
||||
}
|
||||
}
|
||||
|
||||
/******************************** endfile @ main ******************************/
|
||||
117
BLV_RF_W13_V04_20260114/User_Drivers/debug.c
Normal file
117
BLV_RF_W13_V04_20260114/User_Drivers/debug.c
Normal file
@@ -0,0 +1,117 @@
|
||||
#include <stdarg.h>
|
||||
#include "../User/include/includes.h"
|
||||
|
||||
volatile uint32_t SysTick_100us = 0;
|
||||
volatile uint32_t SysTick_1ms = 0;
|
||||
volatile uint32_t SysTick_1s = 0;
|
||||
|
||||
void WDT_Init(void)
|
||||
{
|
||||
WWDG_ResetCfg(ENABLE);
|
||||
WWDG_SetCounter(WDT_NUM);
|
||||
}
|
||||
|
||||
void WDT_Feed(void)
|
||||
{
|
||||
WWDG_ClearFlag();
|
||||
WWDG_SetCounter(WDT_NUM);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
__INTERRUPT
|
||||
__HIGH_CODE
|
||||
void SysTick_Handler(void)
|
||||
{
|
||||
SysTick->SR = 0; //<2F><><EFBFBD><EFBFBD><EFBFBD>жϱ<D0B6>־
|
||||
|
||||
static uint8_t NUM = 0;
|
||||
static uint16_t NUM_s = 0;
|
||||
SysTick_100us++;
|
||||
NUM++;
|
||||
|
||||
if(NUM >= 10){
|
||||
NUM = 0;
|
||||
SysTick_1ms++;
|
||||
NUM_s++;
|
||||
if(NUM_s == 1000)
|
||||
{
|
||||
NUM_s = 0;
|
||||
SysTick_1s++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
int _write(int fd, char *buf, int size)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < size; i++)
|
||||
{
|
||||
#if DEBUG == Debug_UART0
|
||||
while(R8_UART_TFC == UART_FIFO_SIZE); /* <20>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD>ݷ<EFBFBD><DDB7><EFBFBD> */
|
||||
R8_UART_THR = *buf++; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
#endif
|
||||
}
|
||||
return size;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
/*Debug<75><67><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӡ<EFBFBD><D3A1><EFBFBD>ر<EFBFBD><D8B1><EFBFBD>*/
|
||||
uint32_t SysTick_Now = 0, SysTick_Last = 0, SysTick_Diff = 0;
|
||||
char Dbg_Buffer[100];
|
||||
|
||||
uint32_t Dbg_Switch = (DBG_OPT_Debug_STATUS << DBG_BIT_Debug_STATUS)
|
||||
+ (DBG_OPT_PC_COMM << DBG_BIT_PC_COMM)
|
||||
+ (DBG_OPT_BLE_STATUS << DBG_BIT_BLE_STATUS)
|
||||
+ (DBG_OPT_DEVICE_STATUS << DBG_BIT_DEVICE_STATUS)
|
||||
+ (DBG_OPT_SYS_STATUS << DBG_BIT_SYS_STATUS);
|
||||
|
||||
|
||||
void Dbg_NoTick_Println(int DbgOptBit, const char *cmd, ...) {
|
||||
if (DBG_LOG_EN && (Dbg_Switch & (1 << DbgOptBit))) {
|
||||
va_list args; //<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>va_list<73><74><EFBFBD>͵ı<CDB5><C4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>浥<EFBFBD><E6B5A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
va_start(args, cmd); //ʹargsָ<73><D6B8><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
vprintf(cmd, args); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>vprintf<74>ȴ<EFBFBD>V<EFBFBD><56>
|
||||
va_end(args); //<2F><><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD>ȡ
|
||||
DBG_Printf("\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
void Dbg_Println(int DbgOptBit, const char *cmd, ...) {
|
||||
if (DBG_LOG_EN && (Dbg_Switch & (1 << DbgOptBit))) {
|
||||
SysTick_Now = SysTick_1ms;
|
||||
SysTick_Diff = SysTick_Now - SysTick_Last; //<2F><>һ<EFBFBD>δ<EFBFBD>ӡʱ<D3A1><CAB1><EFBFBD><EFBFBD>
|
||||
SysTick_Last = SysTick_Now;
|
||||
sprintf(Dbg_Buffer, "%8d [%6d]: ", SysTick_Now, SysTick_Diff);
|
||||
DBG_Printf("%s", Dbg_Buffer);
|
||||
va_list args; //<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>va_list<73><74><EFBFBD>͵ı<CDB5><C4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>浥<EFBFBD><E6B5A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
va_start(args, cmd); //ʹargsָ<73><D6B8><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
vprintf(cmd, args); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>vprintf<74>ȴ<EFBFBD>V<EFBFBD><56>
|
||||
va_end(args); //<2F><><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD>ȡ
|
||||
DBG_Printf("\r\n");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void Dbg_Print_Buff(int DbgOptBit, const char *cmd, uint8_t *buff, uint32_t len) {
|
||||
if (DBG_LOG_EN && (Dbg_Switch & (1 << DbgOptBit))) {
|
||||
SysTick_Now = SysTick_1ms;
|
||||
SysTick_Diff = SysTick_Now - SysTick_Last; //<2F><>һ<EFBFBD>δ<EFBFBD>ӡʱ<D3A1><CAB1><EFBFBD><EFBFBD>
|
||||
SysTick_Last = SysTick_Now;
|
||||
sprintf(Dbg_Buffer, "%8d [%6d]: ", SysTick_Now, SysTick_Diff);
|
||||
DBG_Printf("%s%s", Dbg_Buffer, cmd);
|
||||
for (uint32_t i = 0; i < len; i++) {
|
||||
DBG_Printf("%02X ", buff[i]);
|
||||
}
|
||||
DBG_Printf("\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
528
BLV_RF_W13_V04_20260114/User_Drivers/flash.c
Normal file
528
BLV_RF_W13_V04_20260114/User_Drivers/flash.c
Normal file
@@ -0,0 +1,528 @@
|
||||
#include "../User/include/includes.h"
|
||||
|
||||
GroupInfo_t g_portGp;
|
||||
OTADataFlashInfo_t p_image_flash;
|
||||
RAR_Info g_rar_info;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>Ĭ<EFBFBD><C4AC>ֵ
|
||||
/* uint8_t Exist_Flag; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˱<EFBFBD><CBB1><EFBFBD> 1:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 2:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 3:<3A><><EFBFBD><EFBFBD><EFBFBD>뿪 4<><34><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>뿪
|
||||
uint8_t Condi_Gruop; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
uint8_t Condi_Subset; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
uint16_t Judgment_Time; //<2F><><EFBFBD><EFBFBD> - <20>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
uint8_t Judgment_Unit; //<2F><><EFBFBD><EFBFBD> - <20>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>䵥λ 1,<2C><> 2,<2C><> 3,ʱ
|
||||
|
||||
uint8_t Port_State[VIRTUAL_PORT_MAX]; //<2F>˿<EFBFBD>,0:<3A><><EFBFBD>ж<EFBFBD> 1:<3A><><EFBFBD><EFBFBD> 2:<3A>ͷ<EFBFBD> 3,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 4,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
uint16_t Timeout_Time; //<2F><><EFBFBD><EFBFBD> - <20>ж<EFBFBD><D0B6><EFBFBD>ʱʱ<CAB1><CAB1>
|
||||
uint8_t Timeout_Unit; //<2F><><EFBFBD><EFBFBD> - <20>ж<EFBFBD><D0B6><EFBFBD>ʱʱ<CAB1>䵥λ
|
||||
|
||||
uint8_t Trigger_Flag; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* */
|
||||
const uint8_t DefaultGroupInfo[VIRTUAL_GP_NUM_MAX][15]=
|
||||
{ //<2F><><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD>
|
||||
{1, 1,1, 0,0,1, 0,4,0,0,0, 2,0,1, 0}, //<2F><><EFBFBD><EFBFBD>˲<EFBFBD><CBB2>
|
||||
{1, 2,1, 0,0,1, 0,0,1,0,0, 20,0,1, 0}, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1 <20><><EFBFBD><EFBFBD>
|
||||
{1, 2,2, 0,0,1, 0,0,0,1,0, 20,0,1, 0}, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2 <20><><EFBFBD><EFBFBD>
|
||||
{1, 2,3, 0,0,1, 0,0,0,0,1, 20,0,1, 0}, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>3 <20><><EFBFBD><EFBFBD>
|
||||
//<2F><><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD>
|
||||
{3, 3,1, 0,0,1, 0,3,0,0,0, 2,0,1, 0}, //<2F><><EFBFBD><EFBFBD>˲<EFBFBD><CBB2>
|
||||
{3, 4,1, 5,0,1, 0,1,2,2,2, 10,0,2, 0}, //<2F><><EFBFBD><EFBFBD>
|
||||
{4, 5,1, 5,0,1, 0,1,2,2,2, 10,0,2, 0}, //<2F><><EFBFBD><EFBFBD>
|
||||
{2, 6,1, 5,0,2, 0,1,2,2,2, 10,0,2, 0}}; //<2F><><EFBFBD>ţ<EFBFBD><C5A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><31>2<EFBFBD><32>3 <20>ͷ<EFBFBD>
|
||||
|
||||
//<2F>˿<EFBFBD><CBBF><EFBFBD>Ϣ<EFBFBD><CFA2>0A<30>Dz<EFBFBD><C7B2>ο<EFBFBD><CEBF><EFBFBD>2<EFBFBD><32><EFBFBD>Ŵźʹ<C5BA><CDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
uint8_t PortInfo[VIRTUAL_PORT_MAX][11]={0x00};
|
||||
|
||||
|
||||
void EEPROM_Init(void)
|
||||
{
|
||||
uint8_t rev = 0x00;
|
||||
uint8_t bufEE[5] = {0x00};
|
||||
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
FLASH_ROM_READ(OTA_DATAFLASH_ADD, &p_image_flash, 4);
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB> */
|
||||
FLASH_ROM_ERASE(OTA_DATAFLASH_ADD, FLASH_BLOCK_SIZE);
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ */
|
||||
// Dbg_Println(DBG_BIT_PC_COMM,"Revd:%d",p_image_flash.Revd[0]);
|
||||
p_image_flash.Revd[0] = 0;
|
||||
|
||||
if(p_image_flash.ImageFlag != IMAGE_A_FLAG){
|
||||
p_image_flash.ImageFlag = IMAGE_A_FLAG;
|
||||
}
|
||||
/* <20><><EFBFBD><EFBFBD>DataFlash */
|
||||
FLASH_ROM_WRITE(OTA_DATAFLASH_ADD, &p_image_flash, 4);
|
||||
|
||||
memset(&g_portGp,0x00,sizeof(GroupInfo_t));
|
||||
memset(&g_rar_info,0x00,sizeof(RAR_Info));
|
||||
|
||||
//<2F><>ȡ<EFBFBD>˿ں<CBBF>
|
||||
rev = EEPROM_Read_PortInfo();
|
||||
if(rev == 0x00)
|
||||
{
|
||||
//<2F><>ȡ<EFBFBD>ɹ<EFBFBD>
|
||||
}else{
|
||||
//<2F><>ȡʧ<C8A1>ܣ<EFBFBD>ʹ<EFBFBD><CAB9>Ĭ<EFBFBD><C4AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
Dbg_Println(DBG_BIT_DEVICE_STATUS,"Use Default PortInfo");
|
||||
EEPROM_Default_PortInfo();
|
||||
}
|
||||
|
||||
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
rev = EEPROM_Read_PortGroupData(&g_portGp);
|
||||
if(rev == 0x00)
|
||||
{
|
||||
|
||||
}else{
|
||||
//<2F><><EFBFBD><EFBFBD>ȡʧ<C8A1>ܣ<EFBFBD>ʹ<EFBFBD><CAB9>Ĭ<EFBFBD><C4AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
Dbg_Println(DBG_BIT_DEVICE_STATUS,"Use Default GroupData");
|
||||
EEPROM_Default_PortGroupData();
|
||||
}
|
||||
|
||||
rev = EEPROM_Read_RARDelayTim(&g_rar_info);
|
||||
if(rev == 0x00)
|
||||
{
|
||||
|
||||
}else{
|
||||
//<2F><><EFBFBD><EFBFBD>ȡʧ<C8A1>ܣ<EFBFBD>ʹ<EFBFBD><CAB9>Ĭ<EFBFBD><C4AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
Dbg_Println(DBG_BIT_DEVICE_STATUS,"Use Default RARDelayTim");
|
||||
EEPROM_Default_RARDelayTim(&g_rar_info);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
uint8_t EEPROM_CheckSum(uint8_t *data,uint16_t len)
|
||||
{
|
||||
uint8_t data_sum = 0;
|
||||
|
||||
for(uint16_t i = 0;i<len;i++)
|
||||
{
|
||||
data_sum += data[i];
|
||||
}
|
||||
return ~data_sum;
|
||||
}
|
||||
|
||||
//<2F><>ȡ<EFBFBD>豸<EFBFBD>Ķ˿<C4B6><CBBF><EFBFBD><EFBFBD>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||
uint8_t EEPROM_Read_PortInfo(void)
|
||||
{
|
||||
uint16_t RD_Len = sizeof(PortInfo);
|
||||
uint16_t read_len = 0x00;
|
||||
uint8_t read_info[4];
|
||||
uint8_t para_data[RD_Len];
|
||||
|
||||
memset(read_info,0,sizeof(read_info));
|
||||
memset(para_data,0,sizeof(para_data));
|
||||
|
||||
FLASH_ROM_READ(EEPROM_INFO_SAVE_ADDR1,read_info,4);
|
||||
|
||||
if(read_info[0] == EEPROM_SaveInfo_Flag){
|
||||
read_len = read_info[2];
|
||||
read_len <<= 8;
|
||||
read_len |= read_info[1];
|
||||
|
||||
if(read_len <= (EEPROM_INFO_Size - 4) ){
|
||||
FLASH_ROM_READ(EEPROM_INFO_SAVE_ADDR1+4,para_data,RD_Len);
|
||||
|
||||
if(EEPROM_CheckSum(para_data,read_len) == read_info[3]){
|
||||
//У<><D0A3><EFBFBD>ɹ<EFBFBD>
|
||||
memcpy(&PortInfo,para_data,read_len);
|
||||
|
||||
Dbg_Println(DBG_BIT_DEVICE_STATUS, "EEPROM_Read SUCC");
|
||||
return 0x00;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
Dbg_Println(DBG_BIT_DEVICE_STATUS, "EEPROM_Read Flag Fail:%02x",read_info[0]);
|
||||
}
|
||||
|
||||
return 0x01;
|
||||
|
||||
}
|
||||
|
||||
//<2F>˿ڲ<CBBF><DAB2><EFBFBD>Ĭ<EFBFBD><C4AC><EFBFBD><EFBFBD>Ϣ
|
||||
void EEPROM_Default_PortInfo(void)
|
||||
{
|
||||
uint8_t Port_DefaultData[11] = {0x00};
|
||||
|
||||
for(uint8_t i = 0; i < VIRTUAL_PORT_MAX; i++)
|
||||
{
|
||||
if(i == 0x00) //<2F>忨
|
||||
{
|
||||
Port_DefaultData[0] = 0x0A;
|
||||
Port_DefaultData[1] = 0x01;
|
||||
Port_DefaultData[2] = (i + 1); //ӳ<><D3B3><EFBFBD><EFBFBD>·
|
||||
Port_DefaultData[3] = 0x00;
|
||||
|
||||
Port_DefaultData[4] = 50; //<2F>ͷ<EFBFBD><CDB7><EFBFBD>ֵ <20><><EFBFBD><EFBFBD>-><3E><><EFBFBD><EFBFBD>
|
||||
|
||||
Port_DefaultData[5] = (i + 1); //<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
||||
Port_DefaultData[6] = 0x00; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>,Ĭ<>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
Port_DefaultData[7] = 0x02; //<2F><>·<EFBFBD><C2B7><EFBFBD><EFBFBD>ͳ<EFBFBD><CDB3>ʱ<EFBFBD><CAB1>
|
||||
Port_DefaultData[8] = 0x00;
|
||||
Port_DefaultData[9] = 0x02; //<2F><>·<EFBFBD><C2B7><EFBFBD><EFBFBD>ͳ<EFBFBD><CDB3>ʱ<EFBFBD>䵥λ
|
||||
|
||||
Port_DefaultData[10] = 20; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ <20><><EFBFBD><EFBFBD>-><3E><><EFBFBD><EFBFBD>
|
||||
}
|
||||
else if(i == 0x01) //<2F>Ŵ<EFBFBD>
|
||||
{
|
||||
Port_DefaultData[0] = 0x02;
|
||||
Port_DefaultData[1] = 0x00;
|
||||
Port_DefaultData[2] = (i + 1); //ӳ<><D3B3><EFBFBD><EFBFBD>·
|
||||
Port_DefaultData[3] = 0x00;
|
||||
|
||||
Port_DefaultData[4] = 50;
|
||||
|
||||
Port_DefaultData[5] = (i + 1); //<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
||||
Port_DefaultData[6] = 0x00; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>,Ĭ<>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
Port_DefaultData[7] = 0x02;
|
||||
Port_DefaultData[8] = 0x00;
|
||||
Port_DefaultData[9] = 0x02;
|
||||
|
||||
Port_DefaultData[10] = 20;
|
||||
}
|
||||
else{ //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
Port_DefaultData[0] = 0x02;
|
||||
Port_DefaultData[1] = 0x00;
|
||||
Port_DefaultData[2] = (i + 1); //ӳ<><D3B3><EFBFBD><EFBFBD>·
|
||||
Port_DefaultData[3] = 0x00;
|
||||
|
||||
Port_DefaultData[4] = 80;
|
||||
|
||||
Port_DefaultData[5] = (i + 1); //<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
||||
Port_DefaultData[6] = 0x00; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>,Ĭ<>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
Port_DefaultData[7] = 0x02;
|
||||
Port_DefaultData[8] = 0x00;
|
||||
Port_DefaultData[9] = 0x03;
|
||||
|
||||
Port_DefaultData[10] = 20;
|
||||
}
|
||||
|
||||
memcpy(&PortInfo[i],Port_DefaultData,11);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD>Ķ˿<C4B6><CBBF><EFBFBD><EFBFBD>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||
uint8_t EEPROM_Write_PortInfo(void)
|
||||
{
|
||||
uint16_t data_len = sizeof(PortInfo);
|
||||
uint16_t WR_Len = (data_len/4 +1)*4 + 4 ;
|
||||
uint8_t data_buff[WR_Len];
|
||||
uint8_t rev = 0;
|
||||
if(WR_Len > EEPROM_INFO_Size) return 0x01;
|
||||
|
||||
memset(data_buff,0,(data_len + 4));
|
||||
|
||||
data_buff[0] = EEPROM_SaveInfo_Flag;
|
||||
data_buff[1] = data_len & 0xFF;
|
||||
data_buff[2] = (data_len >> 8) & 0xFF;
|
||||
data_buff[3] = 0x00; //SumCheck
|
||||
|
||||
memcpy(&data_buff[4],(uint8_t *)PortInfo,data_len);
|
||||
data_buff[3] = EEPROM_CheckSum(&data_buff[4],data_len);
|
||||
data_len += 4;
|
||||
|
||||
// Dbg_Println(DBG_BIT_PC_COMM, "flag:%02x,len:%d,sum:%02x",EEPROM_SaveInfo_Flag,data_len,data_buff[3]);
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>
|
||||
rev = FLASH_ROM_ERASE(EEPROM_INFO_SAVE_ADDR1,EEPROM_INFO_Size);
|
||||
if(rev == 0x00){
|
||||
Dbg_Println(DBG_BIT_DEVICE_STATUS, "1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!");
|
||||
}else {
|
||||
Dbg_Println(DBG_BIT_DEVICE_STATUS, "1<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD> %02X!",rev);
|
||||
return 0x01;
|
||||
}
|
||||
|
||||
//д<><D0B4>
|
||||
rev = FLASH_ROM_WRITE(EEPROM_INFO_SAVE_ADDR1, data_buff, WR_Len);
|
||||
if(rev == 0x00){
|
||||
Dbg_Println(DBG_BIT_DEVICE_STATUS, "1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>");
|
||||
}else {
|
||||
Dbg_Println(DBG_BIT_DEVICE_STATUS, "1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD> %02X!",rev);
|
||||
return 0x02;
|
||||
}
|
||||
|
||||
return 0x00;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***************************************> <20><><EFBFBD><EFBFBD><EFBFBD>жϲ<D0B6><CFB2><EFBFBD> <********************************************/
|
||||
|
||||
|
||||
//<2F><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>жϲ<D0B6><CFB2><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||
uint8_t EEPROM_Read_PortGroupData(GroupInfo_t *info)
|
||||
{
|
||||
uint16_t RD_Len = sizeof(GroupInfo_t) ;
|
||||
uint16_t read_len = 0x00;
|
||||
uint8_t read_info[4];
|
||||
uint8_t para_data[RD_Len];
|
||||
|
||||
memset(read_info,0,sizeof(read_info));
|
||||
memset(para_data,0,sizeof(para_data));
|
||||
|
||||
FLASH_ROM_READ(EEPROM_INFO_SAVE_ADDR2,read_info,4);
|
||||
|
||||
// Dbg_Println(DBG_BIT_PC_COMM, "GroupData:%02x,%02x,%02x,%02x",read_info[0],read_info[1],read_info[2],read_info[3]);
|
||||
if(read_info[0] == EEPROM_SaveInfo_Flag){
|
||||
read_len = read_info[2];
|
||||
read_len <<= 8;
|
||||
read_len |= read_info[1];
|
||||
|
||||
if(read_len <= (EEPROM_INFO_Size - 4) ){
|
||||
FLASH_ROM_READ(EEPROM_INFO_SAVE_ADDR2+4,para_data,read_len);
|
||||
// Dbg_Println(DBG_BIT_PC_COMM, "GroupData:%d,%02x,%02x",read_len,EEPROM_CheckSum(para_data,sizeof(PortGroupInfo)),read_info[3]);
|
||||
if(EEPROM_CheckSum(para_data,read_len) == read_info[3]){
|
||||
// <20><>ȡ<EFBFBD><C8A1><EFBFBD>ˡ<EFBFBD><CBA1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
memcpy(info,para_data,sizeof(GroupInfo_t));
|
||||
// <20><>ȡ<EFBFBD>ɹ<EFBFBD>
|
||||
Dbg_Println(DBG_BIT_DEVICE_STATUS,"Use:%d,%d,%d,%d",info->VC_ConNToSGruop,info->VC_ConNToSSubset,info->VC_ConSToNGruop,info->VC_ConSToNSubset);
|
||||
|
||||
return 0x00;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
Dbg_Println(DBG_BIT_DEVICE_STATUS, "EEPROM_Read Flag Fail2:%02x",read_info[0]);
|
||||
}
|
||||
|
||||
return 0x01;
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>Ĭ<EFBFBD><C4AC><EFBFBD><EFBFBD>Ϣ
|
||||
void EEPROM_Default_PortGroupData(void)
|
||||
{
|
||||
g_portGp.VC_ConNToSGruop = 0x02; //<2F><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
g_portGp.VC_ConNToSSubset = 0x04; //<2F><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
g_portGp.VC_ConSToNGruop = 0x06; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD>)
|
||||
g_portGp.VC_ConSToNSubset = 0x04; //<2F><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
memcpy(&g_portGp.PortGroupInfo,&DefaultGroupInfo,sizeof(DefaultGroupInfo));
|
||||
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD>Ϣ
|
||||
uint8_t EEPROM_Write_PortGroupData(GroupInfo_t *info)
|
||||
{
|
||||
uint16_t data_len = sizeof(GroupInfo_t); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>
|
||||
uint16_t WR_Len = (data_len/4 +1)*4 + 4 ;
|
||||
uint8_t data_buff[WR_Len];
|
||||
uint8_t rev = 0;
|
||||
|
||||
if(WR_Len > EEPROM_INFO_Size) return 0x01;
|
||||
|
||||
Dbg_Println(DBG_BIT_DEVICE_STATUS, "EEPROM_Save_GroupData1:%d",data_len);
|
||||
memset(data_buff,0x00,WR_Len);
|
||||
|
||||
data_buff[0] = EEPROM_SaveInfo_Flag;
|
||||
data_buff[1] = data_len & 0xFF;
|
||||
data_buff[2] = (data_len >> 8) & 0xFF;
|
||||
data_buff[3] = 0x00; //Sum Check
|
||||
|
||||
memcpy(&data_buff[4],(uint8_t *)info,data_len); //<2F><>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>
|
||||
data_buff[3] = EEPROM_CheckSum(&data_buff[4],data_len);
|
||||
data_len += 4;
|
||||
|
||||
// Dbg_Println(DBG_BIT_PC_COMM, "GroupDataW22:%d,%d,%d,%d",data_buff[4],data_buff[5],data_buff[6],data_buff[7]);
|
||||
// Dbg_Println(DBG_BIT_PC_COMM, "flag:%02x,len:%d,sum:%02x",EEPROM_SaveInfo_Flag,data_len,data_buff[3]);
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>
|
||||
rev = FLASH_ROM_ERASE(EEPROM_INFO_SAVE_ADDR2,EEPROM_INFO_Size);
|
||||
if(rev == 0x00){
|
||||
Dbg_Println(DBG_BIT_DEVICE_STATUS, "2<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!");
|
||||
}else {
|
||||
Dbg_Println(DBG_BIT_DEVICE_STATUS, "2<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD> %02X!",rev);
|
||||
return 0x01;
|
||||
}
|
||||
|
||||
//д<><D0B4>
|
||||
rev = FLASH_ROM_WRITE(EEPROM_INFO_SAVE_ADDR2, data_buff, WR_Len);
|
||||
if(rev == 0x00){
|
||||
Dbg_Println(DBG_BIT_DEVICE_STATUS, "2<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>");
|
||||
}else {
|
||||
Dbg_Println(DBG_BIT_DEVICE_STATUS, "2<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD> %02X!",rev);
|
||||
return 0x02;
|
||||
}
|
||||
|
||||
return 0x00;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD>Ϣ
|
||||
uint8_t EEPROM_Read_PortGroupData_2(uint32_t addr,uint16_t len,CONDITION_STRUCT *info)
|
||||
{
|
||||
uint16_t RD_Len = sizeof(CONDITION_STRUCT) ;
|
||||
uint16_t read_len = 0x00;
|
||||
uint8_t read_info[4]; //<2F><>ȡͷ
|
||||
uint8_t para_data[RD_Len];
|
||||
|
||||
|
||||
memset(read_info,0,sizeof(read_info));
|
||||
memset(para_data,0,sizeof(para_data));
|
||||
|
||||
FLASH_ROM_READ(EEPROM_INFO_SAVE_ADDR2,read_info,4);
|
||||
// Dbg_Println(DBG_BIT_PC_COMM, "GroupData:%02x,%02x,%02x,%02x",read_info[0],read_info[1],read_info[2],read_info[3]);
|
||||
|
||||
if(read_info[0] == EEPROM_SaveInfo_Flag){
|
||||
read_len = read_info[2];
|
||||
read_len <<= 8;
|
||||
read_len |= read_info[1];
|
||||
|
||||
if(read_len <= (EEPROM_INFO_Size - 4) ){
|
||||
|
||||
FLASH_ROM_READ(EEPROM_INFO_SAVE_ADDR2+4,(uint8_t *)info,RD_Len);
|
||||
}
|
||||
}
|
||||
|
||||
return 0x01;
|
||||
}
|
||||
|
||||
/********************************* <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ***********************************************************/
|
||||
|
||||
/***************************************************************
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : EEPROM_Read_RARDelayTim
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : <20><>ȡ<EFBFBD>ӳ<EFBFBD><D3B3>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>ӳٲ<D3B3><D9B2><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : RarInfo : <20>ṹ<EFBFBD><E1B9B9>
|
||||
* <20><><EFBFBD>ز<EFBFBD><D8B2><EFBFBD> :
|
||||
****************************************************************/
|
||||
uint8_t EEPROM_Read_RARDelayTim(RAR_Info *RarInfo)
|
||||
{
|
||||
uint16_t RD_Len = sizeof(RAR_Info) ;
|
||||
uint16_t read_len = 0x00;
|
||||
uint8_t read_info[4];
|
||||
uint8_t para_data[RD_Len];
|
||||
|
||||
memset(read_info,0,sizeof(read_info));
|
||||
memset(para_data,0,sizeof(para_data));
|
||||
|
||||
FLASH_ROM_READ(EEPROM_INFO_SAVE_ADDR3,read_info,4);
|
||||
|
||||
// Dbg_Println(DBG_BIT_PC_COMM, "GroupData:%02x,%02x,%02x,%02x",read_info[0],read_info[1],read_info[2],read_info[3]);
|
||||
if(read_info[0] == EEPROM_RARDelayTim_Flag){
|
||||
read_len = read_info[2];
|
||||
read_len <<= 8;
|
||||
read_len |= read_info[1];
|
||||
|
||||
if(read_len <= (EEPROM_INFO_Size - 4) ){
|
||||
FLASH_ROM_READ(EEPROM_INFO_SAVE_ADDR3+4,para_data,read_len);
|
||||
if(EEPROM_CheckSum(para_data,read_len) == read_info[3]){
|
||||
// <20><>ȡ<EFBFBD><C8A1><EFBFBD>ˡ<EFBFBD><CBA1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
memcpy(RarInfo,para_data,sizeof(RAR_Info));
|
||||
// <20><>ȡ<EFBFBD>ɹ<EFBFBD>
|
||||
Dbg_Println(DBG_BIT_DEVICE_STATUS,"RARDelayTim:%d,%d,%d,%d",RarInfo->Door_RARON_Time,RarInfo->Door_RARFF_TimeOut,RarInfo->BATH_RARON_Time,RarInfo->BATH_RARFF_TimeOut);
|
||||
|
||||
if(RarInfo->Door_RARON_Time == 0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
if(RarInfo->Door_RARFF_TimeOut < 5000)
|
||||
{
|
||||
RarInfo->Door_RARFF_TimeOut = 5000;
|
||||
}
|
||||
|
||||
if(RarInfo->BATH_RARON_Time == 0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
if(RarInfo->BATH_RARFF_TimeOut < 5000)
|
||||
{
|
||||
RarInfo->BATH_RARFF_TimeOut = 5000;
|
||||
}
|
||||
|
||||
return 0x00;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
Dbg_Println(DBG_BIT_DEVICE_STATUS, "EEPROM_Read RARDelayTim Flag Fail3:%02x",read_info[0]);
|
||||
}
|
||||
|
||||
return 0x01;
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : EEPROM_Write_RARDelayTim
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : <20><><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD><D3B3>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>ӳٲ<D3B3><D9B2><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : RarInfo : <20>ṹ<EFBFBD><E1B9B9>
|
||||
* <20><><EFBFBD>ز<EFBFBD><D8B2><EFBFBD> :
|
||||
****************************************************************/
|
||||
uint8_t EEPROM_Write_RARDelayTim(RAR_Info *RarInfo)
|
||||
{
|
||||
uint16_t data_len = sizeof(RAR_Info); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>
|
||||
uint16_t WR_Len = (data_len/4 +1)*4 + 4 ;
|
||||
uint8_t data_buff[WR_Len];
|
||||
uint8_t rev = 0;
|
||||
|
||||
if(WR_Len > EEPROM_INFO_Size) return 0x01;
|
||||
|
||||
Dbg_Println(DBG_BIT_DEVICE_STATUS, "EEPROM_Save_RARDelayTim:%d",data_len);
|
||||
memset(data_buff,0x00,WR_Len);
|
||||
|
||||
data_buff[0] = EEPROM_RARDelayTim_Flag;
|
||||
data_buff[1] = data_len & 0xFF;
|
||||
data_buff[2] = (data_len >> 8) & 0xFF;
|
||||
data_buff[3] = 0x00; //Sum Check
|
||||
|
||||
memcpy(&data_buff[4],(uint8_t *)RarInfo,data_len); //<2F><>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>
|
||||
data_buff[3] = EEPROM_CheckSum(&data_buff[4],data_len);
|
||||
data_len += 4;
|
||||
|
||||
// Dbg_Println(DBG_BIT_PC_COMM, "GroupDataW22:%d,%d,%d,%d",data_buff[4],data_buff[5],data_buff[6],data_buff[7]);
|
||||
// Dbg_Println(DBG_BIT_PC_COMM, "flag:%02x,len:%d,sum:%02x",EEPROM_SaveInfo_Flag,data_len,data_buff[3]);
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ
|
||||
rev = FLASH_ROM_ERASE(EEPROM_INFO_SAVE_ADDR3,EEPROM_INFO_Size);
|
||||
if(rev == 0x00){
|
||||
Dbg_Println(DBG_BIT_DEVICE_STATUS, "3<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!");
|
||||
}else {
|
||||
Dbg_Println(DBG_BIT_DEVICE_STATUS, "3<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD> %02X!",rev);
|
||||
return 0x01;
|
||||
}
|
||||
|
||||
//д<><D0B4>
|
||||
rev = FLASH_ROM_WRITE(EEPROM_INFO_SAVE_ADDR3, data_buff, WR_Len);
|
||||
if(rev == 0x00){
|
||||
Dbg_Println(DBG_BIT_DEVICE_STATUS, "3<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>");
|
||||
}else {
|
||||
Dbg_Println(DBG_BIT_DEVICE_STATUS, "3<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD> %02X!",rev);
|
||||
return 0x02;
|
||||
}
|
||||
|
||||
return 0x00;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : EEPROM_Default_RARDelayTim
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : <20>ӳ<EFBFBD><D3B3>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>ӳٲ<D3B3><D9B2><EFBFBD>Ĭ<EFBFBD><C4AC>ֵ
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : RarInfo : <20>ṹ<EFBFBD><E1B9B9>
|
||||
* <20><><EFBFBD>ز<EFBFBD><D8B2><EFBFBD> :
|
||||
****************************************************************/
|
||||
void EEPROM_Default_RARDelayTim(RAR_Info *RarInfo)
|
||||
{
|
||||
RarInfo->Door_RARON_Time = 0;
|
||||
RarInfo->Door_RARFF_TimeOut = DOOR_RDR_DELAYTIME;
|
||||
RarInfo->BATH_RARON_Time = 0;
|
||||
RarInfo->BATH_RARFF_TimeOut = BATH_RDR_DELAYTIME;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
734
BLV_RF_W13_V04_20260114/User_Drivers/gattprofile.c
Normal file
734
BLV_RF_W13_V04_20260114/User_Drivers/gattprofile.c
Normal file
@@ -0,0 +1,734 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : gattprofile.C
|
||||
* Author : WCH
|
||||
* Version : V1.0
|
||||
* Date : 2018/12/10
|
||||
* Description : <20>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֲ<EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD>Եķ<D4B5><C4B7><EFBFBD><F1A3ACB0><EFBFBD><EFBFBD>ɶ<EFBFBD><C9B6><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>֪ͨ<CDA8><D6AA><EFBFBD>ɶ<EFBFBD><C9B6><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD>ȫ<EFBFBD>ɶ<EFBFBD>
|
||||
*********************************************************************************
|
||||
* 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.
|
||||
*******************************************************************************/
|
||||
|
||||
/*********************************************************************
|
||||
* INCLUDES
|
||||
*/
|
||||
#include "CONFIG.h"
|
||||
#include "gattprofile.h"
|
||||
|
||||
/*********************************************************************
|
||||
* MACROS
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* CONSTANTS
|
||||
*/
|
||||
|
||||
// Position of simpleProfilechar4 value in attribute array
|
||||
#define SIMPLEPROFILE_CHAR4_VALUE_POS 5//YYW,1008,11
|
||||
|
||||
/*********************************************************************
|
||||
* TYPEDEFS
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* GLOBAL VARIABLES
|
||||
*/
|
||||
// Simple GATT Profile Service UUID: 0xFFF0
|
||||
const uint8_t simpleProfileServUUID[ATT_BT_UUID_SIZE] = {
|
||||
LO_UINT16(SIMPLEPROFILE_SERV_UUID), HI_UINT16(SIMPLEPROFILE_SERV_UUID)};
|
||||
|
||||
// Characteristic 1 UUID: 0xFFF1
|
||||
const uint8_t simpleProfilechar1UUID[ATT_BT_UUID_SIZE] = {
|
||||
LO_UINT16(SIMPLEPROFILE_CHAR1_UUID), HI_UINT16(SIMPLEPROFILE_CHAR1_UUID)};
|
||||
|
||||
// Characteristic 2 UUID: 0xFFF2
|
||||
const uint8_t simpleProfilechar2UUID[ATT_BT_UUID_SIZE] = {
|
||||
LO_UINT16(SIMPLEPROFILE_CHAR2_UUID), HI_UINT16(SIMPLEPROFILE_CHAR2_UUID)};
|
||||
|
||||
// Characteristic 3 UUID: 0xFFF3
|
||||
const uint8_t simpleProfilechar3UUID[ATT_BT_UUID_SIZE] = {
|
||||
LO_UINT16(SIMPLEPROFILE_CHAR3_UUID), HI_UINT16(SIMPLEPROFILE_CHAR3_UUID)};
|
||||
|
||||
// Characteristic 4 UUID: 0xFFF4
|
||||
const uint8_t simpleProfilechar4UUID[ATT_BT_UUID_SIZE] = {
|
||||
LO_UINT16(SIMPLEPROFILE_CHAR4_UUID), HI_UINT16(SIMPLEPROFILE_CHAR4_UUID)};
|
||||
|
||||
// Characteristic 5 UUID: 0xFFF5
|
||||
const uint8_t simpleProfilechar5UUID[ATT_BT_UUID_SIZE] = {
|
||||
LO_UINT16(SIMPLEPROFILE_CHAR5_UUID), HI_UINT16(SIMPLEPROFILE_CHAR5_UUID)};
|
||||
|
||||
/*********************************************************************
|
||||
* EXTERNAL VARIABLES
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* EXTERNAL FUNCTIONS
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* LOCAL VARIABLES
|
||||
*/
|
||||
|
||||
static simpleProfileCBs_t *simpleProfile_AppCBs = NULL;
|
||||
|
||||
/*********************************************************************
|
||||
* Profile Attributes - variables
|
||||
*/
|
||||
|
||||
// Simple Profile Service attribute
|
||||
static const gattAttrType_t simpleProfileService = {ATT_BT_UUID_SIZE, simpleProfileServUUID};
|
||||
|
||||
// Simple Profile Characteristic 1 Properties
|
||||
static uint8_t simpleProfileChar1Props = GATT_PROP_READ | GATT_PROP_WRITE;
|
||||
|
||||
// Characteristic 1 Value
|
||||
static uint8_t simpleProfileChar1[SIMPLEPROFILE_CHAR1_LEN] = {0};
|
||||
|
||||
// Simple Profile Characteristic 1 User Description
|
||||
static uint8_t simpleProfileChar1UserDesp[] = "Characteristic 1\0";
|
||||
|
||||
// Simple Profile Characteristic 2 Properties
|
||||
static uint8_t simpleProfileChar2Props = GATT_PROP_READ; // @suppress("Unused variable declaration in file scope")
|
||||
|
||||
// Characteristic 2 Value
|
||||
static uint8_t simpleProfileChar2[SIMPLEPROFILE_CHAR2_LEN] = {0};
|
||||
|
||||
// Simple Profile Characteristic 2 User Description
|
||||
static uint8_t simpleProfileChar2UserDesp[] = "Characteristic 2\0"; // @suppress("Unused variable declaration in file scope")
|
||||
|
||||
// Simple Profile Characteristic 3 Properties
|
||||
static uint8_t simpleProfileChar3Props = GATT_PROP_WRITE; // @suppress("Unused variable declaration in file scope")
|
||||
|
||||
// Characteristic 3 Value
|
||||
static uint8_t simpleProfileChar3[SIMPLEPROFILE_CHAR3_LEN] = {0};
|
||||
|
||||
// Simple Profile Characteristic 3 User Description
|
||||
static uint8_t simpleProfileChar3UserDesp[] = "Characteristic 3\0"; // @suppress("Unused variable declaration in file scope")
|
||||
|
||||
// Simple Profile Characteristic 4 Properties
|
||||
static uint8_t simpleProfileChar4Props = GATT_PROP_NOTIFY;
|
||||
|
||||
// Characteristic 4 Value
|
||||
static uint8_t simpleProfileChar4[1] = {0};
|
||||
|
||||
// Simple Profile Characteristic 4 Configuration Each client has its own
|
||||
// instantiation of the Client Characteristic Configuration. Reads of the
|
||||
// Client Characteristic Configuration only shows the configuration for
|
||||
// that client and writes only affect the configuration of that client.
|
||||
static gattCharCfg_t simpleProfileChar4Config[1];
|
||||
|
||||
// Simple Profile Characteristic 4 User Description
|
||||
static uint8_t simpleProfileChar4UserDesp[] = "Characteristic 4\0";
|
||||
|
||||
// Simple Profile Characteristic 5 Properties
|
||||
static uint8_t simpleProfileChar5Props = GATT_PROP_READ;
|
||||
|
||||
// Characteristic 5 Value
|
||||
static uint8_t simpleProfileChar5[SIMPLEPROFILE_CHAR5_LEN] = {0};
|
||||
|
||||
// Simple Profile Characteristic 5 User Description
|
||||
static uint8_t simpleProfileChar5UserDesp[] = "Characteristic 5\0";
|
||||
|
||||
/*********************************************************************
|
||||
* Profile Attributes - Table
|
||||
*/
|
||||
|
||||
static gattAttribute_t simpleProfileAttrTbl[] = {
|
||||
// Simple Profile Service
|
||||
{
|
||||
{ATT_BT_UUID_SIZE, primaryServiceUUID}, /* type */
|
||||
GATT_PERMIT_READ, /* permissions */
|
||||
0, /* handle */
|
||||
(uint8_t *)&simpleProfileService /* pValue */
|
||||
},
|
||||
|
||||
// Characteristic 1 Declaration
|
||||
{
|
||||
{ATT_BT_UUID_SIZE, characterUUID},
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
&simpleProfileChar1Props}, //UUID1<44>Ķ<EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD>
|
||||
|
||||
// Characteristic Value 1
|
||||
{
|
||||
{ATT_BT_UUID_SIZE, simpleProfilechar1UUID},
|
||||
GATT_PERMIT_READ | GATT_PERMIT_WRITE,
|
||||
0,
|
||||
simpleProfileChar1}, //UUID1<44>Ĵ洢<C4B4><E6B4A2><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
// Characteristic 1 User Description
|
||||
{
|
||||
{ATT_BT_UUID_SIZE, charUserDescUUID},
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
simpleProfileChar1UserDesp}, //UUID1<44><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
|
||||
//YYW,1008<30><38><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// // Characteristic 2 Declaration
|
||||
// {
|
||||
// {ATT_BT_UUID_SIZE, characterUUID},
|
||||
// GATT_PERMIT_READ,
|
||||
// 0,
|
||||
// &simpleProfileChar2Props},
|
||||
//
|
||||
// // Characteristic Value 2
|
||||
// {
|
||||
// {ATT_BT_UUID_SIZE, simpleProfilechar2UUID},
|
||||
// GATT_PERMIT_READ,
|
||||
// 0,
|
||||
// simpleProfileChar2},
|
||||
//
|
||||
// // Characteristic 2 User Description
|
||||
// {
|
||||
// {ATT_BT_UUID_SIZE, charUserDescUUID},
|
||||
// GATT_PERMIT_READ,
|
||||
// 0,
|
||||
// simpleProfileChar2UserDesp},
|
||||
//
|
||||
// // Characteristic 3 Declaration
|
||||
// {
|
||||
// {ATT_BT_UUID_SIZE, characterUUID},
|
||||
// GATT_PERMIT_READ,
|
||||
// 0,
|
||||
// &simpleProfileChar3Props},
|
||||
//
|
||||
// // Characteristic Value 3
|
||||
// {
|
||||
// {ATT_BT_UUID_SIZE, simpleProfilechar3UUID},
|
||||
// GATT_PERMIT_WRITE,
|
||||
// 0,
|
||||
// simpleProfileChar3},
|
||||
//
|
||||
// // Characteristic 3 User Description
|
||||
// {
|
||||
// {ATT_BT_UUID_SIZE, charUserDescUUID},
|
||||
// GATT_PERMIT_READ,
|
||||
// 0,
|
||||
// simpleProfileChar3UserDesp},
|
||||
|
||||
|
||||
// Characteristic 4 Declaration
|
||||
{
|
||||
{ATT_BT_UUID_SIZE, characterUUID},
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
&simpleProfileChar4Props},
|
||||
|
||||
// Characteristic Value 4
|
||||
{
|
||||
{ATT_BT_UUID_SIZE, simpleProfilechar4UUID},
|
||||
0,
|
||||
0,
|
||||
simpleProfileChar4},
|
||||
|
||||
// Characteristic 4 configuration
|
||||
{
|
||||
{ATT_BT_UUID_SIZE, clientCharCfgUUID},
|
||||
GATT_PERMIT_READ | GATT_PERMIT_WRITE,
|
||||
0,
|
||||
(uint8_t *)simpleProfileChar4Config},
|
||||
|
||||
// Characteristic 4 User Description
|
||||
{
|
||||
{ATT_BT_UUID_SIZE, charUserDescUUID},
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
simpleProfileChar4UserDesp},
|
||||
|
||||
// Characteristic 5 Declaration
|
||||
{
|
||||
{ATT_BT_UUID_SIZE, characterUUID},
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
&simpleProfileChar5Props},
|
||||
|
||||
// Characteristic Value 5
|
||||
{
|
||||
{ATT_BT_UUID_SIZE, simpleProfilechar5UUID},
|
||||
GATT_PERMIT_AUTHEN_READ,//GATT_PERMIT_AUTHEN_READ,
|
||||
0,
|
||||
simpleProfileChar5},
|
||||
|
||||
// Characteristic 5 User Description
|
||||
{
|
||||
{ATT_BT_UUID_SIZE, charUserDescUUID},
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
simpleProfileChar5UserDesp},
|
||||
};
|
||||
|
||||
/*********************************************************************
|
||||
* LOCAL FUNCTIONS
|
||||
*/
|
||||
static bStatus_t simpleProfile_ReadAttrCB(uint16_t connHandle, gattAttribute_t *pAttr,
|
||||
uint8_t *pValue, uint16_t *pLen, uint16_t offset, uint16_t maxLen, uint8_t method);
|
||||
static bStatus_t simpleProfile_WriteAttrCB(uint16_t connHandle, gattAttribute_t *pAttr,
|
||||
uint8_t *pValue, uint16_t len, uint16_t offset, uint8_t method);
|
||||
|
||||
static void simpleProfile_HandleConnStatusCB(uint16_t connHandle, uint8_t changeType);
|
||||
|
||||
/*********************************************************************
|
||||
* PROFILE CALLBACKS
|
||||
*/
|
||||
// Simple Profile Service Callbacks
|
||||
gattServiceCBs_t simpleProfileCBs = {
|
||||
simpleProfile_ReadAttrCB, // Read callback function pointer
|
||||
simpleProfile_WriteAttrCB, // Write callback function pointer
|
||||
NULL // Authorization callback function pointer
|
||||
};
|
||||
|
||||
/*********************************************************************
|
||||
* PUBLIC FUNCTIONS
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SimpleProfile_AddService
|
||||
*
|
||||
* @brief Initializes the Simple Profile service by registering
|
||||
* GATT attributes with the GATT server.
|
||||
*
|
||||
* @param services - services to add. This is a bit map and can
|
||||
* contain more than one service.
|
||||
*
|
||||
* @return Success or Failure
|
||||
*/
|
||||
bStatus_t SimpleProfile_AddService(uint32_t services)
|
||||
{
|
||||
uint8_t status = SUCCESS;
|
||||
|
||||
// Initialize Client Characteristic Configuration attributes
|
||||
GATTServApp_InitCharCfg(INVALID_CONNHANDLE, simpleProfileChar4Config); //<2F><>ʼ<EFBFBD><CABC>UUID4<44><34>֪ͨ
|
||||
|
||||
// Register with Link DB to receive link status change callback
|
||||
linkDB_Register(simpleProfile_HandleConnStatusCB); //<2F><><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD>ݿ⣨Link DB<44><42>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4>仯<EFBFBD>Ļص<C4BB><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
if(services & SIMPLEPROFILE_SERVICE) //ע<><D7A2> GATT <20><><EFBFBD><EFBFBD><F1B5BDB7><EFBFBD><EFBFBD><EFBFBD>
|
||||
{
|
||||
// Register GATT attribute list and CBs with GATT Server App
|
||||
status = GATTServApp_RegisterService(simpleProfileAttrTbl, //UUIDע<44><D7A2><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD>
|
||||
GATT_NUM_ATTRS(simpleProfileAttrTbl), //<2F><><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ե<EFBFBD><D4B5><EFBFBD><EFBFBD><EFBFBD>
|
||||
GATT_MAX_ENCRYPT_KEY_SIZE, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Կ<EFBFBD><D4BF><EFBFBD><EFBFBD>
|
||||
&simpleProfileCBs); //<2F><>д<EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
|
||||
return (status);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SimpleProfile_RegisterAppCBs
|
||||
*
|
||||
* @brief Registers the application callback function. Only call
|
||||
* this function once.
|
||||
*
|
||||
* @param callbacks - pointer to application callbacks.
|
||||
*
|
||||
* @return SUCCESS or bleAlreadyInRequestedMode
|
||||
*/
|
||||
bStatus_t SimpleProfile_RegisterAppCBs(simpleProfileCBs_t *appCallbacks)
|
||||
{
|
||||
if(appCallbacks)
|
||||
{
|
||||
simpleProfile_AppCBs = appCallbacks;
|
||||
|
||||
return (SUCCESS);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (bleAlreadyInRequestedMode);
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SimpleProfile_SetParameter
|
||||
*
|
||||
* @brief Set a Simple Profile parameter.
|
||||
*
|
||||
* @param param - Profile parameter ID
|
||||
* @param len - length of data to right
|
||||
* @param value - pointer to data to write. This is dependent on
|
||||
* the parameter ID and WILL be cast to the appropriate
|
||||
* data type (example: data type of uint16_t will be cast to
|
||||
* uint16_t pointer).
|
||||
*
|
||||
* @return bStatus_t
|
||||
*/
|
||||
bStatus_t SimpleProfile_SetParameter(uint8_t param, uint8_t len, void *value)
|
||||
{
|
||||
bStatus_t ret = SUCCESS;
|
||||
switch(param)
|
||||
{
|
||||
case SIMPLEPROFILE_CHAR1:
|
||||
if(len == SIMPLEPROFILE_CHAR1_LEN)
|
||||
{
|
||||
tmos_memcpy(simpleProfileChar1, value, SIMPLEPROFILE_CHAR1_LEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = bleInvalidRange;
|
||||
}
|
||||
break;
|
||||
|
||||
case SIMPLEPROFILE_CHAR2:
|
||||
if(len == SIMPLEPROFILE_CHAR2_LEN)
|
||||
{
|
||||
tmos_memcpy(simpleProfileChar2, value, SIMPLEPROFILE_CHAR2_LEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = bleInvalidRange;
|
||||
}
|
||||
break;
|
||||
|
||||
case SIMPLEPROFILE_CHAR3:
|
||||
if(len == SIMPLEPROFILE_CHAR3_LEN)
|
||||
{
|
||||
tmos_memcpy(simpleProfileChar3, value, SIMPLEPROFILE_CHAR3_LEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = bleInvalidRange;
|
||||
}
|
||||
break;
|
||||
|
||||
case SIMPLEPROFILE_CHAR4:
|
||||
if(len == SIMPLEPROFILE_CHAR4_LEN)
|
||||
{
|
||||
tmos_memcpy(simpleProfileChar4, value, SIMPLEPROFILE_CHAR4_LEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = bleInvalidRange;
|
||||
}
|
||||
break;
|
||||
|
||||
case SIMPLEPROFILE_CHAR5:
|
||||
if(len == SIMPLEPROFILE_CHAR5_LEN)
|
||||
{
|
||||
tmos_memcpy(simpleProfileChar5, value, SIMPLEPROFILE_CHAR5_LEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = bleInvalidRange;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
ret = INVALIDPARAMETER;
|
||||
break;
|
||||
}
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SimpleProfile_GetParameter
|
||||
*
|
||||
* @brief Get a Simple Profile parameter.
|
||||
*
|
||||
* @param param - Profile parameter ID
|
||||
* @param value - pointer to data to put. This is dependent on
|
||||
* the parameter ID and WILL be cast to the appropriate
|
||||
* data type (example: data type of uint16_t will be cast to
|
||||
* uint16_t pointer).
|
||||
*
|
||||
* @return bStatus_t
|
||||
*/
|
||||
bStatus_t SimpleProfile_GetParameter(uint8_t param, void *value)
|
||||
{
|
||||
bStatus_t ret = SUCCESS;
|
||||
switch(param)
|
||||
{
|
||||
case SIMPLEPROFILE_CHAR1:
|
||||
tmos_memcpy(value, simpleProfileChar1, SIMPLEPROFILE_CHAR1_LEN);
|
||||
break;
|
||||
|
||||
case SIMPLEPROFILE_CHAR2:
|
||||
tmos_memcpy(value, simpleProfileChar2, SIMPLEPROFILE_CHAR2_LEN);
|
||||
break;
|
||||
|
||||
case SIMPLEPROFILE_CHAR3:
|
||||
tmos_memcpy(value, simpleProfileChar3, SIMPLEPROFILE_CHAR3_LEN);
|
||||
break;
|
||||
|
||||
case SIMPLEPROFILE_CHAR4:
|
||||
tmos_memcpy(value, simpleProfileChar4, SIMPLEPROFILE_CHAR4_LEN);
|
||||
break;
|
||||
|
||||
case SIMPLEPROFILE_CHAR5:
|
||||
tmos_memcpy(value, simpleProfileChar5, SIMPLEPROFILE_CHAR5_LEN);
|
||||
break;
|
||||
|
||||
default:
|
||||
ret = INVALIDPARAMETER;
|
||||
break;
|
||||
}
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn simpleProfile_Notify
|
||||
*
|
||||
* @brief Send a notification containing a heart rate
|
||||
* measurement.
|
||||
*
|
||||
* @param connHandle - connection handle
|
||||
* @param pNoti - pointer to notification structure
|
||||
*
|
||||
* @return Success or Failure
|
||||
*/
|
||||
bStatus_t simpleProfile_Notify(uint16_t connHandle, attHandleValueNoti_t *pNoti)
|
||||
{
|
||||
uint16_t value = GATTServApp_ReadCharCfg(connHandle, simpleProfileChar4Config);
|
||||
|
||||
// If notifications enabled
|
||||
if(value & GATT_CLIENT_CFG_NOTIFY)
|
||||
{
|
||||
// Set the handle //SIMPLEPROFILE_CHAR4_VALUE_POS <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ4<D6B5><34>λ<EFBFBD><CEBB>
|
||||
pNoti->handle = simpleProfileAttrTbl[SIMPLEPROFILE_CHAR4_VALUE_POS].handle;
|
||||
|
||||
// Send the notification
|
||||
return GATT_Notification(connHandle, pNoti, FALSE);
|
||||
}
|
||||
return bleIncorrectMode;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn simpleProfile_ReadAttrCB
|
||||
*
|
||||
* @brief Read an attribute.
|
||||
*
|
||||
* @param connHandle - connection message was received on
|
||||
* @param pAttr - pointer to attribute
|
||||
* @param pValue - pointer to data to be read
|
||||
* @param pLen - length of data to be read
|
||||
* @param offset - offset of the first octet to be read
|
||||
* @param maxLen - maximum length of data to be read
|
||||
*
|
||||
* @return Success or Failure
|
||||
*/
|
||||
static bStatus_t simpleProfile_ReadAttrCB(uint16_t connHandle, gattAttribute_t *pAttr,
|
||||
uint8_t *pValue, uint16_t *pLen, uint16_t offset, uint16_t maxLen, uint8_t method)
|
||||
{
|
||||
bStatus_t status = SUCCESS;
|
||||
|
||||
|
||||
// Make sure it's not a blob operation (no attributes in the profile are long)
|
||||
if(offset > 0)
|
||||
{
|
||||
return (ATT_ERR_ATTR_NOT_LONG);
|
||||
}
|
||||
|
||||
if(pAttr->type.len == ATT_BT_UUID_SIZE)
|
||||
{
|
||||
// 16-bit UUID
|
||||
uint16_t uuid = BUILD_UINT16(pAttr->type.uuid[0], pAttr->type.uuid[1]);
|
||||
switch(uuid)
|
||||
{
|
||||
// No need for "GATT_SERVICE_UUID" or "GATT_CLIENT_CHAR_CFG_UUID" cases;
|
||||
// gattserverapp handles those reads
|
||||
|
||||
// characteristics 1 and 2 have read permissions
|
||||
// characteritisc 3 does not have read permissions; therefore it is not
|
||||
// included here
|
||||
// characteristic 4 does not have read permissions, but because it
|
||||
// can be sent as a notification, it is included here
|
||||
case SIMPLEPROFILE_CHAR1_UUID:
|
||||
if(maxLen > SIMPLEPROFILE_CHAR1_LEN)
|
||||
{
|
||||
*pLen = SIMPLEPROFILE_CHAR1_LEN;
|
||||
}
|
||||
else
|
||||
{
|
||||
*pLen = maxLen;
|
||||
}
|
||||
tmos_memcpy(pValue, pAttr->pValue, *pLen);
|
||||
break;
|
||||
//YYW,1008
|
||||
// case SIMPLEPROFILE_CHAR2_UUID:
|
||||
// if(maxLen > SIMPLEPROFILE_CHAR2_LEN)
|
||||
// {
|
||||
// *pLen = SIMPLEPROFILE_CHAR2_LEN;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// *pLen = maxLen;
|
||||
// }
|
||||
// tmos_memcpy(pValue, pAttr->pValue, *pLen);
|
||||
// break;
|
||||
|
||||
case SIMPLEPROFILE_CHAR4_UUID:
|
||||
if(maxLen > SIMPLEPROFILE_CHAR4_LEN)
|
||||
{
|
||||
*pLen = SIMPLEPROFILE_CHAR4_LEN;
|
||||
}
|
||||
else
|
||||
{
|
||||
*pLen = maxLen;
|
||||
}
|
||||
tmos_memcpy(pValue, pAttr->pValue, *pLen);
|
||||
break;
|
||||
|
||||
case SIMPLEPROFILE_CHAR5_UUID:
|
||||
if(maxLen > SIMPLEPROFILE_CHAR5_LEN)
|
||||
{
|
||||
*pLen = SIMPLEPROFILE_CHAR5_LEN;
|
||||
}
|
||||
else
|
||||
{
|
||||
*pLen = maxLen;
|
||||
}
|
||||
tmos_memcpy(pValue, pAttr->pValue, *pLen);
|
||||
break;
|
||||
|
||||
default:
|
||||
// Should never get here! (characteristics 3 and 4 do not have read permissions)
|
||||
*pLen = 0;
|
||||
status = ATT_ERR_ATTR_NOT_FOUND;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 128-bit UUID
|
||||
*pLen = 0;
|
||||
status = ATT_ERR_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
return (status);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn simpleProfile_WriteAttrCB
|
||||
*
|
||||
* @brief Validate attribute data prior to a write operation
|
||||
*
|
||||
* @param connHandle - connection message was received on
|
||||
* @param pAttr - pointer to attribute
|
||||
* @param pValue - pointer to data to be written
|
||||
* @param len - length of data
|
||||
* @param offset - offset of the first octet to be written
|
||||
*
|
||||
* @return Success or Failure
|
||||
*/
|
||||
static bStatus_t simpleProfile_WriteAttrCB(uint16_t connHandle, gattAttribute_t *pAttr,
|
||||
uint8_t *pValue, uint16_t len, uint16_t offset, uint8_t method)
|
||||
{
|
||||
bStatus_t status = SUCCESS;
|
||||
uint8_t notifyApp = 0xFF;
|
||||
|
||||
// If attribute permissions require authorization to write, return error
|
||||
if(gattPermitAuthorWrite(pAttr->permissions))
|
||||
{
|
||||
// Insufficient authorization
|
||||
return (ATT_ERR_INSUFFICIENT_AUTHOR);
|
||||
}
|
||||
|
||||
if(pAttr->type.len == ATT_BT_UUID_SIZE)
|
||||
{
|
||||
// 16-bit UUID
|
||||
uint16_t uuid = BUILD_UINT16(pAttr->type.uuid[0], pAttr->type.uuid[1]);
|
||||
switch(uuid)
|
||||
{
|
||||
case SIMPLEPROFILE_CHAR1_UUID:
|
||||
//Validate the value
|
||||
// Make sure it's not a blob oper
|
||||
if(offset == 0)
|
||||
{
|
||||
if(len > SIMPLEPROFILE_CHAR1_LEN)
|
||||
{
|
||||
status = ATT_ERR_INVALID_VALUE_SIZE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
status = ATT_ERR_ATTR_NOT_LONG;
|
||||
}
|
||||
|
||||
//Write the value
|
||||
if(status == SUCCESS)
|
||||
{
|
||||
tmos_memcpy(pAttr->pValue, pValue, SIMPLEPROFILE_CHAR1_LEN);
|
||||
notifyApp = SIMPLEPROFILE_CHAR1;
|
||||
}
|
||||
break;
|
||||
//YYW,1008
|
||||
// case SIMPLEPROFILE_CHAR3_UUID:
|
||||
// //Validate the value
|
||||
// // Make sure it's not a blob oper
|
||||
// if(offset == 0)
|
||||
// {
|
||||
// if(len > SIMPLEPROFILE_CHAR3_LEN)
|
||||
// {
|
||||
// status = ATT_ERR_INVALID_VALUE_SIZE;
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// status = ATT_ERR_ATTR_NOT_LONG;
|
||||
// }
|
||||
//
|
||||
// //Write the value
|
||||
// if(status == SUCCESS)
|
||||
// {
|
||||
// tmos_memcpy(pAttr->pValue, pValue, SIMPLEPROFILE_CHAR3_LEN);
|
||||
// notifyApp = SIMPLEPROFILE_CHAR3;
|
||||
// }
|
||||
// break;
|
||||
|
||||
|
||||
case GATT_CLIENT_CHAR_CFG_UUID:
|
||||
status = GATTServApp_ProcessCCCWriteReq(connHandle, pAttr, pValue, len,
|
||||
offset, GATT_CLIENT_CFG_NOTIFY);
|
||||
break;
|
||||
|
||||
default:
|
||||
// Should never get here! (characteristics 2 and 4 do not have write permissions)
|
||||
status = ATT_ERR_ATTR_NOT_FOUND;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 128-bit UUID
|
||||
status = ATT_ERR_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
// If a charactersitic value changed then callback function to notify application of change
|
||||
if((notifyApp != 0xFF) && simpleProfile_AppCBs && simpleProfile_AppCBs->pfnSimpleProfileChange)
|
||||
{
|
||||
simpleProfile_AppCBs->pfnSimpleProfileChange(notifyApp, pValue, len);
|
||||
}
|
||||
|
||||
return (status);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn simpleProfile_HandleConnStatusCB
|
||||
*
|
||||
* @brief Simple Profile link status change handler function.
|
||||
*
|
||||
* @param connHandle - connection handle
|
||||
* @param changeType - type of change
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
static void simpleProfile_HandleConnStatusCB(uint16_t connHandle, uint8_t changeType)
|
||||
{
|
||||
// Make sure this is not loopback connection
|
||||
if(connHandle != LOOPBACK_CONNHANDLE)
|
||||
{
|
||||
// Reset Client Char Config if connection has dropped
|
||||
if((changeType == LINKDB_STATUS_UPDATE_REMOVED) ||
|
||||
((changeType == LINKDB_STATUS_UPDATE_STATEFLAGS) &&
|
||||
(!linkDB_Up(connHandle))))
|
||||
{
|
||||
GATTServApp_InitCharCfg(connHandle, simpleProfileChar4Config); // <20><><EFBFBD><EFBFBD><EFBFBD>ӶϿ<D3B6>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>CHAR4<52><34>֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*********************************************************************/
|
||||
72
BLV_RF_W13_V04_20260114/User_Drivers/inc/debug.h
Normal file
72
BLV_RF_W13_V04_20260114/User_Drivers/inc/debug.h
Normal file
@@ -0,0 +1,72 @@
|
||||
#ifndef USER_DRIVERS_INC_DEBUG_H_
|
||||
#define USER_DRIVERS_INC_DEBUG_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include "CH57x_common.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* DEBUG log function. DEBUG printf() <20><><EFBFBD>ض<EFBFBD><D8B6><EFBFBD>*/
|
||||
#ifndef DBG_LOG_EN
|
||||
#define DBG_LOG_EN 1 //DEBUG LOG <20><><EFBFBD><EFBFBD><EFBFBD>ܿ<EFBFBD><DCBF><EFBFBD>
|
||||
#endif
|
||||
|
||||
#ifndef DBG_Particular_EN
|
||||
#define DBG_Particular_EN 0 //<2F><>ϸ<EFBFBD><CFB8>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD> -- <20><><EFBFBD>嵽<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ú<EFBFBD><C3BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>к<EFBFBD>
|
||||
#endif
|
||||
|
||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>ʼ״̬*/
|
||||
#define DBG_OPT_RDR_STATUS 0 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬ʹ<CCAC><CAB9>
|
||||
#define DBG_OPT_Debug_STATUS 0 //<2F><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD>
|
||||
#define DBG_OPT_PC_COMM 0 //PCͨѶ<CDA8><D1B6>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD>
|
||||
#define DBG_OPT_BLE_STATUS 0 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD>
|
||||
#define DBG_OPT_DEVICE_STATUS 0 //<2F>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD>
|
||||
#define DBG_OPT_SYS_STATUS 0 //ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD>
|
||||
|
||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ*/
|
||||
#define DBG_BIT_RDR_STATUS 5
|
||||
#define DBG_BIT_Debug_STATUS 4
|
||||
#define DBG_BIT_PC_COMM 3
|
||||
#define DBG_BIT_BLE_STATUS 2
|
||||
#define DBG_BIT_DEVICE_STATUS 1
|
||||
#define DBG_BIT_SYS_STATUS 0
|
||||
|
||||
|
||||
#define WDT_NUM 150 //<2F><><EFBFBD>Ź<EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
|
||||
extern uint32_t Dbg_Switch;
|
||||
|
||||
void WDT_Init(void);
|
||||
void WDT_Feed(void);
|
||||
|
||||
|
||||
|
||||
void Systick_Init(void);
|
||||
void Dbg_NoTick_Println(int DbgOptBit, const char *cmd, ...);
|
||||
void Dbg_Println(int DbgOptBit, const char *cmd, ...);
|
||||
void Dbg_Print_Buff(int DbgOptBit, const char *cmd, uint8_t *buff, uint32_t len);
|
||||
|
||||
|
||||
#if DBG_LOG_EN
|
||||
|
||||
#if DBG_Particular_EN
|
||||
#define DBG_Printf(...) {printf("%s %s-%d :",__FILE__,__func__,__LINE__);printf(__VA_ARGS__);}
|
||||
#else
|
||||
#define DBG_Printf(...) printf(__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#else
|
||||
#define DBG_Printf(...)
|
||||
#endif
|
||||
|
||||
#define DBG_INFO(msg) DBG_Printf("%s %s-%d :%s",__FILE__,__func__,__LINE__,msg)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* USER_DRIVEN_INC_DEBUG_H_ */
|
||||
99
BLV_RF_W13_V04_20260114/User_Drivers/inc/flash.h
Normal file
99
BLV_RF_W13_V04_20260114/User_Drivers/inc/flash.h
Normal file
@@ -0,0 +1,99 @@
|
||||
#ifndef USER_DRIVERS_INC_FLASH_H_
|
||||
#define USER_DRIVERS_INC_FLASH_H_
|
||||
|
||||
#include "CH57x_common.h"
|
||||
|
||||
/* CodeFlash<73><68><EFBFBD><EFBFBD>:
|
||||
* 0x0000000-0x0001000 : Jump , 4K
|
||||
* 0x0001000-0x001E000 : APP , 116K
|
||||
* 0x001E000-0x0036000 : IAP , 96K
|
||||
* 0x0036000-0x0037000 : <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>4k
|
||||
* 0x0037000-0x003A000 : User-Flash , 12K
|
||||
* 0x003A000-0x003BFFF : image-Flag , 8K
|
||||
* */
|
||||
|
||||
/*CH572D FlashROM : 240KB 0x00000000-0x0003BFFF
|
||||
* <20><><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>ʹ<EFBFBD><CAB9>Flash 0x037000-0x00039FFF ~ <20><>Ϊ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ϣ<EFBFBD>洢(12K)
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#define EEPROM_INFO_START_ADDR 0x037000
|
||||
|
||||
#define EEPROM_INFO_SAVE_ADDR1 EEPROM_INFO_START_ADDR //<2F>˿<EFBFBD><CBBF><EFBFBD>Ϣ
|
||||
#define EEPROM_INFO_SAVE_ADDR2 0x038000 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#define EEPROM_INFO_SAVE_ADDR3 0x039000 //<2F><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#define EEPROM_INFO_END_ADDR 0x039FFF
|
||||
|
||||
#define EEPROM_INFO_Size 4096 //0x001000 //flash-ROM,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1>λ4K
|
||||
|
||||
#define IMAGE_A_FLAG 0x01
|
||||
#define IMAGE_B_FLAG 0x02
|
||||
#define IMAGE_IAP_FLAG 0x03
|
||||
|
||||
#define EEPROM_DataInfo_Len 0x04 //Ŀǰ<C4BF><C7B0><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||
#define EEPROM_SaveInfo_Flag 0x5A //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־λ
|
||||
#define EEPROM_SaveGpInfo_Flag 0x1A //<2F><><EFBFBD><EFBFBD><EFBFBD>鱣<EFBFBD><E9B1A3><EFBFBD><EFBFBD>־λ
|
||||
#define EEPROM_RARDelayTim_Flag 0x3A //<2F>ӳ<EFBFBD><D3B3>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>ӳٲ<D3B3><D9B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־λ
|
||||
|
||||
|
||||
|
||||
#define DOOR_RDR_DELAYTIME 30000 //<2F>Ŵ<EFBFBD><C5B4><EFBFBD>ʱ<EFBFBD><CAB1>ʱ<EFBFBD><CAB1>
|
||||
#define BATH_RDR_DELAYTIME 3000000 //<2F><>ԡ<EFBFBD><D4A1><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>ʱ<EFBFBD><CAB1>
|
||||
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DataFlash<73><68><EFBFBD><EFBFBD>OTA<54><41>Ϣ */
|
||||
typedef struct
|
||||
{
|
||||
unsigned char ImageFlag; //<2F><>¼<EFBFBD>ĵ<EFBFBD>ǰ<EFBFBD><C7B0>image<67><65>־
|
||||
unsigned char Revd[3]; //<2F><>һ<EFBFBD><D2BB><EFBFBD>ֽڴ<D6BD><DAB4><EFBFBD>OTA<54><41>ת<EFBFBD><D7AA>APP<50>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
}OTADataFlashInfo_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t VC_ConNToSGruop; //<2F><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
uint8_t VC_ConNToSSubset; //<2F><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
uint8_t VC_ConSToNGruop; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD>)
|
||||
uint8_t VC_ConSToNSubset; //<2F><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
uint8_t PortGroupInfo[VIRTUAL_GP_NUM_MAX][15];
|
||||
}GroupInfo_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t Door_RARON_Time; //<2F>Ŵſ<C5B4><C5BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȵƿ<C8B5><C6BF>¼<EFBFBD><C2BC>ӳ<EFBFBD>
|
||||
uint32_t Door_RARFF_TimeOut; //<2F>ȵƹ<C8B5><C6B9>¼<EFBFBD><C2BC>ӳ<EFBFBD>
|
||||
uint32_t BATH_RARON_Time; //<2F><>ԡ<EFBFBD>״↑<D7B4><EFBFAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԡ<EFBFBD>ƿ<EFBFBD><C6BF>¼<EFBFBD><C2BC>ӳ<EFBFBD>
|
||||
uint32_t BATH_RARFF_TimeOut; //<2F><>ԡ<EFBFBD>״↑<D7B4><EFBFAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԡ<EFBFBD>ƹ<EFBFBD><C6B9>¼<EFBFBD><C2BC>ӳ<EFBFBD>
|
||||
|
||||
}RAR_Info;
|
||||
|
||||
|
||||
|
||||
|
||||
/*<2A><><EFBFBD>ֲ<EFBFBD><D6B2><EFBFBD>Ĭ<EFBFBD><C4AC>ֵ*/
|
||||
extern uint8_t PortInfo[VIRTUAL_PORT_MAX][11];
|
||||
extern GroupInfo_t g_portGp;
|
||||
extern RAR_Info g_rar_info;
|
||||
|
||||
uint8_t EEPROM_CheckSum(uint8_t *data,uint16_t len);
|
||||
|
||||
void EEPROM_Init(void);
|
||||
uint8_t EEPROM_Read_PortInfo(void);
|
||||
void EEPROM_Default_PortInfo(void);
|
||||
uint8_t EEPROM_Write_PortInfo(void);
|
||||
|
||||
|
||||
uint8_t EEPROM_Read_PortGroupData(GroupInfo_t *info);
|
||||
void EEPROM_Default_PortGroupData(void);
|
||||
uint8_t EEPROM_Write_PortGroupData(GroupInfo_t *info);
|
||||
|
||||
void EEPROM_Default_RARDelayTim(RAR_Info *RarInfo);
|
||||
uint8_t EEPROM_Write_RARDelayTim(RAR_Info *RarInfo);
|
||||
uint8_t EEPROM_Read_RARDelayTim(RAR_Info *RarInfo);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
135
BLV_RF_W13_V04_20260114/User_Drivers/inc/gattprofile.h
Normal file
135
BLV_RF_W13_V04_20260114/User_Drivers/inc/gattprofile.h
Normal file
@@ -0,0 +1,135 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : gattprofile.h
|
||||
* Author : WCH
|
||||
* Version : V1.0
|
||||
* Date : 2018/12/11
|
||||
* Description :
|
||||
*********************************************************************************
|
||||
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef GATTPROFILE_H
|
||||
#define GATTPROFILE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
* INCLUDES
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* CONSTANTS
|
||||
*/
|
||||
|
||||
// Profile Parameters
|
||||
#define SIMPLEPROFILE_CHAR1 0 // RW uint8_t - Profile Characteristic 1 value
|
||||
#define SIMPLEPROFILE_CHAR2 1 // RW uint8_t - Profile Characteristic 2 value
|
||||
#define SIMPLEPROFILE_CHAR3 2 // RW uint8_t - Profile Characteristic 3 value
|
||||
#define SIMPLEPROFILE_CHAR4 3 // RW uint8_t - Profile Characteristic 4 value
|
||||
#define SIMPLEPROFILE_CHAR5 4 // RW uint8_t - Profile Characteristic 4 value
|
||||
|
||||
// Simple Profile Service UUID
|
||||
#define SIMPLEPROFILE_SERV_UUID 0xFFE0
|
||||
|
||||
// Key Pressed UUID
|
||||
#define SIMPLEPROFILE_CHAR1_UUID 0xFFE1 // д<><D0B4>ͨ<EFBFBD><CDA8>
|
||||
#define SIMPLEPROFILE_CHAR2_UUID 0xFFE4 // δ<><CEB4>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>
|
||||
#define SIMPLEPROFILE_CHAR3_UUID 0xFFE5 // δ<><CEB4>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>
|
||||
#define SIMPLEPROFILE_CHAR4_UUID 0xFFE2 // <20><>ӡͨ<D3A1><CDA8>
|
||||
#define SIMPLEPROFILE_CHAR5_UUID 0xFFE3 // <20><><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δʹ<CEB4><CAB9>
|
||||
|
||||
// Simple Keys Profile Services bit fields
|
||||
#define SIMPLEPROFILE_SERVICE 0x00000001
|
||||
|
||||
// Length of characteristic in bytes ( Default MTU is 23 )
|
||||
#define SIMPLEPROFILE_CHAR1_LEN 80
|
||||
#define SIMPLEPROFILE_CHAR2_LEN 10
|
||||
#define SIMPLEPROFILE_CHAR3_LEN 10
|
||||
#define SIMPLEPROFILE_CHAR4_LEN 60
|
||||
#define SIMPLEPROFILE_CHAR5_LEN 5
|
||||
|
||||
/*********************************************************************
|
||||
* TYPEDEFS
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* MACROS
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* Profile Callbacks
|
||||
*/
|
||||
|
||||
// Callback when a characteristic value has changed
|
||||
typedef void (*simpleProfileChange_t)(uint8_t paramID, uint8_t *pValue, uint16_t len);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
simpleProfileChange_t pfnSimpleProfileChange; // Called when characteristic value changes
|
||||
} simpleProfileCBs_t;
|
||||
|
||||
/*********************************************************************
|
||||
* API FUNCTIONS
|
||||
*/
|
||||
|
||||
/*
|
||||
* SimpleProfile_AddService- Initializes the Simple GATT Profile service by registering
|
||||
* GATT attributes with the GATT server.
|
||||
*
|
||||
* @param services - services to add. This is a bit map and can
|
||||
* contain more than one service.
|
||||
*/
|
||||
|
||||
extern bStatus_t SimpleProfile_AddService(uint32_t services);
|
||||
|
||||
/*
|
||||
* SimpleProfile_RegisterAppCBs - Registers the application callback function.
|
||||
* Only call this function once.
|
||||
*
|
||||
* appCallbacks - pointer to application callbacks.
|
||||
*/
|
||||
extern bStatus_t SimpleProfile_RegisterAppCBs(simpleProfileCBs_t *appCallbacks);
|
||||
|
||||
/*
|
||||
* SimpleProfile_SetParameter - Set a Simple GATT Profile parameter.
|
||||
*
|
||||
* param - Profile parameter ID
|
||||
* len - length of data to right
|
||||
* value - pointer to data to write. This is dependent on
|
||||
* the parameter ID and WILL be cast to the appropriate
|
||||
* data type (example: data type of uint16_t will be cast to
|
||||
* uint16_t pointer).
|
||||
*/
|
||||
extern bStatus_t SimpleProfile_SetParameter(uint8_t param, uint8_t len, void *value);
|
||||
|
||||
/*
|
||||
* SimpleProfile_GetParameter - Get a Simple GATT Profile parameter.
|
||||
*
|
||||
* param - Profile parameter ID
|
||||
* value - pointer to data to write. This is dependent on
|
||||
* the parameter ID and WILL be cast to the appropriate
|
||||
* data type (example: data type of uint16_t will be cast to
|
||||
* uint16_t pointer).
|
||||
*/
|
||||
extern bStatus_t SimpleProfile_GetParameter(uint8_t param, void *value);
|
||||
|
||||
/*
|
||||
* simpleProfile_Notify - Send notification.
|
||||
*
|
||||
* connHandle - connect handle
|
||||
* pNoti - pointer to structure to notify.
|
||||
*/
|
||||
extern bStatus_t simpleProfile_Notify(uint16_t connHandle, attHandleValueNoti_t *pNoti);
|
||||
|
||||
/*********************************************************************
|
||||
*********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
78
BLV_RF_W13_V04_20260114/User_Drivers/inc/peripheral.h
Normal file
78
BLV_RF_W13_V04_20260114/User_Drivers/inc/peripheral.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : peripheral.h
|
||||
* Author : WCH
|
||||
* Version : V1.0
|
||||
* Date : 2018/12/11
|
||||
* Description :
|
||||
*********************************************************************************
|
||||
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef PERIPHERAL_H
|
||||
#define PERIPHERAL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
* INCLUDES
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* CONSTANTS
|
||||
*/
|
||||
|
||||
// Peripheral Task Events
|
||||
#define SBP_START_DEVICE_EVT 0x0001
|
||||
#define SBP_PERIODIC_EVT 0x0002
|
||||
#define SBP_READ_RSSI_EVT 0x0004
|
||||
#define SBP_PARAM_UPDATE_EVT 0x0008
|
||||
#define SBP_PHY_UPDATE_EVT 0x0010
|
||||
|
||||
#define SBP_MTU_DELAY_EVT 0x0020 //YYW,20250917<31><37>MTUЭ<55><D0AD><EFBFBD>¼<EFBFBD>
|
||||
#define SBP_PRINTF_BLE_EVT 0x0040 //YYW,20251008<30><38><EFBFBD><EFBFBD>תOTA<54>¼<EFBFBD>
|
||||
|
||||
|
||||
/* OTA <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־ */
|
||||
#define IMAGE_IAP_FLAG 0x03
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DataFlash<73><68>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB> */
|
||||
#define OTA_DATAFLASH_ADD 0x0003A000
|
||||
/*********************************************************************
|
||||
* MACROS
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t connHandle; // Connection handle of current connection
|
||||
uint16_t connInterval;
|
||||
uint16_t connSlaveLatency;
|
||||
uint16_t connTimeout;
|
||||
} peripheralConnItem_t;
|
||||
|
||||
/*********************************************************************
|
||||
* FUNCTIONS
|
||||
*/
|
||||
extern uint8_t BLE_OTA_flag;
|
||||
/*
|
||||
* Task Initialization for the BLE Application
|
||||
*/
|
||||
extern void Peripheral_Init(void);
|
||||
extern void Ble_Printfln(int DbgOptBit, const char *cmd, ...);
|
||||
extern void Ble_Buff_Print(uint8_t *pValue, uint16_t len);
|
||||
/*
|
||||
* Task Event Processor for the BLE Application
|
||||
*/
|
||||
extern uint16_t Peripheral_ProcessEvent(uint8_t task_id, uint16_t events);
|
||||
void Jump_OTA(void); //YYW,20251009
|
||||
gapRole_States_t Peripheral_GetBLEState(void);
|
||||
/*********************************************************************
|
||||
*********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
240
BLV_RF_W13_V04_20260114/User_Drivers/inc/sensor_scan.h
Normal file
240
BLV_RF_W13_V04_20260114/User_Drivers/inc/sensor_scan.h
Normal file
@@ -0,0 +1,240 @@
|
||||
#ifndef _SENSOR_SCAN_H_
|
||||
#define _SENSOR_SCAN_H_
|
||||
|
||||
|
||||
#define WashRoom_Pin GPIO_Pin_2 //S1
|
||||
#define BedRoom_Pin GPIO_Pin_3 //S2
|
||||
#define GateWay_Pin GPIO_Pin_4
|
||||
#define Retain_Pin GPIO_Pin_5 //<2F>Ŵ<EFBFBD>
|
||||
|
||||
#define DET_EXIST1 GPIO_Pin_6
|
||||
#define DET_EXIST2 GPIO_Pin_7
|
||||
|
||||
|
||||
#define DET_PRESS 0x00
|
||||
#define DET_LOOSEN 0x01
|
||||
|
||||
|
||||
#define DET_NONE 0x00
|
||||
#define DET_SER_PRESS 0x01 //<2F><><EFBFBD><EFBFBD>
|
||||
#define DET_SER_LOOSEN 0x02 //δ<><CEB4><EFBFBD><EFBFBD>
|
||||
#define DET_OPENTOCLOSE 0x03
|
||||
#define DET_CLOSETOOPEN 0x04
|
||||
|
||||
#define DIP_DELAY_COUNT 5 //ɨ<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#define DIP_SCAN_Time 20 //ÿ<><C3BF>ɨ<EFBFBD><C9A8>ʱ<EFBFBD><CAB1>
|
||||
|
||||
#define DET_DELAY_COUNT 10 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#define DET_DELAY_COUNT_LONG 600 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>ʱ<EFBFBD><CAB1>Ϊ3S
|
||||
|
||||
typedef enum{
|
||||
DET_CH0,
|
||||
DET_CH1,
|
||||
DET_CH2,
|
||||
DET_CH3,
|
||||
DET_CH4,
|
||||
|
||||
DET_MAX,
|
||||
}SENSORDET_CH_E;
|
||||
|
||||
|
||||
|
||||
typedef enum {
|
||||
KEY_VAL_NOT, //û<><C3BB><EFBFBD><EFBFBD>
|
||||
KEY_VAL_SHORT_PRESS, //<2F><><EFBFBD><EFBFBD>
|
||||
KEY_VAL_CONT_LONG_PRESS, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
KEY_VAL_SINGLE_LONG_PRESS, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
KEY_VAL_LONG_PRESS_LOOSEN, //<2F><><EFBFBD><EFBFBD><EFBFBD>ɿ<EFBFBD>
|
||||
} KEY_VAL_e;
|
||||
|
||||
|
||||
|
||||
typedef struct{
|
||||
|
||||
uint8_t det_ctrlout_state; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>رձ<D8B1><D5B1><EFBFBD>
|
||||
uint32_t det_action_tick; //<2F><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
|
||||
|
||||
uint8_t door_rarON_flag; //<2F>Ŵſ<C5B4><C5BF><EFBFBD>־
|
||||
uint8_t bath_rarON_flag; //ϴԡ״̬
|
||||
|
||||
uint8_t bath_rarOFF_flag; //ϴԡ<CFB4><D4A1>״̬
|
||||
|
||||
uint32_t door_rarOn_time; //<2F>ŴŹ<C5B4><C5B9>¼<EFBFBD><C2BC><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
uint32_t bath_rarOn_time; //<2F><>ԡ<EFBFBD>״<EFBFBD><D7B4><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
|
||||
uint32_t door_rar_deltime; //<2F>ŴŹ<C5B4><C5B9>¼<EFBFBD><C2BC><EFBFBD>ʱʱ<CAB1><CAB1>
|
||||
uint32_t bath_rar_deltime; //<2F><>ԡ<EFBFBD>״<EFBFBD><D7B4><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>ʱʱ<CAB1><CAB1>
|
||||
|
||||
}__attribute__ ((__packed__))SENSORDET_INFO_T;
|
||||
|
||||
|
||||
|
||||
#define SOMEONE 1 //<2F><><EFBFBD><EFBFBD>
|
||||
#define NOONE 2 //<2F><><EFBFBD><EFBFBD>
|
||||
|
||||
#define VIRTUAL_PORT_MAX 5 //<2F>˿<EFBFBD><CBBF><EFBFBD>
|
||||
#define VIRTUAL_GP_NUM_MAX 9 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
//<2F><><EFBFBD>ö˿ڳ<CBBF>ʱʱ<CAB1><CAB1>
|
||||
#define DETECTION_Window_Hour_Max 8//6
|
||||
#define DETECTION_Window_Min_Max 480//360
|
||||
#define DETECTION_Window_Sec_Max 28800//21600 //<2F><>ʱ<EFBFBD>䴰<EFBFBD>ڼ<EFBFBD><DABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>䣬<EFBFBD><E4A3AC>λ;S
|
||||
#define DETECTION_Window_OnlyPort 240//270 //<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD><CBBF>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>DETECTION_Window_Sec_Max/10/8
|
||||
#define DETECTION_Window_BitMin 15 //һ<><D2BB>bit<69><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#define VC_CONDGROUP_SomeOne_Type 0x01 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#define VC_CONDGROUP_NoOne_Type 0x02
|
||||
#define VC_CONDGROUP_BrieflyLeaving_Type 0x03
|
||||
#define VC_CONDGROUP_LongTermLeaving_Type 0x04
|
||||
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
||||
#define VC_Event_PersonDet_Flag 0x01 //<2F><><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>
|
||||
#define VC_Event_NoPersonDet_Flag 0x02 //<2F><><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>
|
||||
#define VC_Event_DoorSensorOpen_Flag 0x04 //<2F>Ŵſ<C5B4><C5BF>¼<EFBFBD><C2BC><EFBFBD>
|
||||
#define VC_Event_DoorSensorClose_Flag 0x08 //<2F>ŴŹ<C5B4><C5B9>¼<EFBFBD><C2BC><EFBFBD>
|
||||
#define VC_Event_BathroomRadarOn_Flag 0x10 //ϴ<>ּ<EFBFBD><D6BC>״↑<D7B4>¼<EFBFBD><C2BC><EFBFBD>
|
||||
#define VC_Event_BathroomRadarOFF_Flag 0x20 //ϴ<>ּ<EFBFBD><D6BC>״<EFBFBD><D7B4><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>
|
||||
|
||||
|
||||
|
||||
#define VC_CONDGROUP_Default_StartGroup 0x01 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Ĭ<><C4AC><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ0x01
|
||||
#define VC_NONE_Default_StartGroup 0x06 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, Ĭ<><C4AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֧<EFBFBD><D6A7><EFBFBD>ģ<DEB8><C4A3>ռ䲻<D5BC><E4B2BB>
|
||||
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DIP_VAL_OFF, //<2F>ɿ<EFBFBD>
|
||||
DIP_VAL_ON, //<2F><><EFBFBD><EFBFBD>
|
||||
}DIP_VAL_e;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t delayCnt_ON[DET_MAX];
|
||||
uint8_t delayCnt_OFF[DET_MAX];
|
||||
uint32_t DIP_val;
|
||||
uint32_t DIP_last_val;
|
||||
}DIP_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t HPort_Type; //ӳ<><D3B3><EFBFBD>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD>
|
||||
uint8_t HPort_Addr; //ӳ<><D3B3><EFBFBD>˿<EFBFBD>485<38><35>ַ
|
||||
uint16_t HPort_Loop; //ӳ<><D3B3><EFBFBD>˿ڻ<CBBF>·
|
||||
|
||||
uint8_t Release_Thres; //<2F>ͷ<EFBFBD><CDB7><EFBFBD>ֵ <20><><EFBFBD><EFBFBD>-><3E><><EFBFBD><EFBFBD>
|
||||
uint8_t PortIndex; //<2F><><EFBFBD><EFBFBD><EFBFBD>˿ں<CBBF>
|
||||
uint8_t PortEnFlag; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
||||
uint16_t Judgment_Time; //<2F><>·<EFBFBD><C2B7><EFBFBD><EFBFBD>ͳ<EFBFBD><CDB3>ʱ<EFBFBD><CAB1>
|
||||
uint8_t Judgment_Unit; //<2F><>·<EFBFBD><C2B7><EFBFBD><EFBFBD>ͳ<EFBFBD><CDB3>ʱ<EFBFBD>䵥λ
|
||||
uint8_t Trigger_Thres; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ <20><><EFBFBD><EFBFBD>-><3E><><EFBFBD><EFBFBD>
|
||||
}__attribute__ ((__packed__))VPORT_INFO_STRUCT; //<2F>˿<EFBFBD><CBBF><EFBFBD>Ϣ<EFBFBD>ṹ<EFBFBD><E1B9B9> - <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>д洢<D0B4><E6B4A2><EFBFBD>ݽṹ
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t Exist_Flag; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˱<EFBFBD><CBB1><EFBFBD> 1:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 2:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 3:<3A><><EFBFBD><EFBFBD><EFBFBD>뿪 4<><34><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>뿪
|
||||
uint8_t Condi_Gruop; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
uint8_t Condi_Subset; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
uint16_t Judgment_Time; //<2F><><EFBFBD><EFBFBD> - <20>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
uint8_t Judgment_Unit; //<2F><><EFBFBD><EFBFBD> - <20>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>䵥λ
|
||||
|
||||
uint8_t Port_State[VIRTUAL_PORT_MAX]; //<2F>˿<EFBFBD>,0:<3A><><EFBFBD>ж<EFBFBD> 1:<3A><><EFBFBD><EFBFBD> 2:<3A>ͷ<EFBFBD> 4,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 3,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
uint16_t Timeout_Time; //<2F><><EFBFBD><EFBFBD> - <20>ж<EFBFBD><D0B6><EFBFBD>ʱʱ<CAB1><CAB1>
|
||||
uint8_t Timeout_Unit; //<2F><><EFBFBD><EFBFBD> - <20>ж<EFBFBD><D0B6><EFBFBD>ʱʱ<CAB1>䵥λ
|
||||
|
||||
uint8_t Trigger_Flag; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
// uint32_t Trigger_Tick; //<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
|
||||
// uint32_t Timeout_Tick; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱʱ<CAB1><CAB1><EFBFBD><EFBFBD>
|
||||
}__attribute__ ((__packed__))CONDITION_STRUCT; //<2F><><EFBFBD><EFBFBD><EFBFBD>жϽṹ<CFBD><E1B9B9>
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t HPort_Type; //ӳ<><D3B3><EFBFBD>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD>
|
||||
uint8_t HPort_Addr; //ӳ<><D3B3><EFBFBD>˿<EFBFBD>485<38><35>ַ
|
||||
uint16_t HPort_Loop; //ӳ<><D3B3><EFBFBD>˿ڻ<CBBF>·
|
||||
|
||||
uint8_t PortIndex; //<2F><><EFBFBD><EFBFBD><EFBFBD>˿ں<CBBF>
|
||||
uint8_t PortEnFlag; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>ʱ<EFBFBD><CAB1>ͳ<EFBFBD><CDB3><EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
||||
}__attribute__ ((__packed__))VPORT_STRUCT; //<2F>˿<EFBFBD><CBBF><EFBFBD><EFBFBD>Խṹ<D4BD><E1B9B9>
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t Det1sTime; //15s<35><73><EFBFBD>ǰ<E2B5B1><C7B0><EFBFBD><EFBFBD>
|
||||
uint16_t TriggerNum[VIRTUAL_PORT_MAX]; //15s<35>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
uint8_t FullFlag[VIRTUAL_PORT_MAX]; //<2F><><EFBFBD>ⴰ<EFBFBD><E2B4B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><>־λ
|
||||
|
||||
uint8_t Trigger_Thres[VIRTUAL_PORT_MAX]; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ <20><><EFBFBD><EFBFBD>-><3E><><EFBFBD><EFBFBD>
|
||||
uint8_t Release_Thres[VIRTUAL_PORT_MAX]; //<2F>ͷ<EFBFBD><CDB7><EFBFBD>ֵ <20><><EFBFBD><EFBFBD>-><3E><><EFBFBD><EFBFBD>
|
||||
uint16_t DetWinTotalNum[VIRTUAL_PORT_MAX]; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1> Ĭ<><C4AC> 8 Сʱ(<28><>) <20><>λ<EFBFBD><CEBB>S
|
||||
uint16_t DetWinTrigger[VIRTUAL_PORT_MAX]; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>(<28><>λ<EFBFBD><CEBB>n<EFBFBD><6E>)
|
||||
uint16_t DetWinIdex[VIRTUAL_PORT_MAX]; //<2F><><EFBFBD><EFBFBD><EFBFBD>±<EFBFBD>
|
||||
|
||||
}__attribute__ ((__packed__))DETECT_STRUCT; //89B
|
||||
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t PortTick; //<2F>˿ڼ<CBBF><DABC><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD> 4
|
||||
uint8_t PortInit_Flag; //<2F>˿<EFBFBD>ӳ<EFBFBD><D3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1
|
||||
|
||||
VPORT_STRUCT Port_Info[VIRTUAL_PORT_MAX]; //ӳ<><D3B3><EFBFBD>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD> 77
|
||||
uint8_t PortState[VIRTUAL_PORT_MAX]; //<2F>˿<EFBFBD>״̬ 11
|
||||
uint8_t PortStateLast[VIRTUAL_PORT_MAX]; //<2F><>һ<EFBFBD>ζ˿<CEB6>״̬ 11
|
||||
uint8_t PortStateAct[VIRTUAL_PORT_MAX]; //<2F>˿ڶ<CBBF><DAB6><EFBFBD>״̬ 11 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȶ<EFBFBD>ʹ<EFBFBD><CAB9> 0:<3A><><EFBFBD>ж<EFBFBD> 1:<3A><><EFBFBD><EFBFBD> 2:<3A>ͷ<EFBFBD> 3:<3A><><EFBFBD>ر仯 4:<3A><><EFBFBD>ر仯,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD>
|
||||
|
||||
// uint32_t PortTiggleTick[VIRTUAL_PORT_MAX]; //<2F>˿ڼ<CBBF>¼<EFBFBD>㰴ʱ<E3B0B4><CAB1><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD>A9IO<49><4F><EFBFBD><EFBFBD><EFBFBD>ط<EFBFBD><D8B7><EFBFBD><EFBFBD><EFBFBD>״̬ 44
|
||||
DETECT_STRUCT DetInfo; //<2F><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ 102
|
||||
|
||||
float ActThreshold[VIRTUAL_PORT_MAX]; //ʵ<>ʴ<EFBFBD><CAB4><EFBFBD><EFBFBD><EFBFBD>ֵ 44
|
||||
|
||||
uint8_t ExistState; //<2F><><EFBFBD>˻<EFBFBD><CBBB><EFBFBD><EFBFBD><EFBFBD>״̬
|
||||
uint8_t ExistState_Last;
|
||||
uint8_t ConGroupIndx; //<2F><>ǰ<EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>±<EFBFBD>
|
||||
uint8_t Action; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
uint8_t CardState; //<2F>п<EFBFBD>״̬
|
||||
uint8_t CardStateLast;
|
||||
uint8_t DetNum; //<2F><><EFBFBD>봰<EFBFBD>ڼ<EFBFBD><DABC><EFBFBD><EFBFBD>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD>
|
||||
uint8_t Last_ConGroupType; //<2F><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>롢<EFBFBD><EBA1A2>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>¼<EFBFBD>
|
||||
|
||||
uint8_t print_rdrsta_flag; //<2F><><EFBFBD><EFBFBD><EFBFBD>״<EFBFBD>״̬<D7B4><CCAC>־, 0x01,<2C><><EFBFBD><EFBFBD>
|
||||
uint8_t rdrsta_change_flag; // 0x01,<2C>״<EFBFBD>״̬<D7B4>ı<EFBFBD>
|
||||
|
||||
uint32_t Condition_Trigger_Tick;
|
||||
uint32_t Last_Trigger_Tick; //<2F><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
|
||||
|
||||
DIP_t g_Dip; //<2F>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
}__attribute__ ((__packed__))VIRTUALCARD_STRUCT;
|
||||
|
||||
|
||||
|
||||
extern SENSORDET_INFO_T sensor_info;
|
||||
|
||||
|
||||
|
||||
|
||||
void Blv_CardlessPower_Tack(void);
|
||||
void DetWin_WriteData_Bit(uint8_t port,uint16_t idex,uint8_t state);
|
||||
uint8_t DetWin_ReadData_Bit(uint8_t port,uint16_t idex);
|
||||
|
||||
void DIP_ScanTask(void);
|
||||
void Sensor_Init(void);
|
||||
void Action_Task(void);
|
||||
void print_RDRsta_Tack(void);
|
||||
uint8_t BLV_DETInfo_Recv_Processing(uint8_t* RecvData,uint16_t RecvLen);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
47
BLV_RF_W13_V04_20260114/User_Drivers/inc/uart.h
Normal file
47
BLV_RF_W13_V04_20260114/User_Drivers/inc/uart.h
Normal file
@@ -0,0 +1,47 @@
|
||||
#ifndef USER_DRIVERS_UART_C_
|
||||
#define USER_DRIVERS_UART_C_
|
||||
|
||||
#include "CH57x_common.h"
|
||||
|
||||
#define Recv_2400_TimeOut 3 //ms
|
||||
#define Recv_9600_TimeOut 3 //ms
|
||||
#define Recv_115200_TimeOut 3 //ms
|
||||
|
||||
#define USART_BUFFER_NUM 3
|
||||
#define USART_BUFFER_SIZE 80
|
||||
|
||||
#define UART_SEND_BUFFER_NUM 5
|
||||
#define UART_SEND_BUFFER_SIZE 20
|
||||
|
||||
|
||||
#define MCU485_EN_High //GPIOA_SetBits(GPIO_Pin_12)
|
||||
#define MCU485_EN_Low //GPIOA_ResetBits(GPIO_Pin_12)
|
||||
|
||||
typedef uint8_t (*Uart_prt)(uint8_t *,uint16_t);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
UART_0,
|
||||
|
||||
UART_MAX,
|
||||
}UART_IDX;
|
||||
|
||||
typedef struct{
|
||||
|
||||
uint8_t RecvBuffer[USART_BUFFER_SIZE];
|
||||
uint8_t Receiving;
|
||||
uint16_t RecvLen;
|
||||
|
||||
uint32_t RecvTimeout;
|
||||
uint32_t RecvIdleTiming;
|
||||
|
||||
Uart_prt processing_cf; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
|
||||
}__attribute__((packed)) UART_t;
|
||||
|
||||
extern UART_t g_uart[UART_MAX];
|
||||
|
||||
void UARTx_Init(UART_IDX uart_id, uint32_t buad, Uart_prt prt_cf) ;
|
||||
void Set_Uart_recvTimeout(UART_t *set_uart,uint32_t baud);
|
||||
void UART_RECEIVE(void);
|
||||
|
||||
#endif /* USER_DRIVEN_UART_C_ */
|
||||
900
BLV_RF_W13_V04_20260114/User_Drivers/peripheral.c
Normal file
900
BLV_RF_W13_V04_20260114/User_Drivers/peripheral.c
Normal file
@@ -0,0 +1,900 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : peripheral.C
|
||||
* Author : WCH
|
||||
* Version : V1.0
|
||||
* Date : 2018/12/10
|
||||
* Description : <20><><EFBFBD><EFBFBD><EFBFBD>ӻ<EFBFBD><D3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD>㲥<EFBFBD><E3B2A5><EFBFBD>Ӳ<EFBFBD><D3B2><EFBFBD><EFBFBD><EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD>㲥<EFBFBD><E3B2A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӳ<EFBFBD><D3B2><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*********************************************************************************
|
||||
* 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.
|
||||
*******************************************************************************/
|
||||
|
||||
/*********************************************************************
|
||||
* INCLUDES
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "../User/include/includes.h"
|
||||
/*********************************************************************
|
||||
* MACROS
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* CONSTANTS
|
||||
*/
|
||||
|
||||
// How often to perform periodic event
|
||||
#define SBP_PERIODIC_EVT_PERIOD 1600
|
||||
|
||||
// How often to perform read rssi event
|
||||
#define SBP_READ_RSSI_EVT_PERIOD 3200
|
||||
|
||||
// Parameter update delay
|
||||
#define SBP_PARAM_UPDATE_DELAY 6400
|
||||
|
||||
// PHY update delay
|
||||
#define SBP_PHY_UPDATE_DELAY 2400
|
||||
|
||||
// What is the advertising interval when device is discoverable (units of 625us, 80=50ms),<2C><>λΪ625 us
|
||||
#define DEFAULT_ADVERTISING_INTERVAL 160
|
||||
|
||||
// Limited discoverable mode advertises for 30.72s, and then stops
|
||||
// General discoverable mode advertises indefinitely
|
||||
#define DEFAULT_DISCOVERABLE_MODE GAP_ADTYPE_FLAGS_GENERAL
|
||||
|
||||
// Minimum connection interval (units of 1.25ms, 6=7.5ms)
|
||||
#define DEFAULT_DESIRED_MIN_CONN_INTERVAL 8//60//6
|
||||
|
||||
// Maximum connection interval (units of 1.25ms, 100=125ms)
|
||||
#define DEFAULT_DESIRED_MAX_CONN_INTERVAL 40//800//YYW,10/08,100
|
||||
|
||||
// Slave latency to use parameter update
|
||||
#define DEFAULT_DESIRED_SLAVE_LATENCY 0
|
||||
|
||||
// Supervision timeout value (units of 10ms, 100=1s)
|
||||
#define DEFAULT_DESIRED_CONN_TIMEOUT 1000
|
||||
|
||||
// Company Identifier: WCH
|
||||
#define WCH_COMPANY_ID 0x07D7
|
||||
|
||||
/*********************************************************************
|
||||
* TYPEDEFS
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* GLOBAL VARIABLES
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* EXTERNAL VARIABLES
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* EXTERNAL FUNCTIONS
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* LOCAL VARIABLES
|
||||
*/
|
||||
static uint8_t Peripheral_TaskID = INVALID_TASK_ID; // Task ID for internal task/event processing
|
||||
|
||||
uint8_t BLE_OTA_flag = 0x00;
|
||||
|
||||
static gapRole_States_t W13_currentBleState = GAPROLE_INIT;
|
||||
|
||||
|
||||
// GAP - SCAN RSP data (max size = 31 bytes)
|
||||
static uint8_t scanRspData[] = {
|
||||
// complete name
|
||||
0x0D, // length of this data
|
||||
GAP_ADTYPE_LOCAL_NAME_COMPLETE,
|
||||
'B',
|
||||
'L',
|
||||
'V',
|
||||
'_',
|
||||
'W',
|
||||
'1',
|
||||
'3',
|
||||
'_',
|
||||
'0',
|
||||
'0',
|
||||
'0',
|
||||
'0',
|
||||
// connection interval range
|
||||
0x05, // length of this data
|
||||
GAP_ADTYPE_SLAVE_CONN_INTERVAL_RANGE,
|
||||
LO_UINT16(DEFAULT_DESIRED_MIN_CONN_INTERVAL), // 100ms
|
||||
HI_UINT16(DEFAULT_DESIRED_MIN_CONN_INTERVAL),
|
||||
LO_UINT16(DEFAULT_DESIRED_MAX_CONN_INTERVAL), // 1s
|
||||
HI_UINT16(DEFAULT_DESIRED_MAX_CONN_INTERVAL),
|
||||
|
||||
// Tx power level
|
||||
0x02, // length of this data
|
||||
GAP_ADTYPE_POWER_LEVEL,
|
||||
0 // 0dBm
|
||||
};
|
||||
|
||||
// GAP - Advertisement data (max size = 31 bytes, though this is
|
||||
// best kept short to conserve power while advertising)
|
||||
static uint8_t advertData[] = {
|
||||
// Flags; this sets the device to use limited discoverable
|
||||
// mode (advertises for 30 seconds at a time) instead of general
|
||||
// discoverable mode (advertises indefinitely)
|
||||
0x02, // length of this data
|
||||
GAP_ADTYPE_FLAGS,
|
||||
DEFAULT_DISCOVERABLE_MODE | GAP_ADTYPE_FLAGS_BREDR_NOT_SUPPORTED,
|
||||
|
||||
// service UUID, to notify central devices what services are included
|
||||
// in this peripheral
|
||||
0x03, // length of this data
|
||||
GAP_ADTYPE_16BIT_MORE, // some of the UUID's, but not all
|
||||
LO_UINT16(SIMPLEPROFILE_SERV_UUID),
|
||||
HI_UINT16(SIMPLEPROFILE_SERV_UUID)
|
||||
};
|
||||
|
||||
// GAP GATT Attributes
|
||||
static uint8_t attDeviceName[GAP_DEVICE_NAME_LEN] = "BLV_W13_0000";
|
||||
|
||||
// Connection item list
|
||||
static peripheralConnItem_t peripheralConnList;
|
||||
|
||||
static uint16_t peripheralMTU = ATT_MTU_SIZE;
|
||||
/*********************************************************************
|
||||
* LOCAL FUNCTIONS
|
||||
*/
|
||||
static void Peripheral_ProcessTMOSMsg(tmos_event_hdr_t *pMsg);
|
||||
static void peripheralStateNotificationCB(gapRole_States_t newState, gapRoleEvent_t *pEvent);
|
||||
//static void performPeriodicTask(void);
|
||||
|
||||
static void simpleProfileChangeCB(uint8_t paramID, uint8_t *pValue, uint16_t len);
|
||||
static void peripheralParamUpdateCB(uint16_t connHandle, uint16_t connInterval,
|
||||
uint16_t connSlaveLatency, uint16_t connTimeout);
|
||||
static void peripheralInitConnItem(peripheralConnItem_t *peripheralConnList);
|
||||
static void peripheralRssiCB(uint16_t connHandle, int8_t rssi);
|
||||
static void peripheralChar4Notify(uint8_t *pValue, uint16_t len);
|
||||
|
||||
/*********************************************************************
|
||||
* PROFILE CALLBACKS
|
||||
*/
|
||||
|
||||
// GAP Role Callbacks
|
||||
static gapRolesCBs_t Peripheral_PeripheralCBs = {
|
||||
peripheralStateNotificationCB, // Profile State Change Callbacks
|
||||
peripheralRssiCB, // When a valid RSSI is read from controller (not used by application)
|
||||
peripheralParamUpdateCB
|
||||
};
|
||||
|
||||
// Broadcast Callbacks
|
||||
static gapRolesBroadcasterCBs_t Broadcaster_BroadcasterCBs = {
|
||||
NULL, // Not used in peripheral role
|
||||
NULL // Receive scan request callback
|
||||
};
|
||||
|
||||
// GAP Bond Manager Callbacks
|
||||
static gapBondCBs_t Peripheral_BondMgrCBs = {
|
||||
NULL, // Passcode callback (not used by application)
|
||||
NULL, // Pairing / Bonding state Callback (not used by application)
|
||||
NULL // oob callback
|
||||
};
|
||||
|
||||
// Simple GATT Profile Callbacks
|
||||
//<2F><><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>д<EFBFBD><D0B4>
|
||||
static simpleProfileCBs_t Peripheral_SimpleProfileCBs = {
|
||||
simpleProfileChangeCB // Characteristic value change callback
|
||||
};
|
||||
/*********************************************************************
|
||||
* PUBLIC FUNCTIONS
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* @fn Peripheral_Init
|
||||
*
|
||||
* @brief Initialization function for the Peripheral App Task.
|
||||
* This is called during initialization and should contain
|
||||
* any application specific initialization (ie. hardware
|
||||
* initialization/setup, table initialization, power up
|
||||
* notificaiton ... ).
|
||||
*
|
||||
* @param task_id - the ID assigned by TMOS. This ID should be
|
||||
* used to send messages and set timers.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void Peripheral_Init()
|
||||
{
|
||||
Peripheral_TaskID = TMOS_ProcessEventRegister(Peripheral_ProcessEvent);
|
||||
|
||||
// Setup the GAP Peripheral Role Profile
|
||||
{
|
||||
uint8_t initial_advertising_enable = TRUE;
|
||||
uint16_t desired_min_interval = DEFAULT_DESIRED_MIN_CONN_INTERVAL;
|
||||
uint16_t desired_max_interval = DEFAULT_DESIRED_MAX_CONN_INTERVAL;
|
||||
|
||||
// Set the GAP Role Parameters
|
||||
GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t), &initial_advertising_enable); //<2F>㲥ʹ<E3B2A5><CAB9>
|
||||
GAPRole_SetParameter(GAPROLE_SCAN_RSP_DATA, sizeof(scanRspData), scanRspData); //<2F>㲥<EFBFBD><E3B2A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
GAPRole_SetParameter(GAPROLE_ADVERT_DATA, sizeof(advertData), advertData); //
|
||||
GAPRole_SetParameter(GAPROLE_MIN_CONN_INTERVAL, sizeof(uint16_t), &desired_min_interval); //<2F><>С<EFBFBD><D0A1><EFBFBD>Ӽ<EFBFBD><D3BC><EFBFBD>
|
||||
GAPRole_SetParameter(GAPROLE_MAX_CONN_INTERVAL, sizeof(uint16_t), &desired_max_interval); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӽ<EFBFBD><D3BC><EFBFBD>
|
||||
}
|
||||
|
||||
{
|
||||
uint16_t advInt = DEFAULT_ADVERTISING_INTERVAL; //<2F>㲥<EFBFBD><E3B2A5><EFBFBD><EFBFBD>
|
||||
|
||||
// Set advertising interval
|
||||
GAP_SetParamValue(TGAP_DISC_ADV_INT_MIN, advInt); //<2F><><EFBFBD>ù㲥<C3B9><E3B2A5><EFBFBD><EFBFBD>
|
||||
GAP_SetParamValue(TGAP_DISC_ADV_INT_MAX, 320); //YYW,advInt -> 160
|
||||
|
||||
|
||||
// Enable scan req notify
|
||||
GAP_SetParamValue(TGAP_ADV_SCAN_REQ_NOTIFY, ENABLE); // <20><><EFBFBD><EFBFBD>ɨ<EFBFBD><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֪ͨ
|
||||
}
|
||||
|
||||
// Setup the GAP Bond Manager
|
||||
{
|
||||
uint32_t passkey = 123456; // passkey "000000" // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"000000"
|
||||
uint8_t pairMode = GAPBOND_PAIRING_MODE_WAIT_FOR_REQ; // <20>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
||||
uint8_t mitm = TRUE; // <20><><EFBFBD><EFBFBD><EFBFBD>м<EFBFBD><D0BC>˹<EFBFBD><CBB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
uint8_t bonding = TRUE; // <20><><EFBFBD>ð<C3B0><F3B6A8B9><EFBFBD>
|
||||
uint8_t ioCap = GAPBOND_IO_CAP_DISPLAY_ONLY; // IO<49><4F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>룩
|
||||
GAPBondMgr_SetParameter(GAPBOND_PERI_DEFAULT_PASSCODE, sizeof(uint32_t), &passkey);
|
||||
GAPBondMgr_SetParameter(GAPBOND_PERI_PAIRING_MODE, sizeof(uint8_t), &pairMode);
|
||||
GAPBondMgr_SetParameter(GAPBOND_PERI_MITM_PROTECTION, sizeof(uint8_t), &mitm);
|
||||
GAPBondMgr_SetParameter(GAPBOND_PERI_IO_CAPABILITIES, sizeof(uint8_t), &ioCap);
|
||||
GAPBondMgr_SetParameter(GAPBOND_PERI_BONDING_ENABLED, sizeof(uint8_t), &bonding);
|
||||
}
|
||||
|
||||
// Initialize GATT attributes
|
||||
GGS_AddService(GATT_ALL_SERVICES); // GAP ע<><D7A2>ͨ<EFBFBD>÷<EFBFBD><C3B7>ʷ<EFBFBD><CAB7><EFBFBD>
|
||||
GATTServApp_AddService(GATT_ALL_SERVICES); // GATT attributes ע<><D7A2>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD>Է<EFBFBD><D4B7><EFBFBD>
|
||||
SimpleProfile_AddService(GATT_ALL_SERVICES); // Simple GATT Profile ע<><D7A2><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>SimpleProfile<6C><65><EFBFBD><EFBFBD>
|
||||
|
||||
// Set the GAP Characteristics
|
||||
GGS_SetParameter(GGS_DEVICE_NAME_ATT, GAP_DEVICE_NAME_LEN, attDeviceName);
|
||||
|
||||
// Setup the SimpleProfile Characteristic Values
|
||||
{
|
||||
uint8_t charValue1[SIMPLEPROFILE_CHAR1_LEN] = {1}; //<2F><>ʼ<EFBFBD><CABC><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>
|
||||
uint8_t charValue4[SIMPLEPROFILE_CHAR4_LEN] = {0x00};
|
||||
uint8_t charValue5[SIMPLEPROFILE_CHAR5_LEN] = {1, 2, 3, 4, 5};
|
||||
|
||||
SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR1, SIMPLEPROFILE_CHAR1_LEN, charValue1);
|
||||
SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR4, SIMPLEPROFILE_CHAR4_LEN, charValue4);
|
||||
SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR5, SIMPLEPROFILE_CHAR5_LEN, charValue5);
|
||||
}
|
||||
|
||||
// Init Connection Item
|
||||
peripheralInitConnItem(&peripheralConnList); // <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>ӹ<EFBFBD><D3B9><EFBFBD>
|
||||
|
||||
// Register callback with SimpleGATTprofile
|
||||
SimpleProfile_RegisterAppCBs(&Peripheral_SimpleProfileCBs); // ע<><D7A2><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļص<C4BB><D8B5><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
// Register receive scan request callback
|
||||
GAPRole_BroadcasterSetCB(&Broadcaster_BroadcasterCBs); // ע<><D7A2>ɨ<EFBFBD><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD>
|
||||
|
||||
// YYW,20250915,MTUЭ<55><D0AD>
|
||||
GATT_InitClient();
|
||||
|
||||
// Setup a delayed profile startup
|
||||
tmos_set_event(Peripheral_TaskID, SBP_START_DEVICE_EVT); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD>¼<EFBFBD>
|
||||
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn peripheralInitConnItem
|
||||
*
|
||||
* @brief Init Connection Item
|
||||
*
|
||||
* @param peripheralConnList -
|
||||
*
|
||||
* @return NULL
|
||||
*/
|
||||
static void peripheralInitConnItem(peripheralConnItem_t *peripheralConnList)
|
||||
{
|
||||
peripheralConnList->connHandle = GAP_CONNHANDLE_INIT;
|
||||
peripheralConnList->connInterval = 0;
|
||||
peripheralConnList->connSlaveLatency = 0;
|
||||
peripheralConnList->connTimeout = 0;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn Peripheral_ProcessEvent
|
||||
*
|
||||
* @brief Peripheral Application Task event processor. This function
|
||||
* is called to process all events for the task. Events
|
||||
* include timers, messages and any other user defined events.
|
||||
*
|
||||
* @param task_id - The TMOS assigned task ID.
|
||||
* @param events - events to process. This is a bit map and can
|
||||
* contain more than one event.
|
||||
*
|
||||
* @return events not processed
|
||||
*/
|
||||
uint16_t Peripheral_ProcessEvent(uint8_t task_id, uint16_t events)
|
||||
{
|
||||
// VOID task_id; // TMOS required parameter that isn't used in this function
|
||||
|
||||
if(events & SYS_EVENT_MSG)
|
||||
{
|
||||
uint8_t *pMsg;
|
||||
|
||||
if((pMsg = tmos_msg_receive(Peripheral_TaskID)) != NULL)
|
||||
{
|
||||
Peripheral_ProcessTMOSMsg((tmos_event_hdr_t *)pMsg);
|
||||
// Release the TMOS message
|
||||
tmos_msg_deallocate(pMsg);
|
||||
}
|
||||
// return unprocessed events
|
||||
return (events ^ SYS_EVENT_MSG);
|
||||
}
|
||||
|
||||
|
||||
//MTUЭ<55><D0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1s<31><73>ʱ<EFBFBD>ٽ<EFBFBD><D9BD><EFBFBD>MTUЭ<55>̣<EFBFBD>YYW,20250917
|
||||
if(events & SBP_MTU_DELAY_EVT)
|
||||
{
|
||||
if(peripheralConnList.connHandle != GAP_CONNHANDLE_INIT)
|
||||
{
|
||||
// --------------------------
|
||||
// <20>ڴ˴<DAB4><CBB4><EFBFBD><EFBFBD><EFBFBD>MTUЭ<55>̴<EFBFBD><CCB4>루<EFBFBD><EBA3A8><EFBFBD>ģ<EFBFBD>
|
||||
// --------------------------
|
||||
attExchangeMTUReq_t mtuReq;
|
||||
mtuReq.clientRxMTU = 120; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>MTU<54><55>С
|
||||
bStatus_t status = GATT_ExchangeMTU( peripheralConnList.connHandle, &mtuReq, Peripheral_TaskID);
|
||||
if(status == SUCCESS)
|
||||
{
|
||||
PRINT("MTUЭ<EFBFBD>̷<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><EFBFBD>%d\n", mtuReq.clientRxMTU);
|
||||
}
|
||||
else
|
||||
{
|
||||
PRINT("MTUЭ<EFBFBD>̷<EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>״̬<EFBFBD>룺%02x\n", status);
|
||||
}
|
||||
}
|
||||
return (events ^ SBP_MTU_DELAY_EVT);
|
||||
}
|
||||
|
||||
|
||||
if(events & SBP_START_DEVICE_EVT)
|
||||
{
|
||||
// Start the Device
|
||||
GAPRole_PeripheralStartDevice(Peripheral_TaskID, &Peripheral_BondMgrCBs, &Peripheral_PeripheralCBs);
|
||||
return (events ^ SBP_START_DEVICE_EVT);
|
||||
}
|
||||
|
||||
if(events & SBP_PERIODIC_EVT) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
{
|
||||
// Restart timer
|
||||
if(SBP_PERIODIC_EVT_PERIOD)
|
||||
{
|
||||
// tmos_start_task(Peripheral_TaskID, SBP_PERIODIC_EVT, SBP_PERIODIC_EVT_PERIOD);
|
||||
}
|
||||
// Perform periodic application task
|
||||
// performPeriodicTask(); //<2F><><EFBFBD><EFBFBD>ֵ4<D6B5><34><EFBFBD><EFBFBD>ӡ
|
||||
return (events ^ SBP_PERIODIC_EVT);
|
||||
}
|
||||
|
||||
if(events & SBP_PARAM_UPDATE_EVT) //<2F><><EFBFBD>Ӳ<EFBFBD><D3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
{
|
||||
// Send connect param update request
|
||||
// When the current connection parameters already meet the requirements for update, return 0x18(InvalidRange)
|
||||
GAPRole_PeripheralConnParamUpdateReq(peripheralConnList.connHandle,
|
||||
DEFAULT_DESIRED_MIN_CONN_INTERVAL,
|
||||
DEFAULT_DESIRED_MAX_CONN_INTERVAL,
|
||||
DEFAULT_DESIRED_SLAVE_LATENCY, //<2F><><EFBFBD><EFBFBD><EFBFBD>Ĵӻ<C4B4><D3BB>ӳ<EFBFBD>
|
||||
DEFAULT_DESIRED_CONN_TIMEOUT, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD>ʱʱ<CAB1><CAB1>
|
||||
Peripheral_TaskID);
|
||||
|
||||
return (events ^ SBP_PARAM_UPDATE_EVT);
|
||||
}
|
||||
|
||||
if(events & SBP_PHY_UPDATE_EVT)
|
||||
{
|
||||
// start phy update
|
||||
PRINT("PHY Update %x...\n", GAPRole_UpdatePHY(peripheralConnList.connHandle, 0,
|
||||
GAP_PHY_BIT_LE_2M, GAP_PHY_BIT_LE_2M, 0));
|
||||
|
||||
return (events ^ SBP_PHY_UPDATE_EVT);
|
||||
}
|
||||
|
||||
if(events & SBP_READ_RSSI_EVT)
|
||||
{
|
||||
GAPRole_ReadRssiCmd(peripheralConnList.connHandle);
|
||||
tmos_start_task(Peripheral_TaskID, SBP_READ_RSSI_EVT, SBP_READ_RSSI_EVT_PERIOD);
|
||||
return (events ^ SBP_READ_RSSI_EVT);
|
||||
}
|
||||
|
||||
if(events & SBP_PRINTF_BLE_EVT) //YYW,20251008,<2C><>תIAPOTA<54><41><EFBFBD><EFBFBD>
|
||||
{
|
||||
Jump_OTA();
|
||||
return (events ^ SBP_PRINTF_BLE_EVT);
|
||||
}
|
||||
|
||||
// Discard unknown events
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn Peripheral_ProcessGAPMsg
|
||||
*
|
||||
* @brief Process an incoming task message.
|
||||
*
|
||||
* @param pMsg - message to process
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
static void Peripheral_ProcessGAPMsg(gapRoleEvent_t *pEvent)
|
||||
{
|
||||
switch(pEvent->gap.opcode)
|
||||
{
|
||||
case GAP_SCAN_REQUEST_EVENT:
|
||||
{
|
||||
// PRINT("Receive scan req from %x %x %x %x %x %x ..\n", pEvent->scanReqEvt.scannerAddr[0],
|
||||
// pEvent->scanReqEvt.scannerAddr[1], pEvent->scanReqEvt.scannerAddr[2], pEvent->scanReqEvt.scannerAddr[3],
|
||||
// pEvent->scanReqEvt.scannerAddr[4], pEvent->scanReqEvt.scannerAddr[5]);
|
||||
break;
|
||||
}
|
||||
|
||||
case GAP_PHY_UPDATE_EVENT:
|
||||
{
|
||||
PRINT("Phy update Rx:%x Tx:%x ..\n", pEvent->linkPhyUpdate.connRxPHYS, pEvent->linkPhyUpdate.connTxPHYS);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn Peripheral_ProcessTMOSMsg
|
||||
*
|
||||
* @brief Process an incoming task message.
|
||||
*
|
||||
* @param pMsg - message to process
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
static void Peripheral_ProcessTMOSMsg(tmos_event_hdr_t *pMsg)
|
||||
{
|
||||
switch(pMsg->event)
|
||||
{
|
||||
case GAP_MSG_EVENT:
|
||||
{
|
||||
Peripheral_ProcessGAPMsg((gapRoleEvent_t *)pMsg);
|
||||
break;
|
||||
}
|
||||
|
||||
case GATT_MSG_EVENT:
|
||||
{
|
||||
gattMsgEvent_t *pMsgEvent;
|
||||
|
||||
pMsgEvent = (gattMsgEvent_t *)pMsg;
|
||||
if(pMsgEvent->method == ATT_MTU_UPDATED_EVENT)
|
||||
{
|
||||
peripheralMTU = pMsgEvent->msg.exchangeMTUReq.clientRxMTU;
|
||||
PRINT("YYW -- mtu exchange: %d\n", pMsgEvent->msg.exchangeMTUReq.clientRxMTU);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn Peripheral_LinkEstablished
|
||||
*
|
||||
* @brief Process link established.
|
||||
*
|
||||
* @param pEvent - event to process
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
static void Peripheral_LinkEstablished(gapRoleEvent_t *pEvent)
|
||||
{
|
||||
gapEstLinkReqEvent_t *event = (gapEstLinkReqEvent_t *)pEvent;
|
||||
|
||||
// See if already connected
|
||||
if(peripheralConnList.connHandle != GAP_CONNHANDLE_INIT)
|
||||
{
|
||||
GAPRole_TerminateLink(pEvent->linkCmpl.connectionHandle);
|
||||
PRINT("Connection max...\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
peripheralConnList.connHandle = event->connectionHandle;
|
||||
peripheralConnList.connInterval = event->connInterval;
|
||||
peripheralConnList.connSlaveLatency = event->connLatency;
|
||||
peripheralConnList.connTimeout = event->connTimeout;
|
||||
peripheralMTU = ATT_MTU_SIZE;
|
||||
|
||||
// Set timer for periodic event
|
||||
tmos_start_task(Peripheral_TaskID, SBP_PERIODIC_EVT, SBP_PERIODIC_EVT_PERIOD);
|
||||
|
||||
// Set timer for param update event
|
||||
tmos_start_task(Peripheral_TaskID, SBP_PARAM_UPDATE_EVT, SBP_PARAM_UPDATE_DELAY);
|
||||
|
||||
// Start read rssi
|
||||
tmos_start_task(Peripheral_TaskID, SBP_READ_RSSI_EVT, SBP_READ_RSSI_EVT_PERIOD);
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>MTU,YYW,20250917
|
||||
tmos_start_task(Peripheral_TaskID, SBP_MTU_DELAY_EVT, 2000);
|
||||
|
||||
PRINT("Conn %x - Int %x \n", event->connectionHandle, event->connInterval);
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn Peripheral_LinkTerminated
|
||||
*
|
||||
* @brief Process link terminated.
|
||||
*
|
||||
* @param pEvent - event to process
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
static void Peripheral_LinkTerminated(gapRoleEvent_t *pEvent)
|
||||
{
|
||||
gapTerminateLinkEvent_t *event = (gapTerminateLinkEvent_t *)pEvent;
|
||||
|
||||
if(event->connectionHandle == peripheralConnList.connHandle)
|
||||
{
|
||||
peripheralConnList.connHandle = GAP_CONNHANDLE_INIT;
|
||||
peripheralConnList.connInterval = 0;
|
||||
peripheralConnList.connSlaveLatency = 0;
|
||||
peripheralConnList.connTimeout = 0;
|
||||
tmos_stop_task(Peripheral_TaskID, SBP_PERIODIC_EVT);
|
||||
tmos_stop_task(Peripheral_TaskID, SBP_READ_RSSI_EVT);
|
||||
|
||||
//20260119
|
||||
tmos_stop_task(Peripheral_TaskID, SBP_PERIODIC_EVT);
|
||||
tmos_stop_task(Peripheral_TaskID, SBP_READ_RSSI_EVT);
|
||||
tmos_stop_task(Peripheral_TaskID, SBP_PARAM_UPDATE_EVT);
|
||||
tmos_stop_task(Peripheral_TaskID, SBP_MTU_DELAY_EVT);
|
||||
tmos_stop_task(Peripheral_TaskID, SBP_PHY_UPDATE_EVT);
|
||||
|
||||
// Restart advertising
|
||||
{
|
||||
uint8_t advertising_enable = TRUE;
|
||||
GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t), &advertising_enable);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PRINT("ERR..\n");
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn peripheralRssiCB
|
||||
*
|
||||
* @brief RSSI callback.
|
||||
*
|
||||
* @param connHandle - connection handle
|
||||
* @param rssi - RSSI
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
static void peripheralRssiCB(uint16_t connHandle, int8_t rssi)
|
||||
{
|
||||
// PRINT("RSSI -%d dB Conn %x \n", -rssi, connHandle);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn peripheralParamUpdateCB
|
||||
*
|
||||
* @brief Parameter update complete callback
|
||||
*
|
||||
* @param connHandle - connect handle
|
||||
* connInterval - connect interval
|
||||
* connSlaveLatency - connect slave latency
|
||||
* connTimeout - connect timeout
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
static void peripheralParamUpdateCB(uint16_t connHandle, uint16_t connInterval,
|
||||
uint16_t connSlaveLatency, uint16_t connTimeout)
|
||||
{
|
||||
if(connHandle == peripheralConnList.connHandle)
|
||||
{
|
||||
peripheralConnList.connInterval = connInterval;
|
||||
peripheralConnList.connSlaveLatency = connSlaveLatency;
|
||||
peripheralConnList.connTimeout = connTimeout;
|
||||
|
||||
PRINT("Update11 %x - Int %x,%d \n", connHandle, connInterval,connTimeout);
|
||||
}
|
||||
else
|
||||
{
|
||||
PRINT("ERR..\n");
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn peripheralStateNotificationCB
|
||||
*
|
||||
* @brief Notification from the profile of a state change.
|
||||
*
|
||||
* @param newState - new state
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
static void peripheralStateNotificationCB(gapRole_States_t newState, gapRoleEvent_t *pEvent)
|
||||
{
|
||||
W13_currentBleState = (newState & GAPROLE_STATE_ADV_MASK); //2026-01-16,<2C><><EFBFBD><EFBFBD>ble<6C><65><EFBFBD><EFBFBD>״̬
|
||||
|
||||
switch(newState & GAPROLE_STATE_ADV_MASK)
|
||||
{
|
||||
case GAPROLE_STARTED:
|
||||
PRINT("Initialized..\n");
|
||||
break;
|
||||
|
||||
case GAPROLE_ADVERTISING:
|
||||
if(pEvent->gap.opcode == GAP_LINK_TERMINATED_EVENT)
|
||||
{
|
||||
Peripheral_LinkTerminated(pEvent);
|
||||
PRINT("Disconnected.. Reason:%x\n", pEvent->linkTerminate.reason);
|
||||
PRINT("Advertising..\n");
|
||||
}
|
||||
else if(pEvent->gap.opcode == GAP_MAKE_DISCOVERABLE_DONE_EVENT)
|
||||
{
|
||||
PRINT("Advertising..\n");
|
||||
}
|
||||
break;
|
||||
|
||||
case GAPROLE_CONNECTED:
|
||||
if(pEvent->gap.opcode == GAP_LINK_ESTABLISHED_EVENT)
|
||||
{
|
||||
Peripheral_LinkEstablished(pEvent);
|
||||
PRINT("Connected..\n");
|
||||
}
|
||||
break;
|
||||
|
||||
case GAPROLE_CONNECTED_ADV:
|
||||
if(pEvent->gap.opcode == GAP_MAKE_DISCOVERABLE_DONE_EVENT)
|
||||
{
|
||||
PRINT("Connected Advertising..\n");
|
||||
}
|
||||
break;
|
||||
|
||||
case GAPROLE_WAITING:
|
||||
if(pEvent->gap.opcode == GAP_END_DISCOVERABLE_DONE_EVENT)
|
||||
{
|
||||
PRINT("Waiting for advertising..\n");
|
||||
}
|
||||
else if(pEvent->gap.opcode == GAP_LINK_TERMINATED_EVENT)
|
||||
{
|
||||
Peripheral_LinkTerminated(pEvent);
|
||||
PRINT("Disconnected.. Reason:%x\n", pEvent->linkTerminate.reason);
|
||||
}
|
||||
else if(pEvent->gap.opcode == GAP_LINK_ESTABLISHED_EVENT)
|
||||
{
|
||||
if(pEvent->gap.hdr.status != SUCCESS)
|
||||
{
|
||||
PRINT("Waiting for advertising..\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
PRINT("Error..\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PRINT("Error..%x\n", pEvent->gap.opcode);
|
||||
}
|
||||
break;
|
||||
|
||||
case GAPROLE_ERROR:
|
||||
PRINT("Error..\n");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn performPeriodicTask
|
||||
*
|
||||
* @brief Perform a periodic application task. This function gets
|
||||
* called every five seconds as a result of the SBP_PERIODIC_EVT
|
||||
* TMOS event. In this example, the value of the third
|
||||
* characteristic in the SimpleGATTProfile service is retrieved
|
||||
* from the profile, and then copied into the value of the
|
||||
* the fourth characteristic.
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
uint8_t print_BLE[SIMPLEPROFILE_CHAR4_LEN] = {0x00};
|
||||
//static void performPeriodicTask(void)
|
||||
//{
|
||||
//// uint8_t notiData[SIMPLEPROFILE_CHAR4_LEN] = {0x88};
|
||||
//// peripheralChar4Notify(notiData, SIMPLEPROFILE_CHAR4_LEN);
|
||||
//
|
||||
// uint16_t SendLen = sizeof(print_BLE);
|
||||
//
|
||||
//
|
||||
// peripheralChar4Notify(print_BLE, SendLen);
|
||||
//}
|
||||
|
||||
|
||||
void Ble_Printfln(int DbgOptBit, const char *cmd, ...)
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Կ<EFBFBD><D4BF>ض<EFBFBD>Ӧλ<D3A6><CEBB><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>ִ<EFBFBD><D6B4>
|
||||
if (DBG_LOG_EN && (Dbg_Switch & (1 << DbgOptBit))) {
|
||||
va_list args;
|
||||
va_start(args, cmd); // <20><>ʼ<EFBFBD><CABC><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
|
||||
|
||||
// <20><><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD>뻺<EFBFBD><EBBBBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>SIMPLEPROFILE_CHAR4_LEN<45>ֽ<EFBFBD>
|
||||
// vsnprintf<74><66><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD>ĩβ<C4A9><CEB2><EFBFBD><EFBFBD>'\0'<27><>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int formatted_len = vsnprintf(
|
||||
(char *)print_BLE, // Ŀ<>껺<EFBFBD><EABBBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǿ<EFBFBD><C7BF>ת<EFBFBD><D7AA>Ϊchar*<2A><><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
SIMPLEPROFILE_CHAR4_LEN, // <20><><EFBFBD><EFBFBD>д<EFBFBD>볤<EFBFBD>ȣ<EFBFBD><C8A3><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD>
|
||||
cmd, // <20><>ʽ<EFBFBD><CABD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
||||
args // <20>ɱ<EFBFBD><C9B1><EFBFBD><EFBFBD><EFBFBD>
|
||||
);
|
||||
va_end(args); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
|
||||
|
||||
// <20><><EFBFBD><EFBFBD>ʵ<EFBFBD>ʷ<EFBFBD><CAB7>ͳ<EFBFBD><CDB3>ȣ<EFBFBD><C8A3>ų<EFBFBD><C5B3><EFBFBD>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1>
|
||||
uint16_t send_len = 0;
|
||||
if (formatted_len > 0) { // <20><>ʽ<EFBFBD><CABD><EFBFBD>ɹ<EFBFBD>
|
||||
send_len = (formatted_len < SIMPLEPROFILE_CHAR4_LEN) ?
|
||||
formatted_len : (SIMPLEPROFILE_CHAR4_LEN - 1);
|
||||
}
|
||||
|
||||
// ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ4<D6B5><34><EFBFBD><EFBFBD>BLE֪ͨ
|
||||
if (send_len > 0) {
|
||||
peripheralChar4Notify(print_BLE, send_len);
|
||||
}
|
||||
}
|
||||
}
|
||||
void Ble_Buff_Print(uint8_t *pValue, uint16_t len)
|
||||
{
|
||||
if (len > 0) {
|
||||
peripheralChar4Notify(pValue, len);
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn peripheralChar4Notify
|
||||
*
|
||||
* @brief Prepare and send simpleProfileChar4 notification
|
||||
*
|
||||
* @param pValue - data to notify
|
||||
* len - length of data
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
static void peripheralChar4Notify(uint8_t *pValue, uint16_t len)
|
||||
{
|
||||
attHandleValueNoti_t noti;
|
||||
|
||||
//YYW,1008
|
||||
if(peripheralConnList.connHandle == GAP_CONNHANDLE_INIT)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(len > (peripheralMTU - 3))
|
||||
{
|
||||
PRINT("Too large noti\n");
|
||||
return;
|
||||
}
|
||||
noti.len = len;
|
||||
noti.pValue = GATT_bm_alloc(peripheralConnList.connHandle, ATT_HANDLE_VALUE_NOTI, noti.len, NULL, 0);
|
||||
if(noti.pValue)
|
||||
{
|
||||
tmos_memcpy(noti.pValue, pValue, noti.len);
|
||||
if(simpleProfile_Notify(peripheralConnList.connHandle, ¬i) != SUCCESS)
|
||||
{
|
||||
GATT_bm_free((gattMsg_t *)¬i, ATT_HANDLE_VALUE_NOTI);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* flash<73><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>洢 */
|
||||
__attribute__((aligned(8))) uint8_t block_buf[16];
|
||||
|
||||
/*********************************************************************
|
||||
* @fn Jump_OTA
|
||||
*
|
||||
* @brief <20><>תOTA<54><41><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void Jump_OTA(void)
|
||||
{
|
||||
uint16_t i;
|
||||
uint32_t ver_flag;
|
||||
|
||||
/* <20><>ȡ<EFBFBD><C8A1>һ<EFBFBD><D2BB> */
|
||||
FLASH_ROM_READ(OTA_DATAFLASH_ADD, (uint32_t *)&block_buf[0], 4);
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB> */
|
||||
FLASH_ROM_ERASE(OTA_DATAFLASH_ADD, FLASH_BLOCK_SIZE);
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD>Image<67><65>Ϣ */
|
||||
block_buf[0] = IMAGE_IAP_FLAG;
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD>DataFlash */
|
||||
FLASH_ROM_WRITE(OTA_DATAFLASH_ADD, (uint32_t *)&block_buf[0], 4);
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD>λ */
|
||||
SYS_ResetExecute();
|
||||
}
|
||||
/*********************************************************************
|
||||
* @fn simpleProfileChangeCB
|
||||
*
|
||||
* @brief Callback from SimpleBLEProfile indicating a value change
|
||||
*
|
||||
* @param paramID - parameter ID of the value that was changed.
|
||||
* pValue - pointer to data that was changed
|
||||
* len - length of data
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
static void simpleProfileChangeCB(uint8_t paramID, uint8_t *pValue, uint16_t len)
|
||||
{
|
||||
uint8_t rev = 0xFF;
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>洢<EFBFBD><E6B4A2>ֵ<EFBFBD>ı<EFBFBD>
|
||||
switch(paramID)
|
||||
{
|
||||
case SIMPLEPROFILE_CHAR1:
|
||||
{
|
||||
uint8_t newValue[SIMPLEPROFILE_CHAR1_LEN];
|
||||
tmos_memcpy(newValue, pValue, len);
|
||||
tmos_memset(pValue,0,len);
|
||||
// PRINT("profile ChangeCB CHAR1,len:%d\n",len);
|
||||
|
||||
if(rev != 0x00)
|
||||
{
|
||||
rev = BLV_DETInfo_Recv_Processing(newValue,len);
|
||||
}
|
||||
|
||||
if(BLE_OTA_flag == 0x01)
|
||||
{
|
||||
BLE_OTA_flag = 0x00;
|
||||
tmos_start_task(Peripheral_TaskID, SBP_PRINTF_BLE_EVT, 800);
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case SIMPLEPROFILE_CHAR3:
|
||||
{
|
||||
uint8_t newValue[SIMPLEPROFILE_CHAR3_LEN];
|
||||
tmos_memcpy(newValue, pValue, len);
|
||||
PRINT("profile ChangeCB CHAR3..\n");
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
// should not reach here!
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn Peripheral_GetBLEState
|
||||
*
|
||||
* @brief Get current BLE state
|
||||
*
|
||||
* @return current BLE state,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
||||
*/
|
||||
gapRole_States_t Peripheral_GetBLEState(void)
|
||||
{
|
||||
return W13_currentBleState;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
*********************************************************************/
|
||||
1703
BLV_RF_W13_V04_20260114/User_Drivers/sensor_scan.c
Normal file
1703
BLV_RF_W13_V04_20260114/User_Drivers/sensor_scan.c
Normal file
File diff suppressed because it is too large
Load Diff
174
BLV_RF_W13_V04_20260114/User_Drivers/uart.c
Normal file
174
BLV_RF_W13_V04_20260114/User_Drivers/uart.c
Normal file
@@ -0,0 +1,174 @@
|
||||
#include <stdarg.h>
|
||||
#include "../User/include/includes.h"
|
||||
|
||||
UART_t g_uart[UART_MAX];
|
||||
|
||||
uint8_t g_Dealbuf[USART_BUFFER_SIZE];
|
||||
uint16_t g_DealLen = 0x00;
|
||||
|
||||
//uint8_t UART0_RecvBuff[USART_BUFFER_NUM][USART_BUFFER_SIZE]; //USART0 <20><><EFBFBD><EFBFBD><EFBFBD>ݽ<EFBFBD><DDBD>ջ<EFBFBD><D5BB><EFBFBD>
|
||||
//uint8_t *UART0_RecvInPtr; //ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD>ջ<EFBFBD><D5BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>λ<EFBFBD><CEBB>
|
||||
//uint8_t *UART0_RecvOutPtr; //ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD>ջ<EFBFBD><D5BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>ݵ<EFBFBD>λ<EFBFBD><CEBB>
|
||||
//uint8_t *UART0_RecvEndPtr; //ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD>ջ<EFBFBD><D5BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
||||
//
|
||||
////<2F><><EFBFBD><EFBFBD>RS485<38><35><EFBFBD><EFBFBD>
|
||||
//uint8_t UART0_SendBuff[UART_SEND_BUFFER_NUM][UART_SEND_BUFFER_SIZE]; //USART0 <20><><EFBFBD><EFBFBD><EFBFBD>ݷ<EFBFBD><DDB7>ͻ<EFBFBD><CDBB><EFBFBD>
|
||||
//uint8_t *UART0_SendInPtr; //ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>λ<EFBFBD><CEBB>
|
||||
//uint8_t *UART0_SendOutPtr; //ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>ݵ<EFBFBD>λ<EFBFBD><CEBB>
|
||||
//uint8_t *UART0_SendEndPtr; //ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
||||
|
||||
/*********************************************************************
|
||||
* @fn : UARTx_Init
|
||||
* @brief : UART<52><54>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @param : uart_id - <20><><EFBFBD><EFBFBD>ID
|
||||
* @param : buad - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @param : prt_cf - <20><><EFBFBD>ڽ<EFBFBD><DABD>ջص<D5BB><D8B5><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @return : none
|
||||
*/
|
||||
void UARTx_Init(UART_IDX uart_id, uint32_t buad, Uart_prt prt_cf)
|
||||
{
|
||||
switch (uart_id) {
|
||||
case UART_0:
|
||||
/*<2A><>ʼ<EFBFBD><CABC> 485ʹ<35><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
//GPIOA_ModeCfg(GPIO_Pin_12, GPIO_ModeOut_PP_20mA);
|
||||
|
||||
/* <20><><EFBFBD>ô<EFBFBD><C3B4><EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IO<49><4F>ģʽ<C4A3><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ô<EFBFBD><C3B4><EFBFBD> */
|
||||
// GPIOADigitalCfg(ENABLE,GPIO_Pin_0);
|
||||
R16_PIN_ALTERNATE &= ~(1<<14); //<2F><><EFBFBD><EFBFBD>PA0,PA1<41><31>UART<52><54><EFBFBD><EFBFBD>
|
||||
|
||||
GPIOA_SetBits(bTXD_2);
|
||||
GPIOA_ModeCfg(bRXD_2, GPIO_ModeIN_PU); // RXD-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
GPIOA_ModeCfg(bTXD_2, GPIO_ModeOut_PP_5mA); // TXD-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IO<49><4F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD>ƽ
|
||||
UART_Remap(ENABLE, UART_TX_REMAP_PA1, UART_RX_REMAP_PA0);
|
||||
|
||||
// GPIOA_SetBits(bTXD_0);
|
||||
// GPIOA_ModeCfg(bRXD_0, GPIO_ModeIN_PU); // RXD-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// GPIOA_ModeCfg(bTXD_0, GPIO_ModeOut_PP_5mA); // TXD-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IO<49><4F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD>ƽ
|
||||
// UART_Remap(ENABLE, UART_TX_REMAP_PA3, UART_RX_REMAP_PA2);
|
||||
|
||||
//UART_DefInit();
|
||||
UART_BaudRateCfg(buad);
|
||||
R8_UART_FCR = RB_FCR_FIFO_EN;//(2 << 6) | RB_FCR_FIFO_EN; // FIFO<46><EFBFBD>1 0 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>4<EFBFBD>ֽ<EFBFBD>
|
||||
R8_UART_LCR = RB_LCR_WORD_SZ;
|
||||
R8_UART_IER = RB_IER_TXD_EN;
|
||||
R8_UART_DIV = 1;
|
||||
|
||||
UART_ByteTrigCfg( UART_7BYTE_TRIG );
|
||||
UART_INTCfg( ENABLE, RB_IER_RECV_RDY|RB_IER_LINE_STAT );
|
||||
// UART_INTCfg(ENABLE, RB_IER_RECV_RDY | RB_IER_LINE_STAT| RB_IER_THR_EMPTY);
|
||||
PFIC_EnableIRQ(UART_IRQn);
|
||||
|
||||
memset(&g_uart[UART_0],0,sizeof(UART_t));
|
||||
Set_Uart_recvTimeout(&g_uart[UART_0],buad);
|
||||
g_uart[UART_0].processing_cf = prt_cf;
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Set_Uart_recvTimeout(UART_t *set_uart,uint32_t baud)
|
||||
{
|
||||
if(baud == 115200)
|
||||
{
|
||||
set_uart->RecvTimeout = Recv_115200_TimeOut;
|
||||
}else if(baud == 9600)
|
||||
{
|
||||
set_uart->RecvTimeout = Recv_9600_TimeOut;
|
||||
}else if(baud == 2400)
|
||||
{
|
||||
set_uart->RecvTimeout = Recv_2400_TimeOut;
|
||||
}else
|
||||
{
|
||||
set_uart->RecvTimeout = 20;
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn UART0_IRQHandler
|
||||
*
|
||||
* @brief UART0<54>жϺ<D0B6><CFBA><EFBFBD>
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
__INTERRUPT
|
||||
__HIGH_CODE
|
||||
void UART_IRQHandler(void)
|
||||
{
|
||||
volatile uint8_t i;
|
||||
|
||||
switch(UART_GetITFlag())
|
||||
{
|
||||
case UART_II_LINE_STAT: // <20><>·״̬<D7B4><CCAC><EFBFBD><EFBFBD>
|
||||
i = UART_GetLinSTA();
|
||||
break;
|
||||
case UART_II_RECV_RDY: // <20><><EFBFBD>ݴﵽ<DDB4><EFB5BD><EFBFBD>ô<EFBFBD><C3B4><EFBFBD><EFBFBD><EFBFBD>
|
||||
case UART_II_RECV_TOUT: // <20><><EFBFBD>ճ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ʱһ֡<D2BB><D6A1><EFBFBD>ݽ<EFBFBD><DDBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
i = R8_UART_RFC;
|
||||
if((g_uart[UART_0].RecvLen + i) >= USART_BUFFER_SIZE) g_uart[UART_0].RecvLen = 0;
|
||||
i = UART_RecvString(&g_uart[UART_0].RecvBuffer[g_uart[UART_0].RecvLen]);
|
||||
g_uart[UART_0].RecvLen += i;
|
||||
g_uart[UART_0].RecvIdleTiming = SysTick_1ms;
|
||||
|
||||
g_uart[UART_0].Receiving = 0x01;
|
||||
break;
|
||||
case UART_II_THR_EMPTY: // <20><><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>գ<EFBFBD><D5A3>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn UART0_RECEIVE
|
||||
*
|
||||
* @brief UART0
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void UART_RECEIVE(void)
|
||||
{
|
||||
uint8_t rev = 0xFF;
|
||||
uint16_t i = 0;
|
||||
if(g_uart[UART_0].Receiving == 1)
|
||||
{
|
||||
if(SysTick_1ms - g_uart[UART_0].RecvIdleTiming > g_uart[UART_0].RecvTimeout)
|
||||
{
|
||||
g_uart[UART_0].RecvIdleTiming = SysTick_1ms;
|
||||
/*<2A>ж<EFBFBD>RX FIFO<46><4F><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
if(UART_GetLinSTA() & 0x01)
|
||||
{
|
||||
i = R8_UART_RFC;
|
||||
if((g_uart[UART_0].RecvLen + i) >= USART_BUFFER_SIZE) g_uart[UART_0].RecvLen = 0;
|
||||
i = UART_RecvString(&g_uart[UART_0].RecvBuffer[g_uart[UART_0].RecvLen]);
|
||||
g_uart[UART_0].RecvLen += i;
|
||||
return ;
|
||||
}
|
||||
// printf("UART0_RECEIVE len:%d %08x \r\n",g_uart[UART_0].RecvLen,UART0_RecvInPtr);
|
||||
// Dbg_Print_Buff(DBG_BIT_PC_COMM,"buff:",g_uart[UART_0].RecvBuffer,g_uart[UART_0].RecvLen);
|
||||
|
||||
g_uart[UART_0].Receiving = 0;
|
||||
|
||||
|
||||
memcpy(g_Dealbuf,g_uart[UART_0].RecvBuffer,g_uart[UART_0].RecvLen);
|
||||
g_DealLen = g_uart[UART_0].RecvLen;
|
||||
|
||||
|
||||
if(g_uart[UART_0].processing_cf != NULL){
|
||||
rev = g_uart[UART_0].processing_cf(g_Dealbuf,g_DealLen);
|
||||
}
|
||||
|
||||
g_uart[UART_0].RecvLen = 0;
|
||||
g_uart[UART_0].Receiving = 0;
|
||||
|
||||
memset(g_Dealbuf,0x00,g_DealLen);
|
||||
g_DealLen = 0x00;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
21
BLV_RF_W13_V04_20260114/obj/APP/subdir.mk
Normal file
21
BLV_RF_W13_V04_20260114/obj/APP/subdir.mk
Normal file
@@ -0,0 +1,21 @@
|
||||
################################################################################
|
||||
# MRS Version: 1.9.2
|
||||
# <20>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD>ɵ<EFBFBD><C9B5>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>༭<EFBFBD><E0BCAD>
|
||||
################################################################################
|
||||
|
||||
# Add inputs and outputs from these tool invocations to the build variables
|
||||
C_SRCS += \
|
||||
../APP/main.c
|
||||
|
||||
OBJS += \
|
||||
./APP/main.o
|
||||
|
||||
C_DEPS += \
|
||||
./APP/main.d
|
||||
|
||||
|
||||
# Each subdirectory must supply rules for building sources it contributes
|
||||
APP/%.o: ../APP/%.c
|
||||
@ @ riscv-none-elf-gcc -march=rv32imc_zba_zbb_zbc_zbs_xw -mabi=ilp32 -mcmodel=medany -msmall-data-limit=8 -mno-save-restore -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common --param=highcode-gen-section-name=1 -g -DDEBUG=0 -DBLE_BUFF_MAX_LEN=128 -I"G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_C13_New\Startup" -I"G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_C13_New\APP\include" -I"G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_C13_New\StdPeriphDriver\inc" -I"G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_C13_New\HAL\include" -I"G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_C13_New\Ld" -I"G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_C13_New\LIB" -I"G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_C13_New\RVMSIS" -I"G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_C13_New\User_Drivers\inc" -I"G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_C13_New\User_Drivers" -std=gnu99 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
|
||||
@ @
|
||||
|
||||
1093
BLV_RF_W13_V04_20260114/obj/BLV_RF_C13.mem
Normal file
1093
BLV_RF_W13_V04_20260114/obj/BLV_RF_C13.mem
Normal file
File diff suppressed because it is too large
Load Diff
1088
BLV_RF_W13_V04_20260114/obj/BLV_RF_C13.mem_bak
Normal file
1088
BLV_RF_W13_V04_20260114/obj/BLV_RF_C13.mem_bak
Normal file
File diff suppressed because it is too large
Load Diff
BIN
BLV_RF_W13_V04_20260114/obj/BLV_RF_C13_V02.BIN
Normal file
BIN
BLV_RF_W13_V04_20260114/obj/BLV_RF_C13_V02.BIN
Normal file
Binary file not shown.
5481
BLV_RF_W13_V04_20260114/obj/BLV_RF_C13_V02.map
Normal file
5481
BLV_RF_W13_V04_20260114/obj/BLV_RF_C13_V02.map
Normal file
File diff suppressed because it is too large
Load Diff
BIN
BLV_RF_W13_V04_20260114/obj/BLV_RF_W13_V04.elf
Normal file
BIN
BLV_RF_W13_V04_20260114/obj/BLV_RF_W13_V04.elf
Normal file
Binary file not shown.
6794
BLV_RF_W13_V04_20260114/obj/BLV_RF_W13_V04.hex
Normal file
6794
BLV_RF_W13_V04_20260114/obj/BLV_RF_W13_V04.hex
Normal file
File diff suppressed because it is too large
Load Diff
47813
BLV_RF_W13_V04_20260114/obj/BLV_RF_W13_V04.lst
Normal file
47813
BLV_RF_W13_V04_20260114/obj/BLV_RF_W13_V04.lst
Normal file
File diff suppressed because it is too large
Load Diff
5481
BLV_RF_W13_V04_20260114/obj/BLV_RF_W13_V04.map
Normal file
5481
BLV_RF_W13_V04_20260114/obj/BLV_RF_W13_V04.map
Normal file
File diff suppressed because it is too large
Load Diff
47
BLV_RF_W13_V04_20260114/obj/HAL/MCU.d
Normal file
47
BLV_RF_W13_V04_20260114/obj/HAL/MCU.d
Normal file
@@ -0,0 +1,47 @@
|
||||
HAL/MCU.o: ../HAL/MCU.c \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\HAL\include/HAL.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\HAL\include/CONFIG.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\LIB/CH572BLEPeri_LIB.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_common.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH572SFR.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\RVMSIS/core_riscv.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_clk.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_cmp.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_keyscan.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_uart.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_gpio.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_i2c.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_flash.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_pwr.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_pwm.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_sys.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_timer.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_spi.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_usbdev.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_usbhost.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/ISP572.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\HAL\include/RTC.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\HAL\include/SLEEP.h
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\HAL\include/HAL.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\HAL\include/CONFIG.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\LIB/CH572BLEPeri_LIB.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_common.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH572SFR.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\RVMSIS/core_riscv.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_clk.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_cmp.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_keyscan.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_uart.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_gpio.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_i2c.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_flash.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_pwr.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_pwm.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_sys.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_timer.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_spi.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_usbdev.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_usbhost.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/ISP572.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\HAL\include/RTC.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\HAL\include/SLEEP.h:
|
||||
BIN
BLV_RF_W13_V04_20260114/obj/HAL/MCU.o
Normal file
BIN
BLV_RF_W13_V04_20260114/obj/HAL/MCU.o
Normal file
Binary file not shown.
47
BLV_RF_W13_V04_20260114/obj/HAL/RTC.d
Normal file
47
BLV_RF_W13_V04_20260114/obj/HAL/RTC.d
Normal file
@@ -0,0 +1,47 @@
|
||||
HAL/RTC.o: ../HAL/RTC.c \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\HAL\include/HAL.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\HAL\include/CONFIG.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\LIB/CH572BLEPeri_LIB.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_common.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH572SFR.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\RVMSIS/core_riscv.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_clk.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_cmp.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_keyscan.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_uart.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_gpio.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_i2c.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_flash.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_pwr.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_pwm.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_sys.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_timer.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_spi.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_usbdev.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_usbhost.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/ISP572.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\HAL\include/RTC.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\HAL\include/SLEEP.h
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\HAL\include/HAL.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\HAL\include/CONFIG.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\LIB/CH572BLEPeri_LIB.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_common.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH572SFR.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\RVMSIS/core_riscv.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_clk.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_cmp.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_keyscan.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_uart.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_gpio.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_i2c.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_flash.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_pwr.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_pwm.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_sys.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_timer.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_spi.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_usbdev.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_usbhost.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/ISP572.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\HAL\include/RTC.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\HAL\include/SLEEP.h:
|
||||
BIN
BLV_RF_W13_V04_20260114/obj/HAL/RTC.o
Normal file
BIN
BLV_RF_W13_V04_20260114/obj/HAL/RTC.o
Normal file
Binary file not shown.
47
BLV_RF_W13_V04_20260114/obj/HAL/SLEEP.d
Normal file
47
BLV_RF_W13_V04_20260114/obj/HAL/SLEEP.d
Normal file
@@ -0,0 +1,47 @@
|
||||
HAL/SLEEP.o: ../HAL/SLEEP.c \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\HAL\include/HAL.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\HAL\include/CONFIG.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\LIB/CH572BLEPeri_LIB.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_common.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH572SFR.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\RVMSIS/core_riscv.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_clk.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_cmp.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_keyscan.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_uart.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_gpio.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_i2c.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_flash.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_pwr.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_pwm.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_sys.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_timer.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_spi.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_usbdev.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_usbhost.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/ISP572.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\HAL\include/RTC.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\HAL\include/SLEEP.h
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\HAL\include/HAL.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\HAL\include/CONFIG.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\LIB/CH572BLEPeri_LIB.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_common.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH572SFR.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\RVMSIS/core_riscv.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_clk.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_cmp.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_keyscan.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_uart.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_gpio.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_i2c.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_flash.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_pwr.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_pwm.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_sys.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_timer.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_spi.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_usbdev.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_usbhost.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/ISP572.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\HAL\include/RTC.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\HAL\include/SLEEP.h:
|
||||
BIN
BLV_RF_W13_V04_20260114/obj/HAL/SLEEP.o
Normal file
BIN
BLV_RF_W13_V04_20260114/obj/HAL/SLEEP.o
Normal file
Binary file not shown.
27
BLV_RF_W13_V04_20260114/obj/HAL/subdir.mk
Normal file
27
BLV_RF_W13_V04_20260114/obj/HAL/subdir.mk
Normal file
@@ -0,0 +1,27 @@
|
||||
################################################################################
|
||||
# MRS Version: 1.9.2
|
||||
# <20>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD>ɵ<EFBFBD><C9B5>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>༭<EFBFBD><E0BCAD>
|
||||
################################################################################
|
||||
|
||||
# Add inputs and outputs from these tool invocations to the build variables
|
||||
C_SRCS += \
|
||||
../HAL/MCU.c \
|
||||
../HAL/RTC.c \
|
||||
../HAL/SLEEP.c
|
||||
|
||||
OBJS += \
|
||||
./HAL/MCU.o \
|
||||
./HAL/RTC.o \
|
||||
./HAL/SLEEP.o
|
||||
|
||||
C_DEPS += \
|
||||
./HAL/MCU.d \
|
||||
./HAL/RTC.d \
|
||||
./HAL/SLEEP.d
|
||||
|
||||
|
||||
# Each subdirectory must supply rules for building sources it contributes
|
||||
HAL/%.o: ../HAL/%.c
|
||||
@ @ riscv-none-elf-gcc -march=rv32imc_zba_zbb_zbc_zbs_xw -mabi=ilp32 -mcmodel=medany -msmall-data-limit=8 -mno-save-restore -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common --param=highcode-gen-section-name=1 -g -DDEBUG=0 -DBLE_BUFF_MAX_LEN=128 -I"G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\Startup" -I"G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc" -I"G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\HAL\include" -I"G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\Ld" -I"G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\LIB" -I"G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\RVMSIS" -I"G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\User_Drivers\inc" -I"G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\User_Drivers" -I"G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\User\include" -I"G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\User" -std=gnu99 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
|
||||
@ @
|
||||
|
||||
1
BLV_RF_W13_V04_20260114/obj/Startup/startup_CH572.d
Normal file
1
BLV_RF_W13_V04_20260114/obj/Startup/startup_CH572.d
Normal file
@@ -0,0 +1 @@
|
||||
Startup/startup_CH572.o: ../Startup/startup_CH572.S
|
||||
BIN
BLV_RF_W13_V04_20260114/obj/Startup/startup_CH572.o
Normal file
BIN
BLV_RF_W13_V04_20260114/obj/Startup/startup_CH572.o
Normal file
Binary file not shown.
21
BLV_RF_W13_V04_20260114/obj/Startup/subdir.mk
Normal file
21
BLV_RF_W13_V04_20260114/obj/Startup/subdir.mk
Normal file
@@ -0,0 +1,21 @@
|
||||
################################################################################
|
||||
# MRS Version: 1.9.2
|
||||
# <20>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD>ɵ<EFBFBD><C9B5>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>༭<EFBFBD><E0BCAD>
|
||||
################################################################################
|
||||
|
||||
# Add inputs and outputs from these tool invocations to the build variables
|
||||
S_UPPER_SRCS += \
|
||||
../Startup/startup_CH572.S
|
||||
|
||||
OBJS += \
|
||||
./Startup/startup_CH572.o
|
||||
|
||||
S_UPPER_DEPS += \
|
||||
./Startup/startup_CH572.d
|
||||
|
||||
|
||||
# Each subdirectory must supply rules for building sources it contributes
|
||||
Startup/%.o: ../Startup/%.S
|
||||
@ @ riscv-none-elf-gcc -march=rv32imc_zba_zbb_zbc_zbs_xw -mabi=ilp32 -mcmodel=medany -msmall-data-limit=8 -mno-save-restore -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common --param=highcode-gen-section-name=1 -g -x assembler-with-cpp -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
|
||||
@ @
|
||||
|
||||
37
BLV_RF_W13_V04_20260114/obj/StdPeriphDriver/CH57x_clk.d
Normal file
37
BLV_RF_W13_V04_20260114/obj/StdPeriphDriver/CH57x_clk.d
Normal file
@@ -0,0 +1,37 @@
|
||||
StdPeriphDriver/CH57x_clk.o: ../StdPeriphDriver/CH57x_clk.c \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_common.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH572SFR.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\RVMSIS/core_riscv.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_clk.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_cmp.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_keyscan.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_uart.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_gpio.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_i2c.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_flash.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_pwr.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_pwm.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_sys.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_timer.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_spi.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_usbdev.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_usbhost.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/ISP572.h
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_common.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH572SFR.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\RVMSIS/core_riscv.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_clk.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_cmp.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_keyscan.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_uart.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_gpio.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_i2c.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_flash.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_pwr.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_pwm.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_sys.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_timer.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_spi.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_usbdev.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_usbhost.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/ISP572.h:
|
||||
BIN
BLV_RF_W13_V04_20260114/obj/StdPeriphDriver/CH57x_clk.o
Normal file
BIN
BLV_RF_W13_V04_20260114/obj/StdPeriphDriver/CH57x_clk.o
Normal file
Binary file not shown.
37
BLV_RF_W13_V04_20260114/obj/StdPeriphDriver/CH57x_cmp.d
Normal file
37
BLV_RF_W13_V04_20260114/obj/StdPeriphDriver/CH57x_cmp.d
Normal file
@@ -0,0 +1,37 @@
|
||||
StdPeriphDriver/CH57x_cmp.o: ../StdPeriphDriver/CH57x_cmp.c \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_common.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH572SFR.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\RVMSIS/core_riscv.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_clk.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_cmp.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_keyscan.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_uart.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_gpio.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_i2c.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_flash.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_pwr.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_pwm.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_sys.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_timer.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_spi.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_usbdev.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_usbhost.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/ISP572.h
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_common.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH572SFR.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\RVMSIS/core_riscv.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_clk.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_cmp.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_keyscan.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_uart.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_gpio.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_i2c.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_flash.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_pwr.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_pwm.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_sys.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_timer.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_spi.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_usbdev.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_usbhost.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/ISP572.h:
|
||||
BIN
BLV_RF_W13_V04_20260114/obj/StdPeriphDriver/CH57x_cmp.o
Normal file
BIN
BLV_RF_W13_V04_20260114/obj/StdPeriphDriver/CH57x_cmp.o
Normal file
Binary file not shown.
37
BLV_RF_W13_V04_20260114/obj/StdPeriphDriver/CH57x_flash.d
Normal file
37
BLV_RF_W13_V04_20260114/obj/StdPeriphDriver/CH57x_flash.d
Normal file
@@ -0,0 +1,37 @@
|
||||
StdPeriphDriver/CH57x_flash.o: ../StdPeriphDriver/CH57x_flash.c \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_common.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH572SFR.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\RVMSIS/core_riscv.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_clk.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_cmp.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_keyscan.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_uart.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_gpio.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_i2c.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_flash.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_pwr.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_pwm.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_sys.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_timer.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_spi.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_usbdev.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_usbhost.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/ISP572.h
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_common.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH572SFR.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\RVMSIS/core_riscv.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_clk.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_cmp.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_keyscan.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_uart.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_gpio.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_i2c.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_flash.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_pwr.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_pwm.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_sys.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_timer.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_spi.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_usbdev.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_usbhost.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/ISP572.h:
|
||||
BIN
BLV_RF_W13_V04_20260114/obj/StdPeriphDriver/CH57x_flash.o
Normal file
BIN
BLV_RF_W13_V04_20260114/obj/StdPeriphDriver/CH57x_flash.o
Normal file
Binary file not shown.
37
BLV_RF_W13_V04_20260114/obj/StdPeriphDriver/CH57x_gpio.d
Normal file
37
BLV_RF_W13_V04_20260114/obj/StdPeriphDriver/CH57x_gpio.d
Normal file
@@ -0,0 +1,37 @@
|
||||
StdPeriphDriver/CH57x_gpio.o: ../StdPeriphDriver/CH57x_gpio.c \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_common.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH572SFR.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\RVMSIS/core_riscv.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_clk.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_cmp.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_keyscan.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_uart.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_gpio.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_i2c.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_flash.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_pwr.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_pwm.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_sys.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_timer.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_spi.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_usbdev.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_usbhost.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/ISP572.h
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_common.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH572SFR.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\RVMSIS/core_riscv.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_clk.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_cmp.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_keyscan.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_uart.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_gpio.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_i2c.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_flash.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_pwr.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_pwm.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_sys.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_timer.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_spi.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_usbdev.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_usbhost.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/ISP572.h:
|
||||
BIN
BLV_RF_W13_V04_20260114/obj/StdPeriphDriver/CH57x_gpio.o
Normal file
BIN
BLV_RF_W13_V04_20260114/obj/StdPeriphDriver/CH57x_gpio.o
Normal file
Binary file not shown.
37
BLV_RF_W13_V04_20260114/obj/StdPeriphDriver/CH57x_i2c.d
Normal file
37
BLV_RF_W13_V04_20260114/obj/StdPeriphDriver/CH57x_i2c.d
Normal file
@@ -0,0 +1,37 @@
|
||||
StdPeriphDriver/CH57x_i2c.o: ../StdPeriphDriver/CH57x_i2c.c \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_common.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH572SFR.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\RVMSIS/core_riscv.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_clk.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_cmp.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_keyscan.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_uart.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_gpio.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_i2c.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_flash.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_pwr.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_pwm.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_sys.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_timer.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_spi.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_usbdev.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_usbhost.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/ISP572.h
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_common.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH572SFR.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\RVMSIS/core_riscv.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_clk.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_cmp.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_keyscan.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_uart.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_gpio.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_i2c.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_flash.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_pwr.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_pwm.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_sys.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_timer.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_spi.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_usbdev.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_usbhost.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/ISP572.h:
|
||||
BIN
BLV_RF_W13_V04_20260114/obj/StdPeriphDriver/CH57x_i2c.o
Normal file
BIN
BLV_RF_W13_V04_20260114/obj/StdPeriphDriver/CH57x_i2c.o
Normal file
Binary file not shown.
37
BLV_RF_W13_V04_20260114/obj/StdPeriphDriver/CH57x_keyscan.d
Normal file
37
BLV_RF_W13_V04_20260114/obj/StdPeriphDriver/CH57x_keyscan.d
Normal file
@@ -0,0 +1,37 @@
|
||||
StdPeriphDriver/CH57x_keyscan.o: ../StdPeriphDriver/CH57x_keyscan.c \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_common.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH572SFR.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\RVMSIS/core_riscv.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_clk.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_cmp.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_keyscan.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_uart.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_gpio.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_i2c.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_flash.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_pwr.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_pwm.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_sys.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_timer.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_spi.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_usbdev.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_usbhost.h \
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/ISP572.h
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_common.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH572SFR.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\RVMSIS/core_riscv.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_clk.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_cmp.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_keyscan.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_uart.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_gpio.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_i2c.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_flash.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_pwr.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_pwm.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_sys.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_timer.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_spi.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_usbdev.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/CH57x_usbhost.h:
|
||||
G:\WorkSpace_YYW2\CH572D\Project\MCUProject\BLV_RF_W13_V04_20260114\StdPeriphDriver\inc/ISP572.h:
|
||||
BIN
BLV_RF_W13_V04_20260114/obj/StdPeriphDriver/CH57x_keyscan.o
Normal file
BIN
BLV_RF_W13_V04_20260114/obj/StdPeriphDriver/CH57x_keyscan.o
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user