diff --git a/stm-firmware/include/stm-periph/backup-ram.h b/stm-firmware/include/stm-periph/backup-ram.h index a2d2292..3f4a470 100644 --- a/stm-firmware/include/stm-periph/backup-ram.h +++ b/stm-firmware/include/stm-periph/backup-ram.h @@ -19,11 +19,13 @@ */ #include +#include /** * @brief Init the backup ram and make it accesible + * @param use_backup_regulator Enable the Backup VBAT regulator. It will be used, when VDD is powered off */ -void backup_ram_init(void); +void backup_ram_init(bool use_backup_regulator); /** * @brief Disable access to the backup RAM. This saves power diff --git a/stm-firmware/stm-periph/backup-ram.c b/stm-firmware/stm-periph/backup-ram.c index d2bca10..62ad992 100644 --- a/stm-firmware/stm-periph/backup-ram.c +++ b/stm-firmware/stm-periph/backup-ram.c @@ -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));