Kinetis & TLE8888 compatibility & fixes... (#991)
* TLE8888: More compatibility & postTunerStudioState * activeConfiguration & EFI_ACTIVE_CONFIGURATION_IN_FLASH fix * Kinetis: jump_to_bootloader() impl. * Kinetis: UART baudrate safety check * Kinetis: OMG!..
This commit is contained in:
parent
47eaea3da3
commit
ee5ee1942c
|
@ -44,7 +44,6 @@ MEMORY
|
|||
ram5 : org = 0x00000000, len = 0
|
||||
ram6 : org = 0x00000000, len = 0
|
||||
ram7 : org = 0x00000000, len = 0
|
||||
config : org = 0x00075000, len = 0xB000
|
||||
}
|
||||
|
||||
/* Flash region for the configuration bytes.*/
|
||||
|
@ -58,14 +57,6 @@ SECTIONS
|
|||
{
|
||||
KEEP(*(.cfmconfig))
|
||||
} > flash1b
|
||||
|
||||
.config : ALIGN(4)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
*(.config)
|
||||
*(.config.*)
|
||||
. = ALIGN(4);
|
||||
} > config AT > config
|
||||
}
|
||||
|
||||
/* For each data/text section two region are defined, a virtual region
|
||||
|
|
|
@ -203,7 +203,14 @@ void uart_lld_start(UARTDriver *uartp) {
|
|||
}
|
||||
#endif
|
||||
// Enable UART
|
||||
LPUART_Init(uartp->lpuart, &lpuartConfig, KINETIS_UART_FREQUENCY);
|
||||
status_t status = LPUART_Init(uartp->lpuart, &lpuartConfig, KINETIS_UART_FREQUENCY);
|
||||
if (status == kStatus_LPUART_BaudrateNotSupport) {
|
||||
// the only reason we could fail is wrong 'baudRate_Bps'. So let's give it a second chance...
|
||||
static const int defaultBaudRate = 115200;
|
||||
lpuartConfig.baudRate_Bps = defaultBaudRate;
|
||||
status = LPUART_Init(uartp->lpuart, &lpuartConfig, KINETIS_UART_FREQUENCY);
|
||||
assert (status == kStatus_Success);
|
||||
}
|
||||
|
||||
//LPUART_EnableInterrupts(uartp->lpuart, kLPUART_IdleLineInterruptEnable);
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@
|
|||
* It also has smaller pages so it takes less time to erase
|
||||
*
|
||||
* There is no remote access to FlexNVM meaning that we cannot erase settings externally
|
||||
* /
|
||||
*/
|
||||
|
||||
#define FLASH_ADDR 0x10000000 // FlexNVM
|
||||
#define FLASH_ADDR_SECOND_COPY 0x10008000
|
||||
|
@ -407,7 +407,7 @@
|
|||
#define EFI_PRINT_ERRORS_AS_WARNINGS TRUE
|
||||
#define EFI_PRINT_MESSAGES_TO_TERMINAL TRUE
|
||||
|
||||
#define EFI_ACTIVE_CONFIGURATION_IN_FLASH __attribute__((section (".config")))
|
||||
#define EFI_ACTIVE_CONFIGURATION_IN_FLASH FLASH_ADDR
|
||||
|
||||
//#define PWM_PHASE_MAX_COUNT 122
|
||||
|
||||
|
|
|
@ -389,6 +389,7 @@ void setTle8888TestConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
|
|||
* set engine_type 30
|
||||
*/
|
||||
void mreBoardTest(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
|
||||
#if (BOARD_TLE8888_COUNT > 0)
|
||||
engineConfiguration->directSelfStimulation = true; // this engine type is used for board validation
|
||||
|
||||
boardConfiguration->triggerSimulatorFrequency = 60;
|
||||
|
@ -496,6 +497,7 @@ void mreBoardTest(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
|
|||
// TLE8888 high current low side: VVT2 IN9 / OUT5
|
||||
// GPIOE_10: "3 - Lowside 2"
|
||||
boardConfiguration->injectionPins[2 - 1] = GPIOE_10;
|
||||
#endif /* BOARD_TLE8888_COUNT */
|
||||
}
|
||||
|
||||
#endif /* CONFIG_ENGINES_CUSTOM_ENGINE_CPP_ */
|
||||
|
|
|
@ -301,6 +301,7 @@ void setMiataNA6_VAF_Frankenso(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
|
|||
* set engine_type 12
|
||||
*/
|
||||
void setMiataNA6_VAF_MRE(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
|
||||
#if (BOARD_TLE8888_COUNT > 0)
|
||||
// idle.solenoidPin output is inherited from boards/microrusefi/board_configuration.cpp
|
||||
// CLT: "18 - AN temp 1"
|
||||
// IAT: "23 - AN temp 2"
|
||||
|
@ -345,5 +346,5 @@ void setMiataNA6_VAF_MRE(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
|
|||
setMiataNA6_settings(PASS_CONFIG_PARAMETER_SIGNATURE);
|
||||
miataNAcommonEngineSettings(PASS_CONFIG_PARAMETER_SIGNATURE);
|
||||
engineConfiguration->fuelAlgorithm = LM_PLAIN_MAF;
|
||||
|
||||
#endif /* BOARD_TLE8888_COUNT */
|
||||
}
|
||||
|
|
|
@ -486,6 +486,7 @@ void setMazdaMiata2003EngineConfigurationBoardTest(DECLARE_CONFIG_PARAMETER_SIGN
|
|||
* set engine_type 13
|
||||
*/
|
||||
void setMiataNB2_MRE(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
|
||||
#if (BOARD_TLE8888_COUNT > 0)
|
||||
setMazdaMiataEngineNB2Defaults(PASS_CONFIG_PARAMETER_SIGNATURE);
|
||||
|
||||
// MRE has a special main relay control low side pin - rusEfi firmware is totally not involved with main relay control
|
||||
|
@ -564,5 +565,5 @@ void setMiataNB2_MRE(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
|
|||
// 0.3#4 has wrong R139 as well?
|
||||
// 56k high side/10k low side multiplied by above analogInputDividerCoefficient = 11
|
||||
engineConfiguration->vbattDividerCoeff = (66.0f / 10.0f) * engineConfiguration->analogInputDividerCoefficient;
|
||||
|
||||
#endif /* BOARD_TLE8888_COUNT */
|
||||
}
|
||||
|
|
|
@ -91,6 +91,10 @@ extern int icuWidthPeriodCounter;
|
|||
#include "fsio_impl.h"
|
||||
#endif /* EFI_FSIO */
|
||||
|
||||
#if (BOARD_TLE8888_COUNT > 0)
|
||||
#include "tle8888.h"
|
||||
#endif /* BOARD_TLE8888_COUNT */
|
||||
|
||||
#if EFI_ENGINE_SNIFFER
|
||||
#include "engine_sniffer.h"
|
||||
extern WaveChart waveChart;
|
||||
|
@ -999,6 +1003,11 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
|
|||
ionPostState(tsOutputChannels);
|
||||
#endif /* EFI_CDM_INTEGRATION */
|
||||
break;
|
||||
case DBG_TLE8888:
|
||||
#if (BOARD_TLE8888_COUNT > 0)
|
||||
tle8888PostState(tsOutputChannels);
|
||||
#endif /* BOARD_TLE8888_COUNT */
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
|
|
|
@ -141,9 +141,10 @@ static fuel_table_t alphaNfuel = {
|
|||
* todo: place this field next to 'engineConfiguration'?
|
||||
*/
|
||||
#ifdef EFI_ACTIVE_CONFIGURATION_IN_FLASH
|
||||
engine_configuration_s EFI_ACTIVE_CONFIGURATION_IN_FLASH activeConfiguration;
|
||||
engine_configuration_s & activeConfiguration = *(engine_configuration_s *)EFI_ACTIVE_CONFIGURATION_IN_FLASH;
|
||||
#else
|
||||
engine_configuration_s activeConfiguration;
|
||||
static engine_configuration_s activeConfigurationLocalStorage;
|
||||
engine_configuration_s & activeConfiguration = activeConfigurationLocalStorage;
|
||||
#endif /* EFI_ACTIVE_CONFIGURATION_IN_FLASH */
|
||||
|
||||
extern engine_configuration_s *engineConfiguration;
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#define EXTERN_CONFIG \
|
||||
extern engine_configuration_s *engineConfiguration; \
|
||||
extern board_configuration_s *boardConfiguration; \
|
||||
extern engine_configuration_s activeConfiguration; \
|
||||
extern engine_configuration_s & activeConfiguration; \
|
||||
extern persistent_config_container_s persistentState; \
|
||||
extern persistent_config_s *config; \
|
||||
|
||||
|
|
|
@ -40,13 +40,6 @@
|
|||
#include "pin_repository.h"
|
||||
#include "os_util.h"
|
||||
|
||||
/* to be removed */
|
||||
#if EFI_TUNER_STUDIO
|
||||
#include "engine_configuration.h"
|
||||
EXTERN_CONFIG;
|
||||
#include "tunerstudio.h"
|
||||
#endif /* EFI_TUNER_STUDIO */
|
||||
|
||||
/*
|
||||
* TODO list:
|
||||
*/
|
||||
|
@ -118,6 +111,7 @@ static int reinitializationCounter = 0;
|
|||
static int initResponsesAccumulator = 0;
|
||||
static int initResponse0 = 0;
|
||||
static int initResponse1 = 0;
|
||||
static uint16_t spiRxb = 0, spiTxb = 0;
|
||||
|
||||
|
||||
/* Driver private data */
|
||||
|
@ -150,6 +144,18 @@ static const char* tle8888_pin_names[TLE8888_OUTPUTS] = {
|
|||
"TLE8888.IGN1", "TLE8888.IGN2", "TLE8888.IGN3", "TLE8888.IGN4"
|
||||
};
|
||||
|
||||
#if EFI_TUNER_STUDIO
|
||||
void tle8888PostState(TunerStudioOutputChannels *tsOutputChannels) {
|
||||
tsOutputChannels->debugIntField1 = tle8888SpiCounter;
|
||||
tsOutputChannels->debugIntField2 = spiTxb;
|
||||
tsOutputChannels->debugIntField3 = spiRxb;
|
||||
tsOutputChannels->debugIntField4 = initResponsesAccumulator;
|
||||
tsOutputChannels->debugIntField5 = reinitializationCounter;
|
||||
tsOutputChannels->debugFloatField1 = initResponse0;
|
||||
tsOutputChannels->debugFloatField2 = initResponse1;
|
||||
}
|
||||
#endif /* EFI_TUNER_STUDIO */
|
||||
|
||||
/*==========================================================================*/
|
||||
/* Driver local functions. */
|
||||
/*==========================================================================*/
|
||||
|
@ -179,27 +185,18 @@ static int tle8888_spi_rw(struct tle8888_priv *chip, uint16_t tx, uint16_t *rx)
|
|||
/* Slave Select assertion. */
|
||||
spiSelect(spi);
|
||||
/* Atomic transfer operations. */
|
||||
uint16_t rxb = spiPolledExchange(spi, tx);
|
||||
spiRxb = spiPolledExchange(spi, tx);
|
||||
//spiExchange(spi, 2, &tx, &rxb); 8 bit version just in case?
|
||||
/* Slave Select de-assertion. */
|
||||
spiUnselect(spi);
|
||||
/* Ownership release. */
|
||||
spiReleaseBus(spi);
|
||||
|
||||
#if EFI_TUNER_STUDIO
|
||||
if (engineConfiguration->debugMode == DBG_TLE8888) {
|
||||
tsOutputChannels.debugIntField1 = tle8888SpiCounter++;
|
||||
tsOutputChannels.debugIntField2 = tx;
|
||||
tsOutputChannels.debugIntField3 = rxb;
|
||||
tsOutputChannels.debugIntField4 = initResponsesAccumulator;
|
||||
tsOutputChannels.debugIntField5 = reinitializationCounter;
|
||||
tsOutputChannels.debugFloatField1 = initResponse0;
|
||||
tsOutputChannels.debugFloatField2 = initResponse1;
|
||||
}
|
||||
#endif /* EFI_TUNER_STUDIO */
|
||||
spiTxb = tx;
|
||||
tle8888SpiCounter++;
|
||||
|
||||
if (rx)
|
||||
*rx = rxb;
|
||||
*rx = spiRxb;
|
||||
|
||||
/* no errors for now */
|
||||
return 0;
|
||||
|
|
|
@ -53,6 +53,11 @@ extern "C"
|
|||
int tle8888_add(unsigned int index, const struct tle8888_config *cfg);
|
||||
void requestTLE8888initialization(void);
|
||||
|
||||
#if EFI_TUNER_STUDIO
|
||||
#include "tunerstudio_configuration.h"
|
||||
void tle8888PostState(TunerStudioOutputChannels *tsOutputChannels);
|
||||
#endif /* EFI_TUNER_STUDIO */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
|
|
@ -124,3 +124,16 @@ int getAdcChannelPin(adc_channel_e hwChannel) {
|
|||
}
|
||||
|
||||
#endif /* HAL_USE_ADC */
|
||||
|
||||
#if EFI_PROD_CODE
|
||||
#define BOOTLOADER_LOCATION 0x1C00001CUL
|
||||
void jump_to_bootloader() {
|
||||
typedef void (*bootloader_start_t)(void * arg);
|
||||
// Read the function address from the ROM API tree and turn it into a function pointer
|
||||
bootloader_start_t bootloaderStart = (bootloader_start_t)(**(uint32_t **)BOOTLOADER_LOCATION);
|
||||
// Call the function!
|
||||
bootloaderStart(NULL);
|
||||
// Will not return from here
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
#endif /* EFI_PROD_CODE */
|
||||
|
|
|
@ -50,6 +50,7 @@ BOR_Result_t BOR_Set(BOR_Level_t BORValue);
|
|||
|
||||
void baseMCUInit(void);
|
||||
void turnOnSpi(spi_device_e device);
|
||||
void jump_to_bootloader();
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
|
|
|
@ -22,7 +22,7 @@ extern WarningCodeState unitTestWarningCodeState;
|
|||
extern float testMafValue;
|
||||
extern float testCltValue;
|
||||
extern float testIatValue;
|
||||
extern engine_configuration_s activeConfiguration;
|
||||
extern engine_configuration_s & activeConfiguration;
|
||||
|
||||
EngineTestHelperBase::EngineTestHelperBase() {
|
||||
// todo: make this not a global variable, we need currentTimeProvider interface on engine
|
||||
|
|
|
@ -73,7 +73,7 @@ void print(const char *fmt, ...);
|
|||
#define CCM_OPTIONAL
|
||||
|
||||
#define EXTERN_ENGINE extern EnginePins enginePins; \
|
||||
extern engine_configuration_s activeConfiguration
|
||||
extern engine_configuration_s & activeConfiguration
|
||||
|
||||
#define EXTERN_CONFIG
|
||||
|
||||
|
|
Loading…
Reference in New Issue