/*!
* @file     Can_Cfg.c
*
* @version  1.0.0
*
* @brief    AUTOSAR CAN Configuration Source file
 *           
* @attention
*
* Project Name      : AUTOSAR MCAL
*
* Platform          : Arm
*
* Autosar Standard  : Classic Platform 4.4.0
*
* Compiled Version  : G32A10xx_MCAL_1_0_0_15-Nov-25
*
* Copyright (C) 2026 Geehy Semiconductor
*
* You may not use this file except in compliance with the
* GEEHY COPYRIGHT NOTICE (Geehy Semiconductor Software License Agreement).
*
* The program is only for reference, which is distributed in the hope
* that it will be usefull and instructional for customers to develop
* their software. Unless required by applicable law or agreed to in
* writing, the program is distributed on an "AS IS" BASIS, WITHOUT
* ANY WARRANTY OR CONDITIONS OF ANY KIND, either express or implied.
* See the Geehy Semiconductor Software License Agreement for the governing permissions
* and limitations under the License.
*/

#ifdef __cplusplus
extern "C"{
#endif

#include "Can.h"
/** @addtogroup G32A10xx_StdPeriphDriver
  @{
*/

/** @defgroup CAN_Driver
  * @brief CAN driver modules
  @{
*/

/** @defgroup CAN_Macros
  @{
*/
/******************************************************************************
                    VENDOR ID & AUTOSAR VERSION INFO
*******************************************************************************/
/** Vendor ID (vendorId) of the dedicated implementation of this module according to the AUTOSAR vendor list. */
#define CAN_CFG_VENDOR_ID                    0x00C1U
/** Module ID of this module, as defined in the BSW Module List. */
#define CAN_CFG_MODULE_ID                    0x0050U
/** Major version number of AUTOSAR release on which the appropriate implementation is based on. */
#define CAN_CFG_AR_RELEASE_MAJOR_VERSION     0x04U
/** Minor version number of AUTOSAR release on which the appropriate implementation is based on. */
#define CAN_CFG_AR_RELEASE_MINOR_VERSION     0x04U
/** Revision version number of AUTOSAR release on which the appropriate implementation is based on. */
#define CAN_CFG_AR_RELEASE_REVISION_VERSION  0x00U
/** Major version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define CAN_CFG_SW_MAJOR_VERSION             0x01U
/** Minor version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define CAN_CFG_SW_MINOR_VERSION             0x00U
/** Patch level version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define CAN_CFG_SW_PATCH_VERSION             0x00U
/**@} end of group CAN_Macros */
/*************************************************************************************************
                    VERSION INFOMATION VERIFICATION
**************************************************************************************************/
/* Make sure the vendor ids are the same between Can_Cfg.c and Can.h */
#if (CAN_CFG_VENDOR_ID != CAN_H_VENDOR_ID)
    #error "Vendor ids mismatch between Can_Cfg.c and Can.h"
#endif
/* Make sure the Module ids are the same between Can_Cfg.c and Can.h */
#if (CAN_CFG_MODULE_ID != CAN_H_MODULE_ID)
    #error "Module ids mismatch between Can_Cfg.c and Can.h"
#endif
/* Make sure the AUTOSAR major version number is the same between Can_Cfg.c and Can.h */
#if (CAN_CFG_AR_RELEASE_MAJOR_VERSION != CAN_H_AR_RELEASE_MAJOR_VERSION)
    #error "AUTOSAR Major Version Number mismatch between Can_Cfg.c and Can.h"
#endif
/* Make sure the AUTOSAR minor version number is the same between Can_Cfg.c and Can.h */
#if (CAN_CFG_AR_RELEASE_MINOR_VERSION != CAN_H_AR_RELEASE_MINOR_VERSION)
    #error "AUTOSAR minor Version Number mismatch between Can_Cfg.c and Can.h"
#endif
/* Make sure the AUTOSAR revision version number is the same between Can_Cfg.c and Can.h */
#if (CAN_CFG_AR_RELEASE_REVISION_VERSION != CAN_H_AR_RELEASE_REVISION_VERSION)
    #error "AUTOSAR revision Version Number mismatch between Can_Cfg.c and Can.h"
#endif
/* Make sure the software major version number is the same between Can_Cfg.c and Can.h */
#if (CAN_CFG_SW_MAJOR_VERSION != CAN_H_SW_MAJOR_VERSION)
    #error "Software Major Version Number mismatch between Can_Cfg.c and Can.h"
#endif
/* Make sure the software minor version number is the same between Can_Cfg.c and Can.h */
#if (CAN_CFG_SW_MINOR_VERSION != CAN_H_SW_MINOR_VERSION)
    #error "Software Minor Version Number mismatch between Can_Cfg.c and Can.h"
#endif
/* Make sure the software patch version number is the same between Can_Cfg.c and Can.h */
#if (CAN_CFG_SW_PATCH_VERSION != CAN_H_SW_PATCH_VERSION)
    #error "Software Patch Version Number mismatch between Can_Cfg.c and Can.h"
#endif

/*******************************************************************************
                            GLOBAL FUNCTIONS
*******************************************************************************/
/** @defgroup CAN_Fuctions
  @{
*/
#define CAN_START_SEC_CODE
#include "Can_MemMap.h"

#ifdef ENABLE_INTERMODULE_MCAL_CHECK
    /* Make sure the AUTOSAR major version number is the same between Can_Cfg.c and Can_MemMap.h */
    #if (CAN_CFG_AR_RELEASE_MAJOR_VERSION != CAN_MEMMAP_H_AR_RELEASE_MAJOR_VERSION)
        #error "AUTOSAR Major Version Number mismatch between Can_Cfg.c and Can_MemMap.h"
    #endif
    /* Make sure the AUTOSAR minor version number is the same between Can_Cfg.c and Can_MemMap.h */
    #if (CAN_CFG_AR_RELEASE_MINOR_VERSION != CAN_MEMMAP_H_AR_RELEASE_MINOR_VERSION)
        #error "AUTOSAR minor Version Number mismatch between Can_Cfg.c and Can_MemMap.h"
    #endif
#endif

extern void Can_TxCompleteNotification(void);

#define CAN_STOP_SEC_CODE
#include "Can_MemMap.h"
/**@} end of group CAN_Fuctions */
/*************************************************************************
                          LOCAL VARIABLE
**************************************************************************/
/** @defgroup CAN_Variable
  @{
*/
#define CAN_START_SEC_CONFIG_DATA_UNSPECIFIED
#include "Can_MemMap.h"

/** Description of Can Test parameters */
static CONST(Can_TestConfigType, CAN_CONST) g_testConfig = 
{
    /* Loopback mode enable status */
    FALSE,
    /* Tx pin control status */
    CAN_TEST_TX_MODE_CORE_CTRL
};

/** Description of Can Timestamp parameters */
static CONST(Can_TimestampConfigType, CAN_CONST) g_timestampConfig = 
{
    /* Timestamp counter operation mode */
    CAN_TIMESTAMP_OPER_DISABLED,
    /* Timestamp counter prescaler */
    CAN_TIMESTAMP_PSC_DIV1
};

/** Description of Can Timeout Counter parameters */
static CONST(Can_TimeoutCnterConfigType, CAN_CONST) g_timeoutCnterConfig = 
{
    /* Timeout counter enable status */
    FALSE,
    /* Timeout counter operation mode */
    CAN_TIMEOUT_CNTER_OPER_CONTINUOUS,
    /* Timeout Period */
    0U
};

/**  Description of individual Can controllers on chip */
static CONST(Can_ControllerStaticConfigType, CAN_CONST) g_controllersStaticConfig[] =
{
    /* CanController_0 Descriptor */
    {
        /* Controller offset: CAN_HW_INSTANCE0 = 0 */
        CAN_HW_INSTANCE0,
        /* Can controller test mode configuration */
        &g_testConfig,
        /* Can controller timestamp configuration */
        &g_timestampConfig,
        /* Can controller timeout counter configuration */
        &g_timeoutCnterConfig,
        /* CCCR:TXP/EFBI/PXHD/WMM/TEST/DAR/MON/ASM */
        (uint32)0x00000000U,
        /* RWD Register:WDC */
        (uint32)0x00000000U
    #if (STD_ON == CAN_PUBLIC_ICOM_ENABLE)
        ,
        /* If pretended networking is supported */
        FALSE
    #endif
    }
};

/** Message RAM offsets for each section per controller */
static CONST(uint32, CAN_CONST) g_canControllerMsgRAMMap[CAN_RAM_SECTIONS_CNT_PER_CONTROLLER] = 
{
    /* Controller 0 Message RAM offsets */
    (uint32)CAN_SRAM_BASEADDR,             /* Standard Id Filters Address */
    (uint32)(CAN_SRAM_BASEADDR + 0x80U),   /* Extended Id Filters Address */
    (uint32)(CAN_SRAM_BASEADDR + 0x100U),  /* Rx FIFO 0 Address */
    (uint32)(CAN_SRAM_BASEADDR + 0x280U),  /* Rx FIFO 1 Address */
    (uint32)(CAN_SRAM_BASEADDR + 0x400U),  /* Rx Dedicated buffer Address */
    (uint32)(CAN_SRAM_BASEADDR + 0x580U),  /* Tx Dedicated buffer Address */
    (uint32)(CAN_SRAM_BASEADDR + 0x700U)   /* Tx Event FIFO Address */
};

/** Configuration of Message RAM */
static CONST(Can_MessageRamConfigType, CAN_CONST) g_canMessageRamConfig =
{
    /* Message Buffer Configs */
    g_canControllerMsgRAMMap,
    /* Number of the TX Dedicated buffer configured */
    CAN_TX_DEDICATED_BUF_CONFIG_NUMBER,

    /* Size of the TX FIFO Queue configured */
    CAN_TX_FIFO_QUEUE_CONFIG_SIZE,

    /* Size of the TX Event FIFO configured */
    CAN_TX_EVT_FIFO_CONFIG_SIZE

#if (STD_ON == CAN_RXFIFO_ENABLE)
    /* Size of the RX FIFO 0 configured */
    ,
    CAN_RX_FIFO0_CONFIG_SIZE,
    /* Size of the RX FIFO 1 configured */
    CAN_RX_FIFO1_CONFIG_SIZE,
#endif
};

/** Collection of standard id filters */
static CONST(Can_FilterEleType, CAN_CONST) g_standardFilterConfig[] = 
{
    /* Filter 0 */
    {
        /* Filter index */
        (uint8)0x00U,
        /* Filter Element Configuration */
        CAN_FILTER_ELE_COFIG_STORE_RX_BUF,
        /* Filter Type */
        CAN_FILTER_ACTION_DUAL_ID,
        /* Filter Id 1 */
        (Can_IdType)0x100U,
        /* Filter Id 2 */
        (Can_IdType)0x200U,
        /* Rx Buffer Index to store the matched frame:only when the Filter Element 
           Configuration is CAN_FILTER_ELE_COFIG_STORE_RX_BUF, it is valid */
        CAN_RX_BUF_ID_0
    #if (STD_ON == CAN_PUBLIC_ICOM_ENABLE)
        ,
        /* Icom indication */
        FALSE
    #endif
    },
    /* Filter 1 */
    {
        /* Filter index */
        (uint8)0x01U,
        /* Filter Element Configuration */
        CAN_FILTER_ELE_COFIG_STORE_RX_FIFO0,
        /* Filter Type */
        CAN_FILTER_ACTION_DUAL_ID,
        /* Filter Id 1 */
        (Can_IdType)0x300U,
        /* Filter Id 2 */
        (Can_IdType)0x400U,
        /* Rx Buffer Index to store the matched frame */
        CAN_RX_BUF_ID_NONE
    #if (STD_ON == CAN_PUBLIC_ICOM_ENABLE)
        ,
        /* Icom indication */
        FALSE
    #endif
    },
    /* Filter 2 */
    {
        /* Filter index */
        (uint8)0x02U,
        /* Filter Element Configuration */
        CAN_FILTER_ELE_COFIG_STORE_RX_FIFO0,
        /* Filter Type */
        CAN_FILTER_ACTION_CLASSIC,
        /* Filter Id 1 */
        (Can_IdType)0x028U,
        /* Filter Id 2 */
        (Can_IdType)0x03CU,
        /* Rx Buffer Index to store the matched frame */
        CAN_RX_BUF_ID_NONE
    #if (STD_ON == CAN_PUBLIC_ICOM_ENABLE)
        ,
        /* Icom indication */
        FALSE
    #endif
    }
    
};

/** Collection of extended id filters */
static CONST(Can_FilterEleType, CAN_CONST) g_extendedFilterConfig[] = 
{
    /* Filter 0 */
    {
        /* Filter index */
        (uint8)0x00U,
        /* Filter Element Configuration */
        CAN_FILTER_ELE_COFIG_STORE_RX_BUF,
        /* Filter Type */
        CAN_FILTER_ACTION_DUAL_ID,
        /* Filter Id 1 */
        (Can_IdType)0x500U,
        /* Filter Id 2 */
        (Can_IdType)0x600U,
        /* Rx Buffer Index to store the matched frame */
        CAN_RX_BUF_ID_1
    #if (STD_ON == CAN_PUBLIC_ICOM_ENABLE)
        ,
        /* Icom indication */
        FALSE
    #endif
    },
    /* Filter 1 */
    {
        /* Filter index */
        (uint8)0x01U,
        /* Filter Element Configuration */
        CAN_FILTER_ELE_COFIG_STORE_RX_FIFO1,
        /* Filter Type */
        CAN_FILTER_ACTION_DUAL_ID,
        /* Filter Id 1 */
        (Can_IdType)0x700U,
        /* Filter Id 2 */
        (Can_IdType)0x800U,
        /* Rx Buffer Index to store the matched frame */
        CAN_RX_BUF_ID_NONE
    #if (STD_ON == CAN_PUBLIC_ICOM_ENABLE)
        ,
        /* Icom indication */
        FALSE
    #endif
    }
};

/** Configuration of the filter */
static CONST(Can_FilterConfigType, CAN_CONST) g_filterConfig =
{
    /* Message Id length (Standard/Extended/Both) */
    CAN_MSG_ID_LEN_BOTH,
    /* List Size Standard */
    CAN_FILTER_STANDARD_LIST_SIZE,
    /* List Size Extended */
    CAN_FILTER_EXTENDED_LIST_SIZE,
    /* Reject Remote Frames with Standard Id */
    TRUE,
    /* Reject Remote Frames with Extended Id */
    TRUE,
    /* Action to be taken on the frames with ids, which are not matching with the filter */
    CAN_NON_MATCH_FRAME_REJECT,
    /* Action to be taken on the frames with ids, which are not matching with the filter */
    CAN_NON_MATCH_FRAME_REJECT,
    /* Collection of standard id filters */
    g_standardFilterConfig,
    /* Collection of extended id filters */
    g_extendedFilterConfig
};

/** Configuration of Tx buffers */
static CONST(Can_TxConfigType, CAN_CONST) g_txConfig =
{
    /* Tx Dedicated buffer/FIFO/Queue Mode */
    CAN_TX_MODE_SHARE_FIFO,
    /* Tx Buffer Data Field Size */
    CAN_DATA_FIELD_SIZE_64,
    /* Tx FIFO/Queue Watermark Level */
    CAN_FIFO_WATERMARK_DISABLED,
    /* Tx Buffer interrupts Enable:each bit for one tx buffer */
    (uint32)0x000000FU,
    /* Tx Buffer Cancel interrupts Enable:each bit for one tx buffer */
    (uint32)0x0000001U
};

/** Configuration of Rx buffers */
static CONST(Can_RxConfigType, CAN_CONST) g_rxConfig =
{
    /* Rx Buffers or FIFO 0 or combination Mode of reception */
    CAN_RX_MODE_SHARE_ALL,
    /* Rx Buffer Data Field Size */
    CAN_DATA_FIELD_SIZE_8
#if (STD_ON == CAN_RXFIFO_ENABLE)
    ,
    /* Rx FIFO 0 Data Field Size */
    CAN_DATA_FIELD_SIZE_64,
    /* Rx FIFO 1 Data Field Size */
    CAN_DATA_FIELD_SIZE_64,
    /* Rx FIFO 0 operating mode */
    CAN_RX_FIFO_MODE_BLOCKING,
    /* Rx FIFO 1 operating mode */
    CAN_RX_FIFO_MODE_OVERWRITE,
    /* Rx FIFO 0 watermark level */
    CAN_FIFO_WATERMARK_DISABLED,
    /* Rx FIFO 1 watermark level */
    CAN_FIFO_WATERMARK_DISABLED
#endif
};

/** Configuration of Tx message buffers，if some MBS have the same Hth
 * ,these MBS should be continuous in the array  */
static CONST(Can_TxMbConfigType, CAN_CONST) g_txMbConfig[] = 
{
    /* CAN0_TX_1 */
    {
        /* Hardware object Id(Hth) */
        CAN0_TX_1,
        /* Tx Buffer index number:when the buffer type is dedicated buffer, it is valid */
        Can_TX_BUF_ID_0,
        /* configuration id of Controller to which this hardware object is assigned */
        CanConf_CanController_CAN0,
    #if(STD_ON == CAN_ENABLE_FD_MODE)
        /* The CAN FD padding Value */
        (uint8)0U,
    #endif
        /* The buffer types used by the Hardware handler */
        CAN_TX_MODE_DEDICATE_BUF,
    #if (STD_ON == CAN_TRIGGER_TRANSMIT_ENABLE)
        /* Enable trigger transmit feature */
        (boolean)FALSE,
    #endif
        /* Main function read write period reference */
        0U
    },
    /* CAN0_TX_1 */
    {
        /* Hardware object Id(Hth) */
        CAN0_TX_1,
        /* Tx Buffer index number:when the buffer type is dedicated buffer, it is valid */
        Can_TX_BUF_ID_1,
        /* configuration id of Controller to which this hardware object is assigned */
        CanConf_CanController_CAN0,
    #if(STD_ON == CAN_ENABLE_FD_MODE)
        /* The CAN FD padding Value */
        (uint8)0U,
    #endif
        /* The buffer types used by the Hardware handler */
        CAN_TX_MODE_DEDICATE_BUF,
    #if (STD_ON == CAN_TRIGGER_TRANSMIT_ENABLE)
        /* Enable trigger transmit feature */
        (boolean)FALSE,
    #endif
        /* Main function read write period reference */
        0U
    },
    /* CAN0_TX_2 */
    {
        /* Hardware object Id(Hth) */
        CAN0_TX_2,
        /* Tx Buffer index number:when the buffer type is dedicated buffer, it is valid */
        Can_TX_FIFO_QUEUE_ID_32,
        /* configuration id of Controller to which this hardware object is assigned */
        CanConf_CanController_CAN0,
    #if(STD_ON == CAN_ENABLE_FD_MODE)
        /* The CAN FD padding Value */
        (uint8)0U,
    #endif
        /* The buffer types used by the Hardware handler */
        CAN_TX_MODE_SHARE_FIFO,
    #if (STD_ON == CAN_TRIGGER_TRANSMIT_ENABLE)
        /* Enable trigger transmit feature */
        (boolean)FALSE,
    #endif
        /* Main function read write period reference */
        1U
    },
    /* CAN0_TX_3 */
    {
        /* Hardware object Id(Hth) */
        CAN0_TX_3,
        /* Tx Buffer index number:when the buffer type is dedicated buffer, it is valid */
        Can_TX_BUF_ID_2,
        /* configuration id of Controller to which this hardware object is assigned */
        CanConf_CanController_CAN0,
    #if(STD_ON == CAN_ENABLE_FD_MODE)
        /* The CAN FD padding Value */
        (uint8)0U,
    #endif
        /* The buffer types used by the Hardware handler */
        CAN_TX_MODE_DEDICATE_BUF,
    #if (STD_ON == CAN_TRIGGER_TRANSMIT_ENABLE)
        /* Enable trigger transmit feature */
        (boolean)FALSE,
    #endif
        /* Main function read write period reference */
        2U
    }
    
};

/** Configuration of Tx Message Buffers container */
static CONST(Can_TxMbConfigsContainerType, CAN_CONST) g_txMbConfigContainer = 
{
    /* Number of elements in the Tx Message Buffers array */
    (uint8)0x04,
    /* Pointer to the Tx Message Buffers array */
    g_txMbConfig
};

/** Configuration of Rx message buffers */
static CONST(Can_RxMbConfigType, CAN_CONST) g_rxMbConfig[] = 
{
    /* CAN0_RX_STANDARD_1 */
    {
        /* Hardware object Id(Hrh) */
        CAN0_RX_STANDARD_1,
        /* Rx Buffer index number */
        CAN_RX_BUF_ID_0,
        /* configuration id of Controller to which this hardware object is assigned */
        CanConf_CanController_CAN0,
        /* Main function read write period reference */
        0U
    },
    /* CAN0_RX_EXTENDED_1 */
    {
        /* Hardware object Id(Hrh) */
        CAN0_RX_EXTENDED_1,
        /* Rx Buffer index number */
        CAN_RX_BUF_ID_1,
        /* configuration id of Controller to which this hardware object is assigned */
        CanConf_CanController_CAN0,
        /* Main function read write period reference */
        1U
    },
    /* CAN0_RX_STANDARD_2 */
    {
        /* Hardware object Id(Hrh) */
        CAN0_RX_STANDARD_2,
        /* Rx Buffer index number */
        CAN_RX_FIFO0_BUF_INDEX,
        /* configuration id of Controller to which this hardware object is assigned */
        CanConf_CanController_CAN0,
        /* Main function read write period reference */
        2U
    },
    /* CAN0_RX_EXTENDED_2 */
    {
        /* Hardware object Id(Hrh) */
        CAN0_RX_EXTENDED_2,
        /* Rx Buffer index number */
        CAN_RX_FIFO1_BUF_INDEX,
        /* configuration id of Controller to which this hardware object is assigned */
        CanConf_CanController_CAN0,
        /* Main function read write period reference */
        3U
    }
};

/** Configuration of Rx Message Buffers container */
static CONST(Can_RxMbConfigsContainerType, CAN_CONST) g_rxMbConfigContainer = 
{
    /* Number of elements in the Rx Message Buffers array */
    (uint8)0x04,
    /* Pointer to the Rx Message Buffers array */
    g_rxMbConfig
};

/** Configuration of baudrate information */
static CONST(Can_BaudrateConfigType, CAN_CONST) g_baudrateConfig[] = 
{
    /* Baudrate configuration 0 */
    {
        /* Normal bit rate */
        {
            /* Baudrate value configured in Kbps:500K,80% */
            (uint16)500U,
            /* Synchronization Jump Width */
            (uint16)15U,
            /* Baud Rate Prescaler:DIV1 */
            (uint16)0U,
            /* Time Segment 1 */
            (uint8)62U,
            /* Time Segment 2 */
            (uint8)15U
        }
    #if (STD_ON == CAN_ENABLE_FD_MODE)
        ,
        /* Data bit rate */
        {
            /* Baudrate value configured in Kbps:2000K,80% */
            (uint16)2000U,
            /* Synchronization Jump Width */
            (uint16)3U,
            /* Baud Rate Prescaler:DIV1 */
            (uint16)0U,
            /* Time Segment 1 */
            (uint8)14U,
            /* Time Segment 2 */
            (uint8)3U,
            /* Transceiver delay compensation enable */
            TRUE,
            /* Transceiver delay compensation offset */
            0x10U,
            /* Transceiver delay compensation filter window */
            0U,
            /* BRS enable/disable */
            TRUE
        }
    #endif
    #if (STD_ON == CAN_SET_BAUDRATE_API)
        ,
        /* Configuration ID */
        CAN_BAUDRATE_CONFIG_ID_0
    #endif
    #if ((STD_ON == CAN_CONTROLLER_ENABLE_ISO_CANFD) || (STD_ON == CAN_ENABLE_FD_MODE))
        ,
        /* CAN FD related configuration options:NISO and FDOE bit region in CCCR register */
        (uint32)((0 << CAN_CCCR_NISO_SHIFT) | (1 << CAN_CCCR_FDOE_SHIFT))
    #endif
    },
    /* Baudrate configuration 1 */
    {
        /* Normal bit rate */
        {
            /* Baudrate value configured in Kbps:1000K,80% */
            (uint16)1000U,
            /* Synchronization Jump Width */
            (uint16)7U,
            /* Baud Rate Prescaler:DIV1 */
            (uint16)0U,
            /* Time Segment 1 */
            (uint8)30U,
            /* Time Segment 2 */
            (uint8)7U
        }
    #if (STD_ON == CAN_ENABLE_FD_MODE)
        ,
        /* Data bit rate */
        {
            /* Baudrate value configured in Kbps:4000K,80% */
            (uint16)4000U,
            /* Synchronization Jump Width */
            (uint16)1U,
            /* Baud Rate Prescaler:DIV1 */
            (uint16)0U,
            /* Time Segment 1 */
            (uint8)6U,
            /* Time Segment 2 */
            (uint8)1U,
            /* Transceiver delay compensation enable */
            TRUE,
            /* Transceiver delay compensation offset */
            0x08U,
            /* Transceiver delay compensation filter window */
            0U,
            /* BRS enable/disable */
            TRUE
        }
    #endif
    #if (STD_ON == CAN_SET_BAUDRATE_API)
        ,
        /* Configuration ID */
        CAN_BAUDRATE_CONFIG_ID_1
    #endif
    #if ((STD_ON == CAN_CONTROLLER_ENABLE_ISO_CANFD) || (STD_ON == CAN_ENABLE_FD_MODE))
        ,
        /* CAN FD related configuration options:NISO and FDOE bit region in CCCR register */
        (uint32)((0 << CAN_CCCR_NISO_SHIFT) | (1 << CAN_CCCR_FDOE_SHIFT))
    #endif
    }
};

static CONST(Can_NotificationConfigType, CAN_CONST) g_notificationConfig = 
{
#if (STD_ON == CAN_RXFIFO_MSG_LOST_NOTIFICATION_ENABLE)
    /* Pointer to RxFifo0 Message Lost notification function.*/
    NULL_PTR,
    /* Pointer to RxFifo1 Message Lost notification function.*/
    NULL_PTR,
#endif

#if (STD_ON == CAN_TX_EVT_FIFO_LOST_ELE_NOTIFICATION_ENABLE)
    /* Pointer to Tx Event FIFO notification function.*/
    NULL_PTR,
#endif

#if (STD_ON == CAN_HIGH_PRIORITY_MSG_NOTIFICATION_ENABLE)
    /* Pointer to High Priority Message notification function.*/
    NULL_PTR,
#endif

#if (STD_ON == CAN_TRANS_COMPLETE_NOTIFICATION_ENABLE)
    /* Pointer to Transmission Complete notification function.*/
    Can_TxCompleteNotification,
#endif

#if (STD_ON == CAN_CANCEL_FINISHED_NOTIFICATION_ENABLE)
    /* Pointer to Cancel Finished notification function.*/
    NULL_PTR,
#endif

#if (STD_ON == CNA_TX_FIFO_EMPTY_NOTIFICATION_ENABLE)
    /* Pointer to Tx FIFO Empty notification function.*/
    NULL_PTR,
#endif

#if (STD_ON == CAN_TIMESTAMP_OVERFLOW_NOTIFICATION_ENABLE)
    /* Pointer to Timestamp Overflow notification function.*/
    NULL_PTR,
#endif

#if (STD_ON == CAN_RAM_ACC_FAILED_NOTIFICATION_ENABLE)
    /* Pointer to RAM Access Failure notification function.*/
    NULL_PTR,
#endif

#if (STD_ON == CAN_TIME_OVERFLOW_NOTIFICATION_ENABLE)
    /* Pointer to Time Overflow notification function.*/
    NULL_PTR,
#endif

#if (STD_ON == CAN_ERROR_LOG_OVERFLOW_NOTIFICATION_ENABLE)
    /* Pointer to Error Log Overflow notification function.*/
    NULL_PTR,
#endif

#if (STD_ON == CAN_ERROR_PASSIVE_NOTIFICATION_ENABLE)
    /* Pointer to Error Passive notification function.*/
    NULL_PTR,
#endif

#if (STD_ON == CAN_ERROR_WARNING_NOTIFICATION_ENABLE)
    /* Pointer to Error Warning notification function.*/
    NULL_PTR,
#endif

#if (STD_ON == CAN_WDG_NOTIFICATION_ENABLE)
    /* Pointer to Watchdog notification function.*/
    NULL_PTR,
#endif

#if (STD_ON == CAN_PLROTOCOL_ERROR_ARB_NOTIFICATION_ENABLE)
    /* Pointer to Protocol Error Arbitration notification function.*/
    NULL_PTR,
#endif

#if (STD_ON == CAN_PLROTOCOL_ERROR_DATA_NOTIFICATION_ENABLE)
    /* Pointer to Protocol Error Data notification function.*/
    NULL_PTR,
#endif

#if (STD_ON == CAN_ACC_RESERVED_ADDR_NOTIFICATION_ENABLE)
    /* Pointer to Access to Reserved Address notification function.*/
    NULL_PTR,
#endif

#if (STD_ON == CAN_WAKEUP_NOTIFICATION_ENABLE)
    /* Pointer to Wakeup notification function.*/
    NULL_PTR,
#endif

#if (STD_ON == CAN_ECC_ERROR_NOTIFICATION_ENABLE)

#if (STD_ON == CAN_ECC_ERROR_CORRECT_NOTIFICATION_ENABLE)
    /* Pointer to ECC Error Correct notification function.*/
    NULL_PTR,
#endif

#if (STD_ON == CAN_ECC_ERROR_UNCORRECT_NOTIFICATION_ENABLE)
    /* Pointer to ECC Error Uncorrect notification function.*/
    NULL_PTR,
#endif
#endif
};

/** Configuration of controllers information */
static CONST(Can_ControllerInfoType, CAN_CONST) g_controllerInfoConfig = 
{
    /* Max baudrate number */
    (uint8)0x02,
    /* Default baudrate index */
    (uint8)0x00,
    /* Pointer to baudrate configurations */
    g_baudrateConfig,
    /* Pointer to notification configurations */
    &g_notificationConfig
};

/** Configuration of interrupts */
static CONST(Can_InterruptConfigType, CAN_CONST) g_interruptConfig = 
{
    /* Interrupt enable/Disable(one bit for each interrupt) */
    (uint32)(CAN_IE_DRXE_MASK | CAN_IE_RF1NE_MASK | CAN_IE_RF0NE_MASK | CAN_IE_TCE_MASK | CAN_IE_TEFNE_MASK | CAN_IE_BOE_MASK),
    /* Interrupt line for each interrupts(one bit for each interrupt:0:line0, 1:line1) */
    (uint32)(CAN_IE_DRXE_MASK),
    /* Interrupt line enable/Disable(only bit0 and bit1 are used) */
    (uint32)(CAN_ILE_EINT0_MASK | CAN_ILE_EINT1_MASK)
};

/** Configuration of Error Reported Mechanism(ERM) */
static CONST(Can_ErmConfigType, CAN_CONST) g_ermConfig = 
{
    /* Erm control register value */
    (uint32)(CAN_ERM_CTRL_ECC_EN_MASK | CAN_ERM_CTRL_BEC_INT_EN_MASK | CAN_ERM_CTRL_BEU_INT_EN_MASK | 
             CAN_ERM_CTRL_WAKE_INT_EN_MASK | CAN_ERM_CTRL_WAKE_EVENT_EN_MASK)
};

/*************************************************************************
                          GLOBAL VARIABLE
**************************************************************************/

/** Top level structure containing all Can driver configurations */
CONST(Can_ConfigType, CAN_CONST) g_canConfig =
{
    /* Message RAM configuration(current only support one controller) */
    &g_canMessageRamConfig,
    /* Filter configuration */
    &g_filterConfig,
    /* Tx Buffers configuration */
    &g_txConfig,
    /* Rx Buffers/Fifo configuration */
    &g_rxConfig,
    /* Tx Message Buffer configuration container */
    &g_txMbConfigContainer,
    /* Rx Message Buffer configuration container */
    &g_rxMbConfigContainer,
    /* Controllers information configuration */
    &g_controllerInfoConfig,
    /* Interrupts configuration */
    &g_interruptConfig
#if (STD_ON == CAN_ENABLE_ERM)
    ,
    /* Error Reported Mechanism(ERM) configuration */
    &g_ermConfig
#endif
};

/** Top level structure containing all Can driver configurations */
CONST(Can_StaticConfigType, CAN_CONST) g_canStaticConfig =
{
    (uint8) 1, /* Number of CAN controllers */
    g_controllersStaticConfig, /* description of CAN controller */
#if (STD_ON == CAN_PUBLIC_ICOM_ENABLE)
    NULL_PTR, /* Pointer to Icom configuration */
#endif
};

#define CAN_STOP_SEC_CONFIG_DATA_UNSPECIFIED
#include "Can_MemMap.h"

/**@} end of group CAN_Variable */
#ifdef __cplusplus
}
#endif
/**@} end of group CAN_Driver */
/**@} end of group G32A10xx_StdPeriphDriver */

