Skip to content

Commit 10a4ddb

Browse files
ABOSTMfpistm
authored andcommitted
core(C0): Enable/disable Backup Domain write protection depending on series
C0 doesn't have ability to enable/disable Backup Domain write protection Signed-off-by: Alexandre Bourdiol <[email protected]>
1 parent 17ce259 commit 10a4ddb

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

cores/arduino/stm32/backup.h

+8-3
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,15 @@ extern "C" {
5151
#endif /* HID_MAGIC_NUMBER_BKP_VALUE */
5252
#endif /* BL_HID */
5353

54+
#if defined(HAL_PWR_MODULE_ENABLED) && \
55+
(defined(PWR_CR_DBP) || defined(PWR_CR1_DBP) || defined(PWR_DBPR_DBP))
56+
#define PWR_ENABLE_BACKUP_ACCESS_EXIST
57+
#endif
58+
5459
/* Exported functions ------------------------------------------------------- */
5560
static inline void resetBackupDomain(void)
5661
{
57-
#ifdef HAL_PWR_MODULE_ENABLED
62+
#if defined(PWR_ENABLE_BACKUP_ACCESS_EXIST)
5863
/* Enable access to the RTC registers */
5964
HAL_PWR_EnableBkUpAccess();
6065
/**
@@ -69,7 +74,7 @@ static inline void resetBackupDomain(void)
6974

7075
static inline void enableBackupDomain(void)
7176
{
72-
#ifdef HAL_PWR_MODULE_ENABLED
77+
#if defined(PWR_ENABLE_BACKUP_ACCESS_EXIST)
7378
/* Allow access to Backup domain */
7479
HAL_PWR_EnableBkUpAccess();
7580
#endif
@@ -85,7 +90,7 @@ static inline void enableBackupDomain(void)
8590

8691
static inline void disableBackupDomain(void)
8792
{
88-
#ifdef HAL_PWR_MODULE_ENABLED
93+
#if defined(PWR_ENABLE_BACKUP_ACCESS_EXIST)
8994
/* Forbid access to Backup domain */
9095
HAL_PWR_DisableBkUpAccess();
9196
#endif

0 commit comments

Comments
 (0)