TI BLE-Stack for Bluetooth API Documentation  3.03.00.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 "tof/rfc_cmd_tof.h"
43 #include "tof/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 typedef rfc_CMD_TOF_sample_t ToF_Sample;
111 
113 typedef rfc_CMD_TOF_synthCal_t ToF_SynthCal;
114 
115 typedef uint8_t* ToF_TX_Buf;
116 typedef uint8_t* ToF_RX_Buf;
117 
119 typedef void (*TOF_ApplicationCB)(void);
121 
123 typedef struct
124 {
125  RF_Object rfObject;
126  RF_Handle rfHandle;
127  ToF_Role tofRole;
128  uint8_t numFreqs;
129  uint16_t *pFrequencies;
130  uint8_t freqChangePeriod;
131  ToF_SynthCal synthCal[TOF_MAX_NUM_FREQ];
132  ToF_TX_Buf pTxBuf;
133  ToF_RX_Buf pRxBuf;
134  ToF_Sample *pT1RSSIBuf;
135  uint16_t numBurstSamples;
136 } ToF_Object, ToF_Struct, *ToF_Handle;
138 
140 typedef struct
141 {
142  ToF_Role tofRole;
143  ToF_Sample *pT1RSSIBuf;
144  uint16_t numBurstSamples;
145  uint8_t *pTxBuf;
146  uint8_t *pRxBuf;
147  uint16_t *pFrequencies;
148  uint8_t numFreq;
150  uint8_t mask;
152  uint16_t syncTimeout;
154  uint8_t constSyncwords;
155 } ToF_Params;
156 
158 typedef struct
159 {
160  uint16_t freq;
161  double tick;
162  double tickVariance;
163  uint32_t numOk;
164 } ToF_BurstStat;
165 
167 typedef struct
168 {
169  uint32_t freq;
170  RF_EventMask rfEvent;
171  uint32_t ratSyncTime;
172 } ToF_Status;
175 /*-------------------------------------------------------------------
176  * FUNCTIONS
177  */
178 
187 ToF_Handle TOF_open(ToF_Struct *tofStruct, ToF_Params *params);
188 
197 ToF_Status TOF_run(ToF_Handle handle, uint32_t nextTaskTime);
198 
206 void TOF_clearBuffers(ToF_Handle handle);
207 
216 void TOF_getBurstStat(ToF_Handle handle, ToF_BurstStat **resultBuffer);
217 
225 void TOF_close(ToF_Handle handle);
226 
232 uint8_t TOF_genSeed(void);
233 
242 uint8_t TOF_setSeed(uint8_t* newSeed);
243 
251 uint8_t TOF_getSeed(uint8_t *dst);
252 
258 uint8_t TOF_initSyncWords(void);
259 
265 void TOF_skipSyncWords(void);
266 
267 /* For frequency calibration: */
268 #define CMD_READ_FS_CAL 0x000D
269 
270 struct __RFC_STRUCT rfc_CMD_READ_FS_CAL_s
272 {
273  uint16_t commandNo;
274  uint8_t __dummy0;
275  uint8_t coarseCal;
276  uint8_t midCal;
277  uint8_t ktCal;
278  uint16_t tdcCal;
279 };
280 typedef struct __RFC_STRUCT rfc_CMD_READ_FS_CAL_s rfc_CMD_READ_FS_CAL_t;
281 
282 /*********************************************************************
283 *********************************************************************/
284 
285 #ifdef __cplusplus
286 }
287 #endif
288 
289 #endif /* TOF_H_ */
290 
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:167
uint8_t TOF_getSeed(uint8_t *dst)
copy 32 byte seed into dst
RF_EventMask rfEvent
RF Event.
Definition: TOF.h:170
uint8_t * pTxBuf
Pointer to Tx buffer.
Definition: TOF.h:145
ToF_Status TOF_run(ToF_Handle handle, uint32_t nextTaskTime)
Start a ToF run.
uint8_t constSyncwords
Generate syncwords only once.
Definition: TOF.h:154
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:160
uint8_t mask
Mask for the LFSR.
Definition: TOF.h:150
uint8_t ktCal
KT calibration result.
Definition: TOF.h:277
TOF Parameters Structure.
Definition: TOF.h:140
uint16_t tdcCal
TDC calibration result.
Definition: TOF.h:278
uint16_t syncTimeout
How long to wait for first sync word.
Definition: TOF.h:152
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:142
#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:158
uint8_t * ToF_RX_Buf
Pointer to RX buffer.
Definition: TOF.h:116
uint32_t numOk
Num of Ok Recieved.
Definition: TOF.h:163
uint8_t __dummy0
Reserved.
Definition: TOF.h:274
ToF_Sample * pT1RSSIBuf
Pointer to T1|RSSI result buffer.
Definition: TOF.h:143
void TOF_close(ToF_Handle handle)
Close the ToF and RF drivers.
uint8_t freqChangePeriod
How often should we change freq?
Definition: TOF.h:151
uint8_t midCal
Mid calibration result.
Definition: TOF.h:276
ToF_Role
Enumeration for TOF roles of operation.
Definition: TOF.h:102
uint16_t commandNo
The command ID number 0x0601.
Definition: TOF.h:273
double tick
Clock&#39;s time between ticks.
Definition: TOF.h:161
struct __RFC_STRUCT rfc_CMD_READ_FS_CAL_s rfc_CMD_READ_FS_CAL_t
RF Read frequency calibration command Structure.
Definition: TOF.h:280
uint16_t numBurstSamples
Number of bursts to be made (same as sync word length if using single buffer)
Definition: TOF.h:144
tofSecCfgPrms_t tofSecurityParams
TOF Security Configuration Paramaters.
Definition: TOF.h:149
rfc_CMD_TOF_sample_t ToF_Sample
TOF Sample.
Definition: TOF.h:110
uint8_t * ToF_TX_Buf
Pointer to TX buffer.
Definition: TOF.h:115
uint8_t coarseCal
Coarse calibration result.
Definition: TOF.h:275
RF Read frequency calibration command Structure.
Definition: TOF.h:271
ToF security module interface.
ToF Security Configuration Parameters.
Definition: tof_security.h:97
double tickVariance
Variance of tick value.
Definition: TOF.h:162
TOF_ApplicationCB pfnTofApplicationCB
Callback to application.
Definition: TOF.h:153
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:148
uint16_t * pFrequencies
Pointer to Frequencies.
Definition: TOF.h:147
uint32_t freq
Frequency.
Definition: TOF.h:169
uint8_t * pRxBuf
Pointer to Rx buffer.
Definition: TOF.h:146
rf commands used by TOF module
rfc_CMD_TOF_synthCal_t ToF_SynthCal
Pointer to frequency calibration struct, used for the pre-calibration of the synth.
Definition: TOF.h:113
uint32_t ratSyncTime
RAT Sync Time.
Definition: TOF.h:171
void(* TOF_ApplicationCB)(void)
Callback to a handler supplied by the application.
Definition: TOF.h:119
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