/*
  初始化任务
  根据机器人的FLASH配置，决定生成哪些任务。
*/

/* Includes ----------------------------------------------------------------- */

#include "attrTask.h"

/* Private typedef ---------------------------------------------------------- */
/* Private define ----------------------------------------------------------- */
/* Private macro ------------------------------------------------------------ */
/* Private variables -------------------------------------------------------- */
/* Private function --------------------------------------------------------- */
/* Exported functions ------------------------------------------------------- */

/**
 * \brief 初始化
 *
 * \param argument 未使用
 */
void Task_Init(void *argument) {
  (void)argument;  /* 未使用argument，消除警告 */

  // Config_Get(&task_runtime.cfg); /* 获取机器人配置 */

  osKernelLock();
	
  /* 任务 */
    
//	led
 task_runtime.thread.led =
     osThreadNew(Task_Led, NULL, &attr_led);   
//can			
 task_runtime.thread.can = 
     osThreadNew(Task_Can, NULL, &attr_can);
//  dji_motor     
task_runtime.thread.dji_motor = 
     osThreadNew(Task_Motor, NULL, &attr_motor);
//  shoot
task_runtime.thread.shoot = 
     osThreadNew(Task_Shoot, NULL, &attr_shoot);
//  go
task_runtime.thread.go = 
     osThreadNew(Task_Go, NULL, &attr_go); 
//  nuc
task_runtime.thread.nuc = 
     osThreadNew(Task_nuc, NULL, &attr_nuc);
//  rc
task_runtime.thread.rc = 
     osThreadNew(Task_Rc, NULL, &attr_rc);     
// ball
task_runtime.thread.ball =
     osThreadNew(Task_Ball, NULL, &attr_ball);              

  /* 消息队列 */
  //can
//  task_runtime.queue.can.feedback.chassis =
//      osMessageQueueNew(1u, sizeof(CAN_ChassisMotor_t), NULL);
//  task_runtime.queue.can.feedback.gimbal =
//      osMessageQueueNew(1u, sizeof(CAN_GimbalMotor_t), NULL);
//  task_runtime.queue.feedback_left=
//      osMessageQueueNew(1u, sizeof(Parsing_Data_t), NULL);
//   task_runtime.queue.feedback_right =
//      osMessageQueueNew(1u, sizeof(Parsing_Data_t), NULL);  
//  task_runtime.queue.cmd_left=
//      osMessageQueueNew(1u, sizeof(CMD_gimbal_t), NULL);
//   task_runtime.queue.cmd_right =
//      osMessageQueueNew(1u, sizeof(CMD_gimbal_t), NULL); 
	
	/* 互斥量 */
			
//	task_runtime.mutex.can.er_2 = 
//			xSemaphoreCreateMutex();			
//            
//    task_runtime.mutex.cmd_left = 
//            xSemaphoreCreateMutex();
//    task_runtime.mutex.cmd_right = 
//            xSemaphoreCreateMutex();
//    task_runtime.mutex.feedback_left = 
//            xSemaphoreCreateMutex();
//    task_runtime.mutex.feedback_right = 
//            xSemaphoreCreateMutex();
            
  osKernelUnlock();
  osThreadTerminate(osThreadGetId()); /* 结束自身 */
}
