You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
1.9 KiB

2 years ago
  1. #pragma once
  2. #include <stdint.h>
  3. /**
  4. * @brief XSYNCЭ˿
  5. */
  6. #define IFLYTOP_XSYNC_PORT 19973
  7. /**
  8. * @brief
  9. * Э˵
  10. *
  11. * kxsync_packet_type_reg_read:
  12. * tx: regadd
  13. * rx: ecode,regdata
  14. *
  15. * kxsync_packet_type_reg_write
  16. * tx: regadd,regdata
  17. * rx: ecode,regdata
  18. *
  19. * kxsync_packet_type_reg_read_regs
  20. * tx: regstartadd,nreg
  21. * rx: ecode,regdatas
  22. *
  23. */
  24. typedef enum {
  25. kxsync_packet_type_none = 0,
  26. kxsync_packet_type_reg_read = 1,
  27. kxsync_packet_type_reg_write = 2,
  28. kxsync_packet_type_reg_read_regs = 3,
  29. } xsync_protocol_cmd_t;
  30. typedef enum {
  31. kxsync_packet_type_cmd = 0,
  32. kxsync_packet_type_receipt = 1,
  33. } xsync_protocol_packet_type_t;
  34. #pragma pack(1)
  35. typedef struct {
  36. uint16_t type;
  37. uint16_t index;
  38. uint16_t cmd;
  39. uint16_t ndata;
  40. uint32_t data[]; // first is always checksum
  41. /*uint8_t checksum*/
  42. } iflytop_xsync_packet_header_t;
  43. #define XYSNC_REG_DEVICE_INFO_START_ADD 0
  44. #define XYSNC_REG_STM32_CONFIG_START_ADD 16
  45. typedef enum {
  46. /**
  47. * @brief
  48. * REG 0(16) ϢĴ
  49. */
  50. kxsync_reg_software_version = 0,
  51. kxsync_reg_manufacturer = 1,
  52. kxsync_reg_product_type_id = 2,
  53. /**
  54. * @brief
  55. * REG 16(32) STM32üĴ0
  56. */
  57. kxsync_reg_stm32_obtaining_ip_mode = XYSNC_REG_STM32_CONFIG_START_ADD + 0,
  58. kxsync_reg_stm32_ip = XYSNC_REG_STM32_CONFIG_START_ADD + 1,
  59. kxsync_reg_stm32_gw = XYSNC_REG_STM32_CONFIG_START_ADD + 2,
  60. kxsync_reg_stm32_netmask = XYSNC_REG_STM32_CONFIG_START_ADD + 3,
  61. } xsync_reg_add_t;
  62. typedef enum { obtaining_ip_mode_type_static = 0, obtaining_ip_mode_type_dhcp = 1 } obtaining_ip_mode_t;
  63. static inline const char* obtaining_ip_mode_to_string(obtaining_ip_mode_t mode) {
  64. switch (mode) {
  65. case obtaining_ip_mode_type_static:
  66. return "static";
  67. case obtaining_ip_mode_type_dhcp:
  68. return "dhcp";
  69. default:
  70. return "unknown";
  71. }
  72. }
  73. #pragma pack()