avr_io(3)
β¨ avr_io β¨
okay bestie, welcome to avr_io β this is the manual page for avr-libc's big shiny IO header situation, and honestly? it's giving backstage-pass-to-the-whole-microcontroller π
πΈ SYNOPSIS πΈ
π Macros
#define _PROTECTED_WRITE(reg, value)
π DESCRIPTION π
π¦ Detailed Description
#include <avr/io.h>
so like. this header file pulls in the apropriate IO definitions for whatever device you told the compiler about with the -mmcu= compiler command-line switch. (yes, "apropriate" β that's the original spelling, we do not touch the spelling, it's part of the lore π«Ά)
how does it do that? it diverts to the matching file <avr/ioXXXX.h> β and listen, that file should never be included directly, okay? don't do it. no cap. π
some register names that are common to all AVR devices are defined right inside <avr/common.h>, which gets included by <avr/io.h>, but most of the juicy details come from the respective include file for your device.
heads up: this file always includes the following files, every single time:
#include <avr/sfr_defs.h>
#include <avr/portpins.h>
#include <avr/common.h>
#include <avr/version.h>
if you want more deets about that first one, go peek at <avr/sfr_defs.h>: Special function registers β it explains that header way better than I could rn.
included in all this are definitions of the IO register set and their respective bit values, exactly as specified in the Atmel documentation β¨ but note the inconsistencies in naming conventions β like, even identical functions sometimes get different names on different devices. it's a whole thing, we don't question it, we just vibe with it π
also included: the specific names you can use for interrupt function definitions, as documented over there in the docs.
and finally, the following macros are defined:
RAMENDβ the last on-chip RAM address πXRAMENDβ the last possible RAM location that is addressable. for devices that don't allow external RAM, this equalsRAMEND. for devices that do allow external RAM, this will be larger thanRAMEND.E2ENDβ the last EEPROM address πFLASHENDβ the last byte address in the Flash program space π₯SPM_PAGESIZEβ for devices with bootloader support, the flash pagesize (in bytes) to be used for theSPMinstruction.E2PAGESIZEβ the size of the EEPROM page.
π Macro Definition Documentation π
π #define _PROTECTED_WRITE(reg, value)
writes value value to IO register reg that is protected through the Xmega configuration change protection (CCP) mechanism. basically it implements the timed sequence that's required for CCP β the register is like "you can't just walk in here" and this macro is the bouncer with the clipboard π«Ά
here's the example to modify the CPU clock, straight up iconic:
#include <avr/io.h>
_PROTECTED_WRITE(CLK_PSCTRL, CLK_PSADIV0_bm);
_PROTECTED_WRITE(CLK_CTRL, CLK_SCLKSEL0_bm);
β Author β
Generated automatically by Doxygen for avr-libc from the source code. (the robots did this one, we simply say thank you π€π)
okay that's the whole page, ily, go write some embedded code π§β¨
Version 2.1.0 Β· Sat Jan 29 2022 Β· brought to you by the avr-libc girlies β mwah, catch you in the next manpage π ππΈ
π¦ where this page comes from
- fedora 43: avr-libc 2.2.1-3.fc43 Β· BSD-3-Clause
- fedora 44: avr-libc 2.2.1-5.fc44 Β· BSD-3-Clause
- opensuse-leap 16.0: avr-libc 2.1.0-bp160.1.33 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms