From aa6fc58bc4d285e7e464e85aeb12f9f696f18543 Mon Sep 17 00:00:00 2001 From: Oleg Mazurov Date: Mon, 18 Apr 2011 10:11:59 -0600 Subject: [PATCH] Apr.11 updates --- Usb.h | 17 ++++++++-------- address.h | 3 +++ diff.txt | 1 - newusb.pde | 59 ------------------------------------------------------ usbhost.h | 12 ++++++++++- 5 files changed, 23 insertions(+), 69 deletions(-) delete mode 100644 diff.txt delete mode 100644 newusb.pde diff --git a/Usb.h b/Usb.h index 9f96efe5..7d96216d 100644 --- a/Usb.h +++ b/Usb.h @@ -134,12 +134,13 @@ #define USB_DEV_CONFIG_ERROR_DEVICE_INIT_INCOMPLETE 0xD2 #define USB_ERROR_UNABLE_TO_REGISTER_DEVICE_CLASS 0xD3 #define USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL 0xD4 -#define USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL 0xD5 -#define USB_ERROR_EPINFO_IS_NULL 0xD6 -#define USB_ERROR_INVALID_ARGUMENT 0xD7 -#define USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE 0xD8 -#define USB_ERROR_INVALID_MAX_PKT_SIZE 0xD9 -#define USB_ERROR_EP_NOT_FOUND_IN_TBL 0xDA +#define USB_ERROR_HUB_ADDRESS_OVERFLOW 0xD5 +#define USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL 0xD6 +#define USB_ERROR_EPINFO_IS_NULL 0xD7 +#define USB_ERROR_INVALID_ARGUMENT 0xD8 +#define USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE 0xD9 +#define USB_ERROR_INVALID_MAX_PKT_SIZE 0xDA +#define USB_ERROR_EP_NOT_FOUND_IN_TBL 0xDB class USBDeviceConfig { @@ -156,8 +157,8 @@ public: #define USB_SETTLE_DELAY 200 //settle delay in milliseconds #define USB_NAK_NOWAIT 1 //used in Richard's PS2/Wiimote code -#define USB_NUMDEVICES 64 //number of USB devices -#define HUB_MAX_HUBS 7 // maximum number of hubs that can be attached to the host controller +#define USB_NUMDEVICES 16 //number of USB devices +#define HUB_MAX_HUBS 5 // maximum number of hubs that can be attached to the host controller #define HUB_PORT_RESET_DELAY 20 // hub port reset delay 10 ms recomended, can be up to 20 ms /* USB state machine states */ diff --git a/address.h b/address.h index 75b6a58c..f3da24f8 100644 --- a/address.h +++ b/address.h @@ -185,6 +185,9 @@ public: if (parent > 127 || port > 7) return 0; + if (is_hub && hubCounter == 7) + return 0; + // finds first empty address entry starting from one uint8_t index = FindAddressIndex(0); diff --git a/diff.txt b/diff.txt deleted file mode 100644 index 21b456b3..00000000 --- a/diff.txt +++ /dev/null @@ -1 +0,0 @@ -Comparing files usbhost.h and USBHOST.H2 diff --git a/newusb.pde b/newusb.pde deleted file mode 100644 index 0fd7d701..00000000 --- a/newusb.pde +++ /dev/null @@ -1,59 +0,0 @@ -/* new USB library tests */ - -//nclude -#include "usbhost.h" - -MAX3421e Max; -uint8_t buf[10] = {0}; - -void setup() { -// Max.regWr( rPINCTL,( bmFDUPSPI + bmINTLEVEL )); -// Max.regWr( rUSBCTL, bmCHIPRES ); //Chip reset. This stops the oscillator -// Max.regWr( rUSBCTL, 0x00 ); //Remove the reset -// delay( 100 ); - Serial.begin( 115200 ); - Serial.println("Start"); - - // pinModeFast2( 8, OUTPUT) - -} - -void loop() { -// uint16_t i; -// Max.regWr( rUSBCTL, bmCHIPRES ); -// Max.regWr( rUSBCTL, 0x00 ); -// for( i = 0; i < 65535; i++ ) { -// if( ( Max.regRd( rUSBIRQ ) & bmOSCOKIRQ )) { -// break; -// } -// } - Serial.println( Max.reset(), DEC ); - //Max.reset(); - //delay( 100 ); - //Max.regRd( rREVISION ); - //Serial.println( Max.regRd( rREVISION ), HEX ); - - //Serial.println("tick"); - // uint8_t tmp; - // for( uint16_t i = 0; i < 256; i++ ) { - // tmp = Max.SPIxfer( i ); - // if( tmp != i ) { - // Serial.println("error"); - // } - // if( SPSR & 0x40 ) { - // Serial.println("WCOL"); - // } - // } - // static bool oldintval = 0; - // if( Max.intval() != oldintval ) { - // oldintval = Max.intval(); - // Serial.println( oldintval, DEC ); - // } - // Max.sstoggle(); - - //digitalWriteFast2( 8, 0 ); - //digitalWriteFast2( 8, 1 ); -} - - - diff --git a/usbhost.h b/usbhost.h index 04cc1077..46212f31 100644 --- a/usbhost.h +++ b/usbhost.h @@ -171,7 +171,17 @@ uint16_t MAX3421e< SS, INTR >::reset() } return( i ); } - +///* initialize MAX3421E. Set Host mode, pullups, and stuff. Returns 0 if success, -1 if not */ +//template< typename SS, typename INTR > +//int8_t MAX3421e< SS, INTR >::Init() +//{ +// if( reset() == 0 ) { //OSCOKIRQ hasn't asserted in time +// return ( -1 ); +// } +// regWr( rMODE, bmDPPULLDN|bmDMPULLDN|bmHOST ); // set pull-downs, Host +// +// return( 0 ); +//} /* initialize MAX3421E. Set Host mode, pullups, and stuff. Returns 0 if success, -1 if not */ template< typename SS, typename INTR > int8_t MAX3421e< SS, INTR >::Init()