deca_device_api.h 64 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740
  1. /*! ----------------------------------------------------------------------------
  2. * @file deca_device_api.h
  3. * @brief DW1000 API Functions
  4. *
  5. * @attention
  6. *
  7. * Copyright 2015 (c) DecaWave Ltd, Dublin, Ireland.
  8. *
  9. * All rights reserved.
  10. *
  11. */
  12. #ifndef _DECA_DEVICE_API_H_
  13. #define _DECA_DEVICE_API_H_
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. #include "deca_types.h"
  18. /*
  19. #ifndef uint8_t
  20. #ifndef _DECA_UINT8_
  21. #define _DECA_UINT8_
  22. typedef unsigned char uint8_t;
  23. #endif
  24. #endif
  25. #ifndef uint16_t
  26. #ifndef _DECA_UINT16_
  27. #define _DECA_UINT16_
  28. typedef unsigned short uint16_t;
  29. #endif
  30. #endif
  31. #ifndef uint32_t
  32. #ifndef _DECA_UINT32_
  33. #define _DECA_UINT32_
  34. typedef unsigned long uint32_t;
  35. #endif
  36. #endif
  37. #ifndef int8
  38. #ifndef _DECA_INT8_
  39. #define _DECA_INT8_
  40. typedef signed char int8;
  41. #endif
  42. #endif
  43. #ifndef int16
  44. #ifndef _DECA_INT16_
  45. #define _DECA_INT16_
  46. typedef signed short int16;
  47. #endif
  48. #endif
  49. #ifndef int32
  50. #ifndef _DECA_INT32_
  51. #define _DECA_INT32_
  52. typedef signed long int32;
  53. #endif
  54. #endif
  55. #define REG_DUMP (0) //set to 1 to enable register dump functions
  56. #if (REG_DUMP == 1)
  57. #include "string.h"
  58. #endif
  59. */
  60. #define DWT_SUCCESS (0)
  61. #define DWT_ERROR (-1)
  62. #define DWT_TIME_UNITS (1.0/499.2e6/128.0) //!< = 15.65e-12 s
  63. #define DWT_DEVICE_ID (0xDECA0130) //!< DW1000 MP device ID
  64. //! constants for selecting the bit rate for data TX (and RX)
  65. //! These are defined for write (with just a shift) the TX_FCTRL register
  66. #define DWT_BR_110K 0 //!< UWB bit rate 110 kbits/s
  67. #define DWT_BR_850K 1 //!< UWB bit rate 850 kbits/s
  68. #define DWT_BR_6M8 2 //!< UWB bit rate 6.8 Mbits/s
  69. //! constants for specifying the (Nominal) mean Pulse Repetition Frequency
  70. //! These are defined for direct write (with a shift if necessary) to CHAN_CTRL and TX_FCTRL regs
  71. #define DWT_PRF_16M 1 //!< UWB PRF 16 MHz
  72. #define DWT_PRF_64M 2 //!< UWB PRF 64 MHz
  73. //! constants for specifying Preamble Acquisition Chunk (PAC) Size in symbols
  74. #define DWT_PAC8 0 //!< PAC 8 (recommended for RX of preamble length 128 and below
  75. #define DWT_PAC16 1 //!< PAC 16 (recommended for RX of preamble length 256
  76. #define DWT_PAC32 2 //!< PAC 32 (recommended for RX of preamble length 512
  77. #define DWT_PAC64 3 //!< PAC 64 (recommended for RX of preamble length 1024 and up
  78. //! constants for specifying TX Preamble length in symbols
  79. //! These are defined to allow them be directly written into byte 2 of the TX_FCTRL register
  80. //! (i.e. a four bit value destined for bits 20..18 but shifted left by 2 for byte alignment)
  81. #define DWT_PLEN_4096 0x0C //! Standard preamble length 4096 symbols
  82. #define DWT_PLEN_2048 0x28 //! Non-standard preamble length 2048 symbols
  83. #define DWT_PLEN_1536 0x18 //! Non-standard preamble length 1536 symbols
  84. #define DWT_PLEN_1024 0x08 //! Standard preamble length 1024 symbols
  85. #define DWT_PLEN_512 0x34 //! Non-standard preamble length 512 symbols
  86. #define DWT_PLEN_256 0x24 //! Non-standard preamble length 256 symbols
  87. #define DWT_PLEN_128 0x14 //! Non-standard preamble length 128 symbols
  88. #define DWT_PLEN_64 0x04 //! Standard preamble length 64 symbols
  89. //! callback events
  90. #define DWT_SIG_RX_NOERR 0
  91. #define DWT_SIG_TX_DONE 1 // Frame has been sent
  92. #define DWT_SIG_RX_OKAY 2 // Frame Received with Good CRC
  93. #define DWT_SIG_RX_ERROR 3 // Frame Received but CRC is wrong
  94. #define DWT_SIG_RX_TIMEOUT 4 // Timeout on receive has elapsed
  95. #define DWT_SIG_TX_AA_DONE 6 // ACK frame has been sent (as a result of auto-ACK)
  96. #define DWT_SIG_RX_PHR_ERROR 8 // Error found in PHY Header
  97. #define DWT_SIG_RX_SYNCLOSS 9 // Un-recoverable error in Reed Solomon Decoder
  98. #define DWT_SIG_RX_SFDTIMEOUT 10 // Saw preamble but got no SFD within configured time
  99. #define DWT_SIG_RX_PTOTIMEOUT 11 // Got preamble detection timeout (no preamble detected)
  100. #define DWT_SIG_TX_PENDING 12 // TX is pending
  101. #define DWT_SIG_TX_ERROR 13 // TX failed
  102. #define DWT_SIG_RX_PENDING 14 // RX has been re-enabled
  103. #define DWT_SIG_DW_IDLE 15 // DW radio is in IDLE (no TX or RX pending)
  104. #define DWT_SFDTOC_DEF 0x1041 // default SFD timeout value
  105. #define DWT_PHRMODE_STD 0x0 // standard PHR mode
  106. #define DWT_PHRMODE_EXT 0x3 // DW proprietary extended frames PHR mode
  107. // Defined constants for "mode" bitmask parameter passed into dwt_starttx() function.
  108. #define DWT_START_TX_IMMEDIATE 0
  109. #define DWT_START_TX_DELAYED 1
  110. #define DWT_RESPONSE_EXPECTED 2
  111. #define DWT_START_RX_IMMEDIATE 0
  112. #define DWT_START_RX_DELAYED 1
  113. #define DWT_REENABLE_ON_DLY_ERR 2 // if delayed RX failed due to "late" error then this
  114. // flag will re-enable RX immediately if set else RX is off on function return
  115. //frame filtering configuration options
  116. #define DWT_FF_NOTYPE_EN 0x000 // no frame types allowed (FF disabled)
  117. #define DWT_FF_COORD_EN 0x002 // behave as coordinator (can receive frames with no dest address (PAN ID has to match))
  118. #define DWT_FF_BEACON_EN 0x004 // beacon frames allowed
  119. #define DWT_FF_DATA_EN 0x008 // data frames allowed
  120. #define DWT_FF_ACK_EN 0x010 // ack frames allowed
  121. #define DWT_FF_MAC_EN 0x020 // mac control frames allowed
  122. #define DWT_FF_RSVD_EN 0x040 // reserved frame types allowed
  123. //DW1000 interrupt events
  124. #define DWT_INT_CPLOCK 0x00000002 // clock PLL lock
  125. #define DWT_INT_TFRS 0x00000080 // frame sent
  126. #define DWT_INT_LDED 0x00000400 // micro-code has finished execution
  127. #define DWT_INT_RFCG 0x00004000 // frame received with good CRC
  128. #define DWT_INT_RPHE 0x00001000 // receiver PHY header error
  129. #define DWT_INT_RFCE 0x00008000 // receiver CRC error
  130. #define DWT_INT_RFSL 0x00010000 // receiver sync loss error
  131. #define DWT_INT_RFTO 0x00020000 // frame wait timeout
  132. #define DWT_INT_RXOVRR 0x00100000 // receiver overrun
  133. #define DWT_INT_RXPTO 0x00200000 // preamble detect timeout
  134. #define DWT_INT_SLP2INIT 0x00800000 //
  135. #define DWT_INT_SFDT 0x04000000 // SFD timeout
  136. #define DWT_INT_ARFE 0x20000000 // frame rejected (due to frame filtering configuration)
  137. //DW1000 SLEEP and WAKEUP configuration parameters
  138. #define DWT_LOADLDO 0x1000 // ONW_LLDO - on wakeup load the LDO tune value
  139. #define DWT_LOADUCODE 0x0800 // ONW_LLDE - on wakeup load the LDE ucode
  140. #define DWT_PRESRV_SLEEP 0x0100 // PRES_SLEEP - on wakeup preserve sleep bit
  141. #define DWT_LOADOPSET 0x0080 // ONW_L64P - on wakeup load operating parameter set for 64 PSR
  142. #define DWT_CONFIG 0x0040 // ONW_LDC - on wakeup restore (load) the saved configurations (from AON array into HIF)
  143. #define DWT_TANDV 0x0001 // ONW_RADC - on wakeup run ADC to sample temperature and voltage sensor values
  144. #define DWT_XTAL_EN 0x10 // keep XTAL running during sleep
  145. #define DWT_WAKE_SLPCNT 0x8 // wake up after sleep count
  146. #define DWT_WAKE_CS 0x4 // wake up on chip select
  147. #define DWT_WAKE_WK 0x2 // wake up on WAKEUP PIN
  148. #define DWT_SLP_EN 0x1 // enable sleep/deep sleep functionality
  149. //DW1000 INIT configuration parameters
  150. #define DWT_LOADLDOTUNE 0x8
  151. #define DWT_LOADTXCONFIG 0x4
  152. #define DWT_LOADANTDLY 0x2
  153. #define DWT_LOADXTALTRIM 0x1
  154. #define DWT_LOADNONE 0x0
  155. //DW1000 OTP operating parameter set selection
  156. #define DWT_OPSET_64LEN 0x0
  157. #define DWT_OPSET_TIGHT 0x1
  158. #define DWT_OPSET_DEFLT 0x2
  159. typedef struct{
  160. uint32_t status; //initial value of register as ISR is entered
  161. uint8_t event; //event type
  162. uint8_t aatset; //auto ACK TX bit is set
  163. uint16_t datalength; //length of frame
  164. uint8_t fctrl[2]; //frame control bytes
  165. uint8_t dblbuff ; //set if double buffer is enabled
  166. uint8_t temp;
  167. }dwt_callback_data_t;
  168. typedef enum {
  169. CHAN_CTRL_TXCHAN_1 = 0x01, /* Selects the transmit channel 1 */
  170. CHAN_CTRL_TXCHAN_2 = 0x02, /* Selects the transmit channel 2 */
  171. CHAN_CTRL_TXCHAN_3 = 0x03, /* Selects the transmit channel 3 */
  172. CHAN_CTRL_TXCHAN_4 = 0x04, /* Selects the transmit channel 4 */
  173. CHAN_CTRL_TXCHAN_5 = 0x05, /* Selects the transmit channel 5 */
  174. CHAN_CTRL_TXCHAN_7 = 0x07 /* Selects the transmit channel 7 */
  175. }eCHAN;
  176. /*! ------------------------------------------------------------------------------------------------------------------
  177. * Structure typedef: dwt_config_t
  178. *
  179. * Structure for setting device configuration via dwt_configure() function
  180. *
  181. */
  182. #pragma pack(1)
  183. typedef struct
  184. {
  185. uint8_t chan ; //!< channel number {1, 2, 3, 4, 5, 7 }
  186. uint8_t prf ; //!< Pulse Repetition Frequency {DWT_PRF_16M or DWT_PRF_64M}
  187. uint8_t txPreambLength; //!< DWT_PLEN_64..DWT_PLEN_4096
  188. uint8_t rxPAC ; //!< Acquisition Chunk Size (Relates to RX preamble length)
  189. uint8_t txCode ; //!< TX preamble code
  190. uint8_t rxCode ; //!< RX preamble code
  191. uint8_t nsSFD ; //!< Boolean should we use non-standard SFD for better performance
  192. uint8_t dataRate ; //!< Data Rate {DWT_BR_110K, DWT_BR_850K or DWT_BR_6M8}
  193. uint8_t phrMode ; //!< PHR mode {0x0 - standard DWT_PHRMODE_STD, 0x3 - extended frames DWT_PHRMODE_EXT}
  194. uint8_t smartPowerEn ; //!< Smart Power enable / disable
  195. uint16_t sfdTO ; //!< SFD timeout value (in symbols)
  196. }
  197. #ifdef __GNUC__
  198. __attribute__ ((packed)) dwt_config_t;
  199. #elif defined(__ICCARM__)
  200. dwt_config_t;
  201. #endif
  202. #pragma pack()
  203. typedef struct
  204. {
  205. uint8_t PGdly;
  206. uint8_t temp[3];
  207. //TX POWER
  208. //31:24 BOOST_0.125ms_PWR
  209. //23:16 BOOST_0.25ms_PWR-TX_SHR_PWR
  210. //15:8 BOOST_0.5ms_PWR-TX_PHR_PWR
  211. //7:0 DEFAULT_PWR-TX_DATA_PWR
  212. uint32_t power;
  213. }
  214. dwt_txconfig_t ;
  215. typedef struct
  216. {
  217. uint16_t maxNoise ; // LDE max value of noise
  218. uint16_t firstPathAmp1 ; // Amplitude at floor(index FP) + 1
  219. uint16_t stdNoise ; // Standard deviation of noise
  220. uint16_t firstPathAmp2 ; // Amplitude at floor(index FP) + 2
  221. uint16_t firstPathAmp3 ; // Amplitude at floor(index FP) + 3
  222. uint16_t maxGrowthCIR ; // Channel Impulse Response max growth CIR
  223. uint16_t rxPreamCount ; // Count of preamble symbols accumulated
  224. uint16_t temp;
  225. //uint32_t debug1;
  226. //uint32_t debug2;
  227. double firstPath ; // First path index
  228. }dwt_rxdiag_t ;
  229. typedef struct
  230. {
  231. //all of the below are mapped to a 12-bit register in DW1000
  232. uint16_t PHE ; //number of received header errors
  233. uint16_t RSL ; //number of received frame sync loss events
  234. uint16_t CRCG ; //number of good CRC received frames
  235. uint16_t CRCB ; //number of bad CRC (CRC error) received frames
  236. uint16_t ARFE ; //number of address filter errors
  237. uint16_t OVER ; //number of receiver overflows (used in double buffer mode)
  238. uint16_t SFDTO ; //SFD timeouts
  239. uint16_t PTO ; //Preamble timeouts
  240. uint16_t RTO ; //RX frame wait timeouts
  241. uint16_t TXF ; //number of transmitted frames
  242. uint16_t HPW ; //half period warn
  243. uint16_t TXW ; //power up warn
  244. } dwt_deviceentcnts_t ;
  245. typedef void (*dwt_rxtxhandler)(const dwt_callback_data_t *rtxd);
  246. /*! ------------------------------------------------------------------------------------------------------------------
  247. * @fn dwt_getldotune()
  248. *
  249. * @brief This is used to return the low 32 bits of the programmed LDO tune value of the device
  250. *
  251. * input parameters
  252. *
  253. * output parameters
  254. *
  255. * returns the 32 bit LDO tune value of the device as programmed in the factory
  256. */
  257. uint32_t dwt_getldotune(void);
  258. /*! ------------------------------------------------------------------------------------------------------------------
  259. * Function: dwt_getpartid()
  260. *
  261. * Description: This is used to return the read part ID of the device
  262. *
  263. * input parameters
  264. *
  265. * output parameters
  266. *
  267. * returns the 32 bit part ID value as programmed in the factory
  268. */
  269. uint32_t dwt_getpartid(void);
  270. /*! ------------------------------------------------------------------------------------------------------------------
  271. * Function: dwt_getlotid()
  272. *
  273. * Description: This is used to return the read lot ID of the device
  274. *
  275. * input parameters
  276. *
  277. * output parameters
  278. *
  279. * returns the 32 bit lot ID value as programmed in the factory
  280. */
  281. uint32_t dwt_getlotid(void);
  282. /*! ------------------------------------------------------------------------------------------------------------------
  283. * Function: dwt_readdevid()
  284. *
  285. * Description: This is used to return the read device type and revision information of the DW1000 device (MP part is 0xDECA0130)
  286. *
  287. * input parameters:
  288. *
  289. * output parameters:
  290. *
  291. * returns the read value which for DW1000 is 0xDECA0130
  292. */
  293. uint32_t dwt_readdevid(void);
  294. /*! ------------------------------------------------------------------------------------------------------------------
  295. * @fn dwt_getTREKOTPantennadelay()
  296. *
  297. * @brief This API function returns the antenna delay read from the OTP memory as part of device initialisation
  298. * Note: the antenna delay will only be read if dwt_initialise is called with DWT_LOADANTDLY bit set in the config parameter
  299. * The values of antenna delay are only valid for TREK use case modes.
  300. *
  301. * input parameters:
  302. * @param anchor - this is the mode (Tag or Anchor) if Tag set to 0, if Anchor set to 1
  303. * @param chan - this is the channel (1, 2, 3, 4, 5, 7)
  304. * @param datarate - this is the datarate DWT_BR_6M8, DWT_BR_110K or DWT_BR_850K
  305. *
  306. */
  307. uint16_t dwt_getTREKOTPantennadelay(uint8_t anchor, uint8_t chan, uint8_t datarate);
  308. /*! ------------------------------------------------------------------------------------------------------------------
  309. * Function: dwt_otprevision()
  310. *
  311. * Description: This is used to return the read OTP revision
  312. *
  313. * input parameters:
  314. *
  315. * output parameters:
  316. *
  317. * returns the read OTP revision value
  318. */
  319. uint8_t dwt_otprevision(void);
  320. /*! ------------------------------------------------------------------------------------------------------------------
  321. * @fn dwt_setGPIOforEXTTRX()
  322. *
  323. * @brief This is used to enable GPIO for external LNA or PA functionality - HW dependent, consult the DW1000 User Manual
  324. *
  325. * input parameters
  326. *
  327. * output parameters
  328. *
  329. * no return value
  330. */
  331. void dwt_setGPIOforEXTTRX(void);
  332. void dwt_setGPIOforEXTPA(void);
  333. /*! ------------------------------------------------------------------------------------------------------------------
  334. * @fn dwt_setGPIOdirection()
  335. *
  336. * @brief This is used to set GPIO direction as an input (1) or output (0)
  337. *
  338. * input parameters
  339. * @param gpioNum - this is the GPIO to configure - see GxM0... GxM8 in the deca_regs.h file
  340. * @param direction - this sets the GPIO direction - see GxP0... GxP8 in the deca_regs.h file
  341. *
  342. * output parameters
  343. *
  344. * no return value
  345. */
  346. void dwt_setGPIOdirection(uint32_t gpioNum, uint32_t direction);
  347. /*! ------------------------------------------------------------------------------------------------------------------
  348. * @fn dwt_setGPIOvalue()
  349. *
  350. * @brief This is used to set GPIO value as (1) or (0) only applies if the GPIO is configured as output
  351. *
  352. * input parameters
  353. * @param gpioNum - this is the GPIO to configure - see GxM0... GxM8 in the deca_regs.h file
  354. * @param direction - this sets the GPIO value - see GDP0... GDP8 in the deca_regs.h file
  355. *
  356. * output parameters
  357. *
  358. * no return value
  359. */
  360. void dwt_setGPIOvalue(uint32_t gpioNum, uint32_t value);
  361. /*! ------------------------------------------------------------------------------------------------------------------
  362. * Function: dwt_initialise()
  363. *
  364. * Description: This function initiates communications with the DW1000 transceiver
  365. * and reads its DEV_ID register (address 0x00) to verify the IC is one supported
  366. * by this software (e.g. DW1000 32-bit device ID value is 0xDECA0130). Then it
  367. * does any initial once only device configurations needed for use and initialises
  368. * as necessary any static data items belonging to this low-level driver.
  369. *
  370. * NOTES:
  371. * 1.this function needs to be run before dwt_configuresleep, also the SPI freq has to be < 3MHz
  372. * 2.it also reads any calibration data from OTP memory as specified by the input paramter
  373. *
  374. *
  375. * input parameters
  376. * @param config - specifies what configuration to load form OTP memory
  377. * DWT_LOADUCODE 0x800 - load the LDE micro-code from ROM - enabled accurate RX timestamp
  378. * DWT_LOADTXCONFIG 0x4 - load the TX power values
  379. * DWT_LOADANTDLY 0x2 - load the antenna delay values
  380. * DWT_LOADXTALTRIM 0x1 - load XTAL trim values
  381. * DWT_LOADNONE 0x0 - do not load any values from OTP memory
  382. *
  383. * output parameters
  384. *
  385. * returns DWT_DECA_SUCCESS for success, or DWT_DECA_ERROR for error
  386. */
  387. int dwt_initialise(uint16_t config) ;
  388. /*! ------------------------------------------------------------------------------------------------------------------
  389. * Function: dwt_configure()
  390. *
  391. * Description: This function provides the main API for the configuration of the
  392. * DW1000 and this low-level driver. The input is a pointer to the data structure
  393. * of type dwt_config_t that holds all the configurable items.
  394. * The dwt_config_t structure shows which ones are supported
  395. *
  396. * input parameters
  397. * @param config - pointer to the configuration structure, which contains the device configuration data.
  398. * @param useotp - specifies what configuration (read form OTP memory as part of initialisation) to configure
  399. * DWT_LOADANTDLY 0x2 - load the antenna delay values
  400. * DWT_LOADXTALTRIM 0x1 - load XTAL trim values
  401. * DWT_LOADNONE 0x0 - do not load any values from OTP memory
  402. *
  403. * output parameters
  404. *
  405. * returns DWT_DECA_SUCCESS for success, or DWT_DECA_ERROR for error
  406. */
  407. int dwt_configure(dwt_config_t *configData, uint8_t useotp) ;
  408. /*! ------------------------------------------------------------------------------------------------------------------
  409. * Function: dwt_configuretxrf()
  410. *
  411. * Description: This function provides the API for the configuration of the TX spectrum
  412. * including the power and pulse generator delay. The input is a pointer to the data structure
  413. * of type dwt_txconfig_t that holds all the configurable items.
  414. *
  415. * input parameters
  416. * @param config - pointer to the txrf configuration structure, which contains the tx rf config data
  417. *
  418. * output parameters
  419. *
  420. * no return value
  421. */
  422. void dwt_configuretxrf(dwt_txconfig_t *config) ;
  423. /*! ------------------------------------------------------------------------------------------------------------------
  424. * Function: dwt_getotptxpower()
  425. *
  426. * Description: This API function returns the tx power value read from OTP memory as part of initialisation
  427. *
  428. * input parameters
  429. * @param prf - this is the PRF e.g. DWT_PRF_16M or DWT_PRF_64M
  430. * @param chan - this is the channel (e.g. 1, 2, 3, 4, 5, 6 or 7)
  431. *
  432. * output parameters
  433. *
  434. * returns tx power value for a given PRF and channel
  435. */
  436. uint32_t dwt_getotptxpower(uint8_t prf, uint8_t chan);
  437. /*! ------------------------------------------------------------------------------------------------------------------
  438. * Function: dwt_setrxantennadelay()
  439. *
  440. * Description: This API function writes the antenna delay (in time units) to RX registers
  441. *
  442. * input parameters:
  443. * @param antennaDly - this is the total (RX) antenna delay value, which
  444. * will be programmed into the RX register
  445. *
  446. * output parameters
  447. *
  448. * no return value
  449. */
  450. void dwt_setrxantennadelay(uint16_t antennaDly);
  451. /*! ------------------------------------------------------------------------------------------------------------------
  452. * Function: dwt_settxantennadelay()
  453. *
  454. * Description: This API function writes the antenna delay (in time units) to TX registers
  455. *
  456. * input parameters:
  457. * @param antennaDly - this is the total (TX) antenna delay value, which
  458. * will be programmed into the TX delay register
  459. *
  460. * output parameters
  461. *
  462. * no return value
  463. */
  464. void dwt_settxantennadelay(uint16_t antennaDly);
  465. /*! ------------------------------------------------------------------------------------------------------------------
  466. * Function: dwt_readantennadelay()
  467. *
  468. * Description: This API function returns the antenna delay read from the OTP memory as part of device initialisation
  469. * Note: the antenna delay will only be read if dwt_initialise is called with DWT_LOADANTDLY bit set in the config parameter
  470. *
  471. * input parameters:
  472. * @param prf - this is the PRF e.g. DWT_PRF_16M or DWT_PRF_64M
  473. *
  474. * returns the combined tx and rx antenna delay for a given PRF
  475. */
  476. uint16_t dwt_readantennadelay(uint8_t prf);
  477. /*! ------------------------------------------------------------------------------------------------------------------
  478. * Function: dwt_setsmarttxpower()
  479. *
  480. * Description: This call enables or disables the smart TX power feature.
  481. *
  482. * input parameters
  483. * @param enable - this enables or disables the TX smart power (1 = enable, 0 = disable)
  484. *
  485. * output parameters
  486. *
  487. * no return value
  488. */
  489. void dwt_setsmarttxpower(int enable);
  490. /*! ------------------------------------------------------------------------------------------------------------------
  491. * Function: dwt_writetxdata()
  492. *
  493. * Description: This API function writes the supplied TX data into the DW1000's
  494. * TX buffer. The input parameters are the data length in bytes and a pointer
  495. * to those data bytes.
  496. *
  497. * input parameters
  498. * @param txFrameLength - This is the total frame length, including the two byte CRC.
  499. * Note: this is the length of TX message (including the 2 byte CRC) - max is 1023
  500. * standard PHR mode allows up to 127 bytes
  501. * if > 127 is programmed, DWT_PHRMODE_EXT needs to be set in the phrMode configuration
  502. * see dwt_configure function
  503. * @param txFrameBytes - Pointer to the user’s buffer containing the data to send.
  504. * @param txBufferOffset - This specifies an offset in the DW1000’s TX Buffer at which to start writing data.
  505. *
  506. * output parameters
  507. *
  508. * returns DWT_DECA_SUCCESS for success, or DWT_DECA_ERROR for error
  509. */
  510. int dwt_writetxdata(uint16_t txFrameLength, uint8_t *txFrameBytes, uint16_t txBufferOffset) ;
  511. /*! ------------------------------------------------------------------------------------------------------------------
  512. * Function: dwt_writetxfctrl()
  513. *
  514. * Description: This API function configures the TX frame control register before the transmission of a frame
  515. *
  516. * input parameters:
  517. * @param txFrameLength - this is the length of TX message (including the 2 byte CRC) - max is 1023
  518. * NOTE: standard PHR mode allows up to 127 bytes
  519. * if > 127 is programmed, DWT_PHRMODE_EXT needs to be set in the phrMode configuration
  520. * see dwt_configure function
  521. * @param txBufferOffset - the offset in the tx buffer to start writing the data
  522. *
  523. * output parameters
  524. *
  525. * returns DWT_DECA_SUCCESS for success, or DWT_DECA_ERROR for error
  526. *
  527. */
  528. int dwt_writetxfctrl(uint16_t txFrameLength, uint16_t txBufferOffset) ;
  529. /*! ------------------------------------------------------------------------------------------------------------------
  530. * Function: dwt_starttx()
  531. *
  532. * Description: This call initiates the transmission, input parameter indicates which TX mode is used see below
  533. *
  534. * input parameters:
  535. * @param mode - if 0 immediate TX (no response expected)
  536. * if 1 delayed TX (no response expected)
  537. * if 2 immediate TX (response expected - so the receiver sill be automatically turned on after TX is done)
  538. * if 3 delayed TX (response expected - so the receiver sill be automatically turned on after TX is done)
  539. *
  540. * output parameters
  541. *
  542. * returns DWT_DECA_SUCCESS for success, or DWT_DECA_ERROR for error (e.g. a delayed transmission will fail if the delayed time has passed)
  543. */
  544. int dwt_starttx(uint8_t mode) ;
  545. /*! ------------------------------------------------------------------------------------------------------------------
  546. * Function: dwt_setdelayedtrxtime()
  547. *
  548. * Description: This API function configures the delayed transmit time or the delayed rx on time
  549. *
  550. * input parameters
  551. * @param starttime - the tx/rx start time (the 32 bits should be the high 32 bits of the system time at which to send the message,
  552. * or at which to turn on the receiver)
  553. *
  554. * output parameters none
  555. *
  556. * no return value
  557. */
  558. void dwt_setdelayedtrxtime(uint32_t starttime) ;
  559. /*! ------------------------------------------------------------------------------------------------------------------
  560. * Function: dwt_readtxtimestamp()
  561. *
  562. * Description: This is used to read the TX timestamp (adjusted with the programmed antenna delay)
  563. *
  564. * input parameters
  565. * @param timestamp - a pointer to a 5-byte buffer which will store the read TX timestamp time
  566. *
  567. * output parameters
  568. * @param timestamp - the timestamp buffer will contain the value after the function call
  569. *
  570. * no return value
  571. */
  572. void dwt_readtxtimestamp(uint8_t * timestamp);
  573. /*! ------------------------------------------------------------------------------------------------------------------
  574. * Function: dwt_readtxtimestamphi32()
  575. *
  576. * Description: This is used to read the high 32-bits of the TX timestamp (adjusted with the programmed antenna delay)
  577. *
  578. * input parameters
  579. *
  580. * output parameters
  581. *
  582. * returns high 32-bits of TX timestamp
  583. */
  584. uint32_t dwt_readtxtimestamphi32(void);
  585. /*! ------------------------------------------------------------------------------------------------------------------
  586. * Function: dwt_readtxtimestamplo32()
  587. *
  588. * Description: This is used to read the low 32-bits of the TX timestamp (adjusted with the programmed antenna delay)
  589. *
  590. * input parameters
  591. *
  592. * output parameters
  593. *
  594. * returns low 32-bits of TX timestamp
  595. */
  596. uint32_t dwt_readtxtimestamplo32(void);
  597. /*! ------------------------------------------------------------------------------------------------------------------
  598. * Function: dwt_readrxtimestamp()
  599. *
  600. * Description: This is used to read the RX timestamp (adjusted time of arrival)
  601. *
  602. * input parameters
  603. * @param timestamp - a pointer to a 5-byte buffer which will store the read RX timestamp time
  604. *
  605. * output parameters
  606. * @param timestamp - the timestamp buffer will contain the value after the function call
  607. *
  608. * no return value
  609. */
  610. void dwt_readrxtimestamp(uint8_t * timestamp);
  611. /*! ------------------------------------------------------------------------------------------------------------------
  612. * Function: dwt_readrxtimestamphi32()
  613. *
  614. * Description: This is used to read the high 32-bits of the RX timestamp (adjusted with the programmed antenna delay)
  615. *
  616. * input parameters
  617. *
  618. * output parameters
  619. *
  620. * returns high 32-bits of RX timestamp
  621. */
  622. uint32_t dwt_readrxtimestamphi32(void);
  623. /*! ------------------------------------------------------------------------------------------------------------------
  624. * Function: dwt_readrxtimestamplo32()
  625. *
  626. * Description: This is used to read the low 32-bits of the RX timestamp (adjusted with the programmed antenna delay)
  627. *
  628. * input parameters
  629. *
  630. * output parameters
  631. *
  632. * returns low 32-bits of RX timestamp
  633. */
  634. uint32_t dwt_readrxtimestamplo32(void);
  635. /*! ------------------------------------------------------------------------------------------------------------------
  636. * Function: dwt_readsystimestamphi32()
  637. *
  638. * Description: This is used to read the high 32-bits of the system time
  639. *
  640. * input parameters
  641. *
  642. * output parameters
  643. *
  644. * returns high 32-bits of system time timestamp
  645. */
  646. uint32_t dwt_readsystimestamphi32(void);
  647. /*! ------------------------------------------------------------------------------------------------------------------
  648. * Function: dwt_readsystime()
  649. *
  650. * Description: This is used to read the system time
  651. *
  652. * input parameters
  653. * @param timestamp - a pointer to a 5-byte buffer which will store the read system time
  654. *
  655. * output parameters
  656. * @param timestamp - the timestamp buffer will contain the value after the function call
  657. *
  658. * no return value
  659. */
  660. void dwt_readsystime(uint8_t * timestamp);
  661. /*! ------------------------------------------------------------------------------------------------------------------
  662. * Function: dwt_checkoverrun()
  663. *
  664. * Description: This is used to check if the overrun condition is set in DW1000
  665. *
  666. * input parameters
  667. *
  668. * output parameters
  669. *
  670. * no return value
  671. */
  672. int dwt_checkoverrun(void);
  673. /*! ------------------------------------------------------------------------------------------------------------------
  674. * Function: dwt_forcetrxoff()
  675. *
  676. * Description: This is used to turn off the transceiver
  677. *
  678. * input parameters
  679. *
  680. * output parameters
  681. *
  682. * no return value
  683. */
  684. void dwt_forcetrxoff(void);
  685. /*! ------------------------------------------------------------------------------------------------------------------
  686. * Function: dwt_syncrxbufptrs()
  687. *
  688. * Description: this function synchronizes rx buffer pointers
  689. * need to make sure that the host/IC buffer pointers are aligned before starting RX
  690. *
  691. * input parameters:
  692. *
  693. * output parameters
  694. *
  695. * no return value
  696. */
  697. void dwt_syncrxbufptrs(void);
  698. /*! ------------------------------------------------------------------------------------------------------------------
  699. * Function: dwt_rxenable()
  700. *
  701. * Description: This call turns on the receiver, can be immediate or delayed.
  702. * The receiver will stay turned on, listening to any messages until
  703. * it either receives a good frame, an error (CRC, PHY header, Reed Solomon) or it times out (SFD, Preamble or Frame).
  704. *
  705. * input parameters
  706. * @param delayed - TRUE the receiver is turned on after some delay (as programmed with dwt_setdelayedtime())
  707. *
  708. * output parameters
  709. *
  710. * returns DWT_DECA_SUCCESS for success, or DWT_DECA_ERROR for error (e.g. a delayed receive enable will be too far in the future if delayed time has passed (if delayed time is > 8s from now))
  711. */
  712. int dwt_rxenable(uint8_t delayed) ;
  713. /*! ------------------------------------------------------------------------------------------------------------------
  714. * Function: dwt_setrxmode()
  715. *
  716. * Description: enable different rx modes, e.g.:
  717. * a) "snooze" mode, the receiver only listens periodically for preamble
  718. * b) the rx PPDM "sniff" mode - receiver cycles through ON/OFF periods
  719. *
  720. * input parameters:
  721. * @param mode - DWT_RX_NORMAL = 0x0
  722. * DWT_RX_SNIFF = 0x1 enable the rx PPDM "sniff" mode
  723. * @param rxON - SNIFF mode ON period in PACs
  724. * @param rxOFF - SNIFF mode OFF period in us (actually in 1.0256 micro second intervals)
  725. * output parameters
  726. *
  727. * no return value
  728. */
  729. #define DWT_RX_NORMAL (0x0)
  730. #define DWT_RX_SNIFF (0x1)
  731. void dwt_setrxmode(int mode, uint8_t rxON, uint8_t rxOFF);
  732. /*! ------------------------------------------------------------------------------------------------------------------
  733. * Function: dwt_setautorxreenable()
  734. *
  735. * Description: This call enables the auto rx re-enable feature
  736. *
  737. * input parameters
  738. * @param enable - 1 to enable, 0 to disable the feature
  739. *
  740. * output parameters
  741. *
  742. * no return value
  743. */
  744. void dwt_setautorxreenable(int enable);
  745. /*! ------------------------------------------------------------------------------------------------------------------
  746. * Function: dwt_setdblrxbuffmode()
  747. *
  748. * Description: This call enables the double receive buffer mode
  749. *
  750. * input parameters
  751. * @param enable - 1 to enable, 0 to disable the double buffer mode
  752. *
  753. * output parameters
  754. *
  755. * no return value
  756. */
  757. void dwt_setdblrxbuffmode(int enable);
  758. /*! ------------------------------------------------------------------------------------------------------------------
  759. * Function: dwt_setrxtimeout()
  760. *
  761. * Description: This call enables RX timeout (SY_STAT_RFTO event)
  762. *
  763. * input parameters
  764. * @param time - how long the receiver remains on from the RX enable command
  765. * The time parameter used here is in 1.0256 us (512/499.2MHz) units
  766. * If set to 0 the timeout is disabled.
  767. *
  768. * output parameters
  769. *
  770. * no return value
  771. */
  772. void dwt_setrxtimeout(uint16_t time);
  773. /*! ------------------------------------------------------------------------------------------------------------------
  774. * Function: dwt_setpreambledetecttimeout()
  775. *
  776. * Description: This call enables preamble timeout (SY_STAT_RXPTO event)
  777. *
  778. * input parameters
  779. * @param timeout - in PACs
  780. *
  781. * output parameters
  782. *
  783. * no return value
  784. */
  785. void dwt_setpreambledetecttimeout(uint16_t timeout);
  786. /*! ------------------------------------------------------------------------------------------------------------------
  787. * Function: dwt_calibratesleepcnt()
  788. *
  789. * Description: calibrates the local oscillator as its frequency can vary between 7 and 13kHz depending on temp and voltage
  790. *
  791. * NOTE: this function needs to be run before dwt_configuresleepcnt, so that we know what the counter units are
  792. * returns the number of XTAL/2 cycles per low-power oscillator cycle
  793. *
  794. * To get LP OSC freq = (XTAL/2)/result = 19.2MHz/result
  795. *
  796. * input parameters
  797. *
  798. * output parameters
  799. *
  800. * no return value
  801. */
  802. uint16_t dwt_calibratesleepcnt(void);
  803. /*! ------------------------------------------------------------------------------------------------------------------
  804. * Function: dwt_configuresleepcnt()
  805. *
  806. * Description: sets the sleep counter to new value, this function programs the high 16-bits of the 28-bit counter
  807. *
  808. * NOTE: this function needs to be run before dwt_configuresleep, also the SPI freq has to be < 3MHz
  809. *
  810. * input parameters
  811. * @param sleepcnt - this it value of the sleep counter to program
  812. *
  813. * output parameters
  814. *
  815. * no return value
  816. */
  817. void dwt_configuresleepcnt(uint16_t sleepcnt);
  818. /*! ------------------------------------------------------------------------------------------------------------------
  819. * Function: dwt_configuresleep()
  820. *
  821. * Description: configures the device for both DEEP_SLEEP and SLEEP modes, and on-wake mode
  822. * I.e. before entering the sleep, the device should be programmed for TX or RX, then upon "waking up" the TX/RX settings
  823. * will be preserved and the device can immediately perform the desired action TX/RX
  824. *
  825. * NOTE: e.g. MP :- Tag operation - after deep sleep, the device needs to just load the TX buffer and send the frame
  826. *
  827. *
  828. * mode: the array and LDE code (OTP/ROM) and LDO tune, and set sleep persist
  829. * DWT_LOADLDO 0x1000 - load LDO tune value from OTP
  830. * DWT_LOADUCODE 0x0800 - load ucode from OTP
  831. * DWT_PRESRV_SLEEP 0x0100 - preserve sleep
  832. * DWT_LOADOPSET 0x0080 - load operating parameter set on wakeup
  833. * DWT_CONFIG 0x0040 - download the AON array into the HIF (configuration download)
  834. * DWT_LOADEUI 0x0008
  835. * DWT_GOTORX 0x0002
  836. * DWT_TANDV 0x0001
  837. *
  838. * wake: wake up parameters
  839. * DWT_XTAL_EN 0x10 - keep XTAL running during sleep
  840. * DWT_WAKE_SLPCNT 0x8 - wake up after sleep count
  841. * DWT_WAKE_CS 0x4 - wake up on chip select
  842. * DWT_WAKE_WK 0x2 - wake up on WAKEUP PIN
  843. * DWT_SLP_EN 0x1 - enable sleep/deep sleep functionality
  844. *
  845. * input parameters
  846. * @param mode - config on-wake parameters
  847. * @param wake - config wake up parameters
  848. *
  849. * output parameters
  850. *
  851. * no return value
  852. */
  853. void dwt_configuresleep(uint16_t mode, uint8_t wake);
  854. void dwt_getsleepconfig(uint16_t* mode, uint8_t* wake);
  855. /*! ------------------------------------------------------------------------------------------------------------------
  856. * Function: dwt_entersleep()
  857. *
  858. * Description: This function puts the device into deep sleep or sleep. dwt_configuredeepsleep should be called first
  859. * to configure the sleep and on-wake/wakeup parameters
  860. *
  861. * input parameters
  862. *
  863. * output parameters
  864. *
  865. * no return value
  866. */
  867. void dwt_entersleep(void);
  868. /*! ------------------------------------------------------------------------------------------------------------------
  869. * Function: dwt_entersleepaftertx(int enable)
  870. *
  871. * Description: sets the auto TX to sleep bit. This means that after a frame
  872. * transmission the device will enter deep sleep mode. The dwt_setdeepsleep() function
  873. * needs to be called before this to configure the on-wake settings
  874. *
  875. * NOTE: the IRQ line has to be low/inactive (i.e. no pending events)
  876. *
  877. * input parameters
  878. * @param enable - 1 to configure the device to enter deep sleep after TX, 0 - disables the configuration
  879. *
  880. * output parameters
  881. *
  882. * no return value
  883. */
  884. void dwt_entersleepaftertx(int enable);
  885. /*! ------------------------------------------------------------------------------------------------------------------
  886. * Function: dwt_spicswakeup()
  887. *
  888. * Description: wake up the device from sleep mode using the SPI read,
  889. * the device will wake up on chip slect line going low if the line is held low for at least 600us
  890. * NOTE: Alternatively the device can be woken up with WaKE_UP pin if configured for that operation
  891. *
  892. * input parameters
  893. * @param buff - this is a pointer to the dummy buffer which will be used in the SPI read transaction used for the WAKE UP of the device
  894. * @param length - this is the length of the dummy buffer
  895. *
  896. * output parameters
  897. *
  898. * returns DWT_DECA_SUCCESS for success, or DWT_DECA_ERROR for error
  899. */
  900. int dwt_spicswakeup(uint8_t *buff, uint16_t length);
  901. /*! ------------------------------------------------------------------------------------------------------------------
  902. * Function: dwt_setcallbacks()
  903. *
  904. * Description: This is the devices interrupt handler function, it will process/report status events
  905. *
  906. * input parameters
  907. * @param txcallback - the pointer to the TX callback function
  908. * @param rxcallback - the pointer to the RX callback function
  909. *
  910. * output parameters
  911. *
  912. * no return value
  913. */
  914. //void dwt_setcallbacks(void (*txcallback)(const dwt_callback_data_t *), void (*rxcallback)(const dwt_callback_data_t *));
  915. void dwt_setcallbacks(dwt_rxtxhandler txcallback, dwt_rxtxhandler rxcallback);
  916. /*! ------------------------------------------------------------------------------------------------------------------
  917. * @fn dwt_checkIRQ()
  918. *
  919. * @brief This function checks if the IRQ line is active - this is used instead of interrupt handler
  920. *
  921. * input parameters
  922. *
  923. * output parameters
  924. *
  925. * return value is 1 if the IRQS bit is set and 0 otherwise
  926. */
  927. uint8_t dwt_checkIRQ(void);
  928. /*! ------------------------------------------------------------------------------------------------------------------
  929. * Function: dwt_isr()
  930. *
  931. * Description: This is the devices interrupt handler function, it will process/report status events
  932. * Notes: In PC based system using (Cheetah or ARM) USB to SPI converter there can be no interrupts, however we still need something
  933. * to take the place of it and operate in a polled way.
  934. * In an embedded system this function should be configured to launch on an interrupt, then it will process the interrupt trigger event and
  935. * call a tx or rx callback function depending on whether the event is a TX or RX event.
  936. * the tx call-back will be called when a frame has been sent and the rx call-back when a frame has been received.
  937. *
  938. * input parameters
  939. *
  940. * output parameters
  941. *
  942. * no return value
  943. */
  944. void dwt_isr(void);
  945. /*! ------------------------------------------------------------------------------------------------------------------
  946. * Function: void dwt_setinterrupt( uint32_t bitmask, uint8_t enable)
  947. *
  948. * Description: This function enables the specified events to trigger an interrupt.
  949. * The following events can be enabled:
  950. * DWT_INT_TFRS 0x00000080 // frame sent
  951. * DWT_INT_RFCG 0x00004000 // frame received with good CRC
  952. * DWT_INT_RPHE 0x00001000 // receiver PHY header error
  953. * DWT_INT_RFCE 0x00008000 // receiver CRC error
  954. * DWT_INT_RFSL 0x00010000 // receiver sync loss error
  955. * DWT_INT_RFTO 0x00020000 // frame wait timeout
  956. * DWT_INT_RXPTO 0x00200000 // preamble detect timeout
  957. * DWT_INT_SFDT 0x04000000 // SFD timeout
  958. * DWT_INT_ARFE 0x20000000 // frame rejected (due to frame filtering configuration)
  959. *
  960. *
  961. * input parameters:
  962. * @param bitmask - sets the events which will generate interrupt
  963. * @param enable - if set the interrupts are enabled else they are cleared
  964. *
  965. * output parameters
  966. *
  967. * no return value
  968. */
  969. void dwt_setinterrupt( uint32_t bitmask, uint8_t enable);
  970. /*! ------------------------------------------------------------------------------------------------------------------
  971. * Function: dwt_setpanid()
  972. *
  973. * Description: This is used to set the PAN ID
  974. *
  975. *
  976. * input parameters
  977. * @param panID - this is the PAN ID
  978. *
  979. * output parameters
  980. *
  981. * no return value
  982. */
  983. void dwt_setpanid(uint16_t panID);
  984. /*! ------------------------------------------------------------------------------------------------------------------
  985. * Function: dwt_setaddress16()
  986. *
  987. * Description: This is used to set 16-bit (short) address
  988. *
  989. *
  990. * input parameters
  991. * @param shortAddress - this sets the 16 bit short address
  992. *
  993. * output parameters
  994. *
  995. * no return value
  996. */
  997. void dwt_setaddress16(uint16_t shortAddress);
  998. /*! ------------------------------------------------------------------------------------------------------------------
  999. * Function: dwt_seteui()
  1000. *
  1001. * Description: This is used to set the EUI 64-bit (long) address
  1002. *
  1003. * input parameters
  1004. * @param eui64 - this is the pointer to a buffer that contains the 64bit address
  1005. *
  1006. * output parameters
  1007. *
  1008. * no return value
  1009. */
  1010. void dwt_seteui(uint8_t *eui64);
  1011. /*! ------------------------------------------------------------------------------------------------------------------
  1012. * Function: dwt_geteui()
  1013. *
  1014. * Description: This is used to get the EUI 64-bit from the DW1000
  1015. *
  1016. * input parameters
  1017. * @param eui64 - this is the pointer to a buffer that will contain the read 64-bit EUI value
  1018. *
  1019. * output parameters
  1020. *
  1021. * no return value
  1022. */
  1023. void dwt_geteui(uint8_t *eui64);
  1024. /*! ------------------------------------------------------------------------------------------------------------------
  1025. * Function: dwt_enableframefilter()
  1026. *
  1027. * Description: This is used to enable the frame filtering - (the default option is to
  1028. * accept any data and ack frames with correct destination address
  1029. *
  1030. * input parameters
  1031. * @param - bitmask - enables/disables the frame filtering options according to
  1032. * DWT_FF_NOTYPE_EN 0x000 no frame types allowed
  1033. * DWT_FF_COORD_EN 0x002 behave as coordinator (can receive frames with no destination address (PAN ID has to match))
  1034. * DWT_FF_BEACON_EN 0x004 beacon frames allowed
  1035. * DWT_FF_DATA_EN 0x008 data frames allowed
  1036. * DWT_FF_ACK_EN 0x010 ack frames allowed
  1037. * DWT_FF_MAC_EN 0x020 mac control frames allowed
  1038. * DWT_FF_RSVD_EN 0x040 reserved frame types allowed
  1039. *
  1040. * output parameters
  1041. *
  1042. * no return value
  1043. */
  1044. void dwt_enableframefilter(uint16_t bitmask);
  1045. /*! ------------------------------------------------------------------------------------------------------------------
  1046. * Function: dwt_enableautoack()
  1047. *
  1048. * Description: This call enables the auto-ACK feature. If the responseDelayTime (paramter) is 0, the ACK will be sent a.s.a.p.
  1049. * otherwise it will be sent with a programmed delay (in symbols), max is 255.
  1050. *
  1051. * input parameters
  1052. * @param responseDelayTime - if non-zero the ACK is sent after this delay, max is 255.
  1053. *
  1054. * output parameters
  1055. *
  1056. * no return value
  1057. */
  1058. void dwt_enableautoack(uint8_t responseDelayTime);
  1059. /*! ------------------------------------------------------------------------------------------------------------------
  1060. * Function: dwt_setrxaftertxdelay()
  1061. *
  1062. * Description: This sets the receiver turnon delay time after a transmission of a frame
  1063. *
  1064. * input parameters
  1065. * @param rxDelayTime - (20 bits) - the delay is in micro seconds
  1066. *
  1067. * output parameters
  1068. *
  1069. * no return value
  1070. */
  1071. void dwt_setrxaftertxdelay(uint32_t rxDelayTime);
  1072. /*! ------------------------------------------------------------------------------------------------------------------
  1073. * Function: dwt_rxreset()
  1074. *
  1075. * Description: this function resets the receiver of DW1000
  1076. *
  1077. * input parameters:
  1078. *
  1079. * output parameters
  1080. *
  1081. * no return value
  1082. */
  1083. void dwt_rxreset(void);
  1084. /*! ------------------------------------------------------------------------------------------------------------------
  1085. * Function: dwt_softreset()
  1086. *
  1087. * Description: this function resets the DW1000
  1088. *
  1089. * input parameters:
  1090. *
  1091. * output parameters
  1092. *
  1093. * no return value
  1094. */
  1095. void dwt_softreset(void) ;
  1096. /*! ------------------------------------------------------------------------------------------------------------------
  1097. * Function: dwt_readrxdata()
  1098. *
  1099. * Description: This is used to read the data from the RX buffer, from an offset location give by offset paramter
  1100. *
  1101. * input parameters
  1102. * @param buffer - the buffer into which the data will be read
  1103. * @param length - the length of data to read (in bytes)
  1104. * @param rxBufferOffset - the offset in the rx buffer from which to read the data
  1105. *
  1106. * output parameters
  1107. *
  1108. * no return value
  1109. */
  1110. void dwt_readrxdata(uint8_t *buffer, uint16_t length, uint16_t rxBufferOffset);
  1111. /*! ------------------------------------------------------------------------------------------------------------------
  1112. * Function: dwt_readaccdata()
  1113. *
  1114. * Description: This is used to read the data from the Accumulator buffer, from an offset location give by offset parameter
  1115. *
  1116. * input parameters
  1117. * @param buffer - the buffer into which the data will be read
  1118. * @param length - the length of data to read (in bytes)
  1119. * @param rxBufferOffset - the offset in the acc buffer from which to read the data
  1120. *
  1121. * output parameters
  1122. *
  1123. * no return value
  1124. */
  1125. void dwt_readaccdata(uint8_t *buffer, uint16_t length, uint16_t rxBufferOffset);
  1126. /*! ------------------------------------------------------------------------------------------------------------------
  1127. * Function: dwt_readdignostics()
  1128. *
  1129. * Description: Description: this function reads the rx signal quality diagnostic data
  1130. *
  1131. * input parameters
  1132. * @param diagnostics - diagnostic structure pointer, this will contain the diagnostic data read from the DW1000
  1133. *
  1134. * output parameters
  1135. *
  1136. * no return value
  1137. */
  1138. void dwt_readdignostics(dwt_rxdiag_t * diagnostics);
  1139. /*! ------------------------------------------------------------------------------------------------------------------
  1140. * Function: dwt_loadopsettabfromotp()
  1141. *
  1142. * Description: This is used to select which Operational Parameter Set table to load from OTP memory
  1143. *
  1144. * input parameters
  1145. * @param - opset table selection
  1146. * DWT_OPSET_64LEN = 0x0 - load the operational parameter set table for 64 length preamble configuration
  1147. * DWT_OPSET_TIGHT = 0x1 - load the operational parameter set table for tight xtal offsets (<1ppm)
  1148. * DWT_OPSET_DEFLT = 0x2 - load the default operational parameter set table (this is loaded from reset)
  1149. * output parameters
  1150. *
  1151. * no return value
  1152. */
  1153. void dwt_loadopsettabfromotp(uint8_t gtab_sel);
  1154. /*! ------------------------------------------------------------------------------------------------------------------
  1155. * Function: dwt_configeventcounters()
  1156. *
  1157. * Description: This is used to enable/disable the event counter in the IC
  1158. *
  1159. * input parameters
  1160. * @param - enable - 1 enables (and reset), 0 disables the event counters
  1161. * output parameters
  1162. *
  1163. * no return value
  1164. */
  1165. void dwt_configeventcounters(int enable);
  1166. /*! ------------------------------------------------------------------------------------------------------------------
  1167. * Function: dwt_readeventcounters()
  1168. *
  1169. * Description: This is used to read the event counters in the IC
  1170. *
  1171. * input parameters
  1172. * @param counters - pointer to the dwt_deviceentcnts_t structure which will hold the read data
  1173. *
  1174. * output parameters
  1175. *
  1176. * no return value
  1177. */
  1178. void dwt_readeventcounters(dwt_deviceentcnts_t *counters);
  1179. /*! ------------------------------------------------------------------------------------------------------------------
  1180. * Function: dwt_otpwriteandverify()
  1181. *
  1182. * Description: This is used to program 32-bit value into the DW1000 OTP memory.
  1183. *
  1184. * input parameters
  1185. * @param value - this is the 32-bit value to be programmed into OTP
  1186. * @param address - this is the 16-bit OTP address into which the 32-bit value is programmed
  1187. *
  1188. * output parameters
  1189. *
  1190. * returns DWT_DECA_SUCCESS for success, or DWT_DECA_ERROR for error
  1191. */
  1192. uint32_t dwt_otpwriteandverify(uint32_t value, uint16_t address);
  1193. /*! ------------------------------------------------------------------------------------------------------------------
  1194. * Function: dwt_setleds()
  1195. *
  1196. * Description: This is used to set up Tx/Rx GPIOs which could be used to control LEDs
  1197. * Note: not completely IC dependent, also needs board with LEDS fitted on right I/O lines
  1198. *
  1199. * input parameters
  1200. * @param test - if 1 the LEDs will be enabled, if 0 the LED control is disabled.
  1201. * - if value is 2 the LEDs will flash once after enable.
  1202. *
  1203. * output parameters
  1204. *
  1205. * no return value
  1206. */
  1207. void dwt_setleds(uint8_t test) ;
  1208. /*! ------------------------------------------------------------------------------------------------------------------
  1209. * Function: dwt_xtaltrim()
  1210. *
  1211. * Description: This is used adjust the crystal frequency
  1212. *
  1213. * input parameters:
  1214. * @param value - crystal trim value (in range 0x0 to 0x1F) 31 steps (~1.5ppm per step)
  1215. *
  1216. * output parameters
  1217. *
  1218. * no return value
  1219. */
  1220. void dwt_xtaltrim(uint8_t value);
  1221. /*! ------------------------------------------------------------------------------------------------------------------
  1222. * Function: dwt_configcwmode()
  1223. *
  1224. * Description: this function sets the DW1000 to transmit cw signal at specific channel frequency
  1225. *
  1226. * input parameters:
  1227. * @param chan - specifies the operating channel (e.g. 1, 2, 3, 4, 5, 6 or 7)
  1228. *
  1229. * output parameters
  1230. *
  1231. * returns DWT_DECA_SUCCESS for success, or DWT_DECA_ERROR for error
  1232. */
  1233. int dwt_configcwmode(uint8_t chan);
  1234. /*! ------------------------------------------------------------------------------------------------------------------
  1235. * Function: dwt_configcontinuousframemode()
  1236. *
  1237. * Description: this function sets the DW1000 to continuous tx frame mode
  1238. *
  1239. * input parameters:
  1240. * @param framerepetitionrate - specifies the frame repetition rate
  1241. *
  1242. * output parameters
  1243. *
  1244. * no return value
  1245. */
  1246. void dwt_configcontinuousframemode(uint32_t framerepetitionrate);
  1247. /*! ------------------------------------------------------------------------------------------------------------------
  1248. * @fn dwt_readtempvbat()
  1249. *
  1250. * @brief this function reads the battery voltage and temperature of the MP
  1251. * The values read here will be the current values sampled by DW1000 AtoD converters.
  1252. * Note on Temperature: the temperature value needs to be converted to give the real temperature
  1253. * the formula is: 1.13 * reading - 113.0
  1254. * Note on Voltage: the voltage value needs to be converted to give the real voltage
  1255. * the formula is: 0.0057 * reading + 2.3
  1256. *
  1257. * NB: To correctly read the temperature this read should be done with xtal clock
  1258. * however that means that the receiver will be switched off, if receiver needs to be on then
  1259. * the timer is used to make sure the value is stable before reading
  1260. *
  1261. * input parameters:
  1262. * @param fastSPI - set to 1 if SPI rate > than 3MHz is used
  1263. *
  1264. * output parameters
  1265. *
  1266. * returns (temp_raw<<8)|(vbat_raw)
  1267. */
  1268. uint16_t dwt_readtempvbat(uint8_t fastSPI);
  1269. /*! ------------------------------------------------------------------------------------------------------------------
  1270. * Function: dwt_readwakeuptemp()
  1271. *
  1272. * Description: this function reads the temperature of the DW1000 that was sampled
  1273. * on waking from Sleep/Deepsleep. They are not current values, but read on last
  1274. * wakeup if DWT_TANDV bit is set in mode parameter of dwt_configuresleep
  1275. *
  1276. * input parameters:
  1277. *
  1278. * output parameters:
  1279. *
  1280. * returns: 8-bit raw temperature sensor value
  1281. */
  1282. uint8_t dwt_readwakeuptemp(void) ;
  1283. /*! ------------------------------------------------------------------------------------------------------------------
  1284. * Function: dwt_readwakeupvbat()
  1285. *
  1286. * Description: this function reads the battery voltage of the DW1000 that was sampled
  1287. * on waking from Sleep/Deepsleep. They are not current values, but read on last
  1288. * wakeup if DWT_TANDV bit is set in mode parameter of dwt_configuresleep
  1289. *
  1290. * input parameters:
  1291. *
  1292. * output parameters:
  1293. *
  1294. * returns: 8-bit raw battery voltage sensor value
  1295. */
  1296. uint8_t dwt_readwakeupvbat(void) ;
  1297. /*! ------------------------------------------------------------------------------------------------------------------
  1298. * Function: dwt_writetodevice()
  1299. *
  1300. * Description: this function is used to write to the DW1000 device registers
  1301. * Notes:
  1302. * 1. Firstly we create a header (the first byte is a header byte)
  1303. * a. check if sub index is used, if subindexing is used - set bit-6 to 1 to signify that the sub-index address follows the register index byte
  1304. * b. set bit-7 (or with 0x80) for write operation
  1305. * c. if extended sub address index is used (i.e. if index > 127) set bit-7 of the first sub-index byte following the first header byte
  1306. *
  1307. * 2. Write the header followed by the data bytes to the DW1000 device
  1308. *
  1309. *
  1310. * input parameters:
  1311. * @param recordNumber - ID of register file or buffer being accessed
  1312. * @param index - byte index into register file or buffer being accessed
  1313. * @param length - number of bytes being written
  1314. * @param buffer - pointer to buffer containing the 'length' bytes to be written
  1315. *
  1316. * output parameters
  1317. *
  1318. * returns DWT_DECA_SUCCESS for success, or DWT_DECA_ERROR for error
  1319. */
  1320. int dwt_writetodevice // returns 0 for success, or, -1 for error.
  1321. (
  1322. uint16_t recordNumber, // input parameter - ID of register file or buffer being accessed
  1323. uint16_t index, // input parameter - byte index into register file or buffer being accessed
  1324. uint32_t length, // input parameter - number of bytes being written
  1325. const uint8_t *buffer // input parameter - pointer to buffer containing the 'length' bytes to be written
  1326. ) ;
  1327. /*! ------------------------------------------------------------------------------------------------------------------
  1328. * Function: dwt_readfromdevice()
  1329. *
  1330. * Description: this function is used to read from the DW1000 device registers
  1331. * Notes:
  1332. * 1. Firstly we create a header (the first byte is a header byte)
  1333. * a. check if sub index is used, if subindexing is used - set bit-6 to 1 to signify that the sub-index address follows the register index byte
  1334. * b. set bit-7 (or with 0x80) for write operation
  1335. * c. if extended sub address index is used (i.e. if index > 127) set bit-7 of the first sub-index byte following the first header byte
  1336. *
  1337. * 2. Write the header followed by the data bytes to the DW1000 device
  1338. * 3. Store the read data in the input buffer
  1339. *
  1340. * input parameters:
  1341. * @param recordNumber - ID of register file or buffer being accessed
  1342. * @param index - byte index into register file or buffer being accessed
  1343. * @param length - number of bytes being read
  1344. * @param buffer - pointer to buffer in which to return the read data.
  1345. *
  1346. * output parameters
  1347. *
  1348. * returns DWT_DECA_SUCCESS for success, or DWT_DECA_ERROR for error
  1349. */
  1350. int dwt_readfromdevice // returns offset where requested data begins in supplied buffer, or, -1 for error.
  1351. (
  1352. uint16_t recordNumber, // input parameter - ID of register file or buffer being accessed
  1353. uint16_t index, // input parameter - byte index into register file or buffer being accessed
  1354. uint32_t length, // input parameter - number of bytes being read
  1355. uint8_t *buffer // input parameter - pointer to buffer in which to return the read data.
  1356. ) ;
  1357. /*! ------------------------------------------------------------------------------------------------------------------
  1358. * Function: dwt_read32bitoffsetreg()
  1359. *
  1360. * Description: this function is used to read 32-bit value from the DW1000 device registers
  1361. *
  1362. * input parameters:
  1363. * @param regFileID - ID of register file or buffer being accessed
  1364. * @param regOffset - the index into register file or buffer being accessed
  1365. *
  1366. * output parameters
  1367. *
  1368. * returns 32 bit register value (success), or DWT_DECA_ERROR for error
  1369. */
  1370. uint32_t dwt_read32bitoffsetreg(int regFileID, int regOffset) ;
  1371. /*! ------------------------------------------------------------------------------------------------------------------
  1372. * Function: dwt_write32bitoffsetreg()
  1373. *
  1374. * Description: this function is used to write 32-bit value to the DW1000 device registers
  1375. *
  1376. * input parameters:
  1377. * @param regFileID - ID of register file or buffer being accessed
  1378. * @param regOffset - the index into register file or buffer being accessed
  1379. * @param regval - the value to write
  1380. *
  1381. * output parameters
  1382. *
  1383. * returns DWT_DECA_SUCCESS for success, or DWT_DECA_ERROR for error
  1384. */
  1385. int dwt_write32bitoffsetreg(int regFileID, int regOffset, uint32_t regval);
  1386. /*! ------------------------------------------------------------------------------------------------------------------
  1387. * Function: dwt_read16bitoffsetreg()
  1388. *
  1389. * Description: this function is used to read 16-bit value from the DW1000 device registers
  1390. *
  1391. * input parameters:
  1392. * @param regFileID - ID of register file or buffer being accessed
  1393. * @param regOffset - the index into register file or buffer being accessed
  1394. *
  1395. * output parameters
  1396. *
  1397. * returns 16 bit register value (success), or DWT_DECA_ERROR for error
  1398. */
  1399. uint16_t dwt_read16bitoffsetreg(int regFileID, int regOffset);
  1400. /*! ------------------------------------------------------------------------------------------------------------------
  1401. * Function: dwt_write16bitoffsetreg()
  1402. *
  1403. * Description: this function is used to write 16-bit value to the DW1000 device registers
  1404. *
  1405. * input parameters:
  1406. * @param regFileID - ID of register file or buffer being accessed
  1407. * @param regOffset - the index into register file or buffer being accessed
  1408. * @param regval - the value to write
  1409. *
  1410. * output parameters
  1411. *
  1412. * returns DWT_DECA_SUCCESS for success, or DWT_DECA_ERROR for error
  1413. */
  1414. int dwt_write16bitoffsetreg(int regFileID, int regOffset, uint16_t regval) ;
  1415. #define dwt_write32bitreg(x,y) dwt_write32bitoffsetreg(x,0,y)
  1416. #define dwt_read32bitreg(x) dwt_read32bitoffsetreg(x,0)
  1417. /*! ------------------------------------------------------------------------------------------------------------------
  1418. * Function: writetospi()
  1419. *
  1420. * Description:
  1421. * NB: In porting this to a particular microporcessor, the implementer needs to define the two low
  1422. * level abstract functions to write to and read from the SPI the definitions should be in deca_spi.c file.
  1423. * Low level abstract function to write to the SPI
  1424. * Takes two separate byte buffers for write header and write data
  1425. * returns 0 for success, or -1 for error
  1426. *
  1427. * Note: The body of this function is defined in deca_spi.c and is platform specific
  1428. *
  1429. * input parameters:
  1430. * @param headerLength - number of bytes header being written
  1431. * @param headerBuffer - pointer to buffer containing the 'headerLength' bytes of header to be written
  1432. * @param bodylength - number of bytes data being written
  1433. * @param bodyBuffer - pointer to buffer containing the 'bodylength' bytes od data to be written
  1434. *
  1435. * output parameters
  1436. *
  1437. * returns DWT_DECA_SUCCESS for success, or DWT_DECA_ERROR for error
  1438. */
  1439. extern int32_t writetospi // returns 0 for success, or, -1 for error.
  1440. (
  1441. uint16_t headerLength, // input parameter - number of bytes header being written
  1442. const uint8_t *headerBuffer, // input parameter - pointer to buffer containing the 'headerLength' bytes of header to be written
  1443. uint32_t bodylength, // input parameter - number of bytes data being written
  1444. const uint8_t *bodyBuffer // input parameter - pointer to buffer containing the 'bodylength' bytes od data to be written
  1445. ) ;
  1446. /*! ------------------------------------------------------------------------------------------------------------------
  1447. * Function: readfromspi()
  1448. *
  1449. * Description:
  1450. * NB: In porting this to a particular microporcessor, the implementer needs to define the two low
  1451. * level abstract functions to write to and read from the SPI the definitions should be in deca_spi.c file.
  1452. * Low level abstract function to write to the SPI
  1453. * Takes two separate byte buffers for write header and write data
  1454. * returns 0 for success, or -1 for error
  1455. *
  1456. * Note: The body of this function is defined in deca_spi.c and is platform specific
  1457. *
  1458. * input parameters:
  1459. * @param headerLength - number of bytes header to write
  1460. * @param headerBuffer - pointer to buffer containing the 'headerLength' bytes of header to write
  1461. * @param bodylength - number of bytes data being read
  1462. * @param bodyBuffer - pointer to buffer containing to return the data (NB: size required = headerLength + readlength)
  1463. *
  1464. * output parameters
  1465. *
  1466. * returns DWT_DECA_SUCCESS for success (and the position in the buffer at which data begins), or DWT_DECA_ERROR for error
  1467. */
  1468. extern int32_t readfromspi // returns offset where requested data begins in supplied buffer, or, -1 for error.
  1469. (
  1470. uint16_t headerLength, // input parameter - number of bytes header to write
  1471. const uint8_t *headerBuffer, // input parameter - pointer to buffer containing the 'headerLength' bytes of header to write
  1472. uint32_t readlength, // input parameter - number of bytes data being read
  1473. uint8_t *readBuffer // input parameter - pointer to buffer containing to return the data (NB: size required = headerLength + readlength)
  1474. ) ;
  1475. /*! ------------------------------------------------------------------------------------------------------------------
  1476. * Function: dwt_getrangebias()
  1477. *
  1478. * Description: This function is used to return the range bias correction need for TWR with DW1000 units.
  1479. *
  1480. * input parameters:
  1481. * @param chan - specifies the operating channel (e.g. 1, 2, 3, 4, 5, 6 or 7)
  1482. * @param range - the calculated distance before correction
  1483. * @param prf - this is the PRF e.g. DWT_PRF_16M or DWT_PRF_64M
  1484. *
  1485. * output parameters
  1486. *
  1487. * returns correction needed in meters
  1488. */
  1489. double dwt_getrangebias(uint8_t chan, float range, uint8_t prf);
  1490. // ---------------------------------------------------------------------------
  1491. //
  1492. // NB: The purpose of the deca_mutex.c file is to provide for microprocessor interrupt enable/disable, this is used for
  1493. // controlling mutual exclusion from critical sections in the code where interrupts and background
  1494. // processing may interact. The code using this is kept to a minimum and the disabling time is also
  1495. // kept to a mimimum, so blanket interrupt disable may be the easiest way to provide this. But at a
  1496. // minimum those interrrupts coming from the decawave device should be disabled/reenabled by this activity.
  1497. //
  1498. // In porting this to a particular microporcessor, the implementer may choose to use #defines here
  1499. // to map these calls transparently to the target system. Alternatively the appropriate code may
  1500. // be embedded in the functions provided in the deca_irq.c file.
  1501. //
  1502. // ---------------------------------------------------------------------------
  1503. typedef int decaIrqStatus_t ; // type for remembering IRQ status
  1504. /*! ------------------------------------------------------------------------------------------------------------------
  1505. * Function: decamutexon()
  1506. *
  1507. * Description: This function should disable interrupts. This is called at the start of a critical section
  1508. * It returns the irq state before disable, this value is used to reenable in decamutexoff call
  1509. *
  1510. * Note: The body of this function is defined in deca_mutex.c and is platform specific
  1511. *
  1512. * input parameters:
  1513. *
  1514. * output parameters
  1515. *
  1516. * returns the state of the DW1000 interrupt
  1517. */
  1518. decaIrqStatus_t decamutexon(void) ;
  1519. /*! ------------------------------------------------------------------------------------------------------------------
  1520. * Function: decamutexoff()
  1521. *
  1522. * Description: This function should re-enable interrupts, or at least restore their state as returned(&saved) by decamutexon
  1523. * This is called at the end of a critical section
  1524. *
  1525. * Note: The body of this function is defined in deca_mutex.c and is platform specific
  1526. *
  1527. * input parameters:
  1528. * @param s - the state of the DW1000 interrupt as returned by decamutexon
  1529. *
  1530. * output parameters
  1531. *
  1532. * returns the state of the DW1000 interrupt
  1533. */
  1534. void decamutexoff(decaIrqStatus_t s) ;
  1535. // -------------------------------------------------------------------------------------------------------------------
  1536. // Debug API functions
  1537. // -------------------------------------------------------------------------------------------------------------------
  1538. #if (REG_DUMP==1)
  1539. // -------------------------------------------------------------------------------------------------------------------
  1540. // Reads the DW1000 register data to the given string
  1541. void dwt_dumpregisters(char *str, size_t strSize);
  1542. #endif
  1543. #ifdef __cplusplus
  1544. }
  1545. #endif
  1546. #endif /* _DECA_DEVICE_API_H_ */