diff options
Diffstat (limited to 'protocol/lufa/lufa.c')
| -rw-r--r-- | protocol/lufa/lufa.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c index 16a602df1..6802f3b63 100644 --- a/protocol/lufa/lufa.c +++ b/protocol/lufa/lufa.c | |||
| @@ -148,10 +148,23 @@ static void Console_Task(void) | |||
| 148 | */ | 148 | */ |
| 149 | void EVENT_USB_Device_Connect(void) | 149 | void EVENT_USB_Device_Connect(void) |
| 150 | { | 150 | { |
| 151 | /* For battery powered device */ | ||
| 152 | if (!USB_IsInitialized) { | ||
| 153 | USB_Init(); | ||
| 154 | USB_Device_EnableSOFEvents(); | ||
| 155 | } | ||
| 151 | } | 156 | } |
| 152 | 157 | ||
| 153 | void EVENT_USB_Device_Disconnect(void) | 158 | void EVENT_USB_Device_Disconnect(void) |
| 154 | { | 159 | { |
| 160 | /* For battery powered device */ | ||
| 161 | /* TODO: This doesn't work. After several plug in/outs can not be enumerated. | ||
| 162 | if (USB_IsInitialized) { | ||
| 163 | USB_Disable(); // Disable all interrupts | ||
| 164 | USB_Controller_Enable(); | ||
| 165 | USB_INT_Enable(USB_INT_VBUSTI); | ||
| 166 | } | ||
| 167 | */ | ||
| 155 | } | 168 | } |
| 156 | 169 | ||
| 157 | void EVENT_USB_Device_Reset(void) | 170 | void EVENT_USB_Device_Reset(void) |
| @@ -574,7 +587,7 @@ int main(void) | |||
| 574 | print("Keyboard start.\n"); | 587 | print("Keyboard start.\n"); |
| 575 | while (1) { | 588 | while (1) { |
| 576 | while (USB_DeviceState == DEVICE_STATE_Suspended) { | 589 | while (USB_DeviceState == DEVICE_STATE_Suspended) { |
| 577 | suspend_power_down(); | 590 | suspend_power_down(WDTO_120MS); |
| 578 | if (USB_Device_RemoteWakeupEnabled && suspend_wakeup_condition()) { | 591 | if (USB_Device_RemoteWakeupEnabled && suspend_wakeup_condition()) { |
| 579 | USB_Device_SendRemoteWakeup(); | 592 | USB_Device_SendRemoteWakeup(); |
| 580 | } | 593 | } |
