aux serial/WBO cleanup/removal

only:uaefi
This commit is contained in:
Andrey 2024-09-19 23:38:24 -04:00
parent cdc84fd108
commit c3df2dc8eb
14 changed files with 5 additions and 435 deletions

View File

@ -20,9 +20,6 @@
#undef EFI_MAX_31855
#define EFI_MAX_31855 FALSE
#undef EFI_AUX_SERIAL
#define EFI_AUX_SERIAL FALSE
#undef EFI_USB_SERIAL
#define EFI_USB_SERIAL FALSE

View File

@ -291,10 +291,6 @@
#define EFI_WIDEBAND_FIRMWARE_UPDATE TRUE
#ifndef EFI_AUX_SERIAL
#define EFI_AUX_SERIAL TRUE
#endif
#ifndef EFI_IDLE_CONTROL
#define EFI_IDLE_CONTROL TRUE
#endif

View File

@ -57,8 +57,6 @@ CONTROLLERS_SRC_CPP = \
$(CONTROLLERS_DIR)/engine_controller.cpp \
$(CONTROLLERS_DIR)/engine_controller_misc.cpp \
$(CONTROLLERS_DIR)/persistent_store.cpp \
$(CONTROLLERS_DIR)/serial/serial_rx.cpp \
$(CONTROLLERS_DIR)/serial/serial_sensor.cpp \
$(CONTROLLERS_DIR)/start_stop.cpp \
$(CONTROLLERS_DIR)/tcu/buttonshift.cpp \
$(CONTROLLERS_DIR)/tcu/tcu.cpp \

View File

@ -14,7 +14,7 @@
#include "cyclic_buffer.h"
bool hasAfrSensor() {
if (engineConfiguration->enableAemXSeries || engineConfiguration->enableInnovateLC2) {
if (engineConfiguration->enableAemXSeries) {
return true;
}
@ -24,11 +24,6 @@ bool hasAfrSensor() {
extern float InnovateLC2AFR;
float getAfr(SensorType type) {
#if EFI_AUX_SERIAL
if (engineConfiguration->enableInnovateLC2)
return InnovateLC2AFR;
#endif
afr_sensor_s * sensor = &engineConfiguration->afr;
if (!isAdcChannelValid(type == SensorType::Lambda1 ? engineConfiguration->afr.hwChannel : engineConfiguration->afr.hwChannel2)) {

View File

@ -1,35 +0,0 @@
/**
* @file serial.h
*
* @date Mar 19, 2020
* @author Konstantin Smola, (c) 2020
*/
#pragma once
#include "hal.h"
#include "periodic_thread_controller.h"
#define TIME_100MSEC ((sysinterval_t)chTimeMS2I(100))
#define SERBUFFLEN 64
constexpr uint8_t lc2_header_mask = 162;
constexpr uint16_t lc2_pcklen_mask = 383;
typedef enum {UNKNOWN, HEADER_FOUND, IDENTIFIED} innovate_serial_id_state_t;
extern uint8_t ser_buffer[SERBUFFLEN]; //buffer for incoming serial data
extern size_t innovate_msg_len;
extern innovate_serial_id_state_t innovate_serial_id_state;
extern uint8_t sb;
extern bool clear_ser_buffer;
class SerialRead final : public ThreadController<256> {
public:
SerialRead();
void ThreadTask();
uint16_t len;
};

View File

@ -1,52 +0,0 @@
/**
* @file serial_rx.cpp
*
* 2024 Q1: do we really want to support Innovate LC-2 serial?
* 2024 Q2: what else do we have here?
* This file handles auxiliary serial communication.
*
* @date Mar 19, 2020
* @author Konstantin Smola, (c) 2020
*/
#include "pch.h"
#if EFI_AUX_SERIAL
#include "serial.h"
#include "serial_hw.h"
#include "serial_sensor.h"
uint8_t ser_buffer[SERBUFFLEN] = {};
size_t innovate_msg_len = 1;
innovate_serial_id_state_t innovate_serial_id_state = UNKNOWN;
uint8_t sb = 0;
bool clear_ser_buffer = false;
SerialRead::SerialRead()
: ThreadController("AUX Serial RX", PRIO_AUX_SERIAL) {
}
void SerialRead::ThreadTask() {
while (true) {
if (engineConfiguration->enableInnovateLC2) {
len = innovate_msg_len;
}
if (len >= SERBUFFLEN)
len = SERBUFFLEN;
if (sdReadTimeout(AUX_SERIAL_DEVICE, &ser_buffer[sb], len, TIME_100MSEC) == len) {
ParseSerialData();
} else {
ResetSerialSensor();
}
//clear buffer every frame to avoid parsing old data
if (clear_ser_buffer) {
ClearSerialBuffer();
clear_ser_buffer = false;
}
}
}
#endif // EFI_AUX_SERIAL

View File

@ -1,188 +0,0 @@
/**
* @file serial_sensor.cpp
*
*
* @date Mar 19, 2020
* @author Konstantin Smola, (c) 2020
*/
#include "pch.h"
#if EFI_AUX_SERIAL
#include "serial.h"
#include "serial_sensor.h"
#define NUM_INNOVATE_O2_SENSORS 1
#define AFR_MULTIPLIER 147
volatile float InnovateLC2AFR = AFR_ERROR;
typedef enum
{
NO_ERROR = 0,
HEATER_SHORTED = 1,
HEATER_OPEN = 2,
PUMPCELL_SHORTED = 3,
PUMPCELL_OPEN = 4,
REFCELL_SHORTED = 5,
REFCELL_OPEN = 6,
SYSTEM_ERROR = 7,
SENSOR_TIMING_ERR = 8,
SUPP_V_LOW = 9
} sensor_error_code_t;
struct sensor_data_t {
int function_code;
float AFR;
float AFR_multiplier;
float lambda;
float warmup;
sensor_error_code_t error_code;
};
static sensor_data_t innovate_o2_sensor[NUM_INNOVATE_O2_SENSORS];
static size_t tmsglen;
void IdentifyInnovateSerialMsg() { //this identifies an innovate LC1/LC2 o2 sensor by it's first word (header)
if (engineConfiguration->enableInnovateLC2) {
if ((((ser_buffer[0]) & lc2_header_mask) != lc2_header_mask) && innovate_serial_id_state == IDENTIFIED) { //not serial header word
innovate_serial_id_state = UNKNOWN;
innovate_msg_len = 1;
sb = 0;
}
switch (innovate_serial_id_state) {
case UNKNOWN:
InnovateLC2AFR = AFR_ERROR;
// read one byte, identify with mask, advance and read next byte
if (((ser_buffer[0]) & lc2_header_mask) == lc2_header_mask) { // check if it's the first byte of header
// first byte identified, now continue reading and advance statemachine
innovate_serial_id_state = HEADER_FOUND;
innovate_msg_len = 1;
sb = 1;
} else {
innovate_serial_id_state = UNKNOWN;
}
break;
case HEADER_FOUND:
// now we should have both header bytes in array, and we can read the total packet length
tmsglen = (((ser_buffer[0] << 8) | ser_buffer[1]) & lc2_pcklen_mask); //0000000101111111 mask
if (tmsglen) {
tmsglen += 1; // length in words including header (2 bytes)
tmsglen *= 2; // length in bytes (incl header)
innovate_msg_len = tmsglen - 2;
sb = 2;
innovate_serial_id_state = IDENTIFIED; //advance state machine
} else {
innovate_serial_id_state = UNKNOWN;
}
break;
case IDENTIFIED:
innovate_msg_len = tmsglen;
sb = 0;
// serial packet fully identified
ParseInnovateSerialMsg(); //takes about 570ns
clear_ser_buffer = true;
break;
default:
break;
}
}
}
void ParseInnovateSerialMsg() {
float raw_afr;
//get error code and afr
// 000 Lambda valid and Aux data valid, normal operation.
// 001 Lambda value contains O2 level in 1/10%
// 010 Free air Calib in progress, Lambda data not valid
// 011 Need Free air Calibration Request, Lambda data not valid
// 100 Warming up, Lambda value is temp in 1/10% of operating temp.
// 101 Heater Calibration, Lambda value contains calibration countdown.
// 110 Error code in Lambda value
// 111 reserved
for (size_t i = 0; i < ((tmsglen - 2) / 4) && i < NUM_INNOVATE_O2_SENSORS; i++) {
innovate_o2_sensor[i].function_code = (ser_buffer[2 + i * 4] >> 2 & 0x7);
// innovate_o2_sensor[i].AFR_multiplier = ((ser_buffer[2 + i * 4] << 7 | ser_buffer[3 + i * 4]) & 0xFF);
innovate_o2_sensor[i].AFR_multiplier = AFR_MULTIPLIER;
switch (innovate_o2_sensor[i].function_code) {
case 0: //Lambda valid and aux data valid, normal operation
case 1: //Lambda value contains o2 level in 1/10%
innovate_o2_sensor[i].lambda = ((ser_buffer[4 + i * 4] << 7 | ser_buffer[5 + i * 4]) & 0x1FFF);
raw_afr = ((innovate_o2_sensor[i].lambda + 500) * innovate_o2_sensor[i].AFR_multiplier);
if (innovate_o2_sensor[i].function_code) {//case 1
innovate_o2_sensor[i].AFR = raw_afr * 0.001;
} else { // case 0
innovate_o2_sensor[i].AFR = raw_afr * 0.0001;
}
if (innovate_o2_sensor[i].AFR > AFRMAX) {
innovate_o2_sensor[i].AFR = AFRMAX;
} else if (innovate_o2_sensor[i].AFR < AFRMIN) {
innovate_o2_sensor[i].AFR = AFRMIN;
}
InnovateLC2AFR = innovate_o2_sensor[0].AFR; //only using one sensor right now
break;
// this is invalid o2 data, so we can ignore it:
// case 2: // Free air Calib in progress, Lambda data not valid
// break;
// case 3: // Need Free air Calibration Request, Lambda data not valid
// break;
case 4: // Warming up, Lambda value is temp in 1/10% of operating temp
InnovateLC2AFR = AFR_ERROR;
innovate_o2_sensor[i].warmup = ((ser_buffer[4 + i * 4] << 7 | ser_buffer[5 + i * 4]) & 0x1FFF);
//catch potential overflow:
if (innovate_o2_sensor[i].warmup >= 1023) {
innovate_o2_sensor[i].warmup = 1023;
} else if (innovate_o2_sensor[i].warmup <= 0) {
innovate_o2_sensor[i].warmup = 0;
}
break;
// case 5: // Heater Calibration, Lambda value contains calibration countdown
// break;
case 6: // Error code in Lambda value
InnovateLC2AFR = AFR_ERROR;
innovate_o2_sensor[i].error_code = (sensor_error_code_t)((ser_buffer[4 + i * 4] << 7 | ser_buffer[5 + i * 4]) & 0x1FFF);
//catch potential overflow:
if (innovate_o2_sensor[i].error_code >= (sensor_error_code_t)1023) {
innovate_o2_sensor[i].error_code = (sensor_error_code_t)1023;
} else if (innovate_o2_sensor[i].error_code <= 0) {
innovate_o2_sensor[i].error_code = (sensor_error_code_t)0;
}
break;
// case 7: // reserved
// break;
default:
InnovateLC2AFR = AFR_ERROR;
break;
}
}
}
void ResetSerialSensor() {
ClearSerialBuffer();
ParseSerialData();
}
void ClearSerialBuffer() {
memset(ser_buffer, 0, sizeof(ser_buffer));
}
void ParseSerialData() {
if (engineConfiguration->enableInnovateLC2)
IdentifyInnovateSerialMsg();
}
#endif

View File

@ -1,20 +0,0 @@
/**
* @file serial_sensor.h
*
*
* @date Mar 19, 2020
* @author Konstantin Smola, (c) 2020
*/
#pragma once
#define AFRMIN 0
#define AFRMAX 33
#define AFR_ERROR 30
void IdentifyInnovateSerialMsg();
void ParseInnovateSerialMsg();
void ParseSerialData();
void ResetSerialSensor();
void ClearSerialBuffer();

View File

@ -23,7 +23,6 @@ HW_LAYER_DRIVERS =
HW_LAYER_DRIVERS_CPP = \
$(DRIVERS_DIR)/can/can_hw.cpp \
$(DRIVERS_DIR)/serial/serial_hw.cpp \
$(PROJECT_DIR)/hw_layer/smart_gpio.cpp \
$(DRIVERS_DIR)/gpio/can_gpio_msiobox.cpp \
$(DRIVERS_DIR)/gpio/tle6240.cpp \

View File

@ -1,87 +0,0 @@
/**
* @file serial_hw.cpp
* @brief SERIAL bus low level code
*
* @date Apr 17, 2020
* @author Konstantin Smola, (c) 2020
*/
#include "pch.h"
#if EFI_AUX_SERIAL
#include "serial.h"
#include "serial_hw.h"
#include "string.h"
#include "mpu_util.h"
static bool isSerialEnabled = false;
static bool isSerialTXEnabled = false;
static bool isSerialRXEnabled = false;
static SerialConfig uartCfg;
static SerialRead serialRead;
static void auxInfo() {
if (!isSerialEnabled) {
efiPrintf("AUX Serial is not enabled, please enable & restart");
return;
}
efiPrintf("AUX Serial TX %s", hwPortname(engineConfiguration->auxSerialTxPin));
efiPrintf("AUX Serial RX %s", hwPortname(engineConfiguration->auxSerialRxPin));
}
void enableAuxSerial() {
uartCfg.speed = engineConfiguration->auxSerialSpeed;
sdStart(AUX_SERIAL_DEVICE, &uartCfg);
efiPrintf("AUX Serial started");
}
void stopAuxSerialPins() {
efiSetPadUnused(activeConfiguration.auxSerialTxPin);
efiSetPadUnused(activeConfiguration.auxSerialRxPin);
}
void startAuxSerialPins() {
if (isBrainPinValid(engineConfiguration->auxSerialTxPin))
efiSetPadMode("AuxSerial TX", engineConfiguration->auxSerialTxPin, PAL_MODE_ALTERNATE(8));
if (isBrainPinValid(engineConfiguration->auxSerialRxPin))
efiSetPadMode("AuxSerial RX", engineConfiguration->auxSerialRxPin, PAL_MODE_ALTERNATE(8));
enableAuxSerial();
}
void initAuxSerial(void) {
addConsoleAction("auxinfo", auxInfo);
isSerialRXEnabled = isBrainPinValid(engineConfiguration->auxSerialRxPin);
isSerialTXEnabled = isBrainPinValid(engineConfiguration->auxSerialTxPin);
isSerialEnabled =
isSerialRXEnabled || // we need at least one pin set
isSerialTXEnabled;
// exit if no pin is configured
if (!isSerialEnabled)
return;
// Validate pins
if (isSerialTXEnabled && !isValidSerialTxPin(engineConfiguration->auxSerialTxPin)) {
criticalError("unexpected aux TX pin");
return;
}
if (isSerialRXEnabled && !isValidSerialRxPin(engineConfiguration->auxSerialRxPin)) {
criticalError("unexpected aux RX pin");
return;
}
startAuxSerialPins();
if (isSerialRXEnabled)
serialRead.start();
}
#endif // EFI_AUX_SERIAL

View File

@ -1,16 +0,0 @@
/**
* @file serial_hw.h
* @brief SERIAL bus low level code
*
* @date Apr 17, 2020
* @author Konstantin Smola, (c) 2020
*/
#pragma once
void initAuxSerial(void);
#if EFI_AUX_SERIAL
void stopAuxSerialPins();
void startAuxSerialPins();
void enableAuxSerial();
#endif //EFI_AUX_SERIAL

View File

@ -22,7 +22,6 @@
#include "eficonsole.h"
#include "console_io.h"
#include "sensor_chart.h"
#include "serial_hw.h"
#include "idle_thread.h"
#include "odometer.h"
#include "kline.h"
@ -348,10 +347,6 @@ void applyNewHardwareSettings() {
stopKLine();
#if EFI_AUX_SERIAL
stopAuxSerialPins();
#endif /* EFI_AUX_SERIAL */
#if EFI_HIP_9011
stopHip9011_pins();
#endif /* EFI_HIP_9011 */
@ -399,13 +394,8 @@ void applyNewHardwareSettings() {
startSmartCsPins();
#endif /* (BOARD_EXT_GPIOCHIPS > 0) */
#if EFI_AUX_SERIAL
startAuxSerialPins();
#endif /* EFI_AUX_SERIAL */
startKLine();
#if EFI_HIP_9011
startHip9011_pins();
#endif /* EFI_HIP_9011 */
@ -637,10 +627,6 @@ void initHardware() {
initGps();
#endif
#if EFI_AUX_SERIAL
initAuxSerial();
#endif /* EFI_AUX_SERIAL */
#if EFI_CAN_SUPPORT
initCanVssSupport();
#endif // EFI_CAN_SUPPORT

View File

@ -554,7 +554,6 @@ uint32_t cylindersCount;Number of cylinder the engine has.;"", 1, 0, 1, @@MAX_CY
#define ts_show_startup_map_baro_grab true
#define ts_show_wbo_canbus_index true
#define ts_show_wbo_canbus_set_index true
#define ts_show_uegoSerial true
#define ts_show_ego2 true
#define ts_show_exhaust_vvt true
#define ts_show_second_bank true
@ -948,7 +947,7 @@ custom maf_sensor_type_e 1 bits, S08, @OFFSET@, [0:1], @@maf_sensor_type_e_enum@
bit canInputBCM
bit consumeObdSensors;This property is useful if using rusEFI as TCM or BCM only
bit enableCanVss;Read VSS from OEM CAN bus according to selected CAN vehicle configuration.
bit enableInnovateLC2
bit unusedSnableInnovateLC2
bit showHumanReadableWarning
bit stftIgnoreErrorMagnitude;If enabled, adjust at a constant rate instead of a rate proportional to the current lambda error. This mode may be easier to tune, and more tolerant of sensor noise.
bit vvtBooleanForVerySpecialCases
@ -1224,8 +1223,8 @@ int16_t tps2Max;Full throttle#2. tpsMax value as 10 bit ADC value. Not Voltage!\
int16_t afterCrankingIACtaperDuration;This is the duration in cycles that the IAC will take to reach its normal idle position, it can be used to hold the idle higher for a few seconds after cranking to improve startup.\Should be 100 once tune is better;"cycles", 1, 0, 0, 5000, 0
int16_t iacByTpsTaper;IAC Value added when coasting and transitioning into idle.;"percent", 1, 0, 0, 500, 0
Gpio auxSerialTxPin;Auxiliary sensor serial, not to be confused with secondary calibration serial;
Gpio auxSerialRxPin;Auxiliary sensor serial, not to be confused with secondary calibration serial;
Gpio unusedAuxSeria
Gpio unusedAuxSerialRx
Gpio accelerometerCsPin;
uint8_t coastingFuelCutVssLow;Below this speed, disable DFCO. Use this to prevent jerkiness from fuel enable/disable in low gears.;"kph", 1, 0, 0, 255, 0
@ -1247,7 +1246,7 @@ int16_t tps2Max;Full throttle#2. tpsMax value as 10 bit ADC value. Not Voltage!\
float tpsDecelEnleanmentThreshold;For decel we simply multiply delta of TPS and tFor decel we do not use table?!;"roc", 1, 0, 0, 200, 1
float tpsDecelEnleanmentMultiplier;Magic multiplier, we multiply delta of TPS and get fuel squirt duration;"coeff", 1, 0, 0, 200, 2
uint32_t auxSerialSpeed;;"BPs", 1, 0, 0, 1000000, 0
uint32_t unusedAuxSerialSpee
float throttlePedalSecondaryUpVoltage;;"voltage", 1, 0, -6, 6, 2
float throttlePedalSecondaryWOTVoltage;Pedal in the floor;"voltage", 1, 0, -6, 6, 2

View File

@ -71,8 +71,6 @@
#define EFI_BOSCH_YAW FALSE
#define EFI_AUX_SERIAL FALSE
#define EFI_CLOCK_LOCKS FALSE
#define TS_UART_MODE FALSE