/**
*   @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_cpu_shared.h
 *  @version    1.0
 *  @brief      This file has the declarations for the CPU diagnostic 
 *              common functions
 *
 *************************************************************************/
#ifndef DIAG_CPU_SHARED_H
#define	DIAG_CPU_SHARED_H

#ifdef	__cplusplus
extern "C" {
#endif

/*Function headers*/
#include "xc.h"
#include "diag.h"
#define DIAG_CPU_TEST_REGS 14U
#define CPU_RCOUNT_REG_BASE &RCOUNT
#define DIAG_CPU_NUM_TEST_SUBSETS 8U
#define DIAG_CPU_SELFTEST_SUB1_RESULT 0x00000001U
#define DIAG_CPU_SELFTEST_SUB2_RESULT 0x00000002U
#define DIAG_CPU_SELFTEST_SUB3_RESULT 0x00000003U
#define DIAG_CPU_SELFTEST_SUB4_RESULT 0x00000004U
#define DIAG_CPU_SELFTEST_SUB5_RESULT 0x00000005U
#define DIAG_CPU_SELFTEST_SUB6_RESULT 0x00000006U
#define DIAG_CPU_SELFTEST_SUB7_RESULT 0x00000007U
#define DIAG_CPU_SELFTEST_SUB8_RESULT 0x00000008U
    
#define DIAG_CPU_RESULT_BITMASK 0x000000FFU    

/*LDRA_EXCLUDE 63 D : <justification start> Function definition is present in corresponding source file, violation ignored <justification end> */
void DIAG_CPU_SetRetValue(uint32_t returnValue);
/*LDRA_EXCLUDE 63 D : <justification start> Function definition is present in corresponding source file, violation ignored <justification end> */
uint32_t DIAG_CPU_GetRetValue(void);
/*LDRA_EXCLUDE 63 D : <justification start> Function definition is present in corresponding source file, violation ignored <justification end> */
void  DIAG_CPU_MathError(void);

typedef struct
{
    uint32_t resetValue;
    uint32_t resetMask;
}diagCpuResetValueLookup;
typedef struct
{
    uint32_t testValue1;
    uint32_t testValue2;
    uint32_t maskValue;
}diagCpuControlTestLookup;

extern volatile uint32_t __attribute__((address(0x00A000))) DIAG_CPU_TestRam;
extern volatile uint32_t __attribute__((address(0x00B0A0))) DIAG_CPU_TestRam1;
extern volatile uint32_t __attribute__((address(0x00BA00))) DIAG_CPU_TestRam2;
extern volatile uint32_t __attribute__((address(0x00BBA0))) DIAG_CPU_TestRam3;
extern volatile uint32_t __attribute__((address(0x00BB00))) DIAG_CPU_TestRam4;
extern volatile uint32_t __attribute__((address(0x00C0A0))) DIAG_CPU_TestRamY1;
extern volatile uint32_t __attribute__((address(0x00CA00))) DIAG_CPU_TestRamY2;
//extern volatile uint32_t __attribute__((near)) DIAG_CPU_tempArray[12];

/*type define a pointer to an array of DIAG_CPU_TEST_REGS number of registers*/
typedef volatile uint32_t (*cpuRegMap_t)[DIAG_CPU_TEST_REGS];

/*LDRA_EXCLUDE 63 D : <justification start> Function definition is present in corresponding source file, violation ignored <justification end> */
uint32_t DIAG_CPU_SelfTest_Subset1(void);
/*LDRA_EXCLUDE 63 D : <justification start> Function definition is present in corresponding source file, violation ignored <justification end> */
uint32_t DIAG_CPU_SelfTest_Subset2(void);
/*LDRA_EXCLUDE 63 D : <justification start> Function definition is present in corresponding source file, violation ignored <justification end> */
uint32_t DIAG_CPU_SelfTest_Subset3(void);
/*LDRA_EXCLUDE 63 D : <justification start> Function definition is present in corresponding source file, violation ignored <justification end> */
uint32_t DIAG_CPU_SelfTest_Subset4(void);
/*LDRA_EXCLUDE 63 D : <justification start> Function definition is present in corresponding source file, violation ignored <justification end> */
uint32_t DIAG_CPU_SelfTest_Subset5(void);
/*LDRA_EXCLUDE 63 D : <justification start> Function definition is present in corresponding source file, violation ignored <justification end> */
uint32_t DIAG_CPU_SelfTest_Subset6(void);
/*LDRA_EXCLUDE 63 D : <justification start> Function definition is present in corresponding source file, violation ignored <justification end> */
uint32_t DIAG_CPU_SelfTest_Subset7(void);
/*LDRA_EXCLUDE 63 D : <justification start> Function definition is present in corresponding source file, violation ignored <justification end> */
uint32_t DIAG_CPU_SelfTest_Subset8(void);

#ifdef	__cplusplus
}
#endif

#endif	/* DIAG_CPU_SHARED_H */

