TI BLE5-Stack API Documentation  2.01.03.00
rtls_ctrl_tof.h
Go to the documentation of this file.
1 /******************************************************************************
2 
3  @file rtls_ctrl_tof.h
4 
5  @brief This file contains the functions and structures specific to
6  ToF post processing
7  Group: WCS, BTS
8  $Target Device: DEVICES $
9 
10  ******************************************************************************
11  $License: BSD3 2018 $
12  ******************************************************************************
13  $Release Name: PACKAGE NAME $
14  $Release Date: PACKAGE RELEASE DATE $
15  *****************************************************************************/
16 
17 
28 #ifndef RTLS_CTRL_TOF_H_
29 #define RTLS_CTRL_TOF_H_
30 
31 #ifdef __cplusplus
32 extern "C"
33 {
34 #endif
35 
36 /*********************************************************************
37  * INCLUDES
38  */
39 
40 #include "TOF.h"
41 #include "bcomdef.h"
42 #include "rtls_ctrl_api.h"
43 
44 /*********************************************************************
45 * EXTERNAL VARIABLES
46 */
47 
48 /*********************************************************************
49  * CONSTANTS
50  */
51 
52 #define RTLS_CTRL_TOF_RSSI_THRESHOLD_HYSTERESIS -5
53 #define MAX_TOF_SAMPLES_SINGLE_CHUNK 16
54 #define RTLS_TOF_FREQ_PER_NV_BLOCK 4
55 
56 /* NV IDs start here (in user space) and grow with every RTLS_TOF_FREQ_PER_NV_BLOCK
57  * frequencies used. The number of IDs needed is ceiling(NUM_FREQ/RTLS_TOF_FREQ_PER_NV_BLOCK)
58  */
59 #define SNV_ID_CAL_PARAMS BLE_NVID_CUST_START
60 #define SNV_ID_CAL_DATA_SET BLE_NVID_CUST_START+1
61 
62 /*********************************************************************
63  * MACROS
64  */
65 
66 /*********************************************************************
67  * TYPEDEFS
68  */
69 
70 
75 typedef enum
77 {
78  TOF_MODE_DIST,
79  TOF_MODE_STAT,
80  TOF_MODE_RAW
82 
84 typedef enum
85 {
86  TOF_MODE_CONT,
87  TOF_MODE_AUTO
88 } tofRunMode_e;
89 
91 typedef enum
92 {
93  TOF_CALIB_NOT_INITIALIZED,
94  TOF_CALIB_CALIBRATING,
95  TOF_CALIB_CALIBRATED
97 
99 typedef struct
100 {
102  tofResultMode_e resultMode;
103  tofRunMode_e runMode;
105 
107 typedef struct
108 {
109  tofCalibState_e tofCalibState;
111  uint16_t calibrationOffset;
114 
116 typedef struct
117 {
118  uint8_t numFreq;
119  uint16_t calibDistance;
121 
123 typedef struct __attribute__((packed))
124 {
125  uint16_t freq;
126  double tick;
127  double tickVariance;
128  uint32_t numOk;
129 } rtlsTofCalibData_t;
130 
132 typedef struct __attribute__((packed))
133 {
134  rtlsTofCalibParams_t calibParams;
135  rtlsTofCalibData_t calibVals[];
136 } rtlsTofCalibForNV_t;
137 
139 typedef struct __attribute__((packed))
140 {
141  ToF_Role tofRole;
142  uint16_t numSyncwordsPerBurst;
143  uint8_t numFreq;
144  uint8_t slaveLqiFilter;
145  uint8_t postProcessLqiThresh;
146  uint16_t postProcessMagnRatio;
147  rtlsTofConfig_t tofConfig;
148  uint16_t frequencies[];
149 } rtlsTofParams_t;
150 
152 typedef struct __attribute__((packed))
153 {
154  uint8_t seed[TOF_SEEDLEN];
155 } rtlsTofSecSeed_t;
156 
158 typedef struct __attribute__((packed))
159 {
160  uint8_t enableTof;
161 } rtlsEnableTofCmd_t;
162 
164 typedef struct __attribute__((packed))
165 {
166  uint8_t enableCalib;
167  uint16_t samplesPerFreq;
168  uint8_t calibDistance;
169  uint8_t useCalibFromNV;
170 } rtlsEnableTofCalib_t;
171 
173 typedef struct __attribute__((packed))
174 {
175  double distance;
176  int8_t rssi;
177 } rtlsTofResultDistance_t;
178 
180 typedef struct __attribute__((packed))
181 {
182  uint32_t tick;
183  uint8_t freqIdx;
184  int8_t rssi;
185 } rtlsTofResultRaw_t;
186 
188 typedef struct __attribute__((packed))
189 {
190  uint16_t offset;
191  uint16_t samplesLength;
192  rtlsTofResultRaw_t samples[];
193 } rtlsTofResultRawAggr_t;
194 
196 typedef struct __attribute__((packed))
197 {
198  uint16_t freq;
199  double tick;
200  double tickVariance;
201  int8_t rssi;
202  uint32_t numOk;
203 } rtlsTofResultStat_t;
204 
206 typedef struct
207 {
208  ToF_Struct tofStruct;
209  ToF_Handle tofHandle;
217 } rtlsTof_t;
220 /*********************************************************************
221  * API FUNCTIONS
222  */
223 
232 void RTLSCtrl_postProcessTof(rtlsTof_t *tofControlBlock, int8_t rssi);
233 
244 void RTLSCtrl_outputTofStat(uint8_t cmdId, uint16_t numFreq, ToF_BurstStat *tofStatArray, uint8_t rssi);
245 
256 void RTLSCtrl_outputCalibFromNV(uint8_t cmdId, uint8_t numFreq, uint16_t calibDistance, ToF_BurstStat *pCalibVals);
257 
267 
278 
286 void RTLSCtrl_readCalibFromNV(rtlsTof_t *tofControlBlock);
287 
288 /*********************************************************************
289 *********************************************************************/
290 
291 #ifdef __cplusplus
292 }
293 #endif
294 
295 #endif /* RTLS_CTRL_TOF_H_ */
296 
tofCalibState_e tofCalibState
Calibration state.
Definition: rtls_ctrl_tof.h:109
rtlsStatus_e RTLSCtrl_writeCalibToNV(rtlsTofCalibParams_t calibParams, ToF_BurstStat *pCalibVals)
Write calibration to NV.
ToF_BurstStat * pTofAverage
Array to save average of samples (for each frequency)
Definition: rtls_ctrl_tof.h:213
ToF_BurstStat * pTofLastRun
Array to save samples from the last ToF run.
Definition: rtls_ctrl_tof.h:212
void RTLSCtrl_outputTofStat(uint8_t cmdId, uint16_t numFreq, ToF_BurstStat *tofStatArray, uint8_t rssi)
Output array of ToF_BurstStat.
tofResultMode_e
Enumeration for ToF Result Mode.
Definition: rtls_ctrl_tof.h:76
uint8_t numFreq
Number of frequencies.
Definition: rtls_ctrl_tof.h:118
tofRunMode_e runMode
One-shot/continuous/auto.
Definition: rtls_ctrl_tof.h:103
ToF_BurstStat * pCalibVals
Array to save calibration values.
Definition: rtls_ctrl_tof.h:112
void RTLSCtrl_outputCalibFromNV(uint8_t cmdId, uint8_t numFreq, uint16_t calibDistance, ToF_BurstStat *pCalibVals)
Output calibration parameters and values.
rtlsTofCalib_t tofCalibInfo
Information about ToF calibration.
Definition: rtls_ctrl_tof.h:211
uint8_t bSlaveTofEnabled
Used to determine whether slave is doing ToF or not.
Definition: rtls_ctrl_tof.h:216
TOF Burst Stats Structure.
Definition: TOF.h:186
ToF calibration information.
Definition: rtls_ctrl_tof.h:107
rtlsTofConfig_t tofConfig
Values configured by the user.
Definition: rtls_ctrl_tof.h:210
int8_t autoTofRssiTresh
RSSI threshold.
Definition: rtls_ctrl_tof.h:101
tofCalibState_e
Enumeration for ToF calibration states.
Definition: rtls_ctrl_tof.h:91
ToF_Role
Enumeration for TOF roles of operation.
Definition: TOF.h:100
uint16_t calibDistance
The distance at which calibration is being performed (will be subtracted from final result) ...
Definition: rtls_ctrl_tof.h:119
Type definitions and macros for BLE stack.
void RTLSCtrl_postProcessTof(rtlsTof_t *tofControlBlock, int8_t rssi)
Post process a ToF run.
Aggregation of ToF structures needed for RTLS Control operation (saved in gRtlsData) ...
Definition: rtls_ctrl_tof.h:206
ToF_Struct tofStruct
Struct will be filled by TOF_open.
Definition: rtls_ctrl_tof.h:208
struct __attribute__((packed))
BLE Connection information.
Definition: rtls_ble.h:59
#define TOF_SEEDLEN
Seed Length in Bytes.
Definition: TOF.h:53
tofRunMode_e
Enumeration for ToF Run Mode.
Definition: rtls_ctrl_tof.h:84
tofResultMode_e resultMode
On/off-chip result processing.
Definition: rtls_ctrl_tof.h:102
uint8_t bTofValuesInitialized
Flag to check if ToF was run at least once.
Definition: rtls_ctrl_tof.h:214
uint16_t calibrationOffset
The distance at which calibration is being performed (will be subtracted from final result) ...
Definition: rtls_ctrl_tof.h:111
ToF_Handle tofHandle
Handle will be passed to the TOF driver for actions.
Definition: rtls_ctrl_tof.h:209
ToF Calibration Parameters For NV.
Definition: rtls_ctrl_tof.h:116
rtlsStatus_e
Enumeration for RTLS Status.
Definition: rtls_ctrl_api.h:94
TOF interface.
This file contains the RTLS Control API's.
uint8_t bSlaveTofParamPend
Used to determine whether to send params to slave when a connection is formed.
Definition: rtls_ctrl_tof.h:215
rtlsStatus_e RTLSCtrl_loadAndverifyCalibNVParams(rtlsTof_t *tofControlBlock)
Verify calibration and load calibration from NV.
Various ToF configurations.
Definition: rtls_ctrl_tof.h:99
void RTLSCtrl_readCalibFromNV(rtlsTof_t *tofControlBlock)
Read calibration From NV.
uint8_t runsForCalibration
Amount runs (instances of TOF_run) needed until calibration is complete.
Definition: rtls_ctrl_tof.h:110
© Copyright 1995-2020, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale