/**
*   @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_sram_shared.h
 *  @version       	1.0
 *  @brief     		This file has the declarations for the common macros and functions
 *                  that are shared by all the sram module diagnostics 
 *************************************************************************/

/**
 * @defgroup functions Functions
 * @defgroup macros Macros
 * @defgroup errorcodes ErrorCodes
 * @defgroup enums Enums
 * @defgroup struct Struct
*/
 
#ifndef DIAG_SRAM_SHARED_H
#define DIAG_SRAM_SHARED_H

#include <stdint.h>
#include <stddef.h>
#include "diag_sram.h"

#define DIAG_SRAM_MEMORY_BLOCK_SIZE 128U

#define DIAG_SRAM_XMEM_REG_BASE_ADDR &RAMXECCCON

#define DIAG_SRAM_YMEM_REG_BASE_ADDR &RAMYECCCON

#define DIAG_SRAM_XMEM_START_ADDR 0x4000U

#define DIAG_SRAM_YMEM_START_ADDR 0x6000U

#define DIAG_SRAM_XMEM_BOUNDARY_ADDR 0x00006000U

#define DIAG_SRAM_SINGLE_BIT_FAULT_MASK 0x00003FC0U

#define DIAG_SRAM_ECC_ENABLE_MASK 0x00008000U

#define DIAG_SRAM_ECC_FLTINJ_ENABLE_MASK 0x00000001U

#define DIAG_SRAM_ECC_CONTROL_REG_INDEX 0U

#define DIAG_SRAM_FAULT_ADDRESS_INDEX 3U

#define DIAG_SRAM_FAULT_POINTER_INDEX 2U

#define DIAG_SRAM_MAX_FAULT_BIT_VALUE 38U

#define DIAG_SRAM_SAMPLE_FAULT_DATA 0xDEADBEEFU

#define DIAG_INTR_REQ_STATUS_FLAG_REG0 &IFS0

#define DIAG_INTR_REQ_ENABLE_REG0 &IEC0 

#define DIAG_SRAM_ERROR_TYPES 2U

#define DIAG_SRAM_X_MEM_ECC_INTR_FLAG_MASK 0x00000004U

#define DIAG_SRAM_Y_MEM_ECC_INTR_FLAG_MASK 0x00000008U

#define DIAG_SRAM_INTERRUPT_SWITCH_TIMEOUT 5000U

typedef volatile uint32_t (*sramMemoryAddr_t)[DIAG_SRAM_MEMORY_BLOCK_SIZE];

void DIAG_SRAM_SetRetValue(uint32_t returnValue);

uint32_t DIAG_SRAM_GetRetValue(void);

#endif //DIAG_SRAM_SHARED_H
