qmk_firmware

QMK firmware for my keyboards (Corne, Sweep Ferris) and trackball (Ploopy Adept)
Log | Files | Refs | Submodules | LICENSE

suspend.c (1262B)


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