USB Libraries Help > USB Host Libraries > USB CDC Host Library > Library Interface > a) Client Access Functions > USB_HOST_CDC_AttachEventHandlerSet Function
MPLAB Harmony USB Stack
USB_HOST_CDC_AttachEventHandlerSet Function

This function will set an attach event handler. The attach event handler will be called when a CDC device has been attached. The context will be returned in the event handler. This function should be called before the bus has been enabled.

C
USB_HOST_CDC_RESULT USB_HOST_CDC_AttachEventHandlerSet(
    USB_HOST_CDC_ATTACH_EVENT_HANDLER eventHandler, 
    uintptr_t context
);
Preconditions

None.

Parameters
Parameters 
Description 
eventHandler 
pointer to the attach event handler
 
context 
an application defined context that will be returned in the event handler. 
Returns

USB_HOST_CDC_RESULT_SUCCESS - if the attach event handler was registered successfully. 

USB_HOST_CDC_RESULT_FAILURE - if the number of registered event handlers has exceeded USB_HOST_CDC_ATTACH_LISTENERS_NUMBER.

Remarks

Function should be called before USB_HOST_BusEnable() function is called.

Example