sentry_chassis_hzz/modules/master_machine/seasky_protocol.h

109 lines
2.0 KiB
C
Raw Normal View History

2022-11-03 20:38:55 +08:00
#ifndef __SEASKY_PROTOCOL_H
#define __SEASKY_PROTOCOL_H
#include <stdio.h>
#include <stdint.h>
#define PROTOCOL_CMD_ID 0XA5
2022-11-12 18:03:18 +08:00
#define OFFSET_BYTE 8 // 出数据段外,其他部分所占字节数
2022-11-03 20:38:55 +08:00
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,
2022-11-03 20:38:55 +08:00
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;
2022-11-12 18:03:18 +08:00
// uint32_t time_stamp; // @todo 用于和相机的时间戳对齐
2022-11-03 20:38:55 +08:00
} Vision_Send_s;
typedef struct
{
struct
{
uint8_t sof;
uint16_t data_length;
2022-11-12 18:03:18 +08:00
uint8_t crc_check; // 帧头CRC校验
} header; // 数据帧头
uint16_t cmd_id; // 数据ID
uint16_t frame_tail; // 帧尾CRC校验
2022-11-03 20:38:55 +08:00
} protocol_rm_struct;
/*更新发送数据帧,并计算发送数据帧长度*/
2022-11-12 18:03:18 +08:00
void get_protocol_send_data(uint16_t send_id, // 信号id
2022-11-03 20:38:55 +08:00
uint16_t flags_register, // 16位寄存器
2022-11-12 18:03:18 +08:00
float *tx_data, // 待发送的float数据
2022-11-03 20:38:55 +08:00
uint8_t float_length, // float的数据长度
2022-11-12 18:03:18 +08:00
uint8_t *tx_buf, // 待发送的数据帧
uint16_t *tx_buf_len); // 待发送的数据帧长度
2022-11-03 20:38:55 +08:00
/*接收数据处理*/
2022-11-12 18:03:18 +08:00
uint16_t get_protocol_info(uint8_t *rx_buf, // 接收到的原始数据
uint16_t *flags_register, // 接收数据的16位寄存器地址
float *rx_data); // 接收的float数据存储地址
2022-11-03 20:38:55 +08:00
#endif