Re-write core

This commit is contained in:
Ashcon Mohseninia 2021-10-11 20:47:33 +01:00
parent ac5d8f2155
commit a80b39e526
73 changed files with 16024 additions and 6596 deletions

View File

@ -1,3 +1,3 @@
cmake_minimum_required(VERSION 3.16.0)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(ultimate-nag52-fw)
project(fw)

View File

@ -1,176 +0,0 @@
#ifndef CONFIG_H_
#define CONFIG_H_
/// ---------------------------------------------------------------------------------- ///
/// SAFE ZONE ///
/// ///
/// These options can be modified safely. If you are looking for the danger zone for ///
/// experimental options, see the bottom of this file ///
/// ---------------------------------------------------------------------------------- ///
/**
* If enabled, this will compile for W5A580 722.6 (Found with V6 and larger Engines)
* Default firmware is compiled for W5A330 722.6.
*
* Default: false (W5A330)
*/
#define LARGE_NAG false
/**
* If set to true, then the gearbox will not use values from SCN coding,
* instead use values found in this configuration file!
*/
#define FORCE_HARDCODED_VALUES false
/**
* Modify to set the diameter of your tyre edge to edge.
*
* !!!! IT IS IMPORTANT TO SET THIS CORRECTLY!!!!
* Setting this parameter incorrectly will result in output shaft
* speed calculations to be incorrect, thus causing limp home mode
* as gearbox cannot accurately determine which gear it is in!
*
* You can use this website to calculate the diameter of your rear tyres
* https://www.blocklayer.com/tire-size-calculator.aspx
*
* Default is 1972mm (245/40 R17 tyres)
*
* NOTE: This parameter will be overriden by SCN coding unless FORCE_HARDCODED_VALUES
* is enabled, or SCN coding is corrupt / invalid
*
*/
#define TYRE_DIAM_MM 1972 // 1.972m
/**
* Modify to set the ratio of your rear differential
*
* !!!! IT IS IMPORTANT TO SET THIS CORRECTLY!!!!
* Setting this parameter incorrectly will result in output shaft
* speed calculations to be incorrect, thus causing limp home mode
* as gearbox cannot accurately determine which gear it is in!
*
* Default is 1972mm (245/40 R17 tyres)
*
* NOTE: This parameter will be overriden by SCN coding unless FORCE_HARDCODED_VALUES
* is enabled, or SCN coding is corrupt / invalid
*/
#define DIFF_RATIO 2870 // 2.870 : 1
/**
* Modify these to enable / disable different profiles.
*
* A brief rundown on profiles:
*
* - Agility (A) - Also known as Sport+ on newer Mercs, makes the gearbox shift harshly
* without any regards for comfort.
* - Manual (M) - Uses the same profile as 'S' mode, except the car will not automatically shift
* and requires the user to either operate the shift paddles, or +/- position on the
* shift lever
* - Winter (W) - Starts the car in 2nd gear, and very gradual shifting to reduce tyre slipping
* - Comfort (C) - Starts the car in 1st gear, and tries to create as much seamless shifting as possible,
* no matter how harshly the user is accelerating
* - Standard (S) - Moderate shifting, with more agressive shifting occuring at higher RPMs, still smoother
* than in 'A' mode.
*/
#define AGILITY_ENABLE true // 'A' mode (Default: true)
#define MANUAL_ENABLE true // 'M' mode (Default: true)
#define WINTER_ENABLE true // 'W' mode (Default: true)
#define COMFORT_ENABLE true // 'C' mode (Default: true)
#define STANDARD_ENABLE true // 'S' mode (Default: true)
/**
* If disabled, gearbox will not upshift in manual mode when hitting redline.
*
* This does NOT disable automatic downshifting to prevent stalling.
*
* Default: true
*/
#define MANUAL_SHIFT_OVERRIDE true
/**
* If enabled, the car will automatically start in Winter mode if outside air temperature
* is below 4C.
*
* Default: true
*/
#define WINTER_AUTOSTART true
/**
* If enabled, the last profile used will be written to EEPROM, and restored
* on next vehicle startup, rather than always defaulting to C/S mode!
*
* Default: true
*/
#define REMEMBER_LAST_PROFILE true
/// ---------------------------------------------------------------------------------- ///
/// DANGER ZONE ///
/// ///
/// Modifying these settings can cause undefined behaviour as they are experimental!! ///
/// Modify at your own risk! ///
/// ///
/// Once these settings become stable, they will be moved to the safe zone ///
/// ---------------------------------------------------------------------------------- ///
/**
* Enables experimental 6th and 7th gear.
*
* These are completely fake gear. And are just extras to provide gears where
* the torque converter completely locks up to improve efficiency. See the
* gearing table below to see how it works!
*
* D1 - 1st
* D2 - 2nd
* D3 - 3rd
* D4 - 4th
* D5 - 4th + 100% lockup
* D6 - 5th
* D7 - 5th + 100% lockup
*
* Default: False
*/
#define ENABLE_100_LOCKUP_GEARS false
/**
* Changes CAN compatibility from EGS52 to the EGS53's CAN network (Used in 2008 and newer cars),
* as well as changing the diagnostic layer from KWP2000 to UDS.
*
* Default: false
*/
#define EGS53_MODE false
/**
* Enables experimental shift AI framework (SAI)
*
* Default: false
*/
#define ENABLE_SAI false
/**
* Makes the Instrument cluster BEEP in manual mode if approaching max engine RPM to prompt an upshift from the user
*
* This is done by doing some magic over CANBUS to fake a frame from the Cruise control ECU in order to make
* the cluster BEEP rapidly.
*
* Default: false
*/
#define BEEP_MANUAL_UPSHIFT false
#endif // CONFIG_H_

42
include/fluid.h Normal file
View File

@ -0,0 +1,42 @@
/**
* ATF fluid viscosity readings.
*
*
* There are 3 readings that the gearbox uses
* ATF_KV_40C - ATF kinematic viscosity (ISO 3104) at 40C (mm^2/sec)
* ATF_KV_100C - ATF kinematic viscosity (ISO 3104) at 100C (mm^2/sec)
* ATF_VI - ATF viscosity index (ISO2909)
*/
#define MERCEDES_236_10
//#define MERCEDES_236_12
//#define MERCEDES_234_14
#ifdef MERCEDES_236_10
#define ATF_KV_40C 34.5
#define ATF_KV_100C 7.4
#define ATF_VI 189
#endif
#ifdef MERCEDES_236_12
#define ATF_KV_40C 29
#define ATF_KV_100C 6.3
#define ATF_VI 179
#endif
#ifdef MERCEDES_236_14
#define ATF_KV_40C 29
#define ATF_KV_100C 6.5
#define ATF_VI 188
#endif
#ifdef MERCEDES_236_15
#define ATF_KV_40C 29.6
#define ATF_KV_100C 6.0
#define ATF_VI 154
#endif
#if !defined(ATF_40C) || !defined(ATF_100C)
#error "ATF viscosity undefined!"
#endif

View File

@ -1,34 +0,0 @@
#ifndef GEARING_H_
#define GEARING_H_
#include <config.h>
#if LARGE_NAG == true
/** Gear ratios for W5A580 (Large 722.6) **/
#define GEAR_D1 3.5876
#define GEAR_D2 2.1862
#define GEAR_D3 1.4054
#define GEAR_D4 1.0000
#define GEAR_D5 0.8314
#define GEAR_R1 -3.1605
#define GEAR_R2 -1.9259
#else
/** Gear ratios for W5A330 (Small 722.6) **/
#define GEAR_D1 3.9319
#define GEAR_D2 2.4079
#define GEAR_D3 1.4857
#define GEAR_D4 1.0000
#define GEAR_D5 0.8305
#define GEAR_R1 -3.1002
#define GEAR_R2 -1.8986
#endif
#endif // GEARING_H_

View File

@ -1,33 +1,39 @@
#ifndef PINS_H_
#define PINS_H_
#ifndef __PINS_H_
#define __PINS_H_
#define PIN_CAN_TX gpio_num_t::GPIO_NUM_5
#define PIN_CAN_RX gpio_num_t::GPIO_NUM_4
/**
* Pin configuration
*
* Current board. V1.0
*/
#define PIN_SPKR gpio_num_t::GPIO_NUM_15
#define PIN_5V_ENABLE gpio_num_t::GPIO_NUM_2
#define PIN_CAN_TX gpio_num_t::GPIO_NUM_5 // CAN TWAI Tx
#define PIN_CAN_RX gpio_num_t::GPIO_NUM_4 // CAN TWAI Rx
// Sensors
#define PIN_V_SENSE gpio_num_t::GPIO_NUM_25 // Voltage monitor
#define PIN_ATF_SENSE gpio_num_t::GPIO_NUM_26 // ATF / lockout sensor
#define PIN_N3_SENSE gpio_num_t::GPIO_NUM_27 // N3 input RPM
#define PIN_N2_SENSE gpio_num_t::GPIO_NUM_14 // N2 input RPM
#define PIN_SPKR gpio_num_t::GPIO_NUM_15 // Piezo speaker
#define PIN_5V_EN gpio_num_t::GPIO_NUM_2 // 5V enable circuit for sensors
// Solenoid current feedback
#define PIN_Y3_SENSE gpio_num_t::GPIO_NUM_36
#define PIN_Y4_SENSE gpio_num_t::GPIO_NUM_39
#define PIN_Y5_SENSE gpio_num_t::GPIO_NUM_35
#define PIN_MPC_SENSE gpio_num_t::GPIO_NUM_34
#define PIN_SPC_SENSE gpio_num_t::GPIO_NUM_32
#define PIN_TCC_SENSE gpio_num_t::GPIO_NUM_33
#define PIN_VBATT gpio_num_t::GPIO_NUM_25 // Battery voltage feedback
#define PIN_ATF gpio_num_t::GPIO_NUM_26 // ATF temp sensor and lockout
#define PIN_N3 gpio_num_t::GPIO_NUM_27 // N3 speed sensor
#define PIN_N2 gpio_num_t::GPIO_NUM_14 // N3 speed sensor
// Solenoid PWM outputs
#define PIN_Y3_PWM gpio_num_t::GPIO_NUM_23
#define PIN_Y4_PWM gpio_num_t::GPIO_NUM_22
#define PIN_Y5_PWM gpio_num_t::GPIO_NUM_19
#define PIN_MPC_PWM gpio_num_t::GPIO_NUM_21
#define PIN_SPC_PWM gpio_num_t::GPIO_NUM_12
#define PIN_TCC_PWM gpio_num_t::GPIO_NUM_13
#define PIN_Y3_SENSE gpio_num_t::GPIO_NUM_36 // Y3 (1-2/4-5) shift solenoid (Current feedback)
#define PIN_Y3_PWM gpio_num_t::GPIO_NUM_23 // Y3 (1-2/4-5) shift solenoid (PWM output)
#define PIN_Y4_SENSE gpio_num_t::GPIO_NUM_39 // Y4 (3-4) shift solenoid (Current feedback)
#define PIN_Y4_PWM gpio_num_t::GPIO_NUM_22 // Y4 (3-4) shift solenoid (PWM output)
#endif // PINS_H_
#define PIN_Y5_SENSE gpio_num_t::GPIO_NUM_35 // Y5 (2-3) shift solenoid (Current feedback)
#define PIN_Y5_PWM gpio_num_t::GPIO_NUM_19 // Y5 (2-3) shift solenoid (PWM output)
#define PIN_MPC_SENSE gpio_num_t::GPIO_NUM_34 // Modulating pressure solenoid (Current feedback)
#define PIN_MPC_PWM gpio_num_t::GPIO_NUM_21 // Modulating pressure solenoid (PWM output)
#define PIN_SPC_SENSE gpio_num_t::GPIO_NUM_32 // Shift pressure solenoid (Current feedback)
#define PIN_SPC_PWM gpio_num_t::GPIO_NUM_12 // Shift pressure solenoid (PWM output)
#define PIN_TCC_SENSE gpio_num_t::GPIO_NUM_33 // Torque converter solenoid(Current feedback)
#define PIN_TCC_PWM gpio_num_t::GPIO_NUM_13 // Torque converter solenoid (PWM output)
#endif // __PINS_H_

10576
include/scn.h Normal file

File diff suppressed because it is too large Load Diff

2128
include/scn_definition.h Normal file

File diff suppressed because it is too large Load Diff

1447
include/scn_internal.h Normal file

File diff suppressed because it is too large Load Diff

19
lib/convert.py Normal file
View File

@ -0,0 +1,19 @@
# Converts my text files from MBUX-PORT project to C++ header files to use with my ECU!
import os
import sys
input_file=open(sys.argv[1])
output_dir=sys.argv[2]
print("Input file: ", input_file, " Output dir: ", output_dir)
ecu=""
for line in input_file:
if "FRAME " in line:
print(line)
parsed = line.replace(" ", "").split("FRAME")[1]
ecu = parsed.split(" (")[0].split("_")[0]
can_id = parsed.split("(")[1].split(")")[0]
print("Frame {} for ECU {}".format(can_id, ecu))

View File

@ -0,0 +1,4 @@
# What is this?
ECU CAN definitions for EGS52 compatibility (2000-2008 vehicles with EGS52 TCM)

1281
lib/egs52_ecus/can_data.txt Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,184 +0,0 @@
# Remember those text files from my MercedesUI project?
# Well this script converts the data from those files
# into unions that can be manipulated in C++!
import sys
import os
file_name = sys.argv[1]
frame_name = sys.argv[2]
lines = open(file_name, 'r').readlines()
def clear_bit(mask, bit):
return mask & ~(1<<bit)
def get_data_type(len: int) -> str:
if len == 1:
return "bool"
elif len <= 8:
return "uint8_t"
elif len <= 16:
return "short"
elif len <= 32:
return "int"
else:
raise "> 64bit numbers not handled!"
#print("{0:{fill}64b}".format(mask, fill = '0'))
def get_param_text(name: str, desc: str, offset: int, length: int, is_enum: bool) -> str:
# assume all CAN Frames are 64bits in size, and use BigEndian (All MB ECUs in W203 do!)
if 64-offset-length < 0:
raise "Shift is less than 0!?"
mask = 0xFFFFFFFFFFFFFFFF
start_mask = 63-offset
for bit in range(0,length):
mask = clear_bit(mask, start_mask-bit)
f_mask = 0x0
for bit in range(0,length):
f_mask = (f_mask | 0x01 << bit)
if is_enum == True: # Enum parsing
enum_name = "{}_{}".format(frame_name.upper(), name)
string = ""
string = " // Sets {}\n".format(desc)
string += " void set_{}({} value){{ raw = (raw & 0x{:{fill}16x}) | ((uint64_t)value & 0x{:x}) << {}; }}\n".format(enum_name, enum_name, mask, f_mask, 64-length-offset, fill='0')
string += " // Gets {}\n".format(desc)
string += " {} get_{}() {{ return ({})(raw >> {} & 0x{:x}); }}\n".format(enum_name, name, enum_name, 64-length-offset, f_mask)
else: # Normal integer / Boolean
string = ""
string = " // Sets {}\n".format(desc)
string += " void set_{}({} value){{ raw = (raw & 0x{:{fill}16x}) | ((uint64_t)value & 0x{:x}) << {}; }}\n".format(name, get_data_type(length), mask, f_mask, 64-length-offset, fill='0')
string += " // Gets {}\n".format(desc)
string += " {} get_{}() {{ return raw >> {} & 0x{:x}; }}\n".format(get_data_type(length), name, 64-length-offset, f_mask)
return string
frame_lines = []
entries = []
enum_entries_unfiltered = []
enum_entries = {}
located_frame = False
in_enum = False
frame_id = ""
for line in lines:
if line.strip().startswith("FRAME"):
if line.strip().startswith("FRAME {}".format(frame_name)):
frame_id = line.split("(")[1].split(")")[0]
located_frame = True
elif located_frame: # next frame located, we are done loading lines!
break
elif located_frame and not line.strip().startswith("RAW:"):
# ONLY ADD ENTRIES - NOT ENUM VALUES
entries.append(line.strip())
elif located_frame and line.strip().startswith("RAW:"):
try:
enum_entries_unfiltered.append((entries[-1].split(": ")[1].split(",")[0],line.strip()))
except Exception:
print(entries[-1])
enum_entries_unfiltered.append((entries[-1],line.strip()))
continue
if located_frame == False:
raise Exception("Frame not found!")
for x in enum_entries_unfiltered:
if x[0] in enum_entries:
enum_entries[x[0]].append(x[1])
else:
enum_entries[x[0]] = [x[1]]
ecu_name = frame_name.rstrip('h').split("_")[0]
print(enum_entries)
res = ""
print("Found {} entries for {}".format(len(entries), frame_name))
res += "#ifndef {}_H_\n".format(frame_name.upper())
res += "#define {}_H_\n\n".format(frame_name.upper())
res += "/**\n"
res += " * AUTOGENERATED BY gen_unions.py\n"
res += "*/\n"
res += "#include <stdint.h>\n"
res += "\n"
res += "#define {}_ID {}\n".format(frame_name.rstrip('h'), frame_id)
res += "\n\n\n"
# Enums for CAN frame
for x in enum_entries:
res += "enum class {}_{} {{\n".format(frame_name.upper(), x)
for enum in enum_entries[x]:
raw = enum.split("RAW: ")[1].split(" -")[0]
name = enum.split(" / ")[-1]
desc = enum.split(" - ")[1].split(" / ")[0]
res += " {} = {}, /** {} */\n".format(name, raw, desc)
res += "};\n\n"
res += "\n\n\n"
res += "typedef union {\n"
res += " uint8_t bytes[8];\n"
res += " uint64_t raw;\n\n"
for entry in entries:
if not entry:
continue
name = entry.split(": ")[1].split(",")[0]
offset = int(entry.split("OFFSET ")[1].split(" LEN")[0])
length = int(entry.split("LEN ")[1].split(" ")[0])
desc = entry.split(" - ")[1]
is_enum = name in enum_entries
res += get_param_text(name, desc, offset, length, is_enum)
res += "\n"
# Export frame function
res += " /** Imports the frame data from a source */\n"
res += " void import_frame(uint32_t cid, uint8_t* data, uint8_t len) {\n"
res += " if (cid == {}_ID) {{\n".format(frame_name.rstrip('h'))
res += " for (int i = 0; i < len; i++) {\n"
res += " bytes[7-i] = data[i];\n"
res += " }\n"
res += " }\n"
res += " }\n"
res +="\n"
res += " /** Exports the frame data to a destination */\n"
res += " void export_frame(uint32_t* cid, uint8_t* data, uint8_t* len) {\n"
res += " *cid = {}_ID;\n".format(frame_name.rstrip('h'))
res += " *len = 8;\n"
res += " for (int i = 0; i < *len; i++) {\n"
res += " data[i] = bytes[7-i];\n"
res += " }\n"
res += " }\n"
res += "}} {};\n".format(frame_name.rstrip('h'))
res += "\n#endif\n"
path = "src/{}/".format(ecu_name)
if not os.path.exists(path):
os.makedirs(path)
write_file = open("src/{}/{}.h".format(ecu_name, frame_name.rstrip('h')), 'w')
write_file.write(res)
print("Parse complete")

View File

@ -1,54 +0,0 @@
#ifndef ARCADE_A2_H_
#define ARCADE_A2_H_
/**
* AUTOGENERATED BY gen_unions.py
*/
#include <stdint.h>
#define ARCADE_A2_ID 0x0035
typedef union {
uint8_t bytes[8];
uint64_t raw;
// Sets frontal event 5
void set_CRASH_C(bool value){ raw = (raw & 0xfbffffffffffffff) | ((uint64_t)value & 0x1) << 58; }
// Gets frontal event 5
bool get_CRASH_C() { return raw >> 58 & 0x1; }
// Sets frontal event 2
void set_CRASH_F(bool value){ raw = (raw & 0xdfffffffffffffff) | ((uint64_t)value & 0x1) << 61; }
// Gets frontal event 2
bool get_CRASH_F() { return raw >> 61 & 0x1; }
// Sets Confirm bit for all crash events, toggling
void set_CONF_CRASH(bool value){ raw = (raw & 0x7fffffffffffffff) | ((uint64_t)value & 0x1) << 63; }
// Gets Confirm bit for all crash events, toggling
bool get_CONF_CRASH() { return raw >> 63 & 0x1; }
/** Imports the frame data from a source */
void import_frame(uint32_t cid, uint8_t* data, uint8_t len) {
if (cid == ARCADE_A2_ID) {
for (int i = 0; i < len; i++) {
bytes[7-i] = data[i];
}
}
}
/** Exports the frame data to a destination */
void export_frame(uint32_t* cid, uint8_t* data, uint8_t* len) {
*cid = ARCADE_A2_ID;
*len = 8;
for (int i = 0; i < *len; i++) {
data[i] = bytes[7-i];
}
}
} ARCADE_A2;
#endif

View File

@ -1,155 +0,0 @@
#ifndef ART_250_H_
#define ART_250_H_
/**
* AUTOGENERATED BY gen_unions.py
*/
#include <stdint.h>
#define ART_250_ID 0x0250
enum class ART_250_SLV_ART {
SKL0 = 0, /** switching characteristic "0" */
SKL1 = 1, /** switching characteristic "1" */
SKL2 = 2, /** switching characteristic "2" */
SKL3 = 3, /** switching characteristic "3" */
SKL4 = 4, /** switching characteristic "4" */
SKL5 = 5, /** switching characteristic "5" */
SKL6 = 6, /** switching characteristic "6" */
SKL7 = 7, /** switching characteristic "7" */
SKL8 = 8, /** switching characteristic "8" */
SKL9 = 9, /** switching characteristic "9" */
SKL10 = 10, /** switching characteristic "10" */
};
enum class ART_250_GMIN_ART {
PASSIVE = 0, /** Passive value */
G1 = 1, /** target gear, lower limit = 1 */
G2 = 2, /** target gear, lower limit = 2 */
G3 = 3, /** target gear, lower limit = 3 */
G4 = 4, /** target gear, lower limit = 4 */
G5 = 5, /** target gear, lower limit = 5 */
G6 = 6, /** target gear, lower limit = 6 */
G7 = 7, /** target gear, lower limit = 7 */
};
enum class ART_250_GMAX_ART {
PASSIVE = 0, /** Passive value */
G1 = 1, /** target gear, upper limit = 1 */
G2 = 2, /** target gear, upper limit = 2 */
G3 = 3, /** target gear, upper limit = 3 */
G4 = 4, /** target gear, upper limit = 4 */
G5 = 5, /** target gear, upper limit = 5 */
G6 = 6, /** target gear, upper limit = 6 */
G7 = 7, /** target gear, upper limit = 7 */
};
typedef union {
uint8_t bytes[8];
uint64_t raw;
// Sets Suppression of dynamic full load downshift
void set_DYN_UNT(bool value){ raw = (raw & 0xfeffffffffffffff) | ((uint64_t)value & 0x1) << 56; }
// Gets Suppression of dynamic full load downshift
bool get_DYN_UNT() { return raw >> 56 & 0x1; }
// Sets brake light suppression
void set_BL_UNT(bool value){ raw = (raw & 0xfdffffffffffffff) | ((uint64_t)value & 0x1) << 57; }
// Gets brake light suppression
bool get_BL_UNT() { return raw >> 57 & 0x1; }
// Sets ART brakes
void set_ART_BRE(bool value){ raw = (raw & 0xfbffffffffffffff) | ((uint64_t)value & 0x1) << 58; }
// Gets ART brakes
bool get_ART_BRE() { return raw >> 58 & 0x1; }
// Sets ART ok
void set_ART_OK(bool value){ raw = (raw & 0xf7ffffffffffffff) | ((uint64_t)value & 0x1) << 59; }
// Gets ART ok
bool get_ART_OK() { return raw >> 59 & 0x1; }
// Sets switching line shift ART
void set_ART_250_SLV_ART(ART_250_SLV_ART value){ raw = (raw & 0x0fffffffffffffff) | ((uint64_t)value & 0xf) << 60; }
// Gets switching line shift ART
ART_250_SLV_ART get_SLV_ART() { return (ART_250_SLV_ART)(raw >> 60 & 0xf); }
// Sets Cityassistent regulates
void set_CAS_REG(bool value){ raw = (raw & 0xffdfffffffffffff) | ((uint64_t)value & 0x1) << 53; }
// Gets Cityassistent regulates
bool get_CAS_REG() { return raw >> 53 & 0x1; }
// Sets Motor torque request dynamic
void set_MDYN_ART(bool value){ raw = (raw & 0xffbfffffffffffff) | ((uint64_t)value & 0x1) << 54; }
// Gets Motor torque request dynamic
bool get_MDYN_ART() { return raw >> 54 & 0x1; }
// Sets Motor torque request parity (even parity)
void set_MPAR_ART(bool value){ raw = (raw & 0xff7fffffffffffff) | ((uint64_t)value & 0x1) << 55; }
// Gets Motor torque request parity (even parity)
bool get_MPAR_ART() { return raw >> 55 & 0x1; }
// Sets ART regulates
void set_ART_REG(bool value){ raw = (raw & 0xffffdfffffffffff) | ((uint64_t)value & 0x1) << 45; }
// Gets ART regulates
bool get_ART_REG() { return raw >> 45 & 0x1; }
// Sets Limiter controls
void set_LIM_REG(bool value){ raw = (raw & 0xffffbfffffffffff) | ((uint64_t)value & 0x1) << 46; }
// Gets Limiter controls
bool get_LIM_REG() { return raw >> 46 & 0x1; }
// Sets Required. Engine torque
void set_M_ART(short value){ raw = (raw & 0xffffe000ffffffff) | ((uint64_t)value & 0x1fff) << 32; }
// Gets Required. Engine torque
short get_M_ART() { return raw >> 32 & 0x1fff; }
// Sets message counter
void set_BZ250h(uint8_t value){ raw = (raw & 0xffffffff0fffffff) | ((uint64_t)value & 0xf) << 28; }
// Gets message counter
uint8_t get_BZ250h() { return raw >> 28 & 0xf; }
// Sets braking torque (0000h: passive value)
void set_MBRE_ART(short value){ raw = (raw & 0xfffffffff000ffff) | ((uint64_t)value & 0xfff) << 16; }
// Gets braking torque (0000h: passive value)
short get_MBRE_ART() { return raw >> 16 & 0xfff; }
// Sets target gear, lower limit
void set_ART_250_GMIN_ART(ART_250_GMIN_ART value){ raw = (raw & 0xfffffffffffff8ff) | ((uint64_t)value & 0x7) << 8; }
// Gets target gear, lower limit
ART_250_GMIN_ART get_GMIN_ART() { return (ART_250_GMIN_ART)(raw >> 8 & 0x7); }
// Sets target gear, upper limit
void set_ART_250_GMAX_ART(ART_250_GMAX_ART value){ raw = (raw & 0xffffffffffffc7ff) | ((uint64_t)value & 0x7) << 11; }
// Gets target gear, upper limit
ART_250_GMAX_ART get_GMAX_ART() { return (ART_250_GMAX_ART)(raw >> 11 & 0x7); }
// Sets ART request: "Active downshift"
void set_AKT_R_ART(bool value){ raw = (raw & 0xffffffffffff7fff) | ((uint64_t)value & 0x1) << 15; }
// Gets ART request: "Active downshift"
bool get_AKT_R_ART() { return raw >> 15 & 0x1; }
/** Imports the frame data from a source */
void import_frame(uint32_t cid, uint8_t* data, uint8_t len) {
if (cid == ART_250_ID) {
for (int i = 0; i < len; i++) {
bytes[7-i] = data[i];
}
}
}
/** Exports the frame data to a destination */
void export_frame(uint32_t* cid, uint8_t* data, uint8_t* len) {
*cid = ART_250_ID;
*len = 8;
for (int i = 0; i < *len; i++) {
data[i] = bytes[7-i];
}
}
} ART_250;
#endif

View File

@ -1,218 +0,0 @@
#ifndef ART_258_H_
#define ART_258_H_
/**
* AUTOGENERATED BY gen_unions.py
*/
#include <stdint.h>
#define ART_258_ID 0x0258
enum class ART_258_ART_ERR {
OK = 0, /** No error present */
DIRT = 1, /** ART disorder; Sensor dirty */
ART_DEF = 2, /** ART defective */
ART_LIM_DEF = 3, /** ART */
EXT = 4, /** ART; external fault */
DBC_DEF = 5, /** DBC defective */
SCHMUTZ_DBC_DEF = 6, /** ART disorder; Sensor dirty and DBC defective */
ART_DBC_DEF = 7, /** ART and DBC defective */
ART_LIM_DBC_DEF = 8, /** ART */
EXT_DBC = 9, /** ART external fault and DBC defective */
NOT_DEFINED = 15, /** undefined */
};
enum class ART_258_ASSIST_FKT_AKT {
OFF = 0, /** Off */
AAS = 1, /** Distance Assistant */
ADTR = 2, /** Advanced Distronic */
DBC = 3, /** Downhill Brake Control */
};
enum class ART_258_ASSIST_ANZ_V2 {
IDLE = 0, /** basic picture according to active bit */
DBC_LIM = 1, /** Message "Switch on DBC */
DBC_AUS = 2, /** Message "Switch off DBC" */
DBC_AUS_TON = 3, /** Message "switch off DBC" with sound */
DBC_NV_AKT = 4, /** Message "DBC incorrect operation */
DBC_NV_LIM = 5, /** Message "DBC incorrect operation */
AAS_EIN = 6, /** Message "Switch on AAS" */
AAS_AUS = 7, /** Message "Switch off AAS" */
AAS_AUS_TON = 8, /** Message "switch off AAS" with sound */
AAS_NV_LIM = 9, /** Message "AAS cannot be activated */
AAS_NV_OBJ = 10, /** Message "AAS cannot be activated */
AAS_NV_FBED = 11, /** Message "AAS incorrect operation */
AAS_FOLGEN = 12, /** Message "AAS target is starting */
AAS_OBJ_VERLUST = 13, /** Message "AAS object loss" */
AAS_OBJ_WECHSEL = 14, /** Message "AAS new object */
PAS_EIN = 15, /** Message "Switch on PAS */
PAS_AUS = 16, /** Message "Switch off PAS */
PAS_NV = 17, /** Message "PAS cannot be activated" */
};
enum class ART_258_CAS_ERR_ANZ_V2 {
IDLE = 0, /** no error */
CAS_SFV_REINIGEN = 1, /** CAS display "Clean front bumper" */
CAS_SFV_SFH_REINIGEN = 2, /** CAS display "Clean front and rear bumpers" */
CAS_ERR_W = 3, /** CAS display "visit workshop" */
};
typedef union {
uint8_t bytes[8];
uint64_t raw;
// Sets ART error code
void set_ART_258_ART_ERR(ART_258_ART_ERR value){ raw = (raw & 0xf0ffffffffffffff) | ((uint64_t)value & 0xf) << 56; }
// Gets ART error code
ART_258_ART_ERR get_ART_ERR() { return (ART_258_ART_ERR)(raw >> 56 & 0xf); }
// Sets ART info lamp
void set_ART_INFO(bool value){ raw = (raw & 0xefffffffffffffff) | ((uint64_t)value & 0x1) << 60; }
// Gets ART info lamp
bool get_ART_INFO() { return raw >> 60 & 0x1; }
// Sets ART warning tone
void set_ART_WT(bool value){ raw = (raw & 0xdfffffffffffffff) | ((uint64_t)value & 0x1) << 61; }
// Gets ART warning tone
bool get_ART_WT() { return raw >> 61 & 0x1; }
// Sets Detection of stationary object
void set_S_OBJ(bool value){ raw = (raw & 0xbfffffffffffffff) | ((uint64_t)value & 0x1) << 62; }
// Gets Detection of stationary object
bool get_S_OBJ() { return raw >> 62 & 0x1; }
// Sets Switch display to ART display
void set_ART_DSPL_EIN(bool value){ raw = (raw & 0x7fffffffffffffff) | ((uint64_t)value & 0x1) << 63; }
// Gets Switch display to ART display
bool get_ART_DSPL_EIN() { return raw >> 63 & 0x1; }
// Sets set ART speed
void set_V_ART(uint8_t value){ raw = (raw & 0xff00ffffffffffff) | ((uint64_t)value & 0xff) << 48; }
// Gets set ART speed
uint8_t get_V_ART() { return raw >> 48 & 0xff; }
// Sets Distance relevant object
void set_ABST_R_OBJ(uint8_t value){ raw = (raw & 0xffff00ffffffffff) | ((uint64_t)value & 0xff) << 40; }
// Gets Distance relevant object
uint8_t get_ABST_R_OBJ() { return raw >> 40 & 0xff; }
// Sets driver's desired distance
void set_SOLL_ABST(uint8_t value){ raw = (raw & 0xffffff00ffffffff) | ((uint64_t)value & 0xff) << 32; }
// Gets driver's desired distance
uint8_t get_SOLL_ABST() { return raw >> 32 & 0xff; }
// Sets ART-Tempomat switched on
void set_TM_EIN_ART(bool value){ raw = (raw & 0xfffffffffeffffff) | ((uint64_t)value & 0x1) << 24; }
// Gets ART-Tempomat switched on
bool get_TM_EIN_ART() { return raw >> 24 & 0x1; }
// Sets speed display flashing
void set_ART_DSPL_BL(bool value){ raw = (raw & 0xfffffffffdffffff) | ((uint64_t)value & 0x1) << 25; }
// Gets speed display flashing
bool get_ART_DSPL_BL() { return raw >> 25 & 0x1; }
// Sets Switch on ART segment display
void set_ART_SEG_EIN(bool value){ raw = (raw & 0xfffffffffbffffff) | ((uint64_t)value & 0x1) << 26; }
// Gets Switch on ART segment display
bool get_ART_SEG_EIN() { return raw >> 26 & 0x1; }
// Sets Relevant object recognized
void set_OBJ_ERK(bool value){ raw = (raw & 0xfffffffff7ffffff) | ((uint64_t)value & 0x1) << 27; }
// Gets Relevant object recognized
bool get_OBJ_ERK() { return raw >> 27 & 0x1; }
// Sets Adaptive cruise control switched on
void set_ART_EIN(bool value){ raw = (raw & 0xffffffffefffffff) | ((uint64_t)value & 0x1) << 28; }
// Gets Adaptive cruise control switched on
bool get_ART_EIN() { return raw >> 28 & 0x1; }
// Sets Indication "---" on the display
void set_ART_DSPL_LIM(bool value){ raw = (raw & 0xffffffffdfffffff) | ((uint64_t)value & 0x1) << 29; }
// Gets Indication "---" on the display
bool get_ART_DSPL_LIM() { return raw >> 29 & 0x1; }
// Sets Indication "DTR AUS [0]" on the display
void set_ART_VFBR(bool value){ raw = (raw & 0xffffffffbfffffff) | ((uint64_t)value & 0x1) << 30; }
// Gets Indication "DTR AUS [0]" on the display
bool get_ART_VFBR() { return raw >> 30 & 0x1; }
// Sets "Winter tire limit reached" on the display
void set_ART_DSPL_PGB(bool value){ raw = (raw & 0xffffffff7fffffff) | ((uint64_t)value & 0x1) << 31; }
// Gets "Winter tire limit reached" on the display
bool get_ART_DSPL_PGB() { return raw >> 31 & 0x1; }
// Sets speed of detected target vehicle
void set_V_ZIEL(uint8_t value){ raw = (raw & 0xffffffffff00ffff) | ((uint64_t)value & 0xff) << 16; }
// Gets speed of detected target vehicle
uint8_t get_V_ZIEL() { return raw >> 16 & 0xff; }
// Sets Active function
void set_ART_258_ASSIST_FKT_AKT(ART_258_ASSIST_FKT_AKT value){ raw = (raw & 0xfffffffffffffcff) | ((uint64_t)value & 0x3) << 8; }
// Gets Active function
ART_258_ASSIST_FKT_AKT get_ASSIST_FKT_AKT() { return (ART_258_ASSIST_FKT_AKT)(raw >> 8 & 0x3); }
// Sets LED distance assistant flash
void set_AAS_LED_BL(bool value){ raw = (raw & 0xfffffffffffffbff) | ((uint64_t)value & 0x1) << 10; }
// Gets LED distance assistant flash
bool get_AAS_LED_BL() { return raw >> 10 & 0x1; }
// Sets Object offer distance assistant
void set_OBJ_AGB(bool value){ raw = (raw & 0xfffffffffffff7ff) | ((uint64_t)value & 0x1) << 11; }
// Gets Object offer distance assistant
bool get_OBJ_AGB() { return raw >> 11 & 0x1; }
// Sets ART distance warning is switched on
void set_ART_ABW_AKT(bool value){ raw = (raw & 0xffffffffffffefff) | ((uint64_t)value & 0x1) << 12; }
// Gets ART distance warning is switched on
bool get_ART_ABW_AKT() { return raw >> 12 & 0x1; }
// Sets Display of the system availability after system errors
void set_ART_REAKT(bool value){ raw = (raw & 0xffffffffffffdfff) | ((uint64_t)value & 0x1) << 13; }
// Gets Display of the system availability after system errors
bool get_ART_REAKT() { return raw >> 13 & 0x1; }
// Sets ART is overridden by the driver
void set_ART_UEBERSP(bool value){ raw = (raw & 0xffffffffffffbfff) | ((uint64_t)value & 0x1) << 14; }
// Gets ART is overridden by the driver
bool get_ART_UEBERSP() { return raw >> 14 & 0x1; }
// Sets Re-trigger the minimum display time
void set_ART_DSPL_NEU(bool value){ raw = (raw & 0xffffffffffff7fff) | ((uint64_t)value & 0x1) << 15; }
// Gets Re-trigger the minimum display time
bool get_ART_DSPL_NEU() { return raw >> 15 & 0x1; }
// Sets assistance system display request
void set_ART_258_ASSIST_ANZ_V2(ART_258_ASSIST_ANZ_V2 value){ raw = (raw & 0xffffffffffffffe0) | ((uint64_t)value & 0x1f) << 0; }
// Gets assistance system display request
ART_258_ASSIST_ANZ_V2 get_ASSIST_ANZ_V2() { return (ART_258_ASSIST_ANZ_V2)(raw >> 0 & 0x1f); }
// Sets CAS display request
void set_ART_258_CAS_ERR_ANZ_V2(ART_258_CAS_ERR_ANZ_V2 value){ raw = (raw & 0xffffffffffffff1f) | ((uint64_t)value & 0x7) << 5; }
// Gets CAS display request
ART_258_CAS_ERR_ANZ_V2 get_CAS_ERR_ANZ_V2() { return (ART_258_CAS_ERR_ANZ_V2)(raw >> 5 & 0x7); }
/** Imports the frame data from a source */
void import_frame(uint32_t cid, uint8_t* data, uint8_t len) {
if (cid == ART_258_ID) {
for (int i = 0; i < len; i++) {
bytes[7-i] = data[i];
}
}
}
/** Exports the frame data to a destination */
void export_frame(uint32_t* cid, uint8_t* data, uint8_t* len) {
*cid = ART_258_ID;
*len = 8;
for (int i = 0; i < *len; i++) {
data[i] = bytes[7-i];
}
}
} ART_258;
#endif

View File

@ -1,89 +0,0 @@
#include "BaseECU.h"
#include <BS/BS_200.h>
#include <BS/BS_208.h>
#include <BS/BS_270.h>
#include <BS/BS_300.h>
class BS_ECU : public BaseECU {
public:
void clear_old_frames(uint64_t now) {
if (now - bs200_status.last_rx_timestamp > 250) { // every 25ms normally
bs200_status.is_valid = false;
}
if (now - bs208_status.last_rx_timestamp > 250) { // every 25ms normally
bs208_status.is_valid = false;
}
if (now - bs270_status.last_rx_timestamp > 250) { // every 25ms normally
bs270_status.is_valid = false;
}
if (now - bs300_status.last_rx_timestamp > 250) { // every 25ms normally
bs300_status.is_valid = false;
}
}
bool import_can_frame(can_message_t *f, uint64_t timestamp) {
switch (f->identifier) {
case BS_200_ID:
this->bs200.import_frame(f->identifier, f->data, f->data_length_code);
update_framestatus(&this->bs200_status, timestamp);
return true;
case BS_208_ID:
this->bs208.import_frame(f->identifier, f->data, f->data_length_code);
update_framestatus(&this->bs208_status, timestamp);
return true;
case BS_270_ID:
this->bs270.import_frame(f->identifier, f->data, f->data_length_code);
update_framestatus(&this->bs270_status, timestamp);
return true;
case BS_300_ID:
this->bs300.import_frame(f->identifier, f->data, f->data_length_code);
update_framestatus(&this->bs300_status, timestamp);
return true;
default:
return false;
}
}
BS_200* get_bs200() {
if (this->bs200_status.is_valid) {
return &this->bs200;
} else {
return nullptr;
}
}
BS_208* get_bs208() {
if (this->bs208_status.is_valid) {
return &this->bs208;
} else {
return nullptr;
}
}
BS_270* get_bs270() {
if (this->bs270_status.is_valid) {
return &this->bs270;
} else {
return nullptr;
}
}
BS_300* get_bs300() {
if (this->bs300_status.is_valid) {
return &this->bs300;
} else {
return nullptr;
}
}
private:
BS_200 bs200;
BS_208 bs208;
BS_270 bs270;
BS_300 bs300;
FrameStatus bs200_status;
FrameStatus bs208_status;
FrameStatus bs270_status;
FrameStatus bs300_status;
};

View File

@ -1,152 +0,0 @@
#ifndef BS_200_H_
#define BS_200_H_
/**
* AUTOGENERATED BY gen_unions.py
*/
#include <stdint.h>
#define BS_200_ID 0x0200
enum class BS_200_BLS {
BREMSE_NBET = 0, /** brake not applied */
BREMSE_BET = 1, /** brake applied */
NOT_DEFINED = 2, /** not defined */
SNV = 3, /** signal not available */
};
enum class BS_200_DRTGVL {
PASSIVE = 0, /** No direction of rotation detection */
FORWARD = 1, /** direction of rotation forward */
REVERSE = 2, /** direction of rotation backwards */
SNV = 3, /** signal not available */
};
enum class BS_200_DRTGVR {
PASSIVE = 0, /** No direction of rotation detection */
FORWARD = 1, /** direction of rotation forward */
REVERSE = 2, /** direction of rotation backwards */
SNV = 3, /** signal not available */
};
enum class BS_200_DRTGTM {
PASSIVE = 0, /** No direction of rotation detection */
FORWARD = 1, /** direction of rotation forward */
REVERSE = 2, /** direction of rotation backwards */
SNV = 3, /** signal not available */
};
typedef union {
uint8_t bytes[8];
uint64_t raw;
// Sets Brake pad wear indicator lamp
void set_BBV_KL(bool value){ raw = (raw & 0xfeffffffffffffff) | ((uint64_t)value & 0x1) << 56; }
// Gets Brake pad wear indicator lamp
bool get_BBV_KL() { return raw >> 56 & 0x1; }
// Sets ABS defective control lamp
void set_ABS_KL(bool value){ raw = (raw & 0xfbffffffffffffff) | ((uint64_t)value & 0x1) << 58; }
// Gets ABS defective control lamp
bool get_ABS_KL() { return raw >> 58 & 0x1; }
// Sets ESP defective control lamp
void set_ESP_KL(bool value){ raw = (raw & 0xf7ffffffffffffff) | ((uint64_t)value & 0x1) << 59; }
// Gets ESP defective control lamp
bool get_ESP_KL() { return raw >> 59 & 0x1; }
// Sets ESP info lamp steady light
void set_ESP_INFO_DL(bool value){ raw = (raw & 0xefffffffffffffff) | ((uint64_t)value & 0x1) << 60; }
// Gets ESP info lamp steady light
bool get_ESP_INFO_DL() { return raw >> 60 & 0x1; }
// Sets ESP info lamp flashing light
void set_ESP_INFO_BL(bool value){ raw = (raw & 0xdfffffffffffffff) | ((uint64_t)value & 0x1) << 61; }
// Gets ESP info lamp flashing light
bool get_ESP_INFO_BL() { return raw >> 61 & 0x1; }
// Sets BAS defective control lamp
void set_BAS_KL(bool value){ raw = (raw & 0xbfffffffffffffff) | ((uint64_t)value & 0x1) << 62; }
// Gets BAS defective control lamp
bool get_BAS_KL() { return raw >> 62 & 0x1; }
// Sets brake defective control lamp (EBV_KL at 463/461 / NCV2)
void set_BRE_KL(bool value){ raw = (raw & 0x7fffffffffffffff) | ((uint64_t)value & 0x1) << 63; }
// Gets brake defective control lamp (EBV_KL at 463/461 / NCV2)
bool get_BRE_KL() { return raw >> 63 & 0x1; }
// Sets brake light switch
void set_BS_200_BLS(BS_200_BLS value){ raw = (raw & 0xfffcffffffffffff) | ((uint64_t)value & 0x3) << 48; }
// Gets brake light switch
BS_200_BLS get_BLS() { return (BS_200_BLS)(raw >> 48 & 0x3); }
// Sets message counter
void set_BZ200h(uint8_t value){ raw = (raw & 0xffc3ffffffffffff) | ((uint64_t)value & 0xf) << 50; }
// Gets message counter
uint8_t get_BZ200h() { return raw >> 50 & 0xf; }
// Sets BLS Parity (even parity)
void set_BLS_PA(bool value){ raw = (raw & 0xffbfffffffffffff) | ((uint64_t)value & 0x1) << 54; }
// Gets BLS Parity (even parity)
bool get_BLS_PA() { return raw >> 54 & 0x1; }
// Sets brake light suppression (EBV_KL at 163 / T0 / T1N)
void set_BLS_UNT(bool value){ raw = (raw & 0xff7fffffffffffff) | ((uint64_t)value & 0x1) << 55; }
// Gets brake light suppression (EBV_KL at 163 / T0 / T1N)
bool get_BLS_UNT() { return raw >> 55 & 0x1; }
// Sets direction of rotation of front left wheel
void set_BS_200_DRTGVL(BS_200_DRTGVL value){ raw = (raw & 0xffff3fffffffffff) | ((uint64_t)value & 0x3) << 46; }
// Gets direction of rotation of front left wheel
BS_200_DRTGVL get_DRTGVL() { return (BS_200_DRTGVL)(raw >> 46 & 0x3); }
// Sets wheel speed front left
void set_DVL(short value){ raw = (raw & 0xffffc000ffffffff) | ((uint64_t)value & 0x3fff) << 32; }
// Gets wheel speed front left
short get_DVL() { return raw >> 32 & 0x3fff; }
// Sets direction of rotation of the front right wheel
void set_BS_200_DRTGVR(BS_200_DRTGVR value){ raw = (raw & 0xffffffff3fffffff) | ((uint64_t)value & 0x3) << 30; }
// Gets direction of rotation of the front right wheel
BS_200_DRTGVR get_DRTGVR() { return (BS_200_DRTGVR)(raw >> 30 & 0x3); }
// Sets wheel speed front right
void set_DVR(short value){ raw = (raw & 0xffffffffc000ffff) | ((uint64_t)value & 0x3fff) << 16; }
// Gets wheel speed front right
short get_DVR() { return raw >> 16 & 0x3fff; }
// Sets direction of rotation wheel left for cruise control
void set_BS_200_DRTGTM(BS_200_DRTGTM value){ raw = (raw & 0xffffffffffff3fff) | ((uint64_t)value & 0x3) << 14; }
// Gets direction of rotation wheel left for cruise control
BS_200_DRTGTM get_DRTGTM() { return (BS_200_DRTGTM)(raw >> 14 & 0x3); }
// Sets Left wheel speed for cruise control
void set_TM_DL(short value){ raw = (raw & 0xffffffffffffc000) | ((uint64_t)value & 0x3fff) << 0; }
// Gets Left wheel speed for cruise control
short get_TM_DL() { return raw >> 0 & 0x3fff; }
/** Imports the frame data from a source */
void import_frame(uint32_t cid, uint8_t* data, uint8_t len) {
if (cid == BS_200_ID) {
for (int i = 0; i < len; i++) {
bytes[7-i] = data[i];
}
}
}
/** Exports the frame data to a destination */
void export_frame(uint32_t* cid, uint8_t* data, uint8_t* len) {
*cid = BS_200_ID;
*len = 8;
for (int i = 0; i < *len; i++) {
data[i] = bytes[7-i];
}
}
} BS_200;
#endif

View File

@ -1,183 +0,0 @@
#ifndef BS_208_H_
#define BS_208_H_
/**
* AUTOGENERATED BY gen_unions.py
*/
#include <stdint.h>
#define BS_208_ID 0x0208
enum class BS_208_GMIN_ESP {
PASSIVE = 0, /** Passive value */
G1 = 1, /** target gear, lower limit = 1 */
G2 = 2, /** target gear, lower limit = 2 */
G3 = 3, /** target gear, lower limit = 3 */
G4 = 4, /** target gear, lower limit = 4 */
G5 = 5, /** target gear, lower limit = 5 */
G6 = 6, /** target gear, lower limit = 6 */
G7 = 7, /** target gear, lower limit = 7 */
};
enum class BS_208_GMAX_ESP {
PASSIVE = 0, /** Passive value */
G1 = 1, /** target gear, upper limit = 1 */
G2 = 2, /** target gear, upper limit = 2 */
G3 = 3, /** target gear, upper limit = 3 */
G4 = 4, /** target gear, upper limit = 4 */
G5 = 5, /** target gear, upper limit = 5 */
G6 = 6, /** target gear, upper limit = 6 */
G7 = 7, /** target gear, upper limit = 7 */
};
enum class BS_208_SLV_ESP {
SKL0 = 0, /** switching characteristic "0" */
SKL1 = 1, /** switching characteristic "1" */
SKL2 = 2, /** switching characteristic "2" */
SKL3 = 3, /** switching characteristic "3" */
SKL4 = 4, /** switching characteristic "4" */
SKL5 = 5, /** switching characteristic "5" */
SKL6 = 6, /** switching characteristic "6" */
SKL7 = 7, /** switching characteristic "7" */
SKL8 = 8, /** switching characteristic "8" */
SKL9 = 9, /** switching characteristic "9" */
SKL10 = 10, /** switching characteristic "10" */
};
enum class BS_208_SZS {
ERR_DIAG = 0, /** system error or diagnosis */
NORM = 1, /** normal operation */
NOT_DEFINED = 2, /** not defined */
EXHAUST = 3, /** Emissions test */
};
enum class BS_208_ANFN {
NOT_DEFINED = 0, /** not defined */
ANF_N = 1, /** "Neutral" request */
IDLE = 2, /** No requirement */
SNV = 3, /** signal not available */
};
enum class BS_208_DRTGHR {
PASSIVE = 0, /** No direction of rotation detection */
FORWARD = 1, /** direction of rotation forward */
REVERSE = 2, /** direction of rotation backwards */
SNV = 3, /** signal not available */
};
enum class BS_208_DRTGHL {
PASSIVE = 0, /** No direction of rotation detection */
FORWARD = 1, /** direction of rotation forward */
REVERSE = 2, /** direction of rotation backwards */
SNV = 3, /** signal not available */
};
typedef union {
uint8_t bytes[8];
uint64_t raw;
// Sets target gear, lower limit
void set_BS_208_GMIN_ESP(BS_208_GMIN_ESP value){ raw = (raw & 0xf8ffffffffffffff) | ((uint64_t)value & 0x7) << 56; }
// Gets target gear, lower limit
BS_208_GMIN_ESP get_GMIN_ESP() { return (BS_208_GMIN_ESP)(raw >> 56 & 0x7); }
// Sets target gear, upper limit
void set_BS_208_GMAX_ESP(BS_208_GMAX_ESP value){ raw = (raw & 0xc7ffffffffffffff) | ((uint64_t)value & 0x7) << 59; }
// Gets target gear, upper limit
BS_208_GMAX_ESP get_GMAX_ESP() { return (BS_208_GMAX_ESP)(raw >> 59 & 0x7); }
// Sets Target gear request from ART
void set_MINMAX_ART(bool value){ raw = (raw & 0xbfffffffffffffff) | ((uint64_t)value & 0x1) << 62; }
// Gets Target gear request from ART
bool get_MINMAX_ART() { return raw >> 62 & 0x1; }
// Sets ESP / ART request: "Active downshift"
void set_AKT_R_ESP(bool value){ raw = (raw & 0x7fffffffffffffff) | ((uint64_t)value & 0x1) << 63; }
// Gets ESP / ART request: "Active downshift"
bool get_AKT_R_ESP() { return raw >> 63 & 0x1; }
// Sets switching line shift ESP
void set_BS_208_SLV_ESP(BS_208_SLV_ESP value){ raw = (raw & 0xfff0ffffffffffff) | ((uint64_t)value & 0xf) << 48; }
// Gets switching line shift ESP
BS_208_SLV_ESP get_SLV_ESP() { return (BS_208_SLV_ESP)(raw >> 48 & 0xf); }
// Sets Cruise control mode off
void set_TM_AUS(bool value){ raw = (raw & 0xffefffffffffffff) | ((uint64_t)value & 0x1) << 52; }
// Gets Cruise control mode off
bool get_TM_AUS() { return raw >> 52 & 0x1; }
// Sets system status
void set_BS_208_SZS(BS_208_SZS value){ raw = (raw & 0xff9fffffffffffff) | ((uint64_t)value & 0x3) << 53; }
// Gets system status
BS_208_SZS get_SZS() { return (BS_208_SZS)(raw >> 53 & 0x3); }
// Sets Suppression of dynamic full load downshift
void set_DDYN_UNT(bool value){ raw = (raw & 0xff7fffffffffffff) | ((uint64_t)value & 0x1) << 55; }
// Gets Suppression of dynamic full load downshift
bool get_DDYN_UNT() { return raw >> 55 & 0x1; }
// Sets ART brake intervention active
void set_BRE_AKT_ART(bool value){ raw = (raw & 0xffffefffffffffff) | ((uint64_t)value & 0x1) << 44; }
// Gets ART brake intervention active
bool get_BRE_AKT_ART() { return raw >> 44 & 0x1; }
// Sets ESP request: insert "N"
void set_BS_208_ANFN(BS_208_ANFN value){ raw = (raw & 0xffff9fffffffffff) | ((uint64_t)value & 0x3) << 45; }
// Gets ESP request: insert "N"
BS_208_ANFN get_ANFN() { return (BS_208_ANFN)(raw >> 45 & 0x3); }
// Sets ESP brake intervention active
void set_BRE_AKT_ESP(bool value){ raw = (raw & 0xffff7fffffffffff) | ((uint64_t)value & 0x1) << 47; }
// Gets ESP brake intervention active
bool get_BRE_AKT_ESP() { return raw >> 47 & 0x1; }
// Sets Set braking torque (BR240 factor 1.8 greater)
void set_MBRE_ESP(short value){ raw = (raw & 0xfffff000ffffffff) | ((uint64_t)value & 0xfff) << 32; }
// Gets Set braking torque (BR240 factor 1.8 greater)
short get_MBRE_ESP() { return raw >> 32 & 0xfff; }
// Sets direction of rotation of rear wheel right
void set_BS_208_DRTGHR(BS_208_DRTGHR value){ raw = (raw & 0xffffffff3fffffff) | ((uint64_t)value & 0x3) << 30; }
// Gets direction of rotation of rear wheel right
BS_208_DRTGHR get_DRTGHR() { return (BS_208_DRTGHR)(raw >> 30 & 0x3); }
// Sets wheel speed rear right
void set_DHR(short value){ raw = (raw & 0xffffffffc000ffff) | ((uint64_t)value & 0x3fff) << 16; }
// Gets wheel speed rear right
short get_DHR() { return raw >> 16 & 0x3fff; }
// Sets direction of rotation of rear left wheel
void set_BS_208_DRTGHL(BS_208_DRTGHL value){ raw = (raw & 0xffffffffffff3fff) | ((uint64_t)value & 0x3) << 14; }
// Gets direction of rotation of rear left wheel
BS_208_DRTGHL get_DRTGHL() { return (BS_208_DRTGHL)(raw >> 14 & 0x3); }
// Sets rear left wheel speed
void set_DHL(short value){ raw = (raw & 0xffffffffffffc000) | ((uint64_t)value & 0x3fff) << 0; }
// Gets rear left wheel speed
short get_DHL() { return raw >> 0 & 0x3fff; }
/** Imports the frame data from a source */
void import_frame(uint32_t cid, uint8_t* data, uint8_t len) {
if (cid == BS_208_ID) {
for (int i = 0; i < len; i++) {
bytes[7-i] = data[i];
}
}
}
/** Exports the frame data to a destination */
void export_frame(uint32_t* cid, uint8_t* data, uint8_t* len) {
*cid = BS_208_ID;
*len = 8;
for (int i = 0; i < *len; i++) {
data[i] = bytes[7-i];
}
}
} BS_208;
#endif

View File

@ -1,84 +0,0 @@
#ifndef BS_270_H_
#define BS_270_H_
/**
* AUTOGENERATED BY gen_unions.py
*/
#include <stdint.h>
#define BS_270_ID 0x0270
enum class BS_270_PRW_ST {
ON = 0, /** PRW active, no warning */
WARN = 1, /** PRW active, there is a warning */
OFF = 2, /** PRW inactive or not available */
INIT = 3, /** PRW is initialized */
NOT_DEFINED_0 = 4, /** not defined */
NOT_DEFINED_1 = 5, /** not defined */
PRW_NV = 6, /** PRW not available */
SNV = 7, /** signal not available */
};
enum class BS_270_PRW_WARN {
OK = 0, /** no warning */
WARN_OHNE = 1, /** tire pressure warning without position information */
PRW_NV = 2, /** PRW not available */
PRW_START = 3, /** restart PRW */
WARN_VL = 4, /** tire pressure warning front left */
WARN_VR = 5, /** tire pressure warning front right */
WARN_HL = 6, /** rear left tire pressure warning */
WARN_HR = 7, /** Rear right tire pressure warning */
NOT_DEFINED_0 = 8, /** not defined */
NOT_DEFINED_1 = 14, /** undefined */
SNV = 15, /** signal not available */
};
typedef union {
uint8_t bytes[8];
uint64_t raw;
// Sets Pulse ring counter, rear left wheel (48 per revolution)
void set_RIZ_HL(uint8_t value){ raw = (raw & 0x00ffffffffffffff) | ((uint64_t)value & 0xff) << 56; }
// Gets Pulse ring counter, rear left wheel (48 per revolution)
uint8_t get_RIZ_HL() { return raw >> 56 & 0xff; }
// Sets Pulse ring counter, rear right wheel (48 per revolution)
void set_RIZ_HR(uint8_t value){ raw = (raw & 0xff00ffffffffffff) | ((uint64_t)value & 0xff) << 48; }
// Gets Pulse ring counter, rear right wheel (48 per revolution)
uint8_t get_RIZ_HR() { return raw >> 48 & 0xff; }
// Sets Flat roll warning status
void set_BS_270_PRW_ST(BS_270_PRW_ST value){ raw = (raw & 0xfffff8ffffffffff) | ((uint64_t)value & 0x7) << 40; }
// Gets Flat roll warning status
BS_270_PRW_ST get_PRW_ST() { return (BS_270_PRW_ST)(raw >> 40 & 0x7); }
// Sets Warning messages flat roll warner
void set_BS_270_PRW_WARN(BS_270_PRW_WARN value){ raw = (raw & 0xffff0fffffffffff) | ((uint64_t)value & 0xf) << 44; }
// Gets Warning messages flat roll warner
BS_270_PRW_WARN get_PRW_WARN() { return (BS_270_PRW_WARN)(raw >> 44 & 0xf); }
/** Imports the frame data from a source */
void import_frame(uint32_t cid, uint8_t* data, uint8_t len) {
if (cid == BS_270_ID) {
for (int i = 0; i < len; i++) {
bytes[7-i] = data[i];
}
}
}
/** Exports the frame data to a destination */
void export_frame(uint32_t* cid, uint8_t* data, uint8_t* len) {
*cid = BS_270_ID;
*len = 8;
for (int i = 0; i < *len; i++) {
data[i] = bytes[7-i];
}
}
} BS_270;
#endif

View File

@ -1,168 +0,0 @@
#ifndef BS_300_H_
#define BS_300_H_
/**
* AUTOGENERATED BY gen_unions.py
*/
#include <stdint.h>
#define BS_300_ID 0x0300
enum class BS_300_SFB {
BRAKE_NO = 0, /** driver does not brake */
BREMSE_YES = 1, /** driver brakes */
NOT_DEFINED = 2, /** not defined */
SNV = 3, /** signal not available */
};
enum class BS_300_T_Z {
NOT_DEFINED = 0, /** not defined */
T20_0 = 1, /** transmission cycle time 20 ms */
T23_1 = 2, /** transmission cycle time 23.1 ms */
SNV = 3, /** signal not available */
};
typedef union {
uint8_t bytes[8];
uint64_t raw;
// Sets Steering angle sensor initialization possible
void set_LWS_INI_EIN(bool value){ raw = (raw & 0xfeffffffffffffff) | ((uint64_t)value & 0x1) << 56; }
// Gets Steering angle sensor initialization possible
bool get_LWS_INI_EIN() { return raw >> 56 & 0x1; }
// Sets Initialization of steering angle sensor o.k.
void set_LWS_INI_OK(bool value){ raw = (raw & 0xfdffffffffffffff) | ((uint64_t)value & 0x1) << 57; }
// Gets Initialization of steering angle sensor o.k.
bool get_LWS_INI_OK() { return raw >> 57 & 0x1; }
// Sets ESP yaw moment control active
void set_ESP_GIER_AKT(bool value){ raw = (raw & 0xfbffffffffffffff) | ((uint64_t)value & 0x1) << 58; }
// Gets ESP yaw moment control active
bool get_ESP_GIER_AKT() { return raw >> 58 & 0x1; }
// Sets Enable ART
void set_ART_E(bool value){ raw = (raw & 0xf7ffffffffffffff) | ((uint64_t)value & 0x1) << 59; }
// Gets Enable ART
bool get_ART_E() { return raw >> 59 & 0x1; }
// Sets Full braking (ABS controls all 4 wheels)
void set_VOLLBRE(bool value){ raw = (raw & 0xefffffffffffffff) | ((uint64_t)value & 0x1) << 60; }
// Gets Full braking (ABS controls all 4 wheels)
bool get_VOLLBRE() { return raw >> 60 & 0x1; }
// Sets BAS control active
void set_BAS_AKT(bool value){ raw = (raw & 0xdfffffffffffffff) | ((uint64_t)value & 0x1) << 61; }
// Gets BAS control active
bool get_BAS_AKT() { return raw >> 61 & 0x1; }
// Sets Dynamic engine torque request
void set_DMDYN_ART(bool value){ raw = (raw & 0xbfffffffffffffff) | ((uint64_t)value & 0x1) << 62; }
// Gets Dynamic engine torque request
bool get_DMDYN_ART() { return raw >> 62 & 0x1; }
// Sets Motor torque request parity (even parity)
void set_DMPAR_ART(bool value){ raw = (raw & 0x7fffffffffffffff) | ((uint64_t)value & 0x1) << 63; }
// Gets Motor torque request parity (even parity)
bool get_DMPAR_ART() { return raw >> 63 & 0x1; }
// Sets driver brakes
void set_BS_300_SFB(BS_300_SFB value){ raw = (raw & 0xfffcffffffffffff) | ((uint64_t)value & 0x3) << 48; }
// Gets driver brakes
BS_300_SFB get_SFB() { return (BS_300_SFB)(raw >> 48 & 0x3); }
// Sets driver brakes parity (even parity)
void set_SFB_PA(bool value){ raw = (raw & 0xfffbffffffffffff) | ((uint64_t)value & 0x1) << 50; }
// Gets driver brakes parity (even parity)
bool get_SFB_PA() { return raw >> 50 & 0x1; }
// Sets transmission cycle time
void set_BS_300_T_Z(BS_300_T_Z value){ raw = (raw & 0xffe7ffffffffffff) | ((uint64_t)value & 0x3) << 51; }
// Gets transmission cycle time
BS_300_T_Z get_T_Z() { return (BS_300_T_Z)(raw >> 51 & 0x3); }
// Sets drive torque control active
void set_AMR_AKT_ESP(bool value){ raw = (raw & 0xffdfffffffffffff) | ((uint64_t)value & 0x1) << 53; }
// Gets drive torque control active
bool get_AMR_AKT_ESP() { return raw >> 53 & 0x1; }
// Sets Dynamic motor torque request
void set_MDYN_ESP(bool value){ raw = (raw & 0xffbfffffffffffff) | ((uint64_t)value & 0x1) << 54; }
// Gets Dynamic motor torque request
bool get_MDYN_ESP() { return raw >> 54 & 0x1; }
// Sets Motor torque request parity (even parity)
void set_MPAR_ESP(bool value){ raw = (raw & 0xff7fffffffffffff) | ((uint64_t)value & 0x1) << 55; }
// Gets Motor torque request parity (even parity)
bool get_MPAR_ESP() { return raw >> 55 & 0x1; }
// Sets Motor torque request Max
void set_DMMAX_ART(bool value){ raw = (raw & 0xffffdfffffffffff) | ((uint64_t)value & 0x1) << 45; }
// Gets Motor torque request Max
bool get_DMMAX_ART() { return raw >> 45 & 0x1; }
// Sets engine torque request min
void set_DMMIN_ART(bool value){ raw = (raw & 0xffffbfffffffffff) | ((uint64_t)value & 0x1) << 46; }
// Gets engine torque request min
bool get_DMMIN_ART() { return raw >> 46 & 0x1; }
// Sets engine torque request. Toggle 40ms + -10
void set_DMTGL_ART(bool value){ raw = (raw & 0xffff7fffffffffff) | ((uint64_t)value & 0x1) << 47; }
// Gets engine torque request. Toggle 40ms + -10
bool get_DMTGL_ART() { return raw >> 47 & 0x1; }
// Sets Required. Engine torque
void set_DM_ART(short value){ raw = (raw & 0xffffe000ffffffff) | ((uint64_t)value & 0x1fff) << 32; }
// Gets Required. Engine torque
short get_DM_ART() { return raw >> 32 & 0x1fff; }
// Sets Motor torque request Max
void set_MMAX_ESP(bool value){ raw = (raw & 0xffffffffdfffffff) | ((uint64_t)value & 0x1) << 29; }
// Gets Motor torque request Max
bool get_MMAX_ESP() { return raw >> 29 & 0x1; }
// Sets Motor torque request Min
void set_MMIN_ESP(bool value){ raw = (raw & 0xffffffffbfffffff) | ((uint64_t)value & 0x1) << 30; }
// Gets Motor torque request Min
bool get_MMIN_ESP() { return raw >> 30 & 0x1; }
// Sets motor torque request. Toggle 40ms + -10
void set_MTGL_ESP(bool value){ raw = (raw & 0xffffffff7fffffff) | ((uint64_t)value & 0x1) << 31; }
// Gets motor torque request. Toggle 40ms + -10
bool get_MTGL_ESP() { return raw >> 31 & 0x1; }
// Sets Required. Engine torque
void set_M_ESP(short value){ raw = (raw & 0xffffffffe000ffff) | ((uint64_t)value & 0x1fff) << 16; }
// Gets Required. Engine torque
short get_M_ESP() { return raw >> 16 & 0x1fff; }
// Sets Raw signal yaw rate without adjustment / filtering (+ = left)
void set_GIER_ROH(short value){ raw = (raw & 0xffffffffffff0000) | ((uint64_t)value & 0xffff) << 0; }
// Gets Raw signal yaw rate without adjustment / filtering (+ = left)
short get_GIER_ROH() { return raw >> 0 & 0xffff; }
/** Imports the frame data from a source */
void import_frame(uint32_t cid, uint8_t* data, uint8_t len) {
if (cid == BS_300_ID) {
for (int i = 0; i < len; i++) {
bytes[7-i] = data[i];
}
}
}
/** Exports the frame data to a destination */
void export_frame(uint32_t* cid, uint8_t* data, uint8_t* len) {
*cid = BS_300_ID;
*len = 8;
for (int i = 0; i < *len; i++) {
data[i] = bytes[7-i];
}
}
} BS_300;
#endif

View File

@ -1,43 +0,0 @@
#ifndef __BASE_ECU_H_
#define __BASE_ECU_H_
#include <driver/can.h>
/**
* Abstracted layer for all ECUs that will be talking to EGS52
*/
struct FrameStatus {
uint64_t last_rx_timestamp;
bool is_valid;
};
inline void update_framestatus(FrameStatus* status, uint64_t rx_timestamp) {
status->last_rx_timestamp = rx_timestamp;
status->is_valid = true;
}
class BaseECU {
public:
/**
* This function will clear expired CAN frames from the ECU.
* This is so that if the ECU stops transmitting data over CANBUS,
* EGS52 can identify this and throw the correct DTC about data not
* being received over CANBUS, rather than constantly using the last
* CAN Frame
*/
virtual void clear_old_frames(uint64_t now);
/**
* This functions imports a frame from CAN bus using the frames ID and timestamp (The time now)
*
* Returns true if the frame is for THIS ECU, meaning the CAN class can stop trying insert it to other ECUs.
*/
virtual bool import_can_frame(can_message_t *f, uint64_t timestamp);
};
#endif

View File

@ -1,38 +0,0 @@
#include "BaseECU.h"
#include <EWM/EWM_230.h>
class EWM_ECU : public BaseECU {
public:
EWM_ECU() {
this->ewm230.raw = 0x00000000;
this->ewm230_status.is_valid = false;
}
void clear_old_frames(uint64_t now) {
if (now - ewm230_status.last_rx_timestamp > 250) { // every 25ms normally
ewm230_status.is_valid = false;
}
}
bool import_can_frame(can_message_t *f, uint64_t timestamp) {
switch (f->identifier) {
case EWM_230_ID:
this->ewm230.import_frame(f->identifier, f->data, f->data_length_code);
update_framestatus(&this->ewm230_status, timestamp);
return true;
default:
return false;
}
}
EWM_230* get_ewm230() {
if (this->ewm230_status.is_valid) {
return &this->ewm230;
} else {
return nullptr;
}
}
private:
EWM_230 ewm230;
FrameStatus ewm230_status;
};

View File

@ -1,77 +0,0 @@
#ifndef EWM_230_H_
#define EWM_230_H_
/**
* AUTOGENERATED BY gen_unions.py
*/
#include <stdint.h>
#define EWM_230_ID 0x0230
enum class EWM_230_WHC {
D = 5, /** Selector lever in position "D" */
N = 6, /** Selector lever in position "N" */
R = 7, /** Selector lever in position "R" */
P = 8, /** Selector lever in position "P" */
PLUS = 9, /** Selector lever in position "+" */
MINUS = 10, /** Selector lever in position "-" */
N_ZW_D = 11, /** Selector lever in intermediate position "N-D" */
R_ZW_N = 12, /** Selector lever in intermediate position "R-N" */
P_ZW_R = 13, /** Selector lever in intermediate position "P-R" */
SNV = 15, /** Selector lever position implausible */
};
typedef union {
uint8_t bytes[8];
uint64_t raw;
// Sets gear selector lever position (only NAG)
void set_EWM_230_WHC(EWM_230_WHC value){ raw = (raw & 0xf0ffffffffffffff) | ((uint64_t)value & 0xf) << 56; }
// Gets gear selector lever position (only NAG)
EWM_230_WHC get_WHC() { return (EWM_230_WHC)(raw >> 56 & 0xf); }
// Sets Locking magnet energized
void set_LOCKING(bool value){ raw = (raw & 0xefffffffffffffff) | ((uint64_t)value & 0x1) << 60; }
// Gets Locking magnet energized
bool get_LOCKING() { return raw >> 60 & 0x1; }
// Sets kickdown
void set_KD(bool value){ raw = (raw & 0xdfffffffffffffff) | ((uint64_t)value & 0x1) << 61; }
// Gets kickdown
bool get_KD() { return raw >> 61 & 0x1; }
// Sets Drive program button pressed
void set_FPT(bool value){ raw = (raw & 0xbfffffffffffffff) | ((uint64_t)value & 0x1) << 62; }
// Gets Drive program button pressed
bool get_FPT() { return raw >> 62 & 0x1; }
// Sets drive program
void set_W_S(bool value){ raw = (raw & 0x7fffffffffffffff) | ((uint64_t)value & 0x1) << 63; }
// Gets drive program
bool get_W_S() { return raw >> 63 & 0x1; }
/** Imports the frame data from a source */
void import_frame(uint32_t cid, uint8_t* data, uint8_t len) {
if (cid == EWM_230_ID) {
for (int i = 0; i < len; i++) {
bytes[7-i] = data[i];
}
}
}
/** Exports the frame data to a destination */
void export_frame(uint32_t* cid, uint8_t* data, uint8_t* len) {
*cid = EWM_230_ID;
*len = 8;
for (int i = 0; i < *len; i++) {
data[i] = bytes[7-i];
}
}
} EWM_230;
#endif

View File

@ -1,262 +0,0 @@
#ifndef EZS_240_H_
#define EZS_240_H_
/**
* AUTOGENERATED BY gen_unions.py
*/
#include <stdint.h>
#define EZS_240_ID 0x0240
enum class EZS_240_LL_RLC {
NOT_DEFINED = 0, /** not defined */
LL = 1, /** left hand drive */
RL = 2, /** right hand drive */
SNV = 3, /** code does not exist */
};
enum class EZS_240_ESP_BET {
NBET = 0, /** Not pressed (rocker and push push) */
AUS_BET = 1, /** ESP off actuated (rocker), actuated (Push Push) */
EIN_NDEF = 2, /** ESP on actuated (rocker), not defined (push push) */
SNV = 3, /** signal not available (rocker and push push) */
};
enum class EZS_240_ART_ABW_BET {
NDEF_NBET = 0, /** not defined (rocker), not actuated (push push) */
AUS_NDEF = 1, /** Distance warning off (rocker), not defined (Push Push) */
ON_BET = 2, /** Distance warning on (rocker), activated (Push Push) */
SNV = 3, /** signal not available (rocker and push push) */
};
enum class EZS_240_ST3_BET {
NBET = 0, /** Not pressed (rocker and push push) */
UNBET_NDEF = 1, /** Pressed down (rocker), not defined (Push Push) */
OBBET_BET = 2, /** Pressed at the top (rocker), pressed (Push Push) */
NOT_DEFINED = 3, /** Not defined (rocker and push push) */
};
enum class EZS_240_ST2_BET {
NBET = 0, /** Not pressed (rocker and push push) */
UNBET_NDEF = 1, /** Pressed down (rocker), not defined (Push Push) */
OBBET_BET = 2, /** Pressed at the top (rocker), pressed (Push Push) */
NOT_DEFINED = 3, /** Not defined (rocker and push push) */
};
enum class EZS_240_LDC {
RDW = 0, /** rest of the world */
USA_CAN = 1, /** USA */
NOT_DEFINED = 2, /** not defined */
SNV = 3, /** code does not exist */
};
enum class EZS_240_FZGVERSN {
START_LAUNCHED = 0, /** Status when the respective series */
V1 = 1, /** BR 220: AJ 99 */
V2 = 2, /** BR 220: AJ 01/1, C215: AJ 02 */
V3 = 3, /** BR 220: ÄJ 02 */
V4 = 4, /** BR 220: prohibited, C215 */
V5 = 5, /** BR 220: prohibited, C215 */
V6 = 6, /** BR 220: ÄJ 03 */
V7 = 7, /** BR 220 */
};
typedef union {
uint8_t bytes[8];
uint64_t raw;
// Sets Cruise control lever: "Switch off"
void set_OFF(bool value){ raw = (raw & 0xfeffffffffffffff) | ((uint64_t)value & 0x1) << 56; }
// Gets Cruise control lever: "Switch off"
bool get_OFF() { return raw >> 56 & 0x1; }
// Sets Cruise control lever: "Resume"
void set_WA(bool value){ raw = (raw & 0xfdffffffffffffff) | ((uint64_t)value & 0x1) << 57; }
// Gets Cruise control lever: "Resume"
bool get_WA() { return raw >> 57 & 0x1; }
// Sets Cruise control lever: "Set and accelerate level0"
void set_S_PLUS_B(bool value){ raw = (raw & 0xfbffffffffffffff) | ((uint64_t)value & 0x1) << 58; }
// Gets Cruise control lever: "Set and accelerate level0"
bool get_S_PLUS_B() { return raw >> 58 & 0x1; }
// Sets Cruise control lever: "Set and decelerate level0"
void set_S_MINUS_B(bool value){ raw = (raw & 0xf7ffffffffffffff) | ((uint64_t)value & 0x1) << 59; }
// Gets Cruise control lever: "Set and decelerate level0"
bool get_S_MINUS_B() { return raw >> 59 & 0x1; }
// Sets Operation variable speed limit
void set_VMAX_AKT(bool value){ raw = (raw & 0xefffffffffffffff) | ((uint64_t)value & 0x1) << 60; }
// Gets Operation variable speed limit
bool get_VMAX_AKT() { return raw >> 60 & 0x1; }
// Sets Cruise control lever implausible
void set_WH_UP(bool value){ raw = (raw & 0xdfffffffffffffff) | ((uint64_t)value & 0x1) << 61; }
// Gets Cruise control lever implausible
bool get_WH_UP() { return raw >> 61 & 0x1; }
// Sets Terminal 50
void set_KL_50(bool value){ raw = (raw & 0xfffeffffffffffff) | ((uint64_t)value & 0x1) << 48; }
// Gets Terminal 50
bool get_KL_50() { return raw >> 48 & 0x1; }
// Sets Terminal 15
void set_KL_15(bool value){ raw = (raw & 0xfffdffffffffffff) | ((uint64_t)value & 0x1) << 49; }
// Gets Terminal 15
bool get_KL_15() { return raw >> 49 & 0x1; }
// Sets brake switch for shift lock
void set_BS_SL(bool value){ raw = (raw & 0xfffbffffffffffff) | ((uint64_t)value & 0x1) << 50; }
// Gets brake switch for shift lock
bool get_BS_SL() { return raw >> 50 & 0x1; }
// Sets reverse gear engaged (only manual transmission)
void set_RG_SCHALT(bool value){ raw = (raw & 0xfff7ffffffffffff) | ((uint64_t)value & 0x1) << 51; }
// Gets reverse gear engaged (only manual transmission)
bool get_RG_SCHALT() { return raw >> 51 & 0x1; }
// Sets left-hand drive / right-hand drive
void set_EZS_240_LL_RLC(EZS_240_LL_RLC value){ raw = (raw & 0xffcfffffffffffff) | ((uint64_t)value & 0x3) << 52; }
// Gets left-hand drive / right-hand drive
EZS_240_LL_RLC get_LL_RLC() { return (EZS_240_LL_RLC)(raw >> 52 & 0x3); }
// Sets Keyles Go event conditions met
void set_KG_ALB_OK(bool value){ raw = (raw & 0xffbfffffffffffff) | ((uint64_t)value & 0x1) << 54; }
// Gets Keyles Go event conditions met
bool get_KG_ALB_OK() { return raw >> 54 & 0x1; }
// Sets Keyless Go terminal control active
void set_KG_KL_AKT(bool value){ raw = (raw & 0xff7fffffffffffff) | ((uint64_t)value & 0x1) << 55; }
// Gets Keyless Go terminal control active
bool get_KG_KL_AKT() { return raw >> 55 & 0x1; }
// Sets message counter
void set_BZ240h(uint8_t value){ raw = (raw & 0xfffff0ffffffffff) | ((uint64_t)value & 0xf) << 40; }
// Gets message counter
uint8_t get_BZ240h() { return raw >> 40 & 0xf; }
// Sets Cruise control lever parity (even parity)
void set_WH_PA(bool value){ raw = (raw & 0xffffefffffffffff) | ((uint64_t)value & 0x1) << 44; }
// Gets Cruise control lever parity (even parity)
bool get_WH_PA() { return raw >> 44 & 0x1; }
// Sets crash signal from Airbag-SG
void set_CRASH(bool value){ raw = (raw & 0xfffffffeffffffff) | ((uint64_t)value & 0x1) << 32; }
// Gets crash signal from Airbag-SG
bool get_CRASH() { return raw >> 32 & 0x1; }
// Sets CRASH confirmbit
void set_CRASH_CNF(bool value){ raw = (raw & 0xfffffffdffffffff) | ((uint64_t)value & 0x1) << 33; }
// Gets CRASH confirmbit
bool get_CRASH_CNF() { return raw >> 33 & 0x1; }
// Sets ASG sport mode on / off activated (ST2_LED_DL if ABC is available)
void set_ASG_SPORT_BET(bool value){ raw = (raw & 0xffffffefffffffff) | ((uint64_t)value & 0x1) << 36; }
// Gets ASG sport mode on / off activated (ST2_LED_DL if ABC is available)
bool get_ASG_SPORT_BET() { return raw >> 36 & 0x1; }
// Sets direction flashing left
void set_BLI_LI(bool value){ raw = (raw & 0xfffffffffeffffff) | ((uint64_t)value & 0x1) << 24; }
// Gets direction flashing left
bool get_BLI_LI() { return raw >> 24 & 0x1; }
// Sets direction flashing right
void set_BLI_RE(bool value){ raw = (raw & 0xfffffffffdffffff) | ((uint64_t)value & 0x1) << 25; }
// Gets direction flashing right
bool get_BLI_RE() { return raw >> 25 & 0x1; }
// Sets wiper outside of parking position
void set_KL_31B(bool value){ raw = (raw & 0xfffffffff7ffffff) | ((uint64_t)value & 0x1) << 27; }
// Gets wiper outside of parking position
bool get_KL_31B() { return raw >> 27 & 0x1; }
// Sets handbrake applied (control lamp)
void set_HAS_KL(bool value){ raw = (raw & 0xffffffffefffffff) | ((uint64_t)value & 0x1) << 28; }
// Gets handbrake applied (control lamp)
bool get_HAS_KL() { return raw >> 28 & 0x1; }
// Sets ESP on / off actuated
void set_EZS_240_ESP_BET(EZS_240_ESP_BET value){ raw = (raw & 0xffffffff9fffffff) | ((uint64_t)value & 0x3) << 29; }
// Gets ESP on / off actuated
EZS_240_ESP_BET get_ESP_BET() { return (EZS_240_ESP_BET)(raw >> 29 & 0x3); }
// Sets On-board network emergency operation: Prio1 and Prio2 consumers off, second battery supports
void set_BN_NTLF(bool value){ raw = (raw & 0xffffffff7fffffff) | ((uint64_t)value & 0x1) << 31; }
// Gets On-board network emergency operation: Prio1 and Prio2 consumers off, second battery supports
bool get_BN_NTLF() { return raw >> 31 & 0x1; }
// Sets Terminal 54 hardware active
void set_KL54_RM(bool value){ raw = (raw & 0xfffffffffffeffff) | ((uint64_t)value & 0x1) << 16; }
// Gets Terminal 54 hardware active
bool get_KL54_RM() { return raw >> 16 & 0x1; }
// Sets Switch on low beam
void set_ABL_EIN(bool value){ raw = (raw & 0xfffffffffffdffff) | ((uint64_t)value & 0x1) << 17; }
// Gets Switch on low beam
bool get_ABL_EIN() { return raw >> 17 & 0x1; }
// Sets ART distance warning on / off activated
void set_EZS_240_ART_ABW_BET(EZS_240_ART_ABW_BET value){ raw = (raw & 0xfffffffffff3ffff) | ((uint64_t)value & 0x3) << 18; }
// Gets ART distance warning on / off activated
EZS_240_ART_ABW_BET get_ART_ABW_BET() { return (EZS_240_ART_ABW_BET)(raw >> 18 & 0x3); }
// Sets LF / ABC 3-stage switch actuated
void set_EZS_240_ST3_BET(EZS_240_ST3_BET value){ raw = (raw & 0xffffffffffcfffff) | ((uint64_t)value & 0x3) << 20; }
// Gets LF / ABC 3-stage switch actuated
EZS_240_ST3_BET get_ST3_BET() { return (EZS_240_ST3_BET)(raw >> 20 & 0x3); }
// Sets LF / ABC 2-stage switch actuated
void set_EZS_240_ST2_BET(EZS_240_ST2_BET value){ raw = (raw & 0xffffffffff3fffff) | ((uint64_t)value & 0x3) << 22; }
// Gets LF / ABC 2-stage switch actuated
EZS_240_ST2_BET get_ST2_BET() { return (EZS_240_ST2_BET)(raw >> 22 & 0x3); }
// Sets distance factor
void set_ART_ABSTAND(uint8_t value){ raw = (raw & 0xffffffffffff00ff) | ((uint64_t)value & 0xff) << 8; }
// Gets distance factor
uint8_t get_ART_ABSTAND() { return raw >> 8 & 0xff; }
// Sets country code
void set_EZS_240_LDC(EZS_240_LDC value){ raw = (raw & 0xfffffffffffffffc) | ((uint64_t)value & 0x3) << 0; }
// Gets country code
EZS_240_LDC get_LDC() { return (EZS_240_LDC)(raw >> 0 & 0x3); }
// Sets model-dependent vehicle version (only 220/215/230)
void set_EZS_240_FZGVERSN(EZS_240_FZGVERSN value){ raw = (raw & 0xffffffffffffffe3) | ((uint64_t)value & 0x7) << 2; }
// Gets model-dependent vehicle version (only 220/215/230)
EZS_240_FZGVERSN get_FZGVERSN() { return (EZS_240_FZGVERSN)(raw >> 2 & 0x7); }
// Sets E-suction fan: basic ventilation off
void set_GBL_AUS(bool value){ raw = (raw & 0xffffffffffffffbf) | ((uint64_t)value & 0x1) << 6; }
// Gets E-suction fan: basic ventilation off
bool get_GBL_AUS() { return raw >> 6 & 0x1; }
// Sets ART available
void set_ART_VH(bool value){ raw = (raw & 0xffffffffffffff7f) | ((uint64_t)value & 0x1) << 7; }
// Gets ART available
bool get_ART_VH() { return raw >> 7 & 0x1; }
/** Imports the frame data from a source */
void import_frame(uint32_t cid, uint8_t* data, uint8_t len) {
if (cid == EZS_240_ID) {
for (int i = 0; i < len; i++) {
bytes[7-i] = data[i];
}
}
}
/** Exports the frame data to a destination */
void export_frame(uint32_t* cid, uint8_t* data, uint8_t* len) {
*cid = EZS_240_ID;
*len = 8;
for (int i = 0; i < *len; i++) {
data[i] = bytes[7-i];
}
}
} EZS_240;
#endif

View File

@ -1,44 +0,0 @@
#ifndef FS_340_H_
#define FS_340_H_
/**
* AUTOGENERATED BY gen_unions.py
*/
#include <stdint.h>
#define FS_340_ID 0x0340
typedef union {
uint8_t bytes[8];
uint64_t raw;
// Sets Load torque ABC pump
void set_M_LAST(uint8_t value){ raw = (raw & 0xfffffffffffffff0) | ((uint64_t)value & 0xf) << 0; }
// Gets Load torque ABC pump
uint8_t get_M_LAST() { return raw >> 0 & 0xf; }
/** Imports the frame data from a source */
void import_frame(uint32_t cid, uint8_t* data, uint8_t len) {
if (cid == FS_340_ID) {
for (int i = 0; i < len; i++) {
bytes[7-i] = data[i];
}
}
}
/** Exports the frame data to a destination */
void export_frame(uint32_t* cid, uint8_t* data, uint8_t* len) {
*cid = FS_340_ID;
*len = 8;
for (int i = 0; i < *len; i++) {
data[i] = bytes[7-i];
}
}
} FS_340;
#endif

View File

@ -1,5 +0,0 @@
#include <GS/GS_218.h>
#include <GS/GS_338.h>
#include <GS/GS_418.h>

View File

@ -1,246 +0,0 @@
#ifndef GS_218_H_
#define GS_218_H_
/**
* AUTOGENERATED BY gen_unions.py
*/
#include <stdint.h>
#define GS_218_ID 0x0218
enum class GS_218_GIC {
N = 0, /** actual gear "N" */
D1 = 1, /** actual gear "1" */
D2 = 2, /** actual gear "2" */
D3 = 3, /** actual gear "3" */
D4 = 4, /** actual gear "4" */
D5 = 5, /** actual gear "5" */
D6 = 6, /** actual gear "6" */
D7 = 7, /** actual gear "7" */
D_CVT = 8, /** actual gear "continuously forward */
R_CVT = 9, /** actual gear "continuously backwards" */
R3 = 10, /** actual gear "R3" */
R = 11, /** Actual gear "R" */
R2 = 12, /** actual gear "R2" */
P = 13, /** actual gear "P" */
NO_FORCE = 14, /** No Force */
SNV = 15, /** signal not available */
};
enum class GS_218_GZC {
N = 0, /** target gear "N" */
D1 = 1, /** target gear "1" */
D2 = 2, /** target gear "2" */
D3 = 3, /** target gear "3" */
D4 = 4, /** target gear "4" */
D5 = 5, /** target gear "5" */
D6 = 6, /** target gear "6" */
D7 = 7, /** target gear "7" */
D_CVT = 8, /** target gear "stepless forward */
R_CVT = 9, /** target gear "continuously backwards" */
R3 = 10, /** target gear "R3" */
R = 11, /** Target gear "R" */
R2 = 12, /** target gear "R2" */
P = 13, /** Target gear "P" */
CANCEL = 14, /** circuit termination */
SNV = 15, /** signal not available */
};
enum class GS_218_FPC_AAD {
SPORT = 0, /** Sport (default) */
COMFORT = 1, /** COMFORT */
NOT_DEFINED = 2, /** not defined */
SNV = 3, /** signal not available */
};
enum class GS_218_FEHLPRF_ST {
WAIT = 0, /** error check not yet run through completely */
OK = 1, /** error check run through completely, result i. O. */
ERROR = 2, /** Error detected, enter current environment data */
NOT_DEFINED = 3, /** not defined */
};
typedef union {
uint8_t bytes[8];
uint64_t raw;
// Sets Motor torque request Max
void set_MMAX_EGS(bool value){ raw = (raw & 0xdfffffffffffffff) | ((uint64_t)value & 0x1) << 61; }
// Gets Motor torque request Max
bool get_MMAX_EGS() { return raw >> 61 & 0x1; }
// Sets engine torque request min
void set_MMIN_EGS(bool value){ raw = (raw & 0xbfffffffffffffff) | ((uint64_t)value & 0x1) << 62; }
// Gets engine torque request min
bool get_MMIN_EGS() { return raw >> 62 & 0x1; }
// Sets motor torque request. Toggle 40ms + -10
void set_MTGL_EGS(bool value){ raw = (raw & 0x7fffffffffffffff) | ((uint64_t)value & 0x1) << 63; }
// Gets motor torque request. Toggle 40ms + -10
bool get_MTGL_EGS() { return raw >> 63 & 0x1; }
// Sets Required. Engine torque
void set_M_EGS(short value){ raw = (raw & 0xe000ffffffffffff) | ((uint64_t)value & 0x1fff) << 48; }
// Gets Required. Engine torque
short get_M_EGS() { return raw >> 48 & 0x1fff; }
// Sets actual gear
void set_GS_218_GIC(GS_218_GIC value){ raw = (raw & 0xfffff0ffffffffff) | ((uint64_t)value & 0xf) << 40; }
// Gets actual gear
GS_218_GIC get_GIC() { return (GS_218_GIC)(raw >> 40 & 0xf); }
// Sets target gear
void set_GS_218_GZC(GS_218_GZC value){ raw = (raw & 0xffff0fffffffffff) | ((uint64_t)value & 0xf) << 44; }
// Gets target gear
GS_218_GZC get_GZC() { return (GS_218_GZC)(raw >> 44 & 0xf); }
// Sets manual switching mode
void set_HSM(bool value){ raw = (raw & 0xfffffffeffffffff) | ((uint64_t)value & 0x1) << 32; }
// Gets manual switching mode
bool get_HSM() { return raw >> 32 & 0x1; }
// Sets switching
void set_SWITCH(bool value){ raw = (raw & 0xfffffffdffffffff) | ((uint64_t)value & 0x1) << 33; }
// Gets switching
bool get_SWITCH() { return raw >> 33 & 0x1; }
// Sets driving resistance high
void set_FW_HOCH(bool value){ raw = (raw & 0xfffffffbffffffff) | ((uint64_t)value & 0x1) << 34; }
// Gets driving resistance high
bool get_FW_HOCH() { return raw >> 34 & 0x1; }
// Sets basic switching program o.k.
void set_GSP_OK(bool value){ raw = (raw & 0xfffffff7ffffffff) | ((uint64_t)value & 0x1) << 35; }
// Gets basic switching program o.k.
bool get_GSP_OK() { return raw >> 35 & 0x1; }
// Sets off-road gear
void set_G_G(bool value){ raw = (raw & 0xffffffefffffffff) | ((uint64_t)value & 0x1) << 36; }
// Gets off-road gear
bool get_G_G() { return raw >> 36 & 0x1; }
// Sets Order (converter bypass) clutch "closed"
void set_K_G_B(bool value){ raw = (raw & 0xffffffdfffffffff) | ((uint64_t)value & 0x1) << 37; }
// Gets Order (converter bypass) clutch "closed"
bool get_K_G_B() { return raw >> 37 & 0x1; }
// Sets Order (converter bypass) clutch "open"
void set_K_O_B(bool value){ raw = (raw & 0xffffffbfffffffff) | ((uint64_t)value & 0x1) << 38; }
// Gets Order (converter bypass) clutch "open"
bool get_K_O_B() { return raw >> 38 & 0x1; }
// Sets Order (converter bypass) clutch "slip"
void set_K_S_B(bool value){ raw = (raw & 0xffffff7fffffffff) | ((uint64_t)value & 0x1) << 39; }
// Gets Order (converter bypass) clutch "slip"
bool get_K_S_B() { return raw >> 39 & 0x1; }
// Sets drive program for AAD
void set_GS_218_FPC_AAD(GS_218_FPC_AAD value){ raw = (raw & 0xfffffffffcffffff) | ((uint64_t)value & 0x3) << 24; }
// Gets drive program for AAD
GS_218_FPC_AAD get_FPC_AAD() { return (GS_218_FPC_AAD)(raw >> 24 & 0x3); }
// Sets Kickdown
void set_KD(bool value){ raw = (raw & 0xfffffffffbffffff) | ((uint64_t)value & 0x1) << 26; }
// Gets Kickdown
bool get_KD() { return raw >> 26 & 0x1; }
// Sets Overtemperature gearbox
void set_UEHITZ_GET(bool value){ raw = (raw & 0xfffffffff7ffffff) | ((uint64_t)value & 0x1) << 27; }
// Gets Overtemperature gearbox
bool get_UEHITZ_GET() { return raw >> 27 & 0x1; }
// Sets GS in emergency mode
void set_GS_NOTL(bool value){ raw = (raw & 0xffffffffefffffff) | ((uint64_t)value & 0x1) << 28; }
// Gets GS in emergency mode
bool get_GS_NOTL() { return raw >> 28 & 0x1; }
// Sets start release
void set_ALF(bool value){ raw = (raw & 0xffffffffdfffffff) | ((uint64_t)value & 0x1) << 29; }
// Gets start release
bool get_ALF() { return raw >> 29 & 0x1; }
// Sets bang start
void set_KS(bool value){ raw = (raw & 0xffffffffbfffffff) | ((uint64_t)value & 0x1) << 30; }
// Gets bang start
bool get_KS() { return raw >> 30 & 0x1; }
// Sets gear ok
void set_GET_OK(bool value){ raw = (raw & 0xffffffff7fffffff) | ((uint64_t)value & 0x1) << 31; }
// Gets gear ok
bool get_GET_OK() { return raw >> 31 & 0x1; }
// Sets Motor emergency shutdown
void set_MOT_NAUS(bool value){ raw = (raw & 0xfffffffffffeffff) | ((uint64_t)value & 0x1) << 16; }
// Gets Motor emergency shutdown
bool get_MOT_NAUS() { return raw >> 16 & 0x1; }
// Sets MOT_NAUS confirmbit
void set_MOT_NAUS_CNF(bool value){ raw = (raw & 0xfffffffffffdffff) | ((uint64_t)value & 0x1) << 17; }
// Gets MOT_NAUS confirmbit
bool get_MOT_NAUS_CNF() { return raw >> 17 & 0x1; }
// Sets converter lockup clutch unloaded
void set_K_LSTFR(bool value){ raw = (raw & 0xfffffffffffbffff) | ((uint64_t)value & 0x1) << 18; }
// Gets converter lockup clutch unloaded
bool get_K_LSTFR() { return raw >> 18 & 0x1; }
// Sets intervention mode / drive torque control
void set_DYN0_AMR_EGS(bool value){ raw = (raw & 0xffffffffffdfffff) | ((uint64_t)value & 0x1) << 21; }
// Gets intervention mode / drive torque control
bool get_DYN0_AMR_EGS() { return raw >> 21 & 0x1; }
// Sets intervention mode / drive torque control
void set_DYN1_EGS(bool value){ raw = (raw & 0xffffffffffbfffff) | ((uint64_t)value & 0x1) << 22; }
// Gets intervention mode / drive torque control
bool get_DYN1_EGS() { return raw >> 22 & 0x1; }
// Sets Motor torque request parity (even parity)
void set_MPAR_EGS(bool value){ raw = (raw & 0xffffffffff7fffff) | ((uint64_t)value & 0x1) << 23; }
// Gets Motor torque request parity (even parity)
bool get_MPAR_EGS() { return raw >> 23 & 0x1; }
// Sets creep torque (FFh with EGS, CVT) or CALID / CVN
void set_MKRIECH(uint8_t value){ raw = (raw & 0xffffffffffff00ff) | ((uint64_t)value & 0xff) << 8; }
// Gets creep torque (FFh with EGS, CVT) or CALID / CVN
uint8_t get_MKRIECH() { return raw >> 8 & 0xff; }
// Sets Error number or counter for CALID / CVN transmission
void set_ERROR(uint8_t value){ raw = (raw & 0xffffffffffffffe0) | ((uint64_t)value & 0x1f) << 0; }
// Gets Error number or counter for CALID / CVN transmission
uint8_t get_ERROR() { return raw >> 0 & 0x1f; }
// Sets CALID / CVN transmission active
void set_CALID_CVN_AKT(bool value){ raw = (raw & 0xffffffffffffffdf) | ((uint64_t)value & 0x1) << 5; }
// Gets CALID / CVN transmission active
bool get_CALID_CVN_AKT() { return raw >> 5 & 0x1; }
// Sets Status error check
void set_GS_218_FEHLPRF_ST(GS_218_FEHLPRF_ST value){ raw = (raw & 0xffffffffffffff3f) | ((uint64_t)value & 0x3) << 6; }
// Gets Status error check
GS_218_FEHLPRF_ST get_FEHLPRF_ST() { return (GS_218_FEHLPRF_ST)(raw >> 6 & 0x3); }
/** Imports the frame data from a source */
void import_frame(uint32_t cid, uint8_t* data, uint8_t len) {
if (cid == GS_218_ID) {
for (int i = 0; i < len; i++) {
bytes[7-i] = data[i];
}
}
}
/** Exports the frame data to a destination */
void export_frame(uint32_t* cid, uint8_t* data, uint8_t* len) {
*cid = GS_218_ID;
*len = 8;
for (int i = 0; i < *len; i++) {
data[i] = bytes[7-i];
}
}
} GS_218;
#endif

View File

@ -1,49 +0,0 @@
#ifndef GS_338_H_
#define GS_338_H_
/**
* AUTOGENERATED BY gen_unions.py
*/
#include <stdint.h>
#define GS_338_ID 0x0338
typedef union {
uint8_t bytes[8];
uint64_t raw;
// Sets gearbox output speed (only 463/461, otherwise FFFFh)
void set_NAB(short value){ raw = (raw & 0x0000ffffffffffff) | ((uint64_t)value & 0xffff) << 48; }
// Gets gearbox output speed (only 463/461, otherwise FFFFh)
short get_NAB() { return raw >> 48 & 0xffff; }
// Sets turbine speed (EGS52-NAG, VGS-NAG2)
void set_NTURBINE(short value){ raw = (raw & 0xffffffffffff0000) | ((uint64_t)value & 0xffff) << 0; }
// Gets turbine speed (EGS52-NAG, VGS-NAG2)
short get_NTURBINE() { return raw >> 0 & 0xffff; }
/** Imports the frame data from a source */
void import_frame(uint32_t cid, uint8_t* data, uint8_t len) {
if (cid == GS_338_ID) {
for (int i = 0; i < len; i++) {
bytes[7-i] = data[i];
}
}
}
/** Exports the frame data to a destination */
void export_frame(uint32_t* cid, uint8_t* data, uint8_t* len) {
*cid = GS_338_ID;
*len = 8;
for (int i = 0; i < *len; i++) {
data[i] = bytes[7-i];
}
}
} GS_338;
#endif

View File

@ -1,239 +0,0 @@
#ifndef GS_418_H_
#define GS_418_H_
/**
* AUTOGENERATED BY gen_unions.py
*/
#include <stdint.h>
#define GS_418_ID 0x0418
enum class GS_418_FSC {
BLANK = 32, /** Blank ("") */
ONE = 49, /** speed step "1" */
TWO = 50, /** speed step "2" */
THREE = 51, /** speed step "3" */
FOUR = 52, /** speed step "4" */
FUENF = 53, /** speed step "5" */
SIX = 54, /** speed step "6" */
SEVEN = 55, /** speed step "7" */
A = 65, /** speed level "A" */
D = 68, /** speed step "D" */
F = 70, /** "F" */
N = 78, /** speed step "N" */
P = 80, /** speed step "P" */
R = 82, /** speed step "R" */
SNV = 255, /** Passive value */
};
enum class GS_418_FPC {
C_MGFB_WT = 2, /** "C", message "gear, actuate parking brake!" with warning tone */
C_MGSNN = 3, /** "C", message "Shift gear, shift lever to N!" */
C_MGBB = 4, /** "C", message "gear, apply brake!" */
C_MGGEA = 6, /** "C", message "Transmission, request gear again!" */
C_MGZSN = 7, /** "C", message "Gear, insert N to start!" */
A_MGFB_WT = 10, /** "A", message "Activate gear, parking brake!" with warning tone */
A_MGSNN = 11, /** "A", message "Shift gear, shift lever to N!" */
A_MGBB = 12, /** "A", message "gear, apply brake!" */
A_MGGEA = 14, /** "A", message "Request transmission, gear again!" */
A_MGZSN = 15, /** "A", message "Gear, insert N to start!" */
S_MGFB_WT = 18, /** "S", message "Activate gear, parking brake!" with warning tone */
S_MGSNN = 19, /** "S", message "Shift gear, shift lever to N!" */
S_MGBB = 20, /** "S", message "gear, apply brake!" */
S_MGGEA = 22, /** "S", message "Request gear, gear again!" */
S_MGZSN = 23, /** "S", message "Gear, insert N to start!" */
UP = 24, /** shift recommendation "upshift" */
DOWN = 25, /** Shift recommendation "Downshift" */
BLANK = 32, /** "" (blank) */
BLANK_MGN = 64, /** "" (blank), message "Gear, insert N!" */
A = 65, /** "A" */
C = 67, /** "C" */
F = 70, /** "F" */
M = 77, /** "M" */
S = 83, /** "S" */
W = 87, /** "W" */
_ = 95, /** "_" (Underscore) */
BLANK_MGW = 96, /** "" (blank), message "Gearbox, visit workshop!" */
A_MGN = 97, /** "A", message "Gear, insert N!" */
C_MGN = 99, /** "C", message "Gear, insert N!" */
M_MGN = 109, /** "M", message "Gear, insert N!" */
S_MGN = 115, /** "S", message "Gear, insert N!" */
W_MGN = 119, /** "W", message "Gear, insert N!" */
__MGN = 127, /** "_" (Underscore), message "Gear, insert N!" */
A_MGW = 129, /** "A", message "Gearbox, visit workshop!" */
C_MGW = 131, /** "C", message "Gearbox, visit workshop!" */
F_MGW = 134, /** Error marking "F", message "Gearbox, visit workshop!" */
M_MGW = 141, /** "M", message "Gearbox, visit workshop!" */
S_MGW = 147, /** "S", message "Gearbox, visit workshop!" */
W_MGW = 151, /** "W", message "Gearbox, visit workshop!" */
__MGW = 159, /** "_" (Underscore), message "Gearbox, go to the workshop!" */
SNV = 255, /** Passive value */
};
enum class GS_418_MECH {
LARGE = 0, /** NAG, Large Gear */
SMALL = 1, /** NAG, Small Gear */
GROSS2 = 2, /** NAG2, Large Gear */
KLEIN2 = 3, /** NAG2, Small Gear */
};
enum class GS_418_GIC {
N = 0, /** actual gear "N" */
D1 = 1, /** actual gear "1" */
D2 = 2, /** actual gear "2" */
D3 = 3, /** actual gear "3" */
D4 = 4, /** actual gear "4" */
D5 = 5, /** actual gear "5" */
D6 = 6, /** actual gear "6" */
D7 = 7, /** actual gear "7" */
D_CVT = 8, /** actual gear "continuously forward */
R_CVT = 9, /** actual gear "continuously backwards" */
R3 = 10, /** actual gear "R3" */
R = 11, /** Actual gear "R" */
R2 = 12, /** actual gear "R2" */
P = 13, /** actual gear "P" */
NO_FORCE = 14, /** No Force */
SNV = 15, /** signal not available */
};
enum class GS_418_GZC {
N = 0, /** target gear "N" */
D1 = 1, /** target gear "1" */
D2 = 2, /** target gear "2" */
D3 = 3, /** target gear "3" */
D4 = 4, /** target gear "4" */
D5 = 5, /** target gear "5" */
D6 = 6, /** target gear "6" */
D7 = 7, /** target gear "7" */
D_CVT = 8, /** target gear "stepless forward */
R_CVT = 9, /** target gear "continuously backwards" */
R3 = 10, /** target gear "R3" */
R = 11, /** Target gear "R" */
R2 = 12, /** target gear "R2" */
P = 13, /** Target gear "P" */
CANCEL = 14, /** circuit termination */
SNV = 15, /** signal not available */
};
enum class GS_418_WHST {
P = 0, /** Gear selector lever in position "P" */
R = 1, /** Gear selector lever in position "R" */
N = 2, /** Gear selector lever in position "N" */
D = 4, /** Gear selector lever in position "D" */
SNV = 7, /** signal not available */
};
typedef union {
uint8_t bytes[8];
uint64_t raw;
// Sets speed step
void set_GS_418_FSC(GS_418_FSC value){ raw = (raw & 0x00ffffffffffffff) | ((uint64_t)value & 0xff) << 56; }
// Gets speed step
GS_418_FSC get_FSC() { return (GS_418_FSC)(raw >> 56 & 0xff); }
// Sets driving program
void set_GS_418_FPC(GS_418_FPC value){ raw = (raw & 0xff00ffffffffffff) | ((uint64_t)value & 0xff) << 48; }
// Gets driving program
GS_418_FPC get_FPC() { return (GS_418_FPC)(raw >> 48 & 0xff); }
// Sets transmission oil temperature
void set_T_GET(uint8_t value){ raw = (raw & 0xffff00ffffffffff) | ((uint64_t)value & 0xff) << 40; }
// Gets transmission oil temperature
uint8_t get_T_GET() { return raw >> 40 & 0xff; }
// Sets Kickdown
void set_KD(bool value){ raw = (raw & 0xfffffffeffffffff) | ((uint64_t)value & 0x1) << 32; }
// Gets Kickdown
bool get_KD() { return raw >> 32 & 0x1; }
// Sets apply brake when switching on
void set_ESV_BRE(bool value){ raw = (raw & 0xfffffffdffffffff) | ((uint64_t)value & 0x1) << 33; }
// Gets apply brake when switching on
bool get_ESV_BRE() { return raw >> 33 & 0x1; }
// Sets gear mechanism variant
void set_GS_418_MECH(GS_418_MECH value){ raw = (raw & 0xfffffff3ffffffff) | ((uint64_t)value & 0x3) << 34; }
// Gets gear mechanism variant
GS_418_MECH get_MECH() { return (GS_418_MECH)(raw >> 34 & 0x3); }
// Sets continuously variable transmission [1], multi-step transmission [0]
void set_CVT(bool value){ raw = (raw & 0xffffffefffffffff) | ((uint64_t)value & 0x1) << 36; }
// Gets continuously variable transmission [1], multi-step transmission [0]
bool get_CVT() { return raw >> 36 & 0x1; }
// Sets switching
void set_SWITCH(bool value){ raw = (raw & 0xffffffdfffffffff) | ((uint64_t)value & 0x1) << 37; }
// Gets switching
bool get_SWITCH() { return raw >> 37 & 0x1; }
// Sets front-wheel drive [1], rear-wheel drive [0]
void set_FRONT(bool value){ raw = (raw & 0xffffffbfffffffff) | ((uint64_t)value & 0x1) << 38; }
// Gets front-wheel drive [1], rear-wheel drive [0]
bool get_FRONT() { return raw >> 38 & 0x1; }
// Sets all-wheel drive
void set_ALL_WHEEL(bool value){ raw = (raw & 0xffffff7fffffffff) | ((uint64_t)value & 0x1) << 39; }
// Gets all-wheel drive
bool get_ALL_WHEEL() { return raw >> 39 & 0x1; }
// Sets actual gear
void set_GS_418_GIC(GS_418_GIC value){ raw = (raw & 0xfffffffff0ffffff) | ((uint64_t)value & 0xf) << 24; }
// Gets actual gear
GS_418_GIC get_GIC() { return (GS_418_GIC)(raw >> 24 & 0xf); }
// Sets target gear
void set_GS_418_GZC(GS_418_GZC value){ raw = (raw & 0xffffffff0fffffff) | ((uint64_t)value & 0xf) << 28; }
// Gets target gear
GS_418_GZC get_GZC() { return (GS_418_GZC)(raw >> 28 & 0xf); }
// Sets torque loss (FFh at KSG)
void set_M_VERL(uint8_t value){ raw = (raw & 0xffffffffff00ffff) | ((uint64_t)value & 0xff) << 16; }
// Gets torque loss (FFh at KSG)
uint8_t get_M_VERL() { return raw >> 16 & 0xff; }
// Sets Gear selector lever position (NAG, KSG, CVT)
void set_GS_418_WHST(GS_418_WHST value){ raw = (raw & 0xffffffffffffc7ff) | ((uint64_t)value & 0x7) << 11; }
// Gets Gear selector lever position (NAG, KSG, CVT)
GS_418_WHST get_WHST() { return (GS_418_WHST)(raw >> 11 & 0x7); }
// Sets Factor wheel torque toggle 40ms + -10
void set_FMRADTGL(bool value){ raw = (raw & 0xffffffffffffbfff) | ((uint64_t)value & 0x1) << 14; }
// Gets Factor wheel torque toggle 40ms + -10
bool get_FMRADTGL() { return raw >> 14 & 0x1; }
// Sets Wheel torque parity factor (even parity)
void set_FMRADPAR(bool value){ raw = (raw & 0xffffffffffff7fff) | ((uint64_t)value & 0x1) << 15; }
// Gets Wheel torque parity factor (even parity)
bool get_FMRADPAR() { return raw >> 15 & 0x1; }
// Sets wheel torque factor (7FFh at KSG)
void set_FMRAD(short value){ raw = (raw & 0xfffffffffffff800) | ((uint64_t)value & 0x7ff) << 0; }
// Gets wheel torque factor (7FFh at KSG)
short get_FMRAD() { return raw >> 0 & 0x7ff; }
/** Imports the frame data from a source */
void import_frame(uint32_t cid, uint8_t* data, uint8_t len) {
if (cid == GS_418_ID) {
for (int i = 0; i < len; i++) {
bytes[7-i] = data[i];
}
}
}
/** Exports the frame data to a destination */
void export_frame(uint32_t* cid, uint8_t* data, uint8_t* len) {
*cid = GS_418_ID;
*len = 8;
for (int i = 0; i < *len; i++) {
data[i] = bytes[7-i];
}
}
} GS_418;
#endif

View File

@ -1,44 +0,0 @@
#ifndef KLA_40E_H_
#define KLA_40E_H_
/**
* AUTOGENERATED BY gen_unions.py
*/
#include <stdint.h>
#define KLA_40E_ID 0x040E
typedef union {
uint8_t bytes[8];
uint64_t raw;
// Sets Heating power requirement
void set_HZL_ANF(uint8_t value){ raw = (raw & 0x00ffffffffffffff) | ((uint64_t)value & 0xff) << 56; }
// Gets Heating power requirement
uint8_t get_HZL_ANF() { return raw >> 56 & 0xff; }
/** Imports the frame data from a source */
void import_frame(uint32_t cid, uint8_t* data, uint8_t len) {
if (cid == KLA_40E_ID) {
for (int i = 0; i < len; i++) {
bytes[7-i] = data[i];
}
}
}
/** Exports the frame data to a destination */
void export_frame(uint32_t* cid, uint8_t* data, uint8_t* len) {
*cid = KLA_40E_ID;
*len = 8;
for (int i = 0; i < *len; i++) {
data[i] = bytes[7-i];
}
}
} KLA_40E;
#endif

View File

@ -1,74 +0,0 @@
#ifndef KLA_410_H_
#define KLA_410_H_
/**
* AUTOGENERATED BY gen_unions.py
*/
#include <stdint.h>
#define KLA_410_ID 0x0410
typedef union {
uint8_t bytes[8];
uint64_t raw;
// Sets A / C compressor switched on
void set_KOMP_EIN(bool value){ raw = (raw & 0xfeffffffffffffff) | ((uint64_t)value & 0x1) << 56; }
// Gets A / C compressor switched on
bool get_KOMP_EIN() { return raw >> 56 & 0x1; }
// Sets Idle speed increase to increase the cooling capacity
void set_LL_DZA(bool value){ raw = (raw & 0xbfffffffffffffff) | ((uint64_t)value & 0x1) << 62; }
// Gets Idle speed increase to increase the cooling capacity
bool get_LL_DZA() { return raw >> 62 & 0x1; }
// Sets Switching on auxiliary heater allowed
void set_ZH_EIN_OK(bool value){ raw = (raw & 0x7fffffffffffffff) | ((uint64_t)value & 0x1) << 63; }
// Gets Switching on auxiliary heater allowed
bool get_ZH_EIN_OK() { return raw >> 63 & 0x1; }
// Sets refrigerant pressure
void set_P_KAELTE8(uint8_t value){ raw = (raw & 0xff00ffffffffffff) | ((uint64_t)value & 0xff) << 48; }
// Gets refrigerant pressure
uint8_t get_P_KAELTE8() { return raw >> 48 & 0xff; }
// Sets Torque absorption refrigeration compressor
void set_M_KOMP(uint8_t value){ raw = (raw & 0xffff00ffffffffff) | ((uint64_t)value & 0xff) << 40; }
// Gets Torque absorption refrigeration compressor
uint8_t get_M_KOMP() { return raw >> 40 & 0xff; }
// Sets Motor fan setpoint speed
void set_NLFTS(uint8_t value){ raw = (raw & 0xffffff00ffffffff) | ((uint64_t)value & 0xff) << 32; }
// Gets Motor fan setpoint speed
uint8_t get_NLFTS() { return raw >> 32 & 0xff; }
// Sets outside air temperature for heat management
void set_T_AUSSEN_WM(uint8_t value){ raw = (raw & 0xffffffffff00ffff) | ((uint64_t)value & 0xff) << 16; }
// Gets outside air temperature for heat management
uint8_t get_T_AUSSEN_WM() { return raw >> 16 & 0xff; }
/** Imports the frame data from a source */
void import_frame(uint32_t cid, uint8_t* data, uint8_t len) {
if (cid == KLA_410_ID) {
for (int i = 0; i < len; i++) {
bytes[7-i] = data[i];
}
}
}
/** Exports the frame data to a destination */
void export_frame(uint32_t* cid, uint8_t* data, uint8_t* len) {
*cid = KLA_410_ID;
*len = 8;
for (int i = 0; i < *len; i++) {
data[i] = bytes[7-i];
}
}
} KLA_410;
#endif

View File

@ -1,153 +0,0 @@
#ifndef KOMBI_408_H_
#define KOMBI_408_H_
/**
* AUTOGENERATED BY gen_unions.py
*/
#include <stdint.h>
#define KOMBI_408_ID 0x0408
enum class KOMBI_408_WRC {
UBG = 0, /** unlimited */
BG210 = 1, /** 210 km */
BG190 = 2, /** 190 km */
BG160 = 3, /** 160 km */
BG240 = 4, /** 240 km */
BG230 = 5, /** 230 km */
BG220 = 6, /** 220 km */
BG200 = 7, /** 200 km */
BG180 = 128, /** 180 km */
BG170 = 129, /** 170 km */
BG150 = 130, /** 150 km */
BG140 = 131, /** 140 km */
BG130 = 132, /** 130 km */
BG120 = 133, /** 120 km */
BG110 = 134, /** 110 km */
BG100 = 135, /** 100 km */
};
typedef union {
uint8_t bytes[8];
uint64_t raw;
// Sets tank level
void set_TANK_FS(uint8_t value){ raw = (raw & 0x00ffffffffffffff) | ((uint64_t)value & 0xff) << 56; }
// Gets tank level
uint8_t get_TANK_FS() { return raw >> 56 & 0xff; }
// Sets Terminal 61 decoupled
void set_KL_61E(bool value){ raw = (raw & 0xfffeffffffffffff) | ((uint64_t)value & 0x1) << 48; }
// Gets Terminal 61 decoupled
bool get_KL_61E() { return raw >> 48 & 0x1; }
// Sets minimum tank level
void set_TFSM(bool value){ raw = (raw & 0xfffdffffffffffff) | ((uint64_t)value & 0x1) << 49; }
// Gets minimum tank level
bool get_TFSM() { return raw >> 49 & 0x1; }
// Sets Pre-glow control lamp defective
void set_VGL_KL_DEF(bool value){ raw = (raw & 0xfffbffffffffffff) | ((uint64_t)value & 0x1) << 50; }
// Gets Pre-glow control lamp defective
bool get_VGL_KL_DEF() { return raw >> 50 & 0x1; }
// Sets air conditioning available
void set_KLA_VH(bool value){ raw = (raw & 0xfff7ffffffffffff) | ((uint64_t)value & 0x1) << 51; }
// Gets air conditioning available
bool get_KLA_VH() { return raw >> 51 & 0x1; }
// Sets mph instead of km / h (variable speed limit)
void set_V_MPH(bool value){ raw = (raw & 0xffefffffffffffff) | ((uint64_t)value & 0x1) << 52; }
// Gets mph instead of km / h (variable speed limit)
bool get_V_MPH() { return raw >> 52 & 0x1; }
// Sets Tacho calibration
void set_TACHO_SYM(bool value){ raw = (raw & 0xffdfffffffffffff) | ((uint64_t)value & 0x1) << 53; }
// Gets Tacho calibration
bool get_TACHO_SYM() { return raw >> 53 & 0x1; }
// Sets Speed limiter / tempomat display not possible
void set_V_DSPL_AUS(bool value){ raw = (raw & 0xffbfffffffffffff) | ((uint64_t)value & 0x1) << 54; }
// Gets Speed limiter / tempomat display not possible
bool get_V_DSPL_AUS() { return raw >> 54 & 0x1; }
// Sets driver's door open
void set_TF_AUF(bool value){ raw = (raw & 0xff7fffffffffffff) | ((uint64_t)value & 0x1) << 55; }
// Gets driver's door open
bool get_TF_AUF() { return raw >> 55 & 0x1; }
// Sets Raw outside air temperature
void set_T_AUSSEN(uint8_t value){ raw = (raw & 0xffff00ffffffffff) | ((uint64_t)value & 0xff) << 40; }
// Gets Raw outside air temperature
uint8_t get_T_AUSSEN() { return raw >> 40 & 0xff; }
// Sets Terminal 58 dimmed
void set_KL_58D(uint8_t value){ raw = (raw & 0xffffff00ffffffff) | ((uint64_t)value & 0xff) << 32; }
// Gets Terminal 58 dimmed
uint8_t get_KL_58D() { return raw >> 32 & 0xff; }
// Sets engine shutdown time (is sent from terminal 15)
void set_MAZ(uint8_t value){ raw = (raw & 0xffffffff00ffffff) | ((uint64_t)value & 0xff) << 24; }
// Gets engine shutdown time (is sent from terminal 15)
uint8_t get_MAZ() { return raw >> 24 & 0xff; }
// Sets mileage
void set_KM16(short value){ raw = (raw & 0xffffffffff0000ff) | ((uint64_t)value & 0xffff) << 8; }
// Gets mileage
short get_KM16() { return raw >> 8 & 0xffff; }
// Sets maximum winter tire speed with 4 bits
void set_KOMBI_408_WRC(KOMBI_408_WRC value){ raw = (raw & 0xfffffffffffffff8) | ((uint64_t)value & 0x7) << 0; }
// Gets maximum winter tire speed with 4 bits
KOMBI_408_WRC get_WRC() { return (KOMBI_408_WRC)(raw >> 0 & 0x7); }
// Sets Activate roller test mode ESP
void set_RT_EIN(bool value){ raw = (raw & 0xfffffffffffffff7) | ((uint64_t)value & 0x1) << 3; }
// Gets Activate roller test mode ESP
bool get_RT_EIN() { return raw >> 3 & 0x1; }
// Sets Enable auxiliary heater
void set_ZH_FREIG(bool value){ raw = (raw & 0xffffffffffffffef) | ((uint64_t)value & 0x1) << 4; }
// Gets Enable auxiliary heater
bool get_ZH_FREIG() { return raw >> 4 & 0x1; }
// Sets segment tachometer available
void set_SGT_VH(bool value){ raw = (raw & 0xffffffffffffffdf) | ((uint64_t)value & 0x1) << 5; }
// Gets segment tachometer available
bool get_SGT_VH() { return raw >> 5 & 0x1; }
// Sets Speed limiter / cruise control display active
void set_V_DSPL_AKT(bool value){ raw = (raw & 0xffffffffffffffbf) | ((uint64_t)value & 0x1) << 6; }
// Gets Speed limiter / cruise control display active
bool get_V_DSPL_AKT() { return raw >> 6 & 0x1; }
// Sets Winter tire maximum speed bit 3
void set_WRC3(bool value){ raw = (raw & 0xffffffffffffff7f) | ((uint64_t)value & 0x1) << 7; }
// Gets Winter tire maximum speed bit 3
bool get_WRC3() { return raw >> 7 & 0x1; }
/** Imports the frame data from a source */
void import_frame(uint32_t cid, uint8_t* data, uint8_t len) {
if (cid == KOMBI_408_ID) {
for (int i = 0; i < len; i++) {
bytes[7-i] = data[i];
}
}
}
/** Exports the frame data to a destination */
void export_frame(uint32_t* cid, uint8_t* data, uint8_t* len) {
*cid = KOMBI_408_ID;
*len = 8;
for (int i = 0; i < *len; i++) {
data[i] = bytes[7-i];
}
}
} KOMBI_408;
#endif

View File

@ -1,119 +0,0 @@
#ifndef KOMBI_412_H_
#define KOMBI_412_H_
/**
* AUTOGENERATED BY gen_unions.py
*/
#include <stdint.h>
#define KOMBI_412_ID 0x0412
enum class KOMBI_412_IST_ABST {
VERY_SMALL = 0, /** Very Small */
SMALL = 1, /** Small */
MEDIUM = 2, /** Medium */
LARGE = 3, /** Large */
VERY_LARGE = 4, /** Very Large */
NOT_DEFINED_0 = 5, /** not defined */
NOT_DEFINED_1 = 6, /** not defined */
NOT_DEFINED_2 = 7, /** not defined */
};
enum class KOMBI_412_DRTGANZ {
PASSIVE = 0, /** No direction of rotation detection */
FORWARD = 1, /** direction of rotation forward */
REVERSE = 2, /** direction of rotation backwards */
SNV = 3, /** signal not available */
};
enum class KOMBI_412_PRW_ANF {
IDLE = 0, /** No change */
OFF = 1, /** switch PRW off */
ON = 2, /** Activate PRW again */
SNV = 3, /** signal not available */
};
typedef union {
uint8_t bytes[8];
uint64_t raw;
// Sets Status ECO warning
void set_ECO_WARN_ST(bool value){ raw = (raw & 0xf7ffffffffffffff) | ((uint64_t)value & 0x1) << 59; }
// Gets Status ECO warning
bool get_ECO_WARN_ST() { return raw >> 59 & 0x1; }
// Sets Optical warning off
void set_OPT_WARN_AUS(bool value){ raw = (raw & 0xbfffffffffffffff) | ((uint64_t)value & 0x1) << 62; }
// Gets Optical warning off
bool get_OPT_WARN_AUS() { return raw >> 62 & 0x1; }
// Sets Acoustic warning off
void set_AKU_WARN_AUS(bool value){ raw = (raw & 0x7fffffffffffffff) | ((uint64_t)value & 0x1) << 63; }
// Gets Acoustic warning off
bool get_AKU_WARN_AUS() { return raw >> 63 & 0x1; }
// Sets Set distance
void set_KOMBI_412_IST_ABST(KOMBI_412_IST_ABST value){ raw = (raw & 0xff8fffffffffffff) | ((uint64_t)value & 0x7) << 52; }
// Gets Set distance
KOMBI_412_IST_ABST get_IST_ABST() { return (KOMBI_412_IST_ABST)(raw >> 52 & 0x7); }
// Sets distance unit
void set_ABST_S(bool value){ raw = (raw & 0xff7fffffffffffff) | ((uint64_t)value & 0x1) << 55; }
// Gets distance unit
bool get_ABST_S() { return raw >> 55 & 0x1; }
// Sets Displayed speed
void set_V_ANZ(short value){ raw = (raw & 0xfff000ffffffffff) | ((uint64_t)value & 0xfff) << 40; }
// Gets Displayed speed
short get_V_ANZ() { return raw >> 40 & 0xfff; }
// Sets direction of wheel rotation to V_ANZ
void set_KOMBI_412_DRTGANZ(KOMBI_412_DRTGANZ value){ raw = (raw & 0xffffff3fffffffff) | ((uint64_t)value & 0x3) << 38; }
// Gets direction of wheel rotation to V_ANZ
KOMBI_412_DRTGANZ get_DRTGANZ() { return (KOMBI_412_DRTGANZ)(raw >> 38 & 0x3); }
// Sets wheel speed calculated from V_ANZ
void set_DANZ(short value){ raw = (raw & 0xffffffc000ffffff) | ((uint64_t)value & 0x3fff) << 24; }
// Gets wheel speed calculated from V_ANZ
short get_DANZ() { return raw >> 24 & 0x3fff; }
// Sets Flat roll warning request
void set_KOMBI_412_PRW_ANF(KOMBI_412_PRW_ANF value){ raw = (raw & 0xfffffffffffcffff) | ((uint64_t)value & 0x3) << 16; }
// Gets Flat roll warning request
KOMBI_412_PRW_ANF get_PRW_ANF() { return (KOMBI_412_PRW_ANF)(raw >> 16 & 0x3); }
// Sets Activate ECO in the combination menu
void set_ECO_AKT(bool value){ raw = (raw & 0xfffffffffff7ffff) | ((uint64_t)value & 0x1) << 19; }
// Gets Activate ECO in the combination menu
bool get_ECO_AKT() { return raw >> 19 & 0x1; }
// Sets engine shutdown time
void set_MAZ_NEU(short value){ raw = (raw & 0xfffffffffffff000) | ((uint64_t)value & 0xfff) << 0; }
// Gets engine shutdown time
short get_MAZ_NEU() { return raw >> 0 & 0xfff; }
/** Imports the frame data from a source */
void import_frame(uint32_t cid, uint8_t* data, uint8_t len) {
if (cid == KOMBI_412_ID) {
for (int i = 0; i < len; i++) {
bytes[7-i] = data[i];
}
}
}
/** Exports the frame data to a destination */
void export_frame(uint32_t* cid, uint8_t* data, uint8_t* len) {
*cid = KOMBI_412_ID;
*len = 8;
for (int i = 0; i < *len; i++) {
data[i] = bytes[7-i];
}
}
} KOMBI_412;
#endif

View File

@ -1,83 +0,0 @@
#ifndef LRW_236_H_
#define LRW_236_H_
/**
* AUTOGENERATED BY gen_unions.py
*/
#include <stdint.h>
#define LRW_236_ID 0x0236
enum class LRW_236_LRWS_ST {
OK = 0, /** steering wheel angle sensor ok */
INI = 1, /** Steering wheel angle sensor not initialized */
ERR = 2, /** steering wheel angle sensor faulty */
ERR_INI = 3, /** steering wheel angle sensor faulty and not initialized */
};
enum class LRW_236_LRWS_ID {
INIT_PSBL = 0, /** LRW sensor can be initialized */
INIT_SELF = 1, /** LRW sensor initializes itself */
INIT_MUST = 2, /** (LRW sensor must be initialized) */
SNV = 3, /** signal not available */
};
typedef union {
uint8_t bytes[8];
uint64_t raw;
// Sets steering wheel angle
void set_LRW(short value){ raw = (raw & 0xc000ffffffffffff) | ((uint64_t)value & 0x3fff) << 48; }
// Gets steering wheel angle
short get_LRW() { return raw >> 48 & 0x3fff; }
// Sets steering wheel angular speed
void set_VLRW(short value){ raw = (raw & 0xffffc000ffffffff) | ((uint64_t)value & 0x3fff) << 32; }
// Gets steering wheel angular speed
short get_VLRW() { return raw >> 32 & 0x3fff; }
// Sets Steering wheel angle sensor status
void set_LRW_236_LRWS_ST(LRW_236_LRWS_ST value){ raw = (raw & 0xfffffffffcffffff) | ((uint64_t)value & 0x3) << 24; }
// Gets Steering wheel angle sensor status
LRW_236_LRWS_ST get_LRWS_ST() { return (LRW_236_LRWS_ST)(raw >> 24 & 0x3); }
// Sets Identification of the steering wheel angle sensor
void set_LRW_236_LRWS_ID(LRW_236_LRWS_ID value){ raw = (raw & 0xfffffffff3ffffff) | ((uint64_t)value & 0x3) << 26; }
// Gets Identification of the steering wheel angle sensor
LRW_236_LRWS_ID get_LRWS_ID() { return (LRW_236_LRWS_ID)(raw >> 26 & 0x3); }
// Sets message counter
void set_BZ236h(uint8_t value){ raw = (raw & 0xffffffff0fffffff) | ((uint64_t)value & 0xf) << 28; }
// Gets message counter
uint8_t get_BZ236h() { return raw >> 28 & 0xf; }
// Sets CRC checksum byte 1
void set_CRC236h(uint8_t value){ raw = (raw & 0xffffffffffffff00) | ((uint64_t)value & 0xff) << 0; }
// Gets CRC checksum byte 1
uint8_t get_CRC236h() { return raw >> 0 & 0xff; }
/** Imports the frame data from a source */
void import_frame(uint32_t cid, uint8_t* data, uint8_t len) {
if (cid == LRW_236_ID) {
for (int i = 0; i < len; i++) {
bytes[7-i] = data[i];
}
}
}
/** Exports the frame data to a destination */
void export_frame(uint32_t* cid, uint8_t* data, uint8_t* len) {
*cid = LRW_236_ID;
*len = 8;
for (int i = 0; i < *len; i++) {
data[i] = bytes[7-i];
}
}
} LRW_236;
#endif

View File

@ -1,119 +0,0 @@
#ifndef MRM_238_H_
#define MRM_238_H_
/**
* AUTOGENERATED BY gen_unions.py
*/
#include <stdint.h>
#define MRM_238_ID 0x0238
typedef union {
uint8_t bytes[8];
uint64_t raw;
// Sets Cruise control lever: "Switch off"
void set_OFF(bool value){ raw = (raw & 0xfeffffffffffffff) | ((uint64_t)value & 0x1) << 56; }
// Gets Cruise control lever: "Switch off"
bool get_OFF() { return raw >> 56 & 0x1; }
// Sets Cruise control lever: "Resume"
void set_WA(bool value){ raw = (raw & 0xfdffffffffffffff) | ((uint64_t)value & 0x1) << 57; }
// Gets Cruise control lever: "Resume"
bool get_WA() { return raw >> 57 & 0x1; }
// Sets Cruise control lever: "Set and accelerate level0"
void set_S_PLUS_B(bool value){ raw = (raw & 0xfbffffffffffffff) | ((uint64_t)value & 0x1) << 58; }
// Gets Cruise control lever: "Set and accelerate level0"
bool get_S_PLUS_B() { return raw >> 58 & 0x1; }
// Sets Cruise control lever: "Set and decelerate level0"
void set_S_MINUS_B(bool value){ raw = (raw & 0xf7ffffffffffffff) | ((uint64_t)value & 0x1) << 59; }
// Gets Cruise control lever: "Set and decelerate level0"
bool get_S_MINUS_B() { return raw >> 59 & 0x1; }
// Sets Operation variable speed limit
void set_VMAX_AKT(bool value){ raw = (raw & 0xefffffffffffffff) | ((uint64_t)value & 0x1) << 60; }
// Gets Operation variable speed limit
bool get_VMAX_AKT() { return raw >> 60 & 0x1; }
// Sets Cruise control lever implausible
void set_WH_UP(bool value){ raw = (raw & 0xdfffffffffffffff) | ((uint64_t)value & 0x1) << 61; }
// Gets Cruise control lever implausible
bool get_WH_UP() { return raw >> 61 & 0x1; }
// Sets message counter
void set_BZ238h(uint8_t value){ raw = (raw & 0xfff0ffffffffffff) | ((uint64_t)value & 0xf) << 48; }
// Gets message counter
uint8_t get_BZ238h() { return raw >> 48 & 0xf; }
// Sets Cruise control lever parity (even parity)
void set_WH_PA(bool value){ raw = (raw & 0xffefffffffffffff) | ((uint64_t)value & 0x1) << 52; }
// Gets Cruise control lever parity (even parity)
bool get_WH_PA() { return raw >> 52 & 0x1; }
// Sets direction flashing left
void set_BLI_LI(bool value){ raw = (raw & 0xffbfffffffffffff) | ((uint64_t)value & 0x1) << 54; }
// Gets direction flashing left
bool get_BLI_LI() { return raw >> 54 & 0x1; }
// Sets right direction flashing
void set_BLI_RE(bool value){ raw = (raw & 0xff7fffffffffffff) | ((uint64_t)value & 0x1) << 55; }
// Gets right direction flashing
bool get_BLI_RE() { return raw >> 55 & 0x1; }
// Sets steering angle sign
void set_LW_VZ(bool value){ raw = (raw & 0xfffff7ffffffffff) | ((uint64_t)value & 0x1) << 43; }
// Gets steering angle sign
bool get_LW_VZ() { return raw >> 43 & 0x1; }
// Sets Steering angle sensor: not initialized
void set_LW_INI(bool value){ raw = (raw & 0xffffefffffffffff) | ((uint64_t)value & 0x1) << 44; }
// Gets Steering angle sensor: not initialized
bool get_LW_INI() { return raw >> 44 & 0x1; }
// Sets Steering angle sensor: Code error
void set_LW_CF(bool value){ raw = (raw & 0xffffdfffffffffff) | ((uint64_t)value & 0x1) << 45; }
// Gets Steering angle sensor: Code error
bool get_LW_CF() { return raw >> 45 & 0x1; }
// Sets Steering angle sensor: overflow
void set_LW_OV(bool value){ raw = (raw & 0xffffbfffffffffff) | ((uint64_t)value & 0x1) << 46; }
// Gets Steering angle sensor: overflow
bool get_LW_OV() { return raw >> 46 & 0x1; }
// Sets Steering angle parity (even parity)
void set_LW_PA(bool value){ raw = (raw & 0xffff7fffffffffff) | ((uint64_t)value & 0x1) << 47; }
// Gets Steering angle parity (even parity)
bool get_LW_PA() { return raw >> 47 & 0x1; }
// Sets steering angle
void set_LW(short value){ raw = (raw & 0xfffff800ffffffff) | ((uint64_t)value & 0x7ff) << 32; }
// Gets steering angle
short get_LW() { return raw >> 32 & 0x7ff; }
/** Imports the frame data from a source */
void import_frame(uint32_t cid, uint8_t* data, uint8_t len) {
if (cid == MRM_238_ID) {
for (int i = 0; i < len; i++) {
bytes[7-i] = data[i];
}
}
}
/** Exports the frame data to a destination */
void export_frame(uint32_t* cid, uint8_t* data, uint8_t* len) {
*cid = MRM_238_ID;
*len = 8;
for (int i = 0; i < *len; i++) {
data[i] = bytes[7-i];
}
}
} MRM_238;
#endif

View File

@ -1,74 +0,0 @@
#ifndef AAD_580_H_
#define AAD_580_H_
/**
* AUTOGENERATED BY gen_unions.py
*/
#include <stdint.h>
#define AAD_580_ID 0x0580
typedef union {
uint8_t bytes[8];
uint64_t raw;
// Sets code number acceleration type (> 100: dynamic)
void set_FTK_BMI(uint8_t value){ raw = (raw & 0x00ffffffffffffff) | ((uint64_t)value & 0xff) << 56; }
// Gets code number acceleration type (> 100: dynamic)
uint8_t get_FTK_BMI() { return raw >> 56 & 0xff; }
// Sets Code number for lateral acceleration type (> 100: dynamic)
void set_FTK_LMI(uint8_t value){ raw = (raw & 0xff00ffffffffffff) | ((uint64_t)value & 0xff) << 48; }
// Gets Code number for lateral acceleration type (> 100: dynamic)
uint8_t get_FTK_LMI() { return raw >> 48 & 0xff; }
// Sets code number brake type (> 100: dynamic)
void set_FTK_VMI(uint8_t value){ raw = (raw & 0xffff00ffffffffff) | ((uint64_t)value & 0xff) << 40; }
// Gets code number brake type (> 100: dynamic)
uint8_t get_FTK_VMI() { return raw >> 40 & 0xff; }
// Sets Max.diff. Pedal angle value per maneuver
void set_FTK_DPW(uint8_t value){ raw = (raw & 0xffffffff00ffffff) | ((uint64_t)value & 0xff) << 24; }
// Gets Max.diff. Pedal angle value per maneuver
uint8_t get_FTK_DPW() { return raw >> 24 & 0xff; }
// Sets Continuous driver observation
void set_AADKB(uint8_t value){ raw = (raw & 0xffffffffff00ffff) | ((uint64_t)value & 0xff) << 16; }
// Gets Continuous driver observation
uint8_t get_AADKB() { return raw >> 16 & 0xff; }
// Sets Spontaneous dynamic demand
void set_AADKBDYN(bool value){ raw = (raw & 0xffffffffffff7fff) | ((uint64_t)value & 0x1) << 15; }
// Gets Spontaneous dynamic demand
bool get_AADKBDYN() { return raw >> 15 & 0x1; }
// Sets Nervousness
void set_AADNT(uint8_t value){ raw = (raw & 0xffffffffffffff00) | ((uint64_t)value & 0xff) << 0; }
// Gets Nervousness
uint8_t get_AADNT() { return raw >> 0 & 0xff; }
/** Imports the frame data from a source */
void import_frame(uint32_t cid, uint8_t* data, uint8_t len) {
if (cid == AAD_580_ID) {
for (int i = 0; i < len; i++) {
bytes[7-i] = data[i];
}
}
}
/** Exports the frame data to a destination */
void export_frame(uint32_t* cid, uint8_t* data, uint8_t* len) {
*cid = AAD_580_ID;
*len = 8;
for (int i = 0; i < *len; i++) {
data[i] = bytes[7-i];
}
}
} AAD_580;
#endif

View File

@ -1,250 +0,0 @@
#ifndef MS_210_H_
#define MS_210_H_
/**
* AUTOGENERATED BY gen_unions.py
*/
#include <stdint.h>
#define MS_210_ID 0x0210
enum class MS_210_SLV_MS {
SKL0 = 0, /** switching characteristic "0" */
SKL1 = 1, /** switching characteristic "1" */
SKL2 = 2, /** switching characteristic "2" */
SKL3 = 3, /** switching characteristic "3" */
SKL4 = 4, /** switching characteristic "4" */
SKL5 = 5, /** switching characteristic "5" */
SKL6 = 6, /** switching characteristic "6" */
SKL7 = 7, /** switching characteristic "7" */
SKL8 = 8, /** switching characteristic "8" */
SKL9 = 9, /** switching characteristic "9" */
SKL10 = 10, /** switching characteristic "10" */
};
enum class MS_210_GMIN_MS {
PASSIVE = 0, /** Passive value */
G1 = 1, /** target gear, lower limit = 1 */
G2 = 2, /** target gear, lower limit = 2 */
G3 = 3, /** target gear, lower limit = 3 */
G4 = 4, /** target gear, lower limit = 4 */
G5 = 5, /** target gear, lower limit = 5 */
G6 = 6, /** target gear, lower limit = 6 */
G7 = 7, /** target gear, lower limit = 7 */
};
enum class MS_210_GMAX_MS {
PASSIVE = 0, /** Passive value */
G1 = 1, /** target gear, upper limit = 1 */
G2 = 2, /** target gear, upper limit = 2 */
G3 = 3, /** target gear, upper limit = 3 */
G4 = 4, /** target gear, upper limit = 4 */
G5 = 5, /** target gear, upper limit = 5 */
G6 = 6, /** target gear, upper limit = 6 */
G7 = 7, /** target gear, upper limit = 7 */
};
typedef union {
uint8_t bytes[8];
uint64_t raw;
// Sets MS request: "Approach 1st gear"
void set_ANF1(bool value){ raw = (raw & 0xfeffffffffffffff) | ((uint64_t)value & 0x1) << 56; }
// Gets MS request: "Approach 1st gear"
bool get_ANF1() { return raw >> 56 & 0x1; }
// Sets Switch off KSG creep
void set_CREEP_AUS(bool value){ raw = (raw & 0xfdffffffffffffff) | ((uint64_t)value & 0x1) << 57; }
// Gets Switch off KSG creep
bool get_CREEP_AUS() { return raw >> 57 & 0x1; }
// Sets switching line shift MS
void set_MS_210_SLV_MS(MS_210_SLV_MS value){ raw = (raw & 0x87ffffffffffffff) | ((uint64_t)value & 0xf) << 59; }
// Gets switching line shift MS
MS_210_SLV_MS get_SLV_MS() { return (MS_210_SLV_MS)(raw >> 59 & 0xf); }
// Sets Air conditioning compressor emergency shutdown
void set_KOMP_NOTAUS(bool value){ raw = (raw & 0x7fffffffffffffff) | ((uint64_t)value & 0x1) << 63; }
// Gets Air conditioning compressor emergency shutdown
bool get_KOMP_NOTAUS() { return raw >> 63 & 0x1; }
// Sets target gear, lower limit
void set_MS_210_GMIN_MS(MS_210_GMIN_MS value){ raw = (raw & 0xfff8ffffffffffff) | ((uint64_t)value & 0x7) << 48; }
// Gets target gear, lower limit
MS_210_GMIN_MS get_GMIN_MS() { return (MS_210_GMIN_MS)(raw >> 48 & 0x7); }
// Sets target gear, upper limit
void set_MS_210_GMAX_MS(MS_210_GMAX_MS value){ raw = (raw & 0xffc7ffffffffffff) | ((uint64_t)value & 0x7) << 51; }
// Gets target gear, upper limit
MS_210_GMAX_MS get_GMAX_MS() { return (MS_210_GMAX_MS)(raw >> 51 & 0x7); }
// Sets switch off auxiliary heater
void set_ZH_AUS_MS(bool value){ raw = (raw & 0xffbfffffffffffff) | ((uint64_t)value & 0x1) << 54; }
// Gets switch off auxiliary heater
bool get_ZH_AUS_MS() { return raw >> 54 & 0x1; }
// Sets MS request: "Active downshift"
void set_AKT_R_MS(bool value){ raw = (raw & 0xff7fffffffffffff) | ((uint64_t)value & 0x1) << 55; }
// Gets MS request: "Active downshift"
bool get_AKT_R_MS() { return raw >> 55 & 0x1; }
// Sets pedal value
void set_PW(uint8_t value){ raw = (raw & 0xffff00ffffffffff) | ((uint64_t)value & 0xff) << 40; }
// Gets pedal value
uint8_t get_PW() { return raw >> 40 & 0xff; }
// Sets crash signal from engine control
void set_CRASH_MS(bool value){ raw = (raw & 0xfffffffeffffffff) | ((uint64_t)value & 0x1) << 32; }
// Gets crash signal from engine control
bool get_CRASH_MS() { return raw >> 32 & 0x1; }
// Sets Switch off air conditioning compressor: acceleration
void set_KOMP_BAUS(bool value){ raw = (raw & 0xfffffffdffffffff) | ((uint64_t)value & 0x1) << 33; }
// Gets Switch off air conditioning compressor: acceleration
bool get_KOMP_BAUS() { return raw >> 33 & 0x1; }
// Sets Motor start / stop system active
void set_MSS_AKT(bool value){ raw = (raw & 0xfffffffbffffffff) | ((uint64_t)value & 0x1) << 34; }
// Gets Motor start / stop system active
bool get_MSS_AKT() { return raw >> 34 & 0x1; }
// Sets Motor start / stop system control lamp
void set_MSS_KL(bool value){ raw = (raw & 0xfffffff7ffffffff) | ((uint64_t)value & 0x1) << 35; }
// Gets Motor start / stop system control lamp
bool get_MSS_KL() { return raw >> 35 & 0x1; }
// Sets Motor start / stop system defective
void set_MSS_DEF(bool value){ raw = (raw & 0xffffffefffffffff) | ((uint64_t)value & 0x1) << 36; }
// Gets Motor start / stop system defective
bool get_MSS_DEF() { return raw >> 36 & 0x1; }
// Sets preheating status
void set_VGL_ST(bool value){ raw = (raw & 0xffffffdfffffffff) | ((uint64_t)value & 0x1) << 37; }
// Gets preheating status
bool get_VGL_ST() { return raw >> 37 & 0x1; }
// Sets idle is stable
void set_LL_STBL(bool value){ raw = (raw & 0xffffffbfffffffff) | ((uint64_t)value & 0x1) << 38; }
// Gets idle is stable
bool get_LL_STBL() { return raw >> 38 & 0x1; }
// Sets retrigger the minimum display time
void set_V_DSPL_NEU(bool value){ raw = (raw & 0xffffff7fffffffff) | ((uint64_t)value & 0x1) << 39; }
// Gets retrigger the minimum display time
bool get_V_DSPL_NEU() { return raw >> 39 & 0x1; }
// Sets warning buzzer on
void set_V_MAX_SUM(bool value){ raw = (raw & 0xfffffffffeffffff) | ((uint64_t)value & 0x1) << 24; }
// Gets warning buzzer on
bool get_V_MAX_SUM() { return raw >> 24 & 0x1; }
// Sets emergency operation
void set_NOTL(bool value){ raw = (raw & 0xfffffffffdffffff) | ((uint64_t)value & 0x1) << 25; }
// Gets emergency operation
bool get_NOTL() { return raw >> 25 & 0x1; }
// Sets Kickdown (changeover scenario open!)
void set_KD_MS(bool value){ raw = (raw & 0xfffffffffbffffff) | ((uint64_t)value & 0x1) << 26; }
// Gets Kickdown (changeover scenario open!)
bool get_KD_MS() { return raw >> 26 & 0x1; }
// Sets speed limit switched on
void set_V_MAX_EIN(bool value){ raw = (raw & 0xfffffffff7ffffff) | ((uint64_t)value & 0x1) << 27; }
// Gets speed limit switched on
bool get_V_MAX_EIN() { return raw >> 27 & 0x1; }
// Sets Tempomat regulates
void set_TM_REG(bool value){ raw = (raw & 0xffffffffefffffff) | ((uint64_t)value & 0x1) << 28; }
// Gets Tempomat regulates
bool get_TM_REG() { return raw >> 28 & 0x1; }
// Sets Req. Converter lock-up clutch "slip"
void set_KUEB_S_A(bool value){ raw = (raw & 0xffffffffdfffffff) | ((uint64_t)value & 0x1) << 29; }
// Gets Req. Converter lock-up clutch "slip"
bool get_KUEB_S_A() { return raw >> 29 & 0x1; }
// Sets idle
void set_LL(bool value){ raw = (raw & 0xffffffffbfffffff) | ((uint64_t)value & 0x1) << 30; }
// Gets idle
bool get_LL() { return raw >> 30 & 0x1; }
// Sets Pedal encoder error
void set_PWG_ERR(bool value){ raw = (raw & 0xffffffff7fffffff) | ((uint64_t)value & 0x1) << 31; }
// Gets Pedal encoder error
bool get_PWG_ERR() { return raw >> 31 & 0x1; }
// Sets Speed limiter / cruise control display on
void set_V_DSPL_EIN(bool value){ raw = (raw & 0xfffffffffffeffff) | ((uint64_t)value & 0x1) << 16; }
// Gets Speed limiter / cruise control display on
bool get_V_DSPL_EIN() { return raw >> 16 & 0x1; }
// Sets display flashes
void set_V_DSPL_BL(bool value){ raw = (raw & 0xfffffffffffdffff) | ((uint64_t)value & 0x1) << 17; }
// Gets display flashes
bool get_V_DSPL_BL() { return raw >> 17 & 0x1; }
// Sets "Error" indication on the display
void set_V_DSPL_ERR(bool value){ raw = (raw & 0xfffffffffffbffff) | ((uint64_t)value & 0x1) << 18; }
// Gets "Error" indication on the display
bool get_V_DSPL_ERR() { return raw >> 18 & 0x1; }
// Sets Display "Limit?" on the display
void set_V_DSPL_LIM(bool value){ raw = (raw & 0xfffffffffff7ffff) | ((uint64_t)value & 0x1) << 19; }
// Gets Display "Limit?" on the display
bool get_V_DSPL_LIM() { return raw >> 19 & 0x1; }
// Sets speed limiter regulates
void set_V_MAX_REG(bool value){ raw = (raw & 0xffffffffffefffff) | ((uint64_t)value & 0x1) << 20; }
// Gets speed limiter regulates
bool get_V_MAX_REG() { return raw >> 20 & 0x1; }
// Sets Tempomat switched on
void set_TM_EIN(bool value){ raw = (raw & 0xffffffffffdfffff) | ((uint64_t)value & 0x1) << 21; }
// Gets Tempomat switched on
bool get_TM_EIN() { return raw >> 21 & 0x1; }
// Sets "Winter tire limit reached" on the display
void set_V_DSPL_PGB(bool value){ raw = (raw & 0xffffffffffbfffff) | ((uint64_t)value & 0x1) << 22; }
// Gets "Winter tire limit reached" on the display
bool get_V_DSPL_PGB() { return raw >> 22 & 0x1; }
// Sets FBS: Start Error
void set_FBS_SE(bool value){ raw = (raw & 0xffffffffff7fffff) | ((uint64_t)value & 0x1) << 23; }
// Gets FBS: Start Error
bool get_FBS_SE() { return raw >> 23 & 0x1; }
// Sets factor for depreciation. d. Max. Mom. When decreasing A. pressure
void set_FMMOTMAX(uint8_t value){ raw = (raw & 0xffffffffffff00ff) | ((uint64_t)value & 0xff) << 8; }
// Gets factor for depreciation. d. Max. Mom. When decreasing A. pressure
uint8_t get_FMMOTMAX() { return raw >> 8 & 0xff; }
// Sets Set maximum or cruise control speed
void set_V_MAX_TM(uint8_t value){ raw = (raw & 0xffffffffffffff00) | ((uint64_t)value & 0xff) << 0; }
// Gets Set maximum or cruise control speed
uint8_t get_V_MAX_TM() { return raw >> 0 & 0xff; }
/** Imports the frame data from a source */
void import_frame(uint32_t cid, uint8_t* data, uint8_t len) {
if (cid == MS_210_ID) {
for (int i = 0; i < len; i++) {
bytes[7-i] = data[i];
}
}
}
/** Exports the frame data to a destination */
void export_frame(uint32_t* cid, uint8_t* data, uint8_t* len) {
*cid = MS_210_ID;
*len = 8;
for (int i = 0; i < *len; i++) {
data[i] = bytes[7-i];
}
}
} MS_210;
#endif

View File

@ -1,94 +0,0 @@
#ifndef MS_212_H_
#define MS_212_H_
/**
* AUTOGENERATED BY gen_unions.py
*/
#include <stdint.h>
#define MS_212_ID 0x0212
typedef union {
uint8_t bytes[8];
uint64_t raw;
// Sets Target engine idling speed
void set_NMOTS(short value){ raw = (raw & 0x0000ffffffffffff) | ((uint64_t)value & 0xffff) << 48; }
// Gets Target engine idling speed
short get_NMOTS() { return raw >> 48 & 0xffff; }
// Sets Enable torque request ART
void set_M_ART_E(bool value){ raw = (raw & 0xffffdfffffffffff) | ((uint64_t)value & 0x1) << 45; }
// Gets Enable torque request ART
bool get_M_ART_E() { return raw >> 45 & 0x1; }
// Sets Series cruise control is variant-coded
void set_TM_MS(bool value){ raw = (raw & 0xffffbfffffffffff) | ((uint64_t)value & 0x1) << 46; }
// Gets Series cruise control is variant-coded
bool get_TM_MS() { return raw >> 46 & 0x1; }
// Sets driver default torque
void set_M_FV(short value){ raw = (raw & 0xffffe000ffffffff) | ((uint64_t)value & 0x1fff) << 32; }
// Gets driver default torque
short get_M_FV() { return raw >> 32 & 0x1fff; }
// Sets Enable torque request ESP
void set_M_ESP_E(bool value){ raw = (raw & 0xffffffffdfffffff) | ((uint64_t)value & 0x1) << 29; }
// Gets Enable torque request ESP
bool get_M_ESP_E() { return raw >> 29 & 0x1; }
// Sets Enable fast torque setting
void set_SME_E(bool value){ raw = (raw & 0xffffffffbfffffff) | ((uint64_t)value & 0x1) << 30; }
// Gets Enable fast torque setting
bool get_SME_E() { return raw >> 30 & 0x1; }
// Sets Substitute default torque driver
void set_M_FEV(short value){ raw = (raw & 0xffffffffe000ffff) | ((uint64_t)value & 0x1fff) << 16; }
// Gets Substitute default torque driver
short get_M_FEV() { return raw >> 16 & 0x1fff; }
// Sets Enable torque request EGS
void set_M_EGS_E(bool value){ raw = (raw & 0xffffffffffffdfff) | ((uint64_t)value & 0x1) << 13; }
// Gets Enable torque request EGS
bool get_M_EGS_E() { return raw >> 13 & 0x1; }
// Sets Acknowledgment of torque request EGS
void set_M_EGS_Q(bool value){ raw = (raw & 0xffffffffffffbfff) | ((uint64_t)value & 0x1) << 14; }
// Gets Acknowledgment of torque request EGS
bool get_M_EGS_Q() { return raw >> 14 & 0x1; }
// Sets Transfer CALID / CVN enable
void set_CALID_CVN_E(bool value){ raw = (raw & 0xffffffffffff7fff) | ((uint64_t)value & 0x1) << 15; }
// Gets Transfer CALID / CVN enable
bool get_CALID_CVN_E() { return raw >> 15 & 0x1; }
// Sets Preset torque ESP
void set_M_ESPV(short value){ raw = (raw & 0xffffffffffffe000) | ((uint64_t)value & 0x1fff) << 0; }
// Gets Preset torque ESP
short get_M_ESPV() { return raw >> 0 & 0x1fff; }
/** Imports the frame data from a source */
void import_frame(uint32_t cid, uint8_t* data, uint8_t len) {
if (cid == MS_212_ID) {
for (int i = 0; i < len; i++) {
bytes[7-i] = data[i];
}
}
}
/** Exports the frame data to a destination */
void export_frame(uint32_t* cid, uint8_t* data, uint8_t* len) {
*cid = MS_212_ID;
*len = 8;
for (int i = 0; i < *len; i++) {
data[i] = bytes[7-i];
}
}
} MS_212;
#endif

View File

@ -1,101 +0,0 @@
#ifndef MS_268_H_
#define MS_268_H_
/**
* AUTOGENERATED BY gen_unions.py
*/
#include <stdint.h>
#define MS_268_ID 0x0268
enum class MS_268_HZL_ST {
CLOSED = 0, /** Heater shut-off valve is closed */
OPEN = 1, /** Heater shut-off valve is on */
TAKT = 2, /** Heating shut-off valve is clocked */
SNV = 3, /** signal not available */
};
typedef union {
uint8_t bytes[8];
uint64_t raw;
// Sets target ratio, lower limit (FCVT)
void set_IMIN_MS(uint8_t value){ raw = (raw & 0x00ffffffffffffff) | ((uint64_t)value & 0xff) << 56; }
// Gets target ratio, lower limit (FCVT)
uint8_t get_IMIN_MS() { return raw >> 56 & 0xff; }
// Sets target ratio, upper limit (FCVT)
void set_IMAX_MS(uint8_t value){ raw = (raw & 0xff00ffffffffffff) | ((uint64_t)value & 0xff) << 48; }
// Gets target ratio, upper limit (FCVT)
uint8_t get_IMAX_MS() { return raw >> 48 & 0xff; }
// Sets Status of heating output
void set_MS_268_HZL_ST(MS_268_HZL_ST value){ raw = (raw & 0xfffffcffffffffff) | ((uint64_t)value & 0x3) << 40; }
// Gets Status of heating output
MS_268_HZL_ST get_HZL_ST() { return (MS_268_HZL_ST)(raw >> 40 & 0x3); }
// Sets shut-off valve cooling circuit M266 ATL
void set_ASV_KKL_169(bool value){ raw = (raw & 0xffffdfffffffffff) | ((uint64_t)value & 0x1) << 45; }
// Gets shut-off valve cooling circuit M266 ATL
bool get_ASV_KKL_169() { return raw >> 45 & 0x1; }
// Sets Oil info, reserved M266
void set_OEL_INFO_169(bool value){ raw = (raw & 0xffffbfffffffffff) | ((uint64_t)value & 0x1) << 46; }
// Gets Oil info, reserved M266
bool get_OEL_INFO_169() { return raw >> 46 & 0x1; }
// Sets Terminal 61
void set_KL_61_EIN(bool value){ raw = (raw & 0xffff7fffffffffff) | ((uint64_t)value & 0x1) << 47; }
// Gets Terminal 61
bool get_KL_61_EIN() { return raw >> 47 & 0x1; }
// Sets Generator utilization (only with LIN generators!)
void set_LAST_GEN(uint8_t value){ raw = (raw & 0xffffffc0ffffffff) | ((uint64_t)value & 0x3f) << 32; }
// Gets Generator utilization (only with LIN generators!)
uint8_t get_LAST_GEN() { return raw >> 32 & 0x3f; }
// Sets Air control system mode
void set_LRS_MODE(bool value){ raw = (raw & 0xffffffbfffffffff) | ((uint64_t)value & 0x1) << 38; }
// Gets Air control system mode
bool get_LRS_MODE() { return raw >> 38 & 0x1; }
// Sets Request force-free in "D" (FCVT)
void set_KID_MS(bool value){ raw = (raw & 0xffffff7fffffffff) | ((uint64_t)value & 0x1) << 39; }
// Gets Request force-free in "D" (FCVT)
bool get_KID_MS() { return raw >> 39 & 0x1; }
// Sets Max. Air conditioning compressor torque
void set_M_KOMP_MAX(uint8_t value){ raw = (raw & 0xffffffff00ffffff) | ((uint64_t)value & 0xff) << 24; }
// Gets Max. Air conditioning compressor torque
uint8_t get_M_KOMP_MAX() { return raw >> 24 & 0xff; }
// Sets pedal value driver (only 169)
void set_PW_F(uint8_t value){ raw = (raw & 0xffffffffff00ffff) | ((uint64_t)value & 0xff) << 16; }
// Gets pedal value driver (only 169)
uint8_t get_PW_F() { return raw >> 16 & 0xff; }
/** Imports the frame data from a source */
void import_frame(uint32_t cid, uint8_t* data, uint8_t len) {
if (cid == MS_268_ID) {
for (int i = 0; i < len; i++) {
bytes[7-i] = data[i];
}
}
}
/** Exports the frame data to a destination */
void export_frame(uint32_t* cid, uint8_t* data, uint8_t* len) {
*cid = MS_268_ID;
*len = 8;
for (int i = 0; i < *len; i++) {
data[i] = bytes[7-i];
}
}
} MS_268;
#endif

View File

@ -1,87 +0,0 @@
#ifndef MS_2F3_H_
#define MS_2F3_H_
/**
* AUTOGENERATED BY gen_unions.py
*/
#include <stdint.h>
#define MS_2F3_ID 0x02F3
enum class MS_2F3_FSC_IST {
BLANK = 32, /** Blank ("") */
ONE = 49, /** speed step "1" */
TWO = 50, /** speed step "2" */
THREE = 51, /** speed step "3" */
FOUR = 52, /** speed step "4" */
FUENF = 53, /** speed step "5" */
SIX = 54, /** speed step "6" */
SEVEN = 55, /** speed step "7" */
A = 65, /** speed level "A" */
D = 68, /** speed step "D" */
F = 70, /** "F" */
N = 78, /** speed step "N" */
P = 80, /** speed step "P" */
R = 82, /** speed step "R" */
SNV = 255, /** Passive value */
};
enum class MS_2F3_FSC_SOLL {
UP = 1, /** "upshift" */
DOWN = 2, /** "Downshift" */
PAS = 32, /** Blank ("") */
ONE = 49, /** speed step "1" */
TWO = 50, /** speed step "2" */
THREE = 51, /** speed step "3" */
FOUR = 52, /** speed step "4" */
FUENF = 53, /** speed step "5" */
SIX = 54, /** speed step "6" */
SEVEN = 55, /** speed step "7" */
A = 65, /** speed level "A" */
D = 68, /** speed step "D" */
F = 70, /** "F" */
N = 78, /** speed step "N" */
P = 80, /** speed step "P" */
R = 82, /** speed step "R" */
SNV = 255, /** Passive value */
};
typedef union {
uint8_t bytes[8];
uint64_t raw;
// Sets Gear step shift recommendation "Actual"
void set_MS_2F3_FSC_IST(MS_2F3_FSC_IST value){ raw = (raw & 0x00ffffffffffffff) | ((uint64_t)value & 0xff) << 56; }
// Gets Gear step shift recommendation "Actual"
MS_2F3_FSC_IST get_FSC_IST() { return (MS_2F3_FSC_IST)(raw >> 56 & 0xff); }
// Sets Gear step shift recommendation "target"
void set_MS_2F3_FSC_SOLL(MS_2F3_FSC_SOLL value){ raw = (raw & 0xffffffffff00ffff) | ((uint64_t)value & 0xff) << 16; }
// Gets Gear step shift recommendation "target"
MS_2F3_FSC_SOLL get_FSC_SOLL() { return (MS_2F3_FSC_SOLL)(raw >> 16 & 0xff); }
/** Imports the frame data from a source */
void import_frame(uint32_t cid, uint8_t* data, uint8_t len) {
if (cid == MS_2F3_ID) {
for (int i = 0; i < len; i++) {
bytes[7-i] = data[i];
}
}
}
/** Exports the frame data to a destination */
void export_frame(uint32_t* cid, uint8_t* data, uint8_t* len) {
*cid = MS_2F3_ID;
*len = 8;
for (int i = 0; i < *len; i++) {
data[i] = bytes[7-i];
}
}
} MS_2F3;
#endif

View File

@ -1,174 +0,0 @@
#ifndef MS_308_H_
#define MS_308_H_
/**
* AUTOGENERATED BY gen_unions.py
*/
#include <stdint.h>
#define MS_308_ID 0x0308
typedef union {
uint8_t bytes[8];
uint64_t raw;
// Sets cylinder deactivation conditions met
void set_ZASBED(bool value){ raw = (raw & 0xfeffffffffffffff) | ((uint64_t)value & 0x1) << 56; }
// Gets cylinder deactivation conditions met
bool get_ZASBED() { return raw >> 56 & 0x1; }
// Sets water in fuel control lamp (only CR2-USA)
void set_WKS_KL(bool value){ raw = (raw & 0xfdffffffffffffff) | ((uint64_t)value & 0x1) << 57; }
// Gets water in fuel control lamp (only CR2-USA)
bool get_WKS_KL() { return raw >> 57 & 0x1; }
// Sets fuel filter clogged control lamp (only CR2-USA)
void set_KSF_KL(bool value){ raw = (raw & 0xfbffffffffffffff) | ((uint64_t)value & 0x1) << 58; }
// Gets fuel filter clogged control lamp (only CR2-USA)
bool get_KSF_KL() { return raw >> 58 & 0x1; }
// Sets fuel cutoff full
void set_SASV(bool value){ raw = (raw & 0xf7ffffffffffffff) | ((uint64_t)value & 0x1) << 59; }
// Gets fuel cutoff full
bool get_SASV() { return raw >> 59 & 0x1; }
// Sets partial thrust cut-off
void set_SAST(bool value){ raw = (raw & 0xefffffffffffffff) | ((uint64_t)value & 0x1) << 60; }
// Gets partial thrust cut-off
bool get_SAST() { return raw >> 60 & 0x1; }
// Sets speed limitation function active
void set_N_MAX_BG(bool value){ raw = (raw & 0xdfffffffffffffff) | ((uint64_t)value & 0x1) << 61; }
// Gets speed limitation function active
bool get_N_MAX_BG() { return raw >> 61 & 0x1; }
// Sets Req. Torque converter lock-up clutch "open"
void set_KUEB_O_A(bool value){ raw = (raw & 0xbfffffffffffffff) | ((uint64_t)value & 0x1) << 62; }
// Gets Req. Torque converter lock-up clutch "open"
bool get_KUEB_O_A() { return raw >> 62 & 0x1; }
// Sets clutch pressed
void set_KPL(bool value){ raw = (raw & 0x7fffffffffffffff) | ((uint64_t)value & 0x1) << 63; }
// Gets clutch pressed
bool get_KPL() { return raw >> 63 & 0x1; }
// Sets engine speed
void set_NMOT(short value){ raw = (raw & 0xff0000ffffffffff) | ((uint64_t)value & 0xffff) << 40; }
// Gets engine speed
short get_NMOT() { return raw >> 40 & 0xffff; }
// Sets Tank cap open control lamp
void set_TANK_KL(bool value){ raw = (raw & 0xfffffffeffffffff) | ((uint64_t)value & 0x1) << 32; }
// Gets Tank cap open control lamp
bool get_TANK_KL() { return raw >> 32 & 0x1; }
// Sets Diagnostic control lamp (OBD II)
void set_DIAG_KL(bool value){ raw = (raw & 0xfffffffdffffffff) | ((uint64_t)value & 0x1) << 33; }
// Gets Diagnostic control lamp (OBD II)
bool get_DIAG_KL() { return raw >> 33 & 0x1; }
// Sets Oil level / oil pressure control lamp
void set_OEL_KL(bool value){ raw = (raw & 0xfffffffbffffffff) | ((uint64_t)value & 0x1) << 34; }
// Gets Oil level / oil pressure control lamp
bool get_OEL_KL() { return raw >> 34 & 0x1; }
// Sets Pre-glow control lamp
void set_VGL_KL(bool value){ raw = (raw & 0xfffffff7ffffffff) | ((uint64_t)value & 0x1) << 35; }
// Gets Pre-glow control lamp
bool get_VGL_KL() { return raw >> 35 & 0x1; }
// Sets air filter dirty control lamp (only diesel)
void set_LUFI_KL(bool value){ raw = (raw & 0xffffffefffffffff) | ((uint64_t)value & 0x1) << 36; }
// Gets air filter dirty control lamp (only diesel)
bool get_LUFI_KL() { return raw >> 36 & 0x1; }
// Sets ethanol operation detected
void set_EOH(bool value){ raw = (raw & 0xffffffdfffffffff) | ((uint64_t)value & 0x1) << 37; }
// Gets ethanol operation detected
bool get_EOH() { return raw >> 37 & 0x1; }
// Sets Warning message for the eco power steering pump
void set_ELHP_WARN(bool value){ raw = (raw & 0xffffffbfffffffff) | ((uint64_t)value & 0x1) << 38; }
// Gets Warning message for the eco power steering pump
bool get_ELHP_WARN() { return raw >> 38 & 0x1; }
// Sets cooling water temperature too high
void set_TEMP_KL(bool value){ raw = (raw & 0xfffffffffeffffff) | ((uint64_t)value & 0x1) << 24; }
// Gets cooling water temperature too high
bool get_TEMP_KL() { return raw >> 24 & 0x1; }
// Sets speed limitation for display active (0 for CR)
void set_DBAA(bool value){ raw = (raw & 0xfffffffffdffffff) | ((uint64_t)value & 0x1) << 25; }
// Gets speed limitation for display active (0 for CR)
bool get_DBAA() { return raw >> 25 & 0x1; }
// Sets Motor fan defective control lamp
void set_LUEFT_MOT_KL(bool value){ raw = (raw & 0xfffffffffbffffff) | ((uint64_t)value & 0x1) << 26; }
// Gets Motor fan defective control lamp
bool get_LUEFT_MOT_KL() { return raw >> 26 & 0x1; }
// Sets starter is running
void set_ANL_LFT(bool value){ raw = (raw & 0xfffffffff7ffffff) | ((uint64_t)value & 0x1) << 27; }
// Gets starter is running
bool get_ANL_LFT() { return raw >> 27 & 0x1; }
// Sets ADR defective control lamp (only commercial vehicles)
void set_ADR_DEF_KL(bool value){ raw = (raw & 0xffffffffefffffff) | ((uint64_t)value & 0x1) << 28; }
// Gets ADR defective control lamp (only commercial vehicles)
bool get_ADR_DEF_KL() { return raw >> 28 & 0x1; }
// Sets ADR control lamp (commercial vehicles only)
void set_ADR_KL(bool value){ raw = (raw & 0xffffffffdfffffff) | ((uint64_t)value & 0x1) << 29; }
// Gets ADR control lamp (commercial vehicles only)
bool get_ADR_KL() { return raw >> 29 & 0x1; }
// Sets cylinder deactivation
void set_ZAS(bool value){ raw = (raw & 0xffffffffbfffffff) | ((uint64_t)value & 0x1) << 30; }
// Gets cylinder deactivation
bool get_ZAS() { return raw >> 30 & 0x1; }
// Sets engine oil temperature too high (overheating)
void set_UEHITZ(bool value){ raw = (raw & 0xffffffff7fffffff) | ((uint64_t)value & 0x1) << 31; }
// Gets engine oil temperature too high (overheating)
bool get_UEHITZ() { return raw >> 31 & 0x1; }
// Sets oil temperature
void set_T_OEL(uint8_t value){ raw = (raw & 0xffffffffff00ffff) | ((uint64_t)value & 0xff) << 16; }
// Gets oil temperature
uint8_t get_T_OEL() { return raw >> 16 & 0xff; }
// Sets oil level
void set_OEL_FS(uint8_t value){ raw = (raw & 0xffffffffffff00ff) | ((uint64_t)value & 0xff) << 8; }
// Gets oil level
uint8_t get_OEL_FS() { return raw >> 8 & 0xff; }
// Sets oil quality
void set_OEL_QUAL(uint8_t value){ raw = (raw & 0xffffffffffffff00) | ((uint64_t)value & 0xff) << 0; }
// Gets oil quality
uint8_t get_OEL_QUAL() { return raw >> 0 & 0xff; }
/** Imports the frame data from a source */
void import_frame(uint32_t cid, uint8_t* data, uint8_t len) {
if (cid == MS_308_ID) {
for (int i = 0; i < len; i++) {
bytes[7-i] = data[i];
}
}
}
/** Exports the frame data to a destination */
void export_frame(uint32_t* cid, uint8_t* data, uint8_t* len) {
*cid = MS_308_ID;
*len = 8;
for (int i = 0; i < *len; i++) {
data[i] = bytes[7-i];
}
}
} MS_308;
#endif

View File

@ -1,59 +0,0 @@
#ifndef MS_312_H_
#define MS_312_H_
/**
* AUTOGENERATED BY gen_unions.py
*/
#include <stdint.h>
#define MS_312_ID 0x0312
typedef union {
uint8_t bytes[8];
uint64_t raw;
// Sets Static motor torque
void set_M_STA(short value){ raw = (raw & 0xe000ffffffffffff) | ((uint64_t)value & 0x1fff) << 48; }
// Gets Static motor torque
short get_M_STA() { return raw >> 48 & 0x1fff; }
// Sets Maximum motor torque including dyn. Turbocharger share
void set_M_MAX_ATL(short value){ raw = (raw & 0xffffe000ffffffff) | ((uint64_t)value & 0x1fff) << 32; }
// Gets Maximum motor torque including dyn. Turbocharger share
short get_M_MAX_ATL() { return raw >> 32 & 0x1fff; }
// Sets maximum motor torque
void set_M_MAX(short value){ raw = (raw & 0xffffffffe000ffff) | ((uint64_t)value & 0x1fff) << 16; }
// Gets maximum motor torque
short get_M_MAX() { return raw >> 16 & 0x1fff; }
// Sets minimum motor torque
void set_M_MIN(short value){ raw = (raw & 0xffffffffffffe000) | ((uint64_t)value & 0x1fff) << 0; }
// Gets minimum motor torque
short get_M_MIN() { return raw >> 0 & 0x1fff; }
/** Imports the frame data from a source */
void import_frame(uint32_t cid, uint8_t* data, uint8_t len) {
if (cid == MS_312_ID) {
for (int i = 0; i < len; i++) {
bytes[7-i] = data[i];
}
}
}
/** Exports the frame data to a destination */
void export_frame(uint32_t* cid, uint8_t* data, uint8_t* len) {
*cid = MS_312_ID;
*len = 8;
for (int i = 0; i < *len; i++) {
data[i] = bytes[7-i];
}
}
} MS_312;
#endif

View File

@ -1,210 +0,0 @@
#ifndef MS_608_H_
#define MS_608_H_
/**
* AUTOGENERATED BY gen_unions.py
*/
#include <stdint.h>
#define MS_608_ID 0x0608
enum class MS_608_FCOD_BR {
BR221 = 0, /** BR 221 or BR 140 */
BR129 = 1, /** BR 129 */
BR210 = 2, /** BR 210 or BR 212 */
BR202 = 3, /** BR 202 or BR 204 */
BR220 = 4, /** BR 220 */
BR170 = 5, /** BR 170 */
BR203 = 6, /** BR 203 */
BR168 = 7, /** BR 168 */
BR163 = 8, /** BR 163 */
BR208 = 9, /** BR 208 */
BR463 = 10, /** BR 463 */
BR215 = 11, /** BR 215 */
BR230 = 12, /** BR 230 */
BR211 = 13, /** BR 211 */
BR209 = 14, /** BR 209 */
BR461 = 15, /** BR 461 */
BR240 = 16, /** BR 240 */
BR251 = 17, /** BR 251 */
BR171 = 18, /** BR 171 */
BR164 = 19, /** BR 164 */
BR169 = 20, /** BR 169 or BR 245 */
BR199 = 21, /** BR 199 */
BR216 = 22, /** BR 216 */
BR219 = 23, /** BR 219 */
BR454 = 24, /** BR 454 (z-car) */
NCV2 = 25, /** NCV2 */
VITO = 26, /** V-Class */
SPRINTER = 27, /** Sprinter */
NCV3 = 28, /** NCV3 */
NCV1 = 29, /** NCV1 */
REST = 30, /** all other BR */
SNV = 31, /** code does not exist */
};
enum class MS_608_FCOD_KAR {
W = 0, /** W */
V = 1, /** V */
C = 2, /** C */
S = 3, /** S */
A = 4, /** A */
R = 5, /** R */
SS = 6, /** SS */
SNV = 7, /** code does not exist */
};
enum class MS_608_FCOD_MOT {
M272E35 = 0, /** M272 E35 */
M271E18ML105 = 1, /** M271 E18 ML red. (105 kW) */
M271E18ML120 = 2, /** M271 E18 ML (120 kW) */
M112E37 = 3, /** M112 E37 */
M272E25 = 4, /** M272 E25 */
M272E30 = 5, /** M272 E30 */
M112E28 = 7, /** M112 E28 */
M112E32 = 8, /** M112 E32 */
M273E46 = 10, /** M273 E46 */
M273E55 = 11, /** M273 E55 */
M112E26 = 12, /** M112 E26 */
M113E43 = 13, /** M113 E43 */
M113E50 = 14, /** M113 E50 */
M271E18ML140 = 18, /** M271 E18 ML */
M271DE18ML105 = 19, /** M271 DE18 ML red. (105 kW) */
M271DE18ML125 = 20, /** M271 DE18 ML (125 kW) */
M111E_E23ML = 22, /** M111E E23 ML */
M111E_E20 = 23, /** M111E E20 */
M111E_E20ML = 24, /** M111E E20 ML */
M112E32_140 = 25, /** M112 E32 red. (140 kW) */
M266E20ATL = 26, /** M266 E20 ATL */
M266E15 = 27, /** M266 E15 */
M266E17 = 28, /** M266 E17 */
M266E20 = 29, /** M266 E20 */
M275E55 = 30, /** M275 E55 or M285 E55 */
M137E58 = 31, /** M137 E58 */
OM640DE20LA60 = 32, /** OM 640 DE20 LA (60 kW) */
OM640DE20LA80 = 34, /** OM 640 DE20 LA (80 kW) */
OM642DE30LA160 = 35, /** OM642 DE30 LA (155/160 kW) */
OM640DE20LA100 = 36, /** OM 640 DE20 LA (100 kW) */
OM613DE32LA = 37, /** OM613 DE32 LA or OM648 DE32 LA */
OM628DE40LA = 39, /** OM628 DE40 LA */
OM642DE30LA140 = 40, /** OM642 DE30 LA (140 kW) */
OM612DE27LA = 43, /** OM612 DE27 LA or OM647 DE27 LA (120/130 kW) */
OM611DE22LA100 = 44, /** OM611 DE22 LA (105/100 kW) or OM646 DE22 LA (100/105/110 kW) */
OM611DE22LA85 = 45, /** OM611 DE22 LA (85 kW) or OM646 DE22 LA (90 kW) */
OM611DE22LA75 = 46, /** OM611 DE22 LA (75 kW) or OM646 DE22 LA (75 kW) */
M134E11 = 64, /** M134 E11 (3A91) */
M135E13 = 65, /** M135 E13 (4A90) */
M135E15 = 66, /** M135 E15 (4A91) */
M135E15ATL = 67, /** M135 E15 ATL */
M272DE25 = 68, /** M272 DE25 */
M272DE30 = 69, /** M272 DE30 */
M272DE35 = 70, /** M272 DE35 */
M273DE46 = 71, /** M273 DE46 */
M273DE55 = 72, /** M273 DE55 */
M271E18MLATTR115 = 79, /** M271 E18 ML Attr. (115kW) */
M271E18MLATTR141 = 80, /** M271 E18 ML Attr. (141kW) */
OM629DE40LA = 96, /** OM629 DE40 LA */
OM642DE30LARED140 = 99, /** OM642 DE30 LA red. (140kW) */
};
enum class MS_608_PFW {
OK = 0, /** No warning */
PFW1 = 1, /** Warning filter closed, level 1 */
PFW2 = 2, /** Warning filter closed, level 2 */
SNV = 3, /** signal not available */
};
typedef union {
uint8_t bytes[8];
uint64_t raw;
// Sets engine coolant temperature
void set_T_MOT(uint8_t value){ raw = (raw & 0x00ffffffffffffff) | ((uint64_t)value & 0xff) << 56; }
// Gets engine coolant temperature
uint8_t get_T_MOT() { return raw >> 56 & 0xff; }
// Sets intake air temperature
void set_T_LUFT(uint8_t value){ raw = (raw & 0xff00ffffffffffff) | ((uint64_t)value & 0xff) << 48; }
// Gets intake air temperature
uint8_t get_T_LUFT() { return raw >> 48 & 0xff; }
// Sets vehicle code series
void set_MS_608_FCOD_BR(MS_608_FCOD_BR value){ raw = (raw & 0xffffe0ffffffffff) | ((uint64_t)value & 0x1f) << 40; }
// Gets vehicle code series
MS_608_FCOD_BR get_FCOD_BR() { return (MS_608_FCOD_BR)(raw >> 40 & 0x1f); }
// Sets vehicle code body
void set_MS_608_FCOD_KAR(MS_608_FCOD_KAR value){ raw = (raw & 0xffff1fffffffffff) | ((uint64_t)value & 0x7) << 45; }
// Gets vehicle code body
MS_608_FCOD_KAR get_FCOD_KAR() { return (MS_608_FCOD_KAR)(raw >> 45 & 0x7); }
// Sets Vehicle code motor 7Bit, Bit0-5 (Bit6 -> Signal FCOD_MOT6)
void set_MS_608_FCOD_MOT(MS_608_FCOD_MOT value){ raw = (raw & 0xffffffc0ffffffff) | ((uint64_t)value & 0x3f) << 32; }
// Gets Vehicle code motor 7Bit, Bit0-5 (Bit6 -> Signal FCOD_MOT6)
MS_608_FCOD_MOT get_FCOD_MOT() { return (MS_608_FCOD_MOT)(raw >> 32 & 0x3f); }
// Sets transmission control not available
void set_GS_NVH(bool value){ raw = (raw & 0xffffffbfffffffff) | ((uint64_t)value & 0x1) << 38; }
// Gets transmission control not available
bool get_GS_NVH() { return raw >> 38 & 0x1; }
// Sets Vehicle code engine with 7 bits, bit 6
void set_FCOD_MOT6(bool value){ raw = (raw & 0xffffff7fffffffff) | ((uint64_t)value & 0x1) << 39; }
// Gets Vehicle code engine with 7 bits, bit 6
bool get_FCOD_MOT6() { return raw >> 39 & 0x1; }
// Sets Fixed maximum speed
void set_V_MAX_FIX(uint8_t value){ raw = (raw & 0xffffffff00ffffff) | ((uint64_t)value & 0xff) << 24; }
// Gets Fixed maximum speed
uint8_t get_V_MAX_FIX() { return raw >> 24 & 0xff; }
// Sets consumption
void set_VB(short value){ raw = (raw & 0xffffffffff0000ff) | ((uint64_t)value & 0xffff) << 8; }
// Gets consumption
short get_VB() { return raw >> 8 & 0xffff; }
// Sets Particle filter correction offset FMMOTMAX
void set_PFKO(uint8_t value){ raw = (raw & 0xfffffffffffffff0) | ((uint64_t)value & 0xf) << 0; }
// Gets Particle filter correction offset FMMOTMAX
uint8_t get_PFKO() { return raw >> 0 & 0xf; }
// Sets switch on additional consumer
void set_ZVB_EIN_MS(bool value){ raw = (raw & 0xffffffffffffffef) | ((uint64_t)value & 0x1) << 4; }
// Gets switch on additional consumer
bool get_ZVB_EIN_MS() { return raw >> 4 & 0x1; }
// Sets Particle filter warning
void set_MS_608_PFW(MS_608_PFW value){ raw = (raw & 0xffffffffffffff9f) | ((uint64_t)value & 0x3) << 5; }
// Gets Particle filter warning
MS_608_PFW get_PFW() { return (MS_608_PFW)(raw >> 5 & 0x3); }
// Sets switch on additional water pump
void set_ZWP_EIN_MS(bool value){ raw = (raw & 0xffffffffffffff7f) | ((uint64_t)value & 0x1) << 7; }
// Gets switch on additional water pump
bool get_ZWP_EIN_MS() { return raw >> 7 & 0x1; }
/** Imports the frame data from a source */
void import_frame(uint32_t cid, uint8_t* data, uint8_t len) {
if (cid == MS_608_ID) {
for (int i = 0; i < len; i++) {
bytes[7-i] = data[i];
}
}
}
/** Exports the frame data to a destination */
void export_frame(uint32_t* cid, uint8_t* data, uint8_t* len) {
*cid = MS_608_ID;
*len = 8;
for (int i = 0; i < *len; i++) {
data[i] = bytes[7-i];
}
}
} MS_608;
#endif

View File

@ -1,92 +0,0 @@
#ifndef MS_ANZ_H_
#define MS_ANZ_H_
/**
* AUTOGENERATED BY gen_unions.py
*/
#include <stdint.h>
#define MS_ANZ_ID 0x033D
enum class MS_ANZ_ASS_DSPL {
IDLE = 0, /** No status */
M1 = 1, /** message "ASS not active: motor warm-up" */
M2 = 2, /** message "ASS active: driving mode" */
M3 = 3, /** message "ASS active: stop mode" */
M4 = 4, /** Message "ASS not active: electrical energy demand" */
M5 = 5, /** Message "ASS not active: air conditioning on" */
M6 = 6, /** Message "ASS not active: fault" */
M7 = 7, /** Message "ASS active: electrical energy demand, please start the engine" */
M8 = 8, /** Message "ASS active: Use the clutch to start" */
M9 = 9, /** Message "ASS active: Air conditioning? Please start the engine" */
M10 = 10, /** Message "ASS active: Ignition off when leaving!" */
M11 = 11, /** message "ASS deactivated" */
M12 = 12, /** Message "ASS activated" */
M13 = 13, /** Message "ASS: Display defective" */
M14 = 14, /** not defined */
M15 = 15, /** undefined */
};
enum class MS_ANZ_ASS_WARN {
IDLE = 0, /** No status */
M1 = 1, /** message "ASS not active: motor warm-up" */
M2 = 2, /** message "ASS active: driving mode" */
M3 = 3, /** message "ASS active: stop mode" */
M4 = 4, /** Message "ASS not active: electrical energy demand" */
M5 = 5, /** Message "ASS not active: air conditioning on" */
M6 = 6, /** Message "ASS not active: fault" */
M7 = 7, /** Message "ASS active: electrical energy demand, please start the engine" */
M8 = 8, /** Message "ASS active: Use the clutch to start" */
M9 = 9, /** Message "ASS active: Air conditioning? Please start the engine" */
M10 = 10, /** Message "ASS active: Ignition off when leaving!" */
M11 = 11, /** message "ASS deactivated" */
M12 = 12, /** Message "ASS activated" */
M13 = 13, /** Message "ASS: Display defective" */
M14 = 14, /** not defined */
M15 = 15, /** undefined */
};
typedef union {
uint8_t bytes[8];
uint64_t raw;
// Sets number of the ASS status message
void set_MS_ANZ_ASS_DSPL(MS_ANZ_ASS_DSPL value){ raw = (raw & 0xfffff0ffffffffff) | ((uint64_t)value & 0xf) << 40; }
// Gets number of the ASS status message
MS_ANZ_ASS_DSPL get_ASS_DSPL() { return (MS_ANZ_ASS_DSPL)(raw >> 40 & 0xf); }
// Sets number of the ASS warning message
void set_MS_ANZ_ASS_WARN(MS_ANZ_ASS_WARN value){ raw = (raw & 0xffff0fffffffffff) | ((uint64_t)value & 0xf) << 44; }
// Gets number of the ASS warning message
MS_ANZ_ASS_WARN get_ASS_WARN() { return (MS_ANZ_ASS_WARN)(raw >> 44 & 0xf); }
// Sets Suppression of lamp test during the stop phase
void set_ASS_LTEST_AUS(bool value){ raw = (raw & 0xffffff7fffffffff) | ((uint64_t)value & 0x1) << 39; }
// Gets Suppression of lamp test during the stop phase
bool get_ASS_LTEST_AUS() { return raw >> 39 & 0x1; }
/** Imports the frame data from a source */
void import_frame(uint32_t cid, uint8_t* data, uint8_t len) {
if (cid == MS_ANZ_ID) {
for (int i = 0; i < len; i++) {
bytes[7-i] = data[i];
}
}
}
/** Exports the frame data to a destination */
void export_frame(uint32_t* cid, uint8_t* data, uint8_t* len) {
*cid = MS_ANZ_ID;
*len = 8;
for (int i = 0; i < *len; i++) {
data[i] = bytes[7-i];
}
}
} MS_ANZ;
#endif

View File

@ -1,99 +0,0 @@
#ifndef PSM_3B4_H_
#define PSM_3B4_H_
/**
* AUTOGENERATED BY gen_unions.py
*/
#include <stdint.h>
#define PSM_3B4_ID 0x03B4
typedef union {
uint8_t bytes[8];
uint64_t raw;
// Sets Working speed control active
void set_PSM_ADR_AKT(bool value){ raw = (raw & 0xdfffffffffffffff) | ((uint64_t)value & 0x1) << 61; }
// Gets Working speed control active
bool get_PSM_ADR_AKT() { return raw >> 61 & 0x1; }
// Sets working speed control
void set_PSM_ADR_TGL(bool value){ raw = (raw & 0xbfffffffffffffff) | ((uint64_t)value & 0x1) << 62; }
// Gets working speed control
bool get_PSM_ADR_TGL() { return raw >> 62 & 0x1; }
// Sets working speed control
void set_PSM_ADR_PAR(bool value){ raw = (raw & 0x7fffffffffffffff) | ((uint64_t)value & 0x1) << 63; }
// Gets working speed control
bool get_PSM_ADR_PAR() { return raw >> 63 & 0x1; }
// Sets Motor target speed ADR
void set_PSM_N_SOLL(short value){ raw = (raw & 0xff0000ffffffffff) | ((uint64_t)value & 0xffff) << 40; }
// Gets Motor target speed ADR
short get_PSM_N_SOLL() { return raw >> 40 & 0xffff; }
// Sets torque limitation active
void set_PSM_MOM_AKT(bool value){ raw = (raw & 0xffffffdfffffffff) | ((uint64_t)value & 0x1) << 37; }
// Gets torque limitation active
bool get_PSM_MOM_AKT() { return raw >> 37 & 0x1; }
// Sets torque limit
void set_PSM_MOM_TGL(bool value){ raw = (raw & 0xffffffbfffffffff) | ((uint64_t)value & 0x1) << 38; }
// Gets torque limit
bool get_PSM_MOM_TGL() { return raw >> 38 & 0x1; }
// Sets torque limitation
void set_PSM_MOM_PAR(bool value){ raw = (raw & 0xffffff7fffffffff) | ((uint64_t)value & 0x1) << 39; }
// Gets torque limitation
bool get_PSM_MOM_PAR() { return raw >> 39 & 0x1; }
// Sets Maximum motor torque
void set_PSM_MOM_SOLL(short value){ raw = (raw & 0xffffffe000ffffff) | ((uint64_t)value & 0x1fff) << 24; }
// Gets Maximum motor torque
short get_PSM_MOM_SOLL() { return raw >> 24 & 0x1fff; }
// Sets speed limitation active
void set_PSM_DZ_AKT(bool value){ raw = (raw & 0xffffffffffdfffff) | ((uint64_t)value & 0x1) << 21; }
// Gets speed limitation active
bool get_PSM_DZ_AKT() { return raw >> 21 & 0x1; }
// Sets speed limitation
void set_PSM_DZ_TGL(bool value){ raw = (raw & 0xffffffffffbfffff) | ((uint64_t)value & 0x1) << 22; }
// Gets speed limitation
bool get_PSM_DZ_TGL() { return raw >> 22 & 0x1; }
// Sets speed limitation
void set_PSM_DZ_PAR(bool value){ raw = (raw & 0xffffffffff7fffff) | ((uint64_t)value & 0x1) << 23; }
// Gets speed limitation
bool get_PSM_DZ_PAR() { return raw >> 23 & 0x1; }
// Sets maximum speed
void set_PSM_DZ_MAX(short value){ raw = (raw & 0xffffffffffff0000) | ((uint64_t)value & 0xffff) << 0; }
// Gets maximum speed
short get_PSM_DZ_MAX() { return raw >> 0 & 0xffff; }
/** Imports the frame data from a source */
void import_frame(uint32_t cid, uint8_t* data, uint8_t len) {
if (cid == PSM_3B4_ID) {
for (int i = 0; i < len; i++) {
bytes[7-i] = data[i];
}
}
}
/** Exports the frame data to a destination */
void export_frame(uint32_t* cid, uint8_t* data, uint8_t* len) {
*cid = PSM_3B4_ID;
*len = 8;
for (int i = 0; i < *len; i++) {
data[i] = bytes[7-i];
}
}
} PSM_3B4;
#endif

View File

@ -1,84 +0,0 @@
#ifndef PSM_3B8_H_
#define PSM_3B8_H_
/**
* AUTOGENERATED BY gen_unions.py
*/
#include <stdint.h>
#define PSM_3B8_ID 0x03B8
typedef union {
uint8_t bytes[8];
uint64_t raw;
// Sets speed limit active
void set_PSM_V_AKT(bool value){ raw = (raw & 0xdfffffffffffffff) | ((uint64_t)value & 0x1) << 61; }
// Gets speed limit active
bool get_PSM_V_AKT() { return raw >> 61 & 0x1; }
// Sets speed limit
void set_PSM_V_TGL(bool value){ raw = (raw & 0xbfffffffffffffff) | ((uint64_t)value & 0x1) << 62; }
// Gets speed limit
bool get_PSM_V_TGL() { return raw >> 62 & 0x1; }
// Sets speed limit
void set_PSM_V_PAR(bool value){ raw = (raw & 0x7fffffffffffffff) | ((uint64_t)value & 0x1) << 63; }
// Gets speed limit
bool get_PSM_V_PAR() { return raw >> 63 & 0x1; }
// Sets speed limit
void set_PSM_V_SOLL(uint8_t value){ raw = (raw & 0xff00ffffffffffff) | ((uint64_t)value & 0xff) << 48; }
// Gets speed limit
uint8_t get_PSM_V_SOLL() { return raw >> 48 & 0xff; }
// Sets Disable accelerator pedal module
void set_PSM_FPM_SP(bool value){ raw = (raw & 0xfffff7ffffffffff) | ((uint64_t)value & 0x1) << 43; }
// Gets Disable accelerator pedal module
bool get_PSM_FPM_SP() { return raw >> 43 & 0x1; }
// Sets Motor remote stop active
void set_PSM_FERN_STOP(bool value){ raw = (raw & 0xffffefffffffffff) | ((uint64_t)value & 0x1) << 44; }
// Gets Motor remote stop active
bool get_PSM_FERN_STOP() { return raw >> 44 & 0x1; }
// Sets Motor remote start active
void set_PSM_FERN_START(bool value){ raw = (raw & 0xffffdfffffffffff) | ((uint64_t)value & 0x1) << 45; }
// Gets Motor remote start active
bool get_PSM_FERN_START() { return raw >> 45 & 0x1; }
// Sets speed limitation
void set_PSM_DZ_TGL(bool value){ raw = (raw & 0xffffbfffffffffff) | ((uint64_t)value & 0x1) << 46; }
// Gets speed limitation
bool get_PSM_DZ_TGL() { return raw >> 46 & 0x1; }
// Sets speed limitation
void set_PSM_DZ_PAR(bool value){ raw = (raw & 0xffff7fffffffffff) | ((uint64_t)value & 0x1) << 47; }
// Gets speed limitation
bool get_PSM_DZ_PAR() { return raw >> 47 & 0x1; }
/** Imports the frame data from a source */
void import_frame(uint32_t cid, uint8_t* data, uint8_t len) {
if (cid == PSM_3B8_ID) {
for (int i = 0; i < len; i++) {
bytes[7-i] = data[i];
}
}
}
/** Exports the frame data to a destination */
void export_frame(uint32_t* cid, uint8_t* data, uint8_t* len) {
*cid = PSM_3B8_ID;
*len = 8;
for (int i = 0; i < *len; i++) {
data[i] = bytes[7-i];
}
}
} PSM_3B8;
#endif

View File

@ -1,110 +0,0 @@
#ifndef SBW_232_H_
#define SBW_232_H_
/**
* AUTOGENERATED BY gen_unions.py
*/
#include <stdint.h>
#define SBW_232_ID 0x0232
enum class SBW_232_LRT_PM3 {
NBET = 0, /** Not actuated */
PLUS = 1, /** "+" pressed */
MINUS = 2, /** "-" pressed */
PLUS_MINUS = 3, /** "+" and "-" pressed */
NOT_DEFINED_0 = 4, /** not defined */
NOT_DEFINED_1 = 5, /** not defined */
NOT_DEFINED_2 = 6, /** not defined */
SNV = 7, /** signal not available */
};
enum class SBW_232_SID_SBW {
EWM = 0, /** EWM */
MRM = 1, /** MRM */
NOT_DEFINED_0 = 2, /** not defined */
NOT_DEFINED_1 = 3, /** not defined */
};
enum class SBW_232_SBWB_ST_RND {
IDLE = 0, /** SBW control element in rest position */
R = 1, /** SBW control element in "R" */
N_OBEN = 2, /** SBW control element in "N above" */
N_UNTEN = 4, /** SBW control element in "N down" */
INIT = 6, /** SBW control element in initialization */
D = 8, /** SBW control element in "D" */
SNV = 15, /** signal not available */
};
enum class SBW_232_SBWB_ST_P {
IDLE = 0, /** P button in rest position */
P = 1, /** P button in "P" position */
INIT = 2, /** P button initialization */
SNV = 3, /** signal not available */
};
enum class SBW_232_SBWB_ID {
GWHST_LR = 0, /** GWHST_LR valid on bit 0..7 (old signal) */
RES_ALT_FEHLER = 2, /** Reserved old signal "ERROR MRSM" */
SBWB_ST_P_RND = 3, /** SBWB_ST P, RND valid on bit 0..5 (new signals) */
};
typedef union {
uint8_t bytes[8];
uint64_t raw;
// Sets Steering wheel buttons "+", "-" pressed
void set_SBW_232_LRT_PM3(SBW_232_LRT_PM3 value){ raw = (raw & 0xf8ffffffffffffff) | ((uint64_t)value & 0x7) << 56; }
// Gets Steering wheel buttons "+", "-" pressed
SBW_232_LRT_PM3 get_LRT_PM3() { return (SBW_232_LRT_PM3)(raw >> 56 & 0x7); }
// Sets sender identification
void set_SBW_232_SID_SBW(SBW_232_SID_SBW value){ raw = (raw & 0x3fffffffffffffff) | ((uint64_t)value & 0x3) << 62; }
// Gets sender identification
SBW_232_SID_SBW get_SID_SBW() { return (SBW_232_SID_SBW)(raw >> 62 & 0x3); }
// Sets Shift-by-wire control element Status RND
void set_SBW_232_SBWB_ST_RND(SBW_232_SBWB_ST_RND value){ raw = (raw & 0xfff0ffffffffffff) | ((uint64_t)value & 0xf) << 48; }
// Gets Shift-by-wire control element Status RND
SBW_232_SBWB_ST_RND get_SBWB_ST_RND() { return (SBW_232_SBWB_ST_RND)(raw >> 48 & 0xf); }
// Sets Shift-by-wire control element P button
void set_SBW_232_SBWB_ST_P(SBW_232_SBWB_ST_P value){ raw = (raw & 0xffcfffffffffffff) | ((uint64_t)value & 0x3) << 52; }
// Gets Shift-by-wire control element P button
SBW_232_SBWB_ST_P get_SBWB_ST_P() { return (SBW_232_SBWB_ST_P)(raw >> 52 & 0x3); }
// Sets Shift-by-wire control element identification
void set_SBW_232_SBWB_ID(SBW_232_SBWB_ID value){ raw = (raw & 0xff3fffffffffffff) | ((uint64_t)value & 0x3) << 54; }
// Gets Shift-by-wire control element identification
SBW_232_SBWB_ID get_SBWB_ID() { return (SBW_232_SBWB_ID)(raw >> 54 & 0x3); }
// Sets message counter
void set_BZ232h(uint8_t value){ raw = (raw & 0xffff0fffffffffff) | ((uint64_t)value & 0xf) << 44; }
// Gets message counter
uint8_t get_BZ232h() { return raw >> 44 & 0xf; }
/** Imports the frame data from a source */
void import_frame(uint32_t cid, uint8_t* data, uint8_t len) {
if (cid == SBW_232_ID) {
for (int i = 0; i < len; i++) {
bytes[7-i] = data[i];
}
}
}
/** Exports the frame data to a destination */
void export_frame(uint32_t* cid, uint8_t* data, uint8_t* len) {
*cid = SBW_232_ID;
*len = 8;
for (int i = 0; i < *len; i++) {
data[i] = bytes[7-i];
}
}
} SBW_232;
#endif

View File

@ -1,79 +0,0 @@
#ifndef VG_428_H_
#define VG_428_H_
/**
* AUTOGENERATED BY gen_unions.py
*/
#include <stdint.h>
#define VG_428_ID 0x0428
enum class VG_428_VG_GANG {
SH_IPG = 0, /** shift in progress */
LO = 1, /** off-road gear (low range) */
HI = 2, /** street gang (high range) */
N = 4, /** neutral gear (not high or low range) */
SNV = 7, /** signal not available */
};
enum class VG_428_ANFN_VG {
NOT_DEFINED = 0, /** not defined */
ANF_N = 1, /** "Neutral" request */
IDLE = 2, /** No requirement */
SNV = 3, /** signal not available */
};
typedef union {
uint8_t bytes[8];
uint64_t raw;
// Sets Current gear transfer case
void set_VG_428_VG_GANG(VG_428_VG_GANG value){ raw = (raw & 0xf8ffffffffffffff) | ((uint64_t)value & 0x7) << 56; }
// Gets Current gear transfer case
VG_428_VG_GANG get_VG_GANG() { return (VG_428_VG_GANG)(raw >> 56 & 0x7); }
// Sets VG error (ECU failure detected)
void set_VG_ERR(bool value){ raw = (raw & 0xdfffffffffffffff) | ((uint64_t)value & 0x1) << 61; }
// Gets VG error (ECU failure detected)
bool get_VG_ERR() { return raw >> 61 & 0x1; }
// Sets VG
void set_VG_428_ANFN_VG(VG_428_ANFN_VG value){ raw = (raw & 0xfffcffffffffffff) | ((uint64_t)value & 0x3) << 48; }
// Gets VG
VG_428_ANFN_VG get_ANFN_VG() { return (VG_428_ANFN_VG)(raw >> 48 & 0x3); }
// Sets VG
void set_ANFNTGL_VG(bool value){ raw = (raw & 0xfffbffffffffffff) | ((uint64_t)value & 0x1) << 50; }
// Gets VG
bool get_ANFNTGL_VG() { return raw >> 50 & 0x1; }
// Sets VG
void set_ANFNPAR_VG(bool value){ raw = (raw & 0xfff7ffffffffffff) | ((uint64_t)value & 0x1) << 51; }
// Gets VG
bool get_ANFNPAR_VG() { return raw >> 51 & 0x1; }
/** Imports the frame data from a source */
void import_frame(uint32_t cid, uint8_t* data, uint8_t len) {
if (cid == VG_428_ID) {
for (int i = 0; i < len; i++) {
bytes[7-i] = data[i];
}
}
}
/** Exports the frame data to a destination */
void export_frame(uint32_t* cid, uint8_t* data, uint8_t* len) {
*cid = VG_428_ID;
*len = 8;
for (int i = 0; i < *len; i++) {
data[i] = bytes[7-i];
}
}
} VG_428;
#endif

View File

@ -1,76 +0,0 @@
#ifndef ZGW_248_H_
#define ZGW_248_H_
/**
* AUTOGENERATED BY gen_unions.py
*/
#include <stdint.h>
#define ZGW_248_ID 0x0248
enum class ZGW_248_ANH_ERK2 {
NONE = 0, /** Trailer not recognized */
OK = 1, /** trailer recognized */
NOT_DEFINED = 2, /** not defined */
SNV = 3, /** signal not available */
};
typedef union {
uint8_t bytes[8];
uint64_t raw;
// Sets switch on low beam
void set_ABL_EIN(bool value){ raw = (raw & 0xefffffffffffffff) | ((uint64_t)value & 0x1) << 60; }
// Gets switch on low beam
bool get_ABL_EIN() { return raw >> 60 & 0x1; }
// Sets Start Xenon4 diagnostic procedure on the driver's side
void set_DIAG_X4_F(bool value){ raw = (raw & 0xbfffffffffffffff) | ((uint64_t)value & 0x1) << 62; }
// Gets Start Xenon4 diagnostic procedure on the driver's side
bool get_DIAG_X4_F() { return raw >> 62 & 0x1; }
// Sets Start Xenon4 diagnostic procedure on the passenger side
void set_DIAG_X4_B(bool value){ raw = (raw & 0x7fffffffffffffff) | ((uint64_t)value & 0x1) << 63; }
// Gets Start Xenon4 diagnostic procedure on the passenger side
bool get_DIAG_X4_B() { return raw >> 63 & 0x1; }
// Sets Trailer operation detected
void set_ZGW_248_ANH_ERK2(ZGW_248_ANH_ERK2 value){ raw = (raw & 0xfffcffffffffffff) | ((uint64_t)value & 0x3) << 48; }
// Gets Trailer operation detected
ZGW_248_ANH_ERK2 get_ANH_ERK2() { return (ZGW_248_ANH_ERK2)(raw >> 48 & 0x3); }
// Sets Auxiliary water pump is running
void set_ZWP_LFT(bool value){ raw = (raw & 0xfffbffffffffffff) | ((uint64_t)value & 0x1) << 50; }
// Gets Auxiliary water pump is running
bool get_ZWP_LFT() { return raw >> 50 & 0x1; }
// Sets AFL request: switch on low beam
void set_AFL_ABL_EIN(bool value){ raw = (raw & 0xfff7ffffffffffff) | ((uint64_t)value & 0x1) << 51; }
// Gets AFL request: switch on low beam
bool get_AFL_ABL_EIN() { return raw >> 51 & 0x1; }
/** Imports the frame data from a source */
void import_frame(uint32_t cid, uint8_t* data, uint8_t len) {
if (cid == ZGW_248_ID) {
for (int i = 0; i < len; i++) {
bytes[7-i] = data[i];
}
}
}
/** Exports the frame data to a destination */
void export_frame(uint32_t* cid, uint8_t* data, uint8_t* len) {
*cid = ZGW_248_ID;
*len = 8;
for (int i = 0; i < *len; i++) {
data[i] = bytes[7-i];
}
}
} ZGW_248;
#endif

View File

@ -1,49 +0,0 @@
#ifndef ZGW_24C_H_
#define ZGW_24C_H_
/**
* AUTOGENERATED BY gen_unions.py
*/
#include <stdint.h>
#define ZGW_24C_ID 0x024C
typedef union {
uint8_t bytes[8];
uint64_t raw;
// Sets low beam defective driver / left (depending on BR)
void set_ABL_DEF_F_L(bool value){ raw = (raw & 0xfffffffffeffffff) | ((uint64_t)value & 0x1) << 24; }
// Gets low beam defective driver / left (depending on BR)
bool get_ABL_DEF_F_L() { return raw >> 24 & 0x1; }
// Sets dipped beam defective passenger / right (depending on BR)
void set_ABL_DEF_BF_R(bool value){ raw = (raw & 0xfffffffffdffffff) | ((uint64_t)value & 0x1) << 25; }
// Gets dipped beam defective passenger / right (depending on BR)
bool get_ABL_DEF_BF_R() { return raw >> 25 & 0x1; }
/** Imports the frame data from a source */
void import_frame(uint32_t cid, uint8_t* data, uint8_t len) {
if (cid == ZGW_24C_ID) {
for (int i = 0; i < len; i++) {
bytes[7-i] = data[i];
}
}
}
/** Exports the frame data to a destination */
void export_frame(uint32_t* cid, uint8_t* data, uint8_t* len) {
*cid = ZGW_24C_ID;
*len = 8;
for (int i = 0; i < *len; i++) {
data[i] = bytes[7-i];
}
}
} ZGW_24C;
#endif

View File

@ -11,10 +11,10 @@
[env:esp-wrover-kit]
platform = espressif32
board = esp-wrover-kit
board_build.f_cpu = 240000000L ; 240Mhz
framework = espidf
board_build.f_flash = 80000000L
upload_speed = 921600
upload_port = /dev/ttyUSB0
build_flags = -Wall -DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue
monitor_speed = 115200
monitor_speed = 115200
monitor_port = /dev/ttyUSB0
build_flags = -Wall

View File

@ -39,9 +39,9 @@ CONFIG_APP_RETRIEVE_LEN_ELF_SHA=16
# Bootloader config
#
CONFIG_BOOTLOADER_OFFSET_IN_FLASH=0x1000
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE is not set
# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_DEBUG is not set
# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_PERF is not set
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_PERF=y
# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_NONE is not set
# CONFIG_BOOTLOADER_LOG_LEVEL_NONE is not set
CONFIG_BOOTLOADER_LOG_LEVEL_ERROR=y
@ -59,10 +59,10 @@ CONFIG_BOOTLOADER_WDT_ENABLE=y
# CONFIG_BOOTLOADER_WDT_DISABLE_IN_USER_CODE is not set
CONFIG_BOOTLOADER_WDT_TIME_MS=9000
# CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE is not set
# CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP is not set
# CONFIG_BOOTLOADER_SKIP_VALIDATE_ON_POWER_ON is not set
# CONFIG_BOOTLOADER_SKIP_VALIDATE_ALWAYS is not set
CONFIG_BOOTLOADER_RESERVE_RTC_SIZE=0
CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP=y
CONFIG_BOOTLOADER_SKIP_VALIDATE_ON_POWER_ON=y
CONFIG_BOOTLOADER_SKIP_VALIDATE_ALWAYS=y
CONFIG_BOOTLOADER_RESERVE_RTC_SIZE=0x10
# CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC is not set
# end of Bootloader config
@ -90,11 +90,11 @@ CONFIG_ESPTOOLPY_FLASHFREQ_80M=y
# CONFIG_ESPTOOLPY_FLASHFREQ_20M is not set
CONFIG_ESPTOOLPY_FLASHFREQ="80m"
# CONFIG_ESPTOOLPY_FLASHSIZE_1MB is not set
# CONFIG_ESPTOOLPY_FLASHSIZE_2MB is not set
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_ESPTOOLPY_FLASHSIZE_2MB=y
# CONFIG_ESPTOOLPY_FLASHSIZE_4MB is not set
# CONFIG_ESPTOOLPY_FLASHSIZE_8MB is not set
# CONFIG_ESPTOOLPY_FLASHSIZE_16MB is not set
CONFIG_ESPTOOLPY_FLASHSIZE="4MB"
CONFIG_ESPTOOLPY_FLASHSIZE="2MB"
CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y
CONFIG_ESPTOOLPY_BEFORE_RESET=y
# CONFIG_ESPTOOLPY_BEFORE_NORESET is not set
@ -117,11 +117,11 @@ CONFIG_ESPTOOLPY_MONITOR_BAUD=115200
#
# Partition Table
#
# CONFIG_PARTITION_TABLE_SINGLE_APP is not set
CONFIG_PARTITION_TABLE_TWO_OTA=y
CONFIG_PARTITION_TABLE_SINGLE_APP=y
# CONFIG_PARTITION_TABLE_TWO_OTA is not set
# CONFIG_PARTITION_TABLE_CUSTOM is not set
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
CONFIG_PARTITION_TABLE_FILENAME="partitions_two_ota.csv"
CONFIG_PARTITION_TABLE_FILENAME="partitions_singleapp.csv"
CONFIG_PARTITION_TABLE_OFFSET=0x8000
CONFIG_PARTITION_TABLE_MD5=y
# end of Partition Table
@ -129,9 +129,9 @@ CONFIG_PARTITION_TABLE_MD5=y
#
# Compiler options
#
CONFIG_COMPILER_OPTIMIZATION_DEFAULT=y
# CONFIG_COMPILER_OPTIMIZATION_DEFAULT is not set
# CONFIG_COMPILER_OPTIMIZATION_SIZE is not set
# CONFIG_COMPILER_OPTIMIZATION_PERF is not set
CONFIG_COMPILER_OPTIMIZATION_PERF=y
# CONFIG_COMPILER_OPTIMIZATION_NONE is not set
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE=y
# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT is not set
@ -494,7 +494,7 @@ CONFIG_SPI_SLAVE_ISR_IN_IRAM=y
#
# TWAI configuration
#
# CONFIG_TWAI_ISR_IN_IRAM is not set
CONFIG_TWAI_ISR_IN_IRAM=y
# CONFIG_TWAI_ERRATA_FIX_BUS_OFF_REC is not set
# CONFIG_TWAI_ERRATA_FIX_TX_INTR_LOST is not set
# CONFIG_TWAI_ERRATA_FIX_RX_FRAME_INVALID is not set
@ -568,13 +568,13 @@ CONFIG_SPIRAM_SIZE=-1
# CONFIG_SPIRAM_SPEED_40M is not set
CONFIG_SPIRAM_SPEED_80M=y
CONFIG_SPIRAM=y
CONFIG_SPIRAM_BOOT_INIT=y
CONFIG_SPIRAM_IGNORE_NOTFOUND=y
# CONFIG_SPIRAM_BOOT_INIT is not set
# CONFIG_SPIRAM_USE_MEMMAP is not set
CONFIG_SPIRAM_USE_CAPS_ALLOC=y
# CONFIG_SPIRAM_USE_MALLOC is not set
# CONFIG_SPIRAM_MEMTEST is not set
# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set
CONFIG_SPIRAM_USE_MALLOC=y
CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=16384
# CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP is not set
CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=32768
# CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set
CONFIG_SPIRAM_CACHE_WORKAROUND=y
@ -588,6 +588,7 @@ CONFIG_SPIRAM_CACHE_WORKAROUND_STRATEGY_MEMW=y
CONFIG_SPIRAM_BANKSWITCH_ENABLE=y
CONFIG_SPIRAM_BANKSWITCH_RESERVE=8
# CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY is not set
# CONFIG_SPIRAM_OCCUPY_HSPI_HOST is not set
CONFIG_SPIRAM_OCCUPY_VSPI_HOST=y
# CONFIG_SPIRAM_OCCUPY_NO_HOST is not set
@ -706,8 +707,7 @@ CONFIG_ESP_MAC_ADDR_UNIVERSE_ETH=y
# Event Loop Library
#
# CONFIG_ESP_EVENT_LOOP_PROFILING is not set
CONFIG_ESP_EVENT_POST_FROM_ISR=y
CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR=y
# CONFIG_ESP_EVENT_POST_FROM_ISR is not set
# end of Event Loop Library
#
@ -751,7 +751,7 @@ CONFIG_HTTPD_PURGE_BUF_LEN=32
CONFIG_ESP_NETIF_IP_LOST_TIMER_INTERVAL=120
CONFIG_ESP_NETIF_TCPIP_LWIP=y
# CONFIG_ESP_NETIF_LOOPBACK is not set
# CONFIG_ESP_NETIF_TCPIP_ADAPTER_COMPATIBLE_LAYER is not set
CONFIG_ESP_NETIF_TCPIP_ADAPTER_COMPATIBLE_LAYER=y
# end of ESP NETIF Adapter
#
@ -791,14 +791,15 @@ CONFIG_ESP_TIMER_IMPL_TG0_LAC=y
CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE=y
CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=10
CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=32
# CONFIG_ESP32_WIFI_STATIC_TX_BUFFER is not set
CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER=y
CONFIG_ESP32_WIFI_TX_BUFFER_TYPE=1
CONFIG_ESP32_WIFI_STATIC_TX_BUFFER=y
CONFIG_ESP32_WIFI_TX_BUFFER_TYPE=0
CONFIG_ESP32_WIFI_STATIC_TX_BUFFER_NUM=16
CONFIG_ESP32_WIFI_CACHE_TX_BUFFER_NUM=32
CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=32
# CONFIG_ESP32_WIFI_CSI_ENABLED is not set
# CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED is not set
# CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED is not set
CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED=y
CONFIG_ESP32_WIFI_TX_BA_WIN=6
CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=y
CONFIG_ESP32_WIFI_RX_BA_WIN=6
# CONFIG_ESP32_WIFI_AMSDU_TX_ENABLED is not set
# CONFIG_ESP32_WIFI_NVS_ENABLED is not set
CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_0=y
@ -914,7 +915,7 @@ CONFIG_FREERTOS_ASSERT_FAIL_ABORT=y
# CONFIG_FREERTOS_ASSERT_FAIL_PRINT_CONTINUE is not set
# CONFIG_FREERTOS_ASSERT_DISABLE is not set
CONFIG_FREERTOS_IDLE_TASK_STACKSIZE=2304
CONFIG_FREERTOS_ISR_STACKSIZE=2096
CONFIG_FREERTOS_ISR_STACKSIZE=1536
# CONFIG_FREERTOS_LEGACY_HOOKS is not set
CONFIG_FREERTOS_MAX_TASK_NAME_LEN=16
CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION=y
@ -925,7 +926,6 @@ CONFIG_FREERTOS_TIMER_QUEUE_LENGTH=10
CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE=0
# CONFIG_FREERTOS_USE_TRACE_FACILITY is not set
# CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS is not set
CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER=y
CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER=y
# CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE is not set
# CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH is not set
@ -962,10 +962,10 @@ CONFIG_HEAP_TRACING_OFF=y
# CONFIG_LOG_DEFAULT_LEVEL_NONE is not set
# CONFIG_LOG_DEFAULT_LEVEL_ERROR is not set
# CONFIG_LOG_DEFAULT_LEVEL_WARN is not set
# CONFIG_LOG_DEFAULT_LEVEL_INFO is not set
CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y
CONFIG_LOG_DEFAULT_LEVEL_INFO=y
# CONFIG_LOG_DEFAULT_LEVEL_DEBUG is not set
# CONFIG_LOG_DEFAULT_LEVEL_VERBOSE is not set
CONFIG_LOG_DEFAULT_LEVEL=4
CONFIG_LOG_DEFAULT_LEVEL=3
# CONFIG_LOG_COLORS is not set
CONFIG_LOG_TIMESTAMP_SOURCE_RTOS=y
# CONFIG_LOG_TIMESTAMP_SOURCE_SYSTEM is not set
@ -1116,8 +1116,8 @@ CONFIG_MBEDTLS_SSL_OUT_CONTENT_LEN=4096
# Certificate Bundle
#
CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y
CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y
# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN is not set
# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL is not set
CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN=y
# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE is not set
# CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE is not set
# end of Certificate Bundle
@ -1219,7 +1219,7 @@ CONFIG_MBEDTLS_ECP_NIST_OPTIM=y
#
# mDNS
#
CONFIG_MDNS_MAX_SERVICES=10
CONFIG_MDNS_MAX_SERVICES=1
CONFIG_MDNS_TASK_PRIORITY=1
CONFIG_MDNS_TASK_STACK_SIZE=4096
# CONFIG_MDNS_TASK_AFFINITY_NO_AFFINITY is not set
@ -1234,10 +1234,9 @@ CONFIG_MDNS_TIMER_PERIOD_MS=100
#
# ESP-MQTT Configurations
#
CONFIG_MQTT_PROTOCOL_311=y
CONFIG_MQTT_TRANSPORT_SSL=y
CONFIG_MQTT_TRANSPORT_WEBSOCKET=y
CONFIG_MQTT_TRANSPORT_WEBSOCKET_SECURE=y
# CONFIG_MQTT_PROTOCOL_311 is not set
# CONFIG_MQTT_TRANSPORT_SSL is not set
# CONFIG_MQTT_TRANSPORT_WEBSOCKET is not set
# CONFIG_MQTT_MSG_ID_INCREMENTAL is not set
# CONFIG_MQTT_SKIP_PUBLISH_IF_DISCONNECTED is not set
# CONFIG_MQTT_REPORT_DELETED_MESSAGES is not set
@ -1267,9 +1266,9 @@ CONFIG_NEWLIB_STDIN_LINE_ENDING_CR=y
# OpenSSL
#
# CONFIG_OPENSSL_DEBUG is not set
CONFIG_OPENSSL_ERROR_STACK=y
# CONFIG_OPENSSL_ASSERT_DO_NOTHING is not set
CONFIG_OPENSSL_ASSERT_EXIT=y
# CONFIG_OPENSSL_ERROR_STACK is not set
CONFIG_OPENSSL_ASSERT_DO_NOTHING=y
# CONFIG_OPENSSL_ASSERT_EXIT is not set
# end of OpenSSL
#
@ -1409,7 +1408,7 @@ CONFIG_WIFI_PROV_AUTOSTOP_TIMEOUT=30
#
# Supplicant
#
CONFIG_WPA_MBEDTLS_CRYPTO=y
# CONFIG_WPA_MBEDTLS_CRYPTO is not set
# CONFIG_WPA_WAPI_PSK is not set
# CONFIG_WPA_DEBUG_PRINT is not set
# CONFIG_WPA_TESTING_OPTIONS is not set
@ -1448,7 +1447,7 @@ CONFIG_MONITOR_BAUD_115200B=y
# CONFIG_MONITOR_BAUD_OTHER is not set
CONFIG_MONITOR_BAUD_OTHER_VAL=115200
CONFIG_MONITOR_BAUD=115200
CONFIG_COMPILER_OPTIMIZATION_LEVEL_DEBUG=y
# CONFIG_COMPILER_OPTIMIZATION_LEVEL_DEBUG is not set
# CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE is not set
CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED=y
# CONFIG_OPTIMIZATION_ASSERTIONS_SILENT is not set
@ -1712,8 +1711,7 @@ CONFIG_TASK_WDT_TIMEOUT_S=5
CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU0=y
CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU1=y
# CONFIG_EVENT_LOOP_PROFILING is not set
CONFIG_POST_EVENTS_FROM_ISR=y
CONFIG_POST_EVENTS_FROM_IRAM_ISR=y
# CONFIG_POST_EVENTS_FROM_ISR is not set
# CONFIG_ESP32S2_PANIC_PRINT_HALT is not set
CONFIG_ESP32S2_PANIC_PRINT_REBOOT=y
# CONFIG_ESP32S2_PANIC_SILENT_REBOOT is not set

View File

@ -1,147 +0,0 @@
//
// Created by ashcon on 9/13/21.
//
#ifndef ULTIMATE_NAG52_FW_ABSTRACT_CAN_H
#define ULTIMATE_NAG52_FW_ABSTRACT_CAN_H
#include <config.h>
#include <cstdint>
enum class WheelDirection {
PASSIVE = 0,
FORWARD = 1,
REVERSE = 2,
SNV = 3
};
struct WheelRotation {
uint16_t rpm;
WheelDirection dir;
};
enum class ShifterPosition {
P,
P_R,
R,
R_N,
N,
N_D,
D,
PLUS,
MINUS,
SNV
};
enum class Paddle {
None,
Plus,
Minus,
};
enum class DriveProfileDisplay {
Agility,
Standard,
Comfort,
Manual,
Winter,
FAILURE,
SNV
};
enum class DisplayMessage {
ActuateParkingBrake_WarningTone,
ShiftLeverToN,
ShiftLeverToNToStart,
ApplyBrake,
RequestGearAgain,
Upshift,
Downshift,
VisitWorkshop,
None
};
enum class SpeedStep {
BLANK,
ONE,
TWO,
THREE,
FOUR,
FIVE,
SIX,
SEVEN,
A,
D,
F,
N,
P,
R,
SNV
};
enum class Gear {
R2,
R1,
N,
P,
D1,
D2,
D3,
D4,
D5,
D6,
D7,
SNV,
CANCEL,
PASSIVE
};
enum class ErrorCheck {
WAIT,
OK,
ERROR
};
class AbstractCanHandler {
public:
// Getters
virtual uint16_t get_engine_rpm();
virtual void get_rr_rpm(WheelRotation *dest);
virtual void get_rl_rpm(WheelRotation *dest);
virtual void get_fr_rpm(WheelRotation *dest);
virtual void get_fl_rpm(WheelRotation *dest);
virtual int16_t get_steering_angle();
virtual int16_t get_ambient_temp();
virtual int16_t get_engine_temp();
virtual bool is_profile_toggle_pressed();
virtual ShifterPosition get_shifter_position();
virtual Gear get_abs_target_lower_gear();
virtual Gear get_abs_target_upper_gear();
virtual bool get_abs_request_downshift();
virtual bool get_abs_request_gear_forced();
virtual uint16_t get_engine_static_torque();
virtual uint16_t get_engine_max_torque_dyno();
virtual uint16_t get_engine_max_torque();
virtual uint16_t get_engine_min_torque();
// Setters
virtual void set_is_safe_start(bool can_start);
virtual void set_atf_temp(uint16_t temp);
virtual void set_drive_profile(DriveProfileDisplay p);
virtual void set_display_message(DisplayMessage m);
virtual void set_target_gear(Gear g);
virtual void set_actual_gear(Gear g);
virtual void set_turbine_rpm(uint16_t rpm);
virtual void set_torque_loss_nm(uint16_t loss);
virtual void set_display_speed_step(SpeedStep disp);
virtual void set_status_error_check(ErrorCheck e);
virtual void set_shifter_possition(ShifterPosition g);
uint8_t can_tx_ms;
};
#endif //ULTIMATE_NAG52_FW_ABSTRACT_CAN_H

View File

@ -1,662 +0,0 @@
#include "egs52_can.h"
#include <pins.h>
#include <esp_log.h>
GS_218 gs218;
GS_338 gs338;
GS_418 gs418;
#define LOG_TAG "egs52-can"
#define KWP_RX_ID 0x07E1
#define KWP_TX_ID 0x07E9
Egs52Can::Egs52Can() : AbstractCanHandler()
{
// Set CAN Frame data
gs338.raw = 0xFFFF1FFF00FF0000;
gs418.raw = 0x0000000000000000;
gs218.raw = 0x0000000000000000;
// Set one time parameters
this->can_tx_ms = 20; // 20ms for EGS52
this->bsECU = BS_ECU();
this->ewmECU = EWM_ECU();
gs218.set_GSP_OK(true);
gs218.set_G_G(false);
gs218.set_GS_218_FPC_AAD(GS_218_FPC_AAD::SPORT); // TODO Handle 4WD models
gs218.set_KD(false);
gs218.set_GET_OK(true);
gs218.set_MKRIECH(0xFF);
gs218.set_ERROR(0);
gs418.set_CVT(false);
gs418.set_FRONT(false);
gs418.set_ALL_WHEEL(false);
// Setup CANbus
can_general_config_t g_config = CAN_GENERAL_CONFIG_DEFAULT(PIN_CAN_TX, PIN_CAN_RX, CAN_MODE_NORMAL);
g_config.rx_queue_len = 10;
g_config.tx_queue_len = 4;
can_timing_config_t t_config = CAN_TIMING_CONFIG_500KBITS();
can_filter_config_t f_config = CAN_FILTER_CONFIG_ACCEPT_ALL();
can_driver_install(&g_config, &t_config, &f_config);
can_start();
ESP_LOGD(LOG_TAG, "CAN module started");
this->diag_endpoint = new IsoTpServer(KWP_RX_ID, KWP_TX_ID, 8, 20);
}
Egs52Can::~Egs52Can()
{
vTaskDelete(this->task_handler_tx);
vTaskDelete(this->task_handler_rx);
}
void Egs52Can::__start_thread_tx(void *_this) {
static_cast<Egs52Can*>(_this)->tx_loop();
}
void Egs52Can::__start_thread_rx(void *_this) {
static_cast<Egs52Can*>(_this)->rx_loop();
}
void Egs52Can::start_tx_rx_loop() {
if (this->task_handler_tx == nullptr) {
ESP_LOGD(LOG_TAG, "Starting CAN Tx thread");
xTaskCreate(this->__start_thread_tx, "CAN Tx", 2048, this, 5, this->task_handler_tx);
}
if (this->task_handler_tx == nullptr) {
ESP_LOGD(LOG_TAG, "Starting CAN Rx thread");
xTaskCreate(this->__start_thread_rx, "CAN Rx", 8192, this, 5, this->task_handler_rx);
}
//this->diag_endpoint->create_server_task();
}
void Egs52Can::rx_loop() {
can_message_t rx;
can_status_info_t can_status;
while(true) {
can_get_status_info(&can_status);
while (can_status.msgs_to_rx > 0) {
if (can_receive(&rx, pdMS_TO_TICKS(100)) == ESP_OK && rx.data_length_code != 0 && rx.flags == 0) {
uint64_t now = esp_timer_get_time() / 1000;
bool located = false;
if (this->bsECU.import_can_frame(&rx, now)) {
located = true;
} else if (this->ewmECU.import_can_frame(&rx, now)) {
located = true;
} else if (rx.identifier == KWP_RX_ID && rx.data_length_code == 8 && this->diag_endpoint != nullptr) {
this->diag_endpoint->push_frame(&rx);
}
vTaskDelay(1 / portTICK_RATE_MS);
} else {
vTaskDelay(5 / portTICK_PERIOD_MS); // TODO error in Rx
}
}
if (can_status.msgs_to_rx == 0) {
vTaskDelay(5);
}
}
vTaskDelete(this->task_handler_rx);
}
void Egs52Can::tx_loop() {
can_message_t tx;
tx.flags = CAN_MSG_FLAG_NONE; // For Mercs
while(true) {
uint64_t now = esp_timer_get_time();
gs338.export_frame(&tx.identifier, tx.data, &tx.data_length_code);
can_transmit(&tx, pdMS_TO_TICKS(10));
vTaskDelay(1);
gs218.export_frame(&tx.identifier, tx.data, &tx.data_length_code);
can_transmit(&tx, pdMS_TO_TICKS(10));
vTaskDelay(1);
gs418.export_frame(&tx.identifier, tx.data, &tx.data_length_code);
can_transmit(&tx, pdMS_TO_TICKS(10));
if (this->diag_endpoint != nullptr && this->diag_endpoint->pop_frame(&tx)) {
can_transmit(&tx, pdMS_TO_TICKS(10));
}
uint64_t sleep_time = ((esp_timer_get_time() - now) / 1000);
if (sleep_time > this->can_tx_ms) {
sleep_time = 1;
} else {
sleep_time = this->can_tx_ms - sleep_time;
}
vTaskDelay(sleep_time / portTICK_RATE_MS);
}
vTaskDelete(this->task_handler_tx);
}
uint16_t Egs52Can::get_engine_rpm() {
return 0;
}
void Egs52Can::get_rr_rpm(WheelRotation *dest) {
BS_208* bs208 = this->bsECU.get_bs208();
if (bs208 == nullptr) {
dest->rpm = UINT16_MAX;
dest->dir = WheelDirection::SNV;
} else {
dest->rpm = bs208->get_DHR();
switch(bs208->get_DRTGHR()) {
case BS_208_DRTGHR::PASSIVE:
dest->dir = WheelDirection::PASSIVE;
break;
case BS_208_DRTGHR::FORWARD:
dest->dir = WheelDirection::FORWARD;
break;
case BS_208_DRTGHR::REVERSE:
dest->dir = WheelDirection::REVERSE;
break;
case BS_208_DRTGHR::SNV:
dest->dir = WheelDirection::SNV;
break;
default:
break;
}
}
}
void Egs52Can::get_rl_rpm(WheelRotation *dest) {
BS_208* bs208 = this->bsECU.get_bs208();
if (bs208 == nullptr) {
dest->rpm = UINT16_MAX;
dest->dir = WheelDirection::SNV;
} else {
dest->rpm = bs208->get_DHL();
switch(bs208->get_DRTGHL()) {
case BS_208_DRTGHL::PASSIVE:
dest->dir = WheelDirection::PASSIVE;
break;
case BS_208_DRTGHL::FORWARD:
dest->dir = WheelDirection::FORWARD;
break;
case BS_208_DRTGHL::REVERSE:
dest->dir = WheelDirection::REVERSE;
break;
case BS_208_DRTGHL::SNV:
dest->dir = WheelDirection::SNV;
break;
default:
break;
}
}
}
void Egs52Can::get_fr_rpm(WheelRotation *dest) {
}
void Egs52Can::get_fl_rpm(WheelRotation *dest) {
}
int16_t Egs52Can::get_steering_angle() {
return 0;
}
int16_t Egs52Can::get_ambient_temp() {
return 0;
}
int16_t Egs52Can::get_engine_temp() {
return 0;
}
bool Egs52Can::is_profile_toggle_pressed() {
EWM_230* ptr = this->ewmECU.get_ewm230();
if (ptr == nullptr) {
return false;
} else {
return ptr->get_FPT();
}
}
Gear Egs52Can::get_abs_target_lower_gear() {
return Gear::PASSIVE;
}
Gear Egs52Can::get_abs_target_upper_gear() {
return Gear::PASSIVE;
}
bool Egs52Can::get_abs_request_downshift() {
return false;
}
bool Egs52Can::get_abs_request_gear_forced() {
return false;
}
uint16_t Egs52Can::get_engine_static_torque() {
return 0;
}
uint16_t Egs52Can::get_engine_max_torque_dyno() {
return 0;
}
uint16_t Egs52Can::get_engine_max_torque() {
return 0;
}
uint16_t Egs52Can::get_engine_min_torque() {
return 0;
}
ShifterPosition Egs52Can::get_shifter_position() {
EWM_230* ptr = this->ewmECU.get_ewm230();
if (ptr == nullptr) {
return ShifterPosition::SNV;
} else {
switch (ptr->get_WHC()) {
case EWM_230_WHC::D: /** Selector lever in position "D" */
return ShifterPosition::D;
case EWM_230_WHC::PLUS: /** Selector lever in position "+" */
return ShifterPosition::PLUS;
case EWM_230_WHC::MINUS: /** Selector lever in position "-" */
return ShifterPosition::MINUS;
case EWM_230_WHC::N: /** Selector lever in position "N" */
return ShifterPosition::N;
case EWM_230_WHC::R: /** Selector lever in position "R" */
return ShifterPosition::R;
case EWM_230_WHC::P: /** Selector lever in position "P" */
return ShifterPosition::P;
case EWM_230_WHC::N_ZW_D: /** Selector lever in intermediate position "N-D" */
return ShifterPosition::N_D;
case EWM_230_WHC::R_ZW_N: /** Selector lever in intermediate position "R-N" */
return ShifterPosition::R_N;
case EWM_230_WHC::P_ZW_R: /** Selector lever in intermediate position "P-R" */
return ShifterPosition::P_R;
case EWM_230_WHC::SNV: /** Selector lever position implausible */
default:
return ShifterPosition::SNV;
}
}
}
void Egs52Can::set_is_safe_start(bool can_start) {
gs218.set_ALF(can_start);
}
void Egs52Can::set_atf_temp(uint16_t temp) {
gs418.set_T_GET(temp-50);
}
void Egs52Can::set_drive_profile(DriveProfileDisplay p) {
this->temp = p;
switch (p) {
case DriveProfileDisplay::Agility:
gs418.set_GS_418_FPC(GS_418_FPC::A);
break;
case DriveProfileDisplay::Comfort:
gs418.set_GS_418_FPC(GS_418_FPC::C);
break;
case DriveProfileDisplay::Manual:
gs418.set_GS_418_FPC(GS_418_FPC::M);
break;
case DriveProfileDisplay::Standard:
gs418.set_GS_418_FPC(GS_418_FPC::S);
break;
case DriveProfileDisplay::Winter:
gs418.set_GS_418_FPC(GS_418_FPC::W);
break;
case DriveProfileDisplay::FAILURE:
gs418.set_GS_418_FPC(GS_418_FPC::F);
break;
default:
gs418.set_GS_418_FPC(GS_418_FPC::SNV);
break;
}
}
void Egs52Can::set_display_message(DisplayMessage m) {
if (m == DisplayMessage::None) {
// Set drive profile to clear message
this->set_drive_profile(this->temp);
}
if (this->temp == DriveProfileDisplay::Agility) {
switch (m) {
case DisplayMessage::ActuateParkingBrake_WarningTone:
gs418.set_GS_418_FPC(GS_418_FPC::A_MGFB_WT);
break;
case DisplayMessage::ApplyBrake:
gs418.set_GS_418_FPC(GS_418_FPC::A_MGBB);
break;
case DisplayMessage::RequestGearAgain:
gs418.set_GS_418_FPC(GS_418_FPC::A_MGGEA);
break;
case DisplayMessage::ShiftLeverToN:
gs418.set_GS_418_FPC(GS_418_FPC::A_MGN);
break;
case DisplayMessage::ShiftLeverToNToStart:
gs418.set_GS_418_FPC(GS_418_FPC::A_MGSNN);
break;
case DisplayMessage::VisitWorkshop:
gs418.set_GS_418_FPC(GS_418_FPC::A_MGW);
break;
default:
break; // Upshift and downshift request ignore
}
} else if (this->temp == DriveProfileDisplay::Comfort) {
switch (m) {
case DisplayMessage::ActuateParkingBrake_WarningTone:
gs418.set_GS_418_FPC(GS_418_FPC::C_MGFB_WT);
break;
case DisplayMessage::ApplyBrake:
gs418.set_GS_418_FPC(GS_418_FPC::C_MGBB);
break;
case DisplayMessage::RequestGearAgain:
gs418.set_GS_418_FPC(GS_418_FPC::C_MGGEA);
break;
case DisplayMessage::ShiftLeverToN:
gs418.set_GS_418_FPC(GS_418_FPC::C_MGN);
break;
case DisplayMessage::ShiftLeverToNToStart:
gs418.set_GS_418_FPC(GS_418_FPC::C_MGSNN);
break;
case DisplayMessage::VisitWorkshop:
gs418.set_GS_418_FPC(GS_418_FPC::C_MGW);
break;
default:
break; // Upshift and downshift request ignore
}
} else if (this->temp == DriveProfileDisplay::Manual) {
switch (m) {
case DisplayMessage::ActuateParkingBrake_WarningTone:
case DisplayMessage::ApplyBrake:
case DisplayMessage::RequestGearAgain:
break;
case DisplayMessage::ShiftLeverToN:
gs418.set_GS_418_FPC(GS_418_FPC::M_MGN);
break;
case DisplayMessage::ShiftLeverToNToStart:
break;
case DisplayMessage::VisitWorkshop:
gs418.set_GS_418_FPC(GS_418_FPC::M_MGW);
break;
case DisplayMessage::Upshift:
gs418.set_GS_418_FPC(GS_418_FPC::UP);
break;
case DisplayMessage::Downshift:
gs418.set_GS_418_FPC(GS_418_FPC::DOWN);
break;
default:
break; // Upshift and downshift request ignore
}
} else if (this->temp == DriveProfileDisplay::Standard) {
switch (m) {
case DisplayMessage::ActuateParkingBrake_WarningTone:
gs418.set_GS_418_FPC(GS_418_FPC::S_MGFB_WT);
break;
case DisplayMessage::ApplyBrake:
gs418.set_GS_418_FPC(GS_418_FPC::S_MGBB);
break;
case DisplayMessage::RequestGearAgain:
gs418.set_GS_418_FPC(GS_418_FPC::S_MGGEA);
break;
case DisplayMessage::ShiftLeverToN:
gs418.set_GS_418_FPC(GS_418_FPC::S_MGN);
break;
case DisplayMessage::ShiftLeverToNToStart:
gs418.set_GS_418_FPC(GS_418_FPC::S_MGSNN);
break;
case DisplayMessage::VisitWorkshop:
gs418.set_GS_418_FPC(GS_418_FPC::S_MGW);
break;
default:
break; // Upshift and downshift request ignore
}
} else if (this->temp == DriveProfileDisplay::Winter) { // Winter mode (Doesn't have as many warnings??)
switch (m) {
case DisplayMessage::ActuateParkingBrake_WarningTone: // Beep beep "Apply parking brake!"
break;
case DisplayMessage::ApplyBrake: // "Apply parking brake"
break;
case DisplayMessage::RequestGearAgain: // Requesting gear again
break;
case DisplayMessage::ShiftLeverToN: // Shift lever request to 'N'
gs418.set_GS_418_FPC(GS_418_FPC::W_MGN);
break;
case DisplayMessage::ShiftLeverToNToStart: // Shift lever request to 'N' to start engine
break;
case DisplayMessage::VisitWorkshop: // Fault with gearbox. Visit workshop
gs418.set_GS_418_FPC(GS_418_FPC::W_MGW);
break;
default: // Signal not valid (SNV) / Other value
break; // Upshift and downshift request ignore
}
} else if (this->temp == DriveProfileDisplay::FAILURE) { // Gearbox is broken..limp mode profile
switch (m) {
case DisplayMessage::ActuateParkingBrake_WarningTone:
break;
case DisplayMessage::ApplyBrake:
break;
case DisplayMessage::RequestGearAgain:
break;
case DisplayMessage::ShiftLeverToN:
break;
case DisplayMessage::ShiftLeverToNToStart:
break;
case DisplayMessage::VisitWorkshop:
gs418.set_GS_418_FPC(GS_418_FPC::F_MGW);
break;
default:
break; // Upshift and downshift request ignore
}
}
// Ignore SNV
}
void Egs52Can::set_target_gear(Gear g) {
switch (g) {
case Gear::P:
gs218.set_GS_218_GZC(GS_218_GZC::P);
gs418.set_GS_418_GZC(GS_418_GZC::P);
break;
case Gear::N:
gs218.set_GS_218_GZC(GS_218_GZC::N);
gs418.set_GS_418_GZC(GS_418_GZC::N);
break;
case Gear::R1:
gs218.set_GS_218_GZC(GS_218_GZC::R);
gs418.set_GS_418_GZC(GS_418_GZC::R);
break;
case Gear::R2:
gs218.set_GS_218_GZC(GS_218_GZC::R2);
gs418.set_GS_418_GZC(GS_418_GZC::R2);
break;
case Gear::D1:
gs218.set_GS_218_GZC(GS_218_GZC::D1);
gs418.set_GS_418_GZC(GS_418_GZC::D1);
break;
case Gear::D2:
gs218.set_GS_218_GZC(GS_218_GZC::D2);
gs418.set_GS_418_GZC(GS_418_GZC::D2);
break;
case Gear::D3:
gs218.set_GS_218_GZC(GS_218_GZC::D3);
gs418.set_GS_418_GZC(GS_418_GZC::D3);
break;
case Gear::D4:
gs218.set_GS_218_GZC(GS_218_GZC::D4);
gs418.set_GS_418_GZC(GS_418_GZC::D4);
break;
case Gear::D5:
gs218.set_GS_218_GZC(GS_218_GZC::D5);
gs418.set_GS_418_GZC(GS_418_GZC::D5);
break;
case Gear::D6:
gs218.set_GS_218_GZC(GS_218_GZC::D6);
gs418.set_GS_418_GZC(GS_418_GZC::D6);
break;
case Gear::D7:
gs218.set_GS_218_GZC(GS_218_GZC::D7);
gs418.set_GS_418_GZC(GS_418_GZC::D7);
break;
case Gear::CANCEL:
gs218.set_GS_218_GZC(GS_218_GZC::CANCEL);
gs418.set_GS_418_GZC(GS_418_GZC::CANCEL);
break;
default:
break;
}
}
void Egs52Can::set_actual_gear(Gear g) {
switch (g) {
case Gear::P:
gs218.set_GS_218_GIC(GS_218_GIC::P);
gs418.set_GS_418_GIC(GS_418_GIC::P);
break;
case Gear::N:
gs218.set_GS_218_GIC(GS_218_GIC::N);
gs418.set_GS_418_GIC(GS_418_GIC::N);
break;
case Gear::R1:
gs218.set_GS_218_GIC(GS_218_GIC::R);
gs418.set_GS_418_GIC(GS_418_GIC::R);
break;
case Gear::R2:
gs218.set_GS_218_GIC(GS_218_GIC::R2);
gs418.set_GS_418_GIC(GS_418_GIC::R2);
break;
case Gear::D1:
gs218.set_GS_218_GIC(GS_218_GIC::D1);
gs418.set_GS_418_GIC(GS_418_GIC::D1);
break;
case Gear::D2:
gs218.set_GS_218_GIC(GS_218_GIC::D2);
gs418.set_GS_418_GIC(GS_418_GIC::D2);
break;
case Gear::D3:
gs218.set_GS_218_GIC(GS_218_GIC::D3);
gs418.set_GS_418_GIC(GS_418_GIC::D3);
break;
case Gear::D4:
gs218.set_GS_218_GIC(GS_218_GIC::D4);
gs418.set_GS_418_GIC(GS_418_GIC::D4);
break;
case Gear::D5:
gs218.set_GS_218_GIC(GS_218_GIC::D5);
gs418.set_GS_418_GIC(GS_418_GIC::D5);
break;
case Gear::D6:
gs218.set_GS_218_GIC(GS_218_GIC::D6);
gs418.set_GS_418_GIC(GS_418_GIC::D6);
break;
case Gear::D7:
gs218.set_GS_218_GIC(GS_218_GIC::D7);
gs418.set_GS_418_GIC(GS_418_GIC::D7);
break;
default:
break;
}
}
void Egs52Can::set_turbine_rpm(uint16_t rpm) {
gs338.set_NTURBINE(rpm);
}
void Egs52Can::set_torque_loss_nm(uint16_t loss) {
gs418.set_M_VERL(loss);
}
void Egs52Can::set_display_speed_step(SpeedStep disp) {
switch (disp) {
case SpeedStep::BLANK:
gs418.set_GS_418_FSC(GS_418_FSC::BLANK);
break;
case SpeedStep::ONE:
gs418.set_GS_418_FSC(GS_418_FSC::ONE);
break;
case SpeedStep::TWO:
gs418.set_GS_418_FSC(GS_418_FSC::TWO);
break;
case SpeedStep::THREE:
gs418.set_GS_418_FSC(GS_418_FSC::THREE);
break;
case SpeedStep::FOUR:
gs418.set_GS_418_FSC(GS_418_FSC::FOUR);
break;
case SpeedStep::FIVE:
gs418.set_GS_418_FSC(GS_418_FSC::FUENF);
break;
case SpeedStep::SIX:
gs418.set_GS_418_FSC(GS_418_FSC::SIX);
break;
case SpeedStep::SEVEN:
gs418.set_GS_418_FSC(GS_418_FSC::SEVEN);
break;
case SpeedStep::A:
gs418.set_GS_418_FSC(GS_418_FSC::A);
break;
case SpeedStep::D:
gs418.set_GS_418_FSC(GS_418_FSC::D);
break;
case SpeedStep::R:
gs418.set_GS_418_FSC(GS_418_FSC::R);
break;
case SpeedStep::F:
gs418.set_GS_418_FSC(GS_418_FSC::F);
break;
case SpeedStep::N:
gs418.set_GS_418_FSC(GS_418_FSC::N);
break;
case SpeedStep::P:
gs418.set_GS_418_FSC(GS_418_FSC::P);
break;
default:
break;
}
}
void Egs52Can::set_status_error_check(ErrorCheck e) {
switch (e) {
case ErrorCheck::OK:
gs218.set_GS_218_FEHLPRF_ST(GS_218_FEHLPRF_ST::OK);
break;
case ErrorCheck::WAIT:
gs218.set_GS_218_FEHLPRF_ST(GS_218_FEHLPRF_ST::WAIT);
break;
case ErrorCheck::ERROR:
gs218.set_GS_218_FEHLPRF_ST(GS_218_FEHLPRF_ST::ERROR);
break;
default:
break;
}
}
void Egs52Can::set_shifter_possition(ShifterPosition g) {
switch (g) {
case ShifterPosition::P:
gs418.set_GS_418_WHST(GS_418_WHST::P);
break;
case ShifterPosition::P_R:
case ShifterPosition::R:
case ShifterPosition::R_N:
gs418.set_GS_418_WHST(GS_418_WHST::R);
break;
case ShifterPosition::N:
gs418.set_GS_418_WHST(GS_418_WHST::N);
break;
case ShifterPosition::N_D:
case ShifterPosition::D:
case ShifterPosition::MINUS:
case ShifterPosition::PLUS:
gs418.set_GS_418_WHST(GS_418_WHST::D);
break;
case ShifterPosition::SNV:
gs418.set_GS_418_WHST(GS_418_WHST::SNV);
break;
default:
break;
}
}
Egs52Can* egs52_can_handler = nullptr;

View File

@ -1,73 +0,0 @@
#if EGS53_MODE == false
#ifndef EGS52_CAN_H_
#define EGS52_CAN_H_
#include "abstract_can.h"
#include <GS.h>
#include <BS.h>
#include <EWM.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "iso_tp.h"
class Egs52Can : public AbstractCanHandler {
public:
Egs52Can();
~Egs52Can();
void start_tx_rx_loop();
// Getters
uint16_t get_engine_rpm();
void get_rr_rpm(WheelRotation *dest) override;
void get_rl_rpm(WheelRotation *dest) override;
void get_fr_rpm(WheelRotation *dest) override;
void get_fl_rpm(WheelRotation *dest) override;
int16_t get_steering_angle() override;
int16_t get_ambient_temp() override;
int16_t get_engine_temp() override;
bool is_profile_toggle_pressed() override;
Gear get_abs_target_lower_gear() override;
Gear get_abs_target_upper_gear() override;
bool get_abs_request_downshift() override;
bool get_abs_request_gear_forced() override;
uint16_t get_engine_static_torque() override;
uint16_t get_engine_max_torque_dyno() override;
uint16_t get_engine_max_torque() override;
uint16_t get_engine_min_torque() override;
ShifterPosition get_shifter_position() override;
// Setters
void set_is_safe_start(bool can_start) override;
void set_atf_temp(uint16_t temp) override;
void set_drive_profile(DriveProfileDisplay p) override;
void set_display_message(DisplayMessage m) override;
void set_target_gear(Gear g) override;
void set_actual_gear(Gear g) override;
void set_turbine_rpm(uint16_t rpm) override;
void set_torque_loss_nm(uint16_t loss) override;
void set_display_speed_step(SpeedStep disp) override;
void set_status_error_check(ErrorCheck e) override;
void set_shifter_possition(ShifterPosition g) override;
private:
static void __start_thread_tx(void *_this);
static void __start_thread_rx(void *_this);
void tx_loop();
void rx_loop();
TaskHandle_t* task_handler_tx = nullptr;
TaskHandle_t* task_handler_rx = nullptr;
DriveProfileDisplay temp = DriveProfileDisplay::SNV;
BS_ECU bsECU; // ABS / BAS / ESP module
EWM_ECU ewmECU; // Shift lever
IsoTpServer* diag_endpoint;
};
extern Egs52Can* egs52_can_handler;
#endif // EGS52_CAN_H_
#endif // EGS53_MODE

View File

@ -1,68 +0,0 @@
//
// Created by ashcon on 9/9/21.
//
#include "iso_tp.h"
#include "esp_log.h"
#include <stdlib.h>
#include <cstring>
IsoTpServer::IsoTpServer(uint16_t rx_id, uint16_t tx_id, uint8_t bs, uint8_t st_min) {
this->bs = bs;
this->st_min = st_min;
this->tx_id = tx_id;
this->rx_id = rx_id;
this->rx_queue = xQueueCreate(10, sizeof(can_message_t));
this->tx_queue = xQueueCreate(10, sizeof(can_message_t));
}
IsoTpServer::~IsoTpServer() {
vTaskDelete(this->task_handler);
}
void IsoTpServer::create_server_task() {
if (this->task_handler == nullptr) {
xTaskCreate(__start_server_task, "ISO-TP", 32768, this, 5, this->task_handler);
}
}
void IsoTpServer::__start_server_task(void *_this) {
static_cast<IsoTpServer*>(_this)->server_loop();
}
void IsoTpServer::server_loop() {
ESP_LOGD(LOG_TAG, "ISO-TP server started. Listening to CAN ID 0x%04X, sending on CAN ID 0x%04X", this->rx_id, this->tx_id);
can_message_t tmp;
while(true) {
if (xQueueReceive(this->rx_queue, &tmp, 1)) {
ESP_LOGD(LOG_TAG, "Incoming data: 0x%04X, [%02X %02X %02X %02X %02X %02X %02X %02X]",
tmp.identifier,
tmp.data[0],
tmp.data[1],
tmp.data[2],
tmp.data[3],
tmp.data[4],
tmp.data[5],
tmp.data[6],
tmp.data[7]
);
}
vTaskDelay(10);
}
vTaskDelete(this->task_handler);
}
void IsoTpServer::push_frame(can_message_t *msg) {
can_message_t clone;
std::memcpy(&clone, msg, sizeof(can_message_t));
xQueueSend(this->rx_queue, (void*)&clone, 2);
}
bool IsoTpServer::pop_frame(can_message_t *dest) {
if (uxQueueMessagesWaiting(this->tx_queue) > 0) {
if (xQueueReceive(this->tx_queue, dest, 2) == ESP_OK) {
return true;
}
}
return false;
}

View File

@ -1,36 +0,0 @@
//
// Created by ashcon on 9/9/21.
//
#ifndef ULTIMATE_NAG52_FW_ISO_TP_H
#define ULTIMATE_NAG52_FW_ISO_TP_H
#include <cstdint>
#include "driver/can.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#define LOG_TAG "ISO_TP"
class IsoTpServer {
public:
IsoTpServer(uint16_t rx_id, uint16_t tx_id, uint8_t bs, uint8_t st_min);
~IsoTpServer();
void push_frame(can_message_t *msg);
bool pop_frame(can_message_t *dest);
void create_server_task();
private:
QueueHandle_t tx_queue;
QueueHandle_t rx_queue;
uint16_t rx_id;
static void __start_server_task(void *_this);
TaskHandle_t* task_handler = nullptr;
void server_loop();
uint8_t mailbox_id;
uint8_t bs;
uint8_t st_min;
uint16_t tx_id;
};
#endif //ULTIMATE_NAG52_FW_ISO_TP_H

View File

@ -1,2 +0,0 @@
#include "kwp_server.h"

View File

@ -1,41 +0,0 @@
#include <cstdint>
#include "iso_tp.h"
#define MAX_DATA_SIZE 4096
struct KwpPayload {
uint16_t size;
uint8_t buffer[MAX_DATA_SIZE];
};
class KwpDataHandler {
public:
virtual bool recv_payload(KwpPayload* dest);
virtual void send_payload(KwpPayload* tx);
};
class SerialDataHandler: public KwpDataHandler {
};
class BtDataHandler: public KwpDataHandler {
};
class IsoTpDataHandler: public KwpDataHandler {
public:
IsoTpDataHandler(uint16_t rx_can_id, uint16_t tx_can_id);
bool recv_payload(KwpPayload* dest);
void send_payload(KwpPayload* tx);
private:
};
class KwpServer {
KwpServer(KwpDataHandler* handler, uint16_t timeout_interval_ms);
~KwpServer();
private:
KwpDataHandler* handler;
// server_handler;
};

View File

@ -1,39 +0,0 @@
#ifndef __GEARBOX_H_
#define __GEARBOX_H_
#include <config.h>
#include "sensors.h"
#include "../canbus/abstract_can.h"
#include <freertos/task.h>
enum ShiftResult {
Failed,
ShiftAlreadyPending,
OK
}
class Gearbox {
public:
Gearbox();
~Gearbox();
private:
/**
* @brief Task handler for the task which switches gears
*
*/
TaskHandle_t* shifter_task = nullptr;
/**
* @brief Task handler for the gearbox's logic loop
*
*/
TaskHandle_t* logic_loop = nullptr;
Gear target_gear;
Gear actual_gear;
}
#endif // __GEARBOX_H_

View File

@ -1,163 +1,45 @@
#include <pins.h>
#include <sensors.h>
#include <config.h>
#include <canbus/kwp_server.h>
#include <canbus/egs52_can.h>
#include <driver/ledc.h>
#include <esp_log.h>
#include <esp_freertos_hooks.h>
#include <pwm_channels/channels.h>
#include "scn.h"
#include "solenoids/solenoids.h"
#include "esp_log.h"
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <esp32/ulp.h>
#include "speaker.h"
int spkr_channel = 0;
void send_note(uint8_t channel, uint32_t freq, uint32_t dur, uint32_t total_dur) {
spkr_pwm.change_freq(freq);
spkr_pwm.write_pwm(128);
vTaskDelay(dur / portTICK_PERIOD_MS);
spkr_pwm.write_pwm(0);
vTaskDelay((total_dur - dur) / portTICK_PERIOD_MS);
void setup_tcm()
{
init_all_solenoids();
ESP_LOGI("INIT", "INIT OK!");
}
uint32_t v;
[[noreturn]] void print_task(void* pvParams) {
send_note(spkr_channel, 900, 200, 250);
send_note(spkr_channel, 900, 200, 250);
bool haveZero = true;
esp_chip_info_t info;
esp_chip_info(&info);
while(true) {
uint32_t n2 = Sensors::read_n2_rpm();
uint32_t n3 = Sensors::read_n3_rpm();
ESP_LOGD("PRINT", "N2 RPM: %u, N3 RPM: %u, [%d %d %d | %d %d %d]", n2, n3, spc_pwm.get_pwm(), mpc_pwm.get_pwm(), tcc_pwm.get_pwm(), y3_pwm.get_pwm(), y4_pwm.get_pwm(), y5_pwm.get_pwm());
//if (n2 != 0 || n3 != 0 ) {
// spkr_pwm.change_freq((n2+1 + n3+1) / 2);
// spkr_pwm.write_pwm(128);
// haveZero = false;
//} else if (!haveZero) {
// spkr_pwm.write_pwm(0);
// haveZero = true;
//}
vTaskDelay(500 / portTICK_RATE_MS);
}
void set_note(uint32_t s, uint32_t duration, uint32_t total_duration) {
spkr.set_freq(s);
vTaskDelay(duration);
spkr.set_freq(0);
vTaskDelay(total_duration - duration);
}
void test_can(void* args) {
while(Sensors::read_vbatt() < 700) {
vTaskDelay(10);
}
egs52_can_handler->set_drive_profile(DriveProfileDisplay::Comfort);
Gear target = Gear::P;
Gear actual = Gear::P;
bool idling = false;
bool garageshifting = false;
uint64_t last_garage_shift = esp_timer_get_time() / 1000;
bool into_reverse = false;
while(true) {
ShifterPosition pos = egs52_can_handler->get_shifter_position();
egs52_can_handler->set_shifter_possition(pos);
uint32_t n2 = Sensors::read_n2_rpm();
uint32_t n3 = Sensors::read_n3_rpm();
uint32_t rpm = 0;
if (n2 > n3) { rpm = n2; } else { rpm = n3; }
egs52_can_handler->set_turbine_rpm(rpm);
switch(pos) {
case ShifterPosition::P:
egs52_can_handler->set_display_speed_step(SpeedStep::P);
egs52_can_handler->set_is_safe_start(true);
break;
case ShifterPosition::P_R:
case ShifterPosition::R:
egs52_can_handler->set_display_speed_step(SpeedStep::R);
egs52_can_handler->set_is_safe_start(false);
break;
case ShifterPosition::R_N:
case ShifterPosition::N:
egs52_can_handler->set_display_speed_step(SpeedStep::N);
egs52_can_handler->set_is_safe_start(true);
break;
case ShifterPosition::N_D:
case ShifterPosition::PLUS:
case ShifterPosition::MINUS:
case ShifterPosition::D:
egs52_can_handler->set_display_speed_step(SpeedStep::D);
egs52_can_handler->set_is_safe_start(false);
break;
default:
break;
void printer(void*) {
set_note(500, 250, 300);
set_note(500, 250, 300);
while(1) {
//ESP_LOGI("MAIN","RTC_SLOW_MEM[0] = %d", RTC_SLOW_MEM[1]);
ESP_LOGI(
"MAIN",
"Solenoid readings: Y3: %d mA, Y4: %d mA, Y5: %d mA, MPC: %d mA, SPC: %d mA, TCC: %d mA",
sol_y3->get_current_estimate(),
sol_y4->get_current_estimate(),
sol_y5->get_current_estimate(),
sol_mpc->get_current_estimate(),
sol_spc->get_current_estimate(),
sol_tcc->get_current_estimate()
);
vTaskDelay(1000);
}
if ((pos == ShifterPosition::P || pos == ShifterPosition::N) && Sensors::read_park_lock() ) {
// We are in park or neutral!
if (!idling) {
ESP_LOGD("GB","Idling!");
}
if (pos == ShifterPosition::P) {
actual = Gear::P;
target = Gear::P;
} else {
actual = Gear::N;
target = Gear::P;
}
mpc_pwm.write_pwm(102);
spc_pwm.write_pwm(84);
y4_pwm.write_pwm(128);
idling = true;
garageshifting = false;
} else if ((pos == ShifterPosition::P_R || pos == ShifterPosition::R_N || pos == ShifterPosition::N_D) && !Sensors::read_park_lock()) {
if (!garageshifting) {
ESP_LOGD("GB","Garageshifting!");
}
y4_pwm.write_pwm(255);
if (pos == ShifterPosition::P_R) {
y3_pwm.write_pwm(255);
}
mpc_pwm.write_pwm(84);
spc_pwm.write_pwm(120);
idling = false;
garageshifting = true;
last_garage_shift = esp_timer_get_time() / 1000;
} else {
idling = false;
}
if (garageshifting && (esp_timer_get_time() / 1000 - last_garage_shift) > 1000) {
ESP_LOGD("GB","Garageshifting done!");
garageshifting = false;
spc_pwm.write_pwm(0);
mpc_pwm.write_pwm(0);
y4_pwm.write_pwm(0);
y3_pwm.write_pwm(0);
if (Sensors::read_n2_rpm() == 0 && Sensors::read_n3_rpm() == 0) {
if (into_reverse) {
actual = Gear::R1;
target = Gear::R1;
} else {
actual = Gear::D1;
target = Gear::D1;
}
}
}
vTaskDelay(10);
egs52_can_handler->set_target_gear(target);
egs52_can_handler->set_actual_gear(actual);
}
vTaskDelete(NULL);
//while(true) {
// tcc_pwm.fade_pwm(0, 1000);
// vTaskDelay(1000);
// tcc_pwm.fade_pwm(32, 500);
// vTaskDelay(700);
//}
}
// Don't add any code here. Use RTOSTasks only
// This loop just idles forever
extern "C" void app_main(void) {
egs52_can_handler = new Egs52Can();
egs52_can_handler->start_tx_rx_loop();
Sensors::configure_sensor_pins();
xTaskCreate(&print_task, "printer", 4096, nullptr, 5, nullptr);
xTaskCreate(&test_can, "CAN_TEST", 2048, nullptr, 10, nullptr);
xTaskCreate(&pwm_solenoid_fader_thread, "SOL_FADE", 1024, nullptr, 5, nullptr);
extern "C" void app_main(void)
{
setup_tcm();
xTaskCreate(printer, "PRINTER", 8192, nullptr, 2, nullptr);
}

View File

@ -1,99 +0,0 @@
#include "channels.h"
#include <pins.h>
#include <esp_log.h>
#define FADE_STEP_SIZE 10
PwmChannel::PwmChannel(ledc_channel_t channel, uint32_t freq, uint8_t pin, uint8_t initial_pwm, ledc_timer_t timer) {
this->channel = channel;
this->timer = timer;
ledc_timer_config_t config_cfg = {
.speed_mode = ledc_mode_t::LEDC_LOW_SPEED_MODE,
.duty_resolution = LEDC_TIMER_8_BIT,
.timer_num = timer,
.freq_hz = freq,
.clk_cfg = LEDC_AUTO_CLK
};
ledc_timer_config(&config_cfg);
ledc_channel_config_t channel_cfg = {
.gpio_num = pin,
.speed_mode = ledc_mode_t::LEDC_LOW_SPEED_MODE,
.channel = channel,
.intr_type = LEDC_INTR_DISABLE,
.timer_sel = timer,
.duty = 0,
.hpoint = 0
};
ledc_channel_config(&channel_cfg);
this->write_pwm(initial_pwm);
};
void PwmChannel::write_pwm(uint8_t value) {
ledc_set_duty(ledc_mode_t::LEDC_LOW_SPEED_MODE, this->channel, (uint8_t)value);
ledc_update_duty(ledc_mode_t::LEDC_LOW_SPEED_MODE, this->channel);
this->__duty = (int)value*10;
}
uint8_t PwmChannel::get_pwm() {
return (uint8_t)(this->__duty/10);
};
void PwmChannel::change_freq(uint8_t f) {
ledc_set_freq(ledc_mode_t::LEDC_LOW_SPEED_MODE, this->timer, f);
this->write_pwm(this->__duty); // Refresh
this->__duty = f*10;
this->__step = 0;
this->__target_duty = f*10;
}
void PwmChannel::fade_pwm(uint8_t dest_pwm, uint32_t time_ms) {
if (this->__duty/10 == dest_pwm) { return; }
if (time_ms <= FADE_STEP_SIZE) {
this->change_freq(dest_pwm); // Too quick!
} else {
int steps = time_ms/FADE_STEP_SIZE;
if (dest_pwm > this->__duty) {
// increase duty
this->__step = ((int)(dest_pwm*10) - this->__duty) / steps;
} else {
// decrease duty
this->__step = (this->__duty - (int)(dest_pwm*10))*-1 / steps;
}
this->__target_duty = dest_pwm*10;
}
}
PwmChannel y3_pwm = PwmChannel(ledc_channel_t::LEDC_CHANNEL_0, 1000, PIN_Y3_PWM, 0, LEDC_TIMER_0);
PwmChannel y4_pwm = PwmChannel(ledc_channel_t::LEDC_CHANNEL_1, 1000, PIN_Y4_PWM, 0, LEDC_TIMER_0);
PwmChannel y5_pwm = PwmChannel(ledc_channel_t::LEDC_CHANNEL_2, 1000, PIN_Y5_PWM, 0, LEDC_TIMER_0);
PwmChannel spc_pwm = PwmChannel(ledc_channel_t::LEDC_CHANNEL_3, 1000, PIN_SPC_PWM, 0, LEDC_TIMER_1);
PwmChannel mpc_pwm = PwmChannel(ledc_channel_t::LEDC_CHANNEL_4, 1000, PIN_MPC_PWM, 0, LEDC_TIMER_1);
PwmChannel tcc_pwm = PwmChannel(ledc_channel_t::LEDC_CHANNEL_5, 1000, PIN_TCC_PWM, 0, LEDC_TIMER_2);
PwmChannel spkr_pwm = PwmChannel(ledc_channel_t::LEDC_CHANNEL_6, 1000, PIN_SPKR, 0, LEDC_TIMER_3);
uint16_t tmp = 0;
void fade_channel(PwmChannel* c) {
if (c->__step != 0) {
tmp = c->__duty;
c->write_pwm((c->__duty+c->__step)/10);
c->__duty = tmp+c->__step;
if (((c->__duty >= c->__target_duty) && c->__step > 0) || ((c->__duty <= c->__target_duty) && c->__step < 0)) {
c->__step = 0;
c->write_pwm((c->__target_duty)/10);
}
}
}
[[noreturn]] void pwm_solenoid_fader_thread(void* args) {
while(true) {
fade_channel(&tcc_pwm);
fade_channel(&mpc_pwm);
fade_channel(&spc_pwm);
vTaskDelay(FADE_STEP_SIZE);
}
}

View File

@ -1,37 +0,0 @@
#ifndef PWM_CHANNELS_H_
#define PWM_CHANNELS_H_
#include <stdint.h>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <driver/ledc.h>
class PwmChannel {
public:
PwmChannel(ledc_channel_t channel, uint32_t freq, uint8_t pin, uint8_t initial_pwm, ledc_timer_t timer);
void write_pwm(uint8_t value);
uint8_t get_pwm();
void change_freq(uint8_t f);
void fade_pwm(uint8_t dest_pwm, uint32_t time_ms);
int __duty = 0;
int __target_duty = 0;
int __step = 0;
bool down = false;
private:
ledc_channel_t channel;
ledc_timer_t timer;
};
extern PwmChannel y3_pwm;
extern PwmChannel y4_pwm;
extern PwmChannel y5_pwm;
extern PwmChannel spc_pwm;
extern PwmChannel mpc_pwm;
extern PwmChannel tcc_pwm;
extern PwmChannel spkr_pwm;
[[noreturn]] void pwm_solenoid_fader_thread(void* args);
#endif

View File

@ -1,303 +0,0 @@
#include <sensors.h>
#include "pwm_channels/channels.h"
#include "driver/pcnt.h"
#include "driver/i2s.h"
#define SAMPLES_PER_REV 8 // measure 8 times per revolution...
#define AVG_SAMPLES 8 // ...and average over 8 samples
const pcnt_unit_t PCNT_N2_RPM = PCNT_UNIT_0; // N2 RPM uses PCNT unit 0
const pcnt_unit_t PCNT_N3_RPM = PCNT_UNIT_1; // N3 RPM uses PCNT unit 1
bool n2_ok = true; // If false DTC is thrown
bool n3_ok = true; // If false DTC is thrown
static uint32_t base_solenoid_readings[6] = {0,0,0,0,0,0}; // Offsets from ADC
uint64_t last_n2_time = 0; // Last time interrupt was called
uint64_t last_n3_time = 0; // Last time interrupt was called
/**
* To prevent random spikes in RPM, we smooth out the readings
* for N2 and N3 RPM sensor
*
* This is done by keeping track of the past AVG_SAMPLES RPM measurements
* in a moving average fashion
*/
uint64_t n2_deltas[AVG_SAMPLES];
uint8_t n2_sample_id = 0;
uint64_t n2_total = 0;
uint64_t n3_deltas[AVG_SAMPLES];
uint8_t n3_sample_id = 0;
uint64_t n3_total = 0;
// Muxes for interrupts
portMUX_TYPE n2_mux = portMUX_INITIALIZER_UNLOCKED;
portMUX_TYPE n3_mux = portMUX_INITIALIZER_UNLOCKED;
esp_adc_cal_characteristics_t adc1_cal = esp_adc_cal_characteristics_t{};
esp_adc_cal_characteristics_t adc2_cal = esp_adc_cal_characteristics_t{};
uint16_t read_mv = 0;
uint32_t read_pin_mv(ADC_Reading req_pin) {
uint32_t raw = 0;
switch (req_pin) {
case ADC_Reading::Y3:
raw = adc1_get_raw(ADC_CHANNEL_Y3);
return esp_adc_cal_raw_to_voltage(raw, &adc1_cal);
case ADC_Reading::Y4:
raw = adc1_get_raw(ADC_CHANNEL_Y4);
return esp_adc_cal_raw_to_voltage(raw, &adc1_cal);
case ADC_Reading::Y5:
raw = adc1_get_raw(ADC_CHANNEL_Y5);
return esp_adc_cal_raw_to_voltage(raw, &adc1_cal);
case ADC_Reading::MPC:
raw = adc1_get_raw(ADC_CHANNEL_Y4);
return esp_adc_cal_raw_to_voltage(raw, &adc2_cal);
case ADC_Reading::SPC:
raw = adc1_get_raw(ADC_CHANNEL_Y4);
return esp_adc_cal_raw_to_voltage(raw, &adc1_cal);
case ADC_Reading::TCC:
raw = adc1_get_raw(ADC_CHANNEL_Y4);
return esp_adc_cal_raw_to_voltage(raw, &adc1_cal);
case ADC_Reading::ATF:
adc2_get_raw(ADC_CHANNEL_ATF, adc_bits_width_t::ADC_WIDTH_BIT_12, (int*)&raw);
return esp_adc_cal_raw_to_voltage(raw, &adc2_cal);
case ADC_Reading::V_SENSE:
adc2_get_raw(ADC_CHANNEL_VSENSE, adc_bits_width_t::ADC_WIDTH_BIT_12, (int*)&raw);
return esp_adc_cal_raw_to_voltage(raw, &adc2_cal);
default:
return 0;
}
}
static void IRAM_ATTR onOverflow(void *args) {
int unit = (int)args; // PCNT unit we are working with
uint64_t now = esp_timer_get_time();
if (unit == PCNT_N2_RPM) { // N2
portENTER_CRITICAL(&n2_mux);
n2_total = n2_total - n2_deltas[n2_sample_id];
uint64_t delta = (now - last_n2_time);
last_n2_time = now;
n2_deltas[n2_sample_id] = delta;
n2_total += delta;
n2_sample_id = (n2_sample_id+1) % AVG_SAMPLES;
portEXIT_CRITICAL(&n2_mux);
} else if (unit == PCNT_N3_RPM) { // N3
portENTER_CRITICAL(&n3_mux);
n3_total -= n3_deltas[n3_sample_id];
uint64_t delta = (now - last_n3_time);
last_n3_time = now;
n3_deltas[n3_sample_id] = delta;
n3_total += delta;
n3_sample_id = (n3_sample_id+1) % AVG_SAMPLES;
portEXIT_CRITICAL(&n3_mux);
}
}
void Sensors::configure_sensor_pins() {
// Gearbox sensors
gpio_set_direction(PIN_V_SENSE, GPIO_MODE_INPUT);
gpio_set_direction(PIN_ATF_SENSE, GPIO_MODE_INPUT);
gpio_set_direction(PIN_N3_SENSE, GPIO_MODE_INPUT);
gpio_set_direction(PIN_N2_SENSE, GPIO_MODE_INPUT);
gpio_set_pull_mode(PIN_N3_SENSE, GPIO_PULLUP_ONLY);
gpio_set_pull_mode(PIN_N2_SENSE, GPIO_PULLUP_ONLY);
// Solenoid current inputs
gpio_set_direction(PIN_Y3_SENSE, GPIO_MODE_INPUT);
gpio_set_direction(PIN_Y4_SENSE, GPIO_MODE_INPUT);
gpio_set_direction(PIN_Y5_SENSE, GPIO_MODE_INPUT);
gpio_set_direction(PIN_SPC_SENSE, GPIO_MODE_INPUT);
gpio_set_direction(PIN_MPC_SENSE, GPIO_MODE_INPUT);
gpio_set_direction(PIN_TCC_SENSE, GPIO_MODE_INPUT);
// Configure ADC
adc1_config_width(ADC_WIDTH_12Bit);
adc1_config_channel_atten(ADC_CHANNEL_Y3, ADC_ATTEN_11db);
adc1_config_channel_atten(ADC_CHANNEL_Y4, ADC_ATTEN_11db);
adc1_config_channel_atten(ADC_CHANNEL_Y5, ADC_ATTEN_11db);
adc1_config_channel_atten(ADC_CHANNEL_MPC, ADC_ATTEN_11db);
adc1_config_channel_atten(ADC_CHANNEL_SPC, ADC_ATTEN_11db);
adc1_config_channel_atten(ADC_CHANNEL_TCC, ADC_ATTEN_11db);
adc2_config_channel_atten(ADC_CHANNEL_VSENSE, ADC_ATTEN_11db);
adc2_config_channel_atten(ADC_CHANNEL_ATF, ADC_ATTEN_11db);
/*
i2s_config_t i2s_config = {
.mode = I2S_MODE_MASTER | I2S_MODE_RX | I2S_MODE_ADC_BUILT_IN,
.sample_rate = 20000,
.bits_per_sample = i2s_bits_per_sample_t::I2S_BITS_PER_SAMPLE_16BIT,
.channel_format = I2S_CHANNEL_FMT_ONLY_LEFT,
.communication_format = I2S_COMM_FORMAT_I2S,
.dma_buf_count = 2,
.dma_buf_len = 1024,
.use_apll = true,
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1
};
*/
// Read ADC calibration
esp_adc_cal_value_t type = esp_adc_cal_characterize(adc_unit_t::ADC_UNIT_1, ADC_ATTEN_11db, ADC_WIDTH_12Bit, 0, &adc1_cal);
type = esp_adc_cal_characterize(adc_unit_t::ADC_UNIT_2, ADC_ATTEN_11db, ADC_WIDTH_12Bit, 0, &adc2_cal);
adc1_get_raw(adc1_channel_t::ADC1_CHANNEL_0);
// Read all solenoids now to get resting current (PWM hasn't started yet!)
// This is our base measurement
base_solenoid_readings[(uint8_t)Solenoid::Y3] = read_pin_mv(ADC_Reading::Y3);
base_solenoid_readings[(uint8_t)Solenoid::Y4] = read_pin_mv(ADC_Reading::Y4);
base_solenoid_readings[(uint8_t)Solenoid::Y5] = read_pin_mv(ADC_Reading::Y5);
base_solenoid_readings[(uint8_t)Solenoid::MPC] = read_pin_mv(ADC_Reading::MPC);
base_solenoid_readings[(uint8_t)Solenoid::SPC] = read_pin_mv(ADC_Reading::SPC);
base_solenoid_readings[(uint8_t)Solenoid::TCC] = read_pin_mv(ADC_Reading::TCC);
// Now apply 40% to MPC and SPC
// Now check. According to ESP and testing, we shouldn't see more than 300mV at resting current.
// If we do, we can assume there is a short somewhere and the MOSFET no longer has control
// over that solenoid
const pcnt_config_t pcnt_config_n2 {
// Set PCNT input signal and control GPIOs
.pulse_gpio_num = PIN_N2_SENSE, // N2 RPM
.ctrl_gpio_num = PCNT_PIN_NOT_USED, // No control
.lctrl_mode = PCNT_MODE_KEEP, // Ignore control
.hctrl_mode = PCNT_MODE_KEEP, // Ignore control
.pos_mode = PCNT_COUNT_DIS, // Don't count on positive edge
.neg_mode = PCNT_COUNT_INC, // Count on calling edge
.counter_h_lim = N2_PULSES_PER_REV/SAMPLES_PER_REV, // HLim is pulses per rev (60 for N2) / number of samples per rev
.counter_l_lim = 0,
.unit = PCNT_N2_RPM,
.channel = PCNT_CHANNEL_0,
};
pcnt_unit_config(&pcnt_config_n2);
const pcnt_config_t pcnt_config_n3 {
// Set PCNT input signal and control GPIOs
.pulse_gpio_num = PIN_N3_SENSE, // N3 RPM
.ctrl_gpio_num = PCNT_PIN_NOT_USED, // No control
.lctrl_mode = PCNT_MODE_KEEP, // Ignore control
.hctrl_mode = PCNT_MODE_KEEP, // Ignore control
.pos_mode = PCNT_COUNT_DIS, // Don't count on positive edge
.neg_mode = PCNT_COUNT_INC, // Count on calling edge
.counter_h_lim = N3_PULSES_PER_REV/SAMPLES_PER_REV, // HLim is pulses per rev (60 for N2) / number of samples per rev
.counter_l_lim = 0,
.unit = PCNT_N3_RPM,
.channel = PCNT_CHANNEL_0,
};
pcnt_unit_config(&pcnt_config_n3);
// Stop counting and clear. We haven't setup ISR or filter yet
pcnt_counter_pause(PCNT_N2_RPM);
pcnt_counter_pause(PCNT_N3_RPM);
pcnt_counter_clear(PCNT_N2_RPM);
pcnt_counter_clear(PCNT_N3_RPM);
// Setup filter and ISR
pcnt_set_filter_value(PCNT_N2_RPM, 40); // 40us or more counts as a pulse (Works upto 10,000 RPM)
pcnt_set_filter_value(PCNT_N3_RPM, 40);
pcnt_filter_enable(PCNT_N2_RPM);
pcnt_filter_enable(PCNT_N3_RPM);
pcnt_isr_service_install(0);
pcnt_isr_handler_add(PCNT_N2_RPM, &onOverflow, (void*)PCNT_N2_RPM);
pcnt_isr_handler_add(PCNT_N3_RPM, &onOverflow, (void*)PCNT_N3_RPM);
// Enable interrupt when we hit H Lim of the counters
pcnt_event_enable(PCNT_N2_RPM, pcnt_evt_type_t::PCNT_EVT_H_LIM);
pcnt_event_enable(PCNT_N3_RPM, pcnt_evt_type_t::PCNT_EVT_H_LIM);
// Resume counting!
pcnt_counter_resume(PCNT_N2_RPM);
pcnt_counter_resume(PCNT_N3_RPM);
}
uint16_t Sensors::read_vbatt() {
return (uint16_t)(read_pin_mv(ADC_Reading::V_SENSE) * 0.5) + 100;
}
uint32_t Sensors::read_n2_rpm() {
uint64_t now = esp_timer_get_time();
portENTER_CRITICAL(&n2_mux);
if (now - last_n2_time > 100000) { // 100ms timeout
portEXIT_CRITICAL(&n2_mux);
return 0;
}
uint32_t avg = n2_total / AVG_SAMPLES;
float freq = (1000000 * (N2_PULSES_PER_REV / SAMPLES_PER_REV)) / avg;
portEXIT_CRITICAL(&n2_mux);
return freq;
}
uint32_t Sensors::read_n3_rpm() {
uint64_t now = esp_timer_get_time();
portENTER_CRITICAL(&n3_mux);
if (now - last_n3_time > 100000) { // 100ms timeout
portEXIT_CRITICAL(&n3_mux);
return 0;
}
uint32_t avg = n3_total / AVG_SAMPLES;
float freq = (1000000 * (N3_PULSES_PER_REV / SAMPLES_PER_REV)) / avg;
portEXIT_CRITICAL(&n3_mux);
return freq;
}
uint32_t Sensors::read_solenoid_current(Solenoid sol) {
uint32_t raw = 0;
switch(sol) {
case Solenoid::Y3:
raw = read_pin_mv(ADC_Reading::Y3);
break;
case Solenoid::Y4:
raw = read_pin_mv(ADC_Reading::Y4);
break;
case Solenoid::Y5:
raw = read_pin_mv(ADC_Reading::Y5);
break;
case Solenoid::MPC:
raw = read_pin_mv(ADC_Reading::MPC);
break;
case Solenoid::SPC:
raw = read_pin_mv(ADC_Reading::SPC);
break;
case Solenoid::TCC:
return 0;
//return delta_us;
//return read_mv;
//break;
default:
break;
}
return raw;
// 0-3V = 0-6A with 0.05Ohm resistor, so easy calculation!
return (raw - base_solenoid_readings[(uint8_t)sol]) * 2;
}
int16_t Sensors::read_atf_temp() {
return read_pin_mv(ADC_Reading::ATF);
}
bool Sensors::read_park_lock() {
return read_pin_mv(ADC_Reading::ATF) > 3000;
}
uint32_t Sensors::isr_count = 0;

View File

@ -1,127 +0,0 @@
#ifndef SENSORS_H_
#define SENSORS_H_
#include <stdint.h>
#include <pins.h>
#include <driver/adc.h>
#include "esp_adc_cal.h"
/**
* Number of teeth on the N2 carrier gear
*/
#define N2_PULSES_PER_REV 60
/**
* Number of teeth on the N3 carrier gear
*/
#define N3_PULSES_PER_REV 60
/**
* ADC1 channels for solenoid current monitoring
*/
#define ADC_CHANNEL_Y3 adc1_channel_t::ADC1_CHANNEL_0
#define ADC_CHANNEL_Y4 adc1_channel_t::ADC1_CHANNEL_3
#define ADC_CHANNEL_Y5 adc1_channel_t::ADC1_CHANNEL_7
#define ADC_CHANNEL_SPC adc1_channel_t::ADC1_CHANNEL_4
#define ADC_CHANNEL_MPC adc1_channel_t::ADC1_CHANNEL_6
#define ADC_CHANNEL_TCC adc1_channel_t::ADC1_CHANNEL_5
#define ADC_CHANNEL_VSENSE adc2_channel_t::ADC2_CHANNEL_8
#define ADC_CHANNEL_ATF adc2_channel_t::ADC2_CHANNEL_9
enum class ADC_Reading {
Y3,
Y4,
Y5,
MPC,
SPC,
TCC,
ATF,
V_SENSE
};
/**
* Solenoids on the gearbox
*/
enum class Solenoid {
// Y3 shift solenoid (Controls 1-2/4-5 shifting)
Y3 = 0,
// Y4 shift solenoid (Controls 3-4 shifting)
Y4 = 1,
// Y5 shift solenoid (Controls 2-3 shifting)
Y5 = 2,
// Shift pressure solenoid (Controls clutch pack pressure during shifting)
SPC = 3,
// Modulating pressure solenoid (Controls overall pressure to the gearbox)
MPC = 4,
// Torque converter clutch solenoid (Controls clutch application in the torque converter)
TCC = 5
};
namespace Sensors {
extern uint32_t isr_count;
/**
* Run this once on startup to configure all the sensor pins
*/
void configure_sensor_pins();
/**
* Returns the battery voltage sensed in millivolts (mV)
*
* Example: 1430 = 14.3V
*/
uint16_t read_vbatt();
/**
* Reads the speed sensor of the N2 input shaft (At front sun gear).
* This reports a speed in gears N,1,2,3,4,5
*
* IMPORTANT: This reading is NOT normalized or averaged.
* It is the callers responsibility to remove any outliers which may
* result due to signal noise or a faulty speed sensor.
*/
uint32_t read_n2_rpm();
/**
* Reads the speed sensor of the N3 input shaft (At front input carrier gear)
* This reports a speed in gears N,2,3,4,R1,R2
*
* IMPORTANT: This reading is NOT normalized or averaged.
* It is the callers responsibility to remove any outliers which may
* result due to signal noise or a faulty speed sensor.
*/
uint32_t read_n3_rpm();
/**
* Reads the ATF temperature from the gearbox.
*
* If read_park_lock returns true, this function CANNOT be used
* as it'll give a false reading.
*/
int16_t read_atf_temp();
/**
* Reads the park lock status within the gearbox
*
* If this function returns true, then reading ATF temp should not occur
* and instead the gearbox should substitute engine temp for gearbox ATF temp.
* When false, it means the gearbox is either in R or D, starting the engine
* is not allowed, and the function read_atf_temp can be used as normal
*/
bool read_park_lock();
/**
* Returns the current amperage being read from the solenoid circuit.
* 0 = 0A
* 6000 = 6A (Max read)
*
* All solenoids should never exceed 5A, and normal operation should never see more than 2A.
* If over current is detected, the caller must disable the solenoid as there might be a short!
*/
uint32_t read_solenoid_current(Solenoid sol);
}
#endif

289
src/solenoids/solenoids.cpp Normal file
View File

@ -0,0 +1,289 @@
#include "solenoids.h"
#include "esp_log.h"
#include "esp_adc_cal.h"
#include "pins.h"
esp_adc_cal_characteristics_t adc1_cal;
bool all_calibrated = false;
Solenoid::Solenoid(const char *name, gpio_num_t pwm_pin, FeedbackConfig f_config, uint32_t frequency, uint16_t start_pwm, ledc_channel_t channel, ledc_timer_t timer)
{
this->channel = channel;
this->timer = timer;
this->feedback_cfg = f_config;
this->ready = true; // Assume ready unless error!
this->name = name;
this->current = 0;
this->current_mutex = portMUX_INITIALIZER_UNLOCKED;
this->vref = 0;
this->vref_calibrated = false;
// Set GPIO direction of feedback pin
esp_err_t res = gpio_set_direction(f_config.pin, GPIO_MODE_INPUT);
if (res != ESP_OK)
{
this->ready = false;
ESP_LOGE("SOLENOID", "Solenoid %s failed to set feedback pin GPIO mode to GPIO_MODE_INPUT. Status code %d!", name, res);
return;
}
// Set attenuation of feedback pin to 11db
res = adc1_config_channel_atten(f_config.channel, ADC_ATTEN_11db);
if (res != ESP_OK)
{
this->ready = false;
ESP_LOGE("SOLENOID", "Solenoid %s failed to set feedback pin attenuation. Status code %d!", name, res);
return;
}
ledc_timer_config_t timer_cfg = {
.speed_mode = ledc_mode_t::LEDC_HIGH_SPEED_MODE, // Low speed timer mode
.duty_resolution = LEDC_TIMER_12_BIT,
.timer_num = timer,
.freq_hz = frequency,
.clk_cfg = LEDC_AUTO_CLK};
// Set the timer configuration
res = ledc_timer_config(&timer_cfg);
if (res != ESP_OK)
{
this->ready = false;
ESP_LOGE("SOLENOID", "Solenoid %s timer init failed. Status code %d!", name, res);
return;
}
// Set PWM channel configuration
ledc_channel_config_t channel_cfg = {
.gpio_num = pwm_pin,
.speed_mode = ledc_mode_t::LEDC_HIGH_SPEED_MODE,
.channel = channel,
.intr_type = LEDC_INTR_DISABLE, // Disable fade interrupt
.timer_sel = timer,
.duty = start_pwm,
.hpoint = 0};
res = ledc_channel_config(&channel_cfg);
if (res != ESP_OK)
{
this->ready = false;
ESP_LOGE("SOLENOID", "Solenoid %s channel init failed. Status code %d!", name, res);
return;
}
ESP_LOGI("SOLENOID", "Solenoid %s init OK!", name);
}
void Solenoid::write_pwm(uint8_t pwm)
{
esp_err_t res = ledc_set_duty(ledc_mode_t::LEDC_HIGH_SPEED_MODE, this->channel, (uint32_t)pwm << 4); // Convert from 8bit to 12bit
res = ledc_update_duty(ledc_mode_t::LEDC_HIGH_SPEED_MODE, this->channel);
if (res == ESP_OK)
{
this->curr_pwm = pwm;
}
else
{
ESP_LOGE("SOLENOID", "Solenoid %s failed to set duty to %d!", name, pwm);
}
}
uint16_t Solenoid::get_vref() {
return this->vref;
}
void Solenoid::write_pwm_percent(uint16_t percent) {
uint32_t clamped = (percent > 1000) ? 1000 : percent;
uint32_t request = (255 * clamped) / 1000;
this->write_pwm(request);
}
uint16_t Solenoid::get_pwm()
{
return this->curr_pwm;
}
uint16_t Solenoid::get_current_estimate()
{
portENTER_CRITICAL(&this->current_mutex);
uint16_t r = this->current;
portEXIT_CRITICAL(&this->current_mutex);
/**
* Calibration data from ADC:
* 65300 - 3180mV
* 0 - 0mV
*
* With 0.005Ohm shunt resistor and INA180A3 amplifier:
* 300mV = 6000mA
* 150mV = 3000mA
* 0mV = 0mA
*/
int current = 0;
// Convert ADC reading to approx mV
// Voltage = ADC_READING * 0.0487
// Current = Voltage * 2
//
// So basically current = ADC_READING * 0.0974
if (this->vref_calibrated) {
current = (r-this->vref)*0.0974;
} else {
current = r*0.0974;
}
return current;
}
void Solenoid::__set_current_internal(uint16_t c)
{
portENTER_CRITICAL(&this->current_mutex);
this->current = c;
portEXIT_CRITICAL(&this->current_mutex);
}
void Solenoid::__set_vref(uint16_t ref)
{
this->vref = ref;
this->vref_calibrated = true;
}
bool Solenoid::init_ok()
{
return this->ready;
}
Solenoid *sol_y3 = nullptr;
Solenoid *sol_y4 = nullptr;
Solenoid *sol_y5 = nullptr;
Solenoid *sol_mpc = nullptr;
Solenoid *sol_spc = nullptr;
Solenoid *sol_tcc = nullptr;
#define BYTES_PER_SAMPLE 2
#define NUM_SAMPLES 1024
char dma_buffer[BYTES_PER_SAMPLE*NUM_SAMPLES];
const i2s_config_t i2s_config = {
.mode = i2s_mode_t(I2S_MODE_MASTER | I2S_MODE_RX | I2S_MODE_ADC_BUILT_IN),
.sample_rate = 200000,
.bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT,
.channel_format = I2S_CHANNEL_FMT_ALL_LEFT,
.communication_format = i2s_comm_format_t(I2S_COMM_FORMAT_STAND_MSB),
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,
.dma_buf_count = 8,
.dma_buf_len = NUM_SAMPLES,
.use_apll = false,
.tx_desc_auto_clear = false,
.fixed_mclk = false
};
void read_solenoids_i2s(void*) {
esp_log_level_set("I2S", esp_log_level_t::ESP_LOG_WARN); // Discard noisy I2S logs!
// Y3, Y4, Y5, MPC, SPC, TCC
adc1_channel_t solenoid_channels[6] = { ADC1_CHANNEL_0, ADC1_CHANNEL_3, ADC1_CHANNEL_7, ADC1_CHANNEL_6, ADC1_CHANNEL_4, ADC1_CHANNEL_5 };
Solenoid* sol_order[6] = { sol_y3, sol_y4, sol_y5, sol_mpc, sol_spc, sol_tcc };
uint8_t solenoid_id = 0;
i2s_driver_install(I2S_NUM_0, &i2s_config, 0, nullptr);
//SET_PERI_REG_MASK(SYSCON_SARADC_CTRL2_REG, SYSCON_SARADC_SAR1_INV);
size_t bytes_read = 0;
#define SAMPLE_COUNT 5
uint32_t samples[SAMPLE_COUNT];
uint32_t sample_id=0;
uint32_t avg = 0;
while(true) {
i2s_set_adc_mode(ADC_UNIT_1, solenoid_channels[solenoid_id]);
i2s_adc_enable(I2S_NUM_0);
if (all_calibrated) {
vTaskDelay(33 / portTICK_RATE_MS); // Approx 5 refreshes per second
}
sample_id = 0;
avg = 0;
while(sample_id < SAMPLE_COUNT) {
bytes_read = 0;
i2s_read(I2S_NUM_0, &dma_buffer, NUM_SAMPLES*BYTES_PER_SAMPLE, &bytes_read, portMAX_DELAY);
uint32_t tmp = 0;
for (int i = 0; i < BYTES_PER_SAMPLE*NUM_SAMPLES; i += BYTES_PER_SAMPLE) {
tmp += (uint32_t)(dma_buffer[i] << 8 | dma_buffer[i+1]) & 0x00000000FFFFFFFF;
}
samples[sample_id] = tmp / NUM_SAMPLES;
sample_id += 1;
}
for (int i = 0; i < SAMPLE_COUNT; i++) {
avg += samples[i];
}
avg /= SAMPLE_COUNT;
sol_order[solenoid_id]->__set_current_internal(avg);
if (!all_calibrated) {
sol_order[solenoid_id]->__set_vref(avg);
}
solenoid_id++;
if (solenoid_id == 6) {
solenoid_id = 0;
all_calibrated = true;
}
// Configure ADC again and loop to read the next solenoid!
i2s_adc_disable(I2S_NUM_0);
}
}
bool init_all_solenoids()
{
// Need to configure ADC1
esp_err_t res = adc1_config_width(ADC_WIDTH_12Bit);
if (res != ESP_OK)
{
ESP_LOGE("SOLENOID", "FATAL. Could not configure ADC1 width!");
return false;
}
// Get calibration from ESP32 for ADC1
esp_adc_cal_value_t type = esp_adc_cal_characterize(adc_unit_t::ADC_UNIT_1, ADC_ATTEN_11db, ADC_WIDTH_12Bit, 0, &adc1_cal);
switch (type)
{
case esp_adc_cal_value_t::ESP_ADC_CAL_VAL_EFUSE_VREF:
ESP_LOGI("SOLENOID", "ESP_ADC_CAL_VAL_EFUSE_VREF used for ADC calibration!");
break;
case esp_adc_cal_value_t::ESP_ADC_CAL_VAL_EFUSE_TP:
ESP_LOGI("SOLENOID", "ESP_ADC_CAL_VAL_EFUSE_TP used for ADC calibration!");
break;
case esp_adc_cal_value_t::ESP_ADC_CAL_VAL_DEFAULT_VREF:
ESP_LOGI("SOLENOID", "ESP_ADC_CAL_VAL_DEFAULT_VREF used for ADC calibration!");
break;
default:
break;
}
sol_y3 = new Solenoid("Y3", PIN_Y3_PWM, FeedbackConfig{PIN_Y3_SENSE, ADC1_CHANNEL_0, 0}, 1000, 0, ledc_channel_t::LEDC_CHANNEL_0, ledc_timer_t::LEDC_TIMER_0);
sol_y4 = new Solenoid("Y4", PIN_Y4_PWM, FeedbackConfig{PIN_Y4_SENSE, ADC1_CHANNEL_3, 1}, 1000, 0, ledc_channel_t::LEDC_CHANNEL_1, ledc_timer_t::LEDC_TIMER_0);
sol_y5 = new Solenoid("Y5", PIN_Y5_PWM, FeedbackConfig{PIN_Y5_SENSE, ADC1_CHANNEL_7, 2}, 1000, 0, ledc_channel_t::LEDC_CHANNEL_2, ledc_timer_t::LEDC_TIMER_0);
sol_mpc = new Solenoid("MPC", PIN_MPC_PWM, FeedbackConfig{PIN_MPC_SENSE, ADC1_CHANNEL_6, 3}, 1000, 0, ledc_channel_t::LEDC_CHANNEL_3, ledc_timer_t::LEDC_TIMER_1);
sol_spc = new Solenoid("SPC", PIN_SPC_PWM, FeedbackConfig{PIN_SPC_SENSE, ADC1_CHANNEL_4, 4}, 1000, 0, ledc_channel_t::LEDC_CHANNEL_4, ledc_timer_t::LEDC_TIMER_1);
sol_tcc = new Solenoid("TCC", PIN_TCC_PWM, FeedbackConfig{PIN_TCC_SENSE, ADC1_CHANNEL_5, 5}, 100, 0, ledc_channel_t::LEDC_CHANNEL_5, ledc_timer_t::LEDC_TIMER_2);
res = ledc_fade_func_install(0);
if (res != ESP_OK) {
ESP_LOGE("SOLENOID", "FATAL. Could not load insert LEDC fade function %s", esp_err_to_name(res));
return false;
}
bool ok = sol_tcc->init_ok() && sol_mpc->init_ok() && sol_spc->init_ok() && sol_y3->init_ok() && sol_y4->init_ok() && sol_y5->init_ok();
if (!ok) { // Init error, don't do anything else
return false;
}
xTaskCreate(read_solenoids_i2s, "I2S-Reader", 8192, nullptr, 1, nullptr);
while(!all_calibrated) {
vTaskDelay(2);
}
ESP_LOGI("SOLENOID",
"Solenoid calibration readings: Y3: %d, Y4: %d, Y5: %d, MPC: %d, SPC: %d, TCC: %d",
sol_y3->get_vref(),
sol_y4->get_vref(),
sol_y5->get_vref(),
sol_mpc->get_vref(),
sol_spc->get_vref(),
sol_tcc->get_vref()
);
return ok;
}

62
src/solenoids/solenoids.h Normal file
View File

@ -0,0 +1,62 @@
#ifndef __SOLENOID_H_
#define __SOLENOID_H_
#include <stdint.h>
#include "driver/gpio.h"
#include "driver/ledc.h"
#include <freertos/FreeRTOS.h>
#include "freertos/task.h"
#include <driver/i2s.h>
#include <soc/syscon_reg.h>
#include <driver/adc.h>
#include <esp_event.h>
struct FeedbackConfig
{
gpio_num_t pin;
adc1_channel_t channel;
uint8_t readings_id;
};
class Solenoid
{
public:
Solenoid(const char *name, gpio_num_t pwm_pin, FeedbackConfig f_config, uint32_t frequency, uint16_t start_pwm, ledc_channel_t channel, ledc_timer_t timer);
void write_pwm(uint8_t pwm);
/**
* Writes PWM signal to the solenoid using percentages.
* 0 = 0%
* 1000 = 100%
*/
void write_pwm_percent(uint16_t percent);
uint16_t get_pwm();
uint16_t get_current_estimate();
bool init_ok();
uint16_t get_vref();
void __set_current_internal(uint16_t c);
void __set_vref(uint16_t ref);
private:
bool ready;
const char *name;
uint16_t curr_pwm;
uint16_t vref;
bool vref_calibrated;
ledc_channel_t channel;
ledc_timer_t timer;
FeedbackConfig feedback_cfg;
portMUX_TYPE current_mutex;
uint16_t current;
};
bool init_all_solenoids();
extern Solenoid *sol_y3;
extern Solenoid *sol_y4;
extern Solenoid *sol_y5;
extern Solenoid *sol_mpc;
extern Solenoid *sol_spc;
extern Solenoid *sol_tcc;
#endif // __SOLENOID_H_

41
src/speaker.cpp Normal file
View File

@ -0,0 +1,41 @@
#include "speaker.h"
#include "pins.h"
#include "driver/ledc.h"
Speaker::Speaker(gpio_num_t pin) {
ledc_timer_config_t timer_cfg = {
.speed_mode = ledc_mode_t::LEDC_LOW_SPEED_MODE, // Low speed timer mode
.duty_resolution = LEDC_TIMER_8_BIT,
.timer_num = LEDC_TIMER_3,
.freq_hz = 100,
.clk_cfg = LEDC_AUTO_CLK
};
// Set the timer configuration
ledc_timer_config(&timer_cfg);
// Set PWM channel configuration
ledc_channel_config_t channel_cfg = {
.gpio_num = pin,
.speed_mode = ledc_mode_t::LEDC_LOW_SPEED_MODE,
.channel = LEDC_CHANNEL_6,
.intr_type = LEDC_INTR_DISABLE, // Disable fade interrupt
.timer_sel = LEDC_TIMER_3,
.duty = 0,
.hpoint = 0
};
ledc_channel_config(&channel_cfg);
}
void Speaker::set_freq(uint32_t freq) {
if (freq != 0) {
ledc_set_freq(ledc_mode_t::LEDC_LOW_SPEED_MODE, LEDC_TIMER_3, freq);
ledc_set_duty(ledc_mode_t::LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_6, 128);
ledc_update_duty(ledc_mode_t::LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_6);
} else {
ledc_set_duty(ledc_mode_t::LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_6, 0);
ledc_update_duty(ledc_mode_t::LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_6);
}
}
Speaker spkr = Speaker(PIN_SPKR);

17
src/speaker.h Normal file
View File

@ -0,0 +1,17 @@
#ifndef __SPEAKER_H_
#define __SPEAKER_H_
#include "driver/gpio.h"
class Speaker {
public:
Speaker(gpio_num_t pin);
void set_freq(uint32_t freq);
};
extern Speaker spkr;
#endif // __SPEAKER_H_