Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/thirdpin/libopencm3.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Randolf <br1@einfach.org>2018-01-05 16:36:05 +0300
committerKarl Palsson <karlp@tweak.net.au>2019-06-03 01:18:05 +0300
commit2c1823f7bbae19f9322770e855555da08f8bcea8 (patch)
tree198f3fc16b6feba8e1787803fd2afc71cba96491
parenta1f58ea8ae4ab38a640634c4fe47bd650c755f94 (diff)
stm32:l4: pwr: Add en/disable_backup_domain_write_protect()
-rw-r--r--include/libopencm3/stm32/l4/pwr.h2
-rw-r--r--lib/stm32/l4/pwr.c20
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;
+}
+
/**@}*/