/**
*   @file    Can_43_FLEXCAN.h
*   @implements Can.h_Artifact
*   @version 1.0.0
*
*   @brief   AUTOSAR Can_43_FLEXCAN - module interface.
*   @details API header for CAN driver.
*
*   @addtogroup CAN_DRIVER
*   @{
*/
/*==================================================================================================
*   Project              : AUTOSAR 4.3 MCAL
*   Platform             : PA
*   Peripheral           : FLEXCAN
*   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 CAN_43_FLEXCAN_H
#define CAN_43_FLEXCAN_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 Can_43_FLEXCAN_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 <MA>_MemMap.h is as per AUTOSAR requirement [SWS_MemMap_00003].
*
* @section Can_43_FLEXCAN_h_REF_2
* Violates MISRA 2012 Advisory Rule 2.5, A project should not contain unused macro declarations.
* Declaration is reserved for future feature.
*
* @section Can_43_FLEXCAN_h_REF_3
* Violates MISRA 2012 Advisory Rule 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 Can_43_FLEXCAN_h_REF_4
* Violates MISRA 2012 Advisory Rule 2.3, A project should not contain unused type declarations.
* The declarations are used depend on user configuration.
*
*/

/*
(CAN043) The file Can.h contains the declaration of the Can module API.
(CAN037) The file Can.h only contains 'extern' declarations of constants, global data, type definitions and services
            that are specified in the Can module SWS.
*/

/**
* @file           Can.h
*/

/*==================================================================================================
*                                        INCLUDE FILES
* 1) system and project includes
* 2) needed interfaces from external units
* 3) internal and external interfaces from this unit
==================================================================================================*/
/**
* @file           Can.h
*/
#include "ComStack_Types.h"
#include "Can_43_FLEXCAN_Cfg.h"
#include "Can_GeneralTypes.h"
#include "Soc_Ips.h"


/*==================================================================================================
*                              SOURCE FILE VERSION INFORMATION
==================================================================================================*/
/*
    Internal micro-dependent versioning. Check of AUTOSAR & Vendor specification version.
*/
/**
* @{
* @file           Can.h
*/
#define CAN_43_FLEXCAN_VENDOR_ID                   43
/* @violates @ref Can_43_FLEXCAN_h_REF_2 MISRA 2012 Advisory Rule 2.5 */
#define CAN_43_FLEXCAN_MODULE_ID                   80
#define CAN_43_FLEXCAN_AR_RELEASE_MAJOR_VERSION    4
#define CAN_43_FLEXCAN_AR_RELEASE_MINOR_VERSION    3
#define CAN_43_FLEXCAN_AR_RELEASE_REVISION_VERSION 1
#define CAN_43_FLEXCAN_SW_MAJOR_VERSION            1
#define CAN_43_FLEXCAN_SW_MINOR_VERSION            0
#define CAN_43_FLEXCAN_SW_PATCH_VERSION            0
/**@}*/

/*==================================================================================================
*                                     FILE VERSION CHECKS
==================================================================================================*/
/* Check if current file and Can configuration header file are of the same vendor */
#if (CAN_43_FLEXCAN_VENDOR_ID != CAN_43_FLEXCAN_VENDOR_ID_CFG)
#error "Can_43_FLEXCAN.h and Can_43_FLEXCAN_Cfg.h have different vendor ids"
#endif
/* Check if current file and Can configuration header file are of the same Autosar version */
#if ((CAN_43_FLEXCAN_AR_RELEASE_MAJOR_VERSION != CAN_43_FLEXCAN_AR_RELEASE_MAJOR_VERSION_CFG_H) || \
     (CAN_43_FLEXCAN_AR_RELEASE_MINOR_VERSION != CAN_43_FLEXCAN_AR_RELEASE_MINOR_VERSION_CFG_H) || \
     (CAN_43_FLEXCAN_AR_RELEASE_REVISION_VERSION != CAN_43_FLEXCAN_AR_RELEASE_REVISION_VERSION_CFG_H))
  #error "AutoSar Version Numbers of Can_43_FLEXCAN.h and Can_43_FLEXCAN_Cfg.h are different"
#endif

/* Check if current file and CAN configuration header file are of the same software version */
#if ((CAN_43_FLEXCAN_SW_MAJOR_VERSION != CAN_43_FLEXCAN_SW_MAJOR_VERSION_CFG_H) || \
     (CAN_43_FLEXCAN_SW_MINOR_VERSION != CAN_43_FLEXCAN_SW_MINOR_VERSION_CFG_H) || \
     (CAN_43_FLEXCAN_SW_PATCH_VERSION != CAN_43_FLEXCAN_SW_PATCH_VERSION_CFG_H))
  #error "Software Version Numbers of Can_43_FLEXCAN.h and Can_43_FLEXCAN_Cfg.h are different"
#endif
/* Check if current file and CAN configuration header file are of the same software version */
#ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
#if ((CAN_43_FLEXCAN_AR_RELEASE_MAJOR_VERSION != COMTYPE_AR_RELEASE_MAJOR_VERSION) || \
     (CAN_43_FLEXCAN_AR_RELEASE_MINOR_VERSION != COMTYPE_AR_RELEASE_MINOR_VERSION) )
  #error "Software Version Numbers of Can_43_FLEXCAN.h and ComStack_Types.h are different"
#endif
#endif

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

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

#if (CAN_43_FLEXCAN_DEV_ERROR_DETECT == STD_ON)
/**
* @{
* @brief          Development errors.
* @details        (CAN104) The Can module shall be able to detect the following errors and exceptions depending on its configuration (development/production).
*                 (CAN026) Development Errors shall indicate errors that are caused by erroneous usage of the Can module API. This covers API
*                   parameter checks and call sequence errors.
*                 (CAN080) Development error values are of type uint8.
*
*/
#define CAN_43_FLEXCAN_E_PARAM_POINTER         ((uint8)0x01U)
#define CAN_43_FLEXCAN_E_PARAM_HANDLE          ((uint8)0x02U)
#define CAN_43_FLEXCAN_E_PARAM_DATA_LENGTH     ((uint8)0x03U)
#define CAN_43_FLEXCAN_E_PARAM_CONTROLLER      ((uint8)0x04U)
#define CAN_43_FLEXCAN_E_UNINIT                ((uint8)0x05U)
#define CAN_43_FLEXCAN_E_TRANSITION            ((uint8)0x06U)
/* @violates @ref Can_43_FLEXCAN_h_REF_2 MISRA 2012 Advisory Rule 2.5 */
#define CAN_43_FLEXCAN_E_PARAM_BAUDRATE        ((uint8)0x07U)
/* @violates @ref Can_43_FLEXCAN_h_REF_2 MISRA 2012 Advisory Rule 2.5 */
#define CAN_43_FLEXCAN_E_ICOM_CONFIG_INVALID   ((uint8)0x08U)
/* @violates @ref Can_43_FLEXCAN_h_REF_2 MISRA 2012 Advisory Rule 2.5 */
#define CAN_43_FLEXCAN_E_INIT_FAILED           ((uint8)0x09U)
/* @violates @ref Can_43_FLEXCAN_h_REF_2 MISRA 2012 Advisory Rule 2.5 */
#define CAN_43_FLEXCAN_E_INVALID_CONTROLLER    ((uint8)0x0AU)

#define CAN_43_FLEXCAN_E_DATALOST           ((uint8)0x01U)
/**@}*/
#endif

/**
* @{
* @brief          Service ID (APIs) for Det reporting
* @details        Service ID (APIs) for Det reporting
*
*/
/* @violates @ref Can_43_FLEXCAN_h_REF_2 MISRA 2012 Advisory Rule 2.5 */
#define CAN_43_FLEXCAN_SID_INIT                          ((uint8)0x00U)
/* @violates @ref Can_43_FLEXCAN_h_REF_2 MISRA 2012 Advisory Rule 2.5 */
#define CAN_43_FLEXCAN_SID_MAIN_FUNCTION_WRITE           ((uint8)0x01U)
/* @violates @ref Can_43_FLEXCAN_h_REF_2 MISRA 2012 Advisory Rule 2.5 */
#define CAN_43_FLEXCAN_SID_SET_CONTROLLER_MODE           ((uint8)0x03U)
/* @violates @ref Can_43_FLEXCAN_h_REF_2 MISRA 2012 Advisory Rule 2.5 */
#define CAN_43_FLEXCAN_SID_DISABLE_CONTROLLER_INTERRUPTS ((uint8)0x04U)
/* @violates @ref Can_43_FLEXCAN_h_REF_2 MISRA 2012 Advisory Rule 2.5 */
#define CAN_43_FLEXCAN_SID_ENABLE_CONTROLLER_INTERRUPTS  ((uint8)0x05U)
/* @violates @ref Can_43_FLEXCAN_h_REF_2 MISRA 2012 Advisory Rule 2.5 */
#define CAN_43_FLEXCAN_SID_WRITE                         ((uint8)0x06U)
/* @violates @ref Can_43_FLEXCAN_h_REF_2 MISRA 2012 Advisory Rule 2.5 */
#define CAN_43_FLEXCAN_SID_GET_VERSION_INFO              ((uint8)0x07U)
/* @violates @ref Can_43_FLEXCAN_h_REF_2 MISRA 2012 Advisory Rule 2.5 */
#define CAN_43_FLEXCAN_SID_MAIN_FUNCTION_READ            ((uint8)0x08U)
/* @violates @ref Can_43_FLEXCAN_h_REF_2 MISRA 2012 Advisory Rule 2.5 */
#define CAN_43_FLEXCAN_SID_MAIN_FUNCTION_BUS_OFF         ((uint8)0x09U)
/* @violates @ref Can_43_FLEXCAN_h_REF_2 MISRA 2012 Advisory Rule 2.5 */
#define CAN_43_FLEXCAN_SID_MAIN_FUNCTION_WAKEUP          ((uint8)0x0AU)
/* @violates @ref Can_43_FLEXCAN_h_REF_2 MISRA 2012 Advisory Rule 2.5 */
#define CAN_43_FLEXCAN_SID_CBK_CHECK_WAKEUP              ((uint8)0x0BU)
/* @violates @ref Can_43_FLEXCAN_h_REF_2 MISRA 2012 Advisory Rule 2.5 */
#define CAN_43_FLEXCAN_SID_MAIN_FUNCTION_MODE            ((uint8)0x0CU)
/* @violates @ref Can_43_FLEXCAN_h_REF_2 MISRA 2012 Advisory Rule 2.5 */
#define CAN_43_FLEXCAN_SID_CHANGE_BAUDRATE               ((uint8)0x0DU)
/* @violates @ref Can_43_FLEXCAN_h_REF_2 MISRA 2012 Advisory Rule 2.5 */
#define CAN_43_FLEXCAN_SID_CHECK_BAUDRATE                ((uint8)0x0EU)
/* @violates @ref Can_43_FLEXCAN_h_REF_2 MISRA 2012 Advisory Rule 2.5 */
#define CAN_43_FLEXCAN_SID_SET_BAUDRATE                  ((uint8)0x0FU)
/* @violates @ref Can_43_FLEXCAN_h_REF_2 MISRA 2012 Advisory Rule 2.5 */
#define CAN_43_FLEXCAN_SID_DEINIT                        ((uint8)0x10U)
/* @violates @ref Can_43_FLEXCAN_h_REF_2 MISRA 2012 Advisory Rule 2.5 */
#define CAN_43_FLEXCAN_SID_GETCONTROLLERERRORSTATE       ((uint8)0x11U)
/* @violates @ref Can_43_FLEXCAN_h_REF_2 MISRA 2012 Advisory Rule 2.5 */
#define CAN_43_FLEXCAN_SID_GETCONTROLLERMODE             ((uint8)0x12U)
/* @violates @ref Can_43_FLEXCAN_h_REF_2 MISRA 2012 Advisory Rule 2.5 */
#define CAN_43_FLEXCAN_SID_SETCLOCKMODE                  ((uint8)0x11U)
/* @violates @ref Can_43_FLEXCAN_h_REF_2 MISRA 2012 Advisory Rule 2.5 */
#define CAN_43_FLEXCAN_SID_SET_ICOM_CONFIG               ((uint8)0x0FU)
/* @violates @ref Can_43_FLEXCAN_h_REF_2 MISRA 2012 Advisory Rule 2.5 */
#define CAN_43_FLEXCAN_SID_ABORT_MB                      ((uint8)0x10U)

/**@}*/

/**
* @brief          Can_Busy
* @details        CAN_BUSY return from Functions.
* @implements     Can_ReturnType_enumeration
*/

/**< @brief Operation was rejected because of busy state */
#define        CAN_BUSY  (0x2U)

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

/**
* @brief          Can_43_FLEXCAN_ObjType
* @details        Used for value received by Tressos interface configuration.
*                 Describe the MB configuration.
*
*/
typedef enum
    {
        CAN_43_FLEXCAN_RECEIVE = 0U,   /**< @brief Receive MB */
        CAN_43_FLEXCAN_TRANSMIT        /**< @brief Transmit MB */
    } Can_43_FLEXCAN_ObjType;


/**
* @brief          Can_43_FLEXCANIdType
* @details        Used for value received by Tressos interface configuration.
*                 Used to diferentiate Extended, Mixed or Standard Id type.
*
*/
typedef enum
    {
        CAN_43_FLEXCAN_EXTENDED = 0U,  /**< @brief Extended ID (29 bits) */
        CAN_43_FLEXCAN_STANDARD,       /**< @brief Standard ID (11 bits) */
        CAN_43_FLEXCAN_MIXED           /**< @brief Mixed ID (29 bits) */
    } Can_43_FLEXCANIdType;


/**
* @brief          Can_43_FLEXCAN_StatusType
* @details        CAN Driver status used for checking and preventing double driver intialization.
*                 CAN_UNINIT = The CAN controller is not initialized. The CAN Controller is not participating on the CAN bus.
*                              All registers belonging to the CAN module are in reset state, CAN interrupts are disabled.
*                 CAN_READY = Controller has initialized: static variables, including flags;
*                             Common setting for the complete CAN HW unit; CAN controller specific settings for each CAN controller.
*
*/
typedef enum
    {
        CAN_43_FLEXCAN_UNINIT = 0U, /**< @brief Driver not initialized */
        CAN_43_FLEXCAN_READY       /**< @brief Driver ready */
    } Can_43_FLEXCAN_StatusType;

#if (CAN_43_FLEXCAN_DUAL_CLOCK_MODE == STD_ON)
/**
* @brief          Can_43_FLEXCAN_ClockModeType
* @details        CAN source clock selection used in Can_SetClockMode Non-Autosar API.
*
*/
typedef enum
    {
        CAN_43_FLEXCAN_NORMAL = 0U, /**< @brief Standard configuration (default) */
        CAN_43_FLEXCAN_ALTERNATE    /**< @brief Second configuration (special) */
    } Can_43_FLEXCAN_ClockModeType;
#endif

#if (CAN_43_FLEXCAN_PUBLIC_ICOM_SUPPORT == STD_ON)
 /**
* @brief          Can_IcomLevelype
* @details        Defines the level of Pretended Networking.This parameter is reserved for future implementations (Pretended Networking level 2).
*
*/      
typedef enum
    {
        CAN_43_FLEXCAN_AND =0U ,
        CAN_43_FLEXCAN_EQUAL,
        CAN_43_FLEXCAN_GREATER,
        CAN_43_FLEXCAN_SMALLER,
        CAN_43_FLEXCAN_XOR
    } Can_43_FLEXCAN_IcomSignalOperationType;

    
 /**
* @brief          Can_IcomLevelype
* @details        Defines the level of Pretended Networking.This parameter is reserved for future implementations (Pretended Networking level 2).
*
*/      
typedef enum
    {
        CAN_43_FLEXCAN_EXACTLY =0U,
        CAN_43_FLEXCAN_GREATER_MINNUM,
        CAN_43_FLEXCAN_SMALLER_MAXNUM,
        CAN_43_FLEXCAN_INSIDE_RANGE
    } Can_43_FLEXCAN_IcomIdOperationType;
#endif
#if (defined(CAN_43_FLEXCAN_MESSAGE_BUFFER_TIMESTAMP_USED) || defined(CAN_43_FLEXCAN_HIGH_RESOLUTION_TIMESTAMP_USED))
#ifdef CAN_43_FLEXCAN_MESSAGE_BUFFER_TIMESTAMP_USED
/**
* @brief          Can_MBTimestampBaseType
* @details        Defines which time base is used for capturing the 16-bit TIME_STAMP field of the Message Buffer register.
*
*/
typedef enum
    {
        CAN_43_FLEXCAN_MESSAGE_BUFFER_TIMER =0U,
        CAN_43_FLEXCAN_LOWER_16BIT_HR_TIMER,
        CAN_43_FLEXCAN_UPPER_16BIT_HR_TIMER
    } Can_43_FLEXCAN_MBTimestampBaseType;
#endif

/**
* @brief          Can_HRTimestampCapturePointType
* @details        Defines point in time when a 32-bit time base is captured during a CAN frame and stored in the high resolution time stamp register.
*
*/
typedef enum
    {
        CAN_43_FLEXCAN_HR_TIMESTAMP_DIS = 0U,
        CAN_43_FLEXCAN_END_OF_FRAME =1U,
        CAN_43_FLEXCAN_START_OF_FRAME = 2U,
        CAN_43_FLEXCAN_START_RES_FRAME = 3U
    } Can_43_FLEXCAN_HRTimestampCapturePointType;
#endif

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

#if (CAN_43_FLEXCAN_PUBLIC_ICOM_SUPPORT == STD_ON)
typedef struct
{
    CONST(uint32, CAN_CONST) CanIcomSignalMaskLow;
    CONST(uint32, CAN_CONST) CanIcomSignalMaskHigh;
    CONST(Can_43_FLEXCAN_IcomSignalOperationType, CAN_CONST) CanIcomSignalOperation;
    CONST(uint32, CAN_CONST) CanIcomSignalValueLow;
    CONST(uint32, CAN_CONST) CanIcomSignalValueHigh;
    CONST(uint8, CAN_CONST) DLCLowValue;
    CONST(uint8, CAN_CONST) DLCHighValue;
    CONST(uint32, CAN_CONST) CanIcomSignalRef;
} Can_43_FLEXCAN_IcomRxMessageSignalType;

typedef struct
{
    
    CONST(uint32, CAN_CONST) CanIcomCounterValue;
    CONST(uint32, CAN_CONST) CanIcomMessageId;
    CONST(uint32, CAN_CONST) CanIcomMessageIdMask;
    CONST(uint32, CAN_CONST) CanIcomMissingMessageTimerValue;
    CONST(Can_43_FLEXCAN_IcomIdOperationType, CAN_CONST) CanIcomIdOperation;
    CONST(uint8, CAN_CONST) u8NumCanIcomRxMessageSignal;
    CONST(boolean, CAN_CONST) CanFiltPayload;
    P2CONST(Can_43_FLEXCAN_IcomRxMessageSignalType, CAN_CONST, CAN_APPL_CONST) pCanIcomRxMessageSignalConfigs;
} Can_43_FLEXCAN_IcomRxMessageConfigsType;    

typedef struct
{
    CONST(uint8, CAN_CONST) u8CanIcomConfigId;
    CONST(boolean, CAN_CONST) CanIcomWakeOnBusOff;
    CONST(uint8, CAN_CONST) u8NumberCanIcomRxMessage;
    P2CONST(Can_43_FLEXCAN_IcomRxMessageConfigsType, CAN_CONST, CAN_APPL_CONST) pCanIcomRxMessageConfigs;
} Can_43_FLEXCAN_IcomConfigsType;    

#endif

/**
* @brief          Configuration of FlexCAN controller.
* @details        This structure is initialized by Tresos considering user settings.
*                 Used by Can_ChangeBaudrate() API to set the default baudrate after initialization.
*                 and to change the baudrate when the FlexCAN is in stopped mode.
*
*/
#if (CAN_43_FLEXCAN_FD_MODE_ENABLE == STD_ON)
typedef struct
    {
        CONST(uint32, CAN_CONST) u32CanFdEnable;
        CONST(uint32, CAN_CONST) u32CanFdBaudRate;
        CONST(uint32, CAN_CONST) u32CanFdCbtRegister;
        CONST(uint32, CAN_CONST) u32CanControllerTrcvDelayCompensation;
        CONST(uint32, CAN_CONST) u32CanControllerTxBitRateSwitch;
#if ( (CAN_43_FLEXCAN_CONTROLLER_FD_ISO_CANFD == STD_ON) || (CAN_43_FLEXCAN_CONTROLLER_FD_PREXCEN == STD_ON) || (CAN_43_FLEXCAN_CONTROLLER_FD_EDFLTDIS == STD_ON))
        CONST(uint32, CAN_CONST) u32CanFdCTRL2Register;
#endif
    } Can_43_FLEXCAN_ControllerFdConfigType;
#endif

/**
* @brief          Configuration of FlexCAN controller.
* @details        This structure is initialized by Tresos considering user settings.
*                 Used by Can_ChangeBaudrate() API to set the default baudrate after initialization.
*                 and to change the baudrate when the FlexCAN is in stopped mode.
*
*/
typedef struct
    {  
        CONST(uint32, CAN_CONST) u32ControlRegister; /**< @brief Content of the Control Register (CTRL) fields: PRESDIV, RJW, PSEG1, PSEG2, CLKSRC, LPB, SMP, BOFF_REC, LOM, PROPSEG. */ 

        CONST(uint8, CAN_CONST) u8TxArbitrationStartDelay; /**< @brief The value of the Tx Arbitration Start Delay (TASD) bit field. */     

#if (CAN_43_FLEXCAN_DUAL_CLOCK_MODE == STD_ON)

        CONST(uint32, CAN_CONST) u32ControlRegisterAlternate; /**< @brief Content of the Control Register (CTRL) fields: PRESDIV, RJW, PSEG1, PSEG2, CLKSRC, LPB, SMP, BOFF_REC, LOM, PROPSEG. */

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

#if (CAN_43_FLEXCAN_FD_MODE_ENABLE == STD_ON)
        CONST(Can_43_FLEXCAN_ControllerFdConfigType, CAN_CONST) ControllerFD; /*FD settings */
#endif

#if (CAN_43_FLEXCAN_CBT_ENABLE == STD_ON)
        CONST(boolean, CAN_CONST) bControllerCbtEnable; /* CBT enable */
#endif

#if (CAN_43_FLEXCAN_SET_BAUDRATE_API == STD_ON)
        CONST(uint16, CAN_CONST) u16ControllerBaudRateConfigID;
#endif

    } Can_43_FLEXCAN_ControllerBaudrateConfigType;
    
/**
* @brief          Configuration of FlexCAN controller.
* @details        This structure is initialized by Tresos considering user settings.
*                 Used by Can_ChangeBaudrate() API to set the default baudrate after initialization.
*                 and to change the baudrate when the FlexCAN is in stopped mode.
*
*/
typedef struct
    {
     
        CONST(uint32, CAN_CONST) u32ControlRegister; /**< @brief Content of the Control Register (CTRL) fields: PRESDIV, RJW, PSEG1, PSEG2, CLKSRC, LPB, SMP, BOFF_REC, LOM, PROPSEG. */
   
#if (CAN_43_FLEXCAN_DUAL_CLOCK_MODE == STD_ON)
        CONST(uint32, CAN_CONST) u32ControlRegisterAlternate; /**< @brief Content of the Control Register (CTRL) fields: PRESDIV, RJW, PSEG1, PSEG2, CLKSRC, LPB, SMP, BOFF_REC, LOM, PROPSEG. */
#endif /* (CAN_43_FLEXCAN_DUAL_CLOCK_MODE == STD_ON) */
    } Can_43_FLEXCAN_Static_ControllerBaudrateConfigType;


    
/*
* @{
* @brief          Can_IdPtrType
* @details        Type for storing pointer to the Identifier Lenght Type.
*                 - used by "Can_43_FLEXCAN_ConfigType" structure (pointer to the FilterMasks).
*
*/
typedef CONSTP2CONST(Can_IdType, CAN_CONST, CAN_APPL_CONST) Can_IdPtrType;
/**@}*/

#if (defined(CAN_43_FLEXCAN_MESSAGE_BUFFER_TIMESTAMP_USED) || defined(CAN_43_FLEXCAN_HIGH_RESOLUTION_TIMESTAMP_USED))
    typedef void (*Can_TxTimestampPCallBackType)(VAR(Can_HwHandleType, CAN_VAR) Hoh, VAR(uint32, CAN_VAR) CanTxPduId, VAR(uint32, CAN_VAR) u32TimestampVal);
    typedef void (*Can_RxTimestampPCallBackType)(VAR(Can_HwHandleType, CAN_VAR) Hoh, VAR(uint32, CAN_VAR) u32TimestampVal);
#endif

#if (CAN_43_FLEXCAN_RXFIFO_ENABLE == STD_ON)
/**
* @brief          Rx Fifo Table IDs and Filter Masks
* @details        Rx Fifo Table IDs and Filter Masks
*
*/
typedef struct
    {
        CONST(uint32, CAN_CONST) u32TableId; /**< @brief Table with the IDs specific for Rx Fifo */

        CONST(uint32, CAN_CONST) u32TableFilterMask; /**< @brief Table with the Filter masks */

    } Can_43_FLEXCAN_RxFiFoTableIdConfigType;


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

/**
* @brief          Type for pointer to function.
* @details        Type for pointer to function. Used for user handlers from plugin.
*
*/
/* @violates @ref Can_43_FLEXCAN_h_REF_4 MISRA 2012 Advisory Rule 2.3 */
typedef void (*Can_PCallBackType)( void);


/**
* @brief          Can_43_FLEXCAN_MBConfigObjectType
* @details        Type for storing information about Message Buffers (CAN hardware objs).
*                 Used by Can_43_FLEXCAN_MBConfigContainerType.
*
*/
typedef struct
    {
        VAR(Can_HwHandleType, CAN_VAR) uIdMaskIndex; /**< @brief Index into array of Can_FilterMaskType values (uint8/uint16), Current MB and the coresponding filter mask. */

        CONST(uint8, CAN_CONST) u8ControllerId; /**< @brief Controller ID (index into controller address array containing Can_ControllerPtrType). */

        VAR(Can_43_FLEXCANIdType, CAN_VAR) uIdType; /**< @brief ID type: CAN_EXTENDED, CAN_STANDARD, CAN_MIXED. */

        VAR(Can_43_FLEXCAN_ObjType, CAN_VAR) eMBType; /**< @brief Receive/Transmit */

        VAR(Can_IdType, CAN_VAR) uMessageId; /**< @brief (extended identifier) (uint16/uint32). configurable by CanHardwareObject/CanIdValue. */

        CONST(uint8, CAN_CONST) u8LocalPriority; /**< @brief Local priority bits used for arbitration. */

        VAR(uint32, CAN_VAR) u32HWObjID; /**< @brief HW Obiect ID */
        
#if (CAN_43_FLEXCAN_FD_MODE_ENABLE == STD_ON)
        VAR(uint8, CAN_VAR) u8FdPaddingValue; /**< @brief Padding value for MB > 8 bytes */
#endif

        CONST(uint8, CAN_CONST) u32CanMainFuncRWPeriodRef; /**< @brief read write period reference */
        CONST(uint16, CAN_CONST) u16MBOffsetAddr;          /**< @brief offset address of MB */
        CONST(uint8, CAN_CONST)  u8MBPayloadLength;        /**< @brief MB data size */
        CONST(uint8, CAN_CONST)  u8HWMBIndex;              /**< @brief The index of MB in message buffer memory */

#if (CAN_43_FLEXCAN_TRIGGER_TRANSMIT_EN == STD_ON)
        CONST(boolean, CAN_CONST) CanTriggerTransmitEnable; /**< @brief The parameter is used to detect the MB which run with trigger transmit feature*/
#endif
        CONST(boolean, CAN_CONST) CanHwObjectUsesPolling; /**< @brief The parameter is used to detect the MB which is use Polling or Interrupt */
#if (defined(CAN_43_FLEXCAN_MESSAGE_BUFFER_TIMESTAMP_USED) || defined(CAN_43_FLEXCAN_HIGH_RESOLUTION_TIMESTAMP_USED))
        CONST(boolean, CAN_CONST) CanTimestampEnable; /**< @brief The parameter is used to detect the MB which is use to get Timestamp or not */
#endif
    } Can_43_FLEXCAN_MBConfigObjectType;


/**
* @brief          Type for storing Message Buffer configurations.
* @details        The MessageBufferConfigs array is sorted according to:
*                 - HRHs first, HTHs next (AutoSAR requirement)
*                 - Controller ID (HRHs and HTHs belonging to all controllers must be grouped together)
*                 - Message ID (to ensure top priority IDs are first which means they will be serviced first)
*
*/
typedef struct
    {
        CONSTP2CONST(Can_43_FLEXCAN_MBConfigObjectType, CAN_CONST, CAN_APPL_CONST) pMessageBufferConfigsPtr; /**< @brief Pointer to the MB array . */

        CONST(Can_HwHandleType, CAN_CONST) uMessageBufferConfigCount; /**< @brief Number of elements in the array -( having 6 controllers with 64MBs each uint8 is not enough to store this value -> the type is extended to uint16). */

    } Can_43_FLEXCAN_MBConfigContainerType;


/**
* @brief          Structure for describing individual FlexCAN controllers on the chip.
* @details        HRH = Hardware Receive Handle (HRH) is defined and provided by the CAN driver.
*                       Each HRH represents exactly one hardware object.
*                       The HRH can be used to optimize software filtering.
*                 HTH = The Hardware Transmit Handle (HTH) is defined and provided by the CAN driver.
*                       Each HTH represents one or several hardware objects, that are
*                       configured as hardware transmit pool.
*
*/
typedef struct
    {
        CONST(uint8, CAN_CONST) u8MaxMBCount; /**< @brief Max Message Buffer number. */
        CONST(uint16, CAN_CONST) u8MaxBaudRateCount; /**< @brief Max BaudRate number. */
        CONST(uint16, CAN_CONST) u8DefaultBaudRateIndex; /**< @brief Default baudrate index. */
        CONSTP2CONST(Can_43_FLEXCAN_ControllerBaudrateConfigType, CAN_CONST, CAN_APPL_CONST) pControllerBaudrateConfigsPtr; /**< @brief Pointer to the Configuration of Baudrate timing parameter for FlexCAN baudrate controller ( CTRL value register). */
#if (CAN_43_FLEXCAN_RXFIFO_ENABLE == STD_ON)
    #if (CAN_43_FLEXCAN_LEGACY_RXFIFO_ENABLE == STD_ON)
        CONST(uint32, CAN_CONST) u32RxFifoGlobalMask; /**< @brief Rx Fifo Global mask value */
        CONST(uint8, CAN_CONST) u8RxFiFoUsedMb; /**< @brief Number of MBs used by Rx Fifo */
        CONST(Can_PCallBackType, CAN_CONST) Can_RxFifoWarningNotification; /**< @brief Pointer to RX FIFO Warning notification function. */
    #endif /* (CAN_43_FLEXCAN_LEGACY_RXFIFO_ENABLE == STD_ON) */
    #if (CAN_43_FLEXCAN_ENHANCED_RXFIFO_ENABLE == STD_ON)
        CONST(uint16, CAN_CONST) u16EnhancedRxFifoNFE; /**< @brief Number of Filter Elements */
        CONST(uint16, CAN_CONST) u16EnhancedRxFifoNEXIF; /**< @brief Number of Extended Filter Elements */
        #ifdef CAN_43_FLEXCAN_DMA_USED
            CONST(uint8, CAN_CONST) u8EnhancedRxFifoDMAChanel; /**< @brief DMA channel */
            CONST(uint8, CAN_CONST) u8NumberMBTransfer; /**< @brief Number of water mask */
            P2VAR(uint8, CAN_CONST, CAN_APPL_CONST) pDestBuffer;
        #endif
    #endif /* (CAN_43_FLEXCAN_ENHANCED_RXFIFO_ENABLE = STD_ON) */
        CONST(Can_PCallBackType, CAN_CONST) Can_RxFifoOverflowNotification; /**< @brief Pointer to RX FIFO Overflow notification function. */
#endif  /* (CAN_43_FLEXCAN_RXFIFO_ENABLE == STD_ON) */
  #if (CAN_43_FLEXCAN_FD_MODE_ENABLE == STD_ON)
        CONST(uint32, CAN_CONST) u32MBBlockSize; /**< @brief This parameter is used to configure for three MBDSR fields in CAN_FDCTRL register */
  #endif
        CONST(uint32, CAN_CONST) u32Options; /**< @brief Interrupt line */
 
    } Can_43_FLEXCAN_ControlerDescriptorType;
    

    /**
* @brief          Structure for describing individual FlexCAN controllers on the chip.
* @details        HRH = Hardware Receive Handle (HRH) is defined and provided by the CAN driver.
*                       Each HRH represents exactly one hardware object.
*                       The HRH can be used to optimize software filtering.
*                 HTH = The Hardware Transmit Handle (HTH) is defined and provided by the CAN driver.
*                       Each HTH represents one or several hardware objects, that are
*                       configured as hardware transmit pool.
*
*/
typedef struct
    {
#ifdef CAN_43_FLEXCAN_ENABLE_WAKEUP_SUPPORT
    #if (CAN_43_FLEXCAN_ENABLE_WAKEUP_SUPPORT == STD_ON)
        CONST(uint32, CAN_CONST) u32ECUMWakeupSourceId; /* ID source Wakeup of EcuM*/
    #endif
#endif
        CONST(uint8, CAN_CONST) u8ControllerOffset; /**< @brief Hardware Offset for Can controller: FLEXCAN_A = Offset[0], FLEXCAN_B = Offset[1], ... */
        CONSTP2CONST(Can_43_FLEXCAN_Static_ControllerBaudrateConfigType, CAN_CONST, CAN_APPL_CONST) pStaticControllerBaudrateConfigsPtr; /**< @brief Pointer to the Configuration of Baudrate timing parameter for FlexCAN baudrate controller ( CTRL value register). */
    #if (CAN_43_FLEXCAN_ERROR_NOTIFICATION_ENABLE == STD_ON)
        CONST(Can_PCallBackType, CAN_CONST) Can_ErrorNotification; /*< @brief Pointer to Error interrupt notification function (ESR[ERR_INT]). */
    #endif
        CONST(uint8, CAN_CONST) u8NumberOfMB; /*< @brief Number of message Buffers available for FlexCan unit. */
    #if (CAN_43_FLEXCAN_PUBLIC_ICOM_SUPPORT == STD_ON)
        CONST(boolean, CAN_CONST) bPnSupported;
    #endif
        CONST(uint32, CAN_CONST) u32Options; /*< @brief BusOff Sw Recovery, RXFifo En, IDAM Type,  Event Trigger Mode TxProcessing/RxProcessing/BusoffProcessing. */
    } CanStatic_43_FLEXCAN_ControlerDescriptorType;
    
/**
* @brief          Top Level structure containing all Driver configuration.
* @details        A pointer to this structure is transmitted to Can_Init() to initalize the driver at startup.
*                 The application selects one of the configurations by using a pointer to one of the elements
*                 of this array as a parameter of the Can_Init function.
*
*/
typedef struct
    {
        VAR(uint8, CAN_VAR) u8ControllersConfigured; /**< @brief Number of Can Controllers configured in Tresos plugin. */

        P2CONST(CanStatic_43_FLEXCAN_ControlerDescriptorType, CAN_CONST, CAN_APPL_CONST) StaticControlerDescriptors; /**< @brief Pointer to the first FlexCAN Controller description. */

        /*Maximum Object IDs configured */
        VAR(uint32, CAN_VAR) u32CanMaxObjectId;
           
#if (CAN_43_FLEXCAN_PUBLIC_ICOM_SUPPORT == STD_ON)
        CONST(uint8, CAN_CONST) u8NumCanIcomConfigs;
    
        P2CONST(Can_43_FLEXCAN_IcomConfigsType, CAN_CONST, CAN_APPL_CONST) pCanIcomConfigs;

 #endif
    } CanStatic_43_FLEXCAN_ConfigType;
    
    
/**
* @brief          Top Level structure containing all Driver configuration.
* @details        A pointer to this structure is transmitted to Can_Init() to initalize the driver at startup.
*                 The application selects one of the configurations by using a pointer to one of the elements
*                 of this array as a parameter of the Can_Init function.
*
*/
typedef struct
    {

        VAR(Can_IdPtrType, CAN_VAR) pFilterMasks; /**< @brief Pointer to the first FilterMask value - any controller can have many filter masks for Can messages. */
        CONST(Can_43_FLEXCAN_MBConfigContainerType, CAN_CONST) MBConfigContainer; /**< @brief Pointer to the first MB configuration of this Controller. */
        P2CONST(Can_43_FLEXCAN_ControlerDescriptorType, CAN_CONST, CAN_APPL_CONST) ControlerDescriptors; /**< @brief Pointer to the first FlexCAN Controller description. */
   
#if (CAN_43_FLEXCAN_RXFIFO_ENABLE == STD_ON)
        CONSTP2CONST(Can_43_FLEXCAN_RxFiFoTableIdConfigType, CAN_CONST, CAN_APPL_CONST) pRxFiFoTableIdConfig; /**< @brief Pointer to the Table IDs for the RxFifo. */
#endif /* (CAN_43_FLEXCAN_RXFIFO_ENABLE == STD_ON) */

        /* The index of the first HTH configured */
        CONST(Can_HwHandleType, CONST) uCanFirstHTHIndex;
#if (defined(CAN_43_FLEXCAN_MESSAGE_BUFFER_TIMESTAMP_USED) || defined(CAN_43_FLEXCAN_HIGH_RESOLUTION_TIMESTAMP_USED))
    #ifdef CAN_43_FLEXCAN_MESSAGE_BUFFER_TIMESTAMP_USED
        /* This field selects which time base is used for capturing the 16-bit TIME_STAMP field of the Message Buffer register */
        CONST(Can_43_FLEXCAN_MBTimestampBaseType, CONST) eMBTimestampBase;
        /* Selects TimeStamp Time Tick Source for Free Running Time */
        CONST(boolean, CONST) bExternalClockEnable;
    #endif
    /* This field configures the point in time when a 32-bit time base is captured during a CAN frame and stored in the high resolution time stamp register */
    CONST(Can_43_FLEXCAN_HRTimestampCapturePointType, CONST) eHRTimestampCapturePoint;
    CONST(Can_TxTimestampPCallBackType, CAN_CONST) CanTxTimestampNotification ; /**< @brief Pointer to TX Timestamp notification function. */
    CONST(Can_RxTimestampPCallBackType, CAN_CONST) CanRxTimestampNotification; /**< @brief Pointer to RX Timestamp notification function. */
#endif
    } Can_43_FLEXCAN_ConfigType;

/*==================================================================================================
*                                GLOBAL VARIABLE DECLARATIONS
==================================================================================================*/
#define CAN_43_FLEXCAN_START_SEC_VAR_INIT_UNSPECIFIED
/* @violates @ref Can_43_FLEXCAN_h_REF_1 MISRA 2012 Required Directive 4.10 */
#include "Can_43_FLEXCAN_MemMap.h"
/*
    Holds current status/run-time of CAN driver: CAN_UNINIT or CAN_READY (declared as global variable in "Can.c" file).
    (CAN103) After power-up/reset, the Can module shall be in the state CAN_UNINIT.
    Covers CAN103
*/
extern VAR(Can_43_FLEXCAN_StatusType, CAN_VAR) Can_43_FLEXCAN_eDriverStatus;

#define CAN_43_FLEXCAN_STOP_SEC_VAR_INIT_UNSPECIFIED
/* @violates @ref Can_43_FLEXCAN_h_REF_1 MISRA 2012 Required Directive 4.10 */
#include "Can_43_FLEXCAN_MemMap.h"

#define CAN_43_FLEXCAN_START_SEC_VAR_INIT_UNSPECIFIED
/* @violates @ref Can_43_FLEXCAN_h_REF_1 MISRA 2012 Required Directive 4.10 */
#include "Can_43_FLEXCAN_MemMap.h"


/* Pointer to the current Driver Configuration (passed to the driver during initialization). Initialized by Can_Init(). */
extern P2CONST(Can_43_FLEXCAN_ConfigType, CAN_VAR, CAN_APPL_CONST) Can_43_FLEXCAN_pCurrentConfig;
extern P2CONST(Can_43_FLEXCAN_ControlerDescriptorType, CAN_VAR, CAN_APPL_CONST) Can_43_FLEXCAN_pControlerDescriptors;

extern P2CONST(CanStatic_43_FLEXCAN_ConfigType, CAN_VAR, CAN_APPL_CONST) CanStatic_43_FLEXCAN_pCurrentConfig;
extern P2CONST(CanStatic_43_FLEXCAN_ControlerDescriptorType, CAN_VAR, CAN_APPL_CONST) CanStatic_43_FLEXCAN_pControlerDescriptors;
#define CAN_43_FLEXCAN_STOP_SEC_VAR_INIT_UNSPECIFIED

/* @violates @ref Can_43_FLEXCAN_h_REF_1 MISRA 2012 Required Directive 4.10 */
#include "Can_43_FLEXCAN_MemMap.h"

#define CAN_43_FLEXCAN_START_SEC_CONFIG_DATA_UNSPECIFIED
/* @violates @ref Can_43_FLEXCAN_h_REF_1 MISRA 2012 Required Directive 4.10 */
#include "Can_43_FLEXCAN_MemMap.h"

#if (CAN_43_FLEXCAN_PRECOMPILE_SUPPORT == STD_OFF)
    /* Export Driver configuration */
    CAN_43_FLEXCAN_CONF_PB
#endif /* (<MODULE>_PRECOMPILE_SUPPORT == STD_OFF) */


extern CONST(CanStatic_43_FLEXCAN_ConfigType, CAN_CONST) CanStatic_43_FLEXCAN_ConfigSet;

#define CAN_43_FLEXCAN_STOP_SEC_CONFIG_DATA_UNSPECIFIED

/* @violates @ref Can_43_FLEXCAN_h_REF_1 MISRA 2012 Required Directive 4.10 */
#include "Can_43_FLEXCAN_MemMap.h"


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

#define CAN_43_FLEXCAN_START_SEC_CODE
/* @violates @ref Can_43_FLEXCAN_h_REF_1 MISRA 2012 Required Directive 4.10 */
#include "Can_43_FLEXCAN_MemMap.h"

extern FUNC(void, CAN_CODE) Can_43_FLEXCAN_Init( P2CONST(Can_43_FLEXCAN_ConfigType, AUTOMATIC, CAN_APPL_CONST) Config);

extern FUNC(void, CAN_CODE) Can_43_FLEXCAN_DeInit(void);

extern FUNC(Std_ReturnType, CAN_CODE) Can_43_FLEXCAN_GetControllerMode( VAR(uint8, AUTOMATIC) Controller, P2VAR(Can_ControllerStateType, AUTOMATIC, CAN_APPL_DATA) ControllerModePtr);

extern FUNC(Std_ReturnType, CAN_CODE) Can_43_FLEXCAN_GetControllerErrorState( VAR(uint8, AUTOMATIC) ControllerId, P2VAR(Can_ErrorStateType, AUTOMATIC, CAN_APPL_DATA) ErrorStatePtr);

#if (CAN_43_FLEXCAN_VERSION_INFO_API == STD_ON)

extern FUNC(void, CAN_CODE) Can_43_FLEXCAN_GetVersionInfo( P2VAR(Std_VersionInfoType, AUTOMATIC, CAN_APPL_DATA) versioninfo);

#endif /* (CAN_43_FLEXCAN_VERSION_INFO_API == STD_ON) */
#if (CAN_43_FLEXCAN_SET_BAUDRATE_API == STD_ON)
extern FUNC(Std_ReturnType, CAN_CODE) Can_43_FLEXCAN_SetBaudrate( VAR(uint8, AUTOMATIC) Controller,
                                                       CONST(uint16, AUTOMATIC) BaudRateConfigID
                                                     );
#endif /* (CAN_43_FLEXCAN_SET_BAUDRATE_API == STD_ON) */

extern FUNC(Std_ReturnType, CAN_CODE) Can_43_FLEXCAN_SetControllerMode( VAR(uint8, AUTOMATIC) Controller,
                                                             VAR(Can_ControllerStateType, AUTOMATIC) Transition
                                                           );



extern FUNC(void, CAN_CODE) Can_43_FLEXCAN_DisableControllerInterrupts( VAR(uint8, AUTOMATIC) Controller);



extern FUNC(void, CAN_CODE) Can_43_FLEXCAN_EnableControllerInterrupts( VAR(uint8, AUTOMATIC) Controller);



extern FUNC(Std_ReturnType, CAN_CODE) Can_43_FLEXCAN_Write( VAR(Can_HwHandleType, AUTOMATIC) Hth,
                                                 P2CONST(Can_PduType, AUTOMATIC, CAN_APPL_CONST) PduInfo
                                               );
                                               
#ifdef CAN_43_FLEXCAN_ENABLE_WAKEUP_SUPPORT                                             
    #if (CAN_43_FLEXCAN_ENABLE_WAKEUP_SUPPORT == STD_ON)
        
    extern FUNC (Std_ReturnType, CAN_CODE) Can_43_FLEXCAN_CheckWakeup( VAR(uint8, AUTOMATIC) controller);

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

#if (CAN_43_FLEXCAN_PUBLIC_ICOM_SUPPORT == STD_ON)
extern FUNC(Std_ReturnType, CAN_CODE) Can_43_FLEXCAN_SetIcomConfiguration( VAR(uint8, AUTOMATIC) u8Controller, 
                                                                VAR(IcomConfigIdType, AUTOMATIC) u8ConfigurationId 
                                                              );
#endif


#if (CAN_43_FLEXCAN_TXPOLL_SUPPORTED == STD_ON)

extern FUNC(void, CAN_CODE) Can_43_FLEXCAN_MainFunction_Write( void );

#ifdef CAN_43_FLEXCAN_MAINFUNCTION_MULTIPLE_WRITE
#if (CAN_43_FLEXCAN_MAINFUNCTION_MULTIPLE_WRITE==STD_ON)

#ifdef CAN_43_FLEXCAN_MAINFUNCTION_PERIOD_WRITE_0
extern FUNC(void, CAN_CODE) Can_43_FLEXCAN_MainFunction_Write_0( void );
#endif

#ifdef CAN_43_FLEXCAN_MAINFUNCTION_PERIOD_WRITE_1
extern FUNC(void, CAN_CODE) Can_43_FLEXCAN_MainFunction_Write_1( void );
#endif

#ifdef CAN_43_FLEXCAN_MAINFUNCTION_PERIOD_WRITE_2
extern FUNC(void, CAN_CODE) Can_43_FLEXCAN_MainFunction_Write_2( void );
#endif

#ifdef CAN_43_FLEXCAN_MAINFUNCTION_PERIOD_WRITE_3
extern FUNC(void, CAN_CODE) Can_43_FLEXCAN_MainFunction_Write_3( void );
#endif

#ifdef CAN_43_FLEXCAN_MAINFUNCTION_PERIOD_WRITE_4
extern FUNC(void, CAN_CODE) Can_43_FLEXCAN_MainFunction_Write_4( void );
#endif

#ifdef CAN_43_FLEXCAN_MAINFUNCTION_PERIOD_WRITE_5
extern FUNC(void, CAN_CODE) Can_43_FLEXCAN_MainFunction_Write_5( void );
#endif

#ifdef CAN_43_FLEXCAN_MAINFUNCTION_PERIOD_WRITE_6
extern FUNC(void, CAN_CODE) Can_43_FLEXCAN_MainFunction_Write_6( void );
#endif

#ifdef CAN_43_FLEXCAN_MAINFUNCTION_PERIOD_WRITE_7
extern FUNC(void, CAN_CODE) Can_43_FLEXCAN_MainFunction_Write_7( void );
#endif

#ifdef CAN_43_FLEXCAN_MAINFUNCTION_PERIOD_WRITE_8
extern FUNC(void, CAN_CODE) Can_43_FLEXCAN_MainFunction_Write_8( void );
#endif

#ifdef CAN_43_FLEXCAN_MAINFUNCTION_PERIOD_WRITE_9
extern FUNC(void, CAN_CODE) Can_43_FLEXCAN_MainFunction_Write_9( void );
#endif

#ifdef CAN_43_FLEXCAN_MAINFUNCTION_PERIOD_WRITE_10
extern FUNC(void, CAN_CODE) Can_43_FLEXCAN_MainFunction_Write_10( void );
#endif


#endif /* (CAN_43_FLEXCAN_MAINFUNCTION_MULTIPLE_WRITE==STD_ON) */
#endif /* (ifdef CAN_43_FLEXCAN_MAINFUNCTION_MULTIPLE_WRITE) */

#else /* (CAN_43_FLEXCAN_TXPOLL_SUPPORTED == STD_OFF) */
/* @violates @ref Can_43_FLEXCAN_h_REF_3 MISRA 2012 Advisory Rule 4.9 */
/* @violates @ref Can_43_FLEXCAN_h_REF_2 MISRA 2012 Advisory Rule 2.5 */
#define Can_43_FLEXCAN_MainFunction_Write()

#endif /* (CAN_43_FLEXCAN_TXPOLL_SUPPORTED == STD_OFF) */

#if (CAN_43_FLEXCAN_RXPOLL_SUPPORTED == STD_ON)


extern FUNC(void, CAN_CODE) Can_43_FLEXCAN_MainFunction_Read( void);

#ifdef CAN_43_FLEXCAN_MAINFUNCTION_MULTIPLE_READ
#if (CAN_43_FLEXCAN_MAINFUNCTION_MULTIPLE_READ == STD_ON)
    
#ifdef CAN_43_FLEXCAN_MAINFUNCTION_PERIOD_READ_0  
extern FUNC(void, CAN_CODE) Can_43_FLEXCAN_MainFunction_Read_0( void); 
#endif

#ifdef CAN_43_FLEXCAN_MAINFUNCTION_PERIOD_READ_1  
extern FUNC(void, CAN_CODE) Can_43_FLEXCAN_MainFunction_Read_1( void); 
#endif

#ifdef CAN_43_FLEXCAN_MAINFUNCTION_PERIOD_READ_2  
extern FUNC(void, CAN_CODE) Can_43_FLEXCAN_MainFunction_Read_2( void); 
#endif

#ifdef CAN_43_FLEXCAN_MAINFUNCTION_PERIOD_READ_3  
extern FUNC(void, CAN_CODE) Can_43_FLEXCAN_MainFunction_Read_3( void); 
#endif

#ifdef CAN_43_FLEXCAN_MAINFUNCTION_PERIOD_READ_4  
extern FUNC(void, CAN_CODE) Can_43_FLEXCAN_MainFunction_Read_4( void); 
#endif

#ifdef CAN_43_FLEXCAN_MAINFUNCTION_PERIOD_READ_5  
extern FUNC(void, CAN_CODE) Can_43_FLEXCAN_MainFunction_Read_5( void); 
#endif

#ifdef CAN_43_FLEXCAN_MAINFUNCTION_PERIOD_READ_6  
extern FUNC(void, CAN_CODE) Can_43_FLEXCAN_MainFunction_Read_6( void); 
#endif

#ifdef CAN_43_FLEXCAN_MAINFUNCTION_PERIOD_READ_7  
extern FUNC(void, CAN_CODE) Can_43_FLEXCAN_MainFunction_Read_7( void); 
#endif

#ifdef CAN_43_FLEXCAN_MAINFUNCTION_PERIOD_READ_8  
extern FUNC(void, CAN_CODE) Can_43_FLEXCAN_MainFunction_Read_8( void); 
#endif

#ifdef CAN_43_FLEXCAN_MAINFUNCTION_PERIOD_READ_9  
extern FUNC(void, CAN_CODE) Can_43_FLEXCAN_MainFunction_Read_9( void); 
#endif

#ifdef CAN_43_FLEXCAN_MAINFUNCTION_PERIOD_READ_10  
extern FUNC(void, CAN_CODE) Can_43_FLEXCAN_MainFunction_Read_10( void); 
#endif

#endif /* (CAN_43_FLEXCAN_MAINFUNCTION_MULTIPLE_READ == STD_ON) */
#endif /* ifdef CAN_43_FLEXCAN_MAINFUNCTION_MULTIPLE_READ */

#else /* (CAN_43_FLEXCAN_RXPOLL_SUPPORTED == STD_OFF) */
/* @violates @ref Can_43_FLEXCAN_h_REF_2 MISRA 2012 Advisory Rule 2.5 */
/* @violates @ref Can_43_FLEXCAN_h_REF_3 MISRA 2012 Advisory Rule 4.9 */
#define Can_43_FLEXCAN_MainFunction_Read()

#endif /* (CAN_43_FLEXCAN_RXPOLL_SUPPORTED == STD_OFF) */



#if (CAN_43_FLEXCAN_BUSOFFPOLL_SUPPORTED == STD_ON)

extern FUNC(void, CAN_CODE) Can_43_FLEXCAN_MainFunction_BusOff( void);

#else /* (CAN_43_FLEXCAN_BUSOFFPOLL_SUPPORTED == STD_OFF) */

/* @violates @ref Can_43_FLEXCAN_h_REF_2 MISRA 2012 Advisory Rule 2.5 */
/* @violates @ref Can_43_FLEXCAN_h_REF_3 MISRA 2012 Advisory Rule 4.9 */
#define Can_43_FLEXCAN_MainFunction_BusOff()

#endif /* (CAN_43_FLEXCAN_BUSOFFPOLL_SUPPORTED == STD_OFF) */

#ifdef CAN_WAKEUPPOLL_SUPPORTED
    #if (CAN_WAKEUPPOLL_SUPPORTED  == STD_ON) 
        
    extern FUNC(void, CAN_CODE) Can_43_FLEXCAN_MainFunction_Wakeup( void); 

    #else /* (CAN_WAKEUPPOLL_SUPPORTED  == STD_ON) */

    #define Can_43_FLEXCAN_MainFunction_Wakeup()

    #endif /* (CAN_WAKEUPPOLL_SUPPORTED == STD_OFF) */
#endif 
#ifdef CAN_SUPPORT_MRAF_EVENT
  #if (CAN_SUPPORT_MRAF_EVENT == STD_ON)
    #if (CAN_MRAFPOLL_SUPPORTED == STD_ON)
extern FUNC(void, CAN_CODE) Can_43_FLEXCAN_MainFunction_CheckMRAF( void);
    #else /* (CAN_MRAFPOLL_SUPPORTED == STD_OFF) */
#define Can_43_FLEXCAN_MainFunction_CheckMRAF()
    #endif
  #endif /* (CAN_SUPPORT_MRAF_EVENT == STD_OFF) */
#endif /* defined(CAN_SUPPORT_MRAF_EVENT) */

extern FUNC(void, CAN_CODE) Can_43_FLEXCAN_MainFunction_Mode( void);


#if (CAN_43_FLEXCAN_API_ENABLE_ABORT_MB == STD_ON)


extern FUNC(void, CAN_CODE) Can_43_FLEXCAN_AbortMb( VAR(Can_HwHandleType, AUTOMATIC) Hth);

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

#if (CAN_43_FLEXCAN_DUAL_CLOCK_MODE == STD_ON)


extern FUNC(Std_ReturnType, CAN_CODE) Can_43_FLEXCAN_SetClockMode( VAR(uint8, AUTOMATIC) can_controller, VAR(Can_43_FLEXCAN_ClockModeType, AUTOMATIC) can_clk_mode);

#endif /* CAN_43_FLEXCAN_DUAL_CLOCK_MODE == STD_ON */


#define CAN_43_FLEXCAN_STOP_SEC_CODE
/* @violates @ref Can_43_FLEXCAN_h_REF_1 MISRA 2012 Required Directive 4.10 */
#include "Can_43_FLEXCAN_MemMap.h"


#ifdef __cplusplus
}
#endif

#endif /*CAN_H*/

/** @} */
