mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 14:23:33 +08:00
px4io: fixed signals for lower latency PWM output
poll() is not interrupted by signals, whereas usleep() is
This commit is contained in:
+15
-9
@@ -214,28 +214,34 @@ int user_start(int argc, char *argv[])
|
|||||||
debug("Failed to setup SIGUSR1 handler\n");
|
debug("Failed to setup SIGUSR1 handler\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* run the mixer at ~300Hz (for now...) */
|
/*
|
||||||
/* XXX we should use CONFIG_IDLE_CUSTOM and take over the idle thread instead of running two additional tasks */
|
run the mixer at ~50Hz, using signals to run it early if
|
||||||
uint16_t counter=0;
|
need be
|
||||||
|
*/
|
||||||
|
uint64_t last_debug_time = 0;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
/*
|
/*
|
||||||
if we are not scheduled for 10ms then reset the I2C bus
|
if we are not scheduled for 30ms then reset the I2C bus
|
||||||
*/
|
*/
|
||||||
hrt_call_after(&loop_overtime_call, 10000, (hrt_callout)loop_overtime, NULL);
|
hrt_call_after(&loop_overtime_call, 30000, (hrt_callout)loop_overtime, NULL);
|
||||||
|
|
||||||
|
// we use usleep() instead of poll() as poll() is not
|
||||||
|
// interrupted by signals in nuttx, whereas usleep() is
|
||||||
|
usleep(20000);
|
||||||
|
|
||||||
poll(NULL, 0, 3);
|
|
||||||
perf_begin(mixer_perf);
|
perf_begin(mixer_perf);
|
||||||
mixer_tick();
|
mixer_tick();
|
||||||
perf_end(mixer_perf);
|
perf_end(mixer_perf);
|
||||||
|
|
||||||
show_debug_messages();
|
show_debug_messages();
|
||||||
if (counter++ == 800) {
|
if (hrt_absolute_time() - last_debug_time > 1000000) {
|
||||||
counter = 0;
|
isr_debug(1, "d:%u s=0x%x a=0x%x f=0x%x r=%u",
|
||||||
isr_debug(1, "d:%u stat=0x%x arm=0x%x feat=0x%x rst=%u",
|
|
||||||
(unsigned)debug_level,
|
(unsigned)debug_level,
|
||||||
(unsigned)r_status_flags,
|
(unsigned)r_status_flags,
|
||||||
(unsigned)r_setup_arming,
|
(unsigned)r_setup_arming,
|
||||||
(unsigned)r_setup_features,
|
(unsigned)r_setup_features,
|
||||||
(unsigned)i2c_loop_resets);
|
(unsigned)i2c_loop_resets);
|
||||||
|
last_debug_time = hrt_absolute_time();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user