
/*==================================================================================================
*   Project              : RTD AUTOSAR 4.4
*   Platform             : CORTEXM
*   Peripheral           : FLEXCAN
*   Dependencies         : 
*
*   Autosar Version      : 4.4.0
*   Autosar Revision     : ASR_REL_4_4_REV_0000
*   Autosar Conf.Variant :
*   SW Version           : 1.0.0
*   Build Version        : S32K1_RTD_1_0_0_HF01_D2109_ASR_REL_4_4_REV_0000_20210907
*
*   (c) Copyright 2020-2021 NXP Semiconductors
*   All Rights Reserved.
*
*   NXP Confidential. This software is owned or controlled by NXP and may only be
*   used strictly in accordance with the applicable license terms. By expressly
*   accepting such terms or by downloading, installing, activating and/or otherwise
*   using the software, you are agreeing that you have read, and that you agree to
*   comply with and are bound by, such license terms. If you do not agree to be
*   bound by the applicable license terms, then you may not retain, install,
*   activate or otherwise use the software.
==================================================================================================*/

/**
*   @file FlexCAN_IP_PBcfg.c
*
*   @addtogroup FlexCAN
*   @{
*/

#ifdef __cplusplus
extern "C"{
#endif
/*==================================================================================================
*                                        INCLUDE FILES
* 1) system and project includes
* 2) needed interfaces from external units
* 3) internal and external interfaces from this unit
==================================================================================================*/
#include "FlexCAN_Ip_Types.h"
#if (FLEXCAN_IP_FEATURE_HAS_DMA_ENABLE == STD_ON)
    #include "Dma_Ip.h"
#endif
#include "USER_CONFIG.h"
/*==================================================================================================
*                              SOURCE FILE VERSION INFORMATION
==================================================================================================*/
#define FLEXCAN_IP_VENDOR_ID_VS_0_PBCFG_C 43
#define FLEXCAN_IP_AR_RELEASE_MAJOR_VERSION_VS_0_PBCFG_C 4
#define FLEXCAN_IP_AR_RELEASE_MINOR_VERSION_VS_0_PBCFG_C 4
#define FLEXCAN_IP_AR_RELEASE_REVISION_VERSION_VS_0_PBCFG_C 0
#define FLEXCAN_IP_SW_MAJOR_VERSION_VS_0_PBCFG_C 1
#define FLEXCAN_IP_SW_MINOR_VERSION_VS_0_PBCFG_C 0
#define FLEXCAN_IP_SW_PATCH_VERSION_VS_0_PBCFG_C 0
/*==================================================================================================
*                                     FILE VERSION CHECKS
==================================================================================================*/
/* Check if current file and FlexCAN_Ip_Types header file are of the same vendor */
#if (FLEXCAN_IP_VENDOR_ID_VS_0_PBCFG_C != FLEXCAN_IP_TYPES_VENDOR_ID_H)
    #error "FlexCAN_Ip_VS_0_PBcfg.c and FlexCAN_Ip_Types.h have different vendor ids"
#endif
/* Check if current file and FlexCAN_Ip_Types header file are of the same Autosar version */
#if ((FLEXCAN_IP_AR_RELEASE_MAJOR_VERSION_VS_0_PBCFG_C    != FLEXCAN_IP_TYPES_AR_RELEASE_MAJOR_VERSION_H) || \
     (FLEXCAN_IP_AR_RELEASE_MINOR_VERSION_VS_0_PBCFG_C    != FLEXCAN_IP_TYPES_AR_RELEASE_MINOR_VERSION_H) || \
     (FLEXCAN_IP_AR_RELEASE_REVISION_VERSION_VS_0_PBCFG_C != FLEXCAN_IP_TYPES_AR_RELEASE_REVISION_VERSION_H) \
    )
    #error "AutoSar Version Numbers of FlexCAN_Ip_VS_0_PBcfg.c and FlexCAN_Ip_Types.h are different"
#endif
/* Check if current file and FlexCAN_Ip_Types header file are of the same Software version */
#if ((FLEXCAN_IP_SW_MAJOR_VERSION_VS_0_PBCFG_C != FLEXCAN_IP_TYPES_SW_MAJOR_VERSION_H) || \
     (FLEXCAN_IP_SW_MINOR_VERSION_VS_0_PBCFG_C != FLEXCAN_IP_TYPES_SW_MINOR_VERSION_H) || \
     (FLEXCAN_IP_SW_PATCH_VERSION_VS_0_PBCFG_C != FLEXCAN_IP_TYPES_SW_PATCH_VERSION_H) \
    )
    #error "Software Version Numbers of FlexCAN_Ip_VS_0_PBcfg.c and FlexCAN_Ip_Types.h are different"
#endif

#ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
    /* Checks against current file and Dma_Ip.h */
    #if (FLEXCAN_IP_FEATURE_HAS_DMA_ENABLE == STD_ON)
        #if ((FLEXCAN_IP_AR_RELEASE_MAJOR_VERSION_VS_0_PBCFG_C    != DMA_IP_AR_RELEASE_MAJOR_VERSION_H) || \
            (FLEXCAN_IP_AR_RELEASE_MINOR_VERSION_VS_0_PBCFG_C     != DMA_IP_AR_RELEASE_MINOR_VERSION_H) \
            )
            #error "AUTOSAR Version Numbers of FlexCAN_Ip_VS_0_PBcfg.c and Dma_Ip.h are different"
        #endif
    #endif
#endif


/*==================================================================================================
*                                   GLOBAL FUNCTION PROTOTYPES
==================================================================================================*/
#define CAN_START_SEC_CODE
#include "Can_MemMap.h"

extern void Can_CommonIrqCallback(uint8 u8Instance, Flexcan_Ip_EventType event, uint32 u32buffIdx, const Flexcan_Ip_StateType *driverState);
extern void Can_ErrorIrqCallback(uint8 u8Instance, Flexcan_Ip_EventType event, uint32 u32ErrStatus, const Flexcan_Ip_StateType *driverState);

#define CAN_STOP_SEC_CODE
#include "Can_MemMap.h"

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

/*==================================================================================================
*                                      GLOBAL CONSTANTS
==================================================================================================*/
#define CAN_START_SEC_CONFIG_DATA_UNSPECIFIED
#include "Can_MemMap.h"

const Flexcan_Ip_ConfigType Flexcan_aCtrlConfigPB_VS_0[3U]=
{
    /* Can Hardware Channel FLEXCAN_0 */
    {
        /* Number Of Message Buffer used .max_num_mb */
        (uint8)18U,
        /*Can Hw filter count* .num_id_filters */
        (Flexcan_Ip_RxFifoIdFilterNumType)((8U >> 3U) - 1U),
        /* Legacy FIFO ENABLED .is_rx_fifo_needed */
        (boolean)TRUE,
        #if (FLEXCAN_IP_FEATURE_HAS_ENHANCED_RX_FIFO == STD_ON)
        /* The number of standard ID filter elements */
        0U,
        /* The number of extended ID filter elements */
        0U,
        /* The number of enhanced Rx FIFO watermark */
        -1U,
        /* The Enhanced Rx FIFO feature is enabled or not. */
        (boolean)FALSE,
        #endif
        /* Loopback enabled .flexcanMode */
        FLEXCAN_NORMAL_MODE,
        /* Controller Options .ctrlOptions */
        (uint32)( FLEXCAN_IP_BUSOFF_RECOVERY_U32 |FLEXCAN_IP_EACEN_U32),
        /* Can FD RamBlock specified .payload */
        {
            FLEXCAN_PAYLOAD_SIZE_8
        },
        /* Can FD enabled .fd_enable */
        (boolean)FALSE,
        #if (FLEXCAN_IP_FEATURE_HAS_PE_CLKSRC_SELECT == STD_ON)
        /* Can PE clock selected .is_pe_clock */
        (boolean)TRUE,
        #endif
        /* Cbt support .extCbtEnable */
        (boolean)FALSE,
        /*  BRS for FD .bitRateSwitch */
        (boolean)FALSE,
        /* Values for normal baudrate .bitrate */
        {
#if (defined CAN0_BAUDRATE)
#if (CAN0_BAUDRATE == CAN_BAUDRATE_500K)
            (uint8)4U,
            (uint8)4U,
            (uint8)4U,
            (uint16)5,
            (uint8)3U
#elif (CAN0_BAUDRATE == CAN_BAUDRATE_250K)
			(uint8)2U,
            (uint8)5U,
            (uint8)5U,
            (uint16)11,
            (uint8)3U
#else
#error "please define the baudrate of can0 (BAUDRATE_500K or BAUDRATE_250K)"
#endif
#else
#error "please define the CAN0_BAUDRATE"
#endif
        },
        /* Values for CBT baudrate .bitrate_cbt */
        {
#if (defined CAN0_BAUDRATE)
#if (CAN0_BAUDRATE == CAN_BAUDRATE_500K)
            (uint8)4U,
            (uint8)4U,
            (uint8)4U,
            (uint16)5U,
            (uint8)3U
#elif (CAN0_BAUDRATE == CAN_BAUDRATE_250K)
			(uint8)2U,
            (uint8)5U,
            (uint8)5U,
            (uint16)11U,
            (uint8)3U
#else
#error "please define the baudrate of can0 (BAUDRATE_500K or BAUDRATE_250K)"
#endif
#else
#error "please define the baudrate of can0"
#endif
        },
        /* Fifo Transfer Type .transfer_type */
        FLEXCAN_RXFIFO_USING_POLLING,
        #if (FLEXCAN_IP_FEATURE_HAS_DMA_ENABLE == STD_ON)
        /* DMA channel number used for transfers. */
        (uint8)0U,
        #endif
        /* Controller Callback .Callback */
        Can_CommonIrqCallback,
        /* Error Callback .ErrorCallback */
        Can_ErrorIrqCallback
    },
    /* Can Hardware Channel FLEXCAN_1 */
    {
        /* Number Of Message Buffer used .max_num_mb */
        (uint8)18U,
        /*Can Hw filter count* .num_id_filters */
        (Flexcan_Ip_RxFifoIdFilterNumType)((8U >> 3U) - 1U),
        /* Legacy FIFO ENABLED .is_rx_fifo_needed */
        (boolean)TRUE,
        #if (FLEXCAN_IP_FEATURE_HAS_ENHANCED_RX_FIFO == STD_ON)
        /* The number of standard ID filter elements */
        0U,
        /* The number of extended ID filter elements */
        0U,
        /* The number of enhanced Rx FIFO watermark */
        -1U,
        /* The Enhanced Rx FIFO feature is enabled or not. */
        (boolean)FALSE,
        #endif
        /* Loopback enabled .flexcanMode */
        FLEXCAN_NORMAL_MODE,
        /* Controller Options .ctrlOptions */
        (uint32)( FLEXCAN_IP_BUSOFF_RECOVERY_U32 |FLEXCAN_IP_EACEN_U32),
        /* Can FD RamBlock specified .payload */
        {
            FLEXCAN_PAYLOAD_SIZE_8
        },
        /* Can FD enabled .fd_enable */
        (boolean)FALSE,
        #if (FLEXCAN_IP_FEATURE_HAS_PE_CLKSRC_SELECT == STD_ON)
        /* Can PE clock selected .is_pe_clock */
        (boolean)TRUE,
        #endif
        /* Cbt support .extCbtEnable */
        (boolean)FALSE,
        /*  BRS for FD .bitRateSwitch */
        (boolean)FALSE,
        /* Values for normal baudrate .bitrate */
        {
#if (defined CAN1_BAUDRATE)
#if (CAN1_BAUDRATE == CAN_BAUDRATE_500K)
            (uint8)4U,
            (uint8)4U,
            (uint8)4U,
            (uint16)5,
            (uint8)3U
#elif (CAN1_BAUDRATE == CAN_BAUDRATE_250K)
			(uint8)2U,
            (uint8)5U,
            (uint8)5U,
            (uint16)11,
            (uint8)3U
#else
#error "please define the baudrate of can1 (BAUDRATE_500K or BAUDRATE_250K)"
#endif
#else
#error "please define the CAN0_BAUDRATE"
#endif
        },
        /* Values for CBT baudrate .bitrate_cbt */
        {
#if (defined CAN1_BAUDRATE)
#if (CAN1_BAUDRATE == CAN_BAUDRATE_500K)
            (uint8)4U,
            (uint8)4U,
            (uint8)4U,
            (uint16)5U,
            (uint8)3U
#elif (CAN1_BAUDRATE == CAN_BAUDRATE_250K)
			(uint8)2U,
            (uint8)5U,
            (uint8)5U,
            (uint16)11U,
            (uint8)3U
#else
#error "please define the baudrate of can1 (BAUDRATE_500K or BAUDRATE_250K)"
#endif
#else
#error "please define the baudrate of can1"
#endif
        },
        /* Fifo Transfer Type .transfer_type */
        FLEXCAN_RXFIFO_USING_POLLING,
        #if (FLEXCAN_IP_FEATURE_HAS_DMA_ENABLE == STD_ON)
        /* DMA channel number used for transfers. */
        (uint8)0U,
        #endif
        /* Controller Callback .Callback */
        NULL_PTR,
        /* Error Callback .ErrorCallback */
        Can_ErrorIrqCallback
    },
    /* Can Hardware Channel FLEXCAN_2 */
    {
        /* Number Of Message Buffer used .max_num_mb */
        (uint8)15U,
        /*Can Hw filter count* .num_id_filters */
        (Flexcan_Ip_RxFifoIdFilterNumType)((8U >> 3U) - 1U),
        /* Legacy FIFO ENABLED .is_rx_fifo_needed */
        (boolean)TRUE,
        #if (FLEXCAN_IP_FEATURE_HAS_ENHANCED_RX_FIFO == STD_ON)
        /* The number of standard ID filter elements */
        0U,
        /* The number of extended ID filter elements */
        0U,
        /* The number of enhanced Rx FIFO watermark */
        -1U,
        /* The Enhanced Rx FIFO feature is enabled or not. */
        (boolean)FALSE,
        #endif
        /* Loopback enabled .flexcanMode */
        FLEXCAN_NORMAL_MODE,
        /* Controller Options .ctrlOptions */
        (uint32)( FLEXCAN_IP_BUSOFF_RECOVERY_U32 |FLEXCAN_IP_EACEN_U32),
        /* Can FD RamBlock specified .payload */
        {
            FLEXCAN_PAYLOAD_SIZE_8
        },
        /* Can FD enabled .fd_enable */
        (boolean)FALSE,
        #if (FLEXCAN_IP_FEATURE_HAS_PE_CLKSRC_SELECT == STD_ON)
        /* Can PE clock selected .is_pe_clock */
        (boolean)TRUE,
        #endif
        /* Cbt support .extCbtEnable */
        (boolean)FALSE,
        /*  BRS for FD .bitRateSwitch */
        (boolean)FALSE,
        /* Values for normal baudrate .bitrate */
        {
#if (defined CAN2_BAUDRATE)
#if (CAN2_BAUDRATE == CAN_BAUDRATE_500K)
            (uint8)4U,
            (uint8)4U,
            (uint8)4U,
            (uint16)5,
            (uint8)3U
#elif (CAN2_BAUDRATE == CAN_BAUDRATE_250K)
			(uint8)2U,
            (uint8)5U,
            (uint8)5U,
            (uint16)11,
            (uint8)3U
#else
#error "please define the baudrate of can2 (BAUDRATE_500K or BAUDRATE_250K)"
#endif
#else
#error "please define the CAN2_BAUDRATE"
#endif
        },
        /* Values for CBT baudrate .bitrate_cbt */
        {
#if (defined CAN2_BAUDRATE)
#if (CAN2_BAUDRATE == CAN_BAUDRATE_500K)
            (uint8)4U,
            (uint8)4U,
            (uint8)4U,
            (uint16)5U,
            (uint8)3U
#elif (CAN2_BAUDRATE == CAN_BAUDRATE_250K)
			(uint8)2U,
            (uint8)5U,
            (uint8)5U,
            (uint16)11U,
            (uint8)3U
#else
#error "please define the baudrate of can2 (BAUDRATE_500K or BAUDRATE_250K)"
#endif
#else
#error "please define the baudrate of can2"
#endif
        },
        /* Fifo Transfer Type .transfer_type */
        FLEXCAN_RXFIFO_USING_POLLING,
        #if (FLEXCAN_IP_FEATURE_HAS_DMA_ENABLE == STD_ON)
        /* DMA channel number used for transfers. */
        (uint8)0U,
        #endif
        /* Controller Callback .Callback */
        NULL_PTR,
        /* Error Callback .ErrorCallback */
        Can_ErrorIrqCallback
    }
};


/* PN array configuration */
const Flexcan_Ip_PnConfigType Flexcan_aPnConfigPB_VS_0[1U]=
{
    {
        /* Wakeup timeout enable .bWakeUpTimeout */
        (boolean)FALSE,
        /* Wakeup on mactch enable .bWakeUpMatch */
        (boolean)TRUE,
        /* The number of matches needed before generating an wake up event .u16numMatches */
        (uint16)1U,
        /*  Defines a timeout value that generates an wake up event if wakeUpTimeout is true .u16matchTimeout */
        (uint16)0,
        /* Defines the filtering scheme used .eFilterComb */
        FLEXCAN_FILTER_ID_NTIMES,
        /* The configuration of the first ID filter .idFilter1 */
        {
            /* Specifies if the ID is standard or extended .bExtendedId */
            (boolean)TRUE,
            /* Specifies if the frame is standard or remote .bRemoteFrame */
            (boolean)FALSE,
            /* Specifies the ID value .u32Id */
            (uint32)0U
        },
        /* The configuration of the first ID filter .idFilter2 */
        {
            /* Specifies if the ID is standard or extended .bExtendedId */
            (boolean)TRUE,
            /* Specifies if the frame is standard or remote .bRemoteFrame */
            (boolean)TRUE,
            /* Specifies the ID value .u32Id */
            (boolean)0U,
        },
        /* Defines the ID filtering scheme .eIdFilterType */
        FLEXCAN_FILTER_MATCH_GEQ,
        /* Defines the payload filtering scheme. .ePayloadFilterType */
        FLEXCAN_FILTER_MATCH_EXACT,
        /* The configuration of the payload filter .payloadFilter */
        {
            (uint8)0U,
            (uint8)0U,
            {0U},
            {0U}
        }
    }
};

#define CAN_STOP_SEC_CONFIG_DATA_UNSPECIFIED
#include "Can_MemMap.h"


#ifdef __cplusplus
}
#endif

/** @} */
