diff --git a/src/drivers/boards/auav-x21/board_config.h b/src/drivers/boards/auav-x21/board_config.h index 1b48090704f..1cd1878f5da 100644 --- a/src/drivers/boards/auav-x21/board_config.h +++ b/src/drivers/boards/auav-x21/board_config.h @@ -247,6 +247,10 @@ /* This board provides a DMA pool and APIs */ #define BOARD_DMA_ALLOC_POOL_SIZE 5120 +/* This board provides the board_on_reset interface */ + +#define BOARD_HAS_ON_RESET 1 + #define BOARD_HAS_STATIC_MANIFEST 1 __BEGIN_DECLS diff --git a/src/drivers/boards/auav-x21/init.c b/src/drivers/boards/auav-x21/init.c index 3ae6834da0a..c00e8cb0a10 100644 --- a/src/drivers/boards/auav-x21/init.c +++ b/src/drivers/boards/auav-x21/init.c @@ -121,6 +121,37 @@ __END_DECLS /**************************************************************************** * Public Functions ****************************************************************************/ +/************************************************************************************ + * 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) +{ + // 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. + */ + + if (status >= 0) { + up_mdelay(400); + } +} + /************************************************************************************ * Name: board_peripheral_reset * @@ -156,6 +187,10 @@ __EXPORT void board_peripheral_reset(int ms) __EXPORT void stm32_boardinitialize(void) { + // Reset all PWM to Low outputs. + + board_on_reset(-1); + /* configure LEDs */ board_autoled_initialize(); @@ -175,14 +210,6 @@ stm32_boardinitialize(void) px4_arch_configgpio(GPIO_VDD_BRICK_VALID); px4_arch_configgpio(GPIO_VDD_5V_PERIPH_OC); - /* configure the GPIO pins to outputs and keep them low */ - px4_arch_configgpio(GPIO_GPIO0_OUTPUT); - px4_arch_configgpio(GPIO_GPIO1_OUTPUT); - px4_arch_configgpio(GPIO_GPIO2_OUTPUT); - px4_arch_configgpio(GPIO_GPIO3_OUTPUT); - px4_arch_configgpio(GPIO_GPIO4_OUTPUT); - px4_arch_configgpio(GPIO_GPIO5_OUTPUT); - /* configure SPI interfaces */ stm32_spiinitialize();