public bool SetGPIOOn(byte pin) { if (_handle == IntPtr.Zero) { return(false); } _gpo = (byte)(_gpo | (byte)(1 << pin)); lock (_lock) { var status = LibMpsseI2C.FT_WriteGPIO(_handle, _direction, _gpo); CheckResult(status); } return(true); }
//Parts of this code are from http://www.chd.at/sites/default/files/files/FTDI.cs //pin = pin number; dir = 0:=input; 1:=output public bool SetGPIODirection(byte pin, byte dir) { if (_handle == IntPtr.Zero) { return(false); } if (dir == 1) { _direction |= (byte)(1 << pin); } else { _direction &= ((byte)~(1 << pin)); } _gpo &= ((byte)~(1 << pin)); lock (_lock) { var status = LibMpsseI2C.FT_WriteGPIO(_handle, _direction, _gpo); CheckResult(status); } return(true); }