|
|
@@ -32,10 +32,8 @@ void I2C_1_INST_IRQHandler(void)
|
|
|
if(rxPacket.rxCount < rxPacket.rxLen){
|
|
|
//Get byte from the I2C RX FIFO of the target
|
|
|
rxPacket.rxBuffer[rxPacket.rxCount++]= DL_I2C_receiveControllerData(I2C_1_INST);
|
|
|
- //rxPacket.rxCount++;
|
|
|
}else{
|
|
|
DL_I2C_receiveControllerData(I2C_1_INST);
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -52,10 +50,6 @@ void I2C_1_INST_IRQHandler(void)
|
|
|
break;
|
|
|
|
|
|
case DL_I2C_IIDX_CONTROLLER_STOP:
|
|
|
- rxPacket.rxComplete= true;
|
|
|
- txPacket.txComplete= true;
|
|
|
- DL_I2C_flushControllerRXFIFO(I2C_1_INST);
|
|
|
- DL_I2C_flushControllerTXFIFO(I2C_1_INST);
|
|
|
break;
|
|
|
|
|
|
case DL_I2C_IIDX_CONTROLLER_ARBITRATION_LOST:
|
|
|
@@ -64,8 +58,6 @@ void I2C_1_INST_IRQHandler(void)
|
|
|
break;
|
|
|
case DL_I2C_IIDX_TIMEOUT_A:
|
|
|
case DL_I2C_IIDX_TIMEOUT_B:
|
|
|
- DL_I2C_flushTargetTXFIFO(I2C_1_INST);
|
|
|
- DL_I2C_flushTargetRXFIFO(I2C_1_INST);
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
@@ -118,27 +110,34 @@ int main(void)
|
|
|
|
|
|
while(1)
|
|
|
{
|
|
|
- if(picommandPending)
|
|
|
- { //printf("Pi Interrupt Triggered.\n");
|
|
|
- pi_i2c_mcu();
|
|
|
- picommandPending = false;
|
|
|
- }
|
|
|
-
|
|
|
- //DL_SYSCTL_getPendingNonMaskableInterrupt();
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
for(uint8_t slot_id= 0; slot_id< NUM_SLOTS; slot_id++){
|
|
|
+ if(picommandPending)
|
|
|
+ { //printf("Pi Interrupt Triggered.\n");
|
|
|
+ pi_i2c_mcu();
|
|
|
+ picommandPending = false;
|
|
|
+ }
|
|
|
+
|
|
|
//GET battery measurement from the Target
|
|
|
+ printf("Reading Battery Measurement for slot %d\n", slot_id);
|
|
|
getBatteryMeasurement(slot_id);
|
|
|
+
|
|
|
//Reading battery state:
|
|
|
Battery_StateCondition(slot_id);
|
|
|
+
|
|
|
printf("Battery State: %d, Charging State:%d\n", battery_data[slot_id].battery_state, battery_data[slot_id].battery_charging_state);
|
|
|
+
|
|
|
+ //function for CC-CV Charging cycle
|
|
|
CC_CV_ControlCharging(slot_id);
|
|
|
- delay_cycles(MEASUREMENT_CHECK_INTERVAL);
|
|
|
- if(battery_data[slot_id].batteryLimitReceived){
|
|
|
- printf("Min Voltage: %d, Max Voltage: %d, Charge Fraction:%d, Capacitance: %d, CutOff Current:%d\n", battery_data[slot_id].min_voltage, battery_data[slot_id].max_voltage,
|
|
|
+
|
|
|
+ /*if(battery_data[slot_id].batteryLimitReceived){
|
|
|
+ printf("Slot Id: %d, Min Voltage: %d, Max Voltage: %d, Charge Fraction:%d, Capacitance: %d, CutOff Current:%d\n",slot_id, battery_data[slot_id].min_voltage, battery_data[slot_id].max_voltage,
|
|
|
battery_data[slot_id].charge_fraction, battery_data[slot_id].capacitance, battery_data[slot_id].cut_off_current);
|
|
|
- }
|
|
|
+ }*/
|
|
|
+
|
|
|
+ delay_cycles(MEASUREMENT_CHECK_INTERVAL);
|
|
|
+
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|