suspend_avr.h 2.9 KB

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__("in __tmp_reg__,__SREG__" \
  10. "\n\t" \
  11. "cli" \
  12. "\n\t" \
  13. "wdr" \
  14. "\n\t" \
  15. "sts %0,%1" \
  16. "\n\t" \
  17. "out __SREG__,__tmp_reg__" \
  18. "\n\t" \
  19. "sts %0,%2" \
  20. "\n\t" \
  21. : /* no outputs */ \
  22. : "M"(_SFR_MEM_ADDR(_WD_CONTROL_REG)), "r"(_BV(_WD_CHANGE_BIT) | _BV(WDE)), "r"((uint8_t)((value & 0x08 ? _WD_PS3_MASK : 0x00) | _BV(WDIE) | (value & 0x07))) \
  23. : "r0")
  24. #endif