diff options
author | tmk <nobody@nowhere> | 2013-03-27 15:23:57 +0900 |
---|---|---|
committer | tmk <nobody@nowhere> | 2013-03-27 15:23:57 +0900 |
commit | 969cc4f812e3f86213f97adf340e3c7160fc639e (patch) | |
tree | ad3719c0dd8cce043c235fd2d7e30c8bcd65f7af /protocol/pjrc/usb.c | |
parent | 1f19176867b1b1f760c0ec41cd78fbb6832d29ad (diff) | |
parent | ac509aa079bb090017886b5d7e32240ef16a1196 (diff) | |
download | firmware-969cc4f812e3f86213f97adf340e3c7160fc639e.tar.gz firmware-969cc4f812e3f86213f97adf340e3c7160fc639e.tar.bz2 firmware-969cc4f812e3f86213f97adf340e3c7160fc639e.zip |
Merge branch 'suspend_fix'
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 @@ #include "usb_extra.h" #include "print.h" #include "util.h" +#include "sleep_led.h" +#include "suspend.h" /************************************************************************** @@ -595,7 +597,8 @@ void usb_init(void) USB_CONFIG(); // start USB clock UDCON = 0; // enable attach resistor usb_configuration = 0; - UDIEN = (1<<EORSTE)|(1<<SOFE)|(1<<SUSPE); + suspend = false; + UDIEN = (1<<EORSTE)|(1<<SOFE)|(1<<SUSPE)|(1<<WAKEUPE); sei(); } @@ -631,9 +634,23 @@ ISR(USB_GEN_vect) intbits = UDINT; UDINT = 0; - if (intbits & (1<<SUSPI)) { + if ((intbits & (1<<SUSPI)) && (UDIEN & (1<<SUSPE)) && usb_configuration) { +#ifdef SLEEP_LED_ENABLE + sleep_led_enable(); +#endif + UDIEN &= ~(1<<SUSPE); + UDIEN |= (1<<WAKEUPE); suspend = true; - } else { + } + if ((intbits & (1<<WAKEUPI)) && (UDIEN & (1<<WAKEUPE)) && usb_configuration) { + suspend_wakeup_init(); +#ifdef SLEEP_LED_ENABLE + sleep_led_disable(); +#endif + led_set(host_keyboard_leds()); + + UDIEN |= (1<<SUSPE); + UDIEN &= ~(1<<WAKEUPE); suspend = false; } if (intbits & (1<<EORSTI)) { |