/**
*   @file    Eth_Ipw.h
*   @version 1.0.0
*
*   @brief   AUTOSAR Eth driver implementation 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_IPW_H
    #define ETH_IPW_H
#ifdef __cplusplus
extern "C"{
#endif

/**
* @page misra_violations MISRA-C:2012 violations
* 
* @section Eth_Ipw_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_Ipw_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_Fec.h" /* Lower layer header */
/*==================================================================================================
*                              SOURCE FILE VERSION INFORMATION
==================================================================================================*/
#define ETH_VENDOR_ID_ETHIPW_H                    43
/* @violates @ref Eth_Ipw_h_REF_2 */
#define ETH_MODULE_ID_ETHIPW_H                    88
#define ETH_AR_RELEASE_MAJOR_VERSION_ETHIPW_H     4
#define ETH_AR_RELEASE_MINOR_VERSION_ETHIPW_H     3
#define ETH_AR_RELEASE_REVISION_VERSION_ETHIPW_H  1
#define ETH_SW_MAJOR_VERSION_ETHIPW_H             1
#define ETH_SW_MINOR_VERSION_ETHIPW_H             0
#define ETH_SW_PATCH_VERSION_ETHIPW_H             0

/*==================================================================================================
*                                     FILE VERSION CHECKS
==================================================================================================*/
/* Check if current file and ETH configuration header file are of the same vendor */
#if (ETH_VENDOR_ID_ETHIPW_H != ETH_VENDOR_ID_CFG)
#error "Eth_Ipw.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_ETHIPW_H != ETH_AR_RELEASE_MAJOR_VERSION_CFG) || \
     (ETH_AR_RELEASE_MINOR_VERSION_ETHIPW_H != ETH_AR_RELEASE_MINOR_VERSION_CFG) || \
     (ETH_AR_RELEASE_REVISION_VERSION_ETHIPW_H != ETH_AR_RELEASE_REVISION_VERSION_CFG))
#error "AutoSar Version Numbers of Eth_Ipw.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_ETHIPW_H != ETH_SW_MAJOR_VERSION_CFG) || \
     (ETH_SW_MINOR_VERSION_ETHIPW_H != ETH_SW_MINOR_VERSION_CFG) || \
     (ETH_SW_PATCH_VERSION_ETHIPW_H != ETH_SW_PATCH_VERSION_CFG))
#error "Software Version Numbers of Eth_Ipw.h and Eth_Cfg.h are different"
#endif

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

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

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

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

/***************************************************************************
* Wrap of ENET functions    
***************************************************************************/
extern FUNC(void, ETH_CODE) Eth_Ipw_ResetController(CONST(uint8, AUTOMATIC) u8CtrlIdx);
extern FUNC(boolean, ETH_CODE) Eth_Ipw_CheckAccessToController(CONST(uint8, AUTOMATIC) u8CtrlIdx);
extern FUNC(void, ETH_CODE) Eth_Ipw_ConfigureController(CONST(uint8, AUTOMATIC) u8CtrlIdx);
extern FUNC(void, ETH_CODE) Eth_Ipw_EnableController(CONST(uint8, AUTOMATIC) u8CtrlIdx);
extern FUNC(Eth_ModeType, ETH_CODE) Eth_Ipw_CheckControllerIsActive(CONST(uint8, AUTOMATIC) u8CtrlIdx);
extern FUNC(uint32, ETH_CODE) Eth_Ipw_GetPhysicalAddressLow(CONST(uint8, AUTOMATIC) u8CtrlIdx);
extern FUNC(uint16, ETH_CODE) Eth_Ipw_GetPhysicalAddressHigh(CONST(uint8, AUTOMATIC) u8CtrlIdx);
extern FUNC(boolean, ETH_CODE) Eth_Ipw_SetPhysAddr  ( \
                CONST(uint8, AUTOMATIC) u8CtrlIdx, \
                P2CONST(uint8, AUTOMATIC, ETH_APPL_CONST) pPhysAddrPtr \
                                                    );
#if (STD_OFF == ETH_TXFIFO_SINGLE_MODE)
extern FUNC(uint8, ETH_CODE) Eth_Ipw_FindFifoIdx(CONST(uint8, AUTOMATIC) u8CtrlIdx, CONST(Eth_BufIdxType, AUTOMATIC) BufIdx);
#endif
#if STD_ON == ETH_UPDATE_PHYS_ADDR_FILTER
extern FUNC(void, ETH_CODE) Eth_Ipw_UpdatePhysAddrFilter ( \
                    CONST(uint8, AUTOMATIC) u8CtrlIdx, \
                    P2CONST(uint8, AUTOMATIC, ETH_APPL_CONST) pPhysAddrPtr, \
                    VAR(Eth_FilterActionType, AUTOMATIC) eAction \
                                                         );
#endif
extern FUNC(boolean, ETH_CODE) Eth_Ipw_ProvideBufferDataArea   ( \
                        CONST(uint8, AUTOMATIC) u8CtrlIdx, \
                        CONST(uint8, AUTOMATIC) u8FifoIdx, \
                        CONSTP2VAR(Eth_BufIdxType, AUTOMATIC, ETH_APPL_DATA) pBufIdx, \
                        P2P2VAR(uint8, AUTOMATIC, ETH_APPL_DATA) pData, \
                        CONSTP2VAR(uint16, AUTOMATIC, ETH_APPL_DATA) pLength \
                                                        );
extern FUNC(void, ETH_CODE) Eth_Ipw_Transmit   (
                        CONST(uint8, AUTOMATIC) u8CtrlIdx,
                        CONST(uint8, AUTOMATIC) u8FifoIdx,
                        CONST(Eth_BufIdxType, AUTOMATIC) u16Buf,
                        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  */
                                        );
extern FUNC(boolean, ETH_CODE) Eth_Ipw_IsTxBufLockedBT(CONST(uint8, AUTOMATIC) u8CtrlIdx, \
                                                CONST(uint8, AUTOMATIC) u8FifoIdx, \
                                                CONST(Eth_BufIdxType, AUTOMATIC) u8Buf   \
                                                );
#if STD_ON == ETH_CTRLENABLE_MII
extern FUNC(boolean, ETH_CODE) Eth_Ipw_WriteMii ( \
                        CONST(uint8, AUTOMATIC) u8CtrlIdx, \
                        CONST(uint8, AUTOMATIC) u8Trcv, \
                        CONST(uint8, AUTOMATIC) u8Reg, \
                        CONSTP2VAR(uint16, AUTOMATIC, ETH_APPL_DATA) pData \
                                                );
extern FUNC(boolean, ETH_CODE) Eth_Ipw_ReadMii  ( \
                        CONST(uint8, AUTOMATIC) u8CtrlIdx, \
                        CONST(uint8, AUTOMATIC) u8Trcv, \
                        CONST(uint8, AUTOMATIC) u8Reg, \
                        CONSTP2VAR(uint16, AUTOMATIC, ETH_APPL_DATA) pData \
                                                );
#endif /* ETH_CTRLENABLE_MII */
FUNC(uint8, ETH_CODE) Eth_Ipw_FindQueueIdx(CONST(uint8, AUTOMATIC) u8CtrlIdx, CONST(uint8, AUTOMATIC) u8DMAChannel);
extern FUNC(void, ETH_CODE) Eth_Ipw_MainFunction(void);
#if STD_ON == ETH_GETCOUNTVALAPI                                                    
extern FUNC(void, ETH_CODE) Eth_Ipw_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_Ipw_GetRxStats ( \
                       VAR(uint8, AUTOMATIC) u8CtrlIdx, \
                       P2VAR(Eth_RxStatsType, AUTOMATIC, ETH_APPL_DATA) RxStats \
                                               );
#endif
#if STD_ON == ETH_GET_TXSTATS_API
FUNC(void, ETH_CODE) Eth_Ipw_GetTxStats ( \
                       VAR(uint8, AUTOMATIC) u8CtrlIdx, \
                       P2VAR(Eth_TxStatsType, AUTOMATIC, ETH_APPL_DATA) TxStats \
                                               );
#endif
#if STD_ON == ETH_GET_GETTXCOUNT_API
FUNC(void, ETH_CODE) Eth_Ipw_GetTxErrorCounterValues ( \
                       VAR(uint8, AUTOMATIC) u8CtrlIdx, \
                       P2VAR(Eth_TxErrorCounterValuesType, AUTOMATIC, ETH_APPL_DATA) TxErrorCounterValues \
                                               );
#endif
extern FUNC(void, ETH_CODE) Eth_Ipw_ClearRxInterruptFlag(CONST(uint8, AUTOMATIC) u8CtrlIdx, CONST(uint8, AUTOMATIC) u8FifoIdx);
extern FUNC(void, ETH_CODE) Eth_Ipw_ClearTxInterruptFlag(CONST(uint8, AUTOMATIC) u8CtrlIdx, CONST(uint8, AUTOMATIC) u8FifoIdx);
extern FUNC(boolean, ETH_CODE) Eth_Ipw_IsTxInterruptFlagSet(CONST(uint8, AUTOMATIC) u8CtrlIdx, CONST(uint8, AUTOMATIC) u8FifoIdx);
extern FUNC(boolean, ETH_CODE) Eth_Ipw_IsRxInterruptFlagSet (CONST(uint8, AUTOMATIC) u8CtrlIdx, CONST(uint8, AUTOMATIC) u8FifoIdx);
extern FUNC(boolean, ETH_CODE) Eth_Ipw_IsTxInterruptEnabled (CONST(uint8, AUTOMATIC) u8CtrlIdx, CONST(uint8, AUTOMATIC) u8FifoIdx);
extern FUNC(boolean, ETH_CODE) Eth_Ipw_IsRxInterruptEnabled (CONST(uint8, AUTOMATIC) u8CtrlIdx, CONST(uint8, AUTOMATIC) u8FifoIdx);
/***************************************************************************
* ETH_LLD Real Functions Prototypes
***************************************************************************/
extern FUNC(void, ETH_CODE) Eth_Ipw_ReportTransmission(CONST(uint8, AUTOMATIC) u8CtrlIdx, CONST(uint8, AUTOMATIC) u8FifoIdx);
extern FUNC(Eth_RxStatusType, ETH_CODE) Eth_Ipw_ReportReception ( \
                                                CONST(uint8, AUTOMATIC) u8CtrlIdx, \
                                                CONST(uint8, AUTOMATIC) u8FifoIdx, \
                                                CONST(boolean, AUTOMATIC) bIrq \
                                                         );
extern FUNC(void, ETH_CODE) Eth_Ipw_DisableController(CONST(uint8, AUTOMATIC) u8CtrlIdx);

#define ETH_STOP_SEC_CODE
/**
 * @violates @ref Eth_Ipw_h_REF_1 MISRA rule 19.1
 * @violates @ref Eth_Ipw_h_REF_2 MISRA rule 19.15
 */
#include "Eth_MemMap.h"
#ifdef __cplusplus
}
#endif

#endif /* EHT_LLD_H */
/** @} */
