| 125 | } |
| 126 | |
| 127 | int configureApbClockDivider(const bool ppre2, const uint8_t ppre) |
| 128 | { |
| 129 | static const std::pair<decltype(ppre), std::array<decltype(RCC_CFGR_PPRE1_DIV1), 2>> associations[] |
| 130 | { |
| 131 | {ppreDiv1, {RCC_CFGR_PPRE1_DIV1, RCC_CFGR_PPRE2_DIV1}}, |
| 132 | {ppreDiv2, {RCC_CFGR_PPRE1_DIV2, RCC_CFGR_PPRE2_DIV2}}, |
| 133 | {ppreDiv4, {RCC_CFGR_PPRE1_DIV4, RCC_CFGR_PPRE2_DIV4}}, |
| 134 | {ppreDiv8, {RCC_CFGR_PPRE1_DIV8, RCC_CFGR_PPRE2_DIV8}}, |
| 135 | {ppreDiv16, {RCC_CFGR_PPRE1_DIV16, RCC_CFGR_PPRE2_DIV16}}, |
| 136 | }; |
| 137 | |
| 138 | for (auto& association : associations) |
| 139 | if (association.first == ppre) |
| 140 | { |
| 141 | static const decltype(RCC_CFGR_PPRE1) masks[] {RCC_CFGR_PPRE1, RCC_CFGR_PPRE2}; |
| 142 | RCC->CFGR = (RCC->CFGR & ~masks[ppre2]) | association.second[ppre2]; |
| 143 | return 0; |
| 144 | } |
| 145 | |
| 146 | return EINVAL; |
| 147 | } |
| 148 | |
| 149 | int configurePrediv1(const uint8_t prediv1) |
| 150 | { |
no outgoing calls
no test coverage detected