Browse Source

px4fmu: allow for GPIO_SET_OUTPUT with initial value

this is needed to prevent inadvertent camera trigger when setting up a
port
sbg
Andrew Tridgell 10 years ago committed by Lorenz Meier
parent
commit
f38b1bf160
  1. 14
      src/drivers/px4fmu/fmu.cpp

14
src/drivers/px4fmu/fmu.cpp

@ -2502,7 +2502,9 @@ PX4FMU::gpio_set_function(uint32_t gpios, int function)
gpios |= 3; gpios |= 3;
/* flip the buffer to output mode if required */ /* 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); 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); stm32_configgpio(_gpio_tab[i].output);
break; 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: case GPIO_SET_ALT_1:
if (_gpio_tab[i].alt != 0) { if (_gpio_tab[i].alt != 0) {
stm32_configgpio(_gpio_tab[i].alt); stm32_configgpio(_gpio_tab[i].alt);
@ -2716,6 +2726,8 @@ PX4FMU::gpio_ioctl(struct file *filp, int cmd, unsigned long arg)
break; break;
case GPIO_SET_OUTPUT: case GPIO_SET_OUTPUT:
case GPIO_SET_OUTPUT_LOW:
case GPIO_SET_OUTPUT_HIGH:
case GPIO_SET_INPUT: case GPIO_SET_INPUT:
case GPIO_SET_ALT_1: case GPIO_SET_ALT_1:
gpio_set_function(arg, cmd); gpio_set_function(arg, cmd);

Loading…
Cancel
Save