private async Task <GSI.AnalogIO> AnalogIOCreator(Socket socket, SocketPinNumber pinNumber) { if (!this.analogMap.ContainsKey(socket.Number)) { throw new UnsupportedPinModeException(); } if (!this.analogMap[socket.Number].ContainsKey(pinNumber)) { throw new UnsupportedPinModeException(); } var channel = this.analogMap[socket.Number][pinNumber]; if (this.analogSharedMap.ContainsKey(channel)) { var shared = this.analogSharedMap[channel]; if (shared.Item1 == 0) { using (var gpio = await GNI.DigitalIO.CreateInterfaceAsync(shared.Item2)) { gpio.SetDriveMode(GpioPinDriveMode.Input); } } else { this.gpios[shared.Item1 - 1].SetDriveMode(shared.Item2, GpioPinDriveMode.Input); } } return(new IndirectedAnalogIO(channel, this.analog)); }
public async Task <DigitalIO> CreateDigitalIOAsync(SocketPinNumber pinNumber, WD.Gpio.GpioPinEdge interruptType) { var result = await this.CreateDigitalIOAsync(pinNumber); result.InterruptType = interruptType; return(result); }
public async Task <AnalogIO> CreateAnalogIOAsync(SocketPinNumber pinNumber, double initialVoltage) { var result = await this.CreateAnalogIOAsync(pinNumber); result.DriveMode = WD.Gpio.GpioPinDriveMode.Output; result.Voltage = initialVoltage; return(result); }
public async Task <DigitalIO> CreateDigitalIOAsync(SocketPinNumber pinNumber, bool initialValue) { var result = await this.CreateDigitalIOAsync(pinNumber); result.DriveMode = WD.Gpio.GpioPinDriveMode.Output; result.Value = initialValue; return(result); }
public async Task <PwmOutput> CreatePwmOutputAsync(SocketPinNumber pinNumber) { this.EnsureTypeIsSupported(SocketType.P); if (this.PwmOutputCreator != null) { return(await this.PwmOutputCreator(this, pinNumber)); } return(new NativeInterfaces.PwmOutput()); }
public async Task <AnalogIO> CreateAnalogIOAsync(SocketPinNumber pinNumber) { this.EnsureTypeIsSupported(SocketType.A); AnalogIO result; if (this.AnalogIOCreator != null) { result = await this.AnalogIOCreator(this, pinNumber); } else { result = new NativeInterfaces.AnalogIO(); } result.DriveMode = WD.Gpio.GpioPinDriveMode.Input; return(result); }
public async Task <DigitalIO> CreateDigitalIOAsync(SocketPinNumber pinNumber) { DigitalIO result; if (this.nativePins.ContainsKey(pinNumber)) { result = new NativeInterfaces.DigitalIO(await NativeInterfaces.DigitalIO.CreateInterfaceAsync(this.nativePins[pinNumber])); } else if (this.DigitalIOCreator != null) { result = await this.DigitalIOCreator(this, pinNumber); } else { throw new UnsupportedPinModeException(); } result.DriveMode = WD.Gpio.GpioPinDriveMode.Input; return(result); }
private Task <GSI.PwmOutput> PwmOutputCreator(Socket socket, SocketPinNumber pinNumber) { if (!this.pwmMap.ContainsKey(socket.Number)) { throw new UnsupportedPinModeException(); } if (!this.pwmMap[socket.Number].ContainsKey(pinNumber)) { throw new UnsupportedPinModeException(); } var channel = this.pwmMap[socket.Number][pinNumber]; var shared = this.pwmSharedMap[channel]; this.gpios[shared.Item1 - 1].SetDriveMode(shared.Item2, GpioPinDriveMode.Input); this.gpios[shared.Item3 - 1].SetDriveMode(shared.Item4, GpioPinDriveMode.Output); this.gpios[shared.Item3 - 1].Write(shared.Item4, false); return(Task.FromResult <GSI.PwmOutput>(new IndirectedPwmOutput(channel, this.pwm))); }
private Task <GSI.DigitalIO> DigitalIOCreator(Socket socket, SocketPinNumber pinNumber) { if (!this.gpioMap.ContainsKey(socket.Number)) { throw new UnsupportedPinModeException(); } if (!this.gpioMap[socket.Number].ContainsKey(pinNumber)) { throw new UnsupportedPinModeException(); } var pin = this.gpioMap[socket.Number][pinNumber]; if (this.pwmMap.ContainsKey(socket.Number) && this.pwmMap[socket.Number].ContainsKey(pinNumber)) { var channel = this.pwmMap[socket.Number][pinNumber]; var shared = this.pwmSharedMap[channel]; this.gpios[shared.Item3 - 1].SetDriveMode(shared.Item4, GpioPinDriveMode.Output); this.gpios[shared.Item3 - 1].Write(shared.Item4, true); } return(Task.FromResult <GSI.DigitalIO>(new IndirectedDigitalIO(pin.Item2, this.gpios[pin.Item1 - 1]))); }
public async Task<DigitalIO> CreateDigitalIOAsync(SocketPinNumber pinNumber, bool initialValue) { var result = await this.CreateDigitalIOAsync(pinNumber); result.DriveMode = WD.Gpio.GpioPinDriveMode.Output; result.Value = initialValue; return result; }
public async Task<DigitalIO> CreateDigitalIOAsync(SocketPinNumber pinNumber) { DigitalIO result; if (this.nativePins.ContainsKey(pinNumber)) { result = new NativeInterfaces.DigitalIO(await NativeInterfaces.DigitalIO.CreateInterfaceAsync(this.nativePins[pinNumber])); } else if (this.DigitalIOCreator != null) { result = await this.DigitalIOCreator(this, pinNumber); } else { throw new UnsupportedPinModeException(); } result.DriveMode = WD.Gpio.GpioPinDriveMode.Input; return result; }
public async Task<DigitalIO> CreateDigitalIOAsync(SocketPinNumber pinNumber, WD.Gpio.GpioPinEdge interruptType) { var result = await this.CreateDigitalIOAsync(pinNumber); result.InterruptType = interruptType; return result; }
public async Task <SpiDevice> CreateSpiDeviceAsync(WD.Spi.SpiConnectionSettings connectionSettings, SocketPinNumber chipSelectPinNumber, SocketPinNumber masterOutPinNumber, SocketPinNumber masterInPinNumber, SocketPinNumber clockPinNumber) { if (chipSelectPinNumber == SocketPinNumber.Six && masterOutPinNumber == SocketPinNumber.Seven && masterInPinNumber == SocketPinNumber.Eight && clockPinNumber == SocketPinNumber.Nine && this.IsTypeSupported(SocketType.S)) { return(await this.CreateSpiDeviceAsync(connectionSettings)); } var chipSelect = await this.CreateDigitalIOAsync(chipSelectPinNumber); var masterOut = await this.CreateDigitalIOAsync(masterOutPinNumber); var masterIn = await this.CreateDigitalIOAsync(masterInPinNumber); var clock = await this.CreateDigitalIOAsync(clockPinNumber); return(new SoftwareInterfaces.SpiDevice(chipSelect, masterOut, masterIn, clock, connectionSettings)); }
public void SetNativePin(SocketPinNumber pinNumber, int nativePinNumber) { this.nativePins[pinNumber] = nativePinNumber; }
public async Task<PwmOutput> CreatePwmOutputAsync(SocketPinNumber pinNumber) { this.EnsureTypeIsSupported(SocketType.P); if (this.PwmOutputCreator != null) return await this.PwmOutputCreator(this, pinNumber); return new NativeInterfaces.PwmOutput(); }
public async Task<SpiDevice> CreateSpiDeviceAsync(WD.Spi.SpiConnectionSettings connectionSettings, SocketPinNumber chipSelectPinNumber, SocketPinNumber masterOutPinNumber, SocketPinNumber masterInPinNumber, SocketPinNumber clockPinNumber) { if (chipSelectPinNumber == SocketPinNumber.Six && masterOutPinNumber == SocketPinNumber.Seven && masterInPinNumber == SocketPinNumber.Eight && clockPinNumber == SocketPinNumber.Nine && this.IsTypeSupported(SocketType.S)) return await this.CreateSpiDeviceAsync(connectionSettings); var chipSelect = await this.CreateDigitalIOAsync(chipSelectPinNumber); var masterOut = await this.CreateDigitalIOAsync(masterOutPinNumber); var masterIn = await this.CreateDigitalIOAsync(masterInPinNumber); var clock = await this.CreateDigitalIOAsync(clockPinNumber); return new SoftwareInterfaces.SpiDevice(chipSelect, masterOut, masterIn, clock, connectionSettings); }
private byte GetChannel(Socket socket, SocketPinNumber pin) { return (byte)((socket.Number - 1) * 3 + ((int)pin - 3)); }
private async Task<AnalogIO> AnalogIOCreator(Socket socket, SocketPinNumber pinNumber) { if (!this.analogMap.ContainsKey(socket.Number)) throw new UnsupportedPinModeException(); if (!this.analogMap[socket.Number].ContainsKey(pinNumber)) throw new UnsupportedPinModeException(); var channel = this.analogMap[socket.Number][pinNumber]; if (this.analogSharedMap.ContainsKey(channel)) { var shared = this.analogSharedMap[channel]; if (shared.Item1 == 0) { using (var gpio = await NativeInterfaces.DigitalIO.CreateInterfaceAsync(shared.Item2)) { gpio.SetDriveMode(GpioPinDriveMode.Input); } } else { this.gpios[shared.Item1 - 1].SetDriveMode(shared.Item2, GpioPinDriveMode.Input); } } return new IndirectedAnalogIO(channel, this.analog); }
public async Task <GSI.AnalogIO> CreateAnalogIOAsync(SocketPinNumber pinNumber, double initialVoltage) => await this.socket.CreateAnalogIOAsync(pinNumber, initialVoltage);
public async Task <GSI.AnalogIO> CreateAnalogIOAsync(SocketPinNumber pinNumber) => await this.socket.CreateAnalogIOAsync(pinNumber);
public async Task <GSI.DigitalIO> CreateDigitalIOAsync(SocketPinNumber pinNumber, bool initialValue) => await this.socket.CreateDigitalIOAsync(pinNumber, initialValue);
public async Task <GSI.DigitalIO> CreateDigitalIOAsync(SocketPinNumber pinNumber) => await this.socket.CreateDigitalIOAsync(pinNumber);
public async Task<AnalogIO> CreateAnalogIOAsync(SocketPinNumber pinNumber) { this.EnsureTypeIsSupported(SocketType.A); AnalogIO result; if (this.AnalogIOCreator != null) { result = await this.AnalogIOCreator(this, pinNumber); } else { result = new NativeInterfaces.AnalogIO(); } result.DriveMode = WD.Gpio.GpioPinDriveMode.Input; return result; }
private Task<PwmOutput> PwmOutputCreator(Socket socket, SocketPinNumber pinNumber) { if (!this.pwmMap.ContainsKey(socket.Number)) throw new UnsupportedPinModeException(); if (!this.pwmMap[socket.Number].ContainsKey(pinNumber)) throw new UnsupportedPinModeException(); var channel = this.pwmMap[socket.Number][pinNumber]; var shared = this.pwmSharedMap[channel]; this.gpios[shared.Item1 - 1].SetDriveMode(shared.Item2, GpioPinDriveMode.Input); this.gpios[shared.Item3 - 1].SetDriveMode(shared.Item4, GpioPinDriveMode.Output); this.gpios[shared.Item3 - 1].Write(shared.Item4, false); return Task.FromResult<PwmOutput>(new IndirectedPwmOutput(channel, this.pwm)); }
public async Task<AnalogIO> CreateAnalogIOAsync(SocketPinNumber pinNumber, double initialVoltage) { var result = await this.CreateAnalogIOAsync(pinNumber); result.DriveMode = WD.Gpio.GpioPinDriveMode.Output; result.Voltage = initialVoltage; return result; }
private CY8C9560A.Pin GetPin(Socket socket, SocketPinNumber pin) { return(this.map[(int)socket.Number - 1][pin]); }
public async Task<I2cDevice> CreateI2cDeviceAsync(WD.I2c.I2cConnectionSettings connectionSettings, SocketPinNumber sdaPinNumber, SocketPinNumber sclPinNumber) { if (sdaPinNumber == SocketPinNumber.Eight && sclPinNumber == SocketPinNumber.Nine && this.IsTypeSupported(SocketType.I)) return await this.CreateI2cDeviceAsync(connectionSettings); var sda = await this.CreateDigitalIOAsync(sdaPinNumber); var scl = await this.CreateDigitalIOAsync(sclPinNumber); return new SoftwareInterfaces.I2cDevice(sda, scl, connectionSettings); }
private byte GetChannel(Socket socket, SocketPinNumber pin) { return((byte)((socket.Number - 1) * 3 + ((int)pin - 3))); }
public async Task <GSI.PwmOutput> CreatePwmOutputAsync(SocketPinNumber pinNumber) => await this.socket.CreatePwmOutputAsync(pinNumber);
public async Task <I2cDevice> CreateI2cDeviceAsync(WD.I2c.I2cConnectionSettings connectionSettings, SocketPinNumber sdaPinNumber, SocketPinNumber sclPinNumber) { if (sdaPinNumber == SocketPinNumber.Eight && sclPinNumber == SocketPinNumber.Nine && this.IsTypeSupported(SocketType.I)) { return(await this.CreateI2cDeviceAsync(connectionSettings)); } var sda = await this.CreateDigitalIOAsync(sdaPinNumber); var scl = await this.CreateDigitalIOAsync(sclPinNumber); return(new SoftwareInterfaces.I2cDevice(sda, scl, connectionSettings)); }
private Task<DigitalIO> DigitalIOCreator(Socket socket, SocketPinNumber pinNumber) { if (!this.gpioMap.ContainsKey(socket.Number)) throw new UnsupportedPinModeException(); if (!this.gpioMap[socket.Number].ContainsKey(pinNumber)) throw new UnsupportedPinModeException(); var pin = this.gpioMap[socket.Number][pinNumber]; if (this.pwmMap.ContainsKey(socket.Number) && this.pwmMap[socket.Number].ContainsKey(pinNumber)) { var channel = this.pwmMap[socket.Number][pinNumber]; var shared = this.pwmSharedMap[channel]; this.gpios[shared.Item3 - 1].SetDriveMode(shared.Item4, GpioPinDriveMode.Output); this.gpios[shared.Item3 - 1].Write(shared.Item4, true); } return Task.FromResult<DigitalIO>(new IndirectedDigitalIO(pin.Item2, this.gpios[pin.Item1 - 1])); }
private CY8C9560A.Pin GetPin(Socket socket, SocketPinNumber pin) { return this.map[(int)socket.Number - 1][pin]; }