You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
2.5 KiB
84 lines
2.5 KiB
/*
|
|
* bsp_FDCAN.h
|
|
*
|
|
* Created on: Oct 26, 2023
|
|
* Author: shiya
|
|
*/
|
|
|
|
#ifndef INC_BSP_FDCAN_H_
|
|
#define INC_BSP_FDCAN_H_
|
|
#include "bsp_Error.pb.h"
|
|
#include "../../BASE/Inc/BSP/bsp_com_helper.h"
|
|
uint8_t GF_BSP_FDCAN_Init(void);
|
|
|
|
void GF_BSP_FDCAN_Senddata(uint8_t FDCAN_CH, uint32_t FrameID,
|
|
uint8_t DataLength, uint8_t *Txdata);
|
|
|
|
extern uint8_t CAN_Buf[8];
|
|
|
|
extern uint8_t CAN_Buf[8];
|
|
extern uint8_t CAN_Buf_2[8];
|
|
typedef struct _CANSendHandler
|
|
{
|
|
uint32_t CAN_ID;
|
|
uint32_t SendListTimePeriod;
|
|
uint8_t SendLength;
|
|
uint8_t Tx_Buf[8];
|
|
void (*CAN_Decode)(uint32_t, uint8_t*, uint32_t);
|
|
struct _CANSendHandler *pNext;
|
|
} CANSendHandler;
|
|
|
|
typedef struct _FDCANHandler
|
|
{
|
|
|
|
FDCAN_HandleTypeDef *canfd; //UART to use
|
|
struct _DispacherController *dispacherController;
|
|
|
|
|
|
uint8_t timeSpan;
|
|
|
|
uint8_t SendListExists;
|
|
uint32_t SendList_Period; //时间ms
|
|
uint32_t SendList_time_Count;
|
|
|
|
CANSendHandler *pCurrentCANSendHadler; //
|
|
void (*AddCANSendList)(struct _FDCANHandler*, uint32_t, uint8_t, uint8_t*,uint32_t,//这里是修改等待时间
|
|
void (*CAN_Decode)(uint32_t, uint8_t*, uint32_t));
|
|
|
|
void (*CAN_Decode)(uint32_t, uint8_t*, uint32_t); // decode can frame, received from other devices
|
|
|
|
void (*CAN_Send)(struct _FDCANHandler*, uint32_t, uint8_t, uint8_t*);
|
|
void (*CAN_Send_Data)(struct _FDCANHandler*);
|
|
//(uint8_t FDCAN_CH, uint32_t FrameID,uint8_t DataLength, uint8_t *Txdata)
|
|
uint8_t Rx_Buf[128]; // 接收缓存,最大256字节
|
|
uint8_t Tx_Buf[128]; //发送缓存 157,864
|
|
uint32_t ReceivedLength;
|
|
uint32_t SendLength;
|
|
uint32_t ReceivedFrameID;
|
|
uint32_t SendFrameID;
|
|
|
|
} FDCANHandler;
|
|
|
|
extern FDCANHandler FD_CAN_1_Handler;
|
|
extern FDCANHandler FD_CAN_2_Handler;
|
|
void GF_BSP_CAN_Timer();
|
|
void CAN_Send_t(struct _FDCANHandler *fd, uint32_t FrameID, uint8_t DataLength,
|
|
uint8_t *Txdata);
|
|
void CAN_Send_Data_t(struct _FDCANHandler *fd);
|
|
|
|
void GF_CAN_Send_List_Send(FDCANHandler *handler);
|
|
void CANHandlerAddTxList(FDCANHandler *handler, uint32_t CAN_ID,
|
|
uint8_t SendLength, uint8_t *Tx_Buf,uint32_t sendListTimePeriod,
|
|
void (*CAN_Decode)(uint32_t, uint8_t*, uint32_t));
|
|
void GF_BSP_CANHandler_Init(int can1_sendListPeriod, int can1_DispacherPeriod,
|
|
int can2_sendListPeriod, int can2_DispacherPeriod);
|
|
void GF_BSP_CANHandler_Init_CAN(FDCANHandler *handler,
|
|
FDCAN_HandleTypeDef *canfd, int sendListPeriod, int DispacherPeriod);
|
|
|
|
void DecodeMotorCAN(uint32_t canID, uint8_t *buffer, uint32_t length);
|
|
|
|
extern FDCANHandler FD_CAN_1_Handler;
|
|
extern FDCANHandler FD_CAN_2_Handler;
|
|
extern int32_t CAN_ID;
|
|
extern int32_t CAN_ID_2;
|
|
#endif /* INC_BSP_FDCAN_H_ */
|
|
|