1.1.4.4.8 DRV_RF215_TxCfmCallbackRegister Function

C

void DRV_RF215_TxCfmCallbackRegister (
    DRV_HANDLE drvHandle,
    const DRV_RF215_TX_CFM_CALLBACK callback,
    uintptr_t context
);

Summary

Allows a client to set an event handling function for the driver to call back when a transmission request has finished.

Description

This function allows a client to register a RF215 transmit confirm event handling function for the driver to call back when a transmission request has finished, successfully or not.

The callback should be registered immediately after opening the driver. Before this callback is set, any transmission confirmation will not be notified.

Precondition

DRV_RF215_Open must have been called to obtain a valid opened driver handle.

Parameters

ParamDescription
drvHandleA valid open-instance handle, returned from the driver's open routine.
callbackPointer to the callback function.
contextThe value of this parameter will be passed back to the client unchanged, when the callback function is called.

Returns

None.

Example

static void _APP_RF_TxCfmCb (
    DRV_RF215_TX_HANDLE txHandle,
    DRV_RF215_TX_CONFIRM_OBJ *cfmObj,
    uintptr_t ctxt
)
{
    // The context handle was set to an application specific object
    // It is now retrievable easily in the event handler
    MY_APP_OBJ myAppObj = (MY_APP_OBJ *) ctxt;

    // Transmission confirmation handling here.
}

SYS_MODULE_OBJ sysObjDrvRf215; // Returned from DRV_RF215_Initialize
SYS_STATUS drvRf215Status;
DRV_HANDLE drvRf215Handle;
MY_APP_OBJ myAppObj; // Application specific data object

drvRf215Status = DRV_RF215_Status(sysObjDrvRf215);
if (drvRf215Status == SYS_STATUS_READY)
{
    // This means now the driver can be opened using DRV_RF215_Open routine
    drvRf215Handle = DRV_RF215_Open(DRV_RF215_INDEX_0, RF215_TRX_ID_RF09);
    if (drvRf215Handle != DRV_HANDLE_INVALID)
    {
        // Driver opened successfully. Register callback
        DRV_RF215_TxCfmCallbackRegister(drvRf215Handle, _APP_RF_TxCfmCb,
            (uintptr_t) myAppObj);
    }
}

Remarks

The callback once set, persists until the client closes the driver or sets another callback (which could be a "NULL" pointer to indicate no callback).