This file provides firmware functions to manage the following functionalities of the Universal synchronous asynchronous receiver transmitter (USART): More...
Go to the source code of this file.
Macros | |
#define | CR1_CLEAR_MASK |
#define | CR2_CLOCK_CLEAR_MASK |
#define | CR3_CLEAR_MASK ((uint16_t)(USART_CR3_RTSE | USART_CR3_CTSE)) |
#define | IT_MASK ((uint16_t)0x001F) |
Functions | |
void | USART_ClearFlag (USART_TypeDef *USARTx, uint16_t USART_FLAG) |
Clears the USARTx's pending flags. More... | |
void | USART_ClearITPendingBit (USART_TypeDef *USARTx, uint16_t USART_IT) |
Clears the USARTx's interrupt pending bits. More... | |
void | USART_ClockInit (USART_TypeDef *USARTx, USART_ClockInitTypeDef *USART_ClockInitStruct) |
Initializes the USARTx peripheral Clock according to the specified parameters in the USART_ClockInitStruct . More... | |
void | USART_ClockStructInit (USART_ClockInitTypeDef *USART_ClockInitStruct) |
Fills each USART_ClockInitStruct member with its default value. More... | |
void | USART_Cmd (USART_TypeDef *USARTx, FunctionalState NewState) |
Enables or disables the specified USART peripheral. More... | |
void | USART_DeInit (USART_TypeDef *USARTx) |
Deinitializes the USARTx peripheral registers to their default reset values. More... | |
void | USART_DMACmd (USART_TypeDef *USARTx, uint16_t USART_DMAReq, FunctionalState NewState) |
Enables or disables the USART's DMA interface. More... | |
FlagStatus | USART_GetFlagStatus (USART_TypeDef *USARTx, uint16_t USART_FLAG) |
Checks whether the specified USART flag is set or not. More... | |
ITStatus | USART_GetITStatus (USART_TypeDef *USARTx, uint16_t USART_IT) |
Checks whether the specified USART interrupt has occurred or not. More... | |
void | USART_HalfDuplexCmd (USART_TypeDef *USARTx, FunctionalState NewState) |
Enables or disables the USART's Half Duplex communication. More... | |
void | USART_Init (USART_TypeDef *USARTx, USART_InitTypeDef *USART_InitStruct) |
Initializes the USARTx peripheral according to the specified parameters in the USART_InitStruct . More... | |
void | USART_IrDACmd (USART_TypeDef *USARTx, FunctionalState NewState) |
Enables or disables the USART's IrDA interface. More... | |
void | USART_IrDAConfig (USART_TypeDef *USARTx, uint16_t USART_IrDAMode) |
Configures the USART's IrDA interface. More... | |
void | USART_ITConfig (USART_TypeDef *USARTx, uint16_t USART_IT, FunctionalState NewState) |
Enables or disables the specified USART interrupts. More... | |
void | USART_LINBreakDetectLengthConfig (USART_TypeDef *USARTx, uint16_t USART_LINBreakDetectLength) |
Sets the USART LIN Break detection length. More... | |
void | USART_LINCmd (USART_TypeDef *USARTx, FunctionalState NewState) |
Enables or disables the USART's LIN mode. More... | |
void | USART_OneBitMethodCmd (USART_TypeDef *USARTx, FunctionalState NewState) |
Enables or disables the USART's one bit sampling method. More... | |
void | USART_OverSampling8Cmd (USART_TypeDef *USARTx, FunctionalState NewState) |
Enables or disables the USART's 8x oversampling mode. More... | |
uint16_t | USART_ReceiveData (USART_TypeDef *USARTx) |
Returns the most recent received data by the USARTx peripheral. More... | |
void | USART_ReceiverWakeUpCmd (USART_TypeDef *USARTx, FunctionalState NewState) |
Determines if the USART is in mute mode or not. More... | |
void | USART_SendBreak (USART_TypeDef *USARTx) |
Transmits break characters. More... | |
void | USART_SendData (USART_TypeDef *USARTx, uint16_t Data) |
Transmits single data through the USARTx peripheral. More... | |
void | USART_SetAddress (USART_TypeDef *USARTx, uint8_t USART_Address) |
Sets the address of the USART node. More... | |
void | USART_SetGuardTime (USART_TypeDef *USARTx, uint8_t USART_GuardTime) |
Sets the specified USART guard time. More... | |
void | USART_SetPrescaler (USART_TypeDef *USARTx, uint8_t USART_Prescaler) |
Sets the system clock prescaler. More... | |
void | USART_SmartCardCmd (USART_TypeDef *USARTx, FunctionalState NewState) |
Enables or disables the USART's Smart Card mode. More... | |
void | USART_SmartCardNACKCmd (USART_TypeDef *USARTx, FunctionalState NewState) |
Enables or disables NACK transmission. More... | |
void | USART_StructInit (USART_InitTypeDef *USART_InitStruct) |
Fills each USART_InitStruct member with its default value. More... | |
void | USART_WakeUpConfig (USART_TypeDef *USARTx, uint16_t USART_WakeUp) |
Selects the USART WakeUp method. More... | |
This file provides firmware functions to manage the following functionalities of the Universal synchronous asynchronous receiver transmitter (USART):
=============================================================================== ##### 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().
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.
Definition in file stm32f4xx_usart.c.