Index: firmware/App/Drivers/ConductivityTeensy.c =================================================================== diff -u -r1ab489b7b273361422832d620165a66951b1f93b -r5c5496009e91f63def2014cbc04a71eada45f8de --- firmware/App/Drivers/ConductivityTeensy.c (.../ConductivityTeensy.c) (revision 1ab489b7b273361422832d620165a66951b1f93b) +++ firmware/App/Drivers/ConductivityTeensy.c (.../ConductivityTeensy.c) (revision 5c5496009e91f63def2014cbc04a71eada45f8de) @@ -21,9 +21,9 @@ #include "sci.h" #include "sys_dma.h" +#include "Comm.h" #include "ConductivityTeensy.h" - #define SCI_RECEIVE_DMA_REQUEST 38 ///< Serial port receive DMA request line. #define SCI_TRANSMIT_DMA_REQUEST 39 ///< Serial port transmit DMA request line. #define COND_WRITE_CMD_BUFFER_LEN 256 ///< Conductivity write command buffer byte length. @@ -39,8 +39,8 @@ static BOOL condWriteCommandInProgress = FALSE; ///< Flag indicating an Conductivity write command is in progress. static BOOL condReadCommandInProgress = FALSE; ///< Flag indicating an Conductivity read command is in progress. static BOOL condBulkWriteAndReadInProgress = FALSE; ///< Flag indicating an Conductivity bulk write and read command are in progress. -static BOOL condWriteCommandResponseReceived = FALSE; ///< Flag indicating a response to an Conductivity write command has been received. -static BOOL condReadCommandResponseReceived = FALSE; ///< Flag indicating a response to an Conductivity read command has been received. +static BOOL condWriteCmdRspnsRcvd = FALSE; ///< Flag indicating a response to an Conductivity write command has been received. +static BOOL condReadCmdRspnsRcvd = FALSE; ///< Flag indicating a response to an Conductivity read command has been received. // Conductivity comm buffers static U08 condWriteCmdBuffer[ COND_WRITE_CMD_BUFFER_LEN ]; ///< Conductivity write command buffer. Holds the next Conductivity write command to be transmitted. @@ -317,8 +317,8 @@ * indicating pending response from Conductivity is completed. * @details \b Inputs: none * @details \b Outputs: condReceiptCounter, condWriteCommandInProgress, - * condWriteCommandResponseReceived, condReadCommandInProgress, - * condReadCommandResponseReceived, condBulkWriteAndReadInProgress + * condWriteCmdRspnsRcvd, condReadCommandInProgress, + * condReadCmdRspnsRcvd, condBulkWriteAndReadInProgress * @return none *************************************************************************/ void signalConductivityReceiptCompleted( void ) @@ -328,12 +328,12 @@ if ( TRUE == condWriteCommandInProgress ) { condWriteCommandInProgress = FALSE; - condWriteCommandResponseReceived = TRUE; + condWriteCmdRspnsRcvd = TRUE; } else if ( TRUE == condReadCommandInProgress ) { condReadCommandInProgress = FALSE; - condReadCommandResponseReceived = TRUE; + condReadCmdRspnsRcvd = TRUE; } // See if we want to follow up with a bulk read command @@ -621,30 +621,28 @@ } else { - const U08* baseCmd = teensyCmd[ cmdIndex ]; + const U08* baseCmd = (const U08*)teensyCmd[ cmdIndex ]; // Clear the write buffer before writing memset( condWriteCmdBuffer, 0, COND_WRITE_CMD_BUFFER_LEN ); // Format command with optional parameter - if ( ( NULL != param ) && ( strlen( param ) > 0 ) ) + if ( ( NULL != param ) && ( strlen( (const char*)param ) > 0 ) ) { - U16 written = snprintf( (U08*)condWriteCmdBuffer, + U16 written = snprintf( (char*)condWriteCmdBuffer, COND_WRITE_CMD_BUFFER_LEN, "%s %s", - baseCmd, - param ); + (const char*)baseCmd, + (const char*)param ); - // Check if snprintf succeeded and did not overflow success = ( written > 0 ) && ( written < COND_WRITE_CMD_BUFFER_LEN ); } else { - // No parameter: write only the command - U16 written = snprintf( (U08*)condWriteCmdBuffer, + U16 written = snprintf( (char*)condWriteCmdBuffer, COND_WRITE_CMD_BUFFER_LEN, "%s", - baseCmd ); + (const char*)baseCmd ); success = ( written > 0 ) && ( written < COND_WRITE_CMD_BUFFER_LEN ); } @@ -671,18 +669,17 @@ } else { - const U08* baseCmd = teensyCmd[ cmdIndex ]; + const U08* baseCmd = (const U08*)teensyCmd[ cmdIndex ]; // Clear the read buffer before writing memset( condReadCmdBuffer, 0, COND_READ_CMD_BUFFER_LEN ); // Write only the command string (no parameters allowed) - U16 written = snprintf( (U08*)condReadCmdBuffer, + U16 written = snprintf( (char*)condReadCmdBuffer, COND_READ_CMD_BUFFER_LEN, "%s", - baseCmd ); + (const char*)baseCmd ); - // Check if snprintf succeeded and did not overflow success = ( written > 0 ) && ( written < COND_READ_CMD_BUFFER_LEN ); } @@ -733,35 +730,41 @@ return state; } -static CONDUCTIVITY_COMM_STATE_T sendCmd_updateEEPROMdata(CONDUCTIVITY_EEPROM_DATA_T eepromData) +static CONDUCTIVITY_COMM_STATE_T sendCmd_updateEEPROMdata( CONDUCTIVITY_EEPROM_DATA_T eepromData ) { CONDUCTIVITY_COMM_STATE_T state = COND_COMM_STATE_SEND_CMD_UPDATE_EEPROM_DATA; // Format EEPROM data into a string - U08 paramStr[256]; - U16 offset = 0; - U16 i = 0; + U08 paramStr[256]; + U16 offset = 0; + U16 i = 0; - for ( i = 0; i < DOUBLE_COUNT; ++i ) - { - offset += snprintf( paramStr + offset, sizeof(paramStr) - offset, "%.6f,", eepromData.doubleValue[i] ); - } + for ( i = 0; i < DOUBLE_COUNT; ++i ) + { + offset += snprintf( (char*)(paramStr + offset), + sizeof(paramStr) - offset, + "%.6f,", + eepromData.doubleValue[i] ); + } - for ( i = 0; i < FLOAT_COUNT; ++i ) - { - offset += snprintf( paramStr + offset, sizeof(paramStr) - offset, "%.6f,", eepromData.floatValue[i] ); - } + for ( i = 0; i < FLOAT_COUNT; ++i ) + { + offset += snprintf( (char*)(paramStr + offset), + sizeof(paramStr) - offset, + "%.6f,", + eepromData.floatValue[i] ); + } - // Remove trailing comma if needed - if ( offset > 0 && paramStr[offset - 1] == ',' ) - { - paramStr[offset - 1] = '\0'; - } + // Remove trailing comma if needed + if ( ( offset > 0 ) && ( paramStr[ offset - 1 ] == ',' ) ) + { + paramStr[ offset - 1 ] = '\0'; + } - if ( FALSE == sendTeensyWriteCmd( TEENSY_CMD_UPDATE_EEPROM_DATA, paramStr ) ) - { - // Handle error - } + if ( FALSE == sendTeensyWriteCmd( TEENSY_CMD_UPDATE_EEPROM_DATA, paramStr ) ) + { + // Handle error + } return state; } @@ -802,7 +805,8 @@ // Format measurement settings into a string U08 paramStr[128]; - snprintf( paramStr, sizeof(paramStr), "%.3f,%.3f,%.3f,%u,%u,%u,%u", + + snprintf( (char*)paramStr, sizeof(paramStr), "%.3f,%.3f,%.3f,%u,%u,%u,%u", measurementSettings.SinFreq, measurementSettings.DacVoltPP, measurementSettings.BiasVolt, @@ -905,13 +909,12 @@ static void sendCmd_selectSensor( TEENSY_SENSOR_INDEX_T sensorNum ) { U08 paramStr[8]; - snprintf( paramStr, sizeof(paramStr), "%d", sensorNum ); + snprintf( (char*)paramStr, sizeof(paramStr), "%d", sensorNum ); - if ( FALSE == sendTeensyWriteCmd( TEENSY_CMD_SELECT_SENSOR, paramStr ) ) - { - // Handle error - } - + if ( FALSE == sendTeensyWriteCmd( TEENSY_CMD_SELECT_SENSOR, paramStr ) ) + { + // Handle error + } } static void rcvRspns_selectSensor( TEENSY_SENSOR_INDEX_T sensorNum ) @@ -938,8 +941,8 @@ static CONDUCTIVITY_INIT_STATUS_T getInitStatus( void ) { - sendInitStatusCommand(); - receiveInitStatusResponse(); + sendCmd_getInitStatus(); + rcvRspns_getInitStatus(); return conductivityInitStatus; }