HVAC_M7_DataNonVolatile/DataNonVolatile.h

111 lines
2.9 KiB
C

//
// Created by CFIF on 20.10.25.
//
#ifndef HVAC_DEVICEDATANONVOLATILE_H
#define HVAC_DEVICEDATANONVOLATILE_H
#include "DataRuntime.h"
#include "HVAC_preDefine.h"
#define DEVICE_DATA_VERSION_CALIB 0x01
#define DEVICE_DATA_VERSION_PARAM 0x02
// BCD в двоичное число
#define bcd_to_binary(bcd) (((bcd >> 4) * 10) + (bcd & 0x0F))
// Двоичное число в BCD
#define binary_to_bcd(binary) (((binary / 10) << 4) | (binary % 10))
typedef struct __attribute__ ((packed)) {
uint8_t year; // BCD: 0x18 = 2018 год
uint8_t month; // BCD: 0x10 = октябрь
uint8_t day; // BCD: 0x16 = 16 число
char tester_serial[9]; // ASCII: "123456789"
} tFingerprint;
typedef struct __attribute__ ((packed)) {
uint8_t ModuleID; // ModuleID
char testerCode[9]; // ASCII: "123456789"
uint8_t year; // BCD: 0x18 = 2018 год
uint8_t month; // BCD: 0x10 = октябрь
uint8_t day; // BCD: 0x16 = 16 число
} tFingerprintDev;
typedef struct {
uint8_t year;
uint8_t month;
uint8_t day;
uint8_t revision;
} tVersionDateRevision;
typedef struct {
tVersionDateRevision SW;
tVersionDateRevision MBD;
} tInternal_SW_Version;
typedef enum {
AROMA_NOT_PRESENT = 0,
AROMA_PRESENT = 1,
AROMA_DEFAULT = 0xFF
} eAromaConfiguration;
typedef enum {
ALG_STANDART = 0,
ALG_LIMOUSINE = 1,
ALG_DEFAULT = 0xFF
} eAlgorithmConfiguration;
typedef enum {
REAR_HVAC_NOT_PRESENT = 0,
REAR_HVAC_PRESENT = 1,
REAR_HVAC_DEFAULT = 0xFF
} eRearHVACConfiguration;
typedef struct __attribute__ ((packed)) {
eAromaConfiguration AromaConfiguration;
eAlgorithmConfiguration AlgorithmConfiguration;
eRearHVACConfiguration RearHVACConfiguration;
} tStatus_CCU_Configuration;
typedef struct {
tInternal_SW_Version Internal_SW_Version;
char Software_classification_identification[15];
tFingerprint Tester_Fingerprint;
tFingerprintDev Boot_SW_Fingerprint;
tFingerprintDev Application_SW_Fingerprint;
char Spare_Part_Number[27];
char Serial_Number[26];
char Vehicle_Identification[17];
char ECU_hardware_number_NAMI[13];
char ECU_hardware_number_ECU_supplier[2];
char ECU_software_number_ECU_supplier[2];
char ECU_boot_software_identification_ECU_supplier[2];
tStatus_CCU_Configuration Status_CCU_Configuration;
} ecu_identification_t;
typedef struct __attribute__ ((packed)) {
uint32_t meta_fw_crc;
uint32_t size_fw;
tInternal_SW_Version internal_SW_Version;
tFingerprintDev fingerprint;
} tFirmwareMetaMap;
typedef struct {
ecu_identification_t identification;
} tDeviceSettings;
typedef struct {
uint32_t version_param;
uint32_t version_calib;
tDeviceSettings device;
} tDeviceDataNonVolatile;
void DeviceDataParam_InitDefaults(tDeviceDataNonVolatile *env);
void DeviceDataCalib_InitDefaults(tDeviceDataNonVolatile *env);
#endif //HVAC_DEVICEDATANONVOLATILE_H