HAL_PX4: only support oneshot on FMU outputs for now

oneshot on PX4IO gives some very weird results. I think it is doable,
but will take a bit more work
This commit is contained in:
Andrew Tridgell 2016-04-13 17:46:16 +10:00
parent 8408428339
commit 759b0d6629
2 changed files with 27 additions and 2 deletions

View File

@ -462,8 +462,7 @@ void PX4RCOutput::push()
_send_outputs();
if (_fast_channel_mask != 0) {
// this is a crude way of triggering immediate output
set_freq(_fast_channel_mask, 400);
set_freq(_fast_channel_mask, 0);
_trigger_fast_output();
}
}
}
@ -475,4 +474,28 @@ void PX4RCOutput::_timer_tick(void)
}
}
/*
trigger immediate output on fast channels. This only works on FMU,
not IO. It takes advantage of the way the rate update works on FMU
to trigger a oneshot output
*/
void PX4RCOutput::_trigger_fast_output(void)
{
uint32_t primary_mask = _fast_channel_mask & ((1UL<<_servo_count)-1);
uint32_t alt_mask = _fast_channel_mask >> _servo_count;
if (_alt_fd == -1) {
// we're on a FMU only board
if (primary_mask) {
set_freq_fd(_pwm_fd, primary_mask, 400);
set_freq_fd(_pwm_fd, primary_mask, 0);
}
} else {
// we're on a board with px4io
if (alt_mask) {
set_freq_fd(_alt_fd, alt_mask, 400);
set_freq_fd(_alt_fd, alt_mask, 0);
}
}
}
#endif // CONFIG_HAL_BOARD

View File

@ -70,4 +70,6 @@ private:
bool _corking;
enum output_mode _output_mode = MODE_PWM_NORMAL;
void _send_outputs(void);
void _trigger_fast_output();
};