/* ****************************************************************************
 * File:      diode
 * Date:      9 Apr 2026
 * Author:    Andrew Levido
 *
 * Copyright 206 Imbrius Pty Ltd - All Rights Reserved
 *
 *****************************************************************************/
#ifndef _diode_H
#define _diode_H

#include "analog.h"
#ifdef __cplusplus
extern "C" {
#endif

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

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

/* Defines -------------------------------------------------------------------*/
// 
#define AX_DIODE_VF_TEST_V              12000L  // 12V 
#define AX_DIODE_SCHOTTKY_V             400L    // < 400mV 
#define AX_DIODE_LED_V                  900L    // > 900mV
#define AX_DIODE_ZENER_V                11000   // < 11V

/* Typedefs & Enumerations ---------------------------------------------------*/

/* Public Functions Declarations ---------------------------------------------*/

/** Test common-anode diode pair & display results
  * measures Vf and Vr flags schottky, LED, Zener and diplays the appropriate 
  * screen
  * @param k1           Diode 1 Cathode
  * @param a1a2         Common Anode
  * @param k2           Diode 2 Cathode
  */
void ax_test_diode_aa(lead_t k1, lead_t a1a2, lead_t k2);

/** Test common-cathode diode pair & display results
  * measures Vf and Vr flags schottky, LED, Zener and diplays the appropriate 
  * screen
  * @param a1           Diode 1 Anode
  * @param k1k22        Common Cathode
  * @param a2           Diode 2 Anode
  */
void ax_test_diode_kk(lead_t a1, lead_t k1k2, lead_t a2);

/** Test anode-cathode diode pair & display results
  * measures Vf and Vr flags schottky, LED, Zener and diplays the appropriate 
  * screen
  * @param a1           Diode 1 Anode
  * @param k1a2         Common Anode/Cathode
  * @param k2           Diode 2 Cathode
  */
void ax_test_diode_ak(lead_t a1, lead_t k1a2, lead_t k2);

/** Test diode & display results
  * measures Vf and Vr flags schottky, LED, Zener and diplays the appropriate 
  * screen
  * @param a1           Diode Anode
  * @param k1           Diode Cathode
  */
void ax_test_diode(lead_t a1, lead_t k1);

/** Test diode back-to-back or short circuit & display results
  * measures Vf and Vr flags schottky, LED, diplays the appropriate 
  * screen
  * @param a1k2         Diode Pair Anode/Cathode
  * @param k1a2         Diode Pair Cathode/Anode
  * @param nc           Unconnected lead
  */
void ax_test_diode_b2b(lead_t a1k2, lead_t k1a2, lead_t nc);


#ifdef __cplusplus
}
#endif

#endif

/* End diode */