Reputation: 49
I am reading a book on writing embedded system peripheral drivers and the author wrote a C callback function which i really don't understand and want to know the use of it, is it related to interrupts handling?
The function prototype is as following:
void Spi_CallbackRegister(SpiCallback_t Function, TYPE (*CallbackFunction)(type));
Upvotes: 0
Views: 343
Reputation: 3053
Short Answer: Callback function are function pointers with which you invoke them, when a specific event occurs.
Let us say you have an IO device like ethernet (MAC) device. Driver for such device will always be waiting for an events to occur, these events are either hardware or software interrupts, example:
To handle various interrupt(s) type you need a specific function for each of them, these functions are called Interrupt Service Routine(ISR) or Interrupt handler or a callback function
. When an event is mapped to a function, it stores its pointer and thats why the term callback
the function
.
Upvotes: 3