Exemplo n.º 1
0
		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);
		}
Exemplo n.º 2
0
		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);
		}
Exemplo n.º 3
0
		public async Task<SpiDevice> CreateSpiDeviceAsync(WD.Spi.SpiConnectionSettings connectionSettings) {
			if (this.IsTypeSupported(SocketType.Y) && !this.IsTypeSupported(SocketType.S))
				return await this.CreateSpiDeviceAsync(connectionSettings, SocketPinNumber.Six, SocketPinNumber.Seven, SocketPinNumber.Eight, SocketPinNumber.Nine);

			this.EnsureTypeIsSupported(SocketType.S);

			if (this.SpiDeviceCreator != null)
				return await this.SpiDeviceCreator(this);

            return new NativeInterfaces.SpiDevice(await NativeInterfaces.SpiDevice.CreateInterfaceAsync(this.NativeSpiDeviceId, connectionSettings));
		}
Exemplo n.º 4
0
 public I2cDevice(WD.I2c.I2cDevice device) {
     this.device = device;
 }
Exemplo n.º 5
0
		public async Task<DigitalIO> CreateDigitalIOAsync(SocketPinNumber pinNumber, WD.Gpio.GpioPinEdge interruptType) {
			var result = await this.CreateDigitalIOAsync(pinNumber);

			result.InterruptType = interruptType;

			return result;
		}
Exemplo n.º 6
0
        public static async Task<WD.I2c.I2cDevice> CreateInterfaceAsync(string deviceId, WD.I2c.I2cConnectionSettings connectionSettings) {
            var infos = await WD.Enumeration.DeviceInformation.FindAllAsync(WD.I2c.I2cDevice.GetDeviceSelector(deviceId));

            return await WD.I2c.I2cDevice.FromIdAsync(infos[0].Id, connectionSettings);
        }
Exemplo n.º 7
0
 private void OnInterrupt(WD.Gpio.GpioPin sender, WD.Gpio.GpioPinValueChangedEventArgs e) => this.OnValueChanged(e.Edge == WD.Gpio.GpioPinEdge.RisingEdge);
Exemplo n.º 8
0
 public SerialDevice(WD.SerialCommunication.SerialDevice device) {
     this.device = device;
     this.writer = new DataWriter(this.device.OutputStream);
     this.reader = new DataReader(this.device.InputStream);
 }
Exemplo n.º 9
0
 public DigitalIO(WD.Gpio.GpioPin pin) {
     this.pin = pin;
 }
Exemplo n.º 10
0
 public SpiDevice(WD.Spi.SpiDevice device) {
     this.device = device;
 }