telem_structure.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. structures for telemetry packets
  3. This header is common to ArduPilot AP_Radio and STM8 TX code
  4. */
  5. #pragma once
  6. enum telem_type {
  7. TELEM_STATUS= 0, // a telem_status packet
  8. TELEM_PLAY = 1, // play a tune
  9. TELEM_FW = 2, // update new firmware
  10. };
  11. // flags in telem_status structure
  12. #define TELEM_FLAG_GPS_OK (1U<<0)
  13. #define TELEM_FLAG_ARM_OK (1U<<1)
  14. #define TELEM_FLAG_BATT_OK (1U<<2)
  15. #define TELEM_FLAG_ARMED (1U<<4)
  16. #define TELEM_FLAG_POS_OK (1U<<5)
  17. #define TELEM_FLAG_VIDEO (1U<<6)
  18. #define TELEM_FLAG_HYBRID (1U<<7)
  19. struct PACKED telem_status {
  20. uint8_t pps; // packets per second received
  21. uint8_t rssi; // lowpass rssi
  22. uint8_t flags; // TELEM_FLAG_*
  23. uint8_t flight_mode; // flight mode (with profile number in high bit)
  24. uint8_t wifi_chan; // wifi channel number on Sonix
  25. uint8_t tx_max; // max TX power
  26. uint8_t note_adjust; // buzzer tone adjustment
  27. };
  28. // write to new firmware. This is also used to play a tune
  29. struct PACKED telem_firmware {
  30. uint8_t seq;
  31. uint8_t len;
  32. uint16_t offset;
  33. uint8_t data[4];
  34. };
  35. /*
  36. telemetry packet from RX to TX for cypress
  37. */
  38. struct PACKED telem_packet_cypress {
  39. uint8_t crc; // simple CRC
  40. enum telem_type type;
  41. union {
  42. uint8_t pkt[14];
  43. struct telem_status status;
  44. struct telem_firmware fw;
  45. } payload;
  46. };
  47. /*
  48. cc2500 specific protocol structures
  49. */
  50. struct PACKED telem_status_cc2500 {
  51. uint8_t pps; // packets per second received
  52. uint8_t rssi; // lowpass rssi
  53. uint8_t flags; // TELEM_FLAG_*
  54. uint8_t flight_mode; // flight mode (with profile number in high bit)
  55. uint8_t wifi_chan; // wifi channel number on Sonix
  56. uint8_t tx_max; // max TX power
  57. uint8_t note_adjust; // buzzer tone adjustment
  58. uint8_t rxid[2]; // 16 bit ID for cc2500 to prevent double binds
  59. };
  60. /*
  61. telemetry packet from RX to TX for cc2500
  62. */
  63. struct PACKED telem_packet_cc2500 {
  64. uint8_t length;
  65. uint8_t type;
  66. uint8_t txid[2];
  67. union {
  68. uint8_t pkt[9];
  69. struct telem_status_cc2500 status;
  70. struct telem_firmware fw;
  71. } payload;
  72. };
  73. /*
  74. autobind packet from TX to RX for cc2500
  75. */
  76. struct PACKED autobind_packet_cc2500 {
  77. uint8_t length;
  78. uint8_t magic1; // 0xC5
  79. uint8_t magic2; // 0xA2
  80. uint8_t txid[2];
  81. uint8_t txid_inverse[2];
  82. uint8_t wifi_chan;
  83. uint8_t pad[3]; // pad to 13 bytes for fixed packet length
  84. uint8_t crc[2];
  85. };
  86. /*
  87. packet type - controls data field. We have 4 bits, giving 16 possible
  88. data field types
  89. */
  90. enum packet_type {
  91. PKTYPE_VOLTAGE = 0,
  92. PKTYPE_YEAR = 1,
  93. PKTYPE_MONTH = 2,
  94. PKTYPE_DAY = 3,
  95. PKTYPE_TELEM_RSSI = 4,
  96. PKTYPE_TELEM_PPS = 5,
  97. PKTYPE_BL_VERSION = 6,
  98. PKTYPE_FW_ACK = 7,
  99. PKTYPE_RXID1 = 8,
  100. PKTYPE_RXID2 = 9,
  101. PKTYPE_NUM_TYPES = 10 // used for modulus
  102. };
  103. /*
  104. skyrocket specific packet from TX to RX for cc2500
  105. */
  106. struct PACKED srt_packet {
  107. uint8_t length; // required for cc2500 FIFO
  108. uint8_t txid[2];
  109. uint8_t version:4; // protocol version
  110. uint8_t pkt_type:4; // packet type
  111. uint8_t chan1;
  112. uint8_t chan2;
  113. uint8_t chan3;
  114. uint8_t chan4;
  115. uint8_t chan_high;
  116. uint8_t data; // data according to pkt_type
  117. uint8_t buttons; // see channels.h
  118. uint8_t channr;
  119. uint8_t chanskip;
  120. };