only:hellen-honda-k
This commit is contained in:
Andrey 2023-03-05 00:52:57 -05:00
parent 130a1eed14
commit 264f265420
4 changed files with 47 additions and 2 deletions

View File

@ -3,19 +3,49 @@
*/
#include "pch.h"
#include "gpio/gpio_ext.h"
#include "can_gpio.h"
#if EFI_CAN_GPIO
static SEMAPHORE_DECL(wakeSemaphore, 3 /* todo: is that right number? probably not. */);
static THD_WORKING_AREA(canGpio_thread_1_wa, 256);
struct CanOutputs : public GpioChip {
uint8_t state[4];
CanOutputs() {
memset(&state, 0, sizeof(state));
}
void wakeThread() {
/* Entering a reentrant critical zone.*/
chibios_rt::CriticalSectionLocker csl;
chSemSignalI(&wakeSemaphore);
}
/* pin argument is pin number within gpio chip, not a global number */
int writePad(size_t pin, int value) override {
state[pin] = value;
wakeThread();
return 0;
}
};
static THD_FUNCTION(canGpio_driver_thread, p) {
(void)p;
chRegSetThreadName("CanGpio");
while (1) {
chSemWaitTimeout(&wakeSemaphore, TIME_MS2I(1200 /*random number, ms*/));
}
}
#if EFI_CAN_GPIO
void initCanGpio() {
// CAN_PIN_0
chThdCreateStatic(canGpio_thread_1_wa, sizeof(canGpio_thread_1_wa),
PRIO_GPIOCHIP, canGpio_driver_thread, NULL);
}

View File

@ -540,7 +540,7 @@ void initHardware() {
initSpiModules(engineConfiguration);
#endif /* HAL_USE_SPI */
#if EFI_PROD_CODE && (BOARD_EXT_GPIOCHIPS > 0)
#if (EFI_PROD_CODE || EFI_SIMULATOR) && (BOARD_EXT_GPIOCHIPS > 0)
// initSmartGpio depends on 'initSpiModules'
initSmartGpio();
#endif

View File

@ -16,6 +16,11 @@
#define EFI_TCU FALSE
/**
* todo: we *plan* an (integration) test
*/
#define EFI_CAN_GPIO TRUE
#define EFI_ANTILAG_SYSTEM TRUE
#define ENABLE_PERF_TRACE FALSE

View File

@ -83,6 +83,9 @@ static void runChprintfTest() {
}
static void runCanGpioTest() {
}
void rusEfiFunctionalTest(void) {
printToConsole("Running rusEFI simulator version:");
static char versionBuffer[20];
@ -116,7 +119,14 @@ void rusEfiFunctionalTest(void) {
void initMmcCard();
initMmcCard();
/**
* !!!! TESTS !
*/
runChprintfTest();
runCanGpioTest();
/**
* end of TESTS !
*/
initPeriodicEvents();