1.9.10.9 FCW_CallbackRegister Function
C
void FCW_CallbackRegister( FCW_CALLBACK callback, uintptr_t context )
Summary
Sets the pointer to the function (and it's context) to be called when the operation is complete.
Description
This function sets the pointer to a client function to be called "back" when the FCW has completed an operation and is ready to receive new command.
It also passes a context value that is passed into the callback function when it is called. This function is available only when the library is generated with interrupt option (in MHC) enabled.
Precondition
Interrupt option in MHC should have been enabled
Parameters
Param | Description |
---|---|
callback | A pointer to a function with a calling signature defined by the FCW_CALLBACK data type. |
context | A value (usually a pointer) passed (unused) into the function identified by the callback parameter. |
Returns
None.
Example
typedef struct { bool operationComplete; } APP_DATA; // Callback is called when an operation completes. void APP_FCWCallback(uintptr_t context) { APP_DATA * appData = (APP_DATA *)context; appData->operationComplete = true; } // Function calls in main thread. APP_DATA myAppData; myAppData.operationComplete = false; // Register the callback FCW_CallbackRegister(APP_FCWCallback, &myAppData); // Perform some operation. FCW_PageErase(SOME_PAGE_ALIGNED_ADDRESS); // Now wait for the operation to complete. while(!myAppData.operationComplete);
Remarks
The context value may be set to NULL if it is not required. Note that the value of NULL will still be passed to the callback function.
To disable the callback function, pass a NULL for the callback parameter. See the FCW_CALLBACK type definition for additional information.