From 8456bd3c23aa23a1966a2ad22df08273ccacf4e9 Mon Sep 17 00:00:00 2001 From: rusefi Date: Wed, 5 Jun 2019 22:32:30 -0400 Subject: [PATCH] reviving tle8888 configuration --- firmware/config/engines/custom_engine.cpp | 4 ++++ firmware/controllers/engine_controller.cpp | 2 +- firmware/hw_layer/drivers/gpio/tle8888.c | 18 ++++++++++++++---- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/firmware/config/engines/custom_engine.cpp b/firmware/config/engines/custom_engine.cpp index cf96130936..c2490ba5a9 100644 --- a/firmware/config/engines/custom_engine.cpp +++ b/firmware/config/engines/custom_engine.cpp @@ -336,6 +336,10 @@ void setTle8888TestConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS; engineConfiguration->crankingInjectionMode = IM_SEQUENTIAL; + boardConfiguration->spi1mosiPin = GPIOB_5; + boardConfiguration->spi1misoPin = GPIOB_4; + boardConfiguration->spi1sckPin = GPIOB_3; // please note that this pin is also SWO/SWD - Single Wire debug Output + engineConfiguration->tle8888_cs = GPIOD_5; engineConfiguration->directSelfStimulation = true; diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp index 6c00f120b3..41221e9c5c 100644 --- a/firmware/controllers/engine_controller.cpp +++ b/firmware/controllers/engine_controller.cpp @@ -810,6 +810,6 @@ int getRusEfiVersion(void) { if (initBootloader() != 0) return 123; #endif /* EFI_BOOTLOADER_INCLUDE_CODE */ - return 20190515; + return 20190605; } #endif /* EFI_UNIT_TEST */ diff --git a/firmware/hw_layer/drivers/gpio/tle8888.c b/firmware/hw_layer/drivers/gpio/tle8888.c index 2de5868008..b4bc7e5470 100644 --- a/firmware/hw_layer/drivers/gpio/tle8888.c +++ b/firmware/hw_layer/drivers/gpio/tle8888.c @@ -40,7 +40,7 @@ #include "pin_repository.h" #include "rfiutil.h" -/* to be rmeoved */ +/* to be removed */ #if EFI_TUNER_STUDIO #include "engine_configuration.h" EXTERN_CONFIG; @@ -102,6 +102,7 @@ SEMAPHORE_DECL(tle8888_wake, 10 /* or BOARD_TLE8888_COUNT ? */); static THD_WORKING_AREA(tle8888_thread_1_wa, 256); static int tle8888SpiCounter = 0; +static int initResponses = 0; /* Driver private data */ struct tle8888_priv { @@ -171,6 +172,7 @@ static int tle8888_spi_rw(struct tle8888_priv *chip, uint16_t tx, uint16_t *rx) tsOutputChannels.debugIntField1 = tle8888SpiCounter++; tsOutputChannels.debugIntField2 = tx; tsOutputChannels.debugIntField3 = rxb; + tsOutputChannels.debugIntField4 = initResponses; } #endif /* EFI_TUNER_STUDIO */ @@ -345,8 +347,12 @@ int tle8888_chip_init(void * data) } /* Software reset */ - // first packet: 0x335 - tle8888_spi_rw(chip, CMD_SR, NULL); + // first packet: 0x335=821 > 0xFD=253 + uint16_t response; + tle8888_spi_rw(chip, CMD_SR, &response); + if (response == 253) { + initResponses++; + } /** * Table 8. Reset Times. All reset times not more than 20uS @@ -355,7 +361,11 @@ int tle8888_chip_init(void * data) chThdSleepMilliseconds(3); /* Set LOCK bit to 0 */ - tle8888_spi_rw(chip, CMD_UNLOCK, NULL); + // second 0x13D=317 => 0x35=53 + tle8888_spi_rw(chip, CMD_UNLOCK, &response); + if (response == 53) { + initResponses++; + } chip->o_direct_mask = 0; chip->o_oe_mask = 0;