Index: Utilities.h =================================================================== diff -u -r77b29084a85f241dd6c83ef838e076bac666b11c -r18ffb88352fb14d3cdb0e82cd8e278cb37ce7020 --- Utilities.h (.../Utilities.h) (revision 77b29084a85f241dd6c83ef838e076bac666b11c) +++ Utilities.h (.../Utilities.h) (revision 18ffb88352fb14d3cdb0e82cd8e278cb37ce7020) @@ -1,59 +1,63 @@ /************************************************************************** * -* Copyright (c) 2020-2022 Diality Inc. - All Rights Reserved. +* Copyright (c) 2020-2023 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) Dara Navaei -* @date (last) 09-Aug-2022 +* @author (last) Bill Bracken +* @date (last) 15-May-2023 * * @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 ********** - + +#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_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 - TIME_WINDOWED_COUNT_FPGA_CLOCK_SPEED_ERROR, ///< FPGA clock speed error +#define MAX_TIME_WINDOWED_COUNT 10 ///< 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_OFF, ///< CAN off + TIME_WINDOWED_COUNT_CAN_PARITY, ///< CAN parity error + TIME_WINDOWED_COUNT_FPGA_CLOCK_SPEED_ERROR, ///< FPGA clock speed error #ifdef _HD_ - TIME_WINDOWED_COUNT_BP_COMMUTATION_ERROR, ///< Blood pump commutation error + TIME_WINDOWED_COUNT_BP_COMMUTATION_ERROR, ///< Blood pump commutation error TIME_WINDOWED_COUNT_DIP_COMMUTATION_ERROR, ///< Dialysate inlet pump commutation error TIME_WINDOWED_COUNT_DOP_COMMUTATION_ERROR, ///< Dialysate outlet pump commutation error -#endif -#ifdef _DG_ + TIME_WINDOWED_COUNT_FPGA_COMM_FAILURES, ///< FPGA communication failure (NAK, CRC, timeout) + TIME_WINDOWED_COUNT_SYRINGE_PUMP_OFF_ERROR, ///< Syringe pump off movement error + TIME_WINDOWED_COUNT_BATT_COMM_ERROR, ///< Battery communication error + TIME_WINDOWED_COUNT_BLOOD_LEAK_COMM_ERROR, ///< Blood Leak Sensor communication error +#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; + TIME_WINDOWED_COUNT_FPGA_TEMPERATURE_SENSOR_ERROR, ///< FPGA Temperature sensor error + TIME_WINDOWED_COUNT_FPGA_COMM_FAILURES, ///< FPGA communication failure (NAK, CRC, timeout) + TIME_WINDOWED_COUNT_FPGA_DRAIN_PUMP_HALL_SENSOR_ERROR, ///< FPGA Drain pump hall sensor failure +#endif + NUM_OF_TIME_WINDOWED_COUNTS ///< Number of pressure sensors +} TIME_WINDOWED_COUNT_T; -// ******* Critical Data Definitions ********* +// ******* Critical Data Definitions ********* /// Critical data types list. typedef enum Critical_Data_Types { @@ -90,30 +94,30 @@ BOOL set; ///< Flag indicates data has been set } CRITICAL_DATA_T; -// ********** public function prototypes ********** +// ********** public function prototypes ********** -U32 crc32( U32 const initialValue, const U08 *address, U32 len ); -U16 crc16( const U08 *address, U32 len ); +U32 crc32( U32 const initialValue, const U08 *address, U32 len ); +U16 crc16( const U08 *address, U32 len ); U08 crc8( const U08 *address, U32 len ); U08 crc4( U16* buffer, U32 byteCount ); U32 u32DiffWithWrap( U32 start, U32 end ); S32 u32BiDiffWithWrap( U32 start, U32 end ); U16 u16DiffWithWrap( U16 start, U16 end ); -S16 u16BiDiffWithWrap( U16 start, U16 end ); -void initTimeWindowedCount( TIME_WINDOWED_COUNT_T cnt, U32 maxCnt, U32 winMs ); +S16 u16BiDiffWithWrap( U16 start, U16 end ); +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 ); +BOOL hexStrToDec( U08 const * const valuePtr, U32* convValueAddress, U08 size ); BOOL isCriticalDataSet( CRITICAL_DATA_T *data ); ///< Determines if critical data has been set. void initSemaphores( void ); BOOL getSemaphore( SEMAPHORE_T s ); void releaseSemaphore( SEMAPHORE_T s ); -BOOL isSemaphoreReleased( SEMAPHORE_T s ); - -/**@}*/ - -#endif +BOOL isSemaphoreReleased( SEMAPHORE_T s ); + +/**@}*/ + +#endif