#pragma once #include /** * @brief XSYNC协议端口 */ #define IFLYTOP_XSYNC_PORT 19973 /** * @brief * 协议说明 * * kxsync_packet_type_reg_read: * tx: regadd * rx: ecode,regdata * * kxsync_packet_type_reg_write * tx: regadd,regdata * rx: ecode,regdata * * kxsync_packet_type_reg_read_regs * tx: regstartadd,nreg * rx: ecode,regdatas * */ typedef enum { kxsync_packet_type_none = 0, kxsync_packet_type_reg_read = 1, kxsync_packet_type_reg_write = 2, kxsync_packet_type_reg_read_regs = 3, } xsync_protocol_cmd_t; typedef enum { kxsync_packet_type_cmd = 0, kxsync_packet_type_receipt = 1, } xsync_protocol_packet_type_t; #pragma pack(1) typedef struct { uint16_t type; uint16_t index; uint16_t cmd; uint16_t ndata; uint32_t data[]; // first is always checksum /*uint8_t checksum*/ } iflytop_xsync_packet_header_t; #define XYSNC_REG_DEVICE_INFO_START_ADD 0 #define XYSNC_REG_STM32_CONFIG_START_ADD 16 typedef enum { /** * @brief * REG 0(16) 设备信息基础寄存器 */ kxsync_reg_software_version = 0, kxsync_reg_manufacturer = 1, kxsync_reg_product_type_id = 2, /** * @brief * REG 16(32) STM32配置寄存器0 */ kxsync_reg_stm32_obtaining_ip_mode = XYSNC_REG_STM32_CONFIG_START_ADD + 0, kxsync_reg_stm32_ip = XYSNC_REG_STM32_CONFIG_START_ADD + 1, kxsync_reg_stm32_gw = XYSNC_REG_STM32_CONFIG_START_ADD + 2, kxsync_reg_stm32_netmask = XYSNC_REG_STM32_CONFIG_START_ADD + 3, } xsync_reg_add_t; typedef enum { obtaining_ip_mode_type_static = 0, obtaining_ip_mode_type_dhcp = 1 } obtaining_ip_mode_t; static inline const char* obtaining_ip_mode_to_string(obtaining_ip_mode_t mode) { switch (mode) { case obtaining_ip_mode_type_static: return "static"; case obtaining_ip_mode_type_dhcp: return "dhcp"; default: return "unknown"; } } #pragma pack()