user30969: On Arduino I can set digital pins by setting special variables PORTB and PORTD (or maybe they are not variables?). Where are those variables defined? I grepped /usr/share/arduino, but found nothing.
grep -r 'PORTB' /usr/share/arduino/


user18478: PORTB is defined by the "toolchain". It is not defined by Arduino.
For instance in my setup the Arduino Uno uses "toolchain" avr-gcc\4.9.2-amtel3.5.3-arduino2\avr.
If you grep that folder (location dependent on tool and installation options) you will find a file called iom328p.h that defines
#define PORTB _SFR_IO8(0x05)

This is a mapping to a physical address of the cpu.

30969: <p>On Arduino I can set digital pins by setting special variables PORTB and PORTD (or maybe they are not variables?). Where are those variables defined? I grepped /usr/share/arduino, but found nothing.</p>

<pre><code>grep -r 'PORTB' /usr/share/arduino/
</code></pre>
 18478: <p>PORTB is defined by the "toolchain". It is not defined by Arduino.
For instance in my setup the Arduino Uno uses "toolchain" avr-gcc\4.9.2-amtel3.5.3-arduino2\avr.</p>

<p>If you grep that folder (location dependent on tool and installation options) you will find a file called <code>iom328p.h</code> that defines</p>

<pre><code>#define PORTB _SFR_IO8(0x05)
</code></pre>

<p>This is a mapping to a physical address of the cpu.</p>
