/************************************************************************** * * 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) Quang Nguyen * @date (last) 22-Jul-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 ********** #define MAX_TIME_WINDOWED_COUNT 5 ///< Maximum # 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 #endif NUM_OF_TIME_WINDOWED_COUNTS ///< Number of pressure sensors. } TIME_WINDOWED_COUNT_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 ); /**@}*/ #endif