we need TLE8888 driver #714

This commit is contained in:
rusefi 2019-04-04 19:56:03 -04:00
parent 9c05a42b1b
commit b23f9e9cf4
5 changed files with 30 additions and 5 deletions

View File

@ -38,7 +38,7 @@ endif
# C++ specific options here (added to USE_OPT).
ifeq ($(USE_CPPOPT),)
# constexpr float expf_taylor_impl probably needs just c++14 but why not go with 17?
USE_CPPOPT = -std=c++17 -Wno-register -fno-rtti -fno-exceptions -fno-use-cxa-atexit -Werror=write-strings -Werror=type-limits
USE_CPPOPT = -std=c++17 -Wno-register -fno-rtti -fno-threadsafe-statics -fno-exceptions -fno-use-cxa-atexit -Werror=write-strings -Werror=type-limits
endif
# Enable this if you want the linker to remove unused code and data

View File

@ -21,6 +21,7 @@ void turnAllPinsOff(void);
#define turnAllPinsOff() {}
#endif /* EFI_GPIO_HARDWARE */
#ifdef __cplusplus
/**
* @brief Single output pin reference and state
*/
@ -143,6 +144,8 @@ public:
NamedOutputPin auxValve[AUX_DIGITAL_VALVE_COUNT];
};
#endif /* __cplusplus */
/**
* it's a macro to be sure that stack is not used
* @return 0 for OM_DEFAULT and OM_OPENDRAIN
@ -161,8 +164,8 @@ public:
#if EFI_GPIO_HARDWARE || defined(__DOXYGEN__)
ioportmask_t getHwPin(const char *msg, brain_pin_e brainPin);
ioportid_t getHwPort(const char *msg, brain_pin_e brainPin);
EXTERNC ioportmask_t getHwPin(const char *msg, brain_pin_e brainPin);
EXTERNC ioportid_t getHwPort(const char *msg, brain_pin_e brainPin);
const char *portname(ioportid_t GPIOx);
#endif /* EFI_GPIO_HARDWARE */

View File

@ -19,6 +19,7 @@
EXTERN_CONFIG;
#include "hardware.h"
#include "efi_gpio.h"
#include "gpio/gpio_ext.h"
#include "gpio/tle8888.h"
#include "pin_repository.h"
@ -261,7 +262,7 @@ int tle8888_add(unsigned int index, const struct tle8888_config *cfg)
/* this should be in board file */
static struct tle8888_config tle8888_cfg = {
.spi_bus = NULL/*&SPID4*/,
.spi_bus = NULL,
.spi_config = {
.circular = false,
.end_cb = NULL,
@ -291,7 +292,19 @@ static struct tle8888_config tle8888_cfg = {
void initTle8888(DECLARE_ENGINE_PARAMETER_SIGNATURE)
{
if (engineConfiguration->tle8888_cs == GPIO_UNASSIGNED) {
return;
}
// todo: reuse initSpiCs method?
tle8888_cfg.spi_config.ssport = getHwPort("tle8888", engineConfiguration->tle8888_cs);
tle8888_cfg.spi_config.sspad = getHwPin("tle8888", engineConfiguration->tle8888_cs);
tle8888_cfg.spi_bus = getSpiDevice(engineConfiguration->tle8888spiDevice);
if (tle8888_cfg.spi_bus == NULL) {
// error already reported
return;
}
tle8888_add(0, &tle8888_cfg);
}

View File

@ -25,7 +25,7 @@
/* note that spi transfer should be LSB first */
struct tle8888_config {
SPIDriver *spi_bus;
const SPIConfig spi_config;
SPIConfig spi_config;
/* bidirectional, check DS */
struct {
ioportid_t port;

View File

@ -159,6 +159,8 @@ void initI2Cmodule(void) {
//static char txbuf[1];
static void sendI2Cbyte(int addr, int data) {
(void)addr;
(void)data;
// i2cAcquireBus(&I2CD1);
// txbuf[0] = data;
// i2cMasterTransmit(&I2CD1, addr, txbuf, 1, NULL, 0);
@ -458,6 +460,13 @@ void initHardware(Logging *l) {
#endif
#if EFI_TLE8888
if (engineConfiguration->tle8888_cs != GPIO_UNASSIGNED) {
static OutputPin tle8888Cs;
// // SPI pins are enabled in initSpiModules()
tle8888Cs.initPin("tle8888 CS", engineConfiguration->tle8888_cs,
&engineConfiguration->tle8888_csPinMode);
}
initTle8888(PASS_ENGINE_PARAMETER_SIGNATURE);
#endif