1.1.1.4.8 DRV_PLC_PHY_DataIndCallbackRegister Function

C

void DRV_PLC_PHY_DataIndCallbackRegister (
    const DRV_HANDLE handle,
    const DRV_PLC_PHY_DATA_IND_CALLBACK callback, 
    const uintptr_t context 
);

Summary

Allows a client to set a data indication event handling function for the driver to call back when a packet reception has finished.

Description

This function allows a client to register a PLC data indication event handling function for the driver to call back when a data reception PLC event occurs.

Before this callback is set, any received frame by the PLC transceiver will not be notified. 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).

Precondition

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

Parameters

ParamDescription
handleA 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

// Event is received when a frame is received
void APP_PLC_Data_Ind_callback(DRV_PLC_PHY_DATA_IND_OBJ *indObj, uintptr_t context)
{
    // 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 *) context;

    // Reception handling here.

}
    
// myAppObj is an application specific state data object.
MY_APP_OBJ myAppObj;

// myHandle is the handle returned from DRV_PLC_PHY_Open API.

// Client registers a data confirm callback with driver. This is done once

DRV_PLC_PHY_DataIndCallbackRegister( myHandle, APP_PLC_Data_Ind_callback, (uintptr_t)&myAppObj );

// Event is received when PLC data is receiving.

Remarks

None.