A little Background:
So I've been working on a project that utilizes Chibios running on a Raspberry Pi zero (BCM2835 Chip) that will be interacting with several VL53L0X distance sensors (although because I am just setting things up right now I am just working with 1) over the I2C interface. As far as initialing the I2C on the Pi, I followed the blog post I've linked below. I have also confirmed that data is being written across the I2C data line with a separate STM32F4 board.
The Issue:
As of now, the i2cMasterTransmitTimeout() returns MSG_RESET and when calling i2cGetErrors() after receiving MSG_RESET, it seems like i2cflags_t variable that is returned is equal to 0x00. I could not find a lot of documentation on which register(s) these flags are pulled from or what each bit might mean .
Further Look:
As far as tracking the communication between the I2C on the Raspberry Pi and the Sensor, it seems that I can't have the STM Board connected to both the sensor and the Raspberry Pi together. Without the sensor and just having the I2C pins from the Raspberry Pi connected to the STM Board, I am only able to read in the first packet. I originally had the I2C set up on the STM Board, but unfortunately I ran into one problem and didn't want to debug it so I had set up a rising edge interrupt on the clock pin and then read in the value on the data pin (hence why I could only read in the first packet because the acknowledgment was never returned). But the value read in was:
Read in from the STM Board: 0x0692 -> 11010010010
Device Address: 0x52. -> _1010010___
So from my knowledge of I2C, everything (as far as setting up the Raspberry Pi) looks to be as it should.
All of the code that interacts with the sensor over I2C was written by the manufacturer so I find it unlikely to be an issue of bad addressing, but from what I can tell, it errors out on the first I2C call.
So I guess any help deciphering the i2cflags_t output would be much appreciated or any guidance to what to try / where to move to next.
Code:
Code: Select all
static int I2C_setup(){
I2CConfig i2cConfig = {
1,
100000,
2,
};
i2cStart(&I2C1, &i2cConfig);
return 1;
}
/********/
/* Function call */
VL53L0X_WrByte(device, 0x88, 0x00);
/********/
VL53L0X_Error VL53L0X_WrByte (VL53L0X_DEV Dev, uint8_t index, uint8_t data) {
uint8_t request[2];
request[0] = index;
request[1] = data;
i2cAcquireBus(&I2C1);
msg_t status = i2cMasterTransmitTimeout(&I2C1, Dev->I2cDevAddr, request, 2, NULL, 0, MS2ST(2000));
i2cReleaseBus(&I2C1);
if(status == RDY_OK)
return VL53L0X_ERROR_NONE;
return (VL53L0X_Error)status;
}
Setting up I2C on the Raspberry Pi:
http://lightsurge2.blogspot.com/2014/06 ... rev-2.html
Digikey Sensor:
https://www.digikey.com/product-detail/ ... ND/8827827