/*!
* @file     Can_Cfg.h
*
* @version  1.0.0
*
* @brief    AUTOSAR CAN Configuration header file
*
*/

/******************************************************************************
* Project Name      : AUTOSAR MCAL
* Platform          : Arm
* Autosar Standard  : Classic Platform 4.4.0
* Revision Number   :
* Compiled Version  : G32A10xx_MCAL_1_0_0_01-Otc-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 useful 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.
*
*******************************************************************************/

#ifndef CAN_CFG_H
#define CAN_CFG_H

#ifdef __cplusplus
extern "C"{
#endif

#include "Std_Types.h"

/******************************************************************************
                    VENDOR ID & AUTOSAR VERSION INFO
*******************************************************************************/
/* Vendor ID (vendorId) of the dedicated implementation of this module according to the AUTOSAR vendor list. */
#define CAN_CFG_H_VENDOR_ID                         0x00C1U
/* Module ID of this module, as defined in the BSW Module List [1]. */
#define CAN_CFG_H_MODULE_ID                         0x0050U
/* Major version number of AUTOSAR release on which the appropriate implementation is based on. */
#define CAN_CFG_H_AR_RELEASE_MAJOR_VERSION          0x04U
/* Minor version number of AUTOSAR release on which the appropriate implementation is based on. */
#define CAN_CFG_H_AR_RELEASE_MINOR_VERSION          0x04U
/* Revision version number of AUTOSAR release on which the appropriate implementation is based on. */
#define CAN_CFG_H_AR_RELEASE_REVISION_VERSION       0x00U
/* Major version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define CAN_CFG_H_SW_MAJOR_VERSION                  0x01U
/* Minor version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define CAN_CFG_H_SW_MINOR_VERSION                  0x00U
/* Patch level version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define CAN_CFG_H_SW_PATCH_VERSION                  0x00U

/******************************************************************************
                                VERSION CHECK
*******************************************************************************/
#ifdef ENABLE_INTERMODULE_MCAL_CHECK
    /* Make sure the AUTOSAR major version number is the same between Can_Cfg.h and Std_Types.h */
    #if (CAN_CFG_H_AR_RELEASE_MAJOR_VERSION != STD_TYPES_H_AR_RELEASE_MAJOR_VERSION)
        #error "AUTOSAR Major Version Number mismatch between Can_Cfg.h and Std_Types.h"
    #endif
    /* Make sure the AUTOSAR minor version number is the same between Can_Cfg.h and Std_Types.h */
    #if (CAN_CFG_H_AR_RELEASE_MINOR_VERSION != STD_TYPES_H_AR_RELEASE_MINOR_VERSION)
        #error "AUTOSAR minor Version Number mismatch between Can_Cfg.h and Std_Types.h"
    #endif
#endif

/*************************************************************************************************
                                        CONSTANT DEFINITION
**************************************************************************************************/

/*****************************************INTERRUPT AND NOTIFICATION CONFIG START******************************/
/* Enable/Disable the Wakeup notification. */
#define CAN_WAKEUP_NOTIFICATION_ENABLE                (STD_OFF)
/* Enable/Disable the ECC error notification. */
#define CAN_ECC_ERROR_NOTIFICATION_ENABLE             (STD_ON)
/* Enable/Disable the ECC error uncorrect notification. */
#define CAN_ECC_ERROR_UNCORRECT_NOTIFICATION_ENABLE   (STD_ON)
/* Enable/Disable the ECC error correct notification. */
#define CAN_ECC_ERROR_CORRECT_NOTIFICATION_ENABLE     (STD_ON)
/* Enable/Disable the CAN Rx Fifo message lost notification. */
#define CAN_RXFIFO_MSG_LOST_NOTIFICATION_ENABLE       (STD_OFF)
/* Enable/Disable the CAN high prority message notification. */
#define CAN_HIGH_PRIORITY_MSG_NOTIFICATION_ENABLE     (STD_OFF)
/* Enable/Disable the CAN transmission completed notification */
#define CAN_TRANS_COMPLETE_NOTIFICATION_ENABLE        (STD_ON)
/* Enable/Disable the CAN cancel finished notification */
#define CAN_CANCEL_FINISHED_NOTIFICATION_ENABLE       (STD_OFF)
/* Enable/Disable the CAN Tx FIFO empty notification */
#define CNA_TX_FIFO_EMPTY_NOTIFICATION_ENABLE         (STD_OFF)
/* Enable/Disable the Tx event FIFO lost element notification */
#define CAN_TX_EVT_FIFO_LOST_ELE_NOTIFICATION_ENABLE  (STD_OFF)
/* Enable/Disable the Timestamp overflow notification */
#define CAN_TIMESTAMP_OVERFLOW_NOTIFICATION_ENABLE    (STD_OFF)
/* Enable/Disable the CAN RAM access failed notification */
#define CAN_RAM_ACC_FAILED_NOTIFICATION_ENABLE        (STD_OFF)
/* Enable/Disable the CAN time overflow notification */
#define CAN_TIME_OVERFLOW_NOTIFICATION_ENABLE         (STD_OFF)
/* Enable/Disable the CAN error log overflow notification */
#define CAN_ERROR_LOG_OVERFLOW_NOTIFICATION_ENABLE    (STD_OFF)
/* Enable/Disable the CAN error passive notification */
#define CAN_ERROR_PASSIVE_NOTIFICATION_ENABLE         (STD_OFF)
/* Enable/Disable the CAN error warning notification */
#define CAN_ERROR_WARNING_NOTIFICATION_ENABLE         (STD_OFF)
/* Enable/Disable the CAN bus off notification */
#define CAN_WDG_NOTIFICATION_ENABLE                   (STD_OFF)
/* Enable/Disable the CAN protocol error notification for arbitration */
#define CAN_PLROTOCOL_ERROR_ARB_NOTIFICATION_ENABLE   (STD_OFF)
/* Enable/Disable the CAN protocol error notification for data phase */
#define CAN_PLROTOCOL_ERROR_DATA_NOTIFICATION_ENABLE  (STD_OFF)
/* Enable/Disable the CAN access to reserved address notification */
#define CAN_ACC_RESERVED_ADDR_NOTIFICATION_ENABLE     (STD_OFF)

/* Enable/Disable the LPDU notification for Can */
#define CAN_ENABLE_LPDU_NOTIFICATION                  (STD_ON)

/* Enable/Disable the CAN TX interrupt. */
#define CAN_TX_INTERRUPT_HANDLE_ENABLE                (STD_OFF)
/* Enable/Disable the CAN RX Fifo interrupt. */
#define CAN_RX_INTERRUPT_HANDLE_ENABLE                (STD_ON)
/* Enable/Disable the CAN bus off interrupt. */
#define CAN_BUSOFF_INTERRUPT_HANDLE_ENABLE            (STD_ON)

/*********************************************INTERRUPT AND NOTIFICATION CONFIG END****************************/

/* Enable/Disable the Can_MainFunction_Read_X() API for Can */
#define CAN_MAINFUNCTION_MULTIPLE_READ                (STD_ON)
#define CAN_MAINFUNCTION_PERIOD_READ_0                (STD_ON)
#define CAN_MAINFUNCTION_PERIOD_READ_1                (STD_ON)
#define CAN_MAINFUNCTION_PERIOD_READ_2                (STD_ON)
#define CAN_MAINFUNCTION_PERIOD_READ_3                (STD_ON)

/* Enable/Disable the Can_MainFunction_Write_X() API for Can */
#define CAN_MAINFUNCTION_MULTIPLE_WRITE               (STD_ON)
#define CAN_MAINFUNCTION_PERIOD_WRITE_0               (STD_ON)
#define CAN_MAINFUNCTION_PERIOD_WRITE_1               (STD_ON)
#define CAN_MAINFUNCTION_PERIOD_WRITE_2               (STD_ON)

#define CAN_RXFIFO_ENABLE                             (STD_ON)

/* Defines of enable/disable the ERM */
#define CAN_ENABLE_ERM                                (STD_ON)

/* Defines of enable/disable timeout as loop */
#define CAN_ENABLE_TIMEOUT_AS_LOOP                    (STD_ON)

/* Defines of enable/disable ICOM feature for Can */
#define CAN_PUBLIC_ICOM_ENABLE                        (STD_ON)

/* Enable/Disable the aborts only one message buffer for Can when CAN_MULTIPLEXED_TRANSMISSION_ENABLE = STD_ON */
#define CAN_ABORT_ONLY_ONE_MB                         (STD_ON)

/* Enable/Disable the Can_Hw_AbortMb() API for Can */
#define CAN_ABORT_MB_API_ENABLE                       (STD_ON)

/* Enable/Disable the Multiplexed Transmision for Can */
#define CAN_MULTIPLEXED_TRANSMISSION_ENABLE           (STD_ON)

/* Enable/Disable the Can_GetVersionInfo API for Can */
#define CAN_GET_VERSION_INFO_API_ENABLE               (STD_ON)

/* Enable/Disable the Development Error Detection and Notification */
#define CAN_DEV_ERROR_DETECT_ENABLE                   (STD_ON)

/* Enable/Disable the Can_SetBaudrate() API for Can */
#define CAN_SET_BAUDRATE_API                          (STD_ON)

/* Include/exclude the extend id for Can */
#define CAN_INCLUDE_EXTENDEDID                        (STD_ON)

/* Enable/Disable the trigger transmit feature for Can */
#define CAN_TRIGGER_TRANSMIT_ENABLE                   (STD_OFF)

/* Enable/Disable the ISO CAN FD feature for Can Controller */
#define CAN_CONTROLLER_ENABLE_ISO_CANFD               (STD_OFF)

/* Defines for Can FD Init*/
#define CAN_ENABLE_FD_MODE                            (STD_ON)

/* Defines for Can Hardware Objects ID*/
#define  CAN0_RX_STANDARD_1                           (0U)
#define  CAN0_RX_EXTENDED_1                           (1U)
#define  CAN0_RX_STANDARD_2                           (2U)
#define  CAN0_RX_EXTENDED_2                           (3U)
#define  CAN0_TX_1                                    (4U)
#define  CAN0_TX_2                                    (5U)
#define  CAN0_TX_3                                    (6U)

/* Defines the Instance hardware id of the Can module */
#define CAN_HW_INSTANCE0                              (0U)

/* Defines for can Controllers */
#define CanConf_CanController_CAN0                    (0U)

/* Defines the Maximum possible number of Message Buffers per controller */
#define CAN_MAX_TX_MB_SUPPORTED                       (32U)

/* Defines the Maximum number of controllers Configured */
#define CAN_MAXCTRL_NUMBER_CFG                        (1U)

#define CAN_TIMEOUT_VALUE                             (65535U)

/* The number of the ICOM messages configured */
#define CAN_NOOF_ICOM_MSG_CONFIG                      (2U)

/* Number of RAM sections required for CAN messages configured */
#define CAN_RAM_SECTIONS_CNT_PER_CONTROLLER           (7U)

/* Defines the Baudrate Configured ID */
#define CAN_BAUDRATE_CONFIG_ID_0                      (0U)
#define CAN_BAUDRATE_CONFIG_ID_1                      (1U)

/***************************************************MESSAGE RAM CONFIG START******************************************/
/* Defines the Number of Dedicated Tx Buffers Configured */
#define CAN_TX_DEDICATED_BUF_CONFIG_NUMBER            (3U)
/* Defines the size of Tx FIFO Queued Configured */
#define CAN_TX_FIFO_QUEUE_CONFIG_SIZE                 (2U)
/* Defines the size of Tx Event FIFO Configured */
#define CAN_TX_EVT_FIFO_CONFIG_SIZE                   (10U)
/* Defines the size of Rx FIFO 0 Configured */
#define CAN_RX_FIFO0_CONFIG_SIZE                      (3U)
/* Defines the size of Rx FIFO 1 Configured */
#define CAN_RX_FIFO1_CONFIG_SIZE                      (3U)
/***************************************************MESSAGE RAM CONFIG END********************************************/

/*******************************************************FILTER CONFIG START*******************************************/
/* Defines the Standard Filter Configured Size */
#define CAN_FILTER_STANDARD_LIST_SIZE                 (3U)
/* Defines the Extended Filter Configured Size */
#define CAN_FILTER_EXTENDED_LIST_SIZE                 (2U)

/*******************************************************FILTER CONFIG END*********************************************/

#define CAN_CONF_PB \
    extern CONST(Can_ConfigType, CAN_CONST) g_canConfig;

#define Can_LPduReceiveCalloutFunction                (Can_LPduReceived)

#ifdef __cplusplus
}
#endif

#endif /* end of _CAN_CFG_H_ */
