-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
44 changed files
with
49,275 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,282 @@ | ||
/******************************************************************************* | ||
Copyright (C) 2016, STMicroelectronics International N.V. | ||
All rights reserved. | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
* Neither the name of STMicroelectronics nor the | ||
names of its contributors may be used to endorse or promote products | ||
derived from this software without specific prior written permission. | ||
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, FITNESS FOR A PARTICULAR PURPOSE, AND | ||
NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED. | ||
IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. 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. | ||
******************************************************************************/ | ||
|
||
|
||
#ifndef _VL53L1X_H_ | ||
#define _VL53L1X_H_ | ||
|
||
#include "vl53l1_ll_def.h" | ||
#include "vl53l1_platform_user_data.h" | ||
#include "vl53l1_api.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" | ||
{ | ||
#endif | ||
|
||
#define VL53L1X_DEFAULT_ADDRESS 0b0101001 | ||
|
||
#define USE_I2C_2V8 | ||
|
||
/** | ||
* @file vl53l1_platform.h | ||
* | ||
* @brief All end user OS/platform/application porting | ||
*/ | ||
|
||
bool vl53l1xInit(VL53L1_Dev_t *pdev, I2C_Dev *I2Cx); | ||
|
||
bool vl53l1xTestConnection(VL53L1_Dev_t* pdev); | ||
|
||
VL53L1_Error vl53l1xSetI2CAddress(VL53L1_Dev_t* pdev, uint8_t address); | ||
|
||
/** | ||
* @brief Writes the supplied byte buffer to the device | ||
* | ||
* @param[in] pdev : pointer to device structure (device handle) | ||
* @param[in] index : uint16_t register index value | ||
* @param[in] pdata : pointer to uint8_t (byte) buffer containing the data to be written | ||
* @param[in] count : number of bytes in the supplied byte buffer | ||
* | ||
* @return VL53L1_ERROR_NONE Success | ||
* @return "Other error code" See ::VL53L1_Error | ||
*/ | ||
|
||
VL53L1_Error VL53L1_WriteMulti( | ||
VL53L1_Dev_t *pdev, | ||
uint16_t index, | ||
uint8_t *pdata, | ||
uint32_t count); | ||
|
||
|
||
/** | ||
* @brief Reads the requested number of bytes from the device | ||
* | ||
* @param[in] pdev : pointer to device structure (device handle) | ||
* @param[in] index : uint16_t register index value | ||
* @param[out] pdata : pointer to the uint8_t (byte) buffer to store read data | ||
* @param[in] count : number of bytes to read | ||
* | ||
* @return VL53L1_ERROR_NONE Success | ||
* @return "Other error code" See ::VL53L1_Error | ||
*/ | ||
|
||
VL53L1_Error VL53L1_ReadMulti( | ||
VL53L1_Dev_t *pdev, | ||
uint16_t index, | ||
uint8_t *pdata, | ||
uint32_t count); | ||
|
||
|
||
/** | ||
* @brief Writes a single byte to the device | ||
* | ||
* @param[in] pdev : pointer to device structure (device handle) | ||
* @param[in] index : uint16_t register index value | ||
* @param[in] data : uint8_t data value to write | ||
* | ||
* @return VL53L1_ERROR_NONE Success | ||
* @return "Other error code" See ::VL53L1_Error | ||
*/ | ||
|
||
VL53L1_Error VL53L1_WrByte( | ||
VL53L1_Dev_t *pdev, | ||
uint16_t index, | ||
uint8_t data); | ||
|
||
|
||
/** | ||
* @brief Writes a single word (16-bit unsigned) to the device | ||
* | ||
* Manages the big-endian nature of the device register map | ||
* (first byte written is the MS byte). | ||
* | ||
* @param[in] pdev : pointer to device structure (device handle) | ||
* @param[in] index : uint16_t register index value | ||
* @param[in] data : uin16_t data value write | ||
* | ||
* @return VL53L1_ERROR_NONE Success | ||
* @return "Other error code" See ::VL53L1_Error | ||
*/ | ||
|
||
VL53L1_Error VL53L1_WrWord( | ||
VL53L1_Dev_t *pdev, | ||
uint16_t index, | ||
uint16_t data); | ||
|
||
|
||
/** | ||
* @brief Writes a single dword (32-bit unsigned) to the device | ||
* | ||
* Manages the big-endian nature of the device register map | ||
* (first byte written is the MS byte). | ||
* | ||
* @param[in] pdev : pointer to device structure (device handle) | ||
* @param[in] index : uint16_t register index value | ||
* @param[in] data : uint32_t data value to write | ||
* | ||
* @return VL53L1_ERROR_NONE Success | ||
* @return "Other error code" See ::VL53L1_Error | ||
*/ | ||
|
||
VL53L1_Error VL53L1_WrDWord( | ||
VL53L1_Dev_t *pdev, | ||
uint16_t index, | ||
uint32_t data); | ||
|
||
|
||
|
||
/** | ||
* @brief Reads a single byte from the device | ||
* | ||
* @param[in] pdev : pointer to device structure (device handle) | ||
* @param[in] index : uint16_t register index | ||
* @param[out] pdata : pointer to uint8_t data value | ||
* | ||
* @return VL53L1_ERROR_NONE Success | ||
* @return "Other error code" See ::VL53L1_Error | ||
* | ||
*/ | ||
|
||
VL53L1_Error VL53L1_RdByte( | ||
VL53L1_Dev_t *pdev, | ||
uint16_t index, | ||
uint8_t *pdata); | ||
|
||
|
||
/** | ||
* @brief Reads a single word (16-bit unsigned) from the device | ||
* | ||
* Manages the big-endian nature of the device (first byte read is the MS byte). | ||
* | ||
* @param[in] pdev : pointer to device structure (device handle) | ||
* @param[in] index : uint16_t register index value | ||
* @param[out] pdata : pointer to uint16_t data value | ||
* | ||
* @return VL53L1_ERROR_NONE Success | ||
* @return "Other error code" See ::VL53L1_Error | ||
*/ | ||
|
||
VL53L1_Error VL53L1_RdWord( | ||
VL53L1_Dev_t *pdev, | ||
uint16_t index, | ||
uint16_t *pdata); | ||
|
||
|
||
/** | ||
* @brief Reads a single dword (32-bit unsigned) from the device | ||
* | ||
* Manages the big-endian nature of the device (first byte read is the MS byte). | ||
* | ||
* @param[in] pdev : pointer to device structure (device handle) | ||
* @param[in] index : uint16_t register index value | ||
* @param[out] pdata : pointer to uint32_t data value | ||
* | ||
* @return VL53L1_ERROR_NONE Success | ||
* @return "Other error code" See ::VL53L1_Error | ||
*/ | ||
|
||
VL53L1_Error VL53L1_RdDWord( | ||
VL53L1_Dev_t *pdev, | ||
uint16_t index, | ||
uint32_t *pdata); | ||
|
||
|
||
|
||
/** | ||
* @brief Implements a programmable wait in us | ||
* | ||
* @param[in] pdev : pointer to device structure (device handle) | ||
* @param[in] wait_us : integer wait in micro seconds | ||
* | ||
* @return VL53L1_ERROR_NONE Success | ||
* @return "Other error code" See ::VL53L1_Error | ||
*/ | ||
|
||
VL53L1_Error VL53L1_WaitUs( | ||
VL53L1_Dev_t *pdev, | ||
int32_t wait_us); | ||
|
||
|
||
/** | ||
* @brief Implements a programmable wait in ms | ||
* | ||
* @param[in] pdev : pointer to device structure (device handle) | ||
* @param[in] wait_ms : integer wait in milliseconds | ||
* | ||
* @return VL53L1_ERROR_NONE Success | ||
* @return "Other error code" See ::VL53L1_Error | ||
*/ | ||
|
||
VL53L1_Error VL53L1_WaitMs( | ||
VL53L1_Dev_t *pdev, | ||
int32_t wait_ms); | ||
|
||
/* | ||
* @brief Gets current system tick count in [ms] | ||
* | ||
* @return time_ms : current time in [ms] | ||
* | ||
* @return VL53L1_ERROR_NONE Success | ||
* @return "Other error code" See ::VL53L1_Error | ||
*/ | ||
|
||
VL53L1_Error VL53L1_GetTickCount( | ||
uint32_t *ptime_ms); | ||
|
||
|
||
/** | ||
* @brief Register "wait for value" polling routine | ||
* | ||
* Port of the V2WReg Script function WaitValueMaskEx() | ||
* | ||
* @param[in] pdev : pointer to device structure (device handle) | ||
* @param[in] timeout_ms : timeout in [ms] | ||
* @param[in] index : uint16_t register index value | ||
* @param[in] value : value to wait for | ||
* @param[in] mask : mask to be applied before comparison with value | ||
* @param[in] poll_delay_ms : polling delay been each read transaction in [ms] | ||
* | ||
* @return VL53L1_ERROR_NONE Success | ||
* @return "Other error code" See ::VL53L1_Error | ||
*/ | ||
|
||
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); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif | ||
|
Oops, something went wrong.