Hi,
I'm trying to write a driver for the MPL3115A2 Altimeter, but have some trouble with the I2C communication. I've got several other I2C devices working fine, so I think there is a particularity with this device I'm having trouble with.
The Arduino example code says this, at the bottom of the page:
byte [color=rgb(153,0,0);font-weight:bold;]IIC_Read[/color](byte regAddr)
{
[color=rgb(153,153,136);font-style:italic;]// This function reads one byte over IIC[/color]
Wire.beginTransmission(MPL3115A2_ADDRESS);
Wire.write(regAddr); [color=rgb(153,153,136);font-style:italic;]// Address of CTRL_REG1[/color]
Wire.endTransmission([color=rgb(0,134,179);]false[/color]); [color=rgb(153,153,136);font-style:italic;]// Send data to I2C dev with option for a repeated start. THIS IS NECESSARY and not supported before Arduino V1.0.1![/color]
Wire.requestFrom(MPL3115A2_ADDRESS, [color=rgb(0,153,153);]1[/color]); [color=rgb(153,153,136);font-style:italic;]// Request the data...[/color]
return Wire.read();
}
I have a feeling my problem occurs because I cannot find a C#-equivalent for endTransmission(false);
Does anyone have an idea on how I can accomplish the same with C#?
Here is the code I use. It uses the I2C helperclass found in this thread.
byte[] readBuffer = new byte[1];
bus.ReadRegister(config, (byte)Registers.CTRL_REG1, readBuffer, Timeout);
Whatever I do I only get 0-values back from the device.