Question:
When callback occurs?
Answer:
Callbacks are called by the driver when one of the following event types occurs
1. A read or write transaction is completed.
The argument pArg that is passed back is the address of the buffer. At this point the application owns the buffer.
2. An error has occurred during the read or write transaction.
pArg contains the error code(s) for the driver.
Each driver documents the various “events” that can occur and cause a callback. It is the application's responsibility to process the event in the callback and take an appropriate action. If the cause of the callback is a transaction complete event, the application must synchronize the event with the application. Synchronization can be accomplished via a simple global variable or, in the context of an RTOS, via a semaphore. Callbacks operate at interrupt level, so care must be taken to minimize the amount of code executed inside of the interrupt.