void USBDevice_::attach() { _usbConfiguration = 0; _usbCurrentStatus = 0; _usbSuspendState = 0; USB_ClockEnable(); UDINT &= ~((1<<WAKEUPI) | (1<<SUSPI)); // clear already pending WAKEUP / SUSPEND requests UDIEN = (1<<EORSTE) | (1<<SOFE) | (1<<SUSPE); // Enable interrupts for EOR (End of Reset), SOF (start of frame) and SUSPEND TX_RX_LED_INIT; }
void USBDevice_::attach() { _usbConfiguration = 0; _usbCurrentStatus = 0; _usbSuspendState = 0; USB_ClockEnable(); UDINT &= ~((1<<WAKEUPI) | (1<<SUSPI)); // clear already pending WAKEUP / SUSPEND requests UDIEN = (1<<EORSTE) | (1<<SOFE) | (1<<SUSPE); // Enable interrupts for EOR (End of Reset), SOF (start of frame) and SUSPEND TX_RX_LED_INIT; #if MAGIC_KEY_POS != (RAMEND-1) if (pgm_read_word(FLASHEND - 1) == NEW_LUFA_SIGNATURE) { _updatedLUFAbootloader = true; } #endif }
bool USBDevice_::wakeupHost() { // clear any previous wakeup request which might have been set but could be processed at that time // e.g. because the host was not suspended at that time UDCON &= ~(1 << RMWKUP); if(!(UDCON & (1 << RMWKUP)) && (_usbSuspendState & (1<<SUSPI)) && (_usbCurrentStatus & FEATURE_REMOTE_WAKEUP_ENABLED)) { // This short version will only work, when the device has not been suspended. Currently the // Arduino core doesn't handle SUSPEND at all, so this is ok. USB_ClockEnable(); UDCON |= (1 << RMWKUP); // send the wakeup request return true; } return false; }