From 7f1d77b1c9881a7d3727f6c1dc7cb52363fa0e85 Mon Sep 17 00:00:00 2001 From: Greg Ingram Date: Tue, 25 Jun 2019 18:39:21 -0400 Subject: [PATCH] Added new I2cController and related support (#505) * Added new I2cController and related support * Add bus ID as part of way to manage devices * Made static * Removed static * Removed interop file and add partial class for controller * Changed to open/close device methods * Added TryGetDevice method * Added ShouldDispose property * Added more support for disposing * Enabled nullable in file to check builds * Missed the other file for enabling nullable * Added GetDevices and updated OpenDevice check * Updated to ConcurrentDictionary * Consolidated to only Create I2cDevice * Removed unused files * Removed until direction is determined * Moved Create under I2cDevice classes --- .../System/Device/I2c/I2cDevice.Linux.cs | 16 ++++++++++++++++ .../System/Device/I2c/I2cDevice.Windows.cs | 16 ++++++++++++++++ .../System/Device/I2c/I2cDevice.cs | 2 +- 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 src/System.Device.Gpio/System/Device/I2c/I2cDevice.Linux.cs create mode 100644 src/System.Device.Gpio/System/Device/I2c/I2cDevice.Windows.cs diff --git a/src/System.Device.Gpio/System/Device/I2c/I2cDevice.Linux.cs b/src/System.Device.Gpio/System/Device/I2c/I2cDevice.Linux.cs new file mode 100644 index 00000000..05f183af --- /dev/null +++ b/src/System.Device.Gpio/System/Device/I2c/I2cDevice.Linux.cs @@ -0,0 +1,16 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Device.I2c +{ + public partial class I2cDevice + { + /// + /// Creates a communications channel to a device on an I2C bus running on Unix. + /// + /// The connection settings of a device on an I2C bus. + /// A communications channel to a device on an I2C bus running on Unix. + public static I2cDevice Create(I2cConnectionSettings settings) => new Drivers.UnixI2cDevice(settings); + } +} diff --git a/src/System.Device.Gpio/System/Device/I2c/I2cDevice.Windows.cs b/src/System.Device.Gpio/System/Device/I2c/I2cDevice.Windows.cs new file mode 100644 index 00000000..c214e622 --- /dev/null +++ b/src/System.Device.Gpio/System/Device/I2c/I2cDevice.Windows.cs @@ -0,0 +1,16 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Device.I2c +{ + public partial class I2cDevice + { + /// + /// Creates a communications channel to a device on an I2C bus running on Windows 10 IoT. + /// + /// The connection settings of a device on an I2C bus. + /// A communications channel to a device on an I2C bus running on Windows 10 IoT. + public static I2cDevice Create(I2cConnectionSettings settings) => new Drivers.Windows10I2cDevice(settings); + } +} diff --git a/src/System.Device.Gpio/System/Device/I2c/I2cDevice.cs b/src/System.Device.Gpio/System/Device/I2c/I2cDevice.cs index 576f08fb..f50855a5 100644 --- a/src/System.Device.Gpio/System/Device/I2c/I2cDevice.cs +++ b/src/System.Device.Gpio/System/Device/I2c/I2cDevice.cs @@ -7,7 +7,7 @@ namespace System.Device.I2c /// /// The communications channel to a device on an I2C bus. /// - public abstract class I2cDevice : IDisposable + public abstract partial class I2cDevice : IDisposable { /// /// The connection settings of a device on an I2C bus. -- GitLab