mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-02 17:00:34 +08:00
add oneshot mode capability
change fmu to task increase fmu_servo task priority to max and enable true oneshot use lowest FMU priority which minimizes jitter constrain oneshot updates to control group 0 events
This commit is contained in:
committed by
Lorenz Meier
parent
eac72051b8
commit
aa9fbbedd5
@@ -75,6 +75,9 @@ static volatile bool should_arm_nothrottle = false;
|
||||
static volatile bool should_always_enable_pwm = false;
|
||||
static volatile bool in_mixer = false;
|
||||
|
||||
static bool new_fmu_data = false;
|
||||
static uint64_t last_fmu_update = 0;
|
||||
|
||||
extern int _sbus_fd;
|
||||
|
||||
/* selected control values and count for mixing */
|
||||
@@ -133,6 +136,11 @@ mixer_tick(void)
|
||||
|
||||
/* this flag is never cleared once OK */
|
||||
r_status_flags |= PX4IO_P_STATUS_FLAGS_FMU_INITIALIZED;
|
||||
|
||||
if (system_state.fmu_data_received_time > last_fmu_update) {
|
||||
new_fmu_data = true;
|
||||
last_fmu_update = system_state.fmu_data_received_time;
|
||||
}
|
||||
}
|
||||
|
||||
/* default to failsafe mixing - it will be forced below if flag is set */
|
||||
@@ -301,6 +309,15 @@ mixer_tick(void)
|
||||
for (unsigned i = 0; i < PX4IO_SERVO_COUNT; i++) {
|
||||
r_page_actuators[i] = FLOAT_TO_REG(outputs[i]);
|
||||
}
|
||||
|
||||
if (new_fmu_data) {
|
||||
new_fmu_data = false;
|
||||
|
||||
if (up_pwm_get_oneshot_mode()) {
|
||||
up_pwm_force_update();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* set arming */
|
||||
|
||||
@@ -235,6 +235,7 @@ int
|
||||
user_start(int argc, char *argv[])
|
||||
{
|
||||
/* configure the first 8 PWM outputs (i.e. all of them) */
|
||||
up_pwm_set_oneshot_mode(true);
|
||||
up_pwm_servo_init(0xff);
|
||||
|
||||
#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE)
|
||||
|
||||
@@ -325,6 +325,10 @@ registers_set(uint8_t page, uint8_t offset, const uint16_t *values, unsigned num
|
||||
system_state.fmu_data_received_time = hrt_absolute_time();
|
||||
r_status_flags |= PX4IO_P_STATUS_FLAGS_RAW_PWM;
|
||||
|
||||
if (up_pwm_get_oneshot_mode()) {
|
||||
up_pwm_force_update();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
/* handle setup for servo failsafe values */
|
||||
|
||||
Reference in New Issue
Block a user