The VL53L1CB proximity sensor, based on ST’s FlightSense™, Time-of-Flight technology.
Dependencies: X_NUCLEO_COMMON ST_INTERFACES
Dependents: VL53L1CB_noshield_1sensor_polls_auton VL53L1CB_noshield_1sensor_interrupt_auton X_NUCLEO_53L1A2
Based on VL53L1 library, this is a library for the VL53L1CB ToF chip.
Diff: src/spi_interface.cpp
- Revision:
- 18:0696efe39d08
- Parent:
- 0:3ac96e360672
--- a/src/spi_interface.cpp Wed Jun 23 12:57:26 2021 +0000 +++ b/src/spi_interface.cpp Wed Jul 21 17:06:38 2021 +0200 @@ -1,60 +1,38 @@ #include "ToF_I2C.h" #include "spi_interface.h" -/* This file is an interface between the c files and the mbed cpp files. */ - int v53l1x_i2c_write_if(uint8_t* pBuffer, uint8_t DeviceAddr, uint16_t RegisterAddr, +/* This file is an interface between the c platform file and the mbed cpp files. */ + + int v53l1cb_i2c_write_if(void *dev_I2C, uint8_t* pBuffer, uint8_t DeviceAddr, uint16_t RegisterAddr, uint16_t NumByteToWrite) { - - static ToF_DevI2C *dev_I2C = new ToF_DevI2C(D14, D15); - - dev_I2C->frequency(400000); - - // printf("v53l1x_i2c_write_if %d\n",NumByteToWrite); - int status = dev_I2C->ToF_i2c_write(pBuffer, DeviceAddr, RegisterAddr, NumByteToWrite); - - if(status) - { - delete dev_I2C; - return -1; - } - - return status; + int status = 0; + ToF_DevI2C *I2C= (ToF_DevI2C*)dev_I2C; + //I2C->frequency(400000); + status = I2C->ToF_i2c_write(pBuffer, DeviceAddr, RegisterAddr, NumByteToWrite); + return status; } - int v53l1x_i2c_read_if(uint8_t* pBuffer, uint8_t DeviceAddr, uint16_t RegisterAddr, + int v53l1cb_i2c_read_if(void *dev_I2C, uint8_t* pBuffer, uint8_t DeviceAddr, uint16_t RegisterAddr, uint16_t NumByteToRead) { - - - static ToF_DevI2C *dev_I2C = new ToF_DevI2C(D14, D15); - if (dev_I2C == NULL) - { - printf("v53l1x_i2c_read_if no pointer%d\n",NumByteToRead); - } - dev_I2C->frequency(400000); - // printf("v53l1x_i2c_read_if %d\n",NumByteToRead); - int status = dev_I2C->ToF_i2c_read(pBuffer, DeviceAddr, RegisterAddr, NumByteToRead); - // printf("v53l1x_i2c_read_if %d %d %d %d %d\n",status, DeviceAddr, RegisterAddr,NumByteToRead ,pBuffer[0]); - // delete dev_I2C; - - return status; + int status = 0; + ToF_DevI2C *I2C= (ToF_DevI2C*)dev_I2C; + // I2C->frequency(400000); + status = I2C->ToF_i2c_read(pBuffer, DeviceAddr, RegisterAddr, NumByteToRead); + return status; } int GetTickCount( uint32_t *ptick_count_ms) { - /* Returns current tick count in [ms] */ - int status = 0; - //*ptick_count_ms = timeGetTime(); *ptick_count_ms = us_ticker_read() / 1000; - return status; }