Index: Accel.c =================================================================== diff -u -r1797ae184a55396ff3464cead47f16bac9dda84c -rf853004049bc4701d911701e48768cd17189faea --- Accel.c (.../Accel.c) (revision 1797ae184a55396ff3464cead47f16bac9dda84c) +++ Accel.c (.../Accel.c) (revision f853004049bc4701d911701e48768cd17189faea) @@ -92,9 +92,11 @@ static BOOL shockErrorDetected; ///< Flag indicates a shock error has been detected and g-force must now come below alarm clear threshold to clear alarm. #ifdef _HD_ static HD_ACCELEROMETER_SENSOR_CAL_RECORD_T accelSensorCalRecord; ///< HD accelerometer calibration record. +static const ALARM_ID_T CAL_ALARM = ALARM_ID_HD_ACCELEROMETERS_INVALID_CAL_RECORD; ///< HD accelerometer calibration alarm. #endif #ifdef _DG_ static DG_ACCEL_SENSOR_CAL_RECORD_T accelSensorCalRecord; ///< DG accelerometer calibration record. +static const ALARM_ID_T CAL_ALARM = ALARM_ID_DG_ACCELEROMETERS_INVALID_CAL_RECORD; ///< DG accelerometer calibration alarm. #endif // ********** private function prototypes ********** @@ -105,7 +107,6 @@ static void filterAccelReadings( void ); static void checkForTiltError( void ); static void checkForShockError( void ); -static BOOL processCalibrationData( void ); static F32 calcVectorLength( F32 x, F32 y, F32 z ); /*********************************************************************//** @@ -151,7 +152,7 @@ // Check if a new calibration is available if ( TRUE == isNewCalibrationRecordAvailable() ) { - processCalibrationData(); + getNVRecord2Driver( GET_CAL_ACCEL_SENSORS, (U08*)&accelSensorCalRecord, sizeof( accelSensorCalRecord ), 0, CAL_ALARM ); } switch ( accelState ) @@ -582,51 +583,6 @@ /*********************************************************************//** * @brief - * The processCalibrationData function gets the calibration data and makes - * sure it is valid by checking the calibration date. The calibration date - * should not be 0. - * @details Inputs: none - * @details Outputs: accelSensorCalRecord - * @return TRUE if the calibration record is valid, otherwise FALSE - *************************************************************************/ -static BOOL processCalibrationData( void ) -{ - BOOL status = TRUE; - -#ifdef _HD_ - HD_ACCELEROMETER_SENSOR_CAL_RECORD_T calData = getHDAccelerometerSensorCalibrationRecord(); -#endif - -#ifdef _DG_ - DG_ACCEL_SENSOR_CAL_RECORD_T calData = getDGAccelerometerSensorCalibrationRecord(); -#endif - - // Check if the calibration data that was received from NVDataMgmt is legitimate - // The calibration date item should not be zero. If the calibration date is 0, - // then the accelerometer data is not stored in the NV memory or it was corrupted. - if ( 0 == calData.calibrationTime ) - { -#ifndef SKIP_CAL_CHECK -#ifdef _HD_ - activateAlarmNoData( ALARM_ID_HD_ACCELEROMETERS_INVALID_CAL_RECORD ); -#endif -#ifdef _DG_ - activateAlarmNoData( ALARM_ID_DG_ACCELEROMETERS_INVALID_CAL_RECORD ); -#endif - status = FALSE; -#endif - } - - // The calibration data was valid, update the local copy - accelSensorCalRecord.accelXOffset = calData.accelXOffset; - accelSensorCalRecord.accelYOffset = calData.accelYOffset; - accelSensorCalRecord.accelZOffset = calData.accelZOffset; - - return status; -} - -/*********************************************************************//** - * @brief * The calcVectorLength function calculates the length of a vector with * given vector axis magnitudes. * @details Inputs: none @@ -660,13 +616,7 @@ { case ACCELEROMETER_SELF_TEST_STATE_START: { -#ifdef _HD_ - HD_ACCELEROMETER_SENSOR_CAL_RECORD_T cal = getHDAccelerometerSensorCalibrationRecord(); -#endif -#ifdef _DG_ - DG_ACCEL_SENSOR_CAL_RECORD_T cal = getDGAccelerometerSensorCalibrationRecord(); -#endif - BOOL calStatus = processCalibrationData(); + BOOL calStatus = getNVRecord2Driver( GET_CAL_ACCEL_SENSORS, (U08*)&accelSensorCalRecord, sizeof( accelSensorCalRecord ), 0, CAL_ALARM ); if ( FALSE == calStatus ) {