44 #include "drv_fault_handler.h" 59 .Status.bits.Enabled =
false,
60 .Status.bits.FaultActive =
true,
61 .Status.bits.FaultStatus =
true,
63 .SourceObject.ptrObject = NULL,
64 .SourceObject.bitMask = 0xFFFF,
65 .ReferenceObject.ptrObject = NULL,
66 .ReferenceObject.bitMask = 0xFFFF,
67 .TripResponse.compareThreshold = 0,
68 .TripResponse.eventThreshold = 0,
69 .TripResponse.ptrResponseFunction = NULL,
70 .RecoveryResponse.compareThreshold = 0,
71 .RecoveryResponse.eventThreshold = 0,
72 .RecoveryResponse.ptrResponseFunction = NULL,
171 static volatile uint16_t drv_FaultHandler_CheckObject(
volatile struct FAULT_OBJECT_s* fltObject) {
173 volatile uint16_t retval=1;
174 volatile uint16_t source=0;
177 if (fltObject == NULL)
192 source = (
volatile uint16_t)
193 abs((
volatile int32_t)source - (
volatile int32_t)reference);
200 case FLTCMP_GREATER_THAN:
204 else if (source < fltObject->RecoveryResponse.compareThreshold)
208 case FLTCMP_LESS_THAN:
209 if(source < fltObject->TripResponse.compareThreshold)
215 case FLTCMP_IS_EQUAL:
222 case FLTCMP_IS_NOT_EQUAL:
346 volatile uint16_t drv_FaultHandler_ScanObjects(
volatile struct FAULT_OBJECT_s* fltObjectList[],
volatile uint16_t size)
348 volatile uint16_t retval=1;
349 volatile uint16_t _i=0;
350 volatile uint16_t _fltlog=0;
351 volatile bool _fltstate=
false;
352 static bool _pre_fltstate=
false;
355 for (_i=size; _i>0; _i--)
357 retval &= drv_FaultHandler_CheckObject(fltObjectList[(_i-1)]);
360 _fltlog |= fltObjectList[(_i-1)]->Status.bits.FaultStatus;
367 if ((_pre_fltstate) && (!_fltstate))
384 _pre_fltstate = _fltstate;
425 volatile uint16_t drv_FaultHandler_Dispose(
volatile struct FAULT_OBJECT_s* fltObjectList[],
volatile uint16_t size)
427 volatile uint16_t retval=1;
428 volatile uint16_t _i=0;
430 for (_i=0; _i<size; _i++)
431 { *fltObjectList[_i] = fltObjectClear; }
volatile bool Enabled
Bit 15: Control bit enabling/disabling monitoring of the fault object.
volatile uint16_t Counter
Fault event counter (controlled by FAULT HANDLER)
volatile uint16_t(* FaultRecovery)(void)
Function pointer to the common fault recovery function.
enum FLT_COMPARE_TYPE_e CompareType
Bit <10:8>: Fault check comparison type control bits.
volatile struct FLT_COMPARE_OBJECT_s ReferenceObject
Reference object the source should be compared with.
volatile struct FLT_OBJECT_STATUS_s Status
Status word of this fault object.
volatile uint16_t FaultStatusList
Status word encoding individual fault object states in order of their list index.
volatile uint16_t * ptrObject
Pointer to register or variable which should be monitored.
volatile uint16_t FaultRecoveryCounter
Most recent number of fault recovery attempts.
volatile struct FAULT_MONITOR_STATUS_s Status
Status word of the fault monitor.
volatile uint16_t eventThreshold
Bit mask will be &-ed with source as value (use 0xFFFF for full value comparison)
volatile bool FaultStatus
Bit 0: Flag bit indicating if FAULT has been tripped.
volatile uint16_t FaultLatchCount
Number of fault recovery attempts after which the system gets locked in a latched fault state.
volatile uint16_t compareThreshold
Signal level at which the fault condition will be detected.
volatile uint16_t(* ptrResponseFunction)(void)
pointer to a user-defined function called when a defined fault monitoring event is detected
volatile struct FLT_COMPARE_OBJECT_s SourceObject
Object which should be monitored.
volatile bool FaultLatch
Bit 1: Flag bit indicating if a latched FAULT condition has been enforced.
volatile uint16_t bitMask
Bit mask will be &-ed with source as value (use 0xFFFF for full value comparison)
volatile struct FLT_EVENT_RESPONSE_s TripResponse
Settings defining the fault trip event.
volatile bool FaultActive
Bit 1: Flag bit indicating if fault condition has been detected but FAULT has not been tripped yet.
volatile bool FaultStatus
Bit 0: Flag bit indicating if a FAULT condition has been tripped.
volatile struct FLT_EVENT_RESPONSE_s RecoveryResponse
Settings defining the fault recovery event.