/// <summary> /// Sets the direction of a particulare port. /// </summary> /// <param name="pin"></param> /// <param name="direction"></param> public void SetPortDirection(byte pin, PortDirectionType direction) { if (IsValidPin(pin)) { // if it's already configured, get out. (1 = input, 0 = output) if (direction == PortDirectionType.Input) { if (BitHelpers.GetBitValue(_iodir, pin)) { return; } //if ((_iodir & (byte)(1 << pin)) != 0) return; } else { if (!BitHelpers.GetBitValue(_iodir, pin)) { return; } //if ((_iodir & (byte)(1 << pin)) == 0) return; } // set the IODIR bit and write the setting _iodir = BitHelpers.SetBit(_iodir, (byte)pin, (byte)direction); _i2cPeripheral.WriteRegister(_IODirectionRegister, _iodir); } else { throw new Exception("Pin is out of range"); } }
// TODO: all these can go away when we get interface implementation // support from C# 8 into the Meadow.Core project. It won't work today, // even though it's set to C# 8 because the project references the // .NET 4.7.2 runtime. After the latest Mono rebase we'll be able to // move it to Core 3. public IBiDirectionalPort CreateBiDirectionalPort(IPin pin, bool initialState = false, InterruptMode interruptMode = InterruptMode.None, ResistorMode resistorMode = ResistorMode.Disabled, PortDirectionType initialDirection = PortDirectionType.Input, double debounceDuration = 0.0, // 0 - 1000 msec in .1 increments double glitchDuration = 0.0, // 0 - 1000 msec in .1 increments OutputType outputType = OutputType.PushPull) { throw new NotImplementedException(); }
public IBiDirectionalPort CreateBiDirectionalPort(IPin pin, bool initialState = false, bool glitchFilter = false, InterruptMode interruptMode = InterruptMode.None, ResistorMode resistorMode = ResistorMode.Disabled, PortDirectionType initialDirection = PortDirectionType.Input) { throw new NotImplementedException(); }
protected DigitalPortBase(PortDirectionType direction) { _direction = direction; }