/**************************************************************************//**
 * @brief LESENSE_IRQHandler
 * Interrupt Service Routine for LESENSE Interrupt Line
 *****************************************************************************/
void LESENSE_IRQHandler(void)
{  
  /* Clear interrupt flag */
  LESENSE_IntClear(LESENSE_IFS_DEC);
  
  SegmentLCD_Number(++proximityCounter);
}
/**************************************************************************//**
 * @brief LESENSE_IRQHandler
 * Interrupt Service Routine for LESENSE Interrupt Line
 *****************************************************************************/
void LESENSE_IRQHandler(void)
{
  /* Read interrupts flags */
  uint32_t intFlags = LESENSE_IntGet();
  
  /* Clear interrupts */
  LESENSE_IntClear(LESENSE_IFC_DEC | LESENSE_IFC_DECERR);

  /* Enable clock for LCD. */
  CMU_ClockEnable(cmuClock_LCD, true);
  /* Wait until SYNCBUSY_CTRL flag is cleared. */
  LCD_SyncBusyDelay(LCD_SYNCBUSY_CTRL);
  /* Enable LCD. */
  LCD_Enable(true);

  /* If there is a decoder error stop trap execution in this loop */
  if (intFlags & LESENSE_IF_DECERR)
  {
    /* DECODER ERROR */
    SegmentLCD_Write(LCSENSE_ERROR_STRING);
    while (1) ;
  }

  /* Write PCNT counter number the LCD */
  SegmentLCD_Number(PCNT_CounterGet(PCNT0));

  /* Disable RTC first to reset counter */
  RTC_Enable(false);
  /* Set compare value */
  RTC_CompareSet(0, RTC_COMP_VALUE);
  /* Enable RTC */
  RTC_Enable(true);
}