testing calc enable
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "my_math.h"
|
||||
#include "errormessage.h"
|
||||
#include "charger.h"
|
||||
#ifdef TEST_COMMON_H
|
||||
#include "../test/test_common.h"
|
||||
@@ -177,3 +178,33 @@ void ResetValuesInOffMode()
|
||||
}
|
||||
}
|
||||
|
||||
void CalcEnable()
|
||||
{
|
||||
static int recheckCan = 10;
|
||||
bool enablePol = Param::GetBool(Param::enablepol);
|
||||
bool enable = DigIo::enable_in.Get() ^ enablePol;
|
||||
|
||||
enable &= !Param::GetBool(Param::cancontrol) || Param::GetBool(Param::canenable);
|
||||
|
||||
if (Param::GetBool(Param::cancontrol))
|
||||
{
|
||||
if (recheckCan == 0)
|
||||
{
|
||||
if (Param::GetInt(Param::canenable) == 3)
|
||||
{
|
||||
Param::SetInt(Param::canenable, 0);
|
||||
ErrorMessage::Post(ERR_EXTCAN);
|
||||
}
|
||||
else
|
||||
{
|
||||
Param::SetInt(Param::canenable, 3); //Must be overwritten by CAN message within the next second
|
||||
}
|
||||
recheckCan = 10;
|
||||
}
|
||||
|
||||
recheckCan--;
|
||||
}
|
||||
|
||||
Param::SetInt(Param::enable, enable);
|
||||
}
|
||||
|
||||
|
||||
@@ -211,36 +211,6 @@ static void ChargerStateMachine()
|
||||
Param::SetInt(Param::state, state);
|
||||
}
|
||||
|
||||
static void CalcEnable()
|
||||
{
|
||||
static int recheckCan = 10;
|
||||
bool enablePol = Param::GetBool(Param::enablepol);
|
||||
bool enable = DigIo::enable_in.Get() ^ enablePol;
|
||||
|
||||
enable &= !Param::GetBool(Param::cancontrol) || Param::GetBool(Param::canenable);
|
||||
|
||||
if (Param::GetBool(Param::cancontrol))
|
||||
{
|
||||
if (recheckCan == 0)
|
||||
{
|
||||
if (Param::GetInt(Param::canenable) == 3)
|
||||
{
|
||||
Param::SetInt(Param::canenable, 0);
|
||||
ErrorMessage::Post(ERR_EXTCAN);
|
||||
}
|
||||
else
|
||||
{
|
||||
Param::SetInt(Param::canenable, 3); //Must be overwritten by CAN message within the next second
|
||||
}
|
||||
recheckCan = 10;
|
||||
}
|
||||
|
||||
recheckCan--;
|
||||
}
|
||||
|
||||
Param::SetInt(Param::enable, enable);
|
||||
}
|
||||
|
||||
//sample 100ms task
|
||||
static void Ms100Task(void)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user