From 57a3838e385427ac3549f36a6eea12edc76e3dfb Mon Sep 17 00:00:00 2001
From: ws <1621320660@qq.com>
Date: Tue, 1 Jul 2025 14:55:11 +0800
Subject: [PATCH 1/4] =?UTF-8?q?=E5=B0=8F=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
MDK-ARM/.vscode/keil-assistant.log | 2 +
MDK-ARM/.vscode/uv4.log | 72 ++--------------------------
MDK-ARM/.vscode/uv4.log.lock | 2 +-
User/module/ball.cpp | 1 +
User/module/shoot.cpp | 75 +++---------------------------
User/module/shoot.hpp | 2 +
6 files changed, 16 insertions(+), 138 deletions(-)
diff --git a/MDK-ARM/.vscode/keil-assistant.log b/MDK-ARM/.vscode/keil-assistant.log
index 67e4303..3f8afd7 100644
--- a/MDK-ARM/.vscode/keil-assistant.log
+++ b/MDK-ARM/.vscode/keil-assistant.log
@@ -94,3 +94,5 @@
[info] Log at : 2025/6/30|10:24:59|GMT+0800
+[info] Log at : 2025/7/1|10:57:51|GMT+0800
+
diff --git a/MDK-ARM/.vscode/uv4.log b/MDK-ARM/.vscode/uv4.log
index 8ed7e1c..fc45d57 100644
--- a/MDK-ARM/.vscode/uv4.log
+++ b/MDK-ARM/.vscode/uv4.log
@@ -1,76 +1,10 @@
*** Using Compiler 'V5.06 update 7 (build 960)', folder: 'D:\keil\ARM\ARMCC\Bin'
-Rebuild target 'R1'
-assembling startup_stm32f407xx.s...
-compiling dma.c...
-compiling spi.c...
-compiling gpio.c...
-compiling stm32f4xx_hal_msp.c...
-compiling tim.c...
-compiling stm32f4xx_it.c...
-compiling stm32f4xx_hal_rcc.c...
-compiling freertos.c...
-compiling main.c...
-compiling usart.c...
-compiling stm32f4xx_hal_can.c...
-compiling crc.c...
-compiling can.c...
-compiling stm32f4xx_hal_gpio.c...
-compiling stm32f4xx_hal_flash_ramfunc.c...
-compiling stm32f4xx_hal_flash_ex.c...
-compiling stm32f4xx_hal_flash.c...
-compiling stm32f4xx_hal_rcc_ex.c...
-compiling stm32f4xx_hal_cortex.c...
-compiling stm32f4xx_hal_pwr_ex.c...
-compiling stm32f4xx_hal_dma.c...
-compiling stm32f4xx_hal_crc.c...
-compiling stm32f4xx_hal.c...
-compiling stm32f4xx_hal_pwr.c...
-compiling croutine.c...
-compiling stm32f4xx_hal_exti.c...
-compiling event_groups.c...
-compiling list.c...
-compiling stm32f4xx_hal_dma_ex.c...
-compiling queue.c...
-compiling stream_buffer.c...
-compiling timers.c...
-compiling tasks.c...
-compiling heap_4.c...
-compiling system_stm32f4xx.c...
-compiling port.c...
-compiling stm32f4xx_hal_spi.c...
-compiling stm32f4xx_hal_uart.c...
-compiling stm32f4xx_hal_tim_ex.c...
-compiling stm32f4xx_hal_tim.c...
-compiling calc_lib.c...
-compiling crc_ccitt.c...
-compiling kalman.c...
-compiling cmsis_os2.c...
-compiling bsp_buzzer.c...
-compiling bsp_delay.c...
-compiling can_init.c...
-compiling can_it.c...
-compiling gpio_it.c...
-compiling uart_it.c...
-compiling filter.c...
-compiling pid.c...
-compiling user_math.c...
-compiling buzzer.c...
-compiling userTask.c...
-compiling detect.c...
+Build target 'R1'
compiling shoot.cpp...
-compiling vofa.c...
-compiling remote_control.c...
-compiling djiMotor.c...
-compiling GO_M8010_6_Driver.c...
-compiling nuc.c...
compiling ball.cpp...
-compiling initTask.c...
-compiling ballTask.cpp...
-compiling encodeCan.cpp...
-compiling nucTask.cpp...
compiling shootTask.cpp...
linking...
-Program Size: Code=32916 RO-data=1832 RW-data=276 ZI-data=32220
+Program Size: Code=32968 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:04:01
+Build Time Elapsed: 00:00:06
diff --git a/MDK-ARM/.vscode/uv4.log.lock b/MDK-ARM/.vscode/uv4.log.lock
index 4fb6d15..76228fa 100644
--- a/MDK-ARM/.vscode/uv4.log.lock
+++ b/MDK-ARM/.vscode/uv4.log.lock
@@ -1 +1 @@
-2025/6/30 14:27:15
\ No newline at end of file
+2025/7/1 14:54:30
\ No newline at end of file
diff --git a/User/module/ball.cpp b/User/module/ball.cpp
index 3911d37..af89813 100644
--- a/User/module/ball.cpp
+++ b/User/module/ball.cpp
@@ -283,6 +283,7 @@ void Ball::ballDown(void)
break;
case EXTEND_FINISH:
+ HAL_GPIO_WritePin(CLOSE_GPIO_Port, CLOSE_Pin, GPIO_PIN_RESET);
xiaomi.position = O_ANGLE; // 一直保持伸出
// 等待拨杆复位(如切到MIDDLE2),Idle_control会负责回位
break;
diff --git a/User/module/shoot.cpp b/User/module/shoot.cpp
index 36474ea..a3680bc 100644
--- a/User/module/shoot.cpp
+++ b/User/module/shoot.cpp
@@ -148,71 +148,6 @@ int Shoot::GO_SendData(float pos, float limit)
// B键 sw[3]👆 200 开 中 1000 👇1800 关
// sw[5] 👆 200 👇1800
// 左旋 sw[7] 200 --1800
-// void Shoot::rc_mode()
-// {
-// if (rc_ctrl.sw[1] == 200)
-// {
-// rc_key = UP1;
-// }
-// if (rc_ctrl.sw[1] == 1800 && rc_ctrl.sw[2] == 200)
-// {
-// rc_key = MIDDLE1;
-// }
-// if (rc_ctrl.sw[2] == 1800 && rc_ctrl.sw[1] == 1800)
-// {
-// rc_key = DOWN1;
-// }
-// if (rc_ctrl.sw[0] == 1800)
-// {
-// mode_key = PASS;
-// }
-// if (rc_ctrl.sw[0] == 200)
-// {
-// mode_key = VSION;
-// }
-// // if(rc_ctrl.sw[5]==200)
-// // {
-// // mode_key=OUT;
-// // }
-// if (rc_ctrl.sw[5] == 1800)
-// {
-// ready_key = OFFENSIVE;
-// }
-// else if (rc_ctrl.sw[5] == 200)
-// {
-// ready_key = DEFENSE;
-// }
-
-// // //旋钮增量
-// // static int last_knob_value = 0; // 记录旋钮的上一次值
-// // int current_knob_value = rc_ctrl.sw[7]; // 获取当前旋钮值
-
-// // // 计算旋钮增量
-// // if (current_knob_value >= 200 && current_knob_value <= 1800) {
-// // knob_increment = (current_knob_value - last_knob_value) / 15.0f; // 每80单位对应一个增量
-// // } else {
-// // knob_increment = 0; // 如果旋钮值超出范围,不产生增量
-// // }
-
-// // 旋钮物理范围
-// const int knob_min = 200;
-// const int knob_max = 1800;
-
-// // 目标映射范围
-// const float map_min = 130.0f;
-// const float map_max = -60.0f;
-
-// int current_knob_value = rc_ctrl.sw[7];
-
-// // 限制范围
-// if (current_knob_value < knob_min)
-// current_knob_value = knob_min;
-// if (current_knob_value > knob_max)
-// current_knob_value = knob_max;
-
-// // 线性映射
-// knob_increment = map_min + (map_max - map_min) * (current_knob_value - knob_min) / (knob_max - knob_min);
-// }
void Shoot::rc_mode()
{
@@ -226,12 +161,14 @@ void Shoot::rc_mode()
if (bottom_sensor == 0)
{
is_ready = true;
+ BSP_Buzzer_Stop();
- // 可选:蜂鸣器提示“归零成功”
+
}
else
{
- // 未到位,所有按键无效,直接返回
+ BSP_Buzzer_Start();
+ BSP_Buzzer_Set(1, 5000);
return;
}
}
@@ -455,7 +392,7 @@ void Shoot::RemoveError()
#if ONE_CONTROL
-int shoot_wait = 0;
+
void Shoot::shoot_control()
{
@@ -503,6 +440,7 @@ void Shoot::shoot_control()
BSP_Buzzer_Stop();
currentState = SHOOT_IDLE;
osThreadFlagsClear(EXTEND_OK);
+ osThreadFlagsClear(READY_TELL); //蓄力标志位
shoot_wait = 0;
}
}
@@ -557,6 +495,7 @@ void Shoot::shoot_control()
BSP_Buzzer_Stop();
currentState = SHOOT_IDLE;
osThreadFlagsClear(EXTEND_OK);
+ osThreadFlagsClear(READY_TELL); //蓄力标志位
shoot_wait = 0;
}
}
diff --git a/User/module/shoot.hpp b/User/module/shoot.hpp
index a008caf..54d1f7d 100644
--- a/User/module/shoot.hpp
+++ b/User/module/shoot.hpp
@@ -112,6 +112,8 @@ private:
float limit_speed;//go电机限速
+ int shoot_wait;
+
};
From b022b46730b38536f07ff4445647889599eb9c4e Mon Sep 17 00:00:00 2001
From: ws <1621320660@qq.com>
Date: Wed, 2 Jul 2025 17:48:50 +0800
Subject: [PATCH 2/4] =?UTF-8?q?=E4=B8=8D=E7=94=A8=E7=A9=BA=E9=97=B2?=
=?UTF-8?q?=E4=B8=AD=E6=96=AD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
MDK-ARM/.vscode/keil-assistant.log | 4 +++
MDK-ARM/.vscode/uv4.log | 6 ++--
MDK-ARM/.vscode/uv4.log.lock | 2 +-
MDK-ARM/R1.uvoptx | 50 ++++++++++++++++--------------
User/device/nuc.c | 18 ++---------
User/module/ball.cpp | 1 +
User/module/shoot.cpp | 13 +++-----
User/task/ballTask.cpp | 7 ++---
8 files changed, 43 insertions(+), 58 deletions(-)
diff --git a/MDK-ARM/.vscode/keil-assistant.log b/MDK-ARM/.vscode/keil-assistant.log
index 3f8afd7..646e173 100644
--- a/MDK-ARM/.vscode/keil-assistant.log
+++ b/MDK-ARM/.vscode/keil-assistant.log
@@ -96,3 +96,7 @@
[info] Log at : 2025/7/1|10:57:51|GMT+0800
+[info] Log at : 2025/7/2|02:59:15|GMT+0800
+
+[info] Log at : 2025/7/2|17:15:33|GMT+0800
+
diff --git a/MDK-ARM/.vscode/uv4.log b/MDK-ARM/.vscode/uv4.log
index fc45d57..f5e09e6 100644
--- a/MDK-ARM/.vscode/uv4.log
+++ b/MDK-ARM/.vscode/uv4.log
@@ -1,10 +1,8 @@
*** Using Compiler 'V5.06 update 7 (build 960)', folder: 'D:\keil\ARM\ARMCC\Bin'
Build target 'R1'
-compiling shoot.cpp...
compiling ball.cpp...
-compiling shootTask.cpp...
linking...
-Program Size: Code=32968 RO-data=1832 RW-data=268 ZI-data=32220
+Program Size: Code=32904 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:06
+Build Time Elapsed: 00:00:05
diff --git a/MDK-ARM/.vscode/uv4.log.lock b/MDK-ARM/.vscode/uv4.log.lock
index 76228fa..287f658 100644
--- a/MDK-ARM/.vscode/uv4.log.lock
+++ b/MDK-ARM/.vscode/uv4.log.lock
@@ -1 +1 @@
-2025/7/1 14:54:30
\ No newline at end of file
+2025/7/2 14:06:43
\ No newline at end of file
diff --git a/MDK-ARM/R1.uvoptx b/MDK-ARM/R1.uvoptx
index 53306b8..4f9d677 100644
--- a/MDK-ARM/R1.uvoptx
+++ b/MDK-ARM/R1.uvoptx
@@ -153,47 +153,49 @@
-U00160029510000164E574E32 -O2254 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(2BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC800 -FN1 -FF0STM32F4xx_1024.FLM -FS08000000 -FL0100000 -FP0($$Device:STM32F407IGHx$CMSIS\Flash\STM32F4xx_1024.FLM)
-
+
+
+ 0
+ 0
+ 94
+ 1
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ ../Core/Src/main.c
+
+
+
+
0
1
- shoot,0x0A
+ rc_ctrl,0x0A
1
1
- nucData,0x0A
+ shoot,0x0A
2
1
- nucbuf
+ ball,0x0A
3
1
- wzcsb,0x0A
+ nucbuf
4
1
- nuc_v
-
-
- 5
- 1
- abc,0x0A
-
-
- 6
- 1
- shoot_wait,0x0A
-
-
- 7
- 1
- error_code
+ cmd_fromnuc
@@ -962,7 +964,7 @@
User/device
- 1
+ 0
0
0
0
@@ -1054,7 +1056,7 @@
User/module
- 0
+ 1
0
0
0
@@ -1086,7 +1088,7 @@
User/task
- 0
+ 1
0
0
0
diff --git a/User/device/nuc.c b/User/device/nuc.c
index 1fbcaaa..130b3ac 100644
--- a/User/device/nuc.c
+++ b/User/device/nuc.c
@@ -33,22 +33,8 @@ int8_t NUC_Init(NUC_t *nuc)
return DEVICE_OK;
}
-// static void NUC_IdleCallback(void) {
-// osThreadFlagsSet(thread_alert,SIGNAL_NUC_RAW_REDY);
-
-// }
-
-// int8_t NUC_Init(NUC_t *nuc){
-// if(nuc == NULL) return DEVICE_ERR_NULL;
-// if((thread_alert = osThreadGetId()) == NULL ) return DEVICE_ERR_NULL;
-// BSP_UART_RegisterCallback(BSP_UART_AI,BSP_UART_IDLE_LINE_CB,
-// NUC_IdleCallback);
-
-// return DEVICE_OK;
-// }
-
int8_t NUC_StartReceiving(void) {
- if (HAL_UARTEx_ReceiveToIdle_DMA(BSP_UART_GetHandle(BSP_UART_AI),
+ if (HAL_UART_Receive_DMA(BSP_UART_GetHandle(BSP_UART_AI),
(uint8_t *)nucbuf,
sizeof(nucbuf)) == HAL_OK)
return DEVICE_OK;
@@ -63,7 +49,7 @@ int8_t NUC_Restart(void) {
bool_t NUC_WaitDmaCplt(void) {
- return (osThreadFlagsWait(SIGNAL_NUC_RAW_REDY, osFlagsWaitAll,500) ==
+ return (osThreadFlagsWait(SIGNAL_NUC_RAW_REDY, osFlagsWaitAll,20) ==
SIGNAL_NUC_RAW_REDY);
}
diff --git a/User/module/ball.cpp b/User/module/ball.cpp
index af89813..411937d 100644
--- a/User/module/ball.cpp
+++ b/User/module/ball.cpp
@@ -356,6 +356,7 @@ void Ball::ballHadling(void)
break;
case BALL_FORWARD:
+ osDelay(300); // 不放太快
HAL_GPIO_WritePin(CLOSE_GPIO_Port, CLOSE_Pin, GPIO_PIN_SET); // 打开气缸爪子
osDelay(5);
HAL_GPIO_WritePin(DOWN_GPIO_Port, DOWN_Pin, GPIO_PIN_SET); // 打开下气缸
diff --git a/User/module/shoot.cpp b/User/module/shoot.cpp
index a3680bc..62765dd 100644
--- a/User/module/shoot.cpp
+++ b/User/module/shoot.cpp
@@ -58,7 +58,7 @@ Shoot::Shoot()
go1.K_P = 1.0f,
go1.K_W = 0.05,
go1.Pos = 0, // 上电先到一个舒服的位置
- go1.W = 0,
+ go1.W = 0,
go1.T = 0,
limit_speed = TO_TOP; // 快速上去
@@ -162,8 +162,6 @@ void Shoot::rc_mode()
{
is_ready = true;
BSP_Buzzer_Stop();
-
-
}
else
{
@@ -392,7 +390,6 @@ void Shoot::RemoveError()
#if ONE_CONTROL
-
void Shoot::shoot_control()
{
@@ -436,11 +433,11 @@ void Shoot::shoot_control()
t_posSet = Tigger_ZERO;
if (feedback.fd_tpos >= Tigger_ZERO - 20)
{
-
+
BSP_Buzzer_Stop();
currentState = SHOOT_IDLE;
osThreadFlagsClear(EXTEND_OK);
- osThreadFlagsClear(READY_TELL); //蓄力标志位
+ osThreadFlagsClear(READY_TELL); // 蓄力标志位
shoot_wait = 0;
}
}
@@ -484,7 +481,7 @@ void Shoot::shoot_control()
break;
case DOWN1:
- if (shoot_thread & EXTEND_OK )
+ if (shoot_thread & EXTEND_OK)
{
if (shoot_wait == 1)
{
@@ -495,7 +492,7 @@ void Shoot::shoot_control()
BSP_Buzzer_Stop();
currentState = SHOOT_IDLE;
osThreadFlagsClear(EXTEND_OK);
- osThreadFlagsClear(READY_TELL); //蓄力标志位
+ osThreadFlagsClear(READY_TELL); // 蓄力标志位
shoot_wait = 0;
}
}
diff --git a/User/task/ballTask.cpp b/User/task/ballTask.cpp
index 168d0c1..6408282 100644
--- a/User/task/ballTask.cpp
+++ b/User/task/ballTask.cpp
@@ -22,7 +22,7 @@ void FunctionBall(void *argument)
const uint32_t delay_tick = osKernelGetTickFreq() / TASK_FREQ_BALL;
- osDelay(6000);//等待极致控制板启动
+ osDelay(6000);//等待极致控制板启动
XiaomiWait_init(1,&hcan2); //小米电机初始化
uint32_t tick = osKernelGetTickCount();
@@ -34,15 +34,12 @@ void FunctionBall(void *argument)
#endif
//abc=HAL_GPIO_ReadPin(up_ball_GPIO_Port, up_ball_Pin);
- abc=HAL_GPIO_ReadPin(BALL_GPIO_Port, BALL_Pin); // 0为到位
+ abc=HAL_GPIO_ReadPin(BALL_GPIO_Port, BALL_Pin); // 0为到位
ball.rc_mode(); // 遥控器模式
ball.ball_control(); // 控制球的动作
-// HAL_GPIO_WritePin(CLOSE_GPIO_Port, CLOSE_Pin, GPIO_PIN_SET); // 确保气缸爪子闭合
-// HAL_GPIO_WritePin(DOWN_GPIO_Port, DOWN_Pin, GPIO_PIN_SET); // 确保下气缸关闭
-
// ball.xiaomi.position = aaaa;
// CAN_XiaoMi(1,&ball.xiaomi,&hcan2);
From a056dbcb8aace3071fdd1c6e66de451a5a7208fb Mon Sep 17 00:00:00 2001
From: ws <1621320660@qq.com>
Date: Wed, 2 Jul 2025 19:47:00 +0800
Subject: [PATCH 3/4] =?UTF-8?q?=E7=A3=81=E7=8E=AF=E6=9D=BE=E4=BA=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
MDK-ARM/.vscode/uv4.log | 8 ++++++--
MDK-ARM/.vscode/uv4.log.lock | 2 +-
MDK-ARM/R1.uvoptx | 19 +------------------
User/module/ball.cpp | 19 ++++++++++++-------
User/module/ball.hpp | 3 ++-
5 files changed, 22 insertions(+), 29 deletions(-)
diff --git a/MDK-ARM/.vscode/uv4.log b/MDK-ARM/.vscode/uv4.log
index f5e09e6..e27e2d8 100644
--- a/MDK-ARM/.vscode/uv4.log
+++ b/MDK-ARM/.vscode/uv4.log
@@ -1,8 +1,12 @@
*** Using Compiler 'V5.06 update 7 (build 960)', folder: 'D:\keil\ARM\ARMCC\Bin'
Build target 'R1'
+compiling nuc.c...
+compiling shootTask.cpp...
compiling ball.cpp...
+compiling ballTask.cpp...
+compiling shoot.cpp...
linking...
-Program Size: Code=32904 RO-data=1832 RW-data=268 ZI-data=32220
+Program Size: Code=32916 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:05
+Build Time Elapsed: 00:00:08
diff --git a/MDK-ARM/.vscode/uv4.log.lock b/MDK-ARM/.vscode/uv4.log.lock
index 287f658..c647268 100644
--- a/MDK-ARM/.vscode/uv4.log.lock
+++ b/MDK-ARM/.vscode/uv4.log.lock
@@ -1 +1 @@
-2025/7/2 14:06:43
\ No newline at end of file
+2025/7/2 19:36:56
\ No newline at end of file
diff --git a/MDK-ARM/R1.uvoptx b/MDK-ARM/R1.uvoptx
index 4f9d677..73eea2c 100644
--- a/MDK-ARM/R1.uvoptx
+++ b/MDK-ARM/R1.uvoptx
@@ -153,24 +153,7 @@
-U00160029510000164E574E32 -O2254 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(2BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC800 -FN1 -FF0STM32F4xx_1024.FLM -FS08000000 -FL0100000 -FP0($$Device:STM32F407IGHx$CMSIS\Flash\STM32F4xx_1024.FLM)
-
-
- 0
- 0
- 94
- 1
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- ../Core/Src/main.c
-
-
-
-
+
0
diff --git a/User/module/ball.cpp b/User/module/ball.cpp
index 411937d..9136a96 100644
--- a/User/module/ball.cpp
+++ b/User/module/ball.cpp
@@ -10,9 +10,12 @@ extern RC_ctrl_t rc_ctrl;
extern int ball_exit;
// 伸缩
-#define I_ANGLE 147
-#define O_ANGLE 187
-#define WAIT_POS 170
+//外死点168 外163 中150 内127 限位124.8
+#define I_ANGLE 127
+#define O_ANGLE 163
+#define WAIT_POS 150
+#define IN 124.8
+#define OUT 168
// PE11 气缸
@@ -75,7 +78,7 @@ void Ball::rc_mode()
}
if (rc_ctrl.sw[5] == 200)
{
- ready_key = 0; // 默认不准备
+ ready_key = DEF; // 默认不准备
}
}
@@ -234,17 +237,19 @@ void Ball::ball_control()
ballHadling();
break;
}
+
+ Send_control();
}
// 防守
- else
+ else if(ready_key == DEF)
{
xiaomi.position = I_ANGLE; // 保持收回
HAL_GPIO_WritePin(CLOSE_GPIO_Port, CLOSE_Pin, GPIO_PIN_RESET); // 确保爪气缸关闭
HAL_GPIO_WritePin(DOWN_GPIO_Port, DOWN_Pin, GPIO_PIN_RESET); // 确保下气缸关闭
+
+ Send_control();
}
- // 发送小米电机控制数据
- Send_control();
}
// 任务通知来作全过程
diff --git a/User/module/ball.hpp b/User/module/ball.hpp
index f92b606..8595c5f 100644
--- a/User/module/ball.hpp
+++ b/User/module/ball.hpp
@@ -39,7 +39,8 @@ typedef enum
DOWN2,
IN,
OUT,
- SIDE
+ SIDE,
+ DEF
}ball_rc_mode;
// 定义光电传感器检测宏
From 1cb37c4daca10a167dc62cd6d5d205050d7af545 Mon Sep 17 00:00:00 2001
From: ws <1621320660@qq.com>
Date: Fri, 4 Jul 2025 13:18:57 +0800
Subject: [PATCH 4/4] =?UTF-8?q?=E4=B8=B2=E5=8F=A3=E6=94=B6=E6=95=B0?=
=?UTF-8?q?=E6=8F=90=E7=A4=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
MDK-ARM/.vscode/keil-assistant.log | 2 +
MDK-ARM/.vscode/settings.json | 3 +-
MDK-ARM/.vscode/uv4.log | 9 +++--
MDK-ARM/.vscode/uv4.log.lock | 2 +-
MDK-ARM/R1.uvoptx | 10 +++++
User/device/nuc.c | 15 ++++----
User/device/nuc.h | 3 +-
User/task/nucTask.cpp | 62 ++++++++++++++++--------------
8 files changed, 62 insertions(+), 44 deletions(-)
diff --git a/MDK-ARM/.vscode/keil-assistant.log b/MDK-ARM/.vscode/keil-assistant.log
index 646e173..8d5c96e 100644
--- a/MDK-ARM/.vscode/keil-assistant.log
+++ b/MDK-ARM/.vscode/keil-assistant.log
@@ -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
+
diff --git a/MDK-ARM/.vscode/settings.json b/MDK-ARM/.vscode/settings.json
index e5a3724..ceea9fd 100644
--- a/MDK-ARM/.vscode/settings.json
+++ b/MDK-ARM/.vscode/settings.json
@@ -5,6 +5,7 @@
"buzzer.h": "c",
"calc_lib.h": "c",
"usertask.h": "c",
- "detect.h": "c"
+ "detect.h": "c",
+ "nuc.h": "c"
}
}
\ No newline at end of file
diff --git a/MDK-ARM/.vscode/uv4.log b/MDK-ARM/.vscode/uv4.log
index e27e2d8..001bdc4 100644
--- a/MDK-ARM/.vscode/uv4.log
+++ b/MDK-ARM/.vscode/uv4.log
@@ -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
diff --git a/MDK-ARM/.vscode/uv4.log.lock b/MDK-ARM/.vscode/uv4.log.lock
index c647268..397b7bf 100644
--- a/MDK-ARM/.vscode/uv4.log.lock
+++ b/MDK-ARM/.vscode/uv4.log.lock
@@ -1 +1 @@
-2025/7/2 19:36:56
\ No newline at end of file
+2025/7/4 9:21:52
\ No newline at end of file
diff --git a/MDK-ARM/R1.uvoptx b/MDK-ARM/R1.uvoptx
index 73eea2c..09e32bf 100644
--- a/MDK-ARM/R1.uvoptx
+++ b/MDK-ARM/R1.uvoptx
@@ -180,6 +180,16 @@
1
cmd_fromnuc
+
+ 5
+ 1
+ drop_message,0x0A
+
+
+ 6
+ 1
+ error_code,0x0A
+
diff --git a/User/device/nuc.c b/User/device/nuc.c
index 130b3ac..0cf5add 100644
--- a/User/device/nuc.c
+++ b/User/device/nuc.c
@@ -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;
}
diff --git a/User/device/nuc.h b/User/device/nuc.h
index 6c8ff79..02a0bac 100644
--- a/User/device/nuc.h
+++ b/User/device/nuc.h
@@ -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)
// 写结构体存入视觉信息
diff --git a/User/task/nucTask.cpp b/User/task/nucTask.cpp
index f622aaf..8895412 100644
--- a/User/task/nucTask.cpp
+++ b/User/task/nucTask.cpp
@@ -1,10 +1,11 @@
#include "nucTask.hpp"
#include "nuc.h"
#include "userTask.h"
-#include "TopDefine.h"//事件组的一些东西
+#include "TopDefine.h" //事件组的一些东西
#include "FreeRTOS.h"
#include
#include
+#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);
+ }
}