Autonomo pin mapping - Direct Port Manipulation

I am in the process of moving a project from an Arduino MEGA to the Autonomo and the last remaining hurdle I have is to perform direct port manipulation in order to perform fast digital IO.

As an example, on the implementation on the Arduino MEGA I would manipulate the bits of an 8-bit/byte as follows to be able to very quickly toggle one pin (in this case 53, but it could be any other) HIGH, respectively LOW.

void setup()
{
pinMode(53, OUTPUT); //STEP
}

void loop()
{
PORTB|=B00000001 //PIN 53 = HIGH
PORTB&=B11111110 //PIN 53 = LOW
}

From what I see online, the Arduino Zero Platform has everything defined in a 32-bit port, called PORT (or PORT_IOBUS ?). All in all doable, however I don’t have the mapping between the register and the Autonomo Pins.

Any insights are greatly appreciated!

Looking at wiring_digital.c in the /cores directory there appears to be two registers one for setting (HIGH) the other for clearing (LOW):

PORT->Group[x].OUTSET.reg = (1ul << y); // For HIGH
PORT->Group[x].OUTCLR.reg = (1ul << y); // For LOW

Where:
x = PORTA or PORTB
y = the port pin number

You can get these values from the schema or look them up using the g_APinDescription array (which is filled out in variant.cpp).

It would probably be easiest to still use pinMode() to set the initial pin settings.

In the digitalWrite() method they also set the pin to pull up before changing its value. This is only required when the pin has not be previously set to output using pinMode().