Skip to content

Commit 6dfafc7

Browse files
mapellilLMESTM
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 57371ea commit 6dfafc7

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
@@ -445,17 +445,13 @@ int spi_slave_receive(spi_t *obj)
445445

446446
int spi_slave_read(spi_t *obj)
447447
{
448-
SPI_TypeDef *spi = SPI_INST(obj);
449448
struct spi_s *spiobj = SPI_S(obj);
450449
SPI_HandleTypeDef *handle = &(spiobj->handle);
451450
while (!ssp_readable(obj));
452-
if (handle->Init.DataSize == SPI_DATASIZE_8BIT) {
453-
// Force 8-bit access to the data register
454-
uint8_t *p_spi_dr = 0;
455-
p_spi_dr = (uint8_t *) & (spi->DR);
456-
return (int)(*p_spi_dr);
451+
if (handle->Init.DataSize == SPI_DATASIZE_16BIT) {
452+
return LL_SPI_ReceiveData16(SPI_INST(obj));
457453
} else {
458-
return (int)spi->DR;
454+
return LL_SPI_ReceiveData8(SPI_INST(obj));
459455
}
460456
}
461457

0 commit comments

Comments
 (0)