/**
*   @file    Fls_Flash_Types.h   
*   @version 1.0.0
*
*   @brief   AUTOSAR Fls - AUTOSAR Module Flash Driver.
*   @details Definitions of Flash IP exported types.
*
*   @addtogroup FLS
*   @{
*/
/*==================================================================================================
*   Project              : AUTOSAR 4.3 MCAL
*   Platform             : PA
*   Peripheral           : IPV_FLASHV2
*   Dependencies         : none
*
*   Autosar Version      : 4.3.1
*   Autosar Revision     : ASR_REL_4_3_REV_0001
*   Autosar Conf.Variant :
*   SW Version           : 1.0.0
*   Build Version        : MPC5777C_MCAL_1_0_0_RTM_ASR_REL_4_3_REV_0001_20190315
*
*   (c) Copyright 2006-2016 Freescale Semiconductor, Inc. 
*       Copyright 2017-2019 NXP
*   All Rights Reserved.
==================================================================================================*/
/*==================================================================================================
==================================================================================================*/

#ifndef FLS_FLASH_TYPES_H
#define FLS_FLASH_TYPES_H

#ifdef __cplusplus
extern "C"{
#endif

/**
* @page misra_violations MISRA-C:2012 violations
*
* @section Fls_Flash_Type_h_REF_1
* Violates MISRA 2012 Advisory Rule 2.3, A project should not contain unused type declaration.
* This type may be called in user.
*
* @section Fls_Flash_Type_h_REF_2
* Violates MISRA 2012 Advisory Rule 2.5, A project should not contain unused macro declaration.
* This type may be called in user or support multi IPV
*
*/

/*==================================================================================================
*                                        INCLUDE FILES
* 1) system and project includes
* 2) needed interfaces from external units
* 3) internal and external interfaces from this unit
==================================================================================================*/

/*==================================================================================================
*                              SOURCE FILE VERSION INFORMATION
==================================================================================================*/
#define FLS_FLASH_TYPES_VENDOR_ID                    43
#define FLS_FLASH_TYPES_AR_RELEASE_MAJOR_VERSION     4
#define FLS_FLASH_TYPES_AR_RELEASE_MINOR_VERSION     3
#define FLS_FLASH_TYPES_AR_RELEASE_REVISION_VERSION  1
#define FLS_FLASH_TYPES_SW_MAJOR_VERSION             1
#define FLS_FLASH_TYPES_SW_MINOR_VERSION             0
#define FLS_FLASH_TYPES_SW_PATCH_VERSION             0
/*==================================================================================================
                                      FILE VERSION CHECKS
==================================================================================================*/

/*==================================================================================================
*                                      DEFINES AND MACROS
==================================================================================================*/
/**
* @brief          Return value for Fls_DsiHandler.
* @details        module doesn't feel responsible (e.g. address does not belong to its current job,
*                 there is no current pending read/compare job, the syndrome is different).
*
*/
/* @violates @ref Fls_Flash_Type_h_REF_2 A project should not contain unused macro declaration */
#define FLS_UNHANDLED       (0U)

/**
* @brief          Return value for Fls_DsiHandler.
* @details        module feels responsible, but wants to repeat the  causing instruction. 
*                 Maybe: it still uses information in MCM or ECSM module, but they are outdated 
*                (e.g. due to an erroneous DMA transfer in the meantime)
*
*/
/* @violates @ref Fls_Flash_Type_h_REF_2 A project should not contain unused macro declaration */
#define FLS_HANDLED_RETRY   1U

/**
* @brief          Return value for Fls_DsiHandler.
* @details        module feels responsible, the current job is marked as failed,
*                 processing may continue, skipping the causing instruction.
*
*/
/* @violates @ref Fls_Flash_Type_h_REF_2 A project should not contain unused macro declaration */
#define FLS_HANDLED_SKIP    (2U)  

/**
* @brief          Return value for Fls_DsiHandler and Fls_MciHandler.
* @details        module  feels responsible, but the only reaction is to stop the system 
*                 (e.g.: try to shut-down in a quite safe way)
*
*/
/* @violates @ref Fls_Flash_Type_h_REF_2 A project should not contain unused macro declaration */
#define FLS_HANDLED_STOP    3U

/*==================================================================================================
                                 STRUCTURES AND OTHER TYPEDEFS
==================================================================================================*/
/** 
    @brief FLASH physical sector description
*/
typedef struct
{
    P2VAR(volatile uint32, FLS_VAR, FLS_APPL_DATA) pSectorStartAddressPtr; /**< @brief FLASH physical sector start address */
    uint32 u32AddrSpaceBloSelValue; /**< @brief address space block select value */
    uint32 u32AddrSpaceBloLockValue; /**< @brief address space block lock value */
    uint32 u32SectorBloSelRegAddr;    /**< @brief block select register address */
    uint32 u32AddrSpaceBloLockRegAddr; /**< @brief address space block primary lock register address */
    boolean bEccTriggersExc; /**< @brief triggers reading ECC data exception */
    uint32 u32SectorId;    /**< @brief corresponding number in sector location to calc cfgCRC */       
} Fls_Flash_InternalSectorInfoType;

/**
* @brief          Return value of Fls handler function.
* @details        Fls_DsiHandler can return the following value:
*                 - FLS_UNHANDLED    Fls driver is not responsable for this situation
*                 - FLS_HANDLED_SKIP Fls driver is responsable for this exception and want to skip this job
*                 .
*/ 
/* @violates @ref Fls_Flash_Type_h_REF_1 A project should not contain unused type declaration */
typedef uint8_least Fls_CompHandlerReturnType;

typedef const uint8 * Fls_InstructionAddressType;
typedef const void * Fls_DataAddressType;

/**
* @brief          Detailed information on the exception.
* @details        The following information will be checked by the driver:
*                 - if there is a pending read, compare, 
*                 - data_pt matches address currently accessed by pending flash read or flash compare job, 
*                 - if the exception syndrome register indicates DSI or MCI reason, 
*                 .
*
*/
typedef struct
{
    Fls_InstructionAddressType instruction_pt; /**< @brief pointer to the instruction that generated the ECC */
    Fls_DataAddressType        data_pt;        /**< @brief data address that caused the ECC error */
    uint32                     syndrome_u32;   /**< @brief details on the type of exception */
} Fls_ExceptionDetailsType;
/* @violates @ref Fls_Flash_Type_h_REF_1 A project should not contain unused type declaration */
typedef const Fls_ExceptionDetailsType *ExceptionDetailsPtrType;

typedef uint32 Fls_Flash_DataBusWidthType;

#ifdef __cplusplus
}
#endif

#endif /* FLS_FLASH_TYPES_H */

/** @}*/
