1.1.3.4.29 DRV_MEMORY_TRANSFER_HANDLER Typedef

C

typedef SYS_MEDIA_EVENT_HANDLER DRV_MEMORY_TRANSFER_HANDLER;

Summary

Pointer to a Memory Driver Event handler function

Description

This data type defines the required function signature for the Memory event handling callback function. A client must register a pointer to an event handling function whose function signature (parameter and return value types) match the types specified by this function pointer in order to receive event calls back from the driver.

If the event is DRV_MEMORY_EVENT_COMMAND_COMPLETE, it means that the requested operation was completed successfully.

If the event is DRV_MEMORY_EVENT_COMMAND_ERROR, it means that the scheduled operation was not completed successfully.

The context parameter contains the handle to the client context, provided at the time the event handling function was registered using the DRV_MEMORY_TransferHandlerSet function. This context handle value is passed back to the client as the "context" parameter. It can be any value necessary to identify the client context or instance (such as a pointer to the client's data) instance of the client that made the read/write/erase request.

Parameters

ParamDescription
eventIdentifies the type of event
commandHandleHandle returned from the Read/Write/Erase/EraseWrite requests
contextValue identifying the context of the application that registered the event handling function

Returns

None.

Example

void appTransferHandler
(
    DRV_MEMORY_EVENT event,
    DRV_MEMORY_COMMAND_HANDLE commandHandle,
    uintptr_t context
)
{
    switch(event)
    {
        case DRV_MEMORY_EVENT_COMMAND_COMPLETE:
        {
            xfer_done = true;
            break;
        }
        
        case DRV_MEMORY_EVENT_COMMAND_ERROR:
        {
            // Handle Error
            break;
        }
        
        default:
        {
            break;
        }
    }
}

DRV_MEMORY_TransferHandlerSet(memoryHandle, appTransferHandler, (uintptr_t)NULL);

Remarks

Used in Asynchronous mode of operation.

Refer sys_media.h for definition of SYS_MEDIA_EVENT_HANDLER.