1.32.16.13 NVMCTRL_MainCallbackRegister Function

C

void NVMCTRL_MainCallbackRegister( NVMCTRL_CALLBACK callback, uintptr_t context )

Summary

Sets the pointer to the function (and it's context) to be called when an operation on the Flash is complete, provided the corresponding interrupt is enabled.

Description

This function sets the pointer to a client function to be called when the NVMCTRL 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 theNVMCTRL_CALLBACK data type.
context A value (usually a pointer) passed (unused) into the functionidentified by the callback parameter.

Returns

None.

Example

uintptr_t flash_context;
// Callback is called when an operation completes.
void flash_cb(uint8_t int_flags, uintptr_t context)
{
    //Code to check int_flags and decide next action
}

NVMCTRL_Initialize();

// Register the callback
NVMCTRL_MainCallbackRegister(flash_cb, flash_context);

// Perform some operation.
NVMCTRL_PageWrite(data_to_fill, TEST_ADDRESS);

// The callback 'flash_cb' will be invoked after the above operation is done.

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 NVMCTRL_CALLBACK type definition for additional information.