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.

30 lines
670 B

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