1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

Ported pios_iap.c to F4

restored failed boot count check on pios_board.c for revo
This commit is contained in:
Alessio Morale 2012-02-11 13:49:32 +01:00
parent 665801662d
commit 22b211167c
3 changed files with 18 additions and 18 deletions

View File

@ -68,19 +68,17 @@
*/
void PIOS_IAP_Init( void )
{
#if 0
/* Enable CRC clock */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_CRC, ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_CRC, ENABLE);
/* Enable PWR and BKP clock */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_AHB1Periph_BKPSRAM, ENABLE);
/* Enable write access to Backup domain */
PWR_BackupAccessCmd(ENABLE);
/* Clear Tamper pin Event(TE) pending flag */
RTC_ClearFlag();
#endif
RTC_ClearFlag(RTC_FLAG_TAMP1F);
}
/*!
@ -93,8 +91,7 @@ void PIOS_IAP_Init( void )
*/
uint32_t PIOS_IAP_CheckRequest( void )
{
#if 0
uint32_t retval = FALSE;
uint32_t retval = false;
uint16_t reg1;
uint16_t reg2;
@ -103,13 +100,11 @@ uint32_t PIOS_IAP_CheckRequest( void )
if( reg1 == IAP_MAGIC_WORD_1 && reg2 == IAP_MAGIC_WORD_2 ) {
// We have a match.
retval = TRUE;
retval = true;
} else {
retval = FALSE;
retval = false;
}
return retval;
#endif
return 0;
}
@ -122,24 +117,18 @@ uint32_t PIOS_IAP_CheckRequest( void )
*/
void PIOS_IAP_SetRequest1(void)
{
#if 0
RTC_WriteBackupRegister( MAGIC_REG_1, IAP_MAGIC_WORD_1);
#endif
}
void PIOS_IAP_SetRequest2(void)
{
#if 0
RTC_WriteBackupRegister( MAGIC_REG_2, IAP_MAGIC_WORD_2);
#endif
}
void PIOS_IAP_ClearRequest(void)
{
#if 0
RTC_WriteBackupRegister( MAGIC_REG_1, 0);
RTC_WriteBackupRegister( MAGIC_REG_2, 0);
#endif
}
uint16_t PIOS_IAP_ReadBootCount(void)

View File

@ -50,6 +50,7 @@
/* STM32 Std Perf Lib */
#if defined(STM32F4XX)
# include <stm32f4xx.h>
# include <stm32f4xx_rcc.h>
#elif defined(STM32F2XX)
#include <stm32f2xx.h>
#include <stm32f2xx_syscfg.h>

View File

@ -305,7 +305,17 @@ void PIOS_Board_Init(void) {
PIOS_TIM_InitClock(&tim_11_cfg);
/* IAP System Setup */
//PIOS_IAP_Init();
PIOS_IAP_Init();
uint16_t boot_count = PIOS_IAP_ReadBootCount();
if (boot_count < 3) {
PIOS_IAP_WriteBootCount(++boot_count);
AlarmsClear(SYSTEMALARMS_ALARM_BOOTFAULT);
} else {
/* Too many failed boot attempts, force hwsettings to defaults */
HwSettingsSetDefaults(HwSettingsHandle(), 0);
AlarmsSet(SYSTEMALARMS_ALARM_BOOTFAULT, SYSTEMALARMS_ALARM_CRITICAL);
}
#if defined(PIOS_INCLUDE_COM)
#if defined(PIOS_INCLUDE_GPS)