diff --git a/src/System.Device.Gpio/System/Device/Spi/Drivers/UnixSpiDevice.Linux.cs b/src/System.Device.Gpio/System/Device/Spi/Drivers/UnixSpiDevice.Linux.cs index fe6e8f61abfe7436284e92aefcb91aa2cb9c0ee4..251f3a31e03ef7a89c2d897573e8677ded8c02f8 100644 --- a/src/System.Device.Gpio/System/Device/Spi/Drivers/UnixSpiDevice.Linux.cs +++ b/src/System.Device.Gpio/System/Device/Spi/Drivers/UnixSpiDevice.Linux.cs @@ -11,7 +11,7 @@ namespace System.Device.Spi.Drivers private const string Default_Device_Path = "/dev/spidev"; private const uint SPI_IOC_MESSAGE_1 = 0x40206b00; private int _deviceFileDescriptor = -1; - private SpiConnectionSettings _settings; + private readonly SpiConnectionSettings _settings; private static readonly object s_InitializationLock = new object(); public UnixSpiDevice(SpiConnectionSettings settings) diff --git a/src/System.Device.Gpio/System/Device/Spi/SpiConnectionSettings.cs b/src/System.Device.Gpio/System/Device/Spi/SpiConnectionSettings.cs index 2823b0238d2918c6a3c311cf39f1486ed96f2278..ab630e21ccbd2b2df3f00b00cba894ee776a9384 100644 --- a/src/System.Device.Gpio/System/Device/Spi/SpiConnectionSettings.cs +++ b/src/System.Device.Gpio/System/Device/Spi/SpiConnectionSettings.cs @@ -5,40 +5,40 @@ namespace System.Device.Spi { /// - /// Class that holds the connection settings of a device on a Spi bus. + /// The connection settings of a device on a SPI bus. /// public sealed class SpiConnectionSettings { private const SpiMode _defaultSpiMode = SpiMode.Mode0; - private const int _defaultDataBitLenght = 8; // 1 byte. + private const int _defaultDataBitLength = 8; // 1 byte private const int _defaultClockFrequency = 500_000; // 500 KHz private SpiConnectionSettings() { } /// - /// Default constructor. Takes the bus id and the chip select line for that bus. + /// Initializes new instance of SpiConnectionSettings. /// - /// The bus id the device is connected to. - /// The chip select line used on that bus id. + /// The bus ID the device is connected to. + /// The chip select line used on the bus. public SpiConnectionSettings(int busId, int chipSelectLine) { BusId = busId; ChipSelectLine = chipSelectLine; Mode = _defaultSpiMode; - DataBitLength = _defaultDataBitLenght; + DataBitLength = _defaultDataBitLength; ClockFrequency = _defaultClockFrequency; } /// - /// The Spi mode being used. + /// The SPI mode being used. /// public SpiMode Mode { get; set; } /// - /// The bus id the device is connected to. + /// The bus ID the device is connected to. /// public int BusId { get; set; } /// - /// The chip select line used on that bus id. + /// The chip select line used on the bus. /// public int ChipSelectLine { get; set; } /// diff --git a/src/System.Device.Gpio/System/Device/Spi/SpiDevice.cs b/src/System.Device.Gpio/System/Device/Spi/SpiDevice.cs index 69dd71130376b16731b6ed1f45c5f72ca8b12fe9..7445cdcd09eba81465793ade575083315065dddb 100644 --- a/src/System.Device.Gpio/System/Device/Spi/SpiDevice.cs +++ b/src/System.Device.Gpio/System/Device/Spi/SpiDevice.cs @@ -12,11 +12,13 @@ namespace System.Device.Spi public abstract void WriteByte(byte data); public abstract void Write(Span data); public abstract void TransferFullDuplex(Span writeBuffer, Span readBuffer); + public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } + public virtual void Dispose(bool disposing) { //Nothing to do in base class. diff --git a/src/System.Device.Gpio/System/Device/Spi/SpiMode.cs b/src/System.Device.Gpio/System/Device/Spi/SpiMode.cs index f3b91c1e5e48015e91e48818238ba9087c2d6374..141da1d729e03ad25064e80a90aafe8ce6cfc04d 100644 --- a/src/System.Device.Gpio/System/Device/Spi/SpiMode.cs +++ b/src/System.Device.Gpio/System/Device/Spi/SpiMode.cs @@ -5,26 +5,26 @@ namespace System.Device.Spi { /// - /// Enum with the different modes supported by SPI. - /// CPOL - Clock polarity: defines if each cycle consists of a pulse of 1, or 0. - /// CPHA - Clock phase: timing of the data bits relative to the clock pulses. + /// Defines how data is synchronized between devices on a SPI bus. + /// Clock Polarity (CPOL) determines if clock signal is low or high when in idle state. + /// Clock Phase (CPHA) determines when data is sampled relative to the clock signal. /// public enum SpiMode { /// - /// CPOL 0, CPHA 0 + /// CPOL 0, CPHA 0. Polarity is idled low and data is sampled on rising edge of the clock signal. /// Mode0, /// - /// CPOL 0, CPHA 1 + /// CPOL 0, CPHA 1. Polarity is idled low and data is sampled on falling edge of the clock signal. /// Mode1, /// - /// CPOL 1, CPHA 0 + /// CPOL 1, CPHA 0. Polarity is idled high and data is sampled on falling edge of the clock signal. /// Mode2, /// - /// CPOL 1, CPHA 1 + /// CPOL 1, CPHA 1. Polarity is idled high and data is sampled on rising edge of the clock signal. /// Mode3 }