|
|
@@ -51,7 +51,6 @@ void I2C_1_INST_IRQHandler(void)
|
|
|
case DL_I2C_IIDX_CONTROLLER_TXFIFO_TRIGGER:
|
|
|
/* Fill TX FIFO with bytes to send */
|
|
|
mcuSendCommand = true;
|
|
|
- txPacket.txBuffer[0] = (0<<4) | (CMD_GET_MEASUREMENT & 0x0F);
|
|
|
DL_I2C_fillControllerTXFIFO(I2C_1_INST, (uint8_t *)&txPacket.txBuffer[0], 1);
|
|
|
txPacket.txComplete= true;
|
|
|
break;
|
|
|
@@ -132,30 +131,18 @@ int main(void)
|
|
|
}
|
|
|
|
|
|
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");
|
|
|
- /*if (!was_true) {
|
|
|
- printf("executing?\n");
|
|
|
- controller_GetBatteryMeasurement(slot_id);
|
|
|
- was_true =
|
|
|
- printf("true? %d\n", was_true);
|
|
|
- }*/
|
|
|
+ //GET battery measurement from the Target
|
|
|
+ getBatteryMeasurement_test(slot_id);
|
|
|
//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);
|
|
|
+ printf("Battery State: %d\n", battery_data[slot_id].battery_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, "
|
|
|
"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, 50);
|
|
|
|
|
|
}
|
|
|
|