Index: firmware/App/Drivers/BloodLeakDriver.c =================================================================== diff -u -r9273b79631e50be192556bb9eaffd3f3a22d49d2 -rbc46476a2814d80611ec5ef0c1403415a86e43d5 --- firmware/App/Drivers/BloodLeakDriver.c (.../BloodLeakDriver.c) (revision 9273b79631e50be192556bb9eaffd3f3a22d49d2) +++ firmware/App/Drivers/BloodLeakDriver.c (.../BloodLeakDriver.c) (revision bc46476a2814d80611ec5ef0c1403415a86e43d5) @@ -576,237 +576,6 @@ /*********************************************************************//** * @brief - * The convertString2Integer function converts the buffer of the answers in - * string (ASCII) to integer. - * @details \b Inputs: bloodLeakEmbModeCmd - * @details \b Outputs: bloodLeakEmbModeRespBuffer, bloodLeakEmbModeCmd - * @param cmd which is the embedded mode command - * @param respLength the length of the received response from the sensor - * @return none - *************************************************************************/ -static void convertString2Integer( U08 cmd, U32 respLength ) -{ - if ( 1 == respLength ) - { - bloodLeakEmbModeCmd[ cmd ].commandResp = bloodLeakEmbModeRespBuffer[ 0 ]; - } - else - { - U08 i; - U32 bufferValue; - U32 respExpectedLength = bloodLeakEmbModeCmd[ cmd ].length; - // Reset the command response - bloodLeakEmbModeCmd[ cmd ].commandResp = 0; - - for ( i = 0; i < respExpectedLength; i++ ) - { - // The last value is inserted into the response buffer (i.e. S030) - // So the buffer array is used from the last element of the array - bufferValue = bloodLeakEmbModeRespBuffer[ respExpectedLength - 1 - i ]; - - if ( ( bufferValue >= BLOOD_LEAK_EMB_MODE_0_NUM_ASCII ) && ( bufferValue <= BLOOD_LEAK_EMB_MODE_9_NUM_ASCII ) ) - { - // If the value in the response buffer is within the ASCII values of 0 (ASCII 48) to 9 (ASCII 57) then it is a number and needs to be converted to integer - // Subtract the buffer value from ASCII 48 to get the offset (i.e. buffer = 50 - 48 = 2) - // Add the offset value to the command response in the right order (i.e. if i = 1, then it is 2 x 10 ^1 = 20) - bufferValue -= BLOOD_LEAK_EMB_MODE_0_NUM_ASCII; - bloodLeakEmbModeCmd[ cmd ].commandResp += ( bufferValue * pow( 10, i ) ); - } - } - } - - // Set the command response ready - bloodLeakEmbModeCmd[ cmd ].isCmdRespRdy = TRUE; -} - -/*********************************************************************//** - * @brief - * The prepareSetPointSeq function prepares the set point sequence to be - * written to the blood leak sensor. - * @details \b Inputs: none - * @details \b Outputs: bloodLeakSetPointSequence, bloodLeakSetPointSeqLength - * @param setPoint the set point that has to be prepared to be sent to the sensor - * @return none - *************************************************************************/ -static void prepareSetPointSeq( U16 setPoint ) -{ - U08 i; - U32 digitCount; - char tempCharBuffer[ BLOOD_LEAK_SET_POINT_MAX_CHAR_LENGTH ]; - U08 command; - U32 bufferIndex = BLOOD_LEAK_SET_POINT_START_CHAR_INDEX; - - memset( tempCharBuffer, 0x0, BLOOD_LEAK_SET_POINT_MAX_CHAR_LENGTH ); - - // Convert the set point number to the equivalent ASCII number with the unsigned integer data type - sprintf( tempCharBuffer, "%u", (U32)setPoint ); - - // Calculate the length of the character buffer. strlen does not count the null character. - digitCount = strlen( tempCharBuffer ); - - command = ( TRUE == bloodLeakSignalEmbModeReq ? BLOOD_LEAK_EMB_MODE_COMM_RESET : BLOOD_LEAK_RESET_TX_FIFO ); - bloodLeakSetPointSequence[ bufferIndex ][ BLOOD_LEAK_EMB_MODE_CMD_COL_INDEX ] = command; - bloodLeakSetPointSequence[ bufferIndex ][ BLOOD_LEAK_EMB_MODE_IS_UART_COL_INDEX ] = TRUE; - bufferIndex++; - - command = ( TRUE == bloodLeakSignalEmbModeReq ? BLOOD_LEAK_EMB_MODE_COMM_ACTIVE_LOW : BLOOD_LEAK_UART_COMM_ACTIVE_LOW ); - bloodLeakSetPointSequence[ bufferIndex ][ BLOOD_LEAK_EMB_MODE_CMD_COL_INDEX ] = command; - bloodLeakSetPointSequence[ bufferIndex ][ BLOOD_LEAK_EMB_MODE_IS_UART_COL_INDEX ] = TRUE; - bufferIndex++; - - // Set the first item to the ASCII character of S. The format to set the set point is - // SXXXCR10. It starts with S followed by the characters up to 3 digits, carriage return and a 1 and a 0 to write to the buffer. - bloodLeakSetPointSequence[ bufferIndex ][ BLOOD_LEAK_EMB_MODE_CMD_COL_INDEX ] = BLOOD_LEAK_SET_POINT_START_CHAR_ASCII; - bloodLeakSetPointSequence[ bufferIndex ][ BLOOD_LEAK_EMB_MODE_IS_UART_COL_INDEX ] = FALSE; - bufferIndex++; - - // Loop through the number of digits and get each ASCII value - for ( i = 0; i < digitCount; i++ ) - { - // Write the characters - bloodLeakSetPointSequence[ bufferIndex ][ BLOOD_LEAK_EMB_MODE_CMD_COL_INDEX ] = tempCharBuffer[ i ]; - bloodLeakSetPointSequence[ bufferIndex ][ BLOOD_LEAK_EMB_MODE_IS_UART_COL_INDEX ] = FALSE; - bufferIndex++; - } - - // After the characters, insert the carriage return into the buffer - bloodLeakSetPointSequence[ bufferIndex ][ BLOOD_LEAK_EMB_MODE_CMD_COL_INDEX ] = BLOOD_LEAK_CARRIAGE_RETURN_ASCII; - bloodLeakSetPointSequence[ bufferIndex ][ BLOOD_LEAK_EMB_MODE_IS_UART_COL_INDEX ] = FALSE; - bufferIndex++; - - // After the characters, insert the stop write to FIFO character which is number 0 - bloodLeakSetPointSequence[ bufferIndex ][ BLOOD_LEAK_EMB_MODE_CMD_COL_INDEX ] = BLOOD_LEAK_STOP_WRITE_FIFO_COMMAND; - bloodLeakSetPointSequence[ bufferIndex ][ BLOOD_LEAK_EMB_MODE_IS_UART_COL_INDEX ] = FALSE; - bufferIndex++; - - // Set active high into the buffer. - // If the mode is embedded mode, the active high (and active low) values are different than in the Ctrl U mode since the bit values are different - command = ( TRUE == bloodLeakSignalEmbModeReq ? BLOOD_LEAK_EMB_MODE_COMM_ACTIVE_HIGH : BLOOD_LEAK_UART_COMM_ACTIVE_HIGH ); - bloodLeakSetPointSequence[ bufferIndex ][ BLOOD_LEAK_EMB_MODE_CMD_COL_INDEX ] = command; - bloodLeakSetPointSequence[ bufferIndex ][ BLOOD_LEAK_EMB_MODE_IS_UART_COL_INDEX ] = TRUE; - bufferIndex++; - - command = ( TRUE == bloodLeakSignalEmbModeReq ? BLOOD_LEAK_EMB_MODE_COMM_ACTIVE_LOW : BLOOD_LEAK_UART_COMM_ACTIVE_LOW ); - bloodLeakSetPointSequence[ bufferIndex ][ BLOOD_LEAK_EMB_MODE_CMD_COL_INDEX ] = command; - bloodLeakSetPointSequence[ bufferIndex ][ BLOOD_LEAK_EMB_MODE_IS_UART_COL_INDEX ] = TRUE; - - // Update the sequence length for writing to the sensor - bloodLeakSetPointSeqLength = bufferIndex + 1; - bloodLeakUARTCmdIndex = 0; -} - -/*********************************************************************//** - * @brief - * The initEmbModeSpecs function initializes the embedded mode specifications - * structure. - * @details \b Inputs: none - * @details \b Outputs: bloodLeakEmbModeCmd - * @return none - *************************************************************************/ -static void initEmbModeSpecs( void ) -{ - // Null command - bloodLeakEmbModeCmd[ NU_EMB_MODE_CMD ].commandASCII = NU_EMB_MODE_CMD; - bloodLeakEmbModeCmd[ NU_EMB_MODE_CMD ].expChar1 = NU_EMB_MODE_CMD; - bloodLeakEmbModeCmd[ NU_EMB_MODE_CMD ].expChar2 = NU_EMB_MODE_CMD; - bloodLeakEmbModeCmd[ NU_EMB_MODE_CMD ].length = 0; - bloodLeakEmbModeCmd[ NU_EMB_MODE_CMD ].timeoutMS = 0; - bloodLeakEmbModeCmd[ NU_EMB_MODE_CMD ].commandResp = 0; - bloodLeakEmbModeCmd[ NU_EMB_MODE_CMD ].isCmdRespRdy = FALSE; - - // Control S command - bloodLeakEmbModeCmd[ CS_EMB_MODE_CMD ].commandASCII = 19; // ASCII for Control S - bloodLeakEmbModeCmd[ CS_EMB_MODE_CMD ].expChar1 = 69; // ASCII for E (Embedded ...) - bloodLeakEmbModeCmd[ CS_EMB_MODE_CMD ].expChar2 = NU_EMB_MODE_CMD; - bloodLeakEmbModeCmd[ CS_EMB_MODE_CMD ].length = 5; - bloodLeakEmbModeCmd[ CS_EMB_MODE_CMD ].timeoutMS = 5 * MS_PER_SECOND; - bloodLeakEmbModeCmd[ CS_EMB_MODE_CMD ].commandResp = 0; - bloodLeakEmbModeCmd[ CS_EMB_MODE_CMD ].isCmdRespRdy = FALSE; - - // Set point command - bloodLeakEmbModeCmd[ SP_EMB_MODE_CMD ].commandASCII = 83; // ASCII for S - bloodLeakEmbModeCmd[ SP_EMB_MODE_CMD ].expChar1 = 32; // For space (Set point is returned by a space at the beginning of returning the set point value) - bloodLeakEmbModeCmd[ SP_EMB_MODE_CMD ].expChar2 = NU_EMB_MODE_CMD; - bloodLeakEmbModeCmd[ SP_EMB_MODE_CMD ].length = 5; - bloodLeakEmbModeCmd[ SP_EMB_MODE_CMD ].timeoutMS = 10 * MS_PER_SECOND; - bloodLeakEmbModeCmd[ SP_EMB_MODE_CMD ].commandResp = 0; - bloodLeakEmbModeCmd[ SP_EMB_MODE_CMD ].isCmdRespRdy = FALSE; - - // Self test command - bloodLeakEmbModeCmd[ T_EMB_MODE_CMD ].commandASCII = 84; // ASCII for T - bloodLeakEmbModeCmd[ T_EMB_MODE_CMD ].expChar1 = 80; // ASCII for P - bloodLeakEmbModeCmd[ T_EMB_MODE_CMD ].expChar2 = 70; // ASCII for F - bloodLeakEmbModeCmd[ T_EMB_MODE_CMD ].length = 1; - bloodLeakEmbModeCmd[ T_EMB_MODE_CMD ].timeoutMS = 5 * MS_PER_SECOND; - bloodLeakEmbModeCmd[ T_EMB_MODE_CMD ].commandResp = 0; - bloodLeakEmbModeCmd[ T_EMB_MODE_CMD ].isCmdRespRdy = FALSE; - - // Get self test command - bloodLeakEmbModeCmd[ G_EMB_MODE_CMD ].commandASCII = 71; // ASCII for G - bloodLeakEmbModeCmd[ G_EMB_MODE_CMD ].expChar1 = 71; - bloodLeakEmbModeCmd[ G_EMB_MODE_CMD ].expChar2 = NU_EMB_MODE_CMD; - bloodLeakEmbModeCmd[ G_EMB_MODE_CMD ].length = 5; - bloodLeakEmbModeCmd[ G_EMB_MODE_CMD ].timeoutMS = 10 * MS_PER_SECOND; - bloodLeakEmbModeCmd[ G_EMB_MODE_CMD ].commandResp = 0; - bloodLeakEmbModeCmd[ G_EMB_MODE_CMD ].isCmdRespRdy = FALSE; - - // Intensity command - bloodLeakEmbModeCmd[ I_EMB_MODE_CMD ].commandASCII = 73; // ASCII for I - bloodLeakEmbModeCmd[ I_EMB_MODE_CMD ].expChar1 = 73; - bloodLeakEmbModeCmd[ I_EMB_MODE_CMD ].expChar2 = NU_EMB_MODE_CMD; - bloodLeakEmbModeCmd[ I_EMB_MODE_CMD ].length = 5; - bloodLeakEmbModeCmd[ I_EMB_MODE_CMD ].timeoutMS = 5 * MS_PER_SECOND; - bloodLeakEmbModeCmd[ I_EMB_MODE_CMD ].commandResp = 0; - bloodLeakEmbModeCmd[ I_EMB_MODE_CMD ].isCmdRespRdy = FALSE; - - // Blood detection command - bloodLeakEmbModeCmd[ V_EMB_MODE_CMD ].commandASCII = 86; // ASCII for V - bloodLeakEmbModeCmd[ V_EMB_MODE_CMD ].expChar1 = 86; - bloodLeakEmbModeCmd[ V_EMB_MODE_CMD ].expChar2 = NU_EMB_MODE_CMD; - bloodLeakEmbModeCmd[ V_EMB_MODE_CMD ].length = 5; - bloodLeakEmbModeCmd[ V_EMB_MODE_CMD ].timeoutMS = 5 * MS_PER_SECOND; - bloodLeakEmbModeCmd[ V_EMB_MODE_CMD ].commandResp = 0; - bloodLeakEmbModeCmd[ V_EMB_MODE_CMD ].isCmdRespRdy = FALSE; - - // Zero sensor command - bloodLeakEmbModeCmd[ Z_EMB_MODE_CMD ].commandASCII = 90; // ASCII for Z - bloodLeakEmbModeCmd[ Z_EMB_MODE_CMD ].expChar1 = 89; // ASCII for Y - bloodLeakEmbModeCmd[ Z_EMB_MODE_CMD ].expChar2 = NU_EMB_MODE_CMD; - bloodLeakEmbModeCmd[ Z_EMB_MODE_CMD ].length = 1; - bloodLeakEmbModeCmd[ Z_EMB_MODE_CMD ].timeoutMS = 10 * MS_PER_SECOND; - bloodLeakEmbModeCmd[ Z_EMB_MODE_CMD ].commandResp = 0; - bloodLeakEmbModeCmd[ Z_EMB_MODE_CMD ].isCmdRespRdy = FALSE; - - // Zero confirm command - bloodLeakEmbModeCmd[ Q_EMB_MODE_CMD ].commandASCII = 81; // ASCII for Q - bloodLeakEmbModeCmd[ Q_EMB_MODE_CMD ].expChar1 = 80; // ASCII for P - bloodLeakEmbModeCmd[ Q_EMB_MODE_CMD ].expChar2 = 70; // ASCII for F - bloodLeakEmbModeCmd[ Q_EMB_MODE_CMD ].length = 1; - bloodLeakEmbModeCmd[ Q_EMB_MODE_CMD ].timeoutMS = 5 * MS_PER_SECOND; - bloodLeakEmbModeCmd[ Q_EMB_MODE_CMD ].commandResp = 0; - bloodLeakEmbModeCmd[ Q_EMB_MODE_CMD ].isCmdRespRdy = FALSE; - - // Display blood detection command - bloodLeakEmbModeCmd[ D_EMB_MODE_CMD ].commandASCII = 68; - bloodLeakEmbModeCmd[ D_EMB_MODE_CMD ].expChar1 = 68; // ASCII for D - bloodLeakEmbModeCmd[ D_EMB_MODE_CMD ].expChar2 = NU_EMB_MODE_CMD; - bloodLeakEmbModeCmd[ D_EMB_MODE_CMD ].length = 5; - bloodLeakEmbModeCmd[ D_EMB_MODE_CMD ].timeoutMS = 5 * MS_PER_SECOND; - bloodLeakEmbModeCmd[ D_EMB_MODE_CMD ].commandResp = 0; - bloodLeakEmbModeCmd[ D_EMB_MODE_CMD ].isCmdRespRdy = FALSE; - - // Calibrate command - bloodLeakEmbModeCmd[ C_EMB_MODE_CMD ].commandASCII = 67; - bloodLeakEmbModeCmd[ C_EMB_MODE_CMD ].expChar1 = 67; // ASCII for C - bloodLeakEmbModeCmd[ C_EMB_MODE_CMD ].expChar2 = NU_EMB_MODE_CMD; - bloodLeakEmbModeCmd[ C_EMB_MODE_CMD ].length = 4; - bloodLeakEmbModeCmd[ C_EMB_MODE_CMD ].timeoutMS = 5 * MS_PER_SECOND; - bloodLeakEmbModeCmd[ C_EMB_MODE_CMD ].commandResp = 0; - bloodLeakEmbModeCmd[ C_EMB_MODE_CMD ].isCmdRespRdy = FALSE; -} - -/*********************************************************************//** - * @brief * The enqueueEmbModeCmd function enqueues an embedded mode command. * @details \b Inputs: none * @details \b Outputs: bloodLeakEmbModeCmdQRearIndex, bloodLeakEmbModeCmdQCount @@ -1047,7 +816,238 @@ return result; } +/*********************************************************************//** + * @brief + * The convertString2Integer function converts the buffer of the answers in + * string (ASCII) to integer. + * @details \b Inputs: bloodLeakEmbModeCmd + * @details \b Outputs: bloodLeakEmbModeRespBuffer, bloodLeakEmbModeCmd + * @param cmd which is the embedded mode command + * @param respLength the length of the received response from the sensor + * @return none + *************************************************************************/ +static void convertString2Integer( U08 cmd, U32 respLength ) +{ + if ( 1 == respLength ) + { + bloodLeakEmbModeCmd[ cmd ].commandResp = bloodLeakEmbModeRespBuffer[ 0 ]; + } + else + { + U08 i; + U32 bufferValue; + U32 respExpectedLength = bloodLeakEmbModeCmd[ cmd ].length; + // Reset the command response + bloodLeakEmbModeCmd[ cmd ].commandResp = 0; + for ( i = 0; i < respExpectedLength; i++ ) + { + // The last value is inserted into the response buffer (i.e. S030) + // So the buffer array is used from the last element of the array + bufferValue = bloodLeakEmbModeRespBuffer[ respExpectedLength - 1 - i ]; + + if ( ( bufferValue >= BLOOD_LEAK_EMB_MODE_0_NUM_ASCII ) && ( bufferValue <= BLOOD_LEAK_EMB_MODE_9_NUM_ASCII ) ) + { + // If the value in the response buffer is within the ASCII values of 0 (ASCII 48) to 9 (ASCII 57) then it is a number and needs to be converted to integer + // Subtract the buffer value from ASCII 48 to get the offset (i.e. buffer = 50 - 48 = 2) + // Add the offset value to the command response in the right order (i.e. if i = 1, then it is 2 x 10 ^1 = 20) + bufferValue -= BLOOD_LEAK_EMB_MODE_0_NUM_ASCII; + bloodLeakEmbModeCmd[ cmd ].commandResp += ( bufferValue * pow( 10, i ) ); + } + } + } + + // Set the command response ready + bloodLeakEmbModeCmd[ cmd ].isCmdRespRdy = TRUE; +} + +/*********************************************************************//** + * @brief + * The prepareSetPointSeq function prepares the set point sequence to be + * written to the blood leak sensor. + * @details \b Inputs: none + * @details \b Outputs: bloodLeakSetPointSequence, bloodLeakSetPointSeqLength + * @param setPoint the set point that has to be prepared to be sent to the sensor + * @return none + *************************************************************************/ +static void prepareSetPointSeq( U16 setPoint ) +{ + U08 i; + U32 digitCount; + char tempCharBuffer[ BLOOD_LEAK_SET_POINT_MAX_CHAR_LENGTH ]; + U08 command; + U32 bufferIndex = BLOOD_LEAK_SET_POINT_START_CHAR_INDEX; + + memset( tempCharBuffer, 0x0, BLOOD_LEAK_SET_POINT_MAX_CHAR_LENGTH ); + + // Convert the set point number to the equivalent ASCII number with the unsigned integer data type + sprintf( tempCharBuffer, "%u", (U32)setPoint ); + + // Calculate the length of the character buffer. strlen does not count the null character. + digitCount = strlen( tempCharBuffer ); + + command = ( TRUE == bloodLeakSignalEmbModeReq ? BLOOD_LEAK_EMB_MODE_COMM_RESET : BLOOD_LEAK_RESET_TX_FIFO ); + bloodLeakSetPointSequence[ bufferIndex ][ BLOOD_LEAK_EMB_MODE_CMD_COL_INDEX ] = command; + bloodLeakSetPointSequence[ bufferIndex ][ BLOOD_LEAK_EMB_MODE_IS_UART_COL_INDEX ] = TRUE; + bufferIndex++; + + command = ( TRUE == bloodLeakSignalEmbModeReq ? BLOOD_LEAK_EMB_MODE_COMM_ACTIVE_LOW : BLOOD_LEAK_UART_COMM_ACTIVE_LOW ); + bloodLeakSetPointSequence[ bufferIndex ][ BLOOD_LEAK_EMB_MODE_CMD_COL_INDEX ] = command; + bloodLeakSetPointSequence[ bufferIndex ][ BLOOD_LEAK_EMB_MODE_IS_UART_COL_INDEX ] = TRUE; + bufferIndex++; + + // Set the first item to the ASCII character of S. The format to set the set point is + // SXXXCR10. It starts with S followed by the characters up to 3 digits, carriage return and a 1 and a 0 to write to the buffer. + bloodLeakSetPointSequence[ bufferIndex ][ BLOOD_LEAK_EMB_MODE_CMD_COL_INDEX ] = BLOOD_LEAK_SET_POINT_START_CHAR_ASCII; + bloodLeakSetPointSequence[ bufferIndex ][ BLOOD_LEAK_EMB_MODE_IS_UART_COL_INDEX ] = FALSE; + bufferIndex++; + + // Loop through the number of digits and get each ASCII value + for ( i = 0; i < digitCount; i++ ) + { + // Write the characters + bloodLeakSetPointSequence[ bufferIndex ][ BLOOD_LEAK_EMB_MODE_CMD_COL_INDEX ] = tempCharBuffer[ i ]; + bloodLeakSetPointSequence[ bufferIndex ][ BLOOD_LEAK_EMB_MODE_IS_UART_COL_INDEX ] = FALSE; + bufferIndex++; + } + + // After the characters, insert the carriage return into the buffer + bloodLeakSetPointSequence[ bufferIndex ][ BLOOD_LEAK_EMB_MODE_CMD_COL_INDEX ] = BLOOD_LEAK_CARRIAGE_RETURN_ASCII; + bloodLeakSetPointSequence[ bufferIndex ][ BLOOD_LEAK_EMB_MODE_IS_UART_COL_INDEX ] = FALSE; + bufferIndex++; + + // After the characters, insert the stop write to FIFO character which is number 0 + bloodLeakSetPointSequence[ bufferIndex ][ BLOOD_LEAK_EMB_MODE_CMD_COL_INDEX ] = BLOOD_LEAK_STOP_WRITE_FIFO_COMMAND; + bloodLeakSetPointSequence[ bufferIndex ][ BLOOD_LEAK_EMB_MODE_IS_UART_COL_INDEX ] = FALSE; + bufferIndex++; + + // Set active high into the buffer. + // If the mode is embedded mode, the active high (and active low) values are different than in the Ctrl U mode since the bit values are different + command = ( TRUE == bloodLeakSignalEmbModeReq ? BLOOD_LEAK_EMB_MODE_COMM_ACTIVE_HIGH : BLOOD_LEAK_UART_COMM_ACTIVE_HIGH ); + bloodLeakSetPointSequence[ bufferIndex ][ BLOOD_LEAK_EMB_MODE_CMD_COL_INDEX ] = command; + bloodLeakSetPointSequence[ bufferIndex ][ BLOOD_LEAK_EMB_MODE_IS_UART_COL_INDEX ] = TRUE; + bufferIndex++; + + command = ( TRUE == bloodLeakSignalEmbModeReq ? BLOOD_LEAK_EMB_MODE_COMM_ACTIVE_LOW : BLOOD_LEAK_UART_COMM_ACTIVE_LOW ); + bloodLeakSetPointSequence[ bufferIndex ][ BLOOD_LEAK_EMB_MODE_CMD_COL_INDEX ] = command; + bloodLeakSetPointSequence[ bufferIndex ][ BLOOD_LEAK_EMB_MODE_IS_UART_COL_INDEX ] = TRUE; + + // Update the sequence length for writing to the sensor + bloodLeakSetPointSeqLength = bufferIndex + 1; + bloodLeakUARTCmdIndex = 0; +} + +/*********************************************************************//** + * @brief + * The initEmbModeSpecs function initializes the embedded mode specifications + * structure. + * @details \b Inputs: none + * @details \b Outputs: bloodLeakEmbModeCmd + * @return none + *************************************************************************/ +static void initEmbModeSpecs( void ) +{ + // Null command + bloodLeakEmbModeCmd[ NU_EMB_MODE_CMD ].commandASCII = NU_EMB_MODE_CMD; + bloodLeakEmbModeCmd[ NU_EMB_MODE_CMD ].expChar1 = NU_EMB_MODE_CMD; + bloodLeakEmbModeCmd[ NU_EMB_MODE_CMD ].expChar2 = NU_EMB_MODE_CMD; + bloodLeakEmbModeCmd[ NU_EMB_MODE_CMD ].length = 0; + bloodLeakEmbModeCmd[ NU_EMB_MODE_CMD ].timeoutMS = 0; + bloodLeakEmbModeCmd[ NU_EMB_MODE_CMD ].commandResp = 0; + bloodLeakEmbModeCmd[ NU_EMB_MODE_CMD ].isCmdRespRdy = FALSE; + + // Control S command + bloodLeakEmbModeCmd[ CS_EMB_MODE_CMD ].commandASCII = 19; // ASCII for Control S + bloodLeakEmbModeCmd[ CS_EMB_MODE_CMD ].expChar1 = 69; // ASCII for E (Embedded ...) + bloodLeakEmbModeCmd[ CS_EMB_MODE_CMD ].expChar2 = NU_EMB_MODE_CMD; + bloodLeakEmbModeCmd[ CS_EMB_MODE_CMD ].length = 5; + bloodLeakEmbModeCmd[ CS_EMB_MODE_CMD ].timeoutMS = 5 * MS_PER_SECOND; + bloodLeakEmbModeCmd[ CS_EMB_MODE_CMD ].commandResp = 0; + bloodLeakEmbModeCmd[ CS_EMB_MODE_CMD ].isCmdRespRdy = FALSE; + + // Set point command + bloodLeakEmbModeCmd[ SP_EMB_MODE_CMD ].commandASCII = 83; // ASCII for S + bloodLeakEmbModeCmd[ SP_EMB_MODE_CMD ].expChar1 = 32; // For space (Set point is returned by a space at the beginning of returning the set point value) + bloodLeakEmbModeCmd[ SP_EMB_MODE_CMD ].expChar2 = NU_EMB_MODE_CMD; + bloodLeakEmbModeCmd[ SP_EMB_MODE_CMD ].length = 5; + bloodLeakEmbModeCmd[ SP_EMB_MODE_CMD ].timeoutMS = 10 * MS_PER_SECOND; + bloodLeakEmbModeCmd[ SP_EMB_MODE_CMD ].commandResp = 0; + bloodLeakEmbModeCmd[ SP_EMB_MODE_CMD ].isCmdRespRdy = FALSE; + + // Self test command + bloodLeakEmbModeCmd[ T_EMB_MODE_CMD ].commandASCII = 84; // ASCII for T + bloodLeakEmbModeCmd[ T_EMB_MODE_CMD ].expChar1 = 80; // ASCII for P + bloodLeakEmbModeCmd[ T_EMB_MODE_CMD ].expChar2 = 70; // ASCII for F + bloodLeakEmbModeCmd[ T_EMB_MODE_CMD ].length = 1; + bloodLeakEmbModeCmd[ T_EMB_MODE_CMD ].timeoutMS = 5 * MS_PER_SECOND; + bloodLeakEmbModeCmd[ T_EMB_MODE_CMD ].commandResp = 0; + bloodLeakEmbModeCmd[ T_EMB_MODE_CMD ].isCmdRespRdy = FALSE; + + // Get self test command + bloodLeakEmbModeCmd[ G_EMB_MODE_CMD ].commandASCII = 71; // ASCII for G + bloodLeakEmbModeCmd[ G_EMB_MODE_CMD ].expChar1 = 71; + bloodLeakEmbModeCmd[ G_EMB_MODE_CMD ].expChar2 = NU_EMB_MODE_CMD; + bloodLeakEmbModeCmd[ G_EMB_MODE_CMD ].length = 5; + bloodLeakEmbModeCmd[ G_EMB_MODE_CMD ].timeoutMS = 10 * MS_PER_SECOND; + bloodLeakEmbModeCmd[ G_EMB_MODE_CMD ].commandResp = 0; + bloodLeakEmbModeCmd[ G_EMB_MODE_CMD ].isCmdRespRdy = FALSE; + + // Intensity command + bloodLeakEmbModeCmd[ I_EMB_MODE_CMD ].commandASCII = 73; // ASCII for I + bloodLeakEmbModeCmd[ I_EMB_MODE_CMD ].expChar1 = 73; + bloodLeakEmbModeCmd[ I_EMB_MODE_CMD ].expChar2 = NU_EMB_MODE_CMD; + bloodLeakEmbModeCmd[ I_EMB_MODE_CMD ].length = 5; + bloodLeakEmbModeCmd[ I_EMB_MODE_CMD ].timeoutMS = 5 * MS_PER_SECOND; + bloodLeakEmbModeCmd[ I_EMB_MODE_CMD ].commandResp = 0; + bloodLeakEmbModeCmd[ I_EMB_MODE_CMD ].isCmdRespRdy = FALSE; + + // Blood detection command + bloodLeakEmbModeCmd[ V_EMB_MODE_CMD ].commandASCII = 86; // ASCII for V + bloodLeakEmbModeCmd[ V_EMB_MODE_CMD ].expChar1 = 86; + bloodLeakEmbModeCmd[ V_EMB_MODE_CMD ].expChar2 = NU_EMB_MODE_CMD; + bloodLeakEmbModeCmd[ V_EMB_MODE_CMD ].length = 5; + bloodLeakEmbModeCmd[ V_EMB_MODE_CMD ].timeoutMS = 5 * MS_PER_SECOND; + bloodLeakEmbModeCmd[ V_EMB_MODE_CMD ].commandResp = 0; + bloodLeakEmbModeCmd[ V_EMB_MODE_CMD ].isCmdRespRdy = FALSE; + + // Zero sensor command + bloodLeakEmbModeCmd[ Z_EMB_MODE_CMD ].commandASCII = 90; // ASCII for Z + bloodLeakEmbModeCmd[ Z_EMB_MODE_CMD ].expChar1 = 89; // ASCII for Y + bloodLeakEmbModeCmd[ Z_EMB_MODE_CMD ].expChar2 = NU_EMB_MODE_CMD; + bloodLeakEmbModeCmd[ Z_EMB_MODE_CMD ].length = 1; + bloodLeakEmbModeCmd[ Z_EMB_MODE_CMD ].timeoutMS = 10 * MS_PER_SECOND; + bloodLeakEmbModeCmd[ Z_EMB_MODE_CMD ].commandResp = 0; + bloodLeakEmbModeCmd[ Z_EMB_MODE_CMD ].isCmdRespRdy = FALSE; + + // Zero confirm command + bloodLeakEmbModeCmd[ Q_EMB_MODE_CMD ].commandASCII = 81; // ASCII for Q + bloodLeakEmbModeCmd[ Q_EMB_MODE_CMD ].expChar1 = 80; // ASCII for P + bloodLeakEmbModeCmd[ Q_EMB_MODE_CMD ].expChar2 = 70; // ASCII for F + bloodLeakEmbModeCmd[ Q_EMB_MODE_CMD ].length = 1; + bloodLeakEmbModeCmd[ Q_EMB_MODE_CMD ].timeoutMS = 5 * MS_PER_SECOND; + bloodLeakEmbModeCmd[ Q_EMB_MODE_CMD ].commandResp = 0; + bloodLeakEmbModeCmd[ Q_EMB_MODE_CMD ].isCmdRespRdy = FALSE; + + // Display blood detection command + bloodLeakEmbModeCmd[ D_EMB_MODE_CMD ].commandASCII = 68; + bloodLeakEmbModeCmd[ D_EMB_MODE_CMD ].expChar1 = 68; // ASCII for D + bloodLeakEmbModeCmd[ D_EMB_MODE_CMD ].expChar2 = NU_EMB_MODE_CMD; + bloodLeakEmbModeCmd[ D_EMB_MODE_CMD ].length = 5; + bloodLeakEmbModeCmd[ D_EMB_MODE_CMD ].timeoutMS = 5 * MS_PER_SECOND; + bloodLeakEmbModeCmd[ D_EMB_MODE_CMD ].commandResp = 0; + bloodLeakEmbModeCmd[ D_EMB_MODE_CMD ].isCmdRespRdy = FALSE; + + // Calibrate command + bloodLeakEmbModeCmd[ C_EMB_MODE_CMD ].commandASCII = 67; + bloodLeakEmbModeCmd[ C_EMB_MODE_CMD ].expChar1 = 67; // ASCII for C + bloodLeakEmbModeCmd[ C_EMB_MODE_CMD ].expChar2 = NU_EMB_MODE_CMD; + bloodLeakEmbModeCmd[ C_EMB_MODE_CMD ].length = 4; + bloodLeakEmbModeCmd[ C_EMB_MODE_CMD ].timeoutMS = 5 * MS_PER_SECOND; + bloodLeakEmbModeCmd[ C_EMB_MODE_CMD ].commandResp = 0; + bloodLeakEmbModeCmd[ C_EMB_MODE_CMD ].isCmdRespRdy = FALSE; +} + + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ Index: firmware/App/Drivers/BloodLeakDriver.h =================================================================== diff -u -r9273b79631e50be192556bb9eaffd3f3a22d49d2 -rbc46476a2814d80611ec5ef0c1403415a86e43d5 --- firmware/App/Drivers/BloodLeakDriver.h (.../BloodLeakDriver.h) (revision 9273b79631e50be192556bb9eaffd3f3a22d49d2) +++ firmware/App/Drivers/BloodLeakDriver.h (.../BloodLeakDriver.h) (revision bc46476a2814d80611ec5ef0c1403415a86e43d5) @@ -99,6 +99,7 @@ NUM_OF_EMB_CMDS, } BLOOD_LEAK_EMB_MODE_CMD_T; +#pragma pack(push,1) /// Embedded mode command specifications. typedef struct { @@ -119,6 +120,7 @@ U32 responseLen; U08 responseBuffer[ 5 ]; } BLOOD_LEAK_EMB_MODE_RESP_T; +#pragma pack(pop) // ********** public function prototypes **********