From df18a37788b8ebe335a6e7847e218324d656309b Mon Sep 17 00:00:00 2001 From: rusefi Date: Wed, 4 Sep 2019 00:27:19 -0400 Subject: [PATCH] Hall mode for TLE88888 - VRSConfig1 VRSM #915 --- firmware/hw_layer/drivers/gpio/tle8888.c | 10 ++++++++++ firmware/hw_layer/drivers/gpio/tle8888.h | 7 ++++--- firmware/hw_layer/smart_gpio.cpp | 2 ++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/firmware/hw_layer/drivers/gpio/tle8888.c b/firmware/hw_layer/drivers/gpio/tle8888.c index 27eaac075d..1e0cda420c 100644 --- a/firmware/hw_layer/drivers/gpio/tle8888.c +++ b/firmware/hw_layer/drivers/gpio/tle8888.c @@ -85,6 +85,7 @@ typedef enum { #define CMD_LOCK CMD_WR(0x1e, 0x02) */ #define CMD_UNLOCK CMD_WR(0x1e, 0x01) +#define CMD_HALL_MODE CMD_WR(0x4a, 0x3 << 2) #define CMD_INCONFIG(n, d) CMD_WR(0x53 + (n & 0x03), d) #define CMD_DDCONFIG(n, d) CMD_WR(0x57 + (n & 0x03), d) #define CMD_OECONFIG(n, d) CMD_WR(0x5b + (n & 0x03), d) @@ -451,6 +452,15 @@ int tle8888SpiStartupExchange(void * data) { /* enable outputs */ tle8888_spi_rw(chip, CMD_OE_SET, NULL); + + if (cfg->hallMode) { + /** + * By default "auto detection mode for VR sensor signals" is used + * We know that for short Hall signals like Miata NB2 crank sensor this does not work well above certain RPM. + */ + tle8888_spi_rw(chip, CMD_HALL_MODE, NULL); + } + return 0; } diff --git a/firmware/hw_layer/drivers/gpio/tle8888.h b/firmware/hw_layer/drivers/gpio/tle8888.h index 1c3702a83d..7935936796 100644 --- a/firmware/hw_layer/drivers/gpio/tle8888.h +++ b/firmware/hw_layer/drivers/gpio/tle8888.h @@ -1,8 +1,8 @@ /* - * tle8888.h + * @file tle8888.h * - * Created on: Mar 25, 2019 - * Author: garage + * Mar 25, 2019 + * @author Andrey Belomutskiy, (c) 2012-2019 */ #ifndef HW_LAYER_DRIVERS_GPIO_TLE8888_H_ @@ -39,6 +39,7 @@ struct tle8888_config { /* ...used to drive output (starts from 1, as in DS, coders gonna hate) */ int output; } direct_io[TLE8888_DIRECT_MISC]; + bool hallMode; }; #ifdef __cplusplus diff --git a/firmware/hw_layer/smart_gpio.cpp b/firmware/hw_layer/smart_gpio.cpp index 7cbf5d9cdd..7a3c7cfcc8 100644 --- a/firmware/hw_layer/smart_gpio.cpp +++ b/firmware/hw_layer/smart_gpio.cpp @@ -179,6 +179,8 @@ void initSmartGpio() { tle8888_cfg.spi_config.sspad = getHwPin("tle8888 CS", engineConfiguration->tle8888_cs); tle8888_cfg.spi_bus = getSpiDevice(engineConfiguration->tle8888spiDevice); + tle8888_cfg.hallMode = engineConfiguration->useTLE8888_hall_mode; + /* spi_bus == null checked in _add function */ ret = tle8888_add(0, &tle8888_cfg);