Several GPIOs of Marvell's PXA3xx CPUs are available on two pins. These two pins can be individually configured to Alternate Functions. In case these two pins are configured as Alternate function GPIO, then they are coupled. The two instances are named:
If any of the two instances is configured to an alternate function other than GPIO, the other instance behaves like a regular GPIO.
If both pins are used as GPIO, you can see a special behavior:
To use the second instance 'GPIOx_2', you have to follow these steps:
Toradex provides several C libraries. One of them is the GPIO library. This is an example of how to use this Library to set GPIO5_2 to input and read its level.
BOOL level; // initialize the GPIO library InitGPIOLib(); // Set the pin GPIO5_2 to alternate function GPIO. For second instance GPIOs you have to add 128 to the GPIO number. SetGPIOAltFn(5+128, 0, DIR_IN); // Read the level of the GPIO. The GPIO has to be the logical GPIO number assigned to the pin GPIO5_2 level = GetGPIOLevel(5+128); // The GPIOLib translates this from 5+128 to 5 and configures the correct GPIO 5 // Deinitialize the GPIO lib (free the virtual memory used by the lib) DeInitGPIOLib();