Vybhav Kadaba
/
EV-PRO-MW1001_Development_code_cleaup
Removed unwanted enums and unused functions
Diff: src/admw_1001.c
- Revision:
- 43:e1789b7214cf
- Parent:
- 42:c9c5a22e539e
- Child:
- 44:94bdfaefddac
--- a/src/admw_1001.c Tue Dec 10 09:00:11 2019 +0000 +++ b/src/admw_1001.c Tue Jan 07 05:45:58 2020 +0000 @@ -1082,18 +1082,19 @@ ADMW_RESULT admw_SetCycleControl(ADMW_DEVICE_HANDLE hDevice, uint32_t nCycleInterval, - bool vBiasEnable) + bool vBiasEnable, + bool vPostExecCurrentState, + bool vGroundSwitch) { ADMW_CORE_Cycle_Control_t cycleControlReg; cycleControlReg.VALUE16 = REG_RESET_VAL(CORE_CYCLE_CONTROL); - if (nCycleInterval < (1000 * (1 << 12))) { - cycleControlReg.Cycle_Time_Units = CORE_CYCLE_CONTROL_MILLISECONDS; - nCycleInterval /= 1000; + if (nCycleInterval < (1 << 12)) { + cycleControlReg.Cycle_Time_Units = CORE_CYCLE_CONTROL_SECONDS; } else { - cycleControlReg.Cycle_Time_Units = CORE_CYCLE_CONTROL_SECONDS; - nCycleInterval /= 1000000; + ADMW_LOG_ERROR("Invalid nCycleInterval %d specified", nCycleInterval); + return ADMW_INVALID_PARAM; } if (vBiasEnable == true) { @@ -1101,7 +1102,35 @@ } CHECK_REG_FIELD_VAL(CORE_CYCLE_CONTROL_CYCLE_TIME, nCycleInterval); cycleControlReg.Cycle_Time = nCycleInterval; - + + switch(vPostExecCurrentState) + { + case ADMW1001_ADC_EXC_STATE_CYCLE_POWER: + cycleControlReg.PST_MEAS_EXC_CTRL = CORE_CYCLE_CONTROL_POWERCYCLE; + break; + case ADMW1001_ADC_EXC_STATE_ALWAYS_ON: + cycleControlReg.PST_MEAS_EXC_CTRL = CORE_CYCLE_CONTROL_ALWAYSON; + break; + default: + ADMW_LOG_ERROR("Invalid Post measurement Excitation Current state %d specified", + vPostExecCurrentState); + return ADMW_INVALID_PARAM; + } + + switch(vGroundSwitch) + { + case ADMW1001_ADC_GND_SW_OPEN: + cycleControlReg.GND_SW_CTRL = CORE_CYCLE_CONTROL_CYCLE_SW; + break; + case ADMW1001_ADC_GND_SW_CLOSED: + cycleControlReg.GND_SW_CTRL = CORE_CYCLE_CONTROL_CLOSE_SW; + break; + default: + ADMW_LOG_ERROR("Invalid ground switch state %d specified", + vGroundSwitch); + return ADMW_INVALID_PARAM; + } + WRITE_REG_U16(hDevice, cycleControlReg.VALUE16, CORE_CYCLE_CONTROL); return ADMW_SUCCESS; @@ -1139,13 +1168,15 @@ } eRet = admw_SetCycleControl(hDevice, pMeasConfig->cycleInterval, - pMeasConfig->vBiasEnable); + pMeasConfig->vBiasEnable, + pMeasConfig->excitationState, + pMeasConfig->groundSwitch ); if (eRet != ADMW_SUCCESS) { ADMW_LOG_ERROR("Failed to set cycle control"); return eRet; } - if(pMeasConfig->externalRef1Value>0) { + if(pMeasConfig->externalRef1Value > 0) { eRet = admw_SetExternalReferenceValues(hDevice, pMeasConfig->externalRef1Value); } @@ -1512,7 +1543,6 @@ ADMW_CORE_Measurement_Setup_t MeasSetupReg; ADMW1001_ADC_FILTER_CONFIG *pFilterConfig = &pAdcChannelConfig->filter; MeasSetupReg.VALUE32 = REG_RESET_VAL(CORE_MEASUREMENT_SETUPn); - MeasSetupReg.PST_MEAS_EXC_CTRL = pAdcChannelConfig->current.excitationState; MeasSetupReg.Buffer_Bypass = pAdcChannelConfig->bufferBypass; if (pFilterConfig->type == ADMW1001_ADC_FILTER_SINC4) { @@ -1535,19 +1565,6 @@ else MeasSetupReg.NOTCH_EN_2 = 0; - switch(pFilterConfig->groundSwitch) { - case ADMW1001_ADC_GND_SW_OPEN: - MeasSetupReg.GND_SW = CORE_MEASUREMENT_SETUP_GND_SW_OPEN; - break; - case ADMW1001_ADC_GND_SW_CLOSED: - MeasSetupReg.GND_SW = CORE_MEASUREMENT_SETUP_GND_SW_CLOSED; - break; - default: - ADMW_LOG_ERROR("Invalid ground switch state %d specified", - pFilterConfig->groundSwitch); - return ADMW_INVALID_PARAM; - } - WRITE_REG_U32(hDevice, MeasSetupReg.VALUE32, CORE_MEASUREMENT_SETUPn(eChannelId)); return ADMW_SUCCESS;