Index: Accel.c =================================================================== diff -u -r72fb18f47e588c01d4dd1df035fc981a26704040 -r7a2ae3f592cf60f105b932de40c387dba3939170 --- Accel.c (.../Accel.c) (revision 72fb18f47e588c01d4dd1df035fc981a26704040) +++ Accel.c (.../Accel.c) (revision 7a2ae3f592cf60f105b932de40c387dba3939170) @@ -49,6 +49,9 @@ #define MAX_TILT_G ( 1.0F ) ///< Maximum tilt (in g). #define MAX_TILT_ANGLE_DEG ( 90.0F ) ///< Maximum tilt angle (in degrees). #define DATA_PUBLISH_COUNTER_START_COUNT 30 ///< Data publish counter start count. +// POST test +#define ACCEl_POST_TEST_COUNT 5 ///< Number of times to repeat POST test +#define ACCEl_POST_TEST_FAIL_MAX 3 ///< Maximum number of times POST test may fail (<= ACCEl_POST_TEST_COUNT) /// Enumeration of accelerometer monitor states. typedef enum Accelerometer_States @@ -601,7 +604,14 @@ * @return the current state of the accelerometer self-test. *************************************************************************/ SELF_TEST_STATUS_T execAccelTest( void ) -{ +{ + // TODO Remove comment: This POST test is to make sure the Accelerometer + // reading is within tolerance, but could fail if device is bumped/moved. + // 5 Repeats on 50ms interval with 3 fails required is intended to + // mitigate a false fail from bumping the machine. Test will take 250ms. + // Requirement may need to be updated. + static U08 postTestCounter = 0; + static U08 postFailCounter = 0; SELF_TEST_STATUS_T result = SELF_TEST_STATUS_IN_PROGRESS; switch ( accelSelfTestState ) @@ -619,6 +629,8 @@ { accelSelfTestState = ACCELEROMETER_SELF_TEST_STATE_IN_PROGRESS; } + postTestCounter = 0; + postFailCounter = 0; } break; @@ -634,15 +646,34 @@ } else { - result = SELF_TEST_STATUS_FAILED; + if ( postFailCounter < ACCEl_POST_TEST_FAIL_MAX ) + { + // count the failures + postFailCounter++; + result = SELF_TEST_STATUS_PASSED; + } + else + { + result = SELF_TEST_STATUS_FAILED; #ifdef _DG_ - SET_ALARM_WITH_1_F32_DATA( ALARM_ID_DG_ACCELEROMETER_SELF_TEST_FAILURE, vectorLen ) + SET_ALARM_WITH_1_F32_DATA( ALARM_ID_DG_ACCELEROMETER_SELF_TEST_FAILURE, vectorLen ) #else - SET_ALARM_WITH_1_F32_DATA( ALARM_ID_HD_ACCELEROMETER_SELF_TEST_FAILURE, vectorLen ) + SET_ALARM_WITH_1_F32_DATA( ALARM_ID_HD_ACCELEROMETER_SELF_TEST_FAILURE, vectorLen ) #endif + } } - accelSelfTestState = ACCELEROMETER_SELF_TEST_STATE_COMPLETE; + if ( postTestCounter < ACCEl_POST_TEST_COUNT ) + { + // Repeat the test + postTestCounter++; + accelSelfTestState = ACCELEROMETER_SELF_TEST_STATE_IN_PROGRESS; + result = SELF_TEST_STATUS_IN_PROGRESS; + } + else + { + accelSelfTestState = ACCELEROMETER_SELF_TEST_STATE_COMPLETE; + } } break; @@ -655,7 +686,7 @@ SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_ACCEL_INVALID_SELF_TEST_STATE, accelSelfTestState ) #endif break; - } + } return result; }