TI BLE5-Stack API Documentation  2.00.04.00
TOF.h
Go to the documentation of this file.
1 /******************************************************************************
2 
3  @file TOF.h
4 
5  @brief This file contains methods to enable/disable and control TOF
6  Group: WCS, BTS
7  $Target Device: DEVICES $
8 
9  ******************************************************************************
10  $License: BSD3 2018 $
11  ******************************************************************************
12  $Release Name: PACKAGE NAME $
13  $Release Date: PACKAGE RELEASE DATE $
14  *****************************************************************************/
15 
26 #ifndef TOF_H_
27 #define TOF_H_
28 
29 #ifdef __cplusplus
30 extern "C"
31 {
32 #endif
33 
34 /*********************************************************************
35  * INCLUDES
36  */
37 
38 /* RF includes */
39 #include <ti/drivers/rf/RF.h>
40 
41 #include <ti/devices/DeviceFamily.h>
42 #include "rfc_cmd_tof.h"
43 #include "tof_security.h"
44 
45 /*********************************************************************
46  * CONSTANTS
47  */
48 
49 #define TOF_TIMEOUTVAL 0xFFFFFFFF
50 
51 #define TOF_MAX_NUM_FREQ 20
52 
53 #define TOF_SEEDLEN 32
54 
55 #define TOF_NUM_RFC_BURST_PKTS 32
56 
57 #define TOF_COMPENSATION_NO_COMP 0
58 #define TOF_COMPENSATION_STIM_COMP 1
59 #define TOF_COMPENSATION_CORRELATOR_COMP 2
60 
61 // If using partial result readout or double sync word buffer, these are the event ID's
62 #define IRQN_PARTIAL_READ_READY 15
63 #define IRQN_DOUBLE_SYNCWORD_BUFFER_SWITCH 11
64 #define RF_EventPartialReadReady (1 << IRQN_PARTIAL_READ_READY)
65 #define RF_EventDoubleSyncWordBufferSwitch (1 << IRQN_DOUBLE_SYNCWORD_BUFFER_SWITCH)
66 
67 #define TOF_FILL_BOTH_BUFF TOF_SEC_FILL_BOTH_BUFFS
68 #define TOF_FILL_1ST_BUFF TOF_SEC_FILL_1ST_BUFF
69 #define TOF_FILL_2ND_BUFF TOF_SEC_FILL_2ND_BUFF
70 
71 // The ready-flags for the double buffers
72 #define syncWordBufferOneReady 0x01
73 #define syncWordBufferTwoReady 0x02
74 
75 #define TICK_TO_METER (6.25 * 3)
76 
77 #define TOF_PATCH_LOCATION 0x21000914
78 #define SUCCESS 0x00
79 #define FAILURE 0x01
80 
81 #ifdef USE_TRACER
83 /* tracer configuration */
84 #define CMD_ENABLE_DBG_CMDID 0x602
85 #define CMD_ENABLE_DBG_CONFIG ((0<<14) | (1<<12) | (1<<11) | (2<<9) | (1<<8) | (1<<6))
86 #endif // USE_TRACER
87 
89 /*********************************************************************
90  * MACROS
91  */
92 
93 /*********************************************************************
94  * TYPEDEFS
95  */
96 
101 typedef enum
103 {
104  ToF_ROLE_SLAVE = 0,
105  ToF_ROLE_MASTER,
106  ToF_ROLE_PASSIVE
107 } ToF_Role;
108 
110 /* tracer configuration */
111 
112 typedef rfc_CMD_TOF_sample_t ToF_Sample;
113 
115 typedef rfc_CMD_TOF_synthCal_t ToF_SynthCal;
116 
117 typedef uint8_t* ToF_TX_Buf;
118 typedef uint8_t* ToF_RX_Buf;
119 
121 typedef void (*TOF_ApplicationCB)(void);
123 
125 typedef struct
126 {
127  RF_Object rfObject;
128  RF_Handle rfHandle;
129  ToF_Role tofRole;
130  uint8_t numFreqs;
131  uint16_t *pFrequencies;
132  uint8_t freqChangePeriod;
133  ToF_SynthCal synthCal[TOF_MAX_NUM_FREQ];
134  ToF_TX_Buf pTxBuf;
135  ToF_RX_Buf pRxBuf;
136  ToF_Sample *pT1RSSIBuf;
137  uint16_t numBurstSamples;
138 } ToF_Object, ToF_Struct, *ToF_Handle;
140 
142 typedef struct
143 {
144  ToF_Role tofRole;
145  ToF_Sample *pT1RSSIBuf;
146  uint16_t numBurstSamples;
147  uint8_t *pTxBuf;
148  uint8_t *pRxBuf;
149  uint16_t *pFrequencies;
150  uint8_t numFreq;
152  uint8_t mask;
154  uint16_t syncTimeout;
156  uint8_t constSyncwords;
157 } ToF_Params;
158 
160 typedef struct
161 {
162  uint16_t freq;
163  double tick;
164  double tickVariance;
165  uint32_t numOk;
166 } ToF_BurstStat;
167 
169 typedef struct
170 {
171  uint32_t freq;
172  RF_EventMask rfEvent;
173  uint32_t ratSyncTime;
174 } ToF_Status;
177 /*-------------------------------------------------------------------
178  * FUNCTIONS
179  */
180 
189 ToF_Handle TOF_open(ToF_Struct *tofStruct, ToF_Params *params);
190 
199 ToF_Status TOF_run(ToF_Handle handle, uint32_t nextTaskTime);
200 
201 
202 
210 void TOF_clearBuffers(ToF_Handle handle);
211 
220 void TOF_getBurstStat(ToF_Handle handle, ToF_BurstStat **resultBuffer);
221 
229 void TOF_close(ToF_Handle handle);
230 
236 uint8_t TOF_genSeed(void);
237 
246 uint8_t TOF_setSeed(uint8_t* newSeed);
247 
255 uint8_t TOF_getSeed(uint8_t *dst);
256 
262 uint8_t TOF_initSyncWords(void);
263 
269 void TOF_skipSyncWords(void);
270 
271 /* For frequency calibration: */
272 #define CMD_READ_FS_CAL 0x000D
273 
274 struct __RFC_STRUCT rfc_CMD_READ_FS_CAL_s
276 {
277  uint16_t commandNo;
278  uint8_t __dummy0;
279  uint8_t coarseCal;
280  uint8_t midCal;
281  uint8_t ktCal;
282  uint16_t tdcCal;
283 };
284 typedef struct __RFC_STRUCT rfc_CMD_READ_FS_CAL_s rfc_CMD_READ_FS_CAL_t;
285 
286 /*********************************************************************
287 *********************************************************************/
288 
289 #ifdef __cplusplus
290 }
291 #endif
292 
293 #endif /* TOF_H_ */
294 
uint8_t TOF_setSeed(uint8_t *newSeed)
call ToF Security module to restart the ctr drbg new 128-bit random seed
TOF Burst Stats Structure.
Definition: TOF.h:169
uint8_t TOF_getSeed(uint8_t *dst)
copy 32 byte seed into dst
RF_EventMask rfEvent
RF Event.
Definition: TOF.h:172
uint8_t * pTxBuf
Pointer to Tx buffer.
Definition: TOF.h:147
ToF_Status TOF_run(ToF_Handle handle, uint32_t nextTaskTime)
Start a ToF run.
uint8_t constSyncwords
Generate syncwords only once.
Definition: TOF.h:156
ToF_Handle TOF_open(ToF_Struct *tofStruct, ToF_Params *params)
Initiate RF ToF params and open RF driver.
uint16_t freq
Frequency.
Definition: TOF.h:162
uint8_t mask
Mask for the LFSR.
Definition: TOF.h:152
uint8_t ktCal
KT calibration result.
Definition: TOF.h:281
TOF Parameters Structure.
Definition: TOF.h:142
uint16_t tdcCal
TDC calibration result.
Definition: TOF.h:282
uint16_t syncTimeout
How long to wait for first sync word.
Definition: TOF.h:154
void TOF_getBurstStat(ToF_Handle handle, ToF_BurstStat **resultBuffer)
Get the result for the last ToF burst (run)
ToF_Role tofRole
Slave or master.
Definition: TOF.h:144
#define TOF_MAX_NUM_FREQ
Maximun number of frequencies.
Definition: TOF.h:51
void TOF_skipSyncWords(void)
Skip some syncwords into the future (for synchronization purposes)
void TOF_clearBuffers(ToF_Handle handle)
Clean buffers for the specified ToF Handle.
TOF Burst Stats Structure.
Definition: TOF.h:160
uint8_t * ToF_RX_Buf
Pointer to RX buffer.
Definition: TOF.h:118
uint32_t numOk
Num of Ok Recieved.
Definition: TOF.h:165
uint8_t __dummy0
Reserved.
Definition: TOF.h:278
ToF_Sample * pT1RSSIBuf
Pointer to T1|RSSI result buffer.
Definition: TOF.h:145
void TOF_close(ToF_Handle handle)
Close the ToF and RF drivers.
uint8_t freqChangePeriod
How often should we change freq?
Definition: TOF.h:153
uint8_t midCal
Mid calibration result.
Definition: TOF.h:280
ToF_Role
Enumeration for TOF roles of operation.
Definition: TOF.h:102
uint16_t commandNo
The command ID number 0x0601.
Definition: TOF.h:277
double tick
Clock&#39;s time between ticks.
Definition: TOF.h:163
struct __RFC_STRUCT rfc_CMD_READ_FS_CAL_s rfc_CMD_READ_FS_CAL_t
RF Read frequency calibration command Structure.
Definition: TOF.h:284
uint16_t numBurstSamples
Number of bursts to be made (same as sync word length if using single buffer)
Definition: TOF.h:146
tofSecCfgPrms_t tofSecurityParams
TOF Security Configuration Paramaters.
Definition: TOF.h:151
rfc_CMD_TOF_sample_t ToF_Sample
TOF Sample.
Definition: TOF.h:112
uint8_t * ToF_TX_Buf
Pointer to TX buffer.
Definition: TOF.h:117
uint8_t coarseCal
Coarse calibration result.
Definition: TOF.h:279
RF Read frequency calibration command Structure.
Definition: TOF.h:275
ToF security module interface.
ToF Security Configuration Parameters.
Definition: tof_security.h:102
double tickVariance
Variance of tick value.
Definition: TOF.h:164
TOF_ApplicationCB pfnTofApplicationCB
Callback to application.
Definition: TOF.h:155
uint8_t TOF_initSyncWords(void)
Init sync words buffer, depends on user configuration.
uint8_t numFreq
Number of frequencies in above list.
Definition: TOF.h:150
uint16_t * pFrequencies
Pointer to Frequencies.
Definition: TOF.h:149
uint32_t freq
Frequency.
Definition: TOF.h:171
uint8_t * pRxBuf
Pointer to Rx buffer.
Definition: TOF.h:148
rfc_CMD_TOF_synthCal_t ToF_SynthCal
Pointer to frequency calibration struct, used for the pre-calibration of the synth.
Definition: TOF.h:115
uint32_t ratSyncTime
RAT Sync Time.
Definition: TOF.h:173
void(* TOF_ApplicationCB)(void)
Callback to a handler supplied by the application.
Definition: TOF.h:121
uint8_t TOF_genSeed(void)
call ToF Security module to generate a true 128-bit random seed
© Copyright 1995-2019, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale