仍然使用信号量,不使用互斥量
This commit is contained in:
parent
4b086aae75
commit
42f0144389
|
@ -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 ++;
|
||||
//电子稳定
|
||||
|
|
|
@ -258,6 +258,7 @@ static void ptz_recv_hori_servo_task()
|
|||
stopTimeOut(H_MOTOR);
|
||||
//释放信号量,通知能发送一次
|
||||
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();
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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){
|
||||
}
|
||||
|
|
|
@ -826,7 +826,7 @@
|
|||
</option>
|
||||
<option>
|
||||
<name>IlinkIcfFile</name>
|
||||
<state>D:\CompanyCode\newPro\servoMotor_xr\BSP\IAR\GD32F450xE.icf</state>
|
||||
<state>D:\psx\Pan-Tilt\1.software\HY\new_ptz\servoMotor\BSP\IAR\GD32F450xE.icf</state>
|
||||
</option>
|
||||
<option>
|
||||
<name>IlinkIcfFileSlave</name>
|
||||
|
|
Loading…
Reference in New Issue