|
#define | BIT_SET(a, b) ((a) |= (1U<<(b))) |
|
#define | BIT_CLEAR(a, b) ((a) &= ~(1U<<(b))) |
|
#define | BIT_CHECK(var, pos) !!((var) & (1U<<(pos))) |
|
#define | BIT_TOGGLE(var, pos) ((var)^= 1UL << (pos)) |
|
#define | BIT_WRITE(var, pos, bitvalue) ((bitvalue) ? BIT_SET((var), (pos)) : bitClear((var), (pos))) |
|
#define | CRANK_ANGLE_MAX (max(CRANK_ANGLE_MAX_IGN, CRANK_ANGLE_MAX_INJ)) |
|
#define | interruptSafe(c) (noInterrupts(); {c} interrupts();) |
|
#define | MICROS_PER_SEC INT32_C(1000000) |
|
#define | MICROS_PER_MIN INT32_C(MICROS_PER_SEC*60U) |
|
#define | MICROS_PER_HOUR INT32_C(MICROS_PER_MIN*60U) |
|
#define | SERIAL_PORT_PRIMARY 0 |
|
#define | SERIAL_PORT_SECONDARY 3 |
|
#define | LOAD_SOURCE_MAP 0 |
|
#define | LOAD_SOURCE_TPS 1 |
|
#define | LOAD_SOURCE_IMAPEMAP 2 |
|
#define | BIT_ENGINE_RUN 0 |
|
#define | BIT_ENGINE_CRANK 1 |
|
#define | BIT_ENGINE_ASE 2 |
|
#define | BIT_ENGINE_WARMUP 3 |
|
#define | BIT_ENGINE_ACC 4 |
|
#define | BIT_ENGINE_DCC 5 |
|
#define | BIT_ENGINE_MAPACC 6 |
|
#define | BIT_ENGINE_MAPDCC 7 |
|
#define | BIT_STATUS1_INJ1 0 |
|
#define | BIT_STATUS1_INJ2 1 |
|
#define | BIT_STATUS1_INJ3 2 |
|
#define | BIT_STATUS1_INJ4 3 |
|
#define | BIT_STATUS1_DFCO 4 |
|
#define | BIT_STATUS1_BOOSTCUT 5 |
|
#define | BIT_STATUS1_TOOTHLOG1READY 6 |
|
#define | BIT_STATUS1_TOOTHLOG2READY 7 |
|
#define | BIT_STATUS2_HLAUNCH 0 |
|
#define | BIT_STATUS2_SLAUNCH 1 |
|
#define | BIT_STATUS2_HRDLIM 2 |
|
#define | BIT_STATUS2_SFTLIM 3 |
|
#define | BIT_STATUS2_BOOSTCUT 4 |
|
#define | BIT_STATUS2_ERROR 5 |
|
#define | BIT_STATUS2_IDLE 6 |
|
#define | BIT_STATUS2_SYNC 7 |
|
#define | BIT_STATUS5_FLATSH 0 |
|
#define | BIT_STATUS5_FLATSS 1 |
|
#define | BIT_STATUS5_SPARK2_ACTIVE 2 |
|
#define | BIT_STATUS5_KNOCK_ACTIVE 3 |
|
#define | BIT_STATUS5_KNOCK_PULSE 4 |
|
#define | BIT_STATUS5_UNUSED6 5 |
|
#define | BIT_STATUS5_UNUSED7 6 |
|
#define | BIT_STATUS5_UNUSED8 7 |
|
#define | BIT_TIMER_1HZ 0 |
|
#define | BIT_TIMER_4HZ 1 |
|
#define | BIT_TIMER_10HZ 2 |
|
#define | BIT_TIMER_15HZ 3 |
|
#define | BIT_TIMER_30HZ 4 |
|
#define | BIT_TIMER_50HZ 5 |
|
#define | BIT_TIMER_200HZ 6 |
|
#define | BIT_TIMER_1KHZ 7 |
|
#define | BIT_STATUS3_RESET_PREVENT 0 |
|
#define | BIT_STATUS3_NITROUS 1 |
|
#define | BIT_STATUS3_FUEL2_ACTIVE 2 |
|
#define | BIT_STATUS3_VSS_REFRESH 3 |
|
#define | BIT_STATUS3_HALFSYNC 4 |
|
#define | BIT_STATUS3_NSQUIRTS1 5 |
|
#define | BIT_STATUS3_NSQUIRTS2 6 |
|
#define | BIT_STATUS3_NSQUIRTS3 7 |
|
#define | BIT_STATUS4_WMI_EMPTY 0 |
|
#define | BIT_STATUS4_VVT1_ERROR 1 |
|
#define | BIT_STATUS4_VVT2_ERROR 2 |
|
#define | BIT_STATUS4_FAN 3 |
|
#define | BIT_STATUS4_BURNPENDING 4 |
|
#define | BIT_STATUS4_STAGING_ACTIVE 5 |
|
#define | BIT_STATUS4_COMMS_COMPAT 6 |
|
#define | BIT_STATUS4_ALLOW_LEGACY_COMMS 7 |
|
#define | BIT_AIRCON_REQUEST 0 |
|
#define | BIT_AIRCON_COMPRESSOR 1 |
|
#define | BIT_AIRCON_RPM_LOCKOUT 2 |
|
#define | BIT_AIRCON_TPS_LOCKOUT 3 |
|
#define | BIT_AIRCON_TURNING_ON 4 |
|
#define | BIT_AIRCON_CLT_LOCKOUT 5 |
|
#define | BIT_AIRCON_FAN 6 |
|
#define | BIT_AIRCON_UNUSED8 7 |
|
#define | TOOTH_LOG_SIZE 127U |
|
#define | O2_CALIBRATION_PAGE 2U |
|
#define | IAT_CALIBRATION_PAGE 1U |
|
#define | CLT_CALIBRATION_PAGE 0U |
|
#define | COMPOSITE_LOG_PRI 0 |
|
#define | COMPOSITE_LOG_SEC 1 |
|
#define | COMPOSITE_LOG_THIRD 2 |
|
#define | COMPOSITE_LOG_TRIG 3 |
|
#define | COMPOSITE_LOG_SYNC 4 |
|
#define | COMPOSITE_ENGINE_CYCLE 5 |
|
#define | EGO_TYPE_OFF 0 |
|
#define | EGO_TYPE_NARROW 1 |
|
#define | EGO_TYPE_WIDE 2 |
|
#define | INJ_TYPE_PORT 0 |
|
#define | INJ_TYPE_TBODY 1 |
|
#define | INJ_PAIRED 0 |
|
#define | INJ_SEMISEQUENTIAL 1 |
|
#define | INJ_BANKED 2 |
|
#define | INJ_SEQUENTIAL 3 |
|
#define | INJ_PAIR_13_24 0 |
|
#define | INJ_PAIR_14_23 1 |
|
#define | OUTPUT_CONTROL_DIRECT 0 |
|
#define | OUTPUT_CONTROL_MC33810 10 |
|
#define | IGN_MODE_WASTED 0U |
|
#define | IGN_MODE_SINGLE 1U |
|
#define | IGN_MODE_WASTEDCOP 2U |
|
#define | IGN_MODE_SEQUENTIAL 3U |
|
#define | IGN_MODE_ROTARY 4U |
|
#define | SEC_TRIGGER_SINGLE 0 |
|
#define | SEC_TRIGGER_4_1 1 |
|
#define | SEC_TRIGGER_POLL 2 |
|
#define | SEC_TRIGGER_5_3_2 3 |
|
#define | SEC_TRIGGER_TOYOTA_3 4 |
|
#define | ROTARY_IGN_FC 0 |
|
#define | ROTARY_IGN_FD 1 |
|
#define | ROTARY_IGN_RX8 2 |
|
#define | BOOST_MODE_SIMPLE 0 |
|
#define | BOOST_MODE_FULL 1 |
|
#define | EN_BOOST_CONTROL_BARO 0 |
|
#define | EN_BOOST_CONTROL_FIXED 1 |
|
#define | WMI_MODE_SIMPLE 0 |
|
#define | WMI_MODE_PROPORTIONAL 1 |
|
#define | WMI_MODE_OPENLOOP 2 |
|
#define | WMI_MODE_CLOSEDLOOP 3 |
|
#define | HARD_CUT_FULL 0 |
|
#define | HARD_CUT_ROLLING 1 |
|
#define | EVEN_FIRE 0 |
|
#define | ODD_FIRE 1 |
|
#define | EGO_ALGORITHM_SIMPLE 0U |
|
#define | EGO_ALGORITHM_INVALID1 1U |
|
#define | EGO_ALGORITHM_PID 2U |
|
#define | EGO_ALGORITHM_NONE 3U |
|
#define | STAGING_MODE_TABLE 0 |
|
#define | STAGING_MODE_AUTO 1 |
|
#define | NITROUS_OFF 0 |
|
#define | NITROUS_STAGE1 1 |
|
#define | NITROUS_STAGE2 2 |
|
#define | NITROUS_BOTH 3 |
|
#define | PROTECT_CUT_OFF 0 |
|
#define | PROTECT_CUT_IGN 1 |
|
#define | PROTECT_CUT_FUEL 2 |
|
#define | PROTECT_CUT_BOTH 3 |
|
#define | PROTECT_IO_ERROR 7 |
|
#define | AE_MODE_TPS 0 |
|
#define | AE_MODE_MAP 1 |
|
#define | AE_MODE_MULTIPLIER 0 |
|
#define | AE_MODE_ADDER 1 |
|
#define | KNOCK_MODE_OFF 0U |
|
#define | KNOCK_MODE_DIGITAL 1U |
|
#define | KNOCK_MODE_ANALOG 2U |
|
#define | KNOCK_TRIGGER_HIGH 0 |
|
#define | KNOCK_TRIGGER_LOW 1 |
|
#define | FUEL2_MODE_OFF 0 |
|
#define | FUEL2_MODE_MULTIPLY 1 |
|
#define | FUEL2_MODE_ADD 2 |
|
#define | FUEL2_MODE_CONDITIONAL_SWITCH 3 |
|
#define | FUEL2_MODE_INPUT_SWITCH 4 |
|
#define | SPARK2_MODE_OFF 0 |
|
#define | SPARK2_MODE_MULTIPLY 1 |
|
#define | SPARK2_MODE_ADD 2 |
|
#define | SPARK2_MODE_CONDITIONAL_SWITCH 3 |
|
#define | SPARK2_MODE_INPUT_SWITCH 4 |
|
#define | FUEL2_CONDITION_RPM 0 |
|
#define | FUEL2_CONDITION_MAP 1 |
|
#define | FUEL2_CONDITION_TPS 2 |
|
#define | FUEL2_CONDITION_ETH 3 |
|
#define | SPARK2_CONDITION_RPM 0 |
|
#define | SPARK2_CONDITION_MAP 1 |
|
#define | SPARK2_CONDITION_TPS 2 |
|
#define | SPARK2_CONDITION_ETH 3 |
|
#define | RESET_CONTROL_DISABLED 0U |
|
#define | RESET_CONTROL_PREVENT_WHEN_RUNNING 1U |
|
#define | RESET_CONTROL_PREVENT_ALWAYS 2U |
|
#define | RESET_CONTROL_SERIAL_COMMAND 3U |
|
#define | OPEN_LOOP_BOOST 0 |
|
#define | CLOSED_LOOP_BOOST 1 |
|
#define | SOFT_LIMIT_FIXED 0 |
|
#define | SOFT_LIMIT_RELATIVE 1 |
|
#define | VVT_MODE_ONOFF 0 |
|
#define | VVT_MODE_OPEN_LOOP 1 |
|
#define | VVT_MODE_CLOSED_LOOP 2 |
|
#define | VVT_LOAD_MAP 0 |
|
#define | VVT_LOAD_TPS 1 |
|
#define | MULTIPLY_MAP_MODE_OFF 0 |
|
#define | MULTIPLY_MAP_MODE_BARO 1 |
|
#define | MULTIPLY_MAP_MODE_100 2 |
|
#define | FOUR_STROKE 0U |
|
#define | TWO_STROKE 1U |
|
#define | GOING_LOW 0 |
|
#define | GOING_HIGH 1 |
|
#define | BATTV_COR_MODE_WHOLE 0 |
|
#define | BATTV_COR_MODE_OPENTIME 1 |
|
#define | INJ1_CMD_BIT 0 |
|
#define | INJ2_CMD_BIT 1 |
|
#define | INJ3_CMD_BIT 2 |
|
#define | INJ4_CMD_BIT 3 |
|
#define | INJ5_CMD_BIT 4 |
|
#define | INJ6_CMD_BIT 5 |
|
#define | INJ7_CMD_BIT 6 |
|
#define | INJ8_CMD_BIT 7 |
|
#define | IGN1_CMD_BIT 0 |
|
#define | IGN2_CMD_BIT 1 |
|
#define | IGN3_CMD_BIT 2 |
|
#define | IGN4_CMD_BIT 3 |
|
#define | IGN5_CMD_BIT 4 |
|
#define | IGN6_CMD_BIT 5 |
|
#define | IGN7_CMD_BIT 6 |
|
#define | IGN8_CMD_BIT 7 |
|
#define | ENGINE_PROTECT_BIT_RPM 0 |
|
#define | ENGINE_PROTECT_BIT_MAP 1 |
|
#define | ENGINE_PROTECT_BIT_OIL 2 |
|
#define | ENGINE_PROTECT_BIT_AFR 3 |
|
#define | ENGINE_PROTECT_BIT_COOLANT 4 |
|
#define | CALIBRATION_TABLE_SIZE 512 |
| Calibration table size for CLT, IAT, O2.
|
|
#define | CALIBRATION_TEMPERATURE_OFFSET 40 |
|
#define | OFFSET_FUELTRIM 127U |
| The fuel trim tables are offset by 128 to allow for -128 to +128 values.
|
|
#define | OFFSET_IGNITION 40 |
| Ignition values from the main spark table are offset 40 degrees downwards to allow for negative spark timing.
|
|
#define | SERIAL_BUFFER_THRESHOLD 32 |
| When the serial buffer is filled to greater than this threshold value, the serial processing operations will be performed more urgently in order to avoid it overflowing. Serial buffer is 64 bytes long, so the threshold is set at half this as a reasonable figure.
|
|
#define | LOGGER_CSV_SEPARATOR_SEMICOLON 0 |
|
#define | LOGGER_CSV_SEPARATOR_COMMA 1 |
|
#define | LOGGER_CSV_SEPARATOR_TAB 2 |
|
#define | LOGGER_CSV_SEPARATOR_SPACE 3 |
|
#define | LOGGER_DISABLED 0 |
|
#define | LOGGER_CSV 1 |
|
#define | LOGGER_BINARY 2 |
|
#define | LOGGER_RATE_1HZ 0 |
|
#define | LOGGER_RATE_4HZ 1 |
|
#define | LOGGER_RATE_10HZ 2 |
|
#define | LOGGER_RATE_30HZ 3 |
|
#define | LOGGER_FILENAMING_OVERWRITE 0 |
|
#define | LOGGER_FILENAMING_DATETIME 1 |
|
#define | LOGGER_FILENAMING_SEQENTIAL 2 |
|
#define | pinIsInjector(pin) ( ((pin) == pinInjector1) || ((pin) == pinInjector2) || ((pin) == pinInjector3) || ((pin) == pinInjector4) || ((pin) == pinInjector5) || ((pin) == pinInjector6) || ((pin) == pinInjector7) || ((pin) == pinInjector8) ) |
|
#define | pinIsIgnition(pin) ( ((pin) == pinCoil1) || ((pin) == pinCoil2) || ((pin) == pinCoil3) || ((pin) == pinCoil4) || ((pin) == pinCoil5) || ((pin) == pinCoil6) || ((pin) == pinCoil7) || ((pin) == pinCoil8) ) |
|
#define | pinIsSensor(pin) ( ((pin) == pinCLT) || ((pin) == pinIAT) || ((pin) == pinMAP) || ((pin) == pinTPS) || ((pin) == pinO2) || ((pin) == pinBat) || (((pin) == pinFlex) && (configPage2.flexEnabled != 0)) ) |
|
#define | IDLEADVANCE_MODE_OFF 0U |
|
#define | IDLEADVANCE_MODE_ADDED 1U |
|
#define | IDLEADVANCE_MODE_SWITCHED 2U |
|
#define | IDLEADVANCE_ALGO_TPS 0U |
|
#define | IDLEADVANCE_ALGO_CTPS 1U |
|
Global defines, macros, struct definitions (statuses, config2, config4, config*), extern-definitions (for globally accessible vars).
Note on configuration struct layouts
Once the struct members have been assigned to certain "role" (in certain SW version), they should not be "moved around" as the structs are stored onto EEPROM as-is and the offset and size of member needs to remain constant. Also removing existing struct members would disturb layouts. Because of this a certain amount unused old members will be left into the structs. For the storage related reasons also the bit fields are defined in byte-size (or multiple of ...) chunks.
Config Structs and 2D, 3D Tables
The config* structures contain information coming from tuning SW (e.g. TS) for 2D and 3D tables, where looked up value is not a result of direct array lookup, but from interpolation algorithm. Because of standard, reusable interpolation routines associated with structs table2D and table3D, the values from config are copied from config* structs to table2D (table3D destined configurations are not stored in config* structures).
Board choice
There's a C-preprocessor based "#if defined" logic present in this header file based on the Arduino IDE compiler set CPU (+board?) type, e.g. __AVR_ATmega2560__
. This respectively drives (withi it's "#if defined ..." block):
- The setting of various BOARD_* C-preprocessor variables (e.g. BOARD_MAX_ADC_PINS)
- Setting of BOARD_H (Board header) file (e.g. "board_avr2560.h"), which is later used to include the header file
- Seems Arduino ide implicitly compiles and links respective .ino file (by it's internal build/compilation rules) (?)
- Setting of CPU (?) CORE_* variables (e.g. CORE_AVR), that is used across codebase to distinguish CPU.