1.1.1.4.9 DRV_PLC_PHY_ExceptionCallbackRegister Function

C

void DRV_PLC_PHY_ExceptionCallbackRegister (
    const DRV_HANDLE handle,
    const DRV_PLC_PHY_EXCEPTION_CALLBACK callback, 
    const uintptr_t context 
);

Summary

Allows a client to set an exception event handling function for the driver to call back when some error occurs through PLC transceiver communication.

Description

This function allows a client to register a PLC exception event handling function for the driver to call back when a communication SPI error occurs.

The event handler should be set before using the PLC transceiver in order to capture error 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

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

void APP_PLC_Exception_callback(DRV_PLC_PHY_EXCEPTION_OBJ *exceptionObj, 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;

    // Exception 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_ExceptionCallbackRegister( myHandle, APP_PLC_Exception_callback, (uintptr_t)&myAppObj );

Remarks

None.