#ifndef __SEASKY_PROTOCOL_H #define __SEASKY_PROTOCOL_H #include #include #define PROTOCOL_CMD_ID 0XA5 #define OFFSET_BYTE 8 // 出数据段外,其他部分所占字节数 typedef enum { NO_FIRE = 0, AUTO_FIRE = 1, AUTO_AIM = 2 } Fire_Mode_e; typedef enum { NO_TARGET = 0, TARGET_CONVERGING = 1, READY_TO_FIRE = 2 } Target_State_e; typedef enum { NO_TARGET_NUM = 0, HERO1 = 1, ENGINEER2 = 2, INFANTRY3 = 3, INFANTRY4 = 4, INFANTRY5 = 5, OUTPOST = 6, SENTRY = 7, BASE = 8 } Target_Type_e; typedef struct { Fire_Mode_e fire_mode; Target_State_e target_state; Target_Type_e target_type; float yaw; float pitch; } Vision_Recv_s; typedef enum { BLUE = 0, RED = 1 } Enemy_Color_e; typedef enum { MODE_AIM = 0, MODE_SMALL_BUFF = 1, MODE_BIG_BUFF = 2 } Work_Mode_e; typedef enum { BIG_AMU_10 = 10, SMALL_AMU_15 = 15, BIG_AMU_16 = 16, SMALL_AMU_18 = 18, SMALL_AMU_30 = 30, } Bullet_Speed_e; typedef struct { Enemy_Color_e enemy_color; Work_Mode_e work_mode; Bullet_Speed_e bullet_speed; float yaw; float pitch; float roll; // uint32_t time_stamp; // @todo 用于和相机的时间戳对齐 } Vision_Send_s; typedef struct { struct { uint8_t sof; uint16_t data_length; uint8_t crc_check; // 帧头CRC校验 } header; // 数据帧头 uint16_t cmd_id; // 数据ID uint16_t frame_tail; // 帧尾CRC校验 } protocol_rm_struct; /*更新发送数据帧,并计算发送数据帧长度*/ void get_protocol_send_data(uint16_t send_id, // 信号id uint16_t flags_register, // 16位寄存器 float *tx_data, // 待发送的float数据 uint8_t float_length, // float的数据长度 uint8_t *tx_buf, // 待发送的数据帧 uint16_t *tx_buf_len); // 待发送的数据帧长度 /*接收数据处理*/ uint16_t get_protocol_info(uint8_t *rx_buf, // 接收到的原始数据 uint16_t *flags_register, // 接收数据的16位寄存器地址 float *rx_data); // 接收的float数据存储地址 #endif