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_usart.c File Reference
USART HAL module driver. This file provides firmware functions to manage the following functionalities of the Universal Synchronous Asynchronous Receiver Transmitter (USART) 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 HAL_StatusTypeDef | USART_Transmit_IT (USART_HandleTypeDef *husart) |
Simplex Send an amount of data in non-blocking mode. | |
static HAL_StatusTypeDef | USART_EndTransmit_IT (USART_HandleTypeDef *husart) |
Wraps up transmission in non blocking mode. | |
static HAL_StatusTypeDef | USART_Receive_IT (USART_HandleTypeDef *husart) |
Simplex Receive an amount of data in non-blocking mode. | |
static HAL_StatusTypeDef | USART_TransmitReceive_IT (USART_HandleTypeDef *husart) |
Full-Duplex Send receive an amount of data in full-duplex mode (non-blocking). | |
static void | USART_SetConfig (USART_HandleTypeDef *husart) |
Configures the USART peripheral. | |
static void | USART_DMATransmitCplt (DMA_HandleTypeDef *hdma) |
DMA USART transmit process complete callback. | |
static void | USART_DMATxHalfCplt (DMA_HandleTypeDef *hdma) |
DMA USART transmit process half complete callback. | |
static void | USART_DMAReceiveCplt (DMA_HandleTypeDef *hdma) |
DMA USART receive process complete callback. | |
static void | USART_DMARxHalfCplt (DMA_HandleTypeDef *hdma) |
DMA USART receive process half complete callback. | |
static void | USART_DMAError (DMA_HandleTypeDef *hdma) |
DMA USART communication error callback. | |
static HAL_StatusTypeDef | USART_WaitOnFlagUntilTimeout (USART_HandleTypeDef *husart, uint32_t Flag, FlagStatus Status, uint32_t Timeout) |
This function handles USART Communication Timeout. | |
HAL_StatusTypeDef | HAL_USART_Init (USART_HandleTypeDef *husart) |
Initializes the USART mode according to the specified parameters in the USART_InitTypeDef and create the associated handle. | |
HAL_StatusTypeDef | HAL_USART_DeInit (USART_HandleTypeDef *husart) |
DeInitializes the USART peripheral. | |
__weak void | HAL_USART_MspInit (USART_HandleTypeDef *husart) |
USART MSP Init. | |
__weak void | HAL_USART_MspDeInit (USART_HandleTypeDef *husart) |
USART MSP DeInit. | |
HAL_StatusTypeDef | HAL_USART_Transmit (USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size, uint32_t Timeout) |
Simplex Send an amount of data in blocking mode. | |
HAL_StatusTypeDef | HAL_USART_Receive (USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size, uint32_t Timeout) |
Full-Duplex Receive an amount of data in blocking mode. | |
HAL_StatusTypeDef | HAL_USART_TransmitReceive (USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size, uint32_t Timeout) |
Full-Duplex Send receive an amount of data in full-duplex mode (blocking mode). | |
HAL_StatusTypeDef | HAL_USART_Transmit_IT (USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size) |
Simplex Send an amount of data in non-blocking mode. | |
HAL_StatusTypeDef | HAL_USART_Receive_IT (USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size) |
Simplex Receive an amount of data in non-blocking mode. | |
HAL_StatusTypeDef | HAL_USART_TransmitReceive_IT (USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size) |
Full-Duplex Send receive an amount of data in full-duplex mode (non-blocking). | |
HAL_StatusTypeDef | HAL_USART_Transmit_DMA (USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size) |
Simplex Send an amount of data in non-blocking mode. | |
HAL_StatusTypeDef | HAL_USART_Receive_DMA (USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size) |
Full-Duplex Receive an amount of data in non-blocking mode. | |
HAL_StatusTypeDef | HAL_USART_TransmitReceive_DMA (USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size) |
Full-Duplex Transmit Receive an amount of data in non-blocking mode. | |
HAL_StatusTypeDef | HAL_USART_DMAPause (USART_HandleTypeDef *husart) |
Pauses the DMA Transfer. | |
HAL_StatusTypeDef | HAL_USART_DMAResume (USART_HandleTypeDef *husart) |
Resumes the DMA Transfer. | |
HAL_StatusTypeDef | HAL_USART_DMAStop (USART_HandleTypeDef *husart) |
Stops the DMA Transfer. | |
void | HAL_USART_IRQHandler (USART_HandleTypeDef *husart) |
This function handles USART interrupt request. | |
__weak void | HAL_USART_TxCpltCallback (USART_HandleTypeDef *husart) |
Tx Transfer completed callbacks. | |
__weak void | HAL_USART_TxHalfCpltCallback (USART_HandleTypeDef *husart) |
Tx Half Transfer completed callbacks. | |
__weak void | HAL_USART_RxCpltCallback (USART_HandleTypeDef *husart) |
Rx Transfer completed callbacks. | |
__weak void | HAL_USART_RxHalfCpltCallback (USART_HandleTypeDef *husart) |
Rx Half Transfer completed callbacks. | |
__weak void | HAL_USART_TxRxCpltCallback (USART_HandleTypeDef *husart) |
Tx/Rx Transfers completed callback for the non-blocking process. | |
__weak void | HAL_USART_ErrorCallback (USART_HandleTypeDef *husart) |
USART error callbacks. | |
HAL_USART_StateTypeDef | HAL_USART_GetState (USART_HandleTypeDef *husart) |
Returns the USART state. | |
uint32_t | HAL_USART_GetError (USART_HandleTypeDef *husart) |
Return the USART error code. |
Detailed Description
USART HAL module driver. This file provides firmware functions to manage the following functionalities of the Universal Synchronous Asynchronous Receiver Transmitter (USART) 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 USART HAL driver can be used as follows: (#) Declare a USART_HandleTypeDef handle structure. (#) Initialize the USART low level resources by implementing the HAL_USART_MspInit() API: (##) Enable the USARTx interface clock. (##) USART pins configuration: (+++) Enable the clock for the USART 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_USART_Transmit_IT(), HAL_USART_Receive_IT() and HAL_USART_TransmitReceive_IT() APIs): (+++) Configure the USARTx interrupt priority. (+++) Enable the NVIC USART IRQ handle. (##) DMA Configuration if you need to use DMA process (HAL_USART_Transmit_DMA() HAL_USART_Receive_DMA() and HAL_USART_TransmitReceive_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 initilalized DMA handle to the USART 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 husart Init structure. (#) Initialize the USART registers by calling the HAL_USART_Init() API: (++) These APIs configures also the low level Hardware GPIO, CLOCK, CORTEX...etc) by calling the customed HAL_USART_MspInit(&husart) API. -@@- The specific USART interrupts (Transmission complete interrupt, RXNE interrupt and Error Interrupts) will be managed using the macros __HAL_USART_ENABLE_IT() and __HAL_USART_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_USART_Transmit() (+) Receive an amount of data in blocking mode using HAL_USART_Receive() *** Interrupt mode IO operation *** =================================== [..] (+) Send an amount of data in non blocking mode using HAL_USART_Transmit_IT() (+) At transmission end of transfer HAL_USART_TxCpltCallback is executed and user can add his own code by customization of function pointer HAL_USART_TxCpltCallback (+) Receive an amount of data in non blocking mode using HAL_USART_Receive_IT() (+) At reception end of transfer HAL_USART_RxCpltCallback is executed and user can add his own code by customization of function pointer HAL_USART_RxCpltCallback (+) In case of transfer Error, HAL_USART_ErrorCallback() function is executed and user can add his own code by customization of function pointer HAL_USART_ErrorCallback *** DMA mode IO operation *** ============================== [..] (+) Send an amount of data in non blocking mode (DMA) using HAL_USART_Transmit_DMA() (+) At transmission end of half transfer HAL_USART_TxHalfCpltCallback is executed and user can add his own code by customization of function pointer HAL_USART_TxHalfCpltCallback (+) At transmission end of transfer HAL_USART_TxCpltCallback is executed and user can add his own code by customization of function pointer HAL_USART_TxCpltCallback (+) Receive an amount of data in non blocking mode (DMA) using HAL_USART_Receive_DMA() (+) At reception end of half transfer HAL_USART_RxHalfCpltCallback is executed and user can add his own code by customization of function pointer HAL_USART_RxHalfCpltCallback (+) At reception end of transfer HAL_USART_RxCpltCallback is executed and user can add his own code by customization of function pointer HAL_USART_RxCpltCallback (+) In case of transfer Error, HAL_USART_ErrorCallback() function is executed and user can add his own code by customization of function pointer HAL_USART_ErrorCallback (+) Pause the DMA Transfer using HAL_USART_DMAPause() (+) Resume the DMA Transfer using HAL_USART_DMAResume() (+) Stop the DMA Transfer using HAL_USART_DMAStop() *** USART HAL driver macros list *** ============================================= [..] Below the list of most used macros in USART HAL driver. (+) __HAL_USART_ENABLE: Enable the USART peripheral (+) __HAL_USART_DISABLE: Disable the USART peripheral (+) __HAL_USART_GET_FLAG : Check whether the specified USART flag is set or not (+) __HAL_USART_CLEAR_FLAG : Clear the specified USART pending flag (+) __HAL_USART_ENABLE_IT: Enable the specified USART interrupt (+) __HAL_USART_DISABLE_IT: Disable the specified USART interrupt (+) __HAL_USART_GET_IT_SOURCE: Check whether the specified USART interrupt has occurred or not [..] (@) You can refer to the USART 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_usart.c.
Generated on Tue Jul 12 2022 15:37:30 by
