Issue #18: Backup RAM: Make use of backup regulator optional
This commit is contained in:
parent
d3c4e1bffc
commit
a12648ff7a
@ -19,11 +19,13 @@
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/**
|
||||
* @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
|
||||
|
@ -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;
|
||||
|
||||
if (use_backup_regulator) {
|
||||
/* Enable the backup regulator */
|
||||
PWR->CSR |= PWR_CSR_BRE;
|
||||
|
||||
/* 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));
|
||||
|
Loading…
Reference in New Issue
Block a user