Index: Utilities.h =================================================================== diff -u -r62f81f0f9649926feae18dc09da001690dbcd26e -r4b3e011f99900660c9c9f23d3ea50a07cb61e64b --- Utilities.h (.../Utilities.h) (revision 62f81f0f9649926feae18dc09da001690dbcd26e) +++ Utilities.h (.../Utilities.h) (revision 4b3e011f99900660c9c9f23d3ea50a07cb61e64b) @@ -1,28 +1,97 @@ -/************************************************************************** - * - * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. - * - * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN - * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. - * - * @file Utilities.h - * - * @date 23-Oct-2019 - * @author S. Nash - * - * @brief header file for utilities service module. - * - **************************************************************************/ +/************************************************************************** +* +* Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. +* +* THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +* WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +* +* @file Utilities.h +* +* @author (last) Sean Nash +* @date (last) 04-Sep-2020 +* +* @author (original) Sean +* @date (original) 17-Feb-2020 +* +***************************************************************************/ #ifndef __UTILITIES_H__ #define __UTILITIES_H__ +/** + * @defgroup Utilities Utilities + * @brief Utilities module contains various utility functions. + * + * @addtogroup Utilities + * @{ + */ + // ********** public definitions ********** +// ******* Time Windowed Count Definitions ********* +#define MAX_TIME_WINDOWED_COUNT 5 ///< Maximum number of counts that a time windowed count can count to +/// Enumeration of time-windowed counts. +typedef enum TimeWindowedCounts +{ + TIME_WINDOWED_COUNT_BAD_MSG_CRC = 0, ///< Bad message CRC + TIME_WINDOWED_COUNT_CAN_WARNING, ///< CAN warning + TIME_WINDOWED_COUNT_CAN_PASSIVE, ///< CAN passive mode + TIME_WINDOWED_COUNT_CAN_OFF, ///< CAN off + TIME_WINDOWED_COUNT_CAN_PARITY, ///< CAN parity error + TIME_WINDOWED_COUNT_FPGA_UART_FRAME_ERROR, ///< FPGA UART frame error + TIME_WINDOWED_COUNT_FPGA_UART_OVERRUN, ///< FPGA UART overrun error +#ifdef _HD_ +#endif +#ifdef _DG_ + TIME_WINDOWED_COUNT_FPGA_CONDUCTIVITY_SENSOR_ERROR, ///< FPGA Conductivity sensor error + TIME_WINDOWED_COUNT_FPGA_TEMPERATURE_SENSOR_ERROR, ///< FPGA Temperature sensor error +#endif + NUM_OF_TIME_WINDOWED_COUNTS ///< Number of pressure sensors +} TIME_WINDOWED_COUNT_T; + +// ******* Critical Data Definitions ********* +/// Critical data types list. +typedef enum Critical_Data_Types +{ + CRITICAL_DATA_TYPE_U32 = 0, ///< Critical data is unsigned 32-bit integer type + CRITICAL_DATA_TYPE_S32, ///< Critical data is signed 32-bit integer type + CRITICAL_DATA_TYPE_F32, ///< Critical data is 32-bit floating point type + NUM_OF_CRITICAL_DATA_TYPES ///< Total number of critical data types +} CRITICAL_DATA_TYPES_T; + +/// Record structure for alarm data of any supported type. +typedef union +{ + U32 uInt; ///< critical data of unsigned integer type + S32 sInt; ///< critical data of signed integer type + F32 sFlt; ///< critical data of floating point type +} CRITICAL_DATAS_T; + +/// critical integer data structure. +typedef struct +{ + CRITICAL_DATA_TYPES_T typ; ///< Type of data + CRITICAL_DATAS_T minimum; ///< Minimum value for valid data + CRITICAL_DATAS_T maximum; ///< Maximum value for valid data + CRITICAL_DATAS_T defValue; ///< Default value + CRITICAL_DATAS_T data; ///< Data value + U32 comp; ///< One's compliment of value + BOOL set; ///< Flag indicates data has been set +} CRITICAL_DATA_T; + // ********** public function prototypes ********** U16 crc16( const U08 *address, U32 len ); U08 crc8( const U08 *address, U32 len ); +void initTimeWindowedCount( TIME_WINDOWED_COUNT_T cnt, U32 maxCnt, U32 winMs ); +BOOL incTimeWindowedCount( TIME_WINDOWED_COUNT_T cnt ); +CRITICAL_DATAS_T getCriticalData( CRITICAL_DATA_T *data ); +BOOL setCriticalData( CRITICAL_DATA_T *data, CRITICAL_DATAS_T value ); +BOOL isCriticalDataInRange( CRITICAL_DATA_T *data ); +void resetCriticalData( CRITICAL_DATA_T *data ); +U32 hexStrToDec( U08 const * const valuePtr, U08 size ); +/**@}*/ + #endif