GPIO interrupt dispatcher, minimize blocking (#2558)
Only need to lock around the std::map check, not the whole IRQ callback This is important if you have a time sensitive interrupt on one of the cores
This commit is contained in:
parent
9c217b13df
commit
3aa8df5ab7
1 changed files with 13 additions and 6 deletions
|
|
@ -87,15 +87,22 @@ static std::map<pin_size_t, CBInfo> _map;
|
||||||
|
|
||||||
void _gpioInterruptDispatcher(uint gpio, uint32_t events) {
|
void _gpioInterruptDispatcher(uint gpio, uint32_t events) {
|
||||||
(void) events;
|
(void) events;
|
||||||
|
|
||||||
// Only need to lock around the std::map check, not the whole IRQ callback
|
// Only need to lock around the std::map check, not the whole IRQ callback
|
||||||
CoreMutex m(&_irqMutex);
|
CBInfo *cb;
|
||||||
if (m) {
|
{
|
||||||
auto irq = _map.find(gpio);
|
CoreMutex m(&_irqMutex);
|
||||||
if (irq != _map.end()) {
|
if (m) {
|
||||||
auto cb = irq->second;
|
auto irq = _map.find(gpio);
|
||||||
cb.callback();
|
if (irq == _map.end()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cb = &irq->second;
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
cb->callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
// To be called when appropriately protected w/IRQ and mutex protects
|
// To be called when appropriately protected w/IRQ and mutex protects
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue