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

Function configureApbClockDivider

source/chip/STM32/STM32F7/STM32F7-RCC.cpp:55–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53}
54
55int configureApbClockDivider(const bool ppre2, const uint8_t ppre)
56{
57 static const std::pair<decltype(ppre), std::array<decltype(RCC_CFGR_PPRE1_DIV1), 2>> associations[]
58 {
59 {ppreDiv1, {RCC_CFGR_PPRE1_DIV1, RCC_CFGR_PPRE2_DIV1}},
60 {ppreDiv2, {RCC_CFGR_PPRE1_DIV2, RCC_CFGR_PPRE2_DIV2}},
61 {ppreDiv4, {RCC_CFGR_PPRE1_DIV4, RCC_CFGR_PPRE2_DIV4}},
62 {ppreDiv8, {RCC_CFGR_PPRE1_DIV8, RCC_CFGR_PPRE2_DIV8}},
63 {ppreDiv16, {RCC_CFGR_PPRE1_DIV16, RCC_CFGR_PPRE2_DIV16}},
64 };
65
66 for (auto& association : associations)
67 if (association.first == ppre)
68 {
69 static const decltype(RCC_CFGR_PPRE1) masks[] {RCC_CFGR_PPRE1, RCC_CFGR_PPRE2};
70 RCC->CFGR = (RCC->CFGR & ~masks[ppre2]) | association.second[ppre2];
71 return 0;
72 }
73
74 return EINVAL;
75}
76
77void configurePll48ClockSource(const bool pllsaip)
78{

Callers 1

chipLowLevelInitializerFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected