Portenta Machine Edition Pin Naming Convention

Say, you want to write to Digital output pin #2

Unfortunately, the pinout diagram is no use here, but if you check the schematics or the library you will notice the following array containing the corresponding Portenta H7 pin names:

mbed::DigitalOut out[8] = {
		mbed::DigitalOut(PI_6), mbed::DigitalOut(PH_9), mbed::DigitalOut(PJ_9), mbed::DigitalOut(PE_2),
		mbed::DigitalOut(PI_3), mbed::DigitalOut(PI_2), mbed::DigitalOut(PD_3), mbed::DigitalOut(PA_14)
	};

Digital output pin #2 corresponds to "PJ_9". Now that you know the name of the pin, you can use it and pass it to any library function like so:

Instead of
libraryFunction(2);

use
libraryFunction(PinNameToIndex(PJ_9));