diff options
Diffstat (limited to 'protocol/pjrc/usb.c')
| -rw-r--r-- | protocol/pjrc/usb.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/protocol/pjrc/usb.c b/protocol/pjrc/usb.c index f4c6f81f5..a9fbc4638 100644 --- a/protocol/pjrc/usb.c +++ b/protocol/pjrc/usb.c | |||
| @@ -33,6 +33,8 @@ | |||
| 33 | #include "usb_extra.h" | 33 | #include "usb_extra.h" |
| 34 | #include "print.h" | 34 | #include "print.h" |
| 35 | #include "util.h" | 35 | #include "util.h" |
| 36 | #include "sleep_led.h" | ||
| 37 | #include "suspend.h" | ||
| 36 | 38 | ||
| 37 | 39 | ||
| 38 | /************************************************************************** | 40 | /************************************************************************** |
| @@ -595,7 +597,8 @@ void usb_init(void) | |||
| 595 | USB_CONFIG(); // start USB clock | 597 | USB_CONFIG(); // start USB clock |
| 596 | UDCON = 0; // enable attach resistor | 598 | UDCON = 0; // enable attach resistor |
| 597 | usb_configuration = 0; | 599 | usb_configuration = 0; |
| 598 | UDIEN = (1<<EORSTE)|(1<<SOFE)|(1<<SUSPE); | 600 | suspend = false; |
| 601 | UDIEN = (1<<EORSTE)|(1<<SOFE)|(1<<SUSPE)|(1<<WAKEUPE); | ||
| 599 | sei(); | 602 | sei(); |
| 600 | } | 603 | } |
| 601 | 604 | ||
| @@ -631,9 +634,23 @@ ISR(USB_GEN_vect) | |||
| 631 | 634 | ||
| 632 | intbits = UDINT; | 635 | intbits = UDINT; |
| 633 | UDINT = 0; | 636 | UDINT = 0; |
| 634 | if (intbits & (1<<SUSPI)) { | 637 | if ((intbits & (1<<SUSPI)) && (UDIEN & (1<<SUSPE)) && usb_configuration) { |
| 638 | #ifdef SLEEP_LED_ENABLE | ||
| 639 | sleep_led_enable(); | ||
| 640 | #endif | ||
| 641 | UDIEN &= ~(1<<SUSPE); | ||
| 642 | UDIEN |= (1<<WAKEUPE); | ||
| 635 | suspend = true; | 643 | suspend = true; |
| 636 | } else { | 644 | } |
| 645 | if ((intbits & (1<<WAKEUPI)) && (UDIEN & (1<<WAKEUPE)) && usb_configuration) { | ||
| 646 | suspend_wakeup_init(); | ||
| 647 | #ifdef SLEEP_LED_ENABLE | ||
| 648 | sleep_led_disable(); | ||
| 649 | #endif | ||
| 650 | led_set(host_keyboard_leds()); | ||
| 651 | |||
| 652 | UDIEN |= (1<<SUSPE); | ||
| 653 | UDIEN &= ~(1<<WAKEUPE); | ||
| 637 | suspend = false; | 654 | suspend = false; |
| 638 | } | 655 | } |
| 639 | if (intbits & (1<<EORSTI)) { | 656 | if (intbits & (1<<EORSTI)) { |
