Skip to content

Instantly share code, notes, and snippets.

@MayaPosch

MayaPosch/stm32_rcc_enable.cpp Secret

Created Oct 28, 2020
Embed
What would you like to do?
STM32 RCC enable
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
You can’t perform that action at this time.