Example program for EVAL-ADMX2001
Dependencies: ADMX2001
Diff: main.cpp
- Revision:
- 9:29db35656fcb
- Parent:
- 8:bd0b93e35392
- Child:
- 10:186e097fb1e3
--- a/main.cpp Wed Oct 27 21:18:12 2021 +0000 +++ b/main.cpp Tue Nov 02 10:14:25 2021 +0000 @@ -50,6 +50,8 @@ #include <stdio.h> #include <stdlib.h> +/*============= D A T A =============*/ + /** This is kept global and non-static as test code requires this*/ Admx200xDev admx200xDev; @@ -57,6 +59,8 @@ static int32_t ResetModule(); +static int32_t SetGain(uint32_t voltageGain, uint32_t currentGain); + /** * */ @@ -109,6 +113,39 @@ return status; } +/** + * Set the voltage/current gain + */ +int32_t SetGain(uint32_t voltageGain, uint32_t currentGain) +{ + int32_t status = ADMX_STATUS_SUCCESS; + uint16_t addr = 0; + uint8_t cmdId; + uint32_t statReg; + Admx200xDev *pAdmx200x = &admx200xDev; + uint32_t data; + + data = voltageGain; + cmdId = CMD_VOLTAGE_GAIN; + status = Admx200xSendCmd(pAdmx200x, &cmdId, &addr, &data, &statReg); + if (status == ADMX_STATUS_SUCCESS) + { + status = (int32_t)(statReg & ADMX200X_STATUS_CODE_BITM); + } + + if (status == ADMX_STATUS_SUCCESS) + { + cmdId = CMD_CURRENT_GAIN; + status = Admx200xSendCmd(pAdmx200x, &cmdId, &addr, &data, &statReg); + if (status == ADMX_STATUS_SUCCESS) + { + status = (int32_t)(statReg & ADMX200X_STATUS_CODE_BITM); + } + } + + return status; +} + int main() { int32_t status = 0; @@ -147,11 +184,15 @@ INFO_MSG("------ Measurement completed ------"); INFO_MSG("------ Starting Calibration ------"); - INFO_MSG("Setting test load to open circuit"); - // Open the terminals across the lcr meter - EnableMuxLine(0); - // Running open calibration - calType = CAL_TYPE_OPEN; + INFO_MSG("Setting test load to short circuit"); + // Short the terminals across the lcr meter + EnableMuxLine(1); + // Setting the gain for calibration + status = SetGain(0, 0); + INFO_MSG("Setting voltage gain to zero"); + INFO_MSG("Setting current gain to zero"); + // Running short calibration + calType = CAL_TYPE_SHORT; status = Calibrate(calType, stdLoad, Xt); INFO_MSG("------ Calibration completed ------"); }