DRV_AT24_EVENT_HANDLER Typedef

C

typedef void (*DRV_AT24_EVENT_HANDLER )( DRV_AT24_TRANSFER_STATUS event, uintptr_t context );

Summary

Pointer to a AT24 Driver Event handler function

Description

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

The parameters and return values are described here and a partial example implementation is provided.

Parameters

ParamDescription
eventIdentifies the type of event
contextValue identifying the context of the application that registered the event handling function.

Returns

None.

Example

void APP_MyTransferEventHandler( DRV_AT24_TRANSFER_STATUS event, uintptr_t context )
{
    MY_APP_DATA_STRUCT* pAppData = (MY_APP_DATA_STRUCT *) context;

    switch(event)
    {
        case DRV_AT24_TRANSFER_STATUS_COMPLETED:

        // Handle the transfer complete event.
        break;

        case DRV_AT24_TRANSFER_STATUS_ERROR:
        default:

        // Handle error.
        break;
    }
}

Remarks

If the event is DRV_AT24_TRANSFER_STATUS_COMPLETED, it means that the data was transferred successfully.

If the event is DRV_AT24_TRANSFER_STATUS_ERROR, it means that the data was not transferred successfully.

The context parameter contains the handle to the client context, provided at the time the event handling function was registered using the DRV_AT24_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 buffer add request. The event handler function executes in the driver's interrupt context.

It is recommended of the application to not perform process intensive or blocking operations with in this function. The DRV_AT24_Read, DRV_AT24_Write and DRV_AT24_PageWrite functions can be called in the event handler to submit a new request to the driver.