STM32L4xx_HAL_Driver  1.14.0
stm32l4xx_hal_irda.c File Reference

IRDA HAL module driver. This file provides firmware functions to manage the following functionalities of the IrDA (Infrared Data Association) Peripheral (IRDA) More...

Go to the source code of this file.

Functions

void IRDA_InitCallbacksToDefault (IRDA_HandleTypeDef *hirda)
 Initialize the callbacks to their default values. More...
 
static HAL_StatusTypeDef IRDA_SetConfig (IRDA_HandleTypeDef *hirda)
 Configure the IRDA peripheral. More...
 
static HAL_StatusTypeDef IRDA_CheckIdleState (IRDA_HandleTypeDef *hirda)
 Check the IRDA Idle State. More...
 
static HAL_StatusTypeDef IRDA_WaitOnFlagUntilTimeout (IRDA_HandleTypeDef *hirda, uint32_t Flag, FlagStatus Status, uint32_t Tickstart, uint32_t Timeout)
 Handle IRDA Communication Timeout. More...
 
static void IRDA_EndTxTransfer (IRDA_HandleTypeDef *hirda)
 End ongoing Tx transfer on IRDA peripheral (following error detection or Transmit completion). More...
 
static void IRDA_EndRxTransfer (IRDA_HandleTypeDef *hirda)
 End ongoing Rx transfer on UART peripheral (following error detection or Reception completion). More...
 
static void IRDA_DMATransmitCplt (DMA_HandleTypeDef *hdma)
 DMA IRDA transmit process complete callback. More...
 
static void IRDA_DMATransmitHalfCplt (DMA_HandleTypeDef *hdma)
 DMA IRDA transmit process half complete callback. More...
 
static void IRDA_DMAReceiveCplt (DMA_HandleTypeDef *hdma)
 DMA IRDA receive process complete callback. More...
 
static void IRDA_DMAReceiveHalfCplt (DMA_HandleTypeDef *hdma)
 DMA IRDA receive process half complete callback. More...
 
static void IRDA_DMAError (DMA_HandleTypeDef *hdma)
 DMA IRDA communication error callback. More...
 
static void IRDA_DMAAbortOnError (DMA_HandleTypeDef *hdma)
 DMA IRDA communication abort callback, when initiated by HAL services on Error (To be called at end of DMA Abort procedure following error occurrence). More...
 
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 procedure following user abort request). More...
 
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 procedure following user abort request). More...
 
static void IRDA_DMATxOnlyAbortCallback (DMA_HandleTypeDef *hdma)
 DMA IRDA Tx communication abort callback, when initiated by user by a call to HAL_IRDA_AbortTransmit_IT API (Abort only Tx transfer) (This callback is executed at end of DMA Tx Abort procedure following user abort request, and leads to user Tx Abort Complete callback execution). More...
 
static void IRDA_DMARxOnlyAbortCallback (DMA_HandleTypeDef *hdma)
 DMA IRDA Rx communication abort callback, when initiated by user by a call to HAL_IRDA_AbortReceive_IT API (Abort only Rx transfer) (This callback is executed at end of DMA Rx Abort procedure following user abort request, and leads to user Rx Abort Complete callback execution). More...
 
static void IRDA_Transmit_IT (IRDA_HandleTypeDef *hirda)
 Send an amount of data in interrupt mode. More...
 
static void IRDA_EndTransmit_IT (IRDA_HandleTypeDef *hirda)
 Wrap up transmission in non-blocking mode. More...
 
static void IRDA_Receive_IT (IRDA_HandleTypeDef *hirda)
 Receive an amount of data in interrupt mode. More...
 
HAL_StatusTypeDef HAL_IRDA_Init (IRDA_HandleTypeDef *hirda)
 Initialize the IRDA mode according to the specified parameters in the IRDA_InitTypeDef and initialize the associated handle. More...
 
HAL_StatusTypeDef HAL_IRDA_DeInit (IRDA_HandleTypeDef *hirda)
 DeInitialize the IRDA peripheral. More...
 
void HAL_IRDA_MspInit (IRDA_HandleTypeDef *hirda)
 Initialize the IRDA MSP. More...
 
void HAL_IRDA_MspDeInit (IRDA_HandleTypeDef *hirda)
 DeInitialize the IRDA MSP. More...
 
HAL_StatusTypeDef HAL_IRDA_RegisterCallback (IRDA_HandleTypeDef *hirda, HAL_IRDA_CallbackIDTypeDef CallbackID, pIRDA_CallbackTypeDef pCallback)
 Register a User IRDA Callback To be used instead of the weak predefined callback. More...
 
HAL_StatusTypeDef HAL_IRDA_UnRegisterCallback (IRDA_HandleTypeDef *hirda, HAL_IRDA_CallbackIDTypeDef CallbackID)
 Unregister an IRDA callback IRDA callback is redirected to the weak predefined callback. More...
 
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_TxHalfCpltCallback (IRDA_HandleTypeDef *hirda)
 Tx Half Transfer completed callback. More...
 
void HAL_IRDA_RxCpltCallback (IRDA_HandleTypeDef *hirda)
 Rx 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...
 
HAL_IRDA_StateTypeDef HAL_IRDA_GetState (IRDA_HandleTypeDef *hirda)
 Return the IRDA handle state. More...
 
uint32_t HAL_IRDA_GetError (IRDA_HandleTypeDef *hirda)
 Return the IRDA handle error code. More...
 

Detailed Description

IRDA HAL module driver. This file provides firmware functions to manage the following functionalities of the IrDA (Infrared Data Association) Peripheral (IRDA)

Author
MCD Application Team
  • Initialization and de-initialization functions
  • IO operation functions
  • Peripheral State and Errors functions
  • Peripheral Control functions
==============================================================================
                      ##### How to use this driver #####
==============================================================================
[..]
  The IRDA HAL driver can be used as follows:

  (#) Declare a IRDA_HandleTypeDef handle structure (eg. IRDA_HandleTypeDef hirda).
  (#) Initialize the IRDA low level resources by implementing the HAL_IRDA_MspInit() API
      in setting the associated USART or UART in IRDA mode:
      (++) Enable the USARTx/UARTx interface clock.
      (++) USARTx/UARTx pins configuration:
          (+++) Enable the clock for the USARTx/UARTx GPIOs.
          (+++) Configure these USARTx/UARTx pins (TX as alternate function pull-up, RX as alternate function Input).
      (++) NVIC configuration if you need to use interrupt process (HAL_IRDA_Transmit_IT()
           and HAL_IRDA_Receive_IT() APIs):
          (+++) Configure the USARTx/UARTx interrupt priority.
          (+++) Enable the NVIC USARTx/UARTx IRQ handle.
          (+++) The specific IRDA interrupts (Transmission complete interrupt,
                RXNE interrupt and Error Interrupts) will be managed using the macros
                __HAL_IRDA_ENABLE_IT() and __HAL_IRDA_DISABLE_IT() inside the transmit and receive process.

      (++) DMA Configuration if you need to use DMA process (HAL_IRDA_Transmit_DMA()
           and HAL_IRDA_Receive_DMA() APIs):
          (+++) Declare a DMA handle structure for the Tx/Rx channel.
          (+++) Enable the DMAx interface clock.
          (+++) Configure the declared DMA handle structure with the required Tx/Rx parameters.
          (+++) Configure the DMA Tx/Rx channel.
          (+++) Associate the initialized DMA handle to the IRDA DMA Tx/Rx handle.
          (+++) Configure the priority and enable the NVIC for the transfer complete interrupt on the DMA Tx/Rx channel.

  (#) Program the Baud Rate, Word Length and Parity and Mode(Receiver/Transmitter),
      the normal or low power mode and the clock prescaler in the hirda handle Init structure.

  (#) Initialize the IRDA registers by calling the HAL_IRDA_Init() API:
      (++) This API configures also the low level Hardware GPIO, CLOCK, CORTEX...etc)
           by calling the customized HAL_IRDA_MspInit() API.

       -@@- The specific IRDA interrupts (Transmission complete interrupt,
           RXNE interrupt and Error Interrupts) will be managed using the macros
           __HAL_IRDA_ENABLE_IT() and __HAL_IRDA_DISABLE_IT() inside the transmit and receive process.

  (#) Three operation modes are available within this driver :

   *** Polling mode IO operation ***
   =================================
   [..]
     (+) Send an amount of data in blocking mode using HAL_IRDA_Transmit()
     (+) Receive an amount of data in blocking mode using HAL_IRDA_Receive()

   *** Interrupt mode IO operation ***
   ===================================
   [..]
     (+) Send an amount of data in non-blocking mode using HAL_IRDA_Transmit_IT()
     (+) At transmission end of transfer HAL_IRDA_TxCpltCallback() is executed and user can
          add his own code by customization of function pointer HAL_IRDA_TxCpltCallback()
     (+) Receive an amount of data in non-blocking mode using HAL_IRDA_Receive_IT()
     (+) At reception end of transfer HAL_IRDA_RxCpltCallback() is executed and user can
          add his own code by customization of function pointer HAL_IRDA_RxCpltCallback()
     (+) In case of transfer Error, HAL_IRDA_ErrorCallback() function is executed and user can
          add his own code by customization of function pointer HAL_IRDA_ErrorCallback()

   *** DMA mode IO operation ***
   ==============================
   [..]
     (+) Send an amount of data in non-blocking mode (DMA) using HAL_IRDA_Transmit_DMA()
     (+) At transmission half of transfer HAL_IRDA_TxHalfCpltCallback() is executed and user can
          add his own code by customization of function pointer HAL_IRDA_TxHalfCpltCallback()
     (+) At transmission end of transfer HAL_IRDA_TxCpltCallback() is executed and user can
          add his own code by customization of function pointer HAL_IRDA_TxCpltCallback()
     (+) Receive an amount of data in non-blocking mode (DMA) using HAL_IRDA_Receive_DMA()
     (+) At reception half of transfer HAL_IRDA_RxHalfCpltCallback() is executed and user can
          add his own code by customization of function pointer HAL_IRDA_RxHalfCpltCallback()
     (+) At reception end of transfer HAL_IRDA_RxCpltCallback() is executed and user can
          add his own code by customization of function pointer HAL_IRDA_RxCpltCallback()
     (+) In case of transfer Error, HAL_IRDA_ErrorCallback() function is executed and user can
          add his own code by customization of function pointer HAL_IRDA_ErrorCallback()

   *** IRDA HAL driver macros list ***
   ====================================
   [..]
     Below the list of most used macros in IRDA HAL driver.

     (+) __HAL_IRDA_ENABLE: Enable the IRDA peripheral
     (+) __HAL_IRDA_DISABLE: Disable the IRDA peripheral
     (+) __HAL_IRDA_GET_FLAG : Check whether the specified IRDA flag is set or not
     (+) __HAL_IRDA_CLEAR_FLAG : Clear the specified IRDA pending flag
     (+) __HAL_IRDA_ENABLE_IT: Enable the specified IRDA interrupt
     (+) __HAL_IRDA_DISABLE_IT: Disable the specified IRDA interrupt
     (+) __HAL_IRDA_GET_IT_SOURCE: Check whether or not the specified IRDA interrupt is enabled

   [..]
     (@) You can refer to the IRDA HAL driver header file for more useful macros

  ##### Callback registration #####
  ==================================

  [..]
  The compilation define USE_HAL_IRDA_REGISTER_CALLBACKS when set to 1
  allows the user to configure dynamically the driver callbacks.

  [..]
  Use Function @ref HAL_IRDA_RegisterCallback() to register a user callback.
  Function @ref HAL_IRDA_RegisterCallback() allows to register following callbacks:
  (+) TxHalfCpltCallback        : Tx Half Complete Callback.
  (+) TxCpltCallback            : Tx Complete Callback.
  (+) RxHalfCpltCallback        : Rx Half Complete Callback.
  (+) RxCpltCallback            : Rx Complete Callback.
  (+) ErrorCallback             : Error Callback.
  (+) AbortCpltCallback         : Abort Complete Callback.
  (+) AbortTransmitCpltCallback : Abort Transmit Complete Callback.
  (+) AbortReceiveCpltCallback  : Abort Receive Complete Callback.
  (+) MspInitCallback           : IRDA MspInit.
  (+) MspDeInitCallback         : IRDA MspDeInit.
  This function takes as parameters the HAL peripheral handle, the Callback ID
  and a pointer to the user callback function.

  [..]
  Use function @ref HAL_IRDA_UnRegisterCallback() to reset a callback to the default
  weak (surcharged) function.
  @ref HAL_IRDA_UnRegisterCallback() takes as parameters the HAL peripheral handle,
  and the Callback ID.
  This function allows to reset following callbacks:
  (+) TxHalfCpltCallback        : Tx Half Complete Callback.
  (+) TxCpltCallback            : Tx Complete Callback.
  (+) RxHalfCpltCallback        : Rx Half Complete Callback.
  (+) RxCpltCallback            : Rx Complete Callback.
  (+) ErrorCallback             : Error Callback.
  (+) AbortCpltCallback         : Abort Complete Callback.
  (+) AbortTransmitCpltCallback : Abort Transmit Complete Callback.
  (+) AbortReceiveCpltCallback  : Abort Receive Complete Callback.
  (+) MspInitCallback           : IRDA MspInit.
  (+) MspDeInitCallback         : IRDA MspDeInit.

  [..]
  By default, after the @ref HAL_IRDA_Init() and when the state is HAL_IRDA_STATE_RESET
  all callbacks are set to the corresponding weak (surcharged) functions:
  examples @ref HAL_IRDA_TxCpltCallback(), @ref HAL_IRDA_RxHalfCpltCallback().
  Exception done for MspInit and MspDeInit functions that are respectively
  reset to the legacy weak (surcharged) functions in the @ref HAL_IRDA_Init()
  and @ref HAL_IRDA_DeInit() only when these callbacks are null (not registered beforehand).
  If not, MspInit or MspDeInit are not null, the @ref HAL_IRDA_Init() and @ref HAL_IRDA_DeInit()
  keep and use the user MspInit/MspDeInit callbacks (registered beforehand).

  [..]
  Callbacks can be registered/unregistered in HAL_IRDA_STATE_READY state only.
  Exception done MspInit/MspDeInit that can be registered/unregistered
  in HAL_IRDA_STATE_READY or HAL_IRDA_STATE_RESET state, thus registered (user)
  MspInit/DeInit callbacks can be used during the Init/DeInit.
  In that case first register the MspInit/MspDeInit user callbacks
  using @ref HAL_IRDA_RegisterCallback() before calling @ref HAL_IRDA_DeInit()
  or @ref HAL_IRDA_Init() function.

  [..]
  When The compilation define USE_HAL_IRDA_REGISTER_CALLBACKS is set to 0 or
  not defined, the callback registration feature is not available
  and weak (surcharged) callbacks are used.
Attention

© Copyright (c) 2017 STMicroelectronics. All rights reserved.

This software component is licensed by ST under BSD 3-Clause license, the "License"; You may not use this file except in compliance with the License. You may obtain a copy of the License at: opensource.org/licenses/BSD-3-Clause

Definition in file stm32l4xx_hal_irda.c.