1.1.1.2.2 DRV_AK4953_CommandEventHandlerSet Function

void DRV_AK4953_CommandEventHandlerSet

(

DRV_HANDLE handle,

const DRV_AK4953_COMMAND_EVENT_HANDLER eventHandler, const uintptr_t contextHandle

)

Summary

This function allows a client to identify a command event handling function for the driver to call back when the last submitted command have finished.

Description

This function allows a client to identify a command event handling function for the driver to call back when the last submitted command have finished.

When a client calls DRV_AK4953_BufferAddWrite function, it is provided with a handle identifying the buffer that was added to the driver's buffer queue. The driver will pass this handle back to the client by calling "eventHandler" function when the buffer transfer has completed.

The event handler should be set before the client performs any "AK4953 CODEC Specific Client Routines" operations that could generate events. The event handler once set, persists until the client closes the driver or sets another event handler (which could be a "NULL" pointer to indicate no callback).

Preconditions

The DRV_AK4953_Initialize routine must have been called for the specified AK4953 driver instance.

DRV_AK4953_Open must have been called to obtain a valid opened device handle.

Parameters

ParametersDescription
handleA valid open-instance handle, returned from the driver's open routine
eventHandlerPointer to the event handler function.
contextThe value of parameter will be passed back to the client unchanged, when the eventHandler function is called. It can be used to identify any client specific data object that identifies the instance of the client module (for example, it may be a pointer to the client module's state structure).

Returns

None.

Remarks

If the client does not want to be notified when the command has completed, it does not need to register a callback.

Example

MY_APP_OBJ myAppObj;

uint8_t mybuffer[MY_BUFFER_SIZE]; DRV_AK4953_BUFFER_HANDLE bufferHandle;

_\/\/ myAK4953Handle is the handle returned \/\/ by the DRV_AK4953_Open function._

_\/\/ Client registers an event handler with driver_

DRV_AK4953_CommandEventHandlerSet(myAK4953Handle,

APP_AK4953CommandEventHandler, (uintptr_t)&myAppObj);

DRV_AK4953_DeEmphasisFilterSet(myAK4953Handle, DRV_AK4953_DEEMPHASIS_FILTER_44_1KHZ)

_\/\/ Event is received when \/\/ the buffer is processed._ void APP_AK4953CommandEventHandler(uintptr_t contextHandle) { _\/\/ contextHandle points to myAppObj._ switch(event) { _\/\/ Last Submitted command is completed._

_\/\/ Perform further processing here_

}

}

C

void DRV_AK4953_CommandEventHandlerSet(DRV_HANDLE handle, const DRV_AK4953_COMMAND_EVENT_HANDLER eventHandler, const uintptr_t contextHandle);