The callback is simply any executable code that is passed as an argument to other code. A function that would receive a function pointer as an argument can call back the function.
Callbacks may also be used to control whether a function acts or not. For example HAL_UART_RxCpltCallback function that we used before in the STM32 Nextion Screen Led Toggle blog post. This function runs every Rx Transfer on UART receive completed. An example is an easy way to understand Callback in C.
Let’s look at the example below.
In that example, we can write only
Because the name of the function returns a pointer.