Jump to main content

##

# 3.1.2 USB Host Library - Application Interaction

Note: Additional information on the tests conducted on Flash devices (i.e., Pen Drives) and a list of USB application configurations is available in the USB Demonstrations section.

The following figure highlights the steps that the application must follow to use the USB Host Library.

The USB Host stack is initialized in the MPLAB Harmony System Initialization function. The Host Stack requires the Timer System Service and USB Driver. So these must be initialized as well. Note that the figure refers to a general USB Driver. The application may use the USBFS Driver (DRV_USBFS) for PIC32MX microcontroller, USBHS Driver (DRV_USBHS) for PIC32MZ microcontroller or the DRV_USBHS_V1 driver for SAME microcontrollers. The Timer and USB module interrupt priorities must be configured.

The USB Host layer, the USB Driver and the Timer System Service tasks must be called in the MPLAB Harmony System Tasks Routine. This ensures that the state machines of these module stays updated. If the USB Driver and the Timer driver have been configured for interrupt operation, then their corresponding interrupt tasks routines should be called in the corresponding module interrupt service routines.

The application state machine must first set the Host Layer event handler and then enable the bus. Enabling the bus will enable device detection and the Host Layer will enumerate attached devices. The application can query for attached devices and perform operations on attached devices.