void xbox_init(bool watchdog) { if (watchdog) { wdt_enable(WDTO_2S); } else { wdt_disable(); } xbox_reset_pad_status(); USB_Init(); sei(); }
void xbox_init(bool watchdog) { uchar i; // disable timer 0 overflow interrupt (enabled by Arduino's init() function). // PS3 was having difficulties detecting the adapter if that's enabled. // WARNING: This will mess up with micros(), millis() and delay() Arduino functions! // Use alternate timer functions instead! #if defined(TIMSK) && defined(TOIE0) (_SFR_BYTE(TIMSK) &= ~_BV(TOIE0)); #elif defined(TIMSK0) && defined(TOIE0) (_SFR_BYTE(TIMSK0) &= ~_BV(TOIE0)); #endif xbox_reset_pad_status(); if(watchdog) { wdt_enable(WDTO_2S); } else { wdt_disable(); } /* Even if you don't use the watchdog, turn it off here. On newer devices, * the status of the watchdog (on/off, period) is PRESERVED OVER RESET! */ /* RESET status: all port bits are inputs without pull-up. * That's the way we need D+ and D-. Therefore we don't need any * additional hardware initialization. */ usbInit(); usbDeviceDisconnect(); /* enforce re-enumeration, do this while interrupts are disabled! */ i = 0; while (--i) { /* fake USB disconnect for > 250 ms */ wdt_reset(); _delay_ms(1); } usbDeviceConnect(); sei(); }