/**
* @brief  This function handles External lines 9 to 5 interrupt request.
* @param  None
* @retval None
*/
void EXTI9_5_IRQHandler(void)
{  
  /* Check the flag status of EXTI line */
  if(EXTI_GetFlagStatus(UP_BUTTON_V2_EXTI_LINE))
  {    
    Set_UPStatus();
    /* Clear the EXTI line flag */
    EXTI_ClearFlag(UP_BUTTON_V2_EXTI_LINE);
  }
  if(EXTI_GetFlagStatus(LEFT_BUTTON_V3_EXTI_LINE))
  {    
    Set_UPStatus();
    /* Clear the EXTI line flag */
    EXTI_ClearFlag(LEFT_BUTTON_V3_EXTI_LINE);
  }
  /* Check the flag status of EXTI line */
  if(EXTI_GetITStatus(KEY_BUTTON_EXTI_LINE))
  {    
    Set_KeyStatus();
    /* Clear the EXTI line flag */
    EXTI_ClearITPendingBit(KEY_BUTTON_EXTI_LINE);
  }
  if(EXTI_GetITStatus(SCM_PS_BUTTON_EXTI_LINE))
  {
    Set_KeyStatus();
    /* Clear the EXTI line flag */
    EXTI_ClearITPendingBit(SCM_PS_BUTTON_EXTI_LINE);
  }
  
}
/**
* @brief  This function handles External lines 15 to 4 interrupt request.
* @param  None
* @retval None
*/
void EXTI4_15_IRQHandler(void)
{
  /* EXTI line 7 interrupt detected */
  if(__HAL_GPIO_EXTI_GET_IT(RADIO_GPIO_3_EXTI_LINE) != RESET) 
  { 
    __HAL_GPIO_EXTI_CLEAR_IT(RADIO_GPIO_3_EXTI_LINE);
       
    P2PInterruptHandler();
  } 
  
  /* EXTI line 13 interrupt detected */
#ifndef  LPM_ENABLE
  
  if(__HAL_GPIO_EXTI_GET_IT(KEY_BUTTON_EXTI_LINE) != RESET) 
  { 
    __HAL_GPIO_EXTI_CLEAR_IT(KEY_BUTTON_EXTI_LINE);
    
    Set_KeyStatus(SET);
  }
  
#else /*Low Power mode enabled*/ 
  
#if defined(RF_STANDBY)/*if spirit1 is in standby*/
  
  if(EXTI->PR & KEY_BUTTON_EXTI_LINE)
  {
    HAL_GPIO_EXTI_Callback(KEY_BUTTON_EXTI_LINE);
    /* EXTI line 13 interrupt detected */
    if(HAL_GPIO_ReadPin(KEY_BUTTON_GPIO_PORT, KEY_BUTTON_PIN) == 0x01) 
    {
      HAL_GPIO_EXTI_Callback(KEY_BUTTON_EXTI_LINE);
      
      PushButtonStatusWakeup = SET;
      PushButtonStatusData = RESET;
      wakeupCounter = LPM_WAKEUP_TIME; 
      dataSendCounter = DATA_SEND_TIME;
      dataSendCounter++;
    }
    __HAL_GPIO_EXTI_CLEAR_IT(KEY_BUTTON_EXTI_LINE);
  } 
#else /*if spirit1 is not in standby or sleep mode but MCU is in LPM*/
  
  if(__HAL_GPIO_EXTI_GET_IT(KEY_BUTTON_EXTI_LINE) != RESET) 
  { 
    __HAL_GPIO_EXTI_CLEAR_IT(KEY_BUTTON_EXTI_LINE);
    
    HAL_GPIO_EXTI_Callback(KEY_BUTTON_EXTI_LINE);
    
    Set_KeyStatus(SET);
  }
#endif
#endif
}
/**
* @brief  This function handles External line 2 interrupt request.
* @param  None
* @retval None
*/
void EXTI2_IRQHandler(void)
{
#if (DEVICE_TYPE == METER)
  if(0x00 == GPIO_ReadInputDataBit(SCM_PS_BUTTON_VD1_GPIO_PORT, SCM_PS_BUTTON_VD1_PIN))
  {
    Set_DOWNStatus();
    /* Clear the Up Button EXTI line pending bit */
    EXTI_ClearITPendingBit(SCM_PS_BUTTON_VD1_EXTI_LINE); 
  }
#else
  /* Check the flag status of EXTI line */
  if(EXTI_GetITStatus(SCM_PS_BUTTON_VD1_EXTI_LINE))
  {    
    Set_KeyStatus();
    /* Clear the EXTI line flag */
    EXTI_ClearITPendingBit(SCM_PS_BUTTON_VD1_EXTI_LINE);
  } 
#endif
}