Skip to content

Commit 4e8df33

Browse files
committed
SPI: H7 and MP1 fix
Signed-off-by: Alexey Golyshin <[email protected]>
1 parent da74ede commit 4e8df33

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

libraries/SPI/src/utility/spi_com.c

+16-5
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ spi_status_e spi_send(spi_t *obj, uint8_t *Data, uint16_t len, uint32_t Timeout)
393393
* @param rx_buffer : data to receive
394394
* @param len : length in byte of the data to send and receive
395395
* @param Timeout: Timeout duration in tick
396-
* @param skipRecieve: skip recieving data after transmit or not
396+
* @param skipReceive: skip receiving data after transmit or not
397397
* @retval status of the send operation (0) in case of error
398398
*/
399399
spi_status_e spi_transfer(spi_t *obj, uint8_t *tx_buffer, uint8_t *rx_buffer,
@@ -407,14 +407,25 @@ spi_status_e spi_transfer(spi_t *obj, uint8_t *tx_buffer, uint8_t *rx_buffer,
407407
return Timeout > 0U ? SPI_ERROR : SPI_TIMEOUT;
408408
}
409409
tickstart = HAL_GetTick();
410+
411+
#if defined(STM32H7xx) || defined(STM32MP1xx)
412+
LL_SPI_StartMasterTransfer(_SPI); // start master transfer
413+
#endif
414+
410415
while (size--) {
411-
while (!LL_SPI_IsActiveFlag_TXE(_SPI))
412-
;
416+
#if defined(STM32H7xx) || defined(STM32MP1xx)
417+
while (!LL_SPI_IsActiveFlag_TXP(_SPI));
418+
#else
419+
while (!LL_SPI_IsActiveFlag_TXE(_SPI));
420+
#endif
413421
LL_SPI_TransmitData8(_SPI, *tx_buffer++);
414422

415423
if (!skipReceive) {
416-
while (!LL_SPI_IsActiveFlag_RXNE(_SPI))
417-
;
424+
#if defined(STM32H7xx) || defined(STM32MP1xx)
425+
while (!LL_SPI_IsActiveFlag_RXP(_SPI));
426+
#else
427+
while (!LL_SPI_IsActiveFlag_RXNE(_SPI));
428+
#endif
418429
*rx_buffer++ = LL_SPI_ReceiveData8(_SPI);
419430
}
420431
if ((Timeout != HAL_MAX_DELAY) && (HAL_GetTick() - tickstart >= Timeout)) {

0 commit comments

Comments
 (0)