/**
*   @file    Dio_Ipw.h
*   @version 1.0.0
*
*   @brief   AUTOSAR Dio low level header.
*   @details This file is the DIO driver low level header.
*
*   @addtogroup DIO_IPW
*   @{
*/
/*=================================================================================================
*   Project              : AUTOSAR 4.3 MCAL
*   Platform             : PA
*   Peripheral           : SIU
*   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 DIO_IPW_H
#define DIO_IPW_H

#ifdef __cplusplus
extern "C"{
#endif

/**
* @page misra_violations MISRA-C:2012 violations
*
* @section Dio_IPW_H_REF_1
*          Violates MISRA 2012 Advisory Directive 4.9, A function should be used in preference to a function-like macro where they are interchangeable.
*          Function like macro are used to reduce code complexity.
*
* @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, An identifier declared in an inner scope shall not hide an identifier declared in an outer scope.
*          The used compilers use more than 31 chars for identifiers.
*
* @section [global]
*          Violates MISRA 2012 Required Rule 5.5, Macro identifiers shall be distinct.
*          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 "Dio_Siu.h"

/*=================================================================================================
*                              SOURCE FILE VERSION INFORMATION
=================================================================================================*/

#define DIO_VENDOR_ID_IPW                   43
#define DIO_AR_RELEASE_MAJOR_VERSION_IPW    4
#define DIO_AR_RELEASE_MINOR_VERSION_IPW    3
#define DIO_AR_RELEASE_REVISION_VERSION_IPW 1
#define DIO_SW_MAJOR_VERSION_IPW            1
#define DIO_SW_MINOR_VERSION_IPW            0
#define DIO_SW_PATCH_VERSION_IPW            0

/*=================================================================================================
*                                     FILE VERSION CHECKS
=================================================================================================*/


#if ((DIO_AR_RELEASE_MAJOR_VERSION_IPW != DIO_SIU_AR_RELEASE_MAJOR_VERSION)       || \
     (DIO_AR_RELEASE_MINOR_VERSION_IPW != DIO_SIU_AR_RELEASE_MINOR_VERSION)       || \
     (DIO_AR_RELEASE_REVISION_VERSION_IPW != DIO_SIU_AR_RELEASE_REVISION_VERSION)    \
    )
     #error "AUTOSAR Version Numbers of Dio_Ipw.h and Dio_Siu.h are different"
#endif

#if ((DIO_SW_MAJOR_VERSION_IPW != DIO_SIU_SW_MAJOR_VERSION) || \
     (DIO_SW_MINOR_VERSION_IPW != DIO_SIU_SW_MINOR_VERSION) || \
     (DIO_SW_PATCH_VERSION_IPW != DIO_SIU_SW_PATCH_VERSION)    \
    )
    #error "Software Version Numbers of Dio_Ipw.h and Dio_Siu.h are different"
#endif

#if (DIO_VENDOR_ID_IPW != DIO_SIU_VENDOR_ID)
    #error "VENDOR ID for Dio_Ipw.h and Dio_Siu.h is different"
#endif

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

/*=================================================================================================
*                                      DEFINES AND MACROS
=================================================================================================*/
#if (STD_ON == DIO_DEV_ERROR_DETECT)
    /** Bit mask for the leftmost channel in a port*/
    #define DIO_BIT1_LEFTMOST_MASK_U16                  ((uint16)0x8000U)
    #define DIO_PIN_MASK_U16                            ((uint16)0x000FU)
    /** @violates @ref Dio_IPW_H_REF_1 A function should be used in preference to a function-like macro where they are interchangeable. */
    #define DIO_CHECK_CHANNEL_VALIDITY(channelId)       (DIO_BIT1_LEFTMOST_MASK_U16 >> ((channelId) & DIO_PIN_MASK_U16))
#endif
/**
* @brief          Mapping macro between low level layer and high level layer.
*
*/
/** @violates @ref Dio_IPW_H_REF_1 A function should be used in preference to a function-like macro where they are interchangeable. */
#define Dio_Ipw_ReadChannel(ChannelId)              (Dio_Siu_ReadChannel(ChannelId))

/**
* @brief          Mapping macro between low level layer and high level layer.
*
*/
/** @violates @ref Dio_IPW_H_REF_1 A function should be used in preference to a function-like macro where they are interchangeable. */
#define Dio_Ipw_WriteChannel(ChannelId, ChannelLevel)   (Dio_Siu_WriteChannel((ChannelId), (ChannelLevel)))

#if (STD_ON == DIO_FLIP_CHANNEL_API)
/**
* @brief          Mapping macro between low level layer and high level layer.
*
*/
/** @violates @ref Dio_IPW_H_REF_1 A function should be used in preference to a function-like macro where they are interchangeable. */
#define Dio_Ipw_FlipChannel(ChannelId)              (Dio_Siu_FlipChannel(ChannelId))

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

/**
* @brief          Mapping macro between low level layer and high level layer.
*
*/
/** @violates @ref Dio_IPW_H_REF_1 A function should be used in preference to a function-like macro where they are interchangeable. */
#define Dio_Ipw_ReadPort(PortId)                    (Dio_Siu_ReadPort(PortId))

/**
* @brief          Mapping macro between low level layer and high level layer.
*
*/
/** @violates @ref Dio_IPW_H_REF_1 A function should be used in preference to a function-like macro where they are interchangeable. */
#define Dio_Ipw_WritePort(PortId, PortLevel)       (Dio_Siu_WritePort((PortId), (PortLevel)))

/**
* @brief          Mapping macro between low level layer and high level layer.
*
*/
/** @violates @ref Dio_IPW_H_REF_1 A function should be used in preference to a function-like macro where they are interchangeable. */
#define Dio_Ipw_ReadChannelGroup(pChannelGroupIdPtr)    (Dio_Siu_ReadChannelGroup(pChannelGroupIdPtr))

/**
* @brief          Mapping macro between low level layer and high level layer.
*
*/
/** @violates @ref Dio_IPW_H_REF_1 A function should be used in preference to a function-like macro where they are interchangeable. */
#define Dio_Ipw_WriteChannelGroup(pChannelGroupIdPtr, Level)    (Dio_Siu_WriteChannelGroup((pChannelGroupIdPtr), (Level)))

#if (STD_ON == DIO_MASKEDWRITEPORT_API)
/**
* @brief          Mapping macro between low level layer and high level layer.
*
*/
/** @violates @ref Dio_IPW_H_REF_1 A function should be used in preference to a function-like macro where they are interchangeable. */
#define Dio_Ipw_MaskedWritePort(PortId, PortLevel, Mask)    (Dio_Siu_MaskedWritePort((PortId), (PortLevel), (Mask)))
    
#endif /* (STD_ON == DIO_MASKEDWRITEPORT_API) */


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


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


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


/*=================================================================================================
*                                    FUNCTION PROTOTYPES
=================================================================================================*/

#ifdef __cplusplus
}
#endif

#endif /* DIO_IPW_H */

/** @} */
