Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Space_Invaders_Demo neopixels gpio_test_stm32f3_discovery gpio_test_systimer ... more
stm32f30x_usart.h
00001 /** 00002 ****************************************************************************** 00003 * @file stm32f30x_usart.h 00004 * @author MCD Application Team 00005 * @version V1.2.3 00006 * @date 10-July-2015 00007 * @brief This file contains all the functions prototypes for the USART 00008 * firmware library. 00009 ****************************************************************************** 00010 * @attention 00011 * 00012 * <h2><center>© COPYRIGHT 2015 STMicroelectronics</center></h2> 00013 * 00014 * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 00015 * You may not use this file except in compliance with the License. 00016 * You may obtain a copy of the License at: 00017 * 00018 * http://www.st.com/software_license_agreement_liberty_v2 00019 * 00020 * Unless required by applicable law or agreed to in writing, software 00021 * distributed under the License is distributed on an "AS IS" BASIS, 00022 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00023 * See the License for the specific language governing permissions and 00024 * limitations under the License. 00025 * 00026 ****************************************************************************** 00027 */ 00028 00029 /* Define to prevent recursive inclusion -------------------------------------*/ 00030 #ifndef __STM32F30x_USART_H 00031 #define __STM32F30x_USART_H 00032 00033 #ifdef __cplusplus 00034 extern "C" { 00035 #endif 00036 00037 /* Includes ------------------------------------------------------------------*/ 00038 #include "stm32f30x.h" 00039 00040 /** @addtogroup STM32F30x_StdPeriph_Driver 00041 * @{ 00042 */ 00043 00044 /** @addtogroup USART 00045 * @{ 00046 */ 00047 00048 /* Exported types ------------------------------------------------------------*/ 00049 00050 00051 00052 /** 00053 * @brief USART Init Structure definition 00054 */ 00055 00056 typedef struct 00057 { 00058 uint32_t USART_BaudRate; /*!< This member configures the USART communication baud rate. 00059 The baud rate is computed using the following formula: 00060 - IntegerDivider = ((PCLKx) / (16 * (USART_InitStruct->USART_BaudRate))) 00061 - FractionalDivider = ((IntegerDivider - ((uint32_t) IntegerDivider)) * 16) + 0.5 */ 00062 00063 uint32_t USART_WordLength; /*!< Specifies the number of data bits transmitted or received in a frame. 00064 This parameter can be a value of @ref USART_Word_Length */ 00065 00066 uint32_t USART_StopBits; /*!< Specifies the number of stop bits transmitted. 00067 This parameter can be a value of @ref USART_Stop_Bits */ 00068 00069 uint32_t USART_Parity; /*!< Specifies the parity mode. 00070 This parameter can be a value of @ref USART_Parity 00071 @note When parity is enabled, the computed parity is inserted 00072 at the MSB position of the transmitted data (9th bit when 00073 the word length is set to 9 data bits; 8th bit when the 00074 word length is set to 8 data bits). */ 00075 00076 uint32_t USART_Mode; /*!< Specifies whether the Receive or Transmit mode is enabled or disabled. 00077 This parameter can be a value of @ref USART_Mode */ 00078 00079 uint32_t USART_HardwareFlowControl; /*!< Specifies whether the hardware flow control mode is enabled 00080 or disabled. 00081 This parameter can be a value of @ref USART_Hardware_Flow_Control*/ 00082 } USART_InitTypeDef; 00083 00084 /** 00085 * @brief USART Clock Init Structure definition 00086 */ 00087 00088 typedef struct 00089 { 00090 uint32_t USART_Clock; /*!< Specifies whether the USART clock is enabled or disabled. 00091 This parameter can be a value of @ref USART_Clock */ 00092 00093 uint32_t USART_CPOL; /*!< Specifies the steady state of the serial clock. 00094 This parameter can be a value of @ref USART_Clock_Polarity */ 00095 00096 uint32_t USART_CPHA; /*!< Specifies the clock transition on which the bit capture is made. 00097 This parameter can be a value of @ref USART_Clock_Phase */ 00098 00099 uint32_t USART_LastBit; /*!< Specifies whether the clock pulse corresponding to the last transmitted 00100 data bit (MSB) has to be output on the SCLK pin in synchronous mode. 00101 This parameter can be a value of @ref USART_Last_Bit */ 00102 } USART_ClockInitTypeDef; 00103 00104 /* Exported constants --------------------------------------------------------*/ 00105 00106 /** @defgroup USART_Exported_Constants 00107 * @{ 00108 */ 00109 00110 #define IS_USART_ALL_PERIPH(PERIPH) (((PERIPH) == USART1) || \ 00111 ((PERIPH) == USART2) || \ 00112 ((PERIPH) == USART3) || \ 00113 ((PERIPH) == UART4) || \ 00114 ((PERIPH) == UART5)) 00115 00116 #define IS_USART_123_PERIPH(PERIPH) (((PERIPH) == USART1) || \ 00117 ((PERIPH) == USART2) || \ 00118 ((PERIPH) == USART3)) 00119 00120 #define IS_USART_1234_PERIPH(PERIPH) (((PERIPH) == USART1) || \ 00121 ((PERIPH) == USART2) || \ 00122 ((PERIPH) == USART3) || \ 00123 ((PERIPH) == UART4)) 00124 00125 00126 /** @defgroup USART_Word_Length 00127 * @{ 00128 */ 00129 00130 #define USART_WordLength_8b ((uint32_t)0x00000000) 00131 #define USART_WordLength_9b USART_CR1_M 00132 #define IS_USART_WORD_LENGTH(LENGTH) (((LENGTH) == USART_WordLength_8b) || \ 00133 ((LENGTH) == USART_WordLength_9b)) 00134 /** 00135 * @} 00136 */ 00137 00138 /** @defgroup USART_Stop_Bits 00139 * @{ 00140 */ 00141 00142 #define USART_StopBits_1 ((uint32_t)0x00000000) 00143 #define USART_StopBits_2 USART_CR2_STOP_1 00144 #define USART_StopBits_1_5 (USART_CR2_STOP_0 | USART_CR2_STOP_1) 00145 #define IS_USART_STOPBITS(STOPBITS) (((STOPBITS) == USART_StopBits_1) || \ 00146 ((STOPBITS) == USART_StopBits_2) || \ 00147 ((STOPBITS) == USART_StopBits_1_5)) 00148 /** 00149 * @} 00150 */ 00151 00152 /** @defgroup USART_Parity 00153 * @{ 00154 */ 00155 00156 #define USART_Parity_No ((uint32_t)0x00000000) 00157 #define USART_Parity_Even USART_CR1_PCE 00158 #define USART_Parity_Odd (USART_CR1_PCE | USART_CR1_PS) 00159 #define IS_USART_PARITY(PARITY) (((PARITY) == USART_Parity_No) || \ 00160 ((PARITY) == USART_Parity_Even) || \ 00161 ((PARITY) == USART_Parity_Odd)) 00162 /** 00163 * @} 00164 */ 00165 00166 /** @defgroup USART_Mode 00167 * @{ 00168 */ 00169 00170 #define USART_Mode_Rx USART_CR1_RE 00171 #define USART_Mode_Tx USART_CR1_TE 00172 #define IS_USART_MODE(MODE) ((((MODE) & (uint32_t)0xFFFFFFF3) == 0x00) && \ 00173 ((MODE) != (uint32_t)0x00)) 00174 /** 00175 * @} 00176 */ 00177 00178 /** @defgroup USART_Hardware_Flow_Control 00179 * @{ 00180 */ 00181 00182 #define USART_HardwareFlowControl_None ((uint32_t)0x00000000) 00183 #define USART_HardwareFlowControl_RTS USART_CR3_RTSE 00184 #define USART_HardwareFlowControl_CTS USART_CR3_CTSE 00185 #define USART_HardwareFlowControl_RTS_CTS (USART_CR3_RTSE | USART_CR3_CTSE) 00186 #define IS_USART_HARDWARE_FLOW_CONTROL(CONTROL)\ 00187 (((CONTROL) == USART_HardwareFlowControl_None) || \ 00188 ((CONTROL) == USART_HardwareFlowControl_RTS) || \ 00189 ((CONTROL) == USART_HardwareFlowControl_CTS) || \ 00190 ((CONTROL) == USART_HardwareFlowControl_RTS_CTS)) 00191 /** 00192 * @} 00193 */ 00194 00195 /** @defgroup USART_Clock 00196 * @{ 00197 */ 00198 00199 #define USART_Clock_Disable ((uint32_t)0x00000000) 00200 #define USART_Clock_Enable USART_CR2_CLKEN 00201 #define IS_USART_CLOCK(CLOCK) (((CLOCK) == USART_Clock_Disable) || \ 00202 ((CLOCK) == USART_Clock_Enable)) 00203 /** 00204 * @} 00205 */ 00206 00207 /** @defgroup USART_Clock_Polarity 00208 * @{ 00209 */ 00210 00211 #define USART_CPOL_Low ((uint32_t)0x00000000) 00212 #define USART_CPOL_High USART_CR2_CPOL 00213 #define IS_USART_CPOL(CPOL) (((CPOL) == USART_CPOL_Low) || ((CPOL) == USART_CPOL_High)) 00214 00215 /** 00216 * @} 00217 */ 00218 00219 /** @defgroup USART_Clock_Phase 00220 * @{ 00221 */ 00222 00223 #define USART_CPHA_1Edge ((uint32_t)0x00000000) 00224 #define USART_CPHA_2Edge USART_CR2_CPHA 00225 #define IS_USART_CPHA(CPHA) (((CPHA) == USART_CPHA_1Edge) || ((CPHA) == USART_CPHA_2Edge)) 00226 00227 /** 00228 * @} 00229 */ 00230 00231 /** @defgroup USART_Last_Bit 00232 * @{ 00233 */ 00234 00235 #define USART_LastBit_Disable ((uint32_t)0x00000000) 00236 #define USART_LastBit_Enable USART_CR2_LBCL 00237 #define IS_USART_LASTBIT(LASTBIT) (((LASTBIT) == USART_LastBit_Disable) || \ 00238 ((LASTBIT) == USART_LastBit_Enable)) 00239 /** 00240 * @} 00241 */ 00242 00243 /** @defgroup USART_DMA_Requests 00244 * @{ 00245 */ 00246 00247 #define USART_DMAReq_Tx USART_CR3_DMAT 00248 #define USART_DMAReq_Rx USART_CR3_DMAR 00249 #define IS_USART_DMAREQ(DMAREQ) ((((DMAREQ) & (uint32_t)0xFFFFFF3F) == 0x00) && \ 00250 ((DMAREQ) != (uint32_t)0x00)) 00251 00252 /** 00253 * @} 00254 */ 00255 00256 /** @defgroup USART_DMA_Recception_Error 00257 * @{ 00258 */ 00259 00260 #define USART_DMAOnError_Enable ((uint32_t)0x00000000) 00261 #define USART_DMAOnError_Disable USART_CR3_DDRE 00262 #define IS_USART_DMAONERROR(DMAERROR) (((DMAERROR) == USART_DMAOnError_Disable)|| \ 00263 ((DMAERROR) == USART_DMAOnError_Enable)) 00264 /** 00265 * @} 00266 */ 00267 00268 /** @defgroup USART_MuteMode_WakeUp_methods 00269 * @{ 00270 */ 00271 00272 #define USART_WakeUp_IdleLine ((uint32_t)0x00000000) 00273 #define USART_WakeUp_AddressMark USART_CR1_WAKE 00274 #define IS_USART_MUTEMODE_WAKEUP(WAKEUP) (((WAKEUP) == USART_WakeUp_IdleLine) || \ 00275 ((WAKEUP) == USART_WakeUp_AddressMark)) 00276 /** 00277 * @} 00278 */ 00279 00280 /** @defgroup USART_Address_Detection 00281 * @{ 00282 */ 00283 00284 #define USART_AddressLength_4b ((uint32_t)0x00000000) 00285 #define USART_AddressLength_7b USART_CR2_ADDM7 00286 #define IS_USART_ADDRESS_DETECTION(ADDRESS) (((ADDRESS) == USART_AddressLength_4b) || \ 00287 ((ADDRESS) == USART_AddressLength_7b)) 00288 /** 00289 * @} 00290 */ 00291 00292 /** @defgroup USART_StopMode_WakeUp_methods 00293 * @{ 00294 */ 00295 00296 #define USART_WakeUpSource_AddressMatch ((uint32_t)0x00000000) 00297 #define USART_WakeUpSource_StartBit USART_CR3_WUS_1 00298 #define USART_WakeUpSource_RXNE (uint32_t)(USART_CR3_WUS_0 | USART_CR3_WUS_1) 00299 #define IS_USART_STOPMODE_WAKEUPSOURCE(SOURCE) (((SOURCE) == USART_WakeUpSource_AddressMatch) || \ 00300 ((SOURCE) == USART_WakeUpSource_StartBit) || \ 00301 ((SOURCE) == USART_WakeUpSource_RXNE)) 00302 /** 00303 * @} 00304 */ 00305 00306 /** @defgroup USART_LIN_Break_Detection_Length 00307 * @{ 00308 */ 00309 00310 #define USART_LINBreakDetectLength_10b ((uint32_t)0x00000000) 00311 #define USART_LINBreakDetectLength_11b USART_CR2_LBDL 00312 #define IS_USART_LIN_BREAK_DETECT_LENGTH(LENGTH) \ 00313 (((LENGTH) == USART_LINBreakDetectLength_10b) || \ 00314 ((LENGTH) == USART_LINBreakDetectLength_11b)) 00315 /** 00316 * @} 00317 */ 00318 00319 /** @defgroup USART_IrDA_Low_Power 00320 * @{ 00321 */ 00322 00323 #define USART_IrDAMode_LowPower USART_CR3_IRLP 00324 #define USART_IrDAMode_Normal ((uint32_t)0x00000000) 00325 #define IS_USART_IRDA_MODE(MODE) (((MODE) == USART_IrDAMode_LowPower) || \ 00326 ((MODE) == USART_IrDAMode_Normal)) 00327 /** 00328 * @} 00329 */ 00330 00331 /** @defgroup USART_DE_Polarity 00332 * @{ 00333 */ 00334 00335 #define USART_DEPolarity_High ((uint32_t)0x00000000) 00336 #define USART_DEPolarity_Low USART_CR3_DEP 00337 #define IS_USART_DE_POLARITY(POLARITY) (((POLARITY) == USART_DEPolarity_Low) || \ 00338 ((POLARITY) == USART_DEPolarity_High)) 00339 /** 00340 * @} 00341 */ 00342 00343 /** @defgroup USART_Inversion_Pins 00344 * @{ 00345 */ 00346 00347 #define USART_InvPin_Tx USART_CR2_TXINV 00348 #define USART_InvPin_Rx USART_CR2_RXINV 00349 #define IS_USART_INVERSTION_PIN(PIN) ((((PIN) & (uint32_t)0xFFFCFFFF) == 0x00) && \ 00350 ((PIN) != (uint32_t)0x00)) 00351 00352 /** 00353 * @} 00354 */ 00355 00356 /** @defgroup USART_AutoBaudRate_Mode 00357 * @{ 00358 */ 00359 00360 #define USART_AutoBaudRate_StartBit ((uint32_t)0x00000000) 00361 #define USART_AutoBaudRate_FallingEdge USART_CR2_ABRMODE_0 00362 #define USART_AutoBaudRate_0x7FFrame USART_CR2_ABRMODE_1 00363 #define USART_AutoBaudRate_0x55Frame (USART_CR2_ABRMODE_0 | USART_CR2_ABRMODE_1) 00364 #define IS_USART_AUTOBAUDRATE_MODE(MODE) (((MODE) == USART_AutoBaudRate_StartBit) || \ 00365 ((MODE) == USART_AutoBaudRate_FallingEdge) || \ 00366 ((MODE) == USART_AutoBaudRate_0x7FFrame) || \ 00367 ((MODE) == USART_AutoBaudRate_0x55Frame)) 00368 /** 00369 * @} 00370 */ 00371 00372 /** @defgroup USART_OVR_DETECTION 00373 * @{ 00374 */ 00375 00376 #define USART_OVRDetection_Enable ((uint32_t)0x00000000) 00377 #define USART_OVRDetection_Disable USART_CR3_OVRDIS 00378 #define IS_USART_OVRDETECTION(OVR) (((OVR) == USART_OVRDetection_Enable)|| \ 00379 ((OVR) == USART_OVRDetection_Disable)) 00380 /** 00381 * @} 00382 */ 00383 /** @defgroup USART_Request 00384 * @{ 00385 */ 00386 00387 #define USART_Request_ABRRQ USART_RQR_ABRRQ 00388 #define USART_Request_SBKRQ USART_RQR_SBKRQ 00389 #define USART_Request_MMRQ USART_RQR_MMRQ 00390 #define USART_Request_RXFRQ USART_RQR_RXFRQ 00391 #define USART_Request_TXFRQ USART_RQR_TXFRQ 00392 00393 #define IS_USART_REQUEST(REQUEST) (((REQUEST) == USART_Request_TXFRQ) || \ 00394 ((REQUEST) == USART_Request_RXFRQ) || \ 00395 ((REQUEST) == USART_Request_MMRQ) || \ 00396 ((REQUEST) == USART_Request_SBKRQ) || \ 00397 ((REQUEST) == USART_Request_ABRRQ)) 00398 /** 00399 * @} 00400 */ 00401 00402 /** @defgroup USART_Flags 00403 * @{ 00404 */ 00405 #define USART_FLAG_REACK USART_ISR_REACK 00406 #define USART_FLAG_TEACK USART_ISR_TEACK 00407 #define USART_FLAG_WU USART_ISR_WUF 00408 #define USART_FLAG_RWU USART_ISR_RWU 00409 #define USART_FLAG_SBK USART_ISR_SBKF 00410 #define USART_FLAG_CM USART_ISR_CMF 00411 #define USART_FLAG_BUSY USART_ISR_BUSY 00412 #define USART_FLAG_ABRF USART_ISR_ABRF 00413 #define USART_FLAG_ABRE USART_ISR_ABRE 00414 #define USART_FLAG_EOB USART_ISR_EOBF 00415 #define USART_FLAG_RTO USART_ISR_RTOF 00416 #define USART_FLAG_nCTSS USART_ISR_CTS 00417 #define USART_FLAG_CTS USART_ISR_CTSIF 00418 #define USART_FLAG_LBD USART_ISR_LBD 00419 #define USART_FLAG_TXE USART_ISR_TXE 00420 #define USART_FLAG_TC USART_ISR_TC 00421 #define USART_FLAG_RXNE USART_ISR_RXNE 00422 #define USART_FLAG_IDLE USART_ISR_IDLE 00423 #define USART_FLAG_ORE USART_ISR_ORE 00424 #define USART_FLAG_NE USART_ISR_NE 00425 #define USART_FLAG_FE USART_ISR_FE 00426 #define USART_FLAG_PE USART_ISR_PE 00427 #define IS_USART_FLAG(FLAG) (((FLAG) == USART_FLAG_PE) || ((FLAG) == USART_FLAG_TXE) || \ 00428 ((FLAG) == USART_FLAG_TC) || ((FLAG) == USART_FLAG_RXNE) || \ 00429 ((FLAG) == USART_FLAG_IDLE) || ((FLAG) == USART_FLAG_LBD) || \ 00430 ((FLAG) == USART_FLAG_CTS) || ((FLAG) == USART_FLAG_ORE) || \ 00431 ((FLAG) == USART_FLAG_NE) || ((FLAG) == USART_FLAG_FE) || \ 00432 ((FLAG) == USART_FLAG_nCTSS) || ((FLAG) == USART_FLAG_RTO) || \ 00433 ((FLAG) == USART_FLAG_EOB) || ((FLAG) == USART_FLAG_ABRE) || \ 00434 ((FLAG) == USART_FLAG_ABRF) || ((FLAG) == USART_FLAG_BUSY) || \ 00435 ((FLAG) == USART_FLAG_CM) || ((FLAG) == USART_FLAG_SBK) || \ 00436 ((FLAG) == USART_FLAG_RWU) || ((FLAG) == USART_FLAG_WU) || \ 00437 ((FLAG) == USART_FLAG_TEACK)|| ((FLAG) == USART_FLAG_REACK)) 00438 00439 #define IS_USART_CLEAR_FLAG(FLAG) (((FLAG) == USART_FLAG_WU) || ((FLAG) == USART_FLAG_TC) || \ 00440 ((FLAG) == USART_FLAG_IDLE) || ((FLAG) == USART_FLAG_ORE) || \ 00441 ((FLAG) == USART_FLAG_NE) || ((FLAG) == USART_FLAG_FE) || \ 00442 ((FLAG) == USART_FLAG_LBD) || ((FLAG) == USART_FLAG_CTS) || \ 00443 ((FLAG) == USART_FLAG_RTO) || ((FLAG) == USART_FLAG_EOB) || \ 00444 ((FLAG) == USART_FLAG_CM) || ((FLAG) == USART_FLAG_PE)) 00445 /** 00446 * @} 00447 */ 00448 00449 /** @defgroup USART_Interrupt_definition 00450 * @brief USART Interrupt definition 00451 * USART_IT possible values 00452 * Elements values convention: 0xZZZZYYXX 00453 * XX: Position of the corresponding Interrupt 00454 * YY: Register index 00455 * ZZZZ: Flag position 00456 * @{ 00457 */ 00458 00459 #define USART_IT_WU ((uint32_t)0x00140316) 00460 #define USART_IT_CM ((uint32_t)0x0011010E) 00461 #define USART_IT_EOB ((uint32_t)0x000C011B) 00462 #define USART_IT_RTO ((uint32_t)0x000B011A) 00463 #define USART_IT_PE ((uint32_t)0x00000108) 00464 #define USART_IT_TXE ((uint32_t)0x00070107) 00465 #define USART_IT_TC ((uint32_t)0x00060106) 00466 #define USART_IT_RXNE ((uint32_t)0x00050105) 00467 #define USART_IT_IDLE ((uint32_t)0x00040104) 00468 #define USART_IT_LBD ((uint32_t)0x00080206) 00469 #define USART_IT_CTS ((uint32_t)0x0009030A) 00470 #define USART_IT_ERR ((uint32_t)0x00000300) 00471 #define USART_IT_ORE ((uint32_t)0x00030300) 00472 #define USART_IT_NE ((uint32_t)0x00020300) 00473 #define USART_IT_FE ((uint32_t)0x00010300) 00474 00475 #define IS_USART_CONFIG_IT(IT) (((IT) == USART_IT_PE) || ((IT) == USART_IT_TXE) || \ 00476 ((IT) == USART_IT_TC) || ((IT) == USART_IT_RXNE) || \ 00477 ((IT) == USART_IT_IDLE) || ((IT) == USART_IT_LBD) || \ 00478 ((IT) == USART_IT_CTS) || ((IT) == USART_IT_ERR) || \ 00479 ((IT) == USART_IT_RTO) || ((IT) == USART_IT_EOB) || \ 00480 ((IT) == USART_IT_CM) || ((IT) == USART_IT_WU)) 00481 00482 #define IS_USART_GET_IT(IT) (((IT) == USART_IT_PE) || ((IT) == USART_IT_TXE) || \ 00483 ((IT) == USART_IT_TC) || ((IT) == USART_IT_RXNE) || \ 00484 ((IT) == USART_IT_IDLE) || ((IT) == USART_IT_LBD) || \ 00485 ((IT) == USART_IT_CTS) || ((IT) == USART_IT_ORE) || \ 00486 ((IT) == USART_IT_NE) || ((IT) == USART_IT_FE) || \ 00487 ((IT) == USART_IT_RTO) || ((IT) == USART_IT_EOB) || \ 00488 ((IT) == USART_IT_CM) || ((IT) == USART_IT_WU)) 00489 00490 #define IS_USART_CLEAR_IT(IT) (((IT) == USART_IT_TC) || ((IT) == USART_IT_PE) || \ 00491 ((IT) == USART_IT_FE) || ((IT) == USART_IT_NE) || \ 00492 ((IT) == USART_IT_ORE) || ((IT) == USART_IT_IDLE) || \ 00493 ((IT) == USART_IT_LBD) || ((IT) == USART_IT_CTS) || \ 00494 ((IT) == USART_IT_RTO) || ((IT) == USART_IT_EOB) || \ 00495 ((IT) == USART_IT_CM) || ((IT) == USART_IT_WU)) 00496 /** 00497 * @} 00498 */ 00499 00500 /** @defgroup USART_Global_definition 00501 * @{ 00502 */ 00503 00504 #define IS_USART_BAUDRATE(BAUDRATE) (((BAUDRATE) > 0) && ((BAUDRATE) < 0x005B8D81)) 00505 #define IS_USART_DE_ASSERTION_DEASSERTION_TIME(TIME) ((TIME) <= 0x1F) 00506 #define IS_USART_AUTO_RETRY_COUNTER(COUNTER) ((COUNTER) <= 0x7) 00507 #define IS_USART_TIMEOUT(TIMEOUT) ((TIMEOUT) <= 0x00FFFFFF) 00508 #define IS_USART_DATA(DATA) ((DATA) <= 0x1FF) 00509 00510 /** 00511 * @} 00512 */ 00513 00514 /** 00515 * @} 00516 */ 00517 00518 /* Exported macro ------------------------------------------------------------*/ 00519 /* Exported functions ------------------------------------------------------- */ 00520 00521 /* Initialization and Configuration functions *********************************/ 00522 void USART_DeInit(USART_TypeDef* USARTx); 00523 void USART_Init(USART_TypeDef* USARTx, USART_InitTypeDef* USART_InitStruct); 00524 void USART_StructInit(USART_InitTypeDef* USART_InitStruct); 00525 void USART_ClockInit(USART_TypeDef* USARTx, USART_ClockInitTypeDef* USART_ClockInitStruct); 00526 void USART_ClockStructInit(USART_ClockInitTypeDef* USART_ClockInitStruct); 00527 void USART_Cmd(USART_TypeDef* USARTx, FunctionalState NewState); 00528 void USART_DirectionModeCmd(USART_TypeDef* USARTx, uint32_t USART_DirectionMode, FunctionalState NewState); 00529 void USART_SetPrescaler(USART_TypeDef* USARTx, uint8_t USART_Prescaler); 00530 void USART_OverSampling8Cmd(USART_TypeDef* USARTx, FunctionalState NewState); 00531 void USART_OneBitMethodCmd(USART_TypeDef* USARTx, FunctionalState NewState); 00532 void USART_MSBFirstCmd(USART_TypeDef* USARTx, FunctionalState NewState); 00533 void USART_DataInvCmd(USART_TypeDef* USARTx, FunctionalState NewState); 00534 void USART_InvPinCmd(USART_TypeDef* USARTx, uint32_t USART_InvPin, FunctionalState NewState); 00535 void USART_SWAPPinCmd(USART_TypeDef* USARTx, FunctionalState NewState); 00536 void USART_ReceiverTimeOutCmd(USART_TypeDef* USARTx, FunctionalState NewState); 00537 void USART_SetReceiverTimeOut(USART_TypeDef* USARTx, uint32_t USART_ReceiverTimeOut); 00538 00539 /* STOP Mode functions ********************************************************/ 00540 void USART_STOPModeCmd(USART_TypeDef* USARTx, FunctionalState NewState); 00541 void USART_StopModeWakeUpSourceConfig(USART_TypeDef* USARTx, uint32_t USART_WakeUpSource); 00542 00543 /* AutoBaudRate functions *****************************************************/ 00544 void USART_AutoBaudRateCmd(USART_TypeDef* USARTx, FunctionalState NewState); 00545 void USART_AutoBaudRateConfig(USART_TypeDef* USARTx, uint32_t USART_AutoBaudRate); 00546 00547 /* Data transfers functions ***************************************************/ 00548 void USART_SendData(USART_TypeDef* USARTx, uint16_t Data); 00549 uint16_t USART_ReceiveData(USART_TypeDef* USARTx); 00550 00551 /* Multi-Processor Communication functions ************************************/ 00552 void USART_SetAddress(USART_TypeDef* USARTx, uint8_t USART_Address); 00553 void USART_MuteModeWakeUpConfig(USART_TypeDef* USARTx, uint32_t USART_WakeUp); 00554 void USART_MuteModeCmd(USART_TypeDef* USARTx, FunctionalState NewState); 00555 void USART_AddressDetectionConfig(USART_TypeDef* USARTx, uint32_t USART_AddressLength); 00556 /* LIN mode functions *********************************************************/ 00557 void USART_LINBreakDetectLengthConfig(USART_TypeDef* USARTx, uint32_t USART_LINBreakDetectLength); 00558 void USART_LINCmd(USART_TypeDef* USARTx, FunctionalState NewState); 00559 00560 /* Half-duplex mode function **************************************************/ 00561 void USART_HalfDuplexCmd(USART_TypeDef* USARTx, FunctionalState NewState); 00562 00563 /* Smartcard mode functions ***************************************************/ 00564 void USART_SmartCardCmd(USART_TypeDef* USARTx, FunctionalState NewState); 00565 void USART_SmartCardNACKCmd(USART_TypeDef* USARTx, FunctionalState NewState); 00566 void USART_SetGuardTime(USART_TypeDef* USARTx, uint8_t USART_GuardTime); 00567 void USART_SetAutoRetryCount(USART_TypeDef* USARTx, uint8_t USART_AutoCount); 00568 void USART_SetBlockLength(USART_TypeDef* USARTx, uint8_t USART_BlockLength); 00569 00570 /* IrDA mode functions ********************************************************/ 00571 void USART_IrDAConfig(USART_TypeDef* USARTx, uint32_t USART_IrDAMode); 00572 void USART_IrDACmd(USART_TypeDef* USARTx, FunctionalState NewState); 00573 00574 /* RS485 mode functions *******************************************************/ 00575 void USART_DECmd(USART_TypeDef* USARTx, FunctionalState NewState); 00576 void USART_DEPolarityConfig(USART_TypeDef* USARTx, uint32_t USART_DEPolarity); 00577 void USART_SetDEAssertionTime(USART_TypeDef* USARTx, uint32_t USART_DEAssertionTime); 00578 void USART_SetDEDeassertionTime(USART_TypeDef* USARTx, uint32_t USART_DEDeassertionTime); 00579 00580 /* DMA transfers management functions *****************************************/ 00581 void USART_DMACmd(USART_TypeDef* USARTx, uint32_t USART_DMAReq, FunctionalState NewState); 00582 void USART_DMAReceptionErrorConfig(USART_TypeDef* USARTx, uint32_t USART_DMAOnError); 00583 00584 /* Interrupts and flags management functions **********************************/ 00585 void USART_ITConfig(USART_TypeDef* USARTx, uint32_t USART_IT, FunctionalState NewState); 00586 void USART_RequestCmd(USART_TypeDef* USARTx, uint32_t USART_Request, FunctionalState NewState); 00587 void USART_OverrunDetectionConfig(USART_TypeDef* USARTx, uint32_t USART_OVRDetection); 00588 FlagStatus USART_GetFlagStatus(USART_TypeDef* USARTx, uint32_t USART_FLAG); 00589 void USART_ClearFlag(USART_TypeDef* USARTx, uint32_t USART_FLAG); 00590 ITStatus USART_GetITStatus(USART_TypeDef* USARTx, uint32_t USART_IT); 00591 void USART_ClearITPendingBit(USART_TypeDef* USARTx, uint32_t USART_IT); 00592 00593 #ifdef __cplusplus 00594 } 00595 #endif 00596 00597 #endif /* __STM32F30x_USART_H */ 00598 00599 /** 00600 * @} 00601 */ 00602 00603 /** 00604 * @} 00605 */ 00606 00607 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Generated on Tue Jul 12 2022 17:34:45 by
