33 #define _AVR_POWER_H_ 1
642 #if defined(__AVR_ATxmega16A4__) \
643 || defined(__AVR_ATxmega16A4U__) \
644 || defined(__AVR_ATxmega32A4U__) \
645 || defined(__AVR_ATxmega32A4__) \
646 || defined(__AVR_ATxmega64A1__) \
647 || defined(__AVR_ATxmega64A1U__) \
648 || defined(__AVR_ATxmega64A3__) \
649 || defined(__AVR_ATxmega64A3U__) \
650 || defined(__AVR_ATxmega64A4U__) \
651 || defined(__AVR_ATxmega128A1__) \
652 || defined(__AVR_ATxmega128A1U__) \
653 || defined(__AVR_ATxmega128A3__) \
654 || defined(__AVR_ATxmega128A3U__) \
655 || defined(__AVR_ATxmega128A4U__) \
656 || defined(__AVR_ATxmega192A3__) \
657 || defined(__AVR_ATxmega192A3U__) \
658 || defined(__AVR_ATxmega256A3__) \
659 || defined(__AVR_ATxmega256A3U__) \
660 || defined(__AVR_ATxmega256A3B__) \
661 || defined(__AVR_ATxmega256A3BU__) \
662 || defined(__AVR_ATxmega384C3__)
665 #define power_aes_enable() (PR_PRGEN &= (uint8_t)~(PR_AES_bm))
666 #define power_aes_disable() (PR_PRGEN |= (uint8_t)PR_AES_bm)
668 #define power_ebi_enable() (PR_PRGEN &= (uint8_t)~(PR_EBI_bm))
669 #define power_ebi_disable() (PR_PRGEN |= (uint8_t)PR_EBI_bm)
671 #define power_dma_enable() (PR_PRGEN &= (uint8_t)~(PR_DMA_bm))
672 #define power_dma_disable() (PR_PRGEN |= (uint8_t)PR_DMA_bm)
674 #define power_daca_enable() (PR_PRPA &= (uint8_t)~(PR_DAC_bm))
675 #define power_daca_disable() (PR_PRPA |= (uint8_t)PR_DAC_bm)
676 #define power_dacb_enable() (PR_PRPB &= (uint8_t)~(PR_DAC_bm))
677 #define power_dacb_disable() (PR_PRPB |= (uint8_t)PR_DAC_bm)
679 #define power_usartc1_enable() (PR_PRPC &= (uint8_t)~(PR_USART1_bm))
680 #define power_usartc1_disable() (PR_PRPC |= (uint8_t)PR_USART1_bm)
681 #define power_usartd1_enable() (PR_PRPD &= (uint8_t)~(PR_USART1_bm))
682 #define power_usartd1_disable() (PR_PRPD |= (uint8_t)PR_USART1_bm)
683 #define power_usarte1_enable() (PR_PRPE &= (uint8_t)~(PR_USART1_bm))
684 #define power_usarte1_disable() (PR_PRPE |= (uint8_t)PR_USART1_bm)
685 #define power_usartf1_enable() (PR_PRPF &= (uint8_t)~(PR_USART1_bm))
686 #define power_usartf1_disable() (PR_PRPF |= (uint8_t)PR_USART1_bm)
688 #if defined(__AVR_ATxmega384C3__) \
689 || defined(__AVR_ATxmega256A3BU__) \
690 || defined(__AVR_ATxmega16A4U__) \
691 || defined(__AVR_ATxmega32A4U__) \
692 || defined(__AVR_ATxmega64A3U__) \
693 || defined(__AVR_ATxmega64A4U__) \
694 || defined(__AVR_ATxmega128A3U__) \
695 || defined(__AVR_ATxmega128A4U__) \
696 || defined(__AVR_ATxmega192A3U__) \
697 || defined(__AVR_ATxmega256A3U__)
699 #define power_usb_enable() (PR_PRGEN &= (uint8_t)~(PR_USB_bm))
700 #define power_usb_disable() (PR_PRGEN &= (uint8_t)(PR_USB_bm))
702 #define power_all_enable() \
704 PR_PRGEN &= (uint8_t)~(PR_AES_bm|PR_EBI_bm|PR_RTC_bm|PR_EVSYS_bm|PR_DMA_bm|PR_USB_bm); \
705 PR_PRPA &= (uint8_t)~(PR_DAC_bm|PR_ADC_bm|PR_AC_bm); \
706 PR_PRPB &= (uint8_t)~(PR_DAC_bm|PR_ADC_bm|PR_AC_bm); \
707 PR_PRPC &= (uint8_t)~(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
708 PR_PRPD &= (uint8_t)~(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
709 PR_PRPE &= (uint8_t)~(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
710 PR_PRPF &= (uint8_t)~(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
713 #define power_all_disable() \
715 PR_PRGEN |= (uint8_t)(PR_AES_bm|PR_EBI_bm|PR_RTC_bm|PR_EVSYS_bm|PR_DMA_bm|PR_USB_bm); \
716 PR_PRPA |= (uint8_t)(PR_DAC_bm|PR_ADC_bm|PR_AC_bm); \
717 PR_PRPB |= (uint8_t)(PR_DAC_bm|PR_ADC_bm|PR_AC_bm); \
718 PR_PRPC |= (uint8_t)(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
719 PR_PRPD |= (uint8_t)(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
720 PR_PRPE |= (uint8_t)(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
721 PR_PRPF |= (uint8_t)(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
726 #define power_all_enable() \
728 PR_PRGEN &= (uint8_t)~(PR_AES_bm|PR_EBI_bm|PR_RTC_bm|PR_EVSYS_bm|PR_DMA_bm); \
729 PR_PRPA &= (uint8_t)~(PR_DAC_bm|PR_ADC_bm|PR_AC_bm); \
730 PR_PRPB &= (uint8_t)~(PR_DAC_bm|PR_ADC_bm|PR_AC_bm); \
731 PR_PRPC &= (uint8_t)~(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
732 PR_PRPD &= (uint8_t)~(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
733 PR_PRPE &= (uint8_t)~(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
734 PR_PRPF &= (uint8_t)~(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
738 #define power_all_disable() \
740 PR_PRGEN|= (uint8_t)(PR_AES_bm|PR_EBI_bm|PR_RTC_bm|PR_EVSYS_bm|PR_DMA_bm); \
741 PR_PRPA |= (uint8_t)(PR_DAC_bm|PR_ADC_bm|PR_AC_bm); \
742 PR_PRPB |= (uint8_t)(PR_DAC_bm|PR_ADC_bm|PR_AC_bm); \
743 PR_PRPC |= (uint8_t)(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
744 PR_PRPD |= (uint8_t)(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
745 PR_PRPE |= (uint8_t)(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
746 PR_PRPF |= (uint8_t)(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
752 #if defined(__AVR_ATxmega64D3__) \
753 || defined(__AVR_ATxmega128D3__) \
754 || defined(__AVR_ATxmega192D3__) \
755 || defined(__AVR_ATxmega256D3__)
757 #define power_rtc_enable() (PR_PRGEN &= (uint8_t)~(PR_RTC_bm))
758 #define power_rtc_disable() (PR_PRGEN |= (uint8_t)PR_RTC_bm)
760 #define power_evsys_enable() (PR_PRGEN &= (uint8_t)~(PR_EVSYS_bm))
761 #define power_evsys_disable() (PR_PRGEN |= (uint8_t)PR_EVSYS_bm)
763 #define power_adca_enable() (PR_PRPA &= (uint8_t)~(PR_ADC_bm))
764 #define power_adca_disable() (PR_PRPA |= (uint8_t)PR_ADC_bm)
766 #define power_aca_enable() (PR_PRPA &= (uint8_t)~(PR_AC_bm))
767 #define power_aca_disable() (PR_PRPA |= (uint8_t)PR_AC_bm)
769 #define power_twic_enable() (PR_PRPC &= (uint8_t)~(PR_TWI_bm))
770 #define power_twic_disable() (PR_PRPC |= (uint8_t)PR_TWI_bm)
771 #define power_twie_enable() (PR_PRPE &= (uint8_t)~(PR_TWI_bm))
772 #define power_twie_disable() (PR_PRPE |= (uint8_t)PR_TWI_bm)
774 #define power_usartc0_enable() (PR_PRPC &= (uint8_t)~(PR_USART0_bm))
775 #define power_usartc0_disable() (PR_PRPC |= (uint8_t)PR_USART0_bm)
776 #define power_usartd0_enable() (PR_PRPD &= (uint8_t)~(PR_USART0_bm))
777 #define power_usartd0_disable() (PR_PRPD |= (uint8_t)PR_USART0_bm)
778 #define power_usarte0_enable() (PR_PRPE &= (uint8_t)~(PR_USART0_bm))
779 #define power_usarte0_disable() (PR_PRPE |= (uint8_t)PR_USART0_bm)
780 #define power_usartf0_enable() (PR_PRPF &= (uint8_t)~(PR_USART0_bm))
781 #define power_usartf0_disable() (PR_PRPF |= (uint8_t)PR_USART0_bm)
783 #define power_spic_enable() (PR_PRPC &= (uint8_t)~(PR_SPI_bm))
784 #define power_spic_disable() (PR_PRPC |= (uint8_t)PR_SPI_bm)
785 #define power_spid_enable() (PR_PRPD &= (uint8_t)~(PR_SPI_bm))
786 #define power_spid_disable() (PR_PRPD |= (uint8_t)PR_SPI_bm)
788 #define power_hiresc_enable() (PR_PRPC &= (uint8_t)~(PR_HIRES_bm))
789 #define power_hiresc_disable() (PR_PRPC |= (uint8_t)PR_HIRES_bm)
791 #define power_tc1c_enable() (PR_PRPC &= (uint8_t)~(PR_TC1_bm))
792 #define power_tc1c_disable() (PR_PRPC |= (uint8_t)PR_TC1_bm)
794 #define power_tc0c_enable() (PR_PRPC &= (uint8_t)~(PR_TC0_bm))
795 #define power_tc0c_disable() (PR_PRPC |= (uint8_t)PR_TC0_bm)
796 #define power_tc0d_enable() (PR_PRPD &= (uint8_t)~(PR_TC0_bm))
797 #define power_tc0d_disable() (PR_PRPD |= (uint8_t)PR_TC0_bm)
798 #define power_tc0e_enable() (PR_PRPE &= (uint8_t)~(PR_TC0_bm))
799 #define power_tc0e_disable() (PR_PRPE |= (uint8_t)PR_TC0_bm)
800 #define power_tc0f_enable() (PR_PRPF &= (uint8_t)~(PR_TC0_bm))
801 #define power_tc0f_disable() (PR_PRPF |= (uint8_t)PR_TC0_bm)
803 #define power_all_enable() \
805 PR_PRGEN &= (uint8_t)~(PR_RTC_bm|PR_EVSYS_bm); \
806 PR_PRPA &= (uint8_t)~(PR_ADC_bm|PR_AC_bm); \
807 PR_PRPC &= (uint8_t)~(PR_TWI_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
808 PR_PRPD &= (uint8_t)~(PR_USART0_bm|PR_SPI_bm|PR_TC0_bm); \
809 PR_PRPE &= (uint8_t)~(PR_TWI_bm|PR_USART0_bm|PR_TC0_bm); \
810 PR_PRPF &= (uint8_t)~(PR_USART0_bm|PR_TC0_bm); \
814 #define power_all_disable() \
816 PR_PRGEN|= (uint8_t)(PR_RTC_bm|PR_EVSYS_bm); \
817 PR_PRPA |= (uint8_t)(PR_ADC_bm|PR_AC_bm); \
818 PR_PRPC |= (uint8_t)(PR_TWI_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
819 PR_PRPD |= (uint8_t)(PR_USART0_bm|PR_SPI_bm|PR_TC0_bm); \
820 PR_PRPE |= (uint8_t)(PR_TWI_bm|PR_USART0_bm|PR_TC0_bm); \
821 PR_PRPF |= (uint8_t)(PR_USART0_bm|PR_TC0_bm); \
825 #if defined(__AVR_ATxmega16C4__) \
826 || defined(__AVR_ATxmega32C4__) \
827 || defined(__AVR_ATxmega64C3__) \
828 || defined(__AVR_ATxmega128C3__) \
829 || defined(__AVR_ATxmega192C3__) \
830 || defined(__AVR_ATxmega256C3__)
832 #define power_usb_enable() (PR_PRGEN &= (uint8_t)~(PR_USB_bm))
833 #define power_usb_disable() (PR_PRGEN &= (uint8_t)(PR_USB_bm))
835 #define power_aes_enable() (PR_PRGEN &= (uint8_t)~(PR_AES_bm))
836 #define power_aes_disable() (PR_PRGEN |= (uint8_t)PR_AES_bm)
838 #define power_rtc_enable() (PR_PRGEN &= (uint8_t)~(PR_RTC_bm))
839 #define power_rtc_disable() (PR_PRGEN |= (uint8_t)PR_RTC_bm)
841 #define power_evsys_enable() (PR_PRGEN &= (uint8_t)~(PR_EVSYS_bm))
842 #define power_evsys_disable() (PR_PRGEN |= (uint8_t)PR_EVSYS_bm)
844 #define power_dma_enable() (PR_PRGEN &= (uint8_t)~(PR_DMA_bm))
845 #define power_dma_disable() (PR_PRGEN |= (uint8_t)PR_DMA_bm)
847 #define power_adca_enable() (PR_PRPA &= (uint8_t)~(PR_ADC_bm))
848 #define power_adca_disable() (PR_PRPA |= (uint8_t)PR_ADC_bm)
850 #define power_aca_enable() (PR_PRPA &= (uint8_t)~(PR_AC_bm))
851 #define power_aca_disable() (PR_PRPA |= (uint8_t)PR_AC_bm)
853 #define power_twic_enable() (PR_PRPC &= (uint8_t)~(PR_TWI_bm))
854 #define power_twic_disable() (PR_PRPC |= (uint8_t)PR_TWI_bm)
855 #define power_twie_enable() (PR_PRPE &= (uint8_t)~(PR_TWI_bm))
856 #define power_twie_disable() (PR_PRPE |= (uint8_t)PR_TWI_bm)
858 #define power_usartc1_enable() (PR_PRPC &= (uint8_t)~(PR_USART1_bm))
859 #define power_usartc1_disable() (PR_PRPC |= (uint8_t)PR_USART1_bm)
861 #define power_usartc0_enable() (PR_PRPC &= (uint8_t)~(PR_USART0_bm))
862 #define power_usartc0_disable() (PR_PRPC |= (uint8_t)PR_USART0_bm)
863 #define power_usartd0_enable() (PR_PRPD &= (uint8_t)~(PR_USART0_bm))
864 #define power_usartd0_disable() (PR_PRPD |= (uint8_t)PR_USART0_bm)
865 #define power_usarte0_enable() (PR_PRPE &= (uint8_t)~(PR_USART0_bm))
866 #define power_usarte0_disable() (PR_PRPE |= (uint8_t)PR_USART0_bm)
867 #define power_usartf0_enable() (PR_PRPF &= (uint8_t)~(PR_USART0_bm))
868 #define power_usartf0_disable() (PR_PRPF |= (uint8_t)PR_USART0_bm)
870 #define power_spic_enable() (PR_PRPC &= (uint8_t)~(PR_SPI_bm))
871 #define power_spic_disable() (PR_PRPC |= (uint8_t)PR_SPI_bm)
872 #define power_spid_enable() (PR_PRPD &= (uint8_t)~(PR_SPI_bm))
873 #define power_spid_disable() (PR_PRPD |= (uint8_t)PR_SPI_bm)
875 #define power_hiresc_enable() (PR_PRPC &= (uint8_t)~(PR_HIRES_bm))
876 #define power_hiresc_disable() (PR_PRPC |= (uint8_t)PR_HIRES_bm)
878 #define power_tc1c_enable() (PR_PRPC &= (uint8_t)~(PR_TC1_bm))
879 #define power_tc1c_disable() (PR_PRPC |= (uint8_t)PR_TC1_bm)
881 #define power_tc0c_enable() (PR_PRPC &= (uint8_t)~(PR_TC0_bm))
882 #define power_tc0c_disable() (PR_PRPC |= (uint8_t)PR_TC0_bm)
883 #define power_tc0d_enable() (PR_PRPD &= (uint8_t)~(PR_TC0_bm))
884 #define power_tc0d_disable() (PR_PRPD |= (uint8_t)PR_TC0_bm)
885 #define power_tc0e_enable() (PR_PRPE &= (uint8_t)~(PR_TC0_bm))
886 #define power_tc0e_disable() (PR_PRPE |= (uint8_t)PR_TC0_bm)
887 #define power_tc0f_enable() (PR_PRPF &= (uint8_t)~(PR_TC0_bm))
888 #define power_tc0f_disable() (PR_PRPF |= (uint8_t)PR_TC0_bm)
890 #define power_all_enable() \
892 PR_PRGEN &= (uint8_t)~(PR_USB_bm|PR_AES_bm|PR_DMA_bm|PR_RTC_bm|PR_EVSYS_bm); \
893 PR_PRPA &= (uint8_t)~(PR_ADC_bm|PR_AC_bm); \
894 PR_PRPC &= (uint8_t)~(PR_TWI_bm|PR_USART0_bm|PR_USART1_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
895 PR_PRPD &= (uint8_t)~(PR_USART0_bm|PR_SPI_bm|PR_TC0_bm); \
896 PR_PRPE &= (uint8_t)~(PR_TWI_bm|PR_USART0_bm|PR_TC0_bm); \
897 PR_PRPF &= (uint8_t)~(PR_USART0_bm|PR_TC0_bm); \
900 #define power_all_disable() \
902 PR_PRGEN |= (uint8_t)(PR_USB_bm|PR_AES_bm|PR_DMA_bm|PR_RTC_bm|PR_EVSYS_bm); \
903 PR_PRPA |= (uint8_t)(PR_ADC_bm|PR_AC_bm); \
904 PR_PRPC |= (uint8_t)(PR_TWI_bm|PR_USART0_bm|PR_USART1_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
905 PR_PRPD |= (uint8_t)(PR_USART0_bm|PR_SPI_bm|PR_TC0_bm); \
906 PR_PRPE |= (uint8_t)(PR_TWI_bm|PR_USART0_bm|PR_TC0_bm); \
907 PR_PRPF |= (uint8_t)(PR_USART0_bm|PR_TC0_bm); \
912 #if defined(__AVR_ATxmega16A4__) \
913 || defined(__AVR_ATxmega16A4U__) \
914 || defined(__AVR_ATxmega16D4__) \
915 || defined(__AVR_ATxmega32A4__) \
916 || defined(__AVR_ATxmega32A4U__) \
917 || defined(__AVR_ATxmega32D4__) \
918 || defined(__AVR_ATxmega64A1__) \
919 || defined(__AVR_ATxmega64A1U__) \
920 || defined(__AVR_ATxmega64A3__) \
921 || defined(__AVR_ATxmega64A3U__) \
922 || defined(__AVR_ATxmega64A4U__) \
923 || defined(__AVR_ATxmega128A1__) \
924 || defined(__AVR_ATxmega128A1U__) \
925 || defined(__AVR_ATxmega128A3__) \
926 || defined(__AVR_ATxmega128A3U__) \
927 || defined(__AVR_ATxmega128A4U__) \
928 || defined(__AVR_ATxmega192A3__) \
929 || defined(__AVR_ATxmega192A3U__) \
930 || defined(__AVR_ATxmega256A3__) \
931 || defined(__AVR_ATxmega256A3U__) \
932 || defined(__AVR_ATxmega256A3B__) \
933 || defined(__AVR_ATxmega256A3BU__) \
934 || defined(__AVR_ATxmega384C3__)
937 #define power_rtc_enable() (PR_PRGEN &= (uint8_t)~(PR_RTC_bm))
938 #define power_rtc_disable() (PR_PRGEN |= (uint8_t)PR_RTC_bm)
940 #define power_evsys_enable() (PR_PRGEN &= (uint8_t)~(PR_EVSYS_bm))
941 #define power_evsys_disable() (PR_PRGEN |= (uint8_t)PR_EVSYS_bm)
943 #define power_adca_enable() (PR_PRPA &= (uint8_t)~(PR_ADC_bm))
944 #define power_adca_disable() (PR_PRPA |= (uint8_t)PR_ADC_bm)
945 #define power_adcb_enable() (PR_PRPB &= (uint8_t)~(PR_ADC_bm))
946 #define power_adcb_disable() (PR_PRPB |= (uint8_t)PR_ADC_bm)
948 #define power_aca_enable() (PR_PRPA &= (uint8_t)~(PR_AC_bm))
949 #define power_aca_disable() (PR_PRPA |= (uint8_t)PR_AC_bm)
950 #define power_acb_enable() (PR_PRPB &= (uint8_t)~(PR_AC_bm))
951 #define power_acb_disable() (PR_PRPB |= (uint8_t)PR_AC_bm)
953 #define power_twic_enable() (PR_PRPC &= (uint8_t)~(PR_TWI_bm))
954 #define power_twic_disable() (PR_PRPC |= (uint8_t)PR_TWI_bm)
955 #define power_twid_enable() (PR_PRPD &= (uint8_t)~(PR_TWI_bm))
956 #define power_twid_disable() (PR_PRPD |= (uint8_t)PR_TWI_bm)
957 #define power_twie_enable() (PR_PRPE &= (uint8_t)~(PR_TWI_bm))
958 #define power_twie_disable() (PR_PRPE |= (uint8_t)PR_TWI_bm)
959 #define power_twif_enable() (PR_PRPF &= (uint8_t)~(PR_TWI_bm))
960 #define power_twif_disable() (PR_PRPF |= (uint8_t)PR_TWI_bm)
962 #define power_usartc0_enable() (PR_PRPC &= (uint8_t)~(PR_USART0_bm))
963 #define power_usartc0_disable() (PR_PRPC |= (uint8_t)PR_USART0_bm)
964 #define power_usartd0_enable() (PR_PRPD &= (uint8_t)~(PR_USART0_bm))
965 #define power_usartd0_disable() (PR_PRPD |= (uint8_t)PR_USART0_bm)
966 #define power_usarte0_enable() (PR_PRPE &= (uint8_t)~(PR_USART0_bm))
967 #define power_usarte0_disable() (PR_PRPE |= (uint8_t)PR_USART0_bm)
968 #define power_usartf0_enable() (PR_PRPF &= (uint8_t)~(PR_USART0_bm))
969 #define power_usartf0_disable() (PR_PRPF |= (uint8_t)PR_USART0_bm)
971 #define power_spic_enable() (PR_PRPC &= (uint8_t)~(PR_SPI_bm))
972 #define power_spic_disable() (PR_PRPC |= (uint8_t)PR_SPI_bm)
973 #define power_spid_enable() (PR_PRPD &= (uint8_t)~(PR_SPI_bm))
974 #define power_spid_disable() (PR_PRPD |= (uint8_t)PR_SPI_bm)
975 #define power_spie_enable() (PR_PRPE &= (uint8_t)~(PR_SPI_bm))
976 #define power_spie_disable() (PR_PRPE |= (uint8_t)PR_SPI_bm)
977 #define power_spif_enable() (PR_PRPF &= (uint8_t)~(PR_SPI_bm))
978 #define power_spif_disable() (PR_PRPF |= (uint8_t)PR_SPI_bm)
980 #define power_hiresc_enable() (PR_PRPC &= (uint8_t)~(PR_HIRES_bm))
981 #define power_hiresc_disable() (PR_PRPC |= (uint8_t)PR_HIRES_bm)
982 #define power_hiresd_enable() (PR_PRPD &= (uint8_t)~(PR_HIRES_bm))
983 #define power_hiresd_disable() (PR_PRPD |= (uint8_t)PR_HIRES_bm)
984 #define power_hirese_enable() (PR_PRPE &= (uint8_t)~(PR_HIRES_bm))
985 #define power_hirese_disable() (PR_PRPE |= (uint8_t)PR_HIRES_bm)
986 #define power_hiresf_enable() (PR_PRPF &= (uint8_t)~(PR_HIRES_bm))
987 #define power_hiresf_disable() (PR_PRPF |= (uint8_t)PR_HIRES_bm)
989 #define power_tc1c_enable() (PR_PRPC &= (uint8_t)~(PR_TC1_bm))
990 #define power_tc1c_disable() (PR_PRPC |= (uint8_t)PR_TC1_bm)
991 #define power_tc1d_enable() (PR_PRPD &= (uint8_t)~(PR_TC1_bm))
992 #define power_tc1d_disable() (PR_PRPD |= (uint8_t)PR_TC1_bm)
993 #define power_tc1e_enable() (PR_PRPE &= (uint8_t)~(PR_TC1_bm))
994 #define power_tc1e_disable() (PR_PRPE |= (uint8_t)PR_TC1_bm)
995 #define power_tc1f_enable() (PR_PRPF &= (uint8_t)~(PR_TC1_bm))
996 #define power_tc1f_disable() (PR_PRPF |= (uint8_t)PR_TC1_bm)
998 #define power_tc0c_enable() (PR_PRPC &= (uint8_t)~(PR_TC0_bm))
999 #define power_tc0c_disable() (PR_PRPC |= (uint8_t)PR_TC0_bm)
1000 #define power_tc0d_enable() (PR_PRPD &= (uint8_t)~(PR_TC0_bm))
1001 #define power_tc0d_disable() (PR_PRPD |= (uint8_t)PR_TC0_bm)
1002 #define power_tc0e_enable() (PR_PRPE &= (uint8_t)~(PR_TC0_bm))
1003 #define power_tc0e_disable() (PR_PRPE |= (uint8_t)PR_TC0_bm)
1004 #define power_tc0f_enable() (PR_PRPF &= (uint8_t)~(PR_TC0_bm))
1005 #define power_tc0f_disable() (PR_PRPF |= (uint8_t)PR_TC0_bm)
1009 #if defined(__AVR_ATxmega64D4__) \
1010 || defined(__AVR_ATxmega128D4__)
1012 #define power_rtc_enable() (PR_PRGEN &= (uint8_t)~(PR_RTC_bm))
1013 #define power_rtc_disable() (PR_PRGEN |= (uint8_t)PR_RTC_bm)
1015 #define power_evsys_enable() (PR_PRGEN &= (uint8_t)~(PR_EVSYS_bm))
1016 #define power_evsys_disable() (PR_PRGEN |= (uint8_t)PR_EVSYS_bm)
1018 #define power_adca_enable() (PR_PRPA &= (uint8_t)~(PR_ADC_bm))
1019 #define power_adca_disable() (PR_PRPA |= (uint8_t)PR_ADC_bm)
1021 #define power_aca_enable() (PR_PRPA &= (uint8_t)~(PR_AC_bm))
1022 #define power_aca_disable() (PR_PRPA |= (uint8_t)PR_AC_bm)
1024 #define power_twic_enable() (PR_PRPC &= (uint8_t)~(PR_TWI_bm))
1025 #define power_twic_disable() (PR_PRPC |= (uint8_t)PR_TWI_bm)
1026 #define power_twie_enable() (PR_PRPE &= (uint8_t)~(PR_TWI_bm))
1027 #define power_twie_disable() (PR_PRPE |= (uint8_t)PR_TWI_bm)
1029 #define power_usartc0_enable() (PR_PRPC &= (uint8_t)~(PR_USART0_bm))
1030 #define power_usartc0_disable() (PR_PRPC |= (uint8_t)PR_USART0_bm)
1031 #define power_usartd0_enable() (PR_PRPD &= (uint8_t)~(PR_USART0_bm))
1032 #define power_usartd0_disable() (PR_PRPD |= (uint8_t)PR_USART0_bm)
1033 #define power_usarte0_enable() (PR_PRPE &= (uint8_t)~(PR_USART0_bm))
1034 #define power_usarte0_disable() (PR_PRPE |= (uint8_t)PR_USART0_bm)
1035 #define power_usartf0_enable() (PR_PRPF &= (uint8_t)~(PR_USART0_bm))
1036 #define power_usartf0_disable() (PR_PRPF |= (uint8_t)PR_USART0_bm)
1038 #define power_spic_enable() (PR_PRPC &= (uint8_t)~(PR_SPI_bm))
1039 #define power_spic_disable() (PR_PRPC |= (uint8_t)PR_SPI_bm)
1040 #define power_spid_enable() (PR_PRPD &= (uint8_t)~(PR_SPI_bm))
1041 #define power_spid_disable() (PR_PRPD |= (uint8_t)PR_SPI_bm)
1043 #define power_hiresc_enable() (PR_PRPC &= (uint8_t)~(PR_HIRES_bm))
1044 #define power_hiresc_disable() (PR_PRPC |= (uint8_t)PR_HIRES_bm)
1046 #define power_tc1c_enable() (PR_PRPC &= (uint8_t)~(PR_TC1_bm))
1047 #define power_tc1c_disable() (PR_PRPC |= (uint8_t)PR_TC1_bm)
1049 #define power_tc0c_enable() (PR_PRPC &= (uint8_t)~(PR_TC0_bm))
1050 #define power_tc0c_disable() (PR_PRPC |= (uint8_t)PR_TC0_bm)
1051 #define power_tc0d_enable() (PR_PRPD &= (uint8_t)~(PR_TC0_bm))
1052 #define power_tc0d_disable() (PR_PRPD |= (uint8_t)PR_TC0_bm)
1053 #define power_tc0e_enable() (PR_PRPE &= (uint8_t)~(PR_TC0_bm))
1054 #define power_tc0e_disable() (PR_PRPE |= (uint8_t)PR_TC0_bm)
1055 #define power_tc0f_enable() (PR_PRPF &= (uint8_t)~(PR_TC0_bm))
1056 #define power_tc0f_disable() (PR_PRPF |= (uint8_t)PR_TC0_bm)
1058 #define power_all_enable() \
1060 PR_PRGEN &= (uint8_t)~(PR_RTC_bm|PR_EVSYS_bm); \
1061 PR_PRPA &= (uint8_t)~(PR_ADC_bm|PR_AC_bm); \
1062 PR_PRPC &= (uint8_t)~(PR_TWI_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
1063 PR_PRPD &= (uint8_t)~(PR_USART0_bm|PR_SPI_bm|PR_TC0_bm); \
1064 PR_PRPE &= (uint8_t)~(PR_TWI_bm|PR_USART0_bm|PR_TC0_bm); \
1065 PR_PRPF &= (uint8_t)~(PR_USART0_bm|PR_TC0_bm); \
1068 #define power_all_disable() \
1070 PR_PRGEN |= (uint8_t)(PR_RTC_bm|PR_EVSYS_bm); \
1071 PR_PRPA |= (uint8_t)(PR_ADC_bm|PR_AC_bm); \
1072 PR_PRPC |= (uint8_t)(PR_TWI_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
1073 PR_PRPD |= (uint8_t)(PR_USART0_bm|PR_SPI_bm|PR_TC0_bm); \
1074 PR_PRPE |= (uint8_t)(PR_TWI_bm|PR_USART0_bm|PR_TC0_bm); \
1075 PR_PRPF |= (uint8_t)(PR_USART0_bm|PR_TC0_bm); \
1080 #if defined(__AVR_ATxmega16D4__) \
1081 || defined(__AVR_ATxmega32D4__)
1083 #define power_all_enable() \
1085 PR_PRGEN &= (uint8_t)~(PR_RTC_bm|PR_EVSYS_bm); \
1086 PR_PRPA &= (uint8_t)~(PR_ADC_bm|PR_AC_bm); \
1087 PR_PRPB &= (uint8_t)~(PR_ADC_bm|PR_AC_bm); \
1088 PR_PRPC &= (uint8_t)~(PR_TWI_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
1089 PR_PRPD &= (uint8_t)~(PR_TWI_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
1090 PR_PRPE &= (uint8_t)~(PR_TWI_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
1091 PR_PRPF &= (uint8_t)~(PR_TWI_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
1095 #define power_all_disable() \
1097 PR_PRGEN|= (uint8_t)(PR_EBI_bm|PR_RTC_bm|PR_EVSYS_bm|PR_DMA_bm); \
1098 PR_PRPA |= (uint8_t)(PR_ADC_bm|PR_AC_bm); \
1099 PR_PRPB |= (uint8_t)(PR_ADC_bm|PR_AC_bm); \
1100 PR_PRPC |= (uint8_t)(PR_TWI_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
1101 PR_PRPD |= (uint8_t)(PR_TWI_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
1102 PR_PRPE |= (uint8_t)(PR_TWI_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
1103 PR_PRPF |= (uint8_t)(PR_TWI_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
1106 #elif defined (__AVR_ATxmega64B1__) \
1107 || defined (__AVR_ATxmega64B3__) \
1108 || defined (__AVR_ATxmega128B1__) \
1109 || defined (__AVR_ATxmega128B3__)
1110 #define power_lcd_enable() (PR_PRGEN &= (uint8_t)~(PR_LCD_bm))
1111 #define power_lcd_disable() (PR_PRGEN |= (uint8_t)PR_LCD_bm)
1113 #define power_usb_enable() (PR_PRGEN &= (uint8_t)~(PR_USB_bm))
1114 #define power_usb_disable() (PR_PRGEN |= (uint8_t)PR_USB_bm)
1116 #define power_aes_enable() (PR_PRGEN &= (uint8_t)~(PR_AES_bm))
1117 #define power_aes_disable() (PR_PRGEN |= (uint8_t)PR_AES_bm)
1119 #define power_rtc_enable() (PR_PRGEN &= (uint8_t)~(PR_RTC_bm))
1120 #define power_rtc_disable() (PR_PRGEN |= (uint8_t)PR_RTC_bm)
1122 #define power_evsys_enable() (PR_PRGEN &= (uint8_t)~(PR_EVSYS_bm))
1123 #define power_evsys_disable() (PR_PRGEN |= (uint8_t)PR_EVSYS_bm)
1125 #define power_dma_enable() (PR_PRGEN &= (uint8_t)~(PR_DMA_bm))
1126 #define power_dma_disable() (PR_PRGEN |= (uint8_t)PR_DMA_bm)
1128 #define power_adca_enable() (PR_PRPA &= (uint8_t)~(PR_ADC_bm))
1129 #define power_adca_disable() (PR_PRPA |= (uint8_t)PR_ADC_bm)
1130 #define power_adcb_enable() (PR_PRPB &= (uint8_t)~(PR_ADC_bm))
1131 #define power_adcb_disable() (PR_PRPB |= (uint8_t)PR_ADC_bm)
1133 #define power_aca_enable() (PR_PRPA &= (uint8_t)~(PR_AC_bm))
1134 #define power_aca_disable() (PR_PRPA |= (uint8_t)PR_AC_bm)
1135 #define power_acb_enable() (PR_PRPB &= (uint8_t)~(PR_AC_bm))
1136 #define power_acb_disable() (PR_PRPB |= (uint8_t)PR_AC_bm)
1138 #define power_twic_enable() (PR_PRPC &= (uint8_t)~(PR_TWI_bm))
1139 #define power_twic_disable() (PR_PRPC |= (uint8_t)PR_TWI_bm)
1141 #define power_usartc0_enable() (PR_PRPC &= (uint8_t)~(PR_USART0_bm))
1142 #define power_usartc0_disable() (PR_PRPC |= (uint8_t)PR_USART0_bm)
1143 #define power_usarte0_enable() (PR_PRPE &= (uint8_t)~(PR_USART0_bm))
1144 #define power_usarte0_disable() (PR_PRPE |= (uint8_t)PR_USART0_bm)
1146 #define power_spic_enable() (PR_PRPC &= (uint8_t)~(PR_SPI_bm))
1147 #define power_spic_disable() (PR_PRPC |= (uint8_t)PR_SPI_bm)
1149 #define power_hiresc_enable() (PR_PRPC &= (uint8_t)~(PR_HIRES_bm))
1150 #define power_hiresc_disable() (PR_PRPC |= (uint8_t)PR_HIRES_bm)
1152 #define power_tc1c_enable() (PR_PRPC &= (uint8_t)~(PR_TC1_bm))
1153 #define power_tc1c_disable() (PR_PRPC |= (uint8_t)PR_TC1_bm)
1155 #define power_tc0c_enable() (PR_PRPC &= (uint8_t)~(PR_TC0_bm))
1156 #define power_tc0c_disable() (PR_PRPC |= (uint8_t)PR_TC0_bm)
1157 #define power_tc0e_enable() (PR_PRPE &= (uint8_t)~(PR_TC0_bm))
1158 #define power_tc0e_disable() (PR_PRPE |= (uint8_t)PR_TC0_bm)
1160 #define power_all_enable() \
1162 PR_PRGEN &= (uint8_t)~(PR_LCD_bm|PR_USB_bm|PR_AES_bm|PR_RTC_bm|PR_EVSYS_bm|PR_DMA_bm); \
1163 PR_PRPA &= (uint8_t)~(PR_ADC_bm|PR_AC_bm); \
1164 PR_PRPB &= (uint8_t)~(PR_ADC_bm|PR_AC_bm); \
1165 PR_PRPC &= (uint8_t)~(PR_TWI_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
1166 PR_PRPE &= (uint8_t)~(PR_USART0_bm|PR_TC0_bm); \
1169 #define power_all_disable() \
1171 PR_PRGEN |= (uint8_t)(PR_LCD_bm|PR_USB_bm|PR_AES_bm|PR_RTC_bm|PR_EVSYS_bm|PR_DMA_bm); \
1172 PR_PRPA |= (uint8_t)(PR_ADC_bm|PR_AC_bm); \
1173 PR_PRPB |= (uint8_t)(PR_ADC_bm|PR_AC_bm); \
1174 PR_PRPC |= (uint8_t)(PR_TWI_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
1175 PR_PRPE |= (uint8_t)(PR_USART0_bm|PR_TC0_bm); \
1178 #elif defined(__AVR_ATmega640__) \
1179 || defined(__AVR_ATmega1280__) \
1180 || defined(__AVR_ATmega1281__) \
1181 || defined(__AVR_ATmega2560__) \
1182 || defined(__AVR_ATmega2561__)
1184 #define power_adc_enable() (PRR0 &= (uint8_t)~(1 << PRADC))
1185 #define power_adc_disable() (PRR0 |= (uint8_t)(1 << PRADC))
1187 #define power_spi_enable() (PRR0 &= (uint8_t)~(1 << PRSPI))
1188 #define power_spi_disable() (PRR0 |= (uint8_t)(1 << PRSPI))
1190 #define power_twi_enable() (PRR0 &= (uint8_t)~(1 << PRTWI))
1191 #define power_twi_disable() (PRR0 |= (uint8_t)(1 << PRTWI))
1193 #define power_timer0_enable() (PRR0 &= (uint8_t)~(1 << PRTIM0))
1194 #define power_timer0_disable() (PRR0 |= (uint8_t)(1 << PRTIM0))
1196 #define power_timer1_enable() (PRR0 &= (uint8_t)~(1 << PRTIM1))
1197 #define power_timer1_disable() (PRR0 |= (uint8_t)(1 << PRTIM1))
1199 #define power_timer2_enable() (PRR0 &= (uint8_t)~(1 << PRTIM2))
1200 #define power_timer2_disable() (PRR0 |= (uint8_t)(1 << PRTIM2))
1202 #define power_timer3_enable() (PRR1 &= (uint8_t)~(1 << PRTIM3))
1203 #define power_timer3_disable() (PRR1 |= (uint8_t)(1 << PRTIM3))
1205 #define power_timer4_enable() (PRR1 &= (uint8_t)~(1 << PRTIM4))
1206 #define power_timer4_disable() (PRR1 |= (uint8_t)(1 << PRTIM4))
1208 #define power_timer5_enable() (PRR1 &= (uint8_t)~(1 << PRTIM5))
1209 #define power_timer5_disable() (PRR1 |= (uint8_t)(1 << PRTIM5))
1211 #define power_usart0_enable() (PRR0 &= (uint8_t)~(1 << PRUSART0))
1212 #define power_usart0_disable() (PRR0 |= (uint8_t)(1 << PRUSART0))
1214 #define power_usart1_enable() (PRR1 &= (uint8_t)~(1 << PRUSART1))
1215 #define power_usart1_disable() (PRR1 |= (uint8_t)(1 << PRUSART1))
1217 #define power_usart2_enable() (PRR1 &= (uint8_t)~(1 << PRUSART2))
1218 #define power_usart2_disable() (PRR1 |= (uint8_t)(1 << PRUSART2))
1220 #define power_usart3_enable() (PRR1 &= (uint8_t)~(1 << PRUSART3))
1221 #define power_usart3_disable() (PRR1 |= (uint8_t)(1 << PRUSART3))
1223 #define power_all_enable() \
1225 PRR0 &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRUSART0)); \
1226 PRR1 &= (uint8_t)~((1<<PRTIM3)|(1<<PRTIM4)|(1<<PRTIM5)|(1<<PRTIM5)|(1<<PRUSART1)|(1<<PRUSART2)|(1<<PRUSART3)); \
1229 #define power_all_disable() \
1231 PRR0 |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRUSART0)); \
1232 PRR1 |= (uint8_t)((1<<PRTIM3)|(1<<PRTIM4)|(1<<PRTIM5)|(1<<PRTIM5)|(1<<PRUSART1)|(1<<PRUSART2)|(1<<PRUSART3)); \
1236 #elif defined(__AVR_ATmega128RFA1__)
1238 #define power_adc_enable() (PRR0 &= (uint8_t)~(1 << PRADC))
1239 #define power_adc_disable() (PRR0 |= (uint8_t)(1 << PRADC))
1241 #define power_spi_enable() (PRR0 &= (uint8_t)~(1 << PRSPI))
1242 #define power_spi_disable() (PRR0 |= (uint8_t)(1 << PRSPI))
1244 #define power_twi_enable() (PRR0 &= (uint8_t)~(1 << PRTWI))
1245 #define power_twi_disable() (PRR0 |= (uint8_t)(1 << PRTWI))
1247 #define power_timer0_enable() (PRR0 &= (uint8_t)~(1 << PRTIM0))
1248 #define power_timer0_disable() (PRR0 |= (uint8_t)(1 << PRTIM0))
1250 #define power_timer1_enable() (PRR0 &= (uint8_t)~(1 << PRTIM1))
1251 #define power_timer1_disable() (PRR0 |= (uint8_t)(1 << PRTIM1))
1253 #define power_timer2_enable() (PRR0 &= (uint8_t)~(1 << PRTIM2))
1254 #define power_timer2_disable() (PRR0 |= (uint8_t)(1 << PRTIM2))
1256 #define power_timer3_enable() (PRR1 &= (uint8_t)~(1 << PRTIM3))
1257 #define power_timer3_disable() (PRR1 |= (uint8_t)(1 << PRTIM3))
1259 #define power_timer4_enable() (PRR1 &= (uint8_t)~(1 << PRTIM4))
1260 #define power_timer4_disable() (PRR1 |= (uint8_t)(1 << PRTIM4))
1262 #define power_timer5_enable() (PRR1 &= (uint8_t)~(1 << PRTIM5))
1263 #define power_timer5_disable() (PRR1 |= (uint8_t)(1 << PRTIM5))
1265 #define power_usart0_enable() (PRR0 &= (uint8_t)~(1 << PRUSART0))
1266 #define power_usart0_disable() (PRR0 |= (uint8_t)(1 << PRUSART0))
1268 #define power_usart1_enable() (PRR1 &= (uint8_t)~(1 << PRUSART1))
1269 #define power_usart1_disable() (PRR1 |= (uint8_t)(1 << PRUSART1))
1271 #define power_all_enable() \
1273 PRR0 &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRUSART0)); \
1274 PRR1 &= (uint8_t)~((1<<PRTIM3)|(1<<PRTIM4)|(1<<PRTIM5)|(1<<PRTIM5)|(1<<PRUSART1)); \
1277 #define power_all_disable() \
1279 PRR0 |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRUSART0)); \
1280 PRR1 |= (uint8_t)((1<<PRTIM3)|(1<<PRTIM4)|(1<<PRTIM5)|(1<<PRTIM5)|(1<<PRUSART1)); \
1283 #elif defined(__AVR_ATmega256RFR2__) \
1284 || defined(__AVR_ATmega128RFR2__) \
1285 || defined(__AVR_ATmega64RFR2__) \
1286 || defined(__AVR_ATmega2564RFR2__) \
1287 || defined(__AVR_ATmega1284RFR2__) \
1288 || defined(__AVR_ATmega644RFR2__) \
1290 #define power_adc_enable() (PRR0 &= (uint8_t)~(1 << PRADC))
1291 #define power_adc_disable() (PRR0 |= (uint8_t)(1 << PRADC))
1293 #define power_usart0_enable() (PRR0 &= (uint8_t)~(1 << PRUSART0))
1294 #define power_usart0_disable() (PRR0 |= (uint8_t)(1 << PRUSART0))
1296 #define power_spi_enable() (PRR0 &= (uint8_t)~(1 << PRSPI))
1297 #define power_spi_disable() (PRR0 |= (uint8_t)(1 << PRSPI))
1299 #define power_timer1_enable() (PRR0 &= (uint8_t)~(1 << PRTIM1))
1300 #define power_timer1_disable() (PRR0 |= (uint8_t)(1 << PRTIM1))
1302 #define power_pga_enable() (PRR0 &= (uint8_t)~(1 << PRPGA))
1303 #define power_pga_disable() (PRR0 |= (uint8_t)(1 << PRPGA))
1305 #define power_timer0_enable() (PRR0 &= (uint8_t)~(1 << PRTIM0))
1306 #define power_timer0_disable() (PRR0 |= (uint8_t)(1 << PRTIM0))
1308 #define power_timer2_enable() (PRR0 &= (uint8_t)~(1 << PRTIM2))
1309 #define power_timer2_disable() (PRR0 |= (uint8_t)(1 << PRTIM2))
1311 #define power_twi_enable() (PRR0 &= (uint8_t)~(1 << PRTWI))
1312 #define power_twi_disable() (PRR0 |= (uint8_t)(1 << PRTWI))
1314 #define power_usart1_enable() (PRR1 &= (uint8_t)~(1 << PRUSART1))
1315 #define power_usart1_disable() (PRR1 |= (uint8_t)(1 << PRUSART1))
1317 #define power_timer3_enable() (PRR1 &= (uint8_t)~(1 << PRTIM3))
1318 #define power_timer3_disable() (PRR1 |= (uint8_t)(1 << PRTIM3))
1320 #define power_timer4_enable() (PRR1 &= (uint8_t)~(1 << PRTIM4))
1321 #define power_timer4_disable() (PRR1 |= (uint8_t)(1 << PRTIM4))
1323 #define power_timer5_enable() (PRR1 &= (uint8_t)~(1 << PRTIM5))
1324 #define power_timer5_disable() (PRR1 |= (uint8_t)(1 << PRTIM5))
1326 #define power_transceiver_enable() (PRR1 &= (uint8_t)~(1 << PRTRX24))
1327 #define power_transceiver_disable() (PRR1 |= (uint8_t)(1 << PRTRX24))
1329 #define power_ram0_enable() (PRR2 &= (uint8_t)~(1 << PRRAM0))
1330 #define power_ram0_disable() (PRR2 |= (uint8_t)(1 << PRRAM0))
1332 #define power_ram1_enable() (PRR2 &= (uint8_t)~(1 << PRRAM1))
1333 #define power_ram1_disable() (PRR2 |= (uint8_t)(1 << PRRAM1))
1335 #define power_ram2_enable() (PRR2 &= (uint8_t)~(1 << PRRAM2))
1336 #define power_ram2_disable() (PRR2 |= (uint8_t)(1 << PRRAM2))
1338 #define power_ram3_enable() (PRR2 &= (uint8_t)~(1 << PRRAM3))
1339 #define power_ram3_disable() (PRR2 |= (uint8_t)(1 << PRRAM3))
1341 #define power_all_enable() \
1343 PRR0 &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRUSART0)); \
1344 PRR1 &= (uint8_t)~((1<<PRUSART1)|(1<<PRTIM3)|(1<<PRTIM4)|(1<<PRTIM5)|(1<<PRTRX24)); \
1345 PRR2 &= (uint8_t)~((1<<PRRAM0)|(1<<PRRAM1)|(1<<PRRAM2)|(1<<PRRAM3)); \
1348 #define power_all_disable() \
1350 PRR0 |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRUSART0)); \
1351 PRR1 |= (uint8_t)((1<<PRUSART1)|(1<<PRTIM3)|(1<<PRTIM4)|(1<<PRTIM5)|(1<<PRTRX24)); \
1352 PRR2 |= (uint8_t)((1<<PRRAM0)|(1<<PRRAM1)|(1<<PRRAM2)|(1<<PRRAM3)); \
1355 #elif defined(__AVR_AT90USB646__) \
1356 || defined(__AVR_AT90USB647__) \
1357 || defined(__AVR_AT90USB1286__) \
1358 || defined(__AVR_AT90USB1287__)
1360 #define power_adc_enable() (PRR0 &= (uint8_t)~(1 << PRADC))
1361 #define power_adc_disable() (PRR0 |= (uint8_t)(1 << PRADC))
1363 #define power_spi_enable() (PRR0 &= (uint8_t)~(1 << PRSPI))
1364 #define power_spi_disable() (PRR0 |= (uint8_t)(1 << PRSPI))
1366 #define power_twi_enable() (PRR0 &= (uint8_t)~(1 << PRTWI))
1367 #define power_twi_disable() (PRR0 |= (uint8_t)(1 << PRTWI))
1369 #define power_timer0_enable() (PRR0 &= (uint8_t)~(1 << PRTIM0))
1370 #define power_timer0_disable() (PRR0 |= (uint8_t)(1 << PRTIM0))
1372 #define power_timer1_enable() (PRR0 &= (uint8_t)~(1 << PRTIM1))
1373 #define power_timer1_disable() (PRR0 |= (uint8_t)(1 << PRTIM1))
1375 #define power_timer2_enable() (PRR0 &= (uint8_t)~(1 << PRTIM2))
1376 #define power_timer2_disable() (PRR0 |= (uint8_t)(1 << PRTIM2))
1378 #define power_timer3_enable() (PRR1 &= (uint8_t)~(1 << PRTIM3))
1379 #define power_timer3_disable() (PRR1 |= (uint8_t)(1 << PRTIM3))
1381 #define power_usart1_enable() (PRR1 &= (uint8_t)~(1 << PRUSART1))
1382 #define power_usart1_disable() (PRR1 |= (uint8_t)(1 << PRUSART1))
1384 #define power_usb_enable() (PRR1 &= (uint8_t)~(1 << PRUSB))
1385 #define power_usb_disable() (PRR1 |= (uint8_t)(1 << PRUSB))
1387 #define power_all_enable() \
1389 PRR0 &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)); \
1390 PRR1 &= (uint8_t)~((1<<PRTIM3)|(1<<PRUSART1)|(1<<PRUSB)); \
1393 #define power_all_disable() \
1395 PRR0 |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)); \
1396 PRR1 |= (uint8_t)((1<<PRTIM3)|(1<<PRUSART1)|(1<<PRUSB)); \
1400 #elif defined(__AVR_ATmega32U4__) \
1401 || defined(__AVR_ATmega16U4__)
1404 #define power_adc_enable() (PRR0 &= (uint8_t)~(1 << PRADC))
1405 #define power_adc_disable() (PRR0 |= (uint8_t)(1 << PRADC))
1407 #define power_usart0_enable() (PRR0 &= (uint8_t)~(1 << PRUSART0))
1408 #define power_usart0_disable() (PRR0 |= (uint8_t)(1 << PRUSART0))
1410 #define power_spi_enable() (PRR0 &= (uint8_t)~(1 << PRSPI))
1411 #define power_spi_disable() (PRR0 |= (uint8_t)(1 << PRSPI))
1413 #define power_twi_enable() (PRR0 &= (uint8_t)~(1 << PRTWI))
1414 #define power_twi_disable() (PRR0 |= (uint8_t)(1 << PRTWI))
1416 #define power_timer0_enable() (PRR0 &= (uint8_t)~(1 << PRTIM0))
1417 #define power_timer0_disable() (PRR0 |= (uint8_t)(1 << PRTIM0))
1419 #define power_timer1_enable() (PRR0 &= (uint8_t)~(1 << PRTIM1))
1420 #define power_timer1_disable() (PRR0 |= (uint8_t)(1 << PRTIM1))
1422 #define power_timer2_enable() (PRR0 &= (uint8_t)~(1 << PRTIM2))
1423 #define power_timer2_disable() (PRR0 |= (uint8_t)(1 << PRTIM2))
1425 #define power_timer3_enable() (PRR1 &= (uint8_t)~(1 << PRTIM3))
1426 #define power_timer3_disable() (PRR1 |= (uint8_t)(1 << PRTIM3))
1428 #define power_usart1_enable() (PRR1 &= (uint8_t)~(1 << PRUSART1))
1429 #define power_usart1_disable() (PRR1 |= (uint8_t)(1 << PRUSART1))
1431 #define power_usb_enable() (PRR1 &= (uint8_t)~(1 << PRUSB))
1432 #define power_usb_disable() (PRR1 |= (uint8_t)(1 << PRUSB))
1434 #define power_all_enable() \
1436 PRR0 &= (uint8_t)~((1<<PRADC)|(1<<PRUSART0)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)); \
1437 PRR1 &= (uint8_t)~((1<<PRTIM3)|(1<<PRUSART1)|(1<<PRUSB)); \
1440 #define power_all_disable() \
1442 PRR0 |= (uint8_t)((1<<PRADC)|(1<<PRUSART0)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)); \
1443 PRR1 |= (uint8_t)((1<<PRTIM3)|(1<<PRUSART1)|(1<<PRUSB)); \
1447 #elif defined(__AVR_ATmega32U6__)
1450 #define power_adc_enable() (PRR0 &= (uint8_t)~(1 << PRADC))
1451 #define power_adc_disable() (PRR0 |= (uint8_t)(1 << PRADC))
1453 #define power_spi_enable() (PRR0 &= (uint8_t)~(1 << PRSPI))
1454 #define power_spi_disable() (PRR0 |= (uint8_t)(1 << PRSPI))
1456 #define power_twi_enable() (PRR0 &= (uint8_t)~(1 << PRTWI))
1457 #define power_twi_disable() (PRR0 |= (uint8_t)(1 << PRTWI))
1459 #define power_timer0_enable() (PRR0 &= (uint8_t)~(1 << PRTIM0))
1460 #define power_timer0_disable() (PRR0 |= (uint8_t)(1 << PRTIM0))
1462 #define power_timer1_enable() (PRR0 &= (uint8_t)~(1 << PRTIM1))
1463 #define power_timer1_disable() (PRR0 |= (uint8_t)(1 << PRTIM1))
1465 #define power_timer2_enable() (PRR0 &= (uint8_t)~(1 << PRTIM2))
1466 #define power_timer2_disable() (PRR0 |= (uint8_t)(1 << PRTIM2))
1468 #define power_timer3_enable() (PRR1 &= (uint8_t)~(1 << PRTIM3))
1469 #define power_timer3_disable() (PRR1 |= (uint8_t)(1 << PRTIM3))
1471 #define power_usart1_enable() (PRR1 &= (uint8_t)~(1 << PRUSART1))
1472 #define power_usart1_disable() (PRR1 |= (uint8_t)(1 << PRUSART1))
1474 #define power_usb_enable() (PRR1 &= (uint8_t)~(1 << PRUSB))
1475 #define power_usb_disable() (PRR1 |= (uint8_t)(1 << PRUSB))
1477 #define power_all_enable() \
1479 PRR0 &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)); \
1480 PRR1 &= (uint8_t)~((1<<PRTIM3)|(1<<PRUSART1)|(1<<PRUSB)); \
1483 #define power_all_disable() \
1485 PRR0 |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)); \
1486 PRR1 |= (uint8_t)((1<<PRTIM3)|(1<<PRUSART1)|(1<<PRUSB)); \
1490 #elif defined(__AVR_AT90PWM1__)
1492 #define power_adc_enable() (PRR &= (uint8_t)~(1 << PRADC))
1493 #define power_adc_disable() (PRR |= (uint8_t)(1 << PRADC))
1495 #define power_spi_enable() (PRR &= (uint8_t)~(1 << PRSPI))
1496 #define power_spi_disable() (PRR |= (uint8_t)(1 << PRSPI))
1498 #define power_timer0_enable() (PRR &= (uint8_t)~(1 << PRTIM0))
1499 #define power_timer0_disable() (PRR |= (uint8_t)(1 << PRTIM0))
1501 #define power_timer1_enable() (PRR &= (uint8_t)~(1 << PRTIM1))
1502 #define power_timer1_disable() (PRR |= (uint8_t)(1 << PRTIM1))
1505 #define power_psc0_enable() (PRR &= (uint8_t)~(1 << PRPSC0))
1506 #define power_psc0_disable() (PRR |= (uint8_t)(1 << PRPSC0))
1509 #define power_psc1_enable() (PRR &= (uint8_t)~(1 << PRPSC1))
1510 #define power_psc1_disable() (PRR |= (uint8_t)(1 << PRPSC1))
1513 #define power_psc2_enable() (PRR &= (uint8_t)~(1 << PRPSC2))
1514 #define power_psc2_disable() (PRR |= (uint8_t)(1 << PRPSC2))
1516 #define power_all_enable() (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRPSC0)|(1<<PRPSC1)|(1<<PRPSC2)))
1517 #define power_all_disable() (PRR |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRPSC0)|(1<<PRPSC1)|(1<<PRPSC2)))
1520 #elif defined(__AVR_AT90PWM2__) \
1521 || defined(__AVR_AT90PWM2B__) \
1522 || defined(__AVR_AT90PWM3__) \
1523 || defined(__AVR_AT90PWM3B__) \
1524 || defined(__AVR_AT90PWM216__) \
1525 || defined(__AVR_AT90PWM316__)
1527 #define power_adc_enable() (PRR &= (uint8_t)~(1 << PRADC))
1528 #define power_adc_disable() (PRR |= (uint8_t)(1 << PRADC))
1530 #define power_spi_enable() (PRR &= (uint8_t)~(1 << PRSPI))
1531 #define power_spi_disable() (PRR |= (uint8_t)(1 << PRSPI))
1533 #define power_usart_enable() (PRR &= (uint8_t)~(1 << PRUSART))
1534 #define power_usart_disable() (PRR |= (uint8_t)(1 << PRUSART))
1536 #define power_timer0_enable() (PRR &= (uint8_t)~(1 << PRTIM0))
1537 #define power_timer0_disable() (PRR |= (uint8_t)(1 << PRTIM0))
1539 #define power_timer1_enable() (PRR &= (uint8_t)~(1 << PRTIM1))
1540 #define power_timer1_disable() (PRR |= (uint8_t)(1 << PRTIM1))
1543 #define power_psc0_enable() (PRR &= (uint8_t)~(1 << PRPSC0))
1544 #define power_psc0_disable() (PRR |= (uint8_t)(1 << PRPSC0))
1547 #define power_psc1_enable() (PRR &= (uint8_t)~(1 << PRPSC1))
1548 #define power_psc1_disable() (PRR |= (uint8_t)(1 << PRPSC1))
1551 #define power_psc2_enable() (PRR &= (uint8_t)~(1 << PRPSC2))
1552 #define power_psc2_disable() (PRR |= (uint8_t)(1 << PRPSC2))
1554 #define power_all_enable() (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRPSC0)|(1<<PRPSC1)|(1<<PRPSC2)))
1555 #define power_all_disable() (PRR |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRPSC0)|(1<<PRPSC1)|(1<<PRPSC2)))
1558 #elif defined(__AVR_AT90PWM81__) \
1559 || defined(__AVR_AT90PWM161__)
1561 #define power_adc_enable() (PRR &= (uint8_t)~(1 << PRADC))
1562 #define power_adc_disable() (PRR |= (uint8_t)(1 << PRADC))
1564 #define power_spi_enable() (PRR &= (uint8_t)~(1 << PRSPI))
1565 #define power_spi_disable() (PRR |= (uint8_t)(1 << PRSPI))
1567 #define power_timer1_enable() (PRR &= (uint8_t)~(1 << PRTIM1))
1568 #define power_timer1_disable() (PRR |= (uint8_t)(1 << PRTIM1))
1571 #define power_pscr_enable() (PRR &= (uint8_t)~(1 << PRPSCR))
1572 #define power_pscr_disable() (PRR |= (uint8_t)(1 << PRPSCR))
1575 #define power_psc2_enable() (PRR &= (uint8_t)~(1 << PRPSC2))
1576 #define power_psc2_disable() (PRR |= (uint8_t)(1 << PRPSC2))
1578 #define power_all_enable() (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRTIM1)|(1<<PRPSCR)|(1<<PRPSC2)))
1579 #define power_all_disable() (PRR |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRTIM1)|(1<<PRPSCR)|(1<<PRPSC2)))
1582 #elif defined(__AVR_ATmega165__) \
1583 || defined(__AVR_ATmega165A__) \
1584 || defined(__AVR_ATmega165P__) \
1585 || defined(__AVR_ATmega165PA__) \
1586 || defined(__AVR_ATmega325__) \
1587 || defined(__AVR_ATmega325A__) \
1588 || defined(__AVR_ATmega325PA__) \
1589 || defined(__AVR_ATmega3250__) \
1590 || defined(__AVR_ATmega3250A__) \
1591 || defined(__AVR_ATmega3250PA__) \
1592 || defined(__AVR_ATmega645__) \
1593 || defined(__AVR_ATmega645A__) \
1594 || defined(__AVR_ATmega645P__) \
1595 || defined(__AVR_ATmega6450__) \
1596 || defined(__AVR_ATmega6450A__) \
1597 || defined(__AVR_ATmega6450P__)
1599 #define power_adc_enable() (PRR &= (uint8_t)~(1 << PRADC))
1600 #define power_adc_disable() (PRR |= (uint8_t)(1 << PRADC))
1602 #define power_spi_enable() (PRR &= (uint8_t)~(1 << PRSPI))
1603 #define power_spi_disable() (PRR |= (uint8_t)(1 << PRSPI))
1605 #define power_usart0_enable() (PRR &= (uint8_t)~(1 << PRUSART0))
1606 #define power_usart0_disable() (PRR |= (uint8_t)(1 << PRUSART0))
1608 #define power_timer1_enable() (PRR &= (uint8_t)~(1 << PRTIM1))
1609 #define power_timer1_disable() (PRR |= (uint8_t)(1 << PRTIM1))
1611 #define power_all_enable() (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRTIM1)))
1612 #define power_all_disable() (PRR |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRTIM1)))
1615 #elif defined(__AVR_ATmega169__) \
1616 || defined(__AVR_ATmega169A__) \
1617 || defined(__AVR_ATmega169P__) \
1618 || defined(__AVR_ATmega169PA__) \
1619 || defined(__AVR_ATmega329__) \
1620 || defined(__AVR_ATmega329A__) \
1621 || defined(__AVR_ATmega329P__) \
1622 || defined(__AVR_ATmega329PA__) \
1623 || defined(__AVR_ATmega3290__) \
1624 || defined(__AVR_ATmega3290A__) \
1625 || defined(__AVR_ATmega3290P__) \
1626 || defined(__AVR_ATmega3290PA__) \
1627 || defined(__AVR_ATmega649__) \
1628 || defined(__AVR_ATmega649A__) \
1629 || defined(__AVR_ATmega649P__) \
1630 || defined(__AVR_ATmega6490__) \
1631 || defined(__AVR_ATmega6490A__) \
1632 || defined(__AVR_ATmega6490P__)
1634 #define power_adc_enable() (PRR &= (uint8_t)~(1 << PRADC))
1635 #define power_adc_disable() (PRR |= (uint8_t)(1 << PRADC))
1637 #define power_spi_enable() (PRR &= (uint8_t)~(1 << PRSPI))
1638 #define power_spi_disable() (PRR |= (uint8_t)(1 << PRSPI))
1640 #define power_usart0_enable() (PRR &= (uint8_t)~(1 << PRUSART0))
1641 #define power_usart0_disable() (PRR |= (uint8_t)(1 << PRUSART0))
1643 #define power_timer1_enable() (PRR &= (uint8_t)~(1 << PRTIM1))
1644 #define power_timer1_disable() (PRR |= (uint8_t)(1 << PRTIM1))
1646 #define power_lcd_enable() (PRR &= (uint8_t)~(1 << PRLCD))
1647 #define power_lcd_disable() (PRR |= (uint8_t)(1 << PRLCD))
1649 #define power_all_enable() (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRTIM1)|(1<<PRLCD)))
1650 #define power_all_disable() (PRR |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRTIM1)|(1<<PRLCD)))
1653 #elif defined(__AVR_ATmega164A__) \
1654 || defined(__AVR_ATmega164P__) \
1655 || defined(__AVR_ATmega324A__) \
1656 || defined(__AVR_ATmega324P__) \
1657 || defined(__AVR_ATmega324PA__) \
1658 || defined(__AVR_ATmega644P__) \
1659 || defined(__AVR_ATmega644A__) \
1660 || defined(__AVR_ATmega644PA__)
1662 #define power_adc_enable() (PRR0 &= (uint8_t)~(1 << PRADC))
1663 #define power_adc_disable() (PRR0 |= (uint8_t)(1 << PRADC))
1665 #define power_spi_enable() (PRR0 &= (uint8_t)~(1 << PRSPI))
1666 #define power_spi_disable() (PRR0 |= (uint8_t)(1 << PRSPI))
1668 #define power_usart0_enable() (PRR0 &= (uint8_t)~(1 << PRUSART0))
1669 #define power_usart0_disable() (PRR0 |= (uint8_t)(1 << PRUSART0))
1671 #define power_usart1_enable() (PRR0 &= (uint8_t)~(1 << PRUSART1))
1672 #define power_usart1_disable() (PRR0 |= (uint8_t)(1 << PRUSART1))
1674 #define power_timer0_enable() (PRR0 &= (uint8_t)~(1 << PRTIM0))
1675 #define power_timer0_disable() (PRR0 |= (uint8_t)(1 << PRTIM0))
1677 #define power_timer1_enable() (PRR0 &= (uint8_t)~(1 << PRTIM1))
1678 #define power_timer1_disable() (PRR0 |= (uint8_t)(1 << PRTIM1))
1680 #define power_timer2_enable() (PRR0 &= (uint8_t)~(1 << PRTIM2))
1681 #define power_timer2_disable() (PRR0 |= (uint8_t)(1 << PRTIM2))
1683 #define power_twi_enable() (PRR0 &= (uint8_t)~(1 << PRTWI))
1684 #define power_twi_disable() (PRR0 |= (uint8_t)(1 << PRTWI))
1686 #define power_all_enable() (PRR0 &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRUSART1)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRTWI)))
1687 #define power_all_disable() (PRR0 |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRUSART1)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRTWI)))
1690 #elif defined(__AVR_ATmega644__) \
1691 || defined(__AVR_ATmega164PA__)
1693 #define power_adc_enable() (PRR0 &= (uint8_t)~(1 << PRADC))
1694 #define power_adc_disable() (PRR0 |= (uint8_t)(1 << PRADC))
1696 #define power_spi_enable() (PRR0 &= (uint8_t)~(1 << PRSPI))
1697 #define power_spi_disable() (PRR0 |= (uint8_t)(1 << PRSPI))
1699 #define power_usart0_enable() (PRR0 &= (uint8_t)~(1 << PRUSART0))
1700 #define power_usart0_disable() (PRR0 |= (uint8_t)(1 << PRUSART0))
1702 #define power_timer0_enable() (PRR0 &= (uint8_t)~(1 << PRTIM0))
1703 #define power_timer0_disable() (PRR0 |= (uint8_t)(1 << PRTIM0))
1705 #define power_timer1_enable() (PRR0 &= (uint8_t)~(1 << PRTIM1))
1706 #define power_timer1_disable() (PRR0 |= (uint8_t)(1 << PRTIM1))
1708 #define power_timer2_enable() (PRR0 &= (uint8_t)~(1 << PRTIM2))
1709 #define power_timer2_disable() (PRR0 |= (uint8_t)(1 << PRTIM2))
1711 #define power_twi_enable() (PRR0 &= (uint8_t)~(1 << PRTWI))
1712 #define power_twi_disable() (PRR0 |= (uint8_t)(1 << PRTWI))
1714 #define power_all_enable() (PRR0 &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRTWI)))
1715 #define power_all_disable() (PRR0 |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRTWI)))
1718 #elif defined(__AVR_ATmega406__)
1720 #define power_twi_enable() (PRR0 &= (uint8_t)~(1 << PRTWI))
1721 #define power_twi_disable() (PRR0 |= (uint8_t)(1 << PRTWI))
1723 #define power_timer0_enable() (PRR0 &= (uint8_t)~(1 << PRTIM0))
1724 #define power_timer0_disable() (PRR0 |= (uint8_t)(1 << PRTIM0))
1726 #define power_timer1_enable() (PRR0 &= (uint8_t)~(1 << PRTIM1))
1727 #define power_timer1_disable() (PRR0 |= (uint8_t)(1 << PRTIM1))
1730 #define power_vadc_enable() (PRR0 &= (uint8_t)~(1 << PRVADC))
1731 #define power_vadc_disable() (PRR0 |= (uint8_t)(1 << PRVADC))
1733 #define power_all_enable() (PRR0 &= (uint8_t)~((1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRVADC)))
1734 #define power_all_disable() (PRR0 |= (uint8_t)((1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRVADC)))
1737 #elif defined(__AVR_ATmega48__) \
1738 || defined(__AVR_ATmega48A__) \
1739 || defined(__AVR_ATmega48PA__) \
1740 || defined(__AVR_ATmega48P__) \
1741 || defined(__AVR_ATmega88__) \
1742 || defined(__AVR_ATmega88A__) \
1743 || defined(__AVR_ATmega88P__) \
1744 || defined(__AVR_ATmega88PA__) \
1745 || defined(__AVR_ATmega168__) \
1746 || defined(__AVR_ATmega168A__) \
1747 || defined(__AVR_ATmega168P__) \
1748 || defined(__AVR_ATmega168PA__) \
1749 || defined(__AVR_ATmega328__) \
1750 || defined(__AVR_ATmega328P__) \
1751 || defined(__AVR_ATtiny48__) \
1752 || defined(__AVR_ATtiny88__) \
1753 || defined(__AVR_ATtiny828__)
1755 #define power_adc_enable() (PRR &= (uint8_t)~(1 << PRADC))
1756 #define power_adc_disable() (PRR |= (uint8_t)(1 << PRADC))
1758 #define power_spi_enable() (PRR &= (uint8_t)~(1 << PRSPI))
1759 #define power_spi_disable() (PRR |= (uint8_t)(1 << PRSPI))
1761 #define power_usart0_enable() (PRR &= (uint8_t)~(1 << PRUSART0))
1762 #define power_usart0_disable() (PRR |= (uint8_t)(1 << PRUSART0))
1764 #define power_timer0_enable() (PRR &= (uint8_t)~(1 << PRTIM0))
1765 #define power_timer0_disable() (PRR |= (uint8_t)(1 << PRTIM0))
1767 #define power_timer1_enable() (PRR &= (uint8_t)~(1 << PRTIM1))
1768 #define power_timer1_disable() (PRR |= (uint8_t)(1 << PRTIM1))
1770 #if !defined(__AVR_ATtiny828__)
1772 #define power_timer2_enable() (PRR &= (uint8_t)~(1 << PRTIM2))
1773 #define power_timer2_disable() (PRR |= (uint8_t)(1 << PRTIM2))
1777 #define power_twi_enable() (PRR &= (uint8_t)~(1 << PRTWI))
1778 #define power_twi_disable() (PRR |= (uint8_t)(1 << PRTWI))
1780 #if defined(__AVR_ATtiny828__)
1782 #define power_all_enable() (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTWI)))
1783 #define power_all_disable() (PRR |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTWI)))
1787 #define power_all_enable() (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRTWI)))
1788 #define power_all_disable() (PRR |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRTWI)))
1792 #elif defined(__AVR_ATtiny24__) \
1793 || defined(__AVR_ATtiny24A__) \
1794 || defined(__AVR_ATtiny44__) \
1795 || defined(__AVR_ATtiny44A__) \
1796 || defined(__AVR_ATtiny84__) \
1797 || defined(__AVR_ATtiny84A__) \
1798 || defined(__AVR_ATtiny25__) \
1799 || defined(__AVR_ATtiny45__) \
1800 || defined(__AVR_ATtiny85__) \
1801 || defined(__AVR_ATtiny261__) \
1802 || defined(__AVR_ATtiny261A__) \
1803 || defined(__AVR_ATtiny461__) \
1804 || defined(__AVR_ATtiny461A__) \
1805 || defined(__AVR_ATtiny861__) \
1806 || defined(__AVR_ATtiny861A__) \
1807 || defined(__AVR_ATtiny43U__)
1809 #define power_adc_enable() (PRR &= (uint8_t)~(1 << PRADC))
1810 #define power_adc_disable() (PRR |= (uint8_t)(1 << PRADC))
1812 #define power_timer0_enable() (PRR &= (uint8_t)~(1 << PRTIM0))
1813 #define power_timer0_disable() (PRR |= (uint8_t)(1 << PRTIM0))
1815 #define power_timer1_enable() (PRR &= (uint8_t)~(1 << PRTIM1))
1816 #define power_timer1_disable() (PRR |= (uint8_t)(1 << PRTIM1))
1819 #define power_usi_enable() (PRR &= (uint8_t)~(1 << PRUSI))
1820 #define power_usi_disable() (PRR |= (uint8_t)(1 << PRUSI))
1822 #define power_all_enable() (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRUSI)))
1823 #define power_all_disable() (PRR |= (uint8_t)((1<<PRADC)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRUSI)))
1825 #elif defined(__AVR_ATmega1284__)
1827 #define power_adc_enable() (PRR0 &= (uint8_t)~(1 << PRADC))
1828 #define power_adc_disable() (PRR0 |= (uint8_t)(1 << PRADC))
1830 #define power_spi_enable() (PRR0 &= (uint8_t)~(1 << PRSPI))
1831 #define power_spi_disable() (PRR0 |= (uint8_t)(1 << PRSPI))
1833 #define power_twi_enable() (PRR0 &= (uint8_t)~(1 << PRTWI))
1834 #define power_twi_disable() (PRR0 |= (uint8_t)(1 << PRTWI))
1836 #define power_timer0_enable() (PRR0 &= (uint8_t)~(1 << PRTIM0))
1837 #define power_timer0_disable() (PRR0 |= (uint8_t)(1 << PRTIM0))
1839 #define power_timer1_enable() (PRR0 &= (uint8_t)~(1 << PRTIM1))
1840 #define power_timer1_disable() (PRR0 |= (uint8_t)(1 << PRTIM1))
1842 #define power_timer2_enable() (PRR0 &= (uint8_t)~(1 << PRTIM2))
1843 #define power_timer2_disable() (PRR0 |= (uint8_t)(1 << PRTIM2))
1845 #define power_timer3_enable() (PRR1 &= (uint8_t)~(1 << PRTIM3))
1846 #define power_timer3_disable() (PRR1 |= (uint8_t)(1 << PRTIM3))
1848 #define power_usart0_enable() (PRR0 &= (uint8_t)~(1 << PRUSART0))
1849 #define power_usart0_disable() (PRR0 |= (uint8_t)(1 << PRUSART0))
1851 #define power_all_enable() \
1853 PRR0 &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRUSART0)); \
1854 PRR1 &= (uint8_t)~(1<<PRTIM3); \
1857 #define power_all_disable() \
1859 PRR0 |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRUSART0)); \
1860 PRR1 |= (uint8_t)(1<<PRTIM3); \
1863 #elif defined(__AVR_ATmega1284P__)
1866 #define power_adc_enable() (PRR0 &= (uint8_t)~(1 << PRADC))
1867 #define power_adc_disable() (PRR0 |= (uint8_t)(1 << PRADC))
1869 #define power_spi_enable() (PRR0 &= (uint8_t)~(1 << PRSPI))
1870 #define power_spi_disable() (PRR0 |= (uint8_t)(1 << PRSPI))
1872 #define power_twi_enable() (PRR0 &= (uint8_t)~(1 << PRTWI))
1873 #define power_twi_disable() (PRR0 |= (uint8_t)(1 << PRTWI))
1875 #define power_timer0_enable() (PRR0 &= (uint8_t)~(1 << PRTIM0))
1876 #define power_timer0_disable() (PRR0 |= (uint8_t)(1 << PRTIM0))
1878 #define power_timer1_enable() (PRR0 &= (uint8_t)~(1 << PRTIM1))
1879 #define power_timer1_disable() (PRR0 |= (uint8_t)(1 << PRTIM1))
1881 #define power_timer2_enable() (PRR0 &= (uint8_t)~(1 << PRTIM2))
1882 #define power_timer2_disable() (PRR0 |= (uint8_t)(1 << PRTIM2))
1884 #define power_timer3_enable() (PRR1 &= (uint8_t)~(1 << PRTIM3))
1885 #define power_timer3_disable() (PRR1 |= (uint8_t)(1 << PRTIM3))
1887 #define power_usart0_enable() (PRR0 &= (uint8_t)~(1 << PRUSART0))
1888 #define power_usart0_disable() (PRR0 |= (uint8_t)(1 << PRUSART0))
1890 #define power_usart1_enable() (PRR0 &= (uint8_t)~(1 << PRUSART1))
1891 #define power_usart1_disable() (PRR0 |= (uint8_t)(1 << PRUSART1))
1893 #define power_all_enable() \
1895 PRR0 &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRUSART0)|(1<<PRUSART1)); \
1896 PRR1 &= (uint8_t)~(1<<PRTIM3); \
1899 #define power_all_disable() \
1901 PRR0 |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRUSART0)|(1<<PRUSART1)); \
1902 PRR1 |= (uint8_t)(1<<PRTIM3); \
1906 #elif defined(__AVR_ATmega32HVB__) \
1907 || defined(__AVR_ATmega32HVBREVB__) \
1908 || defined(__AVR_ATmega16HVB__) \
1909 || defined(__AVR_ATmega16HVBREVB__)
1912 #define power_twi_enable() (PRR0 &= (uint8_t)~(1 << PRTWI))
1913 #define power_twi_disable() (PRR0 |= (uint8_t)(1 << PRTWI))
1915 #define power_timer0_enable() (PRR0 &= (uint8_t)~(1 << PRTIM0))
1916 #define power_timer0_disable() (PRR0 |= (uint8_t)(1 << PRTIM0))
1918 #define power_timer1_enable() (PRR0 &= (uint8_t)~(1 << PRTIM1))
1919 #define power_timer1_disable() (PRR0 |= (uint8_t)(1 << PRTIM1))
1922 #define power_vadc_enable() (PRR0 &= (uint8_t)~(1 << PRVADC))
1923 #define power_vadc_disable() (PRR0 |= (uint8_t)(1 << PRVADC))
1925 #define power_spi_enable() (PRR0 &= (uint8_t)~(1 << PRSPI))
1926 #define power_spi_disable() (PRR0 |= (uint8_t)(1 << PRSPI))
1928 #define power_vrm_enable() (PRR0 &= (uint8_t)~(1 << PRVRM))
1929 #define power_vrm_disable() (PRR0 |= (uint8_t)(1 << PRVRM))
1931 #define power_all_enable() (PRR0 &= (uint8_t)~((1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRVADC)|(1<<PRSPI)|(1<<PRVRM)))
1932 #define power_all_disable() (PRR0 |= (uint8_t)((1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRVADC)|(1<<PRSPI)|(1<<PRVRM)))
1935 #elif defined (__AVR_ATA5790__) \
1936 || defined (__AVR_ATA5795__)
1939 #define power_vmonitor_enable() (PRR0 &= (uint8_t)~(1 << PRVM))
1940 #define power_vmonitor_disable() (PRR0 |= (uint8_t)(1 << PRVM))
1942 #define power_irdriver_enable() (PRR0 &= (uint8_t)~(1 << PRDS))
1943 #define power_irdriver_disable() (PRR0 |= (uint8_t)(1 << PRDS))
1945 #define power_crypto_enable() (PRR0 &= (uint8_t)~(1 << PRCU))
1946 #define power_crypto_disable() (PRR0 |= (uint8_t)(1 << PRCU))
1948 #define power_timermodulator_enable() (PRR0 &= (uint8_t)~(1 << PRTM))
1949 #define power_timermodulator_disable() (PRR0 |= (uint8_t)(1 << PRTM))
1951 #define power_timer1_enable() (PRR0 &= (uint8_t)~(1 << PRT1))
1952 #define power_timer1_disable() (PRR0 |= (uint8_t)(1 << PRT1))
1954 #define power_timer2_enable() (PRR0 &= (uint8_t)~(1 << PRT2))
1955 #define power_timer2_disable() (PRR0 |= (uint8_t)(1 << PRT2))
1957 #define power_timer3_enable() (PRR0 &= (uint8_t)~(1 << PRT3))
1958 #define power_timer3_disable() (PRR0 |= (uint8_t)(1 << PRT3))
1960 #define power_spi_enable() (PRR1 &= (uint8_t)~(1 << PRSPI))
1961 #define power_spi_disable() (PRR1 |= (uint8_t)(1 << PRSPI))
1963 #define power_cinterface_enable() (PRR1 &= (uint8_t)~(1 << PRCI))
1964 #define power_cinterface_disable() (PRR1 |= (uint8_t)(1 << PRCI))
1966 #if defined(__AVR_ATA5790__)
1968 #define power_lfreceiver_enable() (PRR0 &= (uint8_t)~(1 << PRLFR))
1969 #define power_lfreceiver_disable() (PRR0 |= (uint8_t)(1 << PRLFR))
1971 #define power_all_enable() \
1973 PRR0 &= (uint8_t)~((1<<PRVM)|(1<<PRDS)|(1<<PRCU)|(1<<PRTM)|(1<<PRT3)|(1<<PRT2)|(1<<PRT1)|(1<<PRLFR)); \
1974 PRR1 &= (uint8_t)~((1<<PRSPI)|(1<<PRCI)); \
1977 #define power_all_disable() \
1979 PRR0 |= (uint8_t)((1<<PRVM)|(1<<PRDS)|(1<<PRCU)|(1<<PRTM)|(1<<PRT3)|(1<<PRT2)|(1<<PRT1)|(1<<PRLFR)); \
1980 PRR1 |= (uint8_t)((1<<PRSPI)|(1<<PRCI)); \
1983 #elif defined(__AVR_ATA5795__)
1985 #define power_all_enable() \
1987 PRR0 &= (uint8_t)~((1<<PRVM)|(1<<PRDS)|(1<<PRCU)|(1<<PRTM)|(1<<PRT3)|(1<<PRT2)|(1<<PRT1)); \
1988 PRR1 &= (uint8_t)~((1<<PRSPI)|(1<<PRCI)); \
1991 #define power_all_disable() \
1993 PRR0 |= (uint8_t)((1<<PRVM)|(1<<PRDS)|(1<<PRCU)|(1<<PRTM)|(1<<PRT3)|(1<<PRT2)|(1<<PRT1)); \
1994 PRR1 |= (uint8_t)((1<<PRSPI)|(1<<PRCI)); \
1999 #elif defined(__AVR_ATmega16M1__) \
2000 || defined(__AVR_ATmega32C1__) \
2001 || defined(__AVR_ATmega32M1__) \
2002 || defined(__AVR_ATmega64C1__) \
2003 || defined(__AVR_ATmega64M1__)
2005 #define power_adc_enable() (PRR &= (uint8_t)~(1 << PRADC))
2006 #define power_adc_disable() (PRR |= (uint8_t)(1 << PRADC))
2008 #define power_lin_enable() (PRR &= (uint8_t)~(1 << PRLIN))
2009 #define power_lin_disable() (PRR |= (uint8_t)(1 << PRLIN))
2011 #define power_spi_enable() (PRR &= (uint8_t)~(1 << PRSPI))
2012 #define power_spi_disable() (PRR |= (uint8_t)(1 << PRSPI))
2014 #define power_timer0_enable() (PRR &= (uint8_t)~(1 << PRTIM0))
2015 #define power_timer0_disable() (PRR |= (uint8_t)(1 << PRTIM0))
2017 #define power_timer1_enable() (PRR &= (uint8_t)~(1 << PRTIM1))
2018 #define power_timer1_disable() (PRR |= (uint8_t)(1 << PRTIM1))
2020 #define power_psc_enable() (PRR &= (uint8_t)~(1 << PRPSC))
2021 #define power_psc_disable() (PRR |= (uint8_t)(1 << PRPSC))
2023 #define power_can_enable() (PRR &= (uint8_t)~(1 << PRCAN))
2024 #define power_can_disable() (PRR |= (uint8_t)(1 << PRCAN))
2026 #define power_all_enable() (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRLIN)|(1<<PRSPI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRPSC)|(1<<PRCAN)))
2027 #define power_all_disable() (PRR |= (uint8_t)((1<<PRADC)|(1<<PRLIN)|(1<<PRSPI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRPSC)|(1<<PRCAN)))
2030 #elif defined(__AVR_ATtiny167__) \
2031 || defined(__AVR_ATtiny87__) \
2032 || defined(__AVR_ATA5505__) \
2033 || defined(__AVR_ATA5272__)
2035 #define power_adc_enable() (PRR &= (uint8_t)~(1 << PRADC))
2036 #define power_adc_disable() (PRR |= (uint8_t)(1 << PRADC))
2038 #define power_usi_enable() (PRR &= (uint8_t)~(1 << PRUSI))
2039 #define power_usi_disable() (PRR |= (uint8_t)(1 << PRUSI))
2041 #define power_timer0_enable() (PRR &= (uint8_t)~(1 << PRTIM0))
2042 #define power_timer0_disable() (PRR |= (uint8_t)(1 << PRTIM0))
2044 #define power_timer1_enable() (PRR &= (uint8_t)~(1 << PRTIM1))
2045 #define power_timer1_disable() (PRR |= (uint8_t)(1 << PRTIM1))
2047 #define power_spi_enable() (PRR &= (uint8_t)~(1 << PRSPI))
2048 #define power_spi_disable() (PRR |= (uint8_t)(1 << PRSPI))
2050 #define power_lin_enable() (PRR &= (uint8_t)~(1 << PRLIN))
2051 #define power_lin_disable() (PRR |= (uint8_t)(1 << PRLIN))
2053 #define power_all_enable() (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRUSI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRSPI)|(1<<PRLIN)))
2054 #define power_all_disable() (PRR |= (uint8_t)((1<<PRADC)|(1<<PRUSI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRSPI)|(1<<PRLIN)))
2057 #elif defined(__AVR_ATtiny1634__)
2059 #define power_adc_enable() (PRR &= (uint8_t)~(1 << PRADC))
2060 #define power_adc_disable() (PRR |= (uint8_t)(1 << PRADC))
2062 #define power_usart0_enable() (PRR &= (uint8_t)~(1 << PRUSART0))
2063 #define power_usart0_disable() (PRR |= (uint8_t)(1 << PRUSART0))
2065 #define power_usart1_enable() (PRR &= (uint8_t)~(1 << PRUSART1))
2066 #define power_usart1_disable() (PRR |= (uint8_t)(1 << PRUSART1))
2068 #define power_usi_enable() (PRR &= (uint8_t)~(1 << PRUSI))
2069 #define power_usi_disable() (PRR |= (uint8_t)(1 << PRUSI))
2071 #define power_timer0_enable() (PRR &= (uint8_t)~(1 << PRTIM0))
2072 #define power_timer0_disable() (PRR |= (uint8_t)(1 << PRTIM0))
2074 #define power_timer1_enable() (PRR &= (uint8_t)~(1 << PRTIM1))
2075 #define power_timer1_disable() (PRR |= (uint8_t)(1 << PRTIM1))
2077 #define power_twi_enable() (PRR &= (uint8_t)~(1 << PRTWI))
2078 #define power_twi_disable() (PRR |= (uint8_t)(1 << PRTWI))
2080 #define power_all_enable() (PRR &= (uint8_t)~((1 << PRTWI)|(1 << PRUSI)|(1 << PRTIM0)|(1 << PRTIM1)|(1 << PRUSART0)|(1 << PRUSART1)|(1 << PRADC)))
2081 #define power_all_disable() (PRR |= (uint8_t)((1 << PRTWI)|(1 << PRUSI)|(1 << PRTIM0)|(1 << PRTIM1)|(1 << PRUSART0)|(1 << PRUSART1)|(1 << PRADC)))
2084 #elif defined(__AVR_AT90USB82__) \
2085 || defined(__AVR_AT90USB162__) \
2086 || defined(__AVR_ATmega8U2__) \
2087 || defined(__AVR_ATmega16U2__) \
2088 || defined(__AVR_ATmega32U2__)
2090 #define power_spi_enable() (PRR0 &= (uint8_t)~(1 << PRSPI))
2091 #define power_spi_disable() (PRR0 |= (uint8_t)(1 << PRSPI))
2093 #define power_timer0_enable() (PRR0 &= (uint8_t)~(1 << PRTIM0))
2094 #define power_timer0_disable() (PRR0 |= (uint8_t)(1 << PRTIM0))
2096 #define power_timer1_enable() (PRR0 &= (uint8_t)~(1 << PRTIM1))
2097 #define power_timer1_disable() (PRR0 |= (uint8_t)(1 << PRTIM1))
2099 #define power_usb_enable() (PRR1 &= (uint8_t)~(1 << PRUSB))
2100 #define power_usb_disable() (PRR1 |= (uint8_t)(1 << PRUSB))
2102 #define power_usart1_enable() (PRR1 &= (uint8_t)~(1 << PRUSART1))
2103 #define power_usart1_disable() (PRR1 |= (uint8_t)(1 << PRUSART1))
2105 #define power_all_enable() \
2107 PRR0 &= (uint8_t)~((1<<PRSPI)|(1<<PRTIM0)|(1<<PRTIM1)); \
2108 PRR1 &= (uint8_t)~((1<<PRUSB)|(1<<PRUSART1)); \
2111 #define power_all_disable() \
2113 PRR0 |= (uint8_t)((1<<PRSPI)|(1<<PRTIM0)|(1<<PRTIM1)); \
2114 PRR1 |= (uint8_t)((1<<PRUSB)|(1<<PRUSART1)); \
2118 #elif defined(__AVR_AT90SCR100__)
2120 #define power_usart0_enable() (PRR0 &= (uint8_t)~(1 << PRUSART0))
2121 #define power_usart0_disable() (PRR0 |= (uint8_t)(1 << PRUSART0))
2123 #define power_spi_enable() (PRR0 &= (uint8_t)~(1 << PRSPI))
2124 #define power_spi_disable() (PRR0 |= (uint8_t)(1 << PRSPI))
2126 #define power_timer1_enable() (PRR0 &= (uint8_t)~(1 << PRTIM1))
2127 #define power_timer1_disable() (PRR0 |= (uint8_t)(1 << PRTIM1))
2129 #define power_timer0_enable() (PRR0 &= (uint8_t)~(1 << PRTIM0))
2130 #define power_timer0_disable() (PRR0 |= (uint8_t)(1 << PRTIM0))
2132 #define power_timer2_enable() (PRR0 &= (uint8_t)~(1 << PRTIM2))
2133 #define power_timer2_disable() (PRR0 |= (uint8_t)(1 << PRTIM2))
2135 #define power_twi_enable() (PRR0 &= (uint8_t)~(1 << PRTWI))
2136 #define power_twi_disable() (PRR0 |= (uint8_t)(1 << PRTWI))
2138 #define power_usbh_enable() (PRR1 &= (uint8_t)~(1 << PRUSBH))
2139 #define power_usbh_disable() (PRR1 |= (uint8_t)(1 << PRUSBH))
2141 #define power_usb_enable() (PRR1 &= (uint8_t)~(1 << PRUSB))
2142 #define power_usb_disable() (PRR1 |= (uint8_t)(1 << PRUSB))
2144 #define power_hsspi_enable() (PRR1 &= (uint8_t)~(1 << PRHSSPI))
2145 #define power_hsspi_disable() (PRR1 |= (uint8_t)(1 << PRHSSPI))
2147 #define power_sci_enable() (PRR1 &= (uint8_t)~(1 << PRSCI))
2148 #define power_sci_disable() (PRR1 |= (uint8_t)(1 << PRSCI))
2150 #define power_aes_enable() (PRR1 &= (uint8_t)~(1 << PRAES))
2151 #define power_aes_disable() (PRR1 |= (uint8_t)(1 << PRAES))
2153 #define power_kb_enable() (PRR1 &= (uint8_t)~(1 << PRKB))
2154 #define power_kb_disable() (PRR1 |= (uint8_t)(1 << PRKB))
2156 #define power_all_enable() \
2158 PRR0 &= (uint8_t)~((1<<PRUSART0)|(1<<PRSPI)|(1<<PRTIM1)|(1<<PRTIM0)|(1<<PRTIM2)|(1<<PRTWI)); \
2159 PRR1 &= (uint8_t)~((1<<PRUSBH)|(1<<PRUSB)|(1<<PRHSSPI)|(1<<PRSCI)|(1<<PRAES)|(1<<PRKB)); \
2162 #define power_all_disable() \
2164 PRR0 |= (uint8_t)((1<<PRUSART0)|(1<<PRSPI)|(1<<PRTIM1)|(1<<PRTIM0)|(1<<PRTIM2)|(1<<PRTWI)); \
2165 PRR1 |= (uint8_t)((1<<PRUSBH)|(1<<PRUSB)|(1<<PRHSSPI)|(1<<PRSCI)|(1<<PRAES)|(1<<PRKB)); \
2169 #elif defined(__AVR_ATtiny4__) \
2170 || defined(__AVR_ATtiny5__) \
2171 || defined(__AVR_ATtiny9__) \
2172 || defined(__AVR_ATtiny10__) \
2173 || defined(__AVR_ATtiny13A__) \
2175 #define power_adc_enable() (PRR &= (uint8_t)~(1 << PRADC))
2176 #define power_adc_disable() (PRR |= (uint8_t)(1 << PRADC))
2178 #define power_timer0_enable() (PRR &= (uint8_t)~(1 << PRTIM0))
2179 #define power_timer0_disable() (PRR |= (uint8_t)(1 << PRTIM0))
2181 #define power_all_enable() (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRTIM0)))
2182 #define power_all_disable() (PRR |= (uint8_t)((1<<PRADC)|(1<<PRTIM0)))
2185 #elif defined(__AVR_ATtiny20__) \
2186 || defined(__AVR_ATtiny40__)
2188 #define power_adc_enable() (PRR &= (uint8_t)~(1 << PRADC))
2189 #define power_adc_disable() (PRR |= (uint8_t)(1 << PRADC))
2191 #define power_timer0_enable() (PRR &= (uint8_t)~(1 << PRTIM0))
2192 #define power_timer0_disable() (PRR |= (uint8_t)(1 << PRTIM0))
2194 #define power_timer1_enable() (PRR &= (uint8_t)~(1 << PRTIM1))
2195 #define power_timer1_disable() (PRR |= (uint8_t)(1 << PRTIM1))
2197 #define power_spi_enable() (PRR &= (uint8_t)~(1 << PRSPI))
2198 #define power_spi_disable() (PRR |= (uint8_t)(1 << PRSPI))
2200 #define power_twi_enable() (PRR &= (uint8_t)~(1 << PRTWI))
2201 #define power_twi_disable() (PRR |= (uint8_t)(1 << PRTWI))
2203 #define power_all_enable() (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRSPI)|(1<<PRTWI)))
2204 #define power_all_disable() (PRR |= (uint8_t)((1<<PRADC)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRSPI)|(1<<PRTWI)))
2209 #if defined(__AVR_AT90CAN32__) \
2210 || defined(__AVR_AT90CAN64__) \
2211 || defined(__AVR_AT90CAN128__) \
2212 || defined(__AVR_AT90PWM1__) \
2213 || defined(__AVR_AT90PWM2__) \
2214 || defined(__AVR_AT90PWM2B__) \
2215 || defined(__AVR_AT90PWM3__) \
2216 || defined(__AVR_AT90PWM3B__) \
2217 || defined(__AVR_AT90PWM81__) \
2218 || defined(__AVR_AT90PWM161__) \
2219 || defined(__AVR_AT90PWM216__) \
2220 || defined(__AVR_AT90PWM316__) \
2221 || defined(__AVR_AT90SCR100__) \
2222 || defined(__AVR_AT90USB646__) \
2223 || defined(__AVR_AT90USB647__) \
2224 || defined(__AVR_AT90USB82__) \
2225 || defined(__AVR_AT90USB1286__) \
2226 || defined(__AVR_AT90USB1287__) \
2227 || defined(__AVR_AT90USB162__) \
2228 || defined(__AVR_ATA5505__) \
2229 || defined(__AVR_ATA5272__) \
2230 || defined(__AVR_ATmega1280__) \
2231 || defined(__AVR_ATmega1281__) \
2232 || defined(__AVR_ATmega1284__) \
2233 || defined(__AVR_ATmega128RFA1__) \
2234 || defined(__AVR_ATmega1284RFR2__) \
2235 || defined(__AVR_ATmega128RFR2__) \
2236 || defined(__AVR_ATmega1284P__) \
2237 || defined(__AVR_ATmega162__) \
2238 || defined(__AVR_ATmega164A__) \
2239 || defined(__AVR_ATmega164P__) \
2240 || defined(__AVR_ATmega164PA__) \
2241 || defined(__AVR_ATmega165__) \
2242 || defined(__AVR_ATmega165A__) \
2243 || defined(__AVR_ATmega165P__) \
2244 || defined(__AVR_ATmega165PA__) \
2245 || defined(__AVR_ATmega168__) \
2246 || defined(__AVR_ATmega168P__) \
2247 || defined(__AVR_ATmega168PA__) \
2248 || defined(__AVR_ATmega169__) \
2249 || defined(__AVR_ATmega169A__) \
2250 || defined(__AVR_ATmega169P__) \
2251 || defined(__AVR_ATmega169PA__) \
2252 || defined(__AVR_ATmega16U4__) \
2253 || defined(__AVR_ATmega2560__) \
2254 || defined(__AVR_ATmega2561__) \
2255 || defined(__AVR_ATmega2564RFR2__) \
2256 || defined(__AVR_ATmega256RFR2__) \
2257 || defined(__AVR_ATmega324A__) \
2258 || defined(__AVR_ATmega324P__) \
2259 || defined(__AVR_ATmega325__) \
2260 || defined(__AVR_ATmega325A__) \
2261 || defined(__AVR_ATmega325PA__) \
2262 || defined(__AVR_ATmega3250__) \
2263 || defined(__AVR_ATmega3250A__) \
2264 || defined(__AVR_ATmega3250PA__) \
2265 || defined(__AVR_ATmega328__) \
2266 || defined(__AVR_ATmega328P__) \
2267 || defined(__AVR_ATmega329__) \
2268 || defined(__AVR_ATmega329A__) \
2269 || defined(__AVR_ATmega329P__) \
2270 || defined(__AVR_ATmega329PA__) \
2271 || defined(__AVR_ATmega3290__) \
2272 || defined(__AVR_ATmega3290A__) \
2273 || defined(__AVR_ATmega3290PA__) \
2274 || defined(__AVR_ATmega32C1__) \
2275 || defined(__AVR_ATmega32M1__) \
2276 || defined(__AVR_ATmega32U2__) \
2277 || defined(__AVR_ATmega32U4__) \
2278 || defined(__AVR_ATmega32U6__) \
2279 || defined(__AVR_ATmega48__) \
2280 || defined(__AVR_ATmega48A__) \
2281 || defined(__AVR_ATmega48PA__) \
2282 || defined(__AVR_ATmega48P__) \
2283 || defined(__AVR_ATmega640__) \
2284 || defined(__AVR_ATmega649P__) \
2285 || defined(__AVR_ATmega644__) \
2286 || defined(__AVR_ATmega644A__) \
2287 || defined(__AVR_ATmega644P__) \
2288 || defined(__AVR_ATmega644PA__) \
2289 || defined(__AVR_ATmega645__) \
2290 || defined(__AVR_ATmega645A__) \
2291 || defined(__AVR_ATmega645P__) \
2292 || defined(__AVR_ATmega6450__) \
2293 || defined(__AVR_ATmega6450A__) \
2294 || defined(__AVR_ATmega6450P__) \
2295 || defined(__AVR_ATmega649__) \
2296 || defined(__AVR_ATmega649A__) \
2297 || defined(__AVR_ATmega6490__) \
2298 || defined(__AVR_ATmega6490A__) \
2299 || defined(__AVR_ATmega6490P__) \
2300 || defined(__AVR_ATmega644RFR2__) \
2301 || defined(__AVR_ATmega64RFR2__) \
2302 || defined(__AVR_ATmega88__) \
2303 || defined(__AVR_ATmega88P__) \
2304 || defined(__AVR_ATmega8U2__) \
2305 || defined(__AVR_ATmega16U2__) \
2306 || defined(__AVR_ATmega32U2__) \
2307 || defined(__AVR_ATtiny48__) \
2308 || defined(__AVR_ATtiny167__) \
2309 || defined(__DOXYGEN__)
2376 #if defined(__AVR_ATmega128RFA1__) \
2377 || defined(__AVR_ATmega2564RFR2__) \
2378 || defined(__AVR_ATmega1284RFR2__) \
2379 || defined(__AVR_ATmega644RFR2__) \
2380 || defined(__AVR_ATmega256RFR2__) \
2381 || defined(__AVR_ATmega128RFR2__) \
2382 || defined(__AVR_ATmega64RFR2__)
2383 , clock_div_1_rc = 15
2388 static __inline__
void clock_prescale_set(clock_div_t) __attribute__((__always_inline__));
2402 void clock_prescale_set(clock_div_t __x)
2405 __asm__ __volatile__ (
2406 "in __tmp_reg__,__SREG__" "\n\t"
2410 "out __SREG__, __tmp_reg__"
2413 "M" (_SFR_MEM_ADDR(CLKPR)),
2427 #define clock_prescale_get() (clock_div_t)(CLKPR & (uint8_t)((1<<CLKPS0)|(1<<CLKPS1)|(1<<CLKPS2)|(1<<CLKPS3)))
2429 #elif defined(__AVR_ATmega16HVB__) \
2430 || defined(__AVR_ATmega16HVBREVB__) \
2431 || defined(__AVR_ATmega32HVB__) \
2432 || defined(__AVR_ATmega32HVBREVB__)
2442 static __inline__
void clock_prescale_set(clock_div_t) __attribute__((__always_inline__));
2444 void clock_prescale_set(clock_div_t __x)
2447 __asm__ __volatile__ (
2448 "in __tmp_reg__,__SREG__" "\n\t"
2452 "out __SREG__, __tmp_reg__"
2455 "M" (_SFR_MEM_ADDR(CLKPR)),
2460 #define clock_prescale_get() (clock_div_t)(CLKPR & (uint8_t)((1<<CLKPS0)|(1<<CLKPS1)))
2462 #elif defined(__AVR_ATA5790__) \
2463 || defined (__AVR_ATA5795__)
2477 static __inline__
void system_clock_prescale_set(clock_div_t) __attribute__((__always_inline__));
2479 void system_clock_prescale_set(clock_div_t __x)
2482 __asm__ __volatile__ (
2483 "in __tmp_reg__,__SREG__" "\n\t"
2487 "out __SREG__, __tmp_reg__"
2490 "I" (_SFR_IO_ADDR(CLKPR)),
2495 #define system_clock_prescale_get() (clock_div_t)(CLKPR & (uint8_t)((1<<CLKPS0)|(1<<CLKPS1)|(1<<CLKPS2)))
2499 timer_clock_div_reset = 0,
2500 timer_clock_div_1 = 1,
2501 timer_clock_div_2 = 2,
2502 timer_clock_div_4 = 3,
2503 timer_clock_div_8 = 4,
2504 timer_clock_div_16 = 5,
2505 timer_clock_div_32 = 6,
2506 timer_clock_div_64 = 7
2507 } timer_clock_div_t;
2509 static __inline__
void timer_clock_prescale_set(timer_clock_div_t) __attribute__((__always_inline__));
2511 void timer_clock_prescale_set(timer_clock_div_t __x)
2514 __asm__ __volatile__ (
2515 "in __tmp_reg__,__SREG__" "\n\t"
2517 "in %[temp],%[clkpr]" "\n\t"
2518 "out %[clkpr],%[enable]" "\n\t"
2519 "andi %[temp],%[not_CLTPS]" "\n\t"
2520 "or %[temp], %[set_value]" "\n\t"
2521 "out %[clkpr],%[temp]" "\n\t"
2523 "out __SREG__,__tmp_reg__" "\n\t"
2526 [clkpr]
"I" (_SFR_IO_ADDR(CLKPR)),
2527 [enable]
"r" (
_BV(CLKPCE)),
2528 [not_CLTPS]
"M" (0xFF & (~ ((1 << CLTPS2) | (1 << CLTPS1) | (1 << CLTPS0)))),
2529 [set_value]
"r" ((__x & 7) << 3)
2533 #define timer_clock_prescale_get() (timer_clock_div_t)(CLKPR & (uint8_t)((1<<CLTPS0)|(1<<CLTPS1)|(1<<CLTPS2)))
2535 #elif defined(__AVR_ATA6285__) \
2536 || defined(__AVR_ATA6286__)
2550 static __inline__
void system_clock_prescale_set(clock_div_t) __attribute__((__always_inline__));
2552 void system_clock_prescale_set(clock_div_t __x)
2555 __asm__ __volatile__ (
2556 "in __tmp_reg__,__SREG__" "\n\t"
2558 "in %[temp],%[clpr]" "\n\t"
2559 "out %[clpr],%[enable]" "\n\t"
2560 "andi %[temp],%[not_CLKPS]" "\n\t"
2561 "or %[temp], %[set_value]" "\n\t"
2562 "out %[clpr],%[temp]" "\n\t"
2564 "out __SREG__,__tmp_reg__" "\n\t"
2567 [clpr]
"I" (_SFR_IO_ADDR(CLKPR)),
2568 [enable]
"r" _BV(CLPCE),
2569 [not_CLKPS]
"M" (0xFF & (~ ((1 << CLKPS2) | (1 << CLKPS1) | (1 << CLKPS0)))),
2570 [set_value]
"r" (__x & 7)
2574 #define system_clock_prescale_get() (clock_div_t)(CLKPR & (uint8_t)((1<<CLKPS0)|(1<<CLKPS1)|(1<<CLKPS2)))
2578 timer_clock_div_reset = 0,
2579 timer_clock_div_1 = 1,
2580 timer_clock_div_2 = 2,
2581 timer_clock_div_4 = 3,
2582 timer_clock_div_8 = 4,
2583 timer_clock_div_16 = 5,
2584 timer_clock_div_32 = 6,
2585 timer_clock_div_64 = 7
2586 } timer_clock_div_t;
2588 static __inline__
void timer_clock_prescale_set(timer_clock_div_t) __attribute__((__always_inline__));
2590 void timer_clock_prescale_set(timer_clock_div_t __x)
2593 __asm__ __volatile__ (
2594 "in __tmp_reg__,__SREG__" "\n\t"
2596 "in %[temp],%[clpr]" "\n\t"
2597 "out %[clpr],%[enable]" "\n\t"
2598 "andi %[temp],%[not_CLTPS]" "\n\t"
2599 "or %[temp], %[set_value]" "\n\t"
2600 "out %[clpr],%[temp]" "\n\t"
2602 "out __SREG__,__tmp_reg__" "\n\t"
2605 [clpr]
"I" (_SFR_IO_ADDR(CLKPR)),
2606 [enable]
"r" (
_BV(CLPCE)),
2607 [not_CLTPS]
"M" (0xFF & (~ ((1 << CLTPS2) | (1 << CLTPS1) | (1 << CLTPS0)))),
2608 [set_value]
"r" ((__x & 7) << 3)
2612 #define timer_clock_prescale_get() (timer_clock_div_t)(CLKPR & (uint8_t)((1<<CLTPS0)|(1<<CLTPS1)|(1<<CLTPS2)))
2614 #elif defined(__AVR_ATtiny24__) \
2615 || defined(__AVR_ATtiny24A__) \
2616 || defined(__AVR_ATtiny44__) \
2617 || defined(__AVR_ATtiny44A__) \
2618 || defined(__AVR_ATtiny84__) \
2619 || defined(__AVR_ATtiny84A__) \
2620 || defined(__AVR_ATtiny25__) \
2621 || defined(__AVR_ATtiny45__) \
2622 || defined(__AVR_ATtiny85__) \
2623 || defined(__AVR_ATtiny261A__) \
2624 || defined(__AVR_ATtiny261__) \
2625 || defined(__AVR_ATtiny461__) \
2626 || defined(__AVR_ATtiny461A__) \
2627 || defined(__AVR_ATtiny861__) \
2628 || defined(__AVR_ATtiny861A__) \
2629 || defined(__AVR_ATtiny2313__) \
2630 || defined(__AVR_ATtiny2313A__) \
2631 || defined(__AVR_ATtiny4313__) \
2632 || defined(__AVR_ATtiny13__) \
2633 || defined(__AVR_ATtiny13A__) \
2634 || defined(__AVR_ATtiny43U__) \
2649 static __inline__
void clock_prescale_set(clock_div_t) __attribute__((__always_inline__));
2651 void clock_prescale_set(clock_div_t __x)
2654 __asm__ __volatile__ (
2655 "in __tmp_reg__,__SREG__" "\n\t"
2659 "out __SREG__, __tmp_reg__"
2662 "I" (_SFR_IO_ADDR(CLKPR)),
2668 #define clock_prescale_get() (clock_div_t)(CLKPR & (uint8_t)((1<<CLKPS0)|(1<<CLKPS1)|(1<<CLKPS2)|(1<<CLKPS3)))
2670 #elif defined(__AVR_ATmega64__) \
2671 || defined(__AVR_ATmega103__) \
2672 || defined(__AVR_ATmega128__)
2687 static __inline__
void clock_prescale_set(clock_div_t) __attribute__((__always_inline__));
2689 void clock_prescale_set(clock_div_t __x)
2691 if((__x <= 0) || (__x > 129))
2708 __asm__ __volatile__ (
2709 "in __tmp_reg__,__SREG__" "\n\t"
2711 "out %1, __zero_reg__" "\n\t"
2720 "cpi %0, 0x01" "\n\t"
2722 "ldi %2, 0x81" "\n\t"
2724 "ori %2, 0x80" "\n\t"
2734 "L_%=: " "out __SREG__, __tmp_reg__"
2737 "I" (_SFR_IO_ADDR(XDIV)),
2743 static __inline__ clock_div_t clock_prescale_get(
void) __attribute__((__always_inline__));
2745 clock_div_t clock_prescale_get(
void)
2753 return (clock_div_t)(129 - (XDIV & 0x7F));
2757 #elif defined(__AVR_ATtiny4__) \
2758 || defined(__AVR_ATtiny5__) \
2759 || defined(__AVR_ATtiny9__) \
2760 || defined(__AVR_ATtiny10__) \
2761 || defined(__AVR_ATtiny20__) \
2762 || defined(__AVR_ATtiny40__) \
2777 static __inline__
void clock_prescale_set(clock_div_t) __attribute__((__always_inline__));
2779 void clock_prescale_set(clock_div_t __x)
2782 __asm__ __volatile__ (
2783 "in __tmp_reg__,__SREG__" "\n\t"
2787 "out __SREG__, __tmp_reg__"
2790 "I" (_SFR_IO_ADDR(CCP)),
2791 "I" (_SFR_IO_ADDR(CLKPSR)),
2796 #define clock_prescale_get() (clock_div_t)(CLKPSR & (uint8_t)((1<<CLKPS0)|(1<<CLKPS1)|(1<<CLKPS2)|(1<<CLKPS3)))
#define bit_is_clear(sfr, bit)
Definition: sfr_defs.h:245
unsigned char uint8_t
Definition: stdint.h:80
#define _BV(bit)
Definition: sfr_defs.h:208