35 lines
827 B
C
35 lines
827 B
C
#ifndef CAN_DRIVER_H
|
|
#define CAN_DRIVER_H
|
|
|
|
#include "main.h"
|
|
|
|
#define MOTOR_NUM 4
|
|
void CAN_Driver_Init(void);
|
|
void CAN_Driver_Transmit(uint16_t std_id, uint8_t TxData[], uint8_t len);
|
|
|
|
// 回调函数,由中断调用,用于向上层传递接收到的数据
|
|
// 注意:这个回调函数需要在 motor_control.c 中实现
|
|
void CAN_Rx_Callback(uint16_t std_id, uint8_t RxData[]);
|
|
|
|
typedef struct {
|
|
// 电机反馈数据 (从 CAN 接收)
|
|
uint16_t rotor_angle;
|
|
int16_t speed_rpm;
|
|
int16_t actual_current;
|
|
uint8_t temp;
|
|
|
|
// 控制目标和输出
|
|
float Target_RPM; // 目标速度(外部设定)
|
|
int16_t target_current; // 目标电流/力矩值 (-16384 到 16384)
|
|
|
|
} M2006_Motor_t;
|
|
|
|
|
|
void Motor_Control_Init(void);
|
|
void Motor_Control_Loop(void);
|
|
|
|
|
|
|
|
|
|
#endif
|