串口收数提示
This commit is contained in:
parent
a056dbcb8a
commit
1cb37c4dac
2
MDK-ARM/.vscode/keil-assistant.log
vendored
2
MDK-ARM/.vscode/keil-assistant.log
vendored
@ -100,3 +100,5 @@
|
||||
|
||||
[info] Log at : 2025/7/2|17:15:33|GMT+0800
|
||||
|
||||
[info] Log at : 2025/7/4|09:10:46|GMT+0800
|
||||
|
||||
|
3
MDK-ARM/.vscode/settings.json
vendored
3
MDK-ARM/.vscode/settings.json
vendored
@ -5,6 +5,7 @@
|
||||
"buzzer.h": "c",
|
||||
"calc_lib.h": "c",
|
||||
"usertask.h": "c",
|
||||
"detect.h": "c"
|
||||
"detect.h": "c",
|
||||
"nuc.h": "c"
|
||||
}
|
||||
}
|
9
MDK-ARM/.vscode/uv4.log
vendored
9
MDK-ARM/.vscode/uv4.log
vendored
@ -1,12 +1,13 @@
|
||||
*** Using Compiler 'V5.06 update 7 (build 960)', folder: 'D:\keil\ARM\ARMCC\Bin'
|
||||
Build target 'R1'
|
||||
compiling nuc.c...
|
||||
compiling shootTask.cpp...
|
||||
compiling nuc.c...
|
||||
compiling initTask.c...
|
||||
compiling ball.cpp...
|
||||
compiling ballTask.cpp...
|
||||
compiling nucTask.cpp...
|
||||
compiling shoot.cpp...
|
||||
linking...
|
||||
Program Size: Code=32916 RO-data=1832 RW-data=268 ZI-data=32220
|
||||
Program Size: Code=32960 RO-data=1832 RW-data=268 ZI-data=32220
|
||||
FromELF: creating hex file...
|
||||
"R1\R1.axf" - 0 Error(s), 0 Warning(s).
|
||||
Build Time Elapsed: 00:00:08
|
||||
Build Time Elapsed: 00:02:09
|
||||
|
2
MDK-ARM/.vscode/uv4.log.lock
vendored
2
MDK-ARM/.vscode/uv4.log.lock
vendored
@ -1 +1 @@
|
||||
2025/7/2 19:36:56
|
||||
2025/7/4 9:21:52
|
@ -180,6 +180,16 @@
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>cmd_fromnuc</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>5</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>drop_message,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>6</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>error_code,0x0A</ItemText>
|
||||
</Ww>
|
||||
</WatchWindow1>
|
||||
<MemoryWindow4>
|
||||
<Mm>
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
static osThreadId_t thread_alert;
|
||||
|
||||
static volatile uint32_t drop_message = 0;
|
||||
volatile uint32_t drop_message = 0;
|
||||
|
||||
uint8_t nucbuf[16];
|
||||
uint8_t packet[32]; // 假设最大数据包长度为 32 字节
|
||||
@ -13,10 +13,11 @@ static void NUC_CBLTCallback(void)
|
||||
{
|
||||
osThreadFlagsSet(thread_alert, SIGNAL_NUC_RAW_REDY);
|
||||
}
|
||||
uint32_t error_code;
|
||||
static void NUC_ERRORCALLBACK(void)
|
||||
{
|
||||
NUC_Restart();
|
||||
uint32_t error_code = HAL_UART_GetError(BSP_UART_GetHandle(BSP_UART_AI));
|
||||
NUC_Restart();
|
||||
error_code = HAL_UART_GetError(BSP_UART_GetHandle(BSP_UART_AI));
|
||||
|
||||
}
|
||||
|
||||
@ -80,7 +81,7 @@ int8_t NUC_SendPacket(void *data, uint16_t length) {
|
||||
|
||||
return DEVICE_OK; // 发送成功
|
||||
}
|
||||
int wzcsb=0;
|
||||
|
||||
int8_t NUC_RawParse(NUC_t *n) {
|
||||
if (n == NULL) return DEVICE_ERR_NULL;
|
||||
union {
|
||||
@ -98,12 +99,10 @@ int8_t NUC_RawParse(NUC_t *n) {
|
||||
case VISION:
|
||||
/* 协议格式
|
||||
0xFF HEAD
|
||||
0x09
|
||||
0x07
|
||||
控制帧
|
||||
0x01 相机帧
|
||||
x fp32
|
||||
y fp32
|
||||
z fp32
|
||||
0xFE TAIL
|
||||
*/
|
||||
if (nucbuf[7] != TAIL) goto error;
|
||||
@ -132,7 +131,7 @@ int8_t NUC_RawParse(NUC_t *n) {
|
||||
|
||||
|
||||
error:
|
||||
wzcsb++;
|
||||
drop_message++;
|
||||
return DEVICE_ERR;
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ extern "C" {
|
||||
#include "struct_typedef.h"
|
||||
#include "device.h"
|
||||
#include "uart_it.h"
|
||||
#include "main.h"
|
||||
|
||||
// 帧头针尾
|
||||
#define HEAD (0xFF)
|
||||
@ -15,7 +16,7 @@ extern "C" {
|
||||
|
||||
#define ODOM (0x04)
|
||||
#define PICK (0x06)
|
||||
#define VISION (0x09)
|
||||
#define VISION (0x07)
|
||||
#define SEND (0X07)
|
||||
|
||||
// 写结构体存入视觉信息
|
||||
|
@ -1,10 +1,11 @@
|
||||
#include "nucTask.hpp"
|
||||
#include "nuc.h"
|
||||
#include "userTask.h"
|
||||
#include "TopDefine.h"//事件组的一些东西
|
||||
#include "TopDefine.h" //事件组的一些东西
|
||||
#include "FreeRTOS.h"
|
||||
#include <cmsis_os2.h>
|
||||
#include <stdio.h>
|
||||
#include "bsp_buzzer.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
@ -14,50 +15,53 @@ NUC_t cmd_fromnuc;
|
||||
|
||||
void Function_nuc(void *argument)
|
||||
{
|
||||
(void)argument; /* 未使用argument,消除警告 */
|
||||
|
||||
const uint32_t delay_tick = osKernelGetTickFreq() / TASK_FREQ_AI;
|
||||
(void)argument; /* 未使用argument,消除警告 */
|
||||
|
||||
NUC_Init(&cmd_fromnuc);
|
||||
|
||||
HAL_GPIO_WritePin(LED_G_GPIO_Port,LED_G_Pin,GPIO_PIN_SET);
|
||||
const uint32_t delay_tick = osKernelGetTickFreq() / TASK_FREQ_AI;
|
||||
|
||||
uint32_t tick = osKernelGetTickCount();
|
||||
NUC_Init(&cmd_fromnuc);
|
||||
|
||||
while(1)
|
||||
{
|
||||
uint32_t tick = osKernelGetTickCount();
|
||||
|
||||
while (1)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
task_struct.stack_water_mark.nuc = osThreadGetStackSpace(osThreadGetId());
|
||||
#endif
|
||||
task_struct.stack_water_mark.nuc = osThreadGetStackSpace(osThreadGetId());
|
||||
#endif
|
||||
NUC_StartReceiving();
|
||||
|
||||
//NUC_RawParse(&cmd_fromnuc);
|
||||
//NUC_SendPacket(&send, sizeof(send)); // 发送数据包
|
||||
//掉线处理有空写
|
||||
// if(NUC_WaitDmaCplt())
|
||||
// {
|
||||
// NUC_RawParse(&cmd_fromnuc);
|
||||
|
||||
// NUC_RawParse(&cmd_fromnuc);
|
||||
// NUC_SendPacket(&send, sizeof(send)); // 发送数据包
|
||||
// 掉线处理有空写
|
||||
// if(NUC_WaitDmaCplt())
|
||||
// {
|
||||
// NUC_RawParse(&cmd_fromnuc);
|
||||
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// NUC_HandleOffline(&cmd_fromnuc);
|
||||
// }
|
||||
|
||||
// 假设你在主循环或任务里这样用
|
||||
if (NUC_RawParse(&cmd_fromnuc) == DEVICE_OK)
|
||||
{
|
||||
osMessageQueueReset(task_struct.msgq.nuc); // 清空消息队列
|
||||
osMessageQueuePut(task_struct.msgq.nuc,&(cmd_fromnuc),0,0);
|
||||
//BSP_Buzzer_Stop();
|
||||
HAL_GPIO_WritePin(LED_G_GPIO_Port, LED_G_Pin, GPIO_PIN_SET);
|
||||
HAL_GPIO_WritePin(LED_R_GPIO_Port, LED_R_Pin, GPIO_PIN_RESET);
|
||||
osMessageQueueReset(task_struct.msgq.nuc); // 清空消息队列
|
||||
osMessageQueuePut(task_struct.msgq.nuc, &(cmd_fromnuc), 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
NUC_HandleOffline(&cmd_fromnuc);
|
||||
}
|
||||
osDelay(2);
|
||||
|
||||
tick += delay_tick; /* 计算下一个唤醒时刄1ķ*/
|
||||
osDelayUntil(tick);
|
||||
|
||||
}
|
||||
// BSP_Buzzer_Start();
|
||||
// BSP_Buzzer_Set(1, 5000);
|
||||
HAL_GPIO_WritePin(LED_G_GPIO_Port, LED_G_Pin, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(LED_R_GPIO_Port, LED_R_Pin, GPIO_PIN_SET);
|
||||
NUC_HandleOffline(&cmd_fromnuc);
|
||||
}
|
||||
|
||||
tick += delay_tick; /* 计算下一个唤醒时刄1ķ*/
|
||||
osDelayUntil(tick);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user