中级会员
 
- 积分
- 222
- 金钱
- 222
- 注册时间
- 2012-5-22
- 在线时间
- 59 小时
|

楼主 |
发表于 2022-5-30 18:10:37
|
显示全部楼层
当使用HAL_SPI_Transmit与HAL_SPI_Receive两个组合时用这样的程序:
if(write_size && read_size)
{
if(HAL_SPI_Transmit(spi_dev->spix, (uint8_t *)write_buf, write_size, 1000)!=HAL_OK)
{
result = SFUD_ERR_WRITE;
}
while (HAL_SPI_GetState(spi_dev->spix) != HAL_SPI_STATE_READY);
if(HAL_SPI_Receive(spi_dev->spix, (uint8_t *)read_buf, read_size, 1000)!=HAL_OK)
{
result = SFUD_ERR_READ;
}
}else if(write_size)
{
if(HAL_SPI_Transmit(spi_dev->spix, (uint8_t *)write_buf, write_size, 1000)!=HAL_OK)
{
result = SFUD_ERR_WRITE;
}
}else
{
if(HAL_SPI_Receive(spi_dev->spix, (uint8_t *)read_buf, read_size, 1000)!=HAL_OK)
{
result = SFUD_ERR_READ;
}
} |
|