/* Gets the direction and mode of a pin. */
unsigned long GPIODirModeGet(unsigned long ulPort, unsigned char ucPin)
/* Gets the direction and mode of a pin. */
unsigned long GPIODirModeGet(unsigned long ulPort, unsigned char ucPin)
{
    unsigned long ulDir, ulAFSEL;
    ASSERT(GPIOBaseValid(ulPort));
    ASSERT(ucPin < 8);
    ucPin = 1 << ucPin;
    ulDir = HWREG(ulPort + GPIO_O_DIR);
    ulAFSEL = HWREG(ulPort + GPIO_O_AFSEL);
    return(((ulDir & ucPin) ? 1 : 0) | ((ulAFSEL & ucPin) ? 2 : 0));
}