| 53 | } |
| 54 | |
| 55 | int configureApbClockDivider(const uint8_t ppre) |
| 56 | { |
| 57 | static const std::pair<decltype(ppre), decltype(RCC_CFGR_PPRE_DIV1)> associations[] |
| 58 | { |
| 59 | {ppreDiv1, RCC_CFGR_PPRE_DIV1}, |
| 60 | {ppreDiv2, RCC_CFGR_PPRE_DIV2}, |
| 61 | {ppreDiv4, RCC_CFGR_PPRE_DIV4}, |
| 62 | {ppreDiv8, RCC_CFGR_PPRE_DIV8}, |
| 63 | {ppreDiv16, RCC_CFGR_PPRE_DIV16}, |
| 64 | }; |
| 65 | |
| 66 | for (auto& association : associations) |
| 67 | if (association.first == ppre) |
| 68 | { |
| 69 | RCC->CFGR = (RCC->CFGR & ~RCC_CFGR_PPRE) | association.second; |
| 70 | return 0; |
| 71 | } |
| 72 | |
| 73 | return EINVAL; |
| 74 | } |
| 75 | |
| 76 | int configurePrediv(const uint8_t prediv) |
| 77 | { |
no outgoing calls
no test coverage detected