[spi]fix some bug for rt_spi_sendrecv16 (#6360)

修复 rt_spi_sendrecv16 api 对最高有效位(MSB or LSB)的处理不当造成的一些问题。

https://github.com/stm32duino/Arduino_Core_STM32/blob/main/libraries/SPI/src/SPI.cpp#L273
This commit is contained in:
liYangYang
2022-09-01 00:36:45 -04:00
committed by GitHub
parent 9bbe2097db
commit 6ac09a6db0
2 changed files with 28 additions and 11 deletions
+5 -11
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
* Copyright (c) 2006-2022, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
@@ -7,6 +7,7 @@
* Date Author Notes
* 2012-11-23 Bernard Add extern "C"
* 2020-06-13 armink fix the 3 wires issue
* 2022-09-01 liYony fix api rt_spi_sendrecv16 about MSB and LSB bug
*/
#ifndef __SPI_H__
@@ -227,6 +228,9 @@ rt_err_t rt_spi_send_then_send(struct rt_spi_device *device,
const void *send_buf2,
rt_size_t send_length2);
rt_uint16_t rt_spi_sendrecv16(struct rt_spi_device *device,
rt_uint16_t data);
/**
* This function transmits data to SPI device.
*
@@ -278,16 +282,6 @@ rt_inline rt_uint8_t rt_spi_sendrecv8(struct rt_spi_device *device,
return value;
}
rt_inline rt_uint16_t rt_spi_sendrecv16(struct rt_spi_device *device,
rt_uint16_t data)
{
rt_uint16_t value = 0;
rt_spi_send_then_recv(device, &data, 2, &value, 2);
return value;
}
/**
* This function appends a message to the SPI message list.
*