Skip to content

Commit e37e1da

Browse files
committed
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.
1 parent 8a6e9c3 commit e37e1da

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

hal/api/Callback.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,9 @@ class Callback<R()> {
796796
/** Call the attached function
797797
*/
798798
R call() {
799+
if (NULL == _thunk) {
800+
return (R)0;
801+
}
799802
return _thunk(_obj, &_func);
800803
}
801804

0 commit comments

Comments
 (0)