#include "main.h" #include "stm32l4xx_hal_i2c.h" #include "vl6180x_i2c.h" #define VL6180X_ADDR (0x29 << 1) I2C_HandleTypeDef *handle; void vl6180x_glue_init(I2C_HandleTypeDef *handle_i2c) { handle = handle_i2c; } int VL6180x_I2CWrite(VL6180xDev_t dev, uint8_t *buff, uint8_t len) { if (HAL_I2C_Master_Transmit(handle, VL6180X_ADDR, buff, len, 100) != HAL_OK) { Error_Handler(); } return 0; } int VL6180x_I2CRead(VL6180xDev_t dev, uint8_t *buff, uint8_t len) { if (HAL_I2C_Master_Receive(handle, VL6180X_ADDR | 1, buff, len, 100) != 0) { Error_Handler(); } return 0; }