px4fmu-v2:Insure the discharge of the pins PWM pins on rest.

On resets invoked from system (not boot) insure we establish a low
  output state (discharge the pins) on PWM pins before they become
  inputs.
This commit is contained in:
David Sidrane 2017-07-18 16:59:07 -10:00 committed by Lorenz Meier
parent 4832ad3191
commit 5fd8ef1055
2 changed files with 49 additions and 9 deletions

View File

@ -295,6 +295,8 @@
/* This board provides a DMA pool and APIs */
#define BOARD_DMA_ALLOC_POOL_SIZE 5120
#define BOARD_HAS_ON_RESET 1
__BEGIN_DECLS
/****************************************************************************************************

View File

@ -152,6 +152,48 @@ __EXPORT void board_peripheral_reset(int ms)
stm32_gpiowrite(GPIO_VDD_5V_PERIPH_EN, 0);
}
/************************************************************************************
* Name: board_on_reset
*
* Description:
* Optionally provided function called on entry to board_system_reset
* It should perform any house keeping prior to the rest.
*
* status - 1 if resetting to boot loader
* 0 if just resetting
*
************************************************************************************/
__EXPORT void board_on_reset(int status)
{
UNUSED(status);
/* configure the GPIO pins to outputs and keep them low */
stm32_configgpio(GPIO_GPIO0_OUTPUT);
stm32_configgpio(GPIO_GPIO1_OUTPUT);
stm32_configgpio(GPIO_GPIO2_OUTPUT);
stm32_configgpio(GPIO_GPIO3_OUTPUT);
stm32_configgpio(GPIO_GPIO4_OUTPUT);
stm32_configgpio(GPIO_GPIO5_OUTPUT);
/* On resets invoked from system (not boot) insure we establish a low
* output state (discharge the pins) on PWM pins before they become inputs.
*
* We also delay the onset of the that 3.1 Ms pulse as boot. This has
* triggered some ESC to spin. By adding this delay here the reset
* is pushed out > 400 ms. So the ESC PWM input can not mistake
* the 3.1 Ms pulse as a valid PWM command.
*
* fixme:Establish in upstream NuttX an CONFIG_IO_INIT_STATE to
* the initialize the IO lines in the clock config.
*
*/
if (status >= 0) {
up_mdelay(400);
}
}
/************************************************************************************
* Name: determin_hw_version
*
@ -282,6 +324,11 @@ __EXPORT int board_get_hw_revision()
__EXPORT void
stm32_boardinitialize(void)
{
board_on_reset(-1);
/* configure LEDs */
board_autoled_initialize();
/* configure ADC pins */
stm32_configgpio(GPIO_ADC1_IN2); /* BATT_VOLTAGE_SENS */
@ -300,19 +347,10 @@ stm32_boardinitialize(void)
stm32_configgpio(GPIO_VDD_5V_HIPOWER_OC);
stm32_configgpio(GPIO_VDD_5V_PERIPH_OC);
/* configure the GPIO pins to outputs and keep them low */
stm32_configgpio(GPIO_GPIO0_OUTPUT);
stm32_configgpio(GPIO_GPIO1_OUTPUT);
stm32_configgpio(GPIO_GPIO2_OUTPUT);
stm32_configgpio(GPIO_GPIO3_OUTPUT);
stm32_configgpio(GPIO_GPIO4_OUTPUT);
stm32_configgpio(GPIO_GPIO5_OUTPUT);
/* configure SPI interfaces */
stm32_spiinitialize();
/* configure LEDs */
board_autoled_initialize();
}
/****************************************************************************