#ifndef _NUC_H
#define _NUC_H

#include <cmsis_os2.h>
#include "device.h"
#include "bsp_usart.h"
#include "cmd.h"
#include "protocol.h"
#include "Algorithm/ahrs.h"
#include "Module/Chassis.h"

typedef struct 
{
   fp32 send;
	
}NUC_send_t;

typedef struct {
  uint8_t id;
  Protocol_UpPackageMCU_t package;
} NUC_UpPackageMCU_t;

typedef struct {
  uint8_t head;
  uint8_t type;
  uint8_t id; // 0x01 IMU帧
  Protocol_UpDataIMU_t package;
  uint8_t end;
} NUC_UpPackageIMU_t;

typedef struct {
  uint8_t head;
  uint8_t id;
  Protocol_UpDataCMD_t package;
  uint8_t end;
} NUC_UpPackageCMD_t;


typedef struct {
//  osThreadId_t thread_alert;
  bool unc_online; //是否在线
  Protocol_DownPackageChassis_t Nucfor_chassis; //接收的数据协议

  // NUC_UpPackageMCU_t to_nuc; //发送的数据协议

  struct {
    NUC_UpPackageIMU_t imu;
    NUC_UpPackageCMD_t cmd;
  } to_nuc;

  uint8_t status;//控制状态

} NUC_t;


int8_t NUC_Init(NUC_t *nuc);
int8_t NUC_StartReceiving(void);
bool_t NUC_WaitDmaCplt(void);
int8_t NUC_RawParse(CMD_NUC_t *n, NUC_t *nuc);
int8_t NUC_HandleOffline(CMD_NUC_t *cmd, NUC_t *nuc);
int8_t NUC_Restart(void);

int8_t NUC_PackIMU(NUC_t *nuc, const AHRS_Quaternion_t *quat, const AHRS_Accl_t *accl, const AHRS_Gyro_t *gyro);
int8_t NUC_PackCMD(NUC_t *nuc, const NUC_send_t *send);
int8_t NUC_StartSend(NUC_t *nuc, bool cmd_update);

#endif

