1.1.1.4.7 DRV_PLC_PHY_TxCfmCallbackRegister Function
C
void DRV_PLC_PHY_TxCfmCallbackRegister (
const DRV_HANDLE handle,
const DRV_PLC_PHY_TX_CFM_CALLBACK callback,
const uintptr_t context
);Summary
Allows a client to set a data confirm event handling function for the driver to call back when the requested transmission has finished.
Description
This function allows a client to register a PLC data confirm event handling function for the driver to call back when a data confirmation PLC event occurs.
The event handler should be set before the client submits any transmission requests that could generate events. 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
| Param | Description |
|---|---|
| handle | A valid open-instance handle, returned from the driver's open routine |
| callback | Pointer to the callback function |
| context | The 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 the transmission is finished
void APP_PLC_Data_Cfm_callback(DRV_PLC_PHY_DATA_CFM_OBJ *cfmObj, 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;
if (cfmObj->result == DRV_PLC_PHY_TX_RESULT_PROCESS)
{
// This means the data was transferred successfully.
}
else
{
// Error handling here.
}
}
// myAppObj is an application specific state data object.
MY_APP_OBJ myAppObj;
DRV_PLC_PHY_TRANSMISSION_OBJ myTransmissionObj;
// 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_TxCfmCallbackRegister( myHandle, APP_PLC_Data_Cfm_callback, (uintptr_t)&myAppObj );
DRV_PLC_PHY_TxRequest(myHandle, myTransmissionObj);Remarks
None.
