forked from achamaikin/CCSModuleSW30Web
if it breaks, I’m in the mountains
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
|
||||
#include "charger_control.h"
|
||||
#include "charger_config.h"
|
||||
#include "lock.h"
|
||||
#include "psu_control.h"
|
||||
#include "connector.h"
|
||||
#include "debug.h"
|
||||
|
||||
ChargingConnector_t CONN;
|
||||
CONN_State_t connectorState;
|
||||
|
||||
void CONN_Init(){
|
||||
|
||||
@@ -21,9 +23,7 @@ void CONN_Loop(){
|
||||
CONN.connControl = CMD_NONE;
|
||||
}
|
||||
|
||||
if(GBT_LockState.error){
|
||||
CONN.chargingError = CONN_ERR_LOCK;
|
||||
} else if(PSU0.cont_fault){
|
||||
if(PSU0.cont_fault){
|
||||
CONN.chargingError = CONN_ERR_CONTACTOR;
|
||||
} else if(PSU0.psu_fault){
|
||||
CONN.chargingError = CONN_ERR_PSU_FAULT;
|
||||
@@ -38,6 +38,48 @@ void CONN_Loop(){
|
||||
|
||||
}
|
||||
|
||||
void CONN_Task(){
|
||||
/* CCS state machine is handled in serial.c.
|
||||
* Keep this task lightweight for scheduler compatibility.
|
||||
*/
|
||||
if (CONN.chargingError != CONN_NO_ERROR) {
|
||||
CONN_SetState(Disabled);
|
||||
return;
|
||||
}
|
||||
|
||||
if (connectorState == Unknown) {
|
||||
CONN_SetState(Unplugged);
|
||||
} else if (connectorState == Disabled && CONN.chargingError == CONN_NO_ERROR) {
|
||||
CONN_SetState(Unplugged);
|
||||
}
|
||||
}
|
||||
|
||||
void CONN_SetState(CONN_State_t state){
|
||||
if (connectorState == state) {
|
||||
CONN.connState = state;
|
||||
return;
|
||||
}
|
||||
|
||||
connectorState = state;
|
||||
|
||||
if(connectorState == Unknown) log_printf(LOG_INFO, "Connector: Unknown\n");
|
||||
if(connectorState == Unplugged) log_printf(LOG_INFO, "Connector: Unplugged\n");
|
||||
if(connectorState == Disabled) log_printf(LOG_INFO, "Connector: Disabled\n");
|
||||
if(connectorState == Preparing) log_printf(LOG_INFO, "Connector: Preparing\n");
|
||||
if(connectorState == AuthRequired) log_printf(LOG_INFO, "Connector: AuthRequired\n");
|
||||
if(connectorState == WaitingForEnergy) log_printf(LOG_INFO, "Connector: WaitingForEnergy\n");
|
||||
if(connectorState == ChargingPausedEV) log_printf(LOG_INFO, "Connector: ChargingPausedEV\n");
|
||||
if(connectorState == ChargingPausedEVSE) log_printf(LOG_INFO, "Connector: ChargingPausedEVSE\n");
|
||||
if(connectorState == Charging) log_printf(LOG_INFO, "Connector: Charging\n");
|
||||
if(connectorState == AuthTimeout) log_printf(LOG_INFO, "Connector: AuthTimeout\n");
|
||||
if(connectorState == Finished) log_printf(LOG_INFO, "Connector: Finished\n");
|
||||
if(connectorState == FinishedEVSE) log_printf(LOG_INFO, "Connector: FinishedEVSE\n");
|
||||
if(connectorState == FinishedEV) log_printf(LOG_INFO, "Connector: FinishedEV\n");
|
||||
if(connectorState == Replugging) log_printf(LOG_INFO, "Connector: Replugging\n");
|
||||
|
||||
CONN.connState = state;
|
||||
}
|
||||
|
||||
void CONN_PrintChargingTotal(){
|
||||
printf("CONN%d Charging Finished:\n", 0);
|
||||
// printf("Charging Time: %d\n", CONN.chargingTime);
|
||||
|
||||
Reference in New Issue
Block a user