817 lines
32 KiB
C
817 lines
32 KiB
C
#ifndef _INTERFACE_H_
|
||
#define _INTERFACE_H_
|
||
|
||
#include "stdint.h"
|
||
|
||
#include "app/app_config.h" // 假设包含基础配置和宏定义
|
||
|
||
#pragma pack(1)//数据结构一个字节对齐
|
||
|
||
|
||
#define request_read_id un_request_frame.BitData.frame_type//读取ID
|
||
#define request_header_id un_request_frame.BitData.frame_header//帧头
|
||
|
||
|
||
#define FAULT 0
|
||
#define NORMAL 1
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
//-----CAN----------------------------------------------------------------
|
||
// 接收电机控制器输入
|
||
typedef union _UnMotorInput
|
||
{
|
||
struct
|
||
{
|
||
uint8_t arr[1][8];
|
||
} ArrData;
|
||
struct
|
||
{
|
||
//-----接收数据0x101或者0x201----------------------------------------------
|
||
unsigned int speed : 16; // 转速
|
||
unsigned int bus_voltage : 16; // 母线电压
|
||
unsigned int torque : 16; // 扭矩
|
||
unsigned int fault_code : 8; // 故障码
|
||
unsigned int heartbeat : 8; // 心跳
|
||
} BitData;
|
||
} UnMotorInput, *pUnMotorInput;
|
||
|
||
|
||
|
||
|
||
// 接收BMS输入
|
||
typedef union _UnBmsInput
|
||
{
|
||
struct
|
||
{
|
||
uint8_t arr[2][8];
|
||
} ArrData;
|
||
struct
|
||
{
|
||
//----接收0x100----------------------------------
|
||
// 多字节数据,高位在前,低位在后
|
||
unsigned int bus_voltage : 16; // 母线电压 单位为10mV
|
||
unsigned int bus_current : 16; // 母线电流 单位为10mA
|
||
unsigned int remainder_capacity : 16; // 剩余容量 单位为10mAh
|
||
unsigned int crc1 : 16; //crc
|
||
//----接收0x101----------------------------------
|
||
// 多字节数据,高位在前,低位在后
|
||
unsigned int full_capacity : 16; // 充满容量 单位为10mAh
|
||
unsigned int Discharge_times : 16; // 放电循环次数 单位为1次
|
||
unsigned int soc : 16; // soc
|
||
unsigned int crc2 : 16; //crc
|
||
} BitData;
|
||
} UnBmsInput, *pUnBmsInput;
|
||
|
||
|
||
|
||
|
||
// 接收温度模块输入
|
||
typedef union _UnTempModuleInput
|
||
{
|
||
struct
|
||
{
|
||
uint8_t arr[2][8]; // 2行8列数组,大小与BitData对齐
|
||
} ArrData;
|
||
struct
|
||
{
|
||
//-----接收数据0x301 0x302----------------------------------------------
|
||
// 多字节数据,高位在前,低位在后
|
||
unsigned int channel_1 : 16; // 通道1 温度传感器 系数为0.1 有符号 正数表示正温度,负数表示负温度
|
||
unsigned int channel_2 : 16; // 通道2
|
||
unsigned int channel_3 : 16; // 通道3
|
||
unsigned int channel_4 : 16; // 通道4
|
||
unsigned int channel_5 : 16; // 通道5
|
||
unsigned int channel_6 : 16; // 通道6
|
||
unsigned int channel_7 : 16; // 通道7
|
||
unsigned int channel_8 : 16; // 通道8
|
||
} BitData;
|
||
} UnTempModuleInput, *pUnTempModuleInput;
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
//-----以太网-------------------------------------------------------------
|
||
// 接收自主计算机自动输入
|
||
typedef union _UnAutoComputerInput
|
||
{
|
||
struct
|
||
{
|
||
uint8_t arr[25];
|
||
} ArrData;
|
||
|
||
struct
|
||
{
|
||
// 多字节数据,高位在前,低位在后
|
||
unsigned int frame_header : 16; // 帧头 固定值0xFFCC
|
||
unsigned int frame_type : 16; // 帧类型 固定值0x0001
|
||
unsigned int frame_length : 8; // 帧长 固定值0x19
|
||
unsigned int heartbeat : 8; // 心跳 按帧累加
|
||
unsigned int set_speed : 16; // 设定速度 系数0.01,正为前进,负为后退 单位m/s
|
||
unsigned int set_curvature : 16; // 设定曲率 系数0.0001,正为左转,负为右转
|
||
unsigned int latitude : 32; // 纬度 系数10^-7,431234567表示43.1234567度
|
||
unsigned int longitude : 32; // 经度 系数10^-7,431234567表示43.1234567度
|
||
unsigned int altitude : 32; // 高度 单位mm
|
||
unsigned int heading : 16; // 航向 车辆航向,35999表示359.99度
|
||
unsigned int crc : 8; // CRC 按字节累加之和,溢出取低8位
|
||
} BitData;
|
||
} UnAutoComputerInput, *pUnAutoComputerInput;
|
||
|
||
|
||
|
||
// 接收自主计算机手动输入
|
||
typedef union _UnManualComputerInput
|
||
{
|
||
struct
|
||
{
|
||
uint8_t arr[12];
|
||
} ArrData;
|
||
|
||
struct
|
||
{
|
||
// 手动控制数据 高位在前,低位在后
|
||
unsigned int frame_header : 16; // 帧头 固定值0xFFBB
|
||
unsigned int frame_type : 16; // 帧类型 固定值0x0011
|
||
unsigned int frame_length : 8; // 帧长 固定值0x0B
|
||
unsigned int accumulated : 8; // 累加值 按帧累加
|
||
unsigned int set_speed : 16; // 期望速度 系数0.01,正为前进,负为后退 单位m/s
|
||
unsigned int set_curvature : 16; // 期望曲率 系数0.0001,正为左转,负为右转
|
||
unsigned int reserved : 8; // 保留 同时按下LB+Y时发0xFF,松开发0,同时按下LT+Y时发0x10,松开发0
|
||
unsigned int crc : 8; // CRC 按字节累加之和,溢出取低8位
|
||
} BitData;
|
||
} UnManualComputerInput, *pUnManualComputerInput;
|
||
|
||
|
||
|
||
// 接收请求帧
|
||
typedef union _UnRequestFrame
|
||
{
|
||
struct
|
||
{
|
||
uint8_t arr[10];
|
||
} ArrData;
|
||
|
||
struct
|
||
{
|
||
//--------------------------------------------------
|
||
unsigned int frame_header : 16; // 帧头 固定值0x0080
|
||
unsigned int frame_type : 16; // 帧类型 固定值0x0029
|
||
unsigned int frame_length : 16; // 帧长 固定值10
|
||
unsigned int accumulated : 8; // 累加值 按帧累加
|
||
unsigned int request_id : 16; // 请求帧ID 请求ID 0-FFFF,FFFF表示全部帧
|
||
unsigned int crc : 8; // CRC 按字节累加之和 取低8位
|
||
} BitData;
|
||
} UnRequestFrame, *pUnRequestFrame;
|
||
|
||
|
||
|
||
|
||
//-----串口---------------------------------------------------------------
|
||
// 接收遥控器输入
|
||
typedef union _UnRemoteControlInput
|
||
{
|
||
struct
|
||
{
|
||
uint8_t arr[1][8];
|
||
} ArrData;
|
||
|
||
struct
|
||
{
|
||
//-----接收数据0x12000013----------------------------------------------
|
||
unsigned int speed : 16; // 速度
|
||
unsigned int curvature : 16; // 曲率
|
||
unsigned int reserve1 : 16; // 保留
|
||
|
||
unsigned int switch_a : 1; // SwA
|
||
unsigned int switch_b : 2; // SwB
|
||
unsigned int switch_c : 2; // SwC
|
||
unsigned int switch_d : 1; // SwD
|
||
unsigned int reserve2 : 1; // 保留
|
||
unsigned int reserve3 : 1; // 保留
|
||
|
||
unsigned int enable : 8; // 使能
|
||
} BitData;
|
||
} UnRemoteControlInput, *pUnRemoteControlInput;
|
||
|
||
|
||
//-----IO口---------------------------------------------------------------
|
||
// 从IO口输入
|
||
typedef union _UnSwSample
|
||
{
|
||
struct
|
||
{
|
||
uint8_t arr[1][6];
|
||
} ArrData;
|
||
|
||
struct
|
||
{
|
||
unsigned int CH01 : 1; // 通道1,急停开关,1急停有效,0,释放
|
||
unsigned int CH02 : 1; // 高压开关状态 1有效
|
||
unsigned int CH03 : 1; // 通道3
|
||
unsigned int CH04 : 1; // 通道4
|
||
unsigned int CH05 : 1; // 通道5
|
||
unsigned int CH06 : 1; // 通道6
|
||
unsigned int CH07 : 1; // 通道7
|
||
unsigned int CH08 : 1; // 通道8
|
||
unsigned int CH09 : 1; // 通道9
|
||
unsigned int CH10 : 1; // 通道10
|
||
unsigned int CH11 : 1; // 通道11
|
||
unsigned int CH12 : 1; // 通道12
|
||
unsigned int CH13 : 1; // 通道13
|
||
unsigned int CH14 : 1; // 通道14
|
||
unsigned int CH15 : 1; // 通道15
|
||
unsigned int CH16 : 1; // 通道16
|
||
unsigned int CH17 : 1; // 通道17
|
||
unsigned int CH18 : 1; // 通道18
|
||
unsigned int CH19 : 1; // 通道19
|
||
unsigned int CH20 : 1; // 通道20
|
||
unsigned int CH21 : 1; // 通道21
|
||
unsigned int CH22 : 1; // 通道22
|
||
unsigned int CH23 : 1; // 通道23
|
||
unsigned int CH24 : 1; // 通道24
|
||
unsigned int CH25 : 1; // 通道25
|
||
unsigned int CH26 : 1; // 通道26
|
||
unsigned int CH27 : 1; // 通道27
|
||
unsigned int CH28 : 1; // 通道28
|
||
unsigned int CH29 : 1; // 通道29
|
||
unsigned int CH30 : 1; // 通道30
|
||
unsigned int CH31 : 1; // 通道31
|
||
unsigned int CH32 : 1; // 通道32
|
||
unsigned int CH33 : 1; // 通道33
|
||
unsigned int CH34 : 1; // 通道34
|
||
unsigned int CH35 : 1; // 通道35
|
||
unsigned int CH36 : 1; // 通道36
|
||
unsigned int CH37 : 1; // 通道37
|
||
unsigned int CH38 : 1; // 通道38
|
||
unsigned int CH39 : 1; // 通道39
|
||
unsigned int CH40 : 1; // 通道40
|
||
unsigned int CH41 : 1; // 通道41
|
||
unsigned int CH42 : 1; // 通道42
|
||
unsigned int CH43 : 1; // 通道43
|
||
unsigned int CH44 : 1; // 通道44
|
||
unsigned int reserve : 4;
|
||
} BitData;
|
||
} UnSwSample, *pUnSwSample;
|
||
|
||
|
||
|
||
|
||
//-----输出数据结构---------------------------------------------------------------
|
||
//-----CAN----------------------------------------------------------------
|
||
// 输出到电机控制器
|
||
typedef union _UnMotorOutput
|
||
{
|
||
struct
|
||
{
|
||
uint8_t arr[2][8];
|
||
} ArrData;
|
||
|
||
struct
|
||
{
|
||
//-----发送数据0x201或者0x202----------------------------------------------
|
||
unsigned int mode : 8; // 模式 0x1恒速模式,0x2恒扭模式,其他无效
|
||
unsigned int gear : 8; // 档位 0x0空挡模式,0x1前进挡,0x2倒退档,其他无效
|
||
unsigned int set_torque : 16; // 给定扭矩
|
||
unsigned int set_rotation_speed : 16; // 给定转速
|
||
unsigned int fault_code : 8; // 故障码
|
||
unsigned int heartbeat : 8; // 心跳
|
||
//-----发送数据0x401或者0x402----------------------------------------------
|
||
unsigned int feed_power : 16; // 馈电功率 单位为 W 最大为10KW
|
||
unsigned int discharge_power : 16; // 放电功率 单位为 W 最大为15kW
|
||
unsigned int reserve1 : 16; // 保留
|
||
unsigned int reserve2 : 16; // 保留
|
||
} BitData;
|
||
} UnMotorOutput, *pUnMotorOutput;
|
||
|
||
|
||
|
||
// 输出到开关阀模块
|
||
typedef union _UnInfCanKGFOutput
|
||
{
|
||
struct
|
||
{
|
||
uint8_t arr[2][8];
|
||
} ArrData;
|
||
|
||
struct
|
||
{
|
||
//----------主机发送命令字0x11000002 --------------------------------------------
|
||
unsigned int KGF01 : 1; // 通道1
|
||
unsigned int KGF02 : 1; // 通道2
|
||
unsigned int KGF03 : 1; // 通道3
|
||
unsigned int KGF04 : 1; // 通道4
|
||
unsigned int KGF05 : 1; // 通道5
|
||
unsigned int KGF06 : 1; // 通道6
|
||
unsigned int KGF07 : 1; // 通道7
|
||
unsigned int KGF08 : 1; // 通道8
|
||
unsigned int KGF09 : 1; // 通道9
|
||
unsigned int KGF10 : 1; // 通道10
|
||
unsigned int KGF11 : 1; // 通道11
|
||
unsigned int KGF12 : 1; // 通道12
|
||
unsigned int KGF13 : 1; // 通道13
|
||
unsigned int KGF14 : 1; // 通道14
|
||
unsigned int KGF15 : 1; // 通道15
|
||
unsigned int KGF16 : 1; // 通道16
|
||
|
||
unsigned int can_rx2 : 8; // 保留
|
||
unsigned int can_rx3 : 8; // 保留
|
||
unsigned int can_rx4 : 8; // 保留
|
||
unsigned int can_rx5 : 8; // 保留
|
||
unsigned int can_period_h: 8; // 发送周期高位
|
||
unsigned int can_period_l: 8; // 发送周期低位
|
||
|
||
//----------发送0x11000003 ---------------------------------------------------
|
||
unsigned int pwm_01 : 4; // PWM通道1
|
||
unsigned int pwm_02 : 4; // PWM通道2
|
||
unsigned int pwm_03 : 4; // PWM通道3
|
||
unsigned int pwm_04 : 4; // PWM通道4
|
||
unsigned int pwm_05 : 4; // PWM通道5
|
||
unsigned int pwm_06 : 4; // PWM通道6
|
||
unsigned int pwm_07 : 4; // PWM通道7
|
||
unsigned int pwm_08 : 4; // PWM通道8
|
||
unsigned int pwm_09 : 4; // PWM通道9
|
||
unsigned int pwm_10 : 4; // PWM通道10
|
||
unsigned int pwm_11 : 4; // PWM通道11
|
||
unsigned int pwm_12 : 4; // PWM通道12
|
||
unsigned int pwm_13 : 4; // PWM通道13
|
||
unsigned int pwm_14 : 4; // PWM通道14
|
||
unsigned int pwm_15 : 4; // PWM通道15
|
||
unsigned int pwm_16 : 4; // PWM通道16
|
||
} BitData;
|
||
} UnInfCanKGFOutput, *pInfUnCanKGFOutput;
|
||
|
||
|
||
|
||
|
||
|
||
// 输出到H桥模块
|
||
typedef union _UnHBridgeOutput
|
||
{
|
||
struct
|
||
{
|
||
uint8_t arr[2][8];
|
||
} ArrData;
|
||
|
||
struct
|
||
{
|
||
//----------主机发送命令字0x7F2 --------------------------------------------
|
||
unsigned int channel_01 : 1; // 通道1
|
||
unsigned int channel_02 : 1; // 通道2
|
||
unsigned int channel_03 : 1; // 通道3
|
||
unsigned int channel_04 : 1; // 通道4
|
||
unsigned int channel_05 : 1; // 通道5
|
||
unsigned int channel_06 : 1; // 通道6
|
||
unsigned int channel_07 : 1; // 通道7
|
||
unsigned int channel_08 : 1; // 通道8
|
||
unsigned int sleep_01 : 1; // 休眠1
|
||
unsigned int sleep_02 : 1; // 休眠2
|
||
unsigned int sleep_03 : 1; // 休眠3
|
||
unsigned int sleep_04 : 1; // 休眠4
|
||
unsigned int reserve_01 : 1; // 保留1
|
||
unsigned int reserve_02 : 1; // 保留2
|
||
unsigned int reserve_03 : 1; // 保留3
|
||
unsigned int reserve_04 : 1; // 保留4
|
||
|
||
unsigned int reserve_05 : 8; // 保留5
|
||
unsigned int reserve_06 : 8; // 保留6
|
||
unsigned int reserve_07 : 8; // 保留7
|
||
unsigned int reserve_08 : 8; // 保留8
|
||
unsigned int can_period_h : 8; // 发送周期高位
|
||
unsigned int can_period_l : 8; // 发送周期低位
|
||
|
||
//----------发送0x7F3 ---------------------------------------------------
|
||
unsigned int pwm_channel_01 : 4; // PWM通道1
|
||
unsigned int pwm_channel_02 : 4; // PWM通道2
|
||
unsigned int pwm_channel_03 : 4; // PWM通道3
|
||
unsigned int pwm_channel_04 : 4; // PWM通道4
|
||
unsigned int pwm_channel_05 : 4; // PWM通道5
|
||
unsigned int pwm_channel_06 : 4; // PWM通道6
|
||
unsigned int pwm_channel_07 : 4; // PWM通道7
|
||
unsigned int pwm_channel_08 : 4; // PWM通道8
|
||
unsigned int pwm_reserve_01 : 4; // 保留pwm1
|
||
unsigned int pwm_reserve_02 : 4; // 保留pwm2
|
||
unsigned int pwm_reserve_03 : 4; // 保留pwm3
|
||
unsigned int pwm_reserve_04 : 4; // 保留pwm4
|
||
unsigned int pwm_reserve_05 : 4; // 保留pwm5
|
||
unsigned int pwm_reserve_06 : 4; // 保留pwm6
|
||
unsigned int pwm_reserve_07 : 4; // 保留pwm7
|
||
unsigned int pwm_reserve_08 : 4; // 保留pwm8
|
||
} BitData;
|
||
} UnHBridgeOutput, *pUnHBridgeOutput;
|
||
|
||
|
||
|
||
|
||
// 输出给导航仪
|
||
typedef union _UnWheelSpeedOutput
|
||
{
|
||
struct
|
||
{
|
||
uint8_t arr[1][8];
|
||
} ArrData;
|
||
|
||
struct
|
||
{
|
||
//-----发送数据0x98----------------------------------------------
|
||
unsigned int left_front_wheel_speed : 16; // 左前轮速
|
||
unsigned int right_front_wheel_speed : 16; // 右前轮速
|
||
unsigned int left_rear_wheel_speed : 16; // 左后轮速
|
||
unsigned int right_rear_wheel_speed : 16; // 右后轮速
|
||
} BitData;
|
||
} UnWheelSpeedOutput, *pUnWheelSpeedOutput;
|
||
|
||
|
||
|
||
//-----以太网-------------------------------------------------------------
|
||
// 输出给自主计算机
|
||
typedef union _UnComputerOutput
|
||
{
|
||
struct
|
||
{
|
||
uint8_t arr[11];
|
||
} ArrData;
|
||
|
||
struct
|
||
{
|
||
//--------------------------------------------------
|
||
unsigned int frame_header : 16; // 帧头 0xFFCC
|
||
unsigned int frame_type : 16; // 帧类型 0x0011
|
||
unsigned int frame_length : 8; // 帧长 0x000b,11
|
||
unsigned int accumulated : 8; // 累加值
|
||
unsigned int current_speed : 16; // 当前速度
|
||
unsigned int current_curvature : 16; // 当前曲率
|
||
unsigned int crc : 8; // CRC
|
||
} BitData;
|
||
} UnComputerOutput, *pUnComputerOutput;
|
||
|
||
|
||
|
||
|
||
// 车辆信息,输出给上位机
|
||
typedef union _UnVehicleInfoOutput
|
||
{
|
||
struct
|
||
{
|
||
uint8_t arr[41];
|
||
} ArrData;
|
||
|
||
struct
|
||
{
|
||
//--------------------------------------------------
|
||
unsigned int frame_header : 16; // 帧头
|
||
unsigned int frame_type : 16; // 帧类型
|
||
unsigned int frame_length : 16; // 帧长
|
||
unsigned int accumulated : 8; // 累加值
|
||
unsigned int desired_speed : 16; // 期望速度
|
||
unsigned int desired_curvature : 16; // 期望曲率
|
||
unsigned int set_left_speed : 16; // 设定左转速度
|
||
unsigned int set_right_speed : 16; // 设定右转速度
|
||
unsigned int longitude : 32; // 经度
|
||
unsigned int latitude : 32; // 纬度
|
||
unsigned int altitude : 32; // 高度
|
||
unsigned int heading_angle : 16; // 航向角
|
||
unsigned int current_speed : 16; // 当前车速
|
||
unsigned int current_curvature : 16; // 当前曲率
|
||
unsigned int battery_voltage : 16; // 电池电压
|
||
unsigned int battery_soc : 16; // 电池SOC
|
||
unsigned int battery_current : 16; // 电池电流
|
||
unsigned int vehicle_fault_state : 8; // 整车故障状态
|
||
unsigned int crc : 8; // CRC
|
||
} BitData;
|
||
} UnVehicleInfoOutput, *pUnVehicleInfoOutput;
|
||
|
||
|
||
|
||
// 电机状态信息,输出给上位机
|
||
typedef union _UnMotorStatusOutput
|
||
{
|
||
struct
|
||
{
|
||
uint8_t arr[34];
|
||
} ArrData;
|
||
|
||
struct
|
||
{
|
||
//--------------------------------------------------
|
||
unsigned int frame_header : 16; // 帧头 固定值0xAACC
|
||
unsigned int frame_type : 16; // 帧类型 固定值0x0021
|
||
unsigned int frame_length : 16; // 帧长 固定值30
|
||
unsigned int accumulated : 8; // 累加值 按帧累加
|
||
unsigned int left_wheel_speed : 16; // 当前左侧轮速 系数 1 偏移量 -30000 单位rad/min
|
||
unsigned int right_wheel_speed : 16; // 当前右侧轮速 系数 1 偏移量 -30000 单位rad/min
|
||
unsigned int left_motor_torque : 16; // 左侧电机扭矩 系数 0.01 偏移量 -300 单位N/s
|
||
unsigned int right_motor_torque : 16; // 右侧电机扭矩 系数 0.01 偏移量 -300 单位N/s
|
||
unsigned int left_motor_fault_code : 8; // 左侧电机故障码
|
||
unsigned int right_motor_fault_code: 8; // 右侧电机故障码
|
||
unsigned int left_torque_limit : 16; // 左侧电机扭矩限制
|
||
unsigned int right_torque_limit : 16; // 右侧电机扭矩限制
|
||
unsigned int left_motor_power_in : 16; // 左侧电机馈电功率
|
||
unsigned int right_motor_power_in : 16; // 右侧电机馈电功率
|
||
unsigned int left_motor_power_out : 16; // 左侧电机放电功率
|
||
unsigned int right_motor_power_out : 16; // 右侧电机放电功率
|
||
unsigned int left_motor_voltage : 16; // 左侧电机电压
|
||
unsigned int right_motor_voltage : 16; // 右侧电机电压
|
||
unsigned int checksum : 8; // 校验和 按字节累加之和 取低8位
|
||
} BitData;
|
||
} UnMotorStatusOutput, *pUnMotorStatusOutput;
|
||
|
||
|
||
|
||
|
||
// PID参数输出,输出给上位机
|
||
typedef union _UnPIDOutput
|
||
{
|
||
struct
|
||
{
|
||
uint8_t arr[56];
|
||
} ArrData;
|
||
|
||
struct
|
||
{
|
||
//--------------------------------------------------
|
||
unsigned int frame_header : 16; // 帧头
|
||
unsigned int frame_type : 16; // 帧类型
|
||
unsigned int frame_length : 16; // 帧长
|
||
unsigned int accumulated : 8; // 累加值
|
||
unsigned int rc_straight_p : 32; // 遥控直行P参数
|
||
unsigned int rc_straight_i : 32; // 遥控直行I参数
|
||
unsigned int rc_straight_d : 32; // 遥控直行D参数
|
||
unsigned int auto_straight_p : 32; // 自主直行P参数
|
||
unsigned int auto_straight_i : 32; // 自主直行I参数
|
||
unsigned int auto_straight_d : 32; // 自主直行D参数
|
||
unsigned int rc_turn_p : 32; // 遥控转弯P参数
|
||
unsigned int rc_turn_i : 32; // 遥控转弯I参数
|
||
unsigned int rc_turn_d : 32; // 遥控转弯D参数
|
||
unsigned int auto_turn_p : 32; // 自主转弯P参数
|
||
unsigned int auto_turn_i : 32; // 自主转弯I参数
|
||
unsigned int auto_turn_d : 32; // 自主转弯D参数
|
||
unsigned int checksum : 8; // 校验和
|
||
} BitData;
|
||
} UnPIDOutput, *pUnPIDOutput;
|
||
|
||
|
||
|
||
|
||
// 模拟信号输出,输出给上位机
|
||
typedef union _UnAnalogSignalOutput
|
||
{
|
||
struct
|
||
{
|
||
uint8_t arr[24];
|
||
} ArrData;
|
||
|
||
struct
|
||
{
|
||
//--------------------------------------------------
|
||
unsigned int frame_header : 16; // 帧头 固定值0xAACC
|
||
unsigned int frame_type : 16; // 帧类型 固定值0x0023
|
||
unsigned int frame_length : 16; // 帧长 固定值24
|
||
unsigned int accumulated : 8; // 累加值 按帧累加
|
||
unsigned int channel_1 : 16; // 通道1 温度传感器 系数为0.1 有符号 正数表示正温度,负数标表示负温度
|
||
unsigned int channel_2 : 16; // 通道2
|
||
unsigned int channel_3 : 16; // 通道3
|
||
unsigned int channel_4 : 16; // 通道4
|
||
unsigned int channel_5 : 16; // 通道5 温度传感器 系数为0.1 有符号 正数表示正温度,负数标表示负温度
|
||
unsigned int channel_6 : 16; // 通道6
|
||
unsigned int channel_7 : 16; // 通道7
|
||
unsigned int channel_8 : 16; // 通道8
|
||
unsigned int crc : 8 ; // 校验和 按字节累加之和 取低8位
|
||
|
||
} BitData;
|
||
} UnAnalogSignalOutput, *pUnAnalogSignalOutput;
|
||
|
||
|
||
|
||
// 遥控器数据输出,给上位机
|
||
typedef union _UnRemoteControlOutput
|
||
{
|
||
struct
|
||
{
|
||
uint8_t arr[18];
|
||
} ArrData;
|
||
|
||
struct
|
||
{
|
||
//--------------------------------------------------
|
||
unsigned int frame_header : 16; // 帧头 固定值0xAACC
|
||
unsigned int frame_type : 16; // 帧类型 固定值0x0024
|
||
unsigned int frame_length : 16; // 帧长 固定值20
|
||
unsigned int accumulated : 8; // 累加值 按帧累加
|
||
|
||
// 遥控原始数据
|
||
unsigned int speed : 16; // 速度 系数0.01,正为前进,负为后退 单位m/s
|
||
unsigned int curvature : 16; // 曲率 系数0.0001,正为左转,负为右转
|
||
unsigned int reserve_1 : 16; // 备用1
|
||
|
||
unsigned int switch_a : 1; // SwA
|
||
unsigned int switch_b : 2; // SwB 0和2刹车状态 1正常状态
|
||
unsigned int switch_c : 2; // SwC 0和2自主状态 1手动状态
|
||
unsigned int switch_d : 1; // SwD
|
||
unsigned int hv_relay_state : 1; // 高压继电机状态 0 断开, 1开启
|
||
unsigned int reserve_2 : 1; // 备用
|
||
unsigned int enable : 8; // 使能 1遥控数据有效,0无效
|
||
unsigned int accumulated_value : 16; // 接收累加值
|
||
unsigned int crc : 8; // 校验和 按字节累加之和 取低8位
|
||
} BitData;
|
||
} UnRemoteControlOutput, *pUnRemoteControlOutput;
|
||
|
||
|
||
|
||
|
||
// 手动控制数据,返回给请求者
|
||
typedef union _UnManualControlOutput
|
||
{
|
||
struct
|
||
{
|
||
uint8_t arr[15];
|
||
} ArrData;
|
||
|
||
struct
|
||
{
|
||
//--------------------------------------------------
|
||
// 手动控制数据 高位在前,低位在后
|
||
unsigned int frame_header : 16; // 帧头 固定值0xFFBB
|
||
unsigned int frame_type : 16; // 帧类型 固定值0x0025
|
||
unsigned int frame_length : 8; // 帧长 固定值0x0C
|
||
unsigned int accumulated : 8; // 累加值 按帧累加
|
||
unsigned int set_speed : 16; // 设定速度 系数0.01,正为前进,负为后退 单位m/s
|
||
unsigned int set_curvature : 16; // 设定曲率 系数0.0001,正为左转,负为右转
|
||
unsigned int reserved : 8; // 保留
|
||
unsigned int crc_1 : 8 ; // CRC 按字节累加之和,溢出取低8位
|
||
unsigned int accumulated_value : 16; // 接收累加值
|
||
unsigned int crc_2 : 8 ; // CRC 按字节累加之和,溢出取低8位
|
||
} BitData;
|
||
} UnManualControlOutput, *pUnManualControlOutput;
|
||
|
||
|
||
|
||
|
||
// 自动控制数据输出,返回给请求者
|
||
typedef union _UnAutoControlOutput
|
||
{
|
||
struct
|
||
{
|
||
uint8_t arr[25];
|
||
} ArrData;
|
||
|
||
struct
|
||
{
|
||
//--------------------------------------------------
|
||
// 自主计算机自动数据 高位在前,低位在后
|
||
unsigned int frame_header : 16; // 帧头 固定值0xFFCC
|
||
unsigned int frame_type : 16; // 帧类型 固定值0x0026
|
||
unsigned int frame_length : 8; // 帧长 固定值0x19
|
||
unsigned int accumulated : 8; // 累加值 按帧累加
|
||
unsigned int set_speed : 16; // 设定速度 系数0.01,正为前进,负为后退 单位m/s
|
||
unsigned int set_curvature : 16; // 设定曲率 系数0.0001,正为左转,负为右转
|
||
unsigned int latitude : 32; // 纬度 系数10^-7,431234567表示43.1234567度
|
||
unsigned int longitude : 32; // 经度 系数10^-7,431234567表示43.1234567度
|
||
unsigned int altitude : 32; // 高度 单位mm
|
||
unsigned int heading : 16; // 航向 车辆航向,35999表示359.99度。
|
||
unsigned int crc_1 : 8 ; // CRC 按字节累加之和,溢出取低8位
|
||
} BitData;
|
||
} UnAutoControlOutput, *pUnAutoControlOutput;
|
||
|
||
|
||
|
||
|
||
|
||
// 温度请求指令输出
|
||
typedef union _UnTemperatureRequestOutput
|
||
{
|
||
struct
|
||
{
|
||
uint8_t arr[1][8];
|
||
} ArrData;
|
||
|
||
struct
|
||
{
|
||
//-----数据0x301----------------------------------------------
|
||
unsigned int reserve_1 : 8; // 保留
|
||
unsigned int reserve_2 : 8; // 保留
|
||
unsigned int reserve_3 : 8; // 保留
|
||
unsigned int reserve_4 : 8; // 保留
|
||
unsigned int reserve_5 : 8; // 保留
|
||
unsigned int reserve_6 : 8; // 保留
|
||
unsigned int reserve_7 : 8; // 保留
|
||
unsigned int reserve_8 : 8; // 保留
|
||
} BitData;
|
||
} UnTemperatureRequestOutput, *pUnTemperatureRequestOutput;
|
||
|
||
|
||
|
||
|
||
//-----IO口---------------------------------------------------------------
|
||
// 电压信号输出,到遥控器
|
||
typedef union _UnVoltageSignalOutput
|
||
{
|
||
struct
|
||
{
|
||
uint8_t arr[1][2];
|
||
} ArrData;
|
||
|
||
struct
|
||
{
|
||
unsigned int pwm_value : 16; // PWM值
|
||
} BitData;
|
||
} UnVoltageSignalOutput, *pUnVoltageSignalOutput;
|
||
|
||
|
||
|
||
|
||
|
||
//extern UnMotorInput un_motor_input1; // 定义MotorInput实例
|
||
//extern UnMotorInput un_motor_input2; // 定义MotorInput实例
|
||
//extern UnBmsInput un_bms_input; // 定义UnBmsInput实例
|
||
//extern UnTempModuleInput un_temp_module_input; // 定义UnTempModuleInput实例
|
||
//extern UnAutoComputerInput un_auto_computer_input; // 定义UnAutoComputerInput实例
|
||
//extern UnManualComputerInput un_manual_computer_input; // 定义UnManualComputerInput实例
|
||
//extern UnRequestFrame un_request_frame; // 定义UnRequestFrame实例
|
||
//extern UnRemoteControlInput un_remote_control_input; // 定义UnRemoteControlInput实例
|
||
//extern UnSwSample un_sw_sample; // 定义UnSwSample实例
|
||
//extern UnMotorOutput un_motor_output1; // 定义UnMotorOutput实例
|
||
//extern UnMotorOutput un_motor_output2; // 定义UnMotorOutput实例
|
||
//extern UnInfCanKGFOutput un_inf_can_kgf_output1; // 定义UnInfCanKGFOutput实例
|
||
//extern UnInfCanKGFOutput un_inf_can_kgf_output2; // 定义UnInfCanKGFOutput实例
|
||
//extern UnHBridgeOutput un_h_bridge_output; // 定义UnHBridgeOutput实例
|
||
//extern UnWheelSpeedOutput un_wheel_speed_output; // 定义UnWheelSpeedOutput实例
|
||
//extern UnComputerOutput un_computer_output; // 定义UnComputerOutput实例
|
||
//extern UnVehicleInfoOutput un_vehicle_info_output; // 定义UnVehicleInfoOutput实例
|
||
//extern UnMotorStatusOutput un_motor_status_output; // 定义UnMotorStatusOutput实例
|
||
//extern UnPIDOutput un_pid_output; // 定义UnPIDOutput实例
|
||
//extern UnAnalogSignalOutput un_analog_signal_output; // 定义UnAnalogSignalOutput实例
|
||
//extern UnRemoteControlOutput un_remote_control_output; // 定义UnRemoteControlOutput实例
|
||
//extern UnManualControlOutput un_manual_control_output; // 定义UnManualControlOutput实例
|
||
//extern UnAutoControlOutput un_auto_control_output; // 定义UnAutoControlOutput实例
|
||
//extern UnTemperatureRequestOutput un_temperature_request_output; // 定义UnTemperatureRequestOutput实例
|
||
//extern UnVoltageSignalOutput un_voltage_signal_output; // 定义UnVoltageSignalOutput实例
|
||
|
||
|
||
|
||
//外部数据结构声明
|
||
extern UnMotorInput un_motor_input1 ;//电机控制器1 左侧
|
||
extern UnMotorInput un_motor_input2 ;//电机控制器2 右侧
|
||
extern UnBmsInput un_bms_input ;//BMS接收数据
|
||
extern UnTempModuleInput un_temp_module_input;//温度采集模块
|
||
extern UnAutoComputerInput un_auto_computer_input;//自主计算机自动数据
|
||
extern UnManualComputerInput un_manual_computer_input;//自主计算机手动数据
|
||
|
||
|
||
|
||
|
||
|
||
extern UnMotorOutput un_motor_output1; //电机输出
|
||
extern UnMotorOutput un_motor_output2; //电机输出
|
||
extern UnInfCanKGFOutput un_inf_can_kgf_output1;
|
||
extern UnInfCanKGFOutput un_inf_can_kgf_output2;
|
||
extern UnHBridgeOutput un_h_bridge_output;
|
||
extern UnWheelSpeedOutput un_wheel_speed_output;
|
||
extern UnTemperatureRequestOutput un_temperature_request_output;
|
||
extern UnWheelSpeedOutput un_Wheel_Speed_output;
|
||
|
||
//串口
|
||
extern UnRemoteControlInput un_remote_control_input; //遥控器输入
|
||
|
||
//IO口
|
||
extern UnSwSample un_sw_sample;
|
||
|
||
//以太网
|
||
extern UnRequestFrame un_request_frame; //请求帧
|
||
|
||
extern UnComputerOutput un_computer_output; //输出给自主计算机
|
||
|
||
//输出给上位机
|
||
extern UnVehicleInfoOutput un_vehicle_Info_output; // 车辆信息,输出给上位机
|
||
extern UnMotorStatusOutput un_motor_status_output; // 电机状态信息,输出给上位机
|
||
extern UnPIDOutput un_pid_output; // PID参数输出,输出给上位机
|
||
extern UnAnalogSignalOutput un_analog_signal_output; // 模拟信号输出,输出给上位机
|
||
extern UnRemoteControlOutput un_remote_control_output;// 遥控器数据输出,给上位机
|
||
extern UnManualControlOutput un_manual_control_output;// 手动控制数据,返回给请求者
|
||
extern UnAutoControlOutput un_auto_control_output; // 自动控制数据输出,返回给请求者
|
||
extern UnMotorStatusOutput un_motor_Status_Output;// 电机状态信息,输出给上位机
|
||
|
||
//变量
|
||
extern uint8_t test_app[26];
|
||
|
||
|
||
|
||
|
||
//函数
|
||
void canSendAll(void);
|
||
void ethernetSendAll(void *signal_id);
|
||
|
||
#pragma pack()
|
||
|
||
#endif /* _INTERFACE_H_ */
|