aboutsummaryrefslogtreecommitdiff
path: root/platforms/arm_atsam/suspend.c
diff options
context:
space:
mode:
Diffstat (limited to 'platforms/arm_atsam/suspend.c')
-rw-r--r--platforms/arm_atsam/suspend.c77
1 files changed, 77 insertions, 0 deletions
diff --git a/platforms/arm_atsam/suspend.c b/platforms/arm_atsam/suspend.c
new file mode 100644
index 000000000..e51426128
--- /dev/null
+++ b/platforms/arm_atsam/suspend.c
@@ -0,0 +1,77 @@
1#include "matrix.h"
2#include "i2c_master.h"
3#include "md_rgb_matrix.h"
4#include "suspend.h"
5
6/** \brief Suspend idle
7 *
8 * FIXME: needs doc
9 */
10void suspend_idle(uint8_t time) { /* Note: Not used anywhere currently */
11}
12
13/** \brief Run user level Power down
14 *
15 * FIXME: needs doc
16 */
17__attribute__((weak)) void suspend_power_down_user(void) {}
18
19/** \brief Run keyboard level Power down
20 *
21 * FIXME: needs doc
22 */
23__attribute__((weak)) void suspend_power_down_kb(void) { suspend_power_down_user(); }
24
25/** \brief Suspend power down
26 *
27 * FIXME: needs doc
28 */
29void suspend_power_down(void) {
30#ifdef RGB_MATRIX_ENABLE
31 I2C3733_Control_Set(0); // Disable LED driver
32#endif
33
34 suspend_power_down_kb();
35}
36
37__attribute__((weak)) void matrix_power_up(void) {}
38__attribute__((weak)) void matrix_power_down(void) {}
39bool suspend_wakeup_condition(void) {
40 matrix_power_up();
41 matrix_scan();
42 matrix_power_down();
43 for (uint8_t r = 0; r < MATRIX_ROWS; r++) {
44 if (matrix_get_row(r)) return true;
45 }
46 return false;
47}
48
49/** \brief run user level code immediately after wakeup
50 *
51 * FIXME: needs doc
52 */
53__attribute__((weak)) void suspend_wakeup_init_user(void) {}
54
55/** \brief run keyboard level code immediately after wakeup
56 *
57 * FIXME: needs doc
58 */
59__attribute__((weak)) void suspend_wakeup_init_kb(void) { suspend_wakeup_init_user(); }
60
61/** \brief run immediately after wakeup
62 *
63 * FIXME: needs doc
64 */
65void suspend_wakeup_init(void) {
66#ifdef RGB_MATRIX_ENABLE
67# ifdef USE_MASSDROP_CONFIGURATOR
68 if (led_enabled) {
69 I2C3733_Control_Set(1);
70 }
71# else
72 I2C3733_Control_Set(1);
73# endif
74#endif
75
76 suspend_wakeup_init_kb();
77}