private async Task EnsureInitializedAsync()
{
if (IsInitialised) { return; }
try
{
var settings = new I2cConnectionSettings(I2C_ADDRESS);
settings.BusSpeed = I2cBusSpeed.FastMode;
string aqs = I2cDevice.GetDeviceSelector(I2cControllerName); /* Find the selector string for the I2C bus controller */
var dis = await DeviceInformation.FindAllAsync(aqs); /* Find the I2C bus controller device with our selector string */
I2CDevice = await I2cDevice.FromIdAsync(dis[0].Id, settings); /* Create an I2cDevice with our selected bus controller and I2C settings */
byte id = read8(Register.BMP085_REGISTER_CHIPID);
if (id != 0x55)
{
throw new Exception("Device is not a BMP180");
}
ReadCoefficients();
IsInitialised = true;
}
catch (Exception ex)
{
throw new Exception("I2C Initialization Failed", ex);
}
}