diff options
author | Bruno Randolf <br1@einfach.org> | 2018-01-05 16:36:05 +0300 |
---|---|---|
committer | Karl Palsson <karlp@tweak.net.au> | 2019-06-03 01:18:05 +0300 |
commit | 2c1823f7bbae19f9322770e855555da08f8bcea8 (patch) | |
tree | 198f3fc16b6feba8e1787803fd2afc71cba96491 | |
parent | a1f58ea8ae4ab38a640634c4fe47bd650c755f94 (diff) |
stm32:l4: pwr: Add en/disable_backup_domain_write_protect()
-rw-r--r-- | include/libopencm3/stm32/l4/pwr.h | 2 | ||||
-rw-r--r-- | lib/stm32/l4/pwr.c | 20 |
2 files changed, 22 insertions, 0 deletions
diff --git a/include/libopencm3/stm32/l4/pwr.h b/include/libopencm3/stm32/l4/pwr.h index f4d2b911..04919327 100644 --- a/include/libopencm3/stm32/l4/pwr.h +++ b/include/libopencm3/stm32/l4/pwr.h @@ -170,6 +170,8 @@ enum pwr_vos_scale { BEGIN_DECLS void pwr_set_vos_scale(enum pwr_vos_scale scale); +void pwr_disable_backup_domain_write_protect(void); +void pwr_enable_backup_domain_write_protect(void); END_DECLS diff --git a/lib/stm32/l4/pwr.c b/lib/stm32/l4/pwr.c index e6f71296..e6bd877a 100644 --- a/lib/stm32/l4/pwr.c +++ b/lib/stm32/l4/pwr.c @@ -52,4 +52,24 @@ void pwr_set_vos_scale(enum pwr_vos_scale scale) } PWR_CR1 = reg32; } + +/** Disable Backup Domain Write Protection + * + * This allows backup domain registers to be changed. These registers are write + * protected after a reset. + */ +void pwr_disable_backup_domain_write_protect(void) +{ + PWR_CR1 |= PWR_CR1_DBP; +} + +/** Re-enable Backup Domain Write Protection + * + * This protects backup domain registers from inadvertent change. + */ +void pwr_enable_backup_domain_write_protect(void) +{ + PWR_CR1 &= ~PWR_CR1_DBP; +} + /**@}*/ |