21 #ifndef __STM32F4xx_LL_USART_H
22 #define __STM32F4xx_LL_USART_H
29 #include "stm32f4xx.h"
35 #if defined (USART1) || defined (USART2) || defined (USART3) || defined (USART6) || defined (UART4) || defined (UART5) || defined (UART7) || defined (UART8) || defined (UART9) || defined (UART10)
50 #define USART_POSITION_GTPR_GT USART_GTPR_GT_Pos
56 #if defined(USE_FULL_LL_DRIVER)
66 #if defined(USE_FULL_LL_DRIVER)
95 uint32_t TransferDirection;
100 uint32_t HardwareFlowControl;
105 uint32_t OverSampling;
110 } LL_USART_InitTypeDef;
117 uint32_t ClockOutput;
124 uint32_t ClockPolarity;
136 uint32_t LastBitClockPulse;
143 } LL_USART_ClockInitTypeDef;
159 #define LL_USART_SR_PE USART_SR_PE
160 #define LL_USART_SR_FE USART_SR_FE
161 #define LL_USART_SR_NE USART_SR_NE
162 #define LL_USART_SR_ORE USART_SR_ORE
163 #define LL_USART_SR_IDLE USART_SR_IDLE
164 #define LL_USART_SR_RXNE USART_SR_RXNE
165 #define LL_USART_SR_TC USART_SR_TC
166 #define LL_USART_SR_TXE USART_SR_TXE
167 #define LL_USART_SR_LBD USART_SR_LBD
168 #define LL_USART_SR_CTS USART_SR_CTS
177 #define LL_USART_CR1_IDLEIE USART_CR1_IDLEIE
178 #define LL_USART_CR1_RXNEIE USART_CR1_RXNEIE
179 #define LL_USART_CR1_TCIE USART_CR1_TCIE
180 #define LL_USART_CR1_TXEIE USART_CR1_TXEIE
181 #define LL_USART_CR1_PEIE USART_CR1_PEIE
182 #define LL_USART_CR2_LBDIE USART_CR2_LBDIE
183 #define LL_USART_CR3_EIE USART_CR3_EIE
184 #define LL_USART_CR3_CTSIE USART_CR3_CTSIE
192 #define LL_USART_DIRECTION_NONE 0x00000000U
193 #define LL_USART_DIRECTION_RX USART_CR1_RE
194 #define LL_USART_DIRECTION_TX USART_CR1_TE
195 #define LL_USART_DIRECTION_TX_RX (USART_CR1_TE |USART_CR1_RE)
203 #define LL_USART_PARITY_NONE 0x00000000U
204 #define LL_USART_PARITY_EVEN USART_CR1_PCE
205 #define LL_USART_PARITY_ODD (USART_CR1_PCE | USART_CR1_PS)
213 #define LL_USART_WAKEUP_IDLELINE 0x00000000U
214 #define LL_USART_WAKEUP_ADDRESSMARK USART_CR1_WAKE
222 #define LL_USART_DATAWIDTH_8B 0x00000000U
223 #define LL_USART_DATAWIDTH_9B USART_CR1_M
231 #define LL_USART_OVERSAMPLING_16 0x00000000U
232 #define LL_USART_OVERSAMPLING_8 USART_CR1_OVER8
237 #if defined(USE_FULL_LL_DRIVER)
242 #define LL_USART_CLOCK_DISABLE 0x00000000U
243 #define LL_USART_CLOCK_ENABLE USART_CR2_CLKEN
252 #define LL_USART_LASTCLKPULSE_NO_OUTPUT 0x00000000U
253 #define LL_USART_LASTCLKPULSE_OUTPUT USART_CR2_LBCL
261 #define LL_USART_PHASE_1EDGE 0x00000000U
262 #define LL_USART_PHASE_2EDGE USART_CR2_CPHA
270 #define LL_USART_POLARITY_LOW 0x00000000U
271 #define LL_USART_POLARITY_HIGH USART_CR2_CPOL
279 #define LL_USART_STOPBITS_0_5 USART_CR2_STOP_0
280 #define LL_USART_STOPBITS_1 0x00000000U
281 #define LL_USART_STOPBITS_1_5 (USART_CR2_STOP_0 | USART_CR2_STOP_1)
282 #define LL_USART_STOPBITS_2 USART_CR2_STOP_1
290 #define LL_USART_HWCONTROL_NONE 0x00000000U
291 #define LL_USART_HWCONTROL_RTS USART_CR3_RTSE
292 #define LL_USART_HWCONTROL_CTS USART_CR3_CTSE
293 #define LL_USART_HWCONTROL_RTS_CTS (USART_CR3_RTSE | USART_CR3_CTSE)
301 #define LL_USART_IRDA_POWER_NORMAL 0x00000000U
302 #define LL_USART_IRDA_POWER_LOW USART_CR3_IRLP
310 #define LL_USART_LINBREAK_DETECT_10B 0x00000000U
311 #define LL_USART_LINBREAK_DETECT_11B USART_CR2_LBDL
336 #define LL_USART_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
344 #define LL_USART_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
360 #define __LL_USART_DIV_SAMPLING8_100(__PERIPHCLK__, __BAUDRATE__) ((uint32_t)((((uint64_t)(__PERIPHCLK__))*25)/(2*((uint64_t)(__BAUDRATE__)))))
361 #define __LL_USART_DIVMANT_SAMPLING8(__PERIPHCLK__, __BAUDRATE__) (__LL_USART_DIV_SAMPLING8_100((__PERIPHCLK__), (__BAUDRATE__))/100)
362 #define __LL_USART_DIVFRAQ_SAMPLING8(__PERIPHCLK__, __BAUDRATE__) ((((__LL_USART_DIV_SAMPLING8_100((__PERIPHCLK__), (__BAUDRATE__)) - (__LL_USART_DIVMANT_SAMPLING8((__PERIPHCLK__), (__BAUDRATE__)) * 100)) * 8) + 50) / 100)
365 #define __LL_USART_DIV_SAMPLING8(__PERIPHCLK__, __BAUDRATE__) (((__LL_USART_DIVMANT_SAMPLING8((__PERIPHCLK__), (__BAUDRATE__)) << 4) + \
366 ((__LL_USART_DIVFRAQ_SAMPLING8((__PERIPHCLK__), (__BAUDRATE__)) & 0xF8) << 1)) + \
367 (__LL_USART_DIVFRAQ_SAMPLING8((__PERIPHCLK__), (__BAUDRATE__)) & 0x07))
376 #define __LL_USART_DIV_SAMPLING16_100(__PERIPHCLK__, __BAUDRATE__) ((uint32_t)((((uint64_t)(__PERIPHCLK__))*25)/(4*((uint64_t)(__BAUDRATE__)))))
377 #define __LL_USART_DIVMANT_SAMPLING16(__PERIPHCLK__, __BAUDRATE__) (__LL_USART_DIV_SAMPLING16_100((__PERIPHCLK__), (__BAUDRATE__))/100)
378 #define __LL_USART_DIVFRAQ_SAMPLING16(__PERIPHCLK__, __BAUDRATE__) ((((__LL_USART_DIV_SAMPLING16_100((__PERIPHCLK__), (__BAUDRATE__)) - (__LL_USART_DIVMANT_SAMPLING16((__PERIPHCLK__), (__BAUDRATE__)) * 100)) * 16) + 50) / 100)
381 #define __LL_USART_DIV_SAMPLING16(__PERIPHCLK__, __BAUDRATE__) (((__LL_USART_DIVMANT_SAMPLING16((__PERIPHCLK__), (__BAUDRATE__)) << 4) + \
382 (__LL_USART_DIVFRAQ_SAMPLING16((__PERIPHCLK__), (__BAUDRATE__)) & 0xF0)) + \
383 (__LL_USART_DIVFRAQ_SAMPLING16((__PERIPHCLK__), (__BAUDRATE__)) & 0x0F))
1022 if (OverSampling == LL_USART_OVERSAMPLING_8)
1024 USARTx->
BRR = (uint16_t)(__LL_USART_DIV_SAMPLING8(PeriphClk, BaudRate));
1028 USARTx->
BRR = (uint16_t)(__LL_USART_DIV_SAMPLING16(PeriphClk, BaudRate));
1046 register uint32_t usartdiv = 0x0U;
1047 register uint32_t brrresult = 0x0U;
1049 usartdiv = USARTx->
BRR;
1051 if (OverSampling == LL_USART_OVERSAMPLING_8)
1053 if ((usartdiv & 0xFFF7U) != 0U)
1055 usartdiv = (uint16_t)((usartdiv & 0xFFF0U) | ((usartdiv & 0x0007U) << 1U)) ;
1056 brrresult = (PeriphClk * 2U) / usartdiv;
1061 if ((usartdiv & 0xFFFFU) != 0U)
1063 brrresult = PeriphClk / usartdiv;
1878 __IO uint32_t tmpreg;
1879 tmpreg = USARTx->
SR;
1881 tmpreg = USARTx->
DR;
1897 __IO uint32_t tmpreg;
1898 tmpreg = USARTx->
SR;
1900 tmpreg = USARTx->
DR;
1916 __IO uint32_t tmpreg;
1917 tmpreg = USARTx->
SR;
1919 tmpreg = USARTx->
DR;
1935 __IO uint32_t tmpreg;
1936 tmpreg = USARTx->
SR;
1938 tmpreg = USARTx->
DR;
1954 __IO uint32_t tmpreg;
1955 tmpreg = USARTx->
SR;
1957 tmpreg = USARTx->
DR;
2385 return ((uint32_t) & (USARTx->
DR));
2439 USARTx->
DR = Value & 0x1FFU;
2487 #if defined(USE_FULL_LL_DRIVER)
2493 void LL_USART_StructInit(LL_USART_InitTypeDef *USART_InitStruct);
2495 void LL_USART_ClockStructInit(LL_USART_ClockInitTypeDef *USART_ClockInitStruct);