@dagar helped me get this working, it turns out it’s quite simple
in the rCS script insert these two lines
set FMU_MODE pwm4 set AUX_MODE pwm4
after the camera part, i.e. in line 472
These calls reserve the first 4 pins in FMU ( AUX PWM) to be used as pwm and the two remaining to be used as GPIO
And then if you wanted to toggle AUX6 you would first call:
px4_arch_configgpio(GPIO_GPIO5_OUTPUT)
to configure the pin as Output (or GPIO_GPIO5_INPUT to configure as input.)
The GPIO0-GPIO5 correspond to AUX1-AUX6.
https://github.com/PX4/Firmware/blob/master/src/drivers/boards/px4fmu-v2/board_config.h#L178
You would place this code in the constructor of a class you’re using (for example) as you only want to configure once.
And then call this where needed in your code
px4_arch_gpiowrite(GPIO_GPIO5_OUTPUT,value);
or for an input
px4_arch_gpioread(GPIO_GPIO5_INPUT);
Hope this helps