// // Created by cfif on 23.01.2026. // #ifndef HVAC_M7_DIAGNOSTICTASK_H #define HVAC_M7_DIAGNOSTICTASK_H #include #include "LoggerInterface.h" #include "ccu_candb-binutil.h" #include "CanSpamReceiver.h" #include "lfs.h" #define LOG_DTC 1 #define V_DIAG_LOW 95 #define V_DIAG_HIGH 155 #define V_SEND_LOW 90 #define V_SEND_HIGH 150 #define DTC_TEST_FAILED 1 #define DTC_TEST_CONFIRMED 8 #define DTC_TEST_FAILED_CONFIRMED (DTC_TEST_FAILED | DTC_TEST_CONFIRMED) #define TDiagStart 500 #define DTC_CONFIRM_DELAY_MS 4000u typedef struct { uint32_t since_ms; /* момент первого срабатывания */ bool active; /* условие активно */ } DtcDebounce; enum { DEB_IONIZER_OPEN = 0, DEB_IONIZER_SHORT_GND, DEB_IONIZER_MALFUNCTION, DEB_AQS_OPEN, DEB_AQS_SHORT_GND, DEB_AQS_MALFUNCTION, DEB_DRS_FRONT_ZONE, DEB_DRS_REAR_ZONE, DEB_AROMA_OPEN, DEB_AROMA_SHORT_GND, DEB_AROMA_MALFUNCTION, DEB_COUNT }; typedef struct { uint8_t mask; uint8_t *dataResponse; } tDiagnosticDTC; typedef struct { osMutexId_t access; tLoggerInterface *logger; uint32_t tDiagStart; tCanSpamReceiver *canSpamReceiver; bool isNoBitsDTC; bool isCleanDTC; struct { uint32_t now_ms; bool isT15; bool isT30d; volatile uint16_t P_BATT; CCU_Errors_t *CCU_Errors; uint8_t *dtc_state_error_model; char *VIN; ccu_candb_error_missing_rx_t *CAN_ERROR_MISSING; ccu_candb_time_missing_rx_t *CAN_TIME_MISSING; uint8_t *LIN1_ERROR_MISSING; uint8_t *LIN2_ERROR_MISSING; uint8_t *LIN3_ERROR_MISSING; uint8_t *LIN4_ERROR_MISSING; uint8_t *LIN5_ERROR_MISSING; DtcDebounce dtc_aux_debounce[DEB_COUNT]; volatile uint8_t d_DTC_AROMATIZATION_OPEN; volatile uint8_t d_DTC_AROMATIZATION_SHORT_GND; volatile uint8_t d_DTC_AROMATIZATION_MALFUNCTION; volatile uint8_t d_DTC_AIR_QUALITY_SENSOR_OPEN; volatile uint8_t d_DTC_AIR_QUALITY_SENSOR_SHORT_GND; volatile uint8_t d_DTC_AIR_QUALITY_SENSOR_MALFUNCTION; volatile uint8_t d_DTC_IONIZER_OPEN; volatile uint8_t d_DTC_IONIZER_SHORT_GND; volatile uint8_t d_DTC_IONIZER_MALFUNCTION; volatile uint8_t d_DTC_DRS_FRONT_ZONE_MALFUNCTION; volatile uint8_t d_DTC_DRS_REAR_ZONE_MALFUNCTION; } state; } tDiagnostic; void Diagnostic_Init(tDiagnostic *env, CCU_Errors_t *CCU_Errors, uint8_t *dtc_state_error_model, char *VIN, ccu_candb_error_missing_rx_t *CAN_ERROR_MISSING, ccu_candb_time_missing_rx_t *CAN_TIME_MISSING, uint8_t *LIN1_ERROR_MISSING, uint8_t *LIN2_ERROR_MISSING, uint8_t *LIN3_ERROR_MISSING, uint8_t *LIN4_ERROR_MISSING, uint8_t *LIN5_ERROR_MISSING, tCanSpamReceiver *canSpamReceiver, tLoggerInterface *logger); void set_NoBitsDTC(tDiagnostic *env, bool noBitsDTC); void set_Dtc_state(tDiagnostic *env); uint32_t diagnostic_ClearDiagnosticInformation_14(tDiagnostic *env); uint32_t diagnostic_UDS_ReadDTCInformation_19_count(tDiagnostic *env, tDiagnosticDTC *diagnosticDTC); uint32_t diagnostic_UDS_ReadDTCInformation_19_dtc(tDiagnostic *env, tDiagnosticDTC *diagnosticDTC); uint32_t diagnostic_UDS_ReadDTCSupportDTC_19_dtc(tDiagnostic *env, tDiagnosticDTC *diagnosticDTC); #endif //HVAC_M7_DIAGNOSTICTASK_H