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.

184 lines
5.9 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
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. kxs_ec_param_error = 8,
  51. } xs_error_code_t;
  52. static inline const char* xs_error_code_2_str(xs_error_code_t ecode) {
  53. switch (ecode) {
  54. case kxs_ec_success:
  55. return "success";
  56. case kxs_ec_overtime:
  57. return "overtime";
  58. case kxs_ec_socket_fail:
  59. return "socket fail";
  60. case kxs_ec_bind_fail:
  61. return "bind fail";
  62. case kxs_ec_send_fail:
  63. return "send fail";
  64. case kxs_ec_receive_fail:
  65. return "receive fail";
  66. case kxs_ec_setsockopt_rx_timeout_fail:
  67. return "setsockopt rx timeout fail";
  68. case kxs_ec_lose_connect:
  69. return "lose connect";
  70. case kxs_ec_param_error:
  71. return "param error";
  72. default:
  73. return "unknown error";
  74. }
  75. }
  76. #pragma pack(1)
  77. typedef struct {
  78. uint16_t type;
  79. uint16_t index;
  80. uint16_t cmd;
  81. uint16_t ndata;
  82. uint32_t data[]; // first is always checksum
  83. } iflytop_xsync_packet_header_t;
  84. typedef struct {
  85. uint32_t timecode0;
  86. uint32_t timecode1;
  87. } iflytop_timecode_report_packet_t;
  88. #define XYSNC_REG_DEVICE_INFO_START_ADD 0
  89. #define XYSNC_REG_STM32_CONFIG_START_ADD 16
  90. #define XYSNC_REG_FPGA_REG_START 32
  91. typedef enum {
  92. /**
  93. * @brief
  94. * REG 0(16) ϢĴ
  95. */
  96. kxsync_reg_software_version = 0,
  97. kxsync_reg_manufacturer0 = 1,
  98. kxsync_reg_manufacturer1 = 2,
  99. kxsync_reg_product_type_id = 3,
  100. kxsync_reg_sn_id0 = 4,
  101. kxsync_reg_sn_id1 = 5,
  102. kxsync_reg_sn_id2 = 6,
  103. kxsync_reg_mac0 = 7,
  104. kxsync_reg_mac1 = 8,
  105. /**
  106. * @brief
  107. * REG 16(32) STM32üĴ0
  108. */
  109. kxsync_reg_stm32_obtaining_ip_mode = XYSNC_REG_STM32_CONFIG_START_ADD + 0,
  110. kxsync_reg_stm32_ip = XYSNC_REG_STM32_CONFIG_START_ADD + 1,
  111. kxsync_reg_stm32_gw = XYSNC_REG_STM32_CONFIG_START_ADD + 2,
  112. kxsync_reg_stm32_netmask = XYSNC_REG_STM32_CONFIG_START_ADD + 3,
  113. kxsync_reg_stm32_camera_sync_signal_count = XYSNC_REG_STM32_CONFIG_START_ADD + 4, // д������ֵ֮������
  114. kxsync_reg_stm32_config0 = XYSNC_REG_STM32_CONFIG_START_ADD + 5, // bit0: timecode report enable, bit1: camera sync report enable
  115. kxsync_reg_stm32_action0 = XYSNC_REG_STM32_CONFIG_START_ADD + 14, // action reg
  116. kxsync_reg_stm32_action_val0 = XYSNC_REG_STM32_CONFIG_START_ADD + 15, // action val reg
  117. /**
  118. * @brief
  119. * REG 48(32) FPGAüĴ0
  120. */
  121. kxsync_fpga_reg_test_reg0 = XYSNC_REG_FPGA_REG_START + 16 * 0 + 0,
  122. kxsync_fpga_reg_test_reg1 = XYSNC_REG_FPGA_REG_START + 16 * 0 + 1,
  123. kxsync_fpga_reg_test_reg2 = XYSNC_REG_FPGA_REG_START + 16 * 0 + 2,
  124. kxsync_fpga_reg_test_reg3 = XYSNC_REG_FPGA_REG_START + 16 * 0 + 3,
  125. kxsync_fpga_reg_test_reg4 = XYSNC_REG_FPGA_REG_START + 16 * 0 + 4,
  126. kxsync_fpga_reg_test_reg5 = XYSNC_REG_FPGA_REG_START + 16 * 0 + 5,
  127. kxsync_fpga_reg_test_reg6 = XYSNC_REG_FPGA_REG_START + 16 * 0 + 6,
  128. kxsync_fpga_reg_test_reg7 = XYSNC_REG_FPGA_REG_START + 16 * 0 + 7,
  129. kxsync_fpga_reg_test_reg8 = XYSNC_REG_FPGA_REG_START + 16 * 0 + 8,
  130. kxsync_fpga_reg_test_reg9 = XYSNC_REG_FPGA_REG_START + 16 * 0 + 9,
  131. kxsync_fpga_reg_test_rega = XYSNC_REG_FPGA_REG_START + 16 * 0 + 10,
  132. kxsync_fpga_reg_test_regb = XYSNC_REG_FPGA_REG_START + 16 * 0 + 11,
  133. kxsync_fpga_reg_test_regc = XYSNC_REG_FPGA_REG_START + 16 * 0 + 12,
  134. kxsync_fpga_reg_test_regd = XYSNC_REG_FPGA_REG_START + 16 * 0 + 13,
  135. kxsync_fpga_reg_test_rege = XYSNC_REG_FPGA_REG_START + 16 * 0 + 14,
  136. kxsync_fpga_reg_test_regf = XYSNC_REG_FPGA_REG_START + 16 * 0 + 15,
  137. } xsync_reg_add_t;
  138. #define KXSYNC_REG_STM32_CONFIG0_MASK_TIMECODE_REPORT_ENABLE 0x01
  139. #define KXSYNC_REG_STM32_CONFIG0_MASK_CAMERA_SYNC_REPORT_ENABLE 0x02
  140. typedef enum {
  141. xsync_stm32_action_none, //
  142. xsync_stm32_action_generator_new_mac, //
  143. xsync_stm32_action_factory_reset, //
  144. xsync_stm32_action_reboot, //
  145. xsync_stm32_action_storage_cfg, //
  146. } xsync_stm32_action_t;
  147. typedef enum {
  148. kxsync_device_type_none = 0,
  149. kxsync_device_type_xsync = 1,
  150. kxsync_device_type_puck_station = 2,
  151. kxsync_device_type_encoder = 3,
  152. } xsync_device_type_t;
  153. typedef enum { obtaining_ip_mode_type_static = 0, obtaining_ip_mode_type_dhcp = 1 } obtaining_ip_mode_t;
  154. static inline const char* obtaining_ip_mode_to_string(obtaining_ip_mode_t mode) {
  155. switch (mode) {
  156. case obtaining_ip_mode_type_static:
  157. return "static";
  158. case obtaining_ip_mode_type_dhcp:
  159. return "dhcp";
  160. default:
  161. return "unknown";
  162. }
  163. }
  164. #pragma pack()