all
This commit is contained in:
BIN
SDCFile/.DS_Store
vendored
Normal file
BIN
SDCFile/.DS_Store
vendored
Normal file
Binary file not shown.
21
SDCFile/.ccsproject
Normal file
21
SDCFile/.ccsproject
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<?ccsproject version="1.0"?>
|
||||
<projectOptions>
|
||||
<ccsVersion value="12.3.0"/>
|
||||
<deviceVariant value="Cortex M.MSPM0G3507"/>
|
||||
<deviceFamily value="TMS470"/>
|
||||
<deviceEndianness value="little"/>
|
||||
<codegenToolVersion value="TICLANG_2.1.3.LTS"/>
|
||||
<isElfFormat value="true"/>
|
||||
<connection value="common/targetdb/connections/TIXDS110_Connection.xml"/>
|
||||
<rts value=""/>
|
||||
<createSlaveProjects value=""/>
|
||||
<ignoreDefaultDeviceSettings value="true"/>
|
||||
<ignoreDefaultCCSSettings value="true"/>
|
||||
<templateProperties value="id=gpio_toggle_output_LP_MSPM0G3507_nortos_ticlang.projectspec.gpio_toggle_output_LP_MSPM0G3507_nortos_ticlang,buildProfile=release,isHybrid=true"/>
|
||||
<sourceLookupPath value="${COM_TI_MSPM0_SDK_INSTALL_DIR}/source/ti/driverlib"/>
|
||||
<origin value="C:\ti\mspm0_sdk_1_00_01_03\examples\nortos\LP_MSPM0G3507\driverlib\gpio_toggle_output\ticlang\gpio_toggle_output_LP_MSPM0G3507_nortos_ticlang.projectspec"/>
|
||||
<filesToOpen value="gpio_toggle_output.syscfg,README.md"/>
|
||||
<isTargetManual value="false"/>
|
||||
<activeTargetConfiguration value="targetConfigs/MSPM0G3507.ccxml"/>
|
||||
</projectOptions>
|
||||
11
SDCFile/.clangd
Normal file
11
SDCFile/.clangd
Normal file
@@ -0,0 +1,11 @@
|
||||
# This is an auto-generated file - do not add it to source-control
|
||||
|
||||
CompileFlags:
|
||||
CompilationDatabase: Debug/.clangd
|
||||
|
||||
Diagnostics:
|
||||
Suppress: '*'
|
||||
|
||||
InlayHints:
|
||||
Enabled: No
|
||||
|
||||
105
SDCFile/.cproject
Normal file
105
SDCFile/.cproject
Normal file
@@ -0,0 +1,105 @@
|
||||
<?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="com.ti.ccstudio.buildDefinitions.TMS470.Debug.1353749893">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.ti.ccstudio.buildDefinitions.TMS470.Debug.1353749893" moduleId="org.eclipse.cdt.core.settings" name="Debug">
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
<extension id="com.ti.ccstudio.binaryparser.CoffParser" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="com.ti.ccs.project.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="com.ti.ccs.project.ErrorParser"/>
|
||||
<extension id="com.ti.ccs.errorparser.SysConfigErrorParser" point="com.ti.ccs.project.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="com.ti.ccs.project.ErrorParser"/>
|
||||
<extension id="com.ti.ccs.errorparser.CompilerErrorParser_TI" point="com.ti.ccs.project.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="com.ti.ccstudio.errorparser.CoffErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="com.ti.ccstudio.errorparser.SysConfigErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactExtension="out" artifactName="${ProjName}" buildProperties="" cleanCommand="${CG_CLEAN_CMD}" description="" id="com.ti.ccstudio.buildDefinitions.TMS470.Debug.1353749893" name="Debug" parent="com.ti.ccstudio.buildDefinitions.TMS470.Debug">
|
||||
<folderInfo id="com.ti.ccstudio.buildDefinitions.TMS470.Debug.1353749893." name="/" resourcePath="">
|
||||
<toolChain id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.exe.DebugToolchain.882588848" name="TI Build Tools" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.exe.DebugToolchain" targetTool="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.exe.linkerDebug.383878298">
|
||||
<option id="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS.813758439" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS" valueType="stringList">
|
||||
<listOptionValue value="DEVICE_CONFIGURATION_ID=Cortex M.MSPM0G3507"/>
|
||||
<listOptionValue value="DEVICE_CORE_ID=CORTEX_M0P"/>
|
||||
<listOptionValue value="DEVICE_ENDIANNESS=little"/>
|
||||
<listOptionValue value="OUTPUT_FORMAT=ELF"/>
|
||||
<listOptionValue value="LINKER_COMMAND_FILE=mspm0g3507.cmd"/>
|
||||
<listOptionValue value="RUNTIME_SUPPORT_LIBRARY="/>
|
||||
<listOptionValue value="CCS_MBS_VERSION=6.1.3"/>
|
||||
<listOptionValue value="PRODUCTS=MSPM0-SDK:2.9.0.01;sysconfig:1.26.0;"/>
|
||||
<listOptionValue value="PRODUCT_MACRO_IMPORTS={"sysconfig":["${SYSCONFIG_TOOL_INCLUDE_PATH}","${SYSCONFIG_TOOL_LIBRARY_PATH}","${SYSCONFIG_TOOL_LIBRARIES}","${SYSCONFIG_TOOL_SYMBOLS}","${SYSCONFIG_TOOL_SYSCONFIG_MANIFEST}"],"MSPM0-SDK":["${COM_TI_MSPM0_SDK_INCLUDE_PATH}","${COM_TI_MSPM0_SDK_LIBRARY_PATH}","${COM_TI_MSPM0_SDK_LIBRARIES}","${COM_TI_MSPM0_SDK_SYMBOLS}","${COM_TI_MSPM0_SDK_SYSCONFIG_MANIFEST}"]}"/>
|
||||
<listOptionValue value="OUTPUT_TYPE=executable"/>
|
||||
</option>
|
||||
<option id="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION.969553647" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION" value="TICLANG_4.0.4.LTS" valueType="string"/>
|
||||
<targetPlatform id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.exe.targetPlatformDebug.2053184819" name="Platform" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.exe.targetPlatformDebug"/>
|
||||
<builder buildPath="${BuildDirectory}" id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.exe.builderDebug.736083008" keepEnvironmentInBuildfile="false" name="GNU Make" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.exe.builderDebug"/>
|
||||
<tool id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.exe.compilerDebug.1149727336" name="Arm Compiler" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.exe.compilerDebug">
|
||||
<option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.MARCH.1324670395" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.MARCH" value="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.MARCH.thumbv6m" valueType="enumerated"/>
|
||||
<option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.MCPU.582574544" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.MCPU" value="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.MCPU.cortex-m0plus" valueType="enumerated"/>
|
||||
<option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.MFLOAT_ABI.1872850697" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.MFLOAT_ABI" value="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.MFLOAT_ABI.soft" valueType="enumerated"/>
|
||||
<option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.ENDIAN_NESS__BIG_LITTLE.1614976623" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.ENDIAN_NESS__BIG_LITTLE" value="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.ENDIAN_NESS__BIG_LITTLE.MLITTLE_ENDIAN" valueType="enumerated"/>
|
||||
<option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.SELECT_PROCESSOR_MODE__ARM_THUMB.2031516928" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.SELECT_PROCESSOR_MODE__ARM_THUMB" value="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.SELECT_PROCESSOR_MODE__ARM_THUMB.MTHUMB" valueType="enumerated"/>
|
||||
<option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.OPT_LEVEL.1952526887" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.OPT_LEVEL" value="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.OPT_LEVEL.0" valueType="enumerated"/>
|
||||
<option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.INCLUDE_PATH.945024160" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.INCLUDE_PATH" valueType="includePath">
|
||||
<listOptionValue value="${COM_TI_MSPM0_SDK_INCLUDE_PATH}"/>
|
||||
<listOptionValue value="${SYSCONFIG_TOOL_INCLUDE_PATH}"/>
|
||||
<listOptionValue value="${PROJECT_ROOT}"/>
|
||||
<listOptionValue value="${PROJECT_ROOT}/${ConfigName}"/>
|
||||
<listOptionValue value="${COM_TI_MSPM0_SDK_INSTALL_DIR}/source/third_party/CMSIS/Core/Include"/>
|
||||
<listOptionValue value="${COM_TI_MSPM0_SDK_INSTALL_DIR}/source"/>
|
||||
</option>
|
||||
<option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.DEFINE.1829198521" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.DEFINE" valueType="definedSymbols">
|
||||
<listOptionValue value="${COM_TI_MSPM0_SDK_SYMBOLS}"/>
|
||||
<listOptionValue value="${SYSCONFIG_TOOL_SYMBOLS}"/>
|
||||
<listOptionValue value="__MSPM0G3507__"/>
|
||||
</option>
|
||||
<option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.GENERATE_DWARF_DEBUG.1657173948" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.GENERATE_DWARF_DEBUG" value="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.GENERATE_DWARF_DEBUG.GDWARF_3" valueType="enumerated"/>
|
||||
</tool>
|
||||
<tool id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.exe.linkerDebug.383878298" name="Arm Linker" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.exe.linkerDebug">
|
||||
<option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.MAP_FILE.2068281474" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.MAP_FILE" value="${ProjName}.map" valueType="string"/>
|
||||
<option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.OUTPUT_FILE.1696978613" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.OUTPUT_FILE" value="${ProjName}.out" valueType="string"/>
|
||||
<option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.HEAP_SIZE.1400810192" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.HEAP_SIZE" value="512" valueType="string"/>
|
||||
<option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.STACK_SIZE.1448520262" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.STACK_SIZE" value="512" valueType="string"/>
|
||||
<option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.LIBRARY.896396405" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.LIBRARY" valueType="libs">
|
||||
<listOptionValue value="${COM_TI_MSPM0_SDK_LIBRARIES}"/>
|
||||
<listOptionValue value="${SYSCONFIG_TOOL_LIBRARIES}"/>
|
||||
<listOptionValue value="${COM_TI_MSPM0_SDK_INSTALL_DIR}/source/ti/driverlib/lib/ticlang/m0p/mspm0g1x0x_g3x0x/driverlib.a"/>
|
||||
<listOptionValue value="libc.a"/>
|
||||
</option>
|
||||
<option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.SEARCH_PATH.694018789" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.SEARCH_PATH" valueType="libPaths">
|
||||
<listOptionValue value="${COM_TI_MSPM0_SDK_LIBRARY_PATH}"/>
|
||||
<listOptionValue value="${SYSCONFIG_TOOL_LIBRARY_PATH}"/>
|
||||
<listOptionValue value="${PROJECT_BUILD_DIR}/syscfg"/>
|
||||
<listOptionValue value="${CG_TOOL_ROOT}/lib"/>
|
||||
</option>
|
||||
<option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.REREAD_LIBS.999670728" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.REREAD_LIBS" value="false" valueType="boolean"/>
|
||||
<option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.DIAG_WRAP.1778319960" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.DIAG_WRAP" value="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.DIAG_WRAP.off" valueType="enumerated"/>
|
||||
<option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.DISPLAY_ERROR_NUMBER.406074448" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.DISPLAY_ERROR_NUMBER" value="true" valueType="boolean"/>
|
||||
<option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.XML_LINK_INFO.671337360" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.XML_LINK_INFO" value="${ProjName}_linkInfo.xml" valueType="string"/>
|
||||
</tool>
|
||||
<tool id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.hex.1437755753" name="Arm Hex Utility" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.hex"/>
|
||||
<tool id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.objcopy.1733833299" name="Arm Objcopy Utility" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.objcopy"/>
|
||||
<tool id="com.ti.ccstudio.buildDefinitions.sysConfig.868554524" name="SysConfig" superClass="com.ti.ccstudio.buildDefinitions.sysConfig">
|
||||
<option id="com.ti.ccstudio.buildDefinitions.sysConfig.PRODUCTS.308856811" superClass="com.ti.ccstudio.buildDefinitions.sysConfig.PRODUCTS" valueType="stringList">
|
||||
<listOptionValue value="${COM_TI_MSPM0_SDK_SYSCONFIG_MANIFEST}"/>
|
||||
<listOptionValue value="${SYSCONFIG_TOOL_SYSCONFIG_MANIFEST}"/>
|
||||
</option>
|
||||
</tool>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<project id="gpio_toggle_output_LP_MSPM0G3507_nortos_ticlang.com.ti.ccstudio.buildDefinitions.TMS470.ProjectType.348798676" name="TMS470" projectType="com.ti.ccstudio.buildDefinitions.TMS470.ProjectType"/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="scannerConfiguration"/>
|
||||
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
|
||||
</cproject>
|
||||
64
SDCFile/.project
Normal file
64
SDCFile/.project
Normal file
@@ -0,0 +1,64 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>SDCFile</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
|
||||
<triggers>full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>com.ti.ccstudio.core.ccsNature</nature>
|
||||
<nature>org.eclipse.cdt.core.cnature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
||||
<nature>org.eclipse.cdt.core.ccnature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
||||
</natures>
|
||||
<linkedResources>
|
||||
<link>
|
||||
<name>Clock.c</name>
|
||||
<type>1</type>
|
||||
<locationURI>PARENT-1-PROJECT_LOC/inc/Clock.c</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>DAC.c</name>
|
||||
<type>1</type>
|
||||
<locationURI>PARENT-1-PROJECT_LOC/inc/DAC.c</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>LaunchPad.c</name>
|
||||
<type>1</type>
|
||||
<locationURI>PARENT-1-PROJECT_LOC/inc/LaunchPad.c</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>SPI.c</name>
|
||||
<type>1</type>
|
||||
<locationURI>PARENT-1-PROJECT_LOC/RTOS_Labs_common/SPI.c</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>ST7735_SDC.c</name>
|
||||
<type>1</type>
|
||||
<locationURI>PARENT-1-PROJECT_LOC/RTOS_Labs_common/ST7735_SDC.c</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>TExaS.c</name>
|
||||
<type>1</type>
|
||||
<locationURI>PARENT-1-PROJECT_LOC/inc/TExaS.c</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>Timer.c</name>
|
||||
<type>1</type>
|
||||
<locationURI>PARENT-1-PROJECT_LOC/inc/Timer.c</locationURI>
|
||||
</link>
|
||||
</linkedResources>
|
||||
</projectDescription>
|
||||
3
SDCFile/.settings/org.eclipse.cdt.codan.core.prefs
Normal file
3
SDCFile/.settings/org.eclipse.cdt.codan.core.prefs
Normal file
@@ -0,0 +1,3 @@
|
||||
eclipse.preferences.version=1
|
||||
inEditor=false
|
||||
onBuild=false
|
||||
57
SDCFile/Debug/.clangd/compile_commands.json
Normal file
57
SDCFile/Debug/.clangd/compile_commands.json
Normal file
@@ -0,0 +1,57 @@
|
||||
[
|
||||
{
|
||||
"directory" : "/Users/adipu/lab-7-tweinstein-1/SDCFile/Debug",
|
||||
"command" : "clang++ -I\"/Users/adipu/lab-7-tweinstein-1/SDCFile\" -I\"/Users/adipu/lab-7-tweinstein-1/SDCFile/Debug\" -I\"/Applications/ti/mspm0_sdk_2_09_00_01/source/third_party/CMSIS/Core/Include\" -I\"/Applications/ti/mspm0_sdk_2_09_00_01/source\" -D__MSPM0G3507__ -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/include/armv7em-ti-none-eabihf/c++/v1\" -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/include/c++/v1\" -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/lib/clang/18/include\" -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/include/c\" -I\"/Users/adipu/lab-7-tweinstein-1/SDCFile/Debug/syscfg\" -xc",
|
||||
"file" : "/Users/adipu/lab-7-tweinstein-1/inc/Clock.c"
|
||||
},
|
||||
{
|
||||
"directory" : "/Users/adipu/lab-7-tweinstein-1/SDCFile/Debug",
|
||||
"command" : "clang++ -I\"/Users/adipu/lab-7-tweinstein-1/SDCFile\" -I\"/Users/adipu/lab-7-tweinstein-1/SDCFile/Debug\" -I\"/Applications/ti/mspm0_sdk_2_09_00_01/source/third_party/CMSIS/Core/Include\" -I\"/Applications/ti/mspm0_sdk_2_09_00_01/source\" -D__MSPM0G3507__ -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/include/armv7em-ti-none-eabihf/c++/v1\" -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/include/c++/v1\" -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/lib/clang/18/include\" -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/include/c\" -I\"/Users/adipu/lab-7-tweinstein-1/SDCFile/Debug/syscfg\" -xc",
|
||||
"file" : "/Users/adipu/lab-7-tweinstein-1/inc/DAC.c"
|
||||
},
|
||||
{
|
||||
"directory" : "/Users/adipu/lab-7-tweinstein-1/SDCFile/Debug",
|
||||
"command" : "clang++ -I\"/Users/adipu/lab-7-tweinstein-1/SDCFile\" -I\"/Users/adipu/lab-7-tweinstein-1/SDCFile/Debug\" -I\"/Applications/ti/mspm0_sdk_2_09_00_01/source/third_party/CMSIS/Core/Include\" -I\"/Applications/ti/mspm0_sdk_2_09_00_01/source\" -D__MSPM0G3507__ -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/include/armv7em-ti-none-eabihf/c++/v1\" -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/include/c++/v1\" -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/lib/clang/18/include\" -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/include/c\" -I\"/Users/adipu/lab-7-tweinstein-1/SDCFile/Debug/syscfg\" -xc",
|
||||
"file" : "/Users/adipu/lab-7-tweinstein-1/inc/LaunchPad.c"
|
||||
},
|
||||
{
|
||||
"directory" : "/Users/adipu/lab-7-tweinstein-1/SDCFile/Debug",
|
||||
"command" : "clang++ -I\"/Users/adipu/lab-7-tweinstein-1/SDCFile\" -I\"/Users/adipu/lab-7-tweinstein-1/SDCFile/Debug\" -I\"/Applications/ti/mspm0_sdk_2_09_00_01/source/third_party/CMSIS/Core/Include\" -I\"/Applications/ti/mspm0_sdk_2_09_00_01/source\" -D__MSPM0G3507__ -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/include/armv7em-ti-none-eabihf/c++/v1\" -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/include/c++/v1\" -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/lib/clang/18/include\" -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/include/c\" -I\"/Users/adipu/lab-7-tweinstein-1/SDCFile/Debug/syscfg\" -xc",
|
||||
"file" : "/Users/adipu/lab-7-tweinstein-1/SDCFile/SDCFile.c"
|
||||
},
|
||||
{
|
||||
"directory" : "/Users/adipu/lab-7-tweinstein-1/SDCFile/Debug",
|
||||
"command" : "clang++ -I\"/Users/adipu/lab-7-tweinstein-1/SDCFile\" -I\"/Users/adipu/lab-7-tweinstein-1/SDCFile/Debug\" -I\"/Applications/ti/mspm0_sdk_2_09_00_01/source/third_party/CMSIS/Core/Include\" -I\"/Applications/ti/mspm0_sdk_2_09_00_01/source\" -D__MSPM0G3507__ -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/include/armv7em-ti-none-eabihf/c++/v1\" -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/include/c++/v1\" -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/lib/clang/18/include\" -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/include/c\" -I\"/Users/adipu/lab-7-tweinstein-1/SDCFile/Debug/syscfg\" -xc",
|
||||
"file" : "/Users/adipu/lab-7-tweinstein-1/RTOS_Labs_common/SPI.c"
|
||||
},
|
||||
{
|
||||
"directory" : "/Users/adipu/lab-7-tweinstein-1/SDCFile/Debug",
|
||||
"command" : "clang++ -I\"/Users/adipu/lab-7-tweinstein-1/SDCFile\" -I\"/Users/adipu/lab-7-tweinstein-1/SDCFile/Debug\" -I\"/Applications/ti/mspm0_sdk_2_09_00_01/source/third_party/CMSIS/Core/Include\" -I\"/Applications/ti/mspm0_sdk_2_09_00_01/source\" -D__MSPM0G3507__ -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/include/armv7em-ti-none-eabihf/c++/v1\" -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/include/c++/v1\" -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/lib/clang/18/include\" -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/include/c\" -I\"/Users/adipu/lab-7-tweinstein-1/SDCFile/Debug/syscfg\" -xc",
|
||||
"file" : "/Users/adipu/lab-7-tweinstein-1/RTOS_Labs_common/ST7735_SDC.c"
|
||||
},
|
||||
{
|
||||
"directory" : "/Users/adipu/lab-7-tweinstein-1/SDCFile/Debug",
|
||||
"command" : "clang++ -I\"/Users/adipu/lab-7-tweinstein-1/SDCFile\" -I\"/Users/adipu/lab-7-tweinstein-1/SDCFile/Debug\" -I\"/Applications/ti/mspm0_sdk_2_09_00_01/source/third_party/CMSIS/Core/Include\" -I\"/Applications/ti/mspm0_sdk_2_09_00_01/source\" -D__MSPM0G3507__ -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/include/armv7em-ti-none-eabihf/c++/v1\" -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/include/c++/v1\" -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/lib/clang/18/include\" -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/include/c\" -I\"/Users/adipu/lab-7-tweinstein-1/SDCFile/Debug/syscfg\" -xc",
|
||||
"file" : "/Users/adipu/lab-7-tweinstein-1/inc/TExaS.c"
|
||||
},
|
||||
{
|
||||
"directory" : "/Users/adipu/lab-7-tweinstein-1/SDCFile/Debug",
|
||||
"command" : "clang++ -I\"/Users/adipu/lab-7-tweinstein-1/SDCFile\" -I\"/Users/adipu/lab-7-tweinstein-1/SDCFile/Debug\" -I\"/Applications/ti/mspm0_sdk_2_09_00_01/source/third_party/CMSIS/Core/Include\" -I\"/Applications/ti/mspm0_sdk_2_09_00_01/source\" -D__MSPM0G3507__ -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/include/armv7em-ti-none-eabihf/c++/v1\" -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/include/c++/v1\" -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/lib/clang/18/include\" -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/include/c\" -I\"/Users/adipu/lab-7-tweinstein-1/SDCFile/Debug/syscfg\" -xc",
|
||||
"file" : "/Users/adipu/lab-7-tweinstein-1/inc/Timer.c"
|
||||
},
|
||||
{
|
||||
"directory" : "/Users/adipu/lab-7-tweinstein-1/SDCFile/Debug",
|
||||
"command" : "clang++ -I\"/Users/adipu/lab-7-tweinstein-1/SDCFile\" -I\"/Users/adipu/lab-7-tweinstein-1/SDCFile/Debug\" -I\"/Applications/ti/mspm0_sdk_2_09_00_01/source/third_party/CMSIS/Core/Include\" -I\"/Applications/ti/mspm0_sdk_2_09_00_01/source\" -D__MSPM0G3507__ -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/include/armv7em-ti-none-eabihf/c++/v1\" -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/include/c++/v1\" -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/lib/clang/18/include\" -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/include/c\" -I\"/Users/adipu/lab-7-tweinstein-1/SDCFile/Debug/syscfg\" -xc",
|
||||
"file" : "/Users/adipu/lab-7-tweinstein-1/SDCFile/diskio.c"
|
||||
},
|
||||
{
|
||||
"directory" : "/Users/adipu/lab-7-tweinstein-1/SDCFile/Debug",
|
||||
"command" : "clang++ -I\"/Users/adipu/lab-7-tweinstein-1/SDCFile\" -I\"/Users/adipu/lab-7-tweinstein-1/SDCFile/Debug\" -I\"/Applications/ti/mspm0_sdk_2_09_00_01/source/third_party/CMSIS/Core/Include\" -I\"/Applications/ti/mspm0_sdk_2_09_00_01/source\" -D__MSPM0G3507__ -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/include/armv7em-ti-none-eabihf/c++/v1\" -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/include/c++/v1\" -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/lib/clang/18/include\" -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/include/c\" -I\"/Users/adipu/lab-7-tweinstein-1/SDCFile/Debug/syscfg\" -xc",
|
||||
"file" : "/Users/adipu/lab-7-tweinstein-1/SDCFile/ff.c"
|
||||
},
|
||||
{
|
||||
"directory" : "/Users/adipu/lab-7-tweinstein-1/SDCFile/Debug",
|
||||
"command" : "clang++ -I\"/Users/adipu/lab-7-tweinstein-1/SDCFile\" -I\"/Users/adipu/lab-7-tweinstein-1/SDCFile/Debug\" -I\"/Applications/ti/mspm0_sdk_2_09_00_01/source/third_party/CMSIS/Core/Include\" -I\"/Applications/ti/mspm0_sdk_2_09_00_01/source\" -D__MSPM0G3507__ -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/include/armv7em-ti-none-eabihf/c++/v1\" -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/include/c++/v1\" -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/lib/clang/18/include\" -isystem\"/Applications/ti/ccs2040/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/include/c\" -I\"/Users/adipu/lab-7-tweinstein-1/SDCFile/Debug/syscfg\" -xc",
|
||||
"file" : "/Users/adipu/lab-7-tweinstein-1/SDCFile/ticlang/startup_mspm0g3507_ticlang.c"
|
||||
}
|
||||
]
|
||||
161
SDCFile/README.html
Normal file
161
SDCFile/README.html
Normal file
@@ -0,0 +1,161 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html xmlns:v="urn:schemas-microsoft-com:vml"
|
||||
xmlns:o="urn:schemas-microsoft-com:office:office"
|
||||
xmlns:w="urn:schemas-microsoft-com:office:word"
|
||||
xmlns:m="http://schemas.microsoft.com/office/2004/12/omml"
|
||||
xmlns:st1="urn:schemas-microsoft-com:office:smarttags"
|
||||
xmlns="http://www.w3.org/TR/REC-html40">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type"
|
||||
content="text/html; charset=windows-1252">
|
||||
<meta name="ProgId" content="Word.Document">
|
||||
<meta name="Generator" content="Microsoft Word 14">
|
||||
<meta name="Originator" content="Microsoft Word 14">
|
||||
<base target="_parent">
|
||||
<link rel="Edit-Time-Data" href="index_files/editdata.mso">
|
||||
<title>SDCFile</title>
|
||||
<o:smarttagtype
|
||||
namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="place"></o:smarttagtype><o:smarttagtype
|
||||
namespaceuri="urn:schemas-microsoft-com:office:smarttags"
|
||||
name="PlaceName"></o:smarttagtype>
|
||||
<o:smarttagtype
|
||||
namespaceuri="urn:schemas-microsoft-com:office:smarttags"
|
||||
name="PlaceType"></o:smarttagtype>
|
||||
<link rel="themeData" href="index_files/themedata.thmx">
|
||||
<link rel="colorSchemeMapping"
|
||||
href="index_files/colorschememapping.xml">
|
||||
<style>
|
||||
</style>
|
||||
</head>
|
||||
<body style="background-color: white;" alink="#0000ff" lang="EN-US"
|
||||
link="blue" vlink="#c40026">
|
||||
<div class="WordSection1">
|
||||
<p style="text-align: center;" align="center"><span
|
||||
style="font-size: 18pt;">SDCFile</span><br>
|
||||
<table class="MsoNormalTable"
|
||||
style="border: 3pt outset ; background: rgb(255, 204, 153) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; width: 100%;"
|
||||
border="1" cellpadding="0" width="100%">
|
||||
<tr>
|
||||
<td>
|
||||
<p><b><span style="font-size: 18pt;">Readme</b></span>
|
||||
<br> <br>
|
||||
This is a C language project that demonstrates the <i>serial
|
||||
peripheral interface</i> (SPI). This
|
||||
project interfaces the ST7735R LCD and SDC to the microcontroller.<br>
|
||||
<b>main0</b> Low level test, it will leave the SDC unformated. <br>
|
||||
<b>main1</b> Simple file write and test, SDC needs FAT16 format. <br>
|
||||
<b>main2</b> Longer file write and test, SDC needs FAT16 format. <br>
|
||||
<b>main3</b> Will create a large binary file called Sound.bin.<br>
|
||||
<b>main4</b> Will stream Sound.bin to 12-bit DAC at 11.025 kHz.
|
||||
</p>
|
||||
|
||||
<p>First run main3 to create Sound.bin. Then, connect PB20 (TExaS scope) to PA15 (DAC output) and run main4.</p>
|
||||
<img src="main4.png" alt="Image" style="width:500px;"><br> <br>
|
||||
|
||||
Derived from Texas Instrument code
|
||||
<ul>
|
||||
<li>spi_controller_multibyte_fifo_poll_LP_MSPM0G3507_nortos_ticlang</li>
|
||||
<li>spi_controller_command_data_control_LP_MSPM0G3507_nortos_ticlang</li>
|
||||
<li>spi_peripheral_register_format_LP_MSPM0G3507_nortos_ticlang</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</table>
|
||||
</p>
|
||||
|
||||
<table class="MsoNormalTable"
|
||||
style="border: 3pt outset ; background: rgb(252, 243, 144) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; width: 100%;"
|
||||
border="1" cellpadding="0" width="100%">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p><b><span style="font-size: 18pt;">Hardware Required</b></span>
|
||||
<br>
|
||||
<ul>
|
||||
<li>MSPM0G3507 LaunchPad™ Development Kit (LP-MSPM0G3507)</li>
|
||||
<li>We have tested 2 verions of the 160by128 pixel ST7735R with SDC
|
||||
<ol><li>Adafruit ST7735R Product ID: 358</li>
|
||||
<li>HiLetgo ST7735 TFT and SDC</li>
|
||||
</ol>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<b><span style="font-size: 18pt;">Pin assignments</b></span>
|
||||
<br>
|
||||
<p>The following shows the wiring for the Adafruit ST7735R.
|
||||
See the source code in ST7735.c for wiring other displays.</p>
|
||||
<img src="ST7735pins.png" alt="Image" style="width:500px;"><br> <br>
|
||||
|
||||
|
||||
<ul>
|
||||
<li>SPI1 SCLK: PB9 is ST7735R LCD clock CLK</li>
|
||||
<li>SPI1 PICO: PB8 is ST7735R LCD data MOSI</li>
|
||||
<li>SPI1 POCI: PB7 is SDC data MISO</li>
|
||||
<li>GPIO Output: PB6 is ST7735R LCD chip select TFT_CS</li>
|
||||
<li>GPIO Output: PB15 is ST7735R LCD !RST </li>
|
||||
<li>GPIO Output: PA13 is ST7735R LCD RS </li>
|
||||
<li>GPIO Output: PA12 is SDC chip select CARD_CS </li>
|
||||
<li>Analog Output: PA15 is 12-bit DAC output</li>
|
||||
<li>Analog Input: PB20 is ADC input used by TExaS scope</li>
|
||||
|
||||
<li>Output: PA0 is red LED1, index 0 in IOMUX PINCM table</li>
|
||||
<li>Output: PB22 is blue LED2, index 49 in IOMUX PINCM table</li>
|
||||
<li>Output: PB26 is red LED2, index 56 in IOMUX PINCM table</li>
|
||||
<li>Output: PB27 is green LED2, index 57 in IOMUX PINCM table</li>
|
||||
<li>Input: PA18 is S2 positive logic switch, index 39 in IOMUX PINCM table</li>
|
||||
<li>Input: PB21 is S3 negative logic switch, index 48 in IOMUX PINCM table</li>
|
||||
</ul>
|
||||
<b><span style="font-size: 18pt;">LaunchPad Jumpers</b></span>
|
||||
<br>
|
||||
<ul>
|
||||
<li>Remove J16 J17 J18: Disconnects light sensor from the microcontroller PA22 PA27 PA26</li>
|
||||
<li>J4: Connects PA0 to red LED</li>
|
||||
<li>J5: Connects PB22 to blue LED2</li>
|
||||
<li>J6: Connects PB26 to red LED2</li>
|
||||
<li>J7: Connects PB27 to green LED2</li>
|
||||
</ul>
|
||||
</p> </td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
<p>
|
||||
Simplified BSD License (FreeBSD License)
|
||||
Copyright © 2025, Jonathan Valvano, All rights reserved.<br>
|
||||
<br>
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:<br>
|
||||
<ol>
|
||||
<li>Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.</li>
|
||||
<li>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.</li></ol>
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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.<br>
|
||||
<br>
|
||||
The views and conclusions contained in the software and documentation are
|
||||
those of the authors and should not be interpreted as representing official
|
||||
policies, either expressed or implied, of the FreeBSD Project.
|
||||
<br>
|
||||
</p>
|
||||
<p>For more information, see <a href="http://users.ece.utexas.edu/~valvano/">
|
||||
http://users.ece.utexas.edu/~valvano/</a>.
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
559
SDCFile/SDCFile.c
Normal file
559
SDCFile/SDCFile.c
Normal file
@@ -0,0 +1,559 @@
|
||||
/* SDCFile
|
||||
* Jonathan Valvano
|
||||
* December 27, 2025
|
||||
* Derived
|
||||
* Derived from spi_controller_multibyte_fifo_poll_LP_MSPM0G3507_nortos_ticlang
|
||||
* spi_controller_command_data_control_LP_MSPM0G3507_nortos_ticlang
|
||||
* spi_peripheral_register_format_LP_MSPM0G3507_nortos_ticlang
|
||||
*/
|
||||
|
||||
|
||||
#include <ti/devices/msp/msp.h>
|
||||
#include "../inc/LaunchPad.h"
|
||||
#include "../inc/Clock.h"
|
||||
#include "../RTOS_Labs_common/SPI.h"
|
||||
#include "../RTOS_Labs_common/ST7735_SDC.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "integer.h"
|
||||
#include "diskio.h"
|
||||
#include "ff.h"
|
||||
#include "../inc/DAC.h"
|
||||
#include "../inc/Timer.h"
|
||||
#include "../inc/TExaS.h"
|
||||
|
||||
static FATFS g_sFatFs;
|
||||
FIL Handle,Handle2;
|
||||
FRESULT MountFresult;
|
||||
FRESULT Fresult;
|
||||
DRESULT Result;
|
||||
DSTATUS InitStatus;
|
||||
unsigned char buffer[512];
|
||||
#define MAXBLOCKS 100
|
||||
// Describe the error with text on the LCD and then stall. If
|
||||
// the error was caused by a mistake in configuring SPI1, then
|
||||
// the LCD will probably not work.
|
||||
void diskError(char *errtype, int32_t code, int32_t block){
|
||||
ST7735_DrawString(0, 0, "Err: ", ST7735_Color565(255, 0, 0));
|
||||
ST7735_DrawString(5, 0, errtype, ST7735_Color565(255, 0, 0));
|
||||
ST7735_DrawString(0, 1, "Code: ", ST7735_Color565(255, 0, 0));
|
||||
ST7735_SetCursor(6, 1);
|
||||
ST7735_SetTextColor(ST7735_Color565(255, 0, 0));
|
||||
ST7735_OutUDec(code);
|
||||
ST7735_DrawString(0, 2, "Block:", ST7735_Color565(255, 0, 0));
|
||||
ST7735_SetCursor(7, 2);
|
||||
ST7735_OutUDec(block);
|
||||
while(1){};
|
||||
}
|
||||
#define FILETESTSIZE 10000
|
||||
void test(void);
|
||||
int main(void){ // main1 simple test
|
||||
UINT successfulreads, successfulwrites;
|
||||
uint8_t c, x, y;
|
||||
uint32_t n,d;
|
||||
// simple test of file system
|
||||
__disable_irq();
|
||||
Clock_Init80MHz(0);
|
||||
LaunchPad_Init();
|
||||
__enable_irq();
|
||||
InitStatus = disk_initialize(0); // initialize disk
|
||||
ST7735_InitR(INITR_BLACKTAB); //SPI HiLetgo ST7735R
|
||||
// ST7735_InitR(INITR_REDTAB); //SPI AdaFruit ST7735R
|
||||
ST7735_FillScreen(ST7735_BLACK);
|
||||
ST7735_SetCursor(0, 0);
|
||||
ST7735_OutString("File system test\n");
|
||||
ST7735_SetCursor(0, 1);
|
||||
ST7735_OutString("Mounting\n");
|
||||
if(InitStatus) diskError("disk_initialize", InitStatus, 0);
|
||||
MountFresult = f_mount(&g_sFatFs, "", 0);
|
||||
if(MountFresult){
|
||||
ST7735_DrawString(0, 2, "f_mount error", ST7735_Color565(0, 0, 255));
|
||||
while(1){};
|
||||
}
|
||||
ST7735_SetCursor(0, 2);
|
||||
ST7735_OutString("Opening for write\n");
|
||||
c = 0;
|
||||
x = 0;
|
||||
y = 10;
|
||||
n = 1; // seed
|
||||
Fresult = f_open(&Handle2, "test.txt", FA_CREATE_ALWAYS|FA_WRITE);
|
||||
if(Fresult){
|
||||
ST7735_DrawString(0, 3, "test error", ST7735_Color565(0, 0, 255));
|
||||
while(1){};
|
||||
} else{
|
||||
for(int i=0; i<FILETESTSIZE; i++){
|
||||
n = (16807*n)%2147483647; // pseudo random sequence
|
||||
c = ((n>>24)%10)+'0'; // random digit 0 to 9
|
||||
Fresult = f_write(&Handle2, &c, 1, &successfulwrites);
|
||||
if((successfulwrites != 1) || (Fresult != FR_OK)){
|
||||
ST7735_DrawString(0, 0, "f_write error", ST7735_Color565(0, 0, 255));
|
||||
while(1){};
|
||||
}
|
||||
}
|
||||
Fresult = f_close(&Handle2);
|
||||
if(Fresult){
|
||||
ST7735_DrawString(0, 3, "file2 f_close error", ST7735_Color565(0, 0, 255));
|
||||
while(1){};
|
||||
}
|
||||
}
|
||||
ST7735_SetCursor(0, 3);
|
||||
ST7735_OutString("Opening for read\n");
|
||||
|
||||
n = 1; // reseed, start over to get the same sequence
|
||||
Fresult = f_open(&Handle, "test.txt", FA_READ);
|
||||
if(Fresult == FR_OK){
|
||||
ST7735_DrawString(0, 4, "Opened test.txt", ST7735_Color565(0, 0, 255));
|
||||
for(int i=0; i<FILETESTSIZE; i++){
|
||||
n = (16807*n)%2147483647; // pseudo random sequence
|
||||
d = ((n>>24)%10)+'0'; // expected random digit 0 to 9
|
||||
Fresult = f_read(&Handle, &c, 1, &successfulreads);
|
||||
if((successfulreads == 1) && (Fresult == FR_OK) && (c == d)){
|
||||
ST7735_DrawChar(x, y, c, ST7735_Color565(255, 255, 0), 0, 1);
|
||||
x = x + 6;
|
||||
if(x > 122){
|
||||
x = 0; // start over on the next line
|
||||
y = y + 10;
|
||||
}
|
||||
if(y > 150){
|
||||
y = 10; // the screen is full
|
||||
}
|
||||
} else{
|
||||
ST7735_DrawString(0, 4, "f_read error", ST7735_Color565(0, 0, 255));
|
||||
while(1){};
|
||||
}
|
||||
|
||||
}
|
||||
} else{
|
||||
ST7735_DrawString(0, 4, "Error test.txt ( )", ST7735_Color565(255, 0, 0));
|
||||
ST7735_SetCursor(20, 0);
|
||||
ST7735_SetTextColor(ST7735_Color565(255, 0, 0));
|
||||
ST7735_OutUDec((uint32_t)Fresult);
|
||||
while(1){};
|
||||
}
|
||||
ST7735_SetCursor(0, 4);
|
||||
ST7735_OutString("file test passed\n");
|
||||
Fresult = f_close(&Handle);
|
||||
while(1){};
|
||||
}
|
||||
|
||||
const char inFilename[] = "test.txt"; // 8 characters or fewer
|
||||
const char outFilename[] = "out.txt"; // 8 characters or fewer
|
||||
|
||||
int main2(void){ // main2 longer test
|
||||
UINT successfulreads, successfulwrites;
|
||||
uint8_t c, x, y;
|
||||
__disable_irq();
|
||||
Clock_Init80MHz(0);
|
||||
LaunchPad_Init();
|
||||
__enable_irq();
|
||||
InitStatus = disk_initialize(0); // initialize disk
|
||||
ST7735_InitR(INITR_REDTAB); //SPI HiLetgo ST7735R
|
||||
ST7735_FillScreen(ST7735_BLACK);
|
||||
ST7735_SetCursor(0, 0);
|
||||
ST7735_OutString("File system test\n");
|
||||
if(InitStatus) diskError("disk_initialize", InitStatus, 0);
|
||||
ST7735_SetCursor(0, 1);
|
||||
ST7735_OutString("Mounting\n");
|
||||
MountFresult = f_mount(&g_sFatFs, "", 0);
|
||||
if(MountFresult){
|
||||
ST7735_DrawString(0, 0, "f_mount error", ST7735_Color565(0, 0, 255));
|
||||
while(1){};
|
||||
}
|
||||
ST7735_SetCursor(0, 2);
|
||||
ST7735_OutString("Opening test.txt\n");
|
||||
Fresult = f_open(&Handle, inFilename, FA_READ);
|
||||
if(Fresult == FR_OK){
|
||||
ST7735_DrawString(0, 3, "Opened ", ST7735_Color565(0, 255, 0));
|
||||
ST7735_DrawString(7, 3, (char *)inFilename, ST7735_Color565(0, 255, 0));
|
||||
// get a character in 'c' and the number of successful reads in 'successfulreads'
|
||||
Fresult = f_read(&Handle, &c, 1, &successfulreads);
|
||||
x = 0; // start in the first column
|
||||
y = 10; // start in the second row
|
||||
while((Fresult == FR_OK) && (successfulreads == 1) && (y <= 130)){
|
||||
if(c == '\n'){
|
||||
x = 0; // go to the first column (this seems implied)
|
||||
y = y + 10; // go to the next row
|
||||
} else if(c == '\r'){
|
||||
x = 0; // go to the first column
|
||||
} else{ // the character is printable, so print it
|
||||
ST7735_DrawChar(x, y, c, ST7735_Color565(255, 255, 255), 0, 1);
|
||||
x = x + 6; // go to the next column
|
||||
if(x > 122){ // reached the right edge of the screen
|
||||
x = 0; // go to the first column
|
||||
y = y + 10; // go to the next row
|
||||
}
|
||||
}
|
||||
// get the next character in 'c'
|
||||
Fresult = f_read(&Handle, &c, 1, &successfulreads);
|
||||
}
|
||||
// close the file
|
||||
Fresult = f_close(&Handle);
|
||||
} else{
|
||||
// print the error code
|
||||
ST7735_DrawString(0, 0, "Error ( )", ST7735_Color565(255, 0, 0));
|
||||
ST7735_DrawString(6, 0, (char *)inFilename, ST7735_Color565(255, 0, 0));
|
||||
ST7735_SetCursor(16, 0);
|
||||
ST7735_SetTextColor(ST7735_Color565(255, 0, 0));
|
||||
ST7735_OutUDec((uint32_t)Fresult);
|
||||
}
|
||||
ST7735_SetCursor(0, 3);
|
||||
ST7735_OutString("Opening out.txt\n");
|
||||
|
||||
// open the file to be written
|
||||
// Options:
|
||||
// FA_CREATE_NEW - Creates a new file, only if it does not already exist. If file already exists, the function fails.
|
||||
// FA_CREATE_ALWAYS - Creates a new file, always. If file already exists, it is over-written.
|
||||
// FA_OPEN_ALWAYS - Opens a file, always. If file does not exist, the function creates a file.
|
||||
// FA_OPEN_EXISTING - Opens a file, only if it exists. If the file does not exist, the function fails.
|
||||
Fresult = f_open(&Handle, outFilename, FA_WRITE|FA_OPEN_ALWAYS);
|
||||
if(Fresult == FR_OK){
|
||||
ST7735_DrawString(0, 14, "Opened ", ST7735_Color565(0, 255, 0));
|
||||
ST7735_DrawString(7, 14, (char *)outFilename, ST7735_Color565(0, 255, 0));
|
||||
// jump to the end of the file
|
||||
Fresult = f_lseek(&Handle, Handle.fsize);
|
||||
// write a message and get the number of successful writes in 'successfulwrites'
|
||||
Fresult = f_write(&Handle, "Another successful write.\r\n", 27, &successfulwrites);
|
||||
if(Fresult == FR_OK){
|
||||
// print the number of successful writes
|
||||
// expect: third parameter of f_write()
|
||||
ST7735_DrawString(0, 15, "Writes: @", ST7735_Color565(0, 255, 0));
|
||||
ST7735_SetCursor(8, 15);
|
||||
ST7735_SetTextColor(ST7735_Color565(255, 255, 255));
|
||||
ST7735_OutUDec((uint32_t)successfulwrites);
|
||||
ST7735_SetCursor(13, 15);
|
||||
// print the byte offset from the start of the file where the writes started
|
||||
// expect: (third parameter of f_write())*(number of times this program has been run before)
|
||||
ST7735_OutUDec((uint32_t)(Handle.fptr - successfulwrites));
|
||||
} else{
|
||||
// print the error code
|
||||
ST7735_DrawString(0, 15, "f_write() error ( )", ST7735_Color565(255, 0, 0));
|
||||
ST7735_SetCursor(17, 15);
|
||||
ST7735_SetTextColor(ST7735_Color565(255, 0, 0));
|
||||
ST7735_OutUDec((uint32_t)Fresult);
|
||||
}
|
||||
// close the file
|
||||
Fresult = f_close(&Handle);
|
||||
} else{
|
||||
// print the error code
|
||||
ST7735_DrawString(0, 14, "Error ( )", ST7735_Color565(255, 0, 0));
|
||||
ST7735_DrawString(6, 14, (char *)outFilename, ST7735_Color565(255, 0, 0));
|
||||
ST7735_SetCursor(16, 14);
|
||||
ST7735_SetTextColor(ST7735_Color565(255, 0, 0));
|
||||
ST7735_OutUDec((uint32_t)Fresult);
|
||||
}
|
||||
while(1){};
|
||||
}
|
||||
|
||||
//*******streams 16 bit data from SDC to 12-bit DAC************
|
||||
#define BUFSIZE 256
|
||||
const uint16_t Wave[BUFSIZE] = {
|
||||
2048,2249,2447,2642,2831,3013,3185,3347,3495,3630,3750,
|
||||
3853,3939,4007,4056,4085,4095,4085,4056,4007,3939,3853,
|
||||
3750,3630,3495,3347,3185,3013,2831,2642,2447,2249,2048,
|
||||
1847,1649,1454,1265,1083,911,749,601,466,346,243,
|
||||
157,89,40,11,1,11,40,89,157,243,346,
|
||||
466,601,749,911,1083,1265,1454,1649,1847,
|
||||
2048,2249,2447,2642,2831,3013,3185,3347,3495,3630,3750,
|
||||
3853,3939,4007,4056,4085,4095,4085,4056,4007,3939,3853,
|
||||
3750,3630,3495,3347,3185,3013,2831,2642,2447,2249,2048,
|
||||
1847,1649,1454,1265,1083,911,749,601,466,346,243,
|
||||
157,89,40,11,1,11,40,89,157,243,346,
|
||||
466,601,749,911,1083,1265,1454,1649,1847,
|
||||
2048,2249,2447,2642,2831,3013,3185,3347,3495,3630,3750,
|
||||
3853,3939,4007,4056,4085,4095,4085,4056,4007,3939,3853,
|
||||
3750,3630,3495,3347,3185,3013,2831,2642,2447,2249,2048,
|
||||
1847,1649,1454,1265,1083,911,749,601,466,346,243,
|
||||
157,89,40,11,1,11,40,89,157,243,346,
|
||||
466,601,749,911,1083,1265,1454,1649,1847,
|
||||
2048,2249,2447,2642,2831,3013,3185,3347,3495,3630,3750,
|
||||
3853,3939,4007,4056,4085,4095,4085,4056,4007,3939,3853,
|
||||
3750,3630,3495,3347,3185,3013,2831,2642,2447,2249,2048,
|
||||
1847,1649,1454,1265,1083,911,749,601,466,346,243,
|
||||
157,89,40,11,1,11,40,89,157,243,346,
|
||||
466,601,749,911,1083,1265,1454,1649,1847};
|
||||
uint16_t SoundBuf[BUFSIZE];
|
||||
uint16_t SoundBuf2[BUFSIZE];
|
||||
uint32_t Count;
|
||||
uint16_t *front; // buffer being output to DAC
|
||||
uint16_t *back; // buffer being loaded from SDC
|
||||
int flag; // 1 means need data into back
|
||||
#define NUMBUF 128
|
||||
uint32_t BufCount; // 0 to NUMBUF-1
|
||||
uint32_t IdleTime=0;
|
||||
// file will be NUMBUF by BUFSIZE uint16_t binary values
|
||||
int main3(void){ // run main3 to create a sound file
|
||||
UINT successfulreads, successfulwrites;
|
||||
uint8_t c, x, y;
|
||||
__disable_irq();
|
||||
Clock_Init80MHz(0);
|
||||
LaunchPad_Init();
|
||||
__enable_irq();
|
||||
InitStatus = disk_initialize(0); // initialize disk
|
||||
ST7735_InitR(INITR_REDTAB); // SPI HiLetgo ST7735R
|
||||
ST7735_FillScreen(ST7735_BLACK);
|
||||
ST7735_SetCursor(0, 0);
|
||||
ST7735_OutString("Create sound.bin\n");
|
||||
if(InitStatus) diskError("disk_initialize", InitStatus, 0);
|
||||
ST7735_SetCursor(0, 1);
|
||||
ST7735_OutString("Mounting\n");
|
||||
MountFresult = f_mount(&g_sFatFs, "", 0);
|
||||
if(MountFresult){
|
||||
ST7735_DrawString(0, 0, "f_mount error", ST7735_Color565(0, 0, 255));
|
||||
while(1){};
|
||||
}
|
||||
ST7735_SetCursor(0, 2);
|
||||
ST7735_OutString("Opening sound.bin\n");
|
||||
Fresult = f_open(&Handle2, "sound.bin", FA_CREATE_ALWAYS|FA_WRITE);
|
||||
// Options:
|
||||
// FA_CREATE_NEW - Creates a new file, only if it does not already exist. If file already exists, the function fails.
|
||||
// FA_CREATE_ALWAYS - Creates a new file, always. If file already exists, it is over-written.
|
||||
// FA_OPEN_ALWAYS - Opens a file, always. If file does not exist, the function creates a file.
|
||||
// FA_OPEN_EXISTING - Opens a file, only if it exists. If the file does not exist, the function fails.
|
||||
if(Fresult){
|
||||
ST7735_DrawString(0, 3, "sound.bin error", ST7735_Color565(0, 0, 255));
|
||||
while(1){};
|
||||
}
|
||||
ST7735_DrawString(0, 3, "Opened sound.bin", ST7735_Color565(0, 255, 0));
|
||||
for(int i=0;i<NUMBUF;i++){
|
||||
Fresult = f_write(&Handle2, Wave, BUFSIZE*2, &successfulwrites);
|
||||
if((successfulwrites != BUFSIZE*2) || (Fresult != FR_OK)){
|
||||
ST7735_DrawString(0, 4, "f_write error", ST7735_Color565(0, 0, 255));
|
||||
while(1){};
|
||||
}
|
||||
}
|
||||
// close the file
|
||||
Fresult = f_close(&Handle2);
|
||||
ST7735_DrawString(0, 4, "Closed sound.bin", ST7735_Color565(0, 255, 0));
|
||||
// open the file to be read
|
||||
Fresult = f_open(&Handle, "sound.bin", FA_READ);
|
||||
if(Fresult == FR_OK){
|
||||
ST7735_DrawString(0, 5, "Opened sound.bin", ST7735_Color565(0, 255, 0));
|
||||
for(int i=0;i<NUMBUF;i++){
|
||||
Fresult = f_read(&Handle, SoundBuf, BUFSIZE*2, &successfulreads);
|
||||
if(Fresult){
|
||||
ST7735_DrawString(0, 6, "read error", ST7735_Color565(255, 0, 0));
|
||||
while(1){};
|
||||
}
|
||||
}
|
||||
// close the file
|
||||
Fresult = f_close(&Handle);
|
||||
} else{
|
||||
// print the error code
|
||||
ST7735_DrawString(0, 6, "open for read error", ST7735_Color565(255, 0, 0));
|
||||
}
|
||||
ST7735_DrawString(0, 6, "Success", ST7735_Color565(0, 255, 0));
|
||||
while(1){};
|
||||
}
|
||||
void TIMA1_IRQHandler(void){
|
||||
if((TIMA1->CPU_INT.IIDX) == 1){ // this will acknowledge
|
||||
GPIOB->DOUTTGL31_0 = GREEN; // toggle PB27
|
||||
DAC_Out(front[Count]);
|
||||
Count++;
|
||||
if(Count == BUFSIZE){
|
||||
Count = 0;
|
||||
uint16_t *pt = front;
|
||||
front = back;
|
||||
back = pt; // swap buffers
|
||||
flag = 1; // need more data
|
||||
}
|
||||
}
|
||||
}
|
||||
// YOU MUST RUN main3 before running main4 to create the sound.bin file
|
||||
int main4(void){ // run main4 to stream a sound file to DAC
|
||||
UINT successfulreads, successfulwrites;
|
||||
__disable_irq();
|
||||
Clock_Init80MHz(0);
|
||||
LaunchPad_Init();
|
||||
// TExaS_Init(0,0,&TExaS_LaunchPadLogic);
|
||||
TExaS_Init(ADC0,6,0); // PB20 connected to PA15
|
||||
front = SoundBuf2; // buffer being output to DAC
|
||||
back = SoundBuf; // buffer being written to from SDC
|
||||
Count = 0;
|
||||
flag = 1; // 1 means need data into back
|
||||
BufCount = 0;
|
||||
DAC_Init(); // 12bit DAC on PA15
|
||||
TimerA1_IntArm(80000000/11025,1,0); // 11.025kHz
|
||||
__enable_irq();
|
||||
InitStatus = disk_initialize(0); // initialize disk
|
||||
ST7735_InitR(INITR_REDTAB); // SPI HiLetgo ST7735R
|
||||
ST7735_FillScreen(ST7735_BLACK);
|
||||
ST7735_SetCursor(0, 0);
|
||||
ST7735_OutString("Streaming sound\n");
|
||||
if(InitStatus) diskError("disk_initialize", InitStatus, 0);
|
||||
ST7735_SetCursor(0, 1);
|
||||
ST7735_OutString("Mounting\n");
|
||||
MountFresult = f_mount(&g_sFatFs, "", 0);
|
||||
if(MountFresult){
|
||||
ST7735_DrawString(0, 0, "f_mount error", ST7735_Color565(0, 0, 255));
|
||||
while(1){};
|
||||
}
|
||||
// open the file to be read
|
||||
Fresult = f_open(&Handle, "sound.bin", FA_READ);
|
||||
if(Fresult){
|
||||
ST7735_DrawString(0, 6, "open error", ST7735_Color565(255, 0, 0));
|
||||
while(1){};
|
||||
}
|
||||
while(1){
|
||||
if(flag){ // 1 means need data
|
||||
flag = 0;
|
||||
GPIOB->DOUTSET31_0 = RED; // set PB26
|
||||
// 1.5ms to 1.6ms to read 512 bytes (256 16-bit integers)
|
||||
Fresult = f_read(&Handle, back, BUFSIZE*2, &successfulreads);
|
||||
GPIOB->DOUTCLR31_0 = RED; // clear PB26
|
||||
if(Fresult){
|
||||
ST7735_DrawString(0, 6, "read error", ST7735_Color565(255, 0, 0));
|
||||
while(1){};
|
||||
}
|
||||
BufCount++;
|
||||
if(BufCount == NUMBUF){ // could have seeked
|
||||
Fresult = f_close(&Handle);
|
||||
Fresult = f_open(&Handle, "sound.bin", FA_READ);
|
||||
BufCount = 0;
|
||||
}
|
||||
}
|
||||
// other tasks
|
||||
IdleTime++;
|
||||
}
|
||||
}
|
||||
//*******streams 8 bit sound from SDC to 12-bit DAC************
|
||||
#define BUFSIZE8 512
|
||||
uint8_t Buf[BUFSIZE8];
|
||||
uint8_t Buf2[BUFSIZE8];
|
||||
uint32_t Count8;
|
||||
uint8_t *front8; // buffer being output to DAC
|
||||
uint8_t *back8; // buffer being loaded from SDC
|
||||
int flag8; // 1 means need data into back
|
||||
#define NUMBUF8 (1004563/BUFSIZE8)
|
||||
uint32_t BufCount8; // 0 to NUMBUF8-1
|
||||
void SysTick_IntArm(uint32_t period, uint32_t priority){
|
||||
SysTick->CTRL = 0x00; // disable during initialization
|
||||
SysTick->LOAD = period-1; // set reload register
|
||||
//The ARM Cortex-M0+ only implements the most significant 2 bits of each 8-bit priority field (giving the 4 priority levels).
|
||||
SCB->SHP[1] = (SCB->SHP[1]&(~0xC0000000))|priority<<30; // set priority (bits 31,30)
|
||||
SysTick->VAL = 0; // clear count, cause reload
|
||||
SysTick->CTRL = 0x07; // Enable SysTick IRQ and SysTick Timer
|
||||
}
|
||||
void SysTick_Handler(void){
|
||||
GPIOB->DOUTTGL31_0 = GREEN; // toggle PB27
|
||||
uint32_t data = front8[Count8]<<4;
|
||||
// if(data>4095) data = 4095;
|
||||
DAC_Out(data); // 8 to 12 bit
|
||||
Count8++;
|
||||
if(Count8 == BUFSIZE8){
|
||||
Count8 = 0;
|
||||
uint8_t *pt = front8;
|
||||
front8 = back8;
|
||||
back8 = pt; // swap buffers
|
||||
flag8 = 1; // need more data
|
||||
}
|
||||
}
|
||||
int main5(void){
|
||||
UINT successfulreads, successfulwrites;
|
||||
__disable_irq();
|
||||
Clock_Init80MHz(0);
|
||||
LaunchPad_Init();
|
||||
// TExaS_Init(0,0,&TExaS_LaunchPadLogic);
|
||||
// TExaS_Init(ADC0,6,0); // PB20 connected to PA15
|
||||
front8 = Buf2; // buffer being output to DAC
|
||||
back8 = Buf; // buffer being written to from SDC
|
||||
Count8 = 0;
|
||||
flag8 = 1; // 1 means need data into back
|
||||
BufCount8 = 0;
|
||||
DAC_Init(); // 12bit DAC on PA15
|
||||
SysTick_IntArm(80000000/11025,0); // 11.025kHz
|
||||
__enable_irq();
|
||||
InitStatus = disk_initialize(0); // initialize disk
|
||||
ST7735_InitR(INITR_REDTAB); // SPI HiLetgo ST7735R
|
||||
ST7735_FillScreen(ST7735_BLACK);
|
||||
ST7735_SetCursor(0, 0);
|
||||
ST7735_OutString("Streaming sound\n");
|
||||
if(InitStatus) diskError("disk_initialize", InitStatus, 0);
|
||||
ST7735_SetCursor(0, 1);
|
||||
ST7735_OutString("Mounting\n");
|
||||
MountFresult = f_mount(&g_sFatFs, "", 0);
|
||||
if(MountFresult){
|
||||
ST7735_DrawString(0, 0, "f_mount error", ST7735_Color565(0, 0, 255));
|
||||
while(1){};
|
||||
}
|
||||
// open the file to be read
|
||||
Fresult = f_open(&Handle, "Swift.bin", FA_READ);
|
||||
if(Fresult){
|
||||
ST7735_DrawString(0, 6, "open error", ST7735_Color565(255, 0, 0));
|
||||
while(1){};
|
||||
}
|
||||
while(1){
|
||||
if(flag8){ // 1 means need data
|
||||
flag8 = 0;
|
||||
GPIOB->DOUTSET31_0 = RED; // set PB26
|
||||
// 1.5ms to 1.6ms to read 512 bytes (256 16-bit integers)
|
||||
Fresult = f_read(&Handle, back8, BUFSIZE8, &successfulreads);
|
||||
GPIOB->DOUTCLR31_0 = RED; // clear PB26
|
||||
if(Fresult){
|
||||
ST7735_DrawString(0, 6, "read error", ST7735_Color565(255, 0, 0));
|
||||
while(1){};
|
||||
}
|
||||
BufCount8++;
|
||||
if(BufCount8 == NUMBUF8){ // could have seeked
|
||||
Fresult = f_close(&Handle);
|
||||
Fresult = f_open(&Handle, "Swift.bin", FA_READ);
|
||||
BufCount8 = 0;
|
||||
}
|
||||
}
|
||||
// other tasks
|
||||
IdleTime++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// The simple unformatted test will destroy the formatting and
|
||||
// erase everything on the SD card.
|
||||
void main0(void){
|
||||
uint16_t block; int i; uint32_t n; uint32_t errors = 0;
|
||||
// simple test of eDisk
|
||||
__disable_irq();
|
||||
Clock_Init80MHz(0);
|
||||
LaunchPad_Init();
|
||||
__enable_irq();
|
||||
InitStatus = disk_initialize(0); // initialize disk
|
||||
|
||||
ST7735_InitR(INITR_REDTAB); //SPI HiLetgo ST7735R
|
||||
ST7735_FillScreen(ST7735_BLACK);
|
||||
ST7735_SetCursor(0, 0);
|
||||
ST7735_OutString("Simple unformatted test\n");
|
||||
if(InitStatus) diskError("disk_initialize", InitStatus, 0);
|
||||
n = 1; // seed
|
||||
for(block = 0; block < MAXBLOCKS; block++){
|
||||
for(i=0; i<512; i++){
|
||||
n = (16807*n)%2147483647; // pseudo random sequence
|
||||
buffer[i] = 0xFF&n;
|
||||
}
|
||||
GPIOB->DOUTSET31_0 = BLUE ;
|
||||
Result = disk_write (0,buffer, block, 1);
|
||||
GPIOB->DOUTCLR31_0 = BLUE ;
|
||||
if(Result) diskError("disk_write", Result, block); // save to disk
|
||||
}
|
||||
n = 1; // reseed, start over to get the same sequence
|
||||
for(block = 0; block < MAXBLOCKS; block++){
|
||||
GPIOB->DOUTSET31_0 = RED ;
|
||||
Result = disk_read (0,buffer, block,1);
|
||||
GPIOB->DOUTCLR31_0 = RED ;
|
||||
if(Result) diskError("disk_read ", Result, block); // read from disk
|
||||
for(i=0; i<512; i++){
|
||||
n = (16807*n)%2147483647; // pseudo random sequence
|
||||
if(buffer[i] != (0xFF&n)){
|
||||
errors = errors + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
ST7735_DrawString(0, 0, "Test done", ST7735_Color565(0, 255, 0));
|
||||
ST7735_DrawString(0, 1, "Mismatches:", ST7735_Color565(0, 255, 0));
|
||||
ST7735_SetCursor(12, 1);
|
||||
ST7735_SetTextColor(ST7735_Color565(0, 255, 0));
|
||||
ST7735_OutUDec(errors);
|
||||
while(1){};
|
||||
}
|
||||
|
||||
|
||||
BIN
SDCFile/ST7735pins.png
Normal file
BIN
SDCFile/ST7735pins.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 635 KiB |
BIN
SDCFile/Streaming wav files from the SDC to a DAC.docx
Normal file
BIN
SDCFile/Streaming wav files from the SDC to a DAC.docx
Normal file
Binary file not shown.
31
SDCFile/WCbin.m
Normal file
31
SDCFile/WCbin.m
Normal file
@@ -0,0 +1,31 @@
|
||||
## Author: Ramesh Yerraballi, Jonathan Valvano
|
||||
## Use this in octave to convert a wav file into raw binary
|
||||
## samples with a chosen precision at 11.025kHz
|
||||
## You will need to load the signal package first to use the decimate function
|
||||
## You can load it like this on the octave prompt:
|
||||
## pkg load signal
|
||||
## Run in octave as:
|
||||
## WCbin ("filename", precision);
|
||||
## The inputs are (i) the name of the wav file without the extention .wav.
|
||||
## (ii) the sample precision in bits (e.g., 4 to 8 bits)
|
||||
## This will generate a filename.bin file that has raw binary data
|
||||
## For example, say you have a sound file called boom.wav that you want to use in
|
||||
## in your game.
|
||||
## 1. Put the WCbin.m script and the boom.wav file in a folder (say sounds).
|
||||
## 2. Open octave/matlab and cd to the sounds folder
|
||||
## 3. Run script as: WCbin("boom", 8)
|
||||
## For 8-bit precision
|
||||
## This will produce a file named boom.bin, which contains raw samples
|
||||
## You can put the file on an SDC and read the data at run time
|
||||
function WCbin(filename,precision)
|
||||
# load the file
|
||||
[SplsOrig, fs] = audioread(strcat(filename,'.wav'));
|
||||
# downsample to 11.025kHz
|
||||
Spls = decimate(SplsOrig,round(fs/11025));
|
||||
# trim the precision of each sample
|
||||
Spls = round((Spls+ 1)* (2^precision-1)/2);
|
||||
# write raw binary to file with bin extension
|
||||
file = fopen(strcat(filename,'.bin'), 'w');
|
||||
fwrite(file, Spls(1:length(Spls)));
|
||||
fclose(file);
|
||||
end
|
||||
586
SDCFile/diskio.c
Normal file
586
SDCFile/diskio.c
Normal file
@@ -0,0 +1,586 @@
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* STM32F100: MMCv3/SDv1/SDv2 (SPI mode) control module */
|
||||
/*------------------------------------------------------------------------*/
|
||||
/*
|
||||
/ Copyright (C) 2014, ChaN, all right reserved.
|
||||
/
|
||||
/ * This software is a free software and there is NO WARRANTY.
|
||||
/ * No restriction on use. You can use, modify and redistribute it for
|
||||
/ personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.
|
||||
/ * Redistributions of source code must retain the above copyright notice.
|
||||
/
|
||||
/-------------------------------------------------------------------------*/
|
||||
// converted to MSPM0
|
||||
// April 11, 2024
|
||||
|
||||
#include <stdint.h>
|
||||
#include <ti/devices/msp/msp.h>
|
||||
#include "../inc/LaunchPad.h"
|
||||
#include "../inc/Clock.h"
|
||||
#include "../inc/Timer.h"
|
||||
#include "../RTOS_Labs_common/SPI.h"
|
||||
#include "integer.h"
|
||||
#include "diskio.h"
|
||||
// hardware connections, ECE445M RTOS sensor board
|
||||
// **********ST7735 TFT and SDC*******************
|
||||
// ST7735
|
||||
// Backlight (pin 10) to +3.3 V
|
||||
// MISO (pin 9) to SPI1 POCI: PB7
|
||||
// SCK (pin 8) to SPI1 SCLK: PB9
|
||||
// MOSI (pin 7) to SPI1 PICO: PB8
|
||||
// TFT_CS (pin 6) to GPIO: PB6
|
||||
// CARD_CS (pin 5) to PB0 (GPIO)
|
||||
// Data/Command (pin 4) to PB16 (GPIO), high for data, low for command
|
||||
// RESET (pin 3) to PB15 (GPIO)
|
||||
// VCC (pin 2) to +3.3 V
|
||||
// Gnd (pin 1) to ground
|
||||
|
||||
// **********HiLetgo ST7735 TFT and SDC *******************
|
||||
// ST7735
|
||||
// LED- (pin 16) TFT, to ground
|
||||
// LED+ (pin 15) TFT, to +3.3 V
|
||||
// SD_CS (pin 14) SDC, to PB0 chip select
|
||||
// MOSI (pin 13) SDC, to PB8 MOSI
|
||||
// MISO (pin 12) SDC, to PB7 MISO
|
||||
// SCK (pin 11) SDC, to serial clock
|
||||
// CS (pin 10) TFT, to PB6 GPIO
|
||||
// SCL (pin 9) TFT, to PB9 SPI1 SCLK
|
||||
// SDA (pin 8) TFT, to PB8 MOSI SPI1 PICO
|
||||
// A0 (pin 7) TFT, to PB16 Data/Command, high for data, low for command
|
||||
// RESET (pin 6) TFT, to PB15 reset (GPIO), low to reset
|
||||
// NC (pins 3,4,5)
|
||||
// VCC (pin 2) to +3.3 V
|
||||
// GND (pin 1) to ground
|
||||
|
||||
|
||||
// outputBitRate = (spiInputClock) / ((1 + SCR) * 2)
|
||||
// 99 for 400,000 bps slow mode, used during initialization
|
||||
// 4 for 8,000,000 bps fast mode, used during disk I/O
|
||||
#define FCLK_SLOW() { SPI1->CLKCTL = 99; }
|
||||
#define FCLK_FAST() { SPI1->CLKCTL = 80/16 -1; }// 8 MHz
|
||||
|
||||
|
||||
//#define MMC_CD !(GPIOC_IDR & _BV(4)) /* Card detect (yes:true, no:false, default:true) */
|
||||
#define MMC_CD 1 /* Card detect (yes:true, no:false, default:true) */
|
||||
#define MMC_WP 0 /* Write protected (yes:true, no:false, default:false) */
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
|
||||
Module Private Functions
|
||||
|
||||
---------------------------------------------------------------------------*/
|
||||
/* MMC/SD command */
|
||||
#define CMD0 (0) /* GO_IDLE_STATE */
|
||||
#define CMD1 (1) /* SEND_OP_COND (MMC) */
|
||||
#define ACMD41 (0x80+41) /* SEND_OP_COND (SDC) */
|
||||
#define CMD8 (8) /* SEND_IF_COND */
|
||||
#define CMD9 (9) /* SEND_CSD */
|
||||
#define CMD10 (10) /* SEND_CID */
|
||||
#define CMD12 (12) /* STOP_TRANSMISSION */
|
||||
#define ACMD13 (0x80+13) /* SD_STATUS (SDC) */
|
||||
#define CMD16 (16) /* SET_BLOCKLEN */
|
||||
#define CMD17 (17) /* READ_SINGLE_BLOCK */
|
||||
#define CMD18 (18) /* READ_MULTIPLE_BLOCK */
|
||||
#define CMD23 (23) /* SET_BLOCK_COUNT (MMC) */
|
||||
#define ACMD23 (0x80+23) /* SET_WR_BLK_ERASE_COUNT (SDC) */
|
||||
#define CMD24 (24) /* WRITE_BLOCK */
|
||||
#define CMD25 (25) /* WRITE_MULTIPLE_BLOCK */
|
||||
#define CMD32 (32) /* ERASE_ER_BLK_START */
|
||||
#define CMD33 (33) /* ERASE_ER_BLK_END */
|
||||
#define CMD38 (38) /* ERASE */
|
||||
#define CMD55 (55) /* APP_CMD */
|
||||
#define CMD58 (58) /* READ_OCR */
|
||||
|
||||
static volatile DSTATUS Stat = STA_NOINIT; /* Physical drive status */
|
||||
|
||||
static volatile UINT Timer1, Timer2; /* 1kHz decrement timer stopped at zero (disk_timerproc()) */
|
||||
|
||||
static BYTE CardType; /* Card type flags */
|
||||
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* SPI controls (Platform dependent) */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
/* Initialize MMC interface */
|
||||
static void init_spi(void){
|
||||
SPI1_Init(); // used for both SDC and TFT
|
||||
SDC_CS_HIGH(); /* Set CS# high */
|
||||
TimerG0_IntArm(1000,40,1); // initialize TimerG0 for 1 ms interrupts
|
||||
for (Timer1 = 10; Timer1; ) ; /* 10ms */
|
||||
}
|
||||
|
||||
|
||||
/* Exchange a byte */
|
||||
// Inputs: byte to be sent to SPI
|
||||
// Outputs: byte received from SPI
|
||||
// assumes it has been selected with CS low
|
||||
static BYTE xchg_spi(BYTE data){ BYTE volatile rcvdat;
|
||||
// wait until SPI1 not busy/
|
||||
while((SPI1->STAT&0x10) == 0x10){}; // spin SPI busy
|
||||
SPI1->TXDATA = data;
|
||||
while((SPI1->STAT&0x04) == 0x04){}; // spin SPI RxFifo empty
|
||||
rcvdat = SPI1->RXDATA; // acknowledge response
|
||||
// while((SSI0_SR_R&SSI_SR_BSY)==SSI_SR_BSY){};
|
||||
// SSI0_DR_R = dat; // data out
|
||||
// while((SSI0_SR_R&SSI_SR_RNE)==0){}; // wait until response
|
||||
// rcvdat = SSI0_DR_R; // acknowledge response
|
||||
return rcvdat;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Receive a byte from MMC via SPI (Platform dependent) */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
// Inputs: none
|
||||
// Outputs: byte received from SPI
|
||||
// assumes it has been selected with CS low
|
||||
static BYTE rcvr_spi(void){
|
||||
// wait until SPI1 not busy/
|
||||
while((SPI1->STAT&0x10) == 0x10){}; // spin SPI busy
|
||||
SPI1->TXDATA = 0xFF; // data out, garbage
|
||||
while((SPI1->STAT&0x04) == 0x04){}; // spin SPI RxFifo empty
|
||||
return (BYTE)SPI1->RXDATA; // read received data
|
||||
|
||||
// while((SSI0_SR_R&SSI_SR_BSY)==SSI_SR_BSY){};
|
||||
// SSI0_DR_R = 0xFF; // data out, garbage
|
||||
// while((SSI0_SR_R&SSI_SR_RNE)==0){}; // wait until response
|
||||
// return (BYTE)SSI0_DR_R; // read received data
|
||||
}
|
||||
|
||||
/* Receive multiple byte */
|
||||
// Input: buff Pointer to empty buffer into which data will be received
|
||||
// btr Number of bytes to receive (even number)
|
||||
// Output: none
|
||||
static void rcvr_spi_multi(BYTE *buff, UINT btr){
|
||||
while(btr){
|
||||
*buff = rcvr_spi(); // return by reference
|
||||
btr--; buff++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if _USE_WRITE
|
||||
/* Send multiple byte */
|
||||
// Input: buff Pointer to the data which will be sent
|
||||
// btx Number of bytes to send (even number)
|
||||
// Output: none
|
||||
static void xmit_spi_multi(const BYTE *buff, UINT btx){
|
||||
BYTE volatile rcvdat;
|
||||
while(btx){
|
||||
SPI1->TXDATA = *buff;
|
||||
while((SPI1->STAT&0x04) == 0x04){}; // spin SPI RxFifo empty
|
||||
rcvdat = SPI1->RXDATA; // acknowledge response
|
||||
// SSI0_DR_R = *buff; // data out
|
||||
// while((SSI0_SR_R&SSI_SR_RNE)==0){}; // wait until response
|
||||
// rcvdat = SSI0_DR_R; // acknowledge response
|
||||
btx--; buff++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Wait for card ready */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
// Input: time to wait in ms
|
||||
// Output: 1:Ready, 0:Timeout
|
||||
static int wait_ready(UINT wt){
|
||||
BYTE d;
|
||||
Timer2 = wt;
|
||||
do {
|
||||
d = xchg_spi(0xFF);
|
||||
/* This loop takes a time. Insert rot_rdq() here for multitask environment. */
|
||||
} while (d != 0xFF && Timer2); /* Wait for card goes ready or timeout */
|
||||
return (d == 0xFF) ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Deselect card and release SPI */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
static void deselect(void){
|
||||
SDC_CS_HIGH(); /* CS = H */
|
||||
xchg_spi(0xFF); /* Dummy clock (force DO hi-z for multiple slave SPI) */
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Select card and wait for ready */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
// Input: none
|
||||
// Output: 1:OK, 0:Timeout in 500ms
|
||||
static int select(void){
|
||||
TFT_CS_HIGH(); // make sure TFT is off
|
||||
SDC_CS_LOW();
|
||||
xchg_spi(0xFF); /* Dummy clock (force DO enabled) */
|
||||
if(wait_ready(500)) return 1; /* OK */
|
||||
deselect();
|
||||
return 0; /* Timeout */
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Receive a data packet from the MMC */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
// Input: buff Pointer to empty buffer into which data will be received
|
||||
// btr Number of bytes to receive (even number)
|
||||
// Output: 1:OK, 0:Error on timeout
|
||||
static int rcvr_datablock(BYTE *buff, UINT btr){
|
||||
BYTE token;
|
||||
Timer1 = 200;
|
||||
do { /* Wait for DataStart token in timeout of 200ms */
|
||||
token = xchg_spi(0xFF);
|
||||
/* This loop will take a time. Insert rot_rdq() here for multitask envilonment. */
|
||||
} while ((token == 0xFF) && Timer1);
|
||||
if(token != 0xFE) return 0; /* Function fails if invalid DataStart token or timeout */
|
||||
|
||||
rcvr_spi_multi(buff, btr); /* Store trailing data to the buffer */
|
||||
xchg_spi(0xFF); xchg_spi(0xFF); /* Discard CRC */
|
||||
return 1; /* Function succeeded */
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Send a data packet to the MMC */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
#if _USE_WRITE
|
||||
// Input: buff Pointer to 512 byte data which will be sent
|
||||
// token Token
|
||||
// Output: 1:OK, 0:Failed on timeout
|
||||
static int xmit_datablock(const BYTE *buff, BYTE token){
|
||||
BYTE resp;
|
||||
if (!wait_ready(500)) return 0; /* Wait for card ready */
|
||||
|
||||
xchg_spi(token); /* Send token */
|
||||
if (token != 0xFD) { /* Send data if token is other than StopTran */
|
||||
xmit_spi_multi(buff, 512); /* Data */
|
||||
xchg_spi(0xFF); xchg_spi(0xFF); /* Dummy CRC */
|
||||
|
||||
resp = xchg_spi(0xFF); /* Receive data resp */
|
||||
if ((resp & 0x1F) != 0x05) /* Function fails if the data packet was not accepted */
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Send a command packet to the MMC */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
// Inputs: cmd Command index
|
||||
// arg /* Argument
|
||||
// Outputs: R1 resp (bit7==1:Failed to send)
|
||||
static BYTE send_cmd(BYTE cmd, DWORD arg){
|
||||
BYTE n, res;
|
||||
if (cmd & 0x80) { /* Send a CMD55 prior to ACMD<n> */
|
||||
cmd &= 0x7F;
|
||||
res = send_cmd(CMD55, 0);
|
||||
if (res > 1) return res;
|
||||
}
|
||||
|
||||
/* Select the card and wait for ready except to stop multiple block read */
|
||||
if (cmd != CMD12) {
|
||||
deselect();
|
||||
if (!select()) return 0xFF;
|
||||
}
|
||||
|
||||
/* Send command packet */
|
||||
xchg_spi(0x40 | cmd); /* Start + command index */
|
||||
xchg_spi((BYTE)(arg >> 24)); /* Argument[31..24] */
|
||||
xchg_spi((BYTE)(arg >> 16)); /* Argument[23..16] */
|
||||
xchg_spi((BYTE)(arg >> 8)); /* Argument[15..8] */
|
||||
xchg_spi((BYTE)arg); /* Argument[7..0] */
|
||||
n = 0x01; /* Dummy CRC + Stop */
|
||||
if (cmd == CMD0) n = 0x95; /* Valid CRC for CMD0(0) */
|
||||
if (cmd == CMD8) n = 0x87; /* Valid CRC for CMD8(0x1AA) */
|
||||
xchg_spi(n);
|
||||
|
||||
/* Receive command resp */
|
||||
if (cmd == CMD12) xchg_spi(0xFF); /* Diacard following one byte when CMD12 */
|
||||
n = 10; /* Wait for response (10 bytes max) */
|
||||
do
|
||||
res = xchg_spi(0xFF);
|
||||
while ((res & 0x80) && --n);
|
||||
|
||||
return res; /* Return received response */
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
|
||||
Public Functions
|
||||
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Initialize disk drive */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
// Inputs: Physical drive number, which must be 0
|
||||
// Outputs: status (see DSTATUS)
|
||||
// SPI1_Init called from main
|
||||
DSTATUS disk_initialize(BYTE drv){
|
||||
BYTE n, cmd, ty, ocr[4];
|
||||
|
||||
if (drv) return STA_NOINIT; /* Supports only drive 0 */
|
||||
init_spi(); /* Initialize SPI */
|
||||
|
||||
if (Stat & STA_NODISK) return Stat; /* Is card existing in the soket? */
|
||||
|
||||
FCLK_SLOW();
|
||||
for (n = 10; n; n--) xchg_spi(0xFF); /* Send 80 dummy clocks */
|
||||
|
||||
ty = 0;
|
||||
if (send_cmd(CMD0, 0) == 1) { /* Put the card SPI/Idle state */
|
||||
Timer1 = 1000; /* Initialization timeout = 1 sec */
|
||||
if (send_cmd(CMD8, 0x1AA) == 1) { /* SDv2? */
|
||||
for (n = 0; n < 4; n++) ocr[n] = xchg_spi(0xFF); /* Get 32 bit return value of R7 resp */
|
||||
if (ocr[2] == 0x01 && ocr[3] == 0xAA) { /* Is the card supports vcc of 2.7-3.6V? */
|
||||
while (Timer1 && send_cmd(ACMD41, 1UL << 30)) ; /* Wait for end of initialization with ACMD41(HCS) */
|
||||
if (Timer1 && send_cmd(CMD58, 0) == 0) { /* Check CCS bit in the OCR */
|
||||
for (n = 0; n < 4; n++) ocr[n] = xchg_spi(0xFF);
|
||||
ty = (ocr[0] & 0x40) ? CT_SD2 | CT_BLOCK : CT_SD2; /* Card id SDv2 */
|
||||
}
|
||||
}
|
||||
} else { /* Not SDv2 card */
|
||||
if (send_cmd(ACMD41, 0) <= 1) { /* SDv1 or MMC? */
|
||||
ty = CT_SD1; cmd = ACMD41; /* SDv1 (ACMD41(0)) */
|
||||
} else {
|
||||
ty = CT_MMC; cmd = CMD1; /* MMCv3 (CMD1(0)) */
|
||||
}
|
||||
while (Timer1 && send_cmd(cmd, 0)) ; /* Wait for end of initialization */
|
||||
if (!Timer1 || send_cmd(CMD16, 512) != 0) /* Set block length: 512 */
|
||||
ty = 0;
|
||||
}
|
||||
}
|
||||
CardType = ty; /* Card type */
|
||||
deselect();
|
||||
FCLK_FAST(); /* Set fast clock */
|
||||
|
||||
if (ty) { /* OK */
|
||||
Stat &= ~STA_NOINIT; /* Clear STA_NOINIT flag */
|
||||
} else { /* Failed */
|
||||
Stat = STA_NOINIT;
|
||||
}
|
||||
|
||||
return Stat;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Get disk status */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
// Inputs: Physical drive number, which must be 0
|
||||
// Outputs: status (see DSTATUS)
|
||||
DSTATUS disk_status(BYTE drv){
|
||||
if (drv) return STA_NOINIT; /* Supports only drive 0 */
|
||||
return Stat; /* Return disk status */
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Read sector(s) */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
//Inputs: drv Physical drive number (0)
|
||||
// buff Pointer to the data buffer to store read data
|
||||
// sector Start sector number (LBA)
|
||||
// count Number of sectors to read (1..128)
|
||||
// Outputs: status (see DRESULT)
|
||||
DRESULT disk_read(BYTE drv, BYTE *buff, DWORD sector, UINT count){
|
||||
if (drv || !count) return RES_PARERR; /* Check parameter */
|
||||
if (Stat & STA_NOINIT) return RES_NOTRDY; /* Check if drive is ready */
|
||||
|
||||
if (!(CardType & CT_BLOCK)) sector *= 512; /* LBA ot BA conversion (byte addressing cards) */
|
||||
|
||||
if (count == 1) { /* Single sector read */
|
||||
if ((send_cmd(CMD17, sector) == 0) /* READ_SINGLE_BLOCK */
|
||||
&& rcvr_datablock(buff, 512))
|
||||
count = 0;
|
||||
}
|
||||
else { /* Multiple sector read */
|
||||
if (send_cmd(CMD18, sector) == 0) { /* READ_MULTIPLE_BLOCK */
|
||||
do {
|
||||
if (!rcvr_datablock(buff, 512)) break;
|
||||
buff += 512;
|
||||
} while (--count);
|
||||
send_cmd(CMD12, 0); /* STOP_TRANSMISSION */
|
||||
}
|
||||
}
|
||||
deselect();
|
||||
|
||||
return count ? RES_ERROR : RES_OK; /* Return result */
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Write sector(s) */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
#if _USE_WRITE
|
||||
//Inputs: drv Physical drive number (0)
|
||||
// buff Pointer to the data buffer to write to disk
|
||||
// sector Start sector number (LBA)
|
||||
// count Number of sectors to write (1..128)
|
||||
// Outputs: status (see DRESULT)
|
||||
DRESULT disk_write(BYTE drv, const BYTE *buff, DWORD sector, UINT count){
|
||||
if (drv || !count) return RES_PARERR; /* Check parameter */
|
||||
if (Stat & STA_NOINIT) return RES_NOTRDY; /* Check drive status */
|
||||
if (Stat & STA_PROTECT) return RES_WRPRT; /* Check write protect */
|
||||
|
||||
if (!(CardType & CT_BLOCK)) sector *= 512; /* LBA ==> BA conversion (byte addressing cards) */
|
||||
|
||||
if (count == 1) { /* Single sector write */
|
||||
if ((send_cmd(CMD24, sector) == 0) /* WRITE_BLOCK */
|
||||
&& xmit_datablock(buff, 0xFE))
|
||||
count = 0;
|
||||
}
|
||||
else { /* Multiple sector write */
|
||||
if (CardType & CT_SDC) send_cmd(ACMD23, count); /* Predefine number of sectors */
|
||||
if (send_cmd(CMD25, sector) == 0) { /* WRITE_MULTIPLE_BLOCK */
|
||||
do {
|
||||
if (!xmit_datablock(buff, 0xFC)) break;
|
||||
buff += 512;
|
||||
} while (--count);
|
||||
if (!xmit_datablock(0, 0xFD)) /* STOP_TRAN token */
|
||||
count = 1;
|
||||
}
|
||||
}
|
||||
deselect();
|
||||
|
||||
return count ? RES_ERROR : RES_OK; /* Return result */
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Miscellaneous drive controls other than data read/write */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
// Inputs: drv, Physical drive number (0)
|
||||
// cmd, Control command code
|
||||
// buff Pointer to the control data
|
||||
// Outputs: status (see DRESULT)
|
||||
#if _USE_IOCTL
|
||||
DRESULT disk_ioctl(BYTE drv, BYTE cmd, void *buff){
|
||||
DRESULT res;
|
||||
BYTE n, csd[16];
|
||||
DWORD *dp, st, ed, csize;
|
||||
|
||||
|
||||
if (drv) return RES_PARERR; /* Check parameter */
|
||||
if (Stat & STA_NOINIT) return RES_NOTRDY; /* Check if drive is ready */
|
||||
|
||||
res = RES_ERROR;
|
||||
|
||||
switch (cmd) {
|
||||
case CTRL_SYNC : /* Wait for end of internal write process of the drive */
|
||||
if (select()) res = RES_OK;
|
||||
break;
|
||||
|
||||
case GET_SECTOR_COUNT : /* Get drive capacity in unit of sector (DWORD) */
|
||||
if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) {
|
||||
if ((csd[0] >> 6) == 1) { /* SDC ver 2.00 */
|
||||
csize = csd[9] + ((WORD)csd[8] << 8) + ((DWORD)(csd[7] & 63) << 16) + 1;
|
||||
*(DWORD*)buff = csize << 10;
|
||||
} else { /* SDC ver 1.XX or MMC ver 3 */
|
||||
n = (csd[5] & 15) + ((csd[10] & 128) >> 7) + ((csd[9] & 3) << 1) + 2;
|
||||
csize = (csd[8] >> 6) + ((WORD)csd[7] << 2) + ((WORD)(csd[6] & 3) << 10) + 1;
|
||||
*(DWORD*)buff = csize << (n - 9);
|
||||
}
|
||||
res = RES_OK;
|
||||
}
|
||||
break;
|
||||
|
||||
case GET_BLOCK_SIZE : /* Get erase block size in unit of sector (DWORD) */
|
||||
if (CardType & CT_SD2) { /* SDC ver 2.00 */
|
||||
if (send_cmd(ACMD13, 0) == 0) { /* Read SD status */
|
||||
xchg_spi(0xFF);
|
||||
if (rcvr_datablock(csd, 16)) { /* Read partial block */
|
||||
for (n = 64 - 16; n; n--) xchg_spi(0xFF); /* Purge trailing data */
|
||||
*(DWORD*)buff = 16UL << (csd[10] >> 4);
|
||||
res = RES_OK;
|
||||
}
|
||||
}
|
||||
} else { /* SDC ver 1.XX or MMC */
|
||||
if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) { /* Read CSD */
|
||||
if (CardType & CT_SD1) { /* SDC ver 1.XX */
|
||||
*(DWORD*)buff = (((csd[10] & 63) << 1) + ((WORD)(csd[11] & 128) >> 7) + 1) << ((csd[13] >> 6) - 1);
|
||||
} else { /* MMC */
|
||||
*(DWORD*)buff = ((WORD)((csd[10] & 124) >> 2) + 1) * (((csd[11] & 3) << 3) + ((csd[11] & 224) >> 5) + 1);
|
||||
}
|
||||
res = RES_OK;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CTRL_TRIM : /* Erase a block of sectors (used when _USE_ERASE == 1) */
|
||||
if (!(CardType & CT_SDC)) break; /* Check if the card is SDC */
|
||||
if (disk_ioctl(drv, MMC_GET_CSD, csd)) break; /* Get CSD */
|
||||
if (!(csd[0] >> 6) && !(csd[10] & 0x40)) break; /* Check if sector erase can be applied to the card */
|
||||
dp = buff; st = dp[0]; ed = dp[1]; /* Load sector block */
|
||||
if (!(CardType & CT_BLOCK)) {
|
||||
st *= 512; ed *= 512;
|
||||
}
|
||||
if (send_cmd(CMD32, st) == 0 && send_cmd(CMD33, ed) == 0 && send_cmd(CMD38, 0) == 0 && wait_ready(30000)) /* Erase sector block */
|
||||
res = RES_OK; /* FatFs does not check result of this command */
|
||||
break;
|
||||
|
||||
default:
|
||||
res = RES_PARERR;
|
||||
}
|
||||
|
||||
deselect();
|
||||
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Device timer function */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* This function must be called from timer interrupt routine in period
|
||||
/ of 1 ms to generate card control timing.
|
||||
*/
|
||||
|
||||
void disk_timerproc (void)
|
||||
{
|
||||
WORD n;
|
||||
BYTE s;
|
||||
|
||||
|
||||
n = Timer1; /* 1kHz decrement timer stopped at 0 */
|
||||
if (n) Timer1 = --n;
|
||||
n = Timer2;
|
||||
if (n) Timer2 = --n;
|
||||
|
||||
s = Stat;
|
||||
if (MMC_WP) /* Write protected */
|
||||
s |= STA_PROTECT;
|
||||
else /* Write enabled */
|
||||
s &= ~STA_PROTECT;
|
||||
if (MMC_CD) /* Card is in socket */
|
||||
s &= ~STA_NODISK;
|
||||
else /* Socket empty */
|
||||
s |= (STA_NODISK | STA_NOINIT);
|
||||
Stat = s;
|
||||
}
|
||||
|
||||
|
||||
// Executed every 1 ms
|
||||
void TIMG0_IRQHandler(void){
|
||||
if((TIMG0->CPU_INT.IIDX) == 1){ // this will acknowledge
|
||||
disk_timerproc();
|
||||
}
|
||||
}
|
||||
133
SDCFile/diskio.h
Normal file
133
SDCFile/diskio.h
Normal file
@@ -0,0 +1,133 @@
|
||||
/*-----------------------------------------------------------------------
|
||||
/ Low level disk interface modlue include file (C)ChaN, 2014
|
||||
/-----------------------------------------------------------------------*/
|
||||
// converted to TM4C123, converted to MSPM0
|
||||
// Jonathan Valvano, December 27, 2025
|
||||
#ifndef _DISKIO_DEFINED
|
||||
#define _DISKIO_DEFINED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define _USE_WRITE 1 /* 1: Enable disk_write() function */
|
||||
#define _USE_IOCTL 1 /* 1: Enable disk_ioctl() fucntion */
|
||||
|
||||
#include "integer.h"
|
||||
|
||||
|
||||
/* Status of Disk Functions */
|
||||
typedef BYTE DSTATUS;
|
||||
|
||||
/* Results of Disk Functions */
|
||||
typedef enum {
|
||||
RES_OK = 0, /* 0: Successful */
|
||||
RES_ERROR, /* 1: R/W Error */
|
||||
RES_WRPRT, /* 2: Write Protected */
|
||||
RES_NOTRDY, /* 3: Not Ready */
|
||||
RES_PARERR /* 4: Invalid Parameter */
|
||||
} DRESULT;
|
||||
|
||||
|
||||
/*---------------------------------------*/
|
||||
/* Prototypes for disk control functions */
|
||||
/*---------------------------------------*/
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Initialize disk drive */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
// Inputs: Physical drive number, which must be 0
|
||||
// Outputs: status (see DSTATUS)
|
||||
DSTATUS disk_initialize(BYTE drv);
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Get disk status */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
// Inputs: Physical drive number, which must be 0
|
||||
// Outputs: status (see DSTATUS)
|
||||
DSTATUS disk_status(BYTE drv);
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Read sector(s) */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
//Inputs: drv Physical drive number (0)
|
||||
// buff Pointer to the data buffer to store read data
|
||||
// sector Start sector number (LBA)
|
||||
// count Number of sectors to read (1..128)
|
||||
// Outputs: status (see DRESULT)
|
||||
DRESULT disk_read(BYTE drv, BYTE *buff, DWORD sector, UINT count);
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Write sector(s) */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
#if _USE_WRITE
|
||||
//Inputs: drv Physical drive number (0)
|
||||
// buff Pointer to the data buffer to write to disk
|
||||
// sector Start sector number (LBA)
|
||||
// count Number of sectors to write (1..128)
|
||||
// Outputs: status (see DRESULT)
|
||||
DRESULT disk_write(BYTE drv, const BYTE *buff, DWORD sector, UINT count);
|
||||
#endif
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Miscellaneous drive controls other than data read/write */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
// Inputs: drv, Physical drive number (0)
|
||||
// cmd, Control command code
|
||||
// buff Pointer to the control data
|
||||
// Outputs: status (see DRESULT)
|
||||
#if _USE_IOCTL
|
||||
DRESULT disk_ioctl(BYTE drv, BYTE cmd, void *buff);
|
||||
#endif
|
||||
|
||||
|
||||
/* Disk Status Bits (DSTATUS) */
|
||||
#define STA_NOINIT 0x01 /* Drive not initialized */
|
||||
#define STA_NODISK 0x02 /* No medium in the drive */
|
||||
#define STA_PROTECT 0x04 /* Write protected */
|
||||
|
||||
|
||||
/* Command code for disk_ioctrl fucntion */
|
||||
|
||||
/* Generic command (Used by FatFs) */
|
||||
#define CTRL_SYNC 0 /* Complete pending write process (needed at _FS_READONLY == 0) */
|
||||
#define GET_SECTOR_COUNT 1 /* Get media size (needed at _USE_MKFS == 1) */
|
||||
#define GET_SECTOR_SIZE 2 /* Get sector size (needed at _MAX_SS != _MIN_SS) */
|
||||
#define GET_BLOCK_SIZE 3 /* Get erase block size (needed at _USE_MKFS == 1) */
|
||||
#define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */
|
||||
|
||||
/* Generic command (Not used by FatFs) */
|
||||
#define CTRL_FORMAT 5 /* Create physical format on the media */
|
||||
#define CTRL_POWER_IDLE 6 /* Put the device idle state */
|
||||
#define CTRL_POWER_OFF 7 /* Put the device off state */
|
||||
#define CTRL_LOCK 8 /* Lock media removal */
|
||||
#define CTRL_UNLOCK 9 /* Unlock media removal */
|
||||
#define CTRL_EJECT 10 /* Eject media */
|
||||
|
||||
/* MMC/SDC specific command (Not used by FatFs) */
|
||||
#define MMC_GET_TYPE 50 /* Get card type */
|
||||
#define MMC_GET_CSD 51 /* Get CSD */
|
||||
#define MMC_GET_CID 52 /* Get CID */
|
||||
#define MMC_GET_OCR 53 /* Get OCR */
|
||||
#define MMC_GET_SDSTAT 54 /* Get SD status */
|
||||
|
||||
/* ATA/CF specific command (Not used by FatFs) */
|
||||
#define ATA_GET_REV 60 /* Get F/W revision */
|
||||
#define ATA_GET_MODEL 61 /* Get model name */
|
||||
#define ATA_GET_SN 62 /* Get serial number */
|
||||
|
||||
|
||||
/* MMC card type flags (MMC_GET_TYPE) */
|
||||
#define CT_MMC 0x01 /* MMC ver 3 */
|
||||
#define CT_SD1 0x02 /* SD ver 1 */
|
||||
#define CT_SD2 0x04 /* SD ver 2 */
|
||||
#define CT_SDC (CT_SD1|CT_SD2) /* SD */
|
||||
#define CT_BLOCK 0x08 /* Block addressing */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
4612
SDCFile/ff.c
Normal file
4612
SDCFile/ff.c
Normal file
File diff suppressed because it is too large
Load Diff
341
SDCFile/ff.h
Normal file
341
SDCFile/ff.h
Normal file
@@ -0,0 +1,341 @@
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ FatFs - FAT file system module include file R0.10c (C)ChaN, 2014
|
||||
/----------------------------------------------------------------------------/
|
||||
/ FatFs module is a generic FAT file system module for small embedded systems.
|
||||
/ This is a free software that opened for education, research and commercial
|
||||
/ developments under license policy of following terms.
|
||||
/
|
||||
/ Copyright (C) 2014, ChaN, all right reserved.
|
||||
/
|
||||
/ * The FatFs module is a free software and there is NO WARRANTY.
|
||||
/ * No restriction on use. You can use, modify and redistribute it for
|
||||
/ personal, non-profit or commercial product UNDER YOUR RESPONSIBILITY.
|
||||
/ * Redistributions of source code must retain the above copyright notice.
|
||||
/
|
||||
/----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef _FATFS
|
||||
#define _FATFS 80376 /* Revision ID */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "integer.h" /* Basic integer types */
|
||||
#include "ffconf.h" /* FatFs configuration options */
|
||||
#if _FATFS != _FFCONF
|
||||
#error Wrong configuration file (ffconf.h).
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Definitions of volume management */
|
||||
|
||||
#if _MULTI_PARTITION /* Multiple partition configuration */
|
||||
typedef struct {
|
||||
BYTE pd; /* Physical drive number */
|
||||
BYTE pt; /* Partition: 0:Auto detect, 1-4:Forced partition) */
|
||||
} PARTITION;
|
||||
extern PARTITION VolToPart[]; /* Volume - Partition resolution table */
|
||||
#define LD2PD(vol) (VolToPart[vol].pd) /* Get physical drive number */
|
||||
#define LD2PT(vol) (VolToPart[vol].pt) /* Get partition index */
|
||||
|
||||
#else /* Single partition configuration */
|
||||
#define LD2PD(vol) (BYTE)(vol) /* Each logical drive is bound to the same physical drive number */
|
||||
#define LD2PT(vol) 0 /* Find first valid partition or in SFD */
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Type of path name strings on FatFs API */
|
||||
|
||||
#if _LFN_UNICODE /* Unicode string */
|
||||
#if !_USE_LFN
|
||||
#error _LFN_UNICODE must be 0 at non-LFN cfg.
|
||||
#endif
|
||||
#ifndef _INC_TCHAR
|
||||
typedef WCHAR TCHAR;
|
||||
#define _T(x) L ## x
|
||||
#define _TEXT(x) L ## x
|
||||
#endif
|
||||
|
||||
#else /* ANSI/OEM string */
|
||||
#ifndef _INC_TCHAR
|
||||
typedef char TCHAR;
|
||||
#define _T(x) x
|
||||
#define _TEXT(x) x
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* File system object structure (FATFS) */
|
||||
|
||||
typedef struct {
|
||||
BYTE fs_type; /* FAT sub-type (0:Not mounted) */
|
||||
BYTE drv; /* Physical drive number */
|
||||
BYTE csize; /* Sectors per cluster (1,2,4...128) */
|
||||
BYTE n_fats; /* Number of FAT copies (1 or 2) */
|
||||
BYTE wflag; /* win[] flag (b0:dirty) */
|
||||
BYTE fsi_flag; /* FSINFO flags (b7:disabled, b0:dirty) */
|
||||
WORD id; /* File system mount ID */
|
||||
WORD n_rootdir; /* Number of root directory entries (FAT12/16) */
|
||||
#if _MAX_SS != _MIN_SS
|
||||
WORD ssize; /* Bytes per sector (512, 1024, 2048 or 4096) */
|
||||
#endif
|
||||
#if _FS_REENTRANT
|
||||
_SYNC_t sobj; /* Identifier of sync object */
|
||||
#endif
|
||||
#if !_FS_READONLY
|
||||
DWORD last_clust; /* Last allocated cluster */
|
||||
DWORD free_clust; /* Number of free clusters */
|
||||
#endif
|
||||
#if _FS_RPATH
|
||||
DWORD cdir; /* Current directory start cluster (0:root) */
|
||||
#endif
|
||||
DWORD n_fatent; /* Number of FAT entries, = number of clusters + 2 */
|
||||
DWORD fsize; /* Sectors per FAT */
|
||||
DWORD volbase; /* Volume start sector */
|
||||
DWORD fatbase; /* FAT start sector */
|
||||
DWORD dirbase; /* Root directory start sector (FAT32:Cluster#) */
|
||||
DWORD database; /* Data start sector */
|
||||
DWORD winsect; /* Current sector appearing in the win[] */
|
||||
BYTE win[_MAX_SS]; /* Disk access window for Directory, FAT (and file data at tiny cfg) */
|
||||
} FATFS;
|
||||
|
||||
|
||||
|
||||
/* File object structure (FIL) */
|
||||
|
||||
typedef struct {
|
||||
FATFS* fs; /* Pointer to the related file system object (**do not change order**) */
|
||||
WORD id; /* Owner file system mount ID (**do not change order**) */
|
||||
BYTE flag; /* Status flags */
|
||||
BYTE err; /* Abort flag (error code) */
|
||||
DWORD fptr; /* File read/write pointer (Zeroed on file open) */
|
||||
DWORD fsize; /* File size */
|
||||
DWORD sclust; /* File start cluster (0:no cluster chain, always 0 when fsize is 0) */
|
||||
DWORD clust; /* Current cluster of fpter (not valid when fprt is 0) */
|
||||
DWORD dsect; /* Sector number appearing in buf[] (0:invalid) */
|
||||
#if !_FS_READONLY
|
||||
DWORD dir_sect; /* Sector number containing the directory entry */
|
||||
BYTE* dir_ptr; /* Pointer to the directory entry in the win[] */
|
||||
#endif
|
||||
#if _USE_FASTSEEK
|
||||
DWORD* cltbl; /* Pointer to the cluster link map table (Nulled on file open) */
|
||||
#endif
|
||||
#if _FS_LOCK
|
||||
UINT lockid; /* File lock ID origin from 1 (index of file semaphore table Files[]) */
|
||||
#endif
|
||||
#if !_FS_TINY
|
||||
BYTE buf[_MAX_SS]; /* File private data read/write window */
|
||||
#endif
|
||||
} FIL;
|
||||
|
||||
|
||||
|
||||
/* Directory object structure (DIR) */
|
||||
|
||||
typedef struct {
|
||||
FATFS* fs; /* Pointer to the owner file system object (**do not change order**) */
|
||||
WORD id; /* Owner file system mount ID (**do not change order**) */
|
||||
WORD index; /* Current read/write index number */
|
||||
DWORD sclust; /* Table start cluster (0:Root dir) */
|
||||
DWORD clust; /* Current cluster */
|
||||
DWORD sect; /* Current sector */
|
||||
BYTE* dir; /* Pointer to the current SFN entry in the win[] */
|
||||
BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */
|
||||
#if _FS_LOCK
|
||||
UINT lockid; /* File lock ID (index of file semaphore table Files[]) */
|
||||
#endif
|
||||
#if _USE_LFN
|
||||
WCHAR* lfn; /* Pointer to the LFN working buffer */
|
||||
WORD lfn_idx; /* Last matched LFN index number (0xFFFF:No LFN) */
|
||||
#endif
|
||||
} DIR;
|
||||
|
||||
|
||||
|
||||
/* File status structure (FILINFO) */
|
||||
|
||||
typedef struct {
|
||||
DWORD fsize; /* File size */
|
||||
WORD fdate; /* Last modified date */
|
||||
WORD ftime; /* Last modified time */
|
||||
BYTE fattrib; /* Attribute */
|
||||
TCHAR fname[13]; /* Short file name (8.3 format) */
|
||||
#if _USE_LFN
|
||||
TCHAR* lfname; /* Pointer to the LFN buffer */
|
||||
UINT lfsize; /* Size of LFN buffer in TCHAR */
|
||||
#endif
|
||||
} FILINFO;
|
||||
|
||||
|
||||
|
||||
/* File function return code (FRESULT) */
|
||||
|
||||
typedef enum {
|
||||
FR_OK = 0, /* (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, /* (13) There is no valid FAT volume */
|
||||
FR_MKFS_ABORTED, /* (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, /* (18) Number of open files > _FS_SHARE */
|
||||
FR_INVALID_PARAMETER /* (19) Given parameter is invalid */
|
||||
} FRESULT;
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
/* FatFs module application interface */
|
||||
|
||||
FRESULT f_open (FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a file */
|
||||
FRESULT f_close (FIL* fp); /* Close an open file object */
|
||||
FRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br); /* Read data from a file */
|
||||
FRESULT f_write (FIL* fp, const void* buff, UINT btw, UINT* bw); /* Write data to a file */
|
||||
FRESULT f_forward (FIL* fp, UINT(*func)(const BYTE*,UINT), UINT btf, UINT* bf); /* Forward data to the stream */
|
||||
FRESULT f_lseek (FIL* fp, DWORD ofs); /* Move file pointer of a file object */
|
||||
FRESULT f_truncate (FIL* fp); /* Truncate file */
|
||||
FRESULT f_sync (FIL* fp); /* Flush cached data of a writing file */
|
||||
FRESULT f_opendir (DIR* dp, const TCHAR* path); /* Open a directory */
|
||||
FRESULT f_closedir (DIR* dp); /* Close an open directory */
|
||||
FRESULT f_readdir (DIR* dp, FILINFO* fno); /* Read a directory item */
|
||||
FRESULT f_mkdir (const TCHAR* path); /* Create a sub directory */
|
||||
FRESULT f_unlink (const TCHAR* path); /* Delete an existing file or directory */
|
||||
FRESULT f_rename (const TCHAR* path_old, const TCHAR* path_new); /* Rename/Move a file or directory */
|
||||
FRESULT f_stat (const TCHAR* path, FILINFO* fno); /* Get file status */
|
||||
FRESULT f_chmod (const TCHAR* path, BYTE value, BYTE mask); /* Change attribute of the file/dir */
|
||||
FRESULT f_utime (const TCHAR* path, const FILINFO* fno); /* Change times-tamp of the file/dir */
|
||||
FRESULT f_chdir (const TCHAR* path); /* Change current directory */
|
||||
FRESULT f_chdrive (const TCHAR* path); /* Change current drive */
|
||||
FRESULT f_getcwd (TCHAR* buff, UINT len); /* Get current directory */
|
||||
FRESULT f_getfree (const TCHAR* path, DWORD* nclst, FATFS** fatfs); /* Get number of free clusters on the drive */
|
||||
FRESULT f_getlabel (const TCHAR* path, TCHAR* label, DWORD* vsn); /* Get volume label */
|
||||
FRESULT f_setlabel (const TCHAR* label); /* Set volume label */
|
||||
FRESULT f_mount (FATFS* fs, const TCHAR* path, BYTE opt); /* Mount/Unmount a logical drive */
|
||||
FRESULT f_mkfs (const TCHAR* path, BYTE sfd, UINT au); /* Create a file system on the volume */
|
||||
FRESULT f_fdisk (BYTE pdrv, const DWORD szt[], void* work); /* Divide a physical drive into some partitions */
|
||||
int f_putc (TCHAR c, FIL* fp); /* Put a character to the file */
|
||||
int f_puts (const TCHAR* str, FIL* cp); /* Put a string to the file */
|
||||
int f_printf (FIL* fp, const TCHAR* str, ...); /* Put a formatted string to the file */
|
||||
TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the file */
|
||||
|
||||
#define f_eof(fp) ((int)((fp)->fptr == (fp)->fsize))
|
||||
#define f_error(fp) ((fp)->err)
|
||||
#define f_tell(fp) ((fp)->fptr)
|
||||
#define f_size(fp) ((fp)->fsize)
|
||||
|
||||
#ifndef EOF
|
||||
#define EOF (-1)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
/* Additional user defined functions */
|
||||
|
||||
/* RTC function */
|
||||
#if !_FS_READONLY && !_FS_NORTC
|
||||
DWORD get_fattime (void);
|
||||
#endif
|
||||
|
||||
/* Unicode support functions */
|
||||
#if _USE_LFN /* Unicode - OEM code conversion */
|
||||
WCHAR ff_convert (WCHAR chr, UINT dir); /* OEM-Unicode bidirectional conversion */
|
||||
WCHAR ff_wtoupper (WCHAR chr); /* Unicode upper-case conversion */
|
||||
#if _USE_LFN == 3 /* Memory functions */
|
||||
void* ff_memalloc (UINT msize); /* Allocate memory block */
|
||||
void ff_memfree (void* mblock); /* Free memory block */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Sync functions */
|
||||
#if _FS_REENTRANT
|
||||
int ff_cre_syncobj (BYTE vol, _SYNC_t* sobj); /* Create a sync object */
|
||||
int ff_req_grant (_SYNC_t sobj); /* Lock sync object */
|
||||
void ff_rel_grant (_SYNC_t sobj); /* Unlock sync object */
|
||||
int ff_del_syncobj (_SYNC_t sobj); /* Delete a sync object */
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
/* Flags and offset address */
|
||||
|
||||
|
||||
/* File access control and file status flags (FIL.flag) */
|
||||
|
||||
#define FA_READ 0x01
|
||||
#define FA_OPEN_EXISTING 0x00
|
||||
|
||||
#if !_FS_READONLY
|
||||
#define FA_WRITE 0x02
|
||||
#define FA_CREATE_NEW 0x04
|
||||
#define FA_CREATE_ALWAYS 0x08
|
||||
#define FA_OPEN_ALWAYS 0x10
|
||||
#define FA__WRITTEN 0x20
|
||||
#define FA__DIRTY 0x40
|
||||
#endif
|
||||
|
||||
|
||||
/* FAT sub type (FATFS.fs_type) */
|
||||
|
||||
#define FS_FAT12 1
|
||||
#define FS_FAT16 2
|
||||
#define FS_FAT32 3
|
||||
|
||||
|
||||
/* File attribute bits for directory entry */
|
||||
|
||||
#define AM_RDO 0x01 /* Read only */
|
||||
#define AM_HID 0x02 /* Hidden */
|
||||
#define AM_SYS 0x04 /* System */
|
||||
#define AM_VOL 0x08 /* Volume label */
|
||||
#define AM_LFN 0x0F /* LFN entry */
|
||||
#define AM_DIR 0x10 /* Directory */
|
||||
#define AM_ARC 0x20 /* Archive */
|
||||
#define AM_MASK 0x3F /* Mask of defined bits */
|
||||
|
||||
|
||||
/* Fast seek feature */
|
||||
#define CREATE_LINKMAP 0xFFFFFFFF
|
||||
|
||||
|
||||
|
||||
/*--------------------------------*/
|
||||
/* Multi-byte word access macros */
|
||||
|
||||
#if _WORD_ACCESS == 1 /* Enable word access to the FAT structure */
|
||||
#define LD_WORD(ptr) (WORD)(*(WORD*)(BYTE*)(ptr))
|
||||
#define LD_DWORD(ptr) (DWORD)(*(DWORD*)(BYTE*)(ptr))
|
||||
#define ST_WORD(ptr,val) *(WORD*)(BYTE*)(ptr)=(WORD)(val)
|
||||
#define ST_DWORD(ptr,val) *(DWORD*)(BYTE*)(ptr)=(DWORD)(val)
|
||||
#else /* Use byte-by-byte access to the FAT structure */
|
||||
#define LD_WORD(ptr) (WORD)(((WORD)*((BYTE*)(ptr)+1)<<8)|(WORD)*(BYTE*)(ptr))
|
||||
#define LD_DWORD(ptr) (DWORD)(((DWORD)*((BYTE*)(ptr)+3)<<24)|((DWORD)*((BYTE*)(ptr)+2)<<16)|((WORD)*((BYTE*)(ptr)+1)<<8)|*(BYTE*)(ptr))
|
||||
#define ST_WORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8)
|
||||
#define ST_DWORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8); *((BYTE*)(ptr)+2)=(BYTE)((DWORD)(val)>>16); *((BYTE*)(ptr)+3)=(BYTE)((DWORD)(val)>>24)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _FATFS */
|
||||
270
SDCFile/ffconf.h
Normal file
270
SDCFile/ffconf.h
Normal file
@@ -0,0 +1,270 @@
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ FatFs - FAT file system module configuration file R0.10c (C)ChaN, 2014
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define _FFCONF 80376 /* Revision ID */
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ Functions and Buffer Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define _FS_TINY 0
|
||||
/* This option switches tiny buffer configuration. (0:Normal or 1:Tiny)
|
||||
/ At the tiny configuration, size of the file object (FIL) is reduced _MAX_SS
|
||||
/ bytes. Instead of private sector buffer eliminated from the file object,
|
||||
/ common sector buffer in the file system object (FATFS) is used for the file
|
||||
/ data transfer. */
|
||||
|
||||
|
||||
#define _FS_READONLY 0
|
||||
/* This option switches read-only configuration. (0:Read/Write or 1:Read-only)
|
||||
/ Read-only configuration removes basic writing API functions, f_write(),
|
||||
/ f_sync(), f_unlink(), f_mkdir(), f_chmod(), f_rename(), f_truncate(),
|
||||
/ f_getfree() and optional writing functions as well. */
|
||||
|
||||
|
||||
#define _FS_MINIMIZE 0
|
||||
/* This option defines minimization level to remove some API functions.
|
||||
/
|
||||
/ 0: All basic functions are enabled.
|
||||
/ 1: f_stat(), f_getfree(), f_unlink(), f_mkdir(), f_chmod(), f_utime(),
|
||||
/ f_truncate() and f_rename() function are removed.
|
||||
/ 2: f_opendir(), f_readdir() and f_closedir() are removed in addition to 1.
|
||||
/ 3: f_lseek() function is removed in addition to 2. */
|
||||
|
||||
|
||||
#define _USE_STRFUNC 0
|
||||
/* This option switches string functions, f_gets(), f_putc(), f_puts() and
|
||||
/ f_printf().
|
||||
/
|
||||
/ 0: Disable string functions.
|
||||
/ 1: Enable without LF-CRLF conversion.
|
||||
/ 2: Enable with LF-CRLF conversion. */
|
||||
|
||||
|
||||
#define _USE_MKFS 1
|
||||
/* This option switches f_mkfs() function. (0:Disable or 1:Enable)
|
||||
/ To enable it, also _FS_READONLY need to be set to 0. */
|
||||
|
||||
|
||||
#define _USE_FASTSEEK 0
|
||||
/* This option switches fast seek feature. (0:Disable or 1:Enable) */
|
||||
|
||||
|
||||
#define _USE_LABEL 1
|
||||
/* This option switches volume label functions, f_getlabel() and f_setlabel().
|
||||
/ (0:Disable or 1:Enable) */
|
||||
|
||||
|
||||
#define _USE_FORWARD 0
|
||||
/* This option switches f_forward() function. (0:Disable or 1:Enable) */
|
||||
/* To enable it, also _FS_TINY need to be set to 1. */
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ Locale and Namespace Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define _CODE_PAGE 932
|
||||
/* This option specifies the OEM code page to be used on the target system.
|
||||
/ Incorrect setting of the code page can cause a file open failure.
|
||||
/
|
||||
/ 932 - Japanese Shift_JIS (DBCS, OEM, Windows)
|
||||
/ 936 - Simplified Chinese GBK (DBCS, OEM, Windows)
|
||||
/ 949 - Korean (DBCS, OEM, Windows)
|
||||
/ 950 - Traditional Chinese Big5 (DBCS, OEM, Windows)
|
||||
/ 1250 - Central Europe (Windows)
|
||||
/ 1251 - Cyrillic (Windows)
|
||||
/ 1252 - Latin 1 (Windows)
|
||||
/ 1253 - Greek (Windows)
|
||||
/ 1254 - Turkish (Windows)
|
||||
/ 1255 - Hebrew (Windows)
|
||||
/ 1256 - Arabic (Windows)
|
||||
/ 1257 - Baltic (Windows)
|
||||
/ 1258 - Vietnam (OEM, Windows)
|
||||
/ 437 - U.S. (OEM)
|
||||
/ 720 - Arabic (OEM)
|
||||
/ 737 - Greek (OEM)
|
||||
/ 775 - Baltic (OEM)
|
||||
/ 850 - Multilingual Latin 1 (OEM)
|
||||
/ 858 - Multilingual Latin 1 + Euro (OEM)
|
||||
/ 852 - Latin 2 (OEM)
|
||||
/ 855 - Cyrillic (OEM)
|
||||
/ 866 - Russian (OEM)
|
||||
/ 857 - Turkish (OEM)
|
||||
/ 862 - Hebrew (OEM)
|
||||
/ 874 - Thai (OEM, Windows)
|
||||
/ 1 - ASCII (No extended character. Valid for only non-LFN configuration.) */
|
||||
|
||||
|
||||
#define _USE_LFN 0
|
||||
#define _MAX_LFN 255
|
||||
/* The _USE_LFN option switches the LFN feature.
|
||||
/
|
||||
/ 0: Disable LFN feature. _MAX_LFN has no effect.
|
||||
/ 1: Enable LFN with static working buffer on the BSS. Always NOT thread-safe.
|
||||
/ 2: Enable LFN with dynamic working buffer on the STACK.
|
||||
/ 3: Enable LFN with dynamic working buffer on the HEAP.
|
||||
/
|
||||
/ When enable the LFN feature, Unicode handling functions (option/unicode.c) must
|
||||
/ be added to the project. The LFN working buffer occupies (_MAX_LFN + 1) * 2 bytes.
|
||||
/ When use stack for the working buffer, take care on stack overflow. When use heap
|
||||
/ memory for the working buffer, memory management functions, ff_memalloc() and
|
||||
/ ff_memfree(), must be added to the project. */
|
||||
|
||||
|
||||
#define _LFN_UNICODE 0
|
||||
/* This option switches character encoding on the API. (0:ANSI/OEM or 1:Unicode)
|
||||
/ To use Unicode string for the path name, enable LFN feature and set _LFN_UNICODE
|
||||
/ to 1. This option also affects behavior of string I/O functions. */
|
||||
|
||||
|
||||
#define _STRF_ENCODE 3
|
||||
/* When _LFN_UNICODE is 1, this option selects the character encoding on the file to
|
||||
/ be read/written via string I/O functions, f_gets(), f_putc(), f_puts and f_printf().
|
||||
/
|
||||
/ 0: ANSI/OEM
|
||||
/ 1: UTF-16LE
|
||||
/ 2: UTF-16BE
|
||||
/ 3: UTF-8
|
||||
/
|
||||
/ When _LFN_UNICODE is 0, this option has no effect. */
|
||||
|
||||
|
||||
#define _FS_RPATH 2
|
||||
/* This option configures relative path feature.
|
||||
/
|
||||
/ 0: Disable relative path feature and remove related functions.
|
||||
/ 1: Enable relative path feature. f_chdir() and f_chdrive() are available.
|
||||
/ 2: f_getcwd() function is available in addition to 1.
|
||||
/
|
||||
/ Note that directory items read via f_readdir() are affected by this option. */
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ Drive/Volume Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define _VOLUMES 1
|
||||
/* Number of volumes (logical drives) to be used. */
|
||||
|
||||
|
||||
#define _STR_VOLUME_ID 0
|
||||
#define _VOLUME_STRS "RAM","NAND","CF","SD1","SD2","USB1","USB2","USB3"
|
||||
/* _STR_VOLUME_ID option switches string volume ID feature.
|
||||
/ When _STR_VOLUME_ID is set to 1, also pre-defined strings can be used as drive
|
||||
/ number in the path name. _VOLUME_STRS defines the drive ID strings for each
|
||||
/ logical drives. Number of items must be equal to _VOLUMES. Valid characters for
|
||||
/ the drive ID strings are: A-Z and 0-9. */
|
||||
|
||||
|
||||
#define _MULTI_PARTITION 0
|
||||
/* This option switches multi-partition feature. By default (0), each logical drive
|
||||
/ number is bound to the same physical drive number and only an FAT volume found on
|
||||
/ the physical drive will be mounted. When multi-partition feature is enabled (1),
|
||||
/ each logical drive number is bound to arbitrary physical drive and partition
|
||||
/ listed in the VolToPart[]. Also f_fdisk() funciton will be enabled. */
|
||||
|
||||
|
||||
#define _MIN_SS 512
|
||||
#define _MAX_SS 512
|
||||
/* These options configure the range of sector size to be supported. (512, 1024,
|
||||
/ 2048 or 4096) Always set both 512 for most systems, all type of memory cards and
|
||||
/ harddisk. But a larger value may be required for on-board flash memory and some
|
||||
/ type of optical media. When _MAX_SS is larger than _MIN_SS, FatFs is configured
|
||||
/ to variable sector size and GET_SECTOR_SIZE command must be implemented to the
|
||||
/ disk_ioctl() function. */
|
||||
|
||||
|
||||
#define _USE_TRIM 0
|
||||
/* This option switches ATA-TRIM feature. (0:Disable or 1:Enable)
|
||||
/ To enable Trim feature, also CTRL_TRIM command should be implemented to the
|
||||
/ disk_ioctl() function. */
|
||||
|
||||
|
||||
#define _FS_NOFSINFO 0
|
||||
/* If you need to know correct free space on the FAT32 volume, set bit 0 of this
|
||||
/ option, and f_getfree() function at first time after volume mount will force
|
||||
/ a full FAT scan. Bit 1 controls the use of last allocated cluster number.
|
||||
/
|
||||
/ bit0=0: Use free cluster count in the FSINFO if available.
|
||||
/ bit0=1: Do not trust free cluster count in the FSINFO.
|
||||
/ bit1=0: Use last allocated cluster number in the FSINFO if available.
|
||||
/ bit1=1: Do not trust last allocated cluster number in the FSINFO.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ System Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define _FS_NORTC 1
|
||||
#define _NORTC_MON 11
|
||||
#define _NORTC_MDAY 29
|
||||
#define _NORTC_YEAR 2014
|
||||
/* The _FS_NORTC option switches timestamp feature. If the system does not have
|
||||
/ an RTC function or valid timestamp is not needed, set _FS_NORTC to 1 to disable
|
||||
/ the timestamp feature. All objects modified by FatFs will have a fixed timestamp
|
||||
/ defined by _NORTC_MON, _NORTC_MDAY and _NORTC_YEAR.
|
||||
/ When timestamp feature is enabled (_FS_NORTC == 0), get_fattime() function need
|
||||
/ to be added to the project to read current time form RTC. _NORTC_MON,
|
||||
/ _NORTC_MDAY and _NORTC_YEAR have no effect.
|
||||
/ These options have no effect at read-only configuration (_FS_READONLY == 1). */
|
||||
|
||||
|
||||
#define _FS_LOCK 0
|
||||
/* The _FS_LOCK option switches file lock feature to control duplicated file open
|
||||
/ and illegal operation to open objects. This option must be 0 when _FS_READONLY
|
||||
/ is 1.
|
||||
/
|
||||
/ 0: Disable file lock feature. To avoid volume corruption, application program
|
||||
/ should avoid illegal open, remove and rename to the open objects.
|
||||
/ >0: Enable file lock feature. The value defines how many files/sub-directories
|
||||
/ can be opened simultaneously under file lock control. Note that the file
|
||||
/ lock feature is independent of re-entrancy. */
|
||||
|
||||
|
||||
#define _FS_REENTRANT 0
|
||||
#define _FS_TIMEOUT 1000
|
||||
#define _SYNC_t HANDLE
|
||||
/* The _FS_REENTRANT option switches the re-entrancy (thread safe) of the FatFs
|
||||
/ module itself. Note that regardless of this option, file access to different
|
||||
/ volume is always re-entrant and volume control functions, f_mount(), f_mkfs()
|
||||
/ and f_fdisk() function, are always not re-entrant. Only file/directory access
|
||||
/ to the same volume is under control of this feature.
|
||||
/
|
||||
/ 0: Disable re-entrancy. _FS_TIMEOUT and _SYNC_t have no effect.
|
||||
/ 1: Enable re-entrancy. Also user provided synchronization handlers,
|
||||
/ ff_req_grant(), ff_rel_grant(), ff_del_syncobj() and ff_cre_syncobj()
|
||||
/ function, must be added to the project. Samples are available in
|
||||
/ option/syscall.c.
|
||||
/
|
||||
/ The _FS_TIMEOUT defines timeout period in unit of time tick.
|
||||
/ The _SYNC_t defines O/S dependent sync object type. e.g. HANDLE, ID, OS_EVENT*,
|
||||
/ SemaphoreHandle_t and etc.. */
|
||||
|
||||
|
||||
#define _WORD_ACCESS 0
|
||||
/* The _WORD_ACCESS option is an only platform dependent option. It defines
|
||||
/ which access method is used to the word data on the FAT volume.
|
||||
/
|
||||
/ 0: Byte-by-byte access. Always compatible with all platforms.
|
||||
/ 1: Word access. Do not choose this unless under both the following conditions.
|
||||
/
|
||||
/ * Address misaligned memory access is always allowed to ALL instructions.
|
||||
/ * Byte order on the memory is little-endian.
|
||||
/
|
||||
/ If it is the case, _WORD_ACCESS can also be set to 1 to reduce code size.
|
||||
/ Following table shows allowable settings of some processor types.
|
||||
/
|
||||
/ ARM7TDMI 0 ColdFire 0 V850E 0
|
||||
/ Cortex-M3 0 Z80 0/1 V850ES 0/1
|
||||
/ Cortex-M0 0 x86 0/1 TLCS-870 0/1
|
||||
/ AVR 0/1 RX600(LE) 0/1 TLCS-900 0/1
|
||||
/ AVR32 0 RL78 0 R32C 0
|
||||
/ PIC18 0/1 SH-2 0 M16C 0/1
|
||||
/ PIC24 0 H8S 0 MSP430 0
|
||||
/ PIC32 0 H8/300H 0 8051 0/1
|
||||
*/
|
||||
|
||||
33
SDCFile/integer.h
Normal file
33
SDCFile/integer.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/*-------------------------------------------*/
|
||||
/* Integer type definitions for FatFs module */
|
||||
/*-------------------------------------------*/
|
||||
|
||||
#ifndef _FF_INTEGER
|
||||
#define _FF_INTEGER
|
||||
|
||||
#ifdef _WIN32 /* FatFs development platform */
|
||||
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#else /* Embedded platform */
|
||||
|
||||
/* This type MUST be 8 bit */
|
||||
typedef unsigned char BYTE;
|
||||
|
||||
/* These types MUST be 16 bit */
|
||||
typedef short SHORT;
|
||||
typedef unsigned short WORD;
|
||||
typedef unsigned short WCHAR;
|
||||
|
||||
/* These types MUST be 16 bit or 32 bit */
|
||||
typedef int INT;
|
||||
typedef unsigned int UINT;
|
||||
|
||||
/* These types MUST be 32 bit */
|
||||
typedef long LONG;
|
||||
typedef unsigned long DWORD;
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
BIN
SDCFile/main4.png
Normal file
BIN
SDCFile/main4.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
67
SDCFile/mspm0g3507.cmd
Executable file
67
SDCFile/mspm0g3507.cmd
Executable file
@@ -0,0 +1,67 @@
|
||||
/*****************************************************************************
|
||||
|
||||
Copyright (C) 2023 Texas Instruments Incorporated - http://www.ti.com/
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
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.
|
||||
|
||||
Neither the name of Texas Instruments Incorporated 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 COPYRIGHT HOLDERS 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 COPYRIGHT
|
||||
OWNER 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.
|
||||
|
||||
*****************************************************************************/
|
||||
-uinterruptVectors
|
||||
|
||||
MEMORY
|
||||
{
|
||||
FLASH (RX) : origin = 0x00000000, length = 0x00020000
|
||||
SRAM (RWX) : origin = 0x20200000, length = 0x00008000
|
||||
BCR_CONFIG (R) : origin = 0x41C00000, length = 0x00000080
|
||||
BSL_CONFIG (R) : origin = 0x41C00100, length = 0x00000080
|
||||
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.intvecs: > 0x00000000
|
||||
.text : palign(8) {} > FLASH
|
||||
.const : palign(8) {} > FLASH
|
||||
.cinit : palign(8) {} > FLASH
|
||||
.pinit : palign(8) {} > FLASH
|
||||
.rodata : palign(8) {} > FLASH
|
||||
.ARM.exidx : palign(8) {} > FLASH
|
||||
.init_array : palign(8) {} > FLASH
|
||||
.binit : palign(8) {} > FLASH
|
||||
.TI.ramfunc : load = FLASH, palign(8), run=SRAM, table(BINIT)
|
||||
|
||||
.vtable : > SRAM
|
||||
.args : > SRAM
|
||||
.data : > SRAM
|
||||
.bss : > SRAM
|
||||
.sysmem : > SRAM
|
||||
.stack : > SRAM (HIGH)
|
||||
|
||||
.BCRConfig : {} > BCR_CONFIG
|
||||
.BSLConfig : {} > BSL_CONFIG
|
||||
}
|
||||
142
SDCFile/targetConfigs/MSPM0G3507.ccxml
Normal file
142
SDCFile/targetConfigs/MSPM0G3507.ccxml
Normal file
@@ -0,0 +1,142 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<configurations XML_version="1.2" id="configurations_0">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<configuration XML_version="1.2" id="configuration_0">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<instance XML_version="1.2" desc="Texas Instruments XDS110 USB Debug Probe" href="connections/TIXDS110_Connection.xml" id="Texas Instruments XDS110 USB Debug Probe" xml="TIXDS110_Connection.xml" xmlpath="connections"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<connection XML_version="1.2" id="Texas Instruments XDS110 USB Debug Probe">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<instance XML_version="1.2" href="drivers/tixds510cs_dap.xml" id="drivers" xml="tixds510cs_dap.xml" xmlpath="drivers"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<instance XML_version="1.2" href="drivers/tixds510cortexM0.xml" id="drivers" xml="tixds510cortexM0.xml" xmlpath="drivers"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<instance XML_version="1.2" href="drivers/tixds510sec_ap.xml" id="drivers" xml="tixds510sec_ap.xml" xmlpath="drivers"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<property Type="choicelist" Value="1" id="The JTAG TCLK Frequency (MHz)">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<choice Name="Fixed with user specified value" value="SPECIFIC">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<property Type="stringfield" Value="1MHz" id="-- Enter a value from 100.0kHz to 2.5MHz"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</choice>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</property>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<property Type="choicelist" Value="2" id="SWD Mode Settings">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<choice Name="SWD Mode - Aux COM port is target TDO pin" value="nothing"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</property>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<platform XML_version="1.2" id="platform_0">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<instance XML_version="1.2" desc="MSPM0G3507" href="devices/MSPM0G3507.xml" id="MSPM0G3507" xml="MSPM0G3507.xml" xmlpath="devices"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</platform>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</connection>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</configuration>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</configurations>
|
||||
9
SDCFile/targetConfigs/readme.txt
Normal file
9
SDCFile/targetConfigs/readme.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
The 'targetConfigs' folder contains target-configuration (.ccxml) files, automatically generated based
|
||||
on the device and connection settings specified in your project on the Properties > General page.
|
||||
|
||||
Please note that in automatic target-configuration management, changes to the project's device and/or
|
||||
connection settings will either modify an existing or generate a new target-configuration file. Thus,
|
||||
if you manually edit these auto-generated files, you may need to re-apply your changes. Alternatively,
|
||||
you may create your own target-configuration file for this project and manage it manually. You can
|
||||
always switch back to automatic target-configuration management by checking the "Manage the project's
|
||||
target-configuration automatically" checkbox on the project's Properties > General page.
|
||||
200
SDCFile/ticlang/startup_mspm0g3507_ticlang.c
Normal file
200
SDCFile/ticlang/startup_mspm0g3507_ticlang.c
Normal file
@@ -0,0 +1,200 @@
|
||||
/*****************************************************************************
|
||||
Special MSPM0_ValvanoWare version with Hardfault handler implemented
|
||||
Jonathan Valvano 12/19/2024
|
||||
|
||||
Copyright (C) 2023 Texas Instruments Incorporated - http://www.ti.com/
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
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.
|
||||
|
||||
Neither the name of Texas Instruments Incorporated 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 COPYRIGHT HOLDERS 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 COPYRIGHT
|
||||
OWNER 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.
|
||||
|
||||
*****************************************************************************/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <ti/devices/msp/msp.h>
|
||||
|
||||
/* Linker variable that marks the top of the stack. */
|
||||
extern unsigned long __STACK_END;
|
||||
|
||||
/* External declaration for the reset handler that is to be called when the */
|
||||
/* processor is started */
|
||||
extern __NO_RETURN void __PROGRAM_START(void);
|
||||
|
||||
/* Forward declaration of the default fault handlers. */
|
||||
void Default_Handler (void) __attribute__((weak));
|
||||
void HardFault_Handler (void) __attribute__((weak));
|
||||
extern void Reset_Handler (void) __attribute__((weak));
|
||||
|
||||
/* Processor Exceptions */
|
||||
extern void NMI_Handler (void) __attribute__((weak, alias("Default_Handler")));
|
||||
extern void SVC_Handler (void) __attribute__((weak, alias("Default_Handler")));
|
||||
extern void PendSV_Handler (void) __attribute__((weak, alias("Default_Handler")));
|
||||
extern void SysTick_Handler (void) __attribute__((weak, alias("Default_Handler")));
|
||||
|
||||
/* Device Specific Interrupt Handlers */
|
||||
extern void GROUP0_IRQHandler (void) __attribute__((weak, alias("Default_Handler")));
|
||||
extern void GROUP1_IRQHandler (void) __attribute__((weak, alias("Default_Handler")));
|
||||
extern void TIMG8_IRQHandler (void) __attribute__((weak, alias("Default_Handler")));
|
||||
extern void UART3_IRQHandler (void) __attribute__((weak, alias("Default_Handler")));
|
||||
extern void ADC0_IRQHandler (void) __attribute__((weak, alias("Default_Handler")));
|
||||
extern void ADC1_IRQHandler (void) __attribute__((weak, alias("Default_Handler")));
|
||||
extern void CANFD0_IRQHandler (void) __attribute__((weak, alias("Default_Handler")));
|
||||
extern void DAC0_IRQHandler (void) __attribute__((weak, alias("Default_Handler")));
|
||||
extern void SPI0_IRQHandler (void) __attribute__((weak, alias("Default_Handler")));
|
||||
extern void SPI1_IRQHandler (void) __attribute__((weak, alias("Default_Handler")));
|
||||
extern void UART1_IRQHandler (void) __attribute__((weak, alias("Default_Handler")));
|
||||
extern void UART2_IRQHandler (void) __attribute__((weak, alias("Default_Handler")));
|
||||
extern void UART0_IRQHandler (void) __attribute__((weak, alias("Default_Handler")));
|
||||
extern void TIMG0_IRQHandler (void) __attribute__((weak, alias("Default_Handler")));
|
||||
extern void TIMG6_IRQHandler (void) __attribute__((weak, alias("Default_Handler")));
|
||||
extern void TIMA0_IRQHandler (void) __attribute__((weak, alias("Default_Handler")));
|
||||
extern void TIMA1_IRQHandler (void) __attribute__((weak, alias("Default_Handler")));
|
||||
extern void TIMG7_IRQHandler (void) __attribute__((weak, alias("Default_Handler")));
|
||||
extern void TIMG12_IRQHandler (void) __attribute__((weak, alias("Default_Handler")));
|
||||
extern void I2C0_IRQHandler (void) __attribute__((weak, alias("Default_Handler")));
|
||||
extern void I2C1_IRQHandler (void) __attribute__((weak, alias("Default_Handler")));
|
||||
extern void AES_IRQHandler (void) __attribute__((weak, alias("Default_Handler")));
|
||||
extern void RTC_IRQHandler (void) __attribute__((weak, alias("Default_Handler")));
|
||||
extern void DMA_IRQHandler (void) __attribute__((weak, alias("Default_Handler")));
|
||||
|
||||
|
||||
/* Interrupt vector table. Note that the proper constructs must be placed on this to */
|
||||
/* ensure that it ends up at physical address 0x0000.0000 or at the start of */
|
||||
/* the program if located at a start address other than 0. */
|
||||
#if defined (__ARM_ARCH) && (__ARM_ARCH != 0)
|
||||
void (* const interruptVectors[])(void) __attribute((used)) __attribute__((section (".intvecs"))) =
|
||||
#elif defined (__TI_ARM__)
|
||||
#pragma RETAIN(interruptVectors)
|
||||
#pragma DATA_SECTION(interruptVectors, ".intvecs")
|
||||
void (* const interruptVectors[])(void) =
|
||||
#else
|
||||
#error "Compiler not supported"
|
||||
#endif
|
||||
{
|
||||
(void (*)(void))((uint32_t)&__STACK_END),
|
||||
/* The initial stack pointer */
|
||||
Reset_Handler, /* The reset handler */
|
||||
NMI_Handler, /* The NMI handler */
|
||||
HardFault_Handler, /* The hard fault handler */
|
||||
0, /* Reserved */
|
||||
0, /* Reserved */
|
||||
0, /* Reserved */
|
||||
0, /* Reserved */
|
||||
0, /* Reserved */
|
||||
0, /* Reserved */
|
||||
0, /* Reserved */
|
||||
SVC_Handler, /* SVCall handler */
|
||||
0, /* Reserved */
|
||||
0, /* Reserved */
|
||||
PendSV_Handler, /* The PendSV handler */
|
||||
SysTick_Handler, /* SysTick handler */
|
||||
GROUP0_IRQHandler, /* GROUP0 interrupt handler */
|
||||
GROUP1_IRQHandler, /* GROUP1 interrupt handler */
|
||||
TIMG8_IRQHandler, /* TIMG8 interrupt handler */
|
||||
UART3_IRQHandler, /* UART3 interrupt handler */
|
||||
ADC0_IRQHandler, /* ADC0 interrupt handler */
|
||||
ADC1_IRQHandler, /* ADC1 interrupt handler */
|
||||
CANFD0_IRQHandler, /* CANFD0 interrupt handler */
|
||||
DAC0_IRQHandler, /* DAC0 interrupt handler */
|
||||
0, /* Reserved */
|
||||
SPI0_IRQHandler, /* SPI0 interrupt handler */
|
||||
SPI1_IRQHandler, /* SPI1 interrupt handler */
|
||||
0, /* Reserved */
|
||||
0, /* Reserved */
|
||||
UART1_IRQHandler, /* UART1 interrupt handler */
|
||||
UART2_IRQHandler, /* UART2 interrupt handler */
|
||||
UART0_IRQHandler, /* UART0 interrupt handler */
|
||||
TIMG0_IRQHandler, /* TIMG0 interrupt handler */
|
||||
TIMG6_IRQHandler, /* TIMG6 interrupt handler */
|
||||
TIMA0_IRQHandler, /* TIMA0 interrupt handler */
|
||||
TIMA1_IRQHandler, /* TIMA1 interrupt handler */
|
||||
TIMG7_IRQHandler, /* TIMG7 interrupt handler */
|
||||
TIMG12_IRQHandler, /* TIMG12 interrupt handler */
|
||||
0, /* Reserved */
|
||||
0, /* Reserved */
|
||||
I2C0_IRQHandler, /* I2C0 interrupt handler */
|
||||
I2C1_IRQHandler, /* I2C1 interrupt handler */
|
||||
0, /* Reserved */
|
||||
0, /* Reserved */
|
||||
AES_IRQHandler, /* AES interrupt handler */
|
||||
0, /* Reserved */
|
||||
RTC_IRQHandler, /* RTC interrupt handler */
|
||||
DMA_IRQHandler, /* DMA interrupt handler */
|
||||
|
||||
};
|
||||
|
||||
/* Forward declaration of the default fault handlers. */
|
||||
/* This is the code that gets called when the processor first starts execution */
|
||||
/* following a reset event. Only the absolutely necessary set is performed, */
|
||||
/* after which the application supplied entry() routine is called. Any fancy */
|
||||
/* actions (such as making decisions based on the reset cause register, and */
|
||||
/* resetting the bits in that register) are left solely in the hands of the */
|
||||
/* application. */
|
||||
void Reset_Handler(void)
|
||||
{
|
||||
/* Jump to the ticlang C Initialization Routine. */
|
||||
__asm(" .global _c_int00\n"
|
||||
" b _c_int00");
|
||||
}
|
||||
// fetch the PC that triggered the hard fault
|
||||
void HardFault_Handler(void) {
|
||||
__asm(" MOV R7,SP\n" // this code prevents a hardfault within the hardfault handler
|
||||
" LDR R4,=0x20200000\n" // start of RAM
|
||||
" CMP R7,R4\n"
|
||||
" BLO fault\n" // skip if bad SP
|
||||
" LDR R5,=0x20207FE0\n" // end of RAM-32
|
||||
" CMP R7,R5\n"
|
||||
" BHI fault\n" // skip if bad SP
|
||||
" LDR R6,[SP,#24]\n" // R6=previous PC
|
||||
"fault:");
|
||||
while (1) {
|
||||
// option 1) if SP points to valid RAM (0x20200000 to 0x20207FFC)
|
||||
// then R6 has PC that caused the fault
|
||||
// option 2) if SP is not 0x20200000 to 0x20207FFC then there was a stack overflow
|
||||
// if you're here, you had a hardfault
|
||||
}
|
||||
}
|
||||
/* This is the code that gets called when the processor receives an unexpected */
|
||||
/* interrupt. This simply enters an infinite loop, preserving the system state */
|
||||
/* for examination by a debugger. */
|
||||
void Default_Handler(void)
|
||||
{
|
||||
__asm(" MOV R7,SP\n"
|
||||
" LDR R4,=0x20200000\n"
|
||||
" CMP R7,R4\n"
|
||||
" BLO dfault\n" // bad SP
|
||||
" LDR R5,=0x20207FE0\n"
|
||||
" CMP R7,R5\n"
|
||||
" BHI fault\n" // bad SP
|
||||
" LDR R6,[SP,#24]\n" // previous PC
|
||||
"dfault:");
|
||||
/* Enter an infinite loop. */
|
||||
while(1){
|
||||
// R6 has value of the PC when the interrupt was triggered
|
||||
// you are here probably because you armed an interrupt, but mistyped the ISR name
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user