The library in question is the Adafruit VL6180X TOF sensor (https://github.com/adafruit/Adafruit_VL6180X). I am using the Nucleo L432KC development board. I believe i have successfully ported the both header files but I am having trouble with the source file for the VL6180X sensor. I don't have much knowledge in C++ and even less in translating it to C. I am looking for possible solutions/guidance in tackling this.
Ported header for VL6180X:
#ifndef ADAFRUIT_VL6180X_H
#define ADAFRUIT_VL6180X_H
#include "Adafruit_I2CDevice.h"
#include "main.h"
#include <stdbool.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#define VL6180X_DEFAULT_I2C_ADDR 0x29
#define VL6180X_ERROR_NONE 0
#define VL6180X_ERROR_SYSERR_1 1
#define VL6180X_ERROR_SYSERR_5 5
#define VL6180X_ERROR_ECEFAIL 6
#define VL6180X_ERROR_NOCONVERGE 7
#define VL6180X_ERROR_RANGEIGNORE 8
#define VL6180X_ERROR_SNR 11
#define VL6180X_ERROR_RAWUFLOW 12
#define VL6180X_ERROR_RAWOFLOW 13
#define VL6180X_ERROR_RANGEUFLOW 14
#define VL6180X_ERROR_RANGEOFLOW 15
#define VL6180X_DEFAULT_I2C_ADDR 0x29
typedef struct Adafruit_VL6180X_s {
I2C_HandleTypeDef *hi2c;
uint8_t i2caddr;
} Adafruit_VL6180X;
HAL_StatusTypeDef Adafruit_VL6180X_begin(Adafruit_VL6180X *vl6180x, I2C_HandleTypeDef *hi2c);
HAL_StatusTypeDef Adafruit_VL6180X_setAddress(Adafruit_VL6180X *vl6180x, uint8_t newAddr);
uint8_t Adafruit_VL6180X_getAddress(Adafruit_VL6180X *vl6180x);
uint8_t Adafruit_VL6180X_readRange(Adafruit_VL6180X *vl6180x);
uint8_t Adafruit_VL6180X_readRangeStatus(Adafruit_VL6180X *vl6180x);
HAL_StatusTypeDef Adafruit_VL6180X_startRange(Adafruit_VL6180X *vl6180x);
bool Adafruit_VL6180X_isRangeComplete(Adafruit_VL6180X *vl6180x);
bool Adafruit_VL6180X_waitRangeComplete(Adafruit_VL6180X *vl6180x);
uint8_t Adafruit_VL6180X_readRangeResult(Adafruit_VL6180X *vl6180x);
void Adafruit_VL6180X_startRangeContinuous(Adafruit_VL6180X *vl6180x, uint16_t period_ms);
void Adafruit_VL6180X_stopRangeContinuous(Adafruit_VL6180X *vl6180x);
void Adafruit_VL6180X_setOffset(Adafruit_VL6180X *vl6180x, uint8_t offset);
void Adafruit_VL6180X_getID(Adafruit_VL6180X *vl6180x, uint8_t *id_ptr);
#endif
Ported Header for I2C communication:
#ifndef Adafruit_I2CDevice_h
#define Adafruit_I2CDevice_h
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
typedef struct {
uint8_t _addr;
void* _wire;
bool _begun;
size_t _maxBufferSize;
} Adafruit_I2CDevice;
void Adafruit_I2CDevice_begin(Adafruit_I2CDevice* device, bool addr_detect);
uint8_t Adafruit_I2CDevice_address(Adafruit_I2CDevice* device);
void Adafruit_I2CDevice_end(Adafruit_I2CDevice* device);
bool Adafruit_I2CDevice_detected(Adafruit_I2CDevice* device);
bool Adafruit_I2CDevice_read(Adafruit_I2CDevice* device, uint8_t *buffer, size_t len, bool stop);
bool Adafruit_I2CDevice_write(Adafruit_I2CDevice* device, const uint8_t *buffer, size_t len, bool stop,
const uint8_t *prefix_buffer, size_t prefix_len);
bool Adafruit_I2CDevice_write_then_read(Adafruit_I2CDevice* device, const uint8_t *write_buffer, size_t write_len,
uint8_t *read_buffer, size_t read_len, bool stop);
bool Adafruit_I2CDevice_setSpeed(Adafruit_I2CDevice* device, uint32_t desiredclk);
size_t Adafruit_I2CDevice_maxBufferSize(Adafruit_I2CDevice* device);
#endif