This commit is contained in:
NeoZng 2022-11-09 20:24:22 +08:00
parent 4d32450e3d
commit 35d88aaa93
10 changed files with 39 additions and 44 deletions

View File

@ -42,6 +42,7 @@
"usb_device.h": "c",
"vofa_protocol.h": "c",
"master_process.h": "c",
"stdint-gcc.h": "c"
"stdint-gcc.h": "c",
"string.h": "c"
}
}

View File

@ -57,14 +57,14 @@ static void CANServiceInit()
/* -----------------------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;
if (!idx)
{
CANServiceInit();
}
instance[idx]=ins;
instance[idx] = ins;
instance[idx]->txconf.StdId = config.tx_id;
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]->can_module_callback = config.can_module_callback;
CANAddFilter(instance[idx]);
return instance[idx++];
CANAddFilter(instance[idx++]);
}
void CANTransmit(can_instance *_instance)

View File

@ -4,9 +4,9 @@
* @brief bsp层的实现
* @version beta
* @date 2022-11-01
*
*
* @copyright Copyright (c) 2022
*
*
*/
#include "bsp_usart.h"
#include "stdlib.h"
@ -30,7 +30,7 @@ static void USARTServiceInit(usart_instance *_instance)
void USARTRegister(usart_instance *_instance)
{
static instance_idx;
static uint8_t instance_idx;
USARTServiceInit(_instance);
instance[instance_idx++] = _instance;
}

View File

@ -96,7 +96,7 @@ typedef struct
float frame_period; //ʱ<><CAB1><EFBFBD><EFBFBD>
} ramp_function_source_t;
typedef __packed struct
typedef struct
{
uint16_t Order;
uint32_t Count;

View File

@ -15,6 +15,7 @@
#include "QuaternionEKF.h"
#include "bsp_temperature.h"
#include "spi.h"
#include "user_lib.h"
static INS_t INS;
IMU_Param_t IMU_Param;

View File

@ -8,27 +8,18 @@
#define VISION_RECV_SIZE 36u
#define VISION_SEND_SIZE 36u
typedef struct
{
};
/**
* @brief
*
*
* @param handle handle(C板上一般为USART1,USART2,4pin)
*/
Vision_Recv_s* VisionInit(UART_HandleTypeDef* handle);
Vision_Recv_s *VisionInit(UART_HandleTypeDef *handle);
/**
* @brief
*
*
* @param send
*/
void VisionSend(Vision_Send_s *send);
#endif // !MASTER_PROCESS_H

View File

@ -139,4 +139,5 @@ uint16_t get_protocol_info(uint8_t *rx_buf, //接收到的原始数据
return pro.cmd_id;
}
}
return 0;
}

View File

@ -22,7 +22,7 @@ static void DecodeJoint(can_instance* motor_instance)
uint16_t tmp;
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];
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;
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)

View File

@ -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++)
{
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]->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]->given_current = (uint16_t)(_instance->rx_buff[3] << 8 | _instance->rx_buff[2]);
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]->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]->temperate = _instance->rx_buff[1];
break;
}
}
}
driven_instance* LKMotroInit(can_instance_config config)
driven_instance *LKMotroInit(can_instance_config config)
{
static uint8_t idx;
driven_motor_info[idx]=(driven_instance*)malloc(sizeof(driven_instance));
config.can_module_callback=DecodeDriven;
CANRegister(driven_motor_info[idx++]->motor_can_instance,config);
driven_motor_info[idx] = (driven_instance *)malloc(sizeof(driven_instance));
config.can_module_callback = DecodeDriven;
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(motor2_current, I_MIN, I_MAX);
LIMIT_MIN_MAX(motor1_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[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[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);
}
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};
// code goes here ...
// CANTransmit(driven_mode)
}

View File

@ -12,6 +12,8 @@
#ifndef MOTOR_DEF_H
#define MOTOR_DEF_H
#include "controller.h"
/**
* @brief ,,使
* : CURRENT_LOOP|SPEED_LOOP