Ejemplo n.º 1
0
/**
  * @brief  This function handles IRDA interrupt request.
  * @param  hirda: Pointer to a IRDA_HandleTypeDef structure that contains
  *                the configuration information for the specified IRDA module.
  * @retval None
  */
void HAL_IRDA_IRQHandler(IRDA_HandleTypeDef *hirda)
{
  uint32_t  tmp_flag = 0, tmp_it_source = 0;
  
  tmp_flag = __HAL_IRDA_GET_FLAG(hirda, IRDA_FLAG_PE);
  tmp_it_source = __HAL_IRDA_GET_IT_SOURCE(hirda, IRDA_IT_PE);
  /* IRDA parity error interrupt occurred -----------------------------------*/
  if((tmp_flag != RESET) && (tmp_it_source != RESET))
  {
    hirda->ErrorCode |= HAL_IRDA_ERROR_PE;
  }

  tmp_flag = __HAL_IRDA_GET_FLAG(hirda, IRDA_FLAG_FE);
  tmp_it_source = __HAL_IRDA_GET_IT_SOURCE(hirda, IRDA_IT_ERR);
  /* IRDA frame error interrupt occurred ------------------------------------*/
  if((tmp_flag != RESET) && (tmp_it_source != RESET))
  {
    hirda->ErrorCode |= HAL_IRDA_ERROR_FE;
  }

  tmp_flag = __HAL_IRDA_GET_FLAG(hirda, IRDA_FLAG_NE);
  /* IRDA noise error interrupt occurred ------------------------------------*/
  if((tmp_flag != RESET) && (tmp_it_source != RESET))
  {
    hirda->ErrorCode |= HAL_IRDA_ERROR_NE;
  }

  tmp_flag = __HAL_IRDA_GET_FLAG(hirda, IRDA_FLAG_ORE);
  /* IRDA Over-Run interrupt occurred ---------------------------------------*/
  if((tmp_flag != RESET) && (tmp_it_source != RESET))
  {
    hirda->ErrorCode |= HAL_IRDA_ERROR_ORE;
  }

  /* Call the Error call Back in case of Errors */
  if(hirda->ErrorCode != HAL_IRDA_ERROR_NONE)
  {
    /* Disable PE and ERR interrupt */
    __HAL_IRDA_DISABLE_IT(hirda, IRDA_IT_ERR);
    __HAL_IRDA_DISABLE_IT(hirda, IRDA_IT_PE);
    __HAL_IRDA_DISABLE_IT(hirda, IRDA_IT_TXE);
    
    /* Clear all the error flag at once */
    __HAL_IRDA_CLEAR_PEFLAG(hirda);

    /* Set the IRDA state ready to be able to start again the process */
    hirda->State = HAL_IRDA_STATE_READY;
    HAL_IRDA_ErrorCallback(hirda);
  }

  tmp_flag = __HAL_IRDA_GET_FLAG(hirda, IRDA_FLAG_RXNE);
  tmp_it_source = __HAL_IRDA_GET_IT_SOURCE(hirda, IRDA_IT_RXNE);
  /* IRDA in mode Receiver --------------------------------------------------*/
  if((tmp_flag != RESET) && (tmp_it_source != RESET))
  {
    IRDA_Receive_IT(hirda);
  }

  tmp_flag = __HAL_IRDA_GET_FLAG(hirda, IRDA_FLAG_TXE);
  tmp_it_source = __HAL_IRDA_GET_IT_SOURCE(hirda, IRDA_IT_TXE);
  /* IRDA in mode Transmitter -----------------------------------------------*/
  if((tmp_flag != RESET) && (tmp_it_source != RESET))
  {
    IRDA_Transmit_IT(hirda);
  }

  tmp_flag = __HAL_IRDA_GET_FLAG(hirda, IRDA_FLAG_TC);
  tmp_it_source = __HAL_IRDA_GET_IT_SOURCE(hirda, IRDA_IT_TC);
  /* IRDA in mode Transmitter (transmission end) -----------------------------*/
  if((tmp_flag != RESET) && (tmp_it_source != RESET))
  {
    IRDA_EndTransmit_IT(hirda);
  }   
  
}
Ejemplo n.º 2
0
/**
  * @brief This function handles IRDA interrupt request.
  * @param hirda: IRDA handle
  * @retval None
  */
void HAL_IRDA_IRQHandler(IRDA_HandleTypeDef *hirda)
{
  /* IRDA parity error interrupt occurred -------------------------------------*/
  if((__HAL_IRDA_GET_IT(hirda, IRDA_IT_PE) != RESET) && (__HAL_IRDA_GET_IT_SOURCE(hirda, IRDA_IT_PE) != RESET))
  { 
    __HAL_IRDA_CLEAR_PEFLAG(hirda);

    hirda->ErrorCode |= HAL_IRDA_ERROR_PE;
    /* Set the IRDA state ready to be able to start again the process */
    hirda->State = HAL_IRDA_STATE_READY;
  }
  
  /* IRDA frame error interrupt occured --------------------------------------*/
  if((__HAL_IRDA_GET_IT(hirda, IRDA_IT_FE) != RESET) && (__HAL_IRDA_GET_IT_SOURCE(hirda, IRDA_IT_ERR) != RESET))
  { 
    __HAL_IRDA_CLEAR_FEFLAG(hirda);

    hirda->ErrorCode |= HAL_IRDA_ERROR_FE;
    /* Set the IRDA state ready to be able to start again the process */
    hirda->State = HAL_IRDA_STATE_READY;
  }
  
  /* IRDA noise error interrupt occured --------------------------------------*/
  if((__HAL_IRDA_GET_IT(hirda, IRDA_IT_NE) != RESET) && (__HAL_IRDA_GET_IT_SOURCE(hirda, IRDA_IT_ERR) != RESET))
  { 
    __HAL_IRDA_CLEAR_NEFLAG(hirda);

    hirda->ErrorCode |= HAL_IRDA_ERROR_NE; 
    /* Set the IRDA state ready to be able to start again the process */
    hirda->State = HAL_IRDA_STATE_READY;
  }
  
  /* IRDA Over-Run interrupt occured -----------------------------------------*/
  if((__HAL_IRDA_GET_IT(hirda, IRDA_IT_ORE) != RESET) && (__HAL_IRDA_GET_IT_SOURCE(hirda, IRDA_IT_ERR) != RESET))
  { 
    __HAL_IRDA_CLEAR_OREFLAG(hirda);

    hirda->ErrorCode |= HAL_IRDA_ERROR_ORE; 
    /* Set the IRDA state ready to be able to start again the process */
    hirda->State = HAL_IRDA_STATE_READY;
  }
  
  /* Call IRDA Error Call back function if need be --------------------------*/
  if(hirda->ErrorCode != HAL_IRDA_ERROR_NONE)
  {
    HAL_IRDA_ErrorCallback(hirda);
  } 

  /* IRDA in mode Receiver ---------------------------------------------------*/
  if((__HAL_IRDA_GET_IT(hirda, IRDA_IT_RXNE) != RESET) && (__HAL_IRDA_GET_IT_SOURCE(hirda, IRDA_IT_RXNE) != RESET))
  { 
    IRDA_Receive_IT(hirda);
    /* Clear RXNE interrupt flag */
    __HAL_IRDA_SEND_REQ(hirda, IRDA_RXDATA_FLUSH_REQUEST);
  }
  
  /* IRDA in mode Transmitter ------------------------------------------------*/
 if((__HAL_IRDA_GET_IT(hirda, IRDA_IT_TXE) != RESET) &&(__HAL_IRDA_GET_IT_SOURCE(hirda, IRDA_IT_TXE) != RESET))
  {
    IRDA_Transmit_IT(hirda);
  } 

 /* IRDA in mode Transmitter (transmission end) -----------------------------*/
 if((__HAL_IRDA_GET_IT(hirda, IRDA_IT_TC) != RESET) &&(__HAL_IRDA_GET_IT_SOURCE(hirda, IRDA_IT_TC) != RESET))
  {
    IRDA_EndTransmit_IT(hirda);
  }   

}
Ejemplo n.º 3
0
/**
  * @brief  This function handles IRDA interrupt request.
  * @param  hirda: pointer to a IRDA_HandleTypeDef structure that contains
  *                the configuration information for the specified IRDA module.
  * @retval None
  */
void HAL_IRDA_IRQHandler(IRDA_HandleTypeDef *hirda)
{
  uint32_t  tmp1 = 0, tmp2 =0;
  
  tmp1 = __HAL_IRDA_GET_FLAG(hirda, IRDA_FLAG_PE);
  tmp2 = __HAL_IRDA_GET_IT_SOURCE(hirda, IRDA_IT_PE);
  /* IRDA parity error interrupt occurred -------------------------------------*/
  if((tmp1 != RESET) && (tmp2 != RESET))
  { 
    __HAL_IRDA_CLEAR_PEFLAG(hirda);
    hirda->ErrorCode |= HAL_IRDA_ERROR_PE; 
  }
  
  tmp1 = __HAL_IRDA_GET_FLAG(hirda, IRDA_FLAG_FE);
  tmp2 = __HAL_IRDA_GET_IT_SOURCE(hirda, IRDA_IT_ERR);
  /* IRDA frame error interrupt occurred --------------------------------------*/
  if((tmp1 != RESET) && (tmp2 != RESET))
  { 
    __HAL_IRDA_CLEAR_FEFLAG(hirda);
    hirda->ErrorCode |= HAL_IRDA_ERROR_FE; 
  }
  
  tmp1 = __HAL_IRDA_GET_FLAG(hirda, IRDA_FLAG_NE);
  tmp2 = __HAL_IRDA_GET_IT_SOURCE(hirda, IRDA_IT_ERR);
  /* IRDA noise error interrupt occurred --------------------------------------*/
  if((tmp1 != RESET) && (tmp2 != RESET))
  { 
    __HAL_IRDA_CLEAR_NEFLAG(hirda);
    hirda->ErrorCode |= HAL_IRDA_ERROR_NE; 
  }
  
  tmp1 = __HAL_IRDA_GET_FLAG(hirda, IRDA_FLAG_ORE);
  tmp2 = __HAL_IRDA_GET_IT_SOURCE(hirda, IRDA_IT_ERR);
  /* IRDA Over-Run interrupt occurred -----------------------------------------*/
  if((tmp1 != RESET) && (tmp2 != RESET))
  { 
    __HAL_IRDA_CLEAR_OREFLAG(hirda);
    hirda->ErrorCode |= HAL_IRDA_ERROR_ORE; 
  }

  /* Call the Error call Back in case of Errors */
  if(hirda->ErrorCode != HAL_IRDA_ERROR_NONE)
  {
    /* Set the IRDA state ready to be able to start again the process */
    hirda->State = HAL_IRDA_STATE_READY;
    HAL_IRDA_ErrorCallback(hirda);
  }

  tmp1 = __HAL_IRDA_GET_FLAG(hirda, IRDA_FLAG_RXNE);
  tmp2 = __HAL_IRDA_GET_IT_SOURCE(hirda, IRDA_IT_RXNE);
  /* IRDA in mode Receiver ---------------------------------------------------*/
  if((tmp1 != RESET) && (tmp2 != RESET))
  { 
    IRDA_Receive_IT(hirda);
  }
  
  tmp1 = __HAL_IRDA_GET_FLAG(hirda, IRDA_FLAG_TXE);
  tmp2 = __HAL_IRDA_GET_IT_SOURCE(hirda, IRDA_IT_TXE);
  /* IRDA in mode Transmitter ------------------------------------------------*/
  if((tmp1 != RESET) &&(tmp2 != RESET))
  {
    IRDA_Transmit_IT(hirda);
  }
}