Skip to content

Commit 4650956

Browse files
authored
fix: prevent mbed crash when re-assigning interrupt function
1 parent e3d48af commit 4650956

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Arduino_GigaDisplayTouch.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,10 @@ void Arduino_GigaDisplayTouch::onDetect(void (*handler)(uint8_t, GDTpoint_t*)) {
180180
}
181181
} else {
182182
_gt911TouchHandler = handler;
183-
t.start(callback(&queue, &events::EventQueue::dispatch_forever));
183+
// Only start thread if it is inactive
184+
if (t.get_state() == rtos::Thread::Inactive) {
185+
t.start(callback(&queue, &events::EventQueue::dispatch_forever));
186+
}
184187
_irqInt.rise(queue.event(mbed::callback(this, &Arduino_GigaDisplayTouch::_gt911onIrq)));
185188
}
186189
}

0 commit comments

Comments
 (0)