CAN side of automated testing #4630

This commit is contained in:
rusefillc 2022-09-29 23:45:46 -04:00
parent ad39e5aee9
commit b80c75223a
5 changed files with 22 additions and 5 deletions

View File

@ -224,3 +224,7 @@ void setBoardDefaultConfiguration() {
int getBoardMetaOutputsCount() {
return efi::size(MRE_OUTPUTS);
}
Gpio* getBoardMetaOutputs() {
return &MRE_OUTPUTS;
}

View File

@ -201,3 +201,7 @@ void boardPrepareForStop() {
int getBoardMetaOutputsCount() {
return efi::size(PROTEUS_OUTPUTS);
}
Gpio* getBoardMetaOutputs() {
return &PROTEUS_OUTPUTS;
}

View File

@ -1152,3 +1152,4 @@ __attribute__((weak)) void setBoardDefaultConfiguration() { }
__attribute__((weak)) void setBoardConfigOverrides() { }
__attribute__((weak)) int getBoardMetaOutputsCount() { return 0; }
__attribute__((weak)) Gpio* getBoardMetaOutputs() { return nullptr; }

View File

@ -99,3 +99,4 @@ extern bool isActiveConfigurationVoid;
#define isPinOrModeChanged(pin, mode) (isConfigurationChanged(pin) || isConfigurationChanged(mode))
int getBoardMetaOutputsCount();
Gpio* getBoardMetaOutputs();

View File

@ -10,6 +10,14 @@
#if EFI_CAN_SUPPORT
static void setPin(const CANRxFrame& frame, int value) {
int index = frame.data8[1];
if (index >= getBoardMetaOutputsCount())
return;
Gpio pin = getBoardMetaOutputs()[index];
palWritePad(getHwPort("can_write", pin), getHwPin("can_write", pin), value);
}
void processCanBenchTest(const CANRxFrame& frame) {
if (CAN_EID(frame) != CAN_ECU_HW_META) {
return;
@ -24,12 +32,11 @@ void processCanBenchTest(const CANRxFrame& frame) {
msg[1] = 0;
msg[2] = getBoardMetaOutputsCount();
} else if (command == CAN_BENCH_GET_COUNT) {
} else if (command == CAN_BENCH_GET_SET) {
setPin(frame, 1);
} else if (command == CAN_BENCH_GET_CLEAR) {
setPin(frame, 0);
}
}
#endif // EFI_CAN_SUPPORT