| 53 | } |
| 54 | |
| 55 | int 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 | |
| 77 | void configurePll48ClockSource(const bool pllsaip) |
| 78 | { |
no outgoing calls
no test coverage detected