Vybhav Kadaba
/
EV-PRO-MW1001_dec12
MWARE-1930 fixed
Diff: src/admw_1001.c
- Revision:
- 36:54e2418e7620
- Parent:
- 33:df7a00f1b8e1
- Child:
- 41:df78b7d7b675
--- a/src/admw_1001.c Tue Nov 19 11:28:40 2019 +0000 +++ b/src/admw_1001.c Tue Nov 19 12:10:45 2019 +0000 @@ -926,13 +926,12 @@ READ_REG_U8(hDevice, channelCountReg.VALUE8, CORE_CHANNEL_COUNTn(chId)); READ_REG_U32(hDevice, sensorDetailsReg.VALUE32, CORE_SENSOR_DETAILSn(chId)); - if (channelCountReg.Channel_Enable && !sensorDetailsReg.Do_Not_Publish) { - ADMW_CORE_Sensor_Type_t sensorTypeReg; + if (channelCountReg.Channel_Enable && !sensorDetailsReg.Do_Not_Publish) + { unsigned nActualChannels = 1; - READ_REG_U16(hDevice, sensorTypeReg.VALUE16, CORE_SENSOR_TYPEn(chId)); - - if (chId == ADMW1001_CH_ID_DIG_SPI_0) { + if (chId == ADMW1001_CH_ID_DIG_SPI_0) + { /* Some sensors automatically generate samples on additional * "virtual" channels so these channels must be counted as * active when those sensors are selected and we use the count @@ -941,10 +940,15 @@ #if 0 /* SPI sensors arent supported at present to be added back once there is * support for these sensors */ + ADMW_CORE_Sensor_Type_t sensorTypeReg; + + READ_REG_U16(hDevice, sensorTypeReg.VALUE16, CORE_SENSOR_TYPEn(chId)); + if ((sensorTypeReg.Sensor_Type >= - CORE_SENSOR_TYPE_SPI_ACCELEROMETER_A) && - (sensorTypeReg.Sensor_Type <= - CORE_SENSOR_TYPE_SPI_ACCELEROMETER_B)) { + CORE_SENSOR_TYPE_SPI_ACCELEROMETER_A) && + (sensorTypeReg.Sensor_Type <= + CORE_SENSOR_TYPE_SPI_ACCELEROMETER_B)) + { nActualChannels += 2; } #endif @@ -1102,6 +1106,14 @@ return ADMW_SUCCESS; } +static ADMW_RESULT admw_SetExternalReferenceVoltage( + ADMW_DEVICE_HANDLE hDevice, + float32_t externalRefVoltage) +{ + WRITE_REG_FLOAT(hDevice, externalRefVoltage, CORE_EXTERNAL_VOLTAGE_REFERENCE); + + return ADMW_SUCCESS; +} static ADMW_RESULT admw_SetExternalReferenceValues( ADMW_DEVICE_HANDLE hDevice, @@ -1149,10 +1161,54 @@ ADMW_LOG_ERROR("Failed to set RSenseValue"); return eRet; } + + eRet = admw_SetExternalReferenceVoltage(hDevice, pMeasConfig->externalRefVoltage); + if (eRet != ADMW_SUCCESS) + { + ADMW_LOG_ERROR("Failed to set External reference Voltage"); + return eRet; + } + return ADMW_SUCCESS; } +ADMW_RESULT admw1001_SetDiagnosticsConfig( + ADMW_DEVICE_HANDLE hDevice, + ADMW1001_DIAGNOSTICS_CONFIG *pDiagnosticsConfig) +{ + ADMW_CORE_Diagnostics_Control_t diagnosticsControlReg; + diagnosticsControlReg.VALUE8 = REG_RESET_VAL(CORE_DIAGNOSTICS_CONTROL); + + if (pDiagnosticsConfig->disableMeasurementDiag) + diagnosticsControlReg.Diag_Meas_En = 0; + else + diagnosticsControlReg.Diag_Meas_En = 1; + + switch (pDiagnosticsConfig->osdFrequency) + { + case ADMW1001_OPEN_SENSOR_DIAGNOSTICS_DISABLED: + diagnosticsControlReg.Diag_OSD_Freq = CORE_DIAGNOSTICS_CONTROL_OCD_OFF; + break; + case ADMW1001_OPEN_SENSOR_DIAGNOSTICS_PER_CYCLE: + diagnosticsControlReg.Diag_OSD_Freq = CORE_DIAGNOSTICS_CONTROL_OCD_PER_1_CYCLE; + break; + case ADMW1001_OPEN_SENSOR_DIAGNOSTICS_PER_100_CYCLES: + diagnosticsControlReg.Diag_OSD_Freq = CORE_DIAGNOSTICS_CONTROL_OCD_PER_10_CYCLES; + break; + case ADMW1001_OPEN_SENSOR_DIAGNOSTICS_PER_1000_CYCLES: + diagnosticsControlReg.Diag_OSD_Freq = CORE_DIAGNOSTICS_CONTROL_OCD_PER_100_CYCLES; + break; + default: + ADMW_LOG_ERROR("Invalid open-sensor diagnostic frequency %d specified", + pDiagnosticsConfig->osdFrequency); + return ADMW_INVALID_PARAM; + } + + WRITE_REG_U8(hDevice, diagnosticsControlReg.VALUE8, CORE_DIAGNOSTICS_CONTROL); + + return ADMW_SUCCESS; +} ADMW_RESULT admw1001_SetChannelCount( ADMW_DEVICE_HANDLE hDevice, @@ -1262,8 +1318,13 @@ case ADMW1001_ADC_SENSOR_THERMISTOR_2: case ADMW1001_ADC_SENSOR_THERMISTOR_3: case ADMW1001_ADC_SENSOR_THERMISTOR_4: + case ADMW1001_ADC_SENSOR_SINGLE_ENDED_ABSOLUTE: + case ADMW1001_ADC_SENSOR_DIFFERENTIAL_ABSOLUTE: + case ADMW1001_ADC_SENSOR_SINGLE_ENDED_RATIO: + case ADMW1001_ADC_SENSOR_DIFFERENTIAL_RATIO: if (! (ADMW1001_CHANNEL_IS_ADC_SENSOR(eChannelId) || - ADMW1001_CHANNEL_IS_ADC_CJC(eChannelId))) { + ADMW1001_CHANNEL_IS_ADC_CJC(eChannelId) || ADMW1001_CHANNEL_IS_ADC(eChannelId) )) + { ADMW_LOG_ERROR( "Invalid ADC sensor type %d specified for channel %d", sensorType, eChannelId); @@ -2204,12 +2265,12 @@ return eRet; } -// eRet = admw1001_SetDiagnosticsConfig(hDevice, &pDeviceConfig->diagnostics); -// if (eRet) -// { -// ADMW_LOG_ERROR("Failed to set diagnostics configuration"); -// return eRet; -// } + eRet = admw1001_SetDiagnosticsConfig(hDevice, &pDeviceConfig->diagnostics); + if (eRet) + { + ADMW_LOG_ERROR("Failed to set diagnostics configuration"); + return eRet; + } for (ADMW1001_CH_ID id = ADMW1001_CH_ID_ANLG_1_UNIVERSAL; id < ADMW1001_MAX_CHANNELS;