/**
*   @file    Port.h
*   @implements Port.h_Artifact
*   @version 1.0.0
*
*   @brief   AUTOSAR Port - driver API.
*   @details This file contains the PORT Autosar driver API.
*
*   @addtogroup Port
*   @{
*/
/*=================================================================================================
*   Project              : AUTOSAR 4.3 MCAL
*   Platform             : PA
*   Peripheral           : SIU,IGF
*   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 PORT_H
#define PORT_H

#ifdef __cplusplus
extern "C" {
#endif

/**
* @page misra_violations MISRA-C:2012 violations
*
* @section Port_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 violation is not fixed since the inclusion of 
*          Port_MemMap.h is as per AUTOSAR requirement [SWS_MemMap_00003].
*
* @section Port_h_REF_2
*          Violates MISRA 2012 Advisory Rule 20.1, #include directives should only be preceded by preprocessor
*          directives or comments. Port_MemMap.h is included after each section define in order to set the current 
*          memory section as defined by AUTOSAR
*
* @section Port_h_REF_3
*          Violates MISRA 2012 Advisory Rule 2.5, A project should not contain unused macro declarations. The macro is 
*          used at least in one driver's code configuration.
*
* @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.
*/

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

#include "Std_Types.h"
#include "Port_Cfg.h"
#include "Mcal.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                    43
/** @violates @ref Port_h_REF_3 A project should not contain unused macro declarations. */
#define PORT_MODULE_ID                    124
#define PORT_AR_RELEASE_MAJOR_VERSION     4
#define PORT_AR_RELEASE_MINOR_VERSION     3
#define PORT_AR_RELEASE_REVISION_VERSION  1
#define PORT_SW_MAJOR_VERSION             1
#define PORT_SW_MINOR_VERSION             0
#define PORT_SW_PATCH_VERSION             0

/*=================================================================================================
*                                     FILE VERSION CHECKS
=================================================================================================*/
/* Check if the files Port.h and Port_Cfg.h are of the same vendor */
#if (PORT_VENDOR_ID != PORT_VENDOR_ID_CFG_H)
    #error "Port.h and Port_Cfg.h have different vendor ids"
#endif
/* Check if the files Port.h and Port_Cfg.h are of the same Autosar version */
#if ((PORT_AR_RELEASE_MAJOR_VERSION != PORT_AR_RELEASE_MAJOR_VERSION_CFG_H)     || \
     (PORT_AR_RELEASE_MINOR_VERSION != PORT_AR_RELEASE_MINOR_VERSION_CFG_H)     || \
     (PORT_AR_RELEASE_REVISION_VERSION != PORT_AR_RELEASE_REVISION_VERSION_CFG_H)  \
    )
     #error "AutoSar Version Numbers of Port.h and Port_Cfg.h are different"
#endif
/* Check if the files Port.h and Port_Cfg.h are of the same software version */
#if ((PORT_SW_MAJOR_VERSION != PORT_SW_MAJOR_VERSION_CFG_H) || \
     (PORT_SW_MINOR_VERSION != PORT_SW_MINOR_VERSION_CFG_H) || \
     (PORT_SW_PATCH_VERSION != PORT_SW_PATCH_VERSION_CFG_H)    \
    )
  #error "Software Version Numbers of Port.h and Port_Cfg.h are different"
#endif
#ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
    /* Check if the files Port.h and Std_Types.h are of the same version */
   #if ((PORT_AR_RELEASE_MAJOR_VERSION != STD_AR_RELEASE_MAJOR_VERSION) || \
        (PORT_AR_RELEASE_MINOR_VERSION != STD_AR_RELEASE_MINOR_VERSION)    \
       )
       #error "AutoSar Version Numbers of Port.h and Std_Types.h are different"
   #endif
    /* Check if the files Port.h and Mcal.h are of the same version */
   #if ((PORT_AR_RELEASE_MAJOR_VERSION != MCAL_AR_RELEASE_MAJOR_VERSION) || \
        (PORT_AR_RELEASE_MINOR_VERSION != MCAL_AR_RELEASE_MINOR_VERSION)    \
       )
       #error "AutoSar Version Numbers of Port.h and Mcal.h are different"
   #endif
#endif
/*=================================================================================================
*                                          CONSTANTS
=================================================================================================*/
/* Instance IDs */
/**
* @brief   Instance ID of port driver.
*
*/
/** @violates @ref Port_h_REF_3 A project should not contain unused macro declarations. */
#define PORT_INSTANCE_ID                ((uint8)0x0)

/* Service IDs */
/*
* @brief   Service ID of port driver.
*/

/**
* @brief   API service ID for PORT Init function.
* @details Parameters used when raising an error/exception.
*
* @api
*
*/
/** @violates @ref Port_h_REF_3 A project should not contain unused macro declarations. */
#define PORT_INIT_ID                    ((uint8)0x00)

/**
* @brief   API service ID for PORT set pin direction function.
* @details Parameters used when raising an error/exception.
*
* @api
*
*/
/** @violates @ref Port_h_REF_3 A project should not contain unused macro declarations. */
#define PORT_SETPINDIRECTION_ID         ((uint8)0x01)
/**
* @brief   API service ID for PORT refresh pin direction function.
* @details Parameters used when raising an error/exception.
*
* @api
*
*/
/** @violates @ref Port_h_REF_3 A project should not contain unused macro declarations. */
#define PORT_REFRESHPINDIRECTION_ID     ((uint8)0x02)

/**
* @brief   API service ID for PORT get version info function.
* @details Parameters used when raising an error/exception.
*
* @api
*
*/
/** @violates @ref Port_h_REF_3 A project should not contain unused macro declarations. */
#define PORT_GETVERSIONINFO_ID          ((uint8)0x03)

/**
* @brief   API service ID for PORT set pin mode.
* @details Parameters used when raising an error/exception.
*
* @api
*
*/
/** @violates @ref Port_h_REF_3 A project should not contain unused macro declarations. */
#define PORT_SETPINMODE_ID              ((uint8)0x04)

/* Errors IDs */
/**
* @brief   Error ID of port driver.
* @details The following errors and exception are detectable by the PORT driver
*          if development error detection is enabled.
*
*/

/**
* @brief   Invalid Port Pin ID requested.
* @details Det Error value, returned by Port_SetPinDirection and Port_PinMode
*          if an wrong PortPin ID is passed.
*
* @implements Port_ErrorCodes_define
* @api
*/
/** @violates @ref Port_h_REF_3 A project should not contain unused macro declarations. */
#define PORT_E_PARAM_PIN                ((uint8)0x0A)

/**
* @brief   Port Pin Direction not configured as changeable.
* @details Det Error value, returned by Port_SetPinDirection
*          if the passed PortPin have unchangeable direction.
*
* @implements Port_ErrorCodes_define
* @api
*/
/** @violates @ref Port_h_REF_3 A project should not contain unused macro declarations. */
#define PORT_E_DIRECTION_UNCHANGEABLE   ((uint8)0x0B)

/**
* @brief   API Port_Init() service called with wrong parameter.
* @details Det Error value, returned by Port_Init function
*          if Port_Init is called with wrong parameter.
*
* @implements Port_ErrorCodes_define
* @api
*/
/** @violates @ref Port_h_REF_3 A project should not contain unused macro declarations. */
#define PORT_E_INIT_FAILED              ((uint8)0x0C)

/**
* @brief   API Port_SetPinMode() service called when mode is invalid.
* @details Det Error value, returned by Port_SetPinMode function
*          if the passed PortPinMode is invalid.
*
* @implements Port_ErrorCodes_define
* @api
*/
/** @violates @ref Port_h_REF_3 A project should not contain unused macro declarations. */
#define PORT_E_PARAM_INVALID_MODE       ((uint8)0x0D)

/**
* @brief   API Port_SetPinMode() service called when mode is unchangeable.
* @details Det Error value, returned by Port_SetPinMode function
*          if the passed PortPin have a unchangeable Mode.
*
* @implements Port_ErrorCodes_define
* @api
*/
/** @violates @ref Port_h_REF_3 A project should not contain unused macro declarations. */
#define PORT_E_MODE_UNCHANGEABLE        ((uint8)0x0E)

/**
* @brief   API service called without module initialization.
* @details Det Error value, returned by a function if API service called
*          prior to module initialization.
*
* @implements Port_ErrorCodes_define
* @api
*/
/** @violates @ref Port_h_REF_3 A project should not contain unused macro declarations. */
#define PORT_E_UNINIT                   ((uint8)0x0F)

/**
* @brief   API service called with NULL Pointer Parameter.
* @details Det Error value, returned by Port_GetVersionInfo function
*          if API is called with NULL Pointer Parameter.
*
* @implements Port_ErrorCodes_define
* @api
*/
/** @violates @ref Port_h_REF_3 A project should not contain unused macro declarations. */
#define PORT_E_PARAM_POINTER            ((uint8)0x10)

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


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


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


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


/*=================================================================================================
*                                     FUNCTION PROTOTYPES
=================================================================================================*/
/* Allocate defined section for PORT code */
#define PORT_START_SEC_CODE
/** @violates @ref Port_h_REF_1 Precautions shall be taken in order to prevent the contents of a header file being included more than once. */
/** @violates @ref Port_h_REF_2 #include directives should only be preceded by preprocessor directives or comments. */
#include "Port_MemMap.h"

/*
* Initializes the Port Driver module.
*/
FUNC(void, PORT_CODE) Port_Init
(
    P2CONST(Port_ConfigType, AUTOMATIC, PORT_APPL_CONST) ConfigPtr
);

#if (STD_ON == PORT_SET_PIN_DIRECTION_API)
/*
* Sets the port pin direction.
* Function disabled in the frozen pin configuration.
*/
FUNC(void, PORT_CODE) Port_SetPinDirection
( 
    VAR(Port_PinType,           AUTOMATIC) Pin,
    VAR(Port_PinDirectionType,  AUTOMATIC) Direction
);
#endif /* (STD_ON == PORT_SET_PIN_DIRECTION_API) */

#if (STD_ON == PORT_SET_PIN_MODE_API)
/*
* Sets the port pin mode.
*/
FUNC(void, PORT_CODE) Port_SetPinMode
(
    VAR(Port_PinType,       AUTOMATIC) Pin,
    VAR(Port_PinModeType,   AUTOMATIC) Mode
);
#endif /* (STD_ON == PORT_SET_PIN_MODE_API) */

#if (STD_ON == PORT_VERSION_INFO_API)
/*
* Returns the version information of this module.
*/
FUNC (void, PORT_CODE) Port_GetVersionInfo
(
    P2VAR(Std_VersionInfoType, AUTOMATIC, PORT_APPL_DATA) versioninfo
);
#endif /* (STD_ON == PORT_VERSION_INFO_API) */

/*
* Refreshes port direction.
*/
FUNC(void, PORT_CODE) Port_RefreshPortDirection(void);


#define PORT_STOP_SEC_CODE
/** @violates @ref Port_h_REF_1 Precautions shall be taken in order to prevent the contents of a header file being included more than once. */
/** @violates @ref Port_h_REF_2 #include directives should only be preceded by preprocessor directives or comments. */
#include "Port_MemMap.h"


#ifdef __cplusplus
}
#endif

#endif /* PORT_H */

/** @} */
