mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-07 13:00:34 +08:00
IO firmware: Depend on external RC lib
This commit is contained in:
@@ -64,6 +64,7 @@ px4_join(OUT CMAKE_CXX_FLAGS LIST "${cxx_flags}" GLUE " ")
|
||||
include_directories(
|
||||
${include_dirs}
|
||||
${CMAKE_BINARY_DIR}/src/modules/systemlib/mixer
|
||||
.
|
||||
)
|
||||
link_directories(${link_dirs})
|
||||
add_definitions(${definitions})
|
||||
@@ -71,11 +72,9 @@ add_definitions(${definitions})
|
||||
set(srcs
|
||||
adc.c
|
||||
controls.c
|
||||
dsm.c
|
||||
px4io.c
|
||||
registers.c
|
||||
safety.c
|
||||
sbus.c
|
||||
../systemlib/up_cxxinitialize.c
|
||||
../systemlib/perf_counter.c
|
||||
mixer.cpp
|
||||
@@ -86,6 +85,8 @@ set(srcs
|
||||
../systemlib/pwm_limit/pwm_limit.c
|
||||
../../lib/rc/st24.c
|
||||
../../lib/rc/sumd.c
|
||||
../../lib/rc/sbus.c
|
||||
../../lib/rc/dsm.c
|
||||
../../drivers/stm32/drv_hrt.c
|
||||
../../drivers/stm32/drv_pwm_servo.c
|
||||
../../drivers/boards/${config_io_board}/px4io_init.c
|
||||
|
||||
@@ -46,6 +46,8 @@
|
||||
#include <systemlib/ppm_decode.h>
|
||||
#include <rc/st24.h>
|
||||
#include <rc/sumd.h>
|
||||
#include <rc/sbus.h>
|
||||
#include <rc/dsm.h>
|
||||
|
||||
#include "px4io.h"
|
||||
|
||||
@@ -60,7 +62,8 @@ static perf_counter_t c_gather_dsm;
|
||||
static perf_counter_t c_gather_sbus;
|
||||
static perf_counter_t c_gather_ppm;
|
||||
|
||||
static int _dsm_fd;
|
||||
static int _dsm_fd = -1;
|
||||
int _sbus_fd = -1;
|
||||
|
||||
static uint16_t rc_value_override = 0;
|
||||
|
||||
@@ -158,7 +161,7 @@ controls_init(void)
|
||||
_dsm_fd = dsm_init("/dev/ttyS0");
|
||||
|
||||
/* S.bus input (USART3) */
|
||||
sbus_init("/dev/ttyS2");
|
||||
_sbus_fd = sbus_init("/dev/ttyS2", false);
|
||||
|
||||
/* default to a 1:1 input map, all enabled */
|
||||
for (unsigned i = 0; i < PX4IO_RC_INPUT_CHANNELS; i++) {
|
||||
@@ -240,7 +243,7 @@ controls_tick()
|
||||
perf_begin(c_gather_sbus);
|
||||
|
||||
bool sbus_failsafe, sbus_frame_drop;
|
||||
bool sbus_updated = sbus_input(r_raw_rc_values, &r_raw_rc_count, &sbus_failsafe, &sbus_frame_drop,
|
||||
bool sbus_updated = sbus_input(_sbus_fd, r_raw_rc_values, &r_raw_rc_count, &sbus_failsafe, &sbus_frame_drop,
|
||||
PX4IO_RC_INPUT_CHANNELS);
|
||||
|
||||
if (sbus_updated) {
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
|
||||
#include <drivers/drv_pwm_output.h>
|
||||
#include <drivers/drv_hrt.h>
|
||||
#include <rc/sbus.h>
|
||||
|
||||
#include <systemlib/pwm_limit/pwm_limit.h>
|
||||
#include <systemlib/mixer/mixer.h>
|
||||
@@ -71,6 +72,8 @@ static bool should_arm_nothrottle = false;
|
||||
static bool should_always_enable_pwm = false;
|
||||
static volatile bool in_mixer = false;
|
||||
|
||||
extern int _sbus_fd;
|
||||
|
||||
/* selected control values and count for mixing */
|
||||
enum mixer_source {
|
||||
MIX_NONE,
|
||||
@@ -292,10 +295,10 @@ mixer_tick(void)
|
||||
/* set S.BUS1 or S.BUS2 outputs */
|
||||
|
||||
if (r_setup_features & PX4IO_P_SETUP_FEATURES_SBUS2_OUT) {
|
||||
sbus2_output(r_page_servos, PX4IO_SERVO_COUNT);
|
||||
sbus2_output(_sbus_fd, r_page_servos, PX4IO_SERVO_COUNT);
|
||||
|
||||
} else if (r_setup_features & PX4IO_P_SETUP_FEATURES_SBUS1_OUT) {
|
||||
sbus1_output(r_page_servos, PX4IO_SERVO_COUNT);
|
||||
sbus1_output(_sbus_fd, r_page_servos, PX4IO_SERVO_COUNT);
|
||||
}
|
||||
|
||||
} else if (mixer_servos_armed && should_always_enable_pwm) {
|
||||
@@ -306,11 +309,11 @@ mixer_tick(void)
|
||||
|
||||
/* set S.BUS1 or S.BUS2 outputs */
|
||||
if (r_setup_features & PX4IO_P_SETUP_FEATURES_SBUS1_OUT) {
|
||||
sbus1_output(r_page_servo_disarmed, PX4IO_SERVO_COUNT);
|
||||
sbus1_output(_sbus_fd, r_page_servo_disarmed, PX4IO_SERVO_COUNT);
|
||||
}
|
||||
|
||||
if (r_setup_features & PX4IO_P_SETUP_FEATURES_SBUS2_OUT) {
|
||||
sbus2_output(r_page_servo_disarmed, PX4IO_SERVO_COUNT);
|
||||
sbus2_output(_sbus_fd, r_page_servo_disarmed, PX4IO_SERVO_COUNT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,14 +224,6 @@ extern uint16_t adc_measure(unsigned channel);
|
||||
*/
|
||||
extern void controls_init(void);
|
||||
extern void controls_tick(void);
|
||||
extern int dsm_init(const char *device);
|
||||
extern bool dsm_input(uint16_t *values, uint16_t *num_values, uint8_t *n_bytes, uint8_t **bytes);
|
||||
extern void dsm_bind(uint16_t cmd, int pulses);
|
||||
extern int sbus_init(const char *device);
|
||||
extern bool sbus_input(uint16_t *values, uint16_t *num_values, bool *sbus_failsafe, bool *sbus_frame_drop,
|
||||
uint16_t max_channels);
|
||||
extern void sbus1_output(uint16_t *values, uint16_t num_values);
|
||||
extern void sbus2_output(uint16_t *values, uint16_t num_values);
|
||||
|
||||
/** global debug level for isr_debug() */
|
||||
extern volatile uint8_t debug_level;
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
#include <drivers/drv_pwm_output.h>
|
||||
#include <systemlib/systemlib.h>
|
||||
#include <stm32_pwr.h>
|
||||
#include <rc/dsm.h>
|
||||
|
||||
#include "px4io.h"
|
||||
#include "protocol.h"
|
||||
|
||||
Reference in New Issue
Block a user