/*!
* @file     Lin_GeneralTypes.h
*
* @version  1.0.0
*
* @brief    AUTOSAR Platform - General Types
*
* @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 LIN_GENERAL_TYPES_H
#define LIN_GENERAL_TYPES_H

#ifdef __cplusplus
extern "C"{
#endif

/** @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 LIN_GENERAL_TYPES_H_AR_RELEASE_MAJOR_VERSION      0x04U
/** Minor version number of AUTOSAR release on which the appropriate implementation is based on. */
#define LIN_GENERAL_TYPES_H_AR_RELEASE_MINOR_VERSION      0x04U

/**@} end of group PLATFORM_Macros */

/*******************************************************************************
                            ENUMERATION DEFINITION
*******************************************************************************/
/** @defgroup PLATFORM_Enumerations
  @{
*/

/**
 * @brief    LIN Frame and Channel states
 */
typedef enum
{
    LIN_NOT_OK           = 0,  //!< Development or production error occurred
    LIN_TX_OK            = 1,  //!< Successful transmission
    LIN_TX_BUSY          = 2,  //!< Ongoing transmission (Header or Response)

    /**  Erroneous header transmission such as:
     *   - Mismatch between sent and read back data
     *   - Identifier parity error
     *   - Physical bus error 
    */
    LIN_TX_HEADER_ERROR  = 3,

    /** Erroneous transmission such as:
     *  - Mismatch between sent and read back data
     *  - Physical bus error 
    */
    LIN_TX_ERROR         = 4,
    LIN_RX_OK            = 5,  //!< Reception of correct response

    /** Ongoing reception: at least one response byte has
     *  been received, but the checksum byte has not been received
    */
    LIN_RX_BUSY          = 6,
    
    /** Erroneous reception such as:
     *  - Framing error
     *  - Overrun error
     *  - Checksum error
     *  - Short response.
    */
    LIN_RX_ERROR         = 7,
    LIN_RX_NO_RESPONSE   = 8,  //!< No response byte has been received so far
    
    /** Normal operation;The related LIN channel is ready
     *  to transmit next header, No data from previous frame available
    */
    LIN_OPERATIONAL      = 9,
    LIN_CH_SLEEP         = 10,  //!< Sleep mode operation; In this mode wake-up detection from slave nodes is enabled
    LIN_OK               = 11
} Lin_StatusType;

/**
 * @brief    Frame response type
 */
typedef enum
{
    LIN_MASTER_RESPONSE = 0,    //!< Response is generated from this (master) node
    LIN_SLAVE_RESPONSE  = 1,    //!< Response is generated from a remote slave node
    LIN_SLAVE_TO_SLAVE  = 2     //!< Response is generated from one slave to another slave
} Lin_FrameResponseType;

/**
 * @brief    Checksum model for the LIN framework
 */
typedef enum
{
    LIN_ENHANCED_CS = 0,    //!< Enhanced checksum model
    LIN_CLASSIC_CS  = 1     //!< Classic checksum model
} Lin_FrameCsModelType;

/**@} end of group PLATFORM_Enumerations */

/*******************************************************************************
                            STRUCT DEFINITION
*******************************************************************************/
/** @defgroup PLATFORM_Structure
  @{
*/

/** The LIN identifier (0..0x3F) with its parity bits */
typedef uint8 Lin_FramePidType;

/** Data length of a LIN Frame */
typedef uint8 Lin_FrameDlType;

/**
* @brief    The LIN identifier (0..0x3F) with its parity bits.
*/
typedef struct
{
    Lin_FramePidType      Pid;     //!< LIN frame identifier
    Lin_FrameCsModelType  Cs;      //!< Checksum model type
    Lin_FrameResponseType Drc;     //!< Response type
    Lin_FrameDlType       Dl;      //!< Data length
    uint8*                SduPtr;  //!< Pointer to Sdu
} Lin_PduType;

/**@} end of group PLATFORM_Structure */

#ifdef __cplusplus
}
#endif

#endif

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