Credits to GoForSmoke. Also see Gerben's comment below.
See: https://forum.arduino.cc/index.php?topic=286145.0
byte ddrcMask = ~
(
(1 << DDC0) | // pinMode( 14, INPUT ); // Set to input
(1 << DDC1) | // pinMode( 15, INPUT ); // Set to input
(1 << DDC2) | // pinMode( 16, INPUT ); // Set to input
(1 << DDC3) // pinMode( 17, INPUT ); // Set to input
);
byte portcMask =
(
(1 << PORTC0) | // digitalWrite( 14, HIGH ); // Enable the pullup
(1 << PORTC1) | // digitalWrite( 15, HIGH ); // Enable the pullup
(1 << PORTC2) | // digitalWrite( 16, HIGH ); // Enable the pullup
(1 << PORTC3) // digitalWrite( 17, HIGH ); // Enable the pullup
);
byte pincMask = ( (1 << PINC0) | (1 << PINC1) | (1 << PINC2) | (1 << PINC3) );
void setup( void )
{
// Configure the pins for input
DDRC = DDRC & ddrcMask;
// Enable the pullups
PORTC = PORTC | portcMask;
// Read all four inputs
uint8_t Pdat = PINC & pincMask;
}
void loop( void )
{
}