adds the avr library from the author

This commit is contained in:
ergz 2022-07-30 13:19:17 -07:00
parent f163f0eb02
commit 172b1b9b2a
10 changed files with 1121 additions and 0 deletions

2
AVR-Programming-Library/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
binaryMacroDemo.c

View File

@ -0,0 +1,196 @@
##########------------------------------------------------------##########
########## Project-specific Details ##########
########## Check these every time you start a new project ##########
##########------------------------------------------------------##########
MCU = atmega168p
F_CPU = 1000000UL
BAUD = 9600UL
## Also try BAUD = 19200 or 38400 if you're feeling lucky.
## A directory for common include files and the simple USART library.
## If you move either the current folder or the Library folder, you'll
## need to change this path to match.
LIBDIR = ../../AVR-Programming-Library
##########------------------------------------------------------##########
########## Programmer Defaults ##########
########## Set up once, then forget about it ##########
########## (Can override. See bottom of file.) ##########
##########------------------------------------------------------##########
PROGRAMMER_TYPE = usbtiny
# extra arguments to avrdude: baud rate, chip type, -F flag, etc.
PROGRAMMER_ARGS =
##########------------------------------------------------------##########
########## Program Locations ##########
########## Won't need to change if they're in your PATH ##########
##########------------------------------------------------------##########
CC = avr-gcc
OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump
AVRSIZE = avr-size
AVRDUDE = avrdude
##########------------------------------------------------------##########
########## Makefile Magic! ##########
########## Summary: ##########
########## We want a .hex file ##########
########## Compile source files into .elf ##########
########## Convert .elf file into .hex ##########
########## You shouldn't need to edit below. ##########
##########------------------------------------------------------##########
## The name of your project (without the .c)
# TARGET = blinkLED
## Or name it automatically after the enclosing directory
TARGET = $(lastword $(subst /, ,$(CURDIR)))
# Object files: will find all .c/.h files in current directory
# and in LIBDIR. If you have any other (sub-)directories with code,
# you can add them in to SOURCES below in the wildcard statement.
SOURCES=$(wildcard *.c $(LIBDIR)/*.c)
OBJECTS=$(SOURCES:.c=.o)
HEADERS=$(SOURCES:.c=.h)
## Compilation options, type man avr-gcc if you're curious.
CPPFLAGS = -DF_CPU=$(F_CPU) -DBAUD=$(BAUD) -I. -I$(LIBDIR)
CFLAGS = -Os -g -std=gnu99 -Wall
## Use short (8-bit) data types
CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
## Splits up object files per function
CFLAGS += -ffunction-sections -fdata-sections
LDFLAGS = -Wl,-Map,$(TARGET).map
## Optional, but often ends up with smaller code
LDFLAGS += -Wl,--gc-sections
## Relax shrinks code even more, but makes disassembly messy
## LDFLAGS += -Wl,--relax
## LDFLAGS += -Wl,-u,vfprintf -lprintf_flt -lm ## for floating-point printf
## LDFLAGS += -Wl,-u,vfprintf -lprintf_min ## for smaller printf
TARGET_ARCH = -mmcu=$(MCU)
## Explicit pattern rules:
## To make .o files from .c files
%.o: %.c $(HEADERS) Makefile
$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c -o $@ $<;
$(TARGET).elf: $(OBJECTS)
$(CC) $(LDFLAGS) $(TARGET_ARCH) $^ $(LDLIBS) -o $@
%.hex: %.elf
$(OBJCOPY) -j .text -j .data -O ihex $< $@
%.eeprom: %.elf
$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@
%.lst: %.elf
$(OBJDUMP) -S $< > $@
## These targets don't have files named after them
.PHONY: all disassemble disasm eeprom size clean squeaky_clean flash fuses
all: $(TARGET).hex
debug:
@echo
@echo "Source files:" $(SOURCES)
@echo "MCU, F_CPU, BAUD:" $(MCU), $(F_CPU), $(BAUD)
@echo
# Optionally create listing file from .elf
# This creates approximate assembly-language equivalent of your code.
# Useful for debugging time-sensitive bits,
# or making sure the compiler does what you want.
disassemble: $(TARGET).lst
disasm: disassemble
# Optionally show how big the resulting program is
size: $(TARGET).elf
$(AVRSIZE) -C --mcu=$(MCU) $(TARGET).elf
clean:
rm -f $(TARGET).elf $(TARGET).hex $(TARGET).obj \
$(TARGET).o $(TARGET).d $(TARGET).eep $(TARGET).lst \
$(TARGET).lss $(TARGET).sym $(TARGET).map $(TARGET)~ \
$(TARGET).eeprom
squeaky_clean:
rm -f *.elf *.hex *.obj *.o *.d *.eep *.lst *.lss *.sym *.map *~ *.eeprom
##########------------------------------------------------------##########
########## Programmer-specific details ##########
########## Flashing code to AVR using avrdude ##########
##########------------------------------------------------------##########
flash: $(TARGET).hex
$(AVRDUDE) -c $(PROGRAMMER_TYPE) -p $(MCU) $(PROGRAMMER_ARGS) -U flash:w:$<
## An alias
program: flash
flash_eeprom: $(TARGET).eeprom
$(AVRDUDE) -c $(PROGRAMMER_TYPE) -p $(MCU) $(PROGRAMMER_ARGS) -U eeprom:w:$<
avrdude_terminal:
$(AVRDUDE) -c $(PROGRAMMER_TYPE) -p $(MCU) $(PROGRAMMER_ARGS) -nt
## If you've got multiple programmers that you use,
## you can define them here so that it's easy to switch.
## To invoke, use something like `make flash_arduinoISP`
flash_usbtiny: PROGRAMMER_TYPE = usbtiny
flash_usbtiny: PROGRAMMER_ARGS = # USBTiny works with no further arguments
flash_usbtiny: flash
flash_usbasp: PROGRAMMER_TYPE = usbasp
flash_usbasp: PROGRAMMER_ARGS = # USBasp works with no further arguments
flash_usbasp: flash
flash_arduinoISP: PROGRAMMER_TYPE = avrisp
flash_arduinoISP: PROGRAMMER_ARGS = -b 19200 -P /dev/ttyACM0
## (for windows) flash_arduinoISP: PROGRAMMER_ARGS = -b 19200 -P com5
flash_arduinoISP: flash
flash_109: PROGRAMMER_TYPE = avr109
flash_109: PROGRAMMER_ARGS = -b 9600 -P /dev/ttyUSB0
flash_109: flash
##########------------------------------------------------------##########
########## Fuse settings and suitable defaults ##########
##########------------------------------------------------------##########
## Mega 48, 88, 168, 328 default values
LFUSE = 0x62
HFUSE = 0xdf
EFUSE = 0x00
## Generic
FUSE_STRING = -U lfuse:w:$(LFUSE):m -U hfuse:w:$(HFUSE):m -U efuse:w:$(EFUSE):m
fuses:
$(AVRDUDE) -c $(PROGRAMMER_TYPE) -p $(MCU) \
$(PROGRAMMER_ARGS) $(FUSE_STRING)
show_fuses:
$(AVRDUDE) -c $(PROGRAMMER_TYPE) -p $(MCU) $(PROGRAMMER_ARGS) -nv
## Called with no extra definitions, sets to defaults
set_default_fuses: FUSE_STRING = -U lfuse:w:$(LFUSE):m -U hfuse:w:$(HFUSE):m -U efuse:w:$(EFUSE):m
set_default_fuses: fuses
## Set the fuse byte for full-speed mode
## Note: can also be set in firmware for modern chips
set_fast_fuse: LFUSE = 0xE2
set_fast_fuse: FUSE_STRING = -U lfuse:w:$(LFUSE):m
set_fast_fuse: fuses
## Set the EESAVE fuse byte to preserve EEPROM across flashes
set_eeprom_save_fuse: HFUSE = 0xD7
set_eeprom_save_fuse: FUSE_STRING = -U hfuse:w:$(HFUSE):m
set_eeprom_save_fuse: fuses
## Clear the EESAVE fuse byte
clear_eeprom_save_fuse: FUSE_STRING = -U hfuse:w:$(HFUSE):m
clear_eeprom_save_fuse: fuses

View File

@ -0,0 +1,30 @@
AVR-Programming-Library
=======================
Files that are re-used throughout the book *Make: AVR Programming*
* **pinDefines.h**
Includes all of the pin definitions for the projects in *Make: AVR Programming*. When you
need to know what to hook up where, have a look here.
* **USART.c** and **USART.h**
These are the main utility files used for serial input/output in the book. They're not
particularly clever, but they have a tiny memory and resource footprint and get you
up and running very quickly.
* **binaryMacro.h**
If you're using a compiler other than a recent AVR-GCC, it may not support
native binary digits (e.g. 0b00111010). If so, this include file has a pre-processor
macro that will let you enter them similarly: B8(01010101).
* **macros.h**
This file includes pre-processor macro definitions for bit-twiddling:
set_bit, clear_bit, and toggle_bit. Useful for those days when you're feeling
lazy, or have forgotten your bit-wise logic operations.
* **portpins.h**
This is a recent version of the portpins.h file included with the Arduino environment.
It includes the AVR pin definitions of the form PB1 and similar. The version included
with Arduino is very old -- you'll want to replace it with this one if you want to write
in C using the Arduino IDE. Or you can include this file directly in your code.

View File

@ -0,0 +1,137 @@
/*
Quick and dirty functions that make serial communications work.
Note that receiveByte() blocks -- it sits and waits _forever_ for
a byte to come in. If you're doing anything that's more interesting,
you'll want to implement this with interrupts.
initUSART requires BAUDRATE to be defined in order to calculate
the bit-rate multiplier. 9600 is a reasonable default.
May not work with some of the older chips:
Tiny2313, Mega8, Mega16, Mega32 have different pin macros
If you're using these chips, see (e.g.) iom8.h for how it's done.
These old chips don't specify UDR0 vs UDR1.
Correspondingly, the macros will just be defined as UDR.
*/
#include <avr/io.h>
#include "USART.h"
#include <util/setbaud.h>
void initUSART(void) { /* requires BAUD */
UBRR0H = UBRRH_VALUE; /* defined in setbaud.h */
UBRR0L = UBRRL_VALUE;
#if USE_2X
UCSR0A |= (1 << U2X0);
#else
UCSR0A &= ~(1 << U2X0);
#endif
/* Enable USART transmitter/receiver */
UCSR0B = (1 << TXEN0) | (1 << RXEN0);
UCSR0C = (1 << UCSZ01) | (1 << UCSZ00); /* 8 data bits, 1 stop bit */
}
void transmitByte(uint8_t data) {
/* Wait for empty transmit buffer */
loop_until_bit_is_set(UCSR0A, UDRE0);
UDR0 = data; /* send data */
}
uint8_t receiveByte(void) {
loop_until_bit_is_set(UCSR0A, RXC0); /* Wait for incoming data */
return UDR0; /* return register value */
}
/* Here are a bunch of useful printing commands */
void printString(const char myString[]) {
uint8_t i = 0;
while (myString[i]) {
transmitByte(myString[i]);
i++;
}
}
void readString(char myString[], uint8_t maxLength) {
char response;
uint8_t i;
i = 0;
while (i < (maxLength - 1)) { /* prevent over-runs */
response = receiveByte();
transmitByte(response); /* echo */
if (response == '\r') { /* enter marks the end */
break;
}
else {
myString[i] = response; /* add in a letter */
i++;
}
}
myString[i] = 0; /* terminal NULL character */
}
void printByte(uint8_t byte) {
/* Converts a byte to a string of decimal text, sends it */
transmitByte('0' + (byte / 100)); /* Hundreds */
transmitByte('0' + ((byte / 10) % 10)); /* Tens */
transmitByte('0' + (byte % 10)); /* Ones */
}
void printWord(uint16_t word) {
transmitByte('0' + (word / 10000)); /* Ten-thousands */
transmitByte('0' + ((word / 1000) % 10)); /* Thousands */
transmitByte('0' + ((word / 100) % 10)); /* Hundreds */
transmitByte('0' + ((word / 10) % 10)); /* Tens */
transmitByte('0' + (word % 10)); /* Ones */
}
void printBinaryByte(uint8_t byte) {
/* Prints out a byte as a series of 1's and 0's */
uint8_t bit;
for (bit = 7; bit < 255; bit--) {
if (bit_is_set(byte, bit))
transmitByte('1');
else
transmitByte('0');
}
}
char nibbleToHexCharacter(uint8_t nibble) {
/* Converts 4 bits into hexadecimal */
if (nibble < 10) {
return ('0' + nibble);
}
else {
return ('A' + nibble - 10);
}
}
void printHexByte(uint8_t byte) {
/* Prints a byte as its hexadecimal equivalent */
uint8_t nibble;
nibble = (byte & 0b11110000) >> 4;
transmitByte(nibbleToHexCharacter(nibble));
nibble = byte & 0b00001111;
transmitByte(nibbleToHexCharacter(nibble));
}
uint8_t getNumber(void) {
// Gets a numerical 0-255 from the serial port.
// Converts from string to number.
char hundreds = '0';
char tens = '0';
char ones = '0';
char thisChar = '0';
do { /* shift over */
hundreds = tens;
tens = ones;
ones = thisChar;
thisChar = receiveByte(); /* get a new character */
transmitByte(thisChar); /* echo */
} while (thisChar != '\r'); /* until type return */
return (100 * (hundreds - '0') + 10 * (tens - '0') + ones - '0');
}

View File

@ -0,0 +1,45 @@
/* Functions to initialize, send, receive over USART
initUSART requires BAUD to be defined in order to calculate
the bit-rate multiplier.
*/
#ifndef BAUD /* if not defined in Makefile... */
#define BAUD 9600 /* set a safe default baud rate */
#endif
/* These are defined for convenience */
#define USART_HAS_DATA bit_is_set(UCSR0A, RXC0)
#define USART_READY bit_is_set(UCSR0A, UDRE0)
/* Takes the defined BAUD and F_CPU,
calculates the bit-clock multiplier,
and configures the hardware USART */
void initUSART(void);
/* Blocking transmit and receive functions.
When you call receiveByte() your program will hang until
data comes through. We'll improve on this later. */
void transmitByte(uint8_t data);
uint8_t receiveByte(void);
void printString(const char myString[]);
/* Utility function to transmit an entire string from RAM */
void readString(char myString[], uint8_t maxLength);
/* Define a string variable, pass it to this function
The string will contain whatever you typed over serial */
void printByte(uint8_t byte);
/* Prints a byte out as its 3-digit ascii equivalent */
void printWord(uint16_t word);
/* Prints a word (16-bits) out as its 5-digit ascii equivalent */
void printBinaryByte(uint8_t byte);
/* Prints a byte out in 1s and 0s */
char nibbleToHex(uint8_t nibble);
char nibbleToHexCharacter(uint8_t nibble);
void printHexByte(uint8_t byte);
/* Prints a byte out in hexadecimal */
uint8_t getNumber(void);
/* takes in up to three ascii digits,
converts them to a byte when press enter */

Binary file not shown.

View File

@ -0,0 +1,45 @@
/* Binary constant generator macro
By Tom Torfs - donated to the public domain
*/
/* All macro's evaluate to compile-time constants */
/* *** helper macros *** /
/* turn a numeric literal into a hex constant
(avoids problems with leading zeroes)
8-bit constants max value 0x11111111, always fits in unsigned long
*/
#define HEX__(n) 0x##n##LU
/* 8-bit conversion function */
#define B8__(x) ((x&0x0000000FLU)?1:0) \
+((x&0x000000F0LU)?2:0) \
+((x&0x00000F00LU)?4:0) \
+((x&0x0000F000LU)?8:0) \
+((x&0x000F0000LU)?16:0) \
+((x&0x00F00000LU)?32:0) \
+((x&0x0F000000LU)?64:0) \
+((x&0xF0000000LU)?128:0)
/* *** user macros *** /
/* for upto 8-bit binary constants */
#define B8(d) ((unsigned char)B8__(HEX__(d)))
/* for upto 16-bit binary constants, MSB first */
#define B16(dmsb,dlsb) (((unsigned short)B8(dmsb)<<8) \
+ B8(dlsb))
/* for upto 32-bit binary constants, MSB first */
#define B32(dmsb,db2,db3,dlsb) (((unsigned long)B8(dmsb)<<24) \
+ ((unsigned long)B8(db2)<<16) \
+ ((unsigned long)B8(db3)<<8) \
+ B8(dlsb))
/* Sample usage:
B8(01010101) = 85
B16(10101010,01010101) = 43605
B32(10000000,11111111,10101010,01010101) = 2164238933
*/

View File

@ -0,0 +1,26 @@
/* Standard Macros */
/* You can totally get by without these, but why? */
/* Make sure we've already got io / sfr / pindefs loaded */
#ifndef _AVR_IO_H_
#include <avr/io.h>
#endif
/* Reminder: the following useful bit-twiddling macros are
always included in avr/sfr_defs.h, which is called from
avr/io.h
bit_is_set(sfr, bit)
bit_is_clear(sfr, bit)
loop_until_bit_is_set(sfr, bit)
loop_until_bit_is_clear(sfr, bit)
*/
/* Define up the full complement of bit-twiddling macros */
#define BV(bit) (1 << bit)
#define set_bit(sfr, bit) (_SFR_BYTE(sfr) |= BV(bit)) // old sbi()
#define clear_bit(sfr, bit) (_SFR_BYTE(sfr) &= ~BV(bit)) // old cbi()
#define toggle_bit(sfr, bit) (_SFR_BYTE(sfr) ^= BV(bit))

View File

@ -0,0 +1,91 @@
// ---------------
// Pin Defines
// ---------------
#define LED_PORT PORTB
#define LED_PIN PINB
#define LED_DDR DDRB
#define LED0 PB0
#define LED1 PB1
#define LED2 PB2
#define LED3 PB3
#define LED4 PB4
#define LED5 PB5
#define LED6 PB6
#define LED7 PB7
#define BUTTON_PORT PORTD
#define BUTTON_PIN PIND
#define BUTTON_DDR DDRD
#define BUTTON PD2
#define BUTTON2 PD3
#define BUTTON3 PD4
#define SPEAKER PD6 /* OC0A */
#define SPEAKER_PORT PORTD
#define SPEAKER_PIN PIND
#define SPEAKER_DDR DDRD
#define ANTENNA PD5 /* OC0B */
#define ANTENNA_PORT PORTD
#define ANTENNA_PIN PIND
#define ANTENNA_DDR DDRD
#define MODULATION PD3 /* OC2B */
#define MODULATION_PORT PORTD
#define MODULATION_PIN PIND
#define MODULATION_DDR DDRD
#define LIGHT_SENSOR PC0 /* ADC0 */
#define LIGHT_SENSOR_PORT PORTC
#define LIGHT_SENSOR_PIN PINC
#define LIGHT_SENSOR_DDR DDRC
#define CAP_SENSOR PC1 /* ADC1 */
#define CAP_SENSOR_PORT PORTC
#define CAP_SENSOR_PIN PINC
#define CAP_SENSOR_DDR DDRC
#define PIEZO PC2 /* ADC2 */
#define PIEZO_PORT PORTC
#define PIEZO_PIN PINC
#define PIEZO_DDR DDRC
#define POT PC3 /* ADC3 */
#define POT_PORT PORTC
#define POT_PIN PINC
#define POT_DDR DDRC
// SPI and I2C serial mode defines
#define SPI_SS PB2
#define SPI_SS_PORT PORTB
#define SPI_SS_PIN PINB
#define SPI_SS_DDR DDRB
#define SPI_MOSI PB3
#define SPI_MOSI_PORT PORTB
#define SPI_MOSI_PIN PINB
#define SPI_MOSI_DDR DDRB
#define SPI_MISO PB4
#define SPI_MISO_PORT PORTB
#define SPI_MISO_PIN PINB
#define SPI_MISO_DDR DDRB
#define SPI_SCK PB5
#define SPI_SCK_PORT PORTB
#define SPI_SCK_PIN PINB
#define SPI_SCK_DDR DDRB
#define I2C_SDA PC4
#define I2C_SDA_PORT PORTC
#define I2C_SDA_PIN PINC
#define I2C_SDA_DDR DDRC
#define I2C_SCL PC5
#define I2C_SCL_PORT PORTC
#define I2C_SCL_PIN PINC
#define I2C_SCL_DDR DDRC

View File

@ -0,0 +1,549 @@
/* Copyright (c) 2003 Theodore A. Roth
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
* Neither the name of the copyright holders nor the names of
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. */
/* $Id: portpins.h 1936 2009-03-19 22:19:26Z arcanum $ */
#ifndef _AVR_PORTPINS_H_
#define _AVR_PORTPINS_H_ 1
/* This file should only be included from <avr/io.h>, never directly. */
#ifndef _AVR_IO_H_
# error "Include <avr/io.h> instead of this file."
#endif
/* Define Generic PORTn, DDn, and PINn values. */
/* Port Data Register (generic) */
#define PORT7 7
#define PORT6 6
#define PORT5 5
#define PORT4 4
#define PORT3 3
#define PORT2 2
#define PORT1 1
#define PORT0 0
/* Port Data Direction Register (generic) */
#define DD7 7
#define DD6 6
#define DD5 5
#define DD4 4
#define DD3 3
#define DD2 2
#define DD1 1
#define DD0 0
/* Port Input Pins (generic) */
#define PIN7 7
#define PIN6 6
#define PIN5 5
#define PIN4 4
#define PIN3 3
#define PIN2 2
#define PIN1 1
#define PIN0 0
/* Define PORTxn an Pxn values for all possible port pins if not defined already by io.h. */
/* PORT A */
#if defined(PA0) && !defined(PORTA0)
# define PORTA0 PA0
#elif defined(PORTA0) && !defined(PA0)
# define PA0 PORTA0
#endif
#if defined(PA1) && !defined(PORTA1)
# define PORTA1 PA1
#elif defined(PORTA1) && !defined(PA1)
# define PA1 PORTA1
#endif
#if defined(PA2) && !defined(PORTA2)
# define PORTA2 PA2
#elif defined(PORTA2) && !defined(PA2)
# define PA2 PORTA2
#endif
#if defined(PA3) && !defined(PORTA3)
# define PORTA3 PA3
#elif defined(PORTA3) && !defined(PA3)
# define PA3 PORTA3
#endif
#if defined(PA4) && !defined(PORTA4)
# define PORTA4 PA4
#elif defined(PORTA4) && !defined(PA4)
# define PA4 PORTA4
#endif
#if defined(PA5) && !defined(PORTA5)
# define PORTA5 PA5
#elif defined(PORTA5) && !defined(PA5)
# define PA5 PORTA5
#endif
#if defined(PA6) && !defined(PORTA6)
# define PORTA6 PA6
#elif defined(PORTA6) && !defined(PA6)
# define PA6 PORTA6
#endif
#if defined(PA7) && !defined(PORTA7)
# define PORTA7 PA7
#elif defined(PORTA7) && !defined(PA7)
# define PA7 PORTA7
#endif
/* PORT B */
#if defined(PB0) && !defined(PORTB0)
# define PORTB0 PB0
#elif defined(PORTB0) && !defined(PB0)
# define PB0 PORTB0
#endif
#if defined(PB1) && !defined(PORTB1)
# define PORTB1 PB1
#elif defined(PORTB1) && !defined(PB1)
# define PB1 PORTB1
#endif
#if defined(PB2) && !defined(PORTB2)
# define PORTB2 PB2
#elif defined(PORTB2) && !defined(PB2)
# define PB2 PORTB2
#endif
#if defined(PB3) && !defined(PORTB3)
# define PORTB3 PB3
#elif defined(PORTB3) && !defined(PB3)
# define PB3 PORTB3
#endif
#if defined(PB4) && !defined(PORTB4)
# define PORTB4 PB4
#elif defined(PORTB4) && !defined(PB4)
# define PB4 PORTB4
#endif
#if defined(PB5) && !defined(PORTB5)
# define PORTB5 PB5
#elif defined(PORTB5) && !defined(PB5)
# define PB5 PORTB5
#endif
#if defined(PB6) && !defined(PORTB6)
# define PORTB6 PB6
#elif defined(PORTB6) && !defined(PB6)
# define PB6 PORTB6
#endif
#if defined(PB7) && !defined(PORTB7)
# define PORTB7 PB7
#elif defined(PORTB7) && !defined(PB7)
# define PB7 PORTB7
#endif
/* PORT C */
#if defined(PC0) && !defined(PORTC0)
# define PORTC0 PC0
#elif defined(PORTC0) && !defined(PC0)
# define PC0 PORTC0
#endif
#if defined(PC1) && !defined(PORTC1)
# define PORTC1 PC1
#elif defined(PORTC1) && !defined(PC1)
# define PC1 PORTC1
#endif
#if defined(PC2) && !defined(PORTC2)
# define PORTC2 PC2
#elif defined(PORTC2) && !defined(PC2)
# define PC2 PORTC2
#endif
#if defined(PC3) && !defined(PORTC3)
# define PORTC3 PC3
#elif defined(PORTC3) && !defined(PC3)
# define PC3 PORTC3
#endif
#if defined(PC4) && !defined(PORTC4)
# define PORTC4 PC4
#elif defined(PORTC4) && !defined(PC4)
# define PC4 PORTC4
#endif
#if defined(PC5) && !defined(PORTC5)
# define PORTC5 PC5
#elif defined(PORTC5) && !defined(PC5)
# define PC5 PORTC5
#endif
#if defined(PC6) && !defined(PORTC6)
# define PORTC6 PC6
#elif defined(PORTC6) && !defined(PC6)
# define PC6 PORTC6
#endif
#if defined(PC7) && !defined(PORTC7)
# define PORTC7 PC7
#elif defined(PORTC7) && !defined(PC7)
# define PC7 PORTC7
#endif
/* PORT D */
#if defined(PD0) && !defined(PORTD0)
# define PORTD0 PD0
#elif defined(PORTD0) && !defined(PD0)
# define PD0 PORTD0
#endif
#if defined(PD1) && !defined(PORTD1)
# define PORTD1 PD1
#elif defined(PORTD1) && !defined(PD1)
# define PD1 PORTD1
#endif
#if defined(PD2) && !defined(PORTD2)
# define PORTD2 PD2
#elif defined(PORTD2) && !defined(PD2)
# define PD2 PORTD2
#endif
#if defined(PD3) && !defined(PORTD3)
# define PORTD3 PD3
#elif defined(PORTD3) && !defined(PD3)
# define PD3 PORTD3
#endif
#if defined(PD4) && !defined(PORTD4)
# define PORTD4 PD4
#elif defined(PORTD4) && !defined(PD4)
# define PD4 PORTD4
#endif
#if defined(PD5) && !defined(PORTD5)
# define PORTD5 PD5
#elif defined(PORTD5) && !defined(PD5)
# define PD5 PORTD5
#endif
#if defined(PD6) && !defined(PORTD6)
# define PORTD6 PD6
#elif defined(PORTD6) && !defined(PD6)
# define PD6 PORTD6
#endif
#if defined(PD7) && !defined(PORTD7)
# define PORTD7 PD7
#elif defined(PORTD7) && !defined(PD7)
# define PD7 PORTD7
#endif
/* PORT E */
#if defined(PE0) && !defined(PORTE0)
# define PORTE0 PE0
#elif defined(PORTE0) && !defined(PE0)
# define PE0 PORTE0
#endif
#if defined(PE1) && !defined(PORTE1)
# define PORTE1 PE1
#elif defined(PORTE1) && !defined(PE1)
# define PE1 PORTE1
#endif
#if defined(PE2) && !defined(PORTE2)
# define PORTE2 PE2
#elif defined(PORTE2) && !defined(PE2)
# define PE2 PORTE2
#endif
#if defined(PE3) && !defined(PORTE3)
# define PORTE3 PE3
#elif defined(PORTE3) && !defined(PE3)
# define PE3 PORTE3
#endif
#if defined(PE4) && !defined(PORTE4)
# define PORTE4 PE4
#elif defined(PORTE4) && !defined(PE4)
# define PE4 PORTE4
#endif
#if defined(PE5) && !defined(PORTE5)
# define PORTE5 PE5
#elif defined(PORTE5) && !defined(PE5)
# define PE5 PORTE5
#endif
#if defined(PE6) && !defined(PORTE6)
# define PORTE6 PE6
#elif defined(PORTE6) && !defined(PE6)
# define PE6 PORTE6
#endif
#if defined(PE7) && !defined(PORTE7)
# define PORTE7 PE7
#elif defined(PORTE7) && !defined(PE7)
# define PE7 PORTE7
#endif
/* PORT F */
#if defined(PF0) && !defined(PORTF0)
# define PORTF0 PF0
#elif defined(PORTF0) && !defined(PF0)
# define PF0 PORTF0
#endif
#if defined(PF1) && !defined(PORTF1)
# define PORTF1 PF1
#elif defined(PORTF1) && !defined(PF1)
# define PF1 PORTF1
#endif
#if defined(PF2) && !defined(PORTF2)
# define PORTF2 PF2
#elif defined(PORTF2) && !defined(PF2)
# define PF2 PORTF2
#endif
#if defined(PF3) && !defined(PORTF3)
# define PORTF3 PF3
#elif defined(PORTF3) && !defined(PF3)
# define PF3 PORTF3
#endif
#if defined(PF4) && !defined(PORTF4)
# define PORTF4 PF4
#elif defined(PORTF4) && !defined(PF4)
# define PF4 PORTF4
#endif
#if defined(PF5) && !defined(PORTF5)
# define PORTF5 PF5
#elif defined(PORTF5) && !defined(PF5)
# define PF5 PORTF5
#endif
#if defined(PF6) && !defined(PORTF6)
# define PORTF6 PF6
#elif defined(PORTF6) && !defined(PF6)
# define PF6 PORTF6
#endif
#if defined(PF7) && !defined(PORTF7)
# define PORTF7 PF7
#elif defined(PORTF7) && !defined(PF7)
# define PF7 PORTF7
#endif
/* PORT G */
#if defined(PG0) && !defined(PORTG0)
# define PORTG0 PG0
#elif defined(PORTG0) && !defined(PG0)
# define PG0 PORTG0
#endif
#if defined(PG1) && !defined(PORTG1)
# define PORTG1 PG1
#elif defined(PORTG1) && !defined(PG1)
# define PG1 PORTG1
#endif
#if defined(PG2) && !defined(PORTG2)
# define PORTG2 PG2
#elif defined(PORTG2) && !defined(PG2)
# define PG2 PORTG2
#endif
#if defined(PG3) && !defined(PORTG3)
# define PORTG3 PG3
#elif defined(PORTG3) && !defined(PG3)
# define PG3 PORTG3
#endif
#if defined(PG4) && !defined(PORTG4)
# define PORTG4 PG4
#elif defined(PORTG4) && !defined(PG4)
# define PG4 PORTG4
#endif
#if defined(PG5) && !defined(PORTG5)
# define PORTG5 PG5
#elif defined(PORTG5) && !defined(PG5)
# define PG5 PORTG5
#endif
#if defined(PG6) && !defined(PORTG6)
# define PORTG6 PG6
#elif defined(PORTG6) && !defined(PG6)
# define PG6 PORTG6
#endif
#if defined(PG7) && !defined(PORTG7)
# define PORTG7 PG7
#elif defined(PORTG7) && !defined(PG7)
# define PG7 PORTG7
#endif
/* PORT H */
#if defined(PH0) && !defined(PORTH0)
# define PORTH0 PH0
#elif defined(PORTH0) && !defined(PH0)
# define PH0 PORTH0
#endif
#if defined(PH1) && !defined(PORTH1)
# define PORTH1 PH1
#elif defined(PORTH1) && !defined(PH1)
# define PH1 PORTH1
#endif
#if defined(PH2) && !defined(PORTH2)
# define PORTH2 PH2
#elif defined(PORTH2) && !defined(PH2)
# define PH2 PORTH2
#endif
#if defined(PH3) && !defined(PORTH3)
# define PORTH3 PH3
#elif defined(PORTH3) && !defined(PH3)
# define PH3 PORTH3
#endif
#if defined(PH4) && !defined(PORTH4)
# define PORTH4 PH4
#elif defined(PORTH4) && !defined(PH4)
# define PH4 PORTH4
#endif
#if defined(PH5) && !defined(PORTH5)
# define PORTH5 PH5
#elif defined(PORTH5) && !defined(PH5)
# define PH5 PORTH5
#endif
#if defined(PH6) && !defined(PORTH6)
# define PORTH6 PH6
#elif defined(PORTH6) && !defined(PH6)
# define PH6 PORTH6
#endif
#if defined(PH7) && !defined(PORTH7)
# define PORTH7 PH7
#elif defined(PORTH7) && !defined(PH7)
# define PH7 PORTH7
#endif
/* PORT J */
#if defined(PJ0) && !defined(PORTJ0)
# define PORTJ0 PJ0
#elif defined(PORTJ0) && !defined(PJ0)
# define PJ0 PORTJ0
#endif
#if defined(PJ1) && !defined(PORTJ1)
# define PORTJ1 PJ1
#elif defined(PORTJ1) && !defined(PJ1)
# define PJ1 PORTJ1
#endif
#if defined(PJ2) && !defined(PORTJ2)
# define PORTJ2 PJ2
#elif defined(PORTJ2) && !defined(PJ2)
# define PJ2 PORTJ2
#endif
#if defined(PJ3) && !defined(PORTJ3)
# define PORTJ3 PJ3
#elif defined(PORTJ3) && !defined(PJ3)
# define PJ3 PORTJ3
#endif
#if defined(PJ4) && !defined(PORTJ4)
# define PORTJ4 PJ4
#elif defined(PORTJ4) && !defined(PJ4)
# define PJ4 PORTJ4
#endif
#if defined(PJ5) && !defined(PORTJ5)
# define PORTJ5 PJ5
#elif defined(PORTJ5) && !defined(PJ5)
# define PJ5 PORTJ5
#endif
#if defined(PJ6) && !defined(PORTJ6)
# define PORTJ6 PJ6
#elif defined(PORTJ6) && !defined(PJ6)
# define PJ6 PORTJ6
#endif
#if defined(PJ7) && !defined(PORTJ7)
# define PORTJ7 PJ7
#elif defined(PORTJ7) && !defined(PJ7)
# define PJ7 PORTJ7
#endif
/* PORT K */
#if defined(PK0) && !defined(PORTK0)
# define PORTK0 PK0
#elif defined(PORTK0) && !defined(PK0)
# define PK0 PORTK0
#endif
#if defined(PK1) && !defined(PORTK1)
# define PORTK1 PK1
#elif defined(PORTK1) && !defined(PK1)
# define PK1 PORTK1
#endif
#if defined(PK2) && !defined(PORTK2)
# define PORTK2 PK2
#elif defined(PORTK2) && !defined(PK2)
# define PK2 PORTK2
#endif
#if defined(PK3) && !defined(PORTK3)
# define PORTK3 PK3
#elif defined(PORTK3) && !defined(PK3)
# define PK3 PORTK3
#endif
#if defined(PK4) && !defined(PORTK4)
# define PORTK4 PK4
#elif defined(PORTK4) && !defined(PK4)
# define PK4 PORTK4
#endif
#if defined(PK5) && !defined(PORTK5)
# define PORTK5 PK5
#elif defined(PORTK5) && !defined(PK5)
# define PK5 PORTK5
#endif
#if defined(PK6) && !defined(PORTK6)
# define PORTK6 PK6
#elif defined(PORTK6) && !defined(PK6)
# define PK6 PORTK6
#endif
#if defined(PK7) && !defined(PORTK7)
# define PORTK7 PK7
#elif defined(PORTK7) && !defined(PK7)
# define PK7 PORTK7
#endif
/* PORT L */
#if defined(PL0) && !defined(PORTL0)
# define PORTL0 PL0
#elif defined(PORTL0) && !defined(PL0)
# define PL0 PORTL0
#endif
#if defined(PL1) && !defined(PORTL1)
# define PORTL1 PL1
#elif defined(PORTL1) && !defined(PL1)
# define PL1 PORTL1
#endif
#if defined(PL2) && !defined(PORTL2)
# define PORTL2 PL2
#elif defined(PORTL2) && !defined(PL2)
# define PL2 PORTL2
#endif
#if defined(PL3) && !defined(PORTL3)
# define PORTL3 PL3
#elif defined(PORTL3) && !defined(PL3)
# define PL3 PORTL3
#endif
#if defined(PL4) && !defined(PORTL4)
# define PORTL4 PL4
#elif defined(PORTL4) && !defined(PL4)
# define PL4 PORTL4
#endif
#if defined(PL5) && !defined(PORTL5)
# define PORTL5 PL5
#elif defined(PORTL5) && !defined(PL5)
# define PL5 PORTL5
#endif
#if defined(PL6) && !defined(PORTL6)
# define PORTL6 PL6
#elif defined(PORTL6) && !defined(PL6)
# define PL6 PORTL6
#endif
#if defined(PL7) && !defined(PORTL7)
# define PORTL7 PL7
#elif defined(PORTL7) && !defined(PL7)
# define PL7 PORTL7
#endif
#endif /* _AVR_PORTPINS_H_ */