ah- / anne-key

Firmware for Anne Pro Keyboard written in Rust
Apache License 2.0
567 stars 32 forks source link

Power management: Use wakeup instead of polling #25

Open ah- opened 6 years ago

ah- commented 6 years ago

Right now there is a global timer that continuously scans which keys are pressed and sends out HID reports based on that.

The keys are all wired up so key presses can fire external interrupts that wake up the STM32. The bootloader even leaves it in a half-enabled state, which is why we have all the EXTI handlers in https://github.com/ah-/anne-key/blob/master/src/main.rs#L177

To enable wakeups we probably need to configure the EXTI registers correctly and then set up the keyboard matrix gpios correctly so that pressing a key pulls an EXTI line up/down.

Once this works it'll be really helpful for power management so we can sleep when noone is using the keyboard. We might even want to consider only running off those interrupts and getting rid of the timer altogether?