/**
*   @file       Eth.h
*   @implements Eth.h_Artifact 
*   @version 1.0.0
*
*   @brief   AUTOSAR Eth driver interface header file
*   @details Implementation of the AUTOSAR Ethernet driver
*
*   @addtogroup ETH_DRIVER
*   @{
*/
/*==================================================================================================
*   Project              : AUTOSAR 4.3 MCAL
*   Platform             : PA
*   Peripheral           : FEC
*   Dependencies         : 
*
*   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 ETH_H
#define ETH_H
#ifdef __cplusplus
extern "C"{
#endif

/**
* @page misra_violations MISRA-C:2012 violations
* 
* @section Eth_h_REF_1
* Violates MISRA 2012 Required Directive 4.10, Precautions shall be taken in order to prevent the contents
* of a header file being included more than once. This comes from the order of includes in the .c file
* and from include dependencies. As a safe approach, any file must include all its dependencies.
* Header files are already protected against double inclusions. The inclusion of Eth_Memmap.h is as
* per AUTOSAR requirement (SWS_MemMap_00003)
*
* @section [global]
*          Violates MISRA 2012 Required Rule 5.1, External identifiers shall be distinct.
*          The used compilers use more than 31 chars for identifiers.
*
* @section [global]
*          Violates MISRA 2012 Required Rule 5.2, Identifiers declared in the same scope and name space shall be distinct.
*          The used compilers use more than 31 chars for identifiers.
*
* @section [global]
*          Violates MISRA 2012 Required Rule 5.4, Macro identifiers shall be distinct.
*          The used compilers use more than 31 chars for identifiers.
*
* @section [global]
*          Violates MISRA 2012 Required Rule 5.5, Identifiers shall be distinct from macro names.
*          The used compilers use more than 31 chars for identifiers.
*
* @section Eth_h_REF_2
* Violates MISRA 2012 Advisory Rule 2.5, A project should not contain unused macro declarations.
*
*/

/*==================================================================================================
*                                        INCLUDE FILES
* 1) system and project includes
* 2) needed interfaces from external units
* 3) internal and external interfaces from this unit
==================================================================================================*/
#include "Eth_GeneralTypes.h"  /* Mandatory include - see the SWS */
#include "Eth_Cfg.h" /* Mandatory include - see the SWS */
/*==================================================================================================
*                              SOURCE FILE VERSION INFORMATION
==================================================================================================*/
/** @implements Eth_Version_define */
#define ETH_VENDOR_ID                    43
/* @violates @ref Eth_h_REF_2  These macros are used depending on the configuration, so this violation cannot be avoided.  */
#define ETH_MODULE_ID                    88
#define ETH_AR_RELEASE_MAJOR_VERSION     4
#define ETH_AR_RELEASE_MINOR_VERSION     3
#define ETH_AR_RELEASE_REVISION_VERSION  1
#define ETH_SW_MAJOR_VERSION             1
#define ETH_SW_MINOR_VERSION             0
#define ETH_SW_PATCH_VERSION             0

/*==================================================================================================
*                                     FILE VERSION CHECKS
==================================================================================================*/
/* Check if current file and ETH configuration header file are of the same vendor */
#if (ETH_VENDOR_ID != ETH_VENDOR_ID_CFG)
    #error "Eth.h and Eth_Cfg.h have different vendor ids"
#endif
/* Check if current file and ETH configuration header file are of the same Autosar version */
#if ((ETH_AR_RELEASE_MAJOR_VERSION    != ETH_AR_RELEASE_MAJOR_VERSION_CFG) || \
     (ETH_AR_RELEASE_MINOR_VERSION    != ETH_AR_RELEASE_MINOR_VERSION_CFG) || \
     (ETH_AR_RELEASE_REVISION_VERSION != ETH_AR_RELEASE_REVISION_VERSION_CFG))
    #error "AutoSar Version Numbers of Eth.h and Eth_Cfg.h are different"
#endif
/* Check if current file and ETH configuration header file are of the same software version */
#if ((ETH_SW_MAJOR_VERSION != ETH_SW_MAJOR_VERSION_CFG) || \
     (ETH_SW_MINOR_VERSION != ETH_SW_MINOR_VERSION_CFG) || \
     (ETH_SW_PATCH_VERSION != ETH_SW_PATCH_VERSION_CFG))
    #error "Software Version Numbers of Eth.h and Eth_Cfg.h are different"
#endif

/*==================================================================================================
*                                          CONSTANTS
==================================================================================================*/
/* Service IDs definition */
/* @violates @ref Eth_h_REF_2  These macros are used depending on the configuration, so this violation cannot be avoided.  */
#define ETH_SID_INIT                    0x01
/* @violates @ref Eth_h_REF_2  These macros are used depending on the configuration, so this violation cannot be avoided.  */
#define ETH_SID_CONTROLLERINIT          0x02
/* @violates @ref Eth_h_REF_2  These macros are used depending on the configuration, so this violation cannot be avoided.  */
#define ETH_SID_SETCONTROLLERMODE       0x03
/* @violates @ref Eth_h_REF_2  These macros are used depending on the configuration, so this violation cannot be avoided.  */
#define ETH_SID_GETCONTROLLERMODE       0x04
/* @violates @ref Eth_h_REF_2  These macros are used depending on the configuration, so this violation cannot be avoided.  */
#define ETH_SID_GETPHYSADDR             0x08
/* @violates @ref Eth_h_REF_2  These macros are used depending on the configuration, so this violation cannot be avoided.  */
#define ETH_SID_WRITEMII                0x05
/* @violates @ref Eth_h_REF_2  These macros are used depending on the configuration, so this violation cannot be avoided.  */
#define ETH_SID_READMII                 0x06
/* @violates @ref Eth_h_REF_2  These macros are used depending on the configuration, so this violation cannot be avoided.  */
#define ETH_SID_GETCOUNTERSTATE         0x07
/* @violates @ref Eth_h_REF_2  These macros are used depending on the configuration, so this violation cannot be avoided.  */
#define ETH_SID_PROVIDETXBUFFER         0x09
/* @violates @ref Eth_h_REF_2  These macros are used depending on the configuration, so this violation cannot be avoided.  */
#define ETH_SID_TRANSMIT                0x0A
/* @violates @ref Eth_h_REF_2  These macros are used depending on the configuration, so this violation cannot be avoided.  */
#define ETH_SID_RECEIVE                 0x0B
/* @violates @ref Eth_h_REF_2  These macros are used depending on the configuration, so this violation cannot be avoided.  */
#define ETH_SID_TXCONFIRMATION          0x0C
/* @violates @ref Eth_h_REF_2  These macros are used depending on the configuration, so this violation cannot be avoided.  */
#define ETH_SID_GETVERSIONINFO          0x0D
/* @violates @ref Eth_h_REF_2  These macros are used depending on the configuration, so this violation cannot be avoided.  */
#define ETH_SID_SETPHYSADDR             0x13
/* @violates @ref Eth_h_REF_2  These macros are used depending on the configuration, so this violation cannot be avoided.  */
#define ETH_SID_UPDATEADDRFILTER        0x12
/* @violates @ref Eth_h_REF_2  These macros are used depending on the configuration, so this violation cannot be avoided.  */
#define ETH_SID_GETCOUNTERVALUE         0x14
/* @violates @ref Eth_h_REF_2  These macros are used depending on the configuration, so this violation cannot be avoided.  */
#define ETH_SID_GETRXSTATS              0x15
/* @violates @ref Eth_h_REF_2  These macros are used depending on the configuration, so this violation cannot be avoided.  */
#define ETH_SID_GETCURRENTTIME          0x16
/* @violates @ref Eth_h_REF_2  These macros are used depending on the configuration, so this violation cannot be avoided.  */
#define ETH_SID_ENABLEEGRESSTIMESTAMP   0x17
/* @violates @ref Eth_h_REF_2  These macros are used depending on the configuration, so this violation cannot be avoided.  */
#define ETH_SID_GETEGRESSTIMESTAMP      0x18
/* @violates @ref Eth_h_REF_2  These macros are used depending on the configuration, so this violation cannot be avoided.  */
#define ETH_SID_GETINGRESSTIMESTAMP     0x19
/* @violates @ref Eth_h_REF_2  These macros are used depending on the configuration, so this violation cannot be avoided.  */
#define ETH_SID_SETCORRECTIONTIME       0x1A
/* @violates @ref Eth_h_REF_2  These macros are used depending on the configuration, so this violation cannot be avoided.  */
#define ETH_SID_SETGLOBALTIME           0x1B
/* @violates @ref Eth_h_REF_2  These macros are used depending on the configuration, so this violation cannot be avoided.  */
#define ETH_SID_GETTXSTATS              0x1C
/* @violates @ref Eth_h_REF_2  These macros are used depending on the configuration, so this violation cannot be avoided.  */
#define ETH_SID_GETTXERRORCOUNTERVALUE     0x1D
/* DET error codes */
#if STD_ON == ETH_DEV_ERROR_DETECT
/** @implements Eth_DetErrorIds_define */
#define ETH_E_INV_CTRL_IDX      ((uint8)0x01)
#define ETH_E_UNINIT            ((uint8)0x02)
#define ETH_E_PARAM_POINTER     ((uint8)0x03)
#define ETH_E_INV_PARAM         ((uint8)0x04)
#define ETH_E_INV_MODE          ((uint8)0x05)
#endif
/* Define Specific Error code for Std_ReturnType */
/* @violates @ref Eth_h_REF_2 */
#define ETH_E_NO_ACCESS         ((uint8)0x03U)

/*==================================================================================================
*                                      DEFINES AND MACROS
==================================================================================================*/

/*==================================================================================================
*                                             ENUMS
==================================================================================================*/

/*==================================================================================================
*                                STRUCTURES AND OTHER TYPEDEFS
==================================================================================================*/

/*==================================================================================================
*                                GLOBAL VARIABLE DECLARATIONS
==================================================================================================*/
 

#define ETH_START_SEC_VAR_INIT_UNSPECIFIED
/* @violates @ref Eth_h_REF_1 This violation is not fixed since the inclusion of Eth_MemMap.h is as per AUTOSAR requirement*/
#include "Eth_MemMap.h"

/***************************************************************************
* AUTOSAR Debugging Variables
***************************************************************************/
/* Eth_CtrlState: Used to store state of Eth controller(s). */
extern VAR(volatile Eth_StateType, ETH_VAR) Eth_CtrlState[ETH_MAXCTRLS_SUPPORTED];


#define ETH_STOP_SEC_VAR_INIT_UNSPECIFIED
/* @violates @ref Eth_h_REF_1 This violation is not fixed since the inclusion of Eth_MemMap.h is as per AUTOSAR requirement*/
#include "Eth_MemMap.h"


#if STD_ON == DEBUG_VARIABLES
#define ETH_START_SEC_VAR_INIT_32
/* @violates @ref Eth_h_REF_1 This violation is not fixed since the inclusion of Eth_MemMap.h is as per AUTOSAR requirement*/
#include "Eth_MemMap.h"
extern VAR(uint32, ETH_VAR) Eth_RxBuffersOverflow[ETH_MAXCTRLS_SUPPORTED];
extern VAR(uint32, ETH_VAR) Eth_MiiFailed[ETH_MAXCTRLS_SUPPORTED];

#define ETH_STOP_SEC_VAR_INIT_32
/* @violates @ref Eth_h_REF_1 This violation is not fixed since the inclusion of Eth_MemMap.h is as per AUTOSAR requirement*/
#include "Eth_MemMap.h"
#endif     
    
/*==================================================================================================
*                                    FUNCTION PROTOTYPES
==================================================================================================*/
#define ETH_START_SEC_CODE
/* @violates @ref Eth_h_REF_1 This violation is not fixed since the inclusion of Eth_MemMap.h is as per AUTOSAR requirement*/
#include "Eth_MemMap.h"


extern FUNC(void, ETH_CODE) Eth_Init(P2CONST(Eth_ConfigType, AUTOMATIC, ETH_APPL_CONST) CfgPtr); 
extern FUNC(Std_ReturnType, ETH_CODE) Eth_SetControllerMode ( \
                                    VAR(uint8, AUTOMATIC) CtrlIdx, \
                                    VAR(Eth_ModeType, AUTOMATIC) CtrlMode \
                                                            );
extern FUNC(Std_ReturnType, ETH_CODE) Eth_GetControllerMode ( \
                                    VAR(uint8, AUTOMATIC) CtrlIdx, \
                                    P2VAR(Eth_ModeType, AUTOMATIC, ETH_APPL_DATA) CtrlModePtr \
                                                            );
extern FUNC(void, ETH_CODE) Eth_GetPhysAddr ( \
                        VAR(uint8, AUTOMATIC) CtrlIdx, \
                        P2VAR(uint8, AUTOMATIC, ETH_APPL_DATA) PhysAddrPtr \
                                            );
extern FUNC(void, ETH_CODE) Eth_SetPhysAddr(VAR(uint8, AUTOMATIC) CtrlIdx, P2CONST(uint8, AUTOMATIC, ETH_APPL_CONST) PhysAddrPtr);

#if STD_ON == ETH_UPDATE_PHYS_ADDR_FILTER
    extern FUNC(Std_ReturnType, ETH_CODE) Eth_UpdatePhysAddrFilter  ( \
                                            VAR(uint8, AUTOMATIC) CtrlIdx, \
                                            P2CONST(uint8, AUTOMATIC, ETH_APPL_CONST) PhysAddrPtr, \
                                            VAR(Eth_FilterActionType, AUTOMATIC) Action \
                                                                    );
#endif /* ETH_UPDATE_PHYS_ADDR_FILTER */
#if STD_ON == ETH_GETCOUNTVALAPI
extern FUNC(Std_ReturnType, ETH_CODE) Eth_GetCounterValues ( \
                                        VAR(uint8, AUTOMATIC) CtrlIdx, \
                                        P2VAR(Eth_CounterType, AUTOMATIC, ETH_APPL_DATA) CounterPtr \
                                                );
#endif

#if STD_ON == ETH_CTRLENABLE_MII
extern FUNC(Std_ReturnType, ETH_CODE) Eth_WriteMii ( \
                                VAR(uint8, AUTOMATIC) CtrlIdx, \
                                VAR(uint8, AUTOMATIC) TrcvIdx, \
                                VAR(uint8, AUTOMATIC) RegIdx, \
                                VAR(uint16, AUTOMATIC) RegVal \
                                                    );
extern FUNC(Std_ReturnType, ETH_CODE) Eth_ReadMii   ( \
                                VAR(uint8, AUTOMATIC) CtrlIdx, \
                                VAR(uint8, AUTOMATIC) TrcvIdx, \
                                VAR(uint8, AUTOMATIC) RegIdx, \
                                P2VAR(uint16, AUTOMATIC, ETH_APPL_DATA) RegValPtr \
                                                    );
#endif /* ETH_CTRLENABLE_MII */

#if STD_ON == ETH_GET_RXSTATS_API
extern FUNC(Std_ReturnType, ETH_CODE) Eth_GetRxStats ( \
                                VAR(uint8, AUTOMATIC) CtrlIdx, \
                                P2VAR(Eth_RxStatsType, AUTOMATIC, ETH_APPL_DATA) RxStats \
                                              );
#endif
#if STD_ON == ETH_GET_TXSTATS_API
extern FUNC(Std_ReturnType, ETH_CODE) Eth_GetTxStats ( \
                                VAR(uint8, AUTOMATIC) CtrlIdx, \
                                P2VAR(Eth_TxStatsType, AUTOMATIC, ETH_APPL_DATA) TxStats \
                                              );
#endif
#if STD_ON == ETH_GET_GETTXCOUNT_API
extern FUNC(Std_ReturnType, ETH_CODE) Eth_GetTxErrorCounterValues ( \
                                VAR(uint8, AUTOMATIC) CtrlIdx, \
                                P2VAR(Eth_TxErrorCounterValuesType, AUTOMATIC, ETH_APPL_DATA) TxErrorCounterValues \
                                              );
#endif
#if STD_ON == ETH_GLOBALTIME_SUPPORT
extern FUNC(Std_ReturnType, ETH_CODE) Eth_GetCurrentTime  ( \
                                VAR(uint8, AUTOMATIC) CtrlIdx, \
                                P2VAR(Eth_TimeStampQualType, AUTOMATIC, ETH_APPL_DATA) timeQualPtr, \
                                P2VAR(Eth_TimeStampType, AUTOMATIC, ETH_APPL_DATA) timeStampPtr \
                                                           );
extern FUNC(void, ETH_CODE) Eth_EnableEgressTimeStamp   ( \
                                VAR(uint8, AUTOMATIC) CtrlIdx, \
                                VAR(Eth_BufIdxType, AUTOMATIC) BufIdx \
                                                        );
extern FUNC(void, ETH_CODE) Eth_GetEgressTimeStamp  ( \
                                VAR(uint8, AUTOMATIC) CtrlIdx, \
                                VAR(Eth_BufIdxType, AUTOMATIC) BufIdx, \
                                P2VAR(Eth_TimeStampQualType, AUTOMATIC, ETH_APPL_DATA) timeQualPtr, \
                                P2VAR(Eth_TimeStampType, AUTOMATIC, ETH_APPL_DATA) timeStampPtr \
                                                    );
extern FUNC(void, ETH_CODE) Eth_GetIngressTimeStamp ( \
                                VAR(uint8, AUTOMATIC) CtrlIdx, \
                                P2VAR(Eth_DataType, AUTOMATIC, ETH_APPL_DATA) DataPtr, \
                                P2VAR(Eth_TimeStampQualType, AUTOMATIC, ETH_APPL_DATA) timeQualPtr, \
                                P2VAR(Eth_TimeStampType, AUTOMATIC, ETH_APPL_DATA) timeStampPtr \
                                                    );
#endif

extern FUNC(BufReq_ReturnType, ETH_CODE) Eth_ProvideTxBuffer( \
                                VAR(uint8, AUTOMATIC) CtrlIdx, \
                                VAR(uint8, AUTOMATIC) Priority, \
                                P2VAR(Eth_BufIdxType, AUTOMATIC, ETH_APPL_DATA) BufIdxPtr, \
                                P2P2VAR(uint8, AUTOMATIC, ETH_APPL_DATA) BufPtr, \
                                P2VAR(uint16, AUTOMATIC, ETH_APPL_DATA) LenBytePtr \
                                                            );
extern FUNC(Std_ReturnType, ETH_CODE) Eth_Transmit  (
                            VAR(uint8, AUTOMATIC) CtrlIdx,
                            VAR(Eth_BufIdxType, AUTOMATIC) BufIdx,
                            Eth_FrameType FrameType,
                            VAR(boolean, AUTOMATIC) TxConfirmation,
                            VAR(uint16, AUTOMATIC) LenByte,
                            P2CONST(uint8, AUTOMATIC, ETH_APPL_DATA) PhysAddrPtr
#if STD_ON == ETH_BRIDGE_SUPPORT
                          , P2CONST(uint8, AUTOMATIC, ETH_APPL_DATA) PhysSourceAddrPtr
#endif /* ETH_BRIDGE_SUPPORT  */  
                                                    );
extern FUNC(void, ETH_CODE) Eth_Receive(VAR(uint8, AUTOMATIC) CtrlIdx, \
                                    VAR(uint8, AUTOMATIC) FifoIdx,  \
                                    P2VAR(Eth_RxStatusType, AUTOMATIC, ETH_APPL_DATA) RxStatusPtr   \
                                 ) ;
extern FUNC(void, ETH_CODE) Eth_TxConfirmation(VAR(uint8, AUTOMATIC) CtrlIdx);

#if STD_ON == ETH_VERSION_INFO_API
    #if STD_OFF == ETH_VERSION_INFO_API_MACRO
        extern FUNC(void, ETH_CODE) Eth_GetVersionInfo(P2VAR(Std_VersionInfoType, AUTOMATIC, ETH_APPL_DATA) VersionInfoPtr);
    #endif /* ETH_VERSION_INFO_API_MACRO */
#endif /* ETH_VERSION_INFO_API */
extern FUNC(void, ETH_CODE) Eth_MainFunction(VAR(void, AUTOMATIC));
#define ETH_STOP_SEC_CODE
/* @violates @ref Eth_h_REF_1 This violation is not fixed since the inclusion of Eth_MemMap.h is as per AUTOSAR requirement*/
#include "Eth_MemMap.h"

#ifdef __cplusplus
}
#endif

#endif /* ETH_H */

/** @} */
