ST STM32F2 User Manual page 648

Description of stm32f2 hal and low layer drivers
Hide thumbs Also See for STM32F2:
Table of Contents

Advertisement

HAL UART Generic Driver
c.
d.
3.
Program the Baud Rate, Word Length, Stop Bit, Parity, Hardware flow control and
Mode(Receiver/Transmitter) in the Init structure.
4.
For the UART asynchronous mode, initialize the UART registers by calling the
HAL_UART_Init() API.
5.
For the UART Half duplex mode, initialize the UART registers by calling the
HAL_HalfDuplex_Init() API.
6.
For the LIN mode, initialize the UART registers by calling the HAL_LIN_Init() API.
7.
For the Multi-Processor mode, initialize the UART registers by calling the
HAL_MultiProcessor_Init() 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
648/1371
Configure these UART pins as alternate function pull-up.
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 stream.
Enable the DMAx interface clock.
Configure the declared DMA handle structure with the required Tx/Rx
parameters.
Configure the DMA Tx/Rx Stream.
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 Stream.
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 customized
HAL_UART_MspInit() API.
DocID028236 Rev 2
UM1940

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the STM32F2 and is the answer not in the manual?

Questions and answers

Table of Contents

Save PDF