/* Sets the direction (input/output) for a specific port pin.  */
void gpioSetDir(uint32_t portNum, uint32_t bitPos, gpioDirection_t dir)
/* Sets the direction (input/output) for a specific port pin.  */
void gpioSetDir(uint32_t portNum, uint32_t bitPos, gpioDirection_t dir)
{
  if (!_gpioInitialised) gpioInit();
  REG32 *gpiodir = &GPIO_GPIO0DIR;
  switch (portNum)
  {
    case 0:
      gpiodir = &GPIO_GPIO0DIR;
      break;
    case 1:
      gpiodir = &GPIO_GPIO1DIR;
      break;
    case 2:
      gpiodir = &GPIO_GPIO2DIR;
      break;
    case 3:
      gpiodir = &GPIO_GPIO3DIR;
      break;
  }
  dir == gpioDirection_Output ? (*gpiodir |= (1 << bitPos)) : (*gpiodir &= ~(1 << bitPos));
}