/**
*   @copyright       © 2026 Microchip Technology Inc.
    Microchip Technology Inc. and its subsidiaries. You may use this
    software and any derivatives exclusively with Microchip products.

    THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
    EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED
    WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A
    PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION
    WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION.

    IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
    INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
    WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
    BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE
    FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN
    ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
    THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.

    MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE
    TERMS. 
*
*************************************************************************/

/*************************************************************************
 *  @file           diag_adc_shared.h
 *  @version       	1.0
 *  @brief     		This file has the declarations for the common functions
 *					used by ADC diagnostics.
 *************************************************************************/
 
#ifndef DIAG_ADC_SHARED_H
#define DIAG_ADC_SHARED_H

/*Section: Included Files*/
#include <stdint.h>
#include "diag_adc.h"

#define DIAG_ADC_VALID_CHANNEL          1U
#define DIAG_ADC_INVALID_CHANNEL        0U
#define DIAG_ADC_MAX_INSTANCE   5U
#define DIAG_ADC_NEXT_CHANNEL_ADDRESS   0x0020UL

extern const uint16_t nextADCInstanceAddress [DIAG_ADC_MAX_INSTANCE];

typedef struct
{
    uint32_t controlReg;
    uint32_t dataStatReg;
    uint32_t resultStatReg;
    uint32_t compStatReg;
    uint32_t softTrigReg;
    uint32_t chControl1Reg;
    uint32_t chControl2Reg;
    uint32_t chDataReg;
    uint32_t chResultReg;
    uint32_t chLowCompReg;
    uint32_t chHighCompReg;
}DIAG_ADC_BASE_ADDRESS;

extern const DIAG_ADC_BASE_ADDRESS baseAddress;

/* Function Declarations */
uint16_t DIAG_ADC_IsChannelValid(DIAG_ADC_CHANNELS adcChannel);
uint16_t DIAG_ADC_GetADCInstance(DIAG_ADC_CHANNELS adcChannel);
uint16_t DIAG_ADC_GetADCChannel(DIAG_ADC_CHANNELS adcChannel);
uint32_t DIAG_ADC_TriggerConversionAndGetResult(DIAG_ADC_CHANNELS adcChannel);
void DIAG_ADC_StoreRegisters(DIAG_ADC_CHANNELS adcChannel);
void DIAG_ADC_RestoreRegisters(DIAG_ADC_CHANNELS adcChannel);

#endif /* DIAG_ADC_SHARED_H */
