mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-02 22:18:29 -04:00
HAL_ChibiOS: fixed attach_interrupt check
we can't have two handlers on the same pad
This commit is contained in:
parent
4e6ac85057
commit
64c8ca514c
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user