Update Callback to fix fault in serial interrupts

Update the Callback class to handle a NULL thunk by returning 0
rather than trying to call the thunk.  This fixes a crash that occurs
on some targets when the TX uart handler is not attached.

Background:
The K64F HAL uart implementation calls the TX interrupt handler
every time a uart interrupt occurs while the TX register is empty.
It does not check to see if the TX interrupt has been enabled.
This means that the TX interrupt can and typically does get
run on RX events.  This causes a crash with the newer callback
code which did not (prior to this patch) support a NULL thunk.
Russ Butler 2016-05-24 17:11:33 -05:00
parent 8a6e9c3a26
commit e37e1da7b9
1 changed files with 3 additions and 0 deletions

View File

@ -796,6 +796,9 @@ public:
/** Call the attached function
*/
R call() {
if (NULL == _thunk) {
return (R)0;
}
return _thunk(_obj, &_func);
}