/*
 * @Author: qianziyang qianzy@bmser.com
 * @Date: 2023-09-07 20:00:38
 * @LastEditors: qianziyang qianzy@bmser.com
 * @LastEditTime: 2024-01-22 17:24:00
 * @FilePath: /rk3568_sdk/bmser_app/xieneng_can/src/bmser_can_j1939_recv.h
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#ifndef BMSER_CAN_J1939_RECV_H__
#define BMSER_CAN_J1939_RECV_H__

#include "can_inf.h"
#include "bmser_can_init.h"
#include "j1939.h"

/*!
 * @brief       CAN消息处理初始化（BCU J1939）
 *
 * @param[in]   J1939CanDeviceParam j1939_param
 * @return      void
 * @retval      None
 *
 * @par         modify    log
 * Date        Author     Description             \n
 * 2023-4-11    jyg      Create             \n
 *
 */
Std_Ret_Type J1939RecvMsg_Init(CAN_INF_CFG_STRU *pCanInitCfg);

/*!
 * @brief       接收CAN数据帧回调函数
 *
 * @param[in]   ComIf_Handle_Type handle
 * @param[in]   ComIfData* msg
 * @return      int32_t
 * @retval      None
 *
 * @par         modify    log
 * Date        Author     Description             \n
 * 2023-4-11    jyg      Create             \n
 *
 */
Std_Ret_Type J1939RecvMsg_ReceiveCallback(int canIdIndex, CanMsg *rxcan);


/*!
 * @brief       定时读取主控中的接收的J1939信息与J1939定时会话轮询(调用频率越快越好)
 *
 * @param[in]   void
 * @return      void
 * @retval      None
 *
 * @par         modify    log
 * Date        Author     Description             \n
 * 2023-4-28    jyg      Create             \n
 *
 */
void J1939RecvMsg_TpSession_Runnable (void);

/*!
 * @brief       获取多帧传输时数据发送状态
 *
 * @param[in]   int32_t canIdIndex
 * @return      TpStatus
 * @retval      TpStatus
 *
 * @par         modify    log
 * Date        Author     Description             \n
 * 2023-8-16    jyg      Create             \n
 *
 */
TpStatus J1939MasterRecvMsg_GetTpRecvState(int32_t canIdIndex);

/*!
 * @brief       获取接收详细信息的标志
 *
 * @param[in]   int32_t canIdIndex
 * @return      Std_Bool_Enum
 * @retval      uint64_t bit0~Bit63 每一位代表一簇，该位置1，则说明该簇接收完毕
 *
 * @par         modify    log
 * Date        Author     Description             \n
 * 2023-9-5    jyg      Create             \n
 *
 */
uint64_t J1939MasterRecvMsg_GetRecvDetailInfoFlag(int32_t canIdIndex);

/*!
 * @brief       清除接收详细信息的标志
 *
 * @param[in]   int32_t canIdIndex
 * @return      Std_Ret_Type
 * @retval      Std_Ret_ERR:重置失败 Std_Ret_OK:重置成功
 *
 * @par         modify    log
 * Date        Author     Description             \n
 * 2023-9-5    jyg      Create             \n
 *
 */
Std_Ret_Type J1939MasterRecvMsg_ResetRecvDetailInfoFlag(int32_t canIdIndex);

/*!
 * @brief       获取BUC初始化状态；
 *
 * @param[in]   uint32_t canIdIndex
 * @param[in]   uint64_t *bcuInitState
 * @return      Std_Ret_Type
 * @retval      Std_Ret_OK:获取成功 Std_Ret_OK:获取失败
 *
 * @par         modify    log
 * Date        Author     Description             \n
 * 2023-9-6    jyg      Create             \n
 */
Std_Ret_Type J1939MasterRecvMsg_GetBcuInitState(uint32_t canIdIndex,uint64_t *bcuInitState);

/*!
 * @brief       重置BUC初始化状态；
 *
 * @param[in]   uint32_t canIdIndex
 * @param[in]   uint8_t bcuIndex
 * @return      Std_Ret_Type
 * @retval      Std_Ret_OK:重置成功 Std_Ret_OK:重置失败
 *
 * @par         modify    log
 * Date        Author     Description             \n
 * 2023-9-6    jyg      Create             \n
 */
Std_Ret_Type J1939MasterRecvMsg_SetBcuInitState(uint32_t canIdIndex,uint8_t bcuIndex);

/*!
 * @brief       获取簇接收j1939报文时间戳；
 *
 * @param[in]   int32_t devid
 * @return      long long 
 * @retval      接收报文时间戳
 *
 * @par         modify    log
 * Date        Author     Description             \n
 * 2024-1-22    qzy      Create             \n
 */
long long J1939Get_recvTime(int32_t devid);
#endif


