HAL_CAN_Transmit_IT and HAL_CAN_Receive_IT simultaneously use problem
For rearm RX you can use __HAL_CAN_ENABLE_IT(&amp;hcan, CAN_IT_FMP0); // set interrupt flag for RX FIFO0.

void HAL_CAN_RxCpltCallback(CAN_HandleTypeDef *CanHandle)
{
   __HAL_CAN_ENABLE_IT(CanHandle, CAN_IT_FMP0);

}


or

void HAL_CAN_RxCpltCallback(CAN_HandleTypeDef *CanHandle)
{

  if (HAL_CAN_Receive_IT(CanHandle, CAN_FIFO0) != HAL_OK)
  {
    __HAL_CAN_ENABLE_IT(CanHandle, CAN_IT_FMP0);  // set interrupt flag for RX FIFO0 if CAN locked
  }
}


cause, for example, stm32f1xx_hal_can.c:

HAL_StatusTypeDef HAL_CAN_Receive_IT(CAN_HandleTypeDef* hcan, uint8_t FIFONumber)
{
  /* Check the parameters */
  assert_param(IS_CAN_FIFO(FIFONumber));

  if((hcan-&gt;State == HAL_CAN_STATE_READY) || (hcan-&gt;State == HAL_CAN_STATE_BUSY_TX))
  {
    /* Process locked */
    __HAL_LOCK(hcan);                 // &lt;&lt;----see define of __HAL_LOCK, this contains return command, wtf????????


    if(hcan-&gt;State == HAL_CAN_STATE_BUSY_TX) 
    {
      /* Change CAN state */
      hcan-&gt;State = HAL_CAN_STATE_BUSY_TX_RX;
    }
    else
    {
      /* Change CAN state */
      hcan-&gt;State = HAL_CAN_STATE_BUSY_RX;
    }

    /* Set CAN error code to none */
    hcan-&gt;ErrorCode = HAL_CAN_ERROR_NONE;

    /* Enable interrupts: */
    /*  - Enable Error warning Interrupt */
    /*  - Enable Error passive Interrupt */
    /*  - Enable Bus-off Interrupt */
    /*  - Enable Last error code Interrupt */
    /*  - Enable Error Interrupt */
    /*  - Enable Transmit mailbox empty Interrupt */
    __HAL_CAN_ENABLE_IT(hcan, CAN_IT_EWG |
                              CAN_IT_EPV |
                              CAN_IT_BOF |
                              CAN_IT_LEC |
                              CAN_IT_ERR |
                              CAN_IT_TME  );   
    /* Process unlocked */
    __HAL_UNLOCK(hcan);

    if(FIFONumber == CAN_FIFO0)
    {
      /* Enable FIFO 0 message pending Interrupt */   
      __HAL_CAN_ENABLE_IT(hcan, CAN_IT_FMP0);         // &lt;&lt;---- here the rearm interrupt flag for FIFO0, if can is locked, function exits on  __HAL_LOCK and newer comes here!
    }
    else
    {
      /* Enable FIFO 1 message pending Interrupt */
      __HAL_CAN_ENABLE_IT(hcan, CAN_IT_FMP1);
    }

  }
  else
  {
    return HAL_BUSY;
  }

  /* Return function status */
  return HAL_OK;
}