Skip to content

Instantly share code, notes, and snippets.

@MayaPosch
Created October 28, 2020 15:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MayaPosch/9443988784d8e31ce2c00a900a3be7a6 to your computer and use it in GitHub Desktop.
Save MayaPosch/9443988784d8e31ce2c00a900a3be7a6 to your computer and use it in GitHub Desktop.
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