8 #ifndef SYSTEM_LIBRARIES_INC_OC_DIAG_H_ 9 #define SYSTEM_LIBRARIES_INC_OC_DIAG_H_ 11 #include <oc_errors.h> 18 oC_Diag_State_NotStarted ,
19 oC_Diag_State_Prepared ,
20 oC_Diag_State_InProgress ,
21 oC_Diag_State_Finished ,
22 oC_Diag_State_NumberOfStates
29 const char * ResultDescription;
30 oC_ErrorCode_t Result;
31 oC_Diag_State_t State;
41 typedef oC_ErrorCode_t (*oC_Diag_PerformFunction_t)(
oC_Diag_t * Diag ,
void * Context );
46 oC_Diag_PerformFunction_t PerformFunction;
49 #define oC_Diag_GetNumberOfSupportedDiagnostics( SupportedDiagArray ) oC_ARRAY_SIZE(SupportedDiagArray) 53 static inline oC_ErrorCode_t oC_Diag_PerformDiagnostic(
oC_Diag_t * Diag,
const char * Name ,
const char * SubName , oC_Diag_PerformFunction_t PerformFunction ,
void * Context )
55 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
58 ErrorCondition( Diag !=
NULL, oC_ErrorCode_WrongAddress )
59 && ErrorCondition( Name !=
NULL, oC_ErrorCode_WrongAddress )
60 && ErrorCondition( PerformFunction !=
NULL, oC_ErrorCode_WrongAddress )
64 Diag->SubName = SubName;
65 Diag->ResultDescription =
NULL;
66 Diag->State = oC_Diag_State_InProgress;
73 Diag->Result = PerformFunction(Diag,Context);
74 Diag->State = oC_Diag_State_Finished;
81 errorCode = oC_ErrorCode_None;
87 #define oC_Diag_PerformDiagnostics(SupportedArray,DiagsArray,DiagsSize,SubName,Context) oC_Diag_PerformDiagnosticsFunction((SupportedArray),oC_ARRAY_SIZE(SupportedArray),(DiagsArray),(DiagsSize),(SubName),(Context)) 91 static inline oC_ErrorCode_t oC_Diag_PerformDiagnosticsFunction(
const oC_Diag_SupportedDiagData_t * SupportedArray , uint32_t NumberOfSupportedDiags ,
oC_Diag_t * DiagsArray, uint32_t DiagsSize ,
const char * SubName ,
void * Context )
93 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
96 ErrorCondition( SupportedArray !=
NULL , oC_ErrorCode_WrongAddress )
99 errorCode = oC_ErrorCode_None;
101 for(uint32_t i = 0; i < NumberOfSupportedDiags && i < DiagsSize && !oC_ErrorOccur(errorCode) ; i++)
103 errorCode = oC_Diag_PerformDiagnostic(&DiagsArray[i],SupportedArray->Name,SubName,SupportedArray->PerformFunction,Context);
The file with interface for the GPIO driver.
void(* PrintFunction)(struct oC_Diag_t *Diag)
prints state of the diagnostic
Static array definitions.
#define NULL
pointer to a zero