From 79c186f5c962b514cde21415d7a262cfdbddbd97 Mon Sep 17 00:00:00 2001 From: Reinhard Feger <47209718+rf-eng@users.noreply.github.com> Date: Sat, 22 Aug 2020 18:48:21 +0200 Subject: [PATCH] stm32/spi: Fix baudrate calculation for H7 series. Fixes issue #6342. --- ports/stm32/spi.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ports/stm32/spi.c b/ports/stm32/spi.c index 07374d7a38..f8ab791898 100644 --- a/ports/stm32/spi.c +++ b/ports/stm32/spi.c @@ -633,7 +633,11 @@ void spi_print(const mp_print_t *print, const spi_t *spi_obj, bool legacy) { if (spi->State != HAL_SPI_STATE_RESET) { if (spi->Init.Mode == SPI_MODE_MASTER) { // compute baudrate + #if defined(STM32H7) + uint log_prescaler = (spi->Init.BaudRatePrescaler >> 28) + 1; + #else uint log_prescaler = (spi->Init.BaudRatePrescaler >> 3) + 1; + #endif uint baudrate = spi_get_source_freq(spi) >> log_prescaler; if (legacy) { mp_printf(print, ", SPI.MASTER");