1 /* vl53l1_platform_user_data.h - Zephyr customization of ST vl53l1x library. */
2 
3 /*
4  * Copyright (c) 2017 STMicroelectronics
5  *
6  * SPDX-License-Identifier: Apache-2.0
7  */
8 
9 #ifndef ZEPHYR_DRIVERS_SENSOR_VL53L1X_VL53L1_PLATFORM_USER_DATA_H_
10 #define ZEPHYR_DRIVERS_SENSOR_VL53L1X_VL53L1_PLATFORM_USER_DATA_H_
11 
12 #include "vl53l1_def.h"
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 /**
19  * @struct VL53L1_Dev_t
20  * @brief  Generic PAL device type that does link between API and platform
21  * abstraction layer
22  *
23  */
24 typedef struct {
25 	/*!< Low Level Driver data structure */
26 	VL53L1_DevData_t Data;
27 	/*!< New data ready poll duration in ms - for debug */
28 	uint32_t new_data_ready_poll_duration_ms;
29 	/*!< I2C device handle */
30 	const struct i2c_dt_spec *i2c;
31 } VL53L1_Dev_t;
32 
33 
34 /**
35  * @brief   Declare the device Handle as a pointer of the structure @a VL53L1_Dev_t.
36  *
37  */
38 typedef VL53L1_Dev_t *VL53L1_DEV;
39 
40 /**
41  * @def VL53L1PALDevDataGet
42  * @brief Get ST private structure @a VL53L1_DevData_t data access
43  *
44  * @param Dev       Device Handle
45  * @param field     ST structure field name
46  * It maybe used and as real data "ref" not just as "get" for sub-structure item
47  * like PALDevDataGet(FilterData.field)[i] or
48  * PALDevDataGet(FilterData.MeasurementIndex)++
49  */
50 #define VL53L1DevDataGet(Dev, field) (Dev->Data.field)
51 
52 
53 /**
54  * @def VL53L1PALDevDataSet(Dev, field, data)
55  * @brief  Set ST private structure @a VL53L1_DevData_t data field
56  * @param Dev       Device Handle
57  * @param field     ST structure field name
58  * @param data      Data to be set
59  */
60 #define VL53L1DevDataSet(Dev, field, data) ((Dev->Data.field) = (data))
61 
62 
63 /**
64  * @def VL53L1DevStructGetLLDriverHandle
65  * @brief Get LL Driver handle @a VL53L0_Dev_t data access
66  *
67  * @param Dev      Device Handle
68  */
69 #define VL53L1DevStructGetLLDriverHandle(Dev) (&Dev->Data.LLData)
70 
71 /**
72  * @def VL53L1DevStructGetLLResultsHandle
73  * @brief Get LL Results handle @a VL53L0_Dev_t data access
74  *
75  * @param Dev      Device Handle
76  */
77 #define VL53L1DevStructGetLLResultsHandle(Dev) (&Dev->Data.llresults)
78 
79 #ifdef __cplusplus
80 }
81 #endif
82 
83 #endif /*ZEPHYR_DRIVERS_SENSOR_VL53L1X_VL53L1_PLATFORM_USER_DATA_H_*/
84