#ifndef _INTERFACE_H_ #define _INTERFACE_H_ #include "stdint.h" #include "app/app_config.h" // 假设包含基础配置和宏定义 #include "irq.h" #include "interface_config.h" #include #pragma pack(1)//数据结构一个字节对齐 #define REQUEST_READ_ID un_request_frame.bit_data.request_id//读取ID #define REQUEST_HEADER_ID un_request_frame.bit_data.frame_header//帧头 #define FAULT 0 #define NORMAL 1 //-----CAN---------------------------------------------------------------- // 接收电机控制器输入 typedef struct _StrMotorInput { //-----接收数据0x101或者0x201---------------------------------------------- unsigned int speed : 16; // 转速 偏移量 -30000 unsigned int bus_voltage : 16; // 母线电压 系数 0.1 偏移量 -3000 unsigned int torque : 16; // 扭矩 系数 0.01 偏移量 -300 实际物理量=数据×系数+偏移量 unsigned int fault_code : 8; // 故障码 unsigned int heartbeat : 8; // 心跳 } StrMotorInput; typedef union _UnMotorInput { StrMotorInput bit_data; // 使用定义的结构体变量名 uint8_t arr[sizeof(StrMotorInput)]; // 通过结构体类型确定大小 } UnMotorInput; // 接收电机控制器输入 typedef struct _StrCanDebugOutput { uint8_t speed; uint8_t desired_speed; uint8_t curvature; uint8_t desired_curvature; uint16_t set_left_out; uint16_t set_right_out; } StrCanDebugOutput; typedef union _UnCanDebugOutput { StrCanDebugOutput bit_data; // 使用定义的结构体变量名 uint8_t arr[sizeof(StrCanDebugOutput)]; // 通过结构体类型确定大小 } UnCanDebugOutput; typedef struct _StrMotorTempInput { //-----接收数据0x103或者0x104---------------------------------------------- unsigned int controller_temp : 8; // 控制器温度 偏移量 -40 unsigned int motor_temp : 8; // 电机温度 偏移量 -40 unsigned int motor_max_torque: 16; // 电机最大扭矩 系数 0.01 偏移量 -300 实际物理量=数据×系数+偏移量 unsigned int reserved_1 : 8; // 保留1 unsigned int reserved_2 : 8; // 保留2 unsigned int reserved_3 : 8; // 保留3 unsigned int heartbeat2 : 8; // 心跳 } StrMotorTempInput; typedef union _UnMotorTempInput { StrMotorTempInput bit_data; // 使用定义的结构体变量名 uint8_t arr[sizeof(StrMotorInput)]; // 通过结构体类型确定大小 } UnMotorTempInput; // 接收BMS输入 typedef struct _StrBmsInput { //----接收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 1% unsigned int crc2 : 16; //crc } StrBmsInput; typedef union _UnBmsInput { StrBmsInput bit_data; // 使用定义的结构体变量名 uint8_t arr[sizeof(StrBmsInput)]; // 通过结构体类型确定大小 } UnBmsInput; // 接收温度模块输入 typedef struct _StrTempModuleInput { //-----接收数据0x301,302---------------------------------------------- // 多字节数据,高位在前,低位在后 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 } StrTempModuleInput; typedef union _UnTempModuleInput { StrTempModuleInput bit_data; // 使用定义的结构体变量名 uint8_t arr[sizeof(StrTempModuleInput)]; // 通过结构体类型确定大小 } UnTempModuleInput; //-----以太网------------------------------------------------------------- // 接收自主计算机自动输入 typedef struct _StrAutoComputerInput { // 多字节数据,高位在前,低位在后 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位 } StrAutoComputerInput; typedef union _UnAutoComputerInput { StrAutoComputerInput bit_data; // 使用定义的结构体变量名 uint8_t arr[sizeof(StrAutoComputerInput)]; // 通过结构体类型确定大小 } UnAutoComputerInput; // 接收自主计算机手动输入 typedef struct _StrManualComputerInput { // 手动控制数据 高位在前,低位在后 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位 } StrManualComputerInput; typedef union _UnManualComputerInput { StrManualComputerInput bit_data; // 使用定义的结构体变量名 unsigned int arr[sizeof(StrManualComputerInput) / sizeof(unsigned int)]; // 通过结构体类型确定大小 } UnManualComputerInput; // 接收请求帧 typedef struct _StrRequestFrame { //-------------------------------------------------- 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位 } StrRequestFrame; typedef union _UnRequestFrame { StrRequestFrame bit_data; // 使用定义的结构体变量名 unsigned char arr[sizeof(StrRequestFrame)]; // 通过结构体类型确定大小 } UnRequestFrame; // 接收遥控器输入 typedef struct _StrRemoteControlInput { //-----接收数据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 急停开关 1释放 0/2是急停 unsigned int switch_c : 2; // SwC 模式开关 1自动 0/2是手动 unsigned int switch_d : 1; // SwD 上电开关 先短按再长按 unsigned int reserve2 : 1; // 保留 unsigned int reserve3 : 1; // 保留 unsigned int enable : 8; // 使能 } StrRemoteControlInput; typedef union _UnRemoteControlInput { StrRemoteControlInput bit_data; // 使用定义的结构体变量名 uint8_t arr[sizeof(StrRemoteControlInput)]; // 通过结构体类型确定大小 } UnRemoteControlInput; //-----IO口--------------------------------------------------------------- // 从IO口输入 //20250116 增加温度采集字节 typedef struct _StrSwSample { unsigned int emergency_stop_switch : 1; // 通道1,急停开关 unsigned int High_voltage_switch : 1; // 通道2,高压开关 unsigned int flg_wake_ecu : 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; unsigned int temperature[2]; // 温度 } StrSwSample; typedef union _UnSwSample { StrSwSample bit_data; // 使用定义的结构体变量名 unsigned char arr[sizeof(StrSwSample)]; // 通过结构体类型确定大小 } UnSwSample; //-----输出数据结构--------------------------------------------------------------- //-----CAN---------------------------------------------------------------- // 输出到电机控制器 typedef struct _StrMotorOutput { //-----发送数据0x201或者0x202---------------------------------------------- unsigned int mode : 8; // 模式 0x1恒速模式,0x2恒扭模式,其他无效 unsigned int gear : 8; // 档位 0x0空挡模式,0x1前进挡,0x2倒退档,其他无效 unsigned int set_torque : 16; // 给定扭矩 系数 0.01 偏移量 -300 实际物理量=数据×系数+偏移量 unsigned int set_rotation_speed : 16; // 给定转速 偏移量 -30000 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; // 保留 } StrMotorOutput; typedef union _UnMotorOutput { StrMotorOutput bit_data; // 使用定义的结构体变量名 uint8_t arr[sizeof(StrMotorOutput)]; // 通过结构体类型确定大小 } UnMotorOutput; // 输出到采集模块 typedef struct _StrGatherOutput { //----- Send Data 0x15000002 ---------------------------------------------- unsigned int sleep_duration : 16; // 休眠时间 unsigned int wakeup_interval : 16; // 唤醒时间 unsigned int vehicle_mode : 8; // 整车模式 unsigned int reserved1 : 8; // 保留1 unsigned int reserved2 : 8; // 保留2 unsigned int reserved3 : 8; // 保留3 } StrGatherOutput; typedef union _UnGatherOutput { StrGatherOutput bit_data; // 使用定义的结构体变量名 uint8_t arr[sizeof(StrGatherOutput)]; // 通过结构体类型确定大小 } UnGatherOutput; // canoe协议输出 typedef struct _StrSdoOutput { //-----发送数据0x601---------------------------------------------- unsigned int cmd : 8; // 命令 unsigned int object_index : 16; // 索引 unsigned int sub_index : 8; // 从索引 unsigned int data : 32; // 数据 } StrSdoOutput; typedef union _UnSdoOutput { StrSdoOutput bit_data; // 使用定义的结构体变量名 uint8_t arr[sizeof(StrSdoOutput)]; // 通过结构体类型确定大小 } UnSdoOutput; // 超声波数据发送 typedef struct _StrUltrasonicOutput { //-----发送数据0x521---------------------------------------------- uint8_t node; // 节点 uint8_t function_code; // 功能码 uint16_t register_address; // 寄存器地址 uint16_t data; // 数据 uint16_t reserve;// 保留 } StrUltrasonicOutput; typedef union _UnUltrasonicOutput { StrUltrasonicOutput bit_data; // 使用定义的结构体变量名 uint8_t arr[sizeof(StrUltrasonicOutput)]; // 通过结构体类型确定大小 } UnUltrasonicOutput; // 超声波数据读取 typedef struct _StrUltrasonicIntput { //-----发送数据0x521---------------------------------------------- uint8_t node; // 节点 uint8_t function_code; // 功能码 uint8_t len; // 长度 uint16_t data; // 数据 uint8_t reserve1;// 保留 uint16_t reserve2;// 保留 } StrUltrasonicInput; typedef union _UnUltrasonicInput { StrUltrasonicInput bit_data; // 使用定义的结构体变量名 uint8_t arr[sizeof(StrUltrasonicInput)]; // 通过结构体类型确定大小 } UnUltrasonicInput; //typedef struct _StrMotorOutput //{ ////-----发送数据0x10F80807---------------------------------------------- // unsigned int gear : 2; // 0 表示空挡,1 表示前进,2 表示后退 // unsigned int can_gear : 1; // 0-无效 1-有效。无效时 BIT10 的挡位无效,以线路控制挡位为准 // unsigned int can_break : 1; // 0:不刹车,1-刹车(刹车时才能启动电子刹车) // unsigned int reserve1 : 1; // 0-只有高速档 1-可以通过接线切换 123 档。 // unsigned int reserve2 : 1; // 0-无效 1-有效:线控防盗使能 // unsigned int reserve3 : 1; // 0-无效 1-有效:线控巡航使能 // unsigned int reserve4 : 1; // 0-无效 1-有效:线控座桶使能 // // unsigned int reserve5 : 1; // 0-无效 1-有效:线控边撑使能 // unsigned int reserve6 : 1; // 0-无效 1-有效:线控防盗使能 // unsigned int reserve7 : 1; // 0-无效 1-有效:线控巡航使能 // unsigned int reserve8 : 1; // 0-无效 1-有效:线控座桶使能 // unsigned int reserve9 : 1; // 0-无效 1-有效:线控巡航使能 // unsigned int reserve10 : 1; // 0-无效 1-有效:线控座桶使能 // unsigned int reserve11 : 1; // 0-无效 1-有效:线控巡航使能 // unsigned int reserve12 : 1; // 0-无效 1-有效:线控座桶使能 // // unsigned int reserve13 : 1; // 0-无效 1-有效:线控边撑使能 // unsigned int reserve14 : 1; // 0-无效 1-有效:线控防盗使能 // unsigned int reserve15 : 1; // 0-无效 1-有效:线控巡航使能 // unsigned int reserve16 : 1; // 0-无效 1-有效:线控座桶使能 // unsigned int reserve17 : 1; // 0-无效 1-有效:线控巡航使能 // unsigned int reserve18 : 1; // 0-无效 1-有效:线控座桶使能 // unsigned int motor_direction : 1; // 0 和 1 (静止空闲状态设置有效,在油门、 转矩、转速模式下允许设置,否则使用控制器 内部保存的参数控制电机方向) // unsigned int Contactor : 1; // 0-断开 1-闭合,(部分控制器支持) // // unsigned int reserve19 : 1; // 0-无效 1-有效:线控边撑使能 // unsigned int reserve20 : 1; // 0-无效 1-有效:线控防盗使能 // unsigned int reserve21 : 1; // 0-无效 1-有效:线控巡航使能 // unsigned int reserve22 : 1; // 0-无效 1-有效:线控座桶使能 // unsigned int mode : 4; //0x0:转把控制,0x5:油门模式,0xA:转矩模式, 0xC:转速模式,其它无效停机。在这三种模式下,电机方向设置有效。只允许在停机状态下设置控制模式。 // // unsigned int control_data1 : 16; // 油门-256~+256:(0~+256 表示最大油门,-256 表 示最大电子刹车力度。转矩 -256~10000,(正数 驱 动 扭 矩 0~1000.0Nm,负数表示刹车,-256 表示最大电子刹车力度)转速-256~12000,(正数表示转速 0~12000rpm, 负数表示刹车,-256 最大刹车力度) // unsigned int control_data2 : 16; // 控制数据和上一个一样 //} StrMotorOutput; // //typedef union _UnMotorOutput //{ // StrMotorOutput bit_data; // 使用定义的结构体变量名 // uint8_t arr[sizeof(StrMotorOutput)]; // 通过结构体类型确定大小 //} UnMotorOutput; //电机控制器风扇左 //kgf1 //电机控制器风扇右 //kgf3 //预充 //kgf4 //高压压继电器 //kgf7,8 //低压继电器 //kgf11-12 //左前红灯 //kgf6 //左前黄灯 //kgf9 //左风扇 //kgf14 //右风扇 //kgf19 //电脑 //kgf 17-18 //交换机 //kgf 21-22 //右前红灯 //kgf24 //右前黄灯 //kgf25 //左后红灯 //kgf26 //左后黄灯 //kgf27 //右后红灯 //kgf29 //右后黄灯 //kgf30 // 输出到开关阀模块 typedef struct _StrInfCanKGFOutput { //----------主机发送命令字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 } StrInfCanKGFOutput; typedef union _UnInfCanKGFOutput { StrInfCanKGFOutput bit_data; // 使用定义的结构体变量名 uint8_t arr[sizeof(StrInfCanKGFOutput)]; // 通过结构体类型确定大小 } UnInfCanKGFOutput; // 输出到H桥模块 typedef struct _StrHBridgeOutput { //----------主机发送命令字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 } StrHBridgeOutput; typedef union _UnHBridgeOutput { StrHBridgeOutput bit_data; // 使用定义的结构体变量名 uint8_t arr[sizeof(StrHBridgeOutput)]; // 通过结构体类型确定大小 } UnHBridgeOutput; // 输出给导航仪 typedef struct _StrWheelSpeedOutput { //-----发送数据0x98---------------------------------------------- unsigned int left_front : 16; // 左前轮速 unsigned int right_front : 16; // 右前轮速 unsigned int left_rear : 16; // 左后轮速 unsigned int right_rear : 16; // 右后轮速 } StrWheelSpeedOutput; typedef union _UnWheelSpeedOutput { StrWheelSpeedOutput bit_data; // 使用定义的结构体变量名 uint8_t arr[sizeof(StrWheelSpeedOutput)]; // 通过结构体类型确定大小 } UnWheelSpeedOutput; // 输出给基站升降杆 typedef struct _StrLifterOutput { //-----发送数据0x6F2---------------------------------------------- unsigned int cmd : 8 ; // 上升命令 unsigned int reserve1 : 8 ; // 保留 unsigned int reserve2 : 16; // 保留 unsigned int reserve3 : 16; // 保留 unsigned int reserve4 : 16; // 保留 } StrLifterOutput; typedef union _UnrLifterOutput { StrLifterOutput bit_data; // 使用定义的结构体变量名 uint8_t arr[sizeof(StrLifterOutput)]; // 通过结构体类型确定大小 } UnLifterOutput; //-----以太网------------------------------------------------------------- // 输出给自主计算机 typedef struct _StrComputerOutput { //-------------------------------------------------- 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 speed : 16; // 左侧轮速 unsigned int curvature : 16; // 右侧轮速 unsigned int crc : 8; // CRC } StrComputerOutput; typedef union _UnComputerOutput { StrComputerOutput bit_data; // 使用定义的结构体变量名 uint8_t arr[sizeof(StrComputerOutput)]; // 通过结构体类型确定大小 } UnComputerOutput; // 车辆信息,输出给上位机 typedef struct _StrVehicleInfoOutput { //-------------------------------------------------- unsigned int frame_header : 16; // 帧头 固定值0xAACC unsigned int frame_type : 16; // 帧类型 固定值0x0020 unsigned int frame_length : 16; // 帧长 固定值41 unsigned int accumulated : 8; // 累加值 按帧累加 unsigned int desired_speed : 16; // 期望速度 系数0.01, 正为前进,负为后退 单位m/s unsigned int desired_curvature : 16; // 期望曲率 系数0.0001,正为左转,负为右转 unsigned int set_left_speed : 16; // 设定左转速度 电机1设定转速 正为正传,负为反转 unsigned int set_right_speed : 16; // 设定右转速度 电机2设定转速 正为正传,负为反转 unsigned int longitude : 32; // 纬度 系数 1e-7 值域(-180°,180°) unsigned int latitude : 32; // 经度 系数 1e-7 值域(-90°,90°) unsigned int altitude : 32; // 高度 unsigned int heading_angle : 16; // 航向角 系数 0.01 值域(0-360°) unsigned int speed : 16; // 当前车速 系数 0.01 正为前进,负为后退 单位m/s unsigned int curvature : 16; // 当前曲率 系数 0.0001正为左转,负为右转 unsigned int battery_voltage : 16; // 电池电压 系数 0.1 单位V unsigned int battery_soc : 16; // 电池SOC 系数 0.1 单位:% unsigned int battery_current : 16; // 电池电流 系数 0.1 偏移量 -30000 单位A unsigned int vehicle_fault_state : 8; // 整车故障状态 0 故障 1正常 unsigned int crc : 8; // CRC 按字节累加之和 取低8位 } StrVehicleInfoOutput; typedef union _UnVehicleInfoOutput { StrVehicleInfoOutput bit_data; // 使用定义的结构体变量名 unsigned char arr[sizeof(StrVehicleInfoOutput)]; // 通过结构体类型确定大小 } UnVehicleInfoOutput; // 电机状态信息,输出给上位机 typedef struct _StrMotorStatusOutput { //-------------------------------------------------- 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_torque : 16; // 左侧电机扭矩 系数 0.01 偏移量 -300 单位N/s unsigned int right_torque : 16; // 右侧电机扭矩 系数 0.01 偏移量 -300 单位N/s unsigned int left_fault_code : 8; // 左侧电机故障码 unsigned int right_fault_code : 8; // 右侧电机故障码 unsigned int left_torque_limit : 16; // 左侧电机扭矩限制 系数 0.01 偏移量 -300 单位N/s unsigned int right_torque_limit : 16; // 右侧电机扭矩限制 系数 0.01 偏移量 -300 单位N/s unsigned int left_power_in : 16; // 左侧电机馈电功率 系数 1 偏移量 0 单位W unsigned int right_power_in : 16; // 右侧电机馈电功率 系数 1 偏移量 0 单位W unsigned int left_power_out : 16; // 左侧电机放电功率 系数 1 偏移量 0 单位W unsigned int right_power_out : 16; // 右侧电机放电功率 系数 1 偏移量 0 单位W unsigned int left_voltage : 16; // 左侧电机电压 系数0.1 偏移量-3000 单位V unsigned int right_voltage : 16; // 右侧电机电压 系数0.1 偏移量-3000 单位V unsigned int checksum : 8; // 校验和 按字节累加之和 取低8位 } StrMotorStatusOutput; typedef union _UnMotorStatusOutput { StrMotorStatusOutput bit_data; // 使用定义的结构体变量名 unsigned char arr[sizeof(StrMotorStatusOutput)]; // 通过结构体类型确定大小 } UnMotorStatusOutput; // PID参数输出,输出给上位机 typedef struct _StrPIDOutput { //-------------------------------------------------- unsigned int frame_header : 16; // 帧头 固定值0xAACC unsigned int frame_type : 16; // 帧类型 固定值0x0022 unsigned int frame_length : 16; // 帧长 固定值56 unsigned int accumulated : 8; // 累加值 按帧累加 unsigned int rc_straight_p : 32; // 遥控直行P参数 系数 0.001 unsigned int rc_straight_i : 32; // 遥控直行I参数 系数 0.001 unsigned int rc_straight_d : 32; // 遥控直行D参数 系数 0.001 unsigned int auto_straight_p : 32; // 自主直行P参数 系数 0.001 unsigned int auto_straight_i : 32; // 自主直行I参数 系数 0.001 unsigned int auto_straight_d : 32; // 自主直行D参数 系数 0.001 unsigned int rc_turn_p : 32; // 遥控转弯P参数 系数 0.001 unsigned int rc_turn_i : 32; // 遥控转弯I参数 系数 0.001 unsigned int rc_turn_d : 32; // 遥控转弯D参数 系数 0.001 unsigned int auto_turn_p : 32; // 自主转弯P参数 系数 0.001 unsigned int auto_turn_i : 32; // 自主转弯I参数 系数 0.001 unsigned int auto_turn_d : 32; // 自主转弯D参数 系数 0.001 unsigned int checksum : 8; // 校验和 按字节累加之和 取低8位 } StrPIDOutput; typedef union _UnPIDOutput { StrPIDOutput bit_data; // 使用定义的结构体变量名 unsigned char arr[sizeof(StrPIDOutput)]; // 通过结构体类型确定大小 } UnPIDOutput; // 模拟信号输出,输出给上位机 typedef struct _StrAnalogSignalOutput { //-------------------------------------------------- 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位 } StrAnalogSignalOutput; typedef union _UnAnalogSignalOutput { StrAnalogSignalOutput bit_data; // 使用定义的结构体变量名 unsigned char arr[sizeof(StrAnalogSignalOutput)]; // 通过结构体类型确定大小 } UnAnalogSignalOutput; // 遥控器数据输出,给上位机 typedef struct _StrRemoteControlOutput { //-------------------------------------------------- unsigned int frame_header : 16; // 帧头 固定值0xAACC unsigned int frame_type : 16; // 帧类型 固定值0x0024 unsigned int frame_length : 16; // 帧长 固定值20 unsigned int accumulated : 8; // 累加值 按帧累加 // RC6GS遥控原始数据 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位 } StrRemoteControlOutput; typedef union _UnRemoteControlOutput { StrRemoteControlOutput bit_data; // 使用定义的结构体变量名 unsigned char arr[sizeof(StrRemoteControlOutput)]; // 通过结构体类型确定大小 } UnRemoteControlOutput; // 手动控制数据,返回给请求者 typedef struct _StrManualControlOutput { //-------------------------------------------------- // 手动控制数据 高位在前,低位在后 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位 } StrManualControlOutput; typedef union _UnManualControlOutput { StrManualControlOutput bit_data; // 使用定义的结构体变量名 unsigned char arr[sizeof(StrManualControlOutput)]; // 通过结构体类型确定大小 } UnManualControlOutput; // 自动控制数据输出,返回给请求者 typedef struct _StrAutoControlOutput { //-------------------------------------------------- // 自主计算机自动数据 高位在前,低位在后 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 accumulated_value : 16; // 累加值 按帧累加 unsigned int crc : 8 ; // CRC 总体累加CRC } StrAutoControlOutput; typedef union _UnAutoControlOutput { StrAutoControlOutput bit_data; // 使用定义的结构体变量名 unsigned char arr[sizeof(StrAutoControlOutput)]; // 通过结构体类型确定大小 } UnAutoControlOutput; //-----IO口--------------------------------------------------------------- // 电压信号输出,到遥控器 typedef struct _StrVoltageSignalOutput { unsigned int pwm_value : 16; // PWM值 } StrVoltageSignalOutput; typedef union _UnVoltageSignalOutput { StrVoltageSignalOutput bit_data; // 使用定义的结构体变量名 uint8_t arr[sizeof(StrVoltageSignalOutput)]; // 通过结构体类型确定大小 } UnVoltageSignalOutput; //外部数据结构声明 extern UnMotorInput un_motor_input1 ;//电机控制器1 左侧 extern UnMotorInput un_motor_input2 ;//电机控制器2 右侧 extern UnMotorInput un_motor_input3 ;//电机控制器1 左后侧 extern UnMotorInput un_motor_input4 ;//电机控制器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 UnUltrasonicInput un_ultrasonic_input1;//超声波传感器输入1 extern UnUltrasonicOutput un_ultrasonic_output1;//超声波传感器输出 extern UnMotorOutput un_motor_output1; //电机输出 extern UnMotorOutput un_motor_output2; //电机输出 extern UnMotorOutput un_motor_output3; //电机输出 extern UnMotorOutput un_motor_output4; //电机输出 extern UnMotorTempInput un_motor_temp1; //电机控制器1 温度 extern UnMotorTempInput un_motor_temp2; //电机控制器2 温度 extern UnMotorTempInput un_motor_temp3; //电机控制器3 左后侧 extern UnMotorTempInput un_motor_temp4; //电机控制器4 右后侧 extern UnInfCanKGFOutput un_inf_can_kgf_output1; extern UnInfCanKGFOutput un_inf_can_kgf_output2; extern UnHBridgeOutput un_h_bridge_output; extern UnHBridgeOutput un_h_bridge_output1;//H桥输出 extern UnWheelSpeedOutput un_wheel_wpeed_output; extern UnGatherOutput un_gather_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 UnSdoOutput un_sdo_output ;//转向电机输出 //变量 extern uint8_t test_app[26]; extern UnCanDebugOutput un_can_debug_output;//调试输出 //函数 void canSendAll(void *signal_id); void ethernetSendAll(void *signal_id); #pragma pack() #endif /* _INTERFACE_H_ */