Merge remote-tracking branch 'origin/Hellen_fork_point' into master

# Conflicts:
#	firmware/Makefile
#	firmware/hw_layer/smart_gpio.cpp
This commit is contained in:
rusefi 2020-09-09 17:19:41 -04:00
commit 3a11ea7e31
2 changed files with 63 additions and 3 deletions

View File

@ -80,6 +80,12 @@ ifeq ($(USE_VERBOSE_COMPILE),)
USE_VERBOSE_COMPILE = no
endif
# If enabled, this option makes the build process faster by not compiling
# modules not used in the current configuration.
ifeq ($(USE_SMART_BUILD),)
USE_SMART_BUILD = yes
endif
ifeq ($(USE_BOOTLOADER),)
USE_BOOTLOADER = no
endif

View File

@ -15,11 +15,17 @@
#include "mpu_util.h"
#include "gpio_ext.h"
#include "pin_repository.h"
#include "drivers/gpio/tle6240.h"
#include "drivers/gpio/mc33972.h"
#include "drivers/gpio/mc33810.h"
#include "drivers/gpio/tle8888.h"
#include "drivers/gpio/drv8860.h"
EXTERN_CONFIG;
static OutputPin tle8888Cs;
static OutputPin tle6240Cs;
static OutputPin mc33972Cs;
static OutputPin drv8860Cs;
// todo: migrate to TS or board config
#ifndef TLE6240_RESET_PORT
@ -137,8 +143,32 @@ struct tle8888_config tle8888_cfg = {
};
#endif
#if (BOARD_DRV8860_COUNT > 0)
struct drv8860_config drv8860 = {
.spi_bus = NULL /* TODO software lookup &SPID4 */,
.spi_config = {
.circular = false,
.end_cb = NULL,
.ssport = NULL,
.sspad = 0,
.cr1 =
SPI_CR1_16BIT_MODE |
SPI_CR1_SSM |
SPI_CR1_SSI |
((7 << SPI_CR1_BR_Pos) & SPI_CR1_BR) | /* div = 32 */
SPI_CR1_MSTR |
SPI_CR1_CPOL |
0,
.cr2 = SPI_CR2_16BIT_MODE
},
.reset = {.port = DRV8860_RESET_PORT, .pad = DRV8860_RESET_PAD}
};
#endif /* (BOARD_DRV8860_COUNT > 0) */
void initSmartGpio() {
#if (BOARD_EXT_GPIOCHIPS > 0)
startSmartCsPins();
#endif /* BOARD_EXT_GPIOCHIPS */
int ret = -1;
#if (BOARD_TLE6240_COUNT > 0)
@ -151,9 +181,9 @@ void initSmartGpio() {
ret = -1;
}
if (ret < 0)
#endif /* (BOARD_TLE6240_COUNT > 0) */
/* whenever chip is disabled or error returned - occupy its gpio range */
gpiochip_use_gpio_base(TLE6240_OUTPUTS);
#endif /* (BOARD_TLE6240_COUNT > 0) */
#if (BOARD_MC33972_COUNT > 0)
if (engineConfiguration->mc33972_cs != GPIO_UNASSIGNED) {
@ -167,9 +197,9 @@ void initSmartGpio() {
ret = -1;
}
if (ret < 0)
#endif /* (BOARD_MC33972_COUNT > 0) */
/* whenever chip is disabled or error returned - occupy its gpio range */
gpiochip_use_gpio_base(MC33972_INPUTS);
#endif /* (BOARD_MC33972_COUNT > 0) */
#if (BOARD_TLE8888_COUNT > 0)
if (engineConfiguration->tle8888_cs != GPIO_UNASSIGNED) {
@ -190,9 +220,25 @@ void initSmartGpio() {
ret = -1;
}
if (ret < 0)
#endif /* (BOARD_TLE8888_COUNT > 0) */
/* whenever chip is disabled or error returned - occupy its gpio range */
gpiochip_use_gpio_base(TLE8888_OUTPUTS);
#endif /* (BOARD_TLE8888_COUNT > 0) */
#if (BOARD_DRV8860_COUNT > 0)
if (engineConfiguration->drv8860_cs != GPIO_UNASSIGNED) {
drv8860.spi_config.ssport = getHwPort("drv8860 CS", engineConfiguration->drv8860_cs);
drv8860.spi_config.sspad = getHwPin("drv8860 CS", engineConfiguration->drv8860_cs);
drv8860.spi_bus = getSpiDevice(engineConfiguration->drv8860spiDevice);
ret = drv8860_add(0, &drv8860);
efiAssertVoid(OBD_PCM_Processor_Fault, ret == DRV8860_PIN_1, "drv8860");
} else {
ret = -1;
}
if (ret < 0)
/* whenever chip is disabled or error returned - occupy its gpio range */
gpiochip_use_gpio_base(DRV8860_OUTPUTS);
#endif /* (BOARD_DRV8860_COUNT > 0) */
#if (BOARD_EXT_GPIOCHIPS > 0)
/* external chip init */
@ -211,6 +257,9 @@ void stopSmartCsPins() {
#if (BOARD_MC33972_COUNT > 0)
brain_pin_markUnused(activeConfiguration.mc33972_cs);
#endif /* BOARD_MC33972_COUNT */
#if (BOARD_DRV8860_COUNT > 0)
brain_pin_markUnused(activeConfiguration.drv8860_cs);
#endif /* BOARD_DRV8860_COUNT */
}
void startSmartCsPins() {
@ -229,6 +278,11 @@ void startSmartCsPins() {
&engineConfiguration->mc33972_csPinMode);
mc33972Cs.setValue(true);
#endif /* BOARD_MC33972_COUNT */
#if (BOARD_DRV8860_COUNT > 0)
drv8860Cs.initPin("drv8860 CS", engineConfiguration->drv8860_cs,
&engineConfiguration->drv8860_csPinMode);
drv8860Cs.setValue(true);
#endif /* BOARD_DRV8860_COUNT */
}
#endif /* (BOARD_EXT_GPIOCHIPS > 0) */