#ifndef _RTE_CAN_H_
#define _RTE_CAN_H_

#include "TYW_stdint.h"

typedef enum
{
    CAN_OK,
    CAN_NOT_OK,
    CAN_BUSY,
} Can_ReturnType;

typedef enum
{
    CAN_N_TX   = 0u,
    CAN_Y_TX   = 1u,
    CAN_N_F_TX = 0x81u,
} Can_SendType;

typedef enum
{
    CAN_N_RX   = 0u,
    CAN_Y_RX   = 1u,
    CAN_N_F_RX = 0x81u,
} Can_ReceiveType;

typedef struct
{
    uint32_t MsgID;
    uint8_t  MsgStd;
    uint8_t  MsgRTR;
    uint8_t  MsgDLC;
    uint8_t  MsgPro;
    uint8_t  Msg [ 8 ];
} _CAN_Msg;

void    Can_Lock_Clr(void);
void    CAN_BUSOFF_Recover(void);
void    Can_Init(void);
void    Can_DeInit(void);
uint8_t Can_Write(_CAN_Msg *Msg);
uint8_t Can_CH1_Write(_CAN_Msg *Msg);
uint8_t Can_CH2_Write(_CAN_Msg *Msg);
void    Can_Abort_Confirm(uint32_t Identifier, uint8_t TransferStatus);
void    Can_Sleep_Fun(void);
void    Can_SleepController_Fun(void);
void    Can_Wakeup_Fun(void);

void    Can0_Read_Msg(uint32_t m_id, uint8_t m_dlc, uint8_t m_Msg []);
void    Can0_Confirm(uint32_t Identifier, uint8_t TransferStatus);



void    Can_Abort_All(void);
void    Can_Uds_Abort(void);

void test_can(uint32_t u32ID);

uint8_t CAN_APP_Online(void);
uint8_t CAN_NM_Online(void);
void     CAN_Message_Time_Handle(void);

#endif
