mbed library sources
Fork of mbed-src by
targets/cmsis/TARGET_STM/TARGET_STM32F3XX/stm32f30x_usart.c@637:ed69428d4850, 2015-12-22 (annotated)
- Committer:
- jaerts
- Date:
- Tue Dec 22 13:22:16 2015 +0000
- Revision:
- 637:ed69428d4850
- Parent:
- 155:8435094ec241
Add very shady LPC1768 CAN Filter implementation
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 155:8435094ec241 | 1 | /** |
mbed_official | 155:8435094ec241 | 2 | ****************************************************************************** |
mbed_official | 155:8435094ec241 | 3 | * @file stm32f30x_usart.c |
mbed_official | 155:8435094ec241 | 4 | * @author MCD Application Team |
mbed_official | 155:8435094ec241 | 5 | * @version V1.1.0 |
mbed_official | 155:8435094ec241 | 6 | * @date 27-February-2014 |
mbed_official | 155:8435094ec241 | 7 | * @brief This file provides firmware functions to manage the following |
mbed_official | 155:8435094ec241 | 8 | * functionalities of the Universal synchronous asynchronous receiver |
mbed_official | 155:8435094ec241 | 9 | * transmitter (USART): |
mbed_official | 155:8435094ec241 | 10 | * + Initialization and Configuration |
mbed_official | 155:8435094ec241 | 11 | * + STOP Mode |
mbed_official | 155:8435094ec241 | 12 | * + AutoBaudRate |
mbed_official | 155:8435094ec241 | 13 | * + Data transfers |
mbed_official | 155:8435094ec241 | 14 | * + Multi-Processor Communication |
mbed_official | 155:8435094ec241 | 15 | * + LIN mode |
mbed_official | 155:8435094ec241 | 16 | * + Half-duplex mode |
mbed_official | 155:8435094ec241 | 17 | * + Smartcard mode |
mbed_official | 155:8435094ec241 | 18 | * + IrDA mode |
mbed_official | 155:8435094ec241 | 19 | * + RS485 mode |
mbed_official | 155:8435094ec241 | 20 | * + DMA transfers management |
mbed_official | 155:8435094ec241 | 21 | * + Interrupts and flags management |
mbed_official | 155:8435094ec241 | 22 | * |
mbed_official | 155:8435094ec241 | 23 | * @verbatim |
mbed_official | 155:8435094ec241 | 24 | =============================================================================== |
mbed_official | 155:8435094ec241 | 25 | ##### How to use this driver ##### |
mbed_official | 155:8435094ec241 | 26 | =============================================================================== |
mbed_official | 155:8435094ec241 | 27 | [..] |
mbed_official | 155:8435094ec241 | 28 | (#) Enable peripheral clock using RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE) |
mbed_official | 155:8435094ec241 | 29 | function for USART1 or using RCC_APB1PeriphClockCmd(RCC_APB1Periph_USARTx, ENABLE) |
mbed_official | 155:8435094ec241 | 30 | function for USART2, USART3, UART4 and UART5. |
mbed_official | 155:8435094ec241 | 31 | (#) According to the USART mode, enable the GPIO clocks using |
mbed_official | 155:8435094ec241 | 32 | RCC_AHBPeriphClockCmd() function. (The I/O can be TX, RX, CTS, |
mbed_official | 155:8435094ec241 | 33 | or and SCLK). |
mbed_official | 155:8435094ec241 | 34 | (#) Peripheral's alternate function: |
mbed_official | 155:8435094ec241 | 35 | (++) Connect the pin to the desired peripherals' Alternate |
mbed_official | 155:8435094ec241 | 36 | Function (AF) using GPIO_PinAFConfig() function. |
mbed_official | 155:8435094ec241 | 37 | (++) Configure the desired pin in alternate function by: |
mbed_official | 155:8435094ec241 | 38 | GPIO_InitStruct->GPIO_Mode = GPIO_Mode_AF. |
mbed_official | 155:8435094ec241 | 39 | (++) Select the type, pull-up/pull-down and output speed via |
mbed_official | 155:8435094ec241 | 40 | GPIO_PuPd, GPIO_OType and GPIO_Speed members. |
mbed_official | 155:8435094ec241 | 41 | (++) Call GPIO_Init() function. |
mbed_official | 155:8435094ec241 | 42 | (#) Program the Baud Rate, Word Length , Stop Bit, Parity, Hardware |
mbed_official | 155:8435094ec241 | 43 | flow control and Mode(Receiver/Transmitter) using the SPI_Init() |
mbed_official | 155:8435094ec241 | 44 | function. |
mbed_official | 155:8435094ec241 | 45 | (#) For synchronous mode, enable the clock and program the polarity, |
mbed_official | 155:8435094ec241 | 46 | phase and last bit using the USART_ClockInit() function. |
mbed_official | 155:8435094ec241 | 47 | (#) Enable the USART using the USART_Cmd() function. |
mbed_official | 155:8435094ec241 | 48 | (#) Enable the NVIC and the corresponding interrupt using the function |
mbed_official | 155:8435094ec241 | 49 | USART_ITConfig() if you need to use interrupt mode. |
mbed_official | 155:8435094ec241 | 50 | (#) When using the DMA mode: |
mbed_official | 155:8435094ec241 | 51 | (++) Configure the DMA using DMA_Init() function. |
mbed_official | 155:8435094ec241 | 52 | (++) Activate the needed channel Request using USART_DMACmd() function. |
mbed_official | 155:8435094ec241 | 53 | (#) Enable the DMA using the DMA_Cmd() function, when using DMA mode. |
mbed_official | 155:8435094ec241 | 54 | [..] |
mbed_official | 155:8435094ec241 | 55 | Refer to Multi-Processor, LIN, half-duplex, Smartcard, IrDA sub-sections |
mbed_official | 155:8435094ec241 | 56 | for more details. |
mbed_official | 155:8435094ec241 | 57 | |
mbed_official | 155:8435094ec241 | 58 | @endverbatim |
mbed_official | 155:8435094ec241 | 59 | |
mbed_official | 155:8435094ec241 | 60 | ****************************************************************************** |
mbed_official | 155:8435094ec241 | 61 | * @attention |
mbed_official | 155:8435094ec241 | 62 | * |
mbed_official | 155:8435094ec241 | 63 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
mbed_official | 155:8435094ec241 | 64 | * |
mbed_official | 155:8435094ec241 | 65 | * Redistribution and use in source and binary forms, with or without modification, |
mbed_official | 155:8435094ec241 | 66 | * are permitted provided that the following conditions are met: |
mbed_official | 155:8435094ec241 | 67 | * 1. Redistributions of source code must retain the above copyright notice, |
mbed_official | 155:8435094ec241 | 68 | * this list of conditions and the following disclaimer. |
mbed_official | 155:8435094ec241 | 69 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
mbed_official | 155:8435094ec241 | 70 | * this list of conditions and the following disclaimer in the documentation |
mbed_official | 155:8435094ec241 | 71 | * and/or other materials provided with the distribution. |
mbed_official | 155:8435094ec241 | 72 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
mbed_official | 155:8435094ec241 | 73 | * may be used to endorse or promote products derived from this software |
mbed_official | 155:8435094ec241 | 74 | * without specific prior written permission. |
mbed_official | 155:8435094ec241 | 75 | * |
mbed_official | 155:8435094ec241 | 76 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mbed_official | 155:8435094ec241 | 77 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mbed_official | 155:8435094ec241 | 78 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
mbed_official | 155:8435094ec241 | 79 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
mbed_official | 155:8435094ec241 | 80 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
mbed_official | 155:8435094ec241 | 81 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
mbed_official | 155:8435094ec241 | 82 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
mbed_official | 155:8435094ec241 | 83 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
mbed_official | 155:8435094ec241 | 84 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
mbed_official | 155:8435094ec241 | 85 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 155:8435094ec241 | 86 | * |
mbed_official | 155:8435094ec241 | 87 | ****************************************************************************** |
mbed_official | 155:8435094ec241 | 88 | */ |
mbed_official | 155:8435094ec241 | 89 | |
mbed_official | 155:8435094ec241 | 90 | /* Includes ------------------------------------------------------------------*/ |
mbed_official | 155:8435094ec241 | 91 | #include "stm32f30x_usart.h" |
mbed_official | 155:8435094ec241 | 92 | #include "stm32f30x_rcc.h" |
mbed_official | 155:8435094ec241 | 93 | |
mbed_official | 155:8435094ec241 | 94 | /** @addtogroup STM32F30x_StdPeriph_Driver |
mbed_official | 155:8435094ec241 | 95 | * @{ |
mbed_official | 155:8435094ec241 | 96 | */ |
mbed_official | 155:8435094ec241 | 97 | |
mbed_official | 155:8435094ec241 | 98 | /** @defgroup USART |
mbed_official | 155:8435094ec241 | 99 | * @brief USART driver modules |
mbed_official | 155:8435094ec241 | 100 | * @{ |
mbed_official | 155:8435094ec241 | 101 | */ |
mbed_official | 155:8435094ec241 | 102 | |
mbed_official | 155:8435094ec241 | 103 | /* Private typedef -----------------------------------------------------------*/ |
mbed_official | 155:8435094ec241 | 104 | /* Private define ------------------------------------------------------------*/ |
mbed_official | 155:8435094ec241 | 105 | |
mbed_official | 155:8435094ec241 | 106 | /*!< USART CR1 register clear Mask ((~(uint32_t)0xFFFFE6F3)) */ |
mbed_official | 155:8435094ec241 | 107 | #define CR1_CLEAR_MASK ((uint32_t)(USART_CR1_M | USART_CR1_PCE | \ |
mbed_official | 155:8435094ec241 | 108 | USART_CR1_PS | USART_CR1_TE | \ |
mbed_official | 155:8435094ec241 | 109 | USART_CR1_RE)) |
mbed_official | 155:8435094ec241 | 110 | |
mbed_official | 155:8435094ec241 | 111 | /*!< USART CR2 register clock bits clear Mask ((~(uint32_t)0xFFFFF0FF)) */ |
mbed_official | 155:8435094ec241 | 112 | #define CR2_CLOCK_CLEAR_MASK ((uint32_t)(USART_CR2_CLKEN | USART_CR2_CPOL | \ |
mbed_official | 155:8435094ec241 | 113 | USART_CR2_CPHA | USART_CR2_LBCL)) |
mbed_official | 155:8435094ec241 | 114 | |
mbed_official | 155:8435094ec241 | 115 | /*!< USART CR3 register clear Mask ((~(uint32_t)0xFFFFFCFF)) */ |
mbed_official | 155:8435094ec241 | 116 | #define CR3_CLEAR_MASK ((uint32_t)(USART_CR3_RTSE | USART_CR3_CTSE)) |
mbed_official | 155:8435094ec241 | 117 | |
mbed_official | 155:8435094ec241 | 118 | /*!< USART Interrupts mask */ |
mbed_official | 155:8435094ec241 | 119 | #define IT_MASK ((uint32_t)0x000000FF) |
mbed_official | 155:8435094ec241 | 120 | |
mbed_official | 155:8435094ec241 | 121 | /* Private macro -------------------------------------------------------------*/ |
mbed_official | 155:8435094ec241 | 122 | /* Private variables ---------------------------------------------------------*/ |
mbed_official | 155:8435094ec241 | 123 | /* Private function prototypes -----------------------------------------------*/ |
mbed_official | 155:8435094ec241 | 124 | /* Private functions ---------------------------------------------------------*/ |
mbed_official | 155:8435094ec241 | 125 | |
mbed_official | 155:8435094ec241 | 126 | /** @defgroup USART_Private_Functions |
mbed_official | 155:8435094ec241 | 127 | * @{ |
mbed_official | 155:8435094ec241 | 128 | */ |
mbed_official | 155:8435094ec241 | 129 | |
mbed_official | 155:8435094ec241 | 130 | /** @defgroup USART_Group1 Initialization and Configuration functions |
mbed_official | 155:8435094ec241 | 131 | * @brief Initialization and Configuration functions |
mbed_official | 155:8435094ec241 | 132 | * |
mbed_official | 155:8435094ec241 | 133 | @verbatim |
mbed_official | 155:8435094ec241 | 134 | =============================================================================== |
mbed_official | 155:8435094ec241 | 135 | ##### Initialization and Configuration functions ##### |
mbed_official | 155:8435094ec241 | 136 | =============================================================================== |
mbed_official | 155:8435094ec241 | 137 | [..] |
mbed_official | 155:8435094ec241 | 138 | This subsection provides a set of functions allowing to initialize the USART |
mbed_official | 155:8435094ec241 | 139 | in asynchronous and in synchronous modes. |
mbed_official | 155:8435094ec241 | 140 | (+) For the asynchronous mode only these parameters can be configured: |
mbed_official | 155:8435094ec241 | 141 | (++) Baud Rate. |
mbed_official | 155:8435094ec241 | 142 | (++) Word Length. |
mbed_official | 155:8435094ec241 | 143 | (++) Stop Bit. |
mbed_official | 155:8435094ec241 | 144 | (++) Parity: If the parity is enabled, then the MSB bit of the data written |
mbed_official | 155:8435094ec241 | 145 | in the data register is transmitted but is changed by the parity bit. |
mbed_official | 155:8435094ec241 | 146 | Depending on the frame length defined by the M bit (8-bits or 9-bits), |
mbed_official | 155:8435094ec241 | 147 | the possible USART frame formats are as listed in the following table: |
mbed_official | 155:8435094ec241 | 148 | [..] |
mbed_official | 155:8435094ec241 | 149 | +-------------------------------------------------------------+ |
mbed_official | 155:8435094ec241 | 150 | | M bit | PCE bit | USART frame | |
mbed_official | 155:8435094ec241 | 151 | |---------------------|---------------------------------------| |
mbed_official | 155:8435094ec241 | 152 | | 0 | 0 | | SB | 8 bit data | STB | | |
mbed_official | 155:8435094ec241 | 153 | |---------|-----------|---------------------------------------| |
mbed_official | 155:8435094ec241 | 154 | | 0 | 1 | | SB | 7 bit data | PB | STB | | |
mbed_official | 155:8435094ec241 | 155 | |---------|-----------|---------------------------------------| |
mbed_official | 155:8435094ec241 | 156 | | 1 | 0 | | SB | 9 bit data | STB | | |
mbed_official | 155:8435094ec241 | 157 | |---------|-----------|---------------------------------------| |
mbed_official | 155:8435094ec241 | 158 | | 1 | 1 | | SB | 8 bit data | PB | STB | | |
mbed_official | 155:8435094ec241 | 159 | +-------------------------------------------------------------+ |
mbed_official | 155:8435094ec241 | 160 | [..] |
mbed_official | 155:8435094ec241 | 161 | (++) Hardware flow control. |
mbed_official | 155:8435094ec241 | 162 | (++) Receiver/transmitter modes. |
mbed_official | 155:8435094ec241 | 163 | [..] The USART_Init() function follows the USART asynchronous configuration |
mbed_official | 155:8435094ec241 | 164 | procedure(details for the procedure are available in reference manual. |
mbed_official | 155:8435094ec241 | 165 | (+) For the synchronous mode in addition to the asynchronous mode parameters |
mbed_official | 155:8435094ec241 | 166 | these parameters should be also configured: |
mbed_official | 155:8435094ec241 | 167 | (++) USART Clock Enabled. |
mbed_official | 155:8435094ec241 | 168 | (++) USART polarity. |
mbed_official | 155:8435094ec241 | 169 | (++) USART phase. |
mbed_official | 155:8435094ec241 | 170 | (++) USART LastBit. |
mbed_official | 155:8435094ec241 | 171 | [..] These parameters can be configured using the USART_ClockInit() function. |
mbed_official | 155:8435094ec241 | 172 | |
mbed_official | 155:8435094ec241 | 173 | @endverbatim |
mbed_official | 155:8435094ec241 | 174 | * @{ |
mbed_official | 155:8435094ec241 | 175 | */ |
mbed_official | 155:8435094ec241 | 176 | |
mbed_official | 155:8435094ec241 | 177 | /** |
mbed_official | 155:8435094ec241 | 178 | * @brief Deinitializes the USARTx peripheral registers to their default reset values. |
mbed_official | 155:8435094ec241 | 179 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 180 | * following values: USART1 or USART2 or USART3 or UART4 or UART5. |
mbed_official | 155:8435094ec241 | 181 | * @retval None |
mbed_official | 155:8435094ec241 | 182 | */ |
mbed_official | 155:8435094ec241 | 183 | void USART_DeInit(USART_TypeDef* USARTx) |
mbed_official | 155:8435094ec241 | 184 | { |
mbed_official | 155:8435094ec241 | 185 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 186 | assert_param(IS_USART_ALL_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 187 | |
mbed_official | 155:8435094ec241 | 188 | if (USARTx == USART1) |
mbed_official | 155:8435094ec241 | 189 | { |
mbed_official | 155:8435094ec241 | 190 | RCC_APB2PeriphResetCmd(RCC_APB2Periph_USART1, ENABLE); |
mbed_official | 155:8435094ec241 | 191 | RCC_APB2PeriphResetCmd(RCC_APB2Periph_USART1, DISABLE); |
mbed_official | 155:8435094ec241 | 192 | } |
mbed_official | 155:8435094ec241 | 193 | else if (USARTx == USART2) |
mbed_official | 155:8435094ec241 | 194 | { |
mbed_official | 155:8435094ec241 | 195 | RCC_APB1PeriphResetCmd(RCC_APB1Periph_USART2, ENABLE); |
mbed_official | 155:8435094ec241 | 196 | RCC_APB1PeriphResetCmd(RCC_APB1Periph_USART2, DISABLE); |
mbed_official | 155:8435094ec241 | 197 | } |
mbed_official | 155:8435094ec241 | 198 | else if (USARTx == USART3) |
mbed_official | 155:8435094ec241 | 199 | { |
mbed_official | 155:8435094ec241 | 200 | RCC_APB1PeriphResetCmd(RCC_APB1Periph_USART3, ENABLE); |
mbed_official | 155:8435094ec241 | 201 | RCC_APB1PeriphResetCmd(RCC_APB1Periph_USART3, DISABLE); |
mbed_official | 155:8435094ec241 | 202 | } |
mbed_official | 155:8435094ec241 | 203 | else if (USARTx == UART4) |
mbed_official | 155:8435094ec241 | 204 | { |
mbed_official | 155:8435094ec241 | 205 | RCC_APB1PeriphResetCmd(RCC_APB1Periph_UART4, ENABLE); |
mbed_official | 155:8435094ec241 | 206 | RCC_APB1PeriphResetCmd(RCC_APB1Periph_UART4, DISABLE); |
mbed_official | 155:8435094ec241 | 207 | } |
mbed_official | 155:8435094ec241 | 208 | else |
mbed_official | 155:8435094ec241 | 209 | { |
mbed_official | 155:8435094ec241 | 210 | if (USARTx == UART5) |
mbed_official | 155:8435094ec241 | 211 | { |
mbed_official | 155:8435094ec241 | 212 | RCC_APB1PeriphResetCmd(RCC_APB1Periph_UART5, ENABLE); |
mbed_official | 155:8435094ec241 | 213 | RCC_APB1PeriphResetCmd(RCC_APB1Periph_UART5, DISABLE); |
mbed_official | 155:8435094ec241 | 214 | } |
mbed_official | 155:8435094ec241 | 215 | } |
mbed_official | 155:8435094ec241 | 216 | } |
mbed_official | 155:8435094ec241 | 217 | |
mbed_official | 155:8435094ec241 | 218 | /** |
mbed_official | 155:8435094ec241 | 219 | * @brief Initializes the USARTx peripheral according to the specified |
mbed_official | 155:8435094ec241 | 220 | * parameters in the USART_InitStruct . |
mbed_official | 155:8435094ec241 | 221 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 222 | * following values: USART1 or USART2 or USART3 or UART4 or UART5. |
mbed_official | 155:8435094ec241 | 223 | * @param USART_InitStruct: pointer to a USART_InitTypeDef structure |
mbed_official | 155:8435094ec241 | 224 | * that contains the configuration information for the specified USART peripheral. |
mbed_official | 155:8435094ec241 | 225 | * @retval None |
mbed_official | 155:8435094ec241 | 226 | */ |
mbed_official | 155:8435094ec241 | 227 | void USART_Init(USART_TypeDef* USARTx, USART_InitTypeDef* USART_InitStruct) |
mbed_official | 155:8435094ec241 | 228 | { |
mbed_official | 155:8435094ec241 | 229 | uint32_t divider = 0, apbclock = 0, tmpreg = 0; |
mbed_official | 155:8435094ec241 | 230 | RCC_ClocksTypeDef RCC_ClocksStatus; |
mbed_official | 155:8435094ec241 | 231 | |
mbed_official | 155:8435094ec241 | 232 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 233 | assert_param(IS_USART_ALL_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 234 | assert_param(IS_USART_BAUDRATE(USART_InitStruct->USART_BaudRate)); |
mbed_official | 155:8435094ec241 | 235 | assert_param(IS_USART_WORD_LENGTH(USART_InitStruct->USART_WordLength)); |
mbed_official | 155:8435094ec241 | 236 | assert_param(IS_USART_STOPBITS(USART_InitStruct->USART_StopBits)); |
mbed_official | 155:8435094ec241 | 237 | assert_param(IS_USART_PARITY(USART_InitStruct->USART_Parity)); |
mbed_official | 155:8435094ec241 | 238 | assert_param(IS_USART_MODE(USART_InitStruct->USART_Mode)); |
mbed_official | 155:8435094ec241 | 239 | assert_param(IS_USART_HARDWARE_FLOW_CONTROL(USART_InitStruct->USART_HardwareFlowControl)); |
mbed_official | 155:8435094ec241 | 240 | |
mbed_official | 155:8435094ec241 | 241 | /* Disable USART */ |
mbed_official | 155:8435094ec241 | 242 | USARTx->CR1 &= (uint32_t)~((uint32_t)USART_CR1_UE); |
mbed_official | 155:8435094ec241 | 243 | |
mbed_official | 155:8435094ec241 | 244 | /*---------------------------- USART CR2 Configuration -----------------------*/ |
mbed_official | 155:8435094ec241 | 245 | tmpreg = USARTx->CR2; |
mbed_official | 155:8435094ec241 | 246 | /* Clear STOP[13:12] bits */ |
mbed_official | 155:8435094ec241 | 247 | tmpreg &= (uint32_t)~((uint32_t)USART_CR2_STOP); |
mbed_official | 155:8435094ec241 | 248 | |
mbed_official | 155:8435094ec241 | 249 | /* Configure the USART Stop Bits, Clock, CPOL, CPHA and LastBit ------------*/ |
mbed_official | 155:8435094ec241 | 250 | /* Set STOP[13:12] bits according to USART_StopBits value */ |
mbed_official | 155:8435094ec241 | 251 | tmpreg |= (uint32_t)USART_InitStruct->USART_StopBits; |
mbed_official | 155:8435094ec241 | 252 | |
mbed_official | 155:8435094ec241 | 253 | /* Write to USART CR2 */ |
mbed_official | 155:8435094ec241 | 254 | USARTx->CR2 = tmpreg; |
mbed_official | 155:8435094ec241 | 255 | |
mbed_official | 155:8435094ec241 | 256 | /*---------------------------- USART CR1 Configuration -----------------------*/ |
mbed_official | 155:8435094ec241 | 257 | tmpreg = USARTx->CR1; |
mbed_official | 155:8435094ec241 | 258 | /* Clear M, PCE, PS, TE and RE bits */ |
mbed_official | 155:8435094ec241 | 259 | tmpreg &= (uint32_t)~((uint32_t)CR1_CLEAR_MASK); |
mbed_official | 155:8435094ec241 | 260 | |
mbed_official | 155:8435094ec241 | 261 | /* Configure the USART Word Length, Parity and mode ----------------------- */ |
mbed_official | 155:8435094ec241 | 262 | /* Set the M bits according to USART_WordLength value */ |
mbed_official | 155:8435094ec241 | 263 | /* Set PCE and PS bits according to USART_Parity value */ |
mbed_official | 155:8435094ec241 | 264 | /* Set TE and RE bits according to USART_Mode value */ |
mbed_official | 155:8435094ec241 | 265 | tmpreg |= (uint32_t)USART_InitStruct->USART_WordLength | USART_InitStruct->USART_Parity | |
mbed_official | 155:8435094ec241 | 266 | USART_InitStruct->USART_Mode; |
mbed_official | 155:8435094ec241 | 267 | |
mbed_official | 155:8435094ec241 | 268 | /* Write to USART CR1 */ |
mbed_official | 155:8435094ec241 | 269 | USARTx->CR1 = tmpreg; |
mbed_official | 155:8435094ec241 | 270 | |
mbed_official | 155:8435094ec241 | 271 | /*---------------------------- USART CR3 Configuration -----------------------*/ |
mbed_official | 155:8435094ec241 | 272 | tmpreg = USARTx->CR3; |
mbed_official | 155:8435094ec241 | 273 | /* Clear CTSE and RTSE bits */ |
mbed_official | 155:8435094ec241 | 274 | tmpreg &= (uint32_t)~((uint32_t)CR3_CLEAR_MASK); |
mbed_official | 155:8435094ec241 | 275 | |
mbed_official | 155:8435094ec241 | 276 | /* Configure the USART HFC -------------------------------------------------*/ |
mbed_official | 155:8435094ec241 | 277 | /* Set CTSE and RTSE bits according to USART_HardwareFlowControl value */ |
mbed_official | 155:8435094ec241 | 278 | tmpreg |= USART_InitStruct->USART_HardwareFlowControl; |
mbed_official | 155:8435094ec241 | 279 | |
mbed_official | 155:8435094ec241 | 280 | /* Write to USART CR3 */ |
mbed_official | 155:8435094ec241 | 281 | USARTx->CR3 = tmpreg; |
mbed_official | 155:8435094ec241 | 282 | |
mbed_official | 155:8435094ec241 | 283 | /*---------------------------- USART BRR Configuration -----------------------*/ |
mbed_official | 155:8435094ec241 | 284 | /* Configure the USART Baud Rate -------------------------------------------*/ |
mbed_official | 155:8435094ec241 | 285 | RCC_GetClocksFreq(&RCC_ClocksStatus); |
mbed_official | 155:8435094ec241 | 286 | |
mbed_official | 155:8435094ec241 | 287 | if (USARTx == USART1) |
mbed_official | 155:8435094ec241 | 288 | { |
mbed_official | 155:8435094ec241 | 289 | apbclock = RCC_ClocksStatus.USART1CLK_Frequency; |
mbed_official | 155:8435094ec241 | 290 | } |
mbed_official | 155:8435094ec241 | 291 | else if (USARTx == USART2) |
mbed_official | 155:8435094ec241 | 292 | { |
mbed_official | 155:8435094ec241 | 293 | apbclock = RCC_ClocksStatus.USART2CLK_Frequency; |
mbed_official | 155:8435094ec241 | 294 | } |
mbed_official | 155:8435094ec241 | 295 | else if (USARTx == USART3) |
mbed_official | 155:8435094ec241 | 296 | { |
mbed_official | 155:8435094ec241 | 297 | apbclock = RCC_ClocksStatus.USART3CLK_Frequency; |
mbed_official | 155:8435094ec241 | 298 | } |
mbed_official | 155:8435094ec241 | 299 | else if (USARTx == UART4) |
mbed_official | 155:8435094ec241 | 300 | { |
mbed_official | 155:8435094ec241 | 301 | apbclock = RCC_ClocksStatus.UART4CLK_Frequency; |
mbed_official | 155:8435094ec241 | 302 | } |
mbed_official | 155:8435094ec241 | 303 | else |
mbed_official | 155:8435094ec241 | 304 | { |
mbed_official | 155:8435094ec241 | 305 | apbclock = RCC_ClocksStatus.UART5CLK_Frequency; |
mbed_official | 155:8435094ec241 | 306 | } |
mbed_official | 155:8435094ec241 | 307 | |
mbed_official | 155:8435094ec241 | 308 | /* Determine the integer part */ |
mbed_official | 155:8435094ec241 | 309 | if ((USARTx->CR1 & USART_CR1_OVER8) != 0) |
mbed_official | 155:8435094ec241 | 310 | { |
mbed_official | 155:8435094ec241 | 311 | /* (divider * 10) computing in case Oversampling mode is 8 Samples */ |
mbed_official | 155:8435094ec241 | 312 | divider = (uint32_t)((2 * apbclock) / (USART_InitStruct->USART_BaudRate)); |
mbed_official | 155:8435094ec241 | 313 | tmpreg = (uint32_t)((2 * apbclock) % (USART_InitStruct->USART_BaudRate)); |
mbed_official | 155:8435094ec241 | 314 | } |
mbed_official | 155:8435094ec241 | 315 | else /* if ((USARTx->CR1 & CR1_OVER8_Set) == 0) */ |
mbed_official | 155:8435094ec241 | 316 | { |
mbed_official | 155:8435094ec241 | 317 | /* (divider * 10) computing in case Oversampling mode is 16 Samples */ |
mbed_official | 155:8435094ec241 | 318 | divider = (uint32_t)((apbclock) / (USART_InitStruct->USART_BaudRate)); |
mbed_official | 155:8435094ec241 | 319 | tmpreg = (uint32_t)((apbclock) % (USART_InitStruct->USART_BaudRate)); |
mbed_official | 155:8435094ec241 | 320 | } |
mbed_official | 155:8435094ec241 | 321 | |
mbed_official | 155:8435094ec241 | 322 | /* round the divider : if fractional part i greater than 0.5 increment divider */ |
mbed_official | 155:8435094ec241 | 323 | if (tmpreg >= (USART_InitStruct->USART_BaudRate) / 2) |
mbed_official | 155:8435094ec241 | 324 | { |
mbed_official | 155:8435094ec241 | 325 | divider++; |
mbed_official | 155:8435094ec241 | 326 | } |
mbed_official | 155:8435094ec241 | 327 | |
mbed_official | 155:8435094ec241 | 328 | /* Implement the divider in case Oversampling mode is 8 Samples */ |
mbed_official | 155:8435094ec241 | 329 | if ((USARTx->CR1 & USART_CR1_OVER8) != 0) |
mbed_official | 155:8435094ec241 | 330 | { |
mbed_official | 155:8435094ec241 | 331 | /* get the LSB of divider and shift it to the right by 1 bit */ |
mbed_official | 155:8435094ec241 | 332 | tmpreg = (divider & (uint16_t)0x000F) >> 1; |
mbed_official | 155:8435094ec241 | 333 | |
mbed_official | 155:8435094ec241 | 334 | /* update the divider value */ |
mbed_official | 155:8435094ec241 | 335 | divider = (divider & (uint16_t)0xFFF0) | tmpreg; |
mbed_official | 155:8435094ec241 | 336 | } |
mbed_official | 155:8435094ec241 | 337 | |
mbed_official | 155:8435094ec241 | 338 | /* Write to USART BRR */ |
mbed_official | 155:8435094ec241 | 339 | USARTx->BRR = (uint16_t)divider; |
mbed_official | 155:8435094ec241 | 340 | } |
mbed_official | 155:8435094ec241 | 341 | |
mbed_official | 155:8435094ec241 | 342 | /** |
mbed_official | 155:8435094ec241 | 343 | * @brief Fills each USART_InitStruct member with its default value. |
mbed_official | 155:8435094ec241 | 344 | * @param USART_InitStruct: pointer to a USART_InitTypeDef structure |
mbed_official | 155:8435094ec241 | 345 | * which will be initialized. |
mbed_official | 155:8435094ec241 | 346 | * @retval None |
mbed_official | 155:8435094ec241 | 347 | */ |
mbed_official | 155:8435094ec241 | 348 | void USART_StructInit(USART_InitTypeDef* USART_InitStruct) |
mbed_official | 155:8435094ec241 | 349 | { |
mbed_official | 155:8435094ec241 | 350 | /* USART_InitStruct members default value */ |
mbed_official | 155:8435094ec241 | 351 | USART_InitStruct->USART_BaudRate = 9600; |
mbed_official | 155:8435094ec241 | 352 | USART_InitStruct->USART_WordLength = USART_WordLength_8b; |
mbed_official | 155:8435094ec241 | 353 | USART_InitStruct->USART_StopBits = USART_StopBits_1; |
mbed_official | 155:8435094ec241 | 354 | USART_InitStruct->USART_Parity = USART_Parity_No ; |
mbed_official | 155:8435094ec241 | 355 | USART_InitStruct->USART_Mode = USART_Mode_Rx | USART_Mode_Tx; |
mbed_official | 155:8435094ec241 | 356 | USART_InitStruct->USART_HardwareFlowControl = USART_HardwareFlowControl_None; |
mbed_official | 155:8435094ec241 | 357 | } |
mbed_official | 155:8435094ec241 | 358 | |
mbed_official | 155:8435094ec241 | 359 | /** |
mbed_official | 155:8435094ec241 | 360 | * @brief Initializes the USARTx peripheral Clock according to the |
mbed_official | 155:8435094ec241 | 361 | * specified parameters in the USART_ClockInitStruct. |
mbed_official | 155:8435094ec241 | 362 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 363 | * following values: USART1 or USART2 or USART3. |
mbed_official | 155:8435094ec241 | 364 | * @param USART_ClockInitStruct: pointer to a USART_ClockInitTypeDef |
mbed_official | 155:8435094ec241 | 365 | * structure that contains the configuration information for the specified |
mbed_official | 155:8435094ec241 | 366 | * USART peripheral. |
mbed_official | 155:8435094ec241 | 367 | * @retval None |
mbed_official | 155:8435094ec241 | 368 | */ |
mbed_official | 155:8435094ec241 | 369 | void USART_ClockInit(USART_TypeDef* USARTx, USART_ClockInitTypeDef* USART_ClockInitStruct) |
mbed_official | 155:8435094ec241 | 370 | { |
mbed_official | 155:8435094ec241 | 371 | uint32_t tmpreg = 0; |
mbed_official | 155:8435094ec241 | 372 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 373 | assert_param(IS_USART_123_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 374 | assert_param(IS_USART_CLOCK(USART_ClockInitStruct->USART_Clock)); |
mbed_official | 155:8435094ec241 | 375 | assert_param(IS_USART_CPOL(USART_ClockInitStruct->USART_CPOL)); |
mbed_official | 155:8435094ec241 | 376 | assert_param(IS_USART_CPHA(USART_ClockInitStruct->USART_CPHA)); |
mbed_official | 155:8435094ec241 | 377 | assert_param(IS_USART_LASTBIT(USART_ClockInitStruct->USART_LastBit)); |
mbed_official | 155:8435094ec241 | 378 | /*---------------------------- USART CR2 Configuration -----------------------*/ |
mbed_official | 155:8435094ec241 | 379 | tmpreg = USARTx->CR2; |
mbed_official | 155:8435094ec241 | 380 | /* Clear CLKEN, CPOL, CPHA, LBCL and SSM bits */ |
mbed_official | 155:8435094ec241 | 381 | tmpreg &= (uint32_t)~((uint32_t)CR2_CLOCK_CLEAR_MASK); |
mbed_official | 155:8435094ec241 | 382 | /* Configure the USART Clock, CPOL, CPHA, LastBit and SSM ------------*/ |
mbed_official | 155:8435094ec241 | 383 | /* Set CLKEN bit according to USART_Clock value */ |
mbed_official | 155:8435094ec241 | 384 | /* Set CPOL bit according to USART_CPOL value */ |
mbed_official | 155:8435094ec241 | 385 | /* Set CPHA bit according to USART_CPHA value */ |
mbed_official | 155:8435094ec241 | 386 | /* Set LBCL bit according to USART_LastBit value */ |
mbed_official | 155:8435094ec241 | 387 | tmpreg |= (uint32_t)(USART_ClockInitStruct->USART_Clock | USART_ClockInitStruct->USART_CPOL | |
mbed_official | 155:8435094ec241 | 388 | USART_ClockInitStruct->USART_CPHA | USART_ClockInitStruct->USART_LastBit); |
mbed_official | 155:8435094ec241 | 389 | /* Write to USART CR2 */ |
mbed_official | 155:8435094ec241 | 390 | USARTx->CR2 = tmpreg; |
mbed_official | 155:8435094ec241 | 391 | } |
mbed_official | 155:8435094ec241 | 392 | |
mbed_official | 155:8435094ec241 | 393 | /** |
mbed_official | 155:8435094ec241 | 394 | * @brief Fills each USART_ClockInitStruct member with its default value. |
mbed_official | 155:8435094ec241 | 395 | * @param USART_ClockInitStruct: pointer to a USART_ClockInitTypeDef |
mbed_official | 155:8435094ec241 | 396 | * structure which will be initialized. |
mbed_official | 155:8435094ec241 | 397 | * @retval None |
mbed_official | 155:8435094ec241 | 398 | */ |
mbed_official | 155:8435094ec241 | 399 | void USART_ClockStructInit(USART_ClockInitTypeDef* USART_ClockInitStruct) |
mbed_official | 155:8435094ec241 | 400 | { |
mbed_official | 155:8435094ec241 | 401 | /* USART_ClockInitStruct members default value */ |
mbed_official | 155:8435094ec241 | 402 | USART_ClockInitStruct->USART_Clock = USART_Clock_Disable; |
mbed_official | 155:8435094ec241 | 403 | USART_ClockInitStruct->USART_CPOL = USART_CPOL_Low; |
mbed_official | 155:8435094ec241 | 404 | USART_ClockInitStruct->USART_CPHA = USART_CPHA_1Edge; |
mbed_official | 155:8435094ec241 | 405 | USART_ClockInitStruct->USART_LastBit = USART_LastBit_Disable; |
mbed_official | 155:8435094ec241 | 406 | } |
mbed_official | 155:8435094ec241 | 407 | |
mbed_official | 155:8435094ec241 | 408 | /** |
mbed_official | 155:8435094ec241 | 409 | * @brief Enables or disables the specified USART peripheral. |
mbed_official | 155:8435094ec241 | 410 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 411 | * following values: USART1 or USART2 or USART3 or UART4 or UART5. |
mbed_official | 155:8435094ec241 | 412 | * @param NewState: new state of the USARTx peripheral. |
mbed_official | 155:8435094ec241 | 413 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 414 | * @retval None |
mbed_official | 155:8435094ec241 | 415 | */ |
mbed_official | 155:8435094ec241 | 416 | void USART_Cmd(USART_TypeDef* USARTx, FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 417 | { |
mbed_official | 155:8435094ec241 | 418 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 419 | assert_param(IS_USART_ALL_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 420 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 421 | |
mbed_official | 155:8435094ec241 | 422 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 423 | { |
mbed_official | 155:8435094ec241 | 424 | /* Enable the selected USART by setting the UE bit in the CR1 register */ |
mbed_official | 155:8435094ec241 | 425 | USARTx->CR1 |= USART_CR1_UE; |
mbed_official | 155:8435094ec241 | 426 | } |
mbed_official | 155:8435094ec241 | 427 | else |
mbed_official | 155:8435094ec241 | 428 | { |
mbed_official | 155:8435094ec241 | 429 | /* Disable the selected USART by clearing the UE bit in the CR1 register */ |
mbed_official | 155:8435094ec241 | 430 | USARTx->CR1 &= (uint32_t)~((uint32_t)USART_CR1_UE); |
mbed_official | 155:8435094ec241 | 431 | } |
mbed_official | 155:8435094ec241 | 432 | } |
mbed_official | 155:8435094ec241 | 433 | |
mbed_official | 155:8435094ec241 | 434 | /** |
mbed_official | 155:8435094ec241 | 435 | * @brief Enables or disables the USART's transmitter or receiver. |
mbed_official | 155:8435094ec241 | 436 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 437 | * following values: USART1 or USART2 or USART3 or UART4 or UART5. |
mbed_official | 155:8435094ec241 | 438 | * @param USART_Direction: specifies the USART direction. |
mbed_official | 155:8435094ec241 | 439 | * This parameter can be any combination of the following values: |
mbed_official | 155:8435094ec241 | 440 | * @arg USART_Mode_Tx: USART Transmitter |
mbed_official | 155:8435094ec241 | 441 | * @arg USART_Mode_Rx: USART Receiver |
mbed_official | 155:8435094ec241 | 442 | * @param NewState: new state of the USART transfer direction. |
mbed_official | 155:8435094ec241 | 443 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 444 | * @retval None |
mbed_official | 155:8435094ec241 | 445 | */ |
mbed_official | 155:8435094ec241 | 446 | void USART_DirectionModeCmd(USART_TypeDef* USARTx, uint32_t USART_DirectionMode, FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 447 | { |
mbed_official | 155:8435094ec241 | 448 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 449 | assert_param(IS_USART_ALL_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 450 | assert_param(IS_USART_MODE(USART_DirectionMode)); |
mbed_official | 155:8435094ec241 | 451 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 452 | |
mbed_official | 155:8435094ec241 | 453 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 454 | { |
mbed_official | 155:8435094ec241 | 455 | /* Enable the USART's transfer interface by setting the TE and/or RE bits |
mbed_official | 155:8435094ec241 | 456 | in the USART CR1 register */ |
mbed_official | 155:8435094ec241 | 457 | USARTx->CR1 |= USART_DirectionMode; |
mbed_official | 155:8435094ec241 | 458 | } |
mbed_official | 155:8435094ec241 | 459 | else |
mbed_official | 155:8435094ec241 | 460 | { |
mbed_official | 155:8435094ec241 | 461 | /* Disable the USART's transfer interface by clearing the TE and/or RE bits |
mbed_official | 155:8435094ec241 | 462 | in the USART CR3 register */ |
mbed_official | 155:8435094ec241 | 463 | USARTx->CR1 &= (uint32_t)~USART_DirectionMode; |
mbed_official | 155:8435094ec241 | 464 | } |
mbed_official | 155:8435094ec241 | 465 | } |
mbed_official | 155:8435094ec241 | 466 | |
mbed_official | 155:8435094ec241 | 467 | /** |
mbed_official | 155:8435094ec241 | 468 | * @brief Enables or disables the USART's 8x oversampling mode. |
mbed_official | 155:8435094ec241 | 469 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 470 | * following values: USART1 or USART2 or USART3 or UART4 or UART5. |
mbed_official | 155:8435094ec241 | 471 | * @param NewState: new state of the USART 8x oversampling mode. |
mbed_official | 155:8435094ec241 | 472 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 473 | * @note |
mbed_official | 155:8435094ec241 | 474 | * This function has to be called before calling USART_Init() |
mbed_official | 155:8435094ec241 | 475 | * function in order to have correct baudrate Divider value. |
mbed_official | 155:8435094ec241 | 476 | * @retval None |
mbed_official | 155:8435094ec241 | 477 | */ |
mbed_official | 155:8435094ec241 | 478 | void USART_OverSampling8Cmd(USART_TypeDef* USARTx, FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 479 | { |
mbed_official | 155:8435094ec241 | 480 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 481 | assert_param(IS_USART_ALL_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 482 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 483 | |
mbed_official | 155:8435094ec241 | 484 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 485 | { |
mbed_official | 155:8435094ec241 | 486 | /* Enable the 8x Oversampling mode by setting the OVER8 bit in the CR1 register */ |
mbed_official | 155:8435094ec241 | 487 | USARTx->CR1 |= USART_CR1_OVER8; |
mbed_official | 155:8435094ec241 | 488 | } |
mbed_official | 155:8435094ec241 | 489 | else |
mbed_official | 155:8435094ec241 | 490 | { |
mbed_official | 155:8435094ec241 | 491 | /* Disable the 8x Oversampling mode by clearing the OVER8 bit in the CR1 register */ |
mbed_official | 155:8435094ec241 | 492 | USARTx->CR1 &= (uint32_t)~((uint32_t)USART_CR1_OVER8); |
mbed_official | 155:8435094ec241 | 493 | } |
mbed_official | 155:8435094ec241 | 494 | } |
mbed_official | 155:8435094ec241 | 495 | |
mbed_official | 155:8435094ec241 | 496 | /** |
mbed_official | 155:8435094ec241 | 497 | * @brief Enables or disables the USART's one bit sampling method. |
mbed_official | 155:8435094ec241 | 498 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 499 | * following values: USART1 or USART2 or USART3 or UART4 or UART5. |
mbed_official | 155:8435094ec241 | 500 | * @param NewState: new state of the USART one bit sampling method. |
mbed_official | 155:8435094ec241 | 501 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 502 | * @note |
mbed_official | 155:8435094ec241 | 503 | * This function has to be called before calling USART_Cmd() function. |
mbed_official | 155:8435094ec241 | 504 | * @retval None |
mbed_official | 155:8435094ec241 | 505 | */ |
mbed_official | 155:8435094ec241 | 506 | void USART_OneBitMethodCmd(USART_TypeDef* USARTx, FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 507 | { |
mbed_official | 155:8435094ec241 | 508 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 509 | assert_param(IS_USART_ALL_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 510 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 511 | |
mbed_official | 155:8435094ec241 | 512 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 513 | { |
mbed_official | 155:8435094ec241 | 514 | /* Enable the one bit method by setting the ONEBIT bit in the CR3 register */ |
mbed_official | 155:8435094ec241 | 515 | USARTx->CR3 |= USART_CR3_ONEBIT; |
mbed_official | 155:8435094ec241 | 516 | } |
mbed_official | 155:8435094ec241 | 517 | else |
mbed_official | 155:8435094ec241 | 518 | { |
mbed_official | 155:8435094ec241 | 519 | /* Disable the one bit method by clearing the ONEBIT bit in the CR3 register */ |
mbed_official | 155:8435094ec241 | 520 | USARTx->CR3 &= (uint32_t)~((uint32_t)USART_CR3_ONEBIT); |
mbed_official | 155:8435094ec241 | 521 | } |
mbed_official | 155:8435094ec241 | 522 | } |
mbed_official | 155:8435094ec241 | 523 | |
mbed_official | 155:8435094ec241 | 524 | /** |
mbed_official | 155:8435094ec241 | 525 | * @brief Enables or disables the USART's most significant bit first |
mbed_official | 155:8435094ec241 | 526 | * transmitted/received following the start bit. |
mbed_official | 155:8435094ec241 | 527 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 528 | * following values: USART1 or USART2 or USART3 or UART4 or UART5. |
mbed_official | 155:8435094ec241 | 529 | * @param NewState: new state of the USART most significant bit first |
mbed_official | 155:8435094ec241 | 530 | * transmitted/received following the start bit. |
mbed_official | 155:8435094ec241 | 531 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 532 | * @note |
mbed_official | 155:8435094ec241 | 533 | * This function has to be called before calling USART_Cmd() function. |
mbed_official | 155:8435094ec241 | 534 | * @retval None |
mbed_official | 155:8435094ec241 | 535 | */ |
mbed_official | 155:8435094ec241 | 536 | void USART_MSBFirstCmd(USART_TypeDef* USARTx, FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 537 | { |
mbed_official | 155:8435094ec241 | 538 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 539 | assert_param(IS_USART_ALL_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 540 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 541 | |
mbed_official | 155:8435094ec241 | 542 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 543 | { |
mbed_official | 155:8435094ec241 | 544 | /* Enable the most significant bit first transmitted/received following the |
mbed_official | 155:8435094ec241 | 545 | start bit by setting the MSBFIRST bit in the CR2 register */ |
mbed_official | 155:8435094ec241 | 546 | USARTx->CR2 |= USART_CR2_MSBFIRST; |
mbed_official | 155:8435094ec241 | 547 | } |
mbed_official | 155:8435094ec241 | 548 | else |
mbed_official | 155:8435094ec241 | 549 | { |
mbed_official | 155:8435094ec241 | 550 | /* Disable the most significant bit first transmitted/received following the |
mbed_official | 155:8435094ec241 | 551 | start bit by clearing the MSBFIRST bit in the CR2 register */ |
mbed_official | 155:8435094ec241 | 552 | USARTx->CR2 &= (uint32_t)~((uint32_t)USART_CR2_MSBFIRST); |
mbed_official | 155:8435094ec241 | 553 | } |
mbed_official | 155:8435094ec241 | 554 | } |
mbed_official | 155:8435094ec241 | 555 | |
mbed_official | 155:8435094ec241 | 556 | /** |
mbed_official | 155:8435094ec241 | 557 | * @brief Enables or disables the binary data inversion. |
mbed_official | 155:8435094ec241 | 558 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 559 | * following values: USART1 or USART2 or USART3 or UART4 or UART5. |
mbed_official | 155:8435094ec241 | 560 | * @param NewState: new defined levels for the USART data. |
mbed_official | 155:8435094ec241 | 561 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 562 | * @arg ENABLE: Logical data from the data register are send/received in negative |
mbed_official | 155:8435094ec241 | 563 | * logic. (1=L, 0=H). The parity bit is also inverted. |
mbed_official | 155:8435094ec241 | 564 | * @arg DISABLE: Logical data from the data register are send/received in positive |
mbed_official | 155:8435094ec241 | 565 | * logic. (1=H, 0=L) |
mbed_official | 155:8435094ec241 | 566 | * @note |
mbed_official | 155:8435094ec241 | 567 | * This function has to be called before calling USART_Cmd() function. |
mbed_official | 155:8435094ec241 | 568 | * @retval None |
mbed_official | 155:8435094ec241 | 569 | */ |
mbed_official | 155:8435094ec241 | 570 | void USART_DataInvCmd(USART_TypeDef* USARTx, FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 571 | { |
mbed_official | 155:8435094ec241 | 572 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 573 | assert_param(IS_USART_ALL_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 574 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 575 | |
mbed_official | 155:8435094ec241 | 576 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 577 | { |
mbed_official | 155:8435094ec241 | 578 | /* Enable the binary data inversion feature by setting the DATAINV bit in |
mbed_official | 155:8435094ec241 | 579 | the CR2 register */ |
mbed_official | 155:8435094ec241 | 580 | USARTx->CR2 |= USART_CR2_DATAINV; |
mbed_official | 155:8435094ec241 | 581 | } |
mbed_official | 155:8435094ec241 | 582 | else |
mbed_official | 155:8435094ec241 | 583 | { |
mbed_official | 155:8435094ec241 | 584 | /* Disable the binary data inversion feature by clearing the DATAINV bit in |
mbed_official | 155:8435094ec241 | 585 | the CR2 register */ |
mbed_official | 155:8435094ec241 | 586 | USARTx->CR2 &= (uint32_t)~((uint32_t)USART_CR2_DATAINV); |
mbed_official | 155:8435094ec241 | 587 | } |
mbed_official | 155:8435094ec241 | 588 | } |
mbed_official | 155:8435094ec241 | 589 | |
mbed_official | 155:8435094ec241 | 590 | /** |
mbed_official | 155:8435094ec241 | 591 | * @brief Enables or disables the Pin(s) active level inversion. |
mbed_official | 155:8435094ec241 | 592 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 593 | * following values: USART1 or USART2 or USART3 or UART4 or UART5. |
mbed_official | 155:8435094ec241 | 594 | * @param USART_InvPin: specifies the USART pin(s) to invert. |
mbed_official | 155:8435094ec241 | 595 | * This parameter can be any combination of the following values: |
mbed_official | 155:8435094ec241 | 596 | * @arg USART_InvPin_Tx: USART Tx pin active level inversion. |
mbed_official | 155:8435094ec241 | 597 | * @arg USART_InvPin_Rx: USART Rx pin active level inversion. |
mbed_official | 155:8435094ec241 | 598 | * @param NewState: new active level status for the USART pin(s). |
mbed_official | 155:8435094ec241 | 599 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 600 | * - ENABLE: pin(s) signal values are inverted (Vdd =0, Gnd =1). |
mbed_official | 155:8435094ec241 | 601 | * - DISABLE: pin(s) signal works using the standard logic levels (Vdd =1, Gnd =0). |
mbed_official | 155:8435094ec241 | 602 | * @note |
mbed_official | 155:8435094ec241 | 603 | * This function has to be called before calling USART_Cmd() function. |
mbed_official | 155:8435094ec241 | 604 | * @retval None |
mbed_official | 155:8435094ec241 | 605 | */ |
mbed_official | 155:8435094ec241 | 606 | void USART_InvPinCmd(USART_TypeDef* USARTx, uint32_t USART_InvPin, FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 607 | { |
mbed_official | 155:8435094ec241 | 608 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 609 | assert_param(IS_USART_ALL_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 610 | assert_param(IS_USART_INVERSTION_PIN(USART_InvPin)); |
mbed_official | 155:8435094ec241 | 611 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 612 | |
mbed_official | 155:8435094ec241 | 613 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 614 | { |
mbed_official | 155:8435094ec241 | 615 | /* Enable the active level inversion for selected pins by setting the TXINV |
mbed_official | 155:8435094ec241 | 616 | and/or RXINV bits in the USART CR2 register */ |
mbed_official | 155:8435094ec241 | 617 | USARTx->CR2 |= USART_InvPin; |
mbed_official | 155:8435094ec241 | 618 | } |
mbed_official | 155:8435094ec241 | 619 | else |
mbed_official | 155:8435094ec241 | 620 | { |
mbed_official | 155:8435094ec241 | 621 | /* Disable the active level inversion for selected requests by clearing the |
mbed_official | 155:8435094ec241 | 622 | TXINV and/or RXINV bits in the USART CR2 register */ |
mbed_official | 155:8435094ec241 | 623 | USARTx->CR2 &= (uint32_t)~USART_InvPin; |
mbed_official | 155:8435094ec241 | 624 | } |
mbed_official | 155:8435094ec241 | 625 | } |
mbed_official | 155:8435094ec241 | 626 | |
mbed_official | 155:8435094ec241 | 627 | /** |
mbed_official | 155:8435094ec241 | 628 | * @brief Enables or disables the swap Tx/Rx pins. |
mbed_official | 155:8435094ec241 | 629 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 630 | * following values: USART1 or USART2 or USART3 or UART4 or UART5. |
mbed_official | 155:8435094ec241 | 631 | * @param NewState: new state of the USARTx TX/RX pins pinout. |
mbed_official | 155:8435094ec241 | 632 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 633 | * @arg ENABLE: The TX and RX pins functions are swapped. |
mbed_official | 155:8435094ec241 | 634 | * @arg DISABLE: TX/RX pins are used as defined in standard pinout |
mbed_official | 155:8435094ec241 | 635 | * @note |
mbed_official | 155:8435094ec241 | 636 | * This function has to be called before calling USART_Cmd() function. |
mbed_official | 155:8435094ec241 | 637 | * @retval None |
mbed_official | 155:8435094ec241 | 638 | */ |
mbed_official | 155:8435094ec241 | 639 | void USART_SWAPPinCmd(USART_TypeDef* USARTx, FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 640 | { |
mbed_official | 155:8435094ec241 | 641 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 642 | assert_param(IS_USART_ALL_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 643 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 644 | |
mbed_official | 155:8435094ec241 | 645 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 646 | { |
mbed_official | 155:8435094ec241 | 647 | /* Enable the SWAP feature by setting the SWAP bit in the CR2 register */ |
mbed_official | 155:8435094ec241 | 648 | USARTx->CR2 |= USART_CR2_SWAP; |
mbed_official | 155:8435094ec241 | 649 | } |
mbed_official | 155:8435094ec241 | 650 | else |
mbed_official | 155:8435094ec241 | 651 | { |
mbed_official | 155:8435094ec241 | 652 | /* Disable the SWAP feature by clearing the SWAP bit in the CR2 register */ |
mbed_official | 155:8435094ec241 | 653 | USARTx->CR2 &= (uint32_t)~((uint32_t)USART_CR2_SWAP); |
mbed_official | 155:8435094ec241 | 654 | } |
mbed_official | 155:8435094ec241 | 655 | } |
mbed_official | 155:8435094ec241 | 656 | |
mbed_official | 155:8435094ec241 | 657 | /** |
mbed_official | 155:8435094ec241 | 658 | * @brief Enables or disables the receiver Time Out feature. |
mbed_official | 155:8435094ec241 | 659 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 660 | * following values: USART1 or USART2 or USART3 or UART4 or UART5. |
mbed_official | 155:8435094ec241 | 661 | * @param NewState: new state of the USARTx receiver Time Out. |
mbed_official | 155:8435094ec241 | 662 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 663 | * @retval None |
mbed_official | 155:8435094ec241 | 664 | */ |
mbed_official | 155:8435094ec241 | 665 | void USART_ReceiverTimeOutCmd(USART_TypeDef* USARTx, FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 666 | { |
mbed_official | 155:8435094ec241 | 667 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 668 | assert_param(IS_USART_ALL_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 669 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 670 | |
mbed_official | 155:8435094ec241 | 671 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 672 | { |
mbed_official | 155:8435094ec241 | 673 | /* Enable the receiver time out feature by setting the RTOEN bit in the CR2 |
mbed_official | 155:8435094ec241 | 674 | register */ |
mbed_official | 155:8435094ec241 | 675 | USARTx->CR2 |= USART_CR2_RTOEN; |
mbed_official | 155:8435094ec241 | 676 | } |
mbed_official | 155:8435094ec241 | 677 | else |
mbed_official | 155:8435094ec241 | 678 | { |
mbed_official | 155:8435094ec241 | 679 | /* Disable the receiver time out feature by clearing the RTOEN bit in the CR2 |
mbed_official | 155:8435094ec241 | 680 | register */ |
mbed_official | 155:8435094ec241 | 681 | USARTx->CR2 &= (uint32_t)~((uint32_t)USART_CR2_RTOEN); |
mbed_official | 155:8435094ec241 | 682 | } |
mbed_official | 155:8435094ec241 | 683 | } |
mbed_official | 155:8435094ec241 | 684 | |
mbed_official | 155:8435094ec241 | 685 | /** |
mbed_official | 155:8435094ec241 | 686 | * @brief Sets the receiver Time Out value. |
mbed_official | 155:8435094ec241 | 687 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 688 | * following values: USART1 or USART2 or USART3 or UART4 or UART5. |
mbed_official | 155:8435094ec241 | 689 | * @param USART_ReceiverTimeOut: specifies the Receiver Time Out value. |
mbed_official | 155:8435094ec241 | 690 | * @retval None |
mbed_official | 155:8435094ec241 | 691 | */ |
mbed_official | 155:8435094ec241 | 692 | void USART_SetReceiverTimeOut(USART_TypeDef* USARTx, uint32_t USART_ReceiverTimeOut) |
mbed_official | 155:8435094ec241 | 693 | { |
mbed_official | 155:8435094ec241 | 694 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 695 | assert_param(IS_USART_ALL_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 696 | assert_param(IS_USART_TIMEOUT(USART_ReceiverTimeOut)); |
mbed_official | 155:8435094ec241 | 697 | |
mbed_official | 155:8435094ec241 | 698 | /* Clear the receiver Time Out value by clearing the RTO[23:0] bits in the RTOR |
mbed_official | 155:8435094ec241 | 699 | register */ |
mbed_official | 155:8435094ec241 | 700 | USARTx->RTOR &= (uint32_t)~((uint32_t)USART_RTOR_RTO); |
mbed_official | 155:8435094ec241 | 701 | /* Set the receiver Time Out value by setting the RTO[23:0] bits in the RTOR |
mbed_official | 155:8435094ec241 | 702 | register */ |
mbed_official | 155:8435094ec241 | 703 | USARTx->RTOR |= USART_ReceiverTimeOut; |
mbed_official | 155:8435094ec241 | 704 | } |
mbed_official | 155:8435094ec241 | 705 | |
mbed_official | 155:8435094ec241 | 706 | /** |
mbed_official | 155:8435094ec241 | 707 | * @brief Sets the system clock prescaler. |
mbed_official | 155:8435094ec241 | 708 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 709 | * following values: USART1 or USART2 or USART3 or UART4 or UART5. |
mbed_official | 155:8435094ec241 | 710 | * @param USART_Prescaler: specifies the prescaler clock. |
mbed_official | 155:8435094ec241 | 711 | * @note |
mbed_official | 155:8435094ec241 | 712 | * This function has to be called before calling USART_Cmd() function. |
mbed_official | 155:8435094ec241 | 713 | * @retval None |
mbed_official | 155:8435094ec241 | 714 | */ |
mbed_official | 155:8435094ec241 | 715 | void USART_SetPrescaler(USART_TypeDef* USARTx, uint8_t USART_Prescaler) |
mbed_official | 155:8435094ec241 | 716 | { |
mbed_official | 155:8435094ec241 | 717 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 718 | assert_param(IS_USART_ALL_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 719 | |
mbed_official | 155:8435094ec241 | 720 | /* Clear the USART prescaler */ |
mbed_official | 155:8435094ec241 | 721 | USARTx->GTPR &= USART_GTPR_GT; |
mbed_official | 155:8435094ec241 | 722 | /* Set the USART prescaler */ |
mbed_official | 155:8435094ec241 | 723 | USARTx->GTPR |= USART_Prescaler; |
mbed_official | 155:8435094ec241 | 724 | } |
mbed_official | 155:8435094ec241 | 725 | |
mbed_official | 155:8435094ec241 | 726 | /** |
mbed_official | 155:8435094ec241 | 727 | * @} |
mbed_official | 155:8435094ec241 | 728 | */ |
mbed_official | 155:8435094ec241 | 729 | |
mbed_official | 155:8435094ec241 | 730 | |
mbed_official | 155:8435094ec241 | 731 | /** @defgroup USART_Group2 STOP Mode functions |
mbed_official | 155:8435094ec241 | 732 | * @brief STOP Mode functions |
mbed_official | 155:8435094ec241 | 733 | * |
mbed_official | 155:8435094ec241 | 734 | @verbatim |
mbed_official | 155:8435094ec241 | 735 | =============================================================================== |
mbed_official | 155:8435094ec241 | 736 | ##### STOP Mode functions ##### |
mbed_official | 155:8435094ec241 | 737 | =============================================================================== |
mbed_official | 155:8435094ec241 | 738 | [..] This subsection provides a set of functions allowing to manage |
mbed_official | 155:8435094ec241 | 739 | WakeUp from STOP mode. |
mbed_official | 155:8435094ec241 | 740 | |
mbed_official | 155:8435094ec241 | 741 | [..] The USART is able to WakeUp from Stop Mode if USART clock is set to HSI |
mbed_official | 155:8435094ec241 | 742 | or LSI. |
mbed_official | 155:8435094ec241 | 743 | |
mbed_official | 155:8435094ec241 | 744 | [..] The WakeUp source is configured by calling USART_StopModeWakeUpSourceConfig() |
mbed_official | 155:8435094ec241 | 745 | function. |
mbed_official | 155:8435094ec241 | 746 | |
mbed_official | 155:8435094ec241 | 747 | [..] After configuring the source of WakeUp and before entering in Stop Mode |
mbed_official | 155:8435094ec241 | 748 | USART_STOPModeCmd() function should be called to allow USART WakeUp. |
mbed_official | 155:8435094ec241 | 749 | |
mbed_official | 155:8435094ec241 | 750 | @endverbatim |
mbed_official | 155:8435094ec241 | 751 | * @{ |
mbed_official | 155:8435094ec241 | 752 | */ |
mbed_official | 155:8435094ec241 | 753 | |
mbed_official | 155:8435094ec241 | 754 | /** |
mbed_official | 155:8435094ec241 | 755 | * @brief Enables or disables the specified USART peripheral in STOP Mode. |
mbed_official | 155:8435094ec241 | 756 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 757 | * following values: USART1 or USART2 or USART3 or UART4 or UART5. |
mbed_official | 155:8435094ec241 | 758 | * @param NewState: new state of the USARTx peripheral state in stop mode. |
mbed_official | 155:8435094ec241 | 759 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 760 | * @note |
mbed_official | 155:8435094ec241 | 761 | * This function has to be called when USART clock is set to HSI or LSE. |
mbed_official | 155:8435094ec241 | 762 | * @retval None |
mbed_official | 155:8435094ec241 | 763 | */ |
mbed_official | 155:8435094ec241 | 764 | void USART_STOPModeCmd(USART_TypeDef* USARTx, FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 765 | { |
mbed_official | 155:8435094ec241 | 766 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 767 | assert_param(IS_USART_ALL_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 768 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 769 | |
mbed_official | 155:8435094ec241 | 770 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 771 | { |
mbed_official | 155:8435094ec241 | 772 | /* Enable the selected USART in STOP mode by setting the UESM bit in the CR1 |
mbed_official | 155:8435094ec241 | 773 | register */ |
mbed_official | 155:8435094ec241 | 774 | USARTx->CR1 |= USART_CR1_UESM; |
mbed_official | 155:8435094ec241 | 775 | } |
mbed_official | 155:8435094ec241 | 776 | else |
mbed_official | 155:8435094ec241 | 777 | { |
mbed_official | 155:8435094ec241 | 778 | /* Disable the selected USART in STOP mode by clearing the UE bit in the CR1 |
mbed_official | 155:8435094ec241 | 779 | register */ |
mbed_official | 155:8435094ec241 | 780 | USARTx->CR1 &= (uint32_t)~((uint32_t)USART_CR1_UESM); |
mbed_official | 155:8435094ec241 | 781 | } |
mbed_official | 155:8435094ec241 | 782 | } |
mbed_official | 155:8435094ec241 | 783 | |
mbed_official | 155:8435094ec241 | 784 | /** |
mbed_official | 155:8435094ec241 | 785 | * @brief Selects the USART WakeUp method form stop mode. |
mbed_official | 155:8435094ec241 | 786 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 787 | * following values: USART1 or USART2 or USART3 or UART4 or UART5. |
mbed_official | 155:8435094ec241 | 788 | * @param USART_WakeUp: specifies the selected USART wakeup method. |
mbed_official | 155:8435094ec241 | 789 | * This parameter can be one of the following values: |
mbed_official | 155:8435094ec241 | 790 | * @arg USART_WakeUpSource_AddressMatch: WUF active on address match. |
mbed_official | 155:8435094ec241 | 791 | * @arg USART_WakeUpSource_StartBit: WUF active on Start bit detection. |
mbed_official | 155:8435094ec241 | 792 | * @arg USART_WakeUpSource_RXNE: WUF active on RXNE. |
mbed_official | 155:8435094ec241 | 793 | * @note |
mbed_official | 155:8435094ec241 | 794 | * This function has to be called before calling USART_Cmd() function. |
mbed_official | 155:8435094ec241 | 795 | * @retval None |
mbed_official | 155:8435094ec241 | 796 | */ |
mbed_official | 155:8435094ec241 | 797 | void USART_StopModeWakeUpSourceConfig(USART_TypeDef* USARTx, uint32_t USART_WakeUpSource) |
mbed_official | 155:8435094ec241 | 798 | { |
mbed_official | 155:8435094ec241 | 799 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 800 | assert_param(IS_USART_ALL_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 801 | assert_param(IS_USART_STOPMODE_WAKEUPSOURCE(USART_WakeUpSource)); |
mbed_official | 155:8435094ec241 | 802 | |
mbed_official | 155:8435094ec241 | 803 | USARTx->CR3 &= (uint32_t)~((uint32_t)USART_CR3_WUS); |
mbed_official | 155:8435094ec241 | 804 | USARTx->CR3 |= USART_WakeUpSource; |
mbed_official | 155:8435094ec241 | 805 | } |
mbed_official | 155:8435094ec241 | 806 | |
mbed_official | 155:8435094ec241 | 807 | /** |
mbed_official | 155:8435094ec241 | 808 | * @} |
mbed_official | 155:8435094ec241 | 809 | */ |
mbed_official | 155:8435094ec241 | 810 | |
mbed_official | 155:8435094ec241 | 811 | |
mbed_official | 155:8435094ec241 | 812 | /** @defgroup USART_Group3 AutoBaudRate functions |
mbed_official | 155:8435094ec241 | 813 | * @brief AutoBaudRate functions |
mbed_official | 155:8435094ec241 | 814 | * |
mbed_official | 155:8435094ec241 | 815 | @verbatim |
mbed_official | 155:8435094ec241 | 816 | =============================================================================== |
mbed_official | 155:8435094ec241 | 817 | ##### AutoBaudRate functions ##### |
mbed_official | 155:8435094ec241 | 818 | =============================================================================== |
mbed_official | 155:8435094ec241 | 819 | [..] This subsection provides a set of functions allowing to manage |
mbed_official | 155:8435094ec241 | 820 | the AutoBaudRate detections. |
mbed_official | 155:8435094ec241 | 821 | |
mbed_official | 155:8435094ec241 | 822 | [..] Before Enabling AutoBaudRate detection using USART_AutoBaudRateCmd () |
mbed_official | 155:8435094ec241 | 823 | The character patterns used to calculate baudrate must be chosen by calling |
mbed_official | 155:8435094ec241 | 824 | USART_AutoBaudRateConfig() function. These function take as parameter : |
mbed_official | 155:8435094ec241 | 825 | (#)USART_AutoBaudRate_StartBit : any character starting with a bit 1. |
mbed_official | 155:8435094ec241 | 826 | (#)USART_AutoBaudRate_FallingEdge : any character starting with a 10xx bit pattern. |
mbed_official | 155:8435094ec241 | 827 | |
mbed_official | 155:8435094ec241 | 828 | [..] At any later time, another request for AutoBaudRate detection can be performed |
mbed_official | 155:8435094ec241 | 829 | using USART_RequestCmd() function. |
mbed_official | 155:8435094ec241 | 830 | |
mbed_official | 155:8435094ec241 | 831 | [..] The AutoBaudRate detection is monitored by the status of ABRF flag which indicate |
mbed_official | 155:8435094ec241 | 832 | that the AutoBaudRate detection is completed. In addition to ABRF flag, the ABRE flag |
mbed_official | 155:8435094ec241 | 833 | indicate that this procedure is completed without success. USART_GetFlagStatus () |
mbed_official | 155:8435094ec241 | 834 | function should be used to monitor the status of these flags. |
mbed_official | 155:8435094ec241 | 835 | |
mbed_official | 155:8435094ec241 | 836 | @endverbatim |
mbed_official | 155:8435094ec241 | 837 | * @{ |
mbed_official | 155:8435094ec241 | 838 | */ |
mbed_official | 155:8435094ec241 | 839 | |
mbed_official | 155:8435094ec241 | 840 | /** |
mbed_official | 155:8435094ec241 | 841 | * @brief Enables or disables the Auto Baud Rate. |
mbed_official | 155:8435094ec241 | 842 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 843 | * following values: USART1 or USART2 or USART3 or UART4 or UART5. |
mbed_official | 155:8435094ec241 | 844 | * @param NewState: new state of the USARTx auto baud rate. |
mbed_official | 155:8435094ec241 | 845 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 846 | * @retval None |
mbed_official | 155:8435094ec241 | 847 | */ |
mbed_official | 155:8435094ec241 | 848 | void USART_AutoBaudRateCmd(USART_TypeDef* USARTx, FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 849 | { |
mbed_official | 155:8435094ec241 | 850 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 851 | assert_param(IS_USART_ALL_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 852 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 853 | |
mbed_official | 155:8435094ec241 | 854 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 855 | { |
mbed_official | 155:8435094ec241 | 856 | /* Enable the auto baud rate feature by setting the ABREN bit in the CR2 |
mbed_official | 155:8435094ec241 | 857 | register */ |
mbed_official | 155:8435094ec241 | 858 | USARTx->CR2 |= USART_CR2_ABREN; |
mbed_official | 155:8435094ec241 | 859 | } |
mbed_official | 155:8435094ec241 | 860 | else |
mbed_official | 155:8435094ec241 | 861 | { |
mbed_official | 155:8435094ec241 | 862 | /* Disable the auto baud rate feature by clearing the ABREN bit in the CR2 |
mbed_official | 155:8435094ec241 | 863 | register */ |
mbed_official | 155:8435094ec241 | 864 | USARTx->CR2 &= (uint32_t)~((uint32_t)USART_CR2_ABREN); |
mbed_official | 155:8435094ec241 | 865 | } |
mbed_official | 155:8435094ec241 | 866 | } |
mbed_official | 155:8435094ec241 | 867 | |
mbed_official | 155:8435094ec241 | 868 | /** |
mbed_official | 155:8435094ec241 | 869 | * @brief Selects the USART auto baud rate method. |
mbed_official | 155:8435094ec241 | 870 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 871 | * following values: USART1 or USART2 or USART3 or UART4 or UART5. |
mbed_official | 155:8435094ec241 | 872 | * @param USART_AutoBaudRate: specifies the selected USART auto baud rate method. |
mbed_official | 155:8435094ec241 | 873 | * This parameter can be one of the following values: |
mbed_official | 155:8435094ec241 | 874 | * @arg USART_AutoBaudRate_StartBit: Start Bit duration measurement. |
mbed_official | 155:8435094ec241 | 875 | * @arg USART_AutoBaudRate_FallingEdge: Falling edge to falling edge measurement. |
mbed_official | 155:8435094ec241 | 876 | * @arg USART_AutoBaudRate_0x7FFrame: 0x7F frame. |
mbed_official | 155:8435094ec241 | 877 | * @arg USART_AutoBaudRate_0x55Frame: 0x55 frame. |
mbed_official | 155:8435094ec241 | 878 | * @note |
mbed_official | 155:8435094ec241 | 879 | * This function has to be called before calling USART_Cmd() function. |
mbed_official | 155:8435094ec241 | 880 | * @retval None |
mbed_official | 155:8435094ec241 | 881 | */ |
mbed_official | 155:8435094ec241 | 882 | void USART_AutoBaudRateConfig(USART_TypeDef* USARTx, uint32_t USART_AutoBaudRate) |
mbed_official | 155:8435094ec241 | 883 | { |
mbed_official | 155:8435094ec241 | 884 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 885 | assert_param(IS_USART_ALL_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 886 | assert_param(IS_USART_AUTOBAUDRATE_MODE(USART_AutoBaudRate)); |
mbed_official | 155:8435094ec241 | 887 | |
mbed_official | 155:8435094ec241 | 888 | USARTx->CR2 &= (uint32_t)~((uint32_t)USART_CR2_ABRMODE); |
mbed_official | 155:8435094ec241 | 889 | USARTx->CR2 |= USART_AutoBaudRate; |
mbed_official | 155:8435094ec241 | 890 | } |
mbed_official | 155:8435094ec241 | 891 | |
mbed_official | 155:8435094ec241 | 892 | /** |
mbed_official | 155:8435094ec241 | 893 | * @} |
mbed_official | 155:8435094ec241 | 894 | */ |
mbed_official | 155:8435094ec241 | 895 | |
mbed_official | 155:8435094ec241 | 896 | |
mbed_official | 155:8435094ec241 | 897 | /** @defgroup USART_Group4 Data transfers functions |
mbed_official | 155:8435094ec241 | 898 | * @brief Data transfers functions |
mbed_official | 155:8435094ec241 | 899 | * |
mbed_official | 155:8435094ec241 | 900 | @verbatim |
mbed_official | 155:8435094ec241 | 901 | =============================================================================== |
mbed_official | 155:8435094ec241 | 902 | ##### Data transfers functions ##### |
mbed_official | 155:8435094ec241 | 903 | =============================================================================== |
mbed_official | 155:8435094ec241 | 904 | [..] This subsection provides a set of functions allowing to manage |
mbed_official | 155:8435094ec241 | 905 | the USART data transfers. |
mbed_official | 155:8435094ec241 | 906 | [..] During an USART reception, data shifts in least significant bit first |
mbed_official | 155:8435094ec241 | 907 | through the RX pin. When a transmission is taking place, a write instruction to |
mbed_official | 155:8435094ec241 | 908 | the USART_TDR register stores the data in the shift register. |
mbed_official | 155:8435094ec241 | 909 | [..] The read access of the USART_RDR register can be done using |
mbed_official | 155:8435094ec241 | 910 | the USART_ReceiveData() function and returns the RDR value. |
mbed_official | 155:8435094ec241 | 911 | Whereas a write access to the USART_TDR can be done using USART_SendData() |
mbed_official | 155:8435094ec241 | 912 | function and stores the written data into TDR. |
mbed_official | 155:8435094ec241 | 913 | |
mbed_official | 155:8435094ec241 | 914 | @endverbatim |
mbed_official | 155:8435094ec241 | 915 | * @{ |
mbed_official | 155:8435094ec241 | 916 | */ |
mbed_official | 155:8435094ec241 | 917 | |
mbed_official | 155:8435094ec241 | 918 | /** |
mbed_official | 155:8435094ec241 | 919 | * @brief Transmits single data through the USARTx peripheral. |
mbed_official | 155:8435094ec241 | 920 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 921 | * following values: USART1 or USART2 or USART3 or UART4 or UART5. |
mbed_official | 155:8435094ec241 | 922 | * @param Data: the data to transmit. |
mbed_official | 155:8435094ec241 | 923 | * @retval None |
mbed_official | 155:8435094ec241 | 924 | */ |
mbed_official | 155:8435094ec241 | 925 | void USART_SendData(USART_TypeDef* USARTx, uint16_t Data) |
mbed_official | 155:8435094ec241 | 926 | { |
mbed_official | 155:8435094ec241 | 927 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 928 | assert_param(IS_USART_ALL_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 929 | assert_param(IS_USART_DATA(Data)); |
mbed_official | 155:8435094ec241 | 930 | |
mbed_official | 155:8435094ec241 | 931 | /* Transmit Data */ |
mbed_official | 155:8435094ec241 | 932 | USARTx->TDR = (Data & (uint16_t)0x01FF); |
mbed_official | 155:8435094ec241 | 933 | } |
mbed_official | 155:8435094ec241 | 934 | |
mbed_official | 155:8435094ec241 | 935 | /** |
mbed_official | 155:8435094ec241 | 936 | * @brief Returns the most recent received data by the USARTx peripheral. |
mbed_official | 155:8435094ec241 | 937 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 938 | * following values: USART1 or USART2 or USART3 or UART4 or UART5. |
mbed_official | 155:8435094ec241 | 939 | * @retval The received data. |
mbed_official | 155:8435094ec241 | 940 | */ |
mbed_official | 155:8435094ec241 | 941 | uint16_t USART_ReceiveData(USART_TypeDef* USARTx) |
mbed_official | 155:8435094ec241 | 942 | { |
mbed_official | 155:8435094ec241 | 943 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 944 | assert_param(IS_USART_ALL_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 945 | |
mbed_official | 155:8435094ec241 | 946 | /* Receive Data */ |
mbed_official | 155:8435094ec241 | 947 | return (uint16_t)(USARTx->RDR & (uint16_t)0x01FF); |
mbed_official | 155:8435094ec241 | 948 | } |
mbed_official | 155:8435094ec241 | 949 | |
mbed_official | 155:8435094ec241 | 950 | /** |
mbed_official | 155:8435094ec241 | 951 | * @} |
mbed_official | 155:8435094ec241 | 952 | */ |
mbed_official | 155:8435094ec241 | 953 | |
mbed_official | 155:8435094ec241 | 954 | /** @defgroup USART_Group5 MultiProcessor Communication functions |
mbed_official | 155:8435094ec241 | 955 | * @brief Multi-Processor Communication functions |
mbed_official | 155:8435094ec241 | 956 | * |
mbed_official | 155:8435094ec241 | 957 | @verbatim |
mbed_official | 155:8435094ec241 | 958 | =============================================================================== |
mbed_official | 155:8435094ec241 | 959 | ##### Multi-Processor Communication functions ##### |
mbed_official | 155:8435094ec241 | 960 | =============================================================================== |
mbed_official | 155:8435094ec241 | 961 | [..] This subsection provides a set of functions allowing to manage the USART |
mbed_official | 155:8435094ec241 | 962 | multiprocessor communication. |
mbed_official | 155:8435094ec241 | 963 | [..] For instance one of the USARTs can be the master, its TX output is |
mbed_official | 155:8435094ec241 | 964 | connected to the RX input of the other USART. The others are slaves, |
mbed_official | 155:8435094ec241 | 965 | their respective TX outputs are logically ANDed together and connected |
mbed_official | 155:8435094ec241 | 966 | to the RX input of the master. USART multiprocessor communication is |
mbed_official | 155:8435094ec241 | 967 | possible through the following procedure: |
mbed_official | 155:8435094ec241 | 968 | (#) Program the Baud rate, Word length = 9 bits, Stop bits, Parity, |
mbed_official | 155:8435094ec241 | 969 | Mode transmitter or Mode receiver and hardware flow control values |
mbed_official | 155:8435094ec241 | 970 | using the USART_Init() function. |
mbed_official | 155:8435094ec241 | 971 | (#) Configures the USART address using the USART_SetAddress() function. |
mbed_official | 155:8435094ec241 | 972 | (#) Configures the wake up methode (USART_WakeUp_IdleLine or |
mbed_official | 155:8435094ec241 | 973 | USART_WakeUp_AddressMark) using USART_WakeUpConfig() function only |
mbed_official | 155:8435094ec241 | 974 | for the slaves. |
mbed_official | 155:8435094ec241 | 975 | (#) Enable the USART using the USART_Cmd() function. |
mbed_official | 155:8435094ec241 | 976 | (#) Enter the USART slaves in mute mode using USART_ReceiverWakeUpCmd() |
mbed_official | 155:8435094ec241 | 977 | function. |
mbed_official | 155:8435094ec241 | 978 | [..] The USART Slave exit from mute mode when receive the wake up condition. |
mbed_official | 155:8435094ec241 | 979 | |
mbed_official | 155:8435094ec241 | 980 | @endverbatim |
mbed_official | 155:8435094ec241 | 981 | * @{ |
mbed_official | 155:8435094ec241 | 982 | */ |
mbed_official | 155:8435094ec241 | 983 | |
mbed_official | 155:8435094ec241 | 984 | /** |
mbed_official | 155:8435094ec241 | 985 | * @brief Sets the address of the USART node. |
mbed_official | 155:8435094ec241 | 986 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 987 | * following values: USART1 or USART2 or USART3 or UART4 or UART5. |
mbed_official | 155:8435094ec241 | 988 | * @param USART_Address: Indicates the address of the USART node. |
mbed_official | 155:8435094ec241 | 989 | * @retval None |
mbed_official | 155:8435094ec241 | 990 | */ |
mbed_official | 155:8435094ec241 | 991 | void USART_SetAddress(USART_TypeDef* USARTx, uint8_t USART_Address) |
mbed_official | 155:8435094ec241 | 992 | { |
mbed_official | 155:8435094ec241 | 993 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 994 | assert_param(IS_USART_ALL_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 995 | |
mbed_official | 155:8435094ec241 | 996 | /* Clear the USART address */ |
mbed_official | 155:8435094ec241 | 997 | USARTx->CR2 &= (uint32_t)~((uint32_t)USART_CR2_ADD); |
mbed_official | 155:8435094ec241 | 998 | /* Set the USART address node */ |
mbed_official | 155:8435094ec241 | 999 | USARTx->CR2 |=((uint32_t)USART_Address << (uint32_t)0x18); |
mbed_official | 155:8435094ec241 | 1000 | } |
mbed_official | 155:8435094ec241 | 1001 | |
mbed_official | 155:8435094ec241 | 1002 | /** |
mbed_official | 155:8435094ec241 | 1003 | * @brief Enables or disables the USART's mute mode. |
mbed_official | 155:8435094ec241 | 1004 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 1005 | * following values: USART1 or USART2 or USART3 or UART4 or UART5. |
mbed_official | 155:8435094ec241 | 1006 | * @param NewState: new state of the USART mute mode. |
mbed_official | 155:8435094ec241 | 1007 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 1008 | * @retval None |
mbed_official | 155:8435094ec241 | 1009 | */ |
mbed_official | 155:8435094ec241 | 1010 | void USART_MuteModeCmd(USART_TypeDef* USARTx, FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 1011 | { |
mbed_official | 155:8435094ec241 | 1012 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 1013 | assert_param(IS_USART_ALL_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 1014 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 1015 | |
mbed_official | 155:8435094ec241 | 1016 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 1017 | { |
mbed_official | 155:8435094ec241 | 1018 | /* Enable the USART mute mode by setting the MME bit in the CR1 register */ |
mbed_official | 155:8435094ec241 | 1019 | USARTx->CR1 |= USART_CR1_MME; |
mbed_official | 155:8435094ec241 | 1020 | } |
mbed_official | 155:8435094ec241 | 1021 | else |
mbed_official | 155:8435094ec241 | 1022 | { |
mbed_official | 155:8435094ec241 | 1023 | /* Disable the USART mute mode by clearing the MME bit in the CR1 register */ |
mbed_official | 155:8435094ec241 | 1024 | USARTx->CR1 &= (uint32_t)~((uint32_t)USART_CR1_MME); |
mbed_official | 155:8435094ec241 | 1025 | } |
mbed_official | 155:8435094ec241 | 1026 | } |
mbed_official | 155:8435094ec241 | 1027 | |
mbed_official | 155:8435094ec241 | 1028 | /** |
mbed_official | 155:8435094ec241 | 1029 | * @brief Selects the USART WakeUp method from mute mode. |
mbed_official | 155:8435094ec241 | 1030 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 1031 | * following values: USART1 or USART2 or USART3 or UART4 or UART5. |
mbed_official | 155:8435094ec241 | 1032 | * @param USART_WakeUp: specifies the USART wakeup method. |
mbed_official | 155:8435094ec241 | 1033 | * This parameter can be one of the following values: |
mbed_official | 155:8435094ec241 | 1034 | * @arg USART_WakeUp_IdleLine: WakeUp by an idle line detection |
mbed_official | 155:8435094ec241 | 1035 | * @arg USART_WakeUp_AddressMark: WakeUp by an address mark |
mbed_official | 155:8435094ec241 | 1036 | * @retval None |
mbed_official | 155:8435094ec241 | 1037 | */ |
mbed_official | 155:8435094ec241 | 1038 | void USART_MuteModeWakeUpConfig(USART_TypeDef* USARTx, uint32_t USART_WakeUp) |
mbed_official | 155:8435094ec241 | 1039 | { |
mbed_official | 155:8435094ec241 | 1040 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 1041 | assert_param(IS_USART_ALL_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 1042 | assert_param(IS_USART_MUTEMODE_WAKEUP(USART_WakeUp)); |
mbed_official | 155:8435094ec241 | 1043 | |
mbed_official | 155:8435094ec241 | 1044 | USARTx->CR1 &= (uint32_t)~((uint32_t)USART_CR1_WAKE); |
mbed_official | 155:8435094ec241 | 1045 | USARTx->CR1 |= USART_WakeUp; |
mbed_official | 155:8435094ec241 | 1046 | } |
mbed_official | 155:8435094ec241 | 1047 | |
mbed_official | 155:8435094ec241 | 1048 | /** |
mbed_official | 155:8435094ec241 | 1049 | * @brief Configure the the USART Address detection length. |
mbed_official | 155:8435094ec241 | 1050 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 1051 | * following values: USART1 or USART2 or USART3 or UART4 or UART5. |
mbed_official | 155:8435094ec241 | 1052 | * @param USART_AddressLength: specifies the USART address length detection. |
mbed_official | 155:8435094ec241 | 1053 | * This parameter can be one of the following values: |
mbed_official | 155:8435094ec241 | 1054 | * @arg USART_AddressLength_4b: 4-bit address length detection |
mbed_official | 155:8435094ec241 | 1055 | * @arg USART_AddressLength_7b: 7-bit address length detection |
mbed_official | 155:8435094ec241 | 1056 | * @retval None |
mbed_official | 155:8435094ec241 | 1057 | */ |
mbed_official | 155:8435094ec241 | 1058 | void USART_AddressDetectionConfig(USART_TypeDef* USARTx, uint32_t USART_AddressLength) |
mbed_official | 155:8435094ec241 | 1059 | { |
mbed_official | 155:8435094ec241 | 1060 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 1061 | assert_param(IS_USART_ALL_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 1062 | assert_param(IS_USART_ADDRESS_DETECTION(USART_AddressLength)); |
mbed_official | 155:8435094ec241 | 1063 | |
mbed_official | 155:8435094ec241 | 1064 | USARTx->CR2 &= (uint32_t)~((uint32_t)USART_CR2_ADDM7); |
mbed_official | 155:8435094ec241 | 1065 | USARTx->CR2 |= USART_AddressLength; |
mbed_official | 155:8435094ec241 | 1066 | } |
mbed_official | 155:8435094ec241 | 1067 | |
mbed_official | 155:8435094ec241 | 1068 | /** |
mbed_official | 155:8435094ec241 | 1069 | * @} |
mbed_official | 155:8435094ec241 | 1070 | */ |
mbed_official | 155:8435094ec241 | 1071 | |
mbed_official | 155:8435094ec241 | 1072 | /** @defgroup USART_Group6 LIN mode functions |
mbed_official | 155:8435094ec241 | 1073 | * @brief LIN mode functions |
mbed_official | 155:8435094ec241 | 1074 | * |
mbed_official | 155:8435094ec241 | 1075 | @verbatim |
mbed_official | 155:8435094ec241 | 1076 | =============================================================================== |
mbed_official | 155:8435094ec241 | 1077 | ##### LIN mode functions ##### |
mbed_official | 155:8435094ec241 | 1078 | =============================================================================== |
mbed_official | 155:8435094ec241 | 1079 | [..] This subsection provides a set of functions allowing to manage the USART |
mbed_official | 155:8435094ec241 | 1080 | LIN Mode communication. |
mbed_official | 155:8435094ec241 | 1081 | [..] In LIN mode, 8-bit data format with 1 stop bit is required in accordance |
mbed_official | 155:8435094ec241 | 1082 | with the LIN standard. |
mbed_official | 155:8435094ec241 | 1083 | [..] Only this LIN Feature is supported by the USART IP: |
mbed_official | 155:8435094ec241 | 1084 | (+) LIN Master Synchronous Break send capability and LIN slave break |
mbed_official | 155:8435094ec241 | 1085 | detection capability : 13-bit break generation and 10/11 bit break |
mbed_official | 155:8435094ec241 | 1086 | detection. |
mbed_official | 155:8435094ec241 | 1087 | [..] USART LIN Master transmitter communication is possible through the |
mbed_official | 155:8435094ec241 | 1088 | following procedure: |
mbed_official | 155:8435094ec241 | 1089 | (#) Program the Baud rate, Word length = 8bits, Stop bits = 1bit, Parity, |
mbed_official | 155:8435094ec241 | 1090 | Mode transmitter or Mode receiver and hardware flow control values |
mbed_official | 155:8435094ec241 | 1091 | using the USART_Init() function. |
mbed_official | 155:8435094ec241 | 1092 | (#) Enable the LIN mode using the USART_LINCmd() function. |
mbed_official | 155:8435094ec241 | 1093 | (#) Enable the USART using the USART_Cmd() function. |
mbed_official | 155:8435094ec241 | 1094 | (#) Send the break character using USART_SendBreak() function. |
mbed_official | 155:8435094ec241 | 1095 | [..] USART LIN Master receiver communication is possible through the |
mbed_official | 155:8435094ec241 | 1096 | following procedure: |
mbed_official | 155:8435094ec241 | 1097 | (#) Program the Baud rate, Word length = 8bits, Stop bits = 1bit, Parity, |
mbed_official | 155:8435094ec241 | 1098 | Mode transmitter or Mode receiver and hardware flow control values |
mbed_official | 155:8435094ec241 | 1099 | using the USART_Init() function. |
mbed_official | 155:8435094ec241 | 1100 | (#) Configures the break detection length |
mbed_official | 155:8435094ec241 | 1101 | using the USART_LINBreakDetectLengthConfig() function. |
mbed_official | 155:8435094ec241 | 1102 | (#) Enable the LIN mode using the USART_LINCmd() function. |
mbed_official | 155:8435094ec241 | 1103 | (#) Enable the USART using the USART_Cmd() function. |
mbed_official | 155:8435094ec241 | 1104 | [..] |
mbed_official | 155:8435094ec241 | 1105 | (@) In LIN mode, the following bits must be kept cleared: |
mbed_official | 155:8435094ec241 | 1106 | (+@) CLKEN in the USART_CR2 register. |
mbed_official | 155:8435094ec241 | 1107 | (+@) STOP[1:0], SCEN, HDSEL and IREN in the USART_CR3 register. |
mbed_official | 155:8435094ec241 | 1108 | |
mbed_official | 155:8435094ec241 | 1109 | @endverbatim |
mbed_official | 155:8435094ec241 | 1110 | * @{ |
mbed_official | 155:8435094ec241 | 1111 | */ |
mbed_official | 155:8435094ec241 | 1112 | |
mbed_official | 155:8435094ec241 | 1113 | /** |
mbed_official | 155:8435094ec241 | 1114 | * @brief Sets the USART LIN Break detection length. |
mbed_official | 155:8435094ec241 | 1115 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 1116 | * following values: USART1 or USART2 or USART3 or UART4 or UART5. |
mbed_official | 155:8435094ec241 | 1117 | * @param USART_LINBreakDetectLength: specifies the LIN break detection length. |
mbed_official | 155:8435094ec241 | 1118 | * This parameter can be one of the following values: |
mbed_official | 155:8435094ec241 | 1119 | * @arg USART_LINBreakDetectLength_10b: 10-bit break detection |
mbed_official | 155:8435094ec241 | 1120 | * @arg USART_LINBreakDetectLength_11b: 11-bit break detection |
mbed_official | 155:8435094ec241 | 1121 | * @retval None |
mbed_official | 155:8435094ec241 | 1122 | */ |
mbed_official | 155:8435094ec241 | 1123 | void USART_LINBreakDetectLengthConfig(USART_TypeDef* USARTx, uint32_t USART_LINBreakDetectLength) |
mbed_official | 155:8435094ec241 | 1124 | { |
mbed_official | 155:8435094ec241 | 1125 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 1126 | assert_param(IS_USART_ALL_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 1127 | assert_param(IS_USART_LIN_BREAK_DETECT_LENGTH(USART_LINBreakDetectLength)); |
mbed_official | 155:8435094ec241 | 1128 | |
mbed_official | 155:8435094ec241 | 1129 | USARTx->CR2 &= (uint32_t)~((uint32_t)USART_CR2_LBDL); |
mbed_official | 155:8435094ec241 | 1130 | USARTx->CR2 |= USART_LINBreakDetectLength; |
mbed_official | 155:8435094ec241 | 1131 | } |
mbed_official | 155:8435094ec241 | 1132 | |
mbed_official | 155:8435094ec241 | 1133 | /** |
mbed_official | 155:8435094ec241 | 1134 | * @brief Enables or disables the USART's LIN mode. |
mbed_official | 155:8435094ec241 | 1135 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 1136 | * following values: USART1 or USART2 or USART3 or UART4 or UART5. |
mbed_official | 155:8435094ec241 | 1137 | * @param NewState: new state of the USART LIN mode. |
mbed_official | 155:8435094ec241 | 1138 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 1139 | * @retval None |
mbed_official | 155:8435094ec241 | 1140 | */ |
mbed_official | 155:8435094ec241 | 1141 | void USART_LINCmd(USART_TypeDef* USARTx, FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 1142 | { |
mbed_official | 155:8435094ec241 | 1143 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 1144 | assert_param(IS_USART_ALL_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 1145 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 1146 | |
mbed_official | 155:8435094ec241 | 1147 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 1148 | { |
mbed_official | 155:8435094ec241 | 1149 | /* Enable the LIN mode by setting the LINEN bit in the CR2 register */ |
mbed_official | 155:8435094ec241 | 1150 | USARTx->CR2 |= USART_CR2_LINEN; |
mbed_official | 155:8435094ec241 | 1151 | } |
mbed_official | 155:8435094ec241 | 1152 | else |
mbed_official | 155:8435094ec241 | 1153 | { |
mbed_official | 155:8435094ec241 | 1154 | /* Disable the LIN mode by clearing the LINEN bit in the CR2 register */ |
mbed_official | 155:8435094ec241 | 1155 | USARTx->CR2 &= (uint32_t)~((uint32_t)USART_CR2_LINEN); |
mbed_official | 155:8435094ec241 | 1156 | } |
mbed_official | 155:8435094ec241 | 1157 | } |
mbed_official | 155:8435094ec241 | 1158 | |
mbed_official | 155:8435094ec241 | 1159 | /** |
mbed_official | 155:8435094ec241 | 1160 | * @} |
mbed_official | 155:8435094ec241 | 1161 | */ |
mbed_official | 155:8435094ec241 | 1162 | |
mbed_official | 155:8435094ec241 | 1163 | /** @defgroup USART_Group7 Halfduplex mode function |
mbed_official | 155:8435094ec241 | 1164 | * @brief Half-duplex mode function |
mbed_official | 155:8435094ec241 | 1165 | * |
mbed_official | 155:8435094ec241 | 1166 | @verbatim |
mbed_official | 155:8435094ec241 | 1167 | =============================================================================== |
mbed_official | 155:8435094ec241 | 1168 | ##### Half-duplex mode function ##### |
mbed_official | 155:8435094ec241 | 1169 | =============================================================================== |
mbed_official | 155:8435094ec241 | 1170 | [..] This subsection provides a set of functions allowing to manage the USART |
mbed_official | 155:8435094ec241 | 1171 | Half-duplex communication. |
mbed_official | 155:8435094ec241 | 1172 | [..] The USART can be configured to follow a single-wire half-duplex protocol |
mbed_official | 155:8435094ec241 | 1173 | where the TX and RX lines are internally connected. |
mbed_official | 155:8435094ec241 | 1174 | [..] USART Half duplex communication is possible through the following procedure: |
mbed_official | 155:8435094ec241 | 1175 | (#) Program the Baud rate, Word length, Stop bits, Parity, Mode transmitter |
mbed_official | 155:8435094ec241 | 1176 | or Mode receiver and hardware flow control values using the USART_Init() |
mbed_official | 155:8435094ec241 | 1177 | function. |
mbed_official | 155:8435094ec241 | 1178 | (#) Configures the USART address using the USART_SetAddress() function. |
mbed_official | 155:8435094ec241 | 1179 | (#) Enable the half duplex mode using USART_HalfDuplexCmd() function. |
mbed_official | 155:8435094ec241 | 1180 | (#) Enable the USART using the USART_Cmd() function. |
mbed_official | 155:8435094ec241 | 1181 | [..] |
mbed_official | 155:8435094ec241 | 1182 | (@) The RX pin is no longer used. |
mbed_official | 155:8435094ec241 | 1183 | (@) In Half-duplex mode the following bits must be kept cleared: |
mbed_official | 155:8435094ec241 | 1184 | (+@) LINEN and CLKEN bits in the USART_CR2 register. |
mbed_official | 155:8435094ec241 | 1185 | (+@) SCEN and IREN bits in the USART_CR3 register. |
mbed_official | 155:8435094ec241 | 1186 | |
mbed_official | 155:8435094ec241 | 1187 | @endverbatim |
mbed_official | 155:8435094ec241 | 1188 | * @{ |
mbed_official | 155:8435094ec241 | 1189 | */ |
mbed_official | 155:8435094ec241 | 1190 | |
mbed_official | 155:8435094ec241 | 1191 | /** |
mbed_official | 155:8435094ec241 | 1192 | * @brief Enables or disables the USART's Half Duplex communication. |
mbed_official | 155:8435094ec241 | 1193 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 1194 | * following values: USART1 or USART2 or USART3 or UART4 or UART5. |
mbed_official | 155:8435094ec241 | 1195 | * @param NewState: new state of the USART Communication. |
mbed_official | 155:8435094ec241 | 1196 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 1197 | * @retval None |
mbed_official | 155:8435094ec241 | 1198 | */ |
mbed_official | 155:8435094ec241 | 1199 | void USART_HalfDuplexCmd(USART_TypeDef* USARTx, FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 1200 | { |
mbed_official | 155:8435094ec241 | 1201 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 1202 | assert_param(IS_USART_ALL_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 1203 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 1204 | |
mbed_official | 155:8435094ec241 | 1205 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 1206 | { |
mbed_official | 155:8435094ec241 | 1207 | /* Enable the Half-Duplex mode by setting the HDSEL bit in the CR3 register */ |
mbed_official | 155:8435094ec241 | 1208 | USARTx->CR3 |= USART_CR3_HDSEL; |
mbed_official | 155:8435094ec241 | 1209 | } |
mbed_official | 155:8435094ec241 | 1210 | else |
mbed_official | 155:8435094ec241 | 1211 | { |
mbed_official | 155:8435094ec241 | 1212 | /* Disable the Half-Duplex mode by clearing the HDSEL bit in the CR3 register */ |
mbed_official | 155:8435094ec241 | 1213 | USARTx->CR3 &= (uint32_t)~((uint32_t)USART_CR3_HDSEL); |
mbed_official | 155:8435094ec241 | 1214 | } |
mbed_official | 155:8435094ec241 | 1215 | } |
mbed_official | 155:8435094ec241 | 1216 | |
mbed_official | 155:8435094ec241 | 1217 | /** |
mbed_official | 155:8435094ec241 | 1218 | * @} |
mbed_official | 155:8435094ec241 | 1219 | */ |
mbed_official | 155:8435094ec241 | 1220 | |
mbed_official | 155:8435094ec241 | 1221 | |
mbed_official | 155:8435094ec241 | 1222 | /** @defgroup USART_Group8 Smartcard mode functions |
mbed_official | 155:8435094ec241 | 1223 | * @brief Smartcard mode functions |
mbed_official | 155:8435094ec241 | 1224 | * |
mbed_official | 155:8435094ec241 | 1225 | @verbatim |
mbed_official | 155:8435094ec241 | 1226 | =============================================================================== |
mbed_official | 155:8435094ec241 | 1227 | ##### Smartcard mode functions ##### |
mbed_official | 155:8435094ec241 | 1228 | =============================================================================== |
mbed_official | 155:8435094ec241 | 1229 | [..] This subsection provides a set of functions allowing to manage the USART |
mbed_official | 155:8435094ec241 | 1230 | Smartcard communication. |
mbed_official | 155:8435094ec241 | 1231 | [..] The Smartcard interface is designed to support asynchronous protocol |
mbed_official | 155:8435094ec241 | 1232 | Smartcards as defined in the ISO 7816-3 standard. The USART can provide |
mbed_official | 155:8435094ec241 | 1233 | a clock to the smartcard through the SCLK output. In smartcard mode, |
mbed_official | 155:8435094ec241 | 1234 | SCLK is not associated to the communication but is simply derived from |
mbed_official | 155:8435094ec241 | 1235 | the internal peripheral input clock through a 5-bit prescaler. |
mbed_official | 155:8435094ec241 | 1236 | [..] Smartcard communication is possible through the following procedure: |
mbed_official | 155:8435094ec241 | 1237 | (#) Configures the Smartcard Prsecaler using the USART_SetPrescaler() |
mbed_official | 155:8435094ec241 | 1238 | function. |
mbed_official | 155:8435094ec241 | 1239 | (#) Configures the Smartcard Guard Time using the USART_SetGuardTime() |
mbed_official | 155:8435094ec241 | 1240 | function. |
mbed_official | 155:8435094ec241 | 1241 | (#) Program the USART clock using the USART_ClockInit() function as following: |
mbed_official | 155:8435094ec241 | 1242 | (++) USART Clock enabled. |
mbed_official | 155:8435094ec241 | 1243 | (++) USART CPOL Low. |
mbed_official | 155:8435094ec241 | 1244 | (++) USART CPHA on first edge. |
mbed_official | 155:8435094ec241 | 1245 | (++) USART Last Bit Clock Enabled. |
mbed_official | 155:8435094ec241 | 1246 | (#) Program the Smartcard interface using the USART_Init() function as |
mbed_official | 155:8435094ec241 | 1247 | following: |
mbed_official | 155:8435094ec241 | 1248 | (++) Word Length = 9 Bits. |
mbed_official | 155:8435094ec241 | 1249 | (++) 1.5 Stop Bit. |
mbed_official | 155:8435094ec241 | 1250 | (++) Even parity. |
mbed_official | 155:8435094ec241 | 1251 | (++) BaudRate = 12096 baud. |
mbed_official | 155:8435094ec241 | 1252 | (++) Hardware flow control disabled (RTS and CTS signals). |
mbed_official | 155:8435094ec241 | 1253 | (++) Tx and Rx enabled |
mbed_official | 155:8435094ec241 | 1254 | (#) Optionally you can enable the parity error interrupt using |
mbed_official | 155:8435094ec241 | 1255 | the USART_ITConfig() function. |
mbed_official | 155:8435094ec241 | 1256 | (#) Enable the Smartcard NACK using the USART_SmartCardNACKCmd() function. |
mbed_official | 155:8435094ec241 | 1257 | (#) Enable the Smartcard interface using the USART_SmartCardCmd() function. |
mbed_official | 155:8435094ec241 | 1258 | (#) Enable the USART using the USART_Cmd() function. |
mbed_official | 155:8435094ec241 | 1259 | [..] |
mbed_official | 155:8435094ec241 | 1260 | Please refer to the ISO 7816-3 specification for more details. |
mbed_official | 155:8435094ec241 | 1261 | [..] |
mbed_official | 155:8435094ec241 | 1262 | (@) It is also possible to choose 0.5 stop bit for receiving but it is |
mbed_official | 155:8435094ec241 | 1263 | recommended to use 1.5 stop bits for both transmitting and receiving |
mbed_official | 155:8435094ec241 | 1264 | to avoid switching between the two configurations. |
mbed_official | 155:8435094ec241 | 1265 | (@) In smartcard mode, the following bits must be kept cleared: |
mbed_official | 155:8435094ec241 | 1266 | (+@) LINEN bit in the USART_CR2 register. |
mbed_official | 155:8435094ec241 | 1267 | (+@) HDSEL and IREN bits in the USART_CR3 register. |
mbed_official | 155:8435094ec241 | 1268 | |
mbed_official | 155:8435094ec241 | 1269 | @endverbatim |
mbed_official | 155:8435094ec241 | 1270 | * @{ |
mbed_official | 155:8435094ec241 | 1271 | */ |
mbed_official | 155:8435094ec241 | 1272 | |
mbed_official | 155:8435094ec241 | 1273 | /** |
mbed_official | 155:8435094ec241 | 1274 | * @brief Sets the specified USART guard time. |
mbed_official | 155:8435094ec241 | 1275 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 1276 | * following values: USART1 or USART2 or USART3. |
mbed_official | 155:8435094ec241 | 1277 | * @param USART_GuardTime: specifies the guard time. |
mbed_official | 155:8435094ec241 | 1278 | * @retval None |
mbed_official | 155:8435094ec241 | 1279 | */ |
mbed_official | 155:8435094ec241 | 1280 | void USART_SetGuardTime(USART_TypeDef* USARTx, uint8_t USART_GuardTime) |
mbed_official | 155:8435094ec241 | 1281 | { |
mbed_official | 155:8435094ec241 | 1282 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 1283 | assert_param(IS_USART_123_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 1284 | |
mbed_official | 155:8435094ec241 | 1285 | /* Clear the USART Guard time */ |
mbed_official | 155:8435094ec241 | 1286 | USARTx->GTPR &= USART_GTPR_PSC; |
mbed_official | 155:8435094ec241 | 1287 | /* Set the USART guard time */ |
mbed_official | 155:8435094ec241 | 1288 | USARTx->GTPR |= (uint16_t)((uint16_t)USART_GuardTime << 0x08); |
mbed_official | 155:8435094ec241 | 1289 | } |
mbed_official | 155:8435094ec241 | 1290 | |
mbed_official | 155:8435094ec241 | 1291 | /** |
mbed_official | 155:8435094ec241 | 1292 | * @brief Enables or disables the USART's Smart Card mode. |
mbed_official | 155:8435094ec241 | 1293 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 1294 | * following values: USART1 or USART2 or USART3. |
mbed_official | 155:8435094ec241 | 1295 | * @param NewState: new state of the Smart Card mode. |
mbed_official | 155:8435094ec241 | 1296 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 1297 | * @retval None |
mbed_official | 155:8435094ec241 | 1298 | */ |
mbed_official | 155:8435094ec241 | 1299 | void USART_SmartCardCmd(USART_TypeDef* USARTx, FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 1300 | { |
mbed_official | 155:8435094ec241 | 1301 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 1302 | assert_param(IS_USART_123_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 1303 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 1304 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 1305 | { |
mbed_official | 155:8435094ec241 | 1306 | /* Enable the SC mode by setting the SCEN bit in the CR3 register */ |
mbed_official | 155:8435094ec241 | 1307 | USARTx->CR3 |= USART_CR3_SCEN; |
mbed_official | 155:8435094ec241 | 1308 | } |
mbed_official | 155:8435094ec241 | 1309 | else |
mbed_official | 155:8435094ec241 | 1310 | { |
mbed_official | 155:8435094ec241 | 1311 | /* Disable the SC mode by clearing the SCEN bit in the CR3 register */ |
mbed_official | 155:8435094ec241 | 1312 | USARTx->CR3 &= (uint32_t)~((uint32_t)USART_CR3_SCEN); |
mbed_official | 155:8435094ec241 | 1313 | } |
mbed_official | 155:8435094ec241 | 1314 | } |
mbed_official | 155:8435094ec241 | 1315 | |
mbed_official | 155:8435094ec241 | 1316 | /** |
mbed_official | 155:8435094ec241 | 1317 | * @brief Enables or disables NACK transmission. |
mbed_official | 155:8435094ec241 | 1318 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 1319 | * following values: USART1 or USART2 or USART3. |
mbed_official | 155:8435094ec241 | 1320 | * @param NewState: new state of the NACK transmission. |
mbed_official | 155:8435094ec241 | 1321 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 1322 | * @retval None |
mbed_official | 155:8435094ec241 | 1323 | */ |
mbed_official | 155:8435094ec241 | 1324 | void USART_SmartCardNACKCmd(USART_TypeDef* USARTx, FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 1325 | { |
mbed_official | 155:8435094ec241 | 1326 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 1327 | assert_param(IS_USART_123_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 1328 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 1329 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 1330 | { |
mbed_official | 155:8435094ec241 | 1331 | /* Enable the NACK transmission by setting the NACK bit in the CR3 register */ |
mbed_official | 155:8435094ec241 | 1332 | USARTx->CR3 |= USART_CR3_NACK; |
mbed_official | 155:8435094ec241 | 1333 | } |
mbed_official | 155:8435094ec241 | 1334 | else |
mbed_official | 155:8435094ec241 | 1335 | { |
mbed_official | 155:8435094ec241 | 1336 | /* Disable the NACK transmission by clearing the NACK bit in the CR3 register */ |
mbed_official | 155:8435094ec241 | 1337 | USARTx->CR3 &= (uint32_t)~((uint32_t)USART_CR3_NACK); |
mbed_official | 155:8435094ec241 | 1338 | } |
mbed_official | 155:8435094ec241 | 1339 | } |
mbed_official | 155:8435094ec241 | 1340 | |
mbed_official | 155:8435094ec241 | 1341 | /** |
mbed_official | 155:8435094ec241 | 1342 | * @brief Sets the Smart Card number of retries in transmit and receive. |
mbed_official | 155:8435094ec241 | 1343 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 1344 | * following values: USART1 or USART2 or USART3. |
mbed_official | 155:8435094ec241 | 1345 | * @param USART_AutoCount: specifies the Smart Card auto retry count. |
mbed_official | 155:8435094ec241 | 1346 | * @retval None |
mbed_official | 155:8435094ec241 | 1347 | */ |
mbed_official | 155:8435094ec241 | 1348 | void USART_SetAutoRetryCount(USART_TypeDef* USARTx, uint8_t USART_AutoCount) |
mbed_official | 155:8435094ec241 | 1349 | { |
mbed_official | 155:8435094ec241 | 1350 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 1351 | assert_param(IS_USART_123_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 1352 | assert_param(IS_USART_AUTO_RETRY_COUNTER(USART_AutoCount)); |
mbed_official | 155:8435094ec241 | 1353 | /* Clear the USART auto retry count */ |
mbed_official | 155:8435094ec241 | 1354 | USARTx->CR3 &= (uint32_t)~((uint32_t)USART_CR3_SCARCNT); |
mbed_official | 155:8435094ec241 | 1355 | /* Set the USART auto retry count*/ |
mbed_official | 155:8435094ec241 | 1356 | USARTx->CR3 |= (uint32_t)((uint32_t)USART_AutoCount << 0x11); |
mbed_official | 155:8435094ec241 | 1357 | } |
mbed_official | 155:8435094ec241 | 1358 | |
mbed_official | 155:8435094ec241 | 1359 | /** |
mbed_official | 155:8435094ec241 | 1360 | * @brief Sets the Smart Card Block length. |
mbed_official | 155:8435094ec241 | 1361 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 1362 | * following values: USART1 or USART2 or USART3. |
mbed_official | 155:8435094ec241 | 1363 | * @param USART_BlockLength: specifies the Smart Card block length. |
mbed_official | 155:8435094ec241 | 1364 | * @retval None |
mbed_official | 155:8435094ec241 | 1365 | */ |
mbed_official | 155:8435094ec241 | 1366 | void USART_SetBlockLength(USART_TypeDef* USARTx, uint8_t USART_BlockLength) |
mbed_official | 155:8435094ec241 | 1367 | { |
mbed_official | 155:8435094ec241 | 1368 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 1369 | assert_param(IS_USART_123_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 1370 | |
mbed_official | 155:8435094ec241 | 1371 | /* Clear the Smart card block length */ |
mbed_official | 155:8435094ec241 | 1372 | USARTx->RTOR &= (uint32_t)~((uint32_t)USART_RTOR_BLEN); |
mbed_official | 155:8435094ec241 | 1373 | /* Set the Smart Card block length */ |
mbed_official | 155:8435094ec241 | 1374 | USARTx->RTOR |= (uint32_t)((uint32_t)USART_BlockLength << 0x18); |
mbed_official | 155:8435094ec241 | 1375 | } |
mbed_official | 155:8435094ec241 | 1376 | |
mbed_official | 155:8435094ec241 | 1377 | /** |
mbed_official | 155:8435094ec241 | 1378 | * @} |
mbed_official | 155:8435094ec241 | 1379 | */ |
mbed_official | 155:8435094ec241 | 1380 | |
mbed_official | 155:8435094ec241 | 1381 | /** @defgroup USART_Group9 IrDA mode functions |
mbed_official | 155:8435094ec241 | 1382 | * @brief IrDA mode functions |
mbed_official | 155:8435094ec241 | 1383 | * |
mbed_official | 155:8435094ec241 | 1384 | @verbatim |
mbed_official | 155:8435094ec241 | 1385 | =============================================================================== |
mbed_official | 155:8435094ec241 | 1386 | ##### IrDA mode functions ##### |
mbed_official | 155:8435094ec241 | 1387 | =============================================================================== |
mbed_official | 155:8435094ec241 | 1388 | [..] This subsection provides a set of functions allowing to manage the USART |
mbed_official | 155:8435094ec241 | 1389 | IrDA communication. |
mbed_official | 155:8435094ec241 | 1390 | [..] IrDA is a half duplex communication protocol. If the Transmitter is busy, |
mbed_official | 155:8435094ec241 | 1391 | any data on the IrDA receive line will be ignored by the IrDA decoder |
mbed_official | 155:8435094ec241 | 1392 | and if the Receiver is busy, data on the TX from the USART to IrDA will |
mbed_official | 155:8435094ec241 | 1393 | not be encoded by IrDA. While receiving data, transmission should be |
mbed_official | 155:8435094ec241 | 1394 | avoided as the data to be transmitted could be corrupted. |
mbed_official | 155:8435094ec241 | 1395 | [..] IrDA communication is possible through the following procedure: |
mbed_official | 155:8435094ec241 | 1396 | (#) Program the Baud rate, Word length = 8 bits, Stop bits, Parity, |
mbed_official | 155:8435094ec241 | 1397 | Transmitter/Receiver modes and hardware flow control values using |
mbed_official | 155:8435094ec241 | 1398 | the USART_Init() function. |
mbed_official | 155:8435094ec241 | 1399 | (#) Configures the IrDA pulse width by configuring the prescaler using |
mbed_official | 155:8435094ec241 | 1400 | the USART_SetPrescaler() function. |
mbed_official | 155:8435094ec241 | 1401 | (#) Configures the IrDA USART_IrDAMode_LowPower or USART_IrDAMode_Normal |
mbed_official | 155:8435094ec241 | 1402 | mode using the USART_IrDAConfig() function. |
mbed_official | 155:8435094ec241 | 1403 | (#) Enable the IrDA using the USART_IrDACmd() function. |
mbed_official | 155:8435094ec241 | 1404 | (#) Enable the USART using the USART_Cmd() function. |
mbed_official | 155:8435094ec241 | 1405 | [..] |
mbed_official | 155:8435094ec241 | 1406 | (@) A pulse of width less than two and greater than one PSC period(s) may or |
mbed_official | 155:8435094ec241 | 1407 | may not be rejected. |
mbed_official | 155:8435094ec241 | 1408 | (@) The receiver set up time should be managed by software. The IrDA physical |
mbed_official | 155:8435094ec241 | 1409 | layer specification specifies a minimum of 10 ms delay between |
mbed_official | 155:8435094ec241 | 1410 | transmission and reception (IrDA is a half duplex protocol). |
mbed_official | 155:8435094ec241 | 1411 | (@) In IrDA mode, the following bits must be kept cleared: |
mbed_official | 155:8435094ec241 | 1412 | (+@) LINEN, STOP and CLKEN bits in the USART_CR2 register. |
mbed_official | 155:8435094ec241 | 1413 | (+@) SCEN and HDSEL bits in the USART_CR3 register. |
mbed_official | 155:8435094ec241 | 1414 | |
mbed_official | 155:8435094ec241 | 1415 | @endverbatim |
mbed_official | 155:8435094ec241 | 1416 | * @{ |
mbed_official | 155:8435094ec241 | 1417 | */ |
mbed_official | 155:8435094ec241 | 1418 | |
mbed_official | 155:8435094ec241 | 1419 | /** |
mbed_official | 155:8435094ec241 | 1420 | * @brief Configures the USART's IrDA interface. |
mbed_official | 155:8435094ec241 | 1421 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 1422 | * following values: USART1 or USART2 or USART3 or UART4 or UART5. |
mbed_official | 155:8435094ec241 | 1423 | * @param USART_IrDAMode: specifies the IrDA mode. |
mbed_official | 155:8435094ec241 | 1424 | * This parameter can be one of the following values: |
mbed_official | 155:8435094ec241 | 1425 | * @arg USART_IrDAMode_LowPower |
mbed_official | 155:8435094ec241 | 1426 | * @arg USART_IrDAMode_Normal |
mbed_official | 155:8435094ec241 | 1427 | * @retval None |
mbed_official | 155:8435094ec241 | 1428 | */ |
mbed_official | 155:8435094ec241 | 1429 | void USART_IrDAConfig(USART_TypeDef* USARTx, uint32_t USART_IrDAMode) |
mbed_official | 155:8435094ec241 | 1430 | { |
mbed_official | 155:8435094ec241 | 1431 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 1432 | assert_param(IS_USART_ALL_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 1433 | assert_param(IS_USART_IRDA_MODE(USART_IrDAMode)); |
mbed_official | 155:8435094ec241 | 1434 | |
mbed_official | 155:8435094ec241 | 1435 | USARTx->CR3 &= (uint32_t)~((uint32_t)USART_CR3_IRLP); |
mbed_official | 155:8435094ec241 | 1436 | USARTx->CR3 |= USART_IrDAMode; |
mbed_official | 155:8435094ec241 | 1437 | } |
mbed_official | 155:8435094ec241 | 1438 | |
mbed_official | 155:8435094ec241 | 1439 | /** |
mbed_official | 155:8435094ec241 | 1440 | * @brief Enables or disables the USART's IrDA interface. |
mbed_official | 155:8435094ec241 | 1441 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 1442 | * following values: USART1 or USART2 or USART3 or UART4 or UART5. |
mbed_official | 155:8435094ec241 | 1443 | * @param NewState: new state of the IrDA mode. |
mbed_official | 155:8435094ec241 | 1444 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 1445 | * @retval None |
mbed_official | 155:8435094ec241 | 1446 | */ |
mbed_official | 155:8435094ec241 | 1447 | void USART_IrDACmd(USART_TypeDef* USARTx, FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 1448 | { |
mbed_official | 155:8435094ec241 | 1449 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 1450 | assert_param(IS_USART_ALL_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 1451 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 1452 | |
mbed_official | 155:8435094ec241 | 1453 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 1454 | { |
mbed_official | 155:8435094ec241 | 1455 | /* Enable the IrDA mode by setting the IREN bit in the CR3 register */ |
mbed_official | 155:8435094ec241 | 1456 | USARTx->CR3 |= USART_CR3_IREN; |
mbed_official | 155:8435094ec241 | 1457 | } |
mbed_official | 155:8435094ec241 | 1458 | else |
mbed_official | 155:8435094ec241 | 1459 | { |
mbed_official | 155:8435094ec241 | 1460 | /* Disable the IrDA mode by clearing the IREN bit in the CR3 register */ |
mbed_official | 155:8435094ec241 | 1461 | USARTx->CR3 &= (uint32_t)~((uint32_t)USART_CR3_IREN); |
mbed_official | 155:8435094ec241 | 1462 | } |
mbed_official | 155:8435094ec241 | 1463 | } |
mbed_official | 155:8435094ec241 | 1464 | /** |
mbed_official | 155:8435094ec241 | 1465 | * @} |
mbed_official | 155:8435094ec241 | 1466 | */ |
mbed_official | 155:8435094ec241 | 1467 | |
mbed_official | 155:8435094ec241 | 1468 | /** @defgroup USART_Group10 RS485 mode function |
mbed_official | 155:8435094ec241 | 1469 | * @brief RS485 mode function |
mbed_official | 155:8435094ec241 | 1470 | * |
mbed_official | 155:8435094ec241 | 1471 | @verbatim |
mbed_official | 155:8435094ec241 | 1472 | =============================================================================== |
mbed_official | 155:8435094ec241 | 1473 | ##### RS485 mode functions ##### |
mbed_official | 155:8435094ec241 | 1474 | =============================================================================== |
mbed_official | 155:8435094ec241 | 1475 | [..] This subsection provides a set of functions allowing to manage the USART |
mbed_official | 155:8435094ec241 | 1476 | RS485 flow control. |
mbed_official | 155:8435094ec241 | 1477 | [..] RS485 flow control (Driver enable feature) handling is possible through |
mbed_official | 155:8435094ec241 | 1478 | the following procedure: |
mbed_official | 155:8435094ec241 | 1479 | (#) Program the Baud rate, Word length = 8 bits, Stop bits, Parity, |
mbed_official | 155:8435094ec241 | 1480 | Transmitter/Receiver modes and hardware flow control values using |
mbed_official | 155:8435094ec241 | 1481 | the USART_Init() function. |
mbed_official | 155:8435094ec241 | 1482 | (#) Enable the Driver Enable using the USART_DECmd() function. |
mbed_official | 155:8435094ec241 | 1483 | (#) Configures the Driver Enable polarity using the USART_DEPolarityConfig() |
mbed_official | 155:8435094ec241 | 1484 | function. |
mbed_official | 155:8435094ec241 | 1485 | (#) Configures the Driver Enable assertion time using USART_SetDEAssertionTime() |
mbed_official | 155:8435094ec241 | 1486 | function and deassertion time using the USART_SetDEDeassertionTime() |
mbed_official | 155:8435094ec241 | 1487 | function. |
mbed_official | 155:8435094ec241 | 1488 | (#) Enable the USART using the USART_Cmd() function. |
mbed_official | 155:8435094ec241 | 1489 | [..] |
mbed_official | 155:8435094ec241 | 1490 | (@) The assertion and dessertion times are expressed in sample time units (1/8 or |
mbed_official | 155:8435094ec241 | 1491 | 1/16 bit time, depending on the oversampling rate). |
mbed_official | 155:8435094ec241 | 1492 | |
mbed_official | 155:8435094ec241 | 1493 | @endverbatim |
mbed_official | 155:8435094ec241 | 1494 | * @{ |
mbed_official | 155:8435094ec241 | 1495 | */ |
mbed_official | 155:8435094ec241 | 1496 | |
mbed_official | 155:8435094ec241 | 1497 | /** |
mbed_official | 155:8435094ec241 | 1498 | * @brief Enables or disables the USART's DE functionality. |
mbed_official | 155:8435094ec241 | 1499 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 1500 | * following values: USART1 or USART2 or USART3 or UART4 or UART5. |
mbed_official | 155:8435094ec241 | 1501 | * @param NewState: new state of the driver enable mode. |
mbed_official | 155:8435094ec241 | 1502 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 1503 | * @retval None |
mbed_official | 155:8435094ec241 | 1504 | */ |
mbed_official | 155:8435094ec241 | 1505 | void USART_DECmd(USART_TypeDef* USARTx, FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 1506 | { |
mbed_official | 155:8435094ec241 | 1507 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 1508 | assert_param(IS_USART_ALL_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 1509 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 1510 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 1511 | { |
mbed_official | 155:8435094ec241 | 1512 | /* Enable the DE functionality by setting the DEM bit in the CR3 register */ |
mbed_official | 155:8435094ec241 | 1513 | USARTx->CR3 |= USART_CR3_DEM; |
mbed_official | 155:8435094ec241 | 1514 | } |
mbed_official | 155:8435094ec241 | 1515 | else |
mbed_official | 155:8435094ec241 | 1516 | { |
mbed_official | 155:8435094ec241 | 1517 | /* Disable the DE functionality by clearing the DEM bit in the CR3 register */ |
mbed_official | 155:8435094ec241 | 1518 | USARTx->CR3 &= (uint32_t)~((uint32_t)USART_CR3_DEM); |
mbed_official | 155:8435094ec241 | 1519 | } |
mbed_official | 155:8435094ec241 | 1520 | } |
mbed_official | 155:8435094ec241 | 1521 | |
mbed_official | 155:8435094ec241 | 1522 | /** |
mbed_official | 155:8435094ec241 | 1523 | * @brief Configures the USART's DE polarity |
mbed_official | 155:8435094ec241 | 1524 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 1525 | * following values: USART1 or USART2 or USART3 or UART4 or UART5. |
mbed_official | 155:8435094ec241 | 1526 | * @param USART_DEPolarity: specifies the DE polarity. |
mbed_official | 155:8435094ec241 | 1527 | * This parameter can be one of the following values: |
mbed_official | 155:8435094ec241 | 1528 | * @arg USART_DEPolarity_Low |
mbed_official | 155:8435094ec241 | 1529 | * @arg USART_DEPolarity_High |
mbed_official | 155:8435094ec241 | 1530 | * @retval None |
mbed_official | 155:8435094ec241 | 1531 | */ |
mbed_official | 155:8435094ec241 | 1532 | void USART_DEPolarityConfig(USART_TypeDef* USARTx, uint32_t USART_DEPolarity) |
mbed_official | 155:8435094ec241 | 1533 | { |
mbed_official | 155:8435094ec241 | 1534 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 1535 | assert_param(IS_USART_ALL_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 1536 | assert_param(IS_USART_DE_POLARITY(USART_DEPolarity)); |
mbed_official | 155:8435094ec241 | 1537 | |
mbed_official | 155:8435094ec241 | 1538 | USARTx->CR3 &= (uint32_t)~((uint32_t)USART_CR3_DEP); |
mbed_official | 155:8435094ec241 | 1539 | USARTx->CR3 |= USART_DEPolarity; |
mbed_official | 155:8435094ec241 | 1540 | } |
mbed_official | 155:8435094ec241 | 1541 | |
mbed_official | 155:8435094ec241 | 1542 | /** |
mbed_official | 155:8435094ec241 | 1543 | * @brief Sets the specified RS485 DE assertion time |
mbed_official | 155:8435094ec241 | 1544 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 1545 | * following values: USART1 or USART2 or USART3 or UART4 or UART5. |
mbed_official | 155:8435094ec241 | 1546 | * @param USART_AssertionTime: specifies the time between the activation of the DE |
mbed_official | 155:8435094ec241 | 1547 | * signal and the beginning of the start bit |
mbed_official | 155:8435094ec241 | 1548 | * @retval None |
mbed_official | 155:8435094ec241 | 1549 | */ |
mbed_official | 155:8435094ec241 | 1550 | void USART_SetDEAssertionTime(USART_TypeDef* USARTx, uint32_t USART_DEAssertionTime) |
mbed_official | 155:8435094ec241 | 1551 | { |
mbed_official | 155:8435094ec241 | 1552 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 1553 | assert_param(IS_USART_ALL_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 1554 | assert_param(IS_USART_DE_ASSERTION_DEASSERTION_TIME(USART_DEAssertionTime)); |
mbed_official | 155:8435094ec241 | 1555 | |
mbed_official | 155:8435094ec241 | 1556 | /* Clear the DE assertion time */ |
mbed_official | 155:8435094ec241 | 1557 | USARTx->CR1 &= (uint32_t)~((uint32_t)USART_CR1_DEAT); |
mbed_official | 155:8435094ec241 | 1558 | /* Set the new value for the DE assertion time */ |
mbed_official | 155:8435094ec241 | 1559 | USARTx->CR1 |=((uint32_t)USART_DEAssertionTime << (uint32_t)0x15); |
mbed_official | 155:8435094ec241 | 1560 | } |
mbed_official | 155:8435094ec241 | 1561 | |
mbed_official | 155:8435094ec241 | 1562 | /** |
mbed_official | 155:8435094ec241 | 1563 | * @brief Sets the specified RS485 DE deassertion time |
mbed_official | 155:8435094ec241 | 1564 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 1565 | * following values: USART1 or USART2 or USART3 or UART4 or UART5. |
mbed_official | 155:8435094ec241 | 1566 | * @param USART_DeassertionTime: specifies the time between the middle of the last |
mbed_official | 155:8435094ec241 | 1567 | * stop bit in a transmitted message and the de-activation of the DE signal |
mbed_official | 155:8435094ec241 | 1568 | * @retval None |
mbed_official | 155:8435094ec241 | 1569 | */ |
mbed_official | 155:8435094ec241 | 1570 | void USART_SetDEDeassertionTime(USART_TypeDef* USARTx, uint32_t USART_DEDeassertionTime) |
mbed_official | 155:8435094ec241 | 1571 | { |
mbed_official | 155:8435094ec241 | 1572 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 1573 | assert_param(IS_USART_ALL_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 1574 | assert_param(IS_USART_DE_ASSERTION_DEASSERTION_TIME(USART_DEDeassertionTime)); |
mbed_official | 155:8435094ec241 | 1575 | |
mbed_official | 155:8435094ec241 | 1576 | /* Clear the DE deassertion time */ |
mbed_official | 155:8435094ec241 | 1577 | USARTx->CR1 &= (uint32_t)~((uint32_t)USART_CR1_DEDT); |
mbed_official | 155:8435094ec241 | 1578 | /* Set the new value for the DE deassertion time */ |
mbed_official | 155:8435094ec241 | 1579 | USARTx->CR1 |=((uint32_t)USART_DEDeassertionTime << (uint32_t)0x10); |
mbed_official | 155:8435094ec241 | 1580 | } |
mbed_official | 155:8435094ec241 | 1581 | |
mbed_official | 155:8435094ec241 | 1582 | /** |
mbed_official | 155:8435094ec241 | 1583 | * @} |
mbed_official | 155:8435094ec241 | 1584 | */ |
mbed_official | 155:8435094ec241 | 1585 | |
mbed_official | 155:8435094ec241 | 1586 | /** @defgroup USART_Group11 DMA transfers management functions |
mbed_official | 155:8435094ec241 | 1587 | * @brief DMA transfers management functions |
mbed_official | 155:8435094ec241 | 1588 | * |
mbed_official | 155:8435094ec241 | 1589 | @verbatim |
mbed_official | 155:8435094ec241 | 1590 | =============================================================================== |
mbed_official | 155:8435094ec241 | 1591 | ##### DMA transfers management functions ##### |
mbed_official | 155:8435094ec241 | 1592 | =============================================================================== |
mbed_official | 155:8435094ec241 | 1593 | [..] This section provides two functions that can be used only in DMA mode. |
mbed_official | 155:8435094ec241 | 1594 | [..] In DMA Mode, the USART communication can be managed by 2 DMA Channel |
mbed_official | 155:8435094ec241 | 1595 | requests: |
mbed_official | 155:8435094ec241 | 1596 | (#) USART_DMAReq_Tx: specifies the Tx buffer DMA transfer request. |
mbed_official | 155:8435094ec241 | 1597 | (#) USART_DMAReq_Rx: specifies the Rx buffer DMA transfer request. |
mbed_official | 155:8435094ec241 | 1598 | [..] In this Mode it is advised to use the following function: |
mbed_official | 155:8435094ec241 | 1599 | (+) void USART_DMACmd(USART_TypeDef* USARTx, uint16_t USART_DMAReq, |
mbed_official | 155:8435094ec241 | 1600 | FunctionalState NewState). |
mbed_official | 155:8435094ec241 | 1601 | @endverbatim |
mbed_official | 155:8435094ec241 | 1602 | * @{ |
mbed_official | 155:8435094ec241 | 1603 | */ |
mbed_official | 155:8435094ec241 | 1604 | |
mbed_official | 155:8435094ec241 | 1605 | /** |
mbed_official | 155:8435094ec241 | 1606 | * @brief Enables or disables the USART's DMA interface. |
mbed_official | 155:8435094ec241 | 1607 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 1608 | * following values: USART1 or USART2 or USART3 or UART4. |
mbed_official | 155:8435094ec241 | 1609 | * @param USART_DMAReq: specifies the DMA request. |
mbed_official | 155:8435094ec241 | 1610 | * This parameter can be any combination of the following values: |
mbed_official | 155:8435094ec241 | 1611 | * @arg USART_DMAReq_Tx: USART DMA transmit request |
mbed_official | 155:8435094ec241 | 1612 | * @arg USART_DMAReq_Rx: USART DMA receive request |
mbed_official | 155:8435094ec241 | 1613 | * @param NewState: new state of the DMA Request sources. |
mbed_official | 155:8435094ec241 | 1614 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 1615 | * @retval None |
mbed_official | 155:8435094ec241 | 1616 | */ |
mbed_official | 155:8435094ec241 | 1617 | void USART_DMACmd(USART_TypeDef* USARTx, uint32_t USART_DMAReq, FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 1618 | { |
mbed_official | 155:8435094ec241 | 1619 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 1620 | assert_param(IS_USART_1234_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 1621 | assert_param(IS_USART_DMAREQ(USART_DMAReq)); |
mbed_official | 155:8435094ec241 | 1622 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 1623 | |
mbed_official | 155:8435094ec241 | 1624 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 1625 | { |
mbed_official | 155:8435094ec241 | 1626 | /* Enable the DMA transfer for selected requests by setting the DMAT and/or |
mbed_official | 155:8435094ec241 | 1627 | DMAR bits in the USART CR3 register */ |
mbed_official | 155:8435094ec241 | 1628 | USARTx->CR3 |= USART_DMAReq; |
mbed_official | 155:8435094ec241 | 1629 | } |
mbed_official | 155:8435094ec241 | 1630 | else |
mbed_official | 155:8435094ec241 | 1631 | { |
mbed_official | 155:8435094ec241 | 1632 | /* Disable the DMA transfer for selected requests by clearing the DMAT and/or |
mbed_official | 155:8435094ec241 | 1633 | DMAR bits in the USART CR3 register */ |
mbed_official | 155:8435094ec241 | 1634 | USARTx->CR3 &= (uint32_t)~USART_DMAReq; |
mbed_official | 155:8435094ec241 | 1635 | } |
mbed_official | 155:8435094ec241 | 1636 | } |
mbed_official | 155:8435094ec241 | 1637 | |
mbed_official | 155:8435094ec241 | 1638 | /** |
mbed_official | 155:8435094ec241 | 1639 | * @brief Enables or disables the USART's DMA interface when reception error occurs. |
mbed_official | 155:8435094ec241 | 1640 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 1641 | * following values: USART1 or USART2 or USART3 or UART4. |
mbed_official | 155:8435094ec241 | 1642 | * @param USART_DMAOnError: specifies the DMA status in case of reception error. |
mbed_official | 155:8435094ec241 | 1643 | * This parameter can be any combination of the following values: |
mbed_official | 155:8435094ec241 | 1644 | * @arg USART_DMAOnError_Enable: DMA receive request enabled when the USART DMA |
mbed_official | 155:8435094ec241 | 1645 | * reception error is asserted. |
mbed_official | 155:8435094ec241 | 1646 | * @arg USART_DMAOnError_Disable: DMA receive request disabled when the USART DMA |
mbed_official | 155:8435094ec241 | 1647 | * reception error is asserted. |
mbed_official | 155:8435094ec241 | 1648 | * @retval None |
mbed_official | 155:8435094ec241 | 1649 | */ |
mbed_official | 155:8435094ec241 | 1650 | void USART_DMAReceptionErrorConfig(USART_TypeDef* USARTx, uint32_t USART_DMAOnError) |
mbed_official | 155:8435094ec241 | 1651 | { |
mbed_official | 155:8435094ec241 | 1652 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 1653 | assert_param(IS_USART_1234_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 1654 | assert_param(IS_USART_DMAONERROR(USART_DMAOnError)); |
mbed_official | 155:8435094ec241 | 1655 | |
mbed_official | 155:8435094ec241 | 1656 | /* Clear the DMA Reception error detection bit */ |
mbed_official | 155:8435094ec241 | 1657 | USARTx->CR3 &= (uint32_t)~((uint32_t)USART_CR3_DDRE); |
mbed_official | 155:8435094ec241 | 1658 | /* Set the new value for the DMA Reception error detection bit */ |
mbed_official | 155:8435094ec241 | 1659 | USARTx->CR3 |= USART_DMAOnError; |
mbed_official | 155:8435094ec241 | 1660 | } |
mbed_official | 155:8435094ec241 | 1661 | |
mbed_official | 155:8435094ec241 | 1662 | /** |
mbed_official | 155:8435094ec241 | 1663 | * @} |
mbed_official | 155:8435094ec241 | 1664 | */ |
mbed_official | 155:8435094ec241 | 1665 | |
mbed_official | 155:8435094ec241 | 1666 | /** @defgroup USART_Group12 Interrupts and flags management functions |
mbed_official | 155:8435094ec241 | 1667 | * @brief Interrupts and flags management functions |
mbed_official | 155:8435094ec241 | 1668 | * |
mbed_official | 155:8435094ec241 | 1669 | @verbatim |
mbed_official | 155:8435094ec241 | 1670 | =============================================================================== |
mbed_official | 155:8435094ec241 | 1671 | ##### Interrupts and flags management functions ##### |
mbed_official | 155:8435094ec241 | 1672 | =============================================================================== |
mbed_official | 155:8435094ec241 | 1673 | [..] This subsection provides a set of functions allowing to configure the |
mbed_official | 155:8435094ec241 | 1674 | USART Interrupts sources, Requests and check or clear the flags or pending bits status. |
mbed_official | 155:8435094ec241 | 1675 | The user should identify which mode will be used in his application to |
mbed_official | 155:8435094ec241 | 1676 | manage the communication: Polling mode, Interrupt mode. |
mbed_official | 155:8435094ec241 | 1677 | |
mbed_official | 155:8435094ec241 | 1678 | *** Polling Mode *** |
mbed_official | 155:8435094ec241 | 1679 | ==================== |
mbed_official | 155:8435094ec241 | 1680 | [..] In Polling Mode, the SPI communication can be managed by these flags: |
mbed_official | 155:8435094ec241 | 1681 | (#) USART_FLAG_REACK: to indicate the status of the Receive Enable |
mbed_official | 155:8435094ec241 | 1682 | acknowledge flag |
mbed_official | 155:8435094ec241 | 1683 | (#) USART_FLAG_TEACK: to indicate the status of the Transmit Enable |
mbed_official | 155:8435094ec241 | 1684 | acknowledge flag. |
mbed_official | 155:8435094ec241 | 1685 | (#) USART_FLAG_WUF: to indicate the status of the Wake up flag. |
mbed_official | 155:8435094ec241 | 1686 | (#) USART_FLAG_RWU: to indicate the status of the Receive Wake up flag. |
mbed_official | 155:8435094ec241 | 1687 | (#) USART_FLAG_SBK: to indicate the status of the Send Break flag. |
mbed_official | 155:8435094ec241 | 1688 | (#) USART_FLAG_CMF: to indicate the status of the Character match flag. |
mbed_official | 155:8435094ec241 | 1689 | (#) USART_FLAG_BUSY: to indicate the status of the Busy flag. |
mbed_official | 155:8435094ec241 | 1690 | (#) USART_FLAG_ABRF: to indicate the status of the Auto baud rate flag. |
mbed_official | 155:8435094ec241 | 1691 | (#) USART_FLAG_ABRE: to indicate the status of the Auto baud rate error flag. |
mbed_official | 155:8435094ec241 | 1692 | (#) USART_FLAG_EOBF: to indicate the status of the End of block flag. |
mbed_official | 155:8435094ec241 | 1693 | (#) USART_FLAG_RTOF: to indicate the status of the Receive time out flag. |
mbed_official | 155:8435094ec241 | 1694 | (#) USART_FLAG_nCTSS: to indicate the status of the Inverted nCTS input |
mbed_official | 155:8435094ec241 | 1695 | bit status. |
mbed_official | 155:8435094ec241 | 1696 | (#) USART_FLAG_TXE: to indicate the status of the transmit buffer register. |
mbed_official | 155:8435094ec241 | 1697 | (#) USART_FLAG_RXNE: to indicate the status of the receive buffer register. |
mbed_official | 155:8435094ec241 | 1698 | (#) USART_FLAG_TC: to indicate the status of the transmit operation. |
mbed_official | 155:8435094ec241 | 1699 | (#) USART_FLAG_IDLE: to indicate the status of the Idle Line. |
mbed_official | 155:8435094ec241 | 1700 | (#) USART_FLAG_CTS: to indicate the status of the nCTS input. |
mbed_official | 155:8435094ec241 | 1701 | (#) USART_FLAG_LBD: to indicate the status of the LIN break detection. |
mbed_official | 155:8435094ec241 | 1702 | (#) USART_FLAG_NE: to indicate if a noise error occur. |
mbed_official | 155:8435094ec241 | 1703 | (#) USART_FLAG_FE: to indicate if a frame error occur. |
mbed_official | 155:8435094ec241 | 1704 | (#) USART_FLAG_PE: to indicate if a parity error occur. |
mbed_official | 155:8435094ec241 | 1705 | (#) USART_FLAG_ORE: to indicate if an Overrun error occur. |
mbed_official | 155:8435094ec241 | 1706 | [..] In this Mode it is advised to use the following functions: |
mbed_official | 155:8435094ec241 | 1707 | (+) FlagStatus USART_GetFlagStatus(USART_TypeDef* USARTx, uint16_t USART_FLAG). |
mbed_official | 155:8435094ec241 | 1708 | (+) void USART_ClearFlag(USART_TypeDef* USARTx, uint16_t USART_FLAG). |
mbed_official | 155:8435094ec241 | 1709 | |
mbed_official | 155:8435094ec241 | 1710 | *** Interrupt Mode *** |
mbed_official | 155:8435094ec241 | 1711 | ====================== |
mbed_official | 155:8435094ec241 | 1712 | [..] In Interrupt Mode, the USART communication can be managed by 8 interrupt |
mbed_official | 155:8435094ec241 | 1713 | sources and 10 pending bits: |
mbed_official | 155:8435094ec241 | 1714 | (+) Pending Bits: |
mbed_official | 155:8435094ec241 | 1715 | (##) USART_IT_WU: to indicate the status of the Wake up interrupt. |
mbed_official | 155:8435094ec241 | 1716 | (##) USART_IT_CM: to indicate the status of Character match interrupt. |
mbed_official | 155:8435094ec241 | 1717 | (##) USART_IT_EOB: to indicate the status of End of block interrupt. |
mbed_official | 155:8435094ec241 | 1718 | (##) USART_IT_RTO: to indicate the status of Receive time out interrupt. |
mbed_official | 155:8435094ec241 | 1719 | (##) USART_IT_CTS: to indicate the status of CTS change interrupt. |
mbed_official | 155:8435094ec241 | 1720 | (##) USART_IT_LBD: to indicate the status of LIN Break detection interrupt. |
mbed_official | 155:8435094ec241 | 1721 | (##) USART_IT_TC: to indicate the status of Transmission complete interrupt. |
mbed_official | 155:8435094ec241 | 1722 | (##) USART_IT_IDLE: to indicate the status of IDLE line detected interrupt. |
mbed_official | 155:8435094ec241 | 1723 | (##) USART_IT_ORE: to indicate the status of OverRun Error interrupt. |
mbed_official | 155:8435094ec241 | 1724 | (##) USART_IT_NE: to indicate the status of Noise Error interrupt. |
mbed_official | 155:8435094ec241 | 1725 | (##) USART_IT_FE: to indicate the status of Framing Error interrupt. |
mbed_official | 155:8435094ec241 | 1726 | (##) USART_IT_PE: to indicate the status of Parity Error interrupt. |
mbed_official | 155:8435094ec241 | 1727 | |
mbed_official | 155:8435094ec241 | 1728 | (+) Interrupt Source: |
mbed_official | 155:8435094ec241 | 1729 | (##) USART_IT_WU: specifies the interrupt source for Wake up interrupt. |
mbed_official | 155:8435094ec241 | 1730 | (##) USART_IT_CM: specifies the interrupt source for Character match |
mbed_official | 155:8435094ec241 | 1731 | interrupt. |
mbed_official | 155:8435094ec241 | 1732 | (##) USART_IT_EOB: specifies the interrupt source for End of block |
mbed_official | 155:8435094ec241 | 1733 | interrupt. |
mbed_official | 155:8435094ec241 | 1734 | (##) USART_IT_RTO: specifies the interrupt source for Receive time-out |
mbed_official | 155:8435094ec241 | 1735 | interrupt. |
mbed_official | 155:8435094ec241 | 1736 | (##) USART_IT_CTS: specifies the interrupt source for CTS change interrupt. |
mbed_official | 155:8435094ec241 | 1737 | (##) USART_IT_LBD: specifies the interrupt source for LIN Break |
mbed_official | 155:8435094ec241 | 1738 | detection interrupt. |
mbed_official | 155:8435094ec241 | 1739 | (##) USART_IT_TXE: specifies the interrupt source for Tansmit Data |
mbed_official | 155:8435094ec241 | 1740 | Register empty interrupt. |
mbed_official | 155:8435094ec241 | 1741 | (##) USART_IT_TC: specifies the interrupt source for Transmission |
mbed_official | 155:8435094ec241 | 1742 | complete interrupt. |
mbed_official | 155:8435094ec241 | 1743 | (##) USART_IT_RXNE: specifies the interrupt source for Receive Data |
mbed_official | 155:8435094ec241 | 1744 | register not empty interrupt. |
mbed_official | 155:8435094ec241 | 1745 | (##) USART_IT_IDLE: specifies the interrupt source for Idle line |
mbed_official | 155:8435094ec241 | 1746 | detection interrupt. |
mbed_official | 155:8435094ec241 | 1747 | (##) USART_IT_PE: specifies the interrupt source for Parity Error interrupt. |
mbed_official | 155:8435094ec241 | 1748 | (##) USART_IT_ERR: specifies the interrupt source for Error interrupt |
mbed_official | 155:8435094ec241 | 1749 | (Frame error, noise error, overrun error) |
mbed_official | 155:8435094ec241 | 1750 | -@@- Some parameters are coded in order to use them as interrupt |
mbed_official | 155:8435094ec241 | 1751 | source or as pending bits. |
mbed_official | 155:8435094ec241 | 1752 | [..] In this Mode it is advised to use the following functions: |
mbed_official | 155:8435094ec241 | 1753 | (+) void USART_ITConfig(USART_TypeDef* USARTx, uint16_t USART_IT, FunctionalState NewState). |
mbed_official | 155:8435094ec241 | 1754 | (+) ITStatus USART_GetITStatus(USART_TypeDef* USARTx, uint16_t USART_IT). |
mbed_official | 155:8435094ec241 | 1755 | (+) void USART_ClearITPendingBit(USART_TypeDef* USARTx, uint16_t USART_IT). |
mbed_official | 155:8435094ec241 | 1756 | |
mbed_official | 155:8435094ec241 | 1757 | @endverbatim |
mbed_official | 155:8435094ec241 | 1758 | * @{ |
mbed_official | 155:8435094ec241 | 1759 | */ |
mbed_official | 155:8435094ec241 | 1760 | |
mbed_official | 155:8435094ec241 | 1761 | /** |
mbed_official | 155:8435094ec241 | 1762 | * @brief Enables or disables the specified USART interrupts. |
mbed_official | 155:8435094ec241 | 1763 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 1764 | * following values: USART1 or USART2 or USART3 or UART4 or UART5. |
mbed_official | 155:8435094ec241 | 1765 | * @param USART_IT: specifies the USART interrupt sources to be enabled or disabled. |
mbed_official | 155:8435094ec241 | 1766 | * This parameter can be one of the following values: |
mbed_official | 155:8435094ec241 | 1767 | * @arg USART_IT_WU: Wake up interrupt. |
mbed_official | 155:8435094ec241 | 1768 | * @arg USART_IT_CM: Character match interrupt. |
mbed_official | 155:8435094ec241 | 1769 | * @arg USART_IT_EOB: End of block interrupt. |
mbed_official | 155:8435094ec241 | 1770 | * @arg USART_IT_RTO: Receive time out interrupt. |
mbed_official | 155:8435094ec241 | 1771 | * @arg USART_IT_CTS: CTS change interrupt. |
mbed_official | 155:8435094ec241 | 1772 | * @arg USART_IT_LBD: LIN Break detection interrupt. |
mbed_official | 155:8435094ec241 | 1773 | * @arg USART_IT_TXE: Tansmit Data Register empty interrupt. |
mbed_official | 155:8435094ec241 | 1774 | * @arg USART_IT_TC: Transmission complete interrupt. |
mbed_official | 155:8435094ec241 | 1775 | * @arg USART_IT_RXNE: Receive Data register not empty interrupt. |
mbed_official | 155:8435094ec241 | 1776 | * @arg USART_IT_IDLE: Idle line detection interrupt. |
mbed_official | 155:8435094ec241 | 1777 | * @arg USART_IT_PE: Parity Error interrupt. |
mbed_official | 155:8435094ec241 | 1778 | * @arg USART_IT_ERR: Error interrupt(Frame error, noise error, overrun error) |
mbed_official | 155:8435094ec241 | 1779 | * @param NewState: new state of the specified USARTx interrupts. |
mbed_official | 155:8435094ec241 | 1780 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 1781 | * @retval None |
mbed_official | 155:8435094ec241 | 1782 | */ |
mbed_official | 155:8435094ec241 | 1783 | void USART_ITConfig(USART_TypeDef* USARTx, uint32_t USART_IT, FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 1784 | { |
mbed_official | 155:8435094ec241 | 1785 | uint32_t usartreg = 0, itpos = 0, itmask = 0; |
mbed_official | 155:8435094ec241 | 1786 | uint32_t usartxbase = 0; |
mbed_official | 155:8435094ec241 | 1787 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 1788 | assert_param(IS_USART_ALL_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 1789 | assert_param(IS_USART_CONFIG_IT(USART_IT)); |
mbed_official | 155:8435094ec241 | 1790 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 1791 | |
mbed_official | 155:8435094ec241 | 1792 | usartxbase = (uint32_t)USARTx; |
mbed_official | 155:8435094ec241 | 1793 | |
mbed_official | 155:8435094ec241 | 1794 | /* Get the USART register index */ |
mbed_official | 155:8435094ec241 | 1795 | usartreg = (((uint16_t)USART_IT) >> 0x08); |
mbed_official | 155:8435094ec241 | 1796 | |
mbed_official | 155:8435094ec241 | 1797 | /* Get the interrupt position */ |
mbed_official | 155:8435094ec241 | 1798 | itpos = USART_IT & IT_MASK; |
mbed_official | 155:8435094ec241 | 1799 | itmask = (((uint32_t)0x01) << itpos); |
mbed_official | 155:8435094ec241 | 1800 | |
mbed_official | 155:8435094ec241 | 1801 | if (usartreg == 0x02) /* The IT is in CR2 register */ |
mbed_official | 155:8435094ec241 | 1802 | { |
mbed_official | 155:8435094ec241 | 1803 | usartxbase += 0x04; |
mbed_official | 155:8435094ec241 | 1804 | } |
mbed_official | 155:8435094ec241 | 1805 | else if (usartreg == 0x03) /* The IT is in CR3 register */ |
mbed_official | 155:8435094ec241 | 1806 | { |
mbed_official | 155:8435094ec241 | 1807 | usartxbase += 0x08; |
mbed_official | 155:8435094ec241 | 1808 | } |
mbed_official | 155:8435094ec241 | 1809 | else /* The IT is in CR1 register */ |
mbed_official | 155:8435094ec241 | 1810 | { |
mbed_official | 155:8435094ec241 | 1811 | } |
mbed_official | 155:8435094ec241 | 1812 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 1813 | { |
mbed_official | 155:8435094ec241 | 1814 | *(__IO uint32_t*)usartxbase |= itmask; |
mbed_official | 155:8435094ec241 | 1815 | } |
mbed_official | 155:8435094ec241 | 1816 | else |
mbed_official | 155:8435094ec241 | 1817 | { |
mbed_official | 155:8435094ec241 | 1818 | *(__IO uint32_t*)usartxbase &= ~itmask; |
mbed_official | 155:8435094ec241 | 1819 | } |
mbed_official | 155:8435094ec241 | 1820 | } |
mbed_official | 155:8435094ec241 | 1821 | |
mbed_official | 155:8435094ec241 | 1822 | /** |
mbed_official | 155:8435094ec241 | 1823 | * @brief Enables the specified USART's Request. |
mbed_official | 155:8435094ec241 | 1824 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 1825 | * following values: USART1 or USART2 or USART3 or UART4 or UART5. |
mbed_official | 155:8435094ec241 | 1826 | * @param USART_Request: specifies the USART request. |
mbed_official | 155:8435094ec241 | 1827 | * This parameter can be any combination of the following values: |
mbed_official | 155:8435094ec241 | 1828 | * @arg USART_Request_TXFRQ: Transmit data flush ReQuest |
mbed_official | 155:8435094ec241 | 1829 | * @arg USART_Request_RXFRQ: Receive data flush ReQuest |
mbed_official | 155:8435094ec241 | 1830 | * @arg USART_Request_MMRQ: Mute Mode ReQuest |
mbed_official | 155:8435094ec241 | 1831 | * @arg USART_Request_SBKRQ: Send Break ReQuest |
mbed_official | 155:8435094ec241 | 1832 | * @arg USART_Request_ABRRQ: Auto Baud Rate ReQuest |
mbed_official | 155:8435094ec241 | 1833 | * @param NewState: new state of the DMA interface when reception error occurs. |
mbed_official | 155:8435094ec241 | 1834 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 1835 | * @retval None |
mbed_official | 155:8435094ec241 | 1836 | */ |
mbed_official | 155:8435094ec241 | 1837 | void USART_RequestCmd(USART_TypeDef* USARTx, uint32_t USART_Request, FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 1838 | { |
mbed_official | 155:8435094ec241 | 1839 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 1840 | assert_param(IS_USART_ALL_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 1841 | assert_param(IS_USART_REQUEST(USART_Request)); |
mbed_official | 155:8435094ec241 | 1842 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 1843 | |
mbed_official | 155:8435094ec241 | 1844 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 1845 | { |
mbed_official | 155:8435094ec241 | 1846 | /* Enable the USART ReQuest by setting the dedicated request bit in the RQR |
mbed_official | 155:8435094ec241 | 1847 | register.*/ |
mbed_official | 155:8435094ec241 | 1848 | USARTx->RQR |= USART_Request; |
mbed_official | 155:8435094ec241 | 1849 | } |
mbed_official | 155:8435094ec241 | 1850 | else |
mbed_official | 155:8435094ec241 | 1851 | { |
mbed_official | 155:8435094ec241 | 1852 | /* Disable the USART ReQuest by clearing the dedicated request bit in the RQR |
mbed_official | 155:8435094ec241 | 1853 | register.*/ |
mbed_official | 155:8435094ec241 | 1854 | USARTx->RQR &= (uint32_t)~USART_Request; |
mbed_official | 155:8435094ec241 | 1855 | } |
mbed_official | 155:8435094ec241 | 1856 | } |
mbed_official | 155:8435094ec241 | 1857 | |
mbed_official | 155:8435094ec241 | 1858 | /** |
mbed_official | 155:8435094ec241 | 1859 | * @brief Enables or disables the USART's Overrun detection. |
mbed_official | 155:8435094ec241 | 1860 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 1861 | * following values: USART1 or USART2 or USART3 or UART4 or UART5. |
mbed_official | 155:8435094ec241 | 1862 | * @param USART_OVRDetection: specifies the OVR detection status in case of OVR error. |
mbed_official | 155:8435094ec241 | 1863 | * This parameter can be any combination of the following values: |
mbed_official | 155:8435094ec241 | 1864 | * @arg USART_OVRDetection_Enable: OVR error detection enabled when the USART OVR error |
mbed_official | 155:8435094ec241 | 1865 | * is asserted. |
mbed_official | 155:8435094ec241 | 1866 | * @arg USART_OVRDetection_Disable: OVR error detection disabled when the USART OVR error |
mbed_official | 155:8435094ec241 | 1867 | * is asserted. |
mbed_official | 155:8435094ec241 | 1868 | * @retval None |
mbed_official | 155:8435094ec241 | 1869 | */ |
mbed_official | 155:8435094ec241 | 1870 | void USART_OverrunDetectionConfig(USART_TypeDef* USARTx, uint32_t USART_OVRDetection) |
mbed_official | 155:8435094ec241 | 1871 | { |
mbed_official | 155:8435094ec241 | 1872 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 1873 | assert_param(IS_USART_ALL_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 1874 | assert_param(IS_USART_OVRDETECTION(USART_OVRDetection)); |
mbed_official | 155:8435094ec241 | 1875 | |
mbed_official | 155:8435094ec241 | 1876 | /* Clear the OVR detection bit */ |
mbed_official | 155:8435094ec241 | 1877 | USARTx->CR3 &= (uint32_t)~((uint32_t)USART_CR3_OVRDIS); |
mbed_official | 155:8435094ec241 | 1878 | /* Set the new value for the OVR detection bit */ |
mbed_official | 155:8435094ec241 | 1879 | USARTx->CR3 |= USART_OVRDetection; |
mbed_official | 155:8435094ec241 | 1880 | } |
mbed_official | 155:8435094ec241 | 1881 | |
mbed_official | 155:8435094ec241 | 1882 | /** |
mbed_official | 155:8435094ec241 | 1883 | * @brief Checks whether the specified USART flag is set or not. |
mbed_official | 155:8435094ec241 | 1884 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 1885 | * following values: USART1 or USART2 or USART3 or UART4 or UART5. |
mbed_official | 155:8435094ec241 | 1886 | * @param USART_FLAG: specifies the flag to check. |
mbed_official | 155:8435094ec241 | 1887 | * This parameter can be one of the following values: |
mbed_official | 155:8435094ec241 | 1888 | * @arg USART_FLAG_REACK: Receive Enable acknowledge flag. |
mbed_official | 155:8435094ec241 | 1889 | * @arg USART_FLAG_TEACK: Transmit Enable acknowledge flag. |
mbed_official | 155:8435094ec241 | 1890 | * @arg USART_FLAG_WUF: Wake up flag. |
mbed_official | 155:8435094ec241 | 1891 | * @arg USART_FLAG_RWU: Receive Wake up flag. |
mbed_official | 155:8435094ec241 | 1892 | * @arg USART_FLAG_SBK: Send Break flag. |
mbed_official | 155:8435094ec241 | 1893 | * @arg USART_FLAG_CMF: Character match flag. |
mbed_official | 155:8435094ec241 | 1894 | * @arg USART_FLAG_BUSY: Busy flag. |
mbed_official | 155:8435094ec241 | 1895 | * @arg USART_FLAG_ABRF: Auto baud rate flag. |
mbed_official | 155:8435094ec241 | 1896 | * @arg USART_FLAG_ABRE: Auto baud rate error flag. |
mbed_official | 155:8435094ec241 | 1897 | * @arg USART_FLAG_EOBF: End of block flag. |
mbed_official | 155:8435094ec241 | 1898 | * @arg USART_FLAG_RTOF: Receive time out flag. |
mbed_official | 155:8435094ec241 | 1899 | * @arg USART_FLAG_nCTSS: Inverted nCTS input bit status. |
mbed_official | 155:8435094ec241 | 1900 | * @arg USART_FLAG_CTS: CTS Change flag. |
mbed_official | 155:8435094ec241 | 1901 | * @arg USART_FLAG_LBD: LIN Break detection flag. |
mbed_official | 155:8435094ec241 | 1902 | * @arg USART_FLAG_TXE: Transmit data register empty flag. |
mbed_official | 155:8435094ec241 | 1903 | * @arg USART_FLAG_TC: Transmission Complete flag. |
mbed_official | 155:8435094ec241 | 1904 | * @arg USART_FLAG_RXNE: Receive data register not empty flag. |
mbed_official | 155:8435094ec241 | 1905 | * @arg USART_FLAG_IDLE: Idle Line detection flag. |
mbed_official | 155:8435094ec241 | 1906 | * @arg USART_FLAG_ORE: OverRun Error flag. |
mbed_official | 155:8435094ec241 | 1907 | * @arg USART_FLAG_NE: Noise Error flag. |
mbed_official | 155:8435094ec241 | 1908 | * @arg USART_FLAG_FE: Framing Error flag. |
mbed_official | 155:8435094ec241 | 1909 | * @arg USART_FLAG_PE: Parity Error flag. |
mbed_official | 155:8435094ec241 | 1910 | * @retval The new state of USART_FLAG (SET or RESET). |
mbed_official | 155:8435094ec241 | 1911 | */ |
mbed_official | 155:8435094ec241 | 1912 | FlagStatus USART_GetFlagStatus(USART_TypeDef* USARTx, uint32_t USART_FLAG) |
mbed_official | 155:8435094ec241 | 1913 | { |
mbed_official | 155:8435094ec241 | 1914 | FlagStatus bitstatus = RESET; |
mbed_official | 155:8435094ec241 | 1915 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 1916 | assert_param(IS_USART_ALL_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 1917 | assert_param(IS_USART_FLAG(USART_FLAG)); |
mbed_official | 155:8435094ec241 | 1918 | |
mbed_official | 155:8435094ec241 | 1919 | if ((USARTx->ISR & USART_FLAG) != (uint16_t)RESET) |
mbed_official | 155:8435094ec241 | 1920 | { |
mbed_official | 155:8435094ec241 | 1921 | bitstatus = SET; |
mbed_official | 155:8435094ec241 | 1922 | } |
mbed_official | 155:8435094ec241 | 1923 | else |
mbed_official | 155:8435094ec241 | 1924 | { |
mbed_official | 155:8435094ec241 | 1925 | bitstatus = RESET; |
mbed_official | 155:8435094ec241 | 1926 | } |
mbed_official | 155:8435094ec241 | 1927 | return bitstatus; |
mbed_official | 155:8435094ec241 | 1928 | } |
mbed_official | 155:8435094ec241 | 1929 | |
mbed_official | 155:8435094ec241 | 1930 | /** |
mbed_official | 155:8435094ec241 | 1931 | * @brief Clears the USARTx's pending flags. |
mbed_official | 155:8435094ec241 | 1932 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 1933 | * following values: USART1 or USART2 or USART3 or UART4 or UART5. |
mbed_official | 155:8435094ec241 | 1934 | * @param USART_FLAG: specifies the flag to clear. |
mbed_official | 155:8435094ec241 | 1935 | * This parameter can be any combination of the following values: |
mbed_official | 155:8435094ec241 | 1936 | * @arg USART_FLAG_WUF: Wake up flag. |
mbed_official | 155:8435094ec241 | 1937 | * @arg USART_FLAG_CMF: Character match flag. |
mbed_official | 155:8435094ec241 | 1938 | * @arg USART_FLAG_EOBF: End of block flag. |
mbed_official | 155:8435094ec241 | 1939 | * @arg USART_FLAG_RTOF: Receive time out flag. |
mbed_official | 155:8435094ec241 | 1940 | * @arg USART_FLAG_CTS: CTS Change flag. |
mbed_official | 155:8435094ec241 | 1941 | * @arg USART_FLAG_LBD: LIN Break detection flag. |
mbed_official | 155:8435094ec241 | 1942 | * @arg USART_FLAG_TC: Transmission Complete flag. |
mbed_official | 155:8435094ec241 | 1943 | * @arg USART_FLAG_IDLE: IDLE line detected flag. |
mbed_official | 155:8435094ec241 | 1944 | * @arg USART_FLAG_ORE: OverRun Error flag. |
mbed_official | 155:8435094ec241 | 1945 | * @arg USART_FLAG_NE: Noise Error flag. |
mbed_official | 155:8435094ec241 | 1946 | * @arg USART_FLAG_FE: Framing Error flag. |
mbed_official | 155:8435094ec241 | 1947 | * @arg USART_FLAG_PE: Parity Errorflag. |
mbed_official | 155:8435094ec241 | 1948 | * |
mbed_official | 155:8435094ec241 | 1949 | * @note |
mbed_official | 155:8435094ec241 | 1950 | * - RXNE pending bit is cleared by a read to the USART_RDR register |
mbed_official | 155:8435094ec241 | 1951 | * (USART_ReceiveData()) or by writing 1 to the RXFRQ in the register USART_RQR |
mbed_official | 155:8435094ec241 | 1952 | * (USART_RequestCmd()). |
mbed_official | 155:8435094ec241 | 1953 | * - TC flag can be also cleared by software sequence: a read operation to |
mbed_official | 155:8435094ec241 | 1954 | * USART_SR register (USART_GetFlagStatus()) followed by a write operation |
mbed_official | 155:8435094ec241 | 1955 | * to USART_TDR register (USART_SendData()). |
mbed_official | 155:8435094ec241 | 1956 | * - TXE flag is cleared by a write to the USART_TDR register |
mbed_official | 155:8435094ec241 | 1957 | * (USART_SendData()) or by writing 1 to the TXFRQ in the register USART_RQR |
mbed_official | 155:8435094ec241 | 1958 | * (USART_RequestCmd()). |
mbed_official | 155:8435094ec241 | 1959 | * - SBKF flag is cleared by 1 to the SBKRQ in the register USART_RQR |
mbed_official | 155:8435094ec241 | 1960 | * (USART_RequestCmd()). |
mbed_official | 155:8435094ec241 | 1961 | * @retval None |
mbed_official | 155:8435094ec241 | 1962 | */ |
mbed_official | 155:8435094ec241 | 1963 | void USART_ClearFlag(USART_TypeDef* USARTx, uint32_t USART_FLAG) |
mbed_official | 155:8435094ec241 | 1964 | { |
mbed_official | 155:8435094ec241 | 1965 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 1966 | assert_param(IS_USART_ALL_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 1967 | assert_param(IS_USART_CLEAR_FLAG(USART_FLAG)); |
mbed_official | 155:8435094ec241 | 1968 | |
mbed_official | 155:8435094ec241 | 1969 | USARTx->ICR = USART_FLAG; |
mbed_official | 155:8435094ec241 | 1970 | } |
mbed_official | 155:8435094ec241 | 1971 | |
mbed_official | 155:8435094ec241 | 1972 | /** |
mbed_official | 155:8435094ec241 | 1973 | * @brief Checks whether the specified USART interrupt has occurred or not. |
mbed_official | 155:8435094ec241 | 1974 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 1975 | * following values: USART1 or USART2 or USART3 or UART4 or UART5. |
mbed_official | 155:8435094ec241 | 1976 | * @param USART_IT: specifies the USART interrupt source to check. |
mbed_official | 155:8435094ec241 | 1977 | * This parameter can be one of the following values: |
mbed_official | 155:8435094ec241 | 1978 | * @arg USART_IT_WU: Wake up interrupt. |
mbed_official | 155:8435094ec241 | 1979 | * @arg USART_IT_CM: Character match interrupt. |
mbed_official | 155:8435094ec241 | 1980 | * @arg USART_IT_EOB: End of block interrupt. |
mbed_official | 155:8435094ec241 | 1981 | * @arg USART_IT_RTO: Receive time out interrupt. |
mbed_official | 155:8435094ec241 | 1982 | * @arg USART_IT_CTS: CTS change interrupt. |
mbed_official | 155:8435094ec241 | 1983 | * @arg USART_IT_LBD: LIN Break detection interrupt. |
mbed_official | 155:8435094ec241 | 1984 | * @arg USART_IT_TXE: Tansmit Data Register empty interrupt. |
mbed_official | 155:8435094ec241 | 1985 | * @arg USART_IT_TC: Transmission complete interrupt. |
mbed_official | 155:8435094ec241 | 1986 | * @arg USART_IT_RXNE: Receive Data register not empty interrupt. |
mbed_official | 155:8435094ec241 | 1987 | * @arg USART_IT_IDLE: Idle line detection interrupt. |
mbed_official | 155:8435094ec241 | 1988 | * @arg USART_IT_ORE: OverRun Error interrupt. |
mbed_official | 155:8435094ec241 | 1989 | * @arg USART_IT_NE: Noise Error interrupt. |
mbed_official | 155:8435094ec241 | 1990 | * @arg USART_IT_FE: Framing Error interrupt. |
mbed_official | 155:8435094ec241 | 1991 | * @arg USART_IT_PE: Parity Error interrupt. |
mbed_official | 155:8435094ec241 | 1992 | * @retval The new state of USART_IT (SET or RESET). |
mbed_official | 155:8435094ec241 | 1993 | */ |
mbed_official | 155:8435094ec241 | 1994 | ITStatus USART_GetITStatus(USART_TypeDef* USARTx, uint32_t USART_IT) |
mbed_official | 155:8435094ec241 | 1995 | { |
mbed_official | 155:8435094ec241 | 1996 | uint32_t bitpos = 0, itmask = 0, usartreg = 0; |
mbed_official | 155:8435094ec241 | 1997 | ITStatus bitstatus = RESET; |
mbed_official | 155:8435094ec241 | 1998 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 1999 | assert_param(IS_USART_ALL_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 2000 | assert_param(IS_USART_GET_IT(USART_IT)); |
mbed_official | 155:8435094ec241 | 2001 | |
mbed_official | 155:8435094ec241 | 2002 | /* Get the USART register index */ |
mbed_official | 155:8435094ec241 | 2003 | usartreg = (((uint16_t)USART_IT) >> 0x08); |
mbed_official | 155:8435094ec241 | 2004 | /* Get the interrupt position */ |
mbed_official | 155:8435094ec241 | 2005 | itmask = USART_IT & IT_MASK; |
mbed_official | 155:8435094ec241 | 2006 | itmask = (uint32_t)0x01 << itmask; |
mbed_official | 155:8435094ec241 | 2007 | |
mbed_official | 155:8435094ec241 | 2008 | if (usartreg == 0x01) /* The IT is in CR1 register */ |
mbed_official | 155:8435094ec241 | 2009 | { |
mbed_official | 155:8435094ec241 | 2010 | itmask &= USARTx->CR1; |
mbed_official | 155:8435094ec241 | 2011 | } |
mbed_official | 155:8435094ec241 | 2012 | else if (usartreg == 0x02) /* The IT is in CR2 register */ |
mbed_official | 155:8435094ec241 | 2013 | { |
mbed_official | 155:8435094ec241 | 2014 | itmask &= USARTx->CR2; |
mbed_official | 155:8435094ec241 | 2015 | } |
mbed_official | 155:8435094ec241 | 2016 | else /* The IT is in CR3 register */ |
mbed_official | 155:8435094ec241 | 2017 | { |
mbed_official | 155:8435094ec241 | 2018 | itmask &= USARTx->CR3; |
mbed_official | 155:8435094ec241 | 2019 | } |
mbed_official | 155:8435094ec241 | 2020 | |
mbed_official | 155:8435094ec241 | 2021 | bitpos = USART_IT >> 0x10; |
mbed_official | 155:8435094ec241 | 2022 | bitpos = (uint32_t)0x01 << bitpos; |
mbed_official | 155:8435094ec241 | 2023 | bitpos &= USARTx->ISR; |
mbed_official | 155:8435094ec241 | 2024 | if ((itmask != (uint16_t)RESET)&&(bitpos != (uint16_t)RESET)) |
mbed_official | 155:8435094ec241 | 2025 | { |
mbed_official | 155:8435094ec241 | 2026 | bitstatus = SET; |
mbed_official | 155:8435094ec241 | 2027 | } |
mbed_official | 155:8435094ec241 | 2028 | else |
mbed_official | 155:8435094ec241 | 2029 | { |
mbed_official | 155:8435094ec241 | 2030 | bitstatus = RESET; |
mbed_official | 155:8435094ec241 | 2031 | } |
mbed_official | 155:8435094ec241 | 2032 | |
mbed_official | 155:8435094ec241 | 2033 | return bitstatus; |
mbed_official | 155:8435094ec241 | 2034 | } |
mbed_official | 155:8435094ec241 | 2035 | |
mbed_official | 155:8435094ec241 | 2036 | /** |
mbed_official | 155:8435094ec241 | 2037 | * @brief Clears the USARTx's interrupt pending bits. |
mbed_official | 155:8435094ec241 | 2038 | * @param USARTx: Select the USART peripheral. This parameter can be one of the |
mbed_official | 155:8435094ec241 | 2039 | * following values: USART1 or USART2 or USART3 or UART4 or UART5. |
mbed_official | 155:8435094ec241 | 2040 | * @param USART_IT: specifies the interrupt pending bit to clear. |
mbed_official | 155:8435094ec241 | 2041 | * This parameter can be one of the following values: |
mbed_official | 155:8435094ec241 | 2042 | * @arg USART_IT_WU: Wake up interrupt. |
mbed_official | 155:8435094ec241 | 2043 | * @arg USART_IT_CM: Character match interrupt. |
mbed_official | 155:8435094ec241 | 2044 | * @arg USART_IT_EOB: End of block interrupt. |
mbed_official | 155:8435094ec241 | 2045 | * @arg USART_IT_RTO: Receive time out interrupt. |
mbed_official | 155:8435094ec241 | 2046 | * @arg USART_IT_CTS: CTS change interrupt. |
mbed_official | 155:8435094ec241 | 2047 | * @arg USART_IT_LBD: LIN Break detection interrupt. |
mbed_official | 155:8435094ec241 | 2048 | * @arg USART_IT_TC: Transmission complete interrupt. |
mbed_official | 155:8435094ec241 | 2049 | * @arg USART_IT_IDLE: IDLE line detected interrupt. |
mbed_official | 155:8435094ec241 | 2050 | * @arg USART_IT_ORE: OverRun Error interrupt. |
mbed_official | 155:8435094ec241 | 2051 | * @arg USART_IT_NE: Noise Error interrupt. |
mbed_official | 155:8435094ec241 | 2052 | * @arg USART_IT_FE: Framing Error interrupt. |
mbed_official | 155:8435094ec241 | 2053 | * @arg USART_IT_PE: Parity Error interrupt. |
mbed_official | 155:8435094ec241 | 2054 | * @note |
mbed_official | 155:8435094ec241 | 2055 | * - RXNE pending bit is cleared by a read to the USART_RDR register |
mbed_official | 155:8435094ec241 | 2056 | * (USART_ReceiveData()) or by writing 1 to the RXFRQ in the register USART_RQR |
mbed_official | 155:8435094ec241 | 2057 | * (USART_RequestCmd()). |
mbed_official | 155:8435094ec241 | 2058 | * - TC pending bit can be also cleared by software sequence: a read |
mbed_official | 155:8435094ec241 | 2059 | * operation to USART_SR register (USART_GetITStatus()) followed by a write |
mbed_official | 155:8435094ec241 | 2060 | * operation to USART_TDR register (USART_SendData()). |
mbed_official | 155:8435094ec241 | 2061 | * - TXE pending bit is cleared by a write to the USART_TDR register |
mbed_official | 155:8435094ec241 | 2062 | * (USART_SendData()) or by writing 1 to the TXFRQ in the register USART_RQR |
mbed_official | 155:8435094ec241 | 2063 | * (USART_RequestCmd()). |
mbed_official | 155:8435094ec241 | 2064 | * @retval None |
mbed_official | 155:8435094ec241 | 2065 | */ |
mbed_official | 155:8435094ec241 | 2066 | void USART_ClearITPendingBit(USART_TypeDef* USARTx, uint32_t USART_IT) |
mbed_official | 155:8435094ec241 | 2067 | { |
mbed_official | 155:8435094ec241 | 2068 | uint32_t bitpos = 0, itmask = 0; |
mbed_official | 155:8435094ec241 | 2069 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 2070 | assert_param(IS_USART_ALL_PERIPH(USARTx)); |
mbed_official | 155:8435094ec241 | 2071 | assert_param(IS_USART_CLEAR_IT(USART_IT)); |
mbed_official | 155:8435094ec241 | 2072 | |
mbed_official | 155:8435094ec241 | 2073 | bitpos = USART_IT >> 0x10; |
mbed_official | 155:8435094ec241 | 2074 | itmask = ((uint32_t)0x01 << (uint32_t)bitpos); |
mbed_official | 155:8435094ec241 | 2075 | USARTx->ICR = (uint32_t)itmask; |
mbed_official | 155:8435094ec241 | 2076 | } |
mbed_official | 155:8435094ec241 | 2077 | |
mbed_official | 155:8435094ec241 | 2078 | /** |
mbed_official | 155:8435094ec241 | 2079 | * @} |
mbed_official | 155:8435094ec241 | 2080 | */ |
mbed_official | 155:8435094ec241 | 2081 | |
mbed_official | 155:8435094ec241 | 2082 | /** |
mbed_official | 155:8435094ec241 | 2083 | * @} |
mbed_official | 155:8435094ec241 | 2084 | */ |
mbed_official | 155:8435094ec241 | 2085 | |
mbed_official | 155:8435094ec241 | 2086 | /** |
mbed_official | 155:8435094ec241 | 2087 | * @} |
mbed_official | 155:8435094ec241 | 2088 | */ |
mbed_official | 155:8435094ec241 | 2089 | |
mbed_official | 155:8435094ec241 | 2090 | /** |
mbed_official | 155:8435094ec241 | 2091 | * @} |
mbed_official | 155:8435094ec241 | 2092 | */ |
mbed_official | 155:8435094ec241 | 2093 | |
mbed_official | 155:8435094ec241 | 2094 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |