From 838370b3a4ade8279f4b322f7978e290f9e54140 Mon Sep 17 00:00:00 2001 From: James Cotton Date: Sat, 21 Jan 2012 13:21:37 -0600 Subject: [PATCH] Fix calls to backup registers on F4 --- flight/PiOS/STM32F4xx/pios_iap.c | 18 +++++++++--------- flight/PiOS/inc/pios_iap.h | 12 +++++++++--- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/flight/PiOS/STM32F4xx/pios_iap.c b/flight/PiOS/STM32F4xx/pios_iap.c index 004be298a..140732767 100644 --- a/flight/PiOS/STM32F4xx/pios_iap.c +++ b/flight/PiOS/STM32F4xx/pios_iap.c @@ -79,7 +79,7 @@ void PIOS_IAP_Init( void ) PWR_BackupAccessCmd(ENABLE); /* Clear Tamper pin Event(TE) pending flag */ - BKP_ClearFlag(); + RTC_ClearFlag(); #endif } @@ -98,8 +98,8 @@ uint32_t PIOS_IAP_CheckRequest( void ) uint16_t reg1; uint16_t reg2; - reg1 = BKP_ReadBackupRegister( MAGIC_REG_1 ); - reg2 = BKP_ReadBackupRegister( MAGIC_REG_2 ); + reg1 = RTC_ReadBackupRegister( MAGIC_REG_1 ); + reg2 = RTC_ReadBackupRegister( MAGIC_REG_2 ); if( reg1 == IAP_MAGIC_WORD_1 && reg2 == IAP_MAGIC_WORD_2 ) { // We have a match. @@ -123,31 +123,31 @@ uint32_t PIOS_IAP_CheckRequest( void ) void PIOS_IAP_SetRequest1(void) { #if 0 - BKP_WriteBackupRegister( MAGIC_REG_1, IAP_MAGIC_WORD_1); + RTC_WriteBackupRegister( MAGIC_REG_1, IAP_MAGIC_WORD_1); #endif } void PIOS_IAP_SetRequest2(void) { #if 0 - BKP_WriteBackupRegister( MAGIC_REG_2, IAP_MAGIC_WORD_2); + RTC_WriteBackupRegister( MAGIC_REG_2, IAP_MAGIC_WORD_2); #endif } void PIOS_IAP_ClearRequest(void) { #if 0 - BKP_WriteBackupRegister( MAGIC_REG_1, 0); - BKP_WriteBackupRegister( MAGIC_REG_2, 0); + RTC_WriteBackupRegister( MAGIC_REG_1, 0); + RTC_WriteBackupRegister( MAGIC_REG_2, 0); #endif } uint16_t PIOS_IAP_ReadBootCount(void) { - return BKP_ReadBackupRegister ( IAP_BOOTCOUNT ); + return RTC_ReadBackupRegister ( IAP_BOOTCOUNT ); } void PIOS_IAP_WriteBootCount (uint16_t boot_count) { - BKP_WriteBackupRegister ( IAP_BOOTCOUNT, boot_count ); + RTC_WriteBackupRegister ( IAP_BOOTCOUNT, boot_count ); } diff --git a/flight/PiOS/inc/pios_iap.h b/flight/PiOS/inc/pios_iap.h index 1f67d651f..d9b41170b 100644 --- a/flight/PiOS/inc/pios_iap.h +++ b/flight/PiOS/inc/pios_iap.h @@ -17,9 +17,15 @@ /***************************************************************************************** * Public Definitions/Macros ****************************************************************************************/ -#define MAGIC_REG_1 BKP_DR1 -#define MAGIC_REG_2 BKP_DR2 -#define IAP_BOOTCOUNT BKP_DR3 +#if defined(STM32F4XX) +#define MAGIC_REG_1 RTC_BKP_DR1 +#define MAGIC_REG_2 RTC_BKP_DR2 +#define IAP_BOOTCOUNT RTC_BKP_DR3 +#else +#define MAGIC_REG_1 BKP_DR1 +#define MAGIC_REG_2 BKP_DR2 +#define IAP_BOOTCOUNT BKP_DR3 +#endif /**************************************************************************************** * Public Functions