Issue #18: Backup RAM: Make use of backup regulator optional
This commit is contained in:
@@ -34,18 +34,20 @@
|
||||
#error "Backup RAM size ahs to be a power of two!"
|
||||
#endif
|
||||
|
||||
void backup_ram_init(void)
|
||||
void backup_ram_init(bool use_backup_regulator)
|
||||
{
|
||||
rcc_manager_enable_clock(&RCC->APB1ENR, BITMASK_TO_BITNO(RCC_APB1ENR_PWREN));
|
||||
|
||||
/* Enable access to backup RAM register set */
|
||||
PWR->CR |= PWR_CR_DBP;
|
||||
|
||||
/* Enable the backup regulator */
|
||||
PWR->CSR |= PWR_CSR_BRE;
|
||||
if (use_backup_regulator) {
|
||||
/* Enable the backup regulator */
|
||||
PWR->CSR |= PWR_CSR_BRE;
|
||||
|
||||
/* Wait until regulator is ready */
|
||||
while (!(PWR->CSR & PWR_CSR_BRR));
|
||||
/* Wait until regulator is ready */
|
||||
while (!(PWR->CSR & PWR_CSR_BRR));
|
||||
}
|
||||
|
||||
/* Enable clock for backup ram interface */
|
||||
rcc_manager_enable_clock(&RCC->AHB1ENR, BITMASK_TO_BITNO(RCC_AHB1ENR_BKPSRAMEN));
|
||||
|
Reference in New Issue
Block a user