AP_IOMCU: fixed setting of rate masks

this affects layouts which set a subset of channels on a timer
This commit is contained in:
Andrew Tridgell 2018-07-28 13:44:49 +10:00
parent fa4d125727
commit 6d3ff416cf
1 changed files with 8 additions and 1 deletions

View File

@ -563,8 +563,15 @@ void AP_IOMCU::push(void)
// set output frequency // set output frequency
void AP_IOMCU::set_freq(uint16_t chmask, uint16_t freq) void AP_IOMCU::set_freq(uint16_t chmask, uint16_t freq)
{ {
const uint8_t masks[] = { 0x03,0x0C,0xF0 };
// ensure mask is legal for the timer layout
for (uint8_t i=0; i<ARRAY_SIZE_SIMPLE(masks); i++) {
if (chmask & masks[i]) {
chmask |= masks[i];
}
}
rate.freq = freq; rate.freq = freq;
rate.chmask = chmask; rate.chmask |= chmask;
trigger_event(IOEVENT_SET_RATES); trigger_event(IOEVENT_SET_RATES);
} }