mirror of
https://gitee.com/dlmu-cone/bf_original_balance_chassis
synced 2026-07-24 03:27:45 +08:00
add tutorial
This commit is contained in:
@@ -12,11 +12,14 @@
|
||||
|
||||
/* use usart1 as vision communication*/
|
||||
static Vision_Recv_s recv_data;
|
||||
// @todo:由于后续需要进行IMU-Cam的硬件触发采集控制,因此可能需要将发送设置为定时任务,或由IMU采集完成产生的中断唤醒的任务,
|
||||
// 使得时间戳对齐. 因此,在send_data中设定其他的标志位数据,让ins_task填充姿态值.
|
||||
// static Vision_Send_s send_data;
|
||||
static usart_instance vision_usart_instance;
|
||||
|
||||
/**
|
||||
* @brief 接收解包回调函数,将在bsp_usart.c中被usart rx callback调用
|
||||
* @todo 1.提高可读性,将get_protocol_info的第四个参数增加一个float buffer
|
||||
* @todo 1.提高可读性,将get_protocol_info的第四个参数增加一个float类型buffer
|
||||
* 2.添加标志位解码
|
||||
*/
|
||||
static void DecodeVision()
|
||||
@@ -38,8 +41,10 @@ Vision_Recv_s* VisionInit(UART_HandleTypeDef *handle)
|
||||
|
||||
/**
|
||||
* @brief 发送函数
|
||||
* @todo 1.提高可读性,将get_protocol_info的第四个参数增加一个float buffer
|
||||
* @todo 1.提高可读性,将get_protocol_send_data的第6个参数增加一个float buffer
|
||||
* 2.添加标志位解码
|
||||
* 3.由于后续需要进行IMU-Cam的硬件触发采集控制,因此可能需要将发送设置为定时任务
|
||||
* 或由IMU采集完成产生的中断唤醒的任务,使得时间戳对齐.
|
||||
*
|
||||
* @param send 待发送数据
|
||||
*/
|
||||
@@ -53,3 +58,9 @@ void VisionSend(Vision_Send_s *send)
|
||||
get_protocol_send_data(0x02, flag_register, &send->yaw, 3, send_buff, &tx_len);
|
||||
USARTSend(&vision_usart_instance, send_buff, tx_len);
|
||||
}
|
||||
|
||||
|
||||
Vision_Recv_s* VisionGetcmd()
|
||||
{
|
||||
return &recv_data;
|
||||
}
|
||||
@@ -22,4 +22,11 @@ Vision_Recv_s *VisionInit(UART_HandleTypeDef *handle);
|
||||
*/
|
||||
void VisionSend(Vision_Send_s *send);
|
||||
|
||||
/**
|
||||
* @brief 返回所需的上位机数据
|
||||
*
|
||||
* @return Vision_Recv_s* 数据结构体指针
|
||||
*/
|
||||
Vision_Recv_s* VisionGetcmd();
|
||||
|
||||
#endif // !MASTER_PROCESS_H
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#define PROTOCOL_CMD_ID 0XA5
|
||||
|
||||
#define OFFSET_BYTE 8 //出数据段外,其他部分所占字节数
|
||||
#define OFFSET_BYTE 8 // 出数据段外,其他部分所占字节数
|
||||
|
||||
typedef enum
|
||||
{
|
||||
@@ -77,7 +77,7 @@ typedef struct
|
||||
float pitch;
|
||||
float roll;
|
||||
|
||||
// uint32_t time_stamp;
|
||||
// uint32_t time_stamp; // @todo 用于和相机的时间戳对齐
|
||||
} Vision_Send_s;
|
||||
|
||||
typedef struct
|
||||
@@ -86,23 +86,23 @@ typedef struct
|
||||
{
|
||||
uint8_t sof;
|
||||
uint16_t data_length;
|
||||
uint8_t crc_check; //帧头CRC校验
|
||||
} header; //数据帧头
|
||||
uint16_t cmd_id; //数据ID
|
||||
uint16_t frame_tail; //帧尾CRC校验
|
||||
uint8_t crc_check; // 帧头CRC校验
|
||||
} header; // 数据帧头
|
||||
uint16_t cmd_id; // 数据ID
|
||||
uint16_t frame_tail; // 帧尾CRC校验
|
||||
} protocol_rm_struct;
|
||||
|
||||
/*更新发送数据帧,并计算发送数据帧长度*/
|
||||
void get_protocol_send_data(uint16_t send_id, //信号id
|
||||
void get_protocol_send_data(uint16_t send_id, // 信号id
|
||||
uint16_t flags_register, // 16位寄存器
|
||||
float *tx_data, //待发送的float数据
|
||||
float *tx_data, // 待发送的float数据
|
||||
uint8_t float_length, // float的数据长度
|
||||
uint8_t *tx_buf, //待发送的数据帧
|
||||
uint16_t *tx_buf_len); //待发送的数据帧长度
|
||||
uint8_t *tx_buf, // 待发送的数据帧
|
||||
uint16_t *tx_buf_len); // 待发送的数据帧长度
|
||||
|
||||
/*接收数据处理*/
|
||||
uint16_t get_protocol_info(uint8_t *rx_buf, //接收到的原始数据
|
||||
uint16_t *flags_register, //接收数据的16位寄存器地址
|
||||
float *rx_data); //接收的float数据存储地址
|
||||
uint16_t get_protocol_info(uint8_t *rx_buf, // 接收到的原始数据
|
||||
uint16_t *flags_register, // 接收数据的16位寄存器地址
|
||||
float *rx_data); // 接收的float数据存储地址
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user