mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-26 01:35:41 +03:00
All SPI are fed with same clock (36MHz) on F1 and F3
This commit is contained in:
parent
7a66260713
commit
75f8e49a9a
2 changed files with 8 additions and 4 deletions
|
@ -263,16 +263,18 @@ void spiSetDivisor(SPI_TypeDef *instance, uint16_t divisor)
|
|||
{
|
||||
#define BR_BITS ((BIT(5) | BIT(4) | BIT(3)))
|
||||
|
||||
// SPI2 and SPI3 are always on APB1/AHB1 which PCLK is half that of APB2/AHB2.
|
||||
#if !(defined(STM32F1) || defined(STM32F3))
|
||||
// SPI2 and SPI3 are on APB1/AHB1 which PCLK is half that of APB2/AHB2.
|
||||
|
||||
if (instance == SPI2 || instance == SPI3) {
|
||||
divisor /= 2; // Safe for divisor == 0 or 1
|
||||
}
|
||||
#endif
|
||||
|
||||
SPI_Cmd(instance, DISABLE);
|
||||
|
||||
const uint16_t tempRegister = (instance->CR1 & ~BR_BITS);
|
||||
instance->CR1 = (tempRegister | ((ffs(divisor | 0x100) - 2) << 3));
|
||||
instance->CR1 = tempRegister | (divisor ? ((ffs(divisor | 0x100) - 2) << 3) : 0);
|
||||
|
||||
SPI_Cmd(instance, ENABLE);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue