More config portability: TLE6240, Trigger_input, UART/Serial (#759)

* Add fields to UART/Serial configs

* trigger_input: can be both HAL_USE_PAL and HAL_USE_COMP

* tle6240 config: local temporary solution

* Fix for custom_engine::setFsio

* EFI_ACTIVE_CONFIGURATION_IN_FLASH
This commit is contained in:
andreika-git 2019-04-15 15:40:12 +03:00 committed by rusefi
parent 2cf166373e
commit ffd44bf0fe
5 changed files with 54 additions and 25 deletions

View File

@ -347,8 +347,10 @@ void setTle8888TestConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
// IN1 PF15
// IN2 PF14
// SF PF11
#if EFI_FSIO
setFsio(12, GPIOF_12, "0" PASS_ENGINE_PARAMETER_SUFFIX);
setFsio(14, GPIOF_13, "1" PASS_ENGINE_PARAMETER_SUFFIX);
#endif
CONFIG(etb1_use_two_wires) = true;
CONFIGB(etb1.directionPin1) = GPIOF_15;
CONFIGB(etb1.directionPin2) = GPIOF_14;
@ -360,8 +362,10 @@ void setTle8888TestConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
// IN1 PE2
// IN2 PE4
// SF PE3
#if EFI_FSIO
setFsio(13, GPIOE_5, "0" PASS_ENGINE_PARAMETER_SUFFIX);
setFsio(15, GPIOE_6, "1" PASS_ENGINE_PARAMETER_SUFFIX);
#endif
CONFIG(etb2_use_two_wires) = true;
CONFIG(etb2.directionPin1) = GPIOE_2;
CONFIG(etb2.directionPin2) = GPIOE_4;

View File

@ -65,18 +65,19 @@ static void tsRxIRQIdleHandler(UARTDriver *uartp) {
/* Note: This structure is modified from the default ChibiOS layout! */
static UARTConfig tsDmaUartConfig = {
NULL, NULL, NULL, NULL, NULL,
0, 0, 0/*USART_CR2_STOP1_BITS*/ | USART_CR2_LINEN, 0,
/*timeout_cb*/tsRxIRQIdleHandler, /*rxhalf_cb*/tsRxIRQHalfHandler
.txend1_cb = NULL, .txend2_cb = NULL, .rxend_cb = NULL, .rxchar_cb = NULL, .rxerr_cb = NULL,
.speed = 0, .cr1 = 0, .cr2 = 0/*USART_CR2_STOP1_BITS*/ | USART_CR2_LINEN, .cr3 = 0,
.timeout_cb = tsRxIRQIdleHandler, .rxhalf_cb = tsRxIRQHalfHandler
};
#elif TS_UART_MODE
/* Note: This structure is modified from the default ChibiOS layout! */
static UARTConfig tsUartConfig = {
NULL, NULL, NULL, NULL, NULL,
0, 0, 0/*USART_CR2_STOP1_BITS*/ | USART_CR2_LINEN, 0
.txend1_cb = NULL, .txend2_cb = NULL, .rxend_cb = NULL, .rxchar_cb = NULL, .rxerr_cb = NULL,
.speed = 0, .cr1 = 0, .cr2 = 0/*USART_CR2_STOP1_BITS*/ | USART_CR2_LINEN, .cr3 = 0,
.timeout_cb = NULL, .rxhalf_cb = NULL
};
#else
static SerialConfig tsSerialConfig = { 0, 0, USART_CR2_STOP1_BITS | USART_CR2_LINEN, 0 };
static SerialConfig tsSerialConfig = { .speed = 0, .cr1 = 0, .cr2 = USART_CR2_STOP1_BITS | USART_CR2_LINEN, .cr3 = 0 };
#endif /* TS_UART_DMA_MODE */
#endif /* EFI_PROD_CODE */

View File

@ -151,12 +151,18 @@ volatile int globalConfigurationVersion = 0;
*
* todo: place this field next to 'engineConfiguration'?
*/
#ifdef EFI_ACTIVE_CONFIGURATION_IN_FLASH
engine_configuration_s EFI_ACTIVE_CONFIGURATION_IN_FLASH activeConfiguration;
#else
engine_configuration_s activeConfiguration;
#endif /* EFI_ACTIVE_CONFIGURATION_IN_FLASH */
extern engine_configuration_s *engineConfiguration;
void rememberCurrentConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
#ifndef EFI_ACTIVE_CONFIGURATION_IN_FLASH
memcpy(&activeConfiguration, engineConfiguration, sizeof(engine_configuration_s));
#endif /* EFI_ACTIVE_CONFIGURATION_IN_FLASH */
}

View File

@ -20,14 +20,45 @@
EXTERN_CONFIG;
// todo: migrate to TS or board config
#ifndef TLE6240_SS_PORT
#define TLE6240_SS_PORT GPIOF
#endif /* TLE6240_SS_PORT */
#ifndef TLE6240_SS_PAD
#define TLE6240_SS_PAD 0U
#endif /* TLE6240_SS_PAD */
#ifndef TLE6240_RESET_PORT
#define TLE6240_RESET_PORT GPIOG
#endif /* TLE6240_RESET_PORT */
#ifndef TLE6240_RESET_PAD
#define TLE6240_RESET_PAD 3U
#endif /* TLE6240_RESET_PAD */
#ifndef TLE6240_DIRECT_IO
#define TLE6240_DIRECT_IO \
/* IN1 - D_TACH_OUT */ \
[0] = {.port = GPIOG, .pad = 2}, \
/* IN2..4 grounded */ \
[1] = {.port = NULL, .pad = 0}, \
[2] = {.port = NULL, .pad = 0}, \
[3] = {.port = NULL, .pad = 0}, \
/* IN9 - D_INJ_5 */ \
[4] = {.port = GPIOD, .pad = 15}, \
/* IN10 - D_WASTGATE */ \
[5] = {.port = GPIOD, .pad = 14}, \
/* IN11 - D_IDLE_OPEN */ \
[6] = {.port = GPIOC, .pad = 6}, \
/* IN12 - D_IDLE_CLOSE */ \
[7] = {.port = GPIOC, .pad = 7},
#endif /* TLE6240_DIRECT_IO */
#if (BOARD_TLE6240_COUNT > 0)
struct tle6240_config tle6240 = {
.spi_bus = NULL /* TODO software lookup &SPID4 */,
.spi_config = {
.circular = false,
.end_cb = NULL,
.ssport = GPIOF,
.sspad = 0U,
.ssport = TLE6240_SS_PORT,
.sspad = TLE6240_SS_PAD,
.cr1 =
SPI_CR1_16BIT_MODE |
SPI_CR1_SSM |
@ -41,22 +72,9 @@ struct tle6240_config tle6240 = {
.cr2 = SPI_CR2_16BIT_MODE
},
.direct_io = {
/* IN1 - D_TACH_OUT */
[0] = {.port = GPIOG, .pad = 2},
/* IN2..4 grounded */
[1] = {.port = NULL},
[2] = {.port = NULL},
[3] = {.port = NULL},
/* IN9 - D_INJ_5 */
[4] = {.port = GPIOD, .pad = 15},
/* IN10 - D_WASTGATE */
[5] = {.port = GPIOD, .pad = 14},
/* IN11 - D_IDLE_OPEN */
[6] = {.port = GPIOC, .pad = 6},
/* IN12 - D_IDLE_CLOSE */
[7] = {.port = GPIOC, .pad = 7},
TLE6240_DIRECT_IO
},
.reset = {.port = GPIOG, .pad = 3}
.reset = {.port = TLE6240_RESET_PORT, .pad = TLE6240_RESET_PAD}
};
#endif /* (BOARD_TLE6240_COUNT > 0) */

View File

@ -14,7 +14,7 @@
#include "global.h"
#if EFI_SHAFT_POSITION_INPUT && (HAL_USE_PAL == TRUE || HAL_USE_ICU == TRUE)
#if EFI_SHAFT_POSITION_INPUT && (HAL_USE_PAL == TRUE || HAL_USE_ICU == TRUE) && (HAL_USE_COMP == FALSE)
#include "trigger_input.h"
#include "digital_input_hw.h"
@ -314,4 +314,4 @@ void applyNewTriggerInputPins(void) {
startTriggerInputPins();
}
#endif /* (EFI_SHAFT_POSITION_INPUT && (HAL_USE_PAL == TRUE || HAL_USE_ICU == TRUE)) */
#endif /* (EFI_SHAFT_POSITION_INPUT && (HAL_USE_PAL == TRUE || HAL_USE_ICU == TRUE) && (HAL_USE_COMP == FALSE)) */