From fc590524c20dc2764b0b1bee63b6422ff3020b00 Mon Sep 17 00:00:00 2001 From: rusefi Date: Mon, 25 Mar 2019 20:30:36 -0400 Subject: [PATCH] we need TLE8888 driver #714 --- ...ngine_configuration_generated_structures.h | 10 +++++-- firmware/controllers/algo/rusefi_generated.h | 6 ++-- firmware/controllers/engine_controller.cpp | 2 +- firmware/hw_layer/drivers/gpio/tle8888.cpp | 30 +++++++++++++++++-- firmware/hw_layer/sensors/CJ125.cpp | 6 ++-- firmware/integration/rusefi_config.txt | 3 +- firmware/tunerstudio/rusefi.ini | 6 ++-- firmware/tunerstudio/rusefi.input | 1 + .../models/src/com/rusefi/config/Fields.java | 7 +++-- 9 files changed, 55 insertions(+), 16 deletions(-) diff --git a/firmware/controllers/algo/engine_configuration_generated_structures.h b/firmware/controllers/algo/engine_configuration_generated_structures.h index 66160dc15b..72563f023b 100644 --- a/firmware/controllers/algo/engine_configuration_generated_structures.h +++ b/firmware/controllers/algo/engine_configuration_generated_structures.h @@ -1,4 +1,4 @@ -// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Mon Mar 25 14:42:37 EDT 2019 +// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Mon Mar 25 20:15:52 EDT 2019 // begin #ifndef ENGINE_CONFIGURATION_GENERATED_H_ #define ENGINE_CONFIGURATION_GENERATED_H_ @@ -2218,7 +2218,11 @@ typedef struct { /** * offset 3130 */ - uint8_t unusedTest55[2]; + pin_output_mode_e tle8888_csPinMode; + /** + * offset 3131 + */ + uint8_t unusedTest55; /** * Optional timing advance table for Cranking (see useSeparateAdvanceForCranking) * offset 3132 @@ -2615,4 +2619,4 @@ typedef struct { #endif // end -// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Mon Mar 25 14:42:37 EDT 2019 +// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Mon Mar 25 20:15:52 EDT 2019 diff --git a/firmware/controllers/algo/rusefi_generated.h b/firmware/controllers/algo/rusefi_generated.h index 115a3cde13..c2c4ac1f0b 100644 --- a/firmware/controllers/algo/rusefi_generated.h +++ b/firmware/controllers/algo/rusefi_generated.h @@ -1584,8 +1584,10 @@ #define stepperEnablePin_offset_hex c38 #define tle8888_cs_offset 3129 #define tle8888_cs_offset_hex c39 -#define unusedTest55_offset 3130 -#define unusedTest55_offset_hex c3a +#define tle8888_csPinMode_offset 3130 +#define tle8888_csPinMode_offset_hex c3a +#define unusedTest55_offset 3131 +#define unusedTest55_offset_hex c3b #define crankingAdvanceBins_offset 3132 #define crankingAdvanceBins_offset_hex c3c #define crankingAdvance_offset 3148 diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp index 309e8e1dd6..4fd953f734 100644 --- a/firmware/controllers/engine_controller.cpp +++ b/firmware/controllers/engine_controller.cpp @@ -778,5 +778,5 @@ int getRusEfiVersion(void) { if (initBootloader() != 0) return 123; #endif /* EFI_BOOTLOADER_INCLUDE_CODE */ - return 20190312; + return 20190324; } diff --git a/firmware/hw_layer/drivers/gpio/tle8888.cpp b/firmware/hw_layer/drivers/gpio/tle8888.cpp index d99fb0daed..d166b6727b 100644 --- a/firmware/hw_layer/drivers/gpio/tle8888.cpp +++ b/firmware/hw_layer/drivers/gpio/tle8888.cpp @@ -1,10 +1,16 @@ /** + * + * TLE8888 driver + * + * at the moment only Enable Outputs is implemented - this command is needed to get parallel control pins + * * @date Mar 25, 2019 * @author Andrey Belomutskiy, (c) 2012-2019 */ #include "engine.h" #include "tle8888.h" +#include "hardware.h" /** * 15.2 SPI Frame Definition @@ -12,7 +18,7 @@ */ #define Cmd_write_access 1 #define CmdOE 0x1C -#define DATA_OE_ENABLE 00000010b +#define DATA_OE_ENABLE 0b00000010 static unsigned char tx_buff[2]; @@ -20,11 +26,31 @@ EXTERN_ENGINE; static SPIDriver *driver; -static SPIConfig spiConfig; +static OutputPin tle8888Cs; + +static SPIConfig spiConfig = { NULL, + /* HW dependent part.*/ + NULL, 0, SPI_CR1_MSTR | SPI_CR1_CPHA | SPI_CR1_BR_0 | SPI_CR1_BR_1 | SPI_CR1_BR_2 }; void initTle8888(DECLARE_ENGINE_PARAMETER_SIGNATURE) { if (engineConfiguration->tle8888_cs == GPIO_UNASSIGNED) { return; } + tle8888Cs.initPin("tle8888 CS", engineConfiguration->tle8888_cs, + &engineConfiguration->tle8888_csPinMode); + //spiConfig.cr1 = SPI_BaudRatePrescaler_8; + + driver = getSpiDevice(engineConfiguration->tle8888spiDevice); + spiConfig.ssport = getHwPort("tle8888", engineConfiguration->tle8888_cs); + spiConfig.sspad = getHwPin("tle8888", engineConfiguration->tle8888_cs); + + spiStart(driver, &spiConfig); + + tx_buff[0] = Cmd_write_access + CmdOE; + tx_buff[1] = DATA_OE_ENABLE; + // todo: extract 'sendSync' method? + spiSelect(driver); + spiSend(driver, 2, tx_buff); + spiUnselect(driver); } diff --git a/firmware/hw_layer/sensors/CJ125.cpp b/firmware/hw_layer/sensors/CJ125.cpp index 83a3b66796..6f0d6d712f 100644 --- a/firmware/hw_layer/sensors/CJ125.cpp +++ b/firmware/hw_layer/sensors/CJ125.cpp @@ -90,14 +90,14 @@ static int cjReadRegister(unsigned char regAddr) { #endif /* EFI_UNIT_TEST */ } - static void cjWriteRegister(unsigned char regAddr, unsigned char regValue) { + tx_buff[0] = regAddr; + tx_buff[1] = regValue; #ifdef CJ125_DEBUG_SPI scheduleMsg(logger, "cjWriteRegister: addr=%d value=%d", regAddr, regValue); #endif /* CJ125_DEBUG_SPI */ + // todo: extract 'sendSync' method? spiSelect(driver); - tx_buff[0] = regAddr; - tx_buff[1] = regValue; spiSend(driver, 2, tx_buff); spiUnselect(driver); } diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index 553cb84ed0..da6002841e 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -945,7 +945,8 @@ float[MAP_ACCEL_TAPER] mapAccelTaperMult;;"mult", 1, 0, 0.0, 300, adc_channel_e externalKnockSenseAdc; brain_pin_e stepperEnablePin; brain_pin_e tle8888_cs; - uint8_t[2] unusedTest55; + pin_output_mode_e tle8888_csPinMode; + uint8_t[1] unusedTest55; float[CRANKING_ADVANCE_CURVE_SIZE] crankingAdvanceBins;Optional timing advance table for Cranking (see useSeparateAdvanceForCranking);"RPM", 1, 0, 0.0, 18000, 2 float[CRANKING_ADVANCE_CURVE_SIZE] crankingAdvance ;Optional timing advance table for Cranking (see useSeparateAdvanceForCranking);"deg", 1, 0, -20, 90, 2 diff --git a/firmware/tunerstudio/rusefi.ini b/firmware/tunerstudio/rusefi.ini index b9d6898192..982935c10a 100644 --- a/firmware/tunerstudio/rusefi.ini +++ b/firmware/tunerstudio/rusefi.ini @@ -68,7 +68,7 @@ enable2ndByteCanID = false ; see PAGE_0_SIZE in C source code ; CONFIG_DEFINITION_START -; this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Mon Mar 25 14:42:37 EDT 2019 +; this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Mon Mar 25 20:16:49 EDT 2019 pageSize = 20000 page = 1 @@ -797,7 +797,8 @@ page = 1 externalKnockSenseAdc = bits, U08, 3127, [0:4] "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PB0", "PB1", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "Disabled", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID" stepperEnablePin = bits, U08, 3128, [0:7], "NONE", "INVALID", "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PA8", "PA9", "PA10", "PA11", "PA12", "PA13", "PA14", "PA15", "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7", "PB8", "PB9", "PB10", "PB11", "PB12", "PB13", "PB14", "PB15", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "PC6", "PC7", "PC8", "PC9", "PC10", "PC11", "PC12", "PC13", "PC14", "PC15", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PE0", "PE1", "PE2", "PE3", "PE4", "PE5", "PE6","PE7","PE8","PE9","PE10","PE11","PE12","PE13","PE14","PE15", "PF0","PF1","PF2","PF3","PF4","PF5","PF6","PF7","PF8","PF9","PF10","PF11","PF12","PF13","PF14","PF15", "PG0","PG1","PG2","PG3","PG4","PG5","PG6","PG7","PG8","PG9","PG10","PG11","PG12","PG13","PG14","PG15", "PH0","PH1","PH2","PH3","PH4","PH5","PH6","PH7","PH8","PH9","PH10","PH11","PH12","PH13","PH14","PH15","INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID" tle8888_cs = bits, U08, 3129, [0:7], "NONE", "INVALID", "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PA8", "PA9", "PA10", "PA11", "PA12", "PA13", "PA14", "PA15", "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7", "PB8", "PB9", "PB10", "PB11", "PB12", "PB13", "PB14", "PB15", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "PC6", "PC7", "PC8", "PC9", "PC10", "PC11", "PC12", "PC13", "PC14", "PC15", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PE0", "PE1", "PE2", "PE3", "PE4", "PE5", "PE6","PE7","PE8","PE9","PE10","PE11","PE12","PE13","PE14","PE15", "PF0","PF1","PF2","PF3","PF4","PF5","PF6","PF7","PF8","PF9","PF10","PF11","PF12","PF13","PF14","PF15", "PG0","PG1","PG2","PG3","PG4","PG5","PG6","PG7","PG8","PG9","PG10","PG11","PG12","PG13","PG14","PG15", "PH0","PH1","PH2","PH3","PH4","PH5","PH6","PH7","PH8","PH9","PH10","PH11","PH12","PH13","PH14","PH15","INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID" -;no TS info - skipping unusedTest55 offset 3130 + tle8888_csPinMode = bits, U08, 3130, [0:1], "default", "default inverted", "open collector", "open collector inverted" +;no TS info - skipping unusedTest55 offset 3131 crankingAdvanceBins = array, F32, 3132, [4], "RPM", 1, 0, 0.0, 18000, 2 crankingAdvance = array, F32, 3148, [4], "deg", 1, 0, -20, 90, 2 servoOutputPins1 = bits, U08, 3164, [0:7], "NONE", "INVALID", "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PA8", "PA9", "PA10", "PA11", "PA12", "PA13", "PA14", "PA15", "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7", "PB8", "PB9", "PB10", "PB11", "PB12", "PB13", "PB14", "PB15", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "PC6", "PC7", "PC8", "PC9", "PC10", "PC11", "PC12", "PC13", "PC14", "PC15", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PE0", "PE1", "PE2", "PE3", "PE4", "PE5", "PE6","PE7","PE8","PE9","PE10","PE11","PE12","PE13","PE14","PE15", "PF0","PF1","PF2","PF3","PF4","PF5","PF6","PF7","PF8","PF9","PF10","PF11","PF12","PF13","PF14","PF15", "PG0","PG1","PG2","PG3","PG4","PG5","PG6","PG7","PG8","PG9","PG10","PG11","PG12","PG13","PG14","PG15", "PH0","PH1","PH2","PH3","PH4","PH5","PH6","PH7","PH8","PH9","PH10","PH11","PH12","PH13","PH14","PH15","INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID" @@ -2543,6 +2544,7 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00" field = "comm status light", communicationLedPin field = "running status light", runningLedPin field = "TLE8888 Chip Select", tle8888_cs + field = "TLE8888 CS Mode", tle8888_csPinMode dialog = allPins1_2, "", xAxis diff --git a/firmware/tunerstudio/rusefi.input b/firmware/tunerstudio/rusefi.input index f457a72b89..7cca6998ce 100644 --- a/firmware/tunerstudio/rusefi.input +++ b/firmware/tunerstudio/rusefi.input @@ -1639,6 +1639,7 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00" field = "comm status light", communicationLedPin field = "running status light", runningLedPin field = "TLE8888 Chip Select", tle8888_cs + field = "TLE8888 CS Mode", tle8888_csPinMode dialog = allPins1_2, "", xAxis diff --git a/java_console/models/src/com/rusefi/config/Fields.java b/java_console/models/src/com/rusefi/config/Fields.java index 240bbf3ec1..f25d115168 100644 --- a/java_console/models/src/com/rusefi/config/Fields.java +++ b/java_console/models/src/com/rusefi/config/Fields.java @@ -1,6 +1,6 @@ package com.rusefi.config; -// this file was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Mon Mar 25 14:42:37 EDT 2019 +// this file was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Mon Mar 25 20:16:49 EDT 2019 public class Fields { public static final int LE_COMMAND_LENGTH = 200; public static final int BLOCKING_FACTOR = 400; @@ -1009,7 +1009,8 @@ public class Fields { public static final int externalKnockSenseAdc_offset = 3127; public static final int stepperEnablePin_offset = 3128; public static final int tle8888_cs_offset = 3129; - public static final int unusedTest55_offset = 3130; + public static final int tle8888_csPinMode_offset = 3130; + public static final int unusedTest55_offset = 3131; public static final int crankingAdvanceBins_offset = 3132; public static final int crankingAdvance_offset = 3148; public static final int servoOutputPins1_offset = 3164; @@ -1889,6 +1890,8 @@ public class Fields { public static final Field EXTERNALKNOCKSENSEADC = Field.create("EXTERNALKNOCKSENSEADC", 3127, FieldType.INT, adc_channel_e); public static final Field STEPPERENABLEPIN = Field.create("STEPPERENABLEPIN", 3128, FieldType.INT, brain_pin_e); public static final Field TLE8888_CS = Field.create("TLE8888_CS", 3129, FieldType.INT, brain_pin_e); + public static final Field TLE8888_CSPINMODE = Field.create("TLE8888_CSPINMODE", 3130, FieldType.INT, pin_output_mode_e); + public static final Field UNUSEDTEST55 = Field.create("UNUSEDTEST55", 3131, FieldType.INT); public static final Field SERVOOUTPUTPINS1 = Field.create("SERVOOUTPUTPINS1", 3164, FieldType.INT, brain_pin_e); public static final Field SERVOOUTPUTPINS2 = Field.create("SERVOOUTPUTPINS2", 3165, FieldType.INT, brain_pin_e); public static final Field SERVOOUTPUTPINS3 = Field.create("SERVOOUTPUTPINS3", 3166, FieldType.INT, brain_pin_e);