tmk / tmk_keyboard

Keyboard firmwares for Atmel AVR and Cortex-M
3.99k stars 1.71k forks source link

Problem on Suspend/Wakeup from keyboard #386

Closed tmk closed 5 years ago

tmk commented 8 years ago

It sometime works but sometime not. Iffy.

tmk commented 8 years ago

After test with HHKB controller with ATmega32u4 it doesn't seem to have problem.

tmk commented 8 years ago

PS/2 converter with ps2_interrupt.c(PS2_USE_INT) had problem on handling signal when suspended. In suspend state microcontroller falls into power down mode for 15ms until it checks keyboard for wakeup condition(keypress by user). During the 15ms sleep it can miss signals or get wrong scan codes from keyboard and internal states of converter are corrupted.

WORKAROUND: Instead of power down, PS/2 converter uses standby mode now with SUSPEND_MODE_STANDBY. In standby mode it can wake by pin change interrupt(INT1) and no longer miss signal from keyboard.

With ps2_busywait.c converter inhibits to send signal until it is ready to handle, so the problem above won't occur. ADB and M0110 also won't suffer from this probably because they send codes only when requested.(not confrimed)

With ps2_usart.c converter will have the problem. To solve it the converter will have to inhibit keyboard to send during microcontroller sleeps.

ANOTHER WORKAROUND: If power saving is not important you can keep microcontroller running even when suspended so that converter shouldn't miss signals. Keyboard connected to converter won't sleep basically and vintage keyboards keep drawing much current all the time. No power saving of microcontroller is actually useless there.

tmk commented 8 years ago

Problem during suspended with converters were solved. With this commits PS/2 converter should work. it uses SUSPEND_MODE_STANDBY instead of power down mode. https://github.com/tmk/tmk_keyboard/commit/9818d54d26e2900bf91b288bc6f268adc8e0b8fd https://github.com/tmk/tmk_keyboard/commit/1a7d1f9f4d6fdebb6e1d088ffcb37745ddf119d2

Also Alps64 with ATmega32u2 works now. https://geekhack.org/index.php?topic=69740.msg2277498#msg2277498

Now there is no perceived problem on suspend and resume, but keep this open for future problem report.

Elizafox commented 5 years ago

Issues with suspend/wakeup occur with terminal_usb. Issues occur with my Unicomp 3270 terminal keyboard.

tmk commented 5 years ago

Probably you should make new issue and describe your problem.

This issue is mainly related to key responsiveness when you wake your computer with key press.