#ifndef _SOFT_HD_WATER_PUMP_H #define _SOFT_HD_WATER_PUMP_H #include "stdint.h" #include "string.h" #include #include "soft_water_device.h" //================================MSG FRAM================================================ #define HD_CANID_PRI_POS (26) #define HD_CANID_PRI_MASK (0x1C000000) // 1 1100 0000 0000 0000 0000 0000 0000 #define HD_PRI_HIGHEST 0x00 #define HD_CANID_ANONYMOUS (0) #define HD_CANID_ANONYMOUS_POS (24) #define HD_CANID_ANONYMOUS_MASK (0x01000000) // 0 0001 0000 0000 0000 0000 0000 0000 #define HD_CANID_SUBJECT_ID (0) #define HD_CANID_SUBJECT_POS (14) #define HD_CANID_SUBJECT_MASK (0x00FFFF00) // 0 0000 1111 1111 1111 1111 0000 0000 #define HD_CANID_SNM_POS (25) #define HD_CANID_SNM_MASK (0x02000000) // 0 0010 0000 0000 0000 0000 0000 0000 #define HD_TYPE_MSG (0x0) // �㲥֡(message farme) #define HD_TYPE_SER (0x1) // ����֡ #define HD_CANID_REV_7 (0) #define HD_CANID_REV_7_POS (7) #define HD_CANID_REV_7_MASK (0x00000080) // 0 0000 0000 0000 0000 0000 1000 0000 #define HD_CANID_SRCNODE_POS (0) #define HD_CANID_SRCNODE_MASK (0x0000007F) // 0 0000 0000 0000 0000 0000 0111 1111 //#define HD_NODE_BDC 0x0A // �㲥�ڵ� //================================SER FRAM============================================== #define HD_CANID_RNR_POS (24) #define HD_CANID_RNR_MASK (0x01000000) // 0 0001 0000 0000 0000 0000 0000 0000 #define HD_TYPE_RES (0x0) #define HD_TYPE_REQ (0x1) #define HD_CANID_REV_23 (0) #define HD_CANID_REV_23_POS (23) #define HD_CANID_REV_23_MASK (0x800000) // 0 0000 1000 0000 0000 0000 0000 0000 #define HD_CANID_SERID_POS (14) #define HD_CANID_SERID_MASK (0x007FC000) // 0 0000 0111 1111 1100 0000 0000 0000 #define HD_CANID_SERID (0) #define HD_CANID_DESNODE_POS (7) #define HD_CANID_DESNODE_MASK (0x00003F80) // 0 0000 0000 0000 0011 1111 1000 0000 #define FMU_NODE_ID_HD (0x01) // �ɿؽڵ� #define HD_CANID_PUMP_ID (0x08) //ˮ�ýڵ� #define HD_CANID_NOZZLE_0_ID (0x40) //喷头节点 #define HD_CANID_NOZZLE_1_ID (0x41) // #define HD_CANID_NOZZLE_2_ID (0x42) // #define HD_CANID_NOZZLE_3_ID (0x43) // #define HD_CANID_NOZZLE_4_ID (0x44) // //MSG ID //水泵 #define HD_HIGH_FREQ_REPORT_ID (0x34) //水泵控制器-高频状态上报 #define HD_LOW_FREQ_REPORT_ID (0x35) //水泵控制器-低频状态上报 #define HD_WATER_PUMP_CONTROL_ID (0x36) //水泵控制命令 #define HD_FLOWMETER_PULSE_ID (0x44) //水泵控制器-流量计脉冲 #define HD_HEART_ID (0x05) //水泵控制器-心跳 //喷头 #define HD_NOZZLE_HIGH_FREQ_ID (0x37) //喷头控制器-状态上报高频 #define HD_NOZZLE_LOW_FREQ_ID (0x38) //喷头控制器-状态上报低频 #define HD_NOZZLE_CONTROL_ID (0x39) //喷头控制器-控制命令 #define HD_IDENTIFY_ID (0x0D) //喷头控制器-识别 #define HD_SET_NOZZLE_ID (0x09) //喷头控制器-设置id //msg_id crc payload_len 在多帧中占用的字节数量 #define msg_id_len 1 #define crc_len 2 #define length_len 2 //多帧消息类型 #define none 0 //非多帧消息 #define PSL 1 ///水泵控制器低频状态上报 #define SSL 2 //喷头控制器低频状态上报 //多帧消息长度 #define PSL_LEN 21 #define SSL_LEN 14 //HD��֡��Ϣ�ṹ�� typedef struct _HDMsg { uint8_t Msg_id; uint8_t buffer[50]; uint16_t rxindex; uint16_t length; HWTail Tail; HWTail LastTail; bool finish; uint16_t crc; uint8_t len_wrong; uint8_t crc_wrong; uint32_t setEscIdTime; }HDMsg; typedef struct _pump_status { uint8_t LST : 2; //逻辑状态,0:spin; 1:Stop。 uint8_t SST : 3; //子状态,0:Calib; 1:Ready; 2:Align; 3:Startup; 4:Spin; 5:Freewheel。 uint8_t STA : 2; //水泵状态,0:Fault; 1:Init; 2:Stop; 3:Run。 uint8_t rev: 1; } pump_status; typedef struct _MCU_STATUS { uint8_t CMST : 1; //从 MCU 通讯状态,0:在位;1:失联 uint8_t VQST : 1; //从 MCU 版本查询状态,0:版本查询成功;1:版本查询失败 uint8_t REST : 2; //从 MCU 重启状态,0:运行中;1:重启中;2:重启失败。 uint8_t VERS : 2; //从 MCU 版本同步状态,0:已同步;1:版本同步中;2:版本同步失败。 uint8_t PWMS : 1; //从 MCU 同步 PWM 状态,0:信号正常;1:信号丢失。 uint8_t rev: 1; }_MCU_STATUS; typedef struct _fault_code { uint16_t current_high : 1; //母线电流过大 uint16_t vol_low : 1; //母线电压过低 uint16_t vol_high : 1; //母线电压过高 uint16_t overload : 1; // 过载 uint16_t overspeed : 1; // 超速 uint16_t blockage : 1; // 堵转 uint16_t phase_current_high : 1; // 相电流过大 uint16_t phase_current_abnormal : 1; // 相电流偏移值异常 uint16_t temp_high : 1; // 温度过高 uint16_t phase_line_missing : 1; // 相线缺失 uint16_t thr_loss : 1; //油门信号丢失 uint16_t selif_check_abnormal : 1; // 自检异常 uint16_t hard_over_current : 1; // 硬件过流 uint16_t power_abnormal : 1; // 驱动电源异常 uint16_t overheat_open : 1; // 电机过热开路 }_fault_code; typedef struct _pump { uint32_t devID; uint16_t flow1; uint16_t flow2; pump_status pump1_status; pump_status pump2_status; uint16_t pump1_pwm; uint16_t pump2_pwm; uint16_t pump1_speed; uint16_t pump2_speed; _fault_code pump1_fault_code; _fault_code pump2_fault_code; uint16_t pump1_vol; uint16_t pump2_vol; uint8_t pump1_current; uint8_t pump2_current; uint8_t pump1_temp; uint8_t pump2_temp; _MCU_STATUS MCU_status; uint16_t flowmeter1_pulse_interval; uint16_t flowmeter2_pulse_interval; HDMsg MultiMsg; }HDpump; typedef struct _solenoid_valve_status { uint8_t VDS : 1; //电磁阀检测状态,0:关; 1:开。 uint8_t VCS : 1; //电磁阀控制状态,0:关; 1:开。 uint8_t rev : 5; }_solenoid_valve_status; typedef struct _nozzle_status { uint8_t LST : 2; //逻辑状态,0:spin; 1:Stop; 2:Identify_Spin。 uint8_t SST : 3; //喷头子状态,0:Calib; 1:Ready; 2:Align; 3:Startup; 4:Spin; 5:Freewheel。 uint8_t STA : 2; //喷头状态,0:Fault; 1:Init; 2:Stop; 3:Run。 uint8_t PLS : 1; //功率限制标志,0:未限制; 1 限制中。 }_nozzle_status; typedef struct _nozzle { uint32_t devID; uint16_t speed; _solenoid_valve_status solenoid_valve_status; uint16_t speed_command; _nozzle_status nozzle_status; _fault_code fault_code; uint16_t nozzle_vol; uint8_t nozzle_current; uint8_t solenoid_valve_current; uint8_t nozzle_temp; uint16_t motor_power; uint16_t over_current_num; uint16_t hard_over_current_num; uint8_t blockage_frequency; HDMsg MultiMsg; uint8_t nodeId; comp_status deviceLink; uint32_t linkTime; }HDnozzle; typedef struct _nozzle_id { uint32_t devID; uint8_t nodeId; uint32_t linkTime; }_nozzle_id; //extern HDnozzle HD_nozzle; extern HDnozzle NozzleMsg[5]; extern HDpump HD_pump; void HD_pump_func(void); extern void HuiDaCanRecvHookFunction(uint32_t id, uint8_t *recv_buf, uint8_t len); void HD_frame_process(HDMsg *_HDMsg , uint8_t *recv_buf, uint32_t len); void HD_can_sendmsg( uint8_t msg_id, _nozzle_id* Nozzle_id); void little_to_big_16(uint16_t* value) ; void little_to_big_32(uint32_t* value) ; void add_devId(uint8_t SrcId, uint32_t devId); uint32_t millis(void); #endif