AVR Libc Home Page AVRs AVR Libc Development Pages
Main Page User Manual Reference FAQ Example Projects

xmega.h

01	1 Copyright (c) 2012 Joerg Wunsch
022All rights reserved. 033
044Redistribution and use in source and binary forms, with or without 055modification, are permitted provided that the following conditions are met: 066 077* Redistributions of source code must retain the above copyright 088notice, this list of conditions and the following disclaimer. 099 1010* Redistributions in binary form must reproduce the above copyright 1111notice, this list of conditions and the following disclaimer in 1212the documentation and/or other materials provided with the 1313distribution. 1414 1515* Neither the name of the copyright holders nor the names of 1616contributors may be used to endorse or promote products derived 1717from this software without specific prior written permission. 1818 1919THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 2020AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2121IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2222ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 2323LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2424CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2525SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2626INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2727CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2828ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 2929POSSIBILITY OF SUCH DAMAGE. */ 3030 3131/* $Id: xmega.h 2500 2016-02-05 06:01:20Z pitchumani $ */ 3232 3333/* 3434* This file is included by <avr/io.h> whenever compiling for an Xmega 3535* device. It abstracts certain features common to the Xmega device 3636* families. 3737*/ 3838 3939#ifndef _AVR_XMEGA_H 4040#define _AVR_XMEGA_H 4141 4242#ifdef __DOXYGEN__ 4343/** 4444\def _PROTECTED_WRITE 4545\ingroup avr_io 4646 4747Write value \c value to IO register \c reg that is protected through 4848the Xmega configuration change protection (CCP) mechanism. This 4949implements the timed sequence that is required for CCP. 5050 5151Example to modify the CPU clock: 5252\code 5353#include <avr/io.h> 5454 5555_PROTECTED_WRITE(CLK_PSCTRL, CLK_PSADIV0_bm); 5656_PROTECTED_WRITE(CLK_CTRL, CLK_SCLKSEL0_bm); 5757\endcode 5858*/ 59 59#define _PROTECTED_WRITE(reg, value) 6060#else /* !__DOXYGEN__ */ 6161#define _PROTECTED_WRITE(reg, value) \ 6262__asm__ __volatile__("out %[ccp], %[ccp_ioreg]" "\n\t" \ 6363"sts %[ioreg], %[val]" \ 6464: \ 6565: [ccp] "I" (_SFR_IO_ADDR(CCP)), \ 6666[ccp_ioreg] "d" ((uint8_t)CCP_IOREG_gc), \ 6767[ioreg] "n" (_SFR_MEM_ADDR(reg)), \ 6868[val] "r" ((uint8_t)value)) 6969#endif /* DOXYGEN */ 7070 7171#endif /* _AVR_XMEGA_H */