USB Libraries Help > USB Device Libraries > USB Device Layer Library > Using the Library > How the Library Works > Library Initialization > Device Layer Task Routines
MPLAB Harmony USB Stack
Device Layer Task Routines

A call to the USB_DEVICE_Tasks() function should be placed in the SYS_Tasks() function. This will ensure that this function is called periodically. The USB_DEVICE_Tasks() function in turn calls the tasks routines of the applicable functions drivers. The following code shows an example of how the USB_DEVICE_Tasks() function is called in the SYS_Tasks() function.

void SYS_Tasks ( void )
{
    /* Device layer tasks routine. Function Driver tasks gets called
     * from device layer tasks */

    USB_DEVICE_Tasks(sysObjects.usbDevObject);

    /* Call the application's tasks routine */
    APP_Tasks ();
}