Пример #1
0
        /// <summary>
        /// Exchanges the bytes data to the SPI slave device.
        /// writeBuffer.Length and readBuffer.Length must be equal.
        /// </summary>
        /// <param name="writeBuffer">Array containing data to write to the device.</param>
        /// <param name="readBuffer">Array containing data read from the dievice.</param>
        public void TransferSequential(byte[] writeBuffer, byte[] readBuffer)
        {
            if (writeBuffer.Length != readBuffer.Length)
            {
                throw new Exception("writeBuffer.Length is not equal to readBuffer.Length");
            }

            var buffersLength = Convert.ToUInt32(writeBuffer.Length);

            var ret = NativeSpi.Transfer(_handle, writeBuffer, readBuffer, buffersLength);

            if (ret != Internals.Errors.ErrorCode.None)
            {
                throw ExceptionFactory.CreateException(ret);
            }
        }