#include "user_task.h"
#include "nuc.h"

#ifdef DEBUG

NUC_t nuc_raw;
CMD_NUC_t cmd_fromnuc;

NUC_send_t NUC_send;
#else 
static NUC_t nuc_raw;
static CMD_NUC_t cmd_fromnuc;
NUC_send_t NUC_send;

#endif
fp32 send[4]={11.0f,45.0,1.f,4.0f};
int a=0;
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());
		task_runtime .freq.nuc = TASK_FREQ_NUC;
		task_runtime.last_up_time.nuc=	tick;
    
#endif
			 a++;
			NUC_StartReceiving();
			// NUC_StartSending(NUC_send.send);
			//  NUC_StartSending (send);
      if (NUC_WaitDmaCplt()){ 
         NUC_RawParse(&cmd_fromnuc);
      }
      else{
        NUC_HandleOffline(&cmd_fromnuc);
      }
     osMessageQueueReset(task_runtime.msgq.cmd.raw.nuc);
     osMessageQueuePut(task_runtime.msgq.cmd.raw.nuc,&(cmd_fromnuc),0,0);
		 osMessageQueueGet(task_runtime.msgq.cmd.raw.nuc_send, &NUC_send, NULL, 0);
	
     
		 tick += delay_tick; /* 计算下一个唤醒时刄1ķ*/
		 osDelayUntil(tick);
			
		 }
		 
		 
		 
}
	 
