amiro-lld / drivers / VL53L1X / v1 / alld_VL53L1X.c @ 4dba9195
History | View | Annotate | Download (5.113 KB)
| 1 |
#include <alld_VL53L1X.h> |
|---|---|
| 2 |
//#include "vl53l1_platform.h"
|
| 3 |
#include <vl53l1_api.h> |
| 4 |
// #include "vl53l1_platform_log.h"
|
| 5 |
|
| 6 |
|
| 7 |
// #include "stm32xxx_hal.h"
|
| 8 |
#include <string.h> |
| 9 |
|
| 10 |
apalExitStatus_t hello_world(void){
|
| 11 |
return APAL_STATUS_OK;
|
| 12 |
} |
| 13 |
|
| 14 |
/**
|
| 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.
|
| 19 |
*/
|
| 20 |
apalExitStatus_t vl53l1x_GPIO1_set(const VL53L1XDriver* const vlx, const gpio_lld_state_t state) |
| 21 |
{
|
| 22 |
apalDbgAssert(vlx != NULL);
|
| 23 |
|
| 24 |
return apalControlGpioSet(vlx->xshut, (state == GPIO_LLD_STATE_ON) ? APAL_GPIO_ON : APAL_GPIO_OFF);
|
| 25 |
} |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
// #define I2C_TIME_OUT_BASE 10
|
| 34 |
// #define I2C_TIME_OUT_BYTE 1
|
| 35 |
|
| 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
|
| 40 |
|
| 41 |
// #ifndef HAL_I2C_MODULE_ENABLED
|
| 42 |
// #warning "HAL I2C module must be enable "
|
| 43 |
// #endif
|
| 44 |
|
| 45 |
//extern I2C_HandleTypeDef hi2c1;
|
| 46 |
//#define VL53L0X_pI2cHandle (&hi2c1)
|
| 47 |
|
| 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
|
| 51 |
*/
|
| 52 |
// # define VL53L1_GetI2cBus(...) (void)0
|
| 53 |
// #endif
|
| 54 |
|
| 55 |
// #ifndef VL53L1_PutI2cBus
|
| 56 |
/** This macro can be overloaded by user to enforce i2c sharing in RTOS context
|
| 57 |
*/
|
| 58 |
// # define VL53L1_PutI2cBus(...) (void)0
|
| 59 |
// #endif
|
| 60 |
|
| 61 |
#define I2C_TIME_OUT_BASE 10 |
| 62 |
#define I2C_TIME_OUT_BYTE 1 |
| 63 |
|
| 64 |
uint8_t _I2CBuffer[256] = { 0 }; |
| 65 |
uint8_t rx_buf[256];
|
| 66 |
uint8_t tx_buf[256];
|
| 67 |
|
| 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); |
| 71 |
|
| 72 |
apalExitStatus_t status2 = apalI2CMasterTransmit(Dev->vl53l1x.i2cd, Dev->vl53l1x.addr, pdata, count, rx_buf, 0, 100); |
| 73 |
return status;
|
| 74 |
} |
| 75 |
|
| 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)
|
| 79 |
|
| 80 |
return status;
|
| 81 |
} |
| 82 |
|
| 83 |
// TODO: Needs to be defined
|
| 84 |
|
| 85 |
VL53L1_Error VL53L1_WriteMulti(VL53L1_DEV Dev, uint16_t index, uint8_t *pdata, uint32_t count) {
|
| 86 |
VL53L1_Error Status = VL53L1_ERROR_NONE; |
| 87 |
|
| 88 |
return Status;
|
| 89 |
} |
| 90 |
|
| 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;
|
| 95 |
} |
| 96 |
|
| 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; |
| 101 |
|
| 102 |
_I2CBuffer[0] = index>>8; |
| 103 |
_I2CBuffer[1] = index&0xFF; |
| 104 |
_I2CBuffer[2] = data;
|
| 105 |
|
| 106 |
_I2CWrite(Dev, _I2CBuffer, 3);
|
| 107 |
|
| 108 |
return Status;
|
| 109 |
} |
| 110 |
|
| 111 |
VL53L1_Error VL53L1_WrWord(VL53L1_DEV Dev, uint16_t index, uint16_t data) {
|
| 112 |
VL53L1_Error Status = VL53L1_ERROR_NONE; |
| 113 |
return Status;
|
| 114 |
} |
| 115 |
|
| 116 |
VL53L1_Error VL53L1_WrDWord(VL53L1_DEV Dev, uint16_t index, uint32_t data) {
|
| 117 |
VL53L1_Error Status = VL53L1_ERROR_NONE; |
| 118 |
return Status;
|
| 119 |
} |
| 120 |
|
| 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;
|
| 124 |
} |
| 125 |
|
| 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); |
| 131 |
|
| 132 |
return Status;
|
| 133 |
} |
| 134 |
|
| 135 |
VL53L1_Error VL53L1_RdWord(VL53L1_DEV Dev, uint16_t index, uint16_t *data) {
|
| 136 |
VL53L1_Error Status = VL53L1_ERROR_NONE; |
| 137 |
return Status;
|
| 138 |
} |
| 139 |
|
| 140 |
VL53L1_Error VL53L1_RdDWord(VL53L1_DEV Dev, uint16_t index, uint32_t *data) {
|
| 141 |
VL53L1_Error Status = VL53L1_ERROR_NONE; |
| 142 |
return Status;
|
| 143 |
} |
| 144 |
|
| 145 |
VL53L1_Error VL53L1_GetTickCount( |
| 146 |
uint32_t *ptick_count_ms) |
| 147 |
{
|
| 148 |
VL53L1_Error status = VL53L1_ERROR_NONE; |
| 149 |
return status;
|
| 150 |
} |
| 151 |
|
| 152 |
//#define trace_print(level, ...) \
|
| 153 |
// _LOG_TRACE_PRINT(VL53L1_TRACE_MODULE_PLATFORM, \
|
| 154 |
// level, VL53L1_TRACE_FUNCTION_NONE, ##__VA_ARGS__)
|
| 155 |
|
| 156 |
//#define trace_i2c(...) \
|
| 157 |
// _LOG_TRACE_PRINT(VL53L1_TRACE_MODULE_NONE, \
|
| 158 |
// VL53L1_TRACE_LEVEL_NONE, VL53L1_TRACE_FUNCTION_I2C, ##__VA_ARGS__)
|
| 159 |
|
| 160 |
VL53L1_Error VL53L1_GetTimerFrequency(int32_t *ptimer_freq_hz) |
| 161 |
{
|
| 162 |
VL53L1_Error status = VL53L1_ERROR_NONE; |
| 163 |
return status;
|
| 164 |
} |
| 165 |
|
| 166 |
VL53L1_Error VL53L1_WaitMs(VL53L1_Dev_t *pdev, int32_t wait_ms){
|
| 167 |
VL53L1_Error status = VL53L1_ERROR_NONE; |
| 168 |
return status;
|
| 169 |
} |
| 170 |
|
| 171 |
VL53L1_Error VL53L1_WaitUs(VL53L1_Dev_t *pdev, int32_t wait_us){
|
| 172 |
VL53L1_Error status = VL53L1_ERROR_NONE; |
| 173 |
return status;
|
| 174 |
} |
| 175 |
|
| 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) |
| 183 |
{
|
| 184 |
VL53L1_Error status = VL53L1_ERROR_NONE; |
| 185 |
return status;
|
| 186 |
} |
| 187 |
|
| 188 |
|
| 189 |
|