#include "user_task.h" #include "nuc.h" #ifdef DEBUG NUC_t nuc_raw; CMD_NUC_t cmd_fromnuc; CMD_t cmd_nuc; Chassis_t chassis_nuc; #else static NUC_t nuc_raw; static CMD_NUC_t cmd_fromnuc; static CMD_t cmd_nuc; static Chassis_t chassis_nuc; #endif int a = 0; int i =0; fp32 send_data[4]={1,2,3,4}; void Task_nuc(void *argument){ (void)argument; /**/ // osDelay(TASK_INIT_DELAY_NUC); const uint32_t delay_tick = osKernelGetTickFreq() / TASK_FREQ_NUC; NUC_Init(&nuc_raw); uint32_t tick = osKernelGetTickCount(); while (1) { #ifdef DEBUG task_runtime.stack_water_mark.nuc= osThreadGetStackSpace(osThreadGetId()); #endif osMessageQueueGet(task_runtime.msgq.cmd.nuc,&cmd_nuc, NULL, 0); osMessageQueueGet(task_runtime.msgq.chassis_nuc,&chassis_nuc, NULL, 0); // static bool has_sent = false; if(chassis_nuc.SICK_FALG == 1){ // if (!has_sent){ //发送数据给nuc if(NUC_Send(send_data) == DEVICE_OK){ // has_sent = true; a++; } // } } // else{ // has_sent = false; // } //接收nuc数据 NUC_StartReceiving(); if (NUC_WaitDmaCplt()){ NUC_RawParse(&cmd_fromnuc); } else{ NUC_HandleOffline(&cmd_fromnuc); i++; } osMessageQueueReset(task_runtime.msgq.cmd.raw.nuc); osMessageQueuePut(task_runtime.msgq.cmd.raw.nuc,&(cmd_fromnuc),0,0); tick += delay_tick; /* 计算下一个唤醒时刻*/ osDelayUntil(tick); } }