Files
Simba-OmniInfantry/云台/Bsp/Inc/bsp_can.h
T

28 lines
1002 B
C

#ifndef BSP_CAN_H
#define BSP_CAN_H
#include "stm32f4xx_hal.h"
#define BOARD_DATA_ANY ((uint16_t)0x500)//板间任意数据帧ID
#define BOARD_DATA_UINT16 ((uint16_t)0x600)//板间uint16数据帧ID
typedef CAN_HandleTypeDef hcan_t;//CAN句柄类型别名
typedef struct __CanCtrlData
{
hcan_t * hcan;//目标CAN句柄(&hcan1/&hcan2)
CAN_TxHeaderTypeDef tx_header;//发送帧头配置
uint8_t tx_data[8];//发送数据缓存(8字节)
} CanCtrlData_s;//CAN发送控制数据包结构体
typedef void (*can_rx_callback_f)(uint32_t std_id, const uint8_t rx_data[8], uint32_t dlc);//CAN接收回调函数指针(在RX0中断上下文执行)
extern hcan_t hcan1;//CAN1句柄
extern hcan_t hcan2;//CAN2句柄
void can_start(void);//初始化过滤器并启动CAN1/CAN2及RX0中断
int can_rx_register(hcan_t * hcan, uint32_t std_id, can_rx_callback_f callback);//按(hcan,标准ID)注册接收回调
void CAN_SendTxMessage(CanCtrlData_s * can_ctrl_data);//发送一帧CAN报文
#endif