The fastest way to read out a digital pin state in an Arduino Due
If the pin is declared as input, let's say pin 13:

uint32_t pin_status;
pin_status = PIOB-&gt;PIO_PDSR &amp; PIO_PDSR_P27;


If the pin is declared as output, let's say pin 13:

uint32_t pin_status;
pin_status = PIOB-&gt;PIO_ODSR &amp; PIO_ODSR_P27;