Reading from a 32-bit register of VL6180X (0x7c)

This is my first time using the forum, sorry if my way of asking is not too proper.

Iam trying to read from this register 0x7c in VL6180X time of flight sensor. I found this block of code that can be used to do that.

// Reads a 32-bit register
uint32_t VL6180X::readReg32Bit(uint16_t reg)
{
  uint32_t value;
 
  Wire.beginTransmission(address);
  Wire.write((reg >> 8) & 0xff);  // reg high byte
  Wire.write(reg & 0xff);         // reg low byte
  last_status = Wire.endTransmission();
 
  Wire.requestFrom(address, (uint8_t)4);
  value = (uint32_t)Wire.read() << 24;  // value highest byte
  value |= (uint32_t)Wire.read() << 16;
  value |= (uint16_t)Wire.read() << 8;
  value |= Wire.read();                 // value lowest byte
  Wire.endTransmission();
 
  return value;
}

However when i put it in my arduino code, it keep giving the error below. And the error is from this line of code.

uint32_t VL6180X::readReg32Bit(uint16_t reg)
qualified-id in declaration before '(' token

Below is my arduino code

The range readings are in units of mm. */

#include <Wire.h>
#include <VL6180X.h>

VL6180X sensor;

void setup()
{
  Serial.begin(9600);
  Wire.begin();

  sensor.init();
  sensor.configureDefault();

  sensor.writeReg(VL6180X::SYSRANGE__MAX_CONVERGENCE_TIME, 30);
  sensor.writeReg16Bit(VL6180X::SYSALS__INTEGRATION_PERIOD, 50);

  sensor.setTimeout(500);

   // stop continuous mode if already active
  sensor.stopContinuous();
  // in case stopContinuous() triggered a single-shot
  // measurement, wait for it to complete
  delay(300);
  // start interleaved continuous mode with period of 100 ms
  sensor.startInterleavedContinuous(100);

//Reads a 32-bit sensor register and returns the value read.
//uint32_t readReg32Bit(uint16_t reg)

 uint32_t VL6180X::readReg32Bit(uint16_t reg)
{
uint32_t value;

  Wire.beginTransmission(0x7c);
  Wire.write((reg >> 8) & 0xff);  // reg high byte
  Wire.write(reg & 0xff);         // reg low byte
  last_status = Wire.endTransmission();

  Wire.requestFrom(0x7c, (uint8_t)4);
  value = (uint32_t)Wire.read() << 24;  // value highest byte
  value |= (uint32_t)Wire.read() << 16;
  value |= (uint16_t)Wire.read() << 8;
  value |= Wire.read();                 // value lowest byte
  Wire.endTransmission();

  return value;
}
}

void loop()
{
  Serial.print("Ambient: ");
  Serial.print(sensor.readAmbientContinuous());
  if (sensor.timeoutOccurred()) { Serial.print(" TIMEOUT"); }

  Serial.print("\tRange: ");
  Serial.print(sensor.readRangeContinuousMillimeters());
  if (sensor.timeoutOccurred()) { Serial.print(" TIMEOUT"); }
  
  Serial.println();
}

please whats the proper way to implement this, or any other way to read from the register.
Thank you.

Hello.

The VL6180X::readReg32Bit function is included in the library and you should not add it again a second time in you main program file. If you want to read that register, the following code should work:

uint32_t  registerResults;
registerResults = sensor.readReg32Bit(0x7c);

-Nathan

Okay thank you for the response, I will try it out.