amiro-lld / drivers / DW1000 / v1 / deca_instance_common.c @ ed9a1bf5
History | View | Annotate | Download (71.11 KB)
| 1 | 69a601a5 | Cung Sang | /*! ----------------------------------------------------------------------------
|
|---|---|---|---|
| 2 | * @file instance_common.c
|
||
| 3 | * @brief DecaWave application level common instance functions
|
||
| 4 | *
|
||
| 5 | * @attention
|
||
| 6 | *
|
||
| 7 | * Copyright 2015 (c) DecaWave Ltd, Dublin, Ireland.
|
||
| 8 | *
|
||
| 9 | * All rights reserved.
|
||
| 10 | *
|
||
| 11 | * @author DecaWave
|
||
| 12 | */
|
||
| 13 | |||
| 14 | #include <alld_DW1000.h> |
||
| 15 | 9466e34d | Thomas Schöpping | #include <module.h> |
| 16 | 69a601a5 | Cung Sang | #include <string.h> |
| 17 | #include <math.h> |
||
| 18 | 9466e34d | Thomas Schöpping | #include <deca_instance.h> |
| 19 | 33f54213 | Cung Sang | |
| 20 | |||
| 21 | /*! @brief Software defined configuration settings for RTLS applications */
|
||
| 22 | /*! Configuration for DecaRangeRTLS TREK Modes (4 default use cases selected by the switch S1 [2,3] on EVB1000, indexed 0 to 3 )*/
|
||
| 23 | instanceConfig_t chConfig[4] ={
|
||
| 24 | //mode 1 - S1: 2 off, 3 off
|
||
| 25 | {
|
||
| 26 | .channelNumber = 2, // channel |
||
| 27 | .preambleCode = 4, // preambleCode |
||
| 28 | .pulseRepFreq = DWT_PRF_16M, // prf
|
||
| 29 | .dataRate = DWT_BR_110K, // datarate
|
||
| 30 | .preambleLen = DWT_PLEN_1024, // preambleLength
|
||
| 31 | .pacSize = DWT_PAC32, // pacSize
|
||
| 32 | .nsSFD = 1, // non-standard SFD |
||
| 33 | .sfdTO = (1025 + 64 - 32) // SFD timeout |
||
| 34 | }, |
||
| 35 | //mode 2 - S1: 2 on, 3 off
|
||
| 36 | {
|
||
| 37 | .channelNumber = 2, // channel |
||
| 38 | .preambleCode = 4, // preambleCode |
||
| 39 | .pulseRepFreq = DWT_PRF_16M, // prf
|
||
| 40 | .dataRate = DWT_BR_6M8, // datarate
|
||
| 41 | .preambleLen = DWT_PLEN_128, // preambleLength
|
||
| 42 | .pacSize = DWT_PAC8, // pacSize
|
||
| 43 | .nsSFD = 0, // non-standard SFD |
||
| 44 | .sfdTO = (129 + 8 - 8) // SFD timeout |
||
| 45 | }, |
||
| 46 | //mode 3 - S1: 2 off, 3 on
|
||
| 47 | {
|
||
| 48 | .channelNumber = 5, // channel |
||
| 49 | .preambleCode = 3, // preambleCode |
||
| 50 | .pulseRepFreq = DWT_PRF_16M, // prf
|
||
| 51 | .dataRate = DWT_BR_110K, // datarate
|
||
| 52 | .preambleLen = DWT_PLEN_1024, // preambleLength
|
||
| 53 | .pacSize = DWT_PAC32, // pacSize
|
||
| 54 | .nsSFD = 1, // non-standard SFD |
||
| 55 | .sfdTO = (1025 + 64 - 32) // SFD timeout |
||
| 56 | }, |
||
| 57 | //mode 4 - S1: 2 on, 3 on
|
||
| 58 | {
|
||
| 59 | .channelNumber = 5, // channel |
||
| 60 | .preambleCode = 3, // preambleCode |
||
| 61 | .pulseRepFreq = DWT_PRF_16M, // prf
|
||
| 62 | .dataRate = DWT_BR_6M8, // datarate
|
||
| 63 | .preambleLen = DWT_PLEN_128, // preambleLength
|
||
| 64 | .pacSize = DWT_PAC8, // pacSize
|
||
| 65 | .nsSFD = 0, // non-standard SFD |
||
| 66 | .sfdTO = (129 + 8 - 8) // SFD timeout |
||
| 67 | } |
||
| 68 | }; |
||
| 69 | 69a601a5 | Cung Sang | |
| 70 | |||
| 71 | 33f54213 | Cung Sang | /*! Slot and Superframe Configuration for DecaRangeRTLS TREK Modes (4 default use cases selected by the switch S1 [2,3] on EVB1000, indexed 0 to 3 )*/
|
| 72 | sfConfig_t sfConfig[4] ={
|
||
| 73 | //mode 1 - S1: 2 off, 3 off
|
||
| 74 | {
|
||
| 75 | .slotPeriod = (28), //slot duration in milliseconds (NOTE: the ranging exchange must be able to complete in this time |
||
| 76 | //e.g. tag sends a poll, 4 anchors send responses and tag sends the final + processing time
|
||
| 77 | .numSlots = (10), //number of slots in the superframe (8 tag slots and 2 used for anchor to anchor ranging), |
||
| 78 | .sfPeriod = (10*28), //in ms => 280ms frame means 3.57 Hz location rate |
||
| 79 | .pollSleepDly = (10*28), //tag period in ms (sleep time + ranging time) |
||
| 80 | .replyDly = (25000) //poll to final delay in microseconds (needs to be adjusted according to lengths of ranging frames) |
||
| 81 | }, |
||
| 82 | #if (DISCOVERY == 1) |
||
| 83 | //mode 2 - S1: 2 on, 3 off
|
||
| 84 | {
|
||
| 85 | .slotPeriod = (10), //slot duration in milliseconds (NOTE: the ranging exchange must be able to complete in this time |
||
| 86 | //e.g. tag sends a poll, 4 anchors send responses and tag sends the final + processing time
|
||
| 87 | .numSlots = (100), //number of slots in the superframe (98 tag slots and 2 used for anchor to anchor ranging), |
||
| 88 | .sfPeriod = (10*100), //in ms => 1000 ms frame means 1 Hz location rate |
||
| 89 | .pollSleepDly = (10*100), //tag period in ms (sleep time + ranging time) |
||
| 90 | .replyDly = (2500) //poll to final delay in microseconds (needs to be adjusted according to lengths of ranging frames) |
||
| 91 | |||
| 92 | }, |
||
| 93 | #else
|
||
| 94 | //mode 2 - S1: 2 on, 3 off
|
||
| 95 | {
|
||
| 96 | .slotPeriod = (10), //slot duration in milliseconds (NOTE: the ranging exchange must be able to complete in this time |
||
| 97 | //e.g. tag sends a poll, 4 anchors send responses and tag sends the final + processing time
|
||
| 98 | .numSlots = (10), //number of slots in the superframe (8 tag slots and 2 used for anchor to anchor ranging), |
||
| 99 | .sfPeriod = (10*10), //in ms => 100 ms frame means 10 Hz location rate |
||
| 100 | .pollSleepDly = (10*10), //tag period in ms (sleep time + ranging time) |
||
| 101 | .replyDly = (2500) //poll to final delay in microseconds (needs to be adjusted according to lengths of ranging frames) |
||
| 102 | }, |
||
| 103 | #endif
|
||
| 104 | //mode 3 - S1: 2 off, 3 on
|
||
| 105 | {
|
||
| 106 | .slotPeriod = (28), //slot duration in milliseconds (NOTE: the ranging exchange must be able to complete in this time |
||
| 107 | //e.g. tag sends a poll, 4 anchors send responses and tag sends the final + processing time
|
||
| 108 | .numSlots = (10), //number of slots in the superframe (8 tag slots and 2 used for anchor to anchor ranging), |
||
| 109 | .sfPeriod = (10*28), //in ms => 280ms frame means 3.57 Hz location rate |
||
| 110 | .pollSleepDly = (10*28), //tag period in ms (sleep time + ranging time) |
||
| 111 | .replyDly = (20000) //poll to final delay in microseconds (needs to be adjusted according to lengths of ranging frames) |
||
| 112 | |||
| 113 | }, |
||
| 114 | //mode 4 - S1: 2 on, 3 on
|
||
| 115 | {
|
||
| 116 | .slotPeriod = (10), //slot duration in milliseconds (NOTE: the ranging exchange must be able to complete in this time |
||
| 117 | //e.g. tag sends a poll, 4 anchors send responses and tag sends the final + processing time
|
||
| 118 | .numSlots = (10), //number of slots in the superframe (8 tag slots and 2 used for anchor to anchor ranging), |
||
| 119 | .sfPeriod = (10*10), //in ms => 100 ms frame means 10 Hz location rate |
||
| 120 | .pollSleepDly = (10*10), //tag period in ms (sleep time + ranging time) |
||
| 121 | .replyDly = (2500) //poll to final delay in microseconds (needs to be adjusted according to lengths of ranging frames) |
||
| 122 | } |
||
| 123 | }; |
||
| 124 | 69a601a5 | Cung Sang | |
| 125 | |||
| 126 | // -------------------------------------------------------------------------------------------------------------------
|
||
| 127 | |||
| 128 | //The table below specifies the default TX spectrum configuration parameters... this has been tuned for DW EVK hardware units
|
||
| 129 | //the table is set for smart power - see below in the instance_config function how this is used when not using smart power
|
||
| 130 | const tx_struct txSpectrumConfig[8] = |
||
| 131 | {
|
||
| 132 | //Channel 0 ----- this is just a place holder so the next array element is channel 1
|
||
| 133 | {
|
||
| 134 | 0x0, //0 |
||
| 135 | {
|
||
| 136 | 0x0, //0 |
||
| 137 | 0x0 //0 |
||
| 138 | } |
||
| 139 | }, |
||
| 140 | //Channel 1
|
||
| 141 | {
|
||
| 142 | 0xc9, //PG_DELAY |
||
| 143 | {
|
||
| 144 | 0x15355575, //16M prf power |
||
| 145 | 0x07274767 //64M prf power |
||
| 146 | } |
||
| 147 | |||
| 148 | }, |
||
| 149 | //Channel 2
|
||
| 150 | {
|
||
| 151 | 0xc2, //PG_DELAY |
||
| 152 | {
|
||
| 153 | 0x15355575, //16M prf power |
||
| 154 | 0x07274767 //64M prf power |
||
| 155 | } |
||
| 156 | }, |
||
| 157 | //Channel 3
|
||
| 158 | {
|
||
| 159 | 0xc5, //PG_DELAY |
||
| 160 | {
|
||
| 161 | 0x0f2f4f6f, //16M prf power |
||
| 162 | 0x2b4b6b8b //64M prf power |
||
| 163 | } |
||
| 164 | }, |
||
| 165 | //Channel 4
|
||
| 166 | {
|
||
| 167 | 0x95, //PG_DELAY |
||
| 168 | {
|
||
| 169 | 0x1f1f3f5f, //16M prf power |
||
| 170 | 0x3a5a7a9a //64M prf power |
||
| 171 | } |
||
| 172 | }, |
||
| 173 | //Channel 5
|
||
| 174 | {
|
||
| 175 | 0xc0, //PG_DELAY |
||
| 176 | {
|
||
| 177 | 0x0E082848, //16M prf power |
||
| 178 | 0x25456585 //64M prf power |
||
| 179 | } |
||
| 180 | }, |
||
| 181 | //Channel 6 ----- this is just a place holder so the next array element is channel 7
|
||
| 182 | {
|
||
| 183 | 0x0, //0 |
||
| 184 | {
|
||
| 185 | 0x0, //0 |
||
| 186 | 0x0 //0 |
||
| 187 | } |
||
| 188 | }, |
||
| 189 | //Channel 7
|
||
| 190 | {
|
||
| 191 | 0x93, //PG_DELAY |
||
| 192 | {
|
||
| 193 | 0x32527292, //16M prf power |
||
| 194 | 0x5171B1d1 //64M prf power |
||
| 195 | } |
||
| 196 | } |
||
| 197 | }; |
||
| 198 | |||
| 199 | //these are default antenna delays for EVB1000, these can be used if there is no calibration data in the DW1000,
|
||
| 200 | //or instead of the calibration data
|
||
| 201 | const uint16_t rfDelays[2] = { |
||
| 202 | 26dead12 | Cung Sang | (uint16_t) (((double)DWT_PRF_16M_RFDLY/ 2.0) * 1e-9 / DWT_TIME_UNITS),//PRF 16 |
| 203 | (uint16_t) (((double)DWT_PRF_64M_RFDLY/ 2.0) * 1e-9 / DWT_TIME_UNITS) |
||
| 204 | 69a601a5 | Cung Sang | }; |
| 205 | |||
| 206 | //these are default TREK Tag/Anchor antenna delays
|
||
| 207 | const uint16_t rfDelaysTREK[2] = { |
||
| 208 | 26dead12 | Cung Sang | (uint16_t) (((double)514.83f/ 2.0) * 1e-9 / DWT_TIME_UNITS),//channel 2 |
| 209 | (uint16_t) (((double)514.65f/ 2.0) * 1e-9 / DWT_TIME_UNITS) //channel 5 |
||
| 210 | 69a601a5 | Cung Sang | }; |
| 211 | |||
| 212 | |||
| 213 | // -------------------------------------------------------------------------------------------------------------------
|
||
| 214 | // Data Definitions
|
||
| 215 | // -------------------------------------------------------------------------------------------------------------------
|
||
| 216 | |||
| 217 | instance_data_t instance_data[NUM_INST] ; |
||
| 218 | |||
| 219 | static double inst_tdist[MAX_TAG_LIST_SIZE] ; |
||
| 220 | static double inst_idist[MAX_ANCHOR_LIST_SIZE] ; |
||
| 221 | static double inst_idistraw[MAX_ANCHOR_LIST_SIZE] ; |
||
| 222 | |||
| 223 | instance_data_t instance_data[NUM_INST] ; |
||
| 224 | |||
| 225 | 26dead12 | Cung Sang | typedef struct __attribute__((packed)) |
| 226 |