Пример #1
0
        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);
        }
Пример #2
0
        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);
        }