Browse Source

boards/fmu-v5x: allocating PPS pin

- start pps_capture before pwm_out
master
Igor Mišić 3 years ago committed by Beat Küng
parent
commit
298a8c4637
  1. 3
      ROMFS/px4fmu_common/init.d/rcS
  2. 3
      platforms/nuttx/src/px4/nxp/imxrt/include/px4_arch/io_timer.h
  3. 4
      platforms/nuttx/src/px4/nxp/imxrt/io_pins/io_timer.c
  4. 3
      platforms/nuttx/src/px4/nxp/kinetis/include/px4_arch/io_timer.h
  5. 4
      platforms/nuttx/src/px4/nxp/kinetis/io_pins/io_timer.c
  6. 3
      platforms/nuttx/src/px4/nxp/s32k1xx/include/px4_arch/io_timer.h
  7. 4
      platforms/nuttx/src/px4/nxp/s32k1xx/io_pins/io_timer.c
  8. 3
      platforms/nuttx/src/px4/stm/stm32_common/include/px4_arch/io_timer.h
  9. 4
      platforms/nuttx/src/px4/stm/stm32_common/io_pins/io_timer.c
  10. 22
      src/drivers/pps_capture/PPSCapture.cpp
  11. 1
      src/drivers/pps_capture/PPSCapture.hpp

3
ROMFS/px4fmu_common/init.d/rcS

@ -477,6 +477,9 @@ else @@ -477,6 +477,9 @@ else
rc_input start $RC_INPUT_ARGS
fi
# PPS capture driver (before pwm_out)
pps_capture start
# Camera capture driver (before pwm_out)
if param greater -s CAM_CAP_FBACK 0
then

3
platforms/nuttx/src/px4/nxp/imxrt/include/px4_arch/io_timer.h

@ -62,7 +62,8 @@ typedef enum io_timer_channel_mode_t { @@ -62,7 +62,8 @@ typedef enum io_timer_channel_mode_t {
IOTimerChanMode_Trigger = 5,
IOTimerChanMode_Dshot = 6,
IOTimerChanMode_LED = 7,
IOTimerChanMode_Other = 8,
IOTimerChanMode_PPS = 8,
IOTimerChanMode_Other = 9,
IOTimerChanModeSize
} io_timer_channel_mode_t;

4
platforms/nuttx/src/px4/nxp/imxrt/io_pins/io_timer.c

@ -149,8 +149,8 @@ static int io_timer_handler7(int irq, void *context, void *arg); @@ -149,8 +149,8 @@ static int io_timer_handler7(int irq, void *context, void *arg);
#define rFCTRL20(_tim) REG(_tim, 0, IMXRT_FLEXPWM_FCTRL20_OFFSET) /* Fault Control 2 Register */
// NotUsed PWMOut PWMIn Capture OneShot Trigger Dshot LED Other
io_timer_channel_allocation_t channel_allocations[IOTimerChanModeSize] = { UINT16_MAX, 0, 0, 0, 0, 0, 0, 0, 0 };
// NotUsed PWMOut PWMIn Capture OneShot Trigger Dshot LED PPS Other
io_timer_channel_allocation_t channel_allocations[IOTimerChanModeSize] = { UINT16_MAX, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
typedef uint8_t io_timer_allocation_t; /* big enough to hold MAX_IO_TIMERS */

3
platforms/nuttx/src/px4/nxp/kinetis/include/px4_arch/io_timer.h

@ -66,7 +66,8 @@ typedef enum io_timer_channel_mode_t { @@ -66,7 +66,8 @@ typedef enum io_timer_channel_mode_t {
IOTimerChanMode_Trigger = 5,
IOTimerChanMode_Dshot = 6,
IOTimerChanMode_LED = 7,
IOTimerChanMode_Other = 8,
IOTimerChanMode_PPS = 8,
IOTimerChanMode_Other = 9,
IOTimerChanModeSize
} io_timer_channel_mode_t;

4
platforms/nuttx/src/px4/nxp/kinetis/io_pins/io_timer.c

@ -152,8 +152,8 @@ static int io_timer_handler7(int irq, void *context, void *arg); @@ -152,8 +152,8 @@ static int io_timer_handler7(int irq, void *context, void *arg);
#define CnSC_PWMIN_INIT 0 // TBD
// NotUsed PWMOut PWMIn Capture OneShot Trigger Dshot LED Other
io_timer_channel_allocation_t channel_allocations[IOTimerChanModeSize] = { UINT16_MAX, 0, 0, 0, 0, 0, 0, 0, 0 };
// NotUsed PWMOut PWMIn Capture OneShot Trigger Dshot LED PPS Other
io_timer_channel_allocation_t channel_allocations[IOTimerChanModeSize] = { UINT16_MAX, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
typedef uint8_t io_timer_allocation_t; /* big enough to hold MAX_IO_TIMERS */

3
platforms/nuttx/src/px4/nxp/s32k1xx/include/px4_arch/io_timer.h

@ -62,7 +62,8 @@ typedef enum io_timer_channel_mode_t { @@ -62,7 +62,8 @@ typedef enum io_timer_channel_mode_t {
IOTimerChanMode_Trigger = 5,
IOTimerChanMode_Dshot = 6,
IOTimerChanMode_LED = 7,
IOTimerChanMode_Other = 8,
IOTimerChanMode_PPS = 8,
IOTimerChanMode_Other = 9,
IOTimerChanModeSize
} io_timer_channel_mode_t;

4
platforms/nuttx/src/px4/nxp/s32k1xx/io_pins/io_timer.c

@ -150,8 +150,8 @@ static int io_timer_handler7(int irq, void *context, void *arg); @@ -150,8 +150,8 @@ static int io_timer_handler7(int irq, void *context, void *arg);
#define CnSC_PWMIN_INIT 0 // TBD
// NotUsed PWMOut PWMIn Capture OneShot Trigger Dshot LED Other
io_timer_channel_allocation_t channel_allocations[IOTimerChanModeSize] = { UINT16_MAX, 0, 0, 0, 0, 0, 0, 0, 0 };
// NotUsed PWMOut PWMIn Capture OneShot Trigger Dshot LED PPS Other
io_timer_channel_allocation_t channel_allocations[IOTimerChanModeSize] = { UINT16_MAX, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
typedef uint8_t io_timer_allocation_t; /* big enough to hold MAX_IO_TIMERS */

3
platforms/nuttx/src/px4/stm/stm32_common/include/px4_arch/io_timer.h

@ -75,7 +75,8 @@ typedef enum io_timer_channel_mode_t { @@ -75,7 +75,8 @@ typedef enum io_timer_channel_mode_t {
IOTimerChanMode_Trigger = 5,
IOTimerChanMode_Dshot = 6,
IOTimerChanMode_LED = 7,
IOTimerChanMode_Other = 8,
IOTimerChanMode_PPS = 8,
IOTimerChanMode_Other = 9,
IOTimerChanModeSize
} io_timer_channel_mode_t;

4
platforms/nuttx/src/px4/stm/stm32_common/io_pins/io_timer.c

@ -149,8 +149,8 @@ static int io_timer_handler7(int irq, void *context, void *arg); @@ -149,8 +149,8 @@ static int io_timer_handler7(int irq, void *context, void *arg);
/* The transfer is done to 4 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
#define TIM_DMABURSTLENGTH_4TRANSFERS 0x00000300U
// NotUsed PWMOut PWMIn Capture OneShot Trigger Dshot LED Other
io_timer_channel_allocation_t channel_allocations[IOTimerChanModeSize] = { UINT16_MAX, 0, 0, 0, 0, 0, 0, 0, 0 };
// NotUsed PWMOut PWMIn Capture OneShot Trigger Dshot LED PPS Other
io_timer_channel_allocation_t channel_allocations[IOTimerChanModeSize] = { UINT16_MAX, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
typedef uint8_t io_timer_allocation_t; /* big enough to hold MAX_IO_TIMERS */

22
src/drivers/pps_capture/PPSCapture.cpp

@ -40,6 +40,7 @@ @@ -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() : @@ -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
src/drivers/pps_capture/PPSCapture.hpp

@ -67,6 +67,7 @@ public: @@ -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

Loading…
Cancel
Save