|
|
@@ -58,29 +58,6 @@ void controller_ClearError(uint8_t slot_id){
|
|
|
DL_I2C_flushControllerTXFIFO(I2C_1_INST);
|
|
|
}
|
|
|
|
|
|
-//Logic to handle Power Burning PWM on the controller side: Problem of power flow back to the device which was breaking the board has been resolved
|
|
|
-void controller_EvaluateBatterySlotState(uint8_t slot_id, BatteryMeasurement *measurement){
|
|
|
- static bool slot_sov_hov_state= false;
|
|
|
- if((measurement->slot_state== SLOT_ERR_HOV) || (measurement->slot_state == SLOT_STATE_SOV)){
|
|
|
- slot_sov_hov_state= true;
|
|
|
- if(battery_data[slot_id].pwm_value < (PWM_MAX_VALUE - PWM_INCREMENT_VALUE)){
|
|
|
- battery_data[slot_id].pwm_value+= PWM_INCREMENT_VALUE;
|
|
|
- printf("[Power Burning PWM] SOV/HOV state: Increased power burn PWM to %d\n", battery_data[slot_id].pwm_value);
|
|
|
- DL_TimerG_setCaptureCompareValue(PWM_0_INST, battery_data[slot_id].pwm_value, DL_TIMER_CC_0_INDEX);
|
|
|
- }
|
|
|
-
|
|
|
- }else if(measurement->slot_state== SLOT_STATE_OK && slot_sov_hov_state== true){
|
|
|
- if(battery_data[slot_id].pwm_value >= (INITIAL_PWM_VALUE + PWM_DECREMENT_VALUE)){
|
|
|
- battery_data[slot_id].pwm_value-= PWM_DECREMENT_VALUE;
|
|
|
- printf("[Power Burning PWM] OK state: Decreased power burn PWM to %d\n", battery_data[slot_id].pwm_value);
|
|
|
- DL_TimerG_setCaptureCompareValue(PWM_0_INST, battery_data[slot_id].pwm_value, DL_TIMER_CC_0_INDEX);
|
|
|
- }
|
|
|
- }else{
|
|
|
- printf("[Power Burning PWM] initial state: %d\n", battery_data[slot_id].pwm_value);
|
|
|
- DL_TimerG_setCaptureCompareValue(PWM_0_INST, battery_data[slot_id].pwm_value, DL_TIMER_CC_0_INDEX);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
|
|
|
// Following code worked with ADC as the target with now clocking issues:
|
|
|
bool controllerGetBatteryMeasurement(uint8_t slot_id){
|