Recently, I was studying the source file of I2C from the code examples of LPC177x_8x controller. I came across
void (*callback)(void); /**< Pointer to Call back function when transmission complete. "used in interrupt transfer mode" */
I wonder, how a function pointer can be used in a ISR to go to the CallBack function. i mean the Interrupt may be generated on any function and the hardware stores(PUSH) the return address on to stack and will POP back on the completion of ISR. Note: the function pointer is the member of structure.
The source code file consists of a interrupt handler function [ void I2C_MasterHandler(uint8_t i2cId) ], which can be called from any I2C interrupt handler, passing argument to the function.
PS: No I2C example using interrupt handler is present in the code bundle (or TarBall).
it will do the same as
void func x(); ISR { ... x(); ... }
which, although not generally recommended, works just fine
Erik
The intention is that you make a fucntion void callback (void) { xmitCompleteFlag = TRUE; }
I, when seing similar change the supplied code from callback(); to xmitCompleteFlag = TRUE;
I think the intention is that you have many different callback functions. So depending on which chip you communicate with, you supply a suitable callback function.
That is how I have been doing it when using any framework that have had such callback support.