config.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. //
  2. // Created by macheng on 2018/5/2.
  3. //
  4. #ifndef _INSTANCE_CONFIG_H_
  5. #define _INSTANCE_CONFIG_H_
  6. //slot count and time
  7. #define TA_SLOT_TIME (4)
  8. #define TA_SLOT_STEP (4)//5~7ms
  9. #define TA_SLOT_COUNT (3)
  10. #define TA_SLOT_FACTOR (1000)
  11. //this it the delay used for configuring the receiver on delay (wait for response delay)
  12. //NOTE: this RX_RESPONSE_TURNAROUND is dependent on the microprocessor and code optimisations
  13. #define RX_RESPONSEX_TURNAROUND (50) //takes about 100 us for response to come back
  14. #define RX_RESPONSE1_TURNAROUND (200) //takes about 200 us for the 1st response to come back (from A0)
  15. #define RX_RESPONSE1_TURNAROUND_6M81 (300) //takes about 100 us for response to come back
  16. #define RX_RESPONSE1_TURNAROUND_110K (300) //takes about 100 us for response to come back
  17. //Tag will range to 3 or 4 anchors
  18. //Each ranging exchange will consist of minimum of 3 messages (Poll, Response, Final)
  19. //and a maximum of 6 messages (Poll, Response x 4, Final)
  20. //Thus the ranging exchange will take either 28 ms for 110 kbps and 5 ms for 6.81 Mbps.
  21. //NOTE: the above times are for 110k rate with 64 symb non-standard SFD and 1024 preamble length
  22. #define MAX_TAG_LIST_SIZE (512)
  23. #define MAX_ANCHOR_LIST_SIZE (16) //this is limited to 4 in this application
  24. #define NUM_EXPECTED_RESPONSES (4) //e.g. MAX_ANCHOR_LIST_SIZE - 1
  25. #define NUM_EXPECTED_RESPONSES_ANC (1) //anchors A0, A1 and A2 are involved in anchor to anchor ranging
  26. #define NUM_EXPECTED_RESPONSES_ANC0 (2) //anchor A0 expects response from A1 and A2
  27. #define TAG_LIST_INDEX_MASK (MAX_TAG_LIST_SIZE-1)
  28. #define ANCHOR_LIST_INDEX_MASK (MAX_ANCHOR_LIST_SIZE-1)
  29. #define TAG_SLOT_FIRST_MASK ((MAX_TAG_LIST_SIZE>>1)-1) //low half of all slot
  30. #define RESP_RECORD_COUNT 4 ///Musb be 2, 4, 8, and so on
  31. #define RESP_RECORD_MASK (RESP_RECORD_COUNT - 1)
  32. #define RESP_RECORD_BUFSIZE (MAX_TAG_LIST_SIZE * RESP_RECORD_COUNT)
  33. #define GATEWAY_ANCHOR_ADDR (0x8000)
  34. #define A1_ANCHOR_ADDR (0x8001)
  35. #define A2_ANCHOR_ADDR (0x8002)
  36. #define A3_ANCHOR_ADDR (0x8003)
  37. #define BROADCAST_ADDR (0xffff)
  38. #define ANCHOR_SHORT_MASK (3)
  39. typedef struct
  40. {
  41. uint16_t slotPeriod ; //slot period (time for 1 tag to range to 4 anchors)
  42. uint16_t numSlots ; // number of slots in one superframe (number of tags supported)
  43. uint16_t sfPeriod ; // superframe period in ms
  44. uint16_t pollSleepDly ; // the minimum SLEEP time should be FRAME PERIOD so that tags don't interfere
  45. uint16_t replyDly ; //response delay time (Tag or Anchor when sending Final/Response messages respectively)
  46. } sfConfig_t ;
  47. typedef struct
  48. {
  49. uint8_t channelNumber ; // valid range is 1 to 11
  50. uint8_t preambleCode ; // 00 = use NS code, 1 to 24 selects code
  51. uint8_t pulseRepFreq ; // NOMINAL_4M, NOMINAL_16M, or NOMINAL_64M
  52. uint8_t dataRate ; // DATA_RATE_1 (110K), DATA_RATE_2 (850K), DATA_RATE_3 (6M81)
  53. uint8_t preambleLen ; // values expected are 64, (128), (256), (512), 1024, (2048), and 4096
  54. uint8_t pacSize ;
  55. uint8_t nsSFD ;
  56. uint8_t txPower ;
  57. uint16_t sfdTO; //!< SFD timeout value (in symbols) e.g. preamble length (128) + SFD(8) - PAC + some margin ~ 135us... DWT_SFDTOC_DEF; //default value
  58. } instanceConfig_t ;
  59. typedef struct {
  60. //configuration structures
  61. dwt_config_t configData ; //DW1000 channel configuration
  62. dwt_txconfig_t configTX ; //DW1000 TX power configuration
  63. uint16_t txAntennaDelay ; //DW1000 TX antenna delay
  64. uint16_t rxAntennaDelay ; //DW1000 RX antenna delay
  65. uint32_t txPower ; //DW1000 TX power
  66. uint8_t txPowerChanged ; //power has been changed - update the register on next TWR exchange
  67. uint8_t antennaDelayChanged; //antenna delay has been changed - update the register on next TWR exchange
  68. uint16_t instanceAddress16; //contains tag/anchor address
  69. //this is the delay used for the delayed transmit
  70. uint64_t pollTx2FinalTxDelay ; //this is delay from Poll Tx time to Final Tx time in DW1000 units (40-bit)
  71. uint64_t pollTx2FinalTxDelayAnc ; //this is delay from Poll Tx time to Final Tx time in DW1000 units (40-bit) for Anchor to Anchor ranging
  72. uint64_t fixedReplyDelayAnc ;
  73. uint32_t fixedReplyDelayAncP ;
  74. uint16_t pollRx2FinalRxDelay ;
  75. //Tag function address/message configuration
  76. uint8_t shortAdd_idx ; // device's 16-bit address low byte (used as index into arrays [0 - 3])
  77. uint8_t eui64[8]; // device's EUI 64-bit address
  78. uint16_t panID ; // panid used in the frames
  79. uint16_t sframePeriod;
  80. uint16_t slotPeriod;
  81. uint16_t numSlots;
  82. int fwtoTime_sy ; //this is final message duration (longest out of ranging messages)
  83. int fwtoTimeAnc_sy ;
  84. int ancRespRxDelay ;
  85. }inst_setting;
  86. #endif //HSS200ANC1701_REFACTOR_CONFIG_H