first commit
This commit is contained in:
commit
a2fca7a36d
179
.cproject
Normal file
179
.cproject
Normal file
@ -0,0 +1,179 @@
|
||||
<?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.toolchain.base.528944072">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="ilg.gnumcueclipse.managedbuild.cross.riscv.toolchain.base.528944072" moduleId="org.eclipse.cdt.core.settings" name="Default">
|
||||
<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}" buildProperties="" description="" id="ilg.gnumcueclipse.managedbuild.cross.riscv.toolchain.base.528944072" name="Default" optionalBuildProperties="org.eclipse.cdt.docker.launcher.containerbuild.property.volumes=,org.eclipse.cdt.docker.launcher.containerbuild.property.selectedvolumes=" parent="org.eclipse.cdt.build.core.emptycfg">
|
||||
<folderInfo id="ilg.gnumcueclipse.managedbuild.cross.riscv.toolchain.base.528944072.1792346702" name="/" resourcePath="">
|
||||
<toolChain id="ilg.gnumcueclipse.managedbuild.cross.riscv.toolchain.base.497065614" name="RISC-V Cross GCC" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.toolchain.base">
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.prefix.1352229726" name="Prefix" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.prefix" value="riscv64-unknown-elf-" valueType="string"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.suffix.1688033986" name="Suffix" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.suffix"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.c.1872432415" name="C compiler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.c" value="gcc" valueType="string"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.cpp.2078105401" name="C++ compiler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.cpp" value="g++" valueType="string"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.ar.1831101806" name="Archiver" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.ar" value="ar" valueType="string"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.objcopy.1448757246" name="Hex/Bin converter" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.objcopy" value="objcopy" valueType="string"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.objdump.1075129316" name="Listing generator" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.objdump" value="objdump" valueType="string"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.size.1742672886" name="Size command" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.size" value="size" valueType="string"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.make.1314958796" name="Build command" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.make" value="make" valueType="string"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.rm.1915887520" name="Remove command" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.rm" value="rm" valueType="string"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.toolchain.useglobalpath.1924003386" name="Use global path" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.toolchain.useglobalpath"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.toolchain.path.704067905" name="Path" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.toolchain.path"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createflash.627202708" name="Create flash image" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createflash" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createlisting.1219461309" name="Create extended listing" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createlisting"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.printsize.907545928" name="Print size" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.printsize" value="true" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.base.1015262120" name="Architecture" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.base"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.multiply.1306384982" name="Multiply extension (RVM)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.multiply"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.atomic.1489908576" name="Atomic extension (RVA)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.atomic"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.fp.165133640" name="Floating point" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.fp"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.compressed.1875289751" name="Compressed extension (RVC)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.compressed"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.abi.integer.492284435" name="Integer ABI" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.abi.integer"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.abi.fp.1841793115" name="Floating point ABI" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.abi.fp"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.tune.1108911638" name="Tuning" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.tune"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.codemodel.1594234601" name="Code model" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.codemodel"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.smalldatalimit.1532183408" name="Small data limit" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.smalldatalimit"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.align.1487992932" name="Align" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.align"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.saverestore.641693495" name="Small prologue/epilogue (-msave-restore)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.saverestore"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.memcpy.1612253810" name="Force string operations to call library functions (-mmemcpy)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.memcpy"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.plt.327409451" name="Allow use of PLTs (-mplt)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.plt"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.fdiv.471747874" name="Floating-point divide/sqrt instructions (-mfdiv)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.fdiv"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.div.1454578867" name="Integer divide instructions (-mdiv)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.div"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.other.2061222983" name="Other target flags" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.other"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.level.444746854" name="Optimization Level" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.level"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.messagelength.1137303046" name="Message length (-fmessage-length=0)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.messagelength"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.signedchar.1261641000" name="'char' is signed (-fsigned-char)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.signedchar"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.functionsections.1037457578" name="Function sections (-ffunction-sections)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.functionsections"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.datasections.505001509" name="Data sections (-fdata-sections)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.datasections"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.nocommon.993751625" name="No common unitialized (-fno-common)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.nocommon"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.noinlinefunctions.756959633" name="Do not inline functions (-fno-inline-functions)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.noinlinefunctions"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.freestanding.1590959906" name="Assume freestanding environment (-ffreestanding)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.freestanding"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.nobuiltin.1042039327" name="Disable builtin (-fno-builtin)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.nobuiltin"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.spconstant.1039548956" name="Single precision constants (-fsingle-precision-constant)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.spconstant"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.PIC.1985811521" name="Position independent code (-fPIC)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.PIC"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.lto.1051530800" name="Link-time optimizer (-flto)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.lto"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.nomoveloopinvariants.1205914795" name="Disable loop invariant move (-fno-move-loop-invariants)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.nomoveloopinvariants"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.other.1954151846" name="Other optimization flags" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.other"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.toolchain.name.1744383700" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.toolchain.name" value="RISC-V GCC/Newlib" valueType="string"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.toolchain.id.493085227" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.toolchain.id" value="2262347901" valueType="string"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.syntaxonly.258175649" name="Check syntax only (-fsyntax-only)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.syntaxonly"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.pedantic.1226214321" name="Pedantic (-pedantic)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.pedantic"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.pedanticerrors.110062487" name="Pedantic warnings as errors (-pedantic-errors)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.pedanticerrors"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.nowarn.1919671717" name="Inhibit all warnings (-w)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.nowarn"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.unused.1821427624" name="Warn on various unused elements (-Wunused)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.unused"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.uninitialized.292398014" name="Warn on uninitialized variables (-Wuninitialised)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.uninitialized"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.allwarn.1309277289" name="Enable all common warnings (-Wall)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.allwarn"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.extrawarn.1558226400" name="Enable extra warnings (-Wextra)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.extrawarn"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.missingdeclaration.586697590" name="Warn on undeclared global function (-Wmissing-declaration)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.missingdeclaration"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.conversion.954958860" name="Warn on implicit conversions (-Wconversion)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.conversion"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.pointerarith.563944459" name="Warn if pointer arithmetic (-Wpointer-arith)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.pointerarith"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.padded.1545777759" name="Warn if padding is included (-Wpadded)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.padded"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.shadow.1629270130" name="Warn if shadowed variable (-Wshadow)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.shadow"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.logicalop.658467865" name="Warn if suspicious logical ops (-Wlogical-op)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.logicalop"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.agreggatereturn.971552745" name="Warn if struct is returned (-Wagreggate-return)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.agreggatereturn"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.floatequal.1598374590" name="Warn if floats are compared as equal (-Wfloat-equal)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.floatequal"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.toerrors.1396465302" name="Generate errors instead of warnings (-Werror)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.toerrors"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.other.1062181782" name="Other warning flags" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.other"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.level.1738140850" name="Debug level" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.level"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.format.792481645" name="Debug format" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.format"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.prof.953900793" name="Generate prof information (-p)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.prof"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.gprof.202548387" name="Generate gprof information (-pg)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.gprof"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.other.1881550968" name="Other debugging flags" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.other"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.showDevicesTab.975549113" name="showDevicesTab" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.showDevicesTab"/>
|
||||
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="ilg.gnumcueclipse.managedbuild.cross.riscv.targetPlatform.1497718471" isAbstract="false" osList="all" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.targetPlatform"/>
|
||||
<builder autoBuildTarget="all" cleanBuildTarget="clean" command="make" enableAutoBuild="false" enableCleanBuild="true" enabledIncrementalBuild="true" id="ilg.gnumcueclipse.managedbuild.cross.riscv.builder.1100306583" incrementalBuildTarget="BOARD=BL702_EVB APP=hellowd SAPP=helloworld" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" parallelBuildOn="false" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.builder"/>
|
||||
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.1060786402" name="GNU RISC-V Cross Assembler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler">
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.usepreprocessor.154864423" name="Use preprocessor" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.usepreprocessor" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<inputType id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.input.1096558861" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.input"/>
|
||||
</tool>
|
||||
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.952554633" name="GNU RISC-V Cross C Compiler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler">
|
||||
<inputType id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.input.141010239" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.input"/>
|
||||
</tool>
|
||||
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.compiler.1200181396" name="GNU RISC-V Cross C++ Compiler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.compiler">
|
||||
<inputType id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.compiler.input.1522176966" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.compiler.input"/>
|
||||
</tool>
|
||||
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.linker.734083223" 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.528465909" name="Remove unused sections (-Xlinker --gc-sections)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.gcsections" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
</tool>
|
||||
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.linker.2027828701" 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.1009157025" name="Remove unused sections (-Xlinker --gc-sections)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.gcsections" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<inputType id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.linker.input.807068426" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.linker.input">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
</inputType>
|
||||
</tool>
|
||||
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.archiver.1266046767" name="GNU RISC-V Cross Archiver" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.archiver"/>
|
||||
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.createflash.1181214240" 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.1777652181" 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.1728454125" 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.503927789" 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.603185590" 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.1295754826" 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.312765386" 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.964975723" 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.795673591" name="Size format" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.printsize.format" useByScannerDiscovery="false"/>
|
||||
</tool>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
</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="bl_mcu_sdk.null.805808530" name="bl_mcu_sdk"/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
<scannerConfigBuildInfo instanceId="ilg.gnumcueclipse.managedbuild.cross.riscv.toolchain.base.528944072;ilg.gnumcueclipse.managedbuild.cross.riscv.toolchain.base.528944072.1792346702;ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.compiler.1200181396;ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.compiler.input.1522176966">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="ilg.gnumcueclipse.managedbuild.cross.riscv.toolchain.base.528944072;ilg.gnumcueclipse.managedbuild.cross.riscv.toolchain.base.528944072.1792346702;ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.952554633;ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.input.141010239">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</scannerConfigBuildInfo>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||
<storageModule moduleId="refreshScope" versionNumber="2">
|
||||
<configuration configurationName="Default">
|
||||
<resource resourceType="PROJECT" workspacePath="/bl_mcu_sdk"/>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets">
|
||||
<buildTargets>
|
||||
<target name="bl_make" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments>BOARD=bl706_iot</buildArguments>
|
||||
<buildTarget>APP=helloworld</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>false</useDefaultCommand>
|
||||
<runAllBuilders>true</runAllBuilders>
|
||||
</target>
|
||||
<target name="bl_clean" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildTarget>clean</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>false</useDefaultCommand>
|
||||
<runAllBuilders>true</runAllBuilders>
|
||||
</target>
|
||||
<target name="download" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments>INTERFACE=jlink</buildArguments>
|
||||
<buildTarget>download</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>false</useDefaultCommand>
|
||||
<runAllBuilders>true</runAllBuilders>
|
||||
</target>
|
||||
</buildTargets>
|
||||
</storageModule>
|
||||
</cproject>
|
23
.gitignore
vendored
Normal file
23
.gitignore
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
out/*
|
||||
build/*
|
||||
.vscode/settings.json
|
||||
.settings
|
||||
|
||||
**/.cdk
|
||||
**/Lst
|
||||
**/Obj
|
||||
|
||||
examples/**/*.mk
|
||||
examples/**/*.cdkws
|
||||
!examples/bl_mcu_sdk.cdkws
|
||||
examples/**/*.mk
|
||||
examples/**/*.bat
|
||||
examples/**/cdk/*.txt
|
||||
|
||||
tools/bflb_flash_tool/chips/bl702/eflash_loader/eflash_loader_cfg.ini
|
||||
tools/bflb_flash_tool/chips/bl702/img_create_mcu/bootinfo.bin
|
||||
tools/bflb_flash_tool/chips/bl702/img_create_mcu/img.bin
|
||||
tools/bflb_flash_tool/chips/bl702/img_create_mcu/whole_img.bin
|
||||
tools/bflb_flash_tool/chips/bl702/img_create_mcu/whole_img.pack
|
||||
tools/bflb_flash_tool/img/project.bin
|
||||
tools/bflb_flash_tool/log/*
|
27
.project
Normal file
27
.project
Normal file
@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>bl_mcu_sdk</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||
<triggers>clean,full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
|
||||
<triggers>full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.cdt.core.cnature</nature>
|
||||
<nature>org.eclipse.cdt.core.ccnature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
23
CMakeLists.txt
Normal file
23
CMakeLists.txt
Normal file
@ -0,0 +1,23 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/tools/cmake/riscv64-unknown-elf-gcc.cmake)
|
||||
include(${CMAKE_SOURCE_DIR}/tools/cmake/compiler_flags.cmake)
|
||||
include(${CMAKE_SOURCE_DIR}/tools/cmake/tools.cmake)
|
||||
|
||||
PROJECT(${BOARD} C CXX ASM)
|
||||
|
||||
include_directories(${CMAKE_SOURCE_DIR}/common/misc)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/bsp/bsp_common/platform)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/bsp/board/${BOARD})
|
||||
|
||||
add_subdirectory(common)
|
||||
add_subdirectory(components/fatfs)
|
||||
add_subdirectory(components/usb_stack)
|
||||
add_subdirectory(drivers/${mcu}_driver)
|
||||
|
||||
if(${SUPPORT_SHELL} STREQUAL "ENABLE")
|
||||
add_subdirectory(components/shell)
|
||||
else()
|
||||
endif()
|
||||
|
||||
search_application(${CMAKE_SOURCE_DIR}/examples)
|
||||
|
82
Jlink_bl_mcu_sdk.launch
Normal file
82
Jlink_bl_mcu_sdk.launch
Normal file
@ -0,0 +1,82 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="ilg.gnumcueclipse.debug.gdbjtag.jlink.launchConfigurationType">
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.doConnectToRunning" value="false"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.doContinue" value="true"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.doDebugInRam" value="false"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.doFirstReset" value="true"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.doGdbServerAllocateConsole" value="true"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.doGdbServerAllocateSemihostingConsole" value="true"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.doGdbServerInitRegs" value="true"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.doGdbServerLocalOnly" value="true"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.doGdbServerSilent" value="false"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.doGdbServerVerifyDownload" value="true"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.doSecondReset" value="true"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.doStartGdbServer" value="true"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.enableFlashBreakpoints" value="true"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.enableSemihosting" value="false"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.enableSemihostingIoclientGdbClient" value="false"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.enableSemihostingIoclientTelnet" value="true"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.enableSwo" value="true"/>
|
||||
<intAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.firstResetSpeed" value="1000"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.firstResetType" value=""/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.gdbClientOtherCommands" value="set mem inaccessible-by-default off"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.gdbClientOtherOptions" value="-x tools\openocd\702.init"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.gdbServerConnection" value="usb"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.gdbServerConnectionAddress" value=""/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.gdbServerDebugInterface" value="jtag"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.gdbServerDeviceEndianness" value="little"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.gdbServerDeviceName" value="RV32"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.gdbServerDeviceSpeed" value="1000"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.gdbServerExecutable" value="${jlink_path}/${jlink_gdbserver}"/>
|
||||
<intAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.gdbServerGdbPortNumber" value="2331"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.gdbServerLog" value=""/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.gdbServerOther" value="-singlerun -strict -timeout 0 -nogui"/>
|
||||
<intAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.gdbServerSwoPortNumber" value="2332"/>
|
||||
<intAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.gdbServerTelnetPortNumber" value="2333"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.interfaceSpeed" value="auto"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.otherInitCommands" value=""/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.otherRunCommands" value=""/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.secondResetType" value=""/>
|
||||
<intAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.swoEnableTargetCpuFreq" value="0"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.swoEnableTargetPortMask" value="0x1"/>
|
||||
<intAttribute key="ilg.gnumcueclipse.debug.gdbjtag.jlink.swoEnableTargetSwoFreq" value="0"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.svdPath" value="D:\BouffaloLabWS\bl_mcu_sdk\drivers\bl702_driver\regs\soc702_reg.svd"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageFileName" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageOffset" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.ipAddress" value="localhost"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDevice" value="GNU MCU J-Link"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadImage" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadSymbols" value="true"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value="21000000"/>
|
||||
<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.portNumber" value="2331"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setResume" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setStopAt" value="true"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.stopAt" value="main"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsFileName" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsOffset" value=""/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForImage" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForSymbols" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForImage" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForSymbols" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useRemoteTarget" value="true"/>
|
||||
<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="${cross_prefix}gdb${cross_suffix}"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.UPDATE_THREADLIST_ON_SUSPEND" value="false"/>
|
||||
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="0"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="D:\BouffaloLabWS\bl_mcu_sdk\out\hellowd\helloworld\helloworld_main.elf"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="bl_mcu_sdk"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="true"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="ilg.gnumcueclipse.managedbuild.cross.riscv.toolchain.base.528944072"/>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/bl_mcu_sdk"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="4"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.cdt.debug.core.sourceLocator"/>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;mapping backend_enabled=&quot;true&quot; name=&quot;New Mapping&quot;&gt;&#13;&#10; &lt;mapEntry memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;mapEntry backendPath=&amp;quot;/mnt/c/root&amp;quot; localPath=&amp;quot;C:\root&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&quot;/&gt;&#13;&#10;&lt;/mapping&gt;&#13;&#10;" typeId="org.eclipse.cdt.debug.core.containerType.mapping"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;workspace/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.workspace"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;default/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/>
|
||||
<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList context="Context string"> <memoryBlockExpression address="1073742128" label="0x40000130"/> </memoryBlockExpressionList> "/>
|
||||
<stringAttribute key="org.eclipse.embedcdt.debug.gdbjtag.core.PERIPHERALS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <peripherals/> "/>
|
||||
<stringAttribute key="process_factory_id" value="org.eclipse.cdt.dsf.gdb.GdbProcessFactory"/>
|
||||
</launchConfiguration>
|
202
LICENSE
Normal file
202
LICENSE
Normal file
@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [2020] [BOUFFALO LAB (NANJING) CO., LTD.]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
24
Makefile
Normal file
24
Makefile
Normal file
@ -0,0 +1,24 @@
|
||||
BOARD?=bl706_iot
|
||||
APP?=helloworld
|
||||
CHIP?=bl702
|
||||
INTERFACE?=jlink
|
||||
BAUDRATE ?=12000
|
||||
|
||||
export BOARD
|
||||
export APP
|
||||
# The command to remove a file.
|
||||
RM = cmake -E rm -rf
|
||||
|
||||
build:
|
||||
cmake -E make_directory build
|
||||
cmake -E copy project.build build
|
||||
make -C ./build -f ./project.build
|
||||
|
||||
download:
|
||||
./tools/bflb_flash_tool/bflb_mcu_tool --chipname=$(CHIP) --interface=$(INTERFACE) --baudrate=$(BAUDRATE)
|
||||
|
||||
clean:
|
||||
$(RM) out
|
||||
$(RM) build
|
||||
.PHONY:build clean download
|
||||
|
1
Preload.cmake
Normal file
1
Preload.cmake
Normal file
@ -0,0 +1 @@
|
||||
set(CMAKE_GENERATOR "Unix Makefiles" CACHE INTERNAL "" FORCE)
|
117
README.md
Normal file
117
README.md
Normal file
@ -0,0 +1,117 @@
|
||||
# 简介
|
||||
|
||||
**bl mcu sdk** 是博流智能科技团队专为 BL602/BL604,BL702/BL704/BL706 以及未来其他系列芯片提供的 MCU 软件开发包。
|
||||
|
||||
## 代码框架
|
||||
|
||||
```
|
||||
|
||||
bl_mcu_sdk
|
||||
├── bsp
|
||||
│ ├── board
|
||||
│ │ ├── bl706_avb
|
||||
│ │ ├── bl706_iot
|
||||
│ │ └── bl602_xxx
|
||||
│ └── bsp_common
|
||||
├── common
|
||||
│ ├── device
|
||||
│ ├── libc
|
||||
│ ├── list
|
||||
│ ├── memheap
|
||||
│ ├── misc
|
||||
│ ├── partition
|
||||
│ ├── ring_buffer
|
||||
│ └── soft_crc
|
||||
├── components
|
||||
│ ├── fatfs
|
||||
│ ├── freertos
|
||||
│ ├── shell
|
||||
│ └── usb_stack
|
||||
├── docs
|
||||
│ ├── bl70x_docs
|
||||
│ ├── development_guide
|
||||
├── drivers
|
||||
│ ├── bl602_driver
|
||||
│ └── bl702_driver
|
||||
├── examples
|
||||
│ ├── adc
|
||||
│ ├── audio
|
||||
│ ├── camera
|
||||
│ ├── coremark
|
||||
│ ├── dac
|
||||
│ ├── dhrystone
|
||||
│ ├── dma
|
||||
│ ├── gpio
|
||||
│ ├── hellowd
|
||||
│ ├── i2c
|
||||
│ ├── i2s
|
||||
│ ├── memheap
|
||||
│ ├── spi
|
||||
│ ├── uart
|
||||
│ └── usb
|
||||
├── out
|
||||
└── tools
|
||||
├── bflb_flash_tool
|
||||
├── cdk_flashloader
|
||||
├── cmake
|
||||
└── openocd
|
||||
|
||||
```
|
||||
|
||||
- bsp 存放板级相关的配置文件和驱动。
|
||||
- common 存放一些常见的函数库
|
||||
- components 存放第三方库
|
||||
- drivers 存放芯片外设驱动库
|
||||
- examples 存放外设 demo
|
||||
- out 存放目标文件输出路径
|
||||
- tools 存放一些工具包
|
||||
|
||||
# 资源
|
||||
|
||||
## 硬件资源
|
||||
|
||||
- BL706 IOT 开发板
|
||||
- BL706 AVB 开发板
|
||||
|
||||
## 芯片手册
|
||||
|
||||
[芯片参考手册](https://dev.bouffalolab.com/media/upload/doc/BL702_BL704_706_RM_zh_CN_1.1.pdf)|[芯片数据手册](https://dev.bouffalolab.com/media/upload/doc/BL702_BL704_BL706_DS_zh_CN_Combo_1.7.pdf)
|
||||
|
||||
更多资料请访问 BouffaloLab 开发者网站: [https://dev.bouffalolab.com/](https://dev.bouffalolab.com/)
|
||||
|
||||
## 文档教程
|
||||
|
||||
[bl mcu sdk 文档教程](http://bouffalolab.gitee.io/bl_mcu_sdk)
|
||||
|
||||
## 视频教程
|
||||
|
||||
- [五分钟带你了解 RISC-V 的指令集架构](https://www.bilibili.com/video/BV1aA411L77o)
|
||||
- [BL706 开发板基于 Eclipse 的环境搭建](https://www.bilibili.com/video/BV1HK4y1o7P1)
|
||||
- [BL706 开发板基于 CDK 的环境搭建](https://www.bilibili.com/video/BV14U4y1h7d2)
|
||||
|
||||
## 工具
|
||||
|
||||
- [Eclipse](https://dev.bouffalolab.com/media/upload/download/BouffaloLab_eclipse_x86_64_win.zip) Windows 下 eclipse 开发免安装包
|
||||
- [CDK](https://occ.t-head.cn/development/activities/cdk) ,平头哥剑池 CDK 集成开发环境,建议使用 CDK v2.8.4 以上版本
|
||||
- [cmake 3.19](https://cmake.org/files/v3.19/) , cmake 编译工具,建议使用 cmake v3.19 以上版本
|
||||
- [J-Link v10](https://www.segger.com/downloads/jlink), J-Link 调试器,用于在线调试芯片,建议使用 J-Link V10 以上版本硬件,软件驱动建议使用 V6.98 版本
|
||||
|
||||
博流提供的图形化烧写工具:
|
||||
- [Bouffalo Lab Dev Cube For Windows](https://dev.bouffalolab.com/media/upload/download/BouffaloLabDevCube-1.5.0-win32.zip)
|
||||
- [Bouffalo Lab Dev Cube For Ubuntu](https://dev.bouffalolab.com/media/upload/download/bouffalo_build_tool_for_ubuntu_v1.0.0.rar)
|
||||
|
||||
## 论坛
|
||||
|
||||
博流开发者交流论坛: [https://bbs.bouffalolab.com/](https://bbs.bouffalolab.com/)
|
||||
|
||||
# 许可协议
|
||||
|
||||
**bl mcu sdk** 完全开源,遵循 Apache License 2.0 开源许可协议,可以免费在商业产品中使用,并且不需要公开私有代码。
|
||||
|
||||
```
|
||||
/*
|
||||
* Copyright (c) 2021 Bouffalolab team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
```
|
62
bl_mcu_flash.launch
Normal file
62
bl_mcu_flash.launch
Normal file
@ -0,0 +1,62 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="ilg.gnumcueclipse.debug.gdbjtag.openocd.launchConfigurationType">
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.doContinue" value="true"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.doDebugInRam" value="false"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.doFirstReset" value="true"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.doGdbServerAllocateConsole" value="true"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.doGdbServerAllocateTelnetConsole" value="false"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.doSecondReset" value="true"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.doStartGdbCLient" value="true"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.doStartGdbServer" value="true"/>
|
||||
<booleanAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.enableSemihosting" value="false"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.firstResetType" value="init"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.gdbClientOtherCommands" value="set mem inaccessible-by-default off"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.gdbClientOtherOptions" value="-x tools\openocd\702.init"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.gdbServerConnectionAddress" value=""/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.gdbServerExecutable" value="${openocd_path}/${openocd_executable}"/>
|
||||
<intAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.gdbServerGdbPortNumber" value="3333"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.gdbServerLog" value=""/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.gdbServerOther" value="-f tools\openocd\if_bflb_dbg.cfg -f tools\openocd\tgt_702.cfg"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.gdbServerTclPortNumber" value="6666"/>
|
||||
<intAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.gdbServerTelnetPortNumber" value="4444"/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.otherInitCommands" value=""/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.otherRunCommands" value=""/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.openocd.secondResetType" value=""/>
|
||||
<stringAttribute key="ilg.gnumcueclipse.debug.gdbjtag.svdPath" value="${project_loc}\drivers\bl702_driver\regs\soc702_reg.svd"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageFileName" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageOffset" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.ipAddress" value="localhost"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDevice" value="GNU MCU OpenOCD"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadImage" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadSymbols" value="true"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value="21000000"/>
|
||||
<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.portNumber" value="3333"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setResume" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setStopAt" value="true"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.stopAt" value="main"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsFileName" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsOffset" value=""/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForImage" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForSymbols" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForImage" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForSymbols" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useRemoteTarget" value="true"/>
|
||||
<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="${eclipse_home}\riscv64-unknown-elf-gcc-mingw32\bin\riscv64-unknown-elf-gdb.exe"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.UPDATE_THREADLIST_ON_SUSPEND" value="false"/>
|
||||
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="0"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="D:\BouffaloLabWS\bl_mcu_sdk\out\adc\adc_one_signle_test.elf"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="bl_mcu_sdk"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="true"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="ilg.gnumcueclipse.managedbuild.cross.riscv.toolchain.base.528944072"/>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/bl_mcu_sdk"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="4"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList context="Context string"/> "/>
|
||||
<stringAttribute key="org.eclipse.embedcdt.debug.gdbjtag.core.PERIPHERALS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <peripherals/> "/>
|
||||
<stringAttribute key="process_factory_id" value="org.eclipse.cdt.dsf.gdb.GdbProcessFactory"/>
|
||||
</launchConfiguration>
|
7
bsp/board/bl706_avb/bl702_config.h
Normal file
7
bsp/board/bl706_avb/bl702_config.h
Normal file
@ -0,0 +1,7 @@
|
||||
#ifndef __BL702_CONFIG_H__
|
||||
#define __BL702_CONFIG_H__
|
||||
|
||||
#include "peripheral_config.h"
|
||||
#include "clock_config.h"
|
||||
|
||||
#endif
|
235
bsp/board/bl706_avb/board.c
Normal file
235
bsp/board/bl706_avb/board.c
Normal file
@ -0,0 +1,235 @@
|
||||
#include "hal_gpio.h"
|
||||
#include "hal_clock.h"
|
||||
#include "bl702_glb.h"
|
||||
#include "pinmux_config.h"
|
||||
|
||||
struct pin_mux_cfg
|
||||
{
|
||||
uint8_t pin;
|
||||
uint16_t func;
|
||||
};
|
||||
|
||||
static const struct pin_mux_cfg af_pin_table[] =
|
||||
{
|
||||
{
|
||||
.pin = GPIO_PIN_0,
|
||||
.func = CONFIG_GPIO0_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_1,
|
||||
.func = CONFIG_GPIO1_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_2,
|
||||
.func = CONFIG_GPIO2_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_3,
|
||||
.func = CONFIG_GPIO3_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_4,
|
||||
.func = CONFIG_GPIO4_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_5,
|
||||
.func = CONFIG_GPIO5_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_6,
|
||||
.func = CONFIG_GPIO6_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_7,
|
||||
.func = CONFIG_GPIO7_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_8,
|
||||
.func = CONFIG_GPIO8_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_9,
|
||||
.func = CONFIG_GPIO9_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_10,
|
||||
.func = CONFIG_GPIO10_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_11,
|
||||
.func = CONFIG_GPIO11_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_12,
|
||||
.func = CONFIG_GPIO12_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_13,
|
||||
.func = CONFIG_GPIO13_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_14,
|
||||
.func = CONFIG_GPIO14_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_15,
|
||||
.func = CONFIG_GPIO15_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_16,
|
||||
.func = CONFIG_GPIO16_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_17,
|
||||
.func = CONFIG_GPIO17_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_18,
|
||||
.func = CONFIG_GPIO18_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_19,
|
||||
.func = CONFIG_GPIO19_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_20,
|
||||
.func = CONFIG_GPIO20_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_21,
|
||||
.func = CONFIG_GPIO21_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_22,
|
||||
.func = CONFIG_GPIO22_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_23,
|
||||
.func = CONFIG_GPIO23_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_24,
|
||||
.func = CONFIG_GPIO24_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_25,
|
||||
.func = CONFIG_GPIO25_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_26,
|
||||
.func = CONFIG_GPIO26_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_27,
|
||||
.func = CONFIG_GPIO27_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_28,
|
||||
.func = CONFIG_GPIO28_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_29,
|
||||
.func = CONFIG_GPIO29_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_30,
|
||||
.func = CONFIG_GPIO30_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_31,
|
||||
.func = CONFIG_GPIO31_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_32,
|
||||
.func = CONFIG_GPIO32_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_33,
|
||||
.func = CONFIG_GPIO33_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_34,
|
||||
.func = CONFIG_GPIO34_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_35,
|
||||
.func = CONFIG_GPIO35_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_36,
|
||||
.func = CONFIG_GPIO36_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_37,
|
||||
.func = CONFIG_GPIO37_FUNC
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
static void board_pin_mux_init(void)
|
||||
{
|
||||
GLB_GPIO_Cfg_Type gpio_cfg;
|
||||
|
||||
gpio_cfg.drive = 0;
|
||||
gpio_cfg.smtCtrl = 1;
|
||||
gpio_cfg.gpioMode = GPIO_MODE_AF;
|
||||
gpio_cfg.pullType = GPIO_PULL_UP;
|
||||
|
||||
for (int i = 0; i < sizeof(af_pin_table)/sizeof(af_pin_table[0]); i++)
|
||||
{
|
||||
gpio_cfg.gpioPin = af_pin_table[i].pin;
|
||||
gpio_cfg.gpioFun = af_pin_table[i].func;
|
||||
|
||||
if(af_pin_table[i].func == GPIO_FUN_UNUSED)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if(af_pin_table[i].func == GPIO_FUN_PWM)
|
||||
{
|
||||
gpio_cfg.pullType = GPIO_PULL_DOWN;
|
||||
}
|
||||
else if((af_pin_table[i].func & 0x70) == 0x70)
|
||||
{
|
||||
gpio_cfg.gpioFun = GPIO_FUN_UART;
|
||||
uint8_t sig = af_pin_table[i].func & 0x07;
|
||||
GLB_UART_Fun_Sel((gpio_cfg.gpioPin % 8), sig);
|
||||
}
|
||||
GLB_GPIO_Init(&gpio_cfg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void board_clock_init(void)
|
||||
{
|
||||
system_clock_init();
|
||||
peripheral_clock_init();
|
||||
}
|
||||
|
||||
void bl_show_info(void)
|
||||
{
|
||||
MSG(" ____ __ __ _ _ _ \r\n");
|
||||
MSG(" | _ \\ / _|/ _| | | | | | | \r\n");
|
||||
MSG(" | |_) | ___ _ _| |_| |_ __ _| | ___ | | __ _| |__ \r\n");
|
||||
MSG(" | _ < / _ \\| | | | _| _/ _` | |/ _ \\| |/ _` | '_ \\ \r\n");
|
||||
MSG(" | |_) | (_) | |_| | | | || (_| | | (_) | | (_| | |_) |\r\n");
|
||||
MSG(" |____/ \\___/ \\__,_|_| |_| \\__,_|_|\\___/|_|\\__,_|_.__/ \r\n");
|
||||
MSG("\r\n");
|
||||
MSG("Build:%s,%s\r\n",__TIME__,__DATE__);
|
||||
MSG("2016 - 2030 Copyright by bouffalolab team\r\n");
|
||||
|
||||
#if 0
|
||||
MSG("root clock:%dM\r\n",system_clock_get(SYSTEM_CLOCK_ROOT_CLOCK)/1000000);
|
||||
MSG("fclk clock:%dM\r\n",system_clock_get(SYSTEM_CLOCK_FCLK)/1000000);
|
||||
MSG("bclk clock:%dM\r\n",system_clock_get(SYSTEM_CLOCK_BCLK)/1000000);
|
||||
|
||||
MSG("uart clock:%dM\r\n",peripheral_clock_get(PERIPHERAL_CLOCK_UART)/1000000);
|
||||
MSG("spi clock:%dM\r\n",peripheral_clock_get(PERIPHERAL_CLOCK_SPI)/1000000);
|
||||
MSG("i2c clock:%dM\r\n",peripheral_clock_get(PERIPHERAL_CLOCK_I2C)/1000000);
|
||||
#endif
|
||||
}
|
||||
|
||||
void board_init(void)
|
||||
{
|
||||
board_clock_init();
|
||||
board_pin_mux_init();
|
||||
}
|
44
bsp/board/bl706_avb/clock_config.h
Normal file
44
bsp/board/bl706_avb/clock_config.h
Normal file
@ -0,0 +1,44 @@
|
||||
#ifndef _CLOCK_CONFIG_H
|
||||
#define _CLOCK_CONFIG_H
|
||||
|
||||
#define BSP_ROOT_CLOCK_SOURCE ROOT_CLOCK_SOURCE_DLL_144M
|
||||
|
||||
#if defined(BSP_ROOT_CLOCK_SOURCE)
|
||||
#define BSP_HCLK_DIV 0
|
||||
#define BSP_BCLK_DIV 1
|
||||
#endif
|
||||
|
||||
#if defined(BSP_USING_UART0)||defined(BSP_USING_UART1)
|
||||
#define BSP_UART_CLOCK_SOURCE ROOT_CLOCK_SOURCE_DLL_96M
|
||||
#define BSP_UART_CLOCK_DIV 0
|
||||
#endif
|
||||
#if defined(BSP_USING_I2C0)
|
||||
#define BSP_I2C_CLOCK_SOURCE ROOT_CLOCK_SOURCE_DLL_BCLK
|
||||
#define BSP_I2C_CLOCK_DIV 0
|
||||
#endif
|
||||
#if defined(BSP_USING_SPI0)
|
||||
#define BSP_SPI_CLOCK_SOURCE ROOT_CLOCK_SOURCE_DLL_BCLK
|
||||
#define BSP_SPI_CLOCK_DIV 0
|
||||
#endif
|
||||
#if defined(BSP_USING_PWM)
|
||||
#define BSP_PWM_CLOCK_SOURCE ROOT_CLOCK_SOURCE_DLL_XCLK
|
||||
#define BSP_PWM_CLOCK_DIV 0
|
||||
#endif
|
||||
#if defined(BSP_USING_IR)
|
||||
#define BSP_IR_CLOCK_SOURCE ROOT_CLOCK_SOURCE_DLL_XCLK
|
||||
#define BSP_IR_CLOCK_DIV 0
|
||||
#endif
|
||||
#if defined(BSP_USING_I2S0)
|
||||
#define BSP_I2S_CLOCK_SOURCE ROOT_CLOCK_SOURCE_DLL_XCLK
|
||||
#define BSP_I2S_CLOCK_DIV 0
|
||||
#endif
|
||||
#if defined(BSP_USING_ADC0)
|
||||
#define BSP_ADC_CLOCK_SOURCE ROOT_CLOCK_SOURCE_DLL_XCLK
|
||||
#define BSP_ADC_CLOCK_DIV 0
|
||||
#endif
|
||||
#if defined(BSP_USING_DAC0)
|
||||
#define BSP_DAC_CLOCK_SOURCE ROOT_CLOCK_SOURCE_DLL_XCLK
|
||||
#define BSP_DAC_CLOCK_DIV 0
|
||||
#endif
|
||||
|
||||
#endif
|
278
bsp/board/bl706_avb/peripheral_config.h
Normal file
278
bsp/board/bl706_avb/peripheral_config.h
Normal file
@ -0,0 +1,278 @@
|
||||
#ifndef _PERIPHERAL_CONFIG_H_
|
||||
#define _PERIPHERAL_CONFIG_H_
|
||||
|
||||
/* PERIPHERAL USING LIST */
|
||||
#define BSP_USING_ADC0
|
||||
#define BSP_USING_DAC0
|
||||
#define BSP_USING_UART0
|
||||
#define BSP_USING_UART1
|
||||
#define BSP_USING_SPI0
|
||||
#define BSP_USING_I2C0
|
||||
#define BSP_USING_I2S0
|
||||
#define BSP_USING_USB
|
||||
#define BSP_USING_PWM0
|
||||
/* ----------------------*/
|
||||
|
||||
|
||||
/* PERIPHERAL With DMA LIST */
|
||||
|
||||
#define BSP_USING_DMA0_CH0
|
||||
#define BSP_USING_DMA0_CH1
|
||||
|
||||
#ifdef BSP_USING_UART1
|
||||
#define BSP_USING_DMA0_CH2
|
||||
#endif
|
||||
|
||||
#ifdef BSP_USING_SPI0
|
||||
#define BSP_USING_DMA0_CH3
|
||||
#define BSP_USING_DMA0_CH4
|
||||
#endif
|
||||
|
||||
#ifdef BSP_USING_I2S0
|
||||
#define BSP_USING_DMA0_CH2
|
||||
#endif
|
||||
|
||||
#ifdef BSP_USING_DAC0
|
||||
#define BSP_USING_DMA0_CH6
|
||||
#endif
|
||||
|
||||
|
||||
/* PERIPHERAL CONFIG */
|
||||
#if defined(BSP_USING_ADC0)
|
||||
#ifndef ADC_CONFIG
|
||||
#define ADC_CONFIG \
|
||||
{ \
|
||||
.clk = ADC_CLK_500KHZ,\
|
||||
.vref = ADC_VREF_3P2V,\
|
||||
.resWidth = ADC_DATA_WIDTH_16_WITH_256_AVERAGE,\
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(BSP_USING_DAC0)
|
||||
#ifndef DAC_CONFIG
|
||||
#define DAC_CONFIG \
|
||||
{ \
|
||||
.clk = DAC_CLK_500KHZ,\
|
||||
.pin.dac0 = GLB_GPIO_PIN_11,\
|
||||
.pin.pin_num = 1,\
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(BSP_USING_UART0)
|
||||
#ifndef UART0_CONFIG
|
||||
#define UART0_CONFIG \
|
||||
{ \
|
||||
.id = 0, \
|
||||
.baudrate = 2000000,\
|
||||
.databits = UART_DATA_LEN_8, \
|
||||
.stopbits = UART_STOP_ONE, \
|
||||
.parity = UART_PAR_NONE, \
|
||||
.fifo_threshold = 1, \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(BSP_USING_UART1)
|
||||
#ifndef UART1_CONFIG
|
||||
#define UART1_CONFIG \
|
||||
{ \
|
||||
.id = 1, \
|
||||
.baudrate = 2000000,\
|
||||
.databits = UART_DATA_LEN_8, \
|
||||
.stopbits = UART_STOP_ONE, \
|
||||
.parity = UART_PAR_NONE, \
|
||||
.fifo_threshold = 64, \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(BSP_USING_SPI0)
|
||||
#ifndef SPI0_CONFIG
|
||||
#define SPI0_CONFIG \
|
||||
{ \
|
||||
.id = 0, \
|
||||
.clk = 18000000,\
|
||||
.mode = SPI_MASTER_MODE, \
|
||||
.direction = SPI_MSB_BYTE0_DIRECTION_FIRST, \
|
||||
.clk_polaraity = SPI_POLARITY_LOW, \
|
||||
.clk_phase = SPI_PHASE_1EDGE, \
|
||||
.datasize = SPI_DATASIZE_8BIT, \
|
||||
.fifo_threshold = 1, \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(BSP_USING_PWM0)
|
||||
#ifndef PWM_CONFIG_0
|
||||
#define PWM_CONFIG_0 \
|
||||
{ \
|
||||
.pin = GPIO_PIN_22, \
|
||||
.frequency = 1000000, \
|
||||
.dutyCycle = 0, \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(BSP_USING_I2S0)
|
||||
#ifndef I2S0_CONFIG
|
||||
#define I2S0_CONFIG \
|
||||
{ \
|
||||
.id = 0, \
|
||||
.iis_mode = I2S_MODE_MASTER,\
|
||||
.interface_mode = I2S_MODE_LEFT, \
|
||||
.sampl_freq_hz = 16*1000, \
|
||||
.channel_num = I2S_FS_CHANNELS_NUM_MONO, \
|
||||
.frame_size = I2S_FRAME_LEN_16, \
|
||||
.data_size = I2S_DATA_LEN_16, \
|
||||
.fifo_threshold = 8, \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(BSP_USING_DMA0_CH0)
|
||||
#ifndef DMA0_CH0_CONFIG
|
||||
#define DMA0_CH0_CONFIG \
|
||||
{ \
|
||||
.id = 0, \
|
||||
.ch = 0,\
|
||||
.direction = DMA_MEMORY_TO_MEMORY,\
|
||||
.transfer_mode = DMA_LLI_ONCE_MODE, \
|
||||
.src_req = DMA_REQUEST_NONE, \
|
||||
.dst_req = DMA_REQUEST_NONE, \
|
||||
.src_width = DMA_TRANSFER_WIDTH_32BIT , \
|
||||
.dst_width = DMA_TRANSFER_WIDTH_32BIT , \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(BSP_USING_DMA0_CH1)
|
||||
#ifndef DMA0_CH1_CONFIG
|
||||
#define DMA0_CH1_CONFIG \
|
||||
{ \
|
||||
.id = 0, \
|
||||
.ch = 1,\
|
||||
.direction = DMA_MEMORY_TO_MEMORY, \
|
||||
.transfer_mode = DMA_LLI_ONCE_MODE, \
|
||||
.src_req = DMA_REQUEST_NONE, \
|
||||
.dst_req = DMA_REQUEST_NONE, \
|
||||
.src_width = DMA_TRANSFER_WIDTH_16BIT , \
|
||||
.dst_width = DMA_TRANSFER_WIDTH_16BIT , \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(BSP_USING_DMA0_CH2)
|
||||
#ifndef DMA0_CH2_CONFIG
|
||||
#define DMA0_CH2_CONFIG \
|
||||
{ \
|
||||
.id = 0, \
|
||||
.ch = 2,\
|
||||
.direction = DMA_MEMORY_TO_PERIPH, \
|
||||
.transfer_mode = DMA_LLI_ONCE_MODE, \
|
||||
.src_req = DMA_REQUEST_NONE, \
|
||||
.dst_req = DMA_REQUEST_UART1_TX, \
|
||||
.src_width = DMA_TRANSFER_WIDTH_8BIT , \
|
||||
.dst_width = DMA_TRANSFER_WIDTH_8BIT , \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(BSP_USING_DMA0_CH3)
|
||||
#ifndef DMA0_CH3_CONFIG
|
||||
#define DMA0_CH3_CONFIG \
|
||||
{ \
|
||||
.id = 0, \
|
||||
.ch = 3,\
|
||||
.direction = DMA_MEMORY_TO_PERIPH, \
|
||||
.transfer_mode = DMA_LLI_ONCE_MODE, \
|
||||
.src_req = DMA_REQUEST_NONE, \
|
||||
.dst_req = DMA_REQUEST_SPI0_TX, \
|
||||
.src_width = DMA_TRANSFER_WIDTH_8BIT , \
|
||||
.dst_width = DMA_TRANSFER_WIDTH_8BIT , \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(BSP_USING_DMA0_CH4)
|
||||
#ifndef DMA0_CH4_CONFIG
|
||||
#define DMA0_CH4_CONFIG \
|
||||
{ \
|
||||
.id = 0, \
|
||||
.ch = 4,\
|
||||
.direction = DMA_PERIPH_TO_MEMORY, \
|
||||
.transfer_mode = DMA_LLI_ONCE_MODE, \
|
||||
.src_req = DMA_REQUEST_SPI0_RX, \
|
||||
.dst_req = DMA_REQUEST_NONE, \
|
||||
.src_width = DMA_TRANSFER_WIDTH_8BIT , \
|
||||
.dst_width = DMA_TRANSFER_WIDTH_8BIT , \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(BSP_USING_DMA0_CH5)
|
||||
#ifndef DMA0_CH5_CONFIG
|
||||
#define DMA0_CH5_CONFIG \
|
||||
{ \
|
||||
.id = 0, \
|
||||
.ch = 5,\
|
||||
.direction = DMA_MEMORY_TO_PERIPH, \
|
||||
.transfer_mode = DMA_LLI_CYCLE_MODE, \
|
||||
.src_req = DMA_REQUEST_NONE, \
|
||||
.dst_req = DMA_REQUEST_I2S_TX, \
|
||||
.src_width = DMA_TRANSFER_WIDTH_16BIT , \
|
||||
.dst_width = DMA_TRANSFER_WIDTH_16BIT , \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(BSP_USING_DMA0_CH6)
|
||||
#ifndef DMA0_CH6_CONFIG
|
||||
#define DMA0_CH6_CONFIG \
|
||||
{ \
|
||||
.id = 0, \
|
||||
.ch = 6,\
|
||||
.direction = DMA_MEMORY_TO_PERIPH, \
|
||||
.transfer_mode = DMA_LLI_CYCLE_MODE, \
|
||||
.src_req = DMA_REQUEST_NONE, \
|
||||
.dst_req = DMA_REQUEST_I2S_TX, \
|
||||
.src_width = DMA_TRANSFER_WIDTH_16BIT , \
|
||||
.dst_width = DMA_TRANSFER_WIDTH_16BIT , \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(BSP_USING_DMA0_CH7)
|
||||
#ifndef DMA0_CH7_CONFIG
|
||||
#define DMA0_CH7_CONFIG \
|
||||
{ \
|
||||
.id = 0, \
|
||||
.ch = 0,\
|
||||
.direction = DMA_MEMORY_TO_MEMORY,\
|
||||
.transfer_mode = DMA_LLI_ONCE_MODE, \
|
||||
.src_req = DMA_REQUEST_NONE, \
|
||||
.dst_req = DMA_REQUEST_NONE, \
|
||||
.src_width = DMA_TRANSFER_WIDTH_32BIT , \
|
||||
.dst_width = DMA_TRANSFER_WIDTH_32BIT , \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if defined(BSP_USING_I2C0)
|
||||
#ifndef I2C0_CONFIG
|
||||
#define I2C0_CONFIG \
|
||||
{ \
|
||||
.id = 0, \
|
||||
.mode = I2C_HW_MODE,\
|
||||
.phase = 15, \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
180
bsp/board/bl706_avb/pinmux_config.h
Normal file
180
bsp/board/bl706_avb/pinmux_config.h
Normal file
@ -0,0 +1,180 @@
|
||||
/**
|
||||
* @file pinmux_config.h
|
||||
* @brief
|
||||
*
|
||||
* Copyright (c) 2021 Bouffalolab team
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
#ifndef _PINMUX_CONFIG_H
|
||||
#define _PINMUX_CONFIG_H
|
||||
|
||||
// <<< Use Configuration Wizard in Context Menu >>>
|
||||
|
||||
// <q> GPIO0 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio0 function
|
||||
#define CONFIG_GPIO0_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO1 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_CTS//GPIO_FUN_UART1_CTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio1 function
|
||||
#define CONFIG_GPIO1_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO2 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_TX//GPIO_FUN_UART1_TX//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio2 function
|
||||
#define CONFIG_GPIO2_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO3 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RX//GPIO_FUN_UART1_RX//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio3 function
|
||||
#define CONFIG_GPIO3_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO4 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio4 function
|
||||
#define CONFIG_GPIO4_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO5 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_CTS//GPIO_FUN_UART1_CTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio5 function
|
||||
#define CONFIG_GPIO5_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO6 <2> [GPIO_FUN_UNUSED//GPIO_FUN_CLK_OUT//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_TX//GPIO_FUN_UART1_TX//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio6 function
|
||||
#define CONFIG_GPIO6_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO7 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RX//GPIO_FUN_UART1_RX//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio7 function
|
||||
#define CONFIG_GPIO7_FUNC GPIO_FUN_USB
|
||||
|
||||
// <q> GPIO8 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio8 function
|
||||
#define CONFIG_GPIO8_FUNC GPIO_FUN_USB
|
||||
|
||||
// <q> GPIO9 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio9 function
|
||||
#define CONFIG_GPIO9_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO10 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio10 function
|
||||
#define CONFIG_GPIO10_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO11 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio11 function
|
||||
#define CONFIG_GPIO11_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO12 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio12 function
|
||||
#define CONFIG_GPIO12_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO13 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio13 function
|
||||
#define CONFIG_GPIO13_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO14 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio14 function
|
||||
#define CONFIG_GPIO14_FUNC GPIO_FUN_UART0_TX
|
||||
|
||||
// <q> GPIO15 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio15 function
|
||||
#define CONFIG_GPIO15_FUNC GPIO_FUN_UART0_RX
|
||||
|
||||
// <q> GPIO16 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio16 function
|
||||
#define CONFIG_GPIO16_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO17 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio17 function
|
||||
#define CONFIG_GPIO17_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO18 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio18 function
|
||||
#define CONFIG_GPIO18_FUNC GPIO_FUN_UART1_TX
|
||||
|
||||
// <q> GPIO19 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio19 function
|
||||
#define CONFIG_GPIO19_FUNC GPIO_FUN_UART1_RX
|
||||
|
||||
// <q> GPIO20 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio20 function
|
||||
#define CONFIG_GPIO20_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO21 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio21 function
|
||||
#define CONFIG_GPIO21_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO22 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio22 function
|
||||
#define CONFIG_GPIO22_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO23 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio23 function
|
||||
#define CONFIG_GPIO23_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO24 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio24 function
|
||||
#define CONFIG_GPIO24_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO25 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio25 function
|
||||
#define CONFIG_GPIO25_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO26 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio26 function
|
||||
#define CONFIG_GPIO26_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO27 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio27 function
|
||||
#define CONFIG_GPIO27_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO28 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio28 function
|
||||
#define CONFIG_GPIO28_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO29 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio29 function
|
||||
#define CONFIG_GPIO29_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO30 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio30 function
|
||||
#define CONFIG_GPIO30_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO31 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio31 function
|
||||
#define CONFIG_GPIO31_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO32 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio32 function
|
||||
#define CONFIG_GPIO32_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO33 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio33 function
|
||||
#define CONFIG_GPIO33_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO34 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio34 function
|
||||
#define CONFIG_GPIO34_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO35 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio35 function
|
||||
#define CONFIG_GPIO35_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO36 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio36 function
|
||||
#define CONFIG_GPIO36_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO37 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio37 function
|
||||
#define CONFIG_GPIO37_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
#endif
|
30
bsp/board/bl706_iot/bl702_config.h
Normal file
30
bsp/board/bl706_iot/bl702_config.h
Normal file
@ -0,0 +1,30 @@
|
||||
/**
|
||||
* @file bl702_config.h
|
||||
* @brief
|
||||
*
|
||||
* Copyright (c) 2021 Bouffalolab team
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __BL702_CONFIG_H__
|
||||
#define __BL702_CONFIG_H__
|
||||
|
||||
#include "peripheral_config.h"
|
||||
#include "clock_config.h"
|
||||
|
||||
#endif
|
258
bsp/board/bl706_iot/board.c
Normal file
258
bsp/board/bl706_iot/board.c
Normal file
@ -0,0 +1,258 @@
|
||||
/**
|
||||
* @file board.c
|
||||
* @brief
|
||||
*
|
||||
* Copyright (c) 2021 Bouffalolab team
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "hal_gpio.h"
|
||||
#include "hal_clock.h"
|
||||
#include "bl702_glb.h"
|
||||
#include "pinmux_config.h"
|
||||
|
||||
struct pin_mux_cfg
|
||||
{
|
||||
uint8_t pin;
|
||||
uint16_t func;
|
||||
};
|
||||
|
||||
static const struct pin_mux_cfg af_pin_table[] =
|
||||
{
|
||||
{
|
||||
.pin = GPIO_PIN_0,
|
||||
.func = CONFIG_GPIO0_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_1,
|
||||
.func = CONFIG_GPIO1_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_2,
|
||||
.func = CONFIG_GPIO2_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_3,
|
||||
.func = CONFIG_GPIO3_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_4,
|
||||
.func = CONFIG_GPIO4_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_5,
|
||||
.func = CONFIG_GPIO5_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_6,
|
||||
.func = CONFIG_GPIO6_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_7,
|
||||
.func = CONFIG_GPIO7_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_8,
|
||||
.func = CONFIG_GPIO8_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_9,
|
||||
.func = CONFIG_GPIO9_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_10,
|
||||
.func = CONFIG_GPIO10_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_11,
|
||||
.func = CONFIG_GPIO11_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_12,
|
||||
.func = CONFIG_GPIO12_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_13,
|
||||
.func = CONFIG_GPIO13_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_14,
|
||||
.func = CONFIG_GPIO14_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_15,
|
||||
.func = CONFIG_GPIO15_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_16,
|
||||
.func = CONFIG_GPIO16_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_17,
|
||||
.func = CONFIG_GPIO17_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_18,
|
||||
.func = CONFIG_GPIO18_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_19,
|
||||
.func = CONFIG_GPIO19_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_20,
|
||||
.func = CONFIG_GPIO20_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_21,
|
||||
.func = CONFIG_GPIO21_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_22,
|
||||
.func = CONFIG_GPIO22_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_23,
|
||||
.func = CONFIG_GPIO23_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_24,
|
||||
.func = CONFIG_GPIO24_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_25,
|
||||
.func = CONFIG_GPIO25_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_26,
|
||||
.func = CONFIG_GPIO26_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_27,
|
||||
.func = CONFIG_GPIO27_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_28,
|
||||
.func = CONFIG_GPIO28_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_29,
|
||||
.func = CONFIG_GPIO29_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_30,
|
||||
.func = CONFIG_GPIO30_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_31,
|
||||
.func = CONFIG_GPIO31_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_32,
|
||||
.func = CONFIG_GPIO32_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_33,
|
||||
.func = CONFIG_GPIO33_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_34,
|
||||
.func = CONFIG_GPIO34_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_35,
|
||||
.func = CONFIG_GPIO35_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_36,
|
||||
.func = CONFIG_GPIO36_FUNC
|
||||
},
|
||||
{
|
||||
.pin = GPIO_PIN_37,
|
||||
.func = CONFIG_GPIO37_FUNC
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
static void board_pin_mux_init(void)
|
||||
{
|
||||
GLB_GPIO_Cfg_Type gpio_cfg;
|
||||
|
||||
gpio_cfg.drive = 0;
|
||||
gpio_cfg.smtCtrl = 1;
|
||||
gpio_cfg.gpioMode = GPIO_MODE_AF;
|
||||
gpio_cfg.pullType = GPIO_PULL_UP;
|
||||
|
||||
for (int i = 0; i < sizeof(af_pin_table)/sizeof(af_pin_table[0]); i++)
|
||||
{
|
||||
gpio_cfg.gpioPin = af_pin_table[i].pin;
|
||||
gpio_cfg.gpioFun = af_pin_table[i].func;
|
||||
|
||||
if(af_pin_table[i].func == GPIO_FUN_UNUSED)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if(af_pin_table[i].func == GPIO_FUN_PWM)
|
||||
{
|
||||
gpio_cfg.pullType = GPIO_PULL_DOWN;
|
||||
}
|
||||
else if((af_pin_table[i].func & 0x70) == 0x70)
|
||||
{
|
||||
gpio_cfg.gpioFun = GPIO_FUN_UART;
|
||||
uint8_t sig = af_pin_table[i].func & 0x07;
|
||||
GLB_UART_Fun_Sel((gpio_cfg.gpioPin % 8), sig);
|
||||
}
|
||||
GLB_GPIO_Init(&gpio_cfg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void board_clock_init(void)
|
||||
{
|
||||
system_clock_init();
|
||||
peripheral_clock_init();
|
||||
}
|
||||
|
||||
void bl_show_info(void)
|
||||
{
|
||||
MSG(" ____ __ __ _ _ _ \r\n");
|
||||
MSG(" | _ \\ / _|/ _| | | | | | | \r\n");
|
||||
MSG(" | |_) | ___ _ _| |_| |_ __ _| | ___ | | __ _| |__ \r\n");
|
||||
MSG(" | _ < / _ \\| | | | _| _/ _` | |/ _ \\| |/ _` | '_ \\ \r\n");
|
||||
MSG(" | |_) | (_) | |_| | | | || (_| | | (_) | | (_| | |_) |\r\n");
|
||||
MSG(" |____/ \\___/ \\__,_|_| |_| \\__,_|_|\\___/|_|\\__,_|_.__/ \r\n");
|
||||
MSG("\r\n");
|
||||
MSG("Build:%s,%s\r\n",__TIME__,__DATE__);
|
||||
MSG("2016 - 2030 Copyright by bouffalolab team\r\n");
|
||||
|
||||
#if 0
|
||||
MSG("root clock:%dM\r\n",system_clock_get(SYSTEM_CLOCK_ROOT_CLOCK)/1000000);
|
||||
MSG("fclk clock:%dM\r\n",system_clock_get(SYSTEM_CLOCK_FCLK)/1000000);
|
||||
MSG("bclk clock:%dM\r\n",system_clock_get(SYSTEM_CLOCK_BCLK)/1000000);
|
||||
|
||||
MSG("uart clock:%dM\r\n",peripheral_clock_get(PERIPHERAL_CLOCK_UART)/1000000);
|
||||
MSG("spi clock:%dM\r\n",peripheral_clock_get(PERIPHERAL_CLOCK_SPI)/1000000);
|
||||
MSG("i2c clock:%dM\r\n",peripheral_clock_get(PERIPHERAL_CLOCK_I2C)/1000000);
|
||||
#endif
|
||||
}
|
||||
|
||||
void board_init(void)
|
||||
{
|
||||
board_clock_init();
|
||||
board_pin_mux_init();
|
||||
}
|
67
bsp/board/bl706_iot/clock_config.h
Normal file
67
bsp/board/bl706_iot/clock_config.h
Normal file
@ -0,0 +1,67 @@
|
||||
/**
|
||||
* @file clock_config.h
|
||||
* @brief
|
||||
*
|
||||
* Copyright (c) 2021 Bouffalolab team
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _CLOCK_CONFIG_H
|
||||
#define _CLOCK_CONFIG_H
|
||||
|
||||
#define BSP_ROOT_CLOCK_SOURCE ROOT_CLOCK_SOURCE_DLL_144M
|
||||
|
||||
#if defined(BSP_ROOT_CLOCK_SOURCE)
|
||||
#define BSP_HCLK_DIV 0
|
||||
#define BSP_BCLK_DIV 1
|
||||
#endif
|
||||
|
||||
#if defined(BSP_USING_UART0)||defined(BSP_USING_UART1)
|
||||
#define BSP_UART_CLOCK_SOURCE ROOT_CLOCK_SOURCE_DLL_96M
|
||||
#define BSP_UART_CLOCK_DIV 0
|
||||
#endif
|
||||
#if defined(BSP_USING_I2C0)
|
||||
#define BSP_I2C_CLOCK_SOURCE ROOT_CLOCK_SOURCE_DLL_BCLK
|
||||
#define BSP_I2C_CLOCK_DIV 0
|
||||
#endif
|
||||
#if defined(BSP_USING_SPI0)
|
||||
#define BSP_SPI_CLOCK_SOURCE ROOT_CLOCK_SOURCE_DLL_BCLK
|
||||
#define BSP_SPI_CLOCK_DIV 0
|
||||
#endif
|
||||
#if defined(BSP_USING_PWM)
|
||||
#define BSP_PWM_CLOCK_SOURCE ROOT_CLOCK_SOURCE_DLL_XCLK
|
||||
#define BSP_PWM_CLOCK_DIV 0
|
||||
#endif
|
||||
#if defined(BSP_USING_IR)
|
||||
#define BSP_IR_CLOCK_SOURCE ROOT_CLOCK_SOURCE_DLL_XCLK
|
||||
#define BSP_IR_CLOCK_DIV 0
|
||||
#endif
|
||||
#if defined(BSP_USING_I2S0)
|
||||
#define BSP_I2S_CLOCK_SOURCE ROOT_CLOCK_SOURCE_DLL_XCLK
|
||||
#define BSP_I2S_CLOCK_DIV 0
|
||||
#endif
|
||||
#if defined(BSP_USING_ADC0)
|
||||
#define BSP_ADC_CLOCK_SOURCE ROOT_CLOCK_SOURCE_DLL_XCLK
|
||||
#define BSP_ADC_CLOCK_DIV 0
|
||||
#endif
|
||||
#if defined(BSP_USING_DAC0)
|
||||
#define BSP_DAC_CLOCK_SOURCE ROOT_CLOCK_SOURCE_DLL_XCLK
|
||||
#define BSP_DAC_CLOCK_DIV 0
|
||||
#endif
|
||||
|
||||
#endif
|
301
bsp/board/bl706_iot/peripheral_config.h
Normal file
301
bsp/board/bl706_iot/peripheral_config.h
Normal file
@ -0,0 +1,301 @@
|
||||
/**
|
||||
* @file peripheral_config.h
|
||||
* @brief
|
||||
*
|
||||
* Copyright (c) 2021 Bouffalolab team
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _PERIPHERAL_CONFIG_H_
|
||||
#define _PERIPHERAL_CONFIG_H_
|
||||
|
||||
/* PERIPHERAL USING LIST */
|
||||
#define BSP_USING_ADC0
|
||||
#define BSP_USING_DAC0
|
||||
#define BSP_USING_UART0
|
||||
#define BSP_USING_UART1
|
||||
#define BSP_USING_SPI0
|
||||
#define BSP_USING_I2C0
|
||||
#define BSP_USING_I2S0
|
||||
#define BSP_USING_USB
|
||||
#define BSP_USING_PWM0
|
||||
/* ----------------------*/
|
||||
|
||||
|
||||
/* PERIPHERAL With DMA LIST */
|
||||
|
||||
#define BSP_USING_DMA0_CH0
|
||||
#define BSP_USING_DMA0_CH1
|
||||
|
||||
#ifdef BSP_USING_UART1
|
||||
#define BSP_USING_DMA0_CH2
|
||||
#endif
|
||||
|
||||
#ifdef BSP_USING_SPI0
|
||||
#define BSP_USING_DMA0_CH3
|
||||
#define BSP_USING_DMA0_CH4
|
||||
#endif
|
||||
|
||||
#ifdef BSP_USING_I2S0
|
||||
#define BSP_USING_DMA0_CH2
|
||||
#endif
|
||||
|
||||
#ifdef BSP_USING_DAC0
|
||||
#define BSP_USING_DMA0_CH6
|
||||
#endif
|
||||
|
||||
|
||||
/* PERIPHERAL CONFIG */
|
||||
#if defined(BSP_USING_ADC0)
|
||||
#ifndef ADC_CONFIG
|
||||
#define ADC_CONFIG \
|
||||
{ \
|
||||
.clk = ADC_CLK_500KHZ,\
|
||||
.vref = ADC_VREF_3P2V,\
|
||||
.resWidth = ADC_DATA_WIDTH_16_WITH_256_AVERAGE,\
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(BSP_USING_DAC0)
|
||||
#ifndef DAC_CONFIG
|
||||
#define DAC_CONFIG \
|
||||
{ \
|
||||
.clk = DAC_CLK_500KHZ,\
|
||||
.pin.dac0 = GLB_GPIO_PIN_11,\
|
||||
.pin.pin_num = 1,\
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(BSP_USING_UART0)
|
||||
#ifndef UART0_CONFIG
|
||||
#define UART0_CONFIG \
|
||||
{ \
|
||||
.id = 0, \
|
||||
.baudrate = 2000000,\
|
||||
.databits = UART_DATA_LEN_8, \
|
||||
.stopbits = UART_STOP_ONE, \
|
||||
.parity = UART_PAR_NONE, \
|
||||
.fifo_threshold = 1, \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(BSP_USING_UART1)
|
||||
#ifndef UART1_CONFIG
|
||||
#define UART1_CONFIG \
|
||||
{ \
|
||||
.id = 1, \
|
||||
.baudrate = 2000000,\
|
||||
.databits = UART_DATA_LEN_8, \
|
||||
.stopbits = UART_STOP_ONE, \
|
||||
.parity = UART_PAR_NONE, \
|
||||
.fifo_threshold = 64, \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(BSP_USING_SPI0)
|
||||
#ifndef SPI0_CONFIG
|
||||
#define SPI0_CONFIG \
|
||||
{ \
|
||||
.id = 0, \
|
||||
.clk = 18000000,\
|
||||
.mode = SPI_MASTER_MODE, \
|
||||
.direction = SPI_MSB_BYTE0_DIRECTION_FIRST, \
|
||||
.clk_polaraity = SPI_POLARITY_LOW, \
|
||||
.clk_phase = SPI_PHASE_1EDGE, \
|
||||
.datasize = SPI_DATASIZE_8BIT, \
|
||||
.fifo_threshold = 1, \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(BSP_USING_PWM0)
|
||||
#ifndef PWM_CONFIG_0
|
||||
#define PWM_CONFIG_0 \
|
||||
{ \
|
||||
.ch = 2, \
|
||||
.frequency = 1000000, \
|
||||
.dutyCycle = 0, \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(BSP_USING_I2S0)
|
||||
#ifndef I2S0_CONFIG
|
||||
#define I2S0_CONFIG \
|
||||
{ \
|
||||
.id = 0, \
|
||||
.iis_mode = I2S_MODE_MASTER,\
|
||||
.interface_mode = I2S_MODE_LEFT, \
|
||||
.sampl_freq_hz = 16*1000, \
|
||||
.channel_num = I2S_FS_CHANNELS_NUM_MONO, \
|
||||
.frame_size = I2S_FRAME_LEN_16, \
|
||||
.data_size = I2S_DATA_LEN_16, \
|
||||
.fifo_threshold = 8, \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(BSP_USING_DMA0_CH0)
|
||||
#ifndef DMA0_CH0_CONFIG
|
||||
#define DMA0_CH0_CONFIG \
|
||||
{ \
|
||||
.id = 0, \
|
||||
.ch = 0,\
|
||||
.direction = DMA_MEMORY_TO_MEMORY,\
|
||||
.transfer_mode = DMA_LLI_ONCE_MODE, \
|
||||
.src_req = DMA_REQUEST_NONE, \
|
||||
.dst_req = DMA_REQUEST_NONE, \
|
||||
.src_width = DMA_TRANSFER_WIDTH_32BIT , \
|
||||
.dst_width = DMA_TRANSFER_WIDTH_32BIT , \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(BSP_USING_DMA0_CH1)
|
||||
#ifndef DMA0_CH1_CONFIG
|
||||
#define DMA0_CH1_CONFIG \
|
||||
{ \
|
||||
.id = 0, \
|
||||
.ch = 1,\
|
||||
.direction = DMA_MEMORY_TO_MEMORY, \
|
||||
.transfer_mode = DMA_LLI_ONCE_MODE, \
|
||||
.src_req = DMA_REQUEST_NONE, \
|
||||
.dst_req = DMA_REQUEST_NONE, \
|
||||
.src_width = DMA_TRANSFER_WIDTH_16BIT , \
|
||||
.dst_width = DMA_TRANSFER_WIDTH_16BIT , \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(BSP_USING_DMA0_CH2)
|
||||
#ifndef DMA0_CH2_CONFIG
|
||||
#define DMA0_CH2_CONFIG \
|
||||
{ \
|
||||
.id = 0, \
|
||||
.ch = 2,\
|
||||
.direction = DMA_MEMORY_TO_PERIPH, \
|
||||
.transfer_mode = DMA_LLI_ONCE_MODE, \
|
||||
.src_req = DMA_REQUEST_NONE, \
|
||||
.dst_req = DMA_REQUEST_UART1_TX, \
|
||||
.src_width = DMA_TRANSFER_WIDTH_8BIT , \
|
||||
.dst_width = DMA_TRANSFER_WIDTH_8BIT , \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(BSP_USING_DMA0_CH3)
|
||||
#ifndef DMA0_CH3_CONFIG
|
||||
#define DMA0_CH3_CONFIG \
|
||||
{ \
|
||||
.id = 0, \
|
||||
.ch = 3,\
|
||||
.direction = DMA_MEMORY_TO_PERIPH, \
|
||||
.transfer_mode = DMA_LLI_ONCE_MODE, \
|
||||
.src_req = DMA_REQUEST_NONE, \
|
||||
.dst_req = DMA_REQUEST_SPI0_TX, \
|
||||
.src_width = DMA_TRANSFER_WIDTH_8BIT , \
|
||||
.dst_width = DMA_TRANSFER_WIDTH_8BIT , \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(BSP_USING_DMA0_CH4)
|
||||
#ifndef DMA0_CH4_CONFIG
|
||||
#define DMA0_CH4_CONFIG \
|
||||
{ \
|
||||
.id = 0, \
|
||||
.ch = 4,\
|
||||
.direction = DMA_PERIPH_TO_MEMORY, \
|
||||
.transfer_mode = DMA_LLI_ONCE_MODE, \
|
||||
.src_req = DMA_REQUEST_SPI0_RX, \
|
||||
.dst_req = DMA_REQUEST_NONE, \
|
||||
.src_width = DMA_TRANSFER_WIDTH_8BIT , \
|
||||
.dst_width = DMA_TRANSFER_WIDTH_8BIT , \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(BSP_USING_DMA0_CH5)
|
||||
#ifndef DMA0_CH5_CONFIG
|
||||
#define DMA0_CH5_CONFIG \
|
||||
{ \
|
||||
.id = 0, \
|
||||
.ch = 5,\
|
||||
.direction = DMA_MEMORY_TO_PERIPH, \
|
||||
.transfer_mode = DMA_LLI_CYCLE_MODE, \
|
||||
.src_req = DMA_REQUEST_NONE, \
|
||||
.dst_req = DMA_REQUEST_I2S_TX, \
|
||||
.src_width = DMA_TRANSFER_WIDTH_16BIT , \
|
||||
.dst_width = DMA_TRANSFER_WIDTH_16BIT , \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(BSP_USING_DMA0_CH6)
|
||||
#ifndef DMA0_CH6_CONFIG
|
||||
#define DMA0_CH6_CONFIG \
|
||||
{ \
|
||||
.id = 0, \
|
||||
.ch = 6,\
|
||||
.direction = DMA_MEMORY_TO_PERIPH, \
|
||||
.transfer_mode = DMA_LLI_CYCLE_MODE, \
|
||||
.src_req = DMA_REQUEST_NONE, \
|
||||
.dst_req = DMA_REQUEST_I2S_TX, \
|
||||
.src_width = DMA_TRANSFER_WIDTH_16BIT , \
|
||||
.dst_width = DMA_TRANSFER_WIDTH_16BIT , \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(BSP_USING_DMA0_CH7)
|
||||
#ifndef DMA0_CH7_CONFIG
|
||||
#define DMA0_CH7_CONFIG \
|
||||
{ \
|
||||
.id = 0, \
|
||||
.ch = 0,\
|
||||
.direction = DMA_MEMORY_TO_MEMORY,\
|
||||
.transfer_mode = DMA_LLI_ONCE_MODE, \
|
||||
.src_req = DMA_REQUEST_NONE, \
|
||||
.dst_req = DMA_REQUEST_NONE, \
|
||||
.src_width = DMA_TRANSFER_WIDTH_32BIT , \
|
||||
.dst_width = DMA_TRANSFER_WIDTH_32BIT , \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if defined(BSP_USING_I2C0)
|
||||
#ifndef I2C0_CONFIG
|
||||
#define I2C0_CONFIG \
|
||||
{ \
|
||||
.id = 0, \
|
||||
.mode = I2C_HW_MODE,\
|
||||
.phase = 15, \
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
180
bsp/board/bl706_iot/pinmux_config.h
Normal file
180
bsp/board/bl706_iot/pinmux_config.h
Normal file
@ -0,0 +1,180 @@
|
||||
/**
|
||||
* @file pinmux_config.h
|
||||
* @brief
|
||||
*
|
||||
* Copyright (c) 2021 Bouffalolab team
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
#ifndef _PINMUX_CONFIG_H
|
||||
#define _PINMUX_CONFIG_H
|
||||
|
||||
// <<< Use Configuration Wizard in Context Menu >>>
|
||||
|
||||
// <q> GPIO0 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio0 function
|
||||
#define CONFIG_GPIO0_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO1 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_CTS//GPIO_FUN_UART1_CTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio1 function
|
||||
#define CONFIG_GPIO1_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO2 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_TX//GPIO_FUN_UART1_TX//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio2 function
|
||||
#define CONFIG_GPIO2_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO3 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RX//GPIO_FUN_UART1_RX//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio3 function
|
||||
#define CONFIG_GPIO3_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO4 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio4 function
|
||||
#define CONFIG_GPIO4_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO5 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_CTS//GPIO_FUN_UART1_CTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio5 function
|
||||
#define CONFIG_GPIO5_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO6 <2> [GPIO_FUN_UNUSED//GPIO_FUN_CLK_OUT//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_UART0_TX//GPIO_FUN_UART1_TX//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio6 function
|
||||
#define CONFIG_GPIO6_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO7 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RX//GPIO_FUN_UART1_RX//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio7 function
|
||||
#define CONFIG_GPIO7_FUNC GPIO_FUN_USB
|
||||
|
||||
// <q> GPIO8 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio8 function
|
||||
#define CONFIG_GPIO8_FUNC GPIO_FUN_USB
|
||||
|
||||
// <q> GPIO9 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio9 function
|
||||
#define CONFIG_GPIO9_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO10 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio10 function
|
||||
#define CONFIG_GPIO10_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO11 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio11 function
|
||||
#define CONFIG_GPIO11_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO12 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio12 function
|
||||
#define CONFIG_GPIO12_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO13 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio13 function
|
||||
#define CONFIG_GPIO13_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO14 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio14 function
|
||||
#define CONFIG_GPIO14_FUNC GPIO_FUN_UART0_TX
|
||||
|
||||
// <q> GPIO15 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio15 function
|
||||
#define CONFIG_GPIO15_FUNC GPIO_FUN_UART0_RX
|
||||
|
||||
// <q> GPIO16 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio16 function
|
||||
#define CONFIG_GPIO16_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO17 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio17 function
|
||||
#define CONFIG_GPIO17_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO18 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio18 function
|
||||
#define CONFIG_GPIO18_FUNC GPIO_FUN_UART1_TX
|
||||
|
||||
// <q> GPIO19 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio19 function
|
||||
#define CONFIG_GPIO19_FUNC GPIO_FUN_UART1_RX
|
||||
|
||||
// <q> GPIO20 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio20 function
|
||||
#define CONFIG_GPIO20_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO21 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio21 function
|
||||
#define CONFIG_GPIO21_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO22 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio22 function
|
||||
#define CONFIG_GPIO22_FUNC GPIO_FUN_PWM
|
||||
|
||||
// <q> GPIO23 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio23 function
|
||||
#define CONFIG_GPIO23_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO24 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio24 function
|
||||
#define CONFIG_GPIO24_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO25 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio25 function
|
||||
#define CONFIG_GPIO25_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO26 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio26 function
|
||||
#define CONFIG_GPIO26_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO27 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio27 function
|
||||
#define CONFIG_GPIO27_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO28 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio28 function
|
||||
#define CONFIG_GPIO28_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO29 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio29 function
|
||||
#define CONFIG_GPIO29_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO30 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio30 function
|
||||
#define CONFIG_GPIO30_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO31 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio31 function
|
||||
#define CONFIG_GPIO31_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO32 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio32 function
|
||||
#define CONFIG_GPIO32_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO33 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio33 function
|
||||
#define CONFIG_GPIO33_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO34 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio34 function
|
||||
#define CONFIG_GPIO34_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO35 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio35 function
|
||||
#define CONFIG_GPIO35_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO36 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio36 function
|
||||
#define CONFIG_GPIO36_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
// <q> GPIO37 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio37 function
|
||||
#define CONFIG_GPIO37_FUNC GPIO_FUN_UNUSED
|
||||
|
||||
#endif
|
78
bsp/bsp_common/audio/audio_core.c
Normal file
78
bsp/bsp_common/audio/audio_core.c
Normal file
@ -0,0 +1,78 @@
|
||||
/**
|
||||
* @file audio_proto.c
|
||||
*
|
||||
* Copyright (c) 2021 Bouffalolab team
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
#include "drv_device.h"
|
||||
#include "audio_core.h"
|
||||
#include "hal_dma.h"
|
||||
|
||||
volatile int (*buffer_ready_callback_func)(char bufIndex);
|
||||
volatile audio_core_t * audio_core_cfg_store;
|
||||
volatile int bufferIndex = 0;
|
||||
|
||||
void audio_core_transfer_done(struct device *dev, void *args, uint32_t size, uint32_t state){
|
||||
|
||||
if(!state){
|
||||
if(buffer_ready_callback_func){
|
||||
buffer_ready_callback_func(bufferIndex);
|
||||
}
|
||||
|
||||
if(bufferIndex){
|
||||
bufferIndex = 0;
|
||||
device_write(audio_core_cfg_store->audio_device,0,audio_core_cfg_store->buff1,audio_core_cfg->buff_size);
|
||||
}else{
|
||||
bufferIndex = 1;
|
||||
device_write(audio_core_cfg_store->audio_device,0,audio_core_cfg_store->buff2,audio_core_cfg->buff_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int audio_core_init(audio_core_t * audio_core_cfg){
|
||||
|
||||
if(audio_core_cfg->audio_dma == NULL ||
|
||||
audio_core_cfg->buff_size == NULL||
|
||||
audio_core_cfg->buff1 == NULL ||
|
||||
audio_core_cfg->buff2 == NULL){
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
memset(audio_core_cfg->buff1,0,audio_core_cfg->buff_size);
|
||||
memset(audio_core_cfg->buff2,0,audio_core_cfg->buff_size);
|
||||
|
||||
device_control(audio_core_cfg->audio_device,DEVICE_CTRL_ATTACH_TX_DMA,(void*)audio_core_cfg->audio_dma);
|
||||
|
||||
device_set_callback(audio_core_cfg->audio_dma, audio_core_transfer_done);
|
||||
|
||||
buffer_ready_callback_func = audio_core_cfg->buffer_ready_callback;
|
||||
audio_core_cfg_store = audio_core_cfg;
|
||||
|
||||
device_control(audio_core_cfg->audio_dma, DEVICE_CTRL_SET_INT, NULL);
|
||||
|
||||
}
|
||||
|
||||
int audio_core_start(void){
|
||||
device_write(audio_core_cfg_store->audio_device,0,audio_core_cfg_store->buff1,audio_core_cfg_store->buff_size);
|
||||
}
|
||||
|
||||
int audio_core_stop(void){
|
||||
dma_channel_stop(audio_core_cfg_store->audio_dma);
|
||||
}
|
||||
|
45
bsp/bsp_common/audio/audio_core.h
Normal file
45
bsp/bsp_common/audio/audio_core.h
Normal file
@ -0,0 +1,45 @@
|
||||
/**
|
||||
* @file audio_core.h
|
||||
* @brief
|
||||
*
|
||||
* Copyright (c) 2021 Bouffalolab team
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __AUDIO_PROTO__
|
||||
#define __AUDIO_PROTO__
|
||||
|
||||
#include "misc.h"
|
||||
|
||||
typedef struct{
|
||||
|
||||
uint8_t *buff1;
|
||||
uint8_t *buff2;
|
||||
uint32_t buff_size;
|
||||
|
||||
struct device * audio_dma;
|
||||
struct device * audio_device;
|
||||
|
||||
int (*buffer_ready_callback)(char bufIndex);
|
||||
|
||||
}audio_core_t;
|
||||
|
||||
int audio_core_init(audio_core_t * audio_core_cfg);
|
||||
int audio_core_start(void);
|
||||
int audio_core_stop(void);
|
||||
#endif
|
42
bsp/bsp_common/audio/bl_audio_structure.md
Normal file
42
bsp/bsp_common/audio/bl_audio_structure.md
Normal file
@ -0,0 +1,42 @@
|
||||
# bl音频协议框架
|
||||
|
||||
## 核心音频播放组件
|
||||
|
||||
如下图所示
|
||||
|
||||
[![c1Q8qe.jpg](https://z3.ax1x.com/2021/04/06/c1Q8qe.jpg)](https://imgtu.com/i/c1Q8qe)
|
||||
|
||||
|
||||
整体框架分为两个部分,一个部分是由核心组件提供的双缓存结构,另一个部分是用户的实际使用代码。
|
||||
|
||||
**核心组件需要两个构件**
|
||||
|
||||
1 双缓存,用户需要在自己的应用中开辟两块长度相同的内存块,将其指针传入核心组件。
|
||||
|
||||
2 dma组件,用户需要将配置好了的 dma device 指针传入核心组件,此dma的作用是将设备的数据通过P->M写回Buffer 或者 将数据通过M->P写入Device。搬运的request需要在device的配置参数中给定。
|
||||
|
||||
|
||||
|
||||
**核心组件后的运行逻辑**
|
||||
|
||||
当用户打开音频构架的核心组件代码后
|
||||
组件会首先初始化Buffer1和Buffer2的内容,初始化为0,并且立即打开DMA搬运。
|
||||
当DMA搬运结束,会触发Buffer_Ready中断回调。
|
||||
|
||||
在录音的应用下
|
||||
|
||||
打开核心组件后,DMA会根据Device的DMA Request,把录音数据搬运到Buffer1和Buffer2,用户需要做的是在Buffer_Ready中断回调发生后,将对应Buffer取出来,保存、或者通过下文提到的协议发送。
|
||||
|
||||
在播放音频的应用下
|
||||
|
||||
打开核心组件后,DMA会立即播放Buffer1和Buffer2的数据,但是因为最开始的时候已经初始化Buffer数据为0,所以不会有任何声音播放。用户需要在Buffer_Ready中断回调发生后,以合适的方式,将需要播放的PCM音频数据更新到Buffer中(此过程必须在下一个Buffer消耗完成之前,否则会产生问题),如果在buffer2的数据消耗结束之前还没能完成buffer1的数据更新,那么需要考虑如何加快数据更新速度,或者增加Buffer的size以提供更多操作时间。
|
||||
|
||||
|
||||
## 2 通讯协议约定
|
||||
|
||||
当用户代码部分需要与外界进行通讯时,需要统一规范一个交互的协议,这样不同的音频应用可以兼容相同的audio_cube。
|
||||
|
||||
1 传输音频文件流(目前仅支持wav格式播放)
|
||||
2 每次传输的字节数,使用规范的约定字节数
|
||||
3 是否支持校验
|
||||
4 播放/暂停 停止 音量调整的固定协议
|
76
bsp/bsp_common/audio/wav_info_parser.c
Normal file
76
bsp/bsp_common/audio/wav_info_parser.c
Normal file
@ -0,0 +1,76 @@
|
||||
/**
|
||||
* @file wav_info_parser.c
|
||||
* @brief
|
||||
*
|
||||
* Copyright (c) 2021 Bouffalolab team
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "wav_info_parser.h"
|
||||
|
||||
/* get File pointer from top of file*/
|
||||
int wav_data_parser(uint8_t buff[1024], wav_information_t *wav_information)
|
||||
{
|
||||
uint32_t offset=0;
|
||||
uint32_t chunk_id;
|
||||
|
||||
/* RIFF WAVE Chunk */
|
||||
chunk_id = ((chunk_riff_t *)&buff[offset])->chunk_id;
|
||||
if(chunk_id == 0x46464952)
|
||||
{
|
||||
wav_information->chunk_riff_offset = offset;
|
||||
wav_information->chunk_riff = *((chunk_riff_t *)&buff[offset]);
|
||||
offset += sizeof(chunk_riff_t);
|
||||
}else{
|
||||
wav_information->chunk_riff_offset = -1;
|
||||
return 1;
|
||||
}
|
||||
/* Format Chunk */
|
||||
chunk_id = ((chunk_format_t *)&buff[offset])->chunk_id;
|
||||
if(chunk_id == 0x20746D66 && offset<1000) /* fmt */
|
||||
{
|
||||
wav_information->chunk_format_offset = offset;
|
||||
wav_information->chunk_format = *((chunk_format_t *)&buff[offset]);
|
||||
offset += ((chunk_format_t*)&buff[offset])->chunk_size + 8;
|
||||
}else
|
||||
{
|
||||
wav_information->chunk_format_offset = -1;
|
||||
return 1;
|
||||
}
|
||||
/* Fact/list Chunk */
|
||||
chunk_id = ((chunk_fact_t *)&buff[offset])->chunk_id;
|
||||
if((chunk_id == 0X74636166 || chunk_id == 0X5453494C) && offset<1000) /*fact or list*/
|
||||
{
|
||||
wav_information->chunk_fact_offset = offset;
|
||||
wav_information->chunk_fact = *((chunk_fact_t *)&buff[offset]);
|
||||
offset += ((chunk_fact_t*)&buff[offset])->chunk_size + 8;
|
||||
}else{
|
||||
wav_information->chunk_fact_offset = -1;
|
||||
}
|
||||
/* Data Chunk */
|
||||
chunk_id = ((chunk_data_t *)&buff[offset])->chunk_id;
|
||||
if(chunk_id == 0X61746164 && offset<1000 )
|
||||
{
|
||||
wav_information->chunk_data_offset = offset;
|
||||
wav_information->chunk_data = *((chunk_data_t *)&buff[offset]);
|
||||
}else{
|
||||
wav_information->chunk_data_offset = -1;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
89
bsp/bsp_common/audio/wav_info_parser.h
Normal file
89
bsp/bsp_common/audio/wav_info_parser.h
Normal file
@ -0,0 +1,89 @@
|
||||
/**
|
||||
* @file wav_info_parser.h
|
||||
* @brief
|
||||
*
|
||||
* Copyright (c) 2021 Bouffalolab team
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __WAV_INFO_PARSER__
|
||||
#define __WAV_INFO_PARSER__
|
||||
|
||||
#include "bl_common.h"
|
||||
|
||||
/* RIFF (RIFF WAVE Chunk) */
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
uint32_t chunk_id;
|
||||
uint32_t chunk_size;
|
||||
uint32_t format;
|
||||
}chunk_riff_t ;
|
||||
|
||||
/* fmt (Format Chunk)*/
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
uint32_t chunk_id;
|
||||
uint32_t chunk_size ;
|
||||
uint16_t audio_format;
|
||||
uint16_t num_of_channels;
|
||||
uint32_t sample_rate;
|
||||
uint32_t byte_rate;
|
||||
uint16_t block_align;
|
||||
uint16_t bits_per_sample;
|
||||
}chunk_format_t;
|
||||
|
||||
//fact (Fact Chunk)
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
uint32_t chunk_id;
|
||||
uint32_t chunk_size ;
|
||||
uint32_t data_fact_size;
|
||||
}chunk_fact_t;
|
||||
|
||||
//data (Data Chunk)
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
uint32_t chunk_id;
|
||||
uint32_t chunk_size ;
|
||||
}chunk_data_t;
|
||||
|
||||
//
|
||||
typedef enum
|
||||
{
|
||||
CHUNK_RIFF,
|
||||
CHUNK_FORMAT,
|
||||
CHUNK_FACT,
|
||||
CHUNK_DATA,
|
||||
}mav_chunk_t;
|
||||
|
||||
//.wav information
|
||||
typedef struct
|
||||
{
|
||||
int chunk_riff_offset;
|
||||
chunk_riff_t chunk_riff;
|
||||
int chunk_format_offset;
|
||||
chunk_format_t chunk_format;
|
||||
int chunk_fact_offset;
|
||||
chunk_fact_t chunk_fact;
|
||||
int chunk_data_offset;
|
||||
chunk_data_t chunk_data;
|
||||
}wav_information_t;
|
||||
|
||||
int wav_data_parser(uint8_t buff[1024], wav_information_t *wav_information);
|
||||
|
||||
#endif
|
482
bsp/bsp_common/es8388/bsp_es8388.c
Normal file
482
bsp/bsp_common/es8388/bsp_es8388.c
Normal file
@ -0,0 +1,482 @@
|
||||
/**
|
||||
* @file bsp_es8388.c
|
||||
* @brief
|
||||
*
|
||||
* Copyright (c) 2021 Bouffalolab team
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bflb_platform.h"
|
||||
#include "hal_i2c.h"
|
||||
#include "bsp_es8388.h"
|
||||
|
||||
/** @addtogroup BL702_STD_PERIPH_DRIVER
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup ES8388
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup ES8388_Private_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define ES8388_I2C_SLAVE_ADDR 0x10
|
||||
|
||||
/*@} end of group ES8388_Private_Macros */
|
||||
|
||||
/** @defgroup ES8388_Private_Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group ES8388_Private_Types */
|
||||
|
||||
/** @defgroup ES8388_Private_Variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group ES8388_Private_Variables */
|
||||
|
||||
/** @defgroup ES8388_Global_Variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group ES8388_Global_Variables */
|
||||
|
||||
/** @defgroup ES8388_Private_Fun_Declaration
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group ES8388_Private_Fun_Declaration */
|
||||
|
||||
/** @defgroup ES8388_Private_Functions_User_Define
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group ES8388_Private_Functions_User_Define */
|
||||
|
||||
/** @defgroup ES8388_Private_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
struct device *es8388_i2c = NULL;
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief ES8388 write register
|
||||
*
|
||||
* @param addr: Register address
|
||||
* @param data: data
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
BL_Err_Type ES8388_Write_Reg(uint8_t addr, uint8_t data)
|
||||
{
|
||||
i2c_msg_t msg1;
|
||||
|
||||
msg1.slaveaddr = ES8388_I2C_SLAVE_ADDR,
|
||||
msg1.len = 1,
|
||||
msg1.buf = &data;
|
||||
msg1.flags = SUB_ADDR_1BYTE | I2C_WR;
|
||||
msg1.subaddr = addr;
|
||||
bflb_platform_delay_ms(10);
|
||||
return i2c_transfer(es8388_i2c, &msg1, 1);
|
||||
|
||||
}
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief ES8388_Read_Reg
|
||||
*
|
||||
* @param addr: Register address
|
||||
* @param rdata: data
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
BL_Err_Type ES8388_Read_Reg(uint8_t addr, uint8_t* rdata)
|
||||
{
|
||||
i2c_msg_t msg1;
|
||||
msg1.len = 1,
|
||||
msg1.buf = rdata;
|
||||
msg1.subaddr = addr;
|
||||
msg1.slaveaddr = ES8388_I2C_SLAVE_ADDR,
|
||||
msg1.flags = SUB_ADDR_1BYTE | I2C_RD;
|
||||
return i2c_transfer(es8388_i2c, &msg1, 1);
|
||||
|
||||
}
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief ES8388 codec mode
|
||||
*
|
||||
* @param cfg: None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
void ES8388_Codec_Mode(ES8388_Cfg_Type * cfg){
|
||||
uint8_t tempVal = 0;
|
||||
|
||||
ES8388_Write_Reg(0x01,0x58);//power down whole chip analog
|
||||
ES8388_Write_Reg(0x01,0x50);//power up whole chip analog
|
||||
|
||||
ES8388_Write_Reg(0x02,0xf3);//power down ADC/DAC and reset ADC/DAC state machine
|
||||
ES8388_Write_Reg(0x02,0xf0);//power on ADC/DAC
|
||||
|
||||
ES8388_Write_Reg(0x2B,0x80);//set internal ADC and DAC use sanme LRCK clock
|
||||
|
||||
ES8388_Write_Reg(0x00,0x36);//ADC clock is same as DAC . DACMCLK is the chip master clock source
|
||||
|
||||
if(cfg->role == ES8388_MASTER){
|
||||
ES8388_Write_Reg(0x08,0x80);
|
||||
}else{
|
||||
ES8388_Write_Reg(0x08,0x00);
|
||||
}
|
||||
|
||||
ES8388_Write_Reg(0x04,0x00);//power up dac
|
||||
|
||||
ES8388_Write_Reg(0x05,0x00);//stop lowpower mode
|
||||
ES8388_Write_Reg(0x06,0xc3);//stop lowpower mode
|
||||
|
||||
if(cfg->mic_input_mode == ES8388_SINGLE_ENDED_MIC){
|
||||
/*
|
||||
* default set LINPUT1 and RINPUT1 as single ended mic input
|
||||
* if user want to use LINPUT2 and RINPUT2 as input
|
||||
* please set 0x0a register as 0x50
|
||||
*/
|
||||
ES8388_Write_Reg(0x0A,0x00);//select lin1 and rin1 as micphone input
|
||||
}else{
|
||||
/*
|
||||
* defualt select LIN1 and RIN1 as Mic diff input
|
||||
* if user want to use LIN2 and RIN2 as input
|
||||
* please set 0x0b register as 0x82
|
||||
*/
|
||||
ES8388_Write_Reg(0x0A,0xf0);//set micphone input as difference mode
|
||||
ES8388_Write_Reg(0x0B,0x02);//set LIN1 and RIN1 as micphone different input
|
||||
}
|
||||
|
||||
tempVal = cfg->data_width;
|
||||
tempVal <<= 2;
|
||||
tempVal |= cfg->i2s_frame;
|
||||
|
||||
ES8388_Write_Reg(0x0C,tempVal); //ADC I2S Format sel as i2s_frame , data len as data_width
|
||||
|
||||
tempVal = cfg->data_width;
|
||||
tempVal <<= 2;
|
||||
tempVal |= cfg->i2s_frame;
|
||||
tempVal <<= 1;
|
||||
|
||||
ES8388_Write_Reg(0x17,tempVal); //DAC I2S Format sel as i2s_frame , data len as data_width
|
||||
|
||||
/* when work in master mode , BCLK is devided form MCLK
|
||||
* default divider is 256 , see datasheet reigster 13
|
||||
*/
|
||||
if(cfg->role == ES8388_MASTER){
|
||||
ES8388_Write_Reg(0x0d,0x02);//ADCLRCK = MCLK/256
|
||||
ES8388_Write_Reg(0x18,0x02);//DACLRCK = MCLK/256
|
||||
}
|
||||
|
||||
/*set ADC/DAC default volume as 0 db */
|
||||
ES8388_Write_Reg(0x10,0x00);//LADC volume as 0db
|
||||
ES8388_Write_Reg(0x11,0x00);//RADC volume as 0db
|
||||
ES8388_Write_Reg(0x1A,0x00);//LDAC volume as 0db
|
||||
ES8388_Write_Reg(0x1B,0x00);//RDAC volume as 0db
|
||||
|
||||
tempVal = cfg->mic_pga;
|
||||
tempVal <<=4 ;
|
||||
tempVal |= cfg->mic_pga;
|
||||
|
||||
ES8388_Write_Reg(0x09,tempVal);//set ADC PGA as mic pga
|
||||
|
||||
/*ADC ALC default Setting */
|
||||
ES8388_Write_Reg(0x12,0xE2);
|
||||
ES8388_Write_Reg(0x13,0xC0);
|
||||
ES8388_Write_Reg(0x14,0x12);
|
||||
ES8388_Write_Reg(0x15,0x06);
|
||||
ES8388_Write_Reg(0x16,0xC3);
|
||||
|
||||
/*Mixer setting for LDAC to LOUT and RDAC TO ROUT
|
||||
* default close mixer
|
||||
*/
|
||||
ES8388_Write_Reg(0x27,0xB8);
|
||||
ES8388_Write_Reg(0x2A,0xB8);
|
||||
|
||||
ES8388_Write_Reg(0x02,0x00);//startup FSM and DLL
|
||||
bflb_platform_delay_ms(500);
|
||||
|
||||
/* set LOUT1 ROUT1 LOUT2 ROUT2 volume */
|
||||
ES8388_Write_Reg(0x2e,0x1E);
|
||||
ES8388_Write_Reg(0x2f,0x1E);
|
||||
ES8388_Write_Reg(0x30,0x1E);
|
||||
ES8388_Write_Reg(0x31,0x1E);
|
||||
|
||||
//ES8388_Write_Reg(0x04,0x3C);//enable LOUT & ROUT
|
||||
ES8388_Write_Reg(0x04,0x24);
|
||||
ES8388_Write_Reg(0x26,0x01);
|
||||
ES8388_Write_Reg(0x03,0x09);//power up ADC Enable LIN &RIN.
|
||||
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief ES8388 recording mode
|
||||
*
|
||||
* @param cfg: None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
void ES8388_Recording_Mode(ES8388_Cfg_Type * cfg){
|
||||
uint8_t tempVal = 0;
|
||||
MSG("RECORDING\r\n");
|
||||
ES8388_Write_Reg(0x01,0x58);//power down whole chip analog
|
||||
ES8388_Write_Reg(0x01,0x50);//power up whole chip analog
|
||||
|
||||
ES8388_Write_Reg(0x02,0xf3);//power down ADC/DAC and reset ADC/DAC state machine
|
||||
ES8388_Write_Reg(0x02,0xf0);//power on ADC/DAC
|
||||
ES8388_Write_Reg(0x2B,0x80);//set internal ADC and DAC use the same LRCK clock
|
||||
ES8388_Write_Reg(0x00,0x16);//ADC clock is same as DAC. use ADC MCLK as internal MCLK
|
||||
|
||||
if(cfg->role == ES8388_MASTER){
|
||||
ES8388_Write_Reg(0x08,0x80);
|
||||
}else{
|
||||
ES8388_Write_Reg(0x08,0x00);
|
||||
}
|
||||
|
||||
ES8388_Write_Reg(0x04,0xc0);
|
||||
ES8388_Write_Reg(0x05,0x00);
|
||||
ES8388_Write_Reg(0x06,0xc3);
|
||||
|
||||
if(cfg->mic_input_mode == ES8388_SINGLE_ENDED_MIC){
|
||||
/*
|
||||
* default set LINPUT1 and RINPUT1 as single ended mic input
|
||||
* if user want to use LINPUT2 and RINPUT2 as input
|
||||
* please set 0x0a register as 0x50
|
||||
*/
|
||||
//ES8388_Write_Reg(0x0A,0x00);//select lin1 and rin1 as micphone input
|
||||
ES8388_Write_Reg(0x0A,0xf8);
|
||||
ES8388_Write_Reg(0x0B,0x88); //analog mono mix to left ADC
|
||||
//ES8388_Write_Reg(0x0B,0x90); //analog mono mix to right ADC
|
||||
}else{
|
||||
/*
|
||||
* defualt select LIN1 and RIN1 as Mic diff input
|
||||
* if user want to use LIN2 and RIN2 as input
|
||||
* please set 0x0b register as 0x82
|
||||
*/
|
||||
//ES8388_Write_Reg(0x0A,0xf0);//set micphone input as difference mode
|
||||
//ES8388_Write_Reg(0x0B,0x02);//set LIN1 and RIN1 as micphone different input
|
||||
ES8388_Write_Reg(0x0A,0xf8); // Fixed stereo problems
|
||||
ES8388_Write_Reg(0x0B,0x82); // stereo
|
||||
}
|
||||
|
||||
tempVal = cfg->data_width;
|
||||
tempVal <<= 2;
|
||||
tempVal |= cfg->i2s_frame;
|
||||
|
||||
ES8388_Write_Reg(0x0C,tempVal); //ADC I2S Format sel as i2s_frame , data len as data_width
|
||||
|
||||
ES8388_Write_Reg(0x0d,0x02);//ADC LRCK = MCLK/256
|
||||
|
||||
ES8388_Write_Reg(0x10,0x00);//ADC VOLUME = 0 DB
|
||||
ES8388_Write_Reg(0x11,0x00);//set ADC VOLUME as 0 DB
|
||||
|
||||
tempVal = cfg->mic_pga;
|
||||
tempVal <<= 4;
|
||||
tempVal |= cfg->mic_pga;
|
||||
|
||||
ES8388_Write_Reg(0x09,tempVal);//MIC PGA SEL
|
||||
|
||||
ES8388_Write_Reg(0x12,0xe2);//MIC ALC SETTING
|
||||
|
||||
ES8388_Write_Reg(0x13,0xc0);
|
||||
ES8388_Write_Reg(0x14,0x12);
|
||||
ES8388_Write_Reg(0x15,0x06);
|
||||
ES8388_Write_Reg(0x16,0xc3);
|
||||
|
||||
ES8388_Write_Reg(0x02,0x55); //startup FSM and DLL
|
||||
ES8388_Write_Reg(0x03,0x09); //power up adc , enable LIN and RIN
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief ES8388 Playback mode
|
||||
*
|
||||
* @param cfg: None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
void ES8388_Playback_Mode(ES8388_Cfg_Type * cfg){
|
||||
uint8_t tempVal = 0;
|
||||
|
||||
ES8388_Write_Reg(0x00,0x80); //Reset control port register to default
|
||||
ES8388_Write_Reg(0x00,0x06); //Close reset
|
||||
bflb_platform_delay_ms(10);
|
||||
ES8388_Write_Reg(0x02,0xF3); //Stop STM, DLL and digital block
|
||||
|
||||
if(cfg->role == ES8388_MASTER){
|
||||
ES8388_Write_Reg(0x08,0x80);
|
||||
}else{
|
||||
ES8388_Write_Reg(0x08,0x00);
|
||||
}
|
||||
|
||||
ES8388_Write_Reg(0x2B,0x80); //Set ADC and DAC have the same LRCK
|
||||
ES8388_Write_Reg(0x00,0x05); //Start up reference
|
||||
ES8388_Write_Reg(0x01,0x40); //Start up reference
|
||||
bflb_platform_delay_ms(30);
|
||||
ES8388_Write_Reg(0x03,0x00); //Power on ADC and LIN/RIN input
|
||||
ES8388_Write_Reg(0x04,0x3F); //Power on DAC and LOUT/ROUT input
|
||||
|
||||
|
||||
/* Set ADC */
|
||||
ES8388_Write_Reg(0x09,0x77); //MicBoost PGA = +21dB
|
||||
ES8388_Write_Reg(0x0A,0xF0); //Differential input
|
||||
ES8388_Write_Reg(0x0B,0x02); //Select LIN1 and RIN1 as differential input pairs
|
||||
|
||||
tempVal = cfg->data_width;
|
||||
tempVal <<= 2;
|
||||
tempVal |= cfg->i2s_frame;
|
||||
|
||||
ES8388_Write_Reg(0x0C,tempVal); //ADC I2S Format sel as i2s_frame , data len as data_width
|
||||
|
||||
ES8388_Write_Reg(0x0D,0x04); //MCLK / LRCK = 512
|
||||
ES8388_Write_Reg(0x10,0x00); //LADC volume = 0dB
|
||||
ES8388_Write_Reg(0x11,0x00); //RADC volume = 0dB
|
||||
ES8388_Write_Reg(0x12,0xE2); //ALC enable, PGA Max.Gain = 23.5dB, Min.Gain = 0dB
|
||||
ES8388_Write_Reg(0x13,0xC0); //ALC target = -4.5dB, ALC hold time = 0 ms
|
||||
ES8388_Write_Reg(0x14,0x12); //Decay time = 820us, attack time = 416us
|
||||
ES8388_Write_Reg(0x15,0x06); //ALC mode
|
||||
ES8388_Write_Reg(0x16,0xC3); //Nose gate =-40.5dB, NGG = 0x01(mute ADC)
|
||||
|
||||
tempVal = cfg->data_width;
|
||||
tempVal <<= 2;
|
||||
tempVal |= cfg->i2s_frame;
|
||||
tempVal <<= 1;
|
||||
|
||||
ES8388_Write_Reg(0x18,0x04); //MCLK / LRCK = 512
|
||||
ES8388_Write_Reg(0x1A,0x00); //LDAC volume = 0dB
|
||||
ES8388_Write_Reg(0x1B,0x00); //RDAC volume = 0dB
|
||||
ES8388_Write_Reg(0x26,0x00); //Setup mixer
|
||||
ES8388_Write_Reg(0x27,0xB8); //Setup mixer
|
||||
ES8388_Write_Reg(0x28,0x38); //Setup mixer
|
||||
ES8388_Write_Reg(0x29,0x38); //Setup mixer
|
||||
ES8388_Write_Reg(0x2A,0xB8); //Setup mixer
|
||||
ES8388_Write_Reg(0x2E,0x1E); //Set Lout/Rout volume:0dB
|
||||
ES8388_Write_Reg(0x2F,0x1E); //Set Lout/Rout volume:0dB
|
||||
ES8388_Write_Reg(0x30,0x1E); //Set Lout/Rout volume:0dB
|
||||
ES8388_Write_Reg(0x31,0x1E); //Set Lout/Rout volume:0dB
|
||||
ES8388_Write_Reg(0x02,0x00); //Power up DEM and STM
|
||||
|
||||
}
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief ES8388_I2C_Init
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
int ES8388_Set_Voice_Volume(int volume)
|
||||
{
|
||||
int res;
|
||||
if (volume < 0)
|
||||
volume = 0;
|
||||
else if (volume > 100)
|
||||
volume = 100;
|
||||
volume /= 3;
|
||||
res = ES8388_Write_Reg(0x2e, volume);
|
||||
res |= ES8388_Write_Reg(0x2f, volume);
|
||||
res |= ES8388_Write_Reg(0x30, volume);
|
||||
res |= ES8388_Write_Reg(0x31, volume);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief ES8388_I2C_Init
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
void ES8388_I2C_Init(void)
|
||||
{
|
||||
i2c_register(I2C0_INDEX, "i2c", DEVICE_OFLAG_RDWR);
|
||||
es8388_i2c = device_find("i2c");
|
||||
if(es8388_i2c){
|
||||
device_open(es8388_i2c, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief ES8388_Reg_Dump
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
BL_Err_Type ES8388_Reg_Dump(void)
|
||||
{
|
||||
int i;
|
||||
uint8_t tmp;
|
||||
|
||||
for (i = 0; i < 0X3F; i++) {
|
||||
if(ES8388_Read_Reg(i,&tmp) != SUCCESS)
|
||||
bflb_platform_printf("iic read err\r\n");
|
||||
bflb_platform_printf("Reg[%02x]=%02x \n", i,tmp);
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*@} end of group ES8388_Private_Functions */
|
||||
|
||||
/** @defgroup ES8388_Public_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief ES8388 Init function
|
||||
*
|
||||
* @param cfg: None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
void ES8388_Init(ES8388_Cfg_Type * cfg){
|
||||
|
||||
ES8388_I2C_Init();
|
||||
|
||||
switch(cfg -> work_mode){
|
||||
case ES8388_CODEC_MDOE: ES8388_Codec_Mode(cfg);break;
|
||||
case ES8388_RECORDING_MODE:ES8388_Recording_Mode(cfg);break;
|
||||
case ES8388_PLAY_BACK_MODE:ES8388_Playback_Mode(cfg);break;
|
||||
default:break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*@} end of group ES8388_Public_Functions */
|
||||
|
||||
/*@} end of group ES8388 */
|
||||
|
||||
/*@} end of group BL702_STD_PERIPH_DRIVER */
|
192
bsp/bsp_common/es8388/bsp_es8388.h
Normal file
192
bsp/bsp_common/es8388/bsp_es8388.h
Normal file
@ -0,0 +1,192 @@
|
||||
/**
|
||||
* @file bsp_es8388.h
|
||||
* @brief
|
||||
*
|
||||
* Copyright (c) 2021 Bouffalolab team
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __ES8388_H__
|
||||
#define __ES8388_H__
|
||||
|
||||
#include "bflb_platform.h"
|
||||
|
||||
/** @addtogroup BL702_STD_PERIPH_DRIVER
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup ES8388
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup ES8388_Public_Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief ES8388 Role Matser Or Slave
|
||||
*/
|
||||
typedef enum {
|
||||
ES8388_MASTER, /*!< Master Mode */
|
||||
ES8388_SLAVE, /*!< Slave Mode */
|
||||
}ES8388_Role_Type;
|
||||
|
||||
/**
|
||||
* @brief ES8388 Work Mode
|
||||
*/
|
||||
typedef enum {
|
||||
ES8388_CODEC_MDOE, /*!< ES8388 work at codec mode */
|
||||
ES8388_RECORDING_MODE, /*!< ES8388 work at recording mode */
|
||||
ES8388_PLAY_BACK_MODE, /*!< ES8388 work at paly back mode */
|
||||
ES8388_BY_PASS_MODE, /*!< ES8388 work at by pass mode */
|
||||
}ES8388_Work_Mode;
|
||||
|
||||
/**
|
||||
* @brief ES8388 Microphone input type
|
||||
*/
|
||||
typedef enum {
|
||||
ES8388_SINGLE_ENDED_MIC, /*!< Mic Single Input Mode */
|
||||
ES8388_DIFF_ENDED_MIC, /*!< Mic Different Input Mode */
|
||||
}ES8388_MIC_Input_Type;
|
||||
|
||||
/**
|
||||
* @brief ES8388 Microphone pga sel type
|
||||
*/
|
||||
typedef enum {
|
||||
ES8388_MIC_PGA_0DB, /*!< Mic PGA as 0db */
|
||||
ES8388_MIC_PGA_3DB, /*!< Mic PGA as 3db */
|
||||
ES8388_MIC_PGA_6DB, /*!< Mic PGA as 6db */
|
||||
ES8388_MIC_PGA_9DB, /*!< Mic PGA as 9db */
|
||||
ES8388_MIC_PGA_12DB, /*!< Mic PGA as 12db */
|
||||
ES8388_MIC_PGA_15DB, /*!< Mic PGA as 15db */
|
||||
ES8388_MIC_PGA_18DB, /*!< Mic PGA as 18db */
|
||||
ES8388_MIC_PGA_21DB, /*!< Mic PGA as 21db */
|
||||
ES8388_MIC_PGA_24DB, /*!< Mic PGA as 24db */
|
||||
}ES8388_MIC_Input_PGA_Type;
|
||||
|
||||
/**
|
||||
* @brief ES8388 I2S Frame Type
|
||||
*/
|
||||
typedef enum {
|
||||
ES8388_STD_I2S_FRAME, /*!< Standard I2S Frame */
|
||||
ES8388_LEFT_JUSTIFY_FRAME, /*!< Left Justify Frame */
|
||||
ES8388_RIGHT_JUSTIFY_FRAME, /*!< Right Justify Frame */
|
||||
ES8388_DSP_FRAME, /*!< DSP Frame */
|
||||
}ES8388_I2S_Frame_Type;
|
||||
|
||||
/**
|
||||
* @brief ES8388 I2S Data Len Type
|
||||
*/
|
||||
typedef enum {
|
||||
ES8388_DATA_LEN_24, /*!< I2S Auido Data Len 24 */
|
||||
ES8388_DATA_LEN_20, /*!< I2S Auido Data Len 20 */
|
||||
ES8388_DATA_LEN_18, /*!< I2S Auido Data Len 18 */
|
||||
ES8388_DATA_LEN_16, /*!< I2S Auido Data Len 16 */
|
||||
ES8388_DATA_LEN_32, /*!< I2S Auido Data Len 32 */
|
||||
}ES8388_I2S_Data_Width;
|
||||
|
||||
/**
|
||||
* @brief ES8388_Cfg_Type
|
||||
*/
|
||||
typedef struct {
|
||||
ES8388_Work_Mode work_mode; /*!< ES8388 work mode */
|
||||
ES8388_Role_Type role; /*!< ES8388 role */
|
||||
ES8388_MIC_Input_Type mic_input_mode; /*!< ES8388 mic input mode */
|
||||
ES8388_MIC_Input_PGA_Type mic_pga; /*!< ES8388 mic PGA */
|
||||
ES8388_I2S_Frame_Type i2s_frame; /*!< ES8388 I2S frame */
|
||||
ES8388_I2S_Data_Width data_width; /*!< ES8388 I2S dataWitdh */
|
||||
}ES8388_Cfg_Type;
|
||||
|
||||
/*@} end of group ES8388_Public_Types */
|
||||
|
||||
/** @defgroup ES8388_Public_Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup ES8388_ROLE_TYPE
|
||||
* @{
|
||||
*/
|
||||
#define IS_ES8388_ROLE_TYPE(type) (((type) == ES8388_MASTER) || \
|
||||
((type) == ES8388_SLAVE))
|
||||
|
||||
/** @defgroup ES8388_WORK_MODE
|
||||
* @{
|
||||
*/
|
||||
#define IS_ES8388_WORK_MODE(type) (((type) == ES8388_CODEC_MDOE) || \
|
||||
((type) == ES8388_RECORDING_MODE) || \
|
||||
((type) == ES8388_PLAY_BACK_MODE) || \
|
||||
((type) == ES8388_BY_PASS_MODE))
|
||||
|
||||
/** @defgroup ES8388_MIC_INPUT_TYPE
|
||||
* @{
|
||||
*/
|
||||
#define IS_ES8388_MIC_INPUT_TYPE(type) (((type) == ES8388_SINGLE_ENDED_MIC) || \
|
||||
((type) == ES8388_DIFF_ENDED_MIC))
|
||||
|
||||
/** @defgroup ES8388_MIC_INPUT_PGA_TYPE
|
||||
* @{
|
||||
*/
|
||||
#define IS_ES8388_MIC_INPUT_PGA_TYPE(type) (((type) == ES8388_MIC_PGA_0DB) || \
|
||||
((type) == ES8388_MIC_PGA_3DB) || \
|
||||
((type) == ES8388_MIC_PGA_6DB) || \
|
||||
((type) == ES8388_MIC_PGA_9DB) || \
|
||||
((type) == ES8388_MIC_PGA_12DB) || \
|
||||
((type) == ES8388_MIC_PGA_15DB) || \
|
||||
((type) == ES8388_MIC_PGA_18DB) || \
|
||||
((type) == ES8388_MIC_PGA_21DB) || \
|
||||
((type) == ES8388_MIC_PGA_24DB))
|
||||
|
||||
/** @defgroup ES8388_I2S_FRAME_TYPE
|
||||
* @{
|
||||
*/
|
||||
#define IS_ES8388_I2S_FRAME_TYPE(type) (((type) == ES8388_STD_I2S_FRAME) || \
|
||||
((type) == ES8388_LEFT_JUSTIFY_FRAME) || \
|
||||
((type) == ES8388_RIGHT_JUSTIFY_FRAME) || \
|
||||
((type) == ES8388_DSP_FRAME))
|
||||
|
||||
/** @defgroup ES8388_I2S_DATA_WIDTH
|
||||
* @{
|
||||
*/
|
||||
#define IS_ES8388_I2S_DATA_WIDTH(type) (((type) == ES8388_DATA_LEN_24) || \
|
||||
((type) == ES8388_DATA_LEN_20) || \
|
||||
((type) == ES8388_DATA_LEN_18) || \
|
||||
((type) == ES8388_DATA_LEN_16) || \
|
||||
((type) == ES8388_DATA_LEN_32))
|
||||
|
||||
/*@} end of group ES8388_Public_Constants */
|
||||
|
||||
/** @defgroup ES8388_Public_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group ES8388_Public_Macros */
|
||||
|
||||
/** @defgroup ES8388_Public_Functions
|
||||
* @{
|
||||
*/
|
||||
void ES8388_Init(ES8388_Cfg_Type * cfg);
|
||||
BL_Err_Type ES8388_Reg_Dump(void);
|
||||
int ES8388_Set_Voice_Volume(int volume);
|
||||
|
||||
/*@} end of group ES8388_Public_Functions */
|
||||
|
||||
/*@} end of group ES8388 */
|
||||
|
||||
/*@} end of group BL702_STD_PERIPH_DRIVER */
|
||||
|
||||
#endif /* __ES8388_H__ */
|
160
bsp/bsp_common/fatfs/fatfs_sdio_sd.c
Normal file
160
bsp/bsp_common/fatfs/fatfs_sdio_sd.c
Normal file
@ -0,0 +1,160 @@
|
||||
/**
|
||||
* @file fatfs_sdio_sd.c
|
||||
* @brief
|
||||
*
|
||||
* Copyright (c) 2021 Bouffalolab team
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Low level disk I/O module skeleton for FatFs (C)ChaN, 2019 */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* If a working storage control module is available, it should be */
|
||||
/* attached to the FatFs via a glue function rather than modifying it. */
|
||||
/* This is an example of glue functions to attach various exsisting */
|
||||
/* storage control modules to the FatFs module with a defined API. */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
#include "ff.h" /* Obtains integer types */
|
||||
#include "diskio.h" /* Declarations of disk functions */
|
||||
#include "bsp_sdio_sdcard.h"
|
||||
#include "bflb_platform.h"
|
||||
|
||||
static sd_card_t gSDCardInfo;
|
||||
|
||||
int RAM_disk_status()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MMC_disk_status()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int USB_disk_status()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int RAM_disk_initialize()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MMC_disk_initialize()
|
||||
{
|
||||
static uint8_t inited=0;
|
||||
|
||||
if(inited==0){
|
||||
if(SDH_Init(SDH_DATA_BUS_WIDTH_4BITS,&gSDCardInfo)==SD_OK){
|
||||
inited=1;
|
||||
return 0;
|
||||
}else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int USB_disk_initialize()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int RAM_disk_read(BYTE* buff, LBA_t sector, UINT count)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MMC_disk_read(BYTE* buff, LBA_t sector, UINT count)
|
||||
{
|
||||
if(SD_OK==SDH_ReadMultiBlocks(buff,sector,gSDCardInfo.blockSize,count)){
|
||||
return 0;
|
||||
}else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int USB_disk_read(BYTE* buff, LBA_t sector, UINT count)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int RAM_disk_write(const BYTE* buff, LBA_t sector, UINT count)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MMC_disk_write(const BYTE* buff, LBA_t sector, UINT count)
|
||||
{
|
||||
if(SD_OK==SDH_WriteMultiBlocks((uint8_t *)buff,sector,gSDCardInfo.blockSize,count)){
|
||||
return 0;
|
||||
}else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int USB_disk_write(const BYTE* buff, LBA_t sector, UINT count)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int RAM_disk_ioctl(BYTE cmd, void* buff)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MMC_disk_ioctl(BYTE cmd, void* buff)
|
||||
{
|
||||
switch (cmd)
|
||||
{
|
||||
// Get R/W sector size (WORD)
|
||||
case GET_SECTOR_SIZE :
|
||||
*(WORD * )buff = gSDCardInfo.blockSize;
|
||||
break;
|
||||
// Get erase block size in unit of sector (DWORD)
|
||||
case GET_BLOCK_SIZE :
|
||||
*(DWORD * )buff = 1;
|
||||
break;
|
||||
|
||||
case GET_SECTOR_COUNT:
|
||||
*(DWORD * )buff = gSDCardInfo.blockCount;
|
||||
break;
|
||||
case CTRL_SYNC :
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int USB_disk_ioctl(BYTE cmd, void* buff)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
DWORD get_fattime(void) {
|
||||
return ((DWORD)(2015 - 1980) << 25) /* Year 2015 */
|
||||
| ((DWORD)1 << 21) /* Month 1 */
|
||||
| ((DWORD)1 << 16) /* Mday 1 */
|
||||
| ((DWORD)0 << 11) /* Hour 0 */
|
||||
| ((DWORD)0 << 5) /* Min 0 */
|
||||
| ((DWORD)0 >> 1); /* Sec 0 */
|
||||
}
|
||||
|
110
bsp/bsp_common/fatfs/fatfs_spi_sd.c
Normal file
110
bsp/bsp_common/fatfs/fatfs_spi_sd.c
Normal file
@ -0,0 +1,110 @@
|
||||
/**
|
||||
* @file fatfs_spi_sd.c
|
||||
* @brief
|
||||
*
|
||||
* Copyright (c) 2021 Bouffalolab team
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "diskio.h"
|
||||
#include "bsp_spi_sd.h"
|
||||
const char * FR_Table[]=
|
||||
{
|
||||
"FR_OK:成功", /* (0) Succeeded */
|
||||
"FR_DISK_ERR:底层硬件错误", /* (1) A hard error occurred in the low level disk I/O layer */
|
||||
"FR_INT_ERR:断言失败", /* (2) Assertion failed */
|
||||
"FR_NOT_READY:物理驱动没有工作", /* (3) The physical drive cannot work */
|
||||
"FR_NO_FILE:文件不存在", /* (4) Could not find the file */
|
||||
"FR_NO_PATH:路径不存在", /* (5) Could not find the path */
|
||||
"FR_INVALID_NAME:无效文件名", /* (6) The path name format is invalid */
|
||||
"FR_DENIED:由于禁止访问或者目录已满访问被拒绝", /* (7) Access denied due to prohibited access or directory full */
|
||||
"FR_EXIST:文件已经存在", /* (8) Access denied due to prohibited access */
|
||||
"FR_INVALID_OBJECT:文件或者目录对象无效", /* (9) The file/directory object is invalid */
|
||||
"FR_WRITE_PROTECTED:物理驱动被写保护", /* (10) The physical drive is write protected */
|
||||
"FR_INVALID_DRIVE:逻辑驱动号无效", /* (11) The logical drive number is invalid */
|
||||
"FR_NOT_ENABLED:卷中无工作区", /* (12) The volume has no work area */
|
||||
"FR_NO_FILESYSTEM:没有有效的FAT卷", /* (13) There is no valid FAT volume */
|
||||
"FR_MKFS_ABORTED:由于参数错误f_mkfs()被终止", /* (14) The f_mkfs() aborted due to any parameter error */
|
||||
"FR_TIMEOUT:在规定的时间内无法获得访问卷的许可", /* (15) Could not get a grant to access the volume within defined period */
|
||||
"FR_LOCKED:由于文件共享策略操作被拒绝", /* (16) The operation is rejected according to the file sharing policy */
|
||||
"FR_NOT_ENOUGH_CORE:无法分配长文件名工作区", /* (17) LFN working buffer could not be allocated */
|
||||
"FR_TOO_MANY_OPEN_FILES:当前打开的文件数大于_FS_SHARE", /* (18) Number of open files > _FS_SHARE */
|
||||
"FR_INVALID_PARAMETER:参数无效" /* (19) Given parameter is invalid */
|
||||
};
|
||||
|
||||
int sd_disk_status(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int sd_disk_initialize(void)
|
||||
{
|
||||
return SD_Init(&SD_CardInfo);
|
||||
}
|
||||
int sd_disk_read(BYTE *buff, LBA_t sector, UINT count)
|
||||
{
|
||||
return SD_ReadBlock(sector, buff, count);
|
||||
}
|
||||
int sd_disk_write(const BYTE *buff, LBA_t sector, UINT count)
|
||||
{
|
||||
return SD_WriteBlock(sector, (BYTE *)buff, count);
|
||||
}
|
||||
int sd_disk_ioctl(BYTE cmd, void *buff)
|
||||
{
|
||||
int result = 0;
|
||||
switch (cmd)
|
||||
{
|
||||
case CTRL_SYNC:
|
||||
result = RES_OK;
|
||||
break;
|
||||
case GET_SECTOR_SIZE:
|
||||
*(DWORD *)buff = SD_CardInfo.CardBlockSize;
|
||||
result = RES_OK;
|
||||
break;
|
||||
case GET_BLOCK_SIZE:
|
||||
*(WORD *)buff = SD_CardInfo.CardBlockSize;
|
||||
result = RES_OK;
|
||||
break;
|
||||
case GET_SECTOR_COUNT:
|
||||
*(DWORD *)buff = SD_CardInfo.CardCapacity / SD_CardInfo.CardBlockSize;
|
||||
result = RES_OK;
|
||||
break;
|
||||
default:
|
||||
result = RES_PARERR;
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
DSTATUS Translate_Result_Code(int result)
|
||||
{
|
||||
|
||||
// MSG("%s\r\n",FR_Table[result]);
|
||||
return result;
|
||||
}
|
||||
FATFS_DiskioDriverTypeDef pNewDiskioDriver;
|
||||
|
||||
void fatfs_sd_driver_register(void)
|
||||
{
|
||||
pNewDiskioDriver.MMC_disk_status = sd_disk_status;
|
||||
pNewDiskioDriver.MMC_disk_initialize = sd_disk_initialize;
|
||||
pNewDiskioDriver.MMC_disk_write = sd_disk_write;
|
||||
pNewDiskioDriver.MMC_disk_read = sd_disk_read;
|
||||
pNewDiskioDriver.MMC_disk_ioctl = sd_disk_ioctl;
|
||||
pNewDiskioDriver.Translate_Result_Code = Translate_Result_Code;
|
||||
disk_driver_callback_init(&pNewDiskioDriver);
|
||||
}
|
515
bsp/bsp_common/il9431/bsp_il9431.c
Normal file
515
bsp/bsp_common/il9431/bsp_il9431.c
Normal file
@ -0,0 +1,515 @@
|
||||
/**
|
||||
* @file bsp_il9431.c
|
||||
* @brief
|
||||
*
|
||||
* Copyright (c) 2021 Bouffalolab team
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bsp_il9431.h"
|
||||
#include "hal_spi.h"
|
||||
|
||||
/** @addtogroup BL702_Peripheral_Case
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup TFT_LCD
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup TFT_LCD_Private_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group TFT_LCD_Private_Macros */
|
||||
|
||||
/** @defgroup TFT_LCD_Private_Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group TFT_LCD_Private_Types */
|
||||
|
||||
/** @defgroup TFT_LCD_Private_Variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group TFT_LCD_Private_Variables */
|
||||
|
||||
/** @defgroup TFT_LCD_Global_Variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group TFT_LCD_Global_Variables */
|
||||
|
||||
/** @defgroup TFT_LCD_Private_Fun_Declaration
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group TFT_LCD_Private_Fun_Declaration */
|
||||
|
||||
/** @defgroup TFT_LCD_Private_Functions
|
||||
* @{
|
||||
*/
|
||||
struct device* spi_lcd;
|
||||
|
||||
/*@} end of group TFT_LCD_Private_Functions */
|
||||
|
||||
/** @defgroup TFT_LCD_Public_Functions
|
||||
* @{
|
||||
*/
|
||||
void spi_lcd_init(void)
|
||||
{
|
||||
spi_register(SPI0_INDEX,"spi_lcd",DEVICE_OFLAG_RDWR);
|
||||
gpio_set_mode(LCD_CS_PIN,GPIO_OUTPUT_MODE);
|
||||
gpio_set_mode(LCD_DC_PIN,GPIO_OUTPUT_MODE);
|
||||
gpio_write(LCD_CS_PIN,1); //CS1
|
||||
gpio_write(LCD_DC_PIN,1);//DC
|
||||
spi_lcd = device_find("spi_lcd");
|
||||
if(spi_lcd)
|
||||
{
|
||||
device_open(spi_lcd,DEVICE_OFLAG_STREAM_TX|DEVICE_OFLAG_STREAM_RX);
|
||||
|
||||
}
|
||||
}
|
||||
/****************************************************************************//**
|
||||
* @brief LCD write command
|
||||
*
|
||||
* @param command: Command to write
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
void LCD_WR_Cmd(uint8_t command)
|
||||
{
|
||||
CS1_LOW;
|
||||
DC_LOW;
|
||||
spi_transmit(spi_lcd,&command,1,SPI_TRANSFER_TYPE_8BIT);
|
||||
CS1_HIGH;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief LCD write 8-bit data
|
||||
*
|
||||
* @param data: 8-bit data to write
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
void LCD_WR_Byte(uint8_t data)
|
||||
{
|
||||
CS1_LOW;
|
||||
DC_HIGH;
|
||||
spi_transmit(spi_lcd,&data,1,SPI_TRANSFER_TYPE_8BIT);
|
||||
CS1_HIGH;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief LCD write 16-bit data
|
||||
*
|
||||
* @param data: 16-bit data to write
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
void LCD_WR_HalfWord(uint16_t data)
|
||||
{
|
||||
CS1_LOW;
|
||||
DC_HIGH;
|
||||
spi_transmit(spi_lcd,&data,1,SPI_TRANSFER_TYPE_16BIT);
|
||||
CS1_HIGH;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief LCD write 32-bit data
|
||||
*
|
||||
* @param data: 32-bit data to write
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
void LCD_WR_Word(uint32_t data)
|
||||
{
|
||||
CS1_LOW;
|
||||
DC_HIGH;
|
||||
spi_transmit(spi_lcd,&data,1,SPI_TRANSFER_TYPE_32BIT);
|
||||
CS1_HIGH;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief LCD set address
|
||||
*
|
||||
* @param x1: Coordinate x start
|
||||
* @param y1: Coordinate y start
|
||||
* @param x2: Coordinate x end
|
||||
* @param y2: Coordinate y end
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
void LCD_Set_Addr(uint32_t x1,uint32_t y1,uint32_t x2,uint32_t y2)
|
||||
{
|
||||
LCD_WR_Cmd(0x2a);
|
||||
LCD_WR_Word(x2<<24 | (x2<<8&0xff0000) | (x1<<8&0xff00) | (x1>>8&0xff));
|
||||
|
||||
LCD_WR_Cmd(0x2b);
|
||||
LCD_WR_Word(y2<<24 | (y2<<8&0xff0000) | (y1<<8&0xff00) | (y1>>8&0xff));
|
||||
|
||||
LCD_WR_Cmd(0x2C);
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief SPI LCD init
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
void LCD_Init(void)
|
||||
{
|
||||
spi_lcd_init();
|
||||
|
||||
LCD_WR_Cmd(0x11); /* Exit sleep */
|
||||
bflb_platform_delay_ms(60);
|
||||
|
||||
LCD_WR_Cmd(0xcf);
|
||||
LCD_WR_HalfWord(0xd900);
|
||||
LCD_WR_Byte(0X30);
|
||||
|
||||
LCD_WR_Cmd(0xed);
|
||||
LCD_WR_Word(0x81120364);
|
||||
|
||||
LCD_WR_Cmd(0xe8);
|
||||
LCD_WR_HalfWord(0x1085);
|
||||
LCD_WR_Byte(0x78);
|
||||
|
||||
LCD_WR_Cmd(0xcb);
|
||||
LCD_WR_Word(0x34002c39);
|
||||
LCD_WR_Byte(0x02);
|
||||
|
||||
LCD_WR_Cmd(0xf7);
|
||||
LCD_WR_Byte(0x20);
|
||||
|
||||
LCD_WR_Cmd(0xea);
|
||||
LCD_WR_HalfWord(0x0000);
|
||||
|
||||
LCD_WR_Cmd(0xc0); /* Power control */
|
||||
LCD_WR_Byte(0x23); /* VRH[5:0] */
|
||||
LCD_WR_Cmd(0xc1); /* Power control */
|
||||
LCD_WR_Byte(0x12); /* SAP[2:0];BT[3:0] */
|
||||
LCD_WR_Cmd(0xc2);
|
||||
LCD_WR_Byte(0x11);
|
||||
LCD_WR_Cmd(0xC5); /* VCM control */
|
||||
LCD_WR_HalfWord(0x3040);
|
||||
LCD_WR_Cmd(0xc7); /* VCM control2 */
|
||||
LCD_WR_Byte(0xa9);
|
||||
LCD_WR_Cmd(0x3a);
|
||||
LCD_WR_Byte(0x55);
|
||||
LCD_WR_Cmd(0x36); /* Memory Access Control */
|
||||
LCD_WR_Byte(0x08);
|
||||
LCD_WR_Cmd(0xb1); /* Frame Rate Control */
|
||||
LCD_WR_HalfWord(0x1800);
|
||||
LCD_WR_Cmd(0xb6); /* Display Function Control */
|
||||
LCD_WR_HalfWord(0xa20a);
|
||||
LCD_WR_Cmd(0xf2); /* 3Gamma Function Disable */
|
||||
LCD_WR_Byte(0x00);
|
||||
LCD_WR_Cmd(0xf7);
|
||||
LCD_WR_Byte(0x20);
|
||||
LCD_WR_Cmd(0x26); /* Gamma curve selected */
|
||||
LCD_WR_Byte(0x01);
|
||||
LCD_WR_Cmd(0xe0); /* Set Gamma */
|
||||
LCD_WR_Word(0x0b23241f);
|
||||
LCD_WR_Word(0xd850080f);
|
||||
LCD_WR_Word(0x000a083b);
|
||||
LCD_WR_HalfWord(0x0000);
|
||||
LCD_WR_Byte(0x00);
|
||||
LCD_WR_Cmd(0Xe1); /* Set Gamma */
|
||||
LCD_WR_Word(0x041c1b00);
|
||||
LCD_WR_Word(0x272f0710);
|
||||
LCD_WR_Word(0x0f150744);
|
||||
LCD_WR_HalfWord(0x3f3f);
|
||||
LCD_WR_Byte(0x1f);
|
||||
LCD_WR_Cmd(0x29); /* Display on */
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief LCD clear display
|
||||
*
|
||||
* @param color: Color to fill
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
void LCD_Clear(uint16_t color)
|
||||
{
|
||||
uint16_t i,j;
|
||||
LCD_Set_Addr(0,0,LCD_W-1,LCD_H-1);
|
||||
for(i=0;i<LCD_W;i++){
|
||||
for (j=0;j<LCD_H;j++){
|
||||
LCD_WR_HalfWord(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief LCD draw a point
|
||||
*
|
||||
* @param x: Coordinate x
|
||||
* @param y: Coordinate y
|
||||
* @param color: Color of the point
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
void LCD_DrawPoint(uint16_t x,uint16_t y,uint16_t color)
|
||||
{
|
||||
LCD_Set_Addr(x,y,x,y);
|
||||
LCD_WR_HalfWord(color);
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief LCD draw line
|
||||
*
|
||||
* @param x1: Coordinate x start
|
||||
* @param y1: Coordinate y start
|
||||
* @param x2: Coordinate x end
|
||||
* @param y2: Coordinate y end
|
||||
* @param color: Color of the line
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
void LCD_DrawLine(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2,uint16_t color)
|
||||
{
|
||||
int xVariation,yVariation,temp;
|
||||
int absX,absY,i;
|
||||
xVariation = x2-x1;
|
||||
yVariation = y2-y1;
|
||||
absX = ABS32(xVariation);
|
||||
absY = ABS32(yVariation);
|
||||
|
||||
if(absX > absY){
|
||||
for(i=0;i<absX+1;i++){
|
||||
temp = yVariation*100/absX*i/100;
|
||||
if(xVariation>0){
|
||||
LCD_DrawPoint(x1+i,y1+temp,color);
|
||||
}else{
|
||||
LCD_DrawPoint(x1-i,y1+temp,color);
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
for(i=0;i<absY+1;i++){
|
||||
temp = xVariation*100/absY*i/100;
|
||||
if(yVariation>0){
|
||||
LCD_DrawPoint(x1+temp,y1+i,color);
|
||||
}else{
|
||||
LCD_DrawPoint(x1+temp,y1-i,color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief LCD draw rectangle
|
||||
*
|
||||
* @param x1: Coordinate x start
|
||||
* @param y1: Coordinate y start
|
||||
* @param x2: Coordinate x end
|
||||
* @param y2: Coordinate y end
|
||||
* @param color: Color of the rectangle
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
void LCD_DrawRectangle(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2,uint16_t color)
|
||||
{
|
||||
LCD_DrawLine(x1,y1,x2,y1,color);
|
||||
LCD_DrawLine(x2,y1,x2,y2,color);
|
||||
LCD_DrawLine(x2,y2,x1,y2,color);
|
||||
LCD_DrawLine(x1,y2,x1,y1,color);
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief LCD draw circle
|
||||
*
|
||||
* @param x: Center coordinate x
|
||||
* @param y: Center coordinate y
|
||||
* @param r: Radius
|
||||
* @param color: Color of the circle
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
void LCD_DrawCircle(uint16_t x,uint16_t y,uint16_t r,uint16_t color)
|
||||
{
|
||||
int a = 0,b;
|
||||
int di;
|
||||
b = r;
|
||||
di = 3-(r<<1);
|
||||
while(a <= b)
|
||||
{
|
||||
LCD_DrawPoint(x-b,y-a,color);
|
||||
LCD_DrawPoint(x+b,y-a,color);
|
||||
LCD_DrawPoint(x-a,y+b,color);
|
||||
LCD_DrawPoint(x-b,y-a,color);
|
||||
LCD_DrawPoint(x-a,y-b,color);
|
||||
LCD_DrawPoint(x+b,y+a,color);
|
||||
LCD_DrawPoint(x+a,y-b,color);
|
||||
LCD_DrawPoint(x+a,y+b,color);
|
||||
LCD_DrawPoint(x-b,y+a,color);
|
||||
a++;
|
||||
if(di<0){
|
||||
di += 4*a+6;
|
||||
}else{
|
||||
di += 10+4*(a-b);
|
||||
b--;
|
||||
}
|
||||
LCD_DrawPoint(x+a,y+b,color);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief LCD fill the area with color
|
||||
*
|
||||
* @param x1: Coordinate x start
|
||||
* @param y1: Coordinate y start
|
||||
* @param x2: Coordinate x end
|
||||
* @param y2: Coordinate y end
|
||||
* @param color: Color to fill
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
void LCD_DrawArea(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2,uint16_t color)
|
||||
{
|
||||
uint16_t i,j;
|
||||
LCD_Set_Addr(x1,y1,x2,y2);
|
||||
for(i=y1;i<=y2;i++)
|
||||
{
|
||||
for(j=x1;j<=x2;j++)LCD_WR_HalfWord(color);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief LCD draw picture
|
||||
*
|
||||
* @param x1: Coordinate x start
|
||||
* @param y1: Coordinate y start
|
||||
* @param x2: Coordinate x end
|
||||
* @param y2: Coordinate y end
|
||||
* @param picture: Color array of the picture
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
void LCD_DrawPicture(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2,uint16_t* picture)
|
||||
{
|
||||
uint32_t i;
|
||||
LCD_Set_Addr(x1,y1,x2,y2);
|
||||
for(i=0;i<ABS16((x2-x1+1)*(y2-y1+1));i++)
|
||||
{
|
||||
LCD_WR_HalfWord(picture[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief LCD use uart to receive picture data and send to display
|
||||
*
|
||||
* @param x1: Coordinate x start
|
||||
* @param y1: Coordinate y start
|
||||
* @param x2: Coordinate x end
|
||||
* @param y2: Coordinate y end
|
||||
* @param uartId: Color array of the picture
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
// void LCD_UartDrawPicture(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2,UART_ID_Type uartId)
|
||||
// {
|
||||
// uint32_t rxLen = 0,i;
|
||||
// uint32_t recvCnt = 0;
|
||||
// uint8_t uartRxBuf[UART_RX_FIFO_SIZE] = {0};
|
||||
// LCD_Set_Addr(x1,y1,x2,y2);
|
||||
|
||||
// UART_Enable(uartId,UART_RX);
|
||||
|
||||
// while(rxLen < 2*(x2-x1+1)*(y2-y1+1)){
|
||||
// while((recvCnt=UART_GetRxFifoCount(uartId)) == 0){}
|
||||
// rxLen += UART_ReceiveData(uartId,uartRxBuf,recvCnt);
|
||||
// for(i=0;i<recvCnt;i++){
|
||||
// LCD_WR_Byte(uartRxBuf[i]);
|
||||
// }
|
||||
// }
|
||||
|
||||
// UART_Disable(uartId,UART_RX);
|
||||
// }
|
||||
|
||||
|
||||
/****************************************************************************//**
|
||||
* @brief LCD draw a 32*32 chinese character in lattice mode
|
||||
*
|
||||
* @param x: Coordinate x
|
||||
* @param y: Coordinate y
|
||||
* @param character: Array of the character
|
||||
* @param bColor: Color of the background
|
||||
* @param cColor: Color of the character
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
void LCD_DrawChinese(uint16_t x,uint16_t y,uint8_t* character,uint16_t bColor,uint16_t cColor)
|
||||
{
|
||||
uint8_t i,j;
|
||||
LCD_Set_Addr(x,y,x+31,y+31);
|
||||
for(j=0;j<128;j++)
|
||||
{
|
||||
for(i=0;i<8;i++)
|
||||
{
|
||||
if((*character&(1<<i)) != 0)
|
||||
{
|
||||
LCD_WR_HalfWord(cColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
LCD_WR_HalfWord(bColor);
|
||||
}
|
||||
}
|
||||
character++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*@} end of group TFT_LCD_Public_Functions */
|
||||
|
||||
/*@} end of group TFT_LCD */
|
||||
|
||||
/*@} end of group BL702_Peripheral_Case */
|
96
bsp/bsp_common/il9431/bsp_il9431.h
Normal file
96
bsp/bsp_common/il9431/bsp_il9431.h
Normal file
@ -0,0 +1,96 @@
|
||||
/**
|
||||
* @file bsp_il9431.h
|
||||
* @brief
|
||||
*
|
||||
* Copyright (c) 2021 Bouffalolab team
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
#ifndef __TFT_LCD_H__
|
||||
#define __TFT_LCD_H__
|
||||
|
||||
#include "hal_gpio.h"
|
||||
/** @addtogroup BL702_Peripheral_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup TFT_LCD
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup TFT_LCD_Public_Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group TFT_LCD_Public_Types */
|
||||
|
||||
/** @defgroup TFT_LCD_Public_Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*@} end of group TFT_LCD_Public_Constants */
|
||||
|
||||
/** @defgroup TFT_LCD_Public_Macros
|
||||
* @{
|
||||
*/
|
||||
#define LCD_CS_PIN GPIO_PIN_10
|
||||
#define LCD_DC_PIN GPIO_PIN_22
|
||||
|
||||
#define CS1_HIGH gpio_write(LCD_CS_PIN,1)
|
||||
#define CS1_LOW gpio_write(LCD_CS_PIN,0)
|
||||
#define DC_HIGH gpio_write(LCD_DC_PIN,1)
|
||||
#define DC_LOW gpio_write(LCD_DC_PIN,0)
|
||||
#define LCD_W 240 /* LCD width */
|
||||
#define LCD_H 320 /* LCD height */
|
||||
/* Turn 24-bit RGB color to 16-bit */
|
||||
#define RGB(r,g,b) (((r>>3)<<3|(g>>5)|(g>>2)<<13|(b>>3)<<8)&0xffff)
|
||||
/* Calculate 32-bit or 16-bit absolute value */
|
||||
#define ABS32(value) ((value^(value>>31))-(value>>31))
|
||||
#define ABS16(value) ((value^(value>>15))-(value>>15))
|
||||
|
||||
/*@} end of group TFT_LCD_Public_Macros */
|
||||
|
||||
/** @defgroup TFT_LCD_Public_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Tft_lcd Functions
|
||||
*/
|
||||
void LCD_WR_Cmd(uint8_t command);
|
||||
void LCD_WR_Byte(uint8_t data);
|
||||
void LCD_WR_HalfWord(uint16_t data);
|
||||
void LCD_WR_Word(uint32_t data);
|
||||
void LCD_Set_Addr(uint32_t x1,uint32_t y1,uint32_t x2,uint32_t y2);
|
||||
void LCD_Init(void);
|
||||
void LCD_Clear(uint16_t color);
|
||||
void LCD_DrawPoint(uint16_t x,uint16_t y,uint16_t color);
|
||||
void LCD_DrawLine(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2,uint16_t color);
|
||||
void LCD_DrawRectangle(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2,uint16_t color);
|
||||
void LCD_DrawCircle(uint16_t x,uint16_t y,uint16_t r,uint16_t color);
|
||||
void LCD_DrawArea(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2,uint16_t color);
|
||||
void LCD_DrawPicture(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2,uint16_t* picture);
|
||||
// void LCD_UartDrawPicture(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2,UART_ID_Type uartId);
|
||||
void LCD_DrawChinese(uint16_t x,uint16_t y,uint8_t* character,uint16_t bColor,uint16_t cColor);
|
||||
|
||||
/*@} end of group TFT_LCD_Public_Functions */
|
||||
|
||||
/*@} end of group TFT_LCD */
|
||||
|
||||
/*@} end of group BL702_Peripheral_Driver */
|
||||
|
||||
#endif /* __TFT_LCD_H__ */
|
251
bsp/bsp_common/platform/bflb_platform.c
Normal file
251
bsp/bsp_common/platform/bflb_platform.c
Normal file
@ -0,0 +1,251 @@
|
||||
/**
|
||||
* @file bflb_platform.c
|
||||
* @brief
|
||||
*
|
||||
* Copyright (c) 2021 Bouffalolab team
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "hal_uart.h"
|
||||
#include "hal_mtimer.h"
|
||||
#include "drv_mmheap.h"
|
||||
#include "ring_buffer.h"
|
||||
#include "drv_shell.h"
|
||||
extern uint32_t _HeapBase;
|
||||
extern uint32_t _HeapSize;
|
||||
|
||||
static uint8_t uart_dbg_disable=0;
|
||||
|
||||
#ifdef SHELL_SUPPORT
|
||||
Shell shell;
|
||||
char shellBuffer[512];
|
||||
|
||||
void uart0_irq_callback(struct device *dev, void *args, uint32_t size, uint32_t state)
|
||||
{
|
||||
uint8_t data;
|
||||
|
||||
if (state == UART_EVENT_RX_FIFO)
|
||||
{
|
||||
data = *(uint8_t *)args;
|
||||
shellHandler(&shell, data);
|
||||
}
|
||||
}
|
||||
|
||||
void userShellWrite(char data)
|
||||
{
|
||||
struct device *uart = device_find("debug_log");
|
||||
device_write(uart, 0, (uint8_t *)&data, 1);
|
||||
}
|
||||
|
||||
void shell_init(void)
|
||||
{
|
||||
|
||||
shell.write = userShellWrite;
|
||||
shellInit(&shell, shellBuffer, 512);
|
||||
}
|
||||
#else
|
||||
void uart0_irq_callback(struct device *dev, void *args, uint32_t size, uint32_t state)
|
||||
{
|
||||
if (state == UART_EVENT_RX_FIFO)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
__WEAK__ void board_init(void)
|
||||
{
|
||||
|
||||
}
|
||||
__WEAK__ void bl_show_info(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void bflb_platform_init(uint32_t baudrate)
|
||||
{
|
||||
disable_irq();
|
||||
|
||||
board_init();
|
||||
|
||||
mtimer_init();
|
||||
|
||||
if(!uart_dbg_disable){
|
||||
uart_register(UART0_INDEX, "debug_log", DEVICE_OFLAG_RDWR);
|
||||
struct device *uart = device_find("debug_log");
|
||||
|
||||
if (uart)
|
||||
{
|
||||
device_open(uart, DEVICE_OFLAG_STREAM_TX | DEVICE_OFLAG_INT_RX);
|
||||
device_set_callback(uart, uart0_irq_callback);
|
||||
device_control(uart, DEVICE_CTRL_SET_INT, (void *)(UART_RX_FIFO_IT));
|
||||
}
|
||||
|
||||
bl_show_info();
|
||||
}
|
||||
|
||||
#ifdef SHELL_SUPPORT
|
||||
shell_init();
|
||||
#endif
|
||||
|
||||
if (!mmheap_init_with_pool(&_HeapBase, (size_t)&_HeapSize))
|
||||
{
|
||||
MSG("dynamic memory init success,heap size = 0x%x \r\n", &_HeapSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
MSG("dynamic memory init error\r\n");
|
||||
}
|
||||
|
||||
enable_irq();
|
||||
}
|
||||
|
||||
void bflb_platform_printf(char *fmt, ...)
|
||||
{
|
||||
struct device *uart = device_find("debug_log");
|
||||
char print_buf[128];
|
||||
va_list ap;
|
||||
|
||||
if(!uart_dbg_disable){
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(print_buf, sizeof(print_buf) - 1, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
device_write(uart, 0, (uint8_t *)print_buf, strlen(print_buf));
|
||||
}
|
||||
}
|
||||
|
||||
void bflb_platform_print_set(uint8_t disable)
|
||||
{
|
||||
uart_dbg_disable=disable;
|
||||
}
|
||||
void bflb_platform_dump(uint8_t *data, uint32_t len)
|
||||
{
|
||||
uint32_t i = 0;
|
||||
|
||||
if(!uart_dbg_disable){
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
if (i % 16 == 0)
|
||||
{
|
||||
bflb_platform_printf("\r\n");
|
||||
}
|
||||
bflb_platform_printf("%02x ", data[i]);
|
||||
}
|
||||
bflb_platform_printf("\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
void bflb_platform_init_time()
|
||||
{
|
||||
mtimer_init();
|
||||
}
|
||||
|
||||
void bflb_platform_deinit_time()
|
||||
{
|
||||
mtimer_deinit();
|
||||
}
|
||||
|
||||
void bflb_platform_set_alarm_time(uint64_t time,void( *interruptFun )( void ))
|
||||
{
|
||||
mtimer_set_alarm_time(time,interruptFun);
|
||||
}
|
||||
|
||||
void bflb_platform_clear_time()
|
||||
{
|
||||
mtimer_clear_time();
|
||||
}
|
||||
|
||||
void bflb_platform_start_time()
|
||||
{
|
||||
mtimer_start();
|
||||
}
|
||||
|
||||
void bflb_platform_stop_time()
|
||||
{
|
||||
mtimer_stop();
|
||||
}
|
||||
|
||||
uint64_t bflb_platform_get_time_ms()
|
||||
{
|
||||
return mtimer_get_time_ms();
|
||||
}
|
||||
|
||||
uint64_t bflb_platform_get_time_us()
|
||||
{
|
||||
return mtimer_get_time_us();
|
||||
}
|
||||
|
||||
void bflb_platform_delay_ms(uint32_t ms)
|
||||
{
|
||||
mtimer_delay_ms(ms);
|
||||
}
|
||||
void bflb_platform_delay_us(uint32_t us)
|
||||
{
|
||||
mtimer_delay_us(us);
|
||||
}
|
||||
|
||||
void bflb_print_device_list(void){
|
||||
struct device *dev;
|
||||
dlist_t *node;
|
||||
uint8_t device_index=0;
|
||||
|
||||
MSG("Device List Print\r\n");
|
||||
|
||||
dlist_for_each(node, device_get_list_header())
|
||||
{
|
||||
dev = dlist_entry(node, struct device, list);
|
||||
|
||||
MSG("Index %d\r\nDevice Name = %s \r\n",device_index,dev->name);
|
||||
|
||||
switch(dev->type){
|
||||
|
||||
case DEVICE_CLASS_GPIO:
|
||||
MSG("Device Type = %s \r\n","GPIO");break;
|
||||
case DEVICE_CLASS_UART:
|
||||
MSG("Device Type = %s \r\n","UART");break;
|
||||
case DEVICE_CLASS_SPI:
|
||||
MSG("Device Type = %s \r\n","SPI");break;
|
||||
case DEVICE_CLASS_I2C:
|
||||
MSG("Device Type = %s \r\n","I2C");break;
|
||||
case DEVICE_CLASS_ADC:
|
||||
MSG("Device Type = %s \r\n","ADC");break;
|
||||
case DEVICE_CLASS_DMA:
|
||||
MSG("Device Type = %s \r\n","DMA");break;
|
||||
case DEVICE_CLASS_TIMER:
|
||||
MSG("Device Type = %s \r\n","TIMER");break;
|
||||
case DEVICE_CLASS_PWM:
|
||||
MSG("Device Type = %s \r\n","PWM");break;
|
||||
case DEVICE_CLASS_SDIO:
|
||||
MSG("Device Type = %s \r\n","SDIO");break;
|
||||
case DEVICE_CLASS_USB:
|
||||
MSG("Device Type = %s \r\n","USB");break;
|
||||
case DEVICE_CLASS_I2S:
|
||||
MSG("Device Type = %s \r\n","I2S");break;
|
||||
case DEVICE_CLASS_CAMERA:
|
||||
MSG("Device Type = %s \r\n","CAMERA");break;
|
||||
case DEVICE_CLASS_NONE: break;
|
||||
default : break;
|
||||
}
|
||||
|
||||
MSG("Device Handle = 0x%x \r\n",dev);
|
||||
MSG("---------------------\r\n",dev);
|
||||
|
||||
device_index++;
|
||||
}
|
||||
}
|
95
bsp/bsp_common/platform/bflb_platform.h
Normal file
95
bsp/bsp_common/platform/bflb_platform.h
Normal file
@ -0,0 +1,95 @@
|
||||
/**
|
||||
* @file bflb_platform.h
|
||||
* @brief
|
||||
*
|
||||
* Copyright (c) 2021 Bouffalolab team
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _BFLB_PLATFORM_H
|
||||
#define _BFLB_PLATFORM_H
|
||||
|
||||
#include "misc.h"
|
||||
|
||||
#define MSG(a,...) bflb_platform_printf(a,##__VA_ARGS__)
|
||||
#define MSG_ERR(a,...) bflb_platform_printf(a,##__VA_ARGS__)
|
||||
#define BL_CASE_FAIL {MSG(" Case Fail\r\n");while(1){bflb_platform_delay_ms(1);}}
|
||||
#define BL_CASE_SUCCESS {MSG(" Case Success\r\n");while(1){bflb_platform_delay_ms(1);}}
|
||||
|
||||
/* compatible with old version */
|
||||
#ifndef DBG_TAG
|
||||
#define DBG_TAG "DEBUG"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The color for terminal (foreground)
|
||||
* BLACK 30
|
||||
* RED 31
|
||||
* GREEN 32
|
||||
* YELLOW 33
|
||||
* BLUE 34
|
||||
* PURPLE 35
|
||||
* CYAN 36
|
||||
* WHITE 37
|
||||
*/
|
||||
#define _DBG_COLOR(n) bflb_platform_printf("\033["#n"m")
|
||||
#define _DBG_LOG_HDR(lvl_name, color_n) \
|
||||
bflb_platform_printf("\033["#color_n"m["lvl_name"/"DBG_TAG"] ")
|
||||
#define _DBG_LOG_X_END \
|
||||
bflb_platform_printf("\033[0m\n")
|
||||
|
||||
#define dbg_log_line(lvl, color_n, fmt, ...) \
|
||||
do \
|
||||
{ \
|
||||
_DBG_LOG_HDR(lvl, color_n); \
|
||||
bflb_platform_printf(fmt, ##__VA_ARGS__); \
|
||||
_DBG_LOG_X_END; \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
#define LOG_D(fmt, ...) dbg_log_line("D", 0, fmt, ##__VA_ARGS__)
|
||||
#define LOG_I(fmt, ...) dbg_log_line("I", 35, fmt, ##__VA_ARGS__)
|
||||
#define LOG_W(fmt, ...) dbg_log_line("W", 33, fmt, ##__VA_ARGS__)
|
||||
#define LOG_E(fmt, ...) dbg_log_line("E", 31, fmt, ##__VA_ARGS__)
|
||||
#define LOG_RAW(...) bflb_platform_printf(__VA_ARGS__)
|
||||
|
||||
#ifdef DEBUG
|
||||
void check_failed(uint8_t *file, uint32_t line);
|
||||
#define CHECK_PARAM(expr) ((expr) ? (void)0 : check_failed((uint8_t *)__FILE__, __LINE__))
|
||||
#else
|
||||
#define CHECK_PARAM(expr) ((void)0)
|
||||
#endif /* DEBUG */
|
||||
|
||||
void bflb_platform_init(uint32_t baudrate);
|
||||
void bflb_platform_printf(char *fmt,...);
|
||||
void bflb_platform_dump(uint8_t *data, uint32_t len);
|
||||
|
||||
void bflb_platform_init_time(void);
|
||||
void bflb_platform_clear_time(void);
|
||||
uint64_t bflb_platform_get_time_ms(void);
|
||||
uint64_t bflb_platform_get_time_us(void);
|
||||
void bflb_platform_start_time(void);
|
||||
void bflb_platform_stop_time(void);
|
||||
void bflb_platform_set_alarm_time(uint64_t time,void( *interruptFun )( void ));
|
||||
void bflb_platform_deinit_time(void);
|
||||
void bflb_platform_delay_ms(uint32_t ms);
|
||||
void bflb_platform_delay_us(uint32_t us);
|
||||
|
||||
void bflb_print_device_list(void);
|
||||
|
||||
#endif
|
970
bsp/bsp_common/spi_sd/bsp_spi_sd.c
Normal file
970
bsp/bsp_common/spi_sd/bsp_spi_sd.c
Normal file
@ -0,0 +1,970 @@
|
||||
/**
|
||||
* @file bsp_spi_sd.c
|
||||
* @brief
|
||||
*
|
||||
* Copyright (c) 2021 Bouffalolab team
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "hal_spi.h"
|
||||
#include "hal_gpio.h"
|
||||
#include "hal_dma.h"
|
||||
#include "bl702_spi.h"
|
||||
#include "bsp_spi_sd.h"
|
||||
|
||||
struct device* spi0;
|
||||
struct device* dma_ch3;
|
||||
struct device* dma_ch4;
|
||||
|
||||
SD_CardInfoTypedef SD_CardInfo = {0};
|
||||
|
||||
|
||||
uint8_t SD_SPI_Init(void)
|
||||
{
|
||||
spi_register(0,"spi0",DEVICE_OFLAG_RDWR);
|
||||
dma_register(DMA0_CH3_INDEX, "ch3", DEVICE_OFLAG_RDWR);
|
||||
dma_register(DMA0_CH4_INDEX, "ch4", DEVICE_OFLAG_RDWR);
|
||||
gpio_set_mode(SPI_PIN_CS,GPIO_OUTPUT_MODE);
|
||||
gpio_write(SPI_PIN_CS,1);
|
||||
spi0 = device_find("spi0");
|
||||
if(spi0)
|
||||
{
|
||||
device_open(spi0,DEVICE_OFLAG_DMA_TX|DEVICE_OFLAG_DMA_RX);
|
||||
}
|
||||
|
||||
dma_ch3 = device_find("ch3");
|
||||
if (dma_ch3)
|
||||
{
|
||||
((dma_device_t*)dma_ch3)->direction = DMA_MEMORY_TO_PERIPH;
|
||||
((dma_device_t*)dma_ch3)->transfer_mode = DMA_LLI_ONCE_MODE;
|
||||
((dma_device_t*)dma_ch3)->src_req = DMA_REQUEST_NONE;
|
||||
((dma_device_t*)dma_ch3)->dst_req = DMA_REQUEST_SPI0_TX;
|
||||
((dma_device_t*)dma_ch3)->src_width = DMA_TRANSFER_WIDTH_8BIT;
|
||||
((dma_device_t*)dma_ch3)->dst_width = DMA_TRANSFER_WIDTH_8BIT;
|
||||
device_open(dma_ch3, 0);
|
||||
device_set_callback(dma_ch3, NULL);
|
||||
device_control(dma_ch3, DEVICE_CTRL_SET_INT, NULL);
|
||||
}
|
||||
|
||||
dma_ch4 = device_find("ch4");
|
||||
if (dma_ch4)
|
||||
{
|
||||
((dma_device_t*)dma_ch4)->direction = DMA_PERIPH_TO_MEMORY;
|
||||
((dma_device_t*)dma_ch4)->transfer_mode = DMA_LLI_ONCE_MODE;
|
||||
((dma_device_t*)dma_ch4)->src_req = DMA_REQUEST_SPI0_RX;
|
||||
((dma_device_t*)dma_ch4)->dst_req = DMA_REQUEST_NONE;
|
||||
((dma_device_t*)dma_ch4)->src_width = DMA_TRANSFER_WIDTH_8BIT ;
|
||||
((dma_device_t*)dma_ch4)->dst_width = DMA_TRANSFER_WIDTH_8BIT ;
|
||||
device_open(dma_ch4, 0);
|
||||
device_set_callback(dma_ch4, NULL);
|
||||
device_control(dma_ch4, DEVICE_CTRL_SET_INT, NULL);
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
BL_Err_Type SPI_ReadWriteByte(uint8_t *txBuff, uint8_t *rxBuff, uint32_t length)
|
||||
{
|
||||
static SPI_FifoCfg_Type SPI_fifoconfig={
|
||||
.txFifoThreshold = 1,
|
||||
.rxFifoThreshold = 1,
|
||||
.txFifoDmaEnable = ENABLE,
|
||||
.rxFifoDmaEnable = ENABLE,
|
||||
};
|
||||
|
||||
// DMA自动与手动无法同时使用,DmaEnable开启后,一旦进行手动发送,之后DMA发送就会卡死
|
||||
// test code:
|
||||
// MSG("SPI_DMA_test 1\r\n");
|
||||
// dma_reload(dma_ch3, (uint32_t)txBuff, (uint32_t)DMA_ADDR_SPI_TDR, length);
|
||||
// dma_reload(dma_ch4, (uint32_t)DMA_ADDR_SPI_RDR, (uint32_t)rxBuff, length);
|
||||
// dma_channel_start(dma_ch3);
|
||||
// dma_channel_start(dma_ch4);
|
||||
// while (device_control(dma_ch3, DMA_CHANNEL_GET_STATUS_CMD, NULL) || device_control(dma_ch4, DMA_CHANNEL_GET_STATUS_CMD, NULL))
|
||||
// {
|
||||
// }
|
||||
// MSG("SPI_DMA_test 2\r\n");
|
||||
// spi_transmit_receive(spi0,txBuff,rxBuff,length,SPI_DATASIZE_8BIT);
|
||||
// MSG("SPI_DMA_test 3\r\n");
|
||||
|
||||
if(length<500)
|
||||
{
|
||||
if(SPI_fifoconfig.txFifoDmaEnable == ENABLE || SPI_fifoconfig.rxFifoDmaEnable == ENABLE)
|
||||
{
|
||||
SPI_fifoconfig.txFifoDmaEnable = DISABLE;
|
||||
SPI_fifoconfig.rxFifoDmaEnable = DISABLE;
|
||||
SPI_FifoConfig(SPI_ID_0,&SPI_fifoconfig);
|
||||
}
|
||||
spi_transmit_receive(spi0,txBuff,rxBuff,length,SPI_DATASIZE_8BIT);
|
||||
}
|
||||
else{
|
||||
if(SPI_fifoconfig.txFifoDmaEnable == DISABLE || SPI_fifoconfig.rxFifoDmaEnable == DISABLE)
|
||||
{
|
||||
SPI_fifoconfig.txFifoDmaEnable = ENABLE;
|
||||
SPI_fifoconfig.rxFifoDmaEnable = ENABLE;
|
||||
SPI_FifoConfig(SPI_ID_0,&SPI_fifoconfig);
|
||||
}
|
||||
dma_reload(dma_ch3, (uint32_t)txBuff, (uint32_t)DMA_ADDR_SPI_TDR, length);
|
||||
dma_reload(dma_ch4, (uint32_t)DMA_ADDR_SPI_RDR, (uint32_t)rxBuff, length);
|
||||
dma_channel_start(dma_ch3);
|
||||
dma_channel_start(dma_ch4);
|
||||
while(device_control(dma_ch3,DMA_CHANNEL_GET_STATUS_CMD,NULL)||device_control(dma_ch4,DMA_CHANNEL_GET_STATUS_CMD,NULL))
|
||||
{
|
||||
}
|
||||
dma_channel_stop(dma_ch3);
|
||||
dma_channel_stop(dma_ch4);
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
void SPI_CS_WriteBit(uint8_t bit)
|
||||
{
|
||||
gpio_write(SPI_PIN_CS,bit);
|
||||
}
|
||||
/****************************************************************************
|
||||
* @brief SPI_SetSpeed
|
||||
*
|
||||
*
|
||||
*******************************************************************************/
|
||||
static void SD_SPI_SetSpeed(uint8_t mode)
|
||||
{
|
||||
switch (mode){
|
||||
case (0):
|
||||
device_control(spi0, DEVICE_CTRL_SPI_CONFIG_CLOCK_CMD,(void*)(300 * 1000));
|
||||
break;
|
||||
case (1):
|
||||
device_control(spi0, DEVICE_CTRL_SPI_CONFIG_CLOCK_CMD,(void*)(18 * 1000 * 1000));
|
||||
break;
|
||||
case (2):
|
||||
device_control(spi0, DEVICE_CTRL_SPI_CONFIG_CLOCK_CMD,(void*)(40 * 1000 * 1000));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* @brief SPI_CS_WriteBit
|
||||
*
|
||||
*
|
||||
*******************************************************************************/
|
||||
// static void SPI_CS_WriteBit(uint8_t bit)
|
||||
// {
|
||||
// GLB_GPIO_Write(SPI_PIN_CS, bit);
|
||||
// }
|
||||
|
||||
/****************************************************************************/ /**
|
||||
* @brief SD_GetResponse
|
||||
*
|
||||
*
|
||||
*******************************************************************************/
|
||||
static BL_Err_Type SD_GetResponse(uint8_t Response)
|
||||
{
|
||||
uint8_t rx;
|
||||
uint8_t t_0xFF = 0xFF;
|
||||
uint16_t Count = 0xFFFE;
|
||||
do{
|
||||
SPI_ReadWriteByte(&t_0xFF, &rx, 1);
|
||||
Count--;
|
||||
} while (rx != Response && Count);
|
||||
|
||||
if (Count == 0)
|
||||
return ERROR;
|
||||
else
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* @brief SD_SendCommand
|
||||
*
|
||||
*
|
||||
*******************************************************************************/
|
||||
static uint8_t SD_SendCommand(uint8_t cmd, uint32_t arg, uint8_t crc)
|
||||
{
|
||||
uint8_t rx;
|
||||
uint8_t t_0xFF = 0xFF;
|
||||
uint8_t rxbuff[6];
|
||||
uint8_t txbuff[6];
|
||||
uint8_t retry = 0;
|
||||
|
||||
SPI_CS_WriteBit(1);
|
||||
SPI_ReadWriteByte(&t_0xFF, &rx, 1);
|
||||
|
||||
SPI_CS_WriteBit(0);
|
||||
SD_GetResponse(0xFF);
|
||||
|
||||
txbuff[0] = cmd | 0x40;
|
||||
txbuff[1] = (uint8_t)(arg >> 24);
|
||||
txbuff[2] = (uint8_t)(arg >> 16);
|
||||
txbuff[3] = (uint8_t)(arg >> 8);
|
||||
txbuff[4] = (uint8_t)(arg);
|
||||
txbuff[5] = (uint8_t)(crc);
|
||||
|
||||
SPI_ReadWriteByte(txbuff, rxbuff, 6);
|
||||
|
||||
SPI_ReadWriteByte(&t_0xFF, &rx, 1);
|
||||
|
||||
do{
|
||||
SPI_ReadWriteByte(&t_0xFF, &rx, 1);
|
||||
retry++;
|
||||
} while (rx == 0xFF && retry < 20);
|
||||
|
||||
//MSG("CMD%d :%d num:%d\r\n",cmd,rx,retry);
|
||||
SPI_CS_WriteBit(1);
|
||||
SPI_ReadWriteByte(&t_0xFF, &retry, 1);
|
||||
|
||||
return rx;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* @brief SD_SendCommand_NoDeassert
|
||||
*
|
||||
*
|
||||
*******************************************************************************/
|
||||
static uint8_t SD_SendCommand_NoDeassert(uint8_t cmd, uint32_t arg, uint8_t crc)
|
||||
{
|
||||
uint8_t rx;
|
||||
uint8_t t_0xFF = 0xFF;
|
||||
uint8_t rxbuff[6];
|
||||
uint8_t txbuff[6];
|
||||
uint8_t retry = 0;
|
||||
|
||||
SPI_CS_WriteBit(1);
|
||||
SPI_ReadWriteByte(&t_0xFF, &rx, 1);
|
||||
|
||||
SPI_CS_WriteBit(0);
|
||||
SD_GetResponse(0xFF);
|
||||
|
||||
txbuff[0] = cmd | 0x40;
|
||||
txbuff[1] = (uint8_t)(arg >> 24);
|
||||
txbuff[2] = (uint8_t)(arg >> 16);
|
||||
txbuff[3] = (uint8_t)(arg >> 8);
|
||||
txbuff[4] = (uint8_t)(arg);
|
||||
txbuff[5] = (uint8_t)(crc);
|
||||
|
||||
SPI_ReadWriteByte(txbuff, rxbuff, 6);
|
||||
|
||||
SPI_ReadWriteByte(&t_0xFF, &rx, 1);
|
||||
|
||||
do{
|
||||
SPI_ReadWriteByte(&t_0xFF, &rx, 1);
|
||||
retry++;
|
||||
} while (rx == 0xFF && retry < 20);
|
||||
|
||||
//MSG("CMD%d :%d num:%d\r\n",cmd,rx,retry);
|
||||
|
||||
return rx;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* @brief SD_Idle_Sta
|
||||
*
|
||||
*
|
||||
*******************************************************************************/
|
||||
static BL_Err_Type SD_Idle_Sta(void)
|
||||
{
|
||||
uint16_t i;
|
||||
uint8_t rx = 0;
|
||||
uint8_t t_0xFF = 0xFF;
|
||||
uint8_t retry = 0;
|
||||
|
||||
SPI_CS_WriteBit(1);
|
||||
|
||||
for (i = 0; i < 10; i++)
|
||||
SPI_ReadWriteByte(&t_0xFF, &rx, 1);
|
||||
|
||||
do
|
||||
{
|
||||
rx = SD_SendCommand(CMD0, 0, 0x95);
|
||||
retry++;
|
||||
} while (rx != MSD_IN_IDLE_STATE && retry < 100);
|
||||
|
||||
if (retry >= 100)
|
||||
{
|
||||
//MSG("SD IDLE err:%d\r\n",rx);
|
||||
return ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
//MSG("SD IDLE success\r\n");
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************/ /**
|
||||
* @brief SD_ReceiveData
|
||||
*
|
||||
*
|
||||
*
|
||||
*******************************************************************************/
|
||||
uint8_t SD_ReceiveData(uint8_t *data, uint16_t len, uint8_t release)
|
||||
{
|
||||
uint8_t rx;
|
||||
uint8_t t_0xFF = 0xFF;
|
||||
uint16_t i;
|
||||
|
||||
SPI_CS_WriteBit(0);
|
||||
/* get token */
|
||||
if (SD_GetResponse(0xFE))
|
||||
{
|
||||
SPI_CS_WriteBit(1);
|
||||
MSG("sd receive err: no token\r\n");
|
||||
return ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
//MSG("sd get token\r\n");
|
||||
}
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
SPI_ReadWriteByte(&t_0xFF, data + i, 1);
|
||||
}
|
||||
/* two dummy CRC */
|
||||
SPI_ReadWriteByte(&t_0xFF, &rx, 1);
|
||||
SPI_ReadWriteByte(&t_0xFF, &rx, 1);
|
||||
/* */
|
||||
if (release)
|
||||
SPI_CS_WriteBit(1);
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/****************************************************************************/ /**
|
||||
* @brief SD_SendBlock
|
||||
*
|
||||
*
|
||||
*
|
||||
*******************************************************************************/
|
||||
uint8_t SD_SendBlock(uint8_t *buf, uint8_t cmd)
|
||||
{
|
||||
uint8_t rx;
|
||||
uint8_t rxbuff[512];
|
||||
uint8_t t_0xFF = 0xFF;
|
||||
uint16_t i;
|
||||
/* Waiti for free */
|
||||
if (SD_GetResponse(0xFF))
|
||||
{
|
||||
SPI_CS_WriteBit(1);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
/* send token */
|
||||
SPI_ReadWriteByte(&cmd, &rx, 1);
|
||||
|
||||
if (cmd != 0xFD)
|
||||
{
|
||||
/* send block data */
|
||||
SPI_ReadWriteByte(buf, rxbuff, 512);
|
||||
/* two dummy CRC */
|
||||
SPI_ReadWriteByte(&t_0xFF, &rx, 1);
|
||||
SPI_ReadWriteByte(&t_0xFF, &rx, 1);
|
||||
/* 8 clock */
|
||||
SPI_ReadWriteByte(&t_0xFF, &rx, 1);
|
||||
|
||||
if ((rx & 0x1F) != 0x05)
|
||||
{
|
||||
//MSG("sd send err:%d\r\n",rx,1);
|
||||
SPI_CS_WriteBit(1);
|
||||
return rx;
|
||||
}
|
||||
i = 0;
|
||||
do
|
||||
{
|
||||
SPI_ReadWriteByte(&t_0xFF, &rx, 1);
|
||||
i++;
|
||||
} while (rx != 0xFF && i <= 0xFFFE);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/****************************************************************************/ /**
|
||||
* @brief SD_GetCID
|
||||
*
|
||||
*
|
||||
*******************************************************************************/
|
||||
// static uint8_t SD_GetCID(uint8_t *cid_data)
|
||||
// {
|
||||
// uint8_t rx, i;
|
||||
// rx = SD_SendCommand(CMD10, 0, 0xFF);
|
||||
// if (rx)
|
||||
// {
|
||||
// MSG("get CID err:%d\r\n", rx);
|
||||
// return rx;
|
||||
// }
|
||||
// SD_ReceiveData(cid_data, 16, RELEASE);
|
||||
// MSG("sd cid:");
|
||||
// for (i = 0; i < 16; i++)
|
||||
// MSG("%02X ", cid_data[i]);
|
||||
// MSG("end\r\n");
|
||||
|
||||
// return SUCCESS;
|
||||
// }
|
||||
|
||||
// /****************************************************************************
|
||||
// * @brief SD_GetCSD
|
||||
// *
|
||||
// *
|
||||
// *******************************************************************************/
|
||||
// static uint8_t SD_GetCSD(uint8_t *sid_data)
|
||||
// {
|
||||
// uint8_t rx, i;
|
||||
// rx = SD_SendCommand(CMD9, 0, 0xFF);
|
||||
// if (rx)
|
||||
// {
|
||||
// MSG("get CSD err: CMD9 %d\r\n", rx);
|
||||
// return rx;
|
||||
// }
|
||||
// SD_ReceiveData(sid_data, 16, RELEASE);
|
||||
|
||||
// MSG("sd sid:");
|
||||
// for (i = 0; i < 16; i++)
|
||||
// MSG("%02X ", sid_data[i]);
|
||||
// MSG("end\r\n");
|
||||
|
||||
// return SUCCESS;
|
||||
// }
|
||||
|
||||
// /****************************************************************************/ /**
|
||||
// * @brief SD_GetCapacity
|
||||
// *
|
||||
// *
|
||||
// *******************************************************************************/
|
||||
// uint64_t SD_GetCapacity()
|
||||
// {
|
||||
// uint8_t csd[16] = {0};
|
||||
// uint8_t r1;
|
||||
// uint16_t i;
|
||||
// uint64_t Capacity, temp;
|
||||
|
||||
// if (SD_GetCSD(csd) != 0)
|
||||
// return ERROR;
|
||||
// /* SDHC */
|
||||
// if ((csd[0] & 0xC0) == 0x40)
|
||||
// {
|
||||
// Capacity = (uint64_t)csd[9];
|
||||
// Capacity += ((uint64_t)csd[8]) << 8;
|
||||
// Capacity += ((uint64_t)csd[7] & 0x3F) << 16;
|
||||
// Capacity = (Capacity + 1) << 9; /* sector */
|
||||
// //Capacity*=512; /* KByte */
|
||||
// MSG("SDHC capacity:%lld MByte\r\n", Capacity / 1024);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// i = csd[6] & 0x03;
|
||||
// i <<= 8;
|
||||
// i += csd[7];
|
||||
// i <<= 2;
|
||||
// i += ((csd[8] & 0xc0) >> 6);
|
||||
// /*C_SIZE_MULT */
|
||||
// r1 = csd[9] & 0x03;
|
||||
// r1 <<= 1;
|
||||
// r1 += ((csd[10] & 0x80) >> 7);
|
||||
// r1 += 2;
|
||||
// temp = 1;
|
||||
// while (r1)
|
||||
// {
|
||||
// temp *= 2;
|
||||
// r1--;
|
||||
// }
|
||||
// Capacity = ((uint64_t)(i + 1)) * ((uint64_t)temp);
|
||||
// /* READ_BL_LEN */
|
||||
// i = csd[5] & 0x0f;
|
||||
// /* BLOCK_LEN */
|
||||
// temp = 1;
|
||||
// while (i)
|
||||
// {
|
||||
// temp *= 2;
|
||||
// i--;
|
||||
// }
|
||||
// /* The final result */
|
||||
// Capacity *= (uint64_t)temp; //字节为单位
|
||||
// MSG("SD capacity:%u MByte\r\n", Capacity / 1024 / 1024);
|
||||
// }
|
||||
// return (uint32_t)Capacity;
|
||||
// }
|
||||
|
||||
/****************************************************************************/ /**
|
||||
* @brief SD_Get_CardInfo
|
||||
*
|
||||
*
|
||||
*******************************************************************************/
|
||||
uint8_t SD_Get_CardInfo(SD_CardInfoTypedef *pCardInfo)
|
||||
{
|
||||
uint8_t rx,t_0xFF;
|
||||
uint32_t tmp = 0;
|
||||
/* get cid */
|
||||
rx = SD_SendCommand(CMD10, 0, 0xFF);
|
||||
if (rx)
|
||||
return 1;
|
||||
SD_ReceiveData(pCardInfo->SD_cid.CID, 16, RELEASE);
|
||||
SPI_ReadWriteByte(&t_0xFF, &rx, 1);
|
||||
/* get csd */
|
||||
rx = SD_SendCommand(CMD9, 0, 0xFF);
|
||||
if (rx)
|
||||
return 1;
|
||||
SD_ReceiveData(pCardInfo->SD_csd.CSD, 16, RELEASE);
|
||||
|
||||
/* Byte 0 */
|
||||
tmp = pCardInfo->SD_csd.CSD[0];
|
||||
pCardInfo->SD_csd.CSDStruct = (uint8_t)((tmp & 0xC0) >> 6);
|
||||
pCardInfo->SD_csd.SysSpecVersion = (uint8_t)((tmp & 0x3C) >> 2);
|
||||
pCardInfo->SD_csd.Reserved1 = tmp & 0x03;
|
||||
/* Byte 1 */
|
||||
tmp = pCardInfo->SD_csd.CSD[1];
|
||||
pCardInfo->SD_csd.TAAC = (uint8_t)tmp;
|
||||
/* Byte 2 */
|
||||
tmp = pCardInfo->SD_csd.CSD[2];
|
||||
pCardInfo->SD_csd.NSAC = (uint8_t)tmp;
|
||||
/* Byte 3 */
|
||||
tmp = pCardInfo->SD_csd.CSD[3];
|
||||
pCardInfo->SD_csd.MaxBusClkFrec = (uint8_t)tmp;
|
||||
/* Byte 4 */
|
||||
tmp = pCardInfo->SD_csd.CSD[4] ;
|
||||
pCardInfo->SD_csd.CardComdClasses = (uint16_t)(tmp << 4);
|
||||
/* Byte 5 */
|
||||
tmp = pCardInfo->SD_csd.CSD[5];
|
||||
pCardInfo->SD_csd.CardComdClasses |= (uint16_t)((tmp & 0xF0) >> 4);
|
||||
pCardInfo->SD_csd.RdBlockLen = (uint8_t)(tmp & 0x0F);
|
||||
/* Byte 6 */
|
||||
tmp = pCardInfo->SD_csd.CSD[6];
|
||||
pCardInfo->SD_csd.PartBlockRead = (uint8_t)((tmp & 0x80) >> 7);
|
||||
pCardInfo->SD_csd.WrBlockMisalign = (uint8_t)((tmp & 0x40) >> 6);
|
||||
pCardInfo->SD_csd.RdBlockMisalign = (uint8_t)((tmp & 0x20) >> 5);
|
||||
pCardInfo->SD_csd.DSRImpl = (uint8_t)((tmp & 0x10) >> 4);
|
||||
pCardInfo->SD_csd.Reserved2 = 0; /*!< Reserved */
|
||||
|
||||
if ((pCardInfo->CardType == SD_TYPE_V1) || (pCardInfo->CardType == SD_TYPE_V2))
|
||||
{
|
||||
pCardInfo->SD_csd.DeviceSize = (tmp & 0x03) << 10;
|
||||
/* Byte 7 */
|
||||
tmp = pCardInfo->SD_csd.CSD[7] ;
|
||||
pCardInfo->SD_csd.DeviceSize |= (tmp) << 2;
|
||||
/* Byte 8 */
|
||||
tmp = pCardInfo->SD_csd.CSD[8] ;
|
||||
pCardInfo->SD_csd.DeviceSize |= (tmp & 0xC0) >> 6;
|
||||
pCardInfo->SD_csd.MaxRdCurrentVDDMin = (tmp & 0x38) >> 3;
|
||||
pCardInfo->SD_csd.MaxRdCurrentVDDMax = (tmp & 0x07);
|
||||
/* Byte 9 */
|
||||
tmp = pCardInfo->SD_csd.CSD[9] ;
|
||||
pCardInfo->SD_csd.MaxWrCurrentVDDMin = (tmp & 0xE0) >> 5;
|
||||
pCardInfo->SD_csd.MaxWrCurrentVDDMax = (tmp & 0x1C) >> 2;
|
||||
pCardInfo->SD_csd.DeviceSizeMul = (tmp & 0x03) << 1;
|
||||
/* Byte 10 */
|
||||
tmp = pCardInfo->SD_csd.CSD[10] ;
|
||||
pCardInfo->SD_csd.DeviceSizeMul |= (tmp & 0x80) >> 7;
|
||||
|
||||
pCardInfo->CardCapacity = (pCardInfo->SD_csd.DeviceSize + 1);
|
||||
pCardInfo->CardCapacity *= (1 << (pCardInfo->SD_csd.DeviceSizeMul + 2));
|
||||
pCardInfo->CardBlockSize = 1 << (pCardInfo->SD_csd.RdBlockLen);
|
||||
pCardInfo->CardCapacity *= pCardInfo->CardBlockSize;
|
||||
}
|
||||
else if (pCardInfo->CardType == SD_TYPE_V2HC)
|
||||
{
|
||||
/* Byte 7 */
|
||||
tmp = pCardInfo->SD_csd.CSD[7] ;
|
||||
pCardInfo->SD_csd.DeviceSize = (tmp & 0x3F) << 16;
|
||||
/* Byte 8 */
|
||||
tmp = pCardInfo->SD_csd.CSD[8] ;
|
||||
pCardInfo->SD_csd.DeviceSize |= (tmp << 8);
|
||||
/* Byte 9 */
|
||||
tmp = pCardInfo->SD_csd.CSD[9];
|
||||
pCardInfo->SD_csd.DeviceSize |= (tmp);
|
||||
/* Byte 10 */
|
||||
tmp = pCardInfo->SD_csd.CSD[10] ;
|
||||
|
||||
pCardInfo->CardCapacity = (uint64_t)((((uint64_t)pCardInfo->SD_csd.DeviceSize + 1)) * 512 * 1024);
|
||||
pCardInfo->CardBlockSize = 512;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Not supported card type */
|
||||
}
|
||||
pCardInfo->SD_csd.EraseGrSize = (tmp & 0x40) >> 6;
|
||||
pCardInfo->SD_csd.EraseGrMul = (tmp & 0x3F) << 1;
|
||||
/* Byte 11 */
|
||||
tmp = pCardInfo->SD_csd.CSD[11];
|
||||
pCardInfo->SD_csd.EraseGrMul |= (tmp & 0x80) >> 7;
|
||||
pCardInfo->SD_csd.WrProtectGrSize = (tmp & 0x7F);
|
||||
/* Byte 12 */
|
||||
tmp = pCardInfo->SD_csd.CSD[12];
|
||||
pCardInfo->SD_csd.WrProtectGrEnable = (tmp & 0x80) >> 7;
|
||||
pCardInfo->SD_csd.ManDeflECC = (tmp & 0x60) >> 5;
|
||||
pCardInfo->SD_csd.WrSpeedFact = (tmp & 0x1C) >> 2;
|
||||
pCardInfo->SD_csd.MaxWrBlockLen = (tmp & 0x03) << 2;
|
||||
/* Byte 13 */
|
||||
tmp = pCardInfo->SD_csd.CSD[13];
|
||||
pCardInfo->SD_csd.MaxWrBlockLen |= (tmp & 0xC0) >> 6;
|
||||
pCardInfo->SD_csd.WriteBlockPaPartial = (tmp & 0x20) >> 5;
|
||||
pCardInfo->SD_csd.Reserved3 = 0;
|
||||
pCardInfo->SD_csd.ContentProtectAppli = (tmp & 0x01);
|
||||
/* Byte 14 */
|
||||
tmp = pCardInfo->SD_csd.CSD[14] ;
|
||||
pCardInfo->SD_csd.FileFormatGrouop = (tmp & 0x80) >> 7;
|
||||
pCardInfo->SD_csd.CopyFlag = (tmp & 0x40) >> 6;
|
||||
pCardInfo->SD_csd.PermWrProtect = (tmp & 0x20) >> 5;
|
||||
pCardInfo->SD_csd.TempWrProtect = (tmp & 0x10) >> 4;
|
||||
pCardInfo->SD_csd.FileFormat = (tmp & 0x0C) >> 2;
|
||||
pCardInfo->SD_csd.ECC = (tmp & 0x03);
|
||||
/* Byte 15 */
|
||||
tmp = pCardInfo->SD_csd.CSD[15];
|
||||
pCardInfo->SD_csd.CSD_CRC = (tmp & 0xFE) >> 1;
|
||||
pCardInfo->SD_csd.Reserved4 = 1;
|
||||
|
||||
/* Byte 0 */
|
||||
tmp = pCardInfo->SD_cid.CID[0] ;
|
||||
pCardInfo->SD_cid.ManufacturerID = tmp;
|
||||
/* Byte 1 */
|
||||
tmp = pCardInfo->SD_cid.CID[1];
|
||||
pCardInfo->SD_cid.OEM_AppliID = tmp << 8;
|
||||
/* Byte 2 */
|
||||
tmp = pCardInfo->SD_cid.CID[2];
|
||||
pCardInfo->SD_cid.OEM_AppliID |= tmp;
|
||||
/* Byte 3 */
|
||||
tmp = pCardInfo->SD_cid.CID[3];
|
||||
pCardInfo->SD_cid.ProdName1 = tmp << 24;
|
||||
/* Byte 4 */
|
||||
tmp = pCardInfo->SD_cid.CID[4];
|
||||
pCardInfo->SD_cid.ProdName1 |= tmp << 16;
|
||||
/* Byte 5 */
|
||||
tmp = pCardInfo->SD_cid.CID[5];
|
||||
pCardInfo->SD_cid.ProdName1 |= tmp << 8;
|
||||
/* Byte 6 */
|
||||
tmp = pCardInfo->SD_cid.CID[6];
|
||||
pCardInfo->SD_cid.ProdName1 |= tmp;
|
||||
/* Byte 7 */
|
||||
tmp = pCardInfo->SD_cid.CID[7];
|
||||
pCardInfo->SD_cid.ProdName2 = tmp;
|
||||
/* Byte 8 */
|
||||
tmp = pCardInfo->SD_cid.CID[8] ;
|
||||
pCardInfo->SD_cid.ProdRev = tmp;
|
||||
/* Byte 9 */
|
||||
tmp = pCardInfo->SD_cid.CID[9];
|
||||
pCardInfo->SD_cid.ProdSN = tmp << 24;
|
||||
/* Byte 10 */
|
||||
tmp = pCardInfo->SD_cid.CID[10];
|
||||
pCardInfo->SD_cid.ProdSN |= tmp << 16;
|
||||
/* Byte 11 */
|
||||
tmp = pCardInfo->SD_cid.CID[11];
|
||||
pCardInfo->SD_cid.ProdSN |= tmp << 8;
|
||||
/* Byte 12 */
|
||||
tmp = pCardInfo->SD_cid.CID[12];
|
||||
pCardInfo->SD_cid.ProdSN |= tmp;
|
||||
/* Byte 13 */
|
||||
tmp = pCardInfo->SD_cid.CID[13];
|
||||
pCardInfo->SD_cid.Reserved1 |= (tmp & 0xF0) >> 4;
|
||||
pCardInfo->SD_cid.ManufactDate = (tmp & 0x0F) << 8;
|
||||
/* Byte 14 */
|
||||
tmp = pCardInfo->SD_cid.CID[14];
|
||||
pCardInfo->SD_cid.ManufactDate |= tmp;
|
||||
/* Byte 15 */
|
||||
tmp = pCardInfo->SD_cid.CID[16];
|
||||
pCardInfo->SD_cid.CID_CRC = (tmp & 0xFE) >> 1;
|
||||
pCardInfo->SD_cid.Reserved2 = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/****************************************************************************/ /**
|
||||
* @brief SD_ReadSingleBlock
|
||||
*
|
||||
*
|
||||
*******************************************************************************/
|
||||
uint8_t SD_ReadBlock(uint32_t sector, uint8_t *buffer, uint32_t num)
|
||||
{
|
||||
uint8_t rx;
|
||||
uint8_t t_0xFF;
|
||||
SPI_CS_WriteBit(0);
|
||||
/* sector to byte */
|
||||
if (SD_CardInfo.CardType != SD_TYPE_V2HC){
|
||||
sector = sector << 9;
|
||||
}
|
||||
if (num == 1){
|
||||
rx = SD_SendCommand(CMD17, sector, 0);
|
||||
if (rx)
|
||||
{
|
||||
MSG("SD CMD17 err:%02X\r\n", rx);
|
||||
return rx;
|
||||
}
|
||||
rx = SD_ReceiveData(buffer, 512, RELEASE);
|
||||
if (rx != 0)
|
||||
{
|
||||
MSG("SD sing read err:%02X\r\n", rx);
|
||||
return rx;
|
||||
}
|
||||
}
|
||||
else{
|
||||
rx = SD_SendCommand(CMD18, sector, 0);
|
||||
if (rx)
|
||||
{
|
||||
MSG("SD CMD18 err:%02X\r\n", rx);
|
||||
return rx;
|
||||
}
|
||||
while (num--)
|
||||
{
|
||||
rx = SD_ReceiveData(buffer, 512, NO_RELEASE);
|
||||
if (rx != 0)
|
||||
{
|
||||
MSG("SD read err:%02X\r\n", rx);
|
||||
return rx;
|
||||
}
|
||||
buffer += 512;
|
||||
}
|
||||
rx = SD_SendCommand(CMD12, 0, 0);
|
||||
SPI_CS_WriteBit(1);
|
||||
SPI_ReadWriteByte(&t_0xFF, &rx, 1);
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
/****************************************************************************/ /**
|
||||
* @brief SD_WriteSingleBlock
|
||||
*
|
||||
*
|
||||
*******************************************************************************/
|
||||
uint8_t SD_WriteBlock(uint32_t sector, uint8_t *data, uint32_t num)
|
||||
{
|
||||
uint8_t rx;
|
||||
uint8_t t_0xFF;
|
||||
|
||||
/* sector to byte */
|
||||
if (SD_CardInfo.CardType != SD_TYPE_V2HC){
|
||||
sector = sector << 9;
|
||||
}
|
||||
|
||||
if (SD_GetResponse(0xFF)){
|
||||
return 1;
|
||||
}
|
||||
if (num == 1){
|
||||
rx = SD_SendCommand(CMD24, sector, 1);
|
||||
if (rx)
|
||||
{
|
||||
MSG("SD CMD24 err:%d\r\n", rx);
|
||||
return rx;
|
||||
}
|
||||
SPI_CS_WriteBit(0);
|
||||
rx = SD_SendBlock(data, 0xFE);
|
||||
if (rx)
|
||||
{
|
||||
MSG("write err\r\n");
|
||||
SPI_CS_WriteBit(0);
|
||||
return rx;
|
||||
}
|
||||
}
|
||||
else if (num > 1){
|
||||
if (SD_CardInfo.CardType != SD_TYPE_MMC)
|
||||
{
|
||||
rx = SD_SendCommand(CMD55, 0, 1);
|
||||
if (rx == 0)
|
||||
rx = SD_SendCommand(ACMD23, num, 1);
|
||||
if (rx != 0)
|
||||
{
|
||||
MSG("SD ACMD23 err:%d\r\n", rx);
|
||||
return rx;
|
||||
}
|
||||
}
|
||||
rx = SD_SendCommand(CMD25, sector, 1);
|
||||
if (rx != 0)
|
||||
{
|
||||
MSG("SD ACMD25 err:%d\r\n", rx);
|
||||
return rx;
|
||||
}
|
||||
SPI_CS_WriteBit(0);
|
||||
do
|
||||
{
|
||||
rx = SD_SendBlock(data, 0xFC);
|
||||
data += 512;
|
||||
} while (--num && rx == 0);
|
||||
rx = SD_SendBlock(data, 0xFD);
|
||||
}
|
||||
SPI_CS_WriteBit(1);
|
||||
SPI_ReadWriteByte(&t_0xFF, &rx, 1);
|
||||
return 0;
|
||||
}
|
||||
/****************************************************************************/ /**
|
||||
* @brief SD init
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*******************************************************************************/
|
||||
uint8_t SD_Init(SD_CardInfoTypedef *pCardInfo)
|
||||
{
|
||||
uint8_t rx;
|
||||
uint8_t t_0xFF = 0xFF;
|
||||
//uint8_t txbuff[6];
|
||||
uint8_t rxbuff[6];
|
||||
uint16_t retry = 0,i;
|
||||
|
||||
SD_SPI_Init();
|
||||
|
||||
SPI_CS_WriteBit(1);
|
||||
/* low speed */
|
||||
SD_SPI_SetSpeed(0);
|
||||
|
||||
if (SD_Idle_Sta())
|
||||
{
|
||||
MSG("SD IDLE err:%d\r\n", rx);
|
||||
return ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
MSG("SD IDLE success\r\n");
|
||||
}
|
||||
|
||||
/* send CMD8 */
|
||||
rx = SD_SendCommand_NoDeassert(CMD8, 0x1aa, 0x87);
|
||||
/* sd card v1.0 */
|
||||
if (rx == 0x05)
|
||||
{
|
||||
|
||||
pCardInfo->CardType = SD_TYPE_V1;
|
||||
SPI_CS_WriteBit(1);
|
||||
SPI_ReadWriteByte(&t_0xFF, &rx, 1);
|
||||
/* send CMD55+CMD41 sd init */
|
||||
do
|
||||
{
|
||||
rx = SD_SendCommand(CMD55, 0, 0);
|
||||
if (rx != 0x01)
|
||||
{
|
||||
MSG("sdv1 CMD55 err:%d\r\n", rx);
|
||||
return rx;
|
||||
}
|
||||
rx = SD_SendCommand(ACMD41, 0, 0);
|
||||
retry++;
|
||||
|
||||
} while (rx != 0x00 && retry < 100);
|
||||
|
||||
/* mmc card init */
|
||||
if (retry >= 100)
|
||||
{
|
||||
retry = 0;
|
||||
do
|
||||
{
|
||||
rx = SD_SendCommand(CMD1, 0, 0);
|
||||
retry++;
|
||||
} while (rx != 0x00 && retry < 100);
|
||||
|
||||
if (retry >= 100)
|
||||
{
|
||||
MSG("sdv2 CMD1 timeout err:%d\r\n", rx);
|
||||
return ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
pCardInfo->CardType = SD_TYPE_MMC;
|
||||
}
|
||||
}
|
||||
/* high speed */
|
||||
SD_SPI_SetSpeed(1);
|
||||
SPI_ReadWriteByte(&t_0xFF, &rx, 1);
|
||||
|
||||
/* set sector size */
|
||||
rx = SD_SendCommand(CMD16, 512, 0xff);
|
||||
if (rx != 0x00)
|
||||
{
|
||||
MSG("sdv1 CMD16 err:%d\r\n", rx);
|
||||
return rx;
|
||||
}
|
||||
}
|
||||
/* sd card v2.0 */
|
||||
else if (rx == 0x01)
|
||||
{
|
||||
|
||||
SPI_ReadWriteByte(&t_0xFF, rxbuff + 0, 1);
|
||||
SPI_ReadWriteByte(&t_0xFF, rxbuff + 1, 1);
|
||||
SPI_ReadWriteByte(&t_0xFF, rxbuff + 2, 1);
|
||||
SPI_ReadWriteByte(&t_0xFF, rxbuff + 3, 1);
|
||||
|
||||
SPI_CS_WriteBit(1);
|
||||
/* next 8 clocks */
|
||||
SPI_ReadWriteByte(&t_0xFF, &rx, 1);
|
||||
/* 2.7V - 3.6V */
|
||||
if (rxbuff[2] == 0x01 && rxbuff[3] == 0xAA)
|
||||
{
|
||||
retry = 0;
|
||||
do
|
||||
{
|
||||
rx = SD_SendCommand(CMD55, 0, 0);
|
||||
if (rx != 0x01)
|
||||
{
|
||||
MSG("sdv2 CMD55 err:%d\r\n", rx);
|
||||
return rx;
|
||||
}
|
||||
rx = SD_SendCommand(ACMD41, 0x40000000, 0);
|
||||
retry++;
|
||||
if (retry > 200)
|
||||
{
|
||||
MSG("sdv2 CMD41 timeout err:%d\r\n", rx);
|
||||
return rx;
|
||||
}
|
||||
} while (rx != 0);
|
||||
/* send CMD58 */
|
||||
rx = SD_SendCommand_NoDeassert(CMD58, 0, 0);
|
||||
if (rx != 0X00)
|
||||
{
|
||||
MSG("sdv2 CMD58 err:%d\r\n", rx);
|
||||
return rx;
|
||||
}
|
||||
/* get OCR */
|
||||
SPI_ReadWriteByte(&t_0xFF, rxbuff + 0, 1);
|
||||
SPI_ReadWriteByte(&t_0xFF, rxbuff + 1, 1);
|
||||
SPI_ReadWriteByte(&t_0xFF, rxbuff + 2, 1);
|
||||
SPI_ReadWriteByte(&t_0xFF, rxbuff + 3, 1);
|
||||
|
||||
SPI_CS_WriteBit(1);
|
||||
SPI_ReadWriteByte(&t_0xFF, &rx, 1);
|
||||
/* bit32 CCS: 1-SDHC 0-SD2.0 */
|
||||
if (rxbuff[0] & 0x40)
|
||||
{
|
||||
pCardInfo->CardType = SD_TYPE_V2HC;
|
||||
MSG("sdv2hc success\r\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
pCardInfo->CardType = SD_TYPE_V2;
|
||||
MSG("sdv2.0 success\r\n");
|
||||
}
|
||||
|
||||
/* set sector size */
|
||||
rx = SD_SendCommand(CMD16, 512, 0xff);
|
||||
if (rx != 0x00)
|
||||
MSG("sdv1 CMD16 err:%d\r\n", rx);
|
||||
/* high speed */
|
||||
SD_SPI_SetSpeed(1);
|
||||
SPI_ReadWriteByte(&t_0xFF, &rx, 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
MSG("sd init success\r\n");
|
||||
|
||||
SD_Get_CardInfo(pCardInfo);
|
||||
|
||||
MSG(" sd csd:");
|
||||
for (i = 0; i < 4; i++)
|
||||
MSG("%X ", pCardInfo->SD_csd.CSD[i]);
|
||||
MSG("end\r\n sd cid:");
|
||||
for (i = 0; i < 4; i++)
|
||||
MSG("%X ", pCardInfo->SD_cid.CID[i]);
|
||||
MSG("end\r\n");
|
||||
MSG("SDHC CardBlockSize:%d Byte\r\n", (pCardInfo->CardBlockSize));
|
||||
MSG("SDHC CardCapacity:%lld MByte\r\n", (SD_CardInfo.CardCapacity/1024/1024));
|
||||
|
||||
return 0;
|
||||
}
|
149
bsp/bsp_common/spi_sd/bsp_spi_sd.h
Normal file
149
bsp/bsp_common/spi_sd/bsp_spi_sd.h
Normal file
@ -0,0 +1,149 @@
|
||||
/**
|
||||
* @file bsp_spi_sd.h
|
||||
* @brief
|
||||
*
|
||||
* Copyright (c) 2021 Bouffalolab team
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __SPI_SD_H__
|
||||
#define __SPI_SD_H__
|
||||
|
||||
#define SPI_PIN_CS GPIO_PIN_10
|
||||
|
||||
//SD传输数据结束后是否释放总线宏定义
|
||||
#define NO_RELEASE 0
|
||||
#define RELEASE 1
|
||||
// SD卡类型定义
|
||||
#define SD_TYPE_MMC 0
|
||||
#define SD_TYPE_V1 1
|
||||
#define SD_TYPE_V2 2
|
||||
#define SD_TYPE_V2HC 4
|
||||
|
||||
#define CMD0 0 // Resets the SD memory card.
|
||||
#define CMD1 1 // Sends host capacity support information and activates the card's initialization process.
|
||||
#define CMD8 8 // Sends SD Memory Card interface condition, which includes host supply voltage information and asks the card whether card supports voltage.
|
||||
#define CMD9 9 // Addressed card sends its card specific data (CSD) on the CMD line.
|
||||
#define CMD10 10 // Addressed card sends its card identification (CID) on the CMD line.
|
||||
#define CMD12 12 // Forces the card to stop transmission.
|
||||
#define CMD16 16 // Sets the block length (in bytes for SDSC) for all following block commands (read, write, lock).
|
||||
// Default block length is fixed to 512 Bytes. Not effective for SDHS and SDXC
|
||||
#define CMD17 17 // Reads single block of size selected by SET_BLOCKLEN in case of SDSC, and a block of fixed 512 bytes in case of SDHC and SDXC
|
||||
#define CMD18 18 // Continuously transfers data blocks from card to host until interrupted by STOP_TRANSMISSION command
|
||||
#define ACMD23 23 // Specify block count for CMD18 and CMD25
|
||||
#define CMD24 24 // Writes single block of size selected by SET_BLOCKLEN in case of SDSC, and a block of fixed 512 bytes in case of SDHC and SDXC.
|
||||
#define CMD25 25 // Continuously writes blocks of data until a STOP_TRANSMISSION follows.
|
||||
#define ACMD41 41 //
|
||||
#define CMD55 55 // Indicates to the card that the next command is an application specific command rather than a standard command.
|
||||
#define CMD58 58 // get OCR
|
||||
#define CMD59 59 // enable/disable crc
|
||||
|
||||
//数据写入回应字意义
|
||||
#define MSD_DATA_OK 0x05
|
||||
#define MSD_DATA_CRC_ERROR 0x0B
|
||||
#define MSD_DATA_WRITE_ERROR 0x0D
|
||||
#define MSD_DATA_OTHER_ERROR 0xFF
|
||||
//SD卡回应标记字
|
||||
#define MSD_RESPONSE_NO_ERROR 0x00 // Card state is ready
|
||||
#define MSD_IN_IDLE_STATE 0x01 // Card is in identification state
|
||||
#define MSD_ERASE_RESET 0x02 // Card is in standby state
|
||||
#define MSD_ILLEGAL_COMMAND 0x04 // Card is in transfer state
|
||||
#define MSD_COM_CRC_ERROR 0x08 // Card is sending an operation
|
||||
#define MSD_ERASE_SEQUENCE_ERROR 0x10 // Card is receiving operation information
|
||||
#define MSD_ADDRESS_ERROR 0x20 // Card is in programming state
|
||||
#define MSD_PARAMETER_ERROR 0x40 // Card is disconnected
|
||||
#define MSD_RESPONSE_FAILURE 0xFF // Card is in error state
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t CSD[16]; /*!< SD card specific data table */
|
||||
uint8_t CSDStruct; /*!< CSD structure */
|
||||
uint8_t SysSpecVersion; /*!< System specification version */
|
||||
uint8_t Reserved1; /*!< Reserved */
|
||||
uint8_t TAAC; /*!< Data read access time 1 */
|
||||
uint8_t NSAC; /*!< Data read access time 2 in CLK cycles */
|
||||
uint8_t MaxBusClkFrec; /*!< Max. bus clock frequency */
|
||||
uint16_t CardComdClasses; /*!< Card command classes */
|
||||
uint8_t RdBlockLen; /*!< Max. read data block length */
|
||||
uint8_t PartBlockRead; /*!< Partial blocks for read allowed */
|
||||
uint8_t WrBlockMisalign; /*!< Write block misalignment */
|
||||
uint8_t RdBlockMisalign; /*!< Read block misalignment */
|
||||
uint8_t DSRImpl; /*!< DSR implemented */
|
||||
uint8_t Reserved2; /*!< Reserved */
|
||||
uint32_t DeviceSize; /*!< Device Size */
|
||||
uint8_t MaxRdCurrentVDDMin; /*!< Max. read current @ VDD min */
|
||||
uint8_t MaxRdCurrentVDDMax; /*!< Max. read current @ VDD max */
|
||||
uint8_t MaxWrCurrentVDDMin; /*!< Max. write current @ VDD min */
|
||||
uint8_t MaxWrCurrentVDDMax; /*!< Max. write current @ VDD max */
|
||||
uint8_t DeviceSizeMul; /*!< Device size multiplier */
|
||||
uint8_t EraseGrSize; /*!< Erase group size */
|
||||
uint8_t EraseGrMul; /*!< Erase group size multiplier */
|
||||
uint8_t WrProtectGrSize; /*!< Write protect group size */
|
||||
uint8_t WrProtectGrEnable; /*!< Write protect group enable */
|
||||
uint8_t ManDeflECC; /*!< Manufacturer default ECC */
|
||||
uint8_t WrSpeedFact; /*!< Write speed factor */
|
||||
uint8_t MaxWrBlockLen; /*!< Max. write data block length */
|
||||
uint8_t WriteBlockPaPartial; /*!< Partial blocks for write allowed */
|
||||
uint8_t Reserved3; /*!< Reserved */
|
||||
uint8_t ContentProtectAppli; /*!< Content protection application */
|
||||
uint8_t FileFormatGrouop; /*!< File format group */
|
||||
uint8_t CopyFlag; /*!< Copy flag (OTP) */
|
||||
uint8_t PermWrProtect; /*!< Permanent write protection */
|
||||
uint8_t TempWrProtect; /*!< Temporary write protection */
|
||||
uint8_t FileFormat; /*!< File format */
|
||||
uint8_t ECC; /*!< ECC code */
|
||||
uint8_t CSD_CRC; /*!< CSD CRC */
|
||||
uint8_t Reserved4; /*!< Always 1 */
|
||||
|
||||
} SD_CSDTypedef;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t CID[16]; /*!< SD card identification number table */
|
||||
uint8_t ManufacturerID; /*!< Manufacturer ID */
|
||||
uint16_t OEM_AppliID; /*!< OEM/Application ID */
|
||||
uint32_t ProdName1; /*!< Product Name part1 */
|
||||
uint8_t ProdName2; /*!< Product Name part2 */
|
||||
uint8_t ProdRev; /*!< Product Revision */
|
||||
uint32_t ProdSN; /*!< Product Serial Number */
|
||||
uint8_t Reserved1; /*!< Reserved1 */
|
||||
uint16_t ManufactDate; /*!< Manufacturing Date */
|
||||
uint8_t CID_CRC; /*!< CID CRC */
|
||||
uint8_t Reserved2; /*!< Always 1 */
|
||||
|
||||
} SD_CIDTypedef;
|
||||
|
||||
typedef struct SD_CardInfoTypedef
|
||||
{
|
||||
SD_CSDTypedef SD_csd; /*!< SD card specific data register */
|
||||
SD_CIDTypedef SD_cid; /*!< SD card identification number register */
|
||||
uint64_t CardCapacity; /*!< Card capacity */
|
||||
uint32_t CardBlockSize; /*!< Card block size */
|
||||
uint16_t RCA; /*!< SD relative card address */
|
||||
uint8_t CardType; /*!< SD card type */
|
||||
} SD_CardInfoTypedef;
|
||||
|
||||
extern SD_CardInfoTypedef SD_CardInfo;
|
||||
|
||||
uint8_t SD_Init(SD_CardInfoTypedef *pCardInfo);
|
||||
uint8_t SD_Get_CardInfo(SD_CardInfoTypedef *pCardInfo);
|
||||
|
||||
uint8_t SD_ReadBlock(uint32_t sector, uint8_t *buffer, uint32_t num);
|
||||
uint8_t SD_WriteBlock(uint32_t sector, uint8_t *buffer, uint32_t num);
|
||||
|
||||
#endif
|
197
bsp/bsp_common/usb/uart_interface.c
Normal file
197
bsp/bsp_common/usb/uart_interface.c
Normal file
@ -0,0 +1,197 @@
|
||||
/**
|
||||
* @file uart_interface.c
|
||||
* @brief
|
||||
*
|
||||
* Copyright (c) 2021 Bouffalolab team
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "hal_gpio.h"
|
||||
#include "uart_interface.h"
|
||||
#include "hal_usb.h"
|
||||
#include "hal_dma.h"
|
||||
|
||||
#define USB_OUT_RINGBUFFER_SIZE (8 * 1024)
|
||||
#define UART_RX_RINGBUFFER_SIZE (8 * 1024)
|
||||
#define UART_TX_DMA_SIZE (4095)
|
||||
|
||||
uint8_t usb_rx_mem[USB_OUT_RINGBUFFER_SIZE] __attribute__((section(".system_ram")));
|
||||
uint8_t uart_rx_mem[UART_RX_RINGBUFFER_SIZE] __attribute__((section(".system_ram")));
|
||||
|
||||
uint8_t src_buffer[UART_TX_DMA_SIZE] __attribute__((section(".tcm_code")));
|
||||
|
||||
struct device* uart1;
|
||||
struct device* dma_ch2;
|
||||
|
||||
Ring_Buffer_Type usb_rx_rb;
|
||||
Ring_Buffer_Type uart1_rx_rb;
|
||||
|
||||
void uart_irq_callback(struct device *dev, void *args, uint32_t size, uint32_t state)
|
||||
{
|
||||
if (state == UART_EVENT_RX_FIFO)
|
||||
{
|
||||
if (size && size < Ring_Buffer_Get_Empty_Length(&uart1_rx_rb))
|
||||
{
|
||||
Ring_Buffer_Write(&uart1_rx_rb, (uint8_t *)args, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
MSG("RF\r\n");
|
||||
}
|
||||
}
|
||||
else if (state == UART_EVENT_RTO)
|
||||
{
|
||||
if (size && size < Ring_Buffer_Get_Empty_Length(&uart1_rx_rb))
|
||||
{
|
||||
Ring_Buffer_Write(&uart1_rx_rb, (uint8_t *)args, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
MSG("RTO\r\n");
|
||||
}
|
||||
}
|
||||
else if (state == UART_RX_FER_IT)
|
||||
{
|
||||
MSG("ov\r\n");
|
||||
}
|
||||
}
|
||||
void uart1_init(void)
|
||||
{
|
||||
uart_register(UART1_INDEX, "uart1", DEVICE_OFLAG_RDWR);
|
||||
uart1 = device_find("uart1");
|
||||
|
||||
if (uart1)
|
||||
{
|
||||
device_open(uart1, DEVICE_OFLAG_DMA_TX | DEVICE_OFLAG_INT_RX); //uart0 tx dma mode
|
||||
device_set_callback(uart1, uart_irq_callback);
|
||||
device_control(uart1, DEVICE_CTRL_SET_INT, (void *)(UART_RX_FIFO_IT | UART_RTO_IT | UART_RX_FER_IT));
|
||||
}
|
||||
|
||||
dma_register(DMA0_CH2_INDEX, "ch2", DEVICE_OFLAG_RDWR);
|
||||
dma_ch2 = device_find("ch2");
|
||||
if (dma_ch2)
|
||||
{
|
||||
device_open(dma_ch2, 0);
|
||||
//device_set_callback(dma_ch2, NULL);
|
||||
//device_control(dma_ch2, DEVICE_CTRL_SET_INT, NULL);
|
||||
}
|
||||
device_control(uart1, DEVICE_CTRL_UART_ATTACH_TX_DMA, dma_ch2);
|
||||
|
||||
}
|
||||
|
||||
void uart1_config(uint32_t baudrate, uart_databits_t databits, uart_parity_t parity, uart_stopbits_t stopbits)
|
||||
{
|
||||
uart_param_cfg_t cfg;
|
||||
cfg.baudrate = baudrate;
|
||||
cfg.stopbits = stopbits;
|
||||
cfg.parity = parity;
|
||||
|
||||
if (databits == 5)
|
||||
{
|
||||
cfg.databits = UART_DATA_LEN_5;
|
||||
}
|
||||
else if (databits == 6)
|
||||
{
|
||||
cfg.databits = UART_DATA_LEN_6;
|
||||
}
|
||||
else if (databits == 7)
|
||||
{
|
||||
cfg.databits = UART_DATA_LEN_7;
|
||||
}
|
||||
else if (databits == 8)
|
||||
{
|
||||
cfg.databits = UART_DATA_LEN_8;
|
||||
}
|
||||
|
||||
device_control(uart1, DEVICE_CTRL_CONFIG, &cfg);
|
||||
}
|
||||
|
||||
void uart1_dtr_init(void)
|
||||
{
|
||||
gpio_set_mode(GPIO_PIN_21, GPIO_OUTPUT_MODE);
|
||||
}
|
||||
void uart1_rts_init(void)
|
||||
{
|
||||
gpio_set_mode(GPIO_PIN_20, GPIO_OUTPUT_MODE);
|
||||
}
|
||||
void dtr_pin_set(uint8_t status)
|
||||
{
|
||||
gpio_write(GPIO_PIN_21, status);
|
||||
}
|
||||
void rts_pin_set(uint8_t status)
|
||||
{
|
||||
gpio_write(GPIO_PIN_20, status);
|
||||
}
|
||||
void ringbuffer_lock()
|
||||
{
|
||||
disable_irq();
|
||||
}
|
||||
void ringbuffer_unlock()
|
||||
{
|
||||
enable_irq();
|
||||
}
|
||||
|
||||
void uart_ringbuffer_init(void)
|
||||
{
|
||||
/* init mem for ring_buffer */
|
||||
memset(usb_rx_mem, 0, USB_OUT_RINGBUFFER_SIZE);
|
||||
memset(uart_rx_mem, 0, UART_RX_RINGBUFFER_SIZE);
|
||||
|
||||
/* init ring_buffer */
|
||||
Ring_Buffer_Init(&usb_rx_rb, usb_rx_mem, USB_OUT_RINGBUFFER_SIZE, ringbuffer_lock, ringbuffer_unlock);
|
||||
Ring_Buffer_Init(&uart1_rx_rb, uart_rx_mem, UART_RX_RINGBUFFER_SIZE, ringbuffer_lock, ringbuffer_unlock);
|
||||
}
|
||||
|
||||
static dma_control_data_t uart_dma_ctrl_cfg =
|
||||
{
|
||||
.bits.fix_cnt = 0,
|
||||
.bits.dst_min_mode = 0,
|
||||
.bits.dst_add_mode = 0,
|
||||
.bits.SI = 1,
|
||||
.bits.DI = 0,
|
||||
.bits.SWidth = DMA_TRANSFER_WIDTH_8BIT,
|
||||
.bits.DWidth = DMA_TRANSFER_WIDTH_8BIT,
|
||||
.bits.SBSize = 0,
|
||||
.bits.DBSize = 0,
|
||||
.bits.I = 0,
|
||||
.bits.TransferSize = 4095
|
||||
};
|
||||
static dma_lli_ctrl_t uart_lli_list =
|
||||
{
|
||||
.src_addr = (uint32_t)src_buffer,
|
||||
.dst_addr = DMA_ADDR_UART1_TDR,
|
||||
.nextlli = 0
|
||||
};
|
||||
|
||||
void uart_send_from_ringbuffer(void)
|
||||
{
|
||||
if (!device_control(dma_ch2, DMA_CHANNEL_GET_STATUS_CMD, NULL))
|
||||
{
|
||||
uint32_t avalibleCnt = Ring_Buffer_Read(&usb_rx_rb, src_buffer, UART_TX_DMA_SIZE);
|
||||
|
||||
if (avalibleCnt)
|
||||
{
|
||||
dma_channel_stop(dma_ch2);
|
||||
uart_dma_ctrl_cfg.bits.TransferSize = avalibleCnt;
|
||||
memcpy(&uart_lli_list.cfg, &uart_dma_ctrl_cfg, sizeof(dma_control_data_t));
|
||||
device_control(dma_ch2,DMA_CHANNEL_UPDATE_CMD,(void*)((uint32_t)&uart_lli_list));
|
||||
dma_channel_start(dma_ch2);
|
||||
//device_write(uart1, 0, src_buffer, avalibleCnt);
|
||||
}
|
||||
}
|
||||
}
|
41
bsp/bsp_common/usb/uart_interface.h
Normal file
41
bsp/bsp_common/usb/uart_interface.h
Normal file
@ -0,0 +1,41 @@
|
||||
/**
|
||||
* @file uart_interface.h
|
||||
* @brief
|
||||
*
|
||||
* Copyright (c) 2021 Bouffalolab team
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __UART_IF_H__
|
||||
#define __UART_IF_H__
|
||||
|
||||
#include "hal_uart.h"
|
||||
#include "ring_buffer.h"
|
||||
|
||||
extern Ring_Buffer_Type usb_rx_rb;
|
||||
extern Ring_Buffer_Type uart1_rx_rb;
|
||||
|
||||
void uart1_init(void);
|
||||
void uart1_config(uint32_t baudrate,uart_databits_t databits,uart_parity_t parity,uart_stopbits_t stopbits);
|
||||
void uart1_dtr_init(void);
|
||||
void uart1_rts_init(void);
|
||||
void dtr_pin_set(uint8_t status);
|
||||
void rts_pin_set(uint8_t status);
|
||||
void uart_ringbuffer_init(void);
|
||||
void uart_send_from_ringbuffer(void);
|
||||
#endif
|
116
bsp/bsp_common/usb/usb_dc.c
Normal file
116
bsp/bsp_common/usb/usb_dc.c
Normal file
@ -0,0 +1,116 @@
|
||||
/**
|
||||
* @file usb_dc.c
|
||||
* @brief
|
||||
*
|
||||
* Copyright (c) 2021 Bouffalolab team
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "hal_usb.h"
|
||||
#include "stdbool.h"
|
||||
#include "usbd_core.h"
|
||||
|
||||
struct device *usb;
|
||||
|
||||
static void usb_dc_event_callback(struct device *dev, void *args, uint32_t size, uint32_t state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case USB_DC_EVENT_ERROR:
|
||||
break;
|
||||
case USB_DC_EVENT_RESET:
|
||||
{
|
||||
struct usbd_endpoint_cfg ep_cfg[2];
|
||||
ep_cfg[0].ep_addr = USB_CONTROL_IN_EP0;
|
||||
ep_cfg[0].ep_mps = USB_CTRL_EP_MPS;
|
||||
ep_cfg[0].ep_type = USBD_EP_TYPE_BULK;
|
||||
ep_cfg[1].ep_addr = USB_CONTROL_OUT_EP0;
|
||||
ep_cfg[1].ep_mps = USB_CTRL_EP_MPS;
|
||||
ep_cfg[1].ep_type = USBD_EP_TYPE_BULK;
|
||||
usbd_ep_open(&ep_cfg[0]);
|
||||
usbd_ep_open(&ep_cfg[1]);
|
||||
usbd_set_address(0);
|
||||
|
||||
usbd_event_notify_handler(USB_EVENT_RESET,NULL);
|
||||
}
|
||||
break;
|
||||
case USB_DC_EVENT_SOF:
|
||||
break;
|
||||
case USB_DC_EVENT_SETUP_NOTIFY:
|
||||
usbd_event_notify_handler(USB_EVENT_SETUP_NOTIFY,NULL);
|
||||
break;
|
||||
case USB_DC_EVENT_EP0_IN_NOTIFY:
|
||||
usbd_event_notify_handler(USB_EVENT_EP0_IN_NOTIFY,NULL);
|
||||
break;
|
||||
case USB_DC_EVENT_EP0_OUT_NOTIFY:
|
||||
usbd_event_notify_handler(USB_EVENT_EP0_OUT_NOTIFY,NULL);
|
||||
break;
|
||||
case USB_DC_EVENT_EP_IN_NOTIFY:
|
||||
usbd_event_notify_handler(USB_EVENT_EP_IN_NOTIFY,args);
|
||||
break;
|
||||
case USB_DC_EVENT_EP_OUT_NOTIFY:
|
||||
usbd_event_notify_handler(USB_EVENT_EP_OUT_NOTIFY,args);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
struct device* usb_dc_init(void)
|
||||
{
|
||||
usb_dc_register(USB_INDEX, "usb", DEVICE_OFLAG_RDWR);
|
||||
usb = device_find("usb");
|
||||
device_set_callback(usb,usb_dc_event_callback);
|
||||
device_open(usb, 0);
|
||||
return usb;
|
||||
}
|
||||
|
||||
int usbd_set_address(const uint8_t addr)
|
||||
{
|
||||
return device_control(usb,DEVICE_CTRL_USB_DC_SET_ADDR,(void*)(uint32_t)addr);
|
||||
}
|
||||
|
||||
int usbd_ep_open(const struct usbd_endpoint_cfg *ep_cfg)
|
||||
{
|
||||
return usb_dc_ep_open(usb,(const struct usb_dc_ep_cfg*)ep_cfg);
|
||||
}
|
||||
int usbd_ep_close(const uint8_t ep)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int usbd_ep_set_stall(const uint8_t ep)
|
||||
{
|
||||
return device_control(usb,DEVICE_CTRL_USB_DC_SET_STALL,(void*)(uint32_t)ep);
|
||||
}
|
||||
int usbd_ep_clear_stall(const uint8_t ep)
|
||||
{
|
||||
return device_control(usb,DEVICE_CTRL_USB_DC_CLR_STALL,(void*)(uint32_t)ep);
|
||||
}
|
||||
int usbd_ep_is_stalled(const uint8_t ep, uint8_t *stalled)
|
||||
{
|
||||
return usb_dc_ep_is_stalled(usb,ep,stalled);
|
||||
}
|
||||
|
||||
int usbd_ep_write(const uint8_t ep, const uint8_t *data, uint32_t data_len, uint32_t *ret_bytes)
|
||||
{
|
||||
return usb_dc_ep_write(usb,ep,data,data_len,ret_bytes);
|
||||
}
|
||||
|
||||
int usbd_ep_read(const uint8_t ep, uint8_t *data, uint32_t max_data_len,uint32_t *read_bytes)
|
||||
{
|
||||
return usb_dc_ep_read(usb,ep,data,max_data_len,read_bytes);
|
||||
}
|
64
common/CMakeLists.txt
Normal file
64
common/CMakeLists.txt
Normal file
@ -0,0 +1,64 @@
|
||||
################# Add global include #################
|
||||
list(APPEND ADD_INCLUDE
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/libc/inc"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/ring_buffer"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/soft_crc"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/memheap"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/libc/inc/arm_gcc"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/libc/inc/bits"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/libc/inc/sys"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/misc"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/list"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/device"
|
||||
)
|
||||
#######################################################
|
||||
|
||||
################# Add private include #################
|
||||
# list(APPEND ADD_PRIVATE_INCLUDE
|
||||
# )
|
||||
#######################################################
|
||||
|
||||
############## Add current dir source files ###########
|
||||
file(GLOB_RECURSE sources
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/libc/src/*.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/ring_buffer/*.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/soft_crc/*.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/memheap/*.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/misc/*.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/device/*.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/partition/*.c"
|
||||
)
|
||||
|
||||
#aux_source_directory(. sources)
|
||||
list(APPEND ADD_SRCS ${sources})
|
||||
list(REMOVE_ITEM ADD_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/libc/src/strtox.c" "${CMAKE_CURRENT_SOURCE_DIR}/libc/src/atox.c")
|
||||
#######################################################
|
||||
|
||||
########### Add required/dependent components #########
|
||||
#list(APPEND ADD_REQUIREMENTS BSP_${BOARD}_Driver)
|
||||
#######################################################
|
||||
|
||||
############ Add static libs ##########################
|
||||
# if(CONFIG_COMPONENT1_INCLUDE_STATIC_LIB)
|
||||
# list(APPEND ADD_STATIC_LIB "lib/libtest.a")
|
||||
# endif()
|
||||
#######################################################
|
||||
|
||||
############ Add dynamic libs #########################
|
||||
# list(APPEND ADD_DYNAMIC_LIB "lib/arch/v831/libmaix_nn.so"
|
||||
# "lib/arch/v831/libmaix_cam.so"
|
||||
# )
|
||||
#######################################################
|
||||
|
||||
############ Add global compile option ################
|
||||
#add components denpend on this component
|
||||
# list(APPEND ADD_DEFINITIONS -D${BOARD} -DARCH_RISCV)
|
||||
#######################################################
|
||||
|
||||
############ Add private compile option ################
|
||||
#add compile option for this component that won't affect other modules
|
||||
#list(APPEND ADD_DEFINITIONS_PRIVATE -D${BOARD}_DRIVER)
|
||||
#######################################################
|
||||
|
||||
|
||||
generate_library()
|
330
common/device/drv_device.c
Normal file
330
common/device/drv_device.c
Normal file
@ -0,0 +1,330 @@
|
||||
/**
|
||||
* @file drv_device.c
|
||||
*
|
||||
* Copyright (c) 2021 Bouffalolab team
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
#include "drv_device.h"
|
||||
#include "string.h"
|
||||
|
||||
#define dev_open (dev->open)
|
||||
#define dev_close (dev->close)
|
||||
#define dev_read (dev->read)
|
||||
#define dev_write (dev->write)
|
||||
#define dev_control (dev->control)
|
||||
|
||||
dlist_t device_head = DLIST_OBJECT_INIT(device_head);
|
||||
/**
|
||||
* This function will copy string no more than n bytes.
|
||||
*
|
||||
* @param dst the string to copy
|
||||
* @param src the string to be copied
|
||||
* @param n the maximum copied length
|
||||
*
|
||||
* @return the result
|
||||
*/
|
||||
static char *device_strncpy(char *dst, const char *src, uint32_t n)
|
||||
{
|
||||
if (n != 0)
|
||||
{
|
||||
char *d = dst;
|
||||
const char *s = src;
|
||||
|
||||
do
|
||||
{
|
||||
if ((*d++ = *s++) == 0)
|
||||
{
|
||||
/* NUL pad the remaining n-1 bytes */
|
||||
while (--n != 0)
|
||||
*d++ = 0;
|
||||
break;
|
||||
}
|
||||
} while (--n != 0);
|
||||
}
|
||||
|
||||
return (dst);
|
||||
}
|
||||
/**
|
||||
* This function will compare string no more than n bytes.
|
||||
*
|
||||
* @param dst the string to copy
|
||||
* @param src the string to be copied
|
||||
* @param n the maximum copied length
|
||||
*
|
||||
* @return the result
|
||||
*/
|
||||
static int32_t device_strncmp(const char *cs, const char *ct, uint32_t count)
|
||||
{
|
||||
signed char __res = 0;
|
||||
|
||||
while (count)
|
||||
{
|
||||
if ((__res = *cs - *ct++) != 0 || !*cs++)
|
||||
break;
|
||||
count--;
|
||||
}
|
||||
|
||||
return __res;
|
||||
}
|
||||
/**
|
||||
* This function registers a device driver with specified name.
|
||||
*
|
||||
* @param dev the pointer of device driver structure
|
||||
* @param name the device driver's name
|
||||
* @param flags the capabilities flag of device
|
||||
*
|
||||
* @return the error code, DEVICE_EOK on initialization successfully.
|
||||
*/
|
||||
int device_register(struct device *dev, const char *name, uint16_t flag)
|
||||
{
|
||||
#define OBJECT_DEVICE_TYPE 0
|
||||
#define OBJECT_FLAG_DEFAULT 0
|
||||
|
||||
dlist_t *node;
|
||||
|
||||
dlist_for_each(node, &device_head)
|
||||
{
|
||||
struct device *dev_obj;
|
||||
dev_obj = dlist_entry(node, struct device, list);
|
||||
if (dev_obj == dev)
|
||||
{
|
||||
return -DEVICE_EEXIST;
|
||||
}
|
||||
}
|
||||
|
||||
dev->oflag = flag;
|
||||
device_strncpy(dev->name, name, NAME_MAX);
|
||||
|
||||
dlist_insert_after(&device_head, &(dev->list));
|
||||
dev->status = DEVICE_REGISTERED;
|
||||
return DEVICE_EOK;
|
||||
}
|
||||
/**
|
||||
* This function get device list header
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return device header
|
||||
*/
|
||||
dlist_t * device_get_list_header(void){
|
||||
return &device_head;
|
||||
}
|
||||
/**
|
||||
* This function unregisters a device driver with specified name.
|
||||
*
|
||||
* @param dev the pointer of device driver structure
|
||||
* @param name the device driver's name
|
||||
* @param flags the capabilities flag of device
|
||||
*
|
||||
* @return the error code, DEVICE_EOK on initialization successfully.
|
||||
*/
|
||||
int device_unregister(const char *name)
|
||||
{
|
||||
struct device* dev = device_find(name);
|
||||
if(!dev)
|
||||
return -DEVICE_ENODEV;
|
||||
/* remove from old list */
|
||||
dlist_remove(&(dev->list));
|
||||
return DEVICE_EOK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This function finds a device driver by specified name.
|
||||
*
|
||||
* @param name the device driver's name
|
||||
*
|
||||
* @return the registered device driver on successful, or NULL on failure.
|
||||
*/
|
||||
struct device *device_find(const char *name)
|
||||
{
|
||||
struct device *dev;
|
||||
dlist_t *node;
|
||||
|
||||
dlist_for_each(node, &device_head)
|
||||
{
|
||||
dev = dlist_entry(node, struct device, list);
|
||||
if (device_strncmp(dev->name, name, NAME_MAX) == 0)
|
||||
{
|
||||
return dev;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will open a device
|
||||
*
|
||||
* @param dev the pointer of device driver structure
|
||||
* @param oflag the flags for device open
|
||||
*
|
||||
* @return the result
|
||||
*/
|
||||
int device_open(struct device *dev, uint16_t oflag)
|
||||
{
|
||||
int retval = DEVICE_EOK;
|
||||
|
||||
if ((dev->status == DEVICE_REGISTERED) || (dev->status == DEVICE_CLOSED))
|
||||
{
|
||||
if (dev_open != NULL)
|
||||
{
|
||||
retval = dev_open(dev, oflag);
|
||||
dev->status = DEVICE_OPENED;
|
||||
dev->oflag |= oflag;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
retval = -DEVICE_EFAULT;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
/**
|
||||
* This function will close a device
|
||||
*
|
||||
* @param dev the pointer of device driver structure
|
||||
*
|
||||
* @return the result
|
||||
*/
|
||||
int device_close(struct device *dev)
|
||||
{
|
||||
int retval = DEVICE_EOK;
|
||||
|
||||
if (dev->status == DEVICE_OPENED)
|
||||
{
|
||||
if (dev_close != NULL)
|
||||
{
|
||||
retval = dev_close(dev);
|
||||
dev->status = DEVICE_CLOSED;
|
||||
dev->oflag = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
retval = -DEVICE_EFAULT;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
/**
|
||||
* This function will perform a variety of control functions on devices.
|
||||
*
|
||||
* @param dev the pointer of device driver structure
|
||||
* @param cmd the command sent to device
|
||||
* @param arg the argument of command
|
||||
*
|
||||
* @return the result
|
||||
*/
|
||||
int device_control(struct device *dev, int cmd, void *args)
|
||||
{
|
||||
int retval = DEVICE_EOK;
|
||||
|
||||
if (dev->status >= DEVICE_REGISTERED)
|
||||
{
|
||||
if (dev_control != NULL)
|
||||
{
|
||||
retval = dev_control(dev, cmd, args);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
retval = -DEVICE_EFAULT;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
/**
|
||||
* This function will write some data to a device.
|
||||
*
|
||||
* @param dev the pointer of device driver structure
|
||||
* @param pos the position of written
|
||||
* @param buffer the data buffer to be written to device
|
||||
* @param size the size of buffer
|
||||
*
|
||||
* @return the actually written size on successful, otherwise negative returned.
|
||||
*/
|
||||
int device_write(struct device *dev, uint32_t pos, const void *buffer, uint32_t size)
|
||||
{
|
||||
int retval = DEVICE_EOK;
|
||||
|
||||
if (dev->status == DEVICE_OPENED)
|
||||
{
|
||||
if (dev_write != NULL)
|
||||
{
|
||||
retval = dev_write(dev, pos, buffer, size);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
retval = -DEVICE_EFAULT;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
/**
|
||||
* This function will read some data from a device.
|
||||
*
|
||||
* @param dev the pointer of device driver structure
|
||||
* @param pos the position of reading
|
||||
* @param buffer the data buffer to save read data
|
||||
* @param size the size of buffer
|
||||
*
|
||||
* @return the actually read size on successful, otherwise negative returned.
|
||||
*/
|
||||
int device_read(struct device *dev, uint32_t pos, void *buffer, uint32_t size)
|
||||
{
|
||||
int retval = DEVICE_EOK;
|
||||
|
||||
if (dev->status == DEVICE_OPENED)
|
||||
{
|
||||
if (dev_read != NULL)
|
||||
{
|
||||
retval = dev_read(dev, pos, buffer, size);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
retval = -DEVICE_EFAULT;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
/**
|
||||
* This function will read some data from a device.
|
||||
*
|
||||
* @param dev the pointer of device driver structure
|
||||
* @param pos the position of reading
|
||||
* @param buffer the data buffer to save read data
|
||||
* @param size the size of buffer
|
||||
*
|
||||
* @return the actually read size on successful, otherwise negative returned.
|
||||
*/
|
||||
int device_set_callback(struct device *dev, void (*callback)(struct device *dev, void *args, uint32_t size, uint32_t event))
|
||||
{
|
||||
int retval = DEVICE_EOK;
|
||||
|
||||
if (dev->status > DEVICE_UNREGISTER)
|
||||
{
|
||||
if (callback != NULL)
|
||||
{
|
||||
dev->callback = callback;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
retval = -DEVICE_EFAULT;
|
||||
}
|
||||
return retval;
|
||||
}
|
129
common/device/drv_device.h
Normal file
129
common/device/drv_device.h
Normal file
@ -0,0 +1,129 @@
|
||||
/**
|
||||
* @file drv_device.h
|
||||
* @brief
|
||||
*
|
||||
* Copyright (c) 2021 Bouffalolab team
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
#ifndef __DRV_DEVICE_H__
|
||||
#define __DRV_DEVICE_H__
|
||||
|
||||
#include "drv_list.h"
|
||||
#include "bflb_platform.h"
|
||||
|
||||
#define NAME_MAX 10 /* max device name*/
|
||||
|
||||
#define DEVICE_OFLAG_RDONLY 0x1000 /* open with read only */
|
||||
#define DEVICE_OFLAG_WRONLY 0x2000 /* open with write only */
|
||||
#define DEVICE_OFLAG_RDWR 0x3000 /* open with read and write */
|
||||
|
||||
#define DEVICE_OFLAG_STREAM_TX 0x001 /* open with poll tx */
|
||||
#define DEVICE_OFLAG_STREAM_RX 0x002 /* open with poll rx */
|
||||
#define DEVICE_OFLAG_INT_TX 0x004 /* open with interrupt tx */
|
||||
#define DEVICE_OFLAG_INT_RX 0x008 /* open with interrupt rx */
|
||||
#define DEVICE_OFLAG_DMA_TX 0x010 /* open with dma tx */
|
||||
#define DEVICE_OFLAG_DMA_RX 0x020 /* open with dma rx */
|
||||
|
||||
#define DEVICE_CTRL_SET_INT 0x01 /* set interrupt */
|
||||
#define DEVICE_CTRL_CLR_INT 0x02 /* clear interrupt */
|
||||
#define DEVICE_CTRL_GET_INT 0x03 /* get interrupt status*/
|
||||
#define DEVICE_CTRL_RESUME 0x04 /* resume device */
|
||||
#define DEVICE_CTRL_SUSPEND 0x05 /* suspend device */
|
||||
#define DEVICE_CTRL_CONFIG 0x06 /* config device */
|
||||
#define DEVICE_CTRL_GET_CONFIG 0x07 /* get device configuration */
|
||||
|
||||
/*
|
||||
* POSIX Error codes
|
||||
*/
|
||||
|
||||
#define DEVICE_EOK 0
|
||||
#define DEVICE_EFAULT 14 /* Bad address */
|
||||
#define DEVICE_EEXIST 17 /* device exists */
|
||||
#define DEVICE_ENODEV 19 /* No such device */
|
||||
#define DEVICE_EINVAL 22 /* Invalid argument */
|
||||
#define DEVICE_ENOSPACE 23 /* No more Device for Allocate */
|
||||
#define __ASSERT_PRINT(fmt, ...) bflb_platform_printf(fmt, ##__VA_ARGS__)
|
||||
|
||||
#define __ASSERT_LOC(test) \
|
||||
__ASSERT_PRINT("ASSERTION FAIL [%s] @ %s:%d\n", \
|
||||
#test, \
|
||||
__FILE__, __LINE__)
|
||||
|
||||
#define DEVICE_ASSERT(test, fmt, ...) \
|
||||
do { \
|
||||
if (!(test)) { \
|
||||
__ASSERT_LOC(test); \
|
||||
__ASSERT_PRINT(fmt, ##__VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
enum device_class_type
|
||||
{
|
||||
DEVICE_CLASS_NONE = 0,
|
||||
DEVICE_CLASS_GPIO,
|
||||
DEVICE_CLASS_UART,
|
||||
DEVICE_CLASS_SPI,
|
||||
DEVICE_CLASS_I2C,
|
||||
DEVICE_CLASS_ADC,
|
||||
DEVICE_CLASS_DMA,
|
||||
DEVICE_CLASS_TIMER,
|
||||
DEVICE_CLASS_PWM,
|
||||
DEVICE_CLASS_SDIO,
|
||||
DEVICE_CLASS_USB,
|
||||
DEVICE_CLASS_I2S,
|
||||
DEVICE_CLASS_CAMERA,
|
||||
DEVICE_CLASS_SEC_HASH,
|
||||
} ;
|
||||
|
||||
enum device_status_type
|
||||
{
|
||||
DEVICE_UNREGISTER = 0,
|
||||
DEVICE_REGISTERED,
|
||||
DEVICE_OPENED,
|
||||
DEVICE_CLOSED
|
||||
} ;
|
||||
|
||||
struct device
|
||||
{
|
||||
char name[NAME_MAX]; /*name of device */
|
||||
dlist_t list; /*list node of device */
|
||||
enum device_status_type status; /*status of device */
|
||||
enum device_class_type type; /*type of device */
|
||||
uint16_t oflag; /*oflag of device */
|
||||
|
||||
int (*open)(struct device *dev, uint16_t oflag);
|
||||
int (*close)(struct device *dev);
|
||||
int (*control)(struct device *dev, int cmd, void *args);
|
||||
int (*write)(struct device *dev, uint32_t pos, const void *buffer, uint32_t size);
|
||||
int (*read)(struct device *dev, uint32_t pos, void *buffer, uint32_t size);
|
||||
void (*callback)(struct device *dev, void *args, uint32_t size, uint32_t event);
|
||||
void *handle;
|
||||
};
|
||||
|
||||
int device_register(struct device *dev, const char *name, uint16_t flag);
|
||||
int device_unregister(const char *name);
|
||||
struct device *device_find(const char *name);
|
||||
int device_open(struct device *dev, uint16_t oflag);
|
||||
int device_close(struct device *dev);
|
||||
int device_control(struct device *dev, int cmd, void *args);
|
||||
int device_write(struct device *dev, uint32_t pos, const void *buffer, uint32_t size);
|
||||
int device_read(struct device *dev, uint32_t pos, void *buffer, uint32_t size);
|
||||
int device_set_callback(struct device *dev, void (*callback)(struct device *dev, void *args, uint32_t size, uint32_t event));
|
||||
dlist_t * device_get_list_header(void);
|
||||
#endif
|
62
common/libc/LICENSE
Normal file
62
common/libc/LICENSE
Normal file
@ -0,0 +1,62 @@
|
||||
Some files are derived from files copyrighted by the Regents of The
|
||||
University of California, and are available under the following
|
||||
license:
|
||||
|
||||
Note: The advertising clause in the license appearing on BSD Unix
|
||||
files was officially rescinded by the Director of the Office of
|
||||
Technology Licensing of the University of California on July 22
|
||||
1999. He states that clause 3 is "hereby deleted in its entirety."
|
||||
|
||||
* Copyright (c)
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
|
||||
-----
|
||||
|
||||
For all remaining files, the following license applies:
|
||||
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* Any copyright notice(s) and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
8
common/libc/README
Normal file
8
common/libc/README
Normal file
@ -0,0 +1,8 @@
|
||||
This is a subset of klibc (http://www.kernel.org/pub/linux/libs/klibc/)
|
||||
which is itself a subset of standard C library functions.
|
||||
|
||||
The provided functions are those which can be safely used in the SDK
|
||||
environment.
|
||||
|
||||
The included code was extracted from klibc version 1.5.15 without any
|
||||
of the GPL licensed parts. See the LICENSE file for details.
|
28
common/libc/inc/arm_gcc/compat_attribute.h
Normal file
28
common/libc/inc/arm_gcc/compat_attribute.h
Normal file
@ -0,0 +1,28 @@
|
||||
|
||||
|
||||
|
||||
#ifndef _COMPAT_ATTRIBUTE_H_
|
||||
#define _COMPAT_ATTRIBUTE_H_
|
||||
|
||||
#define __DEPRECATED__(x) __attribute__((deprecated(x)))
|
||||
#define __PACKED__ __attribute__ ((packed))
|
||||
|
||||
#define __PACKED_START__
|
||||
#define __PACKED_END__ __PACKED__
|
||||
|
||||
#define __UNUSED__ __attribute__((unused))
|
||||
#define __MAY_ALIAS__ __attribute__((may_alias))
|
||||
|
||||
#define __ALIGNED__(y) __attribute__((aligned(y)))
|
||||
#define __SECTION__(y) __attribute__((section(#y)))
|
||||
|
||||
#define __FORCED_INLINE__ inline __attribute__((always_inline))
|
||||
#define __NOINLINE__ __attribute__((noinline))
|
||||
|
||||
#define __WEAK__ __attribute__((weak))
|
||||
#define __INTERRUPT__ __attribute__((interrupt))
|
||||
#define __USED__ __attribute__((used))
|
||||
#define __NAKED__ __attribute__((naked))
|
||||
|
||||
#define __VISIBILITY__ __attribute__((visibility("default")))
|
||||
#endif /* _COMPAT_ATTRIBUTE_H_ */
|
6
common/libc/inc/arm_gcc/compat_compiler.h
Normal file
6
common/libc/inc/arm_gcc/compat_compiler.h
Normal file
@ -0,0 +1,6 @@
|
||||
|
||||
|
||||
#ifndef _COMPAT_COMPILER_H_
|
||||
#define _COMPAT_COMPILER_H_
|
||||
#endif /* _COMPAT_COMPILER_H_ */
|
||||
|
9
common/libc/inc/arm_gcc/compat_errno.h
Normal file
9
common/libc/inc/arm_gcc/compat_errno.h
Normal file
@ -0,0 +1,9 @@
|
||||
|
||||
|
||||
#ifndef _COMPAT_ERRNO_H_
|
||||
#define _COMPAT_ERRNO_H_
|
||||
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#endif /* _COMPAT_ERRNO_H_ */
|
6
common/libc/inc/arm_gcc/compat_param.h
Normal file
6
common/libc/inc/arm_gcc/compat_param.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef _COMPAT_PARAM_H
|
||||
#define _COMPAT_PARAM_H
|
||||
|
||||
#include <sys/param.h> /* need this to define BSD */
|
||||
|
||||
#endif /* _COMPAT_PARAM_H */
|
10
common/libc/inc/arm_gcc/compat_time.h
Normal file
10
common/libc/inc/arm_gcc/compat_time.h
Normal file
@ -0,0 +1,10 @@
|
||||
|
||||
|
||||
|
||||
#ifndef _COMPAT_TIME_H_
|
||||
#define _COMPAT_TIME_H_
|
||||
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
#endif /* _COMPAT_TIME_H_ */
|
29
common/libc/inc/bits/ctype_base.h
Normal file
29
common/libc/inc/bits/ctype_base.h
Normal file
@ -0,0 +1,29 @@
|
||||
|
||||
namespace std _GLIBCXX_VISIBILITY(default)
|
||||
{
|
||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
|
||||
/// @brief Base class for ctype.
|
||||
struct ctype_base
|
||||
{
|
||||
// Non-standard typedefs.
|
||||
typedef const int* __to_type;
|
||||
|
||||
// NB: Offsets into ctype<char>::_M_table force a particular size
|
||||
// on the mask type. Because of this, we don't use an enum.
|
||||
typedef char mask;
|
||||
static const mask upper = _U;
|
||||
static const mask lower = _L;
|
||||
static const mask alpha = _U | _L;
|
||||
static const mask digit = _N;
|
||||
static const mask xdigit = _X | _N;
|
||||
static const mask space = _S;
|
||||
static const mask print = _P | _U | _L | _N | _B;
|
||||
static const mask graph = _P | _U | _L | _N;
|
||||
static const mask cntrl = _C;
|
||||
static const mask punct = _P;
|
||||
static const mask alnum = _U | _L | _N;
|
||||
};
|
||||
|
||||
_GLIBCXX_END_NAMESPACE_VERSION
|
||||
} // namespace
|
140
common/libc/inc/ctype.h
Normal file
140
common/libc/inc/ctype.h
Normal file
@ -0,0 +1,140 @@
|
||||
/*
|
||||
* ctype.h
|
||||
*
|
||||
* This assumes ISO 8859-1, being a reasonable superset of ASCII.
|
||||
*/
|
||||
|
||||
#ifndef _CTYPE_H
|
||||
#define _CTYPE_H
|
||||
|
||||
#include <extern.h>
|
||||
#include <libc_compiler.h>
|
||||
|
||||
#define _U (1 << 0)
|
||||
#define _L (1 << 1)
|
||||
#define _N (1 << 2)
|
||||
#define _S (1 << 3)
|
||||
#define _P (1 << 4)
|
||||
#define _C (1 << 5)
|
||||
#define _X (1 << 6)
|
||||
#define _B (1 << 7)
|
||||
|
||||
/*
|
||||
* This relies on the following definitions:
|
||||
*
|
||||
* cntrl = !print
|
||||
* alpha = upper|lower
|
||||
* graph = punct|alpha|digit
|
||||
* blank = '\t' || ' ' (per POSIX requirement)
|
||||
*/
|
||||
enum {
|
||||
__ctype_upper = _U,
|
||||
__ctype_lower = _L,
|
||||
__ctype_digit = _N,
|
||||
__ctype_xdigit = _S,
|
||||
__ctype_space = _P,
|
||||
__ctype_print = _C,
|
||||
__ctype_punct = _X,
|
||||
__ctype_cntrl = _B
|
||||
};
|
||||
|
||||
__extern int isalnum(int);
|
||||
__extern int isalpha(int);
|
||||
__extern int isascii(int);
|
||||
__extern int isblank(int);
|
||||
__extern int iscntrl(int);
|
||||
__extern int isdigit(int);
|
||||
__extern int isgraph(int);
|
||||
__extern int islower(int);
|
||||
__extern int isprint(int);
|
||||
__extern int ispunct(int);
|
||||
__extern int isspace(int);
|
||||
__extern int isupper(int);
|
||||
__extern int isxdigit(int);
|
||||
__extern int toupper(int);
|
||||
__extern int tolower(int);
|
||||
|
||||
extern const unsigned char __ctypes[];
|
||||
|
||||
__must_inline int __ctype_isalnum(int __c)
|
||||
{
|
||||
return __ctypes[__c + 1] &
|
||||
(__ctype_upper | __ctype_lower | __ctype_digit);
|
||||
}
|
||||
|
||||
__must_inline int __ctype_isalpha(int __c)
|
||||
{
|
||||
return __ctypes[__c + 1] & (__ctype_upper | __ctype_lower);
|
||||
}
|
||||
|
||||
__must_inline int __ctype_isascii(int __c)
|
||||
{
|
||||
return !(__c & ~0x7f);
|
||||
}
|
||||
|
||||
__must_inline int __ctype_isblank(int __c)
|
||||
{
|
||||
return (__c == '\t') || (__c == ' ');
|
||||
}
|
||||
|
||||
__must_inline int __ctype_iscntrl(int __c)
|
||||
{
|
||||
return __ctypes[__c + 1] & __ctype_cntrl;
|
||||
}
|
||||
|
||||
__must_inline int __ctype_isdigit(int __c)
|
||||
{
|
||||
return ((unsigned)__c - '0') <= 9;
|
||||
}
|
||||
|
||||
__must_inline int __ctype_isgraph(int __c)
|
||||
{
|
||||
return __ctypes[__c + 1] &
|
||||
(__ctype_upper | __ctype_lower | __ctype_digit | __ctype_punct);
|
||||
}
|
||||
|
||||
__must_inline int __ctype_islower(int __c)
|
||||
{
|
||||
return __ctypes[__c + 1] & __ctype_lower;
|
||||
}
|
||||
|
||||
__must_inline int __ctype_isprint(int __c)
|
||||
{
|
||||
return __ctypes[__c + 1] & __ctype_print;
|
||||
}
|
||||
|
||||
__must_inline int __ctype_ispunct(int __c)
|
||||
{
|
||||
return __ctypes[__c + 1] & __ctype_punct;
|
||||
}
|
||||
|
||||
__must_inline int __ctype_isspace(int __c)
|
||||
{
|
||||
return __ctypes[__c + 1] & __ctype_space;
|
||||
}
|
||||
|
||||
__must_inline int __ctype_isupper(int __c)
|
||||
{
|
||||
return __ctypes[__c + 1] & __ctype_upper;
|
||||
}
|
||||
|
||||
__must_inline int __ctype_isxdigit(int __c)
|
||||
{
|
||||
return __ctypes[__c + 1] & __ctype_xdigit;
|
||||
}
|
||||
|
||||
/* Note: this is decimal, not hex, to avoid accidental promotion to unsigned */
|
||||
#define _toupper(__c) ((__c) & ~32)
|
||||
#define _tolower(__c) ((__c) | 32)
|
||||
|
||||
__must_inline int __ctype_toupper(int __c)
|
||||
{
|
||||
return __ctype_islower(__c) ? _toupper(__c) : __c;
|
||||
}
|
||||
|
||||
__must_inline int __ctype_tolower(int __c)
|
||||
{
|
||||
return __ctype_isupper(__c) ? _tolower(__c) : __c;
|
||||
}
|
||||
|
||||
#endif /* _CTYPE_H */
|
16
common/libc/inc/extern.h
Normal file
16
common/libc/inc/extern.h
Normal file
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* klibc/extern.h
|
||||
*/
|
||||
|
||||
#ifndef _EXTERN_H
|
||||
#define _EXTERN_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define __extern extern "C"
|
||||
#else
|
||||
#define __extern extern
|
||||
#endif
|
||||
|
||||
#define __alias(x) __attribute__((weak, alias(x)))
|
||||
|
||||
#endif /* _EXTERN_H */
|
15
common/libc/inc/fnmatch.h
Normal file
15
common/libc/inc/fnmatch.h
Normal file
@ -0,0 +1,15 @@
|
||||
#ifndef _FNMATCH_H
|
||||
#define _FNMATCH_H
|
||||
|
||||
#include <extern.h>
|
||||
|
||||
#define FNM_NOMATCH 1
|
||||
|
||||
#define FNM_PATHNAME 1
|
||||
#define FNM_FILE_NAME FNM_PATHNAME
|
||||
#define FNM_NOESCAPE 2
|
||||
#define FNM_PERIOD 4
|
||||
|
||||
__extern int fnmatch(const char *, const char *, int);
|
||||
|
||||
#endif /* _FNMATCH_H */
|
227
common/libc/inc/inttypes.h
Normal file
227
common/libc/inc/inttypes.h
Normal file
@ -0,0 +1,227 @@
|
||||
/*
|
||||
* inttypes.h
|
||||
*/
|
||||
|
||||
#ifndef _INTTYPES_H
|
||||
#define _INTTYPES_H
|
||||
|
||||
#include <extern.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <compat_compiler.h>
|
||||
|
||||
static __inline intmax_t imaxabs(intmax_t __n)
|
||||
{
|
||||
return (__n < (intmax_t) 0) ? -__n : __n;
|
||||
}
|
||||
|
||||
__extern intmax_t strtoimax(const char *, char **, int);
|
||||
__extern uintmax_t strtoumax(const char *, char **, int);
|
||||
|
||||
/* extensions */
|
||||
__extern intmax_t strntoimax(const char *, char **, int, size_t);
|
||||
__extern uintmax_t strntoumax(const char *, char **, int, size_t);
|
||||
|
||||
#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS)
|
||||
|
||||
#define PRId8 "d"
|
||||
#define PRId16 "d"
|
||||
#define PRId32 "d"
|
||||
#define PRId64 __PRI64_RANK "d"
|
||||
|
||||
#define PRIdLEAST8 "d"
|
||||
#define PRIdLEAST16 "d"
|
||||
#define PRIdLEAST32 "d"
|
||||
#define PRIdLEAST64 __PRI64_RANK "d"
|
||||
|
||||
#define PRIdFAST8 "d"
|
||||
#define PRIdFAST16 __PRIFAST_RANK "d"
|
||||
#define PRIdFAST32 __PRIFAST_RANK "d"
|
||||
#define PRIdFAST64 __PRI64_RANK "d"
|
||||
|
||||
#define PRIdMAX __PRI64_RANK "d"
|
||||
#define PRIdPTR __PRIPTR_RANK "d"
|
||||
|
||||
#define PRIi8 "i"
|
||||
#define PRIi16 "i"
|
||||
#define PRIi32 "i"
|
||||
#define PRIi64 __PRI64_RANK "i"
|
||||
|
||||
#define PRIiLEAST8 "i"
|
||||
#define PRIiLEAST16 "i"
|
||||
#define PRIiLEAST32 "i"
|
||||
#define PRIiLEAST64 __PRI64_RANK "i"
|
||||
|
||||
#define PRIiFAST8 "i"
|
||||
#define PRIiFAST16 __PRIFAST_RANK "i"
|
||||
#define PRIiFAST32 __PRIFAST_RANK "i"
|
||||
#define PRIiFAST64 __PRI64_RANK "i"
|
||||
|
||||
#define PRIiMAX __PRI64_RANK "i"
|
||||
#define PRIiPTR __PRIPTR_RANK "i"
|
||||
|
||||
#define PRIo8 "o"
|
||||
#define PRIo16 "o"
|
||||
#define PRIo32 "o"
|
||||
#define PRIo64 __PRI64_RANK "o"
|
||||
|
||||
#define PRIoLEAST8 "o"
|
||||
#define PRIoLEAST16 "o"
|
||||
#define PRIoLEAST32 "o"
|
||||
#define PRIoLEAST64 __PRI64_RANK "o"
|
||||
|
||||
#define PRIoFAST8 "o"
|
||||
#define PRIoFAST16 __PRIFAST_RANK "o"
|
||||
#define PRIoFAST32 __PRIFAST_RANK "o"
|
||||
#define PRIoFAST64 __PRI64_RANK "o"
|
||||
|
||||
#define PRIoMAX __PRI64_RANK "o"
|
||||
#define PRIoPTR __PRIPTR_RANK "o"
|
||||
|
||||
#define PRIu8 "u"
|
||||
#define PRIu16 "u"
|
||||
#define PRIu32 "u"
|
||||
#define PRIu64 __PRI64_RANK "u"
|
||||
|
||||
#define PRIuLEAST8 "u"
|
||||
#define PRIuLEAST16 "u"
|
||||
#define PRIuLEAST32 "u"
|
||||
#define PRIuLEAST64 __PRI64_RANK "u"
|
||||
|
||||
#define PRIuFAST8 "u"
|
||||
#define PRIuFAST16 __PRIFAST_RANK "u"
|
||||
#define PRIuFAST32 __PRIFAST_RANK "u"
|
||||
#define PRIuFAST64 __PRI64_RANK "u"
|
||||
|
||||
#define PRIuMAX __PRI64_RANK "u"
|
||||
#define PRIuPTR __PRIPTR_RANK "u"
|
||||
|
||||
#define PRIx8 "x"
|
||||
#define PRIx16 "x"
|
||||
#define PRIx32 "x"
|
||||
#define PRIx64 __PRI64_RANK "x"
|
||||
|
||||
#define PRIxLEAST8 "x"
|
||||
#define PRIxLEAST16 "x"
|
||||
#define PRIxLEAST32 "x"
|
||||
#define PRIxLEAST64 __PRI64_RANK "x"
|
||||
|
||||
#define PRIxFAST8 "x"
|
||||
#define PRIxFAST16 __PRIFAST_RANK "x"
|
||||
#define PRIxFAST32 __PRIFAST_RANK "x"
|
||||
#define PRIxFAST64 __PRI64_RANK "x"
|
||||
|
||||
#define PRIxMAX __PRI64_RANK "x"
|
||||
#define PRIxPTR __PRIPTR_RANK "x"
|
||||
|
||||
#define PRIX8 "X"
|
||||
#define PRIX16 "X"
|
||||
#define PRIX32 "X"
|
||||
#define PRIX64 __PRI64_RANK "X"
|
||||
|
||||
#define PRIXLEAST8 "X"
|
||||
#define PRIXLEAST16 "X"
|
||||
#define PRIXLEAST32 "X"
|
||||
#define PRIXLEAST64 __PRI64_RANK "X"
|
||||
|
||||
#define PRIXFAST8 "X"
|
||||
#define PRIXFAST16 __PRIFAST_RANK "X"
|
||||
#define PRIXFAST32 __PRIFAST_RANK "X"
|
||||
#define PRIXFAST64 __PRI64_RANK "X"
|
||||
|
||||
#define PRIXMAX __PRI64_RANK "X"
|
||||
#define PRIXPTR __PRIPTR_RANK "X"
|
||||
|
||||
#define SCNd8 "hhd"
|
||||
#define SCNd16 "hd"
|
||||
#define SCNd32 "d"
|
||||
#define SCNd64 __PRI64_RANK "d"
|
||||
|
||||
#define SCNdLEAST8 "hhd"
|
||||
#define SCNdLEAST16 "hd"
|
||||
#define SCNdLEAST32 "d"
|
||||
#define SCNdLEAST64 __PRI64_RANK "d"
|
||||
|
||||
#define SCNdFAST8 "hhd"
|
||||
#define SCNdFAST16 __PRIFAST_RANK "d"
|
||||
#define SCNdFAST32 __PRIFAST_RANK "d"
|
||||
#define SCNdFAST64 __PRI64_RANK "d"
|
||||
|
||||
#define SCNdMAX __PRI64_RANK "d"
|
||||
#define SCNdPTR __PRIPTR_RANK "d"
|
||||
|
||||
#define SCNi8 "hhi"
|
||||
#define SCNi16 "hi"
|
||||
#define SCNi32 "i"
|
||||
#define SCNi64 __PRI64_RANK "i"
|
||||
|
||||
#define SCNiLEAST8 "hhi"
|
||||
#define SCNiLEAST16 "hi"
|
||||
#define SCNiLEAST32 "i"
|
||||
#define SCNiLEAST64 __PRI64_RANK "i"
|
||||
|
||||
#define SCNiFAST8 "hhi"
|
||||
#define SCNiFAST16 __PRIFAST_RANK "i"
|
||||
#define SCNiFAST32 __PRIFAST_RANK "i"
|
||||
#define SCNiFAST64 __PRI64_RANK "i"
|
||||
|
||||
#define SCNiMAX __PRI64_RANK "i"
|
||||
#define SCNiPTR __PRIPTR_RANK "i"
|
||||
|
||||
#define SCNo8 "hho"
|
||||
#define SCNo16 "ho"
|
||||
#define SCNo32 "o"
|
||||
#define SCNo64 __PRI64_RANK "o"
|
||||
|
||||
#define SCNoLEAST8 "hho"
|
||||
#define SCNoLEAST16 "ho"
|
||||
#define SCNoLEAST32 "o"
|
||||
#define SCNoLEAST64 __PRI64_RANK "o"
|
||||
|
||||
#define SCNoFAST8 "hho"
|
||||
#define SCNoFAST16 __PRIFAST_RANK "o"
|
||||
#define SCNoFAST32 __PRIFAST_RANK "o"
|
||||
#define SCNoFAST64 __PRI64_RANK "o"
|
||||
|
||||
#define SCNoMAX __PRI64_RANK "o"
|
||||
#define SCNoPTR __PRIPTR_RANK "o"
|
||||
|
||||
#define SCNu8 "hhu"
|
||||
#define SCNu16 "hu"
|
||||
#define SCNu32 "u"
|
||||
#define SCNu64 __PRI64_RANK "u"
|
||||
|
||||
#define SCNuLEAST8 "hhu"
|
||||
#define SCNuLEAST16 "hu"
|
||||
#define SCNuLEAST32 "u"
|
||||
#define SCNuLEAST64 __PRI64_RANK "u"
|
||||
|
||||
#define SCNuFAST8 "hhu"
|
||||
#define SCNuFAST16 __PRIFAST_RANK "u"
|
||||
#define SCNuFAST32 __PRIFAST_RANK "u"
|
||||
#define SCNuFAST64 __PRI64_RANK "u"
|
||||
|
||||
#define SCNuMAX __PRI64_RANK "u"
|
||||
#define SCNuPTR __PRIPTR_RANK "u"
|
||||
|
||||
#define SCNx8 "hhx"
|
||||
#define SCNx16 "hx"
|
||||
#define SCNx32 "x"
|
||||
#define SCNx64 __PRI64_RANK "x"
|
||||
|
||||
#define SCNxLEAST8 "hhx"
|
||||
#define SCNxLEAST16 "hx"
|
||||
#define SCNxLEAST32 "x"
|
||||
#define SCNxLEAST64 __PRI64_RANK "x"
|
||||
|
||||
#define SCNxFAST8 "hhx"
|
||||
#define SCNxFAST16 __PRIFAST_RANK "x"
|
||||
#define SCNxFAST32 __PRIFAST_RANK "x"
|
||||
#define SCNxFAST64 __PRI64_RANK "x"
|
||||
|
||||
#define SCNxMAX __PRI64_RANK "x"
|
||||
#define SCNxPTR __PRIPTR_RANK "x"
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _INTTYPES_H */
|
109
common/libc/inc/libc_compiler.h
Normal file
109
common/libc/inc/libc_compiler.h
Normal file
@ -0,0 +1,109 @@
|
||||
/*
|
||||
* libc compiler.h
|
||||
*
|
||||
* Various compiler features
|
||||
*/
|
||||
|
||||
#ifndef _LIBC_COMPILER_H
|
||||
#define _LIBC_COMPILER_H
|
||||
|
||||
/* Specific calling conventions */
|
||||
/* __cdecl is used when we want varadic and non-varadic functions to have
|
||||
the same binary calling convention. */
|
||||
#ifdef __i386__
|
||||
# ifdef __GNUC__
|
||||
# define __cdecl __attribute__((cdecl,regparm(0)))
|
||||
# else
|
||||
/* Most other C compilers have __cdecl as a keyword */
|
||||
# endif
|
||||
#else
|
||||
# define __cdecl /* Meaningless on non-i386 */
|
||||
#endif
|
||||
|
||||
/* How to declare a function that *must* be inlined */
|
||||
/* Use "extern inline" even in the gcc3+ case to avoid warnings in ctype.h */
|
||||
#ifdef __GNUC__
|
||||
# if __GNUC__ >= 3
|
||||
# ifdef __GNUC_STDC_INLINE__
|
||||
# define __must_inline extern __inline__ \
|
||||
__attribute__((__gnu_inline__,__always_inline__))
|
||||
# else
|
||||
# define __must_inline extern __inline__ __attribute__((__always_inline__))
|
||||
# endif
|
||||
# else
|
||||
# define __must_inline extern __inline__
|
||||
# endif
|
||||
#else
|
||||
# define __must_inline __inline /* Just hope this works... */
|
||||
# define __inline inline
|
||||
#endif
|
||||
|
||||
/* How to declare a function that does not return */
|
||||
#ifdef __GNUC__
|
||||
# define __noreturn void __attribute__((noreturn))
|
||||
#else
|
||||
# define __noreturn void
|
||||
#endif
|
||||
|
||||
/* "const" function:
|
||||
|
||||
Many functions do not examine any values except their arguments,
|
||||
and have no effects except the return value. Basically this is
|
||||
just slightly more strict class than the `pure' attribute above,
|
||||
since function is not allowed to read global memory.
|
||||
|
||||
Note that a function that has pointer arguments and examines the
|
||||
data pointed to must _not_ be declared `const'. Likewise, a
|
||||
function that calls a non-`const' function usually must not be
|
||||
`const'. It does not make sense for a `const' function to return
|
||||
`void'.
|
||||
*/
|
||||
#ifdef __GNUC__
|
||||
# define __constfunc __attribute__((const))
|
||||
#else
|
||||
# define __constfunc
|
||||
#endif
|
||||
#undef __attribute_const__
|
||||
#define __attribute_const__ __constfunc
|
||||
|
||||
/* "pure" function:
|
||||
|
||||
Many functions have no effects except the return value and their
|
||||
return value depends only on the parameters and/or global
|
||||
variables. Such a function can be subject to common subexpression
|
||||
elimination and loop optimization just as an arithmetic operator
|
||||
would be. These functions should be declared with the attribute
|
||||
`pure'.
|
||||
*/
|
||||
#ifdef __GNUC__
|
||||
# define __purefunc __attribute__((pure))
|
||||
#else
|
||||
# define __purefunc
|
||||
#endif
|
||||
#undef __attribute_pure__
|
||||
#define __attribute_pure__ __purefunc
|
||||
|
||||
/* Format attribute */
|
||||
#ifdef __GNUC__
|
||||
# define __formatfunc(t,f,a) __attribute__((format(t,f,a)))
|
||||
#else
|
||||
# define __formatfunc(t,f,a)
|
||||
#endif
|
||||
|
||||
/* malloc() function (returns unaliased pointer) */
|
||||
#if defined(__GNUC__) && (__GNUC__ >= 3)
|
||||
# define __mallocfunc __attribute__((malloc))
|
||||
#else
|
||||
# define __mallocfunc
|
||||
#endif
|
||||
|
||||
/* likely/unlikely */
|
||||
#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95))
|
||||
# define __likely(x) __builtin_expect(!!(x), 1)
|
||||
# define __unlikely(x) __builtin_expect(!!(x), 0)
|
||||
#else
|
||||
# define __likely(x) (!!(x))
|
||||
# define __unlikely(x) (!!(x))
|
||||
#endif
|
||||
|
||||
#endif
|
53
common/libc/inc/limits.h
Normal file
53
common/libc/inc/limits.h
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* limits.h
|
||||
*/
|
||||
|
||||
#ifndef _LIMITS_H
|
||||
#define _LIMITS_H
|
||||
|
||||
#define CHAR_BIT 8
|
||||
#define SHRT_BIT 16
|
||||
#define INT_BIT 32
|
||||
#define LONGLONG_BIT 64
|
||||
|
||||
#define SCHAR_MIN (-128)
|
||||
#define SCHAR_MAX 127
|
||||
#define UCHAR_MAX 255
|
||||
|
||||
#ifdef __CHAR_UNSIGNED__
|
||||
# define CHAR_MIN 0
|
||||
# define CHAR_MAX UCHAR_MAX
|
||||
#else
|
||||
# define CHAR_MIN SCHAR_MIN
|
||||
# define CHAR_MAX SCHAR_MAX
|
||||
#endif
|
||||
|
||||
#define SHRT_MIN (-32768)
|
||||
#define SHRT_MAX 32767
|
||||
#define USHRT_MAX 65535
|
||||
|
||||
|
||||
#define INT_MIN (-2147483647-1)
|
||||
#define INT_MAX 2147483647
|
||||
#define UINT_MAX 4294967295U
|
||||
|
||||
#if __riscv_xlen == 64
|
||||
# define LONG_BIT 64
|
||||
|
||||
# define LONG_MIN (-9223372036854775807LL-1)
|
||||
# define LONG_MAX 9223372036854775807LL
|
||||
# define ULONG_MAX 18446744073709551615ULL
|
||||
#else
|
||||
# define LONG_BIT 32
|
||||
|
||||
# define LONG_MIN (-2147483647L-1)
|
||||
# define LONG_MAX 2147483647L
|
||||
# define ULONG_MAX 4294967295UL
|
||||
#endif
|
||||
|
||||
#define LONGLONG_MIN (-9223372036854775807LL-1)
|
||||
#define LONGLONG_MAX 9223372036854775807LL
|
||||
#define ULONGLONG_MAX 18446744073709551615ULL
|
||||
|
||||
|
||||
#endif /* _LIMITS_H */
|
14
common/libc/inc/stdarg.h
Normal file
14
common/libc/inc/stdarg.h
Normal file
@ -0,0 +1,14 @@
|
||||
/*
|
||||
* stdarg.h
|
||||
*
|
||||
* This is just a wrapper for the gcc one, but defines va_copy()
|
||||
* even if gcc doesn't.
|
||||
*/
|
||||
|
||||
/* Note: the _STDARG_H macro belongs to the gcc header... */
|
||||
#include_next <stdarg.h>
|
||||
|
||||
/* Older gcc considers this an extension, so it's double underbar only */
|
||||
#ifndef va_copy
|
||||
#define va_copy(d,s) __va_copy(d,s)
|
||||
#endif
|
14
common/libc/inc/stdbool.h
Normal file
14
common/libc/inc/stdbool.h
Normal file
@ -0,0 +1,14 @@
|
||||
/*
|
||||
* stdbool.h
|
||||
*/
|
||||
|
||||
#ifndef _STDBOOL_H
|
||||
#define _STDBOOL_H
|
||||
|
||||
#ifndef __cplusplus
|
||||
#define bool _Bool
|
||||
#define true 1
|
||||
#define false 0
|
||||
#endif
|
||||
|
||||
#endif /* _STDBOOL_H */
|
29
common/libc/inc/stddef.h
Normal file
29
common/libc/inc/stddef.h
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* stddef.h
|
||||
*/
|
||||
|
||||
#ifndef _STDDEF_H
|
||||
#define _STDDEF_H
|
||||
|
||||
#define _SIZE_T
|
||||
typedef unsigned long size_t;
|
||||
|
||||
#define _PTRDIFF_T
|
||||
typedef signed int ptrdiff_t;
|
||||
|
||||
#ifndef __ICCARM__
|
||||
#define _WINT_T
|
||||
typedef signed int wint_t;
|
||||
#endif
|
||||
|
||||
#undef NULL
|
||||
#ifdef __cplusplus
|
||||
# define NULL 0
|
||||
#else
|
||||
# define NULL ((void *)0)
|
||||
#endif
|
||||
|
||||
#undef offsetof
|
||||
#define offsetof(t,m) ((size_t)&((t *)0)->m)
|
||||
|
||||
#endif /* _STDDEF_H */
|
163
common/libc/inc/stdint.h
Normal file
163
common/libc/inc/stdint.h
Normal file
@ -0,0 +1,163 @@
|
||||
/*
|
||||
* stdint.h
|
||||
*/
|
||||
|
||||
#ifndef _STDINT_H
|
||||
#define _STDINT_H
|
||||
|
||||
typedef signed char int8_t;
|
||||
typedef short int int16_t;
|
||||
typedef int int32_t;
|
||||
typedef long long int int64_t;
|
||||
|
||||
typedef unsigned char uint8_t;
|
||||
typedef unsigned short int uint16_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef unsigned long long int uint64_t;
|
||||
|
||||
typedef int int_fast16_t;
|
||||
typedef int int_fast32_t;
|
||||
|
||||
typedef unsigned int uint_fast16_t;
|
||||
typedef unsigned int uint_fast32_t;
|
||||
|
||||
#if __riscv_xlen == 32
|
||||
typedef int intptr_t;
|
||||
typedef unsigned int uintptr_t;
|
||||
|
||||
#define __INT64_C(c) c ## LL
|
||||
#define __UINT64_C(c) c ## ULL
|
||||
#elif __riscv_xlen == 64
|
||||
typedef long long intptr_t;
|
||||
typedef unsigned long long uintptr_t;
|
||||
#else
|
||||
# error "unsupported __riscv_xlen"
|
||||
#endif
|
||||
|
||||
#define __PRI64_RANK "ll"
|
||||
#define __PRIFAST_RANK ""
|
||||
#define __PRIPTR_RANK ""
|
||||
typedef int8_t int_least8_t;
|
||||
typedef int16_t int_least16_t;
|
||||
typedef int32_t int_least32_t;
|
||||
typedef int64_t int_least64_t;
|
||||
|
||||
typedef uint8_t uint_least8_t;
|
||||
typedef uint16_t uint_least16_t;
|
||||
typedef uint32_t uint_least32_t;
|
||||
typedef uint64_t uint_least64_t;
|
||||
|
||||
typedef int8_t int_fast8_t;
|
||||
typedef int64_t int_fast64_t;
|
||||
|
||||
typedef uint8_t uint_fast8_t;
|
||||
typedef uint64_t uint_fast64_t;
|
||||
|
||||
typedef int64_t intmax_t;
|
||||
typedef uint64_t uintmax_t;
|
||||
|
||||
#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
|
||||
|
||||
#define INT8_MIN (-128)
|
||||
#define INT16_MIN (-32768)
|
||||
#define INT32_MIN (-2147483647-1)
|
||||
#define INT64_MIN (__INT64_C(-9223372036854775807)-1)
|
||||
|
||||
#define INT8_MAX (127)
|
||||
#define INT16_MAX (32767)
|
||||
#define INT32_MAX (2147483647)
|
||||
#define INT64_MAX (__INT64_C(9223372036854775807))
|
||||
|
||||
#define UINT8_MAX (255U)
|
||||
#define UINT16_MAX (65535U)
|
||||
#define UINT32_MAX (4294967295U)
|
||||
#define UINT64_MAX (__UINT64_C(18446744073709551615))
|
||||
|
||||
#define INT_LEAST8_MIN INT8_MIN
|
||||
#define INT_LEAST16_MIN INT16_MIN
|
||||
#define INT_LEAST32_MIN INT32_MIN
|
||||
#define INT_LEAST64_MIN INT64_MIN
|
||||
|
||||
#define INT_LEAST8_MAX INT8_MAX
|
||||
#define INT_LEAST16_MAX INT16_MAX
|
||||
#define INT_LEAST32_MAX INT32_MAX
|
||||
#define INT_LEAST64_MAX INT64_MAX
|
||||
|
||||
#define UINT_LEAST8_MAX UINT8_MAX
|
||||
#define UINT_LEAST16_MAX UINT16_MAX
|
||||
#define UINT_LEAST32_MAX UINT32_MAX
|
||||
#define UINT_LEAST64_MAX UINT64_MAX
|
||||
|
||||
#define INT_FAST8_MIN INT8_MIN
|
||||
#define INT_FAST64_MIN INT64_MIN
|
||||
|
||||
#define INT_FAST8_MAX INT8_MAX
|
||||
#define INT_FAST64_MAX INT64_MAX
|
||||
|
||||
#define UINT_FAST8_MAX UINT8_MAX
|
||||
#define UINT_FAST64_MAX UINT64_MAX
|
||||
|
||||
#define INTMAX_MIN INT64_MIN
|
||||
#define INTMAX_MAX INT64_MAX
|
||||
#define UINTMAX_MAX UINT64_MAX
|
||||
|
||||
#define INT_FAST16_MIN INT32_MIN
|
||||
#define INT_FAST32_MIN INT32_MIN
|
||||
#define INT_FAST16_MAX INT32_MAX
|
||||
#define INT_FAST32_MAX INT32_MAX
|
||||
#define UINT_FAST16_MAX UINT32_MAX
|
||||
#define UINT_FAST32_MAX UINT32_MAX
|
||||
|
||||
#define INTPTR_MIN INT32_MIN
|
||||
#define INTPTR_MAX INT32_MAX
|
||||
#define UINTPTR_MAX UINT32_MAX
|
||||
|
||||
#define PTRDIFF_MIN INT32_MIN
|
||||
#define PTRDIFF_MAX INT32_MAX
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
|
||||
|
||||
#define INT8_C(c) c
|
||||
#define INT16_C(c) c
|
||||
#define INT32_C(c) c
|
||||
#define INT64_C(c) __INT64_C(c)
|
||||
|
||||
#define UINT8_C(c) c ## U
|
||||
#define UINT16_C(c) c ## U
|
||||
#define UINT32_C(c) c ## U
|
||||
#define UINT64_C(c) __UINT64_C(c)
|
||||
|
||||
#define INT_LEAST8_C(c) INT8_C(c)
|
||||
#define INT_LEAST16_C(c) INT16_C(c)
|
||||
#define INT_LEAST32_C(c) INT32_C(c)
|
||||
#define INT_LEAST64_C(c) INT64_C(c)
|
||||
|
||||
#define UINT_LEAST8_C(c) UINT8_C(c)
|
||||
#define UINT_LEAST16_C(c) UINT16_C(c)
|
||||
#define UINT_LEAST32_C(c) UINT32_C(c)
|
||||
#define UINT_LEAST64_C(c) UINT64_C(c)
|
||||
|
||||
#define INT_FAST8_C(c) INT8_C(c)
|
||||
#define INT_FAST64_C(c) INT64_C(c)
|
||||
|
||||
#define UINT_FAST8_C(c) UINT8_C(c)
|
||||
#define UINT_FAST64_C(c) UINT64_C(c)
|
||||
|
||||
#define INTMAX_C(c) INT64_C(c)
|
||||
#define UINTMAX_C(c) UINT64_C(c)
|
||||
|
||||
#define INT_FAST16_C(c) INT32_C(c)
|
||||
#define INT_FAST32_C(c) INT32_C(c)
|
||||
|
||||
#define UINT_FAST16_C(c) UINT32_C(c)
|
||||
#define UINT_FAST32_C(c) UINT32_C(c)
|
||||
|
||||
#define INTPTR_C(c) INT32_C(c)
|
||||
#define UINTPTR_C(c) UINT32_C(c)
|
||||
#define PTRDIFF_C(c) INT32_C(c)
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _STDINT_H */
|
24
common/libc/inc/stdio.h
Normal file
24
common/libc/inc/stdio.h
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* stdio.h
|
||||
*/
|
||||
|
||||
#ifndef _STDIO_H
|
||||
#define _STDIO_H
|
||||
|
||||
#include <extern.h>
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
|
||||
/* The actual IO functions are not included. */
|
||||
#if __riscv_xlen == 64
|
||||
# include_next <stdio.h>
|
||||
#else
|
||||
__extern int sprintf(char *, const char *, ...);
|
||||
__extern int vsprintf(char *, const char *, va_list);
|
||||
__extern int snprintf(char *__restrict, size_t, const char *__restrict, ...);
|
||||
__extern int vsnprintf(char *, size_t, const char *, va_list);
|
||||
__extern int sscanf(const char *, const char *, ...);
|
||||
__extern int vsscanf(const char *, const char *, va_list);
|
||||
#endif /* __riscv_xlen == 64 */
|
||||
|
||||
#endif /* _STDIO_H */
|
62
common/libc/inc/stdlib.h
Normal file
62
common/libc/inc/stdlib.h
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* stdlib.h
|
||||
*/
|
||||
|
||||
#ifndef _STDLIB_H
|
||||
#define _STDLIB_H
|
||||
|
||||
#include <extern.h>
|
||||
#include <libc_compiler.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#define EXIT_FAILURE 1
|
||||
#define EXIT_SUCCESS 0
|
||||
|
||||
static __inline int abs(int __n)
|
||||
{
|
||||
return (__n < 0) ? -__n : __n;
|
||||
}
|
||||
|
||||
#if __riscv_xlen == 64
|
||||
# include_next <stdio.h>
|
||||
__extern long jrand48(unsigned short *);
|
||||
#else
|
||||
__extern int atoi(const char *);
|
||||
__extern double atof(const char *);
|
||||
__extern long atol(const char *);
|
||||
__extern long long atoll(const char *);
|
||||
static __inline long labs(long __n)
|
||||
{
|
||||
return (__n < 0L) ? -__n : __n;
|
||||
}
|
||||
|
||||
static __inline long long llabs(long long __n)
|
||||
{
|
||||
return (__n < 0LL) ? -__n : __n;
|
||||
}
|
||||
|
||||
__extern long strtol(const char *, char **, int);
|
||||
__extern long long strtoll(const char *, char **, int);
|
||||
__extern unsigned long strtoul(const char *, char **, int);
|
||||
__extern unsigned long long strtoull(const char *, char **, int);
|
||||
|
||||
typedef int (*__comparefunc_t) (const void *, const void *);
|
||||
__extern void *bsearch(const void *, const void *, size_t, size_t,
|
||||
__comparefunc_t);
|
||||
__extern void qsort(void *, size_t, size_t, __comparefunc_t);
|
||||
|
||||
__extern long jrand48(unsigned short *);
|
||||
__extern long mrand48(void);
|
||||
__extern long nrand48(unsigned short *);
|
||||
__extern long lrand48(void);
|
||||
__extern unsigned short *seed48(unsigned short *);
|
||||
__extern void srand48(long);
|
||||
|
||||
#define RAND_MAX 0x7fffffff
|
||||
__extern int rand(void);
|
||||
__extern void srand(unsigned int __s);
|
||||
__extern long random(void);
|
||||
__extern void srandom(unsigned int __s);
|
||||
#endif /* __riscv_xlen == 64 */
|
||||
|
||||
#endif /* _STDLIB_H */
|
52
common/libc/inc/string.h
Normal file
52
common/libc/inc/string.h
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* string.h
|
||||
*/
|
||||
|
||||
#ifndef _STRING_H
|
||||
#define _STRING_H
|
||||
|
||||
#include <extern.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#if __riscv_xlen == 64
|
||||
__extern void memswap(void *m1, void *m2, size_t n);
|
||||
__extern void *memmem(const void *haystack, size_t n, const void *needle, size_t m);
|
||||
__extern char *strtok_r(char *, const char *, char **);
|
||||
__extern char *strsep(char **, const char *);
|
||||
# include_next <string.h>
|
||||
#else
|
||||
__extern void *memccpy(void *, const void *, int, size_t);
|
||||
__extern void *memchr(const void *, int, size_t);
|
||||
__extern void *memrchr(const void *, int, size_t);
|
||||
__extern int memcmp(const void *, const void *, size_t);
|
||||
__extern void *memcpy(void *, const void *, size_t);
|
||||
__extern void *memmove(void *, const void *, size_t);
|
||||
__extern void *memset(void *, int, size_t);
|
||||
__extern void *memmem(const void *, size_t, const void *, size_t);
|
||||
__extern void memswap(void *, void *, size_t);
|
||||
__extern void bzero(void *, size_t);
|
||||
__extern int strcasecmp(const char *, const char *);
|
||||
__extern int strncasecmp(const char *, const char *, size_t);
|
||||
__extern char *strcat(char *, const char *);
|
||||
__extern char *strchr(const char *, int);
|
||||
__extern char *strrchr(const char *, int);
|
||||
__extern int strcmp(const char *, const char *);
|
||||
__extern char *strcpy(char *, const char *);
|
||||
__extern size_t strcspn(const char *, const char *);
|
||||
__extern size_t strlen(const char *);
|
||||
__extern size_t strnlen(const char *, size_t);
|
||||
__extern char *strncat(char *, const char *, size_t);
|
||||
__extern size_t strlcat(char *, const char *, size_t);
|
||||
__extern int strncmp(const char *, const char *, size_t);
|
||||
__extern char *strncpy(char *, const char *, size_t);
|
||||
__extern size_t strlcpy(char *, const char *, size_t);
|
||||
__extern char *strpbrk(const char *, const char *);
|
||||
__extern char *strsep(char **, const char *);
|
||||
__extern size_t strspn(const char *, const char *);
|
||||
__extern char *strstr(const char *, const char *);
|
||||
__extern char *strtok(char *, const char *);
|
||||
__extern char *strtok_r(char *, const char *, char **);
|
||||
char *index(const char *s, int c);
|
||||
#endif /* __riscv_xlen == 64 */
|
||||
|
||||
#endif /* _STRING_H */
|
97
common/libc/inc/sys/types.h
Normal file
97
common/libc/inc/sys/types.h
Normal file
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* sys/types.h
|
||||
*/
|
||||
|
||||
#ifndef _SYS_TYPES_H
|
||||
#define _SYS_TYPES_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define _SSIZE_T
|
||||
typedef ptrdiff_t ssize_t;
|
||||
|
||||
#undef NULL
|
||||
#if defined(__cplusplus)
|
||||
#define NULL 0
|
||||
#else
|
||||
#define NULL ((void *)0)
|
||||
#endif
|
||||
|
||||
typedef int daddr_t;
|
||||
typedef char *caddr_t;
|
||||
|
||||
/* BSD */
|
||||
typedef unsigned char u_char;
|
||||
typedef unsigned short u_short;
|
||||
typedef unsigned int u_int;
|
||||
typedef unsigned long u_long;
|
||||
|
||||
/* SysV */
|
||||
typedef unsigned char unchar;
|
||||
typedef unsigned short ushort;
|
||||
typedef unsigned int uint;
|
||||
typedef unsigned long ulong;
|
||||
|
||||
/* More BSD */
|
||||
typedef uint8_t u_int8_t;
|
||||
typedef uint16_t u_int16_t;
|
||||
typedef uint32_t u_int32_t;
|
||||
typedef uint64_t u_int64_t;
|
||||
|
||||
/* Time related */
|
||||
typedef signed int sbintime_t;
|
||||
|
||||
/* Required by cyassl build */
|
||||
typedef long off_t;
|
||||
typedef short dev_t;
|
||||
typedef unsigned short ino_t;
|
||||
typedef unsigned short nlink_t;
|
||||
typedef unsigned short uid_t;
|
||||
typedef unsigned short mode_t;
|
||||
typedef unsigned short gid_t;
|
||||
typedef signed char pid_t;
|
||||
typedef unsigned long useconds_t;
|
||||
|
||||
/*
|
||||
* Some headers seem to require this...
|
||||
*/
|
||||
#ifndef BITS_PER_LONG
|
||||
# define BITS_PER_LONG 32
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The following FD_SET macros were added to solve the issue where the
|
||||
* lwip/sockets.h saw different sys/types.h files when built, and when its
|
||||
* header files sys/sockets file was included by the SDK.
|
||||
*/
|
||||
/*
|
||||
* Select uses bit masks of file descriptors in longs.
|
||||
* These macros manipulate such bit fields (the filesystem macros use chars).
|
||||
* FD_SETSIZE may be defined by the user, but the default here
|
||||
* should be >= NOFILE (param.h).
|
||||
*/
|
||||
#ifndef FD_SET
|
||||
#ifndef FD_SETSIZE
|
||||
#define FD_SETSIZE 64
|
||||
#endif
|
||||
#define FD_SET(n, p) ((p)->fd_bits[(n)/8] |= (1 << ((n) & 7)))
|
||||
#define FD_CLR(n, p) ((p)->fd_bits[(n)/8] &= ~(1 << ((n) & 7)))
|
||||
#define FD_ISSET(n, p) ((p)->fd_bits[(n)/8] & (1 << ((n) & 7)))
|
||||
#define FD_ZERO(p) memset((void *)(p), 0, sizeof(*(p)))
|
||||
|
||||
typedef struct fd_set {
|
||||
unsigned char fd_bits[(FD_SETSIZE + 7) / 8];
|
||||
} fd_set;
|
||||
#endif /* FD_SET */
|
||||
|
||||
#ifndef __ICCARM__
|
||||
/* wmsdk: Added from sys/times.h and machine/types.h */
|
||||
#define _CLOCK_T_ unsigned long /* clock() */
|
||||
#ifndef __clock_t_defined
|
||||
typedef _CLOCK_T_ clock_t;
|
||||
#define __clock_t_defined
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* _SYS_TYPES_H */
|
102
common/libc/src/atof.c
Normal file
102
common/libc/src/atof.c
Normal file
@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Derived from:
|
||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
||||
*/
|
||||
/*
|
||||
* atof.c
|
||||
*
|
||||
* The atof() function
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <ctype.h>
|
||||
#include <inttypes.h>
|
||||
#include <string.h>
|
||||
|
||||
static inline int digitval(int ch)
|
||||
{
|
||||
if (ch >= '0' && ch <= '9') {
|
||||
return ch - '0';
|
||||
} else if (ch >= 'A' && ch <= 'Z') {
|
||||
return ch - 'A' + 10;
|
||||
} else if (ch >= 'a' && ch <= 'z') {
|
||||
return ch - 'a' + 10;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
double strntof(const char *nptr, char **endptr, int base, size_t n)
|
||||
{
|
||||
int minus = 0;
|
||||
double v = 0.0, m = 0.0, divisor = 1.0;
|
||||
int d;
|
||||
|
||||
while (n && isspace((unsigned char)*nptr)) {
|
||||
nptr++;
|
||||
n--;
|
||||
}
|
||||
|
||||
/* Single optional + or - */
|
||||
if (n) {
|
||||
char c = *nptr;
|
||||
if (c == '-' || c == '+') {
|
||||
minus = (c == '-');
|
||||
nptr++;
|
||||
n--;
|
||||
}
|
||||
}
|
||||
|
||||
if (base == 0) {
|
||||
if (n >= 2 && nptr[0] == '0' &&
|
||||
(nptr[1] == 'x' || nptr[1] == 'X')) {
|
||||
n -= 2;
|
||||
nptr += 2;
|
||||
base = 16;
|
||||
} else if (n >= 1 && nptr[0] == '0') {
|
||||
n--;
|
||||
nptr++;
|
||||
base = 8;
|
||||
} else {
|
||||
base = 10;
|
||||
}
|
||||
} else if (base == 16) {
|
||||
if (n >= 2 && nptr[0] == '0' &&
|
||||
(nptr[1] == 'x' || nptr[1] == 'X')) {
|
||||
n -= 2;
|
||||
nptr += 2;
|
||||
}
|
||||
}
|
||||
|
||||
while (n && (d = digitval(*nptr)) >= 0 && d < base) {
|
||||
v = v * base + d;
|
||||
n--;
|
||||
nptr++;
|
||||
}
|
||||
|
||||
if (*nptr == '.') {
|
||||
n--;
|
||||
nptr++;
|
||||
while (n && (d = digitval(*nptr)) >= 0 && d < base) {
|
||||
m = m * base + d;
|
||||
n--;
|
||||
nptr++;
|
||||
divisor *= 10.0;
|
||||
}
|
||||
}
|
||||
|
||||
if (endptr)
|
||||
*endptr = (char *)nptr;
|
||||
|
||||
v = v + (m / divisor);
|
||||
|
||||
return minus ? -v : v;
|
||||
}
|
||||
|
||||
|
||||
double atof(const char *nptr)
|
||||
{
|
||||
return strntof(nptr, NULL, 0, strlen(nptr));
|
||||
}
|
||||
|
7
common/libc/src/atoi.c
Normal file
7
common/libc/src/atoi.c
Normal file
@ -0,0 +1,7 @@
|
||||
/*
|
||||
* Derived from:
|
||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
||||
*/
|
||||
#define TYPE int
|
||||
#define NAME atoi
|
||||
#include "atox.c"
|
7
common/libc/src/atol.c
Normal file
7
common/libc/src/atol.c
Normal file
@ -0,0 +1,7 @@
|
||||
/*
|
||||
* Derived from:
|
||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
||||
*/
|
||||
#define TYPE long
|
||||
#define NAME atol
|
||||
#include "atox.c"
|
3
common/libc/src/atoll.c
Normal file
3
common/libc/src/atoll.c
Normal file
@ -0,0 +1,3 @@
|
||||
#define TYPE long long
|
||||
#define NAME atoll
|
||||
#include "atox.c"
|
19
common/libc/src/atox.c
Normal file
19
common/libc/src/atox.c
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Derived from:
|
||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
||||
*/
|
||||
/*
|
||||
* atox.c
|
||||
*
|
||||
* atoi(), atol(), atoll()
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
//#include <wmlibc.h>
|
||||
|
||||
TYPE NAME(const char *nptr)
|
||||
{
|
||||
return (TYPE) strntoumax(nptr, (char **)NULL, 10, ~(size_t) 0);
|
||||
}
|
31
common/libc/src/bsearch.c
Normal file
31
common/libc/src/bsearch.c
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Derived from:
|
||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
||||
*/
|
||||
/*
|
||||
* bsearch.c
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
void *bsearch(const void *key, const void *base, size_t nmemb,
|
||||
size_t size, int (*cmp) (const void *, const void *))
|
||||
{
|
||||
while (nmemb) {
|
||||
size_t mididx = nmemb / 2;
|
||||
const void *midobj = (const unsigned char *) base +
|
||||
mididx * size;
|
||||
int diff = cmp(key, midobj);
|
||||
|
||||
if (diff == 0)
|
||||
return (void *)midobj;
|
||||
|
||||
if (diff > 0) {
|
||||
base = (const unsigned char *) midobj + size;
|
||||
nmemb -= mididx + 1;
|
||||
} else
|
||||
nmemb = mididx;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
25
common/libc/src/common.c
Normal file
25
common/libc/src/common.c
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Derived from:
|
||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
||||
*/
|
||||
//#include <stdio.h>
|
||||
|
||||
void __assert_func(const char *file, int line,
|
||||
const char *func, const char *failedexpr)
|
||||
{
|
||||
#if 0
|
||||
printf("assertion \"%s\" failed: file \"%s\", line %d%s%s\n",
|
||||
failedexpr, file, line, func ? ", function: " : "",
|
||||
func ? func : "");
|
||||
|
||||
/* Ensure that nothing runs after this */
|
||||
while (1)
|
||||
;
|
||||
#endif
|
||||
}
|
||||
|
||||
float strtof(const char *nptr, char **endptr)
|
||||
{
|
||||
// printf("Float print not supported yet!\r\n");
|
||||
return 0;
|
||||
}
|
6
common/libc/src/ctype_isalnum.c
Normal file
6
common/libc/src/ctype_isalnum.c
Normal file
@ -0,0 +1,6 @@
|
||||
/*
|
||||
* Derived from:
|
||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
||||
*/
|
||||
#include "ctypefunc.h"
|
||||
CTYPEFUNC(isalnum)
|
6
common/libc/src/ctype_isalpha.c
Normal file
6
common/libc/src/ctype_isalpha.c
Normal file
@ -0,0 +1,6 @@
|
||||
/*
|
||||
* Derived from:
|
||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
||||
*/
|
||||
#include "ctypefunc.h"
|
||||
CTYPEFUNC(isalpha)
|
6
common/libc/src/ctype_isascii.c
Normal file
6
common/libc/src/ctype_isascii.c
Normal file
@ -0,0 +1,6 @@
|
||||
/*
|
||||
* Derived from:
|
||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
||||
*/
|
||||
#include "ctypefunc.h"
|
||||
CTYPEFUNC(isascii)
|
6
common/libc/src/ctype_isblank.c
Normal file
6
common/libc/src/ctype_isblank.c
Normal file
@ -0,0 +1,6 @@
|
||||
/*
|
||||
* Derived from:
|
||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
||||
*/
|
||||
#include "ctypefunc.h"
|
||||
CTYPEFUNC(isblank)
|
6
common/libc/src/ctype_iscntrl.c
Normal file
6
common/libc/src/ctype_iscntrl.c
Normal file
@ -0,0 +1,6 @@
|
||||
/*
|
||||
* Derived from:
|
||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
||||
*/
|
||||
#include "ctypefunc.h"
|
||||
CTYPEFUNC(iscntrl)
|
6
common/libc/src/ctype_isdigit.c
Normal file
6
common/libc/src/ctype_isdigit.c
Normal file
@ -0,0 +1,6 @@
|
||||
/*
|
||||
* Derived from:
|
||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
||||
*/
|
||||
#include "ctypefunc.h"
|
||||
CTYPEFUNC(isdigit)
|
6
common/libc/src/ctype_isgraph.c
Normal file
6
common/libc/src/ctype_isgraph.c
Normal file
@ -0,0 +1,6 @@
|
||||
/*
|
||||
* Derived from:
|
||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
||||
*/
|
||||
#include "ctypefunc.h"
|
||||
CTYPEFUNC(isgraph)
|
6
common/libc/src/ctype_islower.c
Normal file
6
common/libc/src/ctype_islower.c
Normal file
@ -0,0 +1,6 @@
|
||||
/*
|
||||
* Derived from:
|
||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
||||
*/
|
||||
#include "ctypefunc.h"
|
||||
CTYPEFUNC(islower)
|
6
common/libc/src/ctype_isprint.c
Normal file
6
common/libc/src/ctype_isprint.c
Normal file
@ -0,0 +1,6 @@
|
||||
/*
|
||||
* Derived from:
|
||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
||||
*/
|
||||
#include "ctypefunc.h"
|
||||
CTYPEFUNC(isprint)
|
6
common/libc/src/ctype_ispunct.c
Normal file
6
common/libc/src/ctype_ispunct.c
Normal file
@ -0,0 +1,6 @@
|
||||
/*
|
||||
* Derived from:
|
||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
||||
*/
|
||||
#include "ctypefunc.h"
|
||||
CTYPEFUNC(ispunct)
|
6
common/libc/src/ctype_isspace.c
Normal file
6
common/libc/src/ctype_isspace.c
Normal file
@ -0,0 +1,6 @@
|
||||
/*
|
||||
* Derived from:
|
||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
||||
*/
|
||||
#include "ctypefunc.h"
|
||||
CTYPEFUNC(isspace)
|
6
common/libc/src/ctype_isupper.c
Normal file
6
common/libc/src/ctype_isupper.c
Normal file
@ -0,0 +1,6 @@
|
||||
/*
|
||||
* Derived from:
|
||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
||||
*/
|
||||
#include "ctypefunc.h"
|
||||
CTYPEFUNC(isupper)
|
6
common/libc/src/ctype_isxdigit.c
Normal file
6
common/libc/src/ctype_isxdigit.c
Normal file
@ -0,0 +1,6 @@
|
||||
/*
|
||||
* Derived from:
|
||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
||||
*/
|
||||
#include "ctypefunc.h"
|
||||
CTYPEFUNC(isxdigit)
|
6
common/libc/src/ctype_tolower.c
Normal file
6
common/libc/src/ctype_tolower.c
Normal file
@ -0,0 +1,6 @@
|
||||
/*
|
||||
* Derived from:
|
||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
||||
*/
|
||||
#include "ctypefunc.h"
|
||||
CTYPEFUNC(tolower)
|
6
common/libc/src/ctype_toupper.c
Normal file
6
common/libc/src/ctype_toupper.c
Normal file
@ -0,0 +1,6 @@
|
||||
/*
|
||||
* Derived from:
|
||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
||||
*/
|
||||
#include "ctypefunc.h"
|
||||
CTYPEFUNC(toupper)
|
13
common/libc/src/ctypefunc.h
Normal file
13
common/libc/src/ctypefunc.h
Normal file
@ -0,0 +1,13 @@
|
||||
/*
|
||||
* ctype/ctype.h
|
||||
*
|
||||
* Common header for out-of-line ctype functions
|
||||
*/
|
||||
|
||||
#define __CTYPE_NO_INLINE
|
||||
#include <ctype.h>
|
||||
|
||||
#define CTYPEFUNC(X) \
|
||||
int X(int c) { \
|
||||
return __ctype_##X(c); \
|
||||
}
|
288
common/libc/src/ctypes.c
Normal file
288
common/libc/src/ctypes.c
Normal file
@ -0,0 +1,288 @@
|
||||
/*
|
||||
* Derived from:
|
||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
||||
*/
|
||||
/*
|
||||
* ctypes.c
|
||||
*
|
||||
* This is the array that defines <ctype.h> classes.
|
||||
* This assumes ISO 8859-1.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
const unsigned char __ctypes[257] = {
|
||||
0, /* EOF */
|
||||
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl | __ctype_space, /* BS */
|
||||
__ctype_cntrl | __ctype_space, /* TAB */
|
||||
__ctype_cntrl | __ctype_space, /* LF */
|
||||
__ctype_cntrl | __ctype_space, /* VT */
|
||||
__ctype_cntrl | __ctype_space, /* FF */
|
||||
__ctype_cntrl | __ctype_space, /* CR */
|
||||
__ctype_cntrl, /* control character */
|
||||
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
|
||||
__ctype_print | __ctype_space, /* space */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
|
||||
__ctype_print | __ctype_digit | __ctype_xdigit, /* digit */
|
||||
__ctype_print | __ctype_digit | __ctype_xdigit, /* digit */
|
||||
__ctype_print | __ctype_digit | __ctype_xdigit, /* digit */
|
||||
__ctype_print | __ctype_digit | __ctype_xdigit, /* digit */
|
||||
__ctype_print | __ctype_digit | __ctype_xdigit, /* digit */
|
||||
__ctype_print | __ctype_digit | __ctype_xdigit, /* digit */
|
||||
__ctype_print | __ctype_digit | __ctype_xdigit, /* digit */
|
||||
__ctype_print | __ctype_digit | __ctype_xdigit, /* digit */
|
||||
__ctype_print | __ctype_digit | __ctype_xdigit, /* digit */
|
||||
__ctype_print | __ctype_digit | __ctype_xdigit, /* digit */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_upper | __ctype_xdigit, /* A-F */
|
||||
__ctype_print | __ctype_upper | __ctype_xdigit, /* A-F */
|
||||
__ctype_print | __ctype_upper | __ctype_xdigit, /* A-F */
|
||||
__ctype_print | __ctype_upper | __ctype_xdigit, /* A-F */
|
||||
__ctype_print | __ctype_upper | __ctype_xdigit, /* A-F */
|
||||
__ctype_print | __ctype_upper | __ctype_xdigit, /* A-F */
|
||||
__ctype_print | __ctype_upper, /* G-Z */
|
||||
__ctype_print | __ctype_upper, /* G-Z */
|
||||
__ctype_print | __ctype_upper, /* G-Z */
|
||||
__ctype_print | __ctype_upper, /* G-Z */
|
||||
__ctype_print | __ctype_upper, /* G-Z */
|
||||
__ctype_print | __ctype_upper, /* G-Z */
|
||||
__ctype_print | __ctype_upper, /* G-Z */
|
||||
__ctype_print | __ctype_upper, /* G-Z */
|
||||
__ctype_print | __ctype_upper, /* G-Z */
|
||||
|
||||
__ctype_print | __ctype_upper, /* G-Z */
|
||||
__ctype_print | __ctype_upper, /* G-Z */
|
||||
__ctype_print | __ctype_upper, /* G-Z */
|
||||
__ctype_print | __ctype_upper, /* G-Z */
|
||||
__ctype_print | __ctype_upper, /* G-Z */
|
||||
__ctype_print | __ctype_upper, /* G-Z */
|
||||
__ctype_print | __ctype_upper, /* G-Z */
|
||||
__ctype_print | __ctype_upper, /* G-Z */
|
||||
__ctype_print | __ctype_upper, /* G-Z */
|
||||
__ctype_print | __ctype_upper, /* G-Z */
|
||||
__ctype_print | __ctype_upper, /* G-Z */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_lower | __ctype_xdigit, /* a-f */
|
||||
__ctype_print | __ctype_lower | __ctype_xdigit, /* a-f */
|
||||
__ctype_print | __ctype_lower | __ctype_xdigit, /* a-f */
|
||||
__ctype_print | __ctype_lower | __ctype_xdigit, /* a-f */
|
||||
__ctype_print | __ctype_lower | __ctype_xdigit, /* a-f */
|
||||
__ctype_print | __ctype_lower | __ctype_xdigit, /* a-f */
|
||||
__ctype_print | __ctype_lower, /* g-z */
|
||||
__ctype_print | __ctype_lower, /* g-z */
|
||||
__ctype_print | __ctype_lower, /* g-z */
|
||||
__ctype_print | __ctype_lower, /* g-z */
|
||||
__ctype_print | __ctype_lower, /* g-z */
|
||||
__ctype_print | __ctype_lower, /* g-z */
|
||||
__ctype_print | __ctype_lower, /* g-z */
|
||||
__ctype_print | __ctype_lower, /* g-z */
|
||||
__ctype_print | __ctype_lower, /* g-z */
|
||||
|
||||
__ctype_print | __ctype_lower, /* g-z */
|
||||
__ctype_print | __ctype_lower, /* g-z */
|
||||
__ctype_print | __ctype_lower, /* g-z */
|
||||
__ctype_print | __ctype_lower, /* g-z */
|
||||
__ctype_print | __ctype_lower, /* g-z */
|
||||
__ctype_print | __ctype_lower, /* g-z */
|
||||
__ctype_print | __ctype_lower, /* g-z */
|
||||
__ctype_print | __ctype_lower, /* g-z */
|
||||
__ctype_print | __ctype_lower, /* g-z */
|
||||
__ctype_print | __ctype_lower, /* g-z */
|
||||
__ctype_print | __ctype_lower, /* g-z */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_cntrl, /* control character */
|
||||
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
__ctype_cntrl, /* control character */
|
||||
|
||||
__ctype_print | __ctype_space, /* NBSP */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
|
||||
__ctype_print | __ctype_upper, /* upper accented */
|
||||
__ctype_print | __ctype_upper, /* upper accented */
|
||||
__ctype_print | __ctype_upper, /* upper accented */
|
||||
__ctype_print | __ctype_upper, /* upper accented */
|
||||
__ctype_print | __ctype_upper, /* upper accented */
|
||||
__ctype_print | __ctype_upper, /* upper accented */
|
||||
__ctype_print | __ctype_upper, /* upper accented */
|
||||
__ctype_print | __ctype_upper, /* upper accented */
|
||||
__ctype_print | __ctype_upper, /* upper accented */
|
||||
__ctype_print | __ctype_upper, /* upper accented */
|
||||
__ctype_print | __ctype_upper, /* upper accented */
|
||||
__ctype_print | __ctype_upper, /* upper accented */
|
||||
__ctype_print | __ctype_upper, /* upper accented */
|
||||
__ctype_print | __ctype_upper, /* upper accented */
|
||||
__ctype_print | __ctype_upper, /* upper accented */
|
||||
__ctype_print | __ctype_upper, /* upper accented */
|
||||
|
||||
__ctype_print | __ctype_upper, /* upper accented */
|
||||
__ctype_print | __ctype_upper, /* upper accented */
|
||||
__ctype_print | __ctype_upper, /* upper accented */
|
||||
__ctype_print | __ctype_upper, /* upper accented */
|
||||
__ctype_print | __ctype_upper, /* upper accented */
|
||||
__ctype_print | __ctype_upper, /* upper accented */
|
||||
__ctype_print | __ctype_upper, /* upper accented */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_upper, /* upper accented */
|
||||
__ctype_print | __ctype_upper, /* upper accented */
|
||||
__ctype_print | __ctype_upper, /* upper accented */
|
||||
__ctype_print | __ctype_upper, /* upper accented */
|
||||
__ctype_print | __ctype_upper, /* upper accented */
|
||||
__ctype_print | __ctype_upper, /* upper accented */
|
||||
__ctype_print | __ctype_upper, /* upper accented */
|
||||
__ctype_print | __ctype_lower, /* lower accented */
|
||||
|
||||
__ctype_print | __ctype_lower, /* lower accented */
|
||||
__ctype_print | __ctype_lower, /* lower accented */
|
||||
__ctype_print | __ctype_lower, /* lower accented */
|
||||
__ctype_print | __ctype_lower, /* lower accented */
|
||||
__ctype_print | __ctype_lower, /* lower accented */
|
||||
__ctype_print | __ctype_lower, /* lower accented */
|
||||
__ctype_print | __ctype_lower, /* lower accented */
|
||||
__ctype_print | __ctype_lower, /* lower accented */
|
||||
__ctype_print | __ctype_lower, /* lower accented */
|
||||
__ctype_print | __ctype_lower, /* lower accented */
|
||||
__ctype_print | __ctype_lower, /* lower accented */
|
||||
__ctype_print | __ctype_lower, /* lower accented */
|
||||
__ctype_print | __ctype_lower, /* lower accented */
|
||||
__ctype_print | __ctype_lower, /* lower accented */
|
||||
__ctype_print | __ctype_lower, /* lower accented */
|
||||
__ctype_print | __ctype_lower, /* lower accented */
|
||||
|
||||
__ctype_print | __ctype_lower, /* lower accented */
|
||||
__ctype_print | __ctype_lower, /* lower accented */
|
||||
__ctype_print | __ctype_lower, /* lower accented */
|
||||
__ctype_print | __ctype_lower, /* lower accented */
|
||||
__ctype_print | __ctype_lower, /* lower accented */
|
||||
__ctype_print | __ctype_lower, /* lower accented */
|
||||
__ctype_print | __ctype_lower, /* lower accented */
|
||||
__ctype_print | __ctype_punct, /* punctuation */
|
||||
__ctype_print | __ctype_lower, /* lower accented */
|
||||
__ctype_print | __ctype_lower, /* lower accented */
|
||||
__ctype_print | __ctype_lower, /* lower accented */
|
||||
__ctype_print | __ctype_lower, /* lower accented */
|
||||
__ctype_print | __ctype_lower, /* lower accented */
|
||||
__ctype_print | __ctype_lower, /* lower accented */
|
||||
__ctype_print | __ctype_lower, /* lower accented */
|
||||
__ctype_print | __ctype_lower, /* lower accented */
|
||||
};
|
76
common/libc/src/fnmatch.c
Normal file
76
common/libc/src/fnmatch.c
Normal file
@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Derived from:
|
||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
||||
*/
|
||||
/*
|
||||
* fnmatch.c
|
||||
*
|
||||
* Original implementation by Kay Sievers, modified by H. Peter Anvin.
|
||||
*/
|
||||
|
||||
#include <fnmatch.h>
|
||||
|
||||
int fnmatch(const char *p, const char *s, int flags)
|
||||
{
|
||||
if (flags & FNM_PATHNAME && *s == '/')
|
||||
return (*p != '/') || fnmatch(p+1, s+1, flags);
|
||||
if (flags & FNM_PERIOD && *s == '.')
|
||||
return (*p != '.') || fnmatch(p+1, s+1, flags);
|
||||
|
||||
flags &= ~FNM_PERIOD; /* Only applies at beginning */
|
||||
|
||||
if (!(flags & FNM_NOESCAPE) && *p == '\\') {
|
||||
p++;
|
||||
return (*p != *s) || fnmatch(p+1, s+1, flags);
|
||||
}
|
||||
|
||||
if (*s == '\0') {
|
||||
while (*p == '*')
|
||||
p++;
|
||||
return (*p != '\0');
|
||||
}
|
||||
|
||||
switch (*p) {
|
||||
case '[':
|
||||
{
|
||||
int not_mark = 0;
|
||||
p++;
|
||||
if (*p == '!') {
|
||||
not_mark = 1;
|
||||
p++;
|
||||
}
|
||||
while ((*p != '\0') && (*p != ']')) {
|
||||
int match = 0;
|
||||
if (p[1] == '-') {
|
||||
if ((*s >= *p) && (*s <= p[2]))
|
||||
match = 1;
|
||||
p += 3;
|
||||
} else {
|
||||
match = (*p == *s);
|
||||
p++;
|
||||
}
|
||||
if (match ^ not_mark) {
|
||||
while ((*p != '\0') && (*p != ']'))
|
||||
p++;
|
||||
if (*p == ']')
|
||||
return fnmatch(p+1, s+1, flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '*':
|
||||
if (fnmatch(p, s+1, flags))
|
||||
return fnmatch(p+1, s, flags);
|
||||
return 0;
|
||||
case '\0':
|
||||
if (*s == '\0') {
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if ((*p == *s) || (*p == '?'))
|
||||
return fnmatch(p+1, s+1, flags);
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
28
common/libc/src/jrand48.c
Normal file
28
common/libc/src/jrand48.c
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Derived from:
|
||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
||||
*/
|
||||
/*
|
||||
* jrand48.c
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
long jrand48(unsigned short xsubi[3])
|
||||
{
|
||||
uint64_t x;
|
||||
|
||||
/* The xsubi[] array is littleendian by spec */
|
||||
x = (uint64_t) (uint16_t) xsubi[0] +
|
||||
((uint64_t) (uint16_t) xsubi[1] << 16) +
|
||||
((uint64_t) (uint16_t) xsubi[2] << 32);
|
||||
|
||||
x = (0x5deece66dULL * x) + 0xb;
|
||||
|
||||
xsubi[0] = (unsigned short)(uint16_t) x;
|
||||
xsubi[1] = (unsigned short)(uint16_t) (x >> 16);
|
||||
xsubi[2] = (unsigned short)(uint16_t) (x >> 32);
|
||||
|
||||
return (long)(int32_t) (x >> 16);
|
||||
}
|
27
common/libc/src/lrand48.c
Normal file
27
common/libc/src/lrand48.c
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Derived from:
|
||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
||||
*/
|
||||
/*
|
||||
* lrand48.c
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
unsigned short __rand48_seed[3]; /* Common with mrand48.c, srand48.c */
|
||||
|
||||
long lrand48(void)
|
||||
{
|
||||
return (uint32_t) jrand48(__rand48_seed) >> 1;
|
||||
}
|
||||
|
||||
int rand(void)
|
||||
{
|
||||
return (int)lrand48();
|
||||
}
|
||||
|
||||
long random(void)
|
||||
{
|
||||
return lrand48();
|
||||
}
|
27
common/libc/src/memccpy.c
Normal file
27
common/libc/src/memccpy.c
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Derived from:
|
||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
||||
*/
|
||||
/*
|
||||
* memccpy.c
|
||||
*
|
||||
* memccpy()
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
void *memccpy(void *dst, const void *src, int c, size_t n)
|
||||
{
|
||||
char *q = (char *)dst;
|
||||
const char *p = (char *)src;
|
||||
char ch;
|
||||
|
||||
while (n--) {
|
||||
*q++ = ch = *p++;
|
||||
if (ch == (char)c)
|
||||
return q;
|
||||
}
|
||||
|
||||
return NULL; /* No instance of "c" found */
|
||||
}
|
23
common/libc/src/memchr.c
Normal file
23
common/libc/src/memchr.c
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Derived from:
|
||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
||||
*/
|
||||
/*
|
||||
* memchr.c
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
void *memchr(const void *s, int c, size_t n)
|
||||
{
|
||||
const unsigned char *sp = (unsigned char *)s;
|
||||
|
||||
while (n--) {
|
||||
if (*sp == (unsigned char)c)
|
||||
return (void *)sp;
|
||||
sp++;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
23
common/libc/src/memcmp.c
Normal file
23
common/libc/src/memcmp.c
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Derived from:
|
||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
||||
*/
|
||||
/*
|
||||
* memcmp.c
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
int memcmp(const void *s1, const void *s2, size_t n)
|
||||
{
|
||||
const unsigned char *c1 = (unsigned char *)s1, *c2 = (unsigned char *)s2;
|
||||
int d = 0;
|
||||
|
||||
while (n--) {
|
||||
d = (int)*c1++ - (int)*c2++;
|
||||
if (d)
|
||||
break;
|
||||
}
|
||||
|
||||
return d;
|
||||
}
|
16
common/libc/src/memcpy.c
Normal file
16
common/libc/src/memcpy.c
Normal file
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* memcpy.c
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
void *memcpy(void *dst, const void *src, size_t n)
|
||||
{
|
||||
const char *p = (char *)src;
|
||||
char *q = (char *)dst;
|
||||
while (n--) {
|
||||
*q++ = *p++;
|
||||
}
|
||||
return dst;
|
||||
}
|
56
common/libc/src/memmem.c
Normal file
56
common/libc/src/memmem.c
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Derived from:
|
||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
||||
*/
|
||||
/*
|
||||
* memmem.c
|
||||
*
|
||||
* Find a byte string inside a longer byte string
|
||||
*
|
||||
* This uses the "Not So Naive" algorithm, a very simple but
|
||||
* usually effective algorithm, see:
|
||||
*
|
||||
* http://www-igm.univ-mlv.fr/~lecroq/string/
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
void *memmem(const void *haystack, size_t n, const void *needle, size_t m)
|
||||
{
|
||||
const unsigned char *y = (const unsigned char *)haystack;
|
||||
const unsigned char *x = (const unsigned char *)needle;
|
||||
|
||||
size_t j, k, l;
|
||||
|
||||
if (m > n || !m || !n)
|
||||
return NULL;
|
||||
|
||||
if (1 != m) {
|
||||
if (x[0] == x[1]) {
|
||||
k = 2;
|
||||
l = 1;
|
||||
} else {
|
||||
k = 1;
|
||||
l = 2;
|
||||
}
|
||||
|
||||
j = 0;
|
||||
while (j <= n - m) {
|
||||
if (x[1] != y[j + 1]) {
|
||||
j += k;
|
||||
} else {
|
||||
if (!memcmp(x + 2, y + j + 2, m - 2)
|
||||
&& x[0] == y[j])
|
||||
return (void *)&y[j];
|
||||
j += l;
|
||||
}
|
||||
}
|
||||
} else
|
||||
do {
|
||||
if (*y == *x)
|
||||
return (void *)y;
|
||||
y++;
|
||||
} while (--n);
|
||||
|
||||
return NULL;
|
||||
}
|
23
common/libc/src/memrchr.c
Normal file
23
common/libc/src/memrchr.c
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Derived from:
|
||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
||||
*/
|
||||
/*
|
||||
* memrchr.c
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
void *memrchr(const void *s, int c, size_t n)
|
||||
{
|
||||
const unsigned char *sp = (const unsigned char *)s + n - 1;
|
||||
|
||||
while (n--) {
|
||||
if (*sp == (unsigned char)c)
|
||||
return (void *)sp;
|
||||
sp--;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
16
common/libc/src/memset.c
Normal file
16
common/libc/src/memset.c
Normal file
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* memset.c
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
void *memset(void *dst, int c, size_t n)
|
||||
{
|
||||
char *q = (char *)dst;
|
||||
while (n--) {
|
||||
*q++ = c;
|
||||
__asm volatile ("":::"memory");
|
||||
}
|
||||
return dst;
|
||||
}
|
28
common/libc/src/memswap.c
Normal file
28
common/libc/src/memswap.c
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Derived from:
|
||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
||||
*/
|
||||
/*
|
||||
* memswap()
|
||||
*
|
||||
* Swaps the contents of two nonoverlapping memory areas.
|
||||
* This really could be done faster...
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
void memswap(void *m1, void *m2, size_t n)
|
||||
{
|
||||
char *p = (char *)m1;
|
||||
char *q = (char *)m2;
|
||||
char tmp;
|
||||
|
||||
while (n--) {
|
||||
tmp = *p;
|
||||
*p = *q;
|
||||
*q = tmp;
|
||||
|
||||
p++;
|
||||
q++;
|
||||
}
|
||||
}
|
18
common/libc/src/mrand48.c
Normal file
18
common/libc/src/mrand48.c
Normal file
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Derived from:
|
||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
||||
*/
|
||||
/*
|
||||
* mrand48.c
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/* Common with lrand48.c, srand48.c */
|
||||
extern unsigned short __rand48_seed[3];
|
||||
|
||||
long mrand48(void)
|
||||
{
|
||||
return jrand48(__rand48_seed);
|
||||
}
|
15
common/libc/src/nrand48.c
Normal file
15
common/libc/src/nrand48.c
Normal file
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Derived from:
|
||||
* http://www.kernel.org/pub/linux/libs/klibc/
|
||||
*/
|
||||
/*
|
||||
* nrand48.c
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
long nrand48(unsigned short xsubi[3])
|
||||
{
|
||||
return (long)((uint32_t) jrand48(xsubi) >> 1);
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user