usb_device.h

Microchip USB Device Library

USB Device Library Help
usb_device.h

USB Device header file 

This file, with its associated C source file, provides the main substance of the USB device side stack. These files will receive, transmit, and process various USB commands as well as take action when required for various events that occur on the bus. 

This file is located in the "<Install Directory>\Microchip\Include\USB" directory. 

When including this file in a new project, this file can either be referenced from the directory in which it was installed or copied directly into the user application folder. If the first method is chosen to keep the file located in the folder in which it is installed then include paths need to be added so that the library and the application both know where to reference each others files. If the application folder is located in the same folder as the Microchip folder (like the current demo folders), then the following include paths need to be added to the application's project: 

..\Include 

..\..\Include 

..\..\MicrochipInclude 

..\..\<Application Folder> 

..\..\..\<Application Folder> 

If a different directory structure is used, modify the paths as required. An example using absolute paths instead of relative paths would be the following: 

C:\Microchip Solutions\Microchip\Include 

C:\Microchip Solutions\My Demo Application

Functions
 
Name 
Description 
 
This callback is called when a SOF packet is received by the host. (optional) 
 
This function is called whenever a request comes over endpoint 0 (the control endpoint) that the stack does not know how to handle. 
 
This function is called whenever a EP0 data packet is received. (optional) 
 
This callback is called whenever a USB error occurs. (optional) 
 
This function is called whenever the device receives a SET_CONFIGURATION request. 
 
This function should be called to initiate a remote wakeup. (optional) 
 
This callback is called when a SET_DESCRIPTOR request is received (optional) 
 
Call back that is invoked when a USB suspend is detected. 
 
This call back is invoked when a wakeup from USB suspend is detected. 
 
This function initializes the device stack it in the default state. The USB module will be completely reset including all of the internal variables, registers, and interrupt flags. 
 
This function is the main state machine of the USB device side stack. This function should be called periodically to receive and transmit packets through the stack. This function should be called preferably once every 100us during the enumeration process. After the enumeration process this function still needs to be called periodically to respond to various situations on the bus but is more relaxed in its time requirements. This function should also be called at least as fast as the OUT data expected from the PC. 
 
This function will enable the specified endpoint with the specified options 
Macros
 
Name 
Description 
 
Default Value (Bit 7 is set) 
 
_RWU 
Remote Wakeup (Supports if set) 
 
Self-powered (Supports if set) 
 
Address is the state in which the device has its own specific address on the bus. This defintions is a return value of the function USBGetDeviceState(). 
 
Address pending state is not an official state of the USB defined states. This state is internally used to indicate that the device has received a SET_ADDRESS command but has not received the STATUS stage of the transfer yet. The device is should not switch addresses until after the STATUS stage is complete. This defintions is a return value of the function USBGetDeviceState() 
 
Attached is the state in which the device is attached ot the bus but the hub/port that it is attached to is not yet configured. This defintions is a return value of the function USBGetDeviceState() 
 
Configured is the state where the device has been fully enumerated and is operating on the bus. The device is now allowed to excute its application specific tasks. It is also allowed to increase its current consumption to the value specified in the configuration descriptor of the current configuration. This defintions is a return value of the function USBGetDeviceState(). 
 
Default state is the state after the device receives a RESET command from the host. This defintions is a return value of the function USBGetDeviceState() 
 
Detached is the state in which the device is not attached to the bus. When in the detached state a device should not have any pull-ups attached to either the D+ or D- line. This defintions is a return value of the function USBGetDeviceState() 
 
Powered is the state in which the device is attached to the bus and the hub/port that it is attached to is configured. This defintions is a return value of the function USBGetDeviceState() 
 
USB_HANDLE is a pointer to an entry in the BDT. This pointer can be used to read the length of the last transfer, the status of the last transfer, and various other information. Insure to initialize USB_HANDLE objects to NULL so that they are in a known state during their first usage. 
 
This function will return the current state of the device on the USB. This function should return CONFIGURED_STATE before an application tries to send information on the bus. 
 
This function indicates if remote wakeup has been enabled by the host. Devices that support remote wakeup should use this function to determine if it should send a remote wakeup. 
 
Checks to see if the input handle is busy 
 
Retrieves the address of the destination buffer of the input handle 
 
Retrieves the length of the destination buffer of the input handle 
 
This function indicates if this device is currently suspended. When a device is suspended it will not be able to transfer data over the bus. 
MCHPFSUSB Device Library > Stack > Files > usb_device.h
Microchip MCHPFSUSB v2.3 - Sept 20, 2008
Copyright © 2008 Microchip Technology, Inc.  All rights reserved.