/// <summary> /// Writes and reads data from the SPI device. /// </summary> /// <param name="writeBuffer">The buffer that contains the data to be written to the SPI device.</param> /// <param name="readBuffer">The buffer to read the data from the SPI device.</param> public override void TransferFullDuplex(ReadOnlySpan <byte> writeBuffer, Span <byte> readBuffer) { if (writeBuffer.Length != readBuffer.Length) { throw new ArgumentException($"Parameters '{nameof(writeBuffer)}' and '{nameof(readBuffer)}' must have the same length."); } byte[] byteArray = new byte[readBuffer.Length]; _winDevice.TransferFullDuplex(writeBuffer.ToArray(), byteArray); }
/// <summary> /// Writes and reads data from the SPI device. /// </summary> /// <param name="writeBuffer">The buffer that contains the data to be written to the SPI device.</param> /// <param name="readBuffer">The buffer to read the data from the SPI device.</param> public override void TransferFullDuplex(ReadOnlySpan <byte> writeBuffer, Span <byte> readBuffer) { if (writeBuffer.Length != readBuffer.Length) { throw new ArgumentException($"Parameters '{nameof(writeBuffer)}' and '{nameof(readBuffer)}' must have the same length."); } byte[] readArray = new byte[readBuffer.Length]; byte[] writeArray = writeBuffer.ToArray(); if (_isInverted) { ReverseByte(writeArray); } _winDevice.TransferFullDuplex(writeArray, readArray); readArray.CopyTo(readBuffer); if (_isInverted) { ReverseByte(readBuffer); } }