|
@@ -159,7 +159,7 @@ void CC_CV_ControlCharging(uint8_t slot_id, int16_t charge_current) {
|
|
|
case STATE_PRE_CHARGE:
|
|
case STATE_PRE_CHARGE:
|
|
|
|
|
|
|
|
DL_GPIO_setPins(GPIO_Battery_Charging_PORT, GPIO_Battery_Charging_PIN_PB7_PIN);
|
|
DL_GPIO_setPins(GPIO_Battery_Charging_PORT, GPIO_Battery_Charging_PIN_PB7_PIN);
|
|
|
- controller_SetCurrent(TARGET_BASE_ADDRESS, slot_id, charge_current);
|
|
|
|
|
|
|
+ controller_SetCurrent(slot_id, charge_current);
|
|
|
if (true) {
|
|
if (true) {
|
|
|
printf("PRE CHARGING: Slot %d at %d mA.\n", slot_id, charge_current);
|
|
printf("PRE CHARGING: Slot %d at %d mA.\n", slot_id, charge_current);
|
|
|
}
|
|
}
|
|
@@ -169,7 +169,7 @@ void CC_CV_ControlCharging(uint8_t slot_id, int16_t charge_current) {
|
|
|
// reaches to (MAXIMUM_VOLTAGE-BATTERY_THRESHOLD)= 4150 mVolts
|
|
// reaches to (MAXIMUM_VOLTAGE-BATTERY_THRESHOLD)= 4150 mVolts
|
|
|
case STATE_CC_CHARGING:
|
|
case STATE_CC_CHARGING:
|
|
|
DL_GPIO_setPins(GPIO_Battery_Charging_PORT, GPIO_Battery_Charging_PIN_PB7_PIN);
|
|
DL_GPIO_setPins(GPIO_Battery_Charging_PORT, GPIO_Battery_Charging_PIN_PB7_PIN);
|
|
|
- controller_SetCurrent(TARGET_BASE_ADDRESS, slot_id, charge_current);
|
|
|
|
|
|
|
+ controller_SetCurrent(slot_id, charge_current);
|
|
|
printf("CC CHARGING: Slot %d, Current: %d mA, Voltage: %d mV.\n", slot_id, batt_current, batt_voltage);
|
|
printf("CC CHARGING: Slot %d, Current: %d mA, Voltage: %d mV.\n", slot_id, batt_current, batt_voltage);
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
@@ -184,7 +184,7 @@ void CC_CV_ControlCharging(uint8_t slot_id, int16_t charge_current) {
|
|
|
charging_state= STATE_ERROR;
|
|
charging_state= STATE_ERROR;
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
- controller_SetCurrent(TARGET_BASE_ADDRESS, slot_id, charge_current);
|
|
|
|
|
|
|
+ controller_SetCurrent(slot_id, charge_current);
|
|
|
}else {
|
|
}else {
|
|
|
charging_state = STATE_FINAL_DISCHARGE;
|
|
charging_state = STATE_FINAL_DISCHARGE;
|
|
|
dac_initialized= false;
|
|
dac_initialized= false;
|
|
@@ -196,7 +196,7 @@ void CC_CV_ControlCharging(uint8_t slot_id, int16_t charge_current) {
|
|
|
DL_GPIO_setPins(GPIO_Battery_Charging_PORT, GPIO_Battery_Charging_PIN_PB7_PIN);
|
|
DL_GPIO_setPins(GPIO_Battery_Charging_PORT, GPIO_Battery_Charging_PIN_PB7_PIN);
|
|
|
DL_GPIO_setPins(GPIO_Battery_Discharging_PORT, GPIO_Battery_Discharging_PIN_PB6_PIN);
|
|
DL_GPIO_setPins(GPIO_Battery_Discharging_PORT, GPIO_Battery_Discharging_PIN_PB6_PIN);
|
|
|
//controller_EvaluateBatterySlotState(slot_id, BatteryMeasurement *measurement);
|
|
//controller_EvaluateBatterySlotState(slot_id, BatteryMeasurement *measurement);
|
|
|
- controller_SetCurrent(TARGET_BASE_ADDRESS, slot_id, charge_current);
|
|
|
|
|
|
|
+ controller_SetCurrent(slot_id, charge_current);
|
|
|
printf("DISCHARGING: Slot %d at %d mA.\n", slot_id, batt_current);
|
|
printf("DISCHARGING: Slot %d at %d mA.\n", slot_id, batt_current);
|
|
|
|
|
|
|
|
//Safety Check
|
|
//Safety Check
|
|
@@ -211,7 +211,7 @@ void CC_CV_ControlCharging(uint8_t slot_id, int16_t charge_current) {
|
|
|
battery_data[slot_id].battery_state= STATE_MEASUREMENT_DONE;
|
|
battery_data[slot_id].battery_state= STATE_MEASUREMENT_DONE;
|
|
|
DL_GPIO_clearPins(GPIO_Battery_Charging_PORT, GPIO_Battery_Charging_PIN_PB7_PIN);
|
|
DL_GPIO_clearPins(GPIO_Battery_Charging_PORT, GPIO_Battery_Charging_PIN_PB7_PIN);
|
|
|
DL_GPIO_clearPins(GPIO_Battery_Discharging_PORT, GPIO_Battery_Discharging_PIN_PB6_PIN);
|
|
DL_GPIO_clearPins(GPIO_Battery_Discharging_PORT, GPIO_Battery_Discharging_PIN_PB6_PIN);
|
|
|
- controller_SetCurrent(TARGET_BASE_ADDRESS, slot_id, 0);
|
|
|
|
|
|
|
+ controller_SetCurrent(slot_id, 0);
|
|
|
charging_state = STATE_IDLE;
|
|
charging_state = STATE_IDLE;
|
|
|
break;
|
|
break;
|
|
|
|
|
|