diff --git a/libraries/AP_HAL_ChibiOS/HAL_ChibiOS_Class.cpp b/libraries/AP_HAL_ChibiOS/HAL_ChibiOS_Class.cpp index 74969a0750..b2885bfe26 100644 --- a/libraries/AP_HAL_ChibiOS/HAL_ChibiOS_Class.cpp +++ b/libraries/AP_HAL_ChibiOS/HAL_ChibiOS_Class.cpp @@ -25,6 +25,7 @@ #include "shared_dma.h" #include "sdcard.h" #include "hwdef/common/usbcfg.h" +#include "hwdef/common/stm32_util.h" #include @@ -176,6 +177,8 @@ static THD_FUNCTION(main_loop,arg) schedulerInstance.hal_initialized(); + peripheral_power_enable(); + g_callbacks->setup(); hal.scheduler->system_initialized(); diff --git a/libraries/AP_HAL_ChibiOS/hwdef/common/stm32_util.c b/libraries/AP_HAL_ChibiOS/hwdef/common/stm32_util.c index 1ba5c1ef07..57e2645281 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/common/stm32_util.c +++ b/libraries/AP_HAL_ChibiOS/hwdef/common/stm32_util.c @@ -251,3 +251,17 @@ void set_fast_reboot(enum rtc_boot_magic v) { set_rtc_backup0(v); } + +/* + enable peripheral power if needed This is done late to prevent + problems with RTS causing SiK radios to stay in the bootloader +*/ +void peripheral_power_enable(void) +{ +#ifdef HAL_GPIO_PIN_nVDD_5V_PERIPH_EN + palWriteLine(HAL_GPIO_PIN_nVDD_5V_PERIPH_EN, 0); +#endif +#ifdef HAL_GPIO_PIN_nVDD_5V_HIPOWER_EN + palWriteLine(HAL_GPIO_PIN_nVDD_5V_HIPOWER_EN, 0); +#endif +} diff --git a/libraries/AP_HAL_ChibiOS/hwdef/common/stm32_util.h b/libraries/AP_HAL_ChibiOS/hwdef/common/stm32_util.h index 2caa4c4d4d..d9c4c4be29 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/common/stm32_util.h +++ b/libraries/AP_HAL_ChibiOS/hwdef/common/stm32_util.h @@ -64,6 +64,9 @@ enum rtc_boot_magic check_fast_reboot(void); // set RTC register for a fast reboot void set_fast_reboot(enum rtc_boot_magic v); + +// enable peripheral power if needed +void peripheral_power_enable(void); #ifdef __cplusplus } diff --git a/libraries/AP_HAL_ChibiOS/hwdef/fmuv5/hwdef.dat b/libraries/AP_HAL_ChibiOS/hwdef/fmuv5/hwdef.dat index a28c246624..d3433e708e 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/fmuv5/hwdef.dat +++ b/libraries/AP_HAL_ChibiOS/hwdef/fmuv5/hwdef.dat @@ -94,8 +94,13 @@ I2C_ORDER I2C3 I2C1 I2C2 I2C4 # enable pins PE3 VDD_3V3_SENSORS_EN OUTPUT HIGH -PF12 nVDD_5V_HIPOWER_EN OUTPUT LOW -PG4 nVDD_5V_PERIPH_EN OUTPUT LOW + +# start peripheral power off, then enable after init +# this prevents a problem with radios that use RTS for +# bootloader hold +PF12 nVDD_5V_HIPOWER_EN OUTPUT HIGH +PG4 nVDD_5V_PERIPH_EN OUTPUT HIGH + PG5 VDD_5V_RC_EN OUTPUT HIGH PG6 VDD_5V_WIFI_EN OUTPUT HIGH PG7 VDD_3V3_SD_CARD_EN OUTPUT HIGH