Skip to content

Commit

Permalink
fix: SPI: get correct peripheral clock frequency
Browse files Browse the repository at this point in the history
Fixes #1380

Signed-off-by: Frederic Pillon <[email protected]>
  • Loading branch information
fpistm committed May 18, 2021
1 parent b59ef2e commit 3c47c68
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions libraries/SPI/src/utility/spi_com.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,27 @@ uint32_t spi_getClkFreqInst(SPI_TypeDef *spi_inst)
UNUSED(spi_inst);
/* SPIx source CLK is PCKL1 */
spi_freq = HAL_RCC_GetPCLK1Freq();
#elif defined(STM32H7xx)
/* Get source clock depending on SPI instance */
if (spi_inst != NP) {
switch ((uint32_t)spi_inst) {
case (uint32_t)SPI1:
case (uint32_t)SPI2:
case (uint32_t)SPI3:
spi_freq = HAL_RCCEx_GetPeriphCLKFreq(RCC_PERIPHCLK_SPI123);
break;
case (uint32_t)SPI4:
case (uint32_t)SPI5:
spi_freq = HAL_RCC_GetPCLK2Freq();
break;
case (uint32_t)SPI6:
spi_freq = HAL_RCCEx_GetPeriphCLKFreq(RCC_PERIPHCLK_SPI6);
break;
default:
core_debug("CLK: SPI instance not set");
break;
}
}
#elif defined(STM32MP1xx)
/* Get source clock depending on SPI instance */
if (spi_inst != NP) {
Expand Down

0 comments on commit 3c47c68

Please sign in to comment.