Skip to content

Commit

Permalink
Remove Output.WriteLineIfs
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianstevens committed Feb 17, 2025
1 parent ed25169 commit e01bb4b
Showing 1 changed file with 0 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ namespace Meadow.Hardware
/// </summary>
public partial class SpiBus : ISpiBus
{
private bool _showSpiDebug = false;
private SemaphoreSlim _busSemaphore = new SemaphoreSlim(1, 1);
private SpiClockConfiguration? _clockConfig;

Expand Down Expand Up @@ -187,7 +186,6 @@ public unsafe void Write(
ChipSelectMode csMode = ChipSelectMode.ActiveLow)
{
_busSemaphore.Wait();
Output.WriteLineIf(_showSpiDebug, $" +SendData");

try
{
Expand All @@ -207,13 +205,11 @@ public unsafe void Write(
BusNumber = BusNumber
};

Output.WriteLineIf(_showSpiDebug, $" sending {writeBuffer.Length} bytes: {BitConverter.ToString(writeBuffer.ToArray())}");
var result = UPD.Ioctl(Nuttx.UpdIoctlFn.SPIData, ref command);
if (result != 0)
{
DecipherSPIError(UPD.GetLastError());
}
Output.WriteLineIf(_showSpiDebug, $" send complete");

if (chipSelect != null)
{
Expand All @@ -225,7 +221,6 @@ public unsafe void Write(
finally
{
_busSemaphore.Release();
Output.WriteLineIf(_showSpiDebug, $" -SendData");
}
}

Expand Down Expand Up @@ -267,14 +262,11 @@ public unsafe void Exchange(
BusNumber = BusNumber
};

Output.WriteLineIf(_showSpiDebug, "+Exchange");
Output.WriteLineIf(_showSpiDebug, $" Sending {writeBuffer.Length} bytes");
var result = UPD.Ioctl(Nuttx.UpdIoctlFn.SPIData, ref command);
if (result != 0)
{
DecipherSPIError(UPD.GetLastError());
}
Output.WriteLineIf(_showSpiDebug, $" Received {readBuffer.Length} bytes");

if (chipSelect != null)
{
Expand Down Expand Up @@ -319,7 +311,6 @@ private void SetBitsPerWord(int bitsPerWord)
BitsPerWord = bitsPerWord
};

Output.WriteLineIf(_showSpiDebug, $" setting bus {command.BusNumber} bits per word to {command.BitsPerWord}");
var result = UPD.Ioctl(Nuttx.UpdIoctlFn.SPIBits, ref command);
if (result != 0)
{
Expand All @@ -336,14 +327,11 @@ private void SetMode(int mode)
Mode = mode
};

Output.WriteLineIf(_showSpiDebug, "+SetMode");
Output.WriteLineIf(_showSpiDebug, $" setting bus {command.BusNumber} mode to {command.Mode}");
var result = UPD.Ioctl(Nuttx.UpdIoctlFn.SPIMode, ref command);
if (result != 0)
{
DecipherSPIError(UPD.GetLastError());
}
Output.WriteLineIf(_showSpiDebug, $" mode set to {mode}");
}

private Units.Frequency SetFrequency(Units.Frequency desiredSpeed)
Expand All @@ -357,14 +345,11 @@ private Units.Frequency SetFrequency(Units.Frequency desiredSpeed)
Frequency = Convert.ToInt64(speed.Hertz)
};

Output.WriteLineIf(_showSpiDebug, "+SetFrequency");
Output.WriteLineIf(_showSpiDebug, $" setting bus {command.BusNumber} speed to {command.Frequency}");
var result = UPD.Ioctl(Nuttx.UpdIoctlFn.SPISpeed, ref command);
if (result != 0)
{
DecipherSPIError(UPD.GetLastError());
}
Output.WriteLineIf(_showSpiDebug, $" speed set to {desiredSpeed}");

return speed;
}
Expand Down

0 comments on commit e01bb4b

Please sign in to comment.