shoot/User/task/dji_task.c

78 lines
1.4 KiB
C
Raw Normal View History

2025-03-12 23:04:18 +08:00
#include "dji_task.h"
#include "TopDefine.h"//事件组的一些东西
#include "FreeRTOS.h"
#include "attrTask.h"
#include <cmsis_os2.h>
#include "remote_control.h"
#include "dji.h"
2025-03-14 23:57:48 +08:00
#include "read_spi.h"
2025-03-12 23:04:18 +08:00
#include "vofa.h"
2025-03-14 23:57:48 +08:00
2025-03-12 23:04:18 +08:00
extern RC_mess_t RC_mess;
extern int16_t result;
2025-03-13 19:23:24 +08:00
extern int16_t t_result;
2025-03-14 23:57:48 +08:00
extern motor_measure_t *trigger_motor_data;
Encoder_t encoder;
2025-03-12 23:04:18 +08:00
float vofa[8];
2025-03-14 23:57:48 +08:00
int speed=0;
float m=0;
float trigger_angle_o=0;
int mode=0;
2025-03-12 23:04:18 +08:00
/**
* \brief
*
* \param argument 使
*/
void Task_Motor(void *argument)
{
(void)argument; /* 未使用argument消除警告 */
2025-03-13 19:23:24 +08:00
const uint32_t delay_tick = osKernelGetTickFreq() / TASK_FREQ_CTRL_CHASSIS;
2025-03-12 23:04:18 +08:00
motor_init();
2025-03-14 23:57:48 +08:00
Encoder_Init(&encoder);
2025-03-12 23:04:18 +08:00
uint32_t tick = osKernelGetTickCount();
while(1)
{
//收到消息队列新数据
2025-03-14 23:57:48 +08:00
// 更新编码器数据
Update_Encoder(&encoder);
m=trigger_angle_o*(8191/360);
if( mode == THREE )
{
//当最高点时进入离合
if(encoder.round_cnt>=8)
{
2025-03-15 16:42:56 +08:00
trigger_angle_o=2;
2025-03-14 23:57:48 +08:00
trigger_pos(m);
}
}
else if( mode == DZ )
{
//退出离合
trigger_angle_o=0;
trigger_pos(m);
}
2025-03-13 19:23:24 +08:00
CAN_cmd_200(t_result,0,0,0,&hcan1);
2025-03-12 23:04:18 +08:00
osDelay(2);
// vofa[0]=motor_3508_data->speed_rpm;
// vofa[1]=speed;
// vofa_tx_main(vofa);
2025-03-13 19:23:24 +08:00
tick += delay_tick;
osDelayUntil(tick);
2025-03-12 23:04:18 +08:00
}
}