/*==================================================================================================
*   Project              : RTD AUTOSAR 4.4
*   Platform             : CORTEXM
*   Peripheral           : SIUL2
*   Dependencies         : none
*
*   Autosar Version      : 4.4.0
*   Autosar Revision     : ASR_REL_4_4_REV_0000
*   Autosar Conf.Variant :
*   SW Version           : 1.0.0
*   Build Version        : S32K3_RTD_1_0_0_HF02_D2112_ASR_REL_4_4_REV_0000_20211222
*
*   (c) Copyright 2020 - 2021 NXP Semiconductors
*   All Rights Reserved.
*
*   NXP Confidential. This software is owned or controlled by NXP and may only be
*   used strictly in accordance with the applicable license terms. By expressly
*   accepting such terms or by downloading, installing, activating and/or otherwise
*   using the software, you are agreeing that you have read, and that you agree to
*   comply with and are bound by, such license terms. If you do not agree to be
*   bound by the applicable license terms, then you may not retain, install,
*   activate or otherwise use the software.
==================================================================================================*/

#ifndef PORT_IPW_H
#define PORT_IPW_H

/**
*   @file    Port_Ipw.h
*   @internal
*   @defgroup Port_IPW Port IPW
*   @{
*/

#ifdef __cplusplus
extern "C"{
#endif

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

#include "Siul2_Port_Ip.h"
#include "Tspc_Port_Ip.h"
#include "Port_Cfg.h"
/*=================================================================================================
*                              SOURCE FILE VERSION INFORMATION
=================================================================================================*/

/**
* @brief Parameters that shall be published within the Port driver header file and also in the
*        module's description file.
*
*/
#define PORT_VENDOR_ID_IPW_H                    43
#define PORT_AR_RELEASE_MAJOR_VERSION_IPW_H     4
#define PORT_AR_RELEASE_MINOR_VERSION_IPW_H     4
#define PORT_AR_RELEASE_REVISION_VERSION_IPW_H  0
#define PORT_SW_MAJOR_VERSION_IPW_H             1
#define PORT_SW_MINOR_VERSION_IPW_H             0
#define PORT_SW_PATCH_VERSION_IPW_H             0

/*=================================================================================================
*                                     FILE VERSION CHECKS
=================================================================================================*/
/* Check if the files Port_Ipw.h and Siul2_Port_Ip.h are of the same vendor */
#if (PORT_VENDOR_ID_IPW_H != SIUL2_PORT_IP_VENDOR_ID_H)
    #error "Port_Ipw.h and Siul2_Port_Ip.h have different vendor ids"
#endif
/* Check if the files Port_Ipw.h and Siul2_Port_Ip.h are of the same Autosar version */
#if ((PORT_AR_RELEASE_MAJOR_VERSION_IPW_H    != SIUL2_PORT_IP_AR_RELEASE_MAJOR_VERSION_H)  || \
     (PORT_AR_RELEASE_MINOR_VERSION_IPW_H    != SIUL2_PORT_IP_AR_RELEASE_MINOR_VERSION_H)  || \
     (PORT_AR_RELEASE_REVISION_VERSION_IPW_H != SIUL2_PORT_IP_AR_RELEASE_REVISION_VERSION_H)  \
    )
    #error "AutoSar Version Numbers of Port_Ipw.h and Siul2_Port_Ip.h are different"
#endif
/* Check if the files Port_Ipw.h and Siul2_Port_Ip.h are of the same software version */
#if ((PORT_SW_MAJOR_VERSION_IPW_H != SIUL2_PORT_IP_SW_MAJOR_VERSION_H) || \
     (PORT_SW_MINOR_VERSION_IPW_H != SIUL2_PORT_IP_SW_MINOR_VERSION_H) || \
     (PORT_SW_PATCH_VERSION_IPW_H != SIUL2_PORT_IP_SW_PATCH_VERSION_H)    \
    )
    #error "Software Version Numbers of Port_Ipw.h and Siul2_Port_Ip.h are different"
#endif

/* Check if the files Port_Ipw.h and Tspc_Port_Ip.h are of the same vendor */
#if (PORT_VENDOR_ID_IPW_H != TSPC_PORT_IP_VENDOR_ID_H)
    #error "Port_Ipw.h and Tspc_Port_Ip.h have different vendor ids"
#endif
/* Check if the files Port_Ipw.h and Tspc_Port_Ip.h are of the same Autosar version */
#if ((PORT_AR_RELEASE_MAJOR_VERSION_IPW_H    != TSPC_PORT_IP_AR_RELEASE_MAJOR_VERSION_H)  || \
     (PORT_AR_RELEASE_MINOR_VERSION_IPW_H    != TSPC_PORT_IP_AR_RELEASE_MINOR_VERSION_H)  || \
     (PORT_AR_RELEASE_REVISION_VERSION_IPW_H != TSPC_PORT_IP_AR_RELEASE_REVISION_VERSION_H)  \
    )
    #error "AutoSar Version Numbers of Port_Ipw.h and Tspc_Port_Ip.h are different"
#endif
/* Check if the files Port_Ipw.h and Tspc_Port_Ip.h are of the same software version */
#if ((PORT_SW_MAJOR_VERSION_IPW_H != TSPC_PORT_IP_SW_MAJOR_VERSION_H) || \
     (PORT_SW_MINOR_VERSION_IPW_H != TSPC_PORT_IP_SW_MINOR_VERSION_H) || \
     (PORT_SW_PATCH_VERSION_IPW_H != TSPC_PORT_IP_SW_PATCH_VERSION_H)    \
    )
    #error "Software Version Numbers of Port_Ipw.h and Tspc_Port_Ip.h are different"
#endif

/* Check if the files Port_Ipw.h and Port_Cfg.h are of the same vendor */
#if (PORT_VENDOR_ID_IPW_H != PORT_VENDOR_ID_CFG_H)
    #error "Port_Ipw.h and Port_Cfg.h have different vendor ids"
#endif
/* Check if the files Port_Ipw.h and Port_Cfg.h are of the same Autosar version */
#if ((PORT_AR_RELEASE_MAJOR_VERSION_IPW_H    != PORT_AR_RELEASE_MAJOR_VERSION_CFG_H)  || \
     (PORT_AR_RELEASE_MINOR_VERSION_IPW_H    != PORT_AR_RELEASE_MINOR_VERSION_CFG_H)  || \
     (PORT_AR_RELEASE_REVISION_VERSION_IPW_H != PORT_AR_RELEASE_REVISION_VERSION_CFG_H)  \
    )
    #error "AutoSar Version Numbers of Port_Ipw.h and Port_Cfg.h are different"
#endif
/* Check if the files Port_Ipw.h and Port_Cfg.h are of the same software version */
#if ((PORT_SW_MAJOR_VERSION_IPW_H != PORT_SW_MAJOR_VERSION_CFG_H) || \
     (PORT_SW_MINOR_VERSION_IPW_H != PORT_SW_MINOR_VERSION_CFG_H) || \
     (PORT_SW_PATCH_VERSION_IPW_H != PORT_SW_PATCH_VERSION_CFG_H)    \
    )
    #error "Software Version Numbers of Port_Ipw.h and Port_Cfg.h are different"
#endif

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

/*=================================================================================================
*                                      DEFINES AND MACROS
=================================================================================================*/
#define SIUL2_MODE_BIT_OFFSET_MASK_U8  ((uint8)0x0F)
/* @brief Mask definitions for MSCR bit field IBE */
#define SIUL2_MSCR_IBE_U32                          ((uint32)0x00080000U)
#define SIUL2_MSCR_IBE_ON_U32                       ((uint32)0x00080000U)

#define SIUL2_MSCR_OBE_U32                          ((uint32)0x00200000U)
#define SIUL2_MSCR_OBE_ON_U32                       ((uint32)0x00200000U)

#define SIUL2_MSCR_SSS_U32                          ((uint32)0x00000007U)
#define SIUL2_MSCR_SSS_OFFSET_U32                   ((uint32)0)

/*
* @brief Initializing value for the unused IMCR registers in order to avoid writting in not valid
*        memory areas
*/
#ifdef SIUL2_PORT_IP_S32K3XX_PLATFORM
#define SIUL2_UNUSED_IMCR_PATTERN_U8        ((uint32)0xFFU)
#endif
/* @brief Mode bit offset mask */
#define SIUL2_BIT_OFFSET_MASK_U8                        ((uint8)0x0F)



/*!
 * @brief
 *
 * @details
 *
 *
 * @param[in]
 *
 * @return void
 *
 *
 **/
void Port_Ipw_Init
(
    const Port_ConfigType * pConfigPtr
);

#if (STD_ON == PORT_SET_PIN_DIRECTION_API) || (STD_ON == PORT_SET_PIN_MODE_API)
/*!
 * @brief
 *
 * @details
 *
 *
 * @param[in]
 *
 * @return void
 *
 *
 **/
Std_ReturnType Port_Ipw_SetPinDirection
(
    Port_PinType PinIndex,
    Port_PinDirectionType eDirection,
    const Port_ConfigType * pConfigPtr
);

#endif /* (STD_ON == PORT_SET_PIN_DIRECTION_API) */

/*!
 * @brief
 *
 * @details
 *
 *
 * @param[in]
 *
 * @return void
 *
 *
 **/
void Port_Ipw_RefreshPortDirection
(
    const Port_ConfigType * pConfigPtr
);

#ifdef PORT_SET_AS_UNUSED_PIN_API
#if (STD_ON == PORT_SET_AS_UNUSED_PIN_API)
/*!
 * @brief
 *
 * @details
 *
 *
 * @param[in]
 *
 * @return void
 *
 *
 **/
void Port_Ipw_SetAsUnusedPin
(
    Port_PinType PinIndex,
    const Port_ConfigType * pConfigPtr
);

/*!
 * @brief
 *
 * @details
 *
 *
 * @param[in]
 *
 * @return void
 *
 *
 **/
void Port_Ipw_SetAsUsedPin
(
    Port_PinType PinIndex,
    const Port_ConfigType * pConfigPtr
);

#endif /* (STD_ON == PORT_SET_AS_UNUSED_PIN_API) */
#endif

#ifdef PORT_RESET_PIN_MODE_API
#if (STD_ON == PORT_RESET_PIN_MODE_API)
/*!
 * @brief
 *
 * @details
 *
 *
 * @param[in]
 *
 * @return void
 *
 *
 **/
void Port_Ipw_ResetPinMode
(
    Port_PinType PinIndex,
    const Port_ConfigType * pConfigPtr
);

#endif /* (STD_ON == PORT_RESET_PIN_MODE_API) */
#endif
/*=================================================================================================
*                                             ENUMS
=================================================================================================*/


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


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


/*=================================================================================================
*                                     FUNCTION PROTOTYPES
=================================================================================================*/
/* Allocate defined section for PORT code */


#if (STD_ON == PORT_SET_PIN_MODE_API)
/*!
 * @brief
 *
 * @details
 *
 *
 * @param[in]
 *
 * @return void
 *
 *
 **/
Std_ReturnType Port_Ipw_SetPinMode
(
    Port_PinType PinIndex,
    Port_PinModeType PinMode,
    const Port_ConfigType * pConfigPtr
);
#endif /* (STD_ON == PORT_SET_PIN_MODE_API) */



#ifdef __cplusplus
}
#endif

/** @} */

#endif /*PORT_IPW_H*/
