-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtmf882x_mode_app_ioctl.h
368 lines (340 loc) · 13.6 KB
/
tmf882x_mode_app_ioctl.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
/*
*****************************************************************************
* Copyright by ams AG *
* All rights are reserved. *
* *
* IMPORTANT - PLEASE READ CAREFULLY BEFORE COPYING, INSTALLING OR USING *
* THE SOFTWARE. *
* *
* THIS SOFTWARE IS PROVIDED FOR USE ONLY IN CONJUNCTION WITH AMS PRODUCTS. *
* USE OF THE SOFTWARE IN CONJUNCTION WITH NON-AMS-PRODUCTS IS EXPLICITLY *
* EXCLUDED. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT *
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
*****************************************************************************
*/
/** @file tmf882x_mode_app_ioctl.h
*
* TMF882X APP mode ioctl definitions. See @ref tmf882x_ioctl() for how to pass
* input and output parameters to IOCTL driver mode functions.
*
* _IOCTL_R = IOCTL where driver returns data to the client through output param
* _IOCTL_W = IOCTL where client writes data to the driver through input param
* _IOCTL_RW = IOCTL data is both written by the client though the input param
* and data is returned through the output param
* _IOCTL_N = IOCTL where no data is written or returned
*/
#ifndef __TMF882X_MODE_APP_IOCTL_H
#define __TMF882X_MODE_APP_IOCTL_H
#include "tmf882x_mode.h"
#include "tmf882x_mode_app_protocol.h"
#ifdef __cplusplus
extern "C" {
#endif
/*******************************
* APP mode IOCTL definitions
*******************************/
/** @brief APP mode IOCTL ID */
#define TMF882X_IOCTL_APP_MODE 0x02U
#define VERIFY_IOCAPP(nr) (_IOCTL_MODE(nr) == TMF882X_IOCTL_APP_MODE)
/**
* @brief These are the command code numberings in the ioctl bit fields.
* Do not use these directly, use the IOCTL bitmasks IOCAPP_*.
*/
enum _tmf882x_mode_app_iocnr{
APP_SET_CFG,
APP_GET_CFG,
APP_SET_SPADCFG,
APP_GET_SPADCFG,
APP_SET_CALIB,
APP_GET_CALIB,
APP_DO_FACCAL,
APP_IS_MEAS,
APP_DEV_UID,
APP_IS_CLKADJ,
APP_SET_CLKADJ,
APP_SET_8X8MODE,
APP_IS_8X8MODE,
APP_SET_SHORTRANGE,
APP_IS_SHORTRANGE,
NUM_APP_IOCTL
};
/**
* @struct tmf882x_mode_app_config
* @brief
* This is the Application mode config structure that holds all
* configuration parameters for the application
* @var tmf882x_mode_app_config::report_period_ms
* Result reporting period in milliseconds
* @var tmf882x_mode_app_config::kilo_iterations
* Iterations * 1024 for measurements
* @var tmf882x_mode_app_config::low_threshold
* Low distance threshold setting triggering interrupts
* @var tmf882x_mode_app_config::high_threshold
* High distance threshold setting triggering interrupts
* @var tmf882x_mode_app_config::zone_mask
* Zone mask for disabling interrupts for certain channels
* @var tmf882x_mode_app_config::persistence
* Persistence setting for generating interrupts
* @var tmf882x_mode_app_config::confidence_threshold
* Confidence threshold for generating interrupts
* @var tmf882x_mode_app_config::gpio_0
* GPIO_0 config settings
* @var tmf882x_mode_app_config::gpio_1
* GPIO_1 config settings
* @var tmf882x_mode_app_config::power_cfg
* Power configuration settings
* @var tmf882x_mode_app_config::spad_map_id
* Spad map identifier
* @var tmf882x_mode_app_config::alg_setting
* Algorithm setting configuration
* @var tmf882x_mode_app_config::histogram_dump
* Histogram dump configuration
* @var tmf882x_mode_app_config::spread_spectrum
* Spread Spectrum configuration
* @var tmf882x_mode_app_config::i2c_slave_addr
* I2C slave address configuration
* @var tmf882x_mode_app_config::oscillator_trim
* Sensor Oscillator trim value
*/
struct tmf882x_mode_app_config {
uint16_t report_period_ms;
uint16_t kilo_iterations;
uint16_t low_threshold;
uint16_t high_threshold;
uint32_t zone_mask;
uint8_t persistence;
uint8_t confidence_threshold;
uint8_t gpio_0;
uint8_t gpio_1;
uint8_t power_cfg;
uint8_t spad_map_id;
uint32_t alg_setting;
uint8_t histogram_dump;
uint8_t spread_spectrum;
uint8_t i2c_slave_addr;
uint16_t oscillator_trim;
};
/**
* @brief
* IOCTL command code to Write a configuration to the application mode
* @param[in] input type: struct tmf882x_mode_app_config *
* @param[out] output type: none
* @return zero for success, fail otherwise
*/
#define IOCAPP_SET_CFG _IOCTL_W( TMF882X_IOCTL_APP_MODE, APP_SET_CFG, struct tmf882x_mode_app_config )
/**
* @brief
* IOCTL command code to Read a configuration from the application mode
* @param[in] input type: none
* @param[out] output type: struct tmf882x_mode_app_config *
* @return zero for success, fail otherwise
*/
#define IOCAPP_GET_CFG _IOCTL_R( TMF882X_IOCTL_APP_MODE, APP_GET_CFG, struct tmf882x_mode_app_config )
/**
* @struct tmf882x_mode_app_spad_config
* @brief
* This is the Application mode spad config structure that holds the
* complete spad configuration for the application
* @var tmf882x_mode_app_spad_config::tmf882x_mode_app_single_spad_config::xoff_q1
* X-direction offset in Q1 format
* @var tmf882x_mode_app_spad_config::tmf882x_mode_app_single_spad_config::yoff_q1
* Y-direction offset in Q1 format
* @var tmf882x_mode_app_spad_config::tmf882x_mode_app_single_spad_config::xsize
* Size of spad map in X-direction
* @var tmf882x_mode_app_spad_config::tmf882x_mode_app_single_spad_config::ysize
* Size of spad map in Y-direction
* @var tmf882x_mode_app_spad_config::tmf882x_mode_app_single_spad_config::spad_mask
* Spad enable mask configuration (1 enable, 0 disable)
* @var tmf882x_mode_app_spad_config::tmf882x_mode_app_single_spad_config::spad_map
* Spad channel mapping for measurement (channels 1 - 9)
* @var tmf882x_mode_app_spad_config::spad_configs
* The list of spad configurations
* @var tmf882x_mode_app_spad_config::num_spad_configs
* The number of spad configurations in @ref tmf882x_mode_app_spad_configs::spad_configs
* @note The spad enable mask and map size should be 'ysize' * 'xsize' in
* length
*/
struct tmf882x_mode_app_spad_config {
struct tmf882x_mode_app_single_spad_config {
int8_t xoff_q1;
int8_t yoff_q1;
uint8_t xsize;
uint8_t ysize;
uint8_t spad_mask[TMF8X2X_COM_MAX_SPAD_SIZE];
uint8_t spad_map[TMF8X2X_COM_MAX_SPAD_SIZE];
} spad_configs[TMF8X2X_MAX_CONFIGURATIONS];
uint32_t num_spad_configs;
};
/**
* @brief
* IOCTL command code to Write a spad configuration to the application mode
* @param[in] input type: struct tmf882x_mode_app_spad_config *
* @param[out] output type: none
* @return zero for success, fail otherwise
*/
#define IOCAPP_SET_SPADCFG _IOCTL_W( TMF882X_IOCTL_APP_MODE, \
APP_SET_SPADCFG, \
struct tmf882x_mode_app_spad_config )
/**
* @brief
* IOCTL command code to Read the spad configuration from the application mode
* @param[in] input type: none
* @param[out] output type: struct tmf882x_mode_app_spad_config *
* @return zero for success, fail otherwise
*/
#define IOCAPP_GET_SPADCFG _IOCTL_R( TMF882X_IOCTL_APP_MODE, \
APP_GET_SPADCFG, \
struct tmf882x_mode_app_spad_config )
#define TMF882X_MAX_CALIB_SIZE (188 * 4) // 4x to handle 8x8
/**
* @struct tmf882x_mode_app_calib
* @brief
* This is the Application mode calibration structure.
* @var tmf882x_mode_app_calib::data
* Calibration data buffer
* @var tmf882x_mode_app_calib::calib_len
* Length of calibration data in calibration data buffer
*/
struct tmf882x_mode_app_calib {
uint8_t data[TMF882X_MAX_CALIB_SIZE];
uint32_t calib_len;
};
/**
* @brief
* IOCTL command code to Write the calibration data to the application mode
* @param[in] input type: struct tmf882x_mode_app_calib *
* @param[out] output type: none
* @return zero for success, fail otherwise
*/
#define IOCAPP_SET_CALIB _IOCTL_W( TMF882X_IOCTL_APP_MODE, \
APP_SET_CALIB, \
struct tmf882x_mode_app_calib )
/**
* @brief
* IOCTL command code to Read the current calibration data from the application mode
* @param[in] input type: none
* @param[out] output type: struct tmf882x_mode_app_calib *
* @return zero for success, fail otherwise
*/
#define IOCAPP_GET_CALIB _IOCTL_R( TMF882X_IOCTL_APP_MODE, \
APP_GET_CALIB, \
struct tmf882x_mode_app_calib )
/**
* @brief
* IOCTL command code to Perform Factory Calibration and get the new calibration data
* @param[in] input type: none
* @param[out] output type: struct tmf882x_mode_app_calib *
* @return zero for success, fail otherwise
*/
#define IOCAPP_DO_FACCAL _IOCTL_R( TMF882X_IOCTL_APP_MODE, \
APP_DO_FACCAL, \
struct tmf882x_mode_app_calib )
/**
* @brief
* IOCTL command code to Return whether the application mode is currently measuring
* @param[in] input type: none
* @param[out] output type: bool *
* @return zero for success, fail otherwise
*/
#define IOCAPP_IS_MEAS _IOCTL_R( TMF882X_IOCTL_APP_MODE, \
APP_IS_MEAS, \
bool )
/**
* @struct tmf882x_mode_app_dev_UID
* @brief
* This is the Application mode structure to hold the device Unique ID
* @var tmf882x_mode_app_dev_UID::uid
* Unique Identifier (UID) string
*/
struct tmf882x_mode_app_dev_UID {
char uid[32];
};
/**
* @brief
* IOCTL command code to Retrieve the device Unique Identifier (UID)
* @param[in] input type: none
* @param[out] output type: struct tmf882x_mode_app_dev_UID *
* @return zero for success, fail otherwise
*/
#define IOCAPP_DEV_UID _IOCTL_R( TMF882X_IOCTL_APP_MODE, \
APP_DEV_UID, \
struct tmf882x_mode_app_dev_UID )
/**
* @brief
* IOCTL command code to Read the clock compensation enable state
* @param[in] input type: none
* @param[out] output type: bool *
* @return zero for success, fail otherwise
*/
#define IOCAPP_IS_CLKADJ _IOCTL_R( TMF882X_IOCTL_APP_MODE, \
APP_IS_CLKADJ, \
bool )
/**
* @brief
* IOCTL command code to Set the clock compensation enable state
* @param[in] input type: bool *
* @param[out] output type: none
* @return zero for success, fail otherwise
*/
#define IOCAPP_SET_CLKADJ _IOCTL_W( TMF882X_IOCTL_APP_MODE, \
APP_SET_CLKADJ, \
bool )
/**
* @brief
* IOCTL command code to Set the 8x8 operating mode (TMF8828)
* @param[in] input type: bool *
* @param[out] output type: none
* @return zero for success, fail otherwise
* @warn Note that changing to/from 8x8 mode will reset the device
* configuration to its default.
*/
#define IOCAPP_SET_8X8MODE _IOCTL_W( TMF882X_IOCTL_APP_MODE, \
APP_SET_8X8MODE, \
bool )
/**
* @brief
* IOCTL command code to Read the 8x8 operating mode state (TMF8828)
* @param[in] input type: none
* @param[out] output type: bool *
* @return zero for success, fail otherwise
*/
#define IOCAPP_IS_8X8MODE _IOCTL_R( TMF882X_IOCTL_APP_MODE, \
APP_IS_8X8MODE, \
bool )
/**
* @brief
* IOCTL command code to Set the short-range mode
* @param[in] input type: bool *
* @param[out] output type: none
* @return zero for success, fail otherwise
* @warn Note that changing to/from short-range mode will clear the device
* calibration
*/
#define IOCAPP_SET_SHORTRANGE _IOCTL_W( TMF882X_IOCTL_APP_MODE, \
APP_SET_SHORTRANGE, \
bool )
/**
* @brief
* IOCTL command code to Read the short-range operating mode state
* @param[in] input type: none
* @param[out] output type: bool *
* @return zero for success, fail otherwise
*/
#define IOCAPP_IS_SHORTRANGE _IOCTL_R( TMF882X_IOCTL_APP_MODE, \
APP_IS_SHORTRANGE, \
bool )
#ifdef __cplusplus
}
#endif
#endif