#ifndef AD_BOARD_H
#define AD_BOARD_H

#include <stdint.h>

#include "ad_parameter_identification.h"
#include "ad_inverter.h"

typedef struct
{
    uint8_t initialized;
    uint32_t faults;
    uint8_t zero_calibrated;
    uint16_t ia_raw;
    uint16_t ib_raw;
    uint16_t ic_raw;
    uint16_t vdc_raw;
    uint16_t vdc_raw_avg;
    uint16_t mcu_temp_raw;
    uint16_t ia_zero_raw;
    uint16_t ib_zero_raw;
    uint16_t ic_zero_raw;
    uint16_t vdc_zero_raw;
    float ia_adc_V;
    float ib_adc_V;
    float ic_adc_V;
    float vdc_adc_V;
    float vdc_adc_avg_V;
    float mcu_temp_adc_V;
    float mcu_temperature_C;
    float ia_zero_adc_V;
    float ib_zero_adc_V;
    float ic_zero_adc_V;
    float vdc_zero_adc_V;
    float phase_shunt_ohm;
} AD_BoardAdcSnapshot_t;

void AD_Board_Init(void);
void AD_Board_Loop(void);
void AD_Board_ReadMeasurements(AD_Measurements_t *meas);
const AD_BoardAdcSnapshot_t* AD_Board_GetAdcSnapshot(void);
void AD_Board_ResetAdcFaults(void);
void AD_Board_SetPhaseShuntResistanceOhm(float resistance_ohm);
float AD_Board_GetPhaseShuntResistanceOhm(void);
void AD_Board_StartDataLogging(void);
void AD_Board_StartParamTest(uint8_t mode);
void AD_Board_StartParamTestWithDuty(uint8_t mode, float pwm_duty_limit);
void AD_Board_StopParamTest(void);
void AD_Board_ToggleDataLogging(void);

#endif
