串口收数提示
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/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",
|
"buzzer.h": "c",
|
||||||
"calc_lib.h": "c",
|
"calc_lib.h": "c",
|
||||||
"usertask.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'
|
*** Using Compiler 'V5.06 update 7 (build 960)', folder: 'D:\keil\ARM\ARMCC\Bin'
|
||||||
Build target 'R1'
|
Build target 'R1'
|
||||||
compiling nuc.c...
|
|
||||||
compiling shootTask.cpp...
|
compiling shootTask.cpp...
|
||||||
|
compiling nuc.c...
|
||||||
|
compiling initTask.c...
|
||||||
compiling ball.cpp...
|
compiling ball.cpp...
|
||||||
compiling ballTask.cpp...
|
compiling nucTask.cpp...
|
||||||
compiling shoot.cpp...
|
compiling shoot.cpp...
|
||||||
linking...
|
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...
|
FromELF: creating hex file...
|
||||||
"R1\R1.axf" - 0 Error(s), 0 Warning(s).
|
"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>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>cmd_fromnuc</ItemText>
|
<ItemText>cmd_fromnuc</ItemText>
|
||||||
</Ww>
|
</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>
|
</WatchWindow1>
|
||||||
<MemoryWindow4>
|
<MemoryWindow4>
|
||||||
<Mm>
|
<Mm>
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
static osThreadId_t thread_alert;
|
static osThreadId_t thread_alert;
|
||||||
|
|
||||||
static volatile uint32_t drop_message = 0;
|
volatile uint32_t drop_message = 0;
|
||||||
|
|
||||||
uint8_t nucbuf[16];
|
uint8_t nucbuf[16];
|
||||||
uint8_t packet[32]; // 假设最大数据包长度为 32 字节
|
uint8_t packet[32]; // 假设最大数据包长度为 32 字节
|
||||||
@ -13,10 +13,11 @@ static void NUC_CBLTCallback(void)
|
|||||||
{
|
{
|
||||||
osThreadFlagsSet(thread_alert, SIGNAL_NUC_RAW_REDY);
|
osThreadFlagsSet(thread_alert, SIGNAL_NUC_RAW_REDY);
|
||||||
}
|
}
|
||||||
|
uint32_t error_code;
|
||||||
static void NUC_ERRORCALLBACK(void)
|
static void NUC_ERRORCALLBACK(void)
|
||||||
{
|
{
|
||||||
NUC_Restart();
|
NUC_Restart();
|
||||||
uint32_t error_code = HAL_UART_GetError(BSP_UART_GetHandle(BSP_UART_AI));
|
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; // 发送成功
|
return DEVICE_OK; // 发送成功
|
||||||
}
|
}
|
||||||
int wzcsb=0;
|
|
||||||
int8_t NUC_RawParse(NUC_t *n) {
|
int8_t NUC_RawParse(NUC_t *n) {
|
||||||
if (n == NULL) return DEVICE_ERR_NULL;
|
if (n == NULL) return DEVICE_ERR_NULL;
|
||||||
union {
|
union {
|
||||||
@ -98,12 +99,10 @@ int8_t NUC_RawParse(NUC_t *n) {
|
|||||||
case VISION:
|
case VISION:
|
||||||
/* 协议格式
|
/* 协议格式
|
||||||
0xFF HEAD
|
0xFF HEAD
|
||||||
0x09
|
0x07
|
||||||
控制帧
|
控制帧
|
||||||
0x01 相机帧
|
0x01 相机帧
|
||||||
x fp32
|
x fp32
|
||||||
y fp32
|
|
||||||
z fp32
|
|
||||||
0xFE TAIL
|
0xFE TAIL
|
||||||
*/
|
*/
|
||||||
if (nucbuf[7] != TAIL) goto error;
|
if (nucbuf[7] != TAIL) goto error;
|
||||||
@ -132,7 +131,7 @@ int8_t NUC_RawParse(NUC_t *n) {
|
|||||||
|
|
||||||
|
|
||||||
error:
|
error:
|
||||||
wzcsb++;
|
drop_message++;
|
||||||
return DEVICE_ERR;
|
return DEVICE_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ extern "C" {
|
|||||||
#include "struct_typedef.h"
|
#include "struct_typedef.h"
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
#include "uart_it.h"
|
#include "uart_it.h"
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
// 帧头针尾
|
// 帧头针尾
|
||||||
#define HEAD (0xFF)
|
#define HEAD (0xFF)
|
||||||
@ -15,7 +16,7 @@ extern "C" {
|
|||||||
|
|
||||||
#define ODOM (0x04)
|
#define ODOM (0x04)
|
||||||
#define PICK (0x06)
|
#define PICK (0x06)
|
||||||
#define VISION (0x09)
|
#define VISION (0x07)
|
||||||
#define SEND (0X07)
|
#define SEND (0X07)
|
||||||
|
|
||||||
// 写结构体存入视觉信息
|
// 写结构体存入视觉信息
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
#include "nucTask.hpp"
|
#include "nucTask.hpp"
|
||||||
#include "nuc.h"
|
#include "nuc.h"
|
||||||
#include "userTask.h"
|
#include "userTask.h"
|
||||||
#include "TopDefine.h"//事件组的一些东西
|
#include "TopDefine.h" //事件组的一些东西
|
||||||
#include "FreeRTOS.h"
|
#include "FreeRTOS.h"
|
||||||
#include <cmsis_os2.h>
|
#include <cmsis_os2.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include "bsp_buzzer.h"
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|
||||||
@ -20,20 +21,18 @@ void Function_nuc(void *argument)
|
|||||||
|
|
||||||
NUC_Init(&cmd_fromnuc);
|
NUC_Init(&cmd_fromnuc);
|
||||||
|
|
||||||
HAL_GPIO_WritePin(LED_G_GPIO_Port,LED_G_Pin,GPIO_PIN_SET);
|
|
||||||
|
|
||||||
uint32_t tick = osKernelGetTickCount();
|
uint32_t tick = osKernelGetTickCount();
|
||||||
|
|
||||||
while(1)
|
while (1)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
task_struct.stack_water_mark.nuc = osThreadGetStackSpace(osThreadGetId());
|
task_struct.stack_water_mark.nuc = osThreadGetStackSpace(osThreadGetId());
|
||||||
#endif
|
#endif
|
||||||
NUC_StartReceiving();
|
NUC_StartReceiving();
|
||||||
|
|
||||||
//NUC_RawParse(&cmd_fromnuc);
|
// NUC_RawParse(&cmd_fromnuc);
|
||||||
//NUC_SendPacket(&send, sizeof(send)); // 发送数据包
|
// NUC_SendPacket(&send, sizeof(send)); // 发送数据包
|
||||||
//掉线处理有空写
|
// 掉线处理有空写
|
||||||
// if(NUC_WaitDmaCplt())
|
// if(NUC_WaitDmaCplt())
|
||||||
// {
|
// {
|
||||||
// NUC_RawParse(&cmd_fromnuc);
|
// NUC_RawParse(&cmd_fromnuc);
|
||||||
@ -44,20 +43,25 @@ void Function_nuc(void *argument)
|
|||||||
// NUC_HandleOffline(&cmd_fromnuc);
|
// NUC_HandleOffline(&cmd_fromnuc);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// 假设你在主循环或任务里这样用
|
|
||||||
if (NUC_RawParse(&cmd_fromnuc) == DEVICE_OK)
|
if (NUC_RawParse(&cmd_fromnuc) == DEVICE_OK)
|
||||||
{
|
{
|
||||||
|
//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); // 清空消息队列
|
osMessageQueueReset(task_struct.msgq.nuc); // 清空消息队列
|
||||||
osMessageQueuePut(task_struct.msgq.nuc,&(cmd_fromnuc),0,0);
|
osMessageQueuePut(task_struct.msgq.nuc, &(cmd_fromnuc), 0, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// 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);
|
NUC_HandleOffline(&cmd_fromnuc);
|
||||||
}
|
}
|
||||||
osDelay(2);
|
|
||||||
|
|
||||||
tick += delay_tick; /* 计算下一个唤醒时刄1ķ*/
|
tick += delay_tick; /* 计算下一个唤醒时刄1ķ*/
|
||||||
osDelayUntil(tick);
|
osDelayUntil(tick);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user