Understanding writing to input pins and pull up resistors I am new to Arduino, and am trying to understand the following code.  The question is: Is my understanding correct, or if not, what is happening here?

I have to reverse engineer an existing undocumented project, based on Marlin firmware for 3D Printers.  The relevant lines from the source are:

#define DIO87_PIN               PINE2
#define DIO87_RPORT             PINE
#define DIO87_WPORT             PORTE
#define DIO87_DDR               DDRE
#define DIO87_PWM               NULL

#define MASK(PIN)  (1 &lt;&lt; PIN)
#define _TOGGLE(IO)  do {DIO ##  IO ## _RPORT = MASK(DIO ## IO ## _PIN); } while (0)
#define TOGGLE(IO)  _TOGGLE(IO)

TOGGLE(87);


1) Reducing this code gives me:
DI087_RPORT = 1 &lt;&lt; DI087_PIN  

2) Which reduces further to:
PINE = 1 &lt;&lt; PINE2
3) Which reduces further to:
PINE = 00000100

4) I understand this to mean that we are setting Pin 2 of the Inputs Register (of Port E) to "High". (and are setting the other 7 pins to low)

5) I understand this to mean, as we are writing to an "Input", that we are enabling the internal pull-up resistor on Port E Pin 2.
(EDIT: I have made a mistake here in point 5: to enable a pull-up resister, you write to a pins OUTPUT register, not it's INPUT register. (but you must write to it's output register when it is in "input mode")

Questions:  


Is my understanding and work-through above correct?
If yes, does this also mean that we are also disabling the pull-up resistors to the other 7 Input Pins at the same time?


I am confused by the "TOGGLE" code given above - it seems that it is "destructive" in the sense that by "toggling" the input resistor on one pin, you also disable the resistors on all other pins?  Would it not make more sense to just toggle the one pin with a bitwise or.
e.g:
PINE = PINE | 1 &lt;&lt; PINE2
As noted in the I/O-Ports – Introduction section of the ATmega2560 datasheet,


  ... writing a logic one to a bit in the PINx Register, will result in a toggle in the corresponding bit in the Data Register.  In addition, the Pull-up Disable –  PUD bit in MCUCR disables the pull-up function for all pins in all ports when set.


Bits masked with a zero won't be affected.  You can toggle several bits at once if the byte written to the PINx register has several 1's in it.

Pullups are on for an input bit when the data bit is high and the PUD bit in  MCUCR is low.  So as suggested in your comment, pullups for toggled bits would toggle too, if PUD is low.

Regarding the macro code, your reduction looks right.  But note that use of _TOGGLE as an identifier in that code violates section 17.4.3.1.2 of the C++ Standard.  Names beginning with an underscore followed by an uppercase letter are reserved for use by language-implementation software.  They are off-limits for user code.  See What are the rules about using an underscore in a C++ identifier? for discussion.