digital-inputs: board configs

This commit is contained in:
andreika-git 2023-08-22 00:13:47 +03:00
parent d539b4c776
commit 82c2f57e5d
5 changed files with 57 additions and 4 deletions

View File

@ -3,6 +3,7 @@
#include "chprintf.h"
#include "io_pins.h"
#include "can.h"
#include "test_logic.h"
#include "../../ext/libfirmware/can/can_common.h"

View File

@ -34,6 +34,7 @@
#include "can.h"
BaseSequentialStream *chp = (BaseSequentialStream *)&EFI_CONSOLE_USB_DEVICE;
extern bool isGoodCanPackets;
/*
* This is a periodic thread that does absolutely nothing except flashing
@ -72,7 +73,7 @@ static void ConsoleThread(void*) {
while (true) {
bool isGoodDigitalOutputs = testEcuDigitalOutputs();
bool isGoodDititalInputs = testEcuDigitalInputs();
bool isAllGood = isGoodDigitalOutputs && isGoodDititalInputs;
bool isAllGood = isGoodDigitalOutputs && isGoodDititalInputs && isGoodCanPackets;
executionCounter++;

View File

@ -13,6 +13,27 @@ bool haveSeenHigh[COUNT];
int cycleDurationMs = 1;
int cycleCount = 2500;
bool isGoodCanPackets = true;
BoardConfig boardConfigs[NUM_BOARD_CONFIGS] = {
{
"Hellen-Honda125K",
206,
{
{ "TPS1_1", 1.0f, 0.5f * ANALOG_L, 0.5f * ANALOG_H },
{ nullptr, 0, 0, 0 },
{ nullptr, 0, 0, 0 },
{ nullptr, 0, 0, 0 },
{ "MAP", 1.0f, 0.6f * ANALOG_L, 0.6f * ANALOG_H },
{ "CLT", 1.0f, CLT_VALUE * ANALOG_L, CLT_VALUE * ANALOG_H },
{ "IAT", 1.0f, IAT_VALUE * ANALOG_L, IAT_VALUE * ANALOG_H },
{ "BATT", 5.835f, 9.0f, 15.0f },
}
},
};
BoardConfig *currentBoard = nullptr;
bool testEcuDigitalOutput(int testLineIndex) {
memset(haveSeenLow, 0, sizeof(haveSeenLow));
@ -50,3 +71,12 @@ bool testEcuDigitalOutput(int testLineIndex) {
// test is successful if we saw state toggle
return isGood;
}
void canPacketError(const char *msg, ...) {
va_list vl;
va_start(vl, msg);
chvprintf(chp, msg, vl);
va_end(vl);
isGoodCanPackets = false;
}

View File

@ -3,6 +3,27 @@
#include "cstring"
bool testEcuDigitalOutput(int testLineIndex);
#define MAX_ANALOG_CHANNELS 8
#define index2human(x) ((x) + 1)
bool testEcuDigitalOutput(int testLineIndex);
void canPacketError(const char *msg, ...);
class AnalogChannelConfig {
public:
const char *name;
float mulCoef; // equal to 'dividerCoef' from the firmware
float acceptMin, acceptMax;
};
class BoardConfig {
public:
const char *boardName;
int boardId;
AnalogChannelConfig channels[MAX_ANALOG_CHANNELS];
};
#define NUM_BOARD_CONFIGS 1
extern BoardConfig boardConfigs[NUM_BOARD_CONFIGS];
extern BoardConfig *currentBoard;

@ -1 +1 @@
Subproject commit 18f8eb417411725108dd9bf54a3f9361715b8f9f
Subproject commit f9df8eb28db78fd91c28e86adb4027fba79255a9