Porting program from UNU to Zero /M0 32bit

How to name this code for SAMD21 mcu :

void countStep() {
if (PINC & B0100000) target1--; // pin A5 represents direction
else target1++;

}

and this

void encoder() { // pulse and direction, direct port reading to save cycles
if (PINB & 0b00000001) encoderPos++; // digital pin 8 if(digitalRead(encodPinB1)==HIGH)
count ++;
else encoderPos--; // if(digitalRead(encodPinB1)==LOW) count --;

}

so PINC & B0100000 and PINB & 0b00000001 ??

God invented digitalRead(), digitalWrite(), pinMode(). Use them. e.g.

if(digitalRead(encodPinB1)==HIGH)

Yes, you can write bare-metal SAMD21 code. But the Arduino functions work pretty well on the SAMD21.

I use SAMD21 registers when writing to a TFT because there are millions of instructions to just clear the screen.
Other hardware like LCD, Encoder, Temp Sensor, ... only need a few digitalxxxx() statements. So speed is not important.

David.

Find MartinL's post at this thread Faster Pin I/O on Zero? - Arduino Zero - Arduino Forum. I have tested the code on a custom Arduino Zero i made and it works well.