qmk-firmware/tmk_core/common/chibios/suspend.c
skullydazed 5fd68266f5 Clueboard 60% support (#1746)
* initial clueboard_60 support

* LED lighting support

* fix the clueboard->clueboard_66 rename

* Add layout support to clueboard_60

* Fix the 60_iso layout so it's actually iso

* add a default keymap for AEK layout

* fix clueboard_17

* Fixup the ISO layouts

* Fix the `wait_ms()/wait_us()` definitions for chibios

* Fix up the wait_ms/wait_us hack. Reduce stack size.

* Add a missing #include "wait.h"

* commit files that should have already been comitted
2017-09-29 16:17:30 -07:00

67 lines
1.6 KiB
C

/* TODO */
#include "ch.h"
#include "hal.h"
#include "matrix.h"
#include "action.h"
#include "action_util.h"
#include "mousekey.h"
#include "host.h"
#include "backlight.h"
#include "suspend.h"
#include "wait.h"
void suspend_idle(uint8_t time) {
// TODO: this is not used anywhere - what units is 'time' in?
wait_ms(time);
}
void suspend_power_down(void) {
// TODO: figure out what to power down and how
// shouldn't power down TPM/FTM if we want a breathing LED
// also shouldn't power down USB
// on AVR, this enables the watchdog for 15ms (max), and goes to
// SLEEP_MODE_PWR_DOWN
wait_ms(17);
}
__attribute__ ((weak)) void matrix_power_up(void) {}
__attribute__ ((weak)) void matrix_power_down(void) {}
bool suspend_wakeup_condition(void)
{
matrix_power_up();
matrix_scan();
matrix_power_down();
for (uint8_t r = 0; r < MATRIX_ROWS; r++) {
if (matrix_get_row(r)) return true;
}
return false;
}
// run immediately after wakeup
void suspend_wakeup_init(void)
{
// clear keyboard state
// need to do it manually, because we're running from ISR
// and clear_keyboard() calls print
// so only clear the variables in memory
// the reports will be sent from main.c afterwards
// or if the PC asks for GET_REPORT
clear_mods();
clear_weak_mods();
clear_keys();
#ifdef MOUSEKEY_ENABLE
mousekey_clear();
#endif /* MOUSEKEY_ENABLE */
#ifdef EXTRAKEY_ENABLE
host_system_send(0);
host_consumer_send(0);
#endif /* EXTRAKEY_ENABLE */
#ifdef BACKLIGHT_ENABLE
backlight_init();
#endif /* BACKLIGHT_ENABLE */
}