[HUST CSE]fix:修改drv_spi.c空指针问题
This commit is contained in:
parent
8d526a72b4
commit
613e5a3e51
|
@ -393,8 +393,15 @@ static rt_ssize_t xfer(struct rt_spi_device* device, struct rt_spi_message* mess
|
|||
|
||||
/* calculate the start address */
|
||||
already_send_length = message->length - send_length - message_length;
|
||||
send_buf = (rt_uint8_t *)message->send_buf + already_send_length;
|
||||
recv_buf = (rt_uint8_t *)message->recv_buf + already_send_length;
|
||||
/* avoid null pointer problems */
|
||||
if (message->send_buf)
|
||||
{
|
||||
send_buf = (rt_uint8_t *)message->send_buf + already_send_length;
|
||||
}
|
||||
if (message->recv_buf)
|
||||
{
|
||||
recv_buf = (rt_uint8_t *)message->recv_buf + already_send_length;
|
||||
}
|
||||
|
||||
/* start once data exchange in dma mode */
|
||||
if (message->send_buf && message->recv_buf)
|
||||
|
|
|
@ -441,8 +441,16 @@ static rt_uint32_t hc32_spi_xfer(struct rt_spi_device *device, struct rt_spi_mes
|
|||
|
||||
/* calculate the start address */
|
||||
already_send_length = message->length - send_length - message_length;
|
||||
send_buf = (rt_uint8_t *)message->send_buf + already_send_length;
|
||||
recv_buf = (rt_uint8_t *)message->recv_buf + already_send_length;
|
||||
/* avoid null pointer problems */
|
||||
if (message->send_buf)
|
||||
{
|
||||
send_buf = (rt_uint8_t *)message->send_buf + already_send_length;
|
||||
}
|
||||
if (message->recv_buf)
|
||||
{
|
||||
recv_buf = (rt_uint8_t *)message->recv_buf + already_send_length;
|
||||
}
|
||||
|
||||
if (message->send_buf && message->recv_buf)
|
||||
{
|
||||
if ((spi_drv->spi_dma_flag & RT_DEVICE_FLAG_DMA_TX) && (spi_drv->spi_dma_flag & RT_DEVICE_FLAG_DMA_RX))
|
||||
|
|
|
@ -329,9 +329,16 @@ static rt_ssize_t spixfer(struct rt_spi_device *device, struct rt_spi_message *m
|
|||
|
||||
/* calculate the start address */
|
||||
already_send_length = message->length - send_length - message_length;
|
||||
send_buf = (rt_uint8_t *)message->send_buf + already_send_length;
|
||||
recv_buf = (rt_uint8_t *)message->recv_buf + already_send_length;
|
||||
|
||||
/* avoid null pointer problems */
|
||||
if (message->send_buf)
|
||||
{
|
||||
send_buf = (rt_uint8_t *)message->send_buf + already_send_length;
|
||||
}
|
||||
if (message->recv_buf)
|
||||
{
|
||||
recv_buf = (rt_uint8_t *)message->recv_buf + already_send_length;
|
||||
}
|
||||
|
||||
#if defined(SOC_SERIES_STM32H7) || defined(SOC_SERIES_STM32F7)
|
||||
rt_uint32_t* dma_buf = RT_NULL;
|
||||
if ((spi_drv->spi_dma_flag & SPI_USING_TX_DMA_FLAG) && (spi_drv->spi_dma_flag & SPI_USING_RX_DMA_FLAG))
|
||||
|
|
|
@ -410,8 +410,15 @@ static rt_ssize_t spi_xfer(struct rt_spi_device *device, struct rt_spi_message *
|
|||
|
||||
/* calculate the start address */
|
||||
already_send_length = message->length - send_length - message_length;
|
||||
send_buf = (rt_uint8_t *)message->send_buf + already_send_length;
|
||||
recv_buf = (rt_uint8_t *)message->recv_buf + already_send_length;
|
||||
/* avoid null pointer problems */
|
||||
if (message->send_buf)
|
||||
{
|
||||
send_buf = (rt_uint8_t *)message->send_buf + already_send_length;
|
||||
}
|
||||
if (message->recv_buf)
|
||||
{
|
||||
recv_buf = (rt_uint8_t *)message->recv_buf + already_send_length;
|
||||
}
|
||||
|
||||
/* start once data exchange */
|
||||
if (message->send_buf && message->recv_buf)
|
||||
|
|
Loading…
Reference in New Issue