fault: keep fault state for each AFR channel (#139)

Co-authored-by: Andrey Gusakov <dron0gus@gmail.com>
This commit is contained in:
rusefillc 2022-09-06 19:53:11 -04:00 committed by GitHub
parent 268f8ddae7
commit 1647a944cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 8 deletions

View File

@ -1,20 +1,26 @@
#include "wideband_config.h"
#include "fault.h"
using namespace wbo;
static Fault currentFault = Fault::None;
static Fault currentFault[AFR_CHANNELS];
void SetFault(int ch, Fault fault)
{
currentFault = fault;
}
bool HasFault()
{
return currentFault != Fault::None;
currentFault[ch] = fault;
}
Fault GetCurrentFault(int ch)
{
return currentFault;
return currentFault[ch];
}
bool HasFault()
{
bool fault = false;
for (int ch = 0; ch < AFR_CHANNELS; ch++)
fault |= (GetCurrentFault(ch) != Fault::None);
return fault;
}