Browse Source

Updated: Pi I2C Interrupts; target_interrupt

namrota ghosh 9 months ago
parent
commit
05c86dc7ad

+ 14 - 0
.theia/launch.json

@@ -0,0 +1,14 @@
+{
+    "version": "0.2.0",
+    "configurations": [
+        {
+            "name": "charge_controller_v7",
+            "type": "ccs-debug",
+            "request": "launch",
+            "projectInfo": {
+                "name": "charge_controller_v7",
+                "resourceId": "/charge_controller_v7/i2c_target.c"
+            }
+        }
+    ]
+}

+ 10 - 5
Debug/.clangd/compile_commands.json

@@ -2,17 +2,22 @@
    {
       "directory" : "/home/ngosh/workspace_ccstheia/charge_controller_v7/Debug",
       "command"   : "clang++ -D__MSPM0G3507__ -I\"/home/ngosh/workspace_ccstheia/charge_controller_v7\" -I\"/home/ngosh/workspace_ccstheia/charge_controller_v7/Debug\" -I\"/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/third_party/CMSIS/Core/Include\" -I\"/home/ngosh/ti/mspm0_sdk_2_03_00_07/source\" -isystem\"/home/ngosh/ti/ccstheia151/ccs/tools/compiler/ti-cgt-armllvm_4.0.0.LTS/include/armv7em-ti-none-eabihf/c++/v1\" -isystem\"/home/ngosh/ti/ccstheia151/ccs/tools/compiler/ti-cgt-armllvm_4.0.0.LTS/include/c++/v1\" -isystem\"/home/ngosh/ti/ccstheia151/ccs/tools/compiler/ti-cgt-armllvm_4.0.0.LTS/lib/clang/18/include\" -isystem\"/home/ngosh/ti/ccstheia151/ccs/tools/compiler/ti-cgt-armllvm_4.0.0.LTS/include/c\"",
-      "file"      : "/home/ngosh/workspace_ccstheia/charge_controller_v7/i2c_controller.c"
+      "file"      : "/home/ngosh/workspace_ccstheia/charge_controller_v7/adc.c"
    },
    {
       "directory" : "/home/ngosh/workspace_ccstheia/charge_controller_v7/Debug",
       "command"   : "clang++ -D__MSPM0G3507__ -I\"/home/ngosh/workspace_ccstheia/charge_controller_v7\" -I\"/home/ngosh/workspace_ccstheia/charge_controller_v7/Debug\" -I\"/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/third_party/CMSIS/Core/Include\" -I\"/home/ngosh/ti/mspm0_sdk_2_03_00_07/source\" -isystem\"/home/ngosh/ti/ccstheia151/ccs/tools/compiler/ti-cgt-armllvm_4.0.0.LTS/include/armv7em-ti-none-eabihf/c++/v1\" -isystem\"/home/ngosh/ti/ccstheia151/ccs/tools/compiler/ti-cgt-armllvm_4.0.0.LTS/include/c++/v1\" -isystem\"/home/ngosh/ti/ccstheia151/ccs/tools/compiler/ti-cgt-armllvm_4.0.0.LTS/lib/clang/18/include\" -isystem\"/home/ngosh/ti/ccstheia151/ccs/tools/compiler/ti-cgt-armllvm_4.0.0.LTS/include/c\"",
-      "file"      : "/home/ngosh/workspace_ccstheia/charge_controller_v7/ti/comm_modules/i2c/controller/i2c_comm_controller.c"
+      "file"      : "/home/ngosh/workspace_ccstheia/charge_controller_v7/battery.c"
    },
    {
       "directory" : "/home/ngosh/workspace_ccstheia/charge_controller_v7/Debug",
       "command"   : "clang++ -D__MSPM0G3507__ -I\"/home/ngosh/workspace_ccstheia/charge_controller_v7\" -I\"/home/ngosh/workspace_ccstheia/charge_controller_v7/Debug\" -I\"/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/third_party/CMSIS/Core/Include\" -I\"/home/ngosh/ti/mspm0_sdk_2_03_00_07/source\" -isystem\"/home/ngosh/ti/ccstheia151/ccs/tools/compiler/ti-cgt-armllvm_4.0.0.LTS/include/armv7em-ti-none-eabihf/c++/v1\" -isystem\"/home/ngosh/ti/ccstheia151/ccs/tools/compiler/ti-cgt-armllvm_4.0.0.LTS/include/c++/v1\" -isystem\"/home/ngosh/ti/ccstheia151/ccs/tools/compiler/ti-cgt-armllvm_4.0.0.LTS/lib/clang/18/include\" -isystem\"/home/ngosh/ti/ccstheia151/ccs/tools/compiler/ti-cgt-armllvm_4.0.0.LTS/include/c\"",
-      "file"      : "/home/ngosh/workspace_ccstheia/charge_controller_v7/battery.c"
+      "file"      : "/home/ngosh/workspace_ccstheia/charge_controller_v7/dac.c"
+   },
+   {
+      "directory" : "/home/ngosh/workspace_ccstheia/charge_controller_v7/Debug",
+      "command"   : "clang++ -D__MSPM0G3507__ -I\"/home/ngosh/workspace_ccstheia/charge_controller_v7\" -I\"/home/ngosh/workspace_ccstheia/charge_controller_v7/Debug\" -I\"/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/third_party/CMSIS/Core/Include\" -I\"/home/ngosh/ti/mspm0_sdk_2_03_00_07/source\" -isystem\"/home/ngosh/ti/ccstheia151/ccs/tools/compiler/ti-cgt-armllvm_4.0.0.LTS/include/armv7em-ti-none-eabihf/c++/v1\" -isystem\"/home/ngosh/ti/ccstheia151/ccs/tools/compiler/ti-cgt-armllvm_4.0.0.LTS/include/c++/v1\" -isystem\"/home/ngosh/ti/ccstheia151/ccs/tools/compiler/ti-cgt-armllvm_4.0.0.LTS/lib/clang/18/include\" -isystem\"/home/ngosh/ti/ccstheia151/ccs/tools/compiler/ti-cgt-armllvm_4.0.0.LTS/include/c\"",
+      "file"      : "/home/ngosh/workspace_ccstheia/charge_controller_v7/i2c_controller.c"
    },
    {
       "directory" : "/home/ngosh/workspace_ccstheia/charge_controller_v7/Debug",
@@ -27,12 +32,12 @@
    {
       "directory" : "/home/ngosh/workspace_ccstheia/charge_controller_v7/Debug",
       "command"   : "clang++ -D__MSPM0G3507__ -I\"/home/ngosh/workspace_ccstheia/charge_controller_v7\" -I\"/home/ngosh/workspace_ccstheia/charge_controller_v7/Debug\" -I\"/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/third_party/CMSIS/Core/Include\" -I\"/home/ngosh/ti/mspm0_sdk_2_03_00_07/source\" -isystem\"/home/ngosh/ti/ccstheia151/ccs/tools/compiler/ti-cgt-armllvm_4.0.0.LTS/include/armv7em-ti-none-eabihf/c++/v1\" -isystem\"/home/ngosh/ti/ccstheia151/ccs/tools/compiler/ti-cgt-armllvm_4.0.0.LTS/include/c++/v1\" -isystem\"/home/ngosh/ti/ccstheia151/ccs/tools/compiler/ti-cgt-armllvm_4.0.0.LTS/lib/clang/18/include\" -isystem\"/home/ngosh/ti/ccstheia151/ccs/tools/compiler/ti-cgt-armllvm_4.0.0.LTS/include/c\"",
-      "file"      : "/home/ngosh/workspace_ccstheia/charge_controller_v7/adc.c"
+      "file"      : "/home/ngosh/workspace_ccstheia/charge_controller_v7/ti/comm_modules/i2c/controller/i2c_comm_controller.c"
    },
    {
       "directory" : "/home/ngosh/workspace_ccstheia/charge_controller_v7/Debug",
       "command"   : "clang++ -D__MSPM0G3507__ -I\"/home/ngosh/workspace_ccstheia/charge_controller_v7\" -I\"/home/ngosh/workspace_ccstheia/charge_controller_v7/Debug\" -I\"/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/third_party/CMSIS/Core/Include\" -I\"/home/ngosh/ti/mspm0_sdk_2_03_00_07/source\" -isystem\"/home/ngosh/ti/ccstheia151/ccs/tools/compiler/ti-cgt-armllvm_4.0.0.LTS/include/armv7em-ti-none-eabihf/c++/v1\" -isystem\"/home/ngosh/ti/ccstheia151/ccs/tools/compiler/ti-cgt-armllvm_4.0.0.LTS/include/c++/v1\" -isystem\"/home/ngosh/ti/ccstheia151/ccs/tools/compiler/ti-cgt-armllvm_4.0.0.LTS/lib/clang/18/include\" -isystem\"/home/ngosh/ti/ccstheia151/ccs/tools/compiler/ti-cgt-armllvm_4.0.0.LTS/include/c\"",
-      "file"      : "/home/ngosh/workspace_ccstheia/charge_controller_v7/dac.c"
+      "file"      : "/home/ngosh/workspace_ccstheia/charge_controller_v7/cc_cv_charging.c"
    },
    {
       "directory" : "/home/ngosh/workspace_ccstheia/charge_controller_v7/Debug",

BIN
Debug/adc.o


BIN
Debug/battery.o


+ 157 - 0
Debug/cc_cv_charging.d

@@ -0,0 +1,157 @@
+# FIXED
+
+cc_cv_charging.o: ../cc_cv_charging.c ../cc_cv_charging.h ../battery.h \
+ ../dac.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_i2c.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/msp.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/DeviceFamily.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/m0p/mspm0g350x.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/third_party/CMSIS/Core/Include/core_cm0plus.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_adc12.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_aes.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_comp.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_crc.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_dac12.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_dma.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_flashctl.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_gpio.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_gptimer.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_i2c.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_iomux.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_mathacl.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_mcan.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_oa.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_rtc.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_spi.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_trng.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_uart.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_vref.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_wuc.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_wwdt.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/m0p/hw_factoryregion.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/m0p/hw_cpuss.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/m0p/hw_debugss.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/m0p/hw_sysctl.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/m0p/sysctl/hw_sysctl_mspm0g1x0x_g3x0x.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_common.h \
+ ti_msp_dl_config.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/driverlib.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_adc12.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/m0p/dl_factoryregion.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/m0p/dl_core.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_aes.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_aesadv.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_comp.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_crc.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_crcp.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_dac12.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_dma.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_flashctl.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/m0p/dl_sysctl.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/m0p/sysctl/dl_sysctl_mspm0g1x0x_g3x0x.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_gpamp.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_gpio.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_iwdt.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_lfss.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_keystorectl.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_lcd.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_mathacl.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_mcan.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_opa.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_rtc.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_rtc_common.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_rtc_a.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_rtc_b.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_scratchpad.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_spi.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_tamperio.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_timera.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_timer.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_timerg.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_trng.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_uart_extend.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_uart.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_uart_main.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_vref.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_wwdt.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/m0p/dl_interrupt.h \
+ /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/m0p/dl_systick.h \
+ ../adc.h
+../cc_cv_charging.h:
+../battery.h:
+../dac.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_i2c.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/msp.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/DeviceFamily.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/m0p/mspm0g350x.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/third_party/CMSIS/Core/Include/core_cm0plus.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_adc12.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_aes.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_comp.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_crc.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_dac12.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_dma.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_flashctl.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_gpio.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_gptimer.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_i2c.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_iomux.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_mathacl.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_mcan.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_oa.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_rtc.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_spi.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_trng.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_uart.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_vref.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_wuc.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_wwdt.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/m0p/hw_factoryregion.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/m0p/hw_cpuss.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/m0p/hw_debugss.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/m0p/hw_sysctl.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/m0p/sysctl/hw_sysctl_mspm0g1x0x_g3x0x.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_common.h:
+ti_msp_dl_config.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/driverlib.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_adc12.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/m0p/dl_factoryregion.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/m0p/dl_core.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_aes.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_aesadv.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_comp.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_crc.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_crcp.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_dac12.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_dma.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_flashctl.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/m0p/dl_sysctl.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/m0p/sysctl/dl_sysctl_mspm0g1x0x_g3x0x.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_gpamp.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_gpio.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_iwdt.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_lfss.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_keystorectl.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_lcd.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_mathacl.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_mcan.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_opa.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_rtc.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_rtc_common.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_rtc_a.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_rtc_b.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_scratchpad.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_spi.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_tamperio.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_timera.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_timer.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_timerg.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_trng.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_uart_extend.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_uart.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_uart_main.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_vref.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/dl_wwdt.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/m0p/dl_interrupt.h:
+/home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/m0p/dl_systick.h:
+../adc.h:

BIN
Debug/cc_cv_charging.o


+ 1 - 0
Debug/ccsObjs.opt

@@ -1,5 +1,6 @@
 "./adc.o"
 "./battery.o"
+"./cc_cv_charging.o"
 "./dac.o"
 "./i2c_controller.o"
 "./ti_msp_dl_config.o"

File diff suppressed because it is too large
+ 508 - 514
Debug/charge_controller_v7.map


BIN
Debug/charge_controller_v7.out


File diff suppressed because it is too large
+ 808 - 814
Debug/charge_controller_v7_linkInfo.xml


+ 2 - 1
Debug/i2c_controller.d

@@ -76,7 +76,7 @@ i2c_controller.o: ../i2c_controller.c ../i2c_target.h ../battery.h \
  /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/m0p/dl_interrupt.h \
  /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/m0p/dl_systick.h \
  ../ti/comm_modules/i2c/controller/i2c_comm_controller.h \
- ../multiplexer.h ../adc.h ../dac.h
+ ../multiplexer.h ../adc.h ../dac.h ../cc_cv_charging.h
 ../i2c_target.h:
 ../battery.h:
 /home/ngosh/ti/mspm0_sdk_2_03_00_07/source/ti/devices/msp/peripherals/hw_dac12.h:
@@ -157,3 +157,4 @@ ti_msp_dl_config.h:
 ../multiplexer.h:
 ../adc.h:
 ../dac.h:
+../cc_cv_charging.h:

BIN
Debug/i2c_controller.o


BIN
Debug/i2c_target.o


+ 3 - 2
Debug/makefile

@@ -10,6 +10,7 @@ GEN_CMDS__FLAG := -Wl,-l"./device_linker.cmd"
 ORDERED_OBJS += \
 "./adc.o" \
 "./battery.o" \
+"./cc_cv_charging.o" \
 "./dac.o" \
 "./i2c_controller.o" \
 "./ti_msp_dl_config.o" \
@@ -149,8 +150,8 @@ charge_controller_v7.out: $(OBJS) $(GEN_CMDS)
 # Other Targets
 clean:
 	-$(RM) $(GEN_MISC_FILES__QUOTED)$(GEN_FILES__QUOTED)$(EXE_OUTPUTS__QUOTED)
-	-$(RM) "adc.o" "battery.o" "dac.o" "i2c_controller.o" "ti_msp_dl_config.o" "startup_mspm0g350x_ticlang.o" "i2c_target.o" "multiplexer.o" "ti/comm_modules/i2c/controller/i2c_comm_controller.o" 
-	-$(RM) "adc.d" "battery.d" "dac.d" "i2c_controller.d" "ti_msp_dl_config.d" "startup_mspm0g350x_ticlang.d" "i2c_target.d" "multiplexer.d" "ti/comm_modules/i2c/controller/i2c_comm_controller.d" 
+	-$(RM) "adc.o" "battery.o" "cc_cv_charging.o" "dac.o" "i2c_controller.o" "ti_msp_dl_config.o" "startup_mspm0g350x_ticlang.o" "i2c_target.o" "multiplexer.o" "ti/comm_modules/i2c/controller/i2c_comm_controller.o" 
+	-$(RM) "adc.d" "battery.d" "cc_cv_charging.d" "dac.d" "i2c_controller.d" "ti_msp_dl_config.d" "startup_mspm0g350x_ticlang.d" "i2c_target.d" "multiplexer.d" "ti/comm_modules/i2c/controller/i2c_comm_controller.d" 
 	-@echo 'Finished clean'
 	-@echo ' '
 

+ 6 - 0
Debug/subdir_vars.mk

@@ -9,6 +9,7 @@ SYSCFG_SRCS += \
 C_SRCS += \
 ../adc.c \
 ../battery.c \
+../cc_cv_charging.c \
 ../dac.c \
 ../i2c_controller.c \
 ./ti_msp_dl_config.c \
@@ -27,6 +28,7 @@ GEN_FILES += \
 C_DEPS += \
 ./adc.d \
 ./battery.d \
+./cc_cv_charging.d \
 ./dac.d \
 ./i2c_controller.d \
 ./ti_msp_dl_config.d \
@@ -40,6 +42,7 @@ GEN_OPTS += \
 OBJS += \
 ./adc.o \
 ./battery.o \
+./cc_cv_charging.o \
 ./dac.o \
 ./i2c_controller.o \
 ./ti_msp_dl_config.o \
@@ -54,6 +57,7 @@ GEN_MISC_FILES += \
 OBJS__QUOTED += \
 "adc.o" \
 "battery.o" \
+"cc_cv_charging.o" \
 "dac.o" \
 "i2c_controller.o" \
 "ti_msp_dl_config.o" \
@@ -68,6 +72,7 @@ GEN_MISC_FILES__QUOTED += \
 C_DEPS__QUOTED += \
 "adc.d" \
 "battery.d" \
+"cc_cv_charging.d" \
 "dac.d" \
 "i2c_controller.d" \
 "ti_msp_dl_config.d" \
@@ -83,6 +88,7 @@ GEN_FILES__QUOTED += \
 C_SRCS__QUOTED += \
 "../adc.c" \
 "../battery.c" \
+"../cc_cv_charging.c" \
 "../dac.c" \
 "../i2c_controller.c" \
 "./ti_msp_dl_config.c" \

+ 0 - 1
adc.c

@@ -213,4 +213,3 @@ void Battery_UpdateCurrentVoltage(ADC_PARAMS params){
         }
 
 }
-

+ 1 - 0
battery.h

@@ -27,6 +27,7 @@ typedef struct{
     uint16_t max_voltage;
     uint16_t cut_off_current;
     uint16_t capacitance;
+    uint16_t charge_fraction;
 } Battery;
 
 //global battery array declaration: extending visiblity of the variable to multiple source files

+ 9 - 9
cc_cv_charging.c

@@ -1,8 +1,7 @@
 #include "cc_cv_charging.h"
 #include "battery.h"
-#include "cc_cc_charging.h"
 #include "dac.h"
-#include <cstdint>
+#include "adc.h"
 #include <stdio.h>
 
 #define MAX_VOLTAGE_MV (4200)
@@ -25,7 +24,7 @@ static uint32_t pre_charge_start_time= 0;
 void CC_CV_UpdateChargingState(uint8_t slot_id){
     uint16_t batt_voltage= batteries[slot_id].voltage;
     int16_t batt_current= batteries[slot_id].current;
-    static uint16_t trickle_timeer= 0;
+    static uint16_t trickle_timer= 0;
 
     if(batt_voltage < TRICKLE_CHARGE_VOLTAGE_MV){
         charging_state= STATE_TRICKLE_CHARGE;
@@ -70,23 +69,24 @@ void CC_CV_UpdateChargingState(uint8_t slot_id){
     }
 }
 
-void CC_CV_ControlCharging(uint8 slot_id){
+
+void CC_CV_ControlCharging(uint8_t slot_id){
     
-    CC_CV_UpdateChargingState(slot_id){
+    CC_CV_UpdateChargingState(slot_id);
     
     switch(charging_state){
         case STATE_TRICKLE_CHARGE:
-            DAC_fastWrite(TRICKLE_CHARGE_CURRENT_MA * 1000);
+            DAC_fastWrite(TRICKLE_CHARGE_CURRENT_MA);
             printf("[CC-CV] Trickle Charging: Slot %d at %d mA.\n", slot_id, TRICKLE_CHARGE_CURRENT_MA);
             break;
         
         case STATE_PRE_CHARGE:
-            DAC_fastWrite(PRE_CHARGE_CURRENT_MA * 1000);
+            DAC_fastWrite(PRE_CHARGE_CURRENT_MA);
             printf("[CC-CV] Pre Charging: Slot %d at %d mA.\n", slot_id, PRE_CHARGE_CURRENT_MA);
             break;
         
         case STATE_CC_CHARGING:
-            DAC_fastWrite(CC_CURRENT_LIMIT_MA * 1000):
+            DAC_fastWrite(CC_CURRENT_LIMIT_MA);
             printf("[CC-CV] CC Charging: Slot %d at %d mA.\n", slot_id, CC_CURRENT_LIMIT_MA);
             break;
         
@@ -97,7 +97,7 @@ void CC_CV_ControlCharging(uint8 slot_id){
         default:
             break;
         }
-    }
+    
 }
 
 

+ 2 - 4
cc_cv_charging.h

@@ -2,9 +2,7 @@
 #define CC_CV_CHARGING_H_
 
 #include <stdint.h>
-#include "battery.h"
-#include "adc.h"
-#include "dac.h"
+
 
 typedef enum{
     STATE_PRE_CHARGE,
@@ -18,6 +16,6 @@ typedef enum{
 
 
 void CC_CV_UpdateChargingState(uint8_t slot_id);
-void CC_CV_ControlCharging(uint8 slot_id);
+void CC_CV_ControlCharging(uint8_t slot_id);
 
 #endif

+ 137 - 54
i2c_controller.c

@@ -23,7 +23,6 @@
  DAC function to write to Channel A in Fast Mode and return the Analog output
  */
 
-
 #include "i2c_target.h"
 #include "ti/devices/msp/peripherals/hw_dac12.h"
 #include "ti/driverlib/dl_adc12.h"
@@ -34,11 +33,13 @@
 #include "ti/comm_modules/i2c/controller/i2c_comm_controller.h"
 #include <stdint.h>
 #include <stdio.h>
+#include <string.h>
 #include "multiplexer.h"
 #include "adc.h"
 #include "dac.h"
 #include "battery.h"
 #include "i2c_target.h"
+#include "cc_cv_charging.h"
 
 I2C_Instance gI2C;
 I2C_ResponseInfo gResponse;
@@ -201,11 +202,12 @@ void I2C_controller_INST_IRQHandler(void)
     }
 }
 
+/**** Interrupt for Pi to MCU ****/
+
 void I2C_target_INST_IRQHandler(void) {
 
     //printf("I2C Interrupt Triggered to MCU (TARGET)!\n");
-    static uint8_t receivedCommand= 0;
-    static uint8_t requestedSlot= 0;
+    uint8_t receivedCommand= 0;
     uint32_t status = DL_I2C_getPendingInterrupt(I2C_target_INST);
     //ADC_PARAMS params;
     switch (status) {
@@ -222,66 +224,147 @@ void I2C_target_INST_IRQHandler(void) {
         case DL_I2C_IIDX_TARGET_STOP:
             piTxComplete= true;
             piRxComplete = true;
-            printf("I2C Stop Detected- Rx/Tx Complete");
             break;
 
         /* TX FIFO trigger (Pi is reading data from MCU) */
+        /*TXFIFO to GET battery status is triggered when command is 0x01
+        - Pi on request of 0x01 will get a response of the battery status for all the slots
+        - Battery_StateUpdate function is called, which in turn calls the Battery_ReadState funtion to set the state of the batteries
+        -Pi on command of [0x02, slot_id] will GET the 'Battery Data' which is voltage, current and temperature for a given slot.
+            - MCU reads the slot_id from Pi using DL_I2C_receiveTargetData()
+            - piTxCount is set to 0
+            - piTxLen is the sizeof BatteryData struct which is 7 bytes
+            - If the requested slot is correct then:
+                - battery pointer variable points to the memory of the requested slot
+                - the values of voltage, current and temperature are then stored in battery_data struct
+            - Once the values are in BatteryData struct we wait for the bus to be free
+            - Next we send the BatteryData to Pi using DL_I2C_fillTargetTXFIFO()
+            - Reset the TX counter for the next data.
+        */
         case DL_I2C_IIDX_TARGET_TXFIFO_TRIGGER:
-            printf("Tx PI triggered!\n");
-            if (receivedCommand == CMD_GET_BATTERY_STATUS){
-                printf("Battery Status\n");
-                Battery_StateUpdate();
-                uint8_t battery_slots_status[NUM_SLOTS];
-                for(uint8_t slot= 0; slot< NUM_SLOTS; slot++){
-                    battery_slots_status[slot]= batteries[slot].state;
+            printf("TX to PI triggered!\n");
+            if(!DL_I2C_isTargetTXFIFOEmpty(I2C_target_INST)){
+                receivedCommand= DL_I2C_receiveTargetData(I2C_target_INST);
+                printf("Received Command: 0x%02X\n", receivedCommand);
+
+                if (receivedCommand == CMD_GET_BATTERY_STATUS){
+                    printf("Battery status received.\n");
+                    Battery_StateUpdate();
+                    if(piTxCount < piTxLen){
+                        while (DL_I2C_getTargetStatus(I2C_target_INST) & DL_I2C_TARGET_STATUS_BUS_BUSY);
+                        DL_I2C_fillTargetTXFIFO(I2C_target_INST, &piTxPacket[piTxCount], 1);
+                        piTxCount++;
+                        
+                    }
+                    else {
+                    /*
+                    * Fill FIFO with 0x00 if more data is requested than expected piTxLen
+                    */
+                    while (
+                        DL_I2C_transmitTargetDataCheck(I2C_target_INST, 0x00) != false);
+                    }
                 }
-                DL_I2C_fillTargetTXFIFO(I2C_target_INST, battery_slots_status, NUM_SLOTS);
-                while (DL_I2C_getTargetStatus(I2C_target_INST) & DL_I2C_TARGET_STATUS_BUS_BUSY); 
+                else if (receivedCommand == CMD_GET_BATTERY_DATA){
 
-            }
-            else if (receivedCommand == CMD_GET_BATTERY_DATA){
-                printf("Battery Data!\n");
-                    piTxCount= 0;
-                    piTxComplete= false;
-                    if(requestedSlot < NUM_SLOTS){
-                        BatteryData battery_data;
-                        battery_data.slot_id= requestedSlot;
-                        battery_data.voltage= batteries[requestedSlot].voltage;
-                        // as of now set to 0 for testing
-                        battery_data.current= 0;
-                        battery_data.temperature=0;
-                    }
+                    uint8_t requestedSlot= DL_I2C_receiveTargetData(I2C_target_INST);
                     while (DL_I2C_getTargetStatus(I2C_target_INST) & DL_I2C_TARGET_STATUS_BUS_BUSY);
-                    //Casting the struct pointer to byte array: (uint8_t*)
-                    DL_I2C_fillTargetTXFIFO(I2C_target_INST, (uint8_t*)&battery_data, sizeof(BatteryData));
-                    while(!piTxComplete);
-                    while (DL_I2C_getTargetStatus(I2C_target_INST) & DL_I2C_TARGET_STATUS_BUS_BUSY);      
-                    // Check if full data has been sent
-                    if (piTxCount >= sizeof(BatteryData)) {
-                        piTxComplete = true;
-                        piTxCount = 0;  // Reset counter for next request
-                        printf("Sent Full Battery Data\n");
-                    }
-            }
+                    printf("Battery Data!\n");
+                        piTxCount= 0;
+                        piTxLen= sizeof(BatteryData);
+                        BatteryData battery_data;
+                        if(requestedSlot < NUM_SLOTS){
+                            Battery *battery= &batteries[requestedSlot];
+                            battery_data.slot_id = battery-> slot_id;
+                            battery_data.voltage= battery-> voltage;
+                            battery_data.current= battery-> current;
+                            battery_data.temperature= battery-> temperature;
+
+                            while (DL_I2C_getTargetStatus(I2C_target_INST) & DL_I2C_TARGET_STATUS_BUS_BUSY);
+
+                            piTxCount += DL_I2C_fillTargetTXFIFO(I2C_target_INST, (uint8_t*)&battery_data, piTxLen);
+
+                            while (DL_I2C_getTargetStatus(I2C_target_INST) & DL_I2C_TARGET_STATUS_BUS_BUSY);
+
+                            if(piTxCount >= piTxLen){
+                            piTxComplete= true;
+                            piTxCount=0;
+                            }
+
+                        } else{
+                            printf("Invalid Slot ID: %d\n.", requestedSlot);
+                        }
+                    
+                }
+        }
+            
+            break;
 
          /* TARGET_Rx FIFO trigger (Pi is writing data to MCU) */
+         /*Pi SET battery data limits for each slot, where:
+         - RXFIFO buffer is filled if the command from Pi is 0x03
+         - Creating a temporary buffer named ´rxbuffer´
+         - sizeof(BatteryLimitMsg): 11 bytes (1 byte: slot_id, 2 bytes: min_voltage; max_voltage; cut_off_current; capacitance; charge_fraction)
+         - rx_buffer stores the data from Pi.
+         - if all the expected bytes are received from Pi then,
+            - memcpy() to copy the block of address from the temporary buffer to the BatteryLimitMsg structure
+            - Why?, A: It copies the specified number of bytes from one memory location to another regardless of the type of the data stored.
+            - verify if the received slot_id is less than NUM_SLOTS, where slot_id count starts from 0 then:
+                - create a pointer variable for 'Battery' 
+                - battery_limits.slot_id: index of the battery slot to be updated
+                - &batteries[battery_limits.slot_id]: gets the memory address of the battery in that slot
+                - Accessing the structure members of Battery using -> operator. This allows efficient access to the structure's members 
+                without directly using the structure variable.
+
+         */
         case DL_I2C_IIDX_TARGET_RXFIFO_TRIGGER:
-            if (!DL_I2C_isTargetRXFIFOEmpty(I2C_target_INST)) {
+            printf("RX FIFO triggered from PI.\n");
+            if(!DL_I2C_isTargetRXFIFOEmpty(I2C_target_INST)){
+                receivedCommand= DL_I2C_receiveTargetData(I2C_target_INST);
+                printf("Received Command: 0x%02X\n", receivedCommand);
                 if(receivedCommand == CMD_SET_BATTERY_LIMIT){
-                    BatteryLimitMsg battery_limits;
-                    requestedSlot= DL_I2C_receiveTargetData(I2C_target_INST);
-                    if(requestedSlot < NUM_SLOTS){
-                        batteries[requestedSlot].min_voltage= (DL_I2C_receiveTargetData(I2C_target_INST)<< 8)|DL_I2C_receiveTargetData(I2C_target_INST);
-                        batteries[requestedSlot].max_voltage= (DL_I2C_receiveTargetData(I2C_target_INST)<< 8)|DL_I2C_receiveTargetData(I2C_target_INST);
-                        batteries[requestedSlot].cut_off_current= (DL_I2C_receiveTargetData(I2C_target_INST)<< 8)|DL_I2C_receiveTargetData(I2C_target_INST);
-                        batteries[requestedSlot].capacitance= (DL_I2C_receiveTargetData(I2C_target_INST)<< 8)|DL_I2C_receiveTargetData(I2C_target_INST);
+                uint8_t rx_buffer[sizeof(BatteryLimitMsg)];
+                uint8_t index= 0;
+
+                while (!DL_I2C_isTargetRXFIFOEmpty(I2C_target_INST)){
+                    if(index < sizeof(BatteryLimitMsg)){
+                        rx_buffer[index]= DL_I2C_receiveTargetData(I2C_target_INST);
+                        printf("Received Byte[%d]: 0x%02X\n", index, rx_buffer[index]); 
+                        index++;
+                        
                     }
+                    else{
+                        DL_I2C_receiveTargetData(I2C_target_INST);
+                    }
+                }
+
+                printf("Total Bytes Received: %d (Expected: %d)\n", index, sizeof(BatteryLimitMsg));
 
+                if(index == sizeof(BatteryLimitMsg)){
+                    printf("Received Battery Limits.\n");
+                    BatteryLimitMsg battery_limits;
+                    memcpy(&battery_limits, rx_buffer, sizeof(BatteryLimitMsg));
+                    if(battery_limits.slot_id < NUM_SLOTS){
+                        Battery *battery = &batteries[battery_limits.slot_id];
+                        battery -> min_voltage = battery_limits.min_voltage;
+                        battery -> max_voltage = battery_limits.max_voltage;
+                        battery -> cut_off_current = battery_limits.cut_off_current;
+                        battery -> capacitance = battery_limits.capacitance;
+                        battery -> charge_fraction = battery_limits.charge_fraction;
+                        printf("\n Received Battery Limits for slot %d: \n", battery_limits.slot_id);
+                        printf("  Min Voltage:      %d mV (0x%04X)\n", battery_limits.min_voltage, battery_limits.min_voltage);
+                        printf("  Max Voltage:      %d mV (0x%04X)\n", battery_limits.max_voltage, battery_limits.max_voltage);
+                        printf("  Cutoff Current:   %d mA (0x%04X)\n", battery_limits.cut_off_current, battery_limits.cut_off_current);
+                        printf("  Capacitance:      %d µF (0x%04X)\n", battery_limits.capacitance, battery_limits.capacitance);
+                        printf("  Charge Fraction:  %d%% (0x%02X)\n", battery_limits.charge_fraction, battery_limits.charge_fraction);
+                    }
+                }
 
                 }
+
             }
+            
             break;
-
+    
         /* Arbitration lost or NACK */
         case DL_I2C_IIDX_TARGET_ARBITRATION_LOST:
             printf("Arbitration Lost.\n");
@@ -323,7 +406,7 @@ int main(void)
     
     //Reset_I2C_Bus();
     NVIC_EnableIRQ(I2C_target_INST_INT_IRQN);
-    NVIC_EnableIRQ(I2C_controller_INST_INT_IRQN);
+    //NVIC_EnableIRQ(I2C_controller_INST_INT_IRQN);
 
     printf("............System Configuration Enabled...............\n");
     
@@ -340,19 +423,19 @@ int main(void)
         .gain= 1
 
     };
-    printf("Configuring ADC....\n");
+    //printf("Configuring ADC....\n");
     //**Set Configuration Register for ADC**
-    ADC_SetConfigurationBytes(adc_params);
-    uint16_t channel_a_value= 3300; // in mVolts
+    //ADC_SetConfigurationBytes(adc_params);
+    //uint16_t channel_a_value= 3300; // in mVolts
     
     
     while (1)
     {   
         
-        Battery_UpdateCurrentVoltage(adc_params);
-        for(uint8_t slot_id= 0; slot_id < NUM_SLOTS; slot++){
-            CC_CV_ControlCharging(slot_id);
-        }
+        //Battery_UpdateCurrentVoltage(adc_params);
+        //for(uint8_t slot_id= 0; slot_id < NUM_SLOTS; slot_id++){
+        //    CC_CV_ControlCharging(slot_id);
+        //}
         //delay_cycles(5000);
         //DAC_fastWrite(channel_a_value);
         delay_cycles(100000);

+ 36 - 18
i2c_target.c

@@ -57,28 +57,46 @@ void Battery_ReadState(uint8_t slot_id){
 
 
 void Battery_StateUpdate(){
-    for(uint8_t slot=0; slot< NUM_SLOTS; slot++){
+    piTxCount= 0;
+    piTxLen = NUM_SLOTS;
+    for(uint8_t slot=0; slot< piTxLen; slot++){
         Battery_ReadState(slot);
+        piTxPacket[slot]= batteries[slot].state;
+
     }
-    while (DL_I2C_getTargetStatus(I2C_target_INST) & DL_I2C_TARGET_STATUS_BUS_BUSY); 
 }
 
-void ProcessI2CCommand(uint8_t command, uint8_t slot_id, ADC_PARAMS params) {
-    switch(command) {
-        case CMD_GET_BATTERY_STATUS:
-            break;
-            
-        case CMD_GET_BATTERY_DATA: 
+/*
+     {
+                if(receivedCommand == CMD_SET_BATTERY_LIMIT){
+                    BatteryLimitMsg battery_limits;
+                    //requestedSlot= DL_I2C_receiveTargetData(I2C_target_INST);
+                    for(uint8_t slot_id=0; slot_id< NUM_SLOTS; slot++){
+                        
 
+                    }
+                    
+                    if(requestedSlot < NUM_SLOTS){
+                        batteries[requestedSlot].min_voltage= (DL_I2C_receiveTargetData(I2C_target_INST)<< 8)|DL_I2C_receiveTargetData(I2C_target_INST);
+                        batteries[requestedSlot].max_voltage= (DL_I2C_receiveTargetData(I2C_target_INST)<< 8)|DL_I2C_receiveTargetData(I2C_target_INST);
+                        batteries[requestedSlot].cut_off_current= (DL_I2C_receiveTargetData(I2C_target_INST)<< 8)|DL_I2C_receiveTargetData(I2C_target_INST);
+                        batteries[requestedSlot].capacitance= (DL_I2C_receiveTargetData(I2C_target_INST)<< 8)|DL_I2C_receiveTargetData(I2C_target_INST);
+                    }
+
+
+                }
+            }
             break;
-        
-        case CMD_SET_BATTERY_LIMIT: 
-            
-            batteries[slot_id].min_voltage= battery_limits.min_voltage;
-            batteries[slot_id].max_voltage= battery_limits.max_voltage;
-            batteries[slot_id].capacitance= battery_limits.capacitance;
-            batteries[slot_id].cut_off_current= battery_limits.cut_off_current;
-            break;
-    }
-}
+
+
+
+                Battery_StateUpdate();
+                uint8_t battery_slots_status[NUM_SLOTS];
+                for(uint8_t slot= 0; slot< NUM_SLOTS; slot++){
+                    battery_slots_status[slot]= batteries[slot].state;
+                }
+                while (DL_I2C_getTargetStatus(I2C_target_INST) & DL_I2C_TARGET_STATUS_BUS_BUSY); 
+                DL_I2C_fillTargetTXFIFO(I2C_target_INST, battery_slots_status, NUM_SLOTS);
+                while (DL_I2C_getTargetStatus(I2C_target_INST) & DL_I2C_TARGET_STATUS_BUS_BUSY); 
+*/
         

+ 1 - 0
i2c_target.h

@@ -39,6 +39,7 @@ typedef struct{
     uint16_t max_voltage;
     uint16_t cut_off_current;
     uint16_t capacitance;
+    uint16_t charge_fraction;
 } BatteryLimitMsg;
 
 //void I2C_Init();

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