Index: PersistentAlarm.c =================================================================== diff -u -r47562f55e05738340cff996e9b579e90716204db -rd4443dc3a156ca5dad93af0617cfc2967b97e448 --- PersistentAlarm.c (.../PersistentAlarm.c) (revision 47562f55e05738340cff996e9b579e90716204db) +++ PersistentAlarm.c (.../PersistentAlarm.c) (revision d4443dc3a156ca5dad93af0617cfc2967b97e448) @@ -35,7 +35,7 @@ U32 persistentTriggerPeriod; ///< Persistent count limit before trigger alarm U32 errorClearedStartTime; ///< Error cleared start time - U32 errorOccuredStartTime; ///< Error occured start time + U32 errorOccurredStartTime; ///< Error occurred start time } PERSISTENT_ALARM_DATA_T; // ********** private data ********** @@ -62,7 +62,7 @@ persistentAlarms[ alarmId ].persistentClearPeriod = persistentClearPeriod; persistentAlarms[ alarmId ].persistentTriggerPeriod = persistentTriggerPeriod; persistentAlarms[ alarmId ].errorClearedStartTime = 0U; - persistentAlarms[ alarmId ].errorOccuredStartTime = 0U; + persistentAlarms[ alarmId ].errorOccurredStartTime = 0U; } else { @@ -81,22 +81,28 @@ * @details Inputs: persistentAlarms[] * @details Outputs: none * @param alarmId Alarm id - * @param isErrorOccured Flag indicates error condition is occuring or not + * @param isErrorOccurred Flag indicates error condition is occurring or not * @return TRUE if error condition persisted over given time limit, FALSE if not *************************************************************************/ -BOOL isPersistentAlarmTriggered( ALARM_ID_T alarmId, BOOL const isErrorOccured ) +BOOL isPersistentAlarmTriggered( ALARM_ID_T alarmId, BOOL const isErrorOccurred ) { BOOL isAlarmTriggered = FALSE; if ( alarmId < NUM_OF_ALARM_IDS ) { - if ( ( TRUE == isErrorOccured ) && ( persistentAlarms[ alarmId ].errorOccuredStartTime != 0 ) ) + // Update start time when error occurs for the first time + if ( ( TRUE == isErrorOccurred ) && ( persistentAlarms[ alarmId ].errorOccurredStartTime == 0 ) ) { - isAlarmTriggered = didTimeout( persistentAlarms[ alarmId ].errorOccuredStartTime, persistentAlarms[ alarmId ].persistentTriggerPeriod ); + persistentAlarms[ alarmId ].errorOccurredStartTime = getMSTimerCount(); } + + if ( TRUE == isErrorOccurred ) + { + isAlarmTriggered = didTimeout( persistentAlarms[ alarmId ].errorOccurredStartTime, persistentAlarms[ alarmId ].persistentTriggerPeriod ); + } else { - persistentAlarms[ alarmId ].errorOccuredStartTime = getMSTimerCount(); + persistentAlarms[ alarmId ].errorOccurredStartTime = 0; } } else @@ -118,21 +124,28 @@ * @details Inputs: persistentAlarms[] * @details Outputs: none * @param alarmId Alarm id - * @param isErrorOccured Flag indicates error condition is occuring or not + * @param isErrorOccurred Flag indicates error condition is occurring or not * @return TRUE if error condition has been cleared over given time limit, FALSE if not *************************************************************************/ -BOOL isPersistentAlarmConditionCleared( ALARM_ID_T alarmId, BOOL const isErrorOccured ) -{ BOOL isErrorConditionCleared = FALSE; +BOOL isPersistentAlarmConditionCleared( ALARM_ID_T alarmId, BOOL const isErrorOccurred ) +{ + BOOL isErrorConditionCleared = FALSE; if ( alarmId < NUM_OF_ALARM_IDS ) { - if ( ( FALSE == isErrorOccured ) && ( persistentAlarms[ alarmId ].errorClearedStartTime != 0 ) ) + // Update start time when error condition clears for the first time + if ( ( FALSE == isErrorOccurred ) && ( persistentAlarms[ alarmId ].errorClearedStartTime == 0 ) ) { + persistentAlarms[ alarmId ].errorClearedStartTime = getMSTimerCount(); + } + + if ( FALSE == isErrorOccurred ) + { isErrorConditionCleared = didTimeout( persistentAlarms[ alarmId ].errorClearedStartTime, persistentAlarms[ alarmId ].persistentClearPeriod ); } else { - persistentAlarms[ alarmId ].errorClearedStartTime = getMSTimerCount(); + persistentAlarms[ alarmId ].errorClearedStartTime = 0; } } else Index: PersistentAlarm.h =================================================================== diff -u -r47562f55e05738340cff996e9b579e90716204db -rd4443dc3a156ca5dad93af0617cfc2967b97e448 --- PersistentAlarm.h (.../PersistentAlarm.h) (revision 47562f55e05738340cff996e9b579e90716204db) +++ PersistentAlarm.h (.../PersistentAlarm.h) (revision d4443dc3a156ca5dad93af0617cfc2967b97e448) @@ -33,8 +33,8 @@ // Persistent period resolution is in ms void initPersistentAlarm( ALARM_ID_T alarmIndex, U32 persistentClearPeriod, U32 persistentTriggerPeriod ); -BOOL isPersistentAlarmTriggered( ALARM_ID_T alarmIndex, BOOL const isErrorOccured ); -BOOL isPersistentAlarmConditionCleared( ALARM_ID_T alarmIndex, BOOL const isOutOfRange ); +BOOL isPersistentAlarmTriggered( ALARM_ID_T alarmIndex, BOOL const isErrorOccurred ); +BOOL isPersistentAlarmConditionCleared( ALARM_ID_T alarmIndex, BOOL const isErrorOccurred ); /**@}*/