Gadget Driver
A device driver is a software program that implements at the operating system kernel’s mode and communities between the hardware devices attached to the host platform and applications that wish to access the device. A USB gadget driver is a device driver for devices that are connected to the gadget platform via USB and support data transfer on this bus. The following figure shows the general architecture of the USB gadget driver on embedded platform;

Figure: General Architecture of USB HID Class Gadget Driver
USB Device Controller Hardware
The USB controller driver handle low level operation on the USB device to select the speed of communication and configuration of control, interrupt and data pipes and also provide gadget API(s) and data structure to the upper layer for various operations .
USB gadget driver for HID class
This layer will provide to communicate descriptors with the host . The layer will enable pipes for various operations. The character driver will also be implemented on this layer. The character driver will enable the user application to communicate reports between host and device.
Operating system Native wrapper
The layer provides various API(s) and data structures to different layers of HID class gadget driver
Software Architecture of USB Gadget Driver
The following figure shows the software level architecture design of the USB HID class driver;

Figure 2: Software level architecture design