Example program for EVAL-ADMX2001
Dependencies: ADMX2001
Diff: calibrate.h
- Revision:
- 8:bd0b93e35392
- Parent:
- 5:746e78113d7d
- Child:
- 9:29db35656fcb
--- a/calibrate.h Wed Oct 27 07:36:33 2021 +0000 +++ b/calibrate.h Wed Oct 27 21:18:12 2021 +0000 @@ -39,7 +39,7 @@ /** * @file: calibrate.h * @brief: This file contains type definitions and function prototype - * for calibrate.c + * for calibrate.cpp * @details: Provides function definitions for command actions * @defgroup CAL_AND_COMP Calibration and compensation routines */ @@ -51,59 +51,6 @@ #include <stdint.h> /*============= D E F I N E S =============*/ -#define DEFAULT_CAL_COEFF_INDEX (0) -/**< Default calibration coefficient index */ -#define DEFAULT_DC_COEFF_INDEX (0) -/**< Default dc calibration coefficient index */ -#define DEFAULT_COMPN_COEFF_INDEX (0) -/**< Default compensation coefficient index */ -#define NUM_CALIBRATION_SETS (16 + 1) -/**< Max number of cal coefficient sets */ - -/** @brief password array size */ -#define MAX_PASSWORD_SIZE (12) -/** @brief timestamp array size */ -#define TIMESTAMP_SIZE (128) -/** @brief - * Calibration states - * */ - -/** No calibration done*/ -#define CAL_STAT_NO_CAL (0) -/** calibration status is short - Rs, Xs, Gs, Bs*/ -#define CAL_STAT_SHORT (0xF << 0) -/** calibration status is open - Ro, Xo, Go, Bo*/ -#define CAL_STAT_OPEN (0xF << 4) -/** calibration status is Load, Rg, xG, Gg, Bg*/ -#define CAL_STAT_LOAD (0xF << 8) -/** calibration status dirty */ -#define CAL_STAT_DIRTY (1 << 15) -/** Success */ -#define CAL_STATUS_SUCCESS 0 -/** Operation Failed */ -#define CAL_STATUS_FAILURE 1 -/** Password incorrect in calibration commit*/ -#define CAL_STATUS_INVALID_PASSWORD 5 -/** CRC error while reading coeffs from flash */ -#define CAL_STATUS_CRC_ERROR 3 -/** Number of calibration modes */ -#define CAL_NUM_MODES 4 -/** Number of calibration coeffcients */ -#define CAL_NUM_COEFFS 12 -/** Number of dc calibration coeffcients */ -#define CAL_NUM_DC_COEFFS 2 - -/** - * @brief enumeration for all calibration Modes - * - */ -typedef enum -{ - CAL_MODE_NONE = 0, /**< No correction applied */ - CAL_MODE_CAL, /**< Correction applied using calibration coefficients */ - CAL_MODE_COMP, /**< Corrections are applied using both calibration and \ - compensation coeffcients */ -} CAL_MODE; /** * @brief enumeration for all calibration coeffs @@ -117,103 +64,6 @@ CAL_TYPE_LOAD, /**< LOAD Calibration */ } CAL_TYPE; -/** - * @brief enumeration for all calibration coefficients - * - */ -typedef enum -{ - Ro = 0, /**< Open Resistance */ - Xo, /**< Open Reactance */ - Go, /**< Open Conductance */ - Bo, /**< Open Susceptance */ - Rs, /**< Short Resistance */ - Xs, /**< Short Reactance */ - Gs, /**< Short Conductance */ - Bs, /**< Short Susceptance */ - Rg, /**< Resistance gain calibration coefficient */ - Xg, /**< Reactance gain calibration coefficient */ - Gg, /**< Conductance gain calibration coefficient */ - Bg /**< Susceptance gain calibration coefficient */ -} CAL_COEFFICIENT; - -/** - * @brief enumeration for Dc calibration coefficients - * - */ -typedef enum -{ - Rdg = 0, /**< gain coefficient */ - Rdo, /**< offset coefficient */ -} DC_CAL_COEFFICIENT; - -/*============= D A T A T Y P E S =============*/ -/** - * - * @brief structure for all calibration coefficients - * - */ -typedef struct -{ - uint32_t status; /**< status for Open/Load/Short */ - uint32_t voltageGain; /**< voltage gain for calibration */ - uint32_t currentGain; /**< current gain for calibration */ - float frequency; /**< input frequency */ - float temperature; /**< input temperature */ - double Rs; /**< Short Resistance */ - double Rdg; /**< gain coefficient */ - double Rdo; /**< offset coefficient */ -} DcCalibrationCoeffs; - -/** - * - * @brief structure for all calibration coefficients - * - */ -typedef struct -{ - uint32_t status; /**< status for Open/Load/Short */ - uint32_t voltageGain; /**< voltage gain for calibration */ - uint32_t currentGain; /**< current gain for calibration */ - float frequency; /**< input frequency */ - float temperature; /**< input temperature */ - double Ro; /**< Open Resistance */ - double Xo; /**< Open Reactance */ - double Go; /**< Open Conductance */ - double Bo; /**< Open Susceptance */ - double Rs; /**< Short Resistance */ - double Xs; /**< Short Reactance */ - double Gs; /**< Short Conductance */ - double Bs; /**< Short Susceptance */ - double Rg; /**< Resistance gain calibration coefficient */ - double Xg; /**< Reactance gain calibration coefficient */ - double Gg; /**< Conductance gain calibration coefficient */ - double Bg; /**< Susceptance gain calibration coefficient */ -} CalibrationCoeffs; - -/** - * - * @brief structure for calibration data - * - */ -typedef struct -{ - uint16_t crc; - /**< crc value for this structure */ - uint16_t numSets; - /**< number of sets filled +1 for \0 */ - uint16_t numDcSets; - /**< number of Dc coeffs filled +1 for \0 */ - /**FIXME: better to keep seperate count??*/ - uint8_t timestamp[TIMESTAMP_SIZE + 1]; - /**< time stamp +1 for \0 */ - uint8_t password[MAX_PASSWORD_SIZE + 1]; - /**< commit password */ - CalibrationCoeffs coeffs[NUM_CALIBRATION_SETS]; - /**< array of calibration coefficients*/ - DcCalibrationCoeffs dcCoeffs[NUM_CALIBRATION_SETS]; - /**< array of DC calibration coefficients */ -} CalibrationData; /*============= F U N C T I O N P R O T O T Y P E S =============*/