Index: Accel.c =================================================================== diff -u -r32bd3838f190cdbfb47ff3a4b41028f152505510 -r33eaf4899ee38c290e4b4e8acd8d5a717b62d349 --- Accel.c (.../Accel.c) (revision 32bd3838f190cdbfb47ff3a4b41028f152505510) +++ Accel.c (.../Accel.c) (revision 33eaf4899ee38c290e4b4e8acd8d5a717b62d349) @@ -88,7 +88,7 @@ static BOOL tiltErrorDetected; ///< Flag indicates a tilt error has been detected and tilt must now come below alarm clear threshold to clear alarm. static BOOL shockErrorDetected; ///< Flag indicates a shock error has been detected and g-force must now come below alarm clear threshold to clear alarm. - + static ACCELEROMETER_SELF_TEST_STATE_T accelSelfTestState = ACCELEROMETER_SELF_TEST_STATE_START; ///< current accelerometer self-test state // ********** private function prototypes ********** @@ -126,8 +126,8 @@ accelMaxs[ axis ].ovData = 0.0; accelMaxs[ axis ].ovInitData = 0.0; accelMaxs[ axis ].override = OVERRIDE_RESET; - } - + } + tiltErrorDetected = FALSE; shockErrorDetected = FALSE; } @@ -483,8 +483,8 @@ { // excessive tilt must persist before triggering alarm if ( ++accelTiltErrorTimerCounter > MAX_TILT_PERSISTENCE ) - { - tiltErrorDetected = TRUE; + { + tiltErrorDetected = TRUE; #ifdef _DG_ SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DG_EXCESSIVE_TILT, x, y ) #else @@ -500,10 +500,18 @@ SET_ALARM_WITH_2_F32_DATA( ALARM_ID_HD_EXCESSIVE_TILT, x, y ) #endif } + else if ( ( TRUE == tiltErrorDetected ) && ( fabs( x ) > MAX_TILT_ANGLE_TO_CLEAR_ALARM ) && ( fabs( y ) > MAX_TILT_ANGLE_TO_CLEAR_ALARM ) ) + { +#ifdef _DG_ + SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DG_EXCESSIVE_TILT, x, y ) +#else + SET_ALARM_WITH_2_F32_DATA( ALARM_ID_HD_EXCESSIVE_TILT, x, y ) +#endif + } else if ( ( fabs( x ) <= MAX_TILT_ANGLE_TO_CLEAR_ALARM ) && ( fabs( y ) <= MAX_TILT_ANGLE_TO_CLEAR_ALARM ) ) { - accelTiltErrorTimerCounter = 0; - tiltErrorDetected = FALSE; + accelTiltErrorTimerCounter = 0; + tiltErrorDetected = FALSE; #ifdef _DG_ clearAlarm( ALARM_ID_DG_EXCESSIVE_TILT ); #else