EIS-BLE-S3/main/eis.h

48 lines
960 B
C

#ifndef EIS_H
#define EIS_H
#include "ad5940.h"
#define EIS_MAX_POINTS 100
typedef enum {
RTIA_200 = 0, RTIA_1K, RTIA_5K, RTIA_10K,
RTIA_20K, RTIA_40K, RTIA_80K, RTIA_160K,
RTIA_EXT_DE0,
RTIA_COUNT
} EISRtia;
typedef enum {
RCAL_200R = 0, /* RCAL0 ↔ RCAL1 */
RCAL_3K, /* RCAL0 ↔ AIN0 */
RCAL_COUNT
} EISRcal;
typedef struct {
float freq_start_hz;
float freq_stop_hz;
uint16_t points_per_decade;
EISRtia rtia;
EISRcal rcal;
uint32_t pga;
uint32_t excit_amp;
} EISConfig;
typedef struct {
float freq_hz;
float mag_ohms;
float phase_deg;
float z_real;
float z_imag;
} EISPoint;
void eis_default_config(EISConfig *cfg);
void eis_init(const EISConfig *cfg);
void eis_reconfigure(const EISConfig *cfg);
int eis_measure_point(float freq_hz, EISPoint *out);
int eis_sweep(EISPoint *out, uint32_t max_points);
uint32_t eis_calc_num_points(const EISConfig *cfg);
#endif