Skip to content

Commit

Permalink
camera trigger: add support for fmu pins 7 and 8
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielePettenuzzo committed Nov 15, 2018
1 parent 90cee2d commit dd2edd9
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 10 deletions.
18 changes: 12 additions & 6 deletions ROMFS/px4fmu_common/init.d/rcS
Original file line number Diff line number Diff line change
Expand Up @@ -462,15 +462,21 @@ else

if param greater TRIG_MODE 0
then
# We ONLY support trigger on pins 5 and 6 when simultanously using AUX for actuator output.
if param compare TRIG_PINS 56
then
# clear pins 5 and 6
# We ONLY support trigger on pins 5, 6, 7 and 8 when simultanously using AUX for actuator output.
if param compare TRIG_PINS 78
# clear pins 7 and 8
set FMU_MODE pwm4
set AUX_MODE pwm4
else
set FMU_MODE none
set AUX_MODE none
if param compare TRIG_PINS 56
then
# clear pins 5, 6
set FMU_MODE pwm4
set AUX_MODE pwm4
else
set FMU_MODE none
set AUX_MODE none
fi
fi

camera_trigger start
Expand Down
3 changes: 2 additions & 1 deletion src/drivers/camera_trigger/interfaces/src/camera_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <parameters/param.h>
#include <px4_log.h>
#include <board_config.h>

#define arraySize(a) (sizeof((a))/sizeof(((a)[0])))

Expand Down Expand Up @@ -74,6 +75,6 @@ class CameraInterface

param_t _p_pin;

int _pins[6];
int _pins[DIRECT_PWM_OUTPUT_CHANNELS];

};
10 changes: 9 additions & 1 deletion src/drivers/camera_trigger/interfaces/src/gpio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "gpio.h"
#include <cstring>

constexpr uint32_t CameraInterfaceGPIO::_gpios[6];
constexpr uint32_t CameraInterfaceGPIO::_gpios[DIRECT_PWM_OUTPUT_CHANNELS];

CameraInterfaceGPIO::CameraInterfaceGPIO():
CameraInterface(),
Expand Down Expand Up @@ -50,9 +50,17 @@ void CameraInterfaceGPIO::trigger(bool trigger_on_true)

void CameraInterfaceGPIO::info()
{

#if defined(DIRECT_PWM_OUTPUT_CHANNELS) && DIRECT_PWM_OUTPUT_CHANNELS <= 6
PX4_INFO("GPIO trigger mode, pins enabled : [%d][%d][%d][%d][%d][%d], polarity : %s",
_pins[5], _pins[4], _pins[3], _pins[2], _pins[1], _pins[0],
_trigger_invert ? "ACTIVE_LOW" : "ACTIVE_HIGH");
#else
PX4_INFO("GPIO trigger mode, pins enabled : [%d][%d][%d][%d][%d][%d][%d][%d], polarity : %s",
_pins[7], _pins[6], _pins[5], _pins[4], _pins[3], _pins[2], _pins[1], _pins[0],
_trigger_invert ? "ACTIVE_LOW" : "ACTIVE_HIGH");
#endif

}

#endif /* ifdef __PX4_NUTTX */
8 changes: 6 additions & 2 deletions src/drivers/camera_trigger/interfaces/src/gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,17 @@ class CameraInterfaceGPIO : public CameraInterface

bool _trigger_invert;

static constexpr uint32_t _gpios[6] = {
static constexpr uint32_t _gpios[DIRECT_PWM_OUTPUT_CHANNELS] = {
GPIO_GPIO0_OUTPUT,
GPIO_GPIO1_OUTPUT,
GPIO_GPIO2_OUTPUT,
GPIO_GPIO3_OUTPUT,
GPIO_GPIO4_OUTPUT,
GPIO_GPIO5_OUTPUT
GPIO_GPIO5_OUTPUT,
#if defined(DIRECT_PWM_OUTPUT_CHANNELS) && DIRECT_PWM_OUTPUT_CHANNELS > 6
GPIO_GPIO6_OUTPUT,
GPIO_GPIO7_OUTPUT,
#endif
};

uint32_t _triggers[arraySize(_gpios)];
Expand Down
6 changes: 6 additions & 0 deletions src/drivers/camera_trigger/interfaces/src/pwm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,14 @@ void CameraInterfacePWM::trigger(bool trigger_on_true)

void CameraInterfacePWM::info()
{
#if defined(DIRECT_PWM_OUTPUT_CHANNELS) && DIRECT_PWM_OUTPUT_CHANNELS <= 6
PX4_INFO("PWM trigger mode (generic), pins enabled : [%d][%d][%d][%d][%d][%d]",
_pins[5], _pins[4], _pins[3], _pins[2], _pins[1], _pins[0]);
#else
PX4_INFO("PWM trigger mode (generic), pins enabled : [%d][%d][%d][%d][%d][%d][%d][%d]",
_pins[7], _pins[6], _pins[5], _pins[4], _pins[3], _pins[2], _pins[1], _pins[0]);
#endif

}

#endif /* ifdef __PX4_NUTTX */
5 changes: 5 additions & 0 deletions src/drivers/camera_trigger/interfaces/src/seagull_map2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,13 @@ void CameraInterfaceSeagull::send_toggle_power(bool enable)

void CameraInterfaceSeagull::info()
{
#if defined(DIRECT_PWM_OUTPUT_CHANNELS) && DIRECT_PWM_OUTPUT_CHANNELS <= 6
PX4_INFO("PWM trigger mode (Seagull MAP2) , pins enabled : [%d][%d][%d][%d][%d][%d]",
_pins[5], _pins[4], _pins[3], _pins[2], _pins[1], _pins[0]);
#else
PX4_INFO("PWM trigger mode (Seagull MAP2) , pins enabled : [%d][%d][%d][%d][%d][%d][%d][%d]",
_pins[7], _pins[6], _pins[5], _pins[4], _pins[3], _pins[2], _pins[1], _pins[0]);
#endif
}

#endif /* ifdef __PX4_NUTTX */

0 comments on commit dd2edd9

Please sign in to comment.