#ifndef PORT_H
#define PORT_H
/**********************************************************************************************************************
 *  COPYRIGHT
 *  -------------------------------------------------------------------------------------------------------------------
 *  \verbatim
 *
 *                 TEXAS INSTRUMENTS INCORPORATED PROPRIETARY INFORMATION
 *
 *                 Property of Texas Instruments, Unauthorized reproduction and/or distribution
 *                 is strictly prohibited.  This product  is  protected  under  copyright  law
 *                 and  trade  secret law as an  unpublished work.
 *                 (C) Copyright Texas Instruments.  All rights reserved.
 *
 *  \endverbatim
 *  -------------------------------------------------------------------------------------------------------------------
 *  FILE DESCRIPTION
 *  -------------------------------------------------------------------------------------------------------------------
 *         File:  Port.h
 *      Project:  Tms570_AutosarPortDriver
 *       Module:  PortDriver
 *
 *  Description:  This module implements a driver in ANSI C programming language to centralize the
 *                configuration of ports and pins which are used by more than one driver module.
 *                With this driver you can:
 *                - Configure all port pins
 *                - Initialize the configuration
 *                - Refresh the configuration (EMC purposes)
 *                - Switch the port pin configuration during runtime
 *---------------------------------------------------------------------------------------------------------------------
 * Author:  Sunil Kumar T V
 *---------------------------------------------------------------------------------------------------------------------
 * Revision History
 *---------------------------------------------------------------------------------------------------------------------
 * Version        Date         Author                 Change ID       Description
 *---------------------------------------------------------------------------------------------------------------------
 * 02.10.00       11Feb2013    Sapthagiri G           0000000000000   Initial version (adapted from TMS570LS3xx v01.10.00).
 * 02.20.00       29Aug2013    Sreyas K               SDOCM00103509   Changes for Production Version Champion
 * 02.21.00       30Sep2014    Vineeth T Alex         SDOCM00113123   Changes for 2.21.00 release; Files restructured
 * 02.21.01       23Aug2016    VishwanathReddy        SDOCM00122619   Update version info.
 * 02.30.00       01Dec2016    Sudhakar Singh         None            Update version info
 * 05.30.00       15Mar2017    Sudhakar Singh         SDOCM00122834   Version supports TMS570LSxx Family of Devices.
 *********************************************************************************************************************/

/**********************************************************************************************************************
 * INCLUDES
 *********************************************************************************************************************/

 #include "Std_Types.h"
 #include "Port_Cfg.h"


/**********************************************************************************************************************
 *  GLOBAL CONSTANT MACROS
 *********************************************************************************************************************/

/*TI TMS570 Autosar Port Driver Version */
/* Version format 00.00.00  stored as 0x000000*/
/*                Major.Minor.Patch          */

/* AUTOSAR Software Specification Version Information */
/* SourceId : Port_SourceId_004 */
/* DesignId : Port_DesignId_01  */
/* Requirements : AR_PORT_SR22, AR_PORT_SR69 */
#define PORT_AR_RELEASE_MAJOR_VERSION       (0x04U)
#define PORT_AR_RELEASE_MINOR_VERSION       (0x00U)
#define PORT_AR_RELEASE_REVISION_VERSION    (0x03U)

/* vendor and module identification */
#define PORT_VENDOR_ID              (44U)
#define PORT_MODULE_ID              (124U)
#define PORT_INSTANCE_ID            (0U)

/* AUTOSAR Software Specification Version Information */
#define PORT_AR_MAJOR_VERSION       (0x03U)
#define PORT_AR_MINOR_VERSION       (0x02U)
#define PORT_AR_PATCH_VERSION       (0x00U)

/* Component Version Information */
#define PORT_SW_MAJOR_VERSION               (5U)
#define PORT_SW_MINOR_VERSION               (30U)
#define PORT_SW_PATCH_VERSION               (0U)

/**********************************************************************************************************************
 *  GLOBAL FUNCTION MACROS
 *********************************************************************************************************************/

/****** Error Codes in Development-Mode As specified by AUTOSAR Standard ********/
/* SourceId : Port_SourceId_005 */
/* DesignId : Port_DesignId_05  */
/* Requirements : AR_PORT_SR23, AR_PORT_SR23, AR_PORT_SR25, AR_PORT_SR31 */
/*  Invalid Port Pin ID requested  */
#ifndef PORT_E_PARAM_PIN
#define PORT_E_PARAM_PIN				((uint8)0x0AU)
#endif

/*  Port Pin not configured as changeable  */
#ifndef PORT_E_DIRECTION_UNCHANGEABLE
#define PORT_E_DIRECTION_UNCHANGEABLE	((uint8)0x0BU)
#endif

/*  Init service called with wrong parameter  */
#ifndef PORT_E_PARAM_CONFIG
#define PORT_E_PARAM_CONFIG				((uint8)0x0CU)
#endif

#ifndef PORT_E_PARAM_INVALID_MODE
#define PORT_E_PARAM_INVALID_MODE		((uint8)0x0DU)
#endif

#ifndef PORT_MODE_UNCHANGEBLE
#define PORT_MODE_UNCHANGEBLE			((uint8)0x0EU)
#endif

/*  Module not initialized  */
#ifndef PORT_E_UNINIT
#define PORT_E_UNINIT					((uint8)0x0FU)
#endif

#ifndef PORT_E_PARAM_POINTER
#define PORT_E_PARAM_POINTER			((uint8)0x10U)
#endif


/****** Port Service Identification  ************/
#define PORT_SID_INIT                       ((uint8)0x0U)
#define PORT_SID_SET_PIN_DIR                ((uint8)0x1U)
#define PORT_SID_REFRESH_PORT_DIR           ((uint8)0x2U)
#define PORT_SID_GET_VERSION_INFO           ((uint8)0x3U)
#define PORT_SID_SET_PIN_MODE               ((uint8)0x4U)
#define PORT_SID_SET_CONFIGREG				((uint8)0x5U)


/**********************************************************************************************************************
 *  GLOBAL DATA TYPES AND STRUCTURES
 *********************************************************************************************************************/

/*  Type for symbolic name of Port pins  */
/* SAFETYMCUSW 495S MR:6.3 <APPROVED> "Reason - Size of uint8 is 8 bits" */
/* SourceId : Port_SourceId_019 */
/* DesignId : Port_DesignId_09  */
/* Requirements : AR_PORT_SR81, AR_PORT_SR82 */
typedef uint8 Port_PinType;

/*  Type of direction of Port pin  */

/* SourceId : Port_SourceId_020 */
/* DesignId : Port_DesignId_09  */
/* Requirements : AR_PORT_SR83, AR_PORT_SR84 */
typedef enum
{
    PORT_PIN_IN = 0U,
    PORT_PIN_OUT
}Port_PinDirectionType;

#if (STD_ON == PORT_SAFETI_API)
typedef struct{
	uint32 configRegs[PORT_CONFIG_REG_SIZE];
} PortConfigRegsType;
#endif

/**********************************************************************************************************************
 *  GLOBAL FUNCTION PROTOTYPES
 *********************************************************************************************************************/

/*  Service Functions  */

FUNC(void, PORT_CODE) Port_Init( P2CONST( Port_ConfigType, AUTOMATIC, PORT_PBCFG) ConfigPtr );

#if ( STD_ON == PORT_SET_PIN_DIRECTION_API )
   FUNC(void, PORT_CODE) Port_SetPinDirection( Port_PinType Pin, Port_PinDirectionType Direction );
#endif /*( STD_ON == PORT_SET_PIN_DIRECTION_API )*/

#if ( STD_ON == PORT_REFRESH_PORT_DIRECTION_API )
   FUNC(void, PORT_CODE) Port_RefreshPortDirection(void);
#endif /*( STD_ON == PORT_REFRESH_PORT_DIRECTION_API )*/

#if ( STD_ON == PORT_SET_PIN_MODE_API )
   FUNC(void, PORT_CODE) Port_SetPinMode( Port_PinType Pin, Port_PinModeType Mode );
#endif /*( STD_ON == PORT_SET_PIN_MODE_API )*/

#if (STD_ON == PORT_VERSION_INFO_API)
   FUNC(void, PORT_CODE) Port_GetVersionInfo( P2VAR(Std_VersionInfoType, AUTOMATIC, PORT_APPL_DATA) versioninfo );
#endif /*(STD_ON == PORT_VERSION_INFO_API)*/

#if (STD_ON == PORT_SAFETI_API)
   FUNC(void, PORT_PBCODE) Port_GetConfigRegValues( uint8 initial,
									 P2VAR(PortConfigRegsType, AUTOMATIC, PORT_PBCFG) ConfigRegPtr );
#endif /* (STD_ON == PORT_SAFETI_API) */

#endif  /* PORT_H */

/**********************************************************************************************************************
 *  END OF FILE: Port.h
 *********************************************************************************************************************/
