Merge branch 'usb_usb_rwu'
This commit is contained in:
commit
4c126480c2
8 changed files with 7584 additions and 7398 deletions
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -53,4 +53,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#define LOCKING_SUPPORT_ENABLE
|
||||
#define LOCKING_RESYNC_ENABLE
|
||||
|
||||
// power saving during suspended without remote wakeup disabled
|
||||
#define UHS2_POWER_SAVING
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -226,20 +226,80 @@ void led_set(uint8_t usb_led)
|
|||
if (kbd4.isReady()) kbd4.SetLed(&usb_led);
|
||||
}
|
||||
|
||||
// We need to keep doing UHS2 USB::Task() to initialize keyboard
|
||||
// even during USB bus is suspended and remote wakeup is not enabled yet on LUFA side.
|
||||
// This situation can happen just after pluging converter into USB port.
|
||||
static bool init_done = false;
|
||||
void hook_late_init()
|
||||
{
|
||||
dprintf("[i]");
|
||||
init_done = true;
|
||||
}
|
||||
|
||||
void hook_usb_suspend_loop(void)
|
||||
{
|
||||
dprintf("[s]");
|
||||
#ifndef TMK_LUFA_DEBUG_UART
|
||||
// This corrupts debug print when suspend
|
||||
suspend_power_down();
|
||||
#endif
|
||||
if (USB_Device_RemoteWakeupEnabled) {
|
||||
if (suspend_wakeup_condition()) {
|
||||
if (usb_host.checkRemoteWakeup()) {
|
||||
USB_Device_SendRemoteWakeup();
|
||||
}
|
||||
} else {
|
||||
matrix_scan();
|
||||
}
|
||||
}
|
||||
|
||||
static uint8_t _led_stats = 0;
|
||||
void hook_usb_suspend_entry(void)
|
||||
{
|
||||
dprintf("[S]");
|
||||
if (!init_done) return;
|
||||
|
||||
matrix_clear();
|
||||
clear_keyboard();
|
||||
|
||||
usb_host.suspend();
|
||||
|
||||
#ifdef UHS2_POWER_SAVING
|
||||
// power down when remote wake is not enabled
|
||||
if (!USB_Device_RemoteWakeupEnabled) {
|
||||
dprintf("[p]");
|
||||
usb_host.powerDown();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void hook_usb_wakeup(void)
|
||||
{
|
||||
dprintf("[W]");
|
||||
if (!init_done) return;
|
||||
|
||||
suspend_wakeup_init();
|
||||
|
||||
#ifdef UHS2_POWER_SAVING
|
||||
// power down when remote wake is not enabled
|
||||
if (!USB_Device_RemoteWakeupEnabled) {
|
||||
dprintf("[P]");
|
||||
usb_host.powerUp();
|
||||
|
||||
// USB state cannot be retained through power down/up cycle
|
||||
// device should be enumerated and initialize from the beginning
|
||||
usb_host.ReleaseAllDevices();
|
||||
usb_host.setUsbTaskState(USB_STATE_DETACHED);
|
||||
}
|
||||
#endif
|
||||
|
||||
usb_host.resume();
|
||||
}
|
||||
|
||||
void hook_usb_startup_wait_loop(void)
|
||||
{
|
||||
usb_host.Task();
|
||||
|
||||
static uint8_t usb_state = 0;
|
||||
if (usb_state != usb_host.getUsbTaskState()) {
|
||||
usb_state = usb_host.getUsbTaskState();
|
||||
dprintf("u:%02X\n", usb_state);
|
||||
if (usb_state == USB_STATE_RUNNING) {
|
||||
dprintf("s:%s\n", usb_host.getVbusState()==FSHOST ? "f" : "l");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 85af76f6c9967d7457dbf5aa442a6a67e3e9ecf1
|
||||
Subproject commit df8e64d0500c012c47b637522d0c1b33c3683e91
|
||||
Loading…
Add table
Reference in a new issue