From 42f014438932b7045112e4ed9a161c38f1f114a0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=B5=B7=E5=BA=8A=E5=B0=B1=E7=8A=AF=E5=9B=B0?=
<11730503+psx123456@user.noreply.gitee.com>
Date: Mon, 20 Oct 2025 19:35:24 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BB=8D=E7=84=B6=E4=BD=BF=E7=94=A8=E4=BF=A1?=
=?UTF-8?q?=E5=8F=B7=E9=87=8F=EF=BC=8C=E4=B8=8D=E4=BD=BF=E7=94=A8=E4=BA=92?=
=?UTF-8?q?=E6=96=A5=E9=87=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
APP/Device/Device_rotate/rotate_servo.c | 4 +++-
APP/Device/Device_speed/servoMotor_recv.c | 12 +++++++-----
APP/Device/Device_speed/speed_to_servoMotor.c | 12 +++++++++---
BSP/Driver/servoMotor/servoMotor.c | 12 ++++++------
GD32F4xx_Firmware_Library/SYSTICK/gd32f4xx_it.c | 4 ++++
PROJECT/OS2.ewp | 2 +-
6 files changed, 30 insertions(+), 16 deletions(-)
diff --git a/APP/Device/Device_rotate/rotate_servo.c b/APP/Device/Device_rotate/rotate_servo.c
index 37d7b43..2b80aba 100644
--- a/APP/Device/Device_rotate/rotate_servo.c
+++ b/APP/Device/Device_rotate/rotate_servo.c
@@ -136,8 +136,10 @@ void ptz_hori_stop(unsigned short int time)
{
OSTimeDlyHMSM(0u, 0u, 0u, time);
ptz_hori_stop_count = 0;
+ // servoSendData(horiMotorType, WriteMotorOneReg(H_MOTOR, H03_DI1_LOGICAL_SELEC, 0)
+ // , WRITE_ONE_REG_FRAME_NUM, highPriority); //失能电机
servoSendData(horiMotorType, WriteMotorOneReg(H_MOTOR, H03_DI1_LOGICAL_SELEC, 0)
- , WRITE_ONE_REG_FRAME_NUM, highPriority); //失能电机
+ , WRITE_ONE_REG_FRAME_NUM, lowPriority); //失能电机
}
ptz_hori_stop_count ++;
//电子稳定
diff --git a/APP/Device/Device_speed/servoMotor_recv.c b/APP/Device/Device_speed/servoMotor_recv.c
index bd2e8e3..1240bbe 100644
--- a/APP/Device/Device_speed/servoMotor_recv.c
+++ b/APP/Device/Device_speed/servoMotor_recv.c
@@ -257,7 +257,8 @@ static void ptz_recv_hori_servo_task()
}
stopTimeOut(H_MOTOR);
//释放信号量,通知能发送一次
- OSSemPost(g_horiSpeedMutex);
+ OSSemPost(g_horiSpeedMutex);
+ // OSMutexPost(g_horiSpeedMutex);
}
}
@@ -278,6 +279,7 @@ static void ptz_recv_vert_servo_task()
}
stopTimeOut(V_MOTOR);
//释放信号量,通知能发送一次
+ // OSMutexPost(g_vertSpeedMutex);
OSSemPost(g_vertSpeedMutex);
}
}
@@ -332,10 +334,10 @@ static void creat_task_servo_recv_task(void)
void Init_ServoMotorRecv(void)
{
CPU_INT08U err;
- g_horiMotorMutex = OSSemCreate(1);
- g_vertMotorMutex = OSSemCreate(1);
- OSSemPend(g_horiMotorMutex, 1, &err);
- OSSemPend(g_vertMotorMutex, 1, &err);
+ g_horiMotorMutex = OSSemCreate(0);
+ g_vertMotorMutex = OSSemCreate(0);
+// OSSemPend(g_horiMotorMutex, 1, &err);
+// OSSemPend(g_vertMotorMutex, 1, &err);
creat_task_servo_recv_task();
}
diff --git a/APP/Device/Device_speed/speed_to_servoMotor.c b/APP/Device/Device_speed/speed_to_servoMotor.c
index 757ce1b..0f6ff5f 100644
--- a/APP/Device/Device_speed/speed_to_servoMotor.c
+++ b/APP/Device/Device_speed/speed_to_servoMotor.c
@@ -284,6 +284,7 @@ static void ptz_hori_servo_task()
// if(g_ptz.hori_start_stop_set == PTZ_HORI_STOP)
// {
// }
+ // OSMutexPend(g_horiSpeedMutex, 0, &err);
OSSemPend(g_horiSpeedMutex, 0, &err);
OSSemPend(g_horiSpeedSem, 0, &err);
@@ -406,12 +407,14 @@ static void creat_task_vert_servo_task(void)
void horiServoTimeOut()
{
servoLinkListMemPut(horiMotorType);
+ // OSMutexPost(g_horiSpeedMutex);
OSSemPost(g_horiSpeedMutex);
}
void vertServoTimeOut()
{
servoLinkListMemPut(vertMotorType);
+ // OSMutexPost(g_vertSpeedMutex);
OSSemPost(g_vertSpeedMutex);
}
@@ -503,15 +506,18 @@ void startTimeOut(uint8_t motorType)
void init_speed_module(void)
{
+ CPU_INT08U err;
+
g_horiSpeedSem = OSSemCreate(0);
g_vertSpeedSem = OSSemCreate(0);
+ // g_horiSpeedMutex = OSMutexCreate(TASK_HORI_PID_PRIO, &err);
+ // g_vertSpeedMutex = OSMutexCreate(22, &err);
g_horiSpeedMutex = OSSemCreate(1);
g_vertSpeedMutex = OSSemCreate(1);
- OSSemPost(g_horiSpeedMutex);
- OSSemPost(g_vertSpeedMutex);
+ // OSSemPost(g_horiSpeedMutex);
+ // OSSemPost(g_vertSpeedMutex);
- CPU_INT08U err;
g_memPtr = OSMemCreate(memBuffer, sendDataBufNumber * 2, linkListNodeLen, &err);
if (err != OS_ERR_NONE) {
pdebug(DEBUG_LEVEL_FATAL, "Failed to create the motor memory pool\n\r");
diff --git a/BSP/Driver/servoMotor/servoMotor.c b/BSP/Driver/servoMotor/servoMotor.c
index 7838afe..b7f28d4 100644
--- a/BSP/Driver/servoMotor/servoMotor.c
+++ b/BSP/Driver/servoMotor/servoMotor.c
@@ -30,8 +30,8 @@
* @param dataҪĴд
* @return ַ
*/
- static uint8_t g_HwriteOneRegBuff[WRITE_ONE_REG_FRAME_NUM];
- static uint8_t g_VwriteOneRegBuff[WRITE_ONE_REG_FRAME_NUM];
+ uint8_t g_HwriteOneRegBuff[WRITE_ONE_REG_FRAME_NUM];
+ uint8_t g_VwriteOneRegBuff[WRITE_ONE_REG_FRAME_NUM];
uint8_t* WriteMotorOneReg(uint8_t motorNo, uint16_t regAddr, int16_t data)
{
static uint8_t g_writeOneRegBuff[WRITE_ONE_REG_FRAME_NUM];
@@ -46,10 +46,10 @@
g_writeOneRegBuff[6] = (uint8_t)(crc & 0xff);
g_writeOneRegBuff[7] = crc >> 8;
if ( motorNo == H_MOTOR )
- {
- memcpy(g_HwriteOneRegBuff, g_writeOneRegBuff, WRITE_ONE_REG_FRAME_NUM);
- return g_HwriteOneRegBuff;
- }
+ {
+ memcpy(g_HwriteOneRegBuff, g_writeOneRegBuff, WRITE_ONE_REG_FRAME_NUM);
+ return g_HwriteOneRegBuff;
+ }
memcpy(g_VwriteOneRegBuff, g_writeOneRegBuff, WRITE_ONE_REG_FRAME_NUM);
return g_VwriteOneRegBuff;
diff --git a/GD32F4xx_Firmware_Library/SYSTICK/gd32f4xx_it.c b/GD32F4xx_Firmware_Library/SYSTICK/gd32f4xx_it.c
index 5a3ed32..6dcbb99 100644
--- a/GD32F4xx_Firmware_Library/SYSTICK/gd32f4xx_it.c
+++ b/GD32F4xx_Firmware_Library/SYSTICK/gd32f4xx_it.c
@@ -60,6 +60,10 @@ void NMI_Handler(void)
void HardFault_Handler(void)
{
term_printf("****************** HardFault_Handler ********************/\r\n\r\n");
+
+
+ beep_enable();
+
/* if Hard Fault exception occurs, go to infinite loop */
while(1){
}
diff --git a/PROJECT/OS2.ewp b/PROJECT/OS2.ewp
index 571960f..ee7b438 100644
--- a/PROJECT/OS2.ewp
+++ b/PROJECT/OS2.ewp
@@ -826,7 +826,7 @@