/*******************************************************************************
 * @fn          trxIsrConnect
 *
 * @brief       Connects an ISR function to PORT1 interrupt vector and 
 *              configures the interrupt to be a high-low transition. 
 * 
 * input parameters
 *
 * @param       pF  - function pointer to ISR
 *
 * output parameters
 *
 * @return      void
 */ 
void trxIsrConnect(uint8 gpio, uint8 edge, ISR_FUNC_PTR pF)
{
  digio io;
  
  switch(gpio)
  {
   case GPIO_3:
    io = gpio3;
    break;
   case GPIO_2:
    io = gpio2;
    break;
   case GPIO_0:
    io = gpio0;
    break;
   default:
    io = gpio0;
    break;
  }
  
  // Assigning ISR function
  halDigio2IntConnect(io, pF);
  // Setting rising or falling edge trigger
  halDigio2IntSetEdge(io, edge);
  return;
}
/*****************************************************************************
 * @fn          halButtonsInterruptEnable
 *
 * @brief       Enables interrupt on all buttons, high->low transition
 *
 *
 * input parameters
 *
 * output parameters
 *
 * @return      none
 */
void halButtonsInterruptEnable(void)
{
  uint8 buttonIntEnableMask = HAL_BUTTON_ALL;
  digio io;
  io.port = 2;
  io.pin  = 1;
  for (io.pin = 1; io.pin < 6; io.pin++)
  {
    halDigio2IntConnect(io, &buttonsPressedISR);
  }
  intDisabledMask &= ~buttonIntEnableMask; /* all buttons have interrupt enabled */
  BUTTON_PORT_IES &= ~buttonIntEnableMask;
  BUTTON_PORT_IE  |=  buttonIntEnableMask;
}