Writing to VL6180X GPIO pins

I have multiple VL6180X time-of-flight range finding sensors in a project that I’m working on, and I am trying to figure out if it’s possible to send a command over the I2C line to set GPIO1 to be high or low. I plan to use many of these sensors in my design, and thus, for startup it is not ideal to run individual GPIO wires from my microcontroller to each sensor for enabling/disabling them to assign new I2C addresses at startup. Instead, I’d like to have all the boards daisy chained, so I first talk to the first board, assign it a new I2C address, tell it to activate the next board (by turning GPIO1 high, which will be connected to the reset GPIO0 pin on the next board), and then repeat the process going down the line. I have found ways to enable an interrupt on GPIO1, but this is not what I need. Instead, I just need an I2C command to send the board that will set this pin high or low. Is this possible? Thanks!

Hello.

I was able to get two of these sensors to work like this. Some control of the state of the GPIO1 pin can be achieved by using the SYSTEM__MODE_GPIO1 register (documented on page 55 of the VL6180X datasheet). By setting system__gpio1_select to GPIO Interrupt output, the state of the output pin can be set using system__gpio1_polarity.

Our breakout board has pullup resistors on both the GPIO0/CE and GPIO1 pins, so when connecting GPIO1 of one board to GPIO0/CE of the next, GPIO1 will be high when system__gpio1_select is set to OFF (high impedance). The sensor is meant to toggle the state of the GPIO1 pin when taking measurements (subject to some interrupt conditions), though it seems like setting system__gpio1_select to OFF disables this. It is unclear to me whether the status of other registers in the sensor like the SYSTEM__INTERRUPT_CONFIG_GPIO register might affect this, so you should be careful.

The following code shows what I did for two sensors, and the basic template should be expandable for more:

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

VL6180X sensor;
VL6180X sensor2;

void setup() 
{
  Wire.begin();

  sensor.writeReg(0x011, 0b00110000);      // GPIO1 LOW (ActiveHigh  InterruptOutput)
  sensor.init();
  sensor.configureDefault();
  sensor.setAddress(0x30);
  sensor.writeReg(0x011, 0b00000000);      // GPIO1 High Impedance and pull-ups keep pin HIGH

  sensor2.writeReg(0x011, 0b00110000);     // GPIO1 LOW (ActiveHigh  InterruptOutput)
  sensor2.init();
  sensor2.configureDefault();
  sensor2.setAddress(0x31);
  sensor2.writeReg(0x011, 0b00000000);    // GPIO1 High Impedance and pull-ups keep pin HIGH
}

-Nathan