MCPcopy Create free account
hub / github.com/DISTORTEC/distortos / enablePll23

Function enablePll23

source/chip/STM32/STM32F1/STM32F1-RCC.cpp:80–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78 */
79
80int enablePll23(const bool pll3, const uint8_t pll23Mul)
81{
82 if ((pll23Mul < minPll23Mul || pll23Mul > maxPll23Mul) && pll23Mul != pll23Mul16 && pll23Mul != pll23Mul20)
83 return EINVAL;
84
85 const auto convertedPll23Mul = pll23Mul - 2 <= 0xf ? pll23Mul - 2 : 0xf;
86 RCC->CFGR2 = (RCC->CFGR2 & ~(pll3 == true ? RCC_CFGR2_PLL3MUL : RCC_CFGR2_PLL2MUL)) |
87 convertedPll23Mul << (pll3 == true ? RCC_CFGR2_PLL3MUL_Pos : RCC_CFGR2_PLL2MUL_Pos);
88 (pll3 == true ? STM32_BITBAND(RCC, CR, PLL3ON) : STM32_BITBAND(RCC, CR, PLL2ON)) = 1;
89 // wait until PLL is stable
90 while ((pll3 == true ? STM32_BITBAND(RCC, CR, PLL3RDY) : STM32_BITBAND(RCC, CR, PLL2RDY)) == 0);
91 return 0;
92}
93
94#endif // defined(DISTORTOS_CHIP_STM32F105) || defined(DISTORTOS_CHIP_STM32F107)
95

Callers 2

enablePll2Function · 0.85
enablePll3Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected