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:
Mark Whitehorn
2017-02-14 10:08:14 -07:00
committed by Lorenz Meier
parent eac72051b8
commit aa9fbbedd5
10 changed files with 717 additions and 552 deletions
+17
View File
@@ -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 */
+1
View File
@@ -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)
+4
View File
@@ -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 */