From 04e3bbd4ce87696953a8e08cc2a33c772e74a211 Mon Sep 17 00:00:00 2001 From: Cliff Geerdes Date: Sat, 24 Oct 2015 10:43:20 -0400 Subject: [PATCH] LP-73 fix fw_osd build poke wdg in startup --- .../discoveryf4bare/firmware/pios_board.c | 25 +++++++++++++++++++ .../boards/osd/firmware/inc/pios_config.h | 2 +- .../boards/revolution/firmware/pios_board.c | 25 +++++++++++++++++++ .../boards/revonano/firmware/pios_board.c | 12 +++++++++ .../boards/revoproto/firmware/pios_board.c | 12 +++++++++ 5 files changed, 75 insertions(+), 1 deletion(-) diff --git a/flight/targets/boards/discoveryf4bare/firmware/pios_board.c b/flight/targets/boards/discoveryf4bare/firmware/pios_board.c index 1264cd96b..f3192a43f 100644 --- a/flight/targets/boards/discoveryf4bare/firmware/pios_board.c +++ b/flight/targets/boards/discoveryf4bare/firmware/pios_board.c @@ -683,6 +683,13 @@ void PIOS_Board_Init(void) PIOS_Assert(0); } PIOS_DELAY_WaitmS(50); // this was after the other PIOS_I2C_Init(), so I copied it here too +#ifdef PIOS_INCLUDE_WDG + // give HMC5x83 on I2C some extra time to allow for reset, etc. if needed + // this is not in a loop, so it is safe + // leave this here even if PIOS_INCLUDE_HMC5X83 is undefined + // to avoid making something else fail when HMC5X83 is removed + PIOS_WDG_Clear(); +#endif /* PIOS_INCLUDE_WDG */ #if defined(PIOS_INCLUDE_HMC5X83) // get auxmag type AuxMagSettingsTypeOptions option; @@ -692,6 +699,11 @@ void PIOS_Board_Init(void) if (option == AUXMAGSETTINGS_TYPE_FLEXI) { // attach the 5x83 mag to the previously inited I2C2 external_mag = PIOS_HMC5x83_Init(&pios_hmc5x83_external_cfg, pios_i2c_flexiport_adapter_id, 0); +#ifdef PIOS_INCLUDE_WDG + // give HMC5x83 on I2C some extra time to allow for reset, etc. if needed + // this is not in a loop, so it is safe + PIOS_WDG_Clear(); +#endif /* PIOS_INCLUDE_WDG */ // add this sensor to the sensor task's list // be careful that you don't register a slow, unimportant sensor after registering the fastest sensor // and before registering some other fast and important sensor @@ -935,9 +947,22 @@ void PIOS_Board_Init(void) PIOS_ADC_Init(&pios_adc_cfg); #endif +#ifdef PIOS_INCLUDE_WDG + // give HMC5x83 on I2C some extra time to allow for reset, etc. if needed + // this is not in a loop, so it is safe + // leave this here even if PIOS_INCLUDE_HMC5X83 is undefined + // to avoid making something else fail when HMC5X83 is removed + PIOS_WDG_Clear(); +#endif /* PIOS_INCLUDE_WDG */ + #if defined(PIOS_INCLUDE_HMC5X83) // attach the 5x83 mag to the previously inited I2C1 onboard_mag = PIOS_HMC5x83_Init(&pios_hmc5x83_internal_cfg, pios_i2c_mag_pressure_adapter_id, 0); +#ifdef PIOS_INCLUDE_WDG + // give HMC5x83 on I2C some extra time to allow for reset, etc. if needed + // this is not in a loop, so it is safe + PIOS_WDG_Clear(); +#endif /* PIOS_INCLUDE_WDG */ // add this sensor to the sensor task's list PIOS_HMC5x83_Register(onboard_mag, PIOS_SENSORS_TYPE_3AXIS_MAG); #endif diff --git a/flight/targets/boards/osd/firmware/inc/pios_config.h b/flight/targets/boards/osd/firmware/inc/pios_config.h index 98f7c22c0..a835f6a99 100644 --- a/flight/targets/boards/osd/firmware/inc/pios_config.h +++ b/flight/targets/boards/osd/firmware/inc/pios_config.h @@ -81,7 +81,7 @@ /* #define PIOS_INCLUDE_MPU6000 */ /* #define PIOS_MPU6000_ACCEL */ /* #define PIOS_INCLUDE_HMC5843 */ -#define PIOS_INCLUDE_HMC5X83 +/* #define PIOS_INCLUDE_HMC5X83 */ /* #define PIOS_HMC5X83_HAS_GPIOS */ #define PIOS_INCLUDE_BMP085 /* #define PIOS_INCLUDE_MS5611 */ diff --git a/flight/targets/boards/revolution/firmware/pios_board.c b/flight/targets/boards/revolution/firmware/pios_board.c index e63121dc5..bc87a3a70 100644 --- a/flight/targets/boards/revolution/firmware/pios_board.c +++ b/flight/targets/boards/revolution/firmware/pios_board.c @@ -494,6 +494,13 @@ void PIOS_Board_Init(void) PIOS_Assert(0); } PIOS_DELAY_WaitmS(50); // this was after the other PIOS_I2C_Init(), so I copied it here too +#ifdef PIOS_INCLUDE_WDG + // give HMC5x83 on I2C some extra time to allow for reset, etc. if needed + // this is not in a loop, so it is safe + // leave this here even if PIOS_INCLUDE_HMC5X83 is undefined + // to avoid making something else fail when HMC5X83 is removed + PIOS_WDG_Clear(); +#endif /* PIOS_INCLUDE_WDG */ #if defined(PIOS_INCLUDE_HMC5X83) // get auxmag type AuxMagSettingsTypeOptions option; @@ -503,6 +510,11 @@ void PIOS_Board_Init(void) if (option == AUXMAGSETTINGS_TYPE_FLEXI) { // attach the 5x83 mag to the previously inited I2C2 external_mag = PIOS_HMC5x83_Init(&pios_hmc5x83_external_cfg, pios_i2c_flexiport_adapter_id, 0); +#ifdef PIOS_INCLUDE_WDG + // give HMC5x83 on I2C some extra time to allow for reset, etc. if needed + // this is not in a loop, so it is safe + PIOS_WDG_Clear(); +#endif /* PIOS_INCLUDE_WDG */ // add this sensor to the sensor task's list // be careful that you don't register a slow, unimportant sensor after registering the fastest sensor // and before registering some other fast and important sensor @@ -982,9 +994,22 @@ void PIOS_Board_Init(void) PIOS_MPU6000_Register(); #endif +#ifdef PIOS_INCLUDE_WDG + // give HMC5x83 on I2C some extra time to allow for reset, etc. if needed + // this is not in a loop, so it is safe + // leave this here even if PIOS_INCLUDE_HMC5X83 is undefined + // to avoid making something else fail when HMC5X83 is removed + PIOS_WDG_Clear(); +#endif /* PIOS_INCLUDE_WDG */ + #if defined(PIOS_INCLUDE_HMC5X83) // attach the 5x83 mag to the previously inited I2C1 onboard_mag = PIOS_HMC5x83_Init(&pios_hmc5x83_internal_cfg, pios_i2c_mag_pressure_adapter_id, 0); +#ifdef PIOS_INCLUDE_WDG + // give HMC5x83 on I2C some extra time to allow for reset, etc. if needed + // this is not in a loop, so it is safe + PIOS_WDG_Clear(); +#endif /* PIOS_INCLUDE_WDG */ // add this sensor to the sensor task's list PIOS_HMC5x83_Register(onboard_mag, PIOS_SENSORS_TYPE_3AXIS_MAG); #endif diff --git a/flight/targets/boards/revonano/firmware/pios_board.c b/flight/targets/boards/revonano/firmware/pios_board.c index 8f7d25193..2718c709d 100644 --- a/flight/targets/boards/revonano/firmware/pios_board.c +++ b/flight/targets/boards/revonano/firmware/pios_board.c @@ -640,6 +640,13 @@ void PIOS_Board_Init(void) PIOS_Assert(0); } PIOS_DELAY_WaitmS(50); // this was after the other PIOS_I2C_Init(), so I copied it here too +#ifdef PIOS_INCLUDE_WDG + // give HMC5x83 on I2C some extra time to allow for reset, etc. if needed + // this is not in a loop, so it is safe + // leave this here even if PIOS_INCLUDE_HMC5X83 is undefined + // to avoid making something else fail when HMC5X83 is removed + PIOS_WDG_Clear(); +#endif /* PIOS_INCLUDE_WDG */ #if defined(PIOS_INCLUDE_HMC5X83) // get auxmag type AuxMagSettingsTypeOptions option; @@ -649,6 +656,11 @@ void PIOS_Board_Init(void) if (option == AUXMAGSETTINGS_TYPE_FLEXI) { // attach the 5x83 mag to the previously inited I2C2 external_mag = PIOS_HMC5x83_Init(&pios_hmc5x83_external_cfg, pios_i2c_flexiport_adapter_id, 0); +#ifdef PIOS_INCLUDE_WDG + // give HMC5x83 on I2C some extra time to allow for reset, etc. if needed + // this is not in a loop, so it is safe + PIOS_WDG_Clear(); +#endif /* PIOS_INCLUDE_WDG */ // add this sensor to the sensor task's list // be careful that you don't register a slow, unimportant sensor after registering the fastest sensor // and before registering some other fast and important sensor diff --git a/flight/targets/boards/revoproto/firmware/pios_board.c b/flight/targets/boards/revoproto/firmware/pios_board.c index 297cacefc..69b60f0c2 100644 --- a/flight/targets/boards/revoproto/firmware/pios_board.c +++ b/flight/targets/boards/revoproto/firmware/pios_board.c @@ -777,6 +777,13 @@ void PIOS_Board_Init(void) PIOS_Assert(0); } PIOS_DELAY_WaitmS(50); // this was after the other PIOS_I2C_Init(), so I copied it here too +#ifdef PIOS_INCLUDE_WDG + // give HMC5x83 on I2C some extra time to allow for reset, etc. if needed + // this is not in a loop, so it is safe + // leave this here even if PIOS_INCLUDE_HMC5X83 is undefined + // to avoid making something else fail when HMC5X83 is removed + PIOS_WDG_Clear(); +#endif /* PIOS_INCLUDE_WDG */ #if defined(PIOS_INCLUDE_HMC5X83) // get auxmag type AuxMagSettingsTypeOptions option; @@ -786,6 +793,11 @@ void PIOS_Board_Init(void) if (option == AUXMAGSETTINGS_TYPE_FLEXI) { // attach the 5x83 mag to the previously inited I2C2 external_mag = PIOS_HMC5x83_Init(&pios_hmc5x83_external_cfg, pios_i2c_flexiport_adapter_id, 0); +#ifdef PIOS_INCLUDE_WDG + // give HMC5x83 on I2C some extra time to allow for reset, etc. if needed + // this is not in a loop, so it is safe + PIOS_WDG_Clear(); +#endif /* PIOS_INCLUDE_WDG */ // add this sensor to the sensor task's list PIOS_HMC5x83_Register(external_mag, PIOS_SENSORS_TYPE_3AXIS_AUXMAG); // mag alarm is cleared later, so use I2C