vl53l1_platform.c
Go to the documentation of this file.
1 /* Based on: https://github.com/pimoroni/vl53l1x-python */
2 
3 #include "vl53l1_platform.h"
4 #include "vl53l1_api.h"
5 #include <string.h>
6 #include <time.h>
7 #include <unistd.h>
8 
9 #include "i2c.h"
10 
13 }
14 
15 // the ranging_sensor_comms.dll will take care of the page selection
18 }
19 
22 }
23 
26 }
27 
30  return Status;
31 }
32 
35  return Status;
36 }
37 
40 }
41 
44 }
45 
48  return Status;
49 }
50 
52  uint32_t *ptick_count_ms)
53 {
55  return status;
56 }
57 
58 //#define trace_print(level, ...) \
59 // _LOG_TRACE_PRINT(VL53L1_TRACE_MODULE_PLATFORM, \
60 // level, VL53L1_TRACE_FUNCTION_NONE, ##__VA_ARGS__)
61 
62 //#define trace_i2c(...) \
63 // _LOG_TRACE_PRINT(VL53L1_TRACE_MODULE_NONE, \
64 // VL53L1_TRACE_LEVEL_NONE, VL53L1_TRACE_FUNCTION_I2C, ##__VA_ARGS__)
65 
67 {
69  return status;
70 }
71 
73  usleep(wait_ms * 1000);
74  return VL53L1_ERROR_NONE;
75 }
76 
78  usleep(wait_us);
79  return VL53L1_ERROR_NONE;
80 }
81 
83  VL53L1_Dev_t *pdev,
84  uint32_t timeout_ms,
85  uint16_t index,
86  uint8_t value,
87  uint8_t mask,
88  uint32_t poll_delay_ms)
89 {
90  uint8_t register_value = 0;
91 
93 
94  int32_t attempts = timeout_ms / poll_delay_ms;
95 
96  for(int32_t x = 0; x < attempts; x++){
97  status = VL53L1_RdByte(
98  pdev,
99  index,
100  &register_value);
101  if (status == VL53L1_ERROR_NONE && (register_value & mask) == value) {
102  return VL53L1_ERROR_NONE;
103  }
104  usleep(poll_delay_ms * 1000);
105  }
106 
107  return VL53L1_ERROR_TIME_OUT;
108 }
VL53L1_Error VL53L1_RdWord(VL53L1_DEV Dev, uint16_t index, uint16_t *data)
VL53L1_Error VL53L1_WaitUs(VL53L1_Dev_t *pdev, int32_t wait_us)
int8_t 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)
VL53L1_Error VL53L1_WaitMs(VL53L1_Dev_t *pdev, int32_t wait_ms)
VL53L1_Error VL53L1_RdDWord(VL53L1_DEV Dev, uint16_t index, uint32_t *data)
#define VL53L1_ERROR_NONE
#define VL53L1_ERROR_CONTROL_INTERFACE
VL53L1_Error VL53L1_WrWord(VL53L1_DEV Dev, uint16_t index, uint16_t data)
VL53L1_Error VL53L1_GetTimerFrequency(int32_t *ptimer_freq_hz)
VL53L1_Error VL53L1_ReadMulti(VL53L1_DEV Dev, uint16_t index, uint8_t *pdata, uint32_t count)
int int32_t
Typedef defining 32 bit int type. The developer should modify this to suit the platform being deploye...
Definition: vl53l1_types.h:118
bool i2c_writeRegisterByte(uint16_t reg, uint8_t value)
Definition: i2c.cpp:74
bool i2c_readRegisterMulti(uint16_t reg, size_t count, void *pdata)
Definition: i2c.cpp:36
VL53L1_Error VL53L1_WriteMulti(VL53L1_DEV Dev, uint16_t index, uint8_t *pdata, uint32_t count)
bool i2c_readRegisterByte(int reg, uint8_t *pdata)
Definition: i2c.cpp:48
bool i2c_writeRegisterMulti(uint16_t reg, size_t count, void *pdata)
Definition: i2c.cpp:62
VL53L1_Error VL53L1_WrByte(VL53L1_DEV Dev, uint16_t index, uint8_t data)
VL53L1_Error VL53L1_WrDWord(VL53L1_DEV Dev, uint16_t index, uint32_t data)
bool i2c_writeRegisterWord(uint16_t reg, uint16_t value)
Definition: i2c.cpp:80
VL53L1_Error VL53L1_UpdateByte(VL53L1_DEV Dev, uint16_t index, uint8_t AndData, uint8_t OrData)
VL53L1_Error VL53L1_GetTickCount(uint32_t *ptick_count_ms)
bool i2c_readRegisterWord(uint16_t reg, uint16_t *pdata)
Definition: i2c.cpp:53
#define VL53L1_ERROR_TIME_OUT
VL53L1_Error VL53L1_RdByte(VL53L1_DEV Dev, uint16_t index, uint8_t *data)
unsigned short uint16_t
Typedef defining 16 bit unsigned short type. The developer should modify this to suit the platform be...
Definition: vl53l1_types.h:123
unsigned char uint8_t
Typedef defining 8 bit unsigned char type. The developer should modify this to suit the platform bein...
Definition: vl53l1_types.h:133
unsigned int uint32_t
Typedef defining 32 bit unsigned int type. The developer should modify this to suit the platform bein...
Definition: vl53l1_types.h:113


vl53l1x
Author(s):
autogenerated on Sat Dec 10 2022 03:15:50