Index: firmware/App/Drivers/ConductivityTeensy.c =================================================================== diff -u -r9ccc651bf491c37bc202ad8d80f0e4063523320d -r73f8f36e415f20da8ad64b13d71183c047fb4f50 --- firmware/App/Drivers/ConductivityTeensy.c (.../ConductivityTeensy.c) (revision 9ccc651bf491c37bc202ad8d80f0e4063523320d) +++ firmware/App/Drivers/ConductivityTeensy.c (.../ConductivityTeensy.c) (revision 73f8f36e415f20da8ad64b13d71183c047fb4f50) @@ -90,19 +90,20 @@ static CONDUCTIVITY_INIT_STATUS_T conductivityInitStatus; static CONDUCTIVITY_UPDATE_EEPROM_STATUS_T condUpdateEEPROMstatus; -static CONDUCTIVITY_UPDATE_MST_STATUS_T condUpdateMeasurementSettings; +static CONDUCTIVITY_UPDATE_MST_STATUS_T condUpdateSettingStatus; static CONDUCTIVITY_EEPROM_DATA_T conductivityEEPROMdata; static CONDUCTIVITY_MEASUREMENT_SETTINGS_T conductivityMeasurementSettings; static CONDUCTIVITY_SENSOR_DATA_T rawConductivityValues[ MAX_TEENSY_SENSOR ]; static CONDUCTIVITY_CALCULATED_MEASUREMENTS_T calculatedMeasurement[ MAX_TEENSY_SENSOR ]; static CONDUCTIVITY_COEFFICIENTS_T conductivityCoeff[MAX_TEENSY_SENSOR]; static const CONDUCTIVITY_CMD_DATA_T teensyCmdMap[] = { +// Command Index / Sub state Command Length of expected response data { TEENSY_CMD_INIT_SENSOR , (U08*)"a" , RX_SIZE_INIT_SENSOR }, { TEENSY_CMD_GET_INIT_STATUS , (U08*)"l" , RX_SIZE_GET_INIT_STATUS }, - { TEENSY_CMD_UPDATE_EEPROM_DATA , (U08*)"save", RX_SIZE_UPDATE_EEPROM }, + { TEENSY_CMD_UPDATE_EEPROM_DATA , (U08*)"upe" , RX_SIZE_UPDATE_EEPROM }, { TEENSY_CMD_GET_EEPROM_DATA , (U08*)"e" , RX_SIZE_GET_EEPROM }, - { TEENSY_CMD_UPDATE_MEASUREMENT_SETTINGS , (U08*)"cfg" , RX_SIZE_UPDATE_MEASUREMENT_SETTINGS }, + { TEENSY_CMD_UPDATE_MEASUREMENT_SETTINGS , (U08*)"mst" , RX_SIZE_UPDATE_MEASUREMENT_SETTINGS }, { TEENSY_CMD_GET_MEASUREMENT_SETTINGS , (U08*)"k" , RX_SIZE_GET_MEASUREMENT_SETTNGS }, { TEENSY_CMD_GET_MEASUREMENT , (U08*)"m" , RX_SIZE_GET_MEASUREMENT }, { TEENSY_CMD_STOP_MEASUREMENT , (U08*)"n" , RX_SIZE_STOP_MEASUREMENT }, @@ -111,6 +112,16 @@ { TEENSY_CMD_GET_SINGLE_MEASUREMENT , (U08*)"h" , RX_SIZE_GET_SINGLE_MEASUREMENT }, }; +static const U08* condSettingsParam = { + "sinfreq", + "dacpp", + "bias", + "rtia", + "pga", + "dftnum", + "avgnum" + }; + // Conductivity cmd data structs TEENSY_SENSOR_INDEX_T currentSelectedSensor; CONDUCTIVITY_EEPROM_DATA_T eePromDataTX; @@ -140,9 +151,9 @@ static void setupConductivityDMAForReadResp( U32 bytes2Receive ); static void startConductivityDMAReceiptOfReadResp( void ); -static CONDUCTIVITY_PARSE_STATUS parseMeasurementSettings(const U32 *buffer, U32 len ); -static CONDUCTIVITY_PARSE_STATUS parseEEPROMdata( const U32 *buffer, U32 len ); -static CONDUCTIVITY_PARSE_STATUS parseConductivityMeasurements( const U32 *buffer, U32 len ); +static CONDUCTIVITY_PARSE_STATUS parseMeasurementSettings(const U08 *buffer, U32 len ); +static CONDUCTIVITY_PARSE_STATUS parseEEPROMdata( const U08 *buffer, U32 len ); +static CONDUCTIVITY_PARSE_STATUS parseConductivityMeasurements( const U08 *buffer, U32 len ); static BOOL txTeensyWriteCmd( TEENSY_CMD_INDEX_T cmdIndex, const U08* param ); static BOOL rxTeensyReadRsp( TEENSY_CMD_INDEX_T cmdIndex ); @@ -758,7 +769,7 @@ * len - Length of the input data. * @return CONDUCTIVITY_PARSE_STATUS to tell if parsing was successful or not. *************************************************************************/ -static CONDUCTIVITY_PARSE_STATUS parseMeasurementSettings(const U32 *buffer, U32 len) +static CONDUCTIVITY_PARSE_STATUS parseMeasurementSettings(const U08 *buffer, U32 len) { CONDUCTIVITY_PARSE_STATUS parseStatus = CONDUCTIVITY_PARSE_NONE; U32 expectedDataLength = sizeof(CONDUCTIVITY_MEASUREMENT_SETTINGS_T); @@ -792,7 +803,7 @@ * len - Length of the input data. * @return CONDUCTIVITY_PARSE_STATUS to tell if parsing was successful or not. *************************************************************************/ -static CONDUCTIVITY_PARSE_STATUS parseEEPROMdata(const U32 *buffer, U32 len) +static CONDUCTIVITY_PARSE_STATUS parseEEPROMdata(const U08 *buffer, U32 len) { CONDUCTIVITY_PARSE_STATUS parseStatus = CONDUCTIVITY_PARSE_NONE; U32 expectedDataLength = sizeof(CONDUCTIVITY_EEPROM_DATA_T); @@ -827,7 +838,7 @@ * len - Length of the input data. * @return CONDUCTIVITY_PARSE_STATUS to tell if parsing was successful or not. *************************************************************************/ -static CONDUCTIVITY_PARSE_STATUS parseConductivityMeasurements(const U32 *buffer, U32 len) +static CONDUCTIVITY_PARSE_STATUS parseConductivityMeasurements(const U08 *buffer, U32 len) { CONDUCTIVITY_PARSE_STATUS parseStatus = CONDUCTIVITY_PARSE_NONE; U32 expectedDataLength = sizeof(CONDUCTIVITY_SENSOR_DATA_T); @@ -904,7 +915,7 @@ { written = snprintf( (char*)condTxBuffer, COND_TX_BUFFER_LEN, - "%s %s", + "%s,%s", (const char*)baseCmd, (const char*)param ); } @@ -964,10 +975,13 @@ { // Get the current time condResponseTime = getMSTimerCount(); + + // Go to receive state to receive the init status state = COND_COMM_STATE_RX; } else { + // Go to failed state state = COND_COMM_STATE_FAILED; } @@ -978,16 +992,22 @@ static CONDUCTIVITY_COMM_STATE_T rxInitSensor( void ) { CONDUCTIVITY_COMM_STATE_T state = COND_COMM_STATE_RX; - CONDUCTIVITY_INIT_STATUS_T initStatusFirstByte = CONDUCTIVITY_INIT_STATUS_FAILED; // set to fail for testing - CONDUCTIVITY_INIT_STATUS_T initStatusSecondByte = CONDUCTIVITY_INIT_STATUS_FAILED; // if data populates + CONDUCTIVITY_INIT_STATUS_T initStatusInProgress = CONDUCTIVITY_INIT_STATUS_FAILED; // set to fail for testing + CONDUCTIVITY_INIT_STATUS_T initStatusInitialized = CONDUCTIVITY_INIT_STATUS_FAILED; // if data populates BOOL recvComplete = rxTeensyReadRsp( TEENSY_CMD_INIT_SENSOR ); if ( TRUE == recvComplete ) { - initStatusFirstByte = (CONDUCTIVITY_INIT_STATUS_T)condRxBuffer[0]; - initStatusSecondByte = (CONDUCTIVITY_INIT_STATUS_T)condRxBuffer[1]; + // Reset the timer for next use. + condResponseTime = 0; + // Read the data from the receive buffer + initStatusInProgress = (CONDUCTIVITY_INIT_STATUS_T)condRxBuffer[0]; + initStatusInitialized = (CONDUCTIVITY_INIT_STATUS_T)condRxBuffer[1]; - switch(initStatusSecondByte) + // Store the init status + conductivityInitStatus = initStatusInitialized; + + switch(conductivityInitStatus) { case CONDUCTIVITY_INIT_STATUS_UNITIALIZED: break; @@ -1008,8 +1028,13 @@ } else if ( TRUE == didTimeout( condResponseTime, COND_STATUS_TIMEOUT_MS ) ) { + // Go to failed state state = COND_COMM_STATE_FAILED; } + else + { + // Do Nothing. Wait until we either receive a response OR timeout happens. + } return state; } @@ -1021,10 +1046,15 @@ // If the get init status cmd was sent successfully if ( TRUE == txTeensyWriteCmd( TEENSY_CMD_GET_INIT_STATUS, NULL ) ) { + // Get the current time + condResponseTime = getMSTimerCount(); + + // Go to receive state to receive the init status state = COND_COMM_STATE_RX; } else { + // Go to failed state state = COND_COMM_STATE_FAILED; } @@ -1034,35 +1064,46 @@ static CONDUCTIVITY_COMM_STATE_T rxGetInitStatus( void ) { CONDUCTIVITY_COMM_STATE_T state = COND_COMM_STATE_RX; - CONDUCTIVITY_INIT_STATUS_T initStatus = CONDUCTIVITY_INIT_STATUS_UNITIALIZED; - BOOL recvComplete = rxTeensyReadRsp( TEENSY_CMD_INIT_SENSOR ); + // Check if a response is received in the RX buffer + BOOL recvComplete = rxTeensyReadRsp( TEENSY_CMD_GET_INIT_STATUS ); if ( TRUE == recvComplete ) { - initStatus = (CONDUCTIVITY_INIT_STATUS_T)condRxBuffer[0]; + // Reset the timer for next use. + condResponseTime = 0; + + // Read the data from the receive buffer + memcpy(&conductivityInitStatus, &condRxBuffer, teensyCmdMap[ TEENSY_CMD_GET_INIT_STATUS ].rxSize); +// conductivityInitStatus = (CONDUCTIVITY_INIT_STATUS_T)condRxBuffer[0]; + + switch(conductivityInitStatus) + { + case CONDUCTIVITY_INIT_STATUS_UNITIALIZED: + break; + + case CONDUCTIVITY_INIT_STATUS_IN_PROGRESS: + state = COND_COMM_STATE_IDLE; + break; + + case CONDUCTIVITY_INIT_STATUS_INITIALIZED: + state = COND_COMM_STATE_IDLE; + break; + + case CONDUCTIVITY_INIT_STATUS_FAILED: + default: + state = COND_COMM_STATE_FAILED; + break; + } } + else if ( TRUE == didTimeout( condResponseTime, COND_STATUS_TIMEOUT_MS ) ) { + // Go to failed state state = COND_COMM_STATE_FAILED; } - - switch(initStatus) + else { - case CONDUCTIVITY_INIT_STATUS_UNITIALIZED: - break; - - case CONDUCTIVITY_INIT_STATUS_IN_PROGRESS: - state = COND_COMM_STATE_IDLE; - break; - - case CONDUCTIVITY_INIT_STATUS_INITIALIZED: - state = COND_COMM_STATE_IDLE; - break; - - case CONDUCTIVITY_INIT_STATUS_FAILED: - default: - state = COND_COMM_STATE_FAILED; - break; + // Do Nothing. Wait until we either receive a response OR timeout happens. } return state; @@ -1077,6 +1118,7 @@ U16 offset = 0; U16 i = 0; + // Pack the command and EEPROM data for ( i = 0; i < DOUBLE_COUNT; ++i ) { offset += snprintf( (char*)(paramStr + offset), @@ -1099,12 +1141,18 @@ paramStr[ offset - 1 ] = '\0'; } + // Transmit the command and the EEPROM data and check if it was sent successfully if ( TRUE == txTeensyWriteCmd( TEENSY_CMD_UPDATE_EEPROM_DATA, paramStr ) ) { + // Get the current time + condResponseTime = getMSTimerCount(); + + // Go to receive state to receive the EEPROM update status state = COND_COMM_STATE_RX; } else { + // Go to failed state state = COND_COMM_STATE_FAILED; } @@ -1114,22 +1162,50 @@ static CONDUCTIVITY_COMM_STATE_T rxUpdateEEPROMdata( void ) { CONDUCTIVITY_COMM_STATE_T state = COND_COMM_STATE_RX; - condUpdateEEPROMstatus = ( CONDUCTIVITY_UPDATE_EEPROM_STATUS_T )condTxBuffer[ 0 ]; - state = COND_COMM_STATE_IDLE; + + // Check if a response is received in the RX buffer + BOOL recvComplete = rxTeensyReadRsp( TEENSY_CMD_UPDATE_EEPROM_DATA ); + if ( TRUE == recvComplete ) + { + // Reset the timer for next use. + condResponseTime = 0; + + // Read the data from the receive buffer + memcpy(&condUpdateEEPROMstatus, &condRxBuffer, teensyCmdMap[ TEENSY_CMD_UPDATE_EEPROM_DATA ].rxSize); +// condUpdateEEPROMstatus = (CONDUCTIVITY_UPDATE_EEPROM_STATUS_T)condRxBuffer[0]; + + // Go to the idle state to execute next cmd in the queue + state = COND_COMM_STATE_IDLE; + } + else if ( TRUE == didTimeout( condResponseTime, COND_STATUS_TIMEOUT_MS ) ) + { + // Go to failed state + state = COND_COMM_STATE_FAILED; + } + else + { + // Do Nothing. Wait until we either receive a response OR timeout happens. + } + return state; } static CONDUCTIVITY_COMM_STATE_T txGetEEPROMdata( void ) { CONDUCTIVITY_COMM_STATE_T state = COND_COMM_STATE_TX; - if ( TRUE == rxTeensyReadRsp( TEENSY_CMD_GET_EEPROM_DATA ) ) + // If the get EEPROM data cmd was sent successfully + if ( TRUE == txTeensyWriteCmd( TEENSY_CMD_GET_EEPROM_DATA, NULL ) ) { - state = COND_COMM_STATE_RX; + // Get the current time + condResponseTime = getMSTimerCount(); + // Go to receive state to receive the EEPROM data + state = COND_COMM_STATE_RX; } else { + // Go to failed state state = COND_COMM_STATE_FAILED; } @@ -1139,57 +1215,144 @@ static CONDUCTIVITY_COMM_STATE_T rxGetEEPROMdata( void ) { CONDUCTIVITY_COMM_STATE_T state = COND_COMM_STATE_RX; - CONDUCTIVITY_PARSE_STATUS parseStatus = parseEEPROMdata( condRxBuffer, COND_RX_BUFFER_LEN ); + CONDUCTIVITY_PARSE_STATUS parseStatus = CONDUCTIVITY_PARSE_NONE; state = COND_COMM_STATE_IDLE; + + // Check if a response is received in the RX buffer + BOOL recvComplete = rxTeensyReadRsp( TEENSY_CMD_GET_EEPROM_DATA ); + if ( TRUE == recvComplete ) + { + // Reset the timer for next use. + condResponseTime = 0; + + // Read the data from the receive buffer + memcpy(&conductivityEEPROMdata, &condRxBuffer, teensyCmdMap[ TEENSY_CMD_GET_EEPROM_DATA ].rxSize); +// parseStatus = parseEEPROMdata( condRxBuffer, COND_RX_BUFFER_LEN ); + + // Check if parsing was done successfully + if(CONDUCTIVITY_PARSE_SUCCESS == parseStatus) + { + // Go to the idle state to execute next cmd in the queue + state = COND_COMM_STATE_IDLE; + } + else + { + // Go to failed state + state = COND_COMM_STATE_FAILED; + } + } + else if ( TRUE == didTimeout( condResponseTime, COND_DATA_TIMEOUT_MS ) ) + { + // Go to failed state + state = COND_COMM_STATE_FAILED; + } + else + { + // Do Nothing. Wait until we either receive a response OR timeout happens. + } + return state; } static CONDUCTIVITY_COMM_STATE_T txUpdateMeasurementSettings( CONDUCTIVITY_MEASUREMENT_SETTINGS_T measurementSettings ) { CONDUCTIVITY_COMM_STATE_T state = COND_COMM_STATE_TX; + U08 paramStr[64]; + U08 i = 0; + // Array of parameter values as strings + for ( i = 0; i < MAX_CONDUCTIVITY_MST_PARAM_IDX; i++) + { + switch (i) + { + case CONDUCTIVITY_MST_PARAM_IDX_SINFREQ: + snprintf(paramStr, sizeof(paramStr), "%s,%.3f", condSettingsParam[i], measurementSettings.SinFreq); + break; + case CONDUCTIVITY_MST_PARAM_IDX_DACPP: + snprintf(paramStr, sizeof(paramStr), "%s,%.3f", condSettingsParam[i], measurementSettings.DacVoltPP); + break; + case CONDUCTIVITY_MST_PARAM_IDX_BIAS: + snprintf(paramStr, sizeof(paramStr), "%s,%.3f", condSettingsParam[i], measurementSettings.BiasVolt); + break; + case CONDUCTIVITY_MST_PARAM_IDX_RTIA: + snprintf(paramStr, sizeof(paramStr), "%s,%u", condSettingsParam[i], measurementSettings.HstiaRtiaSel); + break; + case CONDUCTIVITY_MST_PARAM_IDX_PGA: + snprintf(paramStr, sizeof(paramStr), "%s,%u", condSettingsParam[i], measurementSettings.AdcPgaGain); + break; + case CONDUCTIVITY_MST_PARAM_IDX_DFTNUM: + snprintf(paramStr, sizeof(paramStr), "%s,%u", condSettingsParam[i], measurementSettings.DftNum); + break; + case CONDUCTIVITY_MST_PARAM_IDX_AVGNUM: + snprintf(paramStr, sizeof(paramStr), "%s,%u", condSettingsParam[i], measurementSettings.ADCAvgNum); + break; + } - // Format measurement settings into a string - U08 paramStr[128]; + // If update measurement settings cmd was sent successfully + if ( TRUE == txTeensyWriteCmd( TEENSY_CMD_UPDATE_MEASUREMENT_SETTINGS, paramStr ) ) + { + // Get the current time + condResponseTime = getMSTimerCount(); - snprintf( (char*)paramStr, sizeof(paramStr), "%.3f,%.3f,%.3f,%u,%u,%u,%u", - measurementSettings.SinFreq, - measurementSettings.DacVoltPP, - measurementSettings.BiasVolt, - measurementSettings.HstiaRtiaSel, - measurementSettings.AdcPgaGain, - measurementSettings.DftNum, - measurementSettings.ADCAvgNum ); - - if ( TRUE == txTeensyWriteCmd( TEENSY_CMD_UPDATE_MEASUREMENT_SETTINGS, paramStr ) ) - { - state = COND_COMM_STATE_RX; + // Go to receive state to receive the EEPROM data + state = COND_COMM_STATE_RX; + } + else + { + // Go to failed state + state = COND_COMM_STATE_FAILED; + } } - else - { - state = COND_COMM_STATE_FAILED; - } return state; } static CONDUCTIVITY_COMM_STATE_T rxUpdateMeasurementSettings( void ) { CONDUCTIVITY_COMM_STATE_T state = COND_COMM_STATE_RX; - condUpdateMeasurementSettings = ( CONDUCTIVITY_UPDATE_MST_STATUS_T )condTxBuffer[0]; - state = COND_COMM_STATE_IDLE; + + // Check if a response is received in the RX buffer + BOOL recvComplete = rxTeensyReadRsp( TEENSY_CMD_UPDATE_MEASUREMENT_SETTINGS ); + if ( TRUE == recvComplete ) + { + // Reset the timer for next use. + condResponseTime = 0; + + // Read the data from the receive buffer + memcpy(&condUpdateSettingStatus, &condRxBuffer, teensyCmdMap[ TEENSY_CMD_UPDATE_MEASUREMENT_SETTINGS ].rxSize); +// condUpdateSettingStatus = ( CONDUCTIVITY_UPDATE_MST_STATUS_T )condTxBuffer[0]; + + // Go to the idle state to execute next cmd in the queue + state = COND_COMM_STATE_IDLE; + } + else if ( TRUE == didTimeout( condResponseTime, COND_STATUS_TIMEOUT_MS ) ) + { + // Go to failed state + state = COND_COMM_STATE_FAILED; + } + else + { + // Do Nothing. Wait until we either receive a response OR timeout happens. + } + return state; } static CONDUCTIVITY_COMM_STATE_T txGetMeasurementSettings( void ) { CONDUCTIVITY_COMM_STATE_T state = COND_COMM_STATE_TX; - if ( TRUE == rxTeensyReadRsp( TEENSY_CMD_GET_MEASUREMENT_SETTINGS ) ) + // If get measurement settings cmd was sent successfully + if ( TRUE == txTeensyWriteCmd( TEENSY_CMD_GET_MEASUREMENT_SETTINGS, NULL ) ) { + // Get the current time + condResponseTime = getMSTimerCount(); + + // Go to receive state to receive the EEPROM data state = COND_COMM_STATE_RX; } else { + // Go to failed state state = COND_COMM_STATE_FAILED; } @@ -1199,22 +1362,61 @@ static CONDUCTIVITY_COMM_STATE_T rxGetMeasurementSettings( void ) { CONDUCTIVITY_COMM_STATE_T state = COND_COMM_STATE_RX; - CONDUCTIVITY_PARSE_STATUS parseStatus = parseMeasurementSettings( condRxBuffer, COND_RX_BUFFER_LEN ); + CONDUCTIVITY_PARSE_STATUS parseStatus = CONDUCTIVITY_PARSE_NONE; state = COND_COMM_STATE_IDLE; + // Check if a response is received in the RX buffer + BOOL recvComplete = rxTeensyReadRsp( TEENSY_CMD_GET_MEASUREMENT_SETTINGS ); + if ( TRUE == recvComplete ) + { + // Reset the timer for next use. + condResponseTime = 0; + + // Read the data from the receive buffer + memcpy(&conductivityMeasurementSettings, &condRxBuffer, teensyCmdMap[ TEENSY_CMD_GET_MEASUREMENT_SETTINGS ].rxSize); +// parseStatus = parseMeasurementSettings( condRxBuffer, COND_RX_BUFFER_LEN ); + + // Check if parsing was done successfully + if(CONDUCTIVITY_PARSE_SUCCESS == parseStatus) + { + // Go to the idle state to execute next cmd in the queue + state = COND_COMM_STATE_IDLE; + } + else + { + // Go to failed state + state = COND_COMM_STATE_FAILED; + } + } + else if ( TRUE == didTimeout( condResponseTime, COND_DATA_TIMEOUT_MS ) ) + { + // Go to failed state + state = COND_COMM_STATE_FAILED; + } + else + { + // Do Nothing. Wait until we either receive a response OR timeout happens. + } + return state; } static CONDUCTIVITY_COMM_STATE_T txGetMeasurements( void ) { CONDUCTIVITY_COMM_STATE_T state = COND_COMM_STATE_TX; - if ( TRUE == rxTeensyReadRsp( TEENSY_CMD_GET_MEASUREMENT ) ) + // If get measurement settings cmd was sent successfully + if ( TRUE == txTeensyWriteCmd( TEENSY_CMD_GET_MEASUREMENT, NULL ) ) { + // Get the current time + condResponseTime = getMSTimerCount(); + + // Go to receive state to receive the measurement data state = COND_COMM_STATE_RX; } else { + // Go to failed state state = COND_COMM_STATE_FAILED; } return state; @@ -1225,6 +1427,39 @@ CONDUCTIVITY_COMM_STATE_T state = COND_COMM_STATE_RX; CONDUCTIVITY_PARSE_STATUS parseStatus = parseConductivityMeasurements( condRxBuffer, COND_RX_BUFFER_LEN ); state = COND_COMM_STATE_IDLE; + + // Check if a response is received in the RX buffer + BOOL recvComplete = rxTeensyReadRsp( TEENSY_CMD_GET_MEASUREMENT ); + if ( TRUE == recvComplete ) + { + // Get the time stamp for next sensor packet + condResponseTime = getMSTimerCount(); + + // Read the data from the receive buffer + CONDUCTIVITY_PARSE_STATUS parseStatus = parseConductivityMeasurements( condRxBuffer, COND_RX_BUFFER_LEN ); + + // Check if parsing was done successfully + if(CONDUCTIVITY_PARSE_SUCCESS == parseStatus) + { + // Go to the idle state to execute next cmd in the queue + state = COND_COMM_STATE_IDLE; + } + else + { + // Go to failed state + state = COND_COMM_STATE_FAILED; + } + } + else if ( TRUE == didTimeout( condResponseTime, COND_DATA_TIMEOUT_MS ) ) + { + // Go to failed state + state = COND_COMM_STATE_FAILED; + } + else + { + // Do Nothing. Wait until we either receive a response OR timeout happens. + } + return state; } Index: firmware/App/Drivers/ConductivityTeensy.h =================================================================== diff -u -r9ccc651bf491c37bc202ad8d80f0e4063523320d -r73f8f36e415f20da8ad64b13d71183c047fb4f50 --- firmware/App/Drivers/ConductivityTeensy.h (.../ConductivityTeensy.h) (revision 9ccc651bf491c37bc202ad8d80f0e4063523320d) +++ firmware/App/Drivers/ConductivityTeensy.h (.../ConductivityTeensy.h) (revision 73f8f36e415f20da8ad64b13d71183c047fb4f50) @@ -84,21 +84,34 @@ { COND_UPDATE_EEPROM_STATUS_UNITIALIZED = 0, ///< The initialization process has not started. COND_UPDATE_EEPROMSTATUS_IN_PROGRESS, ///< The initialization process has started. - COND_UPDATE_EEPROM_STATUS_INITIALIZED, ///< Initialization process completed and all the sensors were initialized successfully. - COND_UPDATE_EEPROM_STATUS_FAILED ///< Initialization process completed but one or more sensor was not initialized properly. + COND_UPDATE_EEPROM_STATUS_INITIALIZED, ///< Initialization process completed and all the sensors were initialized successfully. + COND_UPDATE_EEPROM_STATUS_FAILED ///< Initialization process completed but one or more sensor was not initialized properly. }CONDUCTIVITY_UPDATE_EEPROM_STATUS_T; // Update Measurement Settings Status typedef enum Update_mst_Status { - COND_MST_STATUS_ERR_UNRECOGNIZED_PARAM = 0, // Invalid parameter was passed with the command - COND_MST_STATUS_ERR_UPDATED_TO_DEFAULT_TIA, // Invalid value of "rtia" was passed with the command. So it was updated to its default value. - COND_MST_STATUS_ERR_UPDATED_TO_DEFAULT_PGA, // Invalid value of "pga" was passed with the command. So it was updated to its default value. - COND_MST_STATUS_ERR_UPDATED_TO_DEFAULT_DFT_NUM, // Invalid value of "dftnum" was passed with the command. So it was updated to its default value. - COND_MST_STATUS_ERR_UPDATED_TO_DEFAULT_AVG_NUM, // Invalid value of "avgnum" was passed with the command. So it was updated to its default value. + COND_MST_STATUS_ERR_UNRECOGNIZED_PARAM = 0, ///< Invalid parameter was passed with the command + COND_MST_STATUS_ERR_UPDATED_TO_DEFAULT_TIA, ///< Invalid value of "rtia" was passed with the command. So it was updated to its default value. + COND_MST_STATUS_ERR_UPDATED_TO_DEFAULT_PGA, ///< Invalid value of "pga" was passed with the command. So it was updated to its default value. + COND_MST_STATUS_ERR_UPDATED_TO_DEFAULT_DFT_NUM, ///< Invalid value of "dftnum" was passed with the command. So it was updated to its default value. + COND_MST_STATUS_ERR_UPDATED_TO_DEFAULT_AVG_NUM, ///< Invalid value of "avgnum" was passed with the command. So it was updated to its default value. COND_MST_STATUS_SUCCESS -}CONDUCTIVITY_UPDATE_MST_STATUS_T;; +}CONDUCTIVITY_UPDATE_MST_STATUS_T; +// Update Measurement Settings Status +typedef enum mst_param_idx +{ + CONDUCTIVITY_MST_PARAM_IDX_SINFREQ = 0, ///< SinFreq : Frequency of excitation signal + CONDUCTIVITY_MST_PARAM_IDX_DACPP, ///< DacVoltPP : DAC output voltage in mV peak to peak. Maximum value is 800mVpp. Peak to peak voltage + CONDUCTIVITY_MST_PARAM_IDX_BIAS, ///< BiasVolt : The excitation signal is DC+AC. This parameter decides the DC value in mV unit. 0.0mV means no DC bias. + CONDUCTIVITY_MST_PARAM_IDX_RTIA, ///< HstiaRtiaSel : Valid param values ( 0, 1, 2, 3, 4, 5, 6, 7 ) + CONDUCTIVITY_MST_PARAM_IDX_PGA, ///< AdcPgaGain : Valid param values ( 1, 1.5, 2, 4, 9 ) i.e interpreted as ( 0, 1, 2, 3, 4 ) respectively in Teensy. + CONDUCTIVITY_MST_PARAM_IDX_DFTNUM, ///< DftNum : DFT number Valid param values ( 4096, 2048, 1024, 512, 256 ) i.e interpreted as ( 10, 9, 8, 7, 6 ) respectively in Teensy. + CONDUCTIVITY_MST_PARAM_IDX_AVGNUM, ///< ADCAvgNum : Valid param values ( 2, 4, 8, 16 )i.e interpreted as ( 0, 1, 2, 3 ) respectively in Teensy. + MAX_CONDUCTIVITY_MST_PARAM_IDX ///< Total number of Measurement settings parameters +}CONDUCTIVITY_MST_PARAM_IDX_T; + typedef struct { F64 A0;