boards/fmu-v5x: allocating PPS pin

- start pps_capture before pwm_out
This commit is contained in:
Igor Mišić
2021-12-17 07:56:08 +01:00
committed by Beat Küng
parent 60a212f717
commit 298a8c4637
11 changed files with 40 additions and 14 deletions
+20 -2
View File
@@ -40,6 +40,7 @@
#include "PPSCapture.hpp"
#include "board_config.h"
#include <px4_arch/io_timer.h>
PPSCapture::PPSCapture() :
ScheduledWorkItem(MODULE_NAME, px4::wq_configurations::hp_default)
@@ -48,19 +49,36 @@ PPSCapture::PPSCapture() :
PPSCapture::~PPSCapture()
{
px4_arch_gpiosetevent(BOARD_CAPTURE_GPIO, false, false, false, nullptr, nullptr);
#if defined(PPS_CAPTURE_CHANNEL)
io_timer_unallocate_channel(PPS_CAPTURE_CHANNEL);
px4_arch_gpiosetevent(_pps_capture_gpio, false, false, false, nullptr, nullptr);
#endif
}
bool PPSCapture::init()
{
bool success = false;
int ret_val = px4_arch_gpiosetevent(BOARD_CAPTURE_GPIO, true, false, true, &PPSCapture::gpio_interrupt_callback, this);
#if defined(PPS_CAPTURE_CHANNEL)
int ret = io_timer_allocate_channel(PPS_CAPTURE_CHANNEL, IOTimerChanMode_PPS);
if (ret != PX4_OK) {
PX4_ERR("gpio alloc failed (%i) for PPS at channel (%d)", ret, PPS_CAPTURE_CHANNEL);
return false;
}
_pps_capture_gpio = PX4_MAKE_GPIO_EXTI(io_timer_channel_get_as_pwm_input(PPS_CAPTURE_CHANNEL));
int ret_val = px4_arch_gpiosetevent(_pps_capture_gpio, true, false, true, &PPSCapture::gpio_interrupt_callback, this);
if (ret_val == PX4_OK) {
success = true;
}
#else
#error Driver requires PPS_CAPTURE_CHANNEL to be enabled
#endif
return success;
}
+1
View File
@@ -67,6 +67,7 @@ public:
private:
void Run() override;
uint32_t _pps_capture_gpio{0};
uORB::Publication<pps_capture_s> _pps_capture_pub{ORB_ID(pps_capture)};
static constexpr unsigned USEC_IN_1_SEC{1000000}; // microseconds in 1 second