#include <stdint.h>
#include <xc.h>

#ifndef STRUCTURES
#define STRUCTURES

typedef unsigned long _paddr_t; // a physical address
typedef unsigned long _vaddr_t; // a virtual address
#define KVA_TO_PA(v) ((_paddr_t)(v) & 0x1fffffff)

#define WAV_LEN_MAX 250

struct results_struct
{
    int32_t new_data;
    int32_t wave[WAV_LEN_MAX];
    double voltage_saved[WAV_LEN_MAX];
    double current_saved[WAV_LEN_MAX];
    double volt_real_raw;
    double volt_imag_raw;
    double curr_real_raw;
    double curr_imag_raw;
    double volt_real;
    double volt_imag;
    double curr_real;
    double curr_imag;
    double z_raw_real;
    double z_raw_imag;
    double y_raw_real;
    double y_raw_imag;
    double z_real;
    double z_imag;
    double y_real;
    double y_imag;
    double z_mod;
    double z_arg;
    double y_mod;
    double y_arg;
};

struct comp_struct
{
    double z_resid_real;
    double z_resid_imag;
    double y_stray_real;
    double y_stray_imag;
};

struct config_struct
{
    int32_t v_gain;
    int32_t i_gain;
    int32_t v_i_gain;
    int32_t vrr;
    int32_t irr;
    int32_t fq_sel;
    int32_t amp_sel;
    int32_t do_the_cal;         //is set when ui requests calibration
    int32_t comp_open;          //is set when ui requests open circuit compensation
    int32_t comp_short;         //is set when ui requests short circuit compensation
    int32_t turn_on_off;        //is set when ui requests turn on/off
};

struct cal_struct
{
    double cal_i10;
    double cal_i100;
    double cal_i1000;
    double cal_i10000;
    double cal_u1;
    double cal_u10;
    double cal_u100;
    double ph_cal_i10;
    double ph_cal_i100;
    double ph_cal_i1000;
    double ph_cal_i10000;
    double ph_cal_u1;
    double ph_cal_u10;
    double ph_cal_u100;
};

#endif
