Index: CommBuffers.h =================================================================== diff -u -r722e82fef4304c492a37a0330cd80cb5946e57ca -r34e9d24b76d786a5d3bba641f06e7764439c161e --- CommBuffers.h (.../CommBuffers.h) (revision 722e82fef4304c492a37a0330cd80cb5946e57ca) +++ CommBuffers.h (.../CommBuffers.h) (revision 34e9d24b76d786a5d3bba641f06e7764439c161e) @@ -14,10 +14,10 @@ * @date (original) 30-Jul-2024 * ***************************************************************************/ - -#ifndef __COMM_BUFFERS_H__ -#define __COMM_BUFFERS_H__ - + +#ifndef __COMM_BUFFERS_H__ +#define __COMM_BUFFERS_H__ + /** * @defgroup CommBuffers CommBuffers * @brief The communication buffers unit provides buffering services for @@ -28,9 +28,9 @@ * @{ */ -// ********** public definitions ********** +// ********** public definitions ********** -/// Enumeration of CAN communication buffers. Buffers are ordered by priority. +/// Enumeration of CAN communication buffers. Buffers are ordered by priority. typedef enum Comm_Buffers { COMM_BUFFER_NOT_USED = 0, ///< CAN message boxes start at 1 so we will not use this buffer @@ -46,7 +46,7 @@ COMM_BUFFER_OUT_CAN_TD_BROADCAST, ///< Buffer for outgoing TD broadcast messages COMM_BUFFER_IN_CAN_DD_BROADCAST, ///< Buffer for incoming DD broadcast messages COMM_BUFFER_IN_CAN_RO_BROADCAST, ///< Buffer for incoming RO broadcast messages - COMM_BUFFER_IN_CAN_UI_BROADCAST, ///< Buffer for incoming UI broadcast messages + COMM_BUFFER_IN_CAN_UI_BROADCAST, ///< Buffer for incoming UI broadcast messages #endif #ifdef _DD_ COMM_BUFFER_IN_CAN_TD_ALARM, ///< Buffer for incoming TD alarm messages @@ -63,24 +63,24 @@ COMM_BUFFER_IN_CAN_UI_BROADCAST, ///< Buffer for incoming UI broadcast messages #endif #ifdef _RO_ - COMM_BUFFER_OUT_CAN_RO_ALARM, ///< Buffer for outgoing RO alarm messages - COMM_BUFFER_OUT_CAN_RO_2_DD, ///< Buffer for outgoing RO to DD messages COMM_BUFFER_IN_CAN_TD_ALARM, ///< Buffer for incoming TD alarm messages COMM_BUFFER_IN_CAN_DD_ALARM, ///< Buffer for incoming DD alarm messages + COMM_BUFFER_OUT_CAN_RO_ALARM, ///< Buffer for outgoing RO alarm messages COMM_BUFFER_IN_CAN_UI_ALARM, ///< Buffer for incoming UI alarm messages COMM_BUFFER_IN_CAN_DD_2_RO, ///< Buffer for incoming DD to RO messages + COMM_BUFFER_OUT_CAN_RO_2_DD, ///< Buffer for outgoing RO to DD messages COMM_BUFFER_IN_CAN_TD_BROADCAST, ///< Buffer for incoming TD broadcast messages COMM_BUFFER_IN_CAN_DD_BROADCAST, ///< Buffer for incoming DD broadcast messages - COMM_BUFFER_IN_CAN_UI_BROADCAST, ///< Buffer for incoming UI broadcast messages COMM_BUFFER_OUT_CAN_RO_BROADCAST, ///< Buffer for incoming RO broadcast messages + COMM_BUFFER_IN_CAN_UI_BROADCAST, ///< Buffer for incoming UI broadcast messages #endif COMM_BUFFER_IN_CAN_PC, ///< Buffer for incoming PC messages COMM_BUFFER_OUT_CAN_PC, ///< Buffer for outgoing messages to PC NUM_OF_COMM_BUFFERS ///< Number of CAN communication buffers } COMM_BUFFER_T; /**@}*/ - + #ifdef _TD_ #include "TDCommon.h" #endif @@ -96,15 +96,15 @@ * @{ */ -// ********** public function prototypes ********** - -void initCommBuffers( void ); +// ********** public function prototypes ********** + +void initCommBuffers( void ); void clearBuffer( COMM_BUFFER_T buffer ); -BOOL addToCommBuffer( COMM_BUFFER_T buffer, U08 *data, U32 len ); -U32 getFromCommBuffer( COMM_BUFFER_T buffer, U08 *data, U32 len ); -U32 peekFromCommBuffer( COMM_BUFFER_T buffer, U08 *data, U32 len ); -U32 numberOfBytesInCommBuffer( COMM_BUFFER_T buffer ); - +BOOL addToCommBuffer( COMM_BUFFER_T buffer, U08 *data, U32 len ); +U32 getFromCommBuffer( COMM_BUFFER_T buffer, U08 *data, U32 len ); +U32 peekFromCommBuffer( COMM_BUFFER_T buffer, U08 *data, U32 len ); +U32 numberOfBytesInCommBuffer( COMM_BUFFER_T buffer ); + /**@}*/ -#endif +#endif Index: MessageSupport.h =================================================================== diff -u -r2801d97e877dd78189aa891e80a2f7cf60a6a2b7 -r34e9d24b76d786a5d3bba641f06e7764439c161e --- MessageSupport.h (.../MessageSupport.h) (revision 2801d97e877dd78189aa891e80a2f7cf60a6a2b7) +++ MessageSupport.h (.../MessageSupport.h) (revision 34e9d24b76d786a5d3bba641f06e7764439c161e) @@ -48,9 +48,9 @@ /// Record structure for a message (header + payload). typedef struct { - COMM_BUFFER_T in_buffer; ///< Message received into this channel buffer MESSAGE_HEADER_T hdr; ///< Message header U08 payload[ MAX_MSG_PAYLOAD_SIZE ]; ///< Message payload + COMM_BUFFER_T in_buffer; ///< Message received into this channel buffer } MESSAGE_T; /// Record structure for a wrapped message (message + CRC). Index: PressureCommon.c =================================================================== diff -u -r9bd7299479e7ac304483a309544173beea24557d -r34e9d24b76d786a5d3bba641f06e7764439c161e --- PressureCommon.c (.../PressureCommon.c) (revision 9bd7299479e7ac304483a309544173beea24557d) +++ PressureCommon.c (.../PressureCommon.c) (revision 34e9d24b76d786a5d3bba641f06e7764439c161e) @@ -15,48 +15,46 @@ * ***************************************************************************/ -#include "PressureCommon.h" - +#include "PressureCommon.h" + /** * @addtogroup PressureCommon * @{ */ -// ********** private definitions ********** - -#define BAR_TO_MMHG ( 750.062F ) ///< Conversion factor for converting bar to mmHg. +// ********** private definitions ********** #define PRESSURE_FS ( 14746.0F ) ///< Pressure sensor full scale output. #define PRESSURE_ZERO ( 1638.0F ) ///< Pressure sensor zero value. -#define PRESSURE_FS_MINUS_ZERO ( 13108.0F ) ///< Pressure sensor fullscale and zero difference. +#define PRESSURE_FS_MINUS_ZERO ( PRESSURE_FS - PRESSURE_ZERO ) ///< Pressure sensor fullscale and zero difference. #define PRESSURE_TEMP_RESOLUTION ( 2047.0F ) ///< Pressure sensor temperature resoultion 2^11 bit equals to 2047. #define PRESSURE_TEMP_MULTIPLIER ( 200.0F ) ///< Pressure sensor multiplier #define PRESSURE_TEMP_OFFSET ( 50.0F ) ///< Pressure sensor temperature offset. -// ********** private data ********** - - +// ********** private data ********** + + // ********** private function prototypes ********** /*********************************************************************//** * @brief - * The convertPressureReading2mmHg function converts a raw pressure ADC - * reading from a pressure sensor to mmHg. + * The convertPressureReading function converts a raw pressure ADC + * reading from a pressure sensor to desired units based on given min and + * max range of values. * @details \b Inputs: none * @details \b Outputs: none - * @return Pressure reading in mmHg + * @param counts Pressure sensor reading (in counts) read from FPGA. + * @param min Minimum pressure range in desired units + * @param max Maximum pressure range in desired units + * @return Pressure reading in desired units *************************************************************************/ -F32 convertPressureReading2mmHg( S16 counts ) -{ - F32 pressure_bar, mmHg; +F32 convertPressureReading( S16 counts, F32 min, F32 max ) +{ // Convert raw pressure counts to desired units + F32 pressure_bar = ( ( max - min ) * ( (F32)counts - PRESSURE_ZERO ) / PRESSURE_FS_MINUS_ZERO ) + min; - // Convert raw pressure counts to bar and then to mmHg - pressure_bar = PRESSURE_FS_MINUS_ZERO * ( ( (F32)counts - PRESSURE_ZERO ) / PRESSURE_FS_MINUS_ZERO ) + PRESSURE_ZERO; - mmHg = pressure_bar * BAR_TO_MMHG; - - return mmHg; + return pressure_bar; } /*********************************************************************//** @@ -76,5 +74,5 @@ return degC; } - + /**@}*/ Index: PressureCommon.h =================================================================== diff -u -r9bd7299479e7ac304483a309544173beea24557d -r34e9d24b76d786a5d3bba641f06e7764439c161e --- PressureCommon.h (.../PressureCommon.h) (revision 9bd7299479e7ac304483a309544173beea24557d) +++ PressureCommon.h (.../PressureCommon.h) (revision 34e9d24b76d786a5d3bba641f06e7764439c161e) @@ -14,20 +14,20 @@ * @date (original) 22-Aug-2024 * ***************************************************************************/ - -#ifndef __PRESSURE_COMMON_H__ -#define __PRESSURE_COMMON_H__ -#ifdef _TD_ +#ifndef __PRESSURE_COMMON_H__ +#define __PRESSURE_COMMON_H__ + +#ifdef _TD_ #include "TDCommon.h" #endif #ifdef _DD_ #include "DDCommon.h" #endif #ifdef _RO_ #include "ROCommon.h" -#endif - +#endif + /** * @defgroup PressureCommon PressureCommon * @brief The Pressure Sensor unit provides common conversion functions for @@ -37,14 +37,14 @@ * @{ */ -// ********** public definitions ********** - - -// ********** public function prototypes ********** - -F32 convertPressureReading2mmHg( S16 counts ); +// ********** public definitions ********** + + +// ********** public function prototypes ********** + +F32 convertPressureReading( S16 counts, F32 min, F32 max ); F32 convertPressureTempReading2DegC( S16 counts ); - + /**@}*/ -#endif +#endif Index: Utilities.c =================================================================== diff -u -r15a8d5ff98b2d88bd0f32a37b41f4eec0f7a7088 -r34e9d24b76d786a5d3bba641f06e7764439c161e --- Utilities.c (.../Utilities.c) (revision 15a8d5ff98b2d88bd0f32a37b41f4eec0f7a7088) +++ Utilities.c (.../Utilities.c) (revision 34e9d24b76d786a5d3bba641f06e7764439c161e) @@ -268,33 +268,6 @@ return ( nRem ^ 0x00 ); } -S16 signExtend16( U16 value, U32 signBit ) -{ - U16 signBitMask = 1; - U16 extend = 1; - S32 i; - - for ( i = 1; i < 15U - signBit; i++ ) - { - extend <<= 1; - extend |= 1; - } - extend <<= signBit; - - for ( i = 0; i < signBit; i++ ) - { - signBitMask <<= 1; - } - - // if given value is negative, sign extend value - if ( ( value & signBitMask ) != 0 ) - { - value |= extend; - } - - return (S16)value; -} - /*********************************************************************//** * @brief * The u32DiffWithWrap function calculates the difference between two given Index: Utilities.h =================================================================== diff -u -r4997cacd5a1501b7da1c8a3ba71f9594ad23a603 -r34e9d24b76d786a5d3bba641f06e7764439c161e --- Utilities.h (.../Utilities.h) (revision 4997cacd5a1501b7da1c8a3ba71f9594ad23a603) +++ Utilities.h (.../Utilities.h) (revision 34e9d24b76d786a5d3bba641f06e7764439c161e) @@ -114,8 +114,6 @@ U08 crc8( const U08 *address, U32 len ); U08 crc4( U16* buffer, U32 byteCount ); -S16 signExtend16( U16 value, U32 signBit ); - U32 u32DiffWithWrap( U32 start, U32 end ); S32 u32BiDiffWithWrap( U32 start, U32 end ); U16 u16DiffWithWrap( U16 start, U16 end );