]> git.donarmstrong.com Git - qmk_firmware.git/blob - tmk_core/common/arm_atsam/suspend.c
9c2c47d5610c8711951a20aa9273a5432209994a
[qmk_firmware.git] / tmk_core / common / arm_atsam / suspend.c
1 #include "matrix.h"
2 #include "i2c_master.h"
3 #include "led_matrix.h"
4 #include "suspend.h"
5
6 /** \brief Suspend idle
7  *
8  * FIXME: needs doc
9  */
10 void suspend_idle(uint8_t time) {
11     /* Note: Not used anywhere currently */
12 }
13
14 /** \brief Run user level Power down
15  *
16  * FIXME: needs doc
17  */
18 __attribute__ ((weak))
19 void suspend_power_down_user (void) {
20
21 }
22
23 /** \brief Run keyboard level Power down
24  *
25  * FIXME: needs doc
26  */
27 __attribute__ ((weak))
28 void suspend_power_down_kb(void) {
29     suspend_power_down_user();
30 }
31
32 /** \brief Suspend power down
33  *
34  * FIXME: needs doc
35  */
36 void suspend_power_down(void)
37 {
38 #ifdef RGB_MATRIX_ENABLE
39     I2C3733_Control_Set(0); //Disable LED driver
40 #endif
41
42     suspend_power_down_kb();
43 }
44
45 __attribute__ ((weak)) void matrix_power_up(void) {}
46 __attribute__ ((weak)) void matrix_power_down(void) {}
47 bool suspend_wakeup_condition(void) {
48     matrix_power_up();
49     matrix_scan();
50     matrix_power_down();
51     for (uint8_t r = 0; r < MATRIX_ROWS; r++) {
52         if (matrix_get_row(r)) return true;
53     }
54     return false;
55 }
56
57 /** \brief run user level code immediately after wakeup
58  *
59  * FIXME: needs doc
60  */
61 __attribute__ ((weak))
62 void suspend_wakeup_init_user(void) {
63
64 }
65
66 /** \brief run keyboard level code immediately after wakeup
67  *
68  * FIXME: needs doc
69  */
70 __attribute__ ((weak))
71 void suspend_wakeup_init_kb(void) {
72     suspend_wakeup_init_user();
73 }
74
75 /** \brief run immediately after wakeup
76  *
77  * FIXME: needs doc
78  */
79 void suspend_wakeup_init(void) {
80 #ifdef RGB_MATRIX_ENABLE
81     I2C3733_Control_Set(1);
82 #endif
83
84     suspend_wakeup_init_kb();
85 }
86