Beispiel #1
0
/**
  * @brief This function handles CEC interrupt requests.
  * @param hcec: CEC handle
  * @retval None
  */
void HAL_CEC_IRQHandler(CEC_HandleTypeDef *hcec)
{
  /* Save error status register for further error handling purposes */
  hcec->ErrorCode = READ_BIT(hcec->Instance->ESR, CEC_ESR_ALL_ERROR);

  /* Transmit error */
  if(__HAL_CEC_GET_FLAG(hcec, CEC_FLAG_TERR) != RESET)
  {
    /* Acknowledgement of the error */
    __HAL_CEC_CLEAR_FLAG(hcec, CEC_FLAG_TERR);
    
    hcec->gState = HAL_CEC_STATE_READY;
  }
  
  /* Receive error */
  if(__HAL_CEC_GET_FLAG(hcec, CEC_FLAG_RERR) != RESET)
  {
    /* Acknowledgement of the error */
    __HAL_CEC_CLEAR_FLAG(hcec, CEC_FLAG_RERR);
    hcec->Init.RxBuffer-=hcec->RxXferSize;
    hcec->RxXferSize = 0U; 
    hcec->RxState = HAL_CEC_STATE_READY;
  }
  
  if((hcec->ErrorCode & CEC_ESR_ALL_ERROR) != 0U)
  {
    /* Error  Call Back */
    HAL_CEC_ErrorCallback(hcec);
  }
  
  /* Transmit byte request or block transfer finished */
  if(__HAL_CEC_GET_FLAG(hcec, CEC_FLAG_TBTRF) != RESET)
  {
    CEC_Transmit_IT(hcec);
  }

  /* Receive byte or block transfer finished */
  if(__HAL_CEC_GET_FLAG(hcec, CEC_FLAG_RBTF) != RESET)
  {
    if(hcec->RxXferSize == 0U)
    {
      /* reception is starting */ 
      hcec->RxState = HAL_CEC_STATE_BUSY_RX;
    }
    CEC_Receive_IT(hcec);
  }
}
Beispiel #2
0
/**
  * @brief This function handles CEC interrupt requests.
  * @param hcec: CEC handle
  * @retval None
  */
void HAL_CEC_IRQHandler(CEC_HandleTypeDef *hcec)
{
  /* save interrupts register for further error or interrupts handling purposes */
  hcec->ErrorCode = hcec->Instance->ISR;
  /* CEC TX missing acknowledge error interrupt occurred -------------------------------------*/
  if((__HAL_CEC_GET_FLAG(hcec, CEC_FLAG_TXACKE) != RESET) && (__HAL_CEC_GET_IT_SOURCE(hcec, CEC_IT_TXACKE) != RESET))
  { 
    __HAL_CEC_CLEAR_FLAG(hcec, CEC_FLAG_TXACKE);
    hcec->State = HAL_CEC_STATE_ERROR;
  }
  
  /* CEC transmit error interrupt occurred --------------------------------------*/
  if((__HAL_CEC_GET_FLAG(hcec, CEC_FLAG_TXERR) != RESET) && (__HAL_CEC_GET_IT_SOURCE(hcec, CEC_IT_TXERR) != RESET))
  { 
    __HAL_CEC_CLEAR_FLAG(hcec, CEC_FLAG_TXERR);
    hcec->State = HAL_CEC_STATE_ERROR;
  }
  
  /* CEC TX underrun error interrupt occurred --------------------------------------*/
  if((__HAL_CEC_GET_FLAG(hcec, CEC_FLAG_TXUDR) != RESET) && (__HAL_CEC_GET_IT_SOURCE(hcec, CEC_IT_TXUDR) != RESET))
  { 
    __HAL_CEC_CLEAR_FLAG(hcec, CEC_FLAG_TXUDR);
    hcec->State = HAL_CEC_STATE_ERROR;
  }
  
  /* CEC TX arbitration error interrupt occurred --------------------------------------*/
  if((__HAL_CEC_GET_FLAG(hcec, CEC_FLAG_ARBLST) != RESET) && (__HAL_CEC_GET_IT_SOURCE(hcec, CEC_IT_ARBLST) != RESET))
  { 
    __HAL_CEC_CLEAR_FLAG(hcec, CEC_FLAG_ARBLST);
    hcec->State = HAL_CEC_STATE_ERROR;
  }
  
  /* CEC RX overrun error interrupt occurred --------------------------------------*/
  if((__HAL_CEC_GET_FLAG(hcec, CEC_FLAG_RXOVR) != RESET) && (__HAL_CEC_GET_IT_SOURCE(hcec, CEC_IT_RXOVR) != RESET))
  { 
    __HAL_CEC_CLEAR_FLAG(hcec, CEC_FLAG_RXOVR);
    hcec->State = HAL_CEC_STATE_ERROR;
  } 
  
  /* CEC RX bit rising error interrupt occurred --------------------------------------*/
  if((__HAL_CEC_GET_FLAG(hcec, CEC_FLAG_BRE) != RESET) && (__HAL_CEC_GET_IT_SOURCE(hcec, CEC_IT_BRE) != RESET))
  { 
    __HAL_CEC_CLEAR_FLAG(hcec, CEC_FLAG_BRE);
    hcec->State = HAL_CEC_STATE_ERROR;
  }   
  
  /* CEC RX short bit period error interrupt occurred --------------------------------------*/
  if((__HAL_CEC_GET_FLAG(hcec, CEC_FLAG_SBPE) != RESET) && (__HAL_CEC_GET_IT_SOURCE(hcec, CEC_IT_SBPE) != RESET))
  { 
    __HAL_CEC_CLEAR_FLAG(hcec, CEC_FLAG_SBPE);
    hcec->State = HAL_CEC_STATE_ERROR;
  }   
  
  /* CEC RX long bit period error interrupt occurred --------------------------------------*/
  if((__HAL_CEC_GET_FLAG(hcec, CEC_FLAG_LBPE) != RESET) && (__HAL_CEC_GET_IT_SOURCE(hcec, CEC_IT_LBPE) != RESET))
  { 
    __HAL_CEC_CLEAR_FLAG(hcec, CEC_FLAG_LBPE);
    hcec->State = HAL_CEC_STATE_ERROR;
  }   
  
  /* CEC RX missing acknowledge error interrupt occurred --------------------------------------*/
  if((__HAL_CEC_GET_FLAG(hcec, CEC_FLAG_RXACKE) != RESET) && (__HAL_CEC_GET_IT_SOURCE(hcec, CEC_IT_RXACKE) != RESET))
  { 
    __HAL_CEC_CLEAR_FLAG(hcec, CEC_FLAG_RXACKE);
    hcec->State = HAL_CEC_STATE_ERROR;
  }   

  if ((hcec->ErrorCode & CEC_ISR_ALL_ERROR) != 0)
  {
    HAL_CEC_ErrorCallback(hcec);
  }

  /* CEC RX byte received interrupt  ---------------------------------------------------*/
  if((__HAL_CEC_GET_FLAG(hcec, CEC_FLAG_RXBR) != RESET) && (__HAL_CEC_GET_IT_SOURCE(hcec, CEC_IT_RXBR) != RESET))
  { 
    /* RXBR IT is cleared during HAL_CEC_Transmit_IT processing */
    CEC_Receive_IT(hcec);
  }
  
  /* CEC RX end received interrupt  ---------------------------------------------------*/
  if((__HAL_CEC_GET_FLAG(hcec, CEC_FLAG_RXEND) != RESET) && (__HAL_CEC_GET_IT_SOURCE(hcec, CEC_IT_RXEND) != RESET))
  { 
    /* RXBR IT is cleared during HAL_CEC_Transmit_IT processing */
    CEC_Receive_IT(hcec);
  }
  
  
  /* CEC TX byte request interrupt ------------------------------------------------*/
  if((__HAL_CEC_GET_FLAG(hcec, CEC_FLAG_TXBR) != RESET) &&(__HAL_CEC_GET_IT_SOURCE(hcec, CEC_IT_TXBR) != RESET))
  {
    /* TXBR IT is cleared during HAL_CEC_Transmit_IT processing */
    CEC_Transmit_IT(hcec);
  } 
  
  /* CEC TX end interrupt ------------------------------------------------*/
  if((__HAL_CEC_GET_FLAG(hcec, CEC_FLAG_TXEND) != RESET) &&(__HAL_CEC_GET_IT_SOURCE(hcec, CEC_IT_TXEND) != RESET))
  {
   /* TXEND IT is cleared during HAL_CEC_Transmit_IT processing */
    CEC_Transmit_IT(hcec);
  } 
}
/**
  * @brief This function handles CEC interrupt requests.
  * @param hcec: CEC handle
  * @retval None
  */
void HAL_CEC_IRQHandler(CEC_HandleTypeDef *hcec)
{
  /* Save error status register for further error handling purposes */
  hcec->ErrorCode = READ_BIT(hcec->Instance->ESR, CEC_ESR_ALL_ERROR);

  /* Transmit error */
  if((__HAL_CEC_GET_FLAG(hcec, CEC_FLAG_TERR) != RESET))
  {
    /* Acknowledgement of the error */
    __HAL_CEC_CLEAR_FLAG(hcec, CEC_FLAG_TERR);
    
    /* Check if a receive process is ongoing or not */
    if(hcec->State == HAL_CEC_STATE_BUSY_TX_RX) 
    {
      /* Interrupts are not disabled due to reception still ongoing */
      
      hcec->State = HAL_CEC_STATE_BUSY_RX;
    }
    else
    {
      /* Disable the CEC Transmission Interrupts */
      __HAL_CEC_DISABLE_IT(hcec, CEC_IT_IE);
    
      hcec->State = HAL_CEC_STATE_READY;
    }    
  }
  
  /* Receive error */
  if((__HAL_CEC_GET_FLAG(hcec, CEC_FLAG_RERR) != RESET))
  {
    /* Acknowledgement of the error */
    __HAL_CEC_CLEAR_FLAG(hcec, CEC_FLAG_RERR);
    
    /* Check if a transmit process is ongoing or not */
    if(hcec->State == HAL_CEC_STATE_BUSY_TX_RX) 
    {
      /* Interrupts are not disabled due to reception still ongoing */
      
      hcec->State = HAL_CEC_STATE_BUSY_TX;
    }
    else
    {
      /* Disable the CEC Transmission Interrupts */
      __HAL_CEC_DISABLE_IT(hcec, CEC_IT_IE);
      
      hcec->State = HAL_CEC_STATE_READY;
    }
  } 
  
  if ((hcec->ErrorCode & CEC_ESR_ALL_ERROR) != 0)
  {
    HAL_CEC_ErrorCallback(hcec);
  }
  
  /* Transmit byte request or block transfer finished */
  if((__HAL_CEC_GET_FLAG(hcec, CEC_FLAG_TBTRF) != RESET))
  {
    CEC_Transmit_IT(hcec);
  }  

  /* Receive byte or block transfer finished */
  if((__HAL_CEC_GET_FLAG(hcec, CEC_FLAG_RBTF) != RESET))
  {
    CEC_Receive_IT(hcec);
  }
}