diff --git a/USB_Host_Shield/examples/LCDkbd.pde b/USB_Host_Shield/examples/LCDkbd.pde
deleted file mode 100644
index 0f4dba1..0000000
--- a/USB_Host_Shield/examples/LCDkbd.pde
+++ /dev/null
@@ -1,335 +0,0 @@
-/* MAX3421E USB Host controller LCD/keyboard demonstration */
-#include <Spi.h>
-#include <Max3421e.h>
-#include <Usb.h>
-#include <Max_LCD.h>
-
-/* keyboard data taken from configuration descriptor */
-#define KBD_ADDR        1
-#define KBD_EP          1
-#define KBD_IF          0
-#define EP_MAXPKTSIZE   8
-#define EP_POLL         0x0a
-/**/
-//******************************************************************************
-//  macros to identify special charaters(other than Digits and Alphabets)
-//******************************************************************************
-#define BANG        (0x1E)
-#define AT          (0x1F)
-#define POUND       (0x20)
-#define DOLLAR      (0x21)
-#define PERCENT     (0x22)
-#define CAP         (0x23)
-#define AND         (0x24)
-#define STAR        (0x25)
-#define OPENBKT     (0x26)
-#define CLOSEBKT    (0x27)
-
-#define RETURN      (0x28)
-#define ESCAPE      (0x29)
-#define BACKSPACE   (0x2A)
-#define TAB         (0x2B)
-#define SPACE       (0x2C)
-#define HYPHEN      (0x2D)
-#define EQUAL       (0x2E)
-#define SQBKTOPEN   (0x2F)
-#define SQBKTCLOSE  (0x30)
-#define BACKSLASH   (0x31)
-#define SEMICOLON   (0x33)
-#define INVCOMMA    (0x34)
-#define TILDE       (0x35)
-#define COMMA       (0x36)
-#define PERIOD      (0x37)
-#define FRONTSLASH  (0x38)
-#define DELETE      (0x4c)
-/**/
-/* Modifier masks. One for both modifiers */
-#define SHIFT       0x22
-#define CTRL        0x11
-#define ALT         0x44
-#define GUI         0x88
-/**/
-/* "Sticky keys */
-#define CAPSLOCK    (0x39)
-#define NUMLOCK     (0x53)
-#define SCROLLLOCK  (0x47)
-/* Sticky keys output report bitmasks */
-#define bmNUMLOCK       0x01
-#define bmCAPSLOCK      0x02
-#define bmSCROLLLOCK    0x04
-/**/
-EP_RECORD ep_record[ 2 ];  //endpoint record structure for the keyboard
-
-char buf[ 8 ] = { 0 };      //keyboard buffer
-char old_buf[ 8 ] = { 0 };  //last poll
-/* Sticky key state */
-bool numLock = false;
-bool capsLock = false;
-bool scrollLock = false;
-bool line = false;
-
-void setup();
-void loop();
-
-MAX3421E Max;
-USB Usb;
-Max_LCD LCD;
-
-void setup() {
-  // set up the LCD's number of rows and columns: 
-  LCD.begin(16, 2);
-  LCD.home();
-  Serial.begin( 9600 );
-  Serial.println("Start");
-  Max.powerOn();
-  delay( 200 );
-}
-
-void loop() {
-    Max.Task();
-    Usb.Task();
-    if( Usb.getUsbTaskState() == USB_STATE_CONFIGURING ) {  //wait for addressing state
-        kbd_init();
-        Usb.setUsbTaskState( USB_STATE_RUNNING );
-    }
-    if( Usb.getUsbTaskState() == USB_STATE_RUNNING ) {  //poll the keyboard  
-        kbd_poll();
-    }
-}
-/* Initialize keyboard */
-void kbd_init( void )
-{
- byte rcode = 0;  //return code
-/**/
-    /* Initialize data structures */
-    ep_record[ 0 ] = *( Usb.getDevTableEntry( 0,0 ));  //copy endpoint 0 parameters
-    ep_record[ 1 ].MaxPktSize = EP_MAXPKTSIZE;
-    ep_record[ 1 ].Interval  = EP_POLL;
-    ep_record[ 1 ].sndToggle = bmSNDTOG0;
-    ep_record[ 1 ].rcvToggle = bmRCVTOG0;
-    Usb.setDevTableEntry( 1, ep_record );              //plug kbd.endpoint parameters to devtable
-    /* Configure device */
-    rcode = Usb.setConf( KBD_ADDR, 0, 1 );                    
-    if( rcode ) {
-        Serial.print("Error attempting to configure keyboard. Return code :");
-        Serial.println( rcode, HEX );
-        while(1);  //stop
-    }
-    /* Set boot protocol */
-    rcode = Usb.setProto( KBD_ADDR, 0, 0, 0 );
-    if( rcode ) {
-        Serial.print("Error attempting to configure boot protocol. Return code :");
-        Serial.println( rcode, HEX );
-        while( 1 );  //stop
-    }
-    LCD.print("Keyboard initialized");
-    delay(2000);
-    LCD.clear();
-    LCD.home();
-    Serial.println("Keyboard initialized");
-}
-
-/* Poll keyboard and print result */
-/* buffer starts at position 2, 0 is modifier key state and 1 is irrelevant */
-void kbd_poll( void )
-{
- char i;
- static char leds = 0;
- byte rcode = 0;     //return code
-    /* poll keyboard */
-    rcode = Usb.inTransfer( KBD_ADDR, KBD_EP, 8, buf );
-    if( rcode != 0 ) {
-        return;
-    }//if ( rcode..
-    for( i = 2; i < 8; i++ ) {
-     if( buf[ i ] == 0 ) {  //end of non-empty space
-        break;
-     }
-      if( buf_compare( buf[ i ] ) == false ) {   //if new key
-        switch( buf[ i ] ) {
-          case CAPSLOCK:
-            capsLock =! capsLock;
-            leds = ( capsLock ) ? leds |= bmCAPSLOCK : leds &= ~bmCAPSLOCK;       // set or clear bit 1 of LED report byte
-            break;
-          case NUMLOCK:
-            numLock =! numLock;
-            leds = ( numLock ) ? leds |= bmNUMLOCK : leds &= ~bmNUMLOCK;           // set or clear bit 0 of LED report byte
-            break;
-          case SCROLLLOCK:
-            scrollLock =! scrollLock;
-            leds = ( scrollLock ) ? leds |= bmSCROLLLOCK : leds &= ~bmSCROLLLOCK;   // set or clear bit 2 of LED report byte
-            break;
-          case DELETE:
-            LCD.clear();
-            LCD.home();
-            line = false;
-            break;
-          case RETURN:
-            line =! line;
-            LCD.setCursor( 0, line );
-            break;  
-          default:
-            //LCD.print("A");                          //output
-            LCD.print( HIDtoA( buf[ i ], buf[ 0 ] ));
-            Serial.print(HIDtoA( buf[ i ], buf[ 0 ] ));
-            break;
-        }//switch( buf[ i ...
-        rcode = Usb.setReport( KBD_ADDR, 0, 1, KBD_IF, 0x02, 0, &leds );
-        if( rcode ) {
-          Serial.print("Set report error: ");
-          Serial.println( rcode, HEX );
-        }//if( rcode ...
-     }//if( buf_compare( buf[ i ] ) == false ...
-    }//for( i = 2...
-    for( i = 2; i < 8; i++ ) {                    //copy new buffer to old
-      old_buf[ i ] = buf[ i ];
-    }
-}
-/* compare byte against bytes in old buffer */
-bool buf_compare( byte data )
-{
- char i;
- for( i = 2; i < 8; i++ ) {
-   if( old_buf[ i ] == data ) {
-     return( true );
-   }
- }
- return( false );
-}
-
-/* HID to ASCII converter. Takes HID keyboard scancode, returns ASCII code */
-byte HIDtoA( byte HIDbyte, byte mod )
-{
-  /* upper row of the keyboard, numbers and special symbols */
-  if( HIDbyte >= 0x1e && HIDbyte <= 0x27 ) {
-    if(( mod & SHIFT ) || numLock ) {    //shift key pressed
-      switch( HIDbyte ) {
-        case BANG:  return( 0x21 );
-        case AT:    return( 0x40 );
-        case POUND: return( 0x23 );
-        case DOLLAR: return( 0x24 );
-        case PERCENT: return( 0x25 );
-        case CAP: return( 0x5e );
-        case AND: return( 0x26 );
-        case STAR: return( 0x2a );
-        case OPENBKT: return( 0x28 );
-        case CLOSEBKT: return( 0x29 );
-      }//switch( HIDbyte...
-    }
-    else {                  //numbers
-      if( HIDbyte == 0x27 ) {  //zero
-        return( 0x30 );
-      }
-      else {
-        return( HIDbyte + 0x13 );
-      }
-    }//numbers
-  }//if( HIDbyte >= 0x1e && HIDbyte <= 0x27
-  /**/
-  /* number pad. Arrows are not supported */
-  if(( HIDbyte >= 0x59 && HIDbyte <= 0x61 ) && ( numLock == true )) {  // numbers 1-9
-    return( HIDbyte - 0x28 );
-  }
-  if(( HIDbyte == 0x62 ) && ( numLock == true )) {                      //zero
-    return( 0x30 );
-  }
-  /* Letters a-z */
-  if( HIDbyte >= 0x04 && HIDbyte <= 0x1d ) {
-    if((( capsLock == true ) && ( mod & SHIFT ) == 0 ) || (( capsLock == false ) && ( mod & SHIFT ))) {  //upper case
-      return( HIDbyte + 0x3d );
-    }
-    else {  //lower case
-      return( HIDbyte + 0x5d );
-    }
-  }//if( HIDbyte >= 0x04 && HIDbyte <= 0x1d...
-  /* Other special symbols */
-  if( HIDbyte >= 0x2c && HIDbyte <= 0x38 ) {
-    switch( HIDbyte ) {
-      case SPACE: return( 0x20 ); 
-      case HYPHEN:
-        if(( mod & SHIFT ) == false ) {
-         return( 0x2d );
-        }
-        else {
-          return( 0x5f );
-        }
-      case EQUAL:
-       if(( mod & SHIFT ) == false ) {
-        return( 0x3d );
-       }
-       else {
-        return( 0x2b );
-       }
-       case SQBKTOPEN:
-         if(( mod & SHIFT ) == false ) {
-          return( 0x5b );
-         }
-         else {
-          return( 0x7b );
-         }
-       case SQBKTCLOSE:
-         if(( mod & SHIFT ) == false ) {
-          return( 0x5d );
-         }
-         else {
-          return( 0x7d );
-         } 
-       case BACKSLASH:
-         if(( mod & SHIFT ) == false ) {
-           return( 0x5c );
-         }
-         else {
-           return( 0x7c );
-         }
-       case SEMICOLON:
-         if(( mod & SHIFT ) == false ) {
-           return( 0x3b );
-         }
-         else {
-           return( 0x3a );
-         }
-      case INVCOMMA:
-        if(( mod & SHIFT ) == false ) {
-          return( 0x27 );
-        }
-        else {
-          return( 0x22 );
-        }
-      case TILDE:  
-        if(( mod & SHIFT ) == false ) {
-          return( 0x60 );
-        }
-        else {
-          return( 0x7e );
-        }
-      case COMMA:   
-        if(( mod & SHIFT ) == false ) {
-          return( 0x2c );
-        }
-        else {
-          return( 0x3c );
-        }
-      case PERIOD:
-        if(( mod & SHIFT ) == false ) {
-          return( 0x2e );
-        }
-        else {
-          return( 0x3e );
-        }
-      case FRONTSLASH:
-        if(( mod & SHIFT ) == false ) {
-          return( 0x2f );
-        }
-        else {
-          return( 0x3f );
-        }
-      default:
-        break;
-    }//switch( HIDbyte..
-  }//if( HIDbye >= 0x2d && HIDbyte <= 0x38..
-  return( 0 );
-}
-
-
-
-
diff --git a/USB_Host_Shield/examples/PS3LCD.pde b/USB_Host_Shield/examples/PS3LCD.pde
deleted file mode 100644
index ae103e0..0000000
--- a/USB_Host_Shield/examples/PS3LCD.pde
+++ /dev/null
@@ -1,566 +0,0 @@
-
-
-/* MAX3421E USB Host controller LCD/PS3 demonstration */
-#include <Spi.h>
-#include <Max3421e.h>
-#include <Usb.h>
-#include <Max_LCD.h>
-#include <MemoryFree.h>
-#include <avr/pgmspace.h>
-
-/*The application will work in reduced host mode, so we can save program and data
-memory space. After verifying the PID and VID we will use known values for the 
-configuration values for device, interface, endpoints and HID */
-
-/* PS3 data taken from descriptors */
-#define PS3_ADDR        1
-#define PS3_VID_LO      0x4c  // Sony VID
-#define PS3_VID_HI      0x05
-#define PS3_PID_LO      0x68  // Batch Device
-#define PS3_PID_HI      0x02
-#define PS3_CONFIGURATION 1
-#define PS3_IF          0
-#define PS3_NUM_EP      3
-#define EP_MAXPKTSIZE   64
-#define EP_INTERRUPT    0x03 
-#define EP_POLL         0x01
-#define CONTROL_EP      0
-#define OUTPUT_EP       1
-#define REPORT_EP       2
-
-
-#define PS3_F4_REPORT_LEN 4
-#define PS3_F5_REPORT_LEN 8
-#define PS3_01_REPORT_LEN 48
-#define HID_REPORT_FEATURE 3 
-#define HID_REPORT_OUTPUT  2
-#define PS3_F4_REPORT_ID  0xF4
-#define PS3_01_REPORT_ID  0x01
-#define PS3_F5_REPORT_ID 0xF5
-
-/* Defines for the PS3 Data in the HID Report
-*/
-#define LAnalogX    buf[6]
-#define LAnalogY    buf[7]
-#define RAnalogX    buf[8]
-#define RAnalogY    buf[9]
-#define buttons1    buf[2]
-#define buttons2    buf[3]
-#define buttons3    buf[4]
-#define buttonchange ((buttons1 != oldbuttons1) | (buttons2 != oldbuttons2))
-#define buSelect    (buttons1 & 0x01)
-#define buLAnalog   (buttons1 & 0x02)
-#define buRAnalog   (buttons1 & 0x04)
-#define buStart     (buttons1 & 0x08)
-#define buUp        (buttons1 & 0x10)
-#define buRight     (buttons1 & 0x20)
-#define buDown      (buttons1 & 0x40)
-#define buLeft      (buttons1 & 0x80)
-#define buL2        (buttons2 & 0x01)
-#define buR2        (buttons2 & 0x02)
-#define buL1        (buttons2 & 0x04)
-#define buR1        (buttons2 & 0x08)
-#define buTriangle  (buttons2 & 0x10)
-#define buCircle    (buttons2 & 0x20)
-#define buCross     (buttons2 & 0x40)
-#define buSquare    (buttons2 & 0x80)
-#define buPS        (buttons3 & 0x01)
-#define AnalogUp    buf[14]
-#define AnalogRight buf[15]
-#define AnalogDown  buf[16]
-#define AnalogLeft  buf[17]
-#define AnalogL2    buf[18]
-#define AnalogR2    buf[19]
-#define AnalogL1    buf[20]
-#define AnalogR1    buf[21]
-#define AnalogTriangle buf[22]
-#define AnalogCircle buf[23]
-#define AnalogCross  buf[24]
-#define AnalogSquare buf[25]
-#define AccelX      (((unsigned char)buf[42] | (unsigned char)buf[41] << 8)-512)
-#define AccelY      (((unsigned char)buf[44] | (unsigned char)buf[43] << 8)-512)
-#define AccelZ      (((unsigned char)buf[46] | (unsigned char)buf[45] << 8)-512)
-#define GyroX       (((unsigned char)buf[48] | (unsigned char)buf[47] << 8)-512)
-
-
-
-/*Menu screens
-
-*/
-#define Root    0
-#define Basic   1
-#define Buttons 2
-#define Joystick 3
-#define Pressure 4
-#define Accelerometer 5
-#define LED 6
-#define Bdaddr 7
-#define Freememory 8
-
-
-/* Menu Text
-*/
-
-prog_char menutext_0[] PROGMEM = "Select Test";
-prog_char menutext_1[] PROGMEM = "Basic Tests";  
-prog_char menutext_2[] PROGMEM = "Buttons Test";
-prog_char menutext_3[] PROGMEM = "Joystick Test";
-prog_char menutext_4[] PROGMEM = "Pressure Test";
-prog_char menutext_5[] PROGMEM = "Motion Test";
-prog_char menutext_6[] PROGMEM = "LED/Rumble Test";
-prog_char menutext_7[] PROGMEM = "Bluetooth Addr";
-prog_char menutext_8[] PROGMEM = "Free Memory";
-
-
-PROGMEM const char *menu_table[] = 	  
-{   
-  menutext_0,
-  menutext_1,
-  menutext_2,
-  menutext_3,
-  menutext_4,
-  menutext_5,
-  menutext_6,
-  menutext_7,
-  menutext_8 };
-
-prog_char output_01_report[] PROGMEM = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-                                     0x00, 0x02, 0xff, 0x27, 0x10, 0x00, 0x32, 0xff, 
-                                     0x27, 0x10, 0x00, 0x32, 0xff, 0x27, 0x10, 0x00, 
-                                     0x32, 0xff, 0x27, 0x10, 0x00, 0x32, 0x00, 0x00, 
-                                     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-                                     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-};
-
-prog_char feature_F4_report[] PROGMEM = {0x42, 0x0c, 0x00, 0x00};
-
-EP_RECORD ep_record[ PS3_NUM_EP ];  //endpoint record structure for the PS3 controller
-
-char buf[ 64 ] = { 0 };      //General purpose buffer for usb data
-char oldbuttons1, oldbuttons2;
-char screen, selscreen;
-char lcdbuffer[17];
-unsigned char bdaddr[6];
-char bdcursor;
-char ledrum;
-char lrcursor;
-
-
-void setup();
-void loop();
-
-MAX3421E Max;
-USB Usb;
-Max_LCD LCD;
-
-void setup() {
-  // set up the LCD's number of rows and columns: 
-  LCD.begin(16, 2);
-  LCD.home();
-  LCD.print("PS3 Controller");
-  LCD.setCursor(0,1);
-  LCD.print("Wait for connect");
-  Serial.begin( 9600 );
-  Serial.println("PS3 Controller Start");
-  Serial.print("freeMemory() reports ");
-  Serial.println( freeMemory() );
-  Max.powerOn();
-  delay(200);
-}
-
-void loop() {
-  
-
-    Max.Task();
-    Usb.Task();
-    if( Usb.getUsbTaskState() == USB_STATE_CONFIGURING ) {  //wait for addressing state
-        PS3_init();
-        process_report();
-        Usb.setUsbTaskState( USB_STATE_RUNNING );
-    }
-    if( Usb.getUsbTaskState() == USB_STATE_RUNNING ) {  //poll the PS3 Controller 
-        PS3_poll();
-    }
-}
-/* Initialize PS3 Controller */
-void PS3_init( void )
-{
- byte rcode = 0;  //return code
- byte i;
-/**/
-
-    /* Initialize data structures for endpoints of device 1*/
-    ep_record[ CONTROL_EP ] = *( Usb.getDevTableEntry( 0,0 ));  //copy endpoint 0 parameters
-    ep_record[ OUTPUT_EP ].epAddr = 0x02;    // PS3 output endpoint
-    ep_record[ OUTPUT_EP ].Attr  = EP_INTERRUPT;
-    ep_record[ OUTPUT_EP ].MaxPktSize = EP_MAXPKTSIZE;
-    ep_record[ OUTPUT_EP ].Interval  = EP_POLL;
-    ep_record[ OUTPUT_EP ].sndToggle = bmSNDTOG0;
-    ep_record[ OUTPUT_EP ].rcvToggle = bmRCVTOG0;
-    ep_record[ REPORT_EP ].epAddr = 0x01;    // PS3 report endpoint
-    ep_record[ REPORT_EP ].Attr  = EP_INTERRUPT;
-    ep_record[ REPORT_EP ].MaxPktSize = EP_MAXPKTSIZE;
-    ep_record[ REPORT_EP ].Interval  = EP_POLL;
-    ep_record[ REPORT_EP ].sndToggle = bmSNDTOG0;
-    ep_record[ REPORT_EP ].rcvToggle = bmRCVTOG0;
-    
-    Usb.setDevTableEntry( PS3_ADDR, ep_record );              //plug kbd.endpoint parameters to devtable
-    
-    /* read the device descriptor and check VID and PID*/
-    rcode = Usb.getDevDescr( PS3_ADDR, ep_record[ CONTROL_EP ].epAddr, DEV_DESCR_LEN , buf );
-    if( rcode ) {
-        Serial.print("Error attempting read device descriptor. Return code :");
-        Serial.println( rcode, HEX );
-        while(1);  //stop
-    }
-    if((buf[ 8 ] != PS3_VID_LO) || (buf[ 9 ] != PS3_VID_HI) || (buf[ 10 ] != PS3_PID_LO) || (buf[ 11 ] != PS3_PID_HI) ) {
-        Serial.print("Unsupported USB Device");
-          while(1);  //stop   
-    }
-    
-    /* Configure device */
-    rcode = Usb.setConf( PS3_ADDR, ep_record[ CONTROL_EP ].epAddr, PS3_CONFIGURATION );                    
-    if( rcode ) {
-        Serial.print("Error attempting to configure PS3 controller. Return code :");
-        Serial.println( rcode, HEX );
-        while(1);  //stop
-    }
-    
- 
-    /* Set the PS3 controller to send reports */
-    for (i=0; i < PS3_F4_REPORT_LEN; i++) buf[i] = pgm_read_byte_near( feature_F4_report + i); 
-    rcode = Usb.setReport( PS3_ADDR, ep_record[ CONTROL_EP ].epAddr, PS3_F4_REPORT_LEN,  PS3_IF, HID_REPORT_FEATURE, PS3_F4_REPORT_ID , buf );
-    if( rcode ) {
-        Serial.print("Set report error: ");
-        Serial.println( rcode, HEX );
-        while(1);  //stop
-       
-    }
-    
-    /* Set the PS3 controller LED 1 On */
-    for (i=0; i < PS3_01_REPORT_LEN; i++) buf[i] = pgm_read_byte_near( output_01_report + i); 
-    rcode = Usb.setReport( PS3_ADDR, ep_record[ CONTROL_EP ].epAddr, PS3_01_REPORT_LEN,  PS3_IF, HID_REPORT_OUTPUT, PS3_01_REPORT_ID , buf );
-    if( rcode ) {
-        Serial.print("Set report error: ");
-        Serial.println( rcode, HEX );
-        while(1);  //stop
-       
-    }
-    
-    LCD.print("PS3 initialized");
-    Serial.println("PS3 initialized");
-    delay(200);
-    screen = Root;
-    selscreen = Basic;
-    LCD.clear();
-    LCD.home();
-    LCD.print("Main Menu");
-    LCD.setCursor(0,1);
-    strcpy_P(lcdbuffer, (char*)pgm_read_word(&(menu_table[selscreen]))); 
-    LCD.print(lcdbuffer);
-
-    
-}
-
-/* Poll PS3 and print result */
-
-void PS3_poll( void )
-{
- 
- byte rcode = 0;     //return code
-    /* poll PS3 */
-    rcode = Usb.inTransfer(PS3_ADDR, ep_record[ REPORT_EP ].epAddr, PS3_01_REPORT_LEN, buf );
-    if( rcode != 0 ) {
-       return;
-    }
-    process_report();
-    return;
-}
-
-void process_report(void)
-{
-  byte i, j, mask;
-  if(buPS){
-    screen = Root;
-    selscreen = Basic;
-    LCD.clear();
-    LCD.home();
-    LCD.print("Main Menu");
-    LCD.setCursor(0,1);
-    strcpy_P(lcdbuffer, (char*)pgm_read_word(&(menu_table[selscreen]))); 
-    LCD.print(lcdbuffer);
-    oldbuttons1 = buttons1;
-    oldbuttons2 = buttons2;
-
-  }
-  
-  switch (screen){
-    
-    case Root:     
-      if(buttonchange){
-        if(buDown) selscreen--;
-        else if(buUp | buSelect) selscreen++;
-        else if(buStart) {
-          screen = selscreen;
-          LCD.clear();
-          oldbuttons1 = buttons1;
-          oldbuttons2 = buttons2;
-          break;
-        }
-        else {
-          oldbuttons1 = buttons1;
-          oldbuttons2 = buttons2;
-          break;
-          
-        }
-        if (selscreen == 0) selscreen = 1;
-        if (selscreen > 8) selscreen = 1;
-        LCD.clear();
-        LCD.home();
-        LCD.print("Main Menu:");
-        LCD.setCursor(0,1);
-        strcpy_P(lcdbuffer, (char*)pgm_read_word(&(menu_table[selscreen]))); 
-        LCD.print(lcdbuffer);
-        oldbuttons1 = buttons1;
-        oldbuttons2 = buttons2;
-      }
-      break;
-    
-    case Basic:
-      if(buttonchange){
-        LCD.home();
-        if (buL1) LCD.print('X');
-        else LCD.print(' ');
-        LCD.print("  Test L/R");
-        LCD.setCursor(0,1);
-        if (buL2) LCD.print('X');
-        else LCD.print(' ');
-        LCD.print("  Buttons");
-        LCD.setCursor(15,0);
-        if (buR1) LCD.print('X');
-        else LCD.print(' ');
-        
-        LCD.setCursor(15,1);
-        if (buR2) LCD.print('X');
-        else LCD.print(' ');
-      }
-      
-      break;
-    
-    case Buttons:  
-      if(buttonchange){
-        LCD.home();
-        LCD.print("0123456789ABCDEF");
-        LCD.setCursor(0,1);
-        mask = 1;
-        for( i = 0; i < 8; i++){
-          if (buttons1 & mask) lcdbuffer[i] = '^';
-          else lcdbuffer[i] = ' ';
-          mask <<= 1;
-        }
-        mask = 1;
-        for( i = 0; i < 8; i++){
-          if (buttons2 & mask) lcdbuffer[i+8] = '^';
-          else lcdbuffer[i+8] = ' ';
-          mask <<= 1;
-        }
-        LCD.print(lcdbuffer);
-        oldbuttons1 = buttons1;
-        oldbuttons2 = buttons2;
- 
-      }
-      
-      break;
-    
-    case Joystick:
-      LCD.home();
-      LCD.print('^');
-      LCD.print((unsigned char)LAnalogY, DEC);
-      LCD.print("  ");
-      LCD.setCursor(8,0);
-      LCD.print('^');
-      LCD.print((unsigned char)RAnalogY, DEC);
-      LCD.print("  ");
-      LCD.setCursor(0,1);
-      LCD.print('>');
-      LCD.print((unsigned char)LAnalogX, DEC);
-      LCD.print("  ");
-      LCD.setCursor(8,1);
-      LCD.print('>');
-      LCD.print((unsigned char)RAnalogX, DEC);
-      LCD.print("  ");
-      break;
-      
-    case Pressure:
-      LCD.home();
-      LCD.print((unsigned char)AnalogUp, DEC);
-      LCD.print(" ");
-      LCD.print((unsigned char)AnalogDown, DEC);
-      LCD.print(" ");
-      LCD.print((unsigned char)AnalogLeft, DEC);
-      LCD.print(" ");
-      LCD.print((unsigned char)AnalogRight, DEC);
-      LCD.print(" ");
-      LCD.print((unsigned char)AnalogL1, DEC);
-      LCD.print(" ");
-      LCD.print((unsigned char)AnalogR1, DEC);
-      LCD.print("      ");
- 
-      LCD.setCursor(0,1);
-      LCD.print((unsigned char)AnalogCircle, DEC);
-      LCD.print(" ");
-      LCD.print((unsigned char)AnalogTriangle, DEC);
-      LCD.print(" ");
-      LCD.print((unsigned char)AnalogSquare, DEC);
-      LCD.print(" ");
-      LCD.print((unsigned char)AnalogCross, DEC);
-      LCD.print(" ");
-      LCD.print((unsigned char)AnalogL2, DEC);
-      LCD.print(" ");
-      LCD.print((unsigned char)AnalogR2, DEC);
-      LCD.print("      ");
-     
-      break;
-      
-    case Accelerometer:
-      LCD.home();
-      LCD.print('X');
-      LCD.print(AccelX, DEC);
-      LCD.print("  ");
-      LCD.setCursor(8,0);
-      LCD.print('Y');
-      LCD.print(AccelY, DEC);
-      LCD.print("  ");
-      LCD.setCursor(0,1);
-      LCD.print('Z');
-      LCD.print(AccelZ, DEC);
-      LCD.print("  ");
-      LCD.setCursor(8,1);
-      LCD.print('G');
-      LCD.print(GyroX, DEC);
-      LCD.print("  ");
-      break;
-      
-    case LED:
-      if(buttonchange){
-        oldbuttons1 = buttons1;
-        oldbuttons2 = buttons2;
-        if (buRight) lrcursor++;
-        else if (buLeft) lrcursor--;
-        else if (buUp) ledrum |= 1 << lrcursor;
-        else if (buDown) ledrum &= ~(1 << lrcursor);
-        if (lrcursor > 7) lrcursor = 0;
-        if (lrcursor < 0) lrcursor = 7;
-      }
-      LCD.home();
-      LCD.print("1 2 3 4 S W ");
-      LCD.setCursor(0,1);
-      j = 0;
-      for (i=0; i < 6; i++){
-        if(ledrum & 1 << i) lcdbuffer[j] = 'X';
-        else lcdbuffer[j] = ' ';
-        j++; ;
-        lcdbuffer[j] = ' ';
-        j++;
-      }
-      lcdbuffer[j] = 0;
-      LCD.print(lcdbuffer);
-      LCD.setCursor((lrcursor * 2),1);
-      LCD.cursor();
-      /* default buffer values */
-      for (i=0; i < PS3_01_REPORT_LEN; i++) buf[i] = pgm_read_byte_near( output_01_report + i); 
-      /* LED setings */
-      buf[9] = (ledrum & 0x0f) << 1;
-      /* rumble settings */
-      if (ledrum & 0x30){
-        buf[1] = buf[3] = 0xfe;
-        if (ledrum & 0x10) buf[4] = 0xff;
-        else buf[2] = 0xff;
-      }
-      
-      Usb.setReport( PS3_ADDR, ep_record[ CONTROL_EP ].epAddr, PS3_01_REPORT_LEN,  PS3_IF, HID_REPORT_OUTPUT, PS3_01_REPORT_ID , buf );
-
-      delay(100);
-      LCD.noCursor();
-      break;
-      
-    case Bdaddr:
-      if(buttonchange){
-        oldbuttons1 = buttons1;
-        oldbuttons2 = buttons2;
- 
-        if (buRight) bdcursor++;
-        else if (buLeft) bdcursor--;
-        if (bdcursor > 11) bdcursor = 0;
-        if (bdcursor < 0) bdcursor = 11;
-        if(buUp){
-          if(bdcursor % 2){
-            if ((bdaddr[bdcursor /2] & 0x0f) == 0x0f) bdaddr[bdcursor /2] &= 0xf0;
-            bdaddr[bdcursor / 2] += 0x1;           
-          }
-          else{
-            if ((bdaddr[bdcursor /2] & 0xf0) == 0xf0) bdaddr[bdcursor /2] &= 0x0f;
-            bdaddr[bdcursor / 2] += 0x10;       
-          }
-          
-        }
-        else if (buDown){
-          if(bdcursor % 2){
-            if ((bdaddr[bdcursor /2] & 0x0f) == 0x0) bdaddr[bdcursor /2] |= 0x0f;
-            bdaddr[bdcursor / 2] -= 0x1;           
-          }
-          else{
-            if ((bdaddr[bdcursor /2] & 0xf0) == 0x0) bdaddr[bdcursor /2] |= 0xf0;
-            bdaddr[bdcursor / 2] -= 0x10;       
-          }
-         
-         }
-         if( buCross){
-           buf[0] = 0x01;
-           buf[1] = 0x00;
-           for (i=0; i < 6; i++){
-             buf[i+2] = bdaddr[i];
-           }
-          Serial.println( "bdaddr"); 
-          Usb.setReport( PS3_ADDR, ep_record[ CONTROL_EP ].epAddr, PS3_F5_REPORT_LEN,  PS3_IF, HID_REPORT_FEATURE, PS3_F5_REPORT_ID , buf ); 
-        }
-      }
-      LCD.home();
-      LCD.print("R: ");
-      Usb.getReport( PS3_ADDR, ep_record[ CONTROL_EP ].epAddr, PS3_F5_REPORT_LEN,  PS3_IF, HID_REPORT_FEATURE, PS3_F5_REPORT_ID , buf );
-      for( i=0; i < 6; i++){
-        if ((unsigned char)buf[i+2] < 16) LCD.print ('0');
-        LCD.print((unsigned char)buf[i + 2], HEX);
-      }
-      
-      LCD.setCursor(0,1);
-      LCD.print("W: ");
-      for( i=0; i < 6; i++){
-        if (bdaddr[i] < 16) LCD.print ('0');
-        LCD.print(bdaddr[i], HEX);
-      }
-      LCD.setCursor(3 + bdcursor ,1);
-      LCD.cursor();
-      
-      delay(100);
-      LCD.noCursor();
-      break;
-      
-    case Freememory:
-      LCD.home();
-      LCD.print("Free Memory ");
-      LCD.print( freeMemory(), DEC );
-      LCD.setCursor(0,1);
-      break;
-    
-    default:
-      break;
-      
-  }
-  
-  return;
-}
-
-
-
-
diff --git a/USB_Host_Shield/examples/arm_mouse.pde b/USB_Host_Shield/examples/arm_mouse.pde
deleted file mode 100644
index e934354..0000000
--- a/USB_Host_Shield/examples/arm_mouse.pde
+++ /dev/null
@@ -1,284 +0,0 @@
-/* AL5D robotic arm manual control using USB mouse. Servo controller by Renbotics with some pins swapped, USB Host Shield by Circuits At Home */
-#include <ServoShield.h>
-#include <Spi.h>
-#include <Max3421e.h>
-#include <Usb.h>
- 
-#define DEVADDR 1
-#define CONFVALUE 1
-
-
-
-
-/* Arm dimensions( mm ) */
-#define BASE_HGT 67.31      //base hight 2.65"
-#define HUMERUS 146.05      //shoulder-to-elbow "bone" 5.75"
-#define ULNA 187.325        //elbow-to-wrist "bone" 7.375"   
-#define GRIPPER 100.00      //gripper (incl.heavy duty wrist rotate mechanism) length 3.94"
-
-#define ftl(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))  //float to long conversion
-
-/* Servo names/numbers */
-/* Base servo HS-485HB */
-#define BAS_SERVO 0
-/* Shoulder Servo HS-5745-MG */
-#define SHL_SERVO 1
-/* Elbow Servo HS-5745-MG */
-#define ELB_SERVO 2
-/* Wrist servo HS-645MG */
-#define WRI_SERVO 3
-/* Wrist rotate servo HS-485HB */
-#define WRO_SERVO 4
-/* Gripper servo HS-422 */
-#define GRI_SERVO 5
-
-//#define ARM_PARK set_arm( -50, 140, 100, 0 )  //arm parking position
-
-/* pre-calculations */
-float hum_sq = HUMERUS*HUMERUS;
-float uln_sq = ULNA*ULNA;
-
-void setup();
-void loop();
- 
-ServoShield servos;                       //ServoShield object
-MAX3421E Max;
-USB Usb;
-//ServoShield servos;                       //ServoShield object
-
-/* Arm data structure */
-struct {
-  float x_coord;            // X coordinate of the gripper tip
-  float y_coord;            // Y coordinate of the gripper tip
-  float z_coord;            //Z coordinate of the gripper tip
-  float gripper_angle;      //gripper angle
-  int16_t gripper_servo;   //gripper servo pulse duration 
-  int16_t wrist_rotate;    //wrist rotate servo pulse duration
-} armdata;
-   
-void setup()
-{
-  /* set servo end points */
-  servos.setbounds( BAS_SERVO, 900, 2100 );
-  servos.setbounds( SHL_SERVO, 1000, 2100 );
-  servos.setbounds( ELB_SERVO, 900, 2100 );
-  servos.setbounds( WRI_SERVO, 600, 2400 );
-  servos.setbounds( WRO_SERVO, 600, 2400 );
-  servos.setbounds( GRI_SERVO, 890, 2100 );
-  /**/
-//  servo_park();
-  arm_park();
-  
-  servos.start();                         //Start the servo shield
-  Max.powerOn();
-  Serial.begin( 115200 );
-  Serial.println("Start");
-  delay( 500 );
-  //ARM_PARK;
-}
-
-void loop()
-{
-byte rcode;
-    //delay( 10 );
-    set_arm( armdata.x_coord, armdata.y_coord, armdata.z_coord, armdata.gripper_angle );
-    servos.setposition( WRO_SERVO, armdata.wrist_rotate );
-    servos.setposition( GRI_SERVO, armdata.gripper_servo );
-   //ARM_PARK;
- // circle();
-    Max.Task();
-    Usb.Task();
-    if( Usb.getUsbTaskState() == USB_STATE_CONFIGURING ) {  
-        mouse_init();
-    }//if( Usb.getUsbTaskState() == USB_STATE_CONFIGURING...
-    if( Usb.getUsbTaskState() == USB_STATE_RUNNING ) {  //poll the keyboard  
-        rcode = mouse_poll();
-        if( rcode ) {
-          Serial.print("Mouse Poll Error: ");
-          Serial.println( rcode, HEX );
-        }//if( rcode...
-    }//if( Usb.getUsbTaskState() == USB_STATE_RUNNING...
-    //Serial.println( armdata.gripper_servo, DEC );
-}
-
-/* Initialize mouse */
-void mouse_init( void )
-{
- byte rcode = 0;  //return code
-  /**/
-  Usb.setDevTableEntry( 1, Usb.getDevTableEntry( 0,0 ) );              //copy device 0 endpoint information to device 1
-  /* Configure device */
-  rcode = Usb.setConf( DEVADDR, 0, CONFVALUE );                    
-  if( rcode ) {
-    Serial.print("Error configuring mouse. Return code : ");
-    Serial.println( rcode, HEX );
-    while(1);  //stop
-  }//if( rcode...
-  Usb.setUsbTaskState( USB_STATE_RUNNING );
-  return;
-}
-
-/* Poll mouse using Get Report and fill arm data structure */
-byte mouse_poll( void )
-{
-  byte rcode;
-  char buf[ 4 ];                //mouse buffer
-  static uint16_t delay = 500;  //delay before park
-
-    /* poll mouse */
-    rcode = Usb.getReport( DEVADDR, 0, 4, 0, 1, 0, buf );
-    if( rcode ) {  //error
-      return( rcode );
-    }
-    // todo: add arm limit check
-    armdata.x_coord += ( buf[ 1 ] * -0.1 );
-    armdata.y_coord += ( buf[ 2 ] * -0.1 );
-    switch( buf[ 0 ] ) {  //read buttons
-      case 0x00:            //no buttons pressed
-        armdata.z_coord += ( buf[ 3 ] * -2 ) ;
-        break;
-      case 0x01:            //button 1 pressed. Wheel sets gripper angle
-        armdata.gripper_servo += ( buf[ 3 ] * -20 );
-          /* check gripper boundaries */
-        if( armdata.gripper_servo < 1000 ) {
-          armdata.gripper_servo = 1000;
-        }
-        if( armdata.gripper_servo > 2100 ) {
-          armdata.gripper_servo = 2100;
-        }
-        break;
-      case 0x02:           //button 2 pressed. Wheel sets wrist rotate
-        armdata.wrist_rotate += ( buf[ 3 ] * -10 );
-        /* check wrist rotate boundaries */
-        if( armdata.wrist_rotate < 600 ) {
-          armdata.wrist_rotate = 600;
-        }
-        if( armdata.wrist_rotate > 2400 ) {
-          armdata.wrist_rotate = 2400;
-        }
-        break;
-      case 0x04:          //wheel button pressed. Wheel controls gripper
-        armdata.gripper_angle += ( buf[ 3 ] * -1 );
-        /* check gripper angle boundaries */
-        if( armdata.gripper_angle < -90 ) {
-          armdata.gripper_angle = -90;
-        }
-        if( armdata.gripper_angle > 90 ) {
-          armdata.gripper_angle = 90;
-        }
-        break;
-      case 0x07:          //all 3 buttons pressed. Park the arm
-        arm_park();
-        break;        
-    }//switch( buf[ 0 ...
-    Serial.println( armdata.wrist_rotate, DEC );
-}
-
-
-/* arm positioning routine utilizing inverse kinematics */
-/* z is height, y is distance from base center out, x is side to side. y,z can only be positive */
-//void set_arm( uint16_t x, uint16_t y, uint16_t z, uint16_t grip_angle )
-void set_arm( float x, float y, float z, float grip_angle_d )
-{
-  float grip_angle_r = radians( grip_angle_d );    //grip angle in radians for use in calculations
-  /* Base angle and radial distance from x,y coordinates */
-  float bas_angle_r = atan2( x, y );
-  float rdist = sqrt(( x * x ) + ( y * y ));
-  /* rdist is y coordinate for the arm */
-  y = rdist;
-  /* Grip offsets calculated based on grip angle */
-  float grip_off_z = ( sin( grip_angle_r )) * GRIPPER;
-  float grip_off_y = ( cos( grip_angle_r )) * GRIPPER; 
-  /* Wrist position */
-  float wrist_z = ( z - grip_off_z ) - BASE_HGT;
-  float wrist_y = y - grip_off_y;
-  /* Shoulder to wrist distance ( AKA sw ) */
-  float s_w = ( wrist_z * wrist_z ) + ( wrist_y * wrist_y );
-  float s_w_sqrt = sqrt( s_w );
-  /* s_w angle to ground */
-  //float a1 = atan2( wrist_y, wrist_z ); 
-  float a1 = atan2( wrist_z, wrist_y );
-  /* s_w angle to humerus */
-  float a2 = acos((( hum_sq - uln_sq ) + s_w ) / ( 2 * HUMERUS * s_w_sqrt ));
-  /* shoulder angle */
-  float shl_angle_r = a1 + a2;
-  float shl_angle_d = degrees( shl_angle_r ); 
-  /* elbow angle */
-  float elb_angle_r = acos(( hum_sq + uln_sq - s_w ) / ( 2 * HUMERUS * ULNA ));
-  float elb_angle_d = degrees( elb_angle_r );
-  float elb_angle_dn = -( 180.0 - elb_angle_d );
-  /* wrist angle */
-  float wri_angle_d = ( grip_angle_d - elb_angle_dn ) - shl_angle_d;
- 
-  /* Servo pulses */
-  float bas_servopulse = 1500.0 - (( degrees( bas_angle_r )) * 11.11 );
-  float shl_servopulse = 1500.0 + (( shl_angle_d - 90.0 ) * 6.6 );
-  float elb_servopulse = 1500.0 -  (( elb_angle_d - 90.0 ) * 6.6 );
-  float wri_servopulse = 1500 + ( wri_angle_d  * 11.1 );
-
-  /* Set servos */
-  servos.setposition( BAS_SERVO, ftl( bas_servopulse ));
-  servos.setposition( WRI_SERVO, ftl( wri_servopulse ));
-  servos.setposition( SHL_SERVO, ftl( shl_servopulse ));
-  servos.setposition( ELB_SERVO, ftl( elb_servopulse ));
-  
-}
-
-/* moves the arm to parking position */
-void arm_park()
-{
-  set_arm( armdata.x_coord = -50, armdata.y_coord = 140, armdata.z_coord = 100, armdata.gripper_angle = 0 );
-  servos.setposition( WRO_SERVO, armdata.wrist_rotate = 600 );
-  servos.setposition( GRI_SERVO, armdata.gripper_servo = 900 );
-}
-
-/* move servos to parking position */
-void servo_park()
-{
-  servos.setposition( BAS_SERVO, 1715 );
-  servos.setposition( SHL_SERVO, 2100 );
-  servos.setposition( ELB_SERVO, 2100 );
-  servos.setposition( WRI_SERVO, 1800 );
-  servos.setposition( WRO_SERVO, 600 );
-  servos.setposition( GRI_SERVO, 900 );
-  return;
-}
-
-void zero_x()
-{
-  for( double yaxis = 150.0; yaxis < 356.0; yaxis += 1 ) {
-    set_arm( 0, yaxis, 127.0, 0 );
-    delay( 10 );
-  }
-  for( double yaxis = 356.0; yaxis > 150.0; yaxis -= 1 ) {
-    set_arm( 0, yaxis, 127.0, 0 );
-    delay( 10 );
-  }
-}
-
-/* moves arm in a straight line */
-void line()
-{
-    for( double xaxis = -100.0; xaxis < 100.0; xaxis += 0.5 ) {
-      set_arm( xaxis, 250, 100, 0 );
-      delay( 10 );
-    }
-    for( float xaxis = 100.0; xaxis > -100.0; xaxis -= 0.5 ) {
-      set_arm( xaxis, 250, 100, 0 );
-      delay( 10 );
-    }
-}
-
-void circle()
-{
-  #define RADIUS 80.0
-  //float angle = 0;
-  float zaxis,yaxis;  
-  for( float angle = 0.0; angle < 360.0; angle += 1.0 ) {
-      yaxis = RADIUS * sin( radians( angle )) + 200;
-      zaxis = RADIUS * cos( radians( angle )) + 200;
-      set_arm( 0, yaxis, zaxis, 0 );
-      delay( 1 );
-  }
-}
-  
diff --git a/USB_Host_Shield/examples/board_test/board_test.h b/USB_Host_Shield/examples/board_test/board_test.h
deleted file mode 100644
index 7435d7d..0000000
--- a/USB_Host_Shield/examples/board_test/board_test.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/* USB Host Shield board test sketch header */
-#ifndef _BOARD_TEST_H_
-#define _BOARD_TEST_H_
-
-/* PGMSPACE */
-#include <inttypes.h>
-#include <avr/pgmspace.h>
-
-/* Messages */
-const char startBanner  [] PROGMEM = "\r\nCircuits At Home 2010"
-                                      "\r\nUSB Host Shield QC test routine\r\n";
-const char anykey_msg [] PROGMEM =  "\r\nPress any key to continue...";
-const char testpassed_msg [] PROGMEM = "\r\nTest PASSED";
-const char testfailed_msg [] PROGMEM = "\r\nTest FAILED*!*";
-const char osctest_oscstate_msg [] PROGMEM = " Oscillator state is ";
-const char test_halted_msg [] PROGMEM = "\r\nTest Halted."
-                                        "\r\n0x55 pattern is being transmitted via SPI to aid in troubleshooting";
-const char spitest_fail_msg [] PROGMEM = "\r\nSPI transmit/receive mismatch"
-                                          "\r\nValue written: ";
-
-#endif
diff --git a/USB_Host_Shield/examples/board_test/board_test.pde b/USB_Host_Shield/examples/board_test/board_test.pde
deleted file mode 100644
index 1188fbf..0000000
--- a/USB_Host_Shield/examples/board_test/board_test.pde
+++ /dev/null
@@ -1,296 +0,0 @@
-/* USB Host Shield Board test routine. Runs after assembly to check board functionality */
-
-/* USB related */
-//#include <Spi.h>
-#include <Max3421e.h>
-#include <Max3421e_constants.h>
-#include <Usb.h>
-
-#include "board_test.h" /* Board test messages */
-
-//#define MAX_SS 10
-
-void setup();
-void loop();
-
-MAX3421E Max;
-USB Usb;
-
-void setup()
-{
-  Serial.begin( 115200 );
-  //Serial.println("Start");
-  //Serial.println( SCK_PIN, DEC );
-  Max.powerOn();
-  printProgStr( startBanner );
-  printProgStr( anykey_msg );
-  //Serial.print( Max.getvar(), DEC);
-}
-
-void loop()
-{
-  while( Serial.available() == 0 );  //wait for input
-  Serial.read();                     //empty input buffer
-  /* start tests */
-  /* SPI short test */
-  if (!revregcheck()) test_halted();
-  /* GPIO test */
-  if (!gpiocheck()) printProgStr(PSTR("\r\nGPIO check failed. Make sure GPIO loopback adapter is installed"));
-  /* SPI long test */
-  if (!spitest()) test_halted();      //test SPI for transmission errors
-  if (!osctest()) printProgStr(PSTR("OSCOK test failed. Check the oscillator"));
-  if (!usbtest()) printProgStr(PSTR("USB connection test failed. Check traces from USB connector to MAX3421E, as well as VBUS"));  //never gets here
-    /* All tests passed */
-  printProgStr( anykey_msg );
-}
-
-/* SPI short test. Checks connectivity to MAX3421E by reading REVISION register. */
-/* Die rev.1 returns 0x01, rev.2 0x12, rev.3 0x13. Any other value is considered communication error */
-bool revregcheck()
-{
-  byte tmpbyte;
-  printProgStr(PSTR("\r\nReading REVISION register...Die revision "));
-  tmpbyte = Max.regRd( rREVISION );
-  switch( tmpbyte ) {
-    case( 0x01 ):  //rev.01
-      printProgStr(PSTR("01"));
-      break;  
-    case( 0x12 ):  //rev.02
-      printProgStr(PSTR("02"));
-      break;
-    case( 0x13 ):  //rev.03
-      printProgStr(PSTR("03"));
-      break;
-    default:
-      printProgStr(PSTR("invalid. Value returned: "));
-      print_hex( tmpbyte, 8 );
-      printProgStr( testfailed_msg );
-      return( false );
-      break;
-  }//switch( tmpbyte )...
-  printProgStr( testpassed_msg );
-  return( true );
-}
-/* SPI long test */
-bool spitest()
-{
-  byte l = 0;
-  byte k = 0;
-  byte gpinpol_copy = Max.regRd( rGPINPOL );
-  printProgStr(PSTR("\r\nSPI test. Each  '.' indicates 64K transferred. Stops after transferring 1MB (16 dots)\r\n"));
-  /**/
-  for( byte j = 0; j < 16; j++ ) {
-    for( word i = 0; i < 65535; i++ ) {
-      Max.regWr( rGPINPOL, k );
-      l = Max.regRd( rGPINPOL);
-      if( l != k ) {
-        printProgStr( spitest_fail_msg );
-        print_hex( k, 8);
-        printProgStr(PSTR("Value read: "));
-        print_hex( l, 8 );
-        return( false );                  //test failed
-      }
-      k++;
-    }//for( i = 0; i < 65535; i++
-    Serial.print(".");
-  }//for j = 0; j < 16...
-  Max.regWr( rGPINPOL, gpinpol_copy );
-  printProgStr(testpassed_msg);
-  return( true );
-}
-/* Oscillator test */
-bool osctest()
-{
-  printProgStr(PSTR("\r\nOscillator start/stop test."));
-  printProgStr( osctest_oscstate_msg );
-  check_OSCOKIRQ();                          //print OSCOK state
-  printProgStr(PSTR("\r\nSetting CHIP RESET."));
-  Max.regWr( rUSBCTL, bmCHIPRES );              //Chip reset. This stops the oscillator
-  printProgStr( osctest_oscstate_msg );
-  check_OSCOKIRQ();  //print OSCOK state
-  printProgStr(PSTR("\r\nClearing CHIP RESET. "));
-  Max.regWr( rUSBCTL, 0x00 );                //Chip reset release
-  for( word i = 0; i < 65535; i++) {
-    if( Max.regRd( rUSBIRQ ) & bmOSCOKIRQ ) {
-      printProgStr(PSTR("PLL is stable. Time to stabilize - "));
-      Serial.print( i, DEC );
-      printProgStr(PSTR(" cycles"));
-      printProgStr( testpassed_msg );
-      return( true );
-    }
-  }//for i = 
-  return(false);
-}
-/* Stop/start oscillator */
-void check_OSCOKIRQ()
-{
-  if( Max.regRd( rUSBIRQ ) & bmOSCOKIRQ ) {  //checking oscillator state
-    printProgStr(PSTR("ON"));
-  }
-  else {
-    printProgStr(PSTR("OFF"));
-  }
-}
-/* Test USB connectivity */
-bool usbtest()
-{
-  byte rcode;
-  byte usbstate;
-    Max.powerOn();
-    delay( 200 );
-    printProgStr(PSTR("\r\nUSB Connectivity test. Waiting for device connection... "));
-    while( 1 ) {
-      delay( 200 );
-      Max.Task();
-      Usb.Task();
-      usbstate = Usb.getUsbTaskState();
-      switch( usbstate ) {
-        case( USB_ATTACHED_SUBSTATE_RESET_DEVICE ):
-          printProgStr(PSTR("\r\nDevice connected. Resetting"));
-          break;
-        case( USB_ATTACHED_SUBSTATE_WAIT_SOF ): 
-          printProgStr(PSTR("\r\nReset complete. Waiting for the first SOF..."));
-          //delay( 1000 );
-          break;  
-        case( USB_ATTACHED_SUBSTATE_GET_DEVICE_DESCRIPTOR_SIZE ):
-          printProgStr(PSTR("\r\nSOF generation started. Enumerating device."));
-          break;
-        case( USB_STATE_ADDRESSING ):
-          printProgStr(PSTR("\r\nSetting device address"));
-          //delay( 100 );
-          break;
-        case( USB_STATE_CONFIGURING ):
-          //delay( 1000 );
-          printProgStr(PSTR("\r\nGetting device descriptor"));
-          rcode = getdevdescr( 1 );
-            if( rcode ) {
-              printProgStr(PSTR("\r\nError reading device descriptor. Error code "));
-              print_hex( rcode, 8 );
-            }
-            else {
-              printProgStr(PSTR("\r\n\nAll tests passed. Press RESET to restart test")); 
-              while(1);
-            }
-          break;
-        case( USB_STATE_ERROR ):
-          printProgStr(PSTR("\r\nUSB state machine reached error state"));
-          break;
-        default:
-          break;
-    }//switch
-  }//while(1)
-}
-/* Get device descriptor */
-byte getdevdescr( byte addr )
-{
-  USB_DEVICE_DESCRIPTOR buf;
-  byte rcode;
-  rcode = Usb.getDevDescr( addr, 0, 0x12, ( char *)&buf );
-  if( rcode ) {
-    return( rcode );
-  }
-  printProgStr(PSTR("\r\nDevice descriptor: "));
-  printProgStr(PSTR("\r\nDescriptor Length:\t"));
-  print_hex( buf.bLength, 8 );
-  printProgStr(PSTR("\r\nDescriptor type:\t"));
-  print_hex( buf.bDescriptorType, 8 );
-  printProgStr(PSTR("\r\nUSB version:\t"));
-  print_hex( buf.bcdUSB, 16 );
-  printProgStr(PSTR("\r\nDevice class:\t"));
-  print_hex( buf.bDeviceClass, 8 );
-  printProgStr(PSTR("\r\nDevice Subclass:\t"));
-  print_hex( buf.bDeviceSubClass, 8 );
-  printProgStr(PSTR("\r\nDevice Protocol:\t"));
-  print_hex( buf.bDeviceProtocol, 8 );
-  printProgStr(PSTR("\r\nMax.packet size:\t"));
-  print_hex( buf.bMaxPacketSize0, 8 );
-  printProgStr(PSTR("\r\nVendor ID:\t"));
-  print_hex( buf.idVendor, 16 );
-  printProgStr(PSTR("\r\nProduct ID:\t"));
-  print_hex( buf.idProduct, 16 );
-  printProgStr(PSTR("\r\nRevision ID:\t"));
-  print_hex( buf.bcdDevice, 16 );
-  printProgStr(PSTR("\r\nMfg.string index:\t"));
-  print_hex( buf.iManufacturer, 8 );
-  printProgStr(PSTR("\r\nProd.string index:\t"));
-  print_hex( buf.iProduct, 8 );
-  printProgStr(PSTR("\r\nSerial number index:\t"));
-  print_hex( buf.iSerialNumber, 8 );
-  printProgStr(PSTR("\r\nNumber of conf.:\t"));
-  print_hex( buf.bNumConfigurations, 8 );
-  return( 0 );
-}
-
-/* GPIO lines check. A loopback adapter connecting GPIN to GPOUT is assumed */
-bool gpiocheck()
-{
- byte tmpbyte = 0;
-  printProgStr(PSTR("\r\nChecking GPIO lines. Install GPIO loopback adapter and press any key to continue..."));
-  while( Serial.available() == 0 );  //wait for input
-  Serial.read();                     //empty input buffer  
-    for( byte i = 0; i < 255; i++ ) {
-      Max.gpioWr( i );
-      tmpbyte = Max.gpioRd();
-      if( tmpbyte != i ) {
-        printProgStr(PSTR("GPIO read/write mismatch. Write: "));
-        Serial.print(i, HEX);
-        printProgStr(PSTR(" Read: "));
-        Serial.println( tmpbyte, HEX );
-        return( false );
-      }//if( tmpbyte != i )
-    }//for( i= 0...
-    printProgStr( testpassed_msg );
-    return( true );
-}
-/* Test halted state. Generates 0x55 to aid in SPI troubleshooting */    
-void test_halted()
-{
-  printProgStr( test_halted_msg );
-  printProgStr(PSTR("\r\nPress RESET to restart test"));
-  while( 1 )  {            //System Stop. Generating pattern to keep SCLK, MISO, MOSI, SS busy
-    digitalWrite(MAX_SS,LOW);
-    Max.regWr( 0x55, 0x55 );
-//    Spi.transfer( 0x55 ); 
-    digitalWrite(MAX_SS,HIGH);
-  }
-}
-/* given a PROGMEM string, use Serial.print() to send it out */
-/* Some non-intuitive casting necessary:                           */
-/* printProgStr(PSTR("Func.Mode:\t0x"));                           */
-/* printProgStr((char*)pgm_read_word(&mtpopNames[(op & 0xFF)]));   */
-void printProgStr(const char* str )
-{
-  if(!str) { 
-    return;
-  }
-  char c;
-  while((c = pgm_read_byte(str++))) {
-    Serial.print(c,BYTE);
-  }
-}
-/* prints hex numbers with leading zeroes */
-// copyright, Peter H Anderson, Baltimore, MD, Nov, '07
-// source: http://www.phanderson.com/arduino/arduino_display.html
-void print_hex(int v, int num_places)
-{
-  int mask=0, n, num_nibbles, digit;
-
-  for (n=1; n<=num_places; n++)
-  {
-    mask = (mask << 1) | 0x0001;
-  }
-  v = v & mask; // truncate v to specified number of places
-
-  num_nibbles = num_places / 4;
-  if ((num_places % 4) != 0)
-  {
-    ++num_nibbles;
-  }
-
-  do
-  {
-    digit = ((v >> (num_nibbles-1) * 4)) & 0x0f;
-    Serial.print(digit, HEX);
-  } 
-  while(--num_nibbles);
-}
diff --git a/USB_Host_Shield/examples/conf_descr_dump.pde b/USB_Host_Shield/examples/conf_descr_dump.pde
deleted file mode 100644
index 56d7a58..0000000
--- a/USB_Host_Shield/examples/conf_descr_dump.pde
+++ /dev/null
@@ -1,181 +0,0 @@
-/* MAX3421E USB Host controller get configuration descriptor */
-#include <Spi.h>
-#include <Max3421e.h>
-#include <Usb.h>
- 
-#define LOBYTE(x) ((char*)(&(x)))[0]
-#define HIBYTE(x) ((char*)(&(x)))[1]
-#define BUFSIZE 256    //buffer size
- 
-void setup();
-void loop();
- 
-MAX3421E Max;
-USB Usb;
- 
-void setup()
-{
-  byte tmpdata = 0;
-  Serial.begin( 9600 );
-  Serial.println("Start");
-  Max.powerOn();
-  delay( 200 );
-}
- 
-void loop()
-{
-  byte rcode;
-  byte tmpbyte;
-  Max.Task();
-  Usb.Task();
-  if( Usb.getUsbTaskState() >= USB_STATE_CONFIGURING ) {  //state configuring or higher
-    /* entering configuration number to decode. Restricted to first 10 configurations */
-    Serial.print("Enter configuration number: ");
-    while( Serial.available() == 0 );      //wait for input
-    tmpbyte = Serial.read();
-    Serial.println( tmpbyte );
-    tmpbyte -= 0x30;                       //convert to number
-    if( tmpbyte > 9 ) {
-      Serial.println("Not a number. Assuming configuration 0");
-      tmpbyte = 0;
-    }
-    rcode = getconfdescr( 1, tmpbyte );                 //get configuration descriptor
-    if( rcode ) {
-      Serial.println( rcode, HEX );
-    }
-//    while( 1 );                          //stop
-  }    
-}
- 
-byte getconfdescr( byte addr, byte conf )
-{
-  char buf[ BUFSIZE ];
-  char* buf_ptr = buf;
-  byte rcode;
-  byte descr_length;
-  byte descr_type;
-  unsigned int total_length;
-  rcode = Usb.getConfDescr( addr, 0, 4, conf, buf );  //get total length
-  LOBYTE( total_length ) = buf[ 2 ];
-  HIBYTE( total_length ) = buf[ 3 ];
-  if( total_length > BUFSIZE ) {    //check if total length is larger than buffer
-    Serial.println("Total length truncated to 256 bytes");
-    total_length = BUFSIZE;
-  }
-  rcode = Usb.getConfDescr( addr, 0, total_length, conf, buf ); //get the whole descriptor
-  while( buf_ptr < buf + total_length ) {  //parsing descriptors
-    descr_length = *( buf_ptr );
-    descr_type = *( buf_ptr + 1 );
-    switch( descr_type ) {
-      case( USB_DESCRIPTOR_CONFIGURATION ):
-        printconfdescr( buf_ptr );
-        break;
-      case( USB_DESCRIPTOR_INTERFACE ):
-        printintfdescr( buf_ptr );
-        break;
-      case( USB_DESCRIPTOR_ENDPOINT ):
-        printepdescr( buf_ptr );
-        break;
-      default:
-        printunkdescr( buf_ptr );
-        break;
-        }//switch( descr_type
-    Serial.println("");    
-    buf_ptr = ( buf_ptr + descr_length );    //advance buffer pointer
-  }//while( buf_ptr <=...
-  return( 0 );
-}
-/* prints hex numbers with leading zeroes */
-// copyright, Peter H Anderson, Baltimore, MD, Nov, '07
-// source: http://www.phanderson.com/arduino/arduino_display.html
-void print_hex(int v, int num_places)
-{
-  int mask=0, n, num_nibbles, digit;
- 
-  for (n=1; n<=num_places; n++) {
-    mask = (mask << 1) | 0x0001;
-  }
-  v = v & mask; // truncate v to specified number of places
- 
-  num_nibbles = num_places / 4;
-  if ((num_places % 4) != 0) {
-    ++num_nibbles;
-  }
-  do {
-    digit = ((v >> (num_nibbles-1) * 4)) & 0x0f;
-    Serial.print(digit, HEX);
-  } 
-  while(--num_nibbles);
-}
-/* function to print configuration descriptor */
-void printconfdescr( char* descr_ptr )
-{
- USB_CONFIGURATION_DESCRIPTOR* conf_ptr = ( USB_CONFIGURATION_DESCRIPTOR* )descr_ptr;
-  Serial.println("Configuration descriptor:");
-  Serial.print("Total length:\t");
-  print_hex( conf_ptr->wTotalLength, 16 );
-  Serial.print("\r\nNum.intf:\t\t");
-  print_hex( conf_ptr->bNumInterfaces, 8 );
-  Serial.print("\r\nConf.value:\t");
-  print_hex( conf_ptr->bConfigurationValue, 8 );
-  Serial.print("\r\nConf.string:\t");
-  print_hex( conf_ptr->iConfiguration, 8 );
-  Serial.print("\r\nAttr.:\t\t");
-  print_hex( conf_ptr->bmAttributes, 8 );
-  Serial.print("\r\nMax.pwr:\t\t");
-  print_hex( conf_ptr->bMaxPower, 8 );
-  return;
-}
-/* function to print interface descriptor */
-void printintfdescr( char* descr_ptr )
-{
- USB_INTERFACE_DESCRIPTOR* intf_ptr = ( USB_INTERFACE_DESCRIPTOR* )descr_ptr;
-  Serial.println("\r\nInterface descriptor:");
-  Serial.print("Intf.number:\t");
-  print_hex( intf_ptr->bInterfaceNumber, 8 );
-  Serial.print("\r\nAlt.:\t\t");
-  print_hex( intf_ptr->bAlternateSetting, 8 );
-  Serial.print("\r\nEndpoints:\t\t");
-  print_hex( intf_ptr->bNumEndpoints, 8 );
-  Serial.print("\r\nClass:\t\t");
-  print_hex( intf_ptr->bInterfaceClass, 8 );
-  Serial.print("\r\nSubclass:\t\t");
-  print_hex( intf_ptr->bInterfaceSubClass, 8 );
-  Serial.print("\r\nProtocol:\t\t");
-  print_hex( intf_ptr->bInterfaceProtocol, 8 );
-  Serial.print("\r\nIntf.string:\t");
-  print_hex( intf_ptr->iInterface, 8 );
-  return;
-}
-/* function to print endpoint descriptor */
-void printepdescr( char* descr_ptr )
-{
- USB_ENDPOINT_DESCRIPTOR* ep_ptr = ( USB_ENDPOINT_DESCRIPTOR* )descr_ptr;
-  Serial.println("\r\nEndpoint descriptor:");
-  Serial.print("Endpoint address:\t");
-  print_hex( ep_ptr->bEndpointAddress, 8 );
-  Serial.print("\r\nAttr.:\t\t");
-  print_hex( ep_ptr->bmAttributes, 8 );
-  Serial.print("\r\nMax.pkt size:\t");
-  print_hex( ep_ptr->wMaxPacketSize, 16 );
-  Serial.print("\r\nPolling interval:\t");
-  print_hex( ep_ptr->bInterval, 8 );
-  return;
-}
-/*function to print unknown descriptor */
-void printunkdescr( char* descr_ptr )
-{
-  byte length = *descr_ptr;
-  byte i;
-  Serial.println("\r\nUnknown descriptor:");
-  Serial. print("Length:\t\t");
-  print_hex( *descr_ptr, 8 );
-  Serial.print("\r\nType:\t\t");
-  print_hex( *(descr_ptr + 1 ), 8 );
-  Serial.print("\r\nContents:\t");
-  descr_ptr += 2;
-  for( i = 0; i < length; i++ ) {
-    print_hex( *descr_ptr, 8 );
-    descr_ptr++;
-  }
-}
diff --git a/USB_Host_Shield/examples/descriptor_parser/descriptor_parser.h b/USB_Host_Shield/examples/descriptor_parser/descriptor_parser.h
deleted file mode 100644
index 7570841..0000000
--- a/USB_Host_Shield/examples/descriptor_parser/descriptor_parser.h
+++ /dev/null
@@ -1,284 +0,0 @@
-#ifndef _DESCRIPTOR_PARSER_
-#define _DESCRIPTOR_PARSER_
-
-/* PGMSPACE */
-#include <inttypes.h>
-#include <avr/pgmspace.h>
-
-typedef void (*PARSE)( uint8_t bytes );
-
-/* Common Messages */
-
-const char descr_len [] PROGMEM = "\r\nDescriptor Length:\t";
-const char descr_type [] PROGMEM = "\r\nDescriptor type:\t";
-const char class_str [] PROGMEM = "\r\nClass:\t\t\t";
-const char subclass_str [] PROGMEM = "\r\nSubclass:\t\t";
-const char protocol_str [] PROGMEM = "\r\nProtocol:\t\t";
-const char maxpktsize_str [] PROGMEM = "\r\nMax.packet size:\t";
-const char unk_msg [] PROGMEM = " Unknown";
-const char reserved_msg [] PROGMEM = "Reserved";
-const char rcode_error_msg [] PROGMEM = "\r\nRequest error. Reurn code: ";
-
-/* Endpoint attributes */
-
-const char control_tr [] PROGMEM = "Control";
-const char iso_tr [] PROGMEM = "Isochronous";
-const char bulk_tr [] PROGMEM = "Bulk";
-const char int_tr [] PROGMEM = "Interrupt";
-
-const char* transfer_types [] PROGMEM =
-{
-  control_tr,
-  iso_tr,
-  bulk_tr,
-  int_tr
-};
-
-const char nosync_type [] PROGMEM = "No Synchronization";
-const char async_type [] PROGMEM = "Asynchronous";
-const char adaptive_type [] PROGMEM = "Adaptive";
-const char sync_type [] PROGMEM = "Synchronous";
-
-const char* sync_types [] PROGMEM =
-{
-  nosync_type,
-  async_type,
-  adaptive_type,
-  sync_type
-};
-
-const char data_usage [] PROGMEM = "Data";
-const char feedback_usage [] PROGMEM = "Feedback";
-const char implicit_usage [] PROGMEM = "Implicit Feedback Data";
-const char reserved_usage [] PROGMEM = "Reserved";
-
-const char* usage_types [] PROGMEM =
-{
-  data_usage,
-  feedback_usage,
-  implicit_usage,
-  reserved_usage
-};
-
-/* HID Country Codes */
-
-const char notsupported_cc [] PROGMEM = "Not Supported";
-const char arabic_cc [] PROGMEM = "Arabic";
-const char belgian_cc [] PROGMEM = "Belgian";
-const char canadianbi_cc [] PROGMEM = "Canadian-Bilingual";
-const char canadianfr_cc [] PROGMEM = "Canadian-French";
-const char czech_cc [] PROGMEM = "Czech Republic";
-const char danish_cc [] PROGMEM = "Danish";
-const char finnish_cc [] PROGMEM = "Finnish";
-const char french_cc [] PROGMEM = "French";
-const char german_cc [] PROGMEM = "German";
-const char greek_cc [] PROGMEM = "Greek";
-const char hebrew_cc [] PROGMEM = "Hebrew";
-const char hungary_cc [] PROGMEM = "Hungary";
-const char intl_cc [] PROGMEM = "International (ISO)";
-const char italian_cc [] PROGMEM = "Italian";
-const char japan_cc [] PROGMEM = "Japan (Katakana)";
-const char korean_cc [] PROGMEM = "Korean";
-const char latam_cc [] PROGMEM = "Latin American";
-const char dutch_cc [] PROGMEM = "Netherlands/Dutch";
-const char norwegian_cc [] PROGMEM = "Norwegian";
-const char persian_cc [] PROGMEM = "Persian (Farsi)";
-const char poland_cc [] PROGMEM = "Poland";
-const char portuguese_cc [] PROGMEM = "Portuguese";
-const char russia_cc [] PROGMEM = "Russia";
-const char slovakia_cc [] PROGMEM = "Slovakia";
-const char spanish_cc [] PROGMEM = "Spanish";
-const char swedish_cc [] PROGMEM = "Swedish";
-const char swiss_fr_cc [] PROGMEM = "Swiss/French";
-const char swiss_ger_cc [] PROGMEM = "Swiss/German";
-const char swiss_cc [] PROGMEM = "Switzerland";
-const char taiwan_cc [] PROGMEM = "Taiwan";
-const char turkish_q_cc [] PROGMEM = "Turkish-Q";
-const char uk_cc [] PROGMEM = "UK";
-const char us_cc [] PROGMEM = "US";
-const char yugo_cc [] PROGMEM = "Yugoslavia";
-const char turkish_f_cc [] PROGMEM = "Turkish-F";
-
-const char* HID_Country_Codes [] PROGMEM =
-{
-notsupported_cc,
-arabic_cc,
-belgian_cc,
-canadianbi_cc,
-canadianfr_cc,
-czech_cc,
-danish_cc,
-finnish_cc,
-french_cc,
-german_cc,
-greek_cc,
-hebrew_cc,
-hungary_cc,
-intl_cc,
-italian_cc,
-japan_cc,
-korean_cc,
-latam_cc,
-dutch_cc,
-norwegian_cc,
-persian_cc,
-poland_cc,
-portuguese_cc,
-russia_cc,
-slovakia_cc,
-spanish_cc,
-swedish_cc,
-swiss_fr_cc,
-swiss_ger_cc,
-swiss_cc,
-taiwan_cc,
-turkish_q_cc,
-uk_cc,
-us_cc,
-yugo_cc,
-turkish_f_cc
-};
-
-/* HID report descriptor parser string definitions */
-/* Item type strings */
-const char btype_main [] PROGMEM = "Main";
-const char btype_global [] PROGMEM = "Global";
-const char btype_local [] PROGMEM = "Local";
-const char btype_reserved [] PROGMEM = "Reserved";
-/* Item types strings array. Array index corresponds to bType */
-const char* btypes [] PROGMEM =
-{
-  btype_main,
-  btype_global,
-  btype_local,
-  btype_reserved
-};
-/* Main Item Tag Strings */
-const char main_tag_input [] PROGMEM = "Input\t\t";
-const char main_tag_output [] PROGMEM = "Output\t\t";
-const char main_tag_collection [] PROGMEM = "Collection\t\t";
-const char main_tag_feature [] PROGMEM = "Feature\t\t";
-const char main_tag_endcoll [] PROGMEM = "End Collection\t";
-/* Main Item Tags Strings Array */
-const char* maintags [] PROGMEM =
-{
-  main_tag_input,
-  main_tag_output,
-  main_tag_collection,
-  main_tag_feature,
-  main_tag_endcoll
-};
-/* Global Item Tag Strings */
-const char global_tag_usagepage [] PROGMEM = "Usage Page\t\t";
-const char global_tag_logmin [] PROGMEM = "Logical Minimum\t";
-const char global_tag_logmax [] PROGMEM = "Logical Maximum\t";
-const char global_tag_physmin [] PROGMEM = "Physical Minimum\t";
-const char global_tag_physmax [] PROGMEM = "Physical Maximum\t";
-const char global_tag_unitexp [] PROGMEM = "Unit Exponent\t";
-const char global_tag_unit [] PROGMEM = "Unit\t\t";
-const char global_tag_repsize [] PROGMEM = "Report Size\t";
-const char global_tag_repid [] PROGMEM = "Report ID\t\t";
-const char global_tag_repcount [] PROGMEM = "Report Count\t";
-const char global_tag_push [] PROGMEM = "Push\t\t";
-const char global_tag_pop [] PROGMEM = "Pop\t\t";
-/* Global Item Tag Strings Array */
-const char* globaltags [] PROGMEM =
-{
-  global_tag_usagepage,
-  global_tag_logmin,
-  global_tag_logmax,
-  global_tag_physmin,
-  global_tag_physmax,
-  global_tag_unitexp,
-  global_tag_unit,
-  global_tag_repsize,
-  global_tag_repid,
-  global_tag_repcount,
-  global_tag_push,
-  global_tag_pop
-};
-/* Local Item Tag Strings */
-const char local_tag_usage [] PROGMEM = "Usage\t\t";
-const char local_tag_usagemin [] PROGMEM = "Usage Minimum\t";
-const char local_tag_usagemax [] PROGMEM = "Usage Maximum\t";
-const char local_tag_desidx [] PROGMEM = "Designator Index\t";
-const char local_tag_desmin [] PROGMEM = "Designator Minimum\t";
-const char local_tag_desmax [] PROGMEM = "Designator Maximum\t";
-const char local_tag_stridx [] PROGMEM = "String Index\t";
-const char local_tag_strmin [] PROGMEM = "String Minimum\t";
-const char local_tag_strmax [] PROGMEM = "String Maximum\t";
-const char local_tag_delimiter [] PROGMEM = "Delimiter\t";
-/* Local Item Tag Strings Array */
-const char* localtags [] PROGMEM =
-{
-  local_tag_usage,
-  local_tag_usagemin,
-  local_tag_usagemax,
-  local_tag_desidx,
-  local_tag_desmin,
-  local_tag_desmax,
-  local_tag_stridx,
-  local_tag_strmin,
-  local_tag_strmax,
-  local_tag_delimiter
-};
-/* Collection Types Strings */
-const char coll_phy [] PROGMEM = "Physical (group of axes)";
-const char coll_app [] PROGMEM = "Application (mouse, keyboard)";
-const char coll_log [] PROGMEM = "Logical (interrelated data)";
-const char coll_rep [] PROGMEM = "Report";
-const char coll_arr [] PROGMEM = "Named Array";
-const char coll_usw [] PROGMEM = "Usage Switch";
-const char coll_umod [] PROGMEM = "Usage Modifier";
-/* Collection Types Strings Array */
-const char* collections [] PROGMEM =
-{
-  coll_phy,
-  coll_app,
-  coll_log,
-  coll_rep,
-  coll_arr,
-  coll_usw,
-  coll_umod
-};
-/* Usage Pages Strings */
-const char up_undef [] PROGMEM = "Undefined";
-const char up_gendesk [] PROGMEM = "Generic Desktop Controls";
-const char up_sim [] PROGMEM = "Simulation Controls";
-const char up_vr [] PROGMEM = "VR Controls";
-const char up_sport [] PROGMEM = "Sport Controls";
-const char up_game [] PROGMEM = "Game Controls";
-const char up_gendev [] PROGMEM = "Generic Device Controls";
-const char up_kbd [] PROGMEM = "Keyboard/Keypad";
-const char up_led [] PROGMEM = "LEDs";
-const char up_button [] PROGMEM = "Button";
-const char up_ord [] PROGMEM = "Ordinal";
-const char up_tele [] PROGMEM = "Telephony";
-const char up_cons [] PROGMEM = "Consumer";
-const char up_dig [] PROGMEM = "Digitizer";
-//const char up_res [] PROGMEM = "Reserved";
-const char up_pid [] PROGMEM = "PID Page";
-const char up_uni [] PROGMEM = "Unicode";
-/* Usage Pages Strings Array  */
-const char * usage_pages [] PROGMEM =
-{
-  up_undef,
-  up_gendesk,
-  up_sim,
-  up_vr,
-  up_sport,
-  up_game,
-  up_gendev,
-  up_kbd,
-  up_led,
-  up_button,
-  up_ord,
-  up_tele,
-  up_cons,
-  up_dig,
-  reserved_msg,
-  up_pid,
-  up_uni
-};
-
-#endif //_DESCRIPTOR_PARSER_
diff --git a/USB_Host_Shield/examples/descriptor_parser/descriptor_parser.pde b/USB_Host_Shield/examples/descriptor_parser/descriptor_parser.pde
deleted file mode 100644
index d417e76..0000000
--- a/USB_Host_Shield/examples/descriptor_parser/descriptor_parser.pde
+++ /dev/null
@@ -1,720 +0,0 @@
-/* MAX3421E USB Host controller configuration descriptor parser */
-#include <Spi.h>
-#include <Max3421e.h>
-#include <Usb.h>
-#include "descriptor_parser.h"
- 
-#define LOBYTE(x) ((char*)(&(x)))[0]
-#define HIBYTE(x) ((char*)(&(x)))[1]
-#define BUFSIZE 256    //buffer size
-#define DEVADDR 1
-
-#define getReportDescr( addr, ep, nbytes, parse_func, nak_limit ) ctrlXfer( addr, ep, bmREQ_HIDREPORT, USB_REQUEST_GET_DESCRIPTOR, 0x00, HID_DESCRIPTOR_REPORT, 0x0000, nbytes, parse_func, nak_limit )
-#define getReport( addr, ep, nbytes, interface, report_type, report_id, parse_func, nak_limit ) ctrlXfer( addr, ep, bmREQ_HIDIN, HID_REQUEST_GET_REPORT, report_id, report_type, interface, nbytes, parse_func, nak_limit )
-
-/* Foeward declarations */ 
-void setup();
-void loop();
-byte ctrlXfer( byte addr, byte ep, byte bmReqType, byte bRequest, byte wValLo, byte wValHi, unsigned int wInd, uint16_t nbytes, PARSE parse_func, uint16_t nak_limit );
-void HIDreport_parse( uint8_t* buf, uint8_t* head, uint8_t* tail);
-
-typedef struct {
-  uint8_t bDescriptorType;
-  uint16_t wDescriptorLength;
-} HID_CLASS_DESCRIPTOR;
-
-
-//typedef void (*PARSE)( int8_t*, int8_t*, int8_t );
-
-MAX3421E Max;
-USB Usb;
- 
-void setup()
-{
-  Serial.begin( 115200 );
-  printProgStr(PSTR("\r\nStart"));
-  Max.powerOn();
-  delay( 200 );
-}
- 
-void loop()
-{
-  uint8_t rcode;
-  uint8_t tmpbyte = 0;
-  //PARSE pf = &HIDreport_parse;
-  /**/
-  Max.Task();
-  Usb.Task();
-  if( Usb.getUsbTaskState() >= USB_STATE_CONFIGURING ) {  //state configuring or higher
-  /* printing device descriptor */
-    printProgStr(PSTR("\r\nDevice addressed... "));
-    printProgStr(PSTR("Requesting device descriptor."));
-    tmpbyte = getdevdescr( DEVADDR );                           //number of configurations, 0 if error   
-    if( tmpbyte == 0 ) {
-      printProgStr(PSTR("\r\nDevice descriptor cannot be retrieved. Program Halted\r\n"));
-      while( 1 );           //stop
-     }//if( tmpbyte
-     /* print configuration descriptors for all configurations */
-     for( uint8_t i = 0; i < tmpbyte; i++ ) {
-       getconfdescr( DEVADDR, i );
-     }   
-  /* Stop */
-      while( 1 );                          //stop
-  }    
-}
-
-/* Prints device descriptor. Returns number of configurations or zero if request error occured */
-byte getdevdescr( byte addr )
-{
-  USB_DEVICE_DESCRIPTOR buf;
-  byte rcode;
-  //Max.toggle( BPNT_0 );
-  rcode = Usb.getDevDescr( addr, 0, 0x12, ( char *)&buf );
-  if( rcode ) {
-    printProgStr( rcode_error_msg );
-    print_hex( rcode, 8 );
-    return( 0 );
-  }
-  printProgStr(PSTR("\r\nDevice descriptor: \r\n"));
-  //Descriptor length
-  printProgStr( descr_len );
-  print_hex( buf.bLength, 8 );
-  //Descriptor type
-//  printProgStr( descr_type );
-//  print_hex( buf.bDescriptorType, 8 );
-//  printProgStr( descrtype_parse( buf.bDescriptorType ));
-  //USB Version
-  printProgStr(PSTR("\r\nUSB version:\t\t"));
-  Serial.print(( HIBYTE( buf.bcdUSB )), HEX );
-  Serial.print(".");
-  Serial.print(( LOBYTE( buf.bcdUSB )), HEX );
-  //Device class
-  printProgStr( class_str );
-  print_hex( buf.bDeviceClass, 8 );
-  printProgStr( classname_parse( buf.bDeviceClass ));
-  //Device Subclass 
-  printProgStr( subclass_str );
-  print_hex( buf.bDeviceSubClass, 8 );
-  //Device Protocol
-  printProgStr( protocol_str );
-  print_hex( buf.bDeviceProtocol, 8 );
-  //Max.packet size
-  printProgStr( maxpktsize_str );
-  print_hex( buf.bMaxPacketSize0, 8 );
-  //VID
-  printProgStr(PSTR("\r\nVendor  ID:\t\t"));
-  print_hex( buf.idVendor, 16 );
-  //PID
-  printProgStr(PSTR("\r\nProduct ID:\t\t"));
-  print_hex( buf.idProduct, 16 );
-  //Revision
-  printProgStr(PSTR("\r\nRevision ID:\t\t"));
-  print_hex( buf.bcdDevice, 16 );
-  //Mfg.string
-  printProgStr (PSTR("\r\nMfg.string index:\t"));
-  print_hex( buf.iManufacturer, 8 );
-  getstrdescr( addr, buf.iManufacturer );
-  //Prod.string
-  printProgStr(PSTR("\r\nProd.string index:\t"));
-  print_hex( buf.iProduct, 8 );
-  //printProgStr( str_cont );
-  getstrdescr( addr, buf.iProduct );
-  //Serial number string
-  printProgStr(PSTR("\r\nSerial number index:\t"));
-  print_hex( buf.iSerialNumber, 8 );
-  //printProgStr( str_cont );
-  getstrdescr( addr, buf.iSerialNumber );
-  //Number of configurations
-  printProgStr(PSTR("\r\nNumber of conf.:\t"));
-  print_hex( buf.bNumConfigurations, 8 );
-  return( buf.bNumConfigurations );
-}
-/* Get string descriptor. Takes device address and string index */
-byte getstrdescr( byte addr, byte idx )
-{
-  char buf[ BUFSIZE ];
-  byte rcode;
-  byte length;
-  byte i;
-  unsigned int langid;
-  if( idx == 0 ) {  //don't try to get index zero
-    return( 0 );
-  }
-  rcode = Usb.getStrDescr( addr, 0, 1, 0, 0, buf );  //get language table length
-  if( rcode ) {
-    printProgStr(PSTR("\r\nError retrieving LangID table length"));
-    return( rcode );
-  }
-  length = buf[ 0 ];      //length is the first byte
-  rcode = Usb.getStrDescr( addr, 0, length, 0, 0, buf );  //get language table
-  if( rcode ) {
-    printProgStr(PSTR("\r\nError retrieving LangID table"));
-    return( rcode );
-  }
-  HIBYTE( langid ) = buf[ 3 ];                            //get first langid  
-  LOBYTE( langid ) = buf[ 2 ];                            //bytes are swapped to account for endiannes
-  //printProgStr(PSTR("\r\nLanguage ID: "));
-  //print_hex( langid, 16 );
-  rcode = Usb.getStrDescr( addr, 0, 1, idx, langid, buf );
-  if( rcode ) {
-    printProgStr(PSTR("\r\nError retrieving string length"));
-    return( rcode );
-  }
-  length = ( buf[ 0 ] < 254 ? buf[ 0 ] : 254 );
-  printProgStr(PSTR(" Length: "));
-  Serial.print( length, DEC ); 
-  rcode = Usb.getStrDescr( addr, 0, length, idx, langid, buf );
-  if( rcode ) {
-    printProgStr(PSTR("\r\nError retrieveing string"));
-    return( rcode );
-  }
-  printProgStr(PSTR(" Contents: "));
-  for( i = 2; i < length; i+=2 ) {
-    Serial.print( buf[ i ] );
-  }
-  return( idx );
-}
-/* Returns string to class name */
-const char* classname_parse( byte class_number )
-{
-  switch( class_number ) {
-    case 0x00:
-      return PSTR(" Use class information in the Interface Descriptor");
-    case 0x01:
-      return PSTR(" Audio");
-    case 0x02:
-      return PSTR(" Communications and CDC Control");
-    case 0x03:
-      return PSTR(" HID (Human Interface Device)");
-    case 0x05:
-      return PSTR(" Physical");
-    case 0x06:
-      return PSTR(" Image");
-    case 0x07:
-      return PSTR(" Printer");
-    case 0x08:
-      return PSTR(" Mass Storage");
-    case 0x09:
-      return PSTR(" Hub");
-    case 0x0a:
-      return PSTR(" CDC-Data");
-    case 0x0b:
-      return PSTR(" Smart Card");
-    case 0x0d:
-      return PSTR(" Content Security");
-    case 0x0e:
-      return PSTR(" Video");
-    case 0x0f:
-      return PSTR(" Personal Healthcare");
-    case 0xdc:
-      return PSTR("Diagnostic Device");
-    case 0xe0:
-      return PSTR(" Wireless Controller");
-    case 0xef:
-      return PSTR(" Miscellaneous");
-    case 0xfe:
-      return PSTR(" Application Specific");
-    case 0xff:
-      return PSTR(" Vendor Specific");
-    default:
-      return unk_msg;
-  }//switch( class_number
-}            
-/* Getting configuration descriptor */
-byte getconfdescr( byte addr, byte conf )
-{
-  char buf[ BUFSIZE ];
-  char* buf_ptr = buf;
-  byte rcode;
-  byte descr_length;
-  byte descr_type;
-  unsigned int total_length;
-  printProgStr(PSTR("\r\n\nConfiguration number "));
-  Serial.print( conf, HEX );
-  rcode = Usb.getConfDescr( addr, 0, 4, conf, buf );  //get total length
-  if( rcode ) {
-    printProgStr(PSTR("Error retrieving configuration length. Error code "));
-    Serial.println( rcode, HEX );
-    return( 0 );
-  }//if( rcode
-  LOBYTE( total_length ) = buf[ 2 ];
-  HIBYTE( total_length ) = buf[ 3 ];
-  printProgStr(PSTR("\r\nTotal configuration length: "));
-  Serial.print( total_length, DEC );
-  printProgStr(PSTR(" bytes"));
-  if( total_length > BUFSIZE ) {    //check if total length is larger than buffer
-    printProgStr(PSTR("Total length truncated to "));
-    Serial.print( BUFSIZE, DEC);
-    printProgStr(PSTR("bytes"));
-    total_length = BUFSIZE;
-  }
-  rcode = Usb.getConfDescr( addr, 0, total_length, conf, buf ); //get the whole descriptor
-  while( buf_ptr < buf + total_length ) {  //parsing descriptors
-    descr_length = *( buf_ptr );
-    descr_type = *( buf_ptr + 1 );
-    switch( descr_type ) {
-      case( USB_DESCRIPTOR_CONFIGURATION ):
-        printconfdescr( buf_ptr );
-        break;
-      case( USB_DESCRIPTOR_INTERFACE ):
-        printintfdescr( buf_ptr );
-        break;
-      case( USB_DESCRIPTOR_ENDPOINT ):
-        printepdescr( buf_ptr );
-        break;
-      case( HID_DESCRIPTOR_HID ):
-        printhid_descr( buf_ptr );
-        break;
-      default:
-        printunkdescr( buf_ptr );
-        break;
-        }//switch( descr_type
-    Serial.println("");    
-    buf_ptr = ( buf_ptr + descr_length );    //advance buffer pointer
-  }//while( buf_ptr <=...
-  return( 0 );
-}
-/* function to print configuration descriptor */
-void printconfdescr( char* descr_ptr )
-{
- USB_CONFIGURATION_DESCRIPTOR* conf_ptr = ( USB_CONFIGURATION_DESCRIPTOR* )descr_ptr;
- uint8_t tmpbyte;
-  printProgStr(PSTR("\r\n\nConfiguration descriptor:"));
-  printProgStr(PSTR("\r\nTotal length:\t\t"));
-  print_hex( conf_ptr->wTotalLength, 16 );
-  printProgStr(PSTR("\r\nNumber of interfaces:\t"));
-  print_hex( conf_ptr->bNumInterfaces, 8 );
-  printProgStr(PSTR("\r\nConfiguration value:\t"));
-  print_hex( conf_ptr->bConfigurationValue, 8 );
-  printProgStr(PSTR("\r\nConfiguration string:\t"));
-  tmpbyte = conf_ptr->iConfiguration;
-  print_hex( tmpbyte, 8 );
-  getstrdescr( DEVADDR, tmpbyte );
-  printProgStr(PSTR("\r\nAttributes:\t\t"));
-  tmpbyte = conf_ptr->bmAttributes;
-  print_hex( tmpbyte, 8 );
-  if( tmpbyte & 0x40 ) {  //D6
-    printProgStr(PSTR(" Self-powered"));
-  }
-  if( tmpbyte & 0x20 ) { //D5
-    printProgStr(PSTR(" Remote Wakeup"));
-  }
-  printProgStr(PSTR("\r\nMax.power:\t\t"));
-  tmpbyte = conf_ptr->bMaxPower;
-  print_hex( tmpbyte, 8 );
-  printProgStr(PSTR(" "));
-  Serial.print(( tmpbyte * 2 ), DEC);
-  printProgStr(PSTR("ma"));
-  return;
-}
-/* function to print interface descriptor */
-void printintfdescr( char* descr_ptr )
-{
- USB_INTERFACE_DESCRIPTOR* intf_ptr = ( USB_INTERFACE_DESCRIPTOR* )descr_ptr;
- uint8_t tmpbyte;
-  printProgStr(PSTR("\r\nInterface descriptor:"));
-  printProgStr(PSTR("\r\nInterface number:\t"));
-  print_hex( intf_ptr->bInterfaceNumber, 8 );
-  printProgStr(PSTR("\r\nAlternate setting:\t"));
-  print_hex( intf_ptr->bAlternateSetting, 8 );
-  printProgStr(PSTR("\r\nEndpoints:\t\t"));
-  print_hex( intf_ptr->bNumEndpoints, 8 );
-  printProgStr( class_str );
-  tmpbyte = intf_ptr->bInterfaceClass;
-  print_hex( tmpbyte, 8 );
-  printProgStr(classname_parse( tmpbyte ));
-  printProgStr( subclass_str );
-  print_hex( intf_ptr->bInterfaceSubClass, 8 );
-  printProgStr( protocol_str );
-  print_hex( intf_ptr->bInterfaceProtocol, 8 );
-  printProgStr(PSTR("\r\nInterface string:\t"));
-  tmpbyte = intf_ptr->iInterface;
-  print_hex( tmpbyte, 8 );
-  getstrdescr( DEVADDR, tmpbyte );
-  return;
-}
-/* function to print endpoint descriptor */
-void printepdescr( char* descr_ptr )
-{
- USB_ENDPOINT_DESCRIPTOR* ep_ptr = ( USB_ENDPOINT_DESCRIPTOR* )descr_ptr;
- uint8_t tmpbyte;
-  printProgStr(PSTR("\r\nEndpoint descriptor:"));
-  printProgStr(PSTR("\r\nEndpoint address:\t"));
-  tmpbyte = ep_ptr->bEndpointAddress;
-  print_hex( tmpbyte & 0x0f, 8 );
-  printProgStr(PSTR(" Direction: "));
-  ( tmpbyte & 0x80 ) ? printProgStr(PSTR("IN")) : printProgStr(PSTR("OUT"));
-  printProgStr(PSTR("\r\nAttributes:\t\t"));
-  tmpbyte = ep_ptr->bmAttributes;
-  print_hex( tmpbyte, 8 );
-  printProgStr(PSTR(" Transfer type: "));
-  printProgStr((char*)pgm_read_word(&transfer_types[(tmpbyte & 0x03)]));
-  if(( tmpbyte & 0x03 ) == 1 ) {  //Isochronous Transfer
-    printProgStr(PSTR(", Sync Type: "));
-    printProgStr((char*)pgm_read_word(&sync_types[(tmpbyte & 0x0c)]));
-    printProgStr(PSTR(", Usage Type: "));
-    printProgStr((char*)pgm_read_word(&usage_types[(tmpbyte & 0x30)]));
-  }//if( tmpbyte & 0x01
-  printProgStr( maxpktsize_str );
-  print_hex( ep_ptr->wMaxPacketSize, 16 );
-  printProgStr(PSTR("\r\nPolling interval:\t"));
-  tmpbyte = ep_ptr->bInterval;
-  print_hex( tmpbyte, 8 );
-  printProgStr(PSTR(" "));
-  Serial.print( tmpbyte, DEC );
-  printProgStr(PSTR(" ms"));
-  return;
-}
-/* function to print HID descriptor */
-void printhid_descr( char* descr_ptr )
-{
- PARSE pf = &HIDreport_parse;
- USB_HID_DESCRIPTOR* hid_ptr = ( USB_HID_DESCRIPTOR* )descr_ptr;
- uint8_t tmpbyte;
-  /**/
-  printProgStr(PSTR("\r\nHID descriptor:"));
-  printProgStr(PSTR("\r\nDescriptor length:\t"));
-  tmpbyte = hid_ptr->bLength;
-  print_hex( tmpbyte, 8 );
-  printProgStr(PSTR(" "));
-  Serial.print( tmpbyte, DEC );
-  printProgStr(PSTR(" bytes"));
-  printProgStr(PSTR("\r\nHID version:\t\t"));
-  Serial.print(( HIBYTE( hid_ptr->bcdHID )), HEX );
-  Serial.print(".");
-  Serial.print(( LOBYTE( hid_ptr->bcdHID )), HEX );
-  tmpbyte = hid_ptr->bCountryCode;
-  printProgStr(PSTR("\r\nCountry Code:\t\t"));
-  Serial.print( tmpbyte, DEC );
-  printProgStr(PSTR(" "));
-  ( tmpbyte > 35 ) ? printProgStr(PSTR("Reserved")) : printProgStr((char*)pgm_read_word(&HID_Country_Codes[ tmpbyte ]));
-  tmpbyte = hid_ptr->bNumDescriptors;
-  printProgStr(PSTR("\r\nClass Descriptors:\t"));
-  Serial.print( tmpbyte, DEC );
-  //Printing class descriptors
-  descr_ptr += 6; //advance buffer pointer
-  for( uint8_t i = 0; i < tmpbyte; i++ ) {
-    uint8_t tmpdata;
-    HID_CLASS_DESCRIPTOR* hidclass_ptr = ( HID_CLASS_DESCRIPTOR* )descr_ptr;
-    tmpdata = hidclass_ptr->bDescriptorType;
-    printProgStr(PSTR("\r\nClass Descriptor Type:\t"));
-    Serial.print( tmpdata, HEX );
-    if(( tmpdata < 0x21 ) || ( tmpdata > 0x2f )) {
-     printProgStr(PSTR(" Invalid"));
-    }
-    switch( tmpdata ) {
-      case 0x21:
-        printProgStr(PSTR(" HID"));
-        break;
-      case 0x22:
-        printProgStr(PSTR(" Report"));
-        break;
-      case 0x23:
-        printProgStr(PSTR(" Physical"));
-        break;
-      default:
-        printProgStr(PSTR(" Reserved"));
-        break;
-    }//switch( tmpdata
-    printProgStr(PSTR("\r\nClass Descriptor Length:"));
-    Serial.print( hidclass_ptr->wDescriptorLength );
-    printProgStr(PSTR(" bytes"));
-    printProgStr(PSTR("\r\n\nHID report descriptor:\r\n"));
-    getReportDescr( DEVADDR, 0 , hidclass_ptr->wDescriptorLength, pf, USB_NAK_LIMIT );
-    descr_ptr += 3; //advance to the next record
-  }//for( uint8_t i=...
-  return;
-}
-/*function to print unknown descriptor */
-void printunkdescr( char* descr_ptr )
-{
-  byte length = *descr_ptr;
-  byte i;
-  printProgStr(PSTR("\r\nUnknown descriptor:"));
-  printProgStr(PSTR("Length:\t\t"));
-  print_hex( *descr_ptr, 8 );
-  printProgStr(PSTR("\r\nType:\t\t"));
-  print_hex( *(descr_ptr + 1 ), 8 );
-  printProgStr(PSTR("\r\nContents:\t"));
-  descr_ptr += 2;
-  for( i = 0; i < length; i++ ) {
-    print_hex( *descr_ptr, 8 );
-    descr_ptr++;
-  }
-}
-/* Control-IN transfer with callback. Sets address, endpoint, fills control packet with necessary data, dispatches control packet, and initiates bulk IN transfer   */
-/* Control, data, and setup stages combined from standard USB library to be able to read large data blocks. Restricted to control-IN transfers with data stage   */
-/* data read and MAX3421E RECV FIFO buffer release shall be performed by parse_func callback */
-/* return codes:                */
-/* 00       =   success         */
-/* 01-0f    =   non-zero HRSLT  */
-byte ctrlXfer( byte addr, byte ep, byte bmReqType, byte bRequest, byte wValLo, byte wValHi, unsigned int wInd, uint16_t nbytes, PARSE parse_func, uint16_t nak_limit = USB_NAK_LIMIT )
-{
- byte rcode;   
- SETUP_PKT sp;
- EP_RECORD* ep_rec = Usb.getDevTableEntry( addr, ep );
- byte pktsize;
- byte maxpktsize = ep_rec->MaxPktSize;
- unsigned int xfrlen = 0;
-  /**/
-  Max.regWr( rPERADDR, addr );                    //set peripheral address
-  /* fill in setup packet */
-  sp.ReqType_u.bmRequestType = bmReqType;
-  sp.bRequest = bRequest;
-  sp.wVal_u.wValueLo = wValLo;
-  sp.wVal_u.wValueHi = wValHi;
-  sp.wIndex = wInd;
-  sp.wLength = nbytes;
-  Max.bytesWr( rSUDFIFO, 8, ( char *)&sp );    //transfer to setup packet FIFO
-  rcode = Usb.dispatchPkt( tokSETUP, ep, nak_limit );            //dispatch packet
-  //Serial.println("Setup packet");   //DEBUG
-  if( rcode ) {                                   //return HRSLT if not zero
-      printProgStr(PSTR("\r\nSetup packet error: "));
-      Serial.print( rcode, HEX );                                          
-      return( rcode );
-  }
-  /* Data stage */
-  //ep_rec->rcvToggle = bmRCVTOG1;
-  Max.regWr( rHCTL, bmRCVTOG1 );  //set toggle
-  while( 1 ) {                    //exited by break
-    /* request data */
-    rcode = Usb.dispatchPkt( tokIN, ep, nak_limit );
-    if( rcode ) {
-      printProgStr(PSTR("\r\nData Stage Error: "));
-      Serial.print( rcode, HEX );
-      return( rcode );
-    }
-    /* check for RCVDAVIRQ and generate error if not present */ 
-    /* the only case when absense of RCVDAVIRQ makes sense is when toggle error occured. Need to add handling for that */
-    if(( Max.regRd( rHIRQ ) & bmRCVDAVIRQ ) == 0 ) {
-      printProgStr(PSTR("\r\nData Toggle error."));
-      return ( 0xf0 );                            
-    }    
-    pktsize = Max.regRd( rRCVBC );  //get received bytes count
-    parse_func( pktsize );          //call parse function. Parse is expected to read the FIFO completely
-    Max.regWr( rHIRQ, bmRCVDAVIRQ );                    // Clear the IRQ & free the buffer
-    xfrlen += pktsize;                              // add this packet's byte count to total transfer length
-    /* The transfer is complete under two conditions:           */
-    /* 1. The device sent a short packet (L.T. maxPacketSize)   */
-    /* 2. 'nbytes' have been transferred.                       */
-    if (( pktsize < maxpktsize ) || (xfrlen >= nbytes )) {      // have we transferred 'nbytes' bytes?
-      break;
-    }
-  }//while( 1 )
-  rcode = Usb.dispatchPkt( tokOUTHS, ep, nak_limit );
-  if( rcode ) {   //return error
-    printProgStr(PSTR("Status packet error: "));
-    Serial.print( rcode, HEX );                                          
-  }
-  return( rcode );
-}
-/* Parses bitfields in main items */
-void print_mainbitfield( uint8_t byte_toparse )
-{
-  ( byte_toparse & 0x01 ) ? printProgStr(PSTR("Constant,")) : printProgStr(PSTR("Data,"));  //bit 0
-  ( byte_toparse & 0x02 ) ? printProgStr(PSTR("Variable,")) : printProgStr(PSTR("Array,"));  //bit 1
-  ( byte_toparse & 0x04 ) ? printProgStr(PSTR("Relative,")) : printProgStr(PSTR("Absolute,"));  //...
-  ( byte_toparse & 0x08 ) ? printProgStr(PSTR("Wrap,")) : printProgStr(PSTR("No Wrap,"));
-  ( byte_toparse & 0x10 ) ? printProgStr(PSTR("Non Linear,")) : printProgStr(PSTR("Linear,"));
-  ( byte_toparse & 0x20 ) ? printProgStr(PSTR("No preferred,")) : printProgStr(PSTR("Preferred State,"));
-  ( byte_toparse & 0x40 ) ? printProgStr(PSTR("Null State,")) : printProgStr(PSTR("No Null Position,"));  //bit 6
-  ( byte_toparse & 0x40 ) ? printProgStr(PSTR("Volatile( ignore for Input),")) : printProgStr(PSTR("Non-volatile(Ignore for Input),"));  //bit 7
-}
-/* HID Report Desriptor Parser Callback             */
-/* called repeatedly from Control transfer function */
-void HIDreport_parse( uint8_t pkt_size )
-{
-#define B_SIZE 0x03        //bSize bitmask
-#define B_TYPE 0x0c        //bType bitmask
-#define B_TAG  0xf0        //bTag bitmask
- /* parser states */
- enum STATE { ITEM_START, DATA_PARSE };
- static STATE state = ITEM_START;
- static uint8_t databytes_left = 0;
- static uint8_t prefix;              //item prefix - type and tag
- uint8_t byte_toparse;
- uint8_t bType;
- uint8_t tmpbyte;
- /**/
-  while( 1 ) {
-     if( pkt_size ) {
-       byte_toparse = Max.regRd( rRCVFIFO );  //read a byte from FIFO
-       pkt_size--;
-     }
-     else {
-       return;                                //all bytes read
-     }
-     switch( state ) {
-      case ITEM_START:  //start of the record
-        prefix = byte_toparse >>2;        //store prefix for databyte parsing
-        tmpbyte = byte_toparse & B_SIZE; 
-        /* get item length */
-        ( tmpbyte == 0x03 ) ? databytes_left = 4 : databytes_left = tmpbyte;
-         if( databytes_left ) {
-           state = DATA_PARSE;    //read bytes after prefix
-         }
-         printProgStr(PSTR("\r\nLength: "));
-         Serial.print( databytes_left, DEC );
-         /* get item type */
-         bType = ( byte_toparse & B_TYPE ) >>2;
-         printProgStr(PSTR("  Type: "));
-         printProgStr((char*)pgm_read_word(&btypes[ bType ]));
-         /* get item tag */
-         printProgStr(PSTR("\t\tTag: "));
-         tmpbyte = ( byte_toparse & B_TAG ) >>4 ;
-         switch( bType ) {
-           case 0:  //Main
-             if( tmpbyte < 0x08 ) {
-               printProgStr(PSTR("Invalid Tag"));
-             }
-             else if( tmpbyte > 0x0c ) {
-               printProgStr( reserved_msg ); 
-             }
-             else {
-               printProgStr((char*)pgm_read_word(&maintags[ tmpbyte - 8 /* & 0x03 */]));
-               //Serial.print("Byte: ");
-               //Serial.println( tmpbyte, HEX );
-             }
-             break;//case 0 Main
-           case 1:  //Global
-             ( tmpbyte > 0x0b ) ? printProgStr( reserved_msg ) : printProgStr((char*)pgm_read_word(&globaltags[ tmpbyte ]));
-             break;//case 1 Global
-           case 2:  //Local
-             ( tmpbyte > 0x0a ) ? printProgStr( reserved_msg ) : printProgStr((char*)pgm_read_word(&localtags[ tmpbyte ]));
-             break;//case 2 Local
-           default:
-             break;  
-         }//switch( bType...        
-         break;//case ITEM_START
-       case DATA_PARSE:
-         switch( prefix ) {
-           case 0x20:  //Main Input
-           case 0x24:  //Main Output
-           case 0x2c:  //Main Feature
-             /* todo: add parsing 8th bit */
-             print_mainbitfield( byte_toparse );
-             break;
-           case 0x28:    //Main Collection
-             if(( byte_toparse > 0x06 ) && ( byte_toparse < 0x80 )) {
-               printProgStr( reserved_msg );
-             }
-             else if(( byte_toparse > 0x7f ) && ( byte_toparse <= 0xff )) {
-               printProgStr(PSTR("Vendor-defined"));
-             }
-             else {
-               printProgStr((char*)pgm_read_word(&collections[ byte_toparse ]));
-             }
-             break;//case 0x28 Main Collection           
-           //case 0x30: //Main End Collection
-           case 0x01:    //Global Usage Page
-             switch( byte_toparse ) {  //see HID Usage Tables doc v.1.12 page 14
-               case 0x00:              
-               case 0x01:
-               case 0x02:
-               case 0x03:
-               case 0x04:
-               case 0x05:
-               case 0x06:
-               case 0x07:
-               case 0x08:
-               case 0x09:
-               case 0x0a:
-               case 0x0b:
-               case 0x0c:
-               case 0x0d:
-               case 0x0e:
-               case 0x0f:
-               case 0x10:
-                 printProgStr((char*)pgm_read_word(&usage_pages[ byte_toparse ]));
-                 break;
-               case 0x14:
-                 printProgStr(PSTR("Alphanumeric Display"));
-                 break;
-               case 0x40:
-                 printProgStr(PSTR("Medical Instruments"));
-                 break;
-               case 0x80:
-               case 0x81:
-               case 0x82:
-               case 0x83:
-                 printProgStr(PSTR("Monitor page"));
-                 break;
-               case 0x84:
-               case 0x85:
-               case 0x86:
-               case 0x87:
-                 printProgStr(PSTR("Power page"));
-                 break;
-               case 0x8c:
-                 printProgStr(PSTR("Bar Code Scanner page"));
-                 break;
-               case 0x8d:
-                 printProgStr(PSTR("Scale page"));
-                 break;
-               case 0x8e:
-                 printProgStr(PSTR("Magnetic Stripe Reading (MSR) Devices"));
-                 break;
-               case 0x8f:
-                 printProgStr(PSTR("Reserved Point of Sale pages"));
-                 break;
-               case 0x90:
-                 printProgStr(PSTR("Camera Control Page"));
-                 break;
-               case 0x91: 
-                 printProgStr(PSTR("Arcade Page"));
-                 break;                
-             default:
-//               printProgStr(PSTR("Data: "));
-//               print_hex( byte_toparse, 8 );
-               //databytes_left--;
-               break;           
-             }//switch case 0x01:    //Global Usage Page
-         }//switch( prefix ...         
-         printProgStr(PSTR("  Data: "));
-         print_hex( byte_toparse, 8 );
-         databytes_left--;
-         if( !databytes_left ) {
-           state = ITEM_START;
-         }
-         break;
-     }//switch( state...
-   }//while( 1 ...
-}
-/* prints hex numbers with leading zeroes */
-// copyright, Peter H Anderson, Baltimore, MD, Nov, '07
-// source: http://www.phanderson.com/arduino/arduino_display.html
-void print_hex(int v, int num_places)
-{
-  int mask=0, n, num_nibbles, digit;
- 
-  for (n=1; n<=num_places; n++) {
-    mask = (mask << 1) | 0x0001;
-  }
-  v = v & mask; // truncate v to specified number of places
- 
-  num_nibbles = num_places / 4;
-  if ((num_places % 4) != 0) {
-    ++num_nibbles;
-  }
-  do {
-    digit = ((v >> (num_nibbles-1) * 4)) & 0x0f;
-    Serial.print(digit, HEX);
-  } 
-  while(--num_nibbles);
-}
-
-/* given a PROGMEM string, use Serial.print() to send it out       */
-/* Some non-intuitive casting necessary:                           */
-/* printProgStr(PSTR("Func.Mode:\t0x"));                           */
-/* printProgStr((char*)pgm_read_word(&mtpopNames[(op & 0xFF)]));   */
-void printProgStr(const char* str)
-{
-  if(!str) { 
-    return;
-  }
-  char c;
-  while((c = pgm_read_byte(str++))) {
-    Serial.print(c,BYTE);
-  }
-  return;
-}
