1.1.4.4.9 DRV_RF215_SetChannelCallbackRegister Function

C

void DRV_RF215_SetChannelCallbackRegister (
    DRV_HANDLE drvHandle,
    const DRV_RF215_SET_CHANNEL_CALLBACK callback,
    uintptr_t context
);

Summary

Allows a client to set an event handling function for the driver to call back when frequency channel is updated.

Description

This function allows a client to register a an event handling function for the driver to call back when frequency channel is updated(confirmation of DRV_RF215_SetChannelRequest).

The callback should be registered immediately after opening the driver.

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_SetChannelCb(DRV_RF215_TX_RESULT result, 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;

    // Set channel 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_SetChannelCallbackRegister(drvRf215Handle,
            APP_SetChannelCb, (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).

This function is only available if "Frequency hopping support" is enabled via MCC.