stm32f4xx_ll_usart.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. /**
  2. ******************************************************************************
  3. * @file stm32f4xx_ll_usart.c
  4. * @author MCD Application Team
  5. * @brief USART LL module driver.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  10. *
  11. * Redistribution and use in source and binary forms, with or without modification,
  12. * are permitted provided that the following conditions are met:
  13. * 1. Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  19. * may be used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  25. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  26. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  28. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  29. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  30. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. *
  33. ******************************************************************************
  34. */
  35. #if defined(USE_FULL_LL_DRIVER)
  36. /* Includes ------------------------------------------------------------------*/
  37. #include "stm32f4xx_ll_usart.h"
  38. #include "stm32f4xx_ll_rcc.h"
  39. #include "stm32f4xx_ll_bus.h"
  40. #ifdef USE_FULL_ASSERT
  41. #include "stm32_assert.h"
  42. #else
  43. #define assert_param(expr) ((void)0U)
  44. #endif
  45. /** @addtogroup STM32F4xx_LL_Driver
  46. * @{
  47. */
  48. #if defined (USART1) || defined (USART2) || defined (USART3) || defined (USART6) || defined (UART4) || defined (UART5) || defined (UART7) || defined (UART8) || defined (UART9) || defined (UART10)
  49. /** @addtogroup USART_LL
  50. * @{
  51. */
  52. /* Private types -------------------------------------------------------------*/
  53. /* Private variables ---------------------------------------------------------*/
  54. /* Private constants ---------------------------------------------------------*/
  55. /** @addtogroup USART_LL_Private_Constants
  56. * @{
  57. */
  58. /**
  59. * @}
  60. */
  61. /* Private macros ------------------------------------------------------------*/
  62. /** @addtogroup USART_LL_Private_Macros
  63. * @{
  64. */
  65. /* __BAUDRATE__ The maximum Baud Rate is derived from the maximum clock available
  66. * divided by the smallest oversampling used on the USART (i.e. 8) */
  67. #define IS_LL_USART_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) <= 12500000U)
  68. /* __VALUE__ In case of oversampling by 16 and 8, BRR content must be greater than or equal to 16d. */
  69. #define IS_LL_USART_BRR_MIN(__VALUE__) ((__VALUE__) >= 16U)
  70. /* __VALUE__ BRR content must be lower than or equal to 0xFFFF. */
  71. #define IS_LL_USART_BRR_MAX(__VALUE__) ((__VALUE__) <= 0x0000FFFFU)
  72. #define IS_LL_USART_DIRECTION(__VALUE__) (((__VALUE__) == LL_USART_DIRECTION_NONE) \
  73. || ((__VALUE__) == LL_USART_DIRECTION_RX) \
  74. || ((__VALUE__) == LL_USART_DIRECTION_TX) \
  75. || ((__VALUE__) == LL_USART_DIRECTION_TX_RX))
  76. #define IS_LL_USART_PARITY(__VALUE__) (((__VALUE__) == LL_USART_PARITY_NONE) \
  77. || ((__VALUE__) == LL_USART_PARITY_EVEN) \
  78. || ((__VALUE__) == LL_USART_PARITY_ODD))
  79. #define IS_LL_USART_DATAWIDTH(__VALUE__) (((__VALUE__) == LL_USART_DATAWIDTH_8B) \
  80. || ((__VALUE__) == LL_USART_DATAWIDTH_9B))
  81. #define IS_LL_USART_OVERSAMPLING(__VALUE__) (((__VALUE__) == LL_USART_OVERSAMPLING_16) \
  82. || ((__VALUE__) == LL_USART_OVERSAMPLING_8))
  83. #define IS_LL_USART_LASTBITCLKOUTPUT(__VALUE__) (((__VALUE__) == LL_USART_LASTCLKPULSE_NO_OUTPUT) \
  84. || ((__VALUE__) == LL_USART_LASTCLKPULSE_OUTPUT))
  85. #define IS_LL_USART_CLOCKPHASE(__VALUE__) (((__VALUE__) == LL_USART_PHASE_1EDGE) \
  86. || ((__VALUE__) == LL_USART_PHASE_2EDGE))
  87. #define IS_LL_USART_CLOCKPOLARITY(__VALUE__) (((__VALUE__) == LL_USART_POLARITY_LOW) \
  88. || ((__VALUE__) == LL_USART_POLARITY_HIGH))
  89. #define IS_LL_USART_CLOCKOUTPUT(__VALUE__) (((__VALUE__) == LL_USART_CLOCK_DISABLE) \
  90. || ((__VALUE__) == LL_USART_CLOCK_ENABLE))
  91. #define IS_LL_USART_STOPBITS(__VALUE__) (((__VALUE__) == LL_USART_STOPBITS_0_5) \
  92. || ((__VALUE__) == LL_USART_STOPBITS_1) \
  93. || ((__VALUE__) == LL_USART_STOPBITS_1_5) \
  94. || ((__VALUE__) == LL_USART_STOPBITS_2))
  95. #define IS_LL_USART_HWCONTROL(__VALUE__) (((__VALUE__) == LL_USART_HWCONTROL_NONE) \
  96. || ((__VALUE__) == LL_USART_HWCONTROL_RTS) \
  97. || ((__VALUE__) == LL_USART_HWCONTROL_CTS) \
  98. || ((__VALUE__) == LL_USART_HWCONTROL_RTS_CTS))
  99. /**
  100. * @}
  101. */
  102. /* Private function prototypes -----------------------------------------------*/
  103. /* Exported functions --------------------------------------------------------*/
  104. /** @addtogroup USART_LL_Exported_Functions
  105. * @{
  106. */
  107. /** @addtogroup USART_LL_EF_Init
  108. * @{
  109. */
  110. /**
  111. * @brief De-initialize USART registers (Registers restored to their default values).
  112. * @param USARTx USART Instance
  113. * @retval An ErrorStatus enumeration value:
  114. * - SUCCESS: USART registers are de-initialized
  115. * - ERROR: USART registers are not de-initialized
  116. */
  117. ErrorStatus LL_USART_DeInit(USART_TypeDef *USARTx)
  118. {
  119. ErrorStatus status = SUCCESS;
  120. /* Check the parameters */
  121. assert_param(IS_UART_INSTANCE(USARTx));
  122. if (USARTx == USART1)
  123. {
  124. /* Force reset of USART clock */
  125. LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_USART1);
  126. /* Release reset of USART clock */
  127. LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_USART1);
  128. }
  129. else if (USARTx == USART2)
  130. {
  131. /* Force reset of USART clock */
  132. LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_USART2);
  133. /* Release reset of USART clock */
  134. LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_USART2);
  135. }
  136. #if defined(USART3)
  137. else if (USARTx == USART3)
  138. {
  139. /* Force reset of USART clock */
  140. LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_USART3);
  141. /* Release reset of USART clock */
  142. LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_USART3);
  143. }
  144. #endif /* USART3 */
  145. #if defined(USART6)
  146. else if (USARTx == USART6)
  147. {
  148. /* Force reset of USART clock */
  149. LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_USART6);
  150. /* Release reset of USART clock */
  151. LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_USART6);
  152. }
  153. #endif /* USART6 */
  154. #if defined(UART4)
  155. else if (USARTx == UART4)
  156. {
  157. /* Force reset of UART clock */
  158. LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_UART4);
  159. /* Release reset of UART clock */
  160. LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_UART4);
  161. }
  162. #endif /* UART4 */
  163. #if defined(UART5)
  164. else if (USARTx == UART5)
  165. {
  166. /* Force reset of UART clock */
  167. LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_UART5);
  168. /* Release reset of UART clock */
  169. LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_UART5);
  170. }
  171. #endif /* UART5 */
  172. #if defined(UART7)
  173. else if (USARTx == UART7)
  174. {
  175. /* Force reset of UART clock */
  176. LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_UART7);
  177. /* Release reset of UART clock */
  178. LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_UART7);
  179. }
  180. #endif /* UART7 */
  181. #if defined(UART8)
  182. else if (USARTx == UART8)
  183. {
  184. /* Force reset of UART clock */
  185. LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_UART8);
  186. /* Release reset of UART clock */
  187. LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_UART8);
  188. }
  189. #endif /* UART8 */
  190. #if defined(UART9)
  191. else if (USARTx == UART9)
  192. {
  193. /* Force reset of UART clock */
  194. LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_UART9);
  195. /* Release reset of UART clock */
  196. LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_UART9);
  197. }
  198. #endif /* UART9 */
  199. #if defined(UART10)
  200. else if (USARTx == UART10)
  201. {
  202. /* Force reset of UART clock */
  203. LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_UART10);
  204. /* Release reset of UART clock */
  205. LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_UART10);
  206. }
  207. #endif /* UART10 */
  208. else
  209. {
  210. status = ERROR;
  211. }
  212. return (status);
  213. }
  214. /**
  215. * @brief Initialize USART registers according to the specified
  216. * parameters in USART_InitStruct.
  217. * @note As some bits in USART configuration registers can only be written when the USART is disabled (USART_CR1_UE bit =0),
  218. * USART IP should be in disabled state prior calling this function. Otherwise, ERROR result will be returned.
  219. * @note Baud rate value stored in USART_InitStruct BaudRate field, should be valid (different from 0).
  220. * @param USARTx USART Instance
  221. * @param USART_InitStruct pointer to a LL_USART_InitTypeDef structure
  222. * that contains the configuration information for the specified USART peripheral.
  223. * @retval An ErrorStatus enumeration value:
  224. * - SUCCESS: USART registers are initialized according to USART_InitStruct content
  225. * - ERROR: Problem occurred during USART Registers initialization
  226. */
  227. ErrorStatus LL_USART_Init(USART_TypeDef *USARTx, LL_USART_InitTypeDef *USART_InitStruct)
  228. {
  229. ErrorStatus status = ERROR;
  230. uint32_t periphclk = LL_RCC_PERIPH_FREQUENCY_NO;
  231. LL_RCC_ClocksTypeDef rcc_clocks;
  232. /* Check the parameters */
  233. assert_param(IS_UART_INSTANCE(USARTx));
  234. assert_param(IS_LL_USART_BAUDRATE(USART_InitStruct->BaudRate));
  235. assert_param(IS_LL_USART_DATAWIDTH(USART_InitStruct->DataWidth));
  236. assert_param(IS_LL_USART_STOPBITS(USART_InitStruct->StopBits));
  237. assert_param(IS_LL_USART_PARITY(USART_InitStruct->Parity));
  238. assert_param(IS_LL_USART_DIRECTION(USART_InitStruct->TransferDirection));
  239. assert_param(IS_LL_USART_HWCONTROL(USART_InitStruct->HardwareFlowControl));
  240. assert_param(IS_LL_USART_OVERSAMPLING(USART_InitStruct->OverSampling));
  241. /* USART needs to be in disabled state, in order to be able to configure some bits in
  242. CRx registers */
  243. if (LL_USART_IsEnabled(USARTx) == 0U)
  244. {
  245. /*---------------------------- USART CR1 Configuration -----------------------
  246. * Configure USARTx CR1 (USART Word Length, Parity, Mode and Oversampling bits) with parameters:
  247. * - DataWidth: USART_CR1_M bits according to USART_InitStruct->DataWidth value
  248. * - Parity: USART_CR1_PCE, USART_CR1_PS bits according to USART_InitStruct->Parity value
  249. * - TransferDirection: USART_CR1_TE, USART_CR1_RE bits according to USART_InitStruct->TransferDirection value
  250. * - Oversampling: USART_CR1_OVER8 bit according to USART_InitStruct->OverSampling value.
  251. */
  252. MODIFY_REG(USARTx->CR1,
  253. (USART_CR1_M | USART_CR1_PCE | USART_CR1_PS |
  254. USART_CR1_TE | USART_CR1_RE | USART_CR1_OVER8),
  255. (USART_InitStruct->DataWidth | USART_InitStruct->Parity |
  256. USART_InitStruct->TransferDirection | USART_InitStruct->OverSampling));
  257. /*---------------------------- USART CR2 Configuration -----------------------
  258. * Configure USARTx CR2 (Stop bits) with parameters:
  259. * - Stop Bits: USART_CR2_STOP bits according to USART_InitStruct->StopBits value.
  260. * - CLKEN, CPOL, CPHA and LBCL bits are to be configured using LL_USART_ClockInit().
  261. */
  262. LL_USART_SetStopBitsLength(USARTx, USART_InitStruct->StopBits);
  263. /*---------------------------- USART CR3 Configuration -----------------------
  264. * Configure USARTx CR3 (Hardware Flow Control) with parameters:
  265. * - HardwareFlowControl: USART_CR3_RTSE, USART_CR3_CTSE bits according to USART_InitStruct->HardwareFlowControl value.
  266. */
  267. LL_USART_SetHWFlowCtrl(USARTx, USART_InitStruct->HardwareFlowControl);
  268. /*---------------------------- USART BRR Configuration -----------------------
  269. * Retrieve Clock frequency used for USART Peripheral
  270. */
  271. LL_RCC_GetSystemClocksFreq(&rcc_clocks);
  272. if (USARTx == USART1)
  273. {
  274. periphclk = rcc_clocks.PCLK2_Frequency;
  275. }
  276. else if (USARTx == USART2)
  277. {
  278. periphclk = rcc_clocks.PCLK1_Frequency;
  279. }
  280. #if defined(USART3)
  281. else if (USARTx == USART3)
  282. {
  283. periphclk = rcc_clocks.PCLK1_Frequency;
  284. }
  285. #endif /* USART3 */
  286. #if defined(USART6)
  287. else if (USARTx == USART6)
  288. {
  289. periphclk = rcc_clocks.PCLK2_Frequency;
  290. }
  291. #endif /* USART6 */
  292. #if defined(UART4)
  293. else if (USARTx == UART4)
  294. {
  295. periphclk = rcc_clocks.PCLK1_Frequency;
  296. }
  297. #endif /* UART4 */
  298. #if defined(UART5)
  299. else if (USARTx == UART5)
  300. {
  301. periphclk = rcc_clocks.PCLK1_Frequency;
  302. }
  303. #endif /* UART5 */
  304. #if defined(UART7)
  305. else if (USARTx == UART7)
  306. {
  307. periphclk = rcc_clocks.PCLK1_Frequency;
  308. }
  309. #endif /* UART7 */
  310. #if defined(UART8)
  311. else if (USARTx == UART8)
  312. {
  313. periphclk = rcc_clocks.PCLK1_Frequency;
  314. }
  315. #endif /* UART8 */
  316. #if defined(UART9)
  317. else if (USARTx == UART9)
  318. {
  319. periphclk = rcc_clocks.PCLK1_Frequency;
  320. }
  321. #endif /* UART9 */
  322. #if defined(UART10)
  323. else if (USARTx == UART10)
  324. {
  325. periphclk = rcc_clocks.PCLK1_Frequency;
  326. }
  327. #endif /* UART10 */
  328. else
  329. {
  330. /* Nothing to do, as error code is already assigned to ERROR value */
  331. }
  332. /* Configure the USART Baud Rate :
  333. - valid baud rate value (different from 0) is required
  334. - Peripheral clock as returned by RCC service, should be valid (different from 0).
  335. */
  336. if ((periphclk != LL_RCC_PERIPH_FREQUENCY_NO)
  337. && (USART_InitStruct->BaudRate != 0U))
  338. {
  339. status = SUCCESS;
  340. LL_USART_SetBaudRate(USARTx,
  341. periphclk,
  342. USART_InitStruct->OverSampling,
  343. USART_InitStruct->BaudRate);
  344. /* Check BRR is greater than or equal to 16d */
  345. assert_param(IS_LL_USART_BRR_MIN(USARTx->BRR));
  346. /* Check BRR is greater than or equal to 16d */
  347. assert_param(IS_LL_USART_BRR_MAX(USARTx->BRR));
  348. }
  349. }
  350. /* Endif (=> USART not in Disabled state => return ERROR) */
  351. return (status);
  352. }
  353. /**
  354. * @brief Set each @ref LL_USART_InitTypeDef field to default value.
  355. * @param USART_InitStruct pointer to a @ref LL_USART_InitTypeDef structure
  356. * whose fields will be set to default values.
  357. * @retval None
  358. */
  359. void LL_USART_StructInit(LL_USART_InitTypeDef *USART_InitStruct)
  360. {
  361. /* Set USART_InitStruct fields to default values */
  362. USART_InitStruct->BaudRate = 9600U;
  363. USART_InitStruct->DataWidth = LL_USART_DATAWIDTH_8B;
  364. USART_InitStruct->StopBits = LL_USART_STOPBITS_1;
  365. USART_InitStruct->Parity = LL_USART_PARITY_NONE ;
  366. USART_InitStruct->TransferDirection = LL_USART_DIRECTION_TX_RX;
  367. USART_InitStruct->HardwareFlowControl = LL_USART_HWCONTROL_NONE;
  368. USART_InitStruct->OverSampling = LL_USART_OVERSAMPLING_16;
  369. }
  370. /**
  371. * @brief Initialize USART Clock related settings according to the
  372. * specified parameters in the USART_ClockInitStruct.
  373. * @note As some bits in USART configuration registers can only be written when the USART is disabled (USART_CR1_UE bit =0),
  374. * USART IP should be in disabled state prior calling this function. Otherwise, ERROR result will be returned.
  375. * @param USARTx USART Instance
  376. * @param USART_ClockInitStruct pointer to a @ref LL_USART_ClockInitTypeDef structure
  377. * that contains the Clock configuration information for the specified USART peripheral.
  378. * @retval An ErrorStatus enumeration value:
  379. * - SUCCESS: USART registers related to Clock settings are initialized according to USART_ClockInitStruct content
  380. * - ERROR: Problem occurred during USART Registers initialization
  381. */
  382. ErrorStatus LL_USART_ClockInit(USART_TypeDef *USARTx, LL_USART_ClockInitTypeDef *USART_ClockInitStruct)
  383. {
  384. ErrorStatus status = SUCCESS;
  385. /* Check USART Instance and Clock signal output parameters */
  386. assert_param(IS_UART_INSTANCE(USARTx));
  387. assert_param(IS_LL_USART_CLOCKOUTPUT(USART_ClockInitStruct->ClockOutput));
  388. /* USART needs to be in disabled state, in order to be able to configure some bits in
  389. CRx registers */
  390. if (LL_USART_IsEnabled(USARTx) == 0U)
  391. {
  392. /*---------------------------- USART CR2 Configuration -----------------------*/
  393. /* If Clock signal has to be output */
  394. if (USART_ClockInitStruct->ClockOutput == LL_USART_CLOCK_DISABLE)
  395. {
  396. /* Deactivate Clock signal delivery :
  397. * - Disable Clock Output: USART_CR2_CLKEN cleared
  398. */
  399. LL_USART_DisableSCLKOutput(USARTx);
  400. }
  401. else
  402. {
  403. /* Ensure USART instance is USART capable */
  404. assert_param(IS_USART_INSTANCE(USARTx));
  405. /* Check clock related parameters */
  406. assert_param(IS_LL_USART_CLOCKPOLARITY(USART_ClockInitStruct->ClockPolarity));
  407. assert_param(IS_LL_USART_CLOCKPHASE(USART_ClockInitStruct->ClockPhase));
  408. assert_param(IS_LL_USART_LASTBITCLKOUTPUT(USART_ClockInitStruct->LastBitClockPulse));
  409. /*---------------------------- USART CR2 Configuration -----------------------
  410. * Configure USARTx CR2 (Clock signal related bits) with parameters:
  411. * - Enable Clock Output: USART_CR2_CLKEN set
  412. * - Clock Polarity: USART_CR2_CPOL bit according to USART_ClockInitStruct->ClockPolarity value
  413. * - Clock Phase: USART_CR2_CPHA bit according to USART_ClockInitStruct->ClockPhase value
  414. * - Last Bit Clock Pulse Output: USART_CR2_LBCL bit according to USART_ClockInitStruct->LastBitClockPulse value.
  415. */
  416. MODIFY_REG(USARTx->CR2,
  417. USART_CR2_CLKEN | USART_CR2_CPHA | USART_CR2_CPOL | USART_CR2_LBCL,
  418. USART_CR2_CLKEN | USART_ClockInitStruct->ClockPolarity |
  419. USART_ClockInitStruct->ClockPhase | USART_ClockInitStruct->LastBitClockPulse);
  420. }
  421. }
  422. /* Else (USART not in Disabled state => return ERROR */
  423. else
  424. {
  425. status = ERROR;
  426. }
  427. return (status);
  428. }
  429. /**
  430. * @brief Set each field of a @ref LL_USART_ClockInitTypeDef type structure to default value.
  431. * @param USART_ClockInitStruct pointer to a @ref LL_USART_ClockInitTypeDef structure
  432. * whose fields will be set to default values.
  433. * @retval None
  434. */
  435. void LL_USART_ClockStructInit(LL_USART_ClockInitTypeDef *USART_ClockInitStruct)
  436. {
  437. /* Set LL_USART_ClockInitStruct fields with default values */
  438. USART_ClockInitStruct->ClockOutput = LL_USART_CLOCK_DISABLE;
  439. USART_ClockInitStruct->ClockPolarity = LL_USART_POLARITY_LOW; /* Not relevant when ClockOutput = LL_USART_CLOCK_DISABLE */
  440. USART_ClockInitStruct->ClockPhase = LL_USART_PHASE_1EDGE; /* Not relevant when ClockOutput = LL_USART_CLOCK_DISABLE */
  441. USART_ClockInitStruct->LastBitClockPulse = LL_USART_LASTCLKPULSE_NO_OUTPUT; /* Not relevant when ClockOutput = LL_USART_CLOCK_DISABLE */
  442. }
  443. /**
  444. * @}
  445. */
  446. /**
  447. * @}
  448. */
  449. /**
  450. * @}
  451. */
  452. #endif /* USART1 || USART2 || USART3 || USART6 || UART4 || UART5 || UART7 || UART8 || UART9 || UART10 */
  453. /**
  454. * @}
  455. */
  456. #endif /* USE_FULL_LL_DRIVER */
  457. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/