mirror of
https://gitee.com/dlmu-cone/bf_original_balance_chassis
synced 2026-07-24 11:37:45 +08:00
修复电机反馈的bug,通信bug,ps2手柄支持,舵机的修复,cmdbug的修复
This commit is contained in:
@@ -28,6 +28,7 @@ static void DecodeVision()
|
||||
{
|
||||
static uint16_t flag_register;
|
||||
get_protocol_info(vision_usart_instance->recv_buff, &flag_register, (uint8_t *)&recv_data.pitch);
|
||||
|
||||
// TODO: code to resolve flag_register;
|
||||
}
|
||||
|
||||
@@ -58,8 +59,13 @@ void VisionSend(Vision_Send_s *send)
|
||||
static uint8_t send_buff[VISION_SEND_SIZE];
|
||||
static uint16_t tx_len;
|
||||
// TODO: code to set flag_register
|
||||
|
||||
flag_register = 0x0001;
|
||||
// 将数据转化为seasky协议的数据包
|
||||
get_protocol_send_data(0x02, flag_register, &send->yaw, 3, send_buff, &tx_len);
|
||||
USARTSend(vision_usart_instance, send_buff, tx_len);
|
||||
USARTSend(vision_usart_instance, send_buff, tx_len,USART_TRANSFER_IT);
|
||||
// if(vision_usart_instance->usart_handle->ReceptionType == HAL_UART_RECEPTION_TOIDLE)
|
||||
// {HAL_UARTEx_ReceiveToIdle_DMA(vision_usart_instance->usart_handle, vision_usart_instance->recv_buff, vision_usart_instance->recv_buff_size);
|
||||
// __HAL_DMA_DISABLE_IT(vision_usart_instance->usart_handle->hdmarx, DMA_IT_HT);
|
||||
|
||||
// }
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "bsp_usart.h"
|
||||
#include "seasky_protocol.h"
|
||||
|
||||
#define VISION_RECV_SIZE 36u // 当前为固定值,36字节
|
||||
#define VISION_RECV_SIZE 18u // 当前为固定值,36字节
|
||||
#define VISION_SEND_SIZE 36u
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
@@ -15,6 +15,11 @@
|
||||
#include "crc16.h"
|
||||
#include "memory.h"
|
||||
|
||||
/*获取CRC8校验码*/
|
||||
uint8_t Get_CRC8_Check(uint8_t *pchMessage,uint16_t dwLength)
|
||||
{
|
||||
return crc_8(pchMessage,dwLength);
|
||||
}
|
||||
/*检验CRC8数据段*/
|
||||
static uint8_t CRC8_Check_Sum(uint8_t *pchMessage, uint16_t dwLength)
|
||||
{
|
||||
@@ -25,6 +30,12 @@ static uint8_t CRC8_Check_Sum(uint8_t *pchMessage, uint16_t dwLength)
|
||||
return (ucExpected == pchMessage[dwLength - 1]);
|
||||
}
|
||||
|
||||
/*获取CRC16校验码*/
|
||||
uint16_t Get_CRC16_Check(uint8_t *pchMessage,uint32_t dwLength)
|
||||
{
|
||||
return crc_16(pchMessage,dwLength);
|
||||
}
|
||||
|
||||
/*检验CRC16数据段*/
|
||||
static uint16_t CRC16_Check_Sum(uint8_t *pchMessage, uint32_t dwLength)
|
||||
{
|
||||
@@ -45,7 +56,7 @@ static uint8_t protocol_heade_Check(protocol_rm_struct *pro, uint8_t *rx_buf)
|
||||
pro->header.sof = rx_buf[0];
|
||||
if (CRC8_Check_Sum(&rx_buf[0], 4))
|
||||
{
|
||||
pro->header.data_length = (rx_buf[2] << 8) | rx_buf[1];
|
||||
pro->header.data_length = ((rx_buf[2] << 8) | rx_buf[1]);
|
||||
pro->header.crc_check = rx_buf[3];
|
||||
pro->cmd_id = (rx_buf[5] << 8) | rx_buf[4];
|
||||
return 1;
|
||||
@@ -114,9 +125,9 @@ uint16_t get_protocol_info(uint8_t *rx_buf, // 接收到的原始数据
|
||||
if (CRC16_Check_Sum(&rx_buf[0], date_length))
|
||||
{
|
||||
*flags_register = (rx_buf[7] << 8) | rx_buf[6];
|
||||
memcpy(rx_data, rx_buf + 8, 4 * sizeof(pro.header.data_length - 2));
|
||||
memcpy(rx_data, rx_buf + 8, (pro.header.data_length - 2));
|
||||
return pro.cmd_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user