Index: Accel.c =================================================================== diff -u -rb20ab0cdf009f97c0aff428219e901b0603e3fd2 -r6c500be6ac0c5adffc0d91b666862e35ba27e2db --- Accel.c (.../Accel.c) (revision b20ab0cdf009f97c0aff428219e901b0603e3fd2) +++ Accel.c (.../Accel.c) (revision 6c500be6ac0c5adffc0d91b666862e35ba27e2db) @@ -30,55 +30,55 @@ // ********** private definitions ********** -#define ACCEL_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< interval (ms/task time) at which the accelerometer data is published on the CAN bus -#define SIZE_OF_ROLLING_AVG ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< vector for tilt is filtered w/ moving average -#define G_PER_LSB ( 0.00390625 ) ///< conversion from counts (LSB) to gravities -#define NO_NEW_ACCEL_SAMPLES_TIMEOUT ( 100 / TASK_PRIORITY_INTERVAL ) ///< maximum time w/o new accelerometer sample from FPGA. -#define NOMINAL_ACCEL_VECTOR_LENGTH ( 1.0 ) ///< expect unit vector length when system is stable +#define ACCEL_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< Interval (ms/task time) at which the accelerometer data is published on the CAN bus +#define SIZE_OF_ROLLING_AVG ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< Vector for tilt is filtered w/ moving average +#define G_PER_LSB ( 0.00390625 ) ///< Conversion from counts (LSB) to gravities +#define NO_NEW_ACCEL_SAMPLES_TIMEOUT ( 100 / TASK_PRIORITY_INTERVAL ) ///< Maximum time w/o new accelerometer sample from FPGA +#define NOMINAL_ACCEL_VECTOR_LENGTH ( 1.0 ) ///< Expect unit vector length when system is stable #define MAX_ACCEL_VECTOR_LENGTH_ERROR ( 0.1 ) ///< POST test looks at vector length at presumably stable moment - should be 1 +/- 0.1 -#define MAX_TILT_ANGLE ( 7.0 ) ///< maximum tilt of system before alarm. -#define MIN_TILT_ANGLE_TO_CLEAR_ALARM ( 5.0 ) ///< minimum tilt of system before alarm is cleared. -#define MAX_TILT_PERSISTENCE ( 1 * MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< maximum time (in task intervals) that a tilt in excess of limit can persist before alarm -#define MAX_SHOCK_ACCELERATION ( 2.0 ) ///< maximum shock (acceleration) measured on any axis before alarm. -#define MAX_TILT_G ( 1.0 ) ///< maximum tilt (in g) -#define MAX_TILT_ANGLE_DEG ( 90.0 ) ///< maximum tilt angle (in degrees) +#define MAX_TILT_ANGLE ( 7.0 ) ///< Maximum tilt of system before alarm +#define MIN_TILT_ANGLE_TO_CLEAR_ALARM ( 5.0 ) ///< Minimum tilt of system before alarm is cleared +#define MAX_TILT_PERSISTENCE ( 1 * MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< Maximum time (in task intervals) that a tilt in excess of limit can persist before alarm +#define MAX_SHOCK_ACCELERATION ( 2.0 ) ///< Maximum shock (acceleration) measured on any axis before alarm +#define MAX_TILT_G ( 1.0 ) ///< Maximum tilt (in g) +#define MAX_TILT_ANGLE_DEG ( 90.0 ) ///< Maximum tilt angle (in degrees) /// Enumeration of accelerometer monitor states. typedef enum Accelerometer_States { - ACCELEROMETER_START_STATE = 0, ///< Accelerometer start state. - ACCELEROMETER_MONITOR_STATE, ///< Accelerometer monitor state. - NUM_OF_ACCELEROMETER_STATES ///< Number of accelerometer states. + ACCELEROMETER_START_STATE = 0, ///< Accelerometer start state + ACCELEROMETER_MONITOR_STATE, ///< Accelerometer monitor state + NUM_OF_ACCELEROMETER_STATES ///< Number of accelerometer states } ACCEL_STATE_T; /// Enumeration of accelerometer self test states. typedef enum Accelerometer_Self_Test_States { - ACCELEROMETER_SELF_TEST_STATE_START = 0, ///< Accelerometer self test start state. - ACCELEROMETER_SELF_TEST_STATE_IN_PROGRESS, ///< Accelerometer self test in progress state. - ACCELEROMETER_SELF_TEST_STATE_COMPLETE, ///< Accelerometer self test completed state. - NUM_OF_ACCELEROMETER_SELF_TEST_STATES ///< Number of accelerometer self test states. + ACCELEROMETER_SELF_TEST_STATE_START = 0, ///< Accelerometer self test start state + ACCELEROMETER_SELF_TEST_STATE_IN_PROGRESS, ///< Accelerometer self test in progress state + ACCELEROMETER_SELF_TEST_STATE_COMPLETE, ///< Accelerometer self test completed state + NUM_OF_ACCELEROMETER_SELF_TEST_STATES ///< Number of accelerometer self test states } ACCELEROMETER_SELF_TEST_STATE_T; // ********** private data ********** 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 F32 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). -static OVERRIDE_F32_T accelMaxs[ NUM_OF_ACCEL_AXES ]; ///< Maximum axis readings since last sample (calibrated, converted to gravities). -static U16 accelFPGAFaultReg = 0; ///< FPGA accelerometer fault register value indicates whether issues with reading accelerometer. -static U16 accelFPGASampleCtr = 0; ///< Sample counter from FPGA indicates when new sample(s) are available. -static U32 accelNoNewSampleTimerCounter = 0; ///< used to enforce timeout on no new samples. +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) +static OVERRIDE_F32_T accelMaxs[ NUM_OF_ACCEL_AXES ]; ///< Maximum axis readings since last sample (calibrated, converted to gravities) +static U16 accelFPGAFaultReg = 0; ///< FPGA accelerometer fault register value indicates whether issues with reading accelerometer +static U16 accelFPGASampleCtr = 0; ///< Sample counter from FPGA indicates when new sample(s) are available +static U32 accelNoNewSampleTimerCounter = 0; ///< used to enforce timeout on no new samples static F32 accelReadings[ NUM_OF_ACCEL_AXES ][ SIZE_OF_ROLLING_AVG ]; ///< holds flow samples for a rolling average static F32 accelReadingsTotal[ NUM_OF_ACCEL_AXES ]; ///< rolling total - used to calc average static U32 accelReadingsIdx = 0; ///< index for next sample in rolling average array static U32 accelReadingsCount = 0; ///< number of samples in flow rolling average buffer -static F32 accelAvgVector[ NUM_OF_ACCEL_AXES ]; ///< Filtered accelerometer vector for tilt. -static F32 accelTilt[ NUM_OF_ACCEL_AXES ]; ///< Axis angles for tilt determination (filtered and converted to degrees). +static F32 accelAvgVector[ NUM_OF_ACCEL_AXES ]; ///< Filtered accelerometer vector for tilt +static F32 accelTilt[ NUM_OF_ACCEL_AXES ]; ///< Axis angles for tilt determination (filtered and converted to degrees) static U32 accelTiltErrorTimerCounter = 0; ///< used for persistence requirement on tilt error static ACCELEROMETER_SELF_TEST_STATE_T accelSelfTestState = ACCELEROMETER_SELF_TEST_STATE_START; ///< current accelerometer self test state @@ -97,8 +97,8 @@ * @brief * The initAccel function initializes the Accel module. * @details - * Inputs : none - * Outputs : Accel module initialized. + * Inputs: none + * Outputs: Accel module initialized * @return none *************************************************************************/ void initAccel( void ) @@ -126,8 +126,8 @@ * @brief * The execAccel function executes the accelerometer monitor state machine. * @details - * Inputs : accelState - * Outputs : accelState + * Inputs: accelState + * Outputs: accelState, alarm if software fault happened * @return none *************************************************************************/ void execAccel( void ) @@ -157,11 +157,13 @@ /*********************************************************************//** * @brief - * The handleAccelMonitorState function handles the accelerometer monitor state \n - * of the accelerometer monitor state machine. + * The handleAccelMonitorState function handles the accelerometer monitor + * state of the accelerometer monitor state machine. * @details - * Inputs : - * Outputs : + * Inputs: accelNoNewSampleTimerCounter, accelFPGASampleCtr, accelAxes, + * accelFPGAFaultReg, accelCalOffsets + * Outputs: accelNoNewSampleTimerCounter, accelFPGASampleCtr, accelAxes + * alarm if accelerometer failed * @return next state *************************************************************************/ static ACCEL_STATE_T handleAccelMonitorState( void ) @@ -237,12 +239,13 @@ /*********************************************************************//** * @brief - * The getPublishAccelDataInterval function gets the accelerometer vector data \n - * publication interval. + * The getPublishAccelDataInterval function gets the accelerometer vector + * data publication interval. * @details - * Inputs : accelDataPublishInterval - * Outputs : none - * @return the current accelerometer vector data publication interval (in priority task periods). + * Inputs: accelDataPublishInterval + * Outputs: none + * @return the current accelerometer vector data publication interval + * (in priority task periods). *************************************************************************/ U32 getPublishAccelDataInterval( void ) { @@ -258,11 +261,12 @@ /*********************************************************************//** * @brief - * The getMeasuredAccelAxis function gets the current magnitude for the given \n - * accelerometer axis. + * The getMeasuredAccelAxis function gets the current magnitude for + * the given accelerometer axis. * @details - * Inputs : accelAxes[] - * Outputs : accelAxes[] + * Inputs: accelAxes + * Outputs: alarm if software fault happened + * @param axis the axis to measure the acceleration from * @return the current magnitude for the given accelerometer axis (in g). *************************************************************************/ F32 getMeasuredAccelAxis( U32 axis ) @@ -294,11 +298,12 @@ /*********************************************************************//** * @brief - * The getMaxAccelAxis function gets the current max magnitude for the given \n + * The getMaxAccelAxis function gets the current max magnitude for the given * accelerometer axis. * @details - * Inputs : accelMaxs[] - * Outputs : accelMaxs[] + * Inputs: accelMaxs + * Outputs: alarm software fault if happened + * @param axis the axis to get the max acceleration * @return the current maximum magnitude for the given accelerometer axis (in g). *************************************************************************/ F32 getMaxAccelAxis( U32 axis ) @@ -330,11 +335,11 @@ /*********************************************************************//** * @brief - * The publishAccelData function publishes accelerometer data at the set \n + * The publishAccelData function publishes accelerometer data at the set * interval. * @details - * Inputs : accelAxes[] - * Outputs : Accelerometer data is published to CAN bus. + * Inputs: accelAvgVector, accelTilt, accelAxes, accelDataPublicationTimerCounter + * Outputs: accelAxes, accelDataPublicationTimerCounter * @return none *************************************************************************/ static void publishAccelData( void ) @@ -364,11 +369,13 @@ /*********************************************************************//** * @brief - * The resetAccelMovingAverage function re-initializes the accelerometer \n + * The resetAccelMovingAverage function re-initializes the accelerometer * moving average sample buffer. * @details - * Inputs : none - * Outputs : accelReadingsTotal, accelReadingsIdx, accelReadingsCount all set to zero. + * Inputs: accelReadingsTotal, accelAvgVector, accelReadings, accelReadingsIdx, + * accelReadingsCount + * Outputs: accelReadingsTotal, accelAvgVector, accelReadings, accelReadingsIdx, + * accelReadingsCount * @return none *************************************************************************/ static void resetAccelMovingAverage( void ) @@ -391,10 +398,12 @@ /*********************************************************************//** * @brief - * The filterAccelReadings function adds a new axis samples to the filter. \n + * The filterAccelReadings function adds a new axis samples to the filter. * @details - * Inputs : none - * Outputs : flowReadings[], flowReadingsIdx, flowReadingsCount + * Inputs: accelReadingsCount, accelReadingsTotal, accelReadings, + * accelReadings, accelReadingsCount + * Outputs: accelReadingsCount, accelReadingsTotal, accelReadings, + * accelReadings, accelReadingsCount * @return none *************************************************************************/ static void filterAccelReadings( void ) @@ -438,11 +447,11 @@ /*********************************************************************//** * @brief - * The calcVectorLength function calculates the length of a vector with \n + * The calcVectorLength function calculates the length of a vector with * given vector axis magnitudes. * @details - * Inputs : none - * Outputs : none + * Inputs: none + * Outputs: none * @param x X axis magnitude of vector * @param y Y axis magnitude of vector * @param z Z axis magnitude of vector @@ -459,8 +468,9 @@ * @brief * The checkForTiltError function checks for a tilt error. * @details - * Inputs : accelTilt[], accelTiltErrorTimerCounter - * Outputs : alarm if persistent excessive tilt detected + * Inputs: accelTilt, accelTiltErrorTimerCounter + * Outputs: accelTiltErrorTimerCounter, alarm if persistent excessive + * tilt detected * @return none *************************************************************************/ static void checkForTiltError( void ) @@ -500,8 +510,8 @@ * @brief * The checkForShockError function checks for a shock error. * @details - * Inputs : accelMaxs[] - * Outputs : alarm if excessive shock detected + * Inputs: none + * Outputs: alarm if excessive shock detected * @return none *************************************************************************/ static void checkForShockError( void ) @@ -540,11 +550,11 @@ /*********************************************************************//** * @brief - * The execAccelTest function executes the state machine for the \n + * The execAccelTest function executes the state machine for the * accelerometer self test. * @details - * Inputs : accelSelfTestState - * Outputs : accelSelfTestState + * Inputs: accelSelfTestState, accelCalOffsets + * Outputs: accelSelfTestState, accelCalOffsets, Alarm is self test failed * @return the current state of the accelerometer self test. *************************************************************************/ SELF_TEST_STATUS_T execAccelTest( void ) @@ -621,11 +631,11 @@ /*********************************************************************//** * @brief - * The setAccelCalibration function sets the accelerometer calibration \n + * The setAccelCalibration function sets the accelerometer calibration * factors and has them stored in non-volatile memory. * @details - * Inputs : none - * Outputs : accelCalOffsets[] + * Inputs: accelCalOffsets + * Outputs: accelCalOffsets * @param offsetX offset calibration factor for X axis * @param offsetY offset calibration factor for Y axis * @param offsetZ offset calibration factor for Z axis @@ -657,11 +667,11 @@ /*********************************************************************//** * @brief - * The getAccelCalibration function retrieves the current accelerometer \n + * The getAccelCalibration function retrieves the current accelerometer * calibration factors. * @details - * Inputs : accelCalOffsets[] - * Outputs : none + * Inputs: accelCalOffsets + * Outputs: none * @param offsetX value to populate with X axis offset calibration factor * @param offsetY value to populate with Y axis offset calibration factor * @param offsetZ value to populate with Z axis offset calibration factor @@ -676,11 +686,11 @@ /*********************************************************************//** * @brief - * The testSetAccelDataPublishIntervalOverride function overrides the \n + * The testSetAccelDataPublishIntervalOverride function overrides the * accelerometer data publish interval. * @details - * Inputs : none - * Outputs : accelDataPublishInterval + * Inputs: accelDataPublishInterval + * Outputs: accelDataPublishInterval * @param value override accelerometer data publish interval with (in ms) * @return TRUE if override successful, FALSE if not *************************************************************************/ @@ -702,11 +712,11 @@ /*********************************************************************//** * @brief - * The testResetAccelDataPublishIntervalOverride function resets the override \n - * of the accelerometer data publish interval. + * The testResetAccelDataPublishIntervalOverride function resets the + * override of the accelerometer data publish interval. * @details - * Inputs : none - * Outputs : accelDataPublishInterval + * Inputs: accelDataPublishInterval + * Outputs: accelDataPublishInterval * @return TRUE if override reset successful, FALSE if not *************************************************************************/ BOOL testResetAccelDataPublishIntervalOverride( void ) @@ -725,10 +735,10 @@ /*********************************************************************//** * @brief - * The testSetAccelAxisOverride function overrides the value of the \n + * The testSetAccelAxisOverride function overrides the value of the * specified accelerometer axis with a given value. - * Inputs : none - * Outputs : accelAxes[] + * Inputs: accelAxes + * Outputs: accelAxes * @param axis ID of sensor axis to override for * @param value override value for the given axis * @return TRUE if override successful, FALSE if not @@ -752,11 +762,11 @@ /*********************************************************************//** * @brief - * The testResetAccelAxisOverride function resets the override of the \n + * The testResetAccelAxisOverride function resets the override of the * specified accelerometer axis. * @details - * Inputs : none - * Outputs : accelAxes[] + * Inputs: accelAxes + * Outputs: accelAxes * @param axis ID of accelerometer axis to reset override for * @return TRUE if override successful, FALSE if not *************************************************************************/ @@ -779,10 +789,10 @@ /*********************************************************************//** * @brief - * The testSetAccelMaxOverride function overrides the max. value of the \n + * The testSetAccelMaxOverride function overrides the max. value of the * specified accelerometer axis with a given value. - * Inputs : none - * Outputs : accelMaxs[] + * Inputs: accelMaxs + * Outputs: accelMaxs * @param axis ID of sensor axis to override for * @param value override value for the given axis maximum * @return TRUE if override successful, FALSE if not @@ -806,11 +816,11 @@ /*********************************************************************//** * @brief - * The testResetAccelMaxOverride function resets the override of the \n + * The testResetAccelMaxOverride function resets the override of the * specified accelerometer axis maximum. * @details - * Inputs : none - * Outputs : accelMaxs[] + * Inputs: accelMaxs + * Outputs: accelMaxs * @param axis ID of accelerometer axis to reset override for * @return TRUE if override successful, FALSE if not *************************************************************************/ @@ -832,4 +842,3 @@ } /**@}*/ - Index: Accel.h =================================================================== diff -u -r2a312d7c2448c2ad754532e71c27cbe91f671a15 -r6c500be6ac0c5adffc0d91b666862e35ba27e2db --- Accel.h (.../Accel.h) (revision 2a312d7c2448c2ad754532e71c27cbe91f671a15) +++ Accel.h (.../Accel.h) (revision 6c500be6ac0c5adffc0d91b666862e35ba27e2db) @@ -39,7 +39,7 @@ NUM_OF_ACCEL_AXES ///< Number of accelerometer axes } ACCEL_AXIS_T; -/// Record structure for broadcast accelerometer data +/// Record structure for broadcast accelerometer data. typedef struct { F32 x; ///< X axis reading (in g) Index: Common.h =================================================================== diff -u -r2a312d7c2448c2ad754532e71c27cbe91f671a15 -r6c500be6ac0c5adffc0d91b666862e35ba27e2db --- Common.h (.../Common.h) (revision 2a312d7c2448c2ad754532e71c27cbe91f671a15) +++ Common.h (.../Common.h) (revision 6c500be6ac0c5adffc0d91b666862e35ba27e2db) @@ -32,100 +32,100 @@ // **** Types **** -typedef float F32; ///< 32-bit floating point type. -typedef double F64; ///< 64-bit floating point type. -typedef unsigned int U32; ///< 32-bit unsigned integer type. -typedef int S32; ///< 32-bit signed integer type. -typedef unsigned short U16; ///< 16-bit unsigned integer type. -typedef short S16; ///< 16-bit signed integer type. -typedef unsigned char U08; ///< 8-bit unsigned integer type. -typedef unsigned int BOOL; ///< 32-bit boolean type. -typedef unsigned char BYTE; ///< 8-bit byte type. +typedef float F32; ///< 32-bit floating point type +typedef double F64; ///< 64-bit floating point type +typedef unsigned int U32; ///< 32-bit unsigned integer type +typedef int S32; ///< 32-bit signed integer type +typedef unsigned short U16; ///< 16-bit unsigned integer type +typedef short S16; ///< 16-bit signed integer type +typedef unsigned char U08; ///< 8-bit unsigned integer type +typedef unsigned int BOOL; ///< 32-bit boolean type +typedef unsigned char BYTE; ///< 8-bit byte type /// List of pin signal states. typedef enum Pin_Signal_States { - PIN_SIGNAL_LOW = 0, ///< Low signal level. - PIN_SIGNAL_HIGH, ///< High signal level. - NUM_OF_PIN_SIGNAL_STATES ///< # of pin signal states. + PIN_SIGNAL_LOW = 0, ///< Low signal level + PIN_SIGNAL_HIGH, ///< High signal level + NUM_OF_PIN_SIGNAL_STATES ///< Number of pin signal states } PIN_SIGNAL_STATE_T; /// List of self test status. typedef enum Self_Test_Status { - SELF_TEST_STATUS_IN_PROGRESS = 0, ///< Self test is in progress. - SELF_TEST_STATUS_PASSED, ///< Self test has passed. - SELF_TEST_STATUS_FAILED, ///< Self test has failed. - NUM_OF_SELF_TEST_STATUS ///< # of self test status. + SELF_TEST_STATUS_IN_PROGRESS = 0, ///< Self test is in progress + SELF_TEST_STATUS_PASSED, ///< Self test has passed + SELF_TEST_STATUS_FAILED, ///< Self test has failed + NUM_OF_SELF_TEST_STATUS ///< Number of self test status } SELF_TEST_STATUS_T; /// List of 2-way valve states. typedef enum Two_Way_States { - STATE_CLOSED = 0, ///< Valve is closed state. - STATE_OPEN, ///< Valve is open state. - NUM_OF_OPN_CLS_STATES ///< # of 2-way valve states. + STATE_CLOSED = 0, ///< Valve is closed state + STATE_OPEN, ///< Valve is open state + NUM_OF_OPN_CLS_STATES ///< Number of 2-way valve states } OPN_CLS_STATE_T; /// List of motor directions. typedef enum Motor_Directions { - MOTOR_DIR_FORWARD = 0, ///< Motor direction is forward. - MOTOR_DIR_REVERSE, ///< Motor direction is reverse. - NUM_OF_MOTOR_DIRECTIONS ///< # of motor directions. + MOTOR_DIR_FORWARD = 0, ///< Motor direction is forward + MOTOR_DIR_REVERSE, ///< Motor direction is reverse + NUM_OF_MOTOR_DIRECTIONS ///< Number of motor directions } MOTOR_DIR_T; /// List of pump control modes. typedef enum Pump_Control_Modes { - PUMP_CONTROL_MODE_CLOSED_LOOP = 0, ///< Pump controlled based on set point and feedback. - PUMP_CONTROL_MODE_OPEN_LOOP, ///< Pump controlled to set PWM duty cycle. - NUM_OF_PUMP_CONTROL_MODES ///< # of pump control modes. + PUMP_CONTROL_MODE_CLOSED_LOOP = 0, ///< Pump controlled based on set point and feedback + PUMP_CONTROL_MODE_OPEN_LOOP, ///< Pump controlled to set PWM duty cycle + NUM_OF_PUMP_CONTROL_MODES ///< Number of pump control modes } PUMP_CONTROL_MODE_T; // **** Common Definitions **** -#define NEARLY_ZERO 0.00000001 ///< Value that is nearly zero. Used for floating point zero comparisons (e.g. divide by zero checks). -#define HEX_64_K 0x10000 ///< 64K (65536 in decimal). -#define MASK_OFF_MSB 0x00FF ///< Bits to mask off the most significant byte of a 2-byte word. -#define MASK_OFF_LSB 0xFF00 ///< Bits to mask off the least significant byte of a 2-byte word. -#define MASK_OFF_MSW 0x0000FFFF ///< Bits to mask off the most significant 2-byte word of a 4-byte word. -#define MASK_OFF_LSW 0xFFFF0000 ///< Bits to mask off the least significant 2-byte word of a 4-byte word. -#define MASK_OFF_U32_MSB 0x00FFFFFF ///< Bits to mask off the most significant 2-byte word of a 4-byte word. -#define SHIFT_8_BITS_FOR_BYTE_SHIFT 8 ///< # of bits to shift in order to shift a byte. -#define SHIFT_16_BITS_FOR_WORD_SHIFT 16 ///< # of bits to shift in order to shift 2 bytes. -#define MASK_OFF_NIBBLE_LSB 0xF0 ///< Bits to mask off the least significant nibble of a byte. -#define MASK_OFF_NIBBLE_MSB 0x0F ///< Bits to mask off the most significant nibble of a byte. -#define MAX_DOUBLE_DIGIT_DECIMAL 99U ///< Maximum value for a decimal byte. -#define MAX_SINGLE_DIGIT_DECIMAL 9U ///< Maximum value for a decimal nibble. -#define SHIFT_BITS_BY_4 4U ///< # of bits to shift in order to shift a nibble. -#define FLOAT_TO_INT_ROUNDUP_OFFSET 0.5 ///< Offset to add to a floating point value for rounding rounding when converting to integer. -#define ML_PER_LITER 1000 ///< # of milliliters in a liter. -#define MS_PER_SECOND 1000 ///< # of milliseconds in a second. -#define SEC_PER_MIN 60 ///< # of seconds in a minute. -#define FRACTION_TO_PERCENT_FACTOR 100.0 ///< Percentage factor (100). -#define MIN_PER_HOUR 60 ///< # of minutes in an hour. -#define PI 3.1415927 ///< PI. +#define NEARLY_ZERO 0.00000001 ///< Value that is nearly zero. Used for floating point zero comparisons (e.g. divide by zero checks) +#define HEX_64_K 0x10000 ///< 64K (65536 in decimal) +#define MASK_OFF_MSB 0x00FF ///< Bits to mask off the most significant byte of a 2-byte word +#define MASK_OFF_LSB 0xFF00 ///< Bits to mask off the least significant byte of a 2-byte word +#define MASK_OFF_MSW 0x0000FFFF ///< Bits to mask off the most significant 2-byte word of a 4-byte word +#define MASK_OFF_LSW 0xFFFF0000 ///< Bits to mask off the least significant 2-byte word of a 4-byte word +#define MASK_OFF_U32_MSB 0x00FFFFFF ///< Bits to mask off the most significant 2-byte word of a 4-byte word +#define SHIFT_8_BITS_FOR_BYTE_SHIFT 8 ///< # of bits to shift in order to shift a byte +#define SHIFT_16_BITS_FOR_WORD_SHIFT 16 ///< # of bits to shift in order to shift 2 bytes +#define MASK_OFF_NIBBLE_LSB 0xF0 ///< Bits to mask off the least significant nibble of a byte +#define MASK_OFF_NIBBLE_MSB 0x0F ///< Bits to mask off the most significant nibble of a byte +#define MAX_DOUBLE_DIGIT_DECIMAL 99U ///< Maximum value for a decimal byte +#define MAX_SINGLE_DIGIT_DECIMAL 9U ///< Maximum value for a decimal nibble +#define SHIFT_BITS_BY_4 4U ///< # of bits to shift in order to shift a nibble +#define FLOAT_TO_INT_ROUNDUP_OFFSET 0.5 ///< Offset to add to a floating point value for rounding rounding when converting to integer +#define ML_PER_LITER 1000 ///< # of milliliters in a liter +#define MS_PER_SECOND 1000 ///< # of milliseconds in a second +#define SEC_PER_MIN 60 ///< # of seconds in a minute +#define FRACTION_TO_PERCENT_FACTOR 100.0 ///< Percentage factor (100) +#define MIN_PER_HOUR 60 ///< # of minutes in an hour +#define PI 3.1415927 ///< PI #define SECONDS_IN_A_DAY 86400 ///< Number of seconds in a day // **** Common Macros **** -#define FLOAT_TO_INT_WITH_ROUND(f) ((f) < 0.0 ? (S32)((f) - FLOAT_TO_INT_ROUNDUP_OFFSET) : (S32)((f) + FLOAT_TO_INT_ROUNDUP_OFFSET)) ///< Macro converts a floating point value to an integer. -#define CAP(v, u) ((v) > (u) ? (u) : (v)) ///< Macro caps a value to a maximum. -#define RANGE(v, l, u) ((v) > (u) ? (u) : ((v) < (l) ? (l) : (v))) ///< Macro enforces a range on a value. -#define INC_WRAP(v, l, u) ((v) >= (u) ? (l) : ((v) + 1)) ///< Macro increments a value and wraps to a minimum when a maximum is reached. -#define DEC_WRAP(v, l, u) ((v) <= (l) ? (u) : ((v) - 1)) ///< Macro decrements a value and wraps to a maximum when a minimum is reached. -#define INC_CAP(v, u) ((v) >= (u) ? (u) : ((v) + 1)) ///< Macro increments a value but does not allow to exceed a maximum. -#define MAX(a, b) ((a) < (b) ? (b) : (a)) ///< Macro enforces a maximum on a value. -#define MIN(a, b) ((a) > (b) ? (b) : (a)) ///< Macro enforces a minimum on a value. -#define GET_LSB_OF_WORD(w) ((U08)((w) & MASK_OFF_MSB)) ///< Macro returns the least signficant byte of a 2-byte word. -#define GET_MSB_OF_WORD(w) ((U08)(((w) >> SHIFT_8_BITS_FOR_BYTE_SHIFT) & MASK_OFF_MSB)) ///< Macro returns the most signficant byte of a 2-byte word. -#define GET_LSW_OF_LONG(l) ((U16)((l) & MASK_OFF_MSW)) ///< Macro returns the least signficant 2-byte word of a 4-byte word. -#define GET_MSW_OF_LONG(l) ((U16)(((l) >> SHIFT_16_BITS_FOR_WORD_SHIFT) & MASK_OFF_MSW)) ///< Macro returns the most signficant 2-byte word of a 4-byte word. -#define MAKE_WORD_OF_BYTES(h, l) ((((U16)(h) << SHIFT_8_BITS_FOR_BYTE_SHIFT) & MASK_OFF_LSB) | ((U16)(l) & MASK_OFF_MSB)) ///< Macro merges two bytes into a 2-byte word. -#define MAKE_LONG_OF_WORDS(h, l) ((((U32)(h) << SHIFT_16_BITS_FOR_WORD_SHIFT) & MASK_OFF_LSW) | ((U32)(l) & MASK_OFF_MSW)) ///< Macro merges two 2-byte words into a 4-byte word. -#define GET_TOGGLE(v, l, h) ((v) == (l) ? (h) : (l)) ///< Macro toggles a value. -#define BIT_BY_POS(p) (1U << (p)) ///< Macro returns a bit mask for a bit of given position. +#define FLOAT_TO_INT_WITH_ROUND(f) ((f) < 0.0 ? (S32)((f) - FLOAT_TO_INT_ROUNDUP_OFFSET) : (S32)((f) + FLOAT_TO_INT_ROUNDUP_OFFSET)) ///< Macro converts a floating point value to an integer +#define CAP(v, u) ((v) > (u) ? (u) : (v)) ///< Macro caps a value to a maximum +#define RANGE(v, l, u) ((v) > (u) ? (u) : ((v) < (l) ? (l) : (v))) ///< Macro enforces a range on a value +#define INC_WRAP(v, l, u) ((v) >= (u) ? (l) : ((v) + 1)) ///< Macro increments a value and wraps to a minimum when a maximum is reached +#define DEC_WRAP(v, l, u) ((v) <= (l) ? (u) : ((v) - 1)) ///< Macro decrements a value and wraps to a maximum when a minimum is reached +#define INC_CAP(v, u) ((v) >= (u) ? (u) : ((v) + 1)) ///< Macro increments a value but does not allow to exceed a maximum +#define MAX(a, b) ((a) < (b) ? (b) : (a)) ///< Macro enforces a maximum on a value +#define MIN(a, b) ((a) > (b) ? (b) : (a)) ///< Macro enforces a minimum on a value +#define GET_LSB_OF_WORD(w) ((U08)((w) & MASK_OFF_MSB)) ///< Macro returns the least signficant byte of a 2-byte word +#define GET_MSB_OF_WORD(w) ((U08)(((w) >> SHIFT_8_BITS_FOR_BYTE_SHIFT) & MASK_OFF_MSB)) ///< Macro returns the most signficant byte of a 2-byte word +#define GET_LSW_OF_LONG(l) ((U16)((l) & MASK_OFF_MSW)) ///< Macro returns the least signficant 2-byte word of a 4-byte word +#define GET_MSW_OF_LONG(l) ((U16)(((l) >> SHIFT_16_BITS_FOR_WORD_SHIFT) & MASK_OFF_MSW)) ///< Macro returns the most signficant 2-byte word of a 4-byte word +#define MAKE_WORD_OF_BYTES(h, l) ((((U16)(h) << SHIFT_8_BITS_FOR_BYTE_SHIFT) & MASK_OFF_LSB) | ((U16)(l) & MASK_OFF_MSB)) ///< Macro merges two bytes into a 2-byte word +#define MAKE_LONG_OF_WORDS(h, l) ((((U32)(h) << SHIFT_16_BITS_FOR_WORD_SHIFT) & MASK_OFF_LSW) | ((U32)(l) & MASK_OFF_MSW)) ///< Macro merges two 2-byte words into a 4-byte word +#define GET_TOGGLE(v, l, h) ((v) == (l) ? (h) : (l)) ///< Macro toggles a value +#define BIT_BY_POS(p) (1U << (p)) ///< Macro returns a bit mask for a bit of given position #define RAD2DEG(r) ((r) * 180.0 / PI) ///< Macro converts radians to degrees /// Macro to set a specific alarm with 1 piece of unsigned 32-bit alarm data. @@ -137,7 +137,6 @@ } /// Macro to set a specific alarm with 1 piece of floating point alarm data. - #define SET_ALARM_WITH_1_F32_DATA(a,d1) { \ ALARM_DATA_T dat1; \ dat1.dataType = ALARM_DATA_TYPE_F32; \ @@ -167,8 +166,6 @@ activateAlarm2Data( a, dat1, dat2 ); \ } -/**@}*/ - // **** VectorCAST Definitions **** #ifdef _VECTORCAST_ Index: NVDataMgmt.c =================================================================== diff -u -r13c32729e3186ebb5487e41a0cecd4cf15d357eb -r6c500be6ac0c5adffc0d91b666862e35ba27e2db --- NVDataMgmt.c (.../NVDataMgmt.c) (revision 13c32729e3186ebb5487e41a0cecd4cf15d357eb) +++ NVDataMgmt.c (.../NVDataMgmt.c) (revision 6c500be6ac0c5adffc0d91b666862e35ba27e2db) @@ -26,6 +26,11 @@ #include "Timers.h" #include "Utilities.h" +/** + * @addtogroup NVDataMgmt + * @{ + */ + // Private defines #define QUEUE_MAX_SIZE 20U ///< Max queue size @@ -76,7 +81,7 @@ #define COMMAND_TIME_OUT 500U // time in ms ///< Timeout for an EEPROM or RTC command in ms -/// NVDataMgmt self test states +/// NVDataMgmt self test states enumeration. typedef enum NVDataMgmt_Self_Test_States { NVDATAMGMT_SELF_TEST_STATE_START = 0, ///< Self test start @@ -94,7 +99,7 @@ NUM_OF_NVDATAMGMT_SELF_TEST_STATES ///< Total number of self test states } NVDATAMGMT_SELF_TEST_STATE_T; -/// NVDataMgmt Exec states +/// NVDataMgmt Exec states enumeration. typedef enum NVDataMgmt_Exec_State { NVDATAMGMT_EXEC_STATE_WAIT_FOR_POST = 0, ///< Exec state wait for POST @@ -107,7 +112,7 @@ NUM_OF_NVDATAMGMT_EXEC_STATES ///< Total number of exec states } NVDATAMGMT_EXEC_STATE_T; -/// NVDataMgmt memory operation modes +/// NVDataMgmt memory operation modes enumeration. typedef enum NVDataMgmt_Operation { NVDATAMGMT_NONE = 0, ///< Default mode to prevent any accidental ops @@ -117,7 +122,7 @@ NUM_OF_NVDATAMGMT_OPS_STATES ///< Total number of operation states } NVDATAMGMT_OPERATION_STATE_T; -/// NVDataMgmt memory locations +/// NVDataMgmt memory locations enumeration. typedef enum NVDataMgmt_Location { NVDATAMGMT_EEPROM = 0, ///< Location EEPROM @@ -126,7 +131,7 @@ } NVDATAMGMT_LOCATION_STATE_T; #pragma pack(push, 1) -/// Memory operations struct +/// Memory operations structure. typedef struct { NVDATAMGMT_OPERATION_STATE_T memoryOperation; ///< Memory operation @@ -137,7 +142,7 @@ U32 length; ///< Length of a buffer } MEMORY_OPS_T; -/// Log header struct +/// Log header structure. typedef struct { U16 recordCount; ///< Record count @@ -146,51 +151,51 @@ BOOL isHdrCorrupted; ///< Log header corruption flag } LOG_HEADER_T; -/// Log record struct +/// Log record structure. typedef struct { LOG_HEADER_T logHeader; ///< Log header struct U16 crc; ///< Log header CRC } LOG_RECORD_T; -/// Treatment time struct +/// Treatment time structure. typedef struct { U32 treatmentTime; ///< Treatment time U16 crc; ///< Treatment time CRC } TREATMENT_TIME_RECORD_T; -/// Water consumption struct +/// Water consumption structure. typedef struct { U32 waterConsumption; ///< Water consumption U16 crc; ///< Water consumption CRC } WATER_CONSUMPTION_RECORD_T; -/// Manufacturing data struct +/// Manufacturing data structure. typedef struct { MFG_DATA_T mfgData; ///< Manufacturing data struct U16 crc; ///< Manufacturing data CRC U08 Padding[ 0x30 - sizeof(MFG_DATA_T) - sizeof(U16) ]; ///< Padding for reserved mfg data space } MFG_RECORD_T; -/// Service record struct +/// Service record structure. typedef struct { SERVICE_DATA_T serviceData; ///< Service date struct U16 crc; ///< Service data CRC } SERVICE_RECORD_T; -/// Calibration record struct +/// Calibration record structure. typedef struct { CALIBRATION_DATA_T calData; ///< Calibration data struct U16 crc; ///< Calibration data CRC U08 Padding[ 0x50 - sizeof(CALIBRATION_DATA_T) - sizeof(U16) ]; ///< Padding for reserved cal data space } CALIBRATION_RECORD_T; -/// Last disinfection record struct +/// Last disinfection record structure. typedef struct { DISINFECTION_DATE_T date; ///< Disinfection date (char array) @@ -219,7 +224,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. +static volatile BOOL powerOffIsImminent = FALSE; ///< Power off warning has been signaled. Non-volatile memory operations should be completed ASAP and then ceased // Private functions @@ -262,12 +267,14 @@ static BOOL didCommandTimeout ( ALARM_ID_T alarm, U08* state ); static BOOL eraseDataLogSectors ( void ); -/************************************************************************* - * @brief initNVDataMgmt - * The initNVDataMgmt initializes EEPROM +/*********************************************************************//** + * @brief + * The initNVDataMgmt initializes the module. * @details - * Inputs : none - * Outputs : none + * Inputs: NVDataMgmtSelfTestState, NVDataMgmtExecState, NVDataMgmtSelfTestResult, + * queueRearIndex, queueFrontIndex, queueCount + * Outputs: NVDataMgmtSelfTestState, NVDataMgmtExecState, NVDataMgmtSelfTestResult, + * queueRearIndex, queueFrontIndex, queueCount * @return none *************************************************************************/ void initNVDataMgmt ( void ) @@ -282,31 +289,31 @@ Fapi_setActiveFlashBank( Fapi_FlashBank7 ); } -/************************************************************************* +/*********************************************************************//** * @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 + * The signalPowerOffWarning signals this module that system power off is + * imminent and any non-volatile data writes in progress should be wrapped up * quickly and any pending non-volatile data writes should not be started. * @details - * Inputs : none - * Outputs : powerOffIsImminent + * Inputs: none + * Outputs: powerOffIsImminent * @return none *************************************************************************/ void signalPowerOffWarning( void ) { powerOffIsImminent = TRUE; } -/************************************************************************* - * @brief setMfgData - * The setMfgData updates the struct that holds the manufacturing data, +/*********************************************************************//** + * @brief + * The setMfgData updates the structure that holds the manufacturing data, * calls another function to calculate the CRC for the provided data and * calls another function to erase sector 0 and write the new manufacturing * data. * @details - * Inputs : MFG_DATA_T (data) - * Outputs : BOOL - * @return BOOL + * Inputs: mfgRecord + * Outputs: mfgRecord + * @return TRUE is the enqueue was successfully scheduled *************************************************************************/ BOOL setMfgData ( MFG_DATA_T data ) { @@ -316,14 +323,15 @@ return status; } -/************************************************************************* - * @brief getMfgData - * The getMfgData returns the data in the struct that holds manufacturing - * record to buffer that the caller has provided +/*********************************************************************//** + * @brief + * The getMfgData returns the data in the structure that holds manufacturing + * record to buffer that the caller has provided. * @details - * Inputs : MFG_DATA_T* (buffer) - * Outputs : BOOL (status) - * @return BOOL (status) + * Inputs: mfgRecord + * Outputs: none + * @param buffer address of manufacturing data buffer + * @return TRUE if the buffer pointer was not null and the copy was successful *************************************************************************/ BOOL getMfgData ( MFG_DATA_T* buffer ) { @@ -338,16 +346,17 @@ return status; } -/************************************************************************* - * @brief setCalibrationData - * The setCalibrationData updates the struct that holds the calibration data, +/*********************************************************************//** + * @brief + * The setCalibrationData updates the structure that holds the calibration data, * calls another function to calculate the CRC for the provided data and * calls another function to erase sector 0 and write the new manufacturing * data. * @details - * Inputs : MFG_DATA_T (data) - * Outputs : BOOL - * @return BOOL + * Inputs: calibrationRecord + * Outputs: calibrationRecord + * @param data calibration data structure + * @return TRUE if updating was successfully scheduled *************************************************************************/ BOOL setCalibrationData ( CALIBRATION_DATA_T data ) { @@ -361,14 +370,15 @@ return status; } -/************************************************************************* - * @brief getCalibrationData - * The getCalibrationData returns the data in the struct that hold calibration - * record to buffer that the caller has provided +/*********************************************************************//** + * @brief + * The getCalibrationData returns the data in the structure that hold + * calibration record to buffer that the caller has provided. * @details - * Inputs : CALIBRATION_DATA_T* (buffer) - * Outputs : BOOL (status) - * @return BOOL (status) + * Inputs: calibrationRecord + * Outputs: none + * @param buffer address of calibration data buffer + * @return TRUE if calibration record valid *************************************************************************/ BOOL getCalibrationData ( CALIBRATION_DATA_T* buffer ) { @@ -383,15 +393,16 @@ return status; } -/************************************************************************* - * @brief setServiceDate - * The setServiceDate updates the struct that holds the calibration data, +/*********************************************************************//** + * @brief + * The setServiceDate updates the structure that holds the calibration data, * calls another function to calculate the CRC for the provided data if - * there is enough queues available, it schedules a write to RTC RAM + * there is enough queues available, it schedules a write to RTC RAM. * @details - * Inputs : SERVICE_DATA_T (data) - * Outputs : BOOL - * @return BOOL + * Inputs: serviceRecord + * Outputs: serviceRecord + * @param data service data buffer + * @return TRUE if the queue had enough space to schedule the job *************************************************************************/ BOOL setServiceDate ( SERVICE_DATA_T data ) { @@ -409,14 +420,15 @@ return status; } -/************************************************************************* - * @brief getServiceDate - * The getServiceDate returns the data in the struct that holds service - * date to buffer that the caller has provided +/*********************************************************************//** + * @brief + * The getServiceDate returns the data in the structure that holds service + * date to buffer that the caller has provided. * @details - * Inputs : SERVICE_DATA_T* (buffer) - * Outputs : BOOL (status) - * @return BOOL (status) + * Inputs: serviceRecord + * Outputs: none + * @param buffer address of service data buffer + * @return TRUE if the buffer address was not null *************************************************************************/ BOOL getServiceDate ( SERVICE_DATA_T* buffer ) { @@ -431,14 +443,15 @@ return status; } -/************************************************************************* - * @brief writeLogData +/*********************************************************************//** + * @brief * The writeLogData checks if the queue is not full and if it is not, it calls - * enqueue to schedule a job for writing the log data + * enqueue to schedule a job for writing the log data. * @details - * Inputs : LOG_DATA_T* (data) - * Outputs : BOOL - * @return BOOL + * Inputs: logRecord + * Outputs: none + * @param data address of log data buffer + * @return TRUE if the queue is not full and if the log header is not corrupted *************************************************************************/ BOOL writeLogData ( LOG_DATA_T* data ) { @@ -454,14 +467,16 @@ return status; } -/************************************************************************* - * @brief readLogData +/*********************************************************************//** + * @brief * The readLogData checks if the queue is not full and if it is not, it calls - * enqueue to schedule a job for writing the log data + * enqueue to schedule a job for writing the log data. * @details - * Inputs : READ_DATA_T* (buffer), U32 (length) - * Outputs : BOOL - * @return BOOL + * Inputs: none + * Outputs: none + * @param buffer address of read data buffer + * @param length length of the data log + * @return TRUE if there are enough queues available for the job *************************************************************************/ BOOL readLogData ( READ_DATA_T* buffer, U32 length ) { @@ -477,14 +492,15 @@ return status; } -/************************************************************************* - * @brief setTreatmentTime +/*********************************************************************//** + * @brief * The setTreatmentTime sets a queue job to write the treatment time in - * the specified RAM address + * the specified RAM address. * @details - * Inputs : U32 (mins) - * Outputs : BOOL - * @return BOOL + * Inputs: treatmentTimeRecord + * Outputs: treatmentTimeRecord + * @param hours treatmet time in hours + * @return TRUE if the queue was not full so the job was scheduled successfully *************************************************************************/ BOOL setTreatmentTime ( U32 hours ) { @@ -502,28 +518,29 @@ return status; } -/************************************************************************* - * @brief getTreatmentTime +/*********************************************************************//** + * @brief * The getTreatmentTime returns the total number treatment hours of the - * HD device + * HD device. * @details - * Inputs : none - * Outputs : U32 - * @return U32 + * Inputs: none + * Output: none + * @return treatment time as U32 *************************************************************************/ U32 getTreatmentTime ( void ) { return treatmentTimeRecord.treatmentTime; } -/************************************************************************* - * @brief setWaterConsumption +/*********************************************************************//** + * @brief * The setWaterConsumption sets a queue job to write the amount of water - * that has been consumed in DG + * that has been consumed in DG. * @details - * Inputs : U32 (liters) - * Outputs : BOOL - * @return BOOL + * Inputs: waterConsumptionRecord + * Outputs: waterConsumptionRecord + * @param liters consumed water is liters + * @return TRUE if queue is not full *************************************************************************/ BOOL setWaterConsumption ( U32 liters ) { @@ -541,28 +558,29 @@ return status; } -/************************************************************************* - * @brief getWaterConsumption - * The getWaterConsumption returns the amount of consumed water +/*********************************************************************//** + * @brief + * The getWaterConsumption returns the amount of consumed water. * @details - * Inputs : none - * Outputs : U32 - * @return U32 + * Inputs: none + * Outputs: none + * @return water consumption as a U32 *************************************************************************/ U32 getWaterConsumption ( void ) { return waterConsumptionRecord.waterConsumption; } -/************************************************************************* - * @brief setDisinfectionDate +/*********************************************************************//** + * @brief * The setDisinfectionDate gets the last disinfection date, calculates the * CRC for it and if the queue is not full, it schedules a write to RTC RAM - * to store the last date + * to store the last date. * @details - * Inputs : DISINFECTION_DATE_T (date) - * Outputs : BOOL (status) - * @return BOOL (status) + * Inputs: lastDisinfectionRecord + * Outputs: lastDisinfectionRecord + * @param date disinfection date buffer + * @return TRUE if the queue was not full *************************************************************************/ BOOL setDisinfectionDate ( DISINFECTION_DATE_T date ) { @@ -580,14 +598,15 @@ return status; } -/************************************************************************* - * @brief getDisinfectionDate +/*********************************************************************//** + * @brief * The getDisinfectionDate populates the provided buffer with the last - * disinfection date + * disinfection date. * @details - * Inputs : DISINFECTION_DATE_T* (buffer) - * Outputs : BOOL (status) - * @return BOOL (status) + * Inputs: lastDisinfectionRecord + * Outputs: none + * @param buffer address of disinfection date buffer + * @return TRUE if the buffer address was not null *************************************************************************/ BOOL getDisinfectionDate ( DISINFECTION_DATE_T* buffer ) { @@ -602,13 +621,13 @@ return status; } -/************************************************************************* - * @brief execNVDataMgmtSelfTest - * The execNVDataMgmtSelfTest runs the NVDataMgmt POST during the self test +/*********************************************************************//** + * @brief + * The execNVDataMgmtSelfTest runs the NVDataMgmt POST during the self test. * @details - * Inputs : none - * Outputs : SELF_TEST_STATUS_T - * @return SELF_TEST_STATUS_T + * Inputs: NVDataMgmtSelfTestState + * Outputs: NVDataMgmtSelfTestState, alarm if there was a software fault + * @return NVDataMgmtSelfTestResult the result of self test *************************************************************************/ SELF_TEST_STATUS_T execNVDataMgmtSelfTest ( void ) { @@ -690,13 +709,14 @@ return NVDataMgmtSelfTestResult; } -/************************************************************************* - * @brief setBootloaderFlag - * The setBootloaderFlag sets the bootloader flag to RTC RAM +/*********************************************************************//** + * @brief + * The setBootloaderFlag sets the bootloader flag to RTC RAM. * @details - * Inputs : U32 (flag) - * Outputs : BOOL - * @return BOOL + * Inputs: none + * Outputs: none + * @param flag the bootloader flag + * @return TRUE if the queue was not full *************************************************************************/ BOOL setBootloaderFlag ( U32 flag ) { @@ -712,29 +732,30 @@ return status; } -/************************************************************************* - * @brief getBootloaderFlag - * The getBootloaderFlag gets the bootloader flag from RTC RAM +/*********************************************************************//** + * @brief + * The getBootloaderFlag gets the bootloader flag from RTC RAM. * @details - * Inputs : none - * Outputs : U32 (flag value) - * @return U32 (flag value) + * Inputs: none + * Outputs: none + * @return bootloader flag as a U32 *************************************************************************/ U32 getBootloaderFlag( void ) { return bootloaderFlag; } -/************************************************************************* - * @brief execNVDataMgmt - * The execNVDataMgmt runs the NVDataMgmt main tasks +/*********************************************************************//** + * @brief + * The execNVDataMgmt runs the NVDataMgmt main tasks. * @details - * Inputs : none - * Outputs : none + * Inputs: NVDataMgmtExecState + * Outputs: NVDataMgmtExecState, alarm if exec state was invalid * @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 +{ // 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: @@ -786,15 +807,13 @@ } } -// Private functions - -/************************************************************************* - * @brief handleSelfTestStart - * The handleSelfTestStart enables the EEPROM bank sectors +/*********************************************************************//** + * @brief + * The handleSelfTestStart enables the EEPROM bank sectors. * @details - * Inputs : none - * Outputs : NVDATAMGMT_SELF_TEST_STATE_T - * @return NVDATAMGMT_SELF_TEST_STATE_T + * Inputs: currentTime + * Outputs: currentTime + * @return next state *************************************************************************/ static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestStart ( void ) { @@ -808,14 +827,14 @@ return state; } -/************************************************************************* - * @brief handleSelfTestEnableEEPROM +/*********************************************************************//** + * @brief * The handleSelfTestEnableEEPROM waits for EEPROM to return with ready from - * enabling the EEPROM command + * enabling the EEPROM command. * @details - * Inputs : none - * Outputs : NVDATAMGMT_SELF_TEST_STATE_T - * @return NVDATAMGMT_SELF_TEST_STATE_T + * Inputs: currentTime + * Outputs: currentTime + * @return next state *************************************************************************/ static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestEnableEEPROM ( void ) { @@ -837,14 +856,14 @@ return state; } -/************************************************************************* - * @brief handleSelfTestReadBootloaderFlag +/*********************************************************************//** + * @brief * The handleSelfTestReadBootloaderFlag reads the bootloader flag - * from RTC RAM + * from RTC RAM. * @details - * Inputs : none - * Outputs : NVDATAMGMT_SELF_TEST_STATE_T - * @return NVDATAMGMT_SELF_TEST_STATE_T + * Inputs: currentTime, bootloaderFlag + * Outputs: currentTime + * @return next state *************************************************************************/ static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestReadBootloaderFlag ( void ) { @@ -877,14 +896,14 @@ return state; } -/************************************************************************* - * @brief handleSelfTestReadHDTreatmentTime +/*********************************************************************//** + * @brief * The handleSelfTestReadHDTreatmentTime reads the HD treatment time - * from RTC RAM + * from RTC RAM. * @details - * Inputs : none - * Outputs : NVDATAMGMT_SELF_TEST_STATE_T - * @return NVDATAMGMT_SELF_TEST_STATE_T + * Inputs: currentTime, treatmentTimeRecord + * Outputs: currentTime + * @return next state *************************************************************************/ static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestReadHDTreatmentTime ( void ) { @@ -907,14 +926,14 @@ return state; } -/************************************************************************* - * @brief handleSelfTestReadDGWaterConsumption +/*********************************************************************//** + * @brief * The handleSelfTestReadDGWaterConsumption reads the DG water consumption - * from RTC RAM + * from RTC RAM. * @details - * Inputs : none - * Outputs : NVDATAMGMT_SELF_TEST_STATE_T - * @return NVDATAMGMT_SELF_TEST_STATE_T + * Inputs: currentTime, waterConsumptionRecord + * Outputs: currentTime + * @return next state *************************************************************************/ static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestReadDGWaterConsumption ( void ) { @@ -936,13 +955,13 @@ return state; } -/************************************************************************* - * @brief handleSelfTestReadLogRecord - * The handleSelfTestReadLogRecord reads the log record from RTC RAM +/*********************************************************************//** + * @brief + * The handleSelfTestReadLogRecord reads the log record from RTC RAM. * @details - * Inputs : none - * Outputs : NVDATAMGMT_SELF_TEST_STATE_T - * @return NVDATAMGMT_SELF_TEST_STATE_T + * Inputs: currentTime, logRecord, mfgRecord + * Outputs: currentTime + * @return next state *************************************************************************/ static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestReadLogRecord ( void ) { @@ -966,14 +985,14 @@ return state; } -/************************************************************************* - * @brief handleSelfTestReadMfgRecords +/*********************************************************************//** + * @brief * The handleSelfTestReadMfgRecords reads the manufacturing record from - * EEPROM + * EEPROM. * @details - * Inputs : none - * Outputs : NVDATAMGMT_SELF_TEST_STATE_T - * @return NVDATAMGMT_SELF_TEST_STATE_T + * Inputs: currentTime, calibrationRecord + * Outputs: currentTime + * @return next state *************************************************************************/ static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestReadMfgRecord ( void ) { @@ -993,14 +1012,14 @@ return state; } -/************************************************************************* - * @brief handleSelfTestReadCalibrationRecord +/*********************************************************************//** + * @brief * The handleSelfTestReadCalibrationRecord reads the calibration record - * from EEPROM + * from EEPROM. * @details - * Inputs : none - * Outputs : NVDATAMGMT_SELF_TEST_STATE_T - * @return NVDATAMGMT_SELF_TEST_STATE_T + * Inputs: currentTime + * Outputs: currentTime + * @return next state *************************************************************************/ static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestReadCalibrationRecord ( void ) { @@ -1022,14 +1041,14 @@ return state; } -/************************************************************************* - * @brief handleSelfTestReadServiceRecord +/*********************************************************************//** + * @brief * The handleSelfTestReadServiceRecord reads the service dates from RTC - * RAM + * RAM. * @details - * Inputs : none - * Outputs : NVDATAMGMT_SELF_TEST_STATE_T - * @return NVDATAMGMT_SELF_TEST_STATE_T + * Inputs: currentTime, serviceRecord + * Outputs: currentTime + * @return next state *************************************************************************/ static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestReadServiceRecord ( void ) { @@ -1050,14 +1069,14 @@ return state; } -/************************************************************************* - * @brief handleSelfTestReadLastDisinfectionDate +/*********************************************************************//** + * @brief * The handleSelfTestReadLastDisinfectionDate reads the last disinfection date - * from RTC RAM + * from RTC RAM. * @details - * Inputs : none - * Outputs : NVDATAMGMT_SELF_TEST_STATE_T - * @return NVDATAMGMT_SELF_TEST_STATE_T + * Inputs: lastDisinfectionRecord + * Outputs: none + * @return next state *************************************************************************/ static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestReadLastDisinfectionDate ( void ) { @@ -1074,14 +1093,16 @@ } -/************************************************************************* - * @brief handleSelfTestCheckCRC +/*********************************************************************//** + * @brief * The handleSelfTestCheckCRC calculates the CRC of the records and compares - * them to the CRC that was read. If they don't match, it will fail POST + * them to the CRC that was read. If they don't match, it will fail POST. * @details - * Inputs : none - * Outputs : NVDATAMGMT_SELF_TEST_STATE_T - * @return NVDATAMGMT_SELF_TEST_STATE_T + * Inputs: treatmentTimeRecord, waterConsumptionRecord, lastDisinfectionRecord, + * logRecord, mfgRecord, calibrationRecord, calibrationRecord, serviceRecord, + * NVDataMgmtSelfTestResult + * Outputs: NVDataMgmtSelfTestResult, alarm if any of the CRC checks failed + * @return next state *************************************************************************/ static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestCheckCRC ( void ) { @@ -1176,13 +1197,13 @@ return state; } -/************************************************************************* - * @brief handleExecWaitForPostState - * The handleExecWaitForPostState waits for POST to be completed +/*********************************************************************//** + * @brief + * The handleExecWaitForPostState waits for POST to be completed. * @details - * Inputs : none - * Outputs : NVDATAMGMT_EXEC_STATE_T - * @return NVDATAMGMT_EXEC_STATE_T + * Inputs: NVDataMgmtSelfTestState + * Outputs: none + * @return next state *************************************************************************/ static NVDATAMGMT_EXEC_STATE_T handleExecWaitForPostState ( void ) { @@ -1196,14 +1217,14 @@ return state; } -/************************************************************************* - * @brief handleExecIdleState +/*********************************************************************//** + * @brief * The handleExecIdleState checks if the queue is empty and if it is not - * empty, it sets the state of the job + * empty, it sets the state of the job. * @details - * Inputs : none - * Outputs : NVDATAMGMT_EXEC_STATE_T - * @return NVDATAMGMT_EXEC_STATE_T + * Inputs: currentJob, currentTime + * Outputs: currentJob + * @return next state *************************************************************************/ static NVDATAMGMT_EXEC_STATE_T handleExecIdleState ( void ) { @@ -1264,14 +1285,14 @@ return state; } -/************************************************************************* - * @brief handleExecWriteToEEPROMState +/*********************************************************************//** + * @brief * The handleExecWriteToEEPROMState issues a write command to EEPROM on entry - * and if the write was successful, it sets the state to Idle + * and if the write was successful, it sets the state to Idle. * @details - * Inputs : none - * Outputs : NVDATAMGMT_EXEC_STATE_T - * @return NVDATAMGMT_EXEC_STATE_T + * Inputs: none + * Outputs: none + * @return next state *************************************************************************/ static NVDATAMGMT_EXEC_STATE_T handleExecWriteToEEPROMState ( void ) { @@ -1286,14 +1307,14 @@ return state; } -/************************************************************************* +/*********************************************************************//** * @brief handleExecReadFromEEPROMState * The handleExecReadFromEEPROMState issues a read command to EEPROM on entry - * and if the read was successful, it sets the state to Idle + * and if the read was successful, it sets the state to Idle. * @details - * Inputs : none - * Outputs : NVDATAMGMT_EXEC_STATE_T - * @return NVDATAMGMT_EXEC_STATE_T + * Inputs: currentJob + * Outputs: currentJob + * @return next state *************************************************************************/ static NVDATAMGMT_EXEC_STATE_T handleExecReadFromEEPROMState ( void ) { @@ -1309,14 +1330,14 @@ return state; } -/************************************************************************* - * @brief handleExecEraseState +/*********************************************************************//** + * @brief * The handleExecEraseState issues an erase command to EEPROM on entry - * and if the erase was successful, it sets the state to Idle + * and if the erase was successful, it sets the state to Idle. * @details - * Inputs : none - * Outputs : NVDATAMGMT_EXEC_STATE_T - * @return NVDATAMGMT_EXEC_STATE_T + * Inputs: none + * Outputs: none + * @return next state *************************************************************************/ static NVDATAMGMT_EXEC_STATE_T handleExecEraseState ( void ) { @@ -1331,15 +1352,15 @@ return state; } -/************************************************************************* - * @brief handleExecWriteToRAMState +/*********************************************************************//** + * @brief * The handleExecWriteToRAMState issues a write command to RTC RAM if the * RAM was ready, and if the RAM got back to Idle after the write command, - * it sets the state to Idle + * it sets the state to Idle. * @details - * Inputs : none - * Outputs : NVDATAMGMT_EXEC_STATE_T - * @return NVDATAMGMT_EXEC_STATE_T + * Inputs: none + * Outputs: none + * @return next state *************************************************************************/ static NVDATAMGMT_EXEC_STATE_T handleExecWriteToRAMState ( void ) { @@ -1354,16 +1375,16 @@ return state; } -/************************************************************************* - * @brief handleExecReadFromRAMState +/*********************************************************************//** + * @brief * The handleExecReadFromRAMState issues a read command to RTC RAM if the * RAM was ready, and if the RAM got back to Idle after the read command, * it calls another function to read the data back from RTC RAM and - * it sets the state to Idle + * it sets the state to Idle. * @details - * Inputs : none - * Outputs : NVDATAMGMT_EXEC_STATE_T - * @return NVDATAMGMT_EXEC_STATE_T + * Inputs: currentJob + * Outputs: currentJob + * @return next state *************************************************************************/ static NVDATAMGMT_EXEC_STATE_T handleExecReadFromRAMState ( void ) { @@ -1380,14 +1401,19 @@ return state; } -/************************************************************************* - * @brief setMemoryOpsStruct - * The setMemoryOpsStruct fills up the job struct +/*********************************************************************//** + * @brief + * The setMemoryOpsStruct fills up the job structure. * @details - * Inputs : NVDATAMGMT_OPERATION_STATE_T (ops), NVDATAMGMT_LOCATION_STATE_T - * (location), U32 (startAddress), U08* (data), READ_DATA_T* (extAddress) - * U32 (length) - * Outputs : none + * Inputs: jobQueue, queueCount, queueRearIndex + * Outputs: jobQueue, queueCount, queueRearIndex + * @param ops type of operation (i.e. write to EEPROM) + * @param location location of operation (i.e. RTC RAM) + * @param startAddress start address of operation + * @param data address to the data buffer + * @param extAddress address of the external buffer. Used for reading the log + * data by a client + * @param length length of data for operation * @return none *************************************************************************/ static void setMemoryOpsStruct ( NVDATAMGMT_OPERATION_STATE_T ops, NVDATAMGMT_LOCATION_STATE_T location, @@ -1416,16 +1442,17 @@ _enable_IRQ(); } -/************************************************************************* - * @brief prepareWriteLogJobAndGetStartAddress +/*********************************************************************//** + * @brief * The prepareWriteLogJobAndGetStartAddress checks whether the next write * is at edge of the any of the sectors and if yes, it will update the log * header accordingly. If the write is not at the edge, it will prepare a * normal write to EEPROM job. * @details - * Inputs : U08* (data) - * Outputs : U32 (opsStartAddress) - * @return U32 (opsStartAddress) + * Inputs: logRecord + * Outputs: logRecord + * @param data address of data buffer + * @return address of the next write as a U32 *************************************************************************/ static U32 prepareWriteLogJobAndGetStartAddress ( U08* data ) { @@ -1470,14 +1497,14 @@ return opsStartAddress; } -/************************************************************************* - * @brief prepareReadLogJobAndGetStartAddress +/*********************************************************************//** + * @brief * The prepareReadLogJobAndGetStartAddress prepares a read from the specified * address of the EEPROM. * @details - * Inputs : none - * Outputs : U32 (opsStartAddress) - * @return U32 (opsStartAddress) + * Inputs: logRecord + * Outputs: logRecord + * @return address of the next read as a U32 *************************************************************************/ static U32 prepareReadLogJobAndGetStartAddress ( void ) { @@ -1510,19 +1537,24 @@ return opsStartAddress; } -/************************************************************************* - * @brief enqueue +/*********************************************************************//** + * @brief * The enqueue prepares the jobs to be processed. It checks if the requested * job is read or write, or if it is RTC or EEPROM and sets the job struct. * It checks for the corner cases, for instance, if the next write log to EEPROM * is at the beginning of the next sector, it schedules and erase first and then * it schedules the write jobs. The function breaks the write to EEPROM jobs to - * 16 bytes at the time + * 16 bytes at the time. * @details - * Inputs : NVDATAMGMT_OPERATION_STATE_T (ops), NVDATAMGMT_LOCATION_STATE_T - * (location), U32 (startAddress), U08* (data), READ_DATA_T* (extAddress) - * U32 (length) - * Outputs : none + * Inputs: none + * Outputs: none + * @param ops type of operation (i.e. write to EEPROM) + * @param location location of operation (i.e. RTC RAM) + * @param startAddress start address of operation + * @param data address to the data buffer + * @param extAddress address of the external buffer. Used for reading the log + * data by a client + * @param length length of data for operation * @return none *************************************************************************/ static void enqueue ( NVDATAMGMT_OPERATION_STATE_T ops, NVDATAMGMT_LOCATION_STATE_T location, @@ -1538,6 +1570,9 @@ if ( ops == NVDATAMGMT_WRITE && location == NVDATAMGMT_EEPROM ) { maxBufferLength = MAX_EEPROM_WRITE_BUFFER_BYTES; + + // If the start address is 0, it means it is a data log and the start + // address must be found by referring to the log record header if ( startAddress == 0 ) { opsStartAddress = prepareWriteLogJobAndGetStartAddress ( data ); @@ -1546,6 +1581,8 @@ // Setup EEPROM read log event else if ( ops == NVDATAMGMT_READ && location == NVDATAMGMT_EEPROM ) { + // If the start address is 0, it means it is a data log and the start + // address must be found by referring to the log record header if ( startAddress == 0 ) { opsStartAddress = prepareReadLogJobAndGetStartAddress(); @@ -1577,13 +1614,13 @@ } } -/************************************************************************* - * @brief dequeue +/*********************************************************************//** + * @brief * The dequeue increments the front index counter and if it is equal to - * rear index, it sets it to -1, meaning that the queue is empty + * rear index, it sets it to -1, meaning that the queue is empty. * @details - * Inputs : none - * Outputs : none + * Inputs: queueFrontIndex, queueCount + * Outputs: queueFrontIndex, queueCount * @return none *************************************************************************/ static void dequeue ( void ) @@ -1604,14 +1641,14 @@ _enable_IRQ(); } -/************************************************************************* - * @brief isQueueEmpty +/*********************************************************************//** + * @brief * The isQueueEmpty checks whether the queue is empty and if it is empty, - * it will return a false + * it will return a false. * @details - * Inputs : none - * Outputs : isEmpty (BOOL) - * @return isEmpty (BOOL) + * Inputs: queueCount + * Outputs: none + * @return TRUE if queue is not empty *************************************************************************/ static BOOL isQueueEmpty ( void ) { @@ -1625,14 +1662,14 @@ return isEmpty; } -/************************************************************************* - * @brief isQueueFull +/*********************************************************************//** + * @brief * The isQueueFull checks whether the queue is full and if it is full, - * it will return a true + * it will return a true. * @details - * Inputs : none - * Outputs : isFull (BOOL) - * @return isFull (BOOL) + * Inputs: queueCount + * Outputs: none + * @return TRUE is queue is full *************************************************************************/ static BOOL isQueueFull ( void ) { @@ -1646,29 +1683,29 @@ return isFull; } -/************************************************************************* - * @brief getAvailableQueueCount - * The getAvailableQueueCount returns the number of available queues left +/*********************************************************************//** + * @brief + * The getAvailableQueueCount returns the number of available queues left. * @details - * Inputs : none - * Outputs : U32 - * @return U32 + * Inputs: queueCount + * Outputs: none + * @return available queue counts as a U32 *************************************************************************/ static U32 getAvailableQueueCount ( void ) { return QUEUE_MAX_SIZE - queueCount; } -/************************************************************************* - * @brief enqueueBank7Sector0Records +/*********************************************************************//** + * @brief * The enqueueBank7Sector0Records checks whether there are enough number of * queues for erasing and setting the records. If there are enough queues, * it schedules an erase job and then schdules jobs to write all the records - * back to Bank 7 Sector 0 + * back to Bank 7 Sector 0. * @details - * Inputs : none - * Outputs : BOOL - * @return BOOL + * Inputs: mfgRecord, calibrationRecord + * Outputs: none + * @return TRUE if there are enough queue jobs available *************************************************************************/ static BOOL enqueueBank7Sector0Records( void ) { @@ -1687,15 +1724,17 @@ return status; } -/************************************************************************* - * @brief didCommandTimedout +/*********************************************************************//** + * @brief * The didCommandTimedout checks whether the a command whether RTC RAM or * EEPROM has timedout. If it has timedout, it sets the alarm and turns - * flag to TRUE + * flag to TRUE. * @details - * Inputs : ALARM_ID_T (alarm), U08* state (pointer to the state) - * Outputs : BOOL - * @return BOOL + * Inputs: none + * Outputs: alarm if command timed out + * @param alarm alarm ID + * @param state the state that the command timed out + * @return TRUE if a command timed out *************************************************************************/ static BOOL didCommandTimeout ( ALARM_ID_T alarm, U08* state ) { @@ -1715,14 +1754,14 @@ return status; } -/************************************************************************* - * @brief eraseDataLogSectors +/*********************************************************************//** + * @brief * The eraseDataLogSectors checks whether there are enough queues available - * and if there are, it schedules 3 erases to erase sectors 1,2, and 3 + * and if there are, it schedules 3 erases to erase sectors 1,2, and 3. * @details - * Inputs : none - * Outputs : BOOL - * @return BOOL + * Inputs: none + * Outputs: non + * @return TRUE if there are enough queues available *************************************************************************/ static BOOL eraseDataLogSectors ( void ) { @@ -1739,3 +1778,5 @@ return status; } + +/**@}*/ Index: NVDataMgmt.h =================================================================== diff -u -r2a312d7c2448c2ad754532e71c27cbe91f671a15 -r6c500be6ac0c5adffc0d91b666862e35ba27e2db --- NVDataMgmt.h (.../NVDataMgmt.h) (revision 2a312d7c2448c2ad754532e71c27cbe91f671a15) +++ NVDataMgmt.h (.../NVDataMgmt.h) (revision 6c500be6ac0c5adffc0d91b666862e35ba27e2db) @@ -20,13 +20,22 @@ #include "Common.h" +/** + * @defgroup NVDataMgmt NVDataMgmt + * @brief Non-volatile data management module. Handles Bank 7 of the TI processor and the + * RAM of the RTC chip + * + * @addtogroup NVDataMgmt + * @{ + */ + // ********** public definitions ********** #define MAX_SYS_SERIAL_NUMBER_CHARACTERS 7U ///< Max number of characters for SYS serial number #define MAX_HW_SERIAL_NUMBER_CHARACTERS 5U ///< Max number of characters for HD serial number #define MAX_DATE_CHARACTERS 10U ///< Max number of characters for date -/// Log event enum +/// Log event enumeration. typedef enum LOG_EVENT { NVDATAMGMT_MODE_CHANGE = 0, ///< Mode change @@ -38,7 +47,7 @@ NVDATAMGMT_UI_CRASHED ///< UI crashed } NVDATAMGMT_LOG_EVENT_T; -/// Read status enum +/// Read status enumeration. typedef enum READ_STATUS { NVDATAMGMT_READ_IDLE = 0, ///< Read status idle @@ -47,15 +56,15 @@ } NVDATAMGMT_READ_STATUS_T; #pragma pack(push, 1) -/// Manufacturing data struct +/// Manufacturing data structure. typedef struct mfg_Data { char SYSSerialNumber [ MAX_SYS_SERIAL_NUMBER_CHARACTERS ]; ///< SYS serial number char HWSerialNumber [ MAX_HW_SERIAL_NUMBER_CHARACTERS ]; ///< HW serial number char mfgDate [ MAX_DATE_CHARACTERS ]; ///< Manufacturing date } MFG_DATA_T; -/// Calibration data struct +/// Calibration data structure. typedef struct calibration_Data { U32 calRecordRevision; ///< Revision of calibration record (rev when structure changes to determine compatibility with f/w version) @@ -73,21 +82,21 @@ char calDateAccel[ MAX_DATE_CHARACTERS ]; ///< Last calibration date of accelerometer } CALIBRATION_DATA_T; -/// Service dates struct +/// Service dates structure. typedef struct service_dates { char currentServiceDate [ MAX_DATE_CHARACTERS ]; ///< Current service date char nextServiceDate [ MAX_DATE_CHARACTERS ]; ///< Next service date } SERVICE_DATA_T; -/// Read data status +/// Read data status structure. typedef struct get_data { NVDATAMGMT_READ_STATUS_T status; ///< Read data status U08* externalBuffer; ///< External buffer address } READ_DATA_T; -/// Log data struct +/// Log data structure. typedef struct { U32 epochTime; ///< Log data time in epoch @@ -100,10 +109,10 @@ F32 data5; ///< Log data 5 } LOG_DATA_T; -/// Disinfection date struct +/// Disinfection date structure. typedef struct { - char disinfectionDate [ MAX_DATE_CHARACTERS ]; ///< Disinfection Date + char disinfectionDate [ MAX_DATE_CHARACTERS ]; ///< Disinfection Date } DISINFECTION_DATE_T; #pragma pack(pop) @@ -147,4 +156,6 @@ BOOL readLogData ( READ_DATA_T* buffer, U32 length ); -#endif /* FWCOMMON_NVDATAMGMT_H_ */ +/**@}*/ + +#endif Index: RTC.c =================================================================== diff -u -r13c32729e3186ebb5487e41a0cecd4cf15d357eb -r6c500be6ac0c5adffc0d91b666862e35ba27e2db --- RTC.c (.../RTC.c) (revision 13c32729e3186ebb5487e41a0cecd4cf15d357eb) +++ RTC.c (.../RTC.c) (revision 6c500be6ac0c5adffc0d91b666862e35ba27e2db) @@ -22,6 +22,11 @@ #include "SystemCommMessages.h" #include "OperationModes.h" +/** + * @addtogroup RTC + * @{ + */ + // ********** Definitions ********** #define RTC_REG_1_12_HOUR_MODE_MASK 0x0004 ///< 12-hour mode mask (0x0004) @@ -115,7 +120,7 @@ #define LOCAL_TO_GTM_TIME_CONVERSION 8U ///< Local time to GTM conversion for VectorCAST #endif -/// RTC self test state enums +/// RTC self test state enumeration. typedef enum RTC_Self_Test_States { RTC_SELF_TEST_STATE_START = 0, ///< Self test start @@ -127,7 +132,7 @@ NUM_OF_RTC_SELF_TEST_STATES ///< Total number of self test states } RTC_SELF_TEST_STATE_T; -/// Read date states enums +/// Read date states enumeration. typedef enum RTC_Read_Data { RTC_SEND_COMMAND = 0, ///< RTC send command @@ -136,7 +141,7 @@ NUM_OF_RTC_SERVICE_STATES ///< Total number of RTC read date states } RTC_GET_DATA_STATE_T; -/// RTC exec state enums +/// RTC exec state enumeration. typedef enum RTC_Exec_State { RTC_EXEC_STATE_WAIT_FOR_POST = 0, ///< Exec state wait for post @@ -150,7 +155,7 @@ } RTC_EXEC_STATE_T; #pragma pack(push,4) -/// Timestamp struct +/// Timestamp structure. typedef struct { U16 seconds; ///< Seconds @@ -222,12 +227,12 @@ // ********** Public functions ********** -/************************************************************************* - * @brief initRTC - * The initRTC initializes the RTC +/*********************************************************************//** + * @brief + * The initRTC initializes the RTC. * @details - * Inputs : none - * Outputs : The function is empty for now + * Inputs: RTCSelfTestState, RTCSelfTestState + * Outputs: RTCSelfTestState, RTCSelfTestState * @return none *************************************************************************/ void initRTC( void ) @@ -236,14 +241,20 @@ RTCServiceState = RTC_SEND_COMMAND; } -/************************************************************************* - * @brief setRTCTimestamp + /*********************************************************************//** + * @brief * The setRTCTimestamp gets the timestamp values, converts them into BCD - * and inserts them into the txBuffer to be written into the RTC + * and inserts them into the txBuffer to be written into the RTC. * @details - * Inputs : seconds, minutes, hours, days, months, years - * Outputs : txBuffer will be prepared with the timestamp - * @return none + * Inputs: RTCNewTimestampStruct, hasWriteToRTCRequested, isTimestampBufferReady + * Outputs: RTCNewTimestampStruct, hasWriteToRTCRequested, isTimestampBufferReady + * @param secs seconds + * @param mins minutes + * @param hours hours + * @param days days + * @param months months + * @param years years + * @return TRUE is the provided data is valid *************************************************************************/ BOOL setRTCTimestamp( U08 secs, U08 mins, U08 hours, U08 days, U08 months, U32 years ) { @@ -284,16 +295,17 @@ RTCNewTimestampStruct.months = months; RTCNewTimestampStruct.years = years; } + return isDataOk; } -/************************************************************************* - * @brief execRTCSelfTest - * The execRTCSelfTest runs the RTC POST during the self test +/*********************************************************************//** + * @brief + * The execRTCSelfTest runs the RTC POST during the self test. * @details - * Inputs : none - * Outputs : SELF_TEST_STATUS_T - * @return SELF_TEST_STATUS_T + * Inputs: RTCSelfTestState + * Outputs: RTCSelfTestState, alarm if invalid state was called + * @return RTCSelfTestResult the result of self test *************************************************************************/ SELF_TEST_STATUS_T execRTCSelfTest( void ) { @@ -344,12 +356,12 @@ return RTCSelfTestResult; } -/************************************************************************* - * @brief execRTC - * The execRTC runs the RTC during normal operations +/*********************************************************************//** + * @brief + * The execRTC runs the RTC during normal operations. * @details - * Inputs : none - * Outputs : none + * Inputs: RTCExecState + * Outputs: RTCExecState, alarm if invalid state was called * @return none *************************************************************************/ void execRTC( void ) @@ -403,29 +415,34 @@ } } -/************************************************************************* - * @brief getRTCTimestamp - * The getRTCTimestamp returns the current time in epoch +/*********************************************************************//** + * @brief + * The getRTCTimestamp returns the current time in epoch. * @details - * Inputs : none - * Outputs : current time in epoch - * @return lastEpochTime + * Inputs: lastEpochTime + * Outputs: none + * @return lastEpochTime the time in epoch as a U32 *************************************************************************/ U32 getRTCTimestamp( void ) { return lastEpochTime; } -/************************************************************************* - * @brief writeToRAM +/*********************************************************************//** + * @brief * The writeToRAM checks whether the RAM status is idle and if it is, it * will check input address and length to make sure they are within the * range. If everything is fine, it will prepare the txBuffer and set the - * RAM status to busy + * RAM status to busy. * @details - * Inputs : address, data, length - * Outputs : RTC_RAM_STATUS_T - * @return RTC_RAM_STATUS_T + * Inputs: RTCRAMStatus, RTCRAMState, hasWriteToRAMRequested, RAMBufferLength, + * prepRAMBuffer, txBuffer + * Outputs: RTCRAMStatus, RTCRAMState, hasWriteToRAMRequested, RAMBufferLength, + * prepRAMBuffer, txBuffer + * @param address address of the RTC RAM to write to + * @param data address of the data buffer to be written to RAM + * @param length length of the buffer + * @return status of the RTC RAM *************************************************************************/ RTC_RAM_STATUS_T writeToRAM( U32 address, U08* data, U32 length ) { @@ -460,19 +477,24 @@ } } } + return status; } -/************************************************************************* - * @brief readFromRAM +/*********************************************************************//** + * @brief * The readFromRAM checks whether the RAM status is idle and if it is, it * will check input address and length to make sure they are within the * range. If everything is fine, it will prepare the txBuffer and set the - * RAM status to busy + * RAM status to busy. * @details - * Inputs : address, length - * Outputs : RTC_RAM_STATUS_T - * @return RTC_RAM_STATUS_T + * Inputs: RTCRAMStatus, RTCRAMState, hasReadFromRAMRequested, RAMBufferLength, + * prepRAMBuffer, txBuffer + * Outputs: RTCRAMStatus, RTCRAMState, hasReadFromRAMRequested, RAMBufferLength, + * prepRAMBuffer, txBuffer + * @param address address of the RTC RAM to read data from + * @param length length of data to be read from RAM + * @return status of the RTC RAM *************************************************************************/ RTC_RAM_STATUS_T readFromRAM( U32 address, U32 length ) { @@ -510,27 +532,27 @@ return status; } -/************************************************************************* - * @brief getRTCRAMState - * The getRTCRAMState returns the RAM state +/*********************************************************************//** + * @brief + * The getRTCRAMState returns the RAM state. * @details - * Inputs : none - * Outputs : RTC_RAM_STATE_T - * @return RTC_RAM_STATE_T + * Inputs: RTCRAMState + * Outputs: none + * @return RTC RAM state *************************************************************************/ RTC_RAM_STATE_T getRTCRAMState( void ) { return RTCRAMState; } -/************************************************************************* - * @brief getRTCRAMStatus +/*********************************************************************//** + * @brief * The getRTCRAMStatus returns the RAM state. If the RAM status is complete - * it will set the RAM status to Idle and the RAM state to Ready + * it will set the RAM status to Idle and the RAM state to Ready. * @details - * Inputs : none - * Outputs : RTC_RAM_STATE_T - * @return RTC_RAM_STATE_T + * Inputs: RTCRAMStatus, RTCRAMState + * Outputs: RTCRAMStatus, RTCRAMState + * @return RTC RAM status *************************************************************************/ RTC_RAM_STATUS_T getRTCRAMStatus( void ) { @@ -543,13 +565,15 @@ return RTCRAMStatus; } -/************************************************************************* - * @brief getDataFromRAM +/*********************************************************************//** + * @brief * The getDataFromRAM populates the provided external buffer with the data - * in the specified address in the RAM + * in the specified address in the RAM. * @details - * Inputs : external buffer (pointer), length - * Outputs : none + * Inputs: RAMBuffer + * Outputs: none + * @param externalBuffer address of the external buffer to copy data into + * @param length length of data to be copied into buffer * @return none *************************************************************************/ void getDataFromRAM( U08* externalBuffer, U32 length ) @@ -563,6 +587,7 @@ // ********** Private functions ********* +//TODO fill up the functions /*void mibspiNotification(mibspiBASE_t *mibspi, uint32 flags) { @@ -573,20 +598,21 @@ } */ - -/************************************************************************* - * @brief serviceRTC +/*********************************************************************//** + * @brief * The serviceRTC is the interface to the RTC chip: * If it was called for the first time, it will send the command * If the provided buffer length is not the same as previous, it will * set the buffer length. Otherwise it will ignore it * If it was not called for the first time, it will wait to the buffer * to be transmitted and then it will populate the provided receive buffer - * If the transaction failed, it will try 3 time before it fails + * If the transaction failed, it will try 3 time before it fails. * @details - * Inputs : bufferTransmit, bufferReceive, bufferLength - * Outputs : result (bool) - * @return result (bool) + * Inputs : isRTCServiceOnEntry, RTCServiceState, numberOfFailedRTCTransfers, + * previousTransferLength + * Outputs: isRTCServiceOnEntry, RTCServiceState, numberOfFailedRTCTransfers, + * previousTransferLength + * @return TRUE if RTC operation was successful *************************************************************************/ static BOOL serviceRTC( U16* bufferTransmit, U16* bufferReceive, U16 bufferLength ) { @@ -661,15 +687,15 @@ return result; } -/************************************************************************* - * @brief isRTCFunctional +/*********************************************************************//** + * @brief * The isRTCFunctional checks whether the RTC is still functional by checking * the bits in the first 3 control registers. The function ignore the clear - * flags + * flags. * @details - * Inputs : none - * Outputs : hasTestPassed (bool) - * @return hasTestPassed (bool) + * Inputs: rxBuffer + * Outputs: alarm if any of the control registers are at fault + * @return TRUE if the control registers are normal *************************************************************************/ static BOOL isRTCFunctional( void ) { @@ -723,13 +749,14 @@ return hasTestPassed; } -/************************************************************************* - * @brief convertBCD2Decimal - * The convertBCD2Decimal converts the BCD values to decimal +/*********************************************************************//** + * @brief + * The convertBCD2Decimal converts the BCD values to decimal. * @details - * Inputs : bcd value - * Outputs : decimal value - * @return decimal value + * Inputs: none + * Outputs: none + * @param bcd the number in bcd + * @return number is decimal a U08 *************************************************************************/ static U08 convertBCD2Decimal( U08 bcd ) { @@ -748,16 +775,18 @@ { decimal = ( bcdHigh * TEN ) + bcdLow; } + return decimal; } -/************************************************************************* - * @brief convertDecimal2BCD - * The convertDecimal2BCD converts the decimal values to BCD +/*********************************************************************//** + * @brief + * The convertDecimal2BCD converts the decimal values to BCD. * @details - * Inputs : decimal value - * Outputs : bcd value - * @return bcd value + * Inputs: none + * Outputs: none + * @param decimal number if decimal + * @return number in bcd as a U08 *************************************************************************/ static U08 convertDecimal2BCD( U08 decimal ) { @@ -777,13 +806,13 @@ return bcd; } -/************************************************************************* - * @brief convertTime2Epoch - * The convertTime2Epoch converts the time into epoch (seconds from Jan 1 1970) +/*********************************************************************//** + * @brief + * The convertTime2Epoch converts the time into epoch (seconds from Jan 1 1970). * @details - * Inputs : none - * Outputs : epochTime value - * @return epochTime value + * Inputs: RTCTimestampStruct + * Outputs: none + * @return time in epoch as a U32 *************************************************************************/ static U32 convertTime2Epoch( void ) { @@ -815,13 +844,13 @@ return (U32)epochTime; } -/************************************************************************* - * @brief updateReadTimestampStruct - * The updateReadTimestampStruct function updates the time struct after every - * read +/*********************************************************************//** + * @brief + * The updateReadTimestampStruct function updates the time structure + * after every read. * @details - * Inputs : none - * Outputs : none + * Inputs: RTCTimestampStruct + * Outputs: RTCTimestampStruct * @return none *************************************************************************/ static void updateReadTimestampStruct( void ) @@ -835,14 +864,15 @@ RTCTimestampStruct.years = convertBCD2Decimal( rxBuffer[ RTC_YEARS_INDEX ] ); } -/************************************************************************* - * @brief setMibSPIBufferLength +/*********************************************************************//** + * @brief * The setMibSPIBufferLength sets the MibSPI buffer length prior to every - * RTC transaction + * RTC transaction. * @details - * Inputs : length - * Outputs : ransferStatus (bool) - * @return transferStatus (bool) + * Inputs: none + * Outputs: none + * @param length length of data transfer in bytes + * @return TRUE if the buffer length was set successfully *************************************************************************/ static BOOL setMibSPIBufferLength( U16 length ) { @@ -907,12 +937,13 @@ return transferStatus; } -/************************************************************************* - * @brief prepBufferForReadCommand - * The prepBufferForReadCommand sets the txBuffer for a read +/*********************************************************************//** + * @brief + * The prepBufferForReadCommand sets the txBuffer for a read. * @details - * Inputs : length - * Outputs : none + * Inputs: txBuffer + * Outputs: txBuffer + * @param length length of buffer to read * @return none *************************************************************************/ static void prepBufferForReadCommand( U08 length ) @@ -926,14 +957,14 @@ } } -/************************************************************************* - * @brief handleExecWaitForPostState +/*********************************************************************//** + * @brief * The handleExecWaitForPostState checks whether POST has completed and what - * was the result of the POST test. It will either go to Idle of Fault + * was the result of the POST test. It will either go to Idle of Fault. * @details - * Inputs : none - * Outputs : result (RTC_EXEC_STATE_T) - * @return result (RTC_EXEC_STATE_T) + * Inputs: RTCSelfTestState + * Outputs: none + * @return next state *************************************************************************/ static RTC_EXEC_STATE_T handleExecWaitForPostState( void ) { @@ -947,15 +978,16 @@ return result; } -/************************************************************************* - * @brief handleExecIdleState +/*********************************************************************//** + * @brief * The handleExecIdleState checks whether read or write to RTC or RAM has * been requested. If none of them have been requested, it will increment the - * timer + * timer. * @details - * Inputs : none - * Outputs : result (RTC_EXEC_STATE_T) - * @return result (RTC_EXEC_STATE_T) + * Inputs: nohasWriteToRTCRequested, hasWriteToRAMRequested, + * hasReadFromRAMRequested, timeCounter + * Outputs: timeCounter + * @return next state *************************************************************************/ static RTC_EXEC_STATE_T handleExecIdleState( void ) { @@ -986,13 +1018,15 @@ return result; } -/************************************************************************* - * @brief handleExecWriteState - * The handleExecWriteState writes timestamp to RTC +/*********************************************************************//** + * @brief + * The handleExecWriteState writes timestamp to RTC. * @details - * Inputs : none - * Outputs : result (RTC_EXEC_STATE_T) - * @return result (RTC_EXEC_STATE_T) + * Inputs: isTimestampBufferReady, txBuffer, hasWriteToRTCRequested, + * timeCounter, RTCServiceState + * Outputs: isTimestampBufferReady, txBuffer, hasWriteToRTCRequested, + * timeCounter, alarm if any RTC RAM operations occurred + * @return next state *************************************************************************/ static RTC_EXEC_STATE_T handleExecWriteState( void ) { @@ -1032,13 +1066,14 @@ return result; } -/************************************************************************* - * @brief handleExecPrepRAMState - * The handleExecPrepRAMState prepares the RAM for read or write +/*********************************************************************//** + * @brief + * The handleExecPrepRAMState prepares the RAM for read or write. * @details - * Inputs : none - * Outputs : result (RTC_EXEC_STATE_T) - * @return result (RTC_EXEC_STATE_T) + * Inputs: RTCServiceState, hasWriteToRAMRequested, hasReadFromRAMRequested, + * prepRAMBuffer, RAMBuffer + * Outputs: alarm if any RTC RAM operations error occurred + * @return next state *************************************************************************/ static RTC_EXEC_STATE_T handleExecPrepRAMState( void ) { @@ -1065,13 +1100,15 @@ return result; } -/************************************************************************* - * @brief handleExecWriteToRAMState - * The handleExecWriteToRAMState writes to RAM +/*********************************************************************//** + * @brief + * The handleExecWriteToRAMState writes to RAM. * @details - * Inputs : none - * Outputs : result (RTC_EXEC_STATE_T) - * @return result (RTC_EXEC_STATE_T) + * Inputs: RTCServiceState, hasWriteToRAMRequested, RTCRAMStatus, txBuffer, + * RAMBuffer, RAMBufferLength + * Outputs: hasWriteToRAMRequested, RTCRAMStatus, alarm if any RTC RAM + * operations errors occurred + * @return next state *************************************************************************/ static RTC_EXEC_STATE_T handleExecWriteToRAMState( void ) { @@ -1095,13 +1132,15 @@ return result; } -/************************************************************************* - * @brief handleExecReadFromRAMState - * The handleExecReadFromRAMState read from RAM +/*********************************************************************//** + * @brief + * The handleExecReadFromRAMState read from RAM. * @details - * Inputs : none - * Outputs : result (RTC_EXEC_STATE_T) - * @return result (RTC_EXEC_STATE_T) + * Inputs: RTCServiceState, hasReadFromRAMRequested, RTCRAMStatus, txBuffer, + * RAMBuffer, RAMBufferLength + * Outputs: hasReadFromRAMRequested, RTCRAMStatus, alarm if any RTC RAM + * operations errors occurred + * @return next state *************************************************************************/ static RTC_EXEC_STATE_T handleExecReadFromRAMState( void ) { @@ -1125,15 +1164,16 @@ return result; } -/************************************************************************* - * @brief handleExecReadState - * The handleExecReadState reads timestamp from RTC. The function calls - * other functions to update the time struct and convert the latest time - * to epoch +/*********************************************************************//** + * @brief + * The handleExecReadState reads timestamp from RTC. The function calls + * other functions to update the time structure and convert the latest time + * to epoch. * @details - * Inputs : none - * Outputs : result (RTC_EXEC_STATE_T) - * @return result (RTC_EXEC_STATE_T) + * Inputs: RTCServiceState, lastEpochTime, timeCounter, txBuffer, rxBuffer + * Outputs: lastEpochTime, timeCounter, alarm if any RTC operations error + * occurred + * @return next state *************************************************************************/ static RTC_EXEC_STATE_T handleExecReadState( void ) { @@ -1161,14 +1201,14 @@ return result; } -/************************************************************************* - * @brief handleSelfTestStart +/*********************************************************************//** + * @brief * The handleSelfTestStart calls another function to prepare the txBuffer - * for a read and sets the state to control registers + * for a read and sets the state to control registers. * @details - * Inputs : none - * Outputs : result (RTC_SELF_TEST_STATE_T) - * @return result (RTC_SELF_TEST_STATE_T) + * Inputs: RTCSelfTestResult + * Outputs: RTCSelfTestResult + * @return next state *************************************************************************/ static RTC_SELF_TEST_STATE_T handleSelfTestStart( void ) { @@ -1180,16 +1220,17 @@ return result; } -/************************************************************************* - * @brief handleSelfTestCheckCtrlRegs +/*********************************************************************//** + * @brief * The handleSelfTestCheckCtrlRegs receives the control registers and calls * another function to check whether RTC is function or not. If the RTC is * functional, it will update the RTCPreviousSecond variable and sets the - * state machine to the next state + * state machine to the next state. * @details - * Inputs : none - * Outputs : result (RTC_SELF_TEST_STATE_T) - * @return result (RTC_SELF_TEST_STATE_T) + * Inputs: RTCServiceState, txBuffer, rxBuffer, RTCPreviousSecond, + * RTCSelfTestResult + * Outputs: RTCPreviousSecond, RTCSelfTestResult + * @return next state *************************************************************************/ static RTC_SELF_TEST_STATE_T handleSelfTestCheckCtrlRegs( void ) { @@ -1219,15 +1260,16 @@ return result; } -/************************************************************************* - * @brief handleSelfTestWaitForFirstSecond +/*********************************************************************//** + * @brief * The handleSelfTestWaitForFirstSecond continuously reads the RTC and compares * latest second from RTC to the previous second and if it has changed, it will - * start the timer and set the state machine to the next state + * start the timer and set the state machine to the next state. * @details - * Inputs : none - * Outputs : result (RTC_SELF_TEST_STATE_T) - * @return result (RTC_SELF_TEST_STATE_T) + * Inputs: RTCServiceState, txBuffer, rxBuffer, RTCCurrentSecond, RTCSelfTestTimer, + * RTCPreviousSecond + * Outputs: RTCCurrentSecond, RTCSelfTestTimer, RTCPreviousSecond + * @return next state *************************************************************************/ static RTC_SELF_TEST_STATE_T handleSelfTestWaitForFirstSecond( void ) { @@ -1263,15 +1305,15 @@ return result; } -/************************************************************************* - * @brief handleSelfTestWaitForSecondSecond +/*********************************************************************//** + * @brief * The handleSelfTestWaitForSecondSecond continuously reads the RTC and compares * latest second from RTC to the previous second and if it has changed, it will - * set the state machine to the next state + * set the state machine to the next state. * @details - * Inputs : none - * Outputs : result (RTC_SELF_TEST_STATE_T) - * @return result (RTC_SELF_TEST_STATE_T) + * Inputs: RTCServiceState, txBuffer, rxBuffer, RTCCurrentSecond + * Outputs: RTCCurrentSecond + * @return next state *************************************************************************/ static RTC_SELF_TEST_STATE_T handleSelfTestWaitForSecondSecond( void ) { @@ -1304,16 +1346,17 @@ return result; } -/************************************************************************* - * @brief handleSelfTestCheckAccuracy +/*********************************************************************//** + * @brief * The handleSelfTestCheckAccuracy checks whether the time has been elapsed * within the specified time tolerance. It will call another function to check * whether one second has elapsed. If the time has elapsed, how much time has - * passed since the last second that was read from RTC + * passed since the last second that was read from RTC. * @details - * Inputs : none - * Outputs : result (RTC_SELF_TEST_STATE_T) - * @return result (RTC_SELF_TEST_STATE_T) + * Inputs: RTCSelfTestTimer, RTCSelfTestResult + * Outputs : RTCSelfTestTimer, RTCSelfTestResult, alarm if RTC time accuracy + * test failed + * @return Next state *************************************************************************/ static RTC_SELF_TEST_STATE_T handleSelfTestCheckAccuracy( void ) { @@ -1338,3 +1381,5 @@ return result; } + +/**@}*/ Index: RTC.h =================================================================== diff -u -re8828d66e4a76e0590c3f06b7f6235f33df64e80 -r6c500be6ac0c5adffc0d91b666862e35ba27e2db --- RTC.h (.../RTC.h) (revision e8828d66e4a76e0590c3f06b7f6235f33df64e80) +++ RTC.h (.../RTC.h) (revision 6c500be6ac0c5adffc0d91b666862e35ba27e2db) @@ -20,7 +20,16 @@ #include "Common.h" -/// RTC RAM status +/** + * @defgroup RTC RTC + * @brief Real time clock module. This module controls the clock and + * the RAM of the RTC chip + * + * @addtogroup RTC + * @{ + */ + +/// RTC RAM status enumeration. typedef enum RTC_RAM_STATUS { RTC_RAM_STATUS_IDLE = 0, ///< Status idle @@ -32,7 +41,7 @@ } RTC_RAM_STATUS_T; -/// RTC RAM states +/// RTC RAM states enumeration. typedef enum RTC_RAM_STATE { RTC_RAM_STATE_READY = 0, ///< RAM ready @@ -60,4 +69,6 @@ void getDataFromRAM( U08* externalBuffer, U32 length ); +/**@}*/ + #endif