/* ****************************************************************************
 * File:      analyser_helper
 * Date:      18 Apr 2026
 * Author:    Andrew Levido
 *
 * Copyright 2026 Imbrius Pty Ltd - All Rights Reserved
 *
 *****************************************************************************/
#ifndef _analyser_helper_H
#define _analyser_helper_H

#ifdef __cplusplus
extern "C" {
#endif

/* Description ---------------------------------------------------------------*/

/* Includes ------------------------------------------------------------------*/
#include "app.h"
#include "analog.h"

/* Defines -------------------------------------------------------------------*/

#define AX_TEST_V_HI                    12000L    // 12V in mV
#define AX_TEST_V_LO                    8000L     // 8.0 V in mV 
#define AX_TEST_DRIVE_I                 500L      // 500µA
#define AX_TEST_DRIVE_V                 8000L     // 8V in mV

#define AX_MAX_TEXT_SIZE       40
/* Typedefs & Enumerations ---------------------------------------------------*/
extern char ax_line_1_buffer[AX_MAX_TEXT_SIZE];
extern char ax_line_2_buffer[AX_MAX_TEXT_SIZE];
/* Public Functions Declarations ---------------------------------------------*/

/** Measure load current from in to out with drive node open 
*
*    +V --- LOAD --- in [DUT] out --- 0V
*/
int32_t ax_get_i_open_drive(lead_t lead_in, lead_t lead_out, lead_t lead_drive, bool low_v);

/** Measure load current from in to out with drive node shorted to out 
*
*    +V --- LOAD --- in [DUT] out --- 0V
*/
int32_t ax_get_i_gnd_drive(lead_t lead_in, lead_t lead_out, lead_t lead_drive, bool low_v);

/** Measure load current from in to out with -drive node shorted to in
*
*    +12 --- in [DUT] out --- LOAD--- 12-V+
*/
int32_t ax_get_i_vplus_drive(lead_t lead_in, lead_t lead_out, lead_t lead_drive, bool low_v);

/** Measure load current from in to out with +500uA drive
*
*    +V --- LOAD --- in [DUT] out --- 0V
*/
int32_t ax_get_i_posi_drive(lead_t lead_in, lead_t lead_out, lead_t lead_drive, bool low_v);

/** Measure load current from in to out with -500uA drive
*
*    +12 --- in [DUT] out --- LOAD--- 12-V+
*/
int32_t ax_get_i_negi_drive(lead_t lead_in, lead_t lead_out, lead_t lead_drive, bool low_v);


/** Measure DUT voltage from in to out with +500uA drive
*
*    +V --- LOAD --- in [DUT] out --- 0V
*/
int32_t ax_get_v_posv_drive(lead_t lead_in, lead_t lead_out, lead_t lead_drive, bool low_v);

/** Measure DUT voltage from in to out with drive node open
*
*    +V --- LOAD --- in [DUT] out --- 0V
*/
int32_t ax_get_v_open_drive(lead_t lead_in, lead_t lead_out, lead_t lead_drive, bool low_v);

void ax_print_flt(char * buff, int32_t val);
int32_t ax_get_lead_mv(lead_t lead);

char* ax_lead_2_text(lead_t lead);

char * ax_convert_mv_ua(char* buf, char* lhs, int32_t mv, int32_t ua);
char * ax_convert_hfe_ua(char* buf, char* lhs, int32_t hfe, int32_t ua);
/* Task Function -------------------------------------------------------------*/

/* Interrupt Service Routine Declarations ------------------------------------*/

#ifdef __cplusplus
}
#endif

#endif

/* End analyser_helper */