STM32L4xx_HAL_Driver  1.14.0

IRDA Transmit and Receive functions. More...

Functions

HAL_StatusTypeDef HAL_IRDA_Transmit (IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size, uint32_t Timeout)
 Send an amount of data in blocking mode. More...
 
HAL_StatusTypeDef HAL_IRDA_Receive (IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size, uint32_t Timeout)
 Receive an amount of data in blocking mode. More...
 
HAL_StatusTypeDef HAL_IRDA_Transmit_IT (IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size)
 Send an amount of data in interrupt mode. More...
 
HAL_StatusTypeDef HAL_IRDA_Receive_IT (IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size)
 Receive an amount of data in interrupt mode. More...
 
HAL_StatusTypeDef HAL_IRDA_Transmit_DMA (IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size)
 Send an amount of data in DMA mode. More...
 
HAL_StatusTypeDef HAL_IRDA_Receive_DMA (IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size)
 Receive an amount of data in DMA mode. More...
 
HAL_StatusTypeDef HAL_IRDA_DMAPause (IRDA_HandleTypeDef *hirda)
 Pause the DMA Transfer. More...
 
HAL_StatusTypeDef HAL_IRDA_DMAResume (IRDA_HandleTypeDef *hirda)
 Resume the DMA Transfer. More...
 
HAL_StatusTypeDef HAL_IRDA_DMAStop (IRDA_HandleTypeDef *hirda)
 Stop the DMA Transfer. More...
 
HAL_StatusTypeDef HAL_IRDA_Abort (IRDA_HandleTypeDef *hirda)
 Abort ongoing transfers (blocking mode). More...
 
HAL_StatusTypeDef HAL_IRDA_AbortTransmit (IRDA_HandleTypeDef *hirda)
 Abort ongoing Transmit transfer (blocking mode). More...
 
HAL_StatusTypeDef HAL_IRDA_AbortReceive (IRDA_HandleTypeDef *hirda)
 Abort ongoing Receive transfer (blocking mode). More...
 
HAL_StatusTypeDef HAL_IRDA_Abort_IT (IRDA_HandleTypeDef *hirda)
 Abort ongoing transfers (Interrupt mode). More...
 
HAL_StatusTypeDef HAL_IRDA_AbortTransmit_IT (IRDA_HandleTypeDef *hirda)
 Abort ongoing Transmit transfer (Interrupt mode). More...
 
HAL_StatusTypeDef HAL_IRDA_AbortReceive_IT (IRDA_HandleTypeDef *hirda)
 Abort ongoing Receive transfer (Interrupt mode). More...
 
void HAL_IRDA_IRQHandler (IRDA_HandleTypeDef *hirda)
 Handle IRDA interrupt request. More...
 
void HAL_IRDA_TxCpltCallback (IRDA_HandleTypeDef *hirda)
 Tx Transfer completed callback. More...
 
void HAL_IRDA_RxCpltCallback (IRDA_HandleTypeDef *hirda)
 Rx Transfer completed callback. More...
 
void HAL_IRDA_TxHalfCpltCallback (IRDA_HandleTypeDef *hirda)
 Tx Half Transfer completed callback. More...
 
void HAL_IRDA_RxHalfCpltCallback (IRDA_HandleTypeDef *hirda)
 Rx Half Transfer complete callback. More...
 
void HAL_IRDA_ErrorCallback (IRDA_HandleTypeDef *hirda)
 IRDA error callback. More...
 
void HAL_IRDA_AbortCpltCallback (IRDA_HandleTypeDef *hirda)
 IRDA Abort Complete callback. More...
 
void HAL_IRDA_AbortTransmitCpltCallback (IRDA_HandleTypeDef *hirda)
 IRDA Abort Complete callback. More...
 
void HAL_IRDA_AbortReceiveCpltCallback (IRDA_HandleTypeDef *hirda)
 IRDA Abort Receive Complete callback. More...
 

Detailed Description

IRDA Transmit and Receive functions.

 ===============================================================================
                         ##### IO operation functions #####
 ===============================================================================
  [..]
    This subsection provides a set of functions allowing to manage the IRDA data transfers.

  [..]
    IrDA is a half duplex communication protocol. If the Transmitter is busy, any data
    on the IrDA receive line will be ignored by the IrDA decoder and if the Receiver
    is busy, data on the TX from the USART to IrDA will not be encoded by IrDA.
    While receiving data, transmission should be avoided as the data to be transmitted
    could be corrupted.

    (#) There are two modes of transfer:
        (++) Blocking mode: the communication is performed in polling mode.
             The HAL status of all data processing is returned by the same function
             after finishing transfer.
        (++) Non-Blocking mode: the communication is performed using Interrupts
             or DMA, these API's return the HAL status.
             The end of the data processing will be indicated through the
             dedicated IRDA IRQ when using Interrupt mode or the DMA IRQ when
             using DMA mode.
             The HAL_IRDA_TxCpltCallback(), HAL_IRDA_RxCpltCallback() user callbacks
             will be executed respectively at the end of the Transmit or Receive process
             The HAL_IRDA_ErrorCallback() user callback will be executed when a communication error is detected

    (#) Blocking mode APIs are :
        (++) HAL_IRDA_Transmit()
        (++) HAL_IRDA_Receive()

    (#) Non Blocking mode APIs with Interrupt are :
        (++) HAL_IRDA_Transmit_IT()
        (++) HAL_IRDA_Receive_IT()
        (++) HAL_IRDA_IRQHandler()

    (#) Non Blocking mode functions with DMA are :
        (++) HAL_IRDA_Transmit_DMA()
        (++) HAL_IRDA_Receive_DMA()
        (++) HAL_IRDA_DMAPause()
        (++) HAL_IRDA_DMAResume()
        (++) HAL_IRDA_DMAStop()

    (#) A set of Transfer Complete Callbacks are provided in Non Blocking mode:
        (++) HAL_IRDA_TxHalfCpltCallback()
        (++) HAL_IRDA_TxCpltCallback()
        (++) HAL_IRDA_RxHalfCpltCallback()
        (++) HAL_IRDA_RxCpltCallback()
        (++) HAL_IRDA_ErrorCallback()

    (#) Non-Blocking mode transfers could be aborted using Abort API's :
        (+) HAL_IRDA_Abort()
        (+) HAL_IRDA_AbortTransmit()
        (+) HAL_IRDA_AbortReceive()
        (+) HAL_IRDA_Abort_IT()
        (+) HAL_IRDA_AbortTransmit_IT()
        (+) HAL_IRDA_AbortReceive_IT()

    (#) For Abort services based on interrupts (HAL_IRDA_Abortxxx_IT), a set of Abort Complete Callbacks are provided:
        (+) HAL_IRDA_AbortCpltCallback()
        (+) HAL_IRDA_AbortTransmitCpltCallback()
        (+) HAL_IRDA_AbortReceiveCpltCallback()

    (#) In Non-Blocking mode transfers, possible errors are split into 2 categories.
        Errors are handled as follows :
        (+) Error is considered as Recoverable and non blocking : Transfer could go till end, but error severity is
            to be evaluated by user : this concerns Frame Error, Parity Error or Noise Error in Interrupt mode reception .
            Received character is then retrieved and stored in Rx buffer, Error code is set to allow user to identify error type,
            and HAL_IRDA_ErrorCallback() user callback is executed. Transfer is kept ongoing on IRDA side.
            If user wants to abort it, Abort services should be called by user.
        (+) Error is considered as Blocking : Transfer could not be completed properly and is aborted.
            This concerns Overrun Error In Interrupt mode reception and all errors in DMA mode.
            Error code is set to allow user to identify error type, and HAL_IRDA_ErrorCallback() user callback is executed.

Function Documentation

◆ HAL_IRDA_Abort()

HAL_StatusTypeDef HAL_IRDA_Abort ( IRDA_HandleTypeDef hirda)

Abort ongoing transfers (blocking mode).

Parameters
hirdaPointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified UART module.
Note
This procedure could be used for aborting any ongoing transfer started in Interrupt or DMA mode. This procedure performs following operations :
  • Disable IRDA Interrupts (Tx and Rx)
  • Disable the DMA transfer in the peripheral register (if enabled)
  • Abort DMA transfer by calling HAL_DMA_Abort (in case of transfer in DMA mode)
  • Set handle State to READY
This procedure is executed in blocking mode : when exiting function, Abort is considered as completed.
Return values
HALstatus

Definition at line 1378 of file stm32l4xx_hal_irda.c.

1379 {
1380  /* Disable TXEIE, TCIE, RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts */
1381 #if defined(USART_CR1_FIFOEN)
1382  CLEAR_BIT(hirda->Instance->CR1, (USART_CR1_RXNEIE_RXFNEIE | USART_CR1_PEIE | USART_CR1_TXEIE_TXFNFIE | USART_CR1_TCIE));
1383 #else
1384  CLEAR_BIT(hirda->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE | USART_CR1_TXEIE | USART_CR1_TCIE));
1385 #endif /* USART_CR1_FIFOEN */
1386  CLEAR_BIT(hirda->Instance->CR3, USART_CR3_EIE);
1387 
1388  /* Disable the IRDA DMA Tx request if enabled */
1389  if (HAL_IS_BIT_SET(hirda->Instance->CR3, USART_CR3_DMAT))
1390  {
1391  CLEAR_BIT(hirda->Instance->CR3, USART_CR3_DMAT);
1392 
1393  /* Abort the IRDA DMA Tx channel : use blocking DMA Abort API (no callback) */
1394  if (hirda->hdmatx != NULL)
1395  {
1396  /* Set the IRDA DMA Abort callback to Null.
1397  No call back execution at end of DMA abort procedure */
1398  hirda->hdmatx->XferAbortCallback = NULL;
1399 
1400  if (HAL_DMA_Abort(hirda->hdmatx) != HAL_OK)
1401  {
1402  if (HAL_DMA_GetError(hirda->hdmatx) == HAL_DMA_ERROR_TIMEOUT)
1403  {
1404  /* Set error code to DMA */
1405  hirda->ErrorCode = HAL_IRDA_ERROR_DMA;
1406 
1407  return HAL_TIMEOUT;
1408  }
1409  }
1410  }
1411  }
1412 
1413  /* Disable the IRDA DMA Rx request if enabled */
1414  if (HAL_IS_BIT_SET(hirda->Instance->CR3, USART_CR3_DMAR))
1415  {
1416  CLEAR_BIT(hirda->Instance->CR3, USART_CR3_DMAR);
1417 
1418  /* Abort the IRDA DMA Rx channel : use blocking DMA Abort API (no callback) */
1419  if (hirda->hdmarx != NULL)
1420  {
1421  /* Set the IRDA DMA Abort callback to Null.
1422  No call back execution at end of DMA abort procedure */
1423  hirda->hdmarx->XferAbortCallback = NULL;
1424 
1425  if (HAL_DMA_Abort(hirda->hdmarx) != HAL_OK)
1426  {
1427  if (HAL_DMA_GetError(hirda->hdmarx) == HAL_DMA_ERROR_TIMEOUT)
1428  {
1429  /* Set error code to DMA */
1430  hirda->ErrorCode = HAL_IRDA_ERROR_DMA;
1431 
1432  return HAL_TIMEOUT;
1433  }
1434  }
1435  }
1436  }
1437 
1438  /* Reset Tx and Rx transfer counters */
1439  hirda->TxXferCount = 0U;
1440  hirda->RxXferCount = 0U;
1441 
1442  /* Clear the Error flags in the ICR register */
1443  __HAL_IRDA_CLEAR_FLAG(hirda, IRDA_CLEAR_OREF | IRDA_CLEAR_NEF | IRDA_CLEAR_PEF | IRDA_CLEAR_FEF);
1444 
1445  /* Restore hirda->gState and hirda->RxState to Ready */
1446  hirda->gState = HAL_IRDA_STATE_READY;
1447  hirda->RxState = HAL_IRDA_STATE_READY;
1448 
1449  /* Reset Handle ErrorCode to No Error */
1450  hirda->ErrorCode = HAL_IRDA_ERROR_NONE;
1451 
1452  return HAL_OK;
1453 }
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
return HAL_OK
HAL_StatusTypeDef HAL_DMA_Abort(DMA_HandleTypeDef *hdma)
Abort the DMA Transfer.
uint32_t HAL_DMA_GetError(DMA_HandleTypeDef *hdma)
Return the DMA error code.

◆ HAL_IRDA_Abort_IT()

HAL_StatusTypeDef HAL_IRDA_Abort_IT ( IRDA_HandleTypeDef hirda)

Abort ongoing transfers (Interrupt mode).

Parameters
hirdaPointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified UART module.
Note
This procedure could be used for aborting any ongoing transfer started in Interrupt or DMA mode. This procedure performs following operations :
  • Disable IRDA Interrupts (Tx and Rx)
  • Disable the DMA transfer in the peripheral register (if enabled)
  • Abort DMA transfer by calling HAL_DMA_Abort_IT (in case of transfer in DMA mode)
  • Set handle State to READY
  • At abort completion, call user abort complete callback
This procedure is executed in Interrupt mode, meaning that abort procedure could be considered as completed only when user abort complete callback is executed (not when exiting function).
Return values
HALstatus

Definition at line 1586 of file stm32l4xx_hal_irda.c.

1587 {
1588  uint32_t abortcplt = 1U;
1589 
1590  /* Disable TXEIE, TCIE, RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts */
1591 #if defined(USART_CR1_FIFOEN)
1592  CLEAR_BIT(hirda->Instance->CR1, (USART_CR1_RXNEIE_RXFNEIE | USART_CR1_PEIE | USART_CR1_TXEIE_TXFNFIE | USART_CR1_TCIE));
1593 #else
1594  CLEAR_BIT(hirda->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE | USART_CR1_TXEIE | USART_CR1_TCIE));
1595 #endif /* USART_CR1_FIFOEN */
1596  CLEAR_BIT(hirda->Instance->CR3, USART_CR3_EIE);
1597 
1598  /* If DMA Tx and/or DMA Rx Handles are associated to IRDA Handle, DMA Abort complete callbacks should be initialised
1599  before any call to DMA Abort functions */
1600  /* DMA Tx Handle is valid */
1601  if (hirda->hdmatx != NULL)
1602  {
1603  /* Set DMA Abort Complete callback if IRDA DMA Tx request if enabled.
1604  Otherwise, set it to NULL */
1605  if (HAL_IS_BIT_SET(hirda->Instance->CR3, USART_CR3_DMAT))
1606  {
1607  hirda->hdmatx->XferAbortCallback = IRDA_DMATxAbortCallback;
1608  }
1609  else
1610  {
1611  hirda->hdmatx->XferAbortCallback = NULL;
1612  }
1613  }
1614  /* DMA Rx Handle is valid */
1615  if (hirda->hdmarx != NULL)
1616  {
1617  /* Set DMA Abort Complete callback if IRDA DMA Rx request if enabled.
1618  Otherwise, set it to NULL */
1619  if (HAL_IS_BIT_SET(hirda->Instance->CR3, USART_CR3_DMAR))
1620  {
1621  hirda->hdmarx->XferAbortCallback = IRDA_DMARxAbortCallback;
1622  }
1623  else
1624  {
1625  hirda->hdmarx->XferAbortCallback = NULL;
1626  }
1627  }
1628 
1629  /* Disable the IRDA DMA Tx request if enabled */
1630  if (HAL_IS_BIT_SET(hirda->Instance->CR3, USART_CR3_DMAT))
1631  {
1632  /* Disable DMA Tx at UART level */
1633  CLEAR_BIT(hirda->Instance->CR3, USART_CR3_DMAT);
1634 
1635  /* Abort the IRDA DMA Tx channel : use non blocking DMA Abort API (callback) */
1636  if (hirda->hdmatx != NULL)
1637  {
1638  /* IRDA Tx DMA Abort callback has already been initialised :
1639  will lead to call HAL_IRDA_AbortCpltCallback() at end of DMA abort procedure */
1640 
1641  /* Abort DMA TX */
1642  if (HAL_DMA_Abort_IT(hirda->hdmatx) != HAL_OK)
1643  {
1644  hirda->hdmatx->XferAbortCallback = NULL;
1645  }
1646  else
1647  {
1648  abortcplt = 0U;
1649  }
1650  }
1651  }
1652 
1653  /* Disable the IRDA DMA Rx request if enabled */
1654  if (HAL_IS_BIT_SET(hirda->Instance->CR3, USART_CR3_DMAR))
1655  {
1656  CLEAR_BIT(hirda->Instance->CR3, USART_CR3_DMAR);
1657 
1658  /* Abort the IRDA DMA Rx channel : use non blocking DMA Abort API (callback) */
1659  if (hirda->hdmarx != NULL)
1660  {
1661  /* IRDA Rx DMA Abort callback has already been initialised :
1662  will lead to call HAL_IRDA_AbortCpltCallback() at end of DMA abort procedure */
1663 
1664  /* Abort DMA RX */
1665  if (HAL_DMA_Abort_IT(hirda->hdmarx) != HAL_OK)
1666  {
1667  hirda->hdmarx->XferAbortCallback = NULL;
1668  abortcplt = 1U;
1669  }
1670  else
1671  {
1672  abortcplt = 0U;
1673  }
1674  }
1675  }
1676 
1677  /* if no DMA abort complete callback execution is required => call user Abort Complete callback */
1678  if (abortcplt == 1U)
1679  {
1680  /* Reset Tx and Rx transfer counters */
1681  hirda->TxXferCount = 0U;
1682  hirda->RxXferCount = 0U;
1683 
1684  /* Reset errorCode */
1685  hirda->ErrorCode = HAL_IRDA_ERROR_NONE;
1686 
1687  /* Clear the Error flags in the ICR register */
1688  __HAL_IRDA_CLEAR_FLAG(hirda, IRDA_CLEAR_OREF | IRDA_CLEAR_NEF | IRDA_CLEAR_PEF | IRDA_CLEAR_FEF);
1689 
1690  /* Restore hirda->gState and hirda->RxState to Ready */
1691  hirda->gState = HAL_IRDA_STATE_READY;
1692  hirda->RxState = HAL_IRDA_STATE_READY;
1693 
1694  /* As no DMA to be aborted, call directly user Abort complete callback */
1695 #if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
1696  /* Call registered Abort complete callback */
1697  hirda->AbortCpltCallback(hirda);
1698 #else
1699  /* Call legacy weak Abort complete callback */
1701 #endif /* USE_HAL_IRDA_REGISTER_CALLBACK */
1702  }
1703 
1704  return HAL_OK;
1705 }
static void IRDA_DMATxAbortCallback(DMA_HandleTypeDef *hdma)
DMA IRDA Tx communication abort callback, when initiated by user (To be called at end of DMA Tx Abort...
HAL_StatusTypeDef HAL_DMA_Abort_IT(DMA_HandleTypeDef *hdma)
Aborts the DMA Transfer in Interrupt mode.
static void IRDA_DMARxAbortCallback(DMA_HandleTypeDef *hdma)
DMA IRDA Rx communication abort callback, when initiated by user (To be called at end of DMA Rx Abort...
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
return HAL_OK
void HAL_IRDA_AbortCpltCallback(IRDA_HandleTypeDef *hirda)
IRDA Abort Complete callback.

◆ HAL_IRDA_AbortCpltCallback()

__weak void HAL_IRDA_AbortCpltCallback ( IRDA_HandleTypeDef hirda)

IRDA Abort Complete callback.

Parameters
hirdaPointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified IRDA module.
Return values
None

Definition at line 2144 of file stm32l4xx_hal_irda.c.

2145 {
2146  /* Prevent unused argument(s) compilation warning */
2147  UNUSED(hirda);
2148 
2149  /* NOTE : This function should not be modified, when the callback is needed,
2150  the HAL_IRDA_AbortCpltCallback can be implemented in the user file.
2151  */
2152 }

◆ HAL_IRDA_AbortReceive()

HAL_StatusTypeDef HAL_IRDA_AbortReceive ( IRDA_HandleTypeDef hirda)

Abort ongoing Receive transfer (blocking mode).

Parameters
hirdaPointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified UART module.
Note
This procedure could be used for aborting any ongoing Rx transfer started in Interrupt or DMA mode. This procedure performs following operations :
  • Disable IRDA Interrupts (Rx)
  • Disable the DMA transfer in the peripheral register (if enabled)
  • Abort DMA transfer by calling HAL_DMA_Abort (in case of transfer in DMA mode)
  • Set handle State to READY
This procedure is executed in blocking mode : when exiting function, Abort is considered as completed.
Return values
HALstatus

Definition at line 1524 of file stm32l4xx_hal_irda.c.

1525 {
1526  /* Disable RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts */
1527 #if defined(USART_CR1_FIFOEN)
1528  CLEAR_BIT(hirda->Instance->CR1, (USART_CR1_RXNEIE_RXFNEIE | USART_CR1_PEIE));
1529 #else
1530  CLEAR_BIT(hirda->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE));
1531 #endif /* USART_CR1_FIFOEN */
1532  CLEAR_BIT(hirda->Instance->CR3, USART_CR3_EIE);
1533 
1534  /* Disable the IRDA DMA Rx request if enabled */
1535  if (HAL_IS_BIT_SET(hirda->Instance->CR3, USART_CR3_DMAR))
1536  {
1537  CLEAR_BIT(hirda->Instance->CR3, USART_CR3_DMAR);
1538 
1539  /* Abort the IRDA DMA Rx channel : use blocking DMA Abort API (no callback) */
1540  if (hirda->hdmarx != NULL)
1541  {
1542  /* Set the IRDA DMA Abort callback to Null.
1543  No call back execution at end of DMA abort procedure */
1544  hirda->hdmarx->XferAbortCallback = NULL;
1545 
1546  if (HAL_DMA_Abort(hirda->hdmarx) != HAL_OK)
1547  {
1548  if (HAL_DMA_GetError(hirda->hdmarx) == HAL_DMA_ERROR_TIMEOUT)
1549  {
1550  /* Set error code to DMA */
1551  hirda->ErrorCode = HAL_IRDA_ERROR_DMA;
1552 
1553  return HAL_TIMEOUT;
1554  }
1555  }
1556  }
1557  }
1558 
1559  /* Reset Rx transfer counter */
1560  hirda->RxXferCount = 0U;
1561 
1562  /* Clear the Error flags in the ICR register */
1563  __HAL_IRDA_CLEAR_FLAG(hirda, IRDA_CLEAR_OREF | IRDA_CLEAR_NEF | IRDA_CLEAR_PEF | IRDA_CLEAR_FEF);
1564 
1565  /* Restore hirda->RxState to Ready */
1566  hirda->RxState = HAL_IRDA_STATE_READY;
1567 
1568  return HAL_OK;
1569 }
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
return HAL_OK
HAL_StatusTypeDef HAL_DMA_Abort(DMA_HandleTypeDef *hdma)
Abort the DMA Transfer.
uint32_t HAL_DMA_GetError(DMA_HandleTypeDef *hdma)
Return the DMA error code.

◆ HAL_IRDA_AbortReceive_IT()

HAL_StatusTypeDef HAL_IRDA_AbortReceive_IT ( IRDA_HandleTypeDef hirda)

Abort ongoing Receive transfer (Interrupt mode).

Parameters
hirdaPointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified UART module.
Note
This procedure could be used for aborting any ongoing Rx transfer started in Interrupt or DMA mode. This procedure performs following operations :
  • Disable IRDA Interrupts (Rx)
  • Disable the DMA transfer in the peripheral register (if enabled)
  • Abort DMA transfer by calling HAL_DMA_Abort_IT (in case of transfer in DMA mode)
  • Set handle State to READY
  • At abort completion, call user abort complete callback
This procedure is executed in Interrupt mode, meaning that abort procedure could be considered as completed only when user abort complete callback is executed (not when exiting function).
Return values
HALstatus

Definition at line 1804 of file stm32l4xx_hal_irda.c.

1805 {
1806  /* Disable RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts */
1807 #if defined(USART_CR1_FIFOEN)
1808  CLEAR_BIT(hirda->Instance->CR1, (USART_CR1_RXNEIE_RXFNEIE | USART_CR1_PEIE));
1809 #else
1810  CLEAR_BIT(hirda->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE));
1811 #endif /* USART_CR1_FIFOEN */
1812  CLEAR_BIT(hirda->Instance->CR3, USART_CR3_EIE);
1813 
1814  /* Disable the IRDA DMA Rx request if enabled */
1815  if (HAL_IS_BIT_SET(hirda->Instance->CR3, USART_CR3_DMAR))
1816  {
1817  CLEAR_BIT(hirda->Instance->CR3, USART_CR3_DMAR);
1818 
1819  /* Abort the IRDA DMA Rx channel : use non blocking DMA Abort API (callback) */
1820  if (hirda->hdmarx != NULL)
1821  {
1822  /* Set the IRDA DMA Abort callback :
1823  will lead to call HAL_IRDA_AbortCpltCallback() at end of DMA abort procedure */
1824  hirda->hdmarx->XferAbortCallback = IRDA_DMARxOnlyAbortCallback;
1825 
1826  /* Abort DMA RX */
1827  if (HAL_DMA_Abort_IT(hirda->hdmarx) != HAL_OK)
1828  {
1829  /* Call Directly hirda->hdmarx->XferAbortCallback function in case of error */
1830  hirda->hdmarx->XferAbortCallback(hirda->hdmarx);
1831  }
1832  }
1833  else
1834  {
1835  /* Reset Rx transfer counter */
1836  hirda->RxXferCount = 0U;
1837 
1838  /* Clear the Error flags in the ICR register */
1839  __HAL_IRDA_CLEAR_FLAG(hirda, IRDA_CLEAR_OREF | IRDA_CLEAR_NEF | IRDA_CLEAR_PEF | IRDA_CLEAR_FEF);
1840 
1841  /* Restore hirda->RxState to Ready */
1842  hirda->RxState = HAL_IRDA_STATE_READY;
1843 
1844  /* As no DMA to be aborted, call directly user Abort complete callback */
1845 #if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
1846  /* Call registered Abort Receive Complete Callback */
1847  hirda->AbortReceiveCpltCallback(hirda);
1848 #else
1849  /* Call legacy weak Abort Receive Complete Callback */
1851 #endif /* USE_HAL_IRDA_REGISTER_CALLBACK */
1852  }
1853  }
1854  else
1855  {
1856  /* Reset Rx transfer counter */
1857  hirda->RxXferCount = 0U;
1858 
1859  /* Clear the Error flags in the ICR register */
1860  __HAL_IRDA_CLEAR_FLAG(hirda, IRDA_CLEAR_OREF | IRDA_CLEAR_NEF | IRDA_CLEAR_PEF | IRDA_CLEAR_FEF);
1861 
1862  /* Restore hirda->RxState to Ready */
1863  hirda->RxState = HAL_IRDA_STATE_READY;
1864 
1865  /* As no DMA to be aborted, call directly user Abort complete callback */
1866 #if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
1867  /* Call registered Abort Receive Complete Callback */
1868  hirda->AbortReceiveCpltCallback(hirda);
1869 #else
1870  /* Call legacy weak Abort Receive Complete Callback */
1872 #endif /* USE_HAL_IRDA_REGISTER_CALLBACK */
1873  }
1874 
1875  return HAL_OK;
1876 }
void HAL_IRDA_AbortReceiveCpltCallback(IRDA_HandleTypeDef *hirda)
IRDA Abort Receive Complete callback.
HAL_StatusTypeDef HAL_DMA_Abort_IT(DMA_HandleTypeDef *hdma)
Aborts the DMA Transfer in Interrupt mode.
static void IRDA_DMARxOnlyAbortCallback(DMA_HandleTypeDef *hdma)
DMA IRDA Rx communication abort callback, when initiated by user by a call to HAL_IRDA_AbortReceive_I...
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
return HAL_OK

◆ HAL_IRDA_AbortReceiveCpltCallback()

__weak void HAL_IRDA_AbortReceiveCpltCallback ( IRDA_HandleTypeDef hirda)

IRDA Abort Receive Complete callback.

Parameters
hirdaPointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified IRDA module.
Return values
None

Definition at line 2176 of file stm32l4xx_hal_irda.c.

2177 {
2178  /* Prevent unused argument(s) compilation warning */
2179  UNUSED(hirda);
2180 
2181  /* NOTE : This function should not be modified, when the callback is needed,
2182  the HAL_IRDA_AbortReceiveCpltCallback can be implemented in the user file.
2183  */
2184 }

◆ HAL_IRDA_AbortTransmit()

HAL_StatusTypeDef HAL_IRDA_AbortTransmit ( IRDA_HandleTypeDef hirda)

Abort ongoing Transmit transfer (blocking mode).

Parameters
hirdaPointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified UART module.
Note
This procedure could be used for aborting any ongoing Tx transfer started in Interrupt or DMA mode. This procedure performs following operations :
  • Disable IRDA Interrupts (Tx)
  • Disable the DMA transfer in the peripheral register (if enabled)
  • Abort DMA transfer by calling HAL_DMA_Abort (in case of transfer in DMA mode)
  • Set handle State to READY
This procedure is executed in blocking mode : when exiting function, Abort is considered as completed.
Return values
HALstatus

Definition at line 1468 of file stm32l4xx_hal_irda.c.

1469 {
1470  /* Disable TXEIE and TCIE interrupts */
1471 #if defined(USART_CR1_FIFOEN)
1472  CLEAR_BIT(hirda->Instance->CR1, (USART_CR1_TXEIE_TXFNFIE | USART_CR1_TCIE));
1473 #else
1474  CLEAR_BIT(hirda->Instance->CR1, (USART_CR1_TXEIE | USART_CR1_TCIE));
1475 #endif /* USART_CR1_FIFOEN */
1476 
1477  /* Disable the IRDA DMA Tx request if enabled */
1478  if (HAL_IS_BIT_SET(hirda->Instance->CR3, USART_CR3_DMAT))
1479  {
1480  CLEAR_BIT(hirda->Instance->CR3, USART_CR3_DMAT);
1481 
1482  /* Abort the IRDA DMA Tx channel : use blocking DMA Abort API (no callback) */
1483  if (hirda->hdmatx != NULL)
1484  {
1485  /* Set the IRDA DMA Abort callback to Null.
1486  No call back execution at end of DMA abort procedure */
1487  hirda->hdmatx->XferAbortCallback = NULL;
1488 
1489  if (HAL_DMA_Abort(hirda->hdmatx) != HAL_OK)
1490  {
1491  if (HAL_DMA_GetError(hirda->hdmatx) == HAL_DMA_ERROR_TIMEOUT)
1492  {
1493  /* Set error code to DMA */
1494  hirda->ErrorCode = HAL_IRDA_ERROR_DMA;
1495 
1496  return HAL_TIMEOUT;
1497  }
1498  }
1499  }
1500  }
1501 
1502  /* Reset Tx transfer counter */
1503  hirda->TxXferCount = 0U;
1504 
1505  /* Restore hirda->gState to Ready */
1506  hirda->gState = HAL_IRDA_STATE_READY;
1507 
1508  return HAL_OK;
1509 }
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
return HAL_OK
HAL_StatusTypeDef HAL_DMA_Abort(DMA_HandleTypeDef *hdma)
Abort the DMA Transfer.
uint32_t HAL_DMA_GetError(DMA_HandleTypeDef *hdma)
Return the DMA error code.

◆ HAL_IRDA_AbortTransmit_IT()

HAL_StatusTypeDef HAL_IRDA_AbortTransmit_IT ( IRDA_HandleTypeDef hirda)

Abort ongoing Transmit transfer (Interrupt mode).

Parameters
hirdaPointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified UART module.
Note
This procedure could be used for aborting any ongoing Tx transfer started in Interrupt or DMA mode. This procedure performs following operations :
  • Disable IRDA Interrupts (Tx)
  • Disable the DMA transfer in the peripheral register (if enabled)
  • Abort DMA transfer by calling HAL_DMA_Abort_IT (in case of transfer in DMA mode)
  • Set handle State to READY
  • At abort completion, call user abort complete callback
This procedure is executed in Interrupt mode, meaning that abort procedure could be considered as completed only when user abort complete callback is executed (not when exiting function).
Return values
HALstatus

Definition at line 1722 of file stm32l4xx_hal_irda.c.

1723 {
1724  /* Disable TXEIE and TCIE interrupts */
1725 #if defined(USART_CR1_FIFOEN)
1726  CLEAR_BIT(hirda->Instance->CR1, (USART_CR1_TXEIE_TXFNFIE | USART_CR1_TCIE));
1727 #else
1728  CLEAR_BIT(hirda->Instance->CR1, (USART_CR1_TXEIE | USART_CR1_TCIE));
1729 #endif /* USART_CR1_FIFOEN */
1730 
1731  /* Disable the IRDA DMA Tx request if enabled */
1732  if (HAL_IS_BIT_SET(hirda->Instance->CR3, USART_CR3_DMAT))
1733  {
1734  CLEAR_BIT(hirda->Instance->CR3, USART_CR3_DMAT);
1735 
1736  /* Abort the IRDA DMA Tx channel : use non blocking DMA Abort API (callback) */
1737  if (hirda->hdmatx != NULL)
1738  {
1739  /* Set the IRDA DMA Abort callback :
1740  will lead to call HAL_IRDA_AbortCpltCallback() at end of DMA abort procedure */
1741  hirda->hdmatx->XferAbortCallback = IRDA_DMATxOnlyAbortCallback;
1742 
1743  /* Abort DMA TX */
1744  if (HAL_DMA_Abort_IT(hirda->hdmatx) != HAL_OK)
1745  {
1746  /* Call Directly hirda->hdmatx->XferAbortCallback function in case of error */
1747  hirda->hdmatx->XferAbortCallback(hirda->hdmatx);
1748  }
1749  }
1750  else
1751  {
1752  /* Reset Tx transfer counter */
1753  hirda->TxXferCount = 0U;
1754 
1755  /* Restore hirda->gState to Ready */
1756  hirda->gState = HAL_IRDA_STATE_READY;
1757 
1758  /* As no DMA to be aborted, call directly user Abort complete callback */
1759 #if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
1760  /* Call registered Abort Transmit Complete Callback */
1761  hirda->AbortTransmitCpltCallback(hirda);
1762 #else
1763  /* Call legacy weak Abort Transmit Complete Callback */
1765 #endif /* USE_HAL_IRDA_REGISTER_CALLBACK */
1766  }
1767  }
1768  else
1769  {
1770  /* Reset Tx transfer counter */
1771  hirda->TxXferCount = 0U;
1772 
1773  /* Restore hirda->gState to Ready */
1774  hirda->gState = HAL_IRDA_STATE_READY;
1775 
1776  /* As no DMA to be aborted, call directly user Abort complete callback */
1777 #if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
1778  /* Call registered Abort Transmit Complete Callback */
1779  hirda->AbortTransmitCpltCallback(hirda);
1780 #else
1781  /* Call legacy weak Abort Transmit Complete Callback */
1783 #endif /* USE_HAL_IRDA_REGISTER_CALLBACK */
1784  }
1785 
1786  return HAL_OK;
1787 }
static void IRDA_DMATxOnlyAbortCallback(DMA_HandleTypeDef *hdma)
DMA IRDA Tx communication abort callback, when initiated by user by a call to HAL_IRDA_AbortTransmit_...
HAL_StatusTypeDef HAL_DMA_Abort_IT(DMA_HandleTypeDef *hdma)
Aborts the DMA Transfer in Interrupt mode.
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
return HAL_OK
void HAL_IRDA_AbortTransmitCpltCallback(IRDA_HandleTypeDef *hirda)
IRDA Abort Complete callback.

◆ HAL_IRDA_AbortTransmitCpltCallback()

__weak void HAL_IRDA_AbortTransmitCpltCallback ( IRDA_HandleTypeDef hirda)

IRDA Abort Complete callback.

Parameters
hirdaPointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified IRDA module.
Return values
None

Definition at line 2160 of file stm32l4xx_hal_irda.c.

2161 {
2162  /* Prevent unused argument(s) compilation warning */
2163  UNUSED(hirda);
2164 
2165  /* NOTE : This function should not be modified, when the callback is needed,
2166  the HAL_IRDA_AbortTransmitCpltCallback can be implemented in the user file.
2167  */
2168 }

◆ HAL_IRDA_DMAPause()

HAL_StatusTypeDef HAL_IRDA_DMAPause ( IRDA_HandleTypeDef hirda)

Pause the DMA Transfer.

Parameters
hirdaPointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified IRDA module.
Return values
HALstatus

Definition at line 1228 of file stm32l4xx_hal_irda.c.

1229 {
1230  /* Process Locked */
1231  __HAL_LOCK(hirda);
1232 
1233  if (hirda->gState == HAL_IRDA_STATE_BUSY_TX)
1234  {
1235  if (HAL_IS_BIT_SET(hirda->Instance->CR3, USART_CR3_DMAT))
1236  {
1237  /* Disable the IRDA DMA Tx request */
1238  CLEAR_BIT(hirda->Instance->CR3, USART_CR3_DMAT);
1239  }
1240  }
1241  if (hirda->RxState == HAL_IRDA_STATE_BUSY_RX)
1242  {
1243  if (HAL_IS_BIT_SET(hirda->Instance->CR3, USART_CR3_DMAR))
1244  {
1245  /* Disable PE and ERR (Frame error, noise error, overrun error) interrupts */
1246  CLEAR_BIT(hirda->Instance->CR1, USART_CR1_PEIE);
1247  CLEAR_BIT(hirda->Instance->CR3, USART_CR3_EIE);
1248 
1249  /* Disable the IRDA DMA Rx request */
1250  CLEAR_BIT(hirda->Instance->CR3, USART_CR3_DMAR);
1251  }
1252  }
1253 
1254  /* Process Unlocked */
1255  __HAL_UNLOCK(hirda);
1256 
1257  return HAL_OK;
1258 }
__HAL_UNLOCK(hrtc)
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
__HAL_LOCK(hrtc)
return HAL_OK

◆ HAL_IRDA_DMAResume()

HAL_StatusTypeDef HAL_IRDA_DMAResume ( IRDA_HandleTypeDef hirda)

Resume the DMA Transfer.

Parameters
hirdaPointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified UART module.
Return values
HALstatus

Definition at line 1266 of file stm32l4xx_hal_irda.c.

1267 {
1268  /* Process Locked */
1269  __HAL_LOCK(hirda);
1270 
1271  if (hirda->gState == HAL_IRDA_STATE_BUSY_TX)
1272  {
1273  /* Enable the IRDA DMA Tx request */
1274  SET_BIT(hirda->Instance->CR3, USART_CR3_DMAT);
1275  }
1276  if (hirda->RxState == HAL_IRDA_STATE_BUSY_RX)
1277  {
1278  /* Clear the Overrun flag before resuming the Rx transfer*/
1279  __HAL_IRDA_CLEAR_OREFLAG(hirda);
1280 
1281  /* Reenable PE and ERR (Frame error, noise error, overrun error) interrupts */
1282  SET_BIT(hirda->Instance->CR1, USART_CR1_PEIE);
1283  SET_BIT(hirda->Instance->CR3, USART_CR3_EIE);
1284 
1285  /* Enable the IRDA DMA Rx request */
1286  SET_BIT(hirda->Instance->CR3, USART_CR3_DMAR);
1287  }
1288 
1289  /* Process Unlocked */
1290  __HAL_UNLOCK(hirda);
1291 
1292  return HAL_OK;
1293 }
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
return HAL_OK

◆ HAL_IRDA_DMAStop()

HAL_StatusTypeDef HAL_IRDA_DMAStop ( IRDA_HandleTypeDef hirda)

Stop the DMA Transfer.

Parameters
hirdaPointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified UART module.
Return values
HALstatus

Definition at line 1301 of file stm32l4xx_hal_irda.c.

1302 {
1303  /* The Lock is not implemented on this API to allow the user application
1304  to call the HAL IRDA API under callbacks HAL_IRDA_TxCpltCallback() / HAL_IRDA_RxCpltCallback() /
1305  HAL_IRDA_TxHalfCpltCallback / HAL_IRDA_RxHalfCpltCallback:
1306  indeed, when HAL_DMA_Abort() API is called, the DMA TX/RX Transfer or Half Transfer complete
1307  interrupt is generated if the DMA transfer interruption occurs at the middle or at the end of
1308  the stream and the corresponding call back is executed. */
1309 
1310  /* Stop IRDA DMA Tx request if ongoing */
1311  if (hirda->gState == HAL_IRDA_STATE_BUSY_TX)
1312  {
1313  if (HAL_IS_BIT_SET(hirda->Instance->CR3, USART_CR3_DMAT))
1314  {
1315  CLEAR_BIT(hirda->Instance->CR3, USART_CR3_DMAT);
1316 
1317  /* Abort the IRDA DMA Tx channel */
1318  if (hirda->hdmatx != NULL)
1319  {
1320  if (HAL_DMA_Abort(hirda->hdmatx) != HAL_OK)
1321  {
1322  if (HAL_DMA_GetError(hirda->hdmatx) == HAL_DMA_ERROR_TIMEOUT)
1323  {
1324  /* Set error code to DMA */
1325  hirda->ErrorCode = HAL_IRDA_ERROR_DMA;
1326 
1327  return HAL_TIMEOUT;
1328  }
1329  }
1330  }
1331 
1332  IRDA_EndTxTransfer(hirda);
1333  }
1334  }
1335 
1336  /* Stop IRDA DMA Rx request if ongoing */
1337  if (hirda->RxState == HAL_IRDA_STATE_BUSY_RX)
1338  {
1339  if (HAL_IS_BIT_SET(hirda->Instance->CR3, USART_CR3_DMAR))
1340  {
1341  CLEAR_BIT(hirda->Instance->CR3, USART_CR3_DMAR);
1342 
1343  /* Abort the IRDA DMA Rx channel */
1344  if (hirda->hdmarx != NULL)
1345  {
1346  if (HAL_DMA_Abort(hirda->hdmarx) != HAL_OK)
1347  {
1348  if (HAL_DMA_GetError(hirda->hdmarx) == HAL_DMA_ERROR_TIMEOUT)
1349  {
1350  /* Set error code to DMA */
1351  hirda->ErrorCode = HAL_IRDA_ERROR_DMA;
1352 
1353  return HAL_TIMEOUT;
1354  }
1355  }
1356  }
1357 
1358  IRDA_EndRxTransfer(hirda);
1359  }
1360  }
1361 
1362  return HAL_OK;
1363 }
static void IRDA_EndRxTransfer(IRDA_HandleTypeDef *hirda)
End ongoing Rx transfer on UART peripheral (following error detection or Reception completion)...
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
static void IRDA_EndTxTransfer(IRDA_HandleTypeDef *hirda)
End ongoing Tx transfer on IRDA peripheral (following error detection or Transmit completion)...
return HAL_OK
HAL_StatusTypeDef HAL_DMA_Abort(DMA_HandleTypeDef *hdma)
Abort the DMA Transfer.
uint32_t HAL_DMA_GetError(DMA_HandleTypeDef *hdma)
Return the DMA error code.

◆ HAL_IRDA_ErrorCallback()

__weak void HAL_IRDA_ErrorCallback ( IRDA_HandleTypeDef hirda)

IRDA error callback.

Parameters
hirdaPointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified IRDA module.
Return values
None

Definition at line 2128 of file stm32l4xx_hal_irda.c.

2129 {
2130  /* Prevent unused argument(s) compilation warning */
2131  UNUSED(hirda);
2132 
2133  /* NOTE : This function should not be modified, when the callback is needed,
2134  the HAL_IRDA_ErrorCallback can be implemented in the user file.
2135  */
2136 }

◆ HAL_IRDA_IRQHandler()

void HAL_IRDA_IRQHandler ( IRDA_HandleTypeDef hirda)

Handle IRDA interrupt request.

Parameters
hirdaPointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified IRDA module.
Return values
None

Definition at line 1884 of file stm32l4xx_hal_irda.c.

1885 {
1886  uint32_t isrflags = READ_REG(hirda->Instance->ISR);
1887  uint32_t cr1its = READ_REG(hirda->Instance->CR1);
1888  uint32_t cr3its;
1889  uint32_t errorflags;
1890  uint32_t errorcode;
1891 
1892  /* If no error occurs */
1893  errorflags = (isrflags & (uint32_t)(USART_ISR_PE | USART_ISR_FE | USART_ISR_ORE | USART_ISR_NE));
1894  if (errorflags == 0U)
1895  {
1896  /* IRDA in mode Receiver ---------------------------------------------------*/
1897 #if defined(USART_CR1_FIFOEN)
1898  if (((isrflags & USART_ISR_RXNE_RXFNE) != 0U) && ((cr1its & USART_CR1_RXNEIE_RXFNEIE) != 0U))
1899 #else
1900  if (((isrflags & USART_ISR_RXNE) != 0U) && ((cr1its & USART_CR1_RXNEIE) != 0U))
1901 #endif /* USART_CR1_FIFOEN */
1902  {
1903  IRDA_Receive_IT(hirda);
1904  return;
1905  }
1906  }
1907 
1908  /* If some errors occur */
1909  cr3its = READ_REG(hirda->Instance->CR3);
1910  if ((errorflags != 0U)
1911  && (((cr3its & USART_CR3_EIE) != 0U)
1912 #if defined(USART_CR1_FIFOEN)
1913  || ((cr1its & (USART_CR1_RXNEIE_RXFNEIE | USART_CR1_PEIE)) != 0U)))
1914 #else
1915  || ((cr1its & (USART_CR1_RXNEIE | USART_CR1_PEIE)) != 0U)))
1916 #endif /* USART_CR1_FIFOEN */
1917  {
1918  /* IRDA parity error interrupt occurred -------------------------------------*/
1919  if (((isrflags & USART_ISR_PE) != 0U) && ((cr1its & USART_CR1_PEIE) != 0U))
1920  {
1921  __HAL_IRDA_CLEAR_IT(hirda, IRDA_CLEAR_PEF);
1922 
1923  hirda->ErrorCode |= HAL_IRDA_ERROR_PE;
1924  }
1925 
1926  /* IRDA frame error interrupt occurred --------------------------------------*/
1927  if (((isrflags & USART_ISR_FE) != 0U) && ((cr3its & USART_CR3_EIE) != 0U))
1928  {
1929  __HAL_IRDA_CLEAR_IT(hirda, IRDA_CLEAR_FEF);
1930 
1931  hirda->ErrorCode |= HAL_IRDA_ERROR_FE;
1932  }
1933 
1934  /* IRDA noise error interrupt occurred --------------------------------------*/
1935  if (((isrflags & USART_ISR_NE) != 0U) && ((cr3its & USART_CR3_EIE) != 0U))
1936  {
1937  __HAL_IRDA_CLEAR_IT(hirda, IRDA_CLEAR_NEF);
1938 
1939  hirda->ErrorCode |= HAL_IRDA_ERROR_NE;
1940  }
1941 
1942  /* IRDA Over-Run interrupt occurred -----------------------------------------*/
1943  if (((isrflags & USART_ISR_ORE) != 0U) &&
1944 #if defined(USART_CR1_FIFOEN)
1945  (((cr1its & USART_CR1_RXNEIE_RXFNEIE) != 0U) || ((cr3its & USART_CR3_EIE) != 0U)))
1946 #else
1947  (((cr1its & USART_CR1_RXNEIE) != 0U) || ((cr3its & USART_CR3_EIE) != 0U)))
1948 #endif /* USART_CR1_FIFOEN */
1949  {
1950  __HAL_IRDA_CLEAR_IT(hirda, IRDA_CLEAR_OREF);
1951 
1952  hirda->ErrorCode |= HAL_IRDA_ERROR_ORE;
1953  }
1954 
1955  /* Call IRDA Error Call back function if need be --------------------------*/
1956  if (hirda->ErrorCode != HAL_IRDA_ERROR_NONE)
1957  {
1958  /* IRDA in mode Receiver ---------------------------------------------------*/
1959 #if defined(USART_CR1_FIFOEN)
1960  if (((isrflags & USART_ISR_RXNE_RXFNE) != 0U) && ((cr1its & USART_CR1_RXNEIE_RXFNEIE) != 0U))
1961 #else
1962  if (((isrflags & USART_ISR_RXNE) != 0U) && ((cr1its & USART_CR1_RXNEIE) != 0U))
1963 #endif /* USART_CR1_FIFOEN */
1964  {
1965  IRDA_Receive_IT(hirda);
1966  }
1967 
1968  /* If Overrun error occurs, or if any error occurs in DMA mode reception,
1969  consider error as blocking */
1970  errorcode = hirda->ErrorCode;
1971  if ((HAL_IS_BIT_SET(hirda->Instance->CR3, USART_CR3_DMAR)) ||
1972  ((errorcode & HAL_IRDA_ERROR_ORE) != 0U))
1973  {
1974  /* Blocking error : transfer is aborted
1975  Set the IRDA state ready to be able to start again the process,
1976  Disable Rx Interrupts, and disable Rx DMA request, if ongoing */
1977  IRDA_EndRxTransfer(hirda);
1978 
1979  /* Disable the IRDA DMA Rx request if enabled */
1980  if (HAL_IS_BIT_SET(hirda->Instance->CR3, USART_CR3_DMAR))
1981  {
1982  CLEAR_BIT(hirda->Instance->CR3, USART_CR3_DMAR);
1983 
1984  /* Abort the IRDA DMA Rx channel */
1985  if (hirda->hdmarx != NULL)
1986  {
1987  /* Set the IRDA DMA Abort callback :
1988  will lead to call HAL_IRDA_ErrorCallback() at end of DMA abort procedure */
1989  hirda->hdmarx->XferAbortCallback = IRDA_DMAAbortOnError;
1990 
1991  /* Abort DMA RX */
1992  if (HAL_DMA_Abort_IT(hirda->hdmarx) != HAL_OK)
1993  {
1994  /* Call Directly hirda->hdmarx->XferAbortCallback function in case of error */
1995  hirda->hdmarx->XferAbortCallback(hirda->hdmarx);
1996  }
1997  }
1998  else
1999  {
2000 #if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
2001  /* Call registered user error callback */
2002  hirda->ErrorCallback(hirda);
2003 #else
2004  /* Call legacy weak user error callback */
2005  HAL_IRDA_ErrorCallback(hirda);
2006 #endif /* USE_HAL_IRDA_REGISTER_CALLBACK */
2007  }
2008  }
2009  else
2010  {
2011 #if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
2012  /* Call registered user error callback */
2013  hirda->ErrorCallback(hirda);
2014 #else
2015  /* Call legacy weak user error callback */
2016  HAL_IRDA_ErrorCallback(hirda);
2017 #endif /* USE_HAL_IRDA_REGISTER_CALLBACK */
2018  }
2019  }
2020  else
2021  {
2022  /* Non Blocking error : transfer could go on.
2023  Error is notified to user through user error callback */
2024 #if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
2025  /* Call registered user error callback */
2026  hirda->ErrorCallback(hirda);
2027 #else
2028  /* Call legacy weak user error callback */
2029  HAL_IRDA_ErrorCallback(hirda);
2030 #endif /* USE_HAL_IRDA_REGISTER_CALLBACK */
2031  hirda->ErrorCode = HAL_IRDA_ERROR_NONE;
2032  }
2033  }
2034  return;
2035 
2036  } /* End if some error occurs */
2037 
2038  /* IRDA in mode Transmitter ------------------------------------------------*/
2039 #if defined(USART_CR1_FIFOEN)
2040  if (((isrflags & USART_ISR_TXE_TXFNF) != 0U) && ((cr1its & USART_CR1_TXEIE_TXFNFIE) != 0U))
2041 #else
2042  if (((isrflags & USART_ISR_TXE) != 0U) && ((cr1its & USART_CR1_TXEIE) != 0U))
2043 #endif /* USART_CR1_FIFOEN */
2044  {
2045  IRDA_Transmit_IT(hirda);
2046  return;
2047  }
2048 
2049  /* IRDA in mode Transmitter (transmission end) -----------------------------*/
2050  if (((isrflags & USART_ISR_TC) != 0U) && ((cr1its & USART_CR1_TCIE) != 0U))
2051  {
2052  IRDA_EndTransmit_IT(hirda);
2053  return;
2054  }
2055 
2056 }
static void IRDA_EndTransmit_IT(IRDA_HandleTypeDef *hirda)
Wrap up transmission in non-blocking mode.
static void IRDA_DMAAbortOnError(DMA_HandleTypeDef *hdma)
DMA IRDA communication abort callback, when initiated by HAL services on Error (To be called at end o...
static void IRDA_EndRxTransfer(IRDA_HandleTypeDef *hirda)
End ongoing Rx transfer on UART peripheral (following error detection or Reception completion)...
static void IRDA_Transmit_IT(IRDA_HandleTypeDef *hirda)
Send an amount of data in interrupt mode.
HAL_StatusTypeDef HAL_DMA_Abort_IT(DMA_HandleTypeDef *hdma)
Aborts the DMA Transfer in Interrupt mode.
void HAL_IRDA_ErrorCallback(IRDA_HandleTypeDef *hirda)
IRDA error callback.
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
return HAL_OK
ADC handle Structure definition.
static void IRDA_Receive_IT(IRDA_HandleTypeDef *hirda)
Receive an amount of data in interrupt mode.

◆ HAL_IRDA_Receive()

HAL_StatusTypeDef HAL_IRDA_Receive ( IRDA_HandleTypeDef hirda,
uint8_t *  pData,
uint16_t  Size,
uint32_t  Timeout 
)

Receive an amount of data in blocking mode.

Parameters
hirdaPointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified IRDA module.
pDataPointer to data buffer.
SizeAmount of data to be received.
TimeoutSpecify timeout value.
Return values
HALstatus

Definition at line 889 of file stm32l4xx_hal_irda.c.

890 {
891  uint8_t *pdata8bits;
892  uint16_t *pdata16bits;
893  uint16_t uhMask;
894  uint32_t tickstart;
895 
896  /* Check that a Rx process is not already ongoing */
897  if (hirda->RxState == HAL_IRDA_STATE_READY)
898  {
899  if ((pData == NULL) || (Size == 0U))
900  {
901  return HAL_ERROR;
902  }
903 
904  /* Process Locked */
905  __HAL_LOCK(hirda);
906 
907  hirda->ErrorCode = HAL_IRDA_ERROR_NONE;
908  hirda->RxState = HAL_IRDA_STATE_BUSY_RX;
909 
910  /* Init tickstart for timeout managment*/
911  tickstart = HAL_GetTick();
912 
913  hirda->RxXferSize = Size;
914  hirda->RxXferCount = Size;
915 
916  /* Computation of the mask to apply to RDR register
917  of the UART associated to the IRDA */
918  IRDA_MASK_COMPUTATION(hirda);
919  uhMask = hirda->Mask;
920 
921  /* In case of 9bits/No Parity transfer, pRxData needs to be handled as a uint16_t pointer */
922  if ((hirda->Init.WordLength == IRDA_WORDLENGTH_9B) && (hirda->Init.Parity == IRDA_PARITY_NONE))
923  {
924  pdata8bits = NULL;
925  pdata16bits = (uint16_t *) pData; /* Derogation R.11.3 */
926  }
927  else
928  {
929  pdata8bits = pData;
930  pdata16bits = NULL;
931  }
932 
933  /* Check data remaining to be received */
934  while (hirda->RxXferCount > 0U)
935  {
936  hirda->RxXferCount--;
937 
938  if (IRDA_WaitOnFlagUntilTimeout(hirda, IRDA_FLAG_RXNE, RESET, tickstart, Timeout) != HAL_OK)
939  {
940  return HAL_TIMEOUT;
941  }
942  if (pdata8bits == NULL)
943  {
944  *pdata16bits = (uint16_t)(hirda->Instance->RDR & uhMask);
945  pdata16bits++;
946  }
947  else
948  {
949  *pdata8bits = (uint8_t)(hirda->Instance->RDR & (uint8_t)uhMask);
950  pdata8bits++;
951  }
952  }
953 
954  /* At end of Rx process, restore hirda->RxState to Ready */
955  hirda->RxState = HAL_IRDA_STATE_READY;
956 
957  /* Process Unlocked */
958  __HAL_UNLOCK(hirda);
959 
960  return HAL_OK;
961  }
962  else
963  {
964  return HAL_BUSY;
965  }
966 }
static HAL_StatusTypeDef IRDA_WaitOnFlagUntilTimeout(IRDA_HandleTypeDef *hirda, uint32_t Flag, FlagStatus Status, uint32_t Tickstart, uint32_t Timeout)
Handle IRDA Communication Timeout.
uint32_t HAL_GetTick(void)
Provide a tick value in millisecond.
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
return HAL_OK

◆ HAL_IRDA_Receive_DMA()

HAL_StatusTypeDef HAL_IRDA_Receive_DMA ( IRDA_HandleTypeDef hirda,
uint8_t *  pData,
uint16_t  Size 
)

Receive an amount of data in DMA mode.

Note
When the IRDA parity is enabled (PCE = 1), the received data contains the parity bit (MSB position).
Parameters
hirdaPointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified IRDA module.
pDataPointer to data buffer.
SizeAmount of data to be received.
Return values
HALstatus

Definition at line 1152 of file stm32l4xx_hal_irda.c.

1153 {
1154  /* Check that a Rx process is not already ongoing */
1155  if (hirda->RxState == HAL_IRDA_STATE_READY)
1156  {
1157  if ((pData == NULL) || (Size == 0U))
1158  {
1159  return HAL_ERROR;
1160  }
1161 
1162  /* Process Locked */
1163  __HAL_LOCK(hirda);
1164 
1165  hirda->pRxBuffPtr = pData;
1166  hirda->RxXferSize = Size;
1167 
1168  hirda->ErrorCode = HAL_IRDA_ERROR_NONE;
1169  hirda->RxState = HAL_IRDA_STATE_BUSY_RX;
1170 
1171  /* Set the IRDA DMA transfer complete callback */
1172  hirda->hdmarx->XferCpltCallback = IRDA_DMAReceiveCplt;
1173 
1174  /* Set the IRDA DMA half transfer complete callback */
1175  hirda->hdmarx->XferHalfCpltCallback = IRDA_DMAReceiveHalfCplt;
1176 
1177  /* Set the DMA error callback */
1178  hirda->hdmarx->XferErrorCallback = IRDA_DMAError;
1179 
1180  /* Set the DMA abort callback */
1181  hirda->hdmarx->XferAbortCallback = NULL;
1182 
1183  /* Enable the DMA channel */
1184  if (HAL_DMA_Start_IT(hirda->hdmarx, (uint32_t)&hirda->Instance->RDR, (uint32_t)hirda->pRxBuffPtr, Size) == HAL_OK)
1185  {
1186  /* Process Unlocked */
1187  __HAL_UNLOCK(hirda);
1188 
1189  /* Enable the UART Parity Error Interrupt */
1190  SET_BIT(hirda->Instance->CR1, USART_CR1_PEIE);
1191 
1192  /* Enable the UART Error Interrupt: (Frame error, noise error, overrun error) */
1193  SET_BIT(hirda->Instance->CR3, USART_CR3_EIE);
1194 
1195  /* Enable the DMA transfer for the receiver request by setting the DMAR bit
1196  in the USART CR3 register */
1197  SET_BIT(hirda->Instance->CR3, USART_CR3_DMAR);
1198 
1199  return HAL_OK;
1200  }
1201  else
1202  {
1203  /* Set error code to DMA */
1204  hirda->ErrorCode = HAL_IRDA_ERROR_DMA;
1205 
1206  /* Process Unlocked */
1207  __HAL_UNLOCK(hirda);
1208 
1209  /* Restore hirda->RxState to ready */
1210  hirda->RxState = HAL_IRDA_STATE_READY;
1211 
1212  return HAL_ERROR;
1213  }
1214  }
1215  else
1216  {
1217  return HAL_BUSY;
1218  }
1219 }
static void IRDA_DMAReceiveHalfCplt(DMA_HandleTypeDef *hdma)
DMA IRDA receive process half complete callback.
__HAL_UNLOCK(hrtc)
HAL_StatusTypeDef HAL_DMA_Start_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength)
Start the DMA Transfer with interrupt enabled.
__HAL_LOCK(hrtc)
return HAL_OK
static void IRDA_DMAReceiveCplt(DMA_HandleTypeDef *hdma)
DMA IRDA receive process complete callback.
static void IRDA_DMAError(DMA_HandleTypeDef *hdma)
DMA IRDA communication error callback.

◆ HAL_IRDA_Receive_IT()

HAL_StatusTypeDef HAL_IRDA_Receive_IT ( IRDA_HandleTypeDef hirda,
uint8_t *  pData,
uint16_t  Size 
)

Receive an amount of data in interrupt mode.

Parameters
hirdaPointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified IRDA module.
pDataPointer to data buffer.
SizeAmount of data to be received.
Return values
HALstatus

Definition at line 1022 of file stm32l4xx_hal_irda.c.

1023 {
1024  /* Check that a Rx process is not already ongoing */
1025  if (hirda->RxState == HAL_IRDA_STATE_READY)
1026  {
1027  if ((pData == NULL) || (Size == 0U))
1028  {
1029  return HAL_ERROR;
1030  }
1031 
1032  /* Process Locked */
1033  __HAL_LOCK(hirda);
1034 
1035  hirda->pRxBuffPtr = pData;
1036  hirda->RxXferSize = Size;
1037  hirda->RxXferCount = Size;
1038 
1039  /* Computation of the mask to apply to the RDR register
1040  of the UART associated to the IRDA */
1041  IRDA_MASK_COMPUTATION(hirda);
1042 
1043  hirda->ErrorCode = HAL_IRDA_ERROR_NONE;
1044  hirda->RxState = HAL_IRDA_STATE_BUSY_RX;
1045 
1046  /* Process Unlocked */
1047  __HAL_UNLOCK(hirda);
1048 
1049  /* Enable the IRDA Parity Error and Data Register not empty Interrupts */
1050 #if defined(USART_CR1_FIFOEN)
1051  SET_BIT(hirda->Instance->CR1, USART_CR1_PEIE | USART_CR1_RXNEIE_RXFNEIE);
1052 #else
1053  SET_BIT(hirda->Instance->CR1, USART_CR1_PEIE | USART_CR1_RXNEIE);
1054 #endif /* USART_CR1_FIFOEN */
1055 
1056  /* Enable the IRDA Error Interrupt: (Frame error, noise error, overrun error) */
1057  SET_BIT(hirda->Instance->CR3, USART_CR3_EIE);
1058 
1059  return HAL_OK;
1060  }
1061  else
1062  {
1063  return HAL_BUSY;
1064  }
1065 }
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
return HAL_OK

◆ HAL_IRDA_RxCpltCallback()

__weak void HAL_IRDA_RxCpltCallback ( IRDA_HandleTypeDef hirda)

Rx Transfer completed callback.

Parameters
hirdaPointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified IRDA module.
Return values
None

Definition at line 2096 of file stm32l4xx_hal_irda.c.

2097 {
2098  /* Prevent unused argument(s) compilation warning */
2099  UNUSED(hirda);
2100 
2101  /* NOTE : This function should not be modified, when the callback is needed,
2102  the HAL_IRDA_RxCpltCallback can be implemented in the user file.
2103  */
2104 }

◆ HAL_IRDA_RxHalfCpltCallback()

__weak void HAL_IRDA_RxHalfCpltCallback ( IRDA_HandleTypeDef hirda)

Rx Half Transfer complete callback.

Parameters
hirdaPointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified IRDA module.
Return values
None

Definition at line 2112 of file stm32l4xx_hal_irda.c.

2113 {
2114  /* Prevent unused argument(s) compilation warning */
2115  UNUSED(hirda);
2116 
2117  /* NOTE : This function should not be modified, when the callback is needed,
2118  the HAL_IRDA_RxHalfCpltCallback can be implemented in the user file.
2119  */
2120 }

◆ HAL_IRDA_Transmit()

HAL_StatusTypeDef HAL_IRDA_Transmit ( IRDA_HandleTypeDef hirda,
uint8_t *  pData,
uint16_t  Size,
uint32_t  Timeout 
)

Send an amount of data in blocking mode.

Parameters
hirdaPointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified IRDA module.
pDataPointer to data buffer.
SizeAmount of data to be sent.
TimeoutSpecify timeout value.
Return values
HALstatus

Definition at line 803 of file stm32l4xx_hal_irda.c.

804 {
805  uint8_t *pdata8bits;
806  uint16_t *pdata16bits;
807  uint32_t tickstart;
808 
809  /* Check that a Tx process is not already ongoing */
810  if (hirda->gState == HAL_IRDA_STATE_READY)
811  {
812  if ((pData == NULL) || (Size == 0U))
813  {
814  return HAL_ERROR;
815  }
816 
817  /* Process Locked */
818  __HAL_LOCK(hirda);
819 
820  hirda->ErrorCode = HAL_IRDA_ERROR_NONE;
821  hirda->gState = HAL_IRDA_STATE_BUSY_TX;
822 
823  /* Init tickstart for timeout managment*/
824  tickstart = HAL_GetTick();
825 
826  hirda->TxXferSize = Size;
827  hirda->TxXferCount = Size;
828 
829  /* In case of 9bits/No Parity transfer, pData needs to be handled as a uint16_t pointer */
830  if ((hirda->Init.WordLength == IRDA_WORDLENGTH_9B) && (hirda->Init.Parity == IRDA_PARITY_NONE))
831  {
832  pdata8bits = NULL;
833  pdata16bits = (uint16_t *) pData; /* Derogation R.11.3 */
834  }
835  else
836  {
837  pdata8bits = pData;
838  pdata16bits = NULL;
839  }
840 
841  while (hirda->TxXferCount > 0U)
842  {
843  hirda->TxXferCount--;
844 
845  if (IRDA_WaitOnFlagUntilTimeout(hirda, IRDA_FLAG_TXE, RESET, tickstart, Timeout) != HAL_OK)
846  {
847  return HAL_TIMEOUT;
848  }
849  if (pdata8bits == NULL)
850  {
851  hirda->Instance->TDR = (uint16_t)(*pdata16bits & 0x01FFU);
852  pdata16bits++;
853  }
854  else
855  {
856  hirda->Instance->TDR = (uint8_t)(*pdata8bits & 0xFFU);
857  pdata8bits++;
858  }
859  }
860 
861  if (IRDA_WaitOnFlagUntilTimeout(hirda, IRDA_FLAG_TC, RESET, tickstart, Timeout) != HAL_OK)
862  {
863  return HAL_TIMEOUT;
864  }
865 
866  /* At end of Tx process, restore hirda->gState to Ready */
867  hirda->gState = HAL_IRDA_STATE_READY;
868 
869  /* Process Unlocked */
870  __HAL_UNLOCK(hirda);
871 
872  return HAL_OK;
873  }
874  else
875  {
876  return HAL_BUSY;
877  }
878 }
static HAL_StatusTypeDef IRDA_WaitOnFlagUntilTimeout(IRDA_HandleTypeDef *hirda, uint32_t Flag, FlagStatus Status, uint32_t Tickstart, uint32_t Timeout)
Handle IRDA Communication Timeout.
uint32_t HAL_GetTick(void)
Provide a tick value in millisecond.
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
return HAL_OK

◆ HAL_IRDA_Transmit_DMA()

HAL_StatusTypeDef HAL_IRDA_Transmit_DMA ( IRDA_HandleTypeDef hirda,
uint8_t *  pData,
uint16_t  Size 
)

Send an amount of data in DMA mode.

Parameters
hirdaPointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified IRDA module.
pDatapointer to data buffer.
Sizeamount of data to be sent.
Return values
HALstatus

Definition at line 1075 of file stm32l4xx_hal_irda.c.

1076 {
1077  /* Check that a Tx process is not already ongoing */
1078  if (hirda->gState == HAL_IRDA_STATE_READY)
1079  {
1080  if ((pData == NULL) || (Size == 0U))
1081  {
1082  return HAL_ERROR;
1083  }
1084 
1085  /* Process Locked */
1086  __HAL_LOCK(hirda);
1087 
1088  hirda->pTxBuffPtr = pData;
1089  hirda->TxXferSize = Size;
1090  hirda->TxXferCount = Size;
1091 
1092  hirda->ErrorCode = HAL_IRDA_ERROR_NONE;
1093  hirda->gState = HAL_IRDA_STATE_BUSY_TX;
1094 
1095  /* Set the IRDA DMA transfer complete callback */
1096  hirda->hdmatx->XferCpltCallback = IRDA_DMATransmitCplt;
1097 
1098  /* Set the IRDA DMA half transfer complete callback */
1099  hirda->hdmatx->XferHalfCpltCallback = IRDA_DMATransmitHalfCplt;
1100 
1101  /* Set the DMA error callback */
1102  hirda->hdmatx->XferErrorCallback = IRDA_DMAError;
1103 
1104  /* Set the DMA abort callback */
1105  hirda->hdmatx->XferAbortCallback = NULL;
1106 
1107  /* Enable the IRDA transmit DMA channel */
1108  if (HAL_DMA_Start_IT(hirda->hdmatx, (uint32_t)hirda->pTxBuffPtr, (uint32_t)&hirda->Instance->TDR, Size) == HAL_OK)
1109  {
1110  /* Clear the TC flag in the ICR register */
1111  __HAL_IRDA_CLEAR_FLAG(hirda, IRDA_CLEAR_TCF);
1112 
1113  /* Process Unlocked */
1114  __HAL_UNLOCK(hirda);
1115 
1116  /* Enable the DMA transfer for transmit request by setting the DMAT bit
1117  in the USART CR3 register */
1118  SET_BIT(hirda->Instance->CR3, USART_CR3_DMAT);
1119 
1120  return HAL_OK;
1121  }
1122  else
1123  {
1124  /* Set error code to DMA */
1125  hirda->ErrorCode = HAL_IRDA_ERROR_DMA;
1126 
1127  /* Process Unlocked */
1128  __HAL_UNLOCK(hirda);
1129 
1130  /* Restore hirda->gState to ready */
1131  hirda->gState = HAL_IRDA_STATE_READY;
1132 
1133  return HAL_ERROR;
1134  }
1135  }
1136  else
1137  {
1138  return HAL_BUSY;
1139  }
1140 }
__HAL_UNLOCK(hrtc)
HAL_StatusTypeDef HAL_DMA_Start_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength)
Start the DMA Transfer with interrupt enabled.
__HAL_LOCK(hrtc)
return HAL_OK
static void IRDA_DMATransmitCplt(DMA_HandleTypeDef *hdma)
DMA IRDA transmit process complete callback.
static void IRDA_DMATransmitHalfCplt(DMA_HandleTypeDef *hdma)
DMA IRDA transmit process half complete callback.
static void IRDA_DMAError(DMA_HandleTypeDef *hdma)
DMA IRDA communication error callback.

◆ HAL_IRDA_Transmit_IT()

HAL_StatusTypeDef HAL_IRDA_Transmit_IT ( IRDA_HandleTypeDef hirda,
uint8_t *  pData,
uint16_t  Size 
)

Send an amount of data in interrupt mode.

Parameters
hirdaPointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified IRDA module.
pDataPointer to data buffer.
SizeAmount of data to be sent.
Return values
HALstatus

Definition at line 976 of file stm32l4xx_hal_irda.c.

977 {
978  /* Check that a Tx process is not already ongoing */
979  if (hirda->gState == HAL_IRDA_STATE_READY)
980  {
981  if ((pData == NULL) || (Size == 0U))
982  {
983  return HAL_ERROR;
984  }
985 
986  /* Process Locked */
987  __HAL_LOCK(hirda);
988 
989  hirda->pTxBuffPtr = pData;
990  hirda->TxXferSize = Size;
991  hirda->TxXferCount = Size;
992 
993  hirda->ErrorCode = HAL_IRDA_ERROR_NONE;
994  hirda->gState = HAL_IRDA_STATE_BUSY_TX;
995 
996  /* Process Unlocked */
997  __HAL_UNLOCK(hirda);
998 
999  /* Enable the IRDA Transmit Data Register Empty Interrupt */
1000 #if defined(USART_CR1_FIFOEN)
1001  SET_BIT(hirda->Instance->CR1, USART_CR1_TXEIE_TXFNFIE);
1002 #else
1003  SET_BIT(hirda->Instance->CR1, USART_CR1_TXEIE);
1004 #endif /* USART_CR1_FIFOEN */
1005 
1006  return HAL_OK;
1007  }
1008  else
1009  {
1010  return HAL_BUSY;
1011  }
1012 }
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
return HAL_OK

◆ HAL_IRDA_TxCpltCallback()

__weak void HAL_IRDA_TxCpltCallback ( IRDA_HandleTypeDef hirda)

Tx Transfer completed callback.

Parameters
hirdaPointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified IRDA module.
Return values
None

Definition at line 2064 of file stm32l4xx_hal_irda.c.

2065 {
2066  /* Prevent unused argument(s) compilation warning */
2067  UNUSED(hirda);
2068 
2069  /* NOTE : This function should not be modified, when the callback is needed,
2070  the HAL_IRDA_TxCpltCallback can be implemented in the user file.
2071  */
2072 }

◆ HAL_IRDA_TxHalfCpltCallback()

__weak void HAL_IRDA_TxHalfCpltCallback ( IRDA_HandleTypeDef hirda)

Tx Half Transfer completed callback.

Parameters
hirdaPointer to a IRDA_HandleTypeDef structure that contains the configuration information for the specified USART module.
Return values
None

Definition at line 2080 of file stm32l4xx_hal_irda.c.

2081 {
2082  /* Prevent unused argument(s) compilation warning */
2083  UNUSED(hirda);
2084 
2085  /* NOTE : This function should not be modified, when the callback is needed,
2086  the HAL_IRDA_TxHalfCpltCallback can be implemented in the user file.
2087  */
2088 }