Thinking about it after having done the checkin, I'm not entirely
happy with the naming of CYGHWR_HAL_STM32_BD_UNPROTECT() and
hal_stm32_bd_unprotect(). The un... parts could be a little confusing
and the sense of things seems wrong. I would be happier with
CYGHWR_HAL_STM32_BD_PROTECT() and hal_stm32_bd_protect() with a
matching inversion of the meaning of the argument. It is probably not
worth worrying about immediately, but is something that might need to
change in the future.
I see your point, I'll change that tomorrow.
Here is the patch to change CYGHWR_HAL_STM32_BD_UNPROTECT() to
CYGHWR_HAL_STM32_BD_PROTECT(). I guess this is better done early than later.
Simon
diff -r 7c9d07ab8de4 packages/devs/wallclock/cortexm/stm32/current/ChangeLog
--- a/packages/devs/wallclock/cortexm/stm32/current/ChangeLog Mon Nov 10 16:12:16 2008 +0100
+++ b/packages/devs/wallclock/cortexm/stm32/current/ChangeLog Wed Nov 12 08:34:31 2008 +0100
@@ -1,3 +1,8 @@
+2008-11-12 Simon Kallweit <[EMAIL PROTECTED]>
+
+ * src/stm32_wallclock.cxx: Using new CYGHWR_HAL_STM32_BD_PROTECT
+ macro.
+
2008-11-05 Simon Kallweit <[EMAIL PROTECTED]>
* cdl/wallclock_stm32.cdl:
diff -r 7c9d07ab8de4 packages/devs/wallclock/cortexm/stm32/current/src/stm32_wallclock.cxx
--- a/packages/devs/wallclock/cortexm/stm32/current/src/stm32_wallclock.cxx Mon Nov 10 16:12:16 2008 +0100
+++ b/packages/devs/wallclock/cortexm/stm32/current/src/stm32_wallclock.cxx Wed Nov 12 08:34:31 2008 +0100
@@ -138,7 +138,7 @@
}
// Disable backup domain protection
- CYGHWR_HAL_STM32_BD_UNPROTECT(1);
+ CYGHWR_HAL_STM32_BD_PROTECT(0);
#if defined(CYGHWR_DEVS_WALLCLOCK_STM32_RTC_SOURCE_LSI)
// Start up LSI clock
@@ -197,7 +197,7 @@
config_mode(0);
// Restore backup domain protection
- CYGHWR_HAL_STM32_BD_UNPROTECT(0);
+ CYGHWR_HAL_STM32_BD_PROTECT(1);
}
cyg_uint32
@@ -226,7 +226,7 @@
CYG_ADDRESS rtc = CYGHWR_HAL_STM32_RTC;
// Disable backup domain protection
- CYGHWR_HAL_STM32_BD_UNPROTECT(1);
+ CYGHWR_HAL_STM32_BD_PROTECT(0);
// Enter configuration mode
config_mode(1);
@@ -239,6 +239,6 @@
config_mode(0);
// Restore backup domain protection
- CYGHWR_HAL_STM32_BD_UNPROTECT(0);
+ CYGHWR_HAL_STM32_BD_PROTECT(1);
}
#endif
diff -r 7c9d07ab8de4 packages/hal/cortexm/stm32/var/current/ChangeLog
--- a/packages/hal/cortexm/stm32/var/current/ChangeLog Mon Nov 10 16:12:16 2008 +0100
+++ b/packages/hal/cortexm/stm32/var/current/ChangeLog Wed Nov 12 08:34:31 2008 +0100
@@ -1,3 +1,10 @@
+2008-11-12 Simon Kallweit <[EMAIL PROTECTED]>
+
+ * include/var_io.h: Changed CYGHWR_HAL_STM32_BD_UNPROTECT to
+ CYGHWR_HAL_STM32_BD_PROTECT, inverting the argument.
+ * src/stm32_misc.c: Changed hal_stm32_bd_unprotect() to
+ hal_stm32_bd_protect(), inverting the argument.
+
2008-10-14 Nick Garnett <[EMAIL PROTECTED]>
* tests/timers.c: Add ifdefs to avoid compiling tests when not all
diff -r 7c9d07ab8de4 packages/hal/cortexm/stm32/var/current/include/var_io.h
--- a/packages/hal/cortexm/stm32/var/current/include/var_io.h Mon Nov 10 16:12:16 2008 +0100
+++ b/packages/hal/cortexm/stm32/var/current/include/var_io.h Wed Nov 12 08:34:31 2008 +0100
@@ -591,7 +591,7 @@
// Functions and macros to reset the backup domain as well as
// enable/disable backup domain write protection.
-__externC void hal_stm32_bd_unprotect( int disable );
+__externC void hal_stm32_bd_protect( int protect );
#define CYGHWR_HAL_STM32_BD_RESET() \
CYG_MACRO_START \
@@ -600,8 +600,8 @@
HAL_WRITE_UINT32(CYGHWR_HAL_STM32_RCC+CYGHWR_HAL_STM32_RCC_BDCR, 0); \
CYG_MACRO_END
-#define CYGHWR_HAL_STM32_BD_UNPROTECT(__unprotect ) \
- hal_stm32_bd_unprotect( __unprotect )
+#define CYGHWR_HAL_STM32_BD_PROTECT(__protect ) \
+ hal_stm32_bd_protect( __protect )
//=============================================================================
// FSMC
diff -r 7c9d07ab8de4 packages/hal/cortexm/stm32/var/current/src/stm32_misc.c
--- a/packages/hal/cortexm/stm32/var/current/src/stm32_misc.c Mon Nov 10 16:12:16 2008 +0100
+++ b/packages/hal/cortexm/stm32/var/current/src/stm32_misc.c Wed Nov 12 08:34:31 2008 +0100
@@ -312,16 +312,16 @@
//==========================================================================
// Backup domain
-void hal_stm32_bd_unprotect( int unprotect )
+void hal_stm32_bd_protect( int protect )
{
CYG_ADDRESS pwr = CYGHWR_HAL_STM32_PWR;
cyg_uint32 cr;
HAL_READ_UINT32( pwr+CYGHWR_HAL_STM32_PWR_CR, cr );
- if( unprotect )
+ if( protect )
+ cr &= CYGHWR_HAL_STM32_PWR_CR_DBP;
+ else
cr |= CYGHWR_HAL_STM32_PWR_CR_DBP;
- else
- cr &= CYGHWR_HAL_STM32_PWR_CR_DBP;
HAL_WRITE_UINT32( pwr+CYGHWR_HAL_STM32_PWR_CR, cr );
}