Index: firmware/App/Drivers/BloodLeakDriver.c =================================================================== diff -u -rbc46476a2814d80611ec5ef0c1403415a86e43d5 -r3bafb322a459ffff32af3a109765cd060a748e32 --- firmware/App/Drivers/BloodLeakDriver.c (.../BloodLeakDriver.c) (revision bc46476a2814d80611ec5ef0c1403415a86e43d5) +++ firmware/App/Drivers/BloodLeakDriver.c (.../BloodLeakDriver.c) (revision 3bafb322a459ffff32af3a109765cd060a748e32) @@ -208,6 +208,279 @@ /*********************************************************************//** * @brief + * The processReceivedEmbModeChar function processes the character that + * has been received. + * @details \b Inputs: bloodLeakEmbModeCmd, bloodLeakEmbModeRespIndex + * @details \b Outputs: bloodLeakEmbModeRespBuffer, bloodLeakEmbModeRespIndex + * @param data which is the data that has been received from the BLD + * @return none + *************************************************************************/ +void processReceivedEmbModeChar( U08 data ) +{ + /* + * There are 3 types of data that can be received from the the sensor: + * 1. It could be a start character and the length (i.e. VXXXX) + * 2. It could be two discrete characters (i.e. P, F) + * 3. It could be none of the two characters (i.e. XXXX) + */ + U08 length = bloodLeakEmbModeCmd[ bloodLeakEmbModeRqstedCmd ].length; + U08 expChar1 = bloodLeakEmbModeCmd[ bloodLeakEmbModeRqstedCmd ].expChar1; + U08 expChar2 = bloodLeakEmbModeCmd[ bloodLeakEmbModeRqstedCmd ].expChar2; + + if ( expChar1 != NU_EMB_MODE_CMD ) + { + // This is the case that there is a start character. If current character buffer index is less than the + // length of the expected response of the command. + if ( bloodLeakEmbModeRespIndex < length ) + { + if ( NU_EMB_MODE_CMD == expChar2 ) + { + // Check if the expected char is received and the response buffer is empty because the index is 0, + // insert the buffer data + if ( ( expChar1 == data ) && ( 0 == bloodLeakEmbModeRespIndex ) ) + { + bloodLeakEmbModeRespBuffer[ bloodLeakEmbModeRespIndex ] = data; + bloodLeakEmbModeRespIndex++; + } + // Check if the buffer index is cd ve> 0 so the first char has been inserted and the rest is data but it is not the echo of the command + // For instance, V has been inserted and XXXX is inserted that is followed by V. So V123 and not VVV12. + else if ( ( bloodLeakEmbModeRespIndex > 0 ) && ( data != expChar1 ) ) + { + bloodLeakEmbModeRespBuffer[ bloodLeakEmbModeRespIndex ] = data; + bloodLeakEmbModeRespIndex++; + } + } + else + { + // Check if either of the expected chars are received and if they are insert it into the response buffer + if ( ( expChar1 == data ) || ( expChar2 == data ) ) + { + bloodLeakEmbModeRespBuffer[ bloodLeakEmbModeRespIndex ] = data; + bloodLeakEmbModeRespIndex++; + } + } + } + } + else + { + // This is the case that there are no expected characters and the received value are numbers + if ( bloodLeakEmbModeRespIndex < length ) + { + // If the received character is in the range of numbers chars (0 to 9), then insert them into the response buffer + if ( ( data >= BLOOD_LEAK_EMB_MODE_0_NUM_ASCII ) && ( data <= BLOOD_LEAK_EMB_MODE_9_NUM_ASCII ) ) + { + bloodLeakEmbModeRespBuffer[ bloodLeakEmbModeRespIndex ] = data; + bloodLeakEmbModeRespIndex++; + } + } + } +} + +/*********************************************************************//** + * @brief + * The enqueueEmbModeCmd function enqueues an embedded mode command. + * @details \b Inputs: none + * @details \b Outputs: bloodLeakEmbModeCmdQRearIndex, bloodLeakEmbModeCmdQCount + * bloodLeakEmbModeCmdQ, bloodLeakEmbModeCmd + * @param cmd the command to enqueue + * @return none + *************************************************************************/ +void enqueueEmbModeCmd( U08 cmd ) +{ + // Enqueue the command and increment the rear embedded mode index + // Set the command response to be false so the command was just queued to be read + bloodLeakEmbModeCmdQ[ bloodLeakEmbModeCmdQRearIndex ] = cmd; + bloodLeakEmbModeCmdQRearIndex = INC_WRAP( bloodLeakEmbModeCmdQRearIndex, 0, BLOOD_LEAK_EMB_MODE_CMD_Q_MAX_SIZE - 1 ); + bloodLeakEmbModeCmd[ cmd ].isCmdRespRdy = FALSE; + bloodLeakEmbModeCmd[ cmd ].commandRqstCount++; + bloodLeakEmbModeCmdQCount++; +} + +/*********************************************************************//** + * @brief + * The resetEmbModeCmdRqstCount function resets embedded mode command request + * count. + * @details \b Inputs: none + * @details \b Outputs: bloodLeakEmbModeCmd + * @param cmd the command to reset its request count + * @return none + *************************************************************************/ +void resetEmbModeCmdRqstCount( U08 cmd ) +{ + bloodLeakEmbModeCmd[ cmd ].commandRqstCount = 0; +} + +/*********************************************************************//** + * @brief + * The dequeueEmbModeCmd function dequeues the embedded mode command. + * @details \b Inputs: none + * @details \b Outputs: bloodLeakEmbModeCmdQFrontIndex, bloodLeakEmbModeCmdQCount + * @return command that is dequeued + *************************************************************************/ +U08 dequeueEmbModeCmd( void ) +{ + U08 command = 0; + U08 tempIndex; + + _disable_IRQ(); + tempIndex = bloodLeakEmbModeCmdQFrontIndex; + + if ( FALSE == isEmbModeCmdQueueEmpty() ) + { + bloodLeakEmbModeCmdQFrontIndex = INC_WRAP( bloodLeakEmbModeCmdQFrontIndex, 0, BLOOD_LEAK_EMB_MODE_CMD_Q_MAX_SIZE - 1 ); + command = bloodLeakEmbModeCmdQ[ tempIndex ]; + bloodLeakEmbModeCmdQCount--; + } + _enable_IRQ(); + + return command; +} + +/*********************************************************************//** + * @brief + * The isEmbModeCmdQueueEmpty function checks whether the embedded mode command + * queue is empty or not. + * @details \b Inputs: bloodLeakEmbModeCmdQCount + * @details \b Outputs: none + * @return TRUE if the queue is empty otherwise, FALSE + *************************************************************************/ +BOOL isEmbModeCmdQueueEmpty( void ) +{ + BOOL isEmpty = TRUE; + + if ( bloodLeakEmbModeCmdQCount > 0 ) + { + isEmpty = FALSE; + } + + return isEmpty; +} + +/*********************************************************************//** + * @brief + * The getAvailableEmbModeQueueCount function returns the available embedded + * mode queue count. + * @details \b ts: bloodLeakEmbModeCmdQCount + * @details \b Outputs: none + * @return Current available embedded mode queue count + *************************************************************************/ +U32 getAvailableEmbModeQueueCount( void ) +{ + return BLOOD_LEAK_EMB_MODE_CMD_Q_MAX_SIZE - bloodLeakEmbModeCmdQCount; +} + +/*********************************************************************//** + * @brief + * The enqueueInfoEmbModeCmds function enqueues the informative embedded + * mode commands. + * @details \b Inputs: bloodLeakEmbModeInfoCmdEnqueueLastTimeStamp, bloodLeakState, + * bloodLeakEmbModeInfoCmdCounter + * @details \b Outputs: bloodLeakEmbModeInfoCmdEnqueueLastTimeStamp, bloodLeakState, + * bloodLeakEmbModeInfoCmdCounter + * @return none + *************************************************************************/ +void enqueueInfoEmbModeCmds( void ) +{ + if ( TRUE == didTimeout( bloodLeakEmbModeInfoCmdEnqLastTimeStamp, BLOOD_LEAK_EMB_MODE_INFO_CMD_TIMEOUT_MS ) ) + { + switch ( bloodLeakState ) + { + case BLOOD_LEAK_INIT_STATE: + case BLOOD_LEAK_NORMAL_STATE: + case BLOOD_LEAK_RECOVER_BLOOD_DETECT_STATE: + // Enqueue the next command. Make sure the blood leak state is greater than init state and it is not the zero and self test state + // to make sure setting the embedded mode and getting the set point and zero sequence should go undisturbed. + if ( 0 == bloodLeakEmbModeInfoCmdCounter ) + { + enqueueEmbModeCmd( I_EMB_MODE_CMD ); + } + else if ( 1 == bloodLeakEmbModeInfoCmdCounter ) + { + enqueueEmbModeCmd( V_EMB_MODE_CMD ); + } + + // Set the timer for the next time out to enqueue + // Reset the counter. The counter starts from 0 + bloodLeakEmbModeInfoCmdEnqLastTimeStamp = getMSTimerCount(); + bloodLeakEmbModeInfoCmdCounter = INC_WRAP( bloodLeakEmbModeInfoCmdCounter, 0, BLOOD_LEAK_EMB_MODE_NUM_OF_INFO_CMDS - 1 ); + break; + + default: + // Do nothing as the other commands are ignored + break; + } + } +} + +/*********************************************************************//** + * @brief + * The getFPGABloodDetectProcessedStatus function returns the status of the + * blood detect from FPGA meaning the status that is read from the sensor. + * @details \b Inputs: none + * @details \b Outputs: none + * @return BLOOD_LEAK_NOT_DETECTED if blood has not been detected otherwise, + * BLOOD_LEAK_DETECTED + *************************************************************************/ +BLOOD_LEAK_STATUS_T getFPGABloodDetectProcessedStatus( void ) +{ + // If the blood leak status bit is low (0) it means blood has not been detected, otherwise, blood has been detected + return ( BLOOD_LEAK_STATUS_BIT_LOW == getFPGABloodLeakStatus() ? BLOOD_LEAK_NOT_DETECTED : BLOOD_LEAK_DETECTED ); +} + +/*********************************************************************//** + * @brief + * The resetEmbModeCmdRespConsumedFlag function sets the cmd response ready flag + * to false its flag that fresh data is ready. + * @details \b Inputs: none + * @details \b Outputs: bloodLeakEmbModeCmd + * @param cmd the command to signal its data has been consumed + * @return none + *************************************************************************/ +void resetEmbModeCmdRespConsumedFlag( U08 cmd ) +{ + bloodLeakEmbModeCmd[ cmd ].isCmdRespRdy = FALSE; +} + +/*********************************************************************//** + * @brief + * The getEmbModeInfoValue function gets the data of the embedded info cmds. + * This is only for the info values (I, V). + * @details \b Inputs: bloodLeakEmbModeIntensityOverride, + * bloodLeakEmbModeDetectOverride + * @details \b Outputs: bloodLeakEmbModeCmd + * @param cmd the command to get the read data + * @return the value of the read command + *************************************************************************/ +U32 getEmbModeInfoValue( U08 cmd ) +{ + U32 value = bloodLeakEmbModeCmd[ cmd ].commandResp; + + switch( cmd ) + { + case I_EMB_MODE_CMD: + if ( OVERRIDE_KEY == bloodLeakEmbModeIntensityOverride.override ) + { + value = bloodLeakEmbModeIntensityOverride.ovData; + } + break; + + case V_EMB_MODE_CMD: + if ( OVERRIDE_KEY == bloodLeakEmbModeDetectOverride.override ) + { + value = bloodLeakEmbModeDetectOverride.ovData; + } + break; + + default: + // Do nothing with the rest of the commands + break; + } + + return value; +} + +/*********************************************************************//** + * @brief * The handleBloodLeakEmbModeWaitForCommandState function handles the wait for * command state. The state prepares the message to be sent to the blood leak * sensor. @@ -506,318 +779,6 @@ /*********************************************************************//** * @brief - * The processReceivedEmbModeChar function processes the character that - * has been received. - * @details \b Inputs: bloodLeakEmbModeCmd, bloodLeakEmbModeRespIndex - * @details \b Outputs: bloodLeakEmbModeRespBuffer, bloodLeakEmbModeRespIndex - * @param data which is the data that has been received from the BLD - * @return none - *************************************************************************/ -void processReceivedEmbModeChar( U08 data ) -{ - /* - * There are 3 types of data that can be received from the the sensor: - * 1. It could be a start character and the length (i.e. VXXXX) - * 2. It could be two discrete characters (i.e. P, F) - * 3. It could be none of the two characters (i.e. XXXX) - */ - U08 length = bloodLeakEmbModeCmd[ bloodLeakEmbModeRqstedCmd ].length; - U08 expChar1 = bloodLeakEmbModeCmd[ bloodLeakEmbModeRqstedCmd ].expChar1; - U08 expChar2 = bloodLeakEmbModeCmd[ bloodLeakEmbModeRqstedCmd ].expChar2; - - if ( expChar1 != NU_EMB_MODE_CMD ) - { - // This is the case that there is a start character. If current character buffer index is less than the - // length of the expected response of the command. - if ( bloodLeakEmbModeRespIndex < length ) - { - if ( NU_EMB_MODE_CMD == expChar2 ) - { - // Check if the expected char is received and the response buffer is empty because the index is 0, - // insert the buffer data - if ( ( expChar1 == data ) && ( 0 == bloodLeakEmbModeRespIndex ) ) - { - bloodLeakEmbModeRespBuffer[ bloodLeakEmbModeRespIndex ] = data; - bloodLeakEmbModeRespIndex++; - } - // Check if the buffer index is cd ve> 0 so the first char has been inserted and the rest is data but it is not the echo of the command - // For instance, V has been inserted and XXXX is inserted that is followed by V. So V123 and not VVV12. - else if ( ( bloodLeakEmbModeRespIndex > 0 ) && ( data != expChar1 ) ) - { - bloodLeakEmbModeRespBuffer[ bloodLeakEmbModeRespIndex ] = data; - bloodLeakEmbModeRespIndex++; - } - } - else - { - // Check if either of the expected chars are received and if they are insert it into the response buffer - if ( ( expChar1 == data ) || ( expChar2 == data ) ) - { - bloodLeakEmbModeRespBuffer[ bloodLeakEmbModeRespIndex ] = data; - bloodLeakEmbModeRespIndex++; - } - } - } - } - else - { - // This is the case that there are no expected characters and the received value are numbers - if ( bloodLeakEmbModeRespIndex < length ) - { - // If the received character is in the range of numbers chars (0 to 9), then insert them into the response buffer - if ( ( data >= BLOOD_LEAK_EMB_MODE_0_NUM_ASCII ) && ( data <= BLOOD_LEAK_EMB_MODE_9_NUM_ASCII ) ) - { - bloodLeakEmbModeRespBuffer[ bloodLeakEmbModeRespIndex ] = data; - bloodLeakEmbModeRespIndex++; - } - } - } -} - -/*********************************************************************//** - * @brief - * The enqueueEmbModeCmd function enqueues an embedded mode command. - * @details \b Inputs: none - * @details \b Outputs: bloodLeakEmbModeCmdQRearIndex, bloodLeakEmbModeCmdQCount - * bloodLeakEmbModeCmdQ, bloodLeakEmbModeCmd - * @param cmd the command to enqueue - * @return none - *************************************************************************/ -void enqueueEmbModeCmd( U08 cmd ) -{ - // Enqueue the command and increment the rear embedded mode index - // Set the command response to be false so the command was just queued to be read - bloodLeakEmbModeCmdQ[ bloodLeakEmbModeCmdQRearIndex ] = cmd; - bloodLeakEmbModeCmdQRearIndex = INC_WRAP( bloodLeakEmbModeCmdQRearIndex, 0, BLOOD_LEAK_EMB_MODE_CMD_Q_MAX_SIZE - 1 ); - bloodLeakEmbModeCmd[ cmd ].isCmdRespRdy = FALSE; - bloodLeakEmbModeCmd[ cmd ].commandRqstCount++; - bloodLeakEmbModeCmdQCount++; -} - -/*********************************************************************//** - * @brief - * The resetEmbModeCmdRqstCount function resets embedded mode command request - * count. - * @details \b Inputs: none - * @details \b Outputs: bloodLeakEmbModeCmd - * @param cmd the command to reset its request count - * @return none - *************************************************************************/ -void resetEmbModeCmdRqstCount( U08 cmd ) -{ - bloodLeakEmbModeCmd[ cmd ].commandRqstCount = 0; -} - -/*********************************************************************//** - * @brief - * The dequeueEmbModeCmd function dequeues the embedded mode command. - * @details \b Inputs: none - * @details \b Outputs: bloodLeakEmbModeCmdQFrontIndex, bloodLeakEmbModeCmdQCount - * @return command that is dequeued - *************************************************************************/ -U08 dequeueEmbModeCmd( void ) -{ - U08 command = 0; - U08 tempIndex; - - _disable_IRQ(); - tempIndex = bloodLeakEmbModeCmdQFrontIndex; - - if ( FALSE == isEmbModeCmdQueueEmpty() ) - { - bloodLeakEmbModeCmdQFrontIndex = INC_WRAP( bloodLeakEmbModeCmdQFrontIndex, 0, BLOOD_LEAK_EMB_MODE_CMD_Q_MAX_SIZE - 1 ); - command = bloodLeakEmbModeCmdQ[ tempIndex ]; - bloodLeakEmbModeCmdQCount--; - } - _enable_IRQ(); - - return command; -} - -/*********************************************************************//** - * @brief - * The isEmbModeCmdQueueEmpty function checks whether the embedded mode command - * queue is empty or not. - * @details \b Inputs: bloodLeakEmbModeCmdQCount - * @details \b Outputs: none - * @return TRUE if the queue is empty otherwise, FALSE - *************************************************************************/ -BOOL isEmbModeCmdQueueEmpty( void ) -{ - BOOL isEmpty = TRUE; - - if ( bloodLeakEmbModeCmdQCount > 0 ) - { - isEmpty = FALSE; - } - - return isEmpty; -} - -/*********************************************************************//** - * @brief - * The getAvailableEmbModeQueueCount function returns the available embedded - * mode queue count. - * @details \b ts: bloodLeakEmbModeCmdQCount - * @details \b Outputs: none - * @return Current available embedded mode queue count - *************************************************************************/ -U32 getAvailableEmbModeQueueCount( void ) -{ - return BLOOD_LEAK_EMB_MODE_CMD_Q_MAX_SIZE - bloodLeakEmbModeCmdQCount; -} - -/*********************************************************************//** - * @brief - * The enqueueInfoEmbModeCmds function enqueues the informative embedded - * mode commands. - * @details \b Inputs: bloodLeakEmbModeInfoCmdEnqueueLastTimeStamp, bloodLeakState, - * bloodLeakEmbModeInfoCmdCounter - * @details \b Outputs: bloodLeakEmbModeInfoCmdEnqueueLastTimeStamp, bloodLeakState, - * bloodLeakEmbModeInfoCmdCounter - * @return none - *************************************************************************/ -void enqueueInfoEmbModeCmds( void ) -{ - if ( TRUE == didTimeout( bloodLeakEmbModeInfoCmdEnqLastTimeStamp, BLOOD_LEAK_EMB_MODE_INFO_CMD_TIMEOUT_MS ) ) - { - switch ( bloodLeakState ) - { - case BLOOD_LEAK_INIT_STATE: - case BLOOD_LEAK_NORMAL_STATE: - case BLOOD_LEAK_RECOVER_BLOOD_DETECT_STATE: - // Enqueue the next command. Make sure the blood leak state is greater than init state and it is not the zero and self test state - // to make sure setting the embedded mode and getting the set point and zero sequence should go undisturbed. - if ( 0 == bloodLeakEmbModeInfoCmdCounter ) - { - enqueueEmbModeCmd( I_EMB_MODE_CMD ); - } - else if ( 1 == bloodLeakEmbModeInfoCmdCounter ) - { - enqueueEmbModeCmd( V_EMB_MODE_CMD ); - } - - // Set the timer for the next time out to enqueue - // Reset the counter. The counter starts from 0 - bloodLeakEmbModeInfoCmdEnqLastTimeStamp = getMSTimerCount(); - bloodLeakEmbModeInfoCmdCounter = INC_WRAP( bloodLeakEmbModeInfoCmdCounter, 0, BLOOD_LEAK_EMB_MODE_NUM_OF_INFO_CMDS - 1 ); - break; - - default: - // Do nothing as the other commands are ignored - break; - } - } -} - -/*********************************************************************//** - * @brief - * The getBloodLeakRxBytesAvailable function returns the number of received - * bytes available from FPGA. - * @details \b Inputs: none - * @details \b Outputs: none - * @return Number of received bytes available - *************************************************************************/ -static U16 getBloodLeakRxBytesAvailable( void ) -{ - return getFPGABloodLeakRxFIFOCount() & BLOOD_LEAK_RXFIFO_COUNT_MASK; -} - -/*********************************************************************//** - * @brief - * The getFPGABloodDetectProcessedStatus function returns the status of the - * blood detect from FPGA meaning the status that is read from the sensor. - * @details \b Inputs: none - * @details \b Outputs: none - * @return BLOOD_LEAK_NOT_DETECTED if blood has not been detected otherwise, - * BLOOD_LEAK_DETECTED - *************************************************************************/ -BLOOD_LEAK_STATUS_T getFPGABloodDetectProcessedStatus( void ) -{ - // If the blood leak status bit is low (0) it means blood has not been detected, otherwise, blood has been detected - return ( BLOOD_LEAK_STATUS_BIT_LOW == getFPGABloodLeakStatus() ? BLOOD_LEAK_NOT_DETECTED : BLOOD_LEAK_DETECTED ); -} - -/*********************************************************************//** - * @brief - * The resetEmbModeCmdRespConsumedFlag function sets the cmd response ready flag - * to false its flag that fresh data is ready. - * @details \b Inputs: none - * @details \b Outputs: bloodLeakEmbModeCmd - * @param cmd the command to signal its data has been consumed - * @return none - *************************************************************************/ -void resetEmbModeCmdRespConsumedFlag( U08 cmd ) -{ - bloodLeakEmbModeCmd[ cmd ].isCmdRespRdy = FALSE; -} - -/*********************************************************************//** - * @brief - * The getEmbModeInfoValue function gets the data of the embedded info cmds. - * This is only for the info values (I, V). - * @details \b Inputs: bloodLeakEmbModeIntensityOverride, - * bloodLeakEmbModeDetectOverride - * @details \b Outputs: bloodLeakEmbModeCmd - * @param cmd the command to get the read data - * @return the value of the read command - *************************************************************************/ -U32 getEmbModeInfoValue( U08 cmd ) -{ - U32 value = bloodLeakEmbModeCmd[ cmd ].commandResp; - - switch( cmd ) - { - case I_EMB_MODE_CMD: - if ( OVERRIDE_KEY == bloodLeakEmbModeIntensityOverride.override ) - { - value = bloodLeakEmbModeIntensityOverride.ovData; - } - break; - - case V_EMB_MODE_CMD: - if ( OVERRIDE_KEY == bloodLeakEmbModeDetectOverride.override ) - { - value = bloodLeakEmbModeDetectOverride.ovData; - } - break; - - default: - // Do nothing with the rest of the commands - break; - } - - return value; -} - -/*********************************************************************//** - * @brief - * The sendBloodLeakEmbeddedModeCommandResponse function sends out - * the blood leak embedded mode command response. - * @details \b Inputs: none - * @details \b Outputs: blood leak embedded mode command response msg constructed and queued - * @details \b Message: MSG_ID_DD_SEND_BLOOD_LEAK_EMB_MODE_RESPONSE DD blood leak response command - * @param cmd: the command its response is being sent - * @param responseLen: the length of the buffer - * @param response: pointer to the response buffer - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -static BOOL sendBloodLeakEmbeddedModeCommandResponse( U08 cmd, U32 responseLen, U08 *responseBuffer ) -{ - BLOOD_LEAK_EMB_MODE_RESP_T response; - BOOL result = FALSE; - - response.command = cmd; - response.responseLen = responseLen; - memcpy( response.responseBuffer, responseBuffer, responseLen ); - - result = sendMessage( MSG_ID_DD_SEND_BLOOD_LEAK_EMB_MODE_RESPONSE, COMM_BUFFER_OUT_DD_CAN_PC, (U08*)&response, sizeof( BLOOD_LEAK_EMB_MODE_RESP_T ) ); - - return result; -} - -/*********************************************************************//** - * @brief * The convertString2Integer function converts the buffer of the answers in * string (ASCII) to integer. * @details \b Inputs: bloodLeakEmbModeCmd @@ -1047,7 +1008,44 @@ bloodLeakEmbModeCmd[ C_EMB_MODE_CMD ].isCmdRespRdy = FALSE; } +/*********************************************************************//** + * @brief + * The getBloodLeakRxBytesAvailable function returns the number of received + * bytes available from FPGA. + * @details \b Inputs: none + * @details \b Outputs: none + * @return Number of received bytes available + *************************************************************************/ +static U16 getBloodLeakRxBytesAvailable( void ) +{ + return getFPGABloodLeakRxFIFOCount() & BLOOD_LEAK_RXFIFO_COUNT_MASK; +} +/*********************************************************************//** + * @brief + * The sendBloodLeakEmbeddedModeCommandResponse function sends out + * the blood leak embedded mode command response. + * @details \b Inputs: none + * @details \b Outputs: blood leak embedded mode command response msg constructed and queued + * @details \b Message: MSG_ID_DD_SEND_BLOOD_LEAK_EMB_MODE_RESPONSE DD blood leak response command + * @param cmd: the command its response is being sent + * @param responseLen: the length of the buffer + * @param response: pointer to the response buffer + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +static BOOL sendBloodLeakEmbeddedModeCommandResponse( U08 cmd, U32 responseLen, U08 *responseBuffer ) +{ + BLOOD_LEAK_EMB_MODE_RESP_T response; + BOOL result = FALSE; + response.command = cmd; + response.responseLen = responseLen; + memcpy( response.responseBuffer, responseBuffer, responseLen ); + + result = sendMessage( MSG_ID_DD_SEND_BLOOD_LEAK_EMB_MODE_RESPONSE, COMM_BUFFER_OUT_DD_CAN_PC, (U08*)&response, sizeof( BLOOD_LEAK_EMB_MODE_RESP_T ) ); + + return result; +} + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/