ATmega 32A and 2560 R3 register to pin mapping? I've been doing research for the last few hours trying to determine the mapping of physical pins to memory-mapped I/O registers for the Arduino Mega board (which is an ATmega 2560 R3). 


My code is on GitHub in a pull request, but hasn't been merged yet because I'm not finished yet.
This is the upstream example I'm working from, which was written for an ATmega 32A.
Here is Arduino's 2560 pin mapping which doesn't tell which registers are mapped to which pins.
Here is avr/iomxx0_1.h which defines the ports with simple numbers that I can't make heads or tails of.
Here is a collection of links relevant to my research.
I broke down and cross-referenced all of the uses of memory-mapped I/O registers in the upstream example.


Some of the registers used include CS11, DDB4, DDRA, DDRB, GICR, INT0, INT1, ISC00, ISC10, MCUCR, PA0, PB5, PB7, PD2, PD3, PIND, PORTA, PORTD, SPCR, SPDR, SPIF, SPSR, TCCR1B, and TCNT1. I can't figure out which pins these are and/or what they do.

Here is a diagram provided by the upstream example:



Unfortunately, I'm not very good at reading these diagrams so I'm doing my best.

How can I determine the mapping of these registers to physical ports on both the ATmega 32A, which is the board the example was originally written for, and the ATmega 2560 R3, which is the board I'm currently working with?
What is ATmega2560 R3? There is ATmega2560 MCU or Arduino Mega R3. do you want the mapping of pins of Arduino Mega or the pins of the ATmega2560 MCU.

The mapping of pins of the ATmega 2560 chip is in the datasheet.

The mapping of the Arduino Mega pins to ATmega2560 pins and registers is in the schema of the board or in the Arduino AVR boards package variants mega folder.

The link "Arduino's 2560 pin mapping" in your question shows the mapping too. Registers are PA, PB,... and every register covers to 8 pins with the 8 bits of the register. For example PB3 is pin 50 of the board.