feat: 增加 vofa justfloat 发送
This commit is contained in:
@@ -49,7 +49,7 @@ void by_frame_parse(uint8_t data_num, uint32_t *data_array)
|
|||||||
uint16_t crc_cal = 0;
|
uint16_t crc_cal = 0;
|
||||||
uint32_t read_length = 50;
|
uint32_t read_length = 50;
|
||||||
|
|
||||||
if (fifo_used(&frame_fifo)) {
|
if (fifo_used(&frame_fifo) >= 12) {
|
||||||
fifo_read_buffer(&frame_fifo, frame_buffer_parse, &read_length, FIFO_READ_AND_CLEAN);
|
fifo_read_buffer(&frame_fifo, frame_buffer_parse, &read_length, FIFO_READ_AND_CLEAN);
|
||||||
while (1) {
|
while (1) {
|
||||||
if (cnt_ptr < 50) {
|
if (cnt_ptr < 50) {
|
||||||
@@ -88,9 +88,17 @@ void by_frame_parse(uint8_t data_num, uint32_t *data_array)
|
|||||||
if (!cnt_crc) {
|
if (!cnt_crc) {
|
||||||
if (crc_cal == crc16_check(data_array_temp, 2 + data_num * sizeof(uint32_t))) {
|
if (crc_cal == crc16_check(data_array_temp, 2 + data_num * sizeof(uint32_t))) {
|
||||||
memcpy(data_array, data_array_temp + 2, data_num * sizeof(uint32_t));
|
memcpy(data_array, data_array_temp + 2, data_num * sizeof(uint32_t));
|
||||||
// lwrb_reset(&lwrb_struct); // 处理完直接清空缓冲区,避免堆积产生处理阻塞
|
|
||||||
memset(data_array_temp, 0, sizeof(data_array_temp));
|
memset(data_array_temp, 0, sizeof(data_array_temp));
|
||||||
// printf("parsed done!\r\n");
|
// printf("parsed done!\r\n");
|
||||||
|
for (uint8_t i = 0; i < data_num; i++) {
|
||||||
|
for (uint8_t j = 0; j < 4; j++) {
|
||||||
|
uart_write_byte(DEBUG_UART_INDEX, data_array[i] >> (j * 8));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
uart_write_byte(DEBUG_UART_INDEX, 0x00);
|
||||||
|
uart_write_byte(DEBUG_UART_INDEX, 0x00);
|
||||||
|
uart_write_byte(DEBUG_UART_INDEX, 0x80);
|
||||||
|
uart_write_byte(DEBUG_UART_INDEX, 0x7F);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|||||||
15
app/by_vofa.c
Normal file
15
app/by_vofa.c
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#include "by_vofa.h"
|
||||||
|
|
||||||
|
void by_vofa_init(by_vofa_t *vofa, uart_index_enum uart_index, uint8_t param_num, float *param_ptr)
|
||||||
|
{
|
||||||
|
vofa->uart_index = uart_index;
|
||||||
|
vofa->param_num = param_num;
|
||||||
|
vofa->param_ptr = param_ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void by_vofa_send(by_vofa_t *vofa)
|
||||||
|
{
|
||||||
|
const uint8_t tail[4] = {0x00, 0x00, 0x80, 0x7F};
|
||||||
|
uart_write_buffer(vofa->uart_index, (uint8_t *)vofa->param_ptr, vofa->param_num * 4);
|
||||||
|
uart_write_buffer(vofa->uart_index, tail, 4);
|
||||||
|
}
|
||||||
18
app/by_vofa.h
Normal file
18
app/by_vofa.h
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#ifndef _BY_VOFA_H__
|
||||||
|
#define _BY_VOFA_H__
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "zf_common_headfile.h"
|
||||||
|
|
||||||
|
typedef struct by_vofa_t {
|
||||||
|
uart_index_enum uart_index;
|
||||||
|
uint8_t param_num;
|
||||||
|
float *param_ptr;
|
||||||
|
} by_vofa_t;
|
||||||
|
|
||||||
|
void by_vofa_init(by_vofa_t *vofa, uart_index_enum uart_index, uint8_t param_num, float *param_ptr);
|
||||||
|
void by_vofa_send(by_vofa_t *vofa);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -72,7 +72,7 @@ void sport_motion(void)
|
|||||||
PID_Compute(&speed_pid);
|
PID_Compute(&speed_pid);
|
||||||
// in_speed = -encoder_get_count(TIM5_ENCOEDER); // 速度输入,m/s
|
// in_speed = -encoder_get_count(TIM5_ENCOEDER); // 速度输入,m/s
|
||||||
in_speed = sport_get_speed();
|
in_speed = sport_get_speed();
|
||||||
printf("rate:%d\r\n", (int16_t)in_speed);
|
// printf("rate:%d\r\n", (int16_t)in_speed);
|
||||||
PID_Compute(&near_pos_pid);
|
PID_Compute(&near_pos_pid);
|
||||||
cnt1 = 0;
|
cnt1 = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user