fix bugs
This commit is contained in:
parent
4d32450e3d
commit
35d88aaa93
|
@ -42,6 +42,7 @@
|
||||||
"usb_device.h": "c",
|
"usb_device.h": "c",
|
||||||
"vofa_protocol.h": "c",
|
"vofa_protocol.h": "c",
|
||||||
"master_process.h": "c",
|
"master_process.h": "c",
|
||||||
"stdint-gcc.h": "c"
|
"stdint-gcc.h": "c",
|
||||||
|
"string.h": "c"
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -57,14 +57,14 @@ static void CANServiceInit()
|
||||||
|
|
||||||
/* -----------------------two extern callable function -----------------------*/
|
/* -----------------------two extern callable function -----------------------*/
|
||||||
|
|
||||||
void CANRegister(can_instance* ins,can_instance_config config)
|
void CANRegister(can_instance *ins, can_instance_config config)
|
||||||
{
|
{
|
||||||
static uint8_t idx;
|
static uint8_t idx;
|
||||||
if (!idx)
|
if (!idx)
|
||||||
{
|
{
|
||||||
CANServiceInit();
|
CANServiceInit();
|
||||||
}
|
}
|
||||||
instance[idx]=ins;
|
instance[idx] = ins;
|
||||||
|
|
||||||
instance[idx]->txconf.StdId = config.tx_id;
|
instance[idx]->txconf.StdId = config.tx_id;
|
||||||
instance[idx]->txconf.IDE = CAN_ID_STD;
|
instance[idx]->txconf.IDE = CAN_ID_STD;
|
||||||
|
@ -76,9 +76,7 @@ void CANRegister(can_instance* ins,can_instance_config config)
|
||||||
instance[idx]->rx_id = config.rx_id;
|
instance[idx]->rx_id = config.rx_id;
|
||||||
instance[idx]->can_module_callback = config.can_module_callback;
|
instance[idx]->can_module_callback = config.can_module_callback;
|
||||||
|
|
||||||
CANAddFilter(instance[idx]);
|
CANAddFilter(instance[idx++]);
|
||||||
|
|
||||||
return instance[idx++];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CANTransmit(can_instance *_instance)
|
void CANTransmit(can_instance *_instance)
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
* @brief 串口bsp层的实现
|
* @brief 串口bsp层的实现
|
||||||
* @version beta
|
* @version beta
|
||||||
* @date 2022-11-01
|
* @date 2022-11-01
|
||||||
*
|
*
|
||||||
* @copyright Copyright (c) 2022
|
* @copyright Copyright (c) 2022
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#include "bsp_usart.h"
|
#include "bsp_usart.h"
|
||||||
#include "stdlib.h"
|
#include "stdlib.h"
|
||||||
|
@ -30,7 +30,7 @@ static void USARTServiceInit(usart_instance *_instance)
|
||||||
|
|
||||||
void USARTRegister(usart_instance *_instance)
|
void USARTRegister(usart_instance *_instance)
|
||||||
{
|
{
|
||||||
static instance_idx;
|
static uint8_t instance_idx;
|
||||||
USARTServiceInit(_instance);
|
USARTServiceInit(_instance);
|
||||||
instance[instance_idx++] = _instance;
|
instance[instance_idx++] = _instance;
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,7 @@ typedef struct
|
||||||
float frame_period; //ʱ<><CAB1><EFBFBD><EFBFBD>
|
float frame_period; //ʱ<><CAB1><EFBFBD><EFBFBD>
|
||||||
} ramp_function_source_t;
|
} ramp_function_source_t;
|
||||||
|
|
||||||
typedef __packed struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uint16_t Order;
|
uint16_t Order;
|
||||||
uint32_t Count;
|
uint32_t Count;
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include "QuaternionEKF.h"
|
#include "QuaternionEKF.h"
|
||||||
#include "bsp_temperature.h"
|
#include "bsp_temperature.h"
|
||||||
#include "spi.h"
|
#include "spi.h"
|
||||||
|
#include "user_lib.h"
|
||||||
|
|
||||||
static INS_t INS;
|
static INS_t INS;
|
||||||
IMU_Param_t IMU_Param;
|
IMU_Param_t IMU_Param;
|
||||||
|
|
|
@ -8,27 +8,18 @@
|
||||||
#define VISION_RECV_SIZE 36u
|
#define VISION_RECV_SIZE 36u
|
||||||
#define VISION_SEND_SIZE 36u
|
#define VISION_SEND_SIZE 36u
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 调用此函数初始化和视觉的串口通信
|
* @brief 调用此函数初始化和视觉的串口通信
|
||||||
*
|
*
|
||||||
* @param handle 用于和视觉通信的串口handle(C板上一般为USART1,丝印为USART2,4pin)
|
* @param handle 用于和视觉通信的串口handle(C板上一般为USART1,丝印为USART2,4pin)
|
||||||
*/
|
*/
|
||||||
Vision_Recv_s* VisionInit(UART_HandleTypeDef* handle);
|
Vision_Recv_s *VisionInit(UART_HandleTypeDef *handle);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 发送视觉视觉
|
* @brief 发送视觉视觉
|
||||||
*
|
*
|
||||||
* @param send 视觉需要的数据
|
* @param send 视觉需要的数据
|
||||||
*/
|
*/
|
||||||
void VisionSend(Vision_Send_s *send);
|
void VisionSend(Vision_Send_s *send);
|
||||||
|
|
||||||
|
|
||||||
#endif // !MASTER_PROCESS_H
|
#endif // !MASTER_PROCESS_H
|
|
@ -139,4 +139,5 @@ uint16_t get_protocol_info(uint8_t *rx_buf, //接收到的原始数据
|
||||||
return pro.cmd_id;
|
return pro.cmd_id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ static void DecodeJoint(can_instance* motor_instance)
|
||||||
uint16_t tmp;
|
uint16_t tmp;
|
||||||
for (size_t i = 0; i < HT_MOTOR_CNT; i++)
|
for (size_t i = 0; i < HT_MOTOR_CNT; i++)
|
||||||
{
|
{
|
||||||
if(&joint_motor_info[i]->motor_can_instace==motor_instance)
|
if(joint_motor_info[i]->motor_can_instace==motor_instance)
|
||||||
{
|
{
|
||||||
tmp = (motor_instance->rx_buff[1] << 8) | motor_instance->rx_buff[2];
|
tmp = (motor_instance->rx_buff[1] << 8) | motor_instance->rx_buff[2];
|
||||||
joint_motor_info[i]->last_ecd=joint_motor_info[i]->ecd;
|
joint_motor_info[i]->last_ecd=joint_motor_info[i]->ecd;
|
||||||
|
@ -40,7 +40,8 @@ joint_instance* HTMotorInit(can_instance_config config)
|
||||||
{
|
{
|
||||||
static uint8_t idx;
|
static uint8_t idx;
|
||||||
joint_motor_info[idx]=(joint_instance*)malloc(sizeof(joint_instance));
|
joint_motor_info[idx]=(joint_instance*)malloc(sizeof(joint_instance));
|
||||||
CANRegister(&joint_motor_info[idx++]->motor_can_instace,config);
|
CANRegister(joint_motor_info[idx++]->motor_can_instace,config);
|
||||||
|
return joint_motor_info[idx++];
|
||||||
}
|
}
|
||||||
|
|
||||||
void JointControl(joint_instance* _instance,float current)
|
void JointControl(joint_instance* _instance,float current)
|
||||||
|
|
|
@ -1,47 +1,47 @@
|
||||||
#include"LK9025.h"
|
#include "LK9025.h"
|
||||||
|
|
||||||
static driven_instance* driven_motor_info[LK_MOTOR_CNT];
|
static driven_instance *driven_motor_info[LK_MOTOR_CNT];
|
||||||
|
|
||||||
static void DecodeDriven(can_instance* _instance)
|
static void DecodeDriven(can_instance *_instance)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < LK_MOTOR_CNT; i++)
|
for (size_t i = 0; i < LK_MOTOR_CNT; i++)
|
||||||
{
|
{
|
||||||
if(&driven_motor_info[i]->motor_can_instance==_instance)
|
if (driven_motor_info[i]->motor_can_instance == _instance)
|
||||||
{
|
{
|
||||||
driven_motor_info[i]->last_ecd = driven_motor_info[i]->ecd;
|
driven_motor_info[i]->last_ecd = driven_motor_info[i]->ecd;
|
||||||
driven_motor_info[i]->ecd = (uint16_t)((_instance->rx_buff[7]<<8) | _instance->rx_buff[6]);
|
driven_motor_info[i]->ecd = (uint16_t)((_instance->rx_buff[7] << 8) | _instance->rx_buff[6]);
|
||||||
driven_motor_info[i]->speed_rpm = (uint16_t)(_instance->rx_buff[5] << 8 | _instance->rx_buff[4]);
|
driven_motor_info[i]->speed_rpm = (uint16_t)(_instance->rx_buff[5] << 8 | _instance->rx_buff[4]);
|
||||||
driven_motor_info[i]->given_current = (uint16_t)(_instance->rx_buff[3] << 8 | _instance->rx_buff[2]);
|
driven_motor_info[i]->given_current = (uint16_t)(_instance->rx_buff[3] << 8 | _instance->rx_buff[2]);
|
||||||
driven_motor_info[i]->temperate = _instance->rx_buff[1];
|
driven_motor_info[i]->temperate = _instance->rx_buff[1];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
driven_instance* LKMotroInit(can_instance_config config)
|
driven_instance *LKMotroInit(can_instance_config config)
|
||||||
{
|
{
|
||||||
static uint8_t idx;
|
static uint8_t idx;
|
||||||
driven_motor_info[idx]=(driven_instance*)malloc(sizeof(driven_instance));
|
driven_motor_info[idx] = (driven_instance *)malloc(sizeof(driven_instance));
|
||||||
config.can_module_callback=DecodeDriven;
|
config.can_module_callback = DecodeDriven;
|
||||||
CANRegister(driven_motor_info[idx++]->motor_can_instance,config);
|
CANRegister(driven_motor_info[idx]->motor_can_instance, config);
|
||||||
|
return driven_motor_info[idx++];
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrivenControl(int16_t motor1_current,int16_t motor2_current)
|
void DrivenControl(int16_t motor1_current, int16_t motor2_current)
|
||||||
{
|
{
|
||||||
LIMIT_MIN_MAX(motor1_current, I_MIN, I_MAX);
|
LIMIT_MIN_MAX(motor1_current, I_MIN, I_MAX);
|
||||||
LIMIT_MIN_MAX(motor2_current, I_MIN, I_MAX);
|
LIMIT_MIN_MAX(motor2_current, I_MIN, I_MAX);
|
||||||
driven_motor_info[0]->motor_can_instance->tx_buff[0] = motor1_current;
|
driven_motor_info[0]->motor_can_instance->tx_buff[0] = motor1_current;
|
||||||
driven_motor_info[0]->motor_can_instance->tx_buff[1] = motor1_current>>8;
|
driven_motor_info[0]->motor_can_instance->tx_buff[1] = motor1_current >> 8;
|
||||||
driven_motor_info[0]->motor_can_instance->tx_buff[2] = motor2_current;
|
driven_motor_info[0]->motor_can_instance->tx_buff[2] = motor2_current;
|
||||||
driven_motor_info[0]->motor_can_instance->tx_buff[3] = motor2_current>>8;
|
driven_motor_info[0]->motor_can_instance->tx_buff[3] = motor2_current >> 8;
|
||||||
CANTransmit(driven_motor_info[0]->motor_can_instance);
|
CANTransmit(driven_motor_info[0]->motor_can_instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetDrivenMode(driven_mode cmd,uint16_t motor_id)
|
void SetDrivenMode(driven_mode cmd, uint16_t motor_id)
|
||||||
{
|
{
|
||||||
static uint8_t buf[8] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00};
|
static uint8_t buf[8] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00};
|
||||||
// code goes here ...
|
// code goes here ...
|
||||||
|
|
||||||
// CANTransmit(driven_mode)
|
// CANTransmit(driven_mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
#ifndef MOTOR_DEF_H
|
#ifndef MOTOR_DEF_H
|
||||||
#define MOTOR_DEF_H
|
#define MOTOR_DEF_H
|
||||||
|
|
||||||
|
#include "controller.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 闭环类型,如果需要多个闭环,则使用或运算
|
* @brief 闭环类型,如果需要多个闭环,则使用或运算
|
||||||
* 例如需要速度环和电流环: CURRENT_LOOP|SPEED_LOOP
|
* 例如需要速度环和电流环: CURRENT_LOOP|SPEED_LOOP
|
||||||
|
|
Loading…
Reference in New Issue