Example program for EVAL-ADMX2001
Dependencies: ADMX2001
measure.h@5:746e78113d7d, 2021-10-27 (annotated)
- Committer:
- nsheth
- Date:
- Wed Oct 27 06:58:57 2021 +0000
- Revision:
- 5:746e78113d7d
- Child:
- 8:bd0b93e35392
Changes for measurement and calibration using different test loads
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nsheth | 5:746e78113d7d | 1 | /* Copyright (c) 2021 Analog Devices, Inc. All rights reserved. |
nsheth | 5:746e78113d7d | 2 | |
nsheth | 5:746e78113d7d | 3 | Redistribution and use in source and binary forms, with or without modification, |
nsheth | 5:746e78113d7d | 4 | are permitted provided that the following conditions are met: |
nsheth | 5:746e78113d7d | 5 | - Redistributions of source code must retain the above copyright notice, |
nsheth | 5:746e78113d7d | 6 | this list of conditions and the following disclaimer. |
nsheth | 5:746e78113d7d | 7 | - Redistributions in binary form must reproduce the above copyright notice, |
nsheth | 5:746e78113d7d | 8 | this list of conditions and the following disclaimer in the documentation |
nsheth | 5:746e78113d7d | 9 | and/or other materials provided with the distribution. |
nsheth | 5:746e78113d7d | 10 | - Modified versions of the software must be conspicuously marked as such. |
nsheth | 5:746e78113d7d | 11 | - This software is licensed solely and exclusively for use with processors/products |
nsheth | 5:746e78113d7d | 12 | manufactured by or for Analog Devices, Inc. |
nsheth | 5:746e78113d7d | 13 | - This software may not be combined or merged with other code in any manner |
nsheth | 5:746e78113d7d | 14 | that would cause the software to become subject to terms and conditions which |
nsheth | 5:746e78113d7d | 15 | differ from those listed here. |
nsheth | 5:746e78113d7d | 16 | - Neither the name of Analog Devices, Inc. nor the names of its contributors |
nsheth | 5:746e78113d7d | 17 | may be used to endorse or promote products derived from this software without |
nsheth | 5:746e78113d7d | 18 | specific prior written permission. |
nsheth | 5:746e78113d7d | 19 | - The use of this software may or may not infringe the patent rights of one or |
nsheth | 5:746e78113d7d | 20 | more patent holders. This license does not release you from the requirement |
nsheth | 5:746e78113d7d | 21 | that you obtain separate licenses from these patent holders to use this software. |
nsheth | 5:746e78113d7d | 22 | |
nsheth | 5:746e78113d7d | 23 | THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. AND CONTRIBUTORS "AS IS" AND |
nsheth | 5:746e78113d7d | 24 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, |
nsheth | 5:746e78113d7d | 25 | TITLE, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN |
nsheth | 5:746e78113d7d | 26 | NO EVENT SHALL ANALOG DEVICES, INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
nsheth | 5:746e78113d7d | 27 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE OR CONSEQUENTIAL DAMAGES |
nsheth | 5:746e78113d7d | 28 | (INCLUDING, BUT NOT LIMITED TO, DAMAGES ARISING OUT OF CLAIMS OF INTELLECTUAL |
nsheth | 5:746e78113d7d | 29 | PROPERTY RIGHTS INFRINGEMENT; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS |
nsheth | 5:746e78113d7d | 30 | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
nsheth | 5:746e78113d7d | 31 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
nsheth | 5:746e78113d7d | 32 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
nsheth | 5:746e78113d7d | 33 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
nsheth | 5:746e78113d7d | 34 | |
nsheth | 5:746e78113d7d | 35 | 2021-01-10-7CBSD SLA |
nsheth | 5:746e78113d7d | 36 | */ |
nsheth | 5:746e78113d7d | 37 | /** |
nsheth | 5:746e78113d7d | 38 | * |
nsheth | 5:746e78113d7d | 39 | * @file: measure.h |
nsheth | 5:746e78113d7d | 40 | * |
nsheth | 5:746e78113d7d | 41 | * @brief: This file contains type definitions and function prototype |
nsheth | 5:746e78113d7d | 42 | * for measure.c |
nsheth | 5:746e78113d7d | 43 | * |
nsheth | 5:746e78113d7d | 44 | * @details: Provides function definitions for impedence and admittance |
nsheth | 5:746e78113d7d | 45 | * @defgroup MEASURE Measurement routines |
nsheth | 5:746e78113d7d | 46 | * |
nsheth | 5:746e78113d7d | 47 | * @{ |
nsheth | 5:746e78113d7d | 48 | */ |
nsheth | 5:746e78113d7d | 49 | |
nsheth | 5:746e78113d7d | 50 | #ifndef __MEASURE_H__ |
nsheth | 5:746e78113d7d | 51 | #define __MEASURE_H__ |
nsheth | 5:746e78113d7d | 52 | |
nsheth | 5:746e78113d7d | 53 | /*============= I N C L U D E S =============*/ |
nsheth | 5:746e78113d7d | 54 | #include <complex.h> |
nsheth | 5:746e78113d7d | 55 | #include <stdbool.h> |
nsheth | 5:746e78113d7d | 56 | #include <stdint.h> |
nsheth | 5:746e78113d7d | 57 | |
nsheth | 5:746e78113d7d | 58 | /*============= D E F I N E S =============*/ |
nsheth | 5:746e78113d7d | 59 | /** DC resistance frequency */ |
nsheth | 5:746e78113d7d | 60 | #define DC_RESISTANCE_FREQUENCY (0.0) |
nsheth | 5:746e78113d7d | 61 | /** Min average value */ |
nsheth | 5:746e78113d7d | 62 | #define MIN_AVERAGE 1 |
nsheth | 5:746e78113d7d | 63 | /** Max average value */ |
nsheth | 5:746e78113d7d | 64 | /* FIXME: Need to figure out the exact value */ |
nsheth | 5:746e78113d7d | 65 | #define MAX_AVERAGE 65536 |
nsheth | 5:746e78113d7d | 66 | /** Size of measurement buffer */ |
nsheth | 5:746e78113d7d | 67 | /** FIFO Size / 2 */ |
nsheth | 5:746e78113d7d | 68 | #define MEASUREMENT_BUFFER_SIZE 256 |
nsheth | 5:746e78113d7d | 69 | /** Min sample count value */ |
nsheth | 5:746e78113d7d | 70 | #define MIN_SAMPLE_COUNT 1 |
nsheth | 5:746e78113d7d | 71 | /** Max sample count value */ |
nsheth | 5:746e78113d7d | 72 | #define MAX_SAMPLE_COUNT 255 |
nsheth | 5:746e78113d7d | 73 | /** Min display mode value */ |
nsheth | 5:746e78113d7d | 74 | #define MIN_DISP_MODE 0 |
nsheth | 5:746e78113d7d | 75 | /** Max display mode value */ |
nsheth | 5:746e78113d7d | 76 | #define MAX_DISP_MODE 18 |
nsheth | 5:746e78113d7d | 77 | /** Number of sweep scales */ |
nsheth | 5:746e78113d7d | 78 | #define NUM_SCALES 2 |
nsheth | 5:746e78113d7d | 79 | /** Number of sweep types */ |
nsheth | 5:746e78113d7d | 80 | #define NUM_TYPES 4 |
nsheth | 5:746e78113d7d | 81 | |
nsheth | 5:746e78113d7d | 82 | /** |
nsheth | 5:746e78113d7d | 83 | * Type of resistance modes |
nsheth | 5:746e78113d7d | 84 | */ |
nsheth | 5:746e78113d7d | 85 | typedef enum |
nsheth | 5:746e78113d7d | 86 | { |
nsheth | 5:746e78113d7d | 87 | /** DC resistance mode */ |
nsheth | 5:746e78113d7d | 88 | DC_RESISTANCE_MODE, |
nsheth | 5:746e78113d7d | 89 | /** AC resistance mode */ |
nsheth | 5:746e78113d7d | 90 | AC_RESISTANCE_MODE |
nsheth | 5:746e78113d7d | 91 | } RESISTANCE_MODE; |
nsheth | 5:746e78113d7d | 92 | /** |
nsheth | 5:746e78113d7d | 93 | * Type of sweep type |
nsheth | 5:746e78113d7d | 94 | */ |
nsheth | 5:746e78113d7d | 95 | typedef enum |
nsheth | 5:746e78113d7d | 96 | { |
nsheth | 5:746e78113d7d | 97 | SWEEP_TYPE_NONE, |
nsheth | 5:746e78113d7d | 98 | SWEEP_TYPE_FREQUENCY, |
nsheth | 5:746e78113d7d | 99 | SWEEP_TYPE_OFFSET, |
nsheth | 5:746e78113d7d | 100 | SWEEP_TYPE_MAG |
nsheth | 5:746e78113d7d | 101 | } SWEEP_TYPE; |
nsheth | 5:746e78113d7d | 102 | |
nsheth | 5:746e78113d7d | 103 | /** |
nsheth | 5:746e78113d7d | 104 | * Type of sweep scale |
nsheth | 5:746e78113d7d | 105 | */ |
nsheth | 5:746e78113d7d | 106 | typedef enum |
nsheth | 5:746e78113d7d | 107 | { |
nsheth | 5:746e78113d7d | 108 | SWEEP_SCALE_LINEAR, |
nsheth | 5:746e78113d7d | 109 | SWEEP_SCALE_LOG |
nsheth | 5:746e78113d7d | 110 | } SWEEP_SCALE; |
nsheth | 5:746e78113d7d | 111 | |
nsheth | 5:746e78113d7d | 112 | /** |
nsheth | 5:746e78113d7d | 113 | * Type of measurement mode |
nsheth | 5:746e78113d7d | 114 | */ |
nsheth | 5:746e78113d7d | 115 | typedef enum |
nsheth | 5:746e78113d7d | 116 | { |
nsheth | 5:746e78113d7d | 117 | MEASM_MODE_IMPEDANCE, |
nsheth | 5:746e78113d7d | 118 | MEASM_MODE_ADMITTANCE |
nsheth | 5:746e78113d7d | 119 | |
nsheth | 5:746e78113d7d | 120 | } MEASM_MODE; |
nsheth | 5:746e78113d7d | 121 | |
nsheth | 5:746e78113d7d | 122 | /** |
nsheth | 5:746e78113d7d | 123 | * Impedance correction mode |
nsheth | 5:746e78113d7d | 124 | */ |
nsheth | 5:746e78113d7d | 125 | typedef enum |
nsheth | 5:746e78113d7d | 126 | { |
nsheth | 5:746e78113d7d | 127 | CORRECTION_MODE_NONE, |
nsheth | 5:746e78113d7d | 128 | CORRECTION_MODE_CAL, |
nsheth | 5:746e78113d7d | 129 | CORRECTION_MODE_COMP |
nsheth | 5:746e78113d7d | 130 | } CORRECTION_MODE; |
nsheth | 5:746e78113d7d | 131 | |
nsheth | 5:746e78113d7d | 132 | /** display types */ |
nsheth | 5:746e78113d7d | 133 | typedef enum |
nsheth | 5:746e78113d7d | 134 | { |
nsheth | 5:746e78113d7d | 135 | RS_CS, |
nsheth | 5:746e78113d7d | 136 | CS_D, |
nsheth | 5:746e78113d7d | 137 | CS_Q, |
nsheth | 5:746e78113d7d | 138 | LS_RS, |
nsheth | 5:746e78113d7d | 139 | LS_D, |
nsheth | 5:746e78113d7d | 140 | LS_Q, |
nsheth | 5:746e78113d7d | 141 | R_X, |
nsheth | 5:746e78113d7d | 142 | Z_PHASE_DEG, |
nsheth | 5:746e78113d7d | 143 | Z_PHASE_RAD, |
nsheth | 5:746e78113d7d | 144 | CP_RP, |
nsheth | 5:746e78113d7d | 145 | CP_D, |
nsheth | 5:746e78113d7d | 146 | CP_Q, |
nsheth | 5:746e78113d7d | 147 | LP_RP, |
nsheth | 5:746e78113d7d | 148 | LP_D, |
nsheth | 5:746e78113d7d | 149 | LP_Q, |
nsheth | 5:746e78113d7d | 150 | G_B, |
nsheth | 5:746e78113d7d | 151 | Y_PHASE_DEG, |
nsheth | 5:746e78113d7d | 152 | Y_PHASE_RAD, |
nsheth | 5:746e78113d7d | 153 | DISPLAY_MODE_NONE |
nsheth | 5:746e78113d7d | 154 | } DISPLAY_MODE; |
nsheth | 5:746e78113d7d | 155 | |
nsheth | 5:746e78113d7d | 156 | /*============= D A T A T Y P E S =============*/ |
nsheth | 5:746e78113d7d | 157 | |
nsheth | 5:746e78113d7d | 158 | /** |
nsheth | 5:746e78113d7d | 159 | * adicomplex |
nsheth | 5:746e78113d7d | 160 | * Complex DataType |
nsheth | 5:746e78113d7d | 161 | */ |
nsheth | 5:746e78113d7d | 162 | typedef _Complex adicomplex; |
nsheth | 5:746e78113d7d | 163 | |
nsheth | 5:746e78113d7d | 164 | #ifdef __cplusplus |
nsheth | 5:746e78113d7d | 165 | extern "C" |
nsheth | 5:746e78113d7d | 166 | { |
nsheth | 5:746e78113d7d | 167 | #endif |
nsheth | 5:746e78113d7d | 168 | |
nsheth | 5:746e78113d7d | 169 | /*============= F U N C T I O N P R O T O T Y P E S =============*/ |
nsheth | 5:746e78113d7d | 170 | |
nsheth | 5:746e78113d7d | 171 | /** |
nsheth | 5:746e78113d7d | 172 | * @details Measures impedance based on configured attributes |
nsheth | 5:746e78113d7d | 173 | * @return 0 - Success 1 - Failed |
nsheth | 5:746e78113d7d | 174 | */ |
nsheth | 5:746e78113d7d | 175 | int32_t TriggerAndMeasure(); |
nsheth | 5:746e78113d7d | 176 | |
nsheth | 5:746e78113d7d | 177 | void PrintMeasureStatusMessage(int32_t status); |
nsheth | 5:746e78113d7d | 178 | #ifdef __cplusplus |
nsheth | 5:746e78113d7d | 179 | } |
nsheth | 5:746e78113d7d | 180 | #endif |
nsheth | 5:746e78113d7d | 181 | #endif /* __MEASURE_H__ */ |
nsheth | 5:746e78113d7d | 182 | /** @} */ |