mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-20 11:23:06 +08:00
px4fmu move RC input to new rc_input driver
This commit is contained in:
@@ -87,11 +87,6 @@ then
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $OUTPUT_MODE == tap_esc ]
|
||||
then
|
||||
set FMU_MODE rcin
|
||||
fi
|
||||
|
||||
if [ $OUTPUT_MODE == fmu ]
|
||||
then
|
||||
if fmu mode_$FMU_MODE $FMU_ARGS
|
||||
|
||||
@@ -398,6 +398,11 @@ else
|
||||
tune_control play -t 2
|
||||
fi
|
||||
|
||||
if [ $IO_PRESENT == no -o $USE_IO == no ]
|
||||
then
|
||||
rc_input start
|
||||
fi
|
||||
|
||||
#
|
||||
# Sensors System (start before Commander so Preflight checks are properly run).
|
||||
# Commander Needs to be this early for in-air-restarts.
|
||||
|
||||
@@ -24,6 +24,7 @@ set(config_module_list
|
||||
modules/sensors
|
||||
#drivers/pwm_input
|
||||
#drivers/camera_trigger
|
||||
drivers/rc_input
|
||||
|
||||
#
|
||||
# System commands
|
||||
|
||||
@@ -17,6 +17,7 @@ set(config_module_list
|
||||
drivers/px4fmu
|
||||
drivers/stm32
|
||||
drivers/pwm_out_sim
|
||||
drivers/rc_input
|
||||
drivers/tap_esc
|
||||
modules/sensors
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ set(config_module_list
|
||||
drivers/pwm_out_sim
|
||||
drivers/px4flow
|
||||
drivers/px4fmu
|
||||
drivers/rc_input
|
||||
drivers/stm32
|
||||
drivers/stm32/adc
|
||||
drivers/tap_esc
|
||||
|
||||
@@ -29,6 +29,7 @@ set(config_module_list
|
||||
drivers/px4flow
|
||||
drivers/px4fmu
|
||||
drivers/rgbled
|
||||
drivers/rc_input
|
||||
#drivers/rgbled_pwm
|
||||
drivers/stm32
|
||||
drivers/stm32/adc
|
||||
|
||||
@@ -32,6 +32,7 @@ set(config_module_list
|
||||
drivers/pwm_out_sim
|
||||
drivers/px4flow
|
||||
drivers/px4fmu
|
||||
drivers/rc_input
|
||||
drivers/rgbled
|
||||
drivers/rgbled_pwm
|
||||
drivers/tap_esc
|
||||
|
||||
@@ -20,6 +20,7 @@ set(config_module_list
|
||||
drivers/gps
|
||||
drivers/px4flow
|
||||
drivers/px4fmu
|
||||
drivers/rc_input
|
||||
drivers/rgbled
|
||||
drivers/stm32
|
||||
drivers/stm32/adc
|
||||
|
||||
@@ -27,6 +27,7 @@ set(config_module_list
|
||||
drivers/px4flow
|
||||
drivers/px4fmu
|
||||
drivers/rgbled
|
||||
drivers/rc_input
|
||||
drivers/stm32
|
||||
drivers/stm32/adc
|
||||
drivers/stm32/tone_alarm
|
||||
|
||||
@@ -15,24 +15,24 @@ set(config_module_list
|
||||
|
||||
drivers/batt_smbus
|
||||
drivers/blinkm
|
||||
drivers/camera_trigger
|
||||
drivers/gps
|
||||
drivers/imu/bma180
|
||||
drivers/imu/bmi055
|
||||
drivers/imu/bmi160
|
||||
drivers/camera_trigger
|
||||
drivers/gps
|
||||
drivers/irlock
|
||||
drivers/mkblctrl
|
||||
drivers/imu/mpu6000
|
||||
drivers/imu/mpu9250
|
||||
drivers/irlock
|
||||
drivers/mkblctrl
|
||||
drivers/oreoled
|
||||
drivers/pwm_input
|
||||
drivers/pwm_out_sim
|
||||
drivers/px4flow
|
||||
drivers/px4fmu
|
||||
drivers/px4io
|
||||
drivers/rc_input
|
||||
drivers/rgbled
|
||||
# Enable the line below to put the three leds into PWM RGB mode
|
||||
#drivers/rgbled_pwm
|
||||
#drivers/rgbled_pwm # Enable to put the three leds into PWM RGB mode
|
||||
drivers/stm32
|
||||
drivers/stm32/adc
|
||||
drivers/stm32/tone_alarm
|
||||
|
||||
@@ -14,6 +14,7 @@ set(config_module_list
|
||||
drivers/imu/mpu6000
|
||||
drivers/px4fmu
|
||||
drivers/rgbled_pwm
|
||||
drivers/rc_input
|
||||
drivers/stm32
|
||||
drivers/stm32/adc
|
||||
drivers/stm32/tone_alarm
|
||||
|
||||
@@ -190,10 +190,6 @@ struct pwm_output_rc_config {
|
||||
/** start DSM bind */
|
||||
#define DSM_BIND_START _PX4_IOC(_PWM_SERVO_BASE, 10)
|
||||
|
||||
#define DSM2_BIND_PULSES 3 /* DSM_BIND_START ioctl parameter, pulses required to start dsm2 pairing */
|
||||
#define DSMX_BIND_PULSES 7 /* DSM_BIND_START ioctl parameter, pulses required to start dsmx pairing */
|
||||
#define DSMX8_BIND_PULSES 9 /* DSM_BIND_START ioctl parameter, pulses required to start 8 or more channel dsmx pairing */
|
||||
|
||||
/** power up DSM receiver */
|
||||
#define DSM_BIND_POWER_UP _PX4_IOC(_PWM_SERVO_BASE, 11)
|
||||
|
||||
|
||||
@@ -37,10 +37,8 @@ px4_add_module(
|
||||
COMPILE_FLAGS
|
||||
SRCS
|
||||
fmu.cpp
|
||||
crsf_telemetry.cpp
|
||||
DEPENDS
|
||||
circuit_breaker
|
||||
mixer
|
||||
rc
|
||||
pwm_limit
|
||||
)
|
||||
|
||||
+3
-622
File diff suppressed because it is too large
Load Diff
@@ -67,6 +67,8 @@
|
||||
#include <drivers/drv_hrt.h>
|
||||
#include <drivers/drv_mixer.h>
|
||||
|
||||
#include <rc/dsm.h>
|
||||
|
||||
#include <lib/mixer/mixer.h>
|
||||
#include <perf/perf_counter.h>
|
||||
#include <systemlib/err.h>
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
############################################################################
|
||||
#
|
||||
# Copyright (c) 2015 PX4 Development Team. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name PX4 nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################################
|
||||
px4_add_module(
|
||||
MODULE drivers__rc_input
|
||||
MAIN rc_input
|
||||
STACK_MAIN 1200
|
||||
COMPILE_FLAGS
|
||||
SRCS
|
||||
RCInput.cpp
|
||||
crsf_telemetry.cpp
|
||||
DEPENDS
|
||||
rc
|
||||
)
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,155 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2012-2018 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cfloat>
|
||||
|
||||
#include <board_config.h>
|
||||
#include <drivers/drv_hrt.h>
|
||||
#include <drivers/drv_rc_input.h>
|
||||
#include <lib/rc/crsf.h>
|
||||
#include <lib/rc/dsm.h>
|
||||
#include <lib/rc/sbus.h>
|
||||
#include <lib/rc/st24.h>
|
||||
#include <lib/rc/sumd.h>
|
||||
#include <px4_config.h>
|
||||
#include <px4_getopt.h>
|
||||
#include <px4_log.h>
|
||||
#include <px4_module.h>
|
||||
#include <px4_workqueue.h>
|
||||
#include <uORB/topics/adc_report.h>
|
||||
#include <uORB/topics/input_rc.h>
|
||||
#include <uORB/topics/vehicle_command.h>
|
||||
|
||||
#include "crsf_telemetry.h"
|
||||
|
||||
#ifdef HRT_PPM_CHANNEL
|
||||
# include <systemlib/ppm_decode.h>
|
||||
#endif
|
||||
|
||||
class RCInput : public ModuleBase<RCInput>
|
||||
{
|
||||
public:
|
||||
|
||||
RCInput(bool run_as_task);
|
||||
virtual ~RCInput();
|
||||
|
||||
/** @see ModuleBase */
|
||||
static int task_spawn(int argc, char *argv[]);
|
||||
|
||||
/** @see ModuleBase */
|
||||
static RCInput *instantiate(int argc, char *argv[]);
|
||||
|
||||
/** @see ModuleBase */
|
||||
static int custom_command(int argc, char *argv[]);
|
||||
|
||||
/** @see ModuleBase */
|
||||
static int print_usage(const char *reason = nullptr);
|
||||
|
||||
/** @see ModuleBase::run() */
|
||||
void run() override;
|
||||
|
||||
/**
|
||||
* run the main loop: if running as task, continuously iterate, otherwise execute only one single cycle
|
||||
*/
|
||||
void cycle();
|
||||
|
||||
/** @see ModuleBase::print_status() */
|
||||
int print_status() override;
|
||||
|
||||
int init();
|
||||
|
||||
private:
|
||||
enum RC_SCAN {
|
||||
RC_SCAN_PPM = 0,
|
||||
RC_SCAN_SBUS,
|
||||
RC_SCAN_DSM,
|
||||
RC_SCAN_SUMD,
|
||||
RC_SCAN_ST24,
|
||||
RC_SCAN_CRSF
|
||||
};
|
||||
enum RC_SCAN _rc_scan_state = RC_SCAN_SBUS;
|
||||
|
||||
char const *RC_SCAN_STRING[6] = {
|
||||
"PPM",
|
||||
"SBUS",
|
||||
"DSM",
|
||||
"SUMD",
|
||||
"ST24",
|
||||
"CRSF"
|
||||
};
|
||||
|
||||
hrt_abstime _rc_scan_begin{0};
|
||||
bool _rc_scan_locked{false};
|
||||
bool _report_lock{true};
|
||||
|
||||
hrt_abstime _cycle_timestamp{0};
|
||||
|
||||
unsigned _current_update_rate{0};
|
||||
bool _run_as_task{false};
|
||||
|
||||
static struct work_s _work;
|
||||
|
||||
int _vehicle_cmd_sub{-1};
|
||||
int _adc_sub{-1};
|
||||
|
||||
rc_input_values _rc_in{};
|
||||
|
||||
float _analog_rc_rssi_volt{-1.0f};
|
||||
bool _analog_rc_rssi_stable{false};
|
||||
|
||||
orb_advert_t _to_input_rc{nullptr};
|
||||
|
||||
int _rcs_fd{-1};
|
||||
|
||||
uint8_t _rcs_buf[SBUS_BUFFER_SIZE] {};
|
||||
|
||||
uint16_t _raw_rc_values[input_rc_s::RC_INPUT_MAX_CHANNELS] {};
|
||||
uint16_t _raw_rc_count{};
|
||||
|
||||
CRSFTelemetry *_crsf_telemetry{nullptr};
|
||||
|
||||
static void cycle_trampoline(void *arg);
|
||||
int start();
|
||||
|
||||
void fill_rc_in(uint16_t raw_rc_count_local,
|
||||
uint16_t raw_rc_values_local[input_rc_s::RC_INPUT_MAX_CHANNELS],
|
||||
hrt_abstime now, bool frame_drop, bool failsafe,
|
||||
unsigned frame_drops, int rssi);
|
||||
|
||||
void set_rc_scan_state(RC_SCAN _rc_scan_state);
|
||||
|
||||
void rc_io_invert(bool invert, uint32_t uxart_base);
|
||||
|
||||
};
|
||||
@@ -204,4 +204,3 @@ bool CRSFTelemetry::send_flight_mode()
|
||||
|
||||
return crsf_send_telemetry_flight_mode(_uart_fd, flight_mode);
|
||||
}
|
||||
|
||||
@@ -42,6 +42,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <px4_config.h>
|
||||
#include <px4_defines.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
@@ -85,4 +87,8 @@ enum DSM_CMD { /* DSM bind states */
|
||||
DSM_CMD_BIND_REINIT_UART
|
||||
};
|
||||
|
||||
#define DSM2_BIND_PULSES 3 /* DSM_BIND_START parameter, pulses required to start dsm2 pairing */
|
||||
#define DSMX_BIND_PULSES 7 /* DSM_BIND_START parameter, pulses required to start dsmx pairing */
|
||||
#define DSMX8_BIND_PULSES 9 /* DSM_BIND_START parameter, pulses required to start 8 or more channel dsmx pairing */
|
||||
|
||||
__END_DECLS
|
||||
|
||||
Reference in New Issue
Block a user