optical/NxBase/canctrl.h

88 lines
1.5 KiB
C
Raw Permalink Normal View History

2025-09-04 01:45:08 +00:00
#ifndef __CANCTRL_H__
#define __CANCTRL_H__
#include "config.h"
#if (COMM_CAN != 0)
#include "can.h"
//---------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------
#ifndef HCAN
#define HCAN hcan
#endif
//-------------------------------------------------------------------------------
#ifndef CAN_DATA_LEN
#define CAN_DATA_LEN 8
#endif
#ifndef RESV_PKT_LIST_NUM
#define RESV_PKT_LIST_NUM 16
#endif
#ifndef TRANS_PKT_LIST_NUM
#define TRANS_PKT_LIST_NUM 16
#endif
typedef struct
{
CAN_TxHeaderTypeDef canTxhead;
u8 data[CAN_DATA_LEN];
}CanTxMsg;
typedef struct
{
CAN_RxHeaderTypeDef canRxhead;
u8 data[8];
}CanRxMsg;
typedef struct
{
CanRxMsg pktRxList[RESV_PKT_LIST_NUM]; // <20><><EFBFBD>ջ<EFBFBD><D5BB><EFBFBD><EFBFBD><EFBFBD>
CanRxMsg * pktRxListHead; // ͷָ<CDB7><D6B8>
CanRxMsg * pktRxListTail; // βָ<CEB2><D6B8>
int pktRxNumber; // <20><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>
}CanRxCtrl;
typedef struct
{
CanTxMsg pktTxList[TRANS_PKT_LIST_NUM]; // <20><><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>
CanTxMsg * pktTxListHead; // ͷָ<CDB7><D6B8>
CanTxMsg * pktTxListTail; // βָ<CEB2><D6B8>
int pktTxNumber; // <20><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>
int sendingFlag; // <20><><EFBFBD>ͱ<EFBFBD>־
}CanTxCtrl;
//---------------------------------------------------------------------------------------------
void InitCanCtrl(void);
void DefaultCanFilter(u8 fifo);
void RegistFilter(void*func);
int SendACANDataPacket(CanTxMsg * pMsg);
int GetACanDataPacket(CanRxMsg * pMsg);
//---------------------------------------------------------------------------------------------
#endif
#endif