Selaa lähdekoodia

dac read corrected with SingleWrite

namrota ghosh 8 kuukautta sitten
vanhempi
commit
f4efce9c40

+ 32 - 32
.cproject

@@ -15,8 +15,8 @@
             <storageModule moduleId="cdtBuildSystem" version="4.0.0">
                 <configuration artifactExtension="out" artifactName="${ProjName}" buildProperties="" cleanCommand="${CG_CLEAN_CMD}" description="" id="com.ti.ccstudio.buildDefinitions.TMS470.Debug.1330295774" name="Debug" parent="com.ti.ccstudio.buildDefinitions.TMS470.Debug">
                     <folderInfo id="com.ti.ccstudio.buildDefinitions.TMS470.Debug.1330295774." name="/" resourcePath="">
-                        <toolChain id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.exe.DebugToolchain.1874229270" name="TI Build Tools" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.exe.DebugToolchain" targetTool="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.exe.linkerDebug.1840046603">
-                            <option id="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS.277352073" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS" valueType="stringList">
+                        <toolChain id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.exe.DebugToolchain.1554510281" name="TI Build Tools" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.exe.DebugToolchain" targetTool="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.exe.linkerDebug.1089790574">
+                            <option id="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS.603808739" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS" valueType="stringList">
                                 <listOptionValue value="DEVICE_CONFIGURATION_ID=Cortex M.MSPM0G3507"/>
                                 <listOptionValue value="DEVICE_CORE_ID="/>
                                 <listOptionValue value="DEVICE_ENDIANNESS=little"/>
@@ -27,17 +27,17 @@
                                 <listOptionValue value="PRODUCT_MACRO_IMPORTS={&quot;MSPM0-SDK&quot;:[&quot;${COM_TI_MSPM0_SDK_INCLUDE_PATH}&quot;,&quot;${COM_TI_MSPM0_SDK_LIBRARY_PATH}&quot;,&quot;${COM_TI_MSPM0_SDK_LIBRARIES}&quot;,&quot;${COM_TI_MSPM0_SDK_SYMBOLS}&quot;,&quot;${COM_TI_MSPM0_SDK_SYSCONFIG_MANIFEST}&quot;],&quot;sysconfig&quot;:[&quot;${SYSCONFIG_TOOL_INCLUDE_PATH}&quot;,&quot;${SYSCONFIG_TOOL_LIBRARY_PATH}&quot;,&quot;${SYSCONFIG_TOOL_LIBRARIES}&quot;,&quot;${SYSCONFIG_TOOL_SYMBOLS}&quot;,&quot;${SYSCONFIG_TOOL_SYSCONFIG_MANIFEST}&quot;]}"/>
                                 <listOptionValue value="OUTPUT_TYPE=executable"/>
                             </option>
-                            <option id="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION.1547793914" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION" value="TICLANG_4.0.0.LTS" valueType="string"/>
-                            <targetPlatform id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.exe.targetPlatformDebug.959432679" name="Platform" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.exe.targetPlatformDebug"/>
-                            <builder buildPath="${BuildDirectory}" id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.exe.builderDebug.273421561" name="GNU Make.Debug" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.exe.builderDebug"/>
-                            <tool id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.exe.compilerDebug.1432021582" name="Arm Compiler" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.exe.compilerDebug">
-                                <option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.MARCH.176788296" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.MARCH" value="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.MARCH.thumbv6m" valueType="enumerated"/>
-                                <option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.MCPU.1921641922" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.MCPU" value="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.MCPU.cortex-m0plus" valueType="enumerated"/>
-                                <option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.MFLOAT_ABI.380700039" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.MFLOAT_ABI" value="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.MFLOAT_ABI.soft" valueType="enumerated"/>
-                                <option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.ENDIAN_NESS__BIG_LITTLE.1311591585" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.ENDIAN_NESS__BIG_LITTLE" value="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.ENDIAN_NESS__BIG_LITTLE.MLITTLE_ENDIAN" valueType="enumerated"/>
-                                <option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.SELECT_PROCESSOR_MODE__ARM_THUMB.1751136976" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.SELECT_PROCESSOR_MODE__ARM_THUMB" value="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.SELECT_PROCESSOR_MODE__ARM_THUMB.MTHUMB" valueType="enumerated"/>
-                                <option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.OPT_LEVEL.1001387270" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.OPT_LEVEL" value="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.OPT_LEVEL.0" valueType="enumerated"/>
-                                <option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.INCLUDE_PATH.2024452914" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.INCLUDE_PATH" valueType="includePath">
+                            <option id="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION.1198755417" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION" value="TICLANG_4.0.0.LTS" valueType="string"/>
+                            <targetPlatform id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.exe.targetPlatformDebug.2126614422" name="Platform" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.exe.targetPlatformDebug"/>
+                            <builder buildPath="${BuildDirectory}" id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.exe.builderDebug.1627861165" name="GNU Make.Debug" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.exe.builderDebug"/>
+                            <tool id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.exe.compilerDebug.2107467010" name="Arm Compiler" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.exe.compilerDebug">
+                                <option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.MARCH.2109016369" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.MARCH" value="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.MARCH.thumbv6m" valueType="enumerated"/>
+                                <option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.MCPU.864030303" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.MCPU" value="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.MCPU.cortex-m0plus" valueType="enumerated"/>
+                                <option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.MFLOAT_ABI.889897834" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.MFLOAT_ABI" value="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.MFLOAT_ABI.soft" valueType="enumerated"/>
+                                <option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.ENDIAN_NESS__BIG_LITTLE.824313129" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.ENDIAN_NESS__BIG_LITTLE" value="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.ENDIAN_NESS__BIG_LITTLE.MLITTLE_ENDIAN" valueType="enumerated"/>
+                                <option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.SELECT_PROCESSOR_MODE__ARM_THUMB.1381178007" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.SELECT_PROCESSOR_MODE__ARM_THUMB" value="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.SELECT_PROCESSOR_MODE__ARM_THUMB.MTHUMB" valueType="enumerated"/>
+                                <option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.OPT_LEVEL.740954497" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.OPT_LEVEL" value="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.OPT_LEVEL.0" valueType="enumerated"/>
+                                <option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.INCLUDE_PATH.1177209981" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.INCLUDE_PATH" valueType="includePath">
                                     <listOptionValue value="${COM_TI_MSPM0_SDK_INCLUDE_PATH}"/>
                                     <listOptionValue value="${SYSCONFIG_TOOL_INCLUDE_PATH}"/>
                                     <listOptionValue value="${PROJECT_ROOT}"/>
@@ -45,26 +45,26 @@
                                     <listOptionValue value="${COM_TI_MSPM0_SDK_INSTALL_DIR}/source/third_party/CMSIS/Core/Include"/>
                                     <listOptionValue value="${COM_TI_MSPM0_SDK_INSTALL_DIR}/source"/>
                                 </option>
-                                <option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.DEFINE.510971352" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.DEFINE" valueType="definedSymbols">
+                                <option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.DEFINE.267304742" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.DEFINE" valueType="definedSymbols">
                                     <listOptionValue value="${COM_TI_MSPM0_SDK_SYMBOLS}"/>
                                     <listOptionValue value="${SYSCONFIG_TOOL_SYMBOLS}"/>
                                 </option>
-                                <option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.GENERATE_DWARF_DEBUG.1115098559" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.GENERATE_DWARF_DEBUG" value="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.GENERATE_DWARF_DEBUG.GDWARF_3" valueType="enumerated"/>
-                                <option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.CMD_FILE.190405872" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.CMD_FILE" valueType="stringList">
+                                <option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.GENERATE_DWARF_DEBUG.1021924635" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.GENERATE_DWARF_DEBUG" value="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.GENERATE_DWARF_DEBUG.GDWARF_3" valueType="enumerated"/>
+                                <option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.CMD_FILE.1584166646" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.compilerID.CMD_FILE" valueType="stringList">
                                     <listOptionValue value="device.opt"/>
                                 </option>
                             </tool>
-                            <tool id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.exe.linkerDebug.1840046603" name="Arm Linker" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.exe.linkerDebug">
-                                <option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.MAP_FILE.39638249" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.MAP_FILE" value="${ProjName}.map" valueType="string"/>
-                                <option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.OUTPUT_FILE.799556693" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.OUTPUT_FILE" value="${ProjName}.out" valueType="string"/>
-                                <option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.HEAP_SIZE.659509263" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.HEAP_SIZE" value="0x1000" valueType="string"/>
-                                <option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.LIBRARY.1148428777" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.LIBRARY" valueType="libs">
+                            <tool id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.exe.linkerDebug.1089790574" name="Arm Linker" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.exe.linkerDebug">
+                                <option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.MAP_FILE.1779749605" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.MAP_FILE" value="${ProjName}.map" valueType="string"/>
+                                <option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.OUTPUT_FILE.235075907" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.OUTPUT_FILE" value="${ProjName}.out" valueType="string"/>
+                                <option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.HEAP_SIZE.460141283" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.HEAP_SIZE" value="0x1000" valueType="string"/>
+                                <option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.LIBRARY.138829623" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.LIBRARY" valueType="libs">
                                     <listOptionValue value="${COM_TI_MSPM0_SDK_LIBRARIES}"/>
                                     <listOptionValue value="${SYSCONFIG_TOOL_LIBRARIES}"/>
                                     <listOptionValue value="device.cmd.genlibs"/>
                                     <listOptionValue value="libc.a"/>
                                 </option>
-                                <option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.SEARCH_PATH.1437152857" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.SEARCH_PATH" valueType="libPaths">
+                                <option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.SEARCH_PATH.12767883" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.SEARCH_PATH" valueType="libPaths">
                                     <listOptionValue value="${COM_TI_MSPM0_SDK_LIBRARY_PATH}"/>
                                     <listOptionValue value="${SYSCONFIG_TOOL_LIBRARY_PATH}"/>
                                     <listOptionValue value="${COM_TI_MSPM0_SDK_INSTALL_DIR}/source"/>
@@ -72,17 +72,17 @@
                                     <listOptionValue value="${PROJECT_BUILD_DIR}/syscfg"/>
                                     <listOptionValue value="${CG_TOOL_ROOT}/lib"/>
                                 </option>
-                                <option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.REREAD_LIBS.1613873861" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.REREAD_LIBS" value="false" valueType="boolean"/>
-                                <option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.DIAG_WRAP.358579320" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.DIAG_WRAP" value="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.DIAG_WRAP.off" valueType="enumerated"/>
-                                <option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.DISPLAY_ERROR_NUMBER.142625368" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.DISPLAY_ERROR_NUMBER" value="true" valueType="boolean"/>
-                                <option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.XML_LINK_INFO.579183302" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.XML_LINK_INFO" value="${ProjName}_linkInfo.xml" valueType="string"/>
+                                <option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.REREAD_LIBS.1943682163" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.REREAD_LIBS" value="false" valueType="boolean"/>
+                                <option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.DIAG_WRAP.939851968" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.DIAG_WRAP" value="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.DIAG_WRAP.off" valueType="enumerated"/>
+                                <option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.DISPLAY_ERROR_NUMBER.1274646754" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.DISPLAY_ERROR_NUMBER" value="true" valueType="boolean"/>
+                                <option id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.XML_LINK_INFO.1814908558" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.linkerID.XML_LINK_INFO" value="${ProjName}_linkInfo.xml" valueType="string"/>
                             </tool>
-                            <tool id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.hex.1906934551" name="Arm Hex Utility" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.hex"/>
-                            <tool id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.objcopy.1030212511" name="Arm Objcopy Utility" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.objcopy"/>
-                            <tool id="com.ti.ccstudio.buildDefinitions.sysConfig.1669516373" name="SysConfig" superClass="com.ti.ccstudio.buildDefinitions.sysConfig">
-                                <option id="com.ti.ccstudio.buildDefinitions.sysConfig.DIRECTORY_MODE.338947889" superClass="com.ti.ccstudio.buildDefinitions.sysConfig.DIRECTORY_MODE" value="com.ti.ccstudio.buildDefinitions.sysConfig.DIRECTORY_MODE.manual" valueType="enumerated"/>
-                                <option id="com.ti.ccstudio.buildDefinitions.sysConfig.OUTPUT_DIR__MANUAL.953805556" superClass="com.ti.ccstudio.buildDefinitions.sysConfig.OUTPUT_DIR__MANUAL" value="." valueType="string"/>
-                                <option id="com.ti.ccstudio.buildDefinitions.sysConfig.PRODUCTS.1603468399" superClass="com.ti.ccstudio.buildDefinitions.sysConfig.PRODUCTS" valueType="stringList">
+                            <tool id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.hex.1559768826" name="Arm Hex Utility" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.hex"/>
+                            <tool id="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.objcopy.269774060" name="Arm Objcopy Utility" superClass="com.ti.ccstudio.buildDefinitions.TMS470_TICLANG_4.0.objcopy"/>
+                            <tool id="com.ti.ccstudio.buildDefinitions.sysConfig.1620007687" name="SysConfig" superClass="com.ti.ccstudio.buildDefinitions.sysConfig">
+                                <option id="com.ti.ccstudio.buildDefinitions.sysConfig.DIRECTORY_MODE.1256531140" superClass="com.ti.ccstudio.buildDefinitions.sysConfig.DIRECTORY_MODE" value="com.ti.ccstudio.buildDefinitions.sysConfig.DIRECTORY_MODE.manual" valueType="enumerated"/>
+                                <option id="com.ti.ccstudio.buildDefinitions.sysConfig.OUTPUT_DIR__MANUAL.864855913" superClass="com.ti.ccstudio.buildDefinitions.sysConfig.OUTPUT_DIR__MANUAL" value="." valueType="string"/>
+                                <option id="com.ti.ccstudio.buildDefinitions.sysConfig.PRODUCTS.35102240" superClass="com.ti.ccstudio.buildDefinitions.sysConfig.PRODUCTS" valueType="stringList">
                                     <listOptionValue value="${COM_TI_MSPM0_SDK_SYSCONFIG_MANIFEST}"/>
                                     <listOptionValue value="${SYSCONFIG_TOOL_SYSCONFIG_MANIFEST}"/>
                                 </option>

+ 4 - 0
.settings/org.eclipse.core.resources.prefs

@@ -2,6 +2,10 @@ eclipse.preferences.version=1
 encoding//Debug/makefile=UTF-8
 encoding//Debug/objects.mk=UTF-8
 encoding//Debug/sources.mk=UTF-8
+encoding//Debug/src/hal/subdir_rules.mk=UTF-8
+encoding//Debug/src/hal/subdir_vars.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
 encoding//Debug/ti/comm_modules/i2c/controller/subdir_rules.mk=UTF-8

+ 18 - 0
.theia/launch.json

@@ -9,6 +9,24 @@
                 "name": "charge_controller_v7",
                 "resourceId": "/charge_controller_v7/i2c_target.c"
             }
+        },
+        {
+            "name": "charge_controller_v7 (1)",
+            "type": "ccs-debug",
+            "request": "launch",
+            "projectInfo": {
+                "name": "charge_controller_v7",
+                "resourceId": "/charge_controller_v7"
+            }
+        },
+        {
+            "name": "charge_controller_v7 (2)",
+            "type": "ccs-debug",
+            "request": "launch",
+            "projectInfo": {
+                "name": "charge_controller_v7",
+                "resourceId": "/charge_controller_v7/src/hal/i2c_hal.c"
+            }
         }
     ]
 }

+ 0 - 6
adc_driver.c

@@ -1,6 +0,0 @@
-#include "adc_driver.h"
-#include "adc.h"
-#include "ti_msp_dl_config.h"
-#include "ti/driverlib/dl_i2c.h"
-
-

+ 0 - 8
adc_driver.h

@@ -1,8 +0,0 @@
-#ifndef ADC_DRIVER_H_
-#define ADC_DRIVER_H_
-#include<stdint.h>
-#include<stdbool.h>
-
-
-
-#endif

+ 0 - 115
dac.c

@@ -1,115 +0,0 @@
-#include "dac.h"
-#include <stdint.h>
-#include <stdio.h>
-#include "ti/driverlib/dl_i2c.h"
-#include "ti_msp_dl_config.h"
-
-
-//The device updates all DAC analog output(vout) at the same time
-
-void DAC_UpdateOutput() {
-    uint8_t general_call_command = 0x08;  // General Call Update Command
-    while (DL_I2C_getControllerStatus(I2C_controller_INST) & DL_I2C_CONTROLLER_STATUS_BUSY_BUS);
-    DL_I2C_fillControllerTXFIFO(I2C_controller_INST, &general_call_command, 1);
-
-    // Start I2C transaction
-    DL_I2C_startControllerTransfer(I2C_controller_INST, 0x00, DL_I2C_CONTROLLER_DIRECTION_TX, 1);
-    
-    while (DL_I2C_getControllerStatus(I2C_controller_INST) & DL_I2C_CONTROLLER_STATUS_BUSY_BUS);
-
-    printf("DAC Outputs Updated via General Call Software Update!\n");
-}
-
-/**Function for FAST write command, sending values over I2c to every channel of DAC**/
-bool DAC_fastWrite(uint16_t channel_a_value){
-
-    /*DAC has a 12 bit resolution that ranges from 0 to 4095.
-    0x00: sets the Power Mode to NORMAL for Channel A
-    (channel_a_value >> 8): shifts the value to 8 places right and gives upper 4 bits
-    VoutA channel, rest channels are powered down
-    */
-
-    uint8_t output_buffer[8];
-
-    output_buffer[0]= (0x00)|(channel_a_value >> 8)&0x0F;
-    output_buffer[1]= channel_a_value & 0xFF;
-
-    output_buffer[2]= 0x40; // Power down for the other channels
-    output_buffer[3]= 0x00; 
-
-    output_buffer[4]= 0x40;
-    output_buffer[5]= 0x00;
-
-    output_buffer[6]= 0x40;
-    output_buffer[7]= 0x00;
-
-    if (DL_I2C_getControllerStatus(I2C_controller_INST) & DL_I2C_CONTROLLER_STATUS_ERROR) {
-        printf("I2C Write Error: Failed to write to DAC channels for FAST write mode!\n");
-        DL_I2C_resetControllerTransfer(I2C_controller_INST); // Reset bus if stuck
-        return false;  // Return failure if there was an error
-    }
-
-    // **Wait for I2C Bus to be Free**
-    while (DL_I2C_getControllerStatus(I2C_controller_INST) & DL_I2C_CONTROLLER_STATUS_BUSY_BUS);
-
-    // **Start I2C Write Transaction**
-    DL_I2C_startControllerTransfer(I2C_controller_INST, DAC_TARGET_BASE_ADDRESS, DL_I2C_CONTROLLER_DIRECTION_TX, 8);
-
-    // **Load Configuration Byte into TX FIFO**
-    DL_I2C_fillControllerTXFIFO(I2C_controller_INST, (uint8_t*)&output_buffer, 8);
-
-
-    // **Ensure STOP Condition is Sent**
-    while (DL_I2C_getControllerStatus(I2C_controller_INST) & DL_I2C_CONTROLLER_STATUS_BUSY_BUS);
-    printf("DAC Fast write Successful!\n");
-    DAC_UpdateOutput();
-    return true;
-
-}
-
-/*
-LDAC pin is set to HIGH or LOW
-LDAC "HIGH": until the end of the positive pulse of the 8th clock of the 2nd byte
-LDAC "LOW": negative pulse of the 8th clock of the 2nd byte and stays low until the rising edge of the 9th clock of the 3rd byte
-LDAC pin resumes normal function after STOP bit
-Device address of 0x60 till 0x67, default is 0x60
-*/
-
-void ldac_pin_init(){
-    //Default set to HIGH
-    DL_GPIO_setPins(LDAC_PIN_PORT, LDAC_PIN_PIN_PA8_PIN);
-}
-
-void set_ldac(bool level){
-    if(level){
-        // Set LDAC Pins HIGH
-        DL_GPIO_setPins(LDAC_PIN_PORT, LDAC_PIN_PIN_PA8_PIN);
-    }
-    else{
-        // Set LDAC Pins LOW
-        DL_GPIO_clearPins(LDAC_PIN_PORT, LDAC_PIN_PIN_PA8_PIN);
-    }
-}
-/*General Call Read Address: Command to read I2C address bits of the device*/
-uint8_t DAC_ReadCurrentAddress(){
-    uint8_t current_address= 0;
-    //General call address bits
-    uint8_t command= 0xC3;
-    while (DL_I2C_getControllerStatus(I2C_controller_INST) & DL_I2C_CONTROLLER_STATUS_BUSY_BUS);
-
-    //Send General Call Read Address Command
-    DL_I2C_startControllerTransfer(I2C_controller_INST, I2C_GENERAL_CALL_ADDR, DL_I2C_CONTROLLER_DIRECTION_TX, 1);
-    DL_I2C_fillControllerTXFIFO(I2C_controller_INST, &command, 1);
-
-    while (DL_I2C_getControllerStatus(I2C_controller_INST) & DL_I2C_CONTROLLER_STATUS_BUSY_BUS);
-
-    //Read the response (Current DAC I2C address)
-    DL_I2C_startControllerTransfer(I2C_controller_INST, I2C_GENERAL_CALL_ADDR, DL_I2C_CONTROLLER_DIRECTION_RX, 1);
-    current_address= DL_I2C_receiveControllerData(I2C_controller_INST);
-
-    //Debug
-    printf("Current DAC I2C Address: 0x%02X\n", current_address);
-    return current_address;
-}
-
-

+ 52 - 37
adc.c → src/adc.c

@@ -1,8 +1,9 @@
 #include "battery.h"
+#include "src/interfaces/i2c_controller_interface.h"
 #include "ti/driverlib/dl_i2c.h"
 #include "ti/driverlib/m0p/dl_core.h"
 #include "ti_msp_dl_config.h"
-#include <adc.h>
+#include "adc.h"
 #include <stdint.h>
 #include <stdio.h>
 
@@ -13,10 +14,16 @@ uint8_t gRxPacket[I2C_RX_MAX_PACKET_SIZE];
 
 uint32_t gTxADClen, gTxADCcount;
 uint32_t gRxADClen, gRxADCcount;
+
 static ADC_PARAMS adc_params;
 static ADC_MeasurementState adc_state = ADC_STATE_CONFIGURE;
 
-uint8_t ADC_ConstructConfigBytes(ADC_PARAMS params) {
+/*
+* Creating Configuartion Register as mentioned in the datasheet: https://ww1.microchip.com/downloads/aemDocuments/documents/OTH/ProductDocuments/DataSheets/22226a.pdf
+* Under section 5.2 Configuration Register
+* The function is private to ADC and is can only be called in this file
+*/
+static uint8_t ADC_ConstructConfigBytes(ADC_PARAMS params) {
 
   uint8_t config = 0;
 
@@ -76,17 +83,19 @@ void ADC_SetConfigurationBytes(ADC_PARAMS params) {
   gTxADCcount = 0;
   gTxComplete = false;
 
-  DL_I2C_flushControllerTXFIFO(I2C_controller_INST);
-  DL_I2C_fillControllerTXFIFO(I2C_controller_INST, (uint8_t *)&gTxPacket, 1);
-  DL_I2C_startControllerTransfer(I2C_controller_INST, ADC_TARGET_BASE_ADDRESS,
-                                 DL_I2C_CONTROLLER_DIRECTION_TX, gTxADClen);
+  i2c_hal.write(ADC_TARGET_BASE_ADDRESS, gTxPacket, gTxADClen);
+
+  //DL_I2C_flushControllerTXFIFO(I2C_controller_INST);
+  //DL_I2C_fillControllerTXFIFO(I2C_controller_INST, (uint8_t *)&gTxPacket, 1);
+  //DL_I2C_startControllerTransfer(I2C_controller_INST, ADC_TARGET_BASE_ADDRESS,
+   //                              DL_I2C_CONTROLLER_DIRECTION_TX, gTxADClen);
   // DL_I2C_enableInterrupt(I2C_controller_INST,
   //                        DL_I2C_INTERRUPT_CONTROLLER_TXFIFO_TRIGGER);
   //  while(!gTxComplete);
   //   **Ensure STOP Condition is Sent**
-  while (DL_I2C_getControllerStatus(I2C_controller_INST) &
-         DL_I2C_CONTROLLER_STATUS_BUSY_BUS)
-    ;
+  //while (DL_I2C_getControllerStatus(I2C_controller_INST) &
+  //       DL_I2C_CONTROLLER_STATUS_BUSY_BUS)
+  //  ;
   // printf("Configuration Sent Successfully for 0x%X!\n", config_byte);
 }
 
@@ -110,15 +119,17 @@ bool ADC_CheckReadyBit(uint8_t slot_id, ADC_PARAMS params) {
   gRxADCcount = 0;
   gRxComplete = false;
 
-  DL_I2C_startControllerTransfer(I2C_controller_INST, adc_address,
-                                 DL_I2C_CONTROLLER_DIRECTION_RX, gRxADClen);
-  DL_I2C_enableInterrupt(I2C_controller_INST,
-                         DL_I2C_INTERRUPT_CONTROLLER_RXFIFO_TRIGGER);
-  while (DL_I2C_getControllerStatus(I2C_controller_INST) &
-         DL_I2C_CONTROLLER_STATUS_BUSY_BUS)
-    ;
-  while (!gRxComplete)
-    ;
+  i2c_hal.read(adc_address, gRxADClen);
+
+  //DL_I2C_startControllerTransfer(I2C_controller_INST, adc_address,
+  //                               DL_I2C_CONTROLLER_DIRECTION_RX, gRxADClen);
+  //DL_I2C_enableInterrupt(I2C_controller_INST,
+  //                       DL_I2C_INTERRUPT_CONTROLLER_RXFIFO_TRIGGER);
+  //while (DL_I2C_getControllerStatus(I2C_controller_INST) &
+  //       DL_I2C_CONTROLLER_STATUS_BUSY_BUS)
+  //  ;
+  //while (!gRxComplete)
+  //  ;
 
   uint8_t config_adc_byte = gRxPacket[2];
 
@@ -184,30 +195,34 @@ int16_t ADC_ReadData(uint8_t slot_id, ADC_PARAMS params) {
   uint8_t adc_address = ADC_TARGET_BASE_ADDRESS + slot_id;
   // printf("Reading ADC Data from MCP3428 for channel: %u\n", params.channel);
 
-  if (DL_I2C_getControllerStatus(I2C_controller_INST) &
-      DL_I2C_CONTROLLER_STATUS_BUSY_BUS) {
-    printf("Error: I2C bus stuck! Resetting..\n");
+  
+
+  //if (DL_I2C_getControllerStatus(I2C_controller_INST) &
+  //    DL_I2C_CONTROLLER_STATUS_BUSY_BUS) {
+  //  printf("Error: I2C bus stuck! Resetting..\n");
     // DL_I2C_resetControllerTransfer(I2C_controller_INST);
-  }
+  //}
 
   gRxADClen = bytes_to_read;
   gRxADCcount = 0;
   gRxComplete = false;
 
-  DL_I2C_startControllerTransfer(I2C_controller_INST, adc_address,
-                                 DL_I2C_CONTROLLER_DIRECTION_RX, gRxADClen);
-  DL_I2C_enableInterrupt(I2C_controller_INST,
-                         DL_I2C_INTERRUPT_CONTROLLER_RXFIFO_TRIGGER);
-  while (DL_I2C_getControllerStatus(I2C_controller_INST) &
-         DL_I2C_CONTROLLER_STATUS_BUSY_BUS)
-    ;
-  while (!gRxComplete)
-    ;
+  i2c_hal.read(adc_address, gRxADClen);
+
+  //DL_I2C_startControllerTransfer(I2C_controller_INST, adc_address,
+  //                               DL_I2C_CONTROLLER_DIRECTION_RX, gRxADClen);
+  //DL_I2C_enableInterrupt(I2C_controller_INST,
+  //                       DL_I2C_INTERRUPT_CONTROLLER_RXFIFO_TRIGGER);
+  //while (DL_I2C_getControllerStatus(I2C_controller_INST) &
+  //       DL_I2C_CONTROLLER_STATUS_BUSY_BUS)
+  //  ;
+  //while (!gRxComplete)
+  //  ;
 
   uint8_t msb = gRxPacket[0];
   uint8_t lsb = gRxPacket[1];
   uint8_t config_adc_byte = gRxPacket[2];
-
+  printf("MSB: 0x%02X, LSB: 0x%02X\n", msb, lsb);
   uint8_t gain_setting = (config_adc_byte & 0x03);
   uint8_t gain_multiplier = (1 << gain_setting); // Gain values: 1, 2, 4, 8
 
@@ -256,7 +271,7 @@ uint16_t ADC_ConvertToVoltage(int16_t adc_value, ADC_PARAMS params) {
     printf("Error: Unknown ADC Resolution!\n");
     return 0;
   }
-  measured_voltage = (((uint32_t)adc_value * ADC_VREF_MV) * 3) / max_adc_value;
+  measured_voltage = (((uint32_t)adc_value) * 2.7);
   return (uint16_t)measured_voltage;
 }
 
@@ -268,7 +283,7 @@ uint16_t ADC_ConvertToCurrent(int16_t adc_value, ADC_PARAMS params) {
   uint16_t voltage_mV = ADC_ConvertToVoltage(adc_value, params);
   uint8_t gain_multiplier = (1 << (params.gain - 1));
   // Convert voltage drop across shunt resistor to current
-  current_mA = (voltage_mV) / (0.1 * gain_multiplier);
+  current_mA = (adc_value) * (10 * gain_multiplier);
   // printf("Converted Current: %d mA.\n", current_mA);
   return (int16_t)current_mA;
 }
@@ -279,9 +294,9 @@ void Battery_UpdateADCReading(uint8_t slot, uint8_t channel) {
 
     case ADC_STATE_CONFIGURE:
       adc_params.channel = channel;
-      // printf("Channel: %d\n", adc_params.channel);
+      printf("Channel: %d\n", adc_params.channel);
       adc_params.resolution = 12;
-      adc_params.continuous = 1;
+      adc_params.continuous = 0;
       adc_params.gain = 1;
       ADC_SetConfigurationBytes(adc_params);
       adc_state = ADC_STATE_WAIT;
@@ -298,7 +313,7 @@ void Battery_UpdateADCReading(uint8_t slot, uint8_t channel) {
 
         int16_t raw_adc_voltage = ADC_ReadData(slot, adc_params);
         batteries[slot].voltage =
-            ADC_ConvertToVoltage(raw_adc_voltage, adc_params);
+            ADC_ConvertToVoltage(raw_adc_voltage, adc_params); // Double check voltage dividers later on to get the right value (possibly instead of 2)
         printf("Battery voltage for slot %d is %u mV.\n", slot,
                batteries[slot].voltage);
         adc_state = ADC_STATE_DONE;

+ 1 - 1
adc.h → src/adc.h

@@ -37,7 +37,7 @@ typedef struct{
     uint8_t gain;
 } ADC_PARAMS;
 
-uint8_t ADC_ConstructConfigBytes(ADC_PARAMS params);
+
 void ADC_SetConfigurationBytes(ADC_PARAMS params);
 bool ADC_CheckReadyBit(uint8_t slot_id, ADC_PARAMS params);
 int16_t ADC_ReadData(uint8_t slot_id, ADC_PARAMS params);

+ 0 - 0
battery.c → src/battery.c


+ 1 - 1
battery.h → src/battery.h

@@ -5,7 +5,7 @@
 //define macro to be used by multiple files in the program witout the variable being overwritten
 //for testing
 #define NUM_SLOTS (1)
-#define BATTERY_THRESHOLD (50)
+#define BATTERY_THRESHOLD (100)
 
 
 //Battery states

+ 27 - 11
cc_cv_charging.c → src/cc_cv_charging.c

@@ -83,42 +83,56 @@ void CC_CV_ControlCharging(uint8_t slot_id){
     int16_t batt_current= batteries[slot_id].current;
     uint16_t batt_cutoff_current= batteries[slot_id].cut_off_current;
     uint16_t charge_current_mA= (batteries[slot_id].capacitance * batteries[slot_id].charge_fraction)/100;
-    int16_t dac_channel_VoutA;
+    static uint16_t dac_channel_VoutA= 2000;
 
     switch(charging_state){
-        
         case STATE_PRE_CHARGE:
             DL_GPIO_setPins(GPIO_Battery_Charging_PORT, GPIO_Battery_Charging_PIN_PB4_PIN);
             uint16_t pre_charge_current_limit_ma = charge_current_mA/10;
-            DAC_fastWrite(pre_charge_current_limit_ma);
-            printf("[CC-CV] Pre Charging: Slot %d at %d mA.\n", slot_id, pre_charge_current_limit_ma);
+            //DAC_fastWrite(pre_charge_current_limit_ma);
+            //DAC_fastWrite(dac_channel_VoutA);
+            DAC_SingleWrite(dac_channel_VoutA);
+            //DAC_UpdateOutput();
+            if(true){
+                printf("[CC-CV] Pre Charging: Slot %d at %d mA.\n", slot_id, dac_channel_VoutA);
+            }
+            
             break;
         
         case STATE_CC_CHARGING:
             DL_GPIO_setPins(GPIO_Battery_Charging_PORT, GPIO_Battery_Charging_PIN_PB4_PIN);
-            DAC_fastWrite(charge_current_mA);
+            if(batt_voltage>= 3700) //3.7 Volts of Fast Charging
+            {
+                printf("[CC-CV] CC Charging Completed!\n");
+                break;
+            }
+            uint16_t target_current_mA= CC_CURRENT_LIMIT_MA;
+            //Convert to voltage using Shunt resistor
+            uint16_t voltage_mV= target_current_mA * SHUNT_RESISTOR * 1000;
+
+            DAC_SingleWrite(charge_current_mA);
             printf("[CC-CV] CC Charging: Slot %d at %d mA.\n", slot_id, CC_CURRENT_LIMIT_MA);
             break;
         
         case STATE_CV_CHARGING:
             DL_GPIO_setPins(GPIO_Battery_Charging_PORT, GPIO_Battery_Charging_PIN_PB4_PIN);
             if(batt_current >= batt_cutoff_current+BATTERY_THRESHOLD){
-                //Reducing by 5%
-                dac_channel_VoutA= (batt_current - (batt_current-0.05));
+                dac_channel_VoutA= (dac_channel_VoutA - 50);
+                printf("DAC Channel Value: %d, Battery Current:%d \n", dac_channel_VoutA, batt_current);
             }
             else{
                 dac_channel_VoutA= 0;
                 charging_state= STATE_FINAL_DISCHARGE;
             }
-            DAC_fastWrite(dac_channel_VoutA);
-            printf("[CC-CV] CV Charging: Slot %d at %d mA.\n", slot_id, CUTOFF_CURRENT_MA);
+            DAC_SingleWrite(dac_channel_VoutA);
+            printf("[CC-CV] CV Charging: Slot %d at %d mA.\n", slot_id, dac_channel_VoutA);
             break;
         
         case STATE_DISCHARGING:
             DL_GPIO_clearPins(GPIO_Battery_Charging_PORT, GPIO_Battery_Charging_PIN_PB4_PIN);
             DL_GPIO_setPins(GPIO_Battery_Discharging_PORT, GPIO_Battery_Discharging_PIN_PB12_PIN);
             //still unsure about the value for channel VoutA:
-            DAC_fastWrite(batt_voltage);
+            DAC_SingleWrite(batt_voltage);
             printf("[CC-CV] Discharging: Slot %d at %d mA.\n", slot_id, batt_voltage);
             break;
 
@@ -126,12 +140,14 @@ void CC_CV_ControlCharging(uint8_t slot_id){
             DL_GPIO_clearPins(GPIO_Battery_Charging_PORT, GPIO_Battery_Charging_PIN_PB4_PIN);
             DL_GPIO_clearPins(GPIO_Battery_Discharging_PORT, GPIO_Battery_Discharging_PIN_PB12_PIN);
             printf("[CC-CV] Final Discharge: Slot %d..\n", slot_id);
-            DAC_fastWrite(0);
+            DAC_SingleWrite(0);
+            
         
         case STATE_ERROR:
             DL_GPIO_clearPins(GPIO_Battery_Charging_PORT, GPIO_Battery_Charging_PIN_PB4_PIN);
             DL_GPIO_clearPins(GPIO_Battery_Discharging_PORT, GPIO_Battery_Discharging_PIN_PB12_PIN);
             printf("[CC-CV] Error: Slot %d.\n", slot_id);
+            
 
         default:
             break;

+ 0 - 0
cc_cv_charging.h → src/cc_cv_charging.h


+ 161 - 0
src/dac.c

@@ -0,0 +1,161 @@
+#include "dac.h"
+#include "src/interfaces/i2c_controller_interface.h"
+#include "ti/driverlib/dl_i2c.h"
+#include "ti_msp_dl_config.h"
+#include <stdint.h>
+#include <stdio.h>
+
+// The device updates all DAC analog output(vout) at the same time
+
+void DAC_UpdateOutput() {
+  uint8_t general_call_command = 0x08; // General Call Update Command
+  while (DL_I2C_getControllerStatus(I2C_controller_INST) &
+         DL_I2C_CONTROLLER_STATUS_BUSY_BUS)
+    ;
+
+  // Start I2C transaction
+  DL_I2C_startControllerTransfer(I2C_controller_INST, 0x00,
+                                 DL_I2C_CONTROLLER_DIRECTION_TX, 1);
+
+  while (DL_I2C_getControllerStatus(I2C_controller_INST) &
+         DL_I2C_CONTROLLER_STATUS_BUSY_BUS)
+    ;
+
+  DL_I2C_fillControllerTXFIFO(I2C_controller_INST, &general_call_command, 1);
+
+  printf("DAC Outputs Updated via General Call Software Update!\n");
+}
+
+/**Function for FAST write command, sending values over I2c to every channel of
+ * DAC**/
+bool DAC_fastWrite(uint16_t channel_a_value) {
+
+  /*DAC has a 12 bit resolution that ranges from 0 to 4095.
+  0x00: sets the Power Mode to NORMAL for Channel A
+  (channel_a_value >> 8): shifts the value to 8 places right and gives upper 4
+  bits VoutA channel, rest channels are powered down Each Vout pins is driven by
+  its own output buffer with a gain of 1 or 2.
+
+  */
+
+  uint8_t output_buffer[8];
+
+  output_buffer[0] = 0x01;
+  output_buffer[1] = 0x00;
+
+  // Normal Mode: PD0 and PD1 is 00
+  output_buffer[2] = (0x00) | ((channel_a_value >> 8) & 0x0F);
+  output_buffer[3] = channel_a_value & 0xFF;
+
+  output_buffer[4] = 0x01;
+  output_buffer[5] = 0x00;
+
+  output_buffer[6] = 0x01;
+  output_buffer[7] = 0x00;
+
+  if (!DL_I2C_CONTROLLER_STATUS_ADDR_ACK) {
+    printf("DAC Address Failure");
+    return false;
+  }
+
+  i2c_hal.write(DAC_TARGET_BASE_ADDRESS, (uint8_t *)&output_buffer, 8);
+  printf("Output Buffer[2]: 0x%02X, Output Buffer[3]: 0x%02X\n",
+         output_buffer[2], output_buffer[3]);
+  printf("DAC Fast write Successful!\n");
+  DAC_UpdateOutput();
+  return true;
+}
+
+/*
+LDAC pin is set to HIGH or LOW
+LDAC "HIGH": until the end of the positive pulse of the 8th clock of the 2nd
+byte LDAC "LOW": negative pulse of the 8th clock of the 2nd byte and stays low
+until the rising edge of the 9th clock of the 3rd byte LDAC pin resumes normal
+function after STOP bit Device address of 0x60 till 0x67, default is 0x60
+*/
+
+/*void ldac_pin_init() {
+  // Default set to HIGH
+  DL_GPIO_setPins(LDAC_PIN_PORT, LDAC_PIN_PIN_PA8_PIN);
+}
+
+void set_ldac(bool level) {
+  if (level) {
+    // Set LDAC Pins HIGH
+    DL_GPIO_setPins(LDAC_PIN_PORT, LDAC_PIN_PIN_PA8_PIN);
+  } else {
+    // Set LDAC Pins LOW
+    DL_GPIO_clearPins(LDAC_PIN_PORT, LDAC_PIN_PIN_PA8_PIN);
+  }
+}*/
+
+/*General Call Read Address: Command to read I2C address bits of the device*/
+uint8_t DAC_ReadCurrentAddress() {
+  uint8_t current_address = 0;
+  // General call address bits
+  uint8_t command = 0xC3;
+  while (DL_I2C_getControllerStatus(I2C_controller_INST) &
+         DL_I2C_CONTROLLER_STATUS_BUSY_BUS)
+    ;
+
+  // Send General Call Read Address Command
+  DL_I2C_startControllerTransfer(I2C_controller_INST, I2C_GENERAL_CALL_ADDR,
+                                 DL_I2C_CONTROLLER_DIRECTION_TX, 1);
+  DL_I2C_fillControllerTXFIFO(I2C_controller_INST, &command, 1);
+
+  while (DL_I2C_getControllerStatus(I2C_controller_INST) &
+         DL_I2C_CONTROLLER_STATUS_BUSY_BUS)
+    ;
+
+  // Read the response (Current DAC I2C address)
+  DL_I2C_startControllerTransfer(I2C_controller_INST, I2C_GENERAL_CALL_ADDR,
+                                 DL_I2C_CONTROLLER_DIRECTION_RX, 1);
+  current_address = DL_I2C_receiveControllerData(I2C_controller_INST);
+
+  // Debug
+  printf("Current DAC I2C Address: 0x%02X\n", current_address);
+  return current_address;
+}
+
+/*
+Single Write for DAC: writes the input data to a selected single DAC input
+register and also to its EEPROM. DAC1: Channel Selection Bits
+    - 00 Channel A
+    - 01 Channel B
+    - 10 Channel C
+    - 11 Channel D
+
+UDAC: DAC latch bit
+    - 0: Upload
+    - 1: Do not upload
+*/
+bool DAC_SingleWrite(uint16_t channel_value) {
+  if(channel_value > 4095){
+    printf("DAC Error: channel_value out of range. Must be between 0 and 4095\n");
+    return false;
+  }
+  uint8_t data_length = 3;
+  uint8_t output_buffer_SingleWrite[data_length];
+  output_buffer_SingleWrite[0] = 0x5A; //0x58 for Channel 0
+  output_buffer_SingleWrite[1] = (0x10) | ((channel_value >> 8) & 0x0F);
+  output_buffer_SingleWrite[2] = (channel_value & 0xFF);
+
+
+  // Log data being sent
+  printf("Sending to DAC: 0x%02X 0x%02X 0x%02X\n",
+           output_buffer_SingleWrite[0],
+           output_buffer_SingleWrite[1],
+           output_buffer_SingleWrite[2]);
+
+  // Write data to DAC
+  if (!i2c_hal.write(DAC_TARGET_BASE_ADDRESS, output_buffer_SingleWrite, data_length)) {
+        printf("I2C DAC Write Error: Failed to write to DAC.\n");
+        return false;
+    }
+
+  DAC_UpdateOutput();
+
+  printf("Output_Buffer_1: 0x%02X, Output_Buffer_2: 0x%02X\n", output_buffer_SingleWrite[1], output_buffer_SingleWrite[2]);
+
+  return true;
+}

+ 3 - 1
dac.h → src/dac.h

@@ -4,11 +4,13 @@
 #include <stdbool.h>
 
 #define DAC_TARGET_BASE_ADDRESS (0x60)
-#define CHANNEL_A_VALUE (800) // in mAmps
+//#define CHANNEL_A_VALUE (800) // in mAmps
 #define I2C_GENERAL_CALL_ADDR  0x00
+#define DAC_VREF_MV 2048
 
 bool DAC_fastWrite(uint16_t channel_a_value);
 void DAC_UpdateOutput();
 uint8_t DAC_ReadCurrentAddress();
+bool DAC_SingleWrite(uint16_t channel_value);
 
 #endif

+ 0 - 0
dynamic_i2c_addressing_mcu.c → src/dynamic_i2c_addressing_mcu.c


+ 85 - 0
src/hal/i2c_hal.c

@@ -0,0 +1,85 @@
+/*
+ * This file implements Hardware Abstraction Layer (HAL) to make the I2C
+ * communication of MSPM0 SDK compatible with ADC (MCP3426/7/8) and DAC
+ * (MCP34728)
+ */
+#include "src/interfaces/i2c_controller_interface.h"
+#include "ti/driverlib/dl_i2c.h"
+#include "ti_msp_dl_config.h"
+#include <stdio.h>
+
+/*
+static function is for implementing Data Hiding, access to the static function
+is restricted to the file where they are declared const keyword for
+'TARGET_ADDRESS' and 'Data_length' makes the variable immutable. const uint8_t *
+const Data: means the pointer to the variable and the value of Data is immutable
+*/
+static bool msp_i2c_write(uint8_t const TARGET_ADDRESS,
+                          const uint8_t *const Data,
+                          uint8_t const Data_length) {
+  // Flush any stale data in TX FIFO:
+  DL_I2C_flushControllerTXFIFO(I2C_controller_INST);
+
+  // **Check if the I2C bus is stuck before WRITE
+  if (DL_I2C_getControllerStatus(I2C_controller_INST) &
+      DL_I2C_CONTROLLER_STATUS_ERROR) {
+    printf("DAC I2C Communication: Bus is stuck!\n");
+    DL_I2C_resetControllerTransfer(I2C_controller_INST); 
+    return false; 
+  }
+  
+  // **Wait for I2C Bus to be Free**
+  while (DL_I2C_getControllerStatus(I2C_controller_INST) &
+         DL_I2C_CONTROLLER_STATUS_BUSY_BUS)
+    ;
+
+  // **Start I2C Write Transaction**
+  DL_I2C_startControllerTransfer(I2C_controller_INST, TARGET_ADDRESS,
+                                 DL_I2C_CONTROLLER_DIRECTION_TX, Data_length);
+
+  // **Load Configuration Byte into TX FIFO**
+  DL_I2C_fillControllerTXFIFO(I2C_controller_INST, (uint8_t *)Data,
+                              Data_length);
+
+  // ** Wait for the I2C Bus to be FREE **
+  while (DL_I2C_getControllerStatus(I2C_controller_INST) &
+         DL_I2C_CONTROLLER_STATUS_BUSY_BUS)
+    ;
+  
+  // **Check if the target address is incorrect
+  
+  if (DL_I2C_getControllerStatus(I2C_controller_INST) & DL_I2C_CONTROLLER_STATUS_ADDR_ACK) {
+    printf("I2C Write Error: Target Address not acknowledged!\n");
+    return false;
+  }
+  
+  // Debug for I2C WRITE:
+  printf("HAL Write: Address=0x%02X, Data Length=%d\n", TARGET_ADDRESS, Data_length);
+
+
+  // **Check for any WRITE error
+  if (DL_I2C_getControllerStatus(I2C_controller_INST) & DL_I2C_CONTROLLER_STATUS_ERROR) {
+    printf("I2C Write Error: Bus error after sending data.\n");
+    return false;
+  }
+
+  return true;
+}
+
+static bool msp_i2c_read(uint8_t const TARGET_ADDRESS,
+                         uint8_t const Data_length) {
+
+  while (DL_I2C_getControllerStatus(I2C_controller_INST) &
+         DL_I2C_CONTROLLER_STATUS_BUSY_BUS)
+    ;
+  DL_I2C_startControllerTransfer(I2C_controller_INST, TARGET_ADDRESS,
+                                 DL_I2C_CONTROLLER_DIRECTION_RX, Data_length);
+  DL_I2C_enableInterrupt(I2C_controller_INST,
+                         DL_I2C_INTERRUPT_CONTROLLER_RXFIFO_TRIGGER);
+  return true;
+}
+
+I2C_Interface i2c_hal = {
+    .write = msp_i2c_write,
+    .read = msp_i2c_read,
+};

+ 28 - 35
i2c_controller.c → src/i2c_controller.c

@@ -65,8 +65,8 @@ void I2C_controller_INST_IRQHandler(void) {
       if (gRxADCcount < gRxADClen) {
         gRxPacket[gRxADCcount] =
             DL_I2C_receiveControllerData(I2C_controller_INST);
-        printf("Received Byte[%d]: 0x%02X\n", gRxADCcount,
-               gRxPacket[gRxADCcount]); // Debug print
+        //printf("Received Byte[%d]: 0x%02X\n", gRxADCcount,
+        //        gRxPacket[gRxADCcount]); // Debug print
         gRxADCcount++;
 
       } else {
@@ -124,7 +124,7 @@ void I2C_target_INST_IRQHandler(void) {
   uint8_t receivedCommand = 0;
   uint8_t battery_state[8] = {0x00};
   uint32_t status = DL_I2C_getPendingInterrupt(I2C_target_INST);
-  printf("status: %d\n", status);
+  //printf("status: %d\n", status);
   switch (status) {
   case DL_I2C_IIDX_TARGET_START:
     /*Initialize Tx or RX after Start condition is recieved*/
@@ -146,7 +146,7 @@ void I2C_target_INST_IRQHandler(void) {
     }
     receivedCommand = DL_I2C_receiveTargetData(I2C_target_INST);
     if (receivedCommand == CMD_GET_BATTERY_STATUS) {
-      printf("Received Command: 0x%02X\n", receivedCommand);
+      // printf("Received Command: 0x%02X\n", receivedCommand);
       for (uint8_t slot = 0; slot < NUM_SLOTS; slot++) {
         battery_state[slot] = batteries[slot].state;
       }
@@ -171,38 +171,42 @@ void I2C_target_INST_IRQHandler(void) {
 
     else if ((receivedCommand & 0xF0) == 0x20) {
 
-      //printf("Received Command: 0x%02X\n", receivedCommand);
+      // printf("Received Command: 0x%02X\n", receivedCommand);
       uint8_t requestedSlot = (receivedCommand & 0x07);
-      //printf("Requested slot:%d\n", requestedSlot);
-      // piTxCount = 0;
+      // printf("Requested slot:%d\n", requestedSlot);
+      //  piTxCount = 0;
       piTxLen = sizeof(BatteryData);
       BatteryData battery_data;
 
       if (requestedSlot >= NUM_SLOTS) {
-        //printf("Requested Slot is not valid.\n");
+        // printf("Requested Slot is not valid.\n");
         DL_I2C_flushTargetTXFIFO(I2C_target_INST);
         return;
       }
 
       Battery *battery = &batteries[requestedSlot];
       battery_data.slot_id = battery->slot_id; // !TODO: recheck if necessary
-      //printf("slot_id:%u\n", battery_data.slot_id);
       battery_data.voltage = battery->voltage;
-      //printf("voltage:%u\n", battery_data.voltage);
       battery_data.current = battery->current;
-      //printf("current:%u\n", battery_data.current);
       battery_data.temperature = battery->temperature;
-      //printf("temperature:%u\n", battery_data.temperature);
       DL_I2C_fillTargetTXFIFO(I2C_target_INST, (uint8_t *)&battery_data,
                               piTxLen);
-
+      DL_I2C_flushTargetTXFIFO(I2C_target_INST);
+      // printf("slot_id:%u\n", battery_data.slot_id);
+      // battery_data.slot_id= 0;
+      // battery_data.voltage= 61644;
+      // battery_data.current= 43605;
+      // battery_data.temperature= 13071;
+      // printf("voltage:%u\n", battery_data.voltage);
+      // printf("current:%u\n", battery_data.current);
+      // printf("temperature:%u\n", battery_data.temperature);
       /*piTxComplete= true;
       if(piTxCount >= piTxLen){
           piTxComplete= true;
           piTxCount= 0;
       }*/
-      printf("Battery Measurement Sent. \n");
-      DL_I2C_flushTargetTXFIFO(I2C_target_INST);
+      //printf("Battery Measurement Sent. \n");
+      
 
     }
 
@@ -260,33 +264,22 @@ int main(void) {
 
   // Multiplexer
   Multiplexer_SelectChannel(I2C_CHANNEL);
-  // I2C_scanBus();
+  I2C_scanBus();
   I2C_init(&gI2C);
-
-  // ADC_SetConfigurationBytes(adc_voltage_params);
-  // delay_cycles(50000);
-  // ADC_SetConfigurationBytes(adc_current_params);
-  // delay_cycles(50000);
-  // DAC_ReadCurrentAddress();
-
   while (1) {
     // Looping through the ADC Channels
-    for (uint8_t slot_id = 0; slot_id < NUM_SLOTS; slot_id++) {
+    /*for (uint8_t slot_id = 0; slot_id < NUM_SLOTS; slot_id++) {
       for (uint8_t adc_channel = 0; adc_channel < ADC_CHANNEL_NUM;
            adc_channel++) {
         Battery_UpdateADCReading(slot_id, adc_channel);
+        delay_cycles(10000000);
       }
       Battery_ReadState(slot_id);
-    }
-    printf("Battery Details: Slot: %u, Voltage:%u, Current: %u \n, State:%u\n:",
-           batteries[0].slot_id, batteries[0].voltage, batteries[0].current,
-           batteries[0].state);
-
-    // CC-CV Cycle: maximum cycles is not yet implemented
-    // for(uint8_t slot_id= 0; slot_id < NUM_SLOTS; slot_id++){
-    //     CC_CV_ControlCharging(slot_id);
-    // }
-
-    // DAC_fastWrite(CHANNEL_A_VALUE);
+      CC_CV_ControlCharging(slot_id);
+    }*/
+    //printf("Battery Details: Slot: %u, Voltage:%u, Current: %u \n, State:%u\n:",
+    //       batteries[0].slot_id, batteries[0].voltage, batteries[0].current,
+    //       batteries[0].state);
+    DAC_SingleWrite(2048);
   }
 }

+ 0 - 0
i2c_controller.syscfg → src/i2c_controller.syscfg


+ 0 - 0
i2c_target.c → src/i2c_target.c


+ 0 - 0
i2c_target.h → src/i2c_target.h


+ 17 - 0
src/interfaces/adc_interface.h

@@ -0,0 +1,17 @@
+#ifndef ADC_INTERFACE_H_
+#define ADC_INTERFACE_H_
+#include <stdint.h>
+#include <stdbool.h>
+#include "ti/driverlib/dl_i2c.h"
+#include "ti_msp_dl_config.h"
+
+//Default ADC ADDRESS:
+//#define ADC_TARGET_BASE_ADDRESS (0x68)
+//ADC  VREF in millivolts
+//#define ADC_VREF_MV (2048)
+
+
+
+
+
+#endif

+ 37 - 0
src/interfaces/i2c_controller_interface.h

@@ -0,0 +1,37 @@
+/*
+* This file is an interface file for I2C communication between MCU (Controller) and other peripherals (Target): i2c_hal.c
+* Context:
+* Our current functions in ADC and DAC are tightly coupled with I2C communication. 
+* Need a communication mechanism to isolate the flow of the ADC function from Asynchronous calls.
+* Decision:
+* i2c_controller_interface is a header file which defines what the I2C peripheral does:
+* - i2c READ
+* - i2c WRITE
+* - i2c start controller transfer
+* - i2c enable interrupt
+* - i2c bus wait
+* Consequences:
+* Cleaner platform independent file
+
+Reference:
+- https://www.embeddedrelated.com/showarticle/1596.php
+- https://www.beningo.com/5-tips-for-designing-an-interface-in-c/
+*/
+
+#ifndef I2C_INTERFACE_H_
+#define I2C_INTERFACE_H_
+
+#include <stdint.h>
+#include <stdbool.h>
+
+/*
+* Since C does not allows to add functions in typedef struct, however a function pointer can be included in Structure in C. This interface provides a standard features of i2c_hal
+*/
+typedef struct{
+    bool (*write)(uint8_t const TARGET_ADDRESS, const uint8_t *const Data, uint8_t const Data_length);
+    bool (*read) (uint8_t const TARGET_ADDRESS, uint8_t const Data_length);
+} I2C_Interface;
+
+extern I2C_Interface i2c_hal;
+
+#endif

+ 0 - 0
multiplexer.c → src/multiplexer.c


+ 0 - 0
multiplexer.h → src/multiplexer.h