1.21.12.10 NVM_CALLBACK Typedef
C
typedef void (*NVM_CALLBACK)(uintptr_t context);
Summary
Defines the data type and function signature for the NVM peripheral callback function.
Description
This data type defines the function signature for the NVM peripheral callback function. The NVM peripheral library will call back the client's function with this signature when an on-going erase or write operation has completed and the NVM is ready to accept a new operation request. A function of this type should be registered by calling the NVM_CallbackRegister function.
Parameters
Param | Description |
---|---|
context | Allows the caller to provide a context value (usually a pointer to the callers context for multi-instance clients). |
Returns
None.
Example
typedef struct { bool operationComplete; } APP_DATA; // Callback is called when an operation completes. void APP_NVMCallback(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 NVM_CallbackRegister(APP_NVMCallback, &myAppData); // Perform some operation. NVM_PageErase(0x9D100000); // Now wait for the operation to complete. while(!myAppData.operationComplete);
Remarks
The callback feature is only available when the library was generated with interrupt option (in MHC) enabled.