Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
stm32f1xx_hal_uart.c File Reference
UART HAL module driver. This file provides firmware functions to manage the following functionalities of the Universal Asynchronous Receiver Transmitter (UART) peripheral: + Initialization and de-initialization functions + IO operation functions + Peripheral Control functions + Peripheral State and Errors functions. More...
Go to the source code of this file.
Functions | |
| static void | UART_SetConfig (UART_HandleTypeDef *huart) |
| Configures the UART peripheral. | |
| static HAL_StatusTypeDef | UART_Transmit_IT (UART_HandleTypeDef *huart) |
| Sends an amount of data in non blocking mode. | |
| static HAL_StatusTypeDef | UART_EndTransmit_IT (UART_HandleTypeDef *huart) |
| Wraps up transmission in non blocking mode. | |
| static HAL_StatusTypeDef | UART_Receive_IT (UART_HandleTypeDef *huart) |
| Receives an amount of data in non blocking mode. | |
| static void | UART_DMATransmitCplt (DMA_HandleTypeDef *hdma) |
| DMA UART transmit process complete callback. | |
| static void | UART_DMATxHalfCplt (DMA_HandleTypeDef *hdma) |
| DMA UART transmit process half complete callback. | |
| static void | UART_DMAReceiveCplt (DMA_HandleTypeDef *hdma) |
| DMA UART receive process complete callback. | |
| static void | UART_DMARxHalfCplt (DMA_HandleTypeDef *hdma) |
| DMA UART receive process half complete callback. | |
| static void | UART_DMAError (DMA_HandleTypeDef *hdma) |
| DMA UART communication error callback. | |
| static HAL_StatusTypeDef | UART_WaitOnFlagUntilTimeout (UART_HandleTypeDef *huart, uint32_t Flag, FlagStatus Status, uint32_t Timeout) |
| This function handles UART Communication Timeout. | |
| HAL_StatusTypeDef | HAL_UART_Init (UART_HandleTypeDef *huart) |
| Initializes the UART mode according to the specified parameters in the UART_InitTypeDef and create the associated handle. | |
| HAL_StatusTypeDef | HAL_HalfDuplex_Init (UART_HandleTypeDef *huart) |
| Initializes the half-duplex mode according to the specified parameters in the UART_InitTypeDef and create the associated handle. | |
| HAL_StatusTypeDef | HAL_LIN_Init (UART_HandleTypeDef *huart, uint32_t BreakDetectLength) |
| Initializes the LIN mode according to the specified parameters in the UART_InitTypeDef and create the associated handle. | |
| HAL_StatusTypeDef | HAL_MultiProcessor_Init (UART_HandleTypeDef *huart, uint8_t Address, uint32_t WakeUpMethod) |
| Initializes the Multi-Processor mode according to the specified parameters in the UART_InitTypeDef and create the associated handle. | |
| HAL_StatusTypeDef | HAL_UART_DeInit (UART_HandleTypeDef *huart) |
| DeInitializes the UART peripheral. | |
| __weak void | HAL_UART_MspInit (UART_HandleTypeDef *huart) |
| UART MSP Init. | |
| __weak void | HAL_UART_MspDeInit (UART_HandleTypeDef *huart) |
| UART MSP DeInit. | |
| HAL_StatusTypeDef | HAL_UART_Transmit (UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout) |
| Sends an amount of data in blocking mode. | |
| HAL_StatusTypeDef | HAL_UART_Receive (UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout) |
| Receives an amount of data in blocking mode. | |
| HAL_StatusTypeDef | HAL_UART_Transmit_IT (UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size) |
| Sends an amount of data in non blocking mode. | |
| HAL_StatusTypeDef | HAL_UART_Receive_IT (UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size) |
| Receives an amount of data in non blocking mode. | |
| HAL_StatusTypeDef | HAL_UART_Transmit_DMA (UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size) |
| Sends an amount of data in non blocking mode. | |
| HAL_StatusTypeDef | HAL_UART_Receive_DMA (UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size) |
| Receives an amount of data in non blocking mode. | |
| HAL_StatusTypeDef | HAL_UART_DMAPause (UART_HandleTypeDef *huart) |
| Pauses the DMA Transfer. | |
| HAL_StatusTypeDef | HAL_UART_DMAResume (UART_HandleTypeDef *huart) |
| Resumes the DMA Transfer. | |
| HAL_StatusTypeDef | HAL_UART_DMAStop (UART_HandleTypeDef *huart) |
| Stops the DMA Transfer. | |
| void | HAL_UART_IRQHandler (UART_HandleTypeDef *huart) |
| This function handles UART interrupt request. | |
| __weak void | HAL_UART_TxCpltCallback (UART_HandleTypeDef *huart) |
| Tx Transfer completed callbacks. | |
| __weak void | HAL_UART_TxHalfCpltCallback (UART_HandleTypeDef *huart) |
| Tx Half Transfer completed callbacks. | |
| __weak void | HAL_UART_RxCpltCallback (UART_HandleTypeDef *huart) |
| Rx Transfer completed callbacks. | |
| __weak void | HAL_UART_RxHalfCpltCallback (UART_HandleTypeDef *huart) |
| Rx Half Transfer completed callbacks. | |
| __weak void | HAL_UART_ErrorCallback (UART_HandleTypeDef *huart) |
| UART error callbacks. | |
| HAL_StatusTypeDef | HAL_LIN_SendBreak (UART_HandleTypeDef *huart) |
| Transmits break characters. | |
| HAL_StatusTypeDef | HAL_MultiProcessor_EnterMuteMode (UART_HandleTypeDef *huart) |
| Enters the UART in mute mode. | |
| HAL_StatusTypeDef | HAL_MultiProcessor_ExitMuteMode (UART_HandleTypeDef *huart) |
| Exits the UART mute mode: wake up software. | |
| HAL_StatusTypeDef | HAL_HalfDuplex_EnableTransmitter (UART_HandleTypeDef *huart) |
| Enables the UART transmitter and disables the UART receiver. | |
| HAL_StatusTypeDef | HAL_HalfDuplex_EnableReceiver (UART_HandleTypeDef *huart) |
| Enables the UART receiver and disables the UART transmitter. | |
| HAL_UART_StateTypeDef | HAL_UART_GetState (UART_HandleTypeDef *huart) |
| Returns the UART state. | |
| uint32_t | HAL_UART_GetError (UART_HandleTypeDef *huart) |
| Return the UART error code. | |
Detailed Description
UART HAL module driver. This file provides firmware functions to manage the following functionalities of the Universal Asynchronous Receiver Transmitter (UART) peripheral: + Initialization and de-initialization functions + IO operation functions + Peripheral Control functions + Peripheral State and Errors functions.
- Version:
- V1.0.4
- Date:
- 29-April-2016
============================================================================== ##### How to use this driver ##### ============================================================================== [..] The UART HAL driver can be used as follows: (#) Declare a UART_HandleTypeDef handle structure. (#) Initialize the UART low level resources by implementing the HAL_UART_MspInit() API: (##) Enable the USARTx interface clock. (##) UART pins configuration: (+++) Enable the clock for the UART GPIOs. (+++) Configure the USART pins (TX as alternate function pull-up, RX as alternate function Input). (##) NVIC configuration if you need to use interrupt process (HAL_UART_Transmit_IT() and HAL_UART_Receive_IT() APIs): (+++) Configure the USARTx interrupt priority. (+++) Enable the NVIC USART IRQ handle. (##) DMA Configuration if you need to use DMA process (HAL_UART_Transmit_DMA() and HAL_UART_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 UART DMA Tx/Rx handle. (+++) Configure the priority and enable the NVIC for the transfer complete interrupt on the DMA Tx/Rx channel. (+++) Configure the USARTx interrupt priority and enable the NVIC USART IRQ handle (used for last byte sending completion detection in DMA non circular mode) (#) Program the Baud Rate, Word Length, Stop Bit, Parity, Hardware flow control and Mode(Receiver/Transmitter) in the huart Init structure. (#) For the UART asynchronous mode, initialize the UART registers by calling the HAL_UART_Init() API. (#) For the UART Half duplex mode, initialize the UART registers by calling the HAL_HalfDuplex_Init() API. (#) For the LIN mode, initialize the UART registers by calling the HAL_LIN_Init() API. (#) For the Multi-Processor mode, initialize the UART registers by calling the HAL_MultiProcessor_Init() API. [..] (@) The specific UART interrupts (Transmission complete interrupt, RXNE interrupt and Error Interrupts) will be managed using the macros __HAL_UART_ENABLE_IT() and __HAL_UART_DISABLE_IT() inside the transmit and receive process. [..] (@) These APIs (HAL_UART_Init() and HAL_HalfDuplex_Init()) configure also the low level Hardware GPIO, CLOCK, CORTEX...etc) by calling the customed HAL_UART_MspInit() API. [..] Three operation modes are available within this driver : *** Polling mode IO operation *** ================================= [..] (+) Send an amount of data in blocking mode using HAL_UART_Transmit() (+) Receive an amount of data in blocking mode using HAL_UART_Receive() *** Interrupt mode IO operation *** =================================== [..] (+) Send an amount of data in non blocking mode using HAL_UART_Transmit_IT() (+) At transmission end of transfer HAL_UART_TxCpltCallback is executed and user can add his own code by customization of function pointer HAL_UART_TxCpltCallback (+) Receive an amount of data in non blocking mode using HAL_UART_Receive_IT() (+) At reception end of transfer HAL_UART_RxCpltCallback is executed and user can add his own code by customization of function pointer HAL_UART_RxCpltCallback (+) In case of transfer Error, HAL_UART_ErrorCallback() function is executed and user can add his own code by customization of function pointer HAL_UART_ErrorCallback *** DMA mode IO operation *** ============================== [..] (+) Send an amount of data in non blocking mode (DMA) using HAL_UART_Transmit_DMA() (+) At transmission end of half transfer HAL_UART_TxHalfCpltCallback is executed and user can add his own code by customization of function pointer HAL_UART_TxHalfCpltCallback (+) At transmission end of transfer HAL_UART_TxCpltCallback is executed and user can add his own code by customization of function pointer HAL_UART_TxCpltCallback (+) Receive an amount of data in non blocking mode (DMA) using HAL_UART_Receive_DMA() (+) At reception end of half transfer HAL_UART_RxHalfCpltCallback is executed and user can add his own code by customization of function pointer HAL_UART_RxHalfCpltCallback (+) At reception end of transfer HAL_UART_RxCpltCallback is executed and user can add his own code by customization of function pointer HAL_UART_RxCpltCallback (+) In case of transfer Error, HAL_UART_ErrorCallback() function is executed and user can add his own code by customization of function pointer HAL_UART_ErrorCallback (+) Pause the DMA Transfer using HAL_UART_DMAPause() (+) Resume the DMA Transfer using HAL_UART_DMAResume() (+) Stop the DMA Transfer using HAL_UART_DMAStop() *** UART HAL driver macros list *** ============================================= [..] Below the list of most used macros in UART HAL driver. (+) __HAL_UART_ENABLE: Enable the UART peripheral (+) __HAL_UART_DISABLE: Disable the UART peripheral (+) __HAL_UART_GET_FLAG : Check whether the specified UART flag is set or not (+) __HAL_UART_CLEAR_FLAG : Clear the specified UART pending flag (+) __HAL_UART_ENABLE_IT: Enable the specified UART interrupt (+) __HAL_UART_DISABLE_IT: Disable the specified UART interrupt (+) __HAL_UART_GET_IT_SOURCE: Check whether the specified UART interrupt has occurred or not [..] (@) You can refer to the UART HAL driver header file for more useful macros
- Attention:
© COPYRIGHT(c) 2016 STMicroelectronics
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Definition in file stm32f1xx_hal_uart.c.
Generated on Tue Jul 12 2022 15:37:30 by
1.7.2