Jump to main content

##

# 1.1.7.4.21 DRV_SDSPI_EVENT_HANDLER Typedef

## C

    typedef SYS_MEDIA_EVENT_HANDLER DRV_SDSPI_EVENT_HANDLER;

## Summary

Pointer to a SDSPI Driver Event handler function

## Description

This data type defines the required function signature for the SDSPI 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_SDSPI_EVENT_COMMAND_COMPLETE, it means that the write or a erase operation was completed successfully.

If the event is DRV_SDSPI_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_SDSPI_EventHandlerSet 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

Param | Description
--- | ---
event | Identifies the type of event
commandHandle | Handle returned from the Read/Write requests
context | Value identifying the context of the application that registered the event handling function

## Returns

None.

## Example

    void APP_SDSPIEventHandler(
        DRV_SDSPI_EVENT event,
        DRV_SDSPI_COMMAND_HANDLE commandHandle,
        uintptr_t contextHandle
    )
    {
        // contextHandle points to myAppObj.

        switch(event)
        {
            case DRV_SDSPI_EVENT_COMMAND_COMPLETE:
            {
                // This means the data was transferred successfully
                break;
            }

            case DRV_SDSPI_EVENT_COMMAND_ERROR:
            {
                // Error handling here
                break;
            }

            default:
            {
                break;
            }
        }
    }

## Remarks

Refer sys_media.h for definition of SYS_MEDIA_EVENT_HANDLER.