在 STM32F4 固件库中对串口 USART 的描述原文如下:
************************************************************************
* @brief This file provides firmware functions to manage the following
* functionalities of the Universal synchronous asynchronous receiver
* transmitter (USART):
* + Initialization and Configuration
* + Data transfers
* + Multi-Processor Communication
* + LIN mode
* + Half-duplex mode
* + Smartcard mode
* + IrDA mode
* + DMA transfers management
* + Interrupts and flags management
*
===================================================================
##### How to use this driver #####
===================================================================
[..]
(#) Enable peripheral clock using the following functions
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USARTx, ENABLE) for USART1 and USART6
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USARTx, ENABLE) for USART2, USART3,
UART4 or UART5.
(#) According to the USART mode, enable the GPIO clocks using
RCC_AHB1PeriphClockCmd() function. (The I/O can be TX, RX, CTS,
or/and SCLK).
(#) Peripheral's alternate function:
(++) Connect the pin to the desired peripherals' Alternate
Function (AF) using GPIO_PinAFConfig() function
(++) Configure the desired pin in alternate function by:
GPIO_InitStruct->GPIO_Mode = GPIO_Mode_AF
(++) Select the type, pull-up/pull-down and output speed via
GPIO_PuPd, GPIO_OType and GPIO_Speed members
(++) Call GPIO_Init() function
(#) Program the Baud Rate, Word Length , Stop Bit, Parity, Hardware
flow control and Mode(Receiver/Transmitter) using the USART_Init()
function.
(#) For synchronous mode, enable the clock and program the polarity,
phase and last bit using the USART_ClockInit() function.
(#) Enable the NVIC and the corresponding interrupt using the function
USART_ITConfig() if you need to use interrupt mode.
(#) When using the DMA mode
(++) Configure the DMA using DMA_Init() function
(++) Active the needed channel Request using USART_DMACmd() function
(#) Enable the USART using the USART_Cmd() function.
(#) Enable the DMA using the DMA_Cmd() function, when using DMA mode.
-@- Refer to Multi-Processor, LIN, half-duplex, Smartcard, IrDA sub-sections
for more details
[..]
In order to reach higher communication baudrates, it is possible to
enable the oversampling by 8 mode using the function USART_OverSampling8Cmd().
This function should be called after enabling the USART clock (RCC_APBxPeriphClockCmd())
and before calling the function USART_Init().
@endverbatim
******************************************************************************
* @attention
*
*
© COPYRIGHT 2014 STMicroelectronics
*
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.st.com/software_license_agreement_liberty_v2
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************
* @brief 此文件提供固件功能来管理以下内容
* @通用同步异步接收器的功能
* +初始化和配置
* +数据传输
* +多处理器通信
* + LIN模式
* +半双工模式
* +智能卡模式
* +IrDA模式
* +DMA传输管理
* +中断和标志管理
===============================================================================
#####如何使用这个驱动#####
===============================================================================
[**]
(1.)使用以下功能启用外围时钟
对于USART1和USART6, rcc_apb2periperi_cmd (rcc_apb2peri_usartx, ENABLE)
rcc_apb1periperi_usartcmd (rcc_apb1peri_usartx, ENABLE) for USART2, USART3,UART4或UART5。
根据USART模式,启用GPIO时钟使用RCC_AHB1PeriphClockCmd()函数。(I/O可以是TX, RX, CTS,或/和SCLK)。
(2.)外围设备的复用功能:
(++)连接引脚所需的外设的备用
使用GPIO_PinAFConfig()函数实现
(++)配置所需的引脚在备用功能:
GPIO_InitStruct - > GPIO_Mode = GPIO_Mode_AF
(++)选择类型,上拉/下拉和输出速度通过 GPIO_PuPd、GPIO_OType和GPIO_Speed 成员调用 GPIO_Init()函数
(3.)编写波特率,字长,停止位,奇偶校验,硬件使用USART_Init()的流量控制和模式(接收/发射)函数。
(4.)同步模式,启用时钟和程序极性,使用usart_clockkinit()函数的相位和最后一位。
(5.)启用NVIC和相应的中断使用该函数,USART_ITConfig()如果你需要使用中断模式。
(6.)当使用DMA模式使用DMA_Init()函数配置DMA
(++)激活所需的通道请求使用USART_DMACmd()函数
(7.)使用USART_Cmd()函数启用USART。
当使用DMA模式时,使用DMA_Cmd()函数启用DMA。
-@-参考多处理器、LIN、半双工、智能卡、IrDA等章节
在 STM32F4 固件库中对串口 USART 的描述原文如下:
************************************************************************
* @brief This file provides firmware functions to manage the following
* functionalities of the Universal synchronous asynchronous receiver
* transmitter (USART):
* + Initialization and Configuration
* + Data transfers
* + Multi-Processor Communication
* + LIN mode
* + Half-duplex mode
* + Smartcard mode
* + IrDA mode
* + DMA transfers management
* + Interrupts and flags management
*
===================================================================
##### How to use this driver #####
===================================================================
[..]
(#) Enable peripheral clock using the following functions
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USARTx, ENABLE) for USART1 and USART6
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USARTx, ENABLE) for USART2, USART3,
UART4 or UART5.
(#) According to the USART mode, enable the GPIO clocks using
RCC_AHB1PeriphClockCmd() function. (The I/O can be TX, RX, CTS,
or/and SCLK).
(#) Peripheral's alternate function:
(++) Connect the pin to the desired peripherals' Alternate
Function (AF) using GPIO_PinAFConfig() function
(++) Configure the desired pin in alternate function by:
GPIO_InitStruct->GPIO_Mode = GPIO_Mode_AF
(++) Select the type, pull-up/pull-down and output speed via
GPIO_PuPd, GPIO_OType and GPIO_Speed members
(++) Call GPIO_Init() function
(#) Program the Baud Rate, Word Length , Stop Bit, Parity, Hardware
flow control and Mode(Receiver/Transmitter) using the USART_Init()
function.
(#) For synchronous mode, enable the clock and program the polarity,
phase and last bit using the USART_ClockInit() function.
(#) Enable the NVIC and the corresponding interrupt using the function
USART_ITConfig() if you need to use interrupt mode.
(#) When using the DMA mode
(++) Configure the DMA using DMA_Init() function
(++) Active the needed channel Request using USART_DMACmd() function
(#) Enable the USART using the USART_Cmd() function.
(#) Enable the DMA using the DMA_Cmd() function, when using DMA mode.
-@- Refer to Multi-Processor, LIN, half-duplex, Smartcard, IrDA sub-sections
for more details
[..]
In order to reach higher communication baudrates, it is possible to
enable the oversampling by 8 mode using the function USART_OverSampling8Cmd().
This function should be called after enabling the USART clock (RCC_APBxPeriphClockCmd())
and before calling the function USART_Init().
@endverbatim
******************************************************************************
* @attention
*
*
© COPYRIGHT 2014 STMicroelectronics
*
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.st.com/software_license_agreement_liberty_v2
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************
* @brief 此文件提供固件功能来管理以下内容
* @通用同步异步接收器的功能
* +初始化和配置
* +数据传输
* +多处理器通信
* + LIN模式
* +半双工模式
* +智能卡模式
* +IrDA模式
* +DMA传输管理
* +中断和标志管理
===============================================================================
#####如何使用这个驱动#####
===============================================================================
[**]
(1.)使用以下功能启用外围时钟
对于USART1和USART6, rcc_apb2periperi_cmd (rcc_apb2peri_usartx, ENABLE)
rcc_apb1periperi_usartcmd (rcc_apb1peri_usartx, ENABLE) for USART2, USART3,UART4或UART5。
根据USART模式,启用GPIO时钟使用RCC_AHB1PeriphClockCmd()函数。(I/O可以是TX, RX, CTS,或/和SCLK)。
(2.)外围设备的复用功能:
(++)连接引脚所需的外设的备用
使用GPIO_PinAFConfig()函数实现
(++)配置所需的引脚在备用功能:
GPIO_InitStruct - > GPIO_Mode = GPIO_Mode_AF
(++)选择类型,上拉/下拉和输出速度通过 GPIO_PuPd、GPIO_OType和GPIO_Speed 成员调用 GPIO_Init()函数
(3.)编写波特率,字长,停止位,奇偶校验,硬件使用USART_Init()的流量控制和模式(接收/发射)函数。
(4.)同步模式,启用时钟和程序极性,使用usart_clockkinit()函数的相位和最后一位。
(5.)启用NVIC和相应的中断使用该函数,USART_ITConfig()如果你需要使用中断模式。
(6.)当使用DMA模式使用DMA_Init()函数配置DMA
(++)激活所需的通道请求使用USART_DMACmd()函数
(7.)使用USART_Cmd()函数启用USART。
当使用DMA模式时,使用DMA_Cmd()函数启用DMA。
-@-参考多处理器、LIN、半双工、智能卡、IrDA等章节
举报