suspend.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* TODO */
  2. #include <ch.h>
  3. #include <hal.h>
  4. #include "matrix.h"
  5. #include "action.h"
  6. #include "action_util.h"
  7. #include "mousekey.h"
  8. #include "programmable_button.h"
  9. #include "host.h"
  10. #include "suspend.h"
  11. #include "led.h"
  12. #include "wait.h"
  13. /** \brief suspend power down
  14. *
  15. * FIXME: needs doc
  16. */
  17. void suspend_power_down(void) {
  18. suspend_power_down_quantum();
  19. // on AVR, this enables the watchdog for 15ms (max), and goes to
  20. // SLEEP_MODE_PWR_DOWN
  21. wait_ms(17);
  22. }
  23. /** \brief suspend wakeup condition
  24. *
  25. * run immediately after wakeup
  26. * FIXME: needs doc
  27. */
  28. void suspend_wakeup_init(void) {
  29. // clear keyboard state
  30. // need to do it manually, because we're running from ISR
  31. // and clear_keyboard() calls print
  32. // so only clear the variables in memory
  33. // the reports will be sent from main.c afterwards
  34. // or if the PC asks for GET_REPORT
  35. clear_mods();
  36. clear_weak_mods();
  37. clear_keys();
  38. #ifdef MOUSEKEY_ENABLE
  39. mousekey_clear();
  40. #endif /* MOUSEKEY_ENABLE */
  41. #ifdef PROGRAMMABLE_BUTTON_ENABLE
  42. programmable_button_clear();
  43. #endif /* PROGRAMMABLE_BUTTON_ENABLE */
  44. #ifdef EXTRAKEY_ENABLE
  45. host_system_send(0);
  46. host_consumer_send(0);
  47. #endif /* EXTRAKEY_ENABLE */
  48. suspend_wakeup_init_quantum();
  49. }