AEM X-Series CAN Wideband Support (#1096)

* aem xseries

* parens to avoid operator precedence issues

* put in cfg

* disable that too

* fix sim/unit

* enough generated for ci

* this will guard correctly
This commit is contained in:
Matthew Kennedy 2020-01-12 00:44:37 -08:00 committed by rusefi
parent 1c96a41aee
commit 8200a3da64
6 changed files with 32 additions and 8 deletions

View File

@ -1725,7 +1725,7 @@ typedef enum {
CUSTOM_OBD_ANALOG_INPUT_NOT_CONFIGURED = 6038,
CUSTOM_OBD_WRONG_ADC_MODE = 6039,
CUSTOM_OBD_LOW_CAN_PERIOD = 6040,
CUSTOM_OBD_6040 = 6040,
CUSTOM_OBD_KNOCK_PROCESSOR = 6041,
CUSTOM_OBD_LOCAL_FREEZE = 6042,
CUSTOM_OBD_MMC_ERROR = 6043,

View File

@ -95,6 +95,10 @@ void initEgoAveraging(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
#endif
bool hasAfrSensor(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
if (CONFIG(enableAemXSeries)) {
return true;
}
#if EFI_CJ125 && HAL_USE_SPI
if (CONFIG(isCJ125Enabled)) {
return cjHasAfrSensor(PASS_ENGINE_PARAMETER_SIGNATURE);
@ -103,7 +107,15 @@ bool hasAfrSensor(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
return engineConfiguration->afr.hwChannel != EFI_ADC_NONE;
}
extern float aemXSeriesLambda;
float getAfr(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
#if EFI_CAN_SUPPORT
if (CONFIG(enableAemXSeries)) {
return aemXSeriesLambda * 14.7f;
}
#endif
#if EFI_CJ125 && HAL_USE_SPI
if (CONFIG(isCJ125Enabled)) {
return cjGetAfr(PASS_ENGINE_PARAMETER_SIGNATURE);

View File

@ -241,6 +241,8 @@ public:
}
};
volatile float aemXSeriesLambda = 0;
class CanRead final : public ThreadController<256> {
public:
CanRead()
@ -266,8 +268,17 @@ public:
// Process the message
canReadCounter++;
printPacket(&m_buffer);
obdOnCanPacketRx(&m_buffer);
// TODO: if/when we support multiple lambda sensors, sensor N
// has address 0x0180 + N where N = [0, 15]
if (m_buffer.SID == 0x0180) {
// AEM x-series lambda sensor reports in 0.0001 lambda per bit
uint16_t lambdaInt = SWAP_UINT16(m_buffer.data16[0]);
aemXSeriesLambda = 0.0001f * lambdaInt;
} else {
printPacket(&m_buffer);
obdOnCanPacketRx(&m_buffer);
}
}
}

View File

@ -643,7 +643,7 @@ bit is_enabled_spi_2
bit alignEngineSnifferAtTDC
bit useETBforIdleControl;+This setting allows the ETB to act as the idle air control valve and move to regulate the airflow at idle.
bit idleIncrementalPidCic
bit unused_board_984_31
bit enableAemXSeries
brain_input_pin_e[LOGIC_ANALYZER_CHANNEL_COUNT iterate] logicAnalyzerPins;
pin_output_mode_e mainRelayPinMode;

View File

@ -1951,8 +1951,9 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00"
field = "Heater pin", o2heaterPin
dialog = egoSettings, "", yAxis
panel = egoSettings_IO
panel = egoSettings_sensor, {afr_hwChannel != 16}
panel = egoSettings_IO, {enableAemXSeries == 0}
panel = egoSettings_sensor, {afr_hwChannel != 16 && enableAemXSeries == 0}
field = "Enable AEM X-Series CANbus", enableAemXSeries, { canReadEnabled }
; Engine->EGT inputs
dialog = egtInputs, "EGT inputs"

View File

@ -14,9 +14,9 @@
// http://en.wikipedia.org/wiki/Endianness
#define SWAP_UINT16(x) ((x) << 8) | ((x) >> 8)
#define SWAP_UINT16(x) (((x) << 8) | ((x) >> 8))
#define SWAP_UINT32(x) (((x) >> 24) & 0xff) | (((x) << 8) & 0xff0000) | (((x) >> 8) & 0xff00) | (((x) << 24) & 0xff000000)
#define SWAP_UINT32(x) ((((x) >> 24) & 0xff) | (((x) << 8) & 0xff0000) | (((x) >> 8) & 0xff00) | (((x) << 24) & 0xff000000))
// human-readable IDs start from 1 while computer-readbale indexes start from 0
#define ID2INDEX(id) ((id) - 1)