HAL_ChibiOS: fixed attach_interrupt check

we can't have two handlers on the same pad
This commit is contained in:
Andrew Tridgell 2018-08-03 09:57:57 +10:00
parent 4e6ac85057
commit 64c8ca514c

View File

@ -135,10 +135,21 @@ bool GPIO::_attach_interrupt(ioline_t line, AP_HAL::Proc p, uint8_t mode)
return false;
}
break;
}
if (p) {
osalSysLock();
palevent_t *pep = pal_lld_get_line_event(line);
if (pep->cb) {
// the pad is already being used for a callback
osalSysUnlock();
return false;
}
osalSysUnlock();
}
palDisableLineEvent(line);
palEnableLineEvent(line, chmode);
palSetLineCallback(line, pal_interrupt_cb, (void*)p);
palSetLineCallback(line, p?pal_interrupt_cb:nullptr, (void*)p);
return true;
}