Browse Source

HAL_ChibiOS: fixed peripheral power-up on fmuv5

we need to do the powerup before we initialise the UARTs
master
Andrew Tridgell 7 years ago
parent
commit
0201893f7c
  1. 6
      libraries/AP_HAL_ChibiOS/HAL_ChibiOS_Class.cpp
  2. 12
      libraries/AP_HAL_ChibiOS/hwdef/common/stm32_util.c

6
libraries/AP_HAL_ChibiOS/HAL_ChibiOS_Class.cpp

@ -153,7 +153,9 @@ static THD_FUNCTION(main_loop,arg) @@ -153,7 +153,9 @@ static THD_FUNCTION(main_loop,arg)
#endif
ChibiOS::Shared_DMA::init();
peripheral_power_enable();
hal.uartA->begin(115200);
#ifdef HAL_SPI_CHECK_CLOCK_FREQ
@ -177,8 +179,6 @@ static THD_FUNCTION(main_loop,arg) @@ -177,8 +179,6 @@ static THD_FUNCTION(main_loop,arg)
schedulerInstance.hal_initialized();
peripheral_power_enable();
g_callbacks->setup();
hal.scheduler->system_initialized();

12
libraries/AP_HAL_ChibiOS/hwdef/common/stm32_util.c

@ -254,14 +254,24 @@ void set_fast_reboot(enum rtc_boot_magic v) @@ -254,14 +254,24 @@ void set_fast_reboot(enum rtc_boot_magic v)
/*
enable peripheral power if needed This is done late to prevent
problems with RTS causing SiK radios to stay in the bootloader
problems with CTS causing SiK radios to stay in the bootloader. A
SiK radio will stay in the bootloader if CTS is held to GND on boot
*/
void peripheral_power_enable(void)
{
#if defined(HAL_GPIO_PIN_nVDD_5V_PERIPH_EN) || defined(HAL_GPIO_PIN_nVDD_5V_HIPOWER_EN)
// we don't know what state the bootloader had the CTS pin in, so
// wait here with it pulled up from the PAL table for enough time
// for the radio to be definately powered down
for (uint8_t i=0; i<100; i++) {
// use a loop as this may be a 16 bit timer
chThdSleep(MS2ST(1));
}
#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
#endif
}

Loading…
Cancel
Save