Compare commits

..

No commits in common. "bcefaab8479d3bca0291025491010cbc52c239ce" and "470cf77cac110ac5cf71f3022e46396f105c3f4f" have entirely different histories.

105 changed files with 8501 additions and 34474 deletions

View File

@ -2,13 +2,13 @@
<?ccsproject version="1.0"?> <?ccsproject version="1.0"?>
<projectOptions> <projectOptions>
<ccsVariant value="50:Theia-based"/> <ccsVariant value="50:Theia-based"/>
<ccsVersion value="70.2.0"/> <ccsVersion value="70.1.0"/>
<deviceFamily value="MSP430"/> <deviceFamily value="MSP430"/>
<executableActions value=""/> <executableActions value=""/>
<createSlaveProjects value=""/> <createSlaveProjects value=""/>
<templateProperties value="id=OutOfBox_MSP-EXP430FR2355.projectspec.ESR-11"/> <templateProperties value="id=msp430fr2355_gc_simple_json.projectspec.ESR-G11"/>
<connection value="common/targetdb/connections/TIMSP430-USB.xml"/> <connection value="common/targetdb/connections/TIMSP430-USB.xml"/>
<activeTargetConfiguration value="targetConfigs/MSP430FR2355.ccxml"/> <activeTargetConfiguration value="targetConfigs/MSP430FR2355.ccxml"/>
<origin value="/home/frederik/ti/msp430ware_3_80_14_01/examples/boards/MSP-EXP430FR2355/MSP-EXP430FR2355_Software_Examples/Firmware/Source/OutOfBox_MSP-EXP430FR2355/CCS/OutOfBox_MSP-EXP430FR2355.projectspec"/> <origin value="/home/frederik/ti/msp430ware_3_80_14_01/gui_composer/examples/MSP-EXP430FR2355/streaming/gc_simple_json/ccs/msp430fr2355_gc_simple_json.projectspec"/>
<filesToOpen value="main.c"/> <filesToOpen value=""/>
</projectOptions> </projectOptions>

View File

@ -6,3 +6,6 @@ CompileFlags:
Diagnostics: Diagnostics:
Suppress: '*' Suppress: '*'
InlayHints:
Enabled: No

191
.cproject
View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage"> <?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings"> <storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="com.ti.ccstudio.buildDefinitions.MSP430.Debug.883036648"> <cconfiguration id="com.ti.ccstudio.buildDefinitions.MSP430.Debug.1480263499">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.ti.ccstudio.buildDefinitions.MSP430.Debug.883036648" moduleId="org.eclipse.cdt.core.settings" name="Debug"> <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.ti.ccstudio.buildDefinitions.MSP430.Debug.1480263499" moduleId="org.eclipse.cdt.core.settings" name="Debug">
<externalSettings/> <externalSettings/>
<extensions> <extensions>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="com.ti.ccs.project.ErrorParser"/> <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="com.ti.ccs.project.ErrorParser"/>
@ -10,10 +10,10 @@
</extensions> </extensions>
</storageModule> </storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0"> <storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="out" artifactName="${ProjName}" buildProperties="" cleanCommand="${CG_CLEAN_CMD}" description="" id="com.ti.ccstudio.buildDefinitions.MSP430.Debug.883036648" name="Debug" parent="com.ti.ccstudio.buildDefinitions.MSP430.Debug"> <configuration artifactExtension="out" artifactName="${ProjName}" buildProperties="" cleanCommand="${CG_CLEAN_CMD}" description="" id="com.ti.ccstudio.buildDefinitions.MSP430.Debug.1480263499" name="Debug" parent="com.ti.ccstudio.buildDefinitions.MSP430.Debug">
<folderInfo id="com.ti.ccstudio.buildDefinitions.MSP430.Debug.883036648." name="/" resourcePath=""> <folderInfo id="com.ti.ccstudio.buildDefinitions.MSP430.Debug.1480263499." name="/" resourcePath="">
<toolChain id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.DebugToolchain.1528237250" name="TI Build Tools" secondaryOutputs="com.ti.ccstudio.buildDefinitions.MSP430_21.6.hex.outputType__BIN.108945458" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.DebugToolchain" targetTool="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.linkerDebug.1198846171"> <toolChain id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.DebugToolchain.467192015" name="TI Build Tools" secondaryOutputs="" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.DebugToolchain" targetTool="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.linkerDebug.1015511133">
<option id="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS.121565328" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS" valueType="stringList"> <option id="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS.1780803083" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS" valueType="stringList">
<listOptionValue value="DEVICE_CONFIGURATION_ID=MSP430FR2355"/> <listOptionValue value="DEVICE_CONFIGURATION_ID=MSP430FR2355"/>
<listOptionValue value="DEVICE_CORE_ID="/> <listOptionValue value="DEVICE_CORE_ID="/>
<listOptionValue value="DEVICE_ENDIANNESS=little"/> <listOptionValue value="DEVICE_ENDIANNESS=little"/>
@ -25,73 +25,68 @@
<listOptionValue value="PRODUCTS="/> <listOptionValue value="PRODUCTS="/>
<listOptionValue value="PRODUCT_MACRO_IMPORTS={}"/> <listOptionValue value="PRODUCT_MACRO_IMPORTS={}"/>
</option> </option>
<option id="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION.1502413104" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION" value="21.6.1.LTS" valueType="string"/> <option id="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION.1629037805" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION" value="21.6.1.LTS" valueType="string"/>
<targetPlatform id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.targetPlatformDebug.1741833122" name="Platform" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.targetPlatformDebug"/> <targetPlatform id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.targetPlatformDebug.1138407171" name="Platform" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.targetPlatformDebug"/>
<builder buildPath="${BuildDirectory}" id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.builderDebug.235413854" keepEnvironmentInBuildfile="false" name="GNU Make" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.builderDebug"/> <builder buildPath="${BuildDirectory}" id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.builderDebug.1781188217" name="GNU Make.Debug" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.builderDebug"/>
<tool id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.compilerDebug.281898955" name="MSP430 Compiler" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.compilerDebug"> <tool id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.compilerDebug.878730430" name="MSP430 Compiler" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.compilerDebug">
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DEFINE.925722857" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DEFINE" valueType="definedSymbols"> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DEFINE.1352210013" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DEFINE" valueType="definedSymbols">
<listOptionValue value="__MSP430FR2355__"/> <listOptionValue value="__MSP430FR2355__"/>
<listOptionValue value="_FRWP_ENABLE"/> <listOptionValue value="_FRWP_ENABLE"/>
<listOptionValue value="_INFO_FRWP_ENABLE"/> <listOptionValue value="_INFO_FRWP_ENABLE"/>
<listOptionValue value="__ENABLE_GUI_COMM=1"/>
<listOptionValue value="GLOBAL_Q=8"/>
</option> </option>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.ADVICE__HW_CONFIG.564776162" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.ADVICE__HW_CONFIG" value="all" valueType="string"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.ADVICE__HW_CONFIG.232293091" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.ADVICE__HW_CONFIG" value="all" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.USE_HW_MPY.213607259" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.USE_HW_MPY" value="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.USE_HW_MPY.F5" valueType="enumerated"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.USE_HW_MPY.1457847178" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.USE_HW_MPY" value="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.USE_HW_MPY.F5" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.SILICON_ERRATA.CPU21.804238369" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.SILICON_ERRATA.CPU21" value="true" valueType="boolean"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.SILICON_ERRATA.CPU21.798980990" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.SILICON_ERRATA.CPU21" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.SILICON_ERRATA.CPU22.253852873" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.SILICON_ERRATA.CPU22" value="true" valueType="boolean"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.SILICON_ERRATA.CPU22.614520606" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.SILICON_ERRATA.CPU22" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.SILICON_ERRATA.CPU40.916653631" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.SILICON_ERRATA.CPU40" value="true" valueType="boolean"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.SILICON_ERRATA.CPU40.629948855" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.SILICON_ERRATA.CPU40" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.SILICON_VERSION.973894696" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.SILICON_VERSION" value="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.SILICON_VERSION.mspx" valueType="enumerated"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.SILICON_VERSION.1753808681" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.SILICON_VERSION" value="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.SILICON_VERSION.mspx" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.PRINTF_SUPPORT.1310228180" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.PRINTF_SUPPORT" value="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.PRINTF_SUPPORT.full" valueType="enumerated"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.PRINTF_SUPPORT.867515559" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.PRINTF_SUPPORT" value="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.PRINTF_SUPPORT.minimal" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DEBUGGING_MODEL.1031813406" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DEBUGGING_MODEL" value="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DEBUGGING_MODEL.SYMDEBUG__DWARF" valueType="enumerated"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DEBUGGING_MODEL.880222093" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DEBUGGING_MODEL" value="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DEBUGGING_MODEL.SYMDEBUG__DWARF" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DISPLAY_ERROR_NUMBER.482096263" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DISPLAY_ERROR_NUMBER" value="true" valueType="boolean"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DISPLAY_ERROR_NUMBER.1426235308" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DISPLAY_ERROR_NUMBER" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DIAG_WARNING.1891170450" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DIAG_WARNING" valueType="stringList"> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DIAG_WARNING.1011711137" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DIAG_WARNING" valueType="stringList">
<listOptionValue value="225"/> <listOptionValue value="225"/>
</option> </option>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DIAG_WRAP.1848187510" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DIAG_WRAP" value="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DIAG_WRAP.off" valueType="enumerated"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DIAG_WRAP.448527988" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DIAG_WRAP" value="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DIAG_WRAP.off" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.INCLUDE_PATH.1544102022" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.INCLUDE_PATH" valueType="includePath"> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.INCLUDE_PATH.1838477623" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.INCLUDE_PATH" valueType="includePath">
<listOptionValue value="${CCS_BASE_ROOT}/msp430/include"/> <listOptionValue value="${CCS_BASE_ROOT}/msp430/include"/>
<listOptionValue value="${PROJECT_ROOT}"/> <listOptionValue value="${PROJECT_ROOT}"/>
<listOptionValue value="${PROJECT_ROOT}/jsmn"/> <listOptionValue value="${PROJECT_ROOT}/include"/>
<listOptionValue value="${PROJECT_ROOT}/driverlib/MSP430FR2xx_4xx"/>
<listOptionValue value="${CG_TOOL_ROOT}/include"/> <listOptionValue value="${CG_TOOL_ROOT}/include"/>
</option> </option>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.ADVICE__POWER.1658211342" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.ADVICE__POWER" value="&quot;all&quot;" valueType="string"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.ADVICE__POWER.1569099587" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.ADVICE__POWER" value="&quot;none&quot;" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.CODE_MODEL.2072187754" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.CODE_MODEL" value="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.CODE_MODEL.large" valueType="enumerated"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.OPT_LEVEL.1586547975" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.OPT_LEVEL" value="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.OPT_LEVEL.3" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DATA_MODEL.882086851" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DATA_MODEL" value="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DATA_MODEL.large" valueType="enumerated"/>
</tool> </tool>
<tool id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.linkerDebug.1198846171" name="MSP430 Linker" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.linkerDebug"> <tool id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.linkerDebug.1015511133" name="MSP430 Linker" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.linkerDebug">
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.DEFINE.120956742" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.DEFINE" valueType="definedSymbols"> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.DEFINE.979065961" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.DEFINE" valueType="definedSymbols">
<listOptionValue value="_FRWP_ENABLE"/> <listOptionValue value="_FRWP_ENABLE"/>
<listOptionValue value="_INFO_FRWP_ENABLE"/> <listOptionValue value="_INFO_FRWP_ENABLE"/>
</option> </option>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.SEARCH_PATH.1609644956" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.SEARCH_PATH" valueType="libPaths"> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.SEARCH_PATH.1136092355" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.SEARCH_PATH" valueType="libPaths">
<listOptionValue value="${CCS_BASE_ROOT}/msp430/include"/> <listOptionValue value="${CCS_BASE_ROOT}/msp430/include"/>
<listOptionValue value="${CCS_BASE_ROOT}/msp430/lib/FR2xx"/> <listOptionValue value="${CCS_BASE_ROOT}/msp430/lib/FR2xx"/>
<listOptionValue value="${CG_TOOL_ROOT}/lib"/> <listOptionValue value="${CG_TOOL_ROOT}/lib"/>
<listOptionValue value="${CCS_BASE_ROOT}/msp430/lib/5xx_6xx_FRxx"/>
<listOptionValue value="${CG_TOOL_ROOT}/include"/> <listOptionValue value="${CG_TOOL_ROOT}/include"/>
</option> </option>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.LIBRARY.1532072447" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.LIBRARY" valueType="libs"> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.LIBRARY.1990402480" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.LIBRARY" valueType="libs">
<listOptionValue value="frwp_init.a"/> <listOptionValue value="frwp_init.a"/>
<listOptionValue value="libmath.a"/>
<listOptionValue value="libc.a"/> <listOptionValue value="libc.a"/>
</option> </option>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.PRIORITY.1959485633" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.PRIORITY" value="true" valueType="boolean"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.PRIORITY.771275885" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.PRIORITY" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.USE_HW_MPY.1357345606" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.USE_HW_MPY" value="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.USE_HW_MPY.F5" valueType="enumerated"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.USE_HW_MPY.1280113593" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.USE_HW_MPY" value="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.USE_HW_MPY.F5" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.CINIT_HOLD_WDT.554477927" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.CINIT_HOLD_WDT" value="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.CINIT_HOLD_WDT.on" valueType="enumerated"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.CINIT_HOLD_WDT.289218043" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.CINIT_HOLD_WDT" value="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.CINIT_HOLD_WDT.on" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.HEAP_SIZE.1897872228" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.HEAP_SIZE" value="160" valueType="string"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.HEAP_SIZE.1314825622" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.HEAP_SIZE" value="160" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.STACK_SIZE.1905726483" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.STACK_SIZE" value="160" valueType="string"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.STACK_SIZE.1251545260" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.STACK_SIZE" value="160" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.OUTPUT_FILE.733944004" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.OUTPUT_FILE" value="${ProjName}.out" valueType="string"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.OUTPUT_FILE.1592714132" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.OUTPUT_FILE" value="${ProjName}.out" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.MAP_FILE.615177750" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.MAP_FILE" value="${ProjName}.map" valueType="string"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.MAP_FILE.88122810" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.MAP_FILE" value="${ProjName}.map" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.XML_LINK_INFO.1001496334" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.XML_LINK_INFO" value="${ProjName}_linkInfo.xml" valueType="string"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.XML_LINK_INFO.1593346489" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.XML_LINK_INFO" value="${ProjName}_linkInfo.xml" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.DISPLAY_ERROR_NUMBER.1357216536" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.DISPLAY_ERROR_NUMBER" value="true" valueType="boolean"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.DISPLAY_ERROR_NUMBER.1690650503" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.DISPLAY_ERROR_NUMBER" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.DIAG_WRAP.1227323293" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.DIAG_WRAP" value="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.DIAG_WRAP.off" valueType="enumerated"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.DIAG_WRAP.1978929899" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.DIAG_WRAP" value="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.DIAG_WRAP.off" valueType="enumerated"/>
</tool> </tool>
<tool id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.hex.1030540123" name="MSP430 Hex Utility" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.hex"> <tool id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.hex.1332494119" name="MSP430 Hex Utility" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.hex">
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.hex.ROMWIDTH.620425971" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.hex.ROMWIDTH" value="8" valueType="string"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.hex.ROMWIDTH.1403553952" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.hex.ROMWIDTH" value="8" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.hex.MEMWIDTH.1894054069" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.hex.MEMWIDTH" value="8" valueType="string"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.hex.MEMWIDTH.330241156" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.hex.MEMWIDTH" value="8" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.hex.OUTPUT_FORMAT.1924248998" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.hex.OUTPUT_FORMAT" value="com.ti.ccstudio.buildDefinitions.MSP430_21.6.hex.OUTPUT_FORMAT.TI_TXT" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.hex.TOOL_ENABLE.1203578531" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.hex.TOOL_ENABLE" value="true" valueType="boolean"/>
<outputType id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.hex.outputType__BIN.108945458" name="Binary File" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.hex.outputType__BIN"/>
</tool> </tool>
</toolChain> </toolChain>
</folderInfo> </folderInfo>
@ -99,8 +94,8 @@
</storageModule> </storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration> </cconfiguration>
<cconfiguration id="com.ti.ccstudio.buildDefinitions.MSP430.Release.1974031477"> <cconfiguration id="com.ti.ccstudio.buildDefinitions.MSP430.Release.760058067">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.ti.ccstudio.buildDefinitions.MSP430.Release.1974031477" moduleId="org.eclipse.cdt.core.settings" name="Release"> <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.ti.ccstudio.buildDefinitions.MSP430.Release.760058067" moduleId="org.eclipse.cdt.core.settings" name="Release">
<externalSettings/> <externalSettings/>
<extensions> <extensions>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="com.ti.ccs.project.ErrorParser"/> <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="com.ti.ccs.project.ErrorParser"/>
@ -108,10 +103,10 @@
</extensions> </extensions>
</storageModule> </storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0"> <storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="out" artifactName="${ProjName}" buildProperties="" cleanCommand="${CG_CLEAN_CMD}" description="" id="com.ti.ccstudio.buildDefinitions.MSP430.Release.1974031477" name="Release" parent="com.ti.ccstudio.buildDefinitions.MSP430.Release"> <configuration artifactExtension="out" artifactName="${ProjName}" buildProperties="" cleanCommand="${CG_CLEAN_CMD}" description="" id="com.ti.ccstudio.buildDefinitions.MSP430.Release.760058067" name="Release" parent="com.ti.ccstudio.buildDefinitions.MSP430.Release">
<folderInfo id="com.ti.ccstudio.buildDefinitions.MSP430.Release.1974031477." name="/" resourcePath=""> <folderInfo id="com.ti.ccstudio.buildDefinitions.MSP430.Release.760058067." name="/" resourcePath="">
<toolChain id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.ReleaseToolchain.140586413" name="TI Build Tools" secondaryOutputs="com.ti.ccstudio.buildDefinitions.MSP430_21.6.hex.outputType__BIN.1260252613" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.ReleaseToolchain" targetTool="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.linkerRelease.194246972"> <toolChain id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.ReleaseToolchain.405235695" name="TI Build Tools" secondaryOutputs="" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.ReleaseToolchain" targetTool="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.linkerRelease.310641534">
<option id="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS.1084788803" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS" valueType="stringList"> <option id="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS.330494645" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS" valueType="stringList">
<listOptionValue value="DEVICE_CONFIGURATION_ID=MSP430FR2355"/> <listOptionValue value="DEVICE_CONFIGURATION_ID=MSP430FR2355"/>
<listOptionValue value="DEVICE_CORE_ID="/> <listOptionValue value="DEVICE_CORE_ID="/>
<listOptionValue value="DEVICE_ENDIANNESS=little"/> <listOptionValue value="DEVICE_ENDIANNESS=little"/>
@ -123,73 +118,67 @@
<listOptionValue value="PRODUCTS="/> <listOptionValue value="PRODUCTS="/>
<listOptionValue value="PRODUCT_MACRO_IMPORTS={}"/> <listOptionValue value="PRODUCT_MACRO_IMPORTS={}"/>
</option> </option>
<option id="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION.1768804784" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION" value="21.6.1.LTS" valueType="string"/> <option id="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION.999182012" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION" value="21.6.1.LTS" valueType="string"/>
<targetPlatform id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.targetPlatformRelease.1865672423" name="Platform" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.targetPlatformRelease"/> <targetPlatform id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.targetPlatformRelease.1678616706" name="Platform" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.targetPlatformRelease"/>
<builder buildPath="${BuildDirectory}" id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.builderRelease.1902228951" name="GNU Make.Release" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.builderRelease"/> <builder buildPath="${BuildDirectory}" id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.builderRelease.287496526" name="GNU Make.Release" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.builderRelease"/>
<tool id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.compilerRelease.1238314004" name="MSP430 Compiler" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.compilerRelease"> <tool id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.compilerRelease.51846830" name="MSP430 Compiler" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.compilerRelease">
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DEFINE.108055868" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DEFINE" valueType="definedSymbols"> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DEFINE.1715313629" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DEFINE" valueType="definedSymbols">
<listOptionValue value="__MSP430FR2355__"/> <listOptionValue value="__MSP430FR2355__"/>
<listOptionValue value="_FRWP_ENABLE"/> <listOptionValue value="_FRWP_ENABLE"/>
<listOptionValue value="_INFO_FRWP_ENABLE"/> <listOptionValue value="_INFO_FRWP_ENABLE"/>
<listOptionValue value="__ENABLE_GUI_COMM=1"/>
<listOptionValue value="GLOBAL_Q=8"/>
</option> </option>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.ADVICE__HW_CONFIG.407911399" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.ADVICE__HW_CONFIG" value="all" valueType="string"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.ADVICE__HW_CONFIG.64691209" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.ADVICE__HW_CONFIG" value="all" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.USE_HW_MPY.1622438565" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.USE_HW_MPY" value="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.USE_HW_MPY.F5" valueType="enumerated"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.USE_HW_MPY.640057486" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.USE_HW_MPY" value="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.USE_HW_MPY.F5" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.SILICON_ERRATA.CPU21.1074143369" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.SILICON_ERRATA.CPU21" value="true" valueType="boolean"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.SILICON_ERRATA.CPU21.1573738411" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.SILICON_ERRATA.CPU21" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.SILICON_ERRATA.CPU22.1785542305" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.SILICON_ERRATA.CPU22" value="true" valueType="boolean"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.SILICON_ERRATA.CPU22.1777112603" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.SILICON_ERRATA.CPU22" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.SILICON_ERRATA.CPU40.1375966431" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.SILICON_ERRATA.CPU40" value="true" valueType="boolean"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.SILICON_ERRATA.CPU40.1407412877" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.SILICON_ERRATA.CPU40" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.SILICON_VERSION.1709181544" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.SILICON_VERSION" value="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.SILICON_VERSION.mspx" valueType="enumerated"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.SILICON_VERSION.174481978" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.SILICON_VERSION" value="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.SILICON_VERSION.mspx" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.PRINTF_SUPPORT.10528958" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.PRINTF_SUPPORT" value="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.PRINTF_SUPPORT.minimal" valueType="enumerated"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.PRINTF_SUPPORT.330557881" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.PRINTF_SUPPORT" value="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.PRINTF_SUPPORT.minimal" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DISPLAY_ERROR_NUMBER.362893625" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DISPLAY_ERROR_NUMBER" value="true" valueType="boolean"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DISPLAY_ERROR_NUMBER.1058480034" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DISPLAY_ERROR_NUMBER" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DIAG_WARNING.972322574" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DIAG_WARNING" valueType="stringList"> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DIAG_WARNING.251633234" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DIAG_WARNING" valueType="stringList">
<listOptionValue value="225"/> <listOptionValue value="225"/>
</option> </option>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DIAG_WRAP.877584867" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DIAG_WRAP" value="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DIAG_WRAP.off" valueType="enumerated"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DIAG_WRAP.942936066" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DIAG_WRAP" value="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DIAG_WRAP.off" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.INCLUDE_PATH.1568105874" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.INCLUDE_PATH" valueType="includePath"> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.INCLUDE_PATH.1164889098" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.INCLUDE_PATH" valueType="includePath">
<listOptionValue value="${CCS_BASE_ROOT}/msp430/include"/> <listOptionValue value="${CCS_BASE_ROOT}/msp430/include"/>
<listOptionValue value="${PROJECT_ROOT}"/> <listOptionValue value="${PROJECT_ROOT}"/>
<listOptionValue value="${PROJECT_ROOT}/jsmn"/> <listOptionValue value="${PROJECT_ROOT}/include"/>
<listOptionValue value="${PROJECT_ROOT}/driverlib/MSP430FR2xx_4xx"/>
<listOptionValue value="${CG_TOOL_ROOT}/include"/> <listOptionValue value="${CG_TOOL_ROOT}/include"/>
</option> </option>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.ADVICE__POWER.1120803054" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.ADVICE__POWER" value="&quot;all&quot;" valueType="string"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.ADVICE__POWER.961778537" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.ADVICE__POWER" value="&quot;none&quot;" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DEBUGGING_MODEL.925774561" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DEBUGGING_MODEL" value="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DEBUGGING_MODEL.SYMDEBUG__DWARF" valueType="enumerated"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.OPT_LEVEL.release.986686389" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.OPT_LEVEL.release" value="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.OPT_LEVEL.3" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.CODE_MODEL.1882239629" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.CODE_MODEL" value="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.CODE_MODEL.large" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DATA_MODEL.493202286" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DATA_MODEL" value="com.ti.ccstudio.buildDefinitions.MSP430_21.6.compilerID.DATA_MODEL.large" valueType="enumerated"/>
</tool> </tool>
<tool id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.linkerRelease.194246972" name="MSP430 Linker" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.linkerRelease"> <tool id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.linkerRelease.310641534" name="MSP430 Linker" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.exe.linkerRelease">
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.DEFINE.1250092076" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.DEFINE" valueType="definedSymbols"> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.DEFINE.800571145" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.DEFINE" valueType="definedSymbols">
<listOptionValue value="_FRWP_ENABLE"/> <listOptionValue value="_FRWP_ENABLE"/>
<listOptionValue value="_INFO_FRWP_ENABLE"/> <listOptionValue value="_INFO_FRWP_ENABLE"/>
</option> </option>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.SEARCH_PATH.1393749909" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.SEARCH_PATH" valueType="libPaths"> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.SEARCH_PATH.903712628" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.SEARCH_PATH" valueType="libPaths">
<listOptionValue value="${CCS_BASE_ROOT}/msp430/include"/> <listOptionValue value="${CCS_BASE_ROOT}/msp430/include"/>
<listOptionValue value="${CCS_BASE_ROOT}/msp430/lib/FR2xx"/> <listOptionValue value="${CCS_BASE_ROOT}/msp430/lib/FR2xx"/>
<listOptionValue value="${CG_TOOL_ROOT}/lib"/> <listOptionValue value="${CG_TOOL_ROOT}/lib"/>
<listOptionValue value="${CCS_BASE_ROOT}/msp430/lib/5xx_6xx_FRxx"/>
<listOptionValue value="${CG_TOOL_ROOT}/include"/> <listOptionValue value="${CG_TOOL_ROOT}/include"/>
</option> </option>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.LIBRARY.2030344789" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.LIBRARY" valueType="libs"> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.LIBRARY.680243105" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.LIBRARY" valueType="libs">
<listOptionValue value="frwp_init.a"/> <listOptionValue value="frwp_init.a"/>
<listOptionValue value="libmath.a"/>
<listOptionValue value="libc.a"/> <listOptionValue value="libc.a"/>
</option> </option>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.PRIORITY.2048524577" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.PRIORITY" value="true" valueType="boolean"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.PRIORITY.119201875" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.PRIORITY" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.USE_HW_MPY.581854631" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.USE_HW_MPY" value="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.USE_HW_MPY.F5" valueType="enumerated"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.USE_HW_MPY.1981263533" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.USE_HW_MPY" value="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.USE_HW_MPY.F5" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.CINIT_HOLD_WDT.607809829" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.CINIT_HOLD_WDT" value="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.CINIT_HOLD_WDT.on" valueType="enumerated"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.CINIT_HOLD_WDT.1873920785" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.CINIT_HOLD_WDT" value="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.CINIT_HOLD_WDT.on" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.HEAP_SIZE.1849886778" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.HEAP_SIZE" value="160" valueType="string"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.HEAP_SIZE.1072034688" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.HEAP_SIZE" value="160" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.STACK_SIZE.1269505485" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.STACK_SIZE" value="160" valueType="string"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.STACK_SIZE.863631348" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.STACK_SIZE" value="160" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.OUTPUT_FILE.1524376755" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.OUTPUT_FILE" value="${ProjName}.out" valueType="string"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.OUTPUT_FILE.1557747214" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.OUTPUT_FILE" value="${ProjName}.out" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.MAP_FILE.1640283242" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.MAP_FILE" value="${ProjName}.map" valueType="string"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.MAP_FILE.1681793265" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.MAP_FILE" value="${ProjName}.map" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.XML_LINK_INFO.637054606" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.XML_LINK_INFO" value="${ProjName}_linkInfo.xml" valueType="string"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.XML_LINK_INFO.1347102027" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.XML_LINK_INFO" value="${ProjName}_linkInfo.xml" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.DISPLAY_ERROR_NUMBER.758120580" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.DISPLAY_ERROR_NUMBER" value="true" valueType="boolean"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.DISPLAY_ERROR_NUMBER.547394723" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.DISPLAY_ERROR_NUMBER" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.DIAG_WRAP.492683673" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.DIAG_WRAP" value="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.DIAG_WRAP.off" valueType="enumerated"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.DIAG_WRAP.2002953940" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.DIAG_WRAP" value="com.ti.ccstudio.buildDefinitions.MSP430_21.6.linkerID.DIAG_WRAP.off" valueType="enumerated"/>
</tool> </tool>
<tool id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.hex.1975699522" name="MSP430 Hex Utility" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.hex"> <tool id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.hex.810927938" name="MSP430 Hex Utility" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.hex">
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.hex.ROMWIDTH.183287475" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.hex.ROMWIDTH" value="8" valueType="string"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.hex.ROMWIDTH.288105213" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.hex.ROMWIDTH" value="8" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.hex.MEMWIDTH.595737653" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.hex.MEMWIDTH" value="8" valueType="string"/> <option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.hex.MEMWIDTH.767444476" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.hex.MEMWIDTH" value="8" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.hex.OUTPUT_FORMAT.1320508774" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.hex.OUTPUT_FORMAT" value="com.ti.ccstudio.buildDefinitions.MSP430_21.6.hex.OUTPUT_FORMAT.TI_TXT" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.hex.TOOL_ENABLE.2069805405" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.hex.TOOL_ENABLE" value="true" valueType="boolean"/>
<outputType id="com.ti.ccstudio.buildDefinitions.MSP430_21.6.hex.outputType__BIN.1260252613" name="Binary File" superClass="com.ti.ccstudio.buildDefinitions.MSP430_21.6.hex.outputType__BIN"/>
</tool> </tool>
</toolChain> </toolChain>
</folderInfo> </folderInfo>
@ -199,6 +188,6 @@
</cconfiguration> </cconfiguration>
</storageModule> </storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0"> <storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="ESR-11.com.ti.ccstudio.buildDefinitions.MSP430.ProjectType.2107302554" name="MSP430" projectType="com.ti.ccstudio.buildDefinitions.MSP430.ProjectType"/> <project id="ESR-G11.com.ti.ccstudio.buildDefinitions.MSP430.ProjectType.1034979954" name="MSP430" projectType="com.ti.ccstudio.buildDefinitions.MSP430.ProjectType"/>
</storageModule> </storageModule>
</cproject> </cproject>

4
.gitignore vendored
View File

@ -1,4 +0,0 @@
html/
latex/
doxygen.pdf
Debug/

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<projectDescription> <projectDescription>
<name>ESR-11</name> <name>ESR-G11</name>
<comment></comment> <comment></comment>
<projects> <projects>
</projects> </projects>

View File

@ -1,16 +0,0 @@
eclipse.preferences.version=1
encoding//Debug/docs/latex/subdir_rules.mk=UTF-8
encoding//Debug/docs/latex/subdir_vars.mk=UTF-8
encoding//Debug/driverlib/MSP430FR2xx_4xx/subdir_rules.mk=UTF-8
encoding//Debug/driverlib/MSP430FR2xx_4xx/subdir_vars.mk=UTF-8
encoding//Debug/jsmn/subdir_rules.mk=UTF-8
encoding//Debug/jsmn/subdir_vars.mk=UTF-8
encoding//Debug/latex/subdir_rules.mk=UTF-8
encoding//Debug/latex/subdir_vars.mk=UTF-8
encoding//Debug/makefile=UTF-8
encoding//Debug/objects.mk=UTF-8
encoding//Debug/sources.mk=UTF-8
encoding//Debug/src/subdir_rules.mk=UTF-8
encoding//Debug/src/subdir_vars.mk=UTF-8
encoding//Debug/subdir_rules.mk=UTF-8
encoding//Debug/subdir_vars.mk=UTF-8

View File

@ -1,157 +1,47 @@
[ [
{ {
"directory" : "/home/frederik/workspace_ccstheia/ESR-11/Debug", "directory" : "/home/frederik/workspace_ccstheia/ESR-G11/Debug",
"command" : "clang++ -I\"/home/frederik/.ti/ccs2010/ccs/ccs_base/msp430/include\" -I\"/home/frederik/workspace_ccstheia/ESR-11\" -I\"/home/frederik/workspace_ccstheia/ESR-11/jsmn\" -I\"/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx\" -I\"/home/frederik/.ti/ccs2010/ccs/tools/compiler/ti-cgt-msp430_21.6.1.LTS/include\" -D__MSP430FR2355__ -D_FRWP_ENABLE -D_INFO_FRWP_ENABLE -xc", "command" : "clang++ -I\"/home/frederik/.ti/ccs2010/ccs/ccs_base/msp430/include\" -I\"/home/frederik/workspace_ccstheia/ESR-G11\" -I\"/home/frederik/workspace_ccstheia/ESR-G11/include\" -I\"/home/frederik/.ti/ccs2010/ccs/tools/compiler/ti-cgt-msp430_21.6.1.LTS/include\" -D__MSP430FR2355__ -D_FRWP_ENABLE -D_INFO_FRWP_ENABLE -D__ENABLE_GUI_COMM=1 -DGLOBAL_Q=8",
"file" : "/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx/adc.c" "file" : "/home/frederik/workspace_ccstheia/ESR-G11/GUIComm_JSON.c"
}, },
{ {
"directory" : "/home/frederik/workspace_ccstheia/ESR-11/Debug", "directory" : "/home/frederik/workspace_ccstheia/ESR-G11/Debug",
"command" : "clang++ -I\"/home/frederik/.ti/ccs2010/ccs/ccs_base/msp430/include\" -I\"/home/frederik/workspace_ccstheia/ESR-11\" -I\"/home/frederik/workspace_ccstheia/ESR-11/jsmn\" -I\"/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx\" -I\"/home/frederik/.ti/ccs2010/ccs/tools/compiler/ti-cgt-msp430_21.6.1.LTS/include\" -D__MSP430FR2355__ -D_FRWP_ENABLE -D_INFO_FRWP_ENABLE -xc", "command" : "clang++ -I\"/home/frederik/.ti/ccs2010/ccs/ccs_base/msp430/include\" -I\"/home/frederik/workspace_ccstheia/ESR-G11\" -I\"/home/frederik/workspace_ccstheia/ESR-G11/include\" -I\"/home/frederik/.ti/ccs2010/ccs/tools/compiler/ti-cgt-msp430_21.6.1.LTS/include\" -D__MSP430FR2355__ -D_FRWP_ENABLE -D_INFO_FRWP_ENABLE -D__ENABLE_GUI_COMM=1 -DGLOBAL_Q=8",
"file" : "/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx/crc.c" "file" : "/home/frederik/workspace_ccstheia/ESR-G11/callbacks_JSON.c"
}, },
{ {
"directory" : "/home/frederik/workspace_ccstheia/ESR-11/Debug", "directory" : "/home/frederik/workspace_ccstheia/ESR-G11/Debug",
"command" : "clang++ -I\"/home/frederik/.ti/ccs2010/ccs/ccs_base/msp430/include\" -I\"/home/frederik/workspace_ccstheia/ESR-11\" -I\"/home/frederik/workspace_ccstheia/ESR-11/jsmn\" -I\"/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx\" -I\"/home/frederik/.ti/ccs2010/ccs/tools/compiler/ti-cgt-msp430_21.6.1.LTS/include\" -D__MSP430FR2355__ -D_FRWP_ENABLE -D_INFO_FRWP_ENABLE -xc", "command" : "clang++ -I\"/home/frederik/.ti/ccs2010/ccs/ccs_base/msp430/include\" -I\"/home/frederik/workspace_ccstheia/ESR-G11\" -I\"/home/frederik/workspace_ccstheia/ESR-G11/include\" -I\"/home/frederik/.ti/ccs2010/ccs/tools/compiler/ti-cgt-msp430_21.6.1.LTS/include\" -D__MSP430FR2355__ -D_FRWP_ENABLE -D_INFO_FRWP_ENABLE -D__ENABLE_GUI_COMM=1 -DGLOBAL_Q=8",
"file" : "/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx/cs.c" "file" : "/home/frederik/workspace_ccstheia/ESR-G11/main.c"
}, },
{ {
"directory" : "/home/frederik/workspace_ccstheia/ESR-11/Debug", "directory" : "/home/frederik/workspace_ccstheia/ESR-G11/Debug",
"command" : "clang++ -I\"/home/frederik/.ti/ccs2010/ccs/ccs_base/msp430/include\" -I\"/home/frederik/workspace_ccstheia/ESR-11\" -I\"/home/frederik/workspace_ccstheia/ESR-11/jsmn\" -I\"/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx\" -I\"/home/frederik/.ti/ccs2010/ccs/tools/compiler/ti-cgt-msp430_21.6.1.LTS/include\" -D__MSP430FR2355__ -D_FRWP_ENABLE -D_INFO_FRWP_ENABLE -xc", "command" : "clang++ -I\"/home/frederik/.ti/ccs2010/ccs/ccs_base/msp430/include\" -I\"/home/frederik/workspace_ccstheia/ESR-G11\" -I\"/home/frederik/workspace_ccstheia/ESR-G11/include\" -I\"/home/frederik/.ti/ccs2010/ccs/tools/compiler/ti-cgt-msp430_21.6.1.LTS/include\" -D__MSP430FR2355__ -D_FRWP_ENABLE -D_INFO_FRWP_ENABLE -D__ENABLE_GUI_COMM=1 -DGLOBAL_Q=8",
"file" : "/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx/ecomp.c" "file" : "/home/frederik/workspace_ccstheia/ESR-G11/src/MSP430_GUI/GUI_JSON.c"
}, },
{ {
"directory" : "/home/frederik/workspace_ccstheia/ESR-11/Debug", "directory" : "/home/frederik/workspace_ccstheia/ESR-G11/Debug",
"command" : "clang++ -I\"/home/frederik/.ti/ccs2010/ccs/ccs_base/msp430/include\" -I\"/home/frederik/workspace_ccstheia/ESR-11\" -I\"/home/frederik/workspace_ccstheia/ESR-11/jsmn\" -I\"/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx\" -I\"/home/frederik/.ti/ccs2010/ccs/tools/compiler/ti-cgt-msp430_21.6.1.LTS/include\" -D__MSP430FR2355__ -D_FRWP_ENABLE -D_INFO_FRWP_ENABLE -xc", "command" : "clang++ -I\"/home/frederik/.ti/ccs2010/ccs/ccs_base/msp430/include\" -I\"/home/frederik/workspace_ccstheia/ESR-G11\" -I\"/home/frederik/workspace_ccstheia/ESR-G11/include\" -I\"/home/frederik/.ti/ccs2010/ccs/tools/compiler/ti-cgt-msp430_21.6.1.LTS/include\" -D__MSP430FR2355__ -D_FRWP_ENABLE -D_INFO_FRWP_ENABLE -D__ENABLE_GUI_COMM=1 -DGLOBAL_Q=8",
"file" : "/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx/eusci_a_spi.c" "file" : "/home/frederik/workspace_ccstheia/ESR-G11/src/MSP430_GUI/jsmn/jsmn.c"
}, },
{ {
"directory" : "/home/frederik/workspace_ccstheia/ESR-11/Debug", "directory" : "/home/frederik/workspace_ccstheia/ESR-G11/Debug",
"command" : "clang++ -I\"/home/frederik/.ti/ccs2010/ccs/ccs_base/msp430/include\" -I\"/home/frederik/workspace_ccstheia/ESR-11\" -I\"/home/frederik/workspace_ccstheia/ESR-11/jsmn\" -I\"/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx\" -I\"/home/frederik/.ti/ccs2010/ccs/tools/compiler/ti-cgt-msp430_21.6.1.LTS/include\" -D__MSP430FR2355__ -D_FRWP_ENABLE -D_INFO_FRWP_ENABLE -xc", "command" : "clang++ -I\"/home/frederik/.ti/ccs2010/ccs/ccs_base/msp430/include\" -I\"/home/frederik/workspace_ccstheia/ESR-G11\" -I\"/home/frederik/workspace_ccstheia/ESR-G11/include\" -I\"/home/frederik/.ti/ccs2010/ccs/tools/compiler/ti-cgt-msp430_21.6.1.LTS/include\" -D__MSP430FR2355__ -D_FRWP_ENABLE -D_INFO_FRWP_ENABLE -D__ENABLE_GUI_COMM=1 -DGLOBAL_Q=8",
"file" : "/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx/eusci_a_uart.c" "file" : "/home/frederik/workspace_ccstheia/ESR-G11/src/MSP430_HAL/HAL_GUIComm_UART_FR235x.c"
}, },
{ {
"directory" : "/home/frederik/workspace_ccstheia/ESR-11/Debug", "directory" : "/home/frederik/workspace_ccstheia/ESR-G11/Debug",
"command" : "clang++ -I\"/home/frederik/.ti/ccs2010/ccs/ccs_base/msp430/include\" -I\"/home/frederik/workspace_ccstheia/ESR-11\" -I\"/home/frederik/workspace_ccstheia/ESR-11/jsmn\" -I\"/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx\" -I\"/home/frederik/.ti/ccs2010/ccs/tools/compiler/ti-cgt-msp430_21.6.1.LTS/include\" -D__MSP430FR2355__ -D_FRWP_ENABLE -D_INFO_FRWP_ENABLE -xc", "command" : "clang++ -I\"/home/frederik/.ti/ccs2010/ccs/ccs_base/msp430/include\" -I\"/home/frederik/workspace_ccstheia/ESR-G11\" -I\"/home/frederik/workspace_ccstheia/ESR-G11/include\" -I\"/home/frederik/.ti/ccs2010/ccs/tools/compiler/ti-cgt-msp430_21.6.1.LTS/include\" -D__MSP430FR2355__ -D_FRWP_ENABLE -D_INFO_FRWP_ENABLE -D__ENABLE_GUI_COMM=1 -DGLOBAL_Q=8",
"file" : "/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx/eusci_b_i2c.c" "file" : "/home/frederik/workspace_ccstheia/ESR-G11/src/MSP430_HAL/HAL_IO_FR235x.c"
}, },
{ {
"directory" : "/home/frederik/workspace_ccstheia/ESR-11/Debug", "directory" : "/home/frederik/workspace_ccstheia/ESR-G11/Debug",
"command" : "clang++ -I\"/home/frederik/.ti/ccs2010/ccs/ccs_base/msp430/include\" -I\"/home/frederik/workspace_ccstheia/ESR-11\" -I\"/home/frederik/workspace_ccstheia/ESR-11/jsmn\" -I\"/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx\" -I\"/home/frederik/.ti/ccs2010/ccs/tools/compiler/ti-cgt-msp430_21.6.1.LTS/include\" -D__MSP430FR2355__ -D_FRWP_ENABLE -D_INFO_FRWP_ENABLE -xc", "command" : "clang++ -I\"/home/frederik/.ti/ccs2010/ccs/ccs_base/msp430/include\" -I\"/home/frederik/workspace_ccstheia/ESR-G11\" -I\"/home/frederik/workspace_ccstheia/ESR-G11/include\" -I\"/home/frederik/.ti/ccs2010/ccs/tools/compiler/ti-cgt-msp430_21.6.1.LTS/include\" -D__MSP430FR2355__ -D_FRWP_ENABLE -D_INFO_FRWP_ENABLE -D__ENABLE_GUI_COMM=1 -DGLOBAL_Q=8",
"file" : "/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx/eusci_b_spi.c" "file" : "/home/frederik/workspace_ccstheia/ESR-G11/src/MSP430_HAL/HAL_System_FR235x.c"
}, },
{ {
"directory" : "/home/frederik/workspace_ccstheia/ESR-11/Debug", "directory" : "/home/frederik/workspace_ccstheia/ESR-G11/Debug",
"command" : "clang++ -I\"/home/frederik/.ti/ccs2010/ccs/ccs_base/msp430/include\" -I\"/home/frederik/workspace_ccstheia/ESR-11\" -I\"/home/frederik/workspace_ccstheia/ESR-11/jsmn\" -I\"/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx\" -I\"/home/frederik/.ti/ccs2010/ccs/tools/compiler/ti-cgt-msp430_21.6.1.LTS/include\" -D__MSP430FR2355__ -D_FRWP_ENABLE -D_INFO_FRWP_ENABLE -xc", "command" : "clang++ -I\"/home/frederik/.ti/ccs2010/ccs/ccs_base/msp430/include\" -I\"/home/frederik/workspace_ccstheia/ESR-G11\" -I\"/home/frederik/workspace_ccstheia/ESR-G11/include\" -I\"/home/frederik/.ti/ccs2010/ccs/tools/compiler/ti-cgt-msp430_21.6.1.LTS/include\" -D__MSP430FR2355__ -D_FRWP_ENABLE -D_INFO_FRWP_ENABLE -D__ENABLE_GUI_COMM=1 -DGLOBAL_Q=8",
"file" : "/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx/framctl.c" "file" : "/home/frederik/workspace_ccstheia/ESR-G11/src/MSP430_HAL/HAL_Timer_FR235x.c"
},
{
"directory" : "/home/frederik/workspace_ccstheia/ESR-11/Debug",
"command" : "clang++ -I\"/home/frederik/.ti/ccs2010/ccs/ccs_base/msp430/include\" -I\"/home/frederik/workspace_ccstheia/ESR-11\" -I\"/home/frederik/workspace_ccstheia/ESR-11/jsmn\" -I\"/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx\" -I\"/home/frederik/.ti/ccs2010/ccs/tools/compiler/ti-cgt-msp430_21.6.1.LTS/include\" -D__MSP430FR2355__ -D_FRWP_ENABLE -D_INFO_FRWP_ENABLE -xc",
"file" : "/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx/gpio.c"
},
{
"directory" : "/home/frederik/workspace_ccstheia/ESR-11/Debug",
"command" : "clang++ -I\"/home/frederik/.ti/ccs2010/ccs/ccs_base/msp430/include\" -I\"/home/frederik/workspace_ccstheia/ESR-11\" -I\"/home/frederik/workspace_ccstheia/ESR-11/jsmn\" -I\"/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx\" -I\"/home/frederik/.ti/ccs2010/ccs/tools/compiler/ti-cgt-msp430_21.6.1.LTS/include\" -D__MSP430FR2355__ -D_FRWP_ENABLE -D_INFO_FRWP_ENABLE -xc",
"file" : "/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx/icc.c"
},
{
"directory" : "/home/frederik/workspace_ccstheia/ESR-11/Debug",
"command" : "clang++ -I\"/home/frederik/.ti/ccs2010/ccs/ccs_base/msp430/include\" -I\"/home/frederik/workspace_ccstheia/ESR-11\" -I\"/home/frederik/workspace_ccstheia/ESR-11/jsmn\" -I\"/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx\" -I\"/home/frederik/.ti/ccs2010/ccs/tools/compiler/ti-cgt-msp430_21.6.1.LTS/include\" -D__MSP430FR2355__ -D_FRWP_ENABLE -D_INFO_FRWP_ENABLE -xc",
"file" : "/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx/lcd_e.c"
},
{
"directory" : "/home/frederik/workspace_ccstheia/ESR-11/Debug",
"command" : "clang++ -I\"/home/frederik/.ti/ccs2010/ccs/ccs_base/msp430/include\" -I\"/home/frederik/workspace_ccstheia/ESR-11\" -I\"/home/frederik/workspace_ccstheia/ESR-11/jsmn\" -I\"/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx\" -I\"/home/frederik/.ti/ccs2010/ccs/tools/compiler/ti-cgt-msp430_21.6.1.LTS/include\" -D__MSP430FR2355__ -D_FRWP_ENABLE -D_INFO_FRWP_ENABLE -xc",
"file" : "/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx/mpy32.c"
},
{
"directory" : "/home/frederik/workspace_ccstheia/ESR-11/Debug",
"command" : "clang++ -I\"/home/frederik/.ti/ccs2010/ccs/ccs_base/msp430/include\" -I\"/home/frederik/workspace_ccstheia/ESR-11\" -I\"/home/frederik/workspace_ccstheia/ESR-11/jsmn\" -I\"/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx\" -I\"/home/frederik/.ti/ccs2010/ccs/tools/compiler/ti-cgt-msp430_21.6.1.LTS/include\" -D__MSP430FR2355__ -D_FRWP_ENABLE -D_INFO_FRWP_ENABLE -xc",
"file" : "/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx/pmm.c"
},
{
"directory" : "/home/frederik/workspace_ccstheia/ESR-11/Debug",
"command" : "clang++ -I\"/home/frederik/.ti/ccs2010/ccs/ccs_base/msp430/include\" -I\"/home/frederik/workspace_ccstheia/ESR-11\" -I\"/home/frederik/workspace_ccstheia/ESR-11/jsmn\" -I\"/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx\" -I\"/home/frederik/.ti/ccs2010/ccs/tools/compiler/ti-cgt-msp430_21.6.1.LTS/include\" -D__MSP430FR2355__ -D_FRWP_ENABLE -D_INFO_FRWP_ENABLE -xc",
"file" : "/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx/rtc.c"
},
{
"directory" : "/home/frederik/workspace_ccstheia/ESR-11/Debug",
"command" : "clang++ -I\"/home/frederik/.ti/ccs2010/ccs/ccs_base/msp430/include\" -I\"/home/frederik/workspace_ccstheia/ESR-11\" -I\"/home/frederik/workspace_ccstheia/ESR-11/jsmn\" -I\"/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx\" -I\"/home/frederik/.ti/ccs2010/ccs/tools/compiler/ti-cgt-msp430_21.6.1.LTS/include\" -D__MSP430FR2355__ -D_FRWP_ENABLE -D_INFO_FRWP_ENABLE -xc",
"file" : "/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx/sac.c"
},
{
"directory" : "/home/frederik/workspace_ccstheia/ESR-11/Debug",
"command" : "clang++ -I\"/home/frederik/.ti/ccs2010/ccs/ccs_base/msp430/include\" -I\"/home/frederik/workspace_ccstheia/ESR-11\" -I\"/home/frederik/workspace_ccstheia/ESR-11/jsmn\" -I\"/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx\" -I\"/home/frederik/.ti/ccs2010/ccs/tools/compiler/ti-cgt-msp430_21.6.1.LTS/include\" -D__MSP430FR2355__ -D_FRWP_ENABLE -D_INFO_FRWP_ENABLE -xc",
"file" : "/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx/sfr.c"
},
{
"directory" : "/home/frederik/workspace_ccstheia/ESR-11/Debug",
"command" : "clang++ -I\"/home/frederik/.ti/ccs2010/ccs/ccs_base/msp430/include\" -I\"/home/frederik/workspace_ccstheia/ESR-11\" -I\"/home/frederik/workspace_ccstheia/ESR-11/jsmn\" -I\"/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx\" -I\"/home/frederik/.ti/ccs2010/ccs/tools/compiler/ti-cgt-msp430_21.6.1.LTS/include\" -D__MSP430FR2355__ -D_FRWP_ENABLE -D_INFO_FRWP_ENABLE -xc",
"file" : "/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx/sysctl.c"
},
{
"directory" : "/home/frederik/workspace_ccstheia/ESR-11/Debug",
"command" : "clang++ -I\"/home/frederik/.ti/ccs2010/ccs/ccs_base/msp430/include\" -I\"/home/frederik/workspace_ccstheia/ESR-11\" -I\"/home/frederik/workspace_ccstheia/ESR-11/jsmn\" -I\"/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx\" -I\"/home/frederik/.ti/ccs2010/ccs/tools/compiler/ti-cgt-msp430_21.6.1.LTS/include\" -D__MSP430FR2355__ -D_FRWP_ENABLE -D_INFO_FRWP_ENABLE -xc",
"file" : "/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx/tia.c"
},
{
"directory" : "/home/frederik/workspace_ccstheia/ESR-11/Debug",
"command" : "clang++ -I\"/home/frederik/.ti/ccs2010/ccs/ccs_base/msp430/include\" -I\"/home/frederik/workspace_ccstheia/ESR-11\" -I\"/home/frederik/workspace_ccstheia/ESR-11/jsmn\" -I\"/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx\" -I\"/home/frederik/.ti/ccs2010/ccs/tools/compiler/ti-cgt-msp430_21.6.1.LTS/include\" -D__MSP430FR2355__ -D_FRWP_ENABLE -D_INFO_FRWP_ENABLE -xc",
"file" : "/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx/timer_b.c"
},
{
"directory" : "/home/frederik/workspace_ccstheia/ESR-11/Debug",
"command" : "clang++ -I\"/home/frederik/.ti/ccs2010/ccs/ccs_base/msp430/include\" -I\"/home/frederik/workspace_ccstheia/ESR-11\" -I\"/home/frederik/workspace_ccstheia/ESR-11/jsmn\" -I\"/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx\" -I\"/home/frederik/.ti/ccs2010/ccs/tools/compiler/ti-cgt-msp430_21.6.1.LTS/include\" -D__MSP430FR2355__ -D_FRWP_ENABLE -D_INFO_FRWP_ENABLE -xc",
"file" : "/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx/tlv.c"
},
{
"directory" : "/home/frederik/workspace_ccstheia/ESR-11/Debug",
"command" : "clang++ -I\"/home/frederik/.ti/ccs2010/ccs/ccs_base/msp430/include\" -I\"/home/frederik/workspace_ccstheia/ESR-11\" -I\"/home/frederik/workspace_ccstheia/ESR-11/jsmn\" -I\"/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx\" -I\"/home/frederik/.ti/ccs2010/ccs/tools/compiler/ti-cgt-msp430_21.6.1.LTS/include\" -D__MSP430FR2355__ -D_FRWP_ENABLE -D_INFO_FRWP_ENABLE -xc",
"file" : "/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx/wdt_a.c"
},
{
"directory" : "/home/frederik/workspace_ccstheia/ESR-11/Debug",
"command" : "clang++ -I\"/home/frederik/.ti/ccs2010/ccs/ccs_base/msp430/include\" -I\"/home/frederik/workspace_ccstheia/ESR-11\" -I\"/home/frederik/workspace_ccstheia/ESR-11/jsmn\" -I\"/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx\" -I\"/home/frederik/.ti/ccs2010/ccs/tools/compiler/ti-cgt-msp430_21.6.1.LTS/include\" -D__MSP430FR2355__ -D_FRWP_ENABLE -D_INFO_FRWP_ENABLE -xc",
"file" : "/home/frederik/workspace_ccstheia/ESR-11/jsmn/jsmn.c"
},
{
"directory" : "/home/frederik/workspace_ccstheia/ESR-11/Debug",
"command" : "clang++ -I\"/home/frederik/.ti/ccs2010/ccs/ccs_base/msp430/include\" -I\"/home/frederik/workspace_ccstheia/ESR-11\" -I\"/home/frederik/workspace_ccstheia/ESR-11/jsmn\" -I\"/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx\" -I\"/home/frederik/.ti/ccs2010/ccs/tools/compiler/ti-cgt-msp430_21.6.1.LTS/include\" -D__MSP430FR2355__ -D_FRWP_ENABLE -D_INFO_FRWP_ENABLE -xc",
"file" : "/home/frederik/workspace_ccstheia/ESR-11/main.c"
},
{
"directory" : "/home/frederik/workspace_ccstheia/ESR-11/Debug",
"command" : "clang++ -I\"/home/frederik/.ti/ccs2010/ccs/ccs_base/msp430/include\" -I\"/home/frederik/workspace_ccstheia/ESR-11\" -I\"/home/frederik/workspace_ccstheia/ESR-11/jsmn\" -I\"/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx\" -I\"/home/frederik/.ti/ccs2010/ccs/tools/compiler/ti-cgt-msp430_21.6.1.LTS/include\" -D__MSP430FR2355__ -D_FRWP_ENABLE -D_INFO_FRWP_ENABLE -xc",
"file" : "/home/frederik/workspace_ccstheia/ESR-11/src/i2c.c"
},
{
"directory" : "/home/frederik/workspace_ccstheia/ESR-11/Debug",
"command" : "clang++ -I\"/home/frederik/.ti/ccs2010/ccs/ccs_base/msp430/include\" -I\"/home/frederik/workspace_ccstheia/ESR-11\" -I\"/home/frederik/workspace_ccstheia/ESR-11/jsmn\" -I\"/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx\" -I\"/home/frederik/.ti/ccs2010/ccs/tools/compiler/ti-cgt-msp430_21.6.1.LTS/include\" -D__MSP430FR2355__ -D_FRWP_ENABLE -D_INFO_FRWP_ENABLE -xc",
"file" : "/home/frederik/workspace_ccstheia/ESR-11/src/keypad.c"
},
{
"directory" : "/home/frederik/workspace_ccstheia/ESR-11/Debug",
"command" : "clang++ -I\"/home/frederik/.ti/ccs2010/ccs/ccs_base/msp430/include\" -I\"/home/frederik/workspace_ccstheia/ESR-11\" -I\"/home/frederik/workspace_ccstheia/ESR-11/jsmn\" -I\"/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx\" -I\"/home/frederik/.ti/ccs2010/ccs/tools/compiler/ti-cgt-msp430_21.6.1.LTS/include\" -D__MSP430FR2355__ -D_FRWP_ENABLE -D_INFO_FRWP_ENABLE -xc",
"file" : "/home/frederik/workspace_ccstheia/ESR-11/src/lcd.c"
},
{
"directory" : "/home/frederik/workspace_ccstheia/ESR-11/Debug",
"command" : "clang++ -I\"/home/frederik/.ti/ccs2010/ccs/ccs_base/msp430/include\" -I\"/home/frederik/workspace_ccstheia/ESR-11\" -I\"/home/frederik/workspace_ccstheia/ESR-11/jsmn\" -I\"/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx\" -I\"/home/frederik/.ti/ccs2010/ccs/tools/compiler/ti-cgt-msp430_21.6.1.LTS/include\" -D__MSP430FR2355__ -D_FRWP_ENABLE -D_INFO_FRWP_ENABLE -xc",
"file" : "/home/frederik/workspace_ccstheia/ESR-11/src/morse.c"
},
{
"directory" : "/home/frederik/workspace_ccstheia/ESR-11/Debug",
"command" : "clang++ -I\"/home/frederik/.ti/ccs2010/ccs/ccs_base/msp430/include\" -I\"/home/frederik/workspace_ccstheia/ESR-11\" -I\"/home/frederik/workspace_ccstheia/ESR-11/jsmn\" -I\"/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx\" -I\"/home/frederik/.ti/ccs2010/ccs/tools/compiler/ti-cgt-msp430_21.6.1.LTS/include\" -D__MSP430FR2355__ -D_FRWP_ENABLE -D_INFO_FRWP_ENABLE -xc",
"file" : "/home/frederik/workspace_ccstheia/ESR-11/src/state_machine.c"
},
{
"directory" : "/home/frederik/workspace_ccstheia/ESR-11/Debug",
"command" : "clang++ -I\"/home/frederik/.ti/ccs2010/ccs/ccs_base/msp430/include\" -I\"/home/frederik/workspace_ccstheia/ESR-11\" -I\"/home/frederik/workspace_ccstheia/ESR-11/jsmn\" -I\"/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx\" -I\"/home/frederik/.ti/ccs2010/ccs/tools/compiler/ti-cgt-msp430_21.6.1.LTS/include\" -D__MSP430FR2355__ -D_FRWP_ENABLE -D_INFO_FRWP_ENABLE -xc",
"file" : "/home/frederik/workspace_ccstheia/ESR-11/src/timer.c"
},
{
"directory" : "/home/frederik/workspace_ccstheia/ESR-11/Debug",
"command" : "clang++ -I\"/home/frederik/.ti/ccs2010/ccs/ccs_base/msp430/include\" -I\"/home/frederik/workspace_ccstheia/ESR-11\" -I\"/home/frederik/workspace_ccstheia/ESR-11/jsmn\" -I\"/home/frederik/workspace_ccstheia/ESR-11/driverlib/MSP430FR2xx_4xx\" -I\"/home/frederik/.ti/ccs2010/ccs/tools/compiler/ti-cgt-msp430_21.6.1.LTS/include\" -D__MSP430FR2355__ -D_FRWP_ENABLE -D_INFO_FRWP_ENABLE -xc",
"file" : "/home/frederik/workspace_ccstheia/ESR-11/src/door_sensor.c"
} }
] ]

277
GUIComm_JSON.c Executable file
View File

@ -0,0 +1,277 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2020, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
// GUI Communication Layer
//
// API to communicate with GUI using JSON protocol
// Texas Instruments, Inc.**
#include <msp430.h>
#include <stdbool.h>
#include <stdint.h>
#include <HAL.h>
#include <GUI_JSON.h>
#include <include/GUIComm.h>
static void itoa(int32_t value, char* result);
static const char cmdTemplate[] = "{\"\":}\n";
static char cATXString[20];
//These values are used to concatenate the command and data to the command template
// when using the GUIComm_send functions
#define CMD_INDEX 1
#define DATA_INDEX 3
#define CMD_TEMPLATE_LENGTH 6
#define BASE 10
//! \brief Converts a number into a string
//!
//! \return none
void itoa(int32_t value, char* result)
{
char* ptr = result, *ptr1 = result, tmp_char;
uint32_t tmp_value;
tmp_value = labs(value);
do {
*ptr++ = "0123456789" [tmp_value%BASE];
tmp_value /= BASE;
} while (tmp_value);
// Apply negative sign
if (value < 0) *ptr++ = '-';
*ptr-- = '\0';
while(ptr1 < ptr) {
tmp_char = *ptr;
*ptr--= *ptr1;
*ptr1++ = tmp_char;
}
}
int GUIComm_sendUInt(char *cmd, uint8_t cmdLength, uint32_t val)
{
uint8_t i;
for (i = 0; i < CMD_TEMPLATE_LENGTH; i++)
{
HAL_GUI_TransmitCharBlocking(cmdTemplate[i]);
if (i == CMD_INDEX)
{
GUI_TransmitStringBlocking(cmd);
}
else if (i == DATA_INDEX)
{
itoa(val, cATXString);
GUI_TransmitStringBlocking(cATXString);
}
}
return 0;
}
int GUIComm_sendInt(char *cmd, uint8_t cmdLength, uint32_t val)
{
uint8_t i;
for (i = 0; i < CMD_TEMPLATE_LENGTH; i++)
{
HAL_GUI_TransmitCharBlocking(cmdTemplate[i]);
if (i == CMD_INDEX)
{
GUI_TransmitStringBlocking(cmd);
}
else if (i == DATA_INDEX)
{
itoa(val, cATXString);
GUI_TransmitStringBlocking(cATXString);
}
}
return 0;
}
int GUIComm_sendUInt8(char *cmd, uint8_t cmdLength, uint8_t val)
{
uint8_t i;
for (i = 0; i < CMD_TEMPLATE_LENGTH; i++)
{
HAL_GUI_TransmitCharBlocking(cmdTemplate[i]);
if (i == CMD_INDEX)
{
GUI_TransmitStringBlocking(cmd);
}
else if (i == DATA_INDEX)
{
itoa(val, cATXString);
GUI_TransmitStringBlocking(cATXString);
}
}
return 0;
}
int GUIComm_sendInt8(char *cmd, uint8_t cmdLength, int8_t val)
{
uint8_t i;
for (i = 0; i < CMD_TEMPLATE_LENGTH; i++)
{
HAL_GUI_TransmitCharBlocking(cmdTemplate[i]);
if (i == CMD_INDEX)
{
GUI_TransmitStringBlocking(cmd);
}
else if (i == DATA_INDEX)
{
itoa(val, cATXString);
GUI_TransmitStringBlocking(cATXString);
}
}
return 0;
}
int GUIComm_sendInt16(char *cmd, uint8_t cmdLength, int16_t val)
{
uint8_t i;
for (i = 0; i < CMD_TEMPLATE_LENGTH; i++)
{
HAL_GUI_TransmitCharBlocking(cmdTemplate[i]);
if (i == CMD_INDEX)
{
GUI_TransmitStringBlocking(cmd);
}
else if (i == DATA_INDEX)
{
itoa(val, cATXString);
GUI_TransmitStringBlocking(cATXString);
}
}
return 0;
}
int GUIComm_sendUInt16(char *cmd, uint8_t cmdLength, uint16_t val)
{
uint8_t i;
for (i = 0; i < CMD_TEMPLATE_LENGTH; i++)
{
HAL_GUI_TransmitCharBlocking(cmdTemplate[i]);
if (i == CMD_INDEX)
{
GUI_TransmitStringBlocking(cmd);
}
else if (i == DATA_INDEX)
{
itoa(val, cATXString);
GUI_TransmitStringBlocking(cATXString);
}
}
return 0;
}
int GUIComm_sendUInt32(char *cmd, uint8_t cmdLength, uint32_t val)
{
uint8_t i;
for (i = 0; i < CMD_TEMPLATE_LENGTH; i++)
{
HAL_GUI_TransmitCharBlocking(cmdTemplate[i]);
if (i == CMD_INDEX)
{
GUI_TransmitStringBlocking(cmd);
}
else if (i == DATA_INDEX)
{
itoa(val, cATXString);
GUI_TransmitStringBlocking(cATXString);
}
}
return 0;
}
int GUIComm_sendInt32(char *cmd, uint8_t cmdLength, int32_t val)
{
uint8_t i;
for (i = 0; i < CMD_TEMPLATE_LENGTH; i++)
{
HAL_GUI_TransmitCharBlocking(cmdTemplate[i]);
if (i == CMD_INDEX)
{
GUI_TransmitStringBlocking(cmd);
}
else if (i == DATA_INDEX)
{
itoa(val, cATXString);
GUI_TransmitStringBlocking(cATXString);
}
}
return 0;
}
int GUIComm_sendBool(char *cmd, uint8_t cmdLength, bool val)
{
uint16_t i;
for (i = 0; i < CMD_TEMPLATE_LENGTH; i++)
{
HAL_GUI_TransmitCharBlocking(cmdTemplate[i]);
if (i == CMD_INDEX)
{
GUI_TransmitStringBlocking(cmd);
}
else if (i == DATA_INDEX)
{
if (val == true)
{
GUI_TransmitStringBlocking("true");
}
else
{
GUI_TransmitStringBlocking("false");
}
}
}
return 0;
}

101
Include/GUIComm.h Executable file
View File

@ -0,0 +1,101 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2020, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
// Generic GUI Demo using MSP430
//
// API to communicate with GUI and abstract transport layer protocol
// Texas Instruments, Inc.
// ******************************************************************************
#ifndef INCLUDE_GUICOMM_H_
#define INCLUDE_GUICOMM_H_
//! ***** Functions to send data to GUI *****
//! \brief Sends a 32-bit integer.
//!
//! \return 0 if success, -1 if failure
extern int GUIComm_sendInt(char *cmd, uint8_t cmdLength, uint32_t val);
//! \brief Sends a 32-bit unsigned integer.
//!
//! \return 0 if success, -1 if failure
extern int GUIComm_sendUInt(char *cmd, uint8_t cmdLength, uint32_t val);
//! \brief Sends an uint8_t value to the GUI.
//!
//! \return 0 if success, -1 if failure
extern int GUIComm_sendUInt8(char *cmd, uint8_t cmdLength, uint8_t val);
//! \brief Sends an int8_t value to the GUI.
//!
//! \return 0 if success, -1 if failure
extern int GUIComm_sendInt8(char *cmd, uint8_t cmdLength, int8_t val);
//! \brief Sends an uint16_t value to the GUI.
//!
//! \return 0 if success, -1 if failure
extern int GUIComm_sendUInt16(char *cmd, uint8_t cmdLength, uint16_t val);
//! \brief Sends an int16_t value to the GUI.
//!
//! \return 0 if success, -1 if failure
extern int GUIComm_sendInt16(char *cmd, uint8_t cmdLength, int16_t val);
//! \brief Sends an uint32_t value to the GUI.
//!
//! \return 0 if success, -1 if failure
extern int GUIComm_sendUInt32(char *cmd, uint8_t cmdLength, uint32_t val);
//! \brief Sends an int32_t value to the GUI.
//!
//! \return 0 if success, -1 if failure
extern int GUIComm_sendInt32(char *cmd, uint8_t cmdLength, int32_t val);
//! \brief Sends an uint32_t value to the GUI.
//!
//! \return 0 if success, -1 if failure
extern int GUIComm_sendUInt64(char *cmd, uint8_t cmdLength, uint64_t val);
//! \brief Sends an int32_t value to the GUI.
//!
//! \return 0 if success, -1 if failure
extern int GUIComm_sendInt64(char *cmd, uint8_t cmdLength, int64_t val);
//! \brief Sends a bool value to the GUI.
//!
//! \return 0 if success, -1 if failure
extern int GUIComm_sendBool(char *cmd, uint8_t cmdLength, bool val);
#endif /* INCLUDE_GUICOMM_H_ */

101
Include/HAL.h Executable file
View File

@ -0,0 +1,101 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2019, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
// MSP430 HAL
//
// Hardware Abstraction Layer for MSP430
//
// Texas Instruments, Inc.
#ifndef __HAL_H__
#define __HAL_H__
#include <msp430.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
#include <Config_Common.h>
//! \brief GUI Comm RX Callback function pointer
//!
//! \param[in] char with Received byte
//!
//! \return true if device wakes-up after ISR, false if not.
typedef bool (*tGUICommRXCharCallback)(char );
// ********************* System ************************************************
//! \brief Initializes I/Os used by the system.
//! Initialization is done to achieve lowest power consumption.
//!
//!
//! \return 0 if OK, -1 if error
extern int8_t HAL_System_Init(void);
// ********************* I/O ***************************************************
//! \brief Initializes I/Os used by the system.
//! Initialization is done to achieve lowest power consumption.
//!
//!
//! \return none
extern void HAL_IO_Init(void);
//! \brief Initializes inputs used for push-buttons
//! Pins are initialized with pull-ups and interrupts are enabled.
//!
//!
//! \return none
extern void HAL_IO_InitButtons(void);
// ********************* Timer ***************************************************
//! \brief Initializes a simple periodic interrupt timer.
//! Timer is initialized using Low-frequency clock and interrupts
//! are enabled.
//!
//! \return none
extern void HAL_Timer_Init(void);
// ********************* GUI Communication *************************************
//! \brief Initializes the communication interface for GUI.
//!
//! \param[in] RxByteCallback is the function called when a byte is received.
//!
//! \return none
extern void HAL_GUI_Init(tGUICommRXCharCallback RxByteCallback);
//! \brief Transmits a character to the GUI in blocking mode.
//!
//! \param[in] character is the character being transmitted to GUI.
//!
//! \return none
extern void HAL_GUI_TransmitCharBlocking(char character);
#endif //__HAL_H__

3967
Include/IQmathLib.h Executable file

File diff suppressed because it is too large Load Diff

2100
Include/QmathLib.h Executable file

File diff suppressed because it is too large Load Diff

107
README.html Executable file

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
/* --COPYRIGHT--,BSD /* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated * Copyright (c) 2020, Texas Instruments Incorporated
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -29,14 +29,36 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* --/COPYRIGHT--*/ * --/COPYRIGHT--*/
#ifndef __DRIVERLIB_VERSION__ //*****************************************************************************
#define DRIVERLIB_VER_MAJOR 2 // callbacks_JSON.c
#define DRIVERLIB_VER_MINOR 90 //
#define DRIVERLIB_VER_PATCH 01 // Application level callbacks using JSON
#define DRIVERLIB_VER_BUILD 07 // Texas Instruments, Inc.
#endif
#define getVersion() ((uint32_t)DRIVERLIB_VER_MAJOR << 24 | \ #include <callbacks_JSON.h>
(uint32_t)DRIVERLIB_VER_MINOR << 16 | \
(uint32_t)DRIVERLIB_VER_PATCH << 8 | \ static bool getBoolFromString(char * string);
(uint32_t)DRIVERLIB_VER_BUILD)
// ***** Application Callback Functions to Process data *****
void GUICallback_boolEnable(char * string)
{
// Example to receive a boolean
bEnableSwitch = getBoolFromString(string);
}
void GUICallback_QMathData(char * string)
{
qIncrement = strtol(string, NULL, 10);
}
static bool getBoolFromString(char * string)
{
if (strncmp(string, "true", 4) == 0)
{
return true;
}
else
{
return false;
}
}

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 140 KiB

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +0,0 @@
#!/usr/bin/env bash
doxygen doxygen.conf
cd latex
make
cd ..
cp latex/refman.pdf ./doxygen.pdf
xdg-open ./doxygen.pdf

View File

@ -1,244 +0,0 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
//
// adc.c - Driver for the adc Module.
//
//*****************************************************************************
//*****************************************************************************
//
//! \addtogroup adc_api adc
//! @{
//
//*****************************************************************************
#include "inc/hw_memmap.h"
#ifdef __MSP430_HAS_ADC__
#include "adc.h"
#include <assert.h>
void ADC_init(uint16_t baseAddress,
uint16_t sampleHoldSignalSourceSelect,
uint8_t clockSourceSelect,
uint16_t clockSourceDivider)
{
//Turn OFF ADC Module & Clear Interrupt Registers
HWREG16(baseAddress + OFS_ADCCTL0) &= ~(ADCON + ADCENC + ADCSC);
HWREG16(baseAddress + OFS_ADCIE) &= 0x0000; //Reset ALL interrupt enables
HWREG16(baseAddress + OFS_ADCIFG) &= 0x0000; //Reset ALL interrupt flags
//Set ADC Control 1
HWREG16(baseAddress + OFS_ADCCTL1) = sampleHoldSignalSourceSelect //Setup the Sample-and-Hold Source
+ (clockSourceDivider & ADCDIV_7) //Set Clock Divider
+ clockSourceSelect; //Setup Clock Source
//Set ADC Control 2
HWREG16(baseAddress + OFS_ADCCTL2) = (clockSourceDivider & ADCPDIV_3) //Set Clock Pre-Divider
+ ADCRES_1; //Default resolution to 10-bits
}
void ADC_enable(uint16_t baseAddress)
{
//Reset the ADCON bit to enable the ADC Module
HWREG16(baseAddress + OFS_ADCCTL0) |= ADCON;
}
void ADC_disable(uint16_t baseAddress)
{
//Set the ADCON bit to disable the ADC Module
HWREG16(baseAddress + OFS_ADCCTL0) &= ~ADCON;
}
void ADC_setupSamplingTimer(uint16_t baseAddress,
uint16_t clockCycleHoldCount,
uint16_t multipleSamplesEnabled)
{
HWREG16(baseAddress + OFS_ADCCTL1) |= ADCSHP;
//Reset and Set CB Control 0 Bits
HWREG16(baseAddress + OFS_ADCCTL0) &= ~(ADCSHT_15 + ADCMSC);
HWREG16(baseAddress +
OFS_ADCCTL0) |= clockCycleHoldCount + multipleSamplesEnabled;
}
void ADC_disableSamplingTimer(uint16_t baseAddress)
{
HWREG16(baseAddress + OFS_ADCCTL1) &= ~(ADCSHP);
}
void ADC_configureMemory(uint16_t baseAddress,
uint8_t inputSourceSelect,
uint8_t positiveRefVoltageSourceSelect,
uint8_t negativeRefVoltageSourceSelect)
{
//Make sure the ENC bit is cleared before configuring a Memory Buffer Control
assert(!(HWREG16(baseAddress + OFS_ADCCTL0) & ADCENC));
if(!(HWREG16(baseAddress + OFS_ADCCTL0) & ADCENC))
{
#ifdef ADCPCTL9
//Enable ADC input pin
if(inputSourceSelect < ADCINCH_10)
{
HWREG16(SYS_BASE + OFS_SYSCFG2) |= (1 << inputSourceSelect);
}
#elif ADCPCTL7
if(inputSourceSelect < ADCINCH_8)
{
HWREG16(SYS_BASE + OFS_SYSCFG2) |= (1 << inputSourceSelect);
}
#endif
//Reset and Set the Memory Buffer Control Bits
HWREG16(baseAddress +
OFS_ADCMCTL0) = inputSourceSelect +
positiveRefVoltageSourceSelect
+ negativeRefVoltageSourceSelect;
}
}
void ADC_enableInterrupt(uint16_t baseAddress,
uint8_t interruptMask)
{
HWREG16(baseAddress + OFS_ADCIE) |= interruptMask;
}
void ADC_disableInterrupt(uint16_t baseAddress,
uint8_t interruptMask)
{
HWREG16(baseAddress + OFS_ADCIE) &= ~(interruptMask);
}
void ADC_clearInterrupt(uint16_t baseAddress,
uint8_t interruptFlagMask)
{
HWREG16(baseAddress + OFS_ADCIFG) &= ~(interruptFlagMask);
}
uint8_t ADC_getInterruptStatus(uint16_t baseAddress,
uint8_t interruptFlagMask)
{
return (HWREG16(baseAddress + OFS_ADCIFG) & interruptFlagMask);
}
void ADC_startConversion(uint16_t baseAddress,
uint8_t conversionSequenceModeSelect)
{
//Reset the ENC bit to set the conversion mode sequence
HWREG16(baseAddress + OFS_ADCCTL0) &= ~(ADCENC);
HWREG16(baseAddress + OFS_ADCCTL1) &= ~ADCCONSEQ;
HWREG16(baseAddress + OFS_ADCCTL1) |= conversionSequenceModeSelect;
HWREG16(baseAddress + OFS_ADCCTL0) |= ADCENC | ADCSC;
}
void ADC_disableConversions(uint16_t baseAddress,
bool preempt)
{
if(!preempt)
{
if(!(HWREG16(baseAddress + OFS_ADCCTL1) & ADCCONSEQ_3))
{
//To prevent preemption of a single-channel, single-conversion we must
//wait for the ADC core to finish the conversion.
while(HWREG16(baseAddress + OFS_ADCCTL1) & ADCBUSY)
{
;
}
}
}
HWREG16(baseAddress + OFS_ADCCTL0) &= ~(ADCENC);
HWREG16(baseAddress + OFS_ADCCTL1) &= ~(ADCCONSEQ_3);
}
int16_t ADC_getResults(uint16_t baseAddress)
{
return((int16_t)(HWREG16(baseAddress + OFS_ADCMEM0)));
}
void ADC_setResolution(uint16_t baseAddress,
uint8_t resolutionSelect)
{
HWREG16(baseAddress + OFS_ADCCTL2) &= ~(ADCRES);
HWREG16(baseAddress + OFS_ADCCTL2) |= resolutionSelect;
}
void ADC_setSampleHoldSignalInversion(uint16_t baseAddress,
uint16_t invertedSignal)
{
HWREG16(baseAddress + OFS_ADCCTL1) &= ~(ADCISSH);
HWREG16(baseAddress + OFS_ADCCTL1) |= invertedSignal;
}
void ADC_setDataReadBackFormat(uint16_t baseAddress,
uint16_t readBackFormat)
{
HWREG16(baseAddress + OFS_ADCCTL2) &= ~(ADCDF);
HWREG16(baseAddress + OFS_ADCCTL2) |= readBackFormat;
}
void ADC_setReferenceBufferSamplingRate(uint16_t baseAddress,
uint16_t samplingRateSelect)
{
HWREG16(baseAddress + OFS_ADCCTL2) &= ~(ADCSR);
HWREG16(baseAddress + OFS_ADCCTL2) |= samplingRateSelect;
}
void ADC_setWindowComp(uint16_t baseAddress,
uint16_t highThreshold,
uint16_t lowThreshold)
{
HWREG16(baseAddress + OFS_ADCHI) = highThreshold;
HWREG16(baseAddress + OFS_ADCLO) = lowThreshold;
}
uint32_t ADC_getMemoryAddressForDMA(uint16_t baseAddress)
{
return (baseAddress + OFS_ADCMEM0);
}
uint8_t ADC_isBusy(uint16_t baseAddress)
{
return (HWREG16(baseAddress + OFS_ADCCTL1) & ADCBUSY);
}
#endif
//*****************************************************************************
//
//! Close the doxygen group for adc_api
//! @}
//
//*****************************************************************************

View File

@ -1,892 +0,0 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
//
// adc.h - Driver for the ADC Module.
//
//*****************************************************************************
#ifndef __MSP430WARE_ADC_H__
#define __MSP430WARE_ADC_H__
#include "inc/hw_memmap.h"
#ifdef __MSP430_HAS_ADC__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
// The following are values that can be passed to the clockSourceSelect
// parameter for functions: ADC_init().
//
//*****************************************************************************
#define ADC_CLOCKSOURCE_ADCOSC (ADCSSEL_0)
#define ADC_CLOCKSOURCE_ACLK (ADCSSEL_1)
#define ADC_CLOCKSOURCE_SMCLK (ADCSSEL_2)
//*****************************************************************************
//
// The following are values that can be passed to the clockSourceDivider
// parameter for functions: ADC_init().
//
//*****************************************************************************
#define ADC_CLOCKDIVIDER_1 (ADCDIV_0 + ADCPDIV_0)
#define ADC_CLOCKDIVIDER_2 (ADCDIV_1 + ADCPDIV_0)
#define ADC_CLOCKDIVIDER_3 (ADCDIV_2 + ADCPDIV_0)
#define ADC_CLOCKDIVIDER_4 (ADCDIV_3 + ADCPDIV_0)
#define ADC_CLOCKDIVIDER_5 (ADCDIV_4 + ADCPDIV_0)
#define ADC_CLOCKDIVIDER_6 (ADCDIV_5 + ADCPDIV_0)
#define ADC_CLOCKDIVIDER_7 (ADCDIV_6 + ADCPDIV_0)
#define ADC_CLOCKDIVIDER_8 (ADCDIV_7 + ADCPDIV_0)
#define ADC_CLOCKDIVIDER_12 (ADCDIV_2 + ADCPDIV_1)
#define ADC_CLOCKDIVIDER_16 (ADCDIV_3 + ADCPDIV_1)
#define ADC_CLOCKDIVIDER_20 (ADCDIV_4 + ADCPDIV_1)
#define ADC_CLOCKDIVIDER_24 (ADCDIV_5 + ADCPDIV_1)
#define ADC_CLOCKDIVIDER_28 (ADCDIV_6 + ADCPDIV_1)
#define ADC_CLOCKDIVIDER_32 (ADCDIV_7 + ADCPDIV_1)
#define ADC_CLOCKDIVIDER_64 (ADCDIV_0 + ADCPDIV_2)
#define ADC_CLOCKDIVIDER_128 (ADCDIV_1 + ADCPDIV_2)
#define ADC_CLOCKDIVIDER_192 (ADCDIV_2 + ADCPDIV_2)
#define ADC_CLOCKDIVIDER_256 (ADCDIV_3 + ADCPDIV_2)
#define ADC_CLOCKDIVIDER_320 (ADCDIV_4 + ADCPDIV_2)
#define ADC_CLOCKDIVIDER_384 (ADCDIV_5 + ADCPDIV_2)
#define ADC_CLOCKDIVIDER_448 (ADCDIV_6 + ADCPDIV_2)
#define ADC_CLOCKDIVIDER_512 (ADCDIV_7 + ADCPDIV_2)
//*****************************************************************************
//
// The following are values that can be passed to the
// sampleHoldSignalSourceSelect parameter for functions: ADC_init().
//
//*****************************************************************************
#define ADC_SAMPLEHOLDSOURCE_SC (ADCSHS_0)
#define ADC_SAMPLEHOLDSOURCE_1 (ADCSHS_1)
#define ADC_SAMPLEHOLDSOURCE_2 (ADCSHS_2)
#define ADC_SAMPLEHOLDSOURCE_3 (ADCSHS_3)
//*****************************************************************************
//
// The following are values that can be passed to the multipleSamplesEnabled
// parameter for functions: ADC_setupSamplingTimer().
//
//*****************************************************************************
#define ADC_MULTIPLESAMPLESDISABLE (!(ADCMSC))
#define ADC_MULTIPLESAMPLESENABLE (ADCMSC)
//*****************************************************************************
//
// The following are values that can be passed to the clockCycleHoldCount
// parameter for functions: ADC_setupSamplingTimer().
//
//*****************************************************************************
#define ADC_CYCLEHOLD_4_CYCLES (ADCSHT_0)
#define ADC_CYCLEHOLD_8_CYCLES (ADCSHT_1)
#define ADC_CYCLEHOLD_16_CYCLES (ADCSHT_2)
#define ADC_CYCLEHOLD_32_CYCLES (ADCSHT_3)
#define ADC_CYCLEHOLD_64_CYCLES (ADCSHT_4)
#define ADC_CYCLEHOLD_96_CYCLES (ADCSHT_5)
#define ADC_CYCLEHOLD_128_CYCLES (ADCSHT_6)
#define ADC_CYCLEHOLD_192_CYCLES (ADCSHT_7)
#define ADC_CYCLEHOLD_256_CYCLES (ADCSHT_8)
#define ADC_CYCLEHOLD_384_CYCLES (ADCSHT_9)
#define ADC_CYCLEHOLD_512_CYCLES (ADCSHT_10)
#define ADC_CYCLEHOLD_768_CYCLES (ADCSHT_11)
#define ADC_CYCLEHOLD_1024_CYCLES (ADCSHT_12)
//*****************************************************************************
//
// The following are values that can be passed to the inputSourceSelect
// parameter for functions: ADC_configureMemory().
//
//*****************************************************************************
#define ADC_INPUT_VEREF_N (ADCINCH_0)
#define ADC_INPUT_VEREF_P (ADCINCH_1)
#define ADC_INPUT_A2 (ADCINCH_2)
#define ADC_INPUT_A3 (ADCINCH_3)
#define ADC_INPUT_A4 (ADCINCH_4)
#define ADC_INPUT_A5 (ADCINCH_5)
#define ADC_INPUT_A6 (ADCINCH_6)
#define ADC_INPUT_A7 (ADCINCH_7)
#define ADC_INPUT_A8 (ADCINCH_8)
#define ADC_INPUT_A9 (ADCINCH_9)
#define ADC_INPUT_TEMPSENSOR (ADCINCH_12)
#define ADC_INPUT_REFVOLTAGE (ADCINCH_13)
#define ADC_INPUT_DVSS (ADCINCH_14)
#define ADC_INPUT_DVCC (ADCINCH_15)
//*****************************************************************************
//
// The following are values that can be passed to the
// positiveRefVoltageSourceSelect parameter for functions:
// ADC_configureMemory().
//
//*****************************************************************************
#define ADC_VREFPOS_AVCC (!(ADCSREF0 + ADCSREF1))
#define ADC_VREFPOS_INT (ADCSREF0)
#define ADC_VREFPOS_EXT_BUF (ADCSREF1)
#define ADC_VREFPOS_EXT_NOBUF (ADCSREF1 + ADCSREF0)
//*****************************************************************************
//
// The following are values that can be passed to the
// negativeRefVoltageSourceSelect parameter for functions:
// ADC_configureMemory().
//
//*****************************************************************************
#define ADC_VREFNEG_AVSS (!(ADCSREF2))
#define ADC_VREFNEG_EXT (ADCSREF2)
//*****************************************************************************
//
// The following are values that can be passed to the interruptMask parameter
// for functions: ADC_enableInterrupt(), and ADC_disableInterrupt().
//
//*****************************************************************************
#define ADC_OVERFLOW_INTERRUPT (ADCOVIE)
#define ADC_TIMEOVERFLOW_INTERRUPT (ADCTOVIE)
#define ADC_ABOVETHRESHOLD_INTERRUPT (ADCHIIE)
#define ADC_BELOWTHRESHOLD_INTERRUPT (ADCLOIE)
#define ADC_INSIDEWINDOW_INTERRUPT (ADCINIE)
#define ADC_COMPLETED_INTERRUPT (ADCIE0)
//*****************************************************************************
//
// The following are values that can be passed to the interruptFlagMask
// parameter for functions: ADC_clearInterrupt(), and ADC_getInterruptStatus().
//
//*****************************************************************************
#define ADC_OVERFLOW_INTERRUPT_FLAG (ADCOVIFG)
#define ADC_TIMEOVERFLOW_INTERRUPT_FLAG (ADCTOVIFG)
#define ADC_ABOVETHRESHOLD_INTERRUPT_FLAG (ADCHIIFG)
#define ADC_BELOWTHRESHOLD_INTERRUPT_FLAG (ADCLOIFG)
#define ADC_INSIDEWINDOW_INTERRUPT_FLAG (ADCINIFG)
#define ADC_COMPLETED_INTERRUPT_FLAG (ADCIFG0)
//*****************************************************************************
//
// The following are values that can be passed to the
// conversionSequenceModeSelect parameter for functions: ADC_startConversion().
//
//*****************************************************************************
#define ADC_SINGLECHANNEL (ADCCONSEQ_0)
#define ADC_SEQOFCHANNELS (ADCCONSEQ_1)
#define ADC_REPEATED_SINGLECHANNEL (ADCCONSEQ_2)
#define ADC_REPEATED_SEQOFCHANNELS (ADCCONSEQ_3)
//*****************************************************************************
//
// The following are values that can be passed to the preempt parameter for
// functions: ADC_disableConversions().
//
//*****************************************************************************
#define ADC_COMPLETECONVERSION false
#define ADC_PREEMPTCONVERSION true
//*****************************************************************************
//
// The following are values that can be passed to the resolutionSelect
// parameter for functions: ADC_setResolution().
//
//*****************************************************************************
#define ADC_RESOLUTION_8BIT (0x0)
#define ADC_RESOLUTION_10BIT (0x10)
#define ADC_RESOLUTION_12BIT (0x20)
//*****************************************************************************
//
// The following are values that can be passed to the invertedSignal parameter
// for functions: ADC_setSampleHoldSignalInversion().
//
//*****************************************************************************
#define ADC_NONINVERTEDSIGNAL (!(ADCISSH))
#define ADC_INVERTEDSIGNAL (ADCISSH)
//*****************************************************************************
//
// The following are values that can be passed to the readBackFormat parameter
// for functions: ADC_setDataReadBackFormat().
//
//*****************************************************************************
#define ADC_UNSIGNED_BINARY (!(ADCDF))
#define ADC_SIGNED_2SCOMPLEMENT (ADCDF)
//*****************************************************************************
//
// The following are values that can be passed to the samplingRateSelect
// parameter for functions: ADC_setReferenceBufferSamplingRate().
//
//*****************************************************************************
#define ADC_MAXSAMPLINGRATE_200KSPS (!(ADCSR))
#define ADC_MAXSAMPLINGRATE_50KSPS (ADCSR)
//*****************************************************************************
//
// The following are values that can be passed toThe following are values that
// can be returned by the ADC_isBusy() function.
//
//*****************************************************************************
#define ADC_NOTBUSY (0x00)
#define ADC_BUSY (ADCBUSY)
//*****************************************************************************
//
// Prototypes for the APIs.
//
//*****************************************************************************
//*****************************************************************************
//
//! \brief Initializes the ADC Module.
//!
//! This function initializes the ADC module to allow for analog-to-digital
//! conversions. Specifically this function sets up the sample-and-hold signal
//! and clock sources for the ADC core to use for conversions. Upon successful
//! completion of the initialization all of the ADC control registers will be
//! reset, excluding the memory controls and reference module bits, the given
//! parameters will be set, and the ADC core will be turned on (Note, that the
//! ADC core only draws power during conversions and remains off when not
//! converting).Note that sample/hold signal sources are device dependent. Note
//! that if re-initializing the ADC after starting a conversion with the
//! startConversion() function, the disableConversion() must be called BEFORE
//! this function can be called.
//!
//! \param baseAddress is the base address of the ADC module.
//! \param sampleHoldSignalSourceSelect is the signal that will trigger a
//! sample-and-hold for an input signal to be converted. This parameter
//! is device specific and sources should be found in the device's
//! datasheet.
//! Valid values are:
//! - \b ADC_SAMPLEHOLDSOURCE_SC [Default]
//! - \b ADC_SAMPLEHOLDSOURCE_1
//! - \b ADC_SAMPLEHOLDSOURCE_2
//! - \b ADC_SAMPLEHOLDSOURCE_3
//! \n Modified bits are \b ADCSHSx of \b ADCCTL1 register.
//! \param clockSourceSelect selects the clock that will be used by the ADC
//! core and the sampling timer if a sampling pulse mode is enabled.
//! Valid values are:
//! - \b ADC_CLOCKSOURCE_ADCOSC [Default] - MODOSC 5 MHz oscillator from
//! the clock system
//! - \b ADC_CLOCKSOURCE_ACLK - The Auxilary Clock
//! - \b ADC_CLOCKSOURCE_SMCLK - The Sub-Master Clock
//! \n Modified bits are \b ADCSSELx of \b ADCCTL1 register.
//! \param clockSourceDivider selects the amount that the clock will be
//! divided.
//! Valid values are:
//! - \b ADC_CLOCKDIVIDER_1 [Default]
//! - \b ADC_CLOCKDIVIDER_2
//! - \b ADC_CLOCKDIVIDER_3
//! - \b ADC_CLOCKDIVIDER_4
//! - \b ADC_CLOCKDIVIDER_5
//! - \b ADC_CLOCKDIVIDER_6
//! - \b ADC_CLOCKDIVIDER_7
//! - \b ADC_CLOCKDIVIDER_8
//! - \b ADC_CLOCKDIVIDER_12
//! - \b ADC_CLOCKDIVIDER_16
//! - \b ADC_CLOCKDIVIDER_20
//! - \b ADC_CLOCKDIVIDER_24
//! - \b ADC_CLOCKDIVIDER_28
//! - \b ADC_CLOCKDIVIDER_32
//! - \b ADC_CLOCKDIVIDER_64
//! - \b ADC_CLOCKDIVIDER_128
//! - \b ADC_CLOCKDIVIDER_192
//! - \b ADC_CLOCKDIVIDER_256
//! - \b ADC_CLOCKDIVIDER_320
//! - \b ADC_CLOCKDIVIDER_384
//! - \b ADC_CLOCKDIVIDER_448
//! - \b ADC_CLOCKDIVIDER_512
//! \n Modified bits are \b ADCDIVx of \b ADCCTL1 register; bits \b
//! ADCPDIVx of \b ADCCTL2 register.
//!
//! \return None
//
//*****************************************************************************
extern void ADC_init(uint16_t baseAddress,
uint16_t sampleHoldSignalSourceSelect,
uint8_t clockSourceSelect,
uint16_t clockSourceDivider);
//*****************************************************************************
//
//! \brief Enables the ADC block.
//!
//! This will enable operation of the ADC block.
//!
//! \param baseAddress is the base address of the ADC module.
//!
//! Modified bits are \b ADCON of \b ADCCTL0 register.
//!
//! \return None
//
//*****************************************************************************
extern void ADC_enable(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Disables the ADC block.
//!
//! This will disable operation of the ADC block.
//!
//! \param baseAddress is the base address of the ADC module.
//!
//! Modified bits are \b ADCON of \b ADCCTL0 register.
//!
//! \return None
//
//*****************************************************************************
extern void ADC_disable(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Sets up and enables the Sampling Timer Pulse Mode.
//!
//! This function sets up the sampling timer pulse mode which allows the
//! sample/hold signal to trigger a sampling timer to sample-and-hold an input
//! signal for a specified number of clock cycles without having to hold the
//! sample/hold signal for the entire period of sampling. Note that if a
//! conversion has been started with the startConversion() function, then a
//! call to disableConversions() is required before this function may be
//! called.
//!
//! \param baseAddress is the base address of the ADC module.
//! \param clockCycleHoldCount sets the amount of clock cycles to sample-and-
//! hold for the memory buffer.
//! Valid values are:
//! - \b ADC_CYCLEHOLD_4_CYCLES [Default]
//! - \b ADC_CYCLEHOLD_8_CYCLES
//! - \b ADC_CYCLEHOLD_16_CYCLES
//! - \b ADC_CYCLEHOLD_32_CYCLES
//! - \b ADC_CYCLEHOLD_64_CYCLES
//! - \b ADC_CYCLEHOLD_96_CYCLES
//! - \b ADC_CYCLEHOLD_128_CYCLES
//! - \b ADC_CYCLEHOLD_192_CYCLES
//! - \b ADC_CYCLEHOLD_256_CYCLES
//! - \b ADC_CYCLEHOLD_384_CYCLES
//! - \b ADC_CYCLEHOLD_512_CYCLES
//! - \b ADC_CYCLEHOLD_768_CYCLES
//! - \b ADC_CYCLEHOLD_1024_CYCLES
//! \n Modified bits are \b ADCSHTx of \b ADCCTL0 register.
//! \param multipleSamplesEnabled allows multiple conversions to start without
//! a trigger signal from the sample/hold signal
//! Valid values are:
//! - \b ADC_MULTIPLESAMPLESDISABLE - a timer trigger will be needed to
//! start every ADC conversion.
//! - \b ADC_MULTIPLESAMPLESENABLE - during a sequenced and/or repeated
//! conversion mode, after the first conversion, no sample/hold
//! signal is necessary to start subsequent samples.
//! \n Modified bits are \b ADCMSC of \b ADCCTL0 register.
//!
//! \return None
//
//*****************************************************************************
extern void ADC_setupSamplingTimer(uint16_t baseAddress,
uint16_t clockCycleHoldCount,
uint16_t multipleSamplesEnabled);
//*****************************************************************************
//
//! \brief Disables Sampling Timer Pulse Mode.
//!
//! Disables the Sampling Timer Pulse Mode. Note that if a conversion has been
//! started with the startConversion() function, then a call to
//! disableConversions() is required before this function may be called.
//!
//! \param baseAddress is the base address of the ADC module.
//!
//! Modified bits are \b ADCSHP of \b ADCCTL1 register.
//!
//! \return None
//
//*****************************************************************************
extern void ADC_disableSamplingTimer(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Configures the controls of the selected memory buffer.
//!
//! Maps an input signal conversion into the memory buffer, as well as the
//! positive and negative reference voltages for each conversion being stored
//! into the memory buffer. If the internal reference is used for the positive
//! reference voltage, the internal REF module has to control the voltage
//! level. Note that if a conversion has been started with the
//! startConversion() function, then a call to disableConversions() is required
//! before this function may be called. If conversion is not disabled, this
//! function does nothing.
//!
//! \param baseAddress is the base address of the ADC module.
//! \param inputSourceSelect is the input that will store the converted data
//! into the specified memory buffer.
//! Valid values are:
//! - \b ADC_INPUT_VEREF_N [Default]
//! - \b ADC_INPUT_VEREF_P
//! - \b ADC_INPUT_A2
//! - \b ADC_INPUT_A3
//! - \b ADC_INPUT_A4
//! - \b ADC_INPUT_A5
//! - \b ADC_INPUT_A6
//! - \b ADC_INPUT_A7
//! - \b ADC_INPUT_A8 - [Valid for FR4xx devices]
//! - \b ADC_INPUT_A9 - [Valid for FR4xx devices]
//! - \b ADC_INPUT_TEMPSENSOR
//! - \b ADC_INPUT_REFVOLTAGE
//! - \b ADC_INPUT_DVSS
//! - \b ADC_INPUT_DVCC
//! \n Modified bits are \b ADCINCHx of \b ADCMCTL0 register.
//! \param positiveRefVoltageSourceSelect is the reference voltage source to
//! set as the upper limit for the conversion that is to be stored in
//! the specified memory buffer.
//! Valid values are:
//! - \b ADC_VREFPOS_AVCC [Default]
//! - \b ADC_VREFPOS_INT
//! - \b ADC_VREFPOS_EXT_BUF
//! - \b ADC_VREFPOS_EXT_NOBUF
//! \n Modified bits are \b ADCSREF of \b ADCMCTL0 register.
//! \param negativeRefVoltageSourceSelect is the reference voltage source to
//! set as the lower limit for the conversion that is to be stored in
//! the specified memory buffer.
//! Valid values are:
//! - \b ADC_VREFNEG_AVSS [Default]
//! - \b ADC_VREFNEG_EXT
//! \n Modified bits are \b ADCSREF of \b ADCMCTL0 register.
//!
//! \return None
//
//*****************************************************************************
extern void ADC_configureMemory(uint16_t baseAddress,
uint8_t inputSourceSelect,
uint8_t positiveRefVoltageSourceSelect,
uint8_t negativeRefVoltageSourceSelect);
//*****************************************************************************
//
//! \brief Enables selected ADC interrupt sources.
//!
//! Enables the indicated ADC interrupt sources. Only the sources that are
//! enabled can be reflected to the processor interrupt; disabled sources have
//! no effect on the processor. <b>Does not clear interrupt flags.
//!
//! \param baseAddress is the base address of the ADC module.
//! \param interruptMask is the bit mask of the memory buffer interrupt sources
//! to be enabled.
//! Mask value is the logical OR of any of the following:
//! - \b ADC_OVERFLOW_INTERRUPT - Interrupts when a new conversion is
//! about to overwrite the previous one
//! - \b ADC_TIMEOVERFLOW_INTERRUPT - Interrupts when a new conversion
//! is starting before the previous one has finished
//! - \b ADC_ABOVETHRESHOLD_INTERRUPT - Interrups when the input signal
//! has gone above the high threshold of the window comparator
//! - \b ADC_BELOWTHRESHOLD_INTERRUPT - Interrupts when the input signal
//! has gone below the low threshold of the low window comparator
//! - \b ADC_INSIDEWINDOW_INTERRUPT - Interrupts when the input signal
//! is in between the high and low thresholds of the window
//! comparator
//! - \b ADC_COMPLETED_INTERRUPT - Interrupt for new conversion data in
//! the memory buffer
//!
//! Modified bits of \b ADCIE register.
//!
//! \return None
//
//*****************************************************************************
extern void ADC_enableInterrupt(uint16_t baseAddress,
uint8_t interruptMask);
//*****************************************************************************
//
//! \brief Disables selected ADC interrupt sources.
//!
//! Disables the indicated ADC interrupt sources. Only the sources that are
//! enabled can be reflected to the processor interrupt; disabled sources have
//! no effect on the processor.
//!
//! \param baseAddress is the base address of the ADC module.
//! \param interruptMask is the bit mask of the memory buffer interrupt sources
//! to be disabled.
//! Mask value is the logical OR of any of the following:
//! - \b ADC_OVERFLOW_INTERRUPT - Interrupts when a new conversion is
//! about to overwrite the previous one
//! - \b ADC_TIMEOVERFLOW_INTERRUPT - Interrupts when a new conversion
//! is starting before the previous one has finished
//! - \b ADC_ABOVETHRESHOLD_INTERRUPT - Interrups when the input signal
//! has gone above the high threshold of the window comparator
//! - \b ADC_BELOWTHRESHOLD_INTERRUPT - Interrupts when the input signal
//! has gone below the low threshold of the low window comparator
//! - \b ADC_INSIDEWINDOW_INTERRUPT - Interrupts when the input signal
//! is in between the high and low thresholds of the window
//! comparator
//! - \b ADC_COMPLETED_INTERRUPT - Interrupt for new conversion data in
//! the memory buffer
//!
//! Modified bits of \b ADCIE register.
//!
//! \return None
//
//*****************************************************************************
extern void ADC_disableInterrupt(uint16_t baseAddress,
uint8_t interruptMask);
//*****************************************************************************
//
//! \brief Clears ADC10B selected interrupt flags.
//!
//! The selected ADC interrupt flags are cleared, so that it no longer asserts.
//! The memory buffer interrupt flags are only cleared when the memory buffer
//! is accessed.
//!
//! \param baseAddress is the base address of the ADC module.
//! \param interruptFlagMask is a bit mask of the interrupt flags to be
//! cleared.
//! Mask value is the logical OR of any of the following:
//! - \b ADC_OVERFLOW_INTERRUPT_FLAG - Interrupt flag for when a new
//! conversion is about to overwrite the previous one
//! - \b ADC_TIMEOVERFLOW_INTERRUPT_FLAG - Interrupt flag for when a new
//! conversion is starting before the previous one has finished
//! - \b ADC_ABOVETHRESHOLD_INTERRUPT_FLAG - Interrup flag for when the
//! input signal has gone above the high threshold of the window
//! comparator
//! - \b ADC_BELOWTHRESHOLD_INTERRUPT_FLAG - Interrupt flag for when the
//! input signal has gone below the low threshold of the window
//! comparator
//! - \b ADC_INSIDEWINDOW_INTERRUPT_FLAG - Interrupt flag for when the
//! input signal is in between the high and low thresholds of the
//! window comparator
//! - \b ADC_COMPLETED_INTERRUPT_FLAG - Interrupt flag for new
//! conversion data in the memory buffer
//!
//! Modified bits of \b ADCIFG register.
//!
//! \return None
//
//*****************************************************************************
extern void ADC_clearInterrupt(uint16_t baseAddress,
uint8_t interruptFlagMask);
//*****************************************************************************
//
//! \brief Returns the status of the selected memory interrupt flags.
//!
//! Returns the status of the selected interrupt flags.
//!
//! \param baseAddress is the base address of the ADC module.
//! \param interruptFlagMask is a bit mask of the interrupt flags status to be
//! returned.
//! Mask value is the logical OR of any of the following:
//! - \b ADC_OVERFLOW_INTERRUPT_FLAG - Interrupt flag for when a new
//! conversion is about to overwrite the previous one
//! - \b ADC_TIMEOVERFLOW_INTERRUPT_FLAG - Interrupt flag for when a new
//! conversion is starting before the previous one has finished
//! - \b ADC_ABOVETHRESHOLD_INTERRUPT_FLAG - Interrup flag for when the
//! input signal has gone above the high threshold of the window
//! comparator
//! - \b ADC_BELOWTHRESHOLD_INTERRUPT_FLAG - Interrupt flag for when the
//! input signal has gone below the low threshold of the window
//! comparator
//! - \b ADC_INSIDEWINDOW_INTERRUPT_FLAG - Interrupt flag for when the
//! input signal is in between the high and low thresholds of the
//! window comparator
//! - \b ADC_COMPLETED_INTERRUPT_FLAG - Interrupt flag for new
//! conversion data in the memory buffer
//!
//! Modified bits of \b ADC10IFG register.
//!
//! \return The current interrupt flag status for the corresponding mask.
//
//*****************************************************************************
extern uint8_t ADC_getInterruptStatus(uint16_t baseAddress,
uint8_t interruptFlagMask);
//*****************************************************************************
//
//! \brief Enables/Starts an Analog-to-Digital Conversion.
//!
//! This function enables/starts the conversion process of the ADC. If the
//! sample/hold signal source chosen during initialization was ADCOSC, then the
//! conversion is started immediately, otherwise the chosen sample/hold signal
//! source starts the conversion by a rising edge of the signal. Keep in mind
//! when selecting conversion modes, that for sequenced and/or repeated modes,
//! to keep the sample/hold-and-convert process continuing without a trigger
//! from the sample/hold signal source, the multiple samples must be enabled
//! using the ADC_setupSamplingTimer() function. Also note that when a sequence
//! conversion mode is selected, the first input channel is the one mapped to
//! the memory buffer, the next input channel selected for conversion is one
//! less than the input channel just converted (i.e. A1 comes after A2), until
//! A0 is reached, and if in repeating mode, then the next input channel will
//! again be the one mapped to the memory buffer. Note that after this function
//! is called, the ADC_stopConversions() has to be called to re-initialize the
//! ADC, reconfigure a memory buffer control, enable/disable the sampling
//! timer, or to change the internal reference voltage.
//!
//! \param baseAddress is the base address of the ADC module.
//! \param conversionSequenceModeSelect determines the ADC operating mode.
//! Valid values are:
//! - \b ADC_SINGLECHANNEL [Default] - one-time conversion of a single
//! channel into a single memory buffer
//! - \b ADC_SEQOFCHANNELS - one time conversion of multiple channels
//! into the specified starting memory buffer and each subsequent
//! memory buffer up until the conversion is stored in a memory
//! buffer dedicated as the end-of-sequence by the memory's control
//! register
//! - \b ADC_REPEATED_SINGLECHANNEL - repeated conversions of one
//! channel into a single memory buffer
//! - \b ADC_REPEATED_SEQOFCHANNELS - repeated conversions of multiple
//! channels into the specified starting memory buffer and each
//! subsequent memory buffer up until the conversion is stored in a
//! memory buffer dedicated as the end-of-sequence by the memory's
//! control register
//! \n Modified bits are \b ADCCONSEQx of \b ADCCTL1 register.
//!
//! \return None
//
//*****************************************************************************
extern void ADC_startConversion(uint16_t baseAddress,
uint8_t conversionSequenceModeSelect);
//*****************************************************************************
//
//! \brief Disables the ADC from converting any more signals.
//!
//! Disables the ADC from converting any more signals. If there is a conversion
//! in progress, this function can stop it immediatly if the preempt parameter
//! is set as ADC_PREEMPTCONVERSION, by changing the conversion mode to single-
//! channel, single-conversion and disabling conversions. If the conversion
//! mode is set as single-channel, single-conversion and this function is
//! called without preemption, then the ADC core conversion status is polled
//! until the conversion is complete before disabling conversions to prevent
//! unpredictable data. If the ADC_startConversion() has been called, then this
//! function has to be called to re-initialize the ADC, reconfigure a memory
//! buffer control, enable/disable the sampling pulse mode, or change the
//! internal reference voltage.
//!
//! \param baseAddress is the base address of the ADC module.
//! \param preempt specifies if the current conversion should be preemptly
//! stopped before the end of the conversion
//! Valid values are:
//! - \b ADC_COMPLETECONVERSION - Allows the ADC to end the current
//! conversion before disabling conversions.
//! - \b ADC_PREEMPTCONVERSION - Stops the ADC10B immediately, with
//! unpredicatble results of the current conversion. Cannot be used
//! with repeated conversion.
//!
//! Modified bits of \b ADCCTL0 register and bits of \b ADCCTL1 register.
//!
//! \return None
//
//*****************************************************************************
extern void ADC_disableConversions(uint16_t baseAddress,
bool preempt);
//*****************************************************************************
//
//! \brief Returns the raw contents of the specified memory buffer.
//!
//! Returns the raw contents of the specified memory buffer. The format of the
//! content depends on the read-back format of the data: if the data is in
//! signed 2's complement format then the contents in the memory buffer will be
//! left-justified with the least-siginificant bits as 0's, whereas if the data
//! is in unsigned format then the contents in the memory buffer will be right-
//! justified with the most-significant bits as 0's.
//!
//! \param baseAddress is the base address of the ADC module.
//!
//! \return A Signed Integer of the contents of the specified memory buffer.
//
//*****************************************************************************
extern int16_t ADC_getResults(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Use to change the resolution of the converted data.
//!
//! This function can be used to change the resolution of the converted data
//! from the default of 10-bits. Refer to the device user's guide for available
//! options.
//!
//! \param baseAddress is the base address of the ADC module.
//! \param resolutionSelect determines the resolution of the converted data.
//! Valid values are:
//! - \b ADC_RESOLUTION_8BIT
//! - \b ADC_RESOLUTION_10BIT [Default]
//! - \b ADC_RESOLUTION_12BIT
//! \n Modified bits are \b ADCRES of \b ADCCTL2 register.
//!
//! \return None
//
//*****************************************************************************
extern void ADC_setResolution(uint16_t baseAddress,
uint8_t resolutionSelect);
//*****************************************************************************
//
//! \brief Use to invert or un-invert the sample/hold signal
//!
//! This function can be used to invert or un-invert the sample/hold signal.
//! Note that if a conversion has been started with the startConversion()
//! function, then a call to disableConversions() is required before this
//! function may be called.
//!
//! \param baseAddress is the base address of the ADC module.
//! \param invertedSignal set if the sample/hold signal should be inverted
//! Valid values are:
//! - \b ADC_NONINVERTEDSIGNAL [Default] - a sample-and-hold of an input
//! signal for conversion will be started on a rising edge of the
//! sample/hold signal.
//! - \b ADC_INVERTEDSIGNAL - a sample-and-hold of an input signal for
//! conversion will be started on a falling edge of the sample/hold
//! signal.
//! \n Modified bits are \b ADCISSH of \b ADCCTL1 register.
//!
//! \return None
//
//*****************************************************************************
extern void ADC_setSampleHoldSignalInversion(uint16_t baseAddress,
uint16_t invertedSignal);
//*****************************************************************************
//
//! \brief Use to set the read-back format of the converted data
//!
//! Sets the format of the converted data: how it will be stored into the
//! memory buffer, and how it should be read back. The format can be set as
//! right-justified (default), which indicates that the number will be
//! unsigned, or left-justified, which indicates that the number will be signed
//! in 2's complement format. This change affects all memory buffers for
//! subsequent conversions.
//!
//! \param baseAddress is the base address of the ADC module.
//! \param readBackFormat is the specified format to store the conversions in
//! the memory buffer.
//! Valid values are:
//! - \b ADC_UNSIGNED_BINARY [Default]
//! - \b ADC_SIGNED_2SCOMPLEMENT
//! \n Modified bits are \b ADCDF of \b ADCCTL2 register.
//!
//! \return None
//
//*****************************************************************************
extern void ADC_setDataReadBackFormat(uint16_t baseAddress,
uint16_t readBackFormat);
//*****************************************************************************
//
//! \brief Use to set the reference buffer's sampling rate.
//!
//! Sets the reference buffer's sampling rate to the selected sampling rate.
//! The default sampling rate is maximum of 200-ksps, and can be reduced to a
//! maximum of 50-ksps to conserve power.
//!
//! \param baseAddress is the base address of the ADC module.
//! \param samplingRateSelect is the specified maximum sampling rate.
//! Valid values are:
//! - \b ADC_MAXSAMPLINGRATE_200KSPS [Default]
//! - \b ADC_MAXSAMPLINGRATE_50KSPS
//! \n Modified bits are \b ADCSR of \b ADCCTL2 register.
//!
//! Modified bits of \b ADCCTL2 register.
//!
//! \return None
//
//*****************************************************************************
extern void ADC_setReferenceBufferSamplingRate(uint16_t baseAddress,
uint16_t samplingRateSelect);
//*****************************************************************************
//
//! \brief Sets the high and low threshold for the window comparator feature.
//!
//! Sets the high and low threshold for the window comparator feature. Use the
//! ADCHIIE, ADCINIE, ADCLOIE interrupts to utilize this feature.
//!
//! \param baseAddress is the base address of the ADC module.
//! \param highThreshold is the upper bound that could trip an interrupt for
//! the window comparator.
//! \param lowThreshold is the lower bound that could trip on interrupt for the
//! window comparator.
//!
//! Modified bits of \b ADCLO register and bits of \b ADCHI register.
//!
//! \return None
//
//*****************************************************************************
extern void ADC_setWindowComp(uint16_t baseAddress,
uint16_t highThreshold,
uint16_t lowThreshold);
//*****************************************************************************
//
//! \brief Returns the address of the memory buffer for the DMA module.
//!
//! \param baseAddress is the base address of the ADC module.
//!
//! \return the address of the memory buffer. This can be used in conjunction
//! with the DMA to store the converted data directly to memory.
//
//*****************************************************************************
extern uint32_t ADC_getMemoryAddressForDMA(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Returns the busy status of the ADC core.
//!
//! Returns the status of the ADC core if there is a conversion currently
//! taking place.
//!
//! \param baseAddress is the base address of the ADC module.
//!
//! \return ADC_BUSY or ADC_NOTBUSY dependent if there is a conversion
//! currently taking place.
//! Return one of the following:
//! - \b ADC_NOTBUSY
//! - \b ADC_BUSY
//
//*****************************************************************************
extern uint8_t ADC_isBusy(uint16_t baseAddress);
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif
#endif // __MSP430WARE_ADC_H__

View File

@ -1,103 +0,0 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
//
// crc.c - Driver for the crc Module.
//
//*****************************************************************************
//*****************************************************************************
//
//! \addtogroup crc_api crc
//! @{
//
//*****************************************************************************
#include "inc/hw_memmap.h"
#ifdef __MSP430_HAS_CRC__
#include "crc.h"
#include <assert.h>
void CRC_setSeed(uint16_t baseAddress,
uint16_t seed)
{
HWREG16(baseAddress + OFS_CRCINIRES) = seed;
}
void CRC_set16BitData(uint16_t baseAddress,
uint16_t dataIn)
{
HWREG16(baseAddress + OFS_CRCDI) = dataIn;
}
void CRC_set8BitData(uint16_t baseAddress,
uint8_t dataIn)
{
HWREG8(baseAddress + OFS_CRCDI_L) = dataIn;
}
void CRC_set16BitDataReversed(uint16_t baseAddress,
uint16_t dataIn)
{
HWREG16(baseAddress + OFS_CRCDIRB) = dataIn;
}
void CRC_set8BitDataReversed(uint16_t baseAddress,
uint8_t dataIn)
{
HWREG8(baseAddress + OFS_CRCDIRB_L) = dataIn;
}
uint16_t CRC_getData(uint16_t baseAddress)
{
return (HWREG16(baseAddress + OFS_CRCDI));
}
uint16_t CRC_getResult(uint16_t baseAddress)
{
return (HWREG16(baseAddress + OFS_CRCINIRES));
}
uint16_t CRC_getResultBitsReversed(uint16_t baseAddress)
{
return (HWREG16(baseAddress + OFS_CRCRESR));
}
#endif
//*****************************************************************************
//
//! Close the doxygen group for crc_api
//! @}
//
//*****************************************************************************

View File

@ -1,209 +0,0 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
//
// crc.h - Driver for the CRC Module.
//
//*****************************************************************************
#ifndef __MSP430WARE_CRC_H__
#define __MSP430WARE_CRC_H__
#include "inc/hw_memmap.h"
#ifdef __MSP430_HAS_CRC__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
// Prototypes for the APIs.
//
//*****************************************************************************
//*****************************************************************************
//
//! \brief Sets the seed for the CRC.
//!
//! This function sets the seed for the CRC to begin generating a signature
//! with the given seed and all passed data. Using this function resets the CRC
//! signature.
//!
//! \param baseAddress is the base address of the CRC module.
//! \param seed is the seed for the CRC to start generating a signature from.
//! \n Modified bits are \b CRCINIRES of \b CRCINIRES register.
//!
//! \return None
//
//*****************************************************************************
extern void CRC_setSeed(uint16_t baseAddress,
uint16_t seed);
//*****************************************************************************
//
//! \brief Sets the 16 bit data to add into the CRC module to generate a new
//! signature.
//!
//! This function sets the given data into the CRC module to generate the new
//! signature from the current signature and new data.
//!
//! \param baseAddress is the base address of the CRC module.
//! \param dataIn is the data to be added, through the CRC module, to the
//! signature.
//! \n Modified bits are \b CRCDI of \b CRCDI register.
//!
//! \return None
//
//*****************************************************************************
extern void CRC_set16BitData(uint16_t baseAddress,
uint16_t dataIn);
//*****************************************************************************
//
//! \brief Sets the 8 bit data to add into the CRC module to generate a new
//! signature.
//!
//! This function sets the given data into the CRC module to generate the new
//! signature from the current signature and new data.
//!
//! \param baseAddress is the base address of the CRC module.
//! \param dataIn is the data to be added, through the CRC module, to the
//! signature.
//! \n Modified bits are \b CRCDI of \b CRCDI register.
//!
//! \return None
//
//*****************************************************************************
extern void CRC_set8BitData(uint16_t baseAddress,
uint8_t dataIn);
//*****************************************************************************
//
//! \brief Translates the 16 bit data by reversing the bits in each byte and
//! then sets this data to add into the CRC module to generate a new signature.
//!
//! This function first reverses the bits in each byte of the data and then
//! generates the new signature from the current signature and new translated
//! data.
//!
//! \param baseAddress is the base address of the CRC module.
//! \param dataIn is the data to be added, through the CRC module, to the
//! signature.
//! \n Modified bits are \b CRCDIRB of \b CRCDIRB register.
//!
//! \return None
//
//*****************************************************************************
extern void CRC_set16BitDataReversed(uint16_t baseAddress,
uint16_t dataIn);
//*****************************************************************************
//
//! \brief Translates the 8 bit data by reversing the bits in each byte and
//! then sets this data to add into the CRC module to generate a new signature.
//!
//! This function first reverses the bits in each byte of the data and then
//! generates the new signature from the current signature and new translated
//! data.
//!
//! \param baseAddress is the base address of the CRC module.
//! \param dataIn is the data to be added, through the CRC module, to the
//! signature.
//! \n Modified bits are \b CRCDIRB of \b CRCDIRB register.
//!
//! \return None
//
//*****************************************************************************
extern void CRC_set8BitDataReversed(uint16_t baseAddress,
uint8_t dataIn);
//*****************************************************************************
//
//! \brief Returns the value currently in the Data register.
//!
//! This function returns the value currently in the data register. If set in
//! byte bits reversed format, then the translated data would be returned.
//!
//! \param baseAddress is the base address of the CRC module.
//!
//! \return The value currently in the data register
//
//*****************************************************************************
extern uint16_t CRC_getData(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Returns the value pf the Signature Result.
//!
//! This function returns the value of the signature result generated by the
//! CRC.
//!
//! \param baseAddress is the base address of the CRC module.
//!
//! \return The value currently in the data register
//
//*****************************************************************************
extern uint16_t CRC_getResult(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Returns the bit-wise reversed format of the Signature Result.
//!
//! This function returns the bit-wise reversed format of the Signature Result.
//!
//! \param baseAddress is the base address of the CRC module.
//!
//! \return The bit-wise reversed format of the Signature Result
//
//*****************************************************************************
extern uint16_t CRC_getResultBitsReversed(uint16_t baseAddress);
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif
#endif // __MSP430WARE_CRC_H__

File diff suppressed because it is too large Load Diff

View File

@ -1,845 +0,0 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
//
// cs.h - Driver for the CS Module.
//
//*****************************************************************************
#ifndef __MSP430WARE_CS_H__
#define __MSP430WARE_CS_H__
#include "inc/hw_memmap.h"
#ifdef __MSP430_HAS_CS__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
#include "inc/hw_memmap.h"
//*****************************************************************************
//
//! \brief Used in the CS_initFLLCalculateTrim(), CS_initFLLLoadTrim()
//! functions as the param parameter.
//
//*****************************************************************************
typedef struct CS_initFLLParam
{
//! Contains software trim value for DCOTAP
uint16_t csCtl0;
//! Contains software trim value for DCOFTRIM
uint16_t csCtl1;
//! Is the target frequency for MCLK in kHz
uint16_t fsystem;
} CS_initFLLParam;
//*****************************************************************************
//
// The following are values that can be passed to the clockSourceDivider
// parameter for functions: CS_initClockSignal().
//
//*****************************************************************************
#define CS_CLOCK_DIVIDER_1 DIVM__1
#define CS_CLOCK_DIVIDER_2 DIVM__2
#define CS_CLOCK_DIVIDER_4 DIVM__4
#define CS_CLOCK_DIVIDER_8 DIVM__8
#define CS_CLOCK_DIVIDER_16 DIVM__16
#define CS_CLOCK_DIVIDER_32 DIVM__32
#define CS_CLOCK_DIVIDER_64 DIVM__64
#define CS_CLOCK_DIVIDER_128 DIVM__128
#define CS_CLOCK_DIVIDER_256 0x8
#define CS_CLOCK_DIVIDER_384 0x9
#define CS_CLOCK_DIVIDER_512 0xA
#define CS_CLOCK_DIVIDER_768 0xB
#define CS_CLOCK_DIVIDER_1024 0xC
#define CS_CLOCK_DIVIDER_108 0xD
#define CS_CLOCK_DIVIDER_338 0xE
#define CS_CLOCK_DIVIDER_414 0xF
#define CS_CLOCK_DIVIDER_640 0x10
//*****************************************************************************
//
// The following are values that can be passed to the selectClock parameter for
// functions: CS_enableClockRequest(), and CS_disableClockRequest(); the
// selectedClockSignal parameter for functions: CS_initClockSignal().
//
//*****************************************************************************
#define CS_ACLK 0x01
#define CS_MCLK 0x02
#define CS_SMCLK 0x04
//*****************************************************************************
//
// The following are values that can be passed to the selectedClockSignal
// parameter for functions: CS_initClockSignal().
//
//*****************************************************************************
#define CS_FLLREF 0x08
//*****************************************************************************
//
// The following are values that can be passed to the selectClock parameter for
// functions: CS_enableClockRequest(), and CS_disableClockRequest().
//
//*****************************************************************************
#define CS_MODOSC MODCLKREQEN
//*****************************************************************************
//
// The following are values that can be passed to the clockSource parameter for
// functions: CS_initClockSignal().
//
//*****************************************************************************
#define CS_XT1CLK_SELECT SELMS__XT1CLK
#define CS_VLOCLK_SELECT SELMS__VLOCLK
#define CS_REFOCLK_SELECT SELMS__REFOCLK
#define CS_DCOCLKDIV_SELECT SELMS__DCOCLKDIV
//*****************************************************************************
//
// The following are values that can be passed to the xt1Drive parameter for
// functions: CS_turnOnXT1LF(), CS_turnOnXT1LFWithTimeout(), CS_turnOnXT1HF(),
// and CS_turnOnXT1HFWithTimeout().
//
//*****************************************************************************
#define CS_XT1_DRIVE_0 XT1DRIVE_0
#define CS_XT1_DRIVE_1 XT1DRIVE_1
#define CS_XT1_DRIVE_2 XT1DRIVE_2
#define CS_XT1_DRIVE_3 XT1DRIVE_3
//*****************************************************************************
//
// The following are values that can be passed to the xt1HFFreq parameter for
// functions: CS_turnOnXT1HF(), and CS_turnOnXT1HFWithTimeout().
//
//*****************************************************************************
#define CS_XT1_HFFREQ_1MHZ_4MHZ XT1HFFREQ_0
#define CS_XT1_HFFREQ_4MHZ_6MHZ XT1HFFREQ_1
#define CS_XT1_HFFREQ_6MHZ_16MHZ XT1HFFREQ_2
#define CS_XT1_HFFREQ_16MHZ_24MHZ XT1HFFREQ_3
//*****************************************************************************
//
// The following are values that can be passed to the mask parameter for
// functions: CS_getFaultFlagStatus(), and CS_clearFaultFlag() as well as
// returned by the CS_clearAllOscFlagsWithTimeout() function.
//
//*****************************************************************************
#define CS_XT1OFFG XT1OFFG
#define CS_DCOFFG DCOFFG
#define CS_FLLULIFG FLLULIFG
//*****************************************************************************
//
// Prototypes for the APIs.
//
//*****************************************************************************
//*****************************************************************************
//
//! \brief Sets the external clock source
//!
//! This function sets the external clock sources XT1 crystal oscillator
//! frequency values. This function must be called if an external crystal XT1
//! is used and the user intends to call CS_getMCLK, CS_getSMCLK or CS_getACLK
//! APIs. If not, it is not necessary to invoke this API.
//!
//! \param XT1CLK_frequency is the XT1 crystal frequencies in Hz
//!
//! \return None
//
//*****************************************************************************
extern void CS_setExternalClockSource(uint32_t XT1CLK_frequency);
//*****************************************************************************
//
//! \brief Initializes a clock signal
//!
//! This function initializes each of the clock signals. The user must ensure
//! that this function is called for each clock signal. If not, the default
//! state is assumed for the particular clock signal. Refer MSP430Ware
//! documentation for CS module or Device Family User's Guide for details of
//! default clock signal states. Note that the dividers for \b CS_FLLREF are
//! different from the available clock dividers. Some devices do not support
//! dividers setting for \b CS_FLLREF, please refer to device specific
//! datasheet for details.
//!
//! \param selectedClockSignal selected clock signal
//! Valid values are:
//! - \b CS_ACLK
//! - \b CS_MCLK
//! - \b CS_SMCLK
//! - \b CS_FLLREF
//! \param clockSource is clock source for the selectedClockSignal
//! Valid values are:
//! - \b CS_XT1CLK_SELECT
//! - \b CS_VLOCLK_SELECT
//! - \b CS_REFOCLK_SELECT
//! - \b CS_DCOCLKDIV_SELECT
//! \param clockSourceDivider selected the clock divider to calculate
//! clocksignal from clock source.
//! Valid values are:
//! - \b CS_CLOCK_DIVIDER_1 [Default] - [Valid for CS_FLLREF, CS_MCLK,
//! CS_ACLK, CS_SMCLK]
//! - \b CS_CLOCK_DIVIDER_2 - [Valid for CS_MCLK, CS_SMCLK]
//! - \b CS_CLOCK_DIVIDER_4 - [Valid for CS_MCLK, CS_SMCLK]
//! - \b CS_CLOCK_DIVIDER_8 - [Valid for CS_MCLK, CS_SMCLK]
//! - \b CS_CLOCK_DIVIDER_16 - [Valid for CS_MCLK, CS_ACLK]
//! - \b CS_CLOCK_DIVIDER_32 - [Valid for CS_FLLREF, CS_MCLK, CS_ACLK]
//! - \b CS_CLOCK_DIVIDER_64 - [Valid for CS_FLLREF, CS_MCLK, CS_ACLK]
//! - \b CS_CLOCK_DIVIDER_128 - [Valid for CS_FLLREF, CS_MCLK, CS_ACLK]
//! - \b CS_CLOCK_DIVIDER_256 - [Valid for CS_FLLREF, CS_ACLK]
//! - \b CS_CLOCK_DIVIDER_384 - [Valid for CS_FLLREF, CS_ACLK]
//! - \b CS_CLOCK_DIVIDER_512 - [Valid for CS_FLLREF, CS_ACLK]
//! - \b CS_CLOCK_DIVIDER_768 - [Valid for CS_FLLREF, CS_ACLK]
//! - \b CS_CLOCK_DIVIDER_1024 - [Valid for CS_FLLREF, CS_ACLK]
//! - \b CS_CLOCK_DIVIDER_108 - [Valid for CS_ACLK]
//! - \b CS_CLOCK_DIVIDER_338 - [Valid for CS_ACLK]
//! - \b CS_CLOCK_DIVIDER_414 - [Valid for CS_ACLK]
//! - \b CS_CLOCK_DIVIDER_640 - [Valid for CS_FLLREF, CS_ACLK]
//!
//! Modified bits of \b CSCTL3 register, bits of \b CSCTL5 register and bits of
//! \b CSCTL4 register.
//!
//! \return None
//
//*****************************************************************************
extern void CS_initClockSignal(uint8_t selectedClockSignal,
uint16_t clockSource,
uint16_t clockSourceDivider);
//*****************************************************************************
//
//! \brief Intializes the XT1 crystal oscillator in low frequency mode
//!
//! Initializes the XT1 crystal oscillator in low frequency mode. Loops until
//! all oscillator fault flags are cleared, with no timeout. See the device-
//! specific data sheet for appropriate drive settings.
//!
//! \param xt1Drive is the target drive strength for the XT1 crystal
//! oscillator.
//! Valid values are:
//! - \b CS_XT1_DRIVE_0
//! - \b CS_XT1_DRIVE_1
//! - \b CS_XT1_DRIVE_2
//! - \b CS_XT1_DRIVE_3 [Default]
//! \n Modified bits are \b XT1DRIVE of \b UCSCTL6 register.
//!
//! \return None
//
//*****************************************************************************
extern void CS_turnOnXT1LF(uint16_t xt1Drive);
//*****************************************************************************
//
//! \brief Bypass the XT1 crystal oscillator
//!
//! Bypasses the XT1 crystal oscillator. Loops until all oscillator fault flags
//! are cleared, with no timeout.
//!
//!
//! Modified bits of \b SFRIFG1 register, bits of \b CSCTL7 register and bits
//! of \b CSCTL6 register.
//!
//! \return None
//
//*****************************************************************************
extern void CS_bypassXT1(void);
//*****************************************************************************
//
//! \brief Initializes the XT1 crystal oscillator in low frequency mode with
//! timeout
//!
//! Initializes the XT1 crystal oscillator in low frequency mode with timeout.
//! Loops until all oscillator fault flags are cleared or until a timeout
//! counter is decremented and equals to zero. See the device-specific
//! datasheet for appropriate drive settings.
//!
//! \param xt1Drive is the target drive strength for the XT1 crystal
//! oscillator.
//! Valid values are:
//! - \b CS_XT1_DRIVE_0
//! - \b CS_XT1_DRIVE_1
//! - \b CS_XT1_DRIVE_2
//! - \b CS_XT1_DRIVE_3 [Default]
//! \param timeout is the count value that gets decremented every time the loop
//! that clears oscillator fault flags gets executed.
//!
//! Modified bits of \b SFRIFG1 register, bits of \b CSCTL7 register and bits
//! of \b CSCTL6 register.
//!
//! \return STATUS_SUCCESS or STATUS_FAIL
//
//*****************************************************************************
extern bool CS_turnOnXT1LFWithTimeout(uint16_t xt1Drive,
uint16_t timeout);
//*****************************************************************************
//
//! \brief Bypasses the XT1 crystal oscillator with time out
//!
//! Bypasses the XT1 crystal oscillator with time out. Loops until all
//! oscillator fault flags are cleared or until a timeout counter is
//! decremented and equals to zero.
//!
//! \param timeout is the count value that gets decremented every time the loop
//! that clears oscillator fault flags gets executed.
//!
//! Modified bits of \b SFRIFG1 register, bits of \b CSCTL7 register and bits
//! of \b CSCTL6 register.
//!
//! \return STATUS_SUCCESS or STATUS_FAIL
//
//*****************************************************************************
extern bool CS_bypassXT1WithTimeout(uint16_t timeout);
//*****************************************************************************
//
//! \brief Stops the XT1 oscillator using the XT1AUTOOFF bit.
//!
//!
//! Modified bits are \b XT1AUTOOFF of \b CSCTL6 register.
//!
//! \return None
//
//*****************************************************************************
extern void CS_turnOffXT1(void);
//*****************************************************************************
//
//! \brief Intializes the XT1 crystal oscillator in high frequency mode
//!
//! Initializes the XT1 crystal oscillator in high frequency mode. Loops until
//! all oscillator fault flags are cleared, with no timeout. See the device-
//! specific data sheet for appropriate drive settings.
//!
//! \param xt1Drive is the target drive strength for the XT1 crystal
//! oscillator.
//! Valid values are:
//! - \b CS_XT1_DRIVE_0
//! - \b CS_XT1_DRIVE_1
//! - \b CS_XT1_DRIVE_2
//! - \b CS_XT1_DRIVE_3 [Default]
//! \n Modified bits are \b XT1DRIVE of \b UCSCTL6 register.
//! \param xt1HFFreq is the high frequency range selection.
//! Valid values are:
//! - \b CS_XT1_HFFREQ_1MHZ_4MHZ [Default]
//! - \b CS_XT1_HFFREQ_4MHZ_6MHZ
//! - \b CS_XT1_HFFREQ_6MHZ_16MHZ
//! - \b CS_XT1_HFFREQ_16MHZ_24MHZ
//!
//! \return None
//
//*****************************************************************************
extern void CS_turnOnXT1HF(uint16_t xt1Drive,
uint16_t xt1HFFreq);
//*****************************************************************************
//
//! \brief Initializes the XT1 crystal oscillator in high frequency mode with
//! timeout
//!
//! Initializes the XT1 crystal oscillator in high frequency mode with timeout.
//! Loops until all oscillator fault flags are cleared or until a timeout
//! counter is decremented and equals to zero. See the device-specific
//! datasheet for appropriate drive settings.
//!
//! \param xt1Drive is the target drive strength for the XT1 crystal
//! oscillator.
//! Valid values are:
//! - \b CS_XT1_DRIVE_0
//! - \b CS_XT1_DRIVE_1
//! - \b CS_XT1_DRIVE_2
//! - \b CS_XT1_DRIVE_3 [Default]
//! \param xt1HFFreq is the high frequency range selection.
//! Valid values are:
//! - \b CS_XT1_HFFREQ_1MHZ_4MHZ [Default]
//! - \b CS_XT1_HFFREQ_4MHZ_6MHZ
//! - \b CS_XT1_HFFREQ_6MHZ_16MHZ
//! - \b CS_XT1_HFFREQ_16MHZ_24MHZ
//! \param timeout is the count value that gets decremented every time the loop
//! that clears oscillator fault flags gets executed.
//!
//! Modified bits of \b SFRIFG1 register, bits of \b CSCTL7 register and bits
//! of \b CSCTL6 register.
//!
//! \return STATUS_SUCCESS or STATUS_FAIL
//
//*****************************************************************************
extern bool CS_turnOnXT1HFWithTimeout(uint16_t xt1Drive,
uint16_t xt1HFFreq,
uint16_t timeout);
//*****************************************************************************
//
//! \brief Turn On SMCLK
//!
//!
//! \return None
//
//*****************************************************************************
extern void CS_turnOnSMCLK(void);
//*****************************************************************************
//
//! \brief Turn Off SMCLK
//!
//!
//! \return None
//
//*****************************************************************************
extern void CS_turnOffSMCLK(void);
//*****************************************************************************
//
//! \brief VLO is turned off when not used
//!
//!
//! \return None
//
//*****************************************************************************
extern void CS_enableVLOAutoOff(void);
//*****************************************************************************
//
//! \brief VLO is always on
//!
//!
//! \return None
//
//*****************************************************************************
extern void CS_disableVLOAutoOff(void);
//*****************************************************************************
//
//! \brief Initializes the DCO to operate a frequency that is a multiple of the
//! reference frequency into the FLL
//!
//! Initializes the DCO to operate a frequency that is a multiple of the
//! reference frequency into the FLL. Loops until all oscillator fault flags
//! are cleared, with a timeout. If the frequency is greater than clock system
//! allows, the function sets the MCLK and SMCLK source to the undivided DCO
//! frequency and returns false. Otherwise, the function sets the MCLK and
//! SMCLK source to the DCOCLKDIV frequency. This function executes a software
//! delay that is proportional in length to the ratio of the target FLL
//! frequency and the FLL reference.
//!
//! \param fsystem is the target frequency for MCLK in kHz
//! \param ratio is the ratio x/y, where x = fsystem and y = FLL reference
//! frequency.
//!
//! Modified bits of \b CSCTL1 register, bits of \b CSCTL0 register, bits of \b
//! CSCTL2 register, bits of \b CSCTL4 register, bits of \b CSCTL7 register and
//! bits of \b SFRIFG1 register.
//!
//! \return True if successful, false if unsuccessful and resorted to undivided
//! DCO frequency for MCLK and SMCLK source
//
//*****************************************************************************
extern bool CS_initFLLSettle(uint16_t fsystem,
uint16_t ratio);
//*****************************************************************************
//
//! \brief Initializes the DCO to operate a frequency that is a multiple of the
//! reference frequency into the FLL. This function performs DCO Factory Trim.
//!
//! Initializes the DCO to operate a frequency that is a multiple of the
//! reference frequency into the FLL. Loops until all oscillator fault flags
//! are cleared, with a timeout. If the frequency is greater than clock system
//! allows, the function sets the MCLK and SMCLK source to the undivided DCO
//! frequency and returns false. Otherwise, the function sets the MCLK and
//! SMCLK source to the DCOCLKDIV frequency.
//!
//! \param fsystem is the target frequency for MCLK in kHz
//! \param ratio is the ratio x/y, where x = fsystem and y = FLL reference
//! frequency.
//!
//! Modified bits of \b CSCTL1 register, bits of \b CSCTL0 register, bits of \b
//! CSCTL2 register, bits of \b CSCTL4 register, bits of \b CSCTL7 register and
//! bits of \b SFRIFG1 register.
//!
//! \return True if successful, false if unsuccessful and resorted to undivided
//! DCO frequency for MCLK and SMCLK source
//
//*****************************************************************************
extern bool CS_initFLL(uint16_t fsystem,
uint16_t ratio);
//*****************************************************************************
//
//! \brief Performs same function as initFLLSettle in addition to setting the
//! proper DCOFTRIM according to clock frequency. This function performs DCO
//! Software Trim and saves the trim value into initFLLParam.
//!
//! Initializes the DCO to operate a frequency that is a multiple of the
//! reference frequency into the FLL. Loops until all oscillator fault flags
//! are cleared, with a timeout. If the frequency is greater than clock system
//! allows, the function sets the MCLK and SMCLK source to the undivided DCO
//! frequency and returns false. Otherwise, the function sets the MCLK and
//! SMCLK source to the DCOCLKDIV frequency. This function executes a software
//! delay that is proportional in length to the ratio of the target FLL
//! frequency and the FLL reference. It also calibrates the DCOFTRIM value
//! according to clock frequency. Lastly, it saves the DCOTAP and DCOFTRIM
//! values for future use.
//!
//! \param fsystem is the target frequency for MCLK in kHz
//! \param ratio is the ratio x/y, where x = fsystem and y = FLL reference
//! frequency.
//!
//! Modified bits of \b CSCTL1 register, bits of \b CSCTL0 register, bits of \b
//! CSCTL2 register, bits of \b CSCTL4 register, bits of \b CSCTL7 register and
//! bits of \b SFRIFG1 register.
//!
//! \return True if successful, false if unsuccessful and resorted to undivided
//! DCO frequency for MCLK and SMCLK source
//
//*****************************************************************************
extern bool CS_initFLLCalculateTrim(uint16_t fsystem,
uint16_t ratio,
CS_initFLLParam *param);
//*****************************************************************************
//
//! \brief Performs same function as initFLLCalculateTrim without the overhead
//! of calculating the trim, but rather using the one specified in param. This
//! function corresponds with the DCO Software Trim.
//!
//! Initializes the DCO to operate a frequency that is a multiple of the
//! reference frequency into the FLL. Loops until all oscillator fault flags
//! are cleared, with a timeout. If the frequency is greater than clock system
//! allows, the function sets the MCLK and SMCLK source to the undivided DCO
//! frequency and returns false. Otherwise, the function sets the MCLK and
//! SMCLK source to the DCOCLKDIV frequency. This function executes a software
//! delay that is proportional in length to the ratio of the target FLL
//! frequency and the FLL reference. Lastly, it uses the saved DCOTAP and
//! DCOFTRIM values from the param to avoid overhead in recalculation.
//!
//! \param fsystem is the target frequency for MCLK in kHz
//! \param ratio is the ratio x/y, where x = fsystem and y = FLL reference
//! frequency.
//!
//! Modified bits of \b CSCTL1 register, bits of \b CSCTL0 register, bits of \b
//! CSCTL2 register, bits of \b CSCTL4 register, bits of \b CSCTL7 register and
//! bits of \b SFRIFG1 register.
//!
//! \return True if initialization successful, false if saved DCOFTRIM value is
//! not for the correct clock frequency combination or resorted to
//! undivided DCO frequency for MCLK and SMCLK source
//
//*****************************************************************************
extern bool CS_initFLLLoadTrim(uint16_t fsystem,
uint16_t ratio,
CS_initFLLParam *param);
//*****************************************************************************
//
//! \brief Enables conditional module requests
//!
//! \param selectClock selects specific request enables
//! Valid values are:
//! - \b CS_ACLK
//! - \b CS_MCLK
//! - \b CS_SMCLK
//! - \b CS_MODOSC
//!
//! Modified bits of \b CSCTL8 register.
//!
//! \return None
//
//*****************************************************************************
extern void CS_enableClockRequest(uint8_t selectClock);
//*****************************************************************************
//
//! \brief Disables conditional module requests
//!
//! \param selectClock selects specific request disable
//! Valid values are:
//! - \b CS_ACLK
//! - \b CS_MCLK
//! - \b CS_SMCLK
//! - \b CS_MODOSC
//!
//! Modified bits of \b CSCTL8 register.
//!
//! \return None
//
//*****************************************************************************
extern void CS_disableClockRequest(uint8_t selectClock);
//*****************************************************************************
//
//! \brief Gets the current CS fault flag status.
//!
//! \param mask is the masked interrupt flag status to be returned. Mask
//! parameter can be either any of the following selection.
//! Valid values are:
//! - \b CS_XT1OFFG - XT1 oscillator fault flag
//! - \b CS_DCOFFG - DCO fault flag
//! - \b CS_FLLULIFG - FLL unlock interrupt flag
//!
//! Modified bits of \b CSCTL7 register.
//!
//! \return The current flag status for the corresponding masked bit
//
//*****************************************************************************
extern uint8_t CS_getFaultFlagStatus(uint8_t mask);
//*****************************************************************************
//
//! \brief Clears the current CS fault flag status for the masked bit.
//!
//! \param mask is the masked interrupt flag status to be returned. mask
//! parameter can be any one of the following
//! Valid values are:
//! - \b CS_XT1OFFG - XT1 oscillator fault flag
//! - \b CS_DCOFFG - DCO fault flag
//! - \b CS_FLLULIFG - FLL unlock interrupt flag
//!
//! Modified bits of \b CSCTL7 register.
//!
//! \return None
//
//*****************************************************************************
extern void CS_clearFaultFlag(uint8_t mask);
//*****************************************************************************
//
//! \brief Get the current ACLK frequency
//!
//! Get the current ACLK frequency. The user of this API must ensure that
//! CS_setExternalClockSource API was invoked before in case XT1 is being used.
//!
//!
//! \return Current ACLK frequency in Hz
//
//*****************************************************************************
extern uint32_t CS_getACLK(void);
//*****************************************************************************
//
//! \brief Get the current SMCLK frequency
//!
//! Get the current SMCLK frequency. The user of this API must ensure that
//! CS_setExternalClockSource API was invoked before in case XT1 is being used.
//!
//!
//! \return Current SMCLK frequency in Hz
//
//*****************************************************************************
extern uint32_t CS_getSMCLK(void);
//*****************************************************************************
//
//! \brief Get the current MCLK frequency
//!
//! Get the current MCLK frequency. The user of this API must ensure that
//! CS_setExternalClockSource API was invoked before in case XT1 is being used.
//!
//!
//! \return Current MCLK frequency in Hz
//
//*****************************************************************************
extern uint32_t CS_getMCLK(void);
//*****************************************************************************
//
//! \brief Clears all the Oscillator Flags
//!
//! \param timeout is the count value that gets decremented every time the loop
//! that clears oscillator fault flags gets executed.
//!
//! \return The mask of the oscillator flag status
//! Return Logical OR of any of the following:
//! - \b CS_XT1OFFG XT1 oscillator fault flag
//! - \b CS_DCOFFG DCO fault flag
//! - \b CS_FLLULIFG FLL unlock interrupt flag
//! \n indicating the status of the osciallator fault flags
//
//*****************************************************************************
extern uint16_t CS_clearAllOscFlagsWithTimeout(uint16_t timeout);
//*****************************************************************************
//
//! \brief Enables XT1 automatic gain control
//!
//!
//! Modified bits of \b CSCTL6 register.
//!
//! \return None
//
//*****************************************************************************
extern void CS_enableXT1AutomaticGainControl(void);
//*****************************************************************************
//
//! \brief Disables XT1 automatic gain control
//!
//!
//! Modified bits of \b CSCTL6 register.
//!
//! \return None
//
//*****************************************************************************
extern void CS_disableXT1AutomaticGainControl(void);
//*****************************************************************************
//
//! \brief Enables FLL unlock interrupt.
//!
//!
//! Modified bits are \b FLLULIE of \b CSCTL7 register.
//!
//! \return None
//
//*****************************************************************************
extern void CS_enableFLLUnlock(void);
//*****************************************************************************
//
//! \brief Disables FLL unlock interrupt.
//!
//!
//! Modified bits are \b FLLULIE of \b CSCTL7 register.
//!
//! \return None
//
//*****************************************************************************
extern void CS_disableFLLUnlock(void);
//*****************************************************************************
//
//! \brief Enable low-power REFO.
//!
//!
//! Modified bits are \b REFOLP of \b CSCTL3 register.
//!
//! \return None
//
//*****************************************************************************
extern void CS_enableREFOLP(void);
//*****************************************************************************
//
//! \brief Disable low-power REFO.
//!
//!
//! Modified bits are \b REFOLP of \b CSCTL3 register.
//!
//! \return None
//
//*****************************************************************************
extern void CS_disableREFOLP(void);
//*****************************************************************************
//
//! \brief Get status of low-power REFO.
//!
//!
//! \return Get status of low-power REFO.
//
//*****************************************************************************
extern bool CS_getREFOLP(void);
//*****************************************************************************
//
//! \brief Turns off switching from XT1 to REFO when XT1 fails.
//!
//!
//! Modified bits are \b XT1FAULTOFF of \b CSCTL6 register.
//!
//! \return None
//
//*****************************************************************************
extern void CS_enableXT1FaultOff(void);
//*****************************************************************************
//
//! \brief Turns on switching from XT1 to REFO when XT1 fails.
//!
//!
//! Modified bits are \b XT1FAULTOFF of \b CSCTL6 register.
//!
//! \return None
//
//*****************************************************************************
extern void CS_disableXT1FaultOff(void);
//*****************************************************************************
//
//! \brief Get status of XT1 fault switching.
//!
//!
//! \return Get status of XT1 fault switching.
//
//*****************************************************************************
extern bool CS_getXT1FaultOff(void);
//*****************************************************************************
//
//! \brief Get status indication of low-power REFO switching.
//!
//!
//! \return Get status indication of low-power REFO switching.
//
//*****************************************************************************
extern bool CS_getREFOReady(void);
//*****************************************************************************
//
// The following are deprecated APIs.
//
//*****************************************************************************
#define CS_turnOnXT1 CS_turnOnXT1LF
#define CS_turnOnXT1WithTimeout CS_turnOnXT1LFWithTimeout
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif
#endif // __MSP430WARE_CS_H__

View File

@ -1,169 +0,0 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
//
// ecomp.c - Driver for the ecomp Module.
//
//*****************************************************************************
//*****************************************************************************
//
//! \addtogroup ecomp_api ecomp
//! @{
//
//*****************************************************************************
#include "inc/hw_memmap.h"
#ifdef __MSP430_HAS_ECOMPx__
#include "ecomp.h"
#include <assert.h>
void EComp_init(uint16_t baseAddress,
EComp_initParam *param)
{
HWREG16(baseAddress + OFS_CPCTL0) &= ~(CPNEN | CPNSEL_7 | CPPEN | CPPSEL_7);
HWREG16(baseAddress + OFS_CPCTL1) &= ~(CPFLT | CPFLTDLY_3 | CPINV);
if(param->positiveTerminalInput != ECOMP_INPUT_DISABLED)
{
HWREG16(baseAddress +
OFS_CPCTL0) |= CPPEN | param->positiveTerminalInput;
}
if(param->negativeTerminalInput != ECOMP_INPUT_DISABLED)
{
HWREG16(baseAddress +
OFS_CPCTL0) |= CPNEN | (param->negativeTerminalInput << 8);
}
HWREG16(baseAddress +
OFS_CPCTL1) |= param->outputFilterEnableAndDelayLevel |
param->invertedOutputPolarity;
}
void EComp_selectHysteresisMode(uint16_t baseAddress,
uint16_t hysteresisMode)
{
HWREG16(baseAddress + OFS_CPCTL1) &= ~CPHSEL_3;
HWREG16(baseAddress + OFS_CPCTL1) |= hysteresisMode;
}
void EComp_selectPowerMode(uint16_t baseAddress,
uint16_t powerMode)
{
HWREG16(baseAddress + OFS_CPCTL1) &= ~CPMSEL;
HWREG16(baseAddress + OFS_CPCTL1) |= powerMode;
}
void EComp_enable(uint16_t baseAddress)
{
HWREG16(baseAddress + OFS_CPCTL1) |= CPEN;
}
void EComp_disable(uint16_t baseAddress)
{
HWREG16(baseAddress + OFS_CPCTL1) &= ~CPEN;
}
void EComp_enableInterrupt(uint16_t baseAddress,
uint16_t interruptMask)
{
HWREG16(baseAddress + OFS_CPCTL1) |= interruptMask;
}
void EComp_disableInterrupt(uint16_t baseAddress,
uint16_t interruptMask)
{
HWREG16(baseAddress + OFS_CPCTL1) &= ~(interruptMask);
}
void EComp_clearInterrupt(uint16_t baseAddress,
uint16_t interruptFlagMask)
{
HWREG16(baseAddress + OFS_CPINT) |= interruptFlagMask;
}
uint8_t EComp_getInterruptStatus(uint16_t baseAddress,
uint16_t interruptFlagMask)
{
return (HWREG8(baseAddress + OFS_CPINT) & interruptFlagMask);
}
void EComp_setInterruptEdgeDirection(uint16_t baseAddress,
uint16_t edgeDirection)
{
HWREG16(baseAddress + OFS_CPCTL1) &= ~CPIES;
HWREG16(baseAddress + OFS_CPCTL1) |= edgeDirection;
}
void EComp_toggleInterruptEdgeDirection(uint16_t baseAddress)
{
HWREG16(baseAddress + OFS_CPCTL1) ^= CPIES;
}
uint8_t EComp_outputValue(uint16_t baseAddress)
{
return (HWREG8(baseAddress + OFS_CPCTL1) & CPOUT);
}
void EComp_configureDAC(uint16_t baseAddress,
EComp_configureDACParam *param)
{
HWREG16(baseAddress + OFS_CPDACCTL) &= ~(CPDACREFS | CPDACBUFS | CPDACSW);
HWREG16(baseAddress + OFS_CPDACDATA) &= 0xC0C0;
HWREG16(baseAddress + OFS_CPDACCTL) |= param->referenceVoltage |
param->bufferSource;
HWREG16(baseAddress + OFS_CPDACDATA) |= param->firstBufferData;
HWREG16(baseAddress + OFS_CPDACDATA) |= param->secondBufferData << 8;
}
void EComp_enableDAC(uint16_t baseAddress)
{
HWREG16(baseAddress + OFS_CPDACCTL) |= CPDACEN;
}
void EComp_disableDAC(uint16_t baseAddress)
{
HWREG16(baseAddress + OFS_CPDACCTL) &= ~CPDACEN;
}
#endif
//*****************************************************************************
//
//! Close the doxygen group for ecomp_api
//! @}
//
//*****************************************************************************

View File

@ -1,544 +0,0 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
//
// ecomp.h - Driver for the ECOMP Module.
//
//*****************************************************************************
#ifndef __MSP430WARE_ECOMP_H__
#define __MSP430WARE_ECOMP_H__
#include "inc/hw_memmap.h"
#ifdef __MSP430_HAS_ECOMPx__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
#include "inc/hw_memmap.h"
//*****************************************************************************
//
//! \brief Used in the EComp_init() function as the param parameter.
//
//*****************************************************************************
typedef struct EComp_initParam
{
//! Selects the input to the positive terminal
//! \n Valid values are:
//! - \b ECOMP_INPUT_0
//! - \b ECOMP_INPUT_1
//! - \b ECOMP_INPUT_2
//! - \b ECOMP_INPUT_3
//! - \b ECOMP_INPUT_DEVICE_SPECIFIC_0
//! - \b ECOMP_INPUT_DEVICE_SPECIFIC_1
//! - \b ECOMP_INPUT_DAC
//! - \b ECOMP_INPUT_DISABLED
uint8_t positiveTerminalInput;
//! Selects the input to the negative terminal
//! \n Valid values are:
//! - \b ECOMP_INPUT_0
//! - \b ECOMP_INPUT_1
//! - \b ECOMP_INPUT_2
//! - \b ECOMP_INPUT_3
//! - \b ECOMP_INPUT_DEVICE_SPECIFIC_0
//! - \b ECOMP_INPUT_DEVICE_SPECIFIC_1
//! - \b ECOMP_INPUT_DAC
//! - \b ECOMP_INPUT_DISABLED
uint8_t negativeTerminalInput;
//! Controls the output filter delay state, which is either off or enabled
//! with a specified delay level. This parameter is device specific and
//! delay levels should be found in the device's datasheet.
//! \n Valid values are:
//! - \b ECOMP_FILTER_DELAY_OFF [Default]
//! - \b ECOMP_FILTER_DELAY_450NS
//! - \b ECOMP_FILTER_DELAY_900NS
//! - \b ECOMP_FILTER_DELAY_1800NS
//! - \b ECOMP_FILTER_DELAY_3600NS
uint16_t outputFilterEnableAndDelayLevel;
//! Controls if the output will be inverted or not
//! \n Valid values are:
//! - \b ECOMP_NORMAL_OUTPUT_POLARITY [Default]
//! - \b ECOMP_INVERTED_OUTPUT_POLARITY
uint16_t invertedOutputPolarity;
} EComp_initParam;
//*****************************************************************************
//
//! \brief Used in the EComp_configureDAC() function as the param parameter.
//
//*****************************************************************************
typedef struct EComp_configureDACParam
{
//! Selects the built-in DAC reference voltage.
//! \n Valid values are:
//! - \b ECOMP_DAC_REFERENCE_VOLTAGE_VDD [Default]
//! - \b ECOMP_DAC_REFERENCE_VOLTAGE_VREF
uint8_t referenceVoltage;
//! Selects the built-in DAC buffer controlled source.
//! \n Valid values are:
//! - \b ECOMP_DAC_BUFFER_SOURCE_COMP_OUTPUT
//! - \b ECOMP_DAC_BUFFER_SOURCE_DUAL_BUFFER_1 [Default]
//! - \b ECOMP_DAC_BUFFER_SOURCE_DUAL_BUFFER_2
uint8_t bufferSource;
//! Sets the first DAC buffer data (0~63).
uint16_t firstBufferData;
//! Sets the second DAC buffer data (0~63). The reset value for the second
//! DAC buffer is 0x1.
uint16_t secondBufferData;
} EComp_configureDACParam;
//*****************************************************************************
//
// The following are values that can be passed to the param parameter for
// functions: EComp_init(), and EComp_init().
//
//*****************************************************************************
#define ECOMP_INPUT_0 0x0
#define ECOMP_INPUT_1 0x1
#define ECOMP_INPUT_2 0x2
#define ECOMP_INPUT_3 0x3
#define ECOMP_INPUT_DEVICE_SPECIFIC_0 0x4
#define ECOMP_INPUT_DEVICE_SPECIFIC_1 0x5
#define ECOMP_INPUT_DAC 0x6
#define ECOMP_INPUT_DISABLED 0x7
//*****************************************************************************
//
// The following are values that can be passed to the param parameter for
// functions: EComp_init().
//
//*****************************************************************************
#define ECOMP_FILTER_DELAY_OFF 0x0
#define ECOMP_FILTER_DELAY_450NS (CPFLT | \
CPFLTDLY_0)
#define ECOMP_FILTER_DELAY_900NS (CPFLT | \
CPFLTDLY_1)
#define ECOMP_FILTER_DELAY_1800NS (CPFLT | \
CPFLTDLY_2)
#define ECOMP_FILTER_DELAY_3600NS (CPFLT | \
CPFLTDLY_3)
//*****************************************************************************
//
// The following are values that can be passed to the param parameter for
// functions: EComp_init().
//
//*****************************************************************************
#define ECOMP_NORMAL_OUTPUT_POLARITY 0x0
#define ECOMP_INVERTED_OUTPUT_POLARITY CPINV
//*****************************************************************************
//
// The following are values that can be passed to the hysteresisMode parameter
// for functions: EComp_selectHysteresisMode().
//
//*****************************************************************************
#define ECOMP_HYSTERESIS_MODE_DISABLE CPHSEL_0
#define ECOMP_HYSTERESIS_MODE_10MV CPHSEL_1
#define ECOMP_HYSTERESIS_MODE_20MV CPHSEL_2
#define ECOMP_HYSTERESIS_MODE_30MV CPHSEL_3
//*****************************************************************************
//
// The following are values that can be passed to the powerMode parameter for
// functions: EComp_selectPowerMode().
//
//*****************************************************************************
#define ECOMP_POWER_MODE_HIGH_POWER_HIGH_SPEED 0x0
#define ECOMP_POWER_MODE_LOW_POWER_LOW_SPEED CPMSEL
//*****************************************************************************
//
// The following are values that can be passed to the interruptMask parameter
// for functions: EComp_enableInterrupt(), and EComp_disableInterrupt().
//
//*****************************************************************************
#define ECOMP_OUTPUT_INTERRUPT CPIE
#define ECOMP_INVERTED_POLARITY_INTERRUPT CPIIE
//*****************************************************************************
//
// The following are values that can be passed to the interruptFlagMask
// parameter for functions: EComp_clearInterrupt(), and
// EComp_getInterruptStatus() as well as returned by the
// EComp_getInterruptStatus() function.
//
//*****************************************************************************
#define ECOMP_OUTPUT_INTERRUPT_FLAG CPIFG
#define ECOMP_INVERTED_POLARITY_INTERRUPT_FLAG CPIIFG
//*****************************************************************************
//
// The following are values that can be passed to the edgeDirection parameter
// for functions: EComp_setInterruptEdgeDirection().
//
//*****************************************************************************
#define ECOMP_OUTPUT_INTERRUPT_RISING_EDGE 0x0
#define ECOMP_OUTPUT_INTERRUPT_FALLING_EDGE CPIES
//*****************************************************************************
//
// The following are values that can be passed toThe following are values that
// can be returned by the EComp_outputValue() function.
//
//*****************************************************************************
#define ECOMP_LOW 0x0
#define ECOMP_HIGH CPOUT
//*****************************************************************************
//
// The following are values that can be passed to the param parameter for
// functions: EComp_configureDAC().
//
//*****************************************************************************
#define ECOMP_DAC_REFERENCE_VOLTAGE_VDD 0x0
#define ECOMP_DAC_REFERENCE_VOLTAGE_VREF CPDACREFS
//*****************************************************************************
//
// The following are values that can be passed to the param parameter for
// functions: EComp_configureDAC().
//
//*****************************************************************************
#define ECOMP_DAC_BUFFER_SOURCE_COMP_OUTPUT 0x0
#define ECOMP_DAC_BUFFER_SOURCE_DUAL_BUFFER_1 (CPDACBUFS)
#define ECOMP_DAC_BUFFER_SOURCE_DUAL_BUFFER_2 (CPDACBUFS | \
CPDACSW)
//*****************************************************************************
//
// Prototypes for the APIs.
//
//*****************************************************************************
//*****************************************************************************
//
//! \brief Initializes the EComp
//!
//! Upon successful initialization of the EComp module, this function will have
//! reset all necessary register bits and set the given options in the
//! registers. To actually use the EComp_E module, the EComp_enable() function
//! must be explicitly called before use. (If a Reference Voltage is set to a
//! terminal, the Voltage should be set using the EComp_configureDAC()
//! function.)
//!
//! \param baseAddress is the base address of the ECOMP module.
//!
//! \return None
//
//*****************************************************************************
extern void EComp_init(uint16_t baseAddress,
EComp_initParam *param);
//*****************************************************************************
//
//! \brief Sets the hysteresis mode
//!
//! This function sets the hysteresis mode.
//!
//! \param baseAddress is the base address of the ECOMP module.
//! \param hysteresisMode decides the hysteresis mode
//! Valid values are:
//! - \b ECOMP_HYSTERESIS_MODE_DISABLE [Default]
//! - \b ECOMP_HYSTERESIS_MODE_10MV
//! - \b ECOMP_HYSTERESIS_MODE_20MV
//! - \b ECOMP_HYSTERESIS_MODE_30MV
//!
//! Modified bits are \b CPHSEL of \b CPCTL1 register.
//!
//! \return None
//
//*****************************************************************************
extern void EComp_selectHysteresisMode(uint16_t baseAddress,
uint16_t hysteresisMode);
//*****************************************************************************
//
//! \brief Sets the power mode
//!
//! This function sets the power mode.
//!
//! \param baseAddress is the base address of the ECOMP module.
//! \param powerMode decides the power mode
//! Valid values are:
//! - \b ECOMP_POWER_MODE_HIGH_POWER_HIGH_SPEED [Default]
//! - \b ECOMP_POWER_MODE_LOW_POWER_LOW_SPEED
//!
//! \return None
//
//*****************************************************************************
extern void EComp_selectPowerMode(uint16_t baseAddress,
uint16_t powerMode);
//*****************************************************************************
//
//! \brief Turns on the EComp module
//!
//! This function sets the bit that enables the operation of the EComp module.
//!
//! \param baseAddress is the base address of the ECOMP module.
//!
//! Modified bits are \b CPEN of \b CPCTL1 register.
//!
//! \return None
//
//*****************************************************************************
extern void EComp_enable(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Turns off the EComp module
//!
//! This function clears the CPEN bit disabling the operation of the EComp
//! module, saving from excess power consumption.
//!
//! \param baseAddress is the base address of the ECOMP module.
//!
//! Modified bits are \b CPEN of \b CPCTL1 register.
//!
//! \return None
//
//*****************************************************************************
extern void EComp_disable(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Enables selected EComp interrupt sources
//!
//! Enables the indicated EComp interrupt sources. Only the sources that are
//! enabled can be reflected to the processor interrupt; disabled sources have
//! no effect on the processor. <b>Does not clear interrupt flags.</b>
//!
//! \param baseAddress is the base address of the ECOMP module.
//! \param interruptMask
//! Mask value is the logical OR of any of the following:
//! - \b ECOMP_OUTPUT_INTERRUPT - Output interrupt
//! - \b ECOMP_INVERTED_POLARITY_INTERRUPT - Output interrupt inverted
//! polarity
//!
//! \return None
//
//*****************************************************************************
extern void EComp_enableInterrupt(uint16_t baseAddress,
uint16_t interruptMask);
//*****************************************************************************
//
//! \brief Disables selected EComp interrupt sources
//!
//! Disables the indicated EComp interrupt sources. Only the sources that are
//! enabled can be reflected to the processor interrupt; disabled sources have
//! no effect on the processor. <b>Does not clear interrupt flags.</b>
//!
//! \param baseAddress is the base address of the ECOMP module.
//! \param interruptMask
//! Mask value is the logical OR of any of the following:
//! - \b ECOMP_OUTPUT_INTERRUPT - Output interrupt
//! - \b ECOMP_INVERTED_POLARITY_INTERRUPT - Output interrupt inverted
//! polarity
//!
//! \return None
//
//*****************************************************************************
extern void EComp_disableInterrupt(uint16_t baseAddress,
uint16_t interruptMask);
//*****************************************************************************
//
//! \brief Clears EComp interrupt flags
//!
//! The EComp interrupt source is cleared, so that it no longer asserts. The
//! highest interrupt flag is automatically cleared when an interrupt vector
//! generator is used.
//!
//! \param baseAddress is the base address of the ECOMP module.
//! \param interruptFlagMask
//! Mask value is the logical OR of any of the following:
//! - \b ECOMP_OUTPUT_INTERRUPT_FLAG - Output interrupt flag
//! - \b ECOMP_INVERTED_POLARITY_INTERRUPT_FLAG - Output interrupt flag
//! inverted polarity
//!
//! \return None
//
//*****************************************************************************
extern void EComp_clearInterrupt(uint16_t baseAddress,
uint16_t interruptFlagMask);
//*****************************************************************************
//
//! \brief Gets the current EComp interrupt status
//!
//! This returns the interrupt status for the EComp_E module based on which
//! flag is passed.
//!
//! \param baseAddress is the base address of the ECOMP module.
//! \param interruptFlagMask
//! Mask value is the logical OR of any of the following:
//! - \b ECOMP_OUTPUT_INTERRUPT_FLAG - Output interrupt flag
//! - \b ECOMP_INVERTED_POLARITY_INTERRUPT_FLAG - Output interrupt flag
//! inverted polarity
//!
//! \return Logical OR of any of the following:
//! - \b EComp_OUTPUT_INTERRUPT_FLAG Output interrupt flag
//! - \b EComp_INVERTED_POLARITY_INTERRUPT_FLAG Output interrupt flag
//! inverted polarity
//! \n indicating the status of the masked flags
//
//*****************************************************************************
extern uint8_t EComp_getInterruptStatus(uint16_t baseAddress,
uint16_t interruptFlagMask);
//*****************************************************************************
//
//! \brief Explicitly sets the edge direction that would trigger an interrupt
//!
//! This function will set which direction the output will have to go, whether
//! rising or falling, to generate an interrupt based on a non-inverted
//! interrupt.
//!
//! \param baseAddress is the base address of the ECOMP module.
//! \param edgeDirection determines which direction the edge would have to go
//! to generate an interrupt based on the non-inverted interrupt flag.
//! Valid values are:
//! - \b ECOMP_OUTPUT_INTERRUPT_RISING_EDGE [Default] - sets the bit to
//! generate an interrupt when the output of the EComp rises from LOW
//! to HIGH if the normal interrupt bit is set(and HIGH to LOW if the
//! inverted interrupt enable bit is set).
//! - \b ECOMP_OUTPUT_INTERRUPT_FALLING_EDGE - sets the bit to generate
//! an interrupt when the output of the EComp falls from HIGH to LOW
//! if the normal interrupt bit is set(and LOW to HIGH if the
//! inverted interrupt enable bit is set).
//! \n Modified bits are \b CPIES of \b CPCTL1 register.
//!
//! \return None
//
//*****************************************************************************
extern void EComp_setInterruptEdgeDirection(uint16_t baseAddress,
uint16_t edgeDirection);
//*****************************************************************************
//
//! \brief Toggles the edge direction that would trigger an interrupt
//!
//! This function will toggle which direction the output will have to go,
//! whether rising or falling, to generate an interrupt based on a non-inverted
//! interrupt. If the direction was rising, it is now falling, if it was
//! falling, it is now rising.
//!
//! \param baseAddress is the base address of the ECOMP module.
//!
//! Modified bits are \b CPIES of \b CPCTL1 register.
//!
//! \return None
//
//*****************************************************************************
extern void EComp_toggleInterruptEdgeDirection(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Returns the output value of the EComp module
//!
//! Returns the output value of the EComp module.
//!
//! \param baseAddress is the base address of the ECOMP module.
//!
//! \return indicating the output value of the EComp module
//! Return one of the following:
//! - \b EComp_LOW
//! - \b EComp_HIGH
//! \n indicating the output value of the EComp module
//
//*****************************************************************************
extern uint8_t EComp_outputValue(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Configures the built-in DAC for internal reference
//!
//! This function will configure the built-in DAC register bits including
//! reference voltage and DAC buffer source.
//!
//! \param baseAddress is the base address of the ECOMP module.
//!
//! \return None
//
//*****************************************************************************
extern void EComp_configureDAC(uint16_t baseAddress,
EComp_configureDACParam *param);
//*****************************************************************************
//
//! \brief Enables DAC output
//!
//! This function will enable DAC output.
//!
//! \param baseAddress is the base address of the ECOMP module.
//!
//! \return None
//
//*****************************************************************************
extern void EComp_enableDAC(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Disables DAC output
//!
//! This function will disable DAC output. When it is disabled, the DAC always
//! output low.
//!
//! \param baseAddress is the base address of the ECOMP module.
//!
//! \return None
//
//*****************************************************************************
extern void EComp_disableDAC(uint16_t baseAddress);
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif
#endif // __MSP430WARE_ECOMP_H__

View File

@ -1,230 +0,0 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
//
// eusci_a_spi.c - Driver for the eusci_a_spi Module.
//
//*****************************************************************************
//*****************************************************************************
//
//! \addtogroup eusci_a_spi_api eusci_a_spi
//! @{
//
//*****************************************************************************
#include "inc/hw_memmap.h"
#ifdef __MSP430_HAS_EUSCI_Ax__
#include "eusci_a_spi.h"
#include <assert.h>
void EUSCI_A_SPI_initMaster(uint16_t baseAddress,
EUSCI_A_SPI_initMasterParam *param)
{
//Disable the USCI Module
HWREG16(baseAddress + OFS_UCAxCTLW0) |= UCSWRST;
//Reset OFS_UCAxCTLW0 values
HWREG16(baseAddress + OFS_UCAxCTLW0) &= ~(UCCKPH + UCCKPL + UC7BIT + UCMSB +
UCMST + UCMODE_3 + UCSYNC);
//Reset OFS_UCAxCTLW0 values
HWREG16(baseAddress + OFS_UCAxCTLW0) &= ~(UCSSEL_3);
//Select Clock
HWREG16(baseAddress + OFS_UCAxCTLW0) |= param->selectClockSource;
HWREG16(baseAddress + OFS_UCAxBRW) =
(uint16_t)(param->clockSourceFrequency / param->desiredSpiClock);
/*
* Configure as SPI master mode.
* Clock phase select, polarity, msb
* UCMST = Master mode
* UCSYNC = Synchronous mode
* UCMODE_0 = 3-pin SPI
*/
HWREG16(baseAddress + OFS_UCAxCTLW0) |= (
param->msbFirst +
param->clockPhase +
param->clockPolarity +
UCMST +
UCSYNC +
param->spiMode
);
//No modulation
HWREG16(baseAddress + OFS_UCAxMCTLW) = 0;
}
void EUSCI_A_SPI_select4PinFunctionality(uint16_t baseAddress,
uint8_t select4PinFunctionality)
{
HWREG16(baseAddress + OFS_UCAxCTLW0) &= ~UCSTEM;
HWREG16(baseAddress + OFS_UCAxCTLW0) |= select4PinFunctionality;
}
void EUSCI_A_SPI_changeMasterClock(uint16_t baseAddress,
EUSCI_A_SPI_changeMasterClockParam *param)
{
//Disable the USCI Module
HWREG16(baseAddress + OFS_UCAxCTLW0) |= UCSWRST;
HWREG16(baseAddress + OFS_UCAxBRW) =
(uint16_t)(param->clockSourceFrequency / param->desiredSpiClock);
//Reset the UCSWRST bit to enable the USCI Module
HWREG16(baseAddress + OFS_UCAxCTLW0) &= ~(UCSWRST);
}
void EUSCI_A_SPI_initSlave(uint16_t baseAddress,
EUSCI_A_SPI_initSlaveParam *param)
{
//Disable USCI Module
HWREG16(baseAddress + OFS_UCAxCTLW0) |= UCSWRST;
//Reset OFS_UCAxCTLW0 register
HWREG16(baseAddress + OFS_UCAxCTLW0) &= ~(UCMSB +
UC7BIT +
UCMST +
UCCKPL +
UCCKPH +
UCMODE_3
);
//Clock polarity, phase select, msbFirst, SYNC, Mode0
HWREG16(baseAddress + OFS_UCAxCTLW0) |= (param->clockPhase +
param->clockPolarity +
param->msbFirst +
UCSYNC +
param->spiMode
);
}
void EUSCI_A_SPI_changeClockPhasePolarity(uint16_t baseAddress,
uint16_t clockPhase,
uint16_t clockPolarity)
{
//Disable the USCI Module
HWREG16(baseAddress + OFS_UCAxCTLW0) |= UCSWRST;
HWREG16(baseAddress + OFS_UCAxCTLW0) &= ~(UCCKPH + UCCKPL);
HWREG16(baseAddress + OFS_UCAxCTLW0) |= (
clockPhase +
clockPolarity
);
//Reset the UCSWRST bit to enable the USCI Module
HWREG16(baseAddress + OFS_UCAxCTLW0) &= ~(UCSWRST);
}
void EUSCI_A_SPI_transmitData(uint16_t baseAddress,
uint8_t transmitData)
{
HWREG16(baseAddress + OFS_UCAxTXBUF) = transmitData;
}
uint8_t EUSCI_A_SPI_receiveData(uint16_t baseAddress)
{
return (HWREG16(baseAddress + OFS_UCAxRXBUF));
}
void EUSCI_A_SPI_enableInterrupt(uint16_t baseAddress,
uint8_t mask)
{
HWREG16(baseAddress + OFS_UCAxIE) |= mask;
}
void EUSCI_A_SPI_disableInterrupt(uint16_t baseAddress,
uint8_t mask)
{
HWREG16(baseAddress + OFS_UCAxIE) &= ~mask;
}
uint8_t EUSCI_A_SPI_getInterruptStatus(uint16_t baseAddress,
uint8_t mask)
{
return (HWREG16(baseAddress + OFS_UCAxIFG) & mask);
}
void EUSCI_A_SPI_clearInterrupt(uint16_t baseAddress,
uint8_t mask)
{
HWREG16(baseAddress + OFS_UCAxIFG) &= ~mask;
}
void EUSCI_A_SPI_enable(uint16_t baseAddress)
{
//Reset the UCSWRST bit to enable the USCI Module
HWREG16(baseAddress + OFS_UCAxCTLW0) &= ~(UCSWRST);
}
void EUSCI_A_SPI_disable(uint16_t baseAddress)
{
//Set the UCSWRST bit to disable the USCI Module
HWREG16(baseAddress + OFS_UCAxCTLW0) |= UCSWRST;
}
uint32_t EUSCI_A_SPI_getReceiveBufferAddress(uint16_t baseAddress)
{
return (baseAddress + OFS_UCAxRXBUF);
}
uint32_t EUSCI_A_SPI_getTransmitBufferAddress(uint16_t baseAddress)
{
return (baseAddress + OFS_UCAxTXBUF);
}
uint16_t EUSCI_A_SPI_isBusy(uint16_t baseAddress)
{
//Return the bus busy status.
return (HWREG16(baseAddress + OFS_UCAxSTATW) & UCBUSY);
}
void EUSCI_A_SPI_remapPins(uint16_t baseAddress,
uint8_t pinsSelect)
{
#ifdef USCIARMP
HWREG16(SYS_BASE + OFS_SYSCFG3) &= ~USCIARMP;
HWREG16(SYS_BASE + OFS_SYSCFG3) |= pinsSelect;
#endif
}
#endif
//*****************************************************************************
//
//! Close the doxygen group for eusci_a_spi_api
//! @}
//
//*****************************************************************************

View File

@ -1,563 +0,0 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
//
// eusci_a_spi.h - Driver for the EUSCI_A_SPI Module.
//
//*****************************************************************************
#ifndef __MSP430WARE_EUSCI_A_SPI_H__
#define __MSP430WARE_EUSCI_A_SPI_H__
#include "inc/hw_memmap.h"
#ifdef __MSP430_HAS_EUSCI_Ax__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
#include "inc/hw_memmap.h"
//*****************************************************************************
//
//! \brief Used in the EUSCI_A_SPI_changeMasterClock() function as the param
//! parameter.
//
//*****************************************************************************
typedef struct EUSCI_A_SPI_changeMasterClockParam
{
//! Is the frequency of the selected clock source
uint32_t clockSourceFrequency;
//! Is the desired clock rate for SPI communication
uint32_t desiredSpiClock;
} EUSCI_A_SPI_changeMasterClockParam;
//*****************************************************************************
//
//! \brief Used in the EUSCI_A_SPI_initSlave() function as the param parameter.
//
//*****************************************************************************
typedef struct EUSCI_A_SPI_initSlaveParam
{
//! Controls the direction of the receive and transmit shift register.
//! \n Valid values are:
//! - \b EUSCI_A_SPI_MSB_FIRST
//! - \b EUSCI_A_SPI_LSB_FIRST [Default]
uint16_t msbFirst;
//! Is clock phase select.
//! \n Valid values are:
//! - \b EUSCI_A_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT [Default]
//! - \b EUSCI_A_SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT
uint16_t clockPhase;
//! Is clock polarity select
//! \n Valid values are:
//! - \b EUSCI_A_SPI_CLOCKPOLARITY_INACTIVITY_HIGH
//! - \b EUSCI_A_SPI_CLOCKPOLARITY_INACTIVITY_LOW [Default]
uint16_t clockPolarity;
//! Is SPI mode select
//! \n Valid values are:
//! - \b EUSCI_A_SPI_3PIN
//! - \b EUSCI_A_SPI_4PIN_UCxSTE_ACTIVE_HIGH
//! - \b EUSCI_A_SPI_4PIN_UCxSTE_ACTIVE_LOW
uint16_t spiMode;
} EUSCI_A_SPI_initSlaveParam;
//*****************************************************************************
//
//! \brief Used in the EUSCI_A_SPI_initMaster() function as the param
//! parameter.
//
//*****************************************************************************
typedef struct EUSCI_A_SPI_initMasterParam
{
//! Selects Clock source. Refer to device specific datasheet for available
//! options.
//! \n Valid values are:
//! - \b EUSCI_A_SPI_CLOCKSOURCE_UCLK
//! - \b EUSCI_A_SPI_CLOCKSOURCE_ACLK
//! - \b EUSCI_A_SPI_CLOCKSOURCE_MODCLK
//! - \b EUSCI_A_SPI_CLOCKSOURCE_SMCLK
uint8_t selectClockSource;
//! Is the frequency of the selected clock source
uint32_t clockSourceFrequency;
//! Is the desired clock rate for SPI communication
uint32_t desiredSpiClock;
//! Controls the direction of the receive and transmit shift register.
//! \n Valid values are:
//! - \b EUSCI_A_SPI_MSB_FIRST
//! - \b EUSCI_A_SPI_LSB_FIRST [Default]
uint16_t msbFirst;
//! Is clock phase select.
//! \n Valid values are:
//! - \b EUSCI_A_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT [Default]
//! - \b EUSCI_A_SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT
uint16_t clockPhase;
//! Is clock polarity select
//! \n Valid values are:
//! - \b EUSCI_A_SPI_CLOCKPOLARITY_INACTIVITY_HIGH
//! - \b EUSCI_A_SPI_CLOCKPOLARITY_INACTIVITY_LOW [Default]
uint16_t clockPolarity;
//! Is SPI mode select
//! \n Valid values are:
//! - \b EUSCI_A_SPI_3PIN
//! - \b EUSCI_A_SPI_4PIN_UCxSTE_ACTIVE_HIGH
//! - \b EUSCI_A_SPI_4PIN_UCxSTE_ACTIVE_LOW
uint16_t spiMode;
} EUSCI_A_SPI_initMasterParam;
//*****************************************************************************
//
// The following are values that can be passed to the clockPhase parameter for
// functions: EUSCI_A_SPI_changeClockPhasePolarity(); the param parameter for
// functions: EUSCI_A_SPI_initMaster(), and EUSCI_A_SPI_initSlave().
//
//*****************************************************************************
#define EUSCI_A_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT 0x00
#define EUSCI_A_SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT UCCKPH
//*****************************************************************************
//
// The following are values that can be passed to the param parameter for
// functions: EUSCI_A_SPI_initMaster(), and EUSCI_A_SPI_initSlave().
//
//*****************************************************************************
#define EUSCI_A_SPI_MSB_FIRST UCMSB
#define EUSCI_A_SPI_LSB_FIRST 0x00
//*****************************************************************************
//
// The following are values that can be passed to the param parameter for
// functions: EUSCI_A_SPI_initMaster(), and EUSCI_A_SPI_initSlave(); the
// clockPolarity parameter for functions:
// EUSCI_A_SPI_changeClockPhasePolarity().
//
//*****************************************************************************
#define EUSCI_A_SPI_CLOCKPOLARITY_INACTIVITY_HIGH UCCKPL
#define EUSCI_A_SPI_CLOCKPOLARITY_INACTIVITY_LOW 0x00
//*****************************************************************************
//
// The following are values that can be passed to the param parameter for
// functions: EUSCI_A_SPI_initMaster().
//
//*****************************************************************************
#define EUSCI_A_SPI_CLOCKSOURCE_UCLK UCSSEL__UCLK
#define EUSCI_A_SPI_CLOCKSOURCE_ACLK 0x40
#define EUSCI_A_SPI_CLOCKSOURCE_MODCLK 0x40
#define EUSCI_A_SPI_CLOCKSOURCE_SMCLK UCSSEL__SMCLK
//*****************************************************************************
//
// The following are values that can be passed to the param parameter for
// functions: EUSCI_A_SPI_initMaster(), and EUSCI_A_SPI_initSlave().
//
//*****************************************************************************
#define EUSCI_A_SPI_3PIN UCMODE_0
#define EUSCI_A_SPI_4PIN_UCxSTE_ACTIVE_HIGH UCMODE_1
#define EUSCI_A_SPI_4PIN_UCxSTE_ACTIVE_LOW UCMODE_2
//*****************************************************************************
//
// The following are values that can be passed to the select4PinFunctionality
// parameter for functions: EUSCI_A_SPI_select4PinFunctionality().
//
//*****************************************************************************
#define EUSCI_A_SPI_PREVENT_CONFLICTS_WITH_OTHER_MASTERS 0x00
#define EUSCI_A_SPI_ENABLE_SIGNAL_FOR_4WIRE_SLAVE UCSTEM
//*****************************************************************************
//
// The following are values that can be passed to the mask parameter for
// functions: EUSCI_A_SPI_enableInterrupt(), EUSCI_A_SPI_disableInterrupt(),
// EUSCI_A_SPI_getInterruptStatus(), and EUSCI_A_SPI_clearInterrupt() as well
// as returned by the EUSCI_A_SPI_getInterruptStatus() function.
//
//*****************************************************************************
#define EUSCI_A_SPI_TRANSMIT_INTERRUPT UCTXIE
#define EUSCI_A_SPI_RECEIVE_INTERRUPT UCRXIE
//*****************************************************************************
//
// The following are values that can be passed toThe following are values that
// can be returned by the EUSCI_A_SPI_isBusy() function.
//
//*****************************************************************************
#define EUSCI_A_SPI_BUSY UCBUSY
#define EUSCI_A_SPI_NOT_BUSY 0x00
//*****************************************************************************
//
// The following are values that can be passed to the pinsSelect parameter for
// functions: EUSCI_A_SPI_remapPins().
//
//*****************************************************************************
#define EUSCI_A_SPI_REMAP_PINS_1 0x00
#define EUSCI_A_SPI_REMAP_PINS_2 0x01
//*****************************************************************************
//
// Prototypes for the APIs.
//
//*****************************************************************************
//*****************************************************************************
//
//! \brief Initializes the SPI Master block.
//!
//! Upon successful initialization of the SPI master block, this function will
//! have set the bus speed for the master, but the SPI Master block still
//! remains disabled and must be enabled with EUSCI_A_SPI_enable()
//!
//! \param baseAddress is the base address of the EUSCI_A_SPI Master module.
//! \param param is the pointer to struct for master initialization.
//!
//! Modified bits are \b UCCKPH, \b UCCKPL, \b UC7BIT, \b UCMSB, \b UCSSELx and
//! \b UCSWRST of \b UCAxCTLW0 register.
//!
//! \return STATUS_SUCCESS
//
//*****************************************************************************
extern void EUSCI_A_SPI_initMaster(uint16_t baseAddress,
EUSCI_A_SPI_initMasterParam *param);
//*****************************************************************************
//
//! \brief Selects 4Pin Functionality
//!
//! This function should be invoked only in 4-wire mode. Invoking this function
//! has no effect in 3-wire mode.
//!
//! \param baseAddress is the base address of the EUSCI_A_SPI module.
//! \param select4PinFunctionality selects 4 pin functionality
//! Valid values are:
//! - \b EUSCI_A_SPI_PREVENT_CONFLICTS_WITH_OTHER_MASTERS
//! - \b EUSCI_A_SPI_ENABLE_SIGNAL_FOR_4WIRE_SLAVE
//!
//! Modified bits are \b UCSTEM of \b UCAxCTLW0 register.
//!
//! \return None
//
//*****************************************************************************
extern void EUSCI_A_SPI_select4PinFunctionality(uint16_t baseAddress,
uint8_t select4PinFunctionality);
//*****************************************************************************
//
//! \brief Initializes the SPI Master clock. At the end of this function call,
//! SPI module is left enabled.
//!
//! \param baseAddress is the base address of the EUSCI_A_SPI module.
//! \param param is the pointer to struct for master clock setting.
//!
//! Modified bits are \b UCSWRST of \b UCAxCTLW0 register.
//!
//! \return None
//
//*****************************************************************************
extern void EUSCI_A_SPI_changeMasterClock(uint16_t baseAddress,
EUSCI_A_SPI_changeMasterClockParam *param);
//*****************************************************************************
//
//! \brief Initializes the SPI Slave block.
//!
//! Upon successful initialization of the SPI slave block, this function will
//! have initialized the slave block, but the SPI Slave block still remains
//! disabled and must be enabled with EUSCI_A_SPI_enable()
//!
//! \param baseAddress is the base address of the EUSCI_A_SPI Slave module.
//! \param param is the pointer to struct for slave initialization.
//!
//! Modified bits are \b UCMSB, \b UCMST, \b UC7BIT, \b UCCKPL, \b UCCKPH, \b
//! UCMODE and \b UCSWRST of \b UCAxCTLW0 register.
//!
//! \return STATUS_SUCCESS
//
//*****************************************************************************
extern void EUSCI_A_SPI_initSlave(uint16_t baseAddress,
EUSCI_A_SPI_initSlaveParam *param);
//*****************************************************************************
//
//! \brief Changes the SPI clock phase and polarity. At the end of this
//! function call, SPI module is left enabled.
//!
//! \param baseAddress is the base address of the EUSCI_A_SPI module.
//! \param clockPhase is clock phase select.
//! Valid values are:
//! - \b EUSCI_A_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT
//! [Default]
//! - \b EUSCI_A_SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT
//! \param clockPolarity is clock polarity select
//! Valid values are:
//! - \b EUSCI_A_SPI_CLOCKPOLARITY_INACTIVITY_HIGH
//! - \b EUSCI_A_SPI_CLOCKPOLARITY_INACTIVITY_LOW [Default]
//!
//! Modified bits are \b UCCKPL, \b UCCKPH and \b UCSWRST of \b UCAxCTLW0
//! register.
//!
//! \return None
//
//*****************************************************************************
extern void EUSCI_A_SPI_changeClockPhasePolarity(uint16_t baseAddress,
uint16_t clockPhase,
uint16_t clockPolarity);
//*****************************************************************************
//
//! \brief Transmits a byte from the SPI Module.
//!
//! This function will place the supplied data into SPI transmit data register
//! to start transmission.
//!
//! \param baseAddress is the base address of the EUSCI_A_SPI module.
//! \param transmitData data to be transmitted from the SPI module
//!
//! \return None
//
//*****************************************************************************
extern void EUSCI_A_SPI_transmitData(uint16_t baseAddress,
uint8_t transmitData);
//*****************************************************************************
//
//! \brief Receives a byte that has been sent to the SPI Module.
//!
//! This function reads a byte of data from the SPI receive data Register.
//!
//! \param baseAddress is the base address of the EUSCI_A_SPI module.
//!
//! \return Returns the byte received from by the SPI module, cast as an
//! uint8_t.
//
//*****************************************************************************
extern uint8_t EUSCI_A_SPI_receiveData(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Enables individual SPI interrupt sources.
//!
//! Enables the indicated SPI interrupt sources. Only the sources that are
//! enabled can be reflected to the processor interrupt; disabled sources have
//! no effect on the processor. Does not clear interrupt flags.
//!
//! \param baseAddress is the base address of the EUSCI_A_SPI module.
//! \param mask is the bit mask of the interrupt sources to be enabled.
//! Mask value is the logical OR of any of the following:
//! - \b EUSCI_A_SPI_TRANSMIT_INTERRUPT
//! - \b EUSCI_A_SPI_RECEIVE_INTERRUPT
//!
//! Modified bits of \b UCAxIFG register and bits of \b UCAxIE register.
//!
//! \return None
//
//*****************************************************************************
extern void EUSCI_A_SPI_enableInterrupt(uint16_t baseAddress,
uint8_t mask);
//*****************************************************************************
//
//! \brief Disables individual SPI interrupt sources.
//!
//! Disables the indicated SPI interrupt sources. Only the sources that are
//! enabled can be reflected to the processor interrupt; disabled sources have
//! no effect on the processor.
//!
//! \param baseAddress is the base address of the EUSCI_A_SPI module.
//! \param mask is the bit mask of the interrupt sources to be disabled.
//! Mask value is the logical OR of any of the following:
//! - \b EUSCI_A_SPI_TRANSMIT_INTERRUPT
//! - \b EUSCI_A_SPI_RECEIVE_INTERRUPT
//!
//! Modified bits of \b UCAxIE register.
//!
//! \return None
//
//*****************************************************************************
extern void EUSCI_A_SPI_disableInterrupt(uint16_t baseAddress,
uint8_t mask);
//*****************************************************************************
//
//! \brief Gets the current SPI interrupt status.
//!
//! This returns the interrupt status for the SPI module based on which flag is
//! passed.
//!
//! \param baseAddress is the base address of the EUSCI_A_SPI module.
//! \param mask is the masked interrupt flag status to be returned.
//! Mask value is the logical OR of any of the following:
//! - \b EUSCI_A_SPI_TRANSMIT_INTERRUPT
//! - \b EUSCI_A_SPI_RECEIVE_INTERRUPT
//!
//! \return Logical OR of any of the following:
//! - \b EUSCI_A_SPI_TRANSMIT_INTERRUPT
//! - \b EUSCI_A_SPI_RECEIVE_INTERRUPT
//! \n indicating the status of the masked interrupts
//
//*****************************************************************************
extern uint8_t EUSCI_A_SPI_getInterruptStatus(uint16_t baseAddress,
uint8_t mask);
//*****************************************************************************
//
//! \brief Clears the selected SPI interrupt status flag.
//!
//! \param baseAddress is the base address of the EUSCI_A_SPI module.
//! \param mask is the masked interrupt flag to be cleared.
//! Mask value is the logical OR of any of the following:
//! - \b EUSCI_A_SPI_TRANSMIT_INTERRUPT
//! - \b EUSCI_A_SPI_RECEIVE_INTERRUPT
//!
//! Modified bits of \b UCAxIFG register.
//!
//! \return None
//
//*****************************************************************************
extern void EUSCI_A_SPI_clearInterrupt(uint16_t baseAddress,
uint8_t mask);
//*****************************************************************************
//
//! \brief Enables the SPI block.
//!
//! This will enable operation of the SPI block.
//!
//! \param baseAddress is the base address of the EUSCI_A_SPI module.
//!
//! Modified bits are \b UCSWRST of \b UCAxCTLW0 register.
//!
//! \return None
//
//*****************************************************************************
extern void EUSCI_A_SPI_enable(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Disables the SPI block.
//!
//! This will disable operation of the SPI block.
//!
//! \param baseAddress is the base address of the EUSCI_A_SPI module.
//!
//! Modified bits are \b UCSWRST of \b UCAxCTLW0 register.
//!
//! \return None
//
//*****************************************************************************
extern void EUSCI_A_SPI_disable(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Returns the address of the RX Buffer of the SPI for the DMA module.
//!
//! Returns the address of the SPI RX Buffer. This can be used in conjunction
//! with the DMA to store the received data directly to memory.
//!
//! \param baseAddress is the base address of the EUSCI_A_SPI module.
//!
//! \return the address of the RX Buffer
//
//*****************************************************************************
extern uint32_t EUSCI_A_SPI_getReceiveBufferAddress(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Returns the address of the TX Buffer of the SPI for the DMA module.
//!
//! Returns the address of the SPI TX Buffer. This can be used in conjunction
//! with the DMA to obtain transmitted data directly from memory.
//!
//! \param baseAddress is the base address of the EUSCI_A_SPI module.
//!
//! \return the address of the TX Buffer
//
//*****************************************************************************
extern uint32_t EUSCI_A_SPI_getTransmitBufferAddress(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Indicates whether or not the SPI bus is busy.
//!
//! This function returns an indication of whether or not the SPI bus is
//! busy.This function checks the status of the bus via UCBBUSY bit
//!
//! \param baseAddress is the base address of the EUSCI_A_SPI module.
//!
//! \return One of the following:
//! - \b EUSCI_A_SPI_BUSY
//! - \b EUSCI_A_SPI_NOT_BUSY
//! \n indicating if the EUSCI_A_SPI is busy
//
//*****************************************************************************
extern uint16_t EUSCI_A_SPI_isBusy(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Remaps eUSCI_A GPIO pins.
//!
//! Remaps eUSCI_A GPIO pins. After calling this function,
//! GPIO_setAsPeripheralModuleFunctionInputPin() or
//! GPIO_setAsPeripheralModuleFunctionInputPin() still needs to be invoked to
//! set peripheral functions.
//!
//! \param baseAddress is the base address of the EUSCI_A_SPI module.
//! \param pinsSelect remapping pins to select. Please refer to device specific
//! datasheet for remapping pins details.
//! Valid values are:
//! - \b EUSCI_A_SPI_REMAP_PINS_1 [Default]
//! - \b EUSCI_A_SPI_REMAP_PINS_2
//!
//! \return None
//
//*****************************************************************************
extern void EUSCI_A_SPI_remapPins(uint16_t baseAddress,
uint8_t pinsSelect);
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif
#endif // __MSP430WARE_EUSCI_A_SPI_H__

View File

@ -1,291 +0,0 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
//
// eusci_a_uart.c - Driver for the eusci_a_uart Module.
//
//*****************************************************************************
//*****************************************************************************
//
//! \addtogroup eusci_a_uart_api eusci_a_uart
//! @{
//
//*****************************************************************************
#include "inc/hw_memmap.h"
#ifdef __MSP430_HAS_EUSCI_Ax__
#include "eusci_a_uart.h"
#include <assert.h>
bool EUSCI_A_UART_init(uint16_t baseAddress,
EUSCI_A_UART_initParam *param)
{
bool retVal = STATUS_SUCCESS;
//Disable the USCI Module
HWREG16(baseAddress + OFS_UCAxCTLW0) |= UCSWRST;
//Clock source select
HWREG16(baseAddress + OFS_UCAxCTLW0) &= ~UCSSEL_3;
HWREG16(baseAddress + OFS_UCAxCTLW0) |= param->selectClockSource;
//MSB, LSB select
HWREG16(baseAddress + OFS_UCAxCTLW0) &= ~UCMSB;
HWREG16(baseAddress + OFS_UCAxCTLW0) |= param->msborLsbFirst;
//UCSPB = 0(1 stop bit) OR 1(2 stop bits)
HWREG16(baseAddress + OFS_UCAxCTLW0) &= ~UCSPB;
HWREG16(baseAddress + OFS_UCAxCTLW0) |= param->numberofStopBits;
//Parity
switch(param->parity)
{
case EUSCI_A_UART_NO_PARITY:
//No Parity
HWREG16(baseAddress + OFS_UCAxCTLW0) &= ~UCPEN;
break;
case EUSCI_A_UART_ODD_PARITY:
//Odd Parity
HWREG16(baseAddress + OFS_UCAxCTLW0) |= UCPEN;
HWREG16(baseAddress + OFS_UCAxCTLW0) &= ~UCPAR;
break;
case EUSCI_A_UART_EVEN_PARITY:
//Even Parity
HWREG16(baseAddress + OFS_UCAxCTLW0) |= UCPEN;
HWREG16(baseAddress + OFS_UCAxCTLW0) |= UCPAR;
break;
}
//BaudRate Control Register
HWREG16(baseAddress + OFS_UCAxBRW) = param->clockPrescalar;
//Modulation Control Register
HWREG16(baseAddress + OFS_UCAxMCTLW) = ((param->secondModReg << 8)
+ (param->firstModReg <<
4) + param->overSampling);
//Asynchronous mode & 8 bit character select & clear mode
HWREG16(baseAddress + OFS_UCAxCTLW0) &= ~(UCSYNC +
UC7BIT +
UCMODE_3
);
//Configure UART mode.
HWREG16(baseAddress + OFS_UCAxCTLW0) |= param->uartMode;
//Reset UCRXIE, UCBRKIE, UCDORM, UCTXADDR, UCTXBRK
HWREG16(baseAddress + OFS_UCAxCTLW0) &= ~(UCRXEIE + UCBRKIE + UCDORM +
UCTXADDR + UCTXBRK
);
return (retVal);
}
void EUSCI_A_UART_transmitData(uint16_t baseAddress,
uint8_t transmitData)
{
//If interrupts are not used, poll for flags
if(!(HWREG16(baseAddress + OFS_UCAxIE) & UCTXIE))
{
//Poll for transmit interrupt flag
while(!(HWREG16(baseAddress + OFS_UCAxIFG) & UCTXIFG))
{
;
}
}
HWREG16(baseAddress + OFS_UCAxTXBUF) = transmitData;
}
uint8_t EUSCI_A_UART_receiveData(uint16_t baseAddress)
{
//If interrupts are not used, poll for flags
if(!(HWREG16(baseAddress + OFS_UCAxIE) & UCRXIE))
{
//Poll for receive interrupt flag
while(!(HWREG16(baseAddress + OFS_UCAxIFG) & UCRXIFG))
{
;
}
}
return (HWREG16(baseAddress + OFS_UCAxRXBUF));
}
void EUSCI_A_UART_enableInterrupt(uint16_t baseAddress,
uint8_t mask)
{
uint8_t locMask;
locMask = (mask & (EUSCI_A_UART_RECEIVE_INTERRUPT
| EUSCI_A_UART_TRANSMIT_INTERRUPT
| EUSCI_A_UART_STARTBIT_INTERRUPT
| EUSCI_A_UART_TRANSMIT_COMPLETE_INTERRUPT));
HWREG16(baseAddress + OFS_UCAxIE) |= locMask;
locMask = (mask & (EUSCI_A_UART_RECEIVE_ERRONEOUSCHAR_INTERRUPT
| EUSCI_A_UART_BREAKCHAR_INTERRUPT));
HWREG16(baseAddress + OFS_UCAxCTLW0) |= locMask;
}
void EUSCI_A_UART_disableInterrupt(uint16_t baseAddress,
uint8_t mask)
{
uint8_t locMask;
locMask = (mask & (EUSCI_A_UART_RECEIVE_INTERRUPT
| EUSCI_A_UART_TRANSMIT_INTERRUPT
| EUSCI_A_UART_STARTBIT_INTERRUPT
| EUSCI_A_UART_TRANSMIT_COMPLETE_INTERRUPT));
HWREG16(baseAddress + OFS_UCAxIE) &= ~locMask;
locMask = (mask & (EUSCI_A_UART_RECEIVE_ERRONEOUSCHAR_INTERRUPT
| EUSCI_A_UART_BREAKCHAR_INTERRUPT));
HWREG16(baseAddress + OFS_UCAxCTLW0) &= ~locMask;
}
uint8_t EUSCI_A_UART_getInterruptStatus(uint16_t baseAddress,
uint8_t mask)
{
return (HWREG16(baseAddress + OFS_UCAxIFG) & mask);
}
void EUSCI_A_UART_clearInterrupt(uint16_t baseAddress,
uint8_t mask)
{
//Clear the UART interrupt source.
HWREG16(baseAddress + OFS_UCAxIFG) &= ~(mask);
}
void EUSCI_A_UART_enable(uint16_t baseAddress)
{
//Reset the UCSWRST bit to enable the USCI Module
HWREG16(baseAddress + OFS_UCAxCTLW0) &= ~(UCSWRST);
}
void EUSCI_A_UART_disable(uint16_t baseAddress)
{
//Set the UCSWRST bit to disable the USCI Module
HWREG16(baseAddress + OFS_UCAxCTLW0) |= UCSWRST;
}
uint8_t EUSCI_A_UART_queryStatusFlags(uint16_t baseAddress,
uint8_t mask)
{
return (HWREG16(baseAddress + OFS_UCAxSTATW) & mask);
}
void EUSCI_A_UART_setDormant(uint16_t baseAddress)
{
HWREG16(baseAddress + OFS_UCAxCTLW0) |= UCDORM;
}
void EUSCI_A_UART_resetDormant(uint16_t baseAddress)
{
HWREG16(baseAddress + OFS_UCAxCTLW0) &= ~UCDORM;
}
void EUSCI_A_UART_transmitAddress(uint16_t baseAddress,
uint8_t transmitAddress)
{
//Set UCTXADDR bit
HWREG16(baseAddress + OFS_UCAxCTLW0) |= UCTXADDR;
//Place next byte to be sent into the transmit buffer
HWREG16(baseAddress + OFS_UCAxTXBUF) = transmitAddress;
}
void EUSCI_A_UART_transmitBreak(uint16_t baseAddress)
{
//Set UCTXADDR bit
HWREG16(baseAddress + OFS_UCAxCTLW0) |= UCTXBRK;
//If current mode is automatic baud-rate detection
if(EUSCI_A_UART_AUTOMATIC_BAUDRATE_DETECTION_MODE ==
(HWREG16(baseAddress + OFS_UCAxCTLW0) &
EUSCI_A_UART_AUTOMATIC_BAUDRATE_DETECTION_MODE))
{
HWREG16(baseAddress +
OFS_UCAxTXBUF) = EUSCI_A_UART_AUTOMATICBAUDRATE_SYNC;
}
else
{
HWREG16(baseAddress + OFS_UCAxTXBUF) = DEFAULT_SYNC;
}
//If interrupts are not used, poll for flags
if(!(HWREG16(baseAddress + OFS_UCAxIE) & UCTXIE))
{
//Poll for transmit interrupt flag
while(!(HWREG16(baseAddress + OFS_UCAxIFG) & UCTXIFG))
{
;
}
}
}
uint32_t EUSCI_A_UART_getReceiveBufferAddress(uint16_t baseAddress)
{
return (baseAddress + OFS_UCAxRXBUF);
}
uint32_t EUSCI_A_UART_getTransmitBufferAddress(uint16_t baseAddress)
{
return (baseAddress + OFS_UCAxTXBUF);
}
void EUSCI_A_UART_selectDeglitchTime(uint16_t baseAddress,
uint16_t deglitchTime)
{
HWREG16(baseAddress + OFS_UCAxCTLW1) &= ~(UCGLIT1 + UCGLIT0);
HWREG16(baseAddress + OFS_UCAxCTLW1) |= deglitchTime;
}
void EUSCI_A_UART_remapPins(uint16_t baseAddress,
uint8_t pinsSelect)
{
#ifdef USCIARMP
HWREG16(SYS_BASE + OFS_SYSCFG3) &= ~USCIARMP;
HWREG16(SYS_BASE + OFS_SYSCFG3) |= pinsSelect;
#endif
}
#endif
//*****************************************************************************
//
//! Close the doxygen group for eusci_a_uart_api
//! @}
//
//*****************************************************************************

View File

@ -1,640 +0,0 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
//
// eusci_a_uart.h - Driver for the EUSCI_A_UART Module.
//
//*****************************************************************************
#ifndef __MSP430WARE_EUSCI_A_UART_H__
#define __MSP430WARE_EUSCI_A_UART_H__
#include "inc/hw_memmap.h"
#ifdef __MSP430_HAS_EUSCI_Ax__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
#include "inc/hw_memmap.h"
//*****************************************************************************
//
// The following values are the sync characters possible.
//
//*****************************************************************************
#define DEFAULT_SYNC 0x00
#define EUSCI_A_UART_AUTOMATICBAUDRATE_SYNC 0x55
//*****************************************************************************
//
//! \brief Used in the EUSCI_A_UART_init() function as the param parameter.
//
//*****************************************************************************
typedef struct EUSCI_A_UART_initParam
{
//! Selects Clock source. Refer to device specific datasheet for available
//! options.
//! \n Valid values are:
//! - \b EUSCI_A_UART_CLOCKSOURCE_UCLK
//! - \b EUSCI_A_UART_CLOCKSOURCE_SMCLK
//! - \b EUSCI_A_UART_CLOCKSOURCE_ACLK
//! - \b EUSCI_A_UART_CLOCKSOURCE_MODCLK
uint8_t selectClockSource;
//! Is the value to be written into UCBRx bits
uint16_t clockPrescalar;
//! Is First modulation stage register setting. This value is a pre-
//! calculated value which can be obtained from the Device Users Guide.
//! This value is written into UCBRFx bits of UCAxMCTLW.
uint8_t firstModReg;
//! Is Second modulation stage register setting. This value is a pre-
//! calculated value which can be obtained from the Device Users Guide.
//! This value is written into UCBRSx bits of UCAxMCTLW.
uint8_t secondModReg;
//! Is the desired parity.
//! \n Valid values are:
//! - \b EUSCI_A_UART_NO_PARITY [Default]
//! - \b EUSCI_A_UART_ODD_PARITY
//! - \b EUSCI_A_UART_EVEN_PARITY
uint8_t parity;
//! Controls direction of receive and transmit shift register.
//! \n Valid values are:
//! - \b EUSCI_A_UART_MSB_FIRST
//! - \b EUSCI_A_UART_LSB_FIRST [Default]
uint16_t msborLsbFirst;
//! Indicates one/two STOP bits
//! \n Valid values are:
//! - \b EUSCI_A_UART_ONE_STOP_BIT [Default]
//! - \b EUSCI_A_UART_TWO_STOP_BITS
uint16_t numberofStopBits;
//! Selects the mode of operation
//! \n Valid values are:
//! - \b EUSCI_A_UART_MODE [Default]
//! - \b EUSCI_A_UART_IDLE_LINE_MULTI_PROCESSOR_MODE
//! - \b EUSCI_A_UART_ADDRESS_BIT_MULTI_PROCESSOR_MODE
//! - \b EUSCI_A_UART_AUTOMATIC_BAUDRATE_DETECTION_MODE
uint16_t uartMode;
//! Indicates low frequency or oversampling baud generation
//! \n Valid values are:
//! - \b EUSCI_A_UART_OVERSAMPLING_BAUDRATE_GENERATION
//! - \b EUSCI_A_UART_LOW_FREQUENCY_BAUDRATE_GENERATION
uint8_t overSampling;
} EUSCI_A_UART_initParam;
//*****************************************************************************
//
// The following are values that can be passed to the param parameter for
// functions: EUSCI_A_UART_init().
//
//*****************************************************************************
#define EUSCI_A_UART_NO_PARITY 0x00
#define EUSCI_A_UART_ODD_PARITY 0x01
#define EUSCI_A_UART_EVEN_PARITY 0x02
//*****************************************************************************
//
// The following are values that can be passed to the param parameter for
// functions: EUSCI_A_UART_init().
//
//*****************************************************************************
#define EUSCI_A_UART_MSB_FIRST UCMSB
#define EUSCI_A_UART_LSB_FIRST 0x00
//*****************************************************************************
//
// The following are values that can be passed to the param parameter for
// functions: EUSCI_A_UART_init().
//
//*****************************************************************************
#define EUSCI_A_UART_MODE UCMODE_0
#define EUSCI_A_UART_IDLE_LINE_MULTI_PROCESSOR_MODE UCMODE_1
#define EUSCI_A_UART_ADDRESS_BIT_MULTI_PROCESSOR_MODE UCMODE_2
#define EUSCI_A_UART_AUTOMATIC_BAUDRATE_DETECTION_MODE UCMODE_3
//*****************************************************************************
//
// The following are values that can be passed to the param parameter for
// functions: EUSCI_A_UART_init().
//
//*****************************************************************************
#define EUSCI_A_UART_CLOCKSOURCE_UCLK UCSSEL__UCLK
#define EUSCI_A_UART_CLOCKSOURCE_SMCLK UCSSEL__SMCLK
#define EUSCI_A_UART_CLOCKSOURCE_ACLK 0x40
#define EUSCI_A_UART_CLOCKSOURCE_MODCLK 0x40
//*****************************************************************************
//
// The following are values that can be passed to the param parameter for
// functions: EUSCI_A_UART_init().
//
//*****************************************************************************
#define EUSCI_A_UART_ONE_STOP_BIT 0x00
#define EUSCI_A_UART_TWO_STOP_BITS UCSPB
//*****************************************************************************
//
// The following are values that can be passed to the param parameter for
// functions: EUSCI_A_UART_init().
//
//*****************************************************************************
#define EUSCI_A_UART_OVERSAMPLING_BAUDRATE_GENERATION 0x01
#define EUSCI_A_UART_LOW_FREQUENCY_BAUDRATE_GENERATION 0x00
//*****************************************************************************
//
// The following are values that can be passed to the mask parameter for
// functions: EUSCI_A_UART_enableInterrupt(), and
// EUSCI_A_UART_disableInterrupt().
//
//*****************************************************************************
#define EUSCI_A_UART_RECEIVE_INTERRUPT UCRXIE
#define EUSCI_A_UART_TRANSMIT_INTERRUPT UCTXIE
#define EUSCI_A_UART_RECEIVE_ERRONEOUSCHAR_INTERRUPT UCRXEIE
#define EUSCI_A_UART_BREAKCHAR_INTERRUPT UCBRKIE
#define EUSCI_A_UART_STARTBIT_INTERRUPT UCSTTIE
#define EUSCI_A_UART_TRANSMIT_COMPLETE_INTERRUPT UCTXCPTIE
//*****************************************************************************
//
// The following are values that can be passed to the mask parameter for
// functions: EUSCI_A_UART_getInterruptStatus(), and
// EUSCI_A_UART_clearInterrupt() as well as returned by the
// EUSCI_A_UART_getInterruptStatus() function.
//
//*****************************************************************************
#define EUSCI_A_UART_RECEIVE_INTERRUPT_FLAG UCRXIFG
#define EUSCI_A_UART_TRANSMIT_INTERRUPT_FLAG UCTXIFG
#define EUSCI_A_UART_STARTBIT_INTERRUPT_FLAG UCSTTIFG
#define EUSCI_A_UART_TRANSMIT_COMPLETE_INTERRUPT_FLAG UCTXCPTIFG
//*****************************************************************************
//
// The following are values that can be passed to the mask parameter for
// functions: EUSCI_A_UART_queryStatusFlags() as well as returned by the
// EUSCI_A_UART_queryStatusFlags() function.
//
//*****************************************************************************
#define EUSCI_A_UART_LISTEN_ENABLE UCLISTEN
#define EUSCI_A_UART_FRAMING_ERROR UCFE
#define EUSCI_A_UART_OVERRUN_ERROR UCOE
#define EUSCI_A_UART_PARITY_ERROR UCPE
#define EUSCI_A_UART_BREAK_DETECT UCBRK
#define EUSCI_A_UART_RECEIVE_ERROR UCRXERR
#define EUSCI_A_UART_ADDRESS_RECEIVED UCADDR
#define EUSCI_A_UART_IDLELINE UCIDLE
#define EUSCI_A_UART_BUSY UCBUSY
//*****************************************************************************
//
// The following are values that can be passed to the deglitchTime parameter
// for functions: EUSCI_A_UART_selectDeglitchTime().
//
//*****************************************************************************
#define EUSCI_A_UART_DEGLITCH_TIME_2ns 0x00
#define EUSCI_A_UART_DEGLITCH_TIME_50ns UCGLIT0
#define EUSCI_A_UART_DEGLITCH_TIME_100ns UCGLIT1
#define EUSCI_A_UART_DEGLITCH_TIME_200ns (UCGLIT0 + UCGLIT1)
//*****************************************************************************
//
// The following are values that can be passed to the pinsSelect parameter for
// functions: EUSCI_A_UART_remapPins().
//
//*****************************************************************************
#define EUSCI_A_UART_REMAP_PINS_1 0x00
#define EUSCI_A_UART_REMAP_PINS_2 0x01
//*****************************************************************************
//
// Prototypes for the APIs.
//
//*****************************************************************************
//*****************************************************************************
//
//! \brief Advanced initialization routine for the UART block. The values to be
//! written into the clockPrescalar, firstModReg, secondModReg and overSampling
//! parameters should be pre-computed and passed into the initialization
//! function.
//!
//! Upon successful initialization of the UART block, this function will have
//! initialized the module, but the UART block still remains disabled and must
//! be enabled with EUSCI_A_UART_enable(). To calculate values for
//! clockPrescalar, firstModReg, secondModReg and overSampling please use the
//! link below.
//!
//! http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSP430BaudRateConverter/index.html
//!
//! \param baseAddress is the base address of the EUSCI_A_UART module.
//! \param param is the pointer to struct for initialization.
//!
//! Modified bits are \b UCPEN, \b UCPAR, \b UCMSB, \b UC7BIT, \b UCSPB, \b
//! UCMODEx and \b UCSYNC of \b UCAxCTL0 register; bits \b UCSSELx and \b
//! UCSWRST of \b UCAxCTL1 register.
//!
//! \return STATUS_SUCCESS or STATUS_FAIL of the initialization process
//
//*****************************************************************************
extern bool EUSCI_A_UART_init(uint16_t baseAddress,
EUSCI_A_UART_initParam *param);
//*****************************************************************************
//
//! \brief Transmits a byte from the UART Module.Please note that if TX
//! interrupt is disabled, this function manually polls the TX IFG flag waiting
//! for an indication that it is safe to write to the transmit buffer and does
//! not time-out
//!
//! This function will place the supplied data into UART transmit data register
//! to start transmission
//!
//! \param baseAddress is the base address of the EUSCI_A_UART module.
//! \param transmitData data to be transmitted from the UART module
//!
//! Modified bits of \b UCAxTXBUF register.
//!
//! \return None
//
//*****************************************************************************
extern void EUSCI_A_UART_transmitData(uint16_t baseAddress,
uint8_t transmitData);
//*****************************************************************************
//
//! \brief Receives a byte that has been sent to the UART Module.
//!
//! This function reads a byte of data from the UART receive data Register.
//!
//! \param baseAddress is the base address of the EUSCI_A_UART module.
//!
//! Modified bits of \b UCAxRXBUF register.
//!
//! \return Returns the byte received from by the UART module, cast as an
//! uint8_t.
//
//*****************************************************************************
extern uint8_t EUSCI_A_UART_receiveData(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Enables individual UART interrupt sources.
//!
//! Enables the indicated UART interrupt sources. The interrupt flag is first
//! and then the corresponding interrupt is enabled. Only the sources that are
//! enabled can be reflected to the processor interrupt; disabled sources have
//! no effect on the processor. Does not clear interrupt flags.
//!
//! \param baseAddress is the base address of the EUSCI_A_UART module.
//! \param mask is the bit mask of the interrupt sources to be enabled.
//! Mask value is the logical OR of any of the following:
//! - \b EUSCI_A_UART_RECEIVE_INTERRUPT - Receive interrupt
//! - \b EUSCI_A_UART_TRANSMIT_INTERRUPT - Transmit interrupt
//! - \b EUSCI_A_UART_RECEIVE_ERRONEOUSCHAR_INTERRUPT - Receive
//! erroneous-character interrupt enable
//! - \b EUSCI_A_UART_BREAKCHAR_INTERRUPT - Receive break character
//! interrupt enable
//! - \b EUSCI_A_UART_STARTBIT_INTERRUPT - Start bit received interrupt
//! enable
//! - \b EUSCI_A_UART_TRANSMIT_COMPLETE_INTERRUPT - Transmit complete
//! interrupt enable
//!
//! Modified bits of \b UCAxCTL1 register and bits of \b UCAxIE register.
//!
//! \return None
//
//*****************************************************************************
extern void EUSCI_A_UART_enableInterrupt(uint16_t baseAddress,
uint8_t mask);
//*****************************************************************************
//
//! \brief Disables individual UART interrupt sources.
//!
//! Disables the indicated UART interrupt sources. Only the sources that are
//! enabled can be reflected to the processor interrupt; disabled sources have
//! no effect on the processor.
//!
//! \param baseAddress is the base address of the EUSCI_A_UART module.
//! \param mask is the bit mask of the interrupt sources to be disabled.
//! Mask value is the logical OR of any of the following:
//! - \b EUSCI_A_UART_RECEIVE_INTERRUPT - Receive interrupt
//! - \b EUSCI_A_UART_TRANSMIT_INTERRUPT - Transmit interrupt
//! - \b EUSCI_A_UART_RECEIVE_ERRONEOUSCHAR_INTERRUPT - Receive
//! erroneous-character interrupt enable
//! - \b EUSCI_A_UART_BREAKCHAR_INTERRUPT - Receive break character
//! interrupt enable
//! - \b EUSCI_A_UART_STARTBIT_INTERRUPT - Start bit received interrupt
//! enable
//! - \b EUSCI_A_UART_TRANSMIT_COMPLETE_INTERRUPT - Transmit complete
//! interrupt enable
//!
//! Modified bits of \b UCAxCTL1 register and bits of \b UCAxIE register.
//!
//! \return None
//
//*****************************************************************************
extern void EUSCI_A_UART_disableInterrupt(uint16_t baseAddress,
uint8_t mask);
//*****************************************************************************
//
//! \brief Gets the current UART interrupt status.
//!
//! This returns the interrupt status for the UART module based on which flag
//! is passed.
//!
//! \param baseAddress is the base address of the EUSCI_A_UART module.
//! \param mask is the masked interrupt flag status to be returned.
//! Mask value is the logical OR of any of the following:
//! - \b EUSCI_A_UART_RECEIVE_INTERRUPT_FLAG
//! - \b EUSCI_A_UART_TRANSMIT_INTERRUPT_FLAG
//! - \b EUSCI_A_UART_STARTBIT_INTERRUPT_FLAG
//! - \b EUSCI_A_UART_TRANSMIT_COMPLETE_INTERRUPT_FLAG
//!
//! Modified bits of \b UCAxIFG register.
//!
//! \return Logical OR of any of the following:
//! - \b EUSCI_A_UART_RECEIVE_INTERRUPT_FLAG
//! - \b EUSCI_A_UART_TRANSMIT_INTERRUPT_FLAG
//! - \b EUSCI_A_UART_STARTBIT_INTERRUPT_FLAG
//! - \b EUSCI_A_UART_TRANSMIT_COMPLETE_INTERRUPT_FLAG
//! \n indicating the status of the masked flags
//
//*****************************************************************************
extern uint8_t EUSCI_A_UART_getInterruptStatus(uint16_t baseAddress,
uint8_t mask);
//*****************************************************************************
//
//! \brief Clears UART interrupt sources.
//!
//! The UART interrupt source is cleared, so that it no longer asserts. The
//! highest interrupt flag is automatically cleared when an interrupt vector
//! generator is used.
//!
//! \param baseAddress is the base address of the EUSCI_A_UART module.
//! \param mask is a bit mask of the interrupt sources to be cleared.
//! Mask value is the logical OR of any of the following:
//! - \b EUSCI_A_UART_RECEIVE_INTERRUPT_FLAG
//! - \b EUSCI_A_UART_TRANSMIT_INTERRUPT_FLAG
//! - \b EUSCI_A_UART_STARTBIT_INTERRUPT_FLAG
//! - \b EUSCI_A_UART_TRANSMIT_COMPLETE_INTERRUPT_FLAG
//!
//! Modified bits of \b UCAxIFG register.
//!
//! \return None
//
//*****************************************************************************
extern void EUSCI_A_UART_clearInterrupt(uint16_t baseAddress,
uint8_t mask);
//*****************************************************************************
//
//! \brief Enables the UART block.
//!
//! This will enable operation of the UART block.
//!
//! \param baseAddress is the base address of the EUSCI_A_UART module.
//!
//! Modified bits are \b UCSWRST of \b UCAxCTL1 register.
//!
//! \return None
//
//*****************************************************************************
extern void EUSCI_A_UART_enable(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Disables the UART block.
//!
//! This will disable operation of the UART block.
//!
//! \param baseAddress is the base address of the EUSCI_A_UART module.
//!
//! Modified bits are \b UCSWRST of \b UCAxCTL1 register.
//!
//! \return None
//
//*****************************************************************************
extern void EUSCI_A_UART_disable(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Gets the current UART status flags.
//!
//! This returns the status for the UART module based on which flag is passed.
//!
//! \param baseAddress is the base address of the EUSCI_A_UART module.
//! \param mask is the masked interrupt flag status to be returned.
//! Mask value is the logical OR of any of the following:
//! - \b EUSCI_A_UART_LISTEN_ENABLE
//! - \b EUSCI_A_UART_FRAMING_ERROR
//! - \b EUSCI_A_UART_OVERRUN_ERROR
//! - \b EUSCI_A_UART_PARITY_ERROR
//! - \b EUSCI_A_UART_BREAK_DETECT
//! - \b EUSCI_A_UART_RECEIVE_ERROR
//! - \b EUSCI_A_UART_ADDRESS_RECEIVED
//! - \b EUSCI_A_UART_IDLELINE
//! - \b EUSCI_A_UART_BUSY
//!
//! Modified bits of \b UCAxSTAT register.
//!
//! \return Logical OR of any of the following:
//! - \b EUSCI_A_UART_LISTEN_ENABLE
//! - \b EUSCI_A_UART_FRAMING_ERROR
//! - \b EUSCI_A_UART_OVERRUN_ERROR
//! - \b EUSCI_A_UART_PARITY_ERROR
//! - \b EUSCI_A_UART_BREAK_DETECT
//! - \b EUSCI_A_UART_RECEIVE_ERROR
//! - \b EUSCI_A_UART_ADDRESS_RECEIVED
//! - \b EUSCI_A_UART_IDLELINE
//! - \b EUSCI_A_UART_BUSY
//! \n indicating the status of the masked interrupt flags
//
//*****************************************************************************
extern uint8_t EUSCI_A_UART_queryStatusFlags(uint16_t baseAddress,
uint8_t mask);
//*****************************************************************************
//
//! \brief Sets the UART module in dormant mode
//!
//! Puts USCI in sleep mode Only characters that are preceded by an idle-line
//! or with address bit set UCRXIFG. In UART mode with automatic baud-rate
//! detection, only the combination of a break and sync field sets UCRXIFG.
//!
//! \param baseAddress is the base address of the EUSCI_A_UART module.
//!
//! Modified bits of \b UCAxCTL1 register.
//!
//! \return None
//
//*****************************************************************************
extern void EUSCI_A_UART_setDormant(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Re-enables UART module from dormant mode
//!
//! Not dormant. All received characters set UCRXIFG.
//!
//! \param baseAddress is the base address of the EUSCI_A_UART module.
//!
//! Modified bits are \b UCDORM of \b UCAxCTL1 register.
//!
//! \return None
//
//*****************************************************************************
extern void EUSCI_A_UART_resetDormant(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Transmits the next byte to be transmitted marked as address
//! depending on selected multiprocessor mode
//!
//! \param baseAddress is the base address of the EUSCI_A_UART module.
//! \param transmitAddress is the next byte to be transmitted
//!
//! Modified bits of \b UCAxTXBUF register and bits of \b UCAxCTL1 register.
//!
//! \return None
//
//*****************************************************************************
extern void EUSCI_A_UART_transmitAddress(uint16_t baseAddress,
uint8_t transmitAddress);
//*****************************************************************************
//
//! \brief Transmit break.
//!
//! Transmits a break with the next write to the transmit buffer. In UART mode
//! with automatic baud-rate detection,
//! EUSCI_A_UART_AUTOMATICBAUDRATE_SYNC(0x55) must be written into UCAxTXBUF to
//! generate the required break/sync fields. Otherwise, DEFAULT_SYNC(0x00) must
//! be written into the transmit buffer. Also ensures module is ready for
//! transmitting the next data.
//!
//! \param baseAddress is the base address of the EUSCI_A_UART module.
//!
//! Modified bits of \b UCAxTXBUF register and bits of \b UCAxCTL1 register.
//!
//! \return None
//
//*****************************************************************************
extern void EUSCI_A_UART_transmitBreak(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Returns the address of the RX Buffer of the UART for the DMA module.
//!
//! Returns the address of the UART RX Buffer. This can be used in conjunction
//! with the DMA to store the received data directly to memory.
//!
//! \param baseAddress is the base address of the EUSCI_A_UART module.
//!
//! \return Address of RX Buffer
//
//*****************************************************************************
extern uint32_t EUSCI_A_UART_getReceiveBufferAddress(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Returns the address of the TX Buffer of the UART for the DMA module.
//!
//! Returns the address of the UART TX Buffer. This can be used in conjunction
//! with the DMA to obtain transmitted data directly from memory.
//!
//! \param baseAddress is the base address of the EUSCI_A_UART module.
//!
//! \return Address of TX Buffer
//
//*****************************************************************************
extern uint32_t EUSCI_A_UART_getTransmitBufferAddress(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Sets the deglitch time
//!
//! \param baseAddress is the base address of the EUSCI_A_UART module.
//! \param deglitchTime is the selected deglitch time
//! Valid values are:
//! - \b EUSCI_A_UART_DEGLITCH_TIME_2ns
//! - \b EUSCI_A_UART_DEGLITCH_TIME_50ns
//! - \b EUSCI_A_UART_DEGLITCH_TIME_100ns
//! - \b EUSCI_A_UART_DEGLITCH_TIME_200ns
//!
//! \return None
//
//*****************************************************************************
extern void EUSCI_A_UART_selectDeglitchTime(uint16_t baseAddress,
uint16_t deglitchTime);
//*****************************************************************************
//
//! \brief Remaps eUSCI_A GPIO pins.
//!
//! Remaps eUSCI_A GPIO pins. After calling this function,
//! GPIO_setAsPeripheralModuleFunctionInputPin() or
//! GPIO_setAsPeripheralModuleFunctionInputPin() still needs to be invoked to
//! set peripheral functions.
//!
//! \param baseAddress is the base address of the EUSCI_A_UART module.
//! \param pinsSelect remapping pins to select. Please refer to device specific
//! datasheet for remapping pins details.
//! Valid values are:
//! - \b EUSCI_A_UART_REMAP_PINS_1 [Default]
//! - \b EUSCI_A_UART_REMAP_PINS_2
//!
//! \return None
//
//*****************************************************************************
extern void EUSCI_A_UART_remapPins(uint16_t baseAddress,
uint8_t pinsSelect);
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif
#endif // __MSP430WARE_EUSCI_A_UART_H__

View File

@ -1,652 +0,0 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
//
// eusci_b_i2c.c - Driver for the eusci_b_i2c Module.
//
//*****************************************************************************
//*****************************************************************************
//
//! \addtogroup eusci_b_i2c_api eusci_b_i2c
//! @{
//
//*****************************************************************************
#include "inc/hw_memmap.h"
#ifdef __MSP430_HAS_EUSCI_Bx__
#include "eusci_b_i2c.h"
#include <assert.h>
void EUSCI_B_I2C_initMaster(uint16_t baseAddress,
EUSCI_B_I2C_initMasterParam *param)
{
uint16_t preScalarValue;
//Disable the USCI module and clears the other bits of control register
HWREG16(baseAddress + OFS_UCBxCTLW0) = UCSWRST;
//Configure Automatic STOP condition generation
HWREG16(baseAddress + OFS_UCBxCTLW1) &= ~UCASTP_3;
HWREG16(baseAddress + OFS_UCBxCTLW1) |= param->autoSTOPGeneration;
//Byte Count Threshold
HWREG16(baseAddress + OFS_UCBxTBCNT) = param->byteCounterThreshold;
/*
* Configure as I2C master mode.
* UCMST = Master mode
* UCMODE_3 = I2C mode
* UCSYNC = Synchronous mode
*/
HWREG16(baseAddress + OFS_UCBxCTLW0) |= UCMST + UCMODE_3 + UCSYNC;
//Configure I2C clock source
HWREG16(baseAddress +
OFS_UCBxCTLW0) |= (param->selectClockSource + UCSWRST);
/*
* Compute the clock divider that achieves the fastest speed less than or
* equal to the desired speed. The numerator is biased to favor a larger
* clock divider so that the resulting clock is always less than or equal
* to the desired clock, never greater.
*/
preScalarValue = (uint16_t)(param->i2cClk / param->dataRate);
HWREG16(baseAddress + OFS_UCBxBRW) = preScalarValue;
}
void EUSCI_B_I2C_initSlave(uint16_t baseAddress,
EUSCI_B_I2C_initSlaveParam *param)
{
//Disable the USCI module
HWREG16(baseAddress + OFS_UCBxCTLW0) |= UCSWRST;
//Clear USCI master mode
HWREG16(baseAddress + OFS_UCBxCTLW0) &= ~UCMST;
//Configure I2C as Slave and Synchronous mode
HWREG16(baseAddress + OFS_UCBxCTLW0) |= UCMODE_3 + UCSYNC;
//Set up the slave address.
HWREG16(baseAddress + OFS_UCBxI2COA0 + param->slaveAddressOffset)
= param->slaveAddress + param->slaveOwnAddressEnable;
}
void EUSCI_B_I2C_enable(uint16_t baseAddress)
{
//Reset the UCSWRST bit to enable the USCI Module
HWREG16(baseAddress + OFS_UCBxCTLW0) &= ~(UCSWRST);
}
void EUSCI_B_I2C_disable(uint16_t baseAddress)
{
//Set the UCSWRST bit to disable the USCI Module
HWREG16(baseAddress + OFS_UCBxCTLW0) |= UCSWRST;
}
void EUSCI_B_I2C_setSlaveAddress(uint16_t baseAddress,
uint8_t slaveAddress)
{
//Set the address of the slave with which the master will communicate.
HWREG16(baseAddress + OFS_UCBxI2CSA) = (slaveAddress);
}
void EUSCI_B_I2C_setMode(uint16_t baseAddress,
uint8_t mode)
{
HWREG16(baseAddress + OFS_UCBxCTLW0) &= ~EUSCI_B_I2C_TRANSMIT_MODE;
HWREG16(baseAddress + OFS_UCBxCTLW0) |= mode;
}
uint8_t EUSCI_B_I2C_getMode(uint16_t baseAddress)
{
//Read the I2C mode.
return ((HWREG16(baseAddress + OFS_UCBxCTLW0) & UCTR));
}
void EUSCI_B_I2C_slavePutData(uint16_t baseAddress,
uint8_t transmitData)
{
//Send single byte data.
HWREG16(baseAddress + OFS_UCBxTXBUF) = transmitData;
}
uint8_t EUSCI_B_I2C_slaveGetData(uint16_t baseAddress)
{
//Read a byte.
return (HWREG16(baseAddress + OFS_UCBxRXBUF));
}
uint16_t EUSCI_B_I2C_isBusBusy(uint16_t baseAddress)
{
//Return the bus busy status.
return (HWREG16(baseAddress + OFS_UCBxSTATW) & UCBBUSY);
}
uint16_t EUSCI_B_I2C_masterIsStopSent(uint16_t baseAddress)
{
return (HWREG16(baseAddress + OFS_UCBxCTLW0) & UCTXSTP);
}
uint16_t EUSCI_B_I2C_masterIsStartSent(uint16_t baseAddress)
{
return (HWREG16(baseAddress + OFS_UCBxCTLW0) & UCTXSTT);
}
void EUSCI_B_I2C_enableInterrupt(uint16_t baseAddress,
uint16_t mask)
{
//Enable the interrupt masked bit
HWREG16(baseAddress + OFS_UCBxIE) |= mask;
}
void EUSCI_B_I2C_disableInterrupt(uint16_t baseAddress,
uint16_t mask)
{
//Disable the interrupt masked bit
HWREG16(baseAddress + OFS_UCBxIE) &= ~(mask);
}
void EUSCI_B_I2C_clearInterrupt(uint16_t baseAddress,
uint16_t mask)
{
//Clear the I2C interrupt source.
HWREG16(baseAddress + OFS_UCBxIFG) &= ~(mask);
}
uint16_t EUSCI_B_I2C_getInterruptStatus(uint16_t baseAddress,
uint16_t mask)
{
//Return the interrupt status of the request masked bit.
return (HWREG16(baseAddress + OFS_UCBxIFG) & mask);
}
void EUSCI_B_I2C_masterSendSingleByte(uint16_t baseAddress,
uint8_t txData)
{
//Store current TXIE status
uint16_t txieStatus = HWREG16(baseAddress + OFS_UCBxIE) & UCTXIE;
//Disable transmit interrupt enable
HWREG16(baseAddress + OFS_UCBxIE) &= ~(UCTXIE);
//Send start condition.
HWREG16(baseAddress + OFS_UCBxCTLW0) |= UCTR + UCTXSTT;
//Poll for transmit interrupt flag.
while(!(HWREG16(baseAddress + OFS_UCBxIFG) & UCTXIFG))
{
;
}
//Send single byte data.
HWREG16(baseAddress + OFS_UCBxTXBUF) = txData;
//Poll for transmit interrupt flag.
while(!(HWREG16(baseAddress + OFS_UCBxIFG) & UCTXIFG))
{
;
}
//Send stop condition.
HWREG16(baseAddress + OFS_UCBxCTLW0) |= UCTXSTP;
//Clear transmit interrupt flag before enabling interrupt again
HWREG16(baseAddress + OFS_UCBxIFG) &= ~(UCTXIFG);
//Reinstate transmit interrupt enable
HWREG16(baseAddress + OFS_UCBxIE) |= txieStatus;
}
uint8_t EUSCI_B_I2C_masterReceiveSingleByte(uint16_t baseAddress)
{
//Set USCI in Receive mode
HWREG16(baseAddress + OFS_UCBxCTLW0) &= ~UCTR;
//Send start
HWREG16(baseAddress + OFS_UCBxCTLW0) |= (UCTXSTT + UCTXSTP);
//Poll for receive interrupt flag.
while(!(HWREG16(baseAddress + OFS_UCBxIFG) & UCRXIFG))
{
;
}
//Send single byte data.
return (HWREG16(baseAddress + OFS_UCBxRXBUF));
}
bool EUSCI_B_I2C_masterSendSingleByteWithTimeout(uint16_t baseAddress,
uint8_t txData,
uint32_t timeout)
{
// Creating variable for second timeout scenario
uint32_t timeout2 = timeout;
//Store current TXIE status
uint16_t txieStatus = HWREG16(baseAddress + OFS_UCBxIE) & UCTXIE;
//Disable transmit interrupt enable
HWREG16(baseAddress + OFS_UCBxIE) &= ~(UCTXIE);
//Send start condition.
HWREG16(baseAddress + OFS_UCBxCTLW0) |= UCTR + UCTXSTT;
//Poll for transmit interrupt flag.
while((!(HWREG16(baseAddress + OFS_UCBxIFG) & UCTXIFG)) && --timeout)
{
;
}
//Check if transfer timed out
if(timeout == 0)
{
return (STATUS_FAIL);
}
//Send single byte data.
HWREG16(baseAddress + OFS_UCBxTXBUF) = txData;
//Poll for transmit interrupt flag.
while((!(HWREG16(baseAddress + OFS_UCBxIFG) & UCTXIFG)) && --timeout2)
{
;
}
//Check if transfer timed out
if(timeout2 == 0)
{
return (STATUS_FAIL);
}
//Send stop condition.
HWREG16(baseAddress + OFS_UCBxCTLW0) |= UCTXSTP;
//Clear transmit interrupt flag before enabling interrupt again
HWREG16(baseAddress + OFS_UCBxIFG) &= ~(UCTXIFG);
//Reinstate transmit interrupt enable
HWREG16(baseAddress + OFS_UCBxIE) |= txieStatus;
return (STATUS_SUCCESS);
}
void EUSCI_B_I2C_masterSendMultiByteStart(uint16_t baseAddress,
uint8_t txData)
{
//Store current transmit interrupt enable
uint16_t txieStatus = HWREG16(baseAddress + OFS_UCBxIE) & UCTXIE;
//Disable transmit interrupt enable
HWREG16(baseAddress + OFS_UCBxIE) &= ~(UCTXIE);
//Send start condition.
HWREG16(baseAddress + OFS_UCBxCTLW0) |= UCTR + UCTXSTT;
//Poll for transmit interrupt flag.
while(!(HWREG16(baseAddress + OFS_UCBxIFG) & UCTXIFG))
{
;
}
//Send single byte data.
HWREG16(baseAddress + OFS_UCBxTXBUF) = txData;
//Reinstate transmit interrupt enable
HWREG16(baseAddress + OFS_UCBxIE) |= txieStatus;
}
bool EUSCI_B_I2C_masterSendMultiByteStartWithTimeout(uint16_t baseAddress,
uint8_t txData,
uint32_t timeout)
{
//Store current transmit interrupt enable
uint16_t txieStatus = HWREG16(baseAddress + OFS_UCBxIE) & UCTXIE;
//Disable transmit interrupt enable
HWREG16(baseAddress + OFS_UCBxIE) &= ~(UCTXIE);
//Send start condition.
HWREG16(baseAddress + OFS_UCBxCTLW0) |= UCTR + UCTXSTT;
//Poll for transmit interrupt flag.
while((!(HWREG16(baseAddress + OFS_UCBxIFG) & UCTXIFG)) && --timeout)
{
;
}
//Check if transfer timed out
if(timeout == 0)
{
return (STATUS_FAIL);
}
//Send single byte data.
HWREG16(baseAddress + OFS_UCBxTXBUF) = txData;
//Reinstate transmit interrupt enable
HWREG16(baseAddress + OFS_UCBxIE) |= txieStatus;
return(STATUS_SUCCESS);
}
void EUSCI_B_I2C_masterSendMultiByteNext(uint16_t baseAddress,
uint8_t txData)
{
//If interrupts are not used, poll for flags
if(!(HWREG16(baseAddress + OFS_UCBxIE) & UCTXIE))
{
//Poll for transmit interrupt flag.
while(!(HWREG16(baseAddress + OFS_UCBxIFG) & UCTXIFG))
{
;
}
}
//Send single byte data.
HWREG16(baseAddress + OFS_UCBxTXBUF) = txData;
}
bool EUSCI_B_I2C_masterSendMultiByteNextWithTimeout(uint16_t baseAddress,
uint8_t txData,
uint32_t timeout)
{
//If interrupts are not used, poll for flags
if(!(HWREG16(baseAddress + OFS_UCBxIE) & UCTXIE))
{
//Poll for transmit interrupt flag.
while((!(HWREG16(baseAddress + OFS_UCBxIFG) & UCTXIFG)) && --timeout)
{
;
}
//Check if transfer timed out
if(timeout == 0)
{
return (STATUS_FAIL);
}
}
//Send single byte data.
HWREG16(baseAddress + OFS_UCBxTXBUF) = txData;
return(STATUS_SUCCESS);
}
void EUSCI_B_I2C_masterSendMultiByteFinish(uint16_t baseAddress,
uint8_t txData)
{
//If interrupts are not used, poll for flags
if(!(HWREG16(baseAddress + OFS_UCBxIE) & UCTXIE))
{
//Poll for transmit interrupt flag.
while(!(HWREG16(baseAddress + OFS_UCBxIFG) & UCTXIFG))
{
;
}
}
//Send single byte data.
HWREG16(baseAddress + OFS_UCBxTXBUF) = txData;
//Poll for transmit interrupt flag.
while(!(HWREG16(baseAddress + OFS_UCBxIFG) & UCTXIFG))
{
;
}
//Send stop condition.
HWREG16(baseAddress + OFS_UCBxCTLW0) |= UCTXSTP;
}
bool EUSCI_B_I2C_masterSendMultiByteFinishWithTimeout(uint16_t baseAddress,
uint8_t txData,
uint32_t timeout)
{
uint32_t timeout2 = timeout;
//If interrupts are not used, poll for flags
if(!(HWREG16(baseAddress + OFS_UCBxIE) & UCTXIE))
{
//Poll for transmit interrupt flag.
while((!(HWREG16(baseAddress + OFS_UCBxIFG) & UCTXIFG)) && --timeout)
{
;
}
//Check if transfer timed out
if(timeout == 0)
{
return (STATUS_FAIL);
}
}
//Send single byte data.
HWREG16(baseAddress + OFS_UCBxTXBUF) = txData;
//Poll for transmit interrupt flag.
while((!(HWREG16(baseAddress + OFS_UCBxIFG) & UCTXIFG)) && --timeout2)
{
;
}
//Check if transfer timed out
if(timeout2 == 0)
{
return (STATUS_FAIL);
}
//Send stop condition.
HWREG16(baseAddress + OFS_UCBxCTLW0) |= UCTXSTP;
return(STATUS_SUCCESS);
}
void EUSCI_B_I2C_masterSendStart(uint16_t baseAddress)
{
HWREG16(baseAddress + OFS_UCBxCTLW0) |= UCTXSTT;
}
void EUSCI_B_I2C_masterSendMultiByteStop(uint16_t baseAddress)
{
//If interrupts are not used, poll for flags
if(!(HWREG16(baseAddress + OFS_UCBxIE) & UCTXIE))
{
//Poll for transmit interrupt flag.
while(!(HWREG16(baseAddress + OFS_UCBxIFG) & UCTXIFG))
{
;
}
}
//Send stop condition.
HWREG16(baseAddress + OFS_UCBxCTLW0) |= UCTXSTP;
}
bool EUSCI_B_I2C_masterSendMultiByteStopWithTimeout(uint16_t baseAddress,
uint32_t timeout)
{
//If interrupts are not used, poll for flags
if(!(HWREG16(baseAddress + OFS_UCBxIE) & UCTXIE))
{
//Poll for transmit interrupt flag.
while((!(HWREG16(baseAddress + OFS_UCBxIFG) & UCTXIFG)) && --timeout)
{
;
}
//Check if transfer timed out
if(timeout == 0)
{
return (STATUS_FAIL);
}
}
//Send stop condition.
HWREG16(baseAddress + OFS_UCBxCTLW0) |= UCTXSTP;
return (STATUS_SUCCESS);
}
void EUSCI_B_I2C_masterReceiveStart(uint16_t baseAddress)
{
//Set USCI in Receive mode
HWREG16(baseAddress + OFS_UCBxCTLW0) &= ~UCTR;
//Send start
HWREG16(baseAddress + OFS_UCBxCTLW0) |= UCTXSTT;
}
uint8_t EUSCI_B_I2C_masterReceiveMultiByteNext(uint16_t baseAddress)
{
return (HWREG16(baseAddress + OFS_UCBxRXBUF));
}
uint8_t EUSCI_B_I2C_masterReceiveMultiByteFinish(uint16_t baseAddress)
{
//Send stop condition.
HWREG16(baseAddress + OFS_UCBxCTLW0) |= UCTXSTP;
//Wait for Stop to finish
while(HWREG16(baseAddress + OFS_UCBxCTLW0) & UCTXSTP)
{
// Wait for RX buffer
while(!(HWREG16(baseAddress + OFS_UCBxIFG) & UCRXIFG))
{
;
}
}
//Capture data from receive buffer after setting stop bit due to
//MSP430 I2C critical timing.
return (HWREG16(baseAddress + OFS_UCBxRXBUF));
}
bool EUSCI_B_I2C_masterReceiveMultiByteFinishWithTimeout(uint16_t baseAddress,
uint8_t *txData,
uint32_t timeout)
{
uint32_t timeout2 = timeout;
//Send stop condition.
HWREG16(baseAddress + OFS_UCBxCTLW0) |= UCTXSTP;
//Wait for Stop to finish
while((HWREG16(baseAddress + OFS_UCBxCTLW0) & UCTXSTP) && --timeout)
{
;
}
//Check if transfer timed out
if(timeout == 0)
{
return (STATUS_FAIL);
}
// Wait for RX buffer
while((!(HWREG16(baseAddress + OFS_UCBxIFG) & UCRXIFG)) && --timeout2)
{
;
}
//Check if transfer timed out
if(timeout2 == 0)
{
return (STATUS_FAIL);
}
//Capture data from receive buffer after setting stop bit due to
//MSP430 I2C critical timing.
*txData = (HWREG8(baseAddress + OFS_UCBxRXBUF));
return (STATUS_SUCCESS);
}
void EUSCI_B_I2C_masterReceiveMultiByteStop(uint16_t baseAddress)
{
//Send stop condition.
HWREG16(baseAddress + OFS_UCBxCTLW0) |= UCTXSTP;
}
void EUSCI_B_I2C_enableMultiMasterMode(uint16_t baseAddress)
{
HWREG16(baseAddress + OFS_UCBxCTLW0) |= UCSWRST;
HWREG16(baseAddress + OFS_UCBxCTLW0) |= UCMM;
}
void EUSCI_B_I2C_disableMultiMasterMode(uint16_t baseAddress)
{
HWREG16(baseAddress + OFS_UCBxCTLW0) |= UCSWRST;
HWREG16(baseAddress + OFS_UCBxCTLW0) &= ~UCMM;
}
uint8_t EUSCI_B_I2C_masterReceiveSingle(uint16_t baseAddress)
{
//Polling RXIFG0 if RXIE is not enabled
if(!(HWREG16(baseAddress + OFS_UCBxIE) & UCRXIE0))
{
while(!(HWREG16(baseAddress + OFS_UCBxIFG) & UCRXIFG0))
{
;
}
}
//Read a byte.
return (HWREG16(baseAddress + OFS_UCBxRXBUF));
}
uint32_t EUSCI_B_I2C_getReceiveBufferAddress(uint16_t baseAddress)
{
return (baseAddress + OFS_UCBxRXBUF);
}
uint32_t EUSCI_B_I2C_getTransmitBufferAddress(uint16_t baseAddress)
{
return (baseAddress + OFS_UCBxTXBUF);
}
void EUSCI_B_I2C_remapPins(uint16_t baseAddress,
uint8_t pinsSelect)
{
#ifdef USCIBRMP
HWREG16(SYS_BASE + OFS_SYSCFG2) &= ~USCIBRMP;
HWREG16(SYS_BASE + OFS_SYSCFG2) |= pinsSelect << 11;
#endif
}
#endif
//*****************************************************************************
//
//! Close the doxygen group for eusci_b_i2c_api
//! @}
//
//*****************************************************************************

File diff suppressed because it is too large Load Diff

View File

@ -1,228 +0,0 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
//
// eusci_b_spi.c - Driver for the eusci_b_spi Module.
//
//*****************************************************************************
//*****************************************************************************
//
//! \addtogroup eusci_b_spi_api eusci_b_spi
//! @{
//
//*****************************************************************************
#include "inc/hw_memmap.h"
#ifdef __MSP430_HAS_EUSCI_Bx__
#include "eusci_b_spi.h"
#include <assert.h>
void EUSCI_B_SPI_initMaster(uint16_t baseAddress,
EUSCI_B_SPI_initMasterParam *param)
{
//Disable the USCI Module
HWREG16(baseAddress + OFS_UCBxCTLW0) |= UCSWRST;
//Reset OFS_UCBxCTLW0 values
HWREG16(baseAddress + OFS_UCBxCTLW0) &= ~(UCCKPH + UCCKPL + UC7BIT + UCMSB +
UCMST + UCMODE_3 + UCSYNC);
//Reset OFS_UCBxCTLW0 values
HWREG16(baseAddress + OFS_UCBxCTLW0) &= ~(UCSSEL_3);
//Select Clock
HWREG16(baseAddress + OFS_UCBxCTLW0) |= param->selectClockSource;
HWREG16(baseAddress + OFS_UCBxBRW) =
(uint16_t)(param->clockSourceFrequency / param->desiredSpiClock);
/*
* Configure as SPI master mode.
* Clock phase select, polarity, msb
* UCMST = Master mode
* UCSYNC = Synchronous mode
* UCMODE_0 = 3-pin SPI
*/
HWREG16(baseAddress + OFS_UCBxCTLW0) |= (
param->msbFirst +
param->clockPhase +
param->clockPolarity +
UCMST +
UCSYNC +
param->spiMode
);
}
void EUSCI_B_SPI_select4PinFunctionality(uint16_t baseAddress,
uint8_t select4PinFunctionality)
{
HWREG16(baseAddress + OFS_UCBxCTLW0) &= ~UCSTEM;
HWREG16(baseAddress + OFS_UCBxCTLW0) |= select4PinFunctionality;
}
void EUSCI_B_SPI_changeMasterClock(uint16_t baseAddress,
EUSCI_B_SPI_changeMasterClockParam *param)
{
//Disable the USCI Module
HWREG16(baseAddress + OFS_UCBxCTLW0) |= UCSWRST;
HWREG16(baseAddress + OFS_UCBxBRW) =
(uint16_t)(param->clockSourceFrequency / param->desiredSpiClock);
//Reset the UCSWRST bit to enable the USCI Module
HWREG16(baseAddress + OFS_UCBxCTLW0) &= ~(UCSWRST);
}
void EUSCI_B_SPI_initSlave(uint16_t baseAddress,
EUSCI_B_SPI_initSlaveParam *param)
{
//Disable USCI Module
HWREG16(baseAddress + OFS_UCBxCTLW0) |= UCSWRST;
//Reset OFS_UCBxCTLW0 register
HWREG16(baseAddress + OFS_UCBxCTLW0) &= ~(UCMSB +
UC7BIT +
UCMST +
UCCKPL +
UCCKPH +
UCMODE_3
);
//Clock polarity, phase select, msbFirst, SYNC, Mode0
HWREG16(baseAddress + OFS_UCBxCTLW0) |= (param->clockPhase +
param->clockPolarity +
param->msbFirst +
UCSYNC +
param->spiMode
);
}
void EUSCI_B_SPI_changeClockPhasePolarity(uint16_t baseAddress,
uint16_t clockPhase,
uint16_t clockPolarity)
{
//Disable the USCI Module
HWREG16(baseAddress + OFS_UCBxCTLW0) |= UCSWRST;
HWREG16(baseAddress + OFS_UCBxCTLW0) &= ~(UCCKPH + UCCKPL);
HWREG16(baseAddress + OFS_UCBxCTLW0) |= (
clockPhase +
clockPolarity
);
//Reset the UCSWRST bit to enable the USCI Module
HWREG16(baseAddress + OFS_UCBxCTLW0) &= ~(UCSWRST);
}
void EUSCI_B_SPI_transmitData(uint16_t baseAddress,
uint8_t transmitData)
{
HWREG16(baseAddress + OFS_UCBxTXBUF) = transmitData;
}
uint8_t EUSCI_B_SPI_receiveData(uint16_t baseAddress)
{
return (HWREG16(baseAddress + OFS_UCBxRXBUF));
}
void EUSCI_B_SPI_enableInterrupt(uint16_t baseAddress,
uint8_t mask)
{
HWREG16(baseAddress + OFS_UCBxIE) |= mask;
}
void EUSCI_B_SPI_disableInterrupt(uint16_t baseAddress,
uint8_t mask)
{
HWREG16(baseAddress + OFS_UCBxIE) &= ~mask;
}
uint8_t EUSCI_B_SPI_getInterruptStatus(uint16_t baseAddress,
uint8_t mask)
{
return (HWREG16(baseAddress + OFS_UCBxIFG) & mask);
}
void EUSCI_B_SPI_clearInterrupt(uint16_t baseAddress,
uint8_t mask)
{
HWREG16(baseAddress + OFS_UCBxIFG) &= ~mask;
}
void EUSCI_B_SPI_enable(uint16_t baseAddress)
{
//Reset the UCSWRST bit to enable the USCI Module
HWREG16(baseAddress + OFS_UCBxCTLW0) &= ~(UCSWRST);
}
void EUSCI_B_SPI_disable(uint16_t baseAddress)
{
//Set the UCSWRST bit to disable the USCI Module
HWREG16(baseAddress + OFS_UCBxCTLW0) |= UCSWRST;
}
uint32_t EUSCI_B_SPI_getReceiveBufferAddress(uint16_t baseAddress)
{
return (baseAddress + OFS_UCBxRXBUF);
}
uint32_t EUSCI_B_SPI_getTransmitBufferAddress(uint16_t baseAddress)
{
return (baseAddress + OFS_UCBxTXBUF);
}
uint16_t EUSCI_B_SPI_isBusy(uint16_t baseAddress)
{
//Return the bus busy status.
return (HWREG16(baseAddress + OFS_UCBxSTATW) & UCBUSY);
}
void EUSCI_B_SPI_remapPins(uint16_t baseAddress,
uint8_t pinsSelect)
{
#ifdef USCIBRMP
HWREG16(SYS_BASE + OFS_SYSCFG2) &= ~USCIBRMP;
HWREG16(SYS_BASE + OFS_SYSCFG2) |= pinsSelect << 11;
#endif
}
#endif
//*****************************************************************************
//
//! Close the doxygen group for eusci_b_spi_api
//! @}
//
//*****************************************************************************

View File

@ -1,563 +0,0 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
//
// eusci_b_spi.h - Driver for the EUSCI_B_SPI Module.
//
//*****************************************************************************
#ifndef __MSP430WARE_EUSCI_B_SPI_H__
#define __MSP430WARE_EUSCI_B_SPI_H__
#include "inc/hw_memmap.h"
#ifdef __MSP430_HAS_EUSCI_Bx__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
#include "inc/hw_memmap.h"
//*****************************************************************************
//
//! \brief Used in the EUSCI_B_SPI_initMaster() function as the param
//! parameter.
//
//*****************************************************************************
typedef struct EUSCI_B_SPI_initMasterParam
{
//! Selects Clock source. Refer to device specific datasheet for available
//! options.
//! \n Valid values are:
//! - \b EUSCI_B_SPI_CLOCKSOURCE_UCLK
//! - \b EUSCI_B_SPI_CLOCKSOURCE_ACLK
//! - \b EUSCI_B_SPI_CLOCKSOURCE_MODCLK
//! - \b EUSCI_B_SPI_CLOCKSOURCE_SMCLK
uint8_t selectClockSource;
//! Is the frequency of the selected clock source
uint32_t clockSourceFrequency;
//! Is the desired clock rate for SPI communication
uint32_t desiredSpiClock;
//! Controls the direction of the receive and transmit shift register.
//! \n Valid values are:
//! - \b EUSCI_B_SPI_MSB_FIRST
//! - \b EUSCI_B_SPI_LSB_FIRST [Default]
uint16_t msbFirst;
//! Is clock phase select.
//! \n Valid values are:
//! - \b EUSCI_B_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT [Default]
//! - \b EUSCI_B_SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT
uint16_t clockPhase;
//! Is clock polarity select
//! \n Valid values are:
//! - \b EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_HIGH
//! - \b EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_LOW [Default]
uint16_t clockPolarity;
//! Is SPI mode select
//! \n Valid values are:
//! - \b EUSCI_B_SPI_3PIN
//! - \b EUSCI_B_SPI_4PIN_UCxSTE_ACTIVE_HIGH
//! - \b EUSCI_B_SPI_4PIN_UCxSTE_ACTIVE_LOW
uint16_t spiMode;
} EUSCI_B_SPI_initMasterParam;
//*****************************************************************************
//
//! \brief Used in the EUSCI_B_SPI_initSlave() function as the param parameter.
//
//*****************************************************************************
typedef struct EUSCI_B_SPI_initSlaveParam
{
//! Controls the direction of the receive and transmit shift register.
//! \n Valid values are:
//! - \b EUSCI_B_SPI_MSB_FIRST
//! - \b EUSCI_B_SPI_LSB_FIRST [Default]
uint16_t msbFirst;
//! Is clock phase select.
//! \n Valid values are:
//! - \b EUSCI_B_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT [Default]
//! - \b EUSCI_B_SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT
uint16_t clockPhase;
//! Is clock polarity select
//! \n Valid values are:
//! - \b EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_HIGH
//! - \b EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_LOW [Default]
uint16_t clockPolarity;
//! Is SPI mode select
//! \n Valid values are:
//! - \b EUSCI_B_SPI_3PIN
//! - \b EUSCI_B_SPI_4PIN_UCxSTE_ACTIVE_HIGH
//! - \b EUSCI_B_SPI_4PIN_UCxSTE_ACTIVE_LOW
uint16_t spiMode;
} EUSCI_B_SPI_initSlaveParam;
//*****************************************************************************
//
//! \brief Used in the EUSCI_B_SPI_changeMasterClock() function as the param
//! parameter.
//
//*****************************************************************************
typedef struct EUSCI_B_SPI_changeMasterClockParam
{
//! Is the frequency of the selected clock source
uint32_t clockSourceFrequency;
//! Is the desired clock rate for SPI communication
uint32_t desiredSpiClock;
} EUSCI_B_SPI_changeMasterClockParam;
//*****************************************************************************
//
// The following are values that can be passed to the clockPhase parameter for
// functions: EUSCI_B_SPI_changeClockPhasePolarity(); the param parameter for
// functions: EUSCI_B_SPI_initMaster(), and EUSCI_B_SPI_initSlave().
//
//*****************************************************************************
#define EUSCI_B_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT 0x00
#define EUSCI_B_SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT UCCKPH
//*****************************************************************************
//
// The following are values that can be passed to the param parameter for
// functions: EUSCI_B_SPI_initMaster(), and EUSCI_B_SPI_initSlave().
//
//*****************************************************************************
#define EUSCI_B_SPI_MSB_FIRST UCMSB
#define EUSCI_B_SPI_LSB_FIRST 0x00
//*****************************************************************************
//
// The following are values that can be passed to the param parameter for
// functions: EUSCI_B_SPI_initMaster(), and EUSCI_B_SPI_initSlave(); the
// clockPolarity parameter for functions:
// EUSCI_B_SPI_changeClockPhasePolarity().
//
//*****************************************************************************
#define EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_HIGH UCCKPL
#define EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_LOW 0x00
//*****************************************************************************
//
// The following are values that can be passed to the param parameter for
// functions: EUSCI_B_SPI_initMaster().
//
//*****************************************************************************
#define EUSCI_B_SPI_CLOCKSOURCE_UCLK UCSSEL__UCLK
#define EUSCI_B_SPI_CLOCKSOURCE_ACLK 0x40
#define EUSCI_B_SPI_CLOCKSOURCE_MODCLK 0x40
#define EUSCI_B_SPI_CLOCKSOURCE_SMCLK UCSSEL__SMCLK
//*****************************************************************************
//
// The following are values that can be passed to the param parameter for
// functions: EUSCI_B_SPI_initMaster(), and EUSCI_B_SPI_initSlave().
//
//*****************************************************************************
#define EUSCI_B_SPI_3PIN UCMODE_0
#define EUSCI_B_SPI_4PIN_UCxSTE_ACTIVE_HIGH UCMODE_1
#define EUSCI_B_SPI_4PIN_UCxSTE_ACTIVE_LOW UCMODE_2
//*****************************************************************************
//
// The following are values that can be passed to the select4PinFunctionality
// parameter for functions: EUSCI_B_SPI_select4PinFunctionality().
//
//*****************************************************************************
#define EUSCI_B_SPI_PREVENT_CONFLICTS_WITH_OTHER_MASTERS 0x00
#define EUSCI_B_SPI_ENABLE_SIGNAL_FOR_4WIRE_SLAVE UCSTEM
//*****************************************************************************
//
// The following are values that can be passed to the mask parameter for
// functions: EUSCI_B_SPI_enableInterrupt(), EUSCI_B_SPI_disableInterrupt(),
// EUSCI_B_SPI_getInterruptStatus(), and EUSCI_B_SPI_clearInterrupt() as well
// as returned by the EUSCI_B_SPI_getInterruptStatus() function.
//
//*****************************************************************************
#define EUSCI_B_SPI_TRANSMIT_INTERRUPT UCTXIE
#define EUSCI_B_SPI_RECEIVE_INTERRUPT UCRXIE
//*****************************************************************************
//
// The following are values that can be passed toThe following are values that
// can be returned by the EUSCI_B_SPI_isBusy() function.
//
//*****************************************************************************
#define EUSCI_B_SPI_BUSY UCBUSY
#define EUSCI_B_SPI_NOT_BUSY 0x00
//*****************************************************************************
//
// The following are values that can be passed to the pinsSelect parameter for
// functions: EUSCI_B_SPI_remapPins().
//
//*****************************************************************************
#define EUSCI_B_SPI_REMAP_PINS_1 0x00
#define EUSCI_B_SPI_REMAP_PINS_2 0x01
//*****************************************************************************
//
// Prototypes for the APIs.
//
//*****************************************************************************
//*****************************************************************************
//
//! \brief Initializes the SPI Master block.
//!
//! Upon successful initialization of the SPI master block, this function will
//! have set the bus speed for the master, but the SPI Master block still
//! remains disabled and must be enabled with EUSCI_B_SPI_enable()
//!
//! \param baseAddress is the base address of the EUSCI_B_SPI Master module.
//! \param param is the pointer to struct for master initialization.
//!
//! Modified bits are \b UCCKPH, \b UCCKPL, \b UC7BIT, \b UCMSB, \b UCSSELx and
//! \b UCSWRST of \b UCAxCTLW0 register.
//!
//! \return STATUS_SUCCESS
//
//*****************************************************************************
extern void EUSCI_B_SPI_initMaster(uint16_t baseAddress,
EUSCI_B_SPI_initMasterParam *param);
//*****************************************************************************
//
//! \brief Selects 4Pin Functionality
//!
//! This function should be invoked only in 4-wire mode. Invoking this function
//! has no effect in 3-wire mode.
//!
//! \param baseAddress is the base address of the EUSCI_B_SPI module.
//! \param select4PinFunctionality selects 4 pin functionality
//! Valid values are:
//! - \b EUSCI_B_SPI_PREVENT_CONFLICTS_WITH_OTHER_MASTERS
//! - \b EUSCI_B_SPI_ENABLE_SIGNAL_FOR_4WIRE_SLAVE
//!
//! Modified bits are \b UCSTEM of \b UCAxCTLW0 register.
//!
//! \return None
//
//*****************************************************************************
extern void EUSCI_B_SPI_select4PinFunctionality(uint16_t baseAddress,
uint8_t select4PinFunctionality);
//*****************************************************************************
//
//! \brief Initializes the SPI Master clock. At the end of this function call,
//! SPI module is left enabled.
//!
//! \param baseAddress is the base address of the EUSCI_B_SPI module.
//! \param param is the pointer to struct for master clock setting.
//!
//! Modified bits are \b UCSWRST of \b UCAxCTLW0 register.
//!
//! \return None
//
//*****************************************************************************
extern void EUSCI_B_SPI_changeMasterClock(uint16_t baseAddress,
EUSCI_B_SPI_changeMasterClockParam *param);
//*****************************************************************************
//
//! \brief Initializes the SPI Slave block.
//!
//! Upon successful initialization of the SPI slave block, this function will
//! have initialized the slave block, but the SPI Slave block still remains
//! disabled and must be enabled with EUSCI_B_SPI_enable()
//!
//! \param baseAddress is the base address of the EUSCI_B_SPI Slave module.
//! \param param is the pointer to struct for slave initialization.
//!
//! Modified bits are \b UCMSB, \b UCMST, \b UC7BIT, \b UCCKPL, \b UCCKPH, \b
//! UCMODE and \b UCSWRST of \b UCAxCTLW0 register.
//!
//! \return STATUS_SUCCESS
//
//*****************************************************************************
extern void EUSCI_B_SPI_initSlave(uint16_t baseAddress,
EUSCI_B_SPI_initSlaveParam *param);
//*****************************************************************************
//
//! \brief Changes the SPI clock phase and polarity. At the end of this
//! function call, SPI module is left enabled.
//!
//! \param baseAddress is the base address of the EUSCI_B_SPI module.
//! \param clockPhase is clock phase select.
//! Valid values are:
//! - \b EUSCI_B_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT
//! [Default]
//! - \b EUSCI_B_SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT
//! \param clockPolarity is clock polarity select
//! Valid values are:
//! - \b EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_HIGH
//! - \b EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_LOW [Default]
//!
//! Modified bits are \b UCCKPL, \b UCCKPH and \b UCSWRST of \b UCAxCTLW0
//! register.
//!
//! \return None
//
//*****************************************************************************
extern void EUSCI_B_SPI_changeClockPhasePolarity(uint16_t baseAddress,
uint16_t clockPhase,
uint16_t clockPolarity);
//*****************************************************************************
//
//! \brief Transmits a byte from the SPI Module.
//!
//! This function will place the supplied data into SPI transmit data register
//! to start transmission.
//!
//! \param baseAddress is the base address of the EUSCI_B_SPI module.
//! \param transmitData data to be transmitted from the SPI module
//!
//! \return None
//
//*****************************************************************************
extern void EUSCI_B_SPI_transmitData(uint16_t baseAddress,
uint8_t transmitData);
//*****************************************************************************
//
//! \brief Receives a byte that has been sent to the SPI Module.
//!
//! This function reads a byte of data from the SPI receive data Register.
//!
//! \param baseAddress is the base address of the EUSCI_B_SPI module.
//!
//! \return Returns the byte received from by the SPI module, cast as an
//! uint8_t.
//
//*****************************************************************************
extern uint8_t EUSCI_B_SPI_receiveData(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Enables individual SPI interrupt sources.
//!
//! Enables the indicated SPI interrupt sources. Only the sources that are
//! enabled can be reflected to the processor interrupt; disabled sources have
//! no effect on the processor. Does not clear interrupt flags.
//!
//! \param baseAddress is the base address of the EUSCI_B_SPI module.
//! \param mask is the bit mask of the interrupt sources to be enabled.
//! Mask value is the logical OR of any of the following:
//! - \b EUSCI_B_SPI_TRANSMIT_INTERRUPT
//! - \b EUSCI_B_SPI_RECEIVE_INTERRUPT
//!
//! Modified bits of \b UCAxIFG register and bits of \b UCAxIE register.
//!
//! \return None
//
//*****************************************************************************
extern void EUSCI_B_SPI_enableInterrupt(uint16_t baseAddress,
uint8_t mask);
//*****************************************************************************
//
//! \brief Disables individual SPI interrupt sources.
//!
//! Disables the indicated SPI interrupt sources. Only the sources that are
//! enabled can be reflected to the processor interrupt; disabled sources have
//! no effect on the processor.
//!
//! \param baseAddress is the base address of the EUSCI_B_SPI module.
//! \param mask is the bit mask of the interrupt sources to be disabled.
//! Mask value is the logical OR of any of the following:
//! - \b EUSCI_B_SPI_TRANSMIT_INTERRUPT
//! - \b EUSCI_B_SPI_RECEIVE_INTERRUPT
//!
//! Modified bits of \b UCAxIE register.
//!
//! \return None
//
//*****************************************************************************
extern void EUSCI_B_SPI_disableInterrupt(uint16_t baseAddress,
uint8_t mask);
//*****************************************************************************
//
//! \brief Gets the current SPI interrupt status.
//!
//! This returns the interrupt status for the SPI module based on which flag is
//! passed.
//!
//! \param baseAddress is the base address of the EUSCI_B_SPI module.
//! \param mask is the masked interrupt flag status to be returned.
//! Mask value is the logical OR of any of the following:
//! - \b EUSCI_B_SPI_TRANSMIT_INTERRUPT
//! - \b EUSCI_B_SPI_RECEIVE_INTERRUPT
//!
//! \return Logical OR of any of the following:
//! - \b EUSCI_B_SPI_TRANSMIT_INTERRUPT
//! - \b EUSCI_B_SPI_RECEIVE_INTERRUPT
//! \n indicating the status of the masked interrupts
//
//*****************************************************************************
extern uint8_t EUSCI_B_SPI_getInterruptStatus(uint16_t baseAddress,
uint8_t mask);
//*****************************************************************************
//
//! \brief Clears the selected SPI interrupt status flag.
//!
//! \param baseAddress is the base address of the EUSCI_B_SPI module.
//! \param mask is the masked interrupt flag to be cleared.
//! Mask value is the logical OR of any of the following:
//! - \b EUSCI_B_SPI_TRANSMIT_INTERRUPT
//! - \b EUSCI_B_SPI_RECEIVE_INTERRUPT
//!
//! Modified bits of \b UCAxIFG register.
//!
//! \return None
//
//*****************************************************************************
extern void EUSCI_B_SPI_clearInterrupt(uint16_t baseAddress,
uint8_t mask);
//*****************************************************************************
//
//! \brief Enables the SPI block.
//!
//! This will enable operation of the SPI block.
//!
//! \param baseAddress is the base address of the EUSCI_B_SPI module.
//!
//! Modified bits are \b UCSWRST of \b UCAxCTLW0 register.
//!
//! \return None
//
//*****************************************************************************
extern void EUSCI_B_SPI_enable(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Disables the SPI block.
//!
//! This will disable operation of the SPI block.
//!
//! \param baseAddress is the base address of the EUSCI_B_SPI module.
//!
//! Modified bits are \b UCSWRST of \b UCAxCTLW0 register.
//!
//! \return None
//
//*****************************************************************************
extern void EUSCI_B_SPI_disable(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Returns the address of the RX Buffer of the SPI for the DMA module.
//!
//! Returns the address of the SPI RX Buffer. This can be used in conjunction
//! with the DMA to store the received data directly to memory.
//!
//! \param baseAddress is the base address of the EUSCI_B_SPI module.
//!
//! \return the address of the RX Buffer
//
//*****************************************************************************
extern uint32_t EUSCI_B_SPI_getReceiveBufferAddress(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Returns the address of the TX Buffer of the SPI for the DMA module.
//!
//! Returns the address of the SPI TX Buffer. This can be used in conjunction
//! with the DMA to obtain transmitted data directly from memory.
//!
//! \param baseAddress is the base address of the EUSCI_B_SPI module.
//!
//! \return the address of the TX Buffer
//
//*****************************************************************************
extern uint32_t EUSCI_B_SPI_getTransmitBufferAddress(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Indicates whether or not the SPI bus is busy.
//!
//! This function returns an indication of whether or not the SPI bus is
//! busy.This function checks the status of the bus via UCBBUSY bit
//!
//! \param baseAddress is the base address of the EUSCI_B_SPI module.
//!
//! \return One of the following:
//! - \b EUSCI_B_SPI_BUSY
//! - \b EUSCI_B_SPI_NOT_BUSY
//! \n indicating if the EUSCI_B_SPI is busy
//
//*****************************************************************************
extern uint16_t EUSCI_B_SPI_isBusy(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Remaps eUSCI_B GPIO pins.
//!
//! Remaps eUSCI_B GPIO pins. After calling this function,
//! GPIO_setAsPeripheralModuleFunctionInputPin() or
//! GPIO_setAsPeripheralModuleFunctionInputPin() still needs to be invoked to
//! set peripheral functions.
//!
//! \param baseAddress is the base address of the EUSCI_B_SPI module.
//! \param pinsSelect remapping pins to select. Please refer to device specific
//! datasheet for remapping pins details.
//! Valid values are:
//! - \b EUSCI_B_SPI_REMAP_PINS_1 [Default]
//! - \b EUSCI_B_SPI_REMAP_PINS_2
//!
//! \return None
//
//*****************************************************************************
extern void EUSCI_B_SPI_remapPins(uint16_t baseAddress,
uint8_t pinsSelect);
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif
#endif // __MSP430WARE_EUSCI_B_SPI_H__

View File

@ -1,241 +0,0 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
//
// framctl.c - Driver for the framctl Module.
//
//*****************************************************************************
//*****************************************************************************
//
//! \addtogroup framctl_api framctl
//! @{
//
//*****************************************************************************
#include "inc/hw_memmap.h"
#ifdef __MSP430_HAS_FRAM__
#include "framctl.h"
#include <assert.h>
void FRAMCtl_write8(uint8_t *dataPtr,
uint8_t *framPtr,
uint16_t numberOfBytes)
{
//Get previous write protection setting
uint8_t state = HWREG8(SYS_BASE + OFS_SYSCFG0_L);
#ifdef DFWP
uint8_t wp = DFWP | PFWP;
#else
uint8_t wp = PFWP;
#endif
#ifdef FRWPPW
HWREG16(SYS_BASE + OFS_SYSCFG0) = FWPW | (state & ~wp);
#else
HWREG8(SYS_BASE + OFS_SYSCFG0_L) &= ~wp;
#endif
while(numberOfBytes > 0)
{
//Write to Fram
*framPtr++ = *dataPtr++;
numberOfBytes--;
}
//Restore previous write protection setting
#ifdef FRWPPW
HWREG16(SYS_BASE + OFS_SYSCFG0) = FWPW | state;
#else
HWREG8(SYS_BASE + OFS_SYSCFG0_L) = state;
#endif
}
void FRAMCtl_write16(uint16_t *dataPtr,
uint16_t *framPtr,
uint16_t numberOfWords)
{
//Get previous write protection setting
uint8_t state = HWREG8(SYS_BASE + OFS_SYSCFG0_L);
#ifdef DFWP
uint8_t wp = DFWP | PFWP;
#else
uint8_t wp = PFWP;
#endif
#ifdef FRWPPW
HWREG16(SYS_BASE + OFS_SYSCFG0) = FWPW | (state & ~wp);
#else
HWREG8(SYS_BASE + OFS_SYSCFG0_L) &= ~wp;
#endif
while(numberOfWords > 0)
{
//Write to Fram
*framPtr++ = *dataPtr++;
numberOfWords--;
}
//Restore previous write protection setting
#ifdef FRWPPW
HWREG16(SYS_BASE + OFS_SYSCFG0) = FWPW | state;
#else
HWREG8(SYS_BASE + OFS_SYSCFG0_L) = state;
#endif
}
void FRAMCtl_write32(uint32_t *dataPtr,
uint32_t *framPtr,
uint16_t count)
{
//Get previous write protection setting
uint8_t state = HWREG8(SYS_BASE + OFS_SYSCFG0_L);
#ifdef DFWP
uint8_t wp = DFWP | PFWP;
#else
uint8_t wp = PFWP;
#endif
#ifdef FRWPPW
HWREG16(SYS_BASE + OFS_SYSCFG0) = FWPW | (state & ~wp);
#else
HWREG8(SYS_BASE + OFS_SYSCFG0_L) &= ~wp;
#endif
while(count > 0)
{
//Write to Fram
*framPtr++ = *dataPtr++;
count--;
}
//Restore previous write protection setting
#ifdef FRWPPW
HWREG16(SYS_BASE + OFS_SYSCFG0) = FWPW | state;
#else
HWREG8(SYS_BASE + OFS_SYSCFG0_L) = state;
#endif
}
void FRAMCtl_fillMemory32(uint32_t value,
uint32_t *framPtr,
uint16_t count)
{
//Get previous write protection setting
uint8_t state = HWREG8(SYS_BASE + OFS_SYSCFG0_L);
#ifdef DFWP
uint8_t wp = DFWP | PFWP;
#else
uint8_t wp = PFWP;
#endif
#ifdef FRWPPW
HWREG16(SYS_BASE + OFS_SYSCFG0) = FWPW | (state & ~wp);
#else
HWREG8(SYS_BASE + OFS_SYSCFG0_L) &= ~wp;
#endif
while(count > 0)
{
//Write to Fram
*framPtr++ = value;
count--;
}
//Restore previous write protection setting
#ifdef FRWPPW
HWREG16(SYS_BASE + OFS_SYSCFG0) = FWPW | state;
#else
HWREG8(SYS_BASE + OFS_SYSCFG0_L) = state;
#endif
}
void FRAMCtl_enableInterrupt(uint8_t interruptMask)
{
uint8_t waitSelection;
waitSelection = (HWREG8(FRAM_BASE + OFS_FRCTL0) & 0xFF);
// Clear lock in FRAM control registers
HWREG16(FRAM_BASE + OFS_FRCTL0) = FWPW | waitSelection;
// Enable user selected interrupt sources
HWREG16(FRAM_BASE + OFS_GCCTL0) |= interruptMask;
}
uint8_t FRAMCtl_getInterruptStatus(uint16_t interruptFlagMask)
{
return (HWREG16(FRAM_BASE + OFS_GCCTL1) & interruptFlagMask);
}
void FRAMCtl_disableInterrupt(uint16_t interruptMask)
{
uint8_t waitSelection;
waitSelection = (HWREG8(FRAM_BASE + OFS_FRCTL0) & 0xFF);
//Clear lock in FRAM control registers
HWREG16(FRAM_BASE + OFS_FRCTL0) = FWPW | waitSelection;
HWREG16(FRAM_BASE + OFS_GCCTL0) &= ~(interruptMask);
}
void FRAMCtl_configureWaitStateControl(uint8_t waitState)
{
uint8_t tempVariable = HWREG8(FRAM_BASE + OFS_FRCTL0_L);
tempVariable &= ~NWAITS_7;
tempVariable |= waitState;
HWREG16(FRAM_BASE + OFS_FRCTL0) = (FWPW | tempVariable);
}
void FRAMCtl_delayPowerUpFromLPM(uint8_t delayStatus)
{
#ifdef FRLPMPWR
uint8_t waitSelection;
waitSelection = (HWREG8(FRAM_BASE + OFS_FRCTL0) & 0xFF);
// Clear lock in FRAM control registers
HWREG16(FRAM_BASE + OFS_FRCTL0) = FWPW | waitSelection;
HWREG8(FRAM_BASE + OFS_GCCTL0_L) &= ~FRLPMPWR;
HWREG8(FRAM_BASE + OFS_GCCTL0_L) |= delayStatus;
#endif
}
#endif
//*****************************************************************************
//
//! Close the doxygen group for framctl_api
//! @}
//
//*****************************************************************************

View File

@ -1,308 +0,0 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
//
// framctl.h - Driver for the FRAMCTL Module.
//
//*****************************************************************************
#ifndef __MSP430WARE_FRAMCTL_H__
#define __MSP430WARE_FRAMCTL_H__
#include "inc/hw_memmap.h"
#ifdef __MSP430_HAS_FRAM__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
// The following are values that can be passed to the interruptMask parameter
// for functions: FRAMCtl_enableInterrupt(), and FRAMCtl_disableInterrupt().
//
//*****************************************************************************
#define FRAMCTL_PUC_ON_UNCORRECTABLE_BIT UBDRSTEN
#define FRAMCTL_UNCORRECTABLE_BIT_INTERRUPT UBDIE
#define FRAMCTL_CORRECTABLE_BIT_INTERRUPT CBDIE
#define FRAMCTL_ACCESS_TIME_ERROR_INTERRUPT ACCTEIE
//*****************************************************************************
//
// The following are values that can be passed to the interruptFlagMask
// parameter for functions: FRAMCtl_getInterruptStatus() as well as returned by
// the FRAMCtl_getInterruptStatus() function.
//
//*****************************************************************************
#define FRAMCTL_ACCESS_TIME_ERROR_FLAG ACCTEIFG
#define FRAMCTL_UNCORRECTABLE_BIT_FLAG UBDIFG
#define FRAMCTL_CORRECTABLE_BIT_FLAG CBDIFG
//*****************************************************************************
//
// The following are values that can be passed to the waitState parameter for
// functions: FRAMCtl_configureWaitStateControl().
//
//*****************************************************************************
#define FRAMCTL_ACCESS_TIME_CYCLES_0 NWAITS_0
#define FRAMCTL_ACCESS_TIME_CYCLES_1 NWAITS_1
#define FRAMCTL_ACCESS_TIME_CYCLES_2 NWAITS_2
#define FRAMCTL_ACCESS_TIME_CYCLES_3 NWAITS_3
#define FRAMCTL_ACCESS_TIME_CYCLES_4 NWAITS_4
#define FRAMCTL_ACCESS_TIME_CYCLES_5 NWAITS_5
#define FRAMCTL_ACCESS_TIME_CYCLES_6 NWAITS_6
#define FRAMCTL_ACCESS_TIME_CYCLES_7 NWAITS_7
//*****************************************************************************
//
// The following are values that can be passed to the delayStatus parameter for
// functions: FRAMCtl_delayPowerUpFromLPM().
//
//*****************************************************************************
#define FRAMCTL_DELAY_FROM_LPM_ENABLE 0x00
#define FRAMCTL_DELAY_FROM_LPM_DISABLE 0x02
//*****************************************************************************
//
// Prototypes for the APIs.
//
//*****************************************************************************
//*****************************************************************************
//
//! \brief Write data into the fram memory in byte format.
//!
//! \param dataPtr is the pointer to the data to be written
//! \param framPtr is the pointer into which to write the data
//! \param numberOfBytes is the number of bytes to be written
//!
//! \return None
//
//*****************************************************************************
extern void FRAMCtl_write8(uint8_t *dataPtr,
uint8_t *framPtr,
uint16_t numberOfBytes);
//*****************************************************************************
//
//! \brief Write data into the fram memory in word format.
//!
//! \param dataPtr is the pointer to the data to be written
//! \param framPtr is the pointer into which to write the data
//! \param numberOfWords is the number of words to be written
//!
//! \return None
//
//*****************************************************************************
extern void FRAMCtl_write16(uint16_t *dataPtr,
uint16_t *framPtr,
uint16_t numberOfWords);
//*****************************************************************************
//
//! \brief Write data into the fram memory in long format, pass by reference
//!
//! \param dataPtr is the pointer to the data to be written
//! \param framPtr is the pointer into which to write the data
//! \param count is the number of 32 bit words to be written
//!
//! \return None
//
//*****************************************************************************
extern void FRAMCtl_write32(uint32_t *dataPtr,
uint32_t *framPtr,
uint16_t count);
//*****************************************************************************
//
//! \brief Write data into the fram memory in long format, pass by value
//!
//! \param value is the value to written to FRAMCTL memory
//! \param framPtr is the pointer into which to write the data
//! \param count is the number of 32 bit addresses to fill
//!
//! \return None
//
//*****************************************************************************
extern void FRAMCtl_fillMemory32(uint32_t value,
uint32_t *framPtr,
uint16_t count);
//*****************************************************************************
//
//! \brief Enables selected FRAMCtl interrupt sources.
//!
//! Enables the indicated FRAMCtl interrupt sources. Only the sources that are
//! enabled can be reflected to the processor interrupt; disabled sources have
//! no effect on the processor. Does not clear interrupt flags.
//!
//! \param interruptMask is the bit mask of the memory buffer interrupt sources
//! to be disabled.
//! Mask value is the logical OR of any of the following:
//! - \b FRAMCTL_PUC_ON_UNCORRECTABLE_BIT - Enable PUC reset if FRAMCtl
//! uncorrectable bit error detected.
//! - \b FRAMCTL_UNCORRECTABLE_BIT_INTERRUPT - Interrupts when an
//! uncorrectable bit error is detected.
//! - \b FRAMCTL_CORRECTABLE_BIT_INTERRUPT - Interrupts when a
//! correctable bit error is detected.
//! - \b FRAMCTL_ACCESS_TIME_ERROR_INTERRUPT - Interrupts when an access
//! time error occurs.
//!
//! Modified bits of \b GCCTL0 register and bits of \b FRCTL0 register.
//!
//! \return None
//
//*****************************************************************************
extern void FRAMCtl_enableInterrupt(uint8_t interruptMask);
//*****************************************************************************
//
//! \brief Returns the status of the selected FRAMCtl interrupt flags.
//!
//! \param interruptFlagMask is a bit mask of the interrupt flags status to be
//! returned.
//! Mask value is the logical OR of any of the following:
//! - \b FRAMCTL_ACCESS_TIME_ERROR_FLAG - Interrupt flag is set if a
//! wrong setting for NPRECHG and NACCESS is set and FRAMCtl access
//! time is not hold.
//! - \b FRAMCTL_UNCORRECTABLE_BIT_FLAG - Interrupt flag is set if an
//! uncorrectable bit error has been detected in the FRAMCtl memory
//! error detection logic.
//! - \b FRAMCTL_CORRECTABLE_BIT_FLAG - Interrupt flag is set if a
//! correctable bit error has been detected and corrected in the
//! FRAMCtl memory error detection logic.
//!
//! \return Logical OR of any of the following:
//! - \b FRAMCtl_ACCESS_TIME_ERROR_FLAG Interrupt flag is set if a
//! wrong setting for NPRECHG and NACCESS is set and FRAMCtl access
//! time is not hold.
//! - \b FRAMCtl_UNCORRECTABLE_BIT_FLAG Interrupt flag is set if an
//! uncorrectable bit error has been detected in the FRAMCtl memory
//! error detection logic.
//! - \b FRAMCtl_CORRECTABLE_BIT_FLAG Interrupt flag is set if a
//! correctable bit error has been detected and corrected in the
//! FRAMCtl memory error detection logic.
//! \n indicating the status of the masked flags
//
//*****************************************************************************
extern uint8_t FRAMCtl_getInterruptStatus(uint16_t interruptFlagMask);
//*****************************************************************************
//
//! \brief Disables selected FRAMCtl interrupt sources.
//!
//! Disables the indicated FRAMCtl interrupt sources. Only the sources that
//! are enabled can be reflected to the processor interrupt; disabled sources
//! have no effect on the processor.
//!
//! \param interruptMask is the bit mask of the memory buffer interrupt sources
//! to be disabled.
//! Mask value is the logical OR of any of the following:
//! - \b FRAMCTL_PUC_ON_UNCORRECTABLE_BIT - Enable PUC reset if FRAMCtl
//! uncorrectable bit error detected.
//! - \b FRAMCTL_UNCORRECTABLE_BIT_INTERRUPT - Interrupts when an
//! uncorrectable bit error is detected.
//! - \b FRAMCTL_CORRECTABLE_BIT_INTERRUPT - Interrupts when a
//! correctable bit error is detected.
//! - \b FRAMCTL_ACCESS_TIME_ERROR_INTERRUPT - Interrupts when an access
//! time error occurs.
//!
//! \return None
//
//*****************************************************************************
extern void FRAMCtl_disableInterrupt(uint16_t interruptMask);
//*****************************************************************************
//
//! \brief Configures the access time of the FRAMCtl module
//!
//! Configures the access time of the FRAMCtl module.
//!
//! \param waitState defines the number of CPU cycles required for access time
//! defined in the datasheet
//! Valid values are:
//! - \b FRAMCTL_ACCESS_TIME_CYCLES_0
//! - \b FRAMCTL_ACCESS_TIME_CYCLES_1
//! - \b FRAMCTL_ACCESS_TIME_CYCLES_2
//! - \b FRAMCTL_ACCESS_TIME_CYCLES_3
//! - \b FRAMCTL_ACCESS_TIME_CYCLES_4
//! - \b FRAMCTL_ACCESS_TIME_CYCLES_5
//! - \b FRAMCTL_ACCESS_TIME_CYCLES_6
//! - \b FRAMCTL_ACCESS_TIME_CYCLES_7
//!
//! Modified bits are \b NWAITS of \b GCCTL0 register.
//!
//! \return None
//
//*****************************************************************************
extern void FRAMCtl_configureWaitStateControl(uint8_t waitState);
//*****************************************************************************
//
//! \brief Configures when the FRAMCtl module will power up after LPM exit
//!
//! Configures when the FRAMCtl module will power up after LPM exit. The module
//! can either wait until the first FRAMCtl access to power up or power up
//! immediately after leaving LPM. If FRAMCtl power is disabled, a memory
//! access will automatically insert wait states to ensure sufficient timing
//! for the FRAMCtl power-up and access.
//!
//! \param delayStatus chooses if FRAMCTL should power up instantly with LPM
//! exit or to wait until first FRAMCTL access after LPM exit
//! Valid values are:
//! - \b FRAMCTL_DELAY_FROM_LPM_ENABLE
//! - \b FRAMCTL_DELAY_FROM_LPM_DISABLE
//!
//! \return None
//
//*****************************************************************************
extern void FRAMCtl_delayPowerUpFromLPM(uint8_t delayStatus);
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif
#endif // __MSP430WARE_FRAMCTL_H__

View File

@ -1,554 +0,0 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
//
// gpio.c - Driver for the gpio Module.
//
//*****************************************************************************
//*****************************************************************************
//
//! \addtogroup gpio_api gpio
//! @{
//
//*****************************************************************************
#include "inc/hw_memmap.h"
#if defined(__MSP430_HAS_PORT1_R__) || defined(__MSP430_HAS_PORT2_R__) || \
defined(__MSP430_HAS_PORTA_R__)
#include "gpio.h"
#include <assert.h>
static const uint16_t GPIO_PORT_TO_BASE[] = {
0x00,
#if defined(__MSP430_HAS_PORT1_R__)
__MSP430_BASEADDRESS_PORT1_R__,
#elif defined(__MSP430_HAS_PORT1__)
__MSP430_BASEADDRESS_PORT1__,
#else
0xFFFF,
#endif
#if defined(__MSP430_HAS_PORT2_R__)
__MSP430_BASEADDRESS_PORT2_R__,
#elif defined(__MSP430_HAS_PORT2__)
__MSP430_BASEADDRESS_PORT2__,
#else
0xFFFF,
#endif
#if defined(__MSP430_HAS_PORT3_R__)
__MSP430_BASEADDRESS_PORT3_R__,
#elif defined(__MSP430_HAS_PORT3__)
__MSP430_BASEADDRESS_PORT3__,
#else
0xFFFF,
#endif
#if defined(__MSP430_HAS_PORT4_R__)
__MSP430_BASEADDRESS_PORT4_R__,
#elif defined(__MSP430_HAS_PORT4__)
__MSP430_BASEADDRESS_PORT4__,
#else
0xFFFF,
#endif
#if defined(__MSP430_HAS_PORT5_R__)
__MSP430_BASEADDRESS_PORT5_R__,
#elif defined(__MSP430_HAS_PORT5__)
__MSP430_BASEADDRESS_PORT5__,
#else
0xFFFF,
#endif
#if defined(__MSP430_HAS_PORT6_R__)
__MSP430_BASEADDRESS_PORT6_R__,
#elif defined(__MSP430_HAS_PORT6__)
__MSP430_BASEADDRESS_PORT6__,
#else
0xFFFF,
#endif
#if defined(__MSP430_HAS_PORT7_R__)
__MSP430_BASEADDRESS_PORT7_R__,
#elif defined(__MSP430_HAS_PORT7__)
__MSP430_BASEADDRESS_PORT7__,
#else
0xFFFF,
#endif
#if defined(__MSP430_HAS_PORT8_R__)
__MSP430_BASEADDRESS_PORT8_R__,
#elif defined(__MSP430_HAS_PORT8__)
__MSP430_BASEADDRESS_PORT8__,
#else
0xFFFF,
#endif
#if defined(__MSP430_HAS_PORT9_R__)
__MSP430_BASEADDRESS_PORT9_R__,
#elif defined(__MSP430_HAS_PORT9__)
__MSP430_BASEADDRESS_PORT9__,
#else
0xFFFF,
#endif
#if defined(__MSP430_HAS_PORT10_R__)
__MSP430_BASEADDRESS_PORT10_R__,
#elif defined(__MSP430_HAS_PORT10__)
__MSP430_BASEADDRESS_PORT10__,
#else
0xFFFF,
#endif
#if defined(__MSP430_HAS_PORT11_R__)
__MSP430_BASEADDRESS_PORT11_R__,
#elif defined(__MSP430_HAS_PORT11__)
__MSP430_BASEADDRESS_PORT11__,
#else
0xFFFF,
#endif
0xFFFF,
#if defined(__MSP430_HAS_PORTJ_R__)
__MSP430_BASEADDRESS_PORTJ_R__
#elif defined(__MSP430_HAS_PORTJ__)
__MSP430_BASEADDRESS_PORTJ__
#else
0xFFFF
#endif
};
void GPIO_setAsOutputPin(uint8_t selectedPort,
uint16_t selectedPins) {
uint16_t baseAddress = GPIO_PORT_TO_BASE[selectedPort];
#ifndef NDEBUG
if(baseAddress == 0xFFFF)
{
return;
}
#endif
// Shift by 8 if port is even (upper 8-bits)
if((selectedPort & 1) ^ 1)
{
selectedPins <<= 8;
}
#ifdef __MSP430_HAS_PASEL0__
HWREG16(baseAddress + OFS_PASEL0) &= ~selectedPins;
#endif
#ifdef __MSP430_HAS_PASEL1__
HWREG16(baseAddress + OFS_PASEL1) &= ~selectedPins;
#endif
HWREG16(baseAddress + OFS_PADIR) |= selectedPins;
return;
}
void GPIO_setAsInputPin(uint8_t selectedPort,
uint16_t selectedPins) {
uint16_t baseAddress = GPIO_PORT_TO_BASE[selectedPort];
#ifndef NDEBUG
if(baseAddress == 0xFFFF)
{
return;
}
#endif
// Shift by 8 if port is even (upper 8-bits)
if((selectedPort & 1) ^ 1)
{
selectedPins <<= 8;
}
#ifdef __MSP430_HAS_PASEL0__
HWREG16(baseAddress + OFS_PASEL0) &= ~selectedPins;
#endif
#ifdef __MSP430_HAS_PASEL1__
HWREG16(baseAddress + OFS_PASEL1) &= ~selectedPins;
#endif
HWREG16(baseAddress + OFS_PADIR) &= ~selectedPins;
HWREG16(baseAddress + OFS_PAREN) &= ~selectedPins;
}
void GPIO_setAsPeripheralModuleFunctionOutputPin(uint8_t selectedPort,
uint16_t selectedPins
,
uint8_t mode) {
uint16_t baseAddress = GPIO_PORT_TO_BASE[selectedPort];
#ifndef NDEBUG
if(baseAddress == 0xFFFF)
{
return;
}
#endif
// Shift by 8 if port is even (upper 8-bits)
if((selectedPort & 1) ^ 1)
{
selectedPins <<= 8;
}
HWREG16(baseAddress + OFS_PADIR) |= selectedPins;
switch(mode)
{
case GPIO_PRIMARY_MODULE_FUNCTION:
#ifdef __MSP430_HAS_PASEL0__
HWREG16(baseAddress + OFS_PASEL0) |= selectedPins;
#endif
#ifdef __MSP430_HAS_PASEL1__
HWREG16(baseAddress + OFS_PASEL1) &= ~selectedPins;
#endif
break;
case GPIO_SECONDARY_MODULE_FUNCTION:
#ifdef __MSP430_HAS_PASEL0__
HWREG16(baseAddress + OFS_PASEL0) &= ~selectedPins;
#endif
#ifdef __MSP430_HAS_PASEL1__
HWREG16(baseAddress + OFS_PASEL1) |= selectedPins;
#endif
break;
case GPIO_TERNARY_MODULE_FUNCTION:
#ifdef __MSP430_HAS_PASEL0__
HWREG16(baseAddress + OFS_PASEL0) |= selectedPins;
#endif
#ifdef __MSP430_HAS_PASEL1__
HWREG16(baseAddress + OFS_PASEL1) |= selectedPins;
#endif
break;
}
}
void GPIO_setAsPeripheralModuleFunctionInputPin(uint8_t selectedPort,
uint16_t selectedPins
,
uint8_t mode) {
uint16_t baseAddress = GPIO_PORT_TO_BASE[selectedPort];
#ifndef NDEBUG
if(baseAddress == 0xFFFF)
{
return;
}
#endif
// Shift by 8 if port is even (upper 8-bits)
if((selectedPort & 1) ^ 1)
{
selectedPins <<= 8;
}
HWREG16(baseAddress + OFS_PADIR) &= ~selectedPins;
switch(mode)
{
case GPIO_PRIMARY_MODULE_FUNCTION:
#ifdef __MSP430_HAS_PASEL0__
HWREG16(baseAddress + OFS_PASEL0) |= selectedPins;
#endif
#ifdef __MSP430_HAS_PASEL1__
HWREG16(baseAddress + OFS_PASEL1) &= ~selectedPins;
#endif
break;
case GPIO_SECONDARY_MODULE_FUNCTION:
#ifdef __MSP430_HAS_PASEL0__
HWREG16(baseAddress + OFS_PASEL0) &= ~selectedPins;
#endif
#ifdef __MSP430_HAS_PASEL1__
HWREG16(baseAddress + OFS_PASEL1) |= selectedPins;
#endif
break;
case GPIO_TERNARY_MODULE_FUNCTION:
#ifdef __MSP430_HAS_PASEL0__
HWREG16(baseAddress + OFS_PASEL0) |= selectedPins;
#endif
#ifdef __MSP430_HAS_PASEL1__
HWREG16(baseAddress + OFS_PASEL1) |= selectedPins;
#endif
break;
}
}
void GPIO_setOutputHighOnPin(uint8_t selectedPort,
uint16_t selectedPins) {
uint16_t baseAddress = GPIO_PORT_TO_BASE[selectedPort];
#ifndef NDEBUG
if(baseAddress == 0xFFFF)
{
return;
}
#endif
// Shift by 8 if port is even (upper 8-bits)
if((selectedPort & 1) ^ 1)
{
selectedPins <<= 8;
}
HWREG16(baseAddress + OFS_PAOUT) |= selectedPins;
}
void GPIO_setOutputLowOnPin(uint8_t selectedPort,
uint16_t selectedPins) {
uint16_t baseAddress = GPIO_PORT_TO_BASE[selectedPort];
#ifndef NDEBUG
if(baseAddress == 0xFFFF)
{
return;
}
#endif
// Shift by 8 if port is even (upper 8-bits)
if((selectedPort & 1) ^ 1)
{
selectedPins <<= 8;
}
HWREG16(baseAddress + OFS_PAOUT) &= ~selectedPins;
}
void GPIO_toggleOutputOnPin(uint8_t selectedPort,
uint16_t selectedPins) {
uint16_t baseAddress = GPIO_PORT_TO_BASE[selectedPort];
#ifndef NDEBUG
if(baseAddress == 0xFFFF)
{
return;
}
#endif
// Shift by 8 if port is even (upper 8-bits)
if((selectedPort & 1) ^ 1)
{
selectedPins <<= 8;
}
HWREG16(baseAddress + OFS_PAOUT) ^= selectedPins;
}
void GPIO_setAsInputPinWithPullDownResistor(uint8_t selectedPort,
uint16_t selectedPins) {
uint16_t baseAddress = GPIO_PORT_TO_BASE[selectedPort];
#ifndef NDEBUG
if(baseAddress == 0xFFFF)
{
return;
}
#endif
// Shift by 8 if port is even (upper 8-bits)
if((selectedPort & 1) ^ 1)
{
selectedPins <<= 8;
}
#ifdef __MSP430_HAS_PASEL0__
HWREG16(baseAddress + OFS_PASEL0) &= ~selectedPins;
#endif
#ifdef __MSP430_HAS_PASEL1__
HWREG16(baseAddress + OFS_PASEL1) &= ~selectedPins;
#endif
HWREG16(baseAddress + OFS_PADIR) &= ~selectedPins;
HWREG16(baseAddress + OFS_PAREN) |= selectedPins;
HWREG16(baseAddress + OFS_PAOUT) &= ~selectedPins;
}
void GPIO_setAsInputPinWithPullUpResistor(uint8_t selectedPort,
uint16_t selectedPins) {
uint16_t baseAddress = GPIO_PORT_TO_BASE[selectedPort];
#ifndef NDEBUG
if(baseAddress == 0xFFFF)
{
return;
}
#endif
// Shift by 8 if port is even (upper 8-bits)
if((selectedPort & 1) ^ 1)
{
selectedPins <<= 8;
}
#ifdef __MSP430_HAS_PASEL0__
HWREG16(baseAddress + OFS_PASEL0) &= ~selectedPins;
#endif
#ifdef __MSP430_HAS_PASEL1__
HWREG16(baseAddress + OFS_PASEL1) &= ~selectedPins;
#endif
HWREG16(baseAddress + OFS_PADIR) &= ~selectedPins;
HWREG16(baseAddress + OFS_PAREN) |= selectedPins;
HWREG16(baseAddress + OFS_PAOUT) |= selectedPins;
}
uint8_t GPIO_getInputPinValue(uint8_t selectedPort,
uint16_t selectedPins) {
uint16_t baseAddress = GPIO_PORT_TO_BASE[selectedPort];
#ifndef NDEBUG
if(baseAddress == 0xFFFF)
{
return;
}
#endif
// Shift by 8 if port is even (upper 8-bits)
if((selectedPort & 1) ^ 1)
{
selectedPins <<= 8;
}
uint16_t inputPinValue = HWREG16(baseAddress + OFS_PAIN) & (selectedPins);
if(inputPinValue > 0)
{
return (GPIO_INPUT_PIN_HIGH);
}
return (GPIO_INPUT_PIN_LOW);
}
void GPIO_enableInterrupt(uint8_t selectedPort,
uint16_t selectedPins) {
uint16_t baseAddress = GPIO_PORT_TO_BASE[selectedPort];
#ifndef NDEBUG
if(baseAddress == 0xFFFF)
{
return;
}
#endif
// Shift by 8 if port is even (upper 8-bits)
if((selectedPort & 1) ^ 1)
{
selectedPins <<= 8;
}
HWREG16(baseAddress + OFS_PAIE) |= selectedPins;
}
void GPIO_disableInterrupt(uint8_t selectedPort,
uint16_t selectedPins) {
uint16_t baseAddress = GPIO_PORT_TO_BASE[selectedPort];
#ifndef NDEBUG
if(baseAddress == 0xFFFF)
{
return;
}
#endif
// Shift by 8 if port is even (upper 8-bits)
if((selectedPort & 1) ^ 1)
{
selectedPins <<= 8;
}
HWREG16(baseAddress + OFS_PAIE) &= ~selectedPins;
}
uint16_t GPIO_getInterruptStatus(uint8_t selectedPort,
uint16_t selectedPins) {
uint16_t baseAddress = GPIO_PORT_TO_BASE[selectedPort];
#ifndef NDEBUG
if(baseAddress == 0xFFFF)
{
return;
}
#endif
// Shift by 8 if port is even (upper 8-bits)
if((selectedPort & 1) ^ 1)
{
return (HWREG8(baseAddress + OFS_PAIFG_H) & selectedPins);
}
else
{
return (HWREG16(baseAddress + OFS_PAIFG) & selectedPins);
}
}
void GPIO_clearInterrupt(uint8_t selectedPort,
uint16_t selectedPins) {
uint16_t baseAddress = GPIO_PORT_TO_BASE[selectedPort];
#ifndef NDEBUG
if(baseAddress == 0xFFFF)
{
return;
}
#endif
// Shift by 8 if port is even (upper 8-bits)
if((selectedPort & 1) ^ 1)
{
selectedPins <<= 8;
}
HWREG16(baseAddress + OFS_PAIFG) &= ~selectedPins;
}
void GPIO_selectInterruptEdge(uint8_t selectedPort,
uint16_t selectedPins,
uint8_t edgeSelect) {
uint16_t baseAddress = GPIO_PORT_TO_BASE[selectedPort];
#ifndef NDEBUG
if(baseAddress == 0xFFFF)
{
return;
}
#endif
// Shift by 8 if port is even (upper 8-bits)
if((selectedPort & 1) ^ 1)
{
selectedPins <<= 8;
}
if(GPIO_LOW_TO_HIGH_TRANSITION == edgeSelect)
{
HWREG16(baseAddress + OFS_PAIES) &= ~selectedPins;
}
else
{
HWREG16(baseAddress + OFS_PAIES) |= selectedPins;
}
}
#endif
//*****************************************************************************
//
//! Close the doxygen group for gpio_api
//! @}
//
//*****************************************************************************

File diff suppressed because it is too large Load Diff

View File

@ -1,196 +0,0 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
//
// icc.c - Driver for the icc Module.
//
//*****************************************************************************
//*****************************************************************************
//
//! \addtogroup icc_api icc
//! @{
//
//*****************************************************************************
#include "inc/hw_memmap.h"
#ifdef __MSP430_HAS_ICC__
#include "icc.h"
#include <assert.h>
void ICC_enable(void)
{
HWREG16(ICC_BASE + OFS_ICCSC) |= ICCEN;
}
void ICC_disable(void)
{
HWREG16(ICC_BASE + OFS_ICCSC) &= ~ICCEN;
}
void ICC_setInterruptLevel(uint32_t ILSRmask,
uint8_t interruptLevel){
uint32_t mask = 0x1;
uint8_t i;
for(i = 0; i < 8; i++)
{
if(ILSRmask & mask)
{
HWREG16(ICC_BASE + OFS_ICCILSR0) &= ~(0x3 << (i << 1));
HWREG16(ICC_BASE + OFS_ICCILSR0) |= (interruptLevel << (i << 1));
}
mask <<= 1;
}
for(i = 0; i < 8; i++)
{
if(ILSRmask & mask)
{
HWREG16(ICC_BASE + OFS_ICCILSR1) &= ~(0x3 << (i << 1));
HWREG16(ICC_BASE + OFS_ICCILSR1) |= (interruptLevel << (i << 1));
}
mask <<= 1;
}
for(i = 0; i < 8; i++)
{
if(ILSRmask & mask)
{
HWREG16(ICC_BASE + OFS_ICCILSR2) &= ~(0x3 << (i << 1));
HWREG16(ICC_BASE + OFS_ICCILSR2) |= (interruptLevel << (i << 1));
}
mask <<= 1;
}
for(i = 0; i < 8; i++)
{
if(ILSRmask & mask)
{
HWREG16(ICC_BASE + OFS_ICCILSR3) &= ~(0x3 << (i << 1));
HWREG16(ICC_BASE + OFS_ICCILSR3) |= (interruptLevel << (i << 1));
}
mask <<= 1;
}
}
uint8_t ICC_getInterruptLevel(uint32_t interruptSource){
uint32_t mask = 0x1;
uint8_t i;
for(i = 0; i < 8; i++)
{
if(interruptSource & mask)
{
return((HWREG16(ICC_BASE +
OFS_ICCILSR0) & (0x3 << (i << 1))) >> (i << 1));
}
mask <<= 1;
}
for(i = 0; i < 8; i++)
{
if(interruptSource & mask)
{
return((HWREG16(ICC_BASE +
OFS_ICCILSR1) & (0x3 << (i << 1))) >> (i << 1));
}
mask <<= 1;
}
for(i = 0; i < 8; i++)
{
if(interruptSource & mask)
{
return((HWREG16(ICC_BASE +
OFS_ICCILSR2) & (0x3 << (i << 1))) >> (i << 1));
}
mask <<= 1;
}
for(i = 0; i < 8; i++)
{
if(interruptSource & mask)
{
return((HWREG16(ICC_BASE +
OFS_ICCILSR3) & (0x3 << (i << 1))) >> (i << 1));
}
mask <<= 1;
}
//Error code
return(4);
}
bool ICC_isVirtualStackEmpty(void)
{
return((HWREG16(ICC_BASE + OFS_ICCSC) & VSEFLG) ? true : false);
}
bool ICC_isVirtualStackFull(void)
{
return((HWREG16(ICC_BASE + OFS_ICCSC) & VSFFLG) ? true : false);
}
uint8_t ICC_getCurrentICM(void)
{
return (HWREG16(ICC_BASE + OFS_ICCSC) & ICMC);
}
uint8_t ICC_getMVSStackPointer(void)
{
return ((HWREG16(ICC_BASE + OFS_ICCMVS) & MVSSP) >> 8);
}
uint8_t ICC_getICM3(void)
{
return ((HWREG16(ICC_BASE + OFS_ICCMVS) & ICM3) >> 6);
}
uint8_t ICC_getICM2(void)
{
return ((HWREG16(ICC_BASE + OFS_ICCMVS) & ICM2) >> 4);
}
uint8_t ICC_getICM1(void)
{
return ((HWREG16(ICC_BASE + OFS_ICCMVS) & ICM1) >> 2);
}
uint8_t ICC_getICM0(void)
{
return (HWREG16(ICC_BASE + OFS_ICCMVS) & ICM0);
}
#endif
//*****************************************************************************
//
//! Close the doxygen group for icc_api
//! @}
//
//*****************************************************************************

View File

@ -1,393 +0,0 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
//
// icc.h - Driver for the ICC Module.
//
//*****************************************************************************
#ifndef __MSP430WARE_ICC_H__
#define __MSP430WARE_ICC_H__
#include "inc/hw_memmap.h"
#ifdef __MSP430_HAS_ICC__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
// The following are values that can be passed to the ILSRmask parameter for
// functions: ICC_setInterruptLevel(); the interruptSource parameter for
// functions: ICC_getInterruptLevel().
//
//*****************************************************************************
#define ICC_ILSR_P4 0x1
#define ICC_ILSR_P3 0x2
#define ICC_ILSR_P2 0x4
#define ICC_ILSR_P1 0x8
#define ICC_ILSR_SAC3DAC_SAC1DAC 0x10
#define ICC_ILSR_SAC2DAC_SAC0DAC 0x20
#define ICC_ILSR_ECOMP1_ECOMP0 0x40
#define ICC_ILSR_ADC 0x80
#define ICC_ILSR_EUSCI_B1 0x100
#define ICC_ILSR_EUSCI_B0 0x200
#define ICC_ILSR_EUSCI_A1 0x400
#define ICC_ILSR_EUSCI_A0 0x800
#define ICC_ILSR_WDT_INT 0x1000
#define ICC_ILSR_RTC_COUNTER 0x2000
#define ICC_ILSR_TIMER3_B7_14 0x4000
#define ICC_ILSR_TIMER3_B7_15 0x8000
#define ICC_ILSR_TIMER2_B3_16 0x10000
#define ICC_ILSR_TIMER2_B3_17 0x20000
#define ICC_ILSR_TIMER1_B3_18 0x40000
#define ICC_ILSR_TIMER1_B3_19 0x80000
#define ICC_ILSR_TIMER0_B3_20 0x100000
#define ICC_ILSR_TIMER0_B3_21 0x200000
//*****************************************************************************
//
// The following are values that can be passed to the interruptLevel parameter
// for functions: ICC_setInterruptLevel() as well as returned by the
// ICC_getInterruptLevel() function, the ICC_getCurrentICM() function, the
// ICC_getICM3() function, the ICC_getICM2() function, the ICC_getICM1()
// function and the ICC_getICM0() function.
//
//*****************************************************************************
#define ICC_LEVEL_0 0x0
#define ICC_LEVEL_1 0x1
#define ICC_LEVEL_2 0x2
#define ICC_LEVEL_3 0x3
#define ICC_LEVEL_ERROR 0x4
//*****************************************************************************
//
// The following are values that can be passed toThe following are values that
// can be returned by the ICC_getMVSStackPointer() function.
//
//*****************************************************************************
#define ICC_MVS_STACK_EMPTY 0x0
#define ICC_MVS_STACK_ICM0 0x1
#define ICC_MVS_STACK_ICM0_ICM1 0x2
#define ICC_MVS_STACK_ICM0_ICM1_ICM2 0x3
#define ICC_MVS_STACK_FULL 0x4
//*****************************************************************************
//
// Prototypes for the APIs.
//
//*****************************************************************************
//*****************************************************************************
//
//! \brief Enables ICC module
//!
//! This function enables ICC.
//!
//!
//! \return None
//
//*****************************************************************************
extern void ICC_enable(void);
//*****************************************************************************
//
//! \brief Disables ICC module
//!
//! This function disables ICC.
//!
//!
//! \return None
//
//*****************************************************************************
extern void ICC_disable(void);
//*****************************************************************************
//
//! \brief Sets ICC interrupt level for selected source
//!
//! This function sets ICC interrupt level given a maskable interrupt source.
//!
//! \param ILSRmask is a 32-bit unsigned integer in which bit position (31 to
//! 0) determines which interrupt source is set.
//! Mask value is the logical OR of any of the following:
//! - \b ICC_ILSR_P4
//! - \b ICC_ILSR_P3
//! - \b ICC_ILSR_P2
//! - \b ICC_ILSR_P1
//! - \b ICC_ILSR_SAC3DAC_SAC1DAC
//! - \b ICC_ILSR_SAC2DAC_SAC0DAC
//! - \b ICC_ILSR_ECOMP1_ECOMP0
//! - \b ICC_ILSR_ADC
//! - \b ICC_ILSR_EUSCI_B1
//! - \b ICC_ILSR_EUSCI_B0
//! - \b ICC_ILSR_EUSCI_A1
//! - \b ICC_ILSR_EUSCI_A0
//! - \b ICC_ILSR_WDT_INT
//! - \b ICC_ILSR_RTC_COUNTER
//! - \b ICC_ILSR_TIMER3_B7_14
//! - \b ICC_ILSR_TIMER3_B7_15
//! - \b ICC_ILSR_TIMER2_B3_16
//! - \b ICC_ILSR_TIMER2_B3_17
//! - \b ICC_ILSR_TIMER1_B3_18
//! - \b ICC_ILSR_TIMER1_B3_19
//! - \b ICC_ILSR_TIMER0_B3_20
//! - \b ICC_ILSR_TIMER0_B3_21
//! \param interruptLevel determines what interrupt level to set to.
//! Valid values are:
//! - \b ICC_LEVEL_0
//! - \b ICC_LEVEL_1
//! - \b ICC_LEVEL_2
//! - \b ICC_LEVEL_3
//! - \b ICC_LEVEL_ERROR
//!
//! \return None
//
//*****************************************************************************
extern void ICC_setInterruptLevel(uint32_t ILSRmask,
uint8_t interruptLevel);
//*****************************************************************************
//
//! \brief Gets ICC interrupt level for selected source
//!
//! This function gets ICC interrupt level given a maskable interrupt source.
//!
//! \param interruptSource is a 32-bit unsigned integer in which bit position
//! (31 to 0) determines which interrupt source to read level from.
//! Valid values are:
//! - \b ICC_ILSR_P4
//! - \b ICC_ILSR_P3
//! - \b ICC_ILSR_P2
//! - \b ICC_ILSR_P1
//! - \b ICC_ILSR_SAC3DAC_SAC1DAC
//! - \b ICC_ILSR_SAC2DAC_SAC0DAC
//! - \b ICC_ILSR_ECOMP1_ECOMP0
//! - \b ICC_ILSR_ADC
//! - \b ICC_ILSR_EUSCI_B1
//! - \b ICC_ILSR_EUSCI_B0
//! - \b ICC_ILSR_EUSCI_A1
//! - \b ICC_ILSR_EUSCI_A0
//! - \b ICC_ILSR_WDT_INT
//! - \b ICC_ILSR_RTC_COUNTER
//! - \b ICC_ILSR_TIMER3_B7_14
//! - \b ICC_ILSR_TIMER3_B7_15
//! - \b ICC_ILSR_TIMER2_B3_16
//! - \b ICC_ILSR_TIMER2_B3_17
//! - \b ICC_ILSR_TIMER1_B3_18
//! - \b ICC_ILSR_TIMER1_B3_19
//! - \b ICC_ILSR_TIMER0_B3_20
//! - \b ICC_ILSR_TIMER0_B3_21
//!
//! \return Interrupt level of a given maskable interrupt source.
//! Return one of the following:
//! - \b ICC_LEVEL_0
//! - \b ICC_LEVEL_1
//! - \b ICC_LEVEL_2
//! - \b ICC_LEVEL_3
//! - \b ICC_LEVEL_ERROR
//! \n returns interrupt level of given interrupt source.
//
//*****************************************************************************
extern uint8_t ICC_getInterruptLevel(uint32_t interruptSource);
//*****************************************************************************
//
//! \brief Returns true if virtual stack is empty, false if not
//!
//! This function returns true(1) if virtual stack is empty, false(0) if not.
//!
//!
//! \return 1 if virtual stack is empty, 0 if not
//
//*****************************************************************************
extern bool ICC_isVirtualStackEmpty(void);
//*****************************************************************************
//
//! \brief Returns true if virtual stack is full, false if not
//!
//! This function returns true(1) if virtual stack is full, false(0) if not.
//!
//!
//! \return 1 if virtual stack is full, 0 if not
//
//*****************************************************************************
extern bool ICC_isVirtualStackFull(void);
//*****************************************************************************
//
//! \brief Gets the current interrupt compare mask
//!
//! Returns a 2-bit value that specifies the minimum interrupt priority level
//! that will be sent for service. If ICM[1:0] is less than the priority level
//! (ILSRx[1:0]) of the new interrupt, the corresponding source is sent to the
//! CPU. Note that the ICMC is the element stack that the stack pointer is
//! pointing to.
//!
//!
//! \return Minimum ICC interrupt priority level that will be serviced.
//! Return one of the following:
//! - \b ICC_LEVEL_0
//! - \b ICC_LEVEL_1
//! - \b ICC_LEVEL_2
//! - \b ICC_LEVEL_3
//! - \b ICC_LEVEL_ERROR
//! \n returns minimum interrupt level.
//
//*****************************************************************************
extern uint8_t ICC_getCurrentICM(void);
//*****************************************************************************
//
//! \brief Gets the ICC Mask Virtual Stack stack pointer
//!
//! Returns the stack pointer of the ICC Mask Virtual Stack.
//!
//!
//! \return 0 if stack is empty, 1 if ICM0 occupied, 2 if ICM0/ICM1, 3 if
//! ICM0/ICM1/ICM2, 4 if full.
//! Return one of the following:
//! - \b ICC_MVS_STACK_EMPTY
//! - \b ICC_MVS_STACK_ICM0
//! - \b ICC_MVS_STACK_ICM0_ICM1
//! - \b ICC_MVS_STACK_ICM0_ICM1_ICM2
//! - \b ICC_MVS_STACK_FULL
//! \n Determines how full MVS stack is
//
//*****************************************************************************
extern uint8_t ICC_getMVSStackPointer(void);
//*****************************************************************************
//
//! \brief Gets the interrupt level at Interrupt compare mask virtual stack
//! position 3
//!
//! Returns interrupt level of ICM virtual stack position 3 as a ready-to-read
//! 8-bit integer value (automatically adjusted from original bit position.)
//!
//!
//! \return Interrupt level of ICM virtual stack position 3.
//! Return one of the following:
//! - \b ICC_LEVEL_0
//! - \b ICC_LEVEL_1
//! - \b ICC_LEVEL_2
//! - \b ICC_LEVEL_3
//! - \b ICC_LEVEL_ERROR
//! \n returns interrupt level of ICM virtual stack position 3.
//
//*****************************************************************************
extern uint8_t ICC_getICM3(void);
//*****************************************************************************
//
//! \brief Gets the interrupt level at Interrupt compare mask virtual stack
//! position 2
//!
//! Returns interrupt level of ICM virtual stack position 2 as a ready-to-read
//! 8-bit integer value (automatically adjusted from original bit position.)
//!
//!
//! \return Interrupt level of ICM virtual stack position 2.
//! Return one of the following:
//! - \b ICC_LEVEL_0
//! - \b ICC_LEVEL_1
//! - \b ICC_LEVEL_2
//! - \b ICC_LEVEL_3
//! - \b ICC_LEVEL_ERROR
//! \n returns interrupt level of ICM virtual stack position 2.
//
//*****************************************************************************
extern uint8_t ICC_getICM2(void);
//*****************************************************************************
//
//! \brief Gets the interrupt level at Interrupt compare mask virtual stack
//! position 1
//!
//! Returns interrupt level of ICM virtual stack position 1 as a ready-to-read
//! 8-bit integer value (automatically adjusted from original bit position.)
//!
//!
//! \return Interrupt level of ICM virtual stack position 1.
//! Return one of the following:
//! - \b ICC_LEVEL_0
//! - \b ICC_LEVEL_1
//! - \b ICC_LEVEL_2
//! - \b ICC_LEVEL_3
//! - \b ICC_LEVEL_ERROR
//! \n returns interrupt level of ICM virtual stack position 1.
//
//*****************************************************************************
extern uint8_t ICC_getICM1(void);
//*****************************************************************************
//
//! \brief Gets the interrupt level at Interrupt compare mask virtual stack
//! position 0
//!
//! Returns interrupt level of ICM virtual stack position 0 as a ready-to-read
//! 8-bit integer value (automatically adjusted from original bit position.)
//!
//!
//! \return Interrupt level of ICM virtual stack position 0.
//! Return one of the following:
//! - \b ICC_LEVEL_0
//! - \b ICC_LEVEL_1
//! - \b ICC_LEVEL_2
//! - \b ICC_LEVEL_3
//! - \b ICC_LEVEL_ERROR
//! \n returns interrupt level of ICM virtual stack position 0.
//
//*****************************************************************************
extern uint8_t ICC_getICM0(void);
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif
#endif // __MSP430WARE_ICC_H__

View File

@ -1,85 +0,0 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
#ifndef __HW_MEMMAP__
#define __HW_MEMMAP__
#define __DRIVERLIB_MSP430FR2XX_4XX_FAMILY__
//*****************************************************************************
//
// Include device specific header file
//
//*****************************************************************************
#include <msp430.h>
#ifndef __AUTOGENERATED__
#include "msp430fr2xx_4xxgeneric.h"
#endif
#ifndef ADCRES_1
#define ADCRES_1 (0x0010) /* 10 bit */
#endif
#ifndef ADCCONSEQ
#define ADCCONSEQ (0x0006) /* conversion sequence mode select */
#endif
#include "stdint.h"
#include "stdbool.h"
//*****************************************************************************
//
// SUCCESS and FAILURE for API return value
//
//*****************************************************************************
#define STATUS_SUCCESS 0x01
#define STATUS_FAIL 0x00
//*****************************************************************************
//
// Macro for enabling assert statements for debugging
//
//*****************************************************************************
#define NDEBUG
//*****************************************************************************
//
// Macros for hardware access
//
//*****************************************************************************
#define HWREG32(x) \
(*((volatile uint32_t *)((uint16_t)x)))
#define HWREG16(x) \
(*((volatile uint16_t *)((uint16_t)x)))
#define HWREG8(x) \
(*((volatile uint8_t *)((uint16_t)x)))
#endif // #ifndef __HW_MEMMAP__

View File

@ -1,470 +0,0 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
//
// lcd_e.c - Driver for the lcd_e Module.
//
//*****************************************************************************
//*****************************************************************************
//
//! \addtogroup lcd_e_api lcd_e
//! @{
//
//*****************************************************************************
#include "inc/hw_memmap.h"
#ifdef __MSP430_HAS_LCD_E__
#include "lcd_e.h"
#include <assert.h>
//*****************************************************************************
//
//! Initialization parameter instance
//!
//! \param clockSource selects the clock that will be used by the LCD_E.
//! Valid values are:
//! - \b LCD_E_CLOCKSOURCE_XTCLK [Default] - The external
//! oscillator clock.
//! - \b LCD_E_CLOCKSOURCE_ACLK - The Auxilary Clock.
//! - \b LCD_E_CLOCKSOURCE_VLOCLK - The internal low power and low
//! frequency clock.
//! \n Modified bits are \b LCDSSEL of \b LCDCTL0 register.
//! \param clockDivider selects the divider for LCD_E frequency.
//! Valid values are:
//! - \b LCD_E_CLOCKDIVIDER_1 [Default]
//! - \b LCD_E_CLOCKDIVIDER_2
//! - \b LCD_E_CLOCKDIVIDER_3
//! - \b LCD_E_CLOCKDIVIDER_4
//! - \b LCD_E_CLOCKDIVIDER_5
//! - \b LCD_E_CLOCKDIVIDER_6
//! - \b LCD_E_CLOCKDIVIDER_7
//! - \b LCD_E_CLOCKDIVIDER_8
//! - \b LCD_E_CLOCKDIVIDER_9
//! - \b LCD_E_CLOCKDIVIDER_10
//! - \b LCD_E_CLOCKDIVIDER_11
//! - \b LCD_E_CLOCKDIVIDER_12
//! - \b LCD_E_CLOCKDIVIDER_13
//! - \b LCD_E_CLOCKDIVIDER_14
//! - \b LCD_E_CLOCKDIVIDER_15
//! - \b LCD_E_CLOCKDIVIDER_16
//! - \b LCD_E_CLOCKDIVIDER_17
//! - \b LCD_E_CLOCKDIVIDER_18
//! - \b LCD_E_CLOCKDIVIDER_19
//! - \b LCD_E_CLOCKDIVIDER_20
//! - \b LCD_E_CLOCKDIVIDER_21
//! - \b LCD_E_CLOCKDIVIDER_22
//! - \b LCD_E_CLOCKDIVIDER_23
//! - \b LCD_E_CLOCKDIVIDER_24
//! - \b LCD_E_CLOCKDIVIDER_25
//! - \b LCD_E_CLOCKDIVIDER_26
//! - \b LCD_E_CLOCKDIVIDER_27
//! - \b LCD_E_CLOCKDIVIDER_28
//! - \b LCD_E_CLOCKDIVIDER_29
//! - \b LCD_E_CLOCKDIVIDER_30
//! - \b LCD_E_CLOCKDIVIDER_31
//! - \b LCD_E_CLOCKDIVIDER_32
//! \n Modified bits are \b LCDDIVx of \b LCDCTL0 register.
//! \param muxRate selects LCD_E mux rate.
//! Valid values are:
//! - \b LCD_E_STATIC [Default]
//! - \b LCD_E_2_MUX
//! - \b LCD_E_3_MUX
//! - \b LCD_E_4_MUX
//! - \b LCD_E_5_MUX
//! - \b LCD_E_6_MUX
//! - \b LCD_E_7_MUX
//! - \b LCD_E_8_MUX
//! \n Modified bits are \b LCDMXx of \b LCDCTL0 register.
//! \param waveforms selects LCD_E waveform mode.
//! Valid values are:
//! - \b LCD_E_STANDARD_WAVEFORMS [Default]
//! - \b LCD_E_LOW_POWER_WAVEFORMS
//! \n Modified bits are \b LCDLP of \b LCDCTL0 register.
//! \param segments sets LCD_E segment on/off.
//! Valid values are:
//! - \b LCD_E_SEGMENTS_DISABLED [Default]
//! - \b LCD_E_SEGMENTS_ENABLED
//! \n Modified bits are \b LCDSON of \b LCDCTL0 register.
//
//*****************************************************************************
const LCD_E_initParam LCD_E_INIT_PARAM = {
LCD_E_CLOCKSOURCE_XTCLK,
LCD_E_CLOCKDIVIDER_1,
LCD_E_STATIC,
LCD_E_STANDARD_WAVEFORMS,
LCD_E_SEGMENTS_DISABLED
};
static void setLCDFunction(uint16_t baseAddress,
uint8_t index,
uint16_t value)
{
switch(index)
{
case 0:
HWREG16(baseAddress + OFS_LCDPCTL0) |= value;
break;
case 1:
HWREG16(baseAddress + OFS_LCDPCTL1) |= value;
break;
case 2:
HWREG16(baseAddress + OFS_LCDPCTL2) |= value;
break;
default: break;
}
}
void LCD_E_init(uint16_t baseAddress,
LCD_E_initParam *initParams)
{
HWREG16(baseAddress + OFS_LCDCTL0) &= ~LCDON;
HWREG16(baseAddress + OFS_LCDCTL0) &= ~(LCDMX0 | LCDMX1 | LCDMX2 | LCDSSEL_3
| LCDLP | LCDSON | LCDDIV_31);
HWREG16(baseAddress + OFS_LCDCTL0) |= initParams->muxRate;
HWREG16(baseAddress + OFS_LCDCTL0) |= initParams->clockSource;
HWREG16(baseAddress + OFS_LCDCTL0) |= initParams->waveforms;
HWREG16(baseAddress + OFS_LCDCTL0) |= initParams->segments;
HWREG16(baseAddress + OFS_LCDCTL0) |= initParams->clockDivider;
}
void LCD_E_on(uint16_t baseAddress)
{
HWREG16(SYS_BASE + OFS_SYSCFG2) |= LCDPCTL;
HWREG16(baseAddress + OFS_LCDCTL0) |= LCDON;
}
void LCD_E_off(uint16_t baseAddress)
{
HWREG16(SYS_BASE + OFS_SYSCFG2) &= ~LCDPCTL;
HWREG16(baseAddress + OFS_LCDCTL0) &= ~LCDON;
}
void LCD_E_clearInterrupt(uint16_t baseAddress,
uint16_t mask)
{
HWREG8(baseAddress + OFS_LCDCTL1_L) &= ~(mask >> 8);
}
uint16_t LCD_E_getInterruptStatus(uint16_t baseAddress,
uint16_t mask)
{
return (HWREG8(baseAddress + OFS_LCDCTL1_L) & (mask >> 8));
}
void LCD_E_enableInterrupt(uint16_t baseAddress,
uint16_t mask)
{
HWREG16(baseAddress + OFS_LCDCTL1) |= mask;
}
void LCD_E_disableInterrupt(uint16_t baseAddress,
uint16_t mask)
{
HWREG16(baseAddress + OFS_LCDCTL1) &= ~mask;
}
void LCD_E_clearAllMemory(uint16_t baseAddress)
{
HWREG16(baseAddress + OFS_LCDMEMCTL) |= LCDCLRM;
}
void LCD_E_clearAllBlinkingMemory(uint16_t baseAddress)
{
HWREG16(baseAddress + OFS_LCDMEMCTL) |= LCDCLRBM;
}
void LCD_E_selectDisplayMemory(uint16_t baseAddress,
uint16_t displayMemory)
{
HWREG16(baseAddress + OFS_LCDMEMCTL) &= ~LCDDISP;
HWREG16(baseAddress + OFS_LCDMEMCTL) |= displayMemory;
}
void LCD_E_setBlinkingControl(uint16_t baseAddress,
uint16_t clockPrescalar,
uint16_t mode)
{
HWREG16(baseAddress + OFS_LCDBLKCTL) &=
~(LCDBLKPRE2 | LCDBLKPRE1 | LCDBLKPRE0 | LCDBLKMOD_3);
HWREG16(baseAddress + OFS_LCDBLKCTL) |= (clockPrescalar | mode);
}
void LCD_E_enableChargePump(uint16_t baseAddress)
{
HWREG16(baseAddress + OFS_LCDVCTL) |= LCDCPEN;
}
void LCD_E_disableChargePump(uint16_t baseAddress)
{
HWREG16(baseAddress + OFS_LCDVCTL) &= ~LCDCPEN;
}
void LCD_E_setChargePumpFreq(uint16_t baseAddress,
uint16_t freq)
{
HWREG16(baseAddress + OFS_LCDVCTL) &=
~(LCDCPFSEL3 | LCDCPFSEL2 | LCDCPFSEL1 | LCDCPFSEL0);
HWREG16(baseAddress + OFS_LCDVCTL) |= freq;
}
void LCD_E_setVLCDSource(uint16_t baseAddress,
uint16_t r13Source,
uint16_t r33Source)
{
HWREG16(baseAddress + OFS_LCDVCTL) &= ~(LCDREFMODE | LCDSELVDD);
HWREG16(baseAddress + OFS_LCDVCTL) |= (r13Source | r33Source);
}
void LCD_E_setVLCDVoltage(uint16_t baseAddress,
uint16_t voltage)
{
HWREG16(baseAddress + OFS_LCDVCTL) &= ~(VLCD3 | VLCD2 | VLCD1 | VLCD0);
HWREG16(baseAddress + OFS_LCDVCTL) |= voltage;
}
void LCD_E_setReferenceMode(uint16_t baseAddress,
uint16_t mode)
{
HWREG16(baseAddress + OFS_LCDVCTL) &= ~(LCDREFMODE);
HWREG16(baseAddress + OFS_LCDVCTL) |= mode;
}
void LCD_E_setPinAsLCDFunction(uint16_t baseAddress,
uint8_t pin)
{
HWREG16(baseAddress + OFS_LCDCTL0) &= ~LCDON;
uint8_t idx = pin >> 4;
uint16_t val = 1 << (pin & 0xF);
setLCDFunction(baseAddress, idx, val);
}
void LCD_E_setPinAsPortFunction(uint16_t baseAddress,
uint8_t pin)
{
HWREG16(baseAddress + OFS_LCDCTL0) &= ~LCDON;
uint8_t idx = pin >> 4;
uint16_t val = 1 << (pin & 0xF);
switch(idx)
{
case 0:
HWREG16(baseAddress + OFS_LCDPCTL0) &= ~val;
break;
case 1:
HWREG16(baseAddress + OFS_LCDPCTL1) &= ~val;
break;
case 2:
HWREG16(baseAddress + OFS_LCDPCTL2) &= ~val;
break;
default: break;
}
}
void LCD_E_setPinAsLCDFunctionEx(uint16_t baseAddress,
uint8_t startPin,
uint8_t endPin)
{
uint8_t startIdx = startPin >> 4;
uint8_t endIdx = endPin >> 4;
uint8_t startPos = startPin & 0xF;
uint8_t endPos = endPin & 0xF;
uint16_t val = 0;
uint8_t i = 0;
HWREG16(baseAddress + OFS_LCDCTL0) &= ~LCDON;
if(startIdx == endIdx)
{
val = (0xFFFF >> (15 - endPos)) & (0xFFFF << startPos);
setLCDFunction(baseAddress, startIdx, val);
}
else
{
val = 0xFFFF >> (15 - endPos);
setLCDFunction(baseAddress, endIdx, val);
for(i = endIdx - 1; i > startIdx; i--)
{
setLCDFunction(baseAddress, i, 0xFFFF);
}
val = 0xFFFF << startPos;
setLCDFunction(baseAddress, startIdx, val);
}
}
void LCD_E_setPinAsCOM(uint16_t baseAddress,
uint8_t pin,
uint8_t com)
{
HWREG16(baseAddress + OFS_LCDCTL0) &= ~LCDON;
uint8_t idx = pin >> 4;
uint16_t val = 1 << (pin & 0xF);
uint8_t muxRate =
HWREG16(baseAddress + OFS_LCDCTL0) & (LCDMX2 | LCDMX1 | LCDMX0);
switch(idx)
{
case 0:
HWREG16(baseAddress + OFS_LCDCSSEL0) |= val;
break;
case 1:
HWREG16(baseAddress + OFS_LCDCSSEL1) |= val;
break;
case 2:
HWREG16(baseAddress + OFS_LCDCSSEL2) |= val;
break;
default: break;
}
// Set LCDMem to COM as well for corresponding pins
if(muxRate <= (LCDMX1 | LCDMX0))
{
if(pin & 1)
{
HWREG8(baseAddress + OFS_LCDM0W + pin / 2) |= (com & 0xF) << 4;
HWREG8(baseAddress + OFS_LCDBM0W + pin / 2) |= (com & 0xF) << 4;
}
else
{
HWREG8(baseAddress + OFS_LCDM0W + pin / 2) |= (com & 0xF);
HWREG8(baseAddress + OFS_LCDBM0W + pin / 2) |= (com & 0xF);
}
}
else
{
//5-mux, 6-mux, 7-mux, 8-mux
HWREG8(baseAddress + OFS_LCDM0W + pin) |= com;
HWREG8(baseAddress + OFS_LCDBM0W + pin) |= com;
}
}
void LCD_E_setPinAsSEG(uint16_t baseAddress,
uint8_t pin)
{
// Set LCDMem to COM as well for corresponding pins
HWREG16(baseAddress + OFS_LCDCTL0) &= ~LCDON;
uint8_t idx = pin >> 4;
uint16_t val = 1 << (pin & 0xF);
switch(idx)
{
case 0:
HWREG16(baseAddress + OFS_LCDCSSEL0) &= ~val;
break;
case 1:
HWREG16(baseAddress + OFS_LCDCSSEL1) &= ~val;
break;
case 2:
HWREG16(baseAddress + OFS_LCDCSSEL2) &= ~val;
break;
default: break;
}
}
void LCD_E_setMemory(uint16_t baseAddress,
uint8_t memory,
uint8_t mask)
{
HWREG8(baseAddress + OFS_LCDM0W + memory) = mask;
}
void LCD_E_updateMemory(uint16_t baseAddress,
uint8_t memory,
uint8_t mask)
{
HWREG8(baseAddress + OFS_LCDM0W + memory) |= mask;
}
void LCD_E_toggleMemory(uint16_t baseAddress,
uint8_t memory,
uint8_t mask)
{
HWREG8(baseAddress + OFS_LCDM0W + memory) ^= mask;
}
void LCD_E_clearMemory(uint16_t baseAddress,
uint8_t memory,
uint8_t mask)
{
HWREG8(baseAddress + OFS_LCDM0W + memory) &= ~mask;
}
void LCD_E_setBlinkingMemory(uint16_t baseAddress,
uint8_t memory,
uint8_t mask)
{
HWREG8(baseAddress + OFS_LCDBM0W + memory) = mask;
}
void LCD_E_updateBlinkingMemory(uint16_t baseAddress,
uint8_t memory,
uint8_t mask)
{
HWREG8(baseAddress + OFS_LCDBM0W + memory) |= mask;
}
void LCD_E_toggleBlinkingMemory(uint16_t baseAddress,
uint8_t memory,
uint8_t mask)
{
HWREG8(baseAddress + OFS_LCDBM0W + memory) ^= mask;
}
void LCD_E_clearBlinkingMemory(uint16_t baseAddress,
uint8_t memory,
uint8_t mask)
{
HWREG8(baseAddress + OFS_LCDBM0W + memory) &= ~mask;
}
#endif
//*****************************************************************************
//
//! Close the doxygen group for lcd_e_api
//! @}
//
//*****************************************************************************

File diff suppressed because it is too large Load Diff

View File

@ -1,178 +0,0 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
//
// mpy32.c - Driver for the mpy32 Module.
//
//*****************************************************************************
//*****************************************************************************
//
//! \addtogroup mpy32_api mpy32
//! @{
//
//*****************************************************************************
#include "inc/hw_memmap.h"
#ifdef __MSP430_HAS_MPY32__
#include "mpy32.h"
#include <assert.h>
void MPY32_setWriteDelay(uint16_t writeDelaySelect)
{
HWREG16(MPY32_BASE + OFS_MPY32CTL0) &= ~(MPYDLY32 + MPYDLYWRTEN);
HWREG16(MPY32_BASE + OFS_MPY32CTL0) |= writeDelaySelect;
}
void MPY32_enableSaturationMode(void)
{
HWREG8(MPY32_BASE + OFS_MPY32CTL0_L) |= MPYSAT;
}
void MPY32_disableSaturationMode(void)
{
HWREG8(MPY32_BASE + OFS_MPY32CTL0_L) &= ~(MPYSAT);
}
uint8_t MPY32_getSaturationMode(void)
{
return (HWREG8(MPY32_BASE + OFS_MPY32CTL0_L) & (MPYSAT));
}
void MPY32_enableFractionalMode(void)
{
HWREG8(MPY32_BASE + OFS_MPY32CTL0_L) |= MPYFRAC;
}
void MPY32_disableFractionalMode(void)
{
HWREG8(MPY32_BASE + OFS_MPY32CTL0_L) &= ~(MPYFRAC);
}
uint8_t MPY32_getFractionalMode(void)
{
return (HWREG8(MPY32_BASE + OFS_MPY32CTL0_L) & (MPYFRAC));
}
void MPY32_setOperandOne8Bit(uint8_t multiplicationType,
uint8_t operand)
{
HWREG8(MPY32_BASE + OFS_MPY + multiplicationType) = operand;
}
void MPY32_setOperandOne16Bit(uint8_t multiplicationType,
uint16_t operand)
{
HWREG16(MPY32_BASE + OFS_MPY + multiplicationType) = operand;
}
void MPY32_setOperandOne24Bit(uint8_t multiplicationType,
uint32_t operand)
{
multiplicationType <<= 1;
HWREG16(MPY32_BASE + OFS_MPY32L + multiplicationType) = operand;
HWREG8(MPY32_BASE + OFS_MPY32H + multiplicationType) = (operand >> 16);
}
void MPY32_setOperandOne32Bit(uint8_t multiplicationType,
uint32_t operand)
{
multiplicationType <<= 1;
HWREG16(MPY32_BASE + OFS_MPY32L + multiplicationType) = operand;
HWREG16(MPY32_BASE + OFS_MPY32H + multiplicationType) = (operand >> 16);
}
void MPY32_setOperandTwo8Bit(uint8_t operand)
{
HWREG8(MPY32_BASE + OFS_OP2) = operand;
}
void MPY32_setOperandTwo16Bit(uint16_t operand)
{
HWREG16(MPY32_BASE + OFS_OP2) = operand;
}
void MPY32_setOperandTwo24Bit(uint32_t operand)
{
HWREG16(MPY32_BASE + OFS_OP2L) = operand;
HWREG8(MPY32_BASE + OFS_OP2H) = (operand >> 16);
}
void MPY32_setOperandTwo32Bit(uint32_t operand)
{
HWREG16(MPY32_BASE + OFS_OP2L) = operand;
HWREG16(MPY32_BASE + OFS_OP2H) = (operand >> 16);
}
uint64_t MPY32_getResult(void)
{
uint64_t result;
result = HWREG16(MPY32_BASE + OFS_RES0);
result += ((uint64_t)HWREG16(MPY32_BASE + OFS_RES1) << 16);
result += ((uint64_t)HWREG16(MPY32_BASE + OFS_RES2) << 32);
result += ((uint64_t)HWREG16(MPY32_BASE + OFS_RES3) << 48);
return (result);
}
uint16_t MPY32_getSumExtension(void)
{
return (HWREG16(MPY32_BASE + OFS_SUMEXT));
}
uint16_t MPY32_getCarryBitValue(void)
{
return (HWREG16(MPY32_BASE + OFS_MPY32CTL0) | MPYC);
}
void MPY32_clearCarryBitValue(void)
{
HWREG16(MPY32_BASE + OFS_MPY32CTL0) &= ~MPYC;
}
void MPY32_preloadResult(uint64_t result)
{
HWREG16(MPY32_BASE + OFS_RES0) = (result & 0xFFFF);
HWREG16(MPY32_BASE + OFS_RES1) = ((result >> 16) & 0xFFFF);
HWREG16(MPY32_BASE + OFS_RES2) = ((result >> 32) & 0xFFFF);
HWREG16(MPY32_BASE + OFS_RES3) = ((result >> 48) & 0xFFFF);
}
#endif
//*****************************************************************************
//
//! Close the doxygen group for mpy32_api
//! @}
//
//*****************************************************************************

View File

@ -1,445 +0,0 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
//
// mpy32.h - Driver for the MPY32 Module.
//
//*****************************************************************************
#ifndef __MSP430WARE_MPY32_H__
#define __MSP430WARE_MPY32_H__
#include "inc/hw_memmap.h"
#ifdef __MSP430_HAS_MPY32__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
#include "inc/hw_memmap.h"
//*****************************************************************************
//
// The following are values that can be passed to the writeDelaySelect
// parameter for functions: MPY32_setWriteDelay().
//
//*****************************************************************************
#define MPY32_WRITEDELAY_OFF (!(MPYDLY32 + MPYDLYWRTEN))
#define MPY32_WRITEDELAY_32BIT (MPYDLYWRTEN)
#define MPY32_WRITEDELAY_64BIT (MPYDLY32 + MPYDLYWRTEN)
//*****************************************************************************
//
// The following are values that can be passed to the multiplicationType
// parameter for functions: MPY32_setOperandOne8Bit(),
// MPY32_setOperandOne16Bit(), MPY32_setOperandOne24Bit(), and
// MPY32_setOperandOne32Bit().
//
//*****************************************************************************
#define MPY32_MULTIPLY_UNSIGNED (0x00)
#define MPY32_MULTIPLY_SIGNED (0x02)
#define MPY32_MULTIPLYACCUMULATE_UNSIGNED (0x04)
#define MPY32_MULTIPLYACCUMULATE_SIGNED (0x06)
//*****************************************************************************
//
// The following are values that can be passed toThe following are values that
// can be returned by the MPY32_getSaturationMode() function.
//
//*****************************************************************************
#define MPY32_SATURATION_MODE_DISABLED 0x00
#define MPY32_SATURATION_MODE_ENABLED MPYSAT
//*****************************************************************************
//
// The following are values that can be passed toThe following are values that
// can be returned by the MPY32_getFractionalMode() function.
//
//*****************************************************************************
#define MPY32_FRACTIONAL_MODE_DISABLED 0x00
#define MPY32_FRACTIONAL_MODE_ENABLED MPYFRAC
//*****************************************************************************
//
// Prototypes for the APIs.
//
//*****************************************************************************
//*****************************************************************************
//
//! \brief Sets the write delay setting for the MPY32 module.
//!
//! This function sets up a write delay to the MPY module's registers, which
//! holds any writes to the registers until all calculations are complete.
//! There are two different settings, one which waits for 32-bit results to be
//! ready, and one which waits for 64-bit results to be ready. This prevents
//! unpredicatble results if registers are changed before the results are
//! ready.
//!
//! \param writeDelaySelect delays the write to any MPY32 register until the
//! selected bit size of result has been written.
//! Valid values are:
//! - \b MPY32_WRITEDELAY_OFF [Default] - writes are not delayed
//! - \b MPY32_WRITEDELAY_32BIT - writes are delayed until a 32-bit
//! result is available in the result registers
//! - \b MPY32_WRITEDELAY_64BIT - writes are delayed until a 64-bit
//! result is available in the result registers
//! \n Modified bits are \b MPYDLY32 and \b MPYDLYWRTEN of \b MPY32CTL0
//! register.
//!
//! \return None
//
//*****************************************************************************
extern void MPY32_setWriteDelay(uint16_t writeDelaySelect);
//*****************************************************************************
//
//! \brief Enables Saturation Mode.
//!
//! This function enables saturation mode. When this is enabled, the result
//! read out from the MPY result registers is converted to the most-positive
//! number in the case of an overflow, or the most-negative number in the case
//! of an underflow. Please note, that the raw value in the registers does not
//! reflect the result returned, and if the saturation mode is disabled, then
//! the raw value of the registers will be returned instead.
//!
//!
//! \return None
//
//*****************************************************************************
extern void MPY32_enableSaturationMode(void);
//*****************************************************************************
//
//! \brief Disables Saturation Mode.
//!
//! This function disables saturation mode, which allows the raw result of the
//! MPY result registers to be returned.
//!
//!
//! \return None
//
//*****************************************************************************
extern void MPY32_disableSaturationMode(void);
//*****************************************************************************
//
//! \brief Gets the Saturation Mode.
//!
//! This function gets the current saturation mode.
//!
//!
//! \return Gets the Saturation Mode
//! Return one of the following:
//! - \b MPY32_SATURATION_MODE_DISABLED
//! - \b MPY32_SATURATION_MODE_ENABLED
//! \n Gets the Saturation Mode
//
//*****************************************************************************
extern uint8_t MPY32_getSaturationMode(void);
//*****************************************************************************
//
//! \brief Enables Fraction Mode.
//!
//! This function enables fraction mode.
//!
//!
//! \return None
//
//*****************************************************************************
extern void MPY32_enableFractionalMode(void);
//*****************************************************************************
//
//! \brief Disables Fraction Mode.
//!
//! This function disables fraction mode.
//!
//!
//! \return None
//
//*****************************************************************************
extern void MPY32_disableFractionalMode(void);
//*****************************************************************************
//
//! \brief Gets the Fractional Mode.
//!
//! This function gets the current fractional mode.
//!
//!
//! \return Gets the fractional mode
//! Return one of the following:
//! - \b MPY32_FRACTIONAL_MODE_DISABLED
//! - \b MPY32_FRACTIONAL_MODE_ENABLED
//! \n Gets the Fractional Mode
//
//*****************************************************************************
extern uint8_t MPY32_getFractionalMode(void);
//*****************************************************************************
//
//! \brief Sets an 8-bit value into operand 1.
//!
//! This function sets the first operand for multiplication and determines what
//! type of operation should be performed. Once the second operand is set, then
//! the operation will begin.
//!
//! \param multiplicationType is the type of multiplication to perform once the
//! second operand is set.
//! Valid values are:
//! - \b MPY32_MULTIPLY_UNSIGNED
//! - \b MPY32_MULTIPLY_SIGNED
//! - \b MPY32_MULTIPLYACCUMULATE_UNSIGNED
//! - \b MPY32_MULTIPLYACCUMULATE_SIGNED
//! \param operand is the 8-bit value to load into the 1st operand.
//!
//! \return None
//
//*****************************************************************************
extern void MPY32_setOperandOne8Bit(uint8_t multiplicationType,
uint8_t operand);
//*****************************************************************************
//
//! \brief Sets an 16-bit value into operand 1.
//!
//! This function sets the first operand for multiplication and determines what
//! type of operation should be performed. Once the second operand is set, then
//! the operation will begin.
//!
//! \param multiplicationType is the type of multiplication to perform once the
//! second operand is set.
//! Valid values are:
//! - \b MPY32_MULTIPLY_UNSIGNED
//! - \b MPY32_MULTIPLY_SIGNED
//! - \b MPY32_MULTIPLYACCUMULATE_UNSIGNED
//! - \b MPY32_MULTIPLYACCUMULATE_SIGNED
//! \param operand is the 16-bit value to load into the 1st operand.
//!
//! \return None
//
//*****************************************************************************
extern void MPY32_setOperandOne16Bit(uint8_t multiplicationType,
uint16_t operand);
//*****************************************************************************
//
//! \brief Sets an 24-bit value into operand 1.
//!
//! This function sets the first operand for multiplication and determines what
//! type of operation should be performed. Once the second operand is set, then
//! the operation will begin.
//!
//! \param multiplicationType is the type of multiplication to perform once the
//! second operand is set.
//! Valid values are:
//! - \b MPY32_MULTIPLY_UNSIGNED
//! - \b MPY32_MULTIPLY_SIGNED
//! - \b MPY32_MULTIPLYACCUMULATE_UNSIGNED
//! - \b MPY32_MULTIPLYACCUMULATE_SIGNED
//! \param operand is the 24-bit value to load into the 1st operand.
//!
//! \return None
//
//*****************************************************************************
extern void MPY32_setOperandOne24Bit(uint8_t multiplicationType,
uint32_t operand);
//*****************************************************************************
//
//! \brief Sets an 32-bit value into operand 1.
//!
//! This function sets the first operand for multiplication and determines what
//! type of operation should be performed. Once the second operand is set, then
//! the operation will begin.
//!
//! \param multiplicationType is the type of multiplication to perform once the
//! second operand is set.
//! Valid values are:
//! - \b MPY32_MULTIPLY_UNSIGNED
//! - \b MPY32_MULTIPLY_SIGNED
//! - \b MPY32_MULTIPLYACCUMULATE_UNSIGNED
//! - \b MPY32_MULTIPLYACCUMULATE_SIGNED
//! \param operand is the 32-bit value to load into the 1st operand.
//!
//! \return None
//
//*****************************************************************************
extern void MPY32_setOperandOne32Bit(uint8_t multiplicationType,
uint32_t operand);
//*****************************************************************************
//
//! \brief Sets an 8-bit value into operand 2, which starts the multiplication.
//!
//! This function sets the second operand of the multiplication operation and
//! starts the operation.
//!
//! \param operand is the 8-bit value to load into the 2nd operand.
//!
//! \return None
//
//*****************************************************************************
extern void MPY32_setOperandTwo8Bit(uint8_t operand);
//*****************************************************************************
//
//! \brief Sets an 16-bit value into operand 2, which starts the
//! multiplication.
//!
//! This function sets the second operand of the multiplication operation and
//! starts the operation.
//!
//! \param operand is the 16-bit value to load into the 2nd operand.
//!
//! \return None
//
//*****************************************************************************
extern void MPY32_setOperandTwo16Bit(uint16_t operand);
//*****************************************************************************
//
//! \brief Sets an 24-bit value into operand 2, which starts the
//! multiplication.
//!
//! This function sets the second operand of the multiplication operation and
//! starts the operation.
//!
//! \param operand is the 24-bit value to load into the 2nd operand.
//!
//! \return None
//
//*****************************************************************************
extern void MPY32_setOperandTwo24Bit(uint32_t operand);
//*****************************************************************************
//
//! \brief Sets an 32-bit value into operand 2, which starts the
//! multiplication.
//!
//! This function sets the second operand of the multiplication operation and
//! starts the operation.
//!
//! \param operand is the 32-bit value to load into the 2nd operand.
//!
//! \return None
//
//*****************************************************************************
extern void MPY32_setOperandTwo32Bit(uint32_t operand);
//*****************************************************************************
//
//! \brief Returns an 64-bit result of the last multiplication operation.
//!
//! This function returns all 64 bits of the result registers
//!
//!
//! \return The 64-bit result is returned as a uint64_t type
//
//*****************************************************************************
extern uint64_t MPY32_getResult(void);
//*****************************************************************************
//
//! \brief Returns the Sum Extension of the last multiplication operation.
//!
//! This function returns the Sum Extension of the MPY module, which either
//! gives the sign after a signed operation or shows a carry after a multiply-
//! and-accumulate operation. The Sum Extension acts as a check for overflows
//! or underflows.
//!
//!
//! \return The value of the MPY32 module Sum Extension.
//
//*****************************************************************************
extern uint16_t MPY32_getSumExtension(void);
//*****************************************************************************
//
//! \brief Returns the Carry Bit of the last multiplication operation.
//!
//! This function returns the Carry Bit of the MPY module, which either gives
//! the sign after a signed operation or shows a carry after a multiply- and-
//! accumulate operation.
//!
//!
//! \return The value of the MPY32 module Carry Bit 0x0 or 0x1.
//
//*****************************************************************************
extern uint16_t MPY32_getCarryBitValue(void);
//*****************************************************************************
//
//! \brief Clears the Carry Bit of the last multiplication operation.
//!
//! This function clears the Carry Bit of the MPY module
//!
//!
//! \return The value of the MPY32 module Carry Bit 0x0 or 0x1.
//
//*****************************************************************************
extern void MPY32_clearCarryBitValue(void);
//*****************************************************************************
//
//! \brief Preloads the result register
//!
//! This function Preloads the result register
//!
//! \param result value to preload the result register to
//!
//! \return None
//
//*****************************************************************************
extern void MPY32_preloadResult(uint64_t result);
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif
#endif // __MSP430WARE_MPY32_H__

View File

@ -1,216 +0,0 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
//
// pmm.c - Driver for the pmm Module.
//
//*****************************************************************************
//*****************************************************************************
//
//! \addtogroup pmm_api pmm
//! @{
//
//*****************************************************************************
#include "inc/hw_memmap.h"
#ifdef __MSP430_HAS_PMM_FRAM__
#include "pmm.h"
#include <assert.h>
void PMM_enableSVSH(void)
{
HWREG8(PMM_BASE + OFS_PMMCTL0_H) = PMMPW_H;
HWREG8(PMM_BASE + OFS_PMMCTL0_L) |= SVSHE;
HWREG8(PMM_BASE + OFS_PMMCTL0_H) = 0x00;
}
void PMM_disableSVSH(void)
{
HWREG8(PMM_BASE + OFS_PMMCTL0_H) = PMMPW_H;
HWREG8(PMM_BASE + OFS_PMMCTL0_L) &= ~SVSHE;
HWREG8(PMM_BASE + OFS_PMMCTL0_H) = 0x00;
}
void PMM_turnOnRegulator(void)
{
HWREG8(PMM_BASE + OFS_PMMCTL0_H) = PMMPW_H;
HWREG8(PMM_BASE + OFS_PMMCTL0) &= ~PMMREGOFF;
HWREG8(PMM_BASE + OFS_PMMCTL0_H) = 0x00;
}
void PMM_turnOffRegulator(void)
{
HWREG8(PMM_BASE + OFS_PMMCTL0_H) = PMMPW_H;
HWREG8(PMM_BASE + OFS_PMMCTL0) |= PMMREGOFF;
HWREG8(PMM_BASE + OFS_PMMCTL0_H) = 0x00;
}
void PMM_trigPOR(void)
{
HWREG8(PMM_BASE + OFS_PMMCTL0_H) = PMMPW_H;
HWREG8(PMM_BASE + OFS_PMMCTL0) |= PMMSWPOR;
HWREG8(PMM_BASE + OFS_PMMCTL0_H) = 0x00;
}
void PMM_trigBOR(void)
{
HWREG8(PMM_BASE + OFS_PMMCTL0_H) = PMMPW_H;
HWREG8(PMM_BASE + OFS_PMMCTL0) |= PMMSWBOR;
HWREG8(PMM_BASE + OFS_PMMCTL0_H) = 0x00;
}
void PMM_clearInterrupt(uint16_t mask)
{
HWREG8(PMM_BASE + OFS_PMMCTL0_H) = PMMPW_H;
HWREG16(PMM_BASE + OFS_PMMIFG) &= ~mask;
HWREG8(PMM_BASE + OFS_PMMCTL0_H) = 0x00;
}
uint16_t PMM_getInterruptStatus(uint16_t mask)
{
return ((HWREG16(PMM_BASE + OFS_PMMIFG)) & mask);
}
void PMM_unlockLPM5(void)
{
//Direct register access to avoid compiler warning - #10420-D
//For FRAM devices, at start up, the GPO power-on default
//high-impedance mode needs to be disabled to activate previously
//configured port settings. This can be done by clearing the LOCKLPM5
//bit in PM5CTL0 register
PM5CTL0 &= ~LOCKLPM5;
}
uint16_t PMM_getBandgapMode(void)
{
return (HWREG16((PMM_BASE) + OFS_PMMCTL2) & BGMODE);
}
uint16_t PMM_isBandgapActive(void)
{
return (HWREG16((PMM_BASE) + OFS_PMMCTL2) & REFBGACT);
}
uint16_t PMM_isRefGenActive(void)
{
return (HWREG16((PMM_BASE) + OFS_PMMCTL2) & REFGENACT);
}
uint16_t PMM_getBufferedBandgapVoltageStatus(void)
{
return (HWREG16((PMM_BASE) + OFS_PMMCTL2) & REFBGRDY);
}
uint16_t PMM_getVariableReferenceVoltageStatus(void)
{
return (HWREG16((PMM_BASE) + OFS_PMMCTL2) & REFGENRDY);
}
void PMM_disableTempSensor(void)
{
HWREG8(PMM_BASE + OFS_PMMCTL0_H) = PMMPW_H;
HWREG8(PMM_BASE + OFS_PMMCTL2) &= ~TSENSOREN;
HWREG8(PMM_BASE + OFS_PMMCTL0_H) = 0x00;
}
void PMM_enableTempSensor(void)
{
HWREG8(PMM_BASE + OFS_PMMCTL0_H) = PMMPW_H;
HWREG8(PMM_BASE + OFS_PMMCTL2) |= TSENSOREN;
HWREG8(PMM_BASE + OFS_PMMCTL0_H) = 0x00;
}
void PMM_disableExternalReference(void)
{
HWREG8(PMM_BASE + OFS_PMMCTL0_H) = PMMPW_H;
HWREG8(PMM_BASE + OFS_PMMCTL2) &= ~EXTREFEN;
HWREG8(PMM_BASE + OFS_PMMCTL0_H) = 0x00;
}
void PMM_enableExternalReference(void)
{
HWREG8(PMM_BASE + OFS_PMMCTL0_H) = PMMPW_H;
HWREG8(PMM_BASE + OFS_PMMCTL2) |= EXTREFEN;
HWREG8(PMM_BASE + OFS_PMMCTL0_H) = 0x00;
}
void PMM_disableInternalReference(void)
{
HWREG8(PMM_BASE + OFS_PMMCTL0_H) = PMMPW_H;
HWREG8(PMM_BASE + OFS_PMMCTL2) &= ~INTREFEN;
HWREG8(PMM_BASE + OFS_PMMCTL0_H) = 0x00;
}
void PMM_enableInternalReference(void)
{
HWREG8(PMM_BASE + OFS_PMMCTL0_H) = PMMPW_H;
HWREG8(PMM_BASE + OFS_PMMCTL2) |= INTREFEN;
HWREG8(PMM_BASE + OFS_PMMCTL0_H) = 0x00;
}
void PMM_selectVoltageReference(uint8_t refV){
#ifdef REFVSEL
HWREG16(PMM_BASE + OFS_PMMCTL2) &= ~REFVSEL;
HWREG16(PMM_BASE + OFS_PMMCTL2) |= refV;
#endif
}
void PMM_setPowerMode(uint8_t mode){
#ifdef PWRMODE
HWREG16(PMM_BASE + OFS_PMMCTL2) &= ~PWRMODE;
HWREG16(PMM_BASE + OFS_PMMCTL2) |= (mode << 14);
#endif
}
#endif
//*****************************************************************************
//
//! Close the doxygen group for pmm_api
//! @}
//
//*****************************************************************************

View File

@ -1,502 +0,0 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
//
// pmm.h - Driver for the PMM Module.
//
//*****************************************************************************
#ifndef __MSP430WARE_PMM_H__
#define __MSP430WARE_PMM_H__
#include "inc/hw_memmap.h"
#ifdef __MSP430_HAS_PMM_FRAM__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
// The following are values that can be passed to the mask parameter for
// functions: PMM_clearInterrupt(), and PMM_getInterruptStatus() as well as
// returned by the PMM_getInterruptStatus() function.
//
//*****************************************************************************
#define PMM_BOR_INTERRUPT PMMBORIFG
#define PMM_RST_INTERRUPT PMMRSTIFG
#define PMM_POR_INTERRUPT PMMPORIFG
#define PMM_SVSH_INTERRUPT SVSHIFG
#define PMM_LPM5_INTERRUPT PMMLPM5IFG
#define PMM_ALL (0xA7)
//*****************************************************************************
//
// The following are values that can be passed toThe following are values that
// can be returned by the PMM_getBandgapMode() function.
//
//*****************************************************************************
#define PMM_STATICMODE (0x0)
#define PMM_SAMPLEMODE BGMODE
//*****************************************************************************
//
// The following are values that can be passed toThe following are values that
// can be returned by the PMM_isBandgapActive() function.
//
//*****************************************************************************
#define PMM_REFBG_INACTIVE (0x0)
#define PMM_REFBG_ACTIVE REFBGACT
//*****************************************************************************
//
// The following are values that can be passed toThe following are values that
// can be returned by the PMM_isRefGenActive() function.
//
//*****************************************************************************
#define PMM_REFGEN_INACTIVE (0x0)
#define PMM_REFGEN_ACTIVE REFGENACT
//*****************************************************************************
//
// The following are values that can be passed toThe following are values that
// can be returned by the PMM_getBufferedBandgapVoltageStatus() function.
//
//*****************************************************************************
#define PMM_REFBG_NOTREADY (0x0)
#define PMM_REFBG_READY REFBGRDY
//*****************************************************************************
//
// The following are values that can be passed toThe following are values that
// can be returned by the PMM_getVariableReferenceVoltageStatus() function.
//
//*****************************************************************************
#define PMM_REFGEN_NOTREADY (0x0)
#define PMM_REFGEN_READY REFGENRDY
//*****************************************************************************
//
// The following are values that can be passed to the refV parameter for
// functions: PMM_selectVoltageReference().
//
//*****************************************************************************
#define PMM_REFVSEL_1_5V REFVSEL_0
#define PMM_REFVSEL_2_0V REFVSEL_1
#define PMM_REFVSEL_2_5V REFVSEL_2
//*****************************************************************************
//
// Prototypes for the APIs.
//
//*****************************************************************************
//*****************************************************************************
//
//! \brief Enables the high-side SVS circuitry
//!
//!
//! Modified bits of \b PMMCTL0 register.
//!
//! \return None
//
//*****************************************************************************
extern void PMM_enableSVSH(void);
//*****************************************************************************
//
//! \brief Disables the high-side SVS circuitry
//!
//!
//! Modified bits of \b PMMCTL0 register.
//!
//! \return None
//
//*****************************************************************************
extern void PMM_disableSVSH(void);
//*****************************************************************************
//
//! \brief Makes the low-dropout voltage regulator (LDO) remain ON when going
//! into LPM 3/4.
//!
//!
//! Modified bits of \b PMMCTL0 register.
//!
//! \return None
//
//*****************************************************************************
extern void PMM_turnOnRegulator(void);
//*****************************************************************************
//
//! \brief Turns OFF the low-dropout voltage regulator (LDO) when going into
//! LPM3/4, thus the system will enter LPM3.5 or LPM4.5 respectively
//!
//!
//! Modified bits of \b PMMCTL0 register.
//!
//! \return None
//
//*****************************************************************************
extern void PMM_turnOffRegulator(void);
//*****************************************************************************
//
//! \brief Calling this function will trigger a software Power On Reset (POR).
//!
//!
//! Modified bits of \b PMMCTL0 register.
//!
//! \return None
//
//*****************************************************************************
extern void PMM_trigPOR(void);
//*****************************************************************************
//
//! \brief Calling this function will trigger a software Brown Out Rest (BOR).
//!
//!
//! Modified bits of \b PMMCTL0 register.
//!
//! \return None
//
//*****************************************************************************
extern void PMM_trigBOR(void);
//*****************************************************************************
//
//! \brief Clears interrupt flags for the PMM
//!
//! \param mask is the mask for specifying the required flag
//! Mask value is the logical OR of any of the following:
//! - \b PMM_BOR_INTERRUPT - Software BOR interrupt
//! - \b PMM_RST_INTERRUPT - RESET pin interrupt
//! - \b PMM_POR_INTERRUPT - Software POR interrupt
//! - \b PMM_SVSH_INTERRUPT - SVS high side interrupt
//! - \b PMM_LPM5_INTERRUPT - LPM5 indication
//! - \b PMM_ALL - All interrupts
//!
//! Modified bits of \b PMMCTL0 register and bits of \b PMMIFG register.
//!
//! \return None
//
//*****************************************************************************
extern void PMM_clearInterrupt(uint16_t mask);
//*****************************************************************************
//
//! \brief Returns interrupt status
//!
//! \param mask is the mask for specifying the required flag
//! Mask value is the logical OR of any of the following:
//! - \b PMM_BOR_INTERRUPT - Software BOR interrupt
//! - \b PMM_RST_INTERRUPT - RESET pin interrupt
//! - \b PMM_POR_INTERRUPT - Software POR interrupt
//! - \b PMM_SVSH_INTERRUPT - SVS high side interrupt
//! - \b PMM_LPM5_INTERRUPT - LPM5 indication
//! - \b PMM_ALL - All interrupts
//!
//! \return Logical OR of any of the following:
//! - \b PMM_BOR_INTERRUPT Software BOR interrupt
//! - \b PMM_RST_INTERRUPT RESET pin interrupt
//! - \b PMM_POR_INTERRUPT Software POR interrupt
//! - \b PMM_SVSH_INTERRUPT SVS high side interrupt
//! - \b PMM_LPM5_INTERRUPT LPM5 indication
//! - \b PMM_ALL All interrupts
//! \n indicating the status of the selected interrupt flags
//
//*****************************************************************************
extern uint16_t PMM_getInterruptStatus(uint16_t mask);
//*****************************************************************************
//
//! \brief Unlock LPM5
//!
//! LPMx.5 configuration is not locked and defaults to its reset condition.
//! Disable the GPIO power-on default high-impedance mode to activate
//! previously configured port settings.
//!
//!
//! \return None
//
//*****************************************************************************
extern void PMM_unlockLPM5(void);
//*****************************************************************************
//
//! \brief Returns the bandgap mode of the PMM module.
//!
//! This function is used to return the bandgap mode of the PMM module,
//! requested by the peripherals using the bandgap. If a peripheral requests
//! static mode, then the bandgap mode will be static for all modules, whereas
//! if all of the peripherals using the bandgap request sample mode, then that
//! will be the mode returned. Sample mode allows the bandgap to be active only
//! when necessary to save on power consumption, static mode requires the
//! bandgap to be active until no peripherals are using it anymore.
//!
//!
//! \return The bandgap mode of the PMM module:
//! Return Logical OR of any of the following:
//! - \b PMM_STATICMODE if the bandgap is operating in static mode
//! - \b PMM_SAMPLEMODE if the bandgap is operating in sample mode
//
//*****************************************************************************
extern uint16_t PMM_getBandgapMode(void);
//*****************************************************************************
//
//! \brief Returns the active status of the bandgap in the PMM module.
//!
//! This function is used to return the active status of the bandgap in the PMM
//! module. If the bandgap is in use by a peripheral, then the status will be
//! seen as active.
//!
//!
//! \return The bandgap active status of the PMM module:
//! Return Logical OR of any of the following:
//! - \b PMM_REFBG_INACTIVE if the bandgap is not being used at the
//! time of query
//! - \b PMM_REFBG_ACTIVE if the bandgap is being used at the time of
//! query
//
//*****************************************************************************
extern uint16_t PMM_isBandgapActive(void);
//*****************************************************************************
//
//! \brief Returns the active status of the reference generator in the PMM
//! module.
//!
//! This function is used to return the active status of the reference
//! generator in the PMM module. If the reference generator is on and ready to
//! use, then the status will be seen as active.
//!
//!
//! \return The reference generator active status of the PMM module:
//! Return Logical OR of any of the following:
//! - \b PMM_REFGEN_INACTIVE if the reference generator is off and not
//! operating
//! - \b PMM_REFGEN_ACTIVE if the reference generator is on and ready
//! to be used
//
//*****************************************************************************
extern uint16_t PMM_isRefGenActive(void);
//*****************************************************************************
//
//! \brief Returns the active status of the reference generator in the PMM
//! module.
//!
//! This function is used to return the ready status of the buffered bandgap
//! voltage in the PMM module. If the buffered bandgap voltage is ready to use,
//! the ready status will be returned.
//!
//!
//! \return The buffered bandgap voltage ready status of the PMM module:
//! Return Logical OR of any of the following:
//! - \b PMM_REFBG_NOTREADY if buffered bandgap voltage is NOT ready to
//! be used
//! - \b PMM_REFBG_READY if buffered bandgap voltage ready to be used
//
//*****************************************************************************
extern uint16_t PMM_getBufferedBandgapVoltageStatus(void);
//*****************************************************************************
//
//! \brief Returns the busy status of the variable reference voltage in the PMM
//! module.
//!
//! This function is used to return the ready status of the variable reference
//! voltage in the REFPMM module. If the reference generator is on and ready to
//! use, then the ready status will be returned.
//!
//!
//! \return The variable reference voltage active status of the PMM module:
//! Return Logical OR of any of the following:
//! - \b PMM_REFGEN_NOTREADY if variable reference voltage is NOT ready
//! to be used
//! - \b PMM_REFGEN_READY if variable reference voltage ready to be
//! used
//
//*****************************************************************************
extern uint16_t PMM_getVariableReferenceVoltageStatus(void);
//*****************************************************************************
//
//! \brief Disables the internal temperature sensor to save power consumption.
//!
//! This function is used to turn off the internal temperature sensor to save
//! on power consumption. The temperature sensor is disabled by default.
//!
//!
//! Modified bits are \b TSENSOREN of \b PMMCTL2 register.
//!
//! \return None
//
//*****************************************************************************
extern void PMM_disableTempSensor(void);
//*****************************************************************************
//
//! \brief Enables the internal temperature sensor.
//!
//! This function is used to turn on the internal temperature sensor to use by
//! other peripherals. The temperature sensor is disabled by default.
//!
//!
//! Modified bits are \b TSENSOREN of \b PMMCTL2 register.
//!
//! \return None
//
//*****************************************************************************
extern void PMM_enableTempSensor(void);
//*****************************************************************************
//
//! \brief Disables the external reference output.
//!
//! This function is used to disable the external reference output. The
//! external reference is connected to a given external ADC channel. The
//! external reference is disabled by default.
//!
//!
//! Modified bits are \b EXTREFEN of \b PMMCTL2 register.
//!
//! \return None
//
//*****************************************************************************
extern void PMM_disableExternalReference(void);
//*****************************************************************************
//
//! \brief Enables the external reference output.
//!
//! This function is used to enable the external reference output. The external
//! reference is connected to a given external ADC channel. The external
//! reference is disabled by default.
//!
//!
//! Modified bits are \b EXTREFEN of \b PMMCTL2 register.
//!
//! \return None
//
//*****************************************************************************
extern void PMM_enableExternalReference(void);
//*****************************************************************************
//
//! \brief Disables the internal reference output.
//!
//! This function is used to disable the internal reference output. The
//! internal reference is internally connected to the ADC channel. The internal
//! reference is disabled by default.
//!
//!
//! Modified bits are \b INTREFEN of \b PMMCTL2 register.
//!
//! \return None
//
//*****************************************************************************
extern void PMM_disableInternalReference(void);
//*****************************************************************************
//
//! \brief Enables the internal reference output.
//!
//! This function is used to enable the internal reference output. The internal
//! reference is internally connected to the ADC channel. The internal
//! reference is disabled by default.
//!
//!
//! Modified bits are \b INTREFEN of \b PMMCTL2 register.
//!
//! \return None
//
//*****************************************************************************
extern void PMM_enableInternalReference(void);
//*****************************************************************************
//
//! \brief Selects reference voltage level.
//!
//! This function selects the reference voltage level.
//!
//! \param refV is the reference voltage
//! Valid values are:
//! - \b PMM_REFVSEL_1_5V [Default]
//! - \b PMM_REFVSEL_2_0V
//! - \b PMM_REFVSEL_2_5V
//!
//! Modified bits are \b REFVSEL of \b PMMCTL2 register.
//!
//! \return None
//
//*****************************************************************************
extern void PMM_selectVoltageReference(uint8_t refV);
//*****************************************************************************
//
//! \brief Selects power supply in multi-power supply systems.
//!
//! This function selects power supply in multi power supply systems. A single
//! power supply system is not affected by the bits.
//!
//! \param mode is the power mode
//!
//! Modified bits are \b PWRMODE of \b PMMCTL2 register.
//!
//! \return None
//
//*****************************************************************************
extern void PMM_setPowerMode(uint8_t mode);
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif
#endif // __MSP430WARE_PMM_H__

File diff suppressed because it is too large Load Diff

View File

@ -1,496 +0,0 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
//
// rom_driverlib_fr253x_fr263x.h - Macros to facilitate calling functions in
// ROM for MSP430FR2532, FR2533, FR2632, FR2633
//
// Copyright (c) 2014-2017 Texas Instruments Incorporated. All rights reserved.
// TI Information - Selective Disclosure
//
//*****************************************************************************
//
#ifndef __ROM_DRIVERLIB_H__
#define __ROM_DRIVERLIB_H__
#if (defined(__TI_COMPILER_VERSION__) && !defined(__LARGE_CODE_MODEL__)) || \
(defined(__IAR_SYSTEMS_ICC__) && (__CODE_MODEL__==__CODE_MODEL_SMALL__))
//*****************************************************************************
//
// Pointers to the main API tables.
//
//*****************************************************************************
#define ROM_DRIVERLIB_APITABLE ((uint16_t *)0x67E0)
#define ROM_DRIVERLIB_VERSIONL (ROM_DRIVERLIB_APITABLE[0])
#define ROM_DRIVERLIB_VERSIONH (ROM_DRIVERLIB_APITABLE[1])
#define ROM_EUSCIASPITABLE ((uint16_t *)(ROM_DRIVERLIB_APITABLE[2]))
#define ROM_EUSCIAUARTTABLE ((uint16_t *)(ROM_DRIVERLIB_APITABLE[3]))
#define ROM_EUSCIBI2CTABLE ((uint16_t *)(ROM_DRIVERLIB_APITABLE[4]))
#define ROM_EUSCIBSPITABLE ((uint16_t *)(ROM_DRIVERLIB_APITABLE[5]))
#define ROM_DRIVERLIB_getVersion() ((uint32_t)ROM_DRIVERLIB_VERSIONH<<16|\
ROM_DRIVERLIB_VERSIONL)
//*****************************************************************************
//
// Macros for calling ROM functions in the EUSCIASPI API.
//
//*****************************************************************************
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_A_SPI_disableInterrupt \
((void (*)(uint16_t baseAddress, \
uint8_t mask))ROM_EUSCIASPITABLE[0])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_A_SPI_disable \
((void (*)(uint16_t baseAddress))ROM_EUSCIASPITABLE[1])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_A_SPI_isBusy \
((uint16_t (*)(uint16_t baseAddress))ROM_EUSCIASPITABLE[2])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_A_SPI_getReceiveBufferAddress \
((uint32_t (*)(uint16_t baseAddress))ROM_EUSCIASPITABLE[3])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_A_SPI_enableInterrupt \
((void (*)(uint16_t baseAddress, \
uint8_t mask))ROM_EUSCIASPITABLE[4])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_A_SPI_transmitData \
((void (*)(uint16_t baseAddress, \
uint8_t transmitData))ROM_EUSCIASPITABLE[5])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_A_SPI_changeMasterClock \
((void (*)(uint16_t baseAddress, \
EUSCI_A_SPI_changeMasterClockParam *param))ROM_EUSCIASPITABLE[6])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_A_SPI_initMaster \
((void (*)(uint16_t baseAddress, \
EUSCI_A_SPI_initMasterParam *param))ROM_EUSCIASPITABLE[7])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_A_SPI_changeClockPhasePolarity \
((void (*)(uint16_t baseAddress, \
uint16_t clockPhase, \
uint16_t clockPolarity))ROM_EUSCIASPITABLE[8])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_A_SPI_getInterruptStatus \
((uint8_t (*)(uint16_t baseAddress, \
uint8_t mask))ROM_EUSCIASPITABLE[9])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_A_SPI_select4PinFunctionality \
((void (*)(uint16_t baseAddress, \
uint8_t select4PinFunctionality))ROM_EUSCIASPITABLE[10])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_A_SPI_initSlave \
((void (*)(uint16_t baseAddress, \
EUSCI_A_SPI_initSlaveParam *param))ROM_EUSCIASPITABLE[11])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_A_SPI_enable \
((void (*)(uint16_t baseAddress))ROM_EUSCIASPITABLE[12])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_A_SPI_getTransmitBufferAddress \
((uint32_t (*)(uint16_t baseAddress))ROM_EUSCIASPITABLE[13])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_A_SPI_clearInterrupt \
((void (*)(uint16_t baseAddress, \
uint8_t mask))ROM_EUSCIASPITABLE[14])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_A_SPI_receiveData \
((uint8_t (*)(uint16_t baseAddress))ROM_EUSCIASPITABLE[15])
#endif
//*****************************************************************************
//
// Macros for calling ROM functions in the EUSCIAUART API.
//
//*****************************************************************************
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_A_UART_setDormant \
((void (*)(uint16_t baseAddress))ROM_EUSCIAUARTTABLE[0])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_A_UART_getTransmitBufferAddress \
((uint32_t (*)(uint16_t baseAddress))ROM_EUSCIAUARTTABLE[1])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_A_UART_disableInterrupt \
((void (*)(uint16_t baseAddress, \
uint8_t mask))ROM_EUSCIAUARTTABLE[2])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_A_UART_enable \
((void (*)(uint16_t baseAddress))ROM_EUSCIAUARTTABLE[3])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_A_UART_transmitData \
((void (*)(uint16_t baseAddress, \
uint8_t transmitData))ROM_EUSCIAUARTTABLE[4])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_A_UART_transmitBreak \
((void (*)(uint16_t baseAddress))ROM_EUSCIAUARTTABLE[5])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_A_UART_resetDormant \
((void (*)(uint16_t baseAddress))ROM_EUSCIAUARTTABLE[6])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_A_UART_init \
((bool (*)(uint16_t baseAddress, \
EUSCI_A_UART_initParam *param))ROM_EUSCIAUARTTABLE[7])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_A_UART_clearInterrupt \
((void (*)(uint16_t baseAddress, \
uint8_t mask))ROM_EUSCIAUARTTABLE[8])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_A_UART_transmitAddress \
((void (*)(uint16_t baseAddress, \
uint8_t transmitAddress))ROM_EUSCIAUARTTABLE[9])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_A_UART_receiveData \
((uint8_t (*)(uint16_t baseAddress))ROM_EUSCIAUARTTABLE[10])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_A_UART_enableInterrupt \
((void (*)(uint16_t baseAddress, \
uint8_t mask))ROM_EUSCIAUARTTABLE[11])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_A_UART_queryStatusFlags \
((uint8_t (*)(uint16_t baseAddress, \
uint8_t mask))ROM_EUSCIAUARTTABLE[12])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_A_UART_getReceiveBufferAddress \
((uint32_t (*)(uint16_t baseAddress))ROM_EUSCIAUARTTABLE[13])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_A_UART_getInterruptStatus \
((uint8_t (*)(uint16_t baseAddress, \
uint8_t mask))ROM_EUSCIAUARTTABLE[14])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_A_UART_selectDeglitchTime \
((void (*)(uint16_t baseAddress, \
uint16_t deglitchTime))ROM_EUSCIAUARTTABLE[15])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_A_UART_disable \
((void (*)(uint16_t baseAddress))ROM_EUSCIAUARTTABLE[16])
#endif
//*****************************************************************************
//
// Macros for calling ROM functions in the EUSCIBI2C API.
//
//*****************************************************************************
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_I2C_initSlave \
((void (*)(uint16_t baseAddress, \
EUSCI_B_I2C_initSlaveParam *param))ROM_EUSCIBI2CTABLE[0])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_I2C_masterSendMultiByteStop \
((void (*)(uint16_t baseAddress))ROM_EUSCIBI2CTABLE[1])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_I2C_isBusBusy \
((uint16_t (*)(uint16_t baseAddress))ROM_EUSCIBI2CTABLE[2])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_I2C_masterReceiveMultiByteNext \
((uint8_t (*)(uint16_t baseAddress))ROM_EUSCIBI2CTABLE[3])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_I2C_masterSendMultiByteStartWithTimeout \
((bool (*)(uint16_t baseAddress, \
uint8_t txData, \
uint32_t timeout))ROM_EUSCIBI2CTABLE[4])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_I2C_masterSendStart \
((void (*)(uint16_t baseAddress))ROM_EUSCIBI2CTABLE[5])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_I2C_disableInterrupt \
((void (*)(uint16_t baseAddress, \
uint16_t mask))ROM_EUSCIBI2CTABLE[6])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_I2C_initMaster \
((void (*)(uint16_t baseAddress, \
EUSCI_B_I2C_initMasterParam *param))ROM_EUSCIBI2CTABLE[7])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_I2C_clearInterrupt \
((void (*)(uint16_t baseAddress, \
uint16_t mask))ROM_EUSCIBI2CTABLE[8])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_I2C_getTransmitBufferAddress \
((uint32_t (*)(uint16_t baseAddress))ROM_EUSCIBI2CTABLE[9])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_I2C_masterReceiveMultiByteFinishWithTimeout \
((bool (*)(uint16_t baseAddress, \
uint8_t *txData, \
uint32_t timeout))ROM_EUSCIBI2CTABLE[10])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_I2C_masterReceiveSingleByte \
((uint8_t (*)(uint16_t baseAddress))ROM_EUSCIBI2CTABLE[11])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_I2C_setSlaveAddress \
((void (*)(uint16_t baseAddress, \
uint8_t slaveAddress))ROM_EUSCIBI2CTABLE[12])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_I2C_slaveGetData \
((uint8_t (*)(uint16_t baseAddress))ROM_EUSCIBI2CTABLE[13])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_I2C_masterSendSingleByte \
((void (*)(uint16_t baseAddress, \
uint8_t txData))ROM_EUSCIBI2CTABLE[14])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_I2C_masterSendMultiByteFinish \
((void (*)(uint16_t baseAddress, \
uint8_t txData))ROM_EUSCIBI2CTABLE[15])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_I2C_setMode \
((void (*)(uint16_t baseAddress, \
uint8_t mode))ROM_EUSCIBI2CTABLE[16])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_I2C_enable \
((void (*)(uint16_t baseAddress))ROM_EUSCIBI2CTABLE[17])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_I2C_masterSendMultiByteNext \
((void (*)(uint16_t baseAddress, \
uint8_t txData))ROM_EUSCIBI2CTABLE[18])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_I2C_getMode \
((uint8_t (*)(uint16_t baseAddress))ROM_EUSCIBI2CTABLE[19])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_I2C_masterReceiveSingle \
((uint8_t (*)(uint16_t baseAddress))ROM_EUSCIBI2CTABLE[20])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_I2C_disable \
((void (*)(uint16_t baseAddress))ROM_EUSCIBI2CTABLE[21])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_I2C_enableInterrupt \
((void (*)(uint16_t baseAddress, \
uint16_t mask))ROM_EUSCIBI2CTABLE[22])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_I2C_masterSendMultiByteNextWithTimeout \
((bool (*)(uint16_t baseAddress, \
uint8_t txData, \
uint32_t timeout))ROM_EUSCIBI2CTABLE[23])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_I2C_masterSendSingleByteWithTimeout \
((bool (*)(uint16_t baseAddress, \
uint8_t txData, \
uint32_t timeout))ROM_EUSCIBI2CTABLE[24])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_I2C_slavePutData \
((void (*)(uint16_t baseAddress, \
uint8_t transmitData))ROM_EUSCIBI2CTABLE[25])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_I2C_masterReceiveStart \
((void (*)(uint16_t baseAddress))ROM_EUSCIBI2CTABLE[26])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_I2C_getReceiveBufferAddress \
((uint32_t (*)(uint16_t baseAddress))ROM_EUSCIBI2CTABLE[27])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_I2C_disableMultiMasterMode \
((void (*)(uint16_t baseAddress))ROM_EUSCIBI2CTABLE[28])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_I2C_masterReceiveMultiByteFinish \
((uint8_t (*)(uint16_t baseAddress))ROM_EUSCIBI2CTABLE[29])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_I2C_masterIsStartSent \
((uint16_t (*)(uint16_t baseAddress))ROM_EUSCIBI2CTABLE[30])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_I2C_enableMultiMasterMode \
((void (*)(uint16_t baseAddress))ROM_EUSCIBI2CTABLE[31])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_I2C_masterSendMultiByteStart \
((void (*)(uint16_t baseAddress, \
uint8_t txData))ROM_EUSCIBI2CTABLE[32])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_I2C_masterSendMultiByteStopWithTimeout \
((bool (*)(uint16_t baseAddress, \
uint32_t timeout))ROM_EUSCIBI2CTABLE[33])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_I2C_masterSendMultiByteFinishWithTimeout \
((bool (*)(uint16_t baseAddress, \
uint8_t txData, \
uint32_t timeout))ROM_EUSCIBI2CTABLE[34])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_I2C_masterIsStopSent \
((uint16_t (*)(uint16_t baseAddress))ROM_EUSCIBI2CTABLE[35])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_I2C_masterReceiveMultiByteStop \
((void (*)(uint16_t baseAddress))ROM_EUSCIBI2CTABLE[36])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_I2C_getInterruptStatus \
((uint16_t (*)(uint16_t baseAddress, \
uint16_t mask))ROM_EUSCIBI2CTABLE[37])
#endif
//*****************************************************************************
//
// Macros for calling ROM functions in the EUSCIBSPI API.
//
//*****************************************************************************
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_SPI_enableInterrupt \
((void (*)(uint16_t baseAddress, \
uint8_t mask))ROM_EUSCIBSPITABLE[0])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_SPI_disable \
((void (*)(uint16_t baseAddress))ROM_EUSCIBSPITABLE[1])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_SPI_clearInterrupt \
((void (*)(uint16_t baseAddress, \
uint8_t mask))ROM_EUSCIBSPITABLE[2])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_SPI_isBusy \
((uint16_t (*)(uint16_t baseAddress))ROM_EUSCIBSPITABLE[3])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_SPI_getReceiveBufferAddress \
((uint32_t (*)(uint16_t baseAddress))ROM_EUSCIBSPITABLE[4])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_SPI_changeMasterClock \
((void (*)(uint16_t baseAddress, \
EUSCI_B_SPI_changeMasterClockParam *param))ROM_EUSCIBSPITABLE[5])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_SPI_transmitData \
((void (*)(uint16_t baseAddress, \
uint8_t transmitData))ROM_EUSCIBSPITABLE[6])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_SPI_select4PinFunctionality \
((void (*)(uint16_t baseAddress, \
uint8_t select4PinFunctionality))ROM_EUSCIBSPITABLE[7])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_SPI_initSlave \
((void (*)(uint16_t baseAddress, \
EUSCI_B_SPI_initSlaveParam *param))ROM_EUSCIBSPITABLE[8])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_SPI_disableInterrupt \
((void (*)(uint16_t baseAddress, \
uint8_t mask))ROM_EUSCIBSPITABLE[9])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_SPI_getTransmitBufferAddress \
((uint32_t (*)(uint16_t baseAddress))ROM_EUSCIBSPITABLE[10])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_SPI_changeClockPhasePolarity \
((void (*)(uint16_t baseAddress, \
uint16_t clockPhase, \
uint16_t clockPolarity))ROM_EUSCIBSPITABLE[11])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_SPI_receiveData \
((uint8_t (*)(uint16_t baseAddress))ROM_EUSCIBSPITABLE[12])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_SPI_getInterruptStatus \
((uint8_t (*)(uint16_t baseAddress, \
uint8_t mask))ROM_EUSCIBSPITABLE[13])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_SPI_initMaster \
((void (*)(uint16_t baseAddress, \
EUSCI_B_SPI_initMasterParam *param))ROM_EUSCIBSPITABLE[14])
#endif
#if defined(TARGET_IS_MSP430FR2XX_4XX)
#define ROM_EUSCI_B_SPI_enable \
((void (*)(uint16_t baseAddress))ROM_EUSCIBSPITABLE[15])
#endif
#else
#error "Large code model is not supported"
#endif
#endif // __ROM_DRIVERLIB_H__

File diff suppressed because it is too large Load Diff

View File

@ -1,139 +0,0 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
//
// rtc.c - Driver for the rtc Module.
//
//*****************************************************************************
//*****************************************************************************
//
//! \addtogroup rtc_api rtc
//! @{
//
//*****************************************************************************
#include "inc/hw_memmap.h"
#ifdef __MSP430_HAS_RTC__
#include "rtc.h"
#include <assert.h>
void RTC_init(uint16_t baseAddress,
uint16_t modulo,
uint16_t clockPredivider)
{
HWREG16(baseAddress + OFS_RTCCTL) &= ~(RTCSS_3 | RTCPS_7);
HWREG16(baseAddress + OFS_RTCMOD) = modulo;
HWREG16(baseAddress + OFS_RTCCTL) |= clockPredivider;
}
void RTC_start(uint16_t baseAddress,
uint16_t clockSource)
{
HWREG16(baseAddress + OFS_RTCCTL) &= ~RTCSS_3;
#ifdef RTCCKSEL
HWREG16(SYS_BASE + OFS_SYSCFG2) &= ~RTCCKSEL;
if(clockSource == RTC_CLOCKSOURCE_ACLK)
{
HWREG16(SYS_BASE + OFS_SYSCFG2) |= RTCCKSEL;
HWREG16(baseAddress + OFS_RTCCTL) |= RTCSS_1;
}
else
{
HWREG16(baseAddress + OFS_RTCCTL) |= clockSource;
}
#else
HWREG16(baseAddress + OFS_RTCCTL) |= clockSource;
#endif
HWREG16(baseAddress + OFS_RTCCTL) |= RTCSR;
}
void RTC_stop(uint16_t baseAddress)
{
HWREG16(baseAddress + OFS_RTCCTL) &= ~RTCSS_3;
}
void RTC_setModulo(uint16_t baseAddress,
uint16_t modulo)
{
HWREG16(baseAddress + OFS_RTCMOD) = modulo;
}
void RTC_enableInterrupt(uint16_t baseAddress,
uint8_t interruptMask)
{
if(interruptMask & RTCIE)
{
HWREG16(baseAddress + OFS_RTCCTL) |= RTCIE;
}
}
void RTC_disableInterrupt(uint16_t baseAddress,
uint8_t interruptMask)
{
if(interruptMask & RTCIE)
{
HWREG16(baseAddress + OFS_RTCCTL) &= ~RTCIE;
}
}
uint8_t RTC_getInterruptStatus(uint16_t baseAddress,
uint8_t interruptFlagMask)
{
uint8_t intStatus = 0;
if(interruptFlagMask & RTCIF)
{
intStatus = (uint8_t)(HWREG16(baseAddress + OFS_RTCCTL) & RTCIF);
}
return(intStatus);
}
void RTC_clearInterrupt(uint16_t baseAddress,
int8_t interruptFlagMask)
{
HWREG16(baseAddress + OFS_RTCCTL) &= ~RTCIF;
}
#endif
//*****************************************************************************
//
//! Close the doxygen group for rtc_api
//! @}
//
//*****************************************************************************

View File

@ -1,284 +0,0 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
//
// rtc.h - Driver for the RTC Module.
//
//*****************************************************************************
#ifndef __MSP430WARE_RTC_H__
#define __MSP430WARE_RTC_H__
#include "inc/hw_memmap.h"
#ifdef __MSP430_HAS_RTC__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
// The following are values that can be passed to the clockSource parameter for
// functions: RTC_start().
//
//*****************************************************************************
#define RTC_CLOCKSOURCE_DISABLED (RTCSS_0)
#define RTC_CLOCKSOURCE_SMCLK (RTCSS_1)
#define RTC_CLOCKSOURCE_XT1CLK (RTCSS_2)
#define RTC_CLOCKSOURCE_VLOCLK (RTCSS_3)
#define RTC_CLOCKSOURCE_ACLK (0x4000)
//*****************************************************************************
//
// The following are values that can be passed to the clockPredivider parameter
// for functions: RTC_init().
//
//*****************************************************************************
#define RTC_CLOCKPREDIVIDER_1 (RTCPS_0)
#define RTC_CLOCKPREDIVIDER_10 (RTCPS_1)
#define RTC_CLOCKPREDIVIDER_100 (RTCPS_2)
#define RTC_CLOCKPREDIVIDER_1000 (RTCPS_3)
#define RTC_CLOCKPREDIVIDER_16 (RTCPS_4)
#define RTC_CLOCKPREDIVIDER_64 (RTCPS_5)
#define RTC_CLOCKPREDIVIDER_256 (RTCPS_6)
#define RTC_CLOCKPREDIVIDER_1024 (RTCPS_7)
//*****************************************************************************
//
// The following are values that can be passed to the interruptMask parameter
// for functions: RTC_enableInterrupt(), and RTC_disableInterrupt().
//
//*****************************************************************************
#define RTC_OVERFLOW_INTERRUPT (RTCIE)
//*****************************************************************************
//
// The following are values that can be passed to the interruptFlagMask
// parameter for functions: RTC_getInterruptStatus(), and RTC_clearInterrupt().
//
//*****************************************************************************
#define RTC_OVERFLOW_INTERRUPT_FLAG (RTCIF)
//*****************************************************************************
//
// Prototypes for the APIs.
//
//*****************************************************************************
//*****************************************************************************
//
//! \brief Initializes the RTC.
//!
//! This function initializes the RTC for clock source and clock pre-divider.
//!
//! \param baseAddress is the base address of the RTC module.
//! \param modulo is the modulo value to set to RTC.
//! \n Modified bits of \b RTCMOD register.
//! \param clockPredivider is the clock pre-divider select for RTC.
//! Valid values are:
//! - \b RTC_CLOCKPREDIVIDER_1 [Default]
//! - \b RTC_CLOCKPREDIVIDER_10
//! - \b RTC_CLOCKPREDIVIDER_100
//! - \b RTC_CLOCKPREDIVIDER_1000
//! - \b RTC_CLOCKPREDIVIDER_16
//! - \b RTC_CLOCKPREDIVIDER_64
//! - \b RTC_CLOCKPREDIVIDER_256
//! - \b RTC_CLOCKPREDIVIDER_1024
//! \n Modified bits are \b RTCPS of \b RTCCTL register.
//!
//! \return None
//
//*****************************************************************************
extern void RTC_init(uint16_t baseAddress,
uint16_t modulo,
uint16_t clockPredivider);
//*****************************************************************************
//
//! \brief Starts RTC running.
//!
//! This function starts the RTC by setting the clock source field (RTCSS).
//! When started, the RTC counter will begin counting at the rate described by
//! the clock source and pre-divider value. When the RTC counter reaches the
//! value in the modulo register, the RTC hardware sets the RTC's interrupt
//! flag bit (RTCIF). Please note, that the RTC actually compares the RTC
//! counter to the modulo shadow register. Since the RTC_start() function sets
//! the RTCSR (RTC software reset) bit, this forces the RTC to copy the value
//! from the Modulo register into the shadow register.
//!
//! \param baseAddress is the base address of the RTC module.
//! \param clockSource is the clock source select for RTC.
//! Valid values are:
//! - \b RTC_CLOCKSOURCE_DISABLED [Default]
//! - \b RTC_CLOCKSOURCE_SMCLK
//! - \b RTC_CLOCKSOURCE_XT1CLK
//! - \b RTC_CLOCKSOURCE_VLOCLK
//! - \b RTC_CLOCKSOURCE_ACLK
//! \n Modified bits are \b RTCSS of \b RTCCTL register.
//!
//! Modified bits are \b RTCSR of \b RTCCTL register.
//!
//! \return None
//
//*****************************************************************************
extern void RTC_start(uint16_t baseAddress,
uint16_t clockSource);
//*****************************************************************************
//
//! \brief Stops RTC running.
//!
//! This function does software reset for RTC.
//!
//! \param baseAddress is the base address of the RTC module.
//!
//! \return None
//
//*****************************************************************************
extern void RTC_stop(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Sets the modulo value.
//!
//! This function does software reset for RTC.
//!
//! \param baseAddress is the base address of the RTC module.
//! \param modulo is the modulo value to set to RTC.
//! \n Modified bits of \b RTCMOD register.
//!
//! \return None
//
//*****************************************************************************
extern void RTC_setModulo(uint16_t baseAddress,
uint16_t modulo);
//*****************************************************************************
//
//! \brief Enables selected RTC interrupt sources.
//!
//! This function enables the selected RTC interrupt source. Only the sources
//! that are enabled can be reflected to the processor interrupt; disabled
//! sources have no effect on the processor. Does not clear interrupt flags.
//!
//! \param baseAddress is the base address of the RTC module.
//! \param interruptMask is a bit mask of the interrupts to enable.
//! Valid values are:
//! - \b RTC_OVERFLOW_INTERRUPT - counter overflow interrupt
//!
//! Modified bits are \b RTCIE of \b RTCCTL register.
//!
//! \return None
//
//*****************************************************************************
extern void RTC_enableInterrupt(uint16_t baseAddress,
uint8_t interruptMask);
//*****************************************************************************
//
//! \brief Disables selected RTC interrupt sources.
//!
//! This function disables the selected RTC interrupt source. Only the sources
//! that are enabled can be reflected to the processor interrupt; disabled
//! sources have no effect on the processor.
//!
//! \param baseAddress is the base address of the RTC module.
//! \param interruptMask is a bit mask of the interrupts to disable.
//! Valid values are:
//! - \b RTC_OVERFLOW_INTERRUPT - counter overflow interrupt
//!
//! Modified bits are \b RTCIE of \b RTCCTL register.
//!
//! \return None
//
//*****************************************************************************
extern void RTC_disableInterrupt(uint16_t baseAddress,
uint8_t interruptMask);
//*****************************************************************************
//
//! \brief Returns the status of the selected interrupts flags.
//!
//! This function returns the status of the interrupt flag for the selected
//! channel.
//!
//! \param baseAddress is the base address of the RTC module.
//! \param interruptFlagMask is a bit mask of the interrupt flags to return the
//! status of.
//! Valid values are:
//! - \b RTC_OVERFLOW_INTERRUPT_FLAG - asserts when counter overflows
//!
//! \return A bit mask of the selected interrupt flag's status.
//
//*****************************************************************************
extern uint8_t RTC_getInterruptStatus(uint16_t baseAddress,
uint8_t interruptFlagMask);
//*****************************************************************************
//
//! \brief Clears selected RTC interrupt flags.
//!
//! This function clears the RTC interrupt flag is cleared, so that it no
//! longer asserts.
//!
//! \param baseAddress is the base address of the RTC module.
//! \param interruptFlagMask is a bit mask of the interrupt flags to clear
//! Valid values are:
//! - \b RTC_OVERFLOW_INTERRUPT_FLAG - asserts when counter overflows
//!
//! Modified bits are \b RTCIF of \b RTCCTL register.
//!
//! \return None
//
//*****************************************************************************
extern void RTC_clearInterrupt(uint16_t baseAddress,
int8_t interruptFlagMask);
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif
#endif // __MSP430WARE_RTC_H__

View File

@ -1,234 +0,0 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
//
// sac.c - Driver for the sac Module.
//
//*****************************************************************************
//*****************************************************************************
//
//! \addtogroup sac_api sac
//! @{
//
//*****************************************************************************
#include "inc/hw_memmap.h"
#if defined(__MSP430_HAS_SACx_CONFIG_1__) || \
defined(__MSP430_HAS_SACx_CONFIG_2__) || \
defined(__MSP430_HAS_SACx_CONFIG_3__) || \
defined(__MSP430_HAS_SACx_CONFIG_4__)
#include "sac.h"
#include <assert.h>
void SAC_OA_init(uint16_t baseAddress,
uint16_t positiveInput,
uint16_t negativeInput)
{
HWREG16(baseAddress + OFS_SAC0OA) &= ~(PSEL1 | PSEL0 | NSEL1 | NSEL0);
if(positiveInput == SAC_OA_POSITIVE_INPUT_SOURCE_DISCONNECTED)
{
HWREG16(baseAddress + OFS_SAC0OA) &= ~PMUXEN;
}
else
{
HWREG16(baseAddress + OFS_SAC0OA) |= PMUXEN | positiveInput;
}
if(negativeInput == SAC_OA_NEGATIVE_INPUT_SOURCE_DISCONNECTED)
{
HWREG16(baseAddress + OFS_SAC0OA) &= ~NMUXEN;
}
else
{
HWREG16(baseAddress + OFS_SAC0OA) |= NMUXEN | negativeInput;
}
}
void SAC_OA_selectPowerMode(uint16_t baseAddress,
uint16_t powerMode)
{
HWREG16(baseAddress + OFS_SAC0OA) &= ~OAPM;
HWREG16(baseAddress + OFS_SAC0OA) |= powerMode;
}
void SAC_OA_enable(uint16_t baseAddress)
{
HWREG16(baseAddress + OFS_SAC0OA) |= OAEN;
}
void SAC_OA_disable(uint16_t baseAddress)
{
HWREG16(baseAddress + OFS_SAC0OA) &= ~OAEN;
}
void SAC_enable(uint16_t baseAddress)
{
HWREG16(baseAddress + OFS_SAC0OA) |= SACEN;
}
void SAC_disable(uint16_t baseAddress)
{
HWREG16(baseAddress + OFS_SAC0OA) &= ~SACEN;
}
void SAC_PGA_setMode(uint16_t baseAddress,
uint8_t mode)
{
#ifdef OFS_SAC0PGA
HWREG16(baseAddress + OFS_SAC0PGA) &= ~MSEL;
HWREG16(baseAddress + OFS_SAC0PGA) |= mode;
#endif
}
void SAC_PGA_setGain(uint16_t baseAddress,
uint8_t gain)
{
#ifdef OFS_SAC0PGA
HWREG16(baseAddress + OFS_SAC0PGA) &= ~GAIN;
HWREG16(baseAddress + OFS_SAC0PGA) |= gain;
#endif
}
void SAC_DAC_enable(uint16_t baseAddress)
{
#ifdef OFS_SAC0DAC
HWREG16(baseAddress + OFS_SAC0DAC) |= DACEN;
#endif
}
void SAC_DAC_disable(uint16_t baseAddress)
{
#ifdef OFS_SAC0DAC
HWREG16(baseAddress + OFS_SAC0DAC) &= ~DACEN;
#endif
}
void SAC_DAC_interruptEnable(uint16_t baseAddress)
{
#ifdef OFS_SAC0DAC
assert(!(HWREG16(baseAddress + OFS_SAC0DAC) & DACEN));
HWREG16(baseAddress + OFS_SAC0DAC) |= DACIE;
#endif
}
void SAC_DAC_interruptDisable(uint16_t baseAddress)
{
#ifdef OFS_SAC0DAC
assert(!(HWREG16(baseAddress + OFS_SAC0DAC) & DACEN));
HWREG16(baseAddress + OFS_SAC0DAC) &= ~DACIE;
#endif
}
void SAC_DAC_DMARequestEnable(uint16_t baseAddress)
{
#ifdef OFS_SAC0DAC
assert(!(HWREG16(baseAddress + OFS_SAC0DAC) & DACEN));
HWREG16(baseAddress + OFS_SAC0DAC) |= DACDMAE;
#endif
}
void SAC_DAC_DMARequestDisable(uint16_t baseAddress)
{
#ifdef OFS_SAC0DAC
assert(!(HWREG16(baseAddress + OFS_SAC0DAC) & DACEN));
HWREG16(baseAddress + OFS_SAC0DAC) &= ~DACDMAE;
#endif
}
void SAC_DAC_selectLoad(uint16_t baseAddress,
uint16_t load)
{
#ifdef OFS_SAC0DAC
assert(!(HWREG16(baseAddress + OFS_SAC0DAC) & DACEN));
HWREG16(baseAddress + OFS_SAC0DAC) &= ~DACLSEL;
HWREG16(baseAddress + OFS_SAC0DAC) |= load;
#endif
}
void SAC_DAC_selectRefVoltage(uint16_t baseAddress,
uint16_t reference)
{
#ifdef OFS_SAC0DAC
assert(!(HWREG16(baseAddress + OFS_SAC0DAC) & DACEN));
HWREG16(baseAddress + OFS_SAC0DAC) &= ~DACSREF;
HWREG16(baseAddress + OFS_SAC0DAC) |= reference;
#endif
}
uint16_t SAC_DAC_getData(uint16_t baseAddress)
{
#ifdef OFS_SAC0DAT
return(HWREG16(baseAddress + OFS_SAC0DAT));
#endif
}
void SAC_DAC_setData(uint16_t baseAddress,
uint16_t data)
{
#ifdef OFS_SAC0DAT
HWREG16(baseAddress + OFS_SAC0DAT) = data;
#endif
}
bool SAC_DAC_getIFG(uint16_t baseAddress)
{
#ifdef OFS_SAC0DACSTS
return (HWREG16(baseAddress + OFS_SAC0DACSTS) & DACIFG);
#endif
}
void SAC_DAC_clearIFG(uint16_t baseAddress)
{
#ifdef OFS_SAC0DACSTS
assert(!(HWREG16(baseAddress + OFS_SAC0DACSTS) & DACEN));
HWREG16(baseAddress + OFS_SAC0DACSTS) |= DACIFG;
#endif
}
uint16_t SAC_getInterruptVector(uint16_t baseAddress)
{
#ifdef OFS_SAC0IV
return(HWREG16(baseAddress + OFS_SAC0IV));
#endif
}
#endif
//*****************************************************************************
//
//! Close the doxygen group for sac_api
//! @}
//
//*****************************************************************************

View File

@ -1,512 +0,0 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
//
// sac.h - Driver for the SAC Module.
//
//*****************************************************************************
#ifndef __MSP430WARE_SAC_H__
#define __MSP430WARE_SAC_H__
#include "inc/hw_memmap.h"
#if defined(__MSP430_HAS_SACx_CONFIG_1__) || \
defined(__MSP430_HAS_SACx_CONFIG_2__) || \
defined(__MSP430_HAS_SACx_CONFIG_3__) || \
defined(__MSP430_HAS_SACx_CONFIG_4__)
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
// The following are values that can be passed to the positiveInput parameter
// for functions: SAC_OA_init().
//
//*****************************************************************************
#define SAC_OA_POSITIVE_INPUT_SOURCE_EXTERNAL 0x0
#define SAC_OA_POSITIVE_INPUT_SOURCE_DAC PSEL0
#define SAC_OA_POSITIVE_INPUT_SOURCE_PAIR_OA PSEL1
#define SAC_OA_POSITIVE_INPUT_SOURCE_DISCONNECTED 0xF
//*****************************************************************************
//
// The following are values that can be passed to the negativeInput parameter
// for functions: SAC_OA_init().
//
//*****************************************************************************
#define SAC_OA_NEGATIVE_INPUT_SOURCE_EXTERNAL 0x0
#define SAC_OA_NEGATIVE_INPUT_SOURCE_PGA NSEL0
#define SAC_OA_NEGATIVE_INPUT_SOURCE_DISCONNECTED 0xF
//*****************************************************************************
//
// The following are values that can be passed to the powerMode parameter for
// functions: SAC_OA_selectPowerMode().
//
//*****************************************************************************
#define SAC_OA_POWER_MODE_HIGH_SPEED_HIGH_POWER 0x0
#define SAC_OA_POWER_MODE_LOW_SPEED_LOW_POWER OAPM
//*****************************************************************************
//
// The following are values that can be passed to the mode parameter for
// functions: SAC_PGA_setMode().
//
//*****************************************************************************
#define SAC_PGA_MODE_INVERTING MSEL_0
#define SAC_PGA_MODE_BUFFER MSEL_1
#define SAC_PGA_MODE_NONINVERTING MSEL_2
#define SAC_PGA_MODE_CASCADE_OA_INVERTING MSEL_3
//*****************************************************************************
//
// The following are values that can be passed to the gain parameter for
// functions: SAC_PGA_setGain().
//
//*****************************************************************************
#define SAC_PGA_GAIN_BIT0 GAIN0
#define SAC_PGA_GAIN_BIT1 GAIN1
#define SAC_PGA_GAIN_BIT2 GAIN2
//*****************************************************************************
//
// The following are values that can be passed to the load parameter for
// functions: SAC_DAC_selectLoad().
//
//*****************************************************************************
#define SAC_DAC_LOAD_DACDAT_WRITTEN DACLSEL_0
#define SAC_DAC_LOAD_DEVICE_SPECIFIC_0 DACLSEL_2
#define SAC_DAC_LOAD_DEVICE_SPECIFIC_1 DACLSEL_3
//*****************************************************************************
//
// The following are values that can be passed to the reference parameter for
// functions: SAC_DAC_selectRefVoltage().
//
//*****************************************************************************
#define SAC_DAC_PRIMARY_REFERENCE DACSREF_0
#define SAC_DAC_SECONDARY_REFERENCE DACSREF_1
//*****************************************************************************
//
// The following are values that can be passed to the data parameter for
// functions: SAC_DAC_setData().
//
//*****************************************************************************
#define SAC_DAC_DATA_BIT0 DACDATA0
#define SAC_DAC_DATA_BIT1 DACDATA1
#define SAC_DAC_DATA_BIT2 DACDATA2
#define SAC_DAC_DATA_BIT3 DACDATA3
#define SAC_DAC_DATA_BIT4 DACDATA4
#define SAC_DAC_DATA_BIT5 DACDATA5
#define SAC_DAC_DATA_BIT6 DACDATA6
#define SAC_DAC_DATA_BIT7 DACDATA7
#define SAC_DAC_DATA_BIT8 DACDATA8
#define SAC_DAC_DATA_BIT9 DACDATA9
#define SAC_DAC_DATA_BIT10 DACDATA10
#define SAC_DAC_DATA_BIT11 DACDATA11
//*****************************************************************************
//
// Prototypes for the APIs.
//
//*****************************************************************************
//*****************************************************************************
//
//! \brief Initializes SAC OA with positive input and negative input
//!
//! This function initializes SAC OA with positive input and negative input.
//!
//! \param baseAddress is the base address of the SAC module.
//! \param positiveInput selects the positive input source
//! Valid values are:
//! - \b SAC_OA_POSITIVE_INPUT_SOURCE_EXTERNAL [Default]
//! - \b SAC_OA_POSITIVE_INPUT_SOURCE_DAC
//! - \b SAC_OA_POSITIVE_INPUT_SOURCE_PAIR_OA
//! - \b SAC_OA_POSITIVE_INPUT_SOURCE_DISCONNECTED
//! \n Modified bits are \b PSEL and \b PMUXEN of \b SACxOA register.
//! \param negativeInput selects the negative input source
//! Valid values are:
//! - \b SAC_OA_NEGATIVE_INPUT_SOURCE_EXTERNAL [Default]
//! - \b SAC_OA_NEGATIVE_INPUT_SOURCE_PGA
//! - \b SAC_OA_NEGATIVE_INPUT_SOURCE_DISCONNECTED
//! \n Modified bits are \b NSEL and \b NMUXEN of \b SACxOA register.
//!
//! \return None
//
//*****************************************************************************
extern void SAC_OA_init(uint16_t baseAddress,
uint16_t positiveInput,
uint16_t negativeInput);
//*****************************************************************************
//
//! \brief Selects power mode for OA
//!
//! This function selects power mode for OA.
//!
//! \param baseAddress is the base address of the SAC module.
//! \param powerMode selects OA power mode.
//! Valid values are:
//! - \b SAC_OA_POWER_MODE_HIGH_SPEED_HIGH_POWER [Default]
//! - \b SAC_OA_POWER_MODE_LOW_SPEED_LOW_POWER
//! \n Modified bits are \b OAPM of \b SACxOA register.
//!
//! \return None
//
//*****************************************************************************
extern void SAC_OA_selectPowerMode(uint16_t baseAddress,
uint16_t powerMode);
//*****************************************************************************
//
//! \brief Enables OA
//!
//! This will enables OA for normal mode.
//!
//! \param baseAddress is the base address of the SAC module.
//!
//! \return None
//
//*****************************************************************************
extern void SAC_OA_enable(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Disables OA
//!
//! This will disable OA and OA outputs high impedance.
//!
//! \param baseAddress is the base address of the SAC module.
//!
//! \return None
//
//*****************************************************************************
extern void SAC_OA_disable(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Enables the SAC all modules
//!
//! This will enable SAC all modules.
//!
//! \param baseAddress is the base address of the SAC module.
//!
//! \return None
//
//*****************************************************************************
extern void SAC_enable(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Disables the SAC all modules
//!
//! This will disable SAC all modules.
//!
//! \param baseAddress is the base address of the SAC module.
//!
//! \return None
//
//*****************************************************************************
extern void SAC_disable(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief SAC PGA mode selection
//!
//! Allows selection of different SAC PGA modes.
//!
//! \param baseAddress is the base address of the SAC module.
//! \param mode selects PGA mode.
//! Valid values are:
//! - \b SAC_PGA_MODE_INVERTING
//! - \b SAC_PGA_MODE_BUFFER [Default]
//! - \b SAC_PGA_MODE_NONINVERTING
//! - \b SAC_PGA_MODE_CASCADE_OA_INVERTING
//! \n Modified bits are \b MSEL of \b SACxPGA register.
//!
//! \return None
//
//*****************************************************************************
extern void SAC_PGA_setMode(uint16_t baseAddress,
uint8_t mode);
//*****************************************************************************
//
//! \brief SAC PGA gain configuration
//!
//! Allows different SAC PGA gain configurations.
//!
//! \param baseAddress is the base address of the SAC module.
//! \param gain selects PGA gain configuration.
//! Mask value is the logical OR of any of the following:
//! - \b SAC_PGA_GAIN_BIT0 [Default]
//! - \b SAC_PGA_GAIN_BIT1
//! - \b SAC_PGA_GAIN_BIT2
//! \n Modified bits are \b GAIN of \b SACxPGA register.
//!
//! \return None
//
//*****************************************************************************
extern void SAC_PGA_setGain(uint16_t baseAddress,
uint8_t gain);
//*****************************************************************************
//
//! \brief SAC DAC enable
//!
//! Enables SAC DAC. Can be modified only when DACEN = 0.
//!
//! \param baseAddress is the base address of the SAC module.
//!
//! \return None
//
//*****************************************************************************
extern void SAC_DAC_enable(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief SAC DAC disable
//!
//! Disables SAC DAC. Can be modified only when DACEN = 0.
//!
//! \param baseAddress is the base address of the SAC module.
//!
//! \return None
//
//*****************************************************************************
extern void SAC_DAC_disable(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief SAC DAC interrupt enable
//!
//! Enables SAC DAC interrupt. Can be modified only when DACEN = 0.
//! Asynchronously enable the SAC and the SAC DAC interrupt to prevent
//! unexpected results.
//!
//! \param baseAddress is the base address of the SAC module.
//!
//! \return None
//
//*****************************************************************************
extern void SAC_DAC_interruptEnable(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief SAC DAC interrupt disable
//!
//! Disables SAC DAC interrupt. Can be modified only when DACEN = 0.
//!
//! \param baseAddress is the base address of the SAC module.
//!
//! \return None
//
//*****************************************************************************
extern void SAC_DAC_interruptDisable(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief SAC DAC DMA request enable
//!
//! Enables SAC DAC DMA request. Can be modified only when DACEN = 0.
//!
//! \param baseAddress is the base address of the SAC module.
//!
//! \return None
//
//*****************************************************************************
extern void SAC_DAC_DMARequestEnable(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief SAC DAC DMA request disable
//!
//! Disables SAC DAC DMA request. Can be modified only when DACEN = 0.
//!
//! \param baseAddress is the base address of the SAC module.
//!
//! \return None
//
//*****************************************************************************
extern void SAC_DAC_DMARequestDisable(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief SAC DAC load select
//!
//! Selects the load trigger for the DAC latch. DACENC must be set for the DAC
//! to update, except when DACLSEL = 0. Can be modified only when DACEN = 0.
//!
//! \param baseAddress is the base address of the SAC module.
//! \param load selects DAC load.
//! Valid values are:
//! - \b SAC_DAC_LOAD_DACDAT_WRITTEN [Default]
//! - \b SAC_DAC_LOAD_DEVICE_SPECIFIC_0
//! - \b SAC_DAC_LOAD_DEVICE_SPECIFIC_1
//! \n Modified bits are \b DACLSEL of \b SACxDAC register.
//!
//! \return None
//
//*****************************************************************************
extern void SAC_DAC_selectLoad(uint16_t baseAddress,
uint16_t load);
//*****************************************************************************
//
//! \brief SAC DAC select reference voltage
//!
//! Selects SAC DAC select reference voltage, primary or secondary. Can be
//! modified only when DACEN = 0.
//!
//! \param baseAddress is the base address of the SAC module.
//! \param reference selects DAC reference voltage.
//! Valid values are:
//! - \b SAC_DAC_PRIMARY_REFERENCE [Default]
//! - \b SAC_DAC_SECONDARY_REFERENCE
//! \n Modified bits are \b DACSREF of \b SACxDAC register.
//!
//! \return None
//
//*****************************************************************************
extern void SAC_DAC_selectRefVoltage(uint16_t baseAddress,
uint16_t reference);
//*****************************************************************************
//
//! \brief Get SAC DAC data
//!
//! Gets from SAC DAC data. Bit 11 represents the MSB. Only word access to
//! SACxDAT register is allowed. Byte operation may cause unexpected results.
//!
//! \param baseAddress is the base address of the SAC module.
//!
//! \return 12-bit value from SAC DAC data.
//
//*****************************************************************************
extern uint16_t SAC_DAC_getData(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Set SAC DAC data
//!
//! Sets data to SAC DAC. Bit 11 represents the MSB. Only word access to
//! SACxDAT register is allowed. Byte operation may cause unexpected results.
//!
//! \param baseAddress is the base address of the SAC module.
//! \param data sends DAC data.
//! Mask value is the logical OR of any of the following:
//! - \b SAC_DAC_DATA_BIT0 [Default]
//! - \b SAC_DAC_DATA_BIT1
//! - \b SAC_DAC_DATA_BIT2
//! - \b SAC_DAC_DATA_BIT3
//! - \b SAC_DAC_DATA_BIT4
//! - \b SAC_DAC_DATA_BIT5
//! - \b SAC_DAC_DATA_BIT6
//! - \b SAC_DAC_DATA_BIT7
//! - \b SAC_DAC_DATA_BIT8
//! - \b SAC_DAC_DATA_BIT9
//! - \b SAC_DAC_DATA_BIT10
//! - \b SAC_DAC_DATA_BIT11
//! \n Modified bits are \b DACDATA of \b SACxDAT register.
//!
//! \return None
//
//*****************************************************************************
extern void SAC_DAC_setData(uint16_t baseAddress,
uint16_t data);
//*****************************************************************************
//
//! \brief Get SAC DAC data update flag
//!
//! Gets flag of SAC DAC update status.
//!
//! \param baseAddress is the base address of the SAC module.
//!
//! \return True or false whether DAC latch data register updated
//
//*****************************************************************************
extern bool SAC_DAC_getIFG(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Clears SAC DAC data update flag
//!
//! Clears SAC DAC data update flag by writing 1. It could also be cleared by
//! reading SACxIV register. If DMA is enabled, this flag is automatically
//! cleared by DMA when a new data request is accepted. Can be modified only
//! when DACEN = 0.
//!
//! \param baseAddress is the base address of the SAC module.
//!
//! \return None
//
//*****************************************************************************
extern void SAC_DAC_clearIFG(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Get SAC DAC interrupt vector value
//!
//! Get SAC DAC interrupt vector value. Only word access to the SACIVx register
//! is recommended.
//!
//! \param baseAddress is the base address of the SAC module.
//!
//! \return SAC DAC interrupt vector value
//
//*****************************************************************************
extern uint16_t SAC_getInterruptVector(uint16_t baseAddress);
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif
#endif // __MSP430WARE_SAC_H__

View File

@ -1,96 +0,0 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
//
// sfr.c - Driver for the sfr Module.
//
//*****************************************************************************
//*****************************************************************************
//
//! \addtogroup sfr_api sfr
//! @{
//
//*****************************************************************************
#include "inc/hw_memmap.h"
#ifdef __MSP430_HAS_SFR__
#include "sfr.h"
#include <assert.h>
void SFR_enableInterrupt(uint8_t interruptMask)
{
HWREG8(SFR_BASE + OFS_SFRIE1_L) |= interruptMask;
}
void SFR_disableInterrupt(uint8_t interruptMask)
{
HWREG8(SFR_BASE + OFS_SFRIE1_L) &= ~(interruptMask);
}
uint8_t SFR_getInterruptStatus(uint8_t interruptFlagMask)
{
return (HWREG8(SFR_BASE + OFS_SFRIFG1_L) & interruptFlagMask);
}
void SFR_clearInterrupt(uint8_t interruptFlagMask)
{
HWREG8(SFR_BASE + OFS_SFRIFG1_L) &= ~(interruptFlagMask);
}
void SFR_setResetPinPullResistor(uint16_t pullResistorSetup)
{
HWREG8(SFR_BASE + OFS_SFRRPCR_L) &= ~(SYSRSTRE + SYSRSTUP);
HWREG8(SFR_BASE + OFS_SFRRPCR_L) |= pullResistorSetup;
}
void SFR_setNMIEdge(uint16_t edgeDirection)
{
HWREG8(SFR_BASE + OFS_SFRRPCR_L) &= ~(SYSNMIIES);
HWREG8(SFR_BASE + OFS_SFRRPCR_L) |= edgeDirection;
}
void SFR_setResetNMIPinFunction(uint8_t resetPinFunction)
{
HWREG8(SFR_BASE + OFS_SFRRPCR_L) &= ~(SYSNMI);
HWREG8(SFR_BASE + OFS_SFRRPCR_L) |= resetPinFunction;
}
#endif
//*****************************************************************************
//
//! Close the doxygen group for sfr_api
//! @}
//
//*****************************************************************************

View File

@ -1,290 +0,0 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
//
// sfr.h - Driver for the SFR Module.
//
//*****************************************************************************
#ifndef __MSP430WARE_SFR_H__
#define __MSP430WARE_SFR_H__
#include "inc/hw_memmap.h"
#ifdef __MSP430_HAS_SFR__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
// The following are values that can be passed to the interruptMask parameter
// for functions: SFR_enableInterrupt(), and SFR_disableInterrupt(); the
// interruptFlagMask parameter for functions: SFR_getInterruptStatus(), and
// SFR_clearInterrupt() as well as returned by the SFR_getInterruptStatus()
// function.
//
//*****************************************************************************
#define SFR_JTAG_OUTBOX_INTERRUPT JMBOUTIE
#define SFR_JTAG_INBOX_INTERRUPT JMBINIE
#define SFR_NMI_PIN_INTERRUPT NMIIE
#define SFR_VACANT_MEMORY_ACCESS_INTERRUPT VMAIE
#define SFR_OSCILLATOR_FAULT_INTERRUPT OFIE
#define SFR_WATCHDOG_INTERVAL_TIMER_INTERRUPT WDTIE
//*****************************************************************************
//
// The following are values that can be passed to the pullResistorSetup
// parameter for functions: SFR_setResetPinPullResistor().
//
//*****************************************************************************
#define SFR_RESISTORDISABLE (!(SYSRSTRE + SYSRSTUP))
#define SFR_RESISTORENABLE_PULLUP (SYSRSTRE + SYSRSTUP)
#define SFR_RESISTORENABLE_PULLDOWN (SYSRSTRE)
//*****************************************************************************
//
// The following are values that can be passed to the edgeDirection parameter
// for functions: SFR_setNMIEdge().
//
//*****************************************************************************
#define SFR_NMI_RISINGEDGE (!(SYSNMIIES))
#define SFR_NMI_FALLINGEDGE (SYSNMIIES)
//*****************************************************************************
//
// The following are values that can be passed to the resetPinFunction
// parameter for functions: SFR_setResetNMIPinFunction().
//
//*****************************************************************************
#define SFR_RESETPINFUNC_RESET (!(SYSNMI))
#define SFR_RESETPINFUNC_NMI (SYSNMI)
//*****************************************************************************
//
// Prototypes for the APIs.
//
//*****************************************************************************
//*****************************************************************************
//
//! \brief Enables selected SFR interrupt sources.
//!
//! This function enables the selected SFR interrupt sources. Only the sources
//! that are enabled can be reflected to the processor interrupt; disabled
//! sources have no effect on the processor. Does not clear interrupt flags.
//!
//! \param interruptMask is the bit mask of interrupts that will be enabled.
//! Mask value is the logical OR of any of the following:
//! - \b SFR_JTAG_OUTBOX_INTERRUPT - JTAG outbox interrupt
//! - \b SFR_JTAG_INBOX_INTERRUPT - JTAG inbox interrupt
//! - \b SFR_NMI_PIN_INTERRUPT - NMI pin interrupt, if NMI function is
//! chosen
//! - \b SFR_VACANT_MEMORY_ACCESS_INTERRUPT - Vacant memory access
//! interrupt
//! - \b SFR_OSCILLATOR_FAULT_INTERRUPT - Oscillator fault interrupt
//! - \b SFR_WATCHDOG_INTERVAL_TIMER_INTERRUPT - Watchdog interval timer
//! interrupt
//!
//! \return None
//
//*****************************************************************************
extern void SFR_enableInterrupt(uint8_t interruptMask);
//*****************************************************************************
//
//! \brief Disables selected SFR interrupt sources.
//!
//! This function disables the selected SFR interrupt sources. Only the sources
//! that are enabled can be reflected to the processor interrupt; disabled
//! sources have no effect on the processor.
//!
//! \param interruptMask is the bit mask of interrupts that will be disabled.
//! Mask value is the logical OR of any of the following:
//! - \b SFR_JTAG_OUTBOX_INTERRUPT - JTAG outbox interrupt
//! - \b SFR_JTAG_INBOX_INTERRUPT - JTAG inbox interrupt
//! - \b SFR_NMI_PIN_INTERRUPT - NMI pin interrupt, if NMI function is
//! chosen
//! - \b SFR_VACANT_MEMORY_ACCESS_INTERRUPT - Vacant memory access
//! interrupt
//! - \b SFR_OSCILLATOR_FAULT_INTERRUPT - Oscillator fault interrupt
//! - \b SFR_WATCHDOG_INTERVAL_TIMER_INTERRUPT - Watchdog interval timer
//! interrupt
//!
//! \return None
//
//*****************************************************************************
extern void SFR_disableInterrupt(uint8_t interruptMask);
//*****************************************************************************
//
//! \brief Returns the status of the selected SFR interrupt flags.
//!
//! This function returns the status of the selected SFR interrupt flags in a
//! bit mask format matching that passed into the interruptFlagMask parameter.
//!
//! \param interruptFlagMask is the bit mask of interrupt flags that the status
//! of should be returned.
//! Mask value is the logical OR of any of the following:
//! - \b SFR_JTAG_OUTBOX_INTERRUPT - JTAG outbox interrupt
//! - \b SFR_JTAG_INBOX_INTERRUPT - JTAG inbox interrupt
//! - \b SFR_NMI_PIN_INTERRUPT - NMI pin interrupt, if NMI function is
//! chosen
//! - \b SFR_VACANT_MEMORY_ACCESS_INTERRUPT - Vacant memory access
//! interrupt
//! - \b SFR_OSCILLATOR_FAULT_INTERRUPT - Oscillator fault interrupt
//! - \b SFR_WATCHDOG_INTERVAL_TIMER_INTERRUPT - Watchdog interval timer
//! interrupt
//!
//! \return A bit mask of the status of the selected interrupt flags.
//! Return Logical OR of any of the following:
//! - \b SFR_JTAG_OUTBOX_INTERRUPT JTAG outbox interrupt
//! - \b SFR_JTAG_INBOX_INTERRUPT JTAG inbox interrupt
//! - \b SFR_NMI_PIN_INTERRUPT NMI pin interrupt, if NMI function is
//! chosen
//! - \b SFR_VACANT_MEMORY_ACCESS_INTERRUPT Vacant memory access
//! interrupt
//! - \b SFR_OSCILLATOR_FAULT_INTERRUPT Oscillator fault interrupt
//! - \b SFR_WATCHDOG_INTERVAL_TIMER_INTERRUPT Watchdog interval timer
//! interrupt
//! \n indicating the status of the masked interrupts
//
//*****************************************************************************
extern uint8_t SFR_getInterruptStatus(uint8_t interruptFlagMask);
//*****************************************************************************
//
//! \brief Clears the selected SFR interrupt flags.
//!
//! This function clears the status of the selected SFR interrupt flags.
//!
//! \param interruptFlagMask is the bit mask of interrupt flags that will be
//! cleared.
//! Mask value is the logical OR of any of the following:
//! - \b SFR_JTAG_OUTBOX_INTERRUPT - JTAG outbox interrupt
//! - \b SFR_JTAG_INBOX_INTERRUPT - JTAG inbox interrupt
//! - \b SFR_NMI_PIN_INTERRUPT - NMI pin interrupt, if NMI function is
//! chosen
//! - \b SFR_VACANT_MEMORY_ACCESS_INTERRUPT - Vacant memory access
//! interrupt
//! - \b SFR_OSCILLATOR_FAULT_INTERRUPT - Oscillator fault interrupt
//! - \b SFR_WATCHDOG_INTERVAL_TIMER_INTERRUPT - Watchdog interval timer
//! interrupt
//!
//! \return None
//
//*****************************************************************************
extern void SFR_clearInterrupt(uint8_t interruptFlagMask);
//*****************************************************************************
//
//! \brief Sets the pull-up/down resistor on the ~RST/NMI pin.
//!
//! This function sets the pull-up/down resistors on the ~RST/NMI pin to the
//! settings from the pullResistorSetup parameter.
//!
//! \param pullResistorSetup is the selection of how the pull-up/down resistor
//! on the ~RST/NMI pin should be setup or disabled.
//! Valid values are:
//! - \b SFR_RESISTORDISABLE
//! - \b SFR_RESISTORENABLE_PULLUP [Default]
//! - \b SFR_RESISTORENABLE_PULLDOWN
//! \n Modified bits are \b SYSRSTUP and \b SYSRSTRE of \b SFRRPCR
//! register.
//!
//! \return None
//
//*****************************************************************************
extern void SFR_setResetPinPullResistor(uint16_t pullResistorSetup);
//*****************************************************************************
//
//! \brief Sets the edge direction that will assert an NMI from a signal on the
//! ~RST/NMI pin if NMI function is active.
//!
//! This function sets the edge direction that will assert an NMI from a signal
//! on the ~RST/NMI pin if the NMI function is active. To activate the NMI
//! function of the ~RST/NMI use the SFR_setResetNMIPinFunction() passing
//! SFR_RESETPINFUNC_NMI into the resetPinFunction parameter.
//!
//! \param edgeDirection is the direction that the signal on the ~RST/NMI pin
//! should go to signal an interrupt, if enabled.
//! Valid values are:
//! - \b SFR_NMI_RISINGEDGE [Default]
//! - \b SFR_NMI_FALLINGEDGE
//! \n Modified bits are \b SYSNMIIES of \b SFRRPCR register.
//!
//! \return None
//
//*****************************************************************************
extern void SFR_setNMIEdge(uint16_t edgeDirection);
//*****************************************************************************
//
//! \brief Sets the function of the ~RST/NMI pin.
//!
//! This function sets the functionality of the ~RST/NMI pin, whether in reset
//! mode which will assert a reset if a low signal is observed on that pin, or
//! an NMI which will assert an interrupt from an edge of the signal dependent
//! on the setting of the edgeDirection parameter in SFR_setNMIEdge().
//!
//! \param resetPinFunction is the function that the ~RST/NMI pin should take
//! on.
//! Valid values are:
//! - \b SFR_RESETPINFUNC_RESET [Default]
//! - \b SFR_RESETPINFUNC_NMI
//! \n Modified bits are \b SYSNMI of \b SFRRPCR register.
//!
//! \return None
//
//*****************************************************************************
extern void SFR_setResetNMIPinFunction(uint8_t resetPinFunction);
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif
#endif // __MSP430WARE_SFR_H__

View File

@ -1,239 +0,0 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
//
// sysctl.c - Driver for the sysctl Module.
//
//*****************************************************************************
//*****************************************************************************
//
//! \addtogroup sysctl_api sysctl
//! @{
//
//*****************************************************************************
#include "inc/hw_memmap.h"
#ifdef __MSP430_HAS_SYS__
#include "sysctl.h"
#include <assert.h>
void SysCtl_enableDedicatedJTAGPins(void)
{
HWREG8(SYS_BASE + OFS_SYSCTL_L) |= SYSJTAGPIN;
}
uint8_t SysCtl_getBSLEntryIndication(void)
{
if(HWREG8(SYS_BASE + OFS_SYSCTL_L) & SYSBSLIND)
{
return (SYSCTL_BSLENTRY_INDICATED);
}
else
{
return (SYSCTL_BSLENTRY_NOTINDICATED);
}
}
void SysCtl_enablePMMAccessProtect(void)
{
HWREG8(SYS_BASE + OFS_SYSCTL_L) |= SYSPMMPE;
}
void SysCtl_enableRAMBasedInterruptVectors(void)
{
HWREG8(SYS_BASE + OFS_SYSCTL_L) |= SYSRIVECT;
}
void SysCtl_disableRAMBasedInterruptVectors(void)
{
HWREG8(SYS_BASE + OFS_SYSCTL_L) &= ~(SYSRIVECT);
}
void SysCtl_enableBSLProtect(void)
{
HWREG16(SYS_BASE + OFS_SYSBSLC) |= SYSBSLPE;
}
void SysCtl_disableBSLProtect(void)
{
HWREG16(SYS_BASE + OFS_SYSBSLC) &= ~(SYSBSLPE);
}
void SysCtl_enableBSLMemory(void)
{
HWREG16(SYS_BASE + OFS_SYSBSLC) &= ~(SYSBSLOFF);
}
void SysCtl_disableBSLMemory(void)
{
HWREG16(SYS_BASE + OFS_SYSBSLC) |= SYSBSLOFF;
}
void SysCtl_setRAMAssignedToBSL(uint8_t BSLRAMAssignment)
{
HWREG8(SYS_BASE + OFS_SYSBSLC_L) &= ~(SYSBSLR);
HWREG8(SYS_BASE + OFS_SYSBSLC_L) |= BSLRAMAssignment;
}
void SysCtl_initJTAGMailbox(uint8_t mailboxSizeSelect,
uint8_t autoClearInboxFlagSelect)
{
HWREG8(SYS_BASE + OFS_SYSJMBC_L) &= ~(JMBCLR1OFF + JMBCLR0OFF + JMBMODE);
HWREG8(SYS_BASE + OFS_SYSJMBC_L) |=
mailboxSizeSelect + autoClearInboxFlagSelect;
}
uint8_t SysCtl_getJTAGMailboxFlagStatus(uint8_t mailboxFlagMask)
{
return (HWREG8(SYS_BASE + OFS_SYSJMBC_L) & mailboxFlagMask);
}
void SysCtl_clearJTAGMailboxFlagStatus(uint8_t mailboxFlagMask)
{
HWREG8(SYS_BASE + OFS_SYSJMBC_L) &= ~(mailboxFlagMask);
}
uint16_t SysCtl_getJTAGInboxMessage16Bit(uint8_t inboxSelect)
{
return (HWREG16(SYS_BASE + OFS_SYSJMBI0 + inboxSelect));
}
uint32_t SysCtl_getJTAGInboxMessage32Bit(void)
{
uint32_t JTAGInboxMessageLow = HWREG16(SYS_BASE + OFS_SYSJMBI0);
uint32_t JTAGInboxMessageHigh = HWREG16(SYS_BASE + OFS_SYSJMBI1);
return ((JTAGInboxMessageHigh << 16) + JTAGInboxMessageLow);
}
void SysCtl_setJTAGOutgoingMessage16Bit(uint8_t outboxSelect,
uint16_t outgoingMessage)
{
HWREG16(SYS_BASE + OFS_SYSJMBO0 + outboxSelect) = outgoingMessage;
}
void SysCtl_setJTAGOutgoingMessage32Bit(uint32_t outgoingMessage)
{
HWREG16(SYS_BASE + OFS_SYSJMBO0) = (outgoingMessage);
HWREG16(SYS_BASE + OFS_SYSJMBO1) = (outgoingMessage >> 16);
}
void SysCtl_protectFRAMWrite(uint8_t writeProtect){
uint8_t state = HWREG8(SYS_BASE + OFS_SYSCFG0_L);
#ifndef DFWP
if(writeProtect == SYSCTL_FRAMWRITEPROTECTION_DATA)
{
return;
}
#endif
#ifdef FRWPPW
HWREG16(SYS_BASE + OFS_SYSCFG0) = FWPW | state | writeProtect;
#else
HWREG8(SYS_BASE + OFS_SYSCFG0_L) |= writeProtect;
#endif
}
void SysCtl_enableFRAMWrite(uint8_t writeEnable){
uint8_t state = HWREG8(SYS_BASE + OFS_SYSCFG0_L);
#ifndef DFWP
if(writeEnable == SYSCTL_FRAMWRITEPROTECTION_DATA)
{
return;
}
#endif
#ifdef FRWPPW
HWREG16(SYS_BASE + OFS_SYSCFG0) = FWPW | (state & ~writeEnable);
#else
HWREG8(SYS_BASE + OFS_SYSCFG0_L) &= ~writeEnable;
#endif
}
void SysCtl_setInfraredConfig(uint8_t dataSource,
uint8_t mode,
uint8_t polarity)
{
HWREG16(SYS_BASE + OFS_SYSCFG1) &= ~(IRDSSEL | IRMSEL | IRPSEL);
HWREG16(SYS_BASE + OFS_SYSCFG1) |= dataSource | mode | polarity;
}
void SysCtl_enableInfrared(void)
{
HWREG16(SYS_BASE + OFS_SYSCFG1) |= IREN;
}
void SysCtl_disableInfrared(void)
{
HWREG16(SYS_BASE + OFS_SYSCFG1) &= ~IREN;
}
uint8_t SysCtl_getInfraredData(void)
{
return ((HWREG16(SYS_BASE + OFS_SYSCFG1) & 0x10) >> 4);
}
void SysCtl_setFRWPOA(uint8_t offsetAddress){
uint16_t state = HWREG16(SYS_BASE + OFS_SYSCFG0);
#ifdef FRWPOA
HWREG16(SYS_BASE +
OFS_SYSCFG0) = (FRWPPW | offsetAddress | (state & (DFWP | PFWP)));
#endif
}
void SysCtl_setHARTCLK(uint8_t clockSource){
#ifdef HARTCLK
HWREG16(SYS_BASE + OFS_SYSCFG2) &= ~HARTCLK;
HWREG16(SYS_BASE + OFS_SYSCFG2) |= clockSource;
#endif
}
void SysCtl_setHARTMOD(uint8_t mode){
#ifdef HARTMOD
HWREG16(SYS_BASE + OFS_SYSCFG2) &= ~HARTMOD;
HWREG16(SYS_BASE + OFS_SYSCFG2) |= mode;
#endif
}
#endif
//*****************************************************************************
//
//! Close the doxygen group for sysctl_api
//! @}
//
//*****************************************************************************

View File

@ -1,641 +0,0 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
//
// sysctl.h - Driver for the SYSCTL Module.
//
//*****************************************************************************
#ifndef __MSP430WARE_SYSCTL_H__
#define __MSP430WARE_SYSCTL_H__
#include "inc/hw_memmap.h"
#ifdef __MSP430_HAS_SYS__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
// The following are values that can be passed to the BSLRAMAssignment
// parameter for functions: SysCtl_setRAMAssignedToBSL().
//
//*****************************************************************************
#define SYSCTL_BSLRAMASSIGN_NORAM (!(SYSBSLR))
#define SYSCTL_BSLRAMASSIGN_LOWEST16BYTES (SYSBSLR)
//*****************************************************************************
//
// The following are values that can be passed to the mailboxSizeSelect
// parameter for functions: SysCtl_initJTAGMailbox().
//
//*****************************************************************************
#define SYSCTL_JTAGMBSIZE_16BIT (!(JMBMODE))
#define SYSCTL_JTAGMBSIZE_32BIT (JMBMODE)
//*****************************************************************************
//
// The following are values that can be passed to the autoClearInboxFlagSelect
// parameter for functions: SysCtl_initJTAGMailbox().
//
//*****************************************************************************
#define SYSCTL_JTAGINBOX0AUTO_JTAGINBOX1AUTO (!(JMBCLR0OFF + JMBCLR1OFF))
#define SYSCTL_JTAGINBOX0AUTO_JTAGINBOX1SW (JMBCLR1OFF)
#define SYSCTL_JTAGINBOX0SW_JTAGINBOX1AUTO (JMBCLR0OFF)
#define SYSCTL_JTAGINBOX0SW_JTAGINBOX1SW (JMBCLR0OFF + JMBCLR1OFF)
//*****************************************************************************
//
// The following are values that can be passed to the mailboxFlagMask parameter
// for functions: SysCtl_getJTAGMailboxFlagStatus(), and
// SysCtl_clearJTAGMailboxFlagStatus().
//
//*****************************************************************************
#define SYSCTL_JTAGOUTBOX_FLAG0 (JMBOUT0FG)
#define SYSCTL_JTAGOUTBOX_FLAG1 (JMBOUT1FG)
#define SYSCTL_JTAGINBOX_FLAG0 (JMBIN0FG)
#define SYSCTL_JTAGINBOX_FLAG1 (JMBIN1FG)
//*****************************************************************************
//
// The following are values that can be passed to the inboxSelect parameter for
// functions: SysCtl_getJTAGInboxMessage16Bit().
//
//*****************************************************************************
#define SYSCTL_JTAGINBOX_0 (0x0)
#define SYSCTL_JTAGINBOX_1 (0x2)
//*****************************************************************************
//
// The following are values that can be passed to the outboxSelect parameter
// for functions: SysCtl_setJTAGOutgoingMessage16Bit().
//
//*****************************************************************************
#define SYSCTL_JTAGOUTBOX_0 (0x0)
#define SYSCTL_JTAGOUTBOX_1 (0x2)
//*****************************************************************************
//
// The following are values that can be passed toThe following are values that
// can be returned by the SysCtl_getBSLEntryIndication() function.
//
//*****************************************************************************
#define SYSCTL_BSLENTRY_INDICATED (0x1)
#define SYSCTL_BSLENTRY_NOTINDICATED (0x0)
//*****************************************************************************
//
// The following are values that can be passed to the writeEnable parameter for
// functions: SysCtl_enableFRAMWrite(); the writeProtect parameter for
// functions: SysCtl_protectFRAMWrite().
//
//*****************************************************************************
#define SYSCTL_FRAMWRITEPROTECTION_DATA (0x2)
#define SYSCTL_FRAMWRITEPROTECTION_PROGRAM (0x1)
//*****************************************************************************
//
// The following are values that can be passed to the dataSource parameter for
// functions: SysCtl_setInfraredConfig().
//
//*****************************************************************************
#define SYSCTL_INFRAREDDATASOURCE_CONFIG (0x0)
#define SYSCTL_INFRAREDDATASOURCE_IRDATA (IRDSSEL)
//*****************************************************************************
//
// The following are values that can be passed to the mode parameter for
// functions: SysCtl_setInfraredConfig().
//
//*****************************************************************************
#define SYSCTL_INFRAREDMODE_ASK (0x0)
#define SYSCTL_INFRAREDMODE_FSK (IRMSEL)
//*****************************************************************************
//
// The following are values that can be passed to the polarity parameter for
// functions: SysCtl_setInfraredConfig().
//
//*****************************************************************************
#define SYSCTL_INFRAREDPOLARITY_NORMAL (0x0)
#define SYSCTL_INFRAREDPOLARITY_INVERTED (IRPSEL)
//*****************************************************************************
//
// The following are values that can be passed to the offsetAddress parameter
// for functions: SysCtl_setFRWPOA().
//
//*****************************************************************************
#define SYSCTL_FRWPOA0 FRWPOA0
#define SYSCTL_FRWPOA1 FRWPOA1
#define SYSCTL_FRWPOA2 FRWPOA2
#define SYSCTL_FRWPOA3 FRWPOA3
#define SYSCTL_FRWPOA4 FRWPOA4
#define SYSCTL_FRWPOA5 FRWPOA5
//*****************************************************************************
//
// The following are values that can be passed to the clockSource parameter for
// functions: SysCtl_setHARTCLK().
//
//*****************************************************************************
#define SYSCTL_HARTCLK_TB3_CCR1_B HARTCLK_0
#define SYSCTL_HARTCLK_ACLK HARTCLK_1
//*****************************************************************************
//
// The following are values that can be passed to the mode parameter for
// functions: SysCtl_setHARTMOD().
//
//*****************************************************************************
#define SYSCTL_HARTMOD_STANDARD_SAMPLING HARTMOD_0
#define SYSCTL_HARTMOD_OVER_SAMPLING HARTMOD_1
//*****************************************************************************
//
// Prototypes for the APIs.
//
//*****************************************************************************
//*****************************************************************************
//
//! \brief Sets the JTAG pins to be exclusively for JTAG until a BOR occurs.
//!
//! This function sets the JTAG pins to be exclusively used for the JTAG, and
//! not to be shared with the GPIO pins. This setting can only be cleared when
//! a BOR occurs.
//!
//!
//! \return None
//
//*****************************************************************************
extern void SysCtl_enableDedicatedJTAGPins(void);
//*****************************************************************************
//
//! \brief Returns the indication of a BSL entry sequence from the Spy-Bi-Wire.
//!
//! This function returns the indication of a BSL entry sequence from the Spy-
//! Bi-Wire.
//!
//!
//! \return One of the following:
//! - \b SysCtl_BSLENTRY_INDICATED
//! - \b SysCtl_BSLENTRY_NOTINDICATED
//! \n indicating if a BSL entry sequence was detected
//
//*****************************************************************************
extern uint8_t SysCtl_getBSLEntryIndication(void);
//*****************************************************************************
//
//! \brief Enables PMM Access Protection.
//!
//! This function enables the PMM Access Protection, which will lock any
//! changes on the PMM control registers until a BOR occurs.
//!
//!
//! \return None
//
//*****************************************************************************
extern void SysCtl_enablePMMAccessProtect(void);
//*****************************************************************************
//
//! \brief Enables RAM-based Interrupt Vectors.
//!
//! This function enables RAM-base Interrupt Vectors, which means that
//! interrupt vectors are generated with the end address at the top of RAM,
//! instead of the top of the lower 64kB of flash.
//!
//!
//! \return None
//
//*****************************************************************************
extern void SysCtl_enableRAMBasedInterruptVectors(void);
//*****************************************************************************
//
//! \brief Disables RAM-based Interrupt Vectors.
//!
//! This function disables the interrupt vectors from being generated at the
//! top of the RAM.
//!
//!
//! \return None
//
//*****************************************************************************
extern void SysCtl_disableRAMBasedInterruptVectors(void);
//*****************************************************************************
//
//! \brief Enables BSL memory protection.
//!
//! This function enables protection on the BSL memory, which prevents any
//! reading, programming, or erasing of the BSL memory.
//!
//!
//! \return None
//
//*****************************************************************************
extern void SysCtl_enableBSLProtect(void);
//*****************************************************************************
//
//! \brief Disables BSL memory protection.
//!
//! This function disables protection on the BSL memory.
//!
//!
//! \return None
//
//*****************************************************************************
extern void SysCtl_disableBSLProtect(void);
//*****************************************************************************
//
//! \brief Enables BSL memory.
//!
//! This function enables BSL memory, which allows BSL memory to be addressed
//!
//!
//! \return None
//
//*****************************************************************************
extern void SysCtl_enableBSLMemory(void);
//*****************************************************************************
//
//! \brief Disables BSL memory.
//!
//! This function disables BSL memory, which makes BSL memory act like vacant
//! memory.
//!
//!
//! \return None
//
//*****************************************************************************
extern void SysCtl_disableBSLMemory(void);
//*****************************************************************************
//
//! \brief Sets RAM assignment to BSL area.
//!
//! This function allows RAM to be assigned to BSL, based on the selection of
//! the BSLRAMAssignment parameter.
//!
//! \param BSLRAMAssignment is the selection of if the BSL should be placed in
//! RAM or not.
//! Valid values are:
//! - \b SYSCTL_BSLRAMASSIGN_NORAM [Default]
//! - \b SYSCTL_BSLRAMASSIGN_LOWEST16BYTES
//! \n Modified bits are \b SYSBSLR of \b SYSBSLC register.
//!
//! \return None
//
//*****************************************************************************
extern void SysCtl_setRAMAssignedToBSL(uint8_t BSLRAMAssignment);
//*****************************************************************************
//
//! \brief Initializes JTAG Mailbox with selected properties.
//!
//! This function sets the specified settings for the JTAG Mailbox system. The
//! settings that can be set are the size of the JTAG messages, and the auto-
//! clearing of the inbox flags. If the inbox flags are set to auto-clear, then
//! the inbox flags will be cleared upon reading of the inbox message buffer,
//! otherwise they will have to be reset by software using the
//! SYS_clearJTAGMailboxFlagStatus() function.
//!
//! \param mailboxSizeSelect is the size of the JTAG Mailboxes, whether 16- or
//! 32-bits.
//! Valid values are:
//! - \b SYSCTL_JTAGMBSIZE_16BIT [Default] - the JTAG messages will take
//! up only one JTAG mailbox (i. e. an outgoing message will take up
//! only 1 outbox of the JTAG mailboxes)
//! - \b SYSCTL_JTAGMBSIZE_32BIT - the JTAG messages will be contained
//! within both JTAG mailboxes (i. e. an outgoing message will take
//! up both Outboxes of the JTAG mailboxes)
//! \n Modified bits are \b JMBMODE of \b SYSJMBC register.
//! \param autoClearInboxFlagSelect decides how the JTAG inbox flags should be
//! cleared, whether automatically after the corresponding outbox has
//! been written to, or manually by software.
//! Valid values are:
//! - \b SYSCTL_JTAGINBOX0AUTO_JTAGINBOX1AUTO [Default] - both JTAG
//! inbox flags will be reset automatically when the corresponding
//! inbox is read from.
//! - \b SYSCTL_JTAGINBOX0AUTO_JTAGINBOX1SW - only JTAG inbox 0 flag is
//! reset automatically, while JTAG inbox 1 is reset with the
//! - \b SYSCTL_JTAGINBOX0SW_JTAGINBOX1AUTO - only JTAG inbox 1 flag is
//! reset automatically, while JTAG inbox 0 is reset with the
//! - \b SYSCTL_JTAGINBOX0SW_JTAGINBOX1SW - both JTAG inbox flags will
//! need to be reset manually by the
//! \n Modified bits are \b JMBCLR0OFF and \b JMBCLR1OFF of \b SYSJMBC
//! register.
//!
//! \return None
//
//*****************************************************************************
extern void SysCtl_initJTAGMailbox(uint8_t mailboxSizeSelect,
uint8_t autoClearInboxFlagSelect);
//*****************************************************************************
//
//! \brief Returns the status of the selected JTAG Mailbox flags.
//!
//! This function will return the status of the selected JTAG Mailbox flags in
//! bit mask format matching that passed into the mailboxFlagMask parameter.
//!
//! \param mailboxFlagMask is the bit mask of JTAG mailbox flags that the
//! status of should be returned.
//! Mask value is the logical OR of any of the following:
//! - \b SYSCTL_JTAGOUTBOX_FLAG0 - flag for JTAG outbox 0
//! - \b SYSCTL_JTAGOUTBOX_FLAG1 - flag for JTAG outbox 1
//! - \b SYSCTL_JTAGINBOX_FLAG0 - flag for JTAG inbox 0
//! - \b SYSCTL_JTAGINBOX_FLAG1 - flag for JTAG inbox 1
//!
//! \return A bit mask of the status of the selected mailbox flags.
//
//*****************************************************************************
extern uint8_t SysCtl_getJTAGMailboxFlagStatus(uint8_t mailboxFlagMask);
//*****************************************************************************
//
//! \brief Clears the status of the selected JTAG Mailbox flags.
//!
//! This function clears the selected JTAG Mailbox flags.
//!
//! \param mailboxFlagMask is the bit mask of JTAG mailbox flags that the
//! status of should be cleared.
//! Mask value is the logical OR of any of the following:
//! - \b SYSCTL_JTAGOUTBOX_FLAG0 - flag for JTAG outbox 0
//! - \b SYSCTL_JTAGOUTBOX_FLAG1 - flag for JTAG outbox 1
//! - \b SYSCTL_JTAGINBOX_FLAG0 - flag for JTAG inbox 0
//! - \b SYSCTL_JTAGINBOX_FLAG1 - flag for JTAG inbox 1
//!
//! \return None
//
//*****************************************************************************
extern void SysCtl_clearJTAGMailboxFlagStatus(uint8_t mailboxFlagMask);
//*****************************************************************************
//
//! \brief Returns the contents of the selected JTAG Inbox in a 16 bit format.
//!
//! This function returns the message contents of the selected JTAG inbox. If
//! the auto clear settings for the Inbox flags were set, then using this
//! function will automatically clear the corresponding JTAG inbox flag.
//!
//! \param inboxSelect is the chosen JTAG inbox that the contents of should be
//! returned
//! Valid values are:
//! - \b SYSCTL_JTAGINBOX_0 - return contents of JTAG inbox 0
//! - \b SYSCTL_JTAGINBOX_1 - return contents of JTAG inbox 1
//!
//! \return The contents of the selected JTAG inbox in a 16 bit format.
//
//*****************************************************************************
extern uint16_t SysCtl_getJTAGInboxMessage16Bit(uint8_t inboxSelect);
//*****************************************************************************
//
//! \brief Returns the contents of JTAG Inboxes in a 32 bit format.
//!
//! This function returns the message contents of both JTAG inboxes in a 32 bit
//! format. This function should be used if 32-bit messaging has been set in
//! the SYS_initJTAGMailbox() function. If the auto clear settings for the
//! Inbox flags were set, then using this function will automatically clear
//! both JTAG inbox flags.
//!
//!
//! \return The contents of both JTAG messages in a 32 bit format.
//
//*****************************************************************************
extern uint32_t SysCtl_getJTAGInboxMessage32Bit(void);
//*****************************************************************************
//
//! \brief Sets a 16 bit outgoing message in to the selected JTAG Outbox.
//!
//! This function sets the outgoing message in the selected JTAG outbox. The
//! corresponding JTAG outbox flag is cleared after this function, and set
//! after the JTAG has read the message.
//!
//! \param outboxSelect is the chosen JTAG outbox that the message should be
//! set it.
//! Valid values are:
//! - \b SYSCTL_JTAGOUTBOX_0 - set the contents of JTAG outbox 0
//! - \b SYSCTL_JTAGOUTBOX_1 - set the contents of JTAG outbox 1
//! \param outgoingMessage is the message to send to the JTAG.
//! \n Modified bits are \b MSGHI and \b MSGLO of \b SYSJMBOx register.
//!
//! \return None
//
//*****************************************************************************
extern void SysCtl_setJTAGOutgoingMessage16Bit(uint8_t outboxSelect,
uint16_t outgoingMessage);
//*****************************************************************************
//
//! \brief Sets a 32 bit message in to both JTAG Outboxes.
//!
//! This function sets the 32-bit outgoing message in both JTAG outboxes. The
//! JTAG outbox flags are cleared after this function, and set after the JTAG
//! has read the message.
//!
//! \param outgoingMessage is the message to send to the JTAG.
//! \n Modified bits are \b MSGHI and \b MSGLO of \b SYSJMBOx register.
//!
//! \return None
//
//*****************************************************************************
extern void SysCtl_setJTAGOutgoingMessage32Bit(uint32_t outgoingMessage);
//*****************************************************************************
//
//! \brief Sets write protected for data FRAM and program FRAM.
//!
//! \param writeProtect is the value setting data FRAM and program write
//! protection.
//! Mask value is the logical OR of any of the following:
//! - \b SYSCTL_FRAMWRITEPROTECTION_DATA - data FRAM write protected
//! - \b SYSCTL_FRAMWRITEPROTECTION_PROGRAM - program FRAM write
//! protected
//!
//! \return None
//
//*****************************************************************************
extern void SysCtl_protectFRAMWrite(uint8_t writeProtect);
//*****************************************************************************
//
//! \brief Sets write enable for data FRAM and program FRAM.
//!
//! \param writeEnable is the value setting data FRAM and program write
//! enabled.
//! Mask value is the logical OR of any of the following:
//! - \b SYSCTL_FRAMWRITEPROTECTION_DATA - data FRAM write protected
//! - \b SYSCTL_FRAMWRITEPROTECTION_PROGRAM - program FRAM write
//! protected
//!
//! \return None
//
//*****************************************************************************
extern void SysCtl_enableFRAMWrite(uint8_t writeEnable);
//*****************************************************************************
//
//! \brief Sets infrared configuration bits.
//!
//! \param dataSource is the value setting infrared data source.
//! Valid values are:
//! - \b SYSCTL_INFRAREDDATASOURCE_CONFIG - infrared data from hardware
//! peripherals upon device configuration
//! - \b SYSCTL_INFRAREDDATASOURCE_IRDATA - infrared data from IRDATA
//! bit
//! \param mode is the value setting infrared mode.
//! Valid values are:
//! - \b SYSCTL_INFRAREDMODE_ASK - infrared ASK mode
//! - \b SYSCTL_INFRAREDMODE_FSK - infrared FSK mode
//! \param polarity is the value setting infrared polarity.
//! Valid values are:
//! - \b SYSCTL_INFRAREDPOLARITY_NORMAL - infrared normal polarity
//! - \b SYSCTL_INFRAREDPOLARITY_INVERTED - infrared inverted polarity
//!
//! \return None
//
//*****************************************************************************
extern void SysCtl_setInfraredConfig(uint8_t dataSource,
uint8_t mode,
uint8_t polarity);
//*****************************************************************************
//
//! \brief Enables infrared function.
//!
//!
//! \return None
//
//*****************************************************************************
extern void SysCtl_enableInfrared(void);
//*****************************************************************************
//
//! \brief Disables infrared function.
//!
//!
//! \return None
//
//*****************************************************************************
extern void SysCtl_disableInfrared(void);
//*****************************************************************************
//
//! \brief This function returns the infrared data if the infrared data source
//! is configured as from IRDATA bit.
//!
//!
//! \return the infrared logic data '0' or '1'
//
//*****************************************************************************
extern uint8_t SysCtl_getInfraredData(void);
//*****************************************************************************
//
//! \brief This function sets the Program FRAM write protection offset address
//! from the beginning of Program FRAM. The offset increases by 1 kB
//! resolution.
//!
//! \param offsetAddress is the Program FRAM write protection offset address
//! from the beginning of Program FRAM, with offset increases of 1KB
//! resolution.
//! Mask value is the logical OR of any of the following:
//! - \b SYSCTL_FRWPOA0
//! - \b SYSCTL_FRWPOA1
//! - \b SYSCTL_FRWPOA2
//! - \b SYSCTL_FRWPOA3
//! - \b SYSCTL_FRWPOA4
//! - \b SYSCTL_FRWPOA5
//!
//! \return None
//
//*****************************************************************************
extern void SysCtl_setFRWPOA(uint8_t offsetAddress);
//*****************************************************************************
//
//! \brief This function selects the HART module clock source.
//!
//! \param clockSource is the HART clock source selection.
//! Valid values are:
//! - \b SYSCTL_HARTCLK_TB3_CCR1_B [Default]
//! - \b SYSCTL_HARTCLK_ACLK
//!
//! \return None
//
//*****************************************************************************
extern void SysCtl_setHARTCLK(uint8_t clockSource);
//*****************************************************************************
//
//! \brief This function controls HART mode settings.
//!
//! \param mode is the HART mode settings.
//! Valid values are:
//! - \b SYSCTL_HARTMOD_STANDARD_SAMPLING [Default]
//! - \b SYSCTL_HARTMOD_OVER_SAMPLING
//!
//! \return None
//
//*****************************************************************************
extern void SysCtl_setHARTMOD(uint8_t mode);
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif
#endif // __MSP430WARE_SYSCTL_H__

View File

@ -1,178 +0,0 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
//
// tia.h - Driver for the TIA Module.
//
//*****************************************************************************
#ifndef __MSP430WARE_TIA_H__
#define __MSP430WARE_TIA_H__
#include "inc/hw_memmap.h"
#ifdef __MSP430_HAS_TRIx__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
// The following are values that can be passed to the positiveInput parameter
// for functions: TIA_selectPositiveInput().
//
//*****************************************************************************
#define TIA_POSITIVE_INPUT_EXTERNAL_SOURCE TRIPSEL_0
#define TIA_POSITIVE_INPUT_DEVICE_SPECIFIC_1 TRIPSEL_1
#define TIA_POSITIVE_INPUT_DEVICE_SPECIFIC_2 TRIPSEL_2
#define TIA_POSITIVE_INPUT_DEVICE_SPECIFIC_3 TRIPSEL_3
//*****************************************************************************
//
// The following are values that can be passed to the powerMode parameter for
// functions: TIA_selectPowerMode().
//
//*****************************************************************************
#define TIA_HIGH_SPEED_HIGH_POWER 0x0
#define TIA_LOW_SPEED_LOW_POWER TRIPM
//*****************************************************************************
//
// Prototypes for the APIs.
//
//*****************************************************************************
//*****************************************************************************
//
//! \brief Selects TIA positive input
//!
//! This function selects TIA positive input.
//!
//! \param baseAddress is the base address of the TIA module.
//! \param positiveInput selects positive input.
//! Valid values are:
//! - \b TIA_POSITIVE_INPUT_EXTERNAL_SOURCE [Default]
//! - \b TIA_POSITIVE_INPUT_DEVICE_SPECIFIC_1
//! - \b TIA_POSITIVE_INPUT_DEVICE_SPECIFIC_2
//! - \b TIA_POSITIVE_INPUT_DEVICE_SPECIFIC_3
//! \n Modified bits are \b TRIPSEL of \b TRICTL register.
//!
//! \return None
//
//*****************************************************************************
extern void TIA_selectPositiveInput(uint16_t baseAddress,
uint16_t positiveInput);
//*****************************************************************************
//
//! \brief Selects TIA power mode
//!
//! This function selects TIA power mode.
//!
//! \param baseAddress is the base address of the TIA module.
//! \param powerMode selects TIA power mode.
//! Valid values are:
//! - \b TIA_HIGH_SPEED_HIGH_POWER [Default]
//! - \b TIA_LOW_SPEED_LOW_POWER
//! \n Modified bits are \b TRIPM of \b TRICTL register.
//!
//! \return None
//
//*****************************************************************************
extern void TIA_selectPowerMode(uint16_t baseAddress,
uint16_t powerMode);
//*****************************************************************************
//
//! \brief Enables TIA module
//!
//! This function enables TIA module.
//!
//! \param baseAddress is the base address of the TIA module.
//!
//! \return None
//
//*****************************************************************************
extern void TIA_enable(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Disables TIA module
//!
//! This function disables TIA module.
//!
//! \param baseAddress is the base address of the TIA module.
//!
//! \return None
//
//*****************************************************************************
extern void TIA_disable(uint16_t baseAddress);
//*****************************************************************************
//
// The following are deprecated APIs.
//
//*****************************************************************************
#define TRI_selectPositiveInput TIA_selectPositiveInput
#define TRI_selectPowerMode TIA_selectPowerMode
#define TRI_enable TIA_enable
#define TRI_disable TIA_disable
#define TRI_POSITIVE_INPUT_EXTERNAL_SOURCE TIA_POSITIVE_INPUT_EXTERNAL_SOURCE
#define TRI_POSITIVE_INPUT_DEVICE_SPECIFIC_1 \
TIA_POSITIVE_INPUT_DEVICE_SPECIFIC_1
#define TRI_POSITIVE_INPUT_DEVICE_SPECIFIC_2 \
TIA_POSITIVE_INPUT_DEVICE_SPECIFIC_2
#define TRI_POSITIVE_INPUT_DEVICE_SPECIFIC_3 \
TIA_POSITIVE_INPUT_DEVICE_SPECIFIC_3
#define TRI_HIGH_SPEED_HIGH_POWER TIA_HIGH_SPEED_HIGH_POWER
#define TRI_LOW_SPEED_LOW_POWER TIA_LOW_SPEED_LOW_POWER
#define TIA0_BASE TRI0_BASE
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif
#endif // __MSP430WARE_TIA_H__

File diff suppressed because it is too large Load Diff

View File

@ -1,437 +0,0 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
//
// timer_b.c - Driver for the timer_b Module.
//
//*****************************************************************************
//*****************************************************************************
//
//! \addtogroup timer_b_api timer_b
//! @{
//
//*****************************************************************************
#include "inc/hw_memmap.h"
#ifdef __MSP430_HAS_TxB7__
#include "timer_b.h"
#include <assert.h>
void Timer_B_startCounter(uint16_t baseAddress,
uint16_t timerMode)
{
HWREG16(baseAddress + OFS_TBxCTL) |= timerMode;
}
void Timer_B_initContinuousMode(uint16_t baseAddress,
Timer_B_initContinuousModeParam *param)
{
HWREG16(baseAddress +
OFS_TBxCTL) &= ~(TIMER_B_CLOCKSOURCE_INVERTED_EXTERNAL_TXCLK +
TIMER_B_UPDOWN_MODE +
TIMER_B_DO_CLEAR +
TIMER_B_TBIE_INTERRUPT_ENABLE +
CNTL_3 +
ID__8
);
HWREG16(baseAddress + OFS_TBxEX0) &= ~TBIDEX_7;
HWREG16(baseAddress + OFS_TBxEX0) |= param->clockSourceDivider & 0x7;
HWREG16(baseAddress + OFS_TBxCTL) |= (param->clockSource +
param->timerClear +
param->timerInterruptEnable_TBIE +
((param->clockSourceDivider >>
3) << 6));
if(param->startTimer)
{
HWREG16(baseAddress + OFS_TBxCTL) |= TIMER_B_CONTINUOUS_MODE;
}
}
void Timer_B_initUpMode(uint16_t baseAddress,
Timer_B_initUpModeParam *param)
{
HWREG16(baseAddress + OFS_TBxCTL) &=
~(TIMER_B_CLOCKSOURCE_INVERTED_EXTERNAL_TXCLK +
TIMER_B_UPDOWN_MODE +
TIMER_B_DO_CLEAR +
TIMER_B_TBIE_INTERRUPT_ENABLE +
CNTL_3
);
HWREG16(baseAddress + OFS_TBxEX0) &= ~TBIDEX_7;
HWREG16(baseAddress + OFS_TBxEX0) |= param->clockSourceDivider & 0x7;
HWREG16(baseAddress + OFS_TBxCTL) |= (param->clockSource +
param->timerClear +
param->timerInterruptEnable_TBIE +
((param->clockSourceDivider >>
3) << 6));
if(param->startTimer)
{
HWREG16(baseAddress + OFS_TBxCTL) |= TIMER_B_UP_MODE;
}
if(TIMER_B_CCIE_CCR0_INTERRUPT_ENABLE ==
param->captureCompareInterruptEnable_CCR0_CCIE)
{
HWREG16(baseAddress +
OFS_TBxCCTL0) |= TIMER_B_CCIE_CCR0_INTERRUPT_ENABLE;
}
else
{
HWREG16(baseAddress +
OFS_TBxCCTL0) &= ~TIMER_B_CCIE_CCR0_INTERRUPT_ENABLE;
}
HWREG16(baseAddress + OFS_TBxCCR0) = param->timerPeriod;
}
void Timer_B_initUpDownMode(uint16_t baseAddress,
Timer_B_initUpDownModeParam *param)
{
HWREG16(baseAddress + OFS_TBxCTL) &=
~(TIMER_B_CLOCKSOURCE_INVERTED_EXTERNAL_TXCLK +
TIMER_B_UPDOWN_MODE +
TIMER_B_DO_CLEAR +
TIMER_B_TBIE_INTERRUPT_ENABLE +
CNTL_3
);
HWREG16(baseAddress + OFS_TBxEX0) &= ~TBIDEX_7;
HWREG16(baseAddress + OFS_TBxEX0) |= param->clockSourceDivider & 0x7;
HWREG16(baseAddress + OFS_TBxCTL) |= (param->clockSource +
TIMER_B_STOP_MODE +
param->timerClear +
param->timerInterruptEnable_TBIE +
((param->clockSourceDivider >>
3) << 6));
if(param->startTimer)
{
HWREG16(baseAddress + OFS_TBxCTL) |= TIMER_B_UPDOWN_MODE;
}
if(TIMER_B_CCIE_CCR0_INTERRUPT_ENABLE ==
param->captureCompareInterruptEnable_CCR0_CCIE)
{
HWREG16(baseAddress +
OFS_TBxCCTL0) |= TIMER_B_CCIE_CCR0_INTERRUPT_ENABLE;
}
else
{
HWREG16(baseAddress +
OFS_TBxCCTL0) &= ~TIMER_B_CCIE_CCR0_INTERRUPT_ENABLE;
}
HWREG16(baseAddress + OFS_TBxCCR0) = param->timerPeriod;
}
void Timer_B_initCaptureMode(uint16_t baseAddress,
Timer_B_initCaptureModeParam *param)
{
HWREG16(baseAddress + param->captureRegister) |= CAP;
HWREG16(baseAddress + param->captureRegister) &=
~(TIMER_B_CAPTUREMODE_RISING_AND_FALLING_EDGE +
TIMER_B_CAPTURE_INPUTSELECT_Vcc +
TIMER_B_CAPTURE_SYNCHRONOUS +
TIMER_B_DO_CLEAR +
TIMER_B_TBIE_INTERRUPT_ENABLE +
CM_3
);
HWREG16(baseAddress + param->captureRegister) |= (param->captureMode +
param->captureInputSelect
+
param->
synchronizeCaptureSource +
param->
captureInterruptEnable +
param->captureOutputMode
);
}
void Timer_B_initCompareMode(uint16_t baseAddress,
Timer_B_initCompareModeParam *param)
{
HWREG16(baseAddress + param->compareRegister) &= ~CAP;
HWREG16(baseAddress + param->compareRegister) &=
~(TIMER_B_CAPTURECOMPARE_INTERRUPT_ENABLE +
TIMER_B_OUTPUTMODE_RESET_SET
);
HWREG16(baseAddress +
param->compareRegister) |= (param->compareInterruptEnable +
param->compareOutputMode
);
HWREG16(baseAddress + param->compareRegister +
OFS_TBxR) = param->compareValue;
}
void Timer_B_enableInterrupt(uint16_t baseAddress)
{
HWREG16(baseAddress + OFS_TBxCTL) |= TBIE;
}
void Timer_B_disableInterrupt(uint16_t baseAddress)
{
HWREG16(baseAddress + OFS_TBxCTL) &= ~TBIE;
}
uint32_t Timer_B_getInterruptStatus(uint16_t baseAddress)
{
return (HWREG16(baseAddress + OFS_TBxCTL) & TBIFG);
}
void Timer_B_enableCaptureCompareInterrupt(uint16_t baseAddress,
uint16_t captureCompareRegister)
{
HWREG16(baseAddress + captureCompareRegister) |= CCIE;
}
void Timer_B_disableCaptureCompareInterrupt(uint16_t baseAddress,
uint16_t captureCompareRegister)
{
HWREG16(baseAddress + captureCompareRegister) &= ~CCIE;
}
uint32_t Timer_B_getCaptureCompareInterruptStatus(uint16_t baseAddress,
uint16_t captureCompareRegister,
uint16_t mask)
{
return (HWREG16(baseAddress + captureCompareRegister) & mask);
}
void Timer_B_clear(uint16_t baseAddress)
{
HWREG16(baseAddress + OFS_TBxCTL) |= TBCLR;
}
uint8_t Timer_B_getSynchronizedCaptureCompareInput(uint16_t baseAddress,
uint16_t captureCompareRegister,
uint16_t synchronized)
{
if(HWREG16(baseAddress + captureCompareRegister) & synchronized)
{
return (TIMER_B_CAPTURECOMPARE_INPUT_HIGH);
}
else
{
return (TIMER_B_CAPTURECOMPARE_INPUT_LOW);
}
}
uint8_t Timer_B_getOutputForOutputModeOutBitValue(uint16_t baseAddress,
uint16_t captureCompareRegister)
{
if(HWREG16(baseAddress + captureCompareRegister) & OUT)
{
return (TIMER_B_OUTPUTMODE_OUTBITVALUE_HIGH);
}
else
{
return (TIMER_B_OUTPUTMODE_OUTBITVALUE_LOW);
}
}
uint16_t Timer_B_getCaptureCompareCount(uint16_t baseAddress,
uint16_t captureCompareRegister)
{
return (HWREG16(baseAddress + OFS_TBxR + captureCompareRegister));
}
void Timer_B_setOutputForOutputModeOutBitValue(uint16_t baseAddress,
uint16_t captureCompareRegister,
uint8_t outputModeOutBitValue)
{
HWREG16(baseAddress + captureCompareRegister) &= ~OUT;
HWREG16(baseAddress + captureCompareRegister) |= outputModeOutBitValue;
}
void Timer_B_outputPWM(uint16_t baseAddress,
Timer_B_outputPWMParam *param)
{
HWREG16(baseAddress + OFS_TBxCTL) &=
~(TIMER_B_CLOCKSOURCE_INVERTED_EXTERNAL_TXCLK +
TIMER_B_UPDOWN_MODE + TIMER_B_DO_CLEAR +
TIMER_B_TBIE_INTERRUPT_ENABLE
);
HWREG16(baseAddress + OFS_TBxEX0) &= ~TBIDEX_7;
HWREG16(baseAddress + OFS_TBxEX0) |= param->clockSourceDivider & 0x7;
HWREG16(baseAddress + OFS_TBxCTL) |= (param->clockSource +
TIMER_B_UP_MODE +
TIMER_B_DO_CLEAR +
((param->clockSourceDivider >>
3) << 6));
HWREG16(baseAddress + OFS_TBxCCR0) = param->timerPeriod;
HWREG16(baseAddress + OFS_TBxCCTL0) &=
~(TIMER_B_CAPTURECOMPARE_INTERRUPT_ENABLE +
TIMER_B_OUTPUTMODE_RESET_SET
);
HWREG16(baseAddress + param->compareRegister) |= param->compareOutputMode;
HWREG16(baseAddress + param->compareRegister + OFS_TBxR) = param->dutyCycle;
}
void Timer_B_stop(uint16_t baseAddress)
{
HWREG16(baseAddress + OFS_TBxCTL) &= ~MC_3;
}
void Timer_B_setCompareValue(uint16_t baseAddress,
uint16_t compareRegister,
uint16_t compareValue)
{
HWREG16(baseAddress + compareRegister + OFS_TBxR) = compareValue;
}
void Timer_B_clearTimerInterrupt(uint16_t baseAddress)
{
HWREG16(baseAddress + OFS_TBxCTL) &= ~TBIFG;
}
void Timer_B_clearCaptureCompareInterrupt(uint16_t baseAddress,
uint16_t captureCompareRegister)
{
HWREG16(baseAddress + captureCompareRegister) &= ~CCIFG;
}
void Timer_B_selectCounterLength(uint16_t baseAddress,
uint16_t counterLength)
{
HWREG16(baseAddress + OFS_TBxCTL) &= ~CNTL_3;
HWREG16(baseAddress + OFS_TBxCTL) |= counterLength;
}
void Timer_B_selectLatchingGroup(uint16_t baseAddress,
uint16_t groupLatch)
{
HWREG16(baseAddress + OFS_TBxCTL) &= ~TBCLGRP_3;
HWREG16(baseAddress + OFS_TBxCTL) |= groupLatch;
}
void Timer_B_initCompareLatchLoadEvent(uint16_t baseAddress,
uint16_t compareRegister,
uint16_t compareLatchLoadEvent)
{
HWREG16(baseAddress + compareRegister) &= ~CLLD_3;
HWREG16(baseAddress + compareRegister) |= compareLatchLoadEvent;
}
uint16_t Timer_B_getCounterValue(uint16_t baseAddress)
{
uint16_t voteOne, voteTwo, res;
voteTwo = HWREG16(baseAddress + OFS_TBxR);
do
{
voteOne = voteTwo;
voteTwo = HWREG16(baseAddress + OFS_TBxR);
if(voteTwo > voteOne)
{
res = voteTwo - voteOne;
}
else if(voteOne > voteTwo)
{
res = voteOne - voteTwo;
}
else
{
res = 0;
}
}
while(res > TIMER_B_THRESHOLD);
return(voteTwo);
}
void Timer_B_setOutputMode(uint16_t baseAddress,
uint16_t compareRegister,
uint16_t compareOutputMode)
{
uint16_t temp = HWREG16(baseAddress + compareRegister);
HWREG16(baseAddress +
compareRegister) = temp & ~(OUTMOD_7) | compareOutputMode;
}
void Timer_B_selectOutputHighImpedanceTrigger(uint16_t baseAddress,
uint8_t triggerSelect)
{
#ifdef TB0TRGSEL
if(baseAddress == TIMER_B0_BASE)
{
HWREG16(SYS_BASE + OFS_SYSCFG2) &= ~TB0TRGSEL;
HWREG16(SYS_BASE + OFS_SYSCFG2) |= triggerSelect << 15;
}
#endif
#ifdef TB1TRGSEL
if(baseAddress == TIMER_B1_BASE)
{
HWREG16(SYS_BASE + OFS_SYSCFG2) &= ~TB1TRGSEL;
HWREG16(SYS_BASE + OFS_SYSCFG2) |= triggerSelect << 14;
}
#endif
}
void Timer_B_remapPins(uint16_t baseAddress,
uint8_t pinsSelect)
{
#ifdef TBRMP
HWREG16(SYS_BASE + OFS_SYSCFG3) &= ~TBRMP;
HWREG16(SYS_BASE + OFS_SYSCFG3) |= pinsSelect << 1;
#endif
}
#endif
//*****************************************************************************
//
//! Close the doxygen group for timer_b_api
//! @}
//
//*****************************************************************************

File diff suppressed because it is too large Load Diff

View File

@ -1,239 +0,0 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
//
// tlv.c - Driver for the tlv Module.
//
//*****************************************************************************
//*****************************************************************************
//
//! \addtogroup tlv_api tlv
//! @{
//
//*****************************************************************************
#include "inc/hw_memmap.h"
#ifdef __MSP430_HAS_TLV__
#include "tlv.h"
#include <assert.h>
void TLV_getInfo(uint8_t tag,
uint8_t instance,
uint8_t *length,
uint16_t **data_address)
{
// TLV Structure Start Address
char *TLV_address = (char *)TLV_START;
while((TLV_address < (char *)TLV_END)
&& ((*TLV_address != tag) || instance) // check for tag and instance
&& (*TLV_address != TLV_TAGEND)) // do range check first
{
if(*TLV_address == tag)
{
// repeat till requested instance is reached
instance--;
}
// add (Current TAG address + LENGTH) + 2
TLV_address += *(TLV_address + 1) + 2;
}
// Check if Tag match happened..
if(*TLV_address == tag)
{
// Return length = Address + 1
*length = *(TLV_address + 1);
// Return address of first data/value info = Address + 2
*data_address = (uint16_t *)(TLV_address + 2);
}
// If there was no tag match and the end of TLV structure was reached..
else
{
// Return 0 for TAG not found
*length = 0;
// Return 0 for TAG not found
*data_address = 0;
}
}
uint16_t TLV_getDeviceType()
{
uint16_t *pDeviceType = (uint16_t *)TLV_DEVICE_ID_0;
// Return Value from TLV Table
return(pDeviceType[0]);
}
uint16_t TLV_getMemory(uint8_t instance)
{
uint8_t *pPDTAG;
uint8_t bPDTAG_bytes;
uint16_t count;
// set tag for word access comparison
instance *= 2;
// TLV access Function Call
// Get Peripheral data pointer
TLV_getInfo(TLV_PDTAG,
0,
&bPDTAG_bytes,
(uint16_t **)&pPDTAG
);
for(count = 0; count <= instance; count += 2)
{
if(pPDTAG[count] == 0)
{
// Return 0 if end reached
return(0);
}
if(count == instance)
{
return (pPDTAG[count] | pPDTAG[count + 1] << 8);
}
}
// Return 0: not found
return(0);
}
uint16_t TLV_getPeripheral(uint8_t tag,
uint8_t instance)
{
uint8_t *pPDTAG;
uint8_t bPDTAG_bytes;
uint16_t count = 0;
uint16_t pcount = 0;
// Get Peripheral data pointer
TLV_getInfo(TLV_PDTAG,
0,
&bPDTAG_bytes,
(uint16_t **)&pPDTAG
);
// read memory configuration from TLV to get offset for Peripherals
while(TLV_getMemory(count))
{
count++;
}
// get number of Peripheral entries
pcount = pPDTAG[count * 2 + 1];
// inc count to first Periperal
count++;
// adjust point to first address of Peripheral
pPDTAG += count * 2;
// set counter back to 0
count = 0;
// align pcount for work comparision
pcount *= 2;
// TLV access Function Call
for(count = 0; count <= pcount; count += 2)
{
if(pPDTAG[count + 1] == tag)
{
// test if required Peripheral is found
if(instance > 0)
{
// test if required instance is found
instance--;
}
else
{
// Return found data
return (pPDTAG[count] | pPDTAG[count + 1] << 8);
}
}
}
// Return 0: not found
return(0);
}
uint8_t TLV_getInterrupt(uint8_t tag)
{
uint8_t *pPDTAG;
uint8_t bPDTAG_bytes;
uint16_t count = 0;
uint16_t pcount = 0;
// Get Peripheral data pointer
TLV_getInfo(TLV_PDTAG,
0,
&bPDTAG_bytes,
(uint16_t **)&pPDTAG
);
// read memory configuration from TLV to get offset for Peripherals
while(TLV_getMemory(count))
{
count++;
}
pcount = pPDTAG[count * 2 + 1];
// inc count to first Periperal
count++;
// adjust point to first address of Peripheral
pPDTAG += (pcount + count) * 2;
// set counter back to 0
count = 0;
// TLV access Function Call
for(count = 0; count <= tag; count += 2)
{
if(pPDTAG[count] == 0)
{
// Return 0: not found/end of table
return(0);
}
if(count == tag)
{
// Return found data
return (pPDTAG[count]);
}
}
// Return 0: not found
return(0);
}
#endif
//*****************************************************************************
//
//! Close the doxygen group for tlv_api
//! @}
//
//*****************************************************************************

View File

@ -1,441 +0,0 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
//
// tlv.h - Driver for the TLV Module.
//
//*****************************************************************************
#ifndef __MSP430WARE_TLV_H__
#define __MSP430WARE_TLV_H__
#include "inc/hw_memmap.h"
#ifdef __MSP430_HAS_TLV__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
#include "inc/hw_memmap.h"
//******************************************************************************
//
// TLV Data Types
//
//******************************************************************************
struct s_TLV_Die_Record
{
uint32_t wafer_id;
uint16_t die_x_position;
uint16_t die_y_position;
uint16_t test_results;
};
struct s_TLV_ADC_Cal_Data
{
uint16_t adc_gain_factor;
int16_t adc_offset;
uint16_t adc_ref15_30_temp;
uint16_t adc_ref15_85_temp;
uint16_t adc_ref20_30_temp;
uint16_t adc_ref20_85_temp;
uint16_t adc_ref25_30_temp;
uint16_t adc_ref25_85_temp;
};
struct s_TLV_Timer_D_Cal_Data
{
uint16_t TDH0CTL1_64;
uint16_t TDH0CTL1_128;
uint16_t TDH0CTL1_200;
uint16_t TDH0CTL1_256;
};
struct s_TLV_REF_Cal_Data
{
uint16_t ref_ref15;
uint16_t ref_ref20;
uint16_t ref_ref25;
};
struct s_Peripheral_Memory_Data
{
uint16_t memory_1;
uint16_t memory_2;
uint16_t memory_3;
uint16_t memory_4;
};
//*****************************************************************************
//
// The following are values that can be passed to the tag parameter for
// functions: TLV_getInfo().
//
//*****************************************************************************
#define TLV_TAG_LDTAG TLV_LDTAG
#define TLV_TAG_PDTAG TLV_PDTAG
#define TLV_TAG_Reserved3 TLV_Reserved3
#define TLV_TAG_Reserved4 TLV_Reserved4
#define TLV_TAG_BLANK TLV_BLANK
#define TLV_TAG_Reserved6 TLV_Reserved6
#define TLV_TAG_Reserved7 TLV_Reserved7
#define TLV_TAG_TAGEND TLV_TAGEND
#define TLV_TAG_TAGEXT TLV_TAGEXT
#define TLV_TAG_TIMER_D_CAL TLV_TIMERDCAL
#define TLV_DEVICE_ID_0 0x1A04
#define TLV_DEVICE_ID_1 0x1A05
#define TLV_TAG_DIERECORD TLV_DIERECORD
#define TLV_TAG_ADCCAL TLV_ADCCAL
#define TLV_TAG_ADC12CAL TLV_ADC12CAL
#define TLV_TAG_ADC10CAL TLV_ADC10CAL
#define TLV_TAG_REFCAL TLV_REFCAL
#define TLV_TAG_CTSD16CAL 0x1D
//*****************************************************************************
//
// The following are values that can be passed to the tag parameter for
// functions: TLV_getPeripheral().
//
//*****************************************************************************
#define TLV_PID_NO_MODULE (0x00)
#define TLV_PID_PORTMAPPING (0x10)
#define TLV_PID_MSP430CPUXV2 (0x23)
#define TLV_PID_JTAG (0x09)
#define TLV_PID_SBW (0x0F)
#define TLV_PID_EEM_XS (0x02)
#define TLV_PID_EEM_S (0x03)
#define TLV_PID_EEM_M (0x04)
#define TLV_PID_EEM_L (0x05)
#define TLV_PID_PMM (0x30)
#define TLV_PID_PMM_FR (0x32)
#define TLV_PID_FCTL (0x39)
#define TLV_PID_CRC16 (0x3C)
#define TLV_PID_CRC16_RB (0x3D)
#define TLV_PID_WDT_A (0x40)
#define TLV_PID_SFR (0x41)
#define TLV_PID_SYS (0x42)
#define TLV_PID_RAMCTL (0x44)
#define TLV_PID_DMA_1 (0x46)
#define TLV_PID_DMA_3 (0x47)
#define TLV_PID_UCS (0x48)
#define TLV_PID_DMA_6 (0x4A)
#define TLV_PID_DMA_2 (0x4B)
#define TLV_PID_PORT1_2 (0x51)
#define TLV_PID_PORT3_4 (0x52)
#define TLV_PID_PORT5_6 (0x53)
#define TLV_PID_PORT7_8 (0x54)
#define TLV_PID_PORT9_10 (0x55)
#define TLV_PID_PORT11_12 (0x56)
#define TLV_PID_PORTU (0x5E)
#define TLV_PID_PORTJ (0x5F)
#define TLV_PID_TA2 (0x60)
#define TLV_PID_TA3 (0x61)
#define TLV_PID_TA5 (0x62)
#define TLV_PID_TA7 (0x63)
#define TLV_PID_TB3 (0x65)
#define TLV_PID_TB5 (0x66)
#define TLV_PID_TB7 (0x67)
#define TLV_PID_RTC (0x68)
#define TLV_PID_BT_RTC (0x69)
#define TLV_PID_BBS (0x6A)
#define TLV_PID_RTC_B (0x6B)
#define TLV_PID_TD2 (0x6C)
#define TLV_PID_TD3 (0x6D)
#define TLV_PID_TD5 (0x6E)
#define TLV_PID_TD7 (0x6F)
#define TLV_PID_TEC (0x70)
#define TLV_PID_RTC_C (0x71)
#define TLV_PID_AES (0x80)
#define TLV_PID_MPY16 (0x84)
#define TLV_PID_MPY32 (0x85)
#define TLV_PID_MPU (0x86)
#define TLV_PID_USCI_AB (0x90)
#define TLV_PID_USCI_A (0x91)
#define TLV_PID_USCI_B (0x92)
#define TLV_PID_EUSCI_A (0x94)
#define TLV_PID_EUSCI_B (0x95)
#define TLV_PID_REF (0xA0)
#define TLV_PID_COMP_B (0xA8)
#define TLV_PID_COMP_D (0xA9)
#define TLV_PID_USB (0x98)
#define TLV_PID_LCD_B (0xB1)
#define TLV_PID_LCD_C (0xB2)
#define TLV_PID_DAC12_A (0xC0)
#define TLV_PID_SD16_B_1 (0xC8)
#define TLV_PID_SD16_B_2 (0xC9)
#define TLV_PID_SD16_B_3 (0xCA)
#define TLV_PID_SD16_B_4 (0xCB)
#define TLV_PID_SD16_B_5 (0xCC)
#define TLV_PID_SD16_B_6 (0xCD)
#define TLV_PID_SD16_B_7 (0xCE)
#define TLV_PID_SD16_B_8 (0xCF)
#define TLV_PID_ADC12_A (0xD1)
#define TLV_PID_ADC10_A (0xD3)
#define TLV_PID_ADC10_B (0xD4)
#define TLV_PID_SD16_A (0xD8)
#define TLV_PID_TI_BSL (0xFC)
//*****************************************************************************
//
// Prototypes for the APIs.
//
//*****************************************************************************
//*****************************************************************************
//
//! \brief Gets TLV Info
//!
//! The TLV structure uses a tag or base address to identify segments of the
//! table where information is stored. Some examples of TLV tags are Peripheral
//! Descriptor, Interrupts, Info Block and Die Record. This function retrieves
//! the value of a tag and the length of the tag.
//!
//! \param tag represents the tag for which the information needs to be
//! retrieved.
//! Valid values are:
//! - \b TLV_TAG_LDTAG
//! - \b TLV_TAG_PDTAG
//! - \b TLV_TAG_Reserved3
//! - \b TLV_TAG_Reserved4
//! - \b TLV_TAG_BLANK
//! - \b TLV_TAG_Reserved6
//! - \b TLV_TAG_Reserved7
//! - \b TLV_TAG_TAGEND
//! - \b TLV_TAG_TAGEXT
//! - \b TLV_TAG_TIMER_D_CAL
//! - \b TLV_DEVICE_ID_0
//! - \b TLV_DEVICE_ID_1
//! - \b TLV_TAG_DIERECORD
//! - \b TLV_TAG_ADCCAL
//! - \b TLV_TAG_ADC12CAL
//! - \b TLV_TAG_ADC10CAL
//! - \b TLV_TAG_REFCAL
//! - \b TLV_TAG_CTSD16CAL
//! \param instance In some cases a specific tag may have more than one
//! instance. For example there may be multiple instances of timer
//! calibration data present under a single Timer Cal tag. This variable
//! specifies the instance for which information is to be retrieved (0,
//! 1, etc.). When only one instance exists; 0 is passed.
//! \param length Acts as a return through indirect reference. The function
//! retrieves the value of the TLV tag length. This value is pointed to
//! by *length and can be used by the application level once the
//! function is called. If the specified tag is not found then the
//! pointer is null 0.
//! \param data_address acts as a return through indirect reference. Once the
//! function is called data_address points to the pointer that holds the
//! value retrieved from the specified TLV tag. If the specified tag is
//! not found then the pointer is null 0.
//!
//! \return None
//
//*****************************************************************************
extern void TLV_getInfo(uint8_t tag,
uint8_t instance,
uint8_t *length,
uint16_t **data_address);
//*****************************************************************************
//
//! \brief Retrieves the unique device ID from the TLV structure.
//!
//!
//! \return The device ID is returned as type uint16_t.
//
//*****************************************************************************
extern uint16_t TLV_getDeviceType(void);
//*****************************************************************************
//
//! \brief Gets memory information
//!
//! The Peripheral Descriptor tag is split into two portions a list of the
//! available flash memory blocks followed by a list of available peripherals.
//! This function is used to parse through the first portion and calculate the
//! total flash memory available in a device. The typical usage is to call the
//! TLV_getMemory which returns a non-zero value until the entire memory list
//! has been parsed. When a zero is returned, it indicates that all the memory
//! blocks have been counted and the next address holds the beginning of the
//! device peripheral list.
//!
//! \param instance In some cases a specific tag may have more than one
//! instance. This variable specifies the instance for which information
//! is to be retrieved (0, 1 etc). When only one instance exists; 0 is
//! passed.
//!
//! \return The returned value is zero if the end of the memory list is
//! reached.
//
//*****************************************************************************
extern uint16_t TLV_getMemory(uint8_t instance);
//*****************************************************************************
//
//! \brief Gets peripheral information from the TLV
//!
//! he Peripheral Descriptor tag is split into two portions a list of the
//! available flash memory blocks followed by a list of available peripherals.
//! This function is used to parse through the second portion and can be used
//! to check if a specific peripheral is present in a device. The function
//! calls TLV_getPeripheral() recursively until the end of the memory list and
//! consequently the beginning of the peripheral list is reached. <
//!
//! \param tag represents represents the tag for a specific peripheral for
//! which the information needs to be retrieved. In the header file tlv.
//! h specific peripheral tags are pre-defined, for example USCIA_B and
//! TA0 are defined as TLV_PID_USCI_AB and TLV_PID_TA2 respectively.
//! Valid values are:
//! - \b TLV_PID_NO_MODULE - No Module
//! - \b TLV_PID_PORTMAPPING - Port Mapping
//! - \b TLV_PID_MSP430CPUXV2 - MSP430CPUXV2
//! - \b TLV_PID_JTAG - JTAG
//! - \b TLV_PID_SBW - SBW
//! - \b TLV_PID_EEM_XS - EEM X-Small
//! - \b TLV_PID_EEM_S - EEM Small
//! - \b TLV_PID_EEM_M - EEM Medium
//! - \b TLV_PID_EEM_L - EEM Large
//! - \b TLV_PID_PMM - PMM
//! - \b TLV_PID_PMM_FR - PMM FRAM
//! - \b TLV_PID_FCTL - Flash
//! - \b TLV_PID_CRC16 - CRC16
//! - \b TLV_PID_CRC16_RB - CRC16 Reverse
//! - \b TLV_PID_WDT_A - WDT_A
//! - \b TLV_PID_SFR - SFR
//! - \b TLV_PID_SYS - SYS
//! - \b TLV_PID_RAMCTL - RAMCTL
//! - \b TLV_PID_DMA_1 - DMA 1
//! - \b TLV_PID_DMA_3 - DMA 3
//! - \b TLV_PID_UCS - UCS
//! - \b TLV_PID_DMA_6 - DMA 6
//! - \b TLV_PID_DMA_2 - DMA 2
//! - \b TLV_PID_PORT1_2 - Port 1 + 2 / A
//! - \b TLV_PID_PORT3_4 - Port 3 + 4 / B
//! - \b TLV_PID_PORT5_6 - Port 5 + 6 / C
//! - \b TLV_PID_PORT7_8 - Port 7 + 8 / D
//! - \b TLV_PID_PORT9_10 - Port 9 + 10 / E
//! - \b TLV_PID_PORT11_12 - Port 11 + 12 / F
//! - \b TLV_PID_PORTU - Port U
//! - \b TLV_PID_PORTJ - Port J
//! - \b TLV_PID_TA2 - Timer A2
//! - \b TLV_PID_TA3 - Timer A1
//! - \b TLV_PID_TA5 - Timer A5
//! - \b TLV_PID_TA7 - Timer A7
//! - \b TLV_PID_TB3 - Timer B3
//! - \b TLV_PID_TB5 - Timer B5
//! - \b TLV_PID_TB7 - Timer B7
//! - \b TLV_PID_RTC - RTC
//! - \b TLV_PID_BT_RTC - BT + RTC
//! - \b TLV_PID_BBS - Battery Backup Switch
//! - \b TLV_PID_RTC_B - RTC_B
//! - \b TLV_PID_TD2 - Timer D2
//! - \b TLV_PID_TD3 - Timer D1
//! - \b TLV_PID_TD5 - Timer D5
//! - \b TLV_PID_TD7 - Timer D7
//! - \b TLV_PID_TEC - Timer Event Control
//! - \b TLV_PID_RTC_C - RTC_C
//! - \b TLV_PID_AES - AES
//! - \b TLV_PID_MPY16 - MPY16
//! - \b TLV_PID_MPY32 - MPY32
//! - \b TLV_PID_MPU - MPU
//! - \b TLV_PID_USCI_AB - USCI_AB
//! - \b TLV_PID_USCI_A - USCI_A
//! - \b TLV_PID_USCI_B - USCI_B
//! - \b TLV_PID_EUSCI_A - eUSCI_A
//! - \b TLV_PID_EUSCI_B - eUSCI_B
//! - \b TLV_PID_REF - Shared Reference
//! - \b TLV_PID_COMP_B - COMP_B
//! - \b TLV_PID_COMP_D - COMP_D
//! - \b TLV_PID_USB - USB
//! - \b TLV_PID_LCD_B - LCD_B
//! - \b TLV_PID_LCD_C - LCD_C
//! - \b TLV_PID_DAC12_A - DAC12_A
//! - \b TLV_PID_SD16_B_1 - SD16_B 1 Channel
//! - \b TLV_PID_SD16_B_2 - SD16_B 2 Channel
//! - \b TLV_PID_SD16_B_3 - SD16_B 3 Channel
//! - \b TLV_PID_SD16_B_4 - SD16_B 4 Channel
//! - \b TLV_PID_SD16_B_5 - SD16_B 5 Channel
//! - \b TLV_PID_SD16_B_6 - SD16_B 6 Channel
//! - \b TLV_PID_SD16_B_7 - SD16_B 7 Channel
//! - \b TLV_PID_SD16_B_8 - SD16_B 8 Channel
//! - \b TLV_PID_ADC12_A - ADC12_A
//! - \b TLV_PID_ADC10_A - ADC10_A
//! - \b TLV_PID_ADC10_B - ADC10_B
//! - \b TLV_PID_SD16_A - SD16_A
//! - \b TLV_PID_TI_BSL - BSL
//! \param instance In some cases a specific tag may have more than one
//! instance. For example a device may have more than a single USCI
//! module, each of which is defined by an instance number 0, 1, 2, etc.
//! When only one instance exists; 0 is passed.
//!
//! \return The returned value is zero if the specified tag value (peripheral)
//! is not available in the device.
//
//*****************************************************************************
extern uint16_t TLV_getPeripheral(uint8_t tag,
uint8_t instance);
//*****************************************************************************
//
//! \brief Get interrupt information from the TLV
//!
//! This function is used to retrieve information on available interrupt
//! vectors. It allows the user to check if a specific interrupt vector is
//! defined in a given device.
//!
//! \param tag represents the tag for the interrupt vector. Interrupt vector
//! tags number from 0 to N depending on the number of available
//! interrupts. Refer to the device datasheet for a list of available
//! interrupts.
//!
//! \return The returned value is zero is the specified interrupt vector is not
//! defined.
//
//*****************************************************************************
extern uint8_t TLV_getInterrupt(uint8_t tag);
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif
#endif // __MSP430WARE_TLV_H__

View File

@ -1,101 +0,0 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
//
// wdt_a.c - Driver for the wdt_a Module.
//
//*****************************************************************************
//*****************************************************************************
//
//! \addtogroup wdt_a_api wdt_a
//! @{
//
//*****************************************************************************
#include "inc/hw_memmap.h"
#ifdef __MSP430_HAS_WDT_A__
#include "wdt_a.h"
#include <assert.h>
void WDT_A_hold(uint16_t baseAddress)
{
// Set Hold bit
uint8_t newWDTStatus =
((HWREG16(baseAddress + OFS_WDTCTL) & 0x00FF) | WDTHOLD);
HWREG16(baseAddress + OFS_WDTCTL) = WDTPW + newWDTStatus;
}
void WDT_A_start(uint16_t baseAddress)
{
// Reset Hold bit
uint8_t newWDTStatus =
((HWREG16(baseAddress + OFS_WDTCTL) & 0x00FF) & ~(WDTHOLD));
HWREG16(baseAddress + OFS_WDTCTL) = WDTPW + newWDTStatus;
}
void WDT_A_resetTimer(uint16_t baseAddress)
{
// Set Counter Clear bit
uint8_t newWDTStatus =
((HWREG16(baseAddress + OFS_WDTCTL) & 0x00FF) | WDTCNTCL);
HWREG16(baseAddress + OFS_WDTCTL) = WDTPW + newWDTStatus;
}
void WDT_A_initWatchdogTimer(uint16_t baseAddress,
uint8_t clockSelect,
uint8_t clockDivider)
{
HWREG16(baseAddress + OFS_WDTCTL) =
WDTPW + WDTCNTCL + WDTHOLD + clockSelect + clockDivider;
}
void WDT_A_initIntervalTimer(uint16_t baseAddress,
uint8_t clockSelect,
uint8_t clockDivider)
{
HWREG16(baseAddress + OFS_WDTCTL) =
WDTPW + WDTCNTCL + WDTHOLD + WDTTMSEL + clockSelect + clockDivider;
}
#endif
//*****************************************************************************
//
//! Close the doxygen group for wdt_a_api
//! @}
//
//*****************************************************************************

View File

@ -1,210 +0,0 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
//
// wdt_a.h - Driver for the WDT_A Module.
//
//*****************************************************************************
#ifndef __MSP430WARE_WDT_A_H__
#define __MSP430WARE_WDT_A_H__
#include "inc/hw_memmap.h"
#ifdef __MSP430_HAS_WDT_A__
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
// The following are values that can be passed to the clockSelect parameter for
// functions: WDT_A_initWatchdogTimer(), and WDT_A_initIntervalTimer().
//
//*****************************************************************************
#define WDT_A_CLOCKSOURCE_SMCLK (WDTSSEL_0)
#define WDT_A_CLOCKSOURCE_ACLK (WDTSSEL_1)
#define WDT_A_CLOCKSOURCE_VLOCLK (WDTSSEL_2)
#define WDT_A_CLOCKSOURCE_XCLK (WDTSSEL_3)
//*****************************************************************************
//
// The following are values that can be passed to the clockDivider parameter
// for functions: WDT_A_initWatchdogTimer(), and WDT_A_initIntervalTimer().
//
//*****************************************************************************
#define WDT_A_CLOCKDIVIDER_2G (WDTIS_0)
#define WDT_A_CLOCKDIVIDER_128M (WDTIS_1)
#define WDT_A_CLOCKDIVIDER_8192K (WDTIS_2)
#define WDT_A_CLOCKDIVIDER_512K (WDTIS_3)
#define WDT_A_CLOCKDIVIDER_32K (WDTIS_4)
#define WDT_A_CLOCKDIVIDER_8192 (WDTIS_5)
#define WDT_A_CLOCKDIVIDER_512 (WDTIS_6)
#define WDT_A_CLOCKDIVIDER_64 (WDTIS_7)
//*****************************************************************************
//
// Prototypes for the APIs.
//
//*****************************************************************************
//*****************************************************************************
//
//! \brief Holds the Watchdog Timer.
//!
//! This function stops the watchdog timer from running, that way no interrupt
//! or PUC is asserted.
//!
//! \param baseAddress is the base address of the WDT_A module.
//!
//! \return None
//
//*****************************************************************************
extern void WDT_A_hold(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Starts the Watchdog Timer.
//!
//! This function starts the watchdog timer functionality to start counting
//! again.
//!
//! \param baseAddress is the base address of the WDT_A module.
//!
//! \return None
//
//*****************************************************************************
extern void WDT_A_start(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Resets the timer counter of the Watchdog Timer.
//!
//! This function resets the watchdog timer to 0x0000h.
//!
//! \param baseAddress is the base address of the WDT_A module.
//!
//! \return None
//
//*****************************************************************************
extern void WDT_A_resetTimer(uint16_t baseAddress);
//*****************************************************************************
//
//! \brief Sets the clock source for the Watchdog Timer in watchdog mode.
//!
//! This function sets the watchdog timer in watchdog mode, which will cause a
//! PUC when the timer overflows. When in the mode, a PUC can be avoided with a
//! call to WDT_A_resetTimer() before the timer runs out.
//!
//! \param baseAddress is the base address of the WDT_A module.
//! \param clockSelect is the clock source that the watchdog timer will use.
//! Valid values are:
//! - \b WDT_A_CLOCKSOURCE_SMCLK [Default]
//! - \b WDT_A_CLOCKSOURCE_ACLK
//! - \b WDT_A_CLOCKSOURCE_VLOCLK
//! - \b WDT_A_CLOCKSOURCE_XCLK
//! \n Modified bits are \b WDTSSEL of \b WDTCTL register.
//! \param clockDivider is the divider of the clock source, in turn setting the
//! watchdog timer interval.
//! Valid values are:
//! - \b WDT_A_CLOCKDIVIDER_2G
//! - \b WDT_A_CLOCKDIVIDER_128M
//! - \b WDT_A_CLOCKDIVIDER_8192K
//! - \b WDT_A_CLOCKDIVIDER_512K
//! - \b WDT_A_CLOCKDIVIDER_32K [Default]
//! - \b WDT_A_CLOCKDIVIDER_8192
//! - \b WDT_A_CLOCKDIVIDER_512
//! - \b WDT_A_CLOCKDIVIDER_64
//! \n Modified bits are \b WDTIS and \b WDTHOLD of \b WDTCTL register.
//!
//! \return None
//
//*****************************************************************************
extern void WDT_A_initWatchdogTimer(uint16_t baseAddress,
uint8_t clockSelect,
uint8_t clockDivider);
//*****************************************************************************
//
//! \brief Sets the clock source for the Watchdog Timer in timer interval mode.
//!
//! This function sets the watchdog timer as timer interval mode, which will
//! assert an interrupt without causing a PUC.
//!
//! \param baseAddress is the base address of the WDT_A module.
//! \param clockSelect is the clock source that the watchdog timer will use.
//! Valid values are:
//! - \b WDT_A_CLOCKSOURCE_SMCLK [Default]
//! - \b WDT_A_CLOCKSOURCE_ACLK
//! - \b WDT_A_CLOCKSOURCE_VLOCLK
//! - \b WDT_A_CLOCKSOURCE_XCLK
//! \n Modified bits are \b WDTSSEL of \b WDTCTL register.
//! \param clockDivider is the divider of the clock source, in turn setting the
//! watchdog timer interval.
//! Valid values are:
//! - \b WDT_A_CLOCKDIVIDER_2G
//! - \b WDT_A_CLOCKDIVIDER_128M
//! - \b WDT_A_CLOCKDIVIDER_8192K
//! - \b WDT_A_CLOCKDIVIDER_512K
//! - \b WDT_A_CLOCKDIVIDER_32K [Default]
//! - \b WDT_A_CLOCKDIVIDER_8192
//! - \b WDT_A_CLOCKDIVIDER_512
//! - \b WDT_A_CLOCKDIVIDER_64
//! \n Modified bits are \b WDTIS and \b WDTHOLD of \b WDTCTL register.
//!
//! \return None
//
//*****************************************************************************
extern void WDT_A_initIntervalTimer(uint16_t baseAddress,
uint8_t clockSelect,
uint8_t clockDivider);
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif
#endif // __MSP430WARE_WDT_A_H__

View File

@ -1,5 +1,5 @@
/* --COPYRIGHT--,BSD /* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated * Copyright (c) 2019, Texas Instruments Incorporated
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -29,25 +29,43 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* --/COPYRIGHT--*/ * --/COPYRIGHT--*/
/******************************************************************* //*****************************************************************************
* * // Config_Common.h
* This file is a generic ROM include file, that * //
* helps find the appropriate ROM device header file * // Configuration definitions
* * // Texas Instruments, Inc.
*******************************************************************/ #ifndef __CONFIG_COMMON_H__
#define __CONFIG_COMMON_H__
#ifndef __MSP430_ROM_DRIVERLIB_H__ #include <msp430.h>
#define __MSP430_ROM_DRIVERLIB_H__ #include <stdint.h>
#include <stdbool.h>
#if defined(__MSP430FR2532__) || defined (__MSP430FR2533__) \
|| defined (__MSP430FR2632__) || defined (__MSP430FR2633__)
#include "rom_headers/rom_driverlib_fr253x_fr263x.h"
#elif defined (__MSP430FR2355__) || defined (__MSP430FR2353__)
#include "rom_headers/rom_driverlib_fr235x.h"
#if defined(__TI_COMPILER_VERSION__)
#define __persistent
#define __no_init
#elif defined (__IAR_SYSTEMS_ICC__)
#else #else
#error "No driverlib ROM functions found for this device" #error Compiler not supported!
#endif #endif
#endif /* #ifndef __MSP430_ROM_DRIVERLIB_H__ */ //! \brief CPU Active Frequency in Hz.
//!
#define CPU_FREQ_HZ (8000000)
//! \brief CPU Active Frequency in MHz.
//!
#define CPU_FREQ_MHZ (CPU_FREQ_HZ/1000000)
//! \brief High Speed Bus Frequency in Hz.
//! Used by High Speed peripherals such as UART.
//!
#define HSBUS_FREQ_HZ (8000000)
//! \brief High Speed Bus Frequency in MHz.
//! Used by High Speed peripherals such as UART.
//!
#define HSBUS_FREQ_MHZ (HSBUS_FREQ_HZ/1000000)
//! \brief Low Speed Bus Frequency in Hz.
//! Used by Low Speed peripherals such as LPM timers.
//!
#define LSBUS_FREQ_HZ (32768)
#endif //__CONFIG_COMMON_H__

112
include/GUI_JSON.h Executable file
View File

@ -0,0 +1,112 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2019, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
// GUI Interface
//
// API to send and receive data from GUI using GUI Composer
// Texas Instruments, Inc.
// ******************************************************************************
#ifndef __GUI_H__
#define __GUI_H__
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
//! \brief Maximum string for RX
#ifndef MAX_STR_LEN
#define MAX_STR_LEN 64
#endif
//! \brief Enable GUI Reception of commands
#define GUI_RXCMD_ENABLE (1)
#if (GUI_RXCMD_ENABLE)
//! \brief Callback for RX Commands (called when command is received from GUI)
typedef void (*tGUI_RxCmdCallback)(char *);
//! \brief Structure for RX commands.
typedef struct
{
//!< RX Command (received from GUI)
char *stringCMD;
//!< Function executed if command is detected.
tGUI_RxCmdCallback callback;
} tGUI_RxCmd;
#endif
//! \brief Structure for TX commands.
typedef struct
{
//!< TX Command including sprintf formatting.
char *formattingStringCMD;
//!< Parameter sent with TX command.
void **param;
} tGUI_TxCmd;
//! \brief Initializes the GUI communication and protocol.
//!
//! \return none
extern void GUI_Init(void);
#if (GUI_RXCMD_ENABLE)
//! \brief Initializes structure to receive and process commands
//!
//! \param[in] RxCmdArray is a pointer to the array of RX Commands.
//! These commands will execute a callback function when received.
//! \param[in] size is the size of RxCmdArray.
//!
//! \return none
extern void GUI_InitRxCmd(const tGUI_RxCmd *RxCmdArray,
uint16_t size);
#endif
//! \brief Transmits an array of TX commands.
//!
//! \param[in] TXACmdrray is a pointer to the array of TX commands.
//! These commands will be sent with corresponding formatted data.
//! \param[in] size is the size of TxCmdArray.
//!
//! \return none
extern void GUI_TransmitData(const tGUI_TxCmd *TXCmdrray,
uint16_t size);
//! \brief Transmits a string to GUI.
//!
//! \param[in] str is the string to be sent.
//!
//! \return none
extern void GUI_TransmitStringBlocking(char *str);
#endif // __GUI_H__

View File

@ -1,5 +1,5 @@
/* --COPYRIGHT--,BSD /* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated * Copyright (c) 2020, Texas Instruments Incorporated
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -29,28 +29,30 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* --/COPYRIGHT--*/ * --/COPYRIGHT--*/
#include "inc/hw_memmap.h" //*****************************************************************************
// callbacks_JSON.h
//
// Application level callbacks using JSON
// Texas Instruments, Inc.
#include "adc.h" #include <msp430.h>
#include "crc.h" #include <stdbool.h>
#include "cs.h" #include <stdint.h>
#include "ecomp.h" #include <HAL.h>
#include "eusci_a_spi.h" #include <GUI_JSON.h>
#include "eusci_a_uart.h" #include <include/GUIComm.h>
#include "eusci_b_i2c.h" #include <include/QmathLib.h>
#include "eusci_b_spi.h"
#include "framctl.h"
#include "gpio.h" #ifndef INCLUDE_CALLBACKS_H_
#include "icc.h" #define INCLUDE_CALLBACKS_H_
#include "lcd_e.h"
#include "mpy32.h" // Global variables for the callbacks
#include "pmm.h" volatile bool bEnableSwitch;
#include "rtc.h" volatile _q qIncrement;
#include "sac.h"
#include "sfr.h" // Functions to receive data from GUI
#include "sysctl.h" extern void GUICallback_QMathData(char * string);
#include "tia.h" extern void GUICallback_boolEnable(char * string);
#include "timer_a.h"
#include "timer_b.h" #endif /* INCLUDE_CALLBACKS_H_ */
#include "tlv.h"
#include "wdt_a.h"

195
main.c
View File

@ -1,49 +1,168 @@
/** /* --COPYRIGHT--,BSD
* @file main.c * Copyright (c) 2020, Texas Instruments Incorporated
* @brief Entrypoint for the program. * All rights reserved.
* *
* @date 2025-07-02 * 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.
* --/COPYRIGHT--*/
//*****************************************************************************
// GUI Composer Simple JSON Demo using MSP430
//
// Texas Instruments, Inc.
// ******************************************************************************
#include <msp430.h> #include <msp430.h>
#include <driverlib.h>
#include <stdint.h>
#include <stdio.h>
#include <stdbool.h> #include <stdbool.h>
#include "src/keypad.h" #include <stdint.h>
#include "src/morse.h" #include <HAL.h>
#include "src/i2c.h" #include <GUI_JSON.h>
#include "src/lcd.h" #include <GUIComm.h>
#include "src/Board.h" #include <QmathLib.h>
#include "src/timer.h" #include <callbacks_JSON.h>
#include "src/state_machine.h"
/** On-board LED port and pin (used by Morse module) */ // Q8 is used in this demo because the variable qCounter ranges 0.0-100.0
#define LED_PORT GPIO_PORT_P1 /**< On-board LED port */
#define LED_PIN GPIO_PIN0 /**< On-board LED pin */
/** #define STR_LEN_TWO 2
* @brief Main application entry point. #define STR_LEN_SEVEN 7
*
* Sets up GPIO, UART, keypad interrupts, and enters low-power loop. // Global variable use to track the of state of GUI and counter values
* On keypress, echoes key over UART. volatile uint8_t u8Counter;
* volatile uint16_t u16Counter;
* @return Never returns volatile uint32_t u32Counter;
*/ volatile _q qCounter;
int main(void) volatile bool bUpdateGUI;
//! \brief RX Command structure.
//! The corresponding callback will be called when the command is
//! received from GUI.
//! Note: shorter command names take less time to process
const tGUI_RxCmd GUI_RXCommands[] =
{ {
/* Stop watchdog and unlock GPIO pins */ {"bEnable", GUICallback_boolEnable},
WDT_A_hold(WDT_A_BASE); {"u16Data", GUICallback_QMathData},
PMM_unlockLPM5(); };
/* Initialize on-board LED (used by Morse blinking) */ //! \brief Increments counters using MSP430 and sends data to GUI.
GPIO_setAsOutputPin(LED_PORT, LED_PIN); //!
GPIO_setOutputLowOnPin(LED_PORT, LED_PIN); //! \return none
void main(void)
{
WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer
init_timer(); // Initialize clock, GPIOs
i2c_init(); HAL_System_Init();
lcd_init();
sm_init(); // Initialize GUI layer
sm_loop(); GUI_Init();
GUI_InitRxCmd( &GUI_RXCommands[0],
(sizeof(GUI_RXCommands)/sizeof(GUI_RXCommands[0])) );
// Initialize variables
bUpdateGUI = false; // Update GUI first time
u8Counter = 50; // Counter8 will be updated on SW1 press in increments of 50
u16Counter = 5000; // Counter16 will be updated on button press in increments of 5000
u32Counter = 10000; // Counter32 will be updated on timer in increments of 10000
bEnableSwitch = true; // Switch enables updating QMath
qCounter = _Q(0.5); // QMath counter updated on timer based on boolean in increments of qIncrement
qIncrement = _Q(0.5);
// Configure SW1 and SW2 for interrupts (pins set as input with pull-up during GPIO initialization)
HAL_IO_InitButtons();
// Initialize a timer to update the counter
HAL_Timer_Init();
// Send default value of variables
GUIComm_sendUInt8("c1", STR_LEN_TWO, u8Counter);
GUIComm_sendUInt16("c2", STR_LEN_TWO, u16Counter);
GUIComm_sendUInt32("c3", STR_LEN_TWO, u32Counter);
GUIComm_sendInt16("c4", STR_LEN_TWO, (int16_t) qCounter);
GUIComm_sendInt16("u16Data", STR_LEN_SEVEN, (int16_t) qIncrement);
GUIComm_sendBool("bEnable", STR_LEN_SEVEN, bEnableSwitch);
__bis_SR_register(LPM3_bits | GIE); // Enter LPM3 w/interrupt
__enable_interrupt();
while (1)
{
while (bUpdateGUI == true)
{
GUIComm_sendUInt8("c1", STR_LEN_TWO, u8Counter);
GUIComm_sendUInt16("c2", STR_LEN_TWO, u16Counter);
GUIComm_sendUInt32("c3", STR_LEN_TWO, u32Counter);
if (bEnableSwitch == true)
{
GUIComm_sendInt16("c4", STR_LEN_TWO, (int16_t) qCounter);
}
bUpdateGUI = false;
}
__disable_interrupt();
if (bUpdateGUI == false)
{
__bis_SR_register(LPM3_bits | GIE); // Enter LPM3 w/interrupt
__no_operation(); // For debug
}
}
} }
//! \brief Function called by HAL when there is a periodic timer interrupt
//!
//! \return none
void TimerCallback(void)
{
// Update 32-bit counter
u32Counter += 10000;
bUpdateGUI = true;
if (bEnableSwitch == true)
{
qCounter += qIncrement;
if (qCounter > _Q(100.0))
{
qCounter = 0;
}
}
}
//! \brief Function called by HAL when SW1 is pressed
//!
//! \return none
void ButtonCallback_SW1(void)
{
u8Counter += 50;
}
//! \brief Function called by HAL when SW2 is pressed
//!
//! \return none
void ButtonCallback_SW2(void)
{
u16Counter += 5000;
}

View File

@ -1,248 +0,0 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2017, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
/**
* ===
* Board.h
* ===
* This file is meant to provide generic GPIO selection definitions that allows
* DriverLib to be used portably across different LaunchPads. The same module
* pin might not be populated on the same physical port and pin on different
* LaunchPads.
*
* This file is intended to be modified and updated by individual users based
* on application need. It will be initially populated according to common
* peripherals available on a LaunchPad board, but by all means not complete.
*
* GPIO_PRIMARY_MODULE_FUNCTION indicates Port SEL bits are 01
* GPIO_SECONDARY_MODULE_FUNCTION indicates Port SEL bits are 10
* GPIO_TERNARY_MODULE_FUNCTION indicates Port SEL bits are 11
* If the Port SEL bits are 00, the FUNCTION bits should be ignored
* Please consult device datasheet for more info, under "Input/Output Diagrams"
*
**/
#ifndef __BOARD_H__
#define __BOARD_H__
#ifdef __MSP430FR4133__
#define GPIO_PORT_LED1 GPIO_PORT_P1
#define GPIO_PIN_LED1 GPIO_PIN0
#define GPIO_PORT_LED2 GPIO_PORT_P4
#define GPIO_PIN_LED2 GPIO_PIN0
#define GPIO_PORT_S1 GPIO_PORT_P1
#define GPIO_PIN_S1 GPIO_PIN2
#define GPIO_PORT_ADC7 GPIO_PORT_P1
#define GPIO_PIN_ADC7 GPIO_PIN7
#define GPIO_FUNCTION_ADC7 GPIO_PRIMARY_MODULE_FUNCTION
#define GPIO_PORT_MCLK GPIO_PORT_P1
#define GPIO_PIN_MCLK GPIO_PIN4
#define GPIO_FUNCTION_MCLK GPIO_PRIMARY_MODULE_FUNCTION
#define GPIO_PORT_SMCLK GPIO_PORT_P8
#define GPIO_PIN_SMCLK GPIO_PIN0
#define GPIO_FUNCTION_SMCLK GPIO_PRIMARY_MODULE_FUNCTION
#define GPIO_PORT_ACLK GPIO_PORT_P8
#define GPIO_PIN_ACLK GPIO_PIN1
#define GPIO_FUNCTION_ACLK GPIO_PRIMARY_MODULE_FUNCTION
#define GPIO_PORT_UCA0TXD GPIO_PORT_P1
#define GPIO_PIN_UCA0TXD GPIO_PIN0
#define GPIO_FUNCTION_UCA0TXD GPIO_PRIMARY_MODULE_FUNCTION
#define GPIO_PORT_UCA0RXD GPIO_PORT_P1
#define GPIO_PIN_UCA0RXD GPIO_PIN1
#define GPIO_FUNCTION_UCA0RXD GPIO_PRIMARY_MODULE_FUNCTION
#define GPIO_PORT_UCB0SCL GPIO_PORT_P5
#define GPIO_PIN_UCB0SCL GPIO_PIN3
#define GPIO_FUNCTION_UCB0SCL GPIO_PRIMARY_MODULE_FUNCTION
#define GPIO_PORT_UCB0SDA GPIO_PORT_P5
#define GPIO_PIN_UCB0SDA GPIO_PIN2
#define GPIO_FUNCTION_UCB0SDA GPIO_PRIMARY_MODULE_FUNCTION
#endif // __MSP430FR4133__
#ifdef __MSP430FR2311__
#define GPIO_PORT_LED1 GPIO_PORT_P1
#define GPIO_PIN_LED1 GPIO_PIN0
#define GPIO_PORT_LED2 GPIO_PORT_P2
#define GPIO_PIN_LED2 GPIO_PIN0
#define GPIO_PORT_S1 GPIO_PORT_P1
#define GPIO_PIN_S1 GPIO_PIN1
#define GPIO_PORT_ADC7 GPIO_PORT_P1
#define GPIO_PIN_ADC7 GPIO_PIN7
#define GPIO_FUNCTION_ADC7 GPIO_PRIMARY_MODULE_FUNCTION
#define GPIO_PORT_MCLK GPIO_PORT_P2
#define GPIO_PIN_MCLK GPIO_PIN6
#define GPIO_FUNCTION_MCLK GPIO_PRIMARY_MODULE_FUNCTION
#define GPIO_PORT_SMCLK GPIO_PORT_P1
#define GPIO_PIN_SMCLK GPIO_PIN0
#define GPIO_FUNCTION_SMCLK GPIO_SECONDARY_MODULE_FUNCTION
#define GPIO_PORT_ACLK GPIO_PORT_P1
#define GPIO_PIN_ACLK GPIO_PIN1
#define GPIO_FUNCTION_ACLK GPIO_SECONDARY_MODULE_FUNCTION
#define GPIO_PORT_UCA0TXD GPIO_PORT_P1
#define GPIO_PIN_UCA0TXD GPIO_PIN7
#define GPIO_FUNCTION_UCA0TXD GPIO_PRIMARY_MODULE_FUNCTION
#define GPIO_PORT_UCA0RXD GPIO_PORT_P1
#define GPIO_PIN_UCA0RXD GPIO_PIN6
#define GPIO_FUNCTION_UCA0RXD GPIO_PRIMARY_MODULE_FUNCTION
#define GPIO_PORT_UCB0SCL GPIO_PORT_P1
#define GPIO_PIN_UCB0SCL GPIO_PIN3
#define GPIO_FUNCTION_UCB0SCL GPIO_PRIMARY_MODULE_FUNCTION
#define GPIO_PORT_UCB0SDA GPIO_PORT_P1
#define GPIO_PIN_UCB0SDA GPIO_PIN2
#define GPIO_FUNCTION_UCB0SDA GPIO_PRIMARY_MODULE_FUNCTION
#endif // __MSP430FR2311__
#ifdef __MSP430FR2433__
#define GPIO_PORT_LED1 GPIO_PORT_P1
#define GPIO_PIN_LED1 GPIO_PIN0
#define GPIO_PORT_LED2 GPIO_PORT_P1
#define GPIO_PIN_LED2 GPIO_PIN1
#define GPIO_PORT_S1 GPIO_PORT_P2
#define GPIO_PIN_S1 GPIO_PIN3
#define GPIO_PORT_S2 GPIO_PORT_P2
#define GPIO_PIN_S2 GPIO_PIN7
#define GPIO_PORT_ADC7 GPIO_PORT_P1
#define GPIO_PIN_ADC7 GPIO_PIN7
#define GPIO_FUNCTION_ADC7 GPIO_PRIMARY_MODULE_FUNCTION
#define GPIO_PORT_MCLK GPIO_PORT_P1
#define GPIO_PIN_MCLK GPIO_PIN3
#define GPIO_FUNCTION_MCLK GPIO_SECONDARY_MODULE_FUNCTION
#define GPIO_PORT_SMCLK GPIO_PORT_P1
#define GPIO_PIN_SMCLK GPIO_PIN7
#define GPIO_FUNCTION_SMCLK GPIO_SECONDARY_MODULE_FUNCTION
#define GPIO_PORT_ACLK GPIO_PORT_P2
#define GPIO_PIN_ACLK GPIO_PIN2
#define GPIO_FUNCTION_ACLK GPIO_SECONDARY_MODULE_FUNCTION
#define GPIO_PORT_UCA0TXD GPIO_PORT_P1
#define GPIO_PIN_UCA0TXD GPIO_PIN4
#define GPIO_FUNCTION_UCA0TXD GPIO_PRIMARY_MODULE_FUNCTION
#define GPIO_PORT_UCA0RXD GPIO_PORT_P1
#define GPIO_PIN_UCA0RXD GPIO_PIN5
#define GPIO_FUNCTION_UCA0RXD GPIO_PRIMARY_MODULE_FUNCTION
#define GPIO_PORT_UCB0SCL GPIO_PORT_P1
#define GPIO_PIN_UCB0SCL GPIO_PIN3
#define GPIO_FUNCTION_UCB0SCL GPIO_PRIMARY_MODULE_FUNCTION
#define GPIO_PORT_UCB0SDA GPIO_PORT_P1
#define GPIO_PIN_UCB0SDA GPIO_PIN2
#define GPIO_FUNCTION_UCB0SDA GPIO_PRIMARY_MODULE_FUNCTION
#endif // __MSP430FR2433__
#ifdef __MSP430FR2355__
#define GPIO_PORT_LED1 GPIO_PORT_P1
#define GPIO_PIN_LED1 GPIO_PIN0
#define GPIO_PORT_LED2 GPIO_PORT_P6
#define GPIO_PIN_LED2 GPIO_PIN6
#define GPIO_PORT_S1 GPIO_PORT_P4
#define GPIO_PIN_S1 GPIO_PIN1
#define GPIO_PORT_S2 GPIO_PORT_P2
#define GPIO_PIN_S2 GPIO_PIN3
#define GPIO_PORT_ADC7 GPIO_PORT_P1
#define GPIO_PIN_ADC7 GPIO_PIN7
#define GPIO_FUNCTION_ADC7 GPIO_TERNARY_MODULE_FUNCTION
#define GPIO_PORT_XIN GPIO_PORT_P2
#define GPIO_PIN_XIN GPIO_PIN_P7
#define GPIO_FUNCTION_XIN GPIO_SECONDARY_MODULE_FUNCTION
#define GPIO_PORT_XOUT GPIO_PORT_P2
#define GPIO_PIN_XOUT GPIO_PIN_P6
#define GPIO_FUNCTION_XOUT GPIO_SECONDARY_MODULE_FUNCTION
#define GPIO_PORT_MCLK GPIO_PORT_P3
#define GPIO_PIN_MCLK GPIO_PIN0
#define GPIO_FUNCTION_MCLK GPIO_PRIMARY_MODULE_FUNCTION
#define GPIO_PORT_SMCLK GPIO_PORT_P3
#define GPIO_PIN_SMCLK GPIO_PIN4
#define GPIO_FUNCTION_SMCLK GPIO_PRIMARY_MODULE_FUNCTION
#define GPIO_PORT_ACLK GPIO_PORT_P1
#define GPIO_PIN_ACLK GPIO_PIN1
#define GPIO_FUNCTION_ACLK GPIO_SECONDARY_MODULE_FUNCTION
#define GPIO_PORT_UCA0TXD GPIO_PORT_P1
#define GPIO_PIN_UCA0TXD GPIO_PIN7
#define GPIO_FUNCTION_UCA0TXD GPIO_PRIMARY_MODULE_FUNCTION
#define GPIO_PORT_UCA0RXD GPIO_PORT_P1
#define GPIO_PIN_UCA0RXD GPIO_PIN6
#define GPIO_FUNCTION_UCA0RXD GPIO_PRIMARY_MODULE_FUNCTION
#define GPIO_PORT_UCB0SCL GPIO_PORT_P1
#define GPIO_PIN_UCB0SCL GPIO_PIN3
#define GPIO_FUNCTION_UCB0SCL GPIO_PRIMARY_MODULE_FUNCTION
#define GPIO_PORT_UCB0SDA GPIO_PORT_P1
#define GPIO_PIN_UCB0SDA GPIO_PIN2
#define GPIO_FUNCTION_UCB0SDA GPIO_PRIMARY_MODULE_FUNCTION
#define GPIO_PORT_SACOA0O GPIO_PORT_P1
#define GPIO_PIN_SACOA0O GPIO_PIN1
#define GPIO_FUNCTION_SACOA0O GPIO_TERNARY_MODULE_FUNCTION
#define GPIO_PORT_SACOA0N GPIO_PORT_P1
#define GPIO_PIN_SACOA0N GPIO_PIN2
#define GPIO_FUNCTION_SACOA0N GPIO_TERNARY_MODULE_FUNCTION
#define GPIO_PORT_SACOA0P GPIO_PORT_P1
#define GPIO_PIN_SACOA0P GPIO_PIN3
#define GPIO_FUNCTION_SACOA0P GPIO_TERNARY_MODULE_FUNCTION
#define GPIO_PORT_SACOA2O GPIO_PORT_P3
#define GPIO_PIN_SACOA2O GPIO_PIN1
#define GPIO_FUNCTION_SACOA2O GPIO_TERNARY_MODULE_FUNCTION
#define GPIO_PORT_SACOA2N GPIO_PORT_P3
#define GPIO_PIN_SACOA2N GPIO_PIN2
#define GPIO_FUNCTION_SACOA2N GPIO_TERNARY_MODULE_FUNCTION
#define GPIO_PORT_SACOA2P GPIO_PORT_P3
#define GPIO_PIN_SACOA2P GPIO_PIN3
#define GPIO_FUNCTION_SACOA2P GPIO_TERNARY_MODULE_FUNCTION
#define GPIO_PORT_COMP0O GPIO_PORT_P2
#define GPIO_PIN_COMP0O GPIO_PIN0
#define GPIO_FUNCTION_COMP0O GPIO_SECONDARY_MODULE_FUNCTION
#endif // __MSP430FR2355__
#endif // __BOARD_H__

Binary file not shown.

Binary file not shown.

201
src/MSP430_GUI/GUI_JSON.c Executable file
View File

@ -0,0 +1,201 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2019, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
// GUI Interface
//
// API to send and receive data from GUI using JSON protocol
//
// Texas Instruments, Inc.
#include <GUI_JSON.h>
#include <HAL.h>
#include "./jsmn/jsmn.h"
/**** Local Variables *********************************************************/
static char txString[MAX_STR_LEN]; // String to transmit data
#if (GUI_RXCMD_ENABLE)
static char rxString[MAX_STR_LEN]; // String to receive data
static jsmn_parser p; // parses JSON data
static jsmntok_t t[64]; // We expect no more than 64 tokens
static const tGUI_RxCmd *RxCmdsArray; // Pointer to array of
// RX commands
static uint16_t RxCmdsArraySize; // Size of RX commands
#endif
/**** Local Function Prototypes************************************************/
#if (GUI_RXCMD_ENABLE)
static bool GUI_ParseString(void);
static int jsoneq(const char *json, jsmntok_t *tok, const char *s);
#endif
static bool GUI_RxCharHALCallback(char data);
/**** Functions ***************************************************************/
void GUI_Init(void)
{
HAL_GUI_Init(GUI_RxCharHALCallback);
RxCmdsArraySize= 0;
RxCmdsArray = NULL;
}
#if (GUI_RXCMD_ENABLE)
void GUI_InitRxCmd(const tGUI_RxCmd *CommandArray,
uint16_t size)
{
RxCmdsArray = CommandArray;
RxCmdsArraySize = size;
}
#endif
void GUI_TransmitStringBlocking(char *str)
{
uint16_t i;
for(i = 0; i < strlen(str); i++)
{
if (str[i] != 0)
{
HAL_GUI_TransmitCharBlocking(str[i]);
}
}
}
void GUI_TransmitData(const tGUI_TxCmd *TXCmdrray,
uint16_t size)
{
uint16_t i;
for (i=0; i < size; i++)
{
sprintf(txString, TXCmdrray[i].formattingStringCMD,
*TXCmdrray[i].param);
GUI_TransmitStringBlocking(txString);
}
}
/**** Local Functions**********************************************************/
//! \brief Callback function for GUI HAL. Called when byte is received.
//!
//! \param[in] data is the byte received from GUI Comm interface.
//!
//! \return true to wake-up MCU, false to stay in LPM
static bool GUI_RxCharHALCallback(char data)
{
#if (GUI_RXCMD_ENABLE)
static bool rxInProgress = false;
static uint16_t charCnt = 0;
bool ret = false;
if(!rxInProgress){
if ((data != '\n') ){
rxInProgress = true;
charCnt = 0;
rxString[charCnt] = data;
}
}else{ // in progress
charCnt++;
if((data != '\n')){
if (charCnt >= MAX_STR_LEN){
rxInProgress = false;
}else{
rxString[charCnt] = data;
}
}else{
rxInProgress = false;
rxString[charCnt] = '\0';
// String receive complete
if (GUI_ParseString() == true)
{
ret = true; // wake-up MCU
}
}
}
return ret;
#else
return true;
#endif
}
#if (GUI_RXCMD_ENABLE)
//! \brief Parses a string looking for JSON objects
//!
//! \return true to wake-up MCU when a command is received, false to stay in LPM
static bool GUI_ParseString(void)
{
int i;
int r;
int j;
bool ret = false;
jsmn_init(&p);
r = jsmn_parse(&p, rxString, strlen(rxString), t, sizeof(t)/sizeof(t[0]));
// Loop over keys of JSON object
if (RxCmdsArray != NULL)
{
for (i = 1; i < r; i++) {
for (j=0; j < RxCmdsArraySize; j++)
{
if (jsoneq(rxString, &t[i], RxCmdsArray[j].stringCMD) == 0)
{
if (RxCmdsArray[j].callback != NULL)
{
RxCmdsArray[j].callback(rxString+t[i+1].start);
}
i++;
ret = true;
}
}
}
}
return ret;
}
//! \brief Compare JSON keys
//!
//! \param[in] json is the JSON string.
//! \param[in] tok is the JSON token.
//! \param[in] s is the string to check for equality.
//!
//! \return 0 if string found. -1 if not.
static int jsoneq(const char *json, jsmntok_t *tok, const char *s) {
if (tok->type == JSMN_STRING && (int) strlen(s) == tok->end - tok->start &&
strncmp(json + tok->start, s, tok->end - tok->start) == 0) {
return 0;
}
return -1;
}
#endif

View File

@ -0,0 +1,84 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2019, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
// MSP430 HAL Configuration
//
// Static and default configuration of Library
// Texas Instruments, Inc.
#ifndef __CONFIG_PRIVATE_H__
#define __CONFIG_PRIVATE_H__
#include "Config_Common.h"
//*********** GUI Communication ************************************************
//! \brief baudrate of GUI Communication port
//! i.e. 19200 = 19,200bps
//!
#define HAL_GUICOMM_BAUDRATE (9600)
//! \brief Select which eUSCI to use with UART
#define GUI_COMM_UART_EUSCI (1)
#if (GUI_COMM_UART_EUSCI == 0)
#define UCAnBR0 (UCA0BR0)
#define UCAnBR1 (UCA0BR1)
#define UCAnCTLW0 (UCA0CTLW0)
#define UCAnIE (UCA0IE)
#define UCAnIFG (UCA0IFG)
#define UCAnIV (UCA0IV)
#define UCAnMCTLW (UCA0MCTLW)
#define UCAnSTATW (UCA0STATW)
#define UCAnTXBUF (UCA0TXBUF)
#define UCAnRXBUF (UCA0RXBUF)
#define USCI_An_VECTOR (USCI_A0_VECTOR)
#define USCI_An_ISR (USCI_A0_ISR)
#elif (GUI_COMM_UART_EUSCI == 1)
#define UCAnBR0 (UCA1BR0)
#define UCAnBR1 (UCA1BR1)
#define UCAnCTLW0 (UCA1CTLW0)
#define UCAnIE (UCA1IE)
#define UCAnIFG (UCA1IFG)
#define UCAnIV (UCA1IV)
#define UCAnMCTLW (UCA1MCTLW)
#define UCAnSTATW (UCA1STATW)
#define UCAnTXBUF (UCA1TXBUF)
#define UCAnRXBUF (UCA1RXBUF)
#define USCI_An_VECTOR (USCI_A1_VECTOR)
#define USCI_An_ISR (USCI_A1_ISR)
#else
#error "eUSCI is not defined. Modify HAL layer"
#endif
#endif //__CONFIG_PRIVATE_H__

View File

@ -0,0 +1,145 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2020, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
// GUI HAL for MSP430FR2xxx using UART
//
// Driver to send and receive data from GUI using FR2xxx UART
// Texas Instruments, Inc.
// *****************************************************************************
#include "HAL_Config_Private.h"
#include "HAL.h"
tGUICommRXCharCallback RxByteISRCallback;
void HAL_GUI_Init(tGUICommRXCharCallback RxByteCallback)
{
// Store callback for ISR RX Byte
RxByteISRCallback = RxByteCallback;
// Configure UART for FR2xxx
UCAnCTLW0 |= UCSWRST;
UCAnCTLW0 |= UCSSEL__SMCLK;
#if ((HAL_GUICOMM_BAUDRATE == 9600) && (HSBUS_FREQ_MHZ == 1))
// Baud Rate calculation
// 1000000/(16*9600) = 6.51
// Fractional portion = 0.51
// User's Guide Table 17-4: UCBRSx = 0x20
// UCBRFx = 8
UCAnBR0 = 6;
UCAnBR1 = 0x00;
UCAnMCTLW = 0x2000 | UCOS16 | UCBRF_8;
#elif ((HAL_GUICOMM_BAUDRATE == 28800) && (HSBUS_FREQ_MHZ == 8))
// Baud Rate calculation
// 8E6/(16*28800) = 17.36
// Fractional portion = 0.36
// From eUSCI Calculator: UCBRSx = 221 (0xDD)
// UCBRFx = 5
UCAnBR0 = 17;
UCAnBR1 = 0x00;
UCAnMCTLW = (0xDD<<8) | UCOS16 | UCBRF_5;
#elif ((HAL_GUICOMM_BAUDRATE == 19200) && (HSBUS_FREQ_MHZ == 8))
// Baud Rate calculation
// 8E6/(16*19200) = 26.04
// Fractional portion = 0.04
// User's Guide Table 17-4: UCBRSx = 0xB6
// UCBRFx = 0
UCAnBR0 = 26;
UCAnBR1 = 0x00;
UCAnMCTLW = (0xB6<<8) | UCOS16 | UCBRF_0;
#elif ((HAL_GUICOMM_BAUDRATE == 115200) && (HSBUS_FREQ_MHZ == 8))
// Baud Rate calculation
// 8E6/(16*115200) = 4.34
// Fractional portion = 0.34
// User's Guide Table 22-5: UCBRSx = 0x55
// UCBRFx = 5
UCAnBR0 = 4;
UCAnBR1 = 0x00;
UCAnMCTLW = (0x55<<8) | UCOS16 | UCBRF_5;
#elif ((HAL_GUICOMM_BAUDRATE == 9600) && (HSBUS_FREQ_MHZ == 8))
// Baud Rate calculation
// 8E6/(16*9600) = 52.0833
// Fractional portion = 0.33
// User's Guide Table 17-4: UCBRSx = 0x49
// UCBRFx = 1
UCAnBR0 = 52;
UCAnBR1 = 0x00;
UCAnMCTLW = (0x49<<8) | UCOS16 | UCBRF_1;
#else
#error "Define UART baudrate registers based on desired frequency"
#endif
UCAnCTLW0 &= ~UCSWRST; // Initialize eUSCI
UCAnIE |= UCRXIE;
}
void HAL_GUI_TransmitCharBlocking(char character)
{
// Transmit Character
while (UCAnSTATW & UCBUSY)
;
while (!(UCAnIFG & UCTXIFG))
;
UCAnTXBUF = character;
while (UCAnSTATW & UCBUSY)
;
}
// EUSCI interrupt service routine
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=USCI_An_VECTOR
__interrupt void USCI_An_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(USCI_An_VECTOR))) USCI_An_ISR (void)
#else
#error Compiler not supported!
#endif
{
switch(__even_in_range(UCAnIV,USCI_UART_UCTXCPTIFG))
{
case USCI_NONE: break;
case USCI_UART_UCRXIFG:
if (RxByteISRCallback != NULL)
{
if (RxByteISRCallback(UCAnRXBUF) == true)
{
__bic_SR_register_on_exit(LPM4_bits); // Exit LPM
}
}
break;
case USCI_UART_UCTXIFG: break;
case USCI_UART_UCSTTIFG: break;
case USCI_UART_UCTXCPTIFG: break;
default: break;
}
}

169
src/MSP430_HAL/HAL_IO_FR235x.c Executable file
View File

@ -0,0 +1,169 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2019, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
// HAL IO functions
//
// Texas Instruments, Inc.
// *****************************************************************************
#include <msp430.h>
#include <stdint.h>
#include <stdlib.h>
#include <HAL.h>
#include "HAL_Config_Private.h"
// Simple callbacks to functions in main
extern void ButtonCallback_SW1(void);
extern void ButtonCallback_SW2(void);
/**** Functions **************************************************************/
void HAL_IO_Init(void)
{
// Port output low to save power consumption
// P1.0 = RED LED, Output Low
// P1.1 = Unused, Output Low
// P1.2 = Unused, Output Low
// P1.3 = Unused, Output Low
// P1.4 = Unused, Output Low
// P1.5 = Unused, Output Low
// P1.6 = Unused, Output Low
// P1.7 = Unused, Output Low
P1OUT = (0x00);
P1DIR = (BIT0 | BIT1 | BIT2 | BIT3 | BIT4 | BIT5 | BIT6 | BIT7);
// P2.0 = Unused, Output Low
// P2.1 = Unused, Output Low
// P2.2 = Unused, Output Low
// P2.3 = SW2, Input Pull-up
// P2.4 = Unused, Output Low
// P2.5 = Unused, Output Low
// P2.6 = Unused, Output Low
// P2.7 = Unused, Output Low
P2OUT = (BIT3);
P2DIR = (BIT0 | BIT1 | BIT2 | BIT4 | BIT5 | BIT6 | BIT7);
P2REN |= (BIT3);
// P3.0 = Unused, Output Low
// P3.1 = Unused, Output Low
// P3.2 = Unused, Output Low
// P3.3 = Unused, Output Low
// P3.4 = Unused, Output Low
// P3.5 = Unused, Output Low
// P3.6 = Unused, Output Low
// P3.7 = Unused, Output Low
P3OUT = (0x00);
P3DIR = (BIT0 | BIT1 | BIT2 | BIT3 | BIT4 | BIT5 | BIT6 | BIT7);
// P4.0 = Unused, Output Low
// P4.1 = SW1, Input pull-up
// P4.2 = LP UART RXD, Input pull-up or UART
// P4.3 = LP UART TXD, Input pull-up or UART
// P4.4 = NC, Output Low
// P4.5 = NC, Output Low
// P4.6 = NC, Output Low
// P4.7 = NC, Output Low
P4OUT = (BIT1);
P4DIR = (BIT0 | BIT4 | BIT5 | BIT6 | BIT7);
P4REN |= (BIT1);
P4SEL0 |= (BIT2 | BIT3);
P4SEL1 &= ~(BIT2 | BIT3);
// P5.0 = Unused, Output Low
// P5.1 = Unused, Output Low
// P5.2 = Unused, Output Low
// P5.3 = Unused, Output Low
// P5.4 = Unused, Output Low
// P5.5 = N/A, Output Low
// P5.6 = N/A, Output Low
// P5.7 = N/A, Output Low
P5OUT = (0x00);
P5DIR = (BIT0 | BIT1 | BIT2 | BIT3 | BIT4 | BIT5 | BIT6 | BIT7);
// P6.0 = Unused, Output Low
// P6.1 = Unused, Output Low
// P6.2 = Unused, Output Low
// P6.3 = Unused, Output Low
// P6.4 = Unused, Output Low
// P6.5 = Unused, Output Low
// P6.6 = Unused, Output Low
// P6.7 = N/A, Output Low
P6OUT = (0x00);
P6DIR = (BIT0 | BIT1 | BIT2 | BIT3 | BIT4 | BIT5 | BIT6 | BIT7);
PM5CTL0 &= ~LOCKLPM5; // Disable the GPIO power-on default high-impedance mode
// to activate previously configured port settings
}
void HAL_IO_InitButtons(void)
{
// Configure SW1 and SW2 for interrupts (pins set as input-pullup during GPIO initialization)
P4IES = BIT1; // Hi/Low edge
P4IFG = 0; // Clear flags
P4IE = BIT1; // interrupt enabled
P2IES = BIT3; // Hi/Low edge
P2IFG = 0; // Clear flags
P2IE = BIT3; // interrupt enabled
}
// Port 4 interrupt service routine
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=PORT4_VECTOR
__interrupt void Port_4(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(PORT1_VECTOR))) Port_3 (void)
#else
#error Compiler not supported!
#endif
{
ButtonCallback_SW1();
P4IFG &= ~BIT1; // Clear IFG
__bic_SR_register_on_exit(LPM3_bits); // Exit LPM3
}
// Port 2 interrupt service routine
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=PORT2_VECTOR
__interrupt void Port_2(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(PORT1_VECTOR))) Port_2 (void)
#else
#error Compiler not supported!
#endif
{
ButtonCallback_SW2();
P2IFG &= ~BIT3; // Clear IFG
__bic_SR_register_on_exit(LPM3_bits); // Exit LPM3
}

View File

@ -0,0 +1,147 @@
/* --COPYRIGHT--,BSD
* Copyright (c) 2019, Texas Instruments Incorporated
* All rights reserved.
*
* 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.
* --/COPYRIGHT--*/
//*****************************************************************************
// HAL functions to initialize the system
//
// Texas Instruments, Inc.
// ******************************************************************************
#include <Config_Common.h>
#include "HAL.h"
/**** Local Function Prototypes ***********************************************/
static void HAL_System_Clock_Init(void);
static void Clock_Software_Trim(void);
/**** Functions ***************************************************************/
int8_t HAL_System_Init(void)
{
HAL_IO_Init();
HAL_System_Clock_Init();
return 0; // OK
}
/**** Local Functions *********************************************************/
//! \brief Initializes the system clock
//!
//! \return none
static void HAL_System_Clock_Init(void)
{
#if ( (CPU_FREQ_HZ == 8000000) && (LSBUS_FREQ_HZ == 32768) )
__bis_SR_register(SCG0); // disable FLL
CSCTL3 |= SELREF__REFOCLK; // Set REFO as FLL reference source
CSCTL1 = DCOFTRIMEN_1 | DCOFTRIM0 | DCOFTRIM1 | DCORSEL_3;// DCOFTRIM=3, DCO Range = 8MHz
CSCTL2 = FLLD_0 + 243; // DCODIV = 8MHz
__delay_cycles(3);
__bic_SR_register(SCG0); // enable FLL
Clock_Software_Trim(); // Software Trim to get the best DCOFTRIM value
CSCTL4 = SELMS__DCOCLKDIV | SELA__REFOCLK; // set default REFO(~32768Hz) as ACLK source, ACLK = 32768Hz
// default DCODIV as MCLK and SMCLK source
#else
#error "Clock configuration is not supported. Modify DualRaySmoke_HAL_System.c"
#endif
}
//! \brief Software trim for DCO+FLL to lock target frequency
//!
//! \return none
static void Clock_Software_Trim(void)
{
unsigned int oldDcoTap = 0xffff;
unsigned int newDcoTap = 0xffff;
unsigned int newDcoDelta = 0xffff;
unsigned int bestDcoDelta = 0xffff;
unsigned int csCtl0Copy = 0;
unsigned int csCtl1Copy = 0;
unsigned int csCtl0Read = 0;
unsigned int csCtl1Read = 0;
unsigned int dcoFreqTrim = 3;
unsigned char endLoop = 0;
do
{
CSCTL0 = 0x100; // DCO Tap = 256
do
{
CSCTL7 &= ~DCOFFG; // Clear DCO fault flag
}while (CSCTL7 & DCOFFG); // Test DCO fault flag
__delay_cycles((unsigned long)3000 * CPU_FREQ_MHZ);// Wait FLL lock status (FLLUNLOCK) to be stable
// Suggest to wait 24 cycles of divided FLL reference clock
while((CSCTL7 & (FLLUNLOCK0 | FLLUNLOCK1)) && ((CSCTL7 & DCOFFG) == 0));
csCtl0Read = CSCTL0; // Read CSCTL0
csCtl1Read = CSCTL1; // Read CSCTL1
oldDcoTap = newDcoTap; // Record DCOTAP value of last time
newDcoTap = csCtl0Read & 0x01ff; // Get DCOTAP value of this time
dcoFreqTrim = (csCtl1Read & 0x0070)>>4;// Get DCOFTRIM value
if(newDcoTap < 256) // DCOTAP < 256
{
newDcoDelta = 256 - newDcoTap; // Delta value between DCPTAP and 256
if((oldDcoTap != 0xffff) && (oldDcoTap >= 256)) // DCOTAP cross 256
endLoop = 1; // Stop while loop
else
{
dcoFreqTrim--;
CSCTL1 = (csCtl1Read & (~DCOFTRIM)) | (dcoFreqTrim<<4);
}
}
else // DCOTAP >= 256
{
newDcoDelta = newDcoTap - 256; // Delta value between DCPTAP and 256
if(oldDcoTap < 256) // DCOTAP cross 256
endLoop = 1; // Stop while loop
else
{
dcoFreqTrim++;
CSCTL1 = (csCtl1Read & (~DCOFTRIM)) | (dcoFreqTrim<<4);
}
}
if(newDcoDelta < bestDcoDelta) // Record DCOTAP closest to 256
{
csCtl0Copy = csCtl0Read;
csCtl1Copy = csCtl1Read;
bestDcoDelta = newDcoDelta;
}
}while(endLoop == 0); // Poll until endLoop == 1
CSCTL0 = csCtl0Copy; // Reload locked DCOTAP
CSCTL1 = csCtl1Copy; // Reload locked DCOFTRIM
while(CSCTL7 & (FLLUNLOCK0 | FLLUNLOCK1)); // Poll until FLL is locked
}

View File

@ -1,5 +1,5 @@
/* --COPYRIGHT--,BSD /* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated * Copyright (c) 2019, Texas Instruments Incorporated
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -30,54 +30,42 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* --/COPYRIGHT--*/ * --/COPYRIGHT--*/
//***************************************************************************** //*****************************************************************************
// HAL Timer functions
// //
// tia.c - Driver for the tia Module. // Texas Instruments, Inc.
// // *****************************************************************************
//***************************************************************************** #include <msp430.h>
#include <stdint.h>
#include <stdlib.h>
#include <HAL.h>
#include "HAL_Config_Private.h"
//***************************************************************************** // Simple callbacks to main function
// extern void TimerCallback(void);
//! \addtogroup tia_api tia
//! @{
//
//*****************************************************************************
#include "inc/hw_memmap.h" /**** Functions **************************************************************/
void HAL_Timer_Init(void)
#ifdef __MSP430_HAS_TRIx__
#include "tia.h"
#include <assert.h>
void TIA_selectPositiveInput(uint16_t baseAddress,
uint16_t positiveInput)
{ {
HWREG16(baseAddress + OFS_TRI0CTL) &= ~TRIPSEL_3; // Initialize a timer to update the counter
// Configure Timer
HWREG16(baseAddress + OFS_TRI0CTL) |= positiveInput; TB0CCR0 = LSBUS_FREQ_HZ / 2; // 0.5sec
TB0CCTL0 = CCIE; // TBCCR0 interrupt enabled
TB0CTL = TBSSEL__ACLK | // Use ACLK
MC__UP | // Up Mode
TBCLR; // Clear counter
} }
void TIA_selectPowerMode(uint16_t baseAddress,
uint16_t powerMode)
{
HWREG16(baseAddress + OFS_TRI0CTL) &= ~TRIPM;
HWREG16(baseAddress + OFS_TRI0CTL) |= powerMode;
}
void TIA_enable(uint16_t baseAddress)
{
HWREG16(baseAddress + OFS_TRI0CTL) |= TRIEN;
}
void TIA_disable(uint16_t baseAddress)
{
HWREG16(baseAddress + OFS_TRI0CTL) &= ~TRIEN;
}
// Timer B0 interrupt service routine
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector = TIMER0_B0_VECTOR
__interrupt void Timer(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(TIMER0_B0_VECTOR))) Timer_B0 (void)
#else
#error Compiler not supported!
#endif #endif
//***************************************************************************** {
// TimerCallback();
//! Close the doxygen group for tia_api __bic_SR_register_on_exit(LPM3_bits); // Exit LPM3
//! @} }
//
//*****************************************************************************

View File

@ -1,19 +0,0 @@
/* File: constants.h */
/**
* @file constants.h
* @brief Common constants missing from standard headers (C90).
*
* @author
* Frederik Beimgraben
* Minh Dan Cam
* Luis Meyer
* @date 2025-07-02
*/
#ifndef CONSTANTS_H
#define CONSTANTS_H
/** @brief Null pointer constant for C90. */
#define NULL 0
#endif /* CONSTANTS_H */

View File

@ -1,93 +0,0 @@
/**
* \file door_sensor.c
* \brief Implementation of the door sensor driver using MSP430 GPIO interrupts.
*
* This module configures a GPIO pin to detect door open/close events and invokes
* user-provided callbacks on confirmed state changes.
*/
#include <stdint.h>
#include <msp430.h>
#include <driverlib.h>
#include <stdbool.h>
#include "door_sensor.h"
#include "constants.h"
/**\brief GPIO port used for the door sensor. */
#define SENSOR_PORT GPIO_PORT_P2
/**\brief GPIO pin used for the door sensor. */
#define SENSOR_PIN GPIO_PIN0
/**\brief Interrupt vector associated with the sensor port. */
#define SENSOR_VECTOR PORT2_VECTOR
/**
* \brief Callback invoked when the door is detected as opened.
*
* User must supply a function matching this type to be notified of an open event.
*/
static DoorOpenedCallback_t doorOpenedCallback = NULL;
/**
* \brief Callback invoked when the door is detected as closed.
*
* User must supply a function matching this type to be notified of a close event.
*/
static DoorClosedCallback_t doorClosedCallback = NULL;
/**
* \brief Initialize the door sensor driver.
*
* Configures the GPIO pin for input with pull-up resistor and enables
* interrupts on the specified edge. Also stores the user-provided callbacks.
*
* \param ocb Function to call when the door opens (rising edge).
* \param ccb Function to call when the door closes (falling edge).
*/
void door_init(DoorOpenedCallback_t ocb, DoorClosedCallback_t ccb) {
doorOpenedCallback = ocb;
doorClosedCallback = ccb;
/* Configure port as pull up with interrupt */
GPIO_setAsInputPinWithPullUpResistor(SENSOR_PORT, SENSOR_PIN);
GPIO_clearInterrupt(SENSOR_PORT, SENSOR_PIN);
GPIO_selectInterruptEdge(SENSOR_PORT, SENSOR_PIN, GPIO_LOW_TO_HIGH_TRANSITION);
GPIO_enableInterrupt(SENSOR_PORT, SENSOR_PIN);
/* Enable global interrupts */
__enable_interrupt();
}
/**
* \brief Tracks the last known door state (open = true, closed = false).
*/
volatile bool door_last_open = false;
/**
* \brief ISR for PORT2 interrupt handling door sensor events.
*
* Detects whether the door is opening or closing based on interrupt edge,
* invokes the corresponding callback, and reconfigures the interrupt edge
* for the next transition.
*/
#pragma vector=SENSOR_VECTOR
__interrupt void SENSOR_ISR(void)
{
uint16_t status = GPIO_getInterruptStatus(SENSOR_PORT, SENSOR_PIN);
if (status) {
if (door_last_open) {
/* Door was open, now closed */
if (doorClosedCallback)
doorClosedCallback();
GPIO_selectInterruptEdge(SENSOR_PORT, SENSOR_PIN, GPIO_LOW_TO_HIGH_TRANSITION);
} else {
/* Door was closed, now opened */
if (doorOpenedCallback)
doorOpenedCallback();
GPIO_selectInterruptEdge(SENSOR_PORT, SENSOR_PIN, GPIO_HIGH_TO_LOW_TRANSITION);
}
}
/* Clear the interrupt flag and toggle stored state */
GPIO_clearInterrupt(SENSOR_PORT, SENSOR_PIN);
door_last_open = !door_last_open;
}

View File

@ -1,38 +0,0 @@
/**
* \file door_sensor.h
* \brief Public interface for the door sensor driver.
*
* This header declares the callback types and initialization function
* for detecting door open and close events using GPIO interrupts.
*/
#ifndef DOOR_H
#define DOOR_H
/**
* \brief Callback type invoked when the door is detected as opened.
*
* This function is called by the driver on a confirmed open event.
*/
typedef void (*DoorOpenedCallback_t)(void);
/**
* \brief Callback type invoked when the door is detected as closed.
*
* This function is called by the driver on a confirmed close event.
*/
typedef void (*DoorClosedCallback_t)(void);
/**
* \brief Initialize the door sensor driver.
*
* Configures the GPIO pin for input with pull-up resistor and enables
* interrupts on the door sensor line. The provided callbacks are invoked
* on door open and close events respectively.
*
* \param ocb User-provided callback to invoke on door open.
* \param ccb User-provided callback to invoke on door close.
*/
void door_init(DoorOpenedCallback_t ocb, DoorClosedCallback_t ccb);
#endif // DOOR_H

176
src/i2c.c
View File

@ -1,176 +0,0 @@
/* File: i2c.c */
/**
* @file i2c.c
* @brief I²C master routines and missing standard C90 constants for MSP430FR2355.
*
* Implements byte-wise I²C transmit and single-register read with automatic
* STOP handling and interrupt-driven operation.
*
* @author (based on work by) Luis Wehrberger
* @date 2025-07-02
*/
#include "i2c.h"
#include "msp430fr2355.h"
#include <stdint.h>
#include <stdbool.h>
/** Pointer to the current transmit buffer. */
static char *i2c_tx_buffer;
/** Number of bytes left to send (buffer length). */
static unsigned int i2c_tx_length;
/** Index of the next byte to transmit. */
static unsigned int i2c_tx_index;
/** Last byte received by the ISR. */
static char i2c_rx_byte;
/** Flag set when I²C transfer completes (STOP or NACK). */
static volatile bool i2c_transfer_complete = false;
/**
* @brief Initialize USCI_B0 module for I²C master mode at 50 kHz.
*
* Configures SMCLK source, sets clock divider, 7-bit addressing,
* automatic STOP generation, port mapping for SDA/SCL, and enables
* relevant interrupts.
*/
void i2c_init(void)
{
// Put eUSCI_B0 into reset state for configuration
UCB0CTLW0 |= UCSWRST;
// Select SMCLK and divide by 20 → 50 kHz SCL
UCB0CTLW0 |= UCSSEL_3;
UCB0BRW = 50;
// Configure as I²C master with 7-bit addressing
UCB0CTLW0 |= UCMODE_3 | UCMST;
// Enable automatic STOP when byte counter (UCB0TBCNT) reaches zero
UCB0CTLW1 |= UCASTP_2;
// Assign P1.2 = SDA, P1.3 = SCL via port mapping
P1SEL1 &= ~(BIT2 | BIT3);
P1SEL0 |= (BIT2 | BIT3);
// Release eUSCI_B0 for operation
UCB0CTLW0 &= ~UCSWRST;
// Enable RX, TX, STOP, and NACK interrupts
UCB0IE |= UCRXIE0 | UCTXIE0 | UCSTPIE | UCNACKIE;
__enable_interrupt();
}
/**
* @brief Transmit a sequence of bytes to a given I²C slave.
*
* @param slaveAddress 7-bit I²C address of the slave device.
* @param data Pointer to data buffer to send.
* @param length Number of bytes to transmit.
*/
void i2c_write(uint8_t slaveAddress, char data[], uint8_t length)
{
// Set target slave address
UCB0I2CSA = slaveAddress;
// Initialize transmit buffer and counters
i2c_tx_buffer = data;
i2c_tx_length = length;
i2c_tx_index = 0;
// Configure for master-transmit mode and set byte counter
UCB0CTLW0 |= UCTR;
UCB0TBCNT = length;
// Generate START and wait for STOP flag in ISR
UCB0CTLW0 |= UCTXSTT;
i2c_transfer_complete = false;
while (!i2c_transfer_complete)
{
LPM3; // Enter low-power mode, will wake on STOP or NACK
}
}
/**
* @brief Read a single register byte from an I²C slave.
*
* Performs a write of the register address, followed by a repeated START
* to read one byte, with automatic STOP and interrupt-based wake-up.
*
* @param slaveAddress 7-bit I²C address of the slave device.
* @param registerAddress Register address to read.
* @return Byte read from the register.
*/
char i2c_read_reg(uint8_t slaveAddress, uint8_t registerAddress)
{
// Send register address first
char addr_buf[1] = { (char)registerAddress };
i2c_write(slaveAddress, addr_buf, 1);
// Switch to master-receive mode and request one byte
UCB0CTLW0 &= ~UCTR;
UCB0TBCNT = 1;
// Generate repeated START condition
UCB0CTLW0 |= UCTXSTT;
i2c_transfer_complete = false;
while (!i2c_transfer_complete)
{
LPM3; // Wait for ISR to clear STOP flag
}
return i2c_rx_byte;
}
/**
* @brief USCI_B0 I²C interrupt handler.
*
* Handles NACK, STOP, RX, and TX events:
* - NACK: terminate transfer and wake CPU
* - STOP: terminate transfer and wake CPU
* - RXBUF: store received byte
* - TXBUF: send next byte or reset index
*/
#pragma vector = EUSCI_B0_VECTOR
__interrupt void EUSCI_B0_I2C_ISR(void)
{
switch (__even_in_range(UCB0IV, USCI_I2C_UCBIT9IFG))
{
case USCI_I2C_UCNACKIFG:
// NACK received: signal completion and wake CPU
i2c_transfer_complete = true;
__bic_SR_register_on_exit(LPM3_bits);
break;
case USCI_I2C_UCSTPIFG:
// STOP condition detected: signal completion and wake CPU
i2c_transfer_complete = true;
__bic_SR_register_on_exit(LPM3_bits);
break;
case USCI_I2C_UCRXIFG0:
// Read received byte into buffer
i2c_rx_byte = UCB0RXBUF;
break;
case USCI_I2C_UCTXIFG0:
// Transmit next byte or reset index if done
UCB0TXBUF = i2c_tx_buffer[i2c_tx_index++];
if (i2c_tx_index >= i2c_tx_length)
{
// Reset index for subsequent transactions
i2c_tx_index = 0;
}
break;
default:
// Unhandled interrupts: no action
break;
}
}

View File

@ -1,42 +0,0 @@
/* File: i2c.h */
/**
* @file i2c.h
* @brief Interface for a minimal blocking I²C master driver (MSP430FR2355).
*
* Provides initialization, blocking write, and single-byte register read.
*
* @author
* Frederik Beimgraben
* Minh Dan Cam
* Luis Meyer
* @date 2025-07-02
*/
#ifndef I2C_H
#define I2C_H
#include <stdint.h>
#include <stdbool.h>
/**
* @brief Initialize the I2C module as master.
*/
void i2c_init(void);
/**
* @brief Send a data packet to an I2C slave.
* @param slaveAddress 7-bit address of the target device.
* @param data Pointer to the data buffer to send.
* @param length Number of bytes to send.
*/
void i2c_write(uint8_t slaveAddress, char data[], uint8_t length);
/**
* @brief Read a single byte from a specific register of an I2C slave.
* @param slaveAddress 7-bit address of the target device.
* @param registerAddress Register address to read.
* @return The byte read from the device.
*/
char i2c_read_reg(uint8_t slaveAddress, uint8_t registerAddress);
#endif /* I2C_H */

View File

@ -1,203 +0,0 @@
/**
* @file keypad.c
* @brief Interrupt-driven 4×4 matrix keypad driver for MSP430FR2355.
*
* This driver scans a 4×4 keypad by:
* 1. Configuring rows as outputs (driven HIGH) and columns as inputs w/ pull-ups
* 2. Enabling falling-edge interrupts on each column line
* 3. On column interrupt:
* - Disable all column interrupts
* - Debounce
* - Pull each row LOW in turn to identify which row is active
* - Invoke user callback with ASCII key
* - Wait for key release and debounce
* - Clear flags and re-enable column interrupts
*
* @author Frederik Beimgraben
* @date 2025-07-02
*/
#include <msp430.h>
#include <driverlib.h>
#include "keypad.h"
#include "constants.h"
/** Number of rows in the keypad matrix */
#define ROWS 4U
/** Number of columns in the keypad matrix */
#define COLS 4U
/** Debounce delay (~20 ms @ 1 MHz SMCLK) */
#define DEBOUNCE_CYCLES 20000U
/** ASCII labels for each key at [row][col] */
static const char keys[ROWS][COLS] = {
{ '1', '2', '3', 'A' },
{ '4', '5', '6', 'B' },
{ '7', '8', '9', 'C' },
{ '*', '0', '#', 'D' }
};
/** Row port and pin definitions */
static const uint8_t rowPort[ROWS] = { GPIO_PORT_P6, GPIO_PORT_P6, GPIO_PORT_P6, GPIO_PORT_P6 };
static const uint16_t rowPin [ROWS] = { GPIO_PIN0, GPIO_PIN1, GPIO_PIN2, GPIO_PIN3 };
/** Column port and pin definitions */
enum { COL0 = 0, COL1, COL2, COL3 };
static const uint8_t colPort[COLS] = { GPIO_PORT_P3, GPIO_PORT_P1, GPIO_PORT_P3, GPIO_PORT_P1 };
static const uint16_t colPin [COLS] = { GPIO_PIN0, GPIO_PIN4, GPIO_PIN2, GPIO_PIN1 };
/** User callback invoked on confirmed key press */
static KeypadCallback_t keyCallback = NULL;
/**
* @brief Scan rows to identify which one pulled the given column low.
* @param colIdx Index of column (03) that triggered interrupt
* @return ASCII character of pressed key, or 0 if none detected
*/
static char scan_row_for_column(uint8_t colIdx)
{
char result = 0;
unsigned int r;
/* Ensure all rows are driven HIGH before scanning */
for (r = 0; r < ROWS; r++) {
GPIO_setOutputHighOnPin(rowPort[r], rowPin[r]);
}
/* Drive each row LOW and check column input */
for (r = 0; r < ROWS; r++) {
GPIO_setOutputLowOnPin(rowPort[r], rowPin[r]);
__delay_cycles(DEBOUNCE_CYCLES);
if (GPIO_getInputPinValue(colPort[colIdx], colPin[colIdx]) == GPIO_INPUT_PIN_LOW) {
result = keys[r][colIdx];
break;
}
/* Restore row high for next iteration */
GPIO_setOutputHighOnPin(rowPort[r], rowPin[r]);
}
return result;
}
/**
* @brief Handle column interrupt: debounce, identify key, invoke callback,
* wait for release, then re-arm interrupts.
* @param colIdx Index of column that triggered the interrupt
*/
static void handle_column_interrupt(uint8_t colIdx)
{
unsigned int i;
/* Disable all column interrupts */
for (i = 0; i < COLS; i++) {
GPIO_disableInterrupt(colPort[i], colPin[i]);
}
/* Debounce delay */
__delay_cycles(DEBOUNCE_CYCLES);
/* Identify pressed key and invoke callback if set */
{
char key = scan_row_for_column(colIdx);
if (key && keyCallback) {
keyCallback(key);
}
}
/* Wait for key release */
while (GPIO_getInputPinValue(colPort[colIdx], colPin[colIdx]) == GPIO_INPUT_PIN_LOW) {
;
}
__delay_cycles(DEBOUNCE_CYCLES);
/* Clear interrupt flags and re-enable interrupts */
for (i = 0; i < COLS; i++) {
GPIO_clearInterrupt(colPort[i], colPin[i]);
GPIO_enableInterrupt(colPort[i], colPin[i]);
}
/* Reset all rows to LOW idle state */
for (i = 0; i < ROWS; i++) {
GPIO_setOutputLowOnPin(rowPort[i], rowPin[i]);
}
}
/*===========================================================================*/
/*=== Port ISR vectors =====================================================*/
/*===========================================================================*/
/**
* @brief Interrupt Service Routine for PORT2 (handles COL1 on P2.4)
*/
#pragma vector=PORT1_VECTOR
__interrupt void PORT1_ISR(void)
{
uint16_t mask = colPin[COL1] | colPin[COL3];
uint16_t status = GPIO_getInterruptStatus(GPIO_PORT_P1, mask);
if (status & colPin[COL1]) {
handle_column_interrupt(COL1);
__bic_SR_register_on_exit(LPM0_bits);
}
if (status & colPin[COL3]) {
handle_column_interrupt(COL3);
__bic_SR_register_on_exit(LPM0_bits);
}
GPIO_clearInterrupt(GPIO_PORT_P2, colPin[COL1]);
}
/**
* @brief Interrupt Service Routine for PORT3 (handles COL0, COL2, COL3)
*/
#pragma vector=PORT3_VECTOR
__interrupt void PORT3_ISR(void)
{
uint16_t mask = colPin[COL0] | colPin[COL2] | colPin[COL3];
uint16_t status = GPIO_getInterruptStatus(GPIO_PORT_P3, mask);
if (status & colPin[COL0]) {
handle_column_interrupt(COL0);
__bic_SR_register_on_exit(LPM0_bits);
}
if (status & colPin[COL2]) {
handle_column_interrupt(COL2);
__bic_SR_register_on_exit(LPM0_bits);
}
GPIO_clearInterrupt(GPIO_PORT_P3, mask);
}
/*===========================================================================*/
/*=== Public API ============================================================*/
/*===========================================================================*/
/**
* @brief Initialize keypad GPIOs and interrupts.
* @param cb Callback invoked with ASCII key on press
*/
void keypad_init(KeypadCallback_t cb)
{
unsigned int i;
keyCallback = cb;
/* Configure rows as outputs, idle LOW */
for (i = 0; i < ROWS; i++) {
GPIO_setAsOutputPin(rowPort[i], rowPin[i]);
GPIO_setOutputLowOnPin(rowPort[i], rowPin[i]);
}
/* Configure columns as inputs with pull-up resistors and falling-edge interrupts */
for (i = 0; i < COLS; i++) {
GPIO_setAsInputPinWithPullUpResistor(colPort[i], colPin[i]);
GPIO_clearInterrupt(colPort[i], colPin[i]);
GPIO_selectInterruptEdge(colPort[i], colPin[i], GPIO_HIGH_TO_LOW_TRANSITION);
GPIO_enableInterrupt(colPort[i], colPin[i]);
}
/* Enable global interrupts */
__enable_interrupt();
}

View File

@ -1,29 +0,0 @@
/* File: keypad.h */
/**
* @file keypad.h
* @brief API for 4×4 matrix keypad driver (MSP430FR2355).
*
* Interrupt-driven scanning with callback on key press.
*
* @author Frederik Beimgraben
* @date 2025-07-02
*/
#ifndef KEYPAD_H
#define KEYPAD_H
#include <stdint.h>
/**
* @brief Callback invoked on a confirmed key press.
* @param key ASCII character of the pressed key.
*/
typedef void (*KeypadCallback_t)(char key);
/**
* @brief Initialize the keypad pins and interrupts.
* @param cb User callback for key events.
*/
void keypad_init(KeypadCallback_t cb);
#endif /* KEYPAD_H */

137
src/lcd.c
View File

@ -1,137 +0,0 @@
/**
* \file lcd.c
* \brief I2C-based LCD driver for MSP430FR2355.
*
* This module provides initialization and basic control functions
* for a character LCD connected via an I2C expander. It supports
* 4-bit communication mode and includes routines for sending commands
* and data to the display.
*/
#include "lcd.h"
#include "i2c.h" /**< I²C master driver */
#include <msp430fr2355.h> /**< MSP430 definitions for __delay_cycles() */
#include <stdint.h>
/**
* \brief Send a 4-bit nibble with control flags over I2C to the LCD.
*
* This helper composes a byte containing the nibble (in the high 4 bits),
* the control signals (RS, RW, EN), and the backlight bit, then toggles
* the enable line to latch the data.
*
* \param nibble 4-bit data to send (lower nibble used).
* \param control Control flags (e.g., RS, R/W).
*/
static void lcd_write_nibble(uint8_t nibble, uint8_t control)
{
char buf[1];
/* High nibble placed in upper data bits, include control and backlight */
buf[0] = (uint8_t)((nibble << 4) | control | LCD_BACKLIGHT);
/* Pulse EN high */
i2c_write(LCD_I2C_ADDR, buf, 1);
buf[0] |= LCD_ENABLE;
i2c_write(LCD_I2C_ADDR, buf, 1);
__delay_cycles(500); /**< ~50µs at 1MHz */
/* EN low */
buf[0] &= (char)~LCD_ENABLE;
i2c_write(LCD_I2C_ADDR, buf, 1);
__delay_cycles(500);
}
/**
* \brief Send an 8-bit command to the LCD.
*
* Splits the command into two 4-bit nibbles and sends each with RS=0.
*
* \param cmd Command byte to send.
*/
static void lcd_send_cmd(uint8_t cmd)
{
lcd_write_nibble(cmd >> 4, 0x00);
lcd_write_nibble(cmd & 0x0F, 0x00);
}
/**
* \brief Send an 8-bit data value (character) to the LCD.
*
* Splits the data into two 4-bit nibbles and sends each with RS=1.
*
* \param data Data byte (character) to display.
*/
static void lcd_send_data(uint8_t data)
{
lcd_write_nibble(data >> 4, LCD_RS);
lcd_write_nibble(data & 0x0F, LCD_RS);
}
void lcd_init(void)
{
/* Delay for LCD power-up (approx. 50 ms) */
__delay_cycles(50000);
/* Initialization sequence in 8-bit mode: 3 pulses */
lcd_write_nibble(0x03, 0x00);
__delay_cycles(20000);
lcd_write_nibble(0x03, 0x00);
__delay_cycles(5000);
lcd_write_nibble(0x03, 0x00);
__delay_cycles(2000);
/* Switch to 4-bit mode */
lcd_write_nibble(0x02, 0x00);
__delay_cycles(2000);
/* Function set: 4-bit, 2 lines, 5x8 dots */
lcd_send_cmd(0x28);
/* Display off */
lcd_send_cmd(0x08);
/* Clear display */
lcd_send_cmd(0x01);
__delay_cycles(2000);
/* Entry mode set: increment cursor */
lcd_send_cmd(0x06);
/* Display on, cursor off, blink off */
lcd_send_cmd(0x0C);
}
void lcd_clear(void)
{
/**
* \brief Clear display and reset cursor.
*
* Sends the clear command and waits for the LCD to process it.
*/
lcd_send_cmd(0x01);
__delay_cycles(2000);
}
void lcd_set_cursor(uint8_t row, uint8_t col)
{
/**
* \brief Set cursor to specified position.
*
* Calculates the DDRAM address based on row and column.
*
* \param row Row index (0 or 1).
* \param col Column index (0-15).
*/
uint8_t addr = (row == 0 ? 0x00 : 0x40) + (col & 0x0F);
lcd_send_cmd(0x80 | addr);
}
void lcd_print(const char *str)
{
/**
* \brief Print a null-terminated string to the LCD.
*
* Iterates through the string and sends each character as data.
*
* \param str Pointer to a null-terminated C string.
*/
while (*str)
{
lcd_send_data((uint8_t)*str++);
}
}

View File

@ -1,51 +0,0 @@
/* File: lcd.h */
/**
* @file lcd.h
* @brief API for 1602A-LCD via PCF8574 I²C backpack (0x27) in 4-bit mode.
*
* Uses blocking I2C transfers via I2C_write().
*
* @authors
* Frederik Beimgraben
* Minh Dan Cam
* Luis Meyer
* @date 2025-07-02
*/
#ifndef LCD_I2C_H
#define LCD_I2C_H
#include <stdint.h>
/** I2C address of the PCF8574 backpack. */
#define LCD_I2C_ADDR 0x27u
/** PCF8574 → LCD control bits. */
#define LCD_BACKLIGHT 0x08u
#define LCD_ENABLE 0x04u
#define LCD_RW 0x02u
#define LCD_RS 0x01u
/**
* @brief Initialize the LCD (4-bit, 2 lines, 5×8 dots).
*/
void lcd_init(void);
/**
* @brief Clear the display and return cursor to home position.
*/
void lcd_clear(void);
/**
* @brief Set cursor position.
* @param row Zero-based row index (01).
* @param col Zero-based column index (015).
*/
void lcd_set_cursor(uint8_t row, uint8_t col);
/**
* @brief Write a null-terminated string at current cursor position.
* @param str ASCII string to display.
*/
void lcd_print(const char *str);
#endif /* LCD_I2C_H */

View File

@ -1,141 +0,0 @@
/**
* @file morse.c
* @brief Implementation of Morse code LED blinking for MSP430.
*
* This module provides functions to initialize an LED pin and blink
* Morse code patterns for alphanumeric characters (AZ, 09).
*
* Timing follows standard Morse code rules: dot = 1 unit on, dash = 3 units on,
* intra-character gap = 1 unit off (handled in blinkDot/blinkDash),
* inter-character gap = 3 units off.
*
* Usage:
* morseInit();
* blinkMorseChar('S'); // ...
*
* @date 2025-07-02
*/
#include "morse.h"
#include <msp430.h>
#include <driverlib.h>
#include "constants.h"
/** One time unit in CPU cycles (1 MHz SMCLK) */
#define MORSE_UNIT_CYCLES 200000U
/** LED port definition */
#define LED_PORT GPIO_PORT_P1
/** LED pin definition */
#define LED_PIN GPIO_PIN0
/**
* @brief Blink the LED for a dot: on 1 unit, off 1 unit.
*/
static void blink_dot(void)
{
GPIO_setOutputHighOnPin(LED_PORT, LED_PIN);
__delay_cycles(MORSE_UNIT_CYCLES);
GPIO_setOutputLowOnPin(LED_PORT, LED_PIN);
__delay_cycles(MORSE_UNIT_CYCLES);
}
/**
* @brief Blink the LED for a dash: on 3 units, off 1 unit.
*/
static void blink_dash(void)
{
GPIO_setOutputHighOnPin(LED_PORT, LED_PIN);
__delay_cycles(3 * MORSE_UNIT_CYCLES);
GPIO_setOutputLowOnPin(LED_PORT, LED_PIN);
__delay_cycles(MORSE_UNIT_CYCLES);
}
/**
* @brief Mapping of characters to Morse code patterns.
*/
typedef struct {
char c; /**< Character (AZ, 09) */
const char *pattern;/**< Morse code string (".", "-" sequences) */
} MorseMapEntry;
/** Lookup table for supported characters */
static const MorseMapEntry morseTable[] = {
{'A', ".-"}, {'B', "-..."}, {'C', "-.-."}, {'D', "-.."},
{'E', "."}, {'F', "..-."}, {'G', "--."}, {'H', "...."},
{'I', ".."}, {'J', ".---"}, {'K', "-.-"}, {'L', ".-.."},
{'M', "--"}, {'N', "-."}, {'O', "---"}, {'P', ".--."},
{'Q', "--.-"}, {'R', ".-."}, {'S', "..."}, {'T', "-"},
{'U', "..-"}, {'V', "...-"}, {'W', ".--"}, {'X', "-..-"},
{'Y', "-.--"}, {'Z', "--.."},
{'0', "-----"},{'1', ".----"},{'2', "..---"},{'3', "...--"},
{'4', "....-"},{'5', "....."},{'6', "-...."},{'7', "--..."},
{'8', "---.."},{'9', "----."}
};
/**
* @brief Lookup Morse pattern for given character.
* @param in Character to look up (case-insensitive)
* @return Pointer to pattern string, or NULL if unsupported
*/
static const char *lookupMorse(char in)
{
unsigned int i;
/* Convert lowercase to uppercase */
if (in >= 'a' && in <= 'z') {
in -= ('a' - 'A');
}
/* Search table */
for (i = 0; i < sizeof(morseTable) / sizeof(morseTable[0]); i++) {
if (morseTable[i].c == in) {
return morseTable[i].pattern;
}
}
return NULL;
}
/**
* @brief Initialize the LED pin for output.
*
* Unlocks FRAM I/O power-on default high-impedance lock,
* then configures LED pin as output low.
*/
void morse_init(void)
{
PMM_unlockLPM5();
GPIO_setAsOutputPin(LED_PORT, LED_PIN);
GPIO_setOutputLowOnPin(LED_PORT, LED_PIN);
}
/**
* @brief Blink a single character in Morse code.
*
* Uses dot (.) and dash (-) patterns for timing, with
* an inter-letter gap of 3 units (2 units additional after pattern).
* Unsupported characters are ignored.
*
* @param c Character to blink (AZ, az, 09)
*/
void blink_morse_char(char c)
{
const char *pattern = lookupMorse(c);
const char *p;
if (!pattern) {
return;
}
/* Blink each element in pattern */
for (p = pattern; *p; p++) {
if (*p == '.') {
blink_dot();
} else if (*p == '-') {
blink_dash();
}
}
/* Inter-letter gap: total 3 units; dot/dash leaves 1 unit, so add 2 */
__delay_cycles(2 * MORSE_UNIT_CYCLES);
}

Some files were not shown because too many files have changed in this diff Show More