Port manipulation PINx commands with Arduino Due ?

stimmer:
I had a go at writing some digitalReadDirect/digitalWriteDirect functions but you might want to give them some more thorough testing as I only checked if it worked with the LED :slight_smile:

inline void digitalWriteDirect(int pin, boolean val){

if(val) g_APinDescription[pin].pPort -> PIO_SODR = g_APinDescription[pin].ulPin;
 else    g_APinDescription[pin].pPort -> PIO_CODR = g_APinDescription[pin].ulPin;
}

inline int digitalReadDirect(int pin){
 return !!(g_APinDescription[pin].pPort -> PIO_PDSR & g_APinDescription[pin].ulPin);
}

They seem to work fine. I just used it for my first sketch for my Due, a comparison of port switching and square wave generation using DigitalWrite vs. direct writing using your inline function. Big difference, this is what it looks like on my scope (it overshoots the square because I have a long lead which I corrected for the second measurement):

The waves are a whole lot squarer when running at 1% of the maximum speed. :slight_smile:

Sorry for the bad smartphone pics, I haven't figured out how to properly screen capture on the scope yet and I can't open the manual right now because Adobe Acrobat is having a weird fit.