#ifndef DIO_H
#define DIO_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:  Dio.h
 *    Component:  Tms570_AutosarDioDriver
 *       Module:  DioDriver
 *    Generator:  -
 *
 *  Description:  This is the header file of module Dio. This DIO Driver provides following services
 *                        -   reading and writing to/from DIO Channels (Pins)
 *                        -   reading and writing to/from DIO Ports
 *                        -   reading and writing to/from DIO Channel Groups
 *                                              -   DIO Flip Channel
 *
 *                This module works on pins and ports which are configured by the PORT driver for this purpose.
 *                For this reason there is no configuration and initialization of this port structure in the DIO
 *                Driver.
 *
 *---------------------------------------------------------------------------------------------------------------------
 * 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         SDOCM00113124   Changes for 2.21.00 release; Files restructured
 * 02.21.01       11Mar2016    Enrique Lizarraga      SDOCM00121657   Changes for 2.21.01 version
 * 02.30.00       01Dec2016    Sudhakar Singh           None          Update version info
 * 05.30.00       15Mar2017    Sudhakar Singh         SDOCM00122834   Version supports TMS570LSxx Family of Devices
 ****************************************************************************************************************/

/**********************************************************************************************************************
 * INCLUDES
 *********************************************************************************************************************/
/* SourceId : DIO_SourceId_004 */
/* DesignId : Dio_DesignId_04 */
/* Requirements : AR_DIO_SR8 */
#include "Std_Types.h"


/**********************************************************************************************************************
 * VERSION INFORMATION
 *********************************************************************************************************************/


/*TI TMS570 Autosar DIO Driver Version */

/* vendor and module identification */
#define DIO_VENDOR_ID              (44U)
#define DIO_MODULE_ID              (120U)

/* AUTOSAR Release Version Information */
/* SourceId : DIO_SourceId_009 */
/* DesignId : Dio_DesignId_01 */
/* Requirements : AR_DIO_SR21 */
#define DIO_AR_RELEASE_MAJOR_VERSION       (0x04U)
#define DIO_AR_RELEASE_MINOR_VERSION       (0x00U)
#define DIO_AR_RELEASE_REVISION_VERSION    (0x03U)

/* AUTOSAR Software Specification Version Information */
#define DIO_AR_MAJOR_VERSION       (0x02U)
#define DIO_AR_MINOR_VERSION       (0x05U)
#define DIO_AR_PATCH_VERSION       (0x00U)

/* Component Version Information */
#define DIO_SW_MAJOR_VERSION               (5U)
#define DIO_SW_MINOR_VERSION               (30U)
#define DIO_SW_PATCH_VERSION               (0U)


/*********************************************************************************************************************
 *  GLOBAL DATA TYPES AND STRUCTURES
 *********************************************************************************************************************/
/* SourceId : DIO_SourceId_048 */
/* DesignId : Dio_DesignId_09 */
/* Requirements : AR_DIO_SR48, AR_DIO_SR54, AR_DIO_SR53 */
/* type definition for identifying DIO channels (meaning single port pins) */
typedef uint32 Dio_ChannelType;

/* type definition for identifying ports */
/* SourceId : DIO_SourceId_049 */
/* DesignId : Dio_DesignId_09 */
/* Requirements : AR_DIO_SR57, AR_DIO_SR58  */
typedef uint32 Dio_PortType;

/* type definition for status*/
typedef uint8 Dio_StatusType;

/* type definition for setting port level values (this is a bitmask, where each bit with value '1' sets the
 * corresponding port pin to HIGH and '0' sets the pin to LOW)
 */
/* SourceId : DIO_SourceId_53 */
/* DesignId : Dio_DesignId_09 */
/* Requirements : AR_DIO_SR66, AR_DIO_SR67, AR_DIO_SR117 */
typedef uint32 Dio_PortLevelType;

/* type definition for setting DIO channnel level values (allowed values: STD_HIGH and STD_LOW) */
/* SourceId : DIO_SourceId_007 */
/* DesignId : Dio_DesignId_09 */
/* Requirements : AR_DIO_SR14, AR_DIO_SR64 */
typedef uint8  Dio_LevelType;

/* type definition for identifying channel groups (meaning a set of pins in one port) */
/* SourceId : DIO_SourceId_052 */
/* DesignId : Dio_DesignId_09 */
/* Requirements : AR_DIO_SR61, AR_DIO_SR62  */
typedef struct
{
   Dio_PortType      port;       /* port ID of a channel group                                           */
   Dio_PortLevelType mask;       /* bitmask where a '1' represents a pin handled by this channel group   */
   /* SourceId : DIO_SourceId_68 */
   /* DesignId : Dio_DesignId_09 */
   /* Requirements : AR_DIO_SR118 */
   uint8             offset;     /* shifts channel group values, so it is always "right" aligned.        */
} Dio_ChannelGroupType;

/* type definition for referencing channel group structures */
typedef P2CONST(Dio_ChannelGroupType, AUTOMATIC, DIO_APPL_DATA) Dio_ChannelGroupRefType;

/**********************************************************************************************************************
 * INCLUDES
 *********************************************************************************************************************/
/* Included here as the type definition of Dio_ChannelGroupType is used in Dio_Cfg.h */
/* SourceId : DIO_SourceId_001 */
/* DesignId : Dio_DesignId_04 */
/* Requirements : AR_DIO_SR5 */
#include "Dio_Cfg.h"

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

/* DIO error codes: */
/* SourceId : DIO_SourceId_039 */
/* DesignId : Dio_DesignId_05 */
/* Requirements : AR_DIO_SR40, AR_DIO_SR46 */
#ifndef DIO_E_PARAM_INVALID_CHANNEL_ID
#define DIO_E_PARAM_INVALID_CHANNEL_ID      (0x0Au)   /* API service called with invalid channel ID               */
#endif
#ifndef DIO_E_PARAM_CONFIG
#define DIO_E_PARAM_CONFIG                  (0x10u)   /* Dio_Init if invalid configptr  is passed */
#endif
#ifndef DIO_E_PARAM_INVALID_PORT_ID
#define DIO_E_PARAM_INVALID_PORT_ID         (0x14u)   /* API service called with invalid port ID                  */
#endif
#ifndef DIO_E_PARAM_INVALID_GROUP
#define DIO_E_PARAM_INVALID_GROUP	        (0x1Fu)   /* API service called with invalid channel group ID         */
#endif
#ifndef DIO_E_PARAM_POINTER
#define DIO_E_PARAM_POINTER                 (0x20u)   /* Dio_GetVersionInfo() called with NULL_PTR as parameter   */
#endif

/* DIO API service identification */
#define DIO_SID_READ_CHANNEL                ( 0U)
#define DIO_SID_WRITE_CHANNEL               ( 1U)
#define DIO_SID_READ_PORT                   ( 2U)
#define DIO_SID_WRITE_PORT                  ( 3U)
#define DIO_SID_READ_CHL_GROUP              ( 4U)
#define DIO_SID_WRITE_CHL_GROUP             ( 5U)
#define DIO_SID_INIT						( 6U)
#define DIO_SID_FLIP_CHANNEL				( 7U)
/* SourceId : DIO_SourceId_060 */
/* DesignId : Dio_DesignId_16 */
/* Requirements : AR_DIO_SR95 */
#define DIO_SID_GET_VERSION_INFO            (18U)

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


FUNC(Dio_LevelType, DIO_CODE) Dio_ReadChannel( Dio_ChannelType ChannelId );

FUNC(void, DIO_CODE) Dio_WriteChannel( Dio_ChannelType ChannelId, Dio_LevelType   Level );

FUNC(Dio_PortLevelType, DIO_CODE) Dio_ReadPort( Dio_PortType PortId );

FUNC(void, DIO_CODE) Dio_WritePort( Dio_PortType PortId, Dio_PortLevelType Level );

FUNC(Dio_PortLevelType, DIO_CODE) Dio_ReadChannelGroup( Dio_ChannelGroupRefType ChannelGroupIdPtr );

FUNC(void, DIO_CODE) Dio_WriteChannelGroup( Dio_ChannelGroupRefType ChannelGroupIdPtr, Dio_PortLevelType Level );

#if (STD_ON == DIO_VERSION_INFO_API)
   FUNC(void, DIO_CODE) Dio_GetVersionInfo( P2VAR(Std_VersionInfoType, AUTOMATIC, DIO_APPL_DATA) VersionInfo );
#endif

#if (STD_ON == DIO_FLIP_CHANNEL_API)
   FUNC(Dio_LevelType, DIO_CODE) Dio_FlipChannel(Dio_ChannelType ChannelId);
#endif

FUNC(void, DIO_CODE) Dio_Init(P2CONST(Dio_ConfigType, AUTOMATIC, DIO_PBCFG) ConfigPtr );


#endif  /* DIO_H */

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