Keyboard firmwares for Atmel AVR and Cortex-M
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

suspend_avr.h 640B

123456789101112131415161718192021222324252627
  1. #ifndef SUSPEND_AVR_H
  2. #define SUSPEND_AVR_H
  3. #include <stdint.h>
  4. #include <stdbool.h>
  5. #include <avr/sleep.h>
  6. #include <avr/wdt.h>
  7. #include <avr/interrupt.h>
  8. #define wdt_intr_enable(value) \
  9. __asm__ __volatile__ ( \
  10. "in __tmp_reg__,__SREG__" "\n\t" \
  11. "cli" "\n\t" \
  12. "wdr" "\n\t" \
  13. "sts %0,%1" "\n\t" \
  14. "out __SREG__,__tmp_reg__" "\n\t" \
  15. "sts %0,%2" "\n\t" \
  16. : /* no outputs */ \
  17. : "M" (_SFR_MEM_ADDR(_WD_CONTROL_REG)), \
  18. "r" (_BV(_WD_CHANGE_BIT) | _BV(WDE)), \
  19. "r" ((uint8_t) ((value & 0x08 ? _WD_PS3_MASK : 0x00) | \
  20. _BV(WDIE) | (value & 0x07)) ) \
  21. : "r0" \
  22. )
  23. #endif