/Designs/Tools/I2C-PIC-USB/SW/PIC18F4550/usbconfig.h
44,86 → 44,29
//////// end config ///////////////////////////////////////////////////////////
 
 
//#DEFINE USB_CONFIG_BUS_POWER FALSE
//#define USB_USE_FULL_SPEED FALSE
 
#DEFINE USB_HID_DEVICE TRUE //Tells the CCS PIC USB firmware
//to include HID handling code.
#DEFINE USB_HID_DEVICE FALSE //Tells the CCS PIC USB firmware
//Enable to include HID handling code.
 
//turn on EP1 for IN interrupt transfers. (IN = PIC -> PC)
#define USB_EP1_TX_ENABLE USB_ENABLE_INTERRUPT
//turn on EP0 for IN control transfers. (IN = PIC -> PC)
#define USB_EP0_TX_ENABLE USB_ENABLE_CONTROL
#define USB_EP0_TX_SIZE 64 //max packet size of this endpoint
 
#define USB_EP1_TX_SIZE 8 //max packet size of this endpoint
#define USB_EP0_RX_ENABLE USB_ENABLE_CONTROL
#define USB_EP0_RX_SIZE 64 //max packet size of this endpoint
 
#include <usb.h>
//#define USB_EP1_TX_ENABLE USB_ENABLE_CONTROL
//#define USB_EP1_TX_SIZE 8 //max packet size of this endpoint
 
//////////////////////////////////////////////////////////////////
///
/// HID Report. Tells HID driver how to handle and deal with
/// received data. HID Reports can be extremely complex,
/// see HID specifcation for help on writing your own.
///
/// This examples configures HID driver to take received data
/// as mouse x, y and button data.
///
//////////////////////////////////////////////////////////////////
//#define USB_EP1_RX_ENABLE USB_ENABLE_CONTROL
//#define USB_EP1_RX_SIZE 8 //max packet size of this endpoint
 
const char USB_CLASS_SPECIFIC_DESC[] =
{
0x05, 0x01, // usage page (generic desktop Choose the usage page "mouse" is on
0x09, 0x02, // usage (mouse) Device is a mouse
0xA1, 0x01, // collection (application) This collection encompasses the report format
0x09, 0x01, // usage (pointer) Choose the key code usage page
0xA1, 0x00, // collection (physical) Physical collection
0x05, 0x09, // usage page (buttons) Choose the “button” usage page
0x19, 0x01, // usage minimum (1) There are three buttons
0x29, 0x03, // usage maximum (3)
0x15, 0x00, // logical minimum (0) Each button is represented by one bit
0x25, 0x01, // logical maximum (1)
0x95, 0x03, // report count (3) Three reports, one bit each
0x75, 0x01, // report size (1)
0x81, 0x02, // input (data, variable, absolute) Defined bits above are data bits
0x95, 0x01, // report count (1) One report, five bits in length
0x75, 0x05, // report size (5)
0x81, 0x01, // input (constant) Bit stuff to fill byte
0x05, 0x01, // usage page (generic desktop) Choose the usage pare “X” and “Y” are on
0x09, 0x30, // usage (X) X direction of pointer
0x09, 0x31, // usage (Y) Y direction of pointer
0x09, 0x38 // usage (wheel)
0x15, 0x81, // logical minimum (-127) Range of report data is -127 to 127
0x25, 0x7F, // logical maximum (127)
0x75, 0x08, // report size (8) Two reports, eight bits each
0x95, 0x03, // report count (3)
0x81, 0x06, // input (data, variable, absolute) Defined bits above are data bits
0xC0, // end collection End physical collection
0xC0 // end collection End application collection
};
 
//if a class has an extra descriptor not part of the config descriptor,
// this lookup table defines where to look for it in the const
// USB_CLASS_SPECIFIC_DESC[] array.
//first element is the config number (if your device has more than one config)
//second element is which interface number
//set element to 0xFFFF if this config/interface combo doesn't exist
const int16 USB_CLASS_SPECIFIC_DESC_LOOKUP[USB_NUM_CONFIGURATIONS][1] =
{
//config 1
//interface 0
0
};
 
//if a class has an extra descriptor not part of the config descriptor,
// this lookup table defines the size of that descriptor.
//first element is the config number (if your device has more than one config)
//second element is which interface number
//set element to 0xFFFF if this config/interface combo doesn't exist
const int16 USB_CLASS_SPECIFIC_DESC_LOOKUP_SIZE[USB_NUM_CONFIGURATIONS][1] =
{
//config 1
//interface 0
sizeof(USB_CLASS_SPECIFIC_DESC)
};
#include <usb.h>
 
 
 
//////////////////////////////////////////////////////////////////
///
/// start config descriptor
132,7 → 75,7
///
//////////////////////////////////////////////////////////////////
 
#DEFINE USB_TOTAL_CONFIG_LEN 34 //config+interface+class+endpoint
#DEFINE USB_TOTAL_CONFIG_LEN 32 //config+interface+class+endpoint
 
const char USB_CONFIG_DESC[] = {
//IN ORDER TO COMPLY WITH WINDOWS HOSTS, THE ORDER OF THIS ARRAY MUST BE:
160,27 → 103,35
USB_DESC_INTERFACE_TYPE, //constant INTERFACE (INTERFACE 0x04) =11
0x00, //number defining this interface (IF we had more than one interface) ==12
0x00, //alternate setting ==13
1, //number of endpoints, except 0 ==14
0x03, //class code, 03 = HID ==15
0x01, //subclass code //boot ==16
0x02, //protocol code ==17
2, //number of endpoints, except 0 ==14
0xff, //class code, 03 = HID ==15
0xff, //subclass code //boot ==16
0xff, //protocol code ==17
0x00, //index of string descriptor for interface ==18
 
//class descriptor 1 (HID)
USB_DESC_CLASS_LEN, //length of descriptor ==19
/* USB_DESC_CLASS_LEN, //length of descriptor ==19
USB_DESC_CLASS_TYPE, //dscriptor type (0x21 == HID) ==20
0x00,0x01, //hid class release number (1.0) (try 1.10) ==21,22
0x00, //localized country code (0 = none) ==23
0x01, //number of hid class descrptors that follow (1) ==24
0x22, //report descriptor type (0x22 == HID) ==25
USB_CLASS_SPECIFIC_DESC_LOOKUP_SIZE[0][0], 0x00, //length of report descriptor ==26,27
0, 0x00, //length of report descriptor ==26,27
*/
//endpoint descriptor
USB_DESC_ENDPOINT_LEN, //length of descriptor ==28
USB_DESC_ENDPOINT_TYPE, //constant ENDPOINT (ENDPOINT 0x05) ==29
0x80, //endpoint number and direction (0x80 = EP0 IN) ==30
USB_ENDPOINT_TYPE_CONTROL, //transfer type supported (0x03 is interrupt) ==31
USB_EP0_TX_SIZE,0x00, //maximum packet size supported ==32,33
10 //polling interval, in ms. (cant be smaller than 10 for slow speed devices) ==34
 
//endpoint descriptor
USB_DESC_ENDPOINT_LEN, //length of descriptor ==28
USB_DESC_ENDPOINT_TYPE, //constant ENDPOINT (ENDPOINT 0x05) ==29
0x81, //endpoint number and direction (0x81 = EP1 IN) ==30
USB_ENDPOINT_TYPE_INTERRUPT, //transfer type supported (0x03 is interrupt) ==31
USB_EP1_TX_SIZE,0x00, //maximum packet size supported ==32,33
0x00, //endpoint number and direction (0x80 = EP0 IN) ==30
USB_ENDPOINT_TYPE_CONTROL, //transfer type supported (0x03 is interrupt) ==31
USB_EP0_RX_SIZE,0x00, //maximum packet size supported ==32,33
10 //polling interval, in ms. (cant be smaller than 10 for slow speed devices) ==34
};
 
230,7 → 181,7
USB_DESC_DEVICE_LEN, //the length of this report ==1
0x01, //the constant DEVICE (DEVICE 0x01) ==2
0x10,0x01, //usb version in bcd (pic167xx is 1.1) ==3,4
0xff, //class code ==5
0xff, //class code vendor specific
0x00, //subclass code ==6
0x00, //protocol code ==7
USB_MAX_EP0_PACKET_LENGTH, //max packet size for endpoint 0. (SLOW SPEED SPECIFIES 8) ==8