From f38b1bf160c93c4a306f34be307e425c2ccc8fc3 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 17 Aug 2015 12:01:13 +1000 Subject: [PATCH] px4fmu: allow for GPIO_SET_OUTPUT with initial value this is needed to prevent inadvertent camera trigger when setting up a port --- src/drivers/px4fmu/fmu.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/drivers/px4fmu/fmu.cpp b/src/drivers/px4fmu/fmu.cpp index d74765f6a1..bff4d5e9c4 100644 --- a/src/drivers/px4fmu/fmu.cpp +++ b/src/drivers/px4fmu/fmu.cpp @@ -2502,7 +2502,9 @@ PX4FMU::gpio_set_function(uint32_t gpios, int function) gpios |= 3; /* flip the buffer to output mode if required */ - if (GPIO_SET_OUTPUT == function) { + if (GPIO_SET_OUTPUT == function || + GPIO_SET_OUTPUT_LOW == function || + GPIO_SET_OUTPUT_HIGH == function) { stm32_gpiowrite(GPIO_GPIO_DIR, 1); } } @@ -2521,6 +2523,14 @@ PX4FMU::gpio_set_function(uint32_t gpios, int function) stm32_configgpio(_gpio_tab[i].output); break; + case GPIO_SET_OUTPUT_LOW: + stm32_configgpio((_gpio_tab[i].output & ~(GPIO_OUTPUT_SET)) | GPIO_OUTPUT_CLEAR); + break; + + case GPIO_SET_OUTPUT_HIGH: + stm32_configgpio((_gpio_tab[i].output & ~(GPIO_OUTPUT_CLEAR)) | GPIO_OUTPUT_SET); + break; + case GPIO_SET_ALT_1: if (_gpio_tab[i].alt != 0) { stm32_configgpio(_gpio_tab[i].alt); @@ -2716,6 +2726,8 @@ PX4FMU::gpio_ioctl(struct file *filp, int cmd, unsigned long arg) break; case GPIO_SET_OUTPUT: + case GPIO_SET_OUTPUT_LOW: + case GPIO_SET_OUTPUT_HIGH: case GPIO_SET_INPUT: case GPIO_SET_ALT_1: gpio_set_function(arg, cmd);