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.

181 lines
5.8 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. #pragma once
  2. #include <stdint.h>
  3. /**
  4. * @brief XSYNCЭ˿
  5. */
  6. #define IFLYTOP_XSYNC_SERVICE_XSYNC_PORT 19900 // xsync�˶˿�
  7. #define IFLYTOP_XSYNC_SERVICE_PC_PORT 19901 // pc �˶˿�
  8. #define IFLYTOP_XSYNC_TIMECODE_REPORT_XSYNC_PORT 19902 // xsync�˶˿�
  9. #define IFLYTOP_XSYNC_TIMECODE_REPORT_PC_PORT 19903 // pc�˶˿�
  10. #define IFLYTOP_XSYNC_CAMERA_SYNC_PACKET_XSYNC_PORT 13013 // xsync�˶˿�
  11. #define IFLYTOP_XSYNC_CAMERA_SYNC_PACKET_PC_PORT 13014 // pc�˶˿�
  12. /**
  13. * @brief
  14. * Э˵
  15. *
  16. * kxsync_packet_type_reg_read:
  17. * tx: regadd
  18. * rx: ecode,regdata
  19. *
  20. * kxsync_packet_type_reg_write
  21. * tx: regadd,regdata
  22. * rx: ecode,regdata
  23. *
  24. * kxsync_packet_type_reg_read_regs
  25. * tx: regstartadd,nreg
  26. * rx: ecode,regdatas
  27. *
  28. */
  29. typedef enum {
  30. kxsync_packet_type_none = 0,
  31. kxsync_packet_type_reg_read = 1,
  32. kxsync_packet_type_reg_write = 2,
  33. kxsync_packet_type_reg_read_regs = 3,
  34. kxsync_packet_type_timecode_report = 4,
  35. } xsync_protocol_cmd_t;
  36. typedef enum {
  37. kxsync_packet_type_cmd = 0,
  38. kxsync_packet_type_receipt = 1,
  39. kxsync_packet_type_report = 2,
  40. } xsync_protocol_packet_type_t;
  41. typedef enum {
  42. kxs_ec_success = 0,
  43. kxs_ec_overtime = 1,
  44. kxs_ec_socket_fail = 2,
  45. kxs_ec_bind_fail = 3,
  46. kxs_ec_send_fail = 4,
  47. kxs_ec_receive_fail = 5,
  48. kxs_ec_setsockopt_rx_timeout_fail = 6,
  49. kxs_ec_lose_connect = 7,
  50. } xs_error_code_t;
  51. static inline const char* xs_error_code_2_str(xs_error_code_t ecode) {
  52. switch (ecode) {
  53. case kxs_ec_success:
  54. return "success";
  55. case kxs_ec_overtime:
  56. return "overtime";
  57. case kxs_ec_socket_fail:
  58. return "socket fail";
  59. case kxs_ec_bind_fail:
  60. return "bind fail";
  61. case kxs_ec_send_fail:
  62. return "send fail";
  63. case kxs_ec_receive_fail:
  64. return "receive fail";
  65. case kxs_ec_setsockopt_rx_timeout_fail:
  66. return "setsockopt rx timeout fail";
  67. case kxs_ec_lose_connect:
  68. return "lose connect";
  69. default:
  70. return "unknown error";
  71. }
  72. }
  73. #pragma pack(1)
  74. typedef struct {
  75. uint16_t type;
  76. uint16_t index;
  77. uint16_t cmd;
  78. uint16_t ndata;
  79. uint32_t data[]; // first is always checksum
  80. } iflytop_xsync_packet_header_t;
  81. typedef struct {
  82. uint32_t timecode0;
  83. uint32_t timecode1;
  84. } iflytop_timecode_report_packet_t;
  85. #define XYSNC_REG_DEVICE_INFO_START_ADD 0
  86. #define XYSNC_REG_STM32_CONFIG_START_ADD 16
  87. #define XYSNC_REG_FPGA_REG_START 32
  88. typedef enum {
  89. /**
  90. * @brief
  91. * REG 0(16) ϢĴ
  92. */
  93. kxsync_reg_software_version = 0,
  94. kxsync_reg_manufacturer0 = 1,
  95. kxsync_reg_manufacturer1 = 2,
  96. kxsync_reg_product_type_id = 3,
  97. kxsync_reg_sn_id0 = 4,
  98. kxsync_reg_sn_id1 = 5,
  99. kxsync_reg_sn_id2 = 6,
  100. kxsync_reg_mac0 = 7,
  101. kxsync_reg_mac1 = 8,
  102. /**
  103. * @brief
  104. * REG 16(32) STM32üĴ0
  105. */
  106. kxsync_reg_stm32_obtaining_ip_mode = XYSNC_REG_STM32_CONFIG_START_ADD + 0,
  107. kxsync_reg_stm32_ip = XYSNC_REG_STM32_CONFIG_START_ADD + 1,
  108. kxsync_reg_stm32_gw = XYSNC_REG_STM32_CONFIG_START_ADD + 2,
  109. kxsync_reg_stm32_netmask = XYSNC_REG_STM32_CONFIG_START_ADD + 3,
  110. kxsync_reg_stm32_camera_sync_signal_count = XYSNC_REG_STM32_CONFIG_START_ADD + 4, // д������ֵ֮������
  111. kxsync_reg_stm32_config0 = XYSNC_REG_STM32_CONFIG_START_ADD + 5, // bit0: timecode report enable, bit1: camera sync report enable
  112. kxsync_reg_stm32_action0 = XYSNC_REG_STM32_CONFIG_START_ADD + 14, // action reg
  113. kxsync_reg_stm32_action_val0 = XYSNC_REG_STM32_CONFIG_START_ADD + 15, // action val reg
  114. /**
  115. * @brief
  116. * REG 48(32) FPGAüĴ0
  117. */
  118. kxsync_fpga_reg_test_reg0 = XYSNC_REG_FPGA_REG_START + 16 * 0 + 0,
  119. kxsync_fpga_reg_test_reg1 = XYSNC_REG_FPGA_REG_START + 16 * 0 + 1,
  120. kxsync_fpga_reg_test_reg2 = XYSNC_REG_FPGA_REG_START + 16 * 0 + 2,
  121. kxsync_fpga_reg_test_reg3 = XYSNC_REG_FPGA_REG_START + 16 * 0 + 3,
  122. kxsync_fpga_reg_test_reg4 = XYSNC_REG_FPGA_REG_START + 16 * 0 + 4,
  123. kxsync_fpga_reg_test_reg5 = XYSNC_REG_FPGA_REG_START + 16 * 0 + 5,
  124. kxsync_fpga_reg_test_reg6 = XYSNC_REG_FPGA_REG_START + 16 * 0 + 6,
  125. kxsync_fpga_reg_test_reg7 = XYSNC_REG_FPGA_REG_START + 16 * 0 + 7,
  126. kxsync_fpga_reg_test_reg8 = XYSNC_REG_FPGA_REG_START + 16 * 0 + 8,
  127. kxsync_fpga_reg_test_reg9 = XYSNC_REG_FPGA_REG_START + 16 * 0 + 9,
  128. kxsync_fpga_reg_test_rega = XYSNC_REG_FPGA_REG_START + 16 * 0 + 10,
  129. kxsync_fpga_reg_test_regb = XYSNC_REG_FPGA_REG_START + 16 * 0 + 11,
  130. kxsync_fpga_reg_test_regc = XYSNC_REG_FPGA_REG_START + 16 * 0 + 12,
  131. kxsync_fpga_reg_test_regd = XYSNC_REG_FPGA_REG_START + 16 * 0 + 13,
  132. kxsync_fpga_reg_test_rege = XYSNC_REG_FPGA_REG_START + 16 * 0 + 14,
  133. kxsync_fpga_reg_test_regf = XYSNC_REG_FPGA_REG_START + 16 * 0 + 15,
  134. } xsync_reg_add_t;
  135. #define KXSYNC_REG_STM32_CONFIG0_MASK_TIMECODE_REPORT_ENABLE 0x01
  136. #define KXSYNC_REG_STM32_CONFIG0_MASK_CAMERA_SYNC_REPORT_ENABLE 0x02
  137. typedef enum {
  138. xsync_stm32_action_none, //
  139. xsync_stm32_action_generator_new_mac, //
  140. xsync_stm32_action_factory_reset, //
  141. xsync_stm32_action_reboot, //
  142. xsync_stm32_action_storage_cfg, //
  143. } xsync_stm32_action_t;
  144. typedef enum {
  145. kxsync_device_type_none = 0,
  146. kxsync_device_type_xsync = 1,
  147. kxsync_device_type_puck_station = 2,
  148. kxsync_device_type_encoder = 3,
  149. } xsync_device_type_t;
  150. typedef enum { obtaining_ip_mode_type_static = 0, obtaining_ip_mode_type_dhcp = 1 } obtaining_ip_mode_t;
  151. static inline const char* obtaining_ip_mode_to_string(obtaining_ip_mode_t mode) {
  152. switch (mode) {
  153. case obtaining_ip_mode_type_static:
  154. return "static";
  155. case obtaining_ip_mode_type_dhcp:
  156. return "dhcp";
  157. default:
  158. return "unknown";
  159. }
  160. }
  161. #pragma pack()