|
1 |
/*
|
|
2 |
AMiRo-LLD is a compilation of low-level hardware drivers for the Autonomous Mini Robot (AMiRo) platform.
|
|
3 |
Copyright (C) 2016..2020 Thomas Schöpping et al.
|
|
4 |
|
|
5 |
This program is free software: you can redistribute it and/or modify
|
|
6 |
it under the terms of the GNU Lesser General Public License as published by
|
|
7 |
the Free Software Foundation, either version 3 of the License, or
|
|
8 |
(at your option) any later version.
|
|
9 |
|
|
10 |
This program is distributed in the hope that it will be useful,
|
|
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
GNU Lesser General Public License for more details.
|
|
14 |
|
|
15 |
You should have received a copy of the GNU Lesser General Public License
|
|
16 |
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17 |
*/
|
|
18 |
|
|
19 |
/**
|
|
20 |
* @file alld_VL53L1X.c
|
|
21 |
* @brief ToF sensor function implementations.
|
|
22 |
*
|
|
23 |
* @addtogroup lld_vl53l1x
|
|
24 |
* @{
|
|
25 |
*/
|
|
26 |
|
1 |
27 |
#include <alld_VL53L1X.h>
|
2 |
|
//#include "vl53l1_platform.h"
|
3 |
28 |
#include <vl53l1_api.h>
|
4 |
|
// #include "vl53l1_platform_log.h"
|
|
29 |
#include <string.h>
|
5 |
30 |
|
|
31 |
/******************************************************************************/
|
|
32 |
/* LOCAL DEFINITIONS */
|
|
33 |
/******************************************************************************/
|
6 |
34 |
|
7 |
|
// #include "stm32xxx_hal.h"
|
8 |
|
#include <string.h>
|
|
35 |
/**
|
|
36 |
* @brief I2C communication timeout (in microseconds).
|
|
37 |
* @details Cutsom values can be set via alldconf.h file.
|
|
38 |
*/
|
|
39 |
#if !defined(VL53L1X_LLD_I2C_TIMEOUT) || defined(__DOXYGEN__)
|
|
40 |
# define VL53L1X_LLD_I2C_TIMEOUT ((apalTime_t)1000)
|
|
41 |
#endif
|
|
42 |
|
|
43 |
/******************************************************************************/
|
|
44 |
/* EXPORTED VARIABLES */
|
|
45 |
/******************************************************************************/
|
|
46 |
|
|
47 |
/******************************************************************************/
|
|
48 |
/* LOCAL TYPES */
|
|
49 |
/******************************************************************************/
|
|
50 |
|
|
51 |
/******************************************************************************/
|
|
52 |
/* LOCAL VARIABLES */
|
|
53 |
/******************************************************************************/
|
|
54 |
|
|
55 |
/******************************************************************************/
|
|
56 |
/* LOCAL FUNCTIONS */
|
|
57 |
/******************************************************************************/
|
|
58 |
|
|
59 |
/******************************************************************************/
|
|
60 |
/* EXPORTED FUNCTIONS */
|
|
61 |
/******************************************************************************/
|
|
62 |
|
|
63 |
/* interface functions for ST API *********************************************/
|
9 |
64 |
|
10 |
|
apalExitStatus_t hello_world(void){
|
11 |
|
return APAL_STATUS_OK;
|
|
65 |
/**
|
|
66 |
* @brief Initialization of communication interface (I2C).
|
|
67 |
* @details Function not supported.
|
|
68 |
* Initialization must be done by OS or application instead.
|
|
69 |
*
|
|
70 |
* @param[in] pdev VL53L1X device handle.
|
|
71 |
* @param[in] comms_type I2C speed class (?).
|
|
72 |
* @param[in] comms_speed_khz I2C transmission frequency.
|
|
73 |
*
|
|
74 |
* @return Always returns VL53L1_ERROR_NOT_SUPPORTED.
|
|
75 |
*/
|
|
76 |
VL53L1_Error VL53L1_CommsInitialise(VL53L1_Dev_t *pdev, uint8_t comms_type, uint16_t comms_speed_khz)
|
|
77 |
{
|
|
78 |
apalDbgAssert(pdev != NULL);
|
|
79 |
|
|
80 |
(void)pdev;
|
|
81 |
(void)comms_type;
|
|
82 |
(void)comms_speed_khz;
|
|
83 |
|
|
84 |
return VL53L1_ERROR_NOT_SUPPORTED;
|
12 |
85 |
}
|
13 |
86 |
|
14 |
87 |
/**
|
15 |
|
* @brief Set the GPIO1 to a specific state.
|
16 |
|
* @param[in] ledp The LED driver object.
|
17 |
|
* @param[in] led_state The state to set the LED to.
|
18 |
|
* @return An indicator whether the call was successful.
|
|
88 |
* @brief Deinitialization of communication interface (I2C).
|
|
89 |
* @details Function not supported.
|
|
90 |
* Deinitialization must be done by OS or application instead.
|
|
91 |
*
|
|
92 |
* @param[in] pdev VL53L1X device handle.
|
|
93 |
*
|
|
94 |
* @return Always returns VL53L1_ERROR_NOT_SUPPORTED.
|
19 |
95 |
*/
|
20 |
|
apalExitStatus_t vl53l1x_GPIO1_set(const VL53L1XDriver* const vlx, const gpio_lld_state_t state)
|
|
96 |
VL53L1_Error VL53L1_CommsClose(VL53L1_Dev_t *pdev)
|
21 |
97 |
{
|
22 |
|
apalDbgAssert(vlx != NULL);
|
23 |
|
|
24 |
|
return apalControlGpioSet(vlx->xshut, (state == GPIO_LLD_STATE_ON) ? APAL_GPIO_ON : APAL_GPIO_OFF);
|
|
98 |
apalDbgAssert(pdev != NULL);
|
|
99 |
|
|
100 |
(void)pdev;
|
|
101 |
|
|
102 |
return VL53L1_ERROR_NOT_SUPPORTED;
|
25 |
103 |
}
|
26 |
104 |
|
|
105 |
/**
|
|
106 |
* @brief Transmit multiple bytes of data via I2C.
|
|
107 |
*
|
|
108 |
* @param[in] pdev Device handle.
|
|
109 |
* @param[in] index Register address to write to.
|
|
110 |
* @param[in] pdata Data buffer to be transmitted.
|
|
111 |
* @param[in] count Number of bytes to transmit.
|
|
112 |
*
|
|
113 |
* @return Status indicating whether the call was successful.
|
|
114 |
* @retval VL53L1_ERROR_NONE Transmission was successful.
|
|
115 |
* @retval VL53L1_ERROR_TIME_OUT Transmission timed out.
|
|
116 |
* @retval VL53L1_ERROR_UNDEFINED Transmission failed for some other reason.
|
|
117 |
*/
|
|
118 |
VL53L1_Error VL53L1_WriteMulti(VL53L1_Dev_t *pdev, uint16_t index, uint8_t *pdata, uint32_t count)
|
|
119 |
{
|
|
120 |
apalDbgAssert(pdev != NULL);
|
27 |
121 |
|
|
122 |
// prepare transmit buffer with prepended address bytes.
|
|
123 |
uint8_t txbuf[sizeof(uint16_t) + count];
|
|
124 |
txbuf[0] = index >> 8;
|
|
125 |
txbuf[1] = index & 0xFF;
|
|
126 |
memcpy(&txbuf[2], pdata, count);
|
28 |
127 |
|
|
128 |
// transmit address and data
|
|
129 |
apalExitStatus_t status = apalI2CMasterTransmit(pdev->Interface.i2cd, pdev->Interface.addr, txbuf, sizeof(txbuf), NULL, 0, VL53L1X_LLD_I2C_TIMEOUT);
|
29 |
130 |
|
|
131 |
return (status == APAL_STATUS_OK || status > 0) ? VL53L1_ERROR_NONE :
|
|
132 |
(status == APAL_STATUS_TIMEOUT) ? VL53L1_ERROR_TIME_OUT : VL53L1_ERROR_UNDEFINED;
|
|
133 |
}
|
30 |
134 |
|
|
135 |
/**
|
|
136 |
* @brief Read multiple bytes of data via I2C.
|
|
137 |
*
|
|
138 |
* @param[in] pdev Device handle.
|
|
139 |
* @param[in] index Register address to read from.
|
|
140 |
* @param[out] pdata Data buffer to store read data to.
|
|
141 |
* @param[in] count Number of bytes to read.
|
|
142 |
*
|
|
143 |
* @return Status indicating whether the call was successful.
|
|
144 |
* @retval VL53L1_ERROR_NONE Transmission was successful.
|
|
145 |
* @retval VL53L1_ERROR_TIME_OUT Transmission timed out.
|
|
146 |
* @retval VL53L1_ERROR_UNDEFINED Transmission failed for some other reason.
|
|
147 |
*/
|
|
148 |
VL53L1_Error VL53L1_ReadMulti(VL53L1_Dev_t *pdev, uint16_t index, uint8_t *pdata, uint32_t count)
|
|
149 |
{
|
|
150 |
apalDbgAssert(pdev != NULL);
|
31 |
151 |
|
|
152 |
// prepare address buffer
|
|
153 |
uint8_t txbuf[sizeof(uint16_t)] = {index >> 8, index & 0xFF};
|
32 |
154 |
|
33 |
|
// #define I2C_TIME_OUT_BASE 10
|
34 |
|
// #define I2C_TIME_OUT_BYTE 1
|
|
155 |
// transmit address and recieve data
|
|
156 |
apalExitStatus_t status = apalI2CMasterTransmit(pdev->Interface.i2cd, pdev->Interface.addr, txbuf, sizeof(txbuf), pdata, count, VL53L1X_LLD_I2C_TIMEOUT);
|
35 |
157 |
|
36 |
|
// #ifdef VL53L1_LOG_ENABLE
|
37 |
|
// #define trace_print(level, ...) VL53L1_trace_print_module_function(VL53L1_TRACE_MODULE_PLATFORM, level, VL53L1_TRACE_FUNCTION_NONE, ##__VA_ARGS__)
|
38 |
|
// #define trace_i2c(...) VL53L1_trace_print_module_function(VL53L1_TRACE_MODULE_NONE, VL53L1_TRACE_LEVEL_NONE, VL53L1_TRACE_FUNCTION_I2C, ##__VA_ARGS__)
|
39 |
|
// #endif
|
|
158 |
return (status == APAL_STATUS_OK || status > 0) ? VL53L1_ERROR_NONE :
|
|
159 |
(status == APAL_STATUS_TIMEOUT) ? VL53L1_ERROR_TIME_OUT : VL53L1_ERROR_UNDEFINED;
|
|
160 |
}
|
40 |
161 |
|
41 |
|
// #ifndef HAL_I2C_MODULE_ENABLED
|
42 |
|
// #warning "HAL I2C module must be enable "
|
43 |
|
// #endif
|
|
162 |
/**
|
|
163 |
* @brief Transmit a single byte via I2C.
|
|
164 |
*
|
|
165 |
* @param[in] pdev Device handle.
|
|
166 |
* @param[in] index Register address to write to.
|
|
167 |
* @param[in] VL53L1_PRM_00005 Byte to transmit.
|
|
168 |
*
|
|
169 |
* @return Status indicating whether the call was successful.
|
|
170 |
* @retval VL53L1_ERROR_NONE Transmission was successful.
|
|
171 |
* @retval VL53L1_ERROR_TIME_OUT Transmission timed out.
|
|
172 |
* @retval VL53L1_ERROR_UNDEFINED Transmission failed for some other reason.
|
|
173 |
*/
|
|
174 |
VL53L1_Error VL53L1_WrByte(VL53L1_Dev_t *pdev, uint16_t index, uint8_t VL53L1_PRM_00005)
|
|
175 |
{
|
|
176 |
apalDbgAssert(pdev != NULL);
|
|
177 |
|
|
178 |
// prepare transmit buffer with prepended address bytes.
|
|
179 |
uint8_t txbuf[sizeof(uint16_t) + sizeof(uint8_t)] = {index >> 8, index & 0xFF,
|
|
180 |
VL53L1_PRM_00005};
|
44 |
181 |
|
45 |
|
//extern I2C_HandleTypeDef hi2c1;
|
46 |
|
//#define VL53L0X_pI2cHandle (&hi2c1)
|
|
182 |
// transmit address and data
|
|
183 |
apalExitStatus_t status = apalI2CMasterTransmit(pdev->Interface.i2cd, pdev->Interface.addr, txbuf, sizeof(txbuf), NULL, 0, VL53L1X_LLD_I2C_TIMEOUT);
|
47 |
184 |
|
48 |
|
/* when not customized by application define dummy one */
|
49 |
|
// #ifndef VL53L1_GetI2cBus
|
50 |
|
/** This macro can be overloaded by user to enforce i2c sharing in RTOS context
|
|
185 |
return (status == APAL_STATUS_OK || status > 0) ? VL53L1_ERROR_NONE :
|
|
186 |
(status == APAL_STATUS_TIMEOUT) ? VL53L1_ERROR_TIME_OUT : VL53L1_ERROR_UNDEFINED;
|
|
187 |
}
|
|
188 |
|
|
189 |
/**
|
|
190 |
* @brief Transmit a 16-bit data word via I2C.
|
|
191 |
*
|
|
192 |
* @param[in] pdev Device handle.
|
|
193 |
* @param[in] index Register address to write to.
|
|
194 |
* @param[in] VL53L1_PRM_00005 16-bit data word to transmit.
|
|
195 |
*
|
|
196 |
* @return Status indicating whether the call was successful.
|
|
197 |
* @retval VL53L1_ERROR_NONE Transmission was successful.
|
|
198 |
* @retval VL53L1_ERROR_TIME_OUT Transmission timed out.
|
|
199 |
* @retval VL53L1_ERROR_UNDEFINED Transmission failed for some other reason.
|
51 |
200 |
*/
|
52 |
|
// # define VL53L1_GetI2cBus(...) (void)0
|
53 |
|
// #endif
|
|
201 |
VL53L1_Error VL53L1_WrWord(VL53L1_Dev_t *pdev, uint16_t index, uint16_t VL53L1_PRM_00005)
|
|
202 |
{
|
|
203 |
apalDbgAssert(pdev != NULL);
|
|
204 |
|
|
205 |
// prepare transmit buffer with prepended address bytes.
|
|
206 |
uint8_t txbuf[sizeof(uint16_t) + sizeof(uint16_t)] = {index >> 8, index & 0xFF,
|
|
207 |
(VL53L1_PRM_00005 >> 8) & 0xFF,
|
|
208 |
(VL53L1_PRM_00005 >> 0) & 0xFF};
|
54 |
209 |
|
55 |
|
// #ifndef VL53L1_PutI2cBus
|
56 |
|
/** This macro can be overloaded by user to enforce i2c sharing in RTOS context
|
|
210 |
// transmit address and data
|
|
211 |
apalExitStatus_t status = apalI2CMasterTransmit(pdev->Interface.i2cd, pdev->Interface.addr, txbuf, sizeof(txbuf), NULL, 0, VL53L1X_LLD_I2C_TIMEOUT);
|
|
212 |
|
|
213 |
return (status == APAL_STATUS_OK || status > 0) ? VL53L1_ERROR_NONE :
|
|
214 |
(status == APAL_STATUS_TIMEOUT) ? VL53L1_ERROR_TIME_OUT : VL53L1_ERROR_UNDEFINED;
|
|
215 |
}
|
|
216 |
|
|
217 |
/**
|
|
218 |
* @brief Transmit a 32-bit data word via I2C.
|
|
219 |
*
|
|
220 |
* @param[in] pdev Device handle.
|
|
221 |
* @param[in] index Register address to write to.
|
|
222 |
* @param[in] VL53L1_PRM_00005 32-bit data word to transmit.
|
|
223 |
*
|
|
224 |
* @return Status indicating whether the call was successful.
|
|
225 |
* @retval VL53L1_ERROR_NONE Transmission was successful.
|
|
226 |
* @retval VL53L1_ERROR_TIME_OUT Transmission timed out.
|
|
227 |
* @retval VL53L1_ERROR_UNDEFINED Transmission failed for some other reason.
|
57 |
228 |
*/
|
58 |
|
// # define VL53L1_PutI2cBus(...) (void)0
|
59 |
|
// #endif
|
|
229 |
VL53L1_Error VL53L1_WrDWord(VL53L1_Dev_t *pdev,uint16_t index, uint32_t VL53L1_PRM_00005)
|
|
230 |
{
|
|
231 |
apalDbgAssert(pdev != NULL);
|
|
232 |
|
|
233 |
// prepare transmit buffer with prepended address bytes.
|
|
234 |
uint8_t txbuf[sizeof(uint16_t) + sizeof(uint32_t)] = {index >> 8, index & 0xFF,
|
|
235 |
(VL53L1_PRM_00005 >> 24) & 0xFF,
|
|
236 |
(VL53L1_PRM_00005 >> 16) & 0xFF,
|
|
237 |
(VL53L1_PRM_00005 >> 8) & 0xFF,
|
|
238 |
(VL53L1_PRM_00005 >> 0) & 0xFF};
|
60 |
239 |
|
61 |
|
#define I2C_TIME_OUT_BASE 10
|
62 |
|
#define I2C_TIME_OUT_BYTE 1
|
|
240 |
// transmit address and data
|
|
241 |
apalExitStatus_t status = apalI2CMasterTransmit(pdev->Interface.i2cd, pdev->Interface.addr, txbuf, sizeof(txbuf), NULL, 0, VL53L1X_LLD_I2C_TIMEOUT);
|
63 |
242 |
|
64 |
|
uint8_t _I2CBuffer[256] = { 0 };
|
65 |
|
uint8_t rx_buf[256];
|
66 |
|
uint8_t tx_buf[256];
|
|
243 |
return (status == APAL_STATUS_OK || status > 0) ? VL53L1_ERROR_NONE :
|
|
244 |
(status == APAL_STATUS_TIMEOUT) ? VL53L1_ERROR_TIME_OUT : VL53L1_ERROR_UNDEFINED;
|
|
245 |
}
|
67 |
246 |
|
68 |
|
int _I2CWrite(VL53L1_DEV Dev, uint8_t *pdata, uint32_t count) {
|
69 |
|
int status = 0;
|
70 |
|
int i2c_time_out = 1000 * (I2C_TIME_OUT_BASE + count * I2C_TIME_OUT_BYTE);
|
|
247 |
/**
|
|
248 |
* @brief Read a single byte via I2C.
|
|
249 |
*
|
|
250 |
* @param[in] pdev Device handle.
|
|
251 |
* @param[in] index Register address to read from.
|
|
252 |
* @param[out] pdata Single byte buffer to store the read data to.
|
|
253 |
*
|
|
254 |
* @return Status indicating whether the call was successful.
|
|
255 |
* @retval VL53L1_ERROR_NONE Transmission was successful.
|
|
256 |
* @retval VL53L1_ERROR_TIME_OUT Transmission timed out.
|
|
257 |
* @retval VL53L1_ERROR_UNDEFINED Transmission failed for some other reason.
|
|
258 |
*/
|
|
259 |
VL53L1_Error VL53L1_RdByte(VL53L1_Dev_t *pdev, uint16_t index, uint8_t *pdata)
|
|
260 |
{
|
|
261 |
apalDbgAssert(pdev != NULL);
|
71 |
262 |
|
72 |
|
apalExitStatus_t status2 = apalI2CMasterTransmit(Dev->vl53l1x.i2cd, Dev->vl53l1x.addr, pdata, count, rx_buf, 0, 100);
|
73 |
|
return status;
|
|
263 |
// prepare address buffer
|
|
264 |
uint8_t txbuf[sizeof(uint16_t)] = {index >> 8, index & 0xFF};
|
|
265 |
|
|
266 |
// transmit address and recieve data
|
|
267 |
apalExitStatus_t status = apalI2CMasterTransmit(pdev->Interface.i2cd, pdev->Interface.addr, txbuf, sizeof(txbuf), pdata, 1, VL53L1X_LLD_I2C_TIMEOUT);
|
|
268 |
|
|
269 |
return (status == APAL_STATUS_OK || status > 0) ? VL53L1_ERROR_NONE :
|
|
270 |
(status == APAL_STATUS_TIMEOUT) ? VL53L1_ERROR_TIME_OUT : VL53L1_ERROR_UNDEFINED;
|
74 |
271 |
}
|
75 |
272 |
|
76 |
|
int _I2CRead(VL53L1_DEV Dev, uint8_t *pdata, uint32_t count) {
|
77 |
|
int status = 0;
|
78 |
|
// apalI2CMasterReceive(Dev->vl53l1x->i2cd, Dev->vl53l1x->addr, uint8_t* const rxbuf, const size_t rxbytes, const apalTime_t timeout)
|
|
273 |
/**
|
|
274 |
* @brief Read a 16-bit data word via I2C.
|
|
275 |
*
|
|
276 |
* @param[in] pdev Device handle.
|
|
277 |
* @param[in] index Register address to read from.
|
|
278 |
* @param[out] pdata 16-bit buffer to store the read data to.
|
|
279 |
*
|
|
280 |
* @return Status indicating whether the call was successful.
|
|
281 |
* @retval VL53L1_ERROR_NONE Transmission was successful.
|
|
282 |
* @retval VL53L1_ERROR_TIME_OUT Transmission timed out.
|
|
283 |
* @retval VL53L1_ERROR_UNDEFINED Transmission failed for some other reason.
|
|
284 |
*/
|
|
285 |
VL53L1_Error VL53L1_RdWord(VL53L1_Dev_t *pdev,uint16_t index, uint16_t *pdata)
|
|
286 |
{
|
|
287 |
apalDbgAssert(pdev != NULL);
|
|
288 |
|
|
289 |
// prepare address buffer
|
|
290 |
uint8_t txbuf[sizeof(uint16_t)] = {index >> 8, index & 0xFF};
|
|
291 |
// prepare receive buffer
|
|
292 |
uint8_t rxbuf[sizeof(uint16_t)];
|
|
293 |
|
|
294 |
// transmit address and recieve data
|
|
295 |
apalExitStatus_t status = apalI2CMasterTransmit(pdev->Interface.i2cd, pdev->Interface.addr, txbuf, sizeof(txbuf), rxbuf, sizeof(rxbuf), VL53L1X_LLD_I2C_TIMEOUT);
|
|
296 |
|
|
297 |
// fill return value
|
|
298 |
*pdata = (((uint16_t)rxbuf[0]) << 8) &
|
|
299 |
(((uint16_t)rxbuf[1]) << 0);
|
79 |
300 |
|
80 |
|
return status;
|
|
301 |
return (status == APAL_STATUS_OK || status > 0) ? VL53L1_ERROR_NONE :
|
|
302 |
(status == APAL_STATUS_TIMEOUT) ? VL53L1_ERROR_TIME_OUT : VL53L1_ERROR_UNDEFINED;
|
81 |
303 |
}
|
82 |
304 |
|
83 |
|
// TODO: Needs to be defined
|
|
305 |
/**
|
|
306 |
* @brief Read a 32-bit data word via I2C.
|
|
307 |
*
|
|
308 |
* @param[in] pdev Device handle.
|
|
309 |
* @param[in] index Register address to read from.
|
|
310 |
* @param[out] pdata 32-bit buffer to store the read data to.
|
|
311 |
*
|
|
312 |
* @return Status indicating whether the call was successful.
|
|
313 |
* @retval VL53L1_ERROR_NONE Transmission was successful.
|
|
314 |
* @retval VL53L1_ERROR_TIME_OUT Transmission timed out.
|
|
315 |
* @retval VL53L1_ERROR_UNDEFINED Transmission failed for some other reason.
|
|
316 |
*/
|
|
317 |
VL53L1_Error VL53L1_RdDWord(VL53L1_Dev_t *pdev,uint16_t index, uint32_t *pdata)
|
|
318 |
{
|
|
319 |
apalDbgAssert(pdev != NULL);
|
|
320 |
|
|
321 |
// prepare address buffer
|
|
322 |
uint8_t txbuf[sizeof(uint16_t)] = {index >> 8, index & 0xFF};
|
|
323 |
// prepare receive buffer
|
|
324 |
uint8_t rxbuf[sizeof(uint32_t)];
|
84 |
325 |
|
85 |
|
VL53L1_Error VL53L1_WriteMulti(VL53L1_DEV Dev, uint16_t index, uint8_t *pdata, uint32_t count) {
|
86 |
|
VL53L1_Error Status = VL53L1_ERROR_NONE;
|
|
326 |
apalExitStatus_t status = apalI2CMasterTransmit(pdev->Interface.i2cd, pdev->Interface.addr, txbuf, sizeof(txbuf), rxbuf, sizeof(rxbuf), VL53L1X_LLD_I2C_TIMEOUT);
|
87 |
327 |
|
88 |
|
return Status;
|
|
328 |
// fill return value
|
|
329 |
*pdata = (((uint32_t)rxbuf[0]) << 24) &
|
|
330 |
(((uint32_t)rxbuf[1]) << 16) &
|
|
331 |
(((uint32_t)rxbuf[2]) << 8) &
|
|
332 |
(((uint32_t)rxbuf[3]) << 0);
|
|
333 |
|
|
334 |
return (status == APAL_STATUS_OK || status > 0) ? VL53L1_ERROR_NONE :
|
|
335 |
(status == APAL_STATUS_TIMEOUT) ? VL53L1_ERROR_TIME_OUT : VL53L1_ERROR_UNDEFINED;
|
89 |
336 |
}
|
90 |
337 |
|
91 |
|
// the ranging_sensor_comms.dll will take care of the page selection
|
92 |
|
VL53L1_Error VL53L1_ReadMulti(VL53L1_DEV Dev, uint16_t index, uint8_t *pdata, uint32_t count) {
|
93 |
|
VL53L1_Error Status = VL53L1_ERROR_NONE;
|
94 |
|
return Status;
|
|
338 |
/**
|
|
339 |
* @brief Wait for a specified amount of microseconds.
|
|
340 |
*
|
|
341 |
* @param[in] pdev Device handle.
|
|
342 |
* @param[in] wait_us Time to wait in microsecnonds.
|
|
343 |
*
|
|
344 |
* @return Always returns VL53L1_ERROR_NONE.
|
|
345 |
*/
|
|
346 |
VL53L1_Error VL53L1_WaitUs(VL53L1_Dev_t *pdev, int32_t wait_us)
|
|
347 |
{
|
|
348 |
(void)pdev;
|
|
349 |
|
|
350 |
apalSleep(wait_us);
|
|
351 |
|
|
352 |
return VL53L1_ERROR_NONE;
|
95 |
353 |
}
|
96 |
354 |
|
97 |
|
VL53L1_Error VL53L1_WrByte(VL53L1_DEV Dev, uint16_t index, uint8_t data) {
|
98 |
|
VL53L1_Error Status = VL53L1_ERROR_NONE;
|
99 |
|
// printf("Starting to write byte: %X\n", data);
|
100 |
|
int32_t status_int;
|
|
355 |
/**
|
|
356 |
* @brief Wait for a specified amount of milliseconds.
|
|
357 |
*
|
|
358 |
* @param[in] pdev Device handle.
|
|
359 |
* @param[in] wait_ms Time to wait in milliseconds.
|
|
360 |
*
|
|
361 |
* @return Always returns VL53L1_ERROR_NONE.
|
|
362 |
*/
|
|
363 |
VL53L1_Error VL53L1_WaitMs(VL53L1_Dev_t *pdev, int32_t wait_ms)
|
|
364 |
{
|
|
365 |
(void)pdev;
|
101 |
366 |
|
102 |
|
_I2CBuffer[0] = index>>8;
|
103 |
|
_I2CBuffer[1] = index&0xFF;
|
104 |
|
_I2CBuffer[2] = data;
|
|
367 |
apalSleep(wait_ms * 1000);
|
105 |
368 |
|
106 |
|
_I2CWrite(Dev, _I2CBuffer, 3);
|
|
369 |
return VL53L1_ERROR_NONE;
|
|
370 |
}
|
107 |
371 |
|
108 |
|
return Status;
|
|
372 |
/**
|
|
373 |
* @brief Retrieve the frequency of a timer?
|
|
374 |
* @details Function not supported since it is not used by the ST API.
|
|
375 |
* @note Intention of this function is unknown as it is neither documented nor used by the ST API.
|
|
376 |
*
|
|
377 |
* @param[out] ptimer_freq_hz Buffer to store the timer frequency to.
|
|
378 |
*
|
|
379 |
* @return Always returns VL53L1_ERROR_NOT_SUPPORTED.
|
|
380 |
*/
|
|
381 |
VL53L1_Error VL53L1_GetTimerFrequency(int32_t *ptimer_freq_hz)
|
|
382 |
{
|
|
383 |
apalDbgAssert(ptimer_freq_hz != NULL);
|
|
384 |
|
|
385 |
(void)ptimer_freq_hz;
|
|
386 |
|
|
387 |
return VL53L1_ERROR_NOT_SUPPORTED;
|
109 |
388 |
}
|
110 |
389 |
|
111 |
|
VL53L1_Error VL53L1_WrWord(VL53L1_DEV Dev, uint16_t index, uint16_t data) {
|
112 |
|
VL53L1_Error Status = VL53L1_ERROR_NONE;
|
113 |
|
return Status;
|
|
390 |
/**
|
|
391 |
* @brief Retrieve the current value of a timer?
|
|
392 |
* @details Function not supported since it is not used by the ST API.
|
|
393 |
* @note Intention of this function is unknown as it is neither documented nor used by the ST API.
|
|
394 |
*
|
|
395 |
* @param[out] ptimer_count Buffer to store the current timer value to.
|
|
396 |
*
|
|
397 |
* @return Always returns VL53L1_ERROR_NOT_SUPPORTED.
|
|
398 |
*/
|
|
399 |
VL53L1_Error VL53L1_GetTimerValue(int32_t *ptimer_count)
|
|
400 |
{
|
|
401 |
apalDbgAssert(ptimer_count != NULL);
|
|
402 |
|
|
403 |
(void)ptimer_count;
|
|
404 |
|
|
405 |
return VL53L1_ERROR_NOT_SUPPORTED;
|
114 |
406 |
}
|
115 |
407 |
|
116 |
|
VL53L1_Error VL53L1_WrDWord(VL53L1_DEV Dev, uint16_t index, uint32_t data) {
|
117 |
|
VL53L1_Error Status = VL53L1_ERROR_NONE;
|
118 |
|
return Status;
|
|
408 |
/**
|
|
409 |
* @brief Set the mode for a GPIO.
|
|
410 |
* @details Function not supported since it is not used by the ST API.
|
|
411 |
* @note Intention of this function is unknown as it is neither documented nor used by the ST API.
|
|
412 |
*
|
|
413 |
* @param[in] pin GPIO pin to modify.
|
|
414 |
* @param[in] mode Mode to set for the GPIO.
|
|
415 |
*
|
|
416 |
* @return Always returns VL53L1_ERROR_NOT_SUPPORTED.
|
|
417 |
*/
|
|
418 |
VL53L1_Error VL53L1_GpioSetMode(uint8_t pin, uint8_t mode)
|
|
419 |
{
|
|
420 |
(void)pin;
|
|
421 |
(void)mode;
|
|
422 |
|
|
423 |
return VL53L1_ERROR_NOT_SUPPORTED;
|
119 |
424 |
}
|
120 |
425 |
|
121 |
|
VL53L1_Error VL53L1_UpdateByte(VL53L1_DEV Dev, uint16_t index, uint8_t AndData, uint8_t OrData) {
|
122 |
|
VL53L1_Error Status = VL53L1_ERROR_NONE;
|
123 |
|
return Status;
|
|
426 |
/**
|
|
427 |
* @brief Set the output value for a GPIO.
|
|
428 |
* @details Function not supported since it is not used by the ST API.
|
|
429 |
* @note Intention of this function is unknown as it is neither documented nor used by the ST API.
|
|
430 |
*
|
|
431 |
* @param[in] pin GPIO pin to set.
|
|
432 |
* @param[in] value Value to set for the GPIO.
|
|
433 |
*
|
|
434 |
* @return Always returns VL53L1_ERROR_NOT_SUPPORTED.
|
|
435 |
*/
|
|
436 |
VL53L1_Error VL53L1_GpioSetValue(uint8_t pin, uint8_t value)
|
|
437 |
{
|
|
438 |
(void)pin;
|
|
439 |
(void)value;
|
|
440 |
|
|
441 |
return VL53L1_ERROR_NOT_SUPPORTED;
|
124 |
442 |
}
|
125 |
443 |
|
126 |
|
VL53L1_Error VL53L1_RdByte(VL53L1_DEV Dev, uint16_t index, uint8_t *data) {
|
127 |
|
VL53L1_Error Status = VL53L1_ERROR_NONE;
|
128 |
|
|
129 |
|
uint8_t indx[2] = { index >> 8, index & 0xFF };
|
130 |
|
apalExitStatus_t status2 = apalI2CMasterTransmit(Dev->vl53l1x.i2cd, Dev->vl53l1x.addr, indx, 2, data, 1, 0);
|
|
444 |
/**
|
|
445 |
* @brief Read the input value of a GPIO.
|
|
446 |
* @details Function not supported since it is not used by the ST API.
|
|
447 |
* @note Intention of this function is unknown as it is neither documented nor used by the ST API.
|
|
448 |
*
|
|
449 |
* @param[in] pin GPIO pin to read.
|
|
450 |
* @param[out] pvalue Buffer to write the read value to.
|
|
451 |
*
|
|
452 |
* @return Always returns VL53L1_ERROR_NOT_SUPPORTED.
|
|
453 |
*/
|
|
454 |
VL53L1_Error VL53L1_GpioGetValue(uint8_t pin, uint8_t *pvalue)
|
|
455 |
{
|
|
456 |
(void)pin;
|
|
457 |
(void)pvalue;
|
131 |
458 |
|
132 |
|
return Status;
|
|
459 |
return VL53L1_ERROR_NOT_SUPPORTED;
|
133 |
460 |
}
|
134 |
461 |
|
135 |
|
VL53L1_Error VL53L1_RdWord(VL53L1_DEV Dev, uint16_t index, uint16_t *data) {
|
136 |
|
VL53L1_Error Status = VL53L1_ERROR_NONE;
|
137 |
|
return Status;
|
|
462 |
/**
|
|
463 |
* @brief Set to XSHUT GPIO.
|
|
464 |
* @details Function not supported since it is not used by the ST API.
|
|
465 |
* @note Intention of this function is unknown as it is neither documented nor used by the ST API.
|
|
466 |
*
|
|
467 |
* @param[in] value Value to set the XSHUT GPIO to.
|
|
468 |
*
|
|
469 |
* @return Always returns VL53L1_ERROR_NOT_SUPPORTED.
|
|
470 |
*/
|
|
471 |
VL53L1_Error VL53L1_GpioXshutdown(uint8_t value)
|
|
472 |
{
|
|
473 |
(void)value;
|
|
474 |
|
|
475 |
return VL53L1_ERROR_NOT_SUPPORTED;
|
138 |
476 |
}
|
139 |
477 |
|
140 |
|
VL53L1_Error VL53L1_RdDWord(VL53L1_DEV Dev, uint16_t index, uint32_t *data) {
|
141 |
|
VL53L1_Error Status = VL53L1_ERROR_NONE;
|
142 |
|
return Status;
|
|
478 |
/**
|
|
479 |
* @brief Select a GPIO communication interface?
|
|
480 |
* @details Function not supported since it is not used by the ST API.
|
|
481 |
* @note Intention of this function is unknown as it is neither documented nor used by the ST API.
|
|
482 |
*
|
|
483 |
* @param[in] value Identifier of the interface to select?
|
|
484 |
*
|
|
485 |
* @return Always returns VL53L1_ERROR_NOT_SUPPORTED.
|
|
486 |
*/
|
|
487 |
VL53L1_Error VL53L1_GpioCommsSelect(uint8_t value)
|
|
488 |
{
|
|
489 |
(void)value;
|
|
490 |
|
|
491 |
return VL53L1_ERROR_NOT_SUPPORTED;
|
143 |
492 |
}
|
144 |
493 |
|
145 |
|
VL53L1_Error VL53L1_GetTickCount(
|
146 |
|
uint32_t *ptick_count_ms)
|
|
494 |
/**
|
|
495 |
* @brief Enable power?
|
|
496 |
* @details Function not supported since it is not used by the ST API.
|
|
497 |
* @note Intention of this function is unknown as it is neither documented nor used by the ST API.
|
|
498 |
*
|
|
499 |
* @param[in] value ?
|
|
500 |
*
|
|
501 |
* @return Always returns VL53L1_ERROR_NOT_SUPPORTED.
|
|
502 |
*/
|
|
503 |
VL53L1_Error VL53L1_GpioPowerEnable(uint8_t value)
|
147 |
504 |
{
|
148 |
|
VL53L1_Error status = VL53L1_ERROR_NONE;
|
149 |
|
return status;
|
|
505 |
(void)value;
|
|
506 |
|
|
507 |
return VL53L1_ERROR_NOT_SUPPORTED;
|
150 |
508 |
}
|
151 |
509 |
|
152 |
|
//#define trace_print(level, ...) \
|
153 |
|
// _LOG_TRACE_PRINT(VL53L1_TRACE_MODULE_PLATFORM, \
|
154 |
|
// level, VL53L1_TRACE_FUNCTION_NONE, ##__VA_ARGS__)
|
|
510 |
/**
|
|
511 |
* @brief Enable GPIO interrupt.
|
|
512 |
* @details Function not supported since it is not used by the ST API.
|
|
513 |
* @note Intention of this function is unknown as it is neither documented nor used by the ST API.
|
|
514 |
*
|
|
515 |
* @param[in] fucntion Callback function to be executed on interrupt.
|
|
516 |
* @param[in] edge_type Signal edge to trigger an interrupts.
|
|
517 |
*
|
|
518 |
* @return Always returns VL53L1_ERROR_NOT_SUPPORTED.
|
|
519 |
*/
|
|
520 |
VL53L1_Error VL53L1_GpioInterruptEnable(void (*function)(void), uint8_t edge_type)
|
|
521 |
{
|
|
522 |
(void)function;
|
|
523 |
(void)edge_type;
|
155 |
524 |
|
156 |
|
//#define trace_i2c(...) \
|
157 |
|
// _LOG_TRACE_PRINT(VL53L1_TRACE_MODULE_NONE, \
|
158 |
|
// VL53L1_TRACE_LEVEL_NONE, VL53L1_TRACE_FUNCTION_I2C, ##__VA_ARGS__)
|
|
525 |
return VL53L1_ERROR_NOT_SUPPORTED;
|
|
526 |
}
|
159 |
527 |
|
160 |
|
VL53L1_Error VL53L1_GetTimerFrequency(int32_t *ptimer_freq_hz)
|
|
528 |
/**
|
|
529 |
* @brief Disable GPIO interrupt.
|
|
530 |
* @details Function not supported since it is not used by the ST API.
|
|
531 |
* @note Intention of this function is unknown as it is neither documented nor used by the ST API.
|
|
532 |
*
|
|
533 |
* @return Always returns VL53L1_ERROR_NOT_SUPPORTED.
|
|
534 |
*/
|
|
535 |
VL53L1_Error VL53L1_GpioInterruptDisable(void)
|
161 |
536 |
{
|
162 |
|
VL53L1_Error status = VL53L1_ERROR_NONE;
|
163 |
|
return status;
|
|
537 |
return VL53L1_ERROR_NOT_SUPPORTED;
|
164 |
538 |
}
|
165 |
539 |
|
166 |
|
VL53L1_Error VL53L1_WaitMs(VL53L1_Dev_t *pdev, int32_t wait_ms){
|
167 |
|
VL53L1_Error status = VL53L1_ERROR_NONE;
|
168 |
|
return status;
|
|
540 |
/**
|
|
541 |
* @brief Retrieve the current system tick count.
|
|
542 |
*
|
|
543 |
* @param[out] ptime_ms Buffer to store the current system tick count to.
|
|
544 |
*
|
|
545 |
* @return Always returns VL53L1_ERROR_NONE.
|
|
546 |
*/
|
|
547 |
VL53L1_Error VL53L1_GetTickCount(uint32_t *ptime_ms)
|
|
548 |
{
|
|
549 |
*ptime_ms = apalGetTime() / 1000;
|
|
550 |
|
|
551 |
return VL53L1_ERROR_NONE;
|
169 |
552 |
}
|
170 |
553 |
|
171 |
|
VL53L1_Error VL53L1_WaitUs(VL53L1_Dev_t *pdev, int32_t wait_us){
|
172 |
|
VL53L1_Error status = VL53L1_ERROR_NONE;
|
173 |
|
return status;
|
|
554 |
/**
|
|
555 |
* @brief Wait for a specific register to match a (masked) value.
|
|
556 |
*
|
|
557 |
* @param[in] pdev Device handle.
|
|
558 |
* @param[in] timeout_ms Timeout value in milliseconds.
|
|
559 |
* @param[in] index Register address to check.
|
|
560 |
* @param[in] value Value to be matched.
|
|
561 |
* @param[in] mask Mask to apply to the register value.
|
|
562 |
* Must not be 0x00.
|
|
563 |
* @param[in] poll_delay_ms Poll delay in milliseconds.
|
|
564 |
*
|
|
565 |
* @return Status indicating whether the call was successful.
|
|
566 |
* @retval VL53L1_ERROR_NONE Value matched before timeout.
|
|
567 |
* @retval VL53L1_ERROR_TIME_OUT Value did not match before timeout occurred.
|
|
568 |
* @retval VL53L1_ERROR_UNDEFINED I2C communication failed.
|
|
569 |
*/
|
|
570 |
VL53L1_Error VL53L1_WaitValueMaskEx(VL53L1_Dev_t *pdev, uint32_t timeout_ms, uint16_t index, uint8_t value, uint8_t mask, uint32_t poll_delay_ms)
|
|
571 |
{
|
|
572 |
apalDbgAssert(pdev != NULL);
|
|
573 |
apalDbgAssert(mask != 0x00);
|
|
574 |
|
|
575 |
// local variables
|
|
576 |
const apalTime_t starttime = apalGetTime();
|
|
577 |
apalTime_t transmissionstartoffset, transmissionendoffset;
|
|
578 |
apalTime_t remaintime = timeout_ms * 1000;
|
|
579 |
uint8_t txbuf[sizeof(uint16_t)] = {index >> 8, index & 0xFF};
|
|
580 |
uint8_t rxbuf[sizeof(uint8_t)];
|
|
581 |
|
|
582 |
// infinite loop will return from within
|
|
583 |
for(;;) {
|
|
584 |
// measure time before transmission
|
|
585 |
transmissionstartoffset = apalGetTime() - starttime;
|
|
586 |
|
|
587 |
// try transmission
|
|
588 |
if (apalI2CMasterTransmit(pdev->Interface.i2cd, pdev->Interface.addr, txbuf, sizeof(txbuf), rxbuf, sizeof(rxbuf), (remaintime < VL53L1X_LLD_I2C_TIMEOUT) ? remaintime : VL53L1X_LLD_I2C_TIMEOUT) < 0) {
|
|
589 |
return VL53L1_ERROR_UNDEFINED;
|
|
590 |
}
|
|
591 |
|
|
592 |
// check returned data
|
|
593 |
if ((rxbuf[0] & mask) == value) {
|
|
594 |
return VL53L1_ERROR_NONE;
|
|
595 |
}
|
|
596 |
|
|
597 |
// measure time after transmission
|
|
598 |
transmissionendoffset = apalGetTime() - starttime;
|
|
599 |
|
|
600 |
// check for timeout and recalculate remaining time
|
|
601 |
if (transmissionendoffset < timeout_ms * 1000) {
|
|
602 |
remaintime = (timeout_ms * 1000) - transmissionendoffset;
|
|
603 |
} else {
|
|
604 |
return VL53L1_ERROR_TIME_OUT;
|
|
605 |
}
|
|
606 |
|
|
607 |
// sleep one poll delay, or the remaining time
|
|
608 |
if (remaintime > (poll_delay_ms * 1000) - (transmissionendoffset - transmissionstartoffset)) {
|
|
609 |
apalSleep((poll_delay_ms * 1000) - (transmissionendoffset - transmissionstartoffset));
|
|
610 |
} else {
|
|
611 |
apalSleep(remaintime);
|
|
612 |
return VL53L1_ERROR_TIME_OUT;
|
|
613 |
}
|
|
614 |
|
|
615 |
// recalculate remaining time
|
|
616 |
remaintime = apalGetTime() - starttime;
|
|
617 |
if (remaintime < timeout_ms * 1000) {
|
|
618 |
remaintime = (timeout_ms * 1000) - remaintime;
|
|
619 |
} else {
|
|
620 |
return VL53L1_ERROR_TIME_OUT;
|
|
621 |
}
|
|
622 |
}
|
174 |
623 |
}
|
175 |
624 |
|
176 |
|
VL53L1_Error VL53L1_WaitValueMaskEx(
|
177 |
|
VL53L1_Dev_t *pdev,
|
178 |
|
uint32_t timeout_ms,
|
179 |
|
uint16_t index,
|
180 |
|
uint8_t value,
|
181 |
|
uint8_t mask,
|
182 |
|
uint32_t poll_delay_ms)
|
|
625 |
/* driver functions ***********************************************************/
|
|
626 |
|
|
627 |
/**
|
|
628 |
* @brief Read the current activation state of the device.
|
|
629 |
*
|
|
630 |
* @param[in] vl53l1x Driver object to check.
|
|
631 |
* @param[out] state State of the device.
|
|
632 |
*
|
|
633 |
* @return Indicator whether the call was successful.
|
|
634 |
*/
|
|
635 |
apalExitStatus_t vl53l1x_lld_getState(VL53L1XDriver* vl53l1x, vl53l1x_lld_state_t* state)
|
183 |
636 |
{
|
184 |
|
VL53L1_Error status = VL53L1_ERROR_NONE;
|
185 |
|
return status;
|
|
637 |
apalDbgAssert(vl53l1x != NULL);
|
|
638 |
apalDbgAssert(state != NULL);
|
|
639 |
|
|
640 |
apalControlGpioState_t gpio_state;
|
|
641 |
apalExitStatus_t status = apalControlGpioGet(vl53l1x->Interface.xshut, &gpio_state);
|
|
642 |
*state = gpio_state == APAL_GPIO_ON ? VL53L1X_LLD_STATE_ON : VL53L1X_LLD_STATE_OFF;
|
|
643 |
|
|
644 |
return status;
|
186 |
645 |
}
|
187 |
646 |
|
|
647 |
/**
|
|
648 |
* @brief Performs initialization procedure according to manual after device
|
|
649 |
* brought out of reset.
|
|
650 |
*
|
|
651 |
* @param[in,out] vl53l1x Device to be initialized.
|
|
652 |
*
|
|
653 |
* @return Indicator whether the call was successful.
|
|
654 |
*/
|
|
655 |
apalExitStatus_t vl53l1x_lld_init(VL53L1XDriver* vl53l1x)
|
|
656 |
{
|
|
657 |
apalDbgAssert(vl53l1x != NULL);
|
|
658 |
|
|
659 |
// local variables
|
|
660 |
apalExitStatus_t status;
|
|
661 |
VL53L1_Error errval;
|
|
662 |
|
|
663 |
// check whether the device is already active
|
|
664 |
{
|
|
665 |
vl53l1x_lld_state_t xshut_state;
|
|
666 |
status = vl53l1x_lld_getState(vl53l1x, &xshut_state);
|
|
667 |
if (status != APAL_STATUS_OK) {
|
|
668 |
return APAL_STATUS_ERROR;
|
|
669 |
}
|
|
670 |
// return warning if the device is already active
|
|
671 |
if (xshut_state == VL53L1X_LLD_STATE_ON) {
|
|
672 |
return APAL_STATUS_WARNING;
|
|
673 |
}
|
|
674 |
}
|
|
675 |
|
|
676 |
// activate the device
|
|
677 |
apalDbgPrintf("apalControlGpioSet()\n");
|
|
678 |
status |= apalControlGpioSet(vl53l1x->Interface.xshut, APAL_GPIO_ON);
|
|
679 |
apalDbgPrintf("\tstatus: %d\n", status);
|
|
680 |
|
|
681 |
// initialize device as described in manual
|
|
682 |
apalDbgPrintf("VL53L1_WaitDeviceBooted()\n");
|
|
683 |
errval = VL53L1_WaitDeviceBooted(vl53l1x);
|
|
684 |
status |= (errval == VL53L1_ERROR_NONE) ? APAL_STATUS_SUCCESS : APAL_STATUS_ERROR;
|
|
685 |
apalDbgPrintf("\tstatus: %d\terrval: %d\n", status, errval);
|
|
686 |
apalDbgPrintf("VL53L1_DataInit()\n");
|
|
687 |
errval = VL53L1_DataInit(vl53l1x);
|
|
688 |
status |= (errval == VL53L1_ERROR_NONE) ? APAL_STATUS_SUCCESS : APAL_STATUS_ERROR;
|
|
689 |
apalDbgPrintf("\tstatus: %d\terrval: %d\n", status, errval);
|
|
690 |
apalDbgPrintf("VL53L1_StaticInit()\n");
|
|
691 |
errval = VL53L1_StaticInit(vl53l1x);
|
|
692 |
status |= (errval == VL53L1_ERROR_NONE) ? APAL_STATUS_SUCCESS : APAL_STATUS_ERROR;
|
|
693 |
apalDbgPrintf("\tstatus: %d\terrval: %d\n", status, errval);
|
|
694 |
|
|
695 |
return status;
|
|
696 |
}
|
188 |
697 |
|
|
698 |
/**
|
|
699 |
* @brief Reset a device by deactivating the XSHUT signal.
|
|
700 |
*
|
|
701 |
* @param[in] vl53l1x Device to reset.
|
|
702 |
*
|
|
703 |
* @return Indicator whether the call was successful.
|
|
704 |
*/
|
|
705 |
apalExitStatus_t vl53l1x_lld_reset(VL53L1XDriver* vl53l1x)
|
|
706 |
{
|
|
707 |
return apalControlGpioSet(vl53l1x->Interface.xshut, APAL_GPIO_OFF);
|
|
708 |
}
|
189 |
709 |
|
|
710 |
/** @} */
|