From d2e2b5e8ce3ec325088441cc2b3b28d2f696c011 Mon Sep 17 00:00:00 2001 From: Daniele Pettenuzzo <35664507+DanielePettenuzzo@users.noreply.github.com> Date: Wed, 24 Oct 2018 16:25:41 +0200 Subject: [PATCH] add pmw3901 optical flow support for fmu-v5 (#10750) --- ROMFS/px4fmu_common/init.d/rc.sensors | 3 +++ cmake/configs/nuttx_px4fmu-v5_default.cmake | 1 + src/drivers/pmw3901/pmw3901.cpp | 12 ++++++++---- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d/rc.sensors b/ROMFS/px4fmu_common/init.d/rc.sensors index 5ac2eee781..6da0314cb8 100644 --- a/ROMFS/px4fmu_common/init.d/rc.sensors +++ b/ROMFS/px4fmu_common/init.d/rc.sensors @@ -345,6 +345,9 @@ then # Possible internal compass ist8310 -C -b 5 start + + # Possible pmw3901 optical flow sensor + pmw3901 start fi if ver hwcmp PX4_SAME70XPLAINED_V1 diff --git a/cmake/configs/nuttx_px4fmu-v5_default.cmake b/cmake/configs/nuttx_px4fmu-v5_default.cmake index 9e49a6dfdf..97cda95273 100644 --- a/cmake/configs/nuttx_px4fmu-v5_default.cmake +++ b/cmake/configs/nuttx_px4fmu-v5_default.cmake @@ -32,6 +32,7 @@ set(config_module_list drivers/irlock drivers/mkblctrl drivers/oreoled + drivers/pmw3901 drivers/pwm_input drivers/pwm_out_sim drivers/px4flow diff --git a/src/drivers/pmw3901/pmw3901.cpp b/src/drivers/pmw3901/pmw3901.cpp index 605da11572..a302a56b89 100644 --- a/src/drivers/pmw3901/pmw3901.cpp +++ b/src/drivers/pmw3901/pmw3901.cpp @@ -79,16 +79,20 @@ #include /* Configuration Constants */ -#ifdef PX4_SPI_BUS_EXPANSION +#if defined PX4_SPI_BUS_EXPANSION // crazyflie #define PMW3901_BUS PX4_SPI_BUS_EXPANSION +#elif defined PX4_SPI_BUS_EXTERNAL1 // fmu-v5 +#define PMW3901_BUS PX4_SPI_BUS_EXTERNAL1 #else -#define PMW3901_BUS 0 +#error "add the required spi bus from board_config.h here" #endif -#ifdef PX4_SPIDEV_EXPANSION_2 +#if defined PX4_SPIDEV_EXPANSION_2 // crazyflie flow deck #define PMW3901_SPIDEV PX4_SPIDEV_EXPANSION_2 +#elif defined PX4_SPIDEV_EXTERNAL1_1 // fmu-v5 ext CS1 +#define PMW3901_SPIDEV PX4_SPIDEV_EXTERNAL1_1 #else -#define PMW3901_SPIDEV 0 +#error "add the required spi dev from board_config.h here" #endif #define PMW3901_SPI_BUS_SPEED (2000000L) // 2MHz