コード例 #1
0
        public void SetPinMode(int pin, PinMode mode)
        {
            if (mode == PinMode.Output)
            {
                Directions |= PowerOf2[pin];
            }
            else
            {
                Directions &= ~PowerOf2[pin];
            }

            var result = LibMpsse.FT_WriteGPIO(_i2cHandle, (short)Directions, (short)Values);

            if (result != FtdiMpsseI2CResult.Ok)
            {
                throw new GpioException(result, nameof(SetPinMode));
            }
        }
コード例 #2
0
        public void DigitalWrite(int pin, PinState state)
        {
            if (state == PinState.High)
            {
                this.Values |= PowerOf2[pin];
            }
            else
            {
                Values &= ~PowerOf2[pin];
            }

            var result = LibMpsse.FT_WriteGPIO(_i2cHandle, (short)Directions, (short)Values);

            if (result != FtdiMpsseI2CResult.Ok)
            {
                if (Debugger.IsAttached)
                {
                    Debugger.Break();
                }

                throw new GpioException(result, nameof(DigitalWrite));
            }
        }
コード例 #3
0
 protected FtdiMpsseI2CResult WriteGPIOMask(byte directions, byte values)
 {
     Values     = values;
     Directions = directions;
     return(LibMpsse.FT_WriteGPIO(_i2cHandle, directions, values));
 }
コード例 #4
0
 protected FtdiMpsseI2CResult WriteGPIOMask(byte values)
 {
     return(LibMpsse.FT_WriteGPIO(_i2cHandle, 0, values));
 }