/************************************************************************** * * Copyright (c) 2025-2026 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 BloodLeakDriver.c * * @author (last) Dara Navaei * @date (last) 10-Sep-2024 * * @author (original) Dara Navaei * @date (original) 10-Sep-2024 * ***************************************************************************/ #ifndef __BLOODLEAKDRIVER_H__ #define __BLOODLEAKDRIVER_H__ #include "DDCommon.h" /** * @defgroup BloodLeakDriver BloodLeakDriver * @brief Blood Leak detector driver module. Drives the * blood leak detector. * * INTROTEK - Blood Component Detector Part No. 105-0002 * * @addtogroup BloodLeakDriver * @{ */ // ********** public definitions ********** #pragma pack(push,1) /// Blood leak detector data publish typedef struct { U32 bloodLeakStatus; ///< Blood leak detector status. U32 bloodLeakState; ///< Blood leak detector state. U32 bloodLeakPersistentCounter; ///< Blood leak detector persistent counter. U32 bloodLeakSerialCommState; ///< Blood leak detector serial communication state. U32 bloodLeakIntensity; ///< Blood leak detector intensity. U32 bloodLeakDetect; ///< Blood leak detector detect. F32 bloodLeakIntensityMovingAvg; ///< Blood leak detector intensity moving average. U32 bloodLeakTimeSinceZeroMS; ///< Blood leak detector time since last zero in milliseconds. U32 driftInRangeStatus; ///< Blood leak detector drift in range status. U32 driftUpperRangeStatus; ///< Blood leak detector drift upper range status. } BLOOD_LEAK_DATA_T; #pragma pack(pop) // ********** shared definitions (used by monitor + driver) ********** /// Enumeration of blood leak detector status. typedef enum BloodLeakDetectorStatus { BLOOD_LEAK_DETECTED = 0, ///< Blood leak detector senses blood. BLOOD_LEAK_NOT_DETECTED, ///< Blood leak detector does not sense any blood. NUM_OF_BLOOD_LEAK_STATUS ///< Number of blood leak detector status. } BLOOD_LEAK_STATUS_T; /// Blood leak main state machine states. typedef enum BloodLeakStates { BLOOD_LEAK_WAIT_FOR_POST_STATE = 0, BLOOD_LEAK_CHECK_SET_POINT_STATE, BLOOD_LEAK_INIT_STATE, BLOOD_LEAK_CHECK_ZERO_AND_SELF_TEST_STATE, BLOOD_LEAK_VERIFY_INTENSITY_AFTER_ZEROING_STATE, BLOOD_LEAK_NORMAL_STATE, BLOOD_LEAK_RECOVER_BLOOD_DETECT_STATE, NUM_OF_BLOOD_LEAK_STATES } BLOOD_LEAK_STATE_T; /// Embedded mode internal states. typedef enum EmbStates { BLOOD_LEAK_EMB_MODE_WAIT_FOR_COMAND_STATE = 0, BLOOD_LEAK_EMB_MODE_SEND_COMMAND_STATE, BLOOD_LEAK_EMB_MODE_WAIT_FOR_COMMAND_RESPONSE_STATE, NUM_OF_BLOOD_LEAK_EMB_MODE_STATES } BLOOD_LEAK_EMB_MODE_STATE_T; /// Blood leak detector embedded mode commands. typedef enum EmbCommands { NU_EMB_MODE_CMD = 0, CS_EMB_MODE_CMD, SP_EMB_MODE_CMD, T_EMB_MODE_CMD, G_EMB_MODE_CMD, I_EMB_MODE_CMD, V_EMB_MODE_CMD, Z_EMB_MODE_CMD, Q_EMB_MODE_CMD, D_EMB_MODE_CMD, C_EMB_MODE_CMD, NUM_OF_EMB_CMDS, } BLOOD_LEAK_EMB_MODE_CMD_T; #pragma pack(push,1) /// Embedded mode command specifications. typedef struct { U08 commandASCII; U08 expChar1; U08 expChar2; U32 length; U32 timeoutMS; U32 commandResp; U08 commandRqstCount; BOOL isCmdRespRdy; } EMB_MODE_CMD_T; /// Embedded mode response message. typedef struct { U08 command; U32 responseLen; U08 responseBuffer[ 5 ]; } BLOOD_LEAK_EMB_MODE_RESP_T; #pragma pack(pop) // ********** public function prototypes ********** void initBloodLeakDriver( void ); void execBloodLeakEmbModeCommand( void ); // Embedded mode command queue void enqueueEmbModeCmd( U08 cmd ); U08 dequeueEmbModeCmd( void ); U32 getAvailableEmbModeQueueCount( void ); BOOL isEmbModeCmdQueueEmpty( void ); void enqueueInfoEmbModeCmds( void ); // Embedded mode info/response void resetEmbModeCmdRqstCount( U08 cmd ); void resetEmbModeCmdRespConsumedFlag( U08 cmd ); U32 getEmbModeInfoValue( U08 cmd ); void processReceivedEmbModeChar( U08 data ); BOOL testSetBloodLeak2EmbeddedMode( MESSAGE_T *message ); BOOL testSetBloodLeakEmbeddedModeCommand( MESSAGE_T *message ); BOOL testBloodLeakEmbeddedModeInfoOverride( MESSAGE_T *message ); /**@}*/ #endif