Index: Accel.c =================================================================== diff -u -re6b38d1e5fbb5eab5cf62e850890632ebcfeb1a7 -r9a59cef171550b5a9cb4f3028520c5d3f9d0c4c0 --- Accel.c (.../Accel.c) (revision e6b38d1e5fbb5eab5cf62e850890632ebcfeb1a7) +++ Accel.c (.../Accel.c) (revision 9a59cef171550b5a9cb4f3028520c5d3f9d0c4c0) @@ -16,6 +16,8 @@ #ifndef _VECTORCAST_ #include +#else + #define _VC_OVERRIDE_MATH_ #endif #include "Accel.h" @@ -63,7 +65,7 @@ static ACCEL_STATE_T accelState = ACCELEROMETER_START_STATE; ///< current state of accelerometer monitor state machine static U32 accelDataPublicationTimerCounter = 0; ///< used to schedule accelerometer data publication to CAN bus -static S32 accelCalOffsets[ NUM_OF_ACCEL_AXES ] = { 0, 0, 0 }; ///< accelerometer calibration offsets. +static F32 accelCalOffsets[ NUM_OF_ACCEL_AXES ] = { 0, 0, 0 }; ///< accelerometer calibration offsets. static OVERRIDE_U32_T accelDataPublishInterval = { ACCEL_DATA_PUB_INTERVAL, ACCEL_DATA_PUB_INTERVAL, 0, 0 }; ///< interval (in ms/task interval) at which to publish accelerometer data to CAN bus. static OVERRIDE_F32_T accelAxes[ NUM_OF_ACCEL_AXES ]; ///< Measured accelerometer axis readings (calibrated, converted to gravities). @@ -203,22 +205,14 @@ #endif } - // apply calibration (axis offsets) - x += accelCalOffsets[ ACCEL_AXIS_X ]; - y += accelCalOffsets[ ACCEL_AXIS_Y ]; - z += accelCalOffsets[ ACCEL_AXIS_Z ]; - xm += accelCalOffsets[ ACCEL_AXIS_X ]; - ym += accelCalOffsets[ ACCEL_AXIS_Y ]; - zm += accelCalOffsets[ ACCEL_AXIS_Z ]; + // convert to gravities and apply calibration (axis offsets) + accelAxes[ ACCEL_AXIS_X ].data = (F32)x * G_PER_LSB + accelCalOffsets[ ACCEL_AXIS_X ]; + accelAxes[ ACCEL_AXIS_Y ].data = (F32)y * G_PER_LSB + accelCalOffsets[ ACCEL_AXIS_Y ]; + accelAxes[ ACCEL_AXIS_Z ].data = (F32)z * G_PER_LSB + accelCalOffsets[ ACCEL_AXIS_Z ]; + accelMaxs[ ACCEL_AXIS_X ].data = (F32)xm * G_PER_LSB + accelCalOffsets[ ACCEL_AXIS_X ]; + accelMaxs[ ACCEL_AXIS_Y ].data = (F32)ym * G_PER_LSB + accelCalOffsets[ ACCEL_AXIS_Y ]; + accelMaxs[ ACCEL_AXIS_Z ].data = (F32)zm * G_PER_LSB + accelCalOffsets[ ACCEL_AXIS_Z ]; - // convert to gravities - accelAxes[ ACCEL_AXIS_X ].data = (F32)x * G_PER_LSB; - accelAxes[ ACCEL_AXIS_Y ].data = (F32)y * G_PER_LSB; - accelAxes[ ACCEL_AXIS_Z ].data = (F32)z * G_PER_LSB; - accelMaxs[ ACCEL_AXIS_X ].data = (F32)xm * G_PER_LSB; - accelMaxs[ ACCEL_AXIS_Y ].data = (F32)ym * G_PER_LSB; - accelMaxs[ ACCEL_AXIS_Z ].data = (F32)zm * G_PER_LSB; - // filter readings to get a stable vector for tilt filterAccelReadings(); @@ -608,7 +602,7 @@ * @param offsetZ : offset calibration factor for Z axis * @return TRUE if calibration factors successfully set/stored, FALSE if not *************************************************************************/ -BOOL setAccelCalibration( S32 offsetX, S32 offsetY, S32 offsetZ ) +BOOL setAccelCalibration( F32 offsetX, F32 offsetY, F32 offsetZ ) { BOOL result = FALSE; @@ -644,7 +638,7 @@ * @param offsetZ : value to populate with Z axis offset calibration factor * @return none *************************************************************************/ -void getAccelCalibration( S32 *offsetX, S32 *offsetY, S32 *offsetZ ) +void getAccelCalibration( F32 *offsetX, F32 *offsetY, F32 *offsetZ ) { *offsetX = accelCalOffsets[ ACCEL_AXIS_X ]; *offsetY = accelCalOffsets[ ACCEL_AXIS_Y ]; Index: Accel.h =================================================================== diff -u -r6a00bc5632cfdb84cf72e7dbbc55ff115e3481d5 -r9a59cef171550b5a9cb4f3028520c5d3f9d0c4c0 --- Accel.h (.../Accel.h) (revision 6a00bc5632cfdb84cf72e7dbbc55ff115e3481d5) +++ Accel.h (.../Accel.h) (revision 9a59cef171550b5a9cb4f3028520c5d3f9d0c4c0) @@ -48,8 +48,8 @@ SELF_TEST_STATUS_T execAccelTest( void ); -BOOL setAccelCalibration( S32 offsetX, S32 offsetY, S32 offsetZ ); -void getAccelCalibration( S32 *offsetX, S32 *offsetY, S32 *offsetZ ); +BOOL setAccelCalibration( F32 offsetX, F32 offsetY, F32 offsetZ ); +void getAccelCalibration( F32 *offsetX, F32 *offsetY, F32 *offsetZ ); BOOL testSetAccelDataPublishIntervalOverride( U32 value ); BOOL testResetAccelDataPublishIntervalOverride( void ); BOOL testSetAccelAxisOverride( U32 axis, F32 value ); Index: Common.h =================================================================== diff -u -re6b38d1e5fbb5eab5cf62e850890632ebcfeb1a7 -r9a59cef171550b5a9cb4f3028520c5d3f9d0c4c0 --- Common.h (.../Common.h) (revision e6b38d1e5fbb5eab5cf62e850890632ebcfeb1a7) +++ Common.h (.../Common.h) (revision 9a59cef171550b5a9cb4f3028520c5d3f9d0c4c0) @@ -177,13 +177,14 @@ #define _enable_IRQ() #define _disable_IRQ() #define _enable_FIQ() - #define _disable_FIQ() +#ifdef _VC_OVERRIDE_MATH_ #define fabs(v) ((v) < 0.0 ? ((v) * -1.0) : (v)) extern F32 asin( F32 val ); extern F32 sqrt( F32 val ); - + extern F32 pow( F32 val, F32 exp ); #endif +#endif // include alarm mgmt header so any module can trigger an alarm #include "AlarmMgmt.h" Index: NVDataMgmt.c =================================================================== diff -u -rb4e91eb8049e94b0937e341880a90327113fce56 -r9a59cef171550b5a9cb4f3028520c5d3f9d0c4c0 --- NVDataMgmt.c (.../NVDataMgmt.c) (revision b4e91eb8049e94b0937e341880a90327113fce56) +++ NVDataMgmt.c (.../NVDataMgmt.c) (revision 9a59cef171550b5a9cb4f3028520c5d3f9d0c4c0) @@ -219,6 +219,7 @@ static BOOL hasCommandTimedout = FALSE; ///< Boolean flag for timeout of the commands static U32 currentTime = 0; ///< Current time static BOOL calRecordIsValid = FALSE; ///< Flag indicates whether stored calibration record was found to be valid +static volatile BOOL powerOffIsImminent = FALSE; ///< Power off warning has been signaled. Non-volatile memory operations should be completed ASAP and then ceased. // Private functions @@ -283,6 +284,21 @@ } /************************************************************************* + * @brief + * The signalPowerOffWarning signals this module that system power off is \n + * imminent and any non-volatile data writes in progress should be wrapped up \n + * quickly and any pending non-volatile data writes should not be started. + * @details + * Inputs : none + * Outputs : powerOffIsImminent + * @return none + *************************************************************************/ +void signalPowerOffWarning( void ) +{ + powerOffIsImminent = TRUE; +} + +/************************************************************************* * @brief setMfgData * The setMfgData updates the struct that holds the manufacturing data, * calls another function to calculate the CRC for the provided data and @@ -366,10 +382,7 @@ if ( buffer != NULL ) { memcpy ( buffer, (U08*)&calibrationRecord.calData, sizeof(CALIBRATION_DATA_T) ); - if ( TRUE == calRecordIsValid ) - { - status = TRUE; - } + status = calRecordIsValid; } return status; @@ -740,7 +753,7 @@ * @return none *************************************************************************/ void execNVDataMgmt( void ) -{ +{ // TODO - not sure where it should go Dara, but need to look at powerOffIsImminent flag and block queuing of any new jobs, maybe even block starting of any new jobs if flag is set switch ( NVDataMgmtExecState ) { case NVDATAMGMT_EXEC_STATE_WAIT_FOR_POST: Index: NVDataMgmt.h =================================================================== diff -u -rb4e91eb8049e94b0937e341880a90327113fce56 -r9a59cef171550b5a9cb4f3028520c5d3f9d0c4c0 --- NVDataMgmt.h (.../NVDataMgmt.h) (revision b4e91eb8049e94b0937e341880a90327113fce56) +++ NVDataMgmt.h (.../NVDataMgmt.h) (revision 9a59cef171550b5a9cb4f3028520c5d3f9d0c4c0) @@ -59,9 +59,9 @@ typedef struct calibration_Data { U32 calRecordRevision; ///< Revision of calibration record (rev when structure changes to determine compatibility with f/w version) - S32 accelXOffset; ///< Accelerometer X axis offset - S32 accelYOffset; ///< Accelerometer Y axis offset - S32 accelZOffset; ///< Accelerometer Z axis offset + F32 accelXOffset; ///< Accelerometer X axis offset + F32 accelYOffset; ///< Accelerometer Y axis offset + F32 accelZOffset; ///< Accelerometer Z axis offset #ifdef _HD_ F32 bloodFlowGain; ///< Gain for blood flow sensor F32 bloodFlowOffset_mL_min; ///< Offset for blood flow sensor @@ -109,6 +109,8 @@ void initNVDataMgmt ( void ); +void signalPowerOffWarning( void ); + void execNVDataMgmt ( void ); SELF_TEST_STATUS_T execNVDataMgmtSelfTest ( void );