+
+ // XXX Power negotiation hack -HaaTa
+ // Some devices such as the Apple Ipad do not support bMaxPower greater than 100 mA
+ // However, there is no provision in the basic USB 2.0 stack for power negotiation
+ // To get around this:
+ // * Attempt to set bMaxPower to 500 mA first
+ // * If more than 100 ms passes since retrieving a Get Configuration Descriptor
+ // (Descriptor with bMaxPower in it)
+ // * Change usb_bMaxPower to 50 (100 mA)
+ // * Restart the USB init process
+ // According to notes online, it says that some Apple devices can only do 20 mA
+ // However, in my testing this hasn't been the case
+ // (you can also draw as much current as you want if you just lie in the descriptor :P)
+ // If this becomes an issue we can use this hack a second time to negotiate down to 20 mA
+ // (which should be fine for just the mcu)
+ if ( setup.wValue == 0x0200 && setup.wIndex == 0x0 )
+ {
+ power_neg_delay = 1;
+ power_neg_time = systick_millis_count;
+ }
+