[bsp][stm32] update drv_spi.c
#include "drv_spi.h"
#include "drv_config.h"
+#include <string.h>
//#define DRV_DEBUG
#define LOG_TAG "drv.spi"
@@ -276,7 +277,8 @@ static rt_uint32_t spixfer(struct rt_spi_device *device, struct rt_spi_message *
if ((spi_drv->spi_dma_flag & SPI_USING_TX_DMA_FLAG) && (spi_drv->spi_dma_flag & SPI_USING_RX_DMA_FLAG))
{
state = HAL_SPI_TransmitReceive_DMA(spi_handle, (uint8_t *)message->send_buf, (uint8_t *)message->recv_buf, message->length);
- }else
+ }
+ else
{
state = HAL_SPI_TransmitReceive(spi_handle, (uint8_t *)message->send_buf, (uint8_t *)message->recv_buf, message->length, 1000);
}
@@ -294,6 +296,7 @@ static rt_uint32_t spixfer(struct rt_spi_device *device, struct rt_spi_message *
}
else
{
+ memset(message->recv_buf, 0xff, message->length);
if (spi_drv->spi_dma_flag & SPI_USING_RX_DMA_FLAG)
{
state = HAL_SPI_Receive_DMA(spi_handle, (uint8_t *)message->recv_buf, message->length);
