|
STM32L4xx_HAL_Driver
1.14.0
|
USART HAL module driver. This file provides firmware functions to manage the following functionalities of the Universal Synchronous/Asynchronous Receiver Transmitter Peripheral (USART). More...
Go to the source code of this file.
Functions | |
| void | USART_InitCallbacksToDefault (USART_HandleTypeDef *husart) |
| Initialize the callbacks to their default values. More... | |
| static void | USART_EndTransfer (USART_HandleTypeDef *husart) |
| End ongoing transfer on USART peripheral (following error detection or Transfer completion). More... | |
| static void | USART_DMATransmitCplt (DMA_HandleTypeDef *hdma) |
| DMA USART transmit process complete callback. More... | |
| static void | USART_DMAReceiveCplt (DMA_HandleTypeDef *hdma) |
| DMA USART receive process complete callback. More... | |
| static void | USART_DMATxHalfCplt (DMA_HandleTypeDef *hdma) |
| DMA USART transmit process half complete callback. More... | |
| static void | USART_DMARxHalfCplt (DMA_HandleTypeDef *hdma) |
| DMA USART receive process half complete callback. More... | |
| static void | USART_DMAError (DMA_HandleTypeDef *hdma) |
| DMA USART communication error callback. More... | |
| static void | USART_DMAAbortOnError (DMA_HandleTypeDef *hdma) |
| DMA USART 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 | USART_DMATxAbortCallback (DMA_HandleTypeDef *hdma) |
| DMA USART 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 | USART_DMARxAbortCallback (DMA_HandleTypeDef *hdma) |
| DMA USART Rx communication abort callback, when initiated by user (To be called at end of DMA Rx Abort procedure following user abort request). More... | |
| static HAL_StatusTypeDef | USART_WaitOnFlagUntilTimeout (USART_HandleTypeDef *husart, uint32_t Flag, FlagStatus Status, uint32_t Tickstart, uint32_t Timeout) |
| Handle USART Communication Timeout. More... | |
| static HAL_StatusTypeDef | USART_SetConfig (USART_HandleTypeDef *husart) |
| Configure the USART peripheral. More... | |
| static HAL_StatusTypeDef | USART_CheckIdleState (USART_HandleTypeDef *husart) |
| Check the USART Idle State. More... | |
| static void | USART_TxISR_8BIT (USART_HandleTypeDef *husart) |
| Simplex send an amount of data in non-blocking mode. More... | |
| static void | USART_TxISR_16BIT (USART_HandleTypeDef *husart) |
| Simplex send an amount of data in non-blocking mode. More... | |
| static void | USART_TxISR_8BIT_FIFOEN (USART_HandleTypeDef *husart) |
| Simplex send an amount of data in non-blocking mode. More... | |
| static void | USART_TxISR_16BIT_FIFOEN (USART_HandleTypeDef *husart) |
| Simplex send an amount of data in non-blocking mode. More... | |
| static void | USART_EndTransmit_IT (USART_HandleTypeDef *husart) |
| Wraps up transmission in non-blocking mode. More... | |
| static void | USART_RxISR_8BIT (USART_HandleTypeDef *husart) |
| Simplex receive an amount of data in non-blocking mode. More... | |
| static void | USART_RxISR_16BIT (USART_HandleTypeDef *husart) |
| Simplex receive an amount of data in non-blocking mode. More... | |
| static void | USART_RxISR_8BIT_FIFOEN (USART_HandleTypeDef *husart) |
| Simplex receive an amount of data in non-blocking mode. More... | |
| static void | USART_RxISR_16BIT_FIFOEN (USART_HandleTypeDef *husart) |
| Simplex receive an amount of data in non-blocking mode. More... | |
| HAL_StatusTypeDef | HAL_USART_Init (USART_HandleTypeDef *husart) |
| Initialize the USART mode according to the specified parameters in the USART_InitTypeDef and initialize the associated handle. More... | |
| HAL_StatusTypeDef | HAL_USART_DeInit (USART_HandleTypeDef *husart) |
| DeInitialize the USART peripheral. More... | |
| void | HAL_USART_MspInit (USART_HandleTypeDef *husart) |
| Initialize the USART MSP. More... | |
| void | HAL_USART_MspDeInit (USART_HandleTypeDef *husart) |
| DeInitialize the USART MSP. More... | |
| HAL_StatusTypeDef | HAL_USART_RegisterCallback (USART_HandleTypeDef *husart, HAL_USART_CallbackIDTypeDef CallbackID, pUSART_CallbackTypeDef pCallback) |
| Register a User USART Callback To be used instead of the weak predefined callback. More... | |
| HAL_StatusTypeDef | HAL_USART_UnRegisterCallback (USART_HandleTypeDef *husart, HAL_USART_CallbackIDTypeDef CallbackID) |
| Unregister an UART Callback UART callaback is redirected to the weak predefined callback. More... | |
| 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. More... | |
| HAL_StatusTypeDef | HAL_USART_Receive (USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size, uint32_t Timeout) |
| Receive an amount of data in blocking mode. More... | |
| HAL_StatusTypeDef | HAL_USART_TransmitReceive (USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size, uint32_t Timeout) |
| Full-Duplex Send and Receive an amount of data in blocking mode. More... | |
| HAL_StatusTypeDef | HAL_USART_Transmit_IT (USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size) |
| Send an amount of data in interrupt mode. More... | |
| HAL_StatusTypeDef | HAL_USART_Receive_IT (USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size) |
| Receive an amount of data in interrupt mode. More... | |
| HAL_StatusTypeDef | HAL_USART_TransmitReceive_IT (USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size) |
| Full-Duplex Send and Receive an amount of data in interrupt mode. More... | |
| HAL_StatusTypeDef | HAL_USART_Transmit_DMA (USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size) |
| Send an amount of data in DMA mode. More... | |
| HAL_StatusTypeDef | HAL_USART_Receive_DMA (USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size) |
| Receive an amount of data in DMA mode. More... | |
| 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. More... | |
| HAL_StatusTypeDef | HAL_USART_DMAPause (USART_HandleTypeDef *husart) |
| Pause the DMA Transfer. More... | |
| HAL_StatusTypeDef | HAL_USART_DMAResume (USART_HandleTypeDef *husart) |
| Resume the DMA Transfer. More... | |
| HAL_StatusTypeDef | HAL_USART_DMAStop (USART_HandleTypeDef *husart) |
| Stop the DMA Transfer. More... | |
| HAL_StatusTypeDef | HAL_USART_Abort (USART_HandleTypeDef *husart) |
| Abort ongoing transfers (blocking mode). More... | |
| HAL_StatusTypeDef | HAL_USART_Abort_IT (USART_HandleTypeDef *husart) |
| Abort ongoing transfers (Interrupt mode). More... | |
| void | HAL_USART_IRQHandler (USART_HandleTypeDef *husart) |
| Handle USART interrupt request. More... | |
| void | HAL_USART_TxCpltCallback (USART_HandleTypeDef *husart) |
| Tx Transfer completed callback. More... | |
| void | HAL_USART_TxHalfCpltCallback (USART_HandleTypeDef *husart) |
| Tx Half Transfer completed callback. More... | |
| void | HAL_USART_RxCpltCallback (USART_HandleTypeDef *husart) |
| Rx Transfer completed callback. More... | |
| void | HAL_USART_RxHalfCpltCallback (USART_HandleTypeDef *husart) |
| Rx Half Transfer completed callback. More... | |
| void | HAL_USART_TxRxCpltCallback (USART_HandleTypeDef *husart) |
| Tx/Rx Transfers completed callback for the non-blocking process. More... | |
| void | HAL_USART_ErrorCallback (USART_HandleTypeDef *husart) |
| USART error callback. More... | |
| void | HAL_USART_AbortCpltCallback (USART_HandleTypeDef *husart) |
| USART Abort Complete callback. More... | |
| HAL_USART_StateTypeDef | HAL_USART_GetState (USART_HandleTypeDef *husart) |
| Return the USART handle state. More... | |
| uint32_t | HAL_USART_GetError (USART_HandleTypeDef *husart) |
| Return the USART error code. More... | |
USART HAL module driver. This file provides firmware functions to manage the following functionalities of the Universal Synchronous/Asynchronous Receiver Transmitter Peripheral (USART).
===============================================================================
##### How to use this driver #####
===============================================================================
[..]
The USART HAL driver can be used as follows:
(#) Declare a USART_HandleTypeDef handle structure (eg. USART_HandleTypeDef husart).
(#) 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 these USART pins as alternate function pull-up.
(++) 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.
(++) USART interrupts handling:
-@@- 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.
(++) 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 initialized 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.
(#) Program the Baud Rate, Word Length, Stop Bit, Parity, and Mode
(Receiver/Transmitter) in the husart handle Init structure.
(#) Initialize the USART registers by calling the HAL_USART_Init() API:
(++) This API configures also the low level Hardware GPIO, CLOCK, CORTEX...etc)
by calling the customized HAL_USART_MspInit(&husart) API.
[..]
(@) To configure and enable/disable the USART to wake up the MCU from stop mode, resort to UART API's
HAL_UARTEx_StopModeWakeUpSourceConfig(), HAL_UARTEx_EnableStopMode() and
HAL_UARTEx_DisableStopMode() in casting the USART handle to UART type UART_HandleTypeDef.
##### Callback registration #####
==================================
[..]
The compilation define USE_HAL_USART_REGISTER_CALLBACKS when set to 1
allows the user to configure dynamically the driver callbacks.
[..]
Use Function @ref HAL_USART_RegisterCallback() to register a user callback.
Function @ref HAL_USART_RegisterCallback() allows to register following callbacks:
(+) TxHalfCpltCallback : Tx Half Complete Callback.
(+) TxCpltCallback : Tx Complete Callback.
(+) RxHalfCpltCallback : Rx Half Complete Callback.
(+) RxCpltCallback : Rx Complete Callback.
(+) TxRxCpltCallback : Tx Rx Complete Callback.
(+) ErrorCallback : Error Callback.
(+) AbortCpltCallback : Abort Complete Callback.
(+) RxFifoFullCallback : Rx Fifo Full Callback.
(+) TxFifoEmptyCallback : Tx Fifo Empty Callback.
(+) MspInitCallback : USART MspInit.
(+) MspDeInitCallback : USART 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_USART_UnRegisterCallback() to reset a callback to the default
weak (surcharged) function.
@ref HAL_USART_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.
(+) TxRxCpltCallback : Tx Rx Complete Callback.
(+) ErrorCallback : Error Callback.
(+) AbortCpltCallback : Abort Complete Callback.
(+) RxFifoFullCallback : Rx Fifo Full Callback.
(+) TxFifoEmptyCallback : Tx Fifo Empty Callback.
(+) MspInitCallback : USART MspInit.
(+) MspDeInitCallback : USART MspDeInit.
[..]
By default, after the @ref HAL_USART_Init() and when the state is HAL_USART_STATE_RESET
all callbacks are set to the corresponding weak (surcharged) functions:
examples @ref HAL_USART_TxCpltCallback(), @ref HAL_USART_RxHalfCpltCallback().
Exception done for MspInit and MspDeInit functions that are respectively
reset to the legacy weak (surcharged) functions in the @ref HAL_USART_Init()
and @ref HAL_USART_DeInit() only when these callbacks are null (not registered beforehand).
If not, MspInit or MspDeInit are not null, the @ref HAL_USART_Init() and @ref HAL_USART_DeInit()
keep and use the user MspInit/MspDeInit callbacks (registered beforehand).
[..]
Callbacks can be registered/unregistered in HAL_USART_STATE_READY state only.
Exception done MspInit/MspDeInit that can be registered/unregistered
in HAL_USART_STATE_READY or HAL_USART_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_USART_RegisterCallback() before calling @ref HAL_USART_DeInit()
or @ref HAL_USART_Init() function.
[..]
When The compilation define USE_HAL_USART_REGISTER_CALLBACKS is set to 0 or
not defined, the callback registration feature is not available
and weak (surcharged) callbacks are used.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_usart.c.