From 339043b2082bb02d311418826d6822d18d4eec5a Mon Sep 17 00:00:00 2001 From: Laurent Ellerbach Date: Fri, 16 Jul 2021 17:53:09 +0300 Subject: [PATCH] fixing chip select --- System.Device.Spi/SpiConnectionSettings.cs | 4 ++-- Test/SpiHardwareUnitTests/SimpleSpiTests.cs | 4 ++-- .../SpiHardwareUnitTests.nfproj | 14 ++++++++------ Test/SpiHardwareUnitTests/packages.config | 2 +- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/System.Device.Spi/SpiConnectionSettings.cs b/System.Device.Spi/SpiConnectionSettings.cs index 8644eb7fd..e510a5d50 100644 --- a/System.Device.Spi/SpiConnectionSettings.cs +++ b/System.Device.Spi/SpiConnectionSettings.cs @@ -23,7 +23,7 @@ public sealed class SpiConnectionSettings private SpiSharingMode _spiSharingMode; private DataFlow _dataFlow = DataFlow.MsbFirst; private int _busId; - private PinValue _chipSelectLineActiveState = PinValue.Low; + private int _chipSelectLineActiveState = PinValue.Low == true ? 0 : 1; /// /// Initializes new instance of SpiConnectionSettings. @@ -140,7 +140,7 @@ public DataFlow DataFlow public PinValue ChipSelectLineActiveState { get => _chipSelectLineActiveState; - set => _chipSelectLineActiveState = value; + set => _chipSelectLineActiveState = value == PinValue.Low ? 0 : 1; } /// diff --git a/Test/SpiHardwareUnitTests/SimpleSpiTests.cs b/Test/SpiHardwareUnitTests/SimpleSpiTests.cs index 26d6573c3..d28ef404d 100644 --- a/Test/SpiHardwareUnitTests/SimpleSpiTests.cs +++ b/Test/SpiHardwareUnitTests/SimpleSpiTests.cs @@ -24,7 +24,7 @@ public void TryToSeeIfSpiIsSupported() { // Note: the ChipSelect pin should be adjusted to your device _connectinSettings = new SpiConnectionSettings(1, 12); - _spiDevice = SpiDevice.Create(_connectinSettings); + _spiDevice = SpiDevice.Create(_connectinSettings); } catch (Exception) { @@ -125,7 +125,7 @@ public void SpiBusInfo() Debug.WriteLine($"{nameof(spiBusInfo.MaxClockFrequency)}: {spiBusInfo.MaxClockFrequency}"); Debug.WriteLine($"{nameof(spiBusInfo.MinClockFrequency)}: {spiBusInfo.MinClockFrequency}"); Debug.WriteLine($"{nameof(spiBusInfo.SupportedDataBitLengths)}: "); - foreach(var data in spiBusInfo.SupportedDataBitLengths) + foreach (var data in spiBusInfo.SupportedDataBitLengths) { Debug.WriteLine($" {data}"); } diff --git a/Test/SpiHardwareUnitTests/SpiHardwareUnitTests.nfproj b/Test/SpiHardwareUnitTests/SpiHardwareUnitTests.nfproj index e87cc4958..c0c3c96b6 100644 --- a/Test/SpiHardwareUnitTests/SpiHardwareUnitTests.nfproj +++ b/Test/SpiHardwareUnitTests/SpiHardwareUnitTests.nfproj @@ -39,13 +39,15 @@ ..\..\packages\nanoFramework.Runtime.Events.1.9.1\lib\nanoFramework.Runtime.Events.dll True - - ..\..\packages\nanoFramework.TestFramework.1.0.147\lib\nanoFramework.TestFramework.dll + + ..\..\packages\nanoFramework.TestFramework.1.0.150\lib\nanoFramework.TestFramework.dll True + True - ..\..\packages\nanoFramework.TestFramework.1.0.147\lib\nanoFramework.UnitTestLauncher.exe + ..\..\packages\nanoFramework.TestFramework.1.0.150\lib\nanoFramework.UnitTestLauncher.exe True + True ..\..\packages\nanoFramework.System.Device.Gpio.1.0.1\lib\System.Device.Gpio.dll @@ -66,11 +68,11 @@ - + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}. - + - + \ No newline at end of file diff --git a/Test/SpiHardwareUnitTests/packages.config b/Test/SpiHardwareUnitTests/packages.config index a254e9e5b..8b9c90b70 100644 --- a/Test/SpiHardwareUnitTests/packages.config +++ b/Test/SpiHardwareUnitTests/packages.config @@ -3,5 +3,5 @@ - + \ No newline at end of file