diff options
| author | tmk <nobody@nowhere> | 2013-03-25 01:46:32 +0900 |
|---|---|---|
| committer | tmk <nobody@nowhere> | 2013-03-25 01:46:32 +0900 |
| commit | 2c0bb5e7e620b0472f110d2cbc5768bb6d97eec5 (patch) | |
| tree | b29845f872204470a011264ac5e5d7b6471cbfc5 /common/suspend.h | |
| parent | 1f19176867b1b1f760c0ec41cd78fbb6832d29ad (diff) | |
| download | qmk_firmware-2c0bb5e7e620b0472f110d2cbc5768bb6d97eec5.tar.gz qmk_firmware-2c0bb5e7e620b0472f110d2cbc5768bb6d97eec5.zip | |
Add common/suspend.c
Diffstat (limited to 'common/suspend.h')
| -rw-r--r-- | common/suspend.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/common/suspend.h b/common/suspend.h new file mode 100644 index 000000000..1c1e41ac3 --- /dev/null +++ b/common/suspend.h | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | #ifndef SUSPEND_H | ||
| 2 | #define SUSPEND_H | ||
| 3 | |||
| 4 | #include <stdint.h> | ||
| 5 | #include <stdbool.h> | ||
| 6 | #include <avr/sleep.h> | ||
| 7 | #include <avr/wdt.h> | ||
| 8 | #include <avr/interrupt.h> | ||
| 9 | |||
| 10 | |||
| 11 | #define wdt_intr_enable(value) \ | ||
| 12 | __asm__ __volatile__ ( \ | ||
| 13 | "in __tmp_reg__,__SREG__" "\n\t" \ | ||
| 14 | "cli" "\n\t" \ | ||
| 15 | "wdr" "\n\t" \ | ||
| 16 | "sts %0,%1" "\n\t" \ | ||
| 17 | "out __SREG__,__tmp_reg__" "\n\t" \ | ||
| 18 | "sts %0,%2" "\n\t" \ | ||
| 19 | : /* no outputs */ \ | ||
| 20 | : "M" (_SFR_MEM_ADDR(_WD_CONTROL_REG)), \ | ||
| 21 | "r" (_BV(_WD_CHANGE_BIT) | _BV(WDE)), \ | ||
| 22 | "r" ((uint8_t) ((value & 0x08 ? _WD_PS3_MASK : 0x00) | \ | ||
| 23 | _BV(WDIE) | (value & 0x07)) ) \ | ||
| 24 | : "r0" \ | ||
| 25 | ) | ||
| 26 | |||
| 27 | |||
| 28 | void suspend_power_down(void); | ||
| 29 | bool suspend_wakeup_condition(void); | ||
| 30 | void suspend_wakeup_init(void); | ||
| 31 | |||
| 32 | #endif | ||
