usb_config.h

Microchip USB Device Library

USB Device Library Help
usb_config.h

usb_config.h is a file used to configure the MCHPFSUSB stack. This file provides compile time selection of options provided by the stack. This file defines constants needed by the stack and various function drivers. 

This section will detail the definitions required by the stack. Additional definitions may be required by the function drivers. Please see the Files topic of the Function Drivers section for more details about function driver specific definitions. 

Please note that the usb_config.h file can also be generated using the USBConfig.exe tool provided in the "<Install Directory>\USB Tools\USBConfig Tool" directory. 

USB_USE_DEVICE - This enables the stack to run in device mode and must be included in any project using the USB device side firmware. 

#define USB_USE_DEVICE 

USB_EP0_BUFF_SIZE - this defines the size of the endpoint 0 buffer. Using larger options take more SRAM, but does not provide much advantage in most types of applications. Exceptions to this, are applications that use EP0 IN or OUT for sending large amounts of application related data. The available options are 8, 16, 32, or 64. 

#define USB_EP0_BUFF_SIZE 8 // Valid Options: 8, 16, 32, or 64 bytes. 

USB_MAX_NUM_INT - this defines the maximum interface number used by the device. If the device uses multiple configurations then this is the largest interface number in any of the configurations. 

#define USB_MAX_NUM_INT 1 // For tracking Alternate Setting 

USB_USER_DEVICE_DESCRIPTOR - this defines a pointer to the device descriptor. If this definition is not defined then the application must define a ROM variable named device_dsc that holds the device descriptor. 

#define USB_USER_DEVICE_DESCRIPTOR &device_dsc 

USB_USER_DEVICE_DESCRIPTOR_INCLUDE - this defines any prototype that needs to be included into the library files in order to access the variables/functions required by the USB_USER_DEVICE_DESCRIPTOR option. 

Example where USB_USER_DEVICE_DESCRIPTOR is a ROM variable: 

#define USB_USER_DEVICE_DESCRIPTOR &device_dsc 

#define USB_USER_DEVICE_DESCRIPTOR_INCLUDE extern ROM USB_DEVICE_DESCRIPTOR device_dsc 

Example where USB_USER_DEVICE_DESCRIPTOR is a function: 

#define USB_USER_DEVICE_DESCRIPTOR myDeviceDescriptorFunction() 

#define USB_USER_DEVICE_DESCRIPTOR_INCLUDE ROM BYTE* myDeviceDescriptorFunction(void) 

USB_USER_CONFIG_DESCRIPTOR - this defines a pointer to the configuration descriptor. If this definition is not defined then the application must define a ROM variable named USB_CD_Ptr that holds the configuration descriptor. 

USB_USER_CONFIG_DESCRIPTOR_INCLUDE - this defines any prototype that needs to be included into the library files in order to access the variables/functions required by the USB_USER_DEVICE_DESCRIPTOR option. 

Example where USB_USER_CONFIG_DESCRIPTOR is a ROM variable: 

#define USB_USER_CONFIG_DESCRIPTOR USB_CD_Ptr 

#define USB_USER_CONFIG_DESCRIPTOR_INCLUDE extern ROM BYTE USB_CD_Ptr[] 

Example where USB_USER_CONFIG_DESCRIPTOR is a function: 

#define USB_USER_CONFIG_DESCRIPTOR myConfigDescriptorFunction() 

#define USB_USER_CONFIG_DESCRIPTOR_INCLUDE ROM BYTE* myConfigDescriptorFunction(void) 

 

USB_PING_PONG_MODE - This defines the ping pong mode of operation. When ping ponging is enabled, the device is capable of preparing up to two buffers to send/receive per endpoint direction at any given point of time. This can be used to increase throughput but requires additional RAM. USB_PING_PONG_MODE must be defined as one of the following options:

  • USB_PING_PONG__NO_PING_PONG
  • USB_PING_PONG__FULL_PING_PONG
  • USB_PING_PONG__EP0_OUT_ONLY
  • USB_PING_PONG__ALL_BUT_EP0
Example: 

#define USB_PING_PONG_MODE USB_PING_PONG__FULL_PING_PONG 

Please note that not every device can support all ping pong modes. Please refer to the device datasheet for available options. Here are some limitations:

  • PIC18F4550 family rev A3 devices do not support USB_PING_PONG__ALL_BUT_EP0
  • PIC32MX460F512L family devices only support USB_PING_PONG__FULL_PING_PONG
USB_POLLING - this defintion tells the stack that it is going to be polled. The user is responsible for calling USBDeviceTasks() frequently enough to keep the USB stack running. Currently this is the only available option. 

#define USB_POLLING 

USB_PULLUP_OPTION - This option tells the USB stack if it should enable the internal pull-up resistors or not. There are two possible options:

  • USB_PULLUP_ENABLE
  • USB_PULLUP_DISABLE
Example: 

#define USB_PULLUP_OPTION USB_PULLUP_ENABLE 

USB_TRANSCEIVER_OPTION - This option allows the user to specify if they wish to use the internal or external USB transceiver module. The available options are:

  • USB_INTERNAL_TRANSCEIVER
  • USB_EXTERNAL_TRANSCEIVER
Example: 

#define USB_TRANSCEIVER_OPTION USB_INTERNAL_TRANSCEIVER 

USB_SPEED_OPTION - This option allows users to select the USB speed that want to operate. The available options are the following:

  • USB_FULL_SPEED
  • USB_LOW_SPEED
Example: 

#define USB_SPEED_OPTION USB_FULL_SPEED 

Please note that not all options are available on every device. Please refer to the appropriate device datasheet for more information about a devices capabilities. Some of the known limitations are the following:

  • PIC24FJ256GB110 family devices only support USB_FULL_SPEED
  • PIC32MX460F512L family devices only support USB_FULL_SPEED

MCHPFSUSB Device Library > Stack > Files > usb_config.h
Microchip MCHPFSUSB v2.3 - Sept 20, 2008
Copyright © 2008 Microchip Technology, Inc.  All rights reserved.