Skip to content

Commit fe3a99d

Browse files
mapelliladbridge
authored andcommitted
STM32: SPI: Use LL in spi_slave_read
this is more a cosmetic change, but since LL was introduced, we can now use it here as well.
1 parent 64bd60d commit fe3a99d

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

targets/TARGET_STM/stm_spi_api.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -438,17 +438,13 @@ int spi_slave_receive(spi_t *obj)
438438

439439
int spi_slave_read(spi_t *obj)
440440
{
441-
SPI_TypeDef *spi = SPI_INST(obj);
442441
struct spi_s *spiobj = SPI_S(obj);
443442
SPI_HandleTypeDef *handle = &(spiobj->handle);
444443
while (!ssp_readable(obj));
445-
if (handle->Init.DataSize == SPI_DATASIZE_8BIT) {
446-
// Force 8-bit access to the data register
447-
uint8_t *p_spi_dr = 0;
448-
p_spi_dr = (uint8_t *) & (spi->DR);
449-
return (int)(*p_spi_dr);
444+
if (handle->Init.DataSize == SPI_DATASIZE_16BIT) {
445+
return LL_SPI_ReceiveData16(SPI_INST(obj));
450446
} else {
451-
return (int)spi->DR;
447+
return LL_SPI_ReceiveData8(SPI_INST(obj));
452448
}
453449
}
454450

0 commit comments

Comments
 (0)