Ver Fonte

configuration file update

namrota ghosh há 7 meses atrás
pai
commit
7f553a2507
2 ficheiros alterados com 37 adições e 26 exclusões
  1. 36 18
      main.c
  2. 1 8
      main.syscfg

+ 36 - 18
main.c

@@ -1,4 +1,4 @@
-//#include "ti/driverlib/dl_wwdt.h"
+
 #include "ti/driverlib/m0p/dl_core.h"
 #include "ti_msp_dl_config.h"
 #include "src/pi/i2c_pi_target.h"
@@ -15,6 +15,8 @@
 volatile bool mcuSendCommand = false;
 volatile bool picommandPending = false;
 volatile bool watchdog_triggered= false;
+volatile uint8_t current_command= 0x06;
+volatile bool txCommandSent= false;
 
 // Interrupt for I2C instance -> MCU to Target
 
@@ -27,6 +29,7 @@ void I2C_1_INST_IRQHandler(void)
 
         case DL_I2C_IIDX_CONTROLLER_RXFIFO_TRIGGER:
             mcuSendCommand= true;
+            
             while(DL_I2C_isControllerRXFIFOEmpty(I2C_1_INST) != true) {
                 if(rxPacket.rxCount < rxPacket.rxLen){
                      //Get byte from the I2C RX FIFO of the target
@@ -36,21 +39,35 @@ void I2C_1_INST_IRQHandler(void)
                     DL_I2C_receiveControllerData(I2C_1_INST);
                 }
             }
+           
             if(rxPacket.rxCount >= rxPacket.rxLen){
                 rxPacket.rxComplete= true;
             }
-            
             break;
             
         case DL_I2C_IIDX_CONTROLLER_TXFIFO_TRIGGER:
             /* Fill TX FIFO with bytes to send */
             mcuSendCommand = true;
-            txPacket.txComplete= true;
+            txPacket.txBuffer[0] = (0<<4) | (CMD_GET_MEASUREMENT & 0x0F);
+            DL_I2C_fillControllerTXFIFO(I2C_1_INST, (uint8_t *)&txPacket.txBuffer[0], 1); 
+            /*if(!txCommandSent){
+                txPacket.txBuffer[0]= (0<<4) | (CMD_GET_MEASUREMENT & 0x0F);
+                DL_I2C_fillControllerTXFIFO(I2C_1_INST, (uint8_t *)&txPacket.txBuffer[0], 1); 
+                txPacket.txComplete= true;
+                mcuSendCommand = true;
+                txCommandSent= true;
+            }*/
+            /*else{
+                while (DL_I2C_getControllerStatus(I2C_1_INST) & DL_I2C_CONTROLLER_STATUS_BUSY);
+                DL_I2C_startControllerTransfer(I2C_1_INST, 0x49, DL_I2C_CONTROLLER_DIRECTION_RX, 8);
+                txCommandSent= false;
+            } */          
             break;
 
         case DL_I2C_IIDX_CONTROLLER_STOP:
             mcuSendCommand = true;
             rxPacket.rxComplete= true;
+            txPacket.txComplete= true;
             break;
 
         case DL_I2C_IIDX_CONTROLLER_ARBITRATION_LOST:
@@ -103,40 +120,41 @@ int main(void)
     //Interrupt routine for Pi
     NVIC_EnableIRQ(I2C_0_INST_INT_IRQN);
     //Interrupt for target mcu
-    //NVIC_EnableIRQ(I2C_1_INST_INT_IRQN);
-
-
-    bool was_true = false;
+    NVIC_EnableIRQ(I2C_1_INST_INT_IRQN);
 
     while(1)
     {   
         if(picommandPending)
-        {   printf("Pi Interrupt Triggered.\n");
+        {   //printf("Pi Interrupt Triggered.\n");
             pi_i2c_mcu();
             picommandPending = false;
         }
-        /*if(mcuSendCommand){   
-            printf("MCU Interrupt Triggered.\n");
+        if(mcuSendCommand){   
+            //printf("MCU Interrupt Triggered.\n");
+            //getBatteryMeasurement_test();
             mcuSendCommand = false;
             
-        }*/
+        }
         
         for(uint8_t slot_id= 0; slot_id< NUM_SLOTS; slot_id++){
+            getBatteryMeasurement_test();
+            //controller_GetBatteryMeasurement(slot_id);
             //Reading the battery measurement:
-            printf("mainloop slot?\n");
+            //printf("mainloop slot?\n");
             /*if (!was_true) {
                 printf("executing?\n");
-                was_true = controller_GetBatteryMeasurement(slot_id);
+                controller_GetBatteryMeasurement(slot_id);
+                was_true = 
                 printf("true? %d\n", was_true);
             }*/
             //Reading battery state:
             Battery_StateCondition(slot_id);
             //Reading Charging state condition
-            CC_CV_ControlCharging(slot_id, 50);
-            printf("Battery Charging State: %u\n", battery_data[slot_id].battery_charging_state);
-            printf("Battery Limit Received: %u\n", battery_data[slot_id].batteryLimitReceived);
-            printf("STATUS ***Reading Battery Measurement for Slot ID %u:: Battery State: %u, Voltage: %u, Current: %u, Temperature: %u, Slot state: %u***\n", slot_id, battery_data[slot_id].battery_state, battery_data[slot_id].battery_measurement.voltage,
-            battery_data[slot_id].battery_measurement.current, battery_data[slot_id].battery_measurement.temperature, battery_data[slot_id].battery_measurement.slot_state);
+            //CC_CV_ControlCharging(slot_id, 50);
+            //printf("Battery Charging State: %u\n", battery_data[slot_id].battery_charging_state);
+            //printf("Battery Limit Received: %u\n", battery_data[slot_id].batteryLimitReceived);
+            //printf("STATUS ***Reading Battery Measurement for Slot ID %u:: Battery State: %u, Voltage: %u, Current: %u, Temperature: %u, Slot state: %u***\n", slot_id, battery_data[slot_id].battery_state, battery_data[slot_id].battery_measurement.voltage,
+            //battery_data[slot_id].battery_measurement.current, battery_data[slot_id].battery_measurement.temperature, battery_data[slot_id].battery_measurement.slot_state);
             //If target received battery limits from Pi then start charging:       
             if(battery_data[slot_id].batteryLimitReceived){
                 printf("Battery Limits: Slot: %d, Max Voltage:%u, Min Voltage:%u, "

+ 1 - 8
main.syscfg

@@ -22,8 +22,6 @@ const PWM1          = PWM.addInstance();
 const SYSCTL        = scripting.addModule("/ti/driverlib/SYSCTL");
 const TIMER         = scripting.addModule("/ti/driverlib/TIMER", {}, false);
 const TIMER1        = TIMER.addInstance();
-const WWDT          = scripting.addModule("/ti/driverlib/WWDT", {}, false);
-const WWDT1         = WWDT.addInstance();
 const ProjectConfig = scripting.addModule("/ti/project_config/ProjectConfig");
 
 /**
@@ -103,10 +101,6 @@ TIMER1.timerPeriod        = "300 ms";
 TIMER1.interrupts         = ["ZERO"];
 TIMER1.peripheral.$assign = "TIMG0";
 
-WWDT1.$name               = "WWDT0";
-WWDT1.sleepMode           = true;
-WWDT1.window0ClosedPeriod = "25";
-
 ProjectConfig.migrationCondition = true;
 
 /**
@@ -114,5 +108,4 @@ ProjectConfig.migrationCondition = true;
  * version of the tool will not impact the pinmux you originally saw.  These lines can be completely deleted in order to
  * re-solve from scratch.
  */
-PWM1.peripheral.$suggestSolution  = "TIMG6";
-WWDT1.peripheral.$suggestSolution = "WWDT0";
+PWM1.peripheral.$suggestSolution = "TIMG6";