/**
*   @file    Lin_ESCI.h
*   @version 1.0.0
*
*   @brief   AUTOSAR Lin - Low level driver header file.
*   @details This file includes the function prototypes defined in the LIN low level driver for ESCI.
*
*   @addtogroup LIN
*   @{
*/
/*==================================================================================================
*   Project              : AUTOSAR 4.3 MCAL
*   Platform             : PA
*   Peripheral           : ESCI
*   Dependencies         : 
*
*   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 Lin_ESCI_H
#define Lin_ESCI_H

#ifdef __cplusplus
extern "C" {
#endif

/**
* @page misra_violations MISRA-C:2012 violations
*
* @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.
*
* @section Lin_ESCI_h_REF_1
* Violates MISRA 2012 Advisory Rule 20.1, #include directives should only be preceded by preprocessor directives or comments.
* <MA>_MemMap.h is included after each section define in order to set the current memory section as defined by AUTOSAR.
*
* @section Lin_ESCI_h_REF_2
* 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 <MA>_MemMap.h is as per AUTOSAR requirement [SWS_MemMap_00003].
*/

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


/*==================================================================================================
*                              SOURCE FILE VERSION INFORMATION
==================================================================================================*/
#define LIN_VENDOR_ID_ESCI                    43
#define LIN_AR_RELEASE_MAJOR_VERSION_ESCI     4
#define LIN_AR_RELEASE_MINOR_VERSION_ESCI     3
#define LIN_AR_RELEASE_REVISION_VERSION_ESCI  1
#define LIN_SW_MAJOR_VERSION_ESCI             1
#define LIN_SW_MINOR_VERSION_ESCI             0
#define LIN_SW_PATCH_VERSION_ESCI             0

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

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

/*=================================================================================================
                                       DEFINES AND MACROS
=================================================================================================*/
/**
* @brief        Time out for the slave data byte.
*
*/
#define ESCI_TIMEOUT_DATABYTE_ZERO_U8           ((uint8)63U)
#define ESCI_TIMEOUT_DATABYTE_ONE_U8            ((uint8)77U)
#define ESCI_TIMEOUT_DATABYTE_TWO_U8            ((uint8)91U)
#define ESCI_TIMEOUT_DATABYTE_THREE_U8          ((uint8)105U)
#define ESCI_TIMEOUT_DATABYTE_FOUR_U8           ((uint8)119U)
#define ESCI_TIMEOUT_DATABYTE_FIVE_U8           ((uint8)133U)
#define ESCI_TIMEOUT_DATABYTE_SIX_U8            ((uint8)147U)
#define ESCI_TIMEOUT_DATABYTE_SEVEN_U8          ((uint8)161U)
#define ESCI_TIMEOUT_DATABYTE_EIGHT_U8          ((uint8)175U)

/**
* @brief        Interrupt Errors conditions.
*
*/
#define OVERFLOW_ERROR             0x0AU /**< @brief Overflow error occurred
                                              on a channel. */
#define SLAVE_TIMEOUT_ERROR        0x0BU /**< @brief Slave Timeout error
                                              occurred on a channel. */
#define UNREQUESTED_DATA_ERROR     0x0CU /**< @brief Unrequested Data error
                                              occurred on a channel. */
#define PHYSICAL_BUS_ERROR         0x0DU /**< @brief Phisical Bus error
                                              occurred on a channel. */

/**
* @brief        LIN frames states.
*
*/
#define LIN_CH_SEND_HEADER         0x09U /**< @brief The channel is sending
                                             the header part of the frame */
#define LIN_CH_SEND_DATA           0x0AU /**< @brief The channel is sending
                                               the data part of the frame */
#define LIN_CH_SEND_HEADER_ERROR   0x0BU /**< @brief The channel is
               reporting an error after sent the header part of the frame */
#define LIN_CH_SEND_DATA_ERROR     0x0CU /**< @brief The channel is
                 reporting an error after sent the data part of the frame */
#define LIN_CH_RECEIVE_DATA        0x0DU /**< @brief The channel is
                                     receiving the data part of the frame */

/**
* @brief        Macro used to prepare and send the frame.
*
*/
#define MASTER_RESPONSE_HEADER_WRITE_COUNT_U8       ((uint8)3U)
/*
*  @violates @ref Lin_ESCI_h_REF_5 C macros shall only expand to a braced initializer,
*  a constant, a string literal, a parenthesized expression, a type qualifier,
*  a storage class specifier, or a do-while-zero construct.
*/
#define SLAVE_RESPONSE_HEADER_WRITE_COUNT_U8        ((uint8)4U)
/**
* @brief Number of writes on eSCI registers to sent a complete frame
*
*/
#define LIN_HEADER_DATA_WRITE_COUNT_U8              ((uint8)11U)
/**
* @brief Index of the Data Buffer byte zero
*
*/
#define ESCI_ZERO_U8                                ((uint8)0U)
/**
* @brief Index of the Data Buffer byte one
*
*/
#define ESCI_ONE_U8                                 ((uint8)1U)
/**
* @brief Standard length for master request command
*
*/
#define ESCI_MAX_DATA_LENGTH_U8                     ((uint8)8U)
/**
* @brief Index of the Header Buffer byte zero
*
*/
#define ESCI_HEADER_ZERO_U8                         ((uint8)0U)
/**
* @brief Index of the Header Buffer byte one
*
*/
#define ESCI_HEADER_ONE_U8                          ((uint8)1U)
/**
* @brief Index of the Header Buffer byte two
*
*/
#define ESCI_HEADER_TWO_U8                          ((uint8)2U)
/**
* @brief Index of the Header Buffer byte three
*
*/
#define ESCI_HEADER_THREE_U8                        ((uint8)3U)

/**
* @brief        Sleep command type.
*
*/
#define SLEEP_CMD_TYPE_U8                           ((uint8)0x03U)

/**
* @brief        Sleep command ID 0x3C.
*
*/
#define SLEEP_IDENTIFIER_VALUE_U8                   ((uint8)0x3CU)

/**
* @brief        Data 0 of the shadow buffer to send sleep command.
*
*/
#define SLEEP_DATABYTE_ONE_VALUE_U8                 ((uint8)0x00U)

/**
* @brief        Data 1-7 of the shadow buffer to send sleep command.
*
*/
#define SLEEP_DATABYTE_TWO_TO_EIGHT_VALUE_U8        ((uint8)0xFFU)

/**
* @brief        DMA macros.
*
*/
/**
* @brief        Slave Response Diagnostic Frame ID 0x3D.
*
*/
#define ESCI_SLAVE_RESPONSE_DIAGNOSTIC_ID_U8     ((uint8)0x3DU)

/**
* @brief        Master Request Diagnostic Frame ID 0x3C.
*
*/
#define ESCI_MASTER_REQUEST_DIAGNOSTIC_ID_U8     ((uint8)0x3CU)


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

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

/*=================================================================================================
                                 GLOBAL VARIABLE DECLARATIONS
=================================================================================================*/
#define LIN_START_SEC_VAR_NO_INIT_8
/**
* @violates @ref Lin_ESCI_h_REF_1 <MA>_MemMap.h is included after each section define in order to
                 set the current memory section as defined by AUTOSAR.
* @violates @ref Lin_ESCI_h_REF_2 This violation is not fixed since the inclusion of <MA>_MemMap.h
                 is as per AUTOSAR requirement [SWS_MemMap_00003].
*/
#include "Lin_MemMap.h"

#define LIN_STOP_SEC_VAR_NO_INIT_8
/**
* @violates @ref Lin_ESCI_h_REF_1 <MA>_MemMap.h is included after each section define in order to
                 set the current memory section as defined by AUTOSAR.
* @violates @ref Lin_ESCI_h_REF_2 This violation is not fixed since the inclusion of <MA>_MemMap.h
                 is as per AUTOSAR requirement [SWS_MemMap_00003].
*/
#include "Lin_MemMap.h"

#define LIN_START_SEC_VAR_INIT_UNSPECIFIED
/**
* @violates @ref Lin_ESCI_h_REF_1 <MA>_MemMap.h is included after each section define in order to
                 set the current memory section as defined by AUTOSAR.
* @violates @ref Lin_ESCI_h_REF_2 This violation is not fixed since the inclusion of <MA>_MemMap.h
                 is as per AUTOSAR requirement [SWS_MemMap_00003].
*/
#include "Lin_MemMap.h"

#define LIN_STOP_SEC_VAR_INIT_UNSPECIFIED
/**
* @violates @ref Lin_ESCI_h_REF_1 <MA>_MemMap.h is included after each section define in order to
                 set the current memory section as defined by AUTOSAR.
* @violates @ref Lin_ESCI_h_REF_2 This violation is not fixed since the inclusion of <MA>_MemMap.h
                 is as per AUTOSAR requirement [SWS_MemMap_00003].
*/
#include "Lin_MemMap.h"

#define LIN_START_SEC_VAR_NO_INIT_UNSPECIFIED
/**
* @violates @ref Lin_ESCI_h_REF_1 <MA>_MemMap.h is included after each section define in order to
                 set the current memory section as defined by AUTOSAR.
* @violates @ref Lin_ESCI_h_REF_2 This violation is not fixed since the inclusion of <MA>_MemMap.h
                 is as per AUTOSAR requirement [SWS_MemMap_00003].
*/
#include "Lin_MemMap.h"

#define LIN_STOP_SEC_VAR_NO_INIT_UNSPECIFIED
/**
* @violates @ref Lin_ESCI_h_REF_1 <MA>_MemMap.h is included after each section define in order to
                 set the current memory section as defined by AUTOSAR.
* @violates @ref Lin_ESCI_h_REF_2 This violation is not fixed since the inclusion of <MA>_MemMap.h
                 is as per AUTOSAR requirement [SWS_MemMap_00003].
*/
#include "Lin_MemMap.h"
/*=================================================================================================
                                     FUNCTION PROTOTYPES
=================================================================================================*/
#define LIN_START_SEC_CODE
/**
* @violates @ref Lin_ESCI_h_REF_1 <MA>_MemMap.h is included after each section define in order to
                 set the current memory section as defined by AUTOSAR.
* @violates @ref Lin_ESCI_h_REF_2 This violation is not fixed since the inclusion of <MA>_MemMap.h
                 is as per AUTOSAR requirement [SWS_MemMap_00003].
*/
#include "Lin_MemMap.h"

FUNC (void, LIN_CODE) Lin_ESCI_InterruptHandler(CONST(uint8, AUTOMATIC) u8Channel);

/*****************************************************************************
**                          Non-AUTOSAR LIN Low Level Driver API's          **
*****************************************************************************/
FUNC (Std_ReturnType, LIN_CODE) Lin_ESCI_CheckWakeup(CONST(uint8, AUTOMATIC) u8Channel);
FUNC (void, LIN_CODE) Lin_ESCI_InitChannel(CONST(uint8, AUTOMATIC) u8Channel);
FUNC (Std_ReturnType, LIN_CODE) Lin_ESCI_SendHeader(CONST(uint8, AUTOMATIC) u8Channel, \
                                P2CONST(Lin_PduType, AUTOMATIC, LIN_APPL_CONST) pcPduInfoPtr);
FUNC (void, LIN_CODE) Lin_ESCI_SendResponse(CONST(uint8, AUTOMATIC) u8Channel, \
                                P2CONST(Lin_PduType, AUTOMATIC, LIN_APPL_CONST) pcPduInfoPtr);
FUNC (Std_ReturnType, LIN_CODE) Lin_ESCI_GoToSleep(CONST(uint8, AUTOMATIC) u8Channel);
FUNC (Std_ReturnType, LIN_CODE) Lin_ESCI_GoToSleepInternal(CONST(uint8, AUTOMATIC) u8Channel);
FUNC (void, LIN_CODE) Lin_ESCI_Wakeup(CONST(uint8, AUTOMATIC) u8Channel);
FUNC (void, LIN_CODE) Lin_ESCI_WakeupInternal(CONST(uint8, AUTOMATIC) u8Channel);
FUNC (Lin_StatusType, LIN_CODE) Lin_ESCI_HardwareGetStatus(CONST(uint8, AUTOMATIC) u8Channel, \
                                P2VAR(uint8, AUTOMATIC, LIN_APPL_DATA) pLinSduPtr);
FUNC (void, LIN_CODE) Lin_ESCI_CopyData(CONST(uint8, AUTOMATIC) u8Channel, \
                                P2VAR(uint8, AUTOMATIC, LIN_APPL_DATA) pLinSduPtr);

#define LIN_STOP_SEC_CODE
/**
* @violates @ref Lin_ESCI_h_REF_1 <MA>_MemMap.h is included after each section define in order to
                 set the current memory section as defined by AUTOSAR.
* @violates @ref Lin_ESCI_h_REF_2 This violation is not fixed since the inclusion of <MA>_MemMap.h
                 is as per AUTOSAR requirement [SWS_MemMap_00003].
*/
#include "Lin_MemMap.h"

#ifdef __cplusplus
}
#endif

#endif /* Lin_ESCI_H */

/** @} */
