public static UInt32 Read24Bits(II2C device, byte reg, ByteOrder byteOrder, string exceptionMessage) { try { byte[] addr = { reg }; device.Write(addr); byte[] data = device.Read(3); switch (byteOrder) { case ByteOrder.BigEndian: return((UInt32)((data[0] << 16) | (data[1] << 8) | data[2])); case ByteOrder.LittleEndian: return((UInt32)((data[2] << 16) | (data[1] << 8) | data[0])); default: throw new SensorException($"Unsupported byte order {byteOrder}"); } } catch (Exception exception) { throw new SensorException(exceptionMessage, exception); } }
private void ConnectToI2CDevices() { try { _i2CDevice = I2CDeviceFactory.Singleton.Create(_i2CAddress); } catch (Exception exception) { throw new SensorException("Failed to connect to HTS221", exception); } }
private void ConnectToI2CDevices() { try { _accelGyroI2CDevice = I2CDeviceFactory.Singleton.Create(_accelGyroI2CAddress); _magI2CDevice = I2CDeviceFactory.Singleton.Create(_magI2CAddress); } catch (Exception exception) { throw new SensorException("Failed to connect to LSM9DS1", exception); } }
public static void Write(II2C device, byte reg, byte command, string exceptionMessage) { try { byte[] buffer = { reg, command }; device.Write(buffer); } catch (Exception exception) { throw new SensorException(exceptionMessage, exception); } }
public static byte Read8Bits(II2C device, byte reg, string exceptionMessage) { try { byte[] addr = { reg }; device.Write(addr); return(device.Read(1)[0]); } catch (Exception exception) { throw new SensorException(exceptionMessage, exception); } }
public static byte[] ReadBytes(II2C device, byte reg, int count, string exceptionMessage) { try { byte[] addr = { reg }; device.Write(addr); return(device.Read(count)); } catch (Exception exception) { throw new SensorException(exceptionMessage, exception); } }
public GpioButtonCore(II2C i2cWire, GpioPin pinToMonitor) { _i2CWire = i2cWire; _pinToMonitor = pinToMonitor; }
public DeviceIO(II2C i2C, IDutGpio gpio, AsyncPolicyWrap policyWrap) { I2C = i2C; Gpio = gpio; _policyWrap = policyWrap; }
public Apds9660GestureSensor(II2C device, IDigitalWriteRead gpio = null, int?interruptPin = null) { Device = device; Gpio = gpio; InterruptPin = interruptPin; }
public Mlx90614(II2C device, byte address = 0) { Device = device; Address = address; }
public MainI2CDevice(byte address) { _device = I2CDeviceFactory.Singleton.Create(address); }
protected I2CDevice(II2C i2c) : base(i2c) { }