diff options
Diffstat (limited to 'protocol/pjrc')
| -rw-r--r-- | protocol/pjrc/main.c | 17 | ||||
| -rw-r--r-- | protocol/pjrc/usb.c | 23 |
2 files changed, 32 insertions, 8 deletions
diff --git a/protocol/pjrc/main.c b/protocol/pjrc/main.c index 776bfee9d..5f15dbf89 100644 --- a/protocol/pjrc/main.c +++ b/protocol/pjrc/main.c | |||
| @@ -31,10 +31,7 @@ | |||
| 31 | #include "print.h" | 31 | #include "print.h" |
| 32 | #include "debug.h" | 32 | #include "debug.h" |
| 33 | #include "util.h" | 33 | #include "util.h" |
| 34 | #include "bootloader.h" | 34 | #include "suspend.h" |
| 35 | #ifdef PS2_MOUSE_ENABLE | ||
| 36 | # include "ps2_mouse.h" | ||
| 37 | #endif | ||
| 38 | #include "host.h" | 35 | #include "host.h" |
| 39 | #include "pjrc.h" | 36 | #include "pjrc.h" |
| 40 | 37 | ||
| @@ -55,7 +52,17 @@ int main(void) | |||
| 55 | 52 | ||
| 56 | keyboard_init(); | 53 | keyboard_init(); |
| 57 | host_set_driver(pjrc_driver()); | 54 | host_set_driver(pjrc_driver()); |
| 55 | #ifdef SLEEP_LED_ENABLE | ||
| 56 | sleep_led_init(); | ||
| 57 | #endif | ||
| 58 | while (1) { | 58 | while (1) { |
| 59 | keyboard_task(); | 59 | while (suspend) { |
| 60 | suspend_power_down(); | ||
| 61 | if (remote_wakeup && suspend_wakeup_condition()) { | ||
| 62 | usb_remote_wakeup(); | ||
| 63 | } | ||
| 64 | } | ||
| 65 | |||
| 66 | keyboard_task(); | ||
| 60 | } | 67 | } |
| 61 | } | 68 | } |
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)) { |
