/**
*   @file    Eth_Fec.h
*   @version 0.4.3
*
*   @brief   FEC controller interface header file
*   @details Implementation of the FEC controller interface for
*            the 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_FEC_H
#define ETH_FEC_H
#ifdef __cplusplus
extern "C"{
#endif

/**
* @page misra_violations MISRA-C:2012 violations
* 
* @section Eth_Fec_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_Fec_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
==================================================================================================*/

/*==================================================================================================
*                              SOURCE FILE VERSION INFORMATION
==================================================================================================*/
#define ETH_VENDOR_ID_FEC                    43
/* @violates @ref Eth_Fec_h_REF_2  These macros are used depending on the configuration, so this violation cannot be avoided.  */
#define ETH_MODULE_ID_FEC                   88
#define ETH_AR_RELEASE_MAJOR_VERSION_FEC     4
#define ETH_AR_RELEASE_MINOR_VERSION_FEC     3
#define ETH_AR_RELEASE_REVISION_VERSION_FEC  1
#define ETH_SW_MAJOR_VERSION_FEC             1
#define ETH_SW_MINOR_VERSION_FEC             0
#define ETH_SW_PATCH_VERSION_FEC             0

/*==================================================================================================
*                                     FILE VERSION CHECKS
==================================================================================================*/
/* Check if current file and ETH configuration header file are of the same vendor */
#if (ETH_VENDOR_ID_FEC != ETH_VENDOR_ID_CFG)
#error "Eth_Fec.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_FEC != ETH_AR_RELEASE_MAJOR_VERSION_CFG) || \
     (ETH_AR_RELEASE_MINOR_VERSION_FEC != ETH_AR_RELEASE_MINOR_VERSION_CFG) || \
     (ETH_AR_RELEASE_REVISION_VERSION_FEC != ETH_AR_RELEASE_REVISION_VERSION_CFG))
#error "AutoSar Version Numbers of Eth_Fec.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_FEC != ETH_SW_MAJOR_VERSION_CFG) || \
     (ETH_SW_MINOR_VERSION_FEC != ETH_SW_MINOR_VERSION_CFG) || \
     (ETH_SW_PATCH_VERSION_FEC != ETH_SW_PATCH_VERSION_CFG))
#error "Software Version Numbers of Eth_Fec.h and Eth_Cfg.h are different"
#endif

/*==================================================================================================
*                                          CONSTANTS
==================================================================================================*/

/*==================================================================================================
*                                             ENUMS
==================================================================================================*/
/**
* @brief Type used to return receive buffer status
*/
typedef enum
{
    RX_BUF_EMPTY = 0,         /**< Buffer is empty */
    RX_BUF_SINGLE,            /**< Buffer is full and the received frame
                                                  is within single buffer */
    RX_BUF_MULTI_UNFINISHED,  /**< Buffer is full but the frame reception
                                                has not been finished yet */
    RX_BUF_MULTI_FINISHED,    /**< Buffer is full and it is the last buffer
                              in the row of buffers occupied by one frame */
    RX_BUF_OVERFLOW           /**< Some frame occupies all available buffers
                                      so there is no space to put its end */ 
} Eth_Fec_enRxBufferType;

#define ETH_START_SEC_VAR_INIT_UNSPECIFIED
/* @violates @ref Eth_Fec_h_REF_1 This violation is not fixed since the inclusion of Eth_MemMap.h is as per AUTOSAR requirement*/
/* @violates @ref Eth_Fec_h_REF_2 Eth_MemMap.h is included after each section define in order to set the current memory section as defined by AUTOSAR */
#include "Eth_MemMap.h"

extern P2CONST(Eth_ConfigType, ETH_VAR, ETH_APPL_CONST) Eth_InternalCfgPtr;

#define ETH_STOP_SEC_VAR_INIT_UNSPECIFIED
/* @violates @ref Eth_Fec_h_REF_1 This violation is not fixed since the inclusion of Eth_MemMap.h is as per AUTOSAR requirement*/
/* @violates @ref Eth_Fec_h_REF_2 Eth_MemMap.h is included after each section define in order to set the current memory section as defined by AUTOSAR */
#include "Eth_MemMap.h"    

#define ETH_START_SEC_CODE
/* @violates @ref Eth_Fec_h_REF_1 This violation is not fixed since the inclusion of Eth_MemMap.h is as per AUTOSAR requirement*/
/* @violates @ref Eth_Fec_h_REF_2 Eth_MemMap.h is included after each section define in order to set the current memory section as defined by AUTOSAR */
#include "Eth_MemMap.h"
extern FUNC(void, ETH_CODE) Eth_Fec_ResetController(CONST(uint8, AUTOMATIC) u8CtrlIdx);
extern FUNC(boolean, ETH_CODE) Eth_Fec_CheckAccessToCtrl(CONST(uint8, AUTOMATIC) u8CtrlIdx);
extern FUNC(void, ETH_CODE) Eth_Fec_ReportTransmission(CONST(uint8, AUTOMATIC) u8CtrlIdx, CONST(uint8, AUTOMATIC) u8FifoIdx);
extern FUNC(Eth_RxStatusType, ETH_CODE) Eth_Fec_ReportReception ( \
                                                CONST(uint8, AUTOMATIC) u8CtrlIdx, \
                                                CONST(uint8, AUTOMATIC) u8FifoIdx, \
                                                CONST(boolean, AUTOMATIC) bIrq \
                                                         );
extern FUNC(void, ETH_CODE) Eth_Fec_MainFunction(VAR(void, AUTOMATIC));
extern FUNC(void, ETH_CODE) Eth_Fec_ConfigureCtrl(CONST(uint8, AUTOMATIC) u8CtrlIdx);
extern FUNC(void, ETH_CODE) Eth_Fec_EnableController(CONST(uint8, AUTOMATIC) u8CtrlIdx);
extern FUNC(void, ETH_CODE) Eth_Fec_DisableController(CONST(uint8, AUTOMATIC) u8CtrlIdx);
extern FUNC(Eth_ModeType, ETH_CODE) Eth_Fec_CheckCtrlIsActive(CONST(uint8, AUTOMATIC) u8CtrlIdx);
extern FUNC(uint16, ETH_CODE) Eth_Fec_GetPhysAddressHigh(CONST(uint8, AUTOMATIC) u8CtrlIdx);
extern FUNC(uint32, ETH_CODE) Eth_Fec_GetPhysAddressLow(CONST(uint8, AUTOMATIC) u8CtrlIdx);
extern FUNC(uint8, ETH_CODE) Eth_Fec_FindFifoIdx(CONST(uint8, AUTOMATIC) u8CtrlIdx, CONST(Eth_BufIdxType, AUTOMATIC) BufIdx);
#if STD_ON == ETH_GETCOUNTVALAPI 
extern FUNC(void, ETH_CODE) Eth_Fec_GetCounterValues  ( \
                       VAR(uint8, AUTOMATIC) u8CtrlIdx, \
                       P2VAR(Eth_CounterType, AUTOMATIC, ETH_APPL_DATA) CounterPtr \
                                                        );
#endif
#if STD_ON == ETH_GET_RXSTATS_API
extern FUNC(void, ETH_CODE) Eth_Fec_GetRxStats ( \
                        VAR(uint8, AUTOMATIC) u8CtrlIdx, \
                        P2VAR(Eth_RxStatsType, AUTOMATIC, ETH_APPL_DATA) RxStats \
                                        );
#endif
#if STD_ON == ETH_GET_TXSTATS_API
extern FUNC(void, ETH_CODE) Eth_Fec_GetTxStats ( \
                               VAR(uint8, AUTOMATIC) u8CtrlIdx, \
                               P2VAR(Eth_TxStatsType, AUTOMATIC, ETH_APPL_DATA) TxStats \
                                           );
#endif
#if STD_ON == ETH_GET_GETTXCOUNT_API
extern FUNC(void, ETH_CODE) Eth_Fec_GetTxErrorCounterValues ( \
                               VAR(uint8, AUTOMATIC) u8CtrlIdx, \
                               P2VAR(Eth_TxErrorCounterValuesType, AUTOMATIC, ETH_APPL_DATA) TxErrorCounterValues \
                                           );
#endif
extern FUNC(boolean, ETH_CODE) Eth_Fec_SetPhysAddr(CONST(uint8, AUTOMATIC) u8CtrlIdx, P2CONST(uint8, AUTOMATIC, ETH_APPL_CONST) pPhysAddrPtr);
#if STD_ON == ETH_UPDATE_PHYS_ADDR_FILTER
    extern FUNC(void, ETH_CODE) Eth_Fec_UpdtePhysAddrFiltr  ( \
                            CONST(uint8, AUTOMATIC) u8CtrlIdx, \
                            P2CONST(uint8, AUTOMATIC, ETH_APPL_CONST) pPhysAddrPtr, \
                            VAR(Eth_FilterActionType, AUTOMATIC) eAction \
                                                            );
#endif /* ETH_UPDATE_PHYS_ADDR_FILTER */
extern FUNC(void, ETH_CODE) Eth_Fec_ClearTxIrqFlag(CONST(uint8, AUTOMATIC) u8CtrlIdx, CONST(uint8, AUTOMATIC) u8FifoIdx);
extern FUNC(void, ETH_CODE) Eth_Fec_ClearRxIrqFlag(CONST(uint8, AUTOMATIC) u8CtrlIdx, CONST(uint8, AUTOMATIC) u8FifoIdx);
extern FUNC(boolean, ETH_CODE) Eth_Fec_IsTxIrqFlagSet(CONST(uint8, AUTOMATIC) u8CtrlIdx, CONST(uint8, AUTOMATIC) u8FifoIdx);
extern FUNC(boolean, ETH_CODE) Eth_Fec_IsRxIrqFlagSet(CONST(uint8, AUTOMATIC) u8CtrlIdx, CONST(uint8, AUTOMATIC) u8FifoIdx);
extern FUNC(boolean, ETH_CODE) Eth_Fec_IsTxIrqEnabled(CONST(uint8, AUTOMATIC) u8CtrlIdx, CONST(uint8, AUTOMATIC) u8FifoIdx);
extern FUNC(boolean, ETH_CODE) Eth_Fec_IsRxIrqEnabled(CONST(uint8, AUTOMATIC) u8CtrlIdx, CONST(uint8, AUTOMATIC) u8FifoIdx);
extern FUNC(boolean, ETH_CODE) Eth_Fec_BorrowTxBuffer  ( \
                    CONST(uint8, AUTOMATIC) u8CtrlIdx, \
                    CONST(uint8, AUTOMATIC) u8FifoIdx, \
                    CONSTP2VAR(Eth_BufIdxType, AUTOMATIC, ETH_APPL_DATA) pBufIdx, \
                    P2P2VAR(Eth_DataType, AUTOMATIC, ETH_APPL_DATA) pBufPtr, \
                    CONSTP2VAR(uint16, AUTOMATIC, ETH_APPL_DATA) pBufLength\
                                                );
extern FUNC(boolean, ETH_CODE) Eth_Fec_IsTxBufLockedBT(CONST(uint8, AUTOMATIC) u8CtrlIdx, \
                                                CONST(uint8, AUTOMATIC) u8FifoIdx, \
                                                CONST(Eth_BufIdxType, AUTOMATIC) u8BufIdx \
                                                );
extern FUNC(void, ETH_CODE) Eth_Fec_Transmit  (
                        CONST(uint8, AUTOMATIC) u8CtrlIdx,
                        CONST(uint8, AUTOMATIC) u8FifoIdx,
                        CONST(Eth_BufIdxType, AUTOMATIC) u8BufIdx,
                        CONST(Eth_FrameType, AUTOMATIC) u16Type,
                        CONST(uint16, AUTOMATIC) u16Length,
                        CONST(boolean, AUTOMATIC) bConfirm,
                        P2CONST(uint8, AUTOMATIC, ETH_APPL_DATA) pDest
#if STD_ON == ETH_BRIDGE_SUPPORT
                      , P2CONST(uint8, AUTOMATIC, ETH_APPL_DATA) pSource
#endif /* ETH_BRIDGE_SUPPORT  */
                                        );
    
#if STD_ON == ETH_CTRLENABLE_MII
extern FUNC(boolean, ETH_CODE) Eth_Fec_DoMiiMMF ( \
                        CONST(uint8, AUTOMATIC) u8CtrlIdx, \
                        CONST(uint8, AUTOMATIC) u8Trcv, \
                        CONST(uint8, AUTOMATIC) u8Reg, \
                        CONSTP2VAR(uint16, AUTOMATIC, ETH_APPL_DATA) pData, \
                        CONST(uint32, AUTOMATIC) u32Operation \
                                                    );
#endif /* ETH_CTRLENABLE_MII */
#define ETH_STOP_SEC_CODE
/* @violates @ref Eth_Fec_h_REF_1 This violation is not fixed since the inclusion of Eth_MemMap.h is as per AUTOSAR requirement*/
/* @violates @ref Eth_Fec_h_REF_2 Eth_MemMap.h is included after each section define in order to set the current memory section as defined by AUTOSAR */
#include "Eth_MemMap.h"
#ifdef __cplusplus
}
#endif

#endif /* ETH_FEC_LLD_H */
/** @} */
