init: DLD110SV4 单线圈蓝牙车检器原始代码 (CH591R, BLE OTA 三段式)
This commit is contained in:
+26
@@ -0,0 +1,26 @@
|
||||
# Build output directories (MRS/Eclipse auto-generated)
|
||||
obj/
|
||||
|
||||
# Prerequisites / object files
|
||||
*.d
|
||||
*.o
|
||||
*.ko
|
||||
*.obj
|
||||
*.elf
|
||||
*.map
|
||||
*.lst
|
||||
*.su
|
||||
|
||||
# Firmware artifacts (rebuildable)
|
||||
*.hex
|
||||
*.bin
|
||||
*.BIN
|
||||
|
||||
# BLE ROM library & prebuilt lib must stay tracked
|
||||
!BLE/LIB/*.hex
|
||||
!BLE/LIB/*.a
|
||||
|
||||
# IDE / misc
|
||||
*.launch.bak
|
||||
*.old
|
||||
*.TMP
|
||||
@@ -0,0 +1,159 @@
|
||||
<?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="" 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.979132887" 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.1248059008" name="Atomic extension (RVA)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.atomic" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.nocommon.164387530" name="No common unitialized (-fno-common)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.nocommon" 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:/OnlyUpdateApp_IAP}/obj" id="ilg.gnumcueclipse.managedbuild.cross.riscv.builder.1421508906" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.builder"/>
|
||||
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.1244756189" name="GNU RISC-V Cross Assembler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler">
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.usepreprocessor.1692176068" name="Use preprocessor" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.usepreprocessor" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="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}/APP/include}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/Profile/include}""/>
|
||||
<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}""/>
|
||||
</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="BLE_BUFF_MAX_LEN=251"/>
|
||||
<listOptionValue builtIn="false" value="CH59xBLE_ROM=1"/>
|
||||
<listOptionValue builtIn="false" value="LIB_FLASH_BASE_ADDRESSS=0x0000C000"/>
|
||||
</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}/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 IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.libs.1065329906" name="Libraries (-l)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.libs" useByScannerDiscovery="false" valueType="libs">
|
||||
<listOptionValue builtIn="false" value="ISP592"/>
|
||||
</option>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.flags.1048167962" 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>
|
||||
<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"/>
|
||||
</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 flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="APP"/>
|
||||
<entry excluding="Profile|KEY.c|LED.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|RESOLVED" kind="sourcePath" name="Profile"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="RVMSIS"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="Startup"/>
|
||||
<entry excluding="CH59x_usbdev.c|CH59x_usbhostClass.c|CH59x_usbhostBase.c|CH59x_pwm.c|CH59x_spi0.c|CH59x_timer1.c|CH59x_timer2.c|CH59x_timer3.c|CH59x_uart2.c|CH59x_uart3.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="StdPeriphDriver"/>
|
||||
</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"/>
|
||||
<storageModule moduleId="refreshScope"/>
|
||||
</cproject>
|
||||
@@ -0,0 +1,59 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<projectDescription>
|
||||
<name>592OnlyUpdateApp_IAP_28K</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>
|
||||
<linkedResources>
|
||||
<link>
|
||||
<name>HAL</name>
|
||||
<type>2</type>
|
||||
<locationURI>PARENT-1-PROJECT_LOC/HAL</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>LIB</name>
|
||||
<type>2</type>
|
||||
<locationURI>PARENT-1-PROJECT_LOC/LIB</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>RVMSIS</name>
|
||||
<type>2</type>
|
||||
<locationURI>PARENT-2-PROJECT_LOC/SRC/RVMSIS</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>StdPeriphDriver</name>
|
||||
<type>2</type>
|
||||
<locationURI>PARENT-2-PROJECT_LOC/SRC/StdPeriphDriver</locationURI>
|
||||
</link>
|
||||
</linkedResources>
|
||||
<filteredResources>
|
||||
<filter>
|
||||
<id>1595986042669</id>
|
||||
<name/>
|
||||
<type>22</type>
|
||||
<matcher>
|
||||
<id>org.eclipse.ui.ide.multiFilter</id>
|
||||
<arguments>1.0-name-matches-false-false-*.wvproj</arguments>
|
||||
</matcher>
|
||||
</filter>
|
||||
</filteredResources>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<project>
|
||||
<configuration id="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.1008047074" name="obj">
|
||||
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
|
||||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="125496981066998040" 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
|
||||
Binary file not shown.
@@ -0,0 +1,110 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : ota.h
|
||||
* Author : WCH
|
||||
* Version : V1.10
|
||||
* Date : 2018/12/14
|
||||
* Description : oad相关配置定义
|
||||
*********************************************************************************
|
||||
* 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 __OTA_H
|
||||
#define __OTA_H
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* OTA FLASH
|
||||
* ------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* 整个用户code区分成四块,依次为4K,44K,16K,128K 后三块分别叫做imageA(APP),imageB(IAP),LIB */
|
||||
|
||||
/* FLASH定义 */
|
||||
|
||||
#define FLASH_BLOCK_SIZE EEPROM_BLOCK_SIZE
|
||||
|
||||
/* imageA定义 */
|
||||
#define IMAGE_A_FLAG 0x01
|
||||
#define IMAGE_A_START_ADD 0x1000
|
||||
#define IMAGE_A_SIZE 44 * 1024
|
||||
|
||||
/* imageB定义 */
|
||||
#define IMAGE_B_FLAG 0x02
|
||||
#define IMAGE_B_START_ADD (IMAGE_A_START_ADD + IMAGE_A_SIZE)
|
||||
#define IMAGE_B_SIZE 16 * 1024
|
||||
|
||||
#define IMAGE_OTA_FLAG 0x03
|
||||
|
||||
#define jumpApp ((void (*)(void))((uint32_t *)IMAGE_A_START_ADD))
|
||||
|
||||
/* IAP定义 */
|
||||
/* 以下为IAP下载命令定义 */
|
||||
#define CMD_IAP_PROM 0x80 // IAP编程命令
|
||||
#define CMD_IAP_ERASE 0x81 // IAP擦除命令
|
||||
#define CMD_IAP_VERIFY 0x82 // IAP校验命令
|
||||
#define CMD_IAP_END 0x83 // IAP结束标志
|
||||
#define CMD_IAP_INFO 0x84 // IAP获取设备信息
|
||||
|
||||
/* 数据帧长度定义 */
|
||||
#define IAP_LEN 247
|
||||
|
||||
/* 存放在DataFlash地址,不能占用蓝牙的位置 */
|
||||
#define OTA_DATAFLASH_ADD 0x00077000 - FLASH_ROM_MAX_SIZE
|
||||
|
||||
/* 存放在DataFlash里的OTA信息 */
|
||||
typedef struct
|
||||
{
|
||||
unsigned char ImageFlag; //记录的当前的image标志
|
||||
unsigned char Revd[3];
|
||||
} OTADataFlashInfo_t;
|
||||
|
||||
/* OTA IAP通讯协议定义 */
|
||||
/* 地址使用4倍偏移 */
|
||||
typedef union
|
||||
{
|
||||
struct
|
||||
{
|
||||
unsigned char cmd; /* 命令码 0x81 */
|
||||
unsigned char len; /* 后续数据长度 */
|
||||
unsigned char addr[2]; /* 擦除地址 */
|
||||
unsigned char block_num[2]; /* 擦除块数 */
|
||||
|
||||
} erase; /* 擦除命令 */
|
||||
struct
|
||||
{
|
||||
unsigned char cmd; /* 命令码 0x83 */
|
||||
unsigned char len; /* 后续数据长度 */
|
||||
unsigned char status[2]; /* 两字节状态,保留 */
|
||||
} end; /* 结束命令 */
|
||||
struct
|
||||
{
|
||||
unsigned char cmd; /* 命令码 0x82 */
|
||||
unsigned char len; /* 后续数据长度 */
|
||||
unsigned char addr[2]; /* 校验地址 */
|
||||
unsigned char buf[IAP_LEN - 4]; /* 校验数据 */
|
||||
} verify; /* 校验命令 */
|
||||
struct
|
||||
{
|
||||
unsigned char cmd; /* 命令码 0x80 */
|
||||
unsigned char len; /* 后续数据长度 */
|
||||
unsigned char addr[2]; /* 地址 */
|
||||
unsigned char buf[IAP_LEN - 4]; /* 后续数据 */
|
||||
} program; /* 编程命令 */
|
||||
struct
|
||||
{
|
||||
unsigned char cmd; /* 命令码 0x84 */
|
||||
unsigned char len; /* 后续数据长度 */
|
||||
unsigned char buf[IAP_LEN - 2]; /* 后续数据 */
|
||||
} info; /* 编程命令 */
|
||||
struct
|
||||
{
|
||||
unsigned char buf[IAP_LEN]; /* 接收数据包*/
|
||||
} other;
|
||||
} OTA_IAP_CMD_t;
|
||||
|
||||
/* 记录当前的Image */
|
||||
extern unsigned char CurrImageFlag;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,58 @@
|
||||
/********************************** (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
|
||||
*/
|
||||
|
||||
// Simple BLE Peripheral Task Events
|
||||
#define SBP_START_DEVICE_EVT 0x0001
|
||||
#define SBP_PERIODIC_EVT 0x0002
|
||||
#define OTA_FLASH_ERASE_EVT 0x0004 //OTA Flash²Á³ýÈÎÎñ
|
||||
|
||||
/*********************************************************************
|
||||
* MACROS
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* FUNCTIONS
|
||||
*/
|
||||
|
||||
/*
|
||||
* Task Initialization for the BLE Application
|
||||
*/
|
||||
extern void Peripheral_Init(void);
|
||||
|
||||
/*
|
||||
* Task Event Processor for the BLE Application
|
||||
*/
|
||||
extern uint16_t Peripheral_ProcessEvent(uint8_t task_id, uint16_t events);
|
||||
|
||||
/*********************************************************************
|
||||
*********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,695 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : Peripheral.C
|
||||
* Author : WCH
|
||||
* Version : V1.0
|
||||
* Date : 2018/12/10
|
||||
* 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.
|
||||
*******************************************************************************/
|
||||
|
||||
/*********************************************************************
|
||||
* INCLUDES
|
||||
*/
|
||||
#include "CONFIG.h"
|
||||
#include "GATTprofile.h"
|
||||
#include "Peripheral.h"
|
||||
#include "OTA.h"
|
||||
#include "OTAprofile.h"
|
||||
|
||||
/*********************************************************************
|
||||
* MACROS
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* CONSTANTS
|
||||
*/
|
||||
|
||||
// How often to perform periodic event
|
||||
#define SBP_PERIODIC_EVT_PERIOD 1000
|
||||
|
||||
// What is the advertising interval when device is discoverable (units of 625us, 32=20ms)
|
||||
#define DEFAULT_ADVERTISING_INTERVAL 32
|
||||
|
||||
// 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) if automatic parameter update request is enabled
|
||||
#define DEFAULT_DESIRED_MIN_CONN_INTERVAL 6
|
||||
|
||||
// Maximum connection interval (units of 1.25ms, 12=15ms) if automatic parameter update request is enabled
|
||||
#define DEFAULT_DESIRED_MAX_CONN_INTERVAL 12
|
||||
|
||||
// Slave latency to use if automatic parameter update request is enabled
|
||||
#define DEFAULT_DESIRED_SLAVE_LATENCY 0
|
||||
|
||||
// Supervision timeout value (units of 10ms, 1000=10s) if automatic parameter update request is enabled
|
||||
#define DEFAULT_DESIRED_CONN_TIMEOUT 1000
|
||||
|
||||
// Whether to enable automatic parameter update request when a connection is formed
|
||||
#define DEFAULT_ENABLE_UPDATE_REQUEST TRUE
|
||||
|
||||
// Connection Pause Peripheral time value (in seconds)
|
||||
#define DEFAULT_CONN_PAUSE_PERIPHERAL 6
|
||||
|
||||
// Company Identifier: WCH
|
||||
#define WCH_COMPANY_ID 0x07D7
|
||||
|
||||
#define INVALID_CONNHANDLE 0xFFFF
|
||||
|
||||
// Length of bd addr as a string
|
||||
#define B_ADDR_STR_LEN 15
|
||||
|
||||
/*********************************************************************
|
||||
* TYPEDEFS
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* GLOBAL VARIABLES
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* EXTERNAL VARIABLES
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* EXTERNAL FUNCTIONS
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* LOCAL VARIABLES
|
||||
*/
|
||||
static uint8_t Peripheral_TaskID = INVALID_TASK_ID; // Task ID for internal task/event processing
|
||||
|
||||
// GAP - SCAN RSP data (max size = 31 bytes)
|
||||
static uint8_t scanRspData[31] = {
|
||||
// complete name
|
||||
0x12, // length of this data
|
||||
GAP_ADTYPE_LOCAL_NAME_COMPLETE,
|
||||
'O', 'T', 'A', 'O', 'T', 'A', '_', 'O', 'T', 'A', 'O', 'T', 'A', '_', 'O', 'T', 'A',
|
||||
// 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 advertisting)
|
||||
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] = "OTAOTA_OTAOTA_OTA";
|
||||
|
||||
// OTA IAP VARIABLES
|
||||
/* OTA通讯的帧 */
|
||||
OTA_IAP_CMD_t iap_rec_data;
|
||||
|
||||
/* OTA解析结果 */
|
||||
uint32_t OpParaDataLen = 0;
|
||||
uint32_t OpAdd = 0;
|
||||
|
||||
/* flash的数据临时存储 */
|
||||
__attribute__((aligned(8))) uint8_t block_buf[16];
|
||||
|
||||
/* Image跳转函数地址定义 */
|
||||
typedef int (*pImageTaskFn)(void);
|
||||
pImageTaskFn user_image_tasks;
|
||||
|
||||
/* Flash 擦除过程 */
|
||||
uint32_t EraseAdd = 0; //擦除地址
|
||||
uint32_t EraseBlockNum = 0; //需要擦除的块数
|
||||
uint32_t EraseBlockCnt = 0; //擦除的块计数
|
||||
|
||||
/* FLASH 校验过程 */
|
||||
uint8_t VerifyStatus = 0;
|
||||
|
||||
/*********************************************************************
|
||||
* 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);
|
||||
|
||||
void OTA_IAPReadDataComplete(unsigned char index);
|
||||
void OTA_IAPWriteData(unsigned char index, unsigned char *p_data, unsigned char w_len);
|
||||
void Rec_OTA_IAP_DataDeal(void);
|
||||
void OTA_IAP_SendCMDDealSta(uint8_t deal_status);
|
||||
|
||||
/*********************************************************************
|
||||
* PROFILE CALLBACKS
|
||||
*/
|
||||
|
||||
// GAP Role Callbacks
|
||||
static gapRolesCBs_t Peripheral_PeripheralCBs = {
|
||||
peripheralStateNotificationCB, // Profile State Change Callbacks
|
||||
NULL, // When a valid RSSI is read from controller (not used by application)
|
||||
NULL};
|
||||
|
||||
// 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)
|
||||
};
|
||||
|
||||
// Simple GATT Profile Callbacks
|
||||
static OTAProfileCBs_t Peripheral_OTA_IAPProfileCBs = {
|
||||
OTA_IAPReadDataComplete, // Charactersitic value change callback
|
||||
OTA_IAPWriteData};
|
||||
|
||||
// Callback when the connection parameteres are updated.
|
||||
void PeripheralParamUpdate(uint16_t connInterval, uint16_t connSlaveLatency, uint16_t connTimeout);
|
||||
|
||||
gapRolesParamUpdateCB_t PeripheralParamUpdate_t = NULL;
|
||||
|
||||
/*********************************************************************
|
||||
* 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
|
||||
{
|
||||
// For other hardware platforms, device starts advertising upon initialization
|
||||
uint8_t initial_advertising_enable = TRUE;
|
||||
|
||||
// Set the GAP Role Parameters
|
||||
GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t), &initial_advertising_enable);
|
||||
GAPRole_SetParameter(GAPROLE_SCAN_RSP_DATA, sizeof(scanRspData), scanRspData);
|
||||
GAPRole_SetParameter(GAPROLE_ADVERT_DATA, sizeof(advertData), advertData);
|
||||
}
|
||||
|
||||
// Set the GAP Characteristics
|
||||
GGS_SetParameter(GGS_DEVICE_NAME_ATT, GAP_DEVICE_NAME_LEN, attDeviceName);
|
||||
|
||||
// Set advertising interval
|
||||
{
|
||||
uint16_t advInt = DEFAULT_ADVERTISING_INTERVAL;
|
||||
|
||||
GAP_SetParamValue(TGAP_DISC_ADV_INT_MIN, advInt);
|
||||
GAP_SetParamValue(TGAP_DISC_ADV_INT_MAX, advInt);
|
||||
}
|
||||
|
||||
// Initialize GATT attributes
|
||||
GGS_AddService(GATT_ALL_SERVICES); // GAP
|
||||
GATTServApp_AddService(GATT_ALL_SERVICES); // GATT attributes
|
||||
OTAProfile_AddService(GATT_ALL_SERVICES);
|
||||
|
||||
// Register callback with OTAGATTprofile
|
||||
OTAProfile_RegisterAppCBs(&Peripheral_OTA_IAPProfileCBs);
|
||||
|
||||
// Setup a delayed profile startup
|
||||
tmos_set_event(Peripheral_TaskID, SBP_START_DEVICE_EVT);
|
||||
}
|
||||
|
||||
void PeripheralParamUpdate(uint16_t connInterval, uint16_t connSlaveLatency, uint16_t connTimeout)
|
||||
{
|
||||
PRINT("update %d %d %d \n", connInterval, connSlaveLatency, connTimeout);
|
||||
|
||||
// GAPRole_SendUpdateParam( DEFAULT_DESIRED_MIN_CONN_INTERVAL, DEFAULT_DESIRED_MAX_CONN_INTERVAL,
|
||||
// DEFAULT_DESIRED_SLAVE_LATENCY, DEFAULT_DESIRED_CONN_TIMEOUT, GAPROLE_NO_ACTION );
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @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);
|
||||
}
|
||||
|
||||
if(events & SBP_START_DEVICE_EVT)
|
||||
{
|
||||
// Start the Device
|
||||
GAPRole_PeripheralStartDevice(Peripheral_TaskID, &Peripheral_BondMgrCBs, &Peripheral_PeripheralCBs);
|
||||
// Set timer for first periodic event
|
||||
tmos_start_task(Peripheral_TaskID, SBP_PERIODIC_EVT, SBP_PERIODIC_EVT_PERIOD);
|
||||
return (events ^ SBP_START_DEVICE_EVT);
|
||||
}
|
||||
|
||||
if(events & SBP_PERIODIC_EVT)
|
||||
{
|
||||
// Restart timer
|
||||
if(SBP_PERIODIC_EVT_PERIOD)
|
||||
{
|
||||
tmos_start_task(Peripheral_TaskID, SBP_PERIODIC_EVT, SBP_PERIODIC_EVT_PERIOD);
|
||||
}
|
||||
// Perform periodic application task
|
||||
performPeriodicTask();
|
||||
return (events ^ SBP_PERIODIC_EVT);
|
||||
}
|
||||
|
||||
//OTA_FLASH_ERASE_EVT
|
||||
if(events & OTA_FLASH_ERASE_EVT)
|
||||
{
|
||||
uint8_t status;
|
||||
|
||||
PRINT("ERASE:%08x num:%d\r\n", (int)(EraseAdd + EraseBlockCnt * FLASH_BLOCK_SIZE), (int)EraseBlockCnt);
|
||||
status = FLASH_ROM_ERASE(EraseAdd + EraseBlockCnt * FLASH_BLOCK_SIZE, FLASH_BLOCK_SIZE);
|
||||
|
||||
/* 擦除失败 */
|
||||
if(status != SUCCESS)
|
||||
{
|
||||
OTA_IAP_SendCMDDealSta(status);
|
||||
return (events ^ OTA_FLASH_ERASE_EVT);
|
||||
}
|
||||
|
||||
EraseBlockCnt++;
|
||||
|
||||
/* 擦除结束 */
|
||||
if(EraseBlockCnt >= EraseBlockNum)
|
||||
{
|
||||
PRINT("ERASE Complete\r\n");
|
||||
OTA_IAP_SendCMDDealSta(status);
|
||||
return (events ^ OTA_FLASH_ERASE_EVT);
|
||||
}
|
||||
|
||||
return (events);
|
||||
}
|
||||
|
||||
// Discard unknown events
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @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)
|
||||
{
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @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)
|
||||
{
|
||||
switch(newState & GAPROLE_STATE_ADV_MASK)
|
||||
{
|
||||
case GAPROLE_STARTED:
|
||||
PRINT("Initialized..\n");
|
||||
break;
|
||||
|
||||
case GAPROLE_ADVERTISING:
|
||||
PRINT("Advertising..\n");
|
||||
break;
|
||||
|
||||
case GAPROLE_CONNECTED:
|
||||
{
|
||||
gapEstLinkReqEvent_t *event = (gapEstLinkReqEvent_t *)pEvent;
|
||||
uint16_t conn_interval = 0;
|
||||
|
||||
conn_interval = event->connInterval;
|
||||
PRINT("Connected.. \n");
|
||||
|
||||
if(conn_interval > DEFAULT_DESIRED_MAX_CONN_INTERVAL)
|
||||
{
|
||||
PRINT("Send Update\r\n");
|
||||
GAPRole_PeripheralConnParamUpdateReq(event->connectionHandle,
|
||||
DEFAULT_DESIRED_MIN_CONN_INTERVAL,
|
||||
DEFAULT_DESIRED_MAX_CONN_INTERVAL,
|
||||
DEFAULT_DESIRED_SLAVE_LATENCY,
|
||||
DEFAULT_DESIRED_CONN_TIMEOUT,
|
||||
Peripheral_TaskID);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GAPROLE_CONNECTED_ADV:
|
||||
PRINT("Connected Advertising..\n");
|
||||
break;
|
||||
case GAPROLE_WAITING:
|
||||
{
|
||||
uint8_t initial_advertising_enable = TRUE;
|
||||
|
||||
// Set the GAP Role Parameters
|
||||
GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t), &initial_advertising_enable);
|
||||
PRINT("Disconnected..\n");
|
||||
}
|
||||
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
|
||||
*/
|
||||
static void performPeriodicTask(void)
|
||||
{
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn OTA_IAP_SendData
|
||||
*
|
||||
* @brief OTA IAP发送数据,使用时限制20字节以内
|
||||
*
|
||||
* @param p_send_data - 发送数据的指针
|
||||
* @param send_len - 发送数据的长度
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void OTA_IAP_SendData(uint8_t *p_send_data, uint8_t send_len)
|
||||
{
|
||||
OTAProfile_SendData(OTAPROFILE_CHAR, p_send_data, send_len);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn OTA_IAP_SendCMDDealSta
|
||||
*
|
||||
* @brief OTA IAP执行的状态返回
|
||||
*
|
||||
* @param deal_status - 返回的状态
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void OTA_IAP_SendCMDDealSta(uint8_t deal_status)
|
||||
{
|
||||
uint8_t send_buf[2];
|
||||
|
||||
send_buf[0] = deal_status;
|
||||
send_buf[1] = 0;
|
||||
OTA_IAP_SendData(send_buf, 2);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn OTA_IAP_CMDErrDeal
|
||||
*
|
||||
* @brief OTA IAP异常命令码处理
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void OTA_IAP_CMDErrDeal(void)
|
||||
{
|
||||
OTA_IAP_SendCMDDealSta(0xfe);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SwitchImageFlag
|
||||
*
|
||||
* @brief 切换dataflash里的ImageFlag
|
||||
*
|
||||
* @param new_flag - 切换的ImageFlag
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void SwitchImageFlag(uint8_t new_flag)
|
||||
{
|
||||
uint16_t i;
|
||||
uint32_t ver_flag;
|
||||
|
||||
/* 读取第一块 */
|
||||
EEPROM_READ(OTA_DATAFLASH_ADD, (uint32_t *)&block_buf[0], 4);
|
||||
|
||||
/* 擦除第一块 */
|
||||
EEPROM_ERASE(OTA_DATAFLASH_ADD, EEPROM_PAGE_SIZE);
|
||||
|
||||
/* 更新Image信息 */
|
||||
block_buf[0] = new_flag;
|
||||
|
||||
/* 编程DataFlash */
|
||||
EEPROM_WRITE(OTA_DATAFLASH_ADD, (uint32_t *)&block_buf[0], 4);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn DisableAllIRQ
|
||||
*
|
||||
* @brief 关闭所有的中断
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void DisableAllIRQ(void)
|
||||
{
|
||||
SYS_DisableAllIrq(NULL);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn Rec_OTA_IAP_DataDeal
|
||||
*
|
||||
* @brief 接收到OTA数据包处理
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void Rec_OTA_IAP_DataDeal(void)
|
||||
{
|
||||
switch(iap_rec_data.other.buf[0])
|
||||
{
|
||||
/* 编程 */
|
||||
case CMD_IAP_PROM:
|
||||
{
|
||||
uint32_t i;
|
||||
uint8_t status;
|
||||
|
||||
OpParaDataLen = iap_rec_data.program.len;
|
||||
OpAdd = (uint32_t)(iap_rec_data.program.addr[0]);
|
||||
OpAdd |= ((uint32_t)(iap_rec_data.program.addr[1]) << 8);
|
||||
OpAdd = OpAdd * 16;
|
||||
|
||||
PRINT("IAP_PROM: %08x len:%d \r\n", (int)OpAdd, (int)OpParaDataLen);
|
||||
|
||||
/* 当前是ImageA,直接编程 */
|
||||
status = FLASH_ROM_WRITE(OpAdd, iap_rec_data.program.buf, (uint16_t)OpParaDataLen);
|
||||
OTA_IAP_SendCMDDealSta(status);
|
||||
break;
|
||||
}
|
||||
/* 擦除 -- 蓝牙擦除由主机控制 */
|
||||
case CMD_IAP_ERASE:
|
||||
{
|
||||
OpAdd = (uint32_t)(iap_rec_data.erase.addr[0]);
|
||||
OpAdd |= ((uint32_t)(iap_rec_data.erase.addr[1]) << 8);
|
||||
OpAdd = OpAdd * 16;
|
||||
|
||||
EraseBlockNum = (uint32_t)(iap_rec_data.erase.block_num[0]);
|
||||
EraseBlockNum |= ((uint32_t)(iap_rec_data.erase.block_num[1]) << 8);
|
||||
EraseAdd = OpAdd;
|
||||
EraseBlockCnt = 0;
|
||||
|
||||
/* 检验就放在擦除里清0 */
|
||||
VerifyStatus = 0;
|
||||
|
||||
PRINT("IAP_ERASE start:%08x num:%d\r\n", (int)OpAdd, (int)EraseBlockNum);
|
||||
|
||||
if(EraseAdd < IMAGE_A_START_ADD || (EraseAdd + (EraseBlockNum - 1) * FLASH_BLOCK_SIZE) > IMAGE_B_START_ADD)
|
||||
{
|
||||
OTA_IAP_SendCMDDealSta(0xFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* 修改DataFlash,切换至ImageB */
|
||||
SwitchImageFlag(IMAGE_B_FLAG);
|
||||
|
||||
/* 启动擦除 */
|
||||
tmos_set_event(Peripheral_TaskID, OTA_FLASH_ERASE_EVT);
|
||||
}
|
||||
break;
|
||||
}
|
||||
/* 校验 */
|
||||
case CMD_IAP_VERIFY:
|
||||
{
|
||||
uint32_t i;
|
||||
uint8_t status = 0;
|
||||
|
||||
OpParaDataLen = iap_rec_data.verify.len;
|
||||
|
||||
OpAdd = (uint32_t)(iap_rec_data.verify.addr[0]);
|
||||
OpAdd |= ((uint32_t)(iap_rec_data.verify.addr[1]) << 8);
|
||||
OpAdd = OpAdd * 16;
|
||||
|
||||
PRINT("IAP_VERIFY: %08x len:%d \r\n", (int)OpAdd, (int)OpParaDataLen);
|
||||
|
||||
status = FLASH_ROM_VERIFY(OpAdd, iap_rec_data.verify.buf, OpParaDataLen);
|
||||
VerifyStatus |= status;
|
||||
OTA_IAP_SendCMDDealSta(VerifyStatus);
|
||||
break;
|
||||
}
|
||||
/* 编程结束 */
|
||||
case CMD_IAP_END:
|
||||
{
|
||||
PRINT("IAP_END \r\n");
|
||||
|
||||
/* 关闭当前所有使用中断,或者方便一点直接全部关闭 */
|
||||
DisableAllIRQ();
|
||||
|
||||
/* 修改DataFlash,切换至ImageA */
|
||||
SwitchImageFlag(IMAGE_A_FLAG);
|
||||
|
||||
/* 等待打印完成 ,跳转ImageB*/
|
||||
mDelaymS(10);
|
||||
jumpApp();
|
||||
|
||||
/* 不会执行到这 */
|
||||
SYS_ResetExecute();
|
||||
|
||||
break;
|
||||
}
|
||||
case CMD_IAP_INFO:
|
||||
{
|
||||
uint8_t send_buf[20];
|
||||
|
||||
PRINT("IAP_INFO \r\n");
|
||||
|
||||
/* IMAGE FLAG */
|
||||
send_buf[0] = IMAGE_B_FLAG;
|
||||
|
||||
/* IMAGE_B_START_ADD */
|
||||
send_buf[1] = (uint8_t)(IMAGE_B_START_ADD & 0xff);
|
||||
send_buf[2] = (uint8_t)((IMAGE_B_START_ADD >> 8) & 0xff);
|
||||
send_buf[3] = (uint8_t)((IMAGE_B_START_ADD >> 16) & 0xff);
|
||||
send_buf[4] = (uint8_t)((IMAGE_B_START_ADD >> 24) & 0xff);
|
||||
|
||||
/* BLOCK SIZE */
|
||||
send_buf[5] = (uint8_t)(FLASH_BLOCK_SIZE & 0xff);
|
||||
send_buf[6] = (uint8_t)((FLASH_BLOCK_SIZE >> 8) & 0xff);
|
||||
|
||||
send_buf[7] = CHIP_ID&0xFF;
|
||||
send_buf[8] = (CHIP_ID>>8)&0xFF;
|
||||
/* 有需要再增加 */
|
||||
|
||||
/* 发送信息 */
|
||||
OTA_IAP_SendData(send_buf, 20);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
OTA_IAP_CMDErrDeal();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn OTA_IAPReadDataComplete
|
||||
*
|
||||
* @brief OTA 数据读取完成处理
|
||||
*
|
||||
* @param index - OTA 通道序号
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void OTA_IAPReadDataComplete(unsigned char index)
|
||||
{
|
||||
PRINT("OTA Send Comp \r\n");
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn OTA_IAPWriteData
|
||||
*
|
||||
* @brief OTA 通道数据接收完成处理
|
||||
*
|
||||
* @param index - OTA 通道序号
|
||||
* @param p_data - 写入的数据
|
||||
* @param w_len - 写入的长度
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void OTA_IAPWriteData(unsigned char index, unsigned char *p_data, unsigned char w_len)
|
||||
{
|
||||
unsigned char rec_len;
|
||||
unsigned char *rec_data;
|
||||
|
||||
rec_len = w_len;
|
||||
rec_data = p_data;
|
||||
tmos_memcpy((unsigned char *)&iap_rec_data, rec_data, rec_len);
|
||||
Rec_OTA_IAP_DataDeal();
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*********************************************************************/
|
||||
@@ -0,0 +1,132 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : main.c
|
||||
* Author : WCH
|
||||
* Version : V1.1
|
||||
* Date : 2019/11/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.
|
||||
*******************************************************************************/
|
||||
|
||||
/******************************************************************************/
|
||||
/* 头文件包含 */
|
||||
#include "CONFIG.h"
|
||||
#include "HAL.h"
|
||||
#include "Peripheral.h"
|
||||
#include "OTA.h"
|
||||
#include "OTAprofile.h"
|
||||
|
||||
/* 记录当前的Image */
|
||||
unsigned char CurrImageFlag = 0xff;
|
||||
|
||||
/*********************************************************************
|
||||
* 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
|
||||
|
||||
/* 注意:关于程序升级后flash的操作必须先执行,不开启任何中断,防止操作中断和失败 */
|
||||
/*********************************************************************
|
||||
* @fn ReadImageFlag
|
||||
*
|
||||
* @brief 读取当前的程序的Image标志,DataFlash如果为空,就默认是ImageA,如果为ImageA,则跳转ImageA
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void ReadImageFlag(void)
|
||||
{
|
||||
OTADataFlashInfo_t p_image_flash;
|
||||
|
||||
EEPROM_READ(OTA_DATAFLASH_ADD, &p_image_flash, 4);
|
||||
CurrImageFlag = p_image_flash.ImageFlag;
|
||||
|
||||
/* 程序第一次执行,或者没有更新过,以后更新后在擦除DataFlash */
|
||||
if((CurrImageFlag != IMAGE_B_FLAG) && (CurrImageFlag != IMAGE_A_FLAG) && (CurrImageFlag != IMAGE_OTA_FLAG))
|
||||
{
|
||||
CurrImageFlag = IMAGE_A_FLAG;
|
||||
}
|
||||
|
||||
PRINT("Image Flag %02x\n", CurrImageFlag);
|
||||
|
||||
if(CurrImageFlag == IMAGE_A_FLAG)
|
||||
{
|
||||
PRINT("jump App \n");
|
||||
mDelaymS(5);
|
||||
jumpApp();
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn Main_Circulation
|
||||
*
|
||||
* @brief 主循环
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
__HIGH_CODE
|
||||
__attribute__((noinline))
|
||||
void Main_Circulation()
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
TMOS_SystemProcess();
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn main
|
||||
*
|
||||
* @brief 主函数
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
#if(defined(DCDC_ENABLE)) && (DCDC_ENABLE == TRUE)
|
||||
PWR_DCDCCfg(ENABLE);
|
||||
#endif
|
||||
SetSysClock(CLK_SOURCE_PLL_60MHz);
|
||||
#if(defined(HAL_SLEEP)) && (HAL_SLEEP == TRUE)
|
||||
GPIOA_ModeCfg(GPIO_Pin_All, GPIO_ModeIN_PU);
|
||||
GPIOB_ModeCfg(GPIO_Pin_All, GPIO_ModeIN_PU);
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
// GPIOA_SetBits(bTXD1);
|
||||
// GPIOA_ModeCfg(bTXD1, GPIO_ModeOut_PP_5mA);
|
||||
// UART1_DefInit();
|
||||
#endif
|
||||
/* 配置串口0:先配置IO口模式,再配置串口 */
|
||||
GPIOPinRemap(ENABLE, RB_PIN_UART0);
|
||||
GPIOA_SetBits(GPIO_Pin_14);
|
||||
GPIOA_ModeCfg(GPIO_Pin_15, GPIO_ModeIN_PU); // RXD-配置上拉输入
|
||||
GPIOA_ModeCfg(GPIO_Pin_14, GPIO_ModeOut_PP_5mA); // TXD-配置推挽输出,注意先让IO口输出高电平
|
||||
UART0_DefInit();
|
||||
|
||||
PRINT("%s\n", VER_LIB);
|
||||
ReadImageFlag();
|
||||
if((R8_RESET_STATUS & RB_RESET_FLAG) == RST_FLAG_SW)
|
||||
{
|
||||
// 软复位不跳APP
|
||||
}
|
||||
else
|
||||
{
|
||||
if(CurrImageFlag == IMAGE_OTA_FLAG)
|
||||
{
|
||||
PRINT("jump App \n");
|
||||
mDelaymS(5);
|
||||
jumpApp();
|
||||
}
|
||||
}
|
||||
CH59x_BLEInit();
|
||||
HAL_Init();
|
||||
GAPRole_PeripheralInit();
|
||||
Peripheral_Init();
|
||||
Main_Circulation();
|
||||
}
|
||||
|
||||
/******************************** endfile @ main ******************************/
|
||||
@@ -0,0 +1,185 @@
|
||||
ENTRY( _start )
|
||||
|
||||
__stack_size = 512;
|
||||
|
||||
PROVIDE( _stack_size = __stack_size );
|
||||
|
||||
MEMORY
|
||||
{
|
||||
FLASH (rx) : ORIGIN = 0x00008000, LENGTH = 16K
|
||||
RAM (xrw) : ORIGIN = 0x20002000, LENGTH = 18K
|
||||
}
|
||||
|
||||
PROVIDE( __global_pointer$ = 0x20002000 );
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.init :
|
||||
{
|
||||
_sinit = .;
|
||||
. = ALIGN(4);
|
||||
KEEP(*(SORT_NONE(.init)))
|
||||
. = ALIGN(4);
|
||||
_einit = .;
|
||||
} >FLASH AT>FLASH
|
||||
|
||||
/* .vector :
|
||||
{
|
||||
*(.vector);
|
||||
} >FLASH AT>FLASH */
|
||||
|
||||
.highcodelalign :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
PROVIDE(_highcode_lma = .);
|
||||
} >FLASH AT>FLASH
|
||||
|
||||
.highcode :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
PROVIDE(_highcode_vma_start = .);
|
||||
*(.vector);
|
||||
KEEP(*(SORT_NONE(.vector_handler)))
|
||||
*(.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
|
||||
|
||||
.dalign :
|
||||
{
|
||||
. = ORIGIN(RAM) + SIZEOF(.highcode);
|
||||
} >RAM 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);
|
||||
*(.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) - __stack_size :
|
||||
{
|
||||
PROVIDE( _heap_end = . );
|
||||
. = ALIGN(4);
|
||||
PROVIDE(_susrstack = . );
|
||||
. = . + __stack_size;
|
||||
PROVIDE( _eusrstack = .);
|
||||
} >RAM
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,334 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : OTAprofile.C
|
||||
* Author : WCH
|
||||
* Version : V1.0
|
||||
* Date : 2018/12/10
|
||||
* Description : OTA升级蓝牙通讯接口
|
||||
*********************************************************************************
|
||||
* 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 "OTAprofile.h"
|
||||
#include "CH592SFR.h"
|
||||
#include "ota.h"
|
||||
|
||||
/*********************************************************************
|
||||
* MACROS
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* CONSTANTS
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* TYPEDEFS
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* GLOBAL VARIABLES
|
||||
*/
|
||||
// Simple GATT Profile Service UUID: 0xFFF0
|
||||
const uint8_t OTAProfileServUUID[ATT_BT_UUID_SIZE] = {
|
||||
LO_UINT16(OTAPROFILE_SERV_UUID), HI_UINT16(OTAPROFILE_SERV_UUID)};
|
||||
|
||||
// Characteristic 1 UUID: 0xFFF1
|
||||
const uint8_t OTAProfilechar1UUID[ATT_BT_UUID_SIZE] = {
|
||||
LO_UINT16(OTAPROFILE_CHAR_UUID), HI_UINT16(OTAPROFILE_CHAR_UUID)};
|
||||
|
||||
/*********************************************************************
|
||||
* EXTERNAL VARIABLES
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* EXTERNAL FUNCTIONS
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* LOCAL VARIABLES
|
||||
*/
|
||||
|
||||
static OTAProfileCBs_t *OTAProfile_AppCBs = NULL;
|
||||
|
||||
/*********************************************************************
|
||||
* Profile Attributes - variables
|
||||
*/
|
||||
|
||||
// Simple Profile Service attribute
|
||||
static const gattAttrType_t OTAProfileService = {ATT_BT_UUID_SIZE, OTAProfileServUUID};
|
||||
|
||||
// Simple Profile Characteristic 1 Properties
|
||||
static uint8_t OTAProfileCharProps = GATT_PROP_READ | GATT_PROP_WRITE | GATT_PROP_WRITE_NO_RSP;
|
||||
|
||||
// Characteristic 1 Value
|
||||
static uint8_t OTAProfileChar = 0;
|
||||
|
||||
// Simple Profile Characteristic 1 User Description
|
||||
static uint8_t OTAProfileCharUserDesp[12] = "OTA Channel";
|
||||
|
||||
// write and read buffer
|
||||
static uint8_t OTAProfileReadLen;
|
||||
static uint8_t OTAProfileReadBuf[IAP_LEN];
|
||||
static uint8_t OTAProfileWriteLen;
|
||||
static uint8_t OTAProfileWriteBuf[IAP_LEN];
|
||||
|
||||
/*********************************************************************
|
||||
* Profile Attributes - Table
|
||||
*/
|
||||
|
||||
static gattAttribute_t OTAProfileAttrTbl[4] = {
|
||||
// Simple Profile Service
|
||||
{
|
||||
{ATT_BT_UUID_SIZE, primaryServiceUUID}, /* type */
|
||||
GATT_PERMIT_READ, /* permissions */
|
||||
0, /* handle */
|
||||
(uint8_t *)&OTAProfileService /* pValue */
|
||||
},
|
||||
|
||||
// Characteristic Declaration
|
||||
{
|
||||
{ATT_BT_UUID_SIZE, characterUUID},
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
&OTAProfileCharProps},
|
||||
|
||||
// Characteristic Value
|
||||
{
|
||||
{ATT_BT_UUID_SIZE, OTAProfilechar1UUID},
|
||||
GATT_PERMIT_READ | GATT_PERMIT_WRITE,
|
||||
0,
|
||||
&OTAProfileChar},
|
||||
|
||||
// Characteristic User Description
|
||||
{
|
||||
{ATT_BT_UUID_SIZE, charUserDescUUID},
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
OTAProfileCharUserDesp},
|
||||
};
|
||||
|
||||
/*********************************************************************
|
||||
* LOCAL FUNCTIONS
|
||||
*/
|
||||
static bStatus_t OTAProfile_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 OTAProfile_WriteAttrCB(uint16_t connHandle, gattAttribute_t *pAttr,
|
||||
uint8_t *pValue, uint16_t len, uint16_t offset, uint8_t method);
|
||||
|
||||
/*********************************************************************
|
||||
* PROFILE CALLBACKS
|
||||
*/
|
||||
// OTA Profile Service Callbacks
|
||||
gattServiceCBs_t OTAProfileCBs = {
|
||||
OTAProfile_ReadAttrCB, // Read callback function pointer
|
||||
OTAProfile_WriteAttrCB, // Write callback function pointer
|
||||
NULL // Authorization callback function pointer
|
||||
};
|
||||
|
||||
/*********************************************************************
|
||||
* PUBLIC FUNCTIONS
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* @fn OTAProfile_AddService
|
||||
*
|
||||
* @brief OTA Profile初始化
|
||||
*
|
||||
* @param services - 服务控制字
|
||||
*
|
||||
* @return 初始化的状态
|
||||
*/
|
||||
bStatus_t OTAProfile_AddService(uint32_t services)
|
||||
{
|
||||
uint8_t status = SUCCESS;
|
||||
|
||||
if(services & OTAPROFILE_SERVICE)
|
||||
{
|
||||
// Register GATT attribute list and CBs with GATT Server App
|
||||
status = GATTServApp_RegisterService(OTAProfileAttrTbl,
|
||||
GATT_NUM_ATTRS(OTAProfileAttrTbl),
|
||||
GATT_MAX_ENCRYPT_KEY_SIZE,
|
||||
&OTAProfileCBs);
|
||||
}
|
||||
|
||||
return (status);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn OTAProfile_RegisterAppCBs
|
||||
*
|
||||
* @brief OTA Profile读写回调函数注册
|
||||
*
|
||||
* @param appCallbacks - 函数结构体指针
|
||||
*
|
||||
* @return 函数执行状态
|
||||
*/
|
||||
bStatus_t OTAProfile_RegisterAppCBs(OTAProfileCBs_t *appCallbacks)
|
||||
{
|
||||
if(appCallbacks)
|
||||
{
|
||||
OTAProfile_AppCBs = appCallbacks;
|
||||
|
||||
return (SUCCESS);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (bleAlreadyInRequestedMode);
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn OTAProfile_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 OTAProfile_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;
|
||||
|
||||
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 OTAPROFILE_CHAR_UUID:
|
||||
{
|
||||
*pLen = 0;
|
||||
if(OTAProfileReadLen)
|
||||
{
|
||||
*pLen = OTAProfileReadLen;
|
||||
tmos_memcpy(pValue, OTAProfileReadBuf, OTAProfileReadLen);
|
||||
OTAProfileReadLen = 0;
|
||||
if(OTAProfile_AppCBs && OTAProfile_AppCBs->pfnOTAProfileRead)
|
||||
{
|
||||
OTAProfile_AppCBs->pfnOTAProfileRead(OTAPROFILE_CHAR);
|
||||
}
|
||||
}
|
||||
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 OTAProfile_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 OTAProfile_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(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 OTAPROFILE_CHAR_UUID:
|
||||
{
|
||||
//Write the value
|
||||
if(status == SUCCESS)
|
||||
{
|
||||
uint16_t i;
|
||||
uint8_t *p_rec_buf;
|
||||
|
||||
OTAProfileWriteLen = len;
|
||||
p_rec_buf = pValue;
|
||||
for(i = 0; i < OTAProfileWriteLen; i++)
|
||||
OTAProfileWriteBuf[i] = p_rec_buf[i];
|
||||
}
|
||||
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(OTAProfileWriteLen && OTAProfile_AppCBs && OTAProfile_AppCBs->pfnOTAProfileWrite)
|
||||
{
|
||||
OTAProfile_AppCBs->pfnOTAProfileWrite(OTAPROFILE_CHAR, OTAProfileWriteBuf, OTAProfileWriteLen);
|
||||
OTAProfileWriteLen = 0;
|
||||
}
|
||||
|
||||
return (status);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn OTAProfile_SendData
|
||||
*
|
||||
* @brief OTA Profile通道发送数据
|
||||
*
|
||||
* @param paramID - OTA通道选择
|
||||
* @param p_data - 数据指针
|
||||
* @param send_len - 发送数据长度
|
||||
*
|
||||
* @return 函数执行状态
|
||||
*/
|
||||
bStatus_t OTAProfile_SendData(unsigned char paramID, unsigned char *p_data, unsigned char send_len)
|
||||
{
|
||||
bStatus_t status = SUCCESS;
|
||||
|
||||
/* 数据长度超出范围 */
|
||||
if(send_len > 20)
|
||||
return 0xfe;
|
||||
|
||||
OTAProfileReadLen = send_len;
|
||||
tmos_memcpy(OTAProfileReadBuf, p_data, OTAProfileReadLen);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*********************************************************************/
|
||||
@@ -0,0 +1,102 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : OTAprofile.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 OTAPROFILE_H
|
||||
#define OTAPROFILE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
* INCLUDES
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* CONSTANTS
|
||||
*/
|
||||
|
||||
// OTA Profile通道Index定义
|
||||
#define OTAPROFILE_CHAR 0
|
||||
|
||||
// OTA 服务的UUID定义
|
||||
#define OTAPROFILE_SERV_UUID 0xFEE0
|
||||
|
||||
// OTA 通讯通道UUID定义
|
||||
#define OTAPROFILE_CHAR_UUID 0xFEE1
|
||||
|
||||
// Simple Keys Profile Services bit fields
|
||||
#define OTAPROFILE_SERVICE 0x00000001
|
||||
|
||||
/*********************************************************************
|
||||
* TYPEDEFS
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* MACROS
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* Profile Callbacks
|
||||
*/
|
||||
|
||||
// 读写操作函数回调
|
||||
typedef void (*OTAProfileRead_t)(unsigned char paramID);
|
||||
typedef void (*OTAProfileWrite_t)(unsigned char paramID, unsigned char *p_data, unsigned char w_len);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
OTAProfileRead_t pfnOTAProfileRead;
|
||||
OTAProfileWrite_t pfnOTAProfileWrite;
|
||||
} OTAProfileCBs_t;
|
||||
|
||||
/*********************************************************************
|
||||
* API FUNCTIONS
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief OTA Profile初始化
|
||||
*
|
||||
* @param services - 服务控制字
|
||||
*
|
||||
* @return 初始化的状态
|
||||
*/
|
||||
bStatus_t OTAProfile_AddService(uint32_t services);
|
||||
|
||||
/**
|
||||
* @brief OTA Profile读写回调函数注册
|
||||
*
|
||||
* @param appCallbacks - 函数结构体指针
|
||||
*
|
||||
* @return 函数执行状态
|
||||
*/
|
||||
bStatus_t OTAProfile_RegisterAppCBs(OTAProfileCBs_t *appCallbacks);
|
||||
|
||||
/**
|
||||
* @brief OTA Profile通道发送数据
|
||||
*
|
||||
* @param paramID - OTA通道选择
|
||||
* @param p_data - 数据指针
|
||||
* @param send_len - 发送数据长度
|
||||
*
|
||||
* @return 函数执行状态
|
||||
*/
|
||||
bStatus_t OTAProfile_SendData(unsigned char paramID, unsigned char *p_data, unsigned char send_len);
|
||||
|
||||
/*********************************************************************
|
||||
*********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,123 @@
|
||||
/********************************** (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
|
||||
#define SIMPLEPROFILE_CHAR2_UUID 0xFFE2
|
||||
#define SIMPLEPROFILE_CHAR3_UUID 0xFFE3
|
||||
#define SIMPLEPROFILE_CHAR4_UUID 0xFFE4
|
||||
#define SIMPLEPROFILE_CHAR5_UUID 0xFFE5
|
||||
|
||||
// Simple Keys Profile Services bit fields
|
||||
#define SIMPLEPROFILE_SERVICE 0x00000001
|
||||
|
||||
// Length of Characteristic 5 in bytes
|
||||
#define SIMPLEPROFILE_CHAR4_LEN 8
|
||||
#define SIMPLEPROFILE_CHAR5_LEN 5
|
||||
|
||||
/*********************************************************************
|
||||
* TYPEDEFS
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* MACROS
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* Profile Callbacks
|
||||
*/
|
||||
|
||||
// Callback when a characteristic value has changed
|
||||
typedef void (*simpleProfileChange_t)(uint8_t paramID);
|
||||
|
||||
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);
|
||||
|
||||
/*********************************************************************
|
||||
*********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,187 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : startup_CH59x.s
|
||||
* Author : WCH
|
||||
* Version : V1.0.0
|
||||
* Date : 2021/02/25
|
||||
* 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
|
||||
.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 0xF5F9BDA9
|
||||
.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 SW_Handler /* SW Handler */
|
||||
.word 0
|
||||
/* External Interrupts */
|
||||
.word TMR0_IRQHandler /* 0: TMR0 */
|
||||
.word GPIOA_IRQHandler /* GPIOA */
|
||||
.word GPIOB_IRQHandler /* GPIOB */
|
||||
.word SPI0_IRQHandler /* SPI0 */
|
||||
.word BB_IRQHandler /* BLEB */
|
||||
.word LLE_IRQHandler /* BLEL */
|
||||
.word USB_IRQHandler /* USB */
|
||||
.word 0
|
||||
.word TMR1_IRQHandler /* TMR1 */
|
||||
.word TMR2_IRQHandler /* TMR2 */
|
||||
.word UART0_IRQHandler /* UART0 */
|
||||
.word UART1_IRQHandler /* UART1 */
|
||||
.word RTC_IRQHandler /* RTC */
|
||||
.word ADC_IRQHandler /* ADC */
|
||||
.word I2C_IRQHandler /* I2C */
|
||||
.word PWMX_IRQHandler /* PWMX */
|
||||
.word TMR3_IRQHandler /* TMR3 */
|
||||
.word UART2_IRQHandler /* UART2 */
|
||||
.word UART3_IRQHandler /* UART3 */
|
||||
.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 SW_Handler
|
||||
.weak TMR0_IRQHandler
|
||||
.weak GPIOA_IRQHandler
|
||||
.weak GPIOB_IRQHandler
|
||||
.weak SPI0_IRQHandler
|
||||
.weak BB_IRQHandler
|
||||
.weak LLE_IRQHandler
|
||||
.weak USB_IRQHandler
|
||||
.weak TMR1_IRQHandler
|
||||
.weak TMR2_IRQHandler
|
||||
.weak UART0_IRQHandler
|
||||
.weak UART1_IRQHandler
|
||||
.weak RTC_IRQHandler
|
||||
.weak ADC_IRQHandler
|
||||
.weak I2C_IRQHandler
|
||||
.weak PWMX_IRQHandler
|
||||
.weak TMR3_IRQHandler
|
||||
.weak UART2_IRQHandler
|
||||
.weak UART3_IRQHandler
|
||||
.weak WDOG_BAT_IRQHandler
|
||||
|
||||
NMI_Handler:
|
||||
HardFault_Handler:
|
||||
Ecall_M_Mode_Handler:
|
||||
Ecall_U_Mode_Handler:
|
||||
Break_Point_Handler:
|
||||
SysTick_Handler:
|
||||
SW_Handler:
|
||||
TMR0_IRQHandler:
|
||||
GPIOA_IRQHandler:
|
||||
GPIOB_IRQHandler:
|
||||
SPI0_IRQHandler:
|
||||
BB_IRQHandler:
|
||||
LLE_IRQHandler:
|
||||
USB_IRQHandler:
|
||||
TMR1_IRQHandler:
|
||||
TMR2_IRQHandler:
|
||||
UART0_IRQHandler:
|
||||
UART1_IRQHandler:
|
||||
RTC_IRQHandler:
|
||||
ADC_IRQHandler:
|
||||
I2C_IRQHandler:
|
||||
PWMX_IRQHandler:
|
||||
TMR3_IRQHandler:
|
||||
UART2_IRQHandler:
|
||||
UART3_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$
|
||||
.option pop
|
||||
1:
|
||||
la sp, _eusrstack
|
||||
|
||||
/* 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:
|
||||
/* 流水线控制位 & 动态预测控制位 */
|
||||
li t0, 0x1f
|
||||
csrw 0xbc0, t0
|
||||
/* 打开嵌套中断、硬件压栈功能 */
|
||||
li t0, 0x3
|
||||
csrw 0x804, t0
|
||||
|
||||
li t0, 0x1888
|
||||
csrw mstatus, t0
|
||||
la t0, _vector_base
|
||||
|
||||
/* 配置向量表模式为绝对地址模式 */
|
||||
ori t0, t0, 3
|
||||
csrw mtvec, t0
|
||||
|
||||
la t0, main
|
||||
csrw mepc, t0
|
||||
|
||||
j 0xC000
|
||||
|
||||
mret
|
||||
@@ -0,0 +1,158 @@
|
||||
<?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="" 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.979132887" 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.1248059008" name="Atomic extension (RVA)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.atomic" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.nocommon.921229102" name="No common unitialized (-fno-common)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.nocommon" 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:/OnlyUpdateApp_JumpIAP}/obj" id="ilg.gnumcueclipse.managedbuild.cross.riscv.builder.1421508906" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.builder"/>
|
||||
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.1244756189" name="GNU RISC-V Cross Assembler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler">
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.usepreprocessor.1692176068" name="Use preprocessor" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.usepreprocessor" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="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}/APP/include}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/Profile/include}""/>
|
||||
<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}""/>
|
||||
</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=1"/>
|
||||
<listOptionValue builtIn="false" value="CH59xBLE_ROM=1"/>
|
||||
</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}/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 IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.libs.1065329906" name="Libraries (-l)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.libs" useByScannerDiscovery="false" valueType="libs">
|
||||
<listOptionValue builtIn="false" value="ISP592"/>
|
||||
</option>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.flags.1048167962" 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>
|
||||
<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"/>
|
||||
</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 flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="APP"/>
|
||||
<entry excluding="Profile|KEY.c|LED.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|RESOLVED" kind="sourcePath" name="Profile"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="RVMSIS"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="Startup"/>
|
||||
<entry excluding="CH59x_usbdev.c|CH59x_usbhostClass.c|CH59x_usbhostBase.c|CH59x_pwm.c|CH59x_spi0.c|CH59x_timer1.c|CH59x_timer2.c|CH59x_timer3.c|CH59x_uart0.c|CH59x_uart2.c|CH59x_uart3.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="StdPeriphDriver"/>
|
||||
</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>
|
||||
@@ -0,0 +1,59 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<projectDescription>
|
||||
<name>592OnlyUpdateApp_JumpIAP_28K</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>
|
||||
<linkedResources>
|
||||
<link>
|
||||
<name>HAL</name>
|
||||
<type>2</type>
|
||||
<locationURI>PARENT-1-PROJECT_LOC/HAL</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>LIB</name>
|
||||
<type>2</type>
|
||||
<locationURI>PARENT-1-PROJECT_LOC/LIB</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>RVMSIS</name>
|
||||
<type>2</type>
|
||||
<locationURI>PARENT-2-PROJECT_LOC/SRC/RVMSIS</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>StdPeriphDriver</name>
|
||||
<type>2</type>
|
||||
<locationURI>PARENT-2-PROJECT_LOC/SRC/StdPeriphDriver</locationURI>
|
||||
</link>
|
||||
</linkedResources>
|
||||
<filteredResources>
|
||||
<filter>
|
||||
<id>1595986042669</id>
|
||||
<name/>
|
||||
<type>22</type>
|
||||
<matcher>
|
||||
<id>org.eclipse.ui.ide.multiFilter</id>
|
||||
<arguments>1.0-name-matches-false-false-*.wvproj</arguments>
|
||||
</matcher>
|
||||
</filter>
|
||||
</filteredResources>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<project>
|
||||
<configuration id="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.1008047074" name="obj">
|
||||
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
|
||||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="108603333841037728" 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
|
||||
Binary file not shown.
@@ -0,0 +1,66 @@
|
||||
/********************************** (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
|
||||
|
||||
/*********************************************************************
|
||||
* MACROS
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t connHandle; // Connection handle of current connection
|
||||
uint16_t connInterval;
|
||||
uint16_t connSlaveLatency;
|
||||
uint16_t connTimeout;
|
||||
} peripheralConnItem_t;
|
||||
|
||||
/*********************************************************************
|
||||
* FUNCTIONS
|
||||
*/
|
||||
|
||||
/*
|
||||
* Task Initialization for the BLE Application
|
||||
*/
|
||||
extern void Peripheral_Init(void);
|
||||
|
||||
/*
|
||||
* Task Event Processor for the BLE Application
|
||||
*/
|
||||
extern uint16_t Peripheral_ProcessEvent(uint8_t task_id, uint16_t events);
|
||||
|
||||
/*********************************************************************
|
||||
*********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,28 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : main.c
|
||||
* Author : WCH
|
||||
* Version : V1.1
|
||||
* Date : 2020/08/06
|
||||
* 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.
|
||||
*******************************************************************************/
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
// 如需修改跳转地址,直接修改启动文件 startup_CH59x.s 中跳转指令 “j” 之后的地址
|
||||
|
||||
/*********************************************************************
|
||||
* @fn main
|
||||
*
|
||||
* @brief 主函数
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
}
|
||||
|
||||
/******************************** endfile @ main ******************************/
|
||||
@@ -0,0 +1,27 @@
|
||||
ENTRY( _start )
|
||||
|
||||
MEMORY
|
||||
{
|
||||
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 4K
|
||||
RAM (xrw) : ORIGIN = 0x20002000, LENGTH = 18K
|
||||
}
|
||||
|
||||
PROVIDE( __global_pointer$ = 0x20002000 );
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.init :
|
||||
{
|
||||
_sinit = .;
|
||||
. = ALIGN(4);
|
||||
KEEP(*(SORT_NONE(.init)))
|
||||
KEEP(*(.ImageFlag))
|
||||
KEEP(*(.ImageFlag.*))
|
||||
. = ALIGN(4);
|
||||
_einit = .;
|
||||
} >FLASH AT>FLASH
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : startup_CH59x.s
|
||||
* Author : WCH
|
||||
* Version : V1.0.0
|
||||
* Date : 2020/04/30
|
||||
* 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
|
||||
.align 1
|
||||
_start:
|
||||
j 0x8000
|
||||
|
||||
@@ -0,0 +1,305 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
||||
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
||||
<cconfiguration id="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.2606500741">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.2606500741" moduleId="org.eclipse.cdt.core.settings" name="obj">
|
||||
<macros/>
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactExtension="elf" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" cleanCommand="${cross_rm} -rf" description="" errorParsers="org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.CWDLocator;org.eclipse.cdt.core.GCCErrorParser" id="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.2606500741" name="obj" parent="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release" postannouncebuildStep="" postbuildStep="" preannouncebuildStep="" prebuildStep="">
|
||||
<folderInfo id="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.2606500741" name="/" resourcePath="">
|
||||
<toolChain id="ilg.gnumcueclipse.managedbuild.cross.riscv.toolchain.elf.release.2606500741" name="RISC-V Cross GCC" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.toolchain.elf.release">
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.rvGcc.1171217701" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.rvGcc" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.rvGcc.8" valueType="enumerated"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.base.1900297968" name="Architecture" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.base" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.arch.rv32i" valueType="enumerated"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.multiply.1509705449" name="Multiply extension (RVM)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.multiply" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.atomic.1590833110" name="Atomic extension (RVA)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.atomic" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.fp.1709872289" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.fp" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.isa.fp.none" valueType="enumerated"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.compressed.1038505275" name="Compressed extension (RVC)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.compressed" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.xw.1505432023" name="Extra Compressed extension (RVXW)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.xw" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.b.1896185078" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.b" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.zmmul.724822239" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.zmmul" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.rvv.435767561" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.rvv" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.isa.rvv." valueType="enumerated"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.abi.integer.387605487" name="Integer ABI" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.abi.integer" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.abi.integer.ilp32" valueType="enumerated"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.abi.fp.966196099" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.abi.fp" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.abi.fp.none" valueType="enumerated"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.tune.394563202" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.tune" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.tune.default" valueType="enumerated"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.codemodel.105093140" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.codemodel" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.codemodel.any" valueType="enumerated"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.smalldatalimit.1147643442" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.smalldatalimit" useByScannerDiscovery="false" value="8" valueType="string"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.align.322546450" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.align" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.align.default" valueType="enumerated"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.saverestore.367800619" name="Small prologue/epilogue (-msave-restore)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.saverestore" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.other.1526047739" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.other" useByScannerDiscovery="true" value="" valueType="string"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.level.514997414" name="Optimization Level" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.level" useByScannerDiscovery="true" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.level.size" valueType="enumerated"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.messagelength.1008570639" name="Message length (-fmessage-length=0)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.messagelength" useByScannerDiscovery="true" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.signedchar.467272439" name="'char' is signed (-fsigned-char)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.signedchar" useByScannerDiscovery="true" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.functionsections.2047756949" name="Function sections (-ffunction-sections)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.functionsections" useByScannerDiscovery="true" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.datasections.207613650" name="Data sections (-fdata-sections)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.datasections" useByScannerDiscovery="true" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.nocommon.358586167" name="No common unitialized (-fno-common)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.nocommon" useByScannerDiscovery="true" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.noinlinefunctions.1298414520" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.noinlinefunctions" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.freestanding.213924425" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.freestanding" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.nobuiltin.2007120903" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.nobuiltin" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.spconstant.938841347" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.spconstant" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.PIC.234574726" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.PIC" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.lto.1002322664" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.lto" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.nomoveloopinvariants.1270575343" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.nomoveloopinvariants" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.mrs.highcode.114339272" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.mrs.highcode" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.mrs.asmsoftlib.896763512" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.mrs.asmsoftlib" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.mrs.pipe.1835231981" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.mrs.pipe" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.mrs.caret.2021231049" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.mrs.caret" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.mrs.ccv.2026012911" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.mrs.ccv" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.other.180560481" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.other" useByScannerDiscovery="true" value="" valueType="string"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.syntaxonly.1145714735" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.syntaxonly" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.pedantic.1546854128" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.pedantic" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.pedanticerrors.338820707" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.pedanticerrors" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.nowarn.254465728" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.nowarn" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.unused.1961191588" name="Warn on various unused elements (-Wunused)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.unused" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.uninitialized.929829166" name="Warn on uninitialized variables (-Wuninitialized)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.uninitialized" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.allwarn.1168626160" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.allwarn" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.extrawarn.291772487" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.extrawarn" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.missingdeclaration.102344169" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.missingdeclaration" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.conversion.550923640" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.conversion" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.pointerarith.773148082" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.pointerarith" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.padded.1788238782" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.padded" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.shadow.427580978" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.shadow" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.logicalop.1501889551" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.logicalop" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.agreggatereturn.1785504720" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.agreggatereturn" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.floatequal.134298453" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.floatequal" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.toerrors.1117291056" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.toerrors" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.other.1918769559" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.other" useByScannerDiscovery="true" value="" valueType="string"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.level.1204865254" name="Debug level" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.level" useByScannerDiscovery="true" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.level.default" valueType="enumerated"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.format.867779652" name="Debug format" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.format" useByScannerDiscovery="true" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.format.default" valueType="enumerated"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.prof.2131276390" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.prof" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.gprof.1910159761" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.gprof" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.other.1654431258" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.other" useByScannerDiscovery="true" value="" valueType="string"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.toolchain.name.1218760634" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.toolchain.name" useByScannerDiscovery="false" value="GNU MCU RISC-V GCC" valueType="string"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.prefix.103341323" name="Prefix" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.prefix" useByScannerDiscovery="false" value="riscv-none-embed-" valueType="string"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.c.487601824" name="C compiler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.c" useByScannerDiscovery="false" value="gcc" valueType="string"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.cpp.1062130429" name="C++ compiler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.cpp" useByScannerDiscovery="false" value="g++" valueType="string"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.ar.1194282993" name="Archiver" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.ar" useByScannerDiscovery="false" value="ar" valueType="string"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.objcopy.1529355265" name="Hex/Bin converter" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.objcopy" useByScannerDiscovery="false" value="objcopy" valueType="string"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.objdump.1053750745" name="Listing generator" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.objdump" useByScannerDiscovery="false" value="objdump" valueType="string"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.size.1441326233" name="Size command" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.size" useByScannerDiscovery="false" value="size" valueType="string"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.make.550105535" name="Build command" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.make" useByScannerDiscovery="false" value="make" valueType="string"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.rm.719280496" name="Remove command" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.rm" useByScannerDiscovery="false" value="rm" valueType="string"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.toolchain.id.226017994" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.toolchain.id" useByScannerDiscovery="false" value="512258282" valueType="string"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createflash.1311852988" name="Create flash image" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createflash" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createlisting.1983282875" name="Create extended listing" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createlisting" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.printsize.1000761142" name="Print size" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.printsize" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="ilg.gnumcueclipse.managedbuild.cross.riscv.targetPlatform.1944008784" isAbstract="false" osList="all" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.targetPlatform"/>
|
||||
<builder buildPath="${workspace_loc:/DLD110S_Peripheral_28K/obj" id="ilg.gnumcueclipse.managedbuild.cross.riscv.builder.1421508906" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" stopOnErr="true" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.builder"/>
|
||||
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.1244756189" name="GNU RISC-V Cross Assembler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler">
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.usepreprocessor.1692176068" name="Use preprocessor" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.usepreprocessor" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.nostdinc.821897907" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.nostdinc" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.preprocessonly.1205312655" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.preprocessonly" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.defs.181380015" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.defs" useByScannerDiscovery="true" valueType="definedSymbols"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.undefs.1514976831" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.undefs" useByScannerDiscovery="true" valueType="undefDefinedSymbols"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.include.paths.1034038285" name="Include paths (-I)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.include.paths" useByScannerDiscovery="true" valueType="includePath"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.include.systempaths.496720673" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.include.systempaths" useByScannerDiscovery="true" valueType="includePath"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.include.files.1898455566" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.include.files" useByScannerDiscovery="true" valueType="includeFiles"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.otherwarnings.1717778600" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.otherwarnings" useByScannerDiscovery="true" value="" valueType="string"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.flags.1578223870" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.flags" useByScannerDiscovery="false" valueType="stringList"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.asmlisting.1937791148" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.asmlisting" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.savetemps.119863881" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.savetemps" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.verbose.1408057941" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.verbose" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.other.1308239903" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.other" useByScannerDiscovery="false" value="" valueType="string"/>
|
||||
<inputType id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.input.126366858" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.input"/>
|
||||
</tool>
|
||||
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.1731377187" name="GNU RISC-V Cross C Compiler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler">
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.nostdinc.1633344562" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.nostdinc" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.preprocessonly.208069239" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.preprocessonly" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.defs.177116515" name="Defined symbols (-D)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.defs" useByScannerDiscovery="true" valueType="definedSymbols">
|
||||
<listOptionValue builtIn="false" value="CH59xBLE_ROM=1"/>
|
||||
<listOptionValue builtIn="false" value="LIB_FLASH_BASE_ADDRESSS=0x0000C000"/>
|
||||
</option>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.undef.1820512625" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.undef" useByScannerDiscovery="true" valueType="undefDefinedSymbols"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.paths.1567947810" name="Include paths (-I)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.paths" useByScannerDiscovery="true" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/Startup}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/APP/include}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/Profile/include}""/>
|
||||
<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}""/>
|
||||
</option>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.systempaths.2011720354" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.systempaths" useByScannerDiscovery="true" valueType="includePath"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.files.542153928" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.files" useByScannerDiscovery="true" valueType="includeFiles"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.std.2020844713" name="Language standard" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.std" useByScannerDiscovery="true" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.std.gnu99" valueType="enumerated"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.otheroptimizations.92321033" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.otheroptimizations" useByScannerDiscovery="true" value="" valueType="string"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.warning.missingprototypes.1180998530" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.warning.missingprototypes" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.warning.strictprototypes.684937223" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.warning.strictprototypes" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.warning.badfunctioncast.1090658371" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.warning.badfunctioncast" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.otherwarnings.882361093" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.otherwarnings" useByScannerDiscovery="true" value="" valueType="string"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.asmlisting.1019398219" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.asmlisting" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.savetemps.1858747105" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.savetemps" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.verbose.658438318" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.verbose" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.other.1132663916" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.other" useByScannerDiscovery="true" value="" valueType="string"/>
|
||||
<inputType id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.input.2036806839" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.input"/>
|
||||
</tool>
|
||||
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.compiler.1610882921" name="GNU RISC-V Cross C++ Compiler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.compiler">
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.nostdinc.1306818359" name="Do not search system directories (-nostdinc)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.nostdinc" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.nostdincpp.411115799" name="Do not search system C++ directories (-nostdinc++)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.nostdincpp" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.preprocessonly.704235280" name="Preprocess only (-E)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.preprocessonly" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.defs.256688978" name="Defined symbols (-D)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.defs" useByScannerDiscovery="true" valueType="definedSymbols"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.undef.1769659537" name="Undefined symbols (-U)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.undef" useByScannerDiscovery="true" valueType="undefDefinedSymbols"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.include.paths.1641430352" name="Include paths (-I)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.include.paths" useByScannerDiscovery="true" valueType="includePath"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.include.systempaths.1217742259" name="Include system paths (-isystem)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.include.systempaths" useByScannerDiscovery="true" valueType="includePath"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.include.files.1922780842" name="Include files (-include)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.include.files" useByScannerDiscovery="true" valueType="includeFiles"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.std.426208505" name="Language standard" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.std" useByScannerDiscovery="true" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.std.gnucpp11" valueType="enumerated"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.abiversion.1671052931" name="ABI version" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.abiversion" useByScannerDiscovery="true" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.abiversion.0" valueType="enumerated"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.noexceptions.1891612477" name="Do not use exceptions (-fno-exceptions)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.noexceptions" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.nortti.76308566" name="Do not use RTTI (-fno-rtti)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.nortti" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.nousecxaatexit.390229569" name="Do not use _cxa_atexit() (-fno-use-cxa-atexit)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.nousecxaatexit" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.nothreadsafestatics.1143999424" name="Do not use thread-safe statics (-fno-threadsafe-statics)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.nothreadsafestatics" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.otheroptimizations.1589858535" name="Other optimization flags" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.otheroptimizations" useByScannerDiscovery="true" value="" valueType="string"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.warnabi.1304561076" name="Warn on ABI violations (-Wabi)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.warnabi" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.warning.ctordtorprivacy.534922494" name="Warn on class privacy (-Wctor-dtor-privacy)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.warning.ctordtorprivacy" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.warning.noexcept.1102421587" name="Warn on no-except expressions (-Wnoexcept)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.warning.noexcept" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.warning.nonvirtualdtor.249412631" name="Warn on virtual destructors (-Wnon-virtual-dtor)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.warning.nonvirtualdtor" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.warning.strictnullsentinel.1022346732" name="Warn on uncast NULL (-Wstrict-null-sentinel)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.warning.strictnullsentinel" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.warning.signpromo.1510049602" name="Warn on sign promotion (-Wsign-promo)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.warning.signpromo" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.warneffc.1507924344" name="Warn about Effective C++ violations (-Weffc++)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.warneffc" useByScannerDiscovery="true" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.otherwarnings.521572828" name="Other warning flags" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.otherwarnings" useByScannerDiscovery="true" value="" valueType="string"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.asmlisting.842958016" name="Generate assembler listing (-Wa,-adhlns="$@.lst")" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.asmlisting" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.savetemps.715871177" name="Save temporary files (--save-temps Use with caution!)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.savetemps" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.verbose.974774820" name="Verbose (-v)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.verbose" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.other.1293392631" name="Other compiler flags" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.compiler.other" useByScannerDiscovery="true" value="" valueType="string"/>
|
||||
<inputType id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.compiler.input.1079228323" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.compiler.input"/>
|
||||
</tool>
|
||||
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.linker.1620074387" name="GNU RISC-V Cross C Linker" outputPrefix="" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.linker">
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.scriptfile.1390103472" name="Script files (-T)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.scriptfile" useByScannerDiscovery="false" valueType="stringList">
|
||||
<listOptionValue builtIn="false" value=""${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.nodeflibs.1285997013" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.nodeflibs" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.nostdlibs.179047434" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.nostdlibs" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.gcsections.194760422" name="Remove unused sections (-Xlinker --gc-sections)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.gcsections" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.printgcsections.270824644" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.printgcsections" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.strip.1802601885" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.strip" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.libs.813115939" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.libs" useByScannerDiscovery="false" valueType="libs">
|
||||
<listOptionValue builtIn="false" value="ISP592"/>
|
||||
</option>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.paths.2057340378" name="Library search path (-L)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.paths" useByScannerDiscovery="false" valueType="libPaths">
|
||||
<listOptionValue builtIn="false" value="../"/>
|
||||
<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.flags.1125808200" 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 IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.otherobjs.16994550" name="Other objects" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.otherobjs" useByScannerDiscovery="false" valueType="userObjs"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.mapfilename.789195953" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.mapfilename" useByScannerDiscovery="false" value=""${BuildArtifactFileBaseName}.map"" valueType="string"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.picolibc.62047318" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.picolibc" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.picolibc.disabled" valueType="enumerated"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.cref.824432654" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.cref" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.printmap.751686263" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.printmap" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.usenewlibnano.239404511" name="Use newlib-nano (--specs=nano.specs)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.usenewlibnano" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.usenewlibnosys.351964161" name="Do not use syscalls (--specs=nosys.specs)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.usenewlibnosys" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.useprintffloat.695795083" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.useprintffloat" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.usescanffloat.1839373535" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.usescanffloat" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.verbose.1444336626" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.verbose" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.printfloat.2044235126" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.printfloat" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.printf.888161142" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.printf" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.iqmath.1390292521" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.iqmath" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.other.1683775650" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.other" useByScannerDiscovery="false" value="" valueType="string"/>
|
||||
<inputType id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.linker.input.1859223768" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.linker.input">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
</inputType>
|
||||
</tool>
|
||||
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.linker.1947503520" name="GNU RISC-V Cross C++ Linker" outputPrefix="" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.linker">
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.scriptfile.1751226764" name="Script files (-T)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.scriptfile" useByScannerDiscovery="false" valueType="stringList">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/Ld/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" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.nodeflibs.282300763" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.nodeflibs" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.nostdlibs.924960428" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.nostdlibs" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.gcsections.1689063433" name="Remove unused sections (-Xlinker --gc-sections)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.gcsections" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.printgcsections.621524254" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.printgcsections" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.strip.679063538" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.strip" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.libs.579700779" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.libs" useByScannerDiscovery="false" valueType="libs">
|
||||
<listOptionValue builtIn="false" value="ISP592"/>
|
||||
</option>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.paths.1029177148" name="Library search path (-L)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.paths" useByScannerDiscovery="false" valueType="libPaths">
|
||||
<listOptionValue builtIn="false" value="../"/>
|
||||
<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.cpp.linker.flags.1251620602" name="Linker flags (-Xlinker [option])" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.flags" useByScannerDiscovery="false" valueType="stringList">
|
||||
<listOptionValue builtIn="false" value="--print-memory-usage"/>
|
||||
</option>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.otherobjs.1493906625" name="Other objects" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.otherobjs" useByScannerDiscovery="false" valueType="userObjs"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.mapfilename.1354773182" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.mapfilename" useByScannerDiscovery="false" value=""${BuildArtifactFileBaseName}.map"" valueType="string"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.picolibc.4345436542" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.picolibc" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.picolibc.disabled" valueType="enumerated"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.cref.1007621036" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.cref" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.printmap.2073713641" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.printmap" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.usenewlibnano.1540675679" name="Use newlib-nano (--specs=nano.specs)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.usenewlibnano" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.usenewlibnosys.561457319" name="Do not use syscalls (--specs=nosys.specs)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.usenewlibnosys" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.useprintffloat.1497004994" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.useprintffloat" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.usescanffloat.881728961" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.usescanffloat" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.verbose.922041698" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.verbose" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.printfloat.476377985" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.printfloat" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.printf.626387227" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.printf" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.iqmath.1441123220" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.iqmath" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.other.1748689212" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.other" useByScannerDiscovery="false" value="" valueType="string"/>
|
||||
</tool>
|
||||
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.archiver.1292785366" name="GNU RISC-V Cross Archiver" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.archiver">
|
||||
<outputType id="cdt.managedbuild.tool.gnu.archiver.output.1527226663" superClass="cdt.managedbuild.tool.gnu.archiver.output" outputPrefix="lib"/>
|
||||
<option id="gnu.both.lib.option.flags.22122911" superClass="gnu.both.lib.option.flags" useByScannerDiscovery="false" value="-r" valueType="string"/>
|
||||
</tool>
|
||||
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.createflash.1801165667" name="GNU RISC-V Cross Create Flash Image" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.createflash">
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.textsection.1097396305" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.textsection" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.datasection.2034511797" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.datasection" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.choice.1726268709" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.choice" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.choice.ihex" valueType="enumerated"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.othersection.1890795928" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.othersection" useByScannerDiscovery="false" valueType="stringList"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.other.788974495" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.other" useByScannerDiscovery="false" value="" valueType="string"/>
|
||||
</tool>
|
||||
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.createlisting.1356766765" name="GNU RISC-V Cross Create Listing" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.createlisting">
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.source.2052761852" name="Display source (--source|-S)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.source" useByScannerDiscovery="false" value="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.debugging.1623481730" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.debugging" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.disassemble.1859590835" name="Disassemble (--disassemble|-d)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.disassemble" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.fileheaders.160868348" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.fileheaders" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.linenumbers.1549373929" name="Display line numbers (--line-numbers|-l)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.linenumbers" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.reloc.1008747895" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.reloc" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.symbols.577922241" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.symbols" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.wide.1298918921" name="Wide lines (--wide|-w)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.wide" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.other.1560864108" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.other" useByScannerDiscovery="false" value="" valueType="string"/>
|
||||
</tool>
|
||||
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.printsize.712424314" name="GNU RISC-V Cross Print Size" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.printsize">
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.printsize.format.1404031980" name="Size format" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.printsize.format" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.printsize.format.berkeley" valueType="enumerated"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.printsize.hex.176087647" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.printsize.hex" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.printsize.totals.380903440" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.printsize.totals" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.printsize.other.1271150877" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.printsize.other" useByScannerDiscovery="false" value="" valueType="string"/>
|
||||
</tool>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry excluding="HAL/Profile|HAL/KEY.c|HAL/LED.c|StdPeriphDriver/CH59x_lcd.c|StdPeriphDriver/CH59x_uart1.c|StdPeriphDriver/CH59x_usbdev.c|StdPeriphDriver/CH59x_usbhostClass.c|StdPeriphDriver/CH59x_usbhostBase.c|StdPeriphDriver/CH59x_pwm.c|StdPeriphDriver/CH59x_spi0.c|StdPeriphDriver/CH59x_timer2.c|StdPeriphDriver/CH59x_timer3.c|StdPeriphDriver/CH59x_uart2.c|StdPeriphDriver/CH59x_uart3.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
<storageModule moduleId="ilg.gnumcueclipse.managedbuild.packs"/>
|
||||
</cconfiguration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<project id="999.ilg.gnumcueclipse.managedbuild.cross.riscv.target.elf.275846018" name="Executable file" projectType="ilg.gnumcueclipse.managedbuild.cross.riscv.target.elf"/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
<scannerConfigBuildInfo instanceId="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.debug.767917625;ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.debug.767917625.;ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.1375371130;ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.input.1473381709">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.1008047074;ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.1008047074.;ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.1731377187;ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.input.2036806839">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</scannerConfigBuildInfo>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
|
||||
</cproject>
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "."
|
||||
},
|
||||
{
|
||||
"name": "DLD110S_Peripheral_28K",
|
||||
"path": "e:\\pando\\dg\\prjs\\DLD\\DLD110SB\\BLE\\DLD110S_Peripheral_28K"
|
||||
}
|
||||
],
|
||||
"settings": {
|
||||
"mrs.workspace.type": "project",
|
||||
"files.associations": {
|
||||
"*.c": "c",
|
||||
"*.h": "cpp",
|
||||
"*.hxx": "cpp",
|
||||
"*.hpp": "cpp",
|
||||
"*.c++": "cpp",
|
||||
"*.cpp": "cpp",
|
||||
"*.cxx": "cpp",
|
||||
"*.cc": "cpp",
|
||||
"*.hh": "cpp",
|
||||
"*.h++": "cpp"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "."
|
||||
},
|
||||
{
|
||||
"name": "DLD110S_Peripheral_28K",
|
||||
"path": "e:\\pando\\dg\\prjs\\DLD\\DLD110SB\\BLE\\DLD110S_Peripheral_28K"
|
||||
}
|
||||
],
|
||||
"settings": {
|
||||
"mrs.workspace.type": "project",
|
||||
"files.associations": {
|
||||
"*.c": "c",
|
||||
"*.h": "cpp",
|
||||
"*.hxx": "cpp",
|
||||
"*.hpp": "cpp",
|
||||
"*.c++": "cpp",
|
||||
"*.cpp": "cpp",
|
||||
"*.cxx": "cpp",
|
||||
"*.cc": "cpp",
|
||||
"*.hh": "cpp",
|
||||
"*.h++": "cpp"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "."
|
||||
},
|
||||
{
|
||||
"name": "DVM100BPro_Peipheral_28K",
|
||||
"path": "e:\\pando\\dg\\prjs\\DVM\\DVM100B\\BLE\\DVM100BPro_Peipheral_28K"
|
||||
}
|
||||
],
|
||||
"settings": {
|
||||
"mrs.workspace.type": "project",
|
||||
"files.associations": {
|
||||
"*.c": "c",
|
||||
"*.h": "cpp",
|
||||
"*.hxx": "cpp",
|
||||
"*.hpp": "cpp",
|
||||
"*.c++": "cpp",
|
||||
"*.cpp": "cpp",
|
||||
"*.cxx": "cpp",
|
||||
"*.cc": "cpp",
|
||||
"*.hh": "cpp",
|
||||
"*.h++": "cpp"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "."
|
||||
},
|
||||
{
|
||||
"name": "DLD110S_Peripheral_28K",
|
||||
"path": "e:\\pando\\dg\\prjs\\DLD\\DLD110SB\\BLE\\DLD110S_Peripheral_28K"
|
||||
}
|
||||
],
|
||||
"settings": {
|
||||
"mrs.workspace.type": "project",
|
||||
"files.associations": {
|
||||
"*.c": "c",
|
||||
"*.h": "cpp",
|
||||
"*.hxx": "cpp",
|
||||
"*.hpp": "cpp",
|
||||
"*.c++": "cpp",
|
||||
"*.cpp": "cpp",
|
||||
"*.cxx": "cpp",
|
||||
"*.cc": "cpp",
|
||||
"*.hh": "cpp",
|
||||
"*.h++": "cpp"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "."
|
||||
},
|
||||
{
|
||||
"name": "DLD110S_Peripheral_28K",
|
||||
"path": "e:\\pando\\dg\\prjs\\DLD\\DLD110SB\\BLE\\DLD110S_Peripheral_28K"
|
||||
}
|
||||
],
|
||||
"settings": {
|
||||
"mrs.workspace.type": "project",
|
||||
"files.associations": {
|
||||
"*.c": "c",
|
||||
"*.h": "cpp",
|
||||
"*.hxx": "cpp",
|
||||
"*.hpp": "cpp",
|
||||
"*.c++": "cpp",
|
||||
"*.cpp": "cpp",
|
||||
"*.cxx": "cpp",
|
||||
"*.cc": "cpp",
|
||||
"*.hh": "cpp",
|
||||
"*.h++": "cpp"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "."
|
||||
},
|
||||
{
|
||||
"name": "DLD110S_Peripheral_28K",
|
||||
"path": "e:\\pando\\dg\\prjs\\DLD\\DLD110SB\\BLE\\DLD110S_Peripheral_28K"
|
||||
}
|
||||
],
|
||||
"settings": {
|
||||
"mrs.workspace.type": "project",
|
||||
"files.associations": {
|
||||
"*.c": "c",
|
||||
"*.h": "cpp",
|
||||
"*.hxx": "cpp",
|
||||
"*.hpp": "cpp",
|
||||
"*.c++": "cpp",
|
||||
"*.cpp": "cpp",
|
||||
"*.cxx": "cpp",
|
||||
"*.cc": "cpp",
|
||||
"*.hh": "cpp",
|
||||
"*.h++": "cpp"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "."
|
||||
},
|
||||
{
|
||||
"name": "DLD110S_Peripheral_28K",
|
||||
"path": "E:\\pando\\dg\\prjs\\DLD\\DLD110SB\\BLE\\DLD110S_Peripheral_28K"
|
||||
}
|
||||
],
|
||||
"settings": {
|
||||
"mrs.workspace.type": "project",
|
||||
"mrs.init.arg": "",
|
||||
"files.associations": {
|
||||
"*.c": "c",
|
||||
"*.h": "cpp",
|
||||
"*.hxx": "cpp",
|
||||
"*.hpp": "cpp",
|
||||
"*.c++": "cpp",
|
||||
"*.cpp": "cpp",
|
||||
"*.cxx": "cpp",
|
||||
"*.cc": "cpp",
|
||||
"*.hh": "cpp",
|
||||
"*.h++": "cpp"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "."
|
||||
},
|
||||
{
|
||||
"name": "DLD110S_Peripheral_28K",
|
||||
"path": "e:\\pando\\dg\\prjs\\DLD\\DLD110SB\\BLE\\DLD110S_Peripheral_28K"
|
||||
}
|
||||
],
|
||||
"settings": {
|
||||
"mrs.workspace.type": "project",
|
||||
"files.associations": {
|
||||
"*.c": "c",
|
||||
"*.h": "cpp",
|
||||
"*.hxx": "cpp",
|
||||
"*.hpp": "cpp",
|
||||
"*.c++": "cpp",
|
||||
"*.cpp": "cpp",
|
||||
"*.cxx": "cpp",
|
||||
"*.cc": "cpp",
|
||||
"*.hh": "cpp",
|
||||
"*.h++": "cpp"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "."
|
||||
},
|
||||
{
|
||||
"name": "DLD110S_Peripheral_28K",
|
||||
"path": "e:\\pando\\dg\\prjs\\DLD\\DLD110SB\\BLE\\DLD110S_Peripheral_28K"
|
||||
}
|
||||
],
|
||||
"settings": {
|
||||
"mrs.workspace.type": "project",
|
||||
"files.associations": {
|
||||
"*.c": "c",
|
||||
"*.h": "cpp",
|
||||
"*.hxx": "cpp",
|
||||
"*.hpp": "cpp",
|
||||
"*.c++": "cpp",
|
||||
"*.cpp": "cpp",
|
||||
"*.cxx": "cpp",
|
||||
"*.cc": "cpp",
|
||||
"*.hh": "cpp",
|
||||
"*.h++": "cpp"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"folders": [
|
||||
{
|
||||
"name": ".mrs",
|
||||
"path": "."
|
||||
},
|
||||
{
|
||||
"name": "DLR008B_28K_Gate",
|
||||
"path": "../../../../../drd/DLR008B-test/DLR008B/BLE/DLR008B_28K_Gate"
|
||||
}
|
||||
],
|
||||
"settings": {
|
||||
"mrs.workspace.type": "project",
|
||||
"files.associations": {
|
||||
"*.c": "c",
|
||||
"*.h": "cpp",
|
||||
"*.hxx": "cpp",
|
||||
"*.hpp": "cpp",
|
||||
"*.c++": "cpp",
|
||||
"*.cpp": "cpp",
|
||||
"*.cxx": "cpp",
|
||||
"*.cc": "cpp",
|
||||
"*.hh": "cpp",
|
||||
"*.h++": "cpp"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "."
|
||||
},
|
||||
{
|
||||
"name": "DLD110S_Peripheral_28K",
|
||||
"path": "e:\\pando\\dg\\prjs\\DLD\\DLD110SB\\BLE\\DLD110S_Peripheral_28K"
|
||||
}
|
||||
],
|
||||
"settings": {
|
||||
"mrs.workspace.type": "project",
|
||||
"files.associations": {
|
||||
"*.c": "c",
|
||||
"*.h": "cpp",
|
||||
"*.hxx": "cpp",
|
||||
"*.hpp": "cpp",
|
||||
"*.c++": "cpp",
|
||||
"*.cpp": "cpp",
|
||||
"*.cxx": "cpp",
|
||||
"*.cc": "cpp",
|
||||
"*.hh": "cpp",
|
||||
"*.h++": "cpp"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "."
|
||||
},
|
||||
{
|
||||
"name": "DLD110S_Peripheral_28K",
|
||||
"path": "E:\\pando\\dg\\prjs\\DLD\\DLD110SB\\BLE\\DLD110S_Peripheral_28K"
|
||||
}
|
||||
],
|
||||
"settings": {
|
||||
"mrs.workspace.type": "project",
|
||||
"mrs.init.arg": "",
|
||||
"files.associations": {
|
||||
"*.c": "c",
|
||||
"*.h": "cpp",
|
||||
"*.hxx": "cpp",
|
||||
"*.hpp": "cpp",
|
||||
"*.c++": "cpp",
|
||||
"*.cpp": "cpp",
|
||||
"*.cxx": "cpp",
|
||||
"*.cc": "cpp",
|
||||
"*.hh": "cpp",
|
||||
"*.h++": "cpp"
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,67 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "mrs-debugger",
|
||||
"request": "launch",
|
||||
"name": "DLD110S_Peripheral_28K",
|
||||
"cwd": "e:\\pando\\dg\\prjs\\DLD\\DLD110SB\\BLE\\DLD110S_Peripheral_28K",
|
||||
"openOCDCfg": {
|
||||
"useLocalOpenOCD": true,
|
||||
"executable": "d:/MounRiver/MounRiver_Studio2/resources/app/resources/win32/components/WCH/OpenOCD/OpenOCD/bin/openocd.exe",
|
||||
"configOptions": [
|
||||
"-f \"d:/MounRiver/MounRiver_Studio2/resources/app/resources/win32/components/WCH/OpenOCD/OpenOCD/bin/wch-riscv.cfg\" -c \"chip_id CH59x\""
|
||||
],
|
||||
"gdbport": 3333,
|
||||
"telnetport": 4444,
|
||||
"tclport": 6666,
|
||||
"host": "localhost",
|
||||
"port": 3333,
|
||||
"skipDownloadBeforeDebug": false,
|
||||
"enablePageEraser": false,
|
||||
"enableNoZeroWaitingAreaFlash": false
|
||||
},
|
||||
"gdbCfg": {
|
||||
"executable": "d:/MounRiver/MounRiver_Studio2/resources/app/resources/win32/components/WCH/Toolchain/RISC-V Embedded GCC/bin/riscv-none-embed-gdb.exe",
|
||||
"commands": [
|
||||
"set mem inaccessible-by-default off",
|
||||
"set architecture riscv:rv32",
|
||||
"set remotetimeout unlimited"
|
||||
],
|
||||
"options": []
|
||||
},
|
||||
"startup": {
|
||||
"initCommands": {
|
||||
"initReset": true,
|
||||
"initResetType": "init",
|
||||
"armSemihosting": false,
|
||||
"additionalCommands": []
|
||||
},
|
||||
"loadedFiles": {
|
||||
"executableFile": "e:\\pando\\dg\\prjs\\DLD\\DLD110SB\\BLE\\DLD110S_Peripheral_28K\\obj\\DLD110S_Peripheral_28K.elf",
|
||||
"symbolFile": "e:\\pando\\dg\\prjs\\DLD\\DLD110SB\\BLE\\DLD110S_Peripheral_28K\\obj\\DLD110S_Peripheral_28K.elf",
|
||||
"executableFileOffset": 0,
|
||||
"symbolFileOffset": 0
|
||||
},
|
||||
"runCommands": {
|
||||
"runReset": true,
|
||||
"runResetType": "halt",
|
||||
"additionalCommands": [],
|
||||
"setBreakAt": "handle_reset",
|
||||
"continue": true,
|
||||
"setProgramCounterAt": 0
|
||||
},
|
||||
"debugInRAM": false
|
||||
},
|
||||
"svdpath": "",
|
||||
"output": {
|
||||
"showDebugGDBTrace": true,
|
||||
"saveDebugOutputToFile": false,
|
||||
"showDebugOutputTimestamps": true
|
||||
},
|
||||
"isDualCoreDebug": false,
|
||||
"dualCoreDebugRole": null,
|
||||
"architecture": "RISC-V"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<projectDescription>
|
||||
<name>DLD110S_Peripheral_28K</name>
|
||||
<comment/>
|
||||
<projects/>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||
<triggers>clean,full,incremental,</triggers>
|
||||
<arguments/>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
|
||||
<triggers>full,incremental,</triggers>
|
||||
<arguments/>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.cdt.core.cnature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
||||
</natures>
|
||||
<linkedResources>
|
||||
<link>
|
||||
<name>HAL</name>
|
||||
<type>2</type>
|
||||
<location>PARENT-1-PROJECT_LOC/HAL</location>
|
||||
</link>
|
||||
<link>
|
||||
<name>LIB</name>
|
||||
<type>2</type>
|
||||
<location>PARENT-1-PROJECT_LOC/LIB</location>
|
||||
</link>
|
||||
<link>
|
||||
<name>RVMSIS</name>
|
||||
<type>2</type>
|
||||
<location>PARENT-2-PROJECT_LOC/SRC/RVMSIS</location>
|
||||
</link>
|
||||
<link>
|
||||
<name>StdPeriphDriver</name>
|
||||
<type>2</type>
|
||||
<location>PARENT-2-PROJECT_LOC/SRC/StdPeriphDriver</location>
|
||||
</link>
|
||||
</linkedResources>
|
||||
<filteredResources>
|
||||
<filter>
|
||||
<name/>
|
||||
<type>6</type>
|
||||
<matcher>
|
||||
<id>org.eclipse.ui.ide.multiFilter</id>
|
||||
<arguments>1.0-name-matches-false-false-*.wvproj</arguments>
|
||||
</matcher>
|
||||
</filter>
|
||||
</filteredResources>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,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="103336483641875289" 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,27 @@
|
||||
Vendor=WCH
|
||||
Toolchain=RISC-V
|
||||
Series=CH59X
|
||||
RTOS=NoneOS
|
||||
CalibrateSupport=false
|
||||
CalibrateCommand=
|
||||
MCU=CH591R
|
||||
Link=WCH-Link
|
||||
PeripheralVersion=1.0
|
||||
Description=
|
||||
TempratureScope=
|
||||
ArtifactType=executable
|
||||
Mcu Type=CH59x
|
||||
Address=0x00000000
|
||||
Target Path=
|
||||
Exe Path=
|
||||
Exe Arguments=
|
||||
CLKSpeed=1
|
||||
DebugInterfaceMode=0
|
||||
Erase All=false
|
||||
Program=false
|
||||
Verify=false
|
||||
Reset=false
|
||||
SDIPrintf=false
|
||||
Disable Power Output=false
|
||||
Clear CodeFlash=false
|
||||
Disable Code-Protect=false
|
||||
@@ -0,0 +1,854 @@
|
||||
/*
|
||||
* dbn_ble_srv.c
|
||||
*
|
||||
* Created on: Aug 27, 2024
|
||||
* Author: Thinkpad
|
||||
*/
|
||||
|
||||
#include "dbn_ble_srv.h"
|
||||
#include "cmcng.h"
|
||||
#include "storage.h"
|
||||
#include "CH59x_common.h"
|
||||
|
||||
|
||||
uint8_t g_flag_notify_temp = 0; //临时通知notify flag, 0 disable, 1 enable
|
||||
|
||||
BLE_Notify_Buf g_notify_buftemp = {0,0, ""};
|
||||
BLE_Notify_Buf g_ble_rcv_buf = {0,0, ""};
|
||||
BLE_Notify_Buf g_tmp_report_buf = {0,0, ""};
|
||||
|
||||
Buf_DBN_BLE g_buf_ble_response = {0,0,0,0,0,0,0,""};
|
||||
|
||||
uint8_t tmp_ble_buf[MAX_BLE_TMP_BUF_LEN] = "";
|
||||
|
||||
extern uint8_t loop1_FLAG_CUT;
|
||||
|
||||
|
||||
void clear_ble_notify_buf(BLE_Notify_Buf * buf)
|
||||
{
|
||||
buf->len = 0;
|
||||
buf->flag = 0;
|
||||
memset(buf, 0, MAX_BLE_Notify_Buf_LEN);
|
||||
}
|
||||
|
||||
void clear_buf_dbn_ble(Buf_DBN_BLE * buf)
|
||||
{
|
||||
uint8_t i = 0;
|
||||
|
||||
|
||||
buf->flag = 0;
|
||||
buf->magic = 0;
|
||||
buf->cmd = 0;
|
||||
memset(buf->dat, 0, buf->dat_len);
|
||||
buf->dat_len = 0;
|
||||
buf->dat_offset = 0;
|
||||
buf->pkg_amount = 0;
|
||||
buf->pkg_seq = 0;
|
||||
}
|
||||
|
||||
void clear_buf_dbn_ble_all(Buf_DBN_BLE * buf)
|
||||
{
|
||||
uint8_t i = 0;
|
||||
// if(g_flag_debug)
|
||||
{
|
||||
// PRINT("\nclear_buf_dbn_ble_flag:%02X,magic:%02X,pkg_amount:%02X,seq:%02X,cmd:%02X, dat_len:%d,offset:%d\n",
|
||||
// buf->flag,buf->magic,buf->pkg_amount, buf->pkg_seq,buf->cmd, buf->dat_len,buf->dat_offset);
|
||||
// for(i = 0; i < buf->dat_len; i++)
|
||||
// {
|
||||
// PRINT(" %02X", buf->dat[i]);
|
||||
// }
|
||||
// PRINT("\n");
|
||||
}
|
||||
buf->flag = 0;
|
||||
buf->magic = 0;
|
||||
buf->cmd = 0;
|
||||
memset(buf->dat, 0, MAX_BLE_BUF_LEN);
|
||||
buf->dat_len = 0;
|
||||
buf->dat_offset = 0;
|
||||
buf->pkg_amount = 0;
|
||||
buf->pkg_seq = 0;
|
||||
}
|
||||
|
||||
|
||||
// 0: 包检测异常
|
||||
//检测包是否完整,Magic Byte, Header Byte, CK Byte, 校验字节(异或校验,以及和校验)
|
||||
uint8_t check_pkg(uint8_t * pkg, uint8_t len)
|
||||
{
|
||||
if(len < 6) //min length of ble pkg is 6
|
||||
return 0;
|
||||
uint8_t magic = pkg[0];
|
||||
uint8_t _len = pkg[2]; //data_len
|
||||
if(_len + 5 < len)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
uint8_t _dxor = 0;
|
||||
uint8_t _dsum = 0;
|
||||
uint8_t _cklen = _len + 3; //不计算 校验字节
|
||||
uint8_t i = 0;
|
||||
for(i = 1; i < _cklen; i++)
|
||||
{
|
||||
_dxor ^= pkg[i];
|
||||
_dsum += pkg[i];
|
||||
}
|
||||
if((_dxor != pkg[_cklen]) || (_dsum != pkg[_cklen+1]))
|
||||
{
|
||||
// if(g_flag_debug)
|
||||
// {
|
||||
// PRINT("_dxor:0x%02X - 0x%02X, _dsum:0x%02X - 0x%02X\r\n", _dxor, pkg[_cklen], _dsum, pkg[_cklen + 1] );
|
||||
// }
|
||||
return 0;
|
||||
}
|
||||
|
||||
return magic;
|
||||
}
|
||||
|
||||
static uint8_t set_dev_info_to_ready(uint8_t *dat_dst)
|
||||
{
|
||||
uint8_t i = 0, j = 0;
|
||||
for(i = 0; i < 6; i++)
|
||||
{
|
||||
dat_dst[i] = MACAddr[i];
|
||||
// PRINT(" %02X",dat_dst[i] );
|
||||
}
|
||||
// memcpy(dat_dst, MACAddr, sizeof(MACAddr));
|
||||
// i += sizeof(MACAddr);
|
||||
dat_dst[i++] = HARDWARE_VER_MAIN;
|
||||
dat_dst[i++] = HARDWARE_VER_SUB;
|
||||
dat_dst[i++] = FIRMWARE_VER_MAIN;
|
||||
dat_dst[i++] = FIRMWARE_VER_SUB;
|
||||
|
||||
// Dev Model
|
||||
dat_dst[i++] = strlen(PRODUCT_MODEL);
|
||||
memcpy(&dat_dst[i], PRODUCT_MODEL, strlen(PRODUCT_MODEL));
|
||||
i += strlen(PRODUCT_MODEL);
|
||||
|
||||
// Dev Number
|
||||
for(j = 0; j < 6; j++, i++)
|
||||
{
|
||||
dat_dst[i] = g_dev_number[j];
|
||||
}
|
||||
// sub_code
|
||||
// memcpy(&dat_dst[i], &(g_sub_code_enable.code_set), sizeof(g_sub_code_enable.code_set));
|
||||
// i += sizeof(g_sub_code_enable.code_set);
|
||||
dat_dst[i++] = 0;
|
||||
dat_dst[i++] = 0;
|
||||
|
||||
|
||||
dat_dst[i++] = 0; // g_bus_dus_amount_stored.bus1_amount;
|
||||
dat_dst[i++] = 0; //g_bus_dus_amount_stored.bus2_amount;
|
||||
return i;
|
||||
}
|
||||
|
||||
uint8_t set_response_buf(Buf_DBN_BLE *response_dst, uint8_t magic, uint8_t cmd, uint8_t * dat, uint8_t dat_len)
|
||||
{
|
||||
uint8_t ret = 0;
|
||||
uint8_t i = 0;
|
||||
clear_buf_dbn_ble(response_dst);
|
||||
response_dst->magic = magic;
|
||||
response_dst->cmd = cmd;
|
||||
|
||||
uint8_t _amount = dat_len / MAX_BLE_DAT_RESPONSE_LEN;
|
||||
if((dat_len % MAX_BLE_DAT_RESPONSE_LEN) > 0)
|
||||
{
|
||||
_amount++;
|
||||
}
|
||||
response_dst->pkg_amount = _amount;
|
||||
response_dst->pkg_seq = 0;
|
||||
response_dst->dat_len = dat_len;
|
||||
for(i = 0; i < dat_len; i++)
|
||||
{
|
||||
response_dst->dat[i] = dat[i];
|
||||
}
|
||||
response_dst->flag = 1;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint16_t compute_ckb(uint8_t header_0, uint8_t header_1, uint8_t header_cmd, uint8_t *dat, uint8_t dat_len)
|
||||
{
|
||||
uint16_t ret = 0;
|
||||
uint8_t i = 0;
|
||||
uint8_t _dxor = header_0 ^ header_1 ^ header_cmd;
|
||||
uint8_t _dsum = header_0 + header_1 + header_cmd;
|
||||
|
||||
for(i = 0; i < dat_len; i++)
|
||||
{
|
||||
_dxor ^= dat[i];
|
||||
_dsum += dat[i];
|
||||
}
|
||||
ret = _dxor;
|
||||
ret = (ret << 8) + (_dsum % 0x100);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
//response_ori must set_response_buf first
|
||||
uint8_t set_response_to_notify(Buf_DBN_BLE *response_ori, BLE_Notify_Buf * notify_dst)
|
||||
{
|
||||
uint8_t ret = 0;
|
||||
uint8_t i = 0;
|
||||
uint16_t _ckbl = 0;
|
||||
if(notify_dst->flag)
|
||||
{ //dst not idle
|
||||
return ret;
|
||||
}
|
||||
if(response_ori->flag == 0)
|
||||
{ //ori idle
|
||||
return ret;
|
||||
}
|
||||
if(response_ori->pkg_amount <= 1)
|
||||
{
|
||||
//没有分包的情况
|
||||
notify_dst->buf[0] = response_ori->magic;
|
||||
if(response_ori->magic == MAGIC_BYTE_DBN_TRANSPARENT)
|
||||
{
|
||||
notify_dst->buf[1] = response_ori->pkg_seq;
|
||||
}
|
||||
else
|
||||
{
|
||||
notify_dst->buf[1] = 0;
|
||||
}
|
||||
notify_dst->buf[2] = response_ori->dat_len + 1; // 1 is cmd_byte
|
||||
notify_dst->buf[3] = response_ori->cmd;
|
||||
_ckbl = compute_ckb(notify_dst->buf[1], notify_dst->buf[2], notify_dst->buf[3], response_ori->dat, response_ori->dat_len);
|
||||
for(i = 0; i < response_ori->dat_len; i++)
|
||||
{
|
||||
notify_dst->buf[i + 4] = response_ori->dat[i];
|
||||
}
|
||||
notify_dst->buf[i + 4] = (uint8_t)(_ckbl >> 8);
|
||||
i++;
|
||||
notify_dst->buf[i + 4] = (uint8_t)(_ckbl);
|
||||
i++;
|
||||
notify_dst->len = i + 4;
|
||||
// if(g_flag_debug)
|
||||
// {
|
||||
// PRINT("set_response_to_notify_dst__\n");
|
||||
// for(i = 0; i < notify_dst->len; i++)
|
||||
// {
|
||||
// PRINT(" %02X", notify_dst->buf[i]);
|
||||
// }
|
||||
// }
|
||||
notify_dst->flag = 1;
|
||||
|
||||
clear_buf_dbn_ble(response_ori);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
notify_dst->buf[0] = response_ori->magic;
|
||||
uint8_t _pkg_amount = response_ori->pkg_amount;
|
||||
uint8_t _pkg_seq = response_ori->pkg_seq;
|
||||
uint8_t _remain_len = response_ori->dat_len - response_ori->dat_offset;
|
||||
if(_remain_len > MAX_BLE_DAT_RESPONSE_LEN)
|
||||
{
|
||||
_remain_len = MAX_BLE_DAT_RESPONSE_LEN;
|
||||
}
|
||||
_pkg_seq += 1;
|
||||
notify_dst->buf[1] = (_pkg_amount << 4)|(_pkg_seq);
|
||||
notify_dst->buf[2] = _remain_len + 1; // 1 is cmd_byte
|
||||
notify_dst->buf[3] = response_ori->cmd;
|
||||
|
||||
_ckbl = compute_ckb(notify_dst->buf[1], notify_dst->buf[2], notify_dst->buf[3],
|
||||
&(response_ori->dat[response_ori->dat_offset]), _remain_len);
|
||||
for(i = 0; i < _remain_len; i++)
|
||||
{
|
||||
notify_dst->buf[i + 4] = response_ori->dat[response_ori->dat_offset + i];
|
||||
}
|
||||
notify_dst->buf[i + 4] = (uint8_t)(_ckbl >> 8);
|
||||
i++;
|
||||
notify_dst->buf[i + 4] = (uint8_t)(_ckbl);
|
||||
i++;
|
||||
|
||||
response_ori->dat_offset += _remain_len;
|
||||
response_ori->pkg_seq += 1;
|
||||
notify_dst->len = i + 4;
|
||||
|
||||
|
||||
// if(g_flag_debug)
|
||||
// {
|
||||
// PRINT("\nset_notify_dst,amount:%d,seq:%d,offset:%d\n", response_ori->pkg_amount,response_ori->pkg_seq, response_ori->dat_offset);
|
||||
// for(i = 0; i < notify_dst->len; i++)
|
||||
// {
|
||||
// PRINT(" %02X", notify_dst->buf[i]);
|
||||
// }
|
||||
// PRINT("\n");
|
||||
// }
|
||||
|
||||
notify_dst->flag = 1;
|
||||
if(response_ori->pkg_amount == response_ori->pkg_seq)
|
||||
{
|
||||
clear_buf_dbn_ble(response_ori);
|
||||
}
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
static uint8_t unpack_packs(uint8_t *pkg, uint8_t len)
|
||||
{
|
||||
static uint8_t _offset = 0;
|
||||
uint8_t _header_0 = pkg[1];
|
||||
uint8_t _header_0_high = _header_0 >> 4;
|
||||
uint8_t _header_0_low = _header_0 % 0x10;
|
||||
uint8_t _len = pkg[2];
|
||||
uint8_t _cmd = pkg[3];
|
||||
uint8_t i = 0, j = 0, k = 0;
|
||||
uint8_t _amount = 0;
|
||||
|
||||
if(_header_0_high)
|
||||
{
|
||||
if(_header_0_low == 1)
|
||||
{
|
||||
g_buf_ble_response.magic = pkg[0];
|
||||
g_buf_ble_response.pkg_amount = _header_0_high;
|
||||
g_buf_ble_response.pkg_seq = _header_0_low;
|
||||
g_buf_ble_response.cmd = _cmd;
|
||||
memcpy(&g_buf_ble_response.dat, &pkg[4], _len - 1);
|
||||
_offset = _len - 1;
|
||||
g_buf_ble_response.dat_len = _len - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if((g_buf_ble_response.pkg_amount != _header_0_high) || (g_buf_ble_response.cmd != _cmd))
|
||||
{
|
||||
//printf("\nNot_the_right_sub_pack!\n");
|
||||
clear_buf_dbn_ble_all(&g_buf_ble_response);
|
||||
return 0;
|
||||
}
|
||||
if(g_buf_ble_response.pkg_seq != (_header_0_low -1))
|
||||
{
|
||||
//printf("\nNot_the_right_sub_pack!!\n");
|
||||
clear_buf_dbn_ble_all(&g_buf_ble_response);
|
||||
return 0;
|
||||
}
|
||||
g_buf_ble_response.pkg_seq = _header_0_low;
|
||||
g_buf_ble_response.dat_len += (_len - 1); // not include cmd_byte
|
||||
memcpy(&g_buf_ble_response.dat[_offset], &pkg[4], _len - 1);
|
||||
_offset += (_len - 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
clear_buf_dbn_ble(&g_buf_ble_response);
|
||||
g_buf_ble_response.magic = pkg[0];
|
||||
g_buf_ble_response.pkg_amount = 1;
|
||||
g_buf_ble_response.pkg_seq = 0;
|
||||
g_buf_ble_response.cmd = _cmd;
|
||||
g_buf_ble_response.dat_len = (_len - 1);
|
||||
memcpy(g_buf_ble_response.dat, &pkg[4], _len - 1);
|
||||
}
|
||||
|
||||
if(_header_0_high == _header_0_low)
|
||||
{
|
||||
// received end.
|
||||
// if(g_flag_debug)
|
||||
// {
|
||||
// printf("\nReceive_pack_over:\n");
|
||||
// for(i = 0; i < g_buf_ble_response.dat_len; i++)
|
||||
// {
|
||||
// printf(" %02X", g_buf_ble_response.dat[i]);
|
||||
// }
|
||||
// printf("\nEnd\n");
|
||||
// }
|
||||
|
||||
|
||||
if(g_buf_ble_response.cmd == CMD_DBN_CHECK_PASS)
|
||||
{
|
||||
// memset(tmp_ble_buf, 0, MAX_BLE_TMP_BUF_LEN);
|
||||
// if(g_buf_ble_response.dat_len != 6)
|
||||
// {
|
||||
// //response pass failed
|
||||
// tmp_ble_buf[0] = 0x01;
|
||||
// set_response_buf(&g_buf_ble_response, MAGIC_BYTE_DBN_DEFAULT, _cmd, tmp_ble_buf, 1);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// char _pass = check_ble_safe_pass(g_buf_ble_response.dat);
|
||||
// if(_pass)
|
||||
// {
|
||||
// //response ok
|
||||
// tmp_ble_buf[0] = 0x0;
|
||||
// set_response_buf(&g_buf_ble_response, MAGIC_BYTE_DBN_DEFAULT, _cmd, tmp_ble_buf, 1);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //response failed
|
||||
// tmp_ble_buf[0] = 0x01;
|
||||
// set_response_buf(&g_buf_ble_response, MAGIC_BYTE_DBN_DEFAULT, _cmd, tmp_ble_buf, 1);
|
||||
// }
|
||||
// }
|
||||
|
||||
} //end if g_buf_ble_response.cmd == CMD_DBN_CHECK_PASS
|
||||
else if(g_buf_ble_response.cmd == CMD_DBN_MODIFY_PASS)
|
||||
{
|
||||
// memset(tmp_ble_buf, 0, MAX_BLE_TMP_BUF_LEN);
|
||||
// if(g_buf_ble_response.dat_len != 12)
|
||||
// {
|
||||
// //response failed
|
||||
// tmp_ble_buf[0] = 0x01;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// char _pass = check_ble_safe_pass(g_buf_ble_response.dat);
|
||||
// if(_pass)
|
||||
// {
|
||||
// //response ok
|
||||
// set_ble_safe_pass(&g_buf_ble_response.dat[6]);
|
||||
// tmp_ble_buf[0] = 0x00;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //response failed
|
||||
// tmp_ble_buf[0] = 0x01;
|
||||
// }
|
||||
// }
|
||||
set_response_buf(&g_buf_ble_response, MAGIC_BYTE_DBN_DEFAULT, _cmd, tmp_ble_buf, 1);
|
||||
} //end if g_buf_ble_response.cmd == CMD_DBN_MODIFY_PASS
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void unpack_pkg_set_cjq_param(uint8_t *pkg, uint8_t len)
|
||||
{
|
||||
uint8_t i = 4, k = 0;
|
||||
uint8_t tmp[7] = {0};
|
||||
k = pkg[i++];
|
||||
g_loop_cng_unit.sensitvity = k & 0x0F;
|
||||
g_loop_cng_unit.loopFreq_Level = k >> 4;
|
||||
g_loop_cng_unit.delay_time = pkg[i++];
|
||||
k = pkg[i++];
|
||||
g_loop_cng_unit.output_mode = k & 0x03;
|
||||
g_loop_cng_unit.loopSafe_Timeout = k >> 3;
|
||||
g_loop_cng_unit.exist_mode = pkg[i++];
|
||||
g_loop_cng_unit.direction_mode = pkg[i++];
|
||||
|
||||
g_function_mode = (g_loop_cng_unit.direction_mode >> 4) & 0x0F;
|
||||
|
||||
g_hold_time = g_loop_cng_unit.exist_mode * 30 * 20;
|
||||
|
||||
i = 0;
|
||||
tmp[i++] = g_loop_cng_unit.sensitvity;
|
||||
tmp[i++] = g_loop_cng_unit.delay_time;
|
||||
tmp[i++] = g_loop_cng_unit.output_mode;
|
||||
tmp[i++] = g_loop_cng_unit.direction_mode; //默认 0
|
||||
tmp[i++] = g_loop_cng_unit.loopFreq_Level;
|
||||
tmp[i++] = g_loop_cng_unit.loopSafe_Timeout;
|
||||
tmp[i++] = g_loop_cng_unit.exist_mode;
|
||||
|
||||
write_cfg_to_store(4, tmp, 7);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void usart_packet_processing_acs_loop(uint8_t flag)
|
||||
{
|
||||
static uint32_t _current_freq = 0;
|
||||
static uint32_t _last_freq = 0;
|
||||
|
||||
clear_ble_notify_buf(&g_tmp_report_buf);
|
||||
|
||||
uint8_t i = 0,j;
|
||||
uint32_t _loop_capvd = g_loop_acs_info.loop_capvd << 5;
|
||||
g_tmp_report_buf.flag = flag;
|
||||
|
||||
|
||||
g_loop_acs_info.condition = (flt_mgr.cnt_not_idle > 150) ? 15: (flt_mgr.cnt_not_idle / 10);
|
||||
if(loop1_FLAG_CUT){
|
||||
g_loop_acs_info.condition = 15;
|
||||
}
|
||||
g_tmp_report_buf.buf[i++] = SENS_LOOP_DYNAMIC;
|
||||
|
||||
g_tmp_report_buf.buf[i++] = (g_loop_acs_info.loop_num << 6) | (g_freq_level << 4) | (g_loop_acs_info.condition & 0x0F);
|
||||
g_tmp_report_buf.buf[i++] = (g_loop_acs_info.relay2_state << 6) | (g_loop_acs_info.relay2_cng << 4) | (g_loop_acs_info.relay1_state << 2) | (g_loop_acs_info.relay1_cng & 0x3);
|
||||
g_tmp_report_buf.buf[i++] = (loop1_FLAG_CUT << 7) | (g_loop_acs_info.car_state << 4) | (g_loop_acs_info.direction & 0x0F);
|
||||
|
||||
g_freq_tmp = (float)(g_sys_freq )/((float)(_loop_capvd)/((float)(loop1_LPCNT))); // ?? ???????
|
||||
|
||||
// why + 360? balance value ,补偿,经验值,可以根据示波器比较再进行调整
|
||||
_current_freq = (uint32_t)(g_freq_tmp) + 360 ;// * 32);
|
||||
// if(flag)
|
||||
{
|
||||
g_loop_acs_info.frequent = _current_freq;
|
||||
_last_freq = _current_freq;
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// if(_current_freq > _last_freq)
|
||||
// {
|
||||
// if(_current_freq - _last_freq > 30)
|
||||
// {
|
||||
// //稳定显示,过滤低数值的变动
|
||||
// g_loop_acs_info.frequent = _current_freq;
|
||||
// _last_freq = _current_freq;
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if(_last_freq - _current_freq > 30)
|
||||
// {
|
||||
// // 稳定显示,过滤低数值的变动
|
||||
// g_loop_acs_info.frequent = _current_freq;
|
||||
// _last_freq = _current_freq;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// g_tmp_report_buf.buf[i++] = (uint8_t)flt_mgr.init_freq;
|
||||
// g_tmp_report_buf.buf[i++] = (flt_mgr.init_freq >> 8) % 0x100;
|
||||
// g_tmp_report_buf.buf[i++] = (flt_mgr.init_freq >> 16) % 0x100;
|
||||
|
||||
if(g_loop_acs_info.flag_change){
|
||||
g_loop_acs_info.flag_change = 0;
|
||||
}
|
||||
g_tmp_report_buf.buf[i++] = (g_loop_power_up_state == 0) ? 1 : ((uint8_t)g_loop_cut_amount);
|
||||
g_tmp_report_buf.buf[i++] = (g_loop_power_up_state == 0) ? 0 : ((g_loop_cut_amount >> 8) % 0x100);
|
||||
g_tmp_report_buf.buf[i++] = (g_loop_power_up_state == 0) ? 0 : ((g_loop_cut_amount >> 16) % 0x100);
|
||||
|
||||
g_tmp_report_buf.buf[i++] = (uint8_t)g_loop_acs_info.frequent;
|
||||
g_tmp_report_buf.buf[i++] = (g_loop_acs_info.frequent >> 8) % 0x100;
|
||||
g_tmp_report_buf.buf[i++] = (g_loop_acs_info.frequent >> 16) % 0x100;
|
||||
|
||||
g_tmp_report_buf.buf[i++] = (uint8_t)g_loop_acs_info.variation;
|
||||
g_tmp_report_buf.buf[i++] = (g_loop_acs_info.variation >> 8) % 0x100;
|
||||
|
||||
|
||||
g_tmp_report_buf.len = i;
|
||||
|
||||
set_response_buf(&g_buf_ble_response, MAGIC_BYTE_DBN_DEFAULT, CMD_SUB_SENS_REPORT, g_tmp_report_buf.buf, g_tmp_report_buf.len);
|
||||
}
|
||||
|
||||
|
||||
void report_sens_acs(void)
|
||||
{
|
||||
uint8_t _ret = 0;
|
||||
|
||||
if(g_dbn_ble_state_acs_enable.enable)
|
||||
{
|
||||
// 上报线圈动态数据
|
||||
|
||||
|
||||
// switch(g_dbn_ble_state_acs_enable.sens_type)
|
||||
// {
|
||||
// //case SENS_LOOP_DYNAMIC:
|
||||
// default:
|
||||
// {
|
||||
// 线圈动态信息
|
||||
if(g_loop_acs_info.flag_event)
|
||||
{
|
||||
// if(g_loop_acs_info.report_counter >= 3)
|
||||
{
|
||||
// refresh_loop_acs_info();
|
||||
g_loop_acs_info.flag_event = 0;
|
||||
g_loop_acs_info.report_counter = 0;
|
||||
|
||||
// report
|
||||
usart_packet_processing_acs_loop(1);
|
||||
}
|
||||
}
|
||||
|
||||
if(g_loop_acs_info.report_counter >= 120)
|
||||
{
|
||||
// refresh_loop_acs_info();
|
||||
g_loop_acs_info.report_counter = 0;
|
||||
|
||||
// report
|
||||
usart_packet_processing_acs_loop(0);
|
||||
// response_bt_dat(usart_packet_processing_acs_loop(0));
|
||||
}
|
||||
|
||||
if(g_dbn_ble_state_acs_enable.timeout_min)
|
||||
{
|
||||
if(mstick() - g_dbn_ble_state_acs_enable.counter >= g_dbn_ble_state_acs_enable.timeout_counter)
|
||||
{
|
||||
g_dbn_ble_state_acs_enable.flag = 0;
|
||||
g_dbn_ble_state_acs_enable.enable = 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// } break;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void manage_dbn_ble_default(uint8_t *pkg, uint8_t len)
|
||||
{
|
||||
uint8_t _header_0 = pkg[1];
|
||||
uint8_t _header_0_high = 0;
|
||||
uint8_t _header_0_low = _header_0 % 0x10;
|
||||
uint8_t _len = pkg[2];
|
||||
uint8_t _cmd = pkg[3];
|
||||
uint8_t _tmp = 0;
|
||||
uint8_t i = 0, k = 0;
|
||||
|
||||
memset(tmp_ble_buf, 0, MAX_BLE_TMP_BUF_LEN);
|
||||
|
||||
switch(_cmd)
|
||||
{
|
||||
case CMD_DBN_GET_DEV_INFO:
|
||||
{
|
||||
i = set_dev_info_to_ready(tmp_ble_buf);
|
||||
|
||||
set_response_buf(&g_buf_ble_response, MAGIC_BYTE_DBN_DEFAULT, _cmd, tmp_ble_buf, i);
|
||||
|
||||
// printf("\nGet_dev_info\n");
|
||||
} break;
|
||||
case CMD_DBN_RESET_DEV:
|
||||
{
|
||||
//Restart Dev
|
||||
SYS_ResetExecute();
|
||||
} break;
|
||||
// case CMD_DBN_CHECK_PASS:
|
||||
// {
|
||||
// unpack_packs(pkg, len);
|
||||
// } break;
|
||||
case CMD_DBN_SET_CJQ_PARAM:
|
||||
{
|
||||
// PRINT("\nSet_Cjq_param\n");
|
||||
unpack_pkg_set_cjq_param(pkg, len);
|
||||
tmp_ble_buf[0] = 0;
|
||||
set_response_buf(&g_buf_ble_response, MAGIC_BYTE_DBN_DEFAULT, _cmd, tmp_ble_buf, 1);
|
||||
|
||||
para_store_init();
|
||||
} break;
|
||||
case CMD_DBN_GET_CJQ_PARAM:
|
||||
{
|
||||
i = 0;
|
||||
tmp_ble_buf[i++] = (g_freq_sens + 1) | (g_loop_cng_unit.loopFreq_Level << 4);
|
||||
tmp_ble_buf[i++] = g_loop_cng_unit.delay_time;
|
||||
tmp_ble_buf[i++] = g_loop_cng_unit.output_mode | (g_loop_cng_unit.loopSafe_Timeout << 3);
|
||||
tmp_ble_buf[i++] = g_loop_cng_unit.exist_mode;
|
||||
tmp_ble_buf[i++] = g_loop_sens_list.total << 4;
|
||||
tmp_ble_buf[i++] = (g_loop_power_up_state == 0) ? 1 : ((uint8_t)(g_loop_cut_amount));
|
||||
tmp_ble_buf[i++] = (uint8_t)(g_loop_cut_amount >> 8);
|
||||
tmp_ble_buf[i++] = g_function_mode;
|
||||
|
||||
set_response_buf(&g_buf_ble_response, MAGIC_BYTE_DBN_DEFAULT, _cmd, tmp_ble_buf, i);
|
||||
// PRINT("\nGet_Cjq_param\n");
|
||||
} break;
|
||||
// case CMD_DBN_LOOP_SAMPLE_PARAM:{
|
||||
// // 获取/设置 地感采样参数
|
||||
//// PRINT("SAMPLE_CNG: %02X\n", pkg[4]);
|
||||
// if(pkg[4] == 0){
|
||||
// // get param
|
||||
// i = 0;
|
||||
// tmp_ble_buf[i++] = 0x10;
|
||||
// tmp_ble_buf[i++] = g_loop_balance_planB.sample_cng.flag;
|
||||
// tmp_ble_buf[i++] = g_loop_balance_planB.sample_cng.max_amplitude;
|
||||
// tmp_ble_buf[i++] = (g_loop_balance_planB.sample_cng.max_amplitude >> 8) & 0xFF;
|
||||
// set_response_buf(&g_buf_ble_response, MAGIC_BYTE_DBN_DEFAULT, _cmd, tmp_ble_buf, i);
|
||||
// }
|
||||
// else {
|
||||
// // set param
|
||||
// i = 0;
|
||||
// k = 4;
|
||||
// tmp_ble_buf[i++] = 0x11;
|
||||
// tmp_ble_buf[i++] = pkg[k++];
|
||||
// tmp_ble_buf[i++] = pkg[k++];
|
||||
// tmp_ble_buf[i++] = pkg[k++];
|
||||
//
|
||||
// g_loop_balance_planB.sample_cng.flag = tmp_ble_buf[1];
|
||||
// g_loop_balance_planB.sample_cng.max_amplitude = tmp_ble_buf[2] | ((tmp_ble_buf[3] << 8 ) & 0xFF00);
|
||||
//
|
||||
// write_cfg_to_store(Addr_Loop_PlanB_Cng_Offset, &tmp_ble_buf[1], sizeof(Loop_Sample_Cng));
|
||||
//
|
||||
// set_response_buf(&g_buf_ble_response, MAGIC_BYTE_DBN_DEFAULT, _cmd, tmp_ble_buf, i);
|
||||
//
|
||||
// //TODO: 不整个设备复位,复位除了蓝牙的部分,即蓝牙正常,其他部分重新初始化
|
||||
// para_store_init();
|
||||
// }
|
||||
//
|
||||
// } break;
|
||||
// case CMD_DBN_LOOP_BALANCE_PARAM: {
|
||||
// // 获取/设置 漂移补偿参数
|
||||
//// PRINT("Balance_CNG: %02X\n", pkg[4]);
|
||||
// if(pkg[4] == 0){
|
||||
// // get param
|
||||
// i = 0;
|
||||
// tmp_ble_buf[i++] = 0x10;
|
||||
// tmp_ble_buf[i++] = g_loop_balance_planB.balance_ori_cng.flag;
|
||||
// tmp_ble_buf[i++] = g_loop_balance_planB.balance_ori_cng.max_cnt;
|
||||
// tmp_ble_buf[i++] = (g_loop_balance_planB.balance_ori_cng.max_cnt >> 8) & 0xFF;
|
||||
//
|
||||
// set_response_buf(&g_buf_ble_response, MAGIC_BYTE_DBN_DEFAULT, _cmd, tmp_ble_buf, i);
|
||||
// }
|
||||
// else{
|
||||
// // set param
|
||||
// i = 0;
|
||||
// k = 4;
|
||||
// tmp_ble_buf[i++] = 0x11;
|
||||
// tmp_ble_buf[i++] = pkg[k++];
|
||||
// tmp_ble_buf[i++] = pkg[k++];
|
||||
// tmp_ble_buf[i++] = pkg[k++];
|
||||
//
|
||||
// g_loop_balance_planB.balance_ori_cng.flag = tmp_ble_buf[1];
|
||||
// g_loop_balance_planB.balance_ori_cng.max_cnt = tmp_ble_buf[2] | ((tmp_ble_buf[3] << 8 ) & 0xFF00);
|
||||
//
|
||||
// write_cfg_to_store(Addr_Loop_PlanB_Cng_Offset + sizeof(Loop_Sample_Cng), &tmp_ble_buf[1], sizeof(Loop_Balance_Ori_Cng));
|
||||
//
|
||||
// set_response_buf(&g_buf_ble_response, MAGIC_BYTE_DBN_DEFAULT, _cmd, tmp_ble_buf, i);
|
||||
//
|
||||
// //TODO: 不整个设备复位,复位除了蓝牙的部分,即蓝牙正常,其他部分重新初始化
|
||||
// para_store_init();
|
||||
//
|
||||
// }
|
||||
//
|
||||
// } break;
|
||||
// case CMD_DBN_LOOP_RELEASE_PLANB: {
|
||||
// // 获取/设置 释放去抖动算法参数
|
||||
//// PRINT("Release2_CNG: %02X\n", pkg[4]);
|
||||
// if(pkg[4] == 0){
|
||||
// // get param
|
||||
// i = 0;
|
||||
// tmp_ble_buf[i++] = 0x10;
|
||||
// tmp_ble_buf[i++] = g_loop_balance_planB.release_ori_planB.flag_weight;
|
||||
// tmp_ble_buf[i++] = g_loop_balance_planB.release_ori_planB.max_amplitude;
|
||||
// tmp_ble_buf[i++] = (g_loop_balance_planB.release_ori_planB.max_amplitude >> 8) & 0xFF;
|
||||
// tmp_ble_buf[i++] = g_loop_balance_planB.release_ori_planB.timeout;
|
||||
// tmp_ble_buf[i++] = g_loop_balance_planB.release_change_rate.flag_weight;
|
||||
// tmp_ble_buf[i++] = g_loop_balance_planB.release_change_rate.rate_first;
|
||||
// tmp_ble_buf[i++] = g_loop_balance_planB.release_change_rate.rate_second;
|
||||
// tmp_ble_buf[i++] = g_loop_balance_planB.release_change_rate.mode;
|
||||
//
|
||||
// set_response_buf(&g_buf_ble_response, MAGIC_BYTE_DBN_DEFAULT, _cmd, tmp_ble_buf, i);
|
||||
// }
|
||||
// else{
|
||||
// // set param
|
||||
// i = 0; k = 0;
|
||||
// tmp_ble_buf[i++] = 0x11;
|
||||
// memcpy(&tmp_ble_buf[1], &pkg[4], 8);
|
||||
// i += 8;
|
||||
//
|
||||
// write_cfg_to_store(Addr_Loop_PlanB_Cng_Offset + sizeof(Loop_Sample_Cng) + sizeof(Loop_Balance_Ori_Cng), &tmp_ble_buf[1], 8);
|
||||
//
|
||||
// set_response_buf(&g_buf_ble_response, MAGIC_BYTE_DBN_DEFAULT, _cmd, tmp_ble_buf, i);
|
||||
//
|
||||
// //TODO: 不整个设备复位,复位除了蓝牙的部分,即蓝牙正常,其他部分重新初始化
|
||||
// para_store_init();
|
||||
// }
|
||||
// } break;
|
||||
case CMD_DBN_LOOP_SENS_LIST: {
|
||||
// PRINT("SENS_CNG: %02X\n", pkg[4]);
|
||||
memset(tmp_ble_buf, 0, MAX_BLE_TMP_BUF_LEN);
|
||||
if(pkg[4] == 0x00){
|
||||
// get param
|
||||
i = 0;
|
||||
tmp_ble_buf[i++] = 0x10;
|
||||
tmp_ble_buf[i++] = g_loop_sens_list.total;
|
||||
for(k = 0; k < g_loop_sens_list.total; k++){
|
||||
tmp_ble_buf[i++] = g_loop_sens_list.sens[k].sens_in;
|
||||
tmp_ble_buf[i++] = g_loop_sens_list.sens[k].sens_in >> 8;
|
||||
tmp_ble_buf[i++] = g_loop_sens_list.sens[k].sens_out;
|
||||
tmp_ble_buf[i++] = g_loop_sens_list.sens[k].sens_out >> 8;
|
||||
}
|
||||
set_response_buf(&g_buf_ble_response, MAGIC_BYTE_DBN_DEFAULT, _cmd, tmp_ble_buf, i);
|
||||
}
|
||||
else {
|
||||
// set param
|
||||
i = 0; k = 5;
|
||||
|
||||
tmp_ble_buf[i++] = 0x11;
|
||||
g_loop_sens_list.total = pkg[k];
|
||||
if(g_loop_sens_list.total > MAX_LOOP_SENS_AMOUNT){
|
||||
g_loop_sens_list.total = MAX_LOOP_SENS_AMOUNT;
|
||||
}
|
||||
k = 1 + g_loop_sens_list.total * 4;
|
||||
memcpy(&tmp_ble_buf[i], &pkg[5], k);
|
||||
i += k;
|
||||
|
||||
write_cfg_to_store(Addr_Loop_Sens_List_Offset, &tmp_ble_buf[1], (i - 1));
|
||||
DelayMs(10);
|
||||
|
||||
set_response_buf(&g_buf_ble_response, MAGIC_BYTE_DBN_DEFAULT, _cmd, tmp_ble_buf, i);
|
||||
write_cfg_to_store(Addr_Loop_Sens_List_Offset, &tmp_ble_buf[1], (i - 1));
|
||||
DelayMs(10);
|
||||
|
||||
//TODO: 不整个设备复位,复位除了蓝牙的部分,即蓝牙正常,其他部分重新初始化
|
||||
para_store_init();
|
||||
}
|
||||
} break;
|
||||
case CMD_DBN_SET_CJQ_FACTORY: {
|
||||
// 出厂初始化
|
||||
tmp_ble_buf[0] = 0;
|
||||
set_response_buf(&g_buf_ble_response, MAGIC_BYTE_DBN_DEFAULT, _cmd, tmp_ble_buf, 1);
|
||||
|
||||
set_factory_param();
|
||||
factory_dev();
|
||||
DelayMs(10);
|
||||
//TODO: 不整个设备复位,复位除了蓝牙的部分,即蓝牙正常,其他部分重新初始化
|
||||
para_store_init();
|
||||
} break;
|
||||
case CMD_SENS_ACS_ENABLE: {
|
||||
// 线圈动态
|
||||
g_dbn_ble_state_acs_enable.enable = pkg[5];
|
||||
|
||||
if(g_dbn_ble_state_acs_enable.enable){
|
||||
g_loop_acs_info.condition = 0;
|
||||
g_dbn_ble_state_acs_enable.interval = pkg[6] * 0x7F;
|
||||
g_dbn_ble_state_acs_enable.timeout_min = pkg[7];
|
||||
if(g_dbn_ble_state_acs_enable.timeout_min){
|
||||
g_dbn_ble_state_acs_enable.counter = mstick();
|
||||
g_dbn_ble_state_acs_enable.timeout_counter = g_dbn_ble_state_acs_enable.timeout_min * 60 * 100; // TODO: min --> ms
|
||||
}
|
||||
g_dbn_ble_state_acs_enable.flag = 1;
|
||||
}
|
||||
else{
|
||||
g_dbn_ble_state_acs_enable.flag = 0;
|
||||
}
|
||||
} break;
|
||||
default:
|
||||
{
|
||||
} break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void poll_dbn_ble(void)
|
||||
{
|
||||
uint8_t i = 0;
|
||||
uint8_t magic = 0;
|
||||
if(g_ble_rcv_buf.flag)
|
||||
{
|
||||
// if(g_flag_debug)
|
||||
// {
|
||||
// PRINT("profile ChangeCB CHAR1?..:%s, len:%d \n", g_ble_rcv_buf.buf, g_ble_rcv_buf.len);
|
||||
// for(i = 0; i < g_ble_rcv_buf.len; i++)
|
||||
// {
|
||||
// PRINT(" %02X", g_ble_rcv_buf.buf[i]);
|
||||
// }
|
||||
// PRINT("\n");
|
||||
// }
|
||||
magic = check_pkg(g_ble_rcv_buf.buf, g_ble_rcv_buf.len);
|
||||
// printf("_magic: %02X\n", magic);
|
||||
if(magic != 0)
|
||||
{
|
||||
// if(magic == MAGIC_BYTE_DBN_DEFAULT)
|
||||
{
|
||||
manage_dbn_ble_default(g_ble_rcv_buf.buf, g_ble_rcv_buf.len);
|
||||
}
|
||||
}
|
||||
|
||||
// memcpy(g_notify_buftemp.buf, g_ble_rcv_buf.buf, g_ble_rcv_buf.len);
|
||||
// g_notify_buftemp.len = g_ble_rcv_buf.len;
|
||||
// g_flag_notify_temp = 1;
|
||||
clear_ble_notify_buf(&g_ble_rcv_buf);
|
||||
}
|
||||
if(g_notify_buftemp.flag == 0)
|
||||
{
|
||||
report_sens_acs();
|
||||
g_flag_notify_temp = set_response_to_notify(&g_buf_ble_response, &g_notify_buftemp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* cmcng.h
|
||||
*
|
||||
* Created on: Aug 27, 2024
|
||||
* Author: Thinkpad
|
||||
*/
|
||||
|
||||
#ifndef INCLUDE_CMCNG_H_
|
||||
#define INCLUDE_CMCNG_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define PRODUCT_MODEL "DLD110S"
|
||||
#define FIRMWARE_VER "4.00"
|
||||
#define HARDWARE_VER "4.01"
|
||||
#define FIRMWARE_VER_MAIN 4
|
||||
#define FIRMWARE_VER_SUB 12
|
||||
#define HARDWARE_VER_MAIN 4
|
||||
#define HARDWARE_VER_SUB 1
|
||||
|
||||
#define FUNCTION_A 0x01 // 二次判断
|
||||
#define FUNCTION_B 0x02 // 二次判断增强条件判断
|
||||
#define FUNCTION_C 0x04 //
|
||||
#define FUNCTION_D 0x08 //
|
||||
|
||||
// 二阶变化量计算状态结构体
|
||||
typedef struct {
|
||||
int16_t delta_prev; // 上一次的一阶变化量
|
||||
int16_t delta2_flt; // 滤波后的二阶变化量
|
||||
} SecondOrderState;
|
||||
extern SecondOrderState second_order_state;
|
||||
#define SECOND_ORDER_FILTER_COEF 64 // 滤波系数(64/256=0.25)
|
||||
|
||||
// 一阶滤波管理全局状态
|
||||
typedef struct {
|
||||
uint8_t flag_not_idle;
|
||||
uint32_t counter_not_idle;
|
||||
uint8_t flag_init_value;
|
||||
uint32_t stable_init_value; // 开机稳定初始值
|
||||
uint8_t flag_5sec;
|
||||
uint16_t counter_5sec;
|
||||
uint32_t recent_5sec;
|
||||
// uint8_t flag_5min;
|
||||
// uint32_t counter_5min;
|
||||
// uint16_t recent_5min; // 最近5分钟的一阶滤波值
|
||||
// uint8_t flag_10min;
|
||||
// uint32_t counter_10min;
|
||||
// uint16_t recent_10min; // 最近10分钟的一阶滤波值
|
||||
// uint8_t flag_30min;
|
||||
// uint32_t counter_30min;
|
||||
// uint16_t recent_30min; // 最近半小时的一阶滤波值
|
||||
// uint8_t flag_60min;
|
||||
// uint32_t counter_60min;
|
||||
// uint16_t recent_60min; // 最近1小时的一阶滤波值
|
||||
uint32_t init_sum; // 初始化累加值
|
||||
uint16_t init_samples; // 初始化采样计数器
|
||||
uint8_t is_initialized; // 初始化完成标志
|
||||
uint32_t init_freq; // 初始频率
|
||||
|
||||
uint16_t cnt_sec_samples;
|
||||
uint32_t sum_sec_samples;
|
||||
uint16_t cnt_samples;
|
||||
uint32_t sum_samples;
|
||||
|
||||
uint8_t flag_flat_release;
|
||||
uint16_t cnt_flat_release;
|
||||
uint16_t max_cnt_flat_release;
|
||||
|
||||
uint32_t last_loop_Origin;
|
||||
uint8_t flag_loop_reconnect; // 线圈重连
|
||||
uint16_t cnt_loop_reconnect;
|
||||
uint8_t last_loop_vd_flag;
|
||||
|
||||
uint8_t flag_second_judge; // 进入第二轮判断;由于第一轮判定为有车状态超时了,那么进入第二轮判定,第二轮判定会默认当前无车开始
|
||||
|
||||
uint32_t second_loop_Origin;
|
||||
uint32_t second_loop_ORG_SUM; // for option use
|
||||
uint16_t second_loop_ORG_CNT;
|
||||
uint32_t second_loop_dlt_ORG;
|
||||
uint8_t second_loop_vd_flag;
|
||||
|
||||
// 二次判断增强条件
|
||||
uint32_t second_judge_enter_time; // 进入二次判断的时间戳(单位:5ms)
|
||||
uint16_t second_judge_min_time; // 二次判断最小时间限制(单位:5ms),默认10秒=2000
|
||||
uint16_t cnt_stable_to_idle; // 连续检测到恢复到空闲值的计数
|
||||
uint16_t stable_to_idle_threshold; // 恢复到空闲值的阈值次数
|
||||
|
||||
uint16_t cnt_not_idle;
|
||||
uint16_t cnt_idle;
|
||||
|
||||
uint16_t cnt_simple_release;
|
||||
uint16_t cnt_simple_busy;
|
||||
|
||||
|
||||
// 从无车到有车 从有车到无车
|
||||
// 频率的变化趋势: 频率变大 频率变小
|
||||
// 捕获值的变化趋势: 值变小 值变大
|
||||
// 电感量的变化趋势 值变小 值变大
|
||||
uint16_t cnt_release_Up; // 从有车到无车时,一阶变化量 正数,一阶变化量是新捕获值与上一次捕捉值的差,
|
||||
uint16_t cnt_release_Down; // 从有车到无车时,一阶变化量 负数,此时可能倒车?或者出车的过程中有其他更有影响的部件,如前轮和后轮部分
|
||||
uint16_t min_release_capvd; // 从有车到无车时,U字形 拐点处的 一阶滤波值
|
||||
} FltHistoryManager;
|
||||
extern FltHistoryManager flt_mgr ; // 初始化为0
|
||||
|
||||
// 初始化采样次数(例如100次)
|
||||
#define INIT_SAMPLE_COUNT 10 //40 // 200
|
||||
#define TMP_SAMPLE_COUNT 50
|
||||
|
||||
// 区间类型定义(绝对差值或百分比)
|
||||
typedef enum {
|
||||
RANGE_ABSOLUTE, // 绝对差值(如 ±50)
|
||||
RANGE_PERCENT // 百分比(如 ±10%)
|
||||
} RangeType;
|
||||
|
||||
// 阶段配置结构体(每个时间窗口的区间规则)
|
||||
typedef struct {
|
||||
uint32_t base_value; // 基准值(例如开机稳定值、最近5分钟值等)
|
||||
uint32_t lower;
|
||||
uint32_t upper;
|
||||
uint16_t range_size; // 区间大小(绝对值或百分比数值)
|
||||
RangeType range_type; // 区间类型(绝对或百分比)
|
||||
} StageRangeConfig;
|
||||
|
||||
// 全局阶段配置数组(示例:开机、5分钟、10分钟、30分钟、1小时)
|
||||
#define STAGE_COUNT 2
|
||||
#define STAGE_COUNT_SHORT 2
|
||||
extern StageRangeConfig stage_config[STAGE_COUNT];
|
||||
|
||||
|
||||
|
||||
extern uint16_t g_hold_time;
|
||||
extern char g_flag_debug;
|
||||
extern uint8_t g_dev_number[6];
|
||||
extern uint8_t MACAddr[6];
|
||||
|
||||
extern uint8_t g_loop_cut_last;
|
||||
extern uint32_t g_loop_cut_amount;
|
||||
extern uint8_t g_loop_power_up_state;
|
||||
|
||||
extern uint8_t g_function_mode;
|
||||
|
||||
uint32_t mstick(void);
|
||||
void reload_lower_upper(uint8_t sens_level);
|
||||
|
||||
#endif /* INCLUDE_CMCNG_H_ */
|
||||
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* dbn_ble_srv.h
|
||||
*
|
||||
* Created on: Aug 27, 2024
|
||||
* Author: Thinkpad
|
||||
*/
|
||||
|
||||
#ifndef INCLUDE_DBN_BLE_SRV_H_
|
||||
#define INCLUDE_DBN_BLE_SRV_H_
|
||||
|
||||
#include "CONFIG.h"
|
||||
#include <stdint.h>
|
||||
|
||||
/*
|
||||
* Magic | Header | Data | CheckByte
|
||||
* | Addr/Sub Len CMD | | Xor Sum
|
||||
* 1Byte | 1B 1B 1B | xx | 1B 1B
|
||||
*
|
||||
* * Len = len(CMD) + len(Data)
|
||||
*/
|
||||
#define MAGIC_BYTE_DBN_DEFAULT 0x8F
|
||||
#define MAGIC_BYTE_DBN_TRANSPARENT 0x7F // 用于 显示屏协议、地感协议、探头协议等
|
||||
|
||||
#define CMD_DBN_GET_DEV_INFO 0x10
|
||||
|
||||
#define CMD_DBN_CHECK_PASS 0x1C
|
||||
#define CMD_DBN_MODIFY_PASS 0x1D
|
||||
|
||||
|
||||
#define CMD_DBN_SET_FACTORY 0x1E
|
||||
#define CMD_DBN_RESET_DEV 0x1F
|
||||
|
||||
#define CMD_DBN_SET_NOTIFY 0x20
|
||||
#define CMD_DBN_SET_NOTIFY_LOOP 0x21
|
||||
#define CMD_DBN_SET_SUB_CODE 0x22 //使能 子功能
|
||||
#define CMD_DBN_SET_CJQ_PARAM 0x23 // 设置 车检器参数
|
||||
#define CMD_DBN_GET_CJQ_PARAM 0x24 // 读取 车检器参数
|
||||
|
||||
#define CMD_DBN_DEV_RESET 0x6D
|
||||
|
||||
#define CMD_DBN_LOOP_SAMPLE_PARAM 0x87
|
||||
#define CMD_DBN_LOOP_BALANCE_PARAM 0x88
|
||||
#define CMD_DBN_LOOP_RELEASE_PLANB 0x89
|
||||
#define CMD_DBN_LOOP_SENS_LIST 0x8A
|
||||
#define CMD_DBN_SET_CJQ_FACTORY 0x92
|
||||
|
||||
|
||||
#define CMD_SUB_SENS_REPORT 0xC0 //设备主动上报传感信息
|
||||
// #define CMD_REQUIRE_DEV_MAC_ADDR 0xC1
|
||||
// #define CMD_CHANGE_DEV_ADDR_BY_MAC 0xC2
|
||||
// #define CMD_SET_LED 0xC3
|
||||
// #define CMD_SET_RELAY 0xC4
|
||||
#define CMD_SENS_ACS_ENABLE 0xC5 // 设备主动上报 使能
|
||||
|
||||
|
||||
|
||||
|
||||
#define MAX_BLE_DAT_RESPONSE_LEN (BLE_BUFF_MAX_LEN - 4) // 14 //返回 的所有字节数不能超过20个字节,除去 magic、header和ckb校验字节,剩下数据的字节数为14
|
||||
#define MAX_BLE_Notify_Buf_LEN BLE_BUFF_MAX_LEN //24
|
||||
#define MAX_BLE_BUF_LEN BLE_BUFF_MAX_LEN //128
|
||||
#define MAX_BLE_TMP_BUF_LEN BLE_BUFF_MAX_LEN
|
||||
|
||||
typedef struct _BLE_Notify_Buf_
|
||||
{
|
||||
uint8_t flag; //0 idle, 1 buf ready
|
||||
uint8_t len;
|
||||
uint8_t buf[MAX_BLE_Notify_Buf_LEN];
|
||||
}BLE_Notify_Buf;
|
||||
|
||||
typedef struct _BUF_DBN_BLE_
|
||||
{
|
||||
uint8_t flag;
|
||||
uint8_t magic;
|
||||
uint8_t cmd;
|
||||
uint8_t dat_len ;
|
||||
uint8_t dat_offset;
|
||||
uint8_t pkg_amount;
|
||||
uint8_t pkg_seq;
|
||||
uint8_t dat[MAX_BLE_BUF_LEN];
|
||||
} Buf_DBN_BLE;
|
||||
|
||||
extern Buf_DBN_BLE g_buf_ble_response;
|
||||
|
||||
extern BLE_Notify_Buf g_notify_buftemp;
|
||||
extern uint8_t g_flag_notify_temp;
|
||||
extern BLE_Notify_Buf g_ble_rcv_buf;
|
||||
|
||||
|
||||
extern uint16_t loop1_LPCNT;
|
||||
extern uint8_t g_freq_sens;
|
||||
extern uint8_t loop1_SensLevel;
|
||||
extern uint8_t g_freq_level;
|
||||
extern uint32_t g_sys_freq;
|
||||
extern float g_freq_tmp;
|
||||
|
||||
|
||||
|
||||
void clear_ble_notify_buf(BLE_Notify_Buf * buf);
|
||||
|
||||
void poll_dbn_ble(void);
|
||||
void report_sens_acs(void);
|
||||
|
||||
void set_factory_param(void);
|
||||
void factory_dev(void);
|
||||
void para_store_init(void);
|
||||
|
||||
|
||||
#endif /* INCLUDE_DBN_BLE_SRV_H_ */
|
||||
@@ -0,0 +1,67 @@
|
||||
/********************************** (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
|
||||
*/
|
||||
#include "dbn_ble_srv.h"
|
||||
|
||||
/*********************************************************************
|
||||
* 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
|
||||
|
||||
/*********************************************************************
|
||||
* MACROS
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t connHandle; // Connection handle of current connection
|
||||
uint16_t connInterval;
|
||||
uint16_t connSlaveLatency;
|
||||
uint16_t connTimeout;
|
||||
} peripheralConnItem_t;
|
||||
|
||||
/*********************************************************************
|
||||
* FUNCTIONS
|
||||
*/
|
||||
|
||||
/*
|
||||
* Task Initialization for the BLE Application
|
||||
*/
|
||||
extern void Peripheral_Init(void);
|
||||
|
||||
/*
|
||||
* Task Event Processor for the BLE Application
|
||||
*/
|
||||
extern uint16_t Peripheral_ProcessEvent(uint8_t task_id, uint16_t events);
|
||||
|
||||
/*********************************************************************
|
||||
*********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,187 @@
|
||||
/*
|
||||
* storage.h
|
||||
*
|
||||
* Created on: Aug 27, 2024
|
||||
* Author: Thinkpad
|
||||
*/
|
||||
|
||||
#ifndef INCLUDE_STORAGE_H_
|
||||
#define INCLUDE_STORAGE_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
// #define Addr_Loop_PlanB_Cng_Offset 0x10
|
||||
// #define Addr_Flag_Sample_In 0x10
|
||||
// #define Addr_Sample_Max_Amplitude 0x11
|
||||
// #define Addr_Flag_Balance_Ori_In 0x13
|
||||
// #define Addr_Balance_Ori_In_Max_Cnt 0x14
|
||||
// #define Addr_Flag_Release_Ori_PlanB 0x16
|
||||
// #define Addr_Release_Ori_PlanB_TimeOut 0x17
|
||||
// #define Addr_Release_Ori_PlanB_Weight 0x18
|
||||
// #define Addr_Release_Ori_Amplitude 0x19
|
||||
// #define Addr_Flag_Release_Rate 0x1B
|
||||
// #define Addr_Release_Rate_First 0x1C
|
||||
// #define Addr_Release_Rate_Second 0x1D
|
||||
// #define Addr_Release_Rate_Weight 0x1E
|
||||
// #define Addr_Release_Rate_Mode 0x1F
|
||||
|
||||
#define Addr_Loop_Sens_List_Offset 0x20
|
||||
|
||||
#define Addr_Sens_Array_In 0x20
|
||||
#define Addr_Sens_Array_Out 0x30
|
||||
|
||||
|
||||
#define MAX_LOOP_SENS_AMOUNT 3 // 4 // 5
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
typedef struct _Loop_Sample_CNG_
|
||||
{
|
||||
uint8_t flag;
|
||||
uint16_t max_amplitude; // 最大幅值
|
||||
}Loop_Sample_Cng;
|
||||
|
||||
typedef struct _Loop_Balance_Ori_CNG_
|
||||
{
|
||||
uint8_t flag;
|
||||
uint16_t max_cnt ; // 最大补偿次数
|
||||
}Loop_Balance_Ori_Cng; // 漂移补偿
|
||||
|
||||
typedef struct _Loop_Release_Ori_PlanB_
|
||||
{
|
||||
uint8_t flag_weight;
|
||||
uint16_t max_amplitude; //最大幅值
|
||||
uint8_t timeout; // 单位:分钟
|
||||
}Loop_Release_Ori_PlanB;
|
||||
|
||||
typedef struct _Loop_Release_Change_Rate_
|
||||
{
|
||||
uint8_t flag_weight;
|
||||
uint8_t rate_first;
|
||||
uint8_t rate_second;
|
||||
uint8_t mode;
|
||||
}Loop_Release_Change_Rate;
|
||||
|
||||
|
||||
typedef struct _Loop_Balance_PlanB_
|
||||
{
|
||||
Loop_Sample_Cng sample_cng;
|
||||
Loop_Balance_Ori_Cng balance_ori_cng;
|
||||
Loop_Release_Ori_PlanB release_ori_planB;
|
||||
Loop_Release_Change_Rate release_change_rate;
|
||||
}Loop_Balance_PlanB;
|
||||
|
||||
extern Loop_Balance_PlanB g_loop_balance_planB;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t sensitvity; // 高四位表示灵敏度的数量,低四位表示当前灵敏度的序号(从0开始)
|
||||
uint8_t delay_time;
|
||||
uint8_t output_mode;
|
||||
uint8_t direction_mode; // 方向判别模式,0 触发模式, 非0 表示方向判别模式
|
||||
uint8_t loopFreq_Level; // 高低频
|
||||
uint8_t loopSafe_Timeout; // 线圈安全模式, 0表示关闭,非0表示开启,以10秒为单位
|
||||
uint8_t exist_mode; // 0 永久存在,非0,表示有限存在的时间,单位为10秒
|
||||
}Loop_Cng_Unit;
|
||||
extern Loop_Cng_Unit g_loop_cng_unit;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t sens_in;
|
||||
uint16_t sens_out;
|
||||
}Loop_Single_Sens;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t total;
|
||||
Loop_Single_Sens sens[MAX_LOOP_SENS_AMOUNT];
|
||||
}Loop_Sens_List;
|
||||
extern Loop_Sens_List g_loop_sens_list;
|
||||
|
||||
|
||||
|
||||
typedef struct _DBN_BLE_STATE_
|
||||
{
|
||||
uint8_t flag; // if need to report
|
||||
uint8_t enable; // 是否使能
|
||||
uint8_t send_flag;
|
||||
uint8_t obj_amount;
|
||||
uint8_t cmd;
|
||||
uint8_t sens_type;
|
||||
uint8_t dat_len ;
|
||||
uint8_t dat_offset;
|
||||
uint8_t pkg_amount;
|
||||
uint8_t pkg_seq;
|
||||
uint16_t interval;
|
||||
uint32_t counter;
|
||||
uint8_t timeout_min; // minute
|
||||
uint32_t timeout_counter;
|
||||
} DBN_BLE_State;
|
||||
|
||||
extern DBN_BLE_State g_dbn_ble_state_acs_enable;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SENS_NONE = 0,
|
||||
SENS_SUB_INFO = 1, // 传感器设备信息
|
||||
SENS_OBJ_DYNAMIC = 2, // 动态目标类型
|
||||
SENS_SOUTPUT_STATUS = 3, // 当前开关量输出的状态
|
||||
SENS_DETAIL_CNG = 4, // 详细配置
|
||||
SENS_LOOP_DYNAMIC = 5, // 线圈动态信息
|
||||
SENS_OBJ_BackGround = 6, //
|
||||
SENS_OBJ_INSIDE = 7, //
|
||||
SENS_LOOP_TREND,
|
||||
SENS_OBJ_DYNAMIC_SIMPLE,
|
||||
SENS_OBJ_STATIC_XuJing, //10, 0x0A
|
||||
SENS_DOBULE_LOOP_ESTIMATE //0x0B, 线圈环境评估
|
||||
} SUB_SENS_TYPE; // 传感数据类型
|
||||
|
||||
|
||||
|
||||
typedef struct _LOOP_ACS_INFO
|
||||
{
|
||||
uint8_t flag_event;
|
||||
uint8_t loop_num;
|
||||
uint8_t freq_level;
|
||||
uint8_t sensity;
|
||||
uint8_t relay1_cng;
|
||||
uint8_t relay1_state;
|
||||
uint8_t relay2_cng;
|
||||
uint8_t relay2_state;
|
||||
uint8_t loop_state;
|
||||
uint8_t output_mode;
|
||||
uint8_t dir_mode;
|
||||
uint8_t delay;
|
||||
uint8_t car_state;
|
||||
uint8_t direction;
|
||||
uint8_t flag_loop_safe;
|
||||
uint32_t loop_safe_counter;
|
||||
uint8_t condition;
|
||||
uint8_t flag_change;
|
||||
uint32_t frequent;
|
||||
uint32_t loop_capvd;
|
||||
int16_t variation;
|
||||
uint32_t event_counter;
|
||||
uint32_t report_counter;
|
||||
} Loop_ACS_Info;
|
||||
extern Loop_ACS_Info g_loop_acs_info;
|
||||
|
||||
|
||||
#pragma pack()
|
||||
|
||||
|
||||
#define HOLD_TIME 5*1200
|
||||
#define LC_HOLD_TIME 4*1200 //时间4分钟
|
||||
#define IN_DELAY 10
|
||||
#define OUT_DELAY 39
|
||||
#define PLUSE_DELAY 10
|
||||
|
||||
|
||||
void write_cfg_to_store(uint32_t wAddr, uint8_t * p, uint32_t len);
|
||||
void read_cfg_from_store(uint32_t addr, uint8_t *p, uint32_t len);
|
||||
|
||||
|
||||
#endif /* INCLUDE_STORAGE_H_ */
|
||||
@@ -0,0 +1,784 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : peripheral.C
|
||||
* Author : WCH
|
||||
* Version : V1.0
|
||||
* Date : 2018/12/10
|
||||
* 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.
|
||||
*******************************************************************************/
|
||||
|
||||
/*********************************************************************
|
||||
* INCLUDES
|
||||
*/
|
||||
#include "CONFIG.h"
|
||||
#include "devinfoservice.h"
|
||||
#include "gattprofile.h"
|
||||
#include "peripheral.h"
|
||||
|
||||
/*********************************************************************
|
||||
* MACROS
|
||||
*/
|
||||
extern uint8_t g_flag_bt_state;
|
||||
/*********************************************************************
|
||||
* CONSTANTS
|
||||
*/
|
||||
|
||||
// How often to perform periodic event
|
||||
#define SBP_PERIODIC_EVT_PERIOD 200 //800 //1600
|
||||
|
||||
// How often to perform read rssi event
|
||||
#define SBP_READ_RSSI_EVT_PERIOD 3200
|
||||
|
||||
// Parameter update delay
|
||||
#define SBP_PARAM_UPDATE_DELAY 6400
|
||||
|
||||
// What is the advertising interval when device is discoverable (units of 625us, 80=50ms)
|
||||
#define DEFAULT_ADVERTISING_INTERVAL 80
|
||||
|
||||
// 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 6
|
||||
|
||||
// Maximum connection interval (units of 1.25ms, 100=125ms)
|
||||
#define DEFAULT_DESIRED_MAX_CONN_INTERVAL 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 100
|
||||
|
||||
// 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
|
||||
|
||||
// GAP - SCAN RSP data (max size = 31 bytes)
|
||||
static uint8_t scanRspData[] = {
|
||||
// complete name
|
||||
// 0x12, // length of this data
|
||||
0x08,
|
||||
GAP_ADTYPE_LOCAL_NAME_COMPLETE,
|
||||
// 'S',
|
||||
// 'i',
|
||||
// 'm',
|
||||
// 'p',
|
||||
// 'l',
|
||||
// 'e',
|
||||
// ' ',
|
||||
// 'P',
|
||||
// 'e',
|
||||
// 'r',
|
||||
// 'i',
|
||||
// 'p',
|
||||
// 'h',
|
||||
// 'e',
|
||||
// 'r',
|
||||
// 'a',
|
||||
// 'l',
|
||||
'D','L','D','1','1','0','S',
|
||||
// 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] = "DLD110S";// "Simple Peripheral";
|
||||
|
||||
// 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)
|
||||
};
|
||||
|
||||
// Simple GATT Profile Callbacks
|
||||
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);
|
||||
GAPRole_SetParameter(GAPROLE_SCAN_RSP_DATA, sizeof(scanRspData), scanRspData);
|
||||
GAPRole_SetParameter(GAPROLE_ADVERT_DATA, sizeof(advertData), advertData);
|
||||
GAPRole_SetParameter(GAPROLE_MIN_CONN_INTERVAL, sizeof(uint16_t), &desired_min_interval);
|
||||
GAPRole_SetParameter(GAPROLE_MAX_CONN_INTERVAL, sizeof(uint16_t), &desired_max_interval);
|
||||
}
|
||||
|
||||
// Set the GAP Characteristics
|
||||
GGS_SetParameter(GGS_DEVICE_NAME_ATT, GAP_DEVICE_NAME_LEN, attDeviceName);
|
||||
|
||||
{
|
||||
uint16_t advInt = DEFAULT_ADVERTISING_INTERVAL;
|
||||
|
||||
// Set advertising interval
|
||||
GAP_SetParamValue(TGAP_DISC_ADV_INT_MIN, advInt);
|
||||
GAP_SetParamValue(TGAP_DISC_ADV_INT_MAX, advInt);
|
||||
|
||||
// Enable scan req notify
|
||||
GAP_SetParamValue(TGAP_ADV_SCAN_REQ_NOTIFY, ENABLE);
|
||||
}
|
||||
|
||||
// Setup the GAP Bond Manager
|
||||
{
|
||||
uint32_t passkey = 0; // passkey "000000"
|
||||
uint8_t pairMode = GAPBOND_PAIRING_MODE_WAIT_FOR_REQ;
|
||||
uint8_t mitm = TRUE;
|
||||
uint8_t bonding = TRUE;
|
||||
uint8_t ioCap = GAPBOND_IO_CAP_DISPLAY_ONLY;
|
||||
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
|
||||
GATTServApp_AddService(GATT_ALL_SERVICES); // GATT attributes
|
||||
DevInfo_AddService(); // Device Information Service
|
||||
SimpleProfile_AddService(GATT_ALL_SERVICES); // Simple GATT Profile
|
||||
|
||||
// Setup the SimpleProfile Characteristic Values
|
||||
{
|
||||
uint8_t charValue1[SIMPLEPROFILE_CHAR1_LEN] = {1};
|
||||
uint8_t charValue2[SIMPLEPROFILE_CHAR2_LEN] = {2};
|
||||
uint8_t charValue3[SIMPLEPROFILE_CHAR3_LEN] = {3};
|
||||
uint8_t charValue4[SIMPLEPROFILE_CHAR4_LEN] = {4};
|
||||
// uint8_t charValue5[SIMPLEPROFILE_CHAR5_LEN] = {1, 2, 3, 4, 5};
|
||||
|
||||
SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR1, SIMPLEPROFILE_CHAR1_LEN, charValue1);
|
||||
SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR2, SIMPLEPROFILE_CHAR2_LEN, charValue2);
|
||||
SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR3, SIMPLEPROFILE_CHAR3_LEN, charValue3);
|
||||
SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR4, SIMPLEPROFILE_CHAR4_LEN, charValue4);
|
||||
// SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR5, SIMPLEPROFILE_CHAR5_LEN, charValue5);
|
||||
}
|
||||
|
||||
// Init Connection Item
|
||||
peripheralInitConnItem(&peripheralConnList);
|
||||
|
||||
// Register callback with SimpleGATTprofile
|
||||
SimpleProfile_RegisterAppCBs(&Peripheral_SimpleProfileCBs);
|
||||
|
||||
// Register receive scan request callback
|
||||
GAPRole_BroadcasterSetCB(&Broadcaster_BroadcasterCBs);
|
||||
|
||||
// Setup a delayed profile startup
|
||||
tmos_set_event(Peripheral_TaskID, SBP_START_DEVICE_EVT);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @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);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
// Restart timer
|
||||
if(SBP_PERIODIC_EVT_PERIOD)
|
||||
{
|
||||
tmos_start_task(Peripheral_TaskID, SBP_PERIODIC_EVT, SBP_PERIODIC_EVT_PERIOD);
|
||||
}
|
||||
// Perform periodic application task
|
||||
performPeriodicTask();
|
||||
return (events ^ SBP_PERIODIC_EVT);
|
||||
}
|
||||
|
||||
if(events & SBP_PARAM_UPDATE_EVT)
|
||||
{
|
||||
// Send connect param update request
|
||||
GAPRole_PeripheralConnParamUpdateReq(peripheralConnList.connHandle,
|
||||
DEFAULT_DESIRED_MIN_CONN_INTERVAL,
|
||||
DEFAULT_DESIRED_MAX_CONN_INTERVAL,
|
||||
DEFAULT_DESIRED_SLAVE_LATENCY,
|
||||
DEFAULT_DESIRED_CONN_TIMEOUT,
|
||||
Peripheral_TaskID);
|
||||
|
||||
return (events ^ SBP_PARAM_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);
|
||||
}
|
||||
|
||||
// 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("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);
|
||||
|
||||
// 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);
|
||||
|
||||
// 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("Update %x - Int %x \n", connHandle, connInterval);
|
||||
}
|
||||
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)
|
||||
{
|
||||
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);
|
||||
g_flag_bt_state = 0;
|
||||
// PRINT("Disconnected.. Reason:%x\n", pEvent->linkTerminate.reason);
|
||||
}
|
||||
// PRINT("Advertising..\n");
|
||||
break;
|
||||
|
||||
case GAPROLE_CONNECTED:
|
||||
if(pEvent->gap.opcode == GAP_LINK_ESTABLISHED_EVENT)
|
||||
{
|
||||
Peripheral_LinkEstablished(pEvent);
|
||||
}
|
||||
g_flag_bt_state = 1;
|
||||
// PRINT("Connected..\n");
|
||||
break;
|
||||
|
||||
case GAPROLE_CONNECTED_ADV:
|
||||
// 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);
|
||||
g_flag_bt_state = 0;
|
||||
// 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");
|
||||
g_flag_bt_state = 0;
|
||||
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
|
||||
*/
|
||||
static void performPeriodicTask(void)
|
||||
{
|
||||
// uint8_t notiData[SIMPLEPROFILE_CHAR4_LEN] = {0x88};
|
||||
// peripheralChar4Notify(notiData, SIMPLEPROFILE_CHAR4_LEN);
|
||||
|
||||
if(g_flag_notify_temp){
|
||||
g_flag_notify_temp = 0;
|
||||
peripheralChar4Notify(g_notify_buftemp.buf, g_notify_buftemp.len);
|
||||
clear_ble_notify_buf(&g_notify_buftemp);
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @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;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
void Jump_OTA(void);
|
||||
/*********************************************************************
|
||||
* @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)
|
||||
{
|
||||
switch(paramID)
|
||||
{
|
||||
case SIMPLEPROFILE_CHAR1:
|
||||
{
|
||||
// uint8_t newValue[SIMPLEPROFILE_CHAR1_LEN];
|
||||
// tmos_memcpy(newValue, pValue, len);
|
||||
// PRINT("profile ChangeCB CHAR1.. \n");
|
||||
g_ble_rcv_buf.len = len;
|
||||
tmos_memcpy(g_ble_rcv_buf.buf, pValue, len);
|
||||
g_ble_rcv_buf.flag = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
case SIMPLEPROFILE_CHAR3:
|
||||
{
|
||||
// uint8_t newValue[SIMPLEPROFILE_CHAR3_LEN];
|
||||
// tmos_memcpy(newValue, pValue, len);
|
||||
|
||||
g_ble_rcv_buf.len = len;
|
||||
tmos_memcpy(g_ble_rcv_buf.buf, pValue, len);
|
||||
// PRINT("profile ChangeCB CHAR3..len:%d,dat:%s.\n", len, g_ble_rcv_buf.buf);
|
||||
if(g_ble_rcv_buf.buf[0] == 0x3F && g_ble_rcv_buf.buf[1] == 0xF3 && g_ble_rcv_buf.buf[2] == 0x23 &&
|
||||
g_ble_rcv_buf.buf[3] == 'O' && g_ble_rcv_buf.buf[4] == 'T' && g_ble_rcv_buf.buf[5] == 'A'){
|
||||
// 0x4F, 0x54, 0x41
|
||||
// PRINT("jump OTA \n");
|
||||
mDelaymS(5);
|
||||
Jump_OTA();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
// should not reach here!
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* OTA 升级标志 */
|
||||
#define IMAGE_OTA_FLAG 0x03
|
||||
|
||||
/* 存放在DataFlash地址,不能占用蓝牙的位置 */
|
||||
#define OTA_DATAFLASH_ADD 0x00077000 - FLASH_ROM_MAX_SIZE
|
||||
|
||||
/* flash的数据临时存储 */
|
||||
__attribute__((aligned(8))) uint8_t block_buf[16];
|
||||
|
||||
/*********************************************************************
|
||||
* @fn Jump_OTA
|
||||
*
|
||||
* @brief 跳转OTA升级
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void Jump_OTA(void)
|
||||
{
|
||||
uint16_t i;
|
||||
uint32_t ver_flag;
|
||||
|
||||
/* 读取第一块 */
|
||||
EEPROM_READ(OTA_DATAFLASH_ADD, (uint32_t *)&block_buf[0], 4);
|
||||
|
||||
/* 擦除第一块 */
|
||||
EEPROM_ERASE(OTA_DATAFLASH_ADD, EEPROM_PAGE_SIZE);
|
||||
|
||||
/* 更新Image信息 */
|
||||
block_buf[0] = IMAGE_OTA_FLAG;
|
||||
|
||||
/* 编程DataFlash */
|
||||
EEPROM_WRITE(OTA_DATAFLASH_ADD, (uint32_t *)&block_buf[0], 4);
|
||||
|
||||
/* 软复位 */
|
||||
SYS_ResetExecute();
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*********************************************************************/
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* storage.c
|
||||
*
|
||||
* Created on: Aug 27, 2024
|
||||
* Author: Thinkpad
|
||||
*/
|
||||
|
||||
#include "storage.h"
|
||||
#include "CH59x_common.h"
|
||||
|
||||
|
||||
Loop_Balance_PlanB g_loop_balance_planB;
|
||||
Loop_Cng_Unit g_loop_cng_unit;
|
||||
Loop_Sens_List g_loop_sens_list;
|
||||
|
||||
|
||||
void write_cfg_to_store(uint32_t wAddr, uint8_t * p, uint32_t len)
|
||||
{
|
||||
EEPROM_WRITE(wAddr, p, len);
|
||||
}
|
||||
|
||||
|
||||
void read_cfg_from_store(uint32_t addr, uint8_t *p, uint32_t len)
|
||||
{
|
||||
EEPROM_READ(addr, p, len);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<launchConfiguration type="com.mounriver.debug.gdbjtag.openocd.launchConfigurationType">
|
||||
<booleanAttribute key="com.mounriver.debug.gdbjtag.openocd.doStartGdbServer" value="true"/>
|
||||
<booleanAttribute key="com.mounriver.debug.gdbjtag.openocd.doFirstReset" value="true"/>
|
||||
<booleanAttribute key="com.mounriver.debug.gdbjtag.openocd.enableSemihosting" value="false"/>
|
||||
<booleanAttribute key="com.mounriver.debug.gdbjtag.openocd.enableSemihostingNew" value="false"/>
|
||||
<booleanAttribute key="com.mounriver.debug.gdbjtag.openocd.doDebugInRam" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadSymbols" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForSymbols" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForSymbols" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadImage" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForImage" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForImage" value="false"/>
|
||||
<booleanAttribute key="com.mounriver.debug.gdbjtag.openocd.doContinue" value="true"/>
|
||||
<booleanAttribute key="com.mounriver.debug.gdbjtag.openocd.doSecondReset" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setStopAt" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="true"/>
|
||||
<booleanAttribute key="com.mounriver.debug.gdbjtag.openocd.doGdbServerAllocateConsole" value="true"/>
|
||||
<booleanAttribute key="com.mounriver.debug.gdbjtag.openocd.doGdbServerAllocateTelnetConsole" value="false"/>
|
||||
<booleanAttribute key="com.mounriver.debug.gdbjtag.openocd.doStartGdbCLient" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.UPDATE_THREADLIST_ON_SUSPEND" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setResume" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useRemoteTarget" value="true"/>
|
||||
<stringAttribute key="com.mounriver.debug.gdbjtag.openocd.gdbServerExecutable" value="${eclipse_home}toolchain/OpenOCD/bin/${openocd_executable}"/>
|
||||
<stringAttribute key="com.mounriver.debug.gdbjtag.openocd.gdbServerTclPortNumber" value="6666"/>
|
||||
<stringAttribute key="com.mounriver.debug.gdbjtag.openocd.gdbServerOther" value="-f "${eclipse_home}toolchain/OpenOCD/bin/wch-riscv.cfg""/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.ipAddress" value="localhost"/>
|
||||
<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="${eclipse_home}toolchain/RISC-V Embedded GCC/bin/riscv-none-embed-gdb.exe"/>
|
||||
<stringAttribute key="com.mounriver.debug.gdbjtag.openocd.gdbClientOtherOptions" value=""/>
|
||||
<stringAttribute key="com.mounriver.debug.gdbjtag.openocd.gdbClientOtherCommands" value="set mem inaccessible-by-default off
set architecture riscv:rv32
set remotetimeout unlimited"/>
|
||||
<stringAttribute key="com.mounriver.debug.gdbjtag.openocd.firstResetType" value="init"/>
|
||||
<stringAttribute key="com.mounriver.debug.gdbjtag.openocd.otherInitCommands" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsOffset" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsFileName" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageOffset" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageFileName" value=""/>
|
||||
<stringAttribute key="com.mounriver.debug.gdbjtag.openocd.secondResetType" value="halt"/>
|
||||
<stringAttribute key="com.mounriver.debug.gdbjtag.openocd.otherRunCommands" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.stopAt" value="handle_reset"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value=""/>
|
||||
<stringAttribute key="com.mounriver.debug.gdbjtag.svdPath"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="obj/DLD110S_Peripheral_28K.elf"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="DLD110S_Peripheral_28K"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDevice" value="GNU MCU OpenOCD"/>
|
||||
<stringAttribute key="com.mounriver.debug.gdbjtag.openocd.gdbServerConnectionAddress" value=""/>
|
||||
<stringAttribute key="com.mounriver.debug.gdbjtag.openocd.gdbServerLog" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
|
||||
<stringAttribute key="process_factory_id" value="org.eclipse.cdt.dsf.gdb.GdbProcessFactory"/>
|
||||
<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?>\r\n<memoryBlockExpressionList context="Context string"/>\r\n"/>
|
||||
<intAttribute key="com.mounriver.debug.gdbjtag.openocd.gdbServerGdbPortNumber" value="3333"/>
|
||||
<intAttribute key="com.mounriver.debug.gdbjtag.openocd.gdbServerTelnetPortNumber" value="4444"/>
|
||||
<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.portNumber" value="3333"/>
|
||||
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="DLD110S_Peripheral_28K"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="4"/>
|
||||
</listAttribute>
|
||||
</launchConfiguration>
|
||||
@@ -0,0 +1,462 @@
|
||||
{
|
||||
"version": "1.0",
|
||||
"hasAllParsed": true,
|
||||
"isNormalMRSProject": true,
|
||||
"basic": {
|
||||
"chipInfo": {
|
||||
"vendor": "WCH",
|
||||
"toolchain": "RISC-V",
|
||||
"series": "CH59X",
|
||||
"rtos": "NoneOS",
|
||||
"mcu": "CH591R",
|
||||
"description": "",
|
||||
"tempratureScope": "",
|
||||
"artifactType": "executable",
|
||||
"link": "WCH-Link",
|
||||
"peripheral_version": "1.0",
|
||||
"calibrateSupport": false,
|
||||
"calibrateCommand": ""
|
||||
},
|
||||
"linkedFolders": [
|
||||
{
|
||||
"name": "HAL",
|
||||
"location": "../HAL"
|
||||
},
|
||||
{
|
||||
"name": "LIB",
|
||||
"location": "../LIB"
|
||||
},
|
||||
{
|
||||
"name": "RVMSIS",
|
||||
"location": "../../SRC/RVMSIS"
|
||||
},
|
||||
{
|
||||
"name": "StdPeriphDriver",
|
||||
"location": "../../SRC/StdPeriphDriver"
|
||||
}
|
||||
],
|
||||
"removedResources": [
|
||||
{
|
||||
"parentLogicPath": "",
|
||||
"type": "file",
|
||||
"name": "*.wvproj"
|
||||
}
|
||||
],
|
||||
"projectName": "DLD110S_Peripheral_28K",
|
||||
"architecture": "RISC-V",
|
||||
"projectType": "c"
|
||||
},
|
||||
"buildConfig": {
|
||||
"configurations": [
|
||||
{
|
||||
"buildArtifact": {
|
||||
"artifact_name": "${ProjName}",
|
||||
"artifact_extension": "elf",
|
||||
"output_prefix": "",
|
||||
"artifact_type": "Executable"
|
||||
},
|
||||
"parallelizationNumber": "optimal",
|
||||
"stop_on_first_build_error": true,
|
||||
"pre_script": "",
|
||||
"pre_script_description": "",
|
||||
"post_script": "",
|
||||
"post_script_description": "",
|
||||
"excludeResources": [
|
||||
"${project}/HAL/Profile",
|
||||
"${project}/HAL/KEY.c",
|
||||
"${project}/HAL/LED.c",
|
||||
"${project}/StdPeriphDriver/CH59x_lcd.c",
|
||||
"${project}/StdPeriphDriver/CH59x_uart1.c",
|
||||
"${project}/StdPeriphDriver/CH59x_usbdev.c",
|
||||
"${project}/StdPeriphDriver/CH59x_usbhostClass.c",
|
||||
"${project}/StdPeriphDriver/CH59x_usbhostBase.c",
|
||||
"${project}/StdPeriphDriver/CH59x_pwm.c",
|
||||
"${project}/StdPeriphDriver/CH59x_spi0.c",
|
||||
"${project}/StdPeriphDriver/CH59x_timer2.c",
|
||||
"${project}/StdPeriphDriver/CH59x_timer3.c",
|
||||
"${project}/StdPeriphDriver/CH59x_uart2.c",
|
||||
"${project}/StdPeriphDriver/CH59x_uart3.c"
|
||||
],
|
||||
"optimization": {
|
||||
"level": "size",
|
||||
"message_length": true,
|
||||
"char_is_signed": true,
|
||||
"function_sections": true,
|
||||
"data_sections": true,
|
||||
"no_common_unitialized": true,
|
||||
"do_not_inline_functions": false,
|
||||
"assume_freestanding_environment": false,
|
||||
"disable_builtin": false,
|
||||
"single_precision_constants": false,
|
||||
"position_independent_code": false,
|
||||
"link_time_optimizer": false,
|
||||
"disable_loop_invariant_move": false,
|
||||
"optimize_unused_sections_declared_as_high_code": false,
|
||||
"code_generation_without_hardware_floating": false,
|
||||
"use_pipelines": false,
|
||||
"show_caret_indicating_the_column": false,
|
||||
"calling_convention_variant": false,
|
||||
"other_optimization_flags": ""
|
||||
},
|
||||
"warnings": {
|
||||
"check_syntax_only": false,
|
||||
"pedantic": false,
|
||||
"pedantic_warnings_as_errors": false,
|
||||
"inhibit_all_warnings": false,
|
||||
"warn_on_various_unused_elements": false,
|
||||
"warn_on_uninitialized_variables": false,
|
||||
"enable_all_common_warnings": false,
|
||||
"enable_extra_warnings": false,
|
||||
"warn_on_undeclared_global_function": false,
|
||||
"warn_on_implicit_conversions": false,
|
||||
"warn_if_pointer_arthmetic": false,
|
||||
"warn_if_padding_is_included": false,
|
||||
"warn_if_shadowed_variable": false,
|
||||
"warn_if_suspicious_logical_ops": false,
|
||||
"warn_if_struct_is_returned": false,
|
||||
"warn_if_floats_are_compared_as_equal": false,
|
||||
"generate_errors_instead_of_warnings": false,
|
||||
"other_warning_flags": ""
|
||||
},
|
||||
"debugging": {
|
||||
"debug_level": "default",
|
||||
"debug_format": "default",
|
||||
"generate_prof_information": false,
|
||||
"generate_gprof_information": false,
|
||||
"other_debugging_flags": ""
|
||||
},
|
||||
"assembler": {
|
||||
"preprocessor": {
|
||||
"use_preprocessor": true,
|
||||
"do_not_search_system_directories": false,
|
||||
"preprocess_only": false,
|
||||
"defined_symbols": [],
|
||||
"undefined_symbols": []
|
||||
},
|
||||
"includes": {
|
||||
"include_paths": [],
|
||||
"include_system_paths": [],
|
||||
"include_files": []
|
||||
},
|
||||
"other_warning_flags": "",
|
||||
"miscellaneous": {
|
||||
"assembler_flags": [],
|
||||
"generate_assembler_listing": false,
|
||||
"save_temporary_files": false,
|
||||
"verbose": false,
|
||||
"other_assembler_flags": ""
|
||||
}
|
||||
},
|
||||
"ccompiler": {
|
||||
"preprocessor": {
|
||||
"do_not_search_system_directories": false,
|
||||
"preprocess_only": false,
|
||||
"defined_symbols": [
|
||||
"CH59xBLE_ROM=1",
|
||||
"LIB_FLASH_BASE_ADDRESSS=0x0000C000"
|
||||
],
|
||||
"undefined_symbols": []
|
||||
},
|
||||
"includes": {
|
||||
"include_paths": [
|
||||
"${project}/Startup",
|
||||
"${project}/APP/include",
|
||||
"${project}/Profile/include",
|
||||
"${project}/StdPeriphDriver/inc",
|
||||
"${project}/HAL/include",
|
||||
"${project}/Ld",
|
||||
"${project}/LIB",
|
||||
"${project}/RVMSIS"
|
||||
],
|
||||
"include_system_paths": [],
|
||||
"include_files": []
|
||||
},
|
||||
"optimization": {
|
||||
"language_standard": "gnu99",
|
||||
"other_optimization_flags": ""
|
||||
},
|
||||
"warnings": {
|
||||
"warn_if_a_global_function_has_no_prototype": false,
|
||||
"warn_if_a_function_has_no_arg_type": false,
|
||||
"warn_if_wrong_cast": false,
|
||||
"other_warning_flags": ""
|
||||
},
|
||||
"miscellaneous": {
|
||||
"generate_assembler_listing": false,
|
||||
"save_temporary_files": false,
|
||||
"verbose": false,
|
||||
"other_compiler_flags": ""
|
||||
}
|
||||
},
|
||||
"cppcompiler": {
|
||||
"preprocessor": {
|
||||
"do_not_search_system_directories": false,
|
||||
"do_not_search_system_cpp_directories": false,
|
||||
"preprocess_only": false,
|
||||
"defined_symbols": [],
|
||||
"undefined_symbols": []
|
||||
},
|
||||
"includes": {
|
||||
"include_paths": [],
|
||||
"include_system_paths": [],
|
||||
"include_files": []
|
||||
},
|
||||
"optimization": {
|
||||
"cpp_language_standard": "gnucpp11",
|
||||
"abi_version": "0",
|
||||
"do_not_use_exceptions": false,
|
||||
"do_not_use_rtti": false,
|
||||
"do_not_use__cxa_atexit": false,
|
||||
"do_not_use_thread_safe_statics": false,
|
||||
"other_optimization_flags": ""
|
||||
},
|
||||
"warnings": {
|
||||
"warn_on_abi_violations": false,
|
||||
"warn_on_class_privacy": false,
|
||||
"warn_on_no_except_expressions": false,
|
||||
"warn_on_virtual_destructors": false,
|
||||
"warn_on_uncast_null": false,
|
||||
"warn_on_sign_promotion": false,
|
||||
"warn_about_effictive_cpp_violcations": false,
|
||||
"other_warning_flags": ""
|
||||
},
|
||||
"miscellaneous": {
|
||||
"generate_assembler_listing": false,
|
||||
"save_temporary_files": false,
|
||||
"verbose": false,
|
||||
"other_compiler_flags": ""
|
||||
}
|
||||
},
|
||||
"clinker": {
|
||||
"general": {
|
||||
"scriptFiles": [
|
||||
"${project}/Ld/Link.ld"
|
||||
],
|
||||
"do_not_use_standard_start_files": true,
|
||||
"do_not_use_default_libraries": false,
|
||||
"no_startup_or_default_libs": false,
|
||||
"remove_unused_sections": true,
|
||||
"print_removed_sections": false,
|
||||
"omit_all_symbol_information": false
|
||||
},
|
||||
"libraries": {
|
||||
"libraries": [
|
||||
"ISP592"
|
||||
],
|
||||
"library_search_path": [
|
||||
"../",
|
||||
"${project}/StdPeriphDriver"
|
||||
]
|
||||
},
|
||||
"miscellaneous": {
|
||||
"picolibc": "disabled",
|
||||
"linker_flags": [
|
||||
"--print-memory-usage"
|
||||
],
|
||||
"other_objects": [],
|
||||
"generate_map": "\"${BuildArtifactFileBaseName}.map\"",
|
||||
"cross_reference": false,
|
||||
"print_link_map": false,
|
||||
"use_newlib_nano": true,
|
||||
"use_float_with_nano_printf": false,
|
||||
"use_float_with_nano_scanf": false,
|
||||
"do_not_use_syscalls": true,
|
||||
"verbose": false,
|
||||
"use_wch_printffloat": false,
|
||||
"use_wch_printf": false,
|
||||
"use_iqmath": false,
|
||||
"other_linker_flags": ""
|
||||
}
|
||||
},
|
||||
"cpplinker": {
|
||||
"general": {
|
||||
"scriptFiles": [
|
||||
"${project}/Ld/Link.ld"
|
||||
],
|
||||
"do_not_use_standard_start_files": true,
|
||||
"do_not_use_default_libraries": false,
|
||||
"no_startup_or_default_libs": false,
|
||||
"remove_unused_sections": true,
|
||||
"print_removed_sections": false,
|
||||
"omit_all_symbol_information": false
|
||||
},
|
||||
"libraries": {
|
||||
"libraries": [
|
||||
"ISP592"
|
||||
],
|
||||
"library_search_path": [
|
||||
"../",
|
||||
"${project}/StdPeriphDriver"
|
||||
]
|
||||
},
|
||||
"miscellaneous": {
|
||||
"picolibc": "disabled",
|
||||
"linker_flags": [
|
||||
"--print-memory-usage"
|
||||
],
|
||||
"other_objects": [],
|
||||
"generate_map": "\"${BuildArtifactFileBaseName}.map\"",
|
||||
"cross_reference": false,
|
||||
"print_link_map": false,
|
||||
"use_newlib_nano": true,
|
||||
"use_float_with_nano_printf": false,
|
||||
"use_float_with_nano_scanf": false,
|
||||
"do_not_use_syscalls": true,
|
||||
"verbose": false,
|
||||
"use_wch_printffloat": false,
|
||||
"use_wch_printf": false,
|
||||
"use_iqmath": false,
|
||||
"other_linker_flags": ""
|
||||
}
|
||||
},
|
||||
"archiver": {
|
||||
"archiver_flags": "-r",
|
||||
"libOutputPrefix": "lib"
|
||||
},
|
||||
"createFlash": {
|
||||
"enabled": true,
|
||||
"outputFileFormat": "ihex",
|
||||
"copy_only_section_text": false,
|
||||
"copy_only_section_data": false,
|
||||
"copy_only_sections": [],
|
||||
"other_flags": ""
|
||||
},
|
||||
"createList": {
|
||||
"enabled": true,
|
||||
"display_source": true,
|
||||
"display_all_headers": true,
|
||||
"demangle_names": true,
|
||||
"display_debug_info": false,
|
||||
"disassemble": false,
|
||||
"display_file_headers": false,
|
||||
"display_line_numbers": true,
|
||||
"display_relocation_info": false,
|
||||
"display_symbols": false,
|
||||
"wide_lines": true,
|
||||
"other_flags": ""
|
||||
},
|
||||
"printSize": {
|
||||
"enabled": true,
|
||||
"size_format": "berkeley",
|
||||
"hex": false,
|
||||
"show_totals": false,
|
||||
"other_flags": ""
|
||||
},
|
||||
"configVariables": [],
|
||||
"riscvTargetProcessor": {
|
||||
"architecture": "rv32i",
|
||||
"multiply_extension": true,
|
||||
"atomic_extension": true,
|
||||
"floating_point": "none",
|
||||
"compressed_extension": true,
|
||||
"extra_compressed_extension": false,
|
||||
"bit_extension": false,
|
||||
"multiplication_subset_of_the_M_extension": false,
|
||||
"vector_cryptography_extensions": "",
|
||||
"integer_ABI": "ilp32",
|
||||
"floating_point_ABI": "none",
|
||||
"tuning": "default",
|
||||
"code_model": "any",
|
||||
"small_data_limit": 8,
|
||||
"align": "default",
|
||||
"save_restore": false,
|
||||
"other_target_flags": ""
|
||||
},
|
||||
"component_toolchain": "${WCH:Toolchain:GCC8}",
|
||||
"name": "obj"
|
||||
}
|
||||
]
|
||||
},
|
||||
"flashConfig": {
|
||||
"mcutype": "CH59x",
|
||||
"address": "0x00000000",
|
||||
"target_path": "",
|
||||
"clkSpeed": "High",
|
||||
"debug_interface_mode": "1-wire serial",
|
||||
"erase": false,
|
||||
"program": false,
|
||||
"verify": false,
|
||||
"reset": false,
|
||||
"sdiPrintf": false,
|
||||
"disablepowerout": false,
|
||||
"clearcodeflash": false,
|
||||
"disablecodeprotect": false,
|
||||
"exepath": "",
|
||||
"exearguments": ""
|
||||
},
|
||||
"debugConfigurations": {
|
||||
"openOCDCfg": {
|
||||
"useLocalOpenOCD": true,
|
||||
"executable": "${WCH:OpenOCD:default}",
|
||||
"gdbport": 3333,
|
||||
"telnetport": 4444,
|
||||
"tclport": 6666,
|
||||
"configOptions": [
|
||||
"-f \"${WCH:OpenOCD:default}/bin/wch-riscv.cfg\""
|
||||
],
|
||||
"host": "localhost",
|
||||
"port": 3333,
|
||||
"skipDownloadBeforeDebug": false,
|
||||
"enablePageEraser": false,
|
||||
"enableNoZeroWaitingAreaFlash": false
|
||||
},
|
||||
"gdbCfg": {
|
||||
"executable": "${WCH:Toolchain:GCC8}",
|
||||
"options": [],
|
||||
"commands": [
|
||||
"set mem inaccessible-by-default off",
|
||||
"set architecture riscv:rv32",
|
||||
"set remotetimeout unlimited"
|
||||
]
|
||||
},
|
||||
"startup": {
|
||||
"initCommands": {
|
||||
"initReset": true,
|
||||
"initResetType": "init",
|
||||
"additionalCommands": [],
|
||||
"armSemihosting": false,
|
||||
"armSemihosting_old": false
|
||||
},
|
||||
"loadedFiles": {
|
||||
"loadSymbols": true,
|
||||
"useProjBinaryForSymbols": true,
|
||||
"useFileForSymbols": false,
|
||||
"symbolFile": "",
|
||||
"symbolFileOffset": "",
|
||||
"loadImage": true,
|
||||
"useProjBinaryForImage": true,
|
||||
"useFileForImage": false,
|
||||
"executableFile": "",
|
||||
"executableFileOffset": ""
|
||||
},
|
||||
"runCommands": {
|
||||
"runReset": true,
|
||||
"runResetType": "halt",
|
||||
"additionalCommands": [],
|
||||
"setBreakAt": "handle_reset",
|
||||
"continue": true,
|
||||
"setBreak": true,
|
||||
"setProgramCounter": false,
|
||||
"setProgramCounterAddress": ""
|
||||
},
|
||||
"debugInRAM": false
|
||||
},
|
||||
"svdpath": null,
|
||||
"output": {
|
||||
"showDebugGDBTrace": true,
|
||||
"saveDebugOutputToFile": false,
|
||||
"showDebugOutputTimestamps": true
|
||||
},
|
||||
"reserve": {
|
||||
"PROGRAM_NAME": "obj/DLD110S_Peripheral_28K.elf",
|
||||
"PROJECT_ATTR": "DLD110S_Peripheral_28K",
|
||||
"PROJECT_BUILD_CONFIG_AUTO_ATTR": true,
|
||||
"PROJECT_BUILD_CONFIG_ID_ATTR": "",
|
||||
"ATTR_BUILD_BEFORE_LAUNCH_ATTR": 2,
|
||||
"GdbServerAllocateConsole": true,
|
||||
"GdbServerAllocateTelnetConsole": false,
|
||||
"StartGdbCLient": true,
|
||||
"UPDATE_THREADLIST_ON_SUSPEND": false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
ENTRY( _start )
|
||||
|
||||
__stack_size = 512;
|
||||
|
||||
PROVIDE( _stack_size = __stack_size );
|
||||
|
||||
MEMORY
|
||||
{
|
||||
FLASH (rx) : ORIGIN = 0x00001000, LENGTH = 28K
|
||||
RAM (xrw) : ORIGIN = 0x20002000, LENGTH = 18K
|
||||
}
|
||||
|
||||
PROVIDE( __global_pointer$ = 0x20002000 );
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.init :
|
||||
{
|
||||
_sinit = .;
|
||||
. = ALIGN(4);
|
||||
KEEP(*(SORT_NONE(.init)))
|
||||
KEEP(*(.ImageFlag))
|
||||
KEEP(*(.ImageFlag.*))
|
||||
. = ALIGN(4);
|
||||
_einit = .;
|
||||
} >FLASH AT>FLASH
|
||||
|
||||
/* .vector :
|
||||
{
|
||||
*(.vector);
|
||||
} >FLASH AT>FLASH */
|
||||
|
||||
.highcodelalign :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
PROVIDE(_highcode_lma = .);
|
||||
} >FLASH AT>FLASH
|
||||
|
||||
.highcode :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
PROVIDE(_highcode_vma_start = .);
|
||||
*(.vector);
|
||||
KEEP(*(SORT_NONE(.vector_handler)))
|
||||
*(.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
|
||||
|
||||
.dalign :
|
||||
{
|
||||
. = ORIGIN(RAM) + SIZEOF(.highcode);
|
||||
} >RAM 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);
|
||||
*(.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) - __stack_size :
|
||||
{
|
||||
PROVIDE( _heap_end = . );
|
||||
. = ALIGN(4);
|
||||
PROVIDE(_susrstack = . );
|
||||
. = . + __stack_size;
|
||||
PROVIDE( _eusrstack = .);
|
||||
} >RAM
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,589 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : devinfoservice.c
|
||||
* Author : WCH
|
||||
* Version : V1.0
|
||||
* Date : 2018/12/10
|
||||
* 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.
|
||||
*******************************************************************************/
|
||||
|
||||
/*********************************************************************
|
||||
* INCLUDES
|
||||
*/
|
||||
#include "CONFIG.h"
|
||||
#include "devinfoservice.h"
|
||||
|
||||
/*********************************************************************
|
||||
* MACROS
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* CONSTANTS
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* TYPEDEFS
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* GLOBAL VARIABLES
|
||||
*/
|
||||
// Device information service
|
||||
const uint8_t devInfoServUUID[ATT_BT_UUID_SIZE] = {
|
||||
LO_UINT16(DEVINFO_SERV_UUID), HI_UINT16(DEVINFO_SERV_UUID)};
|
||||
|
||||
// System ID
|
||||
const uint8_t devInfoSystemIdUUID[ATT_BT_UUID_SIZE] = {
|
||||
LO_UINT16(SYSTEM_ID_UUID), HI_UINT16(SYSTEM_ID_UUID)};
|
||||
|
||||
// Model Number String
|
||||
const uint8_t devInfoModelNumberUUID[ATT_BT_UUID_SIZE] = {
|
||||
LO_UINT16(MODEL_NUMBER_UUID), HI_UINT16(MODEL_NUMBER_UUID)};
|
||||
|
||||
// Serial Number String
|
||||
const uint8_t devInfoSerialNumberUUID[ATT_BT_UUID_SIZE] = {
|
||||
LO_UINT16(SERIAL_NUMBER_UUID), HI_UINT16(SERIAL_NUMBER_UUID)};
|
||||
|
||||
// Firmware Revision String
|
||||
const uint8_t devInfoFirmwareRevUUID[ATT_BT_UUID_SIZE] = {
|
||||
LO_UINT16(FIRMWARE_REV_UUID), HI_UINT16(FIRMWARE_REV_UUID)};
|
||||
|
||||
// Hardware Revision String
|
||||
const uint8_t devInfoHardwareRevUUID[ATT_BT_UUID_SIZE] = {
|
||||
LO_UINT16(HARDWARE_REV_UUID), HI_UINT16(HARDWARE_REV_UUID)};
|
||||
|
||||
// Software Revision String
|
||||
const uint8_t devInfoSoftwareRevUUID[ATT_BT_UUID_SIZE] = {
|
||||
LO_UINT16(SOFTWARE_REV_UUID), HI_UINT16(SOFTWARE_REV_UUID)};
|
||||
|
||||
// Manufacturer Name String
|
||||
const uint8_t devInfoMfrNameUUID[ATT_BT_UUID_SIZE] = {
|
||||
LO_UINT16(MANUFACTURER_NAME_UUID), HI_UINT16(MANUFACTURER_NAME_UUID)};
|
||||
|
||||
// IEEE 11073-20601 Regulatory Certification Data List
|
||||
const uint8_t devInfo11073CertUUID[ATT_BT_UUID_SIZE] = {
|
||||
LO_UINT16(IEEE_11073_CERT_DATA_UUID), HI_UINT16(IEEE_11073_CERT_DATA_UUID)};
|
||||
|
||||
// PnP ID
|
||||
const uint8_t devInfoPnpIdUUID[ATT_BT_UUID_SIZE] = {
|
||||
LO_UINT16(PNP_ID_UUID), HI_UINT16(PNP_ID_UUID)};
|
||||
|
||||
/*********************************************************************
|
||||
* EXTERNAL VARIABLES
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* EXTERNAL FUNCTIONS
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* LOCAL VARIABLES
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* Profile Attributes - variables
|
||||
*/
|
||||
|
||||
// Device Information Service attribute
|
||||
static const gattAttrType_t devInfoService = {ATT_BT_UUID_SIZE, devInfoServUUID};
|
||||
|
||||
// System ID characteristic
|
||||
static uint8_t devInfoSystemIdProps = GATT_PROP_READ;
|
||||
static uint8_t devInfoSystemId[DEVINFO_SYSTEM_ID_LEN] = {0, 0, 0, 0, 0, 0, 0, 0};
|
||||
|
||||
// Model Number String characteristic
|
||||
static uint8_t devInfoModelNumberProps = GATT_PROP_READ;
|
||||
static const uint8_t devInfoModelNumber[] = "Model Number";
|
||||
|
||||
// Serial Number String characteristic
|
||||
static uint8_t devInfoSerialNumberProps = GATT_PROP_READ;
|
||||
static const uint8_t devInfoSerialNumber[] = "Serial Number";
|
||||
|
||||
// Firmware Revision String characteristic
|
||||
static uint8_t devInfoFirmwareRevProps = GATT_PROP_READ;
|
||||
static const uint8_t devInfoFirmwareRev[] = "Firmware Revision";
|
||||
|
||||
// Hardware Revision String characteristic
|
||||
static uint8_t devInfoHardwareRevProps = GATT_PROP_READ;
|
||||
static const uint8_t devInfoHardwareRev[] = "Hardware Revision";
|
||||
|
||||
// Software Revision String characteristic
|
||||
static uint8_t devInfoSoftwareRevProps = GATT_PROP_READ;
|
||||
static const uint8_t devInfoSoftwareRev[] = "Software Revision";
|
||||
|
||||
// Manufacturer Name String characteristic
|
||||
static uint8_t devInfoMfrNameProps = GATT_PROP_READ;
|
||||
static const uint8_t devInfoMfrName[] = "Manufacturer Name";
|
||||
|
||||
// IEEE 11073-20601 Regulatory Certification Data List characteristic
|
||||
static uint8_t devInfo11073CertProps = GATT_PROP_READ;
|
||||
static const uint8_t devInfo11073Cert[] = {
|
||||
DEVINFO_11073_BODY_EXP, // authoritative body type
|
||||
0x00, // authoritative body structure type
|
||||
// authoritative body data follows below:
|
||||
'e', 'x', 'p', 'e', 'r', 'i', 'm', 'e', 'n', 't', 'a', 'l'};
|
||||
|
||||
// System ID characteristic
|
||||
static uint8_t devInfoPnpIdProps = GATT_PROP_READ;
|
||||
static uint8_t devInfoPnpId[DEVINFO_PNP_ID_LEN] = {
|
||||
1, // Vendor ID source (1=Bluetooth SIG)
|
||||
LO_UINT16(0x07D7), HI_UINT16(0x07D7), // Vendor ID (WCH)
|
||||
LO_UINT16(0x0000), HI_UINT16(0x0000), // Product ID (vendor-specific)
|
||||
LO_UINT16(0x0110), HI_UINT16(0x0110) // Product version (JJ.M.N)
|
||||
};
|
||||
|
||||
/*********************************************************************
|
||||
* Profile Attributes - Table
|
||||
*/
|
||||
|
||||
static gattAttribute_t devInfoAttrTbl[] = {
|
||||
// Device Information Service
|
||||
{
|
||||
{ATT_BT_UUID_SIZE, primaryServiceUUID}, /* type */
|
||||
GATT_PERMIT_READ, /* permissions */
|
||||
0, /* handle */
|
||||
(uint8_t *)&devInfoService /* pValue */
|
||||
},
|
||||
|
||||
// System ID Declaration
|
||||
{
|
||||
{ATT_BT_UUID_SIZE, characterUUID},
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
&devInfoSystemIdProps},
|
||||
|
||||
// System ID Value
|
||||
{
|
||||
{ATT_BT_UUID_SIZE, devInfoSystemIdUUID},
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
(uint8_t *)devInfoSystemId},
|
||||
|
||||
// Model Number String Declaration
|
||||
{
|
||||
{ATT_BT_UUID_SIZE, characterUUID},
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
&devInfoModelNumberProps},
|
||||
|
||||
// Model Number Value
|
||||
{
|
||||
{ATT_BT_UUID_SIZE, devInfoModelNumberUUID},
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
(uint8_t *)devInfoModelNumber},
|
||||
|
||||
// Serial Number String Declaration
|
||||
{
|
||||
{ATT_BT_UUID_SIZE, characterUUID},
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
&devInfoSerialNumberProps},
|
||||
|
||||
// Serial Number Value
|
||||
{
|
||||
{ATT_BT_UUID_SIZE, devInfoSerialNumberUUID},
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
(uint8_t *)devInfoSerialNumber},
|
||||
|
||||
// Firmware Revision String Declaration
|
||||
{
|
||||
{ATT_BT_UUID_SIZE, characterUUID},
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
&devInfoFirmwareRevProps},
|
||||
|
||||
// Firmware Revision Value
|
||||
{
|
||||
{ATT_BT_UUID_SIZE, devInfoFirmwareRevUUID},
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
(uint8_t *)devInfoFirmwareRev},
|
||||
|
||||
// Hardware Revision String Declaration
|
||||
{
|
||||
{ATT_BT_UUID_SIZE, characterUUID},
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
&devInfoHardwareRevProps},
|
||||
|
||||
// Hardware Revision Value
|
||||
{
|
||||
{ATT_BT_UUID_SIZE, devInfoHardwareRevUUID},
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
(uint8_t *)devInfoHardwareRev},
|
||||
|
||||
// Software Revision String Declaration
|
||||
{
|
||||
{ATT_BT_UUID_SIZE, characterUUID},
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
&devInfoSoftwareRevProps},
|
||||
|
||||
// Software Revision Value
|
||||
{
|
||||
{ATT_BT_UUID_SIZE, devInfoSoftwareRevUUID},
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
(uint8_t *)devInfoSoftwareRev},
|
||||
|
||||
// Manufacturer Name String Declaration
|
||||
{
|
||||
{ATT_BT_UUID_SIZE, characterUUID},
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
&devInfoMfrNameProps},
|
||||
|
||||
// Manufacturer Name Value
|
||||
{
|
||||
{ATT_BT_UUID_SIZE, devInfoMfrNameUUID},
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
(uint8_t *)devInfoMfrName},
|
||||
|
||||
// IEEE 11073-20601 Regulatory Certification Data List Declaration
|
||||
{
|
||||
{ATT_BT_UUID_SIZE, characterUUID},
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
&devInfo11073CertProps},
|
||||
|
||||
// IEEE 11073-20601 Regulatory Certification Data List Value
|
||||
{
|
||||
{ATT_BT_UUID_SIZE, devInfo11073CertUUID},
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
(uint8_t *)devInfo11073Cert},
|
||||
|
||||
// PnP ID Declaration
|
||||
{
|
||||
{ATT_BT_UUID_SIZE, characterUUID},
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
&devInfoPnpIdProps},
|
||||
|
||||
// PnP ID Value
|
||||
{
|
||||
{ATT_BT_UUID_SIZE, devInfoPnpIdUUID},
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
(uint8_t *)devInfoPnpId}
|
||||
};
|
||||
|
||||
/*********************************************************************
|
||||
* LOCAL FUNCTIONS
|
||||
*/
|
||||
static bStatus_t devInfo_ReadAttrCB(uint16_t connHandle, gattAttribute_t *pAttr,
|
||||
uint8_t *pValue, uint16_t *pLen, uint16_t offset, uint16_t maxLen, uint8_t method);
|
||||
|
||||
/*********************************************************************
|
||||
* PROFILE CALLBACKS
|
||||
*/
|
||||
// Device Info Service Callbacks
|
||||
gattServiceCBs_t devInfoCBs = {
|
||||
devInfo_ReadAttrCB, // Read callback function pointer
|
||||
NULL, // Write callback function pointer
|
||||
NULL // Authorization callback function pointer
|
||||
};
|
||||
|
||||
/*********************************************************************
|
||||
* NETWORK LAYER CALLBACKS
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* PUBLIC FUNCTIONS
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* @fn DevInfo_AddService
|
||||
*
|
||||
* @brief Initializes the Device Information service by registering
|
||||
* GATT attributes with the GATT server.
|
||||
*
|
||||
* @return Success or Failure
|
||||
*/
|
||||
bStatus_t DevInfo_AddService(void)
|
||||
{
|
||||
// Register GATT attribute list and CBs with GATT Server App
|
||||
return GATTServApp_RegisterService(devInfoAttrTbl,
|
||||
GATT_NUM_ATTRS(devInfoAttrTbl),
|
||||
GATT_MAX_ENCRYPT_KEY_SIZE,
|
||||
&devInfoCBs);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn DevInfo_SetParameter
|
||||
*
|
||||
* @brief Set a Device Information parameter.
|
||||
*
|
||||
* @param param - Profile parameter ID
|
||||
* @param len - length of data to write
|
||||
* @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 DevInfo_SetParameter(uint8_t param, uint8_t len, void *value)
|
||||
{
|
||||
bStatus_t ret = SUCCESS;
|
||||
|
||||
switch(param)
|
||||
{
|
||||
case DEVINFO_SYSTEM_ID:
|
||||
tmos_memcpy(devInfoSystemId, value, len);
|
||||
break;
|
||||
|
||||
default:
|
||||
ret = INVALIDPARAMETER;
|
||||
break;
|
||||
}
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn DevInfo_GetParameter
|
||||
*
|
||||
* @brief Get a Device Information parameter.
|
||||
*
|
||||
* @param param - Profile parameter ID
|
||||
* @param value - pointer to data to get. 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 DevInfo_GetParameter(uint8_t param, void *value)
|
||||
{
|
||||
bStatus_t ret = SUCCESS;
|
||||
|
||||
switch(param)
|
||||
{
|
||||
case DEVINFO_SYSTEM_ID:
|
||||
tmos_memcpy(value, devInfoSystemId, sizeof(devInfoSystemId));
|
||||
break;
|
||||
|
||||
case DEVINFO_MODEL_NUMBER:
|
||||
tmos_memcpy(value, devInfoModelNumber, sizeof(devInfoModelNumber));
|
||||
break;
|
||||
case DEVINFO_SERIAL_NUMBER:
|
||||
tmos_memcpy(value, devInfoSerialNumber, sizeof(devInfoSerialNumber));
|
||||
break;
|
||||
|
||||
case DEVINFO_FIRMWARE_REV:
|
||||
tmos_memcpy(value, devInfoFirmwareRev, sizeof(devInfoFirmwareRev));
|
||||
break;
|
||||
|
||||
case DEVINFO_HARDWARE_REV:
|
||||
tmos_memcpy(value, devInfoHardwareRev, sizeof(devInfoHardwareRev));
|
||||
break;
|
||||
|
||||
case DEVINFO_SOFTWARE_REV:
|
||||
tmos_memcpy(value, devInfoSoftwareRev, sizeof(devInfoSoftwareRev));
|
||||
break;
|
||||
|
||||
case DEVINFO_MANUFACTURER_NAME:
|
||||
tmos_memcpy(value, devInfoMfrName, sizeof(devInfoMfrName));
|
||||
break;
|
||||
|
||||
case DEVINFO_11073_CERT_DATA:
|
||||
tmos_memcpy(value, devInfo11073Cert, sizeof(devInfo11073Cert));
|
||||
break;
|
||||
|
||||
case DEVINFO_PNP_ID:
|
||||
tmos_memcpy(value, devInfoPnpId, sizeof(devInfoPnpId));
|
||||
break;
|
||||
|
||||
default:
|
||||
ret = INVALIDPARAMETER;
|
||||
break;
|
||||
}
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn devInfo_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 devInfo_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;
|
||||
uint16_t uuid = BUILD_UINT16(pAttr->type.uuid[0], pAttr->type.uuid[1]);
|
||||
|
||||
switch(uuid)
|
||||
{
|
||||
case SYSTEM_ID_UUID:
|
||||
// verify offset
|
||||
if(offset >= sizeof(devInfoSystemId))
|
||||
{
|
||||
status = ATT_ERR_INVALID_OFFSET;
|
||||
}
|
||||
else
|
||||
{
|
||||
// determine read length
|
||||
*pLen = MIN(maxLen, (sizeof(devInfoSystemId) - offset));
|
||||
|
||||
// copy data
|
||||
tmos_memcpy(pValue, &devInfoSystemId[offset], *pLen);
|
||||
}
|
||||
break;
|
||||
|
||||
case MODEL_NUMBER_UUID:
|
||||
// verify offset
|
||||
if(offset >= (sizeof(devInfoModelNumber) - 1))
|
||||
{
|
||||
status = ATT_ERR_INVALID_OFFSET;
|
||||
}
|
||||
else
|
||||
{
|
||||
// determine read length (exclude null terminating character)
|
||||
*pLen = MIN(maxLen, ((sizeof(devInfoModelNumber) - 1) - offset));
|
||||
|
||||
// copy data
|
||||
tmos_memcpy(pValue, &devInfoModelNumber[offset], *pLen);
|
||||
}
|
||||
break;
|
||||
|
||||
case SERIAL_NUMBER_UUID:
|
||||
// verify offset
|
||||
if(offset >= (sizeof(devInfoSerialNumber) - 1))
|
||||
{
|
||||
status = ATT_ERR_INVALID_OFFSET;
|
||||
}
|
||||
else
|
||||
{
|
||||
// determine read length (exclude null terminating character)
|
||||
*pLen = MIN(maxLen, ((sizeof(devInfoSerialNumber) - 1) - offset));
|
||||
|
||||
// copy data
|
||||
tmos_memcpy(pValue, &devInfoSerialNumber[offset], *pLen);
|
||||
}
|
||||
break;
|
||||
|
||||
case FIRMWARE_REV_UUID:
|
||||
// verify offset
|
||||
if(offset >= (sizeof(devInfoFirmwareRev) - 1))
|
||||
{
|
||||
status = ATT_ERR_INVALID_OFFSET;
|
||||
}
|
||||
else
|
||||
{
|
||||
// determine read length (exclude null terminating character)
|
||||
*pLen = MIN(maxLen, ((sizeof(devInfoFirmwareRev) - 1) - offset));
|
||||
|
||||
// copy data
|
||||
tmos_memcpy(pValue, &devInfoFirmwareRev[offset], *pLen);
|
||||
}
|
||||
break;
|
||||
|
||||
case HARDWARE_REV_UUID:
|
||||
// verify offset
|
||||
if(offset >= (sizeof(devInfoHardwareRev) - 1))
|
||||
{
|
||||
status = ATT_ERR_INVALID_OFFSET;
|
||||
}
|
||||
else
|
||||
{
|
||||
// determine read length (exclude null terminating character)
|
||||
*pLen = MIN(maxLen, ((sizeof(devInfoHardwareRev) - 1) - offset));
|
||||
|
||||
// copy data
|
||||
tmos_memcpy(pValue, &devInfoHardwareRev[offset], *pLen);
|
||||
}
|
||||
break;
|
||||
|
||||
case SOFTWARE_REV_UUID:
|
||||
// verify offset
|
||||
if(offset >= (sizeof(devInfoSoftwareRev) - 1))
|
||||
{
|
||||
status = ATT_ERR_INVALID_OFFSET;
|
||||
}
|
||||
else
|
||||
{
|
||||
// determine read length (exclude null terminating character)
|
||||
*pLen = MIN(maxLen, ((sizeof(devInfoSoftwareRev) - 1) - offset));
|
||||
|
||||
// copy data
|
||||
tmos_memcpy(pValue, &devInfoSoftwareRev[offset], *pLen);
|
||||
}
|
||||
break;
|
||||
|
||||
case MANUFACTURER_NAME_UUID:
|
||||
// verify offset
|
||||
if(offset >= (sizeof(devInfoMfrName) - 1))
|
||||
{
|
||||
status = ATT_ERR_INVALID_OFFSET;
|
||||
}
|
||||
else
|
||||
{
|
||||
// determine read length (exclude null terminating character)
|
||||
*pLen = MIN(maxLen, ((sizeof(devInfoMfrName) - 1) - offset));
|
||||
|
||||
// copy data
|
||||
tmos_memcpy(pValue, &devInfoMfrName[offset], *pLen);
|
||||
}
|
||||
break;
|
||||
|
||||
case IEEE_11073_CERT_DATA_UUID:
|
||||
// verify offset
|
||||
if(offset >= sizeof(devInfo11073Cert))
|
||||
{
|
||||
status = ATT_ERR_INVALID_OFFSET;
|
||||
}
|
||||
else
|
||||
{
|
||||
// determine read length
|
||||
*pLen = MIN(maxLen, (sizeof(devInfo11073Cert) - offset));
|
||||
|
||||
// copy data
|
||||
tmos_memcpy(pValue, &devInfo11073Cert[offset], *pLen);
|
||||
}
|
||||
break;
|
||||
|
||||
case PNP_ID_UUID:
|
||||
// verify offset
|
||||
if(offset >= sizeof(devInfoPnpId))
|
||||
{
|
||||
status = ATT_ERR_INVALID_OFFSET;
|
||||
}
|
||||
else
|
||||
{
|
||||
// determine read length
|
||||
*pLen = MIN(maxLen, (sizeof(devInfoPnpId) - offset));
|
||||
|
||||
// copy data
|
||||
tmos_memcpy(pValue, &devInfoPnpId[offset], *pLen);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
*pLen = 0;
|
||||
status = ATT_ERR_ATTR_NOT_FOUND;
|
||||
break;
|
||||
}
|
||||
|
||||
return (status);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*********************************************************************/
|
||||
@@ -0,0 +1,730 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : gattprofile.C
|
||||
* Author : WCH
|
||||
* Version : V1.0
|
||||
* Date : 2018/12/10
|
||||
* 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.
|
||||
*******************************************************************************/
|
||||
|
||||
/*********************************************************************
|
||||
* INCLUDES
|
||||
*/
|
||||
#include "CONFIG.h"
|
||||
#include "gattprofile.h"
|
||||
|
||||
/*********************************************************************
|
||||
* MACROS
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* CONSTANTS
|
||||
*/
|
||||
|
||||
// Position of simpleProfilechar4 value in attribute array
|
||||
#define SIMPLEPROFILE_CHAR4_VALUE_POS 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;
|
||||
|
||||
// Characteristic 2 Value
|
||||
static uint8_t simpleProfileChar2[SIMPLEPROFILE_CHAR2_LEN] = {0};
|
||||
|
||||
// Simple Profile Characteristic 2 User Description
|
||||
static uint8_t simpleProfileChar2UserDesp[] = "Characteristic 2\0";
|
||||
|
||||
// Simple Profile Characteristic 3 Properties
|
||||
static uint8_t simpleProfileChar3Props = GATT_PROP_WRITE;
|
||||
|
||||
// Characteristic 3 Value
|
||||
static uint8_t simpleProfileChar3[SIMPLEPROFILE_CHAR3_LEN] = {0};
|
||||
|
||||
// Simple Profile Characteristic 3 User Description
|
||||
static uint8_t simpleProfileChar3UserDesp[] = "Characteristic 3\0";
|
||||
|
||||
// Simple Profile Characteristic 4 Properties
|
||||
static uint8_t simpleProfileChar4Props = GATT_PROP_NOTIFY;
|
||||
|
||||
// Characteristic 4 Value
|
||||
static uint8_t simpleProfileChar4[SIMPLEPROFILE_CHAR4_LEN] = {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[PERIPHERAL_MAX_CONNECTION];
|
||||
|
||||
// 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},
|
||||
|
||||
// Characteristic Value 1
|
||||
{
|
||||
{ATT_BT_UUID_SIZE, simpleProfilechar1UUID},
|
||||
GATT_PERMIT_READ | GATT_PERMIT_WRITE,
|
||||
0,
|
||||
simpleProfileChar1},
|
||||
|
||||
// Characteristic 1 User Description
|
||||
{
|
||||
{ATT_BT_UUID_SIZE, charUserDescUUID},
|
||||
GATT_PERMIT_READ,
|
||||
0,
|
||||
simpleProfileChar1UserDesp},
|
||||
|
||||
// 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,
|
||||
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);
|
||||
|
||||
// Register with Link DB to receive link status change callback
|
||||
linkDB_Register(simpleProfile_HandleConnStatusCB);
|
||||
|
||||
if(services & SIMPLEPROFILE_SERVICE)
|
||||
{
|
||||
// Register GATT attribute list and CBs with GATT Server App
|
||||
status = GATTServApp_RegisterService(simpleProfileAttrTbl,
|
||||
GATT_NUM_ATTRS(simpleProfileAttrTbl),
|
||||
GATT_MAX_ENCRYPT_KEY_SIZE,
|
||||
&simpleProfileCBs);
|
||||
}
|
||||
|
||||
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
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
*********************************************************************/
|
||||
@@ -0,0 +1,109 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : devinfoservice.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 DEVINFOSERVICE_H
|
||||
#define DEVINFOSERVICE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
* INCLUDES
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* CONSTANTS
|
||||
*/
|
||||
|
||||
// Device Information Service Parameters
|
||||
#define DEVINFO_SYSTEM_ID 0
|
||||
#define DEVINFO_MODEL_NUMBER 1
|
||||
#define DEVINFO_SERIAL_NUMBER 2
|
||||
#define DEVINFO_FIRMWARE_REV 3
|
||||
#define DEVINFO_HARDWARE_REV 4
|
||||
#define DEVINFO_SOFTWARE_REV 5
|
||||
#define DEVINFO_MANUFACTURER_NAME 6
|
||||
#define DEVINFO_11073_CERT_DATA 7
|
||||
#define DEVINFO_PNP_ID 8
|
||||
|
||||
// IEEE 11073 authoritative body values
|
||||
#define DEVINFO_11073_BODY_EMPTY 0
|
||||
#define DEVINFO_11073_BODY_IEEE 1
|
||||
#define DEVINFO_11073_BODY_CONTINUA 2
|
||||
#define DEVINFO_11073_BODY_EXP 254
|
||||
|
||||
// System ID length
|
||||
#define DEVINFO_SYSTEM_ID_LEN 8
|
||||
|
||||
// PnP ID length
|
||||
#define DEVINFO_PNP_ID_LEN 7
|
||||
|
||||
/*********************************************************************
|
||||
* TYPEDEFS
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* MACROS
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* Profile Callbacks
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* API FUNCTIONS
|
||||
*/
|
||||
|
||||
/*
|
||||
* DevInfo_AddService- Initializes the Device Information service by registering
|
||||
* GATT attributes with the GATT server.
|
||||
*
|
||||
*/
|
||||
|
||||
extern bStatus_t DevInfo_AddService(void);
|
||||
|
||||
/*********************************************************************
|
||||
* @fn DevInfo_SetParameter
|
||||
*
|
||||
* @brief Set a Device Information 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 DevInfo_SetParameter(uint8_t param, uint8_t len, void *value);
|
||||
|
||||
/*
|
||||
* DevInfo_GetParameter - Get a Device Information 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 DevInfo_GetParameter(uint8_t param, void *value);
|
||||
|
||||
/*********************************************************************
|
||||
*********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DEVINFOSERVICE_H */
|
||||
@@ -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
|
||||
#define SIMPLEPROFILE_CHAR2_UUID 0xFFE2
|
||||
#define SIMPLEPROFILE_CHAR3_UUID 0xFFE3
|
||||
#define SIMPLEPROFILE_CHAR4_UUID 0xFFE4
|
||||
#define SIMPLEPROFILE_CHAR5_UUID 0xFFE5
|
||||
|
||||
// Simple Keys Profile Services bit fields
|
||||
#define SIMPLEPROFILE_SERVICE 0x00000001
|
||||
|
||||
// Length of characteristic in bytes ( Default MTU is 23 )
|
||||
#define SIMPLEPROFILE_CHAR1_LEN 64
|
||||
#define SIMPLEPROFILE_CHAR2_LEN 1
|
||||
#define SIMPLEPROFILE_CHAR3_LEN 8 //1
|
||||
#define SIMPLEPROFILE_CHAR4_LEN 32//20
|
||||
#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
|
||||
@@ -0,0 +1,187 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : startup_CH59x.s
|
||||
* Author : WCH
|
||||
* Version : V1.0.0
|
||||
* Date : 2021/02/25
|
||||
* 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
|
||||
.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 0xF5F9BDA9
|
||||
.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 SW_Handler /* SW Handler */
|
||||
.word 0
|
||||
/* External Interrupts */
|
||||
.word TMR0_IRQHandler /* 0: TMR0 */
|
||||
.word GPIOA_IRQHandler /* GPIOA */
|
||||
.word GPIOB_IRQHandler /* GPIOB */
|
||||
.word SPI0_IRQHandler /* SPI0 */
|
||||
.word BB_IRQHandler /* BLEB */
|
||||
.word LLE_IRQHandler /* BLEL */
|
||||
.word USB_IRQHandler /* USB */
|
||||
.word 0
|
||||
.word TMR1_IRQHandler /* TMR1 */
|
||||
.word TMR2_IRQHandler /* TMR2 */
|
||||
.word UART0_IRQHandler /* UART0 */
|
||||
.word UART1_IRQHandler /* UART1 */
|
||||
.word RTC_IRQHandler /* RTC */
|
||||
.word ADC_IRQHandler /* ADC */
|
||||
.word I2C_IRQHandler /* I2C */
|
||||
.word PWMX_IRQHandler /* PWMX */
|
||||
.word TMR3_IRQHandler /* TMR3 */
|
||||
.word UART2_IRQHandler /* UART2 */
|
||||
.word UART3_IRQHandler /* UART3 */
|
||||
.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 SW_Handler
|
||||
.weak TMR0_IRQHandler
|
||||
.weak GPIOA_IRQHandler
|
||||
.weak GPIOB_IRQHandler
|
||||
.weak SPI0_IRQHandler
|
||||
.weak BB_IRQHandler
|
||||
.weak LLE_IRQHandler
|
||||
.weak USB_IRQHandler
|
||||
.weak TMR1_IRQHandler
|
||||
.weak TMR2_IRQHandler
|
||||
.weak UART0_IRQHandler
|
||||
.weak UART1_IRQHandler
|
||||
.weak RTC_IRQHandler
|
||||
.weak ADC_IRQHandler
|
||||
.weak I2C_IRQHandler
|
||||
.weak PWMX_IRQHandler
|
||||
.weak TMR3_IRQHandler
|
||||
.weak UART2_IRQHandler
|
||||
.weak UART3_IRQHandler
|
||||
.weak WDOG_BAT_IRQHandler
|
||||
|
||||
NMI_Handler:
|
||||
HardFault_Handler:
|
||||
Ecall_M_Mode_Handler:
|
||||
Ecall_U_Mode_Handler:
|
||||
Break_Point_Handler:
|
||||
SysTick_Handler:
|
||||
SW_Handler:
|
||||
TMR0_IRQHandler:
|
||||
GPIOA_IRQHandler:
|
||||
GPIOB_IRQHandler:
|
||||
SPI0_IRQHandler:
|
||||
BB_IRQHandler:
|
||||
LLE_IRQHandler:
|
||||
USB_IRQHandler:
|
||||
TMR1_IRQHandler:
|
||||
TMR2_IRQHandler:
|
||||
UART0_IRQHandler:
|
||||
UART1_IRQHandler:
|
||||
RTC_IRQHandler:
|
||||
ADC_IRQHandler:
|
||||
I2C_IRQHandler:
|
||||
PWMX_IRQHandler:
|
||||
TMR3_IRQHandler:
|
||||
UART2_IRQHandler:
|
||||
UART3_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$
|
||||
.option pop
|
||||
1:
|
||||
la sp, _eusrstack
|
||||
|
||||
/* 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:
|
||||
/* 流水线控制位 & 动态预测控制位 */
|
||||
li t0, 0x1f
|
||||
csrw 0xbc0, t0
|
||||
/* 打开嵌套中断、硬件压栈功能 */
|
||||
li t0, 0x3
|
||||
csrw 0x804, t0
|
||||
|
||||
li t0, 0x1888
|
||||
csrw mstatus, t0
|
||||
la t0, _vector_base
|
||||
|
||||
/* 配置向量表模式为绝对地址模式 */
|
||||
ori t0, t0, 3
|
||||
csrw mtvec, t0
|
||||
|
||||
la t0, main
|
||||
csrw mepc, t0
|
||||
|
||||
j 0xC000
|
||||
|
||||
mret
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : KEY.c
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2022/01/18
|
||||
* Description :
|
||||
*********************************************************************************
|
||||
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
|
||||
/******************************************************************************/
|
||||
/* 头文件包含 */
|
||||
#include "HAL.h"
|
||||
|
||||
/**************************************************************************************************
|
||||
* GLOBAL VARIABLES
|
||||
**************************************************************************************************/
|
||||
|
||||
static uint8_t halKeySavedKeys; /* 保留按键最后的状态,用于查询是否有键值变化 */
|
||||
|
||||
/**************************************************************************************************
|
||||
* FUNCTIONS - Local
|
||||
**************************************************************************************************/
|
||||
static halKeyCBack_t pHalKeyProcessFunction; /* callback function */
|
||||
|
||||
/**************************************************************************************************
|
||||
* @fn HAL_KeyInit
|
||||
*
|
||||
* @brief Initilize Key Service
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return None
|
||||
**************************************************************************************************/
|
||||
void HAL_KeyInit(void)
|
||||
{
|
||||
/* Initialize previous key to 0 */
|
||||
halKeySavedKeys = 0;
|
||||
/* Initialize callback function */
|
||||
pHalKeyProcessFunction = NULL;
|
||||
KEY1_DIR;
|
||||
KEY1_PU;
|
||||
KEY2_DIR;
|
||||
KEY2_PU;
|
||||
}
|
||||
|
||||
/**************************************************************************************************
|
||||
* @fn HalKeyConfig
|
||||
*
|
||||
* @brief Configure the Key serivce
|
||||
*
|
||||
* @param cback - pointer to the CallBack function
|
||||
*
|
||||
* @return None
|
||||
**************************************************************************************************/
|
||||
void HalKeyConfig(halKeyCBack_t cback)
|
||||
{
|
||||
/* Register the callback fucntion */
|
||||
pHalKeyProcessFunction = cback;
|
||||
tmos_start_task(halTaskID, HAL_KEY_EVENT, HAL_KEY_POLLING_VALUE); /* Kick off polling */
|
||||
}
|
||||
|
||||
/**************************************************************************************************
|
||||
* @fn HalKeyRead
|
||||
*
|
||||
* @brief Read the current value of a key
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return keys - current keys status
|
||||
**************************************************************************************************/
|
||||
uint8_t HalKeyRead(void)
|
||||
{
|
||||
uint8_t keys = 0;
|
||||
|
||||
if(HAL_PUSH_BUTTON1())
|
||||
{ //读按键1
|
||||
keys |= HAL_KEY_SW_1;
|
||||
}
|
||||
if(HAL_PUSH_BUTTON2())
|
||||
{ //读按键1
|
||||
keys |= HAL_KEY_SW_2;
|
||||
}
|
||||
if(HAL_PUSH_BUTTON3())
|
||||
{ //读按键1
|
||||
keys |= HAL_KEY_SW_3;
|
||||
}
|
||||
if(HAL_PUSH_BUTTON4())
|
||||
{ //读按键1
|
||||
keys |= HAL_KEY_SW_4;
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
/**************************************************************************************************
|
||||
* @fn HAL_KeyPoll
|
||||
*
|
||||
* @brief Called by hal_driver to poll the keys
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return None
|
||||
**************************************************************************************************/
|
||||
void HAL_KeyPoll(void)
|
||||
{
|
||||
uint8_t keys = 0;
|
||||
if(HAL_PUSH_BUTTON1())
|
||||
{
|
||||
keys |= HAL_KEY_SW_1;
|
||||
}
|
||||
if(HAL_PUSH_BUTTON2())
|
||||
{
|
||||
keys |= HAL_KEY_SW_2;
|
||||
}
|
||||
if(HAL_PUSH_BUTTON3())
|
||||
{
|
||||
keys |= HAL_KEY_SW_3;
|
||||
}
|
||||
if(HAL_PUSH_BUTTON4())
|
||||
{
|
||||
keys |= HAL_KEY_SW_4;
|
||||
}
|
||||
if(keys == halKeySavedKeys)
|
||||
{ /* Exit - since no keys have changed */
|
||||
return;
|
||||
}
|
||||
halKeySavedKeys = keys; /* Store the current keys for comparation next time */
|
||||
/* Invoke Callback if new keys were depressed */
|
||||
if(keys && (pHalKeyProcessFunction))
|
||||
{
|
||||
(pHalKeyProcessFunction)(keys);
|
||||
}
|
||||
}
|
||||
|
||||
/******************************** endfile @ key ******************************/
|
||||
+361
@@ -0,0 +1,361 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : LED.c
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2022/01/18
|
||||
* Description :
|
||||
*********************************************************************************
|
||||
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
|
||||
/******************************************************************************/
|
||||
/* Í·Îļþ°üº¬ */
|
||||
#include "HAL.h"
|
||||
|
||||
/* LED control structure */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t mode; /* Operation mode */
|
||||
uint8_t todo; /* Blink cycles left */
|
||||
uint8_t onPct; /* On cycle percentage */
|
||||
uint16_t time; /* On/off cycle time (msec) */
|
||||
uint32_t next; /* Time for next change */
|
||||
} HalLedControl_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
HalLedControl_t HalLedControlTable[HAL_LED_DEFAULT_MAX_LEDS];
|
||||
uint8_t sleepActive;
|
||||
} HalLedStatus_t;
|
||||
|
||||
/***************************************************************************************************
|
||||
* GLOBAL VARIABLES
|
||||
***************************************************************************************************/
|
||||
static uint8_t HalLedState; // LED state at last set/clr/blink update
|
||||
|
||||
static uint8_t preBlinkState; // Original State before going to blink mode
|
||||
// bit 0, 1, 2, 3 represent led 0, 1, 2, 3
|
||||
static HalLedStatus_t HalLedStatusControl;
|
||||
|
||||
/***************************************************************************************************
|
||||
* LOCAL FUNCTION
|
||||
***************************************************************************************************/
|
||||
void HalLedOnOff(uint8_t leds, uint8_t mode);
|
||||
|
||||
/***************************************************************************************************
|
||||
* FUNCTIONS - API
|
||||
***************************************************************************************************/
|
||||
|
||||
/*********************************************************************
|
||||
* @fn HAL_LedInit
|
||||
*
|
||||
* @brief Initialize LED Service
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void HAL_LedInit(void)
|
||||
{
|
||||
/* Initialize all LEDs to OFF */
|
||||
LED1_DDR;
|
||||
HalLedSet(HAL_LED_ALL, HAL_LED_MODE_OFF);
|
||||
// just test
|
||||
HalLedBlink(HAL_LED_1, 10, 30, 4000);
|
||||
/* Initialize sleepActive to FALSE */
|
||||
HalLedStatusControl.sleepActive = FALSE;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn HalLedSet
|
||||
*
|
||||
* @brief Turn ON/OFF/TOGGLE given LEDs
|
||||
*
|
||||
* @param led - bit mask value of leds to be turned ON/OFF/TOGGLE
|
||||
* @param mode - BLINK, FLASH, TOGGLE, ON, OFF
|
||||
*
|
||||
* @return 0
|
||||
*/
|
||||
uint8_t HalLedSet(uint8_t leds, uint8_t mode)
|
||||
{
|
||||
uint8_t led;
|
||||
HalLedControl_t *sts;
|
||||
|
||||
switch(mode)
|
||||
{
|
||||
case HAL_LED_MODE_BLINK:
|
||||
{
|
||||
/* Default blink, 1 time, D% duty cycle */
|
||||
HalLedBlink(leds, 1, HAL_LED_DEFAULT_DUTY_CYCLE, HAL_LED_DEFAULT_FLASH_TIME);
|
||||
break;
|
||||
}
|
||||
|
||||
case HAL_LED_MODE_FLASH:
|
||||
{
|
||||
/* Default flash, N times, D% duty cycle */
|
||||
HalLedBlink(leds, HAL_LED_DEFAULT_FLASH_COUNT, HAL_LED_DEFAULT_DUTY_CYCLE, HAL_LED_DEFAULT_FLASH_TIME);
|
||||
break;
|
||||
}
|
||||
|
||||
case HAL_LED_MODE_ON:
|
||||
case HAL_LED_MODE_OFF:
|
||||
case HAL_LED_MODE_TOGGLE:
|
||||
{
|
||||
led = HAL_LED_1;
|
||||
leds &= HAL_LED_ALL;
|
||||
sts = HalLedStatusControl.HalLedControlTable;
|
||||
while(leds)
|
||||
{
|
||||
if(leds & led)
|
||||
{
|
||||
if(mode != HAL_LED_MODE_TOGGLE)
|
||||
{
|
||||
sts->mode = mode; /* ON or OFF */
|
||||
}
|
||||
else
|
||||
{
|
||||
sts->mode ^= HAL_LED_MODE_ON; /* Toggle */
|
||||
}
|
||||
HalLedOnOff(led, sts->mode);
|
||||
leds ^= led;
|
||||
}
|
||||
led <<= 1;
|
||||
sts++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn HalLedBlink
|
||||
*
|
||||
* @brief Blink the leds
|
||||
*
|
||||
* @param led - bit mask value of leds to be turned ON/OFF/TOGGLE
|
||||
* @param numBlinks - number of blinks
|
||||
* @param percent - the percentage in each period where the led will be on
|
||||
* @param period - length of each cycle in milliseconds
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void HalLedBlink(uint8_t leds, uint8_t numBlinks, uint8_t percent, uint16_t period)
|
||||
{
|
||||
uint8_t led;
|
||||
HalLedControl_t *sts;
|
||||
|
||||
if(leds && percent && period)
|
||||
{
|
||||
if(percent < 100)
|
||||
{
|
||||
led = HAL_LED_1;
|
||||
leds &= HAL_LED_ALL;
|
||||
sts = HalLedStatusControl.HalLedControlTable;
|
||||
while(leds)
|
||||
{
|
||||
if(leds & led)
|
||||
{
|
||||
/* Store the current state of the led before going to blinking */
|
||||
preBlinkState |= (led & HalLedState);
|
||||
sts->mode = HAL_LED_MODE_OFF; /* Stop previous blink */
|
||||
sts->time = period; /* Time for one on/off cycle */
|
||||
sts->onPct = percent; /* % of cycle LED is on */
|
||||
sts->todo = numBlinks; /* Number of blink cycles */
|
||||
if(!numBlinks)
|
||||
{
|
||||
sts->mode |= HAL_LED_MODE_FLASH; /* Continuous */
|
||||
}
|
||||
sts->next = TMOS_GetSystemClock(); /* Start now */
|
||||
sts->mode |= HAL_LED_MODE_BLINK; /* Enable blinking */
|
||||
leds ^= led;
|
||||
}
|
||||
led <<= 1;
|
||||
sts++;
|
||||
}
|
||||
tmos_start_task(halTaskID, LED_BLINK_EVENT, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
HalLedSet(leds, HAL_LED_MODE_ON); /* >= 100%, turn on */
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
HalLedSet(leds, HAL_LED_MODE_OFF); /* No on time, turn off */
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn HalLedUpdate
|
||||
*
|
||||
* @brief Update leds to work with blink
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void HalLedUpdate(void)
|
||||
{
|
||||
uint8_t led, pct, leds;
|
||||
uint16_t next, wait;
|
||||
uint32_t time;
|
||||
HalLedControl_t *sts;
|
||||
|
||||
next = 0;
|
||||
led = HAL_LED_1;
|
||||
leds = HAL_LED_ALL;
|
||||
sts = HalLedStatusControl.HalLedControlTable;
|
||||
|
||||
/* Check if sleep is active or not */
|
||||
if(!HalLedStatusControl.sleepActive)
|
||||
{
|
||||
while(leds)
|
||||
{
|
||||
if(leds & led)
|
||||
{
|
||||
if(sts->mode & HAL_LED_MODE_BLINK)
|
||||
{
|
||||
time = TMOS_GetSystemClock();
|
||||
if(time >= sts->next)
|
||||
{
|
||||
if(sts->mode & HAL_LED_MODE_ON)
|
||||
{
|
||||
pct = 100 - sts->onPct; /* Percentage of cycle for off */
|
||||
sts->mode &= ~HAL_LED_MODE_ON; /* Say it's not on */
|
||||
HalLedOnOff(led, HAL_LED_MODE_OFF); /* Turn it off */
|
||||
if(!(sts->mode & HAL_LED_MODE_FLASH))
|
||||
{
|
||||
if(sts->todo != 0xff)
|
||||
{
|
||||
sts->todo--; /* Not continuous, reduce count */
|
||||
}
|
||||
if(!sts->todo)
|
||||
{
|
||||
sts->mode ^= HAL_LED_MODE_BLINK; /* No more blinks */
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pct = sts->onPct; /* Percentage of cycle for on */
|
||||
sts->mode |= HAL_LED_MODE_ON; /* Say it's on */
|
||||
HalLedOnOff(led, HAL_LED_MODE_ON); /* Turn it on */
|
||||
}
|
||||
if(sts->mode & HAL_LED_MODE_BLINK)
|
||||
{
|
||||
wait = (((uint32_t)pct * (uint32_t)sts->time) / 100);
|
||||
sts->next = time + wait;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* no more blink, no more wait */
|
||||
wait = 0;
|
||||
/* After blinking, set the LED back to the state before it blinks */
|
||||
HalLedSet(led, ((preBlinkState & led) != 0) ? HAL_LED_MODE_ON : HAL_LED_MODE_OFF);
|
||||
/* Clear the saved bit */
|
||||
preBlinkState &= (led ^ 0xFF);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
wait = sts->next - time; /* Time left */
|
||||
}
|
||||
if(!next || (wait && (wait < next)))
|
||||
{
|
||||
next = wait;
|
||||
}
|
||||
}
|
||||
leds ^= led;
|
||||
}
|
||||
led <<= 1;
|
||||
sts++;
|
||||
}
|
||||
if(next)
|
||||
{
|
||||
tmos_start_task(halTaskID, LED_BLINK_EVENT, next); /* Schedule event */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn HalLedOnOff
|
||||
*
|
||||
* @brief Turns specified LED ON or OFF
|
||||
*
|
||||
* @param led - LED bit mask
|
||||
* @param mode - LED_ON,LED_OFF,
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void HalLedOnOff(uint8_t leds, uint8_t mode)
|
||||
{
|
||||
if(leds & HAL_LED_1)
|
||||
{
|
||||
if(mode == HAL_LED_MODE_ON)
|
||||
{
|
||||
HAL_TURN_ON_LED1();
|
||||
}
|
||||
else
|
||||
{
|
||||
HAL_TURN_OFF_LED1();
|
||||
}
|
||||
}
|
||||
if(leds & HAL_LED_2)
|
||||
{
|
||||
if(mode == HAL_LED_MODE_ON)
|
||||
{
|
||||
HAL_TURN_ON_LED2();
|
||||
}
|
||||
else
|
||||
{
|
||||
HAL_TURN_OFF_LED2();
|
||||
}
|
||||
}
|
||||
if(leds & HAL_LED_3)
|
||||
{
|
||||
if(mode == HAL_LED_MODE_ON)
|
||||
{
|
||||
HAL_TURN_ON_LED3();
|
||||
}
|
||||
else
|
||||
{
|
||||
HAL_TURN_OFF_LED3();
|
||||
}
|
||||
}
|
||||
if(leds & HAL_LED_4)
|
||||
{
|
||||
if(mode == HAL_LED_MODE_ON)
|
||||
{
|
||||
HAL_TURN_ON_LED4();
|
||||
}
|
||||
else
|
||||
{
|
||||
HAL_TURN_OFF_LED4();
|
||||
}
|
||||
}
|
||||
/* Remember current state */
|
||||
if(mode)
|
||||
{
|
||||
HalLedState |= leds;
|
||||
}
|
||||
else
|
||||
{
|
||||
HalLedState &= (leds ^ 0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************************************************************
|
||||
* @fn HalGetLedState
|
||||
*
|
||||
* @brief Dim LED2 - Dim (set level) of LED2
|
||||
*
|
||||
* @return led state
|
||||
*/
|
||||
uint8_t HalLedGetState()
|
||||
{
|
||||
return HalLedState;
|
||||
}
|
||||
|
||||
/******************************** endfile @ led ******************************/
|
||||
+298
@@ -0,0 +1,298 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : MCU.c
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2022/01/18
|
||||
* Description : 硬件任务处理函数及BLE和硬件初始化
|
||||
*********************************************************************************
|
||||
* 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 "HAL.h"
|
||||
|
||||
tmosTaskID halTaskID;
|
||||
uint32_t g_LLE_IRQLibHandlerLocation;
|
||||
/*******************************************************************************
|
||||
* @fn Lib_Calibration_LSI
|
||||
*
|
||||
* @brief 内部32k校准
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @return None.
|
||||
*/
|
||||
void Lib_Calibration_LSI(void)
|
||||
{
|
||||
Calibration_LSI(Level_64);
|
||||
}
|
||||
|
||||
#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)
|
||||
{
|
||||
EEPROM_READ(addr, pBuf, num * 4);
|
||||
return 0;
|
||||
}
|
||||
/*******************************************************************************
|
||||
* @fn Lib_Write_Flash_592A
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
void Lib_Write_Flash_592A(uint32_t addr, uint32_t num, uint32_t *pBuf)
|
||||
{
|
||||
__attribute__((aligned(4))) uint32_t FLASH_BUF[(BLE_SNV_BLOCK*BLE_SNV_NUM) / 4];
|
||||
EEPROM_READ(addr&0xFFFFF000, FLASH_BUF, BLE_SNV_BLOCK*BLE_SNV_NUM);
|
||||
tmos_memcpy(&FLASH_BUF[addr&0xFFF], pBuf, num * 4);
|
||||
EEPROM_ERASE(addr&0xFFFFF000, ((BLE_SNV_BLOCK*BLE_SNV_NUM+EEPROM_BLOCK_SIZE-1)/EEPROM_BLOCK_SIZE)*EEPROM_BLOCK_SIZE);
|
||||
EEPROM_WRITE(addr&0xFFFFF000, FLASH_BUF, BLE_SNV_BLOCK*BLE_SNV_NUM);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* @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)
|
||||
{
|
||||
if(((*(uint32_t*)ROM_CFG_VERISON)&0xFF) == DEF_CHIP_ID_CH592A)
|
||||
{
|
||||
Lib_Write_Flash_592A(addr, num, pBuf);
|
||||
}
|
||||
else
|
||||
{
|
||||
EEPROM_ERASE(addr, num * 4);
|
||||
EEPROM_WRITE(addr, pBuf, num * 4);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* @fn CH59x_BLEInit
|
||||
*
|
||||
* @brief BLE 库初始化
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @return None.
|
||||
*/
|
||||
void CH59x_BLEInit(void)
|
||||
{
|
||||
uint8_t i;
|
||||
bleConfig_t cfg;
|
||||
if(tmos_memcmp(VER_LIB, VER_FILE, strlen(VER_FILE)) == FALSE)
|
||||
{
|
||||
// PRINT("head file error...VER_LIB:%s, VER_FILE:%s\n", VER_LIB, VER_FILE);
|
||||
// while(1);
|
||||
}
|
||||
|
||||
SysTick_Config(SysTick_LOAD_RELOAD_Msk);// 配置SysTick并打开中断
|
||||
PFIC_DisableIRQ(SysTick_IRQn);
|
||||
|
||||
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;
|
||||
#if(defined(BLE_SNV)) && (BLE_SNV == TRUE)
|
||||
if((BLE_SNV_ADDR + BLE_SNV_BLOCK * BLE_SNV_NUM) > (0x78000 - FLASH_ROM_MAX_SIZE))
|
||||
{
|
||||
// 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.ConnectNumber = (PERIPHERAL_MAX_CONNECTION & 3) | (CENTRAL_MAX_CONNECTION << 2);
|
||||
cfg.srandCB = SYS_GetSysTickCnt;
|
||||
#if(defined TEM_SAMPLE) && (TEM_SAMPLE == TRUE)
|
||||
cfg.tsCB = HAL_GetInterTempValue; // 根据温度变化校准RF和内部RC( 大于7摄氏度 )
|
||||
#if(CLK_OSC32K)
|
||||
cfg.rcCB = Lib_Calibration_LSI; // 内部32K时钟校准
|
||||
#endif
|
||||
#endif
|
||||
#if(defined(HAL_SLEEP)) && (HAL_SLEEP == TRUE)
|
||||
cfg.idleCB = CH59x_LowPower; // 启用睡眠
|
||||
#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]; // 使用芯片mac地址
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if(!cfg.MEMAddr || cfg.MEMLen < 4 * 1024)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
i = BLE_LibInit(&cfg);
|
||||
if(i)
|
||||
{
|
||||
// PRINT("LIB init error code: %x ...\n", i);
|
||||
while(1);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* @fn HAL_ProcessEvent
|
||||
*
|
||||
* @brief 硬件层事务处理
|
||||
*
|
||||
* @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)
|
||||
{ // 处理HAL层消息,调用tmos_msg_receive读取消息,处理完成后删除消息。
|
||||
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)
|
||||
{
|
||||
uint8_t x32Kpw;
|
||||
#if(defined BLE_CALIBRATION_ENABLE) && (BLE_CALIBRATION_ENABLE == TRUE) // 校准任务,单次校准耗时小于10ms
|
||||
BLE_RegInit(); // 校准RF
|
||||
#if(CLK_OSC32K)
|
||||
Lib_Calibration_LSI(); // 校准内部RC
|
||||
#else
|
||||
x32Kpw = (R8_XT32K_TUNE & 0xfc) | 0x01;
|
||||
sys_safe_access_enable();
|
||||
R8_XT32K_TUNE = x32Kpw; // LSE驱动电流降低到额定电流
|
||||
sys_safe_access_disable();
|
||||
#endif
|
||||
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 硬件初始化
|
||||
*
|
||||
* @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); // 添加校准任务,500ms启动,单次校准耗时小于10ms
|
||||
#endif
|
||||
// tmos_start_task( halTaskID, HAL_TEST_EVENT, 1600 ); // 添加一个测试任务
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* @fn HAL_GetInterTempValue
|
||||
*
|
||||
* @brief 获取内部温感采样值,如果使用了ADC中断采样,需在此函数中暂时屏蔽中断.
|
||||
*
|
||||
* @return 内部温感采样值.
|
||||
*/
|
||||
uint16_t HAL_GetInterTempValue(void)
|
||||
{
|
||||
uint8_t sensor, channel, config, tkey_cfg;
|
||||
uint16_t adc_data;
|
||||
|
||||
tkey_cfg = R8_TKEY_CFG;
|
||||
sensor = R8_TEM_SENSOR;
|
||||
channel = R8_ADC_CHANNEL;
|
||||
config = R8_ADC_CFG;
|
||||
ADC_InterTSSampInit();
|
||||
R8_ADC_CONVERT |= RB_ADC_START;
|
||||
while(R8_ADC_CONVERT & RB_ADC_START);
|
||||
adc_data = R16_ADC_DATA;
|
||||
R8_TEM_SENSOR = sensor;
|
||||
R8_ADC_CHANNEL = channel;
|
||||
R8_ADC_CFG = config;
|
||||
R8_TKEY_CFG = tkey_cfg;
|
||||
return (adc_data);
|
||||
}
|
||||
|
||||
/******************************** endfile @ mcu ******************************/
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : RTC.c
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2022/01/18
|
||||
* Description : RTC配置及其初始化
|
||||
*********************************************************************************
|
||||
* 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 "HAL.h"
|
||||
|
||||
/*********************************************************************
|
||||
* CONSTANTS
|
||||
*/
|
||||
#define RTC_INIT_TIME_HOUR 0
|
||||
#define RTC_INIT_TIME_MINUTE 0
|
||||
#define RTC_INIT_TIME_SECEND 0
|
||||
|
||||
/***************************************************
|
||||
* Global variables
|
||||
*/
|
||||
volatile uint32_t RTCTigFlag;
|
||||
|
||||
/*******************************************************************************
|
||||
* @fn RTC_SetTignTime
|
||||
*
|
||||
* @brief 配置RTC触发时间
|
||||
*
|
||||
* @param time - 触发时间.
|
||||
*
|
||||
* @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中断处理
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @return None.
|
||||
*/
|
||||
__INTERRUPT
|
||||
__HIGH_CODE
|
||||
void RTC_IRQHandler(void)
|
||||
{
|
||||
R8_RTC_FLAG_CTRL = (RB_RTC_TMR_CLR | RB_RTC_TRIG_CLR);
|
||||
RTCTigFlag = 1;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* @fn SYS_GetClockValue
|
||||
*
|
||||
* @brief 获取RTC当前计数值
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @return None.
|
||||
*/
|
||||
__HIGH_CODE
|
||||
static uint32_t SYS_GetClockValue(void)
|
||||
{
|
||||
volatile uint32_t i;
|
||||
|
||||
do
|
||||
{
|
||||
i = R32_RTC_CNT_32K;
|
||||
} while(i != R32_RTC_CNT_32K);
|
||||
|
||||
return (i);
|
||||
}
|
||||
/*******************************************************************************
|
||||
* @fn HAL_Time0Init
|
||||
*
|
||||
* @brief 系统定时器初始化
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @return None.
|
||||
*/
|
||||
void HAL_TimeInit(void)
|
||||
{
|
||||
bleClockConfig_t conf;
|
||||
#if(CLK_OSC32K)
|
||||
sys_safe_access_enable();
|
||||
R8_CK32K_CONFIG &= ~(RB_CLK_OSC32K_XT | RB_CLK_XT32K_PON);
|
||||
sys_safe_access_disable();
|
||||
sys_safe_access_enable();
|
||||
R8_CK32K_CONFIG |= RB_CLK_INT32K_PON;
|
||||
sys_safe_access_disable();
|
||||
LSECFG_Current(LSE_RCur_100);
|
||||
Lib_Calibration_LSI();
|
||||
#else
|
||||
sys_safe_access_enable();
|
||||
R8_CK32K_CONFIG &= ~RB_CLK_INT32K_PON;
|
||||
sys_safe_access_disable();
|
||||
sys_safe_access_enable();
|
||||
R8_CK32K_CONFIG |= RB_CLK_OSC32K_XT | RB_CLK_XT32K_PON;
|
||||
sys_safe_access_disable();
|
||||
#endif
|
||||
RTC_InitTime(2020, 1, 1, 0, 0, 0); //RTC时钟初始化当前时间
|
||||
|
||||
tmos_memset( &conf, 0, sizeof(bleClockConfig_t) );
|
||||
conf.ClockAccuracy = CLK_OSC32K ? 1000 : 50;
|
||||
conf.ClockFrequency = CAB_LSIFQ;
|
||||
conf.ClockMaxCount = RTC_MAX_COUNT;
|
||||
conf.getClockValue = SYS_GetClockValue;
|
||||
TMOS_TimerInit( &conf );
|
||||
|
||||
}
|
||||
|
||||
/******************************** endfile @ time ******************************/
|
||||
@@ -0,0 +1,152 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CONFIG.h
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2022/01/18
|
||||
* 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 __CONFIG_H
|
||||
#define __CONFIG_H
|
||||
|
||||
#define ID_CH592 0x92
|
||||
|
||||
#define CHIP_ID ID_CH592
|
||||
|
||||
#ifdef CH59xBLE_ROM
|
||||
#include "CH59xBLE_ROM.h"
|
||||
#else
|
||||
#include "CH59xBLE_LIB.h"
|
||||
#endif
|
||||
|
||||
#include "CH59x_common.h"
|
||||
|
||||
/*********************************************************************
|
||||
【MAC】
|
||||
BLE_MAC - 是否自定义蓝牙Mac地址 ( 默认:FALSE - 使用芯片Mac地址 ),需要在main.c修改Mac地址定义
|
||||
|
||||
【DCDC】
|
||||
DCDC_ENABLE - 是否使能DCDC ( 默认:FALSE )
|
||||
|
||||
【SLEEP】
|
||||
HAL_SLEEP - 是否开启睡眠功能 ( 默认:FALSE )
|
||||
SLEEP_RTC_MIN_TIME - 非空闲模式下睡眠的最小时间(单位:一个RTC周期)
|
||||
SLEEP_RTC_MAX_TIME - 非空闲模式下睡眠的最大时间(单位:一个RTC周期)
|
||||
WAKE_UP_RTC_MAX_TIME - 等待32M晶振稳定时间(单位:一个RTC周期)
|
||||
根据不同睡眠类型取值可分为: 睡眠模式/下电模式 - 45 (默认)
|
||||
暂停模式 - 45
|
||||
空闲模式 - 5
|
||||
【TEMPERATION】
|
||||
TEM_SAMPLE - 是否打开根据温度变化校准的功能,单次校准耗时小于10ms( 默认:TRUE )
|
||||
|
||||
【CALIBRATION】
|
||||
BLE_CALIBRATION_ENABLE - 是否打开定时校准的功能,单次校准耗时小于10ms( 默认:TRUE )
|
||||
BLE_CALIBRATION_PERIOD - 定时校准的周期,单位ms( 默认:120000 )
|
||||
|
||||
【SNV】
|
||||
BLE_SNV - 是否开启SNV功能,用于储存绑定信息( 默认:TRUE )
|
||||
BLE_SNV_ADDR - SNV信息保存地址,使用data flash最后512字节( 默认:0x77E00 )
|
||||
BLE_SNV_BLOCK - SNV信息保存块大小( 默认:256 )
|
||||
BLE_SNV_NUM - SNV信息保存数量( 默认:1 )
|
||||
|
||||
【RTC】
|
||||
CLK_OSC32K - RTC时钟选择,如包含主机角色必须使用外部32K( 0 外部(32768Hz),默认:1:内部(32000Hz),2:内部(32768Hz) )
|
||||
|
||||
【MEMORY】
|
||||
BLE_MEMHEAP_SIZE - 蓝牙协议栈使用的RAM大小,不小于6K ( 默认:(1024*6) )
|
||||
|
||||
【DATA】
|
||||
BLE_BUFF_MAX_LEN - 单个连接最大包长度( 默认:27 (ATT_MTU=23),取值范围[27~516] )
|
||||
BLE_BUFF_NUM - 控制器缓存的包数量( 默认:5 )
|
||||
BLE_TX_NUM_EVENT - 单个连接事件最多可以发多少个数据包( 默认:1 )
|
||||
BLE_TX_POWER - 发射功率( 默认:LL_TX_POWEER_0_DBM (0dBm) )
|
||||
|
||||
【MULTICONN】
|
||||
PERIPHERAL_MAX_CONNECTION - 最多可同时做多少从机角色( 默认:1 )
|
||||
CENTRAL_MAX_CONNECTION - 最多可同时做多少主机角色( 默认:3 )
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
/*********************************************************************
|
||||
* 默认配置值
|
||||
*/
|
||||
#ifndef BLE_MAC
|
||||
#define BLE_MAC FALSE
|
||||
#endif
|
||||
#ifndef DCDC_ENABLE
|
||||
#define DCDC_ENABLE 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 0x77000-FLASH_ROM_MAX_SIZE
|
||||
#endif
|
||||
#ifndef BLE_SNV_BLOCK
|
||||
#define BLE_SNV_BLOCK 256
|
||||
#endif
|
||||
#ifndef BLE_SNV_NUM
|
||||
#define BLE_SNV_NUM 1
|
||||
#endif
|
||||
#ifndef CLK_OSC32K
|
||||
#define CLK_OSC32K 1 // 该项请勿在此修改,必须在工程配置里的预处理中修改,如包含主机角色必须使用外部32K
|
||||
#endif
|
||||
#ifndef BLE_MEMHEAP_SIZE
|
||||
#define BLE_MEMHEAP_SIZE (1024*6)
|
||||
#endif
|
||||
#ifndef BLE_BUFF_MAX_LEN
|
||||
#define BLE_BUFF_MAX_LEN 100 // 27
|
||||
#endif
|
||||
#ifndef BLE_BUFF_NUM
|
||||
#define BLE_BUFF_NUM 5
|
||||
#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
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
/********************************** (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 硬件初始化
|
||||
*/
|
||||
extern void HAL_Init(void);
|
||||
|
||||
/**
|
||||
* @brief 硬件层事务处理
|
||||
*
|
||||
* @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 库初始化
|
||||
*/
|
||||
extern void CH59x_BLEInit(void);
|
||||
|
||||
/**
|
||||
* @brief 获取内部温感采样值,如果使用了ADC中断采样,需在此函数中暂时屏蔽中断.
|
||||
*
|
||||
* @return 内部温感采样值.
|
||||
*/
|
||||
extern uint16_t HAL_GetInterTempValue(void);
|
||||
|
||||
/**
|
||||
* @brief 内部32k校准
|
||||
*/
|
||||
extern void Lib_Calibration_LSI(void);
|
||||
|
||||
/*********************************************************************
|
||||
*********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,112 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : KEY.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 __KEY_H
|
||||
#define __KEY_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**************************************************************************************************
|
||||
* MACROS
|
||||
**************************************************************************************************/
|
||||
#define HAL_KEY_POLLING_VALUE 100
|
||||
|
||||
/* Switches (keys) */
|
||||
#define HAL_KEY_SW_1 0x01 // key1
|
||||
#define HAL_KEY_SW_2 0x02 // key2
|
||||
#define HAL_KEY_SW_3 0x04 // key3
|
||||
#define HAL_KEY_SW_4 0x08 // key4
|
||||
|
||||
/* °´¼ü¶¨Òå */
|
||||
|
||||
/* 1 - KEY */
|
||||
#define KEY1_BV BV(22)
|
||||
#define KEY2_BV BV(4)
|
||||
#define KEY3_BV ()
|
||||
#define KEY4_BV ()
|
||||
|
||||
#define KEY1_PU (R32_PB_PU |= KEY1_BV)
|
||||
#define KEY2_PU (R32_PB_PU |= KEY2_BV)
|
||||
#define KEY3_PU ()
|
||||
#define KEY4_PU ()
|
||||
|
||||
#define KEY1_DIR (R32_PB_DIR &= ~KEY1_BV)
|
||||
#define KEY2_DIR (R32_PB_DIR &= ~KEY2_BV)
|
||||
#define KEY3_DIR ()
|
||||
#define KEY4_DIR ()
|
||||
|
||||
#define KEY1_IN (ACTIVE_LOW(R32_PB_PIN & KEY1_BV))
|
||||
#define KEY2_IN (ACTIVE_LOW(R32_PB_PIN & KEY2_BV))
|
||||
#define KEY3_IN ()
|
||||
#define KEY4_IN ()
|
||||
|
||||
#define HAL_PUSH_BUTTON1() (KEY1_IN) //Ìí¼Ó×Ô¶¨Òå°´¼ü
|
||||
#define HAL_PUSH_BUTTON2() (KEY2_IN)
|
||||
#define HAL_PUSH_BUTTON3() (0)
|
||||
#define HAL_PUSH_BUTTON4() (0)
|
||||
|
||||
/**************************************************************************************************
|
||||
* TYPEDEFS
|
||||
**************************************************************************************************/
|
||||
typedef void (*halKeyCBack_t)(uint8_t keys);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t keys; // keys
|
||||
} keyChange_t;
|
||||
|
||||
/**************************************************************************************************
|
||||
* GLOBAL VARIABLES
|
||||
**************************************************************************************************/
|
||||
|
||||
/*********************************************************************
|
||||
* FUNCTIONS
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Initialize the Key Service
|
||||
*/
|
||||
void HAL_KeyInit(void);
|
||||
|
||||
/**
|
||||
* @brief This is for internal used by hal_driver
|
||||
*/
|
||||
void HAL_KeyPoll(void);
|
||||
|
||||
/**
|
||||
* @brief Configure the Key serivce
|
||||
*
|
||||
* @param cback - pointer to the CallBack function
|
||||
*/
|
||||
void HalKeyConfig(const halKeyCBack_t cback);
|
||||
|
||||
/**
|
||||
* @brief Read the Key callback
|
||||
*/
|
||||
void HalKeyCallback(uint8_t keys);
|
||||
|
||||
/**
|
||||
* @brief Read the Key status
|
||||
*/
|
||||
uint8_t HalKeyRead(void);
|
||||
|
||||
/**************************************************************************************************
|
||||
**************************************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,134 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : LED.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 __LED_H
|
||||
#define __LED_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
* CONSTANTS
|
||||
*/
|
||||
|
||||
/* LEDS - The LED number is the same as the bit position */
|
||||
#define HAL_LED_1 0x01
|
||||
#define HAL_LED_2 0x02
|
||||
#define HAL_LED_3 0x04
|
||||
#define HAL_LED_4 0x08
|
||||
#define HAL_LED_ALL (HAL_LED_1 | HAL_LED_2 | HAL_LED_3 | HAL_LED_4)
|
||||
|
||||
/* Modes */
|
||||
#define HAL_LED_MODE_OFF 0x00
|
||||
#define HAL_LED_MODE_ON 0x01
|
||||
#define HAL_LED_MODE_BLINK 0x02
|
||||
#define HAL_LED_MODE_FLASH 0x04
|
||||
#define HAL_LED_MODE_TOGGLE 0x08
|
||||
|
||||
/* Defaults */
|
||||
#define HAL_LED_DEFAULT_MAX_LEDS 4
|
||||
#define HAL_LED_DEFAULT_DUTY_CYCLE 5
|
||||
#define HAL_LED_DEFAULT_FLASH_COUNT 50
|
||||
#define HAL_LED_DEFAULT_FLASH_TIME 1000
|
||||
|
||||
/*********************************************************************
|
||||
* TYPEDEFS
|
||||
*/
|
||||
|
||||
/* 连接一个LED用于监控演示程序的进度,低电平LED亮 */
|
||||
|
||||
/* 1 - LED */
|
||||
#define LED1_BV BV(15)
|
||||
#define LED2_BV
|
||||
#define LED3_BV
|
||||
|
||||
#define LED1_OUT (R32_PB_OUT)
|
||||
#define LED2_OUT 0
|
||||
#define LED3_OUT 0
|
||||
#define LED4_OUT 0
|
||||
|
||||
#define LED1_DDR (R32_PB_DIR |= LED1_BV)
|
||||
#define LED2_DDR 0
|
||||
#define LED3_DDR 0
|
||||
|
||||
#define HAL_TURN_OFF_LED1() (LED1_OUT |= LED1_BV)
|
||||
#define HAL_TURN_OFF_LED2()
|
||||
#define HAL_TURN_OFF_LED3()
|
||||
#define HAL_TURN_OFF_LED4()
|
||||
|
||||
#define HAL_TURN_ON_LED1() (LED1_OUT &= (~LED1_BV))
|
||||
#define HAL_TURN_ON_LED2()
|
||||
#define HAL_TURN_ON_LED3()
|
||||
#define HAL_TURN_ON_LED4()
|
||||
|
||||
#define HAL_STATE_LED1() 0
|
||||
#define HAL_STATE_LED2() 0
|
||||
#define HAL_STATE_LED3() 0
|
||||
#define HAL_STATE_LED4() 0
|
||||
|
||||
/*********************************************************************
|
||||
* GLOBAL VARIABLES
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Initialize LED Service.
|
||||
*/
|
||||
void HAL_LedInit(void);
|
||||
|
||||
/**
|
||||
* @brief update time LED Service.
|
||||
*/
|
||||
void HalLedUpdate(void);
|
||||
|
||||
/**
|
||||
* @brief Turn ON/OFF/TOGGLE given LEDs
|
||||
*
|
||||
* @param led - bit mask value of leds to be turned ON/OFF/TOGGLE
|
||||
* @param mode - BLINK, FLASH, TOGGLE, ON, OFF
|
||||
*/
|
||||
extern uint8_t HalLedSet(uint8_t led, uint8_t mode);
|
||||
|
||||
/**
|
||||
* @brief Blink the leds
|
||||
*
|
||||
* @param led - bit mask value of leds to be turned ON/OFF/TOGGLE
|
||||
* @param numBlinks - number of blinks
|
||||
* @param percent - the percentage in each period where the led will be on
|
||||
* @param period - length of each cycle in milliseconds
|
||||
*/
|
||||
extern void HalLedBlink(uint8_t leds, uint8_t cnt, uint8_t duty, uint16_t time);
|
||||
|
||||
/**
|
||||
* @brief Put LEDs in sleep state - store current values
|
||||
*/
|
||||
extern void HalLedEnterSleep(void);
|
||||
|
||||
/**
|
||||
* @brief Retore LEDs from sleep state
|
||||
*/
|
||||
extern void HalLedExitSleep(void);
|
||||
|
||||
/**
|
||||
* @brief Return LED state
|
||||
*/
|
||||
extern uint8_t HalLedGetState(void);
|
||||
|
||||
/*********************************************************************
|
||||
*********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,60 @@
|
||||
/********************************** (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_RTC) * 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;
|
||||
|
||||
/**
|
||||
* @brief Initialize time Service.
|
||||
*/
|
||||
void HAL_TimeInit(void);
|
||||
|
||||
/**
|
||||
* @brief ÅäÖÃRTC´¥·¢Ê±¼ä
|
||||
*
|
||||
* @param time - ´¥·¢Ê±¼ä.
|
||||
*/
|
||||
extern void RTC_SetTignTime(uint32_t time);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,50 @@
|
||||
/********************************** (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
|
||||
*/
|
||||
|
||||
/*********************************************************************
|
||||
* FUNCTIONS
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief 配置睡眠唤醒的方式 - RTC唤醒,触发模式
|
||||
*/
|
||||
extern void HAL_SleepInit(void);
|
||||
|
||||
/**
|
||||
* @brief 启动睡眠
|
||||
*
|
||||
* @param time - 唤醒的时间点(RTC绝对值)
|
||||
*
|
||||
* @return state.
|
||||
*/
|
||||
extern uint32_t CH59x_LowPower(uint32_t time);
|
||||
|
||||
/*********************************************************************
|
||||
*********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -0,0 +1,127 @@
|
||||
.global Ecall_M_Mode_Handler
|
||||
.global Ecall_U_Mode_Handler
|
||||
.global LLE_IRQHandler
|
||||
|
||||
.extern g_LLE_IRQLibHandlerLocation
|
||||
|
||||
.section .highcode,"ax",@progbits
|
||||
.align 2
|
||||
.func
|
||||
Ecall_M_Mode_Handler:
|
||||
Ecall_U_Mode_Handler:
|
||||
|
||||
addi a1, x0, 0x20
|
||||
csrs 0x804, a1
|
||||
|
||||
lw a1, 0 * 4( sp )
|
||||
csrw mepc, a1
|
||||
|
||||
lw x1, 1 * 4( sp )
|
||||
lw x4, 2 * 4( sp )
|
||||
lw x5, 3 * 4( sp )
|
||||
lw x6, 4 * 4( sp )
|
||||
lw x7, 5 * 4( sp )
|
||||
lw x8, 6 * 4( sp )
|
||||
lw x9, 7 * 4( sp )
|
||||
lw x10, 8 * 4( sp )
|
||||
lw x11, 9 * 4( sp )
|
||||
lw x12, 10 * 4( sp )
|
||||
lw x13, 11 * 4( sp )
|
||||
lw x14, 12 * 4( sp )
|
||||
lw x15, 13 * 4( sp )
|
||||
lw x16, 14 * 4( sp )
|
||||
lw x17, 15 * 4( sp )
|
||||
lw x18, 16 * 4( sp )
|
||||
lw x19, 17 * 4( sp )
|
||||
lw x20, 18 * 4( sp )
|
||||
lw x21, 19 * 4( sp )
|
||||
lw x22, 20 * 4( sp )
|
||||
lw x23, 21 * 4( sp )
|
||||
lw x24, 22 * 4( sp )
|
||||
lw x25, 23 * 4( sp )
|
||||
lw x26, 24 * 4( sp )
|
||||
lw x27, 25 * 4( sp )
|
||||
lw x28, 26 * 4( sp )
|
||||
lw x29, 27 * 4( sp )
|
||||
lw x30, 28 * 4( sp )
|
||||
lw x31, 29 * 4( sp )
|
||||
|
||||
addi sp, sp, 32*4
|
||||
|
||||
mret
|
||||
.endfunc
|
||||
|
||||
.section .highcode.LLE_IRQHandler,"ax",@progbits
|
||||
.align 2
|
||||
.func
|
||||
LLE_IRQHandler:
|
||||
addi sp, sp, -32*4
|
||||
|
||||
sw x1, 1 * 4( sp )
|
||||
sw x4, 2 * 4( sp )
|
||||
sw x5, 3 * 4( sp )
|
||||
sw x6, 4 * 4( sp )
|
||||
sw x7, 5 * 4( sp )
|
||||
sw x8, 6 * 4( sp )
|
||||
sw x9, 7 * 4( sp )
|
||||
sw x10, 8 * 4( sp )
|
||||
sw x11, 9 * 4( sp )
|
||||
sw x12, 10 * 4( sp )
|
||||
sw x13, 11 * 4( sp )
|
||||
sw x14, 12 * 4( sp )
|
||||
sw x15, 13 * 4( sp )
|
||||
sw x16, 14 * 4( sp )
|
||||
sw x17, 15 * 4( sp )
|
||||
sw x18, 16 * 4( sp )
|
||||
sw x19, 17 * 4( sp )
|
||||
sw x20, 18 * 4( sp )
|
||||
sw x21, 19 * 4( sp )
|
||||
sw x22, 20 * 4( sp )
|
||||
sw x23, 21 * 4( sp )
|
||||
sw x24, 22 * 4( sp )
|
||||
sw x25, 23 * 4( sp )
|
||||
sw x26, 24 * 4( sp )
|
||||
sw x27, 25 * 4( sp )
|
||||
sw x28, 26 * 4( sp )
|
||||
sw x29, 27 * 4( sp )
|
||||
sw x30, 28 * 4( sp )
|
||||
sw x31, 29 * 4( sp )
|
||||
|
||||
la a1, g_LLE_IRQLibHandlerLocation
|
||||
lw a0, 0(a1)
|
||||
jalr x1, 0(a0)
|
||||
|
||||
lw x1, 1 * 4( sp )
|
||||
lw x4, 2 * 4( sp )
|
||||
lw x5, 3 * 4( sp )
|
||||
lw x6, 4 * 4( sp )
|
||||
lw x7, 5 * 4( sp )
|
||||
lw x8, 6 * 4( sp )
|
||||
lw x9, 7 * 4( sp )
|
||||
lw x10, 8 * 4( sp )
|
||||
lw x11, 9 * 4( sp )
|
||||
lw x12, 10 * 4( sp )
|
||||
lw x13, 11 * 4( sp )
|
||||
lw x14, 12 * 4( sp )
|
||||
lw x15, 13 * 4( sp )
|
||||
lw x16, 14 * 4( sp )
|
||||
lw x17, 15 * 4( sp )
|
||||
lw x18, 16 * 4( sp )
|
||||
lw x19, 17 * 4( sp )
|
||||
lw x20, 18 * 4( sp )
|
||||
lw x21, 19 * 4( sp )
|
||||
lw x22, 20 * 4( sp )
|
||||
lw x23, 21 * 4( sp )
|
||||
lw x24, 22 * 4( sp )
|
||||
lw x25, 23 * 4( sp )
|
||||
lw x26, 24 * 4( sp )
|
||||
lw x27, 25 * 4( sp )
|
||||
lw x28, 26 * 4( sp )
|
||||
lw x29, 27 * 4( sp )
|
||||
lw x30, 28 * 4( sp )
|
||||
lw x31, 29 * 4( sp )
|
||||
|
||||
addi sp, sp, 32*4
|
||||
|
||||
mret
|
||||
.endfunc
|
||||
+184
@@ -0,0 +1,184 @@
|
||||
ENTRY( _start )
|
||||
|
||||
__stack_size = 512;
|
||||
|
||||
PROVIDE( _stack_size = __stack_size );
|
||||
|
||||
MEMORY
|
||||
{
|
||||
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 448K
|
||||
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 26K
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.init :
|
||||
{
|
||||
_sinit = .;
|
||||
. = ALIGN(4);
|
||||
KEEP(*(SORT_NONE(.init)))
|
||||
. = ALIGN(4);
|
||||
_einit = .;
|
||||
} >FLASH AT>FLASH
|
||||
|
||||
/* .vector :
|
||||
{
|
||||
*(.vector);
|
||||
} >FLASH AT>FLASH */
|
||||
|
||||
.highcodelalign :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
PROVIDE(_highcode_lma = .);
|
||||
} >FLASH AT>FLASH
|
||||
|
||||
.highcode :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
PROVIDE(_highcode_vma_start = .);
|
||||
*(.vector);
|
||||
KEEP(*(SORT_NONE(.vector_handler)))
|
||||
*(.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
|
||||
|
||||
.dalign :
|
||||
{
|
||||
. = ORIGIN(RAM) + SIZEOF(.highcode);
|
||||
} >RAM 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) - __stack_size :
|
||||
{
|
||||
PROVIDE( _heap_end = . );
|
||||
. = ALIGN(4);
|
||||
PROVIDE(_susrstack = . );
|
||||
. = . + __stack_size;
|
||||
PROVIDE( _eusrstack = .);
|
||||
} >RAM
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,306 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : core_riscv.c
|
||||
* Author : WCH
|
||||
* Version : V1.1.0
|
||||
* Date : 2021/06/06
|
||||
* Description : RISC-V Core Peripheral Access Layer Source File
|
||||
*********************************************************************************
|
||||
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
#include <stdint.h>
|
||||
|
||||
/* 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
|
||||
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
* @fn __get_MSTATUS
|
||||
*
|
||||
* @brief Return the Machine Status Register
|
||||
*
|
||||
* @return mstatus value
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
void __set_MTVAL(uint32_t value)
|
||||
{
|
||||
__ASM volatile ("csrw mtval, %0" : : "r" (value) );
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn __get_MVENDORID
|
||||
*
|
||||
* @brief Return Vendor ID Register
|
||||
*
|
||||
* @return mvendorid value
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
uint32_t __get_SP(void)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
__ASM volatile ( "mv %0," "sp" : "=r"(result) : );
|
||||
return (result);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,638 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : core_riscv.h
|
||||
* Author : WCH
|
||||
* Version : V1.1.0
|
||||
* Date : 2023/04/10
|
||||
* Description : CH592 RISC-V Core Peripheral Access Layer Header File
|
||||
*********************************************************************************
|
||||
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
#ifndef __CORE_RV3A_H__
|
||||
#define __CORE_RV3A_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#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[4]; // 44H
|
||||
__O uint32_t CFGR; // 48H
|
||||
__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;
|
||||
__IO uint64_t CNT;
|
||||
__IO uint64_t CMP;
|
||||
} 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)); })
|
||||
|
||||
#define PFIC_EnableAllIRQ() {write_csr(0x800, 0x88);__nop();__nop();}
|
||||
#define PFIC_DisableAllIRQ() {write_csr(0x800, 0x80);__nop();__nop();}
|
||||
/* ########################## PFIC functions #################################### */
|
||||
|
||||
/*********************************************************************
|
||||
* @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;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* @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));
|
||||
__nop();
|
||||
__nop();
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* @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
|
||||
* bit6-bit4: subpriority
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE void PFIC_SetPriority(IRQn_Type IRQn, uint8_t priority)
|
||||
{
|
||||
PFIC->IPRIOR[(uint32_t)(IRQn)] = priority;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @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->CFGR = PFIC_KEY3 | (1 << 7);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn __AMOADD_W
|
||||
*
|
||||
* @brief Atomic Add with 32bit value
|
||||
* Atomically ADD 32bit value with value in memory using amoadd.d.
|
||||
* addr Address pointer to data, address need to be 4byte aligned
|
||||
* value value to be ADDed
|
||||
*
|
||||
*
|
||||
* @return return memory value + add value
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE int32_t __AMOADD_W(volatile int32_t *addr, int32_t value)
|
||||
{
|
||||
int32_t result;
|
||||
|
||||
__asm volatile ("amoadd.w %0, %2, %1" : \
|
||||
"=r"(result), "+A"(*addr) : "r"(value) : "memory");
|
||||
return *addr;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn __AMOAND_W
|
||||
*
|
||||
* @brief Atomic And with 32bit value
|
||||
* Atomically AND 32bit value with value in memory using amoand.d.
|
||||
* addr Address pointer to data, address need to be 4byte aligned
|
||||
* value value to be ANDed
|
||||
*
|
||||
*
|
||||
* @return return memory value & and value
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE int32_t __AMOAND_W(volatile int32_t *addr, int32_t value)
|
||||
{
|
||||
int32_t result;
|
||||
|
||||
__asm volatile ("amoand.w %0, %2, %1" : \
|
||||
"=r"(result), "+A"(*addr) : "r"(value) : "memory");
|
||||
return *addr;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn __AMOMAX_W
|
||||
*
|
||||
* @brief Atomic signed MAX with 32bit value
|
||||
* @details Atomically signed max compare 32bit value with value in memory using amomax.d.
|
||||
* addr Address pointer to data, address need to be 4byte aligned
|
||||
* value value to be compared
|
||||
*
|
||||
*
|
||||
* @return the bigger value
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE int32_t __AMOMAX_W(volatile int32_t *addr, int32_t value)
|
||||
{
|
||||
int32_t result;
|
||||
|
||||
__asm volatile ("amomax.w %0, %2, %1" : \
|
||||
"=r"(result), "+A"(*addr) : "r"(value) : "memory");
|
||||
return *addr;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn __AMOMAXU_W
|
||||
*
|
||||
* @brief Atomic unsigned MAX with 32bit value
|
||||
* Atomically unsigned max compare 32bit value with value in memory using amomaxu.d.
|
||||
* addr Address pointer to data, address need to be 4byte aligned
|
||||
* value value to be compared
|
||||
*
|
||||
* @return return the bigger value
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE uint32_t __AMOMAXU_W(volatile uint32_t *addr, uint32_t value)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
__asm volatile ("amomaxu.w %0, %2, %1" : \
|
||||
"=r"(result), "+A"(*addr) : "r"(value) : "memory");
|
||||
return *addr;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn __AMOMIN_W
|
||||
*
|
||||
* @brief Atomic signed MIN with 32bit value
|
||||
* Atomically signed min compare 32bit value with value in memory using amomin.d.
|
||||
* addr Address pointer to data, address need to be 4byte aligned
|
||||
* value value to be compared
|
||||
*
|
||||
*
|
||||
* @return the smaller value
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE int32_t __AMOMIN_W(volatile int32_t *addr, int32_t value)
|
||||
{
|
||||
int32_t result;
|
||||
|
||||
__asm volatile ("amomin.w %0, %2, %1" : \
|
||||
"=r"(result), "+A"(*addr) : "r"(value) : "memory");
|
||||
return *addr;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn __AMOMINU_W
|
||||
*
|
||||
* @brief Atomic unsigned MIN with 32bit value
|
||||
* Atomically unsigned min compare 32bit value with value in memory using amominu.d.
|
||||
* addr Address pointer to data, address need to be 4byte aligned
|
||||
* value value to be compared
|
||||
*
|
||||
*
|
||||
* @return the smaller value
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE uint32_t __AMOMINU_W(volatile uint32_t *addr, uint32_t value)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
__asm volatile ("amominu.w %0, %2, %1" : \
|
||||
"=r"(result), "+A"(*addr) : "r"(value) : "memory");
|
||||
return *addr;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn __AMOOR_W
|
||||
*
|
||||
* @brief Atomic OR with 32bit value
|
||||
* @details Atomically OR 32bit value with value in memory using amoor.d.
|
||||
* addr Address pointer to data, address need to be 4byte aligned
|
||||
* value value to be ORed
|
||||
*
|
||||
*
|
||||
* @return return memory value | and value
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE int32_t __AMOOR_W(volatile int32_t *addr, int32_t value)
|
||||
{
|
||||
int32_t result;
|
||||
|
||||
__asm volatile ("amoor.w %0, %2, %1" : \
|
||||
"=r"(result), "+A"(*addr) : "r"(value) : "memory");
|
||||
return *addr;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn __AMOSWAP_W
|
||||
*
|
||||
* @brief Atomically swap new 32bit value into memory using amoswap.d.
|
||||
* addr Address pointer to data, address need to be 4byte aligned
|
||||
* newval New value to be stored into the address
|
||||
*
|
||||
* @return return the original value in memory
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE uint32_t __AMOSWAP_W(volatile uint32_t *addr, uint32_t newval)
|
||||
{
|
||||
uint32_t result;
|
||||
|
||||
__asm volatile ("amoswap.w %0, %2, %1" : \
|
||||
"=r"(result), "+A"(*addr) : "r"(newval) : "memory");
|
||||
return result;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn __AMOXOR_W
|
||||
*
|
||||
* @brief Atomic XOR with 32bit value
|
||||
* @details Atomically XOR 32bit value with value in memory using amoxor.d.
|
||||
* addr Address pointer to data, address need to be 4byte aligned
|
||||
* value value to be XORed
|
||||
*
|
||||
*
|
||||
* @return return memory value ^ and value
|
||||
*/
|
||||
__attribute__((always_inline)) RV_STATIC_INLINE int32_t __AMOXOR_W(volatile int32_t *addr, int32_t value)
|
||||
{
|
||||
int32_t result;
|
||||
|
||||
__asm volatile ("amoxor.w %0, %2, %1" : \
|
||||
"=r"(result), "+A"(*addr) : "r"(value) : "memory");
|
||||
return *addr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return the Machine Status Register
|
||||
*
|
||||
* @return mstatus value
|
||||
*/
|
||||
uint32_t __get_MSTATUS(void);
|
||||
|
||||
/**
|
||||
* @brief Return the Machine ISA Register
|
||||
*
|
||||
* @return misa value
|
||||
*/
|
||||
uint32_t __get_MISA(void);
|
||||
|
||||
/***
|
||||
* @brief Return the Machine Trap-Vector Base-Address Register
|
||||
*
|
||||
* @return mtvec value
|
||||
*/
|
||||
uint32_t __get_MTVEC(void);
|
||||
|
||||
/**
|
||||
* @brief Return the Machine Seratch Register
|
||||
*
|
||||
* @return mscratch value
|
||||
*/
|
||||
uint32_t __get_MSCRATCH(void);
|
||||
|
||||
/**
|
||||
* @brief Return the Machine Exception Program Register
|
||||
*
|
||||
* @return mepc value
|
||||
*/
|
||||
uint32_t __get_MEPC(void);
|
||||
|
||||
/**
|
||||
* @brief Return the Machine Cause Register
|
||||
*
|
||||
* @return mcause value
|
||||
*/
|
||||
uint32_t __get_MCAUSE(void);
|
||||
|
||||
/**
|
||||
* @brief Return the Machine Trap Value Register
|
||||
*
|
||||
* @return mtval value
|
||||
*/
|
||||
uint32_t __get_MTVAL(void);
|
||||
|
||||
/**
|
||||
* @brief Return Vendor ID Register
|
||||
*
|
||||
* @return mvendorid value
|
||||
*/
|
||||
uint32_t __get_MVENDORID(void);
|
||||
|
||||
/**
|
||||
* @brief Return Machine Architecture ID Register
|
||||
*
|
||||
* @return marchid value
|
||||
*/
|
||||
uint32_t __get_MARCHID(void);
|
||||
|
||||
/**
|
||||
* @brief Return Machine Implementation ID Register
|
||||
*
|
||||
* @return mimpid value
|
||||
*/
|
||||
uint32_t __get_MIMPID(void);
|
||||
|
||||
/**
|
||||
* @brief Return Hart ID Register
|
||||
*
|
||||
* @return mhartid value
|
||||
*/
|
||||
uint32_t __get_MHARTID(void);
|
||||
|
||||
/**
|
||||
* @brief Return SP Register
|
||||
*
|
||||
* @return SP value
|
||||
*/
|
||||
uint32_t __get_SP(void);
|
||||
|
||||
#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFFFFFFFFFFF)
|
||||
#define SysTick_CTLR_SWIE (1 << 31)
|
||||
#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)
|
||||
|
||||
#define SysTick_SR_CNTIF (1 << 0)
|
||||
|
||||
RV_STATIC_INLINE uint32_t SysTick_Config(uint64_t ticks)
|
||||
{
|
||||
if((ticks - 1) > SysTick_LOAD_RELOAD_Msk)
|
||||
return (1); /* Reload value impossible */
|
||||
|
||||
SysTick->CMP = ticks - 1; /* set reload register */
|
||||
PFIC_EnableIRQ(SysTick_IRQn);
|
||||
SysTick->CTLR = SysTick_CTLR_INIT |
|
||||
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(uint64_t ticks)
|
||||
{
|
||||
if((ticks - 1) > SysTick_LOAD_RELOAD_Msk)
|
||||
return (1); /* Reload value impossible */
|
||||
|
||||
SysTick->CMP = ticks - 1; /* set reload register */
|
||||
SysTick->CTLR = SysTick_CTLR_INIT |
|
||||
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__ */
|
||||
@@ -0,0 +1,185 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : startup_CH59x.s
|
||||
* Author : WCH
|
||||
* Version : V1.0.0
|
||||
* Date : 2021/02/25
|
||||
* 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
|
||||
.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 0xF5F9BDA9
|
||||
.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 SW_Handler /* SW Handler */
|
||||
.word 0
|
||||
/* External Interrupts */
|
||||
.word TMR0_IRQHandler /* 0: TMR0 */
|
||||
.word GPIOA_IRQHandler /* GPIOA */
|
||||
.word GPIOB_IRQHandler /* GPIOB */
|
||||
.word SPI0_IRQHandler /* SPI0 */
|
||||
.word BB_IRQHandler /* BLEB */
|
||||
.word LLE_IRQHandler /* BLEL */
|
||||
.word USB_IRQHandler /* USB */
|
||||
.word 0
|
||||
.word TMR1_IRQHandler /* TMR1 */
|
||||
.word TMR2_IRQHandler /* TMR2 */
|
||||
.word UART0_IRQHandler /* UART0 */
|
||||
.word UART1_IRQHandler /* UART1 */
|
||||
.word RTC_IRQHandler /* RTC */
|
||||
.word ADC_IRQHandler /* ADC */
|
||||
.word I2C_IRQHandler /* I2C */
|
||||
.word PWMX_IRQHandler /* PWMX */
|
||||
.word TMR3_IRQHandler /* TMR3 */
|
||||
.word UART2_IRQHandler /* UART2 */
|
||||
.word UART3_IRQHandler /* UART3 */
|
||||
.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 SW_Handler
|
||||
.weak TMR0_IRQHandler
|
||||
.weak GPIOA_IRQHandler
|
||||
.weak GPIOB_IRQHandler
|
||||
.weak SPI0_IRQHandler
|
||||
.weak BB_IRQHandler
|
||||
.weak LLE_IRQHandler
|
||||
.weak USB_IRQHandler
|
||||
.weak TMR1_IRQHandler
|
||||
.weak TMR2_IRQHandler
|
||||
.weak UART0_IRQHandler
|
||||
.weak UART1_IRQHandler
|
||||
.weak RTC_IRQHandler
|
||||
.weak ADC_IRQHandler
|
||||
.weak I2C_IRQHandler
|
||||
.weak PWMX_IRQHandler
|
||||
.weak TMR3_IRQHandler
|
||||
.weak UART2_IRQHandler
|
||||
.weak UART3_IRQHandler
|
||||
.weak WDOG_BAT_IRQHandler
|
||||
|
||||
NMI_Handler:
|
||||
HardFault_Handler:
|
||||
Ecall_M_Mode_Handler:
|
||||
Ecall_U_Mode_Handler:
|
||||
Break_Point_Handler:
|
||||
SysTick_Handler:
|
||||
SW_Handler:
|
||||
TMR0_IRQHandler:
|
||||
GPIOA_IRQHandler:
|
||||
GPIOB_IRQHandler:
|
||||
SPI0_IRQHandler:
|
||||
BB_IRQHandler:
|
||||
LLE_IRQHandler:
|
||||
USB_IRQHandler:
|
||||
TMR1_IRQHandler:
|
||||
TMR2_IRQHandler:
|
||||
UART0_IRQHandler:
|
||||
UART1_IRQHandler:
|
||||
RTC_IRQHandler:
|
||||
ADC_IRQHandler:
|
||||
I2C_IRQHandler:
|
||||
PWMX_IRQHandler:
|
||||
TMR3_IRQHandler:
|
||||
UART2_IRQHandler:
|
||||
UART3_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$
|
||||
.option pop
|
||||
1:
|
||||
la sp, _eusrstack
|
||||
|
||||
/* 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:
|
||||
/* 流水线控制位 & 动态预测控制位 */
|
||||
li t0, 0x1f
|
||||
csrw 0xbc0, t0
|
||||
/* 打开嵌套中断、硬件压栈功能 */
|
||||
li t0, 0x3
|
||||
csrw 0x804, t0
|
||||
|
||||
li t0, 0x88
|
||||
csrw mstatus, t0
|
||||
la t0, _vector_base
|
||||
|
||||
/* 配置向量表模式为绝对地址模式 */
|
||||
ori t0, t0, 3
|
||||
csrw mtvec, t0
|
||||
|
||||
la t0, main
|
||||
csrw mepc, t0
|
||||
|
||||
mret
|
||||
@@ -0,0 +1,257 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH59x_adc.c
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2021/11/17
|
||||
* Description
|
||||
*********************************************************************************
|
||||
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "CH59x_common.h"
|
||||
|
||||
/*********************************************************************
|
||||
* @fn ADC_DataCalib_Rough
|
||||
*
|
||||
* @brief 采样数据粗调,获取偏差值,必须先配置ADC后调用此函数获取校准值
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return 偏差
|
||||
*/
|
||||
signed short ADC_DataCalib_Rough(void) // 采样数据粗调,获取偏差值
|
||||
{
|
||||
uint16_t i;
|
||||
uint32_t sum = 0;
|
||||
uint8_t ch = 0; // 备份通道
|
||||
uint8_t cfg = 0; // 备份
|
||||
|
||||
ch = R8_ADC_CHANNEL;
|
||||
cfg = R8_ADC_CFG;
|
||||
|
||||
R8_ADC_CFG |= RB_ADC_OFS_TEST; // 进入测试模式
|
||||
R8_ADC_CFG &= ~RB_ADC_DIFF_EN; // 关闭差分
|
||||
|
||||
R8_ADC_CONVERT |= RB_ADC_START;
|
||||
while(R8_ADC_CONVERT & RB_ADC_START);
|
||||
for(i = 0; i < 16; i++)
|
||||
{
|
||||
R8_ADC_CONVERT |= RB_ADC_START;
|
||||
while(R8_ADC_CONVERT & RB_ADC_START);
|
||||
sum += (~R16_ADC_DATA) & RB_ADC_DATA;
|
||||
}
|
||||
sum = (sum + 8) >> 4;
|
||||
|
||||
R8_ADC_CFG = cfg; // 恢复配置值
|
||||
R8_ADC_CHANNEL = ch;
|
||||
|
||||
return (2048 - sum);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn ADC_ExtSingleChSampInit
|
||||
*
|
||||
* @brief 外部信号单通道采样初始化
|
||||
*
|
||||
* @param sp - refer to ADC_SampClkTypeDef
|
||||
* @param ga - refer to ADC_SignalPGATypeDef
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void ADC_ExtSingleChSampInit(ADC_SampClkTypeDef sp, ADC_SignalPGATypeDef ga)
|
||||
{
|
||||
R8_TKEY_CFG &= ~RB_TKEY_PWR_ON;
|
||||
R8_ADC_CFG = RB_ADC_POWER_ON | RB_ADC_BUF_EN | (sp << 6) | ((ga&0xF) << 4);
|
||||
if( ga & ADC_PGA_2_ )
|
||||
{
|
||||
R8_ADC_CONVERT |= RB_ADC_PGA_GAIN2;
|
||||
}
|
||||
else
|
||||
{
|
||||
R8_ADC_CONVERT &= ~RB_ADC_PGA_GAIN2;
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn ADC_ExtDiffChSampInit
|
||||
*
|
||||
* @brief 外部信号差分通道采样初始化
|
||||
*
|
||||
* @param sp - refer to ADC_SampClkTypeDef
|
||||
* @param ga - refer to ADC_SignalPGATypeDef
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void ADC_ExtDiffChSampInit(ADC_SampClkTypeDef sp, ADC_SignalPGATypeDef ga)
|
||||
{
|
||||
R8_TKEY_CFG &= ~RB_TKEY_PWR_ON;
|
||||
R8_ADC_CFG = RB_ADC_POWER_ON | RB_ADC_DIFF_EN | (sp << 6) | ((ga&0xF) << 4);
|
||||
if( ga & ADC_PGA_2_ )
|
||||
{
|
||||
R8_ADC_CONVERT |= RB_ADC_PGA_GAIN2;
|
||||
}
|
||||
else
|
||||
{
|
||||
R8_ADC_CONVERT &= ~RB_ADC_PGA_GAIN2;
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn ADC_InterTSSampInit
|
||||
*
|
||||
* @brief 内置温度传感器采样初始化
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void ADC_InterTSSampInit(void)
|
||||
{
|
||||
R8_TKEY_CFG &= ~RB_TKEY_PWR_ON;
|
||||
R8_TEM_SENSOR = RB_TEM_SEN_PWR_ON;
|
||||
R8_ADC_CHANNEL = CH_INTE_VTEMP;
|
||||
R8_ADC_CFG = RB_ADC_POWER_ON | RB_ADC_DIFF_EN | (3 << 4);
|
||||
R8_ADC_CONVERT &= ~RB_ADC_PGA_GAIN2;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn ADC_InterBATSampInit
|
||||
*
|
||||
* @brief 内置电池电压采样初始化
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void ADC_InterBATSampInit(void)
|
||||
{
|
||||
R8_TKEY_CFG &= ~RB_TKEY_PWR_ON;
|
||||
R8_ADC_CHANNEL = CH_INTE_VBAT;
|
||||
R8_ADC_CFG = RB_ADC_POWER_ON | RB_ADC_BUF_EN | (0 << 4); // 使用-12dB模式
|
||||
R8_ADC_CONVERT &= ~RB_ADC_PGA_GAIN2;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn TouchKey_ChSampInit
|
||||
*
|
||||
* @brief 触摸按键通道采样初始化
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void TouchKey_ChSampInit(void)
|
||||
{
|
||||
R8_ADC_CFG = RB_ADC_POWER_ON | RB_ADC_BUF_EN | (ADC_PGA_0 << 4) | (SampleFreq_8 << 6);
|
||||
R8_ADC_CONVERT &= ~RB_ADC_PGA_GAIN2;
|
||||
R8_TKEY_CFG |= RB_TKEY_PWR_ON;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn ADC_ExcutSingleConver
|
||||
*
|
||||
* @brief ADC执行单次转换
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return ADC转换后的数据
|
||||
*/
|
||||
uint16_t ADC_ExcutSingleConver(void)
|
||||
{
|
||||
R8_ADC_CONVERT |= RB_ADC_START;
|
||||
while(R8_ADC_CONVERT & RB_ADC_START);
|
||||
|
||||
return (R16_ADC_DATA & RB_ADC_DATA);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn TouchKey_ExcutSingleConver
|
||||
*
|
||||
* @brief TouchKey转换后数据
|
||||
*
|
||||
* @param charg - Touchkey充电时间,5bits有效, t=charg*Tadc
|
||||
* @param disch - Touchkey放电时间,3bits有效, t=disch*Tadc
|
||||
*
|
||||
* @return 当前TouchKey等效数据
|
||||
*/
|
||||
uint16_t TouchKey_ExcutSingleConver(uint8_t charg, uint8_t disch)
|
||||
{
|
||||
R8_TKEY_COUNT = (disch << 5) | (charg & 0x1f);
|
||||
R8_TKEY_CONVERT = RB_TKEY_START;
|
||||
while(R8_TKEY_CONVERT & RB_TKEY_START);
|
||||
return (R16_ADC_DATA & RB_ADC_DATA);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn ADC_AutoConverCycle
|
||||
*
|
||||
* @brief 设置连续 ADC的周期
|
||||
*
|
||||
* @param cycle - 采样周期计算方法为(256-cycle)*16*Tsys
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void ADC_AutoConverCycle(uint8_t cycle)
|
||||
{
|
||||
R8_ADC_AUTO_CYCLE = cycle;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn ADC_DMACfg
|
||||
*
|
||||
* @brief 配置DMA功能
|
||||
*
|
||||
* @param s - 是否打开DMA功能
|
||||
* @param startAddr - DMA 起始地址
|
||||
* @param endAddr - DMA 结束地址
|
||||
* @param m - 配置DMA模式
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void ADC_DMACfg(uint8_t s, uint32_t startAddr, uint32_t endAddr, ADC_DMAModeTypeDef m)
|
||||
{
|
||||
if(s == DISABLE)
|
||||
{
|
||||
R8_ADC_CTRL_DMA &= ~(RB_ADC_DMA_ENABLE | RB_ADC_IE_DMA_END);
|
||||
}
|
||||
else
|
||||
{
|
||||
R16_ADC_DMA_BEG = startAddr&0xFFFF;
|
||||
R16_ADC_DMA_END = endAddr&0xFFFF;
|
||||
if(m)
|
||||
{
|
||||
R8_ADC_CTRL_DMA |= RB_ADC_DMA_LOOP | RB_ADC_IE_DMA_END | RB_ADC_DMA_ENABLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
R8_ADC_CTRL_DMA &= ~RB_ADC_DMA_LOOP;
|
||||
R8_ADC_CTRL_DMA |= RB_ADC_IE_DMA_END | RB_ADC_DMA_ENABLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn adc_to_temperature_celsius
|
||||
*
|
||||
* @brief Convert ADC value to temperature(Celsius)
|
||||
*
|
||||
* @param adc_val - adc value
|
||||
*
|
||||
* @return temperature (Celsius)
|
||||
*/
|
||||
|
||||
int adc_to_temperature_celsius(uint16_t adc_val)
|
||||
{
|
||||
uint32_t C25 = 0;
|
||||
int temp;
|
||||
|
||||
C25 = (*((PUINT32)ROM_CFG_TMP_25C));
|
||||
|
||||
/* current temperature = standard temperature + (adc deviation * adc linearity coefficient) */
|
||||
temp = (((C25 >> 16) & 0xFFFF) ? ((C25 >> 16) & 0xFFFF) : 25) + \
|
||||
(adc_val - ((int)(C25 & 0xFFFF))) * 100 / 283;
|
||||
|
||||
return (temp);
|
||||
}
|
||||
@@ -0,0 +1,624 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH59x_clk.c
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2021/11/17
|
||||
* Description
|
||||
*********************************************************************************
|
||||
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "CH59x_common.h"
|
||||
|
||||
/*********************************************************************
|
||||
* @fn LClk32K_Select
|
||||
*
|
||||
* @brief 32K 低频时钟来源
|
||||
*
|
||||
* @param hc - 选择32K使用内部还是外部
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void LClk32K_Select(LClk32KTypeDef hc)
|
||||
{
|
||||
uint8_t cfg = R8_CK32K_CONFIG;
|
||||
|
||||
if(hc == Clk32K_LSI)
|
||||
{
|
||||
cfg &= ~RB_CLK_OSC32K_XT;
|
||||
LSECFG_Current(LSE_RCur_100);
|
||||
}
|
||||
else
|
||||
{
|
||||
cfg |= RB_CLK_OSC32K_XT;
|
||||
}
|
||||
|
||||
sys_safe_access_enable();
|
||||
R8_CK32K_CONFIG = cfg;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn LClk32K_Cfg
|
||||
*
|
||||
* @brief 32K 低频时钟电源配置
|
||||
*
|
||||
* @param hc - 选择内部32K还是外部32K
|
||||
* @param s - 是否打开电源
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void LClk32K_Cfg(LClk32KTypeDef hc, FunctionalState s)
|
||||
{
|
||||
uint8_t cfg = R8_CK32K_CONFIG;
|
||||
|
||||
if(hc == Clk32K_LSI)
|
||||
{
|
||||
if(s == DISABLE)
|
||||
{
|
||||
cfg &= ~RB_CLK_INT32K_PON;
|
||||
}
|
||||
else
|
||||
{
|
||||
cfg |= RB_CLK_INT32K_PON;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(s == DISABLE)
|
||||
{
|
||||
cfg &= ~RB_CLK_XT32K_PON;
|
||||
}
|
||||
else
|
||||
{
|
||||
cfg |= RB_CLK_XT32K_PON;
|
||||
}
|
||||
}
|
||||
|
||||
sys_safe_access_enable();
|
||||
R8_CK32K_CONFIG = cfg;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn HSECFG_Current
|
||||
*
|
||||
* @brief HSE晶体 偏置电流配置
|
||||
*
|
||||
* @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晶体 负载电容配置
|
||||
*
|
||||
* @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 & 0x8f) | (c << 4);
|
||||
|
||||
sys_safe_access_enable();
|
||||
R8_XT32M_TUNE = x32M_c;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn LSECFG_Current
|
||||
*
|
||||
* @brief LSE晶体 偏置电流配置
|
||||
*
|
||||
* @param c - 70%,100%,140%,200%
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void LSECFG_Current(LSECurrentTypeDef c)
|
||||
{
|
||||
uint8_t x32K_c;
|
||||
|
||||
x32K_c = R8_XT32K_TUNE;
|
||||
x32K_c = (x32K_c & 0xfc) | (c & 0x03);
|
||||
|
||||
sys_safe_access_enable();
|
||||
R8_XT32K_TUNE = x32K_c;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn LSECFG_Capacitance
|
||||
*
|
||||
* @brief LSE晶体 负载电容配置
|
||||
*
|
||||
* @param c - refer to LSECapTypeDef
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void LSECFG_Capacitance(LSECapTypeDef c)
|
||||
{
|
||||
uint8_t x32K_c;
|
||||
|
||||
x32K_c = R8_XT32K_TUNE;
|
||||
x32K_c = (x32K_c & 0x0f) | (c << 4);
|
||||
|
||||
sys_safe_access_enable();
|
||||
R8_XT32K_TUNE = x32K_c;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn Calibration_LSI
|
||||
*
|
||||
* @brief 校准内部32K时钟
|
||||
*
|
||||
* @param cali_Lv - 校准等级选择 Level_32 :2.4ms 1000ppm (32M 主频) 1100ppm (60M 主频)
|
||||
* Level_64 :4.4ms 800ppm (32M 主频) 1000ppm (60M 主频)
|
||||
* Level_128 :8.4ms 600ppm (32M 主频) 800ppm (60M 主频)
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void Calibration_LSI(Cali_LevelTypeDef cali_Lv)
|
||||
{
|
||||
UINT64 i;
|
||||
long long cnt_offset;
|
||||
UINT8 retry = 0;
|
||||
UINT8 retry_all = 0;
|
||||
INT32 freq_sys;
|
||||
UINT32 cnt_32k = 0;
|
||||
UINT32 irqv = 0;
|
||||
|
||||
freq_sys = GetSysClock();
|
||||
|
||||
sys_safe_access_enable();
|
||||
R8_CK32K_CONFIG &= ~RB_CLK_OSC32K_FILT;
|
||||
R8_CK32K_CONFIG |= RB_CLK_OSC32K_FILT;
|
||||
sys_safe_access_disable();
|
||||
LSECFG_Current(LSE_RCur_100);
|
||||
|
||||
while(1)
|
||||
{
|
||||
// 粗调
|
||||
sys_safe_access_enable();
|
||||
R8_OSC_CAL_CTRL &= ~RB_OSC_CNT_TOTAL;
|
||||
R8_OSC_CAL_CTRL |= 1;
|
||||
sys_safe_access_disable();
|
||||
|
||||
while(1)
|
||||
{
|
||||
sys_safe_access_enable();
|
||||
R8_OSC_CAL_CTRL |= RB_OSC_CNT_EN;
|
||||
R16_OSC_CAL_CNT |= RB_OSC_CAL_OV_CLR;
|
||||
R16_OSC_CAL_CNT |= RB_OSC_CAL_IF;
|
||||
sys_safe_access_disable();
|
||||
while( (R8_OSC_CAL_CTRL & RB_OSC_CNT_EN) == 0 )
|
||||
{
|
||||
sys_safe_access_enable();
|
||||
R8_OSC_CAL_CTRL |= RB_OSC_CNT_EN;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
|
||||
while(!(R8_OSC_CAL_CTRL & RB_OSC_CNT_HALT)); // 用于丢弃
|
||||
|
||||
SYS_DisableAllIrq(&irqv);
|
||||
sys_safe_access_enable();
|
||||
R8_OSC_CAL_CTRL &= ~RB_OSC_CNT_EN;
|
||||
R8_OSC_CAL_CTRL |= RB_OSC_CNT_EN;
|
||||
R16_OSC_CAL_CNT |= RB_OSC_CAL_OV_CLR;
|
||||
R16_OSC_CAL_CNT |= RB_OSC_CAL_IF;
|
||||
sys_safe_access_disable();
|
||||
while( (R8_OSC_CAL_CTRL & RB_OSC_CNT_EN) == 0 )
|
||||
{
|
||||
sys_safe_access_enable();
|
||||
R8_OSC_CAL_CTRL |= RB_OSC_CNT_EN;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
|
||||
while(R8_OSC_CAL_CTRL & RB_OSC_CNT_HALT);
|
||||
cnt_32k = RTC_GetCycle32k();
|
||||
while(RTC_GetCycle32k() == cnt_32k);
|
||||
R16_OSC_CAL_CNT |= RB_OSC_CAL_OV_CLR;
|
||||
SYS_RecoverIrq(irqv);
|
||||
while(!(R8_OSC_CAL_CTRL & RB_OSC_CNT_HALT));
|
||||
i = R16_OSC_CAL_CNT; // 实时校准后采样值
|
||||
cnt_offset = (i & 0x3FFF) + R8_OSC_CAL_OV_CNT * 0x3FFF - 2000 * (freq_sys / 1000) / CAB_LSIFQ;
|
||||
if(((cnt_offset > -37 * (freq_sys / 1000) / 60000) && (cnt_offset < 37 * (freq_sys / 1000) / 60000)) || retry > 2)
|
||||
{
|
||||
if(retry)
|
||||
break;
|
||||
}
|
||||
retry++;
|
||||
cnt_offset = (cnt_offset > 0) ? (((cnt_offset * 2) / (74 * (freq_sys/1000) / 60000)) + 1) / 2 : (((cnt_offset * 2) / (74 * (freq_sys/1000) / 60000 )) - 1) / 2;
|
||||
sys_safe_access_enable();
|
||||
R16_INT32K_TUNE += cnt_offset;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
|
||||
// 细调
|
||||
// 配置细调参数后,丢弃2次捕获值(软件行为)上判断已有一次,这里只留一次
|
||||
sys_safe_access_enable();
|
||||
R8_OSC_CAL_CTRL &= ~RB_OSC_CNT_TOTAL;
|
||||
R8_OSC_CAL_CTRL |= cali_Lv;
|
||||
sys_safe_access_disable();
|
||||
while( (R8_OSC_CAL_CTRL & RB_OSC_CNT_TOTAL) != cali_Lv )
|
||||
{
|
||||
sys_safe_access_enable();
|
||||
R8_OSC_CAL_CTRL |= cali_Lv;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
|
||||
sys_safe_access_enable();
|
||||
R8_OSC_CAL_CTRL &= ~RB_OSC_CNT_EN;
|
||||
R8_OSC_CAL_CTRL |= RB_OSC_CNT_EN;
|
||||
R16_OSC_CAL_CNT |= RB_OSC_CAL_OV_CLR;
|
||||
R16_OSC_CAL_CNT |= RB_OSC_CAL_IF;
|
||||
sys_safe_access_disable();
|
||||
while( (R8_OSC_CAL_CTRL & RB_OSC_CNT_EN) == 0 )
|
||||
{
|
||||
sys_safe_access_enable();
|
||||
R8_OSC_CAL_CTRL |= RB_OSC_CNT_EN;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
|
||||
while(!(R8_OSC_CAL_CTRL & RB_OSC_CNT_HALT)); // 用于丢弃
|
||||
|
||||
SYS_DisableAllIrq(&irqv);
|
||||
sys_safe_access_enable();
|
||||
R8_OSC_CAL_CTRL &= ~RB_OSC_CNT_EN;
|
||||
R8_OSC_CAL_CTRL |= RB_OSC_CNT_EN;
|
||||
R16_OSC_CAL_CNT |= RB_OSC_CAL_OV_CLR;
|
||||
R16_OSC_CAL_CNT |= RB_OSC_CAL_IF;
|
||||
sys_safe_access_disable();
|
||||
while( (R8_OSC_CAL_CTRL & RB_OSC_CNT_EN) == 0 )
|
||||
{
|
||||
sys_safe_access_enable();
|
||||
R8_OSC_CAL_CTRL |= RB_OSC_CNT_EN;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
|
||||
while(R8_OSC_CAL_CTRL & RB_OSC_CNT_HALT);
|
||||
cnt_32k = RTC_GetCycle32k();
|
||||
while(RTC_GetCycle32k() == cnt_32k);
|
||||
R16_OSC_CAL_CNT |= RB_OSC_CAL_OV_CLR;
|
||||
SYS_RecoverIrq(irqv);
|
||||
while(!(R8_OSC_CAL_CTRL & RB_OSC_CNT_HALT));
|
||||
sys_safe_access_enable();
|
||||
R8_OSC_CAL_CTRL &= ~RB_OSC_CNT_EN;
|
||||
sys_safe_access_disable();
|
||||
i = R16_OSC_CAL_CNT; // 实时校准后采样值
|
||||
cnt_offset = (i & 0x3FFF) + R8_OSC_CAL_OV_CNT * 0x3FFF - 4000 * (1 << cali_Lv) * (freq_sys / 1000000) / 256 * 1000/(CAB_LSIFQ/256);
|
||||
cnt_offset = (cnt_offset > 0) ? ((((cnt_offset * 2*(100 )) / (1366 * ((1 << cali_Lv)/8) * (freq_sys/1000) / 60000)) + 1) / 2) : ((((cnt_offset * 2*(100)) / (1366 * ((1 << cali_Lv)/8) * (freq_sys/1000) / 60000)) - 1) / 2);
|
||||
if((cnt_offset > 0)&&(((R16_INT32K_TUNE>>5)+cnt_offset)>0xFF))
|
||||
{
|
||||
if(retry_all>2)
|
||||
{
|
||||
sys_safe_access_enable();
|
||||
R16_INT32K_TUNE |= (0xFF<<5);
|
||||
sys_safe_access_disable();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
sys_safe_access_enable();
|
||||
R16_INT32K_TUNE = (R16_INT32K_TUNE&0x1F)|(0x7F<<5);
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
}
|
||||
else if((cnt_offset < 0)&&((R16_INT32K_TUNE>>5)<(-cnt_offset)))
|
||||
{
|
||||
if(retry_all>2)
|
||||
{
|
||||
sys_safe_access_enable();
|
||||
R16_INT32K_TUNE &= 0x1F;
|
||||
sys_safe_access_disable();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
sys_safe_access_enable();
|
||||
R16_INT32K_TUNE = (R16_INT32K_TUNE&0x1F)|(0x7F<<5);
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sys_safe_access_enable();
|
||||
R16_INT32K_TUNE += (cnt_offset<<5);
|
||||
sys_safe_access_disable();
|
||||
return;
|
||||
}
|
||||
retry_all++;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn RTCInitTime
|
||||
*
|
||||
* @brief RTC时钟初始化当前时间
|
||||
*
|
||||
* @param y - 配置年,MAX_Y = BEGYEAR + 44
|
||||
* @param mon - 配置月,MAX_MON = 12
|
||||
* @param d - 配置日,MAX_D = 31
|
||||
* @param h - 配置小时,MAX_H = 23
|
||||
* @param m - 配置分钟,MAX_M = 59
|
||||
* @param s - 配置秒,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;
|
||||
uint16_t year, month, day, sec2, t32k;
|
||||
volatile uint8_t clk_pin;
|
||||
|
||||
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) ? (0x8000) : (0);
|
||||
t = sec2;
|
||||
t = t << 16 | t32k;
|
||||
|
||||
do
|
||||
{
|
||||
clk_pin = (R8_CK32K_CONFIG & RB_32K_CLK_PIN);
|
||||
} while(clk_pin != (R8_CK32K_CONFIG & RB_32K_CLK_PIN));
|
||||
if(!clk_pin)
|
||||
{
|
||||
while(!clk_pin)
|
||||
{
|
||||
do
|
||||
{
|
||||
clk_pin = (R8_CK32K_CONFIG & RB_32K_CLK_PIN);
|
||||
} while(clk_pin != (R8_CK32K_CONFIG & RB_32K_CLK_PIN));
|
||||
}
|
||||
}
|
||||
|
||||
sys_safe_access_enable();
|
||||
R32_RTC_TRIG = day;
|
||||
R8_RTC_MODE_CTRL |= RB_RTC_LOAD_HI;
|
||||
sys_safe_access_disable();
|
||||
while((R32_RTC_TRIG & 0x3FFF) != (R32_RTC_CNT_DAY & 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 获取当前时间
|
||||
*
|
||||
* @param py - 获取到的年,MAX_Y = BEGYEAR + 44
|
||||
* @param pmon - 获取到的月,MAX_MON = 12
|
||||
* @param pd - 获取到的日,MAX_D = 31
|
||||
* @param ph - 获取到的小时,MAX_H = 23
|
||||
* @param pm - 获取到的分钟,MAX_M = 59
|
||||
* @param ps - 获取到的秒,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;
|
||||
uint16_t day, sec2, t32k;
|
||||
|
||||
day = R32_RTC_CNT_DAY & 0x3FFF;
|
||||
sec2 = R16_RTC_CNT_2S;
|
||||
t32k = R16_RTC_CNT_32K;
|
||||
|
||||
t = sec2 * 2 + ((t32k < 0x8000) ? 0 : 1);
|
||||
|
||||
*py = BEGYEAR;
|
||||
while(day >= YearLength(*py))
|
||||
{
|
||||
day -= YearLength(*py);
|
||||
(*py)++;
|
||||
}
|
||||
|
||||
*pmon = 0;
|
||||
while(day >= monthLength(IsLeapYear(*py), *pmon))
|
||||
{
|
||||
day -= monthLength(IsLeapYear(*py), *pmon);
|
||||
(*pmon)++;
|
||||
}
|
||||
(*pmon)++;
|
||||
*pd = day + 1;
|
||||
*ph = t / 3600;
|
||||
*pm = t % 3600 / 60;
|
||||
*ps = t % 60;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn RTC_SetCycle32k
|
||||
*
|
||||
* @brief 基于LSE/LSI时钟,配置当前RTC 周期数
|
||||
*
|
||||
* @param cyc - 配置周期计数初值,MAX_CYC = 0xA8BFFFFF = 2831155199
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void RTC_SetCycle32k(uint32_t cyc)
|
||||
{
|
||||
volatile uint8_t clk_pin;
|
||||
|
||||
do
|
||||
{
|
||||
clk_pin = (R8_CK32K_CONFIG & RB_32K_CLK_PIN);
|
||||
} while((clk_pin != (R8_CK32K_CONFIG & RB_32K_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_GetCycle32k
|
||||
*
|
||||
* @brief 基于LSE/LSI时钟,获取当前RTC 周期数
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return 当前周期数,MAX_CYC = 0xA8BFFFFF = 2831155199
|
||||
*/
|
||||
__HIGH_CODE
|
||||
uint32_t RTC_GetCycle32k(void)
|
||||
{
|
||||
volatile uint32_t i;
|
||||
|
||||
do
|
||||
{
|
||||
i = R32_RTC_CNT_32K;
|
||||
} while(i != R32_RTC_CNT_32K);
|
||||
|
||||
return (i);
|
||||
}
|
||||
/*********************************************************************
|
||||
* @fn RTC_TMRFunCfg
|
||||
*
|
||||
* @brief RTC定时模式配置(注意定时基准固定为32768Hz)
|
||||
*
|
||||
* @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时间触发模式配置
|
||||
*
|
||||
* @param cyc - 相对当前时间的触发间隔时间,基于LSE/LSI时钟周期数
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void RTC_TRIGFunCfg(uint32_t cyc)
|
||||
{
|
||||
uint32_t t;
|
||||
|
||||
t = RTC_GetCycle32k() + 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 模式功能关闭
|
||||
*
|
||||
* @param m - 需要关闭的当前模式
|
||||
*
|
||||
* @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 获取RTC中断标志
|
||||
*
|
||||
* @param f - refer to RTC_EVENTTypeDef
|
||||
*
|
||||
* @return 中断标志状态
|
||||
*/
|
||||
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 清除RTC中断标志
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH59x_flash.c
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2021/11/17
|
||||
* Description
|
||||
*********************************************************************************
|
||||
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "CH59x_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.需在调用用户配置字生效函数后生效,且每次烧录后只能修改一次
|
||||
* (使用该函数,必须使用官方提供的.S文件,同时调用该函数后,两次上电后,两线调试接口默认关闭)
|
||||
*
|
||||
* @param RESET_EN - 外部复位引脚使能
|
||||
* @param BOOT_PIN - ENABLE-使用默认boot脚-PB22,DISABLE-使用boot脚-PB11
|
||||
* @param UART_NO_KEY_EN - 串口免按键下载使能
|
||||
* @param FLASHProt_Size - 写保护大小(单位4K)
|
||||
*
|
||||
* @return 0-Success, 1-Err
|
||||
*/
|
||||
uint8_t UserOptionByteConfig(FunctionalState RESET_EN, FunctionalState BOOT_PIN, 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, 0x7EFFC, &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); //高8位 配置信息取反;
|
||||
|
||||
if(BOOT_PIN == ENABLE)
|
||||
s |= BOOT_PIN_PB22;
|
||||
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 关两线调试接口,其余配置值保持不变.需在调用用户配置字生效函数后生效,且每次烧录后只能修改一次
|
||||
* (使用该函数,必须使用官方提供的.S文件,同时调用该函数后,两次上电后,两线调试接口默认关闭)
|
||||
*
|
||||
* @return 0-Success, 1-Err
|
||||
*/
|
||||
uint8_t UserOptionByteClose_SWD(void)
|
||||
{
|
||||
uint32_t s, t;
|
||||
|
||||
FLASH_ROM_READ(0x14, &s, 4);
|
||||
|
||||
if(s == 0xF3F9BDA9)
|
||||
{
|
||||
FLASH_EEPROM_CMD(CMD_GET_ROM_INFO, 0x7EFFC, &s, 4);
|
||||
|
||||
s &= ~((1 << 4) | (1 << 7)); //禁用调试功能, 禁用SPI读写FLASH
|
||||
|
||||
/* bit[7:0]-bit[31-24] */
|
||||
s &= 0x00FFFFFF;
|
||||
s |= ((~(s << 24)) & 0xFF000000); //高8位 配置信息取反;
|
||||
|
||||
/*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 UserOptionByte_Active
|
||||
*
|
||||
* @brief 用户配置字生效函数,执行后自动复位
|
||||
*
|
||||
* @return 0-Success, 1-Err
|
||||
*/
|
||||
void UserOptionByte_Active(void)
|
||||
{
|
||||
FLASH_ROM_SW_RESET();
|
||||
sys_safe_access_enable();
|
||||
R16_INT32K_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;
|
||||
}
|
||||
@@ -0,0 +1,250 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH59x_gpio.c
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2021/11/17
|
||||
* Description
|
||||
*********************************************************************************
|
||||
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "CH59x_common.h"
|
||||
|
||||
/*********************************************************************
|
||||
* @fn GPIOA_ModeCfg
|
||||
*
|
||||
* @brief GPIOA端口引脚模式配置
|
||||
*
|
||||
* @param pin - PA0-PA15
|
||||
* @param mode - 输入输出类型
|
||||
*
|
||||
* @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 GPIOB_ModeCfg
|
||||
*
|
||||
* @brief GPIOB端口引脚模式配置
|
||||
*
|
||||
* @param pin - PB0-PB23
|
||||
* @param mode - 输入输出类型
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void GPIOB_ModeCfg(uint32_t pin, GPIOModeTypeDef mode)
|
||||
{
|
||||
switch(mode)
|
||||
{
|
||||
case GPIO_ModeIN_Floating:
|
||||
R32_PB_PD_DRV &= ~pin;
|
||||
R32_PB_PU &= ~pin;
|
||||
R32_PB_DIR &= ~pin;
|
||||
break;
|
||||
|
||||
case GPIO_ModeIN_PU:
|
||||
R32_PB_PD_DRV &= ~pin;
|
||||
R32_PB_PU |= pin;
|
||||
R32_PB_DIR &= ~pin;
|
||||
break;
|
||||
|
||||
case GPIO_ModeIN_PD:
|
||||
R32_PB_PD_DRV |= pin;
|
||||
R32_PB_PU &= ~pin;
|
||||
R32_PB_DIR &= ~pin;
|
||||
break;
|
||||
|
||||
case GPIO_ModeOut_PP_5mA:
|
||||
R32_PB_PD_DRV &= ~pin;
|
||||
R32_PB_DIR |= pin;
|
||||
break;
|
||||
|
||||
case GPIO_ModeOut_PP_20mA:
|
||||
R32_PB_PD_DRV |= pin;
|
||||
R32_PB_DIR |= pin;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn GPIOA_ITModeCfg
|
||||
*
|
||||
* @brief GPIOA引脚中断模式配置
|
||||
*
|
||||
* @param pin - PA0-PA15
|
||||
* @param mode - 触发类型
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void GPIOA_ITModeCfg(uint32_t pin, GPIOITModeTpDef mode)
|
||||
{
|
||||
switch(mode)
|
||||
{
|
||||
case GPIO_ITMode_LowLevel: // 低电平触发
|
||||
R16_PA_INT_MODE &= ~pin;
|
||||
R32_PA_CLR |= pin;
|
||||
break;
|
||||
|
||||
case GPIO_ITMode_HighLevel: // 高电平触发
|
||||
R16_PA_INT_MODE &= ~pin;
|
||||
R32_PA_OUT |= pin;
|
||||
break;
|
||||
|
||||
case GPIO_ITMode_FallEdge: // 下降沿触发
|
||||
R16_PA_INT_MODE |= pin;
|
||||
R32_PA_CLR |= pin;
|
||||
break;
|
||||
|
||||
case GPIO_ITMode_RiseEdge: // 上升沿触发
|
||||
R16_PA_INT_MODE |= pin;
|
||||
R32_PA_OUT |= pin;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
R16_PA_INT_IF = pin;
|
||||
R16_PA_INT_EN |= pin;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn GPIOB_ITModeCfg
|
||||
*
|
||||
* @brief GPIOB引脚中断模式配置
|
||||
*
|
||||
* @param pin - PB0-PB23
|
||||
* @param mode - 触发类型
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void GPIOB_ITModeCfg(uint32_t pin, GPIOITModeTpDef mode)
|
||||
{
|
||||
uint32_t Pin = pin | ((pin & (GPIO_Pin_22 | GPIO_Pin_23)) >> 14);
|
||||
switch(mode)
|
||||
{
|
||||
case GPIO_ITMode_LowLevel: // 低电平触发
|
||||
R16_PB_INT_MODE &= ~Pin;
|
||||
R32_PB_CLR |= pin;
|
||||
break;
|
||||
|
||||
case GPIO_ITMode_HighLevel: // 高电平触发
|
||||
R16_PB_INT_MODE &= ~Pin;
|
||||
R32_PB_OUT |= pin;
|
||||
break;
|
||||
|
||||
case GPIO_ITMode_FallEdge: // 下降沿触发
|
||||
R16_PB_INT_MODE |= Pin;
|
||||
R32_PB_CLR |= pin;
|
||||
break;
|
||||
|
||||
case GPIO_ITMode_RiseEdge: // 上升沿触发
|
||||
R16_PB_INT_MODE |= Pin;
|
||||
R32_PB_OUT |= pin;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
R16_PB_INT_IF = Pin;
|
||||
R16_PB_INT_EN |= Pin;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn GPIOPinRemap
|
||||
*
|
||||
* @brief 外设功能引脚映射
|
||||
*
|
||||
* @param s - 是否使能映射
|
||||
* @param perph - RB_RF_ANT_SW_EN - RF antenna switch control output on PA4/PA5/PA12/PA13/PA14/PA15
|
||||
* RB_PIN_U0_INV - RXD0/RXD0_/TXD0/TXD0_ invert input/output
|
||||
* RB_PIN_INTX - INTX: INT24/INT25 PB8/PB9 -> INT24_/INT25_ PB22/PB23
|
||||
* RB_PIN_MODEM - MODEM: PA6/PA7 -> PB12/PB13
|
||||
* RB_PIN_I2C - I2C: PB14/PB15 -> PB14/PB15
|
||||
* RB_PIN_PWMX - PWMX: PA12/PA13 -> PA6/PA7
|
||||
* RB_PIN_SPI0 - SPI0: PA12/PA13/PA14/PA15 -> PB12/PB13/PB14/PB15
|
||||
* RB_PIN_UART3 - UART3: PA4/PA5 -> PA4/PA5
|
||||
* RB_PIN_UART2 - UART2: PB22/PB23 -> PA6/PA7
|
||||
* RB_PIN_UART1 - UART1: PA8/PA9 -> PB12/PB13
|
||||
* RB_PIN_UART0 - UART0: PB4/PB7 -> PA15/PA14
|
||||
* RB_PIN_TMR3 - TMR2: PB22 -> PB22
|
||||
* RB_PIN_TMR2 - TMR2: PA11 -> PB11
|
||||
* RB_PIN_TMR1 - TMR1: PA10 -> PB10
|
||||
* RB_PIN_TMR0 - TMR0: PA9 -> PB23
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void GPIOPinRemap(FunctionalState s, uint16_t perph)
|
||||
{
|
||||
if(s)
|
||||
{
|
||||
R16_PIN_ALTERNATE |= perph;
|
||||
}
|
||||
else
|
||||
{
|
||||
R16_PIN_ALTERNATE &= ~perph;
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn GPIOAGPPCfg
|
||||
*
|
||||
* @brief 模拟外设GPIO引脚功能控制
|
||||
*
|
||||
* @param s - ENABLE - 打开模拟外设功能,关闭数字功能
|
||||
* DISABLE - 启用数字功能,关闭模拟外设功能
|
||||
* @param perph - RB_PIN_USB_DP_PU - USB UD+引脚内部上拉电阻
|
||||
* RB_PIN_USB_IE - USB 引脚
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void GPIOAGPPCfg(FunctionalState s, uint16_t perph)
|
||||
{
|
||||
if(s)
|
||||
{
|
||||
R16_PIN_ANALOG_IE |= perph;
|
||||
}
|
||||
else
|
||||
{
|
||||
R16_PIN_ANALOG_IE &= ~perph;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,672 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH59x_i2c.c
|
||||
* Author : WCH
|
||||
* Version : V1.0
|
||||
* Date : 2021/03/15
|
||||
* Description
|
||||
*********************************************************************************
|
||||
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "CH59x_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 I2C_ClockSpeed, I2C_DutyTypeDef I2C_DutyCycle,
|
||||
I2C_AckTypeDef I2C_Ack, I2C_AckAddrTypeDef I2C_AckAddr, UINT16 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 &= ~0xFFFF;
|
||||
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;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH59x_lcd.c
|
||||
* Author : WCH
|
||||
* Version : V1.0
|
||||
* Date : 2018/12/15
|
||||
* Description
|
||||
*********************************************************************************
|
||||
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "CH59x_common.h"
|
||||
#include "CH59x_lcd.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : LCD_DefInit
|
||||
* Description : LCD段式屏驱动初始化配置
|
||||
* Input : duty 占空比
|
||||
* bias 偏压比
|
||||
* Return : None
|
||||
*******************************************************************************/
|
||||
void LCD_Init(LCDDutyTypeDef duty, LCDBiasTypeDef bias)
|
||||
{
|
||||
R32_PIN_CONFIG2 = 0xfffeff3f; // 关闭数字输入
|
||||
R16_PIN_ALTERNATE |= RB_DEBUG_EN; // 操作LCD时,需关闭debug
|
||||
R32_LCD_CMD = 0x1ffff << 8;
|
||||
R32_LCD_CMD |= RB_LCD_SYS_EN | RB_LCD_ON |
|
||||
(LCD_CLK_128 << 5) |
|
||||
(duty << 3) |
|
||||
(bias << 2);
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH59x_pwm.c
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2021/11/17
|
||||
* Description
|
||||
*********************************************************************************
|
||||
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "CH59x_common.h"
|
||||
|
||||
/*********************************************************************
|
||||
* @fn PWMX_CycleCfg
|
||||
*
|
||||
* @brief PWM4-PWM11周期配置
|
||||
*
|
||||
* @param cyc - refer to PWMX_CycleTypeDef
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void PWMX_CycleCfg(PWMX_CycleTypeDef cyc)
|
||||
{
|
||||
switch(cyc)
|
||||
{
|
||||
case PWMX_Cycle_256:
|
||||
R8_PWM_CONFIG = R8_PWM_CONFIG & 0xf0;
|
||||
break;
|
||||
|
||||
case PWMX_Cycle_255:
|
||||
R8_PWM_CONFIG = (R8_PWM_CONFIG & 0xf0) | 0x01;
|
||||
break;
|
||||
|
||||
case PWMX_Cycle_128:
|
||||
R8_PWM_CONFIG = (R8_PWM_CONFIG & 0xf0) | (1 << 2);
|
||||
break;
|
||||
|
||||
case PWMX_Cycle_127:
|
||||
R8_PWM_CONFIG = (R8_PWM_CONFIG & 0xf0) | (1 << 2) | 0x01;
|
||||
break;
|
||||
|
||||
case PWMX_Cycle_64:
|
||||
R8_PWM_CONFIG = (R8_PWM_CONFIG & 0xf0) | (2 << 2);
|
||||
break;
|
||||
|
||||
case PWMX_Cycle_63:
|
||||
R8_PWM_CONFIG = (R8_PWM_CONFIG & 0xf0) | (2 << 2) | 0x01;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn PWMX_16bit_CycleCfg
|
||||
*
|
||||
* @brief PWM4-PWM9 16位周期配置
|
||||
*
|
||||
* @param cyc - 16位周期
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void PWMX_16bit_CycleCfg(uint16_t cyc)
|
||||
{
|
||||
R8_PWM_CONFIG = (R8_PWM_CONFIG & 0xf0) | (3 << 2);
|
||||
R32_PWM_REG_CYCLE = cyc;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn PWMX_16bit_ACTOUT
|
||||
*
|
||||
* @brief PWM4-PWM9 通道16位输出波形配置
|
||||
*
|
||||
* @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 < 6; i++)
|
||||
{
|
||||
if((ch >> i) & 1)
|
||||
{
|
||||
if(i<4)
|
||||
{
|
||||
*((volatile uint16_t *)((&R16_PWM4_DATA) + i)) = da;
|
||||
}
|
||||
else
|
||||
{
|
||||
*((volatile uint16_t *)((&R16_PWM8_DATA) + (i-4))) = da;
|
||||
}
|
||||
}
|
||||
}
|
||||
R8_PWM_OUT_EN |= (ch);
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn PWMX_ACTOUT
|
||||
*
|
||||
* @brief PWM4-PWM11通道输出波形配置
|
||||
*
|
||||
* @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));
|
||||
for(i = 0; i < 8; i++)
|
||||
{
|
||||
if((ch >> i) & 1)
|
||||
{
|
||||
*((volatile uint8_t *)((&R8_PWM4_DATA) + i)) = da;
|
||||
}
|
||||
}
|
||||
R8_PWM_OUT_EN |= (ch);
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn PWMX_AlterOutCfg
|
||||
*
|
||||
* @brief PWM 交替输出模式配置
|
||||
*
|
||||
* @param ch - select group of PWM alternate output
|
||||
* RB_PWM4_5_STAG_EN - PWM4 和 PWM5 通道交替输出
|
||||
* RB_PWM6_7_STAG_EN - PWM6 和 PWM7 通道交替输出
|
||||
* RB_PWM8_9_STAG_EN - PWM8 和 PWM9 通道交替输出
|
||||
* RB_PWM10_11_STAG_EN - PWM10 和 PWM11 通道交替输出
|
||||
* @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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,398 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH59x_pwr.c
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2021/11/17
|
||||
* Description
|
||||
*********************************************************************************
|
||||
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "CH59x_common.h"
|
||||
|
||||
/*********************************************************************
|
||||
* @fn PWR_DCDCCfg
|
||||
*
|
||||
* @brief 启用内部DC/DC电源,用于节约系统功耗
|
||||
*
|
||||
* @param s - 是否打开DCDC电源
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void PWR_DCDCCfg(FunctionalState s)
|
||||
{
|
||||
uint16_t adj = R16_AUX_POWER_ADJ;
|
||||
uint16_t plan = R16_POWER_PLAN;
|
||||
|
||||
if(s == DISABLE)
|
||||
{
|
||||
|
||||
adj &= ~RB_DCDC_CHARGE;
|
||||
plan &= ~(RB_PWR_DCDC_EN | RB_PWR_DCDC_PRE); // 旁路 DC/DC
|
||||
sys_safe_access_enable();
|
||||
R16_AUX_POWER_ADJ = adj;
|
||||
R16_POWER_PLAN = plan;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t HW_Data[2];
|
||||
FLASH_EEPROM_CMD(CMD_GET_ROM_INFO, ROM_CFG_ADR_HW, HW_Data, 0);
|
||||
if((HW_Data[0]) & (1 << 13))
|
||||
{
|
||||
return;
|
||||
}
|
||||
adj |= RB_DCDC_CHARGE;
|
||||
plan |= RB_PWR_DCDC_PRE;
|
||||
sys_safe_access_enable();
|
||||
R16_AUX_POWER_ADJ = adj;
|
||||
R16_POWER_PLAN = plan;
|
||||
sys_safe_access_disable();
|
||||
DelayUs(10);
|
||||
sys_safe_access_enable();
|
||||
R16_POWER_PLAN |= RB_PWR_DCDC_EN;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn PWR_UnitModCfg
|
||||
*
|
||||
* @brief 可控单元模块的电源控制
|
||||
*
|
||||
* @param s - 是否打开电源
|
||||
* @param unit - please refer to unit of controllable power supply
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void PWR_UnitModCfg(FunctionalState s, uint8_t unit)
|
||||
{
|
||||
uint8_t ck32k_cfg = R8_CK32K_CONFIG;
|
||||
|
||||
if(s == DISABLE) //关闭
|
||||
{
|
||||
ck32k_cfg &= ~(unit & 0x03);
|
||||
}
|
||||
else //打开
|
||||
{
|
||||
ck32k_cfg |= (unit & 0x03);
|
||||
}
|
||||
|
||||
sys_safe_access_enable();
|
||||
R8_CK32K_CONFIG = ck32k_cfg;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn PWR_PeriphClkCfg
|
||||
*
|
||||
* @brief 外设时钟控制位
|
||||
*
|
||||
* @param s - 是否打开对应外设时钟
|
||||
* @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 睡眠唤醒源配置
|
||||
*
|
||||
* @param s - 是否打开此外设睡眠唤醒功能
|
||||
* @param perph - 需要设置的唤醒源
|
||||
* RB_SLP_USB_WAKE - USB 为唤醒源
|
||||
* RB_SLP_RTC_WAKE - RTC 为唤醒源
|
||||
* RB_SLP_GPIO_WAKE - GPIO 为唤醒源
|
||||
* RB_SLP_BAT_WAKE - BAT 为唤醒源
|
||||
* @param mode - refer to WakeUP_ModeypeDef
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void PWR_PeriphWakeUpCfg(FunctionalState s, uint8_t perph, WakeUP_ModeypeDef mode)
|
||||
{
|
||||
uint8_t m;
|
||||
|
||||
if(s == DISABLE)
|
||||
{
|
||||
sys_safe_access_enable();
|
||||
R8_SLP_WAKE_CTRL &= ~perph;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(mode)
|
||||
{
|
||||
case Short_Delay:
|
||||
m = 0x01;
|
||||
break;
|
||||
|
||||
case Long_Delay:
|
||||
m = 0x00;
|
||||
break;
|
||||
|
||||
default:
|
||||
m = 0x01;
|
||||
break;
|
||||
}
|
||||
|
||||
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 |= m;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn PowerMonitor
|
||||
*
|
||||
* @brief 电源监控
|
||||
*
|
||||
* @param s - 是否打开此功能
|
||||
* @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
|
||||
{
|
||||
if(vl & 0x80)
|
||||
{
|
||||
cfg = vl & 0x03;
|
||||
ctrl = RB_BAT_MON_EN | ((vl >> 2) & 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
cfg = vl & 0x03;
|
||||
ctrl = RB_BAT_DET_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 | RB_BAT_LOWER_IE;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn LowPower_Idle
|
||||
*
|
||||
* @brief 低功耗-Idle模式
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
__HIGH_CODE
|
||||
void LowPower_Idle(void)
|
||||
{
|
||||
FLASH_ROM_SW_RESET();
|
||||
R8_FLASH_CTRL = 0x04; //flash关闭
|
||||
|
||||
PFIC->SCTLR &= ~(1 << 2); // sleep
|
||||
__WFI();
|
||||
__nop();
|
||||
__nop();
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn LowPower_Halt
|
||||
*
|
||||
* @brief 低功耗-Halt模式,此低功耗切到HSI/5时钟运行,唤醒后需要用户自己重新选择系统时钟源
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
__HIGH_CODE
|
||||
void LowPower_Halt(void)
|
||||
{
|
||||
uint8_t x32Kpw, x32Mpw;
|
||||
|
||||
FLASH_ROM_SW_RESET();
|
||||
R8_FLASH_CTRL = 0x04; //flash关闭
|
||||
x32Kpw = R8_XT32K_TUNE;
|
||||
x32Mpw = R8_XT32M_TUNE;
|
||||
x32Mpw = (x32Mpw & 0xfc) | 0x03; // 150%额定电流
|
||||
x32Kpw = (x32Kpw & 0xfc) | 0x01; // LSE驱动电流降低到额定电流
|
||||
|
||||
sys_safe_access_enable();
|
||||
R8_BAT_DET_CTRL = 0; // 关闭电压监控
|
||||
sys_safe_access_disable();
|
||||
sys_safe_access_enable();
|
||||
R8_XT32K_TUNE = x32Kpw;
|
||||
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 : 低功耗-Sleep模式。
|
||||
注意当主频为80M时,睡眠唤醒中断不可调用flash内代码,且退出此函数前需要加上30us延迟。
|
||||
* Input : rm:
|
||||
RB_PWR_RAM2K - 2K retention SRAM 供电
|
||||
RB_PWR_RAM24K - 24K main SRAM 供电
|
||||
RB_PWR_EXTEND - USB 和 BLE 单元保留区域供电
|
||||
RB_PWR_XROM - FlashROM 供电
|
||||
NULL - 以上单元都断电
|
||||
* Return : None
|
||||
*******************************************************************************/
|
||||
__HIGH_CODE
|
||||
void LowPower_Sleep(uint16_t rm)
|
||||
{
|
||||
__attribute__((aligned(4))) uint8_t MacAddr[6] = {0};
|
||||
uint8_t x32Mpw;
|
||||
uint16_t power_plan;
|
||||
|
||||
GetMACAddress(MacAddr);
|
||||
|
||||
x32Mpw = R8_XT32M_TUNE;
|
||||
x32Mpw = (x32Mpw & 0xfc) | 0x03; // 150%额定电流
|
||||
|
||||
sys_safe_access_enable();
|
||||
R8_BAT_DET_CTRL = 0; // 关闭电压监控
|
||||
sys_safe_access_disable();
|
||||
sys_safe_access_enable();
|
||||
R8_XT32M_TUNE = x32Mpw;
|
||||
sys_safe_access_disable();
|
||||
|
||||
sys_safe_access_enable();
|
||||
R16_POWER_PLAN &= ~RB_XT_PRE_EN;
|
||||
sys_safe_access_disable();
|
||||
|
||||
PFIC->SCTLR |= (1 << 2); //deep sleep
|
||||
|
||||
power_plan = R16_POWER_PLAN & (RB_PWR_DCDC_EN | RB_PWR_DCDC_PRE);
|
||||
power_plan |= RB_PWR_PLAN_EN | RB_PWR_CORE | rm | (2<<11);
|
||||
|
||||
sys_safe_access_enable();
|
||||
R8_SLP_POWER_CTRL |= RB_RAM_RET_LV;
|
||||
R16_POWER_PLAN = power_plan;
|
||||
sys_safe_access_disable();
|
||||
if((rm & RB_XT_PRE_EN) == 0)
|
||||
{
|
||||
sys_safe_access_enable();
|
||||
R8_PLL_CONFIG |= (1 << 5);
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
|
||||
__WFI();
|
||||
__nop();
|
||||
__nop();
|
||||
|
||||
sys_safe_access_enable();
|
||||
R16_POWER_PLAN &= ~RB_PWR_PLAN_EN;
|
||||
sys_safe_access_disable();
|
||||
|
||||
sys_safe_access_enable();
|
||||
R16_POWER_PLAN &= ~RB_XT_PRE_EN;
|
||||
sys_safe_access_disable();
|
||||
|
||||
if((rm & RB_XT_PRE_EN) == 0)
|
||||
{
|
||||
sys_safe_access_enable();
|
||||
R8_PLL_CONFIG &= ~(1 << 5);
|
||||
sys_safe_access_disable();
|
||||
DelayUs(20);
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn LowPower_Shutdown
|
||||
*
|
||||
* @brief 低功耗-Shutdown模式,此低功耗切到HSI/5时钟运行,唤醒后需要用户自己重新选择系统时钟源
|
||||
* @note 注意调用此函数,DCDC功能强制关闭,唤醒后可以手动再次打开
|
||||
*
|
||||
* @param rm - 供电模块选择
|
||||
* RB_PWR_RAM2K - 2K retention SRAM 供电
|
||||
* RB_PWR_RAM16K - 16K main SRAM 供电
|
||||
* NULL - 以上单元都断电
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
__HIGH_CODE
|
||||
void LowPower_Shutdown(uint16_t rm)
|
||||
{
|
||||
uint8_t x32Kpw, x32Mpw;
|
||||
|
||||
FLASH_ROM_SW_RESET();
|
||||
x32Kpw = R8_XT32K_TUNE;
|
||||
x32Mpw = R8_XT32M_TUNE;
|
||||
x32Mpw = (x32Mpw & 0xfc) | 0x03; // 150%额定电流
|
||||
x32Kpw = (x32Kpw & 0xfc) | 0x01; // LSE驱动电流降低到额定电流
|
||||
|
||||
sys_safe_access_enable();
|
||||
R8_BAT_DET_CTRL = 0; // 关闭电压监控
|
||||
sys_safe_access_disable();
|
||||
sys_safe_access_enable();
|
||||
R8_XT32K_TUNE = x32Kpw;
|
||||
R8_XT32M_TUNE = x32Mpw;
|
||||
sys_safe_access_disable();
|
||||
SetSysClock(CLK_SOURCE_HSE_6_4MHz);
|
||||
|
||||
PFIC->SCTLR |= (1 << 2); //deep sleep
|
||||
|
||||
sys_safe_access_enable();
|
||||
R8_SLP_POWER_CTRL |= RB_RAM_RET_LV;
|
||||
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();
|
||||
}
|
||||
@@ -0,0 +1,370 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH59x_SPI0.c
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2021/11/17
|
||||
* Description
|
||||
*********************************************************************************
|
||||
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "CH59x_common.h"
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SPI0_MasterDefInit
|
||||
*
|
||||
* @brief 主机模式默认初始化:模式0+3线全双工+8MHz
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void SPI0_MasterDefInit(void)
|
||||
{
|
||||
R8_SPI0_CLOCK_DIV = 4; // 主频时钟4分频
|
||||
R8_SPI0_CTRL_MOD = RB_SPI_ALL_CLEAR;
|
||||
R8_SPI0_CTRL_MOD = RB_SPI_MOSI_OE | RB_SPI_SCK_OE;
|
||||
R8_SPI0_CTRL_CFG |= RB_SPI_AUTO_IF; // 访问BUFFER/FIFO自动清除IF_BYTE_END标志
|
||||
R8_SPI0_CTRL_CFG &= ~RB_SPI_DMA_ENABLE; // 不启动DMA方式
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SPI0_CLKCfg
|
||||
*
|
||||
* @brief SPI0 基准时钟配置,= d*Tsys
|
||||
*
|
||||
* @param c - 时钟分频系数
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void SPI0_CLKCfg(uint8_t c)
|
||||
{
|
||||
if(c == 2)
|
||||
{
|
||||
R8_SPI0_CTRL_CFG |= RB_SPI_MST_DLY_EN;
|
||||
}
|
||||
else
|
||||
{
|
||||
R8_SPI0_CTRL_CFG &= ~RB_SPI_MST_DLY_EN;
|
||||
}
|
||||
R8_SPI0_CLOCK_DIV = c;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SPI0_DataMode
|
||||
*
|
||||
* @brief 设置数据流模式
|
||||
*
|
||||
* @param m - 数据流模式 refer to ModeBitOrderTypeDef
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void SPI0_DataMode(ModeBitOrderTypeDef m)
|
||||
{
|
||||
switch(m)
|
||||
{
|
||||
case Mode0_LowBitINFront:
|
||||
R8_SPI0_CTRL_MOD &= ~RB_SPI_MST_SCK_MOD;
|
||||
R8_SPI0_CTRL_CFG |= RB_SPI_BIT_ORDER;
|
||||
break;
|
||||
case Mode0_HighBitINFront:
|
||||
R8_SPI0_CTRL_MOD &= ~RB_SPI_MST_SCK_MOD;
|
||||
R8_SPI0_CTRL_CFG &= ~RB_SPI_BIT_ORDER;
|
||||
break;
|
||||
case Mode3_LowBitINFront:
|
||||
R8_SPI0_CTRL_MOD |= RB_SPI_MST_SCK_MOD;
|
||||
R8_SPI0_CTRL_CFG |= RB_SPI_BIT_ORDER;
|
||||
break;
|
||||
case Mode3_HighBitINFront:
|
||||
R8_SPI0_CTRL_MOD |= RB_SPI_MST_SCK_MOD;
|
||||
R8_SPI0_CTRL_CFG &= ~RB_SPI_BIT_ORDER;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SPI0_MasterSendByte
|
||||
*
|
||||
* @brief 发送单字节 (buffer)
|
||||
*
|
||||
* @param d - 发送字节
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void SPI0_MasterSendByte(uint8_t d)
|
||||
{
|
||||
R8_SPI0_CTRL_MOD &= ~RB_SPI_FIFO_DIR;
|
||||
R8_SPI0_BUFFER = d;
|
||||
while(!(R8_SPI0_INT_FLAG & RB_SPI_FREE));
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SPI0_MasterRecvByte
|
||||
*
|
||||
* @brief 接收单字节 (buffer)
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return 接收到的字节
|
||||
*/
|
||||
uint8_t SPI0_MasterRecvByte(void)
|
||||
{
|
||||
R8_SPI0_CTRL_MOD &= ~RB_SPI_FIFO_DIR;
|
||||
R8_SPI0_BUFFER = 0xFF; // 启动传输
|
||||
while(!(R8_SPI0_INT_FLAG & RB_SPI_FREE));
|
||||
return (R8_SPI0_BUFFER);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SPI0_MasterTrans
|
||||
*
|
||||
* @brief 使用FIFO连续发送多字节
|
||||
*
|
||||
* @param pbuf - 待发送的数据内容首地址
|
||||
* @param len - 请求发送的数据长度,最大4095
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void SPI0_MasterTrans(uint8_t *pbuf, uint16_t len)
|
||||
{
|
||||
uint16_t sendlen;
|
||||
|
||||
sendlen = len;
|
||||
R8_SPI0_CTRL_MOD &= ~RB_SPI_FIFO_DIR; // 设置数据方向为输出
|
||||
R16_SPI0_TOTAL_CNT = sendlen; // 设置要发送的数据长度
|
||||
R8_SPI0_INT_FLAG = RB_SPI_IF_CNT_END;
|
||||
while(sendlen)
|
||||
{
|
||||
if(R8_SPI0_FIFO_COUNT < SPI_FIFO_SIZE)
|
||||
{
|
||||
R8_SPI0_FIFO = *pbuf;
|
||||
pbuf++;
|
||||
sendlen--;
|
||||
}
|
||||
}
|
||||
while(R8_SPI0_FIFO_COUNT != 0); // 等待FIFO中的数据全部发送完成
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SPI0_MasterRecv
|
||||
*
|
||||
* @brief 使用FIFO连续接收多字节
|
||||
*
|
||||
* @param pbuf - 待接收的数据首地址
|
||||
* @param len - 待接收的数据长度,最大4095
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void SPI0_MasterRecv(uint8_t *pbuf, uint16_t len)
|
||||
{
|
||||
uint16_t readlen;
|
||||
|
||||
readlen = len;
|
||||
R8_SPI0_CTRL_MOD |= RB_SPI_FIFO_DIR; // 设置数据方向为输入
|
||||
R16_SPI0_TOTAL_CNT = len; // 设置需要接收的数据长度,FIFO方向为输入长度不为0则会启动传输 */
|
||||
R8_SPI0_INT_FLAG = RB_SPI_IF_CNT_END;
|
||||
while(readlen)
|
||||
{
|
||||
if(R8_SPI0_FIFO_COUNT)
|
||||
{
|
||||
*pbuf = R8_SPI0_FIFO;
|
||||
pbuf++;
|
||||
readlen--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SPI0_MasterDMATrans
|
||||
*
|
||||
* @brief DMA方式连续发送数据
|
||||
*
|
||||
* @param pbuf - 待发送数据起始地址,需要四字节对其
|
||||
* @param len - 待发送数据长度
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void SPI0_MasterDMATrans(uint8_t *pbuf, uint16_t len)
|
||||
{
|
||||
R8_SPI0_CTRL_MOD &= ~RB_SPI_FIFO_DIR;
|
||||
R16_SPI0_DMA_BEG = (uint32_t)pbuf;
|
||||
R16_SPI0_DMA_END = (uint32_t)(pbuf + len);
|
||||
R16_SPI0_TOTAL_CNT = len;
|
||||
R8_SPI0_INT_FLAG = RB_SPI_IF_CNT_END | RB_SPI_IF_DMA_END;
|
||||
R8_SPI0_CTRL_CFG |= RB_SPI_DMA_ENABLE;
|
||||
while(!(R8_SPI0_INT_FLAG & RB_SPI_IF_CNT_END));
|
||||
R8_SPI0_CTRL_CFG &= ~RB_SPI_DMA_ENABLE;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SPI0_MasterDMARecv
|
||||
*
|
||||
* @brief DMA方式连续接收数据
|
||||
*
|
||||
* @param pbuf - 待接收数据存放起始地址,需要四字节对其
|
||||
* @param len - 待接收数据长度
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void SPI0_MasterDMARecv(uint8_t *pbuf, uint16_t len)
|
||||
{
|
||||
R8_SPI0_CTRL_MOD |= RB_SPI_FIFO_DIR;
|
||||
R16_SPI0_DMA_BEG = (uint32_t)pbuf;
|
||||
R16_SPI0_DMA_END = (uint32_t)(pbuf + len);
|
||||
R16_SPI0_TOTAL_CNT = len;
|
||||
R8_SPI0_INT_FLAG = RB_SPI_IF_CNT_END | RB_SPI_IF_DMA_END;
|
||||
R8_SPI0_CTRL_CFG |= RB_SPI_DMA_ENABLE;
|
||||
while(!(R8_SPI0_INT_FLAG & RB_SPI_IF_CNT_END));
|
||||
R8_SPI0_CTRL_CFG &= ~RB_SPI_DMA_ENABLE;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SPI0_SlaveInit
|
||||
*
|
||||
* @brief 设备模式默认初始化,建议设置MISO的GPIO对应为输入模式
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void SPI0_SlaveInit(void)
|
||||
{
|
||||
R8_SPI0_CTRL_MOD = RB_SPI_ALL_CLEAR;
|
||||
R8_SPI0_CTRL_MOD = RB_SPI_MISO_OE | RB_SPI_MODE_SLAVE;
|
||||
R8_SPI0_CTRL_CFG |= RB_SPI_AUTO_IF;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SPI0_SlaveRecvByte
|
||||
*
|
||||
* @brief 从机模式,接收一字节数据
|
||||
*
|
||||
* @return 接收到数据
|
||||
*/
|
||||
uint8_t SPI0_SlaveRecvByte(void)
|
||||
{
|
||||
R8_SPI0_CTRL_MOD |= RB_SPI_FIFO_DIR;
|
||||
while(R8_SPI0_FIFO_COUNT == 0);
|
||||
return R8_SPI0_FIFO;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SPI0_SlaveSendByte
|
||||
*
|
||||
* @brief 从机模式,发送一字节数据
|
||||
*
|
||||
* @param d - 待发送数据
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void SPI0_SlaveSendByte(uint8_t d)
|
||||
{
|
||||
R8_SPI0_CTRL_MOD &= ~RB_SPI_FIFO_DIR;
|
||||
R8_SPI0_FIFO = d;
|
||||
while(R8_SPI0_FIFO_COUNT != 0); // 等待发送完成
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SPI0_SlaveRecv
|
||||
*
|
||||
* @brief 从机模式,接收多字节数据
|
||||
*
|
||||
* @param pbuf - 接收收数据存放起始地址
|
||||
* @param len - 请求接收数据长度
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
__HIGH_CODE
|
||||
void SPI0_SlaveRecv(uint8_t *pbuf, uint16_t len)
|
||||
{
|
||||
uint16_t revlen;
|
||||
|
||||
revlen = len;
|
||||
R8_SPI0_CTRL_MOD |= RB_SPI_FIFO_DIR;
|
||||
R8_SPI0_INT_FLAG = RB_SPI_IF_CNT_END;
|
||||
while(revlen)
|
||||
{
|
||||
if(R8_SPI0_FIFO_COUNT)
|
||||
{
|
||||
*pbuf = R8_SPI0_FIFO;
|
||||
pbuf++;
|
||||
revlen--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SPI0_SlaveTrans
|
||||
*
|
||||
* @brief 从机模式,发送多字节数据
|
||||
*
|
||||
* @param pbuf - 待发送的数据内容首地址
|
||||
* @param len - 请求发送的数据长度,最大4095
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
__HIGH_CODE
|
||||
void SPI0_SlaveTrans(uint8_t *pbuf, uint16_t len)
|
||||
{
|
||||
uint16_t sendlen;
|
||||
|
||||
sendlen = len;
|
||||
R8_SPI0_CTRL_MOD &= ~RB_SPI_FIFO_DIR; // 设置数据方向为输出
|
||||
R8_SPI0_INT_FLAG = RB_SPI_IF_CNT_END;
|
||||
while(sendlen)
|
||||
{
|
||||
if(R8_SPI0_FIFO_COUNT < SPI_FIFO_SIZE)
|
||||
{
|
||||
R8_SPI0_FIFO = *pbuf;
|
||||
pbuf++;
|
||||
sendlen--;
|
||||
}
|
||||
}
|
||||
while(R8_SPI0_FIFO_COUNT != 0); // 等待FIFO中的数据全部发送完成
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SPI0_SlaveDMARecv
|
||||
*
|
||||
* @brief DMA方式连续接收数据
|
||||
*
|
||||
* @param pbuf - 待接收数据存放起始地址,需要四字节对其
|
||||
* @param len - 待接收数据长度
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void SPI0_SlaveDMARecv(uint8_t *pbuf, uint16_t len)
|
||||
{
|
||||
R8_SPI0_CTRL_MOD |= RB_SPI_FIFO_DIR;
|
||||
R16_SPI0_DMA_BEG = (uint32_t)pbuf;
|
||||
R16_SPI0_DMA_END = (uint32_t)(pbuf + len);
|
||||
R16_SPI0_TOTAL_CNT = len;
|
||||
R8_SPI0_INT_FLAG = RB_SPI_IF_CNT_END | RB_SPI_IF_DMA_END;
|
||||
R8_SPI0_CTRL_CFG |= RB_SPI_DMA_ENABLE;
|
||||
while(!(R8_SPI0_INT_FLAG & RB_SPI_IF_CNT_END));
|
||||
R8_SPI0_CTRL_CFG &= ~RB_SPI_DMA_ENABLE;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SPI0_SlaveDMATrans
|
||||
*
|
||||
* @brief DMA方式连续发送数据
|
||||
*
|
||||
* @param pbuf - 待发送数据起始地址,需要四字节对其
|
||||
* @param len - 待发送数据长度
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void SPI0_SlaveDMATrans(uint8_t *pbuf, uint16_t len)
|
||||
{
|
||||
R8_SPI0_CTRL_MOD &= ~RB_SPI_FIFO_DIR;
|
||||
R16_SPI0_DMA_BEG = (uint32_t)pbuf;
|
||||
R16_SPI0_DMA_END = (uint32_t)(pbuf + len);
|
||||
R16_SPI0_TOTAL_CNT = len;
|
||||
R8_SPI0_INT_FLAG = RB_SPI_IF_CNT_END | RB_SPI_IF_DMA_END;
|
||||
R8_SPI0_CTRL_CFG |= RB_SPI_DMA_ENABLE;
|
||||
while(!(R8_SPI0_INT_FLAG & RB_SPI_IF_CNT_END));
|
||||
R8_SPI0_CTRL_CFG &= ~RB_SPI_DMA_ENABLE;
|
||||
}
|
||||
@@ -0,0 +1,389 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH59x_SYS.c
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2021/11/17
|
||||
* Description
|
||||
*********************************************************************************
|
||||
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "CH59x_common.h"
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SetSysClock
|
||||
*
|
||||
* @brief 配置系统运行时钟
|
||||
*
|
||||
* @param sc - 系统时钟源选择 refer to SYS_CLKTypeDef
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
__HIGH_CODE
|
||||
void SetSysClock(SYS_CLKTypeDef sc)
|
||||
{
|
||||
sys_safe_access_enable();
|
||||
R8_PLL_CONFIG &= ~(1 << 5); //
|
||||
sys_safe_access_disable();
|
||||
if(sc & 0x20) // HSE div
|
||||
{
|
||||
sys_safe_access_enable();
|
||||
R32_CLK_SYS_CFG = (0 << 6) | (sc & 0x1f) | RB_TX_32M_PWR_EN | RB_PLL_PWR_EN;
|
||||
__nop();
|
||||
__nop();
|
||||
__nop();
|
||||
__nop();
|
||||
sys_safe_access_disable();
|
||||
sys_safe_access_enable();
|
||||
SAFEOPERATE;
|
||||
R8_FLASH_CFG = 0X51;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
|
||||
else if(sc & 0x40) // PLL div
|
||||
{
|
||||
sys_safe_access_enable();
|
||||
R32_CLK_SYS_CFG = (1 << 6) | (sc & 0x1f) | RB_TX_32M_PWR_EN | RB_PLL_PWR_EN;
|
||||
__nop();
|
||||
__nop();
|
||||
__nop();
|
||||
__nop();
|
||||
sys_safe_access_disable();
|
||||
sys_safe_access_enable();
|
||||
R8_FLASH_CFG = 0X52;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
else
|
||||
{
|
||||
sys_safe_access_enable();
|
||||
R32_CLK_SYS_CFG |= RB_CLK_SYS_MOD;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
//更改FLASH clk的驱动能力
|
||||
sys_safe_access_enable();
|
||||
R8_PLL_CONFIG |= 1 << 7;
|
||||
sys_safe_access_disable();
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn GetSysClock
|
||||
*
|
||||
* @brief 获取当前系统时钟
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return Hz
|
||||
*/
|
||||
uint32_t GetSysClock(void)
|
||||
{
|
||||
uint16_t rev;
|
||||
|
||||
rev = R32_CLK_SYS_CFG & 0xff;
|
||||
if((rev & 0x40) == (0 << 6))
|
||||
{ // 32M进行分频
|
||||
return (32000000 / (rev & 0x1f));
|
||||
}
|
||||
else if((rev & RB_CLK_SYS_MOD) == (1 << 6))
|
||||
{ // PLL进行分频
|
||||
return (480000000 / (rev & 0x1f));
|
||||
}
|
||||
else
|
||||
{ // 32K做主频
|
||||
return (32000);
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SYS_GetInfoSta
|
||||
*
|
||||
* @brief 获取当前系统信息状态
|
||||
*
|
||||
* @param i - refer to SYS_InfoStaTypeDef
|
||||
*
|
||||
* @return 是否开启
|
||||
*/
|
||||
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 执行系统软件复位
|
||||
*
|
||||
* @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 关闭所有中断,并保留当前中断值
|
||||
*
|
||||
* @param pirqv - 当前保留中断值
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn SYS_RecoverIrq
|
||||
*
|
||||
* @brief 恢复之前关闭的中断值
|
||||
*
|
||||
* @param irq_status - 当前保留中断值
|
||||
*
|
||||
* @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 获取当前系统(SYSTICK)计数值
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return 当前计数值
|
||||
*/
|
||||
uint32_t SYS_GetSysTickCnt(void)
|
||||
{
|
||||
uint32_t val;
|
||||
|
||||
val = SysTick->CNT;
|
||||
return (val);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn WWDG_ITCfg
|
||||
*
|
||||
* @brief 看门狗定时器溢出中断使能
|
||||
*
|
||||
* @param s - 溢出是否中断
|
||||
*
|
||||
* @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 看门狗定时器复位功能
|
||||
*
|
||||
* @param s - 溢出是否复位
|
||||
*
|
||||
* @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 清除看门狗中断标志,重新加载计数值也可清除
|
||||
*
|
||||
* @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 硬件错误中断,进入后执行复位,复位类型为上电复位
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
__INTERRUPT
|
||||
__HIGH_CODE
|
||||
__attribute__((weak))
|
||||
void HardFault_Handler(void)
|
||||
{
|
||||
FLASH_ROM_SW_RESET();
|
||||
sys_safe_access_enable();
|
||||
R16_INT32K_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 延时
|
||||
*
|
||||
* @param t - 时间参数
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
__HIGH_CODE
|
||||
void mDelayuS(uint16_t t)
|
||||
{
|
||||
uint32_t i;
|
||||
#if(FREQ_SYS == 80000000)
|
||||
i = t * 20;
|
||||
#elif(FREQ_SYS == 60000000)
|
||||
i = t * 15;
|
||||
#elif(FREQ_SYS == 48000000)
|
||||
i = t * 12;
|
||||
#elif(FREQ_SYS == 40000000)
|
||||
i = t * 10;
|
||||
#elif(FREQ_SYS == 32000000)
|
||||
i = t << 3;
|
||||
#elif(FREQ_SYS == 24000000)
|
||||
i = t * 6;
|
||||
#elif(FREQ_SYS == 16000000)
|
||||
i = t << 2;
|
||||
#elif(FREQ_SYS == 8000000)
|
||||
i = t << 1;
|
||||
#elif(FREQ_SYS == 4000000)
|
||||
i = t;
|
||||
#elif(FREQ_SYS == 2000000)
|
||||
i = t >> 1;
|
||||
#elif(FREQ_SYS == 1000000)
|
||||
i = t >> 2;
|
||||
#else
|
||||
i = t << 1;
|
||||
#endif
|
||||
do
|
||||
{
|
||||
__nop();
|
||||
} while(--i);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn mDelaymS
|
||||
*
|
||||
* @brief mS 延时
|
||||
*
|
||||
* @param t - 时间参数
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
__HIGH_CODE
|
||||
void mDelaymS(uint16_t t)
|
||||
{
|
||||
uint16_t i;
|
||||
|
||||
for(i = 0; i < t; i++)
|
||||
{
|
||||
mDelayuS(1000);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
int _write(int fd, char *buf, int size)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < size; i++)
|
||||
{
|
||||
#if DEBUG == Debug_UART0
|
||||
while(R8_UART0_TFC == UART_FIFO_SIZE); /* 等待数据发送 */
|
||||
R8_UART0_THR = *buf++; /* 发送数据 */
|
||||
#elif DEBUG == Debug_UART1
|
||||
while(R8_UART1_TFC == UART_FIFO_SIZE); /* 等待数据发送 */
|
||||
R8_UART1_THR = *buf++; /* 发送数据 */
|
||||
#elif DEBUG == Debug_UART2
|
||||
while(R8_UART2_TFC == UART_FIFO_SIZE); /* 等待数据发送 */
|
||||
R8_UART2_THR = *buf++; /* 发送数据 */
|
||||
#elif DEBUG == Debug_UART3
|
||||
while(R8_UART3_TFC == UART_FIFO_SIZE); /* 等待数据发送 */
|
||||
R8_UART3_THR = *buf++; /* 发送数据 */
|
||||
#endif
|
||||
}
|
||||
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[];
|
||||
extern char _heap_end[];
|
||||
static char *curbrk = _end;
|
||||
|
||||
if ((curbrk + incr < _end) || (curbrk + incr > _heap_end))
|
||||
return NULL - 1;
|
||||
|
||||
curbrk += incr;
|
||||
return curbrk - incr;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH59x_timer0.c
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2021/11/17
|
||||
* Description
|
||||
*********************************************************************************
|
||||
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "CH59x_common.h"
|
||||
|
||||
/*********************************************************************
|
||||
* @fn TMR0_TimerInit
|
||||
*
|
||||
* @brief 定时功能初始化
|
||||
*
|
||||
* @param t - 定时时间,基于当前系统时钟Tsys, 最长定时周期 67108864
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void TMR0_TimerInit(uint32_t t)
|
||||
{
|
||||
R32_TMR0_CNT_END = t;
|
||||
R8_TMR0_CTRL_MOD = RB_TMR_ALL_CLEAR;
|
||||
R8_TMR0_CTRL_MOD = RB_TMR_COUNT_EN;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn TMR0_EXTSingleCounterInit
|
||||
*
|
||||
* @brief 边沿计数功能初始化
|
||||
*
|
||||
* @param cap - 采集计数类型
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void TMR0_EXTSingleCounterInit(CapModeTypeDef cap)
|
||||
{
|
||||
R8_TMR0_CTRL_MOD = RB_TMR_ALL_CLEAR;
|
||||
R8_TMR0_CTRL_MOD = RB_TMR_COUNT_EN | RB_TMR_CAP_COUNT | RB_TMR_MODE_IN | (cap << 6);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn TMR0_PWMInit
|
||||
*
|
||||
* @brief PWM 输出初始化
|
||||
*
|
||||
* @param pr - select wave polar, refer to PWMX_PolarTypeDef
|
||||
* @param ts - set pwm repeat times, refer to PWM_RepeatTsTypeDef
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void TMR0_PWMInit(PWMX_PolarTypeDef pr, PWM_RepeatTsTypeDef ts)
|
||||
{
|
||||
R8_TMR0_CTRL_MOD = RB_TMR_ALL_CLEAR;
|
||||
R8_TMR0_CTRL_MOD = (pr << 4) | (ts << 6);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn TMR0_CapInit
|
||||
*
|
||||
* @brief 外部信号捕捉功能初始化
|
||||
*
|
||||
* @param cap - select capture mode, refer to CapModeTypeDef
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void TMR0_CapInit(CapModeTypeDef cap)
|
||||
{
|
||||
R8_TMR0_CTRL_MOD = RB_TMR_ALL_CLEAR;
|
||||
R8_TMR0_CTRL_MOD = RB_TMR_COUNT_EN | RB_TMR_MODE_IN | (cap << 6);
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH59x_timer1.c
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2021/11/17
|
||||
* Description
|
||||
*********************************************************************************
|
||||
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "CH59x_common.h"
|
||||
|
||||
/*********************************************************************
|
||||
* @fn TMR1_TimerInit
|
||||
*
|
||||
* @brief 定时功能初始化
|
||||
*
|
||||
* @param t - 定时时间,基于当前系统时钟Tsys, 最长定时周期 67108864
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void TMR1_TimerInit(uint32_t t)
|
||||
{
|
||||
R32_TMR1_CNT_END = t;
|
||||
R8_TMR1_CTRL_MOD = RB_TMR_ALL_CLEAR;
|
||||
R8_TMR1_CTRL_MOD = RB_TMR_COUNT_EN;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn TMR1_EXTSingleCounterInit
|
||||
*
|
||||
* @brief 边沿计数功能初始化
|
||||
*
|
||||
* @param cap - 采集计数类型
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void TMR1_EXTSingleCounterInit(CapModeTypeDef cap)
|
||||
{
|
||||
R8_TMR1_CTRL_MOD = RB_TMR_ALL_CLEAR;
|
||||
R8_TMR1_CTRL_MOD = RB_TMR_COUNT_EN | RB_TMR_CAP_COUNT | RB_TMR_MODE_IN | (cap << 6);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn TMR1_PWMInit
|
||||
*
|
||||
* @brief PWM 输出初始化
|
||||
*
|
||||
* @param pr - select wave polar, refer to PWMX_PolarTypeDef
|
||||
* @param ts - set pwm repeat times, refer to PWM_RepeatTsTypeDef
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void TMR1_PWMInit(PWMX_PolarTypeDef pr, PWM_RepeatTsTypeDef ts)
|
||||
{
|
||||
R8_TMR1_CTRL_MOD = RB_TMR_ALL_CLEAR;
|
||||
R8_TMR1_CTRL_MOD = (pr << 4) | (ts << 6);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn TMR1_CapInit
|
||||
*
|
||||
* @brief 外部信号捕捉功能初始化
|
||||
*
|
||||
* @param cap - select capture mode, refer to CapModeTypeDef
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void TMR1_CapInit(CapModeTypeDef cap)
|
||||
{
|
||||
R8_TMR1_CTRL_MOD = RB_TMR_ALL_CLEAR;
|
||||
R8_TMR1_CTRL_MOD = RB_TMR_COUNT_EN | RB_TMR_MODE_IN | (cap << 6);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn TMR1_DMACfg
|
||||
*
|
||||
* @brief 配置DMA功能
|
||||
*
|
||||
* @param s - 是否打开DMA功能
|
||||
* @param startAddr - DMA 起始地址
|
||||
* @param endAddr - DMA 结束地址
|
||||
* @param m - 配置DMA模式
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void TMR1_DMACfg(uint8_t s, uint16_t startAddr, uint16_t endAddr, DMAModeTypeDef m)
|
||||
{
|
||||
if(s == DISABLE)
|
||||
{
|
||||
R8_TMR1_CTRL_DMA = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
R16_TMR1_DMA_BEG = startAddr;
|
||||
R16_TMR1_DMA_END = endAddr;
|
||||
if(m)
|
||||
R8_TMR1_CTRL_DMA = RB_TMR_DMA_LOOP | RB_TMR_DMA_ENABLE;
|
||||
else
|
||||
R8_TMR1_CTRL_DMA = RB_TMR_DMA_ENABLE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH59x_timer2.c
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2021/11/17
|
||||
* Description
|
||||
*********************************************************************************
|
||||
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "CH59x_common.h"
|
||||
|
||||
/*********************************************************************
|
||||
* @fn TMR2_TimerInit
|
||||
*
|
||||
* @brief 定时功能初始化
|
||||
*
|
||||
* @param t - 定时时间,基于当前系统时钟Tsys, 最长定时周期 67108864
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void TMR2_TimerInit(uint32_t t)
|
||||
{
|
||||
R32_TMR2_CNT_END = t;
|
||||
R8_TMR2_CTRL_MOD = RB_TMR_ALL_CLEAR;
|
||||
R8_TMR2_CTRL_MOD = RB_TMR_COUNT_EN;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn TMR2_EXTSingleCounterInit
|
||||
*
|
||||
* @brief 边沿计数功能初始化
|
||||
*
|
||||
* @param cap - 采集计数类型
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void TMR2_EXTSingleCounterInit(CapModeTypeDef cap)
|
||||
{
|
||||
R8_TMR2_CTRL_MOD = RB_TMR_ALL_CLEAR;
|
||||
R8_TMR2_CTRL_MOD = RB_TMR_COUNT_EN | RB_TMR_CAP_COUNT | RB_TMR_MODE_IN | (cap << 6);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn TMR2_PWMInit
|
||||
*
|
||||
* @brief PWM 输出初始化
|
||||
*
|
||||
* @param pr - select wave polar, refer to PWMX_PolarTypeDef
|
||||
* @param ts - set pwm repeat times, refer to PWM_RepeatTsTypeDef
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void TMR2_PWMInit(PWMX_PolarTypeDef pr, PWM_RepeatTsTypeDef ts)
|
||||
{
|
||||
R8_TMR2_CTRL_MOD = RB_TMR_ALL_CLEAR;
|
||||
R8_TMR2_CTRL_MOD = (pr << 4) | (ts << 6);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn TMR2_CapInit
|
||||
*
|
||||
* @brief 外部信号捕捉功能初始化
|
||||
*
|
||||
* @param cap - select capture mode, refer to CapModeTypeDef
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void TMR2_CapInit(CapModeTypeDef cap)
|
||||
{
|
||||
R8_TMR2_CTRL_MOD = RB_TMR_ALL_CLEAR;
|
||||
R8_TMR2_CTRL_MOD = RB_TMR_COUNT_EN | RB_TMR_MODE_IN | (cap << 6);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn TMR2_DMACfg
|
||||
*
|
||||
* @brief 配置DMA功能
|
||||
*
|
||||
* @param s - 是否打开DMA功能
|
||||
* @param startAddr - DMA 起始地址
|
||||
* @param endAddr - DMA 结束地址
|
||||
* @param m - 配置DMA模式
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void TMR2_DMACfg(uint8_t s, uint32_t startAddr, uint32_t endAddr, DMAModeTypeDef m)
|
||||
{
|
||||
if(s == DISABLE)
|
||||
{
|
||||
R8_TMR2_CTRL_DMA = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
R16_TMR2_DMA_BEG = startAddr&0xFFFF;
|
||||
R16_TMR2_DMA_END = endAddr&0xFFFF;
|
||||
if(m)
|
||||
R8_TMR2_CTRL_DMA = RB_TMR_DMA_LOOP | RB_TMR_DMA_ENABLE;
|
||||
else
|
||||
R8_TMR2_CTRL_DMA = RB_TMR_DMA_ENABLE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH59x_timer3.c
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2021/11/17
|
||||
* Description
|
||||
*********************************************************************************
|
||||
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "CH59x_common.h"
|
||||
|
||||
/*********************************************************************
|
||||
* @fn TMR3_TimerInit
|
||||
*
|
||||
* @brief 定时功能初始化
|
||||
*
|
||||
* @param t - 定时时间,基于当前系统时钟Tsys, 最长定时周期 67108864
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void TMR3_TimerInit(uint32_t t)
|
||||
{
|
||||
R32_TMR3_CNT_END = t;
|
||||
R8_TMR3_CTRL_MOD = RB_TMR_ALL_CLEAR;
|
||||
R8_TMR3_CTRL_MOD = RB_TMR_COUNT_EN;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn TMR3_EXTSingleCounterInit
|
||||
*
|
||||
* @brief 边沿计数功能初始化
|
||||
*
|
||||
* @param cap - 采集计数类型
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void TMR3_EXTSingleCounterInit(CapModeTypeDef cap)
|
||||
{
|
||||
R8_TMR3_CTRL_MOD = RB_TMR_ALL_CLEAR;
|
||||
R8_TMR3_CTRL_MOD = RB_TMR_COUNT_EN | RB_TMR_CAP_COUNT | RB_TMR_MODE_IN | (cap << 6);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn TMR3_PWMInit
|
||||
*
|
||||
* @brief PWM 输出初始化
|
||||
*
|
||||
* @param pr - select wave polar, refer to PWMX_PolarTypeDef
|
||||
* @param ts - set pwm repeat times, refer to PWM_RepeatTsTypeDef
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void TMR3_PWMInit(PWMX_PolarTypeDef pr, PWM_RepeatTsTypeDef ts)
|
||||
{
|
||||
R8_TMR3_CTRL_MOD = RB_TMR_ALL_CLEAR;
|
||||
R8_TMR3_CTRL_MOD = (pr << 4) | (ts << 6);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn TMR3_CapInit
|
||||
*
|
||||
* @brief 外部信号捕捉功能初始化
|
||||
*
|
||||
* @param cap - select capture mode, refer to CapModeTypeDef
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void TMR3_CapInit(CapModeTypeDef cap)
|
||||
{
|
||||
R8_TMR3_CTRL_MOD = RB_TMR_ALL_CLEAR;
|
||||
R8_TMR3_CTRL_MOD = RB_TMR_COUNT_EN | RB_TMR_MODE_IN | (cap << 6);
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH59x_uart0.c
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2021/11/17
|
||||
* Description
|
||||
*********************************************************************************
|
||||
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "CH59x_common.h"
|
||||
|
||||
/*********************************************************************
|
||||
* @fn UART0_DefInit
|
||||
*
|
||||
* @brief 串口默认初始化配置
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void UART0_DefInit(void)
|
||||
{
|
||||
UART0_BaudRateCfg(115200);
|
||||
R8_UART0_FCR = (2 << 6) | RB_FCR_TX_FIFO_CLR | RB_FCR_RX_FIFO_CLR | RB_FCR_FIFO_EN; // FIFO打开,触发点4字节
|
||||
R8_UART0_LCR = RB_LCR_WORD_SZ;
|
||||
R8_UART0_IER = RB_IER_TXD_EN;
|
||||
R8_UART0_DIV = 1;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn UART0_BaudRateCfg
|
||||
*
|
||||
* @brief 串口波特率配置
|
||||
*
|
||||
* @param baudrate - 波特率
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void UART0_BaudRateCfg(uint32_t baudrate)
|
||||
{
|
||||
uint32_t x;
|
||||
|
||||
x = 10 * GetSysClock() / 8 / baudrate;
|
||||
x = (x + 5) / 10;
|
||||
R16_UART0_DL = (uint16_t)x;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn UART0_ByteTrigCfg
|
||||
*
|
||||
* @brief 串口字节触发中断配置
|
||||
*
|
||||
* @param b - 触发字节数 refer to UARTByteTRIGTypeDef
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void UART0_ByteTrigCfg(UARTByteTRIGTypeDef b)
|
||||
{
|
||||
R8_UART0_FCR = (R8_UART0_FCR & ~RB_FCR_FIFO_TRIG) | (b << 6);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn UART0_INTCfg
|
||||
*
|
||||
* @brief 串口中断配置
|
||||
*
|
||||
* @param s - 中断控制状态,是否使能相应中断
|
||||
* @param i - 中断类型
|
||||
* RB_IER_MODEM_CHG - 调制解调器输入状态变化中断使能位(仅 UART0 支持)
|
||||
* RB_IER_LINE_STAT - 接收线路状态中断
|
||||
* RB_IER_THR_EMPTY - 发送保持寄存器空中断
|
||||
* RB_IER_RECV_RDY - 接收数据中断
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void UART0_INTCfg(FunctionalState s, uint8_t i)
|
||||
{
|
||||
if(s)
|
||||
{
|
||||
R8_UART0_IER |= i;
|
||||
R8_UART0_MCR |= RB_MCR_INT_OE;
|
||||
}
|
||||
else
|
||||
{
|
||||
R8_UART0_IER &= ~i;
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn UART0_Reset
|
||||
*
|
||||
* @brief 串口软件复位
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void UART0_Reset(void)
|
||||
{
|
||||
R8_UART0_IER = RB_IER_RESET;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn UART0_SendString
|
||||
*
|
||||
* @brief 串口多字节发送
|
||||
*
|
||||
* @param buf - 待发送的数据内容首地址
|
||||
* @param l - 待发送的数据长度
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void UART0_SendString(uint8_t *buf, uint16_t l)
|
||||
{
|
||||
uint16_t len = l;
|
||||
|
||||
while(len)
|
||||
{
|
||||
if(R8_UART0_TFC != UART_FIFO_SIZE)
|
||||
{
|
||||
R8_UART0_THR = *buf++;
|
||||
len--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn UART0_RecvString
|
||||
*
|
||||
* @brief 串口读取多字节
|
||||
*
|
||||
* @param buf - 读取数据存放缓存区首地址
|
||||
*
|
||||
* @return 读取数据长度
|
||||
*/
|
||||
uint16_t UART0_RecvString(uint8_t *buf)
|
||||
{
|
||||
uint16_t len = 0;
|
||||
|
||||
while(R8_UART0_RFC)
|
||||
{
|
||||
*buf++ = R8_UART0_RBR;
|
||||
len++;
|
||||
}
|
||||
|
||||
return (len);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user