public II2CDevice OpenDevice(byte address, I2CModes mode = I2CModes.Standard) { IntPtr dev = MRAAInterop.mraa_i2c_init(this.Bus); if (dev == IntPtr.Zero) throw new MRAAException(MRAAInterop.Result.ErrorUnspecified); return new EdisonI2CDevice(dev, address, mode); }
internal EdisonI2CDevice(IntPtr dev, byte address, I2CModes frequency) { this.device = dev; this.Address = address; this.Frequency = frequency; var freqResult = MRAAInterop.mraa_i2c_frequency(this.device, (byte)frequency); if (freqResult != MRAAInterop.Result.Success) throw new MRAAException(freqResult); var addressResult = MRAAInterop.mraa_i2c_address(this.device, (byte)address); if (addressResult != MRAAInterop.Result.Success) throw new MRAAException(addressResult); }