-
-
Save MayaPosch/9443988784d8e31ce2c00a900a3be7a6 to your computer and use it in GitHub Desktop.
STM32 RCC enable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool Rcc::enable(RccPeripheral peripheral) { | |
uint8_t perNum = (uint8_t) peripheral; | |
RccPeripheralHandle &ph = (*perHandlesStatic)[perNum]; | |
if (ph.exists == false) { | |
return false; | |
} | |
// Check the current peripheral status. | |
if (ph.count > 0) { | |
if (ph.count >= handle_max) { | |
return false; | |
} | |
// Increase handler count by one. | |
ph.count++; | |
} | |
else { | |
// Activate the peripheral. | |
ph.count = 1; | |
*(ph.enr) |= (1 << ph.enable); | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment