|
|
@@ -25,7 +25,6 @@ void I2C_1_INST_IRQHandler(void)
|
|
|
switch (DL_I2C_getPendingInterrupt(I2C_1_INST))
|
|
|
{
|
|
|
case DL_I2C_IIDX_CONTROLLER_START:
|
|
|
-
|
|
|
break;
|
|
|
|
|
|
case DL_I2C_IIDX_CONTROLLER_RXFIFO_TRIGGER:
|
|
|
@@ -94,8 +93,8 @@ void I2C_0_INST_IRQHandler(void)
|
|
|
break;
|
|
|
case DL_I2C_IIDX_TARGET_STOP:
|
|
|
picommandPending = true;
|
|
|
- //DL_I2C_flushTargetTXFIFO(I2C_0_INST);
|
|
|
- //DL_I2C_flushTargetRXFIFO(I2C_0_INST);
|
|
|
+ DL_I2C_flushTargetTXFIFO(I2C_0_INST);
|
|
|
+ DL_I2C_flushTargetRXFIFO(I2C_0_INST);
|
|
|
break;
|
|
|
case DL_I2C_IIDX_TARGET_ARBITRATION_LOST:
|
|
|
break;
|
|
|
@@ -132,22 +131,21 @@ int main(void)
|
|
|
|
|
|
for(uint8_t slot_id= 0; slot_id< NUM_SLOTS; slot_id++){
|
|
|
//GET battery measurement from the Target
|
|
|
- getBatteryMeasurement_test(slot_id);
|
|
|
+ getBatteryMeasurement(slot_id);
|
|
|
//Reading battery state:
|
|
|
Battery_StateCondition(slot_id);
|
|
|
printf("Battery State: %d\n", battery_data[slot_id].battery_state);
|
|
|
-
|
|
|
- //If target received battery limits from Pi then start charging:
|
|
|
+ //If target received battery limits from Pi then start charging, else wait with state: 3::
|
|
|
+ //CC_CV_ControlCharging(slot_id, 50);
|
|
|
if(battery_data[slot_id].batteryLimitReceived){
|
|
|
printf("Battery Limits: Slot: %d, Max Voltage:%u, Min Voltage:%u, "
|
|
|
"Cutoff Current: %u, Capacitance:%u, Charge Fraction:%u, Cycle Number: %u\n", slot_id, battery_data[slot_id].max_voltage,
|
|
|
battery_data[slot_id].min_voltage, battery_data[slot_id].cut_off_current,
|
|
|
battery_data[slot_id].capacitance, battery_data[slot_id].charge_fraction, battery_data[slot_id].cycle_number);
|
|
|
- //CC_CV_ControlCharging(slot_id, 100);
|
|
|
- controller_SetCurrent(0x48, slot_id, 50);
|
|
|
+ CC_CV_ControlCharging(slot_id, 50);
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
delay_cycles(MEASUREMENT_CHECK_INTERVAL);
|
|
|
|
|
|
}
|