/* Configure GPIO interrupt. 
Notice that any pending interrupt for the selected pin is cleared by this function. */
void GPIO_IntConfig(GPIO_Port_TypeDef port, unsigned int pin, bool risingEdge, bool fallingEdge, bool enable)
/* Configure GPIO interrupt. 
Notice that any pending interrupt for the selected pin is cleared by this function. */
void GPIO_IntConfig(GPIO_Port_TypeDef port, unsigned int pin, bool risingEdge, bool fallingEdge, bool enable)
{
  uint32_t tmp;
  EFM_ASSERT(GPIO_PORT_VALID(port) && GPIO_PIN_VALID(pin));
  if (pin < 8)
  {
    GPIO->EXTIPSELL = (GPIO->EXTIPSELL & ~(0xF << (4 * pin))) |
                      (port << (4 * pin));
  }
  else
  {
    tmp             = pin - 8;
    GPIO->EXTIPSELH = (GPIO->EXTIPSELH & ~(0xF << (4 * tmp))) |
                      (port << (4 * tmp));
  }
  BITBAND_Peripheral(&(GPIO->EXTIRISE), pin, (unsigned int)risingEdge);
  BITBAND_Peripheral(&(GPIO->EXTIFALL), pin, (unsigned int)fallingEdge);
  GPIO->IFC = 1 << pin;
  BITBAND_Peripheral(&(GPIO->IEN), pin, (unsigned int)enable);
}