/*!
* @file     Can_GeneralTypes.h
*
* @version  1.0.0
*
* @brief    AUTOSAR CAN general types. This file is only a sample
*
* @attention
*
* Project Name      : AUTOSAR MCAL
*
* Platform          : Arm
*
* Autosar Standard  : Classic Platform 4.4.0
*
* 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 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.
*/

#ifndef CAN_GENERAL_TYPES_H
#define CAN_GENERAL_TYPES_H

#ifdef __cplusplus
extern "C"{
#endif

#include "Can_Cfg.h"

/** @addtogroup G32A10xx_StdPeriphDriver
  @{
*/

/** @defgroup PLATFORM_Driver
  * @brief PLATFORM driver modules
  @{
*/

/** @defgroup PLATFORM_Macros
  @{
*/
/*******************************************************************************
                    VENDOR ID & AUTOSAR VERSION INFO
*******************************************************************************/
/** Major version number of AUTOSAR release on which the appropriate implementation is based on. */
#define CAN_GENERAL_TYPES_H_AR_RELEASE_MAJOR_VERSION     0x04U
/** Minor version number of AUTOSAR release on which the appropriate implementation is based on. */
#define CAN_GENERAL_TYPES_H_AR_RELEASE_MINOR_VERSION     0x04U

/**@} end of group PLATFORM_Macros */

/*******************************************************************************
                                TYPE DEFINES
*******************************************************************************/
/** @defgroup PLATFORM_Enumerations
  @{
*/

/**
 * @brief    Error states of a CAN controller
 */
typedef enum
{
    CAN_ERRORSTATE_ACTIVE  = 0U,
    CAN_ERRORSTATE_PASSIVE = 1U,
    CAN_ERRORSTATE_BUSOFF  = 2U
} Can_ErrorStateType;

/**@} end of group PLATFORM_Enumerations */

/** @defgroup PLATFORM_Structure
  @{
*/

/**
    Can_IdType
    Represents the identifier of an L-PDU.
    The two most significant bits specify the frame type:
    - 00 CAN message with standard CAN ID
    - 01 CAN FD frame with standard CAN ID
    - 10 CAN message with extended CAN ID
    - 11 CAN FD frame with extended CAN ID
*/
#ifdef CAN_INCLUDE_EXTENDEDID
    #if (STD_ON == CAN_INCLUDE_EXTENDEDID)
        typedef uint32 Can_IdType;
    #else
        typedef uint16 Can_IdType;
    #endif
#else
    typedef uint16 Can_IdType;
#endif

/**@} end of group PLATFORM_Structure */

/** @defgroup PLATFORM_Enumerations
  @{
*/

/**
 * @brief    States of a CAN controller
 */
typedef enum
{
    CAN_CS_UNINIT  = 0U,
    CAN_CS_STARTED = 1U,
    CAN_CS_STOPPED = 2U,
    CAN_CS_SLEEP   = 3U
} Can_ControllerStateType;

/**@} end of group PLATFORM_Enumerations */

/** @defgroup PLATFORM_Structure
  @{
*/

/** Represents the hardware object handles of a CAN hardware unit */
typedef uint8 Can_HwHandleType;

/**
* @brief    This type defines a data structure which provides an Hardware Object
*           Handle including its corresponding CAN controller and therefore
*           CanDrv as well as the specific CanId.
*/
typedef struct
{
    VAR(Can_IdType, CAN_VAR) CanId;     //!< Standard/Extended CAN ID of CAN L-PDU
    VAR(Can_HwHandleType, CAN_VAR) Hoh; //!< ID of the corresponding Hardware Object
    VAR(uint8, CAN_VAR) ControllerId;   //!< ControllerId provided by CanIf clearly identify the corresponding controller
} Can_HwType;

/**
* @brief    This type unites PduId (swPduHandle), SduLength (length), SduData (sdu), and CanId (id) for any CAN L-SDU.
*/
typedef struct
{
    VAR(Can_IdType, CAN_VAR) id;
    VAR(PduIdType, CAN_VAR) swPduHandle;
    VAR(uint8, CAN_VAR) length;
    P2VAR(uint8, CAN_VAR, CAN_APPL_DATA) sdu;
} Can_PduType;

/**@} end of group PLATFORM_Structure */

#ifdef __cplusplus
}
#endif

#endif

/**@} end of group PLATFORM_Driver */
/**@} end of group G32A10xx_StdPeriphDriver */
