Add full automotive RTOS project
Add kernel (Cortex-M0/M3/M4, Tricore, S32K, RISC-V ports), drivers, middleware (CAN stack, diagnostics, safety), applications, board support, build/test tooling, and documentation.
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
/**
|
||||
* @file dtc_manager.h
|
||||
* @brief Diagnostic Trouble Code Manager
|
||||
*/
|
||||
|
||||
#ifndef DTC_MANAGER_H
|
||||
#define DTC_MANAGER_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "kernel.h"
|
||||
|
||||
/* DTC Configuration */
|
||||
#define DTC_MAX_COUNT 100
|
||||
#define DTC_MAX_SNAPSHOT_RECORDS 5
|
||||
#define DTC_MAX_EXTENDED_DATA 10
|
||||
|
||||
/* DTC Status Bits */
|
||||
typedef struct {
|
||||
uint8_t test_failed : 1;
|
||||
uint8_t test_failed_this_operation_cycle : 1;
|
||||
uint8_t pending_dtc : 1;
|
||||
uint8_t confirmed_dtc : 1;
|
||||
uint8_t test_not_completed_since_last_clear : 1;
|
||||
uint8_t test_failed_since_last_clear : 1;
|
||||
uint8_t test_not_completed_this_operation_cycle : 1;
|
||||
uint8_t warning_indicator_requested : 1;
|
||||
} DtcStatus_t;
|
||||
|
||||
/* DTC Format */
|
||||
typedef struct {
|
||||
uint8_t high_byte;
|
||||
uint8_t middle_byte;
|
||||
uint8_t low_byte;
|
||||
} DtcCode_t;
|
||||
|
||||
/* DTC Snapshot Record */
|
||||
typedef struct {
|
||||
uint16_t record_number;
|
||||
uint8_t* data;
|
||||
uint16_t length;
|
||||
uint32_t timestamp;
|
||||
} DtcSnapshotRecord_t;
|
||||
|
||||
/* DTC Extended Data */
|
||||
typedef struct {
|
||||
uint16_t record_number;
|
||||
uint8_t* data;
|
||||
uint16_t length;
|
||||
} DtcExtendedData_t;
|
||||
|
||||
/* DTC Entry */
|
||||
typedef struct {
|
||||
DtcCode_t code;
|
||||
DtcStatus_t status;
|
||||
uint8_t severity;
|
||||
uint8_t functional_unit;
|
||||
uint32_t occurrence_counter;
|
||||
uint32_t aging_counter;
|
||||
uint32_t first_occurrence_time;
|
||||
uint32_t last_occurrence_time;
|
||||
DtcSnapshotRecord_t snapshots[DTC_MAX_SNAPSHOT_RECORDS];
|
||||
uint8_t snapshot_count;
|
||||
DtcExtendedData_t extended_data[DTC_MAX_EXTENDED_DATA];
|
||||
uint8_t extended_data_count;
|
||||
bool is_active;
|
||||
} DtcEntry_t;
|
||||
|
||||
/* DTC Manager Functions */
|
||||
KernelStatus_t dtc_manager_init(void);
|
||||
KernelStatus_t dtc_manager_deinit(void);
|
||||
KernelStatus_t dtc_manager_add_dtc(const DtcCode_t* code, uint8_t severity);
|
||||
KernelStatus_t dtc_manager_remove_dtc(const DtcCode_t* code);
|
||||
KernelStatus_t dtc_manager_set_status(const DtcCode_t* code, DtcStatus_t status);
|
||||
KernelStatus_t dtc_manager_get_status(const DtcCode_t* code, DtcStatus_t* status);
|
||||
KernelStatus_t dtc_manager_add_snapshot(const DtcCode_t* code,
|
||||
const uint8_t* data, uint16_t length);
|
||||
KernelStatus_t dtc_manager_add_extended_data(const DtcCode_t* code,
|
||||
const uint8_t* data, uint16_t length);
|
||||
KernelStatus_t dtc_manager_clear_all(void);
|
||||
uint16_t dtc_manager_get_count(void);
|
||||
KernelStatus_t dtc_manager_get_dtc(uint16_t index, DtcEntry_t* entry);
|
||||
KernelStatus_t dtc_manager_increment_occurrence(const DtcCode_t* code);
|
||||
void dtc_manager_main_function(void); /* Periodic processing */
|
||||
|
||||
#endif /* DTC_MANAGER_H */
|
||||
Reference in New Issue
Block a user