$treeview $search $mathjax $extrastylesheet
avr-libc  2.0.0
$projectbrief
$projectbrief
$searchbox

AVR Libc Home Page

AVRs

AVR Libc Development Pages

Main Page

User Manual

Library Reference

FAQ

Example Projects

<avr/io.h>: AVR device-specific IO definitions

Defines

#define _PROTECTED_WRITE(reg, value)
#define _PROTECTED_WRITE_SPM(reg, value)

Detailed Description

 #include <avr/io.h> 

This header file includes the apropriate IO definitions for the device that has been specified by the -mmcu= compiler command-line switch. This is done by diverting to the appropriate file <avr/ioXXXX.h> which should never be included directly. Some register names common to all AVR devices are defined directly within <avr/common.h>, which is included in <avr/io.h>, but most of the details come from the respective include file.

Note that this file always includes the following files:

    #include <avr/sfr_defs.h>
    #include <avr/portpins.h>
    #include <avr/common.h>
    #include <avr/version.h>

See <avr/sfr_defs.h>: Special function registers for more details about that header file.

Included are definitions of the IO register set and their respective bit values as specified in the Atmel documentation. Note that inconsistencies in naming conventions, so even identical functions sometimes get different names on different devices.

Also included are the specific names useable for interrupt function definitions as documented here.

Finally, the following macros are defined:


Define Documentation

#define _PROTECTED_WRITE ( reg,
value   ) 

Write value value to IO register reg that is protected through the Xmega configuration change protection (CCP) mechanism. This implements the timed sequence that is required for CCP.

Example to modify the CPU clock:

 #include <avr/io.h>

 _PROTECTED_WRITE(CLK_PSCTRL, CLK_PSADIV0_bm);
 _PROTECTED_WRITE(CLK_CTRL, CLK_SCLKSEL0_bm);
#define _PROTECTED_WRITE_SPM ( reg,
value   ) 

Write value value to register reg that is protected through the Xmega configuration change protection (CCP) key for self programming (SPM). This implements the timed sequence that is required for CCP.

Example to modify the CPU clock:

 #include <avr/io.h>

 _PROTECTED_WRITE_SPM(NVMCTRL_CTRLA, NVMCTRL_CMD_PAGEERASEWRITE_gc);
 All Data Structures Files Functions Variables Typedefs Enumerations Defines